@unchainedshop/admin-ui 4.8.33 → 4.9.0

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.
Files changed (89) hide show
  1. package/out/403/index.html +3 -3
  2. package/out/404/index.html +3 -3
  3. package/out/404.html +3 -3
  4. package/out/423/index.html +3 -3
  5. package/out/500/index.html +3 -3
  6. package/out/_next/static/chunks/{2wmsx4gjbgvfv.js → 0bc8hmxlcg6h5.js} +5 -5
  7. package/out/_next/static/chunks/{07o9g5hqfpvjc.js → 0djb38xrt32ao.js} +1 -1
  8. package/out/_next/static/chunks/{23swqksldp1rl.js → 0drw_p7p-jjq1.js} +2 -2
  9. package/out/_next/static/chunks/{2rb1-3t3-sv5s.js → 0hz0qu27uks3z.js} +2 -2
  10. package/out/_next/static/chunks/{1s9v5dndopkuz.js → 0rzjz052fwjjc.js} +1 -1
  11. package/out/_next/static/chunks/170d-jbu8ilzu.js +100 -0
  12. package/out/_next/static/chunks/1a9-pdm78ri7r.js +1 -0
  13. package/out/_next/static/chunks/{3q3m075m4bxz1.js → 1epju6xepfqtq.js} +2 -2
  14. package/out/_next/static/chunks/{1qi5yjvzxspwv.js → 1r0w-hk6d2kqw.js} +1 -1
  15. package/out/_next/static/chunks/25frktmrq-xu0.js +1 -0
  16. package/out/_next/static/chunks/{2jonbba27xy3u.js → 2cclew3l28rc4.js} +1 -1
  17. package/out/_next/static/chunks/{1f7-0l47bx76m.js → 2olb298bph2yc.js} +1 -1
  18. package/out/_next/static/chunks/{11go520d1hcm5.js → 33_-2ne9ecvay.js} +1 -1
  19. package/out/_next/static/chunks/33qeilxkl3ckn.js +116 -0
  20. package/out/_next/static/chunks/{33yzdcbu7w60l.js → 33tewe5d_lfl-.js} +1 -1
  21. package/out/_next/static/chunks/{0qj3xdz043z8l.js → 3i9q2-4e0mix5.js} +1 -1
  22. package/out/_next/static/chunks/3m4smrmdqi2-3.js +5 -0
  23. package/out/_next/static/chunks/{1g96s7-fwvokd.js → 3zw4-oie-f7_0.js} +1 -1
  24. package/out/_next/static/{LYf4c16v7ZGmJ_J77NFgQ → nrNmgRi1nHylx_8lvjG2D}/_buildManifest.js +10 -10
  25. package/out/_offline/index.html +3 -3
  26. package/out/account/forgot-password/index.html +3 -3
  27. package/out/account/index.html +3 -3
  28. package/out/assortments/AssortmentDetailPage/index.html +3 -3
  29. package/out/assortments/index.html +3 -3
  30. package/out/assortments/new/index.html +3 -3
  31. package/out/copilot/index.html +3 -3
  32. package/out/country/CountryDetailPage/index.html +3 -3
  33. package/out/country/index.html +3 -3
  34. package/out/country/new/index.html +3 -3
  35. package/out/currency/CurrencyDetailPage/index.html +3 -3
  36. package/out/currency/index.html +3 -3
  37. package/out/currency/new/index.html +3 -3
  38. package/out/delivery-provider/DeliveryProviderDetailPage/index.html +3 -3
  39. package/out/delivery-provider/index.html +3 -3
  40. package/out/delivery-provider/new/index.html +3 -3
  41. package/out/enrollments/EnrollmentDetailPage/index.html +3 -3
  42. package/out/enrollments/index.html +3 -3
  43. package/out/events/EventDetailPage/index.html +3 -3
  44. package/out/events/index.html +3 -3
  45. package/out/exports/index.html +3 -3
  46. package/out/external/index.html +3 -3
  47. package/out/filters/FilterDetailPage/index.html +3 -3
  48. package/out/filters/index.html +3 -3
  49. package/out/filters/new/index.html +3 -3
  50. package/out/index.html +3 -3
  51. package/out/install/index.html +3 -3
  52. package/out/language/LanguageDetailPage/index.html +3 -3
  53. package/out/language/index.html +3 -3
  54. package/out/language/new/index.html +3 -3
  55. package/out/log-in/index.html +3 -3
  56. package/out/orders/OrderDetailPage/index.html +3 -3
  57. package/out/orders/index.html +3 -3
  58. package/out/payment-provider/PaymentProviderDetailPage/index.html +3 -3
  59. package/out/payment-provider/index.html +3 -3
  60. package/out/payment-provider/new/index.html +3 -3
  61. package/out/products/ProductDetailPage/index.html +3 -3
  62. package/out/products/index.html +3 -3
  63. package/out/products/new/index.html +3 -3
  64. package/out/quotations/QuotationDetailPage/index.html +3 -3
  65. package/out/quotations/index.html +3 -3
  66. package/out/reset-password/index.html +3 -3
  67. package/out/sign-up/index.html +3 -3
  68. package/out/styleguide/index.html +3 -3
  69. package/out/tokens/TokenDetailPage/index.html +3 -3
  70. package/out/tokens/index.html +3 -3
  71. package/out/users/UserDetailPage/index.html +3 -3
  72. package/out/users/index.html +3 -3
  73. package/out/users/new/index.html +3 -3
  74. package/out/verify-email/index.html +3 -3
  75. package/out/warehousing-provider/WarehousingProviderDetailPage/index.html +3 -3
  76. package/out/warehousing-provider/index.html +3 -3
  77. package/out/warehousing-provider/new/index.html +3 -3
  78. package/out/works/WorkDetailPage/index.html +3 -3
  79. package/out/works/WorkQueueListView/index.html +3 -3
  80. package/out/works/index.html +3 -3
  81. package/out/works/management/index.html +3 -3
  82. package/package.json +18 -18
  83. package/out/_next/static/chunks/0a5nr3-_q7xx1.js +0 -100
  84. package/out/_next/static/chunks/1sksqjru86hlm.js +0 -1
  85. package/out/_next/static/chunks/2cj8g3fxmitaa.js +0 -1
  86. package/out/_next/static/chunks/3bqaitmo4sp-a.js +0 -116
  87. package/out/_next/static/chunks/3wlvio5id54ow.js +0 -5
  88. /package/out/_next/static/{LYf4c16v7ZGmJ_J77NFgQ → nrNmgRi1nHylx_8lvjG2D}/_clientMiddlewareManifest.js +0 -0
  89. /package/out/_next/static/{LYf4c16v7ZGmJ_J77NFgQ → nrNmgRi1nHylx_8lvjG2D}/_ssgManifest.js +0 -0
@@ -1,100 +0,0 @@
1
- (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,[95377,16717,e=>{let t,r,a,n,i,o,s,l,u,c,d,p;e.s(["BIGINT_FORMAT_RANGES",()=>eD,"CONSTANT_CATCH",()=>tf,"Class",()=>tn,"NUMBER_FORMAT_RANGES",()=>ej,"aborted",()=>eW,"allowsEval",()=>eE,"assert",()=>Y,"assertEqual",()=>H,"assertIs",()=>G,"assertNever",()=>K,"assertNotEqual",()=>J,"assignProp",()=>eu,"attachSchema",()=>eQ,"base64ToUint8Array",()=>e8,"base64urlToUint8Array",()=>te,"cached",()=>er,"captureStackTrace",()=>ek,"cleanEnum",()=>e3,"cleanRegex",()=>en,"clone",()=>eR,"cloneDef",()=>eg,"codePointLength",()=>e4,"constantCatch",()=>th,"createTransparentProxy",()=>eP,"defineLazy",()=>es,"defineLazyInternal",()=>td,"derived",()=>tl,"esc",()=>ew,"escapeRegex",()=>ez,"explicitlyAborted",()=>eG,"extend",()=>eF,"finalizeIssue",()=>e0,"floatSafeRemainder",()=>ei,"getElementAtPath",()=>ey,"getEnumValues",()=>X,"getLengthableOrigin",()=>e5,"getParsedType",()=>eT,"getSizableOrigin",()=>e1,"hexToUint8Array",()=>tr,"hide",()=>ts,"installLazyProp",()=>tp,"isObject",()=>eS,"isPlainObject",()=>ex,"issue",()=>e9,"joinValues",()=>Q,"jsonStringifyReplacer",()=>ee,"members",()=>ti,"merge",()=>eV,"mergeDefs",()=>em,"normalizeParams",()=>eC,"nullish",()=>ea,"numKeys",()=>eA,"objectClone",()=>el,"omit",()=>eL,"optionalKeys",()=>eN,"own",()=>to,"parsedType",()=>e6,"partial",()=>eH,"pick",()=>eU,"prefixIssues",()=>eK,"primitiveTypes",()=>eM,"promiseAllObject",()=>ev,"propertyKeyTypes",()=>eO,"randomString",()=>eb,"rawShape",()=>ec,"required",()=>eJ,"safeExtend",()=>eq,"shallowClone",()=>eI,"sizeCaps",()=>eX,"slugify",()=>e_,"stringifyPrimitive",()=>e$,"toZod",()=>W,"uint8ArrayToBase64",()=>e7,"uint8ArrayToBase64url",()=>tt,"uint8ArrayToHex",()=>ta,"unwrapMessage",()=>eY],39604);var f,h,m=e.i(91398),g=e.i(91788),y=e.i(50461);let v="vercel.ai.error",b=Symbol.for(v);var w=class e extends Error{constructor({name:e,message:t,cause:r}){super(t),this[b]=!0,this.name=e,this.cause=r}static isInstance(t){return e.hasMarker(t,v)}static hasMarker(e,t){let r=Symbol.for(t);return null!=e&&"object"==typeof e&&r in e&&"boolean"==typeof e[r]&&!0===e[r]}};Symbol.for("vercel.ai.error.AI_DecisionUnsupportedQuestionTypeError");let _="AI_APICallError",k=`vercel.ai.error.${_}`,S=Symbol.for(k);var E=class extends w{constructor({message:e,url:t,requestBodyValues:r,statusCode:a,responseHeaders:n,responseBody:i,cause:o,isRetryable:s=null!=a&&(408===a||409===a||429===a||a>=500),data:l}){super({name:_,message:e,cause:o}),this[S]=!0,this.url=t,this.requestBodyValues=r,this.statusCode=a,this.responseHeaders=n,this.responseBody=i,this.isRetryable=s,this.data=l}static isInstance(e){return w.hasMarker(e,k)}};let x="AI_EmptyResponseBodyError",I=`vercel.ai.error.${x}`,A=Symbol.for(I);var T=class extends w{constructor({message:e="Empty response body"}={}){super({name:x,message:e}),this[A]=!0}static isInstance(e){return w.hasMarker(e,I)}};function O(e){return null==e?"unknown error":"string"==typeof e?e:e instanceof Error?e.toString():JSON.stringify(e)}Symbol.for("vercel.ai.error.AI_DecisionRefusalError");let M="AI_InvalidArgumentError",z=`vercel.ai.error.${M}`,R=Symbol.for(z);var C=class extends w{constructor({message:e,cause:t,argument:r}){super({name:M,message:e,cause:t}),this[R]=!0,this.argument=r}static isInstance(e){return w.hasMarker(e,z)}};Symbol.for("vercel.ai.error.AI_InvalidPromptError"),Symbol.for("vercel.ai.error.AI_InvalidResponseDataError");let P="AI_JSONParseError",$=`vercel.ai.error.${P}`,N=Symbol.for($);var j=class extends w{constructor({text:e,cause:t}){super({name:P,message:`JSON parsing failed: Text: ${e}.
2
- Error message: ${O(t)}`,cause:t}),this[N]=!0,this.text=e}static isInstance(e){return w.hasMarker(e,$)}};Symbol.for("vercel.ai.error.AI_LoadAPIKeyError"),Symbol.for("vercel.ai.error.AI_LoadSettingError"),Symbol.for("vercel.ai.error.AI_NoContentGeneratedError"),Symbol.for("vercel.ai.error.AI_NoSuchModelError"),Symbol.for("vercel.ai.error.AI_NoSuchProviderReferenceError"),Symbol.for("vercel.ai.error.AI_TooManyEmbeddingValuesForCallError");let D="AI_TypeValidationError",U=`vercel.ai.error.${D}`,Z=Symbol.for(U);var L=class e extends w{constructor({value:e,cause:t,context:r}){let a="Type validation failed";if(r?.field&&(a+=` for ${r.field}`),r?.entityName||r?.entityId){a+=" (";let e=[];r.entityName&&e.push(r.entityName),r.entityId&&e.push(`id: "${r.entityId}"`),a+=e.join(", "),a+=")"}super({name:D,message:`${a}: Value: ${JSON.stringify(e)}.
3
- Error message: ${O(t)}`,cause:t}),this[Z]=!0,this.value=e,this.context=r}static isInstance(e){return w.hasMarker(e,U)}static wrap({value:t,cause:r,context:a}){return e.isInstance(r)&&r.value===t&&r.context?.field===a?.field&&r.context?.entityName===a?.entityName&&r.context?.entityId===a?.entityId?r:new e({value:t,cause:r,context:a})}};let F="AI_UnsupportedFunctionalityError",B=`vercel.ai.error.${F}`,q=Symbol.for(B);var V=class extends w{constructor({functionality:e,message:t=`'${e}' functionality not supported.`}){super({name:F,message:t}),this[q]=!0,this.functionality=e}static isInstance(e){return w.hasMarker(e,B)}};function H(e){return e}function J(e){return e}function W(){return e=>e}function G(e){}function K(e){throw Error("Unexpected value in exhaustive check")}function Y(e){}function X(e){let t=Object.values(e).filter(e=>"number"==typeof e);return Object.entries(e).filter(([e,r])=>-1===t.indexOf(+e)).map(([e,t])=>t)}function Q(e,t="|"){return e.map(e=>e$(e)).join(t)}function ee(e,t){return"bigint"==typeof t?t.toString():t}class et{constructor(e){this._getter=e,this._value=void 0}get value(){let e=this._getter;return void 0!==e&&(this._value=e(),this._getter=void 0),this._value}}function er(e){return new et(e)}function ea(e){return null==e}function en(e){let t=+!!e.startsWith("^"),r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function ei(e,t){let r=e/t,a=Math.round(r),n=4*Number.EPSILON*Math.max(Math.abs(r),1);return Math.abs(r-a)<n?0:r-a}let eo=Symbol("evaluating");function es(e,t,r){let a;Object.defineProperty(e,t,{get(){if(a!==eo)return void 0===a&&(a=eo,a=r()),a},set(r){Object.defineProperty(e,t,{value:r})},configurable:!0})}function el(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function eu(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function ec(e){let t=Object.getOwnPropertyDescriptor(e,"shape");return t?.get?t.get.raw:t?.value}function ed(e){return ec(e._zod.def)??e._zod.def.shape}function ep(e,t,r){Object.defineProperty(e,t,{get(){let e=r();return eu(this,t,e),e},enumerable:!0,configurable:!0})}function ef(e,t,r){t in e?eu(e,t,r):e[t]=r}function eh(e,t,r,a){let n=ed(t);for(let i of r){let r=Object.getOwnPropertyDescriptor(n,i);r.enumerable&&(r.get?ep(e,i,()=>{let e=t._zod.def.shape[i];return a?a(e,i):e}):ef(e,i,a?a(r.value,i):r.value))}}function em(...e){let t={};for(let r of e)Object.assign(t,Object.getOwnPropertyDescriptors(r));return Object.defineProperties({},t)}function eg(e){return em(e._zod.def)}function ey(e,t){return t?t.reduce((e,t)=>e?.[t],e):e}function ev(e){let t=Object.keys(e);return Promise.all(t.map(t=>e[t])).then(e=>{let r={};for(let a=0;a<t.length;a++)r[t[a]]=e[a];return r})}function eb(e=10){let t="abcdefghijklmnopqrstuvwxyz",r="";for(let a=0;a<e;a++)r+=t[Math.floor(Math.random()*t.length)];return r}function ew(e){return JSON.stringify(e)}function e_(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}let ek="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function eS(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}let eE=er(()=>{if(tw.jitless||"u">typeof navigator&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return Function(""),!0}catch(e){return!1}});function ex(e){if(!1===eS(e))return!1;let t=e.constructor;if(void 0===t||"function"!=typeof t)return!0;let r=t.prototype;return!1!==eS(r)&&!1!==Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")}function eI(e){return ex(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}function eA(e){let t=0;for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&t++;return t}let eT=e=>{let t=typeof e;switch(t){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(e)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":if(Array.isArray(e))return"array";if(null===e)return"null";if(e.then&&"function"==typeof e.then&&e.catch&&"function"==typeof e.catch)return"promise";if("u">typeof Map&&e instanceof Map)return"map";if("u">typeof Set&&e instanceof Set)return"set";if("u">typeof Date&&e instanceof Date)return"date";if("u">typeof File&&e instanceof File)return"file";return"object";default:throw Error(`Unknown data type: ${t}`)}},eO=new Set(["string","number","symbol"]),eM=new Set(["string","number","bigint","boolean","symbol","undefined"]);function ez(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function eR(e,t,r){let a=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(a._zod.parent=e),a}function eC(e){if(!e)return{};if("string"==typeof e)return{error:()=>e};if(e?.message!==void 0){if(e?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");e.error=e.message}return(delete e.message,"string"==typeof e.error)?{...e,error:()=>e.error}:e}function eP(e){let t;return new Proxy({},{get:(r,a,n)=>(t??(t=e()),Reflect.get(t,a,n)),set:(r,a,n,i)=>(t??(t=e()),Reflect.set(t,a,n,i)),has:(r,a)=>(t??(t=e()),Reflect.has(t,a)),deleteProperty:(r,a)=>(t??(t=e()),Reflect.deleteProperty(t,a)),ownKeys:r=>(t??(t=e()),Reflect.ownKeys(t)),getOwnPropertyDescriptor:(r,a)=>(t??(t=e()),Reflect.getOwnPropertyDescriptor(t,a)),defineProperty:(r,a,n)=>(t??(t=e()),Reflect.defineProperty(t,a,n))})}function e$(e){return"bigint"==typeof e?e.toString()+"n":"string"==typeof e?`"${e}"`:`${e}`}function eN(e){return Object.keys(e).filter(t=>void 0!==e[t]._zod.optin&&"optional"===e[t]._zod.optout)}let ej={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-0x80000000,0x7fffffff],uint32:[0,0xffffffff],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},eD={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function eU(e,t){let r=e._zod.def,a=r.checks;if(a&&a.length>0)throw Error(".pick() cannot be used on object schemas containing refinements");let n={};return eh(n,e,eZ(e,t)),eR(e,em(r,{shape:n,checks:[]}))}function eZ(e,t){let r=ed(e),a=[];for(let e of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(r,e)?.enumerable)throw Error(`Unrecognized key: "${String(e)}"`);t[e]&&a.push(e)}return a}function eL(e,t){let r=e._zod.def,a=r.checks;if(a&&a.length>0)throw Error(".omit() cannot be used on object schemas containing refinements");let n=new Set(eZ(e,t)),i={};return eh(i,e,Reflect.ownKeys(ed(e)).filter(e=>!n.has(e))),eR(e,em(r,{shape:i,checks:[]}))}function eF(e,t){if(!ex(t))throw Error("Invalid input to extend: expected a plain object");let r=e._zod.def.checks;if(r&&r.length>0){let r=ed(e);for(let e of Reflect.ownKeys(t))if(void 0!==Object.getOwnPropertyDescriptor(r,e))throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return eR(e,em(e._zod.def,{shape:eB(e,t)}))}function eB(e,t){let r={};eh(r,e,Reflect.ownKeys(ed(e)));for(let e of Reflect.ownKeys(t)){let a=Object.getOwnPropertyDescriptor(t,e);a.enumerable&&(a.get?ep(r,e,()=>t[e]):ef(r,e,a.value))}return r}function eq(e,t){if(!ex(t))throw Error("Invalid input to safeExtend: expected a plain object");return eR(e,em(e._zod.def,{shape:eB(e,t)}))}function eV(e,t){if(!t?._zod?.def)throw Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let r={};eh(r,e,Reflect.ownKeys(ed(e))),eh(r,t,Reflect.ownKeys(ed(t)));let a=em(e._zod.def,{shape:r,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return eR(e,a)}function eH(e,t,r,a="partial"){let n=t._zod.def.checks;if(n&&n.length>0)throw Error(`.${a}() cannot be used on object schemas containing refinements`);let i=r?new Set(eZ(t,r)):void 0,o={};return eh(o,t,Reflect.ownKeys(ed(t)),e&&((t,r)=>i&&!i.has(r)?t:new e({type:"optional",innerType:t}))),eR(t,em(t._zod.def,{shape:o,checks:[]}))}function eJ(e,t,r){let a=r?new Set(eZ(t,r)):void 0,n={};return eh(n,t,Reflect.ownKeys(ed(t)),(t,r)=>a&&!a.has(r)?t:new e({type:"nonoptional",innerType:t})),eR(t,em(t._zod.def,{shape:n}))}function eW(e,t=0){if(!0===e.aborted)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function eG(e,t=0){if(!0===e.aborted)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue===!1)return!0;return!1}function eK(e,t){return t.map(t=>(t.path??(t.path=[]),t.path.unshift(e),t))}function eY(e){return"string"==typeof e?e:e?.message}function eX(e){let t=[];for(let r of e??[]){let e=r._zod.def;if(!/_(length|size)$|_equals$/.test(e.check))break;let a=e.maximum??e.length??e.size;a>=0&&t.push([a,r])}return t}function eQ(e,t,r){var a;for(let n=t;n<e.length;n++)(a=e[n]).schema??(a.schema=r)}function e0(e,t,r){let a=e.inst?._zod?.traits;a?.has("$ZodType")&&(a.has("$ZodCheck")?e.schema??(e.schema=e.inst):e.schema=e.inst);let n=e.schema!==e.inst?e.schema?._zod.def?.error:void 0,i=e.message?e.message:eY(e.inst?._zod.def?.error?.(e))??eY(n?.(e))??eY(t?.error?.(e))??eY(r.customError?.(e))??eY(r.localeError?.(e))??"Invalid input",o={};for(let t of Object.keys(e))"inst"!==t&&"schema"!==t&&"continue"!==t&&"input"!==t&&"__proto__"!==t&&(o[t]=e[t]);return o.path??(o.path=[]),o.message=i,t?.reportInput&&(o.input=e.input),o}function e1(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}let e2=/[\uD800-\uDBFF]/;function e4(e){let t=e.length;if(!e2.test(e))return t;let r=t;for(let a=0;a<t-1;a++)(64512&e.charCodeAt(a))==55296&&(64512&e.charCodeAt(a+1))==56320&&(r--,a++);return r}function e5(e){return Array.isArray(e)?"array":"string"==typeof e?"string":"unknown"}function e6(e){let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":if(null===e)return"null";if(Array.isArray(e))return"array";if(e&&Object.getPrototypeOf(e)!==Object.prototype&&"constructor"in e&&e.constructor)return e.constructor.name}return t}function e9(...e){let[t,r,a]=e;return"string"==typeof t?{message:t,code:"custom",input:r,inst:a}:{...t}}function e3(e){return Object.entries(e).filter(([e,t])=>Number.isNaN(Number.parseInt(e,10))).map(e=>e[1])}function e8(e){let t=atob(e),r=new Uint8Array(t.length);for(let e=0;e<t.length;e++)r[e]=t.charCodeAt(e);return r}function e7(e){let t="";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return btoa(t)}function te(e){let t=e.replace(/-/g,"+").replace(/_/g,"/"),r="=".repeat((4-t.length%4)%4);return e8(t+r)}function tt(e){return e7(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function tr(e){let t=e.replace(/^0x/,"");if(t.length%2!=0)throw Error("Invalid hex string length");let r=new Uint8Array(t.length/2);for(let e=0;e<t.length;e+=2)r[e/2]=Number.parseInt(t.slice(e,e+2),16);return r}function ta(e){return Array.from(e).map(e=>e.toString(16).padStart(2,"0")).join("")}class tn{constructor(...e){}}function ti(e,t){for(let r in t){let a=Object.getOwnPropertyDescriptor(t,r);a.get?Object.defineProperty(e,r,{...a,enumerable:!1}):function(e,t,r){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?r:to(this,t,r.bind(this))},set(e){to(this,t,e)}})}(e,r,a.value)}}function to(e,t,r,a=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:a,value:r}),r}function ts(e,t,r){return to(e,t,r,!1)}function tl(e,t){for(let r in e){let a=e[r];Object.defineProperty(t,r,{configurable:!0,enumerable:!0,get(){return to(this,r,a(this))},set(e){to(this,r,e)}})}return t}let tu=!1,tc={configurable:!0,get(){tu=!0}};function td(e,r,a){let n=Object.getPrototypeOf(e._zod);if(r in n&&t!==e._zod){t=void 0;return}t=e._zod,Object.defineProperty(n,r,{configurable:!0,get(){Object.defineProperty(this,r,tc);let e=tu;tu=!1;try{let t=a(this);return tu?delete this[r]:Object.defineProperty(this,r,{configurable:!0,writable:!0,value:t}),tu=tu||e,t}catch(t){throw delete this[r],tu=tu||e,t}},set(e){Object.defineProperty(this,r,{configurable:!0,writable:!0,value:e})}})}function tp(e,t,r,a){let n,i=t in(n=Object.getPrototypeOf(e))?void 0:n;i&&Object.defineProperty(i,t,{configurable:!0,get(){let e={configurable:!0,writable:!0,enumerable:a,value:void 0};return Object.defineProperty(this,t,e),e.value=r(this),Object.defineProperty(this,t,e),e.value},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:a,value:e})}})}let tf="~constantCatch";function th(e){let t=()=>e;return t[tf]=!0,t}let tm={value:void 0,enumerable:!1},tg="captureStackTrace"in Error?Error:null;function ty(e,t,r,a){function n(e){this.def=e,this.constr=u,this.traits=new Set}n.prototype={};let i=r&&new WeakSet;function o(a,o){if(a._zod){if(a._zod.traits.has(e))return}else{tm.value=new n(o);try{Object.defineProperty(a,"_zod",tm)}finally{tm.value=void 0}}if(a._zod.traits.add(e),t(a,o),i){let e=Object.getPrototypeOf(a),t=a._zod.constr.prototype,n=e;for(;n&&n!==t;)n=Object.getPrototypeOf(n);let o=n??e;i.has(o)||(i.add(o),ti(o,r))}let s=u.prototype;for(let e in s)Object.prototype.hasOwnProperty.call(s,e)&&(e in a||(a[e]=s[e].bind(a)))}let s=a?.Parent??Object;class l extends s{}function u(e){let t=a?.Parent?function(e){let t=tg;if(t){let r=t.stackTraceLimit;if("number"==typeof r){try{t.stackTraceLimit=0}catch{return tg=null,new e}try{return new e}finally{t.stackTraceLimit=r}}}return new e}(l):this;o(t,e);let r=t._zod.deferred;if(r){for(let e of r)e();t._zod.deferred=void 0}let n=globalThis.__zod_globalConfig?.postProcessor;return n&&n(t),t}return Object.defineProperty(l,"name",{value:e}),Object.defineProperty(u,"init",{value:o}),Object.defineProperty(u,Symbol.hasInstance,{value:t=>!!a?.Parent&&t instanceof a.Parent||t?._zod?.traits?.has(e)}),Object.defineProperty(u,"name",{value:e}),u}class tv extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class tb extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}}(f=globalThis).__zod_globalConfig??(f.__zod_globalConfig={});let tw=globalThis.__zod_globalConfig;function t_(e){return e&&Object.assign(tw,e),tw}let tk={get:function(){let e=this._zod;return e.message??(e.message=JSON.stringify(e.def,ee,2)),e.message},set:function(e){this._zod.message=e},enumerable:!0,configurable:!0},tS={value:void 0,enumerable:!1},tE=new WeakSet([Object.prototype,Error.prototype]),tx=(e,t)=>{e.name="$ZodError",tS.value=t,Object.defineProperty(e,"issues",tS),tS.value=void 0,Object.defineProperty(e,"message",tk);let r=Object.getPrototypeOf(e);tE.has(r)||(tE.add(r),Object.defineProperty(r,"toString",{configurable:!0,enumerable:!1,get(){let e=()=>this.message;return Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0})}}))},tI=ty("$ZodError",tx),tA=ty("$ZodError",tx,void 0,{Parent:Error});function tT(e,t){return{callee:t?.callee??e,Err:t?.Err}}let tO=e=>{let t=(r,a,n,i)=>{let o=n?{...n,async:!1}:{async:!1},s=r._zod.run({value:a,issues:[]},o);if(s instanceof Promise)throw new tv;if(s.issues.length){let r=new(i?.Err??e)(s.issues.map(e=>e0(e,o,t_())));throw ek(r,i?.callee??t),r}return s.value};return t},tM=tO(tA),tz=e=>{let t=async(r,a,n,i)=>{let o=n?{...n,async:!0}:{async:!0},s=r._zod.run({value:a,issues:[]},o);if(s instanceof Promise&&(s=await s),s.issues.length){let r=new(i?.Err??e)(s.issues.map(e=>e0(e,o,t_())));throw ek(r,i?.callee??t),r}return s.value};return t},tR=tz(tA),tC=e=>(t,r,a)=>{let n=a?{...a,async:!1}:{async:!1},i=t._zod.run({value:r,issues:[]},n);if(i instanceof Promise)throw new tv;return i.issues.length?tP(e,i.issues,n):{success:!0,data:i.value}};function tP(e,t,r){let a;return{success:!1,get error(){return a||(a=new e(t.map(e=>e0(e,r,t_()))),t=void 0,r=void 0),a},set error(e){a=e,t=void 0,r=void 0}}}let t$=e=>async(t,r,a)=>{let n=a?{...a,async:!0}:{async:!0},i=t._zod.run({value:r,issues:[]},n);return i instanceof Promise&&(i=await i),i.issues.length?tP(e,i.issues,n):{success:!0,data:i.value}},tN=Symbol.for("zod.compile.invalid"),tj=Symbol.for("zod.compile.fallback"),tD=async(e,t,r)=>{let a=r?{...r,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},n=e._zod.run({value:t,issues:[]},a);return n instanceof Promise&&(n=await n),0===n.issues.length},tU=new WeakSet([Object.prototype,Error.prototype]);function tZ(e,t,r){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let e=r(this);return Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0})}})}let tL=ty("ZodError",(e,t)=>{tI.init(e,t),e.name="ZodError";let r=Object.getPrototypeOf(e);tU.has(r)||(tU.add(r),tZ(r,"format",e=>t=>(function(e,t=e=>e.message){let r={_errors:[]},a=(e,n=[])=>{for(let i of e.issues)if("invalid_union"===i.code&&i.errors.length)i.errors.map(e=>a({issues:e},[...n,...i.path]));else if("invalid_key"===i.code)a({issues:i.issues},[...n,...i.path]);else if("invalid_element"===i.code)a({issues:i.issues},[...n,...i.path]);else{let e=[...n,...i.path];if(0===e.length)r._errors.push(t(i));else{let a=r,n=0;for(;n<e.length;){let r=e[n],o=n===e.length-1;if("_errors"===r){o&&a._errors.push(t(i)),n++;continue}Object.prototype.hasOwnProperty.call(a,r)||Object.defineProperty(a,r,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let s=a[r];o&&s._errors.push(t(i)),a=s,n++}}}};return a(e),r})(e,t)),tZ(r,"flatten",e=>t=>(function(e,t=e=>e.message){let r={},a=[];for(let o of e.issues)if(o.path.length>0){var n,i;(n=o.path[0],i=()=>[],!Object.prototype.hasOwnProperty.call(r,n)&&("__proto__"===n?Object.defineProperty(r,n,{value:i(),writable:!0,enumerable:!0,configurable:!0}):r[n]=i()),r[n]).push(t(o))}else a.push(t(o));return{formErrors:a,fieldErrors:r}})(e,t)),tZ(r,"addIssue",e=>t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,ee,2)}),tZ(r,"addIssues",e=>t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,ee,2)}),Object.defineProperty(r,"isEmpty",{configurable:!0,enumerable:!1,get(){return 0===this.issues.length}}))},void 0,{Parent:Error}),tF=tO(tL),tB=tz(tL),tq=tC(tL),tV=t$(tL),tH=(n=tO(tL),i=(e,t,r,a)=>n(e,t,r?{...r,direction:"backward"}:{direction:"backward"},tT(i,a))),tJ=(o=tO(tL),s=(e,t,r,a)=>o(e,t,r,tT(s,a))),tW=(l=tz(tL),u=async(e,t,r,a)=>{let n=r?{...r,direction:"backward"}:{direction:"backward"};return await l(e,t,n,tT(u,a))}),tG=(c=tz(tL),d=async(e,t,r,a)=>await c(e,t,r,tT(d,a))),tK=(e,t,r)=>{let a=r?{...r,direction:"backward"}:{direction:"backward"};return tC(tL)(e,t,a)},tY=(e,t,r)=>tC(tL)(e,t,r),tX=async(e,t,r)=>{let a=r?{...r,direction:"backward"}:{direction:"backward"};return t$(tL)(e,t,a)},tQ=async(e,t,r)=>t$(tL)(e,t,r),t0=/^[cC][0-9a-z]{6,}$/,t1=/^[0-9a-z]+$/,t2=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,t4=/^[0-9a-vA-V]{20}$/,t5=/^[A-Za-z0-9]{27}$/,t6=/^[a-zA-Z0-9_-]{21}$/;function t9(e){return RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}let t3=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,t8=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,t7=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,re=t7(4),rt=t7(6),rr=t7(7),ra=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,rn=/^[^\s@"]{1,64}@[^\s@]{1,255}$/u;function ri(){return RegExp("^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$","u")}let 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])$/,rs=/^(([0-9a-fA-F]{1,4}:){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}|:))$/,rl=e=>{let t=ez(e??":");return RegExp(`^(?:[0-9A-F]{2}${t}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${t}){5}[0-9a-f]{2}$`)},ru=/^((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])\/([0-9]|[1-2][0-9]|3[0-2])$/,rc=/^(([0-9a-fA-F]{1,4}:){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}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,rd=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,rp=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/,rf=/^https?$/,rh=/^\+[1-9]\d{6,14}$/,rm=/^\d(?:[ -]?\d){11,18}$/,rg=/^[A-Z]{2}(?!00|01|99)\d{2}[A-Z0-9]{11,30}$/,ry="(?:(?:\\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])))",rv=RegExp(`^${ry}$`);function rb(e){let t="(?:[01]\\d|2[0-3]):[0-5]\\d";return"number"==typeof e.precision?-1===e.precision?`${t}`:0===e.precision?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?`${t}:[0-5]\\d(?:\\.\\d+)?`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function rw(e){return RegExp(`^${rb(e)}$`)}function r_(e){let t=["Z"];e.offset&&t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let r=`${rb({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,a=e.local?`${r}|${rb({precision:e.precision})}`:r;return RegExp(`^${ry}T(?:${a})$`)}let rk=/^[\s\S]{0,}$/,rS=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return RegExp(`^${t}$`)},rE=/^-?\d+n?$/,rx=/^-?\d+$/,rI=/^-?\d+(?:\.\d+)?$/,rA=/^(?:true|false)$/i,rT=/^null$/i,rO=/^undefined$/i,rM=/^[^A-Z]*$/,rz=/^[^a-z]*$/;function rR(e,t){return RegExp(`^[A-Za-z0-9+/]{${e}}${t}$`)}function rC(e){return RegExp(`^[A-Za-z0-9_-]{${e}}$`)}let rP=rR(22,"=="),r$=rC(22),rN=rR(27,"="),rj=rC(27),rD=rR(43,"="),rU=rC(43),rZ=rR(64,""),rL=rC(64),rF=rR(86,"=="),rB=rC(86);e.s(["anyString",0,rk,"base64",0,rd,"base64url",0,rp,"bigint",0,rE,"boolean",0,rA,"browserEmail",0,/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,"cidrv4",0,ru,"cidrv6",0,rc,"creditCard",0,rm,"cuid",0,t0,"cuid2",0,t1,"currencyCode",0,/^(?:AED|AFN|ALL|AMD|AOA|ARS|AUD|AWG|AZN|BAM|BBD|BDT|BHD|BIF|BMD|BND|BOB|BOV|BRL|BSD|BTN|BWP|BYN|BZD|CAD|CDF|CHE|CHF|CHW|CLF|CLP|CNY|COP|COU|CRC|CUP|CVE|CZK|DJF|DKK|DOP|DZD|EGP|ERN|ETB|EUR|FJD|FKP|GBP|GEL|GHS|GIP|GMD|GNF|GTQ|GYD|HKD|HNL|HTG|HUF|IDR|ILS|INR|IQD|IRR|ISK|JMD|JOD|JPY|KES|KGS|KHR|KMF|KPW|KRW|KWD|KYD|KZT|LAK|LBP|LKR|LRD|LSL|LYD|MAD|MDL|MGA|MKD|MMK|MNT|MOP|MRU|MUR|MVR|MWK|MXN|MXV|MYR|MZN|NAD|NGN|NIO|NOK|NPR|NZD|OMR|PAB|PEN|PGK|PHP|PKR|PLN|PYG|QAR|RON|RSD|RUB|RWF|SAR|SBD|SCR|SDG|SEK|SGD|SHP|SLE|SOS|SRD|SSP|STN|SVC|SYP|SZL|THB|TJS|TMT|TND|TOP|TRY|TTD|TWD|TZS|UAH|UGX|USD|USN|UYI|UYU|UYW|UZS|VED|VES|VND|VUV|WST|XAD|XAF|XAG|XAU|XBA|XBB|XBC|XBD|XCD|XCG|XDR|XOF|XPD|XPF|XPT|XSU|XTS|XUA|XXX|YER|ZAR|ZMW|ZWG)$/,"date",0,rv,"datetime",0,r_,"domain",0,/^(?=.{1,253}$)([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,63}$/,"duration",0,t3,"e164",0,rh,"email",0,ra,"emoji",0,ri,"extendedDuration",0,/^[-+]?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)?)??$/,"guid",0,t8,"hex",0,/^[0-9a-fA-F]*$/,"hostname",0,/^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/,"html5Email",0,/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,"httpProtocol",0,rf,"iban",0,rg,"idnEmail",0,rn,"integer",0,rx,"ipv4",0,ro,"ipv6",0,rs,"ksuid",0,t5,"lowercase",0,rM,"mac",0,rl,"md5_base64",0,rP,"md5_base64url",0,r$,"md5_hex",0,/^[0-9a-fA-F]{32}$/,"nanoid",0,t6,"nanoidOfLength",0,t9,"null",0,rT,"number",0,rI,"rfc5322Email",0,/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,"sha1_base64",0,rN,"sha1_base64url",0,rj,"sha1_hex",0,/^[0-9a-fA-F]{40}$/,"sha256_base64",0,rD,"sha256_base64url",0,rU,"sha256_hex",0,/^[0-9a-fA-F]{64}$/,"sha384_base64",0,rZ,"sha384_base64url",0,rL,"sha384_hex",0,/^[0-9a-fA-F]{96}$/,"sha512_base64",0,rF,"sha512_base64url",0,rB,"sha512_hex",0,/^[0-9a-fA-F]{128}$/,"string",0,rS,"time",0,rw,"ulid",0,t2,"undefined",0,rO,"unicodeEmail",0,rn,"uppercase",0,rz,"uuid",0,t7,"uuid4",0,re,"uuid6",0,rt,"uuid7",0,rr,"xid",0,t4],59217);let rq=ty("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),rV=e=>{let t=e.value;return!ea(t)&&void 0!==t.size},rH=e=>{let t=e.value;return!ea(t)&&void 0!==t.length},rJ={number:"number",bigint:"bigint",object:"date"},rW=ty("$ZodCheckLessThan",(e,t)=>{rq.init(e,t);let r=rJ[typeof t.value];e._zod.check=a=>{(t.inclusive?a.value<=t.value:a.value<t.value)||a.issues.push({origin:rJ[typeof a.value]??r,code:"too_big",maximum:"object"==typeof t.value?t.value.getTime():t.value,input:a.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),rG=ty("$ZodCheckGreaterThan",(e,t)=>{rq.init(e,t);let r=rJ[typeof t.value];e._zod.check=a=>{(t.inclusive?a.value>=t.value:a.value>t.value)||a.issues.push({origin:rJ[typeof a.value]??r,code:"too_small",minimum:"object"==typeof t.value?t.value.getTime():t.value,input:a.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),rK=ty("$ZodCheckMultipleOf",(e,t)=>{rq.init(e,t),e._zod.check=r=>{if(typeof r.value!=typeof t.value)throw Error("Cannot mix number and bigint in multiple_of check.");("bigint"==typeof r.value?t.value!==BigInt(0)&&r.value%t.value===BigInt(0):0===ei(r.value,t.value))||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:t.value,input:r.value,inst:e,continue:!t.abort})}}),rY=ty("$ZodCheckNumberFormat",(e,t)=>{rq.init(e,t),t.format=t.format||"float64";let r=t.format?.includes("int"),a=r?"int":"number",[n,i]=ej[t.format];e._zod.check=o=>{let s=o.value;if(r){if(!Number.isInteger(s))return void o.issues.push({expected:a,format:t.format,code:"invalid_type",continue:!1,input:s,inst:e});if(!Number.isSafeInteger(s))return void(s>0?o.issues.push({input:s,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:a,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:a,inclusive:!0,continue:!t.abort}))}s<n&&o.issues.push({origin:"number",input:s,code:"too_small",minimum:n,inclusive:!0,inst:e,continue:!t.abort}),s>i&&o.issues.push({origin:"number",input:s,code:"too_big",maximum:i,inclusive:!0,inst:e,continue:!t.abort})}}),rX=ty("$ZodCheckBigIntFormat",(e,t)=>{rq.init(e,t);let[r,a]=eD[t.format];e._zod.check=n=>{let i=n.value;i<r&&n.issues.push({origin:"bigint",input:i,code:"too_small",minimum:r,inclusive:!0,inst:e,continue:!t.abort}),i>a&&n.issues.push({origin:"bigint",input:i,code:"too_big",maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),rQ=ty("$ZodCheckMaxSize",(e,t)=>{var r;rq.init(e,t),(r=e._zod.def).when??(r.when=rV),e._zod.check=r=>{let a=r.value;a.size<=t.maximum||r.issues.push({origin:e1(a),code:"too_big",maximum:t.maximum,inclusive:!0,input:a,inst:e,continue:!t.abort})}}),r0=ty("$ZodCheckMinSize",(e,t)=>{var r;rq.init(e,t),(r=e._zod.def).when??(r.when=rV),e._zod.check=r=>{let a=r.value;a.size>=t.minimum||r.issues.push({origin:e1(a),code:"too_small",minimum:t.minimum,inclusive:!0,input:a,inst:e,continue:!t.abort})}}),r1=ty("$ZodCheckSizeEquals",(e,t)=>{var r;rq.init(e,t),(r=e._zod.def).when??(r.when=rV),e._zod.check=r=>{let a=r.value,n=a.size;if(n===t.size)return;let i=n>t.size;r.issues.push({origin:e1(a),...i?{code:"too_big",maximum:t.size}:{code:"too_small",minimum:t.size},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),r2=ty("$ZodCheckMaxLength",(e,t)=>{var r;rq.init(e,t),(r=e._zod.def).when??(r.when=rH),e._zod.check=r=>{let a=r.value,n=a.length;if(("string"==typeof a&&n>t.maximum?e4(a):n)<=t.maximum)return;let i=e5(a);r.issues.push({origin:i,code:"too_big",maximum:t.maximum,inclusive:!0,input:a,inst:e,continue:!t.abort})}}),r4=ty("$ZodCheckMinLength",(e,t)=>{var r;rq.init(e,t),(r=e._zod.def).when??(r.when=rH),e._zod.check=r=>{let a=r.value,n=a.length;if(("string"==typeof a&&n>=t.minimum&&n<2*t.minimum?e4(a):n)>=t.minimum)return;let i=e5(a);r.issues.push({origin:i,code:"too_small",minimum:t.minimum,inclusive:!0,input:a,inst:e,continue:!t.abort})}}),r5=ty("$ZodCheckLengthEquals",(e,t)=>{var r;rq.init(e,t),(r=e._zod.def).when??(r.when=rH),e._zod.check=r=>{let a=r.value,n=a.length,i="string"==typeof a&&n>=t.length&&n<=2*t.length?e4(a):n;if(i===t.length)return;let o=e5(a),s=i>t.length;r.issues.push({origin:o,...s?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),r6=ty("$ZodCheckStringFormat",(e,t)=>{var r,a;rq.init(e,t),t.pattern?(r=e._zod).check??(r.check=r=>{t.pattern.lastIndex=0,t.pattern.test(r.value)||r.issues.push({origin:"string",code:"invalid_format",format:t.format,input:r.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(a=e._zod).check??(a.check=()=>{})}),r9=ty("$ZodCheckRegex",(e,t)=>{r6.init(e,t),e._zod.check=r=>{t.pattern.lastIndex=0,t.pattern.test(r.value)||r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),r3=ty("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=rM),r6.init(e,t)}),r8=ty("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=rz),r6.init(e,t)}),r7=ty("$ZodCheckIncludes",(e,t)=>{rq.init(e,t);let r=ez(t.includes),a=new RegExp("number"==typeof t.position?`^.{${t.position},}${r}`:r);t.pattern=a,e._zod.check=r=>{r.value.includes(t.includes,t.position)||r.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:r.value,inst:e,continue:!t.abort})}}),ae=ty("$ZodCheckStartsWith",(e,t)=>{rq.init(e,t);let r=RegExp(`^${ez(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.check=r=>{r.value.startsWith(t.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort})}}),at=ty("$ZodCheckEndsWith",(e,t)=>{rq.init(e,t);let r=RegExp(`.*${ez(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.check=r=>{r.value.endsWith(t.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort})}});function ar(e,t,r){e.issues.length&&t.issues.push(...eK(r,e.issues))}let aa=ty("$ZodCheckProperties",(e,t)=>{let r;rq.init(e,t),ts(e,Symbol.iterator,function*(){yield e}),e._zod.check=a=>{let n;if(null==a.value)return void a.issues.push({expected:"object",code:"invalid_type",input:a.value,inst:e});r??(r=Reflect.ownKeys(t.shape).map(e=>[e,t.shape[e]]));let i=a.value;for(let[e,t]of r){let r=t._zod.run({value:i[e],issues:[]},{});r instanceof Promise?(n??(n=[]),n.push(r.then(t=>ar(t,a,e)))):ar(r,a,e)}if(n)return Promise.all(n).then(()=>void 0)}}),an=((e,t)=>{rq.init(e,t);let r=new Set(t.mime);e._zod.check=a=>{r.has(a.value.type)||a.issues.push({code:"invalid_value",values:t.mime,input:a.value.type,inst:e,continue:!t.abort})}},ty("$ZodCheckOverwrite",(e,t)=>{rq.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}));class ai{constructor(e=[],t={}){this.content=[],this.indent=0,this.args=e,this.closed=t}indented(e){this.indent+=1;try{e(this)}finally{this.indent-=1}}write(e){if("function"==typeof e){e(this,{execution:"sync"}),e(this,{execution:"async"});return}let t=e.split("\n").filter(e=>e),r=Math.min(...t.map(e=>e.length-e.trimStart().length));for(let e of t.map(e=>e.slice(r)).map(e=>" ".repeat(2*this.indent)+e))this.content.push(e)}compile(){let e=Function,t=this?.content??[""];return new e(...Object.keys(this.closed),`return function (${this.args.join(", ")}) {
4
- ${t.join("\n")}
5
- };`)(...Object.values(this.closed))}}let ao={major:4,minor:6,patch:7},as=ty("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=ao;let a=e._zod.def.checks,n=e._zod.traits.has("$ZodCheck")?[e,...a??[]]:a?.length?[...a]:[];for(let t of n)for(let r of t._zod.onattach)r(e);if(0===n.length)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(t,r,a)=>{let n;if(t.memo)return t;let i=eW(t);for(let o of r){if(o._zod.def.when){if(eG(t)||!o._zod.def.when(t))continue}else if(i)continue;let r=t.issues.length,s=o._zod.check(t);if(s instanceof Promise&&a?.async===!1)throw new tv;if(n||s instanceof Promise)n=(n??Promise.resolve()).then(async()=>{await s,t.issues.length!==r&&(eQ(t.issues,r,e),i||(i=eW(t,r)))});else{if(t.issues.length===r)continue;eQ(t.issues,r,e),i||(i=eW(t,r))}}return n?n.then(()=>t):t},r=(r,a,i)=>{if(eW(r))return r.aborted=!0,r;let o=t(a,n,i);if(o instanceof Promise){if(!1===i.async)throw new tv;return o.then(t=>e._zod.parse(t,i))}return e._zod.parse(o,i)};e._zod.run=(a,i)=>{if(i.skipChecks)return e._zod.parse(a,i);if("backward"===i.direction){let t=e._zod.parse({value:a.value,issues:[]},{...i,skipChecks:!0});return t instanceof Promise?t.then(e=>r(e,a,i)):r(t,a,i)}let o=e._zod.parse(a,i);if(o instanceof Promise){if(!1===i.async)throw new tv;return o.then(e=>t(e,n,i))}return t(o,n,i)}}},{get"~standard"(){return ts(this,"~standard",ac(this))},set"~standard"(e){to(this,"~standard",e)}}),al=(e,t)=>e.issues.length?{issues:e.issues.map(e=>e0(e,t,t_()))}:{value:e.value};async function au(e,t){let r={async:!0};return al(await e._zod.run({value:t,issues:[]},r),r)}function ac(e){return{validate:t=>{let r={async:!1};try{let a=e._zod.run({value:t,issues:[]},r);if(!(a instanceof Promise))return al(a,r)}catch(e){}return au(e,t)},vendor:"zod",version:1}}let ad=ty("$ZodString",(e,t)=>{as.init(e,t),e._zod.pattern=t.pattern??rk,e._zod.parse=(r,a)=>{if(t.coerce)try{r.value=String(r.value)}catch(e){}return"string"==typeof r.value||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),ap=ty("$ZodStringFormat",(e,t)=>{r6.init(e,t),ad.init(e,t)}),af=ty("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=t8),ap.init(e,t)}),ah=ty("$ZodUUID",(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(void 0===e)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=t7(e))}else t.pattern??(t.pattern=t7());ap.init(e,t)}),am=ty("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=ra),ap.init(e,t)});function ag(e){try{if("u">typeof URL&&"function"==typeof URL.canParse)return URL.canParse(e);return new URL(e),!0}catch{return!1}}let ay=/[\t\n\r]/g;function av(e){return e.replace(ay,"")}let ab=ty("$ZodURL",(e,t)=>{ap.init(e,t),e._zod.check=r=>{try{var a,n;let i=r.value.trim(),o="normalize"in t||"hostname"in t||"protocol"in t?function(e,t){if(!t.normalize&&t.protocol?.source===rf.source&&!/^https?:\/\//i.test(e))return 1;try{if("u">typeof URL){let t=URL;if("function"==typeof t.parse)return t.parse(e)??2}return new URL(e)}catch{return 2}}(i,t):ag(i)||2;if(1===o)return void r.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:r.value,inst:e,continue:!t.abort});if(2===o)return void r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort});if(!0===o){r.value=av(i);return}t.hostname&&((a=t.hostname).lastIndex=0,!a.test(o.hostname))&&r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:r.value,inst:e,continue:!t.abort}),t.protocol&&((n=t.protocol).lastIndex=0,!n.test(o.protocol.endsWith(":")?o.protocol.slice(0,-1):o.protocol))&&r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort}),r.value=t.normalize?o.href:av(i);return}catch(a){r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),aw=ty("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=ri()),ap.init(e,t)}),a_=ty("$ZodNanoID",(e,t)=>{if(void 0!==t.length&&(!Number.isInteger(t.length)||t.length<1))throw Error(`Invalid nanoid length: ${t.length}`);t.pattern??(t.pattern=void 0===t.length?t6:t9(t.length)),ap.init(e,t)}),ak=ty("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=t0),ap.init(e,t)}),aS=ty("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=t1),ap.init(e,t)}),aE=ty("$ZodULID",(e,t)=>{t.pattern??(t.pattern=t2),ap.init(e,t)}),ax=ty("$ZodXID",(e,t)=>{t.pattern??(t.pattern=t4),ap.init(e,t)}),aI=ty("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=t5),ap.init(e,t)}),aA=ty("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=r_(t)),ap.init(e,t)}),aT=ty("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=rv),ap.init(e,t)}),aO=ty("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=rw(t)),ap.init(e,t)}),aM=ty("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=t3),ap.init(e,t)}),az=ty("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=ro),ap.init(e,t)}),aR=/^[0-9a-fA-F:.]+$/;function aC(e){return!!aR.test(e)&&ag(`http://[${e}]`)}let aP=ty("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=rs),ap.init(e,t),e._zod.check=r=>{aC(r.value)||r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}}),a$=((e,t)=>{t.pattern??(t.pattern=rl(t.delimiter)),ap.init(e,t)},ty("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=ru),ap.init(e,t)})),aN=ty("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=rc),ap.init(e,t),e._zod.check=r=>{!function(e){let t=e.split("/");if(2!==t.length)return!1;let[r,a]=t;if(!a)return!1;let n=Number(a);return`${n}`===a&&!(n<0)&&!(n>128)&&aC(r)}(r.value)&&r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}});function aj(e){if(""===e)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}let aD=/^[0-9a-zA-Z+/]*={0,2}$/,aU=ty("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=aD),ap.init(e,t),e._zod.check=r=>{aj(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}}),aZ=/^[A-Za-z0-9_-]*$/,aL=ty("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=aZ),ap.init(e,t),e._zod.check=r=>{!function(e){if(!aZ.test(e))return!1;let t=e.replace(/[-_]/g,e=>"-"===e?"+":"/");return aj(t.padEnd(4*Math.ceil(t.length/4),"="))}(r.value)&&r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),aF=ty("$ZodE164",(e,t)=>{t.pattern??(t.pattern=rh),ap.init(e,t)}),aB=/[- ]/g,aq=((e,t)=>{t.pattern??(t.pattern=rm),ap.init(e,t),e._zod.check=r=>{var a;a=r.value,rm.test(a)&&function(e){let t=e.length,r=1,a=0;for(;t;){let n=e.charCodeAt(--t)-48;r^=1,a+=r?[0,2,4,6,8,1,3,5,7,9][n]:n}return a%10==0}(a.replace(aB,""))||r.issues.push({code:"invalid_format",format:"credit_card",input:r.value,inst:e,continue:!t.abort})}},ty("$ZodJWT",(e,t)=>{ap.init(e,t),e._zod.check=r=>{!function(e,t=null){try{let r=e.split(".");if(3!==r.length)return!1;let[a]=r;if(!a)return!1;let n=JSON.parse(atob(a));if("typ"in n&&n?.typ!=="JWT"||!n.alg||t&&(!("alg"in n)||n.alg!==t))return!1;return!0}catch{return!1}}(r.value,t.alg)&&r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}})),aV=((e,t)=>{ap.init(e,t),e._zod.check=r=>{t.fn(r.value)||r.issues.push({code:"invalid_format",format:t.format,input:r.value,inst:e,continue:!t.abort})}},ty("$ZodNumber",(e,t)=>{as.init(e,t),e._zod.pattern=rI,e._zod.parse=(r,a)=>{if(t.coerce)try{r.value=Number(r.value)}catch(e){}let n=r.value;if("number"==typeof n&&!Number.isNaN(n)&&Number.isFinite(n))return r;let i="number"==typeof n?Number.isNaN(n)?"NaN":Number.isFinite(n)?void 0:String(n):void 0;return r.issues.push({expected:"number",code:"invalid_type",input:n,inst:e,...i?{received:i}:{}}),r}})),aH=ty("$ZodNumberFormat",(e,t)=>{rY.init(e,t),aV.init(e,t)}),aJ=ty("$ZodBoolean",(e,t)=>{as.init(e,t),e._zod.pattern=rA,e._zod.parse=(r,a)=>{if(t.coerce)try{r.value=!!r.value}catch(e){}let n=r.value;return"boolean"==typeof n||r.issues.push({expected:"boolean",code:"invalid_type",input:n,inst:e}),r}}),aW=ty("$ZodBigInt",(e,t)=>{as.init(e,t),e._zod.pattern=rE,e._zod.parse=(r,a)=>{if(t.coerce)try{r.value=BigInt(r.value)}catch(e){}return"bigint"==typeof r.value||r.issues.push({expected:"bigint",code:"invalid_type",input:r.value,inst:e}),r}}),aG=((e,t)=>{rX.init(e,t),aW.init(e,t)},ty("$ZodNull",(e,t)=>{as.init(e,t),e._zod.pattern=rT,e._zod.values=new Set([null]),e._zod.parse=(t,r)=>{let a=t.value;return null===a||t.issues.push({expected:"null",code:"invalid_type",input:a,inst:e}),t}})),aK=ty("$ZodAny",(e,t)=>{as.init(e,t),e._zod.parse=e=>e}),aY=ty("$ZodUnknown",(e,t)=>{as.init(e,t),e._zod.parse=e=>e}),aX=ty("$ZodNever",(e,t)=>{as.init(e,t),e._zod.parse=(t,r)=>(t.issues.push({expected:"never",code:"invalid_type",input:t.value,inst:e}),t)});function aQ(e,t){let r=eX(e._zod.def.checks);if(!r.length)return;let a=Math.min(...r.map(e=>e[0])),n=e._zod.parse;e._zod.parse=(r,i)=>{let o=t(r.value);if(o>a&&!i?.skipChecks&&i?.direction!=="backward"){for(let[t,a]of eX(e._zod.def.checks))if(o>t&&a._zod.def.when(r)){let t=r.issues.length;return a._zod.check(r),r.issues[t].continue=!1,eQ(r.issues,t,e),r}}return n(r,i)}}(e,t)=>{as.init(e,t),e._zod.parse=(t,r)=>{let a=t.value;return void 0===a||t.issues.push({expected:"void",code:"invalid_type",input:a,inst:e}),t}},(e,t)=>{as.init(e,t),e._zod.parse=(r,a)=>{if(t.coerce)try{r.value=new Date(r.value)}catch(e){}let n=r.value,i=n instanceof Date;return i&&!Number.isNaN(n.getTime())||r.issues.push({expected:"date",code:"invalid_type",input:n,...i?{received:"Invalid Date"}:{},inst:e}),r}};let a0=e=>Array.isArray(e)?e.length:-1,a1=e=>e instanceof Map?e.size:-1,a2=e=>e instanceof Set?e.size:-1;function a4(e,t,r){e.issues.length&&t.issues.push(...eK(r,e.issues)),t.value[r]=e.value}let a5=ty("$ZodArray",(e,t)=>{as.init(e,t);let r=tw.memoizer;r?.attach(e),e._zod.parse=(a,n)=>{let i=a.value;if(!Array.isArray(i))return a.issues.push({expected:"array",code:"invalid_type",input:i,inst:e}),a;a.value=r?r.alloc(e,a,Array(i.length),n):Array(i.length);let o=[],s=n?.abortEarly;for(let e=0;e<i.length;e++){let r=i[e],l=t.element._zod.run({value:r,issues:[]},n);if(l instanceof Promise)o.push(l.then(t=>a4(t,a,e)));else if(a4(l,a,e),s&&0!==l.issues.length&&eW(l))break}return o.length?Promise.all(o).then(()=>a):a},aQ(e,a0)});function a6(e,t,r,a,n,i){let o=r in a,s="optional"===i;if(o||!s||"optional"!==n){if(e.issues.length){if(void 0!==n&&s&&!o)return;t.issues.push(...eK(r,e.issues))}if(!o&&void 0===n){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[r]});return}void 0===e.value?(o||"defaulted"===n&&!s)&&(t.value[r]=void 0):t.value[r]=e.value}}let a9=[];function a3(e){let t=Object.keys(e.shape),r=Object.getOwnPropertySymbols(e.shape),a=r.length?r:a9,n=a.length?[...t,...a]:t;for(let t of n)if(!e.shape?.[t]?._zod?.traits?.has("$ZodType"))throw Error(`Invalid element at key "${String(t)}": expected a Zod schema`);let i=eN(e.shape);return{...e,allKeys:n,symbolKeys:a,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(i)}}function a8(e,t,r,a,n,i,o){let s=[],l=n.keySet,u=n.catchall._zod,c=u.def.type,d=u.optin,p=u.optout,f=0;for(let n in t){if(o&&r.issues.length!==f){if(eW(r,f))break;f=r.issues.length}if(l.has(n))continue;if("__proto__"===n){"never"===c&&s.push(n);continue}if("never"===c){s.push(n);continue}let i=u.run({value:t[n],issues:[]},a);i instanceof Promise?e.push(i.then(e=>a6(e,r,n,t,d,p))):a6(i,r,n,t,d,p)}return(s.length&&r.issues.push({code:"unrecognized_keys",keys:s,input:t,inst:i,continue:!0}),e.length)?Promise.all(e).then(()=>r):r}let a7=ty("$ZodObject",(e,t)=>{let r;as.init(e,t);let a=Object.getOwnPropertyDescriptor(t,"shape"),n=a?.get?a.get.raw:t.shape??{};if(n){let e=()=>{let r={...n};return Object.defineProperty(t,"shape",{value:r}),e.raw=r,r};e.raw=n,Object.defineProperty(t,"shape",{get:e})}let i=er(()=>a3(t));td(e,"propValues",e=>{let t=e.def.shape,r={};for(let e in t){let a=t[e]._zod;if(a.values){for(let t of(Object.prototype.hasOwnProperty.call(r,e)||eu(r,e,new Set),a.values))r[e].add(t);void 0!==a.optin&&r[e].add(void 0)}}return r});let o=t.catchall,s=tw.memoizer;s?.attach(e),e._zod.parse=(t,a)=>{r??(r=i.value);let n=t.value;if(!eS(n))return t.issues.push({expected:"object",code:"invalid_type",input:n,inst:e}),t;t.value=s?s.alloc(e,t,{},a):{};let l=[],u=r.shape,c=a?.abortEarly,d=t.issues.length;for(let e of r.allKeys){if(c&&t.issues.length!==d){if(eW(t,d))break;d=t.issues.length}if("__proto__"===e)continue;let r=u[e],i=r._zod.optin,o=r._zod.optout,s=r._zod.run({value:n[e],issues:[]},a);s instanceof Promise?l.push(s.then(r=>a6(r,t,e,n,i,o))):a6(s,t,e,n,i,o)}return o?a8(l,n,t,a,i.value,e,!0===c):l.length?Promise.all(l).then(()=>t):t}}),ne=ty("$ZodObjectJIT",(e,t)=>{let r,a;a7.init(e,t);let n=e._zod.parse,i=er(()=>a3(t)),o=tw.memoizer,s=!tw.jitless,l=s&&eE.value,u=t.catchall;e._zod.parse=(c,d)=>{a??(a=i.value);let p=c.value;return eS(p)?s&&l&&d?.async===!1&&!0!==d.jitless?(r||(r=(t=>{let r=i.value,a=r.symbolKeys,n=new ai(["payload","ctx"],{shape:t,inst:e,memo:o,syms:a}),s=e=>`shape[${e}]._zod.run({ value: input[${e}], issues: [] }, ctx)`,l=(e,t)=>`
6
- let ${e}_ab = false;
7
- for (let i = 0; i < ${e}.issues.length; i++) {
8
- const iss = ${e}.issues[i];
9
- iss.path = iss.path ? [${t}, ...iss.path] : [${t}];
10
- payload.issues.push(iss);
11
- if (iss.continue !== true) ${e}_ab = true;
12
- }
13
- if (${e}_ab && ctx && ctx.abortEarly) {
14
- payload.value = newResult;
15
- return payload;
16
- }`;n.write("const input = payload.value;");let u=Object.create(null),c=0;for(let e of r.allKeys)u[e]=`key_${c++}`;for(let e of(n.write(o?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};"),r.allKeys)){if("__proto__"===e)continue;let r=u[e],i="symbol"==typeof e?`syms[${a.indexOf(e)}]`:ew(e),o=`${i} in input`,c=t[e],d=c?._zod?.optin,p=void 0!==d,f=c?._zod?.optout==="optional";if(n.write(`const ${r} = ${s(i)};`),p&&f){let e="optional"===d?`${r}_present`:`${r}.value !== undefined || ${r}_present`;n.write(`
17
- const ${r}_present = ${o};
18
- if (!${r}.issues.length || ${r}_present) {
19
- if (${r}.issues.length) {${l(r,i)}
20
- }
21
-
22
- if (${e}) {
23
- newResult[${i}] = ${r}.value;
24
- }
25
- }
26
-
27
- `)}else p?(n.write(`
28
- if (${r}.issues.length) {${l(r,i)}
29
- }
30
- `),"defaulted"===d?n.write(`newResult[${i}] = ${r}.value;`):n.write(`
31
- if (${r}.value !== undefined || ${o}) {
32
- newResult[${i}] = ${r}.value;
33
- }
34
- `)):n.write(`
35
- const ${r}_present = ${o};
36
- if (${r}.issues.length) {${l(r,i)}
37
- }
38
- if (!${r}_present && !${r}.issues.length) {
39
- payload.issues.push({
40
- code: "invalid_type",
41
- expected: "nonoptional",
42
- input: undefined,
43
- path: [${i}]
44
- });
45
- if (ctx && ctx.abortEarly) {
46
- payload.value = newResult;
47
- return payload;
48
- }
49
- }
50
-
51
- if (${r}_present) {
52
- newResult[${i}] = ${r}.value;
53
- }
54
-
55
- `)}return n.write("payload.value = newResult;"),n.write("return payload;"),n.compile()})(t.shape)),c=r(c,d),u)?a8([],p,c,d,a,e,d?.abortEarly===!0):c:n(c,d):(c.issues.push({expected:"object",code:"invalid_type",input:p,inst:e}),c)}});function nt(e,t,r,a){for(let r of e)if(0===r.issues.length)return t.value=r.value,t;let n=e.filter(e=>!eW(e));return 1===n.length?(t.value=n[0].value,n[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(e=>e.issues.map(e=>e0(e,a,t_())))}),t)}let nr=ty("$ZodUnion",(e,t)=>{as.init(e,t),td(e,"optin",e=>e.def.options.some(e=>"defaulted"===e._zod.optin)?"defaulted":e.def.options.some(e=>void 0!==e._zod.optin)?"optional":void 0),td(e,"optout",e=>e.def.options.some(e=>"optional"===e._zod.optout)?"optional":void 0),td(e,"values",e=>{if(e.def.options.every(e=>e._zod.values))return new Set(e.def.options.flatMap(e=>Array.from(e._zod.values)))}),td(e,"pattern",e=>{if(e.def.options.every(e=>e._zod.pattern)){let t=e.def.options.map(e=>e._zod.pattern);return RegExp(`^(${t.map(e=>en(e.source)).join("|")})$`)}});let r=1===t.options.length?t.options[0]._zod.run:null;e._zod.parse=(a,n)=>{if(r)return r(a,n);let i=!1,o=[];for(let e of t.options){let t=e._zod.run({value:a.value,issues:[]},n);if(t instanceof Promise)o.push(t),i=!0;else{if(0===t.issues.length)return t;o.push(t)}}return i?Promise.all(o).then(t=>nt(t,a,e,n)):nt(o,a,e,n)}});function na(e,t,r,a){let n=[];for(let t=0;t<e.length;t++)0===e[t].issues.length&&n.push(t);return 1===n.length?t.value=e[n[0]].value:0===n.length?t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(e=>e.issues.map(e=>e0(e,a,t_())))}):t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:[],inclusive:!1,matches:n}),t}(e,t)=>{nr.init(e,t),t.inclusive=!1;let r=1===t.options.length?t.options[0]._zod.run:null;e._zod.parse=(a,n)=>{if(r)return r(a,n);let i=!1,o=[];for(let e of t.options){let t=e._zod.run({value:a.value,issues:[]},n);t instanceof Promise?(o.push(t),i=!0):o.push(t)}return i?Promise.all(o).then(t=>na(t,a,e,n)):na(o,a,e,n)}};let nn=ty("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,nr.init(e,t);let r=e._zod.parse;td(e,"propValues",e=>{let t={},r=0;for(let a of e.def.options){let n=a._zod.propValues;if(!n||0===Object.keys(n).length)throw Error(`Invalid discriminated union option at index "${e.def.options.indexOf(a)}"`);for(let[a,i]of(n[e.def.discriminator]?.has(void 0)&&r++,Object.entries(n)))for(let e of(Object.prototype.hasOwnProperty.call(t,a)||eu(t,a,new Set),i))t[a].add(e)}return!e.def.unionFallback&&r>1&&t[e.def.discriminator]?.delete(void 0),t}),t.options.forEach((e,r)=>{let a=ec(e._zod.def);if(a&&!Object.prototype.hasOwnProperty.call(a,t.discriminator))throw Error(`Invalid discriminated union option at index "${r}"`)});let a=er(()=>(function(e){let t=new Map;for(let r of e.options){let a=r._zod.propValues?.[e.discriminator];if(!a||0===a.size)throw Error(`Invalid discriminated union option at index "${e.options.indexOf(r)}"`);for(let e of a)if(t.has(e)){if(void 0!==e)throw Error(`Duplicate discriminator value "${String(e)}"`);t.set(e,null)}else t.set(e,r)}return t})(t));e._zod.parse=(n,i)=>{let o=n.value;if(!eS(o))return n.issues.push({code:"invalid_type",expected:"object",input:o,inst:e}),n;let s=o?.[t.discriminator],l=a.value.get(s);return l&&(void 0!==s||"backward"!==i.direction)?l._zod.run(n,i):t.unionFallback||"backward"===i.direction?r(n,i):(n.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(a.value.keys()).filter(e=>null!==a.value.get(e)),input:o,path:[t.discriminator],inst:e}),n)}}),ni=ty("$ZodIntersection",(e,t)=>{as.init(e,t),e._zod.parse=(e,r)=>{let a=e.value,n=t.left._zod.run({value:a,issues:[]},r),i=t.right._zod.run({value:a,issues:[]},r);return n instanceof Promise||i instanceof Promise?Promise.all([n,i]).then(([t,r])=>no(e,t,r)):no(e,n,i)}});function no(e,t,r){let a,n=new Map,i=new Map,o=(e,t)=>{let r;if("unrecognized_keys"!==e.code||e.path?.length)if("invalid_key"!==e.code||"record"!==e.origin||e.path?.length!==1)return!1;else{let t=String(e.path[0]);i.has(t)||i.set(t,e),r=[t]}else a??(a=e),r=e.keys;for(let e of r)n.has(e)||n.set(e,{}),n.get(e)[t]=!0;return!0};for(let r of t.issues)o(r,"l")||e.issues.push(r);for(let t of r.issues)o(t,"r")||e.issues.push(t);let s=[...n].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(s.length){let t=a?s.filter(e=>a.keys.includes(e)):[];for(let r of(t.length&&e.issues.push({...a,keys:t}),s))!t.includes(r)&&i.has(r)&&e.issues.push(i.get(r))}let l=function e(t,r){if(t===r||t instanceof Date&&r instanceof Date&&+t==+r)return{valid:!0,data:t};if(ex(t)&&ex(r)){let a=Object.keys(r),n=Object.keys(t).filter(e=>-1!==a.indexOf(e)),i={...t,...r};for(let a of(Object.prototype.hasOwnProperty.call(i,"__proto__")&&delete i.__proto__,n)){if("__proto__"===a)continue;let n=e(t[a],r[a]);if(!n.valid)return{valid:!1,mergeErrorPath:[a,...n.mergeErrorPath]};i[a]=n.data}return{valid:!0,data:i}}if(Array.isArray(t)&&Array.isArray(r)){if(t.length!==r.length)return{valid:!1,mergeErrorPath:[]};let a=[];for(let n=0;n<t.length;n++){let i=e(t[n],r[n]);if(!i.valid)return{valid:!1,mergeErrorPath:[n,...i.mergeErrorPath]};a.push(i.data)}return{valid:!0,data:a}}return{valid:!1,mergeErrorPath:[]}}(t.value,r.value);if(!l.valid){if(eW(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(l.mergeErrorPath)}`)}return e.value=l.data,e}let ns=ty("$ZodTuple",(e,t)=>{as.init(e,t);let r=t.items,a=tw.memoizer;a?.attach(e),e._zod.parse=(n,i)=>{let o=n.value;if(!Array.isArray(o))return n.issues.push({input:o,inst:e,expected:"tuple",code:"invalid_type"}),n;n.value=a?a.alloc(e,n,[],i):[];let s=[],l=nl(r,"optin"),u=nl(r,"optout");if(!t.rest){if(o.length<l)return n.issues.push({code:"too_small",minimum:l,inclusive:!0,input:o,inst:e,origin:"array"}),n;o.length>r.length&&n.issues.push({code:"too_big",maximum:r.length,inclusive:!0,input:o,inst:e,origin:"array"})}let c=Array(r.length),d=t.rest?i?.abortEarly:void 0,p=!1;for(let e=0;e<r.length;e++){let t=r[e]._zod.run({value:o[e],issues:[]},i);t instanceof Promise?s.push(t.then(t=>{c[e]=t})):(c[e]=t,d&&!p&&t.issues.length&&(p=eW(t)))}if(t.rest&&!p){let e=r.length-1,a=o.slice(r.length),l=n.issues.length;for(let r of a){if(d&&n.issues.length!==l){if(eW(n,l))break;l=n.issues.length}e++;let a=t.rest._zod.run({value:r,issues:[]},i);a instanceof Promise?s.push(a.then(t=>nu(t,n,e))):nu(a,n,e)}}return s.length?Promise.all(s).then(()=>nc(c,n,r,o,u)):nc(c,n,r,o,u)}});function nl(e,t){for(let r=e.length-1;r>=0;r--)if(!("optin"===t?void 0!==e[r]._zod.optin:"optional"===e[r]._zod.optout))return r+1;return 0}function nu(e,t,r){e.issues.length&&t.issues.push(...eK(r,e.issues)),t.value[r]=e.value}function nc(e,t,r,a,n){for(let i=0;i<r.length;i++){let o=e[i],s=i<a.length;if(!s&&i>=n&&"optional"===r[i]._zod.optin){t.value.length=i;break}if(o.issues.length){if(!s&&i>=n){t.value.length=i;break}t.issues.push(...eK(i,o.issues))}t.value[i]=o.value}for(let e=t.value.length-1;e>=a.length;e--)if("optional"===r[e]._zod.optout&&void 0===t.value[e])t.value.length=e;else break;return t}let nd=ty("$ZodRecord",(e,t)=>{as.init(e,t);let r=tw.memoizer;r?.attach(e),e._zod.parse=(a,n)=>{let i=a.value;if(!ex(i))return a.issues.push({expected:"record",code:"invalid_type",input:i,inst:e}),a;let o=[],s=t.keyType._zod.values;if(s&&!t.partial){let l;a.value=r?r.alloc(e,a,{},n):{};let u=new Set;for(let r of s)if("string"==typeof r||"number"==typeof r||"symbol"==typeof r){if(u.add("number"==typeof r?r.toString():r),"__proto__"===r)continue;let s=t.keyType._zod.run({value:r,issues:[]},n);if(s instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(s.issues.length){a.issues.push({code:"invalid_key",origin:"record",issues:s.issues.map(e=>e0(e,n,t_())),input:r,path:[r],inst:e});continue}let l=s.value;if("__proto__"===l)continue;let c=t.valueType._zod.run({value:i[r],issues:[]},n);c instanceof Promise?o.push(c.then(e=>{e.issues.length&&a.issues.push(...eK(r,e.issues)),a.value[l]=e.value})):(c.issues.length&&a.issues.push(...eK(r,c.issues)),a.value[l]=c.value)}for(let e in i)if(!u.has(e))if("loose"===t.mode){if("__proto__"===e)continue;a.value[e]=i[e]}else(l=l??[]).push(e);l&&l.length>0&&a.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:l,continue:!0})}else{let l;for(let u of(a.value=r?r.alloc(e,a,{},n):{},Reflect.ownKeys(i))){if("__proto__"===u||!Object.prototype.propertyIsEnumerable.call(i,u))continue;let r=t.keyType._zod.run({value:u,issues:[]},n);if(r instanceof Promise)throw Error("Async schemas not supported in object keys currently");if("string"==typeof u&&rI.test(u)&&r.issues.length){let e=t.keyType._zod.run({value:Number(u),issues:[]},n);if(e instanceof Promise)throw Error("Async schemas not supported in object keys currently");0===e.issues.length&&(r=e)}if(r.issues.length){"loose"===t.mode?a.value[u]=i[u]:s?(l=l??[]).push(u):a.issues.push({code:"invalid_key",origin:"record",issues:r.issues.map(e=>e0(e,n,t_())),input:u,path:[u],inst:e});continue}let c=r.value;if("__proto__"===c)continue;let d=t.valueType._zod.run({value:i[u],issues:[]},n);d instanceof Promise?o.push(d.then(e=>{e.issues.length&&a.issues.push(...eK(u,e.issues)),a.value[c]=e.value})):(d.issues.length&&a.issues.push(...eK(u,d.issues)),a.value[c]=d.value)}l&&l.length>0&&a.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:l,continue:!0})}return o.length?Promise.all(o).then(()=>a):a}});function np(e,t,r,a,n,i,o){e.issues.length&&(eO.has(typeof a)?r.issues.push(...eK(a,e.issues)):r.issues.push({code:"invalid_key",origin:"map",input:n,inst:i,issues:e.issues.map(e=>e0(e,o,t_()))})),t.issues.length&&(eO.has(typeof a)?r.issues.push(...eK(a,t.issues)):r.issues.push({origin:"map",code:"invalid_element",input:n,inst:i,key:a,issues:t.issues.map(e=>e0(e,o,t_()))})),r.value.set(e.value,t.value)}function nf(e,t){e.issues.length&&t.issues.push(...e.issues),t.value.add(e.value)}(e,t)=>{as.init(e,t);let r=tw.memoizer;r?.attach(e),e._zod.parse=(a,n)=>{let i=a.value;if(!(i instanceof Map))return a.issues.push({expected:"map",code:"invalid_type",input:i,inst:e}),a;let o=[];a.value=r?r.alloc(e,a,new Map,n):new Map;let s=n?.abortEarly,l=a.issues.length;for(let[r,u]of i){if(s&&a.issues.length!==l){if(eW(a,l))break;l=a.issues.length}let c=t.keyType._zod.run({value:r,issues:[]},n),d=t.valueType._zod.run({value:u,issues:[]},n);c instanceof Promise||d instanceof Promise?o.push(Promise.all([c,d]).then(([t,o])=>{np(t,o,a,r,i,e,n)})):np(c,d,a,r,i,e,n)}return o.length?Promise.all(o).then(()=>a):a},aQ(e,a1)},(e,t)=>{as.init(e,t);let r=tw.memoizer;r?.attach(e),e._zod.parse=(a,n)=>{let i=a.value;if(!(i instanceof Set))return a.issues.push({input:i,inst:e,expected:"set",code:"invalid_type"}),a;let o=[];a.value=r?r.alloc(e,a,new Set,n):new Set;let s=n?.abortEarly,l=a.issues.length;for(let e of i){if(s&&a.issues.length!==l){if(eW(a,l))break;l=a.issues.length}let r=t.valueType._zod.run({value:e,issues:[]},n);r instanceof Promise?o.push(r.then(e=>nf(e,a))):nf(r,a)}return o.length?Promise.all(o).then(()=>a):a},aQ(e,a2)};let nh=ty("$ZodEnum",(e,t)=>{as.init(e,t);let r=X(t.entries),a=new Set(r);e._zod.values=a,td(e,"pattern",e=>{let t=X(e.def.entries).filter(e=>eO.has(typeof e));return new RegExp(t.length?`^(${t.map(e=>ez(e.toString())).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(t,n)=>{let i=t.value;return a.has(i)||t.issues.push({code:"invalid_value",values:r,input:i,inst:e}),t}}),nm=ty("$ZodLiteral",(e,t)=>{as.init(e,t);let r=new Set(t.values);e._zod.values=r,td(e,"pattern",e=>{let t=e.def.values;return new RegExp(t.length?`^(${t.map(e=>"string"==typeof e?ez(e):e?ez(e.toString()):String(e)).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(a,n)=>{let i=a.value;return r.has(i)||a.issues.push({code:"invalid_value",values:t.values,input:i,inst:e}),a}}),ng=((e,t)=>{as.init(e,t),e._zod.parse=(t,r)=>{let a=t.value;return a instanceof File||t.issues.push({expected:"file",code:"invalid_type",input:a,inst:e}),t}},ty("$ZodTransform",(e,t)=>{as.init(e,t),e._zod.optin="optional",tw.memoizer?.guard(e),e._zod.parse=(r,a)=>{if("backward"===a.direction)throw new tb(e.constructor.name);let n=t.transform(r.value,r);if(a.async)return(n instanceof Promise?n:Promise.resolve(n)).then(e=>(r.value=e,r));if(n instanceof Promise)throw new tv;return r.value=n,r}}));function ny(e,t){return e.value=t.issues.length?void 0:t.value,e}let nv=ty("$ZodOptional",(e,t)=>{as.init(e,t),td(e,"optin",e=>"defaulted"===e.def.innerType._zod.optin?"defaulted":"optional"),e._zod.optout="optional",td(e,"values",e=>{let t=e.def.innerType._zod.values;return t?new Set([...t,void 0]):void 0}),td(e,"pattern",e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${en(t.source)})?$`):void 0}),e._zod.parse=(e,r)=>{if(void 0===e.value){if("defaulted"!==t.innerType._zod.optin)return e;let a=t.innerType._zod.run({value:e.value,issues:[]},r);return a instanceof Promise?a.then(t=>ny(e,t)):ny(e,a)}return t.innerType._zod.run(e,r)}}),nb=ty("$ZodExactOptional",(e,t)=>{nv.init(e,t),td(e,"values",e=>e.def.innerType._zod.values),td(e,"pattern",e=>e.def.innerType._zod.pattern),e._zod.parse=(e,r)=>t.innerType._zod.run(e,r)}),nw=ty("$ZodNullable",(e,t)=>{as.init(e,t),td(e,"optin",e=>e.def.innerType._zod.optin),td(e,"optout",e=>e.def.innerType._zod.optout),td(e,"pattern",e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${en(t.source)}|null)$`):void 0}),td(e,"values",e=>e.def.innerType._zod.values?new Set([...e.def.innerType._zod.values,null]):void 0),e._zod.parse=(e,r)=>null===e.value?e:t.innerType._zod.run(e,r)}),n_=ty("$ZodDefault",(e,t)=>{as.init(e,t),e._zod.optin="defaulted",td(e,"values",e=>e.def.innerType._zod.values),e._zod.parse=(e,r)=>{if("backward"===r.direction)return t.innerType._zod.run(e,r);if(void 0===e.value)return e.value=t.defaultValue,e;let a=t.innerType._zod.run(e,r);return a instanceof Promise?a.then(e=>nk(e,t)):nk(a,t)}});function nk(e,t){return void 0===e.value&&(e.value=t.defaultValue),e}let nS=ty("$ZodPrefault",(e,t)=>{as.init(e,t),e._zod.optin="defaulted",td(e,"values",e=>e.def.innerType._zod.values),e._zod.parse=(e,r)=>("backward"===r.direction||void 0===e.value&&(e.value=t.defaultValue),t.innerType._zod.run(e,r))}),nE=ty("$ZodNonOptional",(e,t)=>{as.init(e,t),td(e,"values",e=>{let t=e.def.innerType._zod.values;return t?new Set([...t].filter(e=>void 0!==e)):void 0}),e._zod.parse=(r,a)=>{let n=t.innerType._zod.run(r,a);return n instanceof Promise?n.then(t=>nx(t,e)):nx(n,e)}});function nx(e,t){return e.issues.length||void 0!==e.value||e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}function nI(e,t,r,a){return t.issues.length?e.value=r.catchValue({...t,value:e.value,error:{issues:t.issues.map(e=>e0(e,a,t_()))},input:e.value}):(e.value=t.value,t.memo&&(e.memo=!0)),e}(e,t)=>{as.init(e,t),e._zod.parse=(e,r)=>{if("backward"===r.direction)throw new tb("ZodSuccess");let a=t.innerType._zod.run(e,r);return a instanceof Promise?a.then(t=>(e.value=0===t.issues.length,e)):(e.value=0===a.issues.length,e)}};let nA=ty("$ZodCatch",(e,t)=>{as.init(e,t),td(e,"optin",e=>"defaulted"===e.def.innerType._zod.optin?"defaulted":"optional"),td(e,"optout",e=>e.def.innerType._zod.optout),td(e,"values",e=>e.def.innerType._zod.values),e._zod.parse=(e,r)=>{if("backward"===r.direction)return t.innerType._zod.run(e,r);let a=t.innerType._zod.run({value:e.value,issues:[]},r);return a instanceof Promise?a.then(a=>nI(e,a,t,r)):nI(e,a,t,r)}}),nT=((e,t)=>{as.init(e,t),e._zod.parse=(t,r)=>("number"==typeof t.value&&Number.isNaN(t.value)||t.issues.push({input:t.value,inst:e,expected:"nan",code:"invalid_type"}),t)},ty("$ZodPipe",(e,t)=>{as.init(e,t),td(e,"values",e=>e.def.in._zod.values),td(e,"optin",e=>e.def.in._zod.optin),td(e,"optout",e=>e.def.out._zod.optout),td(e,"propValues",e=>e.def.in._zod.propValues),e._zod.parse=(e,r)=>{if("backward"===r.direction){let a=t.out._zod.run(e,r);return a instanceof Promise?a.then(e=>nO(e,t.in,r)):nO(a,t.in,r)}let a=t.in._zod.run(e,r);return a instanceof Promise?a.then(e=>nO(e,t.out,r)):nO(a,t.out,r)}}));function nO(e,t,r){return e.issues.some(e=>"unrecognized_keys"!==e.code)?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},r)}function nM(e,t,r){if(e.issues.length)return e.aborted=!0,e;if("forward"===(r.direction||"forward")){let a=t.transform(e.value,e);return a instanceof Promise?a.then(a=>nz(e,a,t.out,r)):nz(e,a,t.out,r)}{let a=t.reverseTransform(e.value,e);return a instanceof Promise?a.then(a=>nz(e,a,t.in,r)):nz(e,a,t.in,r)}}function nz(e,t,r,a){return e.issues.length?(e.aborted=!0,e):r._zod.run({value:t,issues:e.issues},a)}(e,t)=>{as.init(e,t),td(e,"values",e=>e.def.in._zod.values),td(e,"optin",e=>e.def.in._zod.optin),td(e,"optout",e=>e.def.out._zod.optout),td(e,"propValues",e=>e.def.in._zod.propValues),e._zod.parse=(e,r)=>{if("forward"===(r.direction||"forward")){let a=t.in._zod.run(e,r);return a instanceof Promise?a.then(e=>nM(e,t,r)):nM(a,t,r)}{let a=t.out._zod.run(e,r);return a instanceof Promise?a.then(e=>nM(e,t,r)):nM(a,t,r)}}},(e,t)=>{nT.init(e,t)};let nR=ty("$ZodReadonly",(e,t)=>{as.init(e,t),td(e,"propValues",e=>e.def.innerType._zod.propValues),td(e,"values",e=>e.def.innerType._zod.values),td(e,"optin",e=>e.def.innerType?._zod?.optin),td(e,"optout",e=>e.def.innerType?._zod?.optout),e._zod.parse=(e,r)=>{if("backward"===r.direction)return t.innerType._zod.run(e,r);let a=t.innerType._zod.run(e,r);return a instanceof Promise?a.then(nC):nC(a)}});function nC(e){return e.memo||(e.value=Object.freeze(e.value)),e}(e,t)=>{as.init(e,t);let r=[];for(let e of t.parts)if("object"==typeof e&&null!==e){let t=function e(t){let r=t._zod.def,a=t._zod.pattern?.source,n=r.innerType??t._zod.innerType;if(n){let t=n._zod.pattern?.source,r=e(n);return a&&t&&r&&r!==t?a.replace(en(t),()=>en(r)):a}if(r.options){let t=r.options.map(e);if(t.every(Boolean))return`^(${t.map(e=>en(e)).join("|")})$`}return function(e){let t,r,a=e._zod.def,n=a.pattern,i=!!a.format?.includes("int");for(let e of a.checks??[]){let a=e._zod.def;a.pattern&&(n=a.pattern),i||(i=!!a.format?.includes("int"));let o=a.minimum??a.length,s=a.maximum??a.length;void 0!==o&&(void 0===t||o>t)&&(t=o),void 0!==s&&(void 0===r||s<r)&&(r=s)}if(n)return n.source;if(void 0!==t&&void 0!==r&&t>r)return"(?!)";if(void 0!==t||void 0!==r)return rS({minimum:t,maximum:r}).source;let o=e._zod.pattern;return(i&&o===rI?rx:o)?.source}(t)}(e);if(!t)throw Error(`Invalid template literal part, no pattern found: ${[...e._zod.traits].shift()}`);r.push(en(t))}else if(null===e||eM.has(typeof e))r.push(ez(`${e}`));else throw Error(`Invalid template literal part: ${e}`);e._zod.pattern=RegExp(`^${r.join("")}$`),e._zod.parse=(r,a)=>("string"!=typeof r.value?r.issues.push({input:r.value,inst:e,expected:"string",code:"invalid_type"}):(e._zod.pattern.lastIndex=0,e._zod.pattern.test(r.value)||r.issues.push({input:r.value,inst:e,code:"invalid_format",format:t.format??"template_literal",pattern:e._zod.pattern.source})),r)},(e,t)=>{as.init(e,t),e._zod.parse=(e,r)=>Promise.resolve(e.value).then(e=>t.innerType._zod.run({value:e,issues:[]},r))};let nP=ty("$ZodLazy",(e,t)=>{as.init(e,t),es(e._zod,"innerType",()=>(t._cachedInner||(t._cachedInner=t.getter()),t._cachedInner)),td(e,"pattern",e=>e.innerType?._zod?.pattern),td(e,"propValues",e=>e.innerType?._zod?.propValues),td(e,"optin",e=>e.innerType?._zod?.optin??void 0),td(e,"optout",e=>e.innerType?._zod?.optout??void 0),e._zod.parse=(t,r)=>e._zod.innerType._zod.run(t,r)}),n$=ty("$ZodCustom",(e,t)=>{rq.init(e,t),as.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=r=>{let a=r.value,n=t.fn(a);if(n instanceof Promise)return n.then(t=>nN(t,r,a,e));nN(n,r,a,e)}});function nN(e,t,r,a){if(!e){let e={code:"custom",input:r,inst:a,path:[...a._zod.def.path??[]],continue:!a._zod.def.abort};a._zod.def.params&&(e.params=a._zod.def.params),t.issues.push(e9(e))}}(h=globalThis).__zod_globalRegistry??(h.__zod_globalRegistry=new class e{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let r=t[0];return this._map.set(e,r),r&&"object"==typeof r&&"id"in r&&this._idmap.set(r.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&"object"==typeof t&&"id"in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let r={...this.get(t)??{}};delete r.id;let a={...r,...this._map.get(e)};return Object.keys(a).length?a:void 0}return this._map.get(e)}has(e){return this._map.has(e)}});let nj=globalThis.__zod_globalRegistry;function nD(e,...t){for(let r of t)for(let t of Reflect.ownKeys(r))Object.prototype.propertyIsEnumerable.call(r,t)&&eu(e,t,r[t]);return e}function nU(e){let t=e?.target??"draft-2020-12";return"draft-4"===t&&(t="draft-04"),"draft-7"===t&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??nj,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??"ref",reused:e?.reused??"inline",intersections:[],deferred:[],external:e?.external??void 0}}function nZ(e,t,r,a,n){let i="function"==typeof t.unrepresentable?t.unrepresentable({zodSchema:e,path:a.path,message:n}):t.unrepresentable;if("any"===i)return!1;if(void 0===i||"throw"===i)throw Error(n);return Object.assign(r,i),!0}function nL(e,t,r={path:[],schemaPath:[]}){var a;let n=e._zod.def,i=t.seen.get(e);if(i)return i.count++,r.schemaPath.includes(e)&&(i.cycle=r.path),i.schema;let o={schema:{},count:1,cycle:void 0,path:r.path};t.seen.set(e,o),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let a={...r,schemaPath:[...r.schemaPath,e],path:r.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,a);else{let r=o.schema,i=t.processors[n.type];if(!i)throw Error(`[toJSONSchema]: Non-representable type encountered: ${n.type}`);i(e,t,r,a)}let i=e._zod.parent;i&&(o.ref||(o.ref=i),nL(i,t,a),t.seen.get(i).isParent=!0)}let l=t.metadataRegistry.get(e);return l&&nD(o.schema,l),"input"===t.io&&function e(t,r){let a=r??{seen:new Set};if(a.seen.has(t))return!1;a.seen.add(t);let n=t._zod.def;if("transform"===n.type)return!0;if("array"===n.type)return e(n.element,a);if("set"===n.type)return e(n.valueType,a);if("lazy"===n.type)return e(n.getter(),a);if("promise"===n.type||"optional"===n.type||"nonoptional"===n.type||"nullable"===n.type||"readonly"===n.type||"default"===n.type||"prefault"===n.type||"catch"===n.type)return e(n.innerType,a);if("intersection"===n.type)return e(n.left,a)||e(n.right,a);if("record"===n.type||"map"===n.type)return e(n.keyType,a)||e(n.valueType,a);if("pipe"===n.type)return!!t._zod.traits.has("$ZodCodec")||e(n.in,a)||e(n.out,a);if("object"===n.type){for(let t in n.shape)if(e(n.shape[t],a))return!0;return!1}if("union"===n.type){for(let t of n.options)if(e(t,a))return!0;return!1}if("tuple"===n.type){for(let t of n.items)if(e(t,a))return!0;if(n.rest&&e(n.rest,a))return!0}return!1}(e)&&(delete o.schema.examples,delete o.schema.default),"input"===t.io&&"_prefault"in o.schema&&((a=o.schema).default??(a.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function nF(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function nB(e,t){let r=e.seen.get(t);if(!r)throw Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;let a=new Map;for(let t of e.seen.entries()){let r=e.metadataRegistry.get(t[0])?.id;if(r){let e=a.get(r);if(e&&e!==t[0])throw Error(`Duplicate schema id "${r}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);a.set(r,t[0])}}let n=t=>{if(t[1].schema.$ref)return;let a=t[1],{ref:n,defId:i}=(t=>{let a="draft-2020-12"===e.target?"$defs":"definitions";if(e.external){let r=e.external.registry.get(t[0])?.id,n=e.external.uri??(e=>e);if(r)return{ref:n(r)};let i=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=i,{defId:i,ref:`${n("__shared")}#/${a}/${nF(i)}`}}let n=`#/${a}/`;if(t[1]===r&&!t[1].schema.id)return{ref:"#"};let i=t[1].schema.id??`__schema${e.counter++}`;return{defId:i,ref:n+nF(i)}})(t);a.def={...a.schema},i&&(a.defId=i);let o=a.schema;for(let e in o)delete o[e];o.$ref=n};if("throw"===e.cycles)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join("/")}/<root>
56
-
57
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let r of e.seen.entries()){let a=r[1];if(t===r[0]){n(r);continue}if(e.external){let a=e.external.registry.get(r[0])?.id;if(t!==r[0]&&a){n(r);continue}}if(e.metadataRegistry.get(r[0])?.id||a.cycle){n(r);continue}a.count>1&&"ref"===e.reused&&n(r)}e.external&&(e.sharedDefsExtractedFor=e.external)}let nq=new Set(["type","properties","required","additionalProperties"]),nV=["oneOf","anyOf"];function nH(e){let t=e.additionalProperties;return void 0===t||!1===t||"object"!=typeof t||null===t?null:Object.keys(t).length?t:null}function nJ(e){let t=[];for(let r of e){if("object"!=typeof r||"object"!==r.type)return null;for(let e in r)if(!nq.has(e))return null;t.push(r)}let r={},a=new Set;for(let e of t){for(let a in e.properties){if(Object.prototype.hasOwnProperty.call(r,a))continue;let e=[];for(let r of t){let t=r.properties?.[a]??nH(r);null!=t&&(e.some(e=>JSON.stringify(e)===JSON.stringify(t))||e.push(t))}eu(r,a,1===e.length?e[0]:nJ(e)??{allOf:e})}for(let t of e.required??[])a.add(t)}let n={type:"object",properties:r};if(a.size&&(n.required=[...a]),t.every(e=>!1===e.additionalProperties))n.additionalProperties=!1;else{let e=[];for(let r of t){let t=nH(r);t&&!e.some(e=>JSON.stringify(e)===JSON.stringify(t))&&e.push(t)}1===e.length?n.additionalProperties=e[0]:e.length>1&&(n.additionalProperties={allOf:e})}return n}function nW(e,t){let r=e.seen.get(t);if(!r)throw Error("Unprocessed schema. This is a bug in Zod.");let a=t=>{let r=e.seen.get(t);if(null===r.ref)return;let n=r.def??r.schema,i={...n},o=r.ref;if(r.ref=null,o){a(o);let r=e.seen.get(o),s=r.schema;if(s.$ref&&("draft-07"===e.target||"draft-04"===e.target||"openapi-3.0"===e.target)?(n.allOf=n.allOf??[],n.allOf.push(s)):nD(n,s),nD(n,i),t._zod.parent===o)for(let e in n)"$ref"!==e&&"allOf"!==e&&(e in i||delete n[e]);if(s.$ref&&r.def)for(let e in n)"$ref"!==e&&"allOf"!==e&&e in r.def&&JSON.stringify(n[e])===JSON.stringify(r.def[e])&&delete n[e]}let s=t._zod.parent;if(s&&s!==o){a(s);let t=e.seen.get(s);if(t?.schema.$ref&&(n.$ref=t.schema.$ref,t.def))for(let e in n)"$ref"!==e&&"allOf"!==e&&e in t.def&&JSON.stringify(n[e])===JSON.stringify(t.def[e])&&delete n[e]}e.override({zodSchema:t,jsonSchema:n,path:r.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let t of[...e.seen.entries()].reverse())a(t[0]);if("openapi-3.0"!==e.target)for(let t of e.seen.entries())!function e(t){let r=t.anyOf;if(!Array.isArray(r)||0===r.length||void 0!==t.type)return;let a=[];for(let t of r){if(!t||"object"!=typeof t)return;e(t);let r=Object.keys(t);if(1!==r.length||"type"!==r[0])return;let n=t.type;for(let e of Array.isArray(n)?n:[n]){if("string"!=typeof e)return;a.includes(e)||a.push(e)}}delete t.anyOf,t.type=1===a.length?a[0]:a}(t[1].def??t[1].schema);for(let t of e.deferred)t();if(e.intersections.length){let t=new Map;for(let r of e.seen.values())for(let e of[r.schema,r.def]){let r=e?.allOf;if(!Array.isArray(r))continue;let a=t.get(r);a?a.push(e):t.set(r,[e])}for(let r of e.intersections)for(let e of t.get(r)??[])!function(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let t of nq)if(t in e)return;let r=t.filter(e=>nV.some(t=>Array.isArray(e[t]))),a=null;if(r.length){let e=r[0],n=nV.find(t=>Array.isArray(e[t]));if(1!==Object.keys(e).length)return;let i=t.filter(t=>t!==e),o=e[n].map(e=>nJ([...i,e]));if(o.some(e=>!e))return;a={[n]:o}}else a=nJ(t);a&&(delete e.allOf,nD(e,a))}(e)}}let n={};if("draft-2020-12"===e.target?n.$schema="https://json-schema.org/draft/2020-12/schema":"draft-07"===e.target?n.$schema="http://json-schema.org/draft-07/schema#":"draft-04"===e.target?n.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){let r=e.external.registry.get(t)?.id;if(!r)throw Error("Schema is missing an `id` property");n.$id=e.external.uri(r)}nD(n,r.defId?r.schema:r.def??r.schema);let i=e.metadataRegistry.get(t)?.id;void 0!==i&&n.id===i&&delete n.id;let o=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,eu(o,e.defId,e.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(o).length>0&&("draft-2020-12"===e.target?n.$defs=o:n.definitions=o);try{let r=JSON.parse(JSON.stringify(n));return Object.defineProperty(r,"~standard",{value:{...t["~standard"],jsonSchema:{input:nG(t,"input",e.processors),output:nG(t,"output",e.processors)}},enumerable:!1,writable:!1}),r}catch(e){throw Error("Error converting schema to JSON.")}}let nG=(e,t,r={})=>a=>{let{libraryOptions:n,target:i}=a??{},o=nU({...n??{},target:i,io:t,processors:r});return nL(e,o),nB(o,e),nW(o,e)},nK=(e,t,r)=>{(void 0===e[t]||r>e[t])&&(e[t]=r)},nY=(e,t,r)=>{(void 0===e[t]||r<e[t])&&(e[t]=r)},nX=(e,t)=>{nK(e,"minimum",t),nY(e,"maximum",t)},nQ=(e,t)=>{e.multipleOf??(e.multipleOf=[]),e.multipleOf.includes(t)||e.multipleOf.push(t)},n0=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},n1=(e,t)=>{e.mime=e.mime?e.mime.filter(e=>t.includes(e)):[...t]},n2=(e,t)=>{e.format=t,t.includes("int")&&(e.isInt=!0)},n4=(e,t)=>nK(e,"minimum",t.minimum),n5=(e,t)=>nY(e,"maximum",t.maximum),n6=e=>(t,r)=>{n2(t,r.format);let[a,n]=e[r.format];nK(t,"minimum",a),nY(t,"maximum",n)},n9={greater_than:(e,t)=>nK(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>nY(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>nQ(e,t.value),number_format:n6(ej),bigint_format:n6(eD),min_length:n4,max_length:n5,length_equals:(e,t)=>nX(e,t.length),min_size:n4,max_size:n5,size_equals:(e,t)=>nX(e,t.size),string_format:(e,t)=>{n2(e,t.format),t.pattern&&n0(e,t.pattern),("base64"===t.format||"base64url"===t.format)&&(e.contentEncoding=t.format),(t.local||-1===t.precision)&&(e.laxFormat=!0)},mime_type:(e,t)=>n1(e,t.mime)};function n3(e){let t={},r=e._zod.def;for(let a of e._zod.traits.has("$ZodCheck")?[e,...r.checks??[]]:r.checks??[])n9[a._zod.def.check]?.(t,a._zod.def);let a=e._zod.bag;for(let e of(void 0!==a.minimum&&nK(t,"minimum",a.minimum),void 0!==a.exclusiveMinimum&&nK(t,"exclusiveMinimum",a.exclusiveMinimum),void 0!==a.maximum&&nY(t,"maximum",a.maximum),void 0!==a.exclusiveMaximum&&nY(t,"exclusiveMaximum",a.exclusiveMaximum),void 0!==a.multipleOf&&nQ(t,a.multipleOf),void 0!==a.format&&(t.format??(t.format=a.format),a.format.includes("int")&&(t.isInt=!0)),a.mime&&n1(t,a.mime),a.patterns??[]))n0(t,e);return t}let n8={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},n7=new Map([[aD,rd],[aZ,rp]]),ie=e=>n7.get(e)??e,it=(e,t,r,a)=>{r.type="string";let{minimum:n,maximum:i,format:o,patterns:s,contentEncoding:l,laxFormat:u}=n3(e);if("number"==typeof n&&(r.minLength=n),"number"==typeof i&&(r.maxLength=i),o&&(r.format=n8[o]??o,""===r.format&&delete r.format,("time"===o||u)&&delete r.format),l&&(r.contentEncoding=l),s&&s.size>0){let e=[...s].map(ie);1===e.length?r.pattern=e[0].source:e.length>1&&(r.allOf=[...e.map(e=>({..."draft-07"===t.target||"draft-04"===t.target||"openapi-3.0"===t.target?{type:"string"}:{},pattern:e.source}))])}},ir=(e,t,r,a)=>{let{minimum:n,maximum:i,multipleOf:o,exclusiveMaximum:s,exclusiveMinimum:l,isInt:u}=n3(e);r.type=u?"integer":"number";let c="number"==typeof l&&l>=(n??-1/0),d="number"==typeof s&&s<=(i??1/0),p="draft-04"===t.target||"openapi-3.0"===t.target;if(c?p?(r.minimum=l,r.exclusiveMinimum=!0):r.exclusiveMinimum=l:"number"==typeof n&&(r.minimum=n),d?p?(r.maximum=s,r.exclusiveMaximum=!0):r.exclusiveMaximum=s:"number"==typeof i&&(r.maximum=i),o){let n=new Set;for(let i of o)Number.isFinite(i)&&0!==i?n.add(Math.abs(i)):nZ(e,t,r,a,`A multipleOf divisor of ${i} cannot be represented in JSON Schema`);let[i,...s]=n;void 0!==i&&(r.multipleOf=i),s.length&&(r.allOf=[...r.allOf??[],...s.map(e=>({multipleOf:e}))])}},ia=(e,t,r,a)=>{r.type="boolean"},ii=(e,t,r,a)=>{nZ(e,t,r,a,"BigInt cannot be represented in JSON Schema")},io=(e,t,r,a)=>{"openapi-3.0"===t.target?(r.type="string",r.nullable=!0,r.enum=[null]):r.type="null"},is=(e,t,r,a)=>{r.not={}},il=(e,t,r,a)=>{},iu=(e,t,r,a)=>{},ic=(e,t,r,a)=>{let n=X(e._zod.def.entries);if(0===n.length){r.not={};return}n.every(e=>"number"==typeof e)&&(r.type="number"),n.every(e=>"string"==typeof e)&&(r.type="string"),r.enum=n},id=(e,t,r,a)=>{let n=e._zod.def;if(0===n.values.length){r.not={};return}let i=[];for(let o of n.values)if(void 0===o){if(nZ(e,t,r,a,"Literal `undefined` cannot be represented in JSON Schema"))return}else if("bigint"==typeof o){if(nZ(e,t,r,a,"BigInt literals cannot be represented in JSON Schema"))return;i.push(Number(o))}else i.push(o);if(0===i.length);else if(1===i.length){let e=i[0];r.type=null===e?"null":typeof e,"draft-04"===t.target||"openapi-3.0"===t.target?r.enum=[e]:r.const=e}else i.every(e=>"number"==typeof e)&&(r.type="number"),i.every(e=>"string"==typeof e)&&(r.type="string"),i.every(e=>"boolean"==typeof e)&&(r.type="boolean"),i.every(e=>null===e)&&(r.type="null"),r.enum=i},ip=(e,t,r,a)=>{nZ(e,t,r,a,"Custom types cannot be represented in JSON Schema")},ih=(e,t,r,a)=>{nZ(e,t,r,a,"Transforms cannot be represented in JSON Schema")},im=(e,t,r,a)=>{let n=e._zod.def,{minimum:i,maximum:o}=n3(e);"number"==typeof i&&(r.minItems=i),"number"==typeof o&&(r.maxItems=o),r.type="array",r.items=nL(n.element,t,{...a,path:[...a.path,"items"]})};function ig(e){let t=e._zod.def;return"pipe"===t.type&&t.in._zod.traits.has("$ZodTransform")?ig(t.out):"catch"===t.type?ig(t.innerType):e._zod.optin}let iy=(e,t,r,a)=>{let n=e._zod.def,i=n.shape;if(Object.getOwnPropertySymbols(i).length&&nZ(e,t,r,a,"Symbol keys cannot be represented in JSON Schema"))return;for(let e in r.type="object",r.properties={},i)eu(r.properties,e,nL(i[e],t,{...a,path:[...a.path,"properties",e]}));let o=[];for(let e of Object.keys(i)){let r=n.shape[e];("input"===t.io?void 0===ig(r):void 0===r._zod.optout)&&o.push(e)}o.length>0&&(r.required=o),n.catchall?._zod.def.type==="never"?r.additionalProperties=!1:n.catchall?n.catchall&&(r.additionalProperties=nL(n.catchall,t,{...a,path:[...a.path,"additionalProperties"]})):"output"===t.io&&(r.additionalProperties=!1)},iv=(e,t,r,a)=>{let n=e._zod.def,i=!1===n.inclusive,o=n.options.map((e,r)=>nL(e,t,{...a,path:[...a.path,i?"oneOf":"anyOf",r]}));i?r.oneOf=o:r.anyOf=o},ib=(e,t,r,a)=>{let n=e._zod.def,i=nL(n.left,t,{...a,path:[...a.path,"allOf",0]}),o=nL(n.right,t,{...a,path:[...a.path,"allOf",1]}),s=e=>"allOf"in e&&1===Object.keys(e).length,l=[...s(i)?i.allOf:[i],...s(o)?o.allOf:[o]];r.allOf=l,t.intersections.push(l)},iw=new WeakMap,i_=(e,t,r,a)=>{let n=e._zod.def;r.type="object";let i=n.keyType,o=n3(i).patterns;if("loose"===n.mode&&o&&o.size>0){let e=nL(n.valueType,t,{...a,path:[...a.path,"patternProperties","*"]});for(let t of(r.patternProperties={},o))eu(r.patternProperties,ie(t).source,e)}else{if("draft-07"===t.target||"draft-2020-12"===t.target){r.propertyNames=nL(n.keyType,t,{...a,path:[...a.path,"propertyNames"]});let i=iw.get(t);i||(i=[],iw.set(t,i),t.deferred.push(()=>(function(e){let t=new Map;for(let r of e.seen.values())r.def&&!t.has(r.schema)&&t.set(r.schema,r);let r=new Map;for(let a of iw.get(e)??[]){let n=e.seen.get(a),i=(n?.def??n?.schema)?.propertyNames;if(!i||!0===i||r.has(i))continue;let o=function e(t,r,a){if(r.$ref){if(a.has(r))return r;a.add(r);let n=t.get(r)?.def;if(!n)return r;let i=e(t,n,a);return i===n?r:i}for(let n of["anyOf","oneOf"]){let i=r[n];if(!Array.isArray(i))continue;let o=i.map(r=>e(t,r,a));o.some((e,t)=>e!==i[t])&&(r={...r,[n]:o})}let n=Array.isArray(r.type)?r.type:[r.type],i=!n.includes("string")&&n.some(e=>"number"===e||"integer"===e),o=r.enum??(void 0!==r.const?[r.const]:void 0);if(!i&&!o?.some(e=>"number"==typeof e))return r;let{minimum:s,maximum:l,exclusiveMinimum:u,exclusiveMaximum:c,multipleOf:d,format:p,id:f,...h}=r;return h.enum?h.enum=h.enum.map(e=>"number"==typeof e?String(e):e):"number"==typeof h.const&&(h.const=String(h.const)),i&&(h.type="string",o||(h.pattern=(n.includes("number")?rI:rx).source)),h}(t,i,new Set);o!==i&&r.set(i,o)}if(r.size)for(let t of e.seen.values())for(let e of[t.schema,t.def]){let t=e&&r.get(e.propertyNames);t&&(e.propertyNames=t)}})(t))),i.push(e)}r.additionalProperties=nL(n.valueType,t,{...a,path:[...a.path,"additionalProperties"]})}let s=i._zod.values,l="input"===t.io&&void 0!==ig(n.valueType);if(s&&!n.partial&&!l){let e=[...s].filter(e=>"string"==typeof e||"number"==typeof e);e.length>0&&(r.required=e.map(String))}},ik=(e,t,r,a)=>{let n=e._zod.def,i=nL(n.innerType,t,a),o=t.seen.get(e);"openapi-3.0"===t.target?(o.ref=n.innerType,r.nullable=!0):r.anyOf=[i,{type:"null"}]},iS=(e,t,r,a)=>{let n=e._zod.def;nL(n.innerType,t,a),t.seen.get(e).ref=n.innerType},iE=Symbol();function ix(e,t,r,a,n){let i=!1,o=JSON.stringify(e,(e,t)=>"bigint"!=typeof t?t:(i=!0,null));return i?(nZ(t,r,a,n,"BigInt defaults cannot be represented in JSON Schema"),iE):JSON.parse(o)}let iI=(e,t,r,a)=>{let n=e._zod.def;nL(n.innerType,t,a),t.seen.get(e).ref=n.innerType;let i=ix(n.defaultValue,e,t,r,a);i!==iE&&(r.default=i)},iA=(e,t,r,a)=>{let n=e._zod.def;if(nL(n.innerType,t,a),t.seen.get(e).ref=n.innerType,"input"!==t.io)return;let i=ix(n.defaultValue,e,t,r,a);i!==iE&&(r._prefault=i)},iT=(e,t,r,a)=>{let n,i=e._zod.def;nL(i.innerType,t,a),t.seen.get(e).ref=i.innerType;try{n=i.catchValue(void 0)}catch{nZ(e,t,r,a,"Dynamic catch values are not supported in JSON Schema");return}r.default=n},iO=(e,t,r,a)=>{let n=e._zod.def,i=n.in._zod.traits.has("$ZodTransform"),o="input"===t.io?i?n.out:n.in:n.out;nL(o,t,a),t.seen.get(e).ref=o},iM=(e,t,r,a)=>{let n=e._zod.def;nL(n.innerType,t,a),t.seen.get(e).ref=n.innerType,r.readOnly=!0},iz=(e,t,r,a)=>{let n=e._zod.def;nL(n.innerType,t,a),t.seen.get(e).ref=n.innerType},iR=(e,t,r,a)=>{let n=e._zod.innerType;nL(n,t,a),t.seen.get(e).ref=n},iC={string:it,number:ir,boolean:ia,bigint:ii,symbol:(e,t,r,a)=>{nZ(e,t,r,a,"Symbols cannot be represented in JSON Schema")},null:io,undefined:(e,t,r,a)=>{nZ(e,t,r,a,"Undefined cannot be represented in JSON Schema")},void:(e,t,r,a)=>{nZ(e,t,r,a,"Void cannot be represented in JSON Schema")},never:is,any:il,unknown:iu,date:(e,t,r,a)=>{nZ(e,t,r,a,"Date cannot be represented in JSON Schema")},enum:ic,literal:id,nan:(e,t,r,a)=>{nZ(e,t,r,a,"NaN cannot be represented in JSON Schema")},template_literal:(e,t,r,a)=>{let n=e._zod.pattern;if(!n)throw Error("Pattern not found in template literal");r.type="string",r.pattern=n.source},file:(e,t,r,a)=>{r.type="string",r.format="binary",r.contentEncoding="binary";let{minimum:n,maximum:i,mime:o}=n3(e);void 0!==n&&(r.minLength=n),void 0!==i&&(r.maxLength=i),o&&(0===o.length?r.not={}:1===o.length?r.contentMediaType=o[0]:r.anyOf=o.map(e=>({contentMediaType:e})))},success:(e,t,r,a)=>{r.type="boolean"},custom:ip,function:(e,t,r,a)=>{nZ(e,t,r,a,"Function types cannot be represented in JSON Schema")},transform:ih,map:(e,t,r,a)=>{nZ(e,t,r,a,"Map cannot be represented in JSON Schema")},set:(e,t,r,a)=>{nZ(e,t,r,a,"Set cannot be represented in JSON Schema")},array:im,object:iy,union:iv,intersection:ib,tuple:(e,t,r,a)=>{let n=e._zod.def;r.type="array";let i="draft-2020-12"===t.target?"prefixItems":"items",o="draft-2020-12"===t.target||"openapi-3.0"===t.target?"items":"additionalItems",s=n.items.map((e,r)=>nL(e,t,{...a,path:[...a.path,i,r]})),l=n.rest?nL(n.rest,t,{...a,path:[...a.path,o,..."openapi-3.0"===t.target?[n.items.length]:[]]}):null,u=n.items.length;for(;u>0;){let e=n.items[u-1];if(!("input"===t.io?void 0!==ig(e):"optional"===e._zod.optout))break;u--}let c=n.items.length,d=!n.rest;"draft-2020-12"===t.target?(r.prefixItems=s,d?r.items=!1:l&&(r.items=l)):"openapi-3.0"===t.target?(r.items={anyOf:s},l&&r.items.anyOf.push(l)):(r.items=s,d?r.additionalItems=!1:l&&(r.additionalItems=l)),u>0&&(r.minItems=u),d&&(r.maxItems=c);let{minimum:p,maximum:f}=n3(e);"number"==typeof p&&(r.minItems=p),"number"==typeof f&&(r.maxItems=f)},record:i_,nullable:ik,nonoptional:iS,default:iI,prefault:iA,catch:iT,pipe:iO,readonly:iM,promise:(e,t,r,a)=>{let n=e._zod.def;nL(n.innerType,t,a),t.seen.get(e).ref=n.innerType},optional:iz,lazy:iR};class iP extends Error{constructor(e,t){super(e),this.name="ParseError",this.type=t.type,this.field=t.field,this.value=t.value,this.line=t.line}}function i$(e){}function iN(e,t,r){return 100===r&&97===e.charCodeAt(t+1)&&116===e.charCodeAt(t+2)&&97===e.charCodeAt(t+3)&&58===e.charCodeAt(t+4)}function ij(e,t,r){return 101===r&&118===e.charCodeAt(t+1)&&101===e.charCodeAt(t+2)&&110===e.charCodeAt(t+3)&&116===e.charCodeAt(t+4)&&58===e.charCodeAt(t+5)}class iD extends TransformStream{constructor({onError:e,onRetry:t,onComment:r,maxBufferSize:a}={}){let n;super({start(i){n=function(e){if("function"==typeof e)throw TypeError("`config` must be an object, got a function instead. Did you mean `createParser({onEvent: fn})`?");let{onEvent:t=i$,onError:r=i$,onRetry:a=i$,onComment:n,maxBufferSize:i}=e,o=[],s=0,l=!0,u,c="",d=0,p,f=!1;function h(){void 0!==i&&(s+c.length<=i||(f=!0,o.length=0,s=0,u=void 0,c="",d=0,p=void 0,r(new iP(`Buffered data exceeded max buffer size of ${i} characters`,{type:"max-buffer-size-exceeded"}))))}function m(e){let r=0;if(-1===e.indexOf("\r")){let a=e.indexOf(`
58
- `,r);for(;-1!==a;){if(r===a){d>0&&t({id:u,event:p,data:c}),u=void 0,c="",d=0,p=void 0,r=a+1,a=e.indexOf(`
59
- `,r);continue}let n=e.charCodeAt(r);if(iN(e,r,n)){let n=32===e.charCodeAt(r+5)?r+6:r+5,i=e.slice(n,a);if(0===d&&10===e.charCodeAt(a+1)){t({id:u,event:p,data:i}),u=void 0,c="",p=void 0,r=a+2,a=e.indexOf(`
60
- `,r);continue}c=0===d?i:`${c}
61
- ${i}`,d++}else ij(e,r,n)?p=e.slice(32===e.charCodeAt(r+6)?r+7:r+6,a)||void 0:g(e,r,a);r=a+1,a=e.indexOf(`
62
- `,r)}return e.slice(r)}for(;r<e.length;){let t=e.indexOf("\r",r),a=e.indexOf(`
63
- `,r),n=-1;if(-1!==t&&-1!==a?n=t<a?t:a:-1!==t?n=t===e.length-1?-1:t:-1!==a&&(n=a),-1===n)break;g(e,r,n),r=n+1,13===e.charCodeAt(r-1)&&10===e.charCodeAt(r)&&r++}return e.slice(r)}function g(e,r,a){if(r===a)return void(d>0&&t({id:u,event:p,data:c}),u=void 0,c="",d=0,p=void 0);let i=e.charCodeAt(r);if(iN(e,r,i)){let t=32===e.charCodeAt(r+5)?r+6:r+5,n=e.slice(t,a);c=0===d?n:`${c}
64
- ${n}`,d++;return}if(ij(e,r,i)){p=e.slice(32===e.charCodeAt(r+6)?r+7:r+6,a)||void 0;return}if(105===i&&100===e.charCodeAt(r+1)&&58===e.charCodeAt(r+2)){let t=e.slice(32===e.charCodeAt(r+3)?r+4:r+3,a);t.includes("\0")||(u=t);return}if(58===i){n&&n(e.slice(r,a).slice(32===e.charCodeAt(r+1)?2:1));return}let o=e.slice(r,a),s=o.indexOf(":");if(-1===s)return void y(o,"",o);let l=o.slice(0,s),f=32===o.charCodeAt(s+1)?2:1;y(l,o.slice(s+f),o)}function y(e,t,n){switch(e){case"event":p=t||void 0;break;case"data":c=0===d?t:`${c}
65
- ${t}`,d++;break;case"id":t.includes("\0")||(u=t);break;case"retry":/^\d+$/.test(t)?a(parseInt(t,10)):r(new iP(`Invalid \`retry\` value: "${t}"`,{type:"invalid-retry",value:t,line:n}));break;default:r(new iP(`Unknown field "${e.length>20?`${e.slice(0,20)}…`:e}"`,{type:"unknown-field",field:e,value:t,line:n}))}}return{feed:function(e){if(f)throw Error("Cannot feed parser: it was terminated after exceeding the configured max buffer size. Call `reset()` to resume parsing.");if(l&&(l=!1,239===e.charCodeAt(0)&&187===e.charCodeAt(1)&&191===e.charCodeAt(2)&&(e=e.slice(3))),0===o.length){let t=m(e);""!==t&&(o.push(t),s=t.length),h();return}if(-1===e.indexOf(`
66
- `)&&-1===e.indexOf("\r")){o.push(e),s+=e.length,h();return}o.push(e);let t=o.join("");o.length=0,s=0;let r=m(t);""!==r&&(o.push(r),s=r.length),h()},reset:function(e={}){if(e.consume&&o.length>0){let e=o.join("");g(e,0,e.length)}l=!0,u=void 0,c="",d=0,p=void 0,o.length=0,s=0,f=!1}}}({onEvent:e=>{i.enqueue(e)},onError(t){"function"==typeof e&&e(t),("terminate"===e||"max-buffer-size-exceeded"===t.type)&&i.error(t)},onRetry:t,onComment:r,maxBufferSize:a})},transform(e){n.feed(e)}})}}let iU=Symbol.for("workflow-serialize"),iZ=Symbol.for("workflow-deserialize");function iL(...e){return e.reduce((e,t)=>({...e,...t}),{})}async function iF(e,t){if(null==e)return;let r=t?.abortSignal;return new Promise((t,a)=>{if(r?.aborted)return void a(iB());let n=setTimeout(()=>{i(),t()},e),i=()=>{clearTimeout(n),r?.removeEventListener("abort",o)},o=()=>{i(),a(iB())};r?.addEventListener("abort",o)})}function iB(){return new DOMException("Delay was aborted","AbortError")}let iq=new TextDecoder;async function iV(e){return"string"==typeof e?e:e instanceof ArrayBuffer||ArrayBuffer.isView(e)?iq.decode(e):"u">typeof Blob&&e instanceof Blob?e.text():String(e)}async function iH(e,{highWaterMark:t=1048576,pollIntervalMs:r=20,abortSignal:a}={}){for(;1===e.readyState&&(e.bufferedAmount??0)>t;){if(a?.aborted===!0)return;await iF(r)}}let{btoa:iJ,atob:iW}=globalThis;function iG(e){let t=[];for(let r=0;r<e.length;r+=4096)t.push(String.fromCodePoint(...e.subarray(r,r+4096)));return iJ(t.join(""))}function iK(e){return Object.fromEntries([...e.headers])}function iY(e=globalThis){return e.navigator?.userAgent?e.navigator.userAgent.toLowerCase():e.process?.versions?.node?`node.js/${e.process.version}`:e.EdgeRuntime?"vercel-edge":""}function iX(e){return(e instanceof Error||"function"==typeof DOMException&&e instanceof DOMException)&&("AbortError"===e.name||"ResponseAborted"===e.name||"TimeoutError"===e.name)}Symbol.for("vercel.ai.providerStreamError");let iQ=["fetch failed","failed to fetch"],i0=new Set(["ConnectionRefused","ConnectionClosed","FailedToOpenSocket","ECONNRESET","ECONNREFUSED","ETIMEDOUT","EPIPE","UND_ERR_SOCKET","UND_ERR_HEADERS_TIMEOUT","UND_ERR_BODY_TIMEOUT","UND_ERR_CONNECT_TIMEOUT"]);function i1({error:e,url:t,requestBodyValues:r}){if(iX(e))return e;if(e instanceof TypeError&&iQ.includes(e.message.toLowerCase())){let a=e.cause;if(null!=a)return new E({message:`Cannot connect to API: ${a.message}`,cause:a,url:t,requestBodyValues:r,isRetryable:!0})}let a=function(e){let t=new Set,r=e;for(;r instanceof Error&&!t.has(r);){t.add(r);let e=r;if("string"==typeof e.code&&i0.has(e.code))return e;r=r.cause}}(e);return null!=a?new E(E.isInstance(e)?{message:e.message,cause:e.cause,url:e.url,requestBodyValues:e.requestBodyValues,statusCode:e.statusCode,responseHeaders:e.responseHeaders,responseBody:e.responseBody,data:e.data,isRetryable:!0}:{message:`Cannot connect to API: ${e instanceof Error?e.message:a.message}`,cause:e,url:t,requestBodyValues:r,isRetryable:!0}):e}let i2="5.0.61";function i4(e){if(null==e)return{};let t={};if(e instanceof Headers)e.forEach((e,r)=>{t[r.toLowerCase()]=e});else for(let[r,a]of(Array.isArray(e)||(e=Object.entries(e)),e))null!=a&&(t[r.toLowerCase()]=a);return t}function i5(e,...t){let r=new Headers(i4(e)),a=r.get("user-agent")||"";return r.set("user-agent",[a,...t].filter(Boolean).join(" ")),Object.fromEntries(r.entries())}async function i6(e){try{await e.body?.cancel()}catch{}}let i9="AI_DownloadError",i3=`vercel.ai.error.${i9}`,i8=Symbol.for(i3);var i7=class extends w{constructor({url:e,statusCode:t,statusText:r,cause:a,message:n=null==a?`Failed to download ${e}: ${t} ${r}`:`Failed to download ${e}: ${a}`}){super({name:i9,message:n,cause:a}),this[i8]=!0,this.url=e,this.statusCode=t,this.statusText=r}static isInstance(e){return w.hasMarker(e,i3)}};function oe(e,t){try{return new URL(e).origin===new URL(t).origin}catch{return!1}}function ot(e){let t=e.split(".");return 4===t.length&&t.every(e=>{let t=Number(e);return Number.isInteger(t)&&t>=0&&t<=255&&String(t)===e})}function or(e){let[t,r,a]=e.split(".").map(Number);return 0===t||10===t||100===t&&r>=64&&r<=127||127===t||169===t&&254===r||172===t&&r>=16&&r<=31||192===t&&0===r&&0===a||192===t&&0===r&&2===a||192===t&&168===r||198===t&&(18===r||19===r)||198===t&&51===r&&100===a||203===t&&0===r&&113===a||t>=224||!1}function oa(e){let t=function(e){let t=e.toLowerCase(),r=t.indexOf("%");-1!==r&&(t=t.slice(0,r));let a=t.split("::");if(a.length>2)return null;let n=e=>{if(""===e)return[];let t=[],r=e.split(":");for(let e=0;e<r.length;e++){let a=r[e];if(a.includes(".")){if(e!==r.length-1||!ot(a))return null;let[n,i,o,s]=a.split(".").map(Number);t.push(n<<8|i,o<<8|s);continue}if(!/^[0-9a-f]{1,4}$/.test(a))return null;t.push(parseInt(a,16))}return t},i=n(a[0]);if(null===i)return null;if(2===a.length){let e=n(a[1]);if(null===e)return null;let t=8-i.length-e.length;return t<0?null:[...i,...Array(t).fill(0),...e]}return 8===i.length?i:null}(e);if(null===t)return!0;let r=e=>t.slice(0,e).every(e=>0===e);return!!r(7)&&(0===t[7]||1===t[7])||(65024&t[0])==64512||(65472&t[0])==65152||(65472&t[0])==65216||(65280&t[0])==65280||8193===t[0]&&3512===t[1]||16383===t[0]&&(61440&t[1])==0||(!!(r(6)||r(5)&&65535===t[5]||r(4)&&65535===t[4]&&0===t[5])||100===t[0]&&65435===t[1]&&0===t[2]&&0===t[3]&&0===t[4]&&0===t[5]||100===t[0]&&65435===t[1]&&1===t[2])&&or(`${t[6]>>8&255}.${255&t[6]}.${t[7]>>8&255}.${255&t[7]}`)}async function on(){let e;return(e=globalThis.process,e?.release?.name!=="node"||e.versions?.bun!=null||e.versions?.deno!=null||"workerd"===e.title||null!=globalThis.EdgeRuntime)?globalThis.fetch:r??=Promise.resolve().then(oi)}function oi(){let e=oo("node:module"),{lookup:t}=oo("node:dns"),{Agent:r,fetch:a}=e.createRequire(function e(){let t=Error.prepareStackTrace;try{Error.prepareStackTrace=(e,t)=>t;let t=Error("Capture current module path");Error.captureStackTrace(t,e);let[r]=t.stack,a=r?.getFileName();if(null==a)throw Error("Unable to determine the current module path");return a}finally{Error.prepareStackTrace=t}}())("undici"),n=new r({connect:{lookup:(e,r,a)=>{t(e,{...r,all:!0},(t,n)=>{if(t)return void a(t);try{let[t]=n;if(null==t)throw Error(`Hostname ${e} did not resolve to an address`);for(let{address:t,family:r}of n)!function({address:e,family:t,hostname:r}){if(4===t?!ot(e)||or(e):6!==t||oa(e))throw new i7({url:r,message:`Hostname ${r} resolved to disallowed IP address ${e}`})}({address:t,family:r,hostname:e});!0===r.all?a(null,n):a(null,t.address,t.family)}catch(e){a(e instanceof Error?e:Error(String(e)))}})}}});return(e,t)=>a(e,{...t,dispatcher:n})}function oo(e){let t=globalThis.process?.getBuiltinModule?.(e);if(null==t)throw Error(`Node.js built-in module ${e} is unavailable`);return t}let os=["connection","keep-alive","te","trailer","transfer-encoding","upgrade","host","forwarded","proxy-authorization","via","x-forwarded-for","x-forwarded-host","x-forwarded-proto","x-real-ip","metadata","metadata-flavor","x-aws-ec2-metadata-token","x-metadata-token","cookie","set-cookie"];function ol(e){let t=new Headers(e);for(let e of os)t.delete(e);return t}let ou=new Set([301,302,303,307,308]);async function oc(e){return null==e||e===globalThis.fetch?await on():e}async function od({url:e,headers:t,abortSignal:r,maxRedirects:a=10,fetch:n,trustedOrigin:i}){let o=void 0===t?void 0:ol(t),s=e=>{let t={signal:r,redirect:e};return void 0!==o&&(t.headers=new Headers(o)),t},l=e;for(let t=0;t<=a;t++){let t=void 0!==i&&oe(l,i);t||function(e){let t;try{t=new URL(e)}catch{throw new i7({url:e,message:`Invalid URL: ${e}`})}if("data:"===t.protocol)return;if("http:"!==t.protocol&&"https:"!==t.protocol)throw new i7({url:e,message:`URL scheme must be http, https, or data, got ${t.protocol}`});let r=t.hostname.toLowerCase().replace(/\.+$/,"");if(!r)throw new i7({url:e,message:"URL must have a hostname"});if("localhost"===r||r.endsWith(".local")||r.endsWith(".localhost"))throw new i7({url:e,message:`URL with hostname ${r} is not allowed`});if(r.startsWith("[")&&r.endsWith("]")){if(oa(r.slice(1,-1)))throw new i7({url:e,message:`URL with IPv6 address ${r} is not allowed`});return}if(ot(r)&&or(r))throw new i7({url:e,message:`URL with IP address ${r} is not allowed`})}(l);let r=t&&null!=n?n:t?globalThis.fetch:await oc(n),a=await r(l,s("manual"));if("opaqueredirect"===a.type){if(!function(e=globalThis){return null!=e.window}())throw new i7({url:e,message:`Redirect from ${l} could not be validated and was blocked`});return await r(l,s("follow"))}let u=a.headers?.get("location");if(ou.has(a.status)&&u){i6(a);let e=new URL(u,l).toString();if(void 0!==o&&!oe(e,l)){let e=o.get("user-agent");o=new Headers(null==e?void 0:{"user-agent":e})}l=e;continue}return a}throw new i7({url:e,message:`Too many redirects (max ${a})`})}let op=new Set(["accept","accept-language","baggage","cache-control","idempotency-key","if-match","if-modified-since","if-none-match","if-range","if-unmodified-since","pragma","range","traceparent","tracestate","user-agent","x-correlation-id","x-request-id"]);async function of({headers:e,credentialedOrigin:t,untrustedFirstHopHeaders:r,...a}){let n;if(void 0!==e){n=ol(e);let i=t??a.trustedOrigin;if(void 0===i||!oe(a.url,i)){let e=new Set([...op,...(r??[]).map(e=>e.toLowerCase())]);n=new Headers([...n].filter(([t])=>e.has(t)))}}return od({...a,headers:n})}async function oh({response:e,url:t,maxBytes:r=0x80000000}){let a=e.headers.get("content-length");if(null!=a){let n=parseInt(a,10);if(!isNaN(n)&&n>r)throw await i6(e),new i7({url:t,message:`Download of ${t} exceeded maximum size of ${r} bytes (Content-Length: ${n}).`})}let n=e.body;if(null==n)return new Uint8Array(0);let i=n.getReader(),o=[],s=0;try{for(;;){let{done:e,value:a}=await i.read();if(e)break;if((s+=a.length)>r)throw new i7({url:t,message:`Download of ${t} exceeded maximum size of ${r} bytes.`});o.push(a)}}finally{try{await i.cancel()}catch{}finally{i.releaseLock()}}let l=new Uint8Array(s),u=0;for(let e of o)l.set(e,u),u+=e.length;return l}Symbol.for("vercel.ai.embeddingModel.maxInputBytesPerCall"),Symbol.for("vercel.ai.embeddingModel.providerOptionsTransformer");let om=({prefix:e,size:t=16,alphabet:r="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",separator:a="-"}={})=>{let n=()=>{let e=r.length,a=Array(t);for(let n=0;n<t;n++)a[n]=r[Math.random()*e|0];return a.join("")};if(null==e)return n;if(r.includes(a))throw new C({argument:"separator",message:`The separator "${a}" must not be part of the alphabet "${r}".`});return()=>`${e}${a}${n()}`},og=om(),oy=async({url:e,headers:t={},successfulResponseHandler:r,failedResponseHandler:a,abortSignal:n,fetch:i,validateUrl:o,credentialedOrigin:s,trustedOrigin:l})=>{try{let u=i??globalThis.fetch,c=i5(void 0===s||oe(e,s)?t:{},`ai-sdk-provider-utils/${i2}`,iY()),d=o?await od({url:e,headers:c,abortSignal:n,fetch:i,trustedOrigin:l}):await u(e,{method:"GET",headers:c,signal:n}),p=iK(d);if(!d.ok){let t;try{t=await a({response:d,url:e,requestBodyValues:{}})}catch(t){if(iX(t)||E.isInstance(t))throw t;throw new E({message:"Failed to process error response",cause:t,statusCode:d.status,url:e,responseHeaders:p,requestBodyValues:{}})}throw t.value}try{return await r({response:d,url:e,requestBodyValues:{}})}catch(t){if(t instanceof Error&&(iX(t)||E.isInstance(t)))throw t;throw new E({message:"Failed to process successful response",cause:t,statusCode:d.status,url:e,responseHeaders:p,requestBodyValues:{}})}}catch(t){throw i1({error:t,url:e,requestBodyValues:{}})}};function ov(e){return null!=e&&"object"==typeof e&&!Array.isArray(e)}function ob({settingValue:e,environmentVariableName:t}){return"string"==typeof e?e:null!=e||void 0===y.default?void 0:null!=(e=y.default.env[t])&&"string"==typeof e?e:void 0}function ow(e){return null!=e&&Number.isSafeInteger(e)&&e>=0}let o_=/"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/,ok=/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;function oS(e){let t=JSON.parse(e);return null===t||"object"!=typeof t||!1===o_.test(e)&&!1===ok.test(e)?t:function(e){let t=[e];for(;t.length;){let e=t;for(let r of(t=[],e)){if(Object.prototype.hasOwnProperty.call(r,"__proto__")||Object.prototype.hasOwnProperty.call(r,"constructor")&&null!==r.constructor&&"object"==typeof r.constructor&&Object.prototype.hasOwnProperty.call(r.constructor,"prototype"))throw SyntaxError("Object contains forbidden prototype property");for(let e in r){let a=r[e];a&&"object"==typeof a&&t.push(a)}}}return e}(t)}function oE(e){let{stackTraceLimit:t}=Error;try{Error.stackTraceLimit=0}catch{return oS(e)}try{return oS(e)}finally{Error.stackTraceLimit=t}}function ox(e){if("object"===e.type||Array.isArray(e.type)&&e.type.includes("object")){let{additionalProperties:t}=e;e.additionalProperties=null!=t&&"boolean"!=typeof t&&oI(t);let{properties:r}=e;if(null!=r)for(let e of Object.keys(r))r[e]=oI(r[e])}null!=e.items&&(e.items=Array.isArray(e.items)?e.items.map(oI):oI(e.items)),null!=e.anyOf&&(e.anyOf=e.anyOf.map(oI)),null!=e.allOf&&(e.allOf=e.allOf.map(oI)),null!=e.oneOf&&(e.oneOf=e.oneOf.map(oI));let{definitions:t}=e;if(null!=t)for(let e of Object.keys(t))t[e]=oI(t[e]);return e}function oI(e){return"boolean"==typeof e?e:ox(e)}let oA=Symbol("Let zodToJsonSchema decide on which parser to use"),oT={name:void 0,$refStrategy:"root",basePath:["#"],effectStrategy:"input",pipeStrategy:"all",dateStrategy:"format:date-time",mapStrategy:"entries",removeAdditionalStrategy:"passthrough",allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:"definitions",strictUnions:!1,definitions:{},errorMessages:!1,patternStrategy:"escape",applyRegexFlags:!1,emailStrategy:"format:email",base64Strategy:"contentEncoding:base64",nameStrategy:"ref"};function oO(e,t){return oG(e.type._def,t)}let oM=/^[cC][^\s-]{8,}$/,oz=/^[0-9a-z]+$/,oR=/^[0-9A-HJKMNP-TV-Z]{26}$/,oC=/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9-]*\.)+[a-zA-Z]{2,}$/,oP=()=>(void 0===p&&(p=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),p),o$=/^(?:(?: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])$/,oN=/^(([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])$/,oj=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,oD=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,oU=/^[a-zA-Z0-9_-]{21}$/,oZ=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/;function oL(e,t){let r={type:"string"};if(e.checks)for(let a of e.checks)switch(a.kind){case"min":r.minLength="number"==typeof r.minLength?Math.max(r.minLength,a.value):a.value;break;case"max":r.maxLength="number"==typeof r.maxLength?Math.min(r.maxLength,a.value):a.value;break;case"email":switch(t.emailStrategy){case"format:email":oq(r,"email",a.message,t);break;case"format:idn-email":oq(r,"idn-email",a.message,t);break;case"pattern:zod":oV(r,oC,a.message,t)}break;case"url":oq(r,"uri",a.message,t);break;case"uuid":oq(r,"uuid",a.message,t);break;case"regex":oV(r,a.regex,a.message,t);break;case"cuid":oV(r,oM,a.message,t);break;case"cuid2":oV(r,oz,a.message,t);break;case"startsWith":oV(r,RegExp(`^${oF(a.value,t)}`),a.message,t);break;case"endsWith":oV(r,RegExp(`${oF(a.value,t)}$`),a.message,t);break;case"datetime":oq(r,"date-time",a.message,t);break;case"date":oq(r,"date",a.message,t);break;case"time":oq(r,"time",a.message,t);break;case"duration":oq(r,"duration",a.message,t);break;case"length":r.minLength="number"==typeof r.minLength?Math.max(r.minLength,a.value):a.value,r.maxLength="number"==typeof r.maxLength?Math.min(r.maxLength,a.value):a.value;break;case"includes":oV(r,RegExp(oF(a.value,t)),a.message,t);break;case"ip":"v6"!==a.version&&oq(r,"ipv4",a.message,t),"v4"!==a.version&&oq(r,"ipv6",a.message,t);break;case"base64url":oV(r,oD,a.message,t);break;case"jwt":oV(r,oZ,a.message,t);break;case"cidr":"v6"!==a.version&&oV(r,o$,a.message,t),"v4"!==a.version&&oV(r,oN,a.message,t);break;case"emoji":oV(r,oP(),a.message,t);break;case"ulid":oV(r,oR,a.message,t);break;case"base64":switch(t.base64Strategy){case"format:binary":oq(r,"binary",a.message,t);break;case"contentEncoding:base64":r.contentEncoding="base64";break;case"pattern:zod":oV(r,oj,a.message,t)}break;case"nanoid":oV(r,oU,a.message,t)}return r}function oF(e,t){return"escape"===t.patternStrategy?function(e){let t="";for(let r=0;r<e.length;r++)oB.has(e[r])||(t+="\\"),t+=e[r];return t}(e):e}let oB=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function oq(e,t,r,a){e.format||e.anyOf?.some(e=>e.format)?(e.anyOf||(e.anyOf=[]),e.format&&(e.anyOf.push({format:e.format}),delete e.format),e.anyOf.push({format:t,...r&&a.errorMessages&&{errorMessage:{format:r}}})):e.format=t}function oV(e,t,r,a){e.pattern||e.allOf?.some(e=>e.pattern)?(e.allOf||(e.allOf=[]),e.pattern&&(e.allOf.push({pattern:e.pattern}),delete e.pattern),e.allOf.push({pattern:oH(t,a),...r&&a.errorMessages&&{errorMessage:{pattern:r}}})):e.pattern=oH(t,a)}function oH(e,t){if(!t.applyRegexFlags||!e.flags)return e.source;let r={i:e.flags.includes("i"),m:e.flags.includes("m"),s:e.flags.includes("s")},a=r.i?e.source.toLowerCase():e.source,n="",i=!1,o=!1,s=!1;for(let e=0;e<a.length;e++){if(i){n+=a[e],i=!1;continue}if(r.i){if(o){if(a[e].match(/[a-z]/)){s?(n+=a[e],n+=`${a[e-2]}-${a[e]}`.toUpperCase(),s=!1):"-"===a[e+1]&&a[e+2]?.match(/[a-z]/)?(n+=a[e],s=!0):n+=`${a[e]}${a[e].toUpperCase()}`;continue}}else if(a[e].match(/[a-z]/)){n+=`[${a[e]}${a[e].toUpperCase()}]`;continue}}if(r.m){if("^"===a[e]){n+=`(^|(?<=[\r
67
- ]))`;continue}else if("$"===a[e]){n+=`($|(?=[\r
68
- ]))`;continue}}if(r.s&&"."===a[e]){n+=o?`${a[e]}\r
69
- `:`[${a[e]}\r
70
- ]`;continue}n+=a[e],"\\"===a[e]?i=!0:o&&"]"===a[e]?o=!1:o||"["!==a[e]||(o=!0)}try{new RegExp(n)}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 n}function oJ(e,t){let r={type:"object",additionalProperties:oG(e.valueType._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]})??t.allowedAdditionalProperties};if(e.keyType?._def.typeName==="ZodString"&&e.keyType._def.checks?.length){let{type:a,...n}=oL(e.keyType._def,t);return{...r,propertyNames:n}}if(e.keyType?._def.typeName==="ZodEnum")return{...r,propertyNames:{enum:e.keyType._def.values}};if(e.keyType?._def.typeName==="ZodBranded"&&"ZodString"===e.keyType._def.type._def.typeName&&e.keyType._def.type._def.checks?.length){let{type:a,...n}=oO(e.keyType._def,t);return{...r,propertyNames:n}}return r}let oW={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function oG(e,t,r=!1){let a=t.seen.get(e);if(t.override){let n=t.override?.(e,t,a,r);if(n!==oA)return n}if(a&&!r){let e=oK(a,t);if(void 0!==e)return e}let n={def:e,path:t.currentPath,jsonSchema:void 0};t.seen.set(e,n);let i=((e,t,r)=>{switch(t){case"ZodString":return oL(e,r);case"ZodNumber":let a={type:"number"};if(!e.checks)return a;for(let t of e.checks)switch(t.kind){case"int":a.type="integer";break;case"min":t.inclusive?a.minimum=t.value:a.exclusiveMinimum=t.value;break;case"max":t.inclusive?a.maximum=t.value:a.exclusiveMaximum=t.value;break;case"multipleOf":a.multipleOf=t.value}return a;case"ZodObject":return function(e,t){let r={type:"object",properties:{}},a=[],n=e.shape();for(let e in n){let i=n[e];if(void 0===i||void 0===i._def)continue;let o=function(e){try{return e.isOptional()}catch{return!0}}(i),s=oG(i._def,{...t,currentPath:[...t.currentPath,"properties",e],propertyPath:[...t.currentPath,"properties",e]});void 0!==s&&(r.properties[e]=s,o||a.push(e))}a.length&&(r.required=a);let i=function(e,t){if("ZodNever"!==e.catchall._def.typeName)return oG(e.catchall._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]});switch(e.unknownKeys){case"passthrough":return t.allowedAdditionalProperties;case"strict":return t.rejectedAdditionalProperties;case"strip":return"strict"===t.removeAdditionalStrategy?t.allowedAdditionalProperties:t.rejectedAdditionalProperties}}(e,t);return void 0!==i&&(r.additionalProperties=i),r}(e,r);case"ZodBigInt":let n={type:"integer",format:"int64"};if(!e.checks)return n;for(let t of e.checks)switch(t.kind){case"min":t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value;break;case"max":t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value;break;case"multipleOf":n.multipleOf=t.value}return n;case"ZodBoolean":return{type:"boolean"};case"ZodDate":return function e(t,r,a){let n=a??r.dateStrategy;if(Array.isArray(n))return{anyOf:n.map(a=>e(t,r,a))};switch(n){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":var i=t;let o={type:"integer",format:"unix-time"};for(let e of i.checks)switch(e.kind){case"min":o.minimum=e.value;break;case"max":o.maximum=e.value}return o}}(e,r);case"ZodUndefined":case"ZodNaN":case"ZodNever":return{not:{}};case"ZodNull":return{type:"null"};case"ZodArray":let i;return i={type:"array"},e.type?._def&&e.type?._def?.typeName!=="ZodAny"&&(i.items=oG(e.type._def,{...r,currentPath:[...r.currentPath,"items"]})),e.minLength&&(i.minItems=e.minLength.value),e.maxLength&&(i.maxItems=e.maxLength.value),e.exactLength&&(i.minItems=e.exactLength.value,i.maxItems=e.exactLength.value),i;case"ZodUnion":case"ZodDiscriminatedUnion":var o,s;let l,u=e.options instanceof Map?Array.from(e.options.values()):e.options;if(u.every(e=>e._def.typeName in oW&&(!e._def.checks||!e._def.checks.length))){let e=u.reduce((e,t)=>{let r=oW[t._def.typeName];return r&&!e.includes(r)?[...e,r]:e},[]);return{type:e.length>1?e:e[0]}}if(u.every(e=>"ZodLiteral"===e._def.typeName&&!e.description)){let e=u.reduce((e,t)=>{let r=typeof t._def.value;switch(r){case"string":case"number":case"boolean":return[...e,r];case"bigint":return[...e,"integer"];case"object":if(null===t._def.value)return[...e,"null"];default:return e}},[]);if(e.length===u.length){let t=e.filter((e,t,r)=>r.indexOf(e)===t);return{type:t.length>1?t:t[0],enum:u.reduce((e,t)=>e.includes(t._def.value)?e:[...e,t._def.value],[])}}}else if(u.every(e=>"ZodEnum"===e._def.typeName))return{type:"string",enum:u.reduce((e,t)=>[...e,...t._def.values.filter(t=>!e.includes(t))],[])};return o=e,s=r,(l=(o.options instanceof Map?Array.from(o.options.values()):o.options).map((e,t)=>oG(e._def,{...s,currentPath:[...s.currentPath,"anyOf",`${t}`]})).filter(e=>!!e&&(!s.strictUnions||"object"==typeof e&&Object.keys(e).length>0))).length?{anyOf:l}:void 0;case"ZodIntersection":let c,d;return c=[oG(e.left._def,{...r,currentPath:[...r.currentPath,"allOf","0"]}),oG(e.right._def,{...r,currentPath:[...r.currentPath,"allOf","1"]})].filter(e=>!!e),d=[],c.forEach(e=>{if((!("type"in e)||"string"!==e.type)&&"allOf"in e)d.push(...e.allOf);else{let t=e;if("additionalProperties"in e&&!1===e.additionalProperties){let{additionalProperties:r,...a}=e;t=a}d.push(t)}}),d.length?{allOf:d}:void 0;case"ZodTuple":return e.rest?{type:"array",minItems:e.items.length,items:e.items.map((e,t)=>oG(e._def,{...r,currentPath:[...r.currentPath,"items",`${t}`]})).reduce((e,t)=>void 0===t?e:[...e,t],[]),additionalItems:oG(e.rest._def,{...r,currentPath:[...r.currentPath,"additionalItems"]})}:{type:"array",minItems:e.items.length,maxItems:e.items.length,items:e.items.map((e,t)=>oG(e._def,{...r,currentPath:[...r.currentPath,"items",`${t}`]})).reduce((e,t)=>void 0===t?e:[...e,t],[])};case"ZodRecord":return oJ(e,r);case"ZodLiteral":let p;return"bigint"!=(p=typeof e.value)&&"number"!==p&&"boolean"!==p&&"string"!==p?{type:Array.isArray(e.value)?"array":"object"}:{type:"bigint"===p?"integer":p,const:e.value};case"ZodEnum":return{type:"string",enum:Array.from(e.values)};case"ZodNativeEnum":let f,h,m;return f=e.values,{type:1===(m=Array.from(new Set((h=Object.keys(e.values).filter(e=>"number"!=typeof f[f[e]]).map(e=>f[e])).map(e=>typeof e)))).length?"string"===m[0]?"string":"number":["string","number"],enum:h};case"ZodNullable":if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(e.innerType._def.typeName)&&(!e.innerType._def.checks||!e.innerType._def.checks.length))return{type:[oW[e.innerType._def.typeName],"null"]};let g=oG(e.innerType._def,{...r,currentPath:[...r.currentPath,"anyOf","0"]});return g&&{anyOf:[g,{type:"null"}]};case"ZodOptional":if(r.currentPath.toString()===r.propertyPath?.toString())return oG(e.innerType._def,r);let y=oG(e.innerType._def,{...r,currentPath:[...r.currentPath,"anyOf","1"]});return y?{anyOf:[{not:{}},y]}:{};case"ZodMap":return"record"===r.mapStrategy?oJ(e,r):{type:"array",maxItems:125,items:{type:"array",items:[oG(e.keyType._def,{...r,currentPath:[...r.currentPath,"items","items","0"]})||{},oG(e.valueType._def,{...r,currentPath:[...r.currentPath,"items","items","1"]})||{}],minItems:2,maxItems:2}};case"ZodSet":let v;return v={type:"array",uniqueItems:!0,items:oG(e.valueType._def,{...r,currentPath:[...r.currentPath,"items"]})},e.minSize&&(v.minItems=e.minSize.value),e.maxSize&&(v.maxItems=e.maxSize.value),v;case"ZodLazy":return()=>e.getter()._def;case"ZodPromise":return oG(e.type._def,r);case"ZodEffects":return"input"===r.effectStrategy?oG(e.schema._def,r):{};case"ZodAny":case"ZodUnknown":return{};case"ZodDefault":return{...oG(e.innerType._def,r),default:e.defaultValue()};case"ZodBranded":return oO(e,r);case"ZodReadonly":case"ZodCatch":return oG(e.innerType._def,r);case"ZodPipeline":if("input"===r.pipeStrategy)return oG(e.in._def,r);if("output"===r.pipeStrategy)return oG(e.out._def,r);let b=oG(e.in._def,{...r,currentPath:[...r.currentPath,"allOf","0"]});return{allOf:[b,oG(e.out._def,{...r,currentPath:[...r.currentPath,"allOf",b?"1":"0"]})].filter(e=>void 0!==e)};default:return}})(e,e.typeName,t),o="function"==typeof i?oG(i(),t):i;if(o&&oY(e,t,o),t.postProcess){let r=t.postProcess(o,e,t);return n.jsonSchema=o,r}return n.jsonSchema=o,o}let oK=(e,t)=>{switch(t.$refStrategy){case"root":return{$ref:e.path.join("/")};case"relative":return{$ref:((e,t)=>{let r=0;for(;r<e.length&&r<t.length&&e[r]===t[r];r++);return[(e.length-r).toString(),...t.slice(r)].join("/")})(t.currentPath,e.path)};case"none":case"seen":if(e.path.length<t.currentPath.length&&e.path.every((e,r)=>t.currentPath[r]===e))return console.warn(`Recursive reference detected at ${t.currentPath.join("/")}! Defaulting to any`),{};return"seen"===t.$refStrategy?{}:void 0}},oY=(e,t,r)=>(e.description&&(r.description=e.description),r),oX=Symbol.for("vercel.ai.schema");function oQ(e){let t;return()=>(null==t&&(t=e()),t)}function o0(e,{validate:t}={}){return{[oX]:!0,_type:void 0,get jsonSchema(){return"function"==typeof e&&(e=e()),e},validate:t}}function o1(e,t){let r;if("_zod"in e){let r;return r=t?.useReferences??!1,o0(()=>ox(function(e,t){if("_idmap"in e){let r=nU({...t,processors:iC}),a={};for(let t of e._idmap.entries()){let[e,a]=t;nL(a,r)}let n={};for(let i of(r.external={registry:e,uri:t?.uri,defs:a},e._idmap.entries())){let[e,t]=i;nB(r,t),eu(n,e,nW(r,t))}return Object.keys(a).length>0&&(n.__shared={["draft-2020-12"===r.target?"$defs":"definitions"]:a}),{schemas:n}}let r=nU({...t,processors:iC});return nL(e,r),nB(r,e),nW(r,e)}(e,{target:"draft-7",io:"input",reused:r?"ref":"inline"})),{validate:async t=>{let r=await tV(e,t);return r.success?{success:!0,value:r.data}:{success:!1,error:r.error}}})}return r=t?.useReferences??!1,o0(()=>((e,t)=>{let r,a,n=(a=void 0!==(r="string"==typeof t?{...oT,name:t}:{...oT,...t}).name?[...r.basePath,r.definitionPath,r.name]:r.basePath,{...r,currentPath:a,propertyPath:void 0,seen:new Map(Object.entries(r.definitions).map(([e,t])=>[t._def,{def:t._def,path:[...r.basePath,r.definitionPath,e],jsonSchema:void 0}]))}),i="object"==typeof t&&t.definitions?Object.entries(t.definitions).reduce((e,[t,r])=>({...e,[t]:oG(r._def,{...n,currentPath:[...n.basePath,n.definitionPath,t]},!0)??{}}),{}):void 0,o="string"==typeof t?t:t?.nameStrategy==="title"?void 0:t?.name,s=oG(e._def,void 0===o?n:{...n,currentPath:[...n.basePath,n.definitionPath,o]},!1)??{},l="object"==typeof t&&void 0!==t.name&&"title"===t.nameStrategy?t.name:void 0;void 0!==l&&(s.title=l);let u=void 0===o?i?{...s,[n.definitionPath]:i}:s:{$ref:[..."relative"===n.$refStrategy?[]:n.basePath,n.definitionPath,o].join("/"),[n.definitionPath]:{...i,[o]:s}};return u.$schema="http://json-schema.org/draft-07/schema#",u})(e,{$refStrategy:r?"root":"none"}),{validate:async t=>{let r=await e.safeParseAsync(t);return r.success?{success:!0,value:r.data}:{success:!1,error:r.error}}})}async function o2({value:e,schema:t,context:r}){let a=await o4({value:e,schema:t,context:r});if(!a.success)throw L.wrap({value:e,cause:a.error,context:r});return a.value}async function o4({value:e,schema:t,context:r}){let a=function(e){var t;return null==e?o0({type:"object",properties:{},additionalProperties:!1}):"object"==typeof e&&null!==e&&oX in e&&!0===e[oX]&&"jsonSchema"in e&&"validate"in e?e:"~standard"in e?"zod"===e["~standard"].vendor?o1(e):(t=e,o0(()=>{if(null==t["~standard"].jsonSchema)throw Error(`Standard schema vendor '${t["~standard"].vendor}' does not support JSON Schema conversion.`);return ox(t["~standard"].jsonSchema.input({target:"draft-07"}))},{validate:async e=>{let r=await t["~standard"].validate(e);return"value"in r?{success:!0,value:r.value}:{success:!1,error:new L({value:e,cause:r.issues})}}})):e()}(t);try{if(null==a.validate)return{success:!0,value:e,rawValue:e};let t=await a.validate(e);if(t.success)return{success:!0,value:t.value,rawValue:e};return{success:!1,error:L.wrap({value:e,cause:t.error,context:r}),rawValue:e}}catch(t){return{success:!1,error:L.wrap({value:e,cause:t,context:r}),rawValue:e}}}async function o5({text:e,schema:t}){try{let r=oE(e);if(null==t)return r;return await o2({value:r,schema:t})}catch(t){if(j.isInstance(t)||L.isInstance(t))throw t;throw new j({text:e,cause:t})}}async function o6({text:e,schema:t}){try{let r=oE(e);if(null==t)return{success:!0,value:r,rawValue:r};return await o4({value:r,schema:t})}catch(t){return{success:!1,error:j.isInstance(t)?t:new j({text:e,cause:t}),rawValue:void 0}}}function o9({stream:e,schema:t}){return e.pipeThrough(new TextDecoderStream).pipeThrough(new iD).pipeThrough(new TransformStream({async transform({data:e},r){"[DONE]"!==e&&r.enqueue(await o6({text:e,schema:t}))}}))}async function o3({provider:e,providerOptions:t,schema:r}){if(t?.[e]==null)return;let a=await o4({value:t[e],schema:r});if(!a.success)throw new C({argument:"providerOptions",message:`invalid ${e} provider options`,cause:a.error});return a.value}let o8=()=>globalThis.fetch,o7=async({url:e,headers:t,body:r,failedResponseHandler:a,successfulResponseHandler:n,abortSignal:i,fetch:o})=>await se({url:e,headers:{"Content-Type":"application/json",...t},body:{content:JSON.stringify(r),values:r},failedResponseHandler:a,successfulResponseHandler:n,abortSignal:i,fetch:o}),se=async({url:e,headers:t={},body:r,successfulResponseHandler:a,failedResponseHandler:n,abortSignal:i,fetch:o=o8()})=>{try{let s=await o(e,{method:"POST",headers:i5(t,`ai-sdk-provider-utils/${i2}`,iY()),body:r.content,signal:i}),l=iK(s);if(!s.ok){let t;try{t=await n({response:s,url:e,requestBodyValues:r.values})}catch(t){if(iX(t)||E.isInstance(t))throw t;throw new E({message:"Failed to process error response",cause:t,statusCode:s.status,url:e,responseHeaders:l,requestBodyValues:r.values})}throw t.value}try{return await a({response:s,url:e,requestBodyValues:r.values})}catch(t){if(t instanceof Error&&(iX(t)||E.isInstance(t)))throw t;throw new E({message:"Failed to process successful response",cause:t,statusCode:s.status,url:e,responseHeaders:l,requestBodyValues:r.values})}}catch(t){throw i1({error:t,url:e,requestBodyValues:r.values})}};function st({id:e,inputSchema:t,outputSchema:r,supportsDeferredResults:a}){return({onInputStart:n,onInputDelta:i,onInputAvailable:o,...s})=>({type:"provider",isProviderExecuted:!0,id:e,args:s,inputSchema:t,outputSchema:r,onInputStart:n,onInputDelta:i,onInputAvailable:o,supportsDeferredResults:a})}async function sr(e){return"function"==typeof e&&(e=e()),e}let sa=new TextDecoder,sn=0x4000000;async function si({response:e,url:t}){return sa.decode(await oh({response:e,url:t}))}let so=({errorSchema:e,errorToMessage:t,isRetryable:r})=>async({response:a,url:n,requestBodyValues:i})=>{let o=await si({response:a,url:n}),s=iK(a);if(""===o.trim())return{responseHeaders:s,value:new E({message:a.statusText,url:n,requestBodyValues:i,statusCode:a.status,responseHeaders:s,responseBody:o,isRetryable:r?.(a)})};try{let l=await o5({text:o,schema:e});return{responseHeaders:s,value:new E({message:t(l),url:n,requestBodyValues:i,statusCode:a.status,responseHeaders:s,responseBody:o,data:l,isRetryable:r?.(a,l)})}}catch{return{responseHeaders:s,value:new E({message:a.statusText,url:n,requestBodyValues:i,statusCode:a.status,responseHeaders:s,responseBody:o,isRetryable:r?.(a)})}}},ss=e=>async({response:t,url:r,requestBodyValues:a})=>{let n=await si({response:t,url:r}),i=await o6({text:n,schema:e}),o=iK(t);if(!i.success)throw new E({message:"Invalid JSON response",cause:i.error,statusCode:t.status,responseHeaders:o,responseBody:n,url:r,requestBodyValues:a});return{responseHeaders:o,value:i.value,rawValue:i.rawValue}};async function*sl({stream:e,schema:t,url:r,maxLineBytes:a}){let n=e.getReader(),i=new TextDecoder,o="",s=0,l=!1;try{for(;;){let{done:e,value:u}=await n.read();if(e){l=!0,o+=i.decode();break}let c=0;for(;c<u.length;){let e=u.indexOf(10,c),n=-1===e?u.length:e;if((s+=n-c)>a)throw new i7({message:`JSON Lines response exceeded maximum line size of ${a} bytes.`,url:r});let l=-1===e?n:e+1;if(o+=i.decode(u.subarray(c,l),{stream:!0}),-1===e)break;let d=o.slice(0,-1).replace(/\r$/,"");o="",s=0,c=l,d.trim().length>0&&(yield await o5({text:d,schema:t}))}}let e=o.replace(/\r$/,"");e.trim().length>0&&(yield await o5({text:e,schema:t}))}finally{l||await n.cancel().catch(()=>{}),n.releaseLock()}}function su(e){if(null==e)return!0;let t=typeof e;return"string"===t||"number"===t||"boolean"===t||"function"!==t&&"symbol"!==t&&"bigint"!==t&&(Array.isArray(e)?e.every(su):Object.getPrototypeOf(e)===Object.prototype&&Object.values(e).every(su))}let sc="AI_SerializationError",sd=`vercel.ai.error.${sc}`,sp=Symbol.for(sd);var sf=class extends w{constructor({message:e="Failed to serialize value.",cause:t}={}){super({name:sc,message:e,cause:t}),this[sp]=!0}static isInstance(e){return w.hasMarker(e,sd)}};function sh(e){let t={};for(let[r,a]of Object.entries(e.config))if("headers"===r){let e=function(e){let t=e;if("function"==typeof e&&(t=e()),t instanceof Promise)throw new sf({message:"Cannot serialize asynchronous model options."});return t}(a);su(e)&&(t[r]=e)}else su(a)&&(t[r]=a);return{modelId:e.modelId,config:t}}function sm(e){return"string"==typeof e}function sg(e){return"number"==typeof e}function sy(e,t){return void 0===e||t(e)}function sv(e){return ov(e)&&sm(e.type)}function sb(e){return ov(e)&&sm(e.text)&&sg(e.startSecond)&&sg(e.endSecond)}var sw=e.i(21168);class s_ extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform"),this.name="ZodCyclicError"}}let sk="~memo",sS=[];function sE(e){return null!==e&&"object"==typeof e}function sx(e){return e.map(e=>e.path?{...e,path:e.path.slice()}:{...e})}let sI=new WeakMap,sA=[],sT={alloc(e,t,r){let n=a;if(!n)return r;a=void 0;let i={value:r,issues:null};return n.set(t.value,i),sA.push(i),r},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,r=(e,r)=>{var a,n;let i;if("backward"!==r.direction&&(a=r,n=e.value,void 0!==(i=a[sk]?.backEdges)&&sE(n)&&i.has(n)))throw new s_;return t(e,r)};e._zod.parse=r,e._zod.run===t&&(e._zod.run=r)})},attach(e){var t;let r,n,i,o=!1;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,s=(l,u)=>{let c;if(void 0===r){let a=function e(t,r,a){var n,i;let o=sI.get(t);if(void 0!==o)return 2*!!o;if(r.has(t))return 2;r.add(t);let s=0,l=t=>{if(2!==s&&t?._zod){let n=e(t,r,a);n>s&&(s=n)}},u=e=>{e>s&&(s=e)},c=t._zod.def;switch(c.type){case"object":{let t=ec(c);u(t?((t,n)=>{let i=0;for(let o of Reflect.ownKeys(t)){let s=Object.getOwnPropertyDescriptor(t,o);if(n&&!s.enumerable)continue;let l=s.get?1:s.value?._zod?e(s.value,r,a):0;l>i&&(i=l)}return i})(t,!0):1),l(c.catchall);break}case"array":l(c.element);break;case"tuple":for(let e of c.items)l(e);l(c.rest);break;case"record":case"map":l(c.keyType),l(c.valueType);break;case"set":l(c.valueType);break;case"union":for(let e of c.options)l(e);break;case"intersection":l(c.left),l(c.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":l(c.innerType);break;case"pipe":l(c.in),l(c.out);break;case"function":l(c.input),l(c.output);break;case"lazy":{let n=c._cachedInner??(a?t._zod.innerType:void 0);u(n?e(n,r,!1):1);break}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":break;default:for(let e in c){let t=Object.getOwnPropertyDescriptor(c,e);if(!t||t.get)continue;let r=t.value;if(r&&"object"==typeof r){if(r._zod)l(r);else if(Array.isArray(r))for(let e of r)l(e)}}}return r.delete(t),n=t,1!==(i=s)&&sI.set(n,2===i),i}(e,new Set,!1);if(0===a)return e._zod.parse=t,e._zod.run===s&&(e._zod.run=t),t(l,u);2===a||o?r=!0:o=!0}let d=l.value;if(!sE(d))return t(l,u);let p=u[sk];if(p||(p={buckets:new WeakMap,backEdges:void 0},u[sk]=p),n===u)c=i;else{var f;let t;(t=(f=p).buckets.get(e))||(t=new WeakMap,f.buckets.set(e,t)),c=t,n=u,i=c}let h=c.get(d);if(h)return l.value=h.value,h.issues?h.issues.length&&l.issues.push(...sx(h.issues)):(l.memo=!0,p.backEdges??(p.backEdges=new WeakSet),p.backEdges.add(h.value)),l;a=c;let m=sA.length,g=t(l,u);a=void 0;let y=sA.length>m?sA.pop():void 0;return g instanceof Promise?g.then(e=>(y&&(y.issues=e.issues.length?sx(e.issues):sS),e)):(y&&(y.issues=g.issues.length?sx(g.issues):sS),g)};e._zod.parse=s,e._zod.run===t&&(e._zod.run=s)})}};function sO(e){return e.checks&&(e.checks=[...e.checks]),e}function sM(e,t){return new rW({check:"less_than",...eC(t),value:e,inclusive:!1})}function sz(e,t){return new rW({check:"less_than",...eC(t),value:e,inclusive:!0})}function sR(e,t){return new rG({check:"greater_than",...eC(t),value:e,inclusive:!1})}function sC(e,t){return new rG({check:"greater_than",...eC(t),value:e,inclusive:!0})}function sP(e,t){return new rK({check:"multiple_of",...eC(t),value:e})}function s$(e,t){return new r2({check:"max_length",...eC(t),maximum:e})}function sN(e,t){return new r4({check:"min_length",...eC(t),minimum:e})}function sj(e,t){return new r5({check:"length_equals",...eC(t),length:e})}function sD(e){return new an({check:"overwrite",tx:e})}e.i(59217);var sU=e.i(39604),sU=sU,sZ=sU,sL=sU,sF=sU,sB=sU,sq=sU,sV=sU,sH=sU,sJ=sU,sW=sU,sG=sU,sK=sU,sY=sU,sX=sU,sQ=sU,s0=sU;function s1(){tw.memoizer||t_({memoizer:sT})}let s2=ty("ZodType",(e,t)=>(tw.localeError||t_({localeError:(()=>{let e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}},t={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",currency_code:"currency code",credit_card:"credit card number",iban:"IBAN",jwt:"JWT",template_literal:"input"},r={nan:"NaN"};function a(e,t){return"number"!==e||"number"!=typeof t||Number.isFinite(t)?r[e]??e:String(t)}return r=>{switch(r.code){case"invalid_type":{let e=a(r.expected),t=a(e6(r.input),r.input);return`Invalid input: expected ${e}, received ${t}`}case"invalid_value":if(1===r.values.length)return`Invalid input: expected ${e$(r.values[0])}`;return`Invalid option: expected one of ${Q(r.values,"|")}`;case"too_big":{let t=r.exact?"exactly ":r.inclusive?"<=":"<",a=e[r.origin]??null;if(a)return`Too big: expected ${r.origin??"value"} to have ${t}${r.maximum.toString()} ${a.unit??"elements"}`;return`Too big: expected ${r.origin??"value"} to be ${t}${r.maximum.toString()}`}case"too_small":{let t=r.exact?"exactly ":r.inclusive?">=":">",a=e[r.origin]??null;if(a)return`Too small: expected ${r.origin} to have ${t}${r.minimum.toString()} ${a.unit}`;return`Too small: expected ${r.origin} to be ${t}${r.minimum.toString()}`}case"invalid_format":if("starts_with"===r.format)return`Invalid string: must start with "${r.prefix}"`;if("ends_with"===r.format)return`Invalid string: must end with "${r.suffix}"`;if("includes"===r.format)return`Invalid string: must include "${r.includes}"`;if("regex"===r.format)return`Invalid string: must match pattern ${r.pattern}`;return`Invalid ${t[r.format]??r.format}`;case"not_multiple_of":return`Invalid number: must be a multiple of ${r.divisor}`;case"unrecognized_keys":return`Unrecognized key${r.keys.length>1?"s":""}: ${Q(r.keys,", ")}`;case"invalid_key":return`Invalid key in ${r.origin}`;case"invalid_union":if(r.options&&Array.isArray(r.options)&&r.options.length>0){let e=r.options.map(e=>`'${e}'`).join(" | ");return`Invalid discriminator value. Expected ${e}`}if(!1===r.inclusive)return"Invalid input: more than one option matched";return"Invalid input";case"invalid_element":return`Invalid value in ${r.origin}`;default:return"Invalid input"}}})()}),as.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(sZ.mergeDefs(t,{checks:[...t.checks??[],...e.map(e=>"function"==typeof e?{_zod:{check:e,def:{check:"custom"},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return eR(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(function(e,t={}){return new l7({type:"custom",check:"custom",fn:e,...eC(t)})}(e,t))},superRefine(e,t){return this.check(function(e,t){var r;let a,n;return r=t=>(t.addIssue=e=>{"string"==typeof e?t.issues.push(e9(e,t.value,a._zod.def)):(e.fatal&&(e.continue=!1),e.code??(e.code="custom"),"input"in e||(e.input=t.value),e.inst??(e.inst=a),e.continue??(e.continue=!a._zod.def.abort),t.issues.push(e9(e)))},e(t.value,t)),(n=new rq({check:"custom",...eC(t)}))._zod.check=r,a=n}(e,t))},overwrite(e){return this.check(sD(e))},optional(){return lK(this)},exactOptional(){var e;return e=this,new lY({type:"optional",innerType:e})},nullable(){return lQ(this)},nullish(){return lK(lQ(this))},nonoptional(e){var t,r;return t=this,r=e,new l2({type:"nonoptional",innerType:t,...sq.normalizeParams(r)})},array(){return lP(this)},or(e){return lD([this,e])},and(e){var t;return t=this,new lL({type:"intersection",left:t,right:e})},transform(e){return l6(this,new lW({type:"transform",transform:e}))},default(e){var t,r;return t=this,r=e,new l0({type:"default",innerType:t,get defaultValue(){return"function"==typeof r?r():s0.shallowClone(r)}})},prefault(e){var t,r;return t=this,r=e,new l1({type:"prefault",innerType:t,get defaultValue(){return"function"==typeof r?r():s0.shallowClone(r)}})},catch(e){var t,r;return t=this,new l4({type:"catch",innerType:t,catchValue:"function"==typeof(r=e)?r:sU.constantCatch(r)})},pipe(e){return l6(this,e)},readonly(){var e;return e=this,new l9({type:"readonly",innerType:e})},describe(e){let t=this.clone();return nj.add(t,{description:e}),t},meta(...e){if(0===e.length)return nj.get(this);let t=this.clone();return nj.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return 0===t.length?e(this):e(this,...t)},get"~standard"(){return sL.hide(this,"~standard",{...ac(this),jsonSchema:{input:nG(this,"input"),output:nG(this,"output")}})},set"~standard"(e){sF.own(this,"~standard",e)},parse:function e(t,r){return tF(this,t,r,{callee:e})},parseAsync:async function e(t,r){return await tB(this,t,r,{callee:e})},safeParse(e,t){return tq(this,e,t)},async safeParseAsync(e,t){return tV(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){sF.own(this,"spa",e)},validate(e,t){let r=this._zod.bag.validator;if(void 0!==r){if(r(e)!==tN)return!0;if(!0===r.definite&&void 0===t)return!1}return function(e,t,r){let a,n=r?{...r,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},i=e._zod.bag.fallbackRun;if(i?(n[tj]=!0,a=i({value:t,issues:[]},n)):a=e._zod.run({value:t,issues:[]},n),a instanceof Promise)throw new tv;return 0===a.issues.length}(this,e,t)},validateAsync(e,t){return tD(this,e,t)},encode:function e(t,r){return tH(this,t,r,{callee:e})},decode:function e(t,r){return tJ(this,t,r,{callee:e})},encodeAsync:async function e(t,r){return await tW(this,t,r,{callee:e})},decodeAsync:async function e(t,r){return await tG(this,t,r,{callee:e})},safeEncode(e,t){return tK(this,e,t)},safeDecode(e,t){return tY(this,e,t)},async safeEncodeAsync(e,t){return tX(this,e,t)},async safeDecodeAsync(e,t){return tQ(this,e,t)},toJSONSchema(e){return((e,t={})=>r=>{let a=nU({...r,processors:t});return nL(e,a),nB(a,e),nW(a,e)})(this,{})(e)},get description(){return nj.get(this)?.description},get _def(){return this._zod.def}}),s4=ty("_ZodString",(e,t)=>{ad.init(e,t),s2.init(e,t),e._zod.processJSONSchema=(t,r,a)=>it(e,t,r,a)},sB.derived({format:e=>n3(e).format??null,minLength:e=>n3(e).minimum??null,maxLength:e=>n3(e).maximum??null},{regex(...e){return this.check(function(e,t){return new r9({check:"string_format",format:"regex",...eC(t),pattern:e})}(...e))},includes(...e){return this.check(function(e,t){return new r7({check:"string_format",format:"includes",...eC(t),includes:e})}(...e))},startsWith(...e){return this.check(function(e,t){return new ae({check:"string_format",format:"starts_with",...eC(t),prefix:e})}(...e))},endsWith(...e){return this.check(function(e,t){return new at({check:"string_format",format:"ends_with",...eC(t),suffix:e})}(...e))},min(...e){return this.check(sN(...e))},max(...e){return this.check(s$(...e))},length(...e){return this.check(sj(...e))},nonempty(...e){return this.check(sN(1,...e))},lowercase(e){return this.check(new r3({check:"string_format",format:"lowercase",...eC(e)}))},uppercase(e){return this.check(new r8({check:"string_format",format:"uppercase",...eC(e)}))},trim(){return this.check(sD(e=>e.trim()))},normalize(...e){return this.check(function(e){return sD(t=>t.normalize(e))}(...e))},toLowerCase(){return this.check(sD(e=>e.toLowerCase()))},toUpperCase(){return this.check(sD(e=>e.toUpperCase()))},slugify(){return this.check(sD(e=>e_(e)))}})),s5=ty("ZodString",(e,t)=>{ad.init(e,t),s4.init(e,t)},{email(e){return this.check(new lt({type:"string",format:"email",check:"string_format",abort:!1,...eC(e)}))},url(e){return this.check(new ln({type:"string",format:"url",check:"string_format",abort:!1,...eC(e)}))},jwt(e){return this.check(new lb({type:"string",format:"jwt",check:"string_format",abort:!1,...eC(e)}))},emoji(e){return this.check(new li({type:"string",format:"emoji",check:"string_format",abort:!1,...eC(e)}))},guid(e){return this.check(new lr({type:"string",format:"guid",check:"string_format",abort:!1,...eC(e)}))},uuid(e){return this.check(new la({type:"string",format:"uuid",check:"string_format",abort:!1,...eC(e)}))},uuidv4(e){return this.check(new la({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...eC(e)}))},uuidv6(e){return this.check(new la({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...eC(e)}))},uuidv7(e){return this.check(new la({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...eC(e)}))},nanoid(e){return this.check(new lo({type:"string",format:"nanoid",check:"string_format",abort:!1,...eC(e)}))},cuid(e){return this.check(new ls({type:"string",format:"cuid",check:"string_format",abort:!1,...eC(e)}))},cuid2(e){return this.check(new ll({type:"string",format:"cuid2",check:"string_format",abort:!1,...eC(e)}))},ulid(e){return this.check(new lu({type:"string",format:"ulid",check:"string_format",abort:!1,...eC(e)}))},base64(e){return this.check(new lg({type:"string",format:"base64",check:"string_format",abort:!1,...eC(e)}))},base64url(e){return this.check(new ly({type:"string",format:"base64url",check:"string_format",abort:!1,...eC(e)}))},xid(e){return this.check(new lc({type:"string",format:"xid",check:"string_format",abort:!1,...eC(e)}))},ksuid(e){return this.check(new ld({type:"string",format:"ksuid",check:"string_format",abort:!1,...eC(e)}))},ipv4(e){return this.check(new lp({type:"string",format:"ipv4",check:"string_format",abort:!1,...eC(e)}))},ipv6(e){return this.check(new lf({type:"string",format:"ipv6",check:"string_format",abort:!1,...eC(e)}))},cidrv4(e){return this.check(new lh({type:"string",format:"cidrv4",check:"string_format",abort:!1,...eC(e)}))},cidrv6(e){return this.check(new lm({type:"string",format:"cidrv6",check:"string_format",abort:!1,...eC(e)}))},e164(e){return this.check(new lv({type:"string",format:"e164",check:"string_format",abort:!1,...eC(e)}))},datetime(e){return this.check(new s3({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...eC(e)}))},date(e){return this.check(new s8({type:"string",format:"date",check:"string_format",...eC(e)}))},time(e){return this.check(new s7({type:"string",format:"time",check:"string_format",precision:null,...eC(e)}))},duration(e){return this.check(new le({type:"string",format:"duration",check:"string_format",...eC(e)}))}});function s6(e){return new s5(sO({type:"string",...eC(e)}))}let s9=ty("ZodStringFormat",(e,t)=>{ap.init(e,t),s4.init(e,t)}),s3=ty("ZodISODateTime",(e,t)=>{aA.init(e,t),s9.init(e,t)}),s8=ty("ZodISODate",(e,t)=>{aT.init(e,t),s9.init(e,t)}),s7=ty("ZodISOTime",(e,t)=>{aO.init(e,t),s9.init(e,t)}),le=ty("ZodISODuration",(e,t)=>{aM.init(e,t),s9.init(e,t)}),lt=ty("ZodEmail",(e,t)=>{am.init(e,t),s9.init(e,t)}),lr=ty("ZodGUID",(e,t)=>{af.init(e,t),s9.init(e,t)}),la=ty("ZodUUID",(e,t)=>{ah.init(e,t),s9.init(e,t)}),ln=ty("ZodURL",(e,t)=>{ab.init(e,t),s9.init(e,t)}),li=ty("ZodEmoji",(e,t)=>{aw.init(e,t),s9.init(e,t)}),lo=ty("ZodNanoID",(e,t)=>{a_.init(e,t),s9.init(e,t)}),ls=ty("ZodCUID",(e,t)=>{ak.init(e,t),s9.init(e,t)}),ll=ty("ZodCUID2",(e,t)=>{aS.init(e,t),s9.init(e,t)}),lu=ty("ZodULID",(e,t)=>{aE.init(e,t),s9.init(e,t)}),lc=ty("ZodXID",(e,t)=>{ax.init(e,t),s9.init(e,t)}),ld=ty("ZodKSUID",(e,t)=>{aI.init(e,t),s9.init(e,t)}),lp=ty("ZodIPv4",(e,t)=>{az.init(e,t),s9.init(e,t)}),lf=ty("ZodIPv6",(e,t)=>{aP.init(e,t),s9.init(e,t)}),lh=ty("ZodCIDRv4",(e,t)=>{a$.init(e,t),s9.init(e,t)}),lm=ty("ZodCIDRv6",(e,t)=>{aN.init(e,t),s9.init(e,t)}),lg=ty("ZodBase64",(e,t)=>{aU.init(e,t),s9.init(e,t)}),ly=ty("ZodBase64URL",(e,t)=>{aL.init(e,t),s9.init(e,t)}),lv=ty("ZodE164",(e,t)=>{aF.init(e,t),s9.init(e,t)}),lb=ty("ZodJWT",(e,t)=>{aq.init(e,t),s9.init(e,t)}),lw=ty("ZodNumber",(e,t)=>{aV.init(e,t),s2.init(e,t),e._zod.processJSONSchema=(t,r,a)=>ir(e,t,r,a),e.isFinite=!0},sB.derived({minValue:e=>{let{minimum:t,exclusiveMinimum:r}=n3(e);return Math.max(t??-1/0,r??-1/0)},maxValue:e=>{let{maximum:t,exclusiveMaximum:r}=n3(e);return Math.min(t??1/0,r??1/0)},isInt:e=>{let{isInt:t,multipleOf:r}=n3(e);return!!t||!!r?.some(Number.isSafeInteger)},format:e=>n3(e).format??null},{gt(e,t){return this.check(sR(e,t))},gte(e,t){return this.check(sC(e,t))},min(e,t){return this.check(sC(e,t))},lt(e,t){return this.check(sM(e,t))},lte(e,t){return this.check(sz(e,t))},max(e,t){return this.check(sz(e,t))},int(e){return this.check(lS(e))},safe(e){return this.check(lS(e))},positive(e){return this.check(sR(0,e))},nonnegative(e){return this.check(sC(0,e))},negative(e){return this.check(sM(0,e))},nonpositive(e){return this.check(sz(0,e))},multipleOf(e,t){return this.check(sP(e,t))},step(e,t){return this.check(sP(e,t))},finite(){return this}}));function l_(e){return new lw(sO({type:"number",checks:[],...eC(e)}))}let lk=ty("ZodNumberFormat",(e,t)=>{aH.init(e,t),lw.init(e,t)});function lS(e){return new lk({type:"number",check:"number_format",abort:!1,format:"safeint",...eC(e)})}let lE=ty("ZodBoolean",(e,t)=>{aJ.init(e,t),s2.init(e,t),e._zod.processJSONSchema=(t,r,a)=>ia(e,t,r,a)});function lx(e){return new lE({type:"boolean",...eC(e)})}(e,t)=>{aW.init(e,t),s2.init(e,t),e._zod.processJSONSchema=(t,r,a)=>ii(e,t,r,a)};let lI=ty("ZodNull",(e,t)=>{aG.init(e,t),s2.init(e,t),e._zod.processJSONSchema=(t,r,a)=>io(e,t,r,a)});function lA(e){return new lI({type:"null",...eC(e)})}let lT=ty("ZodAny",(e,t)=>{aK.init(e,t),s2.init(e,t),e._zod.processJSONSchema=(t,r,a)=>il(e,t,r,a)}),lO=ty("ZodUnknown",(e,t)=>{aY.init(e,t),s2.init(e,t),e._zod.processJSONSchema=(t,r,a)=>iu(e,t,r,a)});function lM(){return new lO({type:"unknown"})}let lz=ty("ZodNever",(e,t)=>{aX.init(e,t),s2.init(e,t),e._zod.processJSONSchema=(t,r,a)=>is(e,t,r,a)});function lR(e){return new lz({type:"never",...eC(e)})}let lC=ty("ZodArray",(e,t)=>{s1(),a5.init(e,t),s2.init(e,t),e._zod.processJSONSchema=(t,r,a)=>im(e,t,r,a),e.element=t.element},{min(e,t){return this.check(sN(e,t))},nonempty(e){return this.check(sN(1,e))},max(e,t){return this.check(s$(e,t))},length(e,t){return this.check(sj(e,t))},unwrap(){return this.element}});function lP(e,t){return new lC({type:"array",element:e,...eC(t)})}let l$=ty("ZodObject",(e,t)=>{s1(),ne.init(e,t),s2.init(e,t),e._zod.processJSONSchema=(t,r,a)=>iy(e,t,r,a),sX.installLazyProp(e,"shape",e=>e._zod.def.shape,!1)},{keyof(){return lV(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(sZ.mergeDefs(this._zod.def,{catchall:e}))},passthrough(){return this.clone(sZ.mergeDefs(this._zod.def,{catchall:lM()}))},loose(){return this.clone(sZ.mergeDefs(this._zod.def,{catchall:lM()}))},strict(){return this.clone(sZ.mergeDefs(this._zod.def,{catchall:lR()}))},strip(){return this.clone(sZ.mergeDefs(this._zod.def,{catchall:void 0}))},extend(e){return sV.extend(this,e)},safeExtend(e){return sH.safeExtend(this,e)},merge(e){return sJ.merge(this,e)},pick(e){return sW.pick(this,e)},omit(e){return sG.omit(this,e)},partial(...e){return sK.partial(lG,this,e[0])},exactPartial(...e){return sK.partial(lY,this,e[0],"exactPartial")},required(...e){return sY.required(l2,this,e[0])}});function lN(e,t){return new l$({type:"object",shape:e??{},...sq.normalizeParams(t)})}let lj=ty("ZodUnion",(e,t)=>{nr.init(e,t),s2.init(e,t),e._zod.processJSONSchema=(t,r,a)=>iv(e,t,r,a),e.options=t.options});function lD(e,t){return new lj({type:"union",options:e,...sq.normalizeParams(t)})}let lU=ty("ZodDiscriminatedUnion",(e,t)=>{lj.init(e,t),nn.init(e,t)});function lZ(e,t,r){return new lU({type:"union",options:t,discriminator:e,...sq.normalizeParams(r)})}let lL=ty("ZodIntersection",(e,t)=>{ni.init(e,t),s2.init(e,t),e._zod.processJSONSchema=(t,r,a)=>ib(e,t,r,a)}),lF=ty("ZodRecord",(e,t)=>{s1(),nd.init(e,t),s2.init(e,t),e._zod.processJSONSchema=(t,r,a)=>i_(e,t,r,a),e.keyType=t.keyType,e.valueType=t.valueType});function lB(e,t,r){return new lF(t&&t._zod?{type:"record",keyType:e,valueType:t,...sq.normalizeParams(r)}:{type:"record",keyType:s6(),valueType:e,...sq.normalizeParams(t)})}let lq=ty("ZodEnum",(e,t)=>{nh.init(e,t),s2.init(e,t),e._zod.processJSONSchema=(t,r,a)=>ic(e,t,r,a),e.enum=t.entries,e.options=[...e._zod.values];let r=new Set(Object.keys(t.entries));e.extract=(e,a)=>{let n={};for(let a of e)if(r.has(a))n[a]=t.entries[a];else throw Error(`Key ${a} not found in enum`);return new lq({...t,checks:[],...sq.normalizeParams(a),entries:n})},e.exclude=(e,a)=>{let n={...t.entries};for(let t of e)if(r.has(t))delete n[t];else throw Error(`Key ${t} not found in enum`);return new lq({...t,checks:[],...sq.normalizeParams(a),entries:n})}});function lV(e,t){return new lq({type:"enum",entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...sq.normalizeParams(t)})}let lH=ty("ZodLiteral",(e,t)=>{nm.init(e,t),s2.init(e,t),e._zod.processJSONSchema=(t,r,a)=>id(e,t,r,a),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function lJ(e,t){return new lH({type:"literal",values:Array.isArray(e)?e:[e],...sq.normalizeParams(t)})}let lW=ty("ZodTransform",(e,t)=>{s1(),ng.init(e,t),s2.init(e,t),e._zod.processJSONSchema=(t,r,a)=>ih(e,t,r,a),e._zod.parse=(r,a)=>{if("backward"===a.direction)throw new tb(e.constructor.name);r.addIssue=a=>{"string"==typeof a?r.issues.push(sQ.issue(a,r.value,t)):(a.fatal&&(a.continue=!1),a.code??(a.code="custom"),"input"in a||(a.input=r.value),a.inst??(a.inst=e),r.issues.push(sQ.issue(a)))};let n=t.transform(r.value,r);return n instanceof Promise?n.then(e=>(r.value=e,r)):(r.value=n,r)}}),lG=ty("ZodOptional",(e,t)=>{nv.init(e,t),s2.init(e,t),e._zod.processJSONSchema=(t,r,a)=>iz(e,t,r,a),e.unwrap=()=>e._zod.def.innerType});function lK(e){return new lG({type:"optional",innerType:e})}let lY=ty("ZodExactOptional",(e,t)=>{nb.init(e,t),s2.init(e,t),e._zod.processJSONSchema=(t,r,a)=>iz(e,t,r,a),e.unwrap=()=>e._zod.def.innerType}),lX=ty("ZodNullable",(e,t)=>{nw.init(e,t),s2.init(e,t),e._zod.processJSONSchema=(t,r,a)=>ik(e,t,r,a),e.unwrap=()=>e._zod.def.innerType});function lQ(e){return new lX({type:"nullable",innerType:e})}let l0=ty("ZodDefault",(e,t)=>{n_.init(e,t),s2.init(e,t),e._zod.processJSONSchema=(t,r,a)=>iI(e,t,r,a),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap}),l1=ty("ZodPrefault",(e,t)=>{nS.init(e,t),s2.init(e,t),e._zod.processJSONSchema=(t,r,a)=>iA(e,t,r,a),e.unwrap=()=>e._zod.def.innerType}),l2=ty("ZodNonOptional",(e,t)=>{nE.init(e,t),s2.init(e,t),e._zod.processJSONSchema=(t,r,a)=>iS(e,t,r,a),e.unwrap=()=>e._zod.def.innerType}),l4=ty("ZodCatch",(e,t)=>{nA.init(e,t),s2.init(e,t),e._zod.processJSONSchema=(t,r,a)=>iT(e,t,r,a),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap}),l5=ty("ZodPipe",(e,t)=>{nT.init(e,t),s2.init(e,t),e._zod.processJSONSchema=(t,r,a)=>iO(e,t,r,a),e.in=t.in,e.out=t.out});function l6(e,t){return new l5({type:"pipe",in:e,out:t})}let l9=ty("ZodReadonly",(e,t)=>{nR.init(e,t),s2.init(e,t),e._zod.processJSONSchema=(t,r,a)=>iM(e,t,r,a),e.unwrap=()=>e._zod.def.innerType}),l3=ty("ZodLazy",(e,t)=>{nP.init(e,t),s2.init(e,t),e._zod.processJSONSchema=(t,r,a)=>iR(e,t,r,a),e.unwrap=()=>e._zod.def.getter()});function l8(e){return new l3({type:"lazy",getter:e})}let l7=ty("ZodCustom",(e,t)=>{n$.init(e,t),s2.init(e,t),e._zod.processJSONSchema=(t,r,a)=>ip(e,t,r,a)}),ue=ty("ZodInstanceOf",(e,t)=>{l7.init(e,t)},{properties(e,t){return this.check(new aa({check:"properties",shape:e,...eC(t)}))}});var ut=e.i(52897);let ur="ai-gateway-transcription.v1";function ua(e,t,r){let a=[e,`ai-gateway-auth.${t}`];return r?.teamIdOrSlug&&a.push(`ai-gateway-team.${function(e){let t=new TextEncoder().encode(e),r="";for(let e of t)r+=String.fromCharCode(e);return btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/u,"")}(r.teamIdOrSlug)}`),a}let un=function(){return new lT({type:"any"})},ui=lP,uo=lV,us=function(e){let t=l8(()=>lD([s6(e),l_(),lx(),lA(),lP(t),lB(s6(),t)]));return t},ul=lD,uu=Symbol.for("vercel.ai.gateway.error");var uc=class e extends Error{constructor({message:e,statusCode:t=500,cause:r,generationId:a,isRetryable:n=null!=t&&(408===t||409===t||429===t||t>=500)}){super(a?`${e} [${a}]`:e),this[uu]=!0,this.statusCode=t,this.cause=r,this.generationId=a,this.isRetryable=n}static isInstance(t){return e.hasMarker(t)}static hasMarker(e){return"object"==typeof e&&null!==e&&uu in e&&!0===e[uu]}};let ud="GatewayAuthenticationError",up=Symbol.for(`vercel.ai.gateway.error.${ud}`);var uf=class e extends uc{constructor({message:e="Authentication failed",statusCode:t=401,cause:r,generationId:a}={}){super({message:e,statusCode:t,cause:r,generationId:a}),this[up]=!0,this.name=ud,this.type="authentication_error"}static isInstance(e){return uc.hasMarker(e)&&up in e}static createContextualError({apiKeyProvided:t,oidcTokenProvided:r,statusCode:a=401,cause:n,generationId:i}){return new e({message:t?`AI Gateway authentication failed: Invalid API key or token.
71
-
72
- Create a new API key: https://vercel.com/d?to=%2F%5Bteam%5D%2F%7E%2Fai%2Fapi-keys
73
-
74
- Provide an API key or Vercel access token via 'apiKey' option or 'AI_GATEWAY_API_KEY' environment variable.`:r?`AI Gateway authentication failed: Invalid OIDC token.
75
-
76
- Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the token.
77
-
78
- Alternatively, use an API key: https://vercel.com/d?to=%2F%5Bteam%5D%2F%7E%2Fai%2Fapi-keys
79
- or pass a Vercel access token via the 'apiKey' option.`:`AI Gateway authentication failed: No authentication provided.
80
-
81
- Option 1 - API key:
82
- Create an API key: https://vercel.com/d?to=%2F%5Bteam%5D%2F%7E%2Fai%2Fapi-keys
83
- Provide via 'apiKey' option or 'AI_GATEWAY_API_KEY' environment variable.
84
-
85
- Option 2 - Vercel access token:
86
- Pass a Vercel personal access token or Vercel app access token via the 'apiKey' option.
87
-
88
- Option 3 - OIDC token:
89
- Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the token.`,statusCode:a,cause:n,generationId:i})}};let uh="GatewayInvalidRequestError",um=Symbol.for(`vercel.ai.gateway.error.${uh}`);var ug=class extends uc{constructor({message:e="Invalid request",statusCode:t=400,cause:r,generationId:a}={}){super({message:e,statusCode:t,cause:r,generationId:a}),this[um]=!0,this.name=uh,this.type="invalid_request_error"}static isInstance(e){return uc.hasMarker(e)&&um in e}};let uy="GatewayRateLimitError",uv=Symbol.for(`vercel.ai.gateway.error.${uy}`);var ub=class extends uc{constructor({message:e="Rate limit exceeded",statusCode:t=429,cause:r,generationId:a}={}){super({message:e,statusCode:t,cause:r,generationId:a}),this[uv]=!0,this.name=uy,this.type="rate_limit_exceeded"}static isInstance(e){return uc.hasMarker(e)&&uv in e}};let uw="GatewayModelNotFoundError",u_=Symbol.for(`vercel.ai.gateway.error.${uw}`),uk=oQ(()=>o1(lN({modelId:s6()})));var uS=class extends uc{constructor({message:e="Model not found",statusCode:t=404,modelId:r,cause:a,generationId:n}={}){super({message:e,statusCode:t,cause:a,generationId:n}),this[u_]=!0,this.name=uw,this.type="model_not_found",this.modelId=r}static isInstance(e){return uc.hasMarker(e)&&u_ in e}};let uE="GatewayNotFoundError",ux=Symbol.for(`vercel.ai.gateway.error.${uE}`);var uI=class extends uc{constructor({message:e="Resource not found",statusCode:t=404,cause:r,generationId:a}={}){super({message:e,statusCode:t,cause:r,generationId:a}),this[ux]=!0,this.name=uE,this.type="not_found"}static isInstance(e){return uc.hasMarker(e)&&ux in e}};let uA="GatewayInternalServerError",uT=Symbol.for(`vercel.ai.gateway.error.${uA}`);var uO=class extends uc{constructor({message:e="Internal server error",statusCode:t=500,cause:r,generationId:a}={}){super({message:e,statusCode:t,cause:r,generationId:a}),this[uT]=!0,this.name=uA,this.type="internal_server_error"}static isInstance(e){return uc.hasMarker(e)&&uT in e}};let uM="GatewayFailedDependencyError",uz=Symbol.for(`vercel.ai.gateway.error.${uM}`);var uR=class extends uc{constructor({message:e="Failed dependency",statusCode:t=424,cause:r,generationId:a}={}){super({message:e,statusCode:t,cause:r,generationId:a}),this[uz]=!0,this.name=uM,this.type="failed_dependency"}static isInstance(e){return uc.hasMarker(e)&&uz in e}};let uC="GatewayForbiddenError",uP=Symbol.for(`vercel.ai.gateway.error.${uC}`),u$=oQ(()=>o1(lN({ruleId:s6()})));var uN=class extends uc{constructor({message:e="Forbidden",statusCode:t=403,cause:r,generationId:a,ruleId:n}={}){super({message:e,statusCode:t,cause:r,generationId:a}),this[uP]=!0,this.name=uC,this.type="forbidden",this.ruleId=n}static isInstance(e){return uc.hasMarker(e)&&uP in e}};let uj="GatewayResponseError",uD=Symbol.for(`vercel.ai.gateway.error.${uj}`);var uU=class extends uc{constructor({message:e="Invalid response from Gateway",statusCode:t=502,response:r,validationError:a,cause:n,generationId:i,isRetryable:o}={}){super({message:e,statusCode:t,cause:n,generationId:i,isRetryable:o}),this[uD]=!0,this.name=uj,this.type="response_error",this.response=r,this.validationError=a}static isInstance(e){return uc.hasMarker(e)&&uD in e}};async function uZ({response:e,statusCode:t,defaultMessage:r="Gateway request failed",cause:a,authMethod:n,isRetryable:i}){let o=await o4({value:e,schema:uL});if(!o.success){let n="object"==typeof e&&null!==e&&"generationId"in e?e.generationId:void 0;return new uU({message:`Invalid error response format: ${r}`,statusCode:t,response:e,validationError:o.error,cause:a,generationId:n,isRetryable:i})}let s=o.value,l=s.error.type,u=s.error.message,c=s.generationId??void 0;switch(l){case"authentication_error":return uf.createContextualError({apiKeyProvided:"api-key"===n,oidcTokenProvided:"oidc"===n,statusCode:t,cause:a,generationId:c});case"invalid_request_error":return new ug({message:u,statusCode:t,cause:a,generationId:c});case"rate_limit_exceeded":return new ub({message:u,statusCode:t,cause:a,generationId:c});case"model_not_found":{let e=await o4({value:s.error.param,schema:uk});return new uS({message:u,statusCode:t,modelId:e.success?e.value.modelId:void 0,cause:a,generationId:c})}case"not_found":return new uI({message:u,statusCode:t,cause:a,generationId:c});case"internal_server_error":default:return new uO({message:u,statusCode:t,cause:a,generationId:c});case"failed_dependency":return new uR({message:u,statusCode:t,cause:a,generationId:c});case"forbidden":{let e=await o4({value:s.error.param,schema:u$});return new uN({message:u,statusCode:t,cause:a,generationId:c,ruleId:e.success?e.value.ruleId:void 0})}}}let uL=oQ(()=>o1(lN({error:lN({message:s6(),type:s6().nullish(),param:lM().nullish(),code:ul([s6(),l_()]).nullish()}),generationId:s6().nullish()}))),uF="GatewayTimeoutError",uB=Symbol.for(`vercel.ai.gateway.error.${uF}`);var uq=class e extends uc{constructor({message:e="Request timed out",statusCode:t=408,cause:r,generationId:a}={}){super({message:e,statusCode:t,cause:r,generationId:a}),this[uB]=!0,this.name=uF,this.type="timeout_error"}static isInstance(e){return uc.hasMarker(e)&&uB in e}static createTimeoutError({originalMessage:t,statusCode:r=408,cause:a,generationId:n}){return new e({message:`Gateway request timed out: ${t}
90
-
91
- This is a client-side timeout. To resolve this, increase your timeout configuration: https://vercel.com/docs/ai-gateway/capabilities/video-generation#extending-timeouts-for-node.js`,statusCode:r,cause:a,generationId:n})}};function uV(e){if(!(e instanceof Error))return!1;let t=e.code;return"string"==typeof t&&["UND_ERR_HEADERS_TIMEOUT","UND_ERR_BODY_TIMEOUT","UND_ERR_CONNECT_TIMEOUT"].includes(t)}async function uH(e,t){return uc.isInstance(e)?e:uV(e)?uq.createTimeoutError({originalMessage:e instanceof Error?e.message:"Unknown error",cause:e}):E.isInstance(e)?e.cause&&uV(e.cause)?uq.createTimeoutError({originalMessage:e.message,cause:e}):await uZ({response:function(e){if(void 0!==e.data)return e.data;if(null!=e.responseBody)try{return oE(e.responseBody)}catch{return e.responseBody}return{}}(e),statusCode:e.statusCode??500,defaultMessage:"Gateway request failed",cause:e,authMethod:t,isRetryable:!!e.isRetryable&&(null==e.statusCode||e.statusCode<400)||void 0}):await uZ({response:{},statusCode:500,defaultMessage:e instanceof Error?`Gateway request failed: ${e.message}`:"Unknown Gateway error",cause:e,authMethod:t})}let uJ="ai-gateway-auth-method",uW="x-vercel-ai-gateway-team";async function uG(e){let t=await o4({value:e[uJ],schema:uK});return t.success?t.value:void 0}let uK=oQ(()=>o1(ul([lJ("api-key"),lJ("oidc")]))),uY=["embedding","decision","evaluation","image","language","realtime","reranking","speech","transcription","video"];var uX=class{constructor(e){this.config=e}async getAvailableModels(){try{let{value:e}=await oy({url:`${this.config.baseURL}/config`,validateUrl:!1,headers:this.config.headers?await sr(this.config.headers):void 0,successfulResponseHandler:ss(uQ),failedResponseHandler:so({errorSchema:un(),errorToMessage:e=>O(e)??"unknown error"}),fetch:this.config.fetch});return e}catch(e){throw await uH(e)}}async getCredits(){try{let e=new URL(this.config.baseURL),t=this.config.headers?await sr(this.config.headers):void 0,r=new URL("/v1/credits",e.origin),a=function(e){if(e){for(let[t,r]of Object.entries(e))if("x-vercel-ai-gateway-team"===t.toLowerCase())return r?.trim()||void 0}}(t);a&&r.searchParams.set(a.startsWith("team_")?"teamId":"slug",a);let{value:n}=await oy({url:r.toString(),validateUrl:!1,headers:t,successfulResponseHandler:ss(u0),failedResponseHandler:so({errorSchema:un(),errorToMessage:e=>O(e)??"unknown error"}),fetch:this.config.fetch});return n}catch(e){throw await uH(e)}}};let uQ=oQ(()=>o1(lN({models:ui(lN({id:s6(),name:s6(),description:s6().nullish(),pricing:lN({input:s6(),output:s6(),input_cache_read:s6().nullish(),input_cache_write:s6().nullish()}).transform(({input:e,output:t,input_cache_read:r,input_cache_write:a})=>({input:e,output:t,...r?{cachedInputTokens:r}:{},...a?{cacheCreationInputTokens:a}:{}})).nullish(),specification:lN({specificationVersion:lJ("v4"),provider:s6(),modelId:s6()}),modelType:s6().nullish()})).transform(e=>e.filter(e=>null==e.modelType||uY.includes(e.modelType)))}))),u0=oQ(()=>o1(lN({balance:s6(),total_used:s6()}).transform(({balance:e,total_used:t})=>({balance:e,totalUsed:t}))));var u1=class{constructor(e){this.config=e}async getSpendReport(e){try{let t=new URL(this.config.baseURL),r=new URLSearchParams;r.set("start_date",e.startDate),r.set("end_date",e.endDate),e.groupBy&&r.set("group_by",e.groupBy),e.datePart&&r.set("date_part",e.datePart),e.userId&&r.set("user_id",e.userId),e.model&&r.set("model",e.model),e.provider&&r.set("provider",e.provider),e.credentialType&&r.set("credential_type",e.credentialType),e.tags&&e.tags.length>0&&r.set("tags",e.tags.join(","));let{value:a}=await oy({url:`${t.origin}/v1/report?${r.toString()}`,validateUrl:!1,headers:this.config.headers?await sr(this.config.headers):void 0,successfulResponseHandler:ss(u2),failedResponseHandler:so({errorSchema:un(),errorToMessage:e=>O(e)??"unknown error"}),fetch:this.config.fetch});return a}catch(e){throw await uH(e)}}};let u2=oQ(()=>o1(lN({results:ui(lN({day:s6().optional(),hour:s6().optional(),user:s6().optional(),model:s6().optional(),tag:s6().optional(),provider:s6().optional(),credential_type:uo(["byok","system"]).optional(),total_cost:l_(),market_cost:l_().optional(),input_tokens:l_().optional(),output_tokens:l_().optional(),cached_input_tokens:l_().optional(),cache_creation_input_tokens:l_().optional(),reasoning_tokens:l_().optional(),request_count:l_().optional()}).transform(({credential_type:e,total_cost:t,market_cost:r,input_tokens:a,output_tokens:n,cached_input_tokens:i,cache_creation_input_tokens:o,reasoning_tokens:s,request_count:l,...u})=>({...u,...void 0!==e?{credentialType:e}:{},totalCost:t,...void 0!==r?{marketCost:r}:{},...void 0!==a?{inputTokens:a}:{},...void 0!==n?{outputTokens:n}:{},...void 0!==i?{cachedInputTokens:i}:{},...void 0!==o?{cacheCreationInputTokens:o}:{},...void 0!==s?{reasoningTokens:s}:{},...void 0!==l?{requestCount:l}:{}})))})));var u4=class{constructor(e){this.config=e}async getGenerationInfo(e){try{let t=new URL(this.config.baseURL),{value:r}=await oy({url:`${t.origin}/v1/generation?id=${encodeURIComponent(e.id)}`,validateUrl:!1,headers:this.config.headers?await sr(this.config.headers):void 0,successfulResponseHandler:ss(u5),failedResponseHandler:so({errorSchema:un(),errorToMessage:e=>O(e)??"unknown error"}),fetch:this.config.fetch});return r}catch(e){throw await uH(e)}}};let u5=oQ(()=>o1(lN({data:lN({id:s6(),total_cost:l_(),upstream_inference_cost:l_(),usage:l_(),created_at:s6(),model:s6(),is_byok:lx(),provider_name:s6(),streamed:lx(),finish_reason:s6(),latency:l_(),generation_time:l_(),native_tokens_prompt:l_(),native_tokens_completion:l_(),native_tokens_reasoning:l_(),native_tokens_cached:l_(),native_tokens_cache_creation:l_(),billable_web_search_calls:l_()}).transform(({total_cost:e,upstream_inference_cost:t,created_at:r,is_byok:a,provider_name:n,finish_reason:i,generation_time:o,native_tokens_prompt:s,native_tokens_completion:l,native_tokens_reasoning:u,native_tokens_cached:c,native_tokens_cache_creation:d,billable_web_search_calls:p,...f})=>({...f,totalCost:e,upstreamInferenceCost:t,createdAt:r,isByok:a,providerName:n,finishReason:i,generationTime:o,promptTokens:s,completionTokens:l,reasoningTokens:u,cachedTokens:c,cacheCreationTokens:d,billableWebSearchCalls:p}))}).transform(({data:e})=>e)));var u6=class{constructor(e){this.config=e,this.specificationVersion="v4",this.supportedUrls={"*/*":[/.*/]},this.provider=`${e.provider}.batch`}async doStartBatch({requests:e,providerOptions:t,headers:r,abortSignal:a,webhookUrl:n}){var i=e;for(let e of i){let t=e.type;if("text"!==t)throw new V({functionality:`batch request type: ${t}`,message:`The AI Gateway Batch API does not support batch requests with type "${t}".`})}let o=function(e){let t=e[0]?.modelId;if(null==t)throw new C({argument:"requests",message:"The AI Gateway Batch API requires at least one request."});for(let r of e)if(r.modelId!==t)throw new C({argument:"requests",message:`The AI Gateway Batch API requires all requests in a batch to use the same model. Found "${t}" and "${r.modelId}".`});return t}(e),s=this.config.headers?await sr(this.config.headers):void 0,l=function(e){let t=e?.gateway;if(null==t||"object"!=typeof t||Array.isArray(t))return;let r=t.idempotencyKey;return"string"==typeof r&&r.length>0?r:void 0}(t),u=function(e){let t=e?.gateway;if(null==t||"object"!=typeof t||Array.isArray(t)||!("idempotencyKey"in t))return e;let{idempotencyKey:r,...a}=t,n={...e};if(0===Object.keys(a).length?delete n.gateway:n.gateway=a,0!==Object.keys(n).length)return n}(t);try{let{value:t}=await o7({url:this.getBatchUrl("start"),headers:iL(s,r,{"ai-model-id":o},await sr(this.config.o11yHeaders),null!=l?{"idempotency-key":l}:void 0),body:{...null!=n&&{callbackUrl:n},requests:e.map(e=>({id:e.id,type:e.type,modelId:e.modelId,options:function(e){for(let t of e.prompt)if(Array.isArray(t.content)){for(let e of t.content)if("file"===e.type||"reasoning-file"===e.type)e.data=u9(e.data);else if("tool-result"===e.type&&"content"===e.output.type)for(let t of e.output.value)"file"===t.type&&(t.data=u9(t.data))}return e}(e.options)})),...null!=u&&{providerOptions:u}},successfulResponseHandler:ss(ci),failedResponseHandler:so({errorSchema:un(),errorToMessage:e=>O(e)??"unknown error"}),...a&&{abortSignal:a},fetch:this.config.fetch});return{batchId:t.batchId,...u8(t),warnings:t.warnings??[]}}catch(e){if(u3(e))throw e;throw await uH(e,await uG(s??{}))}}async doGetBatchStatus({batchId:e,headers:t,abortSignal:r}){let a=this.config.headers?await sr(this.config.headers):void 0;try{let{value:n}=await o7({url:this.getBatchUrl("status"),headers:iL(a,t,await sr(this.config.o11yHeaders)),body:{batchId:e},successfulResponseHandler:ss(co),failedResponseHandler:so({errorSchema:un(),errorToMessage:e=>O(e)??"unknown error"}),...r&&{abortSignal:r},fetch:this.config.fetch});return u8(n)}catch(e){if(u3(e))throw e;throw await uH(e,await uG(a??{}))}}async doGetBatchResults({batchId:e,headers:t,abortSignal:r}){let a=this.config.headers?await sr(this.config.headers):void 0;try{var n;let i,{value:o}=await o7({url:this.getBatchUrl("results"),headers:iL(a,t,await sr(this.config.o11yHeaders)),body:{batchId:e},successfulResponseHandler:((e,{maxLineBytes:t=sn}={})=>{if(!Number.isSafeInteger(t)||t<=0)throw new C({argument:"maxLineBytes",message:"maxLineBytes must be a positive safe integer."});return async({response:r,url:a})=>{let n=iK(r);if(null==r.body)throw new T({});return{responseHeaders:n,value:sl({stream:r.body,schema:e,url:a,maxLineBytes:t})}}})(ce,{maxLineBytes:this.config.maxLineBytes}),failedResponseHandler:so({errorSchema:un(),errorToMessage:e=>O(e)??"unknown error"}),...r&&{abortSignal:r},fetch:this.config.fetch});return n=u7(o),i=!1,new ReadableStream({async pull(e){if(!i)try{let{value:t,done:r}=await n.next();r?e.close():e.enqueue(t)}catch(t){e.error(t)}},async cancel(e){if(i=!0,n.return)try{await n.return(e)}catch{}}})}catch(e){if(u3(e))throw e;throw await uH(e,await uG(a??{}))}}async doCancelBatch({batchId:e,headers:t,abortSignal:r}){let a=this.config.headers?await sr(this.config.headers):void 0;try{let{value:n}=await o7({url:this.getBatchUrl("cancel"),headers:iL(a,t,await sr(this.config.o11yHeaders)),body:{batchId:e},successfulResponseHandler:ss(co),failedResponseHandler:so({errorSchema:un(),errorToMessage:e=>O(e)??"unknown error"}),...r&&{abortSignal:r},fetch:this.config.fetch});return{...null!=n.providerMetadata&&{providerMetadata:n.providerMetadata}}}catch(e){if(u3(e))throw e;throw await uH(e,await uG(a??{}))}}getBatchUrl(e){return`${this.config.baseURL}/batch/${e}`}};function u9(e){if("data"===e.type){let t=e.data;if(t instanceof Uint8Array)return{...e,data:sw.Buffer.from(t).toString("base64")}}return e}function u3(e){return!!(e instanceof Error||e instanceof DOMException)&&("AbortError"===e.name||"TimeoutError"===e.name)}function u8(e){let t=function({total:e,pending:t,completed:r,failed:a}){if(ow(e)&&ow(t)&&ow(r)&&ow(a)&&t+r+a===e)return{total:e,pending:t,completed:r,failed:a}}({total:e.requestCounts?.total,pending:e.requestCounts?.pending,completed:e.requestCounts?.completed,failed:e.requestCounts?.failed});return{status:e.status,...null!=e.rawStatus&&{rawStatus:e.rawStatus},...null!=t&&{requestCounts:t},...null!=e.error&&{error:{message:e.error.message,...null!=e.error.type&&{type:e.error.type},...null!=e.error.code&&{code:e.error.code},...null!=e.error.statusCode&&{statusCode:e.error.statusCode}}},...null!=e.createdAt&&{createdAt:e.createdAt},...null!=e.expiresAt&&{expiresAt:e.expiresAt},...null!=e.providerMetadata&&{providerMetadata:e.providerMetadata}}}async function*u7(e){for await(let t of e){if("succeeded"===t.status){let e=t.result?.response;void 0!==e&&"string"==typeof e.timestamp&&(e.timestamp=new Date(e.timestamp))}yield t}}let ce=lN({type:lJ("text"),id:s6(),status:uo(["cancelled","expired","failed","succeeded"])}).catchall(lM()),ct=lN({message:s6(),type:s6().nullish(),code:s6().nullish(),statusCode:l_().nullish()}),cr=lN({total:l_().nullish(),pending:l_().nullish(),completed:l_().nullish(),failed:l_().nullish()}),ca=lB(s6(),lB(s6(),lM())),cn=lN({status:uo(["completed","failed","pending"]),rawStatus:s6().nullish(),requestCounts:cr.nullish(),error:ct.nullish(),createdAt:s6().nullish(),expiresAt:s6().nullish(),providerMetadata:ca.nullish()}),ci=cn.extend({batchId:s6(),warnings:ui(lN({requestId:s6().nullish(),warning:lM()}).catchall(lM())).nullish()}),co=cn;var cs=class e{static[iU](e){return sh({modelId:e.modelId,config:e.config})}static[iZ](t){return new e(t.modelId,t.config)}constructor(e,t){this.modelId=e,this.config=t,this.specificationVersion="v4",this.supportedUrls={"*/*":[/.*/]}}get provider(){return this.config.provider}async getArgs(e){let{abortSignal:t,...r}=e;return{args:this.maybeEncodeFileParts(r),warnings:[]}}async doGenerate(e){let{args:t,warnings:r}=await this.getArgs(e),{abortSignal:a}=e,n=this.config.headers?await sr(this.config.headers):void 0;try{let{responseHeaders:i,value:o,rawValue:s}=await o7({url:this.getUrl(),headers:iL(n,e.headers,this.getModelConfigHeaders(this.modelId,!1),await sr(this.config.o11yHeaders)),body:t,successfulResponseHandler:ss(un()),failedResponseHandler:so({errorSchema:un(),errorToMessage:e=>O(e)??"unknown error"}),...a&&{abortSignal:a},fetch:this.config.fetch});return{...o,request:{body:t},response:{headers:i,body:s},warnings:[...o.warnings??[],...r]}}catch(e){throw await uH(e,await uG(n??{}))}}async doStream(e){let{args:t,warnings:r}=await this.getArgs(e),{abortSignal:a}=e,n=this.config.headers?await sr(this.config.headers):void 0;try{let i,{value:o,responseHeaders:s}=await o7({url:this.getUrl(),headers:iL(n,e.headers,this.getModelConfigHeaders(this.modelId,!0),await sr(this.config.o11yHeaders)),body:t,successfulResponseHandler:(i=un(),async({response:e,url:t,requestBodyValues:r})=>{let a=iK(e);if(null==e.body)throw new T({});return{responseHeaders:a,value:o9({stream:function({stream:e,url:t,requestBodyValues:r,statusCode:a,responseHeaders:n}){let i=e.getReader(),o=!1,s=()=>{o||(i.releaseLock(),o=!0)};return new ReadableStream({async pull(e){try{let{done:t,value:r}=await i.read();t?(s(),e.close()):e.enqueue(r)}catch(i){if(s(),iX(i))return void e.error(i);e.error(i1({error:new E({message:"Failed to process successful response",cause:i,statusCode:a,url:t,responseHeaders:n,requestBodyValues:r}),url:t,requestBodyValues:r}))}},async cancel(e){try{await i.cancel(e)}finally{s()}}})}({stream:e.body,url:t,requestBodyValues:r,statusCode:e.status,responseHeaders:a}),schema:i})}}),failedResponseHandler:so({errorSchema:un(),errorToMessage:e=>O(e)??"unknown error"}),...a&&{abortSignal:a},fetch:this.config.fetch});return{stream:o.pipeThrough(new TransformStream({start(e){r.length>0&&e.enqueue({type:"stream-start",warnings:r})},transform(t,r){if(t.success){let a=t.value;("raw"!==a.type||e.includeRawChunks)&&("response-metadata"===a.type&&a.timestamp&&"string"==typeof a.timestamp&&(a.timestamp=new Date(a.timestamp)),r.enqueue(a))}else r.error(t.error)}})),request:{body:t},response:{headers:s}}}catch(e){throw await uH(e,await uG(n??{}))}}maybeEncodeFileParts(e){for(let t of e.prompt)if(Array.isArray(t.content)){for(let e of t.content)if("file"===e.type||"reasoning-file"===e.type)e.data=cl(e.data);else if("tool-result"===e.type&&"content"===e.output.type)for(let t of e.output.value)"file"===t.type&&(t.data=cl(t.data))}return e}getUrl(){return`${this.config.baseURL}/language-model`}getModelConfigHeaders(e,t){return{"ai-language-model-specification-version":"4","ai-language-model-id":e,"ai-language-model-streaming":String(t)}}};function cl(e){if("data"===e.type){let t=e.data;if(t instanceof Uint8Array)return{...e,data:sw.Buffer.from(t).toString("base64")}}return e}var cu=class e{static[iU](e){return sh({modelId:e.modelId,config:e.config})}static[iZ](t){return new e(t.modelId,t.config)}constructor(e,t){this.modelId=e,this.config=t,this.specificationVersion="v4",this.maxEmbeddingsPerCall=2048,this.supportsParallelCalls=!0}get provider(){return this.config.provider}async doEmbed({values:e,dimensions:t,headers:r,abortSignal:a,providerOptions:n}){let i=this.config.headers?await sr(this.config.headers):void 0;try{let{responseHeaders:o,value:s,rawValue:l}=await o7({url:this.getUrl(),headers:iL(i,r??{},this.getModelConfigHeaders(),await sr(this.config.o11yHeaders)),body:{values:e,dimensions:t,...n?{providerOptions:n}:{}},successfulResponseHandler:ss(cd),failedResponseHandler:so({errorSchema:un(),errorToMessage:e=>O(e)??"unknown error"}),...a&&{abortSignal:a},fetch:this.config.fetch});return{embeddings:s.embeddings,usage:s.usage??void 0,providerMetadata:s.providerMetadata,response:{headers:o,body:l},warnings:s.warnings??[]}}catch(e){throw await uH(e,await uG(i??{}))}}getUrl(){return`${this.config.baseURL}/embedding-model`}getModelConfigHeaders(){return{"ai-embedding-model-specification-version":"4","ai-model-id":this.modelId}}};let cc=lZ("type",[lN({type:lJ("unsupported"),feature:s6(),details:s6().optional()}),lN({type:lJ("compatibility"),feature:s6(),details:s6().optional()}),lN({type:lJ("deprecated"),setting:s6(),message:s6()}),lN({type:lJ("other"),message:s6()})]),cd=oQ(()=>o1(lN({embeddings:ui(ui(l_())),usage:lN({tokens:l_()}).nullish(),warnings:ui(cc).optional(),providerMetadata:lB(s6(),lB(s6(),lM())).optional()})));var cp=class e{static[iU](e){return sh({modelId:e.modelId,config:e.config})}static[iZ](t){return new e(t.modelId,t.config)}constructor(e,t){this.modelId=e,this.config=t,this.specificationVersion="v4",this.maxImagesPerCall=Number.MAX_SAFE_INTEGER}get provider(){return this.config.provider}async doGenerate({prompt:e,n:t,size:r,aspectRatio:a,seed:n,files:i,mask:o,providerOptions:s,headers:l,abortSignal:u}){let c=this.config.headers?await sr(this.config.headers):void 0;try{let{responseHeaders:d,value:p}=await o7({url:this.getUrl(),headers:iL(c,l??{},this.getModelConfigHeaders(),await sr(this.config.o11yHeaders)),body:{prompt:e,n:t,...r&&{size:r},...a&&{aspectRatio:a},...n&&{seed:n},...s&&{providerOptions:s},...i&&{files:i.map(e=>cf(e))},...o&&{mask:cf(o)}},successfulResponseHandler:ss(cy),failedResponseHandler:so({errorSchema:un(),errorToMessage:e=>O(e)??"unknown error"}),...u&&{abortSignal:u},fetch:this.config.fetch});return{images:p.images,...null!=p.isRetryable&&{isRetryable:p.isRetryable},warnings:p.warnings??[],providerMetadata:p.providerMetadata,response:{timestamp:new Date,modelId:this.modelId,headers:d},...null!=p.usage&&{usage:{inputTokens:p.usage.inputTokens??void 0,outputTokens:p.usage.outputTokens??void 0,totalTokens:p.usage.totalTokens??void 0}}}}catch(e){throw await uH(e,await uG(c??{}))}}getUrl(){return`${this.config.baseURL}/image-model`}getModelConfigHeaders(){return{"ai-image-model-specification-version":"4","ai-model-id":this.modelId}}};function cf(e){return"file"===e.type&&e.data instanceof Uint8Array?{...e,data:iG(e.data)}:e}let ch=lN({images:ui(lM()).optional()}).catchall(lM()),cm=lZ("type",[lN({type:lJ("unsupported"),feature:s6(),details:s6().optional()}),lN({type:lJ("compatibility"),feature:s6(),details:s6().optional()}),lN({type:lJ("deprecated"),setting:s6(),message:s6()}),lN({type:lJ("other"),message:s6()})]),cg=lN({inputTokens:l_().nullish(),outputTokens:l_().nullish(),totalTokens:l_().nullish()}),cy=lN({images:ui(s6()),isRetryable:lx().optional(),warnings:ui(cm).optional(),providerMetadata:lB(s6(),ch).optional(),usage:cg.optional()});var cv=class{constructor(e,t){this.modelId=e,this.config=t,this.specificationVersion="v4",this.maxVideosPerCall=Number.MAX_SAFE_INTEGER}get provider(){return this.config.provider}async doGenerate(e){let{headers:t,abortSignal:r}=e,a=this.config.headers?await sr(this.config.headers):void 0;try{let{responseHeaders:n,value:i}=await o7({url:this.getUrl(),headers:iL(a,t??{},this.getModelConfigHeaders(),await sr(this.config.o11yHeaders),{accept:"text/event-stream"}),body:this.buildRequestBody(e),successfulResponseHandler:async({response:e,url:t,requestBodyValues:r})=>{if(null==e.body)throw new E({message:"SSE response body is empty",url:t,requestBodyValues:r,statusCode:e.status});let a=o9({stream:e.body,schema:cS}).getReader(),{done:n,value:i}=await a.read();if(a.releaseLock(),n||!i)throw new E({message:"SSE stream ended without a data event",url:t,requestBodyValues:r,statusCode:e.status});if(!i.success)throw new E({message:"Failed to parse video SSE event",cause:i.error,url:t,requestBodyValues:r,statusCode:e.status});let o=i.value;if("error"===o.type)throw new E({message:o.message,statusCode:o.statusCode,url:t,requestBodyValues:r,responseHeaders:Object.fromEntries([...e.headers]),responseBody:JSON.stringify(o),data:{error:{message:o.message,type:o.errorType,param:o.param}}});return{value:{videos:o.videos,warnings:o.warnings,providerMetadata:o.providerMetadata},responseHeaders:Object.fromEntries([...e.headers])}},failedResponseHandler:so({errorSchema:un(),errorToMessage:e=>O(e)??"unknown error"}),...r&&{abortSignal:r},fetch:this.config.fetch});return{videos:i.videos,warnings:i.warnings??[],providerMetadata:i.providerMetadata??void 0,response:{timestamp:new Date,modelId:this.modelId,headers:n}}}catch(e){throw await uH(e,await uG(a??{}))}}async handleWebhookOption({webhook:e}){let{url:t,received:r}=await e();return{webhookUrl:t,received:r}}async doStart(e){let{headers:t,abortSignal:r,webhookUrl:a}=e,n=this.config.headers?await sr(this.config.headers):void 0;try{let{responseHeaders:i,value:o}=await o7({url:this.getStartUrl(),headers:iL(n,t??{},this.getModelConfigHeaders(),await sr(this.config.o11yHeaders)),body:{...this.buildRequestBody(e),...a&&{callbackUrl:a}},successfulResponseHandler:ss(cE),failedResponseHandler:so({errorSchema:un(),errorToMessage:e=>O(e)??"unknown error"}),...r&&{abortSignal:r},fetch:this.config.fetch});return{operation:o.operation,warnings:o.warnings??[],providerMetadata:o.providerMetadata??void 0,response:{timestamp:new Date,modelId:this.modelId,headers:i}}}catch(e){throw await uH(e,await uG(n??{}))}}async doStatus({operation:e,abortSignal:t,headers:r}){let a=this.config.headers?await sr(this.config.headers):void 0;try{let{responseHeaders:n,value:i}=await o7({url:this.getStatusUrl(),headers:iL(a,r??{},this.getModelConfigHeaders(),await sr(this.config.o11yHeaders)),body:{operation:e},successfulResponseHandler:ss(cx),failedResponseHandler:so({errorSchema:un(),errorToMessage:e=>O(e)??"unknown error"}),...t&&{abortSignal:t},fetch:this.config.fetch}),o={timestamp:new Date,modelId:this.modelId,headers:n};if("completed"===i.status)return{status:"completed",videos:i.videos,warnings:i.warnings??[],providerMetadata:i.providerMetadata??void 0,response:o};if("error"===i.status)return{status:"error",error:i.error,providerMetadata:i.providerMetadata??void 0,response:o};if("cancelled"===i.status)return{status:"error",error:"Video generation was cancelled.",providerMetadata:i.providerMetadata??void 0,response:o};return{status:"pending",warnings:i.warnings??[],providerMetadata:i.providerMetadata??void 0,response:o}}catch(e){throw await uH(e,await uG(a??{}))}}buildRequestBody({prompt:e,n:t,aspectRatio:r,resolution:a,duration:n,fps:i,seed:o,generateAudio:s,image:l,frameImages:u,inputReferences:c,providerOptions:d}){return{prompt:e,n:t,...r&&{aspectRatio:r},...a&&{resolution:a},...n&&{duration:n},...i&&{fps:i},...o&&{seed:o},...void 0!==s&&{generateAudio:s},...d&&{providerOptions:d},...l&&{image:cb(l)},...u&&{frameImages:u.map(e=>({...e,image:cb(e.image)}))},...c&&{inputReferences:c.map(e=>cb(e))}}}getUrl(){return`${this.config.baseURL}/video-model`}getStartUrl(){return`${this.config.baseURL}/video-model/start`}getStatusUrl(){return`${this.config.baseURL}/video-model/status`}getModelConfigHeaders(){return{"ai-video-model-specification-version":"4","ai-model-id":this.modelId}}};function cb(e){return"file"===e.type&&e.data instanceof Uint8Array?{...e,data:iG(e.data)}:e}let cw=lN({videos:ui(lM()).optional()}).catchall(lM()),c_=ul([lN({type:lJ("url"),url:s6(),mediaType:s6()}),lN({type:lJ("base64"),data:s6(),mediaType:s6()})]),ck=lZ("type",[lN({type:lJ("unsupported"),feature:s6(),details:s6().optional()}),lN({type:lJ("compatibility"),feature:s6(),details:s6().optional()}),lN({type:lJ("deprecated"),setting:s6(),message:s6()}),lN({type:lJ("other"),message:s6()})]),cS=lZ("type",[lN({type:lJ("result"),videos:ui(c_),warnings:ui(ck).optional(),providerMetadata:lB(s6(),cw).optional()}),lN({type:lJ("error"),message:s6(),errorType:s6(),statusCode:l_(),param:lM().nullable()})]),cE=lN({operation:lM(),warnings:ui(ck).nullish(),providerMetadata:lB(s6(),cw).nullish()}),cx=lZ("status",[lN({status:lJ("pending"),warnings:ui(ck).nullish(),providerMetadata:lB(s6(),cw).nullish()}),lN({status:lJ("completed"),videos:ui(c_),warnings:ui(ck).nullish(),providerMetadata:lB(s6(),cw).nullish()}),lN({status:lJ("error"),error:s6(),providerMetadata:lB(s6(),cw).nullish()}),lN({status:lJ("cancelled"),providerMetadata:lB(s6(),cw).nullish()})]),cI=oQ(()=>o1(lN({models:cR.optional()}).catchall(lM()))),cA=l_().finite().min(0).max(1),cT=s6().min(1).max(256),cO=ul([lN({question:cT.optional(),confidenceBelow:cA}).strict(),lN({question:cT.optional(),probabilityBetween:ui(cA).length(2).refine(([e,t])=>e<=t,{message:"probabilityBetween minimum must be less than or equal to maximum"})}).strict()]),cM=ul([lN({any:lM()}),lN({all:lM()}),lN({atLeast:lM()})]).superRefine((e,t)=>{t.addIssue({code:"custom",message:"conditions can be nested at most 5 levels deep"})}),cz=lN({model:s6().min(1),when:function e(t){if(5===t)return ul([cO,cM]);let r=ui(e(t+1)).min(1).max(20);return ul([cO,lN({any:r}).strict(),lN({all:r}).strict(),lN({atLeast:lN({count:l_().int().min(1),conditions:r}).strict().refine(({count:e,conditions:t})=>e<=t.length,{message:"atLeast count cannot exceed the number of conditions",path:["count"]})}).strict()])}(1)}).strict(),cR=ui(ul([s6(),cz])).superRefine((e,t)=>{let r=e.flatMap((e,t)=>"string"==typeof e?[]:[t]);r.length>1&&t.addIssue({code:"custom",message:"models supports at most one conditional decision fallback"}),void 0!==r[0]&&0!==r[0]&&t.addIssue({code:"custom",message:"a conditional decision fallback must be the first models entry",path:[r[0]]})});var cC=class{constructor(e,t){this.modelId=e,this.config=t,this.specificationVersion="v4",this.supportedQuestionTypes=["choice","score","boolean"]}get provider(){return this.config.provider}doEvaluate(e){return this.doDecide(e)}async doDecide({state:e,questions:t,headers:r,abortSignal:a,providerOptions:n}){let i=e.map(e=>{if("file"!==e.type)return e;if("data"!==e.data.type)throw new V({functionality:`Gateway decision file input: ${e.data.type} data`});let{data:t}=e.data;return{...e,data:{type:"data",data:"string"==typeof t?t:iG(t)}}}),o=await o3({provider:"gateway",providerOptions:n,schema:cI}),s=null==o?n:{...n,gateway:o},l=this.config.headers?await sr(this.config.headers):void 0;try{let{responseHeaders:e,value:n,rawValue:o}=await o7({url:this.getUrl(),headers:iL(l,r??{},this.getModelConfigHeaders(),await sr(this.config.o11yHeaders)),body:{stateParts:i,questions:t,...s?{providerOptions:s}:{}},successfulResponseHandler:ss(cN),failedResponseHandler:so({errorSchema:un(),errorToMessage:e=>O(e)??"unknown error"}),...a&&{abortSignal:a},fetch:this.config.fetch});return{answers:n.answers,...n.rounding?{rounding:n.rounding}:{},...n.usage?{usage:n.usage}:{},warnings:n.warnings??[],providerMetadata:n.providerMetadata,response:{modelId:n.model??this.modelId,headers:e,body:o}}}catch(e){throw await uH(e,await uG(l??{}))}}getUrl(){return`${this.config.baseURL}/decision-model`}getModelConfigHeaders(){return{"ai-decision-model-specification-version":"4","ai-model-id":this.modelId}}};let cP=lZ("type",[lN({type:lJ("choice"),choice:s6(),probabilities:lB(s6(),l_()).optional()}),lN({type:lJ("score"),score:l_(),probabilities:lB(s6(),l_()).optional()}),lN({type:lJ("boolean"),probability:l_()}),lN({type:lJ("refusal")})]),c$=lZ("type",[lN({type:lJ("unsupported"),feature:s6(),details:s6().optional()}),lN({type:lJ("compatibility"),feature:s6(),details:s6().optional()}),lN({type:lJ("deprecated"),setting:s6(),message:s6()}),lN({type:lJ("other"),message:s6()})]),cN=oQ(()=>o1(lN({answers:lB(s6(),cP),model:s6().optional(),rounding:lN({probabilityDecimals:l_().optional(),scoreDecimals:l_().optional()}).optional(),usage:lN({inputTokens:l_().optional(),outputTokens:l_().optional()}).optional(),warnings:ui(c$).optional(),providerMetadata:lB(s6(),lB(s6(),lM())).optional()})));var cj=class{constructor(e,t){this.modelId=e,this.config=t,this.specificationVersion="v4"}get provider(){return this.config.provider}async doRerank({documents:e,query:t,topN:r,headers:a,abortSignal:n,providerOptions:i}){let o=this.config.headers?await sr(this.config.headers):void 0;try{let{responseHeaders:s,value:l,rawValue:u}=await o7({url:this.getUrl(),headers:iL(o,a??{},this.getModelConfigHeaders(),await sr(this.config.o11yHeaders)),body:{documents:e,query:t,...null!=r?{topN:r}:{},...i?{providerOptions:i}:{}},successfulResponseHandler:ss(cU),failedResponseHandler:so({errorSchema:un(),errorToMessage:e=>O(e)??"unknown error"}),...n&&{abortSignal:n},fetch:this.config.fetch});return{ranking:l.ranking,providerMetadata:l.providerMetadata,response:{headers:s,body:u},warnings:l.warnings??[]}}catch(e){throw await uH(e,await uG(o??{}))}}getUrl(){return`${this.config.baseURL}/reranking-model`}getModelConfigHeaders(){return{"ai-reranking-model-specification-version":"4","ai-model-id":this.modelId}}};let cD=lZ("type",[lN({type:lJ("unsupported"),feature:s6(),details:s6().optional()}),lN({type:lJ("compatibility"),feature:s6(),details:s6().optional()}),lN({type:lJ("deprecated"),setting:s6(),message:s6()}),lN({type:lJ("other"),message:s6()})]),cU=oQ(()=>o1(lN({ranking:ui(lN({index:l_(),relevanceScore:l_()})),warnings:ui(cD).optional(),providerMetadata:lB(s6(),lB(s6(),lM())).optional()})));var cZ=class{constructor(e,t){this.modelId=e,this.config=t,this.specificationVersion="v4"}get provider(){return this.config.provider}async doGenerate({text:e,voice:t,outputFormat:r,instructions:a,speed:n,language:i,providerOptions:o,headers:s,abortSignal:l}){let u=this.config.headers?await sr(this.config.headers):void 0;try{let{responseHeaders:c,value:d,rawValue:p}=await o7({url:this.getUrl(),headers:iL(u,s??{},this.getModelConfigHeaders(),await sr(this.config.o11yHeaders)),body:{text:e,...t&&{voice:t},...r&&{outputFormat:r},...a&&{instructions:a},...null!=n&&{speed:n},...i&&{language:i},...o&&{providerOptions:o}},successfulResponseHandler:ss(cB),failedResponseHandler:so({errorSchema:un(),errorToMessage:e=>O(e)??"unknown error"}),...l&&{abortSignal:l},fetch:this.config.fetch});return{audio:d.audio,warnings:d.warnings??[],...null!=d.usage&&{usage:d.usage},providerMetadata:d.providerMetadata,response:{timestamp:new Date,modelId:this.modelId,headers:c,body:p}}}catch(e){throw await uH(e,await uG(u??{}))}}getUrl(){return`${this.config.baseURL}/speech-model`}getModelConfigHeaders(){return{"ai-speech-model-specification-version":"4","ai-model-id":this.modelId}}};let cL=lN({}).catchall(lM()),cF=lZ("type",[lN({type:lJ("unsupported"),feature:s6(),details:s6().optional()}),lN({type:lJ("compatibility"),feature:s6(),details:s6().optional()}),lN({type:lJ("deprecated"),setting:s6(),message:s6()}),lN({type:lJ("other"),message:s6()})]),cB=lN({audio:s6(),warnings:ui(cF).optional(),usage:lB(s6(),us()).optional(),providerMetadata:lB(s6(),cL).optional()});var cq=class{constructor(e,t){this.modelId=e,this.config=t,this.specificationVersion="v4"}get provider(){return this.config.provider}async doGenerate({audio:e,mediaType:t,providerOptions:r,headers:a,abortSignal:n}){let i=this.config.headers?await sr(this.config.headers):void 0;try{var o,s;let{responseHeaders:l,value:u,rawValue:c}=await o7({url:this.getUrl(),headers:iL(i,a??{},this.getModelConfigHeaders(),await sr(this.config.o11yHeaders)),body:{audio:e instanceof Uint8Array?iG(e):e,mediaType:t,...r&&{providerOptions:r}},successfulResponseHandler:ss(cW),failedResponseHandler:so({errorSchema:un(),errorToMessage:e=>O(e)??"unknown error"}),...n&&{abortSignal:n},fetch:this.config.fetch}),d=[...u.warnings??[]];return((o=this.modelId).startsWith("spacexai/")||o.startsWith("xai/"))&&(s=r,s?.xai?.diarize===!0||s?.spacexai?.diarize===!0)&&!function e(t){return Array.isArray(t)?t.some(e):null!=t&&"object"==typeof t&&Object.entries(t).some(([t,r])=>"speaker"===t&&null!=r||e(r))}(c)&&d.push({type:"unsupported",feature:"providerOptions.xai.diarize",details:"AI Gateway does not currently expose xAI speaker diarization metadata."}),{text:u.text,segments:u.segments??[],language:u.language??void 0,durationInSeconds:u.durationInSeconds??void 0,warnings:d,...null!=u.usage&&{usage:u.usage},providerMetadata:u.providerMetadata,response:{timestamp:new Date,modelId:this.modelId,headers:l,body:c}}}catch(e){throw await uH(e,await uG(i??{}))}}async doStream(e){let t,r,a,n=this.config._internal?.currentDate?.()??new Date,i=iL(await sr(this.config.headers??{}),e.headers??{},this.getModelConfigHeaders(),await sr(this.config.o11yHeaders)),o=await uG(i),s={type:"transcription-stream.start",inputAudioFormat:e.inputAudioFormat,...null!=e.providerOptions&&{providerOptions:e.providerOptions},...null!=e.includeRawChunks&&{includeRawChunks:e.includeRawChunks}};return{stream:function({webSocket:e,url:t,protocols:r,headers:a,startFrame:n,audio:i,abortSignal:o,authMethod:s}){let l=!1,u=()=>{};return new ReadableStream({start:c=>{let d,p,f,h=!1,m=!1;u=e=>{null!=d?d.cancel().catch(()=>{}):i.cancel().catch(()=>{}),f?.close(e)};let g=e=>{l||(l=!0,u(),cG(c,e,s))},y=async e=>{let t=i.getReader();d=t;try{for(;;){let{done:r,value:a}=await t.read();if(r||l)break;let n="string"==typeof a?function(e){let t=iW(e.replace(/-/g,"+").replace(/_/g,"/"));return Uint8Array.from(t,e=>e.codePointAt(0))}(a):a;for(let t=0;t<n.length&&!l;t+=65536)e.send(n.subarray(t,t+65536)),await iH(e)}}finally{t.releaseLock(),d===t&&(d=void 0)}l||m||e.send(JSON.stringify({type:"transcription-stream.audio-done"}))};f=function({url:e,protocols:t,headers:r,webSocket:a,abortSignal:n,onOpen:i,onMessageText:o,onProcessingError:s,onSocketError:l,onClose:u,onAbort:c}){let d,p,f=e=>{null!=p&&(n?.removeEventListener("abort",p),p=void 0);try{d?.close(e)}catch{}};if(n?.aborted)return c?.(n.reason??Error("Aborted")),{socket:void 0,close:f};try{var h;d=new(function(e){let t=e??globalThis.WebSocket;if(null==t)throw Error("No WebSocket implementation available.");return t}(a))(e,t,{headers:(h=r??{},Object.fromEntries(Object.entries(h).filter(([e,t])=>null!=t)))})}catch(e){return s(e),{socket:void 0,close:f}}null!=n&&null!=c&&(p=()=>c(n.reason??Error("Aborted")),n.addEventListener("abort",p,{once:!0}));let m=d;d.onopen=()=>{try{i?.(m)}catch(e){s(e)}};let g=Promise.resolve();return d.onmessage=e=>{g=g.then(()=>iV(e.data)).then(e=>o(e)).catch(s)},d.onerror=()=>{g=g.then(()=>l?.()).catch(s)},d.onclose=e=>{let t="number"==typeof e?.code?e.code:void 0,r="string"==typeof e?.reason?e.reason:void 0;g=g.then(()=>u?.({code:t,reason:r})).catch(s)},{socket:d,close:f}}({url:t,protocols:r,headers:a,webSocket:e,abortSignal:o,onAbort:e=>{l||(l=!0,u(),c.error(e))},onProcessingError:g,onOpen:e=>{e.send(JSON.stringify(n)),y(e).catch(g)},onMessageText:e=>{if(l)return;let t=function(e){let t;try{t=oE(e)}catch{return}if(null==t||"object"!=typeof t||Array.isArray(t))return;let r=t;switch(r.type){case"stream-start":return Array.isArray(r.warnings)&&r.warnings.every(sv)?r:void 0;case"transcript-delta":return sm(r.delta)&&sy(r.id,sm)&&sy(r.providerMetadata,ov)?r:void 0;case"transcript-partial":return sm(r.text)&&sy(r.id,sm)&&sy(r.startSecond,sg)&&sy(r.durationInSeconds,sg)&&sy(r.channelIndex,sg)&&sy(r.providerMetadata,ov)?r:void 0;case"transcript-final":return sm(r.text)&&sy(r.id,sm)&&sy(r.startSecond,sg)&&sy(r.endSecond,sg)&&sy(r.channelIndex,sg)&&sy(r.providerMetadata,ov)?r:void 0;case"finish":return sm(r.text)&&Array.isArray(r.segments)&&r.segments.every(sb)&&sy(r.language,sm)&&sy(r.durationInSeconds,sg)&&sy(r.usage,ov)&&sy(r.providerMetadata,ov)?r:void 0;case"response-metadata":{if(!(sy(r.modelId,sm)&&sy(r.headers,ov)))return;let e=r.timestamp;if(null==e)return{...r,timestamp:void 0};if("string"!=typeof e)return;let t=new Date(e);return Number.isNaN(t.getTime())?void 0:{...r,timestamp:t}}case"raw":return"rawValue"in r?r:void 0;case"error":return"error"in r?r:void 0;default:return}}(e);if(null!=t){if("finish"===t.type){l=!0,c.enqueue(t),c.close(),u(1e3);return}"error"===t.type&&(h=!0,p=t.error,m=!0,null!=d?(d.cancel().catch(()=>{}),d=void 0):i.cancel().catch(()=>{})),c.enqueue(t)}},onSocketError:()=>{g(Error("Connection error on AI Gateway transcription stream"))},onClose:()=>{if(h){if(l)return;cY(p,s).then(g);return}g(Error("AI Gateway transcription stream closed before a finish part was received"))}})},cancel:()=>{l||(l=!0,u())}})}({webSocket:this.config.webSocket,url:cV(this.config.baseURL,this.modelId),protocols:(r=(t=i4(i)).authorization,null==(a=r?.startsWith("Bearer ")?r.slice(7):void 0)?[ur]:ua(ur,a,{teamIdOrSlug:t[uW]})),headers:i,startFrame:s,audio:e.audio,abortSignal:e.abortSignal,authMethod:o}),request:{body:s},response:{timestamp:n,modelId:this.modelId}}}getUrl(){return`${this.config.baseURL}/transcription-model`}getModelConfigHeaders(){return{"ai-transcription-model-specification-version":"4","ai-model-id":this.modelId}}};function cV(e,t){let r=new URL(`${e.replace(/^http/,"ws")}/transcription-model`);return r.searchParams.set("ai-model-id",t),r.toString()}let cH=lN({}).catchall(lM()),cJ=lZ("type",[lN({type:lJ("unsupported"),feature:s6(),details:s6().optional()}),lN({type:lJ("compatibility"),feature:s6(),details:s6().optional()}),lN({type:lJ("deprecated"),setting:s6(),message:s6()}),lN({type:lJ("other"),message:s6()})]),cW=lN({text:s6(),segments:ui(lN({text:s6(),startSecond:l_(),endSecond:l_()})).optional(),language:s6().nullish(),durationInSeconds:l_().nullish(),warnings:ui(cJ).optional(),usage:lB(s6(),us()).optional(),providerMetadata:lB(s6(),cH).optional()});async function cG(e,t,r){e.error(await uH(t,r))}let cK={authentication_error:401,failed_dependency:424,forbidden:403,internal_server_error:500,invalid_request_error:400,model_not_found:404,rate_limit_exceeded:429};async function cY(e,t){return"object"==typeof e&&null!=e&&"message"in e&&"string"==typeof e.message&&"type"in e&&"string"==typeof e.type&&e.type in cK?uZ({response:{error:{message:e.message,type:e.type}},statusCode:cK[e.type],authMethod:t}):Error(`AI Gateway transcription stream failed: ${null!=e&&"object"==typeof e&&"message"in e&&"string"==typeof e.message?e.message:O(e)}`)}var cX=class{constructor(e,t){this.specificationVersion="v4",this.modelId=e,this.provider=t.provider,this.config=t}async doCreateClientSecret(e){var t,r;let a,n=await this.config.createClientSecret({modelId:this.modelId,...e?.expiresAfterSeconds!=null&&{expiresAfterSeconds:e.expiresAfterSeconds}});return{token:n.token,url:(t=this.config.baseURL,r=this.modelId,(a=new URL(`${t.replace(/^http/,"ws")}/realtime-model`)).searchParams.set("ai-model-id",r),a.toString()),...null!=n.expiresAt&&{expiresAt:n.expiresAt}}}getWebSocketConfig(e){return{url:e.url,protocols:ua("ai-gateway-realtime.v1",e.token,{teamIdOrSlug:this.config.teamIdOrSlug})}}parseServerEvent(e){return e}serializeClientEvent(e){return e}buildSessionConfig(e){return e}};let cQ=lB(s6(),lM()),c0=st({id:"gateway.browserbase_fetch",inputSchema:oQ(()=>o1(lN({url:s6().url().describe("URL of the page to fetch."),allow_redirects:lx().optional().describe("Whether to follow HTTP redirects (default: false)."),allow_insecure_ssl:lx().optional().describe("Whether to bypass TLS certificate verification (default: false). Only use for trusted hosts."),proxies:lx().optional().describe("Whether to route the request through Browserbase proxies (default: false)."),format:uo(["raw","json","markdown"]).optional().describe("Output format. raw returns the response body unchanged, markdown returns page content as Markdown, and json returns structured content using schema."),schema:cQ.optional().describe("JSON Schema for structured extraction. Only use with format set to json.")}))),outputSchema:oQ(()=>o1(ul([lN({id:s6(),content:ul([s6(),cQ]),contentType:s6(),encoding:s6(),headers:lB(s6(),s6()),statusCode:l_()}),lN({error:uo(["api_error","configuration_error","execution_error","invalid_input","rate_limit","timeout","unknown"]),statusCode:l_().optional(),message:s6()})])))}),c1=st({id:"gateway.browserbase_search",inputSchema:oQ(()=>o1(lN({query:s6().min(1).max(200).describe("Web search query. Must be between 1 and 200 characters."),num_results:l_().int().min(1).max(25).optional().describe("Maximum number of results to return (1-25, default: 10).")}))),outputSchema:oQ(()=>o1(ul([lN({query:s6(),requestId:s6(),results:ui(lN({id:s6(),title:s6(),url:s6(),author:s6().optional(),favicon:s6().optional(),image:s6().optional(),publishedDate:s6().optional()}))}),lN({error:uo(["api_error","configuration_error","execution_error","invalid_input","rate_limit","timeout","unknown"]),statusCode:l_().optional(),message:s6()})])))}),c2=st({id:"gateway.exa_search",inputSchema:oQ(()=>o1(lN({query:s6().describe("Natural-language web search query. This is required."),type:uo(["auto","fast","instant"]).optional().describe("Search method. Use auto for the default balance of speed and quality."),num_results:l_().optional().describe("Maximum number of results to return (1-100, default: 10)."),category:uo(["company","people","research paper","news","personal site","financial report"]).optional().describe("Optional content category to focus results."),user_location:s6().optional().describe("Two-letter ISO country code such as 'US'."),include_domains:ui(s6()).optional().describe("Only return results from these domains."),exclude_domains:ui(s6()).optional().describe("Exclude results from these domains."),start_published_date:s6().optional().describe("Only return links published after this ISO 8601 date."),end_published_date:s6().optional().describe("Only return links published before this ISO 8601 date."),contents:lN({text:ul([lx(),lN({max_characters:l_().optional(),include_html_tags:lx().optional(),verbosity:uo(["compact","standard","full"]).optional(),include_sections:ui(uo(["header","navigation","banner","body","sidebar","footer","metadata"])).optional(),exclude_sections:ui(uo(["header","navigation","banner","body","sidebar","footer","metadata"])).optional()})]).optional(),highlights:ul([lx(),lN({query:s6().optional(),max_characters:l_().optional()})]).optional(),max_age_hours:l_().optional(),livecrawl_timeout:l_().optional(),subpages:l_().optional(),subpage_target:ul([s6(),ui(s6())]).optional(),extras:lN({links:l_().optional(),image_links:l_().optional()}).optional()}).optional().describe("Controls extracted page content and freshness.")}))),outputSchema:oQ(()=>o1(ul([lN({requestId:s6(),searchType:s6().optional(),resolvedSearchType:s6().optional(),results:ui(lN({title:s6(),url:s6(),id:s6(),publishedDate:s6().nullable().optional(),author:s6().nullable().optional(),image:s6().nullable().optional(),favicon:s6().nullable().optional(),text:s6().optional(),highlights:ui(s6()).optional(),highlightScores:ui(l_()).optional(),summary:s6().optional(),subpages:ui(un()).optional(),extras:lN({links:ui(s6()).optional(),imageLinks:ui(s6()).optional()}).optional()})),costDollars:lN({total:l_().optional(),search:lB(s6(),l_()).optional()}).optional()}),lN({error:uo(["api_error","rate_limit","timeout","invalid_input","configuration_error","execution_error","unknown"]),statusCode:l_().optional(),message:s6()})])))}),c4=st({id:"gateway.parallel_search",inputSchema:oQ(()=>o1(lN({objective:s6().describe("Natural-language description of the web research goal, including source or freshness guidance and broader context from the task. Maximum 5000 characters."),search_queries:ui(s6()).optional().describe("Optional search queries to supplement the objective. Maximum 200 characters per query."),mode:uo(["one-shot","agentic"]).optional().describe('Mode preset: "one-shot" for comprehensive results with longer excerpts (default), "agentic" for concise, token-efficient results for multi-step workflows.'),max_results:l_().optional().describe("Maximum number of results to return (1-20). Defaults to 10 if not specified."),source_policy:lN({include_domains:ui(s6()).optional().describe("Limit results to these domains. Use plain domain names only — e.g. example.com or sub.example.gov, or a bare extension like .edu. Do not include a scheme, path, or port (e.g. not https://example.com/page)."),exclude_domains:ui(s6()).optional().describe("Exclude results from these domains. Use plain domain names only — e.g. example.com or sub.example.gov, or a bare extension like .edu. Do not include a scheme, path, or port (e.g. not https://example.com/page)."),after_date:s6().optional().describe("Only include results published after this date. Use an ISO 8601 calendar date formatted YYYY-MM-DD (e.g. 2025-01-01); do not include a time.")}).optional().describe("Source policy for controlling which domains to include/exclude and freshness."),excerpts:lN({max_chars_per_result:l_().optional().describe("Maximum characters per result."),max_chars_total:l_().optional().describe("Maximum total characters across all results.")}).optional().describe("Excerpt configuration for controlling result length."),fetch_policy:lN({max_age_seconds:l_().optional().describe("Maximum age in seconds for cached content. Set to 0 to always fetch fresh content.")}).optional().describe("Fetch policy for controlling content freshness.")}))),outputSchema:oQ(()=>o1(ul([lN({searchId:s6(),results:ui(lN({url:s6(),title:s6(),excerpt:s6(),publishDate:s6().nullable().optional(),relevanceScore:l_().optional()}))}),lN({error:uo(["api_error","rate_limit","timeout","invalid_input","configuration_error","unknown"]),statusCode:l_().optional(),message:s6()})])))}),c5=st({id:"gateway.perplexity_search",inputSchema:oQ(()=>o1(lN({query:ul([s6(),ui(s6())]).describe("Search query (string) or multiple queries (array of up to 5 strings). Multi-query searches return combined results from all queries."),max_results:l_().optional().describe("Maximum number of search results to return (1-20, default: 10)"),max_tokens_per_page:l_().optional().describe("Maximum number of tokens to extract per search result page (256-2048, default: 2048)"),max_tokens:l_().optional().describe("Maximum total tokens across all search results (default: 25000, max: 1000000)"),country:s6().optional().describe("Two-letter ISO 3166-1 alpha-2 country code for regional search results (e.g., 'US', 'GB', 'FR')"),search_domain_filter:ui(s6()).optional().describe("List of domains to include or exclude from search results (max 20). To include: ['nature.com', 'science.org']. To exclude: ['-example.com', '-spam.net']"),search_language_filter:ui(s6()).optional().describe("List of ISO 639-1 language codes to filter results (max 10, lowercase). Examples: ['en', 'fr', 'de']"),search_after_date:s6().optional().describe("Include only results published after this date. Format: 'MM/DD/YYYY' (e.g., '3/1/2025'). Cannot be used with search_recency_filter."),search_before_date:s6().optional().describe("Include only results published before this date. Format: 'MM/DD/YYYY' (e.g., '3/15/2025'). Cannot be used with search_recency_filter."),last_updated_after_filter:s6().optional().describe("Include only results last updated after this date. Format: 'MM/DD/YYYY' (e.g., '3/1/2025'). Cannot be used with search_recency_filter."),last_updated_before_filter:s6().optional().describe("Include only results last updated before this date. Format: 'MM/DD/YYYY' (e.g., '3/15/2025'). Cannot be used with search_recency_filter."),search_recency_filter:uo(["day","week","month","year"]).optional().describe("Filter results by relative time period. Cannot be used with search_after_date or search_before_date.")}))),outputSchema:oQ(()=>o1(ul([lN({results:ui(lN({title:s6(),url:s6(),snippet:s6(),date:s6().optional(),lastUpdated:s6().optional()})),id:s6()}),lN({error:uo(["api_error","rate_limit","timeout","invalid_input","unknown"]),statusCode:l_().optional(),message:s6()})])))}),c6=lN({count:l_().optional().describe("Maximum number of data results to return (1-20). When include_contents is true, each additional result adds its own data surcharge."),include_contents:lx().optional().describe("Inline rows for each data result. This adds a data surcharge based on row count and dataset source. To estimate cost, search with include_contents disabled and inspect cards.content.export_pricing. This applies to every returned card; limit sources.data.count and sources.data.max_rows to control cost."),mode:uo(["inline","url"]).optional().describe("Requested data delivery mode. Search card data is always inline."),content_format:uo(["card_json","csv","json_compact","json_records"]).optional().describe("Serialization for inlined card data."),max_rows:l_().optional().describe("Maximum rows to inline per result. Omit to use the allowance in cards.content.export_pricing. A data surcharge applies per 1,000 exported rows; lower values reduce cost."),node_ids:ui(s6()).optional().describe("Data Graph node IDs to prioritize. Maximum 20."),strict:lx().optional().describe("Only return cards matching node_ids. Requires a non-empty node_ids.")}),c9=lN({count:l_().optional().describe("Maximum number of web results to return (1-20)."),include_contents:lx().optional().describe("Inline extracted web page text. This can add a data charge."),category:uo(["finance","news","sports"]).optional().describe("Optional web-result category filter."),include_domains:ui(s6()).optional().describe("Only return results from these bare domains."),exclude_domains:ui(s6()).optional().describe("Exclude results from these bare domains."),snippet_max_chars:l_().optional().describe("Maximum characters in each web-result snippet."),highlights:lx().optional().describe("Include highlighted passages in web results. Defaults to true in AI Gateway."),article_content_max_chars:l_().optional().describe("Maximum extracted characters per web page when including contents."),published_after:s6().optional().describe("Keep results published on or after this ISO date (YYYY-MM-DD)."),published_before:s6().optional().describe("Keep results published on or before this ISO date (YYYY-MM-DD).")}),c3=oQ(()=>o1(lN({query:s6().describe('Natural-language search query. Include the entity, metric, and time period. Quote a phrase to force it to one entity, for example "Tesla":PRODUCT price.'),effort:uo(["deep","fast","instant"]).optional().describe("Search effort. fast is the balanced default, instant favors cached results and low latency, and deep broadens retrieval with reranking at higher cost and latency."),sources:lN({data:c6.optional(),web:c9.optional()}).optional().describe("Sources to search. Omit to search both curated data and the web. When provided, only keys present are searched."),location:lN({latitude:l_().describe("Latitude between -90 and 90."),longitude:l_().describe("Longitude between -180 and 180.")}).optional().describe("End-user coordinates for localized results."),country_code:s6().optional().describe("Two-letter ISO 3166-1 country code, such as 'US'."),locale:s6().optional().describe("BCP-47 locale, such as 'en-US'."),timezone:s6().optional().describe("IANA timezone, such as 'America/New_York'."),output_settings:lN({image_dark_mode:lx().optional().describe("Render card preview images in dark mode."),force_refresh:lx().optional().describe("Instant-effort only. Request a refreshed instant result.")}).optional().describe("Controls card rendering in the search response."),include_related:l_().optional().describe("Maximum related search suggestions to include (1-20).")}))),c8=ul([lx(),l_(),s6()]).nullable(),c7=lN({content_format:uo(["card_json","csv","json_compact","json_records"]).nullish(),cost:l_().optional(),data:s6().nullish(),records:ui(lB(s6(),c8)).nullish(),dataset:lN({columns:ui(lN({name:s6(),type:uo(["boolean","date","datetime","number","string"]),unit:s6().nullish()})),rows:ui(ui(c8)),total_rows:l_(),truncated:lx(),ref:s6(),sources:ui(lN({name:s6(),index:uo(["data","web"]).optional()})),provenance:uo(["query","web_extraction"]).optional()}).nullish(),card_data:lN({}).passthrough().nullish(),card_data_schema:lN({}).passthrough().nullish(),url:s6().nullish(),expires_at:s6().nullish(),total_rows:l_().nullish(),truncated:lx().optional(),export_pricing:lN({baseline_usd:l_(),free_rows:l_(),max_rows_ceiling:l_(),row_cpm_usd:l_()}).nullish(),manifest:ui(lN({dtype:uo(["boolean","date","datetime","number","string"]).nullish(),entity:s6().nullish(),metric:s6().nullish(),name:s6().nullish(),unit:s6().nullish()})).nullish()}).passthrough(),de=lN({card_id:s6().nullish(),title:s6().nullish(),description:s6().nullish(),semantic_description:s6().nullish(),webpage_url:s6().nullish(),image_url:s6().nullish(),embed_url:s6().nullish(),sources:ui(lN({source_name:s6().nullish(),source_description:s6().nullish(),source_index:uo(["data","web"]),source_text:s6().nullish(),url:s6().nullish()})).nullish(),methodologies:ui(lN({methodology_name:s6().nullable(),methodology_description:s6().nullable()})).nullish(),source_indexes:ui(uo(["data","web"])).nullish(),card_type:s6().nullish(),relevance:uo(["High","Low","Medium"]).nullish(),content:c7.nullish(),exportable:lx().optional(),nodes:ui(lN({id:s6(),type:uo(["entity","metric"]),name:s6(),description:s6().nullish()})).nullish(),metric_definitions:ui(lN({name:s6(),definition:s6()})).nullish(),data_freshness:lN({coverage_end:s6().nullish(),data_as_of:s6().nullish(),last_updated:s6().nullish()}).nullish()}).passthrough(),dt=lN({title:s6(),url:s6(),snippet:s6().nullish(),source_name:s6().nullish(),publish_date:s6().nullish(),content:c7.nullish()}).passthrough(),dr=st({id:"gateway.tako_search",inputSchema:c3,outputSchema:oQ(()=>o1(ul([lN({request_id:s6(),cards:ui(de).optional(),web_results:ui(dt).optional(),usage:lN({total_cost_usd:l_(),compute:lN({cost_usd:l_()}).nullish(),data:lN({cost_usd:l_(),datasets:l_()}).nullish()}).nullish(),related:ui(lN({}).passthrough()).nullish()}).passthrough(),lN({error:uo(["api_error","configuration_error","execution_error","invalid_input","rate_limit","timeout","unknown_tool"]),statusCode:l_().optional(),message:s6()})])))}),da={browserbaseFetch:(e={})=>c0(e),browserbaseSearch:(e={})=>c1(e),exaSearch:(e={})=>c2(e),parallelSearch:(e={})=>c4(e),perplexitySearch:(e={})=>c5(e),takoSearch:(e={})=>dr(e)};async function dn(){return(0,ut.getContext)().headers?.["x-vercel-id"]}let di=lN({token:s6(),expiresAt:l_().nullish()});async function ds(e){let t=ob({settingValue:e.apiKey,environmentVariableName:"AI_GATEWAY_API_KEY"});return t?{token:t,authMethod:"api-key"}:{token:await (0,ut.getVercelOidcToken)(),authMethod:"oidc"}}!function(e={}){var t;let r=null,a=null,n=e.metadataCacheRefreshMillis??3e5,i=0,o=(t=e.baseURL,t?.replace(/\/$/,"")??"https://ai-gateway.vercel.sh/v4/ai"),s=t=>i5({Authorization:`Bearer ${t.token}`,"ai-gateway-protocol-version":"0.0.1",[uJ]:t.authMethod,...null!=e.teamIdOrSlug?{[uW]:e.teamIdOrSlug}:{},...e.headers},"ai-sdk-gateway/4.0.115"),l=async()=>{try{return s(await ds(e))}catch(e){throw uf.createContextualError({apiKeyProvided:!1,oidcTokenProvided:!1,statusCode:401,cause:e})}},u=async()=>{try{return await ds(e)}catch(e){throw uf.createContextualError({apiKeyProvided:!1,oidcTokenProvided:!1,statusCode:401,cause:e})}},c=async t=>{if(void 0!==globalThis.window)throw Error("AI Gateway client secrets must be minted server-side: minting needs your Gateway credential, which must never reach the browser. Call gateway.experimental_realtime.getToken() or gateway.experimental_transcription.getToken() from your server and pass the returned token to the client.");let r=s(await u()),a=new URL("/v1/realtime/client-secrets",o).toString();try{let{value:n}=await o7({url:a,headers:r,body:{model:t.modelId,...null!=t.routeKind&&{routeKind:t.routeKind},...null!=t.expiresAfterSeconds&&{expiresIn:t.expiresAfterSeconds}},successfulResponseHandler:ss(di),failedResponseHandler:so({errorSchema:un(),errorToMessage:e=>O(e)??"unknown error"}),fetch:e.fetch});return{token:n.token,...null!=n.expiresAt&&{expiresAt:n.expiresAt}}}catch(e){throw await uH(e,await uG(r))}},d=()=>{let e=ob({settingValue:void 0,environmentVariableName:"VERCEL_DEPLOYMENT_ID"}),t=ob({settingValue:void 0,environmentVariableName:"VERCEL_ENV"}),r=ob({settingValue:void 0,environmentVariableName:"VERCEL_REGION"}),a=ob({settingValue:void 0,environmentVariableName:"VERCEL_PROJECT_ID"});return async()=>{let n=await dn();return{...e&&{"ai-o11y-deployment-id":e},...t&&{"ai-o11y-environment":t},...r&&{"ai-o11y-region":r},...n&&{"ai-o11y-request-id":n},...a&&{"ai-o11y-project-id":a}}}},p=t=>new cs(t,{provider:"gateway",baseURL:o,headers:l,fetch:e.fetch,o11yHeaders:d()}),f=async()=>{let t=e._internal?.currentDate?.().getTime()??Date.now();return(!r||t-i>n)&&(i=t,r=new uX({baseURL:o,headers:l,fetch:e.fetch}).getAvailableModels().then(e=>(a=e,e)).catch(async e=>{throw await uH(e,await uG(await l()))})),a?Promise.resolve(a):r},h=async()=>new uX({baseURL:o,headers:l,fetch:e.fetch}).getCredits().catch(async e=>{throw await uH(e,await uG(await l()))}),m=async t=>new u1({baseURL:o,headers:l,fetch:e.fetch}).getSpendReport(t).catch(async e=>{throw await uH(e,await uG(await l()))}),g=async t=>new u4({baseURL:o,headers:l,fetch:e.fetch}).getGenerationInfo(t).catch(async e=>{throw await uH(e,await uG(await l()))}),y=function(e){if(new.target)throw Error("The Gateway Provider model function cannot be called with the new keyword.");return p(e)};y.specificationVersion="v4",y.getAvailableModels=f,y.getCredits=h,y.getSpendReport=m,y.getGenerationInfo=g,y.imageModel=t=>new cp(t,{provider:"gateway",baseURL:o,headers:l,fetch:e.fetch,o11yHeaders:d()}),y.languageModel=p,y.experimental_batch=()=>new u6({provider:"gateway",maxLineBytes:e.batchResultDownloads?.maxLineBytes,baseURL:o,headers:l,fetch:e.fetch,o11yHeaders:d()});let v=t=>new cu(t,{provider:"gateway",baseURL:o,headers:l,fetch:e.fetch,o11yHeaders:d()});y.embeddingModel=v,y.textEmbeddingModel=v,y.videoModel=t=>new cv(t,{provider:"gateway",baseURL:o,headers:l,fetch:e.fetch,o11yHeaders:d()});let b=t=>new cj(t,{provider:"gateway",baseURL:o,headers:l,fetch:e.fetch,o11yHeaders:d()});y.rerankingModel=b,y.reranking=b;let w=t=>new cC(t,{provider:"gateway",baseURL:o,headers:l,fetch:e.fetch,o11yHeaders:d()});y.decisionModel=w,y.decision=w,y.evaluationModel=w,y.evaluation=w;let _=t=>new cZ(t,{provider:"gateway",baseURL:o,headers:l,fetch:e.fetch,o11yHeaders:d()});y.speechModel=_,y.speech=_;let k=t=>new cq(t,{provider:"gateway",baseURL:o,headers:l,fetch:e.fetch,o11yHeaders:d(),webSocket:e.webSocket});y.transcriptionModel=k,y.transcription=k,y.experimental_transcription=Object.assign(e=>k(e),{getToken:async e=>{let t=await c({modelId:e.model,routeKind:"transcription",...null!=e.expiresAfterSeconds&&{expiresAfterSeconds:e.expiresAfterSeconds}});return{token:t.token,url:cV(o,e.model),...null!=t.expiresAt&&{expiresAt:t.expiresAt}}}});let S=t=>new cX(t,{provider:"gateway.realtime",baseURL:o,teamIdOrSlug:e.teamIdOrSlug,createClientSecret:c});y.experimental_realtime=Object.assign(e=>S(e),{getToken:async e=>{let{model:t,...r}=e,a=await S(t).doCreateClientSecret(r);return{token:a.token,url:a.url,...null!=a.expiresAt&&{expiresAt:a.expiresAt}}}}),y.chat=y.languageModel,y.embedding=y.embeddingModel,y.image=y.imageModel,y.video=y.videoModel,y.tools=da}();let dl="AI_InvalidArgumentError",du=`vercel.ai.error.${dl}`,dc=Symbol.for(du);var dd=class extends w{constructor({parameter:e,value:t,message:r}){super({name:dl,message:`Invalid argument for parameter ${e}: ${r}`}),this[dc]=!0,this.parameter=e,this.value=t}static isInstance(e){return w.hasMarker(e,du)}};Symbol.for("vercel.ai.error.AI_InvalidStreamPartError"),Symbol.for("vercel.ai.error.AI_InvalidToolApprovalError"),Symbol.for("vercel.ai.error.AI_InvalidToolApprovalSignatureError"),Symbol.for("vercel.ai.error.AI_InvalidToolInputError"),Symbol.for("vercel.ai.error.AI_ToolCallNotFoundForApprovalError"),Symbol.for("vercel.ai.error.AI_MissingToolResultsError"),Symbol.for("vercel.ai.error.AI_NoImageGeneratedError");let dp="AI_NoObjectGeneratedError",df=`vercel.ai.error.${dp}`,dh=Symbol.for(df);Symbol.for("vercel.ai.error.AI_NoOutputGeneratedError"),Symbol.for("vercel.ai.error.AI_NoSpeechGeneratedError"),Symbol.for("vercel.ai.error.AI_NoTranscriptGeneratedError"),Symbol.for("vercel.ai.error.AI_NoTranslationGeneratedError"),Symbol.for("vercel.ai.error.AI_NoVideoGeneratedError"),Symbol.for("vercel.ai.error.AI_NoSuchToolError"),Symbol.for("vercel.ai.error.AI_StreamProviderError"),Symbol.for("vercel.ai.error.AI_ToolCallRepairError"),Symbol.for("vercel.ai.error.AI_ToolChoiceViolationError");let dm="AI_UIMessageStreamError",dg=`vercel.ai.error.${dm}`,dy=Symbol.for(dg);var dv=class extends w{constructor({chunkType:e,chunkId:t,message:r}){super({name:dm,message:r}),this[dy]=!0,this.chunkType=e,this.chunkId=t}static isInstance(e){return w.hasMarker(e,dg)}};Symbol.for("vercel.ai.error.AI_InvalidDataContentError"),Symbol.for("vercel.ai.error.AI_InvalidMessageRoleError"),Symbol.for("vercel.ai.error.AI_MessageConversionError"),Symbol.for("vercel.ai.error.AI_RetryError");let db=async({url:e,maxBytes:t,abortSignal:r})=>{let a=e.toString();try{let e=i5({},"ai-sdk/7.0.142",iY()),n=await of({url:a,headers:e,abortSignal:r});if(!n.ok)throw await i6(n),new i7({url:a,statusCode:n.status,statusText:n.statusText});return{data:await oh({response:n,url:a,maxBytes:t??0x80000000}),mediaType:n.headers.get("content-type")??void 0}}catch(e){if(i7.isInstance(e))throw e;throw new i7({url:a,cause:e})}},dw=lP,d_=function(e,t){var r;let a;return r=e??(()=>!0),(a=eC(t)).abort??(a.abort=!0),new l7({type:"custom",check:"custom",fn:r,...a})},dk=lV,dS=function(e,t={}){let r=new ue({type:"custom",check:"custom",fn:t=>t instanceof e,abort:!0,...sq.normalizeParams(t)});return r._zod.bag.Class=e,r._zod.check=t=>{t.value instanceof e||t.issues.push({code:"invalid_type",expected:e.name,input:t.value,inst:r,path:[...r._zod.def.path??[]]})},r},dE=function(e,t){return new l$({type:"object",shape:e,catchall:lM(),...sq.normalizeParams(t)})},dx=lD,dI=l8(()=>dx([lA(),s6(),l_(),lx(),lB(s6(),dI.optional()),dw(dI)])),dA=lB(s6(),lB(s6(),dI.optional())),dT=dx([s6(),dS(Uint8Array),dS(ArrayBuffer),d_(function(e){return globalThis.Buffer?.isBuffer(e)??!1},{message:"Must be a Buffer"})]),dO=lB(s6(),s6()),dM=lN({type:lJ("text"),text:s6(),providerOptions:dA.optional()}),dz=lN({type:lJ("image"),image:dx([dT,dS(URL),dO]),mediaType:s6().optional(),providerOptions:dA.optional()}),dR=lZ("type",[lN({type:lJ("data"),data:dT}),lN({type:lJ("url"),url:dS(URL)}),lN({type:lJ("reference"),reference:dO}),lN({type:lJ("text"),text:s6()})]),dC=lZ("type",[lN({type:lJ("data"),data:dT}),lN({type:lJ("url"),url:dS(URL)})]),dP=lN({type:lJ("file"),data:dx([dR,dT,dS(URL),dO]),filename:s6().optional(),mediaType:s6(),providerOptions:dA.optional()}),d$=lN({type:lJ("reasoning"),text:s6(),providerOptions:dA.optional()}),dN=lN({type:lJ("custom"),kind:s6().transform(e=>e),providerOptions:dA.optional()}),dj=lN({type:lJ("reasoning-file"),data:dx([dC,dT,dS(URL)]),mediaType:s6(),providerOptions:dA.optional()}),dD=lN({type:lJ("tool-call"),toolCallId:s6(),toolName:s6(),input:lM(),providerOptions:dA.optional(),providerExecuted:lx().optional()}),dU=lZ("type",[lN({type:lJ("text"),value:s6(),providerOptions:dA.optional()}),lN({type:lJ("json"),value:dI,providerOptions:dA.optional()}),lN({type:lJ("execution-denied"),reason:s6().optional(),providerOptions:dA.optional()}),lN({type:lJ("error-text"),value:s6(),providerOptions:dA.optional()}),lN({type:lJ("error-json"),value:dI,providerOptions:dA.optional()}),lN({type:lJ("content"),value:dw(dx([lN({type:lJ("text"),text:s6(),providerOptions:dA.optional()}),lN({type:lJ("file"),data:dR,mediaType:s6(),filename:s6().optional(),providerOptions:dA.optional()}),lN({type:lJ("file-data"),data:s6(),mediaType:s6(),filename:s6().optional(),providerOptions:dA.optional()}),lN({type:lJ("file-url"),url:s6(),mediaType:s6().optional(),providerOptions:dA.optional()}),lN({type:lJ("file-id"),fileId:dx([s6(),lB(s6(),s6())]),providerOptions:dA.optional()}),lN({type:lJ("file-reference"),providerReference:lB(s6(),s6()),providerOptions:dA.optional()}),lN({type:lJ("image-data"),data:s6(),mediaType:s6(),providerOptions:dA.optional()}),lN({type:lJ("image-url"),url:s6(),providerOptions:dA.optional()}),lN({type:lJ("image-file-id"),fileId:dx([s6(),lB(s6(),s6())]),providerOptions:dA.optional()}),lN({type:lJ("image-file-reference"),providerReference:lB(s6(),s6()),providerOptions:dA.optional()}),lN({type:lJ("custom"),providerOptions:dA.optional()})]))})]),dZ=lN({type:lJ("tool-result"),toolCallId:s6(),toolName:s6(),output:dU,providerOptions:dA.optional()}),dL=lN({type:lJ("tool-approval-request"),approvalId:s6(),toolCallId:s6(),reason:s6().optional(),isAutomatic:lx().optional(),signature:s6().optional(),inputSchemaInput:lM().optional()}),dF=lN({type:lJ("tool-approval-response"),approvalId:s6(),approved:lx(),reason:s6().optional()}),dB=lN({role:lJ("system"),content:s6(),providerOptions:dA.optional()}),dq=lN({role:lJ("user"),content:dx([s6(),dw(dx([dM,dz,dP]))]),providerOptions:dA.optional()}),dV=lN({role:lJ("assistant"),content:dx([s6(),dw(dx([dM,dN,dP,d$,dj,dD,dZ,dL]))]),providerOptions:dA.optional()}),dH=lN({role:lJ("tool"),content:dw(dx([dZ,dF])),providerOptions:dA.optional()});async function dJ(e){if(void 0===e)return{value:void 0,state:"undefined-input"};let t=await o6({text:e});return t.success?{value:t.value,state:"successful-parse"}:(t=await o6({text:function(e){let t=["ROOT"],r=-1,a=null,n=0;function i(e,n,i){switch(e){case'"':r=n,t.pop(),t.push(i),t.push("INSIDE_STRING");break;case"f":case"t":case"n":r=n,a=n,t.pop(),t.push(i),t.push("INSIDE_LITERAL");break;case"-":t.pop(),t.push(i),t.push("INSIDE_NUMBER");break;case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":r=n,t.pop(),t.push(i),t.push("INSIDE_NUMBER");break;case"{":r=n,t.pop(),t.push(i),t.push("INSIDE_OBJECT_START");break;case"[":r=n,t.pop(),t.push(i),t.push("INSIDE_ARRAY_START")}}function o(e,a){switch(e){case",":t.pop(),t.push("INSIDE_OBJECT_AFTER_COMMA");break;case"}":r=a,t.pop()}}function s(e,a){switch(e){case",":t.pop(),t.push("INSIDE_ARRAY_AFTER_COMMA");break;case"]":r=a,t.pop()}}for(let l=0;l<e.length;l++){let u=e[l];switch(t[t.length-1]){case"ROOT":i(u,l,"FINISH");break;case"INSIDE_OBJECT_START":switch(u){case'"':t.pop(),t.push("INSIDE_OBJECT_KEY");break;case"}":r=l,t.pop()}break;case"INSIDE_OBJECT_AFTER_COMMA":'"'===u&&(t.pop(),t.push("INSIDE_OBJECT_KEY"));break;case"INSIDE_OBJECT_KEY":'"'===u&&(t.pop(),t.push("INSIDE_OBJECT_AFTER_KEY"));break;case"INSIDE_OBJECT_AFTER_KEY":":"===u&&(t.pop(),t.push("INSIDE_OBJECT_BEFORE_VALUE"));break;case"INSIDE_OBJECT_BEFORE_VALUE":i(u,l,"INSIDE_OBJECT_AFTER_VALUE");break;case"INSIDE_OBJECT_AFTER_VALUE":o(u,l);break;case"INSIDE_STRING":switch(u){case'"':t.pop(),r=l;break;case"\\":t.push("INSIDE_STRING_ESCAPE");break;default:r=l}break;case"INSIDE_ARRAY_START":"]"===u?(r=l,t.pop()):(r=l,i(u,l,"INSIDE_ARRAY_AFTER_VALUE"));break;case"INSIDE_ARRAY_AFTER_VALUE":switch(u){case",":t.pop(),t.push("INSIDE_ARRAY_AFTER_COMMA");break;case"]":r=l,t.pop();break;default:r=l}break;case"INSIDE_ARRAY_AFTER_COMMA":i(u,l,"INSIDE_ARRAY_AFTER_VALUE");break;case"INSIDE_STRING_ESCAPE":t.pop(),"u"===u?(n=0,t.push("INSIDE_STRING_UNICODE_ESCAPE")):r=l;break;case"INSIDE_STRING_UNICODE_ESCAPE":(u>="0"&&u<="9"||u>="A"&&u<="F"||u>="a"&&u<="f")&&4==++n&&(t.pop(),r=l);break;case"INSIDE_NUMBER":switch(u){case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":r=l;break;case"e":case"E":case"-":case".":break;case",":t.pop(),"INSIDE_ARRAY_AFTER_VALUE"===t[t.length-1]&&s(u,l),"INSIDE_OBJECT_AFTER_VALUE"===t[t.length-1]&&o(u,l);break;case"}":t.pop(),"INSIDE_OBJECT_AFTER_VALUE"===t[t.length-1]&&o(u,l);break;case"]":t.pop(),"INSIDE_ARRAY_AFTER_VALUE"===t[t.length-1]&&s(u,l);break;default:t.pop()}break;case"INSIDE_LITERAL":{let n=e.substring(a,l+1);"false".startsWith(n)||"true".startsWith(n)||"null".startsWith(n)?r=l:(t.pop(),"INSIDE_OBJECT_AFTER_VALUE"===t[t.length-1]?o(u,l):"INSIDE_ARRAY_AFTER_VALUE"===t[t.length-1]&&s(u,l))}}}let l=e.slice(0,r+1);for(let r=t.length-1;r>=0;r--)switch(t[r]){case"INSIDE_STRING":l+='"';break;case"INSIDE_OBJECT_KEY":case"INSIDE_OBJECT_AFTER_KEY":case"INSIDE_OBJECT_AFTER_COMMA":case"INSIDE_OBJECT_START":case"INSIDE_OBJECT_BEFORE_VALUE":case"INSIDE_OBJECT_AFTER_VALUE":l+="}";break;case"INSIDE_ARRAY_START":case"INSIDE_ARRAY_AFTER_COMMA":case"INSIDE_ARRAY_AFTER_VALUE":l+="]";break;case"INSIDE_LITERAL":{let t=e.substring(a,e.length);"true".startsWith(t)?l+="true".slice(t.length):"false".startsWith(t)?l+="false".slice(t.length):"null".startsWith(t)&&(l+="null".slice(t.length))}}return l}(e)})).success?{value:t.value,state:"repaired-parse"}:{value:void 0,state:"failed-parse"}}dx([dB,dq,dV,dH]),Symbol.for("vercel.ai.toolSearch"),Symbol.for("vercel.ai.toolSearch.search"),Symbol.for("vercel.ai.toolSearch.maxResults");Symbol("ai-sdk-tool-call-input-schema-input"),new TextEncoder,new TextEncoder,om({prefix:"aitxt",size:24}),om({prefix:"call",size:24}),TransformStream;let dW=lN({source:lZ("sourceType",[lN({type:lJ("source"),sourceType:lJ("url"),id:s6(),url:s6(),title:s6().optional(),providerMetadata:dA.optional()}),lN({type:lJ("source"),sourceType:lJ("document"),id:s6(),mediaType:s6(),title:s6(),filename:s6().optional(),providerMetadata:dA.optional()})]),startIndex:l_().int().nonnegative().optional(),endIndex:l_().int().nonnegative().optional(),citedText:s6().optional()}),dG=lB(s6(),dI.optional()),dK=oQ(()=>o1(dx([dE({type:lJ("text-start"),id:s6(),providerMetadata:dA.optional()}),dE({type:lJ("text-delta"),id:s6(),delta:s6(),providerMetadata:dA.optional()}),dE({type:lJ("text-end"),id:s6(),citations:dw(dW).optional(),providerMetadata:dA.optional()}),dE({type:lJ("error"),errorText:s6()}),dE({type:lJ("tool-input-start"),toolCallId:s6(),toolName:s6(),inputEncoding:dk(["json","text"]).optional(),providerExecuted:lx().optional(),providerMetadata:dA.optional(),toolMetadata:dG.optional(),dynamic:lx().optional(),title:s6().optional()}),dE({type:lJ("tool-input-delta"),toolCallId:s6(),inputTextDelta:s6()}),dE({type:lJ("tool-input-available"),toolCallId:s6(),toolName:s6(),input:lM(),providerExecuted:lx().optional(),providerMetadata:dA.optional(),toolMetadata:dG.optional(),dynamic:lx().optional(),title:s6().optional()}),dE({type:lJ("tool-input-error"),toolCallId:s6(),toolName:s6(),input:lM(),providerExecuted:lx().optional(),providerMetadata:dA.optional(),toolMetadata:dG.optional(),dynamic:lx().optional(),errorText:s6(),title:s6().optional()}),dE({type:lJ("tool-approval-request"),approvalId:s6(),toolCallId:s6(),approvalDescriptor:lM().optional(),inputSchemaInput:lM().optional(),reason:s6().optional(),isAutomatic:lx().optional(),signature:s6().optional()}),dE({type:lJ("tool-approval-response"),approvalId:s6(),approved:lx(),reason:s6().optional(),providerExecuted:lx().optional(),providerMetadata:dA.optional()}),dE({type:lJ("tool-output-available"),toolCallId:s6(),output:lM(),providerExecuted:lx().optional(),providerMetadata:dA.optional(),toolMetadata:dG.optional(),dynamic:lx().optional(),preliminary:lx().optional()}),dE({type:lJ("tool-output-error"),toolCallId:s6(),errorText:s6(),providerExecuted:lx().optional(),providerMetadata:dA.optional(),toolMetadata:dG.optional(),dynamic:lx().optional()}),dE({type:lJ("tool-output-denied"),toolCallId:s6()}),dE({type:lJ("reasoning-start"),id:s6(),providerMetadata:dA.optional()}),dE({type:lJ("reasoning-delta"),id:s6(),delta:s6(),providerMetadata:dA.optional()}),dE({type:lJ("reasoning-end"),id:s6(),providerMetadata:dA.optional()}),dE({type:lJ("custom"),kind:s6().transform(e=>e),providerMetadata:dA.optional()}),dE({type:lJ("source-url"),sourceId:s6(),url:s6(),title:s6().optional(),providerMetadata:dA.optional()}),dE({type:lJ("source-document"),sourceId:s6(),mediaType:s6(),title:s6(),filename:s6().optional(),providerMetadata:dA.optional()}),dE({type:lJ("file"),url:s6(),mediaType:s6(),providerMetadata:dA.optional()}),dE({type:lJ("reasoning-file"),url:s6(),mediaType:s6(),providerMetadata:dA.optional()}),dE({type:d_(e=>"string"==typeof e&&e.startsWith("data-"),{message:'Type must start with "data-"'}),id:s6().optional(),data:lM(),transient:lx().optional()}),dE({type:lJ("start-step")}),dE({type:lJ("finish-step")}),dE({type:lJ("reset-step")}),dE({type:lJ("start"),messageId:s6().optional(),messageMetadata:lM().optional()}),dE({type:lJ("finish"),finishReason:dk(["stop","length","content-filter","tool-calls","error","other"]).optional(),messageMetadata:lM().optional()}),dE({type:lJ("abort"),reason:s6().optional()}),dE({type:lJ("message-metadata"),messageMetadata:lM()})])));function dY(){return Object.create(null)}function dX(e){return e.type.startsWith("tool-")}function dQ(e){return dX(e)||"dynamic-tool"===e.type}function d0(e){return e.type.split("-").slice(1).join("-")}function d1({lastMessage:e,messageId:t}){let r=e?.role==="assistant"?e:{id:t,metadata:void 0,role:"assistant",parts:[]},a=dY(),n=r.parts.findLastIndex(e=>"step-start"===e.type),i=0;for(let e of r.parts.slice(n+1)){if(!dQ(e))continue;let t=i;dX(e)&&i++,"input-streaming"===e.state&&(a[e.toolCallId]={text:e.rawInput??"",inputEncoding:e.inputEncoding,index:t,toolName:"dynamic-tool"===e.type?e.toolName:d0(e),dynamic:"dynamic-tool"===e.type,title:e.title,toolMetadata:e.toolMetadata})}return{message:r,activeTextParts:dY(),activeReasoningParts:dY(),partialToolCalls:a}}async function d2({stream:e,onError:t,abortSignal:r}){let a=e.getReader(),n=()=>{a.cancel().catch(()=>{})};r?.aborted?n():r?.addEventListener("abort",n,{once:!0});try{for(;;){let{done:e}=await a.read();if(e)break}}catch(e){t?.(e)}finally{r?.removeEventListener("abort",n),a.releaseLock()}}Symbol("streamRetryAttemptBoundary"),om({prefix:"aitxt",size:24}),om({prefix:"call",size:24}),om({prefix:"aitxt",size:24}),om({prefix:"call",size:24}),Symbol("streamRetryBoundary");let d4=lB(s6(),dI.optional()),d5=lB(s6(),s6());function d6(e){return({url:t,abortSignal:r})=>db({url:t,maxBytes:e?.maxBytes,abortSignal:r})}oQ(()=>{let e=lN({id:s6(),approved:lR().optional(),descriptor:lM().optional(),requestReason:s6().optional(),reason:lR().optional(),isAutomatic:lx().optional(),signature:s6().optional(),inputSchemaInput:lM().optional()}),t=e.extend({approved:lx(),reason:s6().optional()}),r=t.extend({approved:lJ(!0)}),a=t.extend({approved:lJ(!1)});return o1(dw(lN({id:s6(),role:dk(["system","user","assistant"]),metadata:lM().optional(),parts:dw(dx([lN({type:lJ("text"),text:s6(),citations:dw(dW).optional(),state:dk(["streaming","done"]).optional(),providerMetadata:dA.optional()}),lN({type:lJ("reasoning"),id:s6().optional(),text:s6(),state:dk(["streaming","done"]).optional(),providerMetadata:dA.optional()}),lN({type:lJ("custom"),kind:s6(),providerMetadata:dA.optional()}),lN({type:lJ("source-url"),sourceId:s6(),url:s6(),title:s6().optional(),providerMetadata:dA.optional()}),lN({type:lJ("source-document"),sourceId:s6(),mediaType:s6(),title:s6(),filename:s6().optional(),providerMetadata:dA.optional()}),lN({type:lJ("file"),mediaType:s6(),filename:s6().optional(),url:s6(),providerReference:d5.optional(),providerMetadata:dA.optional()}),lN({type:lJ("reasoning-file"),mediaType:s6(),url:s6(),providerMetadata:dA.optional()}),lN({type:lJ("step-start")}),lN({type:s6().startsWith("data-"),id:s6().optional(),data:lM()}),lN({type:lJ("dynamic-tool"),dynamic:lJ(!1).optional(),toolName:s6(),toolCallId:s6(),title:s6().optional(),toolMetadata:d4.optional(),state:lJ("input-streaming"),input:lM().optional(),rawInput:s6().optional(),inputEncoding:dk(["json","text"]).optional(),providerExecuted:lx().optional(),callProviderMetadata:dA.optional(),output:lR().optional(),errorText:lR().optional(),approval:lR().optional()}),lN({type:lJ("dynamic-tool"),dynamic:lJ(!1).optional(),toolName:s6(),toolCallId:s6(),title:s6().optional(),toolMetadata:d4.optional(),state:lJ("input-available"),input:lM(),providerExecuted:lx().optional(),output:lR().optional(),errorText:lR().optional(),callProviderMetadata:dA.optional(),approval:lR().optional()}),lN({type:lJ("dynamic-tool"),dynamic:lJ(!1).optional(),toolName:s6(),toolCallId:s6(),title:s6().optional(),toolMetadata:d4.optional(),state:lJ("approval-requested"),input:lM(),providerExecuted:lx().optional(),output:lR().optional(),errorText:lR().optional(),callProviderMetadata:dA.optional(),approval:e}),lN({type:lJ("dynamic-tool"),dynamic:lJ(!1).optional(),toolName:s6(),toolCallId:s6(),title:s6().optional(),toolMetadata:d4.optional(),state:lJ("approval-responded"),input:lM(),providerExecuted:lx().optional(),output:lR().optional(),errorText:lR().optional(),callProviderMetadata:dA.optional(),approval:t}),lN({type:lJ("dynamic-tool"),dynamic:lJ(!1).optional(),toolName:s6(),toolCallId:s6(),title:s6().optional(),toolMetadata:d4.optional(),state:lJ("output-available"),input:lM(),providerExecuted:lx().optional(),output:lM(),errorText:lR().optional(),callProviderMetadata:dA.optional(),resultProviderMetadata:dA.optional(),preliminary:lx().optional(),approval:r.optional()}),lN({type:lJ("dynamic-tool"),dynamic:lJ(!1).optional(),toolName:s6(),toolCallId:s6(),title:s6().optional(),toolMetadata:d4.optional(),state:lJ("output-error"),input:lM().optional(),rawInput:lM().optional(),providerExecuted:lx().optional(),output:lR().optional(),errorText:s6(),callProviderMetadata:dA.optional(),resultProviderMetadata:dA.optional(),approval:r.optional()}),lN({type:lJ("dynamic-tool"),dynamic:lJ(!1).optional(),toolName:s6(),toolCallId:s6(),title:s6().optional(),toolMetadata:d4.optional(),state:lJ("output-denied"),input:lM(),providerExecuted:lx().optional(),output:lR().optional(),errorText:lR().optional(),callProviderMetadata:dA.optional(),approval:a}),lN({type:s6().startsWith("tool-"),toolCallId:s6(),title:s6().optional(),toolMetadata:d4.optional(),state:lJ("input-streaming"),providerExecuted:lx().optional(),callProviderMetadata:dA.optional(),input:lM().optional(),rawInput:s6().optional(),inputEncoding:dk(["json","text"]).optional(),output:lR().optional(),errorText:lR().optional(),approval:lR().optional()}),lN({type:s6().startsWith("tool-"),toolCallId:s6(),title:s6().optional(),toolMetadata:d4.optional(),state:lJ("input-available"),providerExecuted:lx().optional(),input:lM(),output:lR().optional(),errorText:lR().optional(),callProviderMetadata:dA.optional(),approval:lR().optional()}),lN({type:s6().startsWith("tool-"),toolCallId:s6(),title:s6().optional(),toolMetadata:d4.optional(),state:lJ("approval-requested"),input:lM(),providerExecuted:lx().optional(),output:lR().optional(),errorText:lR().optional(),callProviderMetadata:dA.optional(),approval:e}),lN({type:s6().startsWith("tool-"),toolCallId:s6(),title:s6().optional(),toolMetadata:d4.optional(),state:lJ("approval-responded"),input:lM(),providerExecuted:lx().optional(),output:lR().optional(),errorText:lR().optional(),callProviderMetadata:dA.optional(),approval:t}),lN({type:s6().startsWith("tool-"),toolCallId:s6(),title:s6().optional(),toolMetadata:d4.optional(),state:lJ("output-available"),providerExecuted:lx().optional(),input:lM(),output:lM(),errorText:lR().optional(),callProviderMetadata:dA.optional(),resultProviderMetadata:dA.optional(),preliminary:lx().optional(),approval:r.optional()}),lN({type:s6().startsWith("tool-"),toolCallId:s6(),title:s6().optional(),toolMetadata:d4.optional(),state:lJ("output-error"),providerExecuted:lx().optional(),input:lM().optional(),rawInput:lM().optional(),output:lR().optional(),errorText:s6(),callProviderMetadata:dA.optional(),resultProviderMetadata:dA.optional(),approval:r.optional()}),lN({type:s6().startsWith("tool-"),toolCallId:s6(),title:s6().optional(),toolMetadata:d4.optional(),state:lJ("output-denied"),providerExecuted:lx().optional(),input:lM(),output:lR().optional(),errorText:lR().optional(),callProviderMetadata:dA.optional(),approval:a})]))}).superRefine((e,t)=>{"assistant"!==e.role&&0===e.parts.length&&t.addIssue({origin:"array",code:"too_small",minimum:1,inclusive:!0,input:e.parts,path:["parts"],message:"Message must contain at least one part"})})).nonempty("Messages array must not be empty"))}),om({prefix:"call",size:24}),om({prefix:"call",size:24}),new TextEncoder,om({prefix:"call",size:24}),om({prefix:"aiobj",size:24});let{atob:d9}=globalThis;var d3=class{constructor(){this.queue=[],this.isProcessing=!1,this.idleWaiters=[]}async processQueue(){if(!this.isProcessing){this.isProcessing=!0;try{for(;this.queue.length>0;)await this.queue[0](),this.queue.shift()}finally{for(let e of(this.isProcessing=!1,this.idleWaiters.splice(0)))e()}}}async run(e){return new Promise((t,r)=>{this.queue.push(async()=>{try{await e(),t()}catch(e){r(e)}}),this.processQueue()})}async waitForIdle(){(this.isProcessing||0!==this.queue.length)&&await new Promise(e=>{this.idleWaiters.push(e)})}};om({prefix:"aiobj",size:24}),om({prefix:"call",size:24}),d6();lN({token:s6().refine(e=>e.trim().length>0),url:s6().refine(e=>{try{let t=new URL(e);return("ws:"===t.protocol||"wss:"===t.protocol)&&""!==t.hostname}catch{return!1}}),expiresAt:l_().positive().max(Number.MAX_SAFE_INTEGER).optional(),tools:dw(lN({type:lJ("function"),name:s6().min(1),description:s6().optional(),parameters:lB(s6(),lM())})).optional()});async function d8({response:e,url:t,fallbackMessage:r}){let a=await e.text();return new E({message:a||r,url:t,requestBodyValues:void 0,statusCode:e.status,responseBody:a})}async function d7(e){if(null==e)return[];if(!globalThis.FileList||!(e instanceof globalThis.FileList))throw new V({functionality:"FileList",message:"FileList is not supported in the current environment"});return Promise.all(Array.from(e).map(async e=>{let{name:t,type:r}=e;return{type:"file",mediaType:r,filename:t,url:await new Promise((t,r)=>{let a=new FileReader;a.onload=e=>{t(e.target?.result)},a.onerror=e=>r(e),a.readAsDataURL(e)})}}))}Symbol.for("vercel.ai.error.AI_NoSuchProviderError"),om({prefix:"call",size:24}),om({prefix:"call",size:24}),d6(),om({prefix:"call",size:24});var pe=class{constructor({api:e="/api/chat",credentials:t,headers:r,body:a,fetch:n,prepareSendMessagesRequest:i,prepareReconnectToStreamRequest:o}){this.api=e,this.credentials=t,this.headers=r,this.body=a,this.fetch=n,this.prepareSendMessagesRequest=i,this.prepareReconnectToStreamRequest=o}async sendMessages({abortSignal:e,...t}){let r=await sr(this.body),a=await sr(this.headers),n=await sr(this.credentials),i={...i4(a),...i4(t.headers)},o=await this.prepareSendMessagesRequest?.({api:this.api,id:t.chatId,messages:t.messages,body:{...r,...t.body},headers:i,credentials:n,requestMetadata:t.metadata,trigger:t.trigger,messageId:t.messageId}),s=o?.api??this.api,l=o?.headers!==void 0?i4(o.headers):i,u=o?.body!==void 0?o.body:{...r,...t.body,id:t.chatId,messages:t.messages,trigger:t.trigger,messageId:t.messageId},c=o?.credentials??n,d=await (this.fetch??globalThis.fetch)(s,{method:"POST",headers:{"content-type":"application/json",...l},body:JSON.stringify(u),credentials:c,signal:e});if(!d.ok)throw await d8({response:d,url:s,fallbackMessage:"Failed to fetch the chat response."});if(!d.body)throw new T({message:"The response body is empty."});return this.processResponseStream(d.body)}async reconnectToStream(e){let t=await sr(this.body),r=await sr(this.headers),a=await sr(this.credentials),n={...i4(r),...i4(e.headers)},i=await this.prepareReconnectToStreamRequest?.({api:this.api,id:e.chatId,body:{...t,...e.body},headers:n,credentials:a,requestMetadata:e.metadata}),o=i?.api;if(null==o){var s,l;let t,r,a;if("."===e.chatId||".."===e.chatId)throw new dd({parameter:"chatId",value:e.chatId,message:'Chat IDs must not be "." or ".." when using the default reconnect URL.'});s=this.api,l=`/${encodeURIComponent(e.chatId)}/stream`,r=-1===(t=s.search(/[?#]/))?s:s.slice(0,t),a=-1===t?"":s.slice(t),o=`${r.endsWith("/")&&l.startsWith("/")?r.slice(0,-1):r}${l}${a}`}let u=i?.headers!==void 0?i4(i.headers):n,c=i?.credentials??a,d=await (this.fetch??globalThis.fetch)(o,{method:"GET",headers:u,credentials:c,signal:e.abortSignal});if(204===d.status)return null;if(!d.ok)throw await d8({response:d,url:o,fallbackMessage:"Failed to fetch the chat response."});if(!d.body)throw new T({message:"The response body is empty."});return this.processResponseStream(d.body)}},pt=class extends pe{constructor({resumeStreamIsReplay:e=!0,...t}={}){super(t),this.resumeStreamIsReplay=e}processResponseStream(e){return o9({stream:e,schema:dK}).pipeThrough(new TransformStream({async transform(e,t){if(!e.success)throw e.error;t.enqueue(e.value)}}))}},pr=class{constructor({generateId:e=og,id:t=e(),transport:r=new pt,messageMetadataSchema:a,dataPartSchemas:n,state:i,onError:o,onToolCall:s,onFinish:l,onData:u,sendAutomaticallyWhen:c}){this.pendingMessagePreparations=new Set,this.activeResponse=void 0,this.activeResumeRequest=void 0,this.resumableStreamState=void 0,this.jobExecutor=new d3,this.activeStopCount=0,this.stopGeneration=0,this.sendMessage=async(e,t)=>{let r;if(null==e){let e=this.pendingApprovalMessageId;if(null==e){e=this.lastMessage?.id;for(let t=this.state.messages.length-1;t>=0;t--){let r=this.state.messages[t];if("assistant"===r.role&&r.parts.some(e=>dQ(e)&&"approval-responded"===e.state)){e=r.id;break}}}let r=null!=e&&e===this.pendingApprovalMessageId?this.state.messages.findIndex(t=>t.id===e):-1;await this.makeRequestForToolApproval({messageId:e,messageIndex:r,...t});return}if("text"in e||"files"in e){let t,a=new AbortController;this.pendingMessagePreparations.add(a);try{t=Array.isArray(e.files)?e.files:await d7(e.files)}finally{this.pendingMessagePreparations.delete(a)}if(a.signal.aborted)return;r={parts:[...t,..."text"in e&&null!=e.text?[{type:"text",text:e.text}]:[]]}}else r=e;if(null!=e.messageId){let t=this.state.messages.findIndex(t=>t.id===e.messageId);if(-1===t)throw new dd({parameter:"message.messageId",value:e.messageId,message:`message with id ${e.messageId} not found`});if("user"!==this.state.messages[t].role)throw new dd({parameter:"message.messageId",value:e.messageId,message:`message with id ${e.messageId} is not a user message`});this.state.messages=this.state.messages.slice(0,t+1),this.state.replaceMessage(t,{id:e.messageId,...r,role:r.role??"user",metadata:e.metadata})}else this.state.pushMessage({...r,id:r.id??this.generateId(),role:r.role??"user",metadata:e.metadata});await this.makeRequest({trigger:"submit-message",messageId:e.messageId,...t})},this.regenerate=async({messageId:e,...t}={})=>{let r=null==e?this.state.messages.length-1:this.state.messages.findIndex(t=>t.id===e);if(-1===r)throw new dd({parameter:"messageId",value:e,message:`message ${e} not found`});this.state.messages=this.state.messages.slice(0,"assistant"===this.messages[r].role?r:r+1),await this.makeRequest({trigger:"regenerate-message",messageId:e,...t})},this.resumeStream=async(e={})=>{await this.makeRequest({trigger:"resume-stream",...e})},this["~resumeStreamIfDisconnected"]=async({shouldResume:e=()=>!0}={})=>{let t=this.activeResponse;(null!=this.resumableStreamState||null==t||(await t.completionPromise,this.resumableStreamState===t.state))&&null!=this.resumableStreamState&&e()&&await this.resumeStream()},this.clearError=()=>{"error"===this.status&&(this.state.error=void 0,this.setStatus({status:"ready"}))},this.addToolApprovalResponse=async({id:e,approved:t,reason:r,options:a})=>this.jobExecutor.run(async()=>{let n=this.state.messages,i=a=>dQ(a)&&"approval-requested"===a.state&&a.approval.id===e?{...a,state:"approval-responded",approval:{...a.approval,id:e,approved:t,reason:r}}:a,o=n.findIndex(t=>t.parts.some(t=>dQ(t)&&"approval-requested"===t.state&&t.approval.id===e));if(-1!==o){let e=n[o];this.state.replaceMessage(o,{...e,parts:e.parts.map(i)}),this.pendingApprovalMessageId=e.id}if(this.activeResponse&&(this.activeResponse.state.message.parts=this.activeResponse.state.message.parts.map(i)),-1!==o&&"streaming"!==this.status&&"submitted"!==this.status&&this.sendAutomaticallyWhen){let e=await this.shouldSendAutomatically();e&&this.runAutomaticRequest(()=>{let e=-1===o?this.lastMessage?.id:n[o].id;return this.makeRequestForToolApproval({messageId:e,messageIndex:o,...a})},e)}}),this.addToolOutput=async({state:e,toolCallId:t,output:r,errorText:a,options:n})=>this.jobExecutor.run(async()=>{let i=this.state.messages,o=n=>{if(!dQ(n)||n.toolCallId!==t)return n;let{approval:i,...o}=n,s=i?.approved===!0?{approval:{...i,approved:i.approved}}:{};return"output-error"===e?{...o,...s,state:e,input:n.input,output:void 0,errorText:a}:{...o,...s,state:"output-available",input:n.input,output:r,errorText:void 0}},s=i.findIndex(e=>e.parts.some(e=>dQ(e)&&e.toolCallId===t));if(-1!==s){let e=i[s];this.state.replaceMessage(s,{...e,parts:e.parts.map(o)})}if(this.activeResponse&&(this.activeResponse.state.message.parts=this.activeResponse.state.message.parts.map(o)),-1!==s&&"streaming"!==this.status&&"submitted"!==this.status&&this.sendAutomaticallyWhen){let e=await this.shouldSendAutomatically();e&&this.runAutomaticRequest(()=>this.makeRequest({trigger:"submit-message",messageId:i[s].id,...n}),e)}}),this.addToolResult=this.addToolOutput,this.stop=async()=>{this.activeStopCount++,this.stopGeneration++;try{let e=this.activeResumeRequest,t=this.activeResponse;for(let e of this.pendingMessagePreparations)e.abort();e?.abortController.abort(),t?.abortController.abort(),await Promise.all([e?.completionPromise,t?.completionPromise]),await this.jobExecutor.waitForIdle()}finally{this.activeStopCount--}},this.dispose=async()=>{await this.stop(),this.transport.close?.()},this.id=t,this.transport=r,this.generateId=e,this.messageMetadataSchema=a,this.dataPartSchemas=n,this.state=i,this.onError=o,this.onToolCall=s,this.onFinish=l,this.onData=u,this.sendAutomaticallyWhen=c}get status(){return this.state.status}setStatus({status:e,error:t}){if(this.status===e){this.error!==t&&(this.state.error=t);return}this.state.status=e,this.state.error=t}get error(){return this.state.error}get messages(){return this.state.messages}get lastMessage(){return this.state.messages[this.state.messages.length-1]}set messages(e){this.state.messages=e}async shouldSendAutomatically(){if(!this.sendAutomaticallyWhen)return!1;let e=this.sendAutomaticallyWhen({messages:this.state.messages});return e&&"object"==typeof e&&"then"in e?await e:e}async runAutomaticRequest(e,t){let r=this.stopGeneration,a=this.activeStopCount>0;!(t??await this.shouldSendAutomatically())||a||r!==this.stopGeneration||this.activeStopCount>0||await e()}async makeRequestForToolApproval({messageId:e,messageIndex:t,...r}){let a=null!=e&&e===this.pendingApprovalMessageId;a&&(this.pendingApprovalMessageId=void 0),await this.makeRequest({trigger:"submit-message",messageId:e,...r}),a&&"error"===this.status&&null==this.pendingApprovalMessageId&&(this.pendingApprovalMessageId=this.state.messages[t]?.id??e)}async makeRequest(e){let t,r,a={promise:new Promise((e,a)=>{t=e,r=a}),resolve:t,reject:r};try{await this.makeRequestImpl({...e,completionPromise:a.promise})}finally{a.resolve()}}async makeRequestImpl({trigger:e,metadata:t,headers:r,body:a,messageId:n,completionPromise:i}){let o,s;"resume-stream"!==e&&(this.resumableStreamState=void 0);let l=new AbortController,u="resume-stream"===e?{abortController:l,completionPromise:i}:void 0;u&&(this.activeResumeRequest?.abortController.abort(),this.activeResumeRequest=u);let c=()=>null==u||this.activeResumeRequest===u,d=()=>{this.activeResumeRequest===u&&(this.activeResumeRequest=void 0)};if("resume-stream"===e)try{let e=await this.transport.reconnectToStream({chatId:this.id,abortSignal:l.signal,metadata:t,headers:r,body:a});if(l.signal.aborted||!c()){await e?.cancel().catch(()=>{}),c()&&(this.setStatus({status:"ready"}),this.resumableStreamState=void 0),d();return}if(null==e){this.setStatus({status:"ready"}),this.resumableStreamState=void 0,d();return}o=e}catch(e){if(l.signal.aborted||"AbortError"===e.name){c()&&(this.setStatus({status:"ready"}),this.resumableStreamState=void 0),d();return}if(!c())return;this.onError&&e instanceof Error&&this.onError(e),this.setStatus({status:"error",error:e}),d();return}this.setStatus({status:"submitted",error:void 0});let p=this.lastMessage,f="submit-message"===e&&null!=n?this.state.messages.findIndex(e=>e.id===n):this.state.messages.length-1,h=-1===f?p:this.state.messages[f],m=h?.id,g="resume-stream"===e&&h?.role==="assistant"&&h.parts.some(e=>dQ(e)&&("input-streaming"===e.state||"input-available"===e.state&&e.providerExecuted||"approval-responded"===e.state))?this.state.snapshot(h):void 0,y=-1!==f&&f<this.state.messages.length-1&&h?.role==="assistant",v=!1,b=!1,w=!1;try{let u,d={state:"resume-stream"===e&&null!=this.resumableStreamState?this.resumableStreamState:d1({lastMessage:"resume-stream"===e?g:"regenerate-message"===e?void 0:this.state.snapshot(h),messageId:this.generateId()}),abortController:l,completionPromise:i};s=d,d.abortController.signal.addEventListener("abort",()=>{v=!0}),this.activeResponse=d,u="resume-stream"===e?o:await this.transport.sendMessages({chatId:this.id,messages:this.state.messages,abortSignal:d.abortController.signal,metadata:t,headers:r,body:a,trigger:e,messageId:n});let p=e=>this.jobExecutor.run(()=>d.abortController.signal.aborted?Promise.resolve():e({state:d.state,write:({updateStatus:e=!0}={})=>{if(d.abortController.signal.aborted)return;e&&this.setStatus({status:"streaming"});let t=this.state.messages.findLastIndex(e=>e.id===d.state.message.id);if(-1!==t)this.state.replaceMessage(t,d.state.message);else if(y){let e=this.state.messages.findLastIndex(e=>e.id===m);-1!==e?this.state.replaceMessage(e,d.state.message):this.state.pushMessage(d.state.message)}else this.state.pushMessage(d.state.message)}}));if(await d2({stream:function({stream:e,messageMetadataSchema:t,dataPartSchemas:r,runUpdateMessageJob:a,onError:n,onToolCall:i,onData:o,resetStateOnMessageIdChange:s=!1,resetStateOnFirstMessageStart:l=!1}){let u=!0;return e.pipeThrough(new TransformStream({async transform(e,c){await a(async({state:a,write:d})=>{function p(){let e=a.message.parts,t=e.length-1;for(;t>=0&&"step-start"!==e[t].type;)t--;return e.slice(t+1)}function f(e){let t=p().filter(dQ).find(t=>t.toolCallId===e);if(null==t){let r=a.message.parts;for(let a=r.length-1;a>=0;a--){let n=r[a];if(dQ(n)&&n.toolCallId===e){t=n;break}}}if(null==t)throw new dv({chunkType:"tool-invocation",chunkId:e,message:`No tool invocation found for tool call ID "${e}".`});return t}function h(e,t){let r=t??p().find(t=>dX(t)&&t.toolCallId===e.toolCallId);if(null!=r){r.state=e.state,r.input=e.input,r.output=e.output,r.errorText=e.errorText,r.rawInput=e.rawInput,null!=e.inputEncoding?r.inputEncoding=e.inputEncoding:delete r.inputEncoding,r.preliminary=e.preliminary,void 0!==e.title&&(r.title=e.title),void 0!==e.toolMetadata&&(r.toolMetadata=e.toolMetadata),r.providerExecuted=e.providerExecuted??r.providerExecuted;let t=e.providerMetadata;null!=t&&("output-available"===e.state||"output-error"===e.state?r.resultProviderMetadata=t:r.callProviderMetadata=t)}else a.message.parts.push({type:`tool-${e.toolName}`,toolCallId:e.toolCallId,state:e.state,title:e.title,...void 0!==e.toolMetadata?{toolMetadata:e.toolMetadata}:{},input:e.input,...null!=e.inputEncoding?{inputEncoding:e.inputEncoding}:{},output:e.output,rawInput:e.rawInput,errorText:e.errorText,providerExecuted:e.providerExecuted,preliminary:e.preliminary,...null!=e.providerMetadata&&("output-available"===e.state||"output-error"===e.state)?{resultProviderMetadata:e.providerMetadata}:{},...null!=e.providerMetadata&&"output-available"!==e.state&&"output-error"!==e.state?{callProviderMetadata:e.providerMetadata}:{}})}function m(e,t){let r=t??p().find(t=>"dynamic-tool"===t.type&&t.toolCallId===e.toolCallId);if(null!=r){r.state=e.state,r.toolName=e.toolName,r.input=e.input,r.output=e.output,r.errorText=e.errorText,r.rawInput=e.rawInput,null!=e.inputEncoding?r.inputEncoding=e.inputEncoding:delete r.inputEncoding,r.preliminary=e.preliminary,void 0!==e.title&&(r.title=e.title),void 0!==e.toolMetadata&&(r.toolMetadata=e.toolMetadata),r.providerExecuted=e.providerExecuted??r.providerExecuted;let t=e.providerMetadata;null!=t&&("output-available"===e.state||"output-error"===e.state?r.resultProviderMetadata=t:r.callProviderMetadata=t)}else a.message.parts.push({type:"dynamic-tool",toolName:e.toolName,toolCallId:e.toolCallId,state:e.state,input:e.input,...null!=e.inputEncoding?{inputEncoding:e.inputEncoding}:{},output:e.output,errorText:e.errorText,preliminary:e.preliminary,providerExecuted:e.providerExecuted,title:e.title,...void 0!==e.toolMetadata?{toolMetadata:e.toolMetadata}:{},...null!=e.providerMetadata&&("output-available"===e.state||"output-error"===e.state)?{resultProviderMetadata:e.providerMetadata}:{},...null!=e.providerMetadata&&"output-available"!==e.state&&"output-error"!==e.state?{callProviderMetadata:e.providerMetadata}:{}})}async function g(e){if(null!=e){let r=null!=a.message.metadata?function e(t,r){if(void 0===t&&void 0===r)return;if(void 0===t)return r;if(void 0===r)return t;let a={...t};for(let n in r)if("__proto__"!==n&&"constructor"!==n&&"prototype"!==n&&Object.prototype.hasOwnProperty.call(r,n)){let i=r[n];if(void 0===i)continue;let o=n in t?t[n]:void 0,s=null!==i&&"object"==typeof i&&!Array.isArray(i)&&!(i instanceof Date)&&!(i instanceof RegExp),l=null!=o&&"object"==typeof o&&!Array.isArray(o)&&!(o instanceof Date)&&!(o instanceof RegExp);s&&l?a[n]=e(o,i):a[n]=i}return a}(a.message.metadata,e):e;null!=t&&await o2({value:r,schema:t,context:{field:"message.metadata",entityId:a.message.id}}),a.message.metadata=r}}switch(e.type){case"text-start":{let t={type:"text",text:"",providerMetadata:e.providerMetadata,state:"streaming"};a.activeTextParts[e.id]=t,a.message.parts.push(t),d();break}case"text-delta":{let t=a.activeTextParts[e.id];if(null==t)throw new dv({chunkType:"text-delta",chunkId:e.id,message:`Received text-delta for missing text part with ID "${e.id}". Ensure a "text-start" chunk is sent before any "text-delta" chunks.`});t.text+=e.delta,t.providerMetadata=e.providerMetadata??t.providerMetadata,d();break}case"text-end":{let t=a.activeTextParts[e.id];if(null==t)throw new dv({chunkType:"text-end",chunkId:e.id,message:`Received text-end for missing text part with ID "${e.id}". Ensure a "text-start" chunk is sent before any "text-end" chunks.`});t.state="done",null!=e.citations&&(t.citations=e.citations),t.providerMetadata=e.providerMetadata??t.providerMetadata,delete a.activeTextParts[e.id],d();break}case"custom":{let t={type:"custom",kind:e.kind,providerMetadata:e.providerMetadata};a.message.parts.push(t),d();break}case"reasoning-start":{let t={type:"reasoning",id:e.id,text:"",providerMetadata:e.providerMetadata,state:"streaming"};a.activeReasoningParts[e.id]=t,a.message.parts.push(t),d();break}case"reasoning-delta":{let t=a.activeReasoningParts[e.id];if(null==t)throw new dv({chunkType:"reasoning-delta",chunkId:e.id,message:`Received reasoning-delta for missing reasoning part with ID "${e.id}". Ensure a "reasoning-start" chunk is sent before any "reasoning-delta" chunks.`});t.text+=e.delta,t.providerMetadata=e.providerMetadata??t.providerMetadata,d();break}case"reasoning-end":{let t=a.activeReasoningParts[e.id];if(null==t)throw new dv({chunkType:"reasoning-end",chunkId:e.id,message:`Received reasoning-end for missing reasoning part with ID "${e.id}". Ensure a "reasoning-start" chunk is sent before any "reasoning-end" chunks.`});t.providerMetadata=e.providerMetadata??t.providerMetadata,t.state="done",delete a.activeReasoningParts[e.id],d();break}case"file":case"reasoning-file":a.message.parts.push({type:e.type,mediaType:e.mediaType,url:e.url,...null!=e.providerMetadata?{providerMetadata:e.providerMetadata}:{}}),d();break;case"source-url":a.message.parts.push({type:"source-url",sourceId:e.sourceId,url:e.url,title:e.title,providerMetadata:e.providerMetadata}),d();break;case"source-document":a.message.parts.push({type:"source-document",sourceId:e.sourceId,mediaType:e.mediaType,title:e.title,filename:e.filename,providerMetadata:e.providerMetadata}),d();break;case"tool-input-start":{let t=p().filter(dX);a.partialToolCalls[e.toolCallId]={text:"",inputEncoding:e.inputEncoding,toolName:e.toolName,index:t.length,dynamic:e.dynamic,title:e.title,toolMetadata:e.toolMetadata},e.dynamic?m({toolCallId:e.toolCallId,toolName:e.toolName,state:"input-streaming",inputEncoding:e.inputEncoding,input:void 0,providerExecuted:e.providerExecuted,title:e.title,toolMetadata:e.toolMetadata,providerMetadata:e.providerMetadata}):h({toolCallId:e.toolCallId,toolName:e.toolName,state:"input-streaming",inputEncoding:e.inputEncoding,input:void 0,providerExecuted:e.providerExecuted,title:e.title,toolMetadata:e.toolMetadata,providerMetadata:e.providerMetadata}),d();break}case"tool-input-delta":{let t=a.partialToolCalls[e.toolCallId];if(null==t)throw new dv({chunkType:"tool-input-delta",chunkId:e.toolCallId,message:`Received tool-input-delta for missing tool call with ID "${e.toolCallId}". Ensure a "tool-input-start" chunk is sent before any "tool-input-delta" chunks.`});t.text+=e.inputTextDelta;let r="text"===t.inputEncoding?t.text:(await dJ(t.text)).value;t.dynamic?m({toolCallId:e.toolCallId,toolName:t.toolName,state:"input-streaming",inputEncoding:t.inputEncoding,input:r,rawInput:t.text,title:t.title,toolMetadata:t.toolMetadata}):h({toolCallId:e.toolCallId,toolName:t.toolName,state:"input-streaming",inputEncoding:t.inputEncoding,input:r,rawInput:t.text,title:t.title,toolMetadata:t.toolMetadata}),d();break}case"tool-input-available":e.dynamic?m({toolCallId:e.toolCallId,toolName:e.toolName,state:"input-available",input:e.input,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,title:e.title,toolMetadata:e.toolMetadata}):h({toolCallId:e.toolCallId,toolName:e.toolName,state:"input-available",input:e.input,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,title:e.title,toolMetadata:e.toolMetadata}),d(),i&&!e.providerExecuted&&await i({toolCall:e});break;case"tool-input-error":{let t=p().filter(dQ).find(t=>t.toolCallId===e.toolCallId);(null!=t?"dynamic-tool"===t.type:e.dynamic)?m({toolCallId:e.toolCallId,toolName:e.toolName,state:"output-error",input:e.input,errorText:e.errorText,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,toolMetadata:e.toolMetadata}):h({toolCallId:e.toolCallId,toolName:e.toolName,state:"output-error",input:e.input,errorText:e.errorText,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,toolMetadata:e.toolMetadata}),d();break}case"tool-approval-request":{let t=f(e.toolCallId);t.state="approval-requested",t.approval={id:e.approvalId,...null!=e.approvalDescriptor?{descriptor:e.approvalDescriptor}:{},...Object.prototype.hasOwnProperty.call(e,"inputSchemaInput")?{inputSchemaInput:e.inputSchemaInput}:{},...null!=e.reason?{requestReason:e.reason}:{},...!0===e.isAutomatic?{isAutomatic:!0}:{},...null!=e.signature?{signature:e.signature}:{}},d();break}case"tool-approval-response":{let t=function(e){let t=a.message.parts.filter(dQ).find(t=>t.approval?.id===e);if(null==t)throw new dv({chunkType:"tool-approval-response",chunkId:e,message:`No tool invocation found for approval ID "${e}".`});return t}(e.approvalId),r=null==t.approval?{id:e.approvalId}:t.approval;t.state="approval-responded",t.approval={...r,id:e.approvalId,approved:e.approved,...null!=e.reason?{reason:e.reason}:{}},null!=e.providerExecuted&&(t.providerExecuted=e.providerExecuted),null!=e.providerMetadata&&(t.callProviderMetadata=e.providerMetadata),d();break}case"tool-output-denied":f(e.toolCallId).state="output-denied",d();break;case"tool-output-available":{let t=f(e.toolCallId);"dynamic-tool"===t.type?m({toolCallId:e.toolCallId,toolName:t.toolName,state:"output-available",input:t.input,output:e.output,preliminary:e.preliminary,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,title:t.title,toolMetadata:e.toolMetadata??t.toolMetadata},t):h({toolCallId:e.toolCallId,toolName:d0(t),state:"output-available",input:t.input,output:e.output,providerExecuted:e.providerExecuted,preliminary:e.preliminary,providerMetadata:e.providerMetadata,title:t.title,toolMetadata:e.toolMetadata??t.toolMetadata},t),d();break}case"tool-output-error":{let t=f(e.toolCallId);"dynamic-tool"===t.type?m({toolCallId:e.toolCallId,toolName:t.toolName,state:"output-error",input:t.input,errorText:e.errorText,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,title:t.title,toolMetadata:e.toolMetadata??t.toolMetadata},t):h({toolCallId:e.toolCallId,toolName:d0(t),state:"output-error",input:t.input,rawInput:t.rawInput,errorText:e.errorText,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,title:t.title,toolMetadata:e.toolMetadata??t.toolMetadata},t),d();break}case"start-step":a.message.parts.push({type:"step-start"});break;case"finish-step":break;case"reset-step":{let e=p();a.activeTextParts=dY(),a.activeReasoningParts=dY(),a.partialToolCalls=dY(),e.length>0&&(a.message.parts.splice(a.message.parts.length-e.length,e.length),d());break}case"start":{let t=l&&u||s&&null!=e.messageId&&e.messageId!==a.message.id;u=!1,t&&Object.assign(a,d1({lastMessage:void 0,messageId:e.messageId??a.message.id}),{finishReason:void 0}),null!=e.messageId&&(a.message.id=e.messageId),await g(e.messageMetadata),(t||null!=e.messageId||null!=e.messageMetadata)&&d({updateStatus:!1});break}case"finish":null!=e.finishReason&&(a.finishReason=e.finishReason),await g(e.messageMetadata),null!=e.messageMetadata&&d();break;case"message-metadata":await g(e.messageMetadata),null!=e.messageMetadata&&d();break;case"error":n?.(Error(e.errorText));break;default:if(e.type.startsWith("data-")){if(r?.[e.type]!=null){let t=a.message.parts.findIndex(t=>"id"in t&&"data"in t&&t.id===e.id&&t.type===e.type),n=t>=0?t:a.message.parts.length;await o2({value:e.data,schema:r[e.type],context:{field:`message.parts[${n}].data`,entityName:e.type,entityId:e.id}})}if(e.transient){o?.(e);break}let t=null!=e.id?a.message.parts.find(t=>e.type===t.type&&e.id===t.id):void 0;null!=t?t.data=e.data:a.message.parts.push(e),o?.(e),d()}}c.enqueue(e)})}}))}({stream:u,resetStateOnMessageIdChange:"resume-stream"===e,resetStateOnFirstMessageStart:"resume-stream"===e&&this.transport.resumeStreamIsReplay,onToolCall:this.onToolCall,onData:this.onData,messageMetadataSchema:this.messageMetadataSchema,dataPartSchemas:this.dataPartSchemas,runUpdateMessageJob:p,onError:e=>{throw e}}),abortSignal:d.abortController.signal,onError:e=>{throw e}}),v)return c()&&(this.setStatus({status:"ready"}),this.resumableStreamState===d.state&&(this.resumableStreamState=void 0)),null;c()&&(this.setStatus({status:"ready"}),this.resumableStreamState===d.state&&(this.resumableStreamState=void 0))}catch(e){if(v||"AbortError"===e.name)return v=!0,c()&&(this.setStatus({status:"ready"}),this.resumableStreamState===s?.state&&(this.resumableStreamState=void 0)),null;if(!c())return null;if(w=!0,e instanceof TypeError){let t=e.message.toLowerCase();b=t.includes("fetch")||t.includes("network")||"load failed"===t}b?this.resumableStreamState=s?.state:this.resumableStreamState===s?.state&&(this.resumableStreamState=void 0),this.onError&&e instanceof Error&&this.onError(e),this.setStatus({status:"error",error:e})}finally{try{s&&this.onFinish?.({message:s.state.message,messages:this.state.messages,isAbort:v,isDisconnect:b,isError:w,finishReason:s.state.finishReason})}finally{this.activeResponse===s&&(this.activeResponse=void 0),d()}}v||w||await this.runAutomaticRequest(()=>this.makeRequest({trigger:"submit-message",messageId:this.lastMessage?.id,metadata:t,headers:r,body:a}))}},pa=e.i(90979),pn=Object.prototype.hasOwnProperty;let pi=new WeakMap,po=()=>{},ps=po(),pl=Object,pu=e=>e===ps,pc=(e,t)=>({...e,...t}),pd={},pp={},pf="undefined",ph=typeof window!=pf,pm=typeof document!=pf,pg=ph&&"Deno"in window,py=(e,t)=>{let r=pi.get(e);return[()=>!pu(t)&&e.get(t)||pd,a=>{if(!pu(t)){let n=e.get(t);t in pp||(pp[t]=n),r[5](t,pc(n,a),n||pd)}},r[6],()=>!pu(t)&&t in pp?pp[t]:!pu(t)&&e.get(t)||pd]},pv=!0,[pb,pw]=ph&&window.addEventListener?[window.addEventListener.bind(window),window.removeEventListener.bind(window)]:[po,po],p_={initFocus:e=>(pm&&document.addEventListener("visibilitychange",e),pb("focus",e),()=>{pm&&document.removeEventListener("visibilitychange",e),pw("focus",e)}),initReconnect:e=>{let t=()=>{pv=!0,e()},r=()=>{pv=!1};return pb("online",t),pb("offline",r),()=>{pw("online",t),pw("offline",r)}}},pk=!g.default.useId,pS=!ph||pg,pE=pS?g.useEffect:g.useLayoutEffect,px="u">typeof navigator&&navigator.connection,pI=!pS&&px&&(["slow-2g","2g"].includes(px.effectiveType)||px.saveData),pA=new WeakMap,pT=(e,t)=>e===`[object ${t}]`,pO=0,pM=e=>{let t,r,a=typeof e,n=pl.prototype.toString.call(e),i=pT(n,"Date"),o=pT(n,"RegExp"),s=pT(n,"Object");if(pl(e)!==e||i||o)t=i?e.toJSON():"symbol"==a?e.toString():"string"==a?JSON.stringify(e):""+e;else{if(t=pA.get(e))return t;if(t=++pO+"~",pA.set(e,t),Array.isArray(e)){for(r=0,t="@";r<e.length;r++)t+=pM(e[r])+",";pA.set(e,t)}if(s){t="#";let a=pl.keys(e).sort();for(;!pu(r=a.pop());)pu(e[r])||(t+=r+":"+pM(e[r])+",");pA.set(e,t)}}return t},pz=e=>{if("function"==typeof e)try{e=e()}catch(t){e=""}let t=e;return[e="string"==typeof e?e:(Array.isArray(e)?e.length:e)?pM(e):"",t]},pR=0,pC=()=>++pR;async function pP(...e){let[t,r,a,n]=e,i=pc({populateCache:!0,throwOnError:!0},"boolean"==typeof n?{revalidate:n}:n||{}),o=i.populateCache,s=i.rollbackOnError,l=i.optimisticData,u=i.throwOnError;if("function"==typeof r){let e=[];for(let a of t.keys())!/^\$(inf|sub)\$/.test(a)&&r(t.get(a)._k)&&e.push(a);return Promise.all(e.map(c))}return c(r);async function c(r){let n,[c]=pz(r);if(!c)return;let[d,p]=py(t,c),[f,h,m,g]=pi.get(t),y=()=>{let e=f[c];return("function"==typeof i.revalidate?i.revalidate(d().data,r):!1!==i.revalidate)&&(delete m[c],delete g[c],e&&e[0])?e[0](2).then(()=>d().data):d().data};if(e.length<3)return y();let v=a,b=!1,w=pC();h[c]=[w,0];let _=!pu(l),k=d(),S=k.data,E=k._c,x=pu(E)?S:E;if(_&&p({data:l="function"==typeof l?l(x,S):l,_c:x}),"function"==typeof v)try{v=v(x)}catch(e){n=e,b=!0}if(v&&"function"==typeof v.then){let e;if(v=await v.catch(e=>{n=e,b=!0}),w!==h[c][0]){if(b)throw n;return v}b&&_&&(e=n,"function"==typeof s?s(e):!1!==s)&&(o=!0,p({data:x,_c:ps}))}if(o&&!b&&("function"==typeof o?p({data:o(v,x),error:ps,_c:ps}):p({data:v,error:ps,_c:ps})),h[c][1]=pC(),Promise.resolve(y()).then(()=>{p({_c:ps})}),b){if(u)throw n;return}return v}}let p$=(e,t)=>{for(let r in e)e[r][0]&&e[r][0](t)},pN=(e,t)=>{if(!pi.has(e)){let r=pc(p_,t),a=Object.create(null),n=pP.bind(ps,e),i=po,o=Object.create(null),s=(e,t)=>{let r=o[e]||[];return o[e]=r,r.push(t),()=>{let e=r.indexOf(t);e>=0&&(r[e]=r[r.length-1],r.pop())}},l=(t,r,a)=>{e.set(t,r);let n=o[t];if(n)for(let e of n)e(r,a)},u=t=>{let r=pi.get(e),[,n,i,s]=r,l=pC();for(let e in r[8]++,i)delete i[e];for(let e in s)delete s[e];for(let e in n)n[e]=[l,l];let u={};for(let t of[...e.keys()]){let r=e.get(t);e.delete(t);let a=o[t];if(a)for(let e of a)e(u,r)}let c=!t||!1!==t.revalidate;for(let e in a){let t=a[e];for(let e=0;e<t.length;e++)t[e](4,{revalidate:c&&!e})}},c=()=>{if(!pi.has(e)&&(pi.set(e,[a,Object.create(null),Object.create(null),Object.create(null),n,l,s,u,0]),!pS)){let t=r.initFocus(setTimeout.bind(ps,p$.bind(ps,a,0))),n=r.initReconnect(setTimeout.bind(ps,p$.bind(ps,a,1)));i=()=>{t&&t(),n&&n(),pi.delete(e)}}};return c(),[e,n,c,i,u]}let r=pi.get(e);return[e,r[4],ps,ps,r[7]]},[pj,pD,,,pU]=pN(new Map),pZ=pc({onLoadingSlow:po,onSuccess:po,onError:po,onErrorRetry:(e,t,r,a,n)=>{let i=r.errorRetryCount,o=n.retryCount,s=~~((Math.random()+.5)*(1<<(o<8?o:8)))*r.errorRetryInterval;(pu(i)||!(o>i))&&setTimeout(a,s,n)},onDiscarded:po,revalidateOnFocus:!0,revalidateOnReconnect:!0,revalidateIfStale:!0,shouldRetryOnError:!0,errorRetryInterval:pI?1e4:5e3,focusThrottleInterval:5e3,dedupingInterval:2e3,loadingTimeout:pI?5e3:3e3,compare:function e(t,r){var a,n;if(t===r)return!0;if(t&&r&&(a=t.constructor)===r.constructor){if(a===Date)return t.getTime()===r.getTime();if(a===RegExp)return t.toString()===r.toString();if(a===Array){if((n=t.length)===r.length)for(;n--&&e(t[n],r[n]););return -1===n}if(!a||"object"==typeof t){for(a in n=0,t)if(pn.call(t,a)&&++n&&!pn.call(r,a)||!(a in r)||!e(t[a],r[a]))return!1;return Object.keys(r).length===n}}return t!=t&&r!=r},isPaused:()=>!1,cache:pj,mutate:pD,unload:pU,fallback:{}},{isOnline:()=>pv,isVisible:()=>{let e=pm&&document.visibilityState;return pu(e)||"hidden"!==e}}),pL=(0,g.createContext)({}),pF=ph&&window.__SWR_DEVTOOLS_USE__;(pF?window.__SWR_DEVTOOLS_USE__:[]).concat(e=>(t,r,a)=>{let n=r&&((...e)=>{let[a]=pz(t),[,,,n]=pi.get(pj);if(a.startsWith("$inf$"))return r(...e);let i=n[a];return pu(i)?r(...e):(delete n[a],i)});return e(t,n,a)}),pF&&(window.__SWR_DEVTOOLS_REACT__=g.default);let pB=g.default.use||(e=>{switch(e.status){case"pending":throw e;case"fulfilled":return e.value;case"rejected":throw e.reason;default:throw e.status="pending",e.then(t=>{e.status="fulfilled",e.value=t},t=>{e.status="rejected",e.reason=t}),e}}),pq={dedupe:!0},pV=Promise.resolve(ps);pV.status="fulfilled",pV.value=ps;pl.defineProperty(e=>{let{value:t}=e,r=(0,g.useContext)(pL),a="function"==typeof t,n=(0,g.useMemo)(()=>a?t(r):t,[a,r,t]),i=(0,g.useMemo)(()=>a?n:((e,t)=>{let r=pc(e,t);if(t){let{use:a,fallback:n,cacheData:i}=e,{use:o,fallback:s,cacheData:l}=t;a&&o&&(r.use=a.concat(o)),n&&s&&(r.fallback=pc(n,s)),i&&l&&(r.cacheData=pc(i,l))}return r})(r,n),[a,r,n]),o=n&&n.provider,s=(0,g.useRef)(ps);o&&!s.current&&(s.current=pN(o(i.cache||pj),n));let l=s.current;return l&&(i.cache=l[0],i.mutate=l[1],i.unload=l[4]),pE(()=>{if(l)return l[2]&&l[2](),l[3]},[]),(0,g.createElement)(pL.Provider,pc(e,{value:i}))},"defaultValue",{value:pZ});var pH=e.i(26167),pJ=class{#e;#t;#r;#a;#n;#i;constructor(e=[]){this.#t="ready",this.#r=void 0,this.#a=new Set,this.#n=new Set,this.#i=new Set,this.pushMessage=e=>{this.#e=this.#e.concat(e),this.#o()},this.popMessage=()=>{this.#e=this.#e.slice(0,-1),this.#o()},this.replaceMessage=(e,t)=>{this.#e=[...this.#e.slice(0,e),this.snapshot(t),...this.#e.slice(e+1)],this.#o()},this.snapshot=e=>{var t;if(null==e||"object"!=typeof e||!("parts"in e)||!Array.isArray(e.parts))return e;let r={...e,parts:e.parts.map(e=>({...e}))};return"metadata"in e&&(r.metadata=Array.isArray(t=e.metadata)?[...t]:null!=t&&"object"==typeof t&&(Object.getPrototypeOf(t)===Object.prototype||null===Object.getPrototypeOf(t))?{...t}:t),r},this["~registerMessagesCallback"]=(e,t)=>{let r=t?null!=t?(0,pH.default)(e,t):e:e;return this.#a.add(r),()=>{this.#a.delete(r)}},this["~registerStatusCallback"]=e=>(this.#n.add(e),()=>{this.#n.delete(e)}),this["~registerErrorCallback"]=e=>(this.#i.add(e),()=>{this.#i.delete(e)}),this.#o=()=>{this.#a.forEach(e=>e())},this.#s=()=>{this.#n.forEach(e=>e())},this.#l=()=>{this.#i.forEach(e=>e())},this.#e=e}get status(){return this.#t}set status(e){this.#t=e,this.#s()}get error(){return this.#r}set error(e){this.#r=e,this.#l()}get messages(){return this.#e}set messages(e){this.#e=[...e],this.#o()}#o;#s;#l},pW=class extends pr{#u;constructor({messages:e,...t}){let r=new pJ(e);super({...t,state:r}),this["~registerMessagesCallback"]=(e,t)=>this.#u["~registerMessagesCallback"](e,t),this["~registerStatusCallback"]=e=>this.#u["~registerStatusCallback"](e),this["~registerErrorCallback"]=e=>this.#u["~registerErrorCallback"](e),this.#u=r}};let pG=new WeakMap;function pK(e){return{chat:e,messages:e.messages,status:e.status,error:e.error}}function pY(e,t){return e.chat===t.chat&&e.messages===t.messages&&e.status===t.status&&e.error===t.error}"u"<typeof window?g.useEffect:g.useLayoutEffect;var pX=e.i(69322);let pQ={createInterruptionMessage:e=>({id:`interruption-${Date.now()}`,role:"assistant",content:`⚠️ **Operation Interrupted**
92
-
93
- The current operation was stopped by user request.
94
-
95
- **Status at interruption:**
96
- - Current phase: ${({submitted:"request processing",streaming:"response generation",error:"error handling",ready:"idle state"})[e]||e}
97
- - Remaining tasks may not have been completed
98
- - You can start a new request at any time
99
-
100
- *The system is ready for your next command.*`}),hasIncompleteToolInvocations:e=>"assistant"===e.role&&!!e.parts&&e.parts.some(e=>"tool-invocation"===e.type&&e.toolInvocation&&(!e.toolInvocation.result||"call"===e.toolInvocation.state)),filterCompleteMessages(e){return e.filter(e=>!this.hasIncompleteToolInvocations(e))}};var p0=e.i(79684);function p1(e){return["png","jpg","jpeg","gif","webp","bmp","svg"].includes(e.split(".").pop()?.toLowerCase().split("?")[0]||"")?`![image](${e})`:`[${e.split("/").pop()||"file"}](${e})`}let p2=()=>{let e=(0,pX.S)(),[t,r]=(0,p0.f)("copilot-chat-history",[]),a=(0,g.useRef)(!1),{messages:n,error:i,resumeStream:o,status:s,setMessages:l,stop:u,regenerate:c,sendMessage:d}=function({throttle:e,experimental_throttle:t,resume:r=!1,...a}={}){let n,i=e??t,o=(0,g.useRef)({}),s=(0,g.useRef)({});"chat"in a||(s.current={onToolCall:a.onToolCall,onData:a.onData,onFinish:a.onFinish,onError:a.onError,sendAutomaticallyWhen:a.sendAutomaticallyWhen,transport:a.transport});let l=()=>s.current.transport??(n??=new pt),u={...a,transport:{get resumeStreamIsReplay(){return l().resumeStreamIsReplay},sendMessages:e=>l().sendMessages(e),reconnectToStream:e=>l().reconnectToStream(e)},onToolCall:e=>s.current.onToolCall?.(e),onData:e=>s.current.onData?.(e),onFinish:e=>s.current.onFinish?.(e),onError:e=>s.current.onError?.(e),sendAutomaticallyWhen:e=>s.current.sendAutomaticallyWhen?.(e)??!1},c="chat"in a?a.chat:a.id,{chat:d,isExternallyManaged:p}=(0,g.useMemo)(()=>({chat:"chat"in a?a.chat:new pW(u),isExternallyManaged:"chat"in a}),[c]);(0,g.useEffect)(()=>{if(!p)return()=>{d.stop()}},[d,p]);let[f,h]=(0,g.useState)(()=>pK(d));f.chat!==d&&h(pK(d)),(0,g.useEffect)(()=>{let e=!0,t=()=>{if(!e)return;let t=pK(d);h(e=>e.chat!==d||pY(e,t)?e:t)},r=[d["~registerMessagesCallback"](t,i),d["~registerStatusCallback"](t),d["~registerErrorCallback"](t)],a=pK(d);return h(e=>pY(e,a)?e:a),()=>{e=!1,r.forEach(e=>e())}},[d,i]);let{messages:m,status:y,error:v}=f,b=(0,g.useCallback)(e=>{"function"==typeof e&&(e=e(d.messages)),d.messages=e},[d]);return(0,g.useEffect)(()=>{if(r)return function({chat:e,registration:t}){let r=pG.get(e);if(null==r){let t={registrations:new Set};if(pG.set(e,t),r=t,"u">typeof document){let r=()=>(function({chat:e,state:t}){if("visible"!==document.visibilityState||null!=t.pendingVisibilityResume)return;let r=()=>{t.pendingVisibilityResume=void 0};t.pendingVisibilityResume=e["~resumeStreamIfDisconnected"]({shouldResume:()=>pG.get(e)===t&&t.registrations.size>0&&"visible"===document.visibilityState}).then(r,r)})({chat:e,state:t});document.addEventListener("visibilitychange",r),t.cleanupVisibilityListener=()=>{document.removeEventListener("visibilitychange",r)}}}let{registrations:a}=r,n=0===a.size;return a.add(t),n&&"submitted"!==e.status&&"streaming"!==e.status&&e.resumeStream(),()=>{a.delete(t),0===a.size&&(r.cleanupVisibilityListener?.(),pG.delete(e))}}({chat:d,registration:o.current})},[r,d]),{id:d.id,messages:m,setMessages:b,sendMessage:d.sendMessage,regenerate:d.regenerate,clearError:d.clearError,stop:d.stop,error:v,resumeStream:d.resumeStream,status:y,addToolResult:d.addToolOutput,addToolOutput:d.addToolOutput,addToolApprovalResponse:d.addToolApprovalResponse}}({transport:new pt({api:"/chat",credentials:"include"}),messages:t,onError:t=>{let r;r=t.message?.includes("401")||t.message?.includes("invalid_token")||t.message?.includes("Unauthorized")?e.formatMessage({id:"chat.error.auth",defaultMessage:"🔐 **Authentication Error**\n\nYour session has expired or the authentication token is invalid.\n\n**To fix this:**\n1. Refresh the page (Ctrl+R / Cmd+R)\n2. Log out and log back in\n3. Check your permissions\n\n*This happens when your session expires after being idle too long.*"}):t.message?.includes("fetch")||t.message?.includes("Failed to fetch")||t.message?.includes("NetworkError")?e.formatMessage({id:"chat.error.connection",defaultMessage:"🚫 **Connection Error**\n\nCannot connect to the chat API server at {chatUrl}.\n\n**To enable chat:**\n1. Start the backend\n2. Ensure chat/MCP endpoint is configured\n3. Check NEXT_PUBLIC_CHAT_URL\n\n**Current configuration:**\n- Chat URL: {chatUrl}\n\n*Please start the backend.*"},{chatUrl:"/chat"}):t.message?.includes("stream")||t.message?.includes("process")?e.formatMessage({id:"chat.error.stream",defaultMessage:"⚠️ **Stream Processing Error**\n\nThere was an error processing the AI response stream.\n\n**Possible causes:**\n1. Backend not running\n2. MCP server not responding\n3. Missing/invalid API keys\n4. Network issues\n\n**Error details:** {details}"},{details:t.message}):e.formatMessage({id:"chat.error.unexpected",defaultMessage:"❌ **Chat Error**\n\nAn unexpected error occurred: {details}\n\n*Please try again or check the console for details.*"},{details:t.message});let a={id:`error-${Date.now()}`,role:"assistant",parts:[{type:"text",text:r}]};l(e=>[...e,a])}});return(0,g.useEffect)(()=>{"streaming"!==s&&r(n)},[s]),{messages:n,handleSubmit:async(t,r)=>{try{let e=r?.map(p1).join("\n")??"",a=[t,e].filter(Boolean).join("\n");t&&d({text:a})}catch(n){console.error("Error in handleSubmit:",n);let t=n instanceof Error?n.message:"Unknown error",r=t.includes("401")||t.includes("Unauthorized")?e.formatMessage({id:"chat.error.auth",defaultMessage:"🔐 **Authentication Error**\n\nYour session has expired or the authentication token is invalid.\n\n*Please refresh or log in again.*"}):e.formatMessage({id:"chat.error.submission",defaultMessage:"❌ **Submission Error**\n\nFailed to send your message.\n\n**Error:** {details}\n\n*Please ensure the backend is running.*"},{details:t}),a={id:`error-${Date.now()}`,role:"assistant",parts:[{type:"text",text:r}]};l(e=>[...e,a])}},error:i,status:s,clearHistory:()=>{l([]),r([]),a.current=!1},stop:u,addInterruptionMessage:e=>{let t=pQ.createInterruptionMessage(e);l(e=>[...e,t])},sendMessage:d,reload:c,resumeStream:o}};e.s(["f",0,p2],16717);let p4=(0,g.createContext)(void 0);e.s(["s",0,({children:e})=>{let t=p2(),r=(0,g.useMemo)(()=>({messages:t.messages,handleSubmit:t.handleSubmit,error:t.error,clearHistory:t.clearHistory,stop:t.stop,addInterruptionMessage:t.addInterruptionMessage,status:t.status,reload:t.reload,sendMessage:t.sendMessage,resumeStream:t.resumeStream}),[t.messages,t.handleSubmit,t.error,t.clearHistory,t.stop,t.addInterruptionMessage,t.status,t.reload,t.sendMessage,t.resumeStream]);return(0,m.jsx)(p4.Provider,{value:r,children:e})},"k",0,()=>{let e=(0,g.useContext)(p4);if(!e)throw Error("useChatContext must be used within a ChatProvider");return e}],95377)},35750,24271,e=>{var t=e.i(91788);let r=t.forwardRef(function({title:e,titleId:r,...a},n){return t.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true","data-slot":"icon",ref:n,"aria-labelledby":r},a),e?t.createElement("title",{id:r},e):null,t.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6.75 3v2.25M17.25 3v2.25M3 18.75V7.5a2.25 2.25 0 0 1 2.25-2.25h13.5A2.25 2.25 0 0 1 21 7.5v11.25m-18 0A2.25 2.25 0 0 0 5.25 21h13.5A2.25 2.25 0 0 0 21 18.75m-18 0v-7.5A2.25 2.25 0 0 1 5.25 9h13.5A2.25 2.25 0 0 1 21 11.25v7.5"}))});e.s(["f",0,r],35750);let a=t.forwardRef(function({title:e,titleId:r,...a},n){return t.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true","data-slot":"icon",ref:n,"aria-labelledby":r},a),e?t.createElement("title",{id:r},e):null,t.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"m6.75 7.5 3 2.25-3 2.25m4.5 0h3m-9 8.25h13.5A2.25 2.25 0 0 0 21 18V6a2.25 2.25 0 0 0-2.25-2.25H5.25A2.25 2.25 0 0 0 3 6v12a2.25 2.25 0 0 0 2.25 2.25Z"}))});e.s(["f",0,a],24271)},1672,e=>{var t=e.i(91788);let r=t.forwardRef(function({title:e,titleId:r,...a},n){return t.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true","data-slot":"icon",ref:n,"aria-labelledby":r},a),e?t.createElement("title",{id:r},e):null,t.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M10.343 3.94c.09-.542.56-.94 1.11-.94h1.093c.55 0 1.02.398 1.11.94l.149.894c.07.424.384.764.78.93.398.164.855.142 1.205-.108l.737-.527a1.125 1.125 0 0 1 1.45.12l.773.774c.39.389.44 1.002.12 1.45l-.527.737c-.25.35-.272.806-.107 1.204.165.397.505.71.93.78l.893.15c.543.09.94.559.94 1.109v1.094c0 .55-.397 1.02-.94 1.11l-.894.149c-.424.07-.764.383-.929.78-.165.398-.143.854.107 1.204l.527.738c.32.447.269 1.06-.12 1.45l-.774.773a1.125 1.125 0 0 1-1.449.12l-.738-.527c-.35-.25-.806-.272-1.203-.107-.398.165-.71.505-.781.929l-.149.894c-.09.542-.56.94-1.11.94h-1.094c-.55 0-1.019-.398-1.11-.94l-.148-.894c-.071-.424-.384-.764-.781-.93-.398-.164-.854-.142-1.204.108l-.738.527c-.447.32-1.06.269-1.45-.12l-.773-.774a1.125 1.125 0 0 1-.12-1.45l.527-.737c.25-.35.272-.806.108-1.204-.165-.397-.506-.71-.93-.78l-.894-.15c-.542-.09-.94-.56-.94-1.109v-1.094c0-.55.398-1.02.94-1.11l.894-.149c.424-.07.765-.383.93-.78.165-.398.143-.854-.108-1.204l-.526-.738a1.125 1.125 0 0 1 .12-1.45l.773-.773a1.125 1.125 0 0 1 1.45-.12l.737.527c.35.25.807.272 1.204.107.397-.165.71-.505.78-.929l.15-.894Z"}),t.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z"}))});e.s(["f",0,r],1672)},2985,(e,t,r)=>{var a=Object.defineProperty,n=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,s={},l={AccessTokenMissingError:()=>c,RefreshAccessTokenFailedError:()=>d};for(var u in l)a(s,u,{get:l[u],enumerable:!0});t.exports=((e,t,r)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let s of i(t))o.call(e,s)||void 0===s||a(e,s,{get:()=>t[s],enumerable:!(r=n(t,s))||r.enumerable});return e})(a({},"__esModule",{value:!0}),s);class c extends Error{constructor(){super("No authentication found. Please log in with the Vercel CLI (vercel login)."),this.name="AccessTokenMissingError"}}class d extends Error{constructor(e){super("Failed to refresh authentication token.",{cause:e}),this.name="RefreshAccessTokenFailedError"}}},16518,(e,t,r)=>{var a=Object.defineProperty,n=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,s={},l={SYMBOL_FOR_REQ_CONTEXT:()=>c,getContext:()=>d};for(var u in l)a(s,u,{get:l[u],enumerable:!0});t.exports=((e,t,r)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let s of i(t))o.call(e,s)||void 0===s||a(e,s,{get:()=>t[s],enumerable:!(r=n(t,s))||r.enumerable});return e})(a({},"__esModule",{value:!0}),s);let c=Symbol.for("@vercel/request-context");function d(){let e=globalThis;return e[c]?.get?.()??{}}},52897,(e,t,r)=>{var a=Object.defineProperty,n=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,s={},l={AccessTokenMissingError:()=>d.AccessTokenMissingError,RefreshAccessTokenFailedError:()=>d.RefreshAccessTokenFailedError,getContext:()=>c.getContext,getVercelOidcToken:()=>p,getVercelOidcTokenSync:()=>f,getVercelToken:()=>h};for(var u in l)a(s,u,{get:l[u],enumerable:!0});t.exports=((e,t,r)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let s of i(t))o.call(e,s)||void 0===s||a(e,s,{get:()=>t[s],enumerable:!(r=n(t,s))||r.enumerable});return e})(a({},"__esModule",{value:!0}),s);var c=e.r(16518),d=e.r(2985);async function p(){return""}function f(){return""}async function h(){throw Error("getVercelToken is not supported in browser environments")}}],21168,(e,t,r)=>{var a={872:function(e,t){"use strict";t.byteLength=function(e){var t=l(e),r=t[0],a=t[1];return(r+a)*3/4-a},t.toByteArray=function(e){var t,r,i=l(e),o=i[0],s=i[1],u=new n((o+s)*3/4-s),c=0,d=s>0?o-4:o;for(r=0;r<d;r+=4)t=a[e.charCodeAt(r)]<<18|a[e.charCodeAt(r+1)]<<12|a[e.charCodeAt(r+2)]<<6|a[e.charCodeAt(r+3)],u[c++]=t>>16&255,u[c++]=t>>8&255,u[c++]=255&t;return 2===s&&(t=a[e.charCodeAt(r)]<<2|a[e.charCodeAt(r+1)]>>4,u[c++]=255&t),1===s&&(t=a[e.charCodeAt(r)]<<10|a[e.charCodeAt(r+1)]<<4|a[e.charCodeAt(r+2)]>>2,u[c++]=t>>8&255,u[c++]=255&t),u},t.fromByteArray=function(e){for(var t,a=e.length,n=a%3,i=[],o=0,s=a-n;o<s;o+=16383)i.push(function(e,t,a){for(var n,i=[],o=t;o<a;o+=3)n=(e[o]<<16&0xff0000)+(e[o+1]<<8&65280)+(255&e[o+2]),i.push(r[n>>18&63]+r[n>>12&63]+r[n>>6&63]+r[63&n]);return i.join("")}(e,o,o+16383>s?s:o+16383));return 1===n?i.push(r[(t=e[a-1])>>2]+r[t<<4&63]+"=="):2===n&&i.push(r[(t=(e[a-2]<<8)+e[a-1])>>10]+r[t>>4&63]+r[t<<2&63]+"="),i.join("")};for(var r=[],a=[],n="u">typeof Uint8Array?Uint8Array:Array,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=0,s=i.length;o<s;++o)r[o]=i[o],a[i.charCodeAt(o)]=o;function l(e){var t=e.length;if(t%4>0)throw Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");-1===r&&(r=t);var a=r===t?0:4-r%4;return[r,a]}a[45]=62,a[95]=63},230:function(e,t,r){"use strict";var a=r(872),n=r(321),i="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;function o(e){if(e>0x7fffffff)throw RangeError('The value "'+e+'" is invalid for option "size"');var t=new Uint8Array(e);return Object.setPrototypeOf(t,s.prototype),t}function s(e,t,r){if("number"==typeof e){if("string"==typeof t)throw TypeError('The "string" argument must be of type string. Received type number');return c(e)}return l(e,t,r)}function l(e,t,r){if("string"==typeof e){var a=e,n=t;if(("string"!=typeof n||""===n)&&(n="utf8"),!s.isEncoding(n))throw TypeError("Unknown encoding: "+n);var i=0|f(a,n),l=o(i),u=l.write(a,n);return u!==i&&(l=l.slice(0,u)),l}if(ArrayBuffer.isView(e))return d(e);if(null==e)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(O(e,ArrayBuffer)||e&&O(e.buffer,ArrayBuffer)||"u">typeof SharedArrayBuffer&&(O(e,SharedArrayBuffer)||e&&O(e.buffer,SharedArrayBuffer)))return function(e,t,r){var a;if(t<0||e.byteLength<t)throw RangeError('"offset" is outside of buffer bounds');if(e.byteLength<t+(r||0))throw RangeError('"length" is outside of buffer bounds');return Object.setPrototypeOf(a=void 0===t&&void 0===r?new Uint8Array(e):void 0===r?new Uint8Array(e,t):new Uint8Array(e,t,r),s.prototype),a}(e,t,r);if("number"==typeof e)throw TypeError('The "value" argument must not be of type number. Received type number');var c=e.valueOf&&e.valueOf();if(null!=c&&c!==e)return s.from(c,t,r);var h=function(e){if(s.isBuffer(e)){var t=0|p(e.length),r=o(t);return 0===r.length||e.copy(r,0,0,t),r}return void 0!==e.length?"number"!=typeof e.length||function(e){return e!=e}(e.length)?o(0):d(e):"Buffer"===e.type&&Array.isArray(e.data)?d(e.data):void 0}(e);if(h)return h;if("u">typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return s.from(e[Symbol.toPrimitive]("string"),t,r);throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}function u(e){if("number"!=typeof e)throw TypeError('"size" argument must be of type number');if(e<0)throw RangeError('The value "'+e+'" is invalid for option "size"')}function c(e){return u(e),o(e<0?0:0|p(e))}function d(e){for(var t=e.length<0?0:0|p(e.length),r=o(t),a=0;a<t;a+=1)r[a]=255&e[a];return r}t.Buffer=s,t.SlowBuffer=function(e){return+e!=e&&(e=0),s.alloc(+e)},t.INSPECT_MAX_BYTES=50,t.kMaxLength=0x7fffffff,s.TYPED_ARRAY_SUPPORT=function(){try{var e=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(e,t),42===e.foo()}catch(e){return!1}}(),!s.TYPED_ARRAY_SUPPORT&&"u">typeof console&&"function"==typeof console.error&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(s.prototype,"parent",{enumerable:!0,get:function(){if(s.isBuffer(this))return this.buffer}}),Object.defineProperty(s.prototype,"offset",{enumerable:!0,get:function(){if(s.isBuffer(this))return this.byteOffset}}),s.poolSize=8192,s.from=function(e,t,r){return l(e,t,r)},Object.setPrototypeOf(s.prototype,Uint8Array.prototype),Object.setPrototypeOf(s,Uint8Array),s.alloc=function(e,t,r){return(u(e),e<=0)?o(e):void 0!==t?"string"==typeof r?o(e).fill(t,r):o(e).fill(t):o(e)},s.allocUnsafe=function(e){return c(e)},s.allocUnsafeSlow=function(e){return c(e)};function p(e){if(e>=0x7fffffff)throw RangeError("Attempt to allocate Buffer larger than maximum size: 0x7fffffff bytes");return 0|e}function f(e,t){if(s.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||O(e,ArrayBuffer))return e.byteLength;if("string"!=typeof e)throw TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);var r=e.length,a=arguments.length>2&&!0===arguments[2];if(!a&&0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return x(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return A(e).length;default:if(n)return a?-1:x(e).length;t=(""+t).toLowerCase(),n=!0}}function h(e,t,r){var n,i,o,s=!1;if((void 0===t||t<0)&&(t=0),t>this.length||((void 0===r||r>this.length)&&(r=this.length),r<=0||(r>>>=0)<=(t>>>=0)))return"";for(e||(e="utf8");;)switch(e){case"hex":return function(e,t,r){var a=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>a)&&(r=a);for(var n="",i=t;i<r;++i)n+=M[e[i]];return n}(this,t,r);case"utf8":case"utf-8":return v(this,t,r);case"ascii":return function(e,t,r){var a="";r=Math.min(e.length,r);for(var n=t;n<r;++n)a+=String.fromCharCode(127&e[n]);return a}(this,t,r);case"latin1":case"binary":return function(e,t,r){var a="";r=Math.min(e.length,r);for(var n=t;n<r;++n)a+=String.fromCharCode(e[n]);return a}(this,t,r);case"base64":return n=this,i=t,o=r,0===i&&o===n.length?a.fromByteArray(n):a.fromByteArray(n.slice(i,o));case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return function(e,t,r){for(var a=e.slice(t,r),n="",i=0;i<a.length;i+=2)n+=String.fromCharCode(a[i]+256*a[i+1]);return n}(this,t,r);default:if(s)throw TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),s=!0}}function m(e,t,r){var a=e[t];e[t]=e[r],e[r]=a}function g(e,t,r,a,n){var i;if(0===e.length)return -1;if("string"==typeof r?(a=r,r=0):r>0x7fffffff?r=0x7fffffff:r<-0x80000000&&(r=-0x80000000),(i=r*=1)!=i&&(r=n?0:e.length-1),r<0&&(r=e.length+r),r>=e.length)if(n)return -1;else r=e.length-1;else if(r<0)if(!n)return -1;else r=0;if("string"==typeof t&&(t=s.from(t,a)),s.isBuffer(t))return 0===t.length?-1:y(e,t,r,a,n);if("number"==typeof t){if(t&=255,"function"==typeof Uint8Array.prototype.indexOf)if(n)return Uint8Array.prototype.indexOf.call(e,t,r);else return Uint8Array.prototype.lastIndexOf.call(e,t,r);return y(e,[t],r,a,n)}throw TypeError("val must be string, number or Buffer")}function y(e,t,r,a,n){var i,o=1,s=e.length,l=t.length;if(void 0!==a&&("ucs2"===(a=String(a).toLowerCase())||"ucs-2"===a||"utf16le"===a||"utf-16le"===a)){if(e.length<2||t.length<2)return -1;o=2,s/=2,l/=2,r/=2}function u(e,t){return 1===o?e[t]:e.readUInt16BE(t*o)}if(n){var c=-1;for(i=r;i<s;i++)if(u(e,i)===u(t,-1===c?0:i-c)){if(-1===c&&(c=i),i-c+1===l)return c*o}else -1!==c&&(i-=i-c),c=-1}else for(r+l>s&&(r=s-l),i=r;i>=0;i--){for(var d=!0,p=0;p<l;p++)if(u(e,i+p)!==u(t,p)){d=!1;break}if(d)return i}return -1}s.isBuffer=function(e){return null!=e&&!0===e._isBuffer&&e!==s.prototype},s.compare=function(e,t){if(O(e,Uint8Array)&&(e=s.from(e,e.offset,e.byteLength)),O(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),!s.isBuffer(e)||!s.isBuffer(t))throw TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;for(var r=e.length,a=t.length,n=0,i=Math.min(r,a);n<i;++n)if(e[n]!==t[n]){r=e[n],a=t[n];break}return r<a?-1:+(a<r)},s.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},s.concat=function(e,t){if(!Array.isArray(e))throw TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return s.alloc(0);if(void 0===t)for(r=0,t=0;r<e.length;++r)t+=e[r].length;var r,a=s.allocUnsafe(t),n=0;for(r=0;r<e.length;++r){var i=e[r];if(O(i,Uint8Array)&&(i=s.from(i)),!s.isBuffer(i))throw TypeError('"list" argument must be an Array of Buffers');i.copy(a,n),n+=i.length}return a},s.byteLength=f,s.prototype._isBuffer=!0,s.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)m(this,t,t+1);return this},s.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)m(this,t,t+3),m(this,t+1,t+2);return this},s.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)m(this,t,t+7),m(this,t+1,t+6),m(this,t+2,t+5),m(this,t+3,t+4);return this},s.prototype.toString=function(){var e=this.length;return 0===e?"":0==arguments.length?v(this,0,e):h.apply(this,arguments)},s.prototype.toLocaleString=s.prototype.toString,s.prototype.equals=function(e){if(!s.isBuffer(e))throw TypeError("Argument must be a Buffer");return this===e||0===s.compare(this,e)},s.prototype.inspect=function(){var e="",r=t.INSPECT_MAX_BYTES;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"},i&&(s.prototype[i]=s.prototype.inspect),s.prototype.compare=function(e,t,r,a,n){if(O(e,Uint8Array)&&(e=s.from(e,e.offset,e.byteLength)),!s.isBuffer(e))throw TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===a&&(a=0),void 0===n&&(n=this.length),t<0||r>e.length||a<0||n>this.length)throw RangeError("out of range index");if(a>=n&&t>=r)return 0;if(a>=n)return -1;if(t>=r)return 1;if(t>>>=0,r>>>=0,a>>>=0,n>>>=0,this===e)return 0;for(var i=n-a,o=r-t,l=Math.min(i,o),u=this.slice(a,n),c=e.slice(t,r),d=0;d<l;++d)if(u[d]!==c[d]){i=u[d],o=c[d];break}return i<o?-1:+(o<i)},s.prototype.includes=function(e,t,r){return -1!==this.indexOf(e,t,r)},s.prototype.indexOf=function(e,t,r){return g(this,e,t,r,!0)},s.prototype.lastIndexOf=function(e,t,r){return g(this,e,t,r,!1)};function v(e,t,r){r=Math.min(e.length,r);for(var a=[],n=t;n<r;){var i,o,s,l,u=e[n],c=null,d=u>239?4:u>223?3:u>191?2:1;if(n+d<=r)switch(d){case 1:u<128&&(c=u);break;case 2:(192&(i=e[n+1]))==128&&(l=(31&u)<<6|63&i)>127&&(c=l);break;case 3:i=e[n+1],o=e[n+2],(192&i)==128&&(192&o)==128&&(l=(15&u)<<12|(63&i)<<6|63&o)>2047&&(l<55296||l>57343)&&(c=l);break;case 4:i=e[n+1],o=e[n+2],s=e[n+3],(192&i)==128&&(192&o)==128&&(192&s)==128&&(l=(15&u)<<18|(63&i)<<12|(63&o)<<6|63&s)>65535&&l<1114112&&(c=l)}null===c?(c=65533,d=1):c>65535&&(c-=65536,a.push(c>>>10&1023|55296),c=56320|1023&c),a.push(c),n+=d}var p=a,f=p.length;if(f<=4096)return String.fromCharCode.apply(String,p);for(var h="",m=0;m<f;)h+=String.fromCharCode.apply(String,p.slice(m,m+=4096));return h}function b(e,t,r){if(e%1!=0||e<0)throw RangeError("offset is not uint");if(e+t>r)throw RangeError("Trying to access beyond buffer length")}function w(e,t,r,a,n,i){if(!s.isBuffer(e))throw TypeError('"buffer" argument must be a Buffer instance');if(t>n||t<i)throw RangeError('"value" argument is out of bounds');if(r+a>e.length)throw RangeError("Index out of range")}function _(e,t,r,a,n,i){if(r+a>e.length||r<0)throw RangeError("Index out of range")}function k(e,t,r,a,i){return t*=1,r>>>=0,i||_(e,t,r,4,34028234663852886e22,-34028234663852886e22),n.write(e,t,r,a,23,4),r+4}function S(e,t,r,a,i){return t*=1,r>>>=0,i||_(e,t,r,8,17976931348623157e292,-17976931348623157e292),n.write(e,t,r,a,52,8),r+8}s.prototype.write=function(e,t,r,a){if(void 0===t)a="utf8",r=this.length,t=0;else if(void 0===r&&"string"==typeof t)a=t,r=this.length,t=0;else if(isFinite(t))t>>>=0,isFinite(r)?(r>>>=0,void 0===a&&(a="utf8")):(a=r,r=void 0);else throw Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var n,i,o,s,l,u,c,d,p=this.length-t;if((void 0===r||r>p)&&(r=p),e.length>0&&(r<0||t<0)||t>this.length)throw RangeError("Attempt to write outside buffer bounds");a||(a="utf8");for(var f=!1;;)switch(a){case"hex":return function(e,t,r,a){r=Number(r)||0;var n=e.length-r;a?(a=Number(a))>n&&(a=n):a=n;var i=t.length;a>i/2&&(a=i/2);for(var o=0;o<a;++o){var s,l=parseInt(t.substr(2*o,2),16);if((s=l)!=s)break;e[r+o]=l}return o}(this,e,t,r);case"utf8":case"utf-8":return n=t,i=r,T(x(e,this.length-n),this,n,i);case"ascii":return o=t,s=r,T(I(e),this,o,s);case"latin1":case"binary":return function(e,t,r,a){return T(I(t),e,r,a)}(this,e,t,r);case"base64":return l=t,u=r,T(A(e),this,l,u);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return c=t,d=r,T(function(e,t){for(var r,a,n=[],i=0;i<e.length&&!((t-=2)<0);++i)a=(r=e.charCodeAt(i))>>8,n.push(r%256),n.push(a);return n}(e,this.length-c),this,c,d);default:if(f)throw TypeError("Unknown encoding: "+a);a=(""+a).toLowerCase(),f=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},s.prototype.slice=function(e,t){var r=this.length;e=~~e,t=void 0===t?r:~~t,e<0?(e+=r)<0&&(e=0):e>r&&(e=r),t<0?(t+=r)<0&&(t=0):t>r&&(t=r),t<e&&(t=e);var a=this.subarray(e,t);return Object.setPrototypeOf(a,s.prototype),a},s.prototype.readUIntLE=function(e,t,r){e>>>=0,t>>>=0,r||b(e,t,this.length);for(var a=this[e],n=1,i=0;++i<t&&(n*=256);)a+=this[e+i]*n;return a},s.prototype.readUIntBE=function(e,t,r){e>>>=0,t>>>=0,r||b(e,t,this.length);for(var a=this[e+--t],n=1;t>0&&(n*=256);)a+=this[e+--t]*n;return a},s.prototype.readUInt8=function(e,t){return e>>>=0,t||b(e,1,this.length),this[e]},s.prototype.readUInt16LE=function(e,t){return e>>>=0,t||b(e,2,this.length),this[e]|this[e+1]<<8},s.prototype.readUInt16BE=function(e,t){return e>>>=0,t||b(e,2,this.length),this[e]<<8|this[e+1]},s.prototype.readUInt32LE=function(e,t){return e>>>=0,t||b(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+0x1000000*this[e+3]},s.prototype.readUInt32BE=function(e,t){return e>>>=0,t||b(e,4,this.length),0x1000000*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},s.prototype.readIntLE=function(e,t,r){e>>>=0,t>>>=0,r||b(e,t,this.length);for(var a=this[e],n=1,i=0;++i<t&&(n*=256);)a+=this[e+i]*n;return a>=(n*=128)&&(a-=Math.pow(2,8*t)),a},s.prototype.readIntBE=function(e,t,r){e>>>=0,t>>>=0,r||b(e,t,this.length);for(var a=t,n=1,i=this[e+--a];a>0&&(n*=256);)i+=this[e+--a]*n;return i>=(n*=128)&&(i-=Math.pow(2,8*t)),i},s.prototype.readInt8=function(e,t){return(e>>>=0,t||b(e,1,this.length),128&this[e])?-((255-this[e]+1)*1):this[e]},s.prototype.readInt16LE=function(e,t){e>>>=0,t||b(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?0xffff0000|r:r},s.prototype.readInt16BE=function(e,t){e>>>=0,t||b(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?0xffff0000|r:r},s.prototype.readInt32LE=function(e,t){return e>>>=0,t||b(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},s.prototype.readInt32BE=function(e,t){return e>>>=0,t||b(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},s.prototype.readFloatLE=function(e,t){return e>>>=0,t||b(e,4,this.length),n.read(this,e,!0,23,4)},s.prototype.readFloatBE=function(e,t){return e>>>=0,t||b(e,4,this.length),n.read(this,e,!1,23,4)},s.prototype.readDoubleLE=function(e,t){return e>>>=0,t||b(e,8,this.length),n.read(this,e,!0,52,8)},s.prototype.readDoubleBE=function(e,t){return e>>>=0,t||b(e,8,this.length),n.read(this,e,!1,52,8)},s.prototype.writeUIntLE=function(e,t,r,a){if(e*=1,t>>>=0,r>>>=0,!a){var n=Math.pow(2,8*r)-1;w(this,e,t,r,n,0)}var i=1,o=0;for(this[t]=255&e;++o<r&&(i*=256);)this[t+o]=e/i&255;return t+r},s.prototype.writeUIntBE=function(e,t,r,a){if(e*=1,t>>>=0,r>>>=0,!a){var n=Math.pow(2,8*r)-1;w(this,e,t,r,n,0)}var i=r-1,o=1;for(this[t+i]=255&e;--i>=0&&(o*=256);)this[t+i]=e/o&255;return t+r},s.prototype.writeUInt8=function(e,t,r){return e*=1,t>>>=0,r||w(this,e,t,1,255,0),this[t]=255&e,t+1},s.prototype.writeUInt16LE=function(e,t,r){return e*=1,t>>>=0,r||w(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},s.prototype.writeUInt16BE=function(e,t,r){return e*=1,t>>>=0,r||w(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},s.prototype.writeUInt32LE=function(e,t,r){return e*=1,t>>>=0,r||w(this,e,t,4,0xffffffff,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},s.prototype.writeUInt32BE=function(e,t,r){return e*=1,t>>>=0,r||w(this,e,t,4,0xffffffff,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},s.prototype.writeIntLE=function(e,t,r,a){if(e*=1,t>>>=0,!a){var n=Math.pow(2,8*r-1);w(this,e,t,r,n-1,-n)}var i=0,o=1,s=0;for(this[t]=255&e;++i<r&&(o*=256);)e<0&&0===s&&0!==this[t+i-1]&&(s=1),this[t+i]=(e/o|0)-s&255;return t+r},s.prototype.writeIntBE=function(e,t,r,a){if(e*=1,t>>>=0,!a){var n=Math.pow(2,8*r-1);w(this,e,t,r,n-1,-n)}var i=r-1,o=1,s=0;for(this[t+i]=255&e;--i>=0&&(o*=256);)e<0&&0===s&&0!==this[t+i+1]&&(s=1),this[t+i]=(e/o|0)-s&255;return t+r},s.prototype.writeInt8=function(e,t,r){return e*=1,t>>>=0,r||w(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},s.prototype.writeInt16LE=function(e,t,r){return e*=1,t>>>=0,r||w(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},s.prototype.writeInt16BE=function(e,t,r){return e*=1,t>>>=0,r||w(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},s.prototype.writeInt32LE=function(e,t,r){return e*=1,t>>>=0,r||w(this,e,t,4,0x7fffffff,-0x80000000),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},s.prototype.writeInt32BE=function(e,t,r){return e*=1,t>>>=0,r||w(this,e,t,4,0x7fffffff,-0x80000000),e<0&&(e=0xffffffff+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},s.prototype.writeFloatLE=function(e,t,r){return k(this,e,t,!0,r)},s.prototype.writeFloatBE=function(e,t,r){return k(this,e,t,!1,r)},s.prototype.writeDoubleLE=function(e,t,r){return S(this,e,t,!0,r)},s.prototype.writeDoubleBE=function(e,t,r){return S(this,e,t,!1,r)},s.prototype.copy=function(e,t,r,a){if(!s.isBuffer(e))throw TypeError("argument should be a Buffer");if(r||(r=0),a||0===a||(a=this.length),t>=e.length&&(t=e.length),t||(t=0),a>0&&a<r&&(a=r),a===r||0===e.length||0===this.length)return 0;if(t<0)throw RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw RangeError("Index out of range");if(a<0)throw RangeError("sourceEnd out of bounds");a>this.length&&(a=this.length),e.length-t<a-r&&(a=e.length-t+r);var n=a-r;if(this===e&&"function"==typeof Uint8Array.prototype.copyWithin)this.copyWithin(t,r,a);else if(this===e&&r<t&&t<a)for(var i=n-1;i>=0;--i)e[i+t]=this[i+r];else Uint8Array.prototype.set.call(e,this.subarray(r,a),t);return n},s.prototype.fill=function(e,t,r,a){if("string"==typeof e){if("string"==typeof t?(a=t,t=0,r=this.length):"string"==typeof r&&(a=r,r=this.length),void 0!==a&&"string"!=typeof a)throw TypeError("encoding must be a string");if("string"==typeof a&&!s.isEncoding(a))throw TypeError("Unknown encoding: "+a);if(1===e.length){var n,i=e.charCodeAt(0);("utf8"===a&&i<128||"latin1"===a)&&(e=i)}}else"number"==typeof e?e&=255:"boolean"==typeof e&&(e=Number(e));if(t<0||this.length<t||this.length<r)throw RangeError("Out of range index");if(r<=t)return this;if(t>>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(n=t;n<r;++n)this[n]=e;else{var o=s.isBuffer(e)?e:s.from(e,a),l=o.length;if(0===l)throw TypeError('The value "'+e+'" is invalid for argument "value"');for(n=0;n<r-t;++n)this[n+t]=o[n%l]}return this};var E=/[^+/0-9A-Za-z-_]/g;function x(e,t){t=t||1/0;for(var r,a=e.length,n=null,i=[],o=0;o<a;++o){if((r=e.charCodeAt(o))>55295&&r<57344){if(!n){if(r>56319||o+1===a){(t-=3)>-1&&i.push(239,191,189);continue}n=r;continue}if(r<56320){(t-=3)>-1&&i.push(239,191,189),n=r;continue}r=(n-55296<<10|r-56320)+65536}else n&&(t-=3)>-1&&i.push(239,191,189);if(n=null,r<128){if((t-=1)<0)break;i.push(r)}else if(r<2048){if((t-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else if(r<1114112){if((t-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}else throw Error("Invalid code point")}return i}function I(e){for(var t=[],r=0;r<e.length;++r)t.push(255&e.charCodeAt(r));return t}function A(e){return a.toByteArray(function(e){if((e=(e=e.split("=")[0]).trim().replace(E,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function T(e,t,r,a){for(var n=0;n<a&&!(n+r>=t.length)&&!(n>=e.length);++n)t[n+r]=e[n];return n}function O(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}var M=function(){for(var e="0123456789abcdef",t=Array(256),r=0;r<16;++r)for(var a=16*r,n=0;n<16;++n)t[a+n]=e[r]+e[n];return t}()},321:function(e,t){t.read=function(e,t,r,a,n){var i,o,s=8*n-a-1,l=(1<<s)-1,u=l>>1,c=-7,d=r?n-1:0,p=r?-1:1,f=e[t+d];for(d+=p,i=f&(1<<-c)-1,f>>=-c,c+=s;c>0;i=256*i+e[t+d],d+=p,c-=8);for(o=i&(1<<-c)-1,i>>=-c,c+=a;c>0;o=256*o+e[t+d],d+=p,c-=8);if(0===i)i=1-u;else{if(i===l)return o?0/0:(f?-1:1)*2e308;o+=Math.pow(2,a),i-=u}return(f?-1:1)*o*Math.pow(2,i-a)},t.write=function(e,t,r,a,n,i){var o,s,l,u=8*i-n-1,c=(1<<u)-1,d=c>>1,p=5960464477539062e-23*(23===n),f=a?0:i-1,h=a?1:-1,m=+(t<0||0===t&&1/t<0);for(isNaN(t=Math.abs(t))||1/0===t?(s=+!!isNaN(t),o=c):(o=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-o))<1&&(o--,l*=2),o+d>=1?t+=p/l:t+=p*Math.pow(2,1-d),t*l>=2&&(o++,l/=2),o+d>=c?(s=0,o=c):o+d>=1?(s=(t*l-1)*Math.pow(2,n),o+=d):(s=t*Math.pow(2,d-1)*Math.pow(2,n),o=0));n>=8;e[r+f]=255&s,f+=h,s/=256,n-=8);for(o=o<<n|s,u+=n;u>0;e[r+f]=255&o,f+=h,o/=256,u-=8);e[r+f-h]|=128*m}}},n={};function i(e){var t=n[e];if(void 0!==t)return t.exports;var r=n[e]={exports:{}},o=!0;try{a[e](r,r.exports,i),o=!1}finally{o&&delete n[e]}return r.exports}i.ab="/ROOT/node_modules/next/dist/compiled/buffer/",t.exports=i(230)},26167,(e,t,r)=>{t.exports=function(e,t){let r;if("function"!=typeof e)throw TypeError(`Expected the first argument to be a \`function\`, got \`${typeof e}\`.`);let a=0;return function(...n){clearTimeout(r);let i=Date.now(),o=t-(i-a);o<=0?(a=i,e.apply(this,n)):r=setTimeout(()=>{a=Date.now(),e.apply(this,n)},o)}}}]);