-
Notifications
You must be signed in to change notification settings - Fork 1.6k
/
Copy pathmodu.5a0dfedba32b88e5.js
1 lines (1 loc) · 94.3 KB
/
modu.5a0dfedba32b88e5.js
1
"use strict";(("undefined"!=typeof self?self:this).webpackChunk_polkadot_apps=("undefined"!=typeof self?self:this).webpackChunk_polkadot_apps||[]).push([[6510],{49213:(e,t,r)=>{var n=r(48834).Buffer;Object.defineProperty(t,"__esModule",{value:!0});const s=r(23919),a=r(5610),i=r(12643),o=r(36963);t.default=class{constructor(e,t){if(null==e)throw new Error("Transport has not been defined");this.transport=e,this.CLA=t.cla,this.INS=t.ins,this.P1_VALUES=t.p1Values,this.CHUNK_SIZE=t.chunkSize,this.REQUIRED_PATH_LENGTHS=t.acceptedPathLengths}serializePath(e){return(0,s.serializePath)(e,this.REQUIRED_PATH_LENGTHS)}prepareChunks(e,t){const r=this.serializePath(e),n=this.messageToChunks(t);return n.unshift(r),n}messageToChunks(e){const t=[],r=n.from(e);for(let e=0;e<r.length;e+=this.CHUNK_SIZE){const n=Math.min(e+this.CHUNK_SIZE,r.length);t.push(r.subarray(e,n))}return t}async sendGenericChunk(e,t,r,n,s){let o=i.PAYLOAD_TYPE.ADD;1===r&&(o=i.PAYLOAD_TYPE.INIT),r===n&&(o=i.PAYLOAD_TYPE.LAST);const d=[i.LedgerError.NoErrors,i.LedgerError.DataIsInvalid,i.LedgerError.BadKeyHandle],u=await this.transport.send(this.CLA,e,o,t,s,d);return(0,a.processResponse)(u)}async signSendChunk(e,t,r,n){return this.sendGenericChunk(e,0,t,r,n)}async getVersion(){try{const e=await this.transport.send(this.CLA,this.INS.GET_VERSION,0,0),t=(0,a.processResponse)(e);let r,n,s,d;if(5===t.length()||9===t.length())r=0!==t.readBytes(1).readUInt8(),n=t.readBytes(1).readUInt8(),s=t.readBytes(1).readUInt8(),d=t.readBytes(1).readUInt8();else if(8===t.length()||12===t.length())r=0!==t.readBytes(1).readUInt8(),n=t.readBytes(2).readUInt16BE(),s=t.readBytes(2).readUInt16BE(),d=t.readBytes(2).readUInt16BE();else{if(14!==t.length()&&18!==t.length())throw new o.ResponseError(i.LedgerError.TechnicalProblem,"Invalid response length");r=0!==t.readBytes(1).readUInt8(),n=t.readBytes(4).readUInt32BE(),s=t.readBytes(4).readUInt32BE(),d=t.readBytes(4).readUInt32BE()}const u=1===t.readBytes(1).readUInt8();let c="";return t.length()>=4&&(c=t.readBytes(4).readUInt32BE().toString(16).padStart(8,"0")),{testMode:r,major:n,minor:s,patch:d,deviceLocked:u,targetId:c}}catch(e){throw(0,a.processErrorResponse)(e)}}async appInfo(){try{const e=await this.transport.send(i.LEDGER_DASHBOARD_CLA,1,0,0),t=(0,a.processResponse)(e);if(1!==t.readBytes(1).readUInt8())throw new o.ResponseError(i.LedgerError.TechnicalProblem,"Format ID not recognized");const r=t.readBytes(1).readUInt8(),n=t.readBytes(r).toString("ascii"),s=t.readBytes(1).readUInt8(),d=t.readBytes(s).toString("ascii"),u=t.readBytes(1).readUInt8(),c=t.readBytes(u).readUInt8();return{appName:n,appVersion:d,flagLen:u,flagsValue:c,flagRecovery:0!=(1&c),flagSignedMcuCode:0!=(2&c),flagOnboarded:0!=(4&c),flagPINValidated:0!=(128&c)}}catch(e){throw(0,a.processErrorResponse)(e)}}async deviceInfo(){try{const e=await this.transport.send(224,1,0,0,n.from([]),[i.LedgerError.NoErrors,28160]),t=(0,a.processResponse)(e),r=t.readBytes(4).toString("hex"),s=t.readBytes(1).readUInt8(),o=t.readBytes(s).toString(),d=t.readBytes(1).readUInt8(),u=t.readBytes(d).toString("hex"),c=t.readBytes(1).readUInt8();let l=t.readBytes(c);const p=l.indexOf(0);return-1!==p&&(l=l.subarray(0,p)),{targetId:r,seVersion:o,flag:u,mcuVersion:l.toString()}}catch(e){throw(0,a.processErrorResponse)(e)}}}},23919:(e,t,r)=>{var n=r(48834).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.bufferToBip32Path=t.numbersToBip32Path=t.serializePath=void 0;const s=r(12643),a=r(36963);function i(e){if(0===e.length)throw new a.ResponseError(s.LedgerError.GenericError,"The items array cannot be empty.");const t=[];for(let r=0;r<e.length;r++){let n=e[r];if(!Number.isInteger(n)||n<0)throw new a.ResponseError(s.LedgerError.GenericError,"Each item must be a positive integer.");let i=n&~s.HARDENED;n>=s.HARDENED?t.push(`${i}'`):t.push(`${i}`)}return"m/"+t.join("/")}t.serializePath=function(e,t){if("string"!=typeof e)throw new a.ResponseError(s.LedgerError.GenericError,"Path should be a string (e.g \"m/44'/461'/5'/0/3\")");if(!e.startsWith("m/"))throw new a.ResponseError(s.LedgerError.GenericError,'Path should start with "m/" (e.g "m/44\'/461\'/5\'/0/3")');const r=e.split("/");if(r.shift(),t&&t.length>0&&!t.includes(r.length))throw new a.ResponseError(s.LedgerError.GenericError,"Invalid path length. (e.g \"m/44'/5757'/5'/0/3\")");const i=n.alloc(4*r.length);return r.forEach(((e,t)=>{let r=0;e.endsWith("'")&&(r+=s.HARDENED,e=e.slice(0,-1));const n=Number(e);if(Number.isNaN(n))throw new a.ResponseError(s.LedgerError.GenericError,`Invalid path : ${e} is not a number. (e.g "m/44'/461'/5'/0/3")`);if(n>=s.HARDENED)throw new a.ResponseError(s.LedgerError.GenericError,"Incorrect child value (bigger or equal to 0x80000000)");r+=n,i.writeUInt32LE(r,4*t)})),i},t.numbersToBip32Path=i,t.bufferToBip32Path=function(e){if(e.length%4!=0)throw new a.ResponseError(s.LedgerError.GenericError,"The buffer length must be a multiple of 4.");const t=[];for(let r=0;r<e.length;r+=4)t.push(e.readUInt32LE(r));return i(t)}},11821:(e,t,r)=>{var n=r(48834).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.ByteStream=void 0;const s=r(12643),a=r(36963);t.ByteStream=class{constructor(e){this.readOffset=0,this.writeOffset=0,this.internalBuffer=e?n.from(e):n.alloc(0),this.readOffset=0,this.writeOffset=this.internalBuffer.length}appendUint8(e){const t=n.from([e]);this.appendBytes(t)}appendUint16(e){const t=n.alloc(2);t.writeUInt16LE(e,0),this.appendBytes(t)}appendUint32(e){const t=n.alloc(4);t.writeUInt32LE(e,0),this.appendBytes(t)}appendUint64(e){const t=n.alloc(8);t.writeBigUInt64LE(e,0),this.appendBytes(t)}readBytes(e){if(this.readOffset+e>this.internalBuffer.length)throw new a.ResponseError(s.LedgerError.UnknownError,"Attempt to read beyond buffer length");const t=this.internalBuffer.subarray(this.readOffset,this.readOffset+e);return this.readOffset+=e,t}readBytesAt(e,t){if(t+e>this.internalBuffer.length)throw new a.ResponseError(s.LedgerError.UnknownError,"Attempt to read beyond buffer length");return this.internalBuffer.subarray(t,t+e)}appendBytes(e){if(this.writeOffset+e.length>this.internalBuffer.length){const t=n.alloc(this.writeOffset+e.length);this.internalBuffer.copy(t,0,0,this.writeOffset),this.internalBuffer=t}e.copy(this.internalBuffer,this.writeOffset),this.writeOffset+=e.length}insertBytesAt(e,t){if(t>this.internalBuffer.length){const r=n.alloc(t-this.internalBuffer.length,0);this.internalBuffer=n.concat([this.internalBuffer,r,e])}else{const r=this.internalBuffer.subarray(0,t),s=this.internalBuffer.subarray(t);this.internalBuffer=n.concat([r,e,s])}}writeBytesAt(e,t){if(t+e.length>this.internalBuffer.length){const r=n.alloc(t+e.length);this.internalBuffer.copy(r,0,0,t),this.internalBuffer=r}e.copy(this.internalBuffer,t),this.writeOffset=t+e.length}skipBytes(e){if(this.readOffset+e>this.internalBuffer.length)throw new a.ResponseError(s.LedgerError.UnknownError,"Attempt to skip beyond buffer length");this.readOffset+=e}clear(){this.internalBuffer=n.alloc(0),this.readOffset=0,this.writeOffset=0}resetOffset(){this.readOffset=0,this.writeOffset=0}getCompleteBuffer(){return n.from(this.internalBuffer)}getAvailableBuffer(){return n.from(this.internalBuffer.subarray(this.readOffset))}length(){return this.internalBuffer.length-this.readOffset}capacity(){return this.internalBuffer.length}getReadOffset(){return this.readOffset}getWriteOffset(){return this.writeOffset}setReadOffset(e){if(e<0||e>this.internalBuffer.length)throw new a.ResponseError(s.LedgerError.UnknownError,"Invalid read offset");this.readOffset=e}setWriteOffset(e){if(e<0||e>this.internalBuffer.length)throw new a.ResponseError(s.LedgerError.UnknownError,"Invalid write offset");this.writeOffset=e}}},5610:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.processErrorResponse=t.processResponse=void 0;const n=r(12643),s=r(42876),a=r(17224),i=r(36963);t.processResponse=function(e){if(e.length<2)throw i.ResponseError.fromReturnCode(n.LedgerError.EmptyBuffer);const t=e.readUInt16BE(e.length-2);let r=(0,s.errorCodeToString)(t);const o=e.subarray(0,e.length-2);if(t===n.LedgerError.NoErrors)return new a.ResponsePayload(o);throw o.length>0&&(r+=` : ${o.toString("ascii")}`),new i.ResponseError(t,r)},t.processErrorResponse=function(e){if(!("object"!=typeof(t=e)||null===t||t instanceof Array||t instanceof Date)){if(Object.prototype.hasOwnProperty.call(e,"statusCode"))return i.ResponseError.fromReturnCode(e.statusCode);if(Object.prototype.hasOwnProperty.call(e,"returnCode")&&Object.prototype.hasOwnProperty.call(e,"errorMessage"))return e}var t;return i.ResponseError.fromReturnCode(n.LedgerError.UnknownTransportError)}},12643:(e,t)=>{var r;Object.defineProperty(t,"__esModule",{value:!0}),t.ERROR_DESCRIPTION_OVERRIDE=t.LedgerError=t.PAYLOAD_TYPE=t.LEDGER_DASHBOARD_CLA=t.HARDENED=void 0,t.HARDENED=2147483648,t.LEDGER_DASHBOARD_CLA=176,t.PAYLOAD_TYPE={INIT:0,ADD:1,LAST:2},function(e){e[e.U2FUnknown=1]="U2FUnknown",e[e.U2FBadRequest=2]="U2FBadRequest",e[e.U2FConfigurationUnsupported=3]="U2FConfigurationUnsupported",e[e.U2FDeviceIneligible=4]="U2FDeviceIneligible",e[e.U2FTimeout=5]="U2FTimeout",e[e.Timeout=14]="Timeout",e[e.GpAuthFailed=25344]="GpAuthFailed",e[e.PinRemainingAttempts=25536]="PinRemainingAttempts",e[e.ExecutionError=25600]="ExecutionError",e[e.WrongLength=26368]="WrongLength",e[e.IncorrectLength=26368]="IncorrectLength",e[e.MissingCriticalParameter=26624]="MissingCriticalParameter",e[e.ErrorDerivingKeys=26626]="ErrorDerivingKeys",e[e.EmptyBuffer=27010]="EmptyBuffer",e[e.SecurityStatusNotSatisfied=27010]="SecurityStatusNotSatisfied",e[e.OutputBufferTooSmall=27011]="OutputBufferTooSmall",e[e.DataIsInvalid=27012]="DataIsInvalid",e[e.ConditionsOfUseNotSatisfied=27013]="ConditionsOfUseNotSatisfied",e[e.CommandIncompatibleFileStructure=27009]="CommandIncompatibleFileStructure",e[e.TransactionRejected=27014]="TransactionRejected",e[e.BadKeyHandle=27264]="BadKeyHandle",e[e.IncorrectData=27264]="IncorrectData",e[e.ReferencedDataNotFound=27272]="ReferencedDataNotFound",e[e.NotEnoughMemorySpace=27268]="NotEnoughMemorySpace",e[e.FileAlreadyExists=27273]="FileAlreadyExists",e[e.InvalidP1P2=27392]="InvalidP1P2",e[e.IncorrectP1P2=27392]="IncorrectP1P2",e[e.InstructionNotSupported=27904]="InstructionNotSupported",e[e.InsNotSupported=27904]="InsNotSupported",e[e.UnknownApdu=27906]="UnknownApdu",e[e.DeviceNotOnboarded=27911]="DeviceNotOnboarded",e[e.DeviceNotOnboarded2=26129]="DeviceNotOnboarded2",e[e.CustomImageBootloader=26159]="CustomImageBootloader",e[e.CustomImageEmpty=26158]="CustomImageEmpty",e[e.AppDoesNotSeemToBeOpen=28161]="AppDoesNotSeemToBeOpen",e[e.ClaNotSupported=28160]="ClaNotSupported",e[e.Licensing=28482]="Licensing",e[e.UnknownError=28416]="UnknownError",e[e.TechnicalProblem=28416]="TechnicalProblem",e[e.SignVerifyError=28417]="SignVerifyError",e[e.Halted=28586]="Halted",e[e.NoErrors=36864]="NoErrors",e[e.DeviceIsBusy=36865]="DeviceIsBusy",e[e.UnknownTransportError=65535]="UnknownTransportError",e[e.AccessConditionNotFulfilled=38916]="AccessConditionNotFulfilled",e[e.AlgorithmNotSupported=38020]="AlgorithmNotSupported",e[e.CodeBlocked=38976]="CodeBlocked",e[e.CodeNotInitialized=38914]="CodeNotInitialized",e[e.ContradictionInvalidation=38928]="ContradictionInvalidation",e[e.ContradictionSecretCodeStatus=38920]="ContradictionSecretCodeStatus",e[e.InvalidKcv=38021]="InvalidKcv",e[e.InvalidOffset=37890]="InvalidOffset",e[e.LockedDevice=21781]="LockedDevice",e[e.MaxValueReached=38992]="MaxValueReached",e[e.MemoryProblem=37440]="MemoryProblem",e[e.NoEfSelected=37888]="NoEfSelected",e[e.InconsistentFile=37896]="InconsistentFile",e[e.FileNotFound=37892]="FileNotFound",e[e.UserRefusedOnDevice=21761]="UserRefusedOnDevice",e[e.NotEnoughSpace=20738]="NotEnoughSpace",e[e.GenericError=4294967295]="GenericError"}(r||(t.LedgerError=r={})),t.ERROR_DESCRIPTION_OVERRIDE={[r.U2FUnknown]:"U2F: Unknown",[r.U2FBadRequest]:"U2F: Bad request",[r.U2FConfigurationUnsupported]:"U2F: Configuration unsupported",[r.U2FDeviceIneligible]:"U2F: Device Ineligible",[r.U2FTimeout]:"U2F: Timeout",[r.Timeout]:"Timeout",[r.NoErrors]:"No errors",[r.DeviceIsBusy]:"Device is busy",[r.ErrorDerivingKeys]:"Error deriving keys",[r.ExecutionError]:"Execution Error",[r.WrongLength]:"Wrong Length",[r.EmptyBuffer]:"Empty Buffer",[r.OutputBufferTooSmall]:"Output buffer too small",[r.DataIsInvalid]:"Data is invalid",[r.TransactionRejected]:"Transaction rejected",[r.BadKeyHandle]:"Bad key handle",[r.InvalidP1P2]:"Invalid P1/P2",[r.InstructionNotSupported]:"Instruction not supported",[r.AppDoesNotSeemToBeOpen]:"App does not seem to be open",[r.UnknownError]:"Unknown error",[r.SignVerifyError]:"Sign/verify error",[r.UnknownTransportError]:"Unknown transport error",[r.GpAuthFailed]:"GP Authentication Failed",[r.PinRemainingAttempts]:"PIN Remaining Attempts",[r.MissingCriticalParameter]:"Missing Critical Parameter",[r.ConditionsOfUseNotSatisfied]:"Conditions of Use Not Satisfied",[r.CommandIncompatibleFileStructure]:"Command Incompatible with File Structure",[r.ReferencedDataNotFound]:"Referenced Data Not Found",[r.NotEnoughMemorySpace]:"Not Enough Memory Space",[r.FileAlreadyExists]:"File Already Exists",[r.UnknownApdu]:"Unknown APDU",[r.DeviceNotOnboarded]:"Device Not Onboarded",[r.DeviceNotOnboarded2]:"Device Not Onboarded (Secondary)",[r.CustomImageBootloader]:"Custom Image Bootloader Error",[r.CustomImageEmpty]:"Custom Image Empty",[r.ClaNotSupported]:"CLA Not Supported",[r.Licensing]:"Licensing Error",[r.Halted]:"Device Halted",[r.AccessConditionNotFulfilled]:"Access Condition Not Fulfilled",[r.AlgorithmNotSupported]:"Algorithm Not Supported",[r.CodeBlocked]:"Code Blocked",[r.CodeNotInitialized]:"Code Not Initialized",[r.ContradictionInvalidation]:"Contradiction Invalidation",[r.ContradictionSecretCodeStatus]:"Contradiction with Secret Code Status",[r.InvalidKcv]:"Invalid KCV",[r.InvalidOffset]:"Invalid Offset",[r.LockedDevice]:"Device Locked",[r.MaxValueReached]:"Maximum Value Reached",[r.MemoryProblem]:"Memory Problem",[r.NoEfSelected]:"No EF Selected",[r.InconsistentFile]:"Inconsistent File",[r.FileNotFound]:"File Not Found",[r.UserRefusedOnDevice]:"User Refused on Device",[r.NotEnoughSpace]:"Not Enough Space",[r.GenericError]:"Generic Error"}},42876:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.errorCodeToString=void 0;const n=r(12643);t.errorCodeToString=function(e){let t=`Unknown Return Code: 0x${e.toString(16).toUpperCase()}`;return e in n.ERROR_DESCRIPTION_OVERRIDE&&(t=n.ERROR_DESCRIPTION_OVERRIDE[e]),t}},92108:function(e,t,r){var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var s=Object.getOwnPropertyDescriptor(t,r);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,s)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),s=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const i=a(r(49213));t.default=i.default,s(r(5610),t),s(r(12643),t),s(r(48962),t),s(r(23919),t),s(r(36963),t),s(r(17224),t)},17224:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ResponsePayload=void 0;const n=r(11821);class s extends n.ByteStream{constructor(e){super(e)}}t.ResponsePayload=s},36963:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ResponseError=void 0;const n=r(42876);class s extends Error{constructor(e,t){super(t),this.errorMessage=t,this.returnCode=e}static fromReturnCode(e){return new s(e,(0,n.errorCodeToString)(e))}}t.ResponseError=s},48962:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0})},21204:(e,t,r)=>{var n=r(48834).Buffer;function s(e){return e in t.ERROR_DESCRIPTION?t.ERROR_DESCRIPTION[e]:`Unknown Status Code: ${e}`}function a(e){if(null!=e){if(!("object"!=typeof(t=e)||null===t||t instanceof Array||t instanceof Date)){if(Object.prototype.hasOwnProperty.call(e,"returnCode"))return{return_code:e.returnCode,error_message:s(e.returnCode)};if(Object.prototype.hasOwnProperty.call(e,"statusCode"))return{return_code:e.statusCode,error_message:s(e.statusCode)};if(Object.prototype.hasOwnProperty.call(e,"return_code")&&Object.prototype.hasOwnProperty.call(e,"error_message"))return e}return{return_code:65535,error_message:e.toString()}}var t;return{return_code:65535,error_message:e.toString()}}Object.defineProperty(t,"__esModule",{value:!0}),t.ERROR_DESCRIPTION=t.CHUNK_SIZE=void 0,t.errorCodeToString=s,t.processErrorResponse=a,t.getVersion=async function(e,t){try{const r=await e.send(t,0,0,0),n=r.subarray(-2),a=256*n[0]+n[1];if(14!==r.length&&20!==r.length)return{return_code:27012,error_message:s(27012)};let i,o,d,u,c;return 14===r.length?(i=r.readUInt16BE(1),o=r.readUInt16BE(3),d=r.readUInt16BE(5),u=1===r[7],c=(r[8]<<24)+(r[9]<<16)+(r[10]<<8)+(r[11]<<0)):(i=r.readUInt32BE(1),o=r.readUInt32BE(5),d=r.readUInt32BE(9),u=1===r[13],c=(r[14]<<24)+(r[15]<<16)+(r[16]<<8)+(r[17]<<0)),{return_code:a,error_message:s(a),test_mode:0!==r[0],major:i,minor:o,patch:d,deviceLocked:u,target_id:c.toString(16)}}catch(e){return a(e)}},t.serializePath=function(e,t,r,s){if(!Number.isInteger(t))throw new Error("Input must be an integer");if(!Number.isInteger(r))throw new Error("Input must be an integer");if(!Number.isInteger(s))throw new Error("Input must be an integer");const a=n.alloc(20);return a.writeUInt32LE(2147483692,0),a.writeUInt32LE(e,4),a.writeUInt32LE(t,8),a.writeUInt32LE(r,12),a.writeUInt32LE(s,16),a},t.CHUNK_SIZE=250,t.ERROR_DESCRIPTION={1:"U2F: Unknown",2:"U2F: Bad request",3:"U2F: Configuration unsupported",4:"U2F: Device Ineligible",5:"U2F: Timeout",14:"Timeout",36864:"No errors",36865:"Device is busy",26626:"Error deriving keys",25600:"Execution Error",26368:"Wrong Length",27010:"Empty Buffer",27011:"Output buffer too small",27012:"Data is invalid",27013:"Conditions not satisfied",27014:"Transaction rejected",27264:"Bad key handle",27392:"Invalid P1/P2",27904:"Instruction not supported",28161:"App does not seem to be open",28416:"Unknown error",28417:"Sign/verify error"}},65856:function(e,t,r){var n=r(48834).Buffer,s=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var s=Object.getOwnPropertyDescriptor(t,r);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,s)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),a=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),i=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&s(t,e,r);return a(t,e),t},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.PolkadotGenericApp=void 0;const d=o(r(60014)),u=i(r(92108));class c extends u.default{constructor(e,t,r){if(super(e,c._params),this.txMetadataSrvUrl=r,this.txMetadataChainId=t,!this.transport)throw new Error("Transport has not been defined")}async getTxMetadata(e,t,r){const s=t??this.txMetadataChainId,a=r??this.txMetadataSrvUrl;if(!s)throw new u.ResponseError(u.LedgerError.GenericError,"txMetadataSrvUrl is not defined or is empty. The use of the method requires access to a metadata shortening service.");if(!a)throw new u.ResponseError(u.LedgerError.GenericError,"txMetadataChainId is not defined or is empty. These values are configured in the metadata shortening service. Check the corresponding configuration in the service.");let i=(await d.default.post(a,{txBlob:e.toString("hex"),chain:{id:s}})).data.txMetadata;return"0x"===i.slice(0,2)&&(i=i.slice(2)),n.from(i,"hex")}async getAddress(e,t,r=!1){if(!Number.isInteger(t)||t<0||t>>16!=0)throw new u.ResponseError(u.LedgerError.ConditionsOfUseNotSatisfied,`Unexpected ss58prefix ${t}. Needs to be a non-negative integer up to 2^16`);const s=this.serializePath(e),a=n.alloc(2);a.writeUInt16LE(t);const i=n.concat([s,a]),o=r?1:0;try{const e=await this.transport.send(this.CLA,this.INS.GET_ADDR,o,0,i),t=(0,u.processResponse)(e);return{pubKey:t.readBytes(32).toString("hex"),address:t.readBytes(t.length()).toString("ascii")}}catch(e){throw(0,u.processErrorResponse)(e)}}splitBufferToChunks(e,t){const r=[],s=n.from(e);for(let e=0;e<s.length;e+=t){let n=e+t;e>s.length&&(n=s.length),r.push(s.subarray(e,n))}return r}getSignReqChunks(e,t,r){const s=[],a=this.serializePath(e),i=n.alloc(2);return i.writeUInt16LE(t.length),s.push(n.concat([a,i])),null==r?s.push(...this.splitBufferToChunks(t,this.CHUNK_SIZE)):s.push(...this.splitBufferToChunks(n.concat([t,r]),this.CHUNK_SIZE)),s}async signImpl(e,t,r,n){const s=this.getSignReqChunks(e,r,n);try{let e=await this.signSendChunk(t,1,s.length,s[0]);for(let r=1;r<s.length;r+=1)e=await this.signSendChunk(t,1+r,s.length,s[r]);return{signature:e.readBytes(e.length())}}catch(e){throw(0,u.processErrorResponse)(e)}}async sign(e,t){if(!this.txMetadataSrvUrl)throw new u.ResponseError(u.LedgerError.GenericError,"txMetadataSrvUrl is not defined or is empty. The use of the method requires access to a metadata shortening service.");if(!this.txMetadataChainId)throw new u.ResponseError(u.LedgerError.GenericError,"txMetadataChainId is not defined or is empty. These values are configured in the metadata shortening service. Check the corresponding configuration in the service.");const r=await this.getTxMetadata(t);return await this.signImpl(e,this.INS.SIGN,t,r)}async signMigration(e,t,r,n){if(!this.txMetadataSrvUrl)throw new u.ResponseError(u.LedgerError.GenericError,"txMetadataSrvUrl is not defined or is empty. The use of the method requires access to a metadata shortening service.");if(!this.txMetadataChainId)throw new u.ResponseError(u.LedgerError.GenericError,"txMetadataChainId is not defined or is empty. These values are configured in the metadata shortening service. Check the corresponding configuration in the service.");const s=await this.getTxMetadata(t,r,n);return await this.signImpl(e,this.INS.SIGN,t,s)}async signRaw(e,t){return await this.signImpl(e,this.INS.SIGN_RAW,t)}async signWithMetadata(e,t,r){return await this.signImpl(e,this.INS.SIGN,t,r)}}t.PolkadotGenericApp=c,c._INS={GET_VERSION:0,GET_ADDR:1,SIGN:2,SIGN_RAW:3},c._params={cla:249,ins:{...c._INS},p1Values:{ONLY_RETRIEVE:0,SHOW_ADDRESS_IN_DEVICE:1},chunkSize:250,requiredPathLengths:[5]}},7908:(e,t,r)=>{var n=r(48834).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.PolkadotGenericAppLegacy=void 0;const s=r(92108),a=r(65856);t.PolkadotGenericAppLegacy=class{constructor(e,t,r,n){this.genericApp=new a.PolkadotGenericApp(e,r,n),this.ss58prefix=t}convertToLegacyError(e){return{error_message:e.errorMessage,return_code:e.returnCode}}convertLegacyPath(e,t,r){return(0,s.numbersToBip32Path)([2147483692,2147484002,e,t,r])}async getVersion(){try{const e=await this.genericApp.getVersion();return{...this.convertToLegacyError(s.ResponseError.fromReturnCode(s.LedgerError.NoErrors)),major:e.major??0,minor:e.minor??0,patch:e.patch??0,device_locked:e.deviceLocked??!1,test_mode:e.testMode??!1}}catch(e){return{device_locked:!1,major:0,minor:0,patch:0,test_mode:!1,...this.convertToLegacyError(e)}}}async appInfo(){try{const e=await this.genericApp.appInfo();return{...this.convertToLegacyError(s.ResponseError.fromReturnCode(s.LedgerError.NoErrors)),...e}}catch(e){return{...this.convertToLegacyError(e)}}}async getAddress(e,t,r,n,a){if(0!==a)throw s.ResponseError.fromReturnCode(s.LedgerError.AlgorithmNotSupported);try{const a=this.convertLegacyPath(e,t,r),i=await this.genericApp.getAddress(a,this.ss58prefix,n);return{...this.convertToLegacyError(s.ResponseError.fromReturnCode(s.LedgerError.NoErrors)),...i}}catch(e){return{address:"ERROR",pubKey:"ERROR",...this.convertToLegacyError(e)}}}async sign(e,t,r,a,i){try{if(0!==i)throw s.ResponseError.fromReturnCode(s.LedgerError.AlgorithmNotSupported);const n=this.convertLegacyPath(e,t,r),o=await this.genericApp.sign(n,a);return{...this.convertToLegacyError(s.ResponseError.fromReturnCode(s.LedgerError.NoErrors)),...o}}catch(e){const t=this.convertToLegacyError(e);return{signature:n.alloc(0),...t}}}async signRaw(e,t,r,a,i){try{if(0!==i)throw s.ResponseError.fromReturnCode(s.LedgerError.AlgorithmNotSupported);const n=this.convertLegacyPath(e,t,r),o=await this.genericApp.signRaw(n,a);return{...this.convertToLegacyError(s.ResponseError.fromReturnCode(s.LedgerError.NoErrors)),...o}}catch(e){const t=this.convertToLegacyError(e);return{signature:n.alloc(0),...t}}}}},67046:function(e,t,r){var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var s=Object.getOwnPropertyDescriptor(t,r);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,s)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),s=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),t.supportedApps=t.newSubstrateApp=t.SubstrateApp=void 0,s(r(24734),t),s(r(65856),t),s(r(7908),t);var a=r(40631);Object.defineProperty(t,"SubstrateApp",{enumerable:!0,get:function(){return a.SubstrateApp}});var i=r(76662);Object.defineProperty(t,"newSubstrateApp",{enumerable:!0,get:function(){return i.newSubstrateApp}}),Object.defineProperty(t,"supportedApps",{enumerable:!0,get:function(){return i.supportedApps}})},24734:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.newKusamaApp=function(e){return(0,n.newSubstrateApp)(e,"Kusama")},t.newPolkadotApp=function(e){return(0,n.newSubstrateApp)(e,"Polkadot")},t.newPolymeshApp=function(e){return(0,n.newSubstrateApp)(e,"Polymesh")},t.newDockApp=function(e){return(0,n.newSubstrateApp)(e,"Dock")},t.newCentrifugeApp=function(e){return(0,n.newSubstrateApp)(e,"Centrifuge")},t.newEdgewareApp=function(e){return(0,n.newSubstrateApp)(e,"Edgeware")},t.newEquilibriumApp=function(e){return(0,n.newSubstrateApp)(e,"Equilibrium")},t.newGenshiroApp=function(e){return(0,n.newSubstrateApp)(e,"Genshiro")},t.newStatemintApp=function(e){return(0,n.newSubstrateApp)(e,"Statemint")},t.newStatemineApp=function(e){return(0,n.newSubstrateApp)(e,"Statemine")},t.newNodleApp=function(e){return(0,n.newSubstrateApp)(e,"Nodle")},t.newSoraApp=function(e){return(0,n.newSubstrateApp)(e,"Sora")},t.newPolkadexApp=function(e){return(0,n.newSubstrateApp)(e,"Polkadex")},t.newBifrostApp=function(e){return(0,n.newSubstrateApp)(e,"Bifrost")},t.newKaruraApp=function(e){return(0,n.newSubstrateApp)(e,"Karura")},t.newReefApp=function(e){return(0,n.newSubstrateApp)(e,"Reef")},t.newAcalaApp=function(e){return(0,n.newSubstrateApp)(e,"Acala")},t.newXXNetworkApp=function(e){return(0,n.newSubstrateApp)(e,"XXNetwork")},t.newParallelApp=function(e){return(0,n.newSubstrateApp)(e,"Parallel")},t.newAstarApp=function(e){return(0,n.newSubstrateApp)(e,"Astar")},t.newComposableApp=function(e){return(0,n.newSubstrateApp)(e,"Composable")},t.newStafiApp=function(e){return(0,n.newSubstrateApp)(e,"Stafi")},t.newAlephZeroApp=function(e){return(0,n.newSubstrateApp)(e,"AlephZero")},t.newInterlayApp=function(e){return(0,n.newSubstrateApp)(e,"Interlay")},t.newUniqueApp=function(e){return(0,n.newSubstrateApp)(e,"Unique")},t.newBifrostKusamaApp=function(e){return(0,n.newSubstrateApp)(e,"BifrostKusama")};const n=r(76662)},40631:(e,t,r)=>{var n=r(48834).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.SubstrateApp=void 0;const s=r(21204);class a{constructor(e,t,r){if(null==e)throw new Error("Transport has not been defined");this.transport=e,this.cla=t,this.slip0044=r}static serializePath(e,t,r,s){if(!Number.isInteger(t))throw new Error("Input must be an integer");if(!Number.isInteger(r))throw new Error("Input must be an integer");if(!Number.isInteger(s))throw new Error("Input must be an integer");const a=n.alloc(20);return a.writeUInt32LE(2147483692,0),a.writeUInt32LE(e,4),a.writeUInt32LE(t,8),a.writeUInt32LE(r,12),a.writeUInt32LE(s,16),a}static GetChunks(e){const t=[],r=n.from(e);for(let e=0;e<r.length;e+=s.CHUNK_SIZE){let n=e+s.CHUNK_SIZE;e>r.length&&(n=r.length),t.push(r.subarray(e,n))}return t}static signGetChunks(e,t,r,n,s){const i=[],o=a.serializePath(e,t,r,n);return i.push(o),i.push(...a.GetChunks(s)),i}async getVersion(){try{return await(0,s.getVersion)(this.transport,this.cla)}catch(e){return(0,s.processErrorResponse)(e)}}async appInfo(){return await this.transport.send(176,1,0,0).then((e=>{const t=e.subarray(-2),r=256*t[0]+t[1];let n="",a="",i=0,o=0;if(1!==e[0])return{return_code:36865,error_message:"response format ID not recognized"};{const t=e[1];n=e.subarray(2,2+t).toString("ascii");let r=2+t;const s=e[r];r+=1,a=e.subarray(r,r+s).toString("ascii"),r+=s;const d=e[r];r+=1,i=d,o=e[r]}return{return_code:r,error_message:(0,s.errorCodeToString)(r),appName:""===n||"err",appVersion:""===a||"err",flagLen:i,flagsValue:o,flag_recovery:0!=(1&o),flag_signed_mcu_code:0!=(2&o),flag_onboarded:0!=(4&o),flag_pin_validated:0!=(128&o)}}),s.processErrorResponse)}async getAddress(e,t,r,n=!1,i=0){const o=a.serializePath(this.slip0044,e,t,r);let d=0;n&&(d=1);let u=0;return isNaN(i)||(u=i),await this.transport.send(this.cla,1,d,u,o).then((e=>{const t=e.subarray(-2),r=256*t[0]+t[1];let n=32;return 2==i&&(n=33),{pubKey:e.subarray(0,n).toString("hex"),address:e.subarray(n,e.length-2).toString("ascii"),return_code:r,error_message:(0,s.errorCodeToString)(r)}}),s.processErrorResponse)}async signSendChunk(e,t,r,n=0,a=2){let i=1;1===e&&(i=0),e===t&&(i=2);let o=0;return isNaN(n)||(o=n),await this.transport.send(this.cla,a,i,o,r,[36864,27012,27264]).then((e=>{const t=e.subarray(-2),r=256*t[0]+t[1];let n=(0,s.errorCodeToString)(r),a=null;return 27264===r||27012===r?n=e.subarray(0,e.length-2).toString("ascii"):e.length>2&&(a=e.subarray(0,e.length-2)),{signature:a,return_code:r,error_message:n}}),s.processErrorResponse)}async signImpl(e,t,r,n,i,o=0){const d=a.signGetChunks(this.slip0044,e,t,r,n);return await this.signSendChunk(1,d.length,d[0],o,i).then((async()=>{let e;for(let t=1;t<d.length&&(e=await this.signSendChunk(1+t,d.length,d[t],o,i),36864===e.return_code);t+=1);return{return_code:e.return_code,error_message:e.error_message,signature:e.signature}}),s.processErrorResponse)}async sign(e,t,r,n,s=0){return await this.signImpl(e,t,r,n,2,s)}async signRaw(e,t,r,n,s=0){return await this.signImpl(e,t,r,n,3,s)}async getAllowlistPubKey(){return await this.transport.send(this.cla,144,0,0).then((e=>{const t=e.subarray(-2),r=256*t[0]+t[1];console.log(e);const n=e.subarray(0,32);return 34!==e.length?{return_code:27012,error_message:(0,s.errorCodeToString)(27012)}:{return_code:r,error_message:(0,s.errorCodeToString)(r),pubkey:n}}),s.processErrorResponse)}async setAllowlistPubKey(e){return await this.transport.send(this.cla,145,0,0,e).then((e=>{const t=e.subarray(-2),r=256*t[0]+t[1];return{return_code:r,error_message:(0,s.errorCodeToString)(r)}}),s.processErrorResponse)}async getAllowlistHash(){return await this.transport.send(this.cla,146,0,0).then((e=>{const t=e.subarray(-2),r=256*t[0]+t[1];console.log(e);const n=e.subarray(0,32);return 34!==e.length?{return_code:27012,error_message:(0,s.errorCodeToString)(27012)}:{return_code:r,error_message:(0,s.errorCodeToString)(r),hash:n}}),s.processErrorResponse)}async uploadSendChunk(e,t,r){let n=1;return 1===e&&(n=0),e===t&&(n=2),await this.transport.send(this.cla,147,n,0,r,[36864]).then((e=>{const t=e.subarray(-2),r=256*t[0]+t[1];return{return_code:r,error_message:(0,s.errorCodeToString)(r)}}),s.processErrorResponse)}async uploadAllowlist(e){const t=[];return t.push(n.from([0])),t.push(...a.GetChunks(e)),await this.uploadSendChunk(1,t.length,t[0]).then((async e=>{if(36864!==e.return_code)return{return_code:e.return_code,error_message:e.error_message};for(let r=1;r<t.length&&36864===(e=await this.uploadSendChunk(1+r,t.length,t[r])).return_code;r+=1);return{return_code:e.return_code,error_message:e.error_message}}),s.processErrorResponse)}}t.SubstrateApp=a},76662:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.supportedApps=void 0,t.newSubstrateApp=function(e,r){const s=t.supportedApps.find((e=>e.name.toLowerCase()===r.toLowerCase()));if(null!=s)return new n.SubstrateApp(e,s.cla,s.slip0044);throw new Error(`Error: ${r} not supported`)},t.getAppParams=function(e){return t.supportedApps.find((t=>t.name.toLowerCase()===e.toLowerCase()))};const n=r(40631);t.supportedApps=[{name:"Polkadot",cla:144,slip0044:2147484002,ss58_addr_type:0},{name:"Polymesh",cla:145,slip0044:2147484243,ss58_addr_type:12},{name:"Dock",cla:146,slip0044:2147484242,ss58_addr_type:22},{name:"Centrifuge",cla:147,slip0044:2147484395,ss58_addr_type:36},{name:"Edgeware",cla:148,slip0044:2147484171,ss58_addr_type:7},{name:"Equilibrium",cla:149,slip0044:2247483645,ss58_addr_type:67},{name:"Statemint",cla:150,slip0044:2147484002,ss58_addr_type:0},{name:"Statemine",cla:151,slip0044:2147484082,ss58_addr_type:2},{name:"Nodle",cla:152,slip0044:2147484651,ss58_addr_type:37},{name:"Kusama",cla:153,slip0044:2147484082,ss58_addr_type:2},{name:"Karura",cla:154,slip0044:2147484334,ss58_addr_type:8},{name:"Acala",cla:155,slip0044:2147484435,ss58_addr_type:10},{name:"VTB",cla:156,slip0044:2147484342,ss58_addr_type:42},{name:"Peer",cla:157,slip0044:2147484366,ss58_addr_type:42},{name:"Genshiro",cla:158,slip0044:2247483644,ss58_addr_type:67},{name:"Sora",cla:159,slip0044:2147484265,ss58_addr_type:69},{name:"Polkadex",cla:160,slip0044:2147484447,ss58_addr_type:88},{name:"Bifrost",cla:161,slip0044:2147484436,ss58_addr_type:6},{name:"Reef",cla:162,slip0044:2147484467,ss58_addr_type:42},{name:"XXNetwork",cla:163,slip0044:2147485603,ss58_addr_type:55},{name:"AlephZero",cla:164,slip0044:2147484291,ss58_addr_type:42},{name:"Interlay",cla:165,slip0044:2147484002,ss58_addr_type:2032},{name:"Parallel",cla:166,slip0044:2147484002,ss58_addr_type:172},{name:"Picasso",cla:167,slip0044:2147484082,ss58_addr_type:49},{name:"Composable",cla:168,slip0044:2147484002,ss58_addr_type:49},{name:"Astar",cla:169,slip0044:2147484458,ss58_addr_type:5},{name:"OriginTrail",cla:170,slip0044:2147484002,ss58_addr_type:101},{name:"HydraDX",cla:171,slip0044:2147484002,ss58_addr_type:63},{name:"Stafi",cla:172,slip0044:2147484555,ss58_addr_type:20},{name:"Unique",cla:173,slip0044:2147484309,ss58_addr_type:7391},{name:"BifrostKusama",cla:174,slip0044:2147484436,ss58_addr_type:6},{name:"Phala",cla:175,slip0044:2147484002,ss58_addr_type:30},{name:"Khala",cla:177,slip0044:2147484082,ss58_addr_type:30},{name:"Darwinia",cla:178,slip0044:2147484002,ss58_addr_type:18},{name:"Ajuna",cla:179,slip0044:2147484002,ss58_addr_type:1328},{name:"Bittensor",cla:180,slip0044:2147484653,ss58_addr_type:42},{name:"Ternoa",cla:181,slip0044:2147484643,ss58_addr_type:42},{name:"Pendulum",cla:182,slip0044:2147484002,ss58_addr_type:56},{name:"Zeitgeist",cla:183,slip0044:2147484002,ss58_addr_type:73},{name:"Joystream",cla:184,slip0044:2147484185,ss58_addr_type:126},{name:"Enjin",cla:185,slip0044:2147484803,ss58_addr_type:2135},{name:"Matrixchain",cla:186,slip0044:2147484803,ss58_addr_type:1110},{name:"Quartz",cla:187,slip0044:2147484279,ss58_addr_type:255},{name:"Avail",cla:188,slip0044:2147484357,ss58_addr_type:42},{name:"Entropy",cla:189,slip0044:2147484960,ss58_addr_type:42},{name:"Peaq",cla:97,slip0044:2147483708,ss58_addr_type:42}]},30195:(e,t,r)=>{var n,s;r.d(t,{Km:()=>mt,Ry:()=>nt,Z_:()=>Ve,z:()=>xt}),function(e){e.assertEqual=e=>e,e.assertIs=function(e){},e.assertNever=function(e){throw new Error},e.arrayToEnum=e=>{const t={};for(const r of e)t[r]=r;return t},e.getValidEnumValues=t=>{const r=e.objectKeys(t).filter((e=>"number"!=typeof t[t[e]])),n={};for(const e of r)n[e]=t[e];return e.objectValues(n)},e.objectValues=t=>e.objectKeys(t).map((function(e){return t[e]})),e.objectKeys="function"==typeof Object.keys?e=>Object.keys(e):e=>{const t=[];for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.push(r);return t},e.find=(e,t)=>{for(const r of e)if(t(r))return r},e.isInteger="function"==typeof Number.isInteger?e=>Number.isInteger(e):e=>"number"==typeof e&&isFinite(e)&&Math.floor(e)===e,e.joinValues=function(e,t=" | "){return e.map((e=>"string"==typeof e?`'${e}'`:e)).join(t)},e.jsonStringifyReplacer=(e,t)=>"bigint"==typeof t?t.toString():t}(n||(n={})),function(e){e.mergeShapes=(e,t)=>({...e,...t})}(s||(s={}));const a=n.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),i=e=>{switch(typeof e){case"undefined":return a.undefined;case"string":return a.string;case"number":return isNaN(e)?a.nan:a.number;case"boolean":return a.boolean;case"function":return a.function;case"bigint":return a.bigint;case"symbol":return a.symbol;case"object":return Array.isArray(e)?a.array:null===e?a.null:e.then&&"function"==typeof e.then&&e.catch&&"function"==typeof e.catch?a.promise:"undefined"!=typeof Map&&e instanceof Map?a.map:"undefined"!=typeof Set&&e instanceof Set?a.set:"undefined"!=typeof Date&&e instanceof Date?a.date:a.object;default:return a.unknown}},o=n.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class d extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=e=>{this.issues=[...this.issues,e]},this.addIssues=(e=[])=>{this.issues=[...this.issues,...e]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){const t=e||function(e){return e.message},r={_errors:[]},n=e=>{for(const s of e.issues)if("invalid_union"===s.code)s.unionErrors.map(n);else if("invalid_return_type"===s.code)n(s.returnTypeError);else if("invalid_arguments"===s.code)n(s.argumentsError);else if(0===s.path.length)r._errors.push(t(s));else{let e=r,n=0;for(;n<s.path.length;){const r=s.path[n];n===s.path.length-1?(e[r]=e[r]||{_errors:[]},e[r]._errors.push(t(s))):e[r]=e[r]||{_errors:[]},e=e[r],n++}}};return n(this),r}static assert(e){if(!(e instanceof d))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,n.jsonStringifyReplacer,2)}get isEmpty(){return 0===this.issues.length}flatten(e=(e=>e.message)){const t={},r=[];for(const n of this.issues)n.path.length>0?(t[n.path[0]]=t[n.path[0]]||[],t[n.path[0]].push(e(n))):r.push(e(n));return{formErrors:r,fieldErrors:t}}get formErrors(){return this.flatten()}}d.create=e=>new d(e);const u=(e,t)=>{let r;switch(e.code){case o.invalid_type:r=e.received===a.undefined?"Required":`Expected ${e.expected}, received ${e.received}`;break;case o.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(e.expected,n.jsonStringifyReplacer)}`;break;case o.unrecognized_keys:r=`Unrecognized key(s) in object: ${n.joinValues(e.keys,", ")}`;break;case o.invalid_union:r="Invalid input";break;case o.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${n.joinValues(e.options)}`;break;case o.invalid_enum_value:r=`Invalid enum value. Expected ${n.joinValues(e.options)}, received '${e.received}'`;break;case o.invalid_arguments:r="Invalid function arguments";break;case o.invalid_return_type:r="Invalid function return type";break;case o.invalid_date:r="Invalid date";break;case o.invalid_string:"object"==typeof e.validation?"includes"in e.validation?(r=`Invalid input: must include "${e.validation.includes}"`,"number"==typeof e.validation.position&&(r=`${r} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?r=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?r=`Invalid input: must end with "${e.validation.endsWith}"`:n.assertNever(e.validation):r="regex"!==e.validation?`Invalid ${e.validation}`:"Invalid";break;case o.too_small:r="array"===e.type?`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:"string"===e.type?`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:"number"===e.type?`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:"date"===e.type?`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:"Invalid input";break;case o.too_big:r="array"===e.type?`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:"string"===e.type?`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:"number"===e.type?`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:"bigint"===e.type?`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:"date"===e.type?`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:"Invalid input";break;case o.custom:r="Invalid input";break;case o.invalid_intersection_types:r="Intersection results could not be merged";break;case o.not_multiple_of:r=`Number must be a multiple of ${e.multipleOf}`;break;case o.not_finite:r="Number must be finite";break;default:r=t.defaultError,n.assertNever(e)}return{message:r}};let c=u;function l(){return c}const p=e=>{const{data:t,path:r,errorMaps:n,issueData:s}=e,a=[...r,...s.path||[]],i={...s,path:a};if(void 0!==s.message)return{...s,path:a,message:s.message};let o="";const d=n.filter((e=>!!e)).slice().reverse();for(const e of d)o=e(i,{data:t,defaultError:o}).message;return{...s,path:a,message:o}};function h(e,t){const r=l(),n=p({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,r,r===u?void 0:u].filter((e=>!!e))});e.common.issues.push(n)}class f{constructor(){this.value="valid"}dirty(){"valid"===this.value&&(this.value="dirty")}abort(){"aborted"!==this.value&&(this.value="aborted")}static mergeArray(e,t){const r=[];for(const n of t){if("aborted"===n.status)return m;"dirty"===n.status&&e.dirty(),r.push(n.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,t){const r=[];for(const e of t){const t=await e.key,n=await e.value;r.push({key:t,value:n})}return f.mergeObjectSync(e,r)}static mergeObjectSync(e,t){const r={};for(const n of t){const{key:t,value:s}=n;if("aborted"===t.status)return m;if("aborted"===s.status)return m;"dirty"===t.status&&e.dirty(),"dirty"===s.status&&e.dirty(),"__proto__"===t.value||void 0===s.value&&!n.alwaysSet||(r[t.value]=s.value)}return{status:e.value,value:r}}}const m=Object.freeze({status:"aborted"}),g=e=>({status:"dirty",value:e}),y=e=>({status:"valid",value:e}),_=e=>"aborted"===e.status,v=e=>"dirty"===e.status,w=e=>"valid"===e.status,b=e=>"undefined"!=typeof Promise&&e instanceof Promise;function E(e,t,r,n){if("a"===r&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(e):n?n.value:t.get(e)}function k(e,t,r,n,s){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?s.call(e,r):s?s.value=r:t.set(e,r),r}var S,x,I;"function"==typeof SuppressedError&&SuppressedError,function(e){e.errToObj=e=>"string"==typeof e?{message:e}:e||{},e.toString=e=>"string"==typeof e?e:null==e?void 0:e.message}(S||(S={}));class A{constructor(e,t,r,n){this._cachedPath=[],this.parent=e,this.data=t,this._path=r,this._key=n}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const C=(e,t)=>{if(w(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new d(e.common.issues);return this._error=t,this._error}}};function O(e){if(!e)return{};const{errorMap:t,invalid_type_error:r,required_error:n,description:s}=e;if(t&&(r||n))throw new Error('Can\'t use "invalid_type_error" or "required_error" in conjunction with custom error map.');return t?{errorMap:t,description:s}:{errorMap:(t,s)=>{var a,i;const{message:o}=e;return"invalid_enum_value"===t.code?{message:null!=o?o:s.defaultError}:void 0===s.data?{message:null!==(a=null!=o?o:n)&&void 0!==a?a:s.defaultError}:"invalid_type"!==t.code?{message:s.defaultError}:{message:null!==(i=null!=o?o:r)&&void 0!==i?i:s.defaultError}},description:s}}class R{get description(){return this._def.description}_getType(e){return i(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:i(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new f,ctx:{common:e.parent.common,data:e.data,parsedType:i(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(b(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const r=this.safeParse(e,t);if(r.success)return r.data;throw r.error}safeParse(e,t){var r;const n={common:{issues:[],async:null!==(r=null==t?void 0:t.async)&&void 0!==r&&r,contextualErrorMap:null==t?void 0:t.errorMap},path:(null==t?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:i(e)},s=this._parseSync({data:e,path:n.path,parent:n});return C(n,s)}"~validate"(e){var t,r;const n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:i(e)};if(!this["~standard"].async)try{const t=this._parseSync({data:e,path:[],parent:n});return w(t)?{value:t.value}:{issues:n.common.issues}}catch(e){(null===(r=null===(t=null==e?void 0:e.message)||void 0===t?void 0:t.toLowerCase())||void 0===r?void 0:r.includes("encountered"))&&(this["~standard"].async=!0),n.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:n}).then((e=>w(e)?{value:e.value}:{issues:n.common.issues}))}async parseAsync(e,t){const r=await this.safeParseAsync(e,t);if(r.success)return r.data;throw r.error}async safeParseAsync(e,t){const r={common:{issues:[],contextualErrorMap:null==t?void 0:t.errorMap,async:!0},path:(null==t?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:i(e)},n=this._parse({data:e,path:r.path,parent:r}),s=await(b(n)?n:Promise.resolve(n));return C(r,s)}refine(e,t){const r=e=>"string"==typeof t||void 0===t?{message:t}:"function"==typeof t?t(e):t;return this._refinement(((t,n)=>{const s=e(t),a=()=>n.addIssue({code:o.custom,...r(t)});return"undefined"!=typeof Promise&&s instanceof Promise?s.then((e=>!!e||(a(),!1))):!!s||(a(),!1)}))}refinement(e,t){return this._refinement(((r,n)=>!!e(r)||(n.addIssue("function"==typeof t?t(r,n):t),!1)))}_refinement(e){return new Re({schema:this,typeName:$e.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:e=>this["~validate"](e)}}optional(){return Ne.create(this,this._def)}nullable(){return Te.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return le.create(this)}promise(){return Oe.create(this,this._def)}or(e){return fe.create([this,e],this._def)}and(e){return _e.create(this,e,this._def)}transform(e){return new Re({...O(this._def),schema:this,typeName:$e.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t="function"==typeof e?e:()=>e;return new Pe({...O(this._def),innerType:this,defaultValue:t,typeName:$e.ZodDefault})}brand(){return new Ue({typeName:$e.ZodBranded,type:this,...O(this._def)})}catch(e){const t="function"==typeof e?e:()=>e;return new Ze({...O(this._def),innerType:this,catchValue:t,typeName:$e.ZodCatch})}describe(e){return new(0,this.constructor)({...this._def,description:e})}pipe(e){return je.create(this,e)}readonly(){return De.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const N=/^c[^\s-]{8,}$/i,T=/^[0-9a-z]+$/,P=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Z=/^[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,B=/^[a-z0-9_-]{21}$/i,L=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,U=/^[-+]?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)?)??$/,j=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;let D;const M=/^(?:(?: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])$/,F=/^(?:(?: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])$/,$=/^(([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]))$/,V=/^(([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])$/,z=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,K=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,G="((\\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])))",H=new RegExp(`^${G}$`);function q(e){let t="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return e.precision?t=`${t}\\.\\d{${e.precision}}`:null==e.precision&&(t=`${t}(\\.\\d+)?`),t}function W(e){let t=`${G}T${q(e)}`;const r=[];return r.push(e.local?"Z?":"Z"),e.offset&&r.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${r.join("|")})`,new RegExp(`^${t}$`)}function Y(e,t){if(!L.test(e))return!1;try{const[r]=e.split("."),n=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),s=JSON.parse(atob(n));return!("object"!=typeof s||null===s||!s.typ||!s.alg||t&&s.alg!==t)}catch(e){return!1}}function X(e,t){return!("v4"!==t&&t||!F.test(e))||!("v6"!==t&&t||!V.test(e))}class J extends R{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==a.string){const t=this._getOrReturnCtx(e);return h(t,{code:o.invalid_type,expected:a.string,received:t.parsedType}),m}const t=new f;let r;for(const a of this._def.checks)if("min"===a.kind)e.data.length<a.value&&(r=this._getOrReturnCtx(e,r),h(r,{code:o.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),t.dirty());else if("max"===a.kind)e.data.length>a.value&&(r=this._getOrReturnCtx(e,r),h(r,{code:o.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),t.dirty());else if("length"===a.kind){const n=e.data.length>a.value,s=e.data.length<a.value;(n||s)&&(r=this._getOrReturnCtx(e,r),n?h(r,{code:o.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):s&&h(r,{code:o.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),t.dirty())}else if("email"===a.kind)j.test(e.data)||(r=this._getOrReturnCtx(e,r),h(r,{validation:"email",code:o.invalid_string,message:a.message}),t.dirty());else if("emoji"===a.kind)D||(D=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),D.test(e.data)||(r=this._getOrReturnCtx(e,r),h(r,{validation:"emoji",code:o.invalid_string,message:a.message}),t.dirty());else if("uuid"===a.kind)Z.test(e.data)||(r=this._getOrReturnCtx(e,r),h(r,{validation:"uuid",code:o.invalid_string,message:a.message}),t.dirty());else if("nanoid"===a.kind)B.test(e.data)||(r=this._getOrReturnCtx(e,r),h(r,{validation:"nanoid",code:o.invalid_string,message:a.message}),t.dirty());else if("cuid"===a.kind)N.test(e.data)||(r=this._getOrReturnCtx(e,r),h(r,{validation:"cuid",code:o.invalid_string,message:a.message}),t.dirty());else if("cuid2"===a.kind)T.test(e.data)||(r=this._getOrReturnCtx(e,r),h(r,{validation:"cuid2",code:o.invalid_string,message:a.message}),t.dirty());else if("ulid"===a.kind)P.test(e.data)||(r=this._getOrReturnCtx(e,r),h(r,{validation:"ulid",code:o.invalid_string,message:a.message}),t.dirty());else if("url"===a.kind)try{new URL(e.data)}catch(n){r=this._getOrReturnCtx(e,r),h(r,{validation:"url",code:o.invalid_string,message:a.message}),t.dirty()}else"regex"===a.kind?(a.regex.lastIndex=0,a.regex.test(e.data)||(r=this._getOrReturnCtx(e,r),h(r,{validation:"regex",code:o.invalid_string,message:a.message}),t.dirty())):"trim"===a.kind?e.data=e.data.trim():"includes"===a.kind?e.data.includes(a.value,a.position)||(r=this._getOrReturnCtx(e,r),h(r,{code:o.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),t.dirty()):"toLowerCase"===a.kind?e.data=e.data.toLowerCase():"toUpperCase"===a.kind?e.data=e.data.toUpperCase():"startsWith"===a.kind?e.data.startsWith(a.value)||(r=this._getOrReturnCtx(e,r),h(r,{code:o.invalid_string,validation:{startsWith:a.value},message:a.message}),t.dirty()):"endsWith"===a.kind?e.data.endsWith(a.value)||(r=this._getOrReturnCtx(e,r),h(r,{code:o.invalid_string,validation:{endsWith:a.value},message:a.message}),t.dirty()):"datetime"===a.kind?W(a).test(e.data)||(r=this._getOrReturnCtx(e,r),h(r,{code:o.invalid_string,validation:"datetime",message:a.message}),t.dirty()):"date"===a.kind?H.test(e.data)||(r=this._getOrReturnCtx(e,r),h(r,{code:o.invalid_string,validation:"date",message:a.message}),t.dirty()):"time"===a.kind?new RegExp(`^${q(a)}$`).test(e.data)||(r=this._getOrReturnCtx(e,r),h(r,{code:o.invalid_string,validation:"time",message:a.message}),t.dirty()):"duration"===a.kind?U.test(e.data)||(r=this._getOrReturnCtx(e,r),h(r,{validation:"duration",code:o.invalid_string,message:a.message}),t.dirty()):"ip"===a.kind?(s=e.data,("v4"!==(i=a.version)&&i||!M.test(s))&&("v6"!==i&&i||!$.test(s))&&(r=this._getOrReturnCtx(e,r),h(r,{validation:"ip",code:o.invalid_string,message:a.message}),t.dirty())):"jwt"===a.kind?Y(e.data,a.alg)||(r=this._getOrReturnCtx(e,r),h(r,{validation:"jwt",code:o.invalid_string,message:a.message}),t.dirty()):"cidr"===a.kind?X(e.data,a.version)||(r=this._getOrReturnCtx(e,r),h(r,{validation:"cidr",code:o.invalid_string,message:a.message}),t.dirty()):"base64"===a.kind?z.test(e.data)||(r=this._getOrReturnCtx(e,r),h(r,{validation:"base64",code:o.invalid_string,message:a.message}),t.dirty()):"base64url"===a.kind?K.test(e.data)||(r=this._getOrReturnCtx(e,r),h(r,{validation:"base64url",code:o.invalid_string,message:a.message}),t.dirty()):n.assertNever(a);var s,i;return{status:t.value,value:e.data}}_regex(e,t,r){return this.refinement((t=>e.test(t)),{validation:t,code:o.invalid_string,...S.errToObj(r)})}_addCheck(e){return new J({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...S.errToObj(e)})}url(e){return this._addCheck({kind:"url",...S.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...S.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...S.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...S.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...S.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...S.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...S.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...S.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...S.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...S.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...S.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...S.errToObj(e)})}datetime(e){var t,r;return"string"==typeof e?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:void 0===(null==e?void 0:e.precision)?null:null==e?void 0:e.precision,offset:null!==(t=null==e?void 0:e.offset)&&void 0!==t&&t,local:null!==(r=null==e?void 0:e.local)&&void 0!==r&&r,...S.errToObj(null==e?void 0:e.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return"string"==typeof e?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:void 0===(null==e?void 0:e.precision)?null:null==e?void 0:e.precision,...S.errToObj(null==e?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...S.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...S.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:null==t?void 0:t.position,...S.errToObj(null==t?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...S.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...S.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...S.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...S.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...S.errToObj(t)})}nonempty(e){return this.min(1,S.errToObj(e))}trim(){return new J({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new J({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new J({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find((e=>"datetime"===e.kind))}get isDate(){return!!this._def.checks.find((e=>"date"===e.kind))}get isTime(){return!!this._def.checks.find((e=>"time"===e.kind))}get isDuration(){return!!this._def.checks.find((e=>"duration"===e.kind))}get isEmail(){return!!this._def.checks.find((e=>"email"===e.kind))}get isURL(){return!!this._def.checks.find((e=>"url"===e.kind))}get isEmoji(){return!!this._def.checks.find((e=>"emoji"===e.kind))}get isUUID(){return!!this._def.checks.find((e=>"uuid"===e.kind))}get isNANOID(){return!!this._def.checks.find((e=>"nanoid"===e.kind))}get isCUID(){return!!this._def.checks.find((e=>"cuid"===e.kind))}get isCUID2(){return!!this._def.checks.find((e=>"cuid2"===e.kind))}get isULID(){return!!this._def.checks.find((e=>"ulid"===e.kind))}get isIP(){return!!this._def.checks.find((e=>"ip"===e.kind))}get isCIDR(){return!!this._def.checks.find((e=>"cidr"===e.kind))}get isBase64(){return!!this._def.checks.find((e=>"base64"===e.kind))}get isBase64url(){return!!this._def.checks.find((e=>"base64url"===e.kind))}get minLength(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}}function Q(e,t){const r=(e.toString().split(".")[1]||"").length,n=(t.toString().split(".")[1]||"").length,s=r>n?r:n;return parseInt(e.toFixed(s).replace(".",""))%parseInt(t.toFixed(s).replace(".",""))/Math.pow(10,s)}J.create=e=>{var t;return new J({checks:[],typeName:$e.ZodString,coerce:null!==(t=null==e?void 0:e.coerce)&&void 0!==t&&t,...O(e)})};class ee extends R{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==a.number){const t=this._getOrReturnCtx(e);return h(t,{code:o.invalid_type,expected:a.number,received:t.parsedType}),m}let t;const r=new f;for(const s of this._def.checks)"int"===s.kind?n.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),h(t,{code:o.invalid_type,expected:"integer",received:"float",message:s.message}),r.dirty()):"min"===s.kind?(s.inclusive?e.data<s.value:e.data<=s.value)&&(t=this._getOrReturnCtx(e,t),h(t,{code:o.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),r.dirty()):"max"===s.kind?(s.inclusive?e.data>s.value:e.data>=s.value)&&(t=this._getOrReturnCtx(e,t),h(t,{code:o.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),r.dirty()):"multipleOf"===s.kind?0!==Q(e.data,s.value)&&(t=this._getOrReturnCtx(e,t),h(t,{code:o.not_multiple_of,multipleOf:s.value,message:s.message}),r.dirty()):"finite"===s.kind?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),h(t,{code:o.not_finite,message:s.message}),r.dirty()):n.assertNever(s);return{status:r.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,S.toString(t))}gt(e,t){return this.setLimit("min",e,!1,S.toString(t))}lte(e,t){return this.setLimit("max",e,!0,S.toString(t))}lt(e,t){return this.setLimit("max",e,!1,S.toString(t))}setLimit(e,t,r,n){return new ee({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:S.toString(n)}]})}_addCheck(e){return new ee({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:S.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:S.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:S.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:S.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:S.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:S.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:S.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:S.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:S.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find((e=>"int"===e.kind||"multipleOf"===e.kind&&n.isInteger(e.value)))}get isFinite(){let e=null,t=null;for(const r of this._def.checks){if("finite"===r.kind||"int"===r.kind||"multipleOf"===r.kind)return!0;"min"===r.kind?(null===t||r.value>t)&&(t=r.value):"max"===r.kind&&(null===e||r.value<e)&&(e=r.value)}return Number.isFinite(t)&&Number.isFinite(e)}}ee.create=e=>new ee({checks:[],typeName:$e.ZodNumber,coerce:(null==e?void 0:e.coerce)||!1,...O(e)});class te extends R{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch(t){return this._getInvalidInput(e)}if(this._getType(e)!==a.bigint)return this._getInvalidInput(e);let t;const r=new f;for(const s of this._def.checks)"min"===s.kind?(s.inclusive?e.data<s.value:e.data<=s.value)&&(t=this._getOrReturnCtx(e,t),h(t,{code:o.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),r.dirty()):"max"===s.kind?(s.inclusive?e.data>s.value:e.data>=s.value)&&(t=this._getOrReturnCtx(e,t),h(t,{code:o.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),r.dirty()):"multipleOf"===s.kind?e.data%s.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),h(t,{code:o.not_multiple_of,multipleOf:s.value,message:s.message}),r.dirty()):n.assertNever(s);return{status:r.value,value:e.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return h(t,{code:o.invalid_type,expected:a.bigint,received:t.parsedType}),m}gte(e,t){return this.setLimit("min",e,!0,S.toString(t))}gt(e,t){return this.setLimit("min",e,!1,S.toString(t))}lte(e,t){return this.setLimit("max",e,!0,S.toString(t))}lt(e,t){return this.setLimit("max",e,!1,S.toString(t))}setLimit(e,t,r,n){return new te({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:S.toString(n)}]})}_addCheck(e){return new te({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:S.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:S.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:S.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:S.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:S.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}}te.create=e=>{var t;return new te({checks:[],typeName:$e.ZodBigInt,coerce:null!==(t=null==e?void 0:e.coerce)&&void 0!==t&&t,...O(e)})};class re extends R{_parse(e){if(this._def.coerce&&(e.data=Boolean(e.data)),this._getType(e)!==a.boolean){const t=this._getOrReturnCtx(e);return h(t,{code:o.invalid_type,expected:a.boolean,received:t.parsedType}),m}return y(e.data)}}re.create=e=>new re({typeName:$e.ZodBoolean,coerce:(null==e?void 0:e.coerce)||!1,...O(e)});class ne extends R{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==a.date){const t=this._getOrReturnCtx(e);return h(t,{code:o.invalid_type,expected:a.date,received:t.parsedType}),m}if(isNaN(e.data.getTime()))return h(this._getOrReturnCtx(e),{code:o.invalid_date}),m;const t=new f;let r;for(const s of this._def.checks)"min"===s.kind?e.data.getTime()<s.value&&(r=this._getOrReturnCtx(e,r),h(r,{code:o.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),t.dirty()):"max"===s.kind?e.data.getTime()>s.value&&(r=this._getOrReturnCtx(e,r),h(r,{code:o.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),t.dirty()):n.assertNever(s);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new ne({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:S.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:S.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return null!=e?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return null!=e?new Date(e):null}}ne.create=e=>new ne({checks:[],coerce:(null==e?void 0:e.coerce)||!1,typeName:$e.ZodDate,...O(e)});class se extends R{_parse(e){if(this._getType(e)!==a.symbol){const t=this._getOrReturnCtx(e);return h(t,{code:o.invalid_type,expected:a.symbol,received:t.parsedType}),m}return y(e.data)}}se.create=e=>new se({typeName:$e.ZodSymbol,...O(e)});class ae extends R{_parse(e){if(this._getType(e)!==a.undefined){const t=this._getOrReturnCtx(e);return h(t,{code:o.invalid_type,expected:a.undefined,received:t.parsedType}),m}return y(e.data)}}ae.create=e=>new ae({typeName:$e.ZodUndefined,...O(e)});class ie extends R{_parse(e){if(this._getType(e)!==a.null){const t=this._getOrReturnCtx(e);return h(t,{code:o.invalid_type,expected:a.null,received:t.parsedType}),m}return y(e.data)}}ie.create=e=>new ie({typeName:$e.ZodNull,...O(e)});class oe extends R{constructor(){super(...arguments),this._any=!0}_parse(e){return y(e.data)}}oe.create=e=>new oe({typeName:$e.ZodAny,...O(e)});class de extends R{constructor(){super(...arguments),this._unknown=!0}_parse(e){return y(e.data)}}de.create=e=>new de({typeName:$e.ZodUnknown,...O(e)});class ue extends R{_parse(e){const t=this._getOrReturnCtx(e);return h(t,{code:o.invalid_type,expected:a.never,received:t.parsedType}),m}}ue.create=e=>new ue({typeName:$e.ZodNever,...O(e)});class ce extends R{_parse(e){if(this._getType(e)!==a.undefined){const t=this._getOrReturnCtx(e);return h(t,{code:o.invalid_type,expected:a.void,received:t.parsedType}),m}return y(e.data)}}ce.create=e=>new ce({typeName:$e.ZodVoid,...O(e)});class le extends R{_parse(e){const{ctx:t,status:r}=this._processInputParams(e),n=this._def;if(t.parsedType!==a.array)return h(t,{code:o.invalid_type,expected:a.array,received:t.parsedType}),m;if(null!==n.exactLength){const e=t.data.length>n.exactLength.value,s=t.data.length<n.exactLength.value;(e||s)&&(h(t,{code:e?o.too_big:o.too_small,minimum:s?n.exactLength.value:void 0,maximum:e?n.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:n.exactLength.message}),r.dirty())}if(null!==n.minLength&&t.data.length<n.minLength.value&&(h(t,{code:o.too_small,minimum:n.minLength.value,type:"array",inclusive:!0,exact:!1,message:n.minLength.message}),r.dirty()),null!==n.maxLength&&t.data.length>n.maxLength.value&&(h(t,{code:o.too_big,maximum:n.maxLength.value,type:"array",inclusive:!0,exact:!1,message:n.maxLength.message}),r.dirty()),t.common.async)return Promise.all([...t.data].map(((e,r)=>n.type._parseAsync(new A(t,e,t.path,r))))).then((e=>f.mergeArray(r,e)));const s=[...t.data].map(((e,r)=>n.type._parseSync(new A(t,e,t.path,r))));return f.mergeArray(r,s)}get element(){return this._def.type}min(e,t){return new le({...this._def,minLength:{value:e,message:S.toString(t)}})}max(e,t){return new le({...this._def,maxLength:{value:e,message:S.toString(t)}})}length(e,t){return new le({...this._def,exactLength:{value:e,message:S.toString(t)}})}nonempty(e){return this.min(1,e)}}function pe(e){if(e instanceof he){const t={};for(const r in e.shape){const n=e.shape[r];t[r]=Ne.create(pe(n))}return new he({...e._def,shape:()=>t})}return e instanceof le?new le({...e._def,type:pe(e.element)}):e instanceof Ne?Ne.create(pe(e.unwrap())):e instanceof Te?Te.create(pe(e.unwrap())):e instanceof ve?ve.create(e.items.map((e=>pe(e)))):e}le.create=(e,t)=>new le({type:e,minLength:null,maxLength:null,exactLength:null,typeName:$e.ZodArray,...O(t)});class he extends R{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(null!==this._cached)return this._cached;const e=this._def.shape(),t=n.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==a.object){const t=this._getOrReturnCtx(e);return h(t,{code:o.invalid_type,expected:a.object,received:t.parsedType}),m}const{status:t,ctx:r}=this._processInputParams(e),{shape:n,keys:s}=this._getCached(),i=[];if(!(this._def.catchall instanceof ue&&"strip"===this._def.unknownKeys))for(const e in r.data)s.includes(e)||i.push(e);const d=[];for(const e of s){const t=n[e],s=r.data[e];d.push({key:{status:"valid",value:e},value:t._parse(new A(r,s,r.path,e)),alwaysSet:e in r.data})}if(this._def.catchall instanceof ue){const e=this._def.unknownKeys;if("passthrough"===e)for(const e of i)d.push({key:{status:"valid",value:e},value:{status:"valid",value:r.data[e]}});else if("strict"===e)i.length>0&&(h(r,{code:o.unrecognized_keys,keys:i}),t.dirty());else if("strip"!==e)throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const e=this._def.catchall;for(const t of i){const n=r.data[t];d.push({key:{status:"valid",value:t},value:e._parse(new A(r,n,r.path,t)),alwaysSet:t in r.data})}}return r.common.async?Promise.resolve().then((async()=>{const e=[];for(const t of d){const r=await t.key,n=await t.value;e.push({key:r,value:n,alwaysSet:t.alwaysSet})}return e})).then((e=>f.mergeObjectSync(t,e))):f.mergeObjectSync(t,d)}get shape(){return this._def.shape()}strict(e){return S.errToObj,new he({...this._def,unknownKeys:"strict",...void 0!==e?{errorMap:(t,r)=>{var n,s,a,i;const o=null!==(a=null===(s=(n=this._def).errorMap)||void 0===s?void 0:s.call(n,t,r).message)&&void 0!==a?a:r.defaultError;return"unrecognized_keys"===t.code?{message:null!==(i=S.errToObj(e).message)&&void 0!==i?i:o}:{message:o}}}:{}})}strip(){return new he({...this._def,unknownKeys:"strip"})}passthrough(){return new he({...this._def,unknownKeys:"passthrough"})}extend(e){return new he({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new he({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:$e.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new he({...this._def,catchall:e})}pick(e){const t={};return n.objectKeys(e).forEach((r=>{e[r]&&this.shape[r]&&(t[r]=this.shape[r])})),new he({...this._def,shape:()=>t})}omit(e){const t={};return n.objectKeys(this.shape).forEach((r=>{e[r]||(t[r]=this.shape[r])})),new he({...this._def,shape:()=>t})}deepPartial(){return pe(this)}partial(e){const t={};return n.objectKeys(this.shape).forEach((r=>{const n=this.shape[r];e&&!e[r]?t[r]=n:t[r]=n.optional()})),new he({...this._def,shape:()=>t})}required(e){const t={};return n.objectKeys(this.shape).forEach((r=>{if(e&&!e[r])t[r]=this.shape[r];else{let e=this.shape[r];for(;e instanceof Ne;)e=e._def.innerType;t[r]=e}})),new he({...this._def,shape:()=>t})}keyof(){return Ie(n.objectKeys(this.shape))}}he.create=(e,t)=>new he({shape:()=>e,unknownKeys:"strip",catchall:ue.create(),typeName:$e.ZodObject,...O(t)}),he.strictCreate=(e,t)=>new he({shape:()=>e,unknownKeys:"strict",catchall:ue.create(),typeName:$e.ZodObject,...O(t)}),he.lazycreate=(e,t)=>new he({shape:e,unknownKeys:"strip",catchall:ue.create(),typeName:$e.ZodObject,...O(t)});class fe extends R{_parse(e){const{ctx:t}=this._processInputParams(e),r=this._def.options;if(t.common.async)return Promise.all(r.map((async e=>{const r={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:r}),ctx:r}}))).then((function(e){for(const t of e)if("valid"===t.result.status)return t.result;for(const r of e)if("dirty"===r.result.status)return t.common.issues.push(...r.ctx.common.issues),r.result;const r=e.map((e=>new d(e.ctx.common.issues)));return h(t,{code:o.invalid_union,unionErrors:r}),m}));{let e;const n=[];for(const s of r){const r={...t,common:{...t.common,issues:[]},parent:null},a=s._parseSync({data:t.data,path:t.path,parent:r});if("valid"===a.status)return a;"dirty"!==a.status||e||(e={result:a,ctx:r}),r.common.issues.length&&n.push(r.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;const s=n.map((e=>new d(e)));return h(t,{code:o.invalid_union,unionErrors:s}),m}}get options(){return this._def.options}}fe.create=(e,t)=>new fe({options:e,typeName:$e.ZodUnion,...O(t)});const me=e=>e instanceof Se?me(e.schema):e instanceof Re?me(e.innerType()):e instanceof xe?[e.value]:e instanceof Ae?e.options:e instanceof Ce?n.objectValues(e.enum):e instanceof Pe?me(e._def.innerType):e instanceof ae?[void 0]:e instanceof ie?[null]:e instanceof Ne?[void 0,...me(e.unwrap())]:e instanceof Te?[null,...me(e.unwrap())]:e instanceof Ue||e instanceof De?me(e.unwrap()):e instanceof Ze?me(e._def.innerType):[];class ge extends R{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==a.object)return h(t,{code:o.invalid_type,expected:a.object,received:t.parsedType}),m;const r=this.discriminator,n=t.data[r],s=this.optionsMap.get(n);return s?t.common.async?s._parseAsync({data:t.data,path:t.path,parent:t}):s._parseSync({data:t.data,path:t.path,parent:t}):(h(t,{code:o.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),m)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,r){const n=new Map;for(const r of t){const t=me(r.shape[e]);if(!t.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const s of t){if(n.has(s))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(s)}`);n.set(s,r)}}return new ge({typeName:$e.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:n,...O(r)})}}function ye(e,t){const r=i(e),s=i(t);if(e===t)return{valid:!0,data:e};if(r===a.object&&s===a.object){const r=n.objectKeys(t),s=n.objectKeys(e).filter((e=>-1!==r.indexOf(e))),a={...e,...t};for(const r of s){const n=ye(e[r],t[r]);if(!n.valid)return{valid:!1};a[r]=n.data}return{valid:!0,data:a}}if(r===a.array&&s===a.array){if(e.length!==t.length)return{valid:!1};const r=[];for(let n=0;n<e.length;n++){const s=ye(e[n],t[n]);if(!s.valid)return{valid:!1};r.push(s.data)}return{valid:!0,data:r}}return r===a.date&&s===a.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}class _e extends R{_parse(e){const{status:t,ctx:r}=this._processInputParams(e),n=(e,n)=>{if(_(e)||_(n))return m;const s=ye(e.value,n.value);return s.valid?((v(e)||v(n))&&t.dirty(),{status:t.value,value:s.data}):(h(r,{code:o.invalid_intersection_types}),m)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then((([e,t])=>n(e,t))):n(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}_e.create=(e,t,r)=>new _e({left:e,right:t,typeName:$e.ZodIntersection,...O(r)});class ve extends R{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==a.array)return h(r,{code:o.invalid_type,expected:a.array,received:r.parsedType}),m;if(r.data.length<this._def.items.length)return h(r,{code:o.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),m;!this._def.rest&&r.data.length>this._def.items.length&&(h(r,{code:o.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const n=[...r.data].map(((e,t)=>{const n=this._def.items[t]||this._def.rest;return n?n._parse(new A(r,e,r.path,t)):null})).filter((e=>!!e));return r.common.async?Promise.all(n).then((e=>f.mergeArray(t,e))):f.mergeArray(t,n)}get items(){return this._def.items}rest(e){return new ve({...this._def,rest:e})}}ve.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new ve({items:e,typeName:$e.ZodTuple,rest:null,...O(t)})};class we extends R{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==a.object)return h(r,{code:o.invalid_type,expected:a.object,received:r.parsedType}),m;const n=[],s=this._def.keyType,i=this._def.valueType;for(const e in r.data)n.push({key:s._parse(new A(r,e,r.path,e)),value:i._parse(new A(r,r.data[e],r.path,e)),alwaysSet:e in r.data});return r.common.async?f.mergeObjectAsync(t,n):f.mergeObjectSync(t,n)}get element(){return this._def.valueType}static create(e,t,r){return new we(t instanceof R?{keyType:e,valueType:t,typeName:$e.ZodRecord,...O(r)}:{keyType:J.create(),valueType:e,typeName:$e.ZodRecord,...O(t)})}}class be extends R{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==a.map)return h(r,{code:o.invalid_type,expected:a.map,received:r.parsedType}),m;const n=this._def.keyType,s=this._def.valueType,i=[...r.data.entries()].map((([e,t],a)=>({key:n._parse(new A(r,e,r.path,[a,"key"])),value:s._parse(new A(r,t,r.path,[a,"value"]))})));if(r.common.async){const e=new Map;return Promise.resolve().then((async()=>{for(const r of i){const n=await r.key,s=await r.value;if("aborted"===n.status||"aborted"===s.status)return m;"dirty"!==n.status&&"dirty"!==s.status||t.dirty(),e.set(n.value,s.value)}return{status:t.value,value:e}}))}{const e=new Map;for(const r of i){const n=r.key,s=r.value;if("aborted"===n.status||"aborted"===s.status)return m;"dirty"!==n.status&&"dirty"!==s.status||t.dirty(),e.set(n.value,s.value)}return{status:t.value,value:e}}}}be.create=(e,t,r)=>new be({valueType:t,keyType:e,typeName:$e.ZodMap,...O(r)});class Ee extends R{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==a.set)return h(r,{code:o.invalid_type,expected:a.set,received:r.parsedType}),m;const n=this._def;null!==n.minSize&&r.data.size<n.minSize.value&&(h(r,{code:o.too_small,minimum:n.minSize.value,type:"set",inclusive:!0,exact:!1,message:n.minSize.message}),t.dirty()),null!==n.maxSize&&r.data.size>n.maxSize.value&&(h(r,{code:o.too_big,maximum:n.maxSize.value,type:"set",inclusive:!0,exact:!1,message:n.maxSize.message}),t.dirty());const s=this._def.valueType;function i(e){const r=new Set;for(const n of e){if("aborted"===n.status)return m;"dirty"===n.status&&t.dirty(),r.add(n.value)}return{status:t.value,value:r}}const d=[...r.data.values()].map(((e,t)=>s._parse(new A(r,e,r.path,t))));return r.common.async?Promise.all(d).then((e=>i(e))):i(d)}min(e,t){return new Ee({...this._def,minSize:{value:e,message:S.toString(t)}})}max(e,t){return new Ee({...this._def,maxSize:{value:e,message:S.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}Ee.create=(e,t)=>new Ee({valueType:e,minSize:null,maxSize:null,typeName:$e.ZodSet,...O(t)});class ke extends R{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==a.function)return h(t,{code:o.invalid_type,expected:a.function,received:t.parsedType}),m;function r(e,r){return p({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,l(),u].filter((e=>!!e)),issueData:{code:o.invalid_arguments,argumentsError:r}})}function n(e,r){return p({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,l(),u].filter((e=>!!e)),issueData:{code:o.invalid_return_type,returnTypeError:r}})}const s={errorMap:t.common.contextualErrorMap},i=t.data;if(this._def.returns instanceof Oe){const e=this;return y((async function(...t){const a=new d([]),o=await e._def.args.parseAsync(t,s).catch((e=>{throw a.addIssue(r(t,e)),a})),u=await Reflect.apply(i,this,o);return await e._def.returns._def.type.parseAsync(u,s).catch((e=>{throw a.addIssue(n(u,e)),a}))}))}{const e=this;return y((function(...t){const a=e._def.args.safeParse(t,s);if(!a.success)throw new d([r(t,a.error)]);const o=Reflect.apply(i,this,a.data),u=e._def.returns.safeParse(o,s);if(!u.success)throw new d([n(o,u.error)]);return u.data}))}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new ke({...this._def,args:ve.create(e).rest(de.create())})}returns(e){return new ke({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,r){return new ke({args:e||ve.create([]).rest(de.create()),returns:t||de.create(),typeName:$e.ZodFunction,...O(r)})}}class Se extends R{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}Se.create=(e,t)=>new Se({getter:e,typeName:$e.ZodLazy,...O(t)});class xe extends R{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return h(t,{received:t.data,code:o.invalid_literal,expected:this._def.value}),m}return{status:"valid",value:e.data}}get value(){return this._def.value}}function Ie(e,t){return new Ae({values:e,typeName:$e.ZodEnum,...O(t)})}xe.create=(e,t)=>new xe({value:e,typeName:$e.ZodLiteral,...O(t)});class Ae extends R{constructor(){super(...arguments),x.set(this,void 0)}_parse(e){if("string"!=typeof e.data){const t=this._getOrReturnCtx(e),r=this._def.values;return h(t,{expected:n.joinValues(r),received:t.parsedType,code:o.invalid_type}),m}if(E(this,x,"f")||k(this,x,new Set(this._def.values),"f"),!E(this,x,"f").has(e.data)){const t=this._getOrReturnCtx(e),r=this._def.values;return h(t,{received:t.data,code:o.invalid_enum_value,options:r}),m}return y(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return Ae.create(e,{...this._def,...t})}exclude(e,t=this._def){return Ae.create(this.options.filter((t=>!e.includes(t))),{...this._def,...t})}}x=new WeakMap,Ae.create=Ie;class Ce extends R{constructor(){super(...arguments),I.set(this,void 0)}_parse(e){const t=n.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==a.string&&r.parsedType!==a.number){const e=n.objectValues(t);return h(r,{expected:n.joinValues(e),received:r.parsedType,code:o.invalid_type}),m}if(E(this,I,"f")||k(this,I,new Set(n.getValidEnumValues(this._def.values)),"f"),!E(this,I,"f").has(e.data)){const e=n.objectValues(t);return h(r,{received:r.data,code:o.invalid_enum_value,options:e}),m}return y(e.data)}get enum(){return this._def.values}}I=new WeakMap,Ce.create=(e,t)=>new Ce({values:e,typeName:$e.ZodNativeEnum,...O(t)});class Oe extends R{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==a.promise&&!1===t.common.async)return h(t,{code:o.invalid_type,expected:a.promise,received:t.parsedType}),m;const r=t.parsedType===a.promise?t.data:Promise.resolve(t.data);return y(r.then((e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap}))))}}Oe.create=(e,t)=>new Oe({type:e,typeName:$e.ZodPromise,...O(t)});class Re extends R{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===$e.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:r}=this._processInputParams(e),s=this._def.effect||null,a={addIssue:e=>{h(r,e),e.fatal?t.abort():t.dirty()},get path(){return r.path}};if(a.addIssue=a.addIssue.bind(a),"preprocess"===s.type){const e=s.transform(r.data,a);if(r.common.async)return Promise.resolve(e).then((async e=>{if("aborted"===t.value)return m;const n=await this._def.schema._parseAsync({data:e,path:r.path,parent:r});return"aborted"===n.status?m:"dirty"===n.status||"dirty"===t.value?g(n.value):n}));{if("aborted"===t.value)return m;const n=this._def.schema._parseSync({data:e,path:r.path,parent:r});return"aborted"===n.status?m:"dirty"===n.status||"dirty"===t.value?g(n.value):n}}if("refinement"===s.type){const e=e=>{const t=s.refinement(e,a);if(r.common.async)return Promise.resolve(t);if(t instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return e};if(!1===r.common.async){const n=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return"aborted"===n.status?m:("dirty"===n.status&&t.dirty(),e(n.value),{status:t.value,value:n.value})}return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then((r=>"aborted"===r.status?m:("dirty"===r.status&&t.dirty(),e(r.value).then((()=>({status:t.value,value:r.value}))))))}if("transform"===s.type){if(!1===r.common.async){const e=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!w(e))return e;const n=s.transform(e.value,a);if(n instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:n}}return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then((e=>w(e)?Promise.resolve(s.transform(e.value,a)).then((e=>({status:t.value,value:e}))):e))}n.assertNever(s)}}Re.create=(e,t,r)=>new Re({schema:e,typeName:$e.ZodEffects,effect:t,...O(r)}),Re.createWithPreprocess=(e,t,r)=>new Re({schema:t,effect:{type:"preprocess",transform:e},typeName:$e.ZodEffects,...O(r)});class Ne extends R{_parse(e){return this._getType(e)===a.undefined?y(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Ne.create=(e,t)=>new Ne({innerType:e,typeName:$e.ZodOptional,...O(t)});class Te extends R{_parse(e){return this._getType(e)===a.null?y(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Te.create=(e,t)=>new Te({innerType:e,typeName:$e.ZodNullable,...O(t)});class Pe extends R{_parse(e){const{ctx:t}=this._processInputParams(e);let r=t.data;return t.parsedType===a.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}Pe.create=(e,t)=>new Pe({innerType:e,typeName:$e.ZodDefault,defaultValue:"function"==typeof t.default?t.default:()=>t.default,...O(t)});class Ze extends R{_parse(e){const{ctx:t}=this._processInputParams(e),r={...t,common:{...t.common,issues:[]}},n=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return b(n)?n.then((e=>({status:"valid",value:"valid"===e.status?e.value:this._def.catchValue({get error(){return new d(r.common.issues)},input:r.data})}))):{status:"valid",value:"valid"===n.status?n.value:this._def.catchValue({get error(){return new d(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}Ze.create=(e,t)=>new Ze({innerType:e,typeName:$e.ZodCatch,catchValue:"function"==typeof t.catch?t.catch:()=>t.catch,...O(t)});class Be extends R{_parse(e){if(this._getType(e)!==a.nan){const t=this._getOrReturnCtx(e);return h(t,{code:o.invalid_type,expected:a.nan,received:t.parsedType}),m}return{status:"valid",value:e.data}}}Be.create=e=>new Be({typeName:$e.ZodNaN,...O(e)});const Le=Symbol("zod_brand");class Ue extends R{_parse(e){const{ctx:t}=this._processInputParams(e),r=t.data;return this._def.type._parse({data:r,path:t.path,parent:t})}unwrap(){return this._def.type}}class je extends R{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{const e=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return"aborted"===e.status?m:"dirty"===e.status?(t.dirty(),g(e.value)):this._def.out._parseAsync({data:e.value,path:r.path,parent:r})})();{const e=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return"aborted"===e.status?m:"dirty"===e.status?(t.dirty(),{status:"dirty",value:e.value}):this._def.out._parseSync({data:e.value,path:r.path,parent:r})}}static create(e,t){return new je({in:e,out:t,typeName:$e.ZodPipeline})}}class De extends R{_parse(e){const t=this._def.innerType._parse(e),r=e=>(w(e)&&(e.value=Object.freeze(e.value)),e);return b(t)?t.then((e=>r(e))):r(t)}unwrap(){return this._def.innerType}}function Me(e,t={},r){return e?oe.create().superRefine(((n,s)=>{var a,i;if(!e(n)){const e="function"==typeof t?t(n):"string"==typeof t?{message:t}:t,o=null===(i=null!==(a=e.fatal)&&void 0!==a?a:r)||void 0===i||i,d="string"==typeof e?{message:e}:e;s.addIssue({code:"custom",...d,fatal:o})}})):oe.create()}De.create=(e,t)=>new De({innerType:e,typeName:$e.ZodReadonly,...O(t)});const Fe={object:he.lazycreate};var $e;!function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"}($e||($e={}));const Ve=J.create,ze=ee.create,Ke=Be.create,Ge=te.create,He=re.create,qe=ne.create,We=se.create,Ye=ae.create,Xe=ie.create,Je=oe.create,Qe=de.create,et=ue.create,tt=ce.create,rt=le.create,nt=he.create,st=he.strictCreate,at=fe.create,it=ge.create,ot=_e.create,dt=ve.create,ut=we.create,ct=be.create,lt=Ee.create,pt=ke.create,ht=Se.create,ft=xe.create,mt=Ae.create,gt=Ce.create,yt=Oe.create,_t=Re.create,vt=Ne.create,wt=Te.create,bt=Re.createWithPreprocess,Et=je.create,kt={string:e=>J.create({...e,coerce:!0}),number:e=>ee.create({...e,coerce:!0}),boolean:e=>re.create({...e,coerce:!0}),bigint:e=>te.create({...e,coerce:!0}),date:e=>ne.create({...e,coerce:!0})},St=m;var xt=Object.freeze({__proto__:null,defaultErrorMap:u,setErrorMap:function(e){c=e},getErrorMap:l,makeIssue:p,EMPTY_PATH:[],addIssueToContext:h,ParseStatus:f,INVALID:m,DIRTY:g,OK:y,isAborted:_,isDirty:v,isValid:w,isAsync:b,get util(){return n},get objectUtil(){return s},ZodParsedType:a,getParsedType:i,ZodType:R,datetimeRegex:W,ZodString:J,ZodNumber:ee,ZodBigInt:te,ZodBoolean:re,ZodDate:ne,ZodSymbol:se,ZodUndefined:ae,ZodNull:ie,ZodAny:oe,ZodUnknown:de,ZodNever:ue,ZodVoid:ce,ZodArray:le,ZodObject:he,ZodUnion:fe,ZodDiscriminatedUnion:ge,ZodIntersection:_e,ZodTuple:ve,ZodRecord:we,ZodMap:be,ZodSet:Ee,ZodFunction:ke,ZodLazy:Se,ZodLiteral:xe,ZodEnum:Ae,ZodNativeEnum:Ce,ZodPromise:Oe,ZodEffects:Re,ZodTransformer:Re,ZodOptional:Ne,ZodNullable:Te,ZodDefault:Pe,ZodCatch:Ze,ZodNaN:Be,BRAND:Le,ZodBranded:Ue,ZodPipeline:je,ZodReadonly:De,custom:Me,Schema:R,ZodSchema:R,late:Fe,get ZodFirstPartyTypeKind(){return $e},coerce:kt,any:Je,array:rt,bigint:Ge,boolean:He,date:qe,discriminatedUnion:it,effect:_t,enum:mt,function:pt,instanceof:(e,t={message:`Input not instance of ${e.name}`})=>Me((t=>t instanceof e),t),intersection:ot,lazy:ht,literal:ft,map:ct,nan:Ke,nativeEnum:gt,never:et,null:Xe,nullable:wt,number:ze,object:nt,oboolean:()=>He().optional(),onumber:()=>ze().optional(),optional:vt,ostring:()=>Ve().optional(),pipeline:Et,preprocess:bt,promise:yt,record:ut,set:lt,strictObject:st,string:Ve,symbol:We,transformer:_t,tuple:dt,undefined:Ye,union:at,unknown:Qe,void:tt,NEVER:St,ZodIssueCode:o,quotelessJson:e=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:"),ZodError:d})},81697:(e,t,r)=>{r.d(t,{z:()=>s});var n={}.hasOwnProperty;function s(e,t){var r=t||{};function s(t){var r=s.invalid,a=s.handlers;if(t&&n.call(t,e)&&(r=n.call(a,t[e])?a[t[e]]:s.unknown),r)return r.apply(this,arguments)}return s.handlers=r.handlers||{},s.invalid=r.invalid,s.unknown=r.unknown,s}}}]);