nemar-cli 0.9.15-dev.2285 → 0.9.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -97,12 +97,12 @@ ${t}`,vwe,_we,wwe=(e,t,r)=>{let n=r===""?"":`with ${r.trim()}() `,i=bwe.bind(nul
|
|
|
97
97
|
depsCount: ${t},
|
|
98
98
|
deps: ${r}}`};var zIe={keyword:"dependencies",type:"object",schemaType:"object",error:tU.error,code(e){let[t,r]=HIe(e);ZL(e,t),eU(e,r)}};function HIe({schema:e}){let t={},r={};for(let n in e){if(n==="__proto__")continue;let i=Array.isArray(e[n])?t:r;i[n]=e[n]}return[t,r]}function ZL(e,t=e.schema){let{gen:r,data:n,it:i}=e;if(Object.keys(t).length===0)return;let s=r.let("missing");for(let o in t){let a=t[o];if(a.length===0)continue;let c=(0,gd.propertyInData)(r,n,o,i.opts.ownProperties);if(e.setParams({property:o,depsCount:a.length,deps:a.join(", ")}),i.allErrors)r.if(c,()=>{for(let u of a)(0,gd.checkReportMissingProp)(e,u)});else r.if(aw._`${c} && (${(0,gd.checkMissingProp)(e,a,s)})`),(0,gd.reportMissingProp)(e,s),r.else()}}tU.validatePropertyDeps=ZL;function eU(e,t=e.schema){let{gen:r,data:n,keyword:i,it:s}=e,o=r.name("valid");for(let a in t){if((0,VIe.alwaysValidSchema)(s,t[a]))continue;r.if((0,gd.propertyInData)(r,n,a,s.opts.ownProperties),()=>{let c=e.subschema({keyword:i,schemaProp:a},o);e.mergeValidEvaluated(c,o)},()=>r.var(o,!0)),e.ok(o)}}tU.validateSchemaDeps=eU;tU.default=zIe});var aU=h(function(oU){Object.defineProperty(oU,"__esModule",{value:!0});var sU=xe(),KIe=qe(),YIe={message:"property name must be valid",params:({params:e})=>sU._`{propertyName: ${e.propertyName}}`},JIe={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:YIe,code(e){let{gen:t,schema:r,data:n,it:i}=e;if((0,KIe.alwaysValidSchema)(i,r))return;let s=t.name("valid");t.forIn("key",n,(o)=>{e.setParams({propertyName:o}),e.subschema({keyword:"propertyNames",data:o,dataTypes:["string"],propertyName:o,compositeRule:!0},s),t.if((0,sU.not)(s),()=>{if(e.error(!0),!i.allErrors)t.break()})}),e.ok(s)}};oU.default=JIe});var cw=h(function(cU){Object.defineProperty(cU,"__esModule",{value:!0});var b0=Qr(),Sn=xe(),QIe=qi(),v0=qe(),ZIe={message:"must NOT have additional properties",params:({params:e})=>Sn._`{additionalProperty: ${e.additionalProperty}}`},e8e={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:ZIe,code(e){let{gen:t,schema:r,parentSchema:n,data:i,errsCount:s,it:o}=e;if(!s)throw Error("ajv implementation error");let{allErrors:a,opts:c}=o;if(o.props=!0,c.removeAdditional!=="all"&&(0,v0.alwaysValidSchema)(o,r))return;let u=(0,b0.allSchemaProperties)(n.properties),d=(0,b0.allSchemaProperties)(n.patternProperties);f(),e.ok(Sn._`${s} === ${QIe.default.errors}`);function f(){t.forIn("key",i,(x)=>{if(!u.length&&!d.length)g(x);else t.if(m(x),()=>g(x))})}function m(x){let v;if(u.length>8){let _=(0,v0.schemaRefOrVal)(o,n.properties,"properties");v=(0,b0.isOwnProperty)(t,_,x)}else if(u.length)v=(0,Sn.or)(...u.map((_)=>Sn._`${x} === ${_}`));else v=Sn.nil;if(d.length)v=(0,Sn.or)(v,...d.map((_)=>Sn._`${(0,b0.usePattern)(e,_)}.test(${x})`));return(0,Sn.not)(v)}function p(x){t.code(Sn._`delete ${i}[${x}]`)}function g(x){if(c.removeAdditional==="all"||c.removeAdditional&&r===!1){p(x);return}if(r===!1){if(e.setParams({additionalProperty:x}),e.error(),!a)t.break();return}if(typeof r=="object"&&!(0,v0.alwaysValidSchema)(o,r)){let v=t.name("valid");if(c.removeAdditional==="failing")y(x,v,!1),t.if((0,Sn.not)(v),()=>{e.reset(),p(x)});else if(y(x,v),!a)t.if((0,Sn.not)(v),()=>t.break())}}function y(x,v,_){let S={keyword:"additionalProperties",dataProp:x,dataPropType:v0.Type.Str};if(_===!1)Object.assign(S,{compositeRule:!0,createErrors:!1,allErrors:!1});e.subschema(S,v)}}};cU.default=e8e});var fU=h(function(dU){Object.defineProperty(dU,"__esModule",{value:!0});var r8e=sd(),uU=Qr(),uw=qe(),lU=cw(),n8e={keyword:"properties",type:"object",schemaType:"object",code(e){let{gen:t,schema:r,parentSchema:n,data:i,it:s}=e;if(s.opts.removeAdditional==="all"&&n.additionalProperties===void 0)lU.default.code(new r8e.KeywordCxt(s,lU.default,"additionalProperties"));let o=(0,uU.allSchemaProperties)(r);for(let f of o)s.definedProperties.add(f);if(s.opts.unevaluated&&o.length&&s.props!==!0)s.props=uw.mergeEvaluated.props(t,(0,uw.toHash)(o),s.props);let a=o.filter((f)=>!(0,uw.alwaysValidSchema)(s,r[f]));if(a.length===0)return;let c=t.name("valid");for(let f of a){if(u(f))d(f);else{if(t.if((0,uU.propertyInData)(t,i,f,s.opts.ownProperties)),d(f),!s.allErrors)t.else().var(c,!0);t.endIf()}e.it.definedProperties.add(f),e.ok(c)}function u(f){return s.opts.useDefaults&&!s.compositeRule&&r[f].default!==void 0}function d(f){e.subschema({keyword:"properties",schemaProp:f,dataProp:f},c)}}};dU.default=n8e});var yU=h(function(gU){Object.defineProperty(gU,"__esModule",{value:!0});var pU=Qr(),_0=xe(),mU=qe(),hU=qe(),s8e={keyword:"patternProperties",type:"object",schemaType:"object",code(e){let{gen:t,schema:r,data:n,parentSchema:i,it:s}=e,{opts:o}=s,a=(0,pU.allSchemaProperties)(r),c=a.filter((y)=>(0,mU.alwaysValidSchema)(s,r[y]));if(a.length===0||c.length===a.length&&(!s.opts.unevaluated||s.props===!0))return;let u=o.strictSchema&&!o.allowMatchingProperties&&i.properties,d=t.name("valid");if(s.props!==!0&&!(s.props instanceof _0.Name))s.props=(0,hU.evaluatedPropsToName)(t,s.props);let{props:f}=s;m();function m(){for(let y of a){if(u)p(y);if(s.allErrors)g(y);else t.var(d,!0),g(y),t.if(d)}}function p(y){for(let x in u)if(new RegExp(y).test(x))(0,mU.checkStrictMode)(s,`property ${x} matches pattern ${y} (use allowMatchingProperties)`)}function g(y){t.forIn("key",n,(x)=>{t.if(_0._`${(0,pU.usePattern)(e,y)}.test(${x})`,()=>{let v=c.includes(y);if(!v)e.subschema({keyword:"patternProperties",schemaProp:y,dataProp:x,dataPropType:hU.Type.Str},d);if(s.opts.unevaluated&&f!==!0)t.assign(_0._`${f}[${x}]`,!0);else if(!v&&!s.allErrors)t.if((0,_0.not)(d),()=>t.break())})})}}};gU.default=s8e});var bU=h(function(xU){Object.defineProperty(xU,"__esModule",{value:!0});var a8e=qe(),c8e={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(e){let{gen:t,schema:r,it:n}=e;if((0,a8e.alwaysValidSchema)(n,r)){e.fail();return}let i=t.name("valid");e.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},i),e.failResult(i,()=>e.reset(),()=>e.error())},error:{message:"must NOT be valid"}};xU.default=c8e});var _U=h(function(vU){Object.defineProperty(vU,"__esModule",{value:!0});var l8e=Qr(),d8e={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:l8e.validateUnion,error:{message:"must match a schema in anyOf"}};vU.default=d8e});var DU=h(function(wU){Object.defineProperty(wU,"__esModule",{value:!0});var w0=xe(),p8e=qe(),m8e={message:"must match exactly one schema in oneOf",params:({params:e})=>w0._`{passingSchemas: ${e.passing}}`},h8e={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:m8e,code(e){let{gen:t,schema:r,parentSchema:n,it:i}=e;if(!Array.isArray(r))throw Error("ajv implementation error");if(i.opts.discriminator&&n.discriminator)return;let s=r,o=t.let("valid",!1),a=t.let("passing",null),c=t.name("_valid");e.setParams({passing:a}),t.block(u),e.result(o,()=>e.reset(),()=>e.error(!0));function u(){s.forEach((d,f)=>{let m;if((0,p8e.alwaysValidSchema)(i,d))t.var(c,!0);else m=e.subschema({keyword:"oneOf",schemaProp:f,compositeRule:!0},c);if(f>0)t.if(w0._`${c} && ${o}`).assign(o,!1).assign(a,w0._`[${a}, ${f}]`).else();t.if(c,()=>{if(t.assign(o,!0),t.assign(a,f),m)e.mergeEvaluated(m,w0.Name)})})}}};wU.default=h8e});var SU=h(function(EU){Object.defineProperty(EU,"__esModule",{value:!0});var y8e=qe(),x8e={keyword:"allOf",schemaType:"array",code(e){let{gen:t,schema:r,it:n}=e;if(!Array.isArray(r))throw Error("ajv implementation error");let i=t.name("valid");r.forEach((s,o)=>{if((0,y8e.alwaysValidSchema)(n,s))return;let a=e.subschema({keyword:"allOf",schemaProp:o},i);e.ok(i),e.mergeEvaluated(a)})}};EU.default=x8e});var FU=h(function(RU){Object.defineProperty(RU,"__esModule",{value:!0});var D0=xe(),CU=qe(),v8e={message:({params:e})=>D0.str`must match "${e.ifClause}" schema`,params:({params:e})=>D0._`{failingKeyword: ${e.ifClause}}`},_8e={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:v8e,code(e){let{gen:t,parentSchema:r,it:n}=e;if(r.then===void 0&&r.else===void 0)(0,CU.checkStrictMode)(n,'"if" without "then" and "else" is ignored');let i=$U(n,"then"),s=$U(n,"else");if(!i&&!s)return;let o=t.let("valid",!0),a=t.name("_valid");if(c(),e.reset(),i&&s){let d=t.let("ifClause");e.setParams({ifClause:d}),t.if(a,u("then",d),u("else",d))}else if(i)t.if(a,u("then"));else t.if((0,D0.not)(a),u("else"));e.pass(o,()=>e.error(!0));function c(){let d=e.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},a);e.mergeEvaluated(d)}function u(d,f){return()=>{let m=e.subschema({keyword:d},a);if(t.assign(o,a),e.mergeValidEvaluated(m,o),f)t.assign(f,D0._`${d}`);else e.setParams({ifClause:d})}}}};function $U(e,t){let r=e.schema[t];return r!==void 0&&!(0,CU.alwaysValidSchema)(e,r)}RU.default=_8e});var AU=h(function(OU){Object.defineProperty(OU,"__esModule",{value:!0});var D8e=qe(),E8e={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:e,parentSchema:t,it:r}){if(t.if===void 0)(0,D8e.checkStrictMode)(r,`"${e}" without "if" is ignored`)}};OU.default=E8e});var PU=h(function(kU){Object.defineProperty(kU,"__esModule",{value:!0});var $8e=sw(),C8e=WL(),R8e=ow(),F8e=JL(),O8e=QL(),A8e=iU(),k8e=aU(),P8e=cw(),I8e=fU(),T8e=yU(),N8e=bU(),q8e=_U(),j8e=DU(),M8e=SU(),B8e=FU(),L8e=AU();function U8e(e=!1){let t=[N8e.default,q8e.default,j8e.default,M8e.default,B8e.default,L8e.default,k8e.default,P8e.default,A8e.default,I8e.default,T8e.default];if(e)t.push(C8e.default,F8e.default);else t.push($8e.default,R8e.default);return t.push(O8e.default),t}kU.default=U8e});var TU=h(function(IU){Object.defineProperty(IU,"__esModule",{value:!0});var xt=xe(),z8e={message:({schemaCode:e})=>xt.str`must match format "${e}"`,params:({schemaCode:e})=>xt._`{format: ${e}}`},H8e={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:z8e,code(e,t){let{gen:r,data:n,$data:i,schema:s,schemaCode:o,it:a}=e,{opts:c,errSchemaPath:u,schemaEnv:d,self:f}=a;if(!c.validateFormats)return;if(i)m();else p();function m(){let g=r.scopeValue("formats",{ref:f.formats,code:c.code.formats}),y=r.const("fDef",xt._`${g}[${o}]`),x=r.let("fType"),v=r.let("format");r.if(xt._`typeof ${y} == "object" && !(${y} instanceof RegExp)`,()=>r.assign(x,xt._`${y}.type || "string"`).assign(v,xt._`${y}.validate`),()=>r.assign(x,xt._`"string"`).assign(v,y)),e.fail$data((0,xt.or)(_(),S()));function _(){if(c.strictSchema===!1)return xt.nil;return xt._`${o} && !${v}`}function S(){let C=d.$async?xt._`(${y}.async ? await ${v}(${n}) : ${v}(${n}))`:xt._`${v}(${n})`,w=xt._`(typeof ${v} == "function" ? ${C} : ${v}.test(${n}))`;return xt._`${v} && ${v} !== true && ${x} === ${t} && !${w}`}}function p(){let g=f.formats[s];if(!g){_();return}if(g===!0)return;let[y,x,v]=S(g);if(y===t)e.pass(C());function _(){if(c.strictSchema===!1){f.logger.warn(w());return}throw Error(w());function w(){return`unknown format "${s}" ignored in schema at path "${u}"`}}function S(w){let A=w instanceof RegExp?(0,xt.regexpCode)(w):c.code.formats?xt._`${c.code.formats}${(0,xt.getProperty)(s)}`:void 0,R=r.scopeValue("formats",{key:s,ref:w,code:A});if(typeof w=="object"&&!(w instanceof RegExp))return[w.type||"string",w.validate,xt._`${R}.validate`];return["string",w,R]}function C(){if(typeof g=="object"&&!(g instanceof RegExp)&&g.async){if(!d.$async)throw Error("async format in sync schema");return xt._`await ${v}(${n})`}return typeof x=="function"?xt._`${v}(${n})`:xt._`${v}.test(${n})`}}}};IU.default=H8e});var qU=h(function(NU){Object.defineProperty(NU,"__esModule",{value:!0});var W8e=TU(),K8e=[W8e.default];NU.default=K8e});var BU=h(function(jU){Object.defineProperty(jU,"__esModule",{value:!0});jU.contentVocabulary=jU.metadataVocabulary=void 0;jU.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];jU.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]});var VU=h(function(UU){Object.defineProperty(UU,"__esModule",{value:!0});var X8e=dL(),Q8e=jL(),Z8e=PU(),eTe=qU(),LU=BU(),tTe=[X8e.default,Q8e.default,(0,Z8e.default)(),eTe.default,LU.metadataVocabulary,LU.contentVocabulary];UU.default=tTe});var WU=h(function(HU){Object.defineProperty(HU,"__esModule",{value:!0});HU.DiscrError=void 0;var zU;(function(e){e.Tag="tag",e.Mapping="mapping"})(zU||(HU.DiscrError=zU={}))});var JU=h(function(YU){Object.defineProperty(YU,"__esModule",{value:!0});var Rc=xe(),lw=WU(),KU=c0(),nTe=od(),iTe=qe(),sTe={message:({params:{discrError:e,tagName:t}})=>e===lw.DiscrError.Tag?`tag "${t}" must be string`:`value of tag "${t}" must be in oneOf`,params:({params:{discrError:e,tag:t,tagName:r}})=>Rc._`{error: ${e}, tag: ${r}, tagValue: ${t}}`},oTe={keyword:"discriminator",type:"object",schemaType:"object",error:sTe,code(e){let{gen:t,data:r,schema:n,parentSchema:i,it:s}=e,{oneOf:o}=i;if(!s.opts.discriminator)throw Error("discriminator: requires discriminator option");let a=n.propertyName;if(typeof a!="string")throw Error("discriminator: requires propertyName");if(n.mapping)throw Error("discriminator: mapping is not supported");if(!o)throw Error("discriminator: requires oneOf keyword");let c=t.let("valid",!1),u=t.const("tag",Rc._`${r}${(0,Rc.getProperty)(a)}`);t.if(Rc._`typeof ${u} == "string"`,()=>d(),()=>e.error(!1,{discrError:lw.DiscrError.Tag,tag:u,tagName:a})),e.ok(c);function d(){let p=m();t.if(!1);for(let g in p)t.elseIf(Rc._`${u} === ${g}`),t.assign(c,f(p[g]));t.else(),e.error(!1,{discrError:lw.DiscrError.Mapping,tag:u,tagName:a}),t.endIf()}function f(p){let g=t.name("valid"),y=e.subschema({keyword:"oneOf",schemaProp:p},g);return e.mergeEvaluated(y,Rc.Name),g}function m(){var p;let g={},y=v(i),x=!0;for(let C=0;C<o.length;C++){let w=o[C];if((w===null||w===void 0?void 0:w.$ref)&&!(0,iTe.schemaHasRulesButRef)(w,s.self.RULES)){let R=w.$ref;if(w=KU.resolveRef.call(s.self,s.schemaEnv.root,s.baseId,R),w instanceof KU.SchemaEnv)w=w.schema;if(w===void 0)throw new nTe.default(s.opts.uriResolver,s.baseId,R)}let A=(p=w===null||w===void 0?void 0:w.properties)===null||p===void 0?void 0:p[a];if(typeof A!="object")throw Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${a}"`);x=x&&(y||v(w)),_(A,C)}if(!x)throw Error(`discriminator: "${a}" must be required`);return g;function v({required:C}){return Array.isArray(C)&&C.includes(a)}function _(C,w){if(C.const)S(C.const,w);else if(C.enum)for(let A of C.enum)S(A,w);else throw Error(`discriminator: "properties/${a}" must have "const" or "enum"`)}function S(C,w){if(typeof C!="string"||C in g)throw Error(`discriminator: "${a}" values must be unique strings`);g[C]=w}}}};YU.default=oTe});var XU=h(function(crt,cTe){cTe.exports={$schema:"http://json-schema.org/draft-07/schema#",$id:"http://json-schema.org/draft-07/schema#",title:"Core schema meta-schema",definitions:{schemaArray:{type:"array",minItems:1,items:{$ref:"#"}},nonNegativeInteger:{type:"integer",minimum:0},nonNegativeIntegerDefault0:{allOf:[{$ref:"#/definitions/nonNegativeInteger"},{default:0}]},simpleTypes:{enum:["array","boolean","integer","null","number","object","string"]},stringArray:{type:"array",items:{type:"string"},uniqueItems:!0,default:[]}},type:["object","boolean"],properties:{$id:{type:"string",format:"uri-reference"},$schema:{type:"string",format:"uri"},$ref:{type:"string",format:"uri-reference"},$comment:{type:"string"},title:{type:"string"},description:{type:"string"},default:!0,readOnly:{type:"boolean",default:!1},examples:{type:"array",items:!0},multipleOf:{type:"number",exclusiveMinimum:0},maximum:{type:"number"},exclusiveMaximum:{type:"number"},minimum:{type:"number"},exclusiveMinimum:{type:"number"},maxLength:{$ref:"#/definitions/nonNegativeInteger"},minLength:{$ref:"#/definitions/nonNegativeIntegerDefault0"},pattern:{type:"string",format:"regex"},additionalItems:{$ref:"#"},items:{anyOf:[{$ref:"#"},{$ref:"#/definitions/schemaArray"}],default:!0},maxItems:{$ref:"#/definitions/nonNegativeInteger"},minItems:{$ref:"#/definitions/nonNegativeIntegerDefault0"},uniqueItems:{type:"boolean",default:!1},contains:{$ref:"#"},maxProperties:{$ref:"#/definitions/nonNegativeInteger"},minProperties:{$ref:"#/definitions/nonNegativeIntegerDefault0"},required:{$ref:"#/definitions/stringArray"},additionalProperties:{$ref:"#"},definitions:{type:"object",additionalProperties:{$ref:"#"},default:{}},properties:{type:"object",additionalProperties:{$ref:"#"},default:{}},patternProperties:{type:"object",additionalProperties:{$ref:"#"},propertyNames:{format:"regex"},default:{}},dependencies:{type:"object",additionalProperties:{anyOf:[{$ref:"#"},{$ref:"#/definitions/stringArray"}]}},propertyNames:{$ref:"#"},const:!0,enum:{type:"array",items:!0,minItems:1,uniqueItems:!0},type:{anyOf:[{$ref:"#/definitions/simpleTypes"},{type:"array",items:{$ref:"#/definitions/simpleTypes"},minItems:1,uniqueItems:!0}]},format:{type:"string"},contentMediaType:{type:"string"},contentEncoding:{type:"string"},if:{$ref:"#"},then:{$ref:"#"},else:{$ref:"#"},allOf:{$ref:"#/definitions/schemaArray"},anyOf:{$ref:"#/definitions/schemaArray"},oneOf:{$ref:"#/definitions/schemaArray"},not:{$ref:"#"}},default:!0}});var ZU=h(function(Sr,dw){Object.defineProperty(Sr,"__esModule",{value:!0});Sr.MissingRefError=Sr.ValidationError=Sr.CodeGen=Sr.Name=Sr.nil=Sr.stringify=Sr.str=Sr._=Sr.KeywordCxt=Sr.Ajv=void 0;var uTe=tL(),lTe=VU(),dTe=JU(),QU=XU(),fTe=["/properties"],E0="http://json-schema.org/draft-07/schema";class yd extends uTe.default{_addVocabularies(){if(super._addVocabularies(),lTe.default.forEach((e)=>this.addVocabulary(e)),this.opts.discriminator)this.addKeyword(dTe.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let e=this.opts.$data?this.$dataMetaSchema(QU,fTe):QU;this.addMetaSchema(e,E0,!1),this.refs["http://json-schema.org/schema"]=E0}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(E0)?E0:void 0)}}Sr.Ajv=yd;dw.exports=Sr=yd;dw.exports.Ajv=yd;Object.defineProperty(Sr,"__esModule",{value:!0});Sr.default=yd;var pTe=sd();Object.defineProperty(Sr,"KeywordCxt",{enumerable:!0,get:function(){return pTe.KeywordCxt}});var Fc=xe();Object.defineProperty(Sr,"_",{enumerable:!0,get:function(){return Fc._}});Object.defineProperty(Sr,"str",{enumerable:!0,get:function(){return Fc.str}});Object.defineProperty(Sr,"stringify",{enumerable:!0,get:function(){return Fc.stringify}});Object.defineProperty(Sr,"nil",{enumerable:!0,get:function(){return Fc.nil}});Object.defineProperty(Sr,"Name",{enumerable:!0,get:function(){return Fc.Name}});Object.defineProperty(Sr,"CodeGen",{enumerable:!0,get:function(){return Fc.CodeGen}});var mTe=o0();Object.defineProperty(Sr,"ValidationError",{enumerable:!0,get:function(){return mTe.default}});var hTe=od();Object.defineProperty(Sr,"MissingRefError",{enumerable:!0,get:function(){return hTe.default}})});var tV=h(function(eV){Object.defineProperty(eV,"__esModule",{value:!0});eV.formatLimitDefinition=void 0;var xTe=ZU(),$n=xe(),Ls=$n.operators,S0={formatMaximum:{okStr:"<=",ok:Ls.LTE,fail:Ls.GT},formatMinimum:{okStr:">=",ok:Ls.GTE,fail:Ls.LT},formatExclusiveMaximum:{okStr:"<",ok:Ls.LT,fail:Ls.GTE},formatExclusiveMinimum:{okStr:">",ok:Ls.GT,fail:Ls.LTE}},bTe={message:({keyword:e,schemaCode:t})=>$n.str`should be ${S0[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>$n._`{comparison: ${S0[e].okStr}, limit: ${t}}`};eV.formatLimitDefinition={keyword:Object.keys(S0),type:"string",schemaType:"string",$data:!0,error:bTe,code(e){let{gen:t,data:r,schemaCode:n,keyword:i,it:s}=e,{opts:o,self:a}=s;if(!o.validateFormats)return;let c=new xTe.KeywordCxt(s,a.RULES.all.format.definition,"format");if(c.$data)u();else d();function u(){let m=t.scopeValue("formats",{ref:a.formats,code:o.code.formats}),p=t.const("fmt",$n._`${m}[${c.schemaCode}]`);e.fail$data((0,$n.or)($n._`typeof ${p} != "object"`,$n._`${p} instanceof RegExp`,$n._`typeof ${p}.compare != "function"`,f(p)))}function d(){let m=c.schema,p=a.formats[m];if(!p||p===!0)return;if(typeof p!="object"||p instanceof RegExp||typeof p.compare!="function")throw Error(`"${i}": format "${m}" does not define "compare" function`);let g=t.scopeValue("formats",{key:m,ref:p,code:o.code.formats?$n._`${o.code.formats}${(0,$n.getProperty)(m)}`:void 0});e.fail$data(f(g))}function f(m){return $n._`${m}.compare(${r}, ${n}) ${S0[i].fail} 0`}},dependencies:["format"]};var vTe=(e)=>(e.addKeyword(eV.formatLimitDefinition),e);eV.default=vTe});var sV=h(function(xd,iV){Object.defineProperty(xd,"__esModule",{value:!0});var Oc=Zj(),wTe=tV(),pw=xe(),rV=new pw.Name("fullFormats"),DTe=new pw.Name("fastFormats"),mw=(e,t={keywords:!0})=>{if(Array.isArray(t))return nV(e,t,Oc.fullFormats,rV),e;let[r,n]=t.mode==="fast"?[Oc.fastFormats,DTe]:[Oc.fullFormats,rV],i=t.formats||Oc.formatNames;if(nV(e,i,r,n),t.keywords)(0,wTe.default)(e);return e};mw.get=(e,t="full")=>{let n=(t==="fast"?Oc.fastFormats:Oc.fullFormats)[e];if(!n)throw Error(`Unknown format "${e}"`);return n};function nV(e,t,r,n){var i,s;(i=(s=e.opts.code).formats)!==null&&i!==void 0||(s.formats=pw._`require("ajv-formats/dist/formats").${n}`);for(let o of t)e.addFormat(o,r[o])}iV.exports=xd=mw;Object.defineProperty(xd,"__esModule",{value:!0});xd.default=mw});var ETe=(e,t={})=>{if(typeof e!=="function")throw TypeError(`Expected the first argument to be a function, got \`${typeof e}\``);let{wait:r=0,maxWait:n=Number.POSITIVE_INFINITY,before:i=!1,after:s=!0}=t;if(r<0||n<0)throw RangeError("`wait` and `maxWait` must not be negative.");if(!i&&!s)throw Error("Both `before` and `after` are false, function wouldn't be called.");let o,a,c,u=function(...d){let f=this,m=()=>{if(o=void 0,a)clearTimeout(a),a=void 0;if(s)c=e.apply(f,d)},p=()=>{if(a=void 0,o)clearTimeout(o),o=void 0;if(s)c=e.apply(f,d)},g=i&&!o;if(clearTimeout(o),o=setTimeout(m,r),n>0&&n!==Number.POSITIVE_INFINITY&&!a)a=setTimeout(p,n);if(g)c=e.apply(f,d);return c};return vl(u,e),u.cancel=()=>{if(o)clearTimeout(o),o=void 0;if(a)clearTimeout(a),a=void 0},u},hw;var oV=O(()=>{Hb();hw=ETe});var bd=h(function(vrt,aV){var STe=Number.MAX_SAFE_INTEGER||9007199254740991,$Te=["major","premajor","minor","preminor","patch","prepatch","prerelease"];aV.exports={MAX_LENGTH:256,MAX_SAFE_COMPONENT_LENGTH:16,MAX_SAFE_BUILD_LENGTH:250,MAX_SAFE_INTEGER:STe,RELEASE_TYPES:$Te,SEMVER_SPEC_VERSION:"2.0.0",FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2}});var vd=h(function(_rt,cV){var CTe=typeof process==="object"&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...e)=>console.error("SEMVER",...e):()=>{};cV.exports=CTe});var Ac=h(function(ui,uV){var{MAX_SAFE_COMPONENT_LENGTH:gw,MAX_SAFE_BUILD_LENGTH:RTe,MAX_LENGTH:FTe}=bd(),OTe=vd();ui=uV.exports={};var ATe=ui.re=[],kTe=ui.safeRe=[],z=ui.src=[],PTe=ui.safeSrc=[],H=ui.t={},ITe=0,yw="[a-zA-Z0-9-]",TTe=[["\\s",1],["\\d",FTe],[yw,RTe]],NTe=(e)=>{for(let[t,r]of TTe)e=e.split(`${t}*`).join(`${t}{0,${r}}`).split(`${t}+`).join(`${t}{1,${r}}`);return e},ce=(e,t,r)=>{let n=NTe(t),i=ITe++;OTe(e,i,t),H[e]=i,z[i]=t,PTe[i]=n,ATe[i]=new RegExp(t,r?"g":void 0),kTe[i]=new RegExp(n,r?"g":void 0)};ce("NUMERICIDENTIFIER","0|[1-9]\\d*");ce("NUMERICIDENTIFIERLOOSE","\\d+");ce("NONNUMERICIDENTIFIER",`\\d*[a-zA-Z-]${yw}*`);ce("MAINVERSION",`(${z[H.NUMERICIDENTIFIER]})\\.(${z[H.NUMERICIDENTIFIER]})\\.(${z[H.NUMERICIDENTIFIER]})`);ce("MAINVERSIONLOOSE",`(${z[H.NUMERICIDENTIFIERLOOSE]})\\.(${z[H.NUMERICIDENTIFIERLOOSE]})\\.(${z[H.NUMERICIDENTIFIERLOOSE]})`);ce("PRERELEASEIDENTIFIER",`(?:${z[H.NONNUMERICIDENTIFIER]}|${z[H.NUMERICIDENTIFIER]})`);ce("PRERELEASEIDENTIFIERLOOSE",`(?:${z[H.NONNUMERICIDENTIFIER]}|${z[H.NUMERICIDENTIFIERLOOSE]})`);ce("PRERELEASE",`(?:-(${z[H.PRERELEASEIDENTIFIER]}(?:\\.${z[H.PRERELEASEIDENTIFIER]})*))`);ce("PRERELEASELOOSE",`(?:-?(${z[H.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${z[H.PRERELEASEIDENTIFIERLOOSE]})*))`);ce("BUILDIDENTIFIER",`${yw}+`);ce("BUILD",`(?:\\+(${z[H.BUILDIDENTIFIER]}(?:\\.${z[H.BUILDIDENTIFIER]})*))`);ce("FULLPLAIN",`v?${z[H.MAINVERSION]}${z[H.PRERELEASE]}?${z[H.BUILD]}?`);ce("FULL",`^${z[H.FULLPLAIN]}$`);ce("LOOSEPLAIN",`[v=\\s]*${z[H.MAINVERSIONLOOSE]}${z[H.PRERELEASELOOSE]}?${z[H.BUILD]}?`);ce("LOOSE",`^${z[H.LOOSEPLAIN]}$`);ce("GTLT","((?:<|>)?=?)");ce("XRANGEIDENTIFIERLOOSE",`${z[H.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);ce("XRANGEIDENTIFIER",`${z[H.NUMERICIDENTIFIER]}|x|X|\\*`);ce("XRANGEPLAIN",`[v=\\s]*(${z[H.XRANGEIDENTIFIER]})(?:\\.(${z[H.XRANGEIDENTIFIER]})(?:\\.(${z[H.XRANGEIDENTIFIER]})(?:${z[H.PRERELEASE]})?${z[H.BUILD]}?)?)?`);ce("XRANGEPLAINLOOSE",`[v=\\s]*(${z[H.XRANGEIDENTIFIERLOOSE]})(?:\\.(${z[H.XRANGEIDENTIFIERLOOSE]})(?:\\.(${z[H.XRANGEIDENTIFIERLOOSE]})(?:${z[H.PRERELEASELOOSE]})?${z[H.BUILD]}?)?)?`);ce("XRANGE",`^${z[H.GTLT]}\\s*${z[H.XRANGEPLAIN]}$`);ce("XRANGELOOSE",`^${z[H.GTLT]}\\s*${z[H.XRANGEPLAINLOOSE]}$`);ce("COERCEPLAIN",`(^|[^\\d])(\\d{1,${gw}})(?:\\.(\\d{1,${gw}}))?(?:\\.(\\d{1,${gw}}))?`);ce("COERCE",`${z[H.COERCEPLAIN]}(?:$|[^\\d])`);ce("COERCEFULL",z[H.COERCEPLAIN]+`(?:${z[H.PRERELEASE]})?(?:${z[H.BUILD]})?(?:$|[^\\d])`);ce("COERCERTL",z[H.COERCE],!0);ce("COERCERTLFULL",z[H.COERCEFULL],!0);ce("LONETILDE","(?:~>?)");ce("TILDETRIM",`(\\s*)${z[H.LONETILDE]}\\s+`,!0);ui.tildeTrimReplace="$1~";ce("TILDE",`^${z[H.LONETILDE]}${z[H.XRANGEPLAIN]}$`);ce("TILDELOOSE",`^${z[H.LONETILDE]}${z[H.XRANGEPLAINLOOSE]}$`);ce("LONECARET","(?:\\^)");ce("CARETTRIM",`(\\s*)${z[H.LONECARET]}\\s+`,!0);ui.caretTrimReplace="$1^";ce("CARET",`^${z[H.LONECARET]}${z[H.XRANGEPLAIN]}$`);ce("CARETLOOSE",`^${z[H.LONECARET]}${z[H.XRANGEPLAINLOOSE]}$`);ce("COMPARATORLOOSE",`^${z[H.GTLT]}\\s*(${z[H.LOOSEPLAIN]})$|^$`);ce("COMPARATOR",`^${z[H.GTLT]}\\s*(${z[H.FULLPLAIN]})$|^$`);ce("COMPARATORTRIM",`(\\s*)${z[H.GTLT]}\\s*(${z[H.LOOSEPLAIN]}|${z[H.XRANGEPLAIN]})`,!0);ui.comparatorTrimReplace="$1$2$3";ce("HYPHENRANGE",`^\\s*(${z[H.XRANGEPLAIN]})\\s+-\\s+(${z[H.XRANGEPLAIN]})\\s*$`);ce("HYPHENRANGELOOSE",`^\\s*(${z[H.XRANGEPLAINLOOSE]})\\s+-\\s+(${z[H.XRANGEPLAINLOOSE]})\\s*$`);ce("STAR","(<|>)?=?\\s*\\*");ce("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$");ce("GTE0PRE","^\\s*>=\\s*0\\.0\\.0-0\\s*$")});var $0=h(function(wrt,lV){var qTe=Object.freeze({loose:!0}),jTe=Object.freeze({}),MTe=(e)=>{if(!e)return jTe;if(typeof e!=="object")return qTe;return e};lV.exports=MTe});var xw=h(function(Drt,pV){var dV=/^[0-9]+$/,fV=(e,t)=>{if(typeof e==="number"&&typeof t==="number")return e===t?0:e<t?-1:1;let r=dV.test(e),n=dV.test(t);if(r&&n)e=+e,t=+t;return e===t?0:r&&!n?-1:n&&!r?1:e<t?-1:1},BTe=(e,t)=>fV(t,e);pV.exports={compareIdentifiers:fV,rcompareIdentifiers:BTe}});var Gt=h(function(Ert,hV){var C0=vd(),{MAX_LENGTH:mV,MAX_SAFE_INTEGER:R0}=bd(),{safeRe:F0,t:O0}=Ac(),LTe=$0(),{compareIdentifiers:bw}=xw();class Cn{constructor(e,t){if(t=LTe(t),e instanceof Cn)if(e.loose===!!t.loose&&e.includePrerelease===!!t.includePrerelease)return e;else e=e.version;else if(typeof e!=="string")throw TypeError(`Invalid version. Must be a string. Got type "${typeof e}".`);if(e.length>mV)throw TypeError(`version is longer than ${mV} characters`);C0("SemVer",e,t),this.options=t,this.loose=!!t.loose,this.includePrerelease=!!t.includePrerelease;let r=e.trim().match(t.loose?F0[O0.LOOSE]:F0[O0.FULL]);if(!r)throw TypeError(`Invalid Version: ${e}`);if(this.raw=e,this.major=+r[1],this.minor=+r[2],this.patch=+r[3],this.major>R0||this.major<0)throw TypeError("Invalid major version");if(this.minor>R0||this.minor<0)throw TypeError("Invalid minor version");if(this.patch>R0||this.patch<0)throw TypeError("Invalid patch version");if(!r[4])this.prerelease=[];else this.prerelease=r[4].split(".").map((n)=>{if(/^[0-9]+$/.test(n)){let i=+n;if(i>=0&&i<R0)return i}return n});this.build=r[5]?r[5].split("."):[],this.format()}format(){if(this.version=`${this.major}.${this.minor}.${this.patch}`,this.prerelease.length)this.version+=`-${this.prerelease.join(".")}`;return this.version}toString(){return this.version}compare(e){if(C0("SemVer.compare",this.version,this.options,e),!(e instanceof Cn)){if(typeof e==="string"&&e===this.version)return 0;e=new Cn(e,this.options)}if(e.version===this.version)return 0;return this.compareMain(e)||this.comparePre(e)}compareMain(e){if(!(e instanceof Cn))e=new Cn(e,this.options);if(this.major<e.major)return-1;if(this.major>e.major)return 1;if(this.minor<e.minor)return-1;if(this.minor>e.minor)return 1;if(this.patch<e.patch)return-1;if(this.patch>e.patch)return 1;return 0}comparePre(e){if(!(e instanceof Cn))e=new Cn(e,this.options);if(this.prerelease.length&&!e.prerelease.length)return-1;else if(!this.prerelease.length&&e.prerelease.length)return 1;else if(!this.prerelease.length&&!e.prerelease.length)return 0;let t=0;do{let r=this.prerelease[t],n=e.prerelease[t];if(C0("prerelease compare",t,r,n),r===void 0&&n===void 0)return 0;else if(n===void 0)return 1;else if(r===void 0)return-1;else if(r===n)continue;else return bw(r,n)}while(++t)}compareBuild(e){if(!(e instanceof Cn))e=new Cn(e,this.options);let t=0;do{let r=this.build[t],n=e.build[t];if(C0("build compare",t,r,n),r===void 0&&n===void 0)return 0;else if(n===void 0)return 1;else if(r===void 0)return-1;else if(r===n)continue;else return bw(r,n)}while(++t)}inc(e,t,r){if(e.startsWith("pre")){if(!t&&r===!1)throw Error("invalid increment argument: identifier is empty");if(t){let n=`-${t}`.match(this.options.loose?F0[O0.PRERELEASELOOSE]:F0[O0.PRERELEASE]);if(!n||n[1]!==t)throw Error(`invalid identifier: ${t}`)}}switch(e){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",t,r);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",t,r);break;case"prepatch":this.prerelease.length=0,this.inc("patch",t,r),this.inc("pre",t,r);break;case"prerelease":if(this.prerelease.length===0)this.inc("patch",t,r);this.inc("pre",t,r);break;case"release":if(this.prerelease.length===0)throw Error(`version ${this.raw} is not a prerelease`);this.prerelease.length=0;break;case"major":if(this.minor!==0||this.patch!==0||this.prerelease.length===0)this.major++;this.minor=0,this.patch=0,this.prerelease=[];break;case"minor":if(this.patch!==0||this.prerelease.length===0)this.minor++;this.patch=0,this.prerelease=[];break;case"patch":if(this.prerelease.length===0)this.patch++;this.prerelease=[];break;case"pre":{let n=Number(r)?1:0;if(this.prerelease.length===0)this.prerelease=[n];else{let i=this.prerelease.length;while(--i>=0)if(typeof this.prerelease[i]==="number")this.prerelease[i]++,i=-2;if(i===-1){if(t===this.prerelease.join(".")&&r===!1)throw Error("invalid increment argument: identifier already exists");this.prerelease.push(n)}}if(t){let i=[t,n];if(r===!1)i=[t];if(bw(this.prerelease[0],t)===0){if(isNaN(this.prerelease[1]))this.prerelease=i}else this.prerelease=i}break}default:throw Error(`invalid increment argument: ${e}`)}if(this.raw=this.format(),this.build.length)this.raw+=`+${this.build.join(".")}`;return this}}hV.exports=Cn});var Mo=h(function(Srt,yV){var gV=Gt(),UTe=(e,t,r=!1)=>{if(e instanceof gV)return e;try{return new gV(e,t)}catch(n){if(!r)return null;throw n}};yV.exports=UTe});var bV=h(function($rt,xV){var VTe=Mo(),zTe=(e,t)=>{let r=VTe(e,t);return r?r.version:null};xV.exports=zTe});var _V=h(function(Crt,vV){var HTe=Mo(),GTe=(e,t)=>{let r=HTe(e.trim().replace(/^[=v]+/,""),t);return r?r.version:null};vV.exports=GTe});var EV=h(function(Rrt,DV){var wV=Gt(),WTe=(e,t,r,n,i)=>{if(typeof r==="string")i=n,n=r,r=void 0;try{return new wV(e instanceof wV?e.version:e,r).inc(t,n,i).version}catch(s){return null}};DV.exports=WTe});var CV=h(function(Frt,$V){var SV=Mo(),KTe=(e,t)=>{let r=SV(e,null,!0),n=SV(t,null,!0),i=r.compare(n);if(i===0)return null;let s=i>0,o=s?r:n,a=s?n:r,c=!!o.prerelease.length;if(!!a.prerelease.length&&!c){if(!a.patch&&!a.minor)return"major";if(a.compareMain(o)===0){if(a.minor&&!a.patch)return"minor";return"patch"}}let d=c?"pre":"";if(r.major!==n.major)return d+"major";if(r.minor!==n.minor)return d+"minor";if(r.patch!==n.patch)return d+"patch";return"prerelease"};$V.exports=KTe});var FV=h(function(Ort,RV){var YTe=Gt(),JTe=(e,t)=>new YTe(e,t).major;RV.exports=JTe});var AV=h(function(Art,OV){var XTe=Gt(),QTe=(e,t)=>new XTe(e,t).minor;OV.exports=QTe});var PV=h(function(krt,kV){var ZTe=Gt(),e4e=(e,t)=>new ZTe(e,t).patch;kV.exports=e4e});var TV=h(function(Prt,IV){var t4e=Mo(),r4e=(e,t)=>{let r=t4e(e,t);return r&&r.prerelease.length?r.prerelease:null};IV.exports=r4e});var en=h(function(Irt,qV){var NV=Gt(),n4e=(e,t,r)=>new NV(e,r).compare(new NV(t,r));qV.exports=n4e});var MV=h(function(Trt,jV){var i4e=en(),s4e=(e,t,r)=>i4e(t,e,r);jV.exports=s4e});var LV=h(function(Nrt,BV){var o4e=en(),a4e=(e,t)=>o4e(e,t,!0);BV.exports=a4e});var A0=h(function(qrt,VV){var UV=Gt(),c4e=(e,t,r)=>{let n=new UV(e,r),i=new UV(t,r);return n.compare(i)||n.compareBuild(i)};VV.exports=c4e});var HV=h(function(jrt,zV){var u4e=A0(),l4e=(e,t)=>e.sort((r,n)=>u4e(r,n,t));zV.exports=l4e});var WV=h(function(Mrt,GV){var d4e=A0(),f4e=(e,t)=>e.sort((r,n)=>d4e(n,r,t));GV.exports=f4e});var _d=h(function(Brt,KV){var p4e=en(),m4e=(e,t,r)=>p4e(e,t,r)>0;KV.exports=m4e});var k0=h(function(Lrt,YV){var h4e=en(),g4e=(e,t,r)=>h4e(e,t,r)<0;YV.exports=g4e});var vw=h(function(Urt,JV){var y4e=en(),x4e=(e,t,r)=>y4e(e,t,r)===0;JV.exports=x4e});var _w=h(function(Vrt,XV){var b4e=en(),v4e=(e,t,r)=>b4e(e,t,r)!==0;XV.exports=v4e});var P0=h(function(zrt,QV){var _4e=en(),w4e=(e,t,r)=>_4e(e,t,r)>=0;QV.exports=w4e});var I0=h(function(Hrt,ZV){var D4e=en(),E4e=(e,t,r)=>D4e(e,t,r)<=0;ZV.exports=E4e});var ww=h(function(Grt,ez){var S4e=vw(),$4e=_w(),C4e=_d(),R4e=P0(),F4e=k0(),O4e=I0(),A4e=(e,t,r,n)=>{switch(t){case"===":if(typeof e==="object")e=e.version;if(typeof r==="object")r=r.version;return e===r;case"!==":if(typeof e==="object")e=e.version;if(typeof r==="object")r=r.version;return e!==r;case"":case"=":case"==":return S4e(e,r,n);case"!=":return $4e(e,r,n);case">":return C4e(e,r,n);case">=":return R4e(e,r,n);case"<":return F4e(e,r,n);case"<=":return O4e(e,r,n);default:throw TypeError(`Invalid operator: ${t}`)}};ez.exports=A4e});var rz=h(function(Wrt,tz){var k4e=Gt(),P4e=Mo(),{safeRe:T0,t:N0}=Ac(),I4e=(e,t)=>{if(e instanceof k4e)return e;if(typeof e==="number")e=String(e);if(typeof e!=="string")return null;t=t||{};let r=null;if(!t.rtl)r=e.match(t.includePrerelease?T0[N0.COERCEFULL]:T0[N0.COERCE]);else{let c=t.includePrerelease?T0[N0.COERCERTLFULL]:T0[N0.COERCERTL],u;while((u=c.exec(e))&&(!r||r.index+r[0].length!==e.length)){if(!r||u.index+u[0].length!==r.index+r[0].length)r=u;c.lastIndex=u.index+u[1].length+u[2].length}c.lastIndex=-1}if(r===null)return null;let n=r[2],i=r[3]||"0",s=r[4]||"0",o=t.includePrerelease&&r[5]?`-${r[5]}`:"",a=t.includePrerelease&&r[6]?`+${r[6]}`:"";return P4e(`${n}.${i}.${s}${o}${a}`,t)};tz.exports=I4e});var sz=h(function(Krt,iz){class nz{constructor(){this.max=1000,this.map=new Map}get(e){let t=this.map.get(e);if(t===void 0)return;else return this.map.delete(e),this.map.set(e,t),t}delete(e){return this.map.delete(e)}set(e,t){if(!this.delete(e)&&t!==void 0){if(this.map.size>=this.max){let n=this.map.keys().next().value;this.delete(n)}this.map.set(e,t)}return this}}iz.exports=nz});var tn=h(function(Yrt,uz){var T4e=/\s+/g;class wd{constructor(e,t){if(t=q4e(t),e instanceof wd)if(e.loose===!!t.loose&&e.includePrerelease===!!t.includePrerelease)return e;else return new wd(e.raw,t);if(e instanceof Dw)return this.raw=e.value,this.set=[[e]],this.formatted=void 0,this;if(this.options=t,this.loose=!!t.loose,this.includePrerelease=!!t.includePrerelease,this.raw=e.trim().replace(T4e," "),this.set=this.raw.split("||").map((r)=>this.parseRange(r.trim())).filter((r)=>r.length),!this.set.length)throw TypeError(`Invalid SemVer Range: ${this.raw}`);if(this.set.length>1){let r=this.set[0];if(this.set=this.set.filter((n)=>!az(n[0])),this.set.length===0)this.set=[r];else if(this.set.length>1){for(let n of this.set)if(n.length===1&&z4e(n[0])){this.set=[n];break}}}this.formatted=void 0}get range(){if(this.formatted===void 0){this.formatted="";for(let e=0;e<this.set.length;e++){if(e>0)this.formatted+="||";let t=this.set[e];for(let r=0;r<t.length;r++){if(r>0)this.formatted+=" ";this.formatted+=t[r].toString().trim()}}}return this.formatted}format(){return this.range}toString(){return this.range}parseRange(e){let r=((this.options.includePrerelease&&U4e)|(this.options.loose&&V4e))+":"+e,n=oz.get(r);if(n)return n;let i=this.options.loose,s=i?sr[Wt.HYPHENRANGELOOSE]:sr[Wt.HYPHENRANGE];e=e.replace(s,e3e(this.options.includePrerelease)),nt("hyphen replace",e),e=e.replace(sr[Wt.COMPARATORTRIM],M4e),nt("comparator trim",e),e=e.replace(sr[Wt.TILDETRIM],B4e),nt("tilde trim",e),e=e.replace(sr[Wt.CARETTRIM],L4e),nt("caret trim",e);let o=e.split(" ").map((d)=>H4e(d,this.options)).join(" ").split(/\s+/).map((d)=>Z4e(d,this.options));if(i)o=o.filter((d)=>(nt("loose invalid filter",d,this.options),!!d.match(sr[Wt.COMPARATORLOOSE])));nt("range list",o);let a=new Map,c=o.map((d)=>new Dw(d,this.options));for(let d of c){if(az(d))return[d];a.set(d.value,d)}if(a.size>1&&a.has(""))a.delete("");let u=[...a.values()];return oz.set(r,u),u}intersects(e,t){if(!(e instanceof wd))throw TypeError("a Range is required");return this.set.some((r)=>cz(r,t)&&e.set.some((n)=>cz(n,t)&&r.every((i)=>n.every((s)=>i.intersects(s,t)))))}test(e){if(!e)return!1;if(typeof e==="string")try{e=new j4e(e,this.options)}catch(t){return!1}for(let t=0;t<this.set.length;t++)if(t3e(this.set[t],e,this.options))return!0;return!1}}uz.exports=wd;var N4e=sz(),oz=new N4e,q4e=$0(),Dw=Dd(),nt=vd(),j4e=Gt(),{safeRe:sr,t:Wt,comparatorTrimReplace:M4e,tildeTrimReplace:B4e,caretTrimReplace:L4e}=Ac(),{FLAG_INCLUDE_PRERELEASE:U4e,FLAG_LOOSE:V4e}=bd(),az=(e)=>e.value==="<0.0.0-0",z4e=(e)=>e.value==="",cz=(e,t)=>{let r=!0,n=e.slice(),i=n.pop();while(r&&n.length)r=n.every((s)=>i.intersects(s,t)),i=n.pop();return r},H4e=(e,t)=>(e=e.replace(sr[Wt.BUILD],""),nt("comp",e,t),e=K4e(e,t),nt("caret",e),e=G4e(e,t),nt("tildes",e),e=J4e(e,t),nt("xrange",e),e=Q4e(e,t),nt("stars",e),e),or=(e)=>!e||e.toLowerCase()==="x"||e==="*",G4e=(e,t)=>e.trim().split(/\s+/).map((r)=>W4e(r,t)).join(" "),W4e=(e,t)=>{let r=t.loose?sr[Wt.TILDELOOSE]:sr[Wt.TILDE];return e.replace(r,(n,i,s,o,a)=>{nt("tilde",e,n,i,s,o,a);let c;if(or(i))c="";else if(or(s))c=`>=${i}.0.0 <${+i+1}.0.0-0`;else if(or(o))c=`>=${i}.${s}.0 <${i}.${+s+1}.0-0`;else if(a)nt("replaceTilde pr",a),c=`>=${i}.${s}.${o}-${a} <${i}.${+s+1}.0-0`;else c=`>=${i}.${s}.${o} <${i}.${+s+1}.0-0`;return nt("tilde return",c),c})},K4e=(e,t)=>e.trim().split(/\s+/).map((r)=>Y4e(r,t)).join(" "),Y4e=(e,t)=>{nt("caret",e,t);let r=t.loose?sr[Wt.CARETLOOSE]:sr[Wt.CARET],n=t.includePrerelease?"-0":"";return e.replace(r,(i,s,o,a,c)=>{nt("caret",e,i,s,o,a,c);let u;if(or(s))u="";else if(or(o))u=`>=${s}.0.0${n} <${+s+1}.0.0-0`;else if(or(a))if(s==="0")u=`>=${s}.${o}.0${n} <${s}.${+o+1}.0-0`;else u=`>=${s}.${o}.0${n} <${+s+1}.0.0-0`;else if(c)if(nt("replaceCaret pr",c),s==="0")if(o==="0")u=`>=${s}.${o}.${a}-${c} <${s}.${o}.${+a+1}-0`;else u=`>=${s}.${o}.${a}-${c} <${s}.${+o+1}.0-0`;else u=`>=${s}.${o}.${a}-${c} <${+s+1}.0.0-0`;else if(nt("no pr"),s==="0")if(o==="0")u=`>=${s}.${o}.${a}${n} <${s}.${o}.${+a+1}-0`;else u=`>=${s}.${o}.${a}${n} <${s}.${+o+1}.0-0`;else u=`>=${s}.${o}.${a} <${+s+1}.0.0-0`;return nt("caret return",u),u})},J4e=(e,t)=>(nt("replaceXRanges",e,t),e.split(/\s+/).map((r)=>X4e(r,t)).join(" ")),X4e=(e,t)=>{e=e.trim();let r=t.loose?sr[Wt.XRANGELOOSE]:sr[Wt.XRANGE];return e.replace(r,(n,i,s,o,a,c)=>{nt("xRange",e,n,i,s,o,a,c);let u=or(s),d=u||or(o),f=d||or(a),m=f;if(i==="="&&m)i="";if(c=t.includePrerelease?"-0":"",u)if(i===">"||i==="<")n="<0.0.0-0";else n="*";else if(i&&m){if(d)o=0;if(a=0,i===">")if(i=">=",d)s=+s+1,o=0,a=0;else o=+o+1,a=0;else if(i==="<=")if(i="<",d)s=+s+1;else o=+o+1;if(i==="<")c="-0";n=`${i+s}.${o}.${a}${c}`}else if(d)n=`>=${s}.0.0${c} <${+s+1}.0.0-0`;else if(f)n=`>=${s}.${o}.0${c} <${s}.${+o+1}.0-0`;return nt("xRange return",n),n})},Q4e=(e,t)=>(nt("replaceStars",e,t),e.trim().replace(sr[Wt.STAR],"")),Z4e=(e,t)=>(nt("replaceGTE0",e,t),e.trim().replace(sr[t.includePrerelease?Wt.GTE0PRE:Wt.GTE0],"")),e3e=(e)=>(t,r,n,i,s,o,a,c,u,d,f,m)=>{if(or(n))r="";else if(or(i))r=`>=${n}.0.0${e?"-0":""}`;else if(or(s))r=`>=${n}.${i}.0${e?"-0":""}`;else if(o)r=`>=${r}`;else r=`>=${r}${e?"-0":""}`;if(or(u))c="";else if(or(d))c=`<${+u+1}.0.0-0`;else if(or(f))c=`<${u}.${+d+1}.0-0`;else if(m)c=`<=${u}.${d}.${f}-${m}`;else if(e)c=`<${u}.${d}.${+f+1}-0`;else c=`<=${c}`;return`${r} ${c}`.trim()},t3e=(e,t,r)=>{for(let n=0;n<e.length;n++)if(!e[n].test(t))return!1;if(t.prerelease.length&&!r.includePrerelease){for(let n=0;n<e.length;n++){if(nt(e[n].semver),e[n].semver===Dw.ANY)continue;if(e[n].semver.prerelease.length>0){let i=e[n].semver;if(i.major===t.major&&i.minor===t.minor&&i.patch===t.patch)return!0}}return!1}return!0}});var Dd=h(function(Jrt,hz){var Ed=Symbol("SemVer ANY");class q0{static get ANY(){return Ed}constructor(e,t){if(t=lz(t),e instanceof q0)if(e.loose===!!t.loose)return e;else e=e.value;if(e=e.trim().split(/\s+/).join(" "),Sw("comparator",e,t),this.options=t,this.loose=!!t.loose,this.parse(e),this.semver===Ed)this.value="";else this.value=this.operator+this.semver.version;Sw("comp",this)}parse(e){let t=this.options.loose?dz[fz.COMPARATORLOOSE]:dz[fz.COMPARATOR],r=e.match(t);if(!r)throw TypeError(`Invalid comparator: ${e}`);if(this.operator=r[1]!==void 0?r[1]:"",this.operator==="=")this.operator="";if(!r[2])this.semver=Ed;else this.semver=new pz(r[2],this.options.loose)}toString(){return this.value}test(e){if(Sw("Comparator.test",e,this.options.loose),this.semver===Ed||e===Ed)return!0;if(typeof e==="string")try{e=new pz(e,this.options)}catch(t){return!1}return Ew(e,this.operator,this.semver,this.options)}intersects(e,t){if(!(e instanceof q0))throw TypeError("a Comparator is required");if(this.operator===""){if(this.value==="")return!0;return new mz(e.value,t).test(this.value)}else if(e.operator===""){if(e.value==="")return!0;return new mz(this.value,t).test(e.semver)}if(t=lz(t),t.includePrerelease&&(this.value==="<0.0.0-0"||e.value==="<0.0.0-0"))return!1;if(!t.includePrerelease&&(this.value.startsWith("<0.0.0")||e.value.startsWith("<0.0.0")))return!1;if(this.operator.startsWith(">")&&e.operator.startsWith(">"))return!0;if(this.operator.startsWith("<")&&e.operator.startsWith("<"))return!0;if(this.semver.version===e.semver.version&&this.operator.includes("=")&&e.operator.includes("="))return!0;if(Ew(this.semver,"<",e.semver,t)&&this.operator.startsWith(">")&&e.operator.startsWith("<"))return!0;if(Ew(this.semver,">",e.semver,t)&&this.operator.startsWith("<")&&e.operator.startsWith(">"))return!0;return!1}}hz.exports=q0;var lz=$0(),{safeRe:dz,t:fz}=Ac(),Ew=ww(),Sw=vd(),pz=Gt(),mz=tn()});var Sd=h(function(Xrt,gz){var r3e=tn(),n3e=(e,t,r)=>{try{t=new r3e(t,r)}catch(n){return!1}return t.test(e)};gz.exports=n3e});var xz=h(function(Qrt,yz){var i3e=tn(),s3e=(e,t)=>new i3e(e,t).set.map((r)=>r.map((n)=>n.value).join(" ").trim().split(" "));yz.exports=s3e});var vz=h(function(Zrt,bz){var o3e=Gt(),a3e=tn(),c3e=(e,t,r)=>{let n=null,i=null,s=null;try{s=new a3e(t,r)}catch(o){return null}return e.forEach((o)=>{if(s.test(o)){if(!n||i.compare(o)===-1)n=o,i=new o3e(n,r)}}),n};bz.exports=c3e});var wz=h(function(ent,_z){var u3e=Gt(),l3e=tn(),d3e=(e,t,r)=>{let n=null,i=null,s=null;try{s=new l3e(t,r)}catch(o){return null}return e.forEach((o)=>{if(s.test(o)){if(!n||i.compare(o)===1)n=o,i=new u3e(n,r)}}),n};_z.exports=d3e});var Sz=h(function(tnt,Ez){var $w=Gt(),f3e=tn(),Dz=_d(),p3e=(e,t)=>{e=new f3e(e,t);let r=new $w("0.0.0");if(e.test(r))return r;if(r=new $w("0.0.0-0"),e.test(r))return r;r=null;for(let n=0;n<e.set.length;++n){let i=e.set[n],s=null;if(i.forEach((o)=>{let a=new $w(o.semver.version);switch(o.operator){case">":if(a.prerelease.length===0)a.patch++;else a.prerelease.push(0);a.raw=a.format();case"":case">=":if(!s||Dz(a,s))s=a;break;case"<":case"<=":break;default:throw Error(`Unexpected operation: ${o.operator}`)}}),s&&(!r||Dz(r,s)))r=s}if(r&&e.test(r))return r;return null};Ez.exports=p3e});var Cz=h(function(rnt,$z){var m3e=tn(),h3e=(e,t)=>{try{return new m3e(e,t).range||"*"}catch(r){return null}};$z.exports=h3e});var j0=h(function(nnt,Az){var g3e=Gt(),Oz=Dd(),{ANY:y3e}=Oz,x3e=tn(),b3e=Sd(),Rz=_d(),Fz=k0(),v3e=I0(),_3e=P0(),w3e=(e,t,r,n)=>{e=new g3e(e,n),t=new x3e(t,n);let i,s,o,a,c;switch(r){case">":i=Rz,s=v3e,o=Fz,a=">",c=">=";break;case"<":i=Fz,s=_3e,o=Rz,a="<",c="<=";break;default:throw TypeError('Must provide a hilo val of "<" or ">"')}if(b3e(e,t,n))return!1;for(let u=0;u<t.set.length;++u){let d=t.set[u],f=null,m=null;if(d.forEach((p)=>{if(p.semver===y3e)p=new Oz(">=0.0.0");if(f=f||p,m=m||p,i(p.semver,f.semver,n))f=p;else if(o(p.semver,m.semver,n))m=p}),f.operator===a||f.operator===c)return!1;if((!m.operator||m.operator===a)&&s(e,m.semver))return!1;else if(m.operator===c&&o(e,m.semver))return!1}return!0};Az.exports=w3e});var Pz=h(function(int,kz){var D3e=j0(),E3e=(e,t,r)=>D3e(e,t,">",r);kz.exports=E3e});var Tz=h(function(snt,Iz){var S3e=j0(),$3e=(e,t,r)=>S3e(e,t,"<",r);Iz.exports=$3e});var jz=h(function(ont,qz){var Nz=tn(),C3e=(e,t,r)=>(e=new Nz(e,r),t=new Nz(t,r),e.intersects(t,r));qz.exports=C3e});var Bz=h(function(ant,Mz){var R3e=Sd(),F3e=en();Mz.exports=(e,t,r)=>{let n=[],i=null,s=null,o=e.sort((d,f)=>F3e(d,f,r));for(let d of o)if(R3e(d,t,r)){if(s=d,!i)i=d}else{if(s)n.push([i,s]);s=null,i=null}if(i)n.push([i,null]);let a=[];for(let[d,f]of n)if(d===f)a.push(d);else if(!f&&d===o[0])a.push("*");else if(!f)a.push(`>=${d}`);else if(d===o[0])a.push(`<=${f}`);else a.push(`${d} - ${f}`);let c=a.join(" || "),u=typeof t.raw==="string"?t.raw:String(t);return c.length<u.length?c:t}});var Gz=h(function(cnt,Hz){var Lz=tn(),Rw=Dd(),{ANY:Cw}=Rw,$d=Sd(),Fw=en(),O3e=(e,t,r={})=>{if(e===t)return!0;e=new Lz(e,r),t=new Lz(t,r);let n=!1;e:for(let i of e.set){for(let s of t.set){let o=k3e(i,s,r);if(n=n||o!==null,o)continue e}if(n)return!1}return!0},A3e=[new Rw(">=0.0.0-0")],Uz=[new Rw(">=0.0.0")],k3e=(e,t,r)=>{if(e===t)return!0;if(e.length===1&&e[0].semver===Cw)if(t.length===1&&t[0].semver===Cw)return!0;else if(r.includePrerelease)e=A3e;else e=Uz;if(t.length===1&&t[0].semver===Cw)if(r.includePrerelease)return!0;else t=Uz;let n=new Set,i,s;for(let p of e)if(p.operator===">"||p.operator===">=")i=Vz(i,p,r);else if(p.operator==="<"||p.operator==="<=")s=zz(s,p,r);else n.add(p.semver);if(n.size>1)return null;let o;if(i&&s){if(o=Fw(i.semver,s.semver,r),o>0)return null;else if(o===0&&(i.operator!==">="||s.operator!=="<="))return null}for(let p of n){if(i&&!$d(p,String(i),r))return null;if(s&&!$d(p,String(s),r))return null;for(let g of t)if(!$d(p,String(g),r))return!1;return!0}let a,c,u,d,f=s&&!r.includePrerelease&&s.semver.prerelease.length?s.semver:!1,m=i&&!r.includePrerelease&&i.semver.prerelease.length?i.semver:!1;if(f&&f.prerelease.length===1&&s.operator==="<"&&f.prerelease[0]===0)f=!1;for(let p of t){if(d=d||p.operator===">"||p.operator===">=",u=u||p.operator==="<"||p.operator==="<=",i){if(m){if(p.semver.prerelease&&p.semver.prerelease.length&&p.semver.major===m.major&&p.semver.minor===m.minor&&p.semver.patch===m.patch)m=!1}if(p.operator===">"||p.operator===">="){if(a=Vz(i,p,r),a===p&&a!==i)return!1}else if(i.operator===">="&&!$d(i.semver,String(p),r))return!1}if(s){if(f){if(p.semver.prerelease&&p.semver.prerelease.length&&p.semver.major===f.major&&p.semver.minor===f.minor&&p.semver.patch===f.patch)f=!1}if(p.operator==="<"||p.operator==="<="){if(c=zz(s,p,r),c===p&&c!==s)return!1}else if(s.operator==="<="&&!$d(s.semver,String(p),r))return!1}if(!p.operator&&(s||i)&&o!==0)return!1}if(i&&u&&!s&&o!==0)return!1;if(s&&d&&!i&&o!==0)return!1;if(m||f)return!1;return!0},Vz=(e,t,r)=>{if(!e)return t;let n=Fw(e.semver,t.semver,r);return n>0?e:n<0?t:t.operator===">"&&e.operator===">="?t:e},zz=(e,t,r)=>{if(!e)return t;let n=Fw(e.semver,t.semver,r);return n<0?e:n>0?t:t.operator==="<"&&e.operator==="<="?t:e};Hz.exports=O3e});var Jz=h(function(unt,Yz){var Ow=Ac(),Wz=bd(),P3e=Gt(),Kz=xw(),I3e=Mo(),T3e=bV(),N3e=_V(),q3e=EV(),j3e=CV(),M3e=FV(),B3e=AV(),L3e=PV(),U3e=TV(),V3e=en(),z3e=MV(),H3e=LV(),G3e=A0(),W3e=HV(),K3e=WV(),Y3e=_d(),J3e=k0(),X3e=vw(),Q3e=_w(),Z3e=P0(),e5e=I0(),t5e=ww(),r5e=rz(),n5e=Dd(),i5e=tn(),s5e=Sd(),o5e=xz(),a5e=vz(),c5e=wz(),u5e=Sz(),l5e=Cz(),d5e=j0(),f5e=Pz(),p5e=Tz(),m5e=jz(),h5e=Bz(),g5e=Gz();Yz.exports={parse:I3e,valid:T3e,clean:N3e,inc:q3e,diff:j3e,major:M3e,minor:B3e,patch:L3e,prerelease:U3e,compare:V3e,rcompare:z3e,compareLoose:H3e,compareBuild:G3e,sort:W3e,rsort:K3e,gt:Y3e,lt:J3e,eq:X3e,neq:Q3e,gte:Z3e,lte:e5e,cmp:t5e,coerce:r5e,Comparator:n5e,Range:i5e,satisfies:s5e,toComparators:o5e,maxSatisfying:a5e,minSatisfying:c5e,minVersion:u5e,validRange:l5e,outside:d5e,gtr:f5e,ltr:p5e,intersects:m5e,simplifyRange:h5e,subset:g5e,SemVer:P3e,re:Ow.re,src:Ow.src,tokens:Ow.t,SEMVER_SPEC_VERSION:Wz.SEMVER_SPEC_VERSION,RELEASE_TYPES:Wz.RELEASE_TYPES,compareIdentifiers:Kz.compareIdentifiers,rcompareIdentifiers:Kz.rcompareIdentifiers}});function Qz(e,t,r){if(!e)return!1;if(e.constructor===t)return!0;return y5e.call(e)===r}function Zz(e){return Qz(e,Uint8Array,"[object Uint8Array]")}function x5e(e){return Qz(e,ArrayBuffer,"[object ArrayBuffer]")}function b5e(e){return Zz(e)||x5e(e)}function v5e(e){if(!Zz(e))throw TypeError(`Expected \`Uint8Array\`, got \`${typeof e}\``)}function _5e(e){if(!b5e(e))throw TypeError(`Expected \`Uint8Array\` or \`ArrayBuffer\`, got \`${typeof e}\``)}function Aw(e,t){if(e.length===0)return new Uint8Array(0);t??=e.reduce((i,s)=>i+s.length,0);let r=new Uint8Array(t),n=0;for(let i of e)v5e(i),r.set(i,n),n+=i.length;return r}function kw(e,t="utf8"){return _5e(e),Xz[t]??=new globalThis.TextDecoder(t),Xz[t].decode(e)}function w5e(e){if(typeof e!=="string")throw TypeError(`Expected \`string\`, got \`${typeof e}\``)}function M0(e){return w5e(e),D5e.encode(e)}var y5e,Xz,D5e,lnt;var eH=O(()=>{y5e=Object.prototype.toString;Xz={utf8:new globalThis.TextDecoder("utf8")};D5e=new globalThis.TextEncoder;lnt=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"))});import{isDeepStrictEqual as E5e}from"util";import tH from"process";import Bo from"fs";import rH from"path";import Cd from"crypto";import S5e from"assert";var iH,sH,Lo,$5e,nH="aes-256-cbc",kc=()=>Object.create(null),C5e=(e)=>e!==void 0&&e!==null,R5e=(e,t)=>{let r=new Set(["undefined","symbol","function"]),n=typeof t;if(r.has(n))throw TypeError(`Setting a value of type \`${n}\` for key \`${e}\` is not allowed as it's not supported by JSON`)},B0="__internal__",Pw,L0;var oH=O(()=>{m5();g5();G5();oV();eH();iH=ne(Vj(),1),sH=ne(sV(),1),Lo=ne(Jz(),1),$5e=sH.default.default,Pw=`${B0}.migrations.version`;L0=class L0{path;events;#r;#t;#e;#i={};constructor(e={}){let t={configName:"config",fileExtension:"json",projectSuffix:"nodejs",clearInvalidConfig:!1,accessPropertiesByDotNotation:!0,configFileMode:438,...e};if(!t.cwd){if(!t.projectName)throw Error("Please specify the `projectName` option.");t.cwd=uv(t.projectName,{suffix:t.projectSuffix}).config}if(this.#e=t,t.schema??t.ajvOptions??t.rootSchema){if(t.schema&&typeof t.schema!=="object")throw TypeError("The `schema` option must be an object.");let s=new iH.Ajv2020({allErrors:!0,useDefaults:!0,...t.ajvOptions});$5e(s);let o={...t.rootSchema,type:"object",properties:t.schema};this.#r=s.compile(o);for(let[a,c]of Object.entries(t.schema??{}))if(c?.default)this.#i[a]=c.default}if(t.defaults)this.#i={...this.#i,...t.defaults};if(t.serialize)this._serialize=t.serialize;if(t.deserialize)this._deserialize=t.deserialize;this.events=new EventTarget,this.#t=t.encryptionKey;let r=t.fileExtension?`.${t.fileExtension}`:"";this.path=rH.resolve(t.cwd,`${t.configName??"config"}${r}`);let n=this.store,i=Object.assign(kc(),t.defaults,n);if(t.migrations){if(!t.projectVersion)throw Error("Please specify the `projectVersion` option.");this._migrate(t.migrations,t.projectVersion,t.beforeEachMigration)}this._validate(i);try{S5e.deepEqual(n,i)}catch{this.store=i}if(t.watch)this._watch()}get(e,t){if(this.#e.accessPropertiesByDotNotation)return this._get(e,t);let{store:r}=this;return e in r?r[e]:t}set(e,t){if(typeof e!=="string"&&typeof e!=="object")throw TypeError(`Expected \`key\` to be of type \`string\` or \`object\`, got ${typeof e}`);if(typeof e!=="object"&&t===void 0)throw TypeError("Use `delete()` to clear values");if(this._containsReservedKey(e))throw TypeError(`Please don't use the ${B0} key, as it's used to manage this module internal operations.`);let{store:r}=this,n=(i,s)=>{if(R5e(i,s),this.#e.accessPropertiesByDotNotation)ov(r,i,s);else r[i]=s};if(typeof e==="object"){let i=e;for(let[s,o]of Object.entries(i))n(s,o)}else n(e,t);this.store=r}has(e){if(this.#e.accessPropertiesByDotNotation)return p5(this.store,e);return e in this.store}reset(...e){for(let t of e)if(C5e(this.#i[t]))this.set(t,this.#i[t])}delete(e){let{store:t}=this;if(this.#e.accessPropertiesByDotNotation)f5(t,e);else delete t[e];this.store=t}clear(){this.store=kc();for(let e of Object.keys(this.#i))this.reset(e)}onDidChange(e,t){if(typeof e!=="string")throw TypeError(`Expected \`key\` to be of type \`string\`, got ${typeof e}`);if(typeof t!=="function")throw TypeError(`Expected \`callback\` to be of type \`function\`, got ${typeof t}`);return this._handleChange(()=>this.get(e),t)}onDidAnyChange(e){if(typeof e!=="function")throw TypeError(`Expected \`callback\` to be of type \`function\`, got ${typeof e}`);return this._handleChange(()=>this.store,e)}get size(){return Object.keys(this.store).length}get store(){try{let e=Bo.readFileSync(this.path,this.#t?null:"utf8"),t=this._encryptData(e),r=this._deserialize(t);return this._validate(r),Object.assign(kc(),r)}catch(e){if(e?.code==="ENOENT")return this._ensureDirectory(),kc();if(this.#e.clearInvalidConfig&&e.name==="SyntaxError")return kc();throw e}}set store(e){this._ensureDirectory(),this._validate(e),this._write(e),this.events.dispatchEvent(new Event("change"))}*[Symbol.iterator](){for(let[e,t]of Object.entries(this.store))yield[e,t]}_encryptData(e){if(!this.#t)return typeof e==="string"?e:kw(e);try{let t=e.slice(0,16),r=Cd.pbkdf2Sync(this.#t,t.toString(),1e4,32,"sha512"),n=Cd.createDecipheriv(nH,r,t),i=e.slice(17),s=typeof i==="string"?M0(i):i;return kw(Aw([n.update(s),n.final()]))}catch{}return e.toString()}_handleChange(e,t){let r=e(),n=()=>{let i=r,s=e();if(E5e(s,i))return;r=s,t.call(this,s,i)};return this.events.addEventListener("change",n),()=>{this.events.removeEventListener("change",n)}}_deserialize=(e)=>JSON.parse(e);_serialize=(e)=>JSON.stringify(e,void 0,"\t");_validate(e){if(!this.#r)return;if(this.#r(e)||!this.#r.errors)return;let r=this.#r.errors.map(({instancePath:n,message:i=""})=>`\`${n.slice(1)}\` ${i}`);throw Error("Config schema violation: "+r.join("; "))}_ensureDirectory(){Bo.mkdirSync(rH.dirname(this.path),{recursive:!0})}_write(e){let t=this._serialize(e);if(this.#t){let r=Cd.randomBytes(16),n=Cd.pbkdf2Sync(this.#t,r.toString(),1e4,32,"sha512"),i=Cd.createCipheriv(nH,n,r);t=Aw([r,M0(":"),i.update(M0(t)),i.final()])}if(tH.env.SNAP)Bo.writeFileSync(this.path,t,{mode:this.#e.configFileMode});else try{vv(this.path,t,{mode:this.#e.configFileMode})}catch(r){if(r?.code==="EXDEV"){Bo.writeFileSync(this.path,t,{mode:this.#e.configFileMode});return}throw r}}_watch(){if(this._ensureDirectory(),!Bo.existsSync(this.path))this._write(kc());if(tH.platform==="win32")Bo.watch(this.path,{persistent:!1},hw(()=>{this.events.dispatchEvent(new Event("change"))},{wait:100}));else Bo.watchFile(this.path,{persistent:!1},hw(()=>{this.events.dispatchEvent(new Event("change"))},{wait:5000}))}_migrate(e,t,r){let n=this._get(Pw,"0.0.0"),i=Object.keys(e).filter((o)=>this._shouldPerformMigration(o,n,t)),s={...this.store};for(let o of i)try{if(r)r(this,{fromVersion:n,toVersion:o,finalVersion:t,versions:i});let a=e[o];a?.(this),this._set(Pw,o),n=o,s={...this.store}}catch(a){throw this.store=s,Error(`Something went wrong during the migration! Changes applied to the store until this failed migration will be restored. ${a}`)}if(this._isVersionInRangeFormat(n)||!Lo.default.eq(n,t))this._set(Pw,t)}_containsReservedKey(e){if(typeof e==="object"){if(Object.keys(e)[0]===B0)return!0}if(typeof e!=="string")return!1;if(this.#e.accessPropertiesByDotNotation){if(e.startsWith(`${B0}.`))return!0;return!1}return!1}_isVersionInRangeFormat(e){return Lo.default.clean(e)===null}_shouldPerformMigration(e,t,r){if(this._isVersionInRangeFormat(e)){if(t!=="0.0.0"&&Lo.default.satisfies(t,e))return!1;return Lo.default.satisfies(r,e)}if(Lo.default.lte(e,t))return!1;if(Lo.default.gt(e,r))return!1;return!0}_get(e,t){return d5(this.store,e,t)}_set(e,t){let{store:r}=this;ov(r,e,t),this.store=r}}});var De,Iw,N,li=(e)=>{switch(typeof e){case"undefined":return N.undefined;case"string":return N.string;case"number":return Number.isNaN(e)?N.nan:N.number;case"boolean":return N.boolean;case"function":return N.function;case"bigint":return N.bigint;case"symbol":return N.symbol;case"object":if(Array.isArray(e))return N.array;if(e===null)return N.null;if(e.then&&typeof e.then==="function"&&e.catch&&typeof e.catch==="function")return N.promise;if(typeof Map<"u"&&e instanceof Map)return N.map;if(typeof Set<"u"&&e instanceof Set)return N.set;if(typeof Date<"u"&&e instanceof Date)return N.date;return N.object;default:return N.unknown}};var Rd=O(()=>{(function(e){e.assertEqual=(i)=>{};function t(i){}e.assertIs=t;function r(i){throw Error()}e.assertNever=r,e.arrayToEnum=(i)=>{let s={};for(let o of i)s[o]=o;return s},e.getValidEnumValues=(i)=>{let s=e.objectKeys(i).filter((a)=>typeof i[i[a]]!=="number"),o={};for(let a of s)o[a]=i[a];return e.objectValues(o)},e.objectValues=(i)=>e.objectKeys(i).map(function(s){return i[s]}),e.objectKeys=typeof Object.keys==="function"?(i)=>Object.keys(i):(i)=>{let s=[];for(let o in i)if(Object.prototype.hasOwnProperty.call(i,o))s.push(o);return s},e.find=(i,s)=>{for(let o of i)if(s(o))return o;return},e.isInteger=typeof Number.isInteger==="function"?(i)=>Number.isInteger(i):(i)=>typeof i==="number"&&Number.isFinite(i)&&Math.floor(i)===i;function n(i,s=" | "){return i.map((o)=>typeof o==="string"?`'${o}'`:o).join(s)}e.joinValues=n,e.jsonStringifyReplacer=(i,s)=>{if(typeof s==="bigint")return s.toString();return s}})(De||(De={}));(function(e){e.mergeShapes=(t,r)=>({...t,...r})})(Iw||(Iw={}));N=De.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"])});var I,F5e=(e)=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:"),$r;var U0=O(()=>{Rd();I=De.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"]);$r=class $r extends Error{get errors(){return this.issues}constructor(e){super();this.issues=[],this.addIssue=(r)=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};let t=new.target.prototype;if(Object.setPrototypeOf)Object.setPrototypeOf(this,t);else this.__proto__=t;this.name="ZodError",this.issues=e}format(e){let t=e||function(i){return i.message},r={_errors:[]},n=(i)=>{for(let s of i.issues)if(s.code==="invalid_union")s.unionErrors.map(n);else if(s.code==="invalid_return_type")n(s.returnTypeError);else if(s.code==="invalid_arguments")n(s.argumentsError);else if(s.path.length===0)r._errors.push(t(s));else{let o=r,a=0;while(a<s.path.length){let c=s.path[a];if(a!==s.path.length-1)o[c]=o[c]||{_errors:[]};else o[c]=o[c]||{_errors:[]},o[c]._errors.push(t(s));o=o[c],a++}}};return n(this),r}static assert(e){if(!(e instanceof $r))throw Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,De.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=(t)=>t.message){let t={},r=[];for(let n of this.issues)if(n.path.length>0){let i=n.path[0];t[i]=t[i]||[],t[i].push(e(n))}else r.push(e(n));return{formErrors:r,fieldErrors:t}}get formErrors(){return this.flatten()}};$r.create=(e)=>new $r(e)});var O5e=(e,t)=>{let r;switch(e.code){case I.invalid_type:if(e.received===N.undefined)r="Required";else r=`Expected ${e.expected}, received ${e.received}`;break;case I.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(e.expected,De.jsonStringifyReplacer)}`;break;case I.unrecognized_keys:r=`Unrecognized key(s) in object: ${De.joinValues(e.keys,", ")}`;break;case I.invalid_union:r="Invalid input";break;case I.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${De.joinValues(e.options)}`;break;case I.invalid_enum_value:r=`Invalid enum value. Expected ${De.joinValues(e.options)}, received '${e.received}'`;break;case I.invalid_arguments:r="Invalid function arguments";break;case I.invalid_return_type:r="Invalid function return type";break;case I.invalid_date:r="Invalid date";break;case I.invalid_string:if(typeof e.validation==="object")if("includes"in e.validation){if(r=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position==="number")r=`${r} at one or more positions greater than or equal to ${e.validation.position}`}else if("startsWith"in e.validation)r=`Invalid input: must start with "${e.validation.startsWith}"`;else if("endsWith"in e.validation)r=`Invalid input: must end with "${e.validation.endsWith}"`;else De.assertNever(e.validation);else if(e.validation!=="regex")r=`Invalid ${e.validation}`;else r="Invalid";break;case I.too_small:if(e.type==="array")r=`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`;else if(e.type==="string")r=`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`;else if(e.type==="number")r=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`;else if(e.type==="bigint")r=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`;else if(e.type==="date")r=`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`;else r="Invalid input";break;case I.too_big:if(e.type==="array")r=`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`;else if(e.type==="string")r=`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`;else if(e.type==="number")r=`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`;else if(e.type==="bigint")r=`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`;else if(e.type==="date")r=`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`;else r="Invalid input";break;case I.custom:r="Invalid input";break;case I.invalid_intersection_types:r="Intersection results could not be merged";break;case I.not_multiple_of:r=`Number must be a multiple of ${e.multipleOf}`;break;case I.not_finite:r="Number must be finite";break;default:r=t.defaultError,De.assertNever(e)}return{message:r}},Bi;var Tw=O(()=>{U0();Rd();Bi=O5e});function A5e(e){aH=e}function Pc(){return aH}var aH;var V0=O(()=>{Tw();aH=Bi});function L(e,t){let r=Pc(),n=Fd({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,r,r===Bi?void 0:Bi].filter((i)=>!!i)});e.common.issues.push(n)}class qt{constructor(){this.value="valid"}dirty(){if(this.value==="valid")this.value="dirty"}abort(){if(this.value!=="aborted")this.value="aborted"}static mergeArray(e,t){let r=[];for(let n of t){if(n.status==="aborted")return ee;if(n.status==="dirty")e.dirty();r.push(n.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,t){let r=[];for(let n of t){let i=await n.key,s=await n.value;r.push({key:i,value:s})}return qt.mergeObjectSync(e,r)}static mergeObjectSync(e,t){let r={};for(let n of t){let{key:i,value:s}=n;if(i.status==="aborted")return ee;if(s.status==="aborted")return ee;if(i.status==="dirty")e.dirty();if(s.status==="dirty")e.dirty();if(i.value!=="__proto__"&&(typeof s.value<"u"||n.alwaysSet))r[i.value]=s.value}return{status:e.value,value:r}}}var Fd=(e)=>{let{data:t,path:r,errorMaps:n,issueData:i}=e,s=[...r,...i.path||[]],o={...i,path:s};if(i.message!==void 0)return{...i,path:s,message:i.message};let a="",c=n.filter((u)=>!!u).slice().reverse();for(let u of c)a=u(o,{data:t,defaultError:a}).message;return{...i,path:s,message:a}},k5e,ee,Uo=(e)=>({status:"dirty",value:e}),Kt=(e)=>({status:"valid",value:e}),z0=(e)=>e.status==="aborted",H0=(e)=>e.status==="dirty",Us=(e)=>e.status==="valid",Ic=(e)=>typeof Promise<"u"&&e instanceof Promise;var Nw=O(()=>{V0();Tw();k5e=[];ee=Object.freeze({status:"aborted"})});var cH=()=>{};var Y;var uH=O(()=>{(function(e){e.errToObj=(t)=>typeof t==="string"?{message:t}:t||{},e.toString=(t)=>typeof t==="string"?t:t?.message})(Y||(Y={}))});class An{constructor(e,t,r,n){this._cachedPath=[],this.parent=e,this.data=t,this._path=r,this._key=n}get path(){if(!this._cachedPath.length)if(Array.isArray(this._key))this._cachedPath.push(...this._path,...this._key);else this._cachedPath.push(...this._path,this._key);return this._cachedPath}}function pe(e){if(!e)return{};let{errorMap:t,invalid_type_error:r,required_error:n,description:i}=e;if(t&&(r||n))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);if(t)return{errorMap:t,description:i};return{errorMap:(o,a)=>{let{message:c}=e;if(o.code==="invalid_enum_value")return{message:c??a.defaultError};if(typeof a.data>"u")return{message:c??n??a.defaultError};if(o.code!=="invalid_type")return{message:a.defaultError};return{message:c??r??a.defaultError}},description:i}}class be{get description(){return this._def.description}_getType(e){return li(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:li(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new qt,ctx:{common:e.parent.common,data:e.data,parsedType:li(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(Ic(t))throw Error("Synchronous parse encountered promise.");return t}_parseAsync(e){let t=this._parse(e);return Promise.resolve(t)}parse(e,t){let r=this.safeParse(e,t);if(r.success)return r.data;throw r.error}safeParse(e,t){let r={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:li(e)},n=this._parseSync({data:e,path:r.path,parent:r});return lH(r,n)}"~validate"(e){let t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:li(e)};if(!this["~standard"].async)try{let r=this._parseSync({data:e,path:[],parent:t});return Us(r)?{value:r.value}:{issues:t.common.issues}}catch(r){if(r?.message?.toLowerCase()?.includes("encountered"))this["~standard"].async=!0;t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then((r)=>Us(r)?{value:r.value}:{issues:t.common.issues})}async parseAsync(e,t){let r=await this.safeParseAsync(e,t);if(r.success)return r.data;throw r.error}async safeParseAsync(e,t){let r={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:li(e)},n=this._parse({data:e,path:r.path,parent:r}),i=await(Ic(n)?n:Promise.resolve(n));return lH(r,i)}refine(e,t){let r=(n)=>{if(typeof t==="string"||typeof t>"u")return{message:t};else if(typeof t==="function")return t(n);else return t};return this._refinement((n,i)=>{let s=e(n),o=()=>i.addIssue({code:I.custom,...r(n)});if(typeof Promise<"u"&&s instanceof Promise)return s.then((a)=>{if(!a)return o(),!1;else return!0});if(!s)return o(),!1;else return!0})}refinement(e,t){return this._refinement((r,n)=>{if(!e(r))return n.addIssue(typeof t==="function"?t(r,n):t),!1;else return!0})}_refinement(e){return new kn({schema:this,typeName:re.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:(t)=>this["~validate"](t)}}optional(){return On.create(this,this._def)}nullable(){return Ui.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Fn.create(this)}promise(){return Go.create(this,this._def)}or(e){return Bc.create([this,e],this._def)}and(e){return Lc.create(this,e,this._def)}transform(e){return new kn({...pe(this._def),schema:this,typeName:re.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let t=typeof e==="function"?e:()=>e;return new Hc({...pe(this._def),innerType:this,defaultValue:t,typeName:re.ZodDefault})}brand(){return new W0({typeName:re.ZodBranded,type:this,...pe(this._def)})}catch(e){let t=typeof e==="function"?e:()=>e;return new Gc({...pe(this._def),innerType:this,catchValue:t,typeName:re.ZodCatch})}describe(e){return new this.constructor({...this._def,description:e})}pipe(e){return Td.create(this,e)}readonly(){return Wc.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}function pH(e){let t="[0-5]\\d";if(e.precision)t=`${t}\\.\\d{${e.precision}}`;else if(e.precision==null)t=`${t}(\\.\\d+)?`;let r=e.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${r}`}function Y5e(e){return new RegExp(`^${pH(e)}$`)}function mH(e){let t=`${fH}T${pH(e)}`,r=[];if(r.push(e.local?"Z?":"Z"),e.offset)r.push("([+-]\\d{2}:?\\d{2})");return t=`${t}(${r.join("|")})`,new RegExp(`^${t}$`)}function J5e(e,t){if((t==="v4"||!t)&&U5e.test(e))return!0;if((t==="v6"||!t)&&z5e.test(e))return!0;return!1}function X5e(e,t){if(!j5e.test(e))return!1;try{let[r]=e.split(".");if(!r)return!1;let n=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),i=JSON.parse(atob(n));if(typeof i!=="object"||i===null)return!1;if("typ"in i&&i?.typ!=="JWT")return!1;if(!i.alg)return!1;if(t&&i.alg!==t)return!1;return!0}catch{return!1}}function Q5e(e,t){if((t==="v4"||!t)&&V5e.test(e))return!0;if((t==="v6"||!t)&&H5e.test(e))return!0;return!1}function Z5e(e,t){let r=(e.toString().split(".")[1]||"").length,n=(t.toString().split(".")[1]||"").length,i=r>n?r:n,s=Number.parseInt(e.toFixed(i).replace(".","")),o=Number.parseInt(t.toFixed(i).replace(".",""));return s%o/10**i}function Tc(e){if(e instanceof pt){let t={};for(let r in e.shape){let n=e.shape[r];t[r]=On.create(Tc(n))}return new pt({...e._def,shape:()=>t})}else if(e instanceof Fn)return new Fn({...e._def,type:Tc(e.element)});else if(e instanceof On)return On.create(Tc(e.unwrap()));else if(e instanceof Ui)return Ui.create(Tc(e.unwrap()));else if(e instanceof fi)return fi.create(e.items.map((t)=>Tc(t)));else return e}function jw(e,t){let r=li(e),n=li(t);if(e===t)return{valid:!0,data:e};else if(r===N.object&&n===N.object){let i=De.objectKeys(t),s=De.objectKeys(e).filter((a)=>i.indexOf(a)!==-1),o={...e,...t};for(let a of s){let c=jw(e[a],t[a]);if(!c.valid)return{valid:!1};o[a]=c.data}return{valid:!0,data:o}}else if(r===N.array&&n===N.array){if(e.length!==t.length)return{valid:!1};let i=[];for(let s=0;s<e.length;s++){let o=e[s],a=t[s],c=jw(o,a);if(!c.valid)return{valid:!1};i.push(c.data)}return{valid:!0,data:i}}else if(r===N.date&&n===N.date&&+e===+t)return{valid:!0,data:e};else return{valid:!1}}function hH(e,t){return new Gs({values:e,typeName:re.ZodEnum,...pe(t)})}function dH(e,t){let r=typeof e==="function"?e(t):typeof e==="string"?{message:e}:e;return typeof r==="string"?{message:r}:r}function gH(e,t={},r){if(e)return zo.create().superRefine((n,i)=>{let s=e(n);if(s instanceof Promise)return s.then((o)=>{if(!o){let a=dH(t,n),c=a.fatal??r??!0;i.addIssue({code:"custom",...a,fatal:c})}});if(!s){let o=dH(t,n),a=o.fatal??r??!0;i.addIssue({code:"custom",...o,fatal:a})}return});return zo.create()}var lH=(e,t)=>{if(Us(t))return{success:!0,data:t.value};else{if(!e.common.issues.length)throw Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let r=new $r(e.common.issues);return this._error=r,this._error}}}},P5e,I5e,T5e,N5e,q5e,j5e,M5e,B5e,L5e="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",qw,U5e,V5e,z5e,H5e,G5e,W5e,fH="((\\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])))",K5e,Rn,zs,Hs,qc,Vo,Od,jc,Mc,zo,Vs,di,Ad,Fn,pt,Bc,Li=(e)=>{if(e instanceof Uc)return Li(e.schema);else if(e instanceof kn)return Li(e.innerType());else if(e instanceof Vc)return[e.value];else if(e instanceof Gs)return e.options;else if(e instanceof zc)return De.objectValues(e.enum);else if(e instanceof Hc)return Li(e._def.innerType);else if(e instanceof jc)return[void 0];else if(e instanceof Mc)return[null];else if(e instanceof On)return[void 0,...Li(e.unwrap())];else if(e instanceof Ui)return[null,...Li(e.unwrap())];else if(e instanceof W0)return Li(e.unwrap());else if(e instanceof Wc)return Li(e.unwrap());else if(e instanceof Gc)return Li(e._def.innerType);else return[]},G0,Lc,fi,kd,Pd,Ho,Nc,Uc,Vc,Gs,zc,Go,kn,On,Ui,Hc,Gc,Id,eNe,W0,Td,Wc,tNe,re,rNe=(e,t={message:`Input not instance of ${e.name}`})=>gH((r)=>r instanceof e,t),yH,xH,nNe,iNe,bH,sNe,oNe,aNe,cNe,uNe,lNe,dNe,fNe,pNe,mNe,hNe,gNe,yNe,xNe,bNe,vNe,_Ne,wNe,DNe,ENe,SNe,$Ne,CNe,RNe,FNe,ONe,ANe,kNe,PNe,INe=()=>yH().optional(),TNe=()=>xH().optional(),NNe=()=>bH().optional(),qNe,jNe;var vH=O(()=>{U0();V0();uH();Nw();Rd();P5e=/^c[^\s-]{8,}$/i,I5e=/^[0-9a-z]+$/,T5e=/^[0-9A-HJKMNP-TV-Z]{26}$/i,N5e=/^[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,q5e=/^[a-z0-9_-]{21}$/i,j5e=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,M5e=/^[-+]?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)?)??$/,B5e=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,U5e=/^(?:(?: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])$/,V5e=/^(?:(?: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])$/,z5e=/^(([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]))$/,H5e=/^(([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])$/,G5e=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,W5e=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,K5e=new RegExp(`^${fH}$`);Rn=class Rn extends be{_parse(e){if(this._def.coerce)e.data=String(e.data);if(this._getType(e)!==N.string){let i=this._getOrReturnCtx(e);return L(i,{code:I.invalid_type,expected:N.string,received:i.parsedType}),ee}let r=new qt,n=void 0;for(let i of this._def.checks)if(i.kind==="min"){if(e.data.length<i.value)n=this._getOrReturnCtx(e,n),L(n,{code:I.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty()}else if(i.kind==="max"){if(e.data.length>i.value)n=this._getOrReturnCtx(e,n),L(n,{code:I.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty()}else if(i.kind==="length"){let s=e.data.length>i.value,o=e.data.length<i.value;if(s||o){if(n=this._getOrReturnCtx(e,n),s)L(n,{code:I.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message});else if(o)L(n,{code:I.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message});r.dirty()}}else if(i.kind==="email"){if(!B5e.test(e.data))n=this._getOrReturnCtx(e,n),L(n,{validation:"email",code:I.invalid_string,message:i.message}),r.dirty()}else if(i.kind==="emoji"){if(!qw)qw=new RegExp(L5e,"u");if(!qw.test(e.data))n=this._getOrReturnCtx(e,n),L(n,{validation:"emoji",code:I.invalid_string,message:i.message}),r.dirty()}else if(i.kind==="uuid"){if(!N5e.test(e.data))n=this._getOrReturnCtx(e,n),L(n,{validation:"uuid",code:I.invalid_string,message:i.message}),r.dirty()}else if(i.kind==="nanoid"){if(!q5e.test(e.data))n=this._getOrReturnCtx(e,n),L(n,{validation:"nanoid",code:I.invalid_string,message:i.message}),r.dirty()}else if(i.kind==="cuid"){if(!P5e.test(e.data))n=this._getOrReturnCtx(e,n),L(n,{validation:"cuid",code:I.invalid_string,message:i.message}),r.dirty()}else if(i.kind==="cuid2"){if(!I5e.test(e.data))n=this._getOrReturnCtx(e,n),L(n,{validation:"cuid2",code:I.invalid_string,message:i.message}),r.dirty()}else if(i.kind==="ulid"){if(!T5e.test(e.data))n=this._getOrReturnCtx(e,n),L(n,{validation:"ulid",code:I.invalid_string,message:i.message}),r.dirty()}else if(i.kind==="url")try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),L(n,{validation:"url",code:I.invalid_string,message:i.message}),r.dirty()}else if(i.kind==="regex"){if(i.regex.lastIndex=0,!i.regex.test(e.data))n=this._getOrReturnCtx(e,n),L(n,{validation:"regex",code:I.invalid_string,message:i.message}),r.dirty()}else if(i.kind==="trim")e.data=e.data.trim();else if(i.kind==="includes"){if(!e.data.includes(i.value,i.position))n=this._getOrReturnCtx(e,n),L(n,{code:I.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),r.dirty()}else if(i.kind==="toLowerCase")e.data=e.data.toLowerCase();else if(i.kind==="toUpperCase")e.data=e.data.toUpperCase();else if(i.kind==="startsWith"){if(!e.data.startsWith(i.value))n=this._getOrReturnCtx(e,n),L(n,{code:I.invalid_string,validation:{startsWith:i.value},message:i.message}),r.dirty()}else if(i.kind==="endsWith"){if(!e.data.endsWith(i.value))n=this._getOrReturnCtx(e,n),L(n,{code:I.invalid_string,validation:{endsWith:i.value},message:i.message}),r.dirty()}else if(i.kind==="datetime"){if(!mH(i).test(e.data))n=this._getOrReturnCtx(e,n),L(n,{code:I.invalid_string,validation:"datetime",message:i.message}),r.dirty()}else if(i.kind==="date"){if(!K5e.test(e.data))n=this._getOrReturnCtx(e,n),L(n,{code:I.invalid_string,validation:"date",message:i.message}),r.dirty()}else if(i.kind==="time"){if(!Y5e(i).test(e.data))n=this._getOrReturnCtx(e,n),L(n,{code:I.invalid_string,validation:"time",message:i.message}),r.dirty()}else if(i.kind==="duration"){if(!M5e.test(e.data))n=this._getOrReturnCtx(e,n),L(n,{validation:"duration",code:I.invalid_string,message:i.message}),r.dirty()}else if(i.kind==="ip"){if(!J5e(e.data,i.version))n=this._getOrReturnCtx(e,n),L(n,{validation:"ip",code:I.invalid_string,message:i.message}),r.dirty()}else if(i.kind==="jwt"){if(!X5e(e.data,i.alg))n=this._getOrReturnCtx(e,n),L(n,{validation:"jwt",code:I.invalid_string,message:i.message}),r.dirty()}else if(i.kind==="cidr"){if(!Q5e(e.data,i.version))n=this._getOrReturnCtx(e,n),L(n,{validation:"cidr",code:I.invalid_string,message:i.message}),r.dirty()}else if(i.kind==="base64"){if(!G5e.test(e.data))n=this._getOrReturnCtx(e,n),L(n,{validation:"base64",code:I.invalid_string,message:i.message}),r.dirty()}else if(i.kind==="base64url"){if(!W5e.test(e.data))n=this._getOrReturnCtx(e,n),L(n,{validation:"base64url",code:I.invalid_string,message:i.message}),r.dirty()}else De.assertNever(i);return{status:r.value,value:e.data}}_regex(e,t,r){return this.refinement((n)=>e.test(n),{validation:t,code:I.invalid_string,...Y.errToObj(r)})}_addCheck(e){return new Rn({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...Y.errToObj(e)})}url(e){return this._addCheck({kind:"url",...Y.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...Y.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...Y.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...Y.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...Y.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...Y.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...Y.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...Y.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...Y.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...Y.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...Y.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...Y.errToObj(e)})}datetime(e){if(typeof e==="string")return this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e});return this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...Y.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){if(typeof e==="string")return this._addCheck({kind:"time",precision:null,message:e});return this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...Y.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...Y.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...Y.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...Y.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...Y.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...Y.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...Y.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...Y.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...Y.errToObj(t)})}nonempty(e){return this.min(1,Y.errToObj(e))}trim(){return new Rn({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Rn({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Rn({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find((e)=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find((e)=>e.kind==="date")}get isTime(){return!!this._def.checks.find((e)=>e.kind==="time")}get isDuration(){return!!this._def.checks.find((e)=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find((e)=>e.kind==="email")}get isURL(){return!!this._def.checks.find((e)=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find((e)=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find((e)=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find((e)=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find((e)=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find((e)=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find((e)=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find((e)=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find((e)=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find((e)=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find((e)=>e.kind==="base64url")}get minLength(){let e=null;for(let t of this._def.checks)if(t.kind==="min"){if(e===null||t.value>e)e=t.value}return e}get maxLength(){let e=null;for(let t of this._def.checks)if(t.kind==="max"){if(e===null||t.value<e)e=t.value}return e}};Rn.create=(e)=>new Rn({checks:[],typeName:re.ZodString,coerce:e?.coerce??!1,...pe(e)});zs=class zs extends be{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);if(this._getType(e)!==N.number){let i=this._getOrReturnCtx(e);return L(i,{code:I.invalid_type,expected:N.number,received:i.parsedType}),ee}let r=void 0,n=new qt;for(let i of this._def.checks)if(i.kind==="int"){if(!De.isInteger(e.data))r=this._getOrReturnCtx(e,r),L(r,{code:I.invalid_type,expected:"integer",received:"float",message:i.message}),n.dirty()}else if(i.kind==="min"){if(i.inclusive?e.data<i.value:e.data<=i.value)r=this._getOrReturnCtx(e,r),L(r,{code:I.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),n.dirty()}else if(i.kind==="max"){if(i.inclusive?e.data>i.value:e.data>=i.value)r=this._getOrReturnCtx(e,r),L(r,{code:I.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),n.dirty()}else if(i.kind==="multipleOf"){if(Z5e(e.data,i.value)!==0)r=this._getOrReturnCtx(e,r),L(r,{code:I.not_multiple_of,multipleOf:i.value,message:i.message}),n.dirty()}else if(i.kind==="finite"){if(!Number.isFinite(e.data))r=this._getOrReturnCtx(e,r),L(r,{code:I.not_finite,message:i.message}),n.dirty()}else De.assertNever(i);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,Y.toString(t))}gt(e,t){return this.setLimit("min",e,!1,Y.toString(t))}lte(e,t){return this.setLimit("max",e,!0,Y.toString(t))}lt(e,t){return this.setLimit("max",e,!1,Y.toString(t))}setLimit(e,t,r,n){return new zs({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:Y.toString(n)}]})}_addCheck(e){return new zs({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:Y.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Y.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Y.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Y.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Y.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:Y.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:Y.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Y.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Y.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)if(t.kind==="min"){if(e===null||t.value>e)e=t.value}return e}get maxValue(){let e=null;for(let t of this._def.checks)if(t.kind==="max"){if(e===null||t.value<e)e=t.value}return e}get isInt(){return!!this._def.checks.find((e)=>e.kind==="int"||e.kind==="multipleOf"&&De.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let r of this._def.checks)if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;else if(r.kind==="min"){if(t===null||r.value>t)t=r.value}else if(r.kind==="max"){if(e===null||r.value<e)e=r.value}return Number.isFinite(t)&&Number.isFinite(e)}};zs.create=(e)=>new zs({checks:[],typeName:re.ZodNumber,coerce:e?.coerce||!1,...pe(e)});Hs=class Hs extends be{constructor(){super(...arguments);this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==N.bigint)return this._getInvalidInput(e);let r=void 0,n=new qt;for(let i of this._def.checks)if(i.kind==="min"){if(i.inclusive?e.data<i.value:e.data<=i.value)r=this._getOrReturnCtx(e,r),L(r,{code:I.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),n.dirty()}else if(i.kind==="max"){if(i.inclusive?e.data>i.value:e.data>=i.value)r=this._getOrReturnCtx(e,r),L(r,{code:I.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),n.dirty()}else if(i.kind==="multipleOf"){if(e.data%i.value!==BigInt(0))r=this._getOrReturnCtx(e,r),L(r,{code:I.not_multiple_of,multipleOf:i.value,message:i.message}),n.dirty()}else De.assertNever(i);return{status:n.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return L(t,{code:I.invalid_type,expected:N.bigint,received:t.parsedType}),ee}gte(e,t){return this.setLimit("min",e,!0,Y.toString(t))}gt(e,t){return this.setLimit("min",e,!1,Y.toString(t))}lte(e,t){return this.setLimit("max",e,!0,Y.toString(t))}lt(e,t){return this.setLimit("max",e,!1,Y.toString(t))}setLimit(e,t,r,n){return new Hs({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:Y.toString(n)}]})}_addCheck(e){return new Hs({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Y.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Y.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Y.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Y.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:Y.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)if(t.kind==="min"){if(e===null||t.value>e)e=t.value}return e}get maxValue(){let e=null;for(let t of this._def.checks)if(t.kind==="max"){if(e===null||t.value<e)e=t.value}return e}};Hs.create=(e)=>new Hs({checks:[],typeName:re.ZodBigInt,coerce:e?.coerce??!1,...pe(e)});qc=class qc extends be{_parse(e){if(this._def.coerce)e.data=Boolean(e.data);if(this._getType(e)!==N.boolean){let r=this._getOrReturnCtx(e);return L(r,{code:I.invalid_type,expected:N.boolean,received:r.parsedType}),ee}return Kt(e.data)}};qc.create=(e)=>new qc({typeName:re.ZodBoolean,coerce:e?.coerce||!1,...pe(e)});Vo=class Vo extends be{_parse(e){if(this._def.coerce)e.data=new Date(e.data);if(this._getType(e)!==N.date){let i=this._getOrReturnCtx(e);return L(i,{code:I.invalid_type,expected:N.date,received:i.parsedType}),ee}if(Number.isNaN(e.data.getTime())){let i=this._getOrReturnCtx(e);return L(i,{code:I.invalid_date}),ee}let r=new qt,n=void 0;for(let i of this._def.checks)if(i.kind==="min"){if(e.data.getTime()<i.value)n=this._getOrReturnCtx(e,n),L(n,{code:I.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),r.dirty()}else if(i.kind==="max"){if(e.data.getTime()>i.value)n=this._getOrReturnCtx(e,n),L(n,{code:I.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),r.dirty()}else De.assertNever(i);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Vo({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:Y.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:Y.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)if(t.kind==="min"){if(e===null||t.value>e)e=t.value}return e!=null?new Date(e):null}get maxDate(){let e=null;for(let t of this._def.checks)if(t.kind==="max"){if(e===null||t.value<e)e=t.value}return e!=null?new Date(e):null}};Vo.create=(e)=>new Vo({checks:[],coerce:e?.coerce||!1,typeName:re.ZodDate,...pe(e)});Od=class Od extends be{_parse(e){if(this._getType(e)!==N.symbol){let r=this._getOrReturnCtx(e);return L(r,{code:I.invalid_type,expected:N.symbol,received:r.parsedType}),ee}return Kt(e.data)}};Od.create=(e)=>new Od({typeName:re.ZodSymbol,...pe(e)});jc=class jc extends be{_parse(e){if(this._getType(e)!==N.undefined){let r=this._getOrReturnCtx(e);return L(r,{code:I.invalid_type,expected:N.undefined,received:r.parsedType}),ee}return Kt(e.data)}};jc.create=(e)=>new jc({typeName:re.ZodUndefined,...pe(e)});Mc=class Mc extends be{_parse(e){if(this._getType(e)!==N.null){let r=this._getOrReturnCtx(e);return L(r,{code:I.invalid_type,expected:N.null,received:r.parsedType}),ee}return Kt(e.data)}};Mc.create=(e)=>new Mc({typeName:re.ZodNull,...pe(e)});zo=class zo extends be{constructor(){super(...arguments);this._any=!0}_parse(e){return Kt(e.data)}};zo.create=(e)=>new zo({typeName:re.ZodAny,...pe(e)});Vs=class Vs extends be{constructor(){super(...arguments);this._unknown=!0}_parse(e){return Kt(e.data)}};Vs.create=(e)=>new Vs({typeName:re.ZodUnknown,...pe(e)});di=class di extends be{_parse(e){let t=this._getOrReturnCtx(e);return L(t,{code:I.invalid_type,expected:N.never,received:t.parsedType}),ee}};di.create=(e)=>new di({typeName:re.ZodNever,...pe(e)});Ad=class Ad extends be{_parse(e){if(this._getType(e)!==N.undefined){let r=this._getOrReturnCtx(e);return L(r,{code:I.invalid_type,expected:N.void,received:r.parsedType}),ee}return Kt(e.data)}};Ad.create=(e)=>new Ad({typeName:re.ZodVoid,...pe(e)});Fn=class Fn extends be{_parse(e){let{ctx:t,status:r}=this._processInputParams(e),n=this._def;if(t.parsedType!==N.array)return L(t,{code:I.invalid_type,expected:N.array,received:t.parsedType}),ee;if(n.exactLength!==null){let s=t.data.length>n.exactLength.value,o=t.data.length<n.exactLength.value;if(s||o)L(t,{code:s?I.too_big:I.too_small,minimum:o?n.exactLength.value:void 0,maximum:s?n.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:n.exactLength.message}),r.dirty()}if(n.minLength!==null){if(t.data.length<n.minLength.value)L(t,{code:I.too_small,minimum:n.minLength.value,type:"array",inclusive:!0,exact:!1,message:n.minLength.message}),r.dirty()}if(n.maxLength!==null){if(t.data.length>n.maxLength.value)L(t,{code:I.too_big,maximum:n.maxLength.value,type:"array",inclusive:!0,exact:!1,message:n.maxLength.message}),r.dirty()}if(t.common.async)return Promise.all([...t.data].map((s,o)=>n.type._parseAsync(new An(t,s,t.path,o)))).then((s)=>qt.mergeArray(r,s));let i=[...t.data].map((s,o)=>n.type._parseSync(new An(t,s,t.path,o)));return qt.mergeArray(r,i)}get element(){return this._def.type}min(e,t){return new Fn({...this._def,minLength:{value:e,message:Y.toString(t)}})}max(e,t){return new Fn({...this._def,maxLength:{value:e,message:Y.toString(t)}})}length(e,t){return new Fn({...this._def,exactLength:{value:e,message:Y.toString(t)}})}nonempty(e){return this.min(1,e)}};Fn.create=(e,t)=>new Fn({type:e,minLength:null,maxLength:null,exactLength:null,typeName:re.ZodArray,...pe(t)});pt=class pt extends be{constructor(){super(...arguments);this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),t=De.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==N.object){let c=this._getOrReturnCtx(e);return L(c,{code:I.invalid_type,expected:N.object,received:c.parsedType}),ee}let{status:r,ctx:n}=this._processInputParams(e),{shape:i,keys:s}=this._getCached(),o=[];if(!(this._def.catchall instanceof di&&this._def.unknownKeys==="strip")){for(let c in n.data)if(!s.includes(c))o.push(c)}let a=[];for(let c of s){let u=i[c],d=n.data[c];a.push({key:{status:"valid",value:c},value:u._parse(new An(n,d,n.path,c)),alwaysSet:c in n.data})}if(this._def.catchall instanceof di){let c=this._def.unknownKeys;if(c==="passthrough")for(let u of o)a.push({key:{status:"valid",value:u},value:{status:"valid",value:n.data[u]}});else if(c==="strict"){if(o.length>0)L(n,{code:I.unrecognized_keys,keys:o}),r.dirty()}else if(c==="strip");else throw Error("Internal ZodObject error: invalid unknownKeys value.")}else{let c=this._def.catchall;for(let u of o){let d=n.data[u];a.push({key:{status:"valid",value:u},value:c._parse(new An(n,d,n.path,u)),alwaysSet:u in n.data})}}if(n.common.async)return Promise.resolve().then(async()=>{let c=[];for(let u of a){let d=await u.key,f=await u.value;c.push({key:d,value:f,alwaysSet:u.alwaysSet})}return c}).then((c)=>qt.mergeObjectSync(r,c));else return qt.mergeObjectSync(r,a)}get shape(){return this._def.shape()}strict(e){return Y.errToObj,new pt({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,r)=>{let n=this._def.errorMap?.(t,r).message??r.defaultError;if(t.code==="unrecognized_keys")return{message:Y.errToObj(e).message??n};return{message:n}}}:{}})}strip(){return new pt({...this._def,unknownKeys:"strip"})}passthrough(){return new pt({...this._def,unknownKeys:"passthrough"})}extend(e){return new pt({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new pt({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:re.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new pt({...this._def,catchall:e})}pick(e){let t={};for(let r of De.objectKeys(e))if(e[r]&&this.shape[r])t[r]=this.shape[r];return new pt({...this._def,shape:()=>t})}omit(e){let t={};for(let r of De.objectKeys(this.shape))if(!e[r])t[r]=this.shape[r];return new pt({...this._def,shape:()=>t})}deepPartial(){return Tc(this)}partial(e){let t={};for(let r of De.objectKeys(this.shape)){let n=this.shape[r];if(e&&!e[r])t[r]=n;else t[r]=n.optional()}return new pt({...this._def,shape:()=>t})}required(e){let t={};for(let r of De.objectKeys(this.shape))if(e&&!e[r])t[r]=this.shape[r];else{let i=this.shape[r];while(i instanceof On)i=i._def.innerType;t[r]=i}return new pt({...this._def,shape:()=>t})}keyof(){return hH(De.objectKeys(this.shape))}};pt.create=(e,t)=>new pt({shape:()=>e,unknownKeys:"strip",catchall:di.create(),typeName:re.ZodObject,...pe(t)});pt.strictCreate=(e,t)=>new pt({shape:()=>e,unknownKeys:"strict",catchall:di.create(),typeName:re.ZodObject,...pe(t)});pt.lazycreate=(e,t)=>new pt({shape:e,unknownKeys:"strip",catchall:di.create(),typeName:re.ZodObject,...pe(t)});Bc=class Bc extends be{_parse(e){let{ctx:t}=this._processInputParams(e),r=this._def.options;function n(i){for(let o of i)if(o.result.status==="valid")return o.result;for(let o of i)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;let s=i.map((o)=>new $r(o.ctx.common.issues));return L(t,{code:I.invalid_union,unionErrors:s}),ee}if(t.common.async)return Promise.all(r.map(async(i)=>{let s={...t,common:{...t.common,issues:[]},parent:null};return{result:await i._parseAsync({data:t.data,path:t.path,parent:s}),ctx:s}})).then(n);else{let i=void 0,s=[];for(let a of r){let c={...t,common:{...t.common,issues:[]},parent:null},u=a._parseSync({data:t.data,path:t.path,parent:c});if(u.status==="valid")return u;else if(u.status==="dirty"&&!i)i={result:u,ctx:c};if(c.common.issues.length)s.push(c.common.issues)}if(i)return t.common.issues.push(...i.ctx.common.issues),i.result;let o=s.map((a)=>new $r(a));return L(t,{code:I.invalid_union,unionErrors:o}),ee}}get options(){return this._def.options}};Bc.create=(e,t)=>new Bc({options:e,typeName:re.ZodUnion,...pe(t)});G0=class G0 extends be{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==N.object)return L(t,{code:I.invalid_type,expected:N.object,received:t.parsedType}),ee;let r=this.discriminator,n=t.data[r],i=this.optionsMap.get(n);if(!i)return L(t,{code:I.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),ee;if(t.common.async)return i._parseAsync({data:t.data,path:t.path,parent:t});else return i._parseSync({data:t.data,path:t.path,parent:t})}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,r){let n=new Map;for(let i of t){let s=Li(i.shape[e]);if(!s.length)throw Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let o of s){if(n.has(o))throw Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);n.set(o,i)}}return new G0({typeName:re.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:n,...pe(r)})}};Lc=class Lc extends be{_parse(e){let{status:t,ctx:r}=this._processInputParams(e),n=(i,s)=>{if(z0(i)||z0(s))return ee;let o=jw(i.value,s.value);if(!o.valid)return L(r,{code:I.invalid_intersection_types}),ee;if(H0(i)||H0(s))t.dirty();return{status:t.value,value:o.data}};if(r.common.async)return 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(([i,s])=>n(i,s));else return 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}))}};Lc.create=(e,t,r)=>new Lc({left:e,right:t,typeName:re.ZodIntersection,...pe(r)});fi=class fi extends be{_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==N.array)return L(r,{code:I.invalid_type,expected:N.array,received:r.parsedType}),ee;if(r.data.length<this._def.items.length)return L(r,{code:I.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),ee;if(!this._def.rest&&r.data.length>this._def.items.length)L(r,{code:I.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty();let i=[...r.data].map((s,o)=>{let a=this._def.items[o]||this._def.rest;if(!a)return null;return a._parse(new An(r,s,r.path,o))}).filter((s)=>!!s);if(r.common.async)return Promise.all(i).then((s)=>qt.mergeArray(t,s));else return qt.mergeArray(t,i)}get items(){return this._def.items}rest(e){return new fi({...this._def,rest:e})}};fi.create=(e,t)=>{if(!Array.isArray(e))throw Error("You must pass an array of schemas to z.tuple([ ... ])");return new fi({items:e,typeName:re.ZodTuple,rest:null,...pe(t)})};kd=class kd extends be{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==N.object)return L(r,{code:I.invalid_type,expected:N.object,received:r.parsedType}),ee;let n=[],i=this._def.keyType,s=this._def.valueType;for(let o in r.data)n.push({key:i._parse(new An(r,o,r.path,o)),value:s._parse(new An(r,r.data[o],r.path,o)),alwaysSet:o in r.data});if(r.common.async)return qt.mergeObjectAsync(t,n);else return qt.mergeObjectSync(t,n)}get element(){return this._def.valueType}static create(e,t,r){if(t instanceof be)return new kd({keyType:e,valueType:t,typeName:re.ZodRecord,...pe(r)});return new kd({keyType:Rn.create(),valueType:e,typeName:re.ZodRecord,...pe(t)})}};Pd=class Pd extends be{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==N.map)return L(r,{code:I.invalid_type,expected:N.map,received:r.parsedType}),ee;let n=this._def.keyType,i=this._def.valueType,s=[...r.data.entries()].map(([o,a],c)=>({key:n._parse(new An(r,o,r.path,[c,"key"])),value:i._parse(new An(r,a,r.path,[c,"value"]))}));if(r.common.async){let o=new Map;return Promise.resolve().then(async()=>{for(let a of s){let c=await a.key,u=await a.value;if(c.status==="aborted"||u.status==="aborted")return ee;if(c.status==="dirty"||u.status==="dirty")t.dirty();o.set(c.value,u.value)}return{status:t.value,value:o}})}else{let o=new Map;for(let a of s){let{key:c,value:u}=a;if(c.status==="aborted"||u.status==="aborted")return ee;if(c.status==="dirty"||u.status==="dirty")t.dirty();o.set(c.value,u.value)}return{status:t.value,value:o}}}};Pd.create=(e,t,r)=>new Pd({valueType:t,keyType:e,typeName:re.ZodMap,...pe(r)});Ho=class Ho extends be{_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==N.set)return L(r,{code:I.invalid_type,expected:N.set,received:r.parsedType}),ee;let n=this._def;if(n.minSize!==null){if(r.data.size<n.minSize.value)L(r,{code:I.too_small,minimum:n.minSize.value,type:"set",inclusive:!0,exact:!1,message:n.minSize.message}),t.dirty()}if(n.maxSize!==null){if(r.data.size>n.maxSize.value)L(r,{code:I.too_big,maximum:n.maxSize.value,type:"set",inclusive:!0,exact:!1,message:n.maxSize.message}),t.dirty()}let i=this._def.valueType;function s(a){let c=new Set;for(let u of a){if(u.status==="aborted")return ee;if(u.status==="dirty")t.dirty();c.add(u.value)}return{status:t.value,value:c}}let o=[...r.data.values()].map((a,c)=>i._parse(new An(r,a,r.path,c)));if(r.common.async)return Promise.all(o).then((a)=>s(a));else return s(o)}min(e,t){return new Ho({...this._def,minSize:{value:e,message:Y.toString(t)}})}max(e,t){return new Ho({...this._def,maxSize:{value:e,message:Y.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};Ho.create=(e,t)=>new Ho({valueType:e,minSize:null,maxSize:null,typeName:re.ZodSet,...pe(t)});Nc=class Nc extends be{constructor(){super(...arguments);this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==N.function)return L(t,{code:I.invalid_type,expected:N.function,received:t.parsedType}),ee;function r(o,a){return Fd({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Pc(),Bi].filter((c)=>!!c),issueData:{code:I.invalid_arguments,argumentsError:a}})}function n(o,a){return Fd({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Pc(),Bi].filter((c)=>!!c),issueData:{code:I.invalid_return_type,returnTypeError:a}})}let i={errorMap:t.common.contextualErrorMap},s=t.data;if(this._def.returns instanceof Go){let o=this;return Kt(async function(...a){let c=new $r([]),u=await o._def.args.parseAsync(a,i).catch((m)=>{throw c.addIssue(r(a,m)),c}),d=await Reflect.apply(s,this,u);return await o._def.returns._def.type.parseAsync(d,i).catch((m)=>{throw c.addIssue(n(d,m)),c})})}else{let o=this;return Kt(function(...a){let c=o._def.args.safeParse(a,i);if(!c.success)throw new $r([r(a,c.error)]);let u=Reflect.apply(s,this,c.data),d=o._def.returns.safeParse(u,i);if(!d.success)throw new $r([n(u,d.error)]);return d.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Nc({...this._def,args:fi.create(e).rest(Vs.create())})}returns(e){return new Nc({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,r){return new Nc({args:e?e:fi.create([]).rest(Vs.create()),returns:t||Vs.create(),typeName:re.ZodFunction,...pe(r)})}};Uc=class Uc extends be{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};Uc.create=(e,t)=>new Uc({getter:e,typeName:re.ZodLazy,...pe(t)});Vc=class Vc extends be{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return L(t,{received:t.data,code:I.invalid_literal,expected:this._def.value}),ee}return{status:"valid",value:e.data}}get value(){return this._def.value}};Vc.create=(e,t)=>new Vc({value:e,typeName:re.ZodLiteral,...pe(t)});Gs=class Gs extends be{_parse(e){if(typeof e.data!=="string"){let t=this._getOrReturnCtx(e),r=this._def.values;return L(t,{expected:De.joinValues(r),received:t.parsedType,code:I.invalid_type}),ee}if(!this._cache)this._cache=new Set(this._def.values);if(!this._cache.has(e.data)){let t=this._getOrReturnCtx(e),r=this._def.values;return L(t,{received:t.data,code:I.invalid_enum_value,options:r}),ee}return Kt(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return Gs.create(e,{...this._def,...t})}exclude(e,t=this._def){return Gs.create(this.options.filter((r)=>!e.includes(r)),{...this._def,...t})}};Gs.create=hH;zc=class zc extends be{_parse(e){let t=De.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==N.string&&r.parsedType!==N.number){let n=De.objectValues(t);return L(r,{expected:De.joinValues(n),received:r.parsedType,code:I.invalid_type}),ee}if(!this._cache)this._cache=new Set(De.getValidEnumValues(this._def.values));if(!this._cache.has(e.data)){let n=De.objectValues(t);return L(r,{received:r.data,code:I.invalid_enum_value,options:n}),ee}return Kt(e.data)}get enum(){return this._def.values}};zc.create=(e,t)=>new zc({values:e,typeName:re.ZodNativeEnum,...pe(t)});Go=class Go extends be{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==N.promise&&t.common.async===!1)return L(t,{code:I.invalid_type,expected:N.promise,received:t.parsedType}),ee;let r=t.parsedType===N.promise?t.data:Promise.resolve(t.data);return Kt(r.then((n)=>this._def.type.parseAsync(n,{path:t.path,errorMap:t.common.contextualErrorMap})))}};Go.create=(e,t)=>new Go({type:e,typeName:re.ZodPromise,...pe(t)});kn=class kn extends be{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===re.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:r}=this._processInputParams(e),n=this._def.effect||null,i={addIssue:(s)=>{if(L(r,s),s.fatal)t.abort();else t.dirty()},get path(){return r.path}};if(i.addIssue=i.addIssue.bind(i),n.type==="preprocess"){let s=n.transform(r.data,i);if(r.common.async)return Promise.resolve(s).then(async(o)=>{if(t.value==="aborted")return ee;let a=await this._def.schema._parseAsync({data:o,path:r.path,parent:r});if(a.status==="aborted")return ee;if(a.status==="dirty")return Uo(a.value);if(t.value==="dirty")return Uo(a.value);return a});else{if(t.value==="aborted")return ee;let o=this._def.schema._parseSync({data:s,path:r.path,parent:r});if(o.status==="aborted")return ee;if(o.status==="dirty")return Uo(o.value);if(t.value==="dirty")return Uo(o.value);return o}}if(n.type==="refinement"){let s=(o)=>{let a=n.refinement(o,i);if(r.common.async)return Promise.resolve(a);if(a instanceof Promise)throw Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(r.common.async===!1){let o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(o.status==="aborted")return ee;if(o.status==="dirty")t.dirty();return s(o.value),{status:t.value,value:o.value}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then((o)=>{if(o.status==="aborted")return ee;if(o.status==="dirty")t.dirty();return s(o.value).then(()=>({status:t.value,value:o.value}))})}if(n.type==="transform")if(r.common.async===!1){let s=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!Us(s))return ee;let o=n.transform(s.value,i);if(o instanceof Promise)throw Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:o}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then((s)=>{if(!Us(s))return ee;return Promise.resolve(n.transform(s.value,i)).then((o)=>({status:t.value,value:o}))});De.assertNever(n)}};kn.create=(e,t,r)=>new kn({schema:e,typeName:re.ZodEffects,effect:t,...pe(r)});kn.createWithPreprocess=(e,t,r)=>new kn({schema:t,effect:{type:"preprocess",transform:e},typeName:re.ZodEffects,...pe(r)});On=class On extends be{_parse(e){if(this._getType(e)===N.undefined)return Kt(void 0);return this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};On.create=(e,t)=>new On({innerType:e,typeName:re.ZodOptional,...pe(t)});Ui=class Ui extends be{_parse(e){if(this._getType(e)===N.null)return Kt(null);return this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Ui.create=(e,t)=>new Ui({innerType:e,typeName:re.ZodNullable,...pe(t)});Hc=class Hc extends be{_parse(e){let{ctx:t}=this._processInputParams(e),r=t.data;if(t.parsedType===N.undefined)r=this._def.defaultValue();return this._def.innerType._parse({data:r,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};Hc.create=(e,t)=>new Hc({innerType:e,typeName:re.ZodDefault,defaultValue:typeof t.default==="function"?t.default:()=>t.default,...pe(t)});Gc=class Gc extends be{_parse(e){let{ctx:t}=this._processInputParams(e),r={...t,common:{...t.common,issues:[]}},n=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});if(Ic(n))return n.then((i)=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new $r(r.common.issues)},input:r.data})}));else return{status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new $r(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}};Gc.create=(e,t)=>new Gc({innerType:e,typeName:re.ZodCatch,catchValue:typeof t.catch==="function"?t.catch:()=>t.catch,...pe(t)});Id=class Id extends be{_parse(e){if(this._getType(e)!==N.nan){let r=this._getOrReturnCtx(e);return L(r,{code:I.invalid_type,expected:N.nan,received:r.parsedType}),ee}return{status:"valid",value:e.data}}};Id.create=(e)=>new Id({typeName:re.ZodNaN,...pe(e)});eNe=Symbol("zod_brand");W0=class W0 extends be{_parse(e){let{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}};Td=class Td extends be{_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{let i=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});if(i.status==="aborted")return ee;if(i.status==="dirty")return t.dirty(),Uo(i.value);else return this._def.out._parseAsync({data:i.value,path:r.path,parent:r})})();else{let n=this._def.in._parseSync({data:r.data,path:r.path,parent:r});if(n.status==="aborted")return ee;if(n.status==="dirty")return t.dirty(),{status:"dirty",value:n.value};else return this._def.out._parseSync({data:n.value,path:r.path,parent:r})}}static create(e,t){return new Td({in:e,out:t,typeName:re.ZodPipeline})}};Wc=class Wc extends be{_parse(e){let t=this._def.innerType._parse(e),r=(n)=>{if(Us(n))n.value=Object.freeze(n.value);return n};return Ic(t)?t.then((n)=>r(n)):r(t)}unwrap(){return this._def.innerType}};Wc.create=(e,t)=>new Wc({innerType:e,typeName:re.ZodReadonly,...pe(t)});tNe={object:pt.lazycreate};(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"})(re||(re={}));yH=Rn.create,xH=zs.create,nNe=Id.create,iNe=Hs.create,bH=qc.create,sNe=Vo.create,oNe=Od.create,aNe=jc.create,cNe=Mc.create,uNe=zo.create,lNe=Vs.create,dNe=di.create,fNe=Ad.create,pNe=Fn.create,mNe=pt.create,hNe=pt.strictCreate,gNe=Bc.create,yNe=G0.create,xNe=Lc.create,bNe=fi.create,vNe=kd.create,_Ne=Pd.create,wNe=Ho.create,DNe=Nc.create,ENe=Uc.create,SNe=Vc.create,$Ne=Gs.create,CNe=zc.create,RNe=Go.create,FNe=kn.create,ONe=On.create,ANe=Ui.create,kNe=kn.createWithPreprocess,PNe=Td.create,qNe={string:(e)=>Rn.create({...e,coerce:!0}),number:(e)=>zs.create({...e,coerce:!0}),boolean:(e)=>qc.create({...e,coerce:!0}),bigint:(e)=>Hs.create({...e,coerce:!0}),date:(e)=>Vo.create({...e,coerce:!0})},jNe=ee});var E={};Ji(E,{BRAND:()=>eNe,DIRTY:()=>Uo,EMPTY_PATH:()=>k5e,INVALID:()=>ee,NEVER:()=>jNe,OK:()=>Kt,ParseStatus:()=>qt,Schema:()=>be,ZodAny:()=>zo,ZodArray:()=>Fn,ZodBigInt:()=>Hs,ZodBoolean:()=>qc,ZodBranded:()=>W0,ZodCatch:()=>Gc,ZodDate:()=>Vo,ZodDefault:()=>Hc,ZodDiscriminatedUnion:()=>G0,ZodEffects:()=>kn,ZodEnum:()=>Gs,ZodError:()=>$r,ZodFirstPartyTypeKind:()=>re,ZodFunction:()=>Nc,ZodIntersection:()=>Lc,ZodIssueCode:()=>I,ZodLazy:()=>Uc,ZodLiteral:()=>Vc,ZodMap:()=>Pd,ZodNaN:()=>Id,ZodNativeEnum:()=>zc,ZodNever:()=>di,ZodNull:()=>Mc,ZodNullable:()=>Ui,ZodNumber:()=>zs,ZodObject:()=>pt,ZodOptional:()=>On,ZodParsedType:()=>N,ZodPipeline:()=>Td,ZodPromise:()=>Go,ZodReadonly:()=>Wc,ZodRecord:()=>kd,ZodSchema:()=>be,ZodSet:()=>Ho,ZodString:()=>Rn,ZodSymbol:()=>Od,ZodTransformer:()=>kn,ZodTuple:()=>fi,ZodType:()=>be,ZodUndefined:()=>jc,ZodUnion:()=>Bc,ZodUnknown:()=>Vs,ZodVoid:()=>Ad,addIssueToContext:()=>L,any:()=>uNe,array:()=>pNe,bigint:()=>iNe,boolean:()=>bH,coerce:()=>qNe,custom:()=>gH,date:()=>sNe,datetimeRegex:()=>mH,defaultErrorMap:()=>Bi,discriminatedUnion:()=>yNe,effect:()=>FNe,enum:()=>$Ne,function:()=>DNe,getErrorMap:()=>Pc,getParsedType:()=>li,instanceof:()=>rNe,intersection:()=>xNe,isAborted:()=>z0,isAsync:()=>Ic,isDirty:()=>H0,isValid:()=>Us,late:()=>tNe,lazy:()=>ENe,literal:()=>SNe,makeIssue:()=>Fd,map:()=>_Ne,nan:()=>nNe,nativeEnum:()=>CNe,never:()=>dNe,null:()=>cNe,nullable:()=>ANe,number:()=>xH,object:()=>mNe,objectUtil:()=>Iw,oboolean:()=>NNe,onumber:()=>TNe,optional:()=>ONe,ostring:()=>INe,pipeline:()=>PNe,preprocess:()=>kNe,promise:()=>RNe,quotelessJson:()=>F5e,record:()=>vNe,set:()=>wNe,setErrorMap:()=>A5e,strictObject:()=>hNe,string:()=>yH,symbol:()=>oNe,transformer:()=>FNe,tuple:()=>bNe,undefined:()=>aNe,union:()=>gNe,unknown:()=>lNe,util:()=>De,void:()=>fNe});var Mw=O(()=>{V0();Nw();cH();Rd();vH();U0()});var Wo=O(()=>{Mw();Mw()});import{copyFileSync as MNe,existsSync as _H,mkdirSync as BNe}from"fs";import{homedir as Y0}from"os";import{join as Kc}from"path";function UNe(e){let t=e.trim().replace(/\/+$/,"");try{let r=new URL(t);return r.protocol=r.protocol.toLowerCase(),r.host=r.host.toLowerCase(),r.toString().replace(/\/+$/,"")}catch{return console.error(`[nemar] could not parse stored apiUrl ${JSON.stringify(e)}; leaving as-is`),t}}function VNe(){return process.env.NEMAR_CONFIG_DIR||Kc(Y0(),".config","nemar")}function zNe(e){if(process.env.NEMAR_CONFIG_DIR)return;let t=Kc(e,"config.json");if(_H(t))return;let r=[];if(process.platform==="darwin")r.push(Kc(Y0(),"Library","Preferences","nemar-nodejs","config.json"));if(process.platform==="win32"){let n=process.env.APPDATA||Kc(Y0(),"AppData","Roaming");r.push(Kc(n,"nemar-nodejs","config.json"))}r.push(Kc(Y0(),".config","nemar-nodejs","config.json"));for(let n of r)if(_H(n))try{BNe(e,{recursive:!0}),MNe(n,t),console.error(`[nemar] Config migrated from ${n} to ${t}
|
|
99
99
|
[nemar] You can safely remove the old file.`);return}catch(i){console.error(`[nemar] Failed to migrate config from ${n}:`,i,`
|
|
100
|
-
[nemar] You can manually copy ${n} to ${t}`)}}function Pn(){let e=VNe();if(K0&&wH===e)return K0;if(zNe(e),K0=new L0({projectName:"nemar",schema:{activeAccount:{type:"string"},accounts:{type:"object"},apiKey:{type:"string"},apiUrl:{type:"string"},username:{type:"string"},email:{type:"string"},githubUsername:{type:"string"},sandboxCompleted:{type:"boolean"},sandboxDatasetId:{type:"string"}},cwd:e}),wH=e,!DH.has(e))DH.add(e),GNe(),WNe();return K0}function GNe(){let e=Pn(),t=e.get("accounts");if(t&&Object.keys(t).length>0)return;let r=e.get("apiKey"),n=e.get("username");if(!r&&!n)return;try{let i=n||"default",s={};for(let o of HNe){let a=e.get(o);if(a!==void 0)s[o]=a}e.store={activeAccount:i,accounts:{[i]:s}}}catch(i){console.error("Config migration failed (legacy config preserved):",i)}}function WNe(){let e=Pn(),t=e.store,r=t.accounts,n=!1;if(r)for(let[s,o]of Object.entries(r)){let a=o?.apiUrl;if(!a)continue;if(LNe.has(UNe(a)))r[s]={...o,apiUrl:Ko},console.error(`[nemar] migrated stored apiUrl for account "${s}": ${a} -> ${Ko}`),n=!0}let i=t.apiUrl;if(r&&Object.keys(r).length>0&&i!==void 0){let{apiUrl:s,...o}=t;try{e.store=o,console.error(`[nemar] removed stale top-level apiUrl from config (was: ${i})`),n=!1}catch(a){console.error("API URL cleanup failed (config file unchanged):",a)}}if(n)try{e.store={...e.store,accounts:r}}catch(s){console.error("API URL migration failed (config file unchanged):",s)}}function J0(){return Pn().get("activeAccount")}function Yc(){return Pn().get("accounts")||{}}function bt(){let e={apiUrl:Ko},t=J0();if(!t)return e;return Yc()[t]||e}function EH(){return!!bt().sandboxCompleted}function In(e,t){let r=Pn(),n=r.get("activeAccount")||"default",i=r.get("accounts")||{};if(!i[n])i[n]={apiUrl:Ko};i[n][e]=t,r.store={...r.store,accounts:i,activeAccount:n}}function Bw(e){let t=J0();if(!t)return;let r=Yc();if(r[t])delete r[t][e],Pn().set("accounts",r)}function SH(){let e=Pn(),t=J0();if(!t){e.clear();return}let r=Yc();delete r[t];let n=Object.keys(r);if(n.length>0)e.store={...e.store,accounts:r,activeAccount:n[0]};else e.clear()}function $H(){Pn().clear()}function He(){return!!bt().apiKey}function CH(){return Pn().path}function Nd(){let e=Yc(),t=J0();return Object.entries(e).map(([r,n])=>({username:n.username||r,email:n.email,githubUsername:n.githubUsername,active:r===t}))}function RH(e,t){let r=Pn(),n=Yc();n[e]=t,r.store={...r.store,accounts:n,activeAccount:e}}function FH(e){let t=Pn(),r=Yc();if(r[e])return t.store={...t.store,activeAccount:e},r[e];for(let[n,i]of Object.entries(r))if(i.githubUsername===e)return t.store={...t.store,activeAccount:n},i;return null}var Ko="https://
|
|
100
|
+
[nemar] You can manually copy ${n} to ${t}`)}}function Pn(){let e=VNe();if(K0&&wH===e)return K0;if(zNe(e),K0=new L0({projectName:"nemar",schema:{activeAccount:{type:"string"},accounts:{type:"object"},apiKey:{type:"string"},apiUrl:{type:"string"},username:{type:"string"},email:{type:"string"},githubUsername:{type:"string"},sandboxCompleted:{type:"boolean"},sandboxDatasetId:{type:"string"}},cwd:e}),wH=e,!DH.has(e))DH.add(e),GNe(),WNe();return K0}function GNe(){let e=Pn(),t=e.get("accounts");if(t&&Object.keys(t).length>0)return;let r=e.get("apiKey"),n=e.get("username");if(!r&&!n)return;try{let i=n||"default",s={};for(let o of HNe){let a=e.get(o);if(a!==void 0)s[o]=a}e.store={activeAccount:i,accounts:{[i]:s}}}catch(i){console.error("Config migration failed (legacy config preserved):",i)}}function WNe(){let e=Pn(),t=e.store,r=t.accounts,n=!1;if(r)for(let[s,o]of Object.entries(r)){let a=o?.apiUrl;if(!a)continue;if(LNe.has(UNe(a)))r[s]={...o,apiUrl:Ko},console.error(`[nemar] migrated stored apiUrl for account "${s}": ${a} -> ${Ko}`),n=!0}let i=t.apiUrl;if(r&&Object.keys(r).length>0&&i!==void 0){let{apiUrl:s,...o}=t;try{e.store=o,console.error(`[nemar] removed stale top-level apiUrl from config (was: ${i})`),n=!1}catch(a){console.error("API URL cleanup failed (config file unchanged):",a)}}if(n)try{e.store={...e.store,accounts:r}}catch(s){console.error("API URL migration failed (config file unchanged):",s)}}function J0(){return Pn().get("activeAccount")}function Yc(){return Pn().get("accounts")||{}}function bt(){let e={apiUrl:Ko},t=J0();if(!t)return e;return Yc()[t]||e}function EH(){return!!bt().sandboxCompleted}function In(e,t){let r=Pn(),n=r.get("activeAccount")||"default",i=r.get("accounts")||{};if(!i[n])i[n]={apiUrl:Ko};i[n][e]=t,r.store={...r.store,accounts:i,activeAccount:n}}function Bw(e){let t=J0();if(!t)return;let r=Yc();if(r[t])delete r[t][e],Pn().set("accounts",r)}function SH(){let e=Pn(),t=J0();if(!t){e.clear();return}let r=Yc();delete r[t];let n=Object.keys(r);if(n.length>0)e.store={...e.store,accounts:r,activeAccount:n[0]};else e.clear()}function $H(){Pn().clear()}function He(){return!!bt().apiKey}function CH(){return Pn().path}function Nd(){let e=Yc(),t=J0();return Object.entries(e).map(([r,n])=>({username:n.username||r,email:n.email,githubUsername:n.githubUsername,active:r===t}))}function RH(e,t){let r=Pn(),n=Yc();n[e]=t,r.store={...r.store,accounts:n,activeAccount:e}}function FH(e){let t=Pn(),r=Yc();if(r[e])return t.store={...t.store,activeAccount:e},r[e];for(let[n,i]of Object.entries(r))if(i.githubUsername===e)return t.store={...t.store,activeAccount:n},i;return null}var Ko="https://api.nemar.org",LNe,tit,K0=null,wH=null,DH,HNe;var Ws=O(()=>{oH();Wo();LNe=new Set(["https://api.osc.earth/nemar","https://nemar-api.neuromechanist.workers.dev","https://nemar-api-dev.shirazi-10f.workers.dev"]);tit=E.object({apiKey:E.string().optional(),apiUrl:E.string().url().default(Ko),username:E.string().optional(),email:E.string().email().optional(),githubUsername:E.string().optional(),sandboxCompleted:E.boolean().optional(),sandboxDatasetId:E.string().optional(),dismissedNoticeIds:E.array(E.number()).optional()});DH=new Set;HNe=["apiKey","apiUrl","username","email","githubUsername","sandboxCompleted","sandboxDatasetId","dismissedNoticeIds"]});function X0(e){if(OH)return;OH=!0;let t=l.yellow("\u2500".repeat(60)),r=l.yellow.bold("[MAINTENANCE]"),n=l.dim(`mode: ${e.mode}`),i=e.eta?`
|
|
101
101
|
${l.dim(`eta: ${e.eta}`)}`:"";process.stderr.write(`${t}
|
|
102
102
|
${r} ${e.message}
|
|
103
103
|
${n}${i}
|
|
104
104
|
${t}
|
|
105
|
-
`)}var OH=!1;var Lw=O(()=>{Ye()});var kH;var AH=O(()=>{kH={name:"nemar-cli",version:"0.9.15-dev.2285",description:"CLI for NEMAR (Neuroelectromagnetic Data Archive and Tools Resource) dataset management",type:"module",main:"dist/index.js",bin:{nemar:"dist/index.js"},scripts:{dev:"bun run src/index.ts",build:"bun build src/index.ts --outdir dist --target bun --minify && sed '1s|#!/usr/bin/env node|#!/usr/bin/env bun|' dist/index.js > dist/index.js.tmp && mv dist/index.js.tmp dist/index.js",test:"bun test",lint:"biome check src/","lint:fix":"biome check --fix src/",format:"biome format --write src/",typecheck:"tsc --noEmit && tsc --noEmit -p backend","generate-openapi":"bun run scripts/generate-openapi.ts",prepublishOnly:"bun run build",prepare:"husky",postinstall:"bun scripts/postinstall-check.mjs",deploy:"wrangler deploy",preview:"wrangler dev"},keywords:["nemar","bids","neuroimaging","eeg","emg","datalad","cli"],author:"NEMAR Team",license:"CC-BY-NC-ND-4.0",repository:{type:"git",url:"git+https://github.com/nemarOrg/nemar-cli.git"},bugs:{url:"https://github.com/nemarOrg/nemar-cli/issues"},homepage:"https://docs.nemar.org",engines:{bun:">=1.0.0"},files:["dist","scripts/postinstall-check.mjs","scripts/recover-datasets.json","scripts/withdrawn-datasets.json","README.md","LICENSE"],dependencies:{chalk:"^5.3.0",commander:"^12.1.0",conf:"^13.0.1",inquirer:"^9.2.15",ora:"^8.0.1",semver:"^7.8.5",zod:"^3.23.8"},"lint-staged":{"src/**/*.{ts,tsx}":["biome check --fix"],"backend/src/**/*.{ts,tsx}":["biome check --fix"]},devDependencies:{"@asteasolutions/zod-to-openapi":"^7.3.4","@biomejs/biome":"1.9.4","@types/bun":"latest","@types/inquirer":"^9.0.7","@types/semver":"^7.8.0",ajv:"^8.20.0","ajv-formats":"^3.0.1",bcryptjs:"^3.0.3",husky:"^9.1.7","lint-staged":"^16.3.2",typescript:"^5.5.4",wrangler:"^4.70.0",yaml:"^2.8.4"}}});var Yo;var Q0=O(()=>{AH();Yo=kH.version});function U(e){if(e instanceof Error)return e.message;return String(e)}var q,Jo;var ar=O(()=>{q=class q extends Error{statusCode;details;step;constructor(e,t,r,n){super(t);this.statusCode=e;this.details=r;this.step=n;this.name="ApiError"}};Jo=class Jo extends q{mode;eta;constructor(e,t,r,n){super(503,t,n);this.mode=e;this.eta=r;this.name="MaintenanceError"}}});function PH(){if(process.env.TEST_API_URL)return process.env.TEST_API_URL;if(Vw)return Uw;return bt().apiUrl||Uw}async function P(e,t={},r=!1,n){let i=`${PH()}${e}`,s={"Content-Type":"application/json","X-CLI-Version":Yo,...t.headers};if(r){let c=bt();if(!c.apiKey&&r===!0)throw new q(401,"Not authenticated. Run 'nemar auth login' first.");if(c.apiKey)s.Authorization=`Bearer ${c.apiKey}`}let o;try{o=await fetch(i,{...t,headers:s})}catch(c){throw new q(0,`Network error: Could not connect to ${PH()}`,{originalError:c instanceof Error?c.message:String(c)})}let a;try{a=await o.json()}catch{throw new q(o.status,`Invalid response from server (status ${o.status})`)}if(!o.ok){if(o.status===503&&(a.mode==="read-only"||a.mode==="full")){let c=typeof a.message==="string"?a.message:"NEMAR is in maintenance mode. Please retry shortly.",u=typeof a.eta==="string"?a.eta:null,d=new Jo(a.mode,c,u,a.details);throw X0(d),d}throw new q(o.status,a.error||a.message||"Request failed",a.details,typeof a.step==="string"?a.step:void 0)}if(n){let c=n.safeParse(a);if(!c.success)throw new q(o.status,`Response for ${e} did not match the expected NEMAR contract`,{issues:c.error.issues});return c.data}return a}var Uw="https://nemar-api-dev.sccn-org.workers.dev",Vw;var Ks=O(()=>{Ws();Lw();Q0();ar();Vw=Uw.includes("workers.dev")});async function IH(e,t){let r=new URLSearchParams;if(e)r.set("status",e);if(t)r.set("role",t);let n=r.toString()?`?${r.toString()}`:"";return P(`/admin/users${n}`,{},!0)}async function TH(e){return P(`/admin/approve/${e}`,{method:"POST"},!0)}async function NH(e){return P(`/admin/approve/by-id/${e}`,{method:"POST"},!0)}async function qH(e){return P(`/admin/revoke/${e}`,{method:"POST"},!0)}async function jH(e,t){return P(`/admin/users/${e}/role`,{method:"POST",body:JSON.stringify({role:t})},!0)}async function zw(e,t){return P(`/admin/datasets/${e}/visibility`,{method:"PATCH",body:JSON.stringify({visibility:t})},!0)}async function MH(e){return P(`/datasets/${e}/publish`,{method:"POST"},!0)}async function BH(e){return P(`/admin/datasets/${e}/ci`,{},!0)}async function Vi(e){return P(`/admin/datasets/${e}/ci`,{method:"POST"},!0)}async function Hw(e){return P(`/admin/datasets/${e}/ci/validate`,{method:"POST"},!0)}async function Gw(e){return P(`/admin/datasets/${e}/ci/sync`,{method:"POST"},!0)}async function LH(e,t){return P(`/admin/datasets/${e}/doi/concept`,{method:"POST",body:JSON.stringify(t)},!0)}async function qd(e){return P(`/admin/datasets/${e}/doi`,{},!0)}async function Ww(e,t){return P(`/admin/datasets/${e}/doi/update`,{method:"POST",body:JSON.stringify(t)},!0)}async function UH(e,t){return P(`/admin/datasets/${e}/withdraw`,{method:"POST",body:JSON.stringify({reason:t.reason,dry_run:t.dryRun})},!0)}async function VH(e,t){return P(`/admin/datasets/${e}/restore`,{method:"POST",body:JSON.stringify({dry_run:t.dryRun})},!0)}async function zH(e){return P(`/admin/datasets/${e}/reset`,{method:"POST"},!0)}async function HH(e,t=!1){return P(`/admin/datasets/${e}`,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({force:t})},!0)}async function GH(e){return P("/admin/datasets/bulk-delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dataset_ids:e})},!0)}async function WH(e){return P("/admin/datasets/import",{method:"POST",body:JSON.stringify(e)},!0)}async function KH(e){return P("/admin/datasets/exemplar",{method:"POST",body:JSON.stringify(e)},!0)}async function YH(e){return P(`/admin/datasets/${e}/exemplar/remint-dois`,{method:"POST"},!0)}async function Kw(e,t){let r=new URLSearchParams;if(e)r.set("status",e);if(t!==void 0)r.set("blocklisted",t?"1":"0");let n=r.toString();return P(`/admin/imports${n?`?${n}`:""}`,{},!0)}async function JH(e){return P(`/admin/imports/${e}/rollback`,{method:"POST"},!0)}async function XH(e){return P(`/admin/imports/${e}/retry`,{method:"POST"},!0)}async function Yw(e){return P(`/admin/imports/${e}/verify`,{method:"POST"},!0)}async function QH(e){return P("/admin/imports/dispatch-cooldown",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dataset_ids:e})},!0)}async function Jc(e,t){return P(`/admin/datasets/${e}/reindex`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t??{})},!0)}async function ZH(e,t){return P("/admin/datasets/reindex/bulk",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filter:e,...t??{}})},!0)}async function eG(e){let t=e?.limit??15;return P(`/admin/datasets/hed-sweep?limit=${encodeURIComponent(String(t))}`,{method:"POST",headers:{"Content-Type":"application/json"}},!0)}async function tG(){return P("/admin/datasets/hed-sweep?reset=1",{method:"POST",headers:{"Content-Type":"application/json"}},!0)}async function rG(e){let t=e?.limit??50;return P(`/admin/datasets/recording-stats-sweep?limit=${encodeURIComponent(String(t))}`,{method:"POST",headers:{"Content-Type":"application/json"}},!0)}async function nG(){return P("/admin/datasets/recording-stats-sweep?reset=1",{method:"POST",headers:{"Content-Type":"application/json"}},!0)}async function iG(e){let t=e?.limit??15;return P(`/admin/datasets/signal-defaults-sweep?limit=${encodeURIComponent(String(t))}`,{method:"POST",headers:{"Content-Type":"application/json"}},!0)}async function sG(){return P("/admin/datasets/signal-defaults-sweep?reset=1",{method:"POST",headers:{"Content-Type":"application/json"}},!0)}async function oG(e){let t=e?.limit??15,r=new URLSearchParams({limit:String(t)});if(e?.olderThan!=null)r.set("older-than",String(e.olderThan));if(e?.before!=null)r.set("before",e.before);return P(`/admin/datasets/data-integrity-sweep?${r.toString()}`,{method:"POST",headers:{"Content-Type":"application/json"}},!0)}async function aG(){return P("/admin/datasets/data-integrity-sweep?reset=1",{method:"POST",headers:{"Content-Type":"application/json"}},!0)}async function cG(e,t){let r=t?.write?"":"?dry_run=1";return P(`/admin/datasets/${e}/availability-report${r}`,{method:"POST",headers:{"Content-Type":"application/json"}},!0)}async function uG(e){let t=e?.limit??30,r=new URLSearchParams({limit:String(t)});if(e?.missingOnly)r.set("missing-only","1");return P(`/admin/datasets/availability-report-sweep?${r.toString()}`,{method:"POST",headers:{"Content-Type":"application/json"}},!0)}async function lG(){return P("/admin/datasets/availability-report-sweep?reset=1",{method:"POST",headers:{"Content-Type":"application/json"}},!0)}async function dG(e){let t=new URLSearchParams;if(e?.prefix)t.set("prefix",e.prefix);if(e?.visibility)t.set("visibility",e.visibility);if(e?.limit)t.set("limit",String(e.limit));let r=t.toString()?`?${t.toString()}`:"";return P(`/admin/fleet/drift${r}`,{},!0)}async function Xc(e,t){return P(`/admin/datasets/${e}/enforce`,{method:"POST",body:JSON.stringify({dry_run:t})},!0)}async function fG(e){return P("/admin/datasets/enforce/bulk",{method:"POST",body:JSON.stringify({prefix:e.prefix,visibility:e.visibility,limit:e.limit,dry_run:e.dryRun})},!0)}async function pG(e,t=!1){return P(`/admin/datasets/${e}/revalidate${t?"?force=true":""}`,{method:"POST"},!0)}async function mG(e){let t=e?`?user=${encodeURIComponent(e)}`:"";return P(`/admin/email-preferences${t}`,{},!0)}async function hG(e,t){let r=t?`?user=${encodeURIComponent(t)}`:"";return P(`/admin/email-preferences${r}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)},!0)}async function Jw(e){return P("/admin/notify",{method:"POST",body:JSON.stringify(e)},!0)}async function gG(){return P("/admin/summary/coverage",{},!0)}async function yG(e,t,r){return P("/admin/manifest/dispatch",{method:"POST",body:JSON.stringify({dataset_id:e,version:t,skip_canary:r?.skipCanary??!1})},!0)}async function Xw(e){return P("/admin/doctor/scan",{method:"POST",body:JSON.stringify({...e?.check&&{check:e.check},...e?.datasetId&&{dataset_id:e.datasetId}})},!0)}async function Qw(e){return P("/admin/doctor/fix",{method:"POST",body:JSON.stringify({check:e.check,...e.datasetId&&{dataset_id:e.datasetId},...e.dryRun&&{dry_run:!0}})},!0)}async function xG(){return P("/admin/zarr-catalog/publish",{method:"POST"},!0)}async function bG(e){let t=new URLSearchParams;if(e?.limit!=null)t.set("limit",String(e.limit));let r=t.toString()?`?${t.toString()}`:"";return P(`/admin/datasets/zarr-fidelity-sweep${r}`,{method:"POST",headers:{"Content-Type":"application/json"}},!0)}var Qc=O(()=>{Ks()});async function pi(e,t){return P(`/datasets/${e}/upload-credentials`,{method:"POST",body:JSON.stringify({duration_seconds:t})},!0)}async function Zw(e,t){return P(`/datasets/${e}/download-credentials`,{method:"POST",body:JSON.stringify({duration_seconds:t})},!0)}async function vG(e){return P(`/admin/datasets/${e}/files`,{},!0)}async function _G(e){let t,r=0,n=[],i=!0;while(i){let s=await P(`/admin/datasets/${e}/s3-lock`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({continuation_token:t})},!0);if(r+=s.locked,s.failed?.length)n.push(...s.failed);if(i=s.hasMore,t=s.continuation_token,i&&!t)throw new q(500,"S3 lock paginated response missing continuation_token; aborting to avoid infinite loop")}return{locked:r,failed:n}}var Zc=O(()=>{Ks();ar()});function XNe(e){return e.startsWith("v")?e:`v${e}`}var YNe,JNe,wG,vit;var eD=O(()=>{Wo();YNe=/^v?\d+\.\d+\.\d+(?:-(?:rc|alpha|beta)\d*)?$/,JNe=/^v\d+\.\d+\.\d+(?:-(?:rc|alpha|beta)\d*)?$/;wG=E.string().regex(YNe,"must be a semver version, optionally v-prefixed").transform(XNe),vit=E.string().regex(JNe,"must be the canonical v-prefixed tag (vX.Y.Z)")});var QNe,ZNe,DG;var EG=O(()=>{Wo();QNe=E.object({id:E.number().int(),username:E.string().nullable(),email:E.string(),github_username:E.string().nullable(),role:E.string(),orcid:E.string().nullable().optional(),created_at:E.string().optional(),approved_at:E.string().nullable().optional(),dataset_count:E.number().int().optional(),sandbox_completed:E.boolean().optional(),sandbox_completed_at:E.string().nullable().optional(),sandbox_dataset_id:E.string().nullable().optional()}).passthrough(),ZNe=E.object({prefix:E.string(),created_at:E.string(),last_used_at:E.string().nullable()}).passthrough().nullable(),DG=E.object({user:QNe,token:ZNe.optional()}).passthrough()});function $G(e,t){if(e.zarr_index_url!=null&&e.zarr_status!=="ready")t.addIssue({code:E.ZodIssueCode.custom,message:"zarr_index_url must be null/absent unless zarr_status is 'ready'",path:["zarr_index_url"]})}function CG(e,t){if(e.zarr_verified_at!=null&&e.zarr_verify_status==null)t.addIssue({code:E.ZodIssueCode.custom,message:"zarr_verified_at must be null/absent unless zarr_verify_status is non-null",path:["zarr_verified_at"]})}var e9e="0.4.0",tD,eu,SG,t9e,r9e,n9e,RG,$it,FG,Cit,zi,i9e,Z0,Rit;var rD=O(()=>{Wo();eD();tD=E.enum(["openneuro","nemar","gin","other"]),eu=E.union([E.literal(0),E.literal(1)]).nullable(),SG=E.object({dataset_id:E.string(),id:E.string().optional(),name:E.string(),description:E.string().nullable().optional(),status:E.string(),visibility:E.string(),concept_doi:E.string().nullable().optional(),doi:E.string().nullable().optional(),created_at:E.string(),updated_at:E.string().optional(),owner_username:E.string().nullable().optional(),source:E.string().nullable().optional(),modalities:E.string().optional(),participants:E.number().int().nonnegative(),tasks:E.string().optional(),authors:E.string().optional(),license:E.string().optional(),file_size:E.number().nonnegative(),file_size_formatted:E.string().optional(),total_files:E.number().nonnegative().nullable().optional(),num_citations:E.number().int().nonnegative().optional(),n_channels:E.number().int().nullable().optional(),electrode_system:E.string().nullable().optional(),has_hed:eu.optional(),hed_version:E.string().nullable().optional(),data_complete:eu.optional(),bytes_present:E.number().nonnegative().nullable().optional(),latest_version:wG.nullable().optional(),subject_count:E.number().int().nullable().optional(),file_size_bytes:E.number().nullable().optional(),sessions_count:E.number().int().nullable().optional(),age_min:E.number().nullable().optional(),age_max:E.number().nullable().optional(),bids_version:E.string().nullable().optional(),zarr_status:E.enum(["pending","ready","failed"]).nullable().optional(),zarr_store_count:E.number().int().nullable().optional(),zarr_converted_at:E.string().nullable().optional(),zarr_source_commit:E.string().nullable().optional(),zarr_errors:E.number().int().nullable().optional(),zarr_failure_count:E.number().int().nullable().optional(),zarr_deterministic:eu.optional(),zarr_failed_at:E.string().nullable().optional(),zarr_index_url:E.string().nullable().optional(),zarr_verify_status:E.enum(["verified","failed","unverifiable"]).nullable().optional(),zarr_verified_at:E.string().nullable().optional(),total_recording_duration:E.number().nullable().optional(),recording_duration_min:E.number().nullable().optional(),recording_duration_max:E.number().nullable().optional(),recording_count:E.number().int().nullable().optional(),recordings_unavailable:E.number().int().nullable().optional(),channel_count_min:E.number().int().nullable().optional(),channel_count_max:E.number().int().nullable().optional(),sampling_frequency:E.number().nullable().optional(),power_line_frequency:E.number().nullable().optional(),eeg_reference:E.string().nullable().optional(),placement_scheme:E.string().nullable().optional()}).passthrough();t9e=SG.superRefine((e,t)=>{$G(e,t),CG(e,t)}),r9e=SG.extend({file_size:E.number().nonnegative().nullable(),file_size_formatted:E.string().nullable().optional(),modalities:E.string().nullable().optional(),tasks:E.string().nullable().optional(),authors:E.string().nullable().optional(),license:E.string().nullable().optional(),owner_github:E.string().nullable().optional(),attestation_deposit_type:E.enum(["owner","redistribution"]).nullable().optional(),attestation_key_status:E.enum(["destroyed","retained"]).nullable().optional(),attestation_deidentified:eu.optional(),attestation_no_duplicate:eu.optional(),attestation_upstream_source:E.string().nullable().optional(),attestation_accepted_at:E.string().nullable().optional(),zarr_data_failures:E.object({count:E.number().int().nonnegative(),detail_ref:E.string(),compacted_by:E.string().optional(),pending:E.number().int().nonnegative().optional(),discovered:E.number().int().nonnegative().optional(),events_upload_failed:E.literal(!0).optional(),manifest_upload_failed:E.literal(!0).optional()}).passthrough().nullable().optional()}).passthrough().superRefine((e,t)=>{$G(e,t),CG(e,t)}),n9e=E.object({id:E.string(),name:E.string(),modalities:E.string().nullable().optional(),participants:E.number().int().nullable().optional(),doi:E.string().nullable().optional(),tasks:E.string().nullable().optional(),authors:E.string().nullable().optional(),has_hed:eu.optional(),score:E.number().optional(),snippet:E.string().optional()}).passthrough(),RG=E.record(E.string(),E.number().int().nonnegative()),$it=E.object({datasets:E.array(t9e),count:E.number().int().nonnegative(),total_count:E.number().int().nonnegative().optional(),limit:E.number().int().optional(),offset:E.number().int().optional(),excluded_unknown:E.number().int().nonnegative().optional(),excluded_unknown_by_facet:RG.optional()}).passthrough(),FG=E.object({results:E.array(n9e),count:E.number().int().nonnegative(),returned:E.number().int().nonnegative().optional(),offset:E.number().int().nonnegative().optional(),limit:E.number().int().optional(),candidate_ceiling:E.number().int().optional(),truncated:E.boolean().optional(),method:E.enum(["exact_id","text","text_fallback","semantic","unavailable"]).optional(),min_score:E.number().optional(),warning:E.string().optional(),excluded_unknown:E.number().int().nonnegative().optional(),excluded_unknown_by_facet:RG.optional()}).passthrough(),Cit=E.object({dataset:r9e}).passthrough(),zi=E.object({value:E.string(),count:E.number().int().nonnegative()}),i9e=E.object({values:E.array(zi),distinct_total:E.number().int().nonnegative(),truncated:E.boolean()}),Z0=E.object({"electrode-system":E.array(zi).optional(),source:E.array(zi).optional(),zarr:E.array(zi).optional(),powerline:E.array(zi).optional(),"bids-version":E.array(zi).optional(),"hed-version":E.array(zi).optional(),license:E.array(zi).optional(),modality:E.array(zi).optional(),task:i9e.optional(),warning:E.string().optional()}).passthrough(),Rit=E.object({schema_version:E.literal(e9e),doc_type:E.literal("dataset"),dataset_id:E.string().regex(/^[a-z]{2}\d+$/,"neuroschema dataset_id pattern"),name:E.string(),source:tD,recording_modality:E.array(E.string()).min(1),description:E.string().nullable().optional(),bids_version:E.string().nullable().optional(),license:E.string().nullable().optional()}).passthrough()});var eh=O(()=>{eD();EG();rD()});async function rh(e){return P(`/datasets/${e}/ci/status`,{},!0)}async function OG(e){return P(`/datasets/${e}/manifest`,{},!0)}async function nh(e,t){return P(`/datasets/${e}/manifest/${t}`,{},!0)}function AG(e){let t=e;if(!t.status)t.status="active";else if(!["active","archived","deleted"].includes(t.status))throw Error(`Invalid dataset status: ${t.status}`);if(!t.visibility)t.visibility="private";else if(!["public","private"].includes(t.visibility))throw Error(`Invalid dataset visibility: ${t.visibility}`);return t}async function tu(e={}){let t=new URLSearchParams;if(e.mine)t.set("mine","true");if(e.search)t.set("search",e.search);if(e.modality)t.set("modality",e.modality);if(e.author)t.set("author",e.author);if(e.task)t.set("task",e.task);if(e.license)t.set("license",e.license);if(e.hasDoi)t.set("has_doi","true");if(e.hasHed)t.set("has_hed","1");if(e.hasZarr)t.set("has_zarr","1");if(e.hasZarrVerified)t.set("has_zarr_verified","1");if(e.dataComplete)t.set("data_complete","1");if(e.recent)t.set("recent",String(e.recent));if(e.sort)t.set("sort",e.sort);if(e.limit!=null)t.set("limit",String(e.limit));if(e.offset!=null)t.set("offset",String(e.offset));if(e.owner)t.set("owner",e.owner);if(e.facets)for(let[i,s]of Object.entries(e.facets))t.set(i,s);if(e.includeUnknown)t.set("include_unknown","1");let r=t.toString()?`?${t.toString()}`:"",n=await P(`/datasets${r}`,{},e.mine?!0:"optional");return n.datasets=n.datasets.map(AG),n}async function kG(e){return P(`/datasets/resolve/${e}`,{},"optional")}async function PG(){return P("/datasets/facets",{signal:AbortSignal.timeout(5000)},"optional",Z0)}async function IG(e,t={}){let r=new URLSearchParams({q:e});if(t.modality)r.set("modality",t.modality);if(t.limit)r.set("limit",String(t.limit));if(t.hasHed)r.set("has_hed","1");if(t.hasZarr)r.set("has_zarr","1");if(t.hasZarrVerified)r.set("has_zarr_verified","1");if(t.author)r.set("author",t.author);if(t.task)r.set("task",t.task);if(t.license)r.set("license",t.license);if(t.hasDoi)r.set("has_doi","true");if(t.dataComplete)r.set("data_complete","1");if(t.recent)r.set("recent",String(t.recent));if(t.facets)for(let[i,s]of Object.entries(t.facets))r.set(i,s);if(t.includeUnknown)r.set("include_unknown","1");return await P(`/datasets/search?${r.toString()}`,{},"optional",FG)}async function vt(e){let t=await P(`/datasets/${e}`,{},"optional");return AG(t.dataset)}async function TG(e){return P(`/datasets/${e}/versions`,{},!0)}async function ih(e){return P("/datasets",{method:"POST",body:JSON.stringify(e)},!0)}async function sh(e){return P(`/datasets/${e}/finalize`,{method:"POST"},!0)}async function nD(e){return P(`/datasets/${e}/request-access`,{method:"POST"},!0)}async function NG(e,t){let r=t?`?status=${t}`:"";return P(`/datasets/${e}/access-requests${r}`,{},!0)}async function qG(e,t){return P(`/datasets/${e}/access-requests/${t}/approve`,{method:"POST"},!0)}async function jG(e,t){return P(`/datasets/${e}/access-requests/${t}/deny`,{method:"POST"},!0)}async function MG(e,t){return P(`/datasets/${e}/invite`,{method:"POST",body:JSON.stringify({username:t})},!0)}async function BG(e){return P(`/datasets/${e}/collaborators`,{},!0)}async function LG(e,t){return P(`/admin/datasets/${e}/enrichment`,{method:"POST",body:JSON.stringify(t)},!0)}var th;var Ys=O(()=>{eh();Ks();th=/^\d{4}-\d{4}-\d{4}-\d{3}[\dX]$/});var ru;var GG=O(()=>{ru=["ci_check","enrichment_check","s3_public_read","repo_public","tag_protect","doi_create","update_metadata","update_readme","create_tag","create_release","upload_to_zenodo","publish_doi","version_doi","s3_lock","sync_nemar","notify_user"]});async function nu(e){return P(`/datasets/${e}/publish/request`,{method:"POST"},!0)}async function KG(e){return P(`/datasets/${e}/publish/status`,{},!0)}async function YG(e){return P(`/datasets/${e}/publish/resend`,{method:"POST"},!0)}async function JG(e){let t=e?`?status=${e}`:"";return P(`/admin/publish/requests${t}`,{},!0)}async function XG(e,t){return P(`/admin/publish/${e}/deny`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({reason:t})},!0)}function s9e(e,t=[]){if(e){let r=ru.indexOf(e);if(r>=0)return r+1}return Math.min(t.length+1,ru.length)}function o9e(e){if(!(e instanceof q))return!1;if(e.statusCode===0)return!0;if(e.statusCode===429)return!0;if(e.statusCode>=500&&e.statusCode<600)return!0;if(e.statusCode===403&&/repository has been locked/i.test(e.message))return!0;return!1}async function iu(e,t=!1,r=!1,n=!1,i,s){let c,u,d=0,f=!1,m,p=t,g=[],y;function x(v,_,S,C){if(!s)return;s({step:v,stepIndex:s9e(v,_),stepTotal:ru.length,s3LockLocked:S,s3LockTotal:C,s3LockResumed:v==="s3_lock"&&f?!0:void 0})}for(let v=1;v<=5;v++)try{let _,S=!0;do{if(_=await P(`/admin/publish/${e}/approve`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({resume:S?p:!0,sandbox:r,s3_lock_continuation_token:c,s3_lock_total:u,skip_ci_check:n})},!0),S=!1,_.step_results)g.push(..._.step_results);if(_.s3_lock_total!==void 0)u=_.s3_lock_total;if(_.s3_lock_batch_count!==void 0)d+=_.s3_lock_batch_count;let C=_.step??_.step_results?.[_.step_results.length-1]?.step;if(C&&(C!==m||C==="s3_lock"))x(C,_.steps_completed??[],C==="s3_lock"?d:void 0,C==="s3_lock"?u:void 0),m=C;if(_.hasMore&&_.s3_lock_continuation_token!==void 0)c=_.s3_lock_continuation_token;else break}while(_.hasMore);if(g.length>0)_.step_results=WG(g);return _}catch(_){if(y=_,v===5||!o9e(_)){if(_ instanceof q&&g.length>0)_.stepResults=WG(g);throw _}let C=_;if(i?.({attempt:v,maxAttempts:5,delayMs:1e4,step:C.step,error:C.message}),await new Promise((w)=>setTimeout(w,1e4)),p=!0,c!==void 0)f=!0}throw y}function WG(e){let t=new Map;for(let r of e)t.set(r.step,r);return Array.from(t.values())}var jd=O(()=>{GG();Ks();ar()});function eW(e){oD=e}function aD(){return oD}function Md(e){if(oD)process.stderr.write(`${e}
|
|
105
|
+
`)}var OH=!1;var Lw=O(()=>{Ye()});var kH;var AH=O(()=>{kH={name:"nemar-cli",version:"0.9.15",description:"CLI for NEMAR (Neuroelectromagnetic Data Archive and Tools Resource) dataset management",type:"module",main:"dist/index.js",bin:{nemar:"dist/index.js"},scripts:{dev:"bun run src/index.ts",build:"bun build src/index.ts --outdir dist --target bun --minify && sed '1s|#!/usr/bin/env node|#!/usr/bin/env bun|' dist/index.js > dist/index.js.tmp && mv dist/index.js.tmp dist/index.js",test:"bun test",lint:"biome check src/","lint:fix":"biome check --fix src/",format:"biome format --write src/",typecheck:"tsc --noEmit && tsc --noEmit -p backend","generate-openapi":"bun run scripts/generate-openapi.ts",prepublishOnly:"bun run build",prepare:"husky",postinstall:"bun scripts/postinstall-check.mjs",deploy:"wrangler deploy",preview:"wrangler dev"},keywords:["nemar","bids","neuroimaging","eeg","emg","datalad","cli"],author:"NEMAR Team",license:"CC-BY-NC-ND-4.0",repository:{type:"git",url:"git+https://github.com/nemarOrg/nemar-cli.git"},bugs:{url:"https://github.com/nemarOrg/nemar-cli/issues"},homepage:"https://docs.nemar.org",engines:{bun:">=1.0.0"},files:["dist","scripts/postinstall-check.mjs","scripts/recover-datasets.json","scripts/withdrawn-datasets.json","README.md","LICENSE"],dependencies:{chalk:"^5.3.0",commander:"^12.1.0",conf:"^13.0.1",inquirer:"^9.2.15",ora:"^8.0.1",semver:"^7.8.5",zod:"^3.23.8"},"lint-staged":{"src/**/*.{ts,tsx}":["biome check --fix"],"backend/src/**/*.{ts,tsx}":["biome check --fix"]},devDependencies:{"@asteasolutions/zod-to-openapi":"^7.3.4","@biomejs/biome":"1.9.4","@types/bun":"latest","@types/inquirer":"^9.0.7","@types/semver":"^7.8.0",ajv:"^8.20.0","ajv-formats":"^3.0.1",bcryptjs:"^3.0.3",husky:"^9.1.7","lint-staged":"^16.3.2",typescript:"^5.5.4",wrangler:"^4.70.0",yaml:"^2.8.4"}}});var Yo;var Q0=O(()=>{AH();Yo=kH.version});function U(e){if(e instanceof Error)return e.message;return String(e)}var q,Jo;var ar=O(()=>{q=class q extends Error{statusCode;details;step;constructor(e,t,r,n){super(t);this.statusCode=e;this.details=r;this.step=n;this.name="ApiError"}};Jo=class Jo extends q{mode;eta;constructor(e,t,r,n){super(503,t,n);this.mode=e;this.eta=r;this.name="MaintenanceError"}}});function PH(){if(process.env.TEST_API_URL)return process.env.TEST_API_URL;if(Vw)return Uw;return bt().apiUrl||Uw}async function P(e,t={},r=!1,n){let i=`${PH()}${e}`,s={"Content-Type":"application/json","X-CLI-Version":Yo,...t.headers};if(r){let c=bt();if(!c.apiKey&&r===!0)throw new q(401,"Not authenticated. Run 'nemar auth login' first.");if(c.apiKey)s.Authorization=`Bearer ${c.apiKey}`}let o;try{o=await fetch(i,{...t,headers:s})}catch(c){throw new q(0,`Network error: Could not connect to ${PH()}`,{originalError:c instanceof Error?c.message:String(c)})}let a;try{a=await o.json()}catch{throw new q(o.status,`Invalid response from server (status ${o.status})`)}if(!o.ok){if(o.status===503&&(a.mode==="read-only"||a.mode==="full")){let c=typeof a.message==="string"?a.message:"NEMAR is in maintenance mode. Please retry shortly.",u=typeof a.eta==="string"?a.eta:null,d=new Jo(a.mode,c,u,a.details);throw X0(d),d}throw new q(o.status,a.error||a.message||"Request failed",a.details,typeof a.step==="string"?a.step:void 0)}if(n){let c=n.safeParse(a);if(!c.success)throw new q(o.status,`Response for ${e} did not match the expected NEMAR contract`,{issues:c.error.issues});return c.data}return a}var Uw="https://api.nemar.org",Vw;var Ks=O(()=>{Ws();Lw();Q0();ar();Vw=Uw.includes("workers.dev")});async function IH(e,t){let r=new URLSearchParams;if(e)r.set("status",e);if(t)r.set("role",t);let n=r.toString()?`?${r.toString()}`:"";return P(`/admin/users${n}`,{},!0)}async function TH(e){return P(`/admin/approve/${e}`,{method:"POST"},!0)}async function NH(e){return P(`/admin/approve/by-id/${e}`,{method:"POST"},!0)}async function qH(e){return P(`/admin/revoke/${e}`,{method:"POST"},!0)}async function jH(e,t){return P(`/admin/users/${e}/role`,{method:"POST",body:JSON.stringify({role:t})},!0)}async function zw(e,t){return P(`/admin/datasets/${e}/visibility`,{method:"PATCH",body:JSON.stringify({visibility:t})},!0)}async function MH(e){return P(`/datasets/${e}/publish`,{method:"POST"},!0)}async function BH(e){return P(`/admin/datasets/${e}/ci`,{},!0)}async function Vi(e){return P(`/admin/datasets/${e}/ci`,{method:"POST"},!0)}async function Hw(e){return P(`/admin/datasets/${e}/ci/validate`,{method:"POST"},!0)}async function Gw(e){return P(`/admin/datasets/${e}/ci/sync`,{method:"POST"},!0)}async function LH(e,t){return P(`/admin/datasets/${e}/doi/concept`,{method:"POST",body:JSON.stringify(t)},!0)}async function qd(e){return P(`/admin/datasets/${e}/doi`,{},!0)}async function Ww(e,t){return P(`/admin/datasets/${e}/doi/update`,{method:"POST",body:JSON.stringify(t)},!0)}async function UH(e,t){return P(`/admin/datasets/${e}/withdraw`,{method:"POST",body:JSON.stringify({reason:t.reason,dry_run:t.dryRun})},!0)}async function VH(e,t){return P(`/admin/datasets/${e}/restore`,{method:"POST",body:JSON.stringify({dry_run:t.dryRun})},!0)}async function zH(e){return P(`/admin/datasets/${e}/reset`,{method:"POST"},!0)}async function HH(e,t=!1){return P(`/admin/datasets/${e}`,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({force:t})},!0)}async function GH(e){return P("/admin/datasets/bulk-delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dataset_ids:e})},!0)}async function WH(e){return P("/admin/datasets/import",{method:"POST",body:JSON.stringify(e)},!0)}async function KH(e){return P("/admin/datasets/exemplar",{method:"POST",body:JSON.stringify(e)},!0)}async function YH(e){return P(`/admin/datasets/${e}/exemplar/remint-dois`,{method:"POST"},!0)}async function Kw(e,t){let r=new URLSearchParams;if(e)r.set("status",e);if(t!==void 0)r.set("blocklisted",t?"1":"0");let n=r.toString();return P(`/admin/imports${n?`?${n}`:""}`,{},!0)}async function JH(e){return P(`/admin/imports/${e}/rollback`,{method:"POST"},!0)}async function XH(e){return P(`/admin/imports/${e}/retry`,{method:"POST"},!0)}async function Yw(e){return P(`/admin/imports/${e}/verify`,{method:"POST"},!0)}async function QH(e){return P("/admin/imports/dispatch-cooldown",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dataset_ids:e})},!0)}async function Jc(e,t){return P(`/admin/datasets/${e}/reindex`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t??{})},!0)}async function ZH(e,t){return P("/admin/datasets/reindex/bulk",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filter:e,...t??{}})},!0)}async function eG(e){let t=e?.limit??15;return P(`/admin/datasets/hed-sweep?limit=${encodeURIComponent(String(t))}`,{method:"POST",headers:{"Content-Type":"application/json"}},!0)}async function tG(){return P("/admin/datasets/hed-sweep?reset=1",{method:"POST",headers:{"Content-Type":"application/json"}},!0)}async function rG(e){let t=e?.limit??50;return P(`/admin/datasets/recording-stats-sweep?limit=${encodeURIComponent(String(t))}`,{method:"POST",headers:{"Content-Type":"application/json"}},!0)}async function nG(){return P("/admin/datasets/recording-stats-sweep?reset=1",{method:"POST",headers:{"Content-Type":"application/json"}},!0)}async function iG(e){let t=e?.limit??15;return P(`/admin/datasets/signal-defaults-sweep?limit=${encodeURIComponent(String(t))}`,{method:"POST",headers:{"Content-Type":"application/json"}},!0)}async function sG(){return P("/admin/datasets/signal-defaults-sweep?reset=1",{method:"POST",headers:{"Content-Type":"application/json"}},!0)}async function oG(e){let t=e?.limit??15,r=new URLSearchParams({limit:String(t)});if(e?.olderThan!=null)r.set("older-than",String(e.olderThan));if(e?.before!=null)r.set("before",e.before);return P(`/admin/datasets/data-integrity-sweep?${r.toString()}`,{method:"POST",headers:{"Content-Type":"application/json"}},!0)}async function aG(){return P("/admin/datasets/data-integrity-sweep?reset=1",{method:"POST",headers:{"Content-Type":"application/json"}},!0)}async function cG(e,t){let r=t?.write?"":"?dry_run=1";return P(`/admin/datasets/${e}/availability-report${r}`,{method:"POST",headers:{"Content-Type":"application/json"}},!0)}async function uG(e){let t=e?.limit??30,r=new URLSearchParams({limit:String(t)});if(e?.missingOnly)r.set("missing-only","1");return P(`/admin/datasets/availability-report-sweep?${r.toString()}`,{method:"POST",headers:{"Content-Type":"application/json"}},!0)}async function lG(){return P("/admin/datasets/availability-report-sweep?reset=1",{method:"POST",headers:{"Content-Type":"application/json"}},!0)}async function dG(e){let t=new URLSearchParams;if(e?.prefix)t.set("prefix",e.prefix);if(e?.visibility)t.set("visibility",e.visibility);if(e?.limit)t.set("limit",String(e.limit));let r=t.toString()?`?${t.toString()}`:"";return P(`/admin/fleet/drift${r}`,{},!0)}async function Xc(e,t){return P(`/admin/datasets/${e}/enforce`,{method:"POST",body:JSON.stringify({dry_run:t})},!0)}async function fG(e){return P("/admin/datasets/enforce/bulk",{method:"POST",body:JSON.stringify({prefix:e.prefix,visibility:e.visibility,limit:e.limit,dry_run:e.dryRun})},!0)}async function pG(e,t=!1){return P(`/admin/datasets/${e}/revalidate${t?"?force=true":""}`,{method:"POST"},!0)}async function mG(e){let t=e?`?user=${encodeURIComponent(e)}`:"";return P(`/admin/email-preferences${t}`,{},!0)}async function hG(e,t){let r=t?`?user=${encodeURIComponent(t)}`:"";return P(`/admin/email-preferences${r}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)},!0)}async function Jw(e){return P("/admin/notify",{method:"POST",body:JSON.stringify(e)},!0)}async function gG(){return P("/admin/summary/coverage",{},!0)}async function yG(e,t,r){return P("/admin/manifest/dispatch",{method:"POST",body:JSON.stringify({dataset_id:e,version:t,skip_canary:r?.skipCanary??!1})},!0)}async function Xw(e){return P("/admin/doctor/scan",{method:"POST",body:JSON.stringify({...e?.check&&{check:e.check},...e?.datasetId&&{dataset_id:e.datasetId}})},!0)}async function Qw(e){return P("/admin/doctor/fix",{method:"POST",body:JSON.stringify({check:e.check,...e.datasetId&&{dataset_id:e.datasetId},...e.dryRun&&{dry_run:!0}})},!0)}async function xG(){return P("/admin/zarr-catalog/publish",{method:"POST"},!0)}async function bG(e){let t=new URLSearchParams;if(e?.limit!=null)t.set("limit",String(e.limit));let r=t.toString()?`?${t.toString()}`:"";return P(`/admin/datasets/zarr-fidelity-sweep${r}`,{method:"POST",headers:{"Content-Type":"application/json"}},!0)}var Qc=O(()=>{Ks()});async function pi(e,t){return P(`/datasets/${e}/upload-credentials`,{method:"POST",body:JSON.stringify({duration_seconds:t})},!0)}async function Zw(e,t){return P(`/datasets/${e}/download-credentials`,{method:"POST",body:JSON.stringify({duration_seconds:t})},!0)}async function vG(e){return P(`/admin/datasets/${e}/files`,{},!0)}async function _G(e){let t,r=0,n=[],i=!0;while(i){let s=await P(`/admin/datasets/${e}/s3-lock`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({continuation_token:t})},!0);if(r+=s.locked,s.failed?.length)n.push(...s.failed);if(i=s.hasMore,t=s.continuation_token,i&&!t)throw new q(500,"S3 lock paginated response missing continuation_token; aborting to avoid infinite loop")}return{locked:r,failed:n}}var Zc=O(()=>{Ks();ar()});function XNe(e){return e.startsWith("v")?e:`v${e}`}var YNe,JNe,wG,vit;var eD=O(()=>{Wo();YNe=/^v?\d+\.\d+\.\d+(?:-(?:rc|alpha|beta)\d*)?$/,JNe=/^v\d+\.\d+\.\d+(?:-(?:rc|alpha|beta)\d*)?$/;wG=E.string().regex(YNe,"must be a semver version, optionally v-prefixed").transform(XNe),vit=E.string().regex(JNe,"must be the canonical v-prefixed tag (vX.Y.Z)")});var QNe,ZNe,DG;var EG=O(()=>{Wo();QNe=E.object({id:E.number().int(),username:E.string().nullable(),email:E.string(),github_username:E.string().nullable(),role:E.string(),orcid:E.string().nullable().optional(),created_at:E.string().optional(),approved_at:E.string().nullable().optional(),dataset_count:E.number().int().optional(),sandbox_completed:E.boolean().optional(),sandbox_completed_at:E.string().nullable().optional(),sandbox_dataset_id:E.string().nullable().optional()}).passthrough(),ZNe=E.object({prefix:E.string(),created_at:E.string(),last_used_at:E.string().nullable()}).passthrough().nullable(),DG=E.object({user:QNe,token:ZNe.optional()}).passthrough()});function $G(e,t){if(e.zarr_index_url!=null&&e.zarr_status!=="ready")t.addIssue({code:E.ZodIssueCode.custom,message:"zarr_index_url must be null/absent unless zarr_status is 'ready'",path:["zarr_index_url"]})}function CG(e,t){if(e.zarr_verified_at!=null&&e.zarr_verify_status==null)t.addIssue({code:E.ZodIssueCode.custom,message:"zarr_verified_at must be null/absent unless zarr_verify_status is non-null",path:["zarr_verified_at"]})}var e9e="0.4.0",tD,eu,SG,t9e,r9e,n9e,RG,$it,FG,Cit,zi,i9e,Z0,Rit;var rD=O(()=>{Wo();eD();tD=E.enum(["openneuro","nemar","gin","other"]),eu=E.union([E.literal(0),E.literal(1)]).nullable(),SG=E.object({dataset_id:E.string(),id:E.string().optional(),name:E.string(),description:E.string().nullable().optional(),status:E.string(),visibility:E.string(),concept_doi:E.string().nullable().optional(),doi:E.string().nullable().optional(),created_at:E.string(),updated_at:E.string().optional(),owner_username:E.string().nullable().optional(),source:E.string().nullable().optional(),modalities:E.string().optional(),participants:E.number().int().nonnegative(),tasks:E.string().optional(),authors:E.string().optional(),license:E.string().optional(),file_size:E.number().nonnegative(),file_size_formatted:E.string().optional(),total_files:E.number().nonnegative().nullable().optional(),num_citations:E.number().int().nonnegative().optional(),n_channels:E.number().int().nullable().optional(),electrode_system:E.string().nullable().optional(),has_hed:eu.optional(),hed_version:E.string().nullable().optional(),data_complete:eu.optional(),bytes_present:E.number().nonnegative().nullable().optional(),latest_version:wG.nullable().optional(),subject_count:E.number().int().nullable().optional(),file_size_bytes:E.number().nullable().optional(),sessions_count:E.number().int().nullable().optional(),age_min:E.number().nullable().optional(),age_max:E.number().nullable().optional(),bids_version:E.string().nullable().optional(),zarr_status:E.enum(["pending","ready","failed"]).nullable().optional(),zarr_store_count:E.number().int().nullable().optional(),zarr_converted_at:E.string().nullable().optional(),zarr_source_commit:E.string().nullable().optional(),zarr_errors:E.number().int().nullable().optional(),zarr_failure_count:E.number().int().nullable().optional(),zarr_deterministic:eu.optional(),zarr_failed_at:E.string().nullable().optional(),zarr_index_url:E.string().nullable().optional(),zarr_verify_status:E.enum(["verified","failed","unverifiable"]).nullable().optional(),zarr_verified_at:E.string().nullable().optional(),total_recording_duration:E.number().nullable().optional(),recording_duration_min:E.number().nullable().optional(),recording_duration_max:E.number().nullable().optional(),recording_count:E.number().int().nullable().optional(),recordings_unavailable:E.number().int().nullable().optional(),channel_count_min:E.number().int().nullable().optional(),channel_count_max:E.number().int().nullable().optional(),sampling_frequency:E.number().nullable().optional(),power_line_frequency:E.number().nullable().optional(),eeg_reference:E.string().nullable().optional(),placement_scheme:E.string().nullable().optional()}).passthrough();t9e=SG.superRefine((e,t)=>{$G(e,t),CG(e,t)}),r9e=SG.extend({file_size:E.number().nonnegative().nullable(),file_size_formatted:E.string().nullable().optional(),modalities:E.string().nullable().optional(),tasks:E.string().nullable().optional(),authors:E.string().nullable().optional(),license:E.string().nullable().optional(),owner_github:E.string().nullable().optional(),attestation_deposit_type:E.enum(["owner","redistribution"]).nullable().optional(),attestation_key_status:E.enum(["destroyed","retained"]).nullable().optional(),attestation_deidentified:eu.optional(),attestation_no_duplicate:eu.optional(),attestation_upstream_source:E.string().nullable().optional(),attestation_accepted_at:E.string().nullable().optional(),zarr_data_failures:E.object({count:E.number().int().nonnegative(),detail_ref:E.string(),compacted_by:E.string().optional(),pending:E.number().int().nonnegative().optional(),discovered:E.number().int().nonnegative().optional(),events_upload_failed:E.literal(!0).optional(),manifest_upload_failed:E.literal(!0).optional()}).passthrough().nullable().optional()}).passthrough().superRefine((e,t)=>{$G(e,t),CG(e,t)}),n9e=E.object({id:E.string(),name:E.string(),modalities:E.string().nullable().optional(),participants:E.number().int().nullable().optional(),doi:E.string().nullable().optional(),tasks:E.string().nullable().optional(),authors:E.string().nullable().optional(),has_hed:eu.optional(),score:E.number().optional(),snippet:E.string().optional()}).passthrough(),RG=E.record(E.string(),E.number().int().nonnegative()),$it=E.object({datasets:E.array(t9e),count:E.number().int().nonnegative(),total_count:E.number().int().nonnegative().optional(),limit:E.number().int().optional(),offset:E.number().int().optional(),excluded_unknown:E.number().int().nonnegative().optional(),excluded_unknown_by_facet:RG.optional()}).passthrough(),FG=E.object({results:E.array(n9e),count:E.number().int().nonnegative(),returned:E.number().int().nonnegative().optional(),offset:E.number().int().nonnegative().optional(),limit:E.number().int().optional(),candidate_ceiling:E.number().int().optional(),truncated:E.boolean().optional(),method:E.enum(["exact_id","text","text_fallback","semantic","unavailable"]).optional(),min_score:E.number().optional(),warning:E.string().optional(),excluded_unknown:E.number().int().nonnegative().optional(),excluded_unknown_by_facet:RG.optional()}).passthrough(),Cit=E.object({dataset:r9e}).passthrough(),zi=E.object({value:E.string(),count:E.number().int().nonnegative()}),i9e=E.object({values:E.array(zi),distinct_total:E.number().int().nonnegative(),truncated:E.boolean()}),Z0=E.object({"electrode-system":E.array(zi).optional(),source:E.array(zi).optional(),zarr:E.array(zi).optional(),powerline:E.array(zi).optional(),"bids-version":E.array(zi).optional(),"hed-version":E.array(zi).optional(),license:E.array(zi).optional(),modality:E.array(zi).optional(),task:i9e.optional(),warning:E.string().optional()}).passthrough(),Rit=E.object({schema_version:E.literal(e9e),doc_type:E.literal("dataset"),dataset_id:E.string().regex(/^[a-z]{2}\d+$/,"neuroschema dataset_id pattern"),name:E.string(),source:tD,recording_modality:E.array(E.string()).min(1),description:E.string().nullable().optional(),bids_version:E.string().nullable().optional(),license:E.string().nullable().optional()}).passthrough()});var eh=O(()=>{eD();EG();rD()});async function rh(e){return P(`/datasets/${e}/ci/status`,{},!0)}async function OG(e){return P(`/datasets/${e}/manifest`,{},!0)}async function nh(e,t){return P(`/datasets/${e}/manifest/${t}`,{},!0)}function AG(e){let t=e;if(!t.status)t.status="active";else if(!["active","archived","deleted"].includes(t.status))throw Error(`Invalid dataset status: ${t.status}`);if(!t.visibility)t.visibility="private";else if(!["public","private"].includes(t.visibility))throw Error(`Invalid dataset visibility: ${t.visibility}`);return t}async function tu(e={}){let t=new URLSearchParams;if(e.mine)t.set("mine","true");if(e.search)t.set("search",e.search);if(e.modality)t.set("modality",e.modality);if(e.author)t.set("author",e.author);if(e.task)t.set("task",e.task);if(e.license)t.set("license",e.license);if(e.hasDoi)t.set("has_doi","true");if(e.hasHed)t.set("has_hed","1");if(e.hasZarr)t.set("has_zarr","1");if(e.hasZarrVerified)t.set("has_zarr_verified","1");if(e.dataComplete)t.set("data_complete","1");if(e.recent)t.set("recent",String(e.recent));if(e.sort)t.set("sort",e.sort);if(e.limit!=null)t.set("limit",String(e.limit));if(e.offset!=null)t.set("offset",String(e.offset));if(e.owner)t.set("owner",e.owner);if(e.facets)for(let[i,s]of Object.entries(e.facets))t.set(i,s);if(e.includeUnknown)t.set("include_unknown","1");let r=t.toString()?`?${t.toString()}`:"",n=await P(`/datasets${r}`,{},e.mine?!0:"optional");return n.datasets=n.datasets.map(AG),n}async function kG(e){return P(`/datasets/resolve/${e}`,{},"optional")}async function PG(){return P("/datasets/facets",{signal:AbortSignal.timeout(5000)},"optional",Z0)}async function IG(e,t={}){let r=new URLSearchParams({q:e});if(t.modality)r.set("modality",t.modality);if(t.limit)r.set("limit",String(t.limit));if(t.hasHed)r.set("has_hed","1");if(t.hasZarr)r.set("has_zarr","1");if(t.hasZarrVerified)r.set("has_zarr_verified","1");if(t.author)r.set("author",t.author);if(t.task)r.set("task",t.task);if(t.license)r.set("license",t.license);if(t.hasDoi)r.set("has_doi","true");if(t.dataComplete)r.set("data_complete","1");if(t.recent)r.set("recent",String(t.recent));if(t.facets)for(let[i,s]of Object.entries(t.facets))r.set(i,s);if(t.includeUnknown)r.set("include_unknown","1");return await P(`/datasets/search?${r.toString()}`,{},"optional",FG)}async function vt(e){let t=await P(`/datasets/${e}`,{},"optional");return AG(t.dataset)}async function TG(e){return P(`/datasets/${e}/versions`,{},!0)}async function ih(e){return P("/datasets",{method:"POST",body:JSON.stringify(e)},!0)}async function sh(e){return P(`/datasets/${e}/finalize`,{method:"POST"},!0)}async function nD(e){return P(`/datasets/${e}/request-access`,{method:"POST"},!0)}async function NG(e,t){let r=t?`?status=${t}`:"";return P(`/datasets/${e}/access-requests${r}`,{},!0)}async function qG(e,t){return P(`/datasets/${e}/access-requests/${t}/approve`,{method:"POST"},!0)}async function jG(e,t){return P(`/datasets/${e}/access-requests/${t}/deny`,{method:"POST"},!0)}async function MG(e,t){return P(`/datasets/${e}/invite`,{method:"POST",body:JSON.stringify({username:t})},!0)}async function BG(e){return P(`/datasets/${e}/collaborators`,{},!0)}async function LG(e,t){return P(`/admin/datasets/${e}/enrichment`,{method:"POST",body:JSON.stringify(t)},!0)}var th;var Ys=O(()=>{eh();Ks();th=/^\d{4}-\d{4}-\d{4}-\d{3}[\dX]$/});var ru;var GG=O(()=>{ru=["ci_check","enrichment_check","s3_public_read","repo_public","tag_protect","doi_create","update_metadata","update_readme","create_tag","create_release","upload_to_zenodo","publish_doi","version_doi","s3_lock","sync_nemar","notify_user"]});async function nu(e){return P(`/datasets/${e}/publish/request`,{method:"POST"},!0)}async function KG(e){return P(`/datasets/${e}/publish/status`,{},!0)}async function YG(e){return P(`/datasets/${e}/publish/resend`,{method:"POST"},!0)}async function JG(e){let t=e?`?status=${e}`:"";return P(`/admin/publish/requests${t}`,{},!0)}async function XG(e,t){return P(`/admin/publish/${e}/deny`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({reason:t})},!0)}function s9e(e,t=[]){if(e){let r=ru.indexOf(e);if(r>=0)return r+1}return Math.min(t.length+1,ru.length)}function o9e(e){if(!(e instanceof q))return!1;if(e.statusCode===0)return!0;if(e.statusCode===429)return!0;if(e.statusCode>=500&&e.statusCode<600)return!0;if(e.statusCode===403&&/repository has been locked/i.test(e.message))return!0;return!1}async function iu(e,t=!1,r=!1,n=!1,i,s){let c,u,d=0,f=!1,m,p=t,g=[],y;function x(v,_,S,C){if(!s)return;s({step:v,stepIndex:s9e(v,_),stepTotal:ru.length,s3LockLocked:S,s3LockTotal:C,s3LockResumed:v==="s3_lock"&&f?!0:void 0})}for(let v=1;v<=5;v++)try{let _,S=!0;do{if(_=await P(`/admin/publish/${e}/approve`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({resume:S?p:!0,sandbox:r,s3_lock_continuation_token:c,s3_lock_total:u,skip_ci_check:n})},!0),S=!1,_.step_results)g.push(..._.step_results);if(_.s3_lock_total!==void 0)u=_.s3_lock_total;if(_.s3_lock_batch_count!==void 0)d+=_.s3_lock_batch_count;let C=_.step??_.step_results?.[_.step_results.length-1]?.step;if(C&&(C!==m||C==="s3_lock"))x(C,_.steps_completed??[],C==="s3_lock"?d:void 0,C==="s3_lock"?u:void 0),m=C;if(_.hasMore&&_.s3_lock_continuation_token!==void 0)c=_.s3_lock_continuation_token;else break}while(_.hasMore);if(g.length>0)_.step_results=WG(g);return _}catch(_){if(y=_,v===5||!o9e(_)){if(_ instanceof q&&g.length>0)_.stepResults=WG(g);throw _}let C=_;if(i?.({attempt:v,maxAttempts:5,delayMs:1e4,step:C.step,error:C.message}),await new Promise((w)=>setTimeout(w,1e4)),p=!0,c!==void 0)f=!0}throw y}function WG(e){let t=new Map;for(let r of e)t.set(r.step,r);return Array.from(t.values())}var jd=O(()=>{GG();Ks();ar()});function eW(e){oD=e}function aD(){return oD}function Md(e){if(oD)process.stderr.write(`${e}
|
|
106
106
|
`)}var oD=!1;var tW={};Ji(tW,{runCommand:()=>F});var{spawn:a9e}=globalThis.Bun;async function F(e,t={}){let r={...process.env,GIT_TERMINAL_PROMPT:"0",...t.env};for(let u of t.unsetEnv??[])delete r[u];let n=a9e({cmd:e,cwd:t.cwd,stdout:"pipe",stderr:"pipe",env:r}),i=!1,s;if(t.timeout)s=setTimeout(()=>{i=!0,n.kill()},t.timeout);if(aD()){let u=t.cwd?` (cwd=${t.cwd})`:"";Md(l.dim(`$ ${e.join(" ")}${u}`))}let o=await new Response(n.stdout).text(),a=await new Response(n.stderr).text(),c=await n.exited;if(s)clearTimeout(s);if(aD()){if(o.trim())Md(l.dim(o.trimEnd()));if(a.trim())Md(l.yellow(a.trimEnd()));Md(l.dim(`(exit ${c})`))}if(i)return{stdout:o,stderr:a||`Command timed out after ${Math.round(t.timeout/1000)}s`,exitCode:c??1};return{stdout:o,stderr:a,exitCode:c}}var Yt=O(()=>{Ye()});async function c9e(){try{let{exitCode:e,stderr:t}=await F(["ssh","-T","-o","BatchMode=yes","-o","ConnectTimeout=5","git@github.com"]),r=t.includes("successfully authenticated");if(!r)console.warn("SSH test to github.com failed:",{exitCode:e,stderr:t.trim().slice(0,500)});return{works:r,error:r?void 0:t.trim().slice(0,500)}}catch(e){let t=e instanceof Error?e.message:String(e);return console.warn("SSH test exception:",t),{works:!1,error:t}}}async function Bd(){try{let{stdout:e,exitCode:t,stderr:r}=await F(["gh","auth","token"]);if(t!==0)return console.warn("gh CLI returned non-zero exit code:",t),console.warn("stderr:",r),{token:null,error:`gh auth token failed: ${r.trim()||"unknown error"}`};if(!e.trim())return console.warn("gh auth token returned empty output"),{token:null,error:"gh CLI returned empty token"};return{token:e.trim()}}catch(e){let t=e instanceof Error?e.message:String(e);if(console.error("Failed to get GitHub token from gh CLI:",t),t.includes("ENOENT")||t.includes("not found"))return{token:null,error:"gh CLI not installed (command not found)"};return{token:null,error:`gh CLI error: ${t}`}}}async function oh(e){try{let{stdout:t,exitCode:r,stderr:n}=await F(["gh","api","user","--jq",".login"]);if(r!==0){if(n.includes("not logged in")||n.includes("auth login"))return{authenticated:!1,error:"gh CLI not authenticated. Run 'gh auth login' to authenticate."};return{authenticated:!1,error:`gh CLI error: ${n.trim()||"unknown error"}`}}let i=t.trim();if(!i)return{authenticated:!1,error:"gh CLI returned empty username"};if(e){let s=i.toLowerCase()===e.toLowerCase();return{authenticated:!0,username:i,matches:s,error:s?void 0:`gh CLI authenticated as '${i}', expected '${e}'`}}return{authenticated:!0,username:i}}catch(t){let r=t instanceof Error?t.message:String(t);if(r.includes("ENOENT")||r.includes("not found"))return{authenticated:!1,error:"gh CLI not installed. Install from https://cli.github.com/"};return{authenticated:!1,error:`Failed to verify gh CLI: ${r}`}}}async function ah(e){if(!/^[a-zA-Z0-9_.-]+\/[a-zA-Z0-9_.-]+$/.test(e))return{accepted:!1,error:`Invalid repository format: ${e}`};let{stdout:t,exitCode:r,stderr:n}=await F(["gh","api","/user/repository_invitations"]);if(r!==0){if(n.includes("not logged in")||n.includes("auth login"))return{accepted:!1,error:"gh CLI not authenticated. Run 'gh auth login' to authenticate."};if(n.includes("API rate limit")||n.includes("403"))return{accepted:!1,error:"GitHub API rate limit exceeded. Please try again in a few minutes."};if(n.includes("ENOENT")||n.includes("not found"))return{accepted:!1,error:"gh CLI not installed. Install from https://cli.github.com/"};return{accepted:!1,error:`Failed to list invitations: ${n.trim()||"unknown error"}`}}let i=null;try{i=JSON.parse(t||"[]").find((u)=>u.repository.full_name===e)?.id??null}catch(a){let c=a instanceof Error?a.message:String(a);return console.error("Failed to parse GitHub invitations response:",c),console.error(" Raw response (first 500 chars):",(t||"").slice(0,500)),{accepted:!1,error:`Failed to parse GitHub API response: ${c}`}}if(!i){let{exitCode:a}=await F(["gh","api",`/repos/${e}`,"--silent"]);if(a===0)return{accepted:!0,alreadyCollaborator:!0};return{accepted:!1,error:`No pending invitation found for ${e}. You may need to accept it manually via GitHub.`}}let{exitCode:s,stderr:o}=await F(["gh","api","--method","PATCH",`/user/repository_invitations/${i}`]);if(s!==0)return{accepted:!1,error:`Failed to accept invitation: ${o.trim()||"unknown error"}`};return{accepted:!0}}async function mi(e,t,r="origin"){let n=t;if(process.env.GH_TOKEN&&t.startsWith("git@github.com:")){let i=process.env.GH_TOKEN.trim();if(!i||/\s/.test(i))return{success:!1,error:"GH_TOKEN environment variable is set but appears malformed (empty or contains whitespace)"};n=`https://github.com/${t.replace("git@github.com:","")}`,await F(["git","config","credential.https://github.com.helper",`!printf 'username=x-access-token\\npassword=${i}'`],{cwd:e})}else if(t.startsWith("git@github.com:")){let i=t.replace("git@github.com:",""),s=await Bd();if(s.token)n=`https://github.com/${i}`,await F(["git","config","credential.https://github.com.helper",`!printf 'username=x-access-token\\npassword=${s.token}'`],{cwd:e});else{let o=await c9e();if(o.works)n=t;else return{success:!1,error:`GitHub authentication not configured.
|
|
107
107
|
|
|
108
108
|
gh CLI failed: ${s.error||"could not get token"}
|