nemar-cli 0.9.11-dev.2155 → 0.9.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -97,12 +97,12 @@ ${t}`,gbe,ybe,xbe=(e,t,r)=>{let n=r===""?"":`with ${r.trim()}() `,i=hbe.bind(nul
|
|
|
97
97
|
depsCount: ${t},
|
|
98
98
|
deps: ${r}}`};var BAe={keyword:"dependencies",type:"object",schemaType:"object",error:JB.error,code(e){let[t,r]=LAe(e);KB(e,t),YB(e,r)}};function LAe({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,Zl.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,Zl.checkReportMissingProp)(e,l)});else r.if(w_._`${c} && (${(0,Zl.checkMissingProp)(e,a,s)})`),(0,Zl.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,MAe.alwaysValidSchema)(s,t[a]))continue;r.if((0,Zl.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=BAe});var rL=h(function(tL){Object.defineProperty(tL,"__esModule",{value:!0});var eL=me(),zAe=Pe(),HAe={message:"property name must be valid",params:({params:e})=>eL._`{propertyName: ${e.propertyName}}`},WAe={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:HAe,code(e){let{gen:t,schema:r,data:n,it:i}=e;if((0,zAe.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=WAe});var E_=h(function(nL){Object.defineProperty(nL,"__esModule",{value:!0});var X0=zr(),hn=me(),KAe=Si(),Q0=Pe(),YAe={message:"must NOT have additional properties",params:({params:e})=>hn._`{additionalProperty: ${e.additionalProperty}}`},JAe={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:YAe,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} === ${KAe.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 E={keyword:"additionalProperties",dataProp:x,dataPropType:Q0.Type.Str};if(_===!1)Object.assign(E,{compositeRule:!0,createErrors:!1,allErrors:!1});e.subschema(E,v)}}};nL.default=JAe});var aL=h(function(oL){Object.defineProperty(oL,"__esModule",{value:!0});var QAe=Ul(),iL=zr(),S_=Pe(),sL=E_(),ZAe={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 QAe.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=ZAe});var fL=h(function(dL){Object.defineProperty(dL,"__esModule",{value:!0});var cL=zr(),Z0=me(),uL=Pe(),lL=Pe(),tke={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=tke});var mL=h(function(pL){Object.defineProperty(pL,"__esModule",{value:!0});var nke=Pe(),ike={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(e){let{gen:t,schema:r,it:n}=e;if((0,nke.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=ike});var gL=h(function(hL){Object.defineProperty(hL,"__esModule",{value:!0});var oke=zr(),ake={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:oke.validateUnion,error:{message:"must match a schema in anyOf"}};hL.default=ake});var xL=h(function(yL){Object.defineProperty(yL,"__esModule",{value:!0});var em=me(),uke=Pe(),lke={message:"must match exactly one schema in oneOf",params:({params:e})=>em._`{passingSchemas: ${e.passing}}`},dke={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:lke,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,uke.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=dke});var vL=h(function(bL){Object.defineProperty(bL,"__esModule",{value:!0});var pke=Pe(),mke={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,pke.alwaysValidSchema)(n,s))return;let a=e.subschema({keyword:"allOf",schemaProp:o},i);e.ok(i),e.mergeEvaluated(a)})}};bL.default=mke});var EL=h(function(wL){Object.defineProperty(wL,"__esModule",{value:!0});var tm=me(),DL=Pe(),gke={message:({params:e})=>tm.str`must match "${e.ifClause}" schema`,params:({params:e})=>tm._`{failingKeyword: ${e.ifClause}}`},yke={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:gke,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=yke});var $L=h(function(SL){Object.defineProperty(SL,"__esModule",{value:!0});var bke=Pe(),vke={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:e,parentSchema:t,it:r}){if(t.if===void 0)(0,bke.checkStrictMode)(r,`"${e}" without "if" is ignored`)}};SL.default=vke});var FL=h(function(CL){Object.defineProperty(CL,"__esModule",{value:!0});var Dke=__(),wke=UB(),Eke=D_(),Ske=HB(),$ke=GB(),Cke=ZB(),Fke=rL(),Rke=E_(),Oke=aL(),Ake=fL(),kke=mL(),Pke=gL(),Ike=xL(),Tke=vL(),Nke=EL(),qke=$L();function jke(e=!1){let t=[kke.default,Pke.default,Ike.default,Tke.default,Nke.default,qke.default,Fke.default,Rke.default,Cke.default,Oke.default,Ake.default];if(e)t.push(wke.default,Ske.default);else t.push(Dke.default,Eke.default);return t.push($ke.default),t}CL.default=jke});var OL=h(function(RL){Object.defineProperty(RL,"__esModule",{value:!0});var mt=me(),Bke={message:({schemaCode:e})=>mt.str`must match format "${e}"`,params:({schemaCode:e})=>mt._`{format: ${e}}`},Lke={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:Bke,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)(_(),E()));function _(){if(c.strictSchema===!1)return mt.nil;return mt._`${o} && !${v}`}function E(){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]=E(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 E(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=Lke});var kL=h(function(AL){Object.defineProperty(AL,"__esModule",{value:!0});var Vke=OL(),zke=[Vke.default];AL.default=zke});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 Gke=oB(),Kke=PB(),Yke=FL(),Jke=kL(),NL=TL(),Xke=[Gke.default,Kke.default,(0,Yke.default)(),Jke.default,NL.metadataVocabulary,NL.contentVocabulary];qL.default=Xke});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(),Zke=Vl(),ePe=Pe(),tPe={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}}`},rPe={keyword:"discriminator",type:"object",schemaType:"object",error:tPe,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,ePe.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 Zke.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)E(C.const,D);else if(C.enum)for(let O of C.enum)E(O,D);else throw Error(`discriminator: "properties/${a}" must have "const" or "enum"`)}function E(C,D){if(typeof C!="string"||C in g)throw Error(`discriminator: "${a}" values must be unique strings`);g[C]=D}}}};zL.default=rPe});var WL=h(function(YYe,iPe){iPe.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 sPe=JM(),oPe=jL(),aPe=HL(),GL=WL(),cPe=["/properties"],rm="http://json-schema.org/draft-07/schema";class ed extends sPe.default{_addVocabularies(){if(super._addVocabularies(),oPe.default.forEach((e)=>this.addVocabulary(e)),this.opts.discriminator)this.addKeyword(aPe.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let e=this.opts.$data?this.$dataMetaSchema(GL,cPe):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=ed;C_.exports=yr=ed;C_.exports.Ajv=ed;Object.defineProperty(yr,"__esModule",{value:!0});yr.default=ed;var uPe=Ul();Object.defineProperty(yr,"KeywordCxt",{enumerable:!0,get:function(){return uPe.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 lPe=j0();Object.defineProperty(yr,"ValidationError",{enumerable:!0,get:function(){return lPe.default}});var dPe=Vl();Object.defineProperty(yr,"MissingRefError",{enumerable:!0,get:function(){return dPe.default}})});var JL=h(function(YL){Object.defineProperty(YL,"__esModule",{value:!0});YL.formatLimitDefinition=void 0;var mPe=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}},hPe={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:hPe,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 mPe.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 gPe=(e)=>(e.addKeyword(YL.formatLimitDefinition),e);YL.default=gPe});var eU=h(function(td,ZL){Object.defineProperty(td,"__esModule",{value:!0});var gc=Kq(),xPe=JL(),R_=me(),XL=new R_.Name("fullFormats"),bPe=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,bPe]:[gc.fullFormats,XL],i=t.formats||gc.formatNames;if(QL(e,i,r,n),t.keywords)(0,xPe.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=td=O_;Object.defineProperty(td,"__esModule",{value:!0});td.default=O_});var vPe=(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 nl(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_=vPe});var rd=h(function(aJe,rU){var _Pe=Number.MAX_SAFE_INTEGER||9007199254740991,DPe=["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:_Pe,RELEASE_TYPES:DPe,SEMVER_SPEC_VERSION:"2.0.0",FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2}});var nd=h(function(cJe,nU){var wPe=typeof process==="object"&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...e)=>console.error("SEMVER",...e):()=>{};nU.exports=wPe});var yc=h(function(Xn,iU){var{MAX_SAFE_COMPONENT_LENGTH:k_,MAX_SAFE_BUILD_LENGTH:EPe,MAX_LENGTH:SPe}=rd(),$Pe=nd();Xn=iU.exports={};var CPe=Xn.re=[],FPe=Xn.safeRe=[],z=Xn.src=[],RPe=Xn.safeSrc=[],H=Xn.t={},OPe=0,P_="[a-zA-Z0-9-]",APe=[["\\s",1],["\\d",SPe],[P_,EPe]],kPe=(e)=>{for(let[t,r]of APe)e=e.split(`${t}*`).join(`${t}{0,${r}}`).split(`${t}+`).join(`${t}{1,${r}}`);return e},se=(e,t,r)=>{let n=kPe(t),i=OPe++;$Pe(e,i,t),H[e]=i,z[i]=t,RPe[i]=n,CPe[i]=new RegExp(t,r?"g":void 0),FPe[i]=new RegExp(n,r?"g":void 0)};se("NUMERICIDENTIFIER","0|[1-9]\\d*");se("NUMERICIDENTIFIERLOOSE","\\d+");se("NONNUMERICIDENTIFIER",`\\d*[a-zA-Z-]${P_}*`);se("MAINVERSION",`(${z[H.NUMERICIDENTIFIER]})\\.(${z[H.NUMERICIDENTIFIER]})\\.(${z[H.NUMERICIDENTIFIER]})`);se("MAINVERSIONLOOSE",`(${z[H.NUMERICIDENTIFIERLOOSE]})\\.(${z[H.NUMERICIDENTIFIERLOOSE]})\\.(${z[H.NUMERICIDENTIFIERLOOSE]})`);se("PRERELEASEIDENTIFIER",`(?:${z[H.NONNUMERICIDENTIFIER]}|${z[H.NUMERICIDENTIFIER]})`);se("PRERELEASEIDENTIFIERLOOSE",`(?:${z[H.NONNUMERICIDENTIFIER]}|${z[H.NUMERICIDENTIFIERLOOSE]})`);se("PRERELEASE",`(?:-(${z[H.PRERELEASEIDENTIFIER]}(?:\\.${z[H.PRERELEASEIDENTIFIER]})*))`);se("PRERELEASELOOSE",`(?:-?(${z[H.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${z[H.PRERELEASEIDENTIFIERLOOSE]})*))`);se("BUILDIDENTIFIER",`${P_}+`);se("BUILD",`(?:\\+(${z[H.BUILDIDENTIFIER]}(?:\\.${z[H.BUILDIDENTIFIER]})*))`);se("FULLPLAIN",`v?${z[H.MAINVERSION]}${z[H.PRERELEASE]}?${z[H.BUILD]}?`);se("FULL",`^${z[H.FULLPLAIN]}$`);se("LOOSEPLAIN",`[v=\\s]*${z[H.MAINVERSIONLOOSE]}${z[H.PRERELEASELOOSE]}?${z[H.BUILD]}?`);se("LOOSE",`^${z[H.LOOSEPLAIN]}$`);se("GTLT","((?:<|>)?=?)");se("XRANGEIDENTIFIERLOOSE",`${z[H.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);se("XRANGEIDENTIFIER",`${z[H.NUMERICIDENTIFIER]}|x|X|\\*`);se("XRANGEPLAIN",`[v=\\s]*(${z[H.XRANGEIDENTIFIER]})(?:\\.(${z[H.XRANGEIDENTIFIER]})(?:\\.(${z[H.XRANGEIDENTIFIER]})(?:${z[H.PRERELEASE]})?${z[H.BUILD]}?)?)?`);se("XRANGEPLAINLOOSE",`[v=\\s]*(${z[H.XRANGEIDENTIFIERLOOSE]})(?:\\.(${z[H.XRANGEIDENTIFIERLOOSE]})(?:\\.(${z[H.XRANGEIDENTIFIERLOOSE]})(?:${z[H.PRERELEASELOOSE]})?${z[H.BUILD]}?)?)?`);se("XRANGE",`^${z[H.GTLT]}\\s*${z[H.XRANGEPLAIN]}$`);se("XRANGELOOSE",`^${z[H.GTLT]}\\s*${z[H.XRANGEPLAINLOOSE]}$`);se("COERCEPLAIN",`(^|[^\\d])(\\d{1,${k_}})(?:\\.(\\d{1,${k_}}))?(?:\\.(\\d{1,${k_}}))?`);se("COERCE",`${z[H.COERCEPLAIN]}(?:$|[^\\d])`);se("COERCEFULL",z[H.COERCEPLAIN]+`(?:${z[H.PRERELEASE]})?(?:${z[H.BUILD]})?(?:$|[^\\d])`);se("COERCERTL",z[H.COERCE],!0);se("COERCERTLFULL",z[H.COERCEFULL],!0);se("LONETILDE","(?:~>?)");se("TILDETRIM",`(\\s*)${z[H.LONETILDE]}\\s+`,!0);Xn.tildeTrimReplace="$1~";se("TILDE",`^${z[H.LONETILDE]}${z[H.XRANGEPLAIN]}$`);se("TILDELOOSE",`^${z[H.LONETILDE]}${z[H.XRANGEPLAINLOOSE]}$`);se("LONECARET","(?:\\^)");se("CARETTRIM",`(\\s*)${z[H.LONECARET]}\\s+`,!0);Xn.caretTrimReplace="$1^";se("CARET",`^${z[H.LONECARET]}${z[H.XRANGEPLAIN]}$`);se("CARETLOOSE",`^${z[H.LONECARET]}${z[H.XRANGEPLAINLOOSE]}$`);se("COMPARATORLOOSE",`^${z[H.GTLT]}\\s*(${z[H.LOOSEPLAIN]})$|^$`);se("COMPARATOR",`^${z[H.GTLT]}\\s*(${z[H.FULLPLAIN]})$|^$`);se("COMPARATORTRIM",`(\\s*)${z[H.GTLT]}\\s*(${z[H.LOOSEPLAIN]}|${z[H.XRANGEPLAIN]})`,!0);Xn.comparatorTrimReplace="$1$2$3";se("HYPHENRANGE",`^\\s*(${z[H.XRANGEPLAIN]})\\s+-\\s+(${z[H.XRANGEPLAIN]})\\s*$`);se("HYPHENRANGELOOSE",`^\\s*(${z[H.XRANGEPLAINLOOSE]})\\s+-\\s+(${z[H.XRANGEPLAINLOOSE]})\\s*$`);se("STAR","(<|>)?=?\\s*\\*");se("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$");se("GTE0PRE","^\\s*>=\\s*0\\.0\\.0-0\\s*$")});var im=h(function(uJe,sU){var PPe=Object.freeze({loose:!0}),IPe=Object.freeze({}),TPe=(e)=>{if(!e)return IPe;if(typeof e!=="object")return PPe;return e};sU.exports=TPe});var I_=h(function(lJe,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},NPe=(e,t)=>aU(t,e);cU.exports={compareIdentifiers:aU,rcompareIdentifiers:NPe}});var Mt=h(function(dJe,lU){var sm=nd(),{MAX_LENGTH:uU,MAX_SAFE_INTEGER:om}=rd(),{safeRe:am,t:cm}=yc(),qPe=im(),{compareIdentifiers:T_}=I_();class yn{constructor(e,t){if(t=qPe(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(fJe,fU){var dU=Mt(),jPe=(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=jPe});var mU=h(function(pJe,pU){var MPe=$o(),BPe=(e,t)=>{let r=MPe(e,t);return r?r.version:null};pU.exports=BPe});var gU=h(function(mJe,hU){var LPe=$o(),UPe=(e,t)=>{let r=LPe(e.trim().replace(/^[=v]+/,""),t);return r?r.version:null};hU.exports=UPe});var bU=h(function(hJe,xU){var yU=Mt(),VPe=(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=VPe});var DU=h(function(gJe,_U){var vU=$o(),zPe=(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=zPe});var EU=h(function(yJe,wU){var HPe=Mt(),WPe=(e,t)=>new HPe(e,t).major;wU.exports=WPe});var $U=h(function(xJe,SU){var GPe=Mt(),KPe=(e,t)=>new GPe(e,t).minor;SU.exports=KPe});var FU=h(function(bJe,CU){var YPe=Mt(),JPe=(e,t)=>new YPe(e,t).patch;CU.exports=JPe});var OU=h(function(vJe,RU){var XPe=$o(),QPe=(e,t)=>{let r=XPe(e,t);return r&&r.prerelease.length?r.prerelease:null};RU.exports=QPe});var Wr=h(function(_Je,kU){var AU=Mt(),ZPe=(e,t,r)=>new AU(e,r).compare(new AU(t,r));kU.exports=ZPe});var IU=h(function(DJe,PU){var e8e=Wr(),t8e=(e,t,r)=>e8e(t,e,r);PU.exports=t8e});var NU=h(function(wJe,TU){var r8e=Wr(),n8e=(e,t)=>r8e(e,t,!0);TU.exports=n8e});var um=h(function(EJe,jU){var qU=Mt(),i8e=(e,t,r)=>{let n=new qU(e,r),i=new qU(t,r);return n.compare(i)||n.compareBuild(i)};jU.exports=i8e});var BU=h(function(SJe,MU){var s8e=um(),o8e=(e,t)=>e.sort((r,n)=>s8e(r,n,t));MU.exports=o8e});var UU=h(function($Je,LU){var a8e=um(),c8e=(e,t)=>e.sort((r,n)=>a8e(n,r,t));LU.exports=c8e});var id=h(function(CJe,VU){var u8e=Wr(),l8e=(e,t,r)=>u8e(e,t,r)>0;VU.exports=l8e});var lm=h(function(FJe,zU){var d8e=Wr(),f8e=(e,t,r)=>d8e(e,t,r)<0;zU.exports=f8e});var N_=h(function(RJe,HU){var p8e=Wr(),m8e=(e,t,r)=>p8e(e,t,r)===0;HU.exports=m8e});var q_=h(function(OJe,WU){var h8e=Wr(),g8e=(e,t,r)=>h8e(e,t,r)!==0;WU.exports=g8e});var dm=h(function(AJe,GU){var y8e=Wr(),x8e=(e,t,r)=>y8e(e,t,r)>=0;GU.exports=x8e});var fm=h(function(kJe,KU){var b8e=Wr(),v8e=(e,t,r)=>b8e(e,t,r)<=0;KU.exports=v8e});var j_=h(function(PJe,YU){var _8e=N_(),D8e=q_(),w8e=id(),E8e=dm(),S8e=lm(),$8e=fm(),C8e=(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 _8e(e,r,n);case"!=":return D8e(e,r,n);case">":return w8e(e,r,n);case">=":return E8e(e,r,n);case"<":return S8e(e,r,n);case"<=":return $8e(e,r,n);default:throw TypeError(`Invalid operator: ${t}`)}};YU.exports=C8e});var XU=h(function(IJe,JU){var F8e=Mt(),R8e=$o(),{safeRe:pm,t:mm}=yc(),O8e=(e,t)=>{if(e instanceof F8e)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 R8e(`${n}.${i}.${s}${o}${a}`,t)};JU.exports=O8e});var eV=h(function(TJe,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(NJe,iV){var A8e=/\s+/g;class sd{constructor(e,t){if(t=P8e(t),e instanceof sd)if(e.loose===!!t.loose&&e.includePrerelease===!!t.includePrerelease)return e;else return new sd(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(A8e," "),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&&B8e(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&&j8e)|(this.options.loose&&M8e))+":"+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,J8e(this.options.includePrerelease)),Qe("hyphen replace",e),e=e.replace(Qt[Bt.COMPARATORTRIM],T8e),Qe("comparator trim",e),e=e.replace(Qt[Bt.TILDETRIM],N8e),Qe("tilde trim",e),e=e.replace(Qt[Bt.CARETTRIM],q8e),Qe("caret trim",e);let o=e.split(" ").map((d)=>L8e(d,this.options)).join(" ").split(/\s+/).map((d)=>Y8e(d,this.options));if(i)o=o.filter((d)=>(Qe("loose invalid filter",d,this.options),!!d.match(Qt[Bt.COMPARATORLOOSE])));Qe("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 sd))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 I8e(e,this.options)}catch(t){return!1}for(let t=0;t<this.set.length;t++)if(X8e(this.set[t],e,this.options))return!0;return!1}}iV.exports=sd;var k8e=eV(),tV=new k8e,P8e=im(),M_=od(),Qe=nd(),I8e=Mt(),{safeRe:Qt,t:Bt,comparatorTrimReplace:T8e,tildeTrimReplace:N8e,caretTrimReplace:q8e}=yc(),{FLAG_INCLUDE_PRERELEASE:j8e,FLAG_LOOSE:M8e}=rd(),rV=(e)=>e.value==="<0.0.0-0",B8e=(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},L8e=(e,t)=>(e=e.replace(Qt[Bt.BUILD],""),Qe("comp",e,t),e=z8e(e,t),Qe("caret",e),e=U8e(e,t),Qe("tildes",e),e=W8e(e,t),Qe("xrange",e),e=K8e(e,t),Qe("stars",e),e),Zt=(e)=>!e||e.toLowerCase()==="x"||e==="*",U8e=(e,t)=>e.trim().split(/\s+/).map((r)=>V8e(r,t)).join(" "),V8e=(e,t)=>{let r=t.loose?Qt[Bt.TILDELOOSE]:Qt[Bt.TILDE];return e.replace(r,(n,i,s,o,a)=>{Qe("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)Qe("replaceTilde pr",a),c=`>=${i}.${s}.${o}-${a} <${i}.${+s+1}.0-0`;else c=`>=${i}.${s}.${o} <${i}.${+s+1}.0-0`;return Qe("tilde return",c),c})},z8e=(e,t)=>e.trim().split(/\s+/).map((r)=>H8e(r,t)).join(" "),H8e=(e,t)=>{Qe("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)=>{Qe("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(Qe("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(Qe("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 Qe("caret return",l),l})},W8e=(e,t)=>(Qe("replaceXRanges",e,t),e.split(/\s+/).map((r)=>G8e(r,t)).join(" ")),G8e=(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)=>{Qe("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 Qe("xRange return",n),n})},K8e=(e,t)=>(Qe("replaceStars",e,t),e.trim().replace(Qt[Bt.STAR],"")),Y8e=(e,t)=>(Qe("replaceGTE0",e,t),e.trim().replace(Qt[t.includePrerelease?Bt.GTE0PRE:Bt.GTE0],"")),J8e=(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()},X8e=(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(Qe(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 od=h(function(qJe,lV){var ad=Symbol("SemVer ANY");class hm{static get ANY(){return ad}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===ad)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=ad;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===ad||e===ad)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_=nd(),cV=Mt(),uV=Gr()});var cd=h(function(jJe,dV){var Q8e=Gr(),Z8e=(e,t,r)=>{try{t=new Q8e(t,r)}catch(n){return!1}return t.test(e)};dV.exports=Z8e});var pV=h(function(MJe,fV){var e4e=Gr(),t4e=(e,t)=>new e4e(e,t).set.map((r)=>r.map((n)=>n.value).join(" ").trim().split(" "));fV.exports=t4e});var hV=h(function(BJe,mV){var r4e=Mt(),n4e=Gr(),i4e=(e,t,r)=>{let n=null,i=null,s=null;try{s=new n4e(t,r)}catch(o){return null}return e.forEach((o)=>{if(s.test(o)){if(!n||i.compare(o)===-1)n=o,i=new r4e(n,r)}}),n};mV.exports=i4e});var yV=h(function(LJe,gV){var s4e=Mt(),o4e=Gr(),a4e=(e,t,r)=>{let n=null,i=null,s=null;try{s=new o4e(t,r)}catch(o){return null}return e.forEach((o)=>{if(s.test(o)){if(!n||i.compare(o)===1)n=o,i=new s4e(n,r)}}),n};gV.exports=a4e});var vV=h(function(UJe,bV){var U_=Mt(),c4e=Gr(),xV=id(),u4e=(e,t)=>{e=new c4e(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=u4e});var DV=h(function(VJe,_V){var l4e=Gr(),d4e=(e,t)=>{try{return new l4e(e,t).range||"*"}catch(r){return null}};_V.exports=d4e});var gm=h(function(zJe,$V){var f4e=Mt(),SV=od(),{ANY:p4e}=SV,m4e=Gr(),h4e=cd(),wV=id(),EV=lm(),g4e=fm(),y4e=dm(),x4e=(e,t,r,n)=>{e=new f4e(e,n),t=new m4e(t,n);let i,s,o,a,c;switch(r){case">":i=wV,s=g4e,o=EV,a=">",c=">=";break;case"<":i=EV,s=y4e,o=wV,a="<",c="<=";break;default:throw TypeError('Must provide a hilo val of "<" or ">"')}if(h4e(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===p4e)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=x4e});var FV=h(function(HJe,CV){var b4e=gm(),v4e=(e,t,r)=>b4e(e,t,">",r);CV.exports=v4e});var OV=h(function(WJe,RV){var _4e=gm(),D4e=(e,t,r)=>_4e(e,t,"<",r);RV.exports=D4e});var PV=h(function(GJe,kV){var AV=Gr(),w4e=(e,t,r)=>(e=new AV(e,r),t=new AV(t,r),e.intersects(t,r));kV.exports=w4e});var TV=h(function(KJe,IV){var E4e=cd(),S4e=Wr();IV.exports=(e,t,r)=>{let n=[],i=null,s=null,o=e.sort((d,f)=>S4e(d,f,r));for(let d of o)if(E4e(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(YJe,BV){var NV=Gr(),z_=od(),{ANY:V_}=z_,ud=cd(),H_=Wr(),$4e=(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=F4e(i,s,r);if(n=n||o!==null,o)continue e}if(n)return!1}return!0},C4e=[new z_(">=0.0.0-0")],qV=[new z_(">=0.0.0")],F4e=(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=C4e;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&&!ud(p,String(i),r))return null;if(s&&!ud(p,String(s),r))return null;for(let g of t)if(!ud(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===">="&&!ud(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==="<="&&!ud(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=$4e});var HV=h(function(JJe,zV){var W_=yc(),UV=rd(),R4e=Mt(),VV=I_(),O4e=$o(),A4e=mU(),k4e=gU(),P4e=bU(),I4e=DU(),T4e=EU(),N4e=$U(),q4e=FU(),j4e=OU(),M4e=Wr(),B4e=IU(),L4e=NU(),U4e=um(),V4e=BU(),z4e=UU(),H4e=id(),W4e=lm(),G4e=N_(),K4e=q_(),Y4e=dm(),J4e=fm(),X4e=j_(),Q4e=XU(),Z4e=od(),e3e=Gr(),t3e=cd(),r3e=pV(),n3e=hV(),i3e=yV(),s3e=vV(),o3e=DV(),a3e=gm(),c3e=FV(),u3e=OV(),l3e=PV(),d3e=TV(),f3e=LV();zV.exports={parse:O4e,valid:A4e,clean:k4e,inc:P4e,diff:I4e,major:T4e,minor:N4e,patch:q4e,prerelease:j4e,compare:M4e,rcompare:B4e,compareLoose:L4e,compareBuild:U4e,sort:V4e,rsort:z4e,gt:H4e,lt:W4e,eq:G4e,neq:K4e,gte:Y4e,lte:J4e,cmp:X4e,coerce:Q4e,Comparator:Z4e,Range:e3e,satisfies:t3e,toComparators:r3e,maxSatisfying:n3e,minSatisfying:i3e,minVersion:s3e,validRange:o3e,outside:a3e,gtr:c3e,ltr:u3e,intersects:l3e,simplifyRange:d3e,subset:f3e,SemVer:R4e,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 p3e.call(e)===r}function KV(e){return GV(e,Uint8Array,"[object Uint8Array]")}function m3e(e){return GV(e,ArrayBuffer,"[object ArrayBuffer]")}function h3e(e){return KV(e)||m3e(e)}function g3e(e){if(!KV(e))throw TypeError(`Expected \`Uint8Array\`, got \`${typeof e}\``)}function y3e(e){if(!h3e(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)g3e(i),r.set(i,n),n+=i.length;return r}function K_(e,t="utf8"){return y3e(e),WV[t]??=new globalThis.TextDecoder(t),WV[t].decode(e)}function x3e(e){if(typeof e!=="string")throw TypeError(`Expected \`string\`, got \`${typeof e}\``)}function ym(e){return x3e(e),b3e.encode(e)}var p3e,WV,b3e,XJe;var YV=A(()=>{p3e=Object.prototype.toString;WV={utf8:new globalThis.TextDecoder("utf8")};b3e=new globalThis.TextEncoder;XJe=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"))});import{isDeepStrictEqual as v3e}from"util";import JV from"process";import Co from"fs";import XV from"path";import ld from"crypto";import _3e from"assert";var ZV,ez,Fo,D3e,QV="aes-256-cbc",xc=()=>Object.create(null),w3e=(e)=>e!==void 0&&e!==null,E3e=(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),D3e=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});D3e(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{_3e.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(E3e(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(w3e(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=ld.pbkdf2Sync(this.#t,t.toString(),1e4,32,"sha512"),n=ld.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(v3e(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=ld.randomBytes(16),n=ld.pbkdf2Sync(this.#t,r.toString(),1e4,32,"sha512"),i=ld.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 be,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 dd=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}})(be||(be={}));(function(e){e.mergeShapes=(t,r)=>({...t,...r})})(J_||(J_={}));N=be.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"])});var P,S3e=(e)=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:"),xr;var vm=A(()=>{dd();P=be.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,be.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 $3e=(e,t)=>{let r;switch(e.code){case P.invalid_type:if(e.received===N.undefined)r="Required";else r=`Expected ${e.expected}, received ${e.received}`;break;case P.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(e.expected,be.jsonStringifyReplacer)}`;break;case P.unrecognized_keys:r=`Unrecognized key(s) in object: ${be.joinValues(e.keys,", ")}`;break;case P.invalid_union:r="Invalid input";break;case P.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${be.joinValues(e.options)}`;break;case P.invalid_enum_value:r=`Invalid enum value. Expected ${be.joinValues(e.options)}, received '${e.received}'`;break;case P.invalid_arguments:r="Invalid function arguments";break;case P.invalid_return_type:r="Invalid function return type";break;case P.invalid_date:r="Invalid date";break;case P.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 be.assertNever(e.validation);else if(e.validation!=="regex")r=`Invalid ${e.validation}`;else r="Invalid";break;case P.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 P.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 P.custom:r="Invalid input";break;case P.invalid_intersection_types:r="Intersection results could not be merged";break;case P.not_multiple_of:r=`Number must be a multiple of ${e.multipleOf}`;break;case P.not_finite:r="Number must be finite";break;default:r=t.defaultError,be.assertNever(e)}return{message:r}},Fi;var X_=A(()=>{vm();dd();Fi=$3e});function C3e(e){rz=e}function bc(){return rz}var rz;var _m=A(()=>{X_();rz=Fi});function L(e,t){let r=bc(),n=fd({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 fd=(e)=>{let{data:t,path:r,errorMaps:n,issueData:i}=e,s=[...r,...i.path||[]],o={...i,path:s};if(i.message!==void 0)return{...i,path:s,message:i.message};let a="",c=n.filter((l)=>!!l).slice().reverse();for(let l of c)a=l(o,{data:t,defaultError:a}).message;return{...i,path:s,message:a}},F3e,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_();F3e=[];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:P.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 xd.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 H3e(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 W3e(e,t){if((t==="v4"||!t)&&j3e.test(e))return!0;if((t==="v6"||!t)&&B3e.test(e))return!0;return!1}function G3e(e,t){if(!I3e.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 K3e(e,t){if((t==="v4"||!t)&&M3e.test(e))return!0;if((t==="v6"||!t)&&L3e.test(e))return!0;return!1}function Y3e(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=be.objectKeys(t),s=be.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}}}},R3e,O3e,A3e,k3e,P3e,I3e,T3e,N3e,q3e="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",Z_,j3e,M3e,B3e,L3e,U3e,V3e,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])))",z3e,xn,ks,Ps,wc,Oo,pd,Ec,Sc,Ao,As,Zn,md,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 be.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,hd,gd,ko,Dc,Fc,Rc,Is,Oc,Po,Dn,vn,Oi,Ac,kc,yd,J3e,Sm,xd,Pc,X3e,ee,Q3e=(e,t={message:`Input not instance of ${e.name}`})=>dz((r)=>r instanceof e,t),fz,pz,Z3e,eIe,mz,tIe,rIe,nIe,iIe,sIe,oIe,aIe,cIe,uIe,lIe,dIe,fIe,pIe,mIe,hIe,gIe,yIe,xIe,bIe,vIe,_Ie,DIe,wIe,EIe,SIe,$Ie,CIe,FIe,RIe,OIe=()=>fz().optional(),AIe=()=>pz().optional(),kIe=()=>mz().optional(),PIe,IIe;var hz=A(()=>{vm();_m();iz();Q_();dd();R3e=/^c[^\s-]{8,}$/i,O3e=/^[0-9a-z]+$/,A3e=/^[0-9A-HJKMNP-TV-Z]{26}$/i,k3e=/^[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,P3e=/^[a-z0-9_-]{21}$/i,I3e=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,T3e=/^[-+]?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)?)??$/,N3e=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,j3e=/^(?:(?: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])$/,M3e=/^(?:(?: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])$/,B3e=/^(([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]))$/,L3e=/^(([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])$/,U3e=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,V3e=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,z3e=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:P.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:P.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:P.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:P.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message});else if(o)L(n,{code:P.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message});r.dirty()}}else if(i.kind==="email"){if(!N3e.test(e.data))n=this._getOrReturnCtx(e,n),L(n,{validation:"email",code:P.invalid_string,message:i.message}),r.dirty()}else if(i.kind==="emoji"){if(!Z_)Z_=new RegExp(q3e,"u");if(!Z_.test(e.data))n=this._getOrReturnCtx(e,n),L(n,{validation:"emoji",code:P.invalid_string,message:i.message}),r.dirty()}else if(i.kind==="uuid"){if(!k3e.test(e.data))n=this._getOrReturnCtx(e,n),L(n,{validation:"uuid",code:P.invalid_string,message:i.message}),r.dirty()}else if(i.kind==="nanoid"){if(!P3e.test(e.data))n=this._getOrReturnCtx(e,n),L(n,{validation:"nanoid",code:P.invalid_string,message:i.message}),r.dirty()}else if(i.kind==="cuid"){if(!R3e.test(e.data))n=this._getOrReturnCtx(e,n),L(n,{validation:"cuid",code:P.invalid_string,message:i.message}),r.dirty()}else if(i.kind==="cuid2"){if(!O3e.test(e.data))n=this._getOrReturnCtx(e,n),L(n,{validation:"cuid2",code:P.invalid_string,message:i.message}),r.dirty()}else if(i.kind==="ulid"){if(!A3e.test(e.data))n=this._getOrReturnCtx(e,n),L(n,{validation:"ulid",code:P.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:P.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:P.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:P.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:P.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:P.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:P.invalid_string,validation:"datetime",message:i.message}),r.dirty()}else if(i.kind==="date"){if(!z3e.test(e.data))n=this._getOrReturnCtx(e,n),L(n,{code:P.invalid_string,validation:"date",message:i.message}),r.dirty()}else if(i.kind==="time"){if(!H3e(i).test(e.data))n=this._getOrReturnCtx(e,n),L(n,{code:P.invalid_string,validation:"time",message:i.message}),r.dirty()}else if(i.kind==="duration"){if(!T3e.test(e.data))n=this._getOrReturnCtx(e,n),L(n,{validation:"duration",code:P.invalid_string,message:i.message}),r.dirty()}else if(i.kind==="ip"){if(!W3e(e.data,i.version))n=this._getOrReturnCtx(e,n),L(n,{validation:"ip",code:P.invalid_string,message:i.message}),r.dirty()}else if(i.kind==="jwt"){if(!G3e(e.data,i.alg))n=this._getOrReturnCtx(e,n),L(n,{validation:"jwt",code:P.invalid_string,message:i.message}),r.dirty()}else if(i.kind==="cidr"){if(!K3e(e.data,i.version))n=this._getOrReturnCtx(e,n),L(n,{validation:"cidr",code:P.invalid_string,message:i.message}),r.dirty()}else if(i.kind==="base64"){if(!U3e.test(e.data))n=this._getOrReturnCtx(e,n),L(n,{validation:"base64",code:P.invalid_string,message:i.message}),r.dirty()}else if(i.kind==="base64url"){if(!V3e.test(e.data))n=this._getOrReturnCtx(e,n),L(n,{validation:"base64url",code:P.invalid_string,message:i.message}),r.dirty()}else be.assertNever(i);return{status:r.value,value:e.data}}_regex(e,t,r){return this.refinement((n)=>e.test(n),{validation:t,code:P.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:P.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(!be.isInteger(e.data))r=this._getOrReturnCtx(e,r),L(r,{code:P.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:P.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:P.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),n.dirty()}else if(i.kind==="multipleOf"){if(Y3e(e.data,i.value)!==0)r=this._getOrReturnCtx(e,r),L(r,{code:P.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:P.not_finite,message:i.message}),n.dirty()}else be.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"&&be.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:P.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:P.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:P.not_multiple_of,multipleOf:i.value,message:i.message}),n.dirty()}else be.assertNever(i);return{status:n.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return L(t,{code:P.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:P.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:P.invalid_type,expected:N.date,received:i.parsedType}),Q}if(Number.isNaN(e.data.getTime())){let i=this._getOrReturnCtx(e);return L(i,{code:P.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:P.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:P.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),r.dirty()}else be.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)});pd=class pd extends he{_parse(e){if(this._getType(e)!==N.symbol){let r=this._getOrReturnCtx(e);return L(r,{code:P.invalid_type,expected:N.symbol,received:r.parsedType}),Q}return Lt(e.data)}};pd.create=(e)=>new pd({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:P.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:P.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:P.invalid_type,expected:N.never,received:t.parsedType}),Q}};Zn.create=(e)=>new Zn({typeName:ee.ZodNever,...le(e)});md=class md extends he{_parse(e){if(this._getType(e)!==N.undefined){let r=this._getOrReturnCtx(e);return L(r,{code:P.invalid_type,expected:N.void,received:r.parsedType}),Q}return Lt(e.data)}};md.create=(e)=>new md({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:P.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?P.too_big:P.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:P.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:P.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=be.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:P.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:P.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 be.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 be.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 be.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 be.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(be.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:P.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:P.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:P.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:P.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:P.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:P.invalid_type,expected:N.array,received:r.parsedType}),Q;if(r.data.length<this._def.items.length)return L(r,{code:P.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:P.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)})};hd=class hd 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:P.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 hd({keyType:e,valueType:t,typeName:ee.ZodRecord,...le(r)});return new hd({keyType:xn.create(),valueType:e,typeName:ee.ZodRecord,...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.map)return L(r,{code:P.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}}}};gd.create=(e,t,r)=>new gd({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:P.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:P.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:P.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:P.invalid_type,expected:N.function,received:t.parsedType}),Q;function r(o,a){return fd({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,bc(),Fi].filter((c)=>!!c),issueData:{code:P.invalid_arguments,argumentsError:a}})}function n(o,a){return fd({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,bc(),Fi].filter((c)=>!!c),issueData:{code:P.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:P.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:be.joinValues(r),received:t.parsedType,code:P.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:P.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=be.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==N.string&&r.parsedType!==N.number){let n=be.objectValues(t);return L(r,{expected:be.joinValues(n),received:r.parsedType,code:P.invalid_type}),Q}if(!this._cache)this._cache=new Set(be.getValidEnumValues(this._def.values));if(!this._cache.has(e.data)){let n=be.objectValues(t);return L(r,{received:r.data,code:P.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:P.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}))});be.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)});yd=class yd extends he{_parse(e){if(this._getType(e)!==N.nan){let r=this._getOrReturnCtx(e);return L(r,{code:P.invalid_type,expected:N.nan,received:r.parsedType}),Q}return{status:"valid",value:e.data}}};yd.create=(e)=>new yd({typeName:ee.ZodNaN,...le(e)});J3e=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}};xd=class xd 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 xd({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)});X3e={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,Z3e=yd.create,eIe=Ps.create,mz=wc.create,tIe=Oo.create,rIe=pd.create,nIe=Ec.create,iIe=Sc.create,sIe=Ao.create,oIe=As.create,aIe=Zn.create,cIe=md.create,uIe=bn.create,lIe=ut.create,dIe=ut.strictCreate,fIe=$c.create,pIe=Em.create,mIe=Cc.create,hIe=ei.create,gIe=hd.create,yIe=gd.create,xIe=ko.create,bIe=Dc.create,vIe=Fc.create,_Ie=Rc.create,DIe=Is.create,wIe=Oc.create,EIe=Po.create,SIe=Dn.create,$Ie=vn.create,CIe=Oi.create,FIe=Dn.createWithPreprocess,RIe=xd.create,PIe={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})},IIe=Q});var S={};ji(S,{BRAND:()=>J3e,DIRTY:()=>Ro,EMPTY_PATH:()=>F3e,INVALID:()=>Q,NEVER:()=>IIe,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:()=>P,ZodLazy:()=>Fc,ZodLiteral:()=>Rc,ZodMap:()=>gd,ZodNaN:()=>yd,ZodNativeEnum:()=>Oc,ZodNever:()=>Zn,ZodNull:()=>Sc,ZodNullable:()=>Oi,ZodNumber:()=>ks,ZodObject:()=>ut,ZodOptional:()=>vn,ZodParsedType:()=>N,ZodPipeline:()=>xd,ZodPromise:()=>Po,ZodReadonly:()=>Pc,ZodRecord:()=>hd,ZodSchema:()=>he,ZodSet:()=>ko,ZodString:()=>xn,ZodSymbol:()=>pd,ZodTransformer:()=>Dn,ZodTuple:()=>ei,ZodType:()=>he,ZodUndefined:()=>Ec,ZodUnion:()=>$c,ZodUnknown:()=>As,ZodVoid:()=>md,addIssueToContext:()=>L,any:()=>sIe,array:()=>uIe,bigint:()=>eIe,boolean:()=>mz,coerce:()=>PIe,custom:()=>dz,date:()=>tIe,datetimeRegex:()=>uz,defaultErrorMap:()=>Fi,discriminatedUnion:()=>pIe,effect:()=>SIe,enum:()=>DIe,function:()=>bIe,getErrorMap:()=>bc,getParsedType:()=>Qn,instanceof:()=>Q3e,intersection:()=>mIe,isAborted:()=>Dm,isAsync:()=>vc,isDirty:()=>wm,isValid:()=>Os,late:()=>X3e,lazy:()=>vIe,literal:()=>_Ie,makeIssue:()=>fd,map:()=>yIe,nan:()=>Z3e,nativeEnum:()=>wIe,never:()=>aIe,null:()=>iIe,nullable:()=>CIe,number:()=>pz,object:()=>lIe,objectUtil:()=>J_,oboolean:()=>kIe,onumber:()=>AIe,optional:()=>$Ie,ostring:()=>OIe,pipeline:()=>RIe,preprocess:()=>FIe,promise:()=>EIe,quotelessJson:()=>S3e,record:()=>gIe,set:()=>xIe,setErrorMap:()=>C3e,strictObject:()=>dIe,string:()=>fz,symbol:()=>rIe,transformer:()=>SIe,tuple:()=>hIe,undefined:()=>nIe,union:()=>fIe,unknown:()=>oIe,util:()=>be,void:()=>cIe});var tD=A(()=>{_m();Q_();nz();dd();hz();vm()});var Ic=A(()=>{tD();tD()});import{copyFileSync as TIe,existsSync as gz,mkdirSync as NIe}from"fs";import{homedir as Cm}from"os";import{join as Tc}from"path";function jIe(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 MIe(){return process.env.NEMAR_CONFIG_DIR||Tc(Cm(),".config","nemar")}function BIe(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{NIe(e,{recursive:!0}),TIe(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=MIe();if($m&&yz===e)return $m;if(BIe(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),UIe(),VIe();return $m}function UIe(){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 LIe){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 VIe(){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(qIe.has(jIe(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 bd(){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://
|
|
100
|
+
[nemar] You can manually copy ${n} to ${t}`)}}function wn(){let e=MIe();if($m&&yz===e)return $m;if(BIe(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),UIe(),VIe();return $m}function UIe(){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 LIe){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 VIe(){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(qIe.has(jIe(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 bd(){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",qIe,UXe,$m=null,yz=null,xz,LIe;var Ts=A(()=>{tz();Ic();qIe=new Set(["https://api.osc.earth/nemar","https://nemar-api.neuromechanist.workers.dev","https://nemar-api-dev.shirazi-10f.workers.dev"]);UXe=S.object({apiKey:S.string().optional(),apiUrl:S.string().url().default(Io),username:S.string().optional(),email:S.string().email().optional(),githubUsername:S.string().optional(),sandboxCompleted:S.boolean().optional(),sandboxDatasetId:S.string().optional(),dismissedNoticeIds:S.array(S.number()).optional()});xz=new Set;LIe=["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.11-dev.2155",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 I(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 I(`/admin/users${n}`,{},!0)}async function Oz(e){return I(`/admin/approve/${e}`,{method:"POST"},!0)}async function Az(e){return I(`/admin/approve/by-id/${e}`,{method:"POST"},!0)}async function kz(e){return I(`/admin/revoke/${e}`,{method:"POST"},!0)}async function Pz(e,t){return I(`/admin/users/${e}/role`,{method:"POST",body:JSON.stringify({role:t})},!0)}async function oD(e,t){return I(`/admin/datasets/${e}/visibility`,{method:"PATCH",body:JSON.stringify({visibility:t})},!0)}async function Iz(e){return I(`/datasets/${e}/publish`,{method:"POST"},!0)}async function Tz(e){return I(`/admin/datasets/${e}/ci`,{},!0)}async function Ai(e){return I(`/admin/datasets/${e}/ci`,{method:"POST"},!0)}async function aD(e){return I(`/admin/datasets/${e}/ci/validate`,{method:"POST"},!0)}async function cD(e){return I(`/admin/datasets/${e}/ci/sync`,{method:"POST"},!0)}async function Nz(e,t){return I(`/admin/datasets/${e}/doi/concept`,{method:"POST",body:JSON.stringify(t)},!0)}async function vd(e){return I(`/admin/datasets/${e}/doi`,{},!0)}async function uD(e,t){return I(`/admin/datasets/${e}/doi/update`,{method:"POST",body:JSON.stringify(t)},!0)}async function qz(e,t){return I(`/admin/datasets/${e}/withdraw`,{method:"POST",body:JSON.stringify({reason:t.reason,dry_run:t.dryRun})},!0)}async function jz(e,t){return I(`/admin/datasets/${e}/restore`,{method:"POST",body:JSON.stringify({dry_run:t.dryRun})},!0)}async function Mz(e){return I(`/admin/datasets/${e}/reset`,{method:"POST"},!0)}async function Bz(e,t=!1){return I(`/admin/datasets/${e}`,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({force:t})},!0)}async function Lz(e){return I("/admin/datasets/bulk-delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dataset_ids:e})},!0)}async function Uz(e){return I("/admin/datasets/import",{method:"POST",body:JSON.stringify(e)},!0)}async function Vz(e){return I("/admin/datasets/exemplar",{method:"POST",body:JSON.stringify(e)},!0)}async function zz(e){return I(`/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 I(`/admin/imports${n?`?${n}`:""}`,{},!0)}async function Hz(e){return I(`/admin/imports/${e}/rollback`,{method:"POST"},!0)}async function Wz(e){return I(`/admin/imports/${e}/retry`,{method:"POST"},!0)}async function dD(e){return I(`/admin/imports/${e}/verify`,{method:"POST"},!0)}async function Gz(e){return I("/admin/imports/dispatch-cooldown",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dataset_ids:e})},!0)}async function qc(e,t){return I(`/admin/datasets/${e}/reindex`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t??{})},!0)}async function Kz(e,t){return I("/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 I(`/admin/datasets/hed-sweep?limit=${encodeURIComponent(String(t))}`,{method:"POST",headers:{"Content-Type":"application/json"}},!0)}async function Jz(){return I("/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 I(`/admin/datasets/data-integrity-sweep?${r.toString()}`,{method:"POST",headers:{"Content-Type":"application/json"}},!0)}async function Qz(){return I("/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 I(`/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 I(`/admin/datasets/availability-report-sweep?${r.toString()}`,{method:"POST",headers:{"Content-Type":"application/json"}},!0)}async function tH(){return I("/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 I(`/admin/fleet/drift${r}`,{},!0)}async function jc(e,t){return I(`/admin/datasets/${e}/enforce`,{method:"POST",body:JSON.stringify({dry_run:t})},!0)}async function nH(e){return I("/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 I(`/admin/datasets/${e}/revalidate${t?"?force=true":""}`,{method:"POST"},!0)}async function sH(e){let t=e?`?user=${encodeURIComponent(e)}`:"";return I(`/admin/email-preferences${t}`,{},!0)}async function oH(e,t){let r=t?`?user=${encodeURIComponent(t)}`:"";return I(`/admin/email-preferences${r}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)},!0)}async function fD(e){return I("/admin/notify",{method:"POST",body:JSON.stringify(e)},!0)}async function aH(){return I("/admin/summary/coverage",{},!0)}async function cH(e,t,r){return I("/admin/manifest/dispatch",{method:"POST",body:JSON.stringify({dataset_id:e,version:t,skip_canary:r?.skipCanary??!1})},!0)}async function pD(e){return I("/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 I("/admin/doctor/fix",{method:"POST",body:JSON.stringify({check:e.check,...e.datasetId&&{dataset_id:e.datasetId},...e.dryRun&&{dry_run:!0}})},!0)}var Mc=A(()=>{Ns()});async function ti(e,t){return I(`/datasets/${e}/upload-credentials`,{method:"POST",body:JSON.stringify({duration_seconds:t})},!0)}async function hD(e,t){return I(`/datasets/${e}/download-credentials`,{method:"POST",body:JSON.stringify({duration_seconds:t})},!0)}async function uH(e){return I(`/admin/datasets/${e}/files`,{},!0)}async function lH(e){let t,r=0,n=[],i=!0;while(i){let s=await I(`/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 GIe(e){return e.startsWith("v")?e:`v${e}`}var HIe,WIe,dH,aQe;var gD=A(()=>{Ic();HIe=/^v?\d+\.\d+\.\d+(?:-(?:rc|alpha|beta)\d*)?$/,WIe=/^v\d+\.\d+\.\d+(?:-(?:rc|alpha|beta)\d*)?$/;dH=S.string().regex(HIe,"must be a semver version, optionally v-prefixed").transform(GIe),aQe=S.string().regex(WIe,"must be the canonical v-prefixed tag (vX.Y.Z)")});var KIe,YIe,fH;var pH=A(()=>{Ic();KIe=S.object({id:S.number().int(),username:S.string().nullable(),email:S.string(),github_username:S.string().nullable(),role:S.string(),orcid:S.string().nullable().optional(),created_at:S.string().optional(),approved_at:S.string().nullable().optional(),dataset_count:S.number().int().optional(),sandbox_completed:S.boolean().optional(),sandbox_completed_at:S.string().nullable().optional(),sandbox_dataset_id:S.string().nullable().optional()}).passthrough(),YIe=S.object({prefix:S.string(),created_at:S.string(),last_used_at:S.string().nullable()}).passthrough().nullable(),fH=S.object({user:KIe,token:YIe.optional()}).passthrough()});var JIe="0.4.0",yD,_d,mH,XIe,QIe,hH,pQe,gH,mQe,ki,ZIe,Am,hQe;var xD=A(()=>{Ic();gD();yD=S.enum(["openneuro","nemar","gin","other"]),_d=S.union([S.literal(0),S.literal(1)]).nullable(),mH=S.object({dataset_id:S.string(),id:S.string().optional(),name:S.string(),description:S.string().nullable().optional(),status:S.string(),visibility:S.string(),concept_doi:S.string().nullable().optional(),doi:S.string().nullable().optional(),created_at:S.string(),updated_at:S.string().optional(),owner_username:S.string().nullable().optional(),source:S.string().nullable().optional(),modalities:S.string().optional(),participants:S.number().int().nonnegative(),tasks:S.string().optional(),authors:S.string().optional(),license:S.string().optional(),file_size:S.number().nonnegative(),file_size_formatted:S.string().optional(),total_files:S.number().nonnegative().nullable().optional(),num_citations:S.number().int().nonnegative().optional(),n_channels:S.number().int().nullable().optional(),electrode_system:S.string().nullable().optional(),has_hed:_d.optional(),hed_version:S.string().nullable().optional(),data_complete:_d.optional(),bytes_present:S.number().nonnegative().nullable().optional(),latest_version:dH.nullable().optional(),subject_count:S.number().int().nullable().optional(),file_size_bytes:S.number().nullable().optional(),sessions_count:S.number().int().nullable().optional(),age_min:S.number().nullable().optional(),age_max:S.number().nullable().optional(),bids_version:S.string().nullable().optional(),zarr_status:S.enum(["pending","ready","failed"]).nullable().optional(),total_recording_duration:S.number().nullable().optional(),recording_duration_min:S.number().nullable().optional(),recording_duration_max:S.number().nullable().optional(),recording_count:S.number().int().nullable().optional(),recordings_unavailable:S.number().int().nullable().optional(),channel_count_min:S.number().int().nullable().optional(),channel_count_max:S.number().int().nullable().optional(),sampling_frequency:S.number().nullable().optional(),power_line_frequency:S.number().nullable().optional(),eeg_reference:S.string().nullable().optional(),placement_scheme:S.string().nullable().optional()}).passthrough(),XIe=mH.extend({file_size:S.number().nonnegative().nullable(),modalities:S.string().nullable().optional(),tasks:S.string().nullable().optional(),authors:S.string().nullable().optional(),license:S.string().nullable().optional(),owner_github:S.string().nullable().optional(),attestation_deposit_type:S.enum(["owner","redistribution"]).nullable().optional(),attestation_key_status:S.enum(["destroyed","retained"]).nullable().optional(),attestation_deidentified:_d.optional(),attestation_no_duplicate:_d.optional(),attestation_upstream_source:S.string().nullable().optional(),attestation_accepted_at:S.string().nullable().optional()}).passthrough(),QIe=S.object({id:S.string(),name:S.string(),modalities:S.string().nullable().optional(),participants:S.number().int().nullable().optional(),doi:S.string().nullable().optional(),tasks:S.string().nullable().optional(),authors:S.string().nullable().optional(),has_hed:_d.optional(),score:S.number().optional(),snippet:S.string().optional()}).passthrough(),hH=S.record(S.string(),S.number().int().nonnegative()),pQe=S.object({datasets:S.array(mH),count:S.number().int().nonnegative(),total_count:S.number().int().nonnegative().optional(),limit:S.number().int().optional(),offset:S.number().int().optional(),excluded_unknown:S.number().int().nonnegative().optional(),excluded_unknown_by_facet:hH.optional()}).passthrough(),gH=S.object({results:S.array(QIe),count:S.number().int().nonnegative(),returned:S.number().int().nonnegative().optional(),offset:S.number().int().nonnegative().optional(),limit:S.number().int().optional(),candidate_ceiling:S.number().int().optional(),truncated:S.boolean().optional(),method:S.enum(["exact_id","text","text_fallback","semantic","unavailable"]).optional(),min_score:S.number().optional(),warning:S.string().optional(),excluded_unknown:S.number().int().nonnegative().optional(),excluded_unknown_by_facet:hH.optional()}).passthrough(),mQe=S.object({dataset:XIe}).passthrough(),ki=S.object({value:S.string(),count:S.number().int().nonnegative()}),ZIe=S.object({values:S.array(ki),distinct_total:S.number().int().nonnegative(),truncated:S.boolean()}),Am=S.object({"electrode-system":S.array(ki).optional(),source:S.array(ki).optional(),zarr:S.array(ki).optional(),powerline:S.array(ki).optional(),"bids-version":S.array(ki).optional(),"hed-version":S.array(ki).optional(),license:S.array(ki).optional(),modality:S.array(ki).optional(),task:ZIe.optional(),warning:S.string().optional()}).passthrough(),hQe=S.object({schema_version:S.literal(JIe),doc_type:S.literal("dataset"),dataset_id:S.string().regex(/^[a-z]{2}\d+$/,"neuroschema dataset_id pattern"),name:S.string(),source:yD,recording_modality:S.array(S.string()).min(1),description:S.string().nullable().optional(),bids_version:S.string().nullable().optional(),license:S.string().nullable().optional()}).passthrough()});var km=A(()=>{gD();pH();xD()});async function Im(e){return I(`/datasets/${e}/ci/status`,{},!0)}async function yH(e){return I(`/datasets/${e}/manifest`,{},!0)}async function Tm(e,t){return I(`/datasets/${e}/manifest/${t}`,{},!0)}function xH(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 Lc(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.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 I(`/datasets${r}`,{},e.mine?!0:"optional");return n.datasets=n.datasets.map(xH),n}async function bH(e){return I(`/datasets/resolve/${e}`,{},"optional")}async function vH(){return I("/datasets/facets",{signal:AbortSignal.timeout(5000)},"optional",Am)}async function _H(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.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 I(`/datasets/search?${r.toString()}`,{},"optional",gH)}async function gt(e){let t=await I(`/datasets/${e}`,{},"optional");return xH(t.dataset)}async function DH(e){return I(`/datasets/${e}/versions`,{},!0)}async function Nm(e){return I("/datasets",{method:"POST",body:JSON.stringify(e)},!0)}async function qm(e){return I(`/datasets/${e}/finalize`,{method:"POST"},!0)}async function bD(e){return I(`/datasets/${e}/request-access`,{method:"POST"},!0)}async function wH(e,t){let r=t?`?status=${t}`:"";return I(`/datasets/${e}/access-requests${r}`,{},!0)}async function EH(e,t){return I(`/datasets/${e}/access-requests/${t}/approve`,{method:"POST"},!0)}async function SH(e,t){return I(`/datasets/${e}/access-requests/${t}/deny`,{method:"POST"},!0)}async function $H(e,t){return I(`/datasets/${e}/invite`,{method:"POST",body:JSON.stringify({username:t})},!0)}async function CH(e){return I(`/datasets/${e}/collaborators`,{},!0)}async function FH(e,t){return I(`/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 Uc;var PH=A(()=>{Uc=["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 Vc(e){return I(`/datasets/${e}/publish/request`,{method:"POST"},!0)}async function TH(e){return I(`/datasets/${e}/publish/status`,{},!0)}async function NH(e){return I(`/datasets/${e}/publish/resend`,{method:"POST"},!0)}async function qH(e){let t=e?`?status=${e}`:"";return I(`/admin/publish/requests${t}`,{},!0)}async function jH(e,t){return I(`/admin/publish/${e}/deny`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({reason:t})},!0)}function eTe(e,t=[]){if(e){let r=Uc.indexOf(e);if(r>=0)return r+1}return Math.min(t.length+1,Uc.length)}function tTe(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 zc(e,t=!1,r=!1,n=!1,i,s){let c,l,d=0,f=!1,m,p=t,g=[],y;function x(v,_,E,C){if(!s)return;s({step:v,stepIndex:eTe(v,_),stepTotal:Uc.length,s3LockLocked:E,s3LockTotal:C,s3LockResumed:v==="s3_lock"&&f?!0:void 0})}for(let v=1;v<=5;v++)try{let _,E=!0;do{if(_=await I(`/admin/publish/${e}/approve`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({resume:E?p:!0,sandbox:r,s3_lock_continuation_token:c,s3_lock_total:l,skip_ci_check:n})},!0),E=!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=IH(g);return _}catch(_){if(y=_,v===5||!tTe(_)){if(_ instanceof q&&g.length>0)_.stepResults=IH(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 IH(e){let t=new Map;for(let r of e)t.set(r.step,r);return Array.from(t.values())}var Dd=A(()=>{PH();Ns();er()});function LH(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.11",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 I(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 I(`/admin/users${n}`,{},!0)}async function Oz(e){return I(`/admin/approve/${e}`,{method:"POST"},!0)}async function Az(e){return I(`/admin/approve/by-id/${e}`,{method:"POST"},!0)}async function kz(e){return I(`/admin/revoke/${e}`,{method:"POST"},!0)}async function Pz(e,t){return I(`/admin/users/${e}/role`,{method:"POST",body:JSON.stringify({role:t})},!0)}async function oD(e,t){return I(`/admin/datasets/${e}/visibility`,{method:"PATCH",body:JSON.stringify({visibility:t})},!0)}async function Iz(e){return I(`/datasets/${e}/publish`,{method:"POST"},!0)}async function Tz(e){return I(`/admin/datasets/${e}/ci`,{},!0)}async function Ai(e){return I(`/admin/datasets/${e}/ci`,{method:"POST"},!0)}async function aD(e){return I(`/admin/datasets/${e}/ci/validate`,{method:"POST"},!0)}async function cD(e){return I(`/admin/datasets/${e}/ci/sync`,{method:"POST"},!0)}async function Nz(e,t){return I(`/admin/datasets/${e}/doi/concept`,{method:"POST",body:JSON.stringify(t)},!0)}async function vd(e){return I(`/admin/datasets/${e}/doi`,{},!0)}async function uD(e,t){return I(`/admin/datasets/${e}/doi/update`,{method:"POST",body:JSON.stringify(t)},!0)}async function qz(e,t){return I(`/admin/datasets/${e}/withdraw`,{method:"POST",body:JSON.stringify({reason:t.reason,dry_run:t.dryRun})},!0)}async function jz(e,t){return I(`/admin/datasets/${e}/restore`,{method:"POST",body:JSON.stringify({dry_run:t.dryRun})},!0)}async function Mz(e){return I(`/admin/datasets/${e}/reset`,{method:"POST"},!0)}async function Bz(e,t=!1){return I(`/admin/datasets/${e}`,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({force:t})},!0)}async function Lz(e){return I("/admin/datasets/bulk-delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dataset_ids:e})},!0)}async function Uz(e){return I("/admin/datasets/import",{method:"POST",body:JSON.stringify(e)},!0)}async function Vz(e){return I("/admin/datasets/exemplar",{method:"POST",body:JSON.stringify(e)},!0)}async function zz(e){return I(`/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 I(`/admin/imports${n?`?${n}`:""}`,{},!0)}async function Hz(e){return I(`/admin/imports/${e}/rollback`,{method:"POST"},!0)}async function Wz(e){return I(`/admin/imports/${e}/retry`,{method:"POST"},!0)}async function dD(e){return I(`/admin/imports/${e}/verify`,{method:"POST"},!0)}async function Gz(e){return I("/admin/imports/dispatch-cooldown",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dataset_ids:e})},!0)}async function qc(e,t){return I(`/admin/datasets/${e}/reindex`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t??{})},!0)}async function Kz(e,t){return I("/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 I(`/admin/datasets/hed-sweep?limit=${encodeURIComponent(String(t))}`,{method:"POST",headers:{"Content-Type":"application/json"}},!0)}async function Jz(){return I("/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 I(`/admin/datasets/data-integrity-sweep?${r.toString()}`,{method:"POST",headers:{"Content-Type":"application/json"}},!0)}async function Qz(){return I("/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 I(`/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 I(`/admin/datasets/availability-report-sweep?${r.toString()}`,{method:"POST",headers:{"Content-Type":"application/json"}},!0)}async function tH(){return I("/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 I(`/admin/fleet/drift${r}`,{},!0)}async function jc(e,t){return I(`/admin/datasets/${e}/enforce`,{method:"POST",body:JSON.stringify({dry_run:t})},!0)}async function nH(e){return I("/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 I(`/admin/datasets/${e}/revalidate${t?"?force=true":""}`,{method:"POST"},!0)}async function sH(e){let t=e?`?user=${encodeURIComponent(e)}`:"";return I(`/admin/email-preferences${t}`,{},!0)}async function oH(e,t){let r=t?`?user=${encodeURIComponent(t)}`:"";return I(`/admin/email-preferences${r}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)},!0)}async function fD(e){return I("/admin/notify",{method:"POST",body:JSON.stringify(e)},!0)}async function aH(){return I("/admin/summary/coverage",{},!0)}async function cH(e,t,r){return I("/admin/manifest/dispatch",{method:"POST",body:JSON.stringify({dataset_id:e,version:t,skip_canary:r?.skipCanary??!1})},!0)}async function pD(e){return I("/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 I("/admin/doctor/fix",{method:"POST",body:JSON.stringify({check:e.check,...e.datasetId&&{dataset_id:e.datasetId},...e.dryRun&&{dry_run:!0}})},!0)}var Mc=A(()=>{Ns()});async function ti(e,t){return I(`/datasets/${e}/upload-credentials`,{method:"POST",body:JSON.stringify({duration_seconds:t})},!0)}async function hD(e,t){return I(`/datasets/${e}/download-credentials`,{method:"POST",body:JSON.stringify({duration_seconds:t})},!0)}async function uH(e){return I(`/admin/datasets/${e}/files`,{},!0)}async function lH(e){let t,r=0,n=[],i=!0;while(i){let s=await I(`/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 GIe(e){return e.startsWith("v")?e:`v${e}`}var HIe,WIe,dH,aQe;var gD=A(()=>{Ic();HIe=/^v?\d+\.\d+\.\d+(?:-(?:rc|alpha|beta)\d*)?$/,WIe=/^v\d+\.\d+\.\d+(?:-(?:rc|alpha|beta)\d*)?$/;dH=S.string().regex(HIe,"must be a semver version, optionally v-prefixed").transform(GIe),aQe=S.string().regex(WIe,"must be the canonical v-prefixed tag (vX.Y.Z)")});var KIe,YIe,fH;var pH=A(()=>{Ic();KIe=S.object({id:S.number().int(),username:S.string().nullable(),email:S.string(),github_username:S.string().nullable(),role:S.string(),orcid:S.string().nullable().optional(),created_at:S.string().optional(),approved_at:S.string().nullable().optional(),dataset_count:S.number().int().optional(),sandbox_completed:S.boolean().optional(),sandbox_completed_at:S.string().nullable().optional(),sandbox_dataset_id:S.string().nullable().optional()}).passthrough(),YIe=S.object({prefix:S.string(),created_at:S.string(),last_used_at:S.string().nullable()}).passthrough().nullable(),fH=S.object({user:KIe,token:YIe.optional()}).passthrough()});var JIe="0.4.0",yD,_d,mH,XIe,QIe,hH,pQe,gH,mQe,ki,ZIe,Am,hQe;var xD=A(()=>{Ic();gD();yD=S.enum(["openneuro","nemar","gin","other"]),_d=S.union([S.literal(0),S.literal(1)]).nullable(),mH=S.object({dataset_id:S.string(),id:S.string().optional(),name:S.string(),description:S.string().nullable().optional(),status:S.string(),visibility:S.string(),concept_doi:S.string().nullable().optional(),doi:S.string().nullable().optional(),created_at:S.string(),updated_at:S.string().optional(),owner_username:S.string().nullable().optional(),source:S.string().nullable().optional(),modalities:S.string().optional(),participants:S.number().int().nonnegative(),tasks:S.string().optional(),authors:S.string().optional(),license:S.string().optional(),file_size:S.number().nonnegative(),file_size_formatted:S.string().optional(),total_files:S.number().nonnegative().nullable().optional(),num_citations:S.number().int().nonnegative().optional(),n_channels:S.number().int().nullable().optional(),electrode_system:S.string().nullable().optional(),has_hed:_d.optional(),hed_version:S.string().nullable().optional(),data_complete:_d.optional(),bytes_present:S.number().nonnegative().nullable().optional(),latest_version:dH.nullable().optional(),subject_count:S.number().int().nullable().optional(),file_size_bytes:S.number().nullable().optional(),sessions_count:S.number().int().nullable().optional(),age_min:S.number().nullable().optional(),age_max:S.number().nullable().optional(),bids_version:S.string().nullable().optional(),zarr_status:S.enum(["pending","ready","failed"]).nullable().optional(),total_recording_duration:S.number().nullable().optional(),recording_duration_min:S.number().nullable().optional(),recording_duration_max:S.number().nullable().optional(),recording_count:S.number().int().nullable().optional(),recordings_unavailable:S.number().int().nullable().optional(),channel_count_min:S.number().int().nullable().optional(),channel_count_max:S.number().int().nullable().optional(),sampling_frequency:S.number().nullable().optional(),power_line_frequency:S.number().nullable().optional(),eeg_reference:S.string().nullable().optional(),placement_scheme:S.string().nullable().optional()}).passthrough(),XIe=mH.extend({file_size:S.number().nonnegative().nullable(),modalities:S.string().nullable().optional(),tasks:S.string().nullable().optional(),authors:S.string().nullable().optional(),license:S.string().nullable().optional(),owner_github:S.string().nullable().optional(),attestation_deposit_type:S.enum(["owner","redistribution"]).nullable().optional(),attestation_key_status:S.enum(["destroyed","retained"]).nullable().optional(),attestation_deidentified:_d.optional(),attestation_no_duplicate:_d.optional(),attestation_upstream_source:S.string().nullable().optional(),attestation_accepted_at:S.string().nullable().optional()}).passthrough(),QIe=S.object({id:S.string(),name:S.string(),modalities:S.string().nullable().optional(),participants:S.number().int().nullable().optional(),doi:S.string().nullable().optional(),tasks:S.string().nullable().optional(),authors:S.string().nullable().optional(),has_hed:_d.optional(),score:S.number().optional(),snippet:S.string().optional()}).passthrough(),hH=S.record(S.string(),S.number().int().nonnegative()),pQe=S.object({datasets:S.array(mH),count:S.number().int().nonnegative(),total_count:S.number().int().nonnegative().optional(),limit:S.number().int().optional(),offset:S.number().int().optional(),excluded_unknown:S.number().int().nonnegative().optional(),excluded_unknown_by_facet:hH.optional()}).passthrough(),gH=S.object({results:S.array(QIe),count:S.number().int().nonnegative(),returned:S.number().int().nonnegative().optional(),offset:S.number().int().nonnegative().optional(),limit:S.number().int().optional(),candidate_ceiling:S.number().int().optional(),truncated:S.boolean().optional(),method:S.enum(["exact_id","text","text_fallback","semantic","unavailable"]).optional(),min_score:S.number().optional(),warning:S.string().optional(),excluded_unknown:S.number().int().nonnegative().optional(),excluded_unknown_by_facet:hH.optional()}).passthrough(),mQe=S.object({dataset:XIe}).passthrough(),ki=S.object({value:S.string(),count:S.number().int().nonnegative()}),ZIe=S.object({values:S.array(ki),distinct_total:S.number().int().nonnegative(),truncated:S.boolean()}),Am=S.object({"electrode-system":S.array(ki).optional(),source:S.array(ki).optional(),zarr:S.array(ki).optional(),powerline:S.array(ki).optional(),"bids-version":S.array(ki).optional(),"hed-version":S.array(ki).optional(),license:S.array(ki).optional(),modality:S.array(ki).optional(),task:ZIe.optional(),warning:S.string().optional()}).passthrough(),hQe=S.object({schema_version:S.literal(JIe),doc_type:S.literal("dataset"),dataset_id:S.string().regex(/^[a-z]{2}\d+$/,"neuroschema dataset_id pattern"),name:S.string(),source:yD,recording_modality:S.array(S.string()).min(1),description:S.string().nullable().optional(),bids_version:S.string().nullable().optional(),license:S.string().nullable().optional()}).passthrough()});var km=A(()=>{gD();pH();xD()});async function Im(e){return I(`/datasets/${e}/ci/status`,{},!0)}async function yH(e){return I(`/datasets/${e}/manifest`,{},!0)}async function Tm(e,t){return I(`/datasets/${e}/manifest/${t}`,{},!0)}function xH(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 Lc(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.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 I(`/datasets${r}`,{},e.mine?!0:"optional");return n.datasets=n.datasets.map(xH),n}async function bH(e){return I(`/datasets/resolve/${e}`,{},"optional")}async function vH(){return I("/datasets/facets",{signal:AbortSignal.timeout(5000)},"optional",Am)}async function _H(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.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 I(`/datasets/search?${r.toString()}`,{},"optional",gH)}async function gt(e){let t=await I(`/datasets/${e}`,{},"optional");return xH(t.dataset)}async function DH(e){return I(`/datasets/${e}/versions`,{},!0)}async function Nm(e){return I("/datasets",{method:"POST",body:JSON.stringify(e)},!0)}async function qm(e){return I(`/datasets/${e}/finalize`,{method:"POST"},!0)}async function bD(e){return I(`/datasets/${e}/request-access`,{method:"POST"},!0)}async function wH(e,t){let r=t?`?status=${t}`:"";return I(`/datasets/${e}/access-requests${r}`,{},!0)}async function EH(e,t){return I(`/datasets/${e}/access-requests/${t}/approve`,{method:"POST"},!0)}async function SH(e,t){return I(`/datasets/${e}/access-requests/${t}/deny`,{method:"POST"},!0)}async function $H(e,t){return I(`/datasets/${e}/invite`,{method:"POST",body:JSON.stringify({username:t})},!0)}async function CH(e){return I(`/datasets/${e}/collaborators`,{},!0)}async function FH(e,t){return I(`/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 Uc;var PH=A(()=>{Uc=["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 Vc(e){return I(`/datasets/${e}/publish/request`,{method:"POST"},!0)}async function TH(e){return I(`/datasets/${e}/publish/status`,{},!0)}async function NH(e){return I(`/datasets/${e}/publish/resend`,{method:"POST"},!0)}async function qH(e){let t=e?`?status=${e}`:"";return I(`/admin/publish/requests${t}`,{},!0)}async function jH(e,t){return I(`/admin/publish/${e}/deny`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({reason:t})},!0)}function eTe(e,t=[]){if(e){let r=Uc.indexOf(e);if(r>=0)return r+1}return Math.min(t.length+1,Uc.length)}function tTe(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 zc(e,t=!1,r=!1,n=!1,i,s){let c,l,d=0,f=!1,m,p=t,g=[],y;function x(v,_,E,C){if(!s)return;s({step:v,stepIndex:eTe(v,_),stepTotal:Uc.length,s3LockLocked:E,s3LockTotal:C,s3LockResumed:v==="s3_lock"&&f?!0:void 0})}for(let v=1;v<=5;v++)try{let _,E=!0;do{if(_=await I(`/admin/publish/${e}/approve`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({resume:E?p:!0,sandbox:r,s3_lock_continuation_token:c,s3_lock_total:l,skip_ci_check:n})},!0),E=!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=IH(g);return _}catch(_){if(y=_,v===5||!tTe(_)){if(_ instanceof q&&g.length>0)_.stepResults=IH(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 IH(e){let t=new Map;for(let r of e)t.set(r.step,r);return Array.from(t.values())}var Dd=A(()=>{PH();Ns();er()});function LH(e){DD=e}function wD(){return DD}function wd(e){if(DD)process.stderr.write(`${e}
|
|
106
106
|
`)}var DD=!1;var UH={};ji(UH,{runCommand:()=>R});var{spawn:rTe}=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=rTe({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 nTe(){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 nTe();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"}
|