nemar-cli 0.9.14-dev.2230 → 0.9.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +2 -2
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -97,12 +97,12 @@ ${t}`,Dbe,wbe,Ebe=(e,t,r)=>{let n=r===""?"":`with ${r.trim()}() `,i=_be.bind(nul
97
97
  depsCount: ${t},
98
98
  deps: ${r}}`};var WAe={keyword:"dependencies",type:"object",schemaType:"object",error:JB.error,code(e){let[t,r]=GAe(e);KB(e,t),YB(e,r)}};function GAe({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 KB(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,ed.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 l of a)(0,ed.checkReportMissingProp)(e,l)});else r.if(w_._`${c} && (${(0,ed.checkMissingProp)(e,a,s)})`),(0,ed.reportMissingProp)(e,s),r.else()}}JB.validatePropertyDeps=KB;function YB(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,HAe.alwaysValidSchema)(s,t[a]))continue;r.if((0,ed.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)}}JB.validateSchemaDeps=YB;JB.default=WAe});var rL=h(function(tL){Object.defineProperty(tL,"__esModule",{value:!0});var eL=me(),JAe=Ie(),XAe={message:"property name must be valid",params:({params:e})=>eL._`{propertyName: ${e.propertyName}}`},QAe={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:XAe,code(e){let{gen:t,schema:r,data:n,it:i}=e;if((0,JAe.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,eL.not)(s),()=>{if(e.error(!0),!i.allErrors)t.break()})}),e.ok(s)}};tL.default=QAe});var E_=h(function(nL){Object.defineProperty(nL,"__esModule",{value:!0});var X0=zr(),hn=me(),eke=Si(),Q0=Ie(),tke={message:"must NOT have additional properties",params:({params:e})=>hn._`{additionalProperty: ${e.additionalProperty}}`},rke={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:tke,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,Q0.alwaysValidSchema)(o,r))return;let l=(0,X0.allSchemaProperties)(n.properties),d=(0,X0.allSchemaProperties)(n.patternProperties);f(),e.ok(hn._`${s} === ${eke.default.errors}`);function f(){t.forIn("key",i,(x)=>{if(!l.length&&!d.length)g(x);else t.if(m(x),()=>g(x))})}function m(x){let v;if(l.length>8){let _=(0,Q0.schemaRefOrVal)(o,n.properties,"properties");v=(0,X0.isOwnProperty)(t,_,x)}else if(l.length)v=(0,hn.or)(...l.map((_)=>hn._`${x} === ${_}`));else v=hn.nil;if(d.length)v=(0,hn.or)(v,...d.map((_)=>hn._`${(0,X0.usePattern)(e,_)}.test(${x})`));return(0,hn.not)(v)}function p(x){t.code(hn._`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,Q0.alwaysValidSchema)(o,r)){let v=t.name("valid");if(c.removeAdditional==="failing")y(x,v,!1),t.if((0,hn.not)(v),()=>{e.reset(),p(x)});else if(y(x,v),!a)t.if((0,hn.not)(v),()=>t.break())}}function y(x,v,_){let S={keyword:"additionalProperties",dataProp:x,dataPropType:Q0.Type.Str};if(_===!1)Object.assign(S,{compositeRule:!0,createErrors:!1,allErrors:!1});e.subschema(S,v)}}};nL.default=rke});var aL=h(function(oL){Object.defineProperty(oL,"__esModule",{value:!0});var ike=Vl(),iL=zr(),S_=Ie(),sL=E_(),ske={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)sL.default.code(new ike.KeywordCxt(s,sL.default,"additionalProperties"));let o=(0,iL.allSchemaProperties)(r);for(let f of o)s.definedProperties.add(f);if(s.opts.unevaluated&&o.length&&s.props!==!0)s.props=S_.mergeEvaluated.props(t,(0,S_.toHash)(o),s.props);let a=o.filter((f)=>!(0,S_.alwaysValidSchema)(s,r[f]));if(a.length===0)return;let c=t.name("valid");for(let f of a){if(l(f))d(f);else{if(t.if((0,iL.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 l(f){return s.opts.useDefaults&&!s.compositeRule&&r[f].default!==void 0}function d(f){e.subschema({keyword:"properties",schemaProp:f,dataProp:f},c)}}};oL.default=ske});var fL=h(function(dL){Object.defineProperty(dL,"__esModule",{value:!0});var cL=zr(),Z0=me(),uL=Ie(),lL=Ie(),ake={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,cL.allSchemaProperties)(r),c=a.filter((y)=>(0,uL.alwaysValidSchema)(s,r[y]));if(a.length===0||c.length===a.length&&(!s.opts.unevaluated||s.props===!0))return;let l=o.strictSchema&&!o.allowMatchingProperties&&i.properties,d=t.name("valid");if(s.props!==!0&&!(s.props instanceof Z0.Name))s.props=(0,lL.evaluatedPropsToName)(t,s.props);let{props:f}=s;m();function m(){for(let y of a){if(l)p(y);if(s.allErrors)g(y);else t.var(d,!0),g(y),t.if(d)}}function p(y){for(let x in l)if(new RegExp(y).test(x))(0,uL.checkStrictMode)(s,`property ${x} matches pattern ${y} (use allowMatchingProperties)`)}function g(y){t.forIn("key",n,(x)=>{t.if(Z0._`${(0,cL.usePattern)(e,y)}.test(${x})`,()=>{let v=c.includes(y);if(!v)e.subschema({keyword:"patternProperties",schemaProp:y,dataProp:x,dataPropType:lL.Type.Str},d);if(s.opts.unevaluated&&f!==!0)t.assign(Z0._`${f}[${x}]`,!0);else if(!v&&!s.allErrors)t.if((0,Z0.not)(d),()=>t.break())})})}}};dL.default=ake});var mL=h(function(pL){Object.defineProperty(pL,"__esModule",{value:!0});var uke=Ie(),lke={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(e){let{gen:t,schema:r,it:n}=e;if((0,uke.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"}};pL.default=lke});var gL=h(function(hL){Object.defineProperty(hL,"__esModule",{value:!0});var fke=zr(),pke={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:fke.validateUnion,error:{message:"must match a schema in anyOf"}};hL.default=pke});var xL=h(function(yL){Object.defineProperty(yL,"__esModule",{value:!0});var em=me(),hke=Ie(),gke={message:"must match exactly one schema in oneOf",params:({params:e})=>em._`{passingSchemas: ${e.passing}}`},yke={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:gke,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(l),e.result(o,()=>e.reset(),()=>e.error(!0));function l(){s.forEach((d,f)=>{let m;if((0,hke.alwaysValidSchema)(i,d))t.var(c,!0);else m=e.subschema({keyword:"oneOf",schemaProp:f,compositeRule:!0},c);if(f>0)t.if(em._`${c} && ${o}`).assign(o,!1).assign(a,em._`[${a}, ${f}]`).else();t.if(c,()=>{if(t.assign(o,!0),t.assign(a,f),m)e.mergeEvaluated(m,em.Name)})})}}};yL.default=yke});var vL=h(function(bL){Object.defineProperty(bL,"__esModule",{value:!0});var bke=Ie(),vke={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,bke.alwaysValidSchema)(n,s))return;let a=e.subschema({keyword:"allOf",schemaProp:o},i);e.ok(i),e.mergeEvaluated(a)})}};bL.default=vke});var EL=h(function(wL){Object.defineProperty(wL,"__esModule",{value:!0});var tm=me(),DL=Ie(),Dke={message:({params:e})=>tm.str`must match "${e.ifClause}" schema`,params:({params:e})=>tm._`{failingKeyword: ${e.ifClause}}`},wke={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:Dke,code(e){let{gen:t,parentSchema:r,it:n}=e;if(r.then===void 0&&r.else===void 0)(0,DL.checkStrictMode)(n,'"if" without "then" and "else" is ignored');let i=_L(n,"then"),s=_L(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,l("then",d),l("else",d))}else if(i)t.if(a,l("then"));else t.if((0,tm.not)(a),l("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 l(d,f){return()=>{let m=e.subschema({keyword:d},a);if(t.assign(o,a),e.mergeValidEvaluated(m,o),f)t.assign(f,tm._`${d}`);else e.setParams({ifClause:d})}}}};function _L(e,t){let r=e.schema[t];return r!==void 0&&!(0,DL.alwaysValidSchema)(e,r)}wL.default=wke});var $L=h(function(SL){Object.defineProperty(SL,"__esModule",{value:!0});var Ske=Ie(),$ke={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:e,parentSchema:t,it:r}){if(t.if===void 0)(0,Ske.checkStrictMode)(r,`"${e}" without "if" is ignored`)}};SL.default=$ke});var FL=h(function(CL){Object.defineProperty(CL,"__esModule",{value:!0});var Fke=__(),Rke=UB(),Oke=D_(),Ake=HB(),kke=GB(),Pke=ZB(),Ike=rL(),Tke=E_(),Nke=aL(),qke=fL(),jke=mL(),Mke=gL(),Bke=xL(),Lke=vL(),Uke=EL(),Vke=$L();function zke(e=!1){let t=[jke.default,Mke.default,Bke.default,Lke.default,Uke.default,Vke.default,Ike.default,Tke.default,Pke.default,Nke.default,qke.default];if(e)t.push(Rke.default,Ake.default);else t.push(Fke.default,Oke.default);return t.push(kke.default),t}CL.default=zke});var OL=h(function(RL){Object.defineProperty(RL,"__esModule",{value:!0});var mt=me(),Wke={message:({schemaCode:e})=>mt.str`must match format "${e}"`,params:({schemaCode:e})=>mt._`{format: ${e}}`},Gke={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:Wke,code(e,t){let{gen:r,data:n,$data:i,schema:s,schemaCode:o,it:a}=e,{opts:c,errSchemaPath:l,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",mt._`${g}[${o}]`),x=r.let("fType"),v=r.let("format");r.if(mt._`typeof ${y} == "object" && !(${y} instanceof RegExp)`,()=>r.assign(x,mt._`${y}.type || "string"`).assign(v,mt._`${y}.validate`),()=>r.assign(x,mt._`"string"`).assign(v,y)),e.fail$data((0,mt.or)(_(),S()));function _(){if(c.strictSchema===!1)return mt.nil;return mt._`${o} && !${v}`}function S(){let C=d.$async?mt._`(${y}.async ? await ${v}(${n}) : ${v}(${n}))`:mt._`${v}(${n})`,D=mt._`(typeof ${v} == "function" ? ${C} : ${v}.test(${n}))`;return mt._`${v} && ${v} !== true && ${x} === ${t} && !${D}`}}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(D());return}throw Error(D());function D(){return`unknown format "${s}" ignored in schema at path "${l}"`}}function S(D){let O=D instanceof RegExp?(0,mt.regexpCode)(D):c.code.formats?mt._`${c.code.formats}${(0,mt.getProperty)(s)}`:void 0,F=r.scopeValue("formats",{key:s,ref:D,code:O});if(typeof D=="object"&&!(D instanceof RegExp))return[D.type||"string",D.validate,mt._`${F}.validate`];return["string",D,F]}function C(){if(typeof g=="object"&&!(g instanceof RegExp)&&g.async){if(!d.$async)throw Error("async format in sync schema");return mt._`await ${v}(${n})`}return typeof x=="function"?mt._`${v}(${n})`:mt._`${v}.test(${n})`}}}};RL.default=Gke});var kL=h(function(AL){Object.defineProperty(AL,"__esModule",{value:!0});var Yke=OL(),Jke=[Yke.default];AL.default=Jke});var TL=h(function(PL){Object.defineProperty(PL,"__esModule",{value:!0});PL.contentVocabulary=PL.metadataVocabulary=void 0;PL.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];PL.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]});var jL=h(function(qL){Object.defineProperty(qL,"__esModule",{value:!0});var Zke=oB(),ePe=PB(),tPe=FL(),rPe=kL(),NL=TL(),nPe=[Zke.default,ePe.default,(0,tPe.default)(),rPe.default,NL.metadataVocabulary,NL.contentVocabulary];qL.default=nPe});var UL=h(function(BL){Object.defineProperty(BL,"__esModule",{value:!0});BL.DiscrError=void 0;var ML;(function(e){e.Tag="tag",e.Mapping="mapping"})(ML||(BL.DiscrError=ML={}))});var HL=h(function(zL){Object.defineProperty(zL,"__esModule",{value:!0});var mc=me(),$_=UL(),VL=B0(),sPe=zl(),oPe=Ie(),aPe={message:({params:{discrError:e,tagName:t}})=>e===$_.DiscrError.Tag?`tag "${t}" must be string`:`value of tag "${t}" must be in oneOf`,params:({params:{discrError:e,tag:t,tagName:r}})=>mc._`{error: ${e}, tag: ${r}, tagValue: ${t}}`},cPe={keyword:"discriminator",type:"object",schemaType:"object",error:aPe,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),l=t.const("tag",mc._`${r}${(0,mc.getProperty)(a)}`);t.if(mc._`typeof ${l} == "string"`,()=>d(),()=>e.error(!1,{discrError:$_.DiscrError.Tag,tag:l,tagName:a})),e.ok(c);function d(){let p=m();t.if(!1);for(let g in p)t.elseIf(mc._`${l} === ${g}`),t.assign(c,f(p[g]));t.else(),e.error(!1,{discrError:$_.DiscrError.Mapping,tag:l,tagName:a}),t.endIf()}function f(p){let g=t.name("valid"),y=e.subschema({keyword:"oneOf",schemaProp:p},g);return e.mergeEvaluated(y,mc.Name),g}function m(){var p;let g={},y=v(i),x=!0;for(let C=0;C<o.length;C++){let D=o[C];if((D===null||D===void 0?void 0:D.$ref)&&!(0,oPe.schemaHasRulesButRef)(D,s.self.RULES)){let F=D.$ref;if(D=VL.resolveRef.call(s.self,s.schemaEnv.root,s.baseId,F),D instanceof VL.SchemaEnv)D=D.schema;if(D===void 0)throw new sPe.default(s.opts.uriResolver,s.baseId,F)}let O=(p=D===null||D===void 0?void 0:D.properties)===null||p===void 0?void 0:p[a];if(typeof O!="object")throw Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${a}"`);x=x&&(y||v(D)),_(O,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,D){if(C.const)S(C.const,D);else if(C.enum)for(let O of C.enum)S(O,D);else throw Error(`discriminator: "properties/${a}" must have "const" or "enum"`)}function S(C,D){if(typeof C!="string"||C in g)throw Error(`discriminator: "${a}" values must be unique strings`);g[C]=D}}}};zL.default=cPe});var WL=h(function(rJe,lPe){lPe.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 KL=h(function(yr,C_){Object.defineProperty(yr,"__esModule",{value:!0});yr.MissingRefError=yr.ValidationError=yr.CodeGen=yr.Name=yr.nil=yr.stringify=yr.str=yr._=yr.KeywordCxt=yr.Ajv=void 0;var dPe=JM(),fPe=jL(),pPe=HL(),GL=WL(),mPe=["/properties"],rm="http://json-schema.org/draft-07/schema";class td extends dPe.default{_addVocabularies(){if(super._addVocabularies(),fPe.default.forEach((e)=>this.addVocabulary(e)),this.opts.discriminator)this.addKeyword(pPe.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let e=this.opts.$data?this.$dataMetaSchema(GL,mPe):GL;this.addMetaSchema(e,rm,!1),this.refs["http://json-schema.org/schema"]=rm}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(rm)?rm:void 0)}}yr.Ajv=td;C_.exports=yr=td;C_.exports.Ajv=td;Object.defineProperty(yr,"__esModule",{value:!0});yr.default=td;var hPe=Vl();Object.defineProperty(yr,"KeywordCxt",{enumerable:!0,get:function(){return hPe.KeywordCxt}});var hc=me();Object.defineProperty(yr,"_",{enumerable:!0,get:function(){return hc._}});Object.defineProperty(yr,"str",{enumerable:!0,get:function(){return hc.str}});Object.defineProperty(yr,"stringify",{enumerable:!0,get:function(){return hc.stringify}});Object.defineProperty(yr,"nil",{enumerable:!0,get:function(){return hc.nil}});Object.defineProperty(yr,"Name",{enumerable:!0,get:function(){return hc.Name}});Object.defineProperty(yr,"CodeGen",{enumerable:!0,get:function(){return hc.CodeGen}});var gPe=j0();Object.defineProperty(yr,"ValidationError",{enumerable:!0,get:function(){return gPe.default}});var yPe=zl();Object.defineProperty(yr,"MissingRefError",{enumerable:!0,get:function(){return yPe.default}})});var JL=h(function(YL){Object.defineProperty(YL,"__esModule",{value:!0});YL.formatLimitDefinition=void 0;var vPe=KL(),gn=me(),Rs=gn.operators,nm={formatMaximum:{okStr:"<=",ok:Rs.LTE,fail:Rs.GT},formatMinimum:{okStr:">=",ok:Rs.GTE,fail:Rs.LT},formatExclusiveMaximum:{okStr:"<",ok:Rs.LT,fail:Rs.GTE},formatExclusiveMinimum:{okStr:">",ok:Rs.GT,fail:Rs.LTE}},_Pe={message:({keyword:e,schemaCode:t})=>gn.str`should be ${nm[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>gn._`{comparison: ${nm[e].okStr}, limit: ${t}}`};YL.formatLimitDefinition={keyword:Object.keys(nm),type:"string",schemaType:"string",$data:!0,error:_Pe,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 vPe.KeywordCxt(s,a.RULES.all.format.definition,"format");if(c.$data)l();else d();function l(){let m=t.scopeValue("formats",{ref:a.formats,code:o.code.formats}),p=t.const("fmt",gn._`${m}[${c.schemaCode}]`);e.fail$data((0,gn.or)(gn._`typeof ${p} != "object"`,gn._`${p} instanceof RegExp`,gn._`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?gn._`${o.code.formats}${(0,gn.getProperty)(m)}`:void 0});e.fail$data(f(g))}function f(m){return gn._`${m}.compare(${r}, ${n}) ${nm[i].fail} 0`}},dependencies:["format"]};var DPe=(e)=>(e.addKeyword(YL.formatLimitDefinition),e);YL.default=DPe});var eU=h(function(rd,ZL){Object.defineProperty(rd,"__esModule",{value:!0});var gc=Kq(),EPe=JL(),R_=me(),XL=new R_.Name("fullFormats"),SPe=new R_.Name("fastFormats"),O_=(e,t={keywords:!0})=>{if(Array.isArray(t))return QL(e,t,gc.fullFormats,XL),e;let[r,n]=t.mode==="fast"?[gc.fastFormats,SPe]:[gc.fullFormats,XL],i=t.formats||gc.formatNames;if(QL(e,i,r,n),t.keywords)(0,EPe.default)(e);return e};O_.get=(e,t="full")=>{let n=(t==="fast"?gc.fastFormats:gc.fullFormats)[e];if(!n)throw Error(`Unknown format "${e}"`);return n};function QL(e,t,r,n){var i,s;(i=(s=e.opts.code).formats)!==null&&i!==void 0||(s.formats=R_._`require("ajv-formats/dist/formats").${n}`);for(let o of t)e.addFormat(o,r[o])}ZL.exports=rd=O_;Object.defineProperty(rd,"__esModule",{value:!0});rd.default=O_});var $Pe=(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,l=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 il(l,e),l.cancel=()=>{if(o)clearTimeout(o),o=void 0;if(a)clearTimeout(a),a=void 0},l},A_;var tU=A(()=>{ab();A_=$Pe});var nd=h(function(mJe,rU){var CPe=Number.MAX_SAFE_INTEGER||9007199254740991,FPe=["major","premajor","minor","preminor","patch","prepatch","prerelease"];rU.exports={MAX_LENGTH:256,MAX_SAFE_COMPONENT_LENGTH:16,MAX_SAFE_BUILD_LENGTH:250,MAX_SAFE_INTEGER:CPe,RELEASE_TYPES:FPe,SEMVER_SPEC_VERSION:"2.0.0",FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2}});var id=h(function(hJe,nU){var RPe=typeof process==="object"&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...e)=>console.error("SEMVER",...e):()=>{};nU.exports=RPe});var yc=h(function(Xn,iU){var{MAX_SAFE_COMPONENT_LENGTH:k_,MAX_SAFE_BUILD_LENGTH:OPe,MAX_LENGTH:APe}=nd(),kPe=id();Xn=iU.exports={};var PPe=Xn.re=[],IPe=Xn.safeRe=[],z=Xn.src=[],TPe=Xn.safeSrc=[],H=Xn.t={},NPe=0,P_="[a-zA-Z0-9-]",qPe=[["\\s",1],["\\d",APe],[P_,OPe]],jPe=(e)=>{for(let[t,r]of qPe)e=e.split(`${t}*`).join(`${t}{0,${r}}`).split(`${t}+`).join(`${t}{1,${r}}`);return e},oe=(e,t,r)=>{let n=jPe(t),i=NPe++;kPe(e,i,t),H[e]=i,z[i]=t,TPe[i]=n,PPe[i]=new RegExp(t,r?"g":void 0),IPe[i]=new RegExp(n,r?"g":void 0)};oe("NUMERICIDENTIFIER","0|[1-9]\\d*");oe("NUMERICIDENTIFIERLOOSE","\\d+");oe("NONNUMERICIDENTIFIER",`\\d*[a-zA-Z-]${P_}*`);oe("MAINVERSION",`(${z[H.NUMERICIDENTIFIER]})\\.(${z[H.NUMERICIDENTIFIER]})\\.(${z[H.NUMERICIDENTIFIER]})`);oe("MAINVERSIONLOOSE",`(${z[H.NUMERICIDENTIFIERLOOSE]})\\.(${z[H.NUMERICIDENTIFIERLOOSE]})\\.(${z[H.NUMERICIDENTIFIERLOOSE]})`);oe("PRERELEASEIDENTIFIER",`(?:${z[H.NONNUMERICIDENTIFIER]}|${z[H.NUMERICIDENTIFIER]})`);oe("PRERELEASEIDENTIFIERLOOSE",`(?:${z[H.NONNUMERICIDENTIFIER]}|${z[H.NUMERICIDENTIFIERLOOSE]})`);oe("PRERELEASE",`(?:-(${z[H.PRERELEASEIDENTIFIER]}(?:\\.${z[H.PRERELEASEIDENTIFIER]})*))`);oe("PRERELEASELOOSE",`(?:-?(${z[H.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${z[H.PRERELEASEIDENTIFIERLOOSE]})*))`);oe("BUILDIDENTIFIER",`${P_}+`);oe("BUILD",`(?:\\+(${z[H.BUILDIDENTIFIER]}(?:\\.${z[H.BUILDIDENTIFIER]})*))`);oe("FULLPLAIN",`v?${z[H.MAINVERSION]}${z[H.PRERELEASE]}?${z[H.BUILD]}?`);oe("FULL",`^${z[H.FULLPLAIN]}$`);oe("LOOSEPLAIN",`[v=\\s]*${z[H.MAINVERSIONLOOSE]}${z[H.PRERELEASELOOSE]}?${z[H.BUILD]}?`);oe("LOOSE",`^${z[H.LOOSEPLAIN]}$`);oe("GTLT","((?:<|>)?=?)");oe("XRANGEIDENTIFIERLOOSE",`${z[H.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);oe("XRANGEIDENTIFIER",`${z[H.NUMERICIDENTIFIER]}|x|X|\\*`);oe("XRANGEPLAIN",`[v=\\s]*(${z[H.XRANGEIDENTIFIER]})(?:\\.(${z[H.XRANGEIDENTIFIER]})(?:\\.(${z[H.XRANGEIDENTIFIER]})(?:${z[H.PRERELEASE]})?${z[H.BUILD]}?)?)?`);oe("XRANGEPLAINLOOSE",`[v=\\s]*(${z[H.XRANGEIDENTIFIERLOOSE]})(?:\\.(${z[H.XRANGEIDENTIFIERLOOSE]})(?:\\.(${z[H.XRANGEIDENTIFIERLOOSE]})(?:${z[H.PRERELEASELOOSE]})?${z[H.BUILD]}?)?)?`);oe("XRANGE",`^${z[H.GTLT]}\\s*${z[H.XRANGEPLAIN]}$`);oe("XRANGELOOSE",`^${z[H.GTLT]}\\s*${z[H.XRANGEPLAINLOOSE]}$`);oe("COERCEPLAIN",`(^|[^\\d])(\\d{1,${k_}})(?:\\.(\\d{1,${k_}}))?(?:\\.(\\d{1,${k_}}))?`);oe("COERCE",`${z[H.COERCEPLAIN]}(?:$|[^\\d])`);oe("COERCEFULL",z[H.COERCEPLAIN]+`(?:${z[H.PRERELEASE]})?(?:${z[H.BUILD]})?(?:$|[^\\d])`);oe("COERCERTL",z[H.COERCE],!0);oe("COERCERTLFULL",z[H.COERCEFULL],!0);oe("LONETILDE","(?:~>?)");oe("TILDETRIM",`(\\s*)${z[H.LONETILDE]}\\s+`,!0);Xn.tildeTrimReplace="$1~";oe("TILDE",`^${z[H.LONETILDE]}${z[H.XRANGEPLAIN]}$`);oe("TILDELOOSE",`^${z[H.LONETILDE]}${z[H.XRANGEPLAINLOOSE]}$`);oe("LONECARET","(?:\\^)");oe("CARETTRIM",`(\\s*)${z[H.LONECARET]}\\s+`,!0);Xn.caretTrimReplace="$1^";oe("CARET",`^${z[H.LONECARET]}${z[H.XRANGEPLAIN]}$`);oe("CARETLOOSE",`^${z[H.LONECARET]}${z[H.XRANGEPLAINLOOSE]}$`);oe("COMPARATORLOOSE",`^${z[H.GTLT]}\\s*(${z[H.LOOSEPLAIN]})$|^$`);oe("COMPARATOR",`^${z[H.GTLT]}\\s*(${z[H.FULLPLAIN]})$|^$`);oe("COMPARATORTRIM",`(\\s*)${z[H.GTLT]}\\s*(${z[H.LOOSEPLAIN]}|${z[H.XRANGEPLAIN]})`,!0);Xn.comparatorTrimReplace="$1$2$3";oe("HYPHENRANGE",`^\\s*(${z[H.XRANGEPLAIN]})\\s+-\\s+(${z[H.XRANGEPLAIN]})\\s*$`);oe("HYPHENRANGELOOSE",`^\\s*(${z[H.XRANGEPLAINLOOSE]})\\s+-\\s+(${z[H.XRANGEPLAINLOOSE]})\\s*$`);oe("STAR","(<|>)?=?\\s*\\*");oe("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$");oe("GTE0PRE","^\\s*>=\\s*0\\.0\\.0-0\\s*$")});var im=h(function(gJe,sU){var MPe=Object.freeze({loose:!0}),BPe=Object.freeze({}),LPe=(e)=>{if(!e)return BPe;if(typeof e!=="object")return MPe;return e};sU.exports=LPe});var I_=h(function(yJe,cU){var oU=/^[0-9]+$/,aU=(e,t)=>{if(typeof e==="number"&&typeof t==="number")return e===t?0:e<t?-1:1;let r=oU.test(e),n=oU.test(t);if(r&&n)e=+e,t=+t;return e===t?0:r&&!n?-1:n&&!r?1:e<t?-1:1},UPe=(e,t)=>aU(t,e);cU.exports={compareIdentifiers:aU,rcompareIdentifiers:UPe}});var Mt=h(function(xJe,lU){var sm=id(),{MAX_LENGTH:uU,MAX_SAFE_INTEGER:om}=nd(),{safeRe:am,t:cm}=yc(),VPe=im(),{compareIdentifiers:T_}=I_();class yn{constructor(e,t){if(t=VPe(t),e instanceof yn)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>uU)throw TypeError(`version is longer than ${uU} characters`);sm("SemVer",e,t),this.options=t,this.loose=!!t.loose,this.includePrerelease=!!t.includePrerelease;let r=e.trim().match(t.loose?am[cm.LOOSE]:am[cm.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>om||this.major<0)throw TypeError("Invalid major version");if(this.minor>om||this.minor<0)throw TypeError("Invalid minor version");if(this.patch>om||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<om)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(sm("SemVer.compare",this.version,this.options,e),!(e instanceof yn)){if(typeof e==="string"&&e===this.version)return 0;e=new yn(e,this.options)}if(e.version===this.version)return 0;return this.compareMain(e)||this.comparePre(e)}compareMain(e){if(!(e instanceof yn))e=new yn(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 yn))e=new yn(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(sm("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 T_(r,n)}while(++t)}compareBuild(e){if(!(e instanceof yn))e=new yn(e,this.options);let t=0;do{let r=this.build[t],n=e.build[t];if(sm("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 T_(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?am[cm.PRERELEASELOOSE]:am[cm.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(T_(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}}lU.exports=yn});var $o=h(function(bJe,fU){var dU=Mt(),zPe=(e,t,r=!1)=>{if(e instanceof dU)return e;try{return new dU(e,t)}catch(n){if(!r)return null;throw n}};fU.exports=zPe});var mU=h(function(vJe,pU){var HPe=$o(),WPe=(e,t)=>{let r=HPe(e,t);return r?r.version:null};pU.exports=WPe});var gU=h(function(_Je,hU){var GPe=$o(),KPe=(e,t)=>{let r=GPe(e.trim().replace(/^[=v]+/,""),t);return r?r.version:null};hU.exports=KPe});var bU=h(function(DJe,xU){var yU=Mt(),YPe=(e,t,r,n,i)=>{if(typeof r==="string")i=n,n=r,r=void 0;try{return new yU(e instanceof yU?e.version:e,r).inc(t,n,i).version}catch(s){return null}};xU.exports=YPe});var DU=h(function(wJe,_U){var vU=$o(),JPe=(e,t)=>{let r=vU(e,null,!0),n=vU(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"};_U.exports=JPe});var EU=h(function(EJe,wU){var XPe=Mt(),QPe=(e,t)=>new XPe(e,t).major;wU.exports=QPe});var $U=h(function(SJe,SU){var ZPe=Mt(),e8e=(e,t)=>new ZPe(e,t).minor;SU.exports=e8e});var FU=h(function($Je,CU){var t8e=Mt(),r8e=(e,t)=>new t8e(e,t).patch;CU.exports=r8e});var OU=h(function(CJe,RU){var n8e=$o(),i8e=(e,t)=>{let r=n8e(e,t);return r&&r.prerelease.length?r.prerelease:null};RU.exports=i8e});var Wr=h(function(FJe,kU){var AU=Mt(),s8e=(e,t,r)=>new AU(e,r).compare(new AU(t,r));kU.exports=s8e});var IU=h(function(RJe,PU){var o8e=Wr(),a8e=(e,t,r)=>o8e(t,e,r);PU.exports=a8e});var NU=h(function(OJe,TU){var c8e=Wr(),u8e=(e,t)=>c8e(e,t,!0);TU.exports=u8e});var um=h(function(AJe,jU){var qU=Mt(),l8e=(e,t,r)=>{let n=new qU(e,r),i=new qU(t,r);return n.compare(i)||n.compareBuild(i)};jU.exports=l8e});var BU=h(function(kJe,MU){var d8e=um(),f8e=(e,t)=>e.sort((r,n)=>d8e(r,n,t));MU.exports=f8e});var UU=h(function(PJe,LU){var p8e=um(),m8e=(e,t)=>e.sort((r,n)=>p8e(n,r,t));LU.exports=m8e});var sd=h(function(IJe,VU){var h8e=Wr(),g8e=(e,t,r)=>h8e(e,t,r)>0;VU.exports=g8e});var lm=h(function(TJe,zU){var y8e=Wr(),x8e=(e,t,r)=>y8e(e,t,r)<0;zU.exports=x8e});var N_=h(function(NJe,HU){var b8e=Wr(),v8e=(e,t,r)=>b8e(e,t,r)===0;HU.exports=v8e});var q_=h(function(qJe,WU){var _8e=Wr(),D8e=(e,t,r)=>_8e(e,t,r)!==0;WU.exports=D8e});var dm=h(function(jJe,GU){var w8e=Wr(),E8e=(e,t,r)=>w8e(e,t,r)>=0;GU.exports=E8e});var fm=h(function(MJe,KU){var S8e=Wr(),$8e=(e,t,r)=>S8e(e,t,r)<=0;KU.exports=$8e});var j_=h(function(BJe,YU){var C8e=N_(),F8e=q_(),R8e=sd(),O8e=dm(),A8e=lm(),k8e=fm(),P8e=(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 C8e(e,r,n);case"!=":return F8e(e,r,n);case">":return R8e(e,r,n);case">=":return O8e(e,r,n);case"<":return A8e(e,r,n);case"<=":return k8e(e,r,n);default:throw TypeError(`Invalid operator: ${t}`)}};YU.exports=P8e});var XU=h(function(LJe,JU){var I8e=Mt(),T8e=$o(),{safeRe:pm,t:mm}=yc(),N8e=(e,t)=>{if(e instanceof I8e)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?pm[mm.COERCEFULL]:pm[mm.COERCE]);else{let c=t.includePrerelease?pm[mm.COERCERTLFULL]:pm[mm.COERCERTL],l;while((l=c.exec(e))&&(!r||r.index+r[0].length!==e.length)){if(!r||l.index+l[0].length!==r.index+r[0].length)r=l;c.lastIndex=l.index+l[1].length+l[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 T8e(`${n}.${i}.${s}${o}${a}`,t)};JU.exports=N8e});var eV=h(function(UJe,ZU){class QU{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}}ZU.exports=QU});var Gr=h(function(VJe,iV){var q8e=/\s+/g;class od{constructor(e,t){if(t=M8e(t),e instanceof od)if(e.loose===!!t.loose&&e.includePrerelease===!!t.includePrerelease)return e;else return new od(e.raw,t);if(e instanceof M_)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(q8e," "),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)=>!rV(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&&W8e(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&&z8e)|(this.options.loose&&H8e))+":"+e,n=tV.get(r);if(n)return n;let i=this.options.loose,s=i?Qt[Bt.HYPHENRANGELOOSE]:Qt[Bt.HYPHENRANGE];e=e.replace(s,r4e(this.options.includePrerelease)),Ze("hyphen replace",e),e=e.replace(Qt[Bt.COMPARATORTRIM],L8e),Ze("comparator trim",e),e=e.replace(Qt[Bt.TILDETRIM],U8e),Ze("tilde trim",e),e=e.replace(Qt[Bt.CARETTRIM],V8e),Ze("caret trim",e);let o=e.split(" ").map((d)=>G8e(d,this.options)).join(" ").split(/\s+/).map((d)=>t4e(d,this.options));if(i)o=o.filter((d)=>(Ze("loose invalid filter",d,this.options),!!d.match(Qt[Bt.COMPARATORLOOSE])));Ze("range list",o);let a=new Map,c=o.map((d)=>new M_(d,this.options));for(let d of c){if(rV(d))return[d];a.set(d.value,d)}if(a.size>1&&a.has(""))a.delete("");let l=[...a.values()];return tV.set(r,l),l}intersects(e,t){if(!(e instanceof od))throw TypeError("a Range is required");return this.set.some((r)=>nV(r,t)&&e.set.some((n)=>nV(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 B8e(e,this.options)}catch(t){return!1}for(let t=0;t<this.set.length;t++)if(n4e(this.set[t],e,this.options))return!0;return!1}}iV.exports=od;var j8e=eV(),tV=new j8e,M8e=im(),M_=ad(),Ze=id(),B8e=Mt(),{safeRe:Qt,t:Bt,comparatorTrimReplace:L8e,tildeTrimReplace:U8e,caretTrimReplace:V8e}=yc(),{FLAG_INCLUDE_PRERELEASE:z8e,FLAG_LOOSE:H8e}=nd(),rV=(e)=>e.value==="<0.0.0-0",W8e=(e)=>e.value==="",nV=(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},G8e=(e,t)=>(e=e.replace(Qt[Bt.BUILD],""),Ze("comp",e,t),e=J8e(e,t),Ze("caret",e),e=K8e(e,t),Ze("tildes",e),e=Q8e(e,t),Ze("xrange",e),e=e4e(e,t),Ze("stars",e),e),Zt=(e)=>!e||e.toLowerCase()==="x"||e==="*",K8e=(e,t)=>e.trim().split(/\s+/).map((r)=>Y8e(r,t)).join(" "),Y8e=(e,t)=>{let r=t.loose?Qt[Bt.TILDELOOSE]:Qt[Bt.TILDE];return e.replace(r,(n,i,s,o,a)=>{Ze("tilde",e,n,i,s,o,a);let c;if(Zt(i))c="";else if(Zt(s))c=`>=${i}.0.0 <${+i+1}.0.0-0`;else if(Zt(o))c=`>=${i}.${s}.0 <${i}.${+s+1}.0-0`;else if(a)Ze("replaceTilde pr",a),c=`>=${i}.${s}.${o}-${a} <${i}.${+s+1}.0-0`;else c=`>=${i}.${s}.${o} <${i}.${+s+1}.0-0`;return Ze("tilde return",c),c})},J8e=(e,t)=>e.trim().split(/\s+/).map((r)=>X8e(r,t)).join(" "),X8e=(e,t)=>{Ze("caret",e,t);let r=t.loose?Qt[Bt.CARETLOOSE]:Qt[Bt.CARET],n=t.includePrerelease?"-0":"";return e.replace(r,(i,s,o,a,c)=>{Ze("caret",e,i,s,o,a,c);let l;if(Zt(s))l="";else if(Zt(o))l=`>=${s}.0.0${n} <${+s+1}.0.0-0`;else if(Zt(a))if(s==="0")l=`>=${s}.${o}.0${n} <${s}.${+o+1}.0-0`;else l=`>=${s}.${o}.0${n} <${+s+1}.0.0-0`;else if(c)if(Ze("replaceCaret pr",c),s==="0")if(o==="0")l=`>=${s}.${o}.${a}-${c} <${s}.${o}.${+a+1}-0`;else l=`>=${s}.${o}.${a}-${c} <${s}.${+o+1}.0-0`;else l=`>=${s}.${o}.${a}-${c} <${+s+1}.0.0-0`;else if(Ze("no pr"),s==="0")if(o==="0")l=`>=${s}.${o}.${a}${n} <${s}.${o}.${+a+1}-0`;else l=`>=${s}.${o}.${a}${n} <${s}.${+o+1}.0-0`;else l=`>=${s}.${o}.${a} <${+s+1}.0.0-0`;return Ze("caret return",l),l})},Q8e=(e,t)=>(Ze("replaceXRanges",e,t),e.split(/\s+/).map((r)=>Z8e(r,t)).join(" ")),Z8e=(e,t)=>{e=e.trim();let r=t.loose?Qt[Bt.XRANGELOOSE]:Qt[Bt.XRANGE];return e.replace(r,(n,i,s,o,a,c)=>{Ze("xRange",e,n,i,s,o,a,c);let l=Zt(s),d=l||Zt(o),f=d||Zt(a),m=f;if(i==="="&&m)i="";if(c=t.includePrerelease?"-0":"",l)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 Ze("xRange return",n),n})},e4e=(e,t)=>(Ze("replaceStars",e,t),e.trim().replace(Qt[Bt.STAR],"")),t4e=(e,t)=>(Ze("replaceGTE0",e,t),e.trim().replace(Qt[t.includePrerelease?Bt.GTE0PRE:Bt.GTE0],"")),r4e=(e)=>(t,r,n,i,s,o,a,c,l,d,f,m)=>{if(Zt(n))r="";else if(Zt(i))r=`>=${n}.0.0${e?"-0":""}`;else if(Zt(s))r=`>=${n}.${i}.0${e?"-0":""}`;else if(o)r=`>=${r}`;else r=`>=${r}${e?"-0":""}`;if(Zt(l))c="";else if(Zt(d))c=`<${+l+1}.0.0-0`;else if(Zt(f))c=`<${l}.${+d+1}.0-0`;else if(m)c=`<=${l}.${d}.${f}-${m}`;else if(e)c=`<${l}.${d}.${+f+1}-0`;else c=`<=${c}`;return`${r} ${c}`.trim()},n4e=(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(Ze(e[n].semver),e[n].semver===M_.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 ad=h(function(zJe,lV){var cd=Symbol("SemVer ANY");class hm{static get ANY(){return cd}constructor(e,t){if(t=sV(t),e instanceof hm)if(e.loose===!!t.loose)return e;else e=e.value;if(e=e.trim().split(/\s+/).join(" "),L_("comparator",e,t),this.options=t,this.loose=!!t.loose,this.parse(e),this.semver===cd)this.value="";else this.value=this.operator+this.semver.version;L_("comp",this)}parse(e){let t=this.options.loose?oV[aV.COMPARATORLOOSE]:oV[aV.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=cd;else this.semver=new cV(r[2],this.options.loose)}toString(){return this.value}test(e){if(L_("Comparator.test",e,this.options.loose),this.semver===cd||e===cd)return!0;if(typeof e==="string")try{e=new cV(e,this.options)}catch(t){return!1}return B_(e,this.operator,this.semver,this.options)}intersects(e,t){if(!(e instanceof hm))throw TypeError("a Comparator is required");if(this.operator===""){if(this.value==="")return!0;return new uV(e.value,t).test(this.value)}else if(e.operator===""){if(e.value==="")return!0;return new uV(this.value,t).test(e.semver)}if(t=sV(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(B_(this.semver,"<",e.semver,t)&&this.operator.startsWith(">")&&e.operator.startsWith("<"))return!0;if(B_(this.semver,">",e.semver,t)&&this.operator.startsWith("<")&&e.operator.startsWith(">"))return!0;return!1}}lV.exports=hm;var sV=im(),{safeRe:oV,t:aV}=yc(),B_=j_(),L_=id(),cV=Mt(),uV=Gr()});var ud=h(function(HJe,dV){var i4e=Gr(),s4e=(e,t,r)=>{try{t=new i4e(t,r)}catch(n){return!1}return t.test(e)};dV.exports=s4e});var pV=h(function(WJe,fV){var o4e=Gr(),a4e=(e,t)=>new o4e(e,t).set.map((r)=>r.map((n)=>n.value).join(" ").trim().split(" "));fV.exports=a4e});var hV=h(function(GJe,mV){var c4e=Mt(),u4e=Gr(),l4e=(e,t,r)=>{let n=null,i=null,s=null;try{s=new u4e(t,r)}catch(o){return null}return e.forEach((o)=>{if(s.test(o)){if(!n||i.compare(o)===-1)n=o,i=new c4e(n,r)}}),n};mV.exports=l4e});var yV=h(function(KJe,gV){var d4e=Mt(),f4e=Gr(),p4e=(e,t,r)=>{let n=null,i=null,s=null;try{s=new f4e(t,r)}catch(o){return null}return e.forEach((o)=>{if(s.test(o)){if(!n||i.compare(o)===1)n=o,i=new d4e(n,r)}}),n};gV.exports=p4e});var vV=h(function(YJe,bV){var U_=Mt(),m4e=Gr(),xV=sd(),h4e=(e,t)=>{e=new m4e(e,t);let r=new U_("0.0.0");if(e.test(r))return r;if(r=new U_("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 U_(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||xV(a,s))s=a;break;case"<":case"<=":break;default:throw Error(`Unexpected operation: ${o.operator}`)}}),s&&(!r||xV(r,s)))r=s}if(r&&e.test(r))return r;return null};bV.exports=h4e});var DV=h(function(JJe,_V){var g4e=Gr(),y4e=(e,t)=>{try{return new g4e(e,t).range||"*"}catch(r){return null}};_V.exports=y4e});var gm=h(function(XJe,$V){var x4e=Mt(),SV=ad(),{ANY:b4e}=SV,v4e=Gr(),_4e=ud(),wV=sd(),EV=lm(),D4e=fm(),w4e=dm(),E4e=(e,t,r,n)=>{e=new x4e(e,n),t=new v4e(t,n);let i,s,o,a,c;switch(r){case">":i=wV,s=D4e,o=EV,a=">",c=">=";break;case"<":i=EV,s=w4e,o=wV,a="<",c="<=";break;default:throw TypeError('Must provide a hilo val of "<" or ">"')}if(_4e(e,t,n))return!1;for(let l=0;l<t.set.length;++l){let d=t.set[l],f=null,m=null;if(d.forEach((p)=>{if(p.semver===b4e)p=new SV(">=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};$V.exports=E4e});var FV=h(function(QJe,CV){var S4e=gm(),$4e=(e,t,r)=>S4e(e,t,">",r);CV.exports=$4e});var OV=h(function(ZJe,RV){var C4e=gm(),F4e=(e,t,r)=>C4e(e,t,"<",r);RV.exports=F4e});var PV=h(function(eXe,kV){var AV=Gr(),R4e=(e,t,r)=>(e=new AV(e,r),t=new AV(t,r),e.intersects(t,r));kV.exports=R4e});var TV=h(function(tXe,IV){var O4e=ud(),A4e=Wr();IV.exports=(e,t,r)=>{let n=[],i=null,s=null,o=e.sort((d,f)=>A4e(d,f,r));for(let d of o)if(O4e(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(" || "),l=typeof t.raw==="string"?t.raw:String(t);return c.length<l.length?c:t}});var LV=h(function(rXe,BV){var NV=Gr(),z_=ad(),{ANY:V_}=z_,ld=ud(),H_=Wr(),k4e=(e,t,r={})=>{if(e===t)return!0;e=new NV(e,r),t=new NV(t,r);let n=!1;e:for(let i of e.set){for(let s of t.set){let o=I4e(i,s,r);if(n=n||o!==null,o)continue e}if(n)return!1}return!0},P4e=[new z_(">=0.0.0-0")],qV=[new z_(">=0.0.0")],I4e=(e,t,r)=>{if(e===t)return!0;if(e.length===1&&e[0].semver===V_)if(t.length===1&&t[0].semver===V_)return!0;else if(r.includePrerelease)e=P4e;else e=qV;if(t.length===1&&t[0].semver===V_)if(r.includePrerelease)return!0;else t=qV;let n=new Set,i,s;for(let p of e)if(p.operator===">"||p.operator===">=")i=jV(i,p,r);else if(p.operator==="<"||p.operator==="<=")s=MV(s,p,r);else n.add(p.semver);if(n.size>1)return null;let o;if(i&&s){if(o=H_(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&&!ld(p,String(i),r))return null;if(s&&!ld(p,String(s),r))return null;for(let g of t)if(!ld(p,String(g),r))return!1;return!0}let a,c,l,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===">=",l=l||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=jV(i,p,r),a===p&&a!==i)return!1}else if(i.operator===">="&&!ld(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=MV(s,p,r),c===p&&c!==s)return!1}else if(s.operator==="<="&&!ld(s.semver,String(p),r))return!1}if(!p.operator&&(s||i)&&o!==0)return!1}if(i&&l&&!s&&o!==0)return!1;if(s&&d&&!i&&o!==0)return!1;if(m||f)return!1;return!0},jV=(e,t,r)=>{if(!e)return t;let n=H_(e.semver,t.semver,r);return n>0?e:n<0?t:t.operator===">"&&e.operator===">="?t:e},MV=(e,t,r)=>{if(!e)return t;let n=H_(e.semver,t.semver,r);return n<0?e:n>0?t:t.operator==="<"&&e.operator==="<="?t:e};BV.exports=k4e});var HV=h(function(nXe,zV){var W_=yc(),UV=nd(),T4e=Mt(),VV=I_(),N4e=$o(),q4e=mU(),j4e=gU(),M4e=bU(),B4e=DU(),L4e=EU(),U4e=$U(),V4e=FU(),z4e=OU(),H4e=Wr(),W4e=IU(),G4e=NU(),K4e=um(),Y4e=BU(),J4e=UU(),X4e=sd(),Q4e=lm(),Z4e=N_(),e3e=q_(),t3e=dm(),r3e=fm(),n3e=j_(),i3e=XU(),s3e=ad(),o3e=Gr(),a3e=ud(),c3e=pV(),u3e=hV(),l3e=yV(),d3e=vV(),f3e=DV(),p3e=gm(),m3e=FV(),h3e=OV(),g3e=PV(),y3e=TV(),x3e=LV();zV.exports={parse:N4e,valid:q4e,clean:j4e,inc:M4e,diff:B4e,major:L4e,minor:U4e,patch:V4e,prerelease:z4e,compare:H4e,rcompare:W4e,compareLoose:G4e,compareBuild:K4e,sort:Y4e,rsort:J4e,gt:X4e,lt:Q4e,eq:Z4e,neq:e3e,gte:t3e,lte:r3e,cmp:n3e,coerce:i3e,Comparator:s3e,Range:o3e,satisfies:a3e,toComparators:c3e,maxSatisfying:u3e,minSatisfying:l3e,minVersion:d3e,validRange:f3e,outside:p3e,gtr:m3e,ltr:h3e,intersects:g3e,simplifyRange:y3e,subset:x3e,SemVer:T4e,re:W_.re,src:W_.src,tokens:W_.t,SEMVER_SPEC_VERSION:UV.SEMVER_SPEC_VERSION,RELEASE_TYPES:UV.RELEASE_TYPES,compareIdentifiers:VV.compareIdentifiers,rcompareIdentifiers:VV.rcompareIdentifiers}});function GV(e,t,r){if(!e)return!1;if(e.constructor===t)return!0;return b3e.call(e)===r}function KV(e){return GV(e,Uint8Array,"[object Uint8Array]")}function v3e(e){return GV(e,ArrayBuffer,"[object ArrayBuffer]")}function _3e(e){return KV(e)||v3e(e)}function D3e(e){if(!KV(e))throw TypeError(`Expected \`Uint8Array\`, got \`${typeof e}\``)}function w3e(e){if(!_3e(e))throw TypeError(`Expected \`Uint8Array\` or \`ArrayBuffer\`, got \`${typeof e}\``)}function G_(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)D3e(i),r.set(i,n),n+=i.length;return r}function K_(e,t="utf8"){return w3e(e),WV[t]??=new globalThis.TextDecoder(t),WV[t].decode(e)}function E3e(e){if(typeof e!=="string")throw TypeError(`Expected \`string\`, got \`${typeof e}\``)}function ym(e){return E3e(e),S3e.encode(e)}var b3e,WV,S3e,iXe;var YV=A(()=>{b3e=Object.prototype.toString;WV={utf8:new globalThis.TextDecoder("utf8")};S3e=new globalThis.TextEncoder;iXe=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"))});import{isDeepStrictEqual as $3e}from"util";import JV from"process";import Co from"fs";import XV from"path";import dd from"crypto";import C3e from"assert";var ZV,ez,Fo,F3e,QV="aes-256-cbc",xc=()=>Object.create(null),R3e=(e)=>e!==void 0&&e!==null,O3e=(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`)},xm="__internal__",Y_,bm;var tz=A(()=>{uT();dT();LT();tU();YV();ZV=ne(jq(),1),ez=ne(eU(),1),Fo=ne(HV(),1),F3e=ez.default.default,Y_=`${xm}.migrations.version`;bm=class bm{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=Sb(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 ZV.Ajv2020({allErrors:!0,useDefaults:!0,...t.ajvOptions});F3e(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=XV.resolve(t.cwd,`${t.configName??"config"}${r}`);let n=this.store,i=Object.assign(xc(),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{C3e.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 ${xm} key, as it's used to manage this module internal operations.`);let{store:r}=this,n=(i,s)=>{if(O3e(i,s),this.#e.accessPropertiesByDotNotation)Db(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 cT(this.store,e);return e in this.store}reset(...e){for(let t of e)if(R3e(this.#i[t]))this.set(t,this.#i[t])}delete(e){let{store:t}=this;if(this.#e.accessPropertiesByDotNotation)aT(t,e);else delete t[e];this.store=t}clear(){this.store=xc();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=Co.readFileSync(this.path,this.#t?null:"utf8"),t=this._encryptData(e),r=this._deserialize(t);return this._validate(r),Object.assign(xc(),r)}catch(e){if(e?.code==="ENOENT")return this._ensureDirectory(),xc();if(this.#e.clearInvalidConfig&&e.name==="SyntaxError")return xc();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:K_(e);try{let t=e.slice(0,16),r=dd.pbkdf2Sync(this.#t,t.toString(),1e4,32,"sha512"),n=dd.createDecipheriv(QV,r,t),i=e.slice(17),s=typeof i==="string"?ym(i):i;return K_(G_([n.update(s),n.final()]))}catch{}return e.toString()}_handleChange(e,t){let r=e(),n=()=>{let i=r,s=e();if($3e(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(){Co.mkdirSync(XV.dirname(this.path),{recursive:!0})}_write(e){let t=this._serialize(e);if(this.#t){let r=dd.randomBytes(16),n=dd.pbkdf2Sync(this.#t,r.toString(),1e4,32,"sha512"),i=dd.createCipheriv(QV,n,r);t=G_([r,ym(":"),i.update(ym(t)),i.final()])}if(JV.env.SNAP)Co.writeFileSync(this.path,t,{mode:this.#e.configFileMode});else try{Nb(this.path,t,{mode:this.#e.configFileMode})}catch(r){if(r?.code==="EXDEV"){Co.writeFileSync(this.path,t,{mode:this.#e.configFileMode});return}throw r}}_watch(){if(this._ensureDirectory(),!Co.existsSync(this.path))this._write(xc());if(JV.platform==="win32")Co.watch(this.path,{persistent:!1},A_(()=>{this.events.dispatchEvent(new Event("change"))},{wait:100}));else Co.watchFile(this.path,{persistent:!1},A_(()=>{this.events.dispatchEvent(new Event("change"))},{wait:5000}))}_migrate(e,t,r){let n=this._get(Y_,"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(Y_,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)||!Fo.default.eq(n,t))this._set(Y_,t)}_containsReservedKey(e){if(typeof e==="object"){if(Object.keys(e)[0]===xm)return!0}if(typeof e!=="string")return!1;if(this.#e.accessPropertiesByDotNotation){if(e.startsWith(`${xm}.`))return!0;return!1}return!1}_isVersionInRangeFormat(e){return Fo.default.clean(e)===null}_shouldPerformMigration(e,t,r){if(this._isVersionInRangeFormat(e)){if(t!=="0.0.0"&&Fo.default.satisfies(t,e))return!1;return Fo.default.satisfies(r,e)}if(Fo.default.lte(e,t))return!1;if(Fo.default.gt(e,r))return!1;return!0}_get(e,t){return oT(this.store,e,t)}_set(e,t){let{store:r}=this;Db(r,e,t),this.store=r}}});var ve,J_,N,Qn=(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 fd=A(()=>{(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}})(ve||(ve={}));(function(e){e.mergeShapes=(t,r)=>({...t,...r})})(J_||(J_={}));N=ve.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"])});var I,A3e=(e)=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:"),xr;var vm=A(()=>{fd();I=ve.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"]);xr=class xr 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 xr))throw Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,ve.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()}};xr.create=(e)=>new xr(e)});var k3e=(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,ve.jsonStringifyReplacer)}`;break;case I.unrecognized_keys:r=`Unrecognized key(s) in object: ${ve.joinValues(e.keys,", ")}`;break;case I.invalid_union:r="Invalid input";break;case I.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${ve.joinValues(e.options)}`;break;case I.invalid_enum_value:r=`Invalid enum value. Expected ${ve.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 ve.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,ve.assertNever(e)}return{message:r}},Fi;var X_=A(()=>{vm();fd();Fi=k3e});function P3e(e){rz=e}function bc(){return rz}var rz;var _m=A(()=>{X_();rz=Fi});function L(e,t){let r=bc(),n=pd({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,r,r===Fi?void 0:Fi].filter((i)=>!!i)});e.common.issues.push(n)}class kt{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 Q;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 kt.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 Q;if(s.status==="aborted")return Q;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 pd=(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((l)=>!!l).slice().reverse();for(let l of c)a=l(o,{data:t,defaultError:a}).message;return{...i,path:s,message:a}},I3e,Q,Ro=(e)=>({status:"dirty",value:e}),Lt=(e)=>({status:"valid",value:e}),Dm=(e)=>e.status==="aborted",wm=(e)=>e.status==="dirty",Os=(e)=>e.status==="valid",vc=(e)=>typeof Promise<"u"&&e instanceof Promise;var Q_=A(()=>{_m();X_();I3e=[];Q=Object.freeze({status:"aborted"})});var nz=()=>{};var G;var iz=A(()=>{(function(e){e.errToObj=(t)=>typeof t==="string"?{message:t}:t||{},e.toString=(t)=>typeof t==="string"?t:t?.message})(G||(G={}))});class _n{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 le(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 he{get description(){return this._def.description}_getType(e){return Qn(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:Qn(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new kt,ctx:{common:e.parent.common,data:e.data,parsedType:Qn(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(vc(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:Qn(e)},n=this._parseSync({data:e,path:r.path,parent:r});return sz(r,n)}"~validate"(e){let t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Qn(e)};if(!this["~standard"].async)try{let r=this._parseSync({data:e,path:[],parent:t});return Os(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)=>Os(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:Qn(e)},n=this._parse({data:e,path:r.path,parent:r}),i=await(vc(n)?n:Promise.resolve(n));return sz(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 Dn({schema:this,typeName:ee.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 vn.create(this,this._def)}nullable(){return Oi.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return bn.create(this)}promise(){return Po.create(this,this._def)}or(e){return $c.create([this,e],this._def)}and(e){return Cc.create(this,e,this._def)}transform(e){return new Dn({...le(this._def),schema:this,typeName:ee.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let t=typeof e==="function"?e:()=>e;return new Ac({...le(this._def),innerType:this,defaultValue:t,typeName:ee.ZodDefault})}brand(){return new Sm({typeName:ee.ZodBranded,type:this,...le(this._def)})}catch(e){let t=typeof e==="function"?e:()=>e;return new kc({...le(this._def),innerType:this,catchValue:t,typeName:ee.ZodCatch})}describe(e){return new this.constructor({...this._def,description:e})}pipe(e){return bd.create(this,e)}readonly(){return Pc.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}function cz(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 X3e(e){return new RegExp(`^${cz(e)}$`)}function uz(e){let t=`${az}T${cz(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 Q3e(e,t){if((t==="v4"||!t)&&z3e.test(e))return!0;if((t==="v6"||!t)&&W3e.test(e))return!0;return!1}function Z3e(e,t){if(!B3e.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 eIe(e,t){if((t==="v4"||!t)&&H3e.test(e))return!0;if((t==="v6"||!t)&&G3e.test(e))return!0;return!1}function tIe(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 _c(e){if(e instanceof ut){let t={};for(let r in e.shape){let n=e.shape[r];t[r]=vn.create(_c(n))}return new ut({...e._def,shape:()=>t})}else if(e instanceof bn)return new bn({...e._def,type:_c(e.element)});else if(e instanceof vn)return vn.create(_c(e.unwrap()));else if(e instanceof Oi)return Oi.create(_c(e.unwrap()));else if(e instanceof ei)return ei.create(e.items.map((t)=>_c(t)));else return e}function eD(e,t){let r=Qn(e),n=Qn(t);if(e===t)return{valid:!0,data:e};else if(r===N.object&&n===N.object){let i=ve.objectKeys(t),s=ve.objectKeys(e).filter((a)=>i.indexOf(a)!==-1),o={...e,...t};for(let a of s){let c=eD(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=eD(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 lz(e,t){return new Is({values:e,typeName:ee.ZodEnum,...le(t)})}function oz(e,t){let r=typeof e==="function"?e(t):typeof e==="string"?{message:e}:e;return typeof r==="string"?{message:r}:r}function dz(e,t={},r){if(e)return Ao.create().superRefine((n,i)=>{let s=e(n);if(s instanceof Promise)return s.then((o)=>{if(!o){let a=oz(t,n),c=a.fatal??r??!0;i.addIssue({code:"custom",...a,fatal:c})}});if(!s){let o=oz(t,n),a=o.fatal??r??!0;i.addIssue({code:"custom",...o,fatal:a})}return});return Ao.create()}var sz=(e,t)=>{if(Os(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 xr(e.common.issues);return this._error=r,this._error}}}},T3e,N3e,q3e,j3e,M3e,B3e,L3e,U3e,V3e="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",Z_,z3e,H3e,W3e,G3e,K3e,Y3e,az="((\\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])))",J3e,xn,ks,Ps,wc,Oo,md,Ec,Sc,Ao,As,Zn,hd,bn,ut,$c,Ri=(e)=>{if(e instanceof Fc)return Ri(e.schema);else if(e instanceof Dn)return Ri(e.innerType());else if(e instanceof Rc)return[e.value];else if(e instanceof Is)return e.options;else if(e instanceof Oc)return ve.objectValues(e.enum);else if(e instanceof Ac)return Ri(e._def.innerType);else if(e instanceof Ec)return[void 0];else if(e instanceof Sc)return[null];else if(e instanceof vn)return[void 0,...Ri(e.unwrap())];else if(e instanceof Oi)return[null,...Ri(e.unwrap())];else if(e instanceof Sm)return Ri(e.unwrap());else if(e instanceof Pc)return Ri(e.unwrap());else if(e instanceof kc)return Ri(e._def.innerType);else return[]},Em,Cc,ei,gd,yd,ko,Dc,Fc,Rc,Is,Oc,Po,Dn,vn,Oi,Ac,kc,xd,rIe,Sm,bd,Pc,nIe,ee,iIe=(e,t={message:`Input not instance of ${e.name}`})=>dz((r)=>r instanceof e,t),fz,pz,sIe,oIe,mz,aIe,cIe,uIe,lIe,dIe,fIe,pIe,mIe,hIe,gIe,yIe,xIe,bIe,vIe,_Ie,DIe,wIe,EIe,SIe,$Ie,CIe,FIe,RIe,OIe,AIe,kIe,PIe,IIe,TIe,NIe=()=>fz().optional(),qIe=()=>pz().optional(),jIe=()=>mz().optional(),MIe,BIe;var hz=A(()=>{vm();_m();iz();Q_();fd();T3e=/^c[^\s-]{8,}$/i,N3e=/^[0-9a-z]+$/,q3e=/^[0-9A-HJKMNP-TV-Z]{26}$/i,j3e=/^[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,M3e=/^[a-z0-9_-]{21}$/i,B3e=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,L3e=/^[-+]?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)?)??$/,U3e=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,z3e=/^(?:(?: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])$/,H3e=/^(?:(?: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])$/,W3e=/^(([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]))$/,G3e=/^(([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])$/,K3e=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Y3e=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,J3e=new RegExp(`^${az}$`);xn=class xn extends he{_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}),Q}let r=new kt,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(!U3e.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(!Z_)Z_=new RegExp(V3e,"u");if(!Z_.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(!j3e.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(!M3e.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(!T3e.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(!N3e.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(!q3e.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(!uz(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(!J3e.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(!X3e(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(!L3e.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(!Q3e(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(!Z3e(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(!eIe(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(!K3e.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(!Y3e.test(e.data))n=this._getOrReturnCtx(e,n),L(n,{validation:"base64url",code:I.invalid_string,message:i.message}),r.dirty()}else ve.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,...G.errToObj(r)})}_addCheck(e){return new xn({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...G.errToObj(e)})}url(e){return this._addCheck({kind:"url",...G.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...G.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...G.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...G.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...G.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...G.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...G.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...G.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...G.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...G.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...G.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...G.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,...G.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,...G.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...G.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...G.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...G.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...G.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...G.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...G.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...G.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...G.errToObj(t)})}nonempty(e){return this.min(1,G.errToObj(e))}trim(){return new xn({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new xn({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new xn({...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}};xn.create=(e)=>new xn({checks:[],typeName:ee.ZodString,coerce:e?.coerce??!1,...le(e)});ks=class ks extends he{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}),Q}let r=void 0,n=new kt;for(let i of this._def.checks)if(i.kind==="int"){if(!ve.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(tIe(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 ve.assertNever(i);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,G.toString(t))}gt(e,t){return this.setLimit("min",e,!1,G.toString(t))}lte(e,t){return this.setLimit("max",e,!0,G.toString(t))}lt(e,t){return this.setLimit("max",e,!1,G.toString(t))}setLimit(e,t,r,n){return new ks({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:G.toString(n)}]})}_addCheck(e){return new ks({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:G.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:G.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:G.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:G.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:G.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:G.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:G.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:G.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:G.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"&&ve.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)}};ks.create=(e)=>new ks({checks:[],typeName:ee.ZodNumber,coerce:e?.coerce||!1,...le(e)});Ps=class Ps extends he{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 kt;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 ve.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}),Q}gte(e,t){return this.setLimit("min",e,!0,G.toString(t))}gt(e,t){return this.setLimit("min",e,!1,G.toString(t))}lte(e,t){return this.setLimit("max",e,!0,G.toString(t))}lt(e,t){return this.setLimit("max",e,!1,G.toString(t))}setLimit(e,t,r,n){return new Ps({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:G.toString(n)}]})}_addCheck(e){return new Ps({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:G.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:G.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:G.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:G.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:G.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}};Ps.create=(e)=>new Ps({checks:[],typeName:ee.ZodBigInt,coerce:e?.coerce??!1,...le(e)});wc=class wc extends he{_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}),Q}return Lt(e.data)}};wc.create=(e)=>new wc({typeName:ee.ZodBoolean,coerce:e?.coerce||!1,...le(e)});Oo=class Oo extends he{_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}),Q}if(Number.isNaN(e.data.getTime())){let i=this._getOrReturnCtx(e);return L(i,{code:I.invalid_date}),Q}let r=new kt,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 ve.assertNever(i);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Oo({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:G.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:G.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}};Oo.create=(e)=>new Oo({checks:[],coerce:e?.coerce||!1,typeName:ee.ZodDate,...le(e)});md=class md extends he{_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}),Q}return Lt(e.data)}};md.create=(e)=>new md({typeName:ee.ZodSymbol,...le(e)});Ec=class Ec extends he{_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}),Q}return Lt(e.data)}};Ec.create=(e)=>new Ec({typeName:ee.ZodUndefined,...le(e)});Sc=class Sc extends he{_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}),Q}return Lt(e.data)}};Sc.create=(e)=>new Sc({typeName:ee.ZodNull,...le(e)});Ao=class Ao extends he{constructor(){super(...arguments);this._any=!0}_parse(e){return Lt(e.data)}};Ao.create=(e)=>new Ao({typeName:ee.ZodAny,...le(e)});As=class As extends he{constructor(){super(...arguments);this._unknown=!0}_parse(e){return Lt(e.data)}};As.create=(e)=>new As({typeName:ee.ZodUnknown,...le(e)});Zn=class Zn extends he{_parse(e){let t=this._getOrReturnCtx(e);return L(t,{code:I.invalid_type,expected:N.never,received:t.parsedType}),Q}};Zn.create=(e)=>new Zn({typeName:ee.ZodNever,...le(e)});hd=class hd extends he{_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}),Q}return Lt(e.data)}};hd.create=(e)=>new hd({typeName:ee.ZodVoid,...le(e)});bn=class bn extends he{_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}),Q;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 _n(t,s,t.path,o)))).then((s)=>kt.mergeArray(r,s));let i=[...t.data].map((s,o)=>n.type._parseSync(new _n(t,s,t.path,o)));return kt.mergeArray(r,i)}get element(){return this._def.type}min(e,t){return new bn({...this._def,minLength:{value:e,message:G.toString(t)}})}max(e,t){return new bn({...this._def,maxLength:{value:e,message:G.toString(t)}})}length(e,t){return new bn({...this._def,exactLength:{value:e,message:G.toString(t)}})}nonempty(e){return this.min(1,e)}};bn.create=(e,t)=>new bn({type:e,minLength:null,maxLength:null,exactLength:null,typeName:ee.ZodArray,...le(t)});ut=class ut extends he{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=ve.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}),Q}let{status:r,ctx:n}=this._processInputParams(e),{shape:i,keys:s}=this._getCached(),o=[];if(!(this._def.catchall instanceof Zn&&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 l=i[c],d=n.data[c];a.push({key:{status:"valid",value:c},value:l._parse(new _n(n,d,n.path,c)),alwaysSet:c in n.data})}if(this._def.catchall instanceof Zn){let c=this._def.unknownKeys;if(c==="passthrough")for(let l of o)a.push({key:{status:"valid",value:l},value:{status:"valid",value:n.data[l]}});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 l of o){let d=n.data[l];a.push({key:{status:"valid",value:l},value:c._parse(new _n(n,d,n.path,l)),alwaysSet:l in n.data})}}if(n.common.async)return Promise.resolve().then(async()=>{let c=[];for(let l of a){let d=await l.key,f=await l.value;c.push({key:d,value:f,alwaysSet:l.alwaysSet})}return c}).then((c)=>kt.mergeObjectSync(r,c));else return kt.mergeObjectSync(r,a)}get shape(){return this._def.shape()}strict(e){return G.errToObj,new ut({...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:G.errToObj(e).message??n};return{message:n}}}:{}})}strip(){return new ut({...this._def,unknownKeys:"strip"})}passthrough(){return new ut({...this._def,unknownKeys:"passthrough"})}extend(e){return new ut({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new ut({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:ee.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new ut({...this._def,catchall:e})}pick(e){let t={};for(let r of ve.objectKeys(e))if(e[r]&&this.shape[r])t[r]=this.shape[r];return new ut({...this._def,shape:()=>t})}omit(e){let t={};for(let r of ve.objectKeys(this.shape))if(!e[r])t[r]=this.shape[r];return new ut({...this._def,shape:()=>t})}deepPartial(){return _c(this)}partial(e){let t={};for(let r of ve.objectKeys(this.shape)){let n=this.shape[r];if(e&&!e[r])t[r]=n;else t[r]=n.optional()}return new ut({...this._def,shape:()=>t})}required(e){let t={};for(let r of ve.objectKeys(this.shape))if(e&&!e[r])t[r]=this.shape[r];else{let i=this.shape[r];while(i instanceof vn)i=i._def.innerType;t[r]=i}return new ut({...this._def,shape:()=>t})}keyof(){return lz(ve.objectKeys(this.shape))}};ut.create=(e,t)=>new ut({shape:()=>e,unknownKeys:"strip",catchall:Zn.create(),typeName:ee.ZodObject,...le(t)});ut.strictCreate=(e,t)=>new ut({shape:()=>e,unknownKeys:"strict",catchall:Zn.create(),typeName:ee.ZodObject,...le(t)});ut.lazycreate=(e,t)=>new ut({shape:e,unknownKeys:"strip",catchall:Zn.create(),typeName:ee.ZodObject,...le(t)});$c=class $c extends he{_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 xr(o.ctx.common.issues));return L(t,{code:I.invalid_union,unionErrors:s}),Q}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},l=a._parseSync({data:t.data,path:t.path,parent:c});if(l.status==="valid")return l;else if(l.status==="dirty"&&!i)i={result:l,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 xr(a));return L(t,{code:I.invalid_union,unionErrors:o}),Q}}get options(){return this._def.options}};$c.create=(e,t)=>new $c({options:e,typeName:ee.ZodUnion,...le(t)});Em=class Em extends he{_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}),Q;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]}),Q;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=Ri(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 Em({typeName:ee.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:n,...le(r)})}};Cc=class Cc extends he{_parse(e){let{status:t,ctx:r}=this._processInputParams(e),n=(i,s)=>{if(Dm(i)||Dm(s))return Q;let o=eD(i.value,s.value);if(!o.valid)return L(r,{code:I.invalid_intersection_types}),Q;if(wm(i)||wm(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}))}};Cc.create=(e,t,r)=>new Cc({left:e,right:t,typeName:ee.ZodIntersection,...le(r)});ei=class ei extends he{_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}),Q;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"}),Q;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 _n(r,s,r.path,o))}).filter((s)=>!!s);if(r.common.async)return Promise.all(i).then((s)=>kt.mergeArray(t,s));else return kt.mergeArray(t,i)}get items(){return this._def.items}rest(e){return new ei({...this._def,rest:e})}};ei.create=(e,t)=>{if(!Array.isArray(e))throw Error("You must pass an array of schemas to z.tuple([ ... ])");return new ei({items:e,typeName:ee.ZodTuple,rest:null,...le(t)})};gd=class gd extends he{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}),Q;let n=[],i=this._def.keyType,s=this._def.valueType;for(let o in r.data)n.push({key:i._parse(new _n(r,o,r.path,o)),value:s._parse(new _n(r,r.data[o],r.path,o)),alwaysSet:o in r.data});if(r.common.async)return kt.mergeObjectAsync(t,n);else return kt.mergeObjectSync(t,n)}get element(){return this._def.valueType}static create(e,t,r){if(t instanceof he)return new gd({keyType:e,valueType:t,typeName:ee.ZodRecord,...le(r)});return new gd({keyType:xn.create(),valueType:e,typeName:ee.ZodRecord,...le(t)})}};yd=class yd extends he{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}),Q;let n=this._def.keyType,i=this._def.valueType,s=[...r.data.entries()].map(([o,a],c)=>({key:n._parse(new _n(r,o,r.path,[c,"key"])),value:i._parse(new _n(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,l=await a.value;if(c.status==="aborted"||l.status==="aborted")return Q;if(c.status==="dirty"||l.status==="dirty")t.dirty();o.set(c.value,l.value)}return{status:t.value,value:o}})}else{let o=new Map;for(let a of s){let{key:c,value:l}=a;if(c.status==="aborted"||l.status==="aborted")return Q;if(c.status==="dirty"||l.status==="dirty")t.dirty();o.set(c.value,l.value)}return{status:t.value,value:o}}}};yd.create=(e,t,r)=>new yd({valueType:t,keyType:e,typeName:ee.ZodMap,...le(r)});ko=class ko extends he{_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}),Q;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 l of a){if(l.status==="aborted")return Q;if(l.status==="dirty")t.dirty();c.add(l.value)}return{status:t.value,value:c}}let o=[...r.data.values()].map((a,c)=>i._parse(new _n(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 ko({...this._def,minSize:{value:e,message:G.toString(t)}})}max(e,t){return new ko({...this._def,maxSize:{value:e,message:G.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};ko.create=(e,t)=>new ko({valueType:e,minSize:null,maxSize:null,typeName:ee.ZodSet,...le(t)});Dc=class Dc extends he{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}),Q;function r(o,a){return pd({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,bc(),Fi].filter((c)=>!!c),issueData:{code:I.invalid_arguments,argumentsError:a}})}function n(o,a){return pd({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,bc(),Fi].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 Po){let o=this;return Lt(async function(...a){let c=new xr([]),l=await o._def.args.parseAsync(a,i).catch((m)=>{throw c.addIssue(r(a,m)),c}),d=await Reflect.apply(s,this,l);return await o._def.returns._def.type.parseAsync(d,i).catch((m)=>{throw c.addIssue(n(d,m)),c})})}else{let o=this;return Lt(function(...a){let c=o._def.args.safeParse(a,i);if(!c.success)throw new xr([r(a,c.error)]);let l=Reflect.apply(s,this,c.data),d=o._def.returns.safeParse(l,i);if(!d.success)throw new xr([n(l,d.error)]);return d.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Dc({...this._def,args:ei.create(e).rest(As.create())})}returns(e){return new Dc({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,r){return new Dc({args:e?e:ei.create([]).rest(As.create()),returns:t||As.create(),typeName:ee.ZodFunction,...le(r)})}};Fc=class Fc extends he{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})}};Fc.create=(e,t)=>new Fc({getter:e,typeName:ee.ZodLazy,...le(t)});Rc=class Rc extends he{_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}),Q}return{status:"valid",value:e.data}}get value(){return this._def.value}};Rc.create=(e,t)=>new Rc({value:e,typeName:ee.ZodLiteral,...le(t)});Is=class Is extends he{_parse(e){if(typeof e.data!=="string"){let t=this._getOrReturnCtx(e),r=this._def.values;return L(t,{expected:ve.joinValues(r),received:t.parsedType,code:I.invalid_type}),Q}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}),Q}return Lt(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 Is.create(e,{...this._def,...t})}exclude(e,t=this._def){return Is.create(this.options.filter((r)=>!e.includes(r)),{...this._def,...t})}};Is.create=lz;Oc=class Oc extends he{_parse(e){let t=ve.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==N.string&&r.parsedType!==N.number){let n=ve.objectValues(t);return L(r,{expected:ve.joinValues(n),received:r.parsedType,code:I.invalid_type}),Q}if(!this._cache)this._cache=new Set(ve.getValidEnumValues(this._def.values));if(!this._cache.has(e.data)){let n=ve.objectValues(t);return L(r,{received:r.data,code:I.invalid_enum_value,options:n}),Q}return Lt(e.data)}get enum(){return this._def.values}};Oc.create=(e,t)=>new Oc({values:e,typeName:ee.ZodNativeEnum,...le(t)});Po=class Po extends he{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}),Q;let r=t.parsedType===N.promise?t.data:Promise.resolve(t.data);return Lt(r.then((n)=>this._def.type.parseAsync(n,{path:t.path,errorMap:t.common.contextualErrorMap})))}};Po.create=(e,t)=>new Po({type:e,typeName:ee.ZodPromise,...le(t)});Dn=class Dn extends he{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===ee.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 Q;let a=await this._def.schema._parseAsync({data:o,path:r.path,parent:r});if(a.status==="aborted")return Q;if(a.status==="dirty")return Ro(a.value);if(t.value==="dirty")return Ro(a.value);return a});else{if(t.value==="aborted")return Q;let o=this._def.schema._parseSync({data:s,path:r.path,parent:r});if(o.status==="aborted")return Q;if(o.status==="dirty")return Ro(o.value);if(t.value==="dirty")return Ro(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 Q;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 Q;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(!Os(s))return Q;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(!Os(s))return Q;return Promise.resolve(n.transform(s.value,i)).then((o)=>({status:t.value,value:o}))});ve.assertNever(n)}};Dn.create=(e,t,r)=>new Dn({schema:e,typeName:ee.ZodEffects,effect:t,...le(r)});Dn.createWithPreprocess=(e,t,r)=>new Dn({schema:t,effect:{type:"preprocess",transform:e},typeName:ee.ZodEffects,...le(r)});vn=class vn extends he{_parse(e){if(this._getType(e)===N.undefined)return Lt(void 0);return this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};vn.create=(e,t)=>new vn({innerType:e,typeName:ee.ZodOptional,...le(t)});Oi=class Oi extends he{_parse(e){if(this._getType(e)===N.null)return Lt(null);return this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Oi.create=(e,t)=>new Oi({innerType:e,typeName:ee.ZodNullable,...le(t)});Ac=class Ac extends he{_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}};Ac.create=(e,t)=>new Ac({innerType:e,typeName:ee.ZodDefault,defaultValue:typeof t.default==="function"?t.default:()=>t.default,...le(t)});kc=class kc extends he{_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(vc(n))return n.then((i)=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new xr(r.common.issues)},input:r.data})}));else return{status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new xr(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}};kc.create=(e,t)=>new kc({innerType:e,typeName:ee.ZodCatch,catchValue:typeof t.catch==="function"?t.catch:()=>t.catch,...le(t)});xd=class xd extends he{_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}),Q}return{status:"valid",value:e.data}}};xd.create=(e)=>new xd({typeName:ee.ZodNaN,...le(e)});rIe=Symbol("zod_brand");Sm=class Sm extends he{_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}};bd=class bd extends he{_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 Q;if(i.status==="dirty")return t.dirty(),Ro(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 Q;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 bd({in:e,out:t,typeName:ee.ZodPipeline})}};Pc=class Pc extends he{_parse(e){let t=this._def.innerType._parse(e),r=(n)=>{if(Os(n))n.value=Object.freeze(n.value);return n};return vc(t)?t.then((n)=>r(n)):r(t)}unwrap(){return this._def.innerType}};Pc.create=(e,t)=>new Pc({innerType:e,typeName:ee.ZodReadonly,...le(t)});nIe={object:ut.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"})(ee||(ee={}));fz=xn.create,pz=ks.create,sIe=xd.create,oIe=Ps.create,mz=wc.create,aIe=Oo.create,cIe=md.create,uIe=Ec.create,lIe=Sc.create,dIe=Ao.create,fIe=As.create,pIe=Zn.create,mIe=hd.create,hIe=bn.create,gIe=ut.create,yIe=ut.strictCreate,xIe=$c.create,bIe=Em.create,vIe=Cc.create,_Ie=ei.create,DIe=gd.create,wIe=yd.create,EIe=ko.create,SIe=Dc.create,$Ie=Fc.create,CIe=Rc.create,FIe=Is.create,RIe=Oc.create,OIe=Po.create,AIe=Dn.create,kIe=vn.create,PIe=Oi.create,IIe=Dn.createWithPreprocess,TIe=bd.create,MIe={string:(e)=>xn.create({...e,coerce:!0}),number:(e)=>ks.create({...e,coerce:!0}),boolean:(e)=>wc.create({...e,coerce:!0}),bigint:(e)=>Ps.create({...e,coerce:!0}),date:(e)=>Oo.create({...e,coerce:!0})},BIe=Q});var E={};ji(E,{BRAND:()=>rIe,DIRTY:()=>Ro,EMPTY_PATH:()=>I3e,INVALID:()=>Q,NEVER:()=>BIe,OK:()=>Lt,ParseStatus:()=>kt,Schema:()=>he,ZodAny:()=>Ao,ZodArray:()=>bn,ZodBigInt:()=>Ps,ZodBoolean:()=>wc,ZodBranded:()=>Sm,ZodCatch:()=>kc,ZodDate:()=>Oo,ZodDefault:()=>Ac,ZodDiscriminatedUnion:()=>Em,ZodEffects:()=>Dn,ZodEnum:()=>Is,ZodError:()=>xr,ZodFirstPartyTypeKind:()=>ee,ZodFunction:()=>Dc,ZodIntersection:()=>Cc,ZodIssueCode:()=>I,ZodLazy:()=>Fc,ZodLiteral:()=>Rc,ZodMap:()=>yd,ZodNaN:()=>xd,ZodNativeEnum:()=>Oc,ZodNever:()=>Zn,ZodNull:()=>Sc,ZodNullable:()=>Oi,ZodNumber:()=>ks,ZodObject:()=>ut,ZodOptional:()=>vn,ZodParsedType:()=>N,ZodPipeline:()=>bd,ZodPromise:()=>Po,ZodReadonly:()=>Pc,ZodRecord:()=>gd,ZodSchema:()=>he,ZodSet:()=>ko,ZodString:()=>xn,ZodSymbol:()=>md,ZodTransformer:()=>Dn,ZodTuple:()=>ei,ZodType:()=>he,ZodUndefined:()=>Ec,ZodUnion:()=>$c,ZodUnknown:()=>As,ZodVoid:()=>hd,addIssueToContext:()=>L,any:()=>dIe,array:()=>hIe,bigint:()=>oIe,boolean:()=>mz,coerce:()=>MIe,custom:()=>dz,date:()=>aIe,datetimeRegex:()=>uz,defaultErrorMap:()=>Fi,discriminatedUnion:()=>bIe,effect:()=>AIe,enum:()=>FIe,function:()=>SIe,getErrorMap:()=>bc,getParsedType:()=>Qn,instanceof:()=>iIe,intersection:()=>vIe,isAborted:()=>Dm,isAsync:()=>vc,isDirty:()=>wm,isValid:()=>Os,late:()=>nIe,lazy:()=>$Ie,literal:()=>CIe,makeIssue:()=>pd,map:()=>wIe,nan:()=>sIe,nativeEnum:()=>RIe,never:()=>pIe,null:()=>lIe,nullable:()=>PIe,number:()=>pz,object:()=>gIe,objectUtil:()=>J_,oboolean:()=>jIe,onumber:()=>qIe,optional:()=>kIe,ostring:()=>NIe,pipeline:()=>TIe,preprocess:()=>IIe,promise:()=>OIe,quotelessJson:()=>A3e,record:()=>DIe,set:()=>EIe,setErrorMap:()=>P3e,strictObject:()=>yIe,string:()=>fz,symbol:()=>cIe,transformer:()=>AIe,tuple:()=>_Ie,undefined:()=>uIe,union:()=>xIe,unknown:()=>fIe,util:()=>ve,void:()=>mIe});var tD=A(()=>{_m();Q_();nz();fd();hz();vm()});var Ic=A(()=>{tD();tD()});import{copyFileSync as LIe,existsSync as gz,mkdirSync as UIe}from"fs";import{homedir as Cm}from"os";import{join as Tc}from"path";function zIe(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 HIe(){return process.env.NEMAR_CONFIG_DIR||Tc(Cm(),".config","nemar")}function WIe(e){if(process.env.NEMAR_CONFIG_DIR)return;let t=Tc(e,"config.json");if(gz(t))return;let r=[];if(process.platform==="darwin")r.push(Tc(Cm(),"Library","Preferences","nemar-nodejs","config.json"));if(process.platform==="win32"){let n=process.env.APPDATA||Tc(Cm(),"AppData","Roaming");r.push(Tc(n,"nemar-nodejs","config.json"))}r.push(Tc(Cm(),".config","nemar-nodejs","config.json"));for(let n of r)if(gz(n))try{UIe(e,{recursive:!0}),LIe(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 wn(){let e=HIe();if($m&&yz===e)return $m;if(WIe(e),$m=new bm({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}),yz=e,!xz.has(e))xz.add(e),KIe(),YIe();return $m}function KIe(){let e=wn(),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 GIe){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 YIe(){let e=wn(),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(VIe.has(zIe(a)))r[s]={...o,apiUrl:Io},console.error(`[nemar] migrated stored apiUrl for account "${s}": ${a} -> ${Io}`),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 Fm(){return wn().get("activeAccount")}function Nc(){return wn().get("accounts")||{}}function ht(){let e={apiUrl:Io},t=Fm();if(!t)return e;return Nc()[t]||e}function bz(){return!!ht().sandboxCompleted}function En(e,t){let r=wn(),n=r.get("activeAccount")||"default",i=r.get("accounts")||{};if(!i[n])i[n]={apiUrl:Io};i[n][e]=t,r.store={...r.store,accounts:i,activeAccount:n}}function rD(e){let t=Fm();if(!t)return;let r=Nc();if(r[t])delete r[t][e],wn().set("accounts",r)}function vz(){let e=wn(),t=Fm();if(!t){e.clear();return}let r=Nc();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 _z(){wn().clear()}function Ue(){return!!ht().apiKey}function Dz(){return wn().path}function vd(){let e=Nc(),t=Fm();return Object.entries(e).map(([r,n])=>({username:n.username||r,email:n.email,githubUsername:n.githubUsername,active:r===t}))}function wz(e,t){let r=wn(),n=Nc();n[e]=t,r.store={...r.store,accounts:n,activeAccount:e}}function Ez(e){let t=wn(),r=Nc();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 Io="https://nemar-api-dev.sccn-org.workers.dev",VIe,YXe,$m=null,yz=null,xz,GIe;var Ts=A(()=>{tz();Ic();VIe=new Set(["https://api.osc.earth/nemar","https://nemar-api.neuromechanist.workers.dev","https://nemar-api-dev.shirazi-10f.workers.dev"]);YXe=E.object({apiKey:E.string().optional(),apiUrl:E.string().url().default(Io),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()});xz=new Set;GIe=["apiKey","apiUrl","username","email","githubUsername","sandboxCompleted","sandboxDatasetId","dismissedNoticeIds"]});function Rm(e){if(Sz)return;Sz=!0;let t=u.yellow("\u2500".repeat(60)),r=u.yellow.bold("[MAINTENANCE]"),n=u.dim(`mode: ${e.mode}`),i=e.eta?`
100
+ [nemar] You can manually copy ${n} to ${t}`)}}function wn(){let e=HIe();if($m&&yz===e)return $m;if(WIe(e),$m=new bm({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}),yz=e,!xz.has(e))xz.add(e),KIe(),YIe();return $m}function KIe(){let e=wn(),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 GIe){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 YIe(){let e=wn(),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(VIe.has(zIe(a)))r[s]={...o,apiUrl:Io},console.error(`[nemar] migrated stored apiUrl for account "${s}": ${a} -> ${Io}`),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 Fm(){return wn().get("activeAccount")}function Nc(){return wn().get("accounts")||{}}function ht(){let e={apiUrl:Io},t=Fm();if(!t)return e;return Nc()[t]||e}function bz(){return!!ht().sandboxCompleted}function En(e,t){let r=wn(),n=r.get("activeAccount")||"default",i=r.get("accounts")||{};if(!i[n])i[n]={apiUrl:Io};i[n][e]=t,r.store={...r.store,accounts:i,activeAccount:n}}function rD(e){let t=Fm();if(!t)return;let r=Nc();if(r[t])delete r[t][e],wn().set("accounts",r)}function vz(){let e=wn(),t=Fm();if(!t){e.clear();return}let r=Nc();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 _z(){wn().clear()}function Ue(){return!!ht().apiKey}function Dz(){return wn().path}function vd(){let e=Nc(),t=Fm();return Object.entries(e).map(([r,n])=>({username:n.username||r,email:n.email,githubUsername:n.githubUsername,active:r===t}))}function wz(e,t){let r=wn(),n=Nc();n[e]=t,r.store={...r.store,accounts:n,activeAccount:e}}function Ez(e){let t=wn(),r=Nc();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 Io="https://api.nemar.org",VIe,YXe,$m=null,yz=null,xz,GIe;var Ts=A(()=>{tz();Ic();VIe=new Set(["https://api.osc.earth/nemar","https://nemar-api.neuromechanist.workers.dev","https://nemar-api-dev.shirazi-10f.workers.dev"]);YXe=E.object({apiKey:E.string().optional(),apiUrl:E.string().url().default(Io),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()});xz=new Set;GIe=["apiKey","apiUrl","username","email","githubUsername","sandboxCompleted","sandboxDatasetId","dismissedNoticeIds"]});function Rm(e){if(Sz)return;Sz=!0;let t=u.yellow("\u2500".repeat(60)),r=u.yellow.bold("[MAINTENANCE]"),n=u.dim(`mode: ${e.mode}`),i=e.eta?`
101
101
  ${u.dim(`eta: ${e.eta}`)}`:"";process.stderr.write(`${t}
102
102
  ${r} ${e.message}
103
103
  ${n}${i}
104
104
  ${t}
105
- `)}var Sz=!1;var nD=A(()=>{He()});var Cz;var $z=A(()=>{Cz={name:"nemar-cli",version:"0.9.14-dev.2230",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",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","README.md","LICENSE"],dependencies:{chalk:"^5.3.0",commander:"^12.1.0",conf:"^13.0.1","fuse.js":"^7.1.0",inquirer:"^9.2.15",ora:"^8.0.1",zod:"^3.23.8"},"lint-staged":{"src/**/*.{ts,tsx}":["biome check --fix"],"backend/src/**/*.{ts,tsx}":["biome check --fix"]},devDependencies:{"@biomejs/biome":"1.9.4","@types/bcryptjs":"^3.0.0","@types/bun":"latest","@types/inquirer":"^9.0.7",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 To;var Om=A(()=>{$z();To=Cz.version});function V(e){if(e instanceof Error)return e.message;return String(e)}var q,No;var er=A(()=>{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"}};No=class No extends q{mode;eta;constructor(e,t,r,n){super(503,t,n);this.mode=e;this.eta=r;this.name="MaintenanceError"}}});function Fz(){if(process.env.TEST_API_URL)return process.env.TEST_API_URL;if(sD)return iD;return ht().apiUrl||iD}async function P(e,t={},r=!1,n){let i=`${Fz()}${e}`,s={"Content-Type":"application/json","X-CLI-Version":To,...t.headers};if(r){let c=ht();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 ${Fz()}`,{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.",l=typeof a.eta==="string"?a.eta:null,d=new No(a.mode,c,l,a.details);throw Rm(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 iD="https://nemar-api-dev.sccn-org.workers.dev",sD;var Ns=A(()=>{Ts();nD();Om();er();sD=iD.includes("workers.dev")});async function Rz(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 Oz(e){return P(`/admin/approve/${e}`,{method:"POST"},!0)}async function Az(e){return P(`/admin/approve/by-id/${e}`,{method:"POST"},!0)}async function kz(e){return P(`/admin/revoke/${e}`,{method:"POST"},!0)}async function Pz(e,t){return P(`/admin/users/${e}/role`,{method:"POST",body:JSON.stringify({role:t})},!0)}async function oD(e,t){return P(`/admin/datasets/${e}/visibility`,{method:"PATCH",body:JSON.stringify({visibility:t})},!0)}async function Iz(e){return P(`/datasets/${e}/publish`,{method:"POST"},!0)}async function Tz(e){return P(`/admin/datasets/${e}/ci`,{},!0)}async function Ai(e){return P(`/admin/datasets/${e}/ci`,{method:"POST"},!0)}async function aD(e){return P(`/admin/datasets/${e}/ci/validate`,{method:"POST"},!0)}async function cD(e){return P(`/admin/datasets/${e}/ci/sync`,{method:"POST"},!0)}async function Nz(e,t){return P(`/admin/datasets/${e}/doi/concept`,{method:"POST",body:JSON.stringify(t)},!0)}async function _d(e){return P(`/admin/datasets/${e}/doi`,{},!0)}async function uD(e,t){return P(`/admin/datasets/${e}/doi/update`,{method:"POST",body:JSON.stringify(t)},!0)}async function qz(e,t){return P(`/admin/datasets/${e}/withdraw`,{method:"POST",body:JSON.stringify({reason:t.reason,dry_run:t.dryRun})},!0)}async function jz(e,t){return P(`/admin/datasets/${e}/restore`,{method:"POST",body:JSON.stringify({dry_run:t.dryRun})},!0)}async function Mz(e){return P(`/admin/datasets/${e}/reset`,{method:"POST"},!0)}async function Bz(e,t=!1){return P(`/admin/datasets/${e}`,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({force:t})},!0)}async function Lz(e){return P("/admin/datasets/bulk-delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dataset_ids:e})},!0)}async function Uz(e){return P("/admin/datasets/import",{method:"POST",body:JSON.stringify(e)},!0)}async function Vz(e){return P("/admin/datasets/exemplar",{method:"POST",body:JSON.stringify(e)},!0)}async function zz(e){return P(`/admin/datasets/${e}/exemplar/remint-dois`,{method:"POST"},!0)}async function lD(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 Hz(e){return P(`/admin/imports/${e}/rollback`,{method:"POST"},!0)}async function Wz(e){return P(`/admin/imports/${e}/retry`,{method:"POST"},!0)}async function dD(e){return P(`/admin/imports/${e}/verify`,{method:"POST"},!0)}async function Gz(e){return P("/admin/imports/dispatch-cooldown",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dataset_ids:e})},!0)}async function qc(e,t){return P(`/admin/datasets/${e}/reindex`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t??{})},!0)}async function Kz(e,t){return P("/admin/datasets/reindex/bulk",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filter:e,...t??{}})},!0)}async function Yz(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 Jz(){return P("/admin/datasets/hed-sweep?reset=1",{method:"POST",headers:{"Content-Type":"application/json"}},!0)}async function Xz(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 Qz(){return P("/admin/datasets/data-integrity-sweep?reset=1",{method:"POST",headers:{"Content-Type":"application/json"}},!0)}async function Zz(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 eH(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 tH(){return P("/admin/datasets/availability-report-sweep?reset=1",{method:"POST",headers:{"Content-Type":"application/json"}},!0)}async function rH(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 jc(e,t){return P(`/admin/datasets/${e}/enforce`,{method:"POST",body:JSON.stringify({dry_run:t})},!0)}async function nH(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 iH(e,t=!1){return P(`/admin/datasets/${e}/revalidate${t?"?force=true":""}`,{method:"POST"},!0)}async function sH(e){let t=e?`?user=${encodeURIComponent(e)}`:"";return P(`/admin/email-preferences${t}`,{},!0)}async function oH(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 fD(e){return P("/admin/notify",{method:"POST",body:JSON.stringify(e)},!0)}async function aH(){return P("/admin/summary/coverage",{},!0)}async function cH(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 pD(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 mD(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 uH(){return P("/admin/zarr-catalog/publish",{method:"POST"},!0)}async function lH(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 Mc=A(()=>{Ns()});async function ti(e,t){return P(`/datasets/${e}/upload-credentials`,{method:"POST",body:JSON.stringify({duration_seconds:t})},!0)}async function hD(e,t){return P(`/datasets/${e}/download-credentials`,{method:"POST",body:JSON.stringify({duration_seconds:t})},!0)}async function dH(e){return P(`/admin/datasets/${e}/files`,{},!0)}async function fH(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 Bc=A(()=>{Ns();er()});function ZIe(e){return e.startsWith("v")?e:`v${e}`}var XIe,QIe,pH,mQe;var gD=A(()=>{Ic();XIe=/^v?\d+\.\d+\.\d+(?:-(?:rc|alpha|beta)\d*)?$/,QIe=/^v\d+\.\d+\.\d+(?:-(?:rc|alpha|beta)\d*)?$/;pH=E.string().regex(XIe,"must be a semver version, optionally v-prefixed").transform(ZIe),mQe=E.string().regex(QIe,"must be the canonical v-prefixed tag (vX.Y.Z)")});var eTe,tTe,mH;var hH=A(()=>{Ic();eTe=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(),tTe=E.object({prefix:E.string(),created_at:E.string(),last_used_at:E.string().nullable()}).passthrough().nullable(),mH=E.object({user:eTe,token:tTe.optional()}).passthrough()});function yH(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 xH(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 rTe="0.4.0",yD,Lc,gH,nTe,iTe,sTe,bH,vQe,vH,_Qe,ki,oTe,Am,DQe;var xD=A(()=>{Ic();gD();yD=E.enum(["openneuro","nemar","gin","other"]),Lc=E.union([E.literal(0),E.literal(1)]).nullable(),gH=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:Lc.optional(),hed_version:E.string().nullable().optional(),data_complete:Lc.optional(),bytes_present:E.number().nonnegative().nullable().optional(),latest_version:pH.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:Lc.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();nTe=gH.superRefine((e,t)=>{yH(e,t),xH(e,t)}),iTe=gH.extend({file_size:E.number().nonnegative().nullable(),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:Lc.optional(),attestation_no_duplicate:Lc.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)=>{yH(e,t),xH(e,t)}),sTe=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:Lc.optional(),score:E.number().optional(),snippet:E.string().optional()}).passthrough(),bH=E.record(E.string(),E.number().int().nonnegative()),vQe=E.object({datasets:E.array(nTe),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:bH.optional()}).passthrough(),vH=E.object({results:E.array(sTe),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:bH.optional()}).passthrough(),_Qe=E.object({dataset:iTe}).passthrough(),ki=E.object({value:E.string(),count:E.number().int().nonnegative()}),oTe=E.object({values:E.array(ki),distinct_total:E.number().int().nonnegative(),truncated:E.boolean()}),Am=E.object({"electrode-system":E.array(ki).optional(),source:E.array(ki).optional(),zarr:E.array(ki).optional(),powerline:E.array(ki).optional(),"bids-version":E.array(ki).optional(),"hed-version":E.array(ki).optional(),license:E.array(ki).optional(),modality:E.array(ki).optional(),task:oTe.optional(),warning:E.string().optional()}).passthrough(),DQe=E.object({schema_version:E.literal(rTe),doc_type:E.literal("dataset"),dataset_id:E.string().regex(/^[a-z]{2}\d+$/,"neuroschema dataset_id pattern"),name:E.string(),source:yD,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 km=A(()=>{gD();hH();xD()});async function Im(e){return P(`/datasets/${e}/ci/status`,{},!0)}async function _H(e){return P(`/datasets/${e}/manifest`,{},!0)}async function Tm(e,t){return P(`/datasets/${e}/manifest/${t}`,{},!0)}function DH(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 Uc(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(DH),n}async function wH(e){return P(`/datasets/resolve/${e}`,{},"optional")}async function EH(){return P("/datasets/facets",{signal:AbortSignal.timeout(5000)},"optional",Am)}async function SH(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",vH)}async function gt(e){let t=await P(`/datasets/${e}`,{},"optional");return DH(t.dataset)}async function $H(e){return P(`/datasets/${e}/versions`,{},!0)}async function Nm(e){return P("/datasets",{method:"POST",body:JSON.stringify(e)},!0)}async function qm(e){return P(`/datasets/${e}/finalize`,{method:"POST"},!0)}async function bD(e){return P(`/datasets/${e}/request-access`,{method:"POST"},!0)}async function CH(e,t){let r=t?`?status=${t}`:"";return P(`/datasets/${e}/access-requests${r}`,{},!0)}async function FH(e,t){return P(`/datasets/${e}/access-requests/${t}/approve`,{method:"POST"},!0)}async function RH(e,t){return P(`/datasets/${e}/access-requests/${t}/deny`,{method:"POST"},!0)}async function OH(e,t){return P(`/datasets/${e}/invite`,{method:"POST",body:JSON.stringify({username:t})},!0)}async function AH(e){return P(`/datasets/${e}/collaborators`,{},!0)}async function kH(e,t){return P(`/admin/datasets/${e}/enrichment`,{method:"POST",body:JSON.stringify(t)},!0)}var Pm;var qs=A(()=>{km();Ns();Pm=/^\d{4}-\d{4}-\d{4}-\d{3}[\dX]$/});var Vc;var qH=A(()=>{Vc=["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 zc(e){return P(`/datasets/${e}/publish/request`,{method:"POST"},!0)}async function MH(e){return P(`/datasets/${e}/publish/status`,{},!0)}async function BH(e){return P(`/datasets/${e}/publish/resend`,{method:"POST"},!0)}async function LH(e){let t=e?`?status=${e}`:"";return P(`/admin/publish/requests${t}`,{},!0)}async function UH(e,t){return P(`/admin/publish/${e}/deny`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({reason:t})},!0)}function aTe(e,t=[]){if(e){let r=Vc.indexOf(e);if(r>=0)return r+1}return Math.min(t.length+1,Vc.length)}function cTe(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 Hc(e,t=!1,r=!1,n=!1,i,s){let c,l,d=0,f=!1,m,p=t,g=[],y;function x(v,_,S,C){if(!s)return;s({step:v,stepIndex:aTe(v,_),stepTotal:Vc.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:l,skip_ci_check:n})},!0),S=!1,_.step_results)g.push(..._.step_results);if(_.s3_lock_total!==void 0)l=_.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"?l: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=jH(g);return _}catch(_){if(y=_,v===5||!cTe(_)){if(_ instanceof q&&g.length>0)_.stepResults=jH(g);throw _}let C=_;if(i?.({attempt:v,maxAttempts:5,delayMs:1e4,step:C.step,error:C.message}),await new Promise((D)=>setTimeout(D,1e4)),p=!0,c!==void 0)f=!0}throw y}function jH(e){let t=new Map;for(let r of e)t.set(r.step,r);return Array.from(t.values())}var Dd=A(()=>{qH();Ns();er()});function HH(e){DD=e}function wD(){return DD}function wd(e){if(DD)process.stderr.write(`${e}
105
+ `)}var Sz=!1;var nD=A(()=>{He()});var Cz;var $z=A(()=>{Cz={name:"nemar-cli",version:"0.9.14",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",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","README.md","LICENSE"],dependencies:{chalk:"^5.3.0",commander:"^12.1.0",conf:"^13.0.1","fuse.js":"^7.1.0",inquirer:"^9.2.15",ora:"^8.0.1",zod:"^3.23.8"},"lint-staged":{"src/**/*.{ts,tsx}":["biome check --fix"],"backend/src/**/*.{ts,tsx}":["biome check --fix"]},devDependencies:{"@biomejs/biome":"1.9.4","@types/bcryptjs":"^3.0.0","@types/bun":"latest","@types/inquirer":"^9.0.7",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 To;var Om=A(()=>{$z();To=Cz.version});function V(e){if(e instanceof Error)return e.message;return String(e)}var q,No;var er=A(()=>{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"}};No=class No extends q{mode;eta;constructor(e,t,r,n){super(503,t,n);this.mode=e;this.eta=r;this.name="MaintenanceError"}}});function Fz(){if(process.env.TEST_API_URL)return process.env.TEST_API_URL;if(sD)return iD;return ht().apiUrl||iD}async function P(e,t={},r=!1,n){let i=`${Fz()}${e}`,s={"Content-Type":"application/json","X-CLI-Version":To,...t.headers};if(r){let c=ht();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 ${Fz()}`,{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.",l=typeof a.eta==="string"?a.eta:null,d=new No(a.mode,c,l,a.details);throw Rm(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 iD="https://api.nemar.org",sD;var Ns=A(()=>{Ts();nD();Om();er();sD=iD.includes("workers.dev")});async function Rz(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 Oz(e){return P(`/admin/approve/${e}`,{method:"POST"},!0)}async function Az(e){return P(`/admin/approve/by-id/${e}`,{method:"POST"},!0)}async function kz(e){return P(`/admin/revoke/${e}`,{method:"POST"},!0)}async function Pz(e,t){return P(`/admin/users/${e}/role`,{method:"POST",body:JSON.stringify({role:t})},!0)}async function oD(e,t){return P(`/admin/datasets/${e}/visibility`,{method:"PATCH",body:JSON.stringify({visibility:t})},!0)}async function Iz(e){return P(`/datasets/${e}/publish`,{method:"POST"},!0)}async function Tz(e){return P(`/admin/datasets/${e}/ci`,{},!0)}async function Ai(e){return P(`/admin/datasets/${e}/ci`,{method:"POST"},!0)}async function aD(e){return P(`/admin/datasets/${e}/ci/validate`,{method:"POST"},!0)}async function cD(e){return P(`/admin/datasets/${e}/ci/sync`,{method:"POST"},!0)}async function Nz(e,t){return P(`/admin/datasets/${e}/doi/concept`,{method:"POST",body:JSON.stringify(t)},!0)}async function _d(e){return P(`/admin/datasets/${e}/doi`,{},!0)}async function uD(e,t){return P(`/admin/datasets/${e}/doi/update`,{method:"POST",body:JSON.stringify(t)},!0)}async function qz(e,t){return P(`/admin/datasets/${e}/withdraw`,{method:"POST",body:JSON.stringify({reason:t.reason,dry_run:t.dryRun})},!0)}async function jz(e,t){return P(`/admin/datasets/${e}/restore`,{method:"POST",body:JSON.stringify({dry_run:t.dryRun})},!0)}async function Mz(e){return P(`/admin/datasets/${e}/reset`,{method:"POST"},!0)}async function Bz(e,t=!1){return P(`/admin/datasets/${e}`,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({force:t})},!0)}async function Lz(e){return P("/admin/datasets/bulk-delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dataset_ids:e})},!0)}async function Uz(e){return P("/admin/datasets/import",{method:"POST",body:JSON.stringify(e)},!0)}async function Vz(e){return P("/admin/datasets/exemplar",{method:"POST",body:JSON.stringify(e)},!0)}async function zz(e){return P(`/admin/datasets/${e}/exemplar/remint-dois`,{method:"POST"},!0)}async function lD(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 Hz(e){return P(`/admin/imports/${e}/rollback`,{method:"POST"},!0)}async function Wz(e){return P(`/admin/imports/${e}/retry`,{method:"POST"},!0)}async function dD(e){return P(`/admin/imports/${e}/verify`,{method:"POST"},!0)}async function Gz(e){return P("/admin/imports/dispatch-cooldown",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dataset_ids:e})},!0)}async function qc(e,t){return P(`/admin/datasets/${e}/reindex`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t??{})},!0)}async function Kz(e,t){return P("/admin/datasets/reindex/bulk",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filter:e,...t??{}})},!0)}async function Yz(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 Jz(){return P("/admin/datasets/hed-sweep?reset=1",{method:"POST",headers:{"Content-Type":"application/json"}},!0)}async function Xz(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 Qz(){return P("/admin/datasets/data-integrity-sweep?reset=1",{method:"POST",headers:{"Content-Type":"application/json"}},!0)}async function Zz(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 eH(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 tH(){return P("/admin/datasets/availability-report-sweep?reset=1",{method:"POST",headers:{"Content-Type":"application/json"}},!0)}async function rH(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 jc(e,t){return P(`/admin/datasets/${e}/enforce`,{method:"POST",body:JSON.stringify({dry_run:t})},!0)}async function nH(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 iH(e,t=!1){return P(`/admin/datasets/${e}/revalidate${t?"?force=true":""}`,{method:"POST"},!0)}async function sH(e){let t=e?`?user=${encodeURIComponent(e)}`:"";return P(`/admin/email-preferences${t}`,{},!0)}async function oH(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 fD(e){return P("/admin/notify",{method:"POST",body:JSON.stringify(e)},!0)}async function aH(){return P("/admin/summary/coverage",{},!0)}async function cH(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 pD(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 mD(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 uH(){return P("/admin/zarr-catalog/publish",{method:"POST"},!0)}async function lH(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 Mc=A(()=>{Ns()});async function ti(e,t){return P(`/datasets/${e}/upload-credentials`,{method:"POST",body:JSON.stringify({duration_seconds:t})},!0)}async function hD(e,t){return P(`/datasets/${e}/download-credentials`,{method:"POST",body:JSON.stringify({duration_seconds:t})},!0)}async function dH(e){return P(`/admin/datasets/${e}/files`,{},!0)}async function fH(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 Bc=A(()=>{Ns();er()});function ZIe(e){return e.startsWith("v")?e:`v${e}`}var XIe,QIe,pH,mQe;var gD=A(()=>{Ic();XIe=/^v?\d+\.\d+\.\d+(?:-(?:rc|alpha|beta)\d*)?$/,QIe=/^v\d+\.\d+\.\d+(?:-(?:rc|alpha|beta)\d*)?$/;pH=E.string().regex(XIe,"must be a semver version, optionally v-prefixed").transform(ZIe),mQe=E.string().regex(QIe,"must be the canonical v-prefixed tag (vX.Y.Z)")});var eTe,tTe,mH;var hH=A(()=>{Ic();eTe=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(),tTe=E.object({prefix:E.string(),created_at:E.string(),last_used_at:E.string().nullable()}).passthrough().nullable(),mH=E.object({user:eTe,token:tTe.optional()}).passthrough()});function yH(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 xH(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 rTe="0.4.0",yD,Lc,gH,nTe,iTe,sTe,bH,vQe,vH,_Qe,ki,oTe,Am,DQe;var xD=A(()=>{Ic();gD();yD=E.enum(["openneuro","nemar","gin","other"]),Lc=E.union([E.literal(0),E.literal(1)]).nullable(),gH=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:Lc.optional(),hed_version:E.string().nullable().optional(),data_complete:Lc.optional(),bytes_present:E.number().nonnegative().nullable().optional(),latest_version:pH.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:Lc.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();nTe=gH.superRefine((e,t)=>{yH(e,t),xH(e,t)}),iTe=gH.extend({file_size:E.number().nonnegative().nullable(),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:Lc.optional(),attestation_no_duplicate:Lc.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)=>{yH(e,t),xH(e,t)}),sTe=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:Lc.optional(),score:E.number().optional(),snippet:E.string().optional()}).passthrough(),bH=E.record(E.string(),E.number().int().nonnegative()),vQe=E.object({datasets:E.array(nTe),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:bH.optional()}).passthrough(),vH=E.object({results:E.array(sTe),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:bH.optional()}).passthrough(),_Qe=E.object({dataset:iTe}).passthrough(),ki=E.object({value:E.string(),count:E.number().int().nonnegative()}),oTe=E.object({values:E.array(ki),distinct_total:E.number().int().nonnegative(),truncated:E.boolean()}),Am=E.object({"electrode-system":E.array(ki).optional(),source:E.array(ki).optional(),zarr:E.array(ki).optional(),powerline:E.array(ki).optional(),"bids-version":E.array(ki).optional(),"hed-version":E.array(ki).optional(),license:E.array(ki).optional(),modality:E.array(ki).optional(),task:oTe.optional(),warning:E.string().optional()}).passthrough(),DQe=E.object({schema_version:E.literal(rTe),doc_type:E.literal("dataset"),dataset_id:E.string().regex(/^[a-z]{2}\d+$/,"neuroschema dataset_id pattern"),name:E.string(),source:yD,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 km=A(()=>{gD();hH();xD()});async function Im(e){return P(`/datasets/${e}/ci/status`,{},!0)}async function _H(e){return P(`/datasets/${e}/manifest`,{},!0)}async function Tm(e,t){return P(`/datasets/${e}/manifest/${t}`,{},!0)}function DH(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 Uc(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(DH),n}async function wH(e){return P(`/datasets/resolve/${e}`,{},"optional")}async function EH(){return P("/datasets/facets",{signal:AbortSignal.timeout(5000)},"optional",Am)}async function SH(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",vH)}async function gt(e){let t=await P(`/datasets/${e}`,{},"optional");return DH(t.dataset)}async function $H(e){return P(`/datasets/${e}/versions`,{},!0)}async function Nm(e){return P("/datasets",{method:"POST",body:JSON.stringify(e)},!0)}async function qm(e){return P(`/datasets/${e}/finalize`,{method:"POST"},!0)}async function bD(e){return P(`/datasets/${e}/request-access`,{method:"POST"},!0)}async function CH(e,t){let r=t?`?status=${t}`:"";return P(`/datasets/${e}/access-requests${r}`,{},!0)}async function FH(e,t){return P(`/datasets/${e}/access-requests/${t}/approve`,{method:"POST"},!0)}async function RH(e,t){return P(`/datasets/${e}/access-requests/${t}/deny`,{method:"POST"},!0)}async function OH(e,t){return P(`/datasets/${e}/invite`,{method:"POST",body:JSON.stringify({username:t})},!0)}async function AH(e){return P(`/datasets/${e}/collaborators`,{},!0)}async function kH(e,t){return P(`/admin/datasets/${e}/enrichment`,{method:"POST",body:JSON.stringify(t)},!0)}var Pm;var qs=A(()=>{km();Ns();Pm=/^\d{4}-\d{4}-\d{4}-\d{3}[\dX]$/});var Vc;var qH=A(()=>{Vc=["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 zc(e){return P(`/datasets/${e}/publish/request`,{method:"POST"},!0)}async function MH(e){return P(`/datasets/${e}/publish/status`,{},!0)}async function BH(e){return P(`/datasets/${e}/publish/resend`,{method:"POST"},!0)}async function LH(e){let t=e?`?status=${e}`:"";return P(`/admin/publish/requests${t}`,{},!0)}async function UH(e,t){return P(`/admin/publish/${e}/deny`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({reason:t})},!0)}function aTe(e,t=[]){if(e){let r=Vc.indexOf(e);if(r>=0)return r+1}return Math.min(t.length+1,Vc.length)}function cTe(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 Hc(e,t=!1,r=!1,n=!1,i,s){let c,l,d=0,f=!1,m,p=t,g=[],y;function x(v,_,S,C){if(!s)return;s({step:v,stepIndex:aTe(v,_),stepTotal:Vc.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:l,skip_ci_check:n})},!0),S=!1,_.step_results)g.push(..._.step_results);if(_.s3_lock_total!==void 0)l=_.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"?l: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=jH(g);return _}catch(_){if(y=_,v===5||!cTe(_)){if(_ instanceof q&&g.length>0)_.stepResults=jH(g);throw _}let C=_;if(i?.({attempt:v,maxAttempts:5,delayMs:1e4,step:C.step,error:C.message}),await new Promise((D)=>setTimeout(D,1e4)),p=!0,c!==void 0)f=!0}throw y}function jH(e){let t=new Map;for(let r of e)t.set(r.step,r);return Array.from(t.values())}var Dd=A(()=>{qH();Ns();er()});function HH(e){DD=e}function wD(){return DD}function wd(e){if(DD)process.stderr.write(`${e}
106
106
  `)}var DD=!1;var WH={};ji(WH,{runCommand:()=>R});var{spawn:uTe}=globalThis.Bun;async function R(e,t={}){let r={...process.env,GIT_TERMINAL_PROMPT:"0",...t.env};for(let l of t.unsetEnv??[])delete r[l];let n=uTe({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(wD()){let l=t.cwd?` (cwd=${t.cwd})`:"";wd(u.dim(`$ ${e.join(" ")}${l}`))}let o=await new Response(n.stdout).text(),a=await new Response(n.stderr).text(),c=await n.exited;if(s)clearTimeout(s);if(wD()){if(o.trim())wd(u.dim(o.trimEnd()));if(a.trim())wd(u.yellow(a.trimEnd()));wd(u.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 Ut=A(()=>{He()});async function lTe(){try{let{exitCode:e,stderr:t}=await R(["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 Ed(){try{let{stdout:e,exitCode:t,stderr:r}=await R(["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 jm(e){try{let{stdout:t,exitCode:r,stderr:n}=await R(["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 Mm(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 R(["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((l)=>l.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 R(["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 R(["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 ri(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 R(["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 Ed();if(s.token)n=`https://github.com/${i}`,await R(["git","config","credential.https://github.com.helper",`!printf 'username=x-access-token\\npassword=${s.token}'`],{cwd:e});else{let o=await lTe();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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nemar-cli",
3
- "version": "0.9.14-dev.2230",
3
+ "version": "0.9.14",
4
4
  "description": "CLI for NEMAR (Neuroelectromagnetic Data Archive and Tools Resource) dataset management",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",