UNPKG

autogram-sdk

Version:
2 lines 100 kB
var AutogramSDK=(()=>{var mn=Object.create;var $e=Object.defineProperty,yn=Object.defineProperties,gn=Object.getOwnPropertyDescriptor,_n=Object.getOwnPropertyDescriptors,vn=Object.getOwnPropertyNames,nr=Object.getOwnPropertySymbols,bn=Object.getPrototypeOf,ar=Object.prototype.hasOwnProperty,xn=Object.prototype.propertyIsEnumerable;var ir=Math.pow,sr=(t,e,r)=>e in t?$e(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,o=(t,e)=>{for(var r in e||(e={}))ar.call(e,r)&&sr(t,r,e[r]);if(nr)for(var r of nr(e))xn.call(e,r)&&sr(t,r,e[r]);return t},y=(t,e)=>yn(t,_n(e));var wn=(t=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(t,{get:(e,r)=>(typeof require!="undefined"?require:e)[r]}):t)(function(t){if(typeof require!="undefined")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var Sn=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),En=(t,e)=>{for(var r in e)$e(t,r,{get:e[r],enumerable:!0})},or=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of vn(e))!ar.call(t,s)&&s!==r&&$e(t,s,{get:()=>e[s],enumerable:!(n=gn(e,s))||n.enumerable});return t};var cr=(t,e,r)=>(r=t!=null?mn(bn(t)):{},or(e||!t||!t.__esModule?$e(r,"default",{value:t,enumerable:!0}):r,t)),Tn=t=>or($e({},"__esModule",{value:!0}),t);var x=(t,e,r)=>new Promise((n,s)=>{var a=l=>{try{c(r.next(l))}catch(h){s(h)}},i=l=>{try{c(r.throw(l))}catch(h){s(h)}},c=l=>l.done?n(l.value):Promise.resolve(l.value).then(a,i);c((r=r.apply(t,e)).next())});var sn=Sn((se,nn)=>{var vt=typeof globalThis!="undefined"&&globalThis||typeof self!="undefined"&&self||typeof global!="undefined"&&global,bt=function(){function t(){this.fetch=!1,this.DOMException=vt.DOMException}return t.prototype=vt,new t}();(function(t){var e=function(r){var n=typeof t!="undefined"&&t||typeof self!="undefined"&&self||typeof n!="undefined"&&n,s={searchParams:"URLSearchParams"in n,iterable:"Symbol"in n&&"iterator"in Symbol,blob:"FileReader"in n&&"Blob"in n&&function(){try{return new Blob,!0}catch(u){return!1}}(),formData:"FormData"in n,arrayBuffer:"ArrayBuffer"in n};function a(u){return u&&DataView.prototype.isPrototypeOf(u)}if(s.arrayBuffer)var i=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],c=ArrayBuffer.isView||function(u){return u&&i.indexOf(Object.prototype.toString.call(u))>-1};function l(u){if(typeof u!="string"&&(u=String(u)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(u)||u==="")throw new TypeError('Invalid character in header field name: "'+u+'"');return u.toLowerCase()}function h(u){return typeof u!="string"&&(u=String(u)),u}function _(u){var f={next:function(){var T=u.shift();return{done:T===void 0,value:T}}};return s.iterable&&(f[Symbol.iterator]=function(){return f}),f}function E(u){this.map={},u instanceof E?u.forEach(function(f,T){this.append(T,f)},this):Array.isArray(u)?u.forEach(function(f){this.append(f[0],f[1])},this):u&&Object.getOwnPropertyNames(u).forEach(function(f){this.append(f,u[f])},this)}E.prototype.append=function(u,f){u=l(u),f=h(f);var T=this.map[u];this.map[u]=T?T+", "+f:f},E.prototype.delete=function(u){delete this.map[l(u)]},E.prototype.get=function(u){return u=l(u),this.has(u)?this.map[u]:null},E.prototype.has=function(u){return this.map.hasOwnProperty(l(u))},E.prototype.set=function(u,f){this.map[l(u)]=h(f)},E.prototype.forEach=function(u,f){for(var T in this.map)this.map.hasOwnProperty(T)&&u.call(f,this.map[T],T,this)},E.prototype.keys=function(){var u=[];return this.forEach(function(f,T){u.push(T)}),_(u)},E.prototype.values=function(){var u=[];return this.forEach(function(f){u.push(f)}),_(u)},E.prototype.entries=function(){var u=[];return this.forEach(function(f,T){u.push([T,f])}),_(u)},s.iterable&&(E.prototype[Symbol.iterator]=E.prototype.entries);function we(u){if(u.bodyUsed)return Promise.reject(new TypeError("Already read"));u.bodyUsed=!0}function Se(u){return new Promise(function(f,T){u.onload=function(){f(u.result)},u.onerror=function(){T(u.error)}})}function an(u){var f=new FileReader,T=Se(f);return f.readAsArrayBuffer(u),T}function on(u){var f=new FileReader,T=Se(f);return f.readAsText(u),T}function cn(u){for(var f=new Uint8Array(u),T=new Array(f.length),R=0;R<f.length;R++)T[R]=String.fromCharCode(f[R]);return T.join("")}function tr(u){if(u.slice)return u.slice(0);var f=new Uint8Array(u.byteLength);return f.set(new Uint8Array(u)),f.buffer}function rr(){return this.bodyUsed=!1,this._initBody=function(u){this.bodyUsed=this.bodyUsed,this._bodyInit=u,u?typeof u=="string"?this._bodyText=u:s.blob&&Blob.prototype.isPrototypeOf(u)?this._bodyBlob=u:s.formData&&FormData.prototype.isPrototypeOf(u)?this._bodyFormData=u:s.searchParams&&URLSearchParams.prototype.isPrototypeOf(u)?this._bodyText=u.toString():s.arrayBuffer&&s.blob&&a(u)?(this._bodyArrayBuffer=tr(u.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):s.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(u)||c(u))?this._bodyArrayBuffer=tr(u):this._bodyText=u=Object.prototype.toString.call(u):this._bodyText="",this.headers.get("content-type")||(typeof u=="string"?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):s.searchParams&&URLSearchParams.prototype.isPrototypeOf(u)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},s.blob&&(this.blob=function(){var u=we(this);if(u)return u;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){if(this._bodyArrayBuffer){var u=we(this);return u||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer))}else return this.blob().then(an)}),this.text=function(){var u=we(this);if(u)return u;if(this._bodyBlob)return on(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(cn(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},s.formData&&(this.formData=function(){return this.text().then(ln)}),this.json=function(){return this.text().then(JSON.parse)},this}var un=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function dn(u){var f=u.toUpperCase();return un.indexOf(f)>-1?f:u}function Y(u,f){if(!(this instanceof Y))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');f=f||{};var T=f.body;if(u instanceof Y){if(u.bodyUsed)throw new TypeError("Already read");this.url=u.url,this.credentials=u.credentials,f.headers||(this.headers=new E(u.headers)),this.method=u.method,this.mode=u.mode,this.signal=u.signal,!T&&u._bodyInit!=null&&(T=u._bodyInit,u.bodyUsed=!0)}else this.url=String(u);if(this.credentials=f.credentials||this.credentials||"same-origin",(f.headers||!this.headers)&&(this.headers=new E(f.headers)),this.method=dn(f.method||this.method||"GET"),this.mode=f.mode||this.mode||null,this.signal=f.signal||this.signal,this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&T)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(T),(this.method==="GET"||this.method==="HEAD")&&(f.cache==="no-store"||f.cache==="no-cache")){var R=/([?&])_=[^&]*/;if(R.test(this.url))this.url=this.url.replace(R,"$1_="+new Date().getTime());else{var I=/\?/;this.url+=(I.test(this.url)?"&":"?")+"_="+new Date().getTime()}}}Y.prototype.clone=function(){return new Y(this,{body:this._bodyInit})};function ln(u){var f=new FormData;return u.trim().split("&").forEach(function(T){if(T){var R=T.split("="),I=R.shift().replace(/\+/g," "),k=R.join("=").replace(/\+/g," ");f.append(decodeURIComponent(I),decodeURIComponent(k))}}),f}function fn(u){var f=new E,T=u.replace(/\r?\n[\t ]+/g," ");return T.split("\r").map(function(R){return R.indexOf(` `)===0?R.substr(1,R.length):R}).forEach(function(R){var I=R.split(":"),k=I.shift().trim();if(k){var Qe=I.join(":").trim();f.append(k,Qe)}}),f}rr.call(Y.prototype);function L(u,f){if(!(this instanceof L))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');f||(f={}),this.type="default",this.status=f.status===void 0?200:f.status,this.ok=this.status>=200&&this.status<300,this.statusText=f.statusText===void 0?"":""+f.statusText,this.headers=new E(f.headers),this.url=f.url||"",this._initBody(u)}rr.call(L.prototype),L.prototype.clone=function(){return new L(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new E(this.headers),url:this.url})},L.error=function(){var u=new L(null,{status:0,statusText:""});return u.type="error",u};var hn=[301,302,303,307,308];L.redirect=function(u,f){if(hn.indexOf(f)===-1)throw new RangeError("Invalid status code");return new L(null,{status:f,headers:{location:u}})},r.DOMException=n.DOMException;try{new r.DOMException}catch(u){r.DOMException=function(f,T){this.message=f,this.name=T;var R=Error(f);this.stack=R.stack},r.DOMException.prototype=Object.create(Error.prototype),r.DOMException.prototype.constructor=r.DOMException}function wt(u,f){return new Promise(function(T,R){var I=new Y(u,f);if(I.signal&&I.signal.aborted)return R(new r.DOMException("Aborted","AbortError"));var k=new XMLHttpRequest;function Qe(){k.abort()}k.onload=function(){var B={status:k.status,statusText:k.statusText,headers:fn(k.getAllResponseHeaders()||"")};B.url="responseURL"in k?k.responseURL:B.headers.get("X-Request-URL");var et="response"in k?k.response:k.responseText;setTimeout(function(){T(new L(et,B))},0)},k.onerror=function(){setTimeout(function(){R(new TypeError("Network request failed"))},0)},k.ontimeout=function(){setTimeout(function(){R(new TypeError("Network request failed"))},0)},k.onabort=function(){setTimeout(function(){R(new r.DOMException("Aborted","AbortError"))},0)};function pn(B){try{return B===""&&n.location.href?n.location.href:B}catch(et){return B}}k.open(I.method,pn(I.url),!0),I.credentials==="include"?k.withCredentials=!0:I.credentials==="omit"&&(k.withCredentials=!1),"responseType"in k&&(s.blob?k.responseType="blob":s.arrayBuffer&&I.headers.get("Content-Type")&&I.headers.get("Content-Type").indexOf("application/octet-stream")!==-1&&(k.responseType="arraybuffer")),f&&typeof f.headers=="object"&&!(f.headers instanceof E)?Object.getOwnPropertyNames(f.headers).forEach(function(B){k.setRequestHeader(B,h(f.headers[B]))}):I.headers.forEach(function(B,et){k.setRequestHeader(et,B)}),I.signal&&(I.signal.addEventListener("abort",Qe),k.onreadystatechange=function(){k.readyState===4&&I.signal.removeEventListener("abort",Qe)}),k.send(typeof I._bodyInit=="undefined"?null:I._bodyInit)})}return wt.polyfill=!0,n.fetch||(n.fetch=wt,n.Headers=E,n.Request=Y,n.Response=L),r.Headers=E,r.Request=Y,r.Response=L,r.fetch=wt,r}({})})(bt);bt.fetch.ponyfill=!0;delete bt.fetch.polyfill;var Me=vt.fetch?vt:bt;se=Me.fetch;se.default=Me.fetch;se.fetch=Me.fetch;se.Headers=Me.Headers;se.Request=Me.Request;se.Response=Me.Response;nn.exports=se});var oa={};En(oa,{AutogramVMobileIntegration:()=>_t,AutogramVMobileSimulation:()=>xt,GetDocumentsResponse:()=>Yt,randomUUID:()=>Qt});var Ee=crypto,tt=t=>t instanceof CryptoKey;var J=new TextEncoder,Ze=new TextDecoder,da=ir(2,32);function ur(...t){let e=t.reduce((s,{length:a})=>s+a,0),r=new Uint8Array(e),n=0;for(let s of t)r.set(s,n),n+=s.length;return r}var An=t=>{let e=t;typeof e=="string"&&(e=J.encode(e));let r=32768,n=[];for(let s=0;s<e.length;s+=r)n.push(String.fromCharCode.apply(null,e.subarray(s,s+r)));return btoa(n.join(""))},rt=t=>An(t).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_"),Cn=t=>{let e=atob(t),r=new Uint8Array(e.length);for(let n=0;n<e.length;n++)r[n]=e.charCodeAt(n);return r},nt=t=>{let e=t;e instanceof Uint8Array&&(e=Ze.decode(e)),e=e.replace(/-/g,"+").replace(/_/g,"/").replace(/\s/g,"");try{return Cn(e)}catch(r){throw new TypeError("The input to be decoded is not correctly encoded.")}};var O=class extends Error{constructor(e,r){var n;super(e,r),this.code="ERR_JOSE_GENERIC",this.name=this.constructor.name,(n=Error.captureStackTrace)==null||n.call(Error,this,this.constructor)}};O.code="ERR_JOSE_GENERIC";var St=class extends O{constructor(e,r,n="unspecified",s="unspecified"){super(e,{cause:{claim:n,reason:s,payload:r}}),this.code="ERR_JWT_CLAIM_VALIDATION_FAILED",this.claim=n,this.reason=s,this.payload=r}};St.code="ERR_JWT_CLAIM_VALIDATION_FAILED";var Et=class extends O{constructor(e,r,n="unspecified",s="unspecified"){super(e,{cause:{claim:n,reason:s,payload:r}}),this.code="ERR_JWT_EXPIRED",this.claim=n,this.reason=s,this.payload=r}};Et.code="ERR_JWT_EXPIRED";var Tt=class extends O{constructor(){super(...arguments),this.code="ERR_JOSE_ALG_NOT_ALLOWED"}};Tt.code="ERR_JOSE_ALG_NOT_ALLOWED";var M=class extends O{constructor(){super(...arguments),this.code="ERR_JOSE_NOT_SUPPORTED"}};M.code="ERR_JOSE_NOT_SUPPORTED";var At=class extends O{constructor(e="decryption operation failed",r){super(e,r),this.code="ERR_JWE_DECRYPTION_FAILED"}};At.code="ERR_JWE_DECRYPTION_FAILED";var Ct=class extends O{constructor(){super(...arguments),this.code="ERR_JWE_INVALID"}};Ct.code="ERR_JWE_INVALID";var z=class extends O{constructor(){super(...arguments),this.code="ERR_JWS_INVALID"}};z.code="ERR_JWS_INVALID";var Le=class extends O{constructor(){super(...arguments),this.code="ERR_JWT_INVALID"}};Le.code="ERR_JWT_INVALID";var kt=class extends O{constructor(){super(...arguments),this.code="ERR_JWK_INVALID"}};kt.code="ERR_JWK_INVALID";var Rt=class extends O{constructor(){super(...arguments),this.code="ERR_JWKS_INVALID"}};Rt.code="ERR_JWKS_INVALID";var It=class extends O{constructor(e="no applicable key found in the JSON Web Key Set",r){super(e,r),this.code="ERR_JWKS_NO_MATCHING_KEY"}};It.code="ERR_JWKS_NO_MATCHING_KEY";var Ot=class extends O{constructor(e="multiple matching keys found in the JSON Web Key Set",r){super(e,r),this.code="ERR_JWKS_MULTIPLE_MATCHING_KEYS"}};Ot.code="ERR_JWKS_MULTIPLE_MATCHING_KEYS";var Pt=class extends O{constructor(e="request timed out",r){super(e,r),this.code="ERR_JWKS_TIMEOUT"}};Pt.code="ERR_JWKS_TIMEOUT";var Dt=class extends O{constructor(e="signature verification failed",r){super(e,r),this.code="ERR_JWS_SIGNATURE_VERIFICATION_FAILED"}};Dt.code="ERR_JWS_SIGNATURE_VERIFICATION_FAILED";function G(t,e="algorithm.name"){return new TypeError(`CryptoKey does not support this operation, its ${e} must be ${t}`)}function st(t,e){return t.name===e}function jt(t){return parseInt(t.name.slice(4),10)}function kn(t){switch(t){case"ES256":return"P-256";case"ES384":return"P-384";case"ES512":return"P-521";default:throw new Error("unreachable")}}function Rn(t,e){if(e.length&&!e.some(r=>t.usages.includes(r))){let r="CryptoKey does not support this operation, its usages must include ";if(e.length>2){let n=e.pop();r+=`one of ${e.join(", ")}, or ${n}.`}else e.length===2?r+=`one of ${e[0]} or ${e[1]}.`:r+=`${e[0]}.`;throw new TypeError(r)}}function dr(t,e,...r){switch(e){case"HS256":case"HS384":case"HS512":{if(!st(t.algorithm,"HMAC"))throw G("HMAC");let n=parseInt(e.slice(2),10);if(jt(t.algorithm.hash)!==n)throw G(`SHA-${n}`,"algorithm.hash");break}case"RS256":case"RS384":case"RS512":{if(!st(t.algorithm,"RSASSA-PKCS1-v1_5"))throw G("RSASSA-PKCS1-v1_5");let n=parseInt(e.slice(2),10);if(jt(t.algorithm.hash)!==n)throw G(`SHA-${n}`,"algorithm.hash");break}case"PS256":case"PS384":case"PS512":{if(!st(t.algorithm,"RSA-PSS"))throw G("RSA-PSS");let n=parseInt(e.slice(2),10);if(jt(t.algorithm.hash)!==n)throw G(`SHA-${n}`,"algorithm.hash");break}case"EdDSA":{if(t.algorithm.name!=="Ed25519"&&t.algorithm.name!=="Ed448")throw G("Ed25519 or Ed448");break}case"ES256":case"ES384":case"ES512":{if(!st(t.algorithm,"ECDSA"))throw G("ECDSA");let n=kn(e);if(t.algorithm.namedCurve!==n)throw G(n,"algorithm.namedCurve");break}default:throw new TypeError("CryptoKey does not support this operation")}Rn(t,r)}function lr(t,e,...r){var n;if(r=r.filter(Boolean),r.length>2){let s=r.pop();t+=`one of type ${r.join(", ")}, or ${s}.`}else r.length===2?t+=`one of type ${r[0]} or ${r[1]}.`:t+=`of type ${r[0]}.`;return e==null?t+=` Received ${e}`:typeof e=="function"&&e.name?t+=` Received function ${e.name}`:typeof e=="object"&&e!=null&&(n=e.constructor)!=null&&n.name&&(t+=` Received an instance of ${e.constructor.name}`),t}var Nt=(t,...e)=>lr("Key must be ",t,...e);function Kt(t,e,...r){return lr(`Key for the ${t} algorithm must be `,e,...r)}var Ut=t=>tt(t)?!0:(t==null?void 0:t[Symbol.toStringTag])==="KeyObject",Te=["CryptoKey"];var In=(...t)=>{let e=t.filter(Boolean);if(e.length===0||e.length===1)return!0;let r;for(let n of e){let s=Object.keys(n);if(!r||r.size===0){r=new Set(s);continue}for(let a of s){if(r.has(a))return!1;r.add(a)}}return!0},fr=In;function On(t){return typeof t=="object"&&t!==null}function We(t){if(!On(t)||Object.prototype.toString.call(t)!=="[object Object]")return!1;if(Object.getPrototypeOf(t)===null)return!0;let e=t;for(;Object.getPrototypeOf(e)!==null;)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e}var hr=(t,e)=>{if(t.startsWith("RS")||t.startsWith("PS")){let{modulusLength:r}=e.algorithm;if(typeof r!="number"||r<2048)throw new TypeError(`${t} requires key modulusLength to be 2048 bits or larger`)}};function ae(t){return We(t)&&typeof t.kty=="string"}function pr(t){return t.kty!=="oct"&&typeof t.d=="string"}function mr(t){return t.kty!=="oct"&&typeof t.d=="undefined"}function yr(t){return ae(t)&&t.kty==="oct"&&typeof t.k=="string"}function Dn(t){let e,r;switch(t.kty){case"RSA":{switch(t.alg){case"PS256":case"PS384":case"PS512":e={name:"RSA-PSS",hash:`SHA-${t.alg.slice(-3)}`},r=t.d?["sign"]:["verify"];break;case"RS256":case"RS384":case"RS512":e={name:"RSASSA-PKCS1-v1_5",hash:`SHA-${t.alg.slice(-3)}`},r=t.d?["sign"]:["verify"];break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":e={name:"RSA-OAEP",hash:`SHA-${parseInt(t.alg.slice(-3),10)||1}`},r=t.d?["decrypt","unwrapKey"]:["encrypt","wrapKey"];break;default:throw new M('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}break}case"EC":{switch(t.alg){case"ES256":e={name:"ECDSA",namedCurve:"P-256"},r=t.d?["sign"]:["verify"];break;case"ES384":e={name:"ECDSA",namedCurve:"P-384"},r=t.d?["sign"]:["verify"];break;case"ES512":e={name:"ECDSA",namedCurve:"P-521"},r=t.d?["sign"]:["verify"];break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":e={name:"ECDH",namedCurve:t.crv},r=t.d?["deriveBits"]:[];break;default:throw new M('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}break}case"OKP":{switch(t.alg){case"EdDSA":e={name:t.crv},r=t.d?["sign"]:["verify"];break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":e={name:t.crv},r=t.d?["deriveBits"]:[];break;default:throw new M('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}break}default:throw new M('Invalid or unsupported JWK "kty" (Key Type) Parameter value')}return{algorithm:e,keyUsages:r}}var jn=t=>x(void 0,null,function*(){var a,i;if(!t.alg)throw new TypeError('"alg" argument is required when "jwk.alg" is not present');let{algorithm:e,keyUsages:r}=Dn(t),n=[e,(a=t.ext)!=null?a:!1,(i=t.key_ops)!=null?i:r],s=o({},t);return delete s.alg,delete s.use,Ee.subtle.importKey("jwk",s,...n)}),gr=jn;var _r=t=>nt(t),Ae,Ce,vr=t=>(t==null?void 0:t[Symbol.toStringTag])==="KeyObject",at=(t,e,r,n,s=!1)=>x(void 0,null,function*(){let a=t.get(e);if(a!=null&&a[n])return a[n];let i=yield gr(y(o({},r),{alg:n}));return s&&Object.freeze(e),a?a[n]=i:t.set(e,{[n]:i}),i}),Nn=(t,e)=>{if(vr(t)){let r=t.export({format:"jwk"});return delete r.d,delete r.dp,delete r.dq,delete r.p,delete r.q,delete r.qi,r.k?_r(r.k):(Ce||(Ce=new WeakMap),at(Ce,t,r,e))}return ae(t)?t.k?nt(t.k):(Ce||(Ce=new WeakMap),at(Ce,t,t,e,!0)):t},Kn=(t,e)=>{if(vr(t)){let r=t.export({format:"jwk"});return r.k?_r(r.k):(Ae||(Ae=new WeakMap),at(Ae,t,r,e))}return ae(t)?t.k?nt(t.k):(Ae||(Ae=new WeakMap),at(Ae,t,t,e,!0)):t},Bt={normalizePublicKey:Nn,normalizePrivateKey:Kn};var ke=t=>t==null?void 0:t[Symbol.toStringTag],Mt=(t,e,r)=>{var n,s;if(e.use!==void 0&&e.use!=="sig")throw new TypeError("Invalid key for this operation, when present its use must be sig");if(e.key_ops!==void 0&&((s=(n=e.key_ops).includes)==null?void 0:s.call(n,r))!==!0)throw new TypeError(`Invalid key for this operation, when present its key_ops must include ${r}`);if(e.alg!==void 0&&e.alg!==t)throw new TypeError(`Invalid key for this operation, when present its alg must be ${t}`);return!0},Un=(t,e,r,n)=>{if(!(e instanceof Uint8Array)){if(n&&ae(e)){if(yr(e)&&Mt(t,e,r))return;throw new TypeError('JSON Web Key for symmetric algorithms must have JWK "kty" (Key Type) equal to "oct" and the JWK "k" (Key Value) present')}if(!Ut(e))throw new TypeError(Kt(t,e,...Te,"Uint8Array",n?"JSON Web Key":null));if(e.type!=="secret")throw new TypeError(`${ke(e)} instances for symmetric algorithms must be of type "secret"`)}},Bn=(t,e,r,n)=>{if(n&&ae(e))switch(r){case"sign":if(pr(e)&&Mt(t,e,r))return;throw new TypeError("JSON Web Key for this operation be a private JWK");case"verify":if(mr(e)&&Mt(t,e,r))return;throw new TypeError("JSON Web Key for this operation be a public JWK")}if(!Ut(e))throw new TypeError(Kt(t,e,...Te,n?"JSON Web Key":null));if(e.type==="secret")throw new TypeError(`${ke(e)} instances for asymmetric algorithms must not be of type "secret"`);if(r==="sign"&&e.type==="public")throw new TypeError(`${ke(e)} instances for asymmetric algorithm signing must be of type "private"`);if(r==="decrypt"&&e.type==="public")throw new TypeError(`${ke(e)} instances for asymmetric algorithm decryption must be of type "private"`);if(e.algorithm&&r==="verify"&&e.type==="private")throw new TypeError(`${ke(e)} instances for asymmetric algorithm verifying must be of type "public"`);if(e.algorithm&&r==="encrypt"&&e.type==="private")throw new TypeError(`${ke(e)} instances for asymmetric algorithm encryption must be of type "public"`)};function br(t,e,r,n){e.startsWith("HS")||e==="dir"||e.startsWith("PBES2")||/^A\d{3}(?:GCM)?KW$/.test(e)?Un(e,r,n,t):Bn(e,r,n,t)}var Na=br.bind(void 0,!1),xr=br.bind(void 0,!0);function Mn(t,e,r,n,s){if(s.crit!==void 0&&(n==null?void 0:n.crit)===void 0)throw new t('"crit" (Critical) Header Parameter MUST be integrity protected');if(!n||n.crit===void 0)return new Set;if(!Array.isArray(n.crit)||n.crit.length===0||n.crit.some(i=>typeof i!="string"||i.length===0))throw new t('"crit" (Critical) Header Parameter MUST be an array of non-empty strings when present');let a;r!==void 0?a=new Map([...Object.entries(r),...e.entries()]):a=e;for(let i of n.crit){if(!a.has(i))throw new M(`Extension Header Parameter "${i}" is not recognized`);if(s[i]===void 0)throw new t(`Extension Header Parameter "${i}" is missing`);if(a.get(i)&&n[i]===void 0)throw new t(`Extension Header Parameter "${i}" MUST be integrity protected`)}return new Set(n.crit)}var wr=Mn;function $t(t,e){let r=`SHA-${t.slice(-3)}`;switch(t){case"HS256":case"HS384":case"HS512":return{hash:r,name:"HMAC"};case"PS256":case"PS384":case"PS512":return{hash:r,name:"RSA-PSS",saltLength:t.slice(-3)>>3};case"RS256":case"RS384":case"RS512":return{hash:r,name:"RSASSA-PKCS1-v1_5"};case"ES256":case"ES384":case"ES512":return{hash:r,name:"ECDSA",namedCurve:e.namedCurve};case"EdDSA":return{name:e.name};default:throw new M(`alg ${t} is not supported either by JOSE or your javascript runtime`)}}function Zt(t,e,r){return x(this,null,function*(){if(r==="sign"&&(e=yield Bt.normalizePrivateKey(e,t)),r==="verify"&&(e=yield Bt.normalizePublicKey(e,t)),tt(e))return dr(e,t,r),e;if(e instanceof Uint8Array){if(!t.startsWith("HS"))throw new TypeError(Nt(e,...Te));return Ee.subtle.importKey("raw",e,{hash:`SHA-${t.slice(-3)}`,name:"HMAC"},!1,[r])}throw new TypeError(Nt(e,...Te,"Uint8Array","JSON Web Key"))})}var Q=t=>Math.floor(t.getTime()/1e3);var $n=/^(\+|\-)? ?(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)(?: (ago|from now))?$/i,it=t=>{let e=$n.exec(t);if(!e||e[4]&&e[1])throw new TypeError("Invalid time period format");let r=parseFloat(e[2]),n=e[3].toLowerCase(),s;switch(n){case"sec":case"secs":case"second":case"seconds":case"s":s=Math.round(r);break;case"minute":case"minutes":case"min":case"mins":case"m":s=Math.round(r*60);break;case"hour":case"hours":case"hr":case"hrs":case"h":s=Math.round(r*3600);break;case"day":case"days":case"d":s=Math.round(r*86400);break;case"week":case"weeks":case"w":s=Math.round(r*604800);break;default:s=Math.round(r*31557600);break}return e[1]==="-"||e[4]==="ago"?-s:s};var Zn=(t,e,r)=>x(void 0,null,function*(){let n=yield Zt(t,e,"sign");hr(t,n);let s=yield Ee.subtle.sign($t(t,n.algorithm),n,r);return new Uint8Array(s)}),Sr=Zn;var ot=class{constructor(e){if(!(e instanceof Uint8Array))throw new TypeError("payload must be an instance of Uint8Array");this._payload=e}setProtectedHeader(e){if(this._protectedHeader)throw new TypeError("setProtectedHeader can only be called once");return this._protectedHeader=e,this}setUnprotectedHeader(e){if(this._unprotectedHeader)throw new TypeError("setUnprotectedHeader can only be called once");return this._unprotectedHeader=e,this}sign(e,r){return x(this,null,function*(){if(!this._protectedHeader&&!this._unprotectedHeader)throw new z("either setProtectedHeader or setUnprotectedHeader must be called before #sign()");if(!fr(this._protectedHeader,this._unprotectedHeader))throw new z("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");let n=o(o({},this._protectedHeader),this._unprotectedHeader),s=wr(z,new Map([["b64",!0]]),r==null?void 0:r.crit,this._protectedHeader,n),a=!0;if(s.has("b64")&&(a=this._protectedHeader.b64,typeof a!="boolean"))throw new z('The "b64" (base64url-encode payload) Header Parameter must be a boolean');let{alg:i}=n;if(typeof i!="string"||!i)throw new z('JWS "alg" (Algorithm) Header Parameter missing or invalid');xr(i,e,"sign");let c=this._payload;a&&(c=J.encode(rt(c)));let l;this._protectedHeader?l=J.encode(rt(JSON.stringify(this._protectedHeader))):l=J.encode("");let h=ur(l,J.encode("."),c),_=yield Sr(i,e,h),E={signature:rt(_),payload:""};return a&&(E.payload=Ze.decode(c)),this._unprotectedHeader&&(E.header=this._unprotectedHeader),this._protectedHeader&&(E.protected=Ze.decode(l)),E})}};var ct=class{constructor(e){this._flattened=new ot(e)}setProtectedHeader(e){return this._flattened.setProtectedHeader(e),this}sign(e,r){return x(this,null,function*(){let n=yield this._flattened.sign(e,r);if(n.payload===void 0)throw new TypeError("use the flattened module for creating JWS with b64: false");return`${n.protected}.${n.payload}.${n.signature}`})}};function ie(t,e){if(!Number.isFinite(e))throw new TypeError(`Invalid ${t} input`);return e}var ut=class{constructor(e={}){if(!We(e))throw new TypeError("JWT Claims Set MUST be an object");this._payload=e}setIssuer(e){return this._payload=y(o({},this._payload),{iss:e}),this}setSubject(e){return this._payload=y(o({},this._payload),{sub:e}),this}setAudience(e){return this._payload=y(o({},this._payload),{aud:e}),this}setJti(e){return this._payload=y(o({},this._payload),{jti:e}),this}setNotBefore(e){return typeof e=="number"?this._payload=y(o({},this._payload),{nbf:ie("setNotBefore",e)}):e instanceof Date?this._payload=y(o({},this._payload),{nbf:ie("setNotBefore",Q(e))}):this._payload=y(o({},this._payload),{nbf:Q(new Date)+it(e)}),this}setExpirationTime(e){return typeof e=="number"?this._payload=y(o({},this._payload),{exp:ie("setExpirationTime",e)}):e instanceof Date?this._payload=y(o({},this._payload),{exp:ie("setExpirationTime",Q(e))}):this._payload=y(o({},this._payload),{exp:Q(new Date)+it(e)}),this}setIssuedAt(e){return typeof e=="undefined"?this._payload=y(o({},this._payload),{iat:Q(new Date)}):e instanceof Date?this._payload=y(o({},this._payload),{iat:ie("setIssuedAt",Q(e))}):typeof e=="string"?this._payload=y(o({},this._payload),{iat:ie("setIssuedAt",Q(new Date)+it(e))}):this._payload=y(o({},this._payload),{iat:ie("setIssuedAt",e)}),this}};var Ve=class extends ut{setProtectedHeader(e){return this._protectedHeader=e,this}sign(e,r){return x(this,null,function*(){var s;let n=new ct(J.encode(JSON.stringify(this._payload)));if(n.setProtectedHeader(this._protectedHeader),Array.isArray((s=this._protectedHeader)==null?void 0:s.crit)&&this._protectedHeader.crit.includes("b64")&&this._protectedHeader.b64===!1)throw new Le("JWTs MUST NOT use unencoded payload");return n.sign(e,r)})}};var C;(function(t){t.assertEqual=s=>s;function e(s){}t.assertIs=e;function r(s){throw new Error}t.assertNever=r,t.arrayToEnum=s=>{let a={};for(let i of s)a[i]=i;return a},t.getValidEnumValues=s=>{let a=t.objectKeys(s).filter(c=>typeof s[s[c]]!="number"),i={};for(let c of a)i[c]=s[c];return t.objectValues(i)},t.objectValues=s=>t.objectKeys(s).map(function(a){return s[a]}),t.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{let a=[];for(let i in s)Object.prototype.hasOwnProperty.call(s,i)&&a.push(i);return a},t.find=(s,a)=>{for(let i of s)if(a(i))return i},t.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&isFinite(s)&&Math.floor(s)===s;function n(s,a=" | "){return s.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}t.joinValues=n,t.jsonStringifyReplacer=(s,a)=>typeof a=="bigint"?a.toString():a})(C||(C={}));var Wt;(function(t){t.mergeShapes=(e,r)=>o(o({},e),r)})(Wt||(Wt={}));var m=C.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),ee=t=>{switch(typeof t){case"undefined":return m.undefined;case"string":return m.string;case"number":return isNaN(t)?m.nan:m.number;case"boolean":return m.boolean;case"function":return m.function;case"bigint":return m.bigint;case"symbol":return m.symbol;case"object":return Array.isArray(t)?m.array:t===null?m.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?m.promise:typeof Map!="undefined"&&t instanceof Map?m.map:typeof Set!="undefined"&&t instanceof Set?m.set:typeof Date!="undefined"&&t instanceof Date?m.date:m.object;default:return m.unknown}},d=C.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),Ln=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),K=class t extends Error{constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};let r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){let r=e||function(a){return a.message},n={_errors:[]},s=a=>{for(let i of a.issues)if(i.code==="invalid_union")i.unionErrors.map(s);else if(i.code==="invalid_return_type")s(i.returnTypeError);else if(i.code==="invalid_arguments")s(i.argumentsError);else if(i.path.length===0)n._errors.push(r(i));else{let c=n,l=0;for(;l<i.path.length;){let h=i.path[l];l===i.path.length-1?(c[h]=c[h]||{_errors:[]},c[h]._errors.push(r(i))):c[h]=c[h]||{_errors:[]},c=c[h],l++}}};return s(this),n}static assert(e){if(!(e instanceof t))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,C.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=r=>r.message){let r={},n=[];for(let s of this.issues)s.path.length>0?(r[s.path[0]]=r[s.path[0]]||[],r[s.path[0]].push(e(s))):n.push(e(s));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}};K.create=t=>new K(t);var Oe=(t,e)=>{let r;switch(t.code){case d.invalid_type:t.received===m.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case d.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,C.jsonStringifyReplacer)}`;break;case d.unrecognized_keys:r=`Unrecognized key(s) in object: ${C.joinValues(t.keys,", ")}`;break;case d.invalid_union:r="Invalid input";break;case d.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${C.joinValues(t.options)}`;break;case d.invalid_enum_value:r=`Invalid enum value. Expected ${C.joinValues(t.options)}, received '${t.received}'`;break;case d.invalid_arguments:r="Invalid function arguments";break;case d.invalid_return_type:r="Invalid function return type";break;case d.invalid_date:r="Invalid date";break;case d.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(r=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?r=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?r=`Invalid input: must end with "${t.validation.endsWith}"`:C.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case d.too_small:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:r="Invalid input";break;case d.too_big:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?r=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:r="Invalid input";break;case d.custom:r="Invalid input";break;case d.invalid_intersection_types:r="Intersection results could not be merged";break;case d.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case d.not_finite:r="Number must be finite";break;default:r=e.defaultError,C.assertNever(t)}return{message:r}},Ar=Oe;function Wn(t){Ar=t}function dt(){return Ar}var lt=t=>{let{data:e,path:r,errorMaps:n,issueData:s}=t,a=[...r,...s.path||[]],i=y(o({},s),{path:a});if(s.message!==void 0)return y(o({},s),{path:a,message:s.message});let c="",l=n.filter(h=>!!h).slice().reverse();for(let h of l)c=h(i,{data:e,defaultError:c}).message;return y(o({},s),{path:a,message:c})},Vn=[];function p(t,e){let r=dt(),n=lt({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===Oe?void 0:Oe].filter(s=>!!s)});t.common.issues.push(n)}var D=class t{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,r){let n=[];for(let s of r){if(s.status==="aborted")return b;s.status==="dirty"&&e.dirty(),n.push(s.value)}return{status:e.value,value:n}}static mergeObjectAsync(e,r){return x(this,null,function*(){let n=[];for(let s of r){let a=yield s.key,i=yield s.value;n.push({key:a,value:i})}return t.mergeObjectSync(e,n)})}static mergeObjectSync(e,r){let n={};for(let s of r){let{key:a,value:i}=s;if(a.status==="aborted"||i.status==="aborted")return b;a.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof i.value!="undefined"||s.alwaysSet)&&(n[a.value]=i.value)}return{status:e.value,value:n}}},b=Object.freeze({status:"aborted"}),Ie=t=>({status:"dirty",value:t}),j=t=>({status:"valid",value:t}),Vt=t=>t.status==="aborted",Ht=t=>t.status==="dirty",ze=t=>t.status==="valid",Ge=t=>typeof Promise!="undefined"&&t instanceof Promise;function ft(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)}function Cr(t,e,r,n,s){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r}var g;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(g||(g={}));var He,Je,Z=class{constructor(e,r,n,s){this._cachedPath=[],this.parent=e,this.data=r,this._path=n,this._key=s}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},Er=(t,e)=>{if(ze(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let r=new K(t.common.issues);return this._error=r,this._error}}};function w(t){if(!t)return{};let{errorMap:e,invalid_type_error:r,required_error:n,description:s}=t;if(e&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(i,c)=>{var l,h;let{message:_}=t;return i.code==="invalid_enum_value"?{message:_!=null?_:c.defaultError}:typeof c.data=="undefined"?{message:(l=_!=null?_:n)!==null&&l!==void 0?l:c.defaultError}:i.code!=="invalid_type"?{message:c.defaultError}:{message:(h=_!=null?_:r)!==null&&h!==void 0?h:c.defaultError}},description:s}}var S=class{constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(e){return ee(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:ee(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new D,ctx:{common:e.parent.common,data:e.data,parsedType:ee(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let r=this._parse(e);if(Ge(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(e){let r=this._parse(e);return Promise.resolve(r)}parse(e,r){let n=this.safeParse(e,r);if(n.success)return n.data;throw n.error}safeParse(e,r){var n;let s={common:{issues:[],async:(n=r==null?void 0:r.async)!==null&&n!==void 0?n:!1,contextualErrorMap:r==null?void 0:r.errorMap},path:(r==null?void 0:r.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ee(e)},a=this._parseSync({data:e,path:s.path,parent:s});return Er(s,a)}parseAsync(e,r){return x(this,null,function*(){let n=yield this.safeParseAsync(e,r);if(n.success)return n.data;throw n.error})}safeParseAsync(e,r){return x(this,null,function*(){let n={common:{issues:[],contextualErrorMap:r==null?void 0:r.errorMap,async:!0},path:(r==null?void 0:r.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ee(e)},s=this._parse({data:e,path:n.path,parent:n}),a=yield Ge(s)?s:Promise.resolve(s);return Er(n,a)})}refine(e,r){let n=s=>typeof r=="string"||typeof r=="undefined"?{message:r}:typeof r=="function"?r(s):r;return this._refinement((s,a)=>{let i=e(s),c=()=>a.addIssue(o({code:d.custom},n(s)));return typeof Promise!="undefined"&&i instanceof Promise?i.then(l=>l?!0:(c(),!1)):i?!0:(c(),!1)})}refinement(e,r){return this._refinement((n,s)=>e(n)?!0:(s.addIssue(typeof r=="function"?r(n,s):r),!1))}_refinement(e){return new U({schema:this,typeName:v.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return $.create(this,this._def)}nullable(){return H.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return X.create(this,this._def)}promise(){return ne.create(this,this._def)}or(e){return he.create([this,e],this._def)}and(e){return pe.create(this,e,this._def)}transform(e){return new U(y(o({},w(this._def)),{schema:this,typeName:v.ZodEffects,effect:{type:"transform",transform:e}}))}default(e){let r=typeof e=="function"?e:()=>e;return new ve(y(o({},w(this._def)),{innerType:this,defaultValue:r,typeName:v.ZodDefault}))}brand(){return new qe(o({typeName:v.ZodBranded,type:this},w(this._def)))}catch(e){let r=typeof e=="function"?e:()=>e;return new be(y(o({},w(this._def)),{innerType:this,catchValue:r,typeName:v.ZodCatch}))}describe(e){let r=this.constructor;return new r(y(o({},this._def),{description:e}))}pipe(e){return Fe.create(this,e)}readonly(){return xe.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},Hn=/^c[^\s-]{8,}$/i,Jn=/^[0-9a-z]+$/,zn=/^[0-9A-HJKMNP-TV-Z]{26}$/,Gn=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,qn=/^[a-z0-9_-]{21}$/i,Fn=/^[-+]?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)?)??$/,Xn=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Yn="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",Lt,Qn=/^(?:(?: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])$/,es=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ts=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,kr="((\\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])))",rs=new RegExp(`^${kr}$`);function Rr(t){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`),e}function ns(t){return new RegExp(`^${Rr(t)}$`)}function Ir(t){let e=`${kr}T${Rr(t)}`,r=[];return r.push(t.local?"Z?":"Z"),t.offset&&r.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${r.join("|")})`,new RegExp(`^${e}$`)}function ss(t,e){return!!((e==="v4"||!e)&&Qn.test(t)||(e==="v6"||!e)&&es.test(t))}var te=class t extends S{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==m.string){let a=this._getOrReturnCtx(e);return p(a,{code:d.invalid_type,expected:m.string,received:a.parsedType}),b}let n=new D,s;for(let a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(s=this._getOrReturnCtx(e,s),p(s,{code:d.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="max")e.data.length>a.value&&(s=this._getOrReturnCtx(e,s),p(s,{code:d.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="length"){let i=e.data.length>a.value,c=e.data.length<a.value;(i||c)&&(s=this._getOrReturnCtx(e,s),i?p(s,{code:d.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):c&&p(s,{code:d.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),n.dirty())}else if(a.kind==="email")Xn.test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"email",code:d.invalid_string,message:a.message}),n.dirty());else if(a.kind==="emoji")Lt||(Lt=new RegExp(Yn,"u")),Lt.test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"emoji",code:d.invalid_string,message:a.message}),n.dirty());else if(a.kind==="uuid")Gn.test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"uuid",code:d.invalid_string,message:a.message}),n.dirty());else if(a.kind==="nanoid")qn.test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"nanoid",code:d.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid")Hn.test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"cuid",code:d.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid2")Jn.test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"cuid2",code:d.invalid_string,message:a.message}),n.dirty());else if(a.kind==="ulid")zn.test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"ulid",code:d.invalid_string,message:a.message}),n.dirty());else if(a.kind==="url")try{new URL(e.data)}catch(i){s=this._getOrReturnCtx(e,s),p(s,{validation:"url",code:d.invalid_string,message:a.message}),n.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"regex",code:d.invalid_string,message:a.message}),n.dirty())):a.kind==="trim"?e.data=e.data.trim():a.kind==="includes"?e.data.includes(a.value,a.position)||(s=this._getOrReturnCtx(e,s),p(s,{code:d.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),n.dirty()):a.kind==="toLowerCase"?e.data=e.data.toLowerCase():a.kind==="toUpperCase"?e.data=e.data.toUpperCase():a.kind==="startsWith"?e.data.startsWith(a.value)||(s=this._getOrReturnCtx(e,s),p(s,{code:d.invalid_string,validation:{startsWith:a.value},message:a.message}),n.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(s=this._getOrReturnCtx(e,s),p(s,{code:d.invalid_string,validation:{endsWith:a.value},message:a.message}),n.dirty()):a.kind==="datetime"?Ir(a).test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{code:d.invalid_string,validation:"datetime",message:a.message}),n.dirty()):a.kind==="date"?rs.test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{code:d.invalid_string,validation:"date",message:a.message}),n.dirty()):a.kind==="time"?ns(a).test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{code:d.invalid_string,validation:"time",message:a.message}),n.dirty()):a.kind==="duration"?Fn.test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"duration",code:d.invalid_string,message:a.message}),n.dirty()):a.kind==="ip"?ss(e.data,a.version)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"ip",code:d.invalid_string,message:a.message}),n.dirty()):a.kind==="base64"?ts.test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"base64",code:d.invalid_string,message:a.message}),n.dirty()):C.assertNever(a);return{status:n.value,value:e.data}}_regex(e,r,n){return this.refinement(s=>e.test(s),o({validation:r,code:d.invalid_string},g.errToObj(n)))}_addCheck(e){return new t(y(o({},this._def),{checks:[...this._def.checks,e]}))}email(e){return this._addCheck(o({kind:"email"},g.errToObj(e)))}url(e){return this._addCheck(o({kind:"url"},g.errToObj(e)))}emoji(e){return this._addCheck(o({kind:"emoji"},g.errToObj(e)))}uuid(e){return this._addCheck(o({kind:"uuid"},g.errToObj(e)))}nanoid(e){return this._addCheck(o({kind:"nanoid"},g.errToObj(e)))}cuid(e){return this._addCheck(o({kind:"cuid"},g.errToObj(e)))}cuid2(e){return this._addCheck(o({kind:"cuid2"},g.errToObj(e)))}ulid(e){return this._addCheck(o({kind:"ulid"},g.errToObj(e)))}base64(e){return this._addCheck(o({kind:"base64"},g.errToObj(e)))}ip(e){return this._addCheck(o({kind:"ip"},g.errToObj(e)))}datetime(e){var r,n;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck(o({kind:"datetime",precision:typeof(e==null?void 0:e.precision)=="undefined"?null:e==null?void 0:e.precision,offset:(r=e==null?void 0:e.offset)!==null&&r!==void 0?r:!1,local:(n=e==null?void 0:e.local)!==null&&n!==void 0?n:!1},g.errToObj(e==null?void 0:e.message)))}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck(o({kind:"time",precision:typeof(e==null?void 0:e.precision)=="undefined"?null:e==null?void 0:e.precision},g.errToObj(e==null?void 0:e.message)))}duration(e){return this._addCheck(o({kind:"duration"},g.errToObj(e)))}regex(e,r){return this._addCheck(o({kind:"re