nemar-cli 0.9.16 → 0.9.17-dev.2347

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +3 -3
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -97,11 +97,11 @@ ${t}`,$we,Cwe,Rwe=(e,t,r)=>{let n=r===""?"":`with ${r.trim()}() `,i=Swe.bind(nul
97
97
  depsCount: ${t},
98
98
  deps: ${r}}`};var z8e={keyword:"dependencies",type:"object",schemaType:"object",error:PV.error,code(e){let[t,r]=H8e(e);AV(e,t),FV(e,r)}};function H8e({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 AV(e,t=e.schema){let{gen:r,data:n,it:i}=e;if(Object.keys(t).length===0)return;let o=r.let("missing");for(let s in t){let a=t[s];if(a.length===0)continue;let c=qd.propertyInData(r,n,s,i.opts.ownProperties);if(e.setParams({property:s,depsCount:a.length,deps:a.join(", ")}),i.allErrors)r.if(c,()=>{for(let u of a)qd.checkReportMissingProp(e,u)});else r.if(iw._`${c} && (${qd.checkMissingProp(e,a,o)})`),qd.reportMissingProp(e,o),r.else()}}PV.validatePropertyDeps=AV;function FV(e,t=e.schema){let{gen:r,data:n,keyword:i,it:o}=e,s=r.name("valid");for(let a in t){if(G8e.alwaysValidSchema(o,t[a]))continue;r.if(qd.propertyInData(r,n,a,o.opts.ownProperties),()=>{let c=e.subschema({keyword:i,schemaProp:a},s);e.mergeValidEvaluated(c,s)},()=>r.var(s,!0)),e.ok(s)}}PV.validateSchemaDeps=FV;PV.default=z8e});var MV=h(function(jV){Object.defineProperty(jV,"__esModule",{value:!0});var qV=be(),Y8e=je(),J8e={message:"property name must be valid",params:({params:e})=>qV._`{propertyName: ${e.propertyName}}`},X8e={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:J8e,code(e){let{gen:t,schema:r,data:n,it:i}=e;if(Y8e.alwaysValidSchema(i,r))return;let o=t.name("valid");t.forIn("key",n,(s)=>{e.setParams({propertyName:s}),e.subschema({keyword:"propertyNames",data:s,dataTypes:["string"],propertyName:s,compositeRule:!0},o),t.if(qV.not(o),()=>{if(e.error(!0),!i.allErrors)t.break()})}),e.ok(o)}};jV.default=X8e});var ow=h(function(BV){Object.defineProperty(BV,"__esModule",{value:!0});var t0=un(),jn=be(),Z8e=to(),r0=je(),e4e={message:"must NOT have additional properties",params:({params:e})=>jn._`{additionalProperty: ${e.additionalProperty}}`},t4e={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:e4e,code(e){let{gen:t,schema:r,parentSchema:n,data:i,errsCount:o,it:s}=e;if(!o)throw Error("ajv implementation error");let{allErrors:a,opts:c}=s;if(s.props=!0,c.removeAdditional!=="all"&&r0.alwaysValidSchema(s,r))return;let u=t0.allSchemaProperties(n.properties),d=t0.allSchemaProperties(n.patternProperties);f(),e.ok(jn._`${o} === ${Z8e.default.errors}`);function f(){t.forIn("key",i,(x)=>{if(!u.length&&!d.length)g(x);else t.if(m(x),()=>g(x))})}function m(x){let _;if(u.length>8){let v=r0.schemaRefOrVal(s,n.properties,"properties");_=t0.isOwnProperty(t,v,x)}else if(u.length)_=jn.or(...u.map((v)=>jn._`${x} === ${v}`));else _=jn.nil;if(d.length)_=jn.or(_,...d.map((v)=>jn._`${t0.usePattern(e,v)}.test(${x})`));return jn.not(_)}function p(x){t.code(jn._`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"&&!r0.alwaysValidSchema(s,r)){let _=t.name("valid");if(c.removeAdditional==="failing")y(x,_,!1),t.if(jn.not(_),()=>{e.reset(),p(x)});else if(y(x,_),!a)t.if(jn.not(_),()=>t.break())}}function y(x,_,v){let E={keyword:"additionalProperties",dataProp:x,dataPropType:r0.Type.Str};if(v===!1)Object.assign(E,{compositeRule:!0,createErrors:!1,allErrors:!1});e.subschema(E,_)}}};BV.default=t4e});var GV=h(function(VV){Object.defineProperty(VV,"__esModule",{value:!0});var n4e=$d(),UV=un(),sw=je(),LV=ow(),i4e={keyword:"properties",type:"object",schemaType:"object",code(e){let{gen:t,schema:r,parentSchema:n,data:i,it:o}=e;if(o.opts.removeAdditional==="all"&&n.additionalProperties===void 0)LV.default.code(new n4e.KeywordCxt(o,LV.default,"additionalProperties"));let s=UV.allSchemaProperties(r);for(let f of s)o.definedProperties.add(f);if(o.opts.unevaluated&&s.length&&o.props!==!0)o.props=sw.mergeEvaluated.props(t,sw.toHash(s),o.props);let a=s.filter((f)=>!sw.alwaysValidSchema(o,r[f]));if(a.length===0)return;let c=t.name("valid");for(let f of a){if(u(f))d(f);else{if(t.if(UV.propertyInData(t,i,f,o.opts.ownProperties)),d(f),!o.allErrors)t.else().var(c,!0);t.endIf()}e.it.definedProperties.add(f),e.ok(c)}function u(f){return o.opts.useDefaults&&!o.compositeRule&&r[f].default!==void 0}function d(f){e.subschema({keyword:"properties",schemaProp:f,dataProp:f},c)}}};VV.default=i4e});var YV=h(function(KV){Object.defineProperty(KV,"__esModule",{value:!0});var zV=un(),n0=be(),HV=je(),WV=je(),s4e={keyword:"patternProperties",type:"object",schemaType:"object",code(e){let{gen:t,schema:r,data:n,parentSchema:i,it:o}=e,{opts:s}=o,a=zV.allSchemaProperties(r),c=a.filter((y)=>HV.alwaysValidSchema(o,r[y]));if(a.length===0||c.length===a.length&&(!o.opts.unevaluated||o.props===!0))return;let u=s.strictSchema&&!s.allowMatchingProperties&&i.properties,d=t.name("valid");if(o.props!==!0&&!(o.props instanceof n0.Name))o.props=WV.evaluatedPropsToName(t,o.props);let{props:f}=o;m();function m(){for(let y of a){if(u)p(y);if(o.allErrors)g(y);else t.var(d,!0),g(y),t.if(d)}}function p(y){for(let x in u)if(new RegExp(y).test(x))HV.checkStrictMode(o,`property ${x} matches pattern ${y} (use allowMatchingProperties)`)}function g(y){t.forIn("key",n,(x)=>{t.if(n0._`${zV.usePattern(e,y)}.test(${x})`,()=>{let _=c.includes(y);if(!_)e.subschema({keyword:"patternProperties",schemaProp:y,dataProp:x,dataPropType:WV.Type.Str},d);if(o.opts.unevaluated&&f!==!0)t.assign(n0._`${f}[${x}]`,!0);else if(!_&&!o.allErrors)t.if(n0.not(d),()=>t.break())})})}}};KV.default=s4e});var XV=h(function(JV){Object.defineProperty(JV,"__esModule",{value:!0});var c4e=je(),l4e={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(e){let{gen:t,schema:r,it:n}=e;if(c4e.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"}};JV.default=l4e});var ZV=h(function(QV){Object.defineProperty(QV,"__esModule",{value:!0});var d4e=un(),f4e={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:d4e.validateUnion,error:{message:"must match a schema in anyOf"}};QV.default=f4e});var tG=h(function(eG){Object.defineProperty(eG,"__esModule",{value:!0});var i0=be(),m4e=je(),h4e={message:"must match exactly one schema in oneOf",params:({params:e})=>i0._`{passingSchemas: ${e.passing}}`},g4e={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:h4e,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 o=r,s=t.let("valid",!1),a=t.let("passing",null),c=t.name("_valid");e.setParams({passing:a}),t.block(u),e.result(s,()=>e.reset(),()=>e.error(!0));function u(){o.forEach((d,f)=>{let m;if(m4e.alwaysValidSchema(i,d))t.var(c,!0);else m=e.subschema({keyword:"oneOf",schemaProp:f,compositeRule:!0},c);if(f>0)t.if(i0._`${c} && ${s}`).assign(s,!1).assign(a,i0._`[${a}, ${f}]`).else();t.if(c,()=>{if(t.assign(s,!0),t.assign(a,f),m)e.mergeEvaluated(m,i0.Name)})})}}};eG.default=g4e});var nG=h(function(rG){Object.defineProperty(rG,"__esModule",{value:!0});var x4e=je(),b4e={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((o,s)=>{if(x4e.alwaysValidSchema(n,o))return;let a=e.subschema({keyword:"allOf",schemaProp:s},i);e.ok(i),e.mergeEvaluated(a)})}};rG.default=b4e});var aG=h(function(sG){Object.defineProperty(sG,"__esModule",{value:!0});var o0=be(),oG=je(),v4e={message:({params:e})=>o0.str`must match "${e.ifClause}" schema`,params:({params:e})=>o0._`{failingKeyword: ${e.ifClause}}`},w4e={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:v4e,code(e){let{gen:t,parentSchema:r,it:n}=e;if(r.then===void 0&&r.else===void 0)oG.checkStrictMode(n,'"if" without "then" and "else" is ignored');let i=iG(n,"then"),o=iG(n,"else");if(!i&&!o)return;let s=t.let("valid",!0),a=t.name("_valid");if(c(),e.reset(),i&&o){let d=t.let("ifClause");e.setParams({ifClause:d}),t.if(a,u("then",d),u("else",d))}else if(i)t.if(a,u("then"));else t.if(o0.not(a),u("else"));e.pass(s,()=>e.error(!0));function c(){let d=e.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},a);e.mergeEvaluated(d)}function u(d,f){return()=>{let m=e.subschema({keyword:d},a);if(t.assign(s,a),e.mergeValidEvaluated(m,s),f)t.assign(f,o0._`${d}`);else e.setParams({ifClause:d})}}}};function iG(e,t){let r=e.schema[t];return r!==void 0&&!oG.alwaysValidSchema(e,r)}sG.default=w4e});var lG=h(function(cG){Object.defineProperty(cG,"__esModule",{value:!0});var E4e=je(),S4e={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:e,parentSchema:t,it:r}){if(t.if===void 0)E4e.checkStrictMode(r,`"${e}" without "if" is ignored`)}};cG.default=S4e});var dG=h(function(uG){Object.defineProperty(uG,"__esModule",{value:!0});var C4e=rw(),R4e=SV(),O4e=nw(),k4e=RV(),A4e=kV(),F4e=NV(),P4e=MV(),I4e=ow(),T4e=GV(),N4e=YV(),q4e=XV(),j4e=ZV(),M4e=tG(),B4e=nG(),L4e=aG(),U4e=lG();function V4e(e=!1){let t=[q4e.default,j4e.default,M4e.default,B4e.default,L4e.default,U4e.default,P4e.default,I4e.default,F4e.default,T4e.default,N4e.default];if(e)t.push(R4e.default,k4e.default);else t.push(C4e.default,O4e.default);return t.push(A4e.default),t}uG.default=V4e});var pG=h(function(fG){Object.defineProperty(fG,"__esModule",{value:!0});var Et=be(),z4e={message:({schemaCode:e})=>Et.str`must match format "${e}"`,params:({schemaCode:e})=>Et._`{format: ${e}}`},H4e={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:z4e,code(e,t){let{gen:r,data:n,$data:i,schema:o,schemaCode:s,it:a}=e,{opts:c,errSchemaPath:u,schemaEnv:d,self:f}=a;if(!c.validateFormats)return;if(i)m();else p();function m(){let g=r.scopeValue("formats",{ref:f.formats,code:c.code.formats}),y=r.const("fDef",Et._`${g}[${s}]`),x=r.let("fType"),_=r.let("format");r.if(Et._`typeof ${y} == "object" && !(${y} instanceof RegExp)`,()=>r.assign(x,Et._`${y}.type || "string"`).assign(_,Et._`${y}.validate`),()=>r.assign(x,Et._`"string"`).assign(_,y)),e.fail$data(Et.or(v(),E()));function v(){if(c.strictSchema===!1)return Et.nil;return Et._`${s} && !${_}`}function E(){let S=d.$async?Et._`(${y}.async ? await ${_}(${n}) : ${_}(${n}))`:Et._`${_}(${n})`,D=Et._`(typeof ${_} == "function" ? ${S} : ${_}.test(${n}))`;return Et._`${_} && ${_} !== true && ${x} === ${t} && !${D}`}}function p(){let g=f.formats[o];if(!g){v();return}if(g===!0)return;let[y,x,_]=E(g);if(y===t)e.pass(S());function v(){if(c.strictSchema===!1){f.logger.warn(D());return}throw Error(D());function D(){return`unknown format "${o}" ignored in schema at path "${u}"`}}function E(D){let A=D instanceof RegExp?Et.regexpCode(D):c.code.formats?Et._`${c.code.formats}${Et.getProperty(o)}`:void 0,C=r.scopeValue("formats",{key:o,ref:D,code:A});if(typeof D=="object"&&!(D instanceof RegExp))return[D.type||"string",D.validate,Et._`${C}.validate`];return["string",D,C]}function S(){if(typeof g=="object"&&!(g instanceof RegExp)&&g.async){if(!d.$async)throw Error("async format in sync schema");return Et._`await ${_}(${n})`}return typeof x=="function"?Et._`${_}(${n})`:Et._`${_}.test(${n})`}}}};fG.default=H4e});var hG=h(function(mG){Object.defineProperty(mG,"__esModule",{value:!0});var K4e=pG(),Y4e=[K4e.default];mG.default=Y4e});var xG=h(function(gG){Object.defineProperty(gG,"__esModule",{value:!0});gG.contentVocabulary=gG.metadataVocabulary=void 0;gG.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];gG.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]});var vG=h(function(_G){Object.defineProperty(_G,"__esModule",{value:!0});var Q4e=VU(),Z4e=gV(),e3e=dG(),t3e=hG(),bG=xG(),r3e=[Q4e.default,Z4e.default,(0,e3e.default)(),t3e.default,bG.metadataVocabulary,bG.contentVocabulary];_G.default=r3e});var SG=h(function(DG){Object.defineProperty(DG,"__esModule",{value:!0});DG.DiscrError=void 0;var wG;(function(e){e.Tag="tag",e.Mapping="mapping"})(wG||(DG.DiscrError=wG={}))});var RG=h(function(CG){Object.defineProperty(CG,"__esModule",{value:!0});var Wc=be(),aw=SG(),$G=Gh(),i3e=Cd(),o3e=je(),s3e={message:({params:{discrError:e,tagName:t}})=>e===aw.DiscrError.Tag?`tag "${t}" must be string`:`value of tag "${t}" must be in oneOf`,params:({params:{discrError:e,tag:t,tagName:r}})=>Wc._`{error: ${e}, tag: ${r}, tagValue: ${t}}`},a3e={keyword:"discriminator",type:"object",schemaType:"object",error:s3e,code(e){let{gen:t,data:r,schema:n,parentSchema:i,it:o}=e,{oneOf:s}=i;if(!o.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(!s)throw Error("discriminator: requires oneOf keyword");let c=t.let("valid",!1),u=t.const("tag",Wc._`${r}${Wc.getProperty(a)}`);t.if(Wc._`typeof ${u} == "string"`,()=>d(),()=>e.error(!1,{discrError:aw.DiscrError.Tag,tag:u,tagName:a})),e.ok(c);function d(){let p=m();t.if(!1);for(let g in p)t.elseIf(Wc._`${u} === ${g}`),t.assign(c,f(p[g]));t.else(),e.error(!1,{discrError:aw.DiscrError.Mapping,tag:u,tagName:a}),t.endIf()}function f(p){let g=t.name("valid"),y=e.subschema({keyword:"oneOf",schemaProp:p},g);return e.mergeEvaluated(y,Wc.Name),g}function m(){var p;let g={},y=_(i),x=!0;for(let S=0;S<s.length;S++){let D=s[S];if((D===null||D===void 0?void 0:D.$ref)&&!o3e.schemaHasRulesButRef(D,o.self.RULES)){let C=D.$ref;if(D=$G.resolveRef.call(o.self,o.schemaEnv.root,o.baseId,C),D instanceof $G.SchemaEnv)D=D.schema;if(D===void 0)throw new i3e.default(o.opts.uriResolver,o.baseId,C)}let A=(p=D===null||D===void 0?void 0:D.properties)===null||p===void 0?void 0:p[a];if(typeof A!="object")throw Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${a}"`);x=x&&(y||_(D)),v(A,S)}if(!x)throw Error(`discriminator: "${a}" must be required`);return g;function _({required:S}){return Array.isArray(S)&&S.includes(a)}function v(S,D){if(S.const)E(S.const,D);else if(S.enum)for(let A of S.enum)E(A,D);else throw Error(`discriminator: "properties/${a}" must have "const" or "enum"`)}function E(S,D){if(typeof S!="string"||S in g)throw Error(`discriminator: "${a}" values must be unique strings`);g[S]=D}}}};CG.default=a3e});var OG=h(function(Uot,l3e){l3e.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 AG=h(function(Tr,cw){Object.defineProperty(Tr,"__esModule",{value:!0});Tr.MissingRefError=Tr.ValidationError=Tr.CodeGen=Tr.Name=Tr.nil=Tr.stringify=Tr.str=Tr._=Tr.KeywordCxt=Tr.Ajv=void 0;var u3e=PU(),d3e=vG(),f3e=RG(),kG=OG(),p3e=["/properties"],s0="http://json-schema.org/draft-07/schema";class jd extends u3e.default{_addVocabularies(){if(super._addVocabularies(),d3e.default.forEach((e)=>this.addVocabulary(e)),this.opts.discriminator)this.addKeyword(f3e.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let e=this.opts.$data?this.$dataMetaSchema(kG,p3e):kG;this.addMetaSchema(e,s0,!1),this.refs["http://json-schema.org/schema"]=s0}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(s0)?s0:void 0)}}Tr.Ajv=jd;cw.exports=Tr=jd;cw.exports.Ajv=jd;Object.defineProperty(Tr,"__esModule",{value:!0});Tr.default=jd;var m3e=$d();Object.defineProperty(Tr,"KeywordCxt",{enumerable:!0,get:function(){return m3e.KeywordCxt}});var Kc=be();Object.defineProperty(Tr,"_",{enumerable:!0,get:function(){return Kc._}});Object.defineProperty(Tr,"str",{enumerable:!0,get:function(){return Kc.str}});Object.defineProperty(Tr,"stringify",{enumerable:!0,get:function(){return Kc.stringify}});Object.defineProperty(Tr,"nil",{enumerable:!0,get:function(){return Kc.nil}});Object.defineProperty(Tr,"Name",{enumerable:!0,get:function(){return Kc.Name}});Object.defineProperty(Tr,"CodeGen",{enumerable:!0,get:function(){return Kc.CodeGen}});var h3e=Uh();Object.defineProperty(Tr,"ValidationError",{enumerable:!0,get:function(){return h3e.default}});var g3e=Cd();Object.defineProperty(Tr,"MissingRefError",{enumerable:!0,get:function(){return g3e.default}})});var PG=h(function(FG){Object.defineProperty(FG,"__esModule",{value:!0});FG.formatLimitDefinition=void 0;var b3e=AG(),Mn=be(),is=Mn.operators,a0={formatMaximum:{okStr:"<=",ok:is.LTE,fail:is.GT},formatMinimum:{okStr:">=",ok:is.GTE,fail:is.LT},formatExclusiveMaximum:{okStr:"<",ok:is.LT,fail:is.GTE},formatExclusiveMinimum:{okStr:">",ok:is.GT,fail:is.LTE}},_3e={message:({keyword:e,schemaCode:t})=>Mn.str`should be ${a0[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>Mn._`{comparison: ${a0[e].okStr}, limit: ${t}}`};FG.formatLimitDefinition={keyword:Object.keys(a0),type:"string",schemaType:"string",$data:!0,error:_3e,code(e){let{gen:t,data:r,schemaCode:n,keyword:i,it:o}=e,{opts:s,self:a}=o;if(!s.validateFormats)return;let c=new b3e.KeywordCxt(o,a.RULES.all.format.definition,"format");if(c.$data)u();else d();function u(){let m=t.scopeValue("formats",{ref:a.formats,code:s.code.formats}),p=t.const("fmt",Mn._`${m}[${c.schemaCode}]`);e.fail$data(Mn.or(Mn._`typeof ${p} != "object"`,Mn._`${p} instanceof RegExp`,Mn._`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:s.code.formats?Mn._`${s.code.formats}${Mn.getProperty(m)}`:void 0});e.fail$data(f(g))}function f(m){return Mn._`${m}.compare(${r}, ${n}) ${a0[i].fail} 0`}},dependencies:["format"]};var v3e=(e)=>(e.addKeyword(FG.formatLimitDefinition),e);FG.default=v3e});var qG=h(function(Md,NG){Object.defineProperty(Md,"__esModule",{value:!0});var Yc=AB(),D3e=PG(),uw=be(),IG=new uw.Name("fullFormats"),E3e=new uw.Name("fastFormats"),dw=(e,t={keywords:!0})=>{if(Array.isArray(t))return TG(e,t,Yc.fullFormats,IG),e;let[r,n]=t.mode==="fast"?[Yc.fastFormats,E3e]:[Yc.fullFormats,IG],i=t.formats||Yc.formatNames;if(TG(e,i,r,n),t.keywords)(0,D3e.default)(e);return e};dw.get=(e,t="full")=>{let n=(t==="fast"?Yc.fastFormats:Yc.fullFormats)[e];if(!n)throw Error(`Unknown format "${e}"`);return n};function TG(e,t,r,n){var i,o;(i=(o=e.opts.code).formats)!==null&&i!==void 0||(o.formats=uw._`require("ajv-formats/dist/formats").${n}`);for(let s of t)e.addFormat(s,r[s])}NG.exports=Md=dw;Object.defineProperty(Md,"__esModule",{value:!0});Md.default=dw});var S3e=(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:o=!0}=t;if(r<0||n<0)throw RangeError("`wait` and `maxWait` must not be negative.");if(!i&&!o)throw Error("Both `before` and `after` are false, function wouldn't be called.");let s,a,c,u=function(...d){let f=this,m=()=>{if(s=void 0,a)clearTimeout(a),a=void 0;if(o)c=e.apply(f,d)},p=()=>{if(a=void 0,s)clearTimeout(s),s=void 0;if(o)c=e.apply(f,d)},g=i&&!s;if(clearTimeout(s),s=setTimeout(m,r),n>0&&n!==Number.POSITIVE_INFINITY&&!a)a=setTimeout(p,n);if(g)c=e.apply(f,d);return c};return Eu(u,e),u.cancel=()=>{if(s)clearTimeout(s),s=void 0;if(a)clearTimeout(a),a=void 0},u},fw;var jG=O(()=>{S_();fw=S3e});var Bd=h(function(est,MG){var $3e=Number.MAX_SAFE_INTEGER||9007199254740991,C3e=["major","premajor","minor","preminor","patch","prepatch","prerelease"];MG.exports={MAX_LENGTH:256,MAX_SAFE_COMPONENT_LENGTH:16,MAX_SAFE_BUILD_LENGTH:250,MAX_SAFE_INTEGER:$3e,RELEASE_TYPES:C3e,SEMVER_SPEC_VERSION:"2.0.0",FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2}});var Ld=h(function(tst,BG){var R3e=typeof process==="object"&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...e)=>console.error("SEMVER",...e):()=>{};BG.exports=R3e});var Jc=h(function(bi,LG){var{MAX_SAFE_COMPONENT_LENGTH:pw,MAX_SAFE_BUILD_LENGTH:O3e,MAX_LENGTH:k3e}=Bd(),A3e=Ld();bi=LG.exports={};var F3e=bi.re=[],P3e=bi.safeRe=[],V=bi.src=[],I3e=bi.safeSrc=[],G=bi.t={},T3e=0,mw="[a-zA-Z0-9-]",N3e=[["\\s",1],["\\d",k3e],[mw,O3e]],q3e=(e)=>{for(let[t,r]of N3e)e=e.split(`${t}*`).join(`${t}{0,${r}}`).split(`${t}+`).join(`${t}{1,${r}}`);return e},ue=(e,t,r)=>{let n=q3e(t),i=T3e++;A3e(e,i,t),G[e]=i,V[i]=t,I3e[i]=n,F3e[i]=new RegExp(t,r?"g":void 0),P3e[i]=new RegExp(n,r?"g":void 0)};ue("NUMERICIDENTIFIER","0|[1-9]\\d*");ue("NUMERICIDENTIFIERLOOSE","\\d+");ue("NONNUMERICIDENTIFIER",`\\d*[a-zA-Z-]${mw}*`);ue("MAINVERSION",`(${V[G.NUMERICIDENTIFIER]})\\.(${V[G.NUMERICIDENTIFIER]})\\.(${V[G.NUMERICIDENTIFIER]})`);ue("MAINVERSIONLOOSE",`(${V[G.NUMERICIDENTIFIERLOOSE]})\\.(${V[G.NUMERICIDENTIFIERLOOSE]})\\.(${V[G.NUMERICIDENTIFIERLOOSE]})`);ue("PRERELEASEIDENTIFIER",`(?:${V[G.NONNUMERICIDENTIFIER]}|${V[G.NUMERICIDENTIFIER]})`);ue("PRERELEASEIDENTIFIERLOOSE",`(?:${V[G.NONNUMERICIDENTIFIER]}|${V[G.NUMERICIDENTIFIERLOOSE]})`);ue("PRERELEASE",`(?:-(${V[G.PRERELEASEIDENTIFIER]}(?:\\.${V[G.PRERELEASEIDENTIFIER]})*))`);ue("PRERELEASELOOSE",`(?:-?(${V[G.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${V[G.PRERELEASEIDENTIFIERLOOSE]})*))`);ue("BUILDIDENTIFIER",`${mw}+`);ue("BUILD",`(?:\\+(${V[G.BUILDIDENTIFIER]}(?:\\.${V[G.BUILDIDENTIFIER]})*))`);ue("FULLPLAIN",`v?${V[G.MAINVERSION]}${V[G.PRERELEASE]}?${V[G.BUILD]}?`);ue("FULL",`^${V[G.FULLPLAIN]}$`);ue("LOOSEPLAIN",`[v=\\s]*${V[G.MAINVERSIONLOOSE]}${V[G.PRERELEASELOOSE]}?${V[G.BUILD]}?`);ue("LOOSE",`^${V[G.LOOSEPLAIN]}$`);ue("GTLT","((?:<|>)?=?)");ue("XRANGEIDENTIFIERLOOSE",`${V[G.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);ue("XRANGEIDENTIFIER",`${V[G.NUMERICIDENTIFIER]}|x|X|\\*`);ue("XRANGEPLAIN",`[v=\\s]*(${V[G.XRANGEIDENTIFIER]})(?:\\.(${V[G.XRANGEIDENTIFIER]})(?:\\.(${V[G.XRANGEIDENTIFIER]})(?:${V[G.PRERELEASE]})?${V[G.BUILD]}?)?)?`);ue("XRANGEPLAINLOOSE",`[v=\\s]*(${V[G.XRANGEIDENTIFIERLOOSE]})(?:\\.(${V[G.XRANGEIDENTIFIERLOOSE]})(?:\\.(${V[G.XRANGEIDENTIFIERLOOSE]})(?:${V[G.PRERELEASELOOSE]})?${V[G.BUILD]}?)?)?`);ue("XRANGE",`^${V[G.GTLT]}\\s*${V[G.XRANGEPLAIN]}$`);ue("XRANGELOOSE",`^${V[G.GTLT]}\\s*${V[G.XRANGEPLAINLOOSE]}$`);ue("COERCEPLAIN",`(^|[^\\d])(\\d{1,${pw}})(?:\\.(\\d{1,${pw}}))?(?:\\.(\\d{1,${pw}}))?`);ue("COERCE",`${V[G.COERCEPLAIN]}(?:$|[^\\d])`);ue("COERCEFULL",V[G.COERCEPLAIN]+`(?:${V[G.PRERELEASE]})?(?:${V[G.BUILD]})?(?:$|[^\\d])`);ue("COERCERTL",V[G.COERCE],!0);ue("COERCERTLFULL",V[G.COERCEFULL],!0);ue("LONETILDE","(?:~>?)");ue("TILDETRIM",`(\\s*)${V[G.LONETILDE]}\\s+`,!0);bi.tildeTrimReplace="$1~";ue("TILDE",`^${V[G.LONETILDE]}${V[G.XRANGEPLAIN]}$`);ue("TILDELOOSE",`^${V[G.LONETILDE]}${V[G.XRANGEPLAINLOOSE]}$`);ue("LONECARET","(?:\\^)");ue("CARETTRIM",`(\\s*)${V[G.LONECARET]}\\s+`,!0);bi.caretTrimReplace="$1^";ue("CARET",`^${V[G.LONECARET]}${V[G.XRANGEPLAIN]}$`);ue("CARETLOOSE",`^${V[G.LONECARET]}${V[G.XRANGEPLAINLOOSE]}$`);ue("COMPARATORLOOSE",`^${V[G.GTLT]}\\s*(${V[G.LOOSEPLAIN]})$|^$`);ue("COMPARATOR",`^${V[G.GTLT]}\\s*(${V[G.FULLPLAIN]})$|^$`);ue("COMPARATORTRIM",`(\\s*)${V[G.GTLT]}\\s*(${V[G.LOOSEPLAIN]}|${V[G.XRANGEPLAIN]})`,!0);bi.comparatorTrimReplace="$1$2$3";ue("HYPHENRANGE",`^\\s*(${V[G.XRANGEPLAIN]})\\s+-\\s+(${V[G.XRANGEPLAIN]})\\s*$`);ue("HYPHENRANGELOOSE",`^\\s*(${V[G.XRANGEPLAINLOOSE]})\\s+-\\s+(${V[G.XRANGEPLAINLOOSE]})\\s*$`);ue("STAR","(<|>)?=?\\s*\\*");ue("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$");ue("GTE0PRE","^\\s*>=\\s*0\\.0\\.0-0\\s*$")});var c0=h(function(rst,UG){var j3e=Object.freeze({loose:!0}),M3e=Object.freeze({}),B3e=(e)=>{if(!e)return M3e;if(typeof e!=="object")return j3e;return e};UG.exports=B3e});var hw=h(function(nst,zG){var VG=/^[0-9]+$/,GG=(e,t)=>{if(typeof e==="number"&&typeof t==="number")return e===t?0:e<t?-1:1;let r=VG.test(e),n=VG.test(t);if(r&&n)e=+e,t=+t;return e===t?0:r&&!n?-1:n&&!r?1:e<t?-1:1},L3e=(e,t)=>GG(t,e);zG.exports={compareIdentifiers:GG,rcompareIdentifiers:L3e}});var nr=h(function(ist,WG){var l0=Ld(),{MAX_LENGTH:HG,MAX_SAFE_INTEGER:u0}=Bd(),{safeRe:d0,t:f0}=Jc(),U3e=c0(),{compareIdentifiers:gw}=hw();class Bn{constructor(e,t){if(t=U3e(t),e instanceof Bn)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>HG)throw TypeError(`version is longer than ${HG} characters`);l0("SemVer",e,t),this.options=t,this.loose=!!t.loose,this.includePrerelease=!!t.includePrerelease;let r=e.trim().match(t.loose?d0[f0.LOOSE]:d0[f0.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>u0||this.major<0)throw TypeError("Invalid major version");if(this.minor>u0||this.minor<0)throw TypeError("Invalid minor version");if(this.patch>u0||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<u0)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(l0("SemVer.compare",this.version,this.options,e),!(e instanceof Bn)){if(typeof e==="string"&&e===this.version)return 0;e=new Bn(e,this.options)}if(e.version===this.version)return 0;return this.compareMain(e)||this.comparePre(e)}compareMain(e){if(!(e instanceof Bn))e=new Bn(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 Bn))e=new Bn(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(l0("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 gw(r,n)}while(++t)}compareBuild(e){if(!(e instanceof Bn))e=new Bn(e,this.options);let t=0;do{let r=this.build[t],n=e.build[t];if(l0("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 gw(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?d0[f0.PRERELEASELOOSE]:d0[f0.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(gw(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}}WG.exports=Bn});var Zs=h(function(ost,YG){var KG=nr(),V3e=(e,t,r=!1)=>{if(e instanceof KG)return e;try{return new KG(e,t)}catch(n){if(!r)return null;throw n}};YG.exports=V3e});var XG=h(function(sst,JG){var G3e=Zs(),z3e=(e,t)=>{let r=G3e(e,t);return r?r.version:null};JG.exports=z3e});var ZG=h(function(ast,QG){var H3e=Zs(),W3e=(e,t)=>{let r=H3e(e.trim().replace(/^[=v]+/,""),t);return r?r.version:null};QG.exports=W3e});var rz=h(function(cst,tz){var ez=nr(),K3e=(e,t,r,n,i)=>{if(typeof r==="string")i=n,n=r,r=void 0;try{return new ez(e instanceof ez?e.version:e,r).inc(t,n,i).version}catch(o){return null}};tz.exports=K3e});var oz=h(function(lst,iz){var nz=Zs(),Y3e=(e,t)=>{let r=nz(e,null,!0),n=nz(t,null,!0),i=r.compare(n);if(i===0)return null;let o=i>0,s=o?r:n,a=o?n:r,c=!!s.prerelease.length;if(!!a.prerelease.length&&!c){if(!a.patch&&!a.minor)return"major";if(a.compareMain(s)===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"};iz.exports=Y3e});var az=h(function(ust,sz){var J3e=nr(),X3e=(e,t)=>new J3e(e,t).major;sz.exports=X3e});var lz=h(function(dst,cz){var Q3e=nr(),Z3e=(e,t)=>new Q3e(e,t).minor;cz.exports=Z3e});var dz=h(function(fst,uz){var e5e=nr(),t5e=(e,t)=>new e5e(e,t).patch;uz.exports=t5e});var pz=h(function(pst,fz){var r5e=Zs(),n5e=(e,t)=>{let r=r5e(e,t);return r&&r.prerelease.length?r.prerelease:null};fz.exports=n5e});var fn=h(function(mst,hz){var mz=nr(),i5e=(e,t,r)=>new mz(e,r).compare(new mz(t,r));hz.exports=i5e});var yz=h(function(hst,gz){var o5e=fn(),s5e=(e,t,r)=>o5e(t,e,r);gz.exports=s5e});var bz=h(function(gst,xz){var a5e=fn(),c5e=(e,t)=>a5e(e,t,!0);xz.exports=c5e});var p0=h(function(yst,vz){var _z=nr(),l5e=(e,t,r)=>{let n=new _z(e,r),i=new _z(t,r);return n.compare(i)||n.compareBuild(i)};vz.exports=l5e});var Dz=h(function(xst,wz){var u5e=p0(),d5e=(e,t)=>e.sort((r,n)=>u5e(r,n,t));wz.exports=d5e});var Sz=h(function(bst,Ez){var f5e=p0(),p5e=(e,t)=>e.sort((r,n)=>f5e(n,r,t));Ez.exports=p5e});var Ud=h(function(_st,$z){var m5e=fn(),h5e=(e,t,r)=>m5e(e,t,r)>0;$z.exports=h5e});var m0=h(function(vst,Cz){var g5e=fn(),y5e=(e,t,r)=>g5e(e,t,r)<0;Cz.exports=y5e});var yw=h(function(wst,Rz){var x5e=fn(),b5e=(e,t,r)=>x5e(e,t,r)===0;Rz.exports=b5e});var xw=h(function(Dst,Oz){var _5e=fn(),v5e=(e,t,r)=>_5e(e,t,r)!==0;Oz.exports=v5e});var h0=h(function(Est,kz){var w5e=fn(),D5e=(e,t,r)=>w5e(e,t,r)>=0;kz.exports=D5e});var g0=h(function(Sst,Az){var E5e=fn(),S5e=(e,t,r)=>E5e(e,t,r)<=0;Az.exports=S5e});var bw=h(function($st,Fz){var $5e=yw(),C5e=xw(),R5e=Ud(),O5e=h0(),k5e=m0(),A5e=g0(),F5e=(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 $5e(e,r,n);case"!=":return C5e(e,r,n);case">":return R5e(e,r,n);case">=":return O5e(e,r,n);case"<":return k5e(e,r,n);case"<=":return A5e(e,r,n);default:throw TypeError(`Invalid operator: ${t}`)}};Fz.exports=F5e});var Iz=h(function(Cst,Pz){var P5e=nr(),I5e=Zs(),{safeRe:y0,t:x0}=Jc(),T5e=(e,t)=>{if(e instanceof P5e)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?y0[x0.COERCEFULL]:y0[x0.COERCE]);else{let c=t.includePrerelease?y0[x0.COERCERTLFULL]:y0[x0.COERCERTL],u;while((u=c.exec(e))&&(!r||r.index+r[0].length!==e.length)){if(!r||u.index+u[0].length!==r.index+r[0].length)r=u;c.lastIndex=u.index+u[1].length+u[2].length}c.lastIndex=-1}if(r===null)return null;let n=r[2],i=r[3]||"0",o=r[4]||"0",s=t.includePrerelease&&r[5]?`-${r[5]}`:"",a=t.includePrerelease&&r[6]?`+${r[6]}`:"";return I5e(`${n}.${i}.${o}${s}${a}`,t)};Pz.exports=T5e});var qz=h(function(Rst,Nz){class Tz{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}}Nz.exports=Tz});var pn=h(function(Ost,Lz){var N5e=/\s+/g;class Vd{constructor(e,t){if(t=j5e(t),e instanceof Vd)if(e.loose===!!t.loose&&e.includePrerelease===!!t.includePrerelease)return e;else return new Vd(e.raw,t);if(e instanceof _w)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(N5e," "),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)=>!Mz(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&&z5e(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&&V5e)|(this.options.loose&&G5e))+":"+e,n=jz.get(r);if(n)return n;let i=this.options.loose,o=i?gr[ir.HYPHENRANGELOOSE]:gr[ir.HYPHENRANGE];e=e.replace(o,tNe(this.options.includePrerelease)),ct("hyphen replace",e),e=e.replace(gr[ir.COMPARATORTRIM],B5e),ct("comparator trim",e),e=e.replace(gr[ir.TILDETRIM],L5e),ct("tilde trim",e),e=e.replace(gr[ir.CARETTRIM],U5e),ct("caret trim",e);let s=e.split(" ").map((d)=>H5e(d,this.options)).join(" ").split(/\s+/).map((d)=>eNe(d,this.options));if(i)s=s.filter((d)=>(ct("loose invalid filter",d,this.options),!!d.match(gr[ir.COMPARATORLOOSE])));ct("range list",s);let a=new Map,c=s.map((d)=>new _w(d,this.options));for(let d of c){if(Mz(d))return[d];a.set(d.value,d)}if(a.size>1&&a.has(""))a.delete("");let u=[...a.values()];return jz.set(r,u),u}intersects(e,t){if(!(e instanceof Vd))throw TypeError("a Range is required");return this.set.some((r)=>Bz(r,t)&&e.set.some((n)=>Bz(n,t)&&r.every((i)=>n.every((o)=>i.intersects(o,t)))))}test(e){if(!e)return!1;if(typeof e==="string")try{e=new M5e(e,this.options)}catch(t){return!1}for(let t=0;t<this.set.length;t++)if(rNe(this.set[t],e,this.options))return!0;return!1}}Lz.exports=Vd;var q5e=qz(),jz=new q5e,j5e=c0(),_w=Gd(),ct=Ld(),M5e=nr(),{safeRe:gr,t:ir,comparatorTrimReplace:B5e,tildeTrimReplace:L5e,caretTrimReplace:U5e}=Jc(),{FLAG_INCLUDE_PRERELEASE:V5e,FLAG_LOOSE:G5e}=Bd(),Mz=(e)=>e.value==="<0.0.0-0",z5e=(e)=>e.value==="",Bz=(e,t)=>{let r=!0,n=e.slice(),i=n.pop();while(r&&n.length)r=n.every((o)=>i.intersects(o,t)),i=n.pop();return r},H5e=(e,t)=>(e=e.replace(gr[ir.BUILD],""),ct("comp",e,t),e=Y5e(e,t),ct("caret",e),e=W5e(e,t),ct("tildes",e),e=X5e(e,t),ct("xrange",e),e=Z5e(e,t),ct("stars",e),e),yr=(e)=>!e||e.toLowerCase()==="x"||e==="*",W5e=(e,t)=>e.trim().split(/\s+/).map((r)=>K5e(r,t)).join(" "),K5e=(e,t)=>{let r=t.loose?gr[ir.TILDELOOSE]:gr[ir.TILDE];return e.replace(r,(n,i,o,s,a)=>{ct("tilde",e,n,i,o,s,a);let c;if(yr(i))c="";else if(yr(o))c=`>=${i}.0.0 <${+i+1}.0.0-0`;else if(yr(s))c=`>=${i}.${o}.0 <${i}.${+o+1}.0-0`;else if(a)ct("replaceTilde pr",a),c=`>=${i}.${o}.${s}-${a} <${i}.${+o+1}.0-0`;else c=`>=${i}.${o}.${s} <${i}.${+o+1}.0-0`;return ct("tilde return",c),c})},Y5e=(e,t)=>e.trim().split(/\s+/).map((r)=>J5e(r,t)).join(" "),J5e=(e,t)=>{ct("caret",e,t);let r=t.loose?gr[ir.CARETLOOSE]:gr[ir.CARET],n=t.includePrerelease?"-0":"";return e.replace(r,(i,o,s,a,c)=>{ct("caret",e,i,o,s,a,c);let u;if(yr(o))u="";else if(yr(s))u=`>=${o}.0.0${n} <${+o+1}.0.0-0`;else if(yr(a))if(o==="0")u=`>=${o}.${s}.0${n} <${o}.${+s+1}.0-0`;else u=`>=${o}.${s}.0${n} <${+o+1}.0.0-0`;else if(c)if(ct("replaceCaret pr",c),o==="0")if(s==="0")u=`>=${o}.${s}.${a}-${c} <${o}.${s}.${+a+1}-0`;else u=`>=${o}.${s}.${a}-${c} <${o}.${+s+1}.0-0`;else u=`>=${o}.${s}.${a}-${c} <${+o+1}.0.0-0`;else if(ct("no pr"),o==="0")if(s==="0")u=`>=${o}.${s}.${a}${n} <${o}.${s}.${+a+1}-0`;else u=`>=${o}.${s}.${a}${n} <${o}.${+s+1}.0-0`;else u=`>=${o}.${s}.${a} <${+o+1}.0.0-0`;return ct("caret return",u),u})},X5e=(e,t)=>(ct("replaceXRanges",e,t),e.split(/\s+/).map((r)=>Q5e(r,t)).join(" ")),Q5e=(e,t)=>{e=e.trim();let r=t.loose?gr[ir.XRANGELOOSE]:gr[ir.XRANGE];return e.replace(r,(n,i,o,s,a,c)=>{ct("xRange",e,n,i,o,s,a,c);let u=yr(o),d=u||yr(s),f=d||yr(a),m=f;if(i==="="&&m)i="";if(c=t.includePrerelease?"-0":"",u)if(i===">"||i==="<")n="<0.0.0-0";else n="*";else if(i&&m){if(d)s=0;if(a=0,i===">")if(i=">=",d)o=+o+1,s=0,a=0;else s=+s+1,a=0;else if(i==="<=")if(i="<",d)o=+o+1;else s=+s+1;if(i==="<")c="-0";n=`${i+o}.${s}.${a}${c}`}else if(d)n=`>=${o}.0.0${c} <${+o+1}.0.0-0`;else if(f)n=`>=${o}.${s}.0${c} <${o}.${+s+1}.0-0`;return ct("xRange return",n),n})},Z5e=(e,t)=>(ct("replaceStars",e,t),e.trim().replace(gr[ir.STAR],"")),eNe=(e,t)=>(ct("replaceGTE0",e,t),e.trim().replace(gr[t.includePrerelease?ir.GTE0PRE:ir.GTE0],"")),tNe=(e)=>(t,r,n,i,o,s,a,c,u,d,f,m)=>{if(yr(n))r="";else if(yr(i))r=`>=${n}.0.0${e?"-0":""}`;else if(yr(o))r=`>=${n}.${i}.0${e?"-0":""}`;else if(s)r=`>=${r}`;else r=`>=${r}${e?"-0":""}`;if(yr(u))c="";else if(yr(d))c=`<${+u+1}.0.0-0`;else if(yr(f))c=`<${u}.${+d+1}.0-0`;else if(m)c=`<=${u}.${d}.${f}-${m}`;else if(e)c=`<${u}.${d}.${+f+1}-0`;else c=`<=${c}`;return`${r} ${c}`.trim()},rNe=(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(ct(e[n].semver),e[n].semver===_w.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 Gd=h(function(kst,Wz){var zd=Symbol("SemVer ANY");class b0{static get ANY(){return zd}constructor(e,t){if(t=Uz(t),e instanceof b0)if(e.loose===!!t.loose)return e;else e=e.value;if(e=e.trim().split(/\s+/).join(" "),ww("comparator",e,t),this.options=t,this.loose=!!t.loose,this.parse(e),this.semver===zd)this.value="";else this.value=this.operator+this.semver.version;ww("comp",this)}parse(e){let t=this.options.loose?Vz[Gz.COMPARATORLOOSE]:Vz[Gz.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=zd;else this.semver=new zz(r[2],this.options.loose)}toString(){return this.value}test(e){if(ww("Comparator.test",e,this.options.loose),this.semver===zd||e===zd)return!0;if(typeof e==="string")try{e=new zz(e,this.options)}catch(t){return!1}return vw(e,this.operator,this.semver,this.options)}intersects(e,t){if(!(e instanceof b0))throw TypeError("a Comparator is required");if(this.operator===""){if(this.value==="")return!0;return new Hz(e.value,t).test(this.value)}else if(e.operator===""){if(e.value==="")return!0;return new Hz(this.value,t).test(e.semver)}if(t=Uz(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(vw(this.semver,"<",e.semver,t)&&this.operator.startsWith(">")&&e.operator.startsWith("<"))return!0;if(vw(this.semver,">",e.semver,t)&&this.operator.startsWith("<")&&e.operator.startsWith(">"))return!0;return!1}}Wz.exports=b0;var Uz=c0(),{safeRe:Vz,t:Gz}=Jc(),vw=bw(),ww=Ld(),zz=nr(),Hz=pn()});var Hd=h(function(Ast,Kz){var nNe=pn(),iNe=(e,t,r)=>{try{t=new nNe(t,r)}catch(n){return!1}return t.test(e)};Kz.exports=iNe});var Jz=h(function(Fst,Yz){var oNe=pn(),sNe=(e,t)=>new oNe(e,t).set.map((r)=>r.map((n)=>n.value).join(" ").trim().split(" "));Yz.exports=sNe});var Qz=h(function(Pst,Xz){var aNe=nr(),cNe=pn(),lNe=(e,t,r)=>{let n=null,i=null,o=null;try{o=new cNe(t,r)}catch(s){return null}return e.forEach((s)=>{if(o.test(s)){if(!n||i.compare(s)===-1)n=s,i=new aNe(n,r)}}),n};Xz.exports=lNe});var eH=h(function(Ist,Zz){var uNe=nr(),dNe=pn(),fNe=(e,t,r)=>{let n=null,i=null,o=null;try{o=new dNe(t,r)}catch(s){return null}return e.forEach((s)=>{if(o.test(s)){if(!n||i.compare(s)===1)n=s,i=new uNe(n,r)}}),n};Zz.exports=fNe});var nH=h(function(Tst,rH){var Dw=nr(),pNe=pn(),tH=Ud(),mNe=(e,t)=>{e=new pNe(e,t);let r=new Dw("0.0.0");if(e.test(r))return r;if(r=new Dw("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],o=null;if(i.forEach((s)=>{let a=new Dw(s.semver.version);switch(s.operator){case">":if(a.prerelease.length===0)a.patch++;else a.prerelease.push(0);a.raw=a.format();case"":case">=":if(!o||tH(a,o))o=a;break;case"<":case"<=":break;default:throw Error(`Unexpected operation: ${s.operator}`)}}),o&&(!r||tH(r,o)))r=o}if(r&&e.test(r))return r;return null};rH.exports=mNe});var oH=h(function(Nst,iH){var hNe=pn(),gNe=(e,t)=>{try{return new hNe(e,t).range||"*"}catch(r){return null}};iH.exports=gNe});var _0=h(function(qst,lH){var yNe=nr(),cH=Gd(),{ANY:xNe}=cH,bNe=pn(),_Ne=Hd(),sH=Ud(),aH=m0(),vNe=g0(),wNe=h0(),DNe=(e,t,r,n)=>{e=new yNe(e,n),t=new bNe(t,n);let i,o,s,a,c;switch(r){case">":i=sH,o=vNe,s=aH,a=">",c=">=";break;case"<":i=aH,o=wNe,s=sH,a="<",c="<=";break;default:throw TypeError('Must provide a hilo val of "<" or ">"')}if(_Ne(e,t,n))return!1;for(let u=0;u<t.set.length;++u){let d=t.set[u],f=null,m=null;if(d.forEach((p)=>{if(p.semver===xNe)p=new cH(">=0.0.0");if(f=f||p,m=m||p,i(p.semver,f.semver,n))f=p;else if(s(p.semver,m.semver,n))m=p}),f.operator===a||f.operator===c)return!1;if((!m.operator||m.operator===a)&&o(e,m.semver))return!1;else if(m.operator===c&&s(e,m.semver))return!1}return!0};lH.exports=DNe});var dH=h(function(jst,uH){var ENe=_0(),SNe=(e,t,r)=>ENe(e,t,">",r);uH.exports=SNe});var pH=h(function(Mst,fH){var $Ne=_0(),CNe=(e,t,r)=>$Ne(e,t,"<",r);fH.exports=CNe});var gH=h(function(Bst,hH){var mH=pn(),RNe=(e,t,r)=>(e=new mH(e,r),t=new mH(t,r),e.intersects(t,r));hH.exports=RNe});var xH=h(function(Lst,yH){var ONe=Hd(),kNe=fn();yH.exports=(e,t,r)=>{let n=[],i=null,o=null,s=e.sort((d,f)=>kNe(d,f,r));for(let d of s)if(ONe(d,t,r)){if(o=d,!i)i=d}else{if(o)n.push([i,o]);o=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===s[0])a.push("*");else if(!f)a.push(`>=${d}`);else if(d===s[0])a.push(`<=${f}`);else a.push(`${d} - ${f}`);let c=a.join(" || "),u=typeof t.raw==="string"?t.raw:String(t);return c.length<u.length?c:t}});var EH=h(function(Ust,DH){var bH=pn(),Sw=Gd(),{ANY:Ew}=Sw,Wd=Hd(),$w=fn(),ANe=(e,t,r={})=>{if(e===t)return!0;e=new bH(e,r),t=new bH(t,r);let n=!1;e:for(let i of e.set){for(let o of t.set){let s=PNe(i,o,r);if(n=n||s!==null,s)continue e}if(n)return!1}return!0},FNe=[new Sw(">=0.0.0-0")],_H=[new Sw(">=0.0.0")],PNe=(e,t,r)=>{if(e===t)return!0;if(e.length===1&&e[0].semver===Ew)if(t.length===1&&t[0].semver===Ew)return!0;else if(r.includePrerelease)e=FNe;else e=_H;if(t.length===1&&t[0].semver===Ew)if(r.includePrerelease)return!0;else t=_H;let n=new Set,i,o;for(let p of e)if(p.operator===">"||p.operator===">=")i=vH(i,p,r);else if(p.operator==="<"||p.operator==="<=")o=wH(o,p,r);else n.add(p.semver);if(n.size>1)return null;let s;if(i&&o){if(s=$w(i.semver,o.semver,r),s>0)return null;else if(s===0&&(i.operator!==">="||o.operator!=="<="))return null}for(let p of n){if(i&&!Wd(p,String(i),r))return null;if(o&&!Wd(p,String(o),r))return null;for(let g of t)if(!Wd(p,String(g),r))return!1;return!0}let a,c,u,d,f=o&&!r.includePrerelease&&o.semver.prerelease.length?o.semver:!1,m=i&&!r.includePrerelease&&i.semver.prerelease.length?i.semver:!1;if(f&&f.prerelease.length===1&&o.operator==="<"&&f.prerelease[0]===0)f=!1;for(let p of t){if(d=d||p.operator===">"||p.operator===">=",u=u||p.operator==="<"||p.operator==="<=",i){if(m){if(p.semver.prerelease&&p.semver.prerelease.length&&p.semver.major===m.major&&p.semver.minor===m.minor&&p.semver.patch===m.patch)m=!1}if(p.operator===">"||p.operator===">="){if(a=vH(i,p,r),a===p&&a!==i)return!1}else if(i.operator===">="&&!Wd(i.semver,String(p),r))return!1}if(o){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=wH(o,p,r),c===p&&c!==o)return!1}else if(o.operator==="<="&&!Wd(o.semver,String(p),r))return!1}if(!p.operator&&(o||i)&&s!==0)return!1}if(i&&u&&!o&&s!==0)return!1;if(o&&d&&!i&&s!==0)return!1;if(m||f)return!1;return!0},vH=(e,t,r)=>{if(!e)return t;let n=$w(e.semver,t.semver,r);return n>0?e:n<0?t:t.operator===">"&&e.operator===">="?t:e},wH=(e,t,r)=>{if(!e)return t;let n=$w(e.semver,t.semver,r);return n<0?e:n>0?t:t.operator==="<"&&e.operator==="<="?t:e};DH.exports=ANe});var RH=h(function(Vst,CH){var Cw=Jc(),SH=Bd(),INe=nr(),$H=hw(),TNe=Zs(),NNe=XG(),qNe=ZG(),jNe=rz(),MNe=oz(),BNe=az(),LNe=lz(),UNe=dz(),VNe=pz(),GNe=fn(),zNe=yz(),HNe=bz(),WNe=p0(),KNe=Dz(),YNe=Sz(),JNe=Ud(),XNe=m0(),QNe=yw(),ZNe=xw(),eqe=h0(),tqe=g0(),rqe=bw(),nqe=Iz(),iqe=Gd(),oqe=pn(),sqe=Hd(),aqe=Jz(),cqe=Qz(),lqe=eH(),uqe=nH(),dqe=oH(),fqe=_0(),pqe=dH(),mqe=pH(),hqe=gH(),gqe=xH(),yqe=EH();CH.exports={parse:TNe,valid:NNe,clean:qNe,inc:jNe,diff:MNe,major:BNe,minor:LNe,patch:UNe,prerelease:VNe,compare:GNe,rcompare:zNe,compareLoose:HNe,compareBuild:WNe,sort:KNe,rsort:YNe,gt:JNe,lt:XNe,eq:QNe,neq:ZNe,gte:eqe,lte:tqe,cmp:rqe,coerce:nqe,Comparator:iqe,Range:oqe,satisfies:sqe,toComparators:aqe,maxSatisfying:cqe,minSatisfying:lqe,minVersion:uqe,validRange:dqe,outside:fqe,gtr:pqe,ltr:mqe,intersects:hqe,simplifyRange:gqe,subset:yqe,SemVer:INe,re:Cw.re,src:Cw.src,tokens:Cw.t,SEMVER_SPEC_VERSION:SH.SEMVER_SPEC_VERSION,RELEASE_TYPES:SH.RELEASE_TYPES,compareIdentifiers:$H.compareIdentifiers,rcompareIdentifiers:$H.rcompareIdentifiers}});function kH(e,t,r){if(!e)return!1;if(e.constructor===t)return!0;return xqe.call(e)===r}function AH(e){return kH(e,Uint8Array,"[object Uint8Array]")}function bqe(e){return kH(e,ArrayBuffer,"[object ArrayBuffer]")}function _qe(e){return AH(e)||bqe(e)}function vqe(e){if(!AH(e))throw TypeError(`Expected \`Uint8Array\`, got \`${typeof e}\``)}function wqe(e){if(!_qe(e))throw TypeError(`Expected \`Uint8Array\` or \`ArrayBuffer\`, got \`${typeof e}\``)}function Rw(e,t){if(e.length===0)return new Uint8Array(0);t??=e.reduce((i,o)=>i+o.length,0);let r=new Uint8Array(t),n=0;for(let i of e)vqe(i),r.set(i,n),n+=i.length;return r}function Ow(e,t="utf8"){return wqe(e),OH[t]??=new globalThis.TextDecoder(t),OH[t].decode(e)}function Dqe(e){if(typeof e!=="string")throw TypeError(`Expected \`string\`, got \`${typeof e}\``)}function v0(e){return Dqe(e),Eqe.encode(e)}var xqe,OH,Eqe,Gst;var FH=O(()=>{xqe=Object.prototype.toString;OH={utf8:new globalThis.TextDecoder("utf8")};Eqe=new globalThis.TextEncoder;Gst=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"))});import{isDeepStrictEqual as Sqe}from"util";import PH from"process";import ea from"fs";import IH from"path";import Kd from"crypto";import $qe from"assert";var NH,qH,ta,Cqe,TH="aes-256-cbc",Xc=()=>Object.create(null),Rqe=(e)=>e!==void 0&&e!==null,Oqe=(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`)},w0="__internal__",kw,D0;var jH=O(()=>{HN();KN();Eq();jG();FH();NH=ce(vB(),1),qH=ce(qG(),1),ta=ce(RH(),1),Cqe=qH.default.default,kw=`${w0}.migrations.version`;D0=class D0{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=sv(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 o=new NH.Ajv2020({allErrors:!0,useDefaults:!0,...t.ajvOptions});Cqe(o);let s={...t.rootSchema,type:"object",properties:t.schema};this.#r=o.compile(s);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=IH.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{$qe.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 ${w0} key, as it's used to manage this module internal operations.`);let{store:r}=this,n=(i,o)=>{if(Oqe(i,o),this.#e.accessPropertiesByDotNotation)nv(r,i,o);else r[i]=o};if(typeof e==="object"){let i=e;for(let[o,s]of Object.entries(i))n(o,s)}else n(e,t);this.store=r}has(e){if(this.#e.accessPropertiesByDotNotation)return zN(this.store,e);return e in this.store}reset(...e){for(let t of e)if(Rqe(this.#i[t]))this.set(t,this.#i[t])}delete(e){let{store:t}=this;if(this.#e.accessPropertiesByDotNotation)GN(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=ea.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:Ow(e);try{let t=e.slice(0,16),r=Kd.pbkdf2Sync(this.#t,t.toString(),1e4,32,"sha512"),n=Kd.createDecipheriv(TH,r,t),i=e.slice(17),o=typeof i==="string"?v0(i):i;return Ow(Rw([n.update(o),n.final()]))}catch{}return e.toString()}_handleChange(e,t){let r=e(),n=()=>{let i=r,o=e();if(Sqe(o,i))return;r=o,t.call(this,o,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(){ea.mkdirSync(IH.dirname(this.path),{recursive:!0})}_write(e){let t=this._serialize(e);if(this.#t){let r=Kd.randomBytes(16),n=Kd.pbkdf2Sync(this.#t,r.toString(),1e4,32,"sha512"),i=Kd.createCipheriv(TH,n,r);t=Rw([r,v0(":"),i.update(v0(t)),i.final()])}if(PH.env.SNAP)ea.writeFileSync(this.path,t,{mode:this.#e.configFileMode});else try{yv(this.path,t,{mode:this.#e.configFileMode})}catch(r){if(r?.code==="EXDEV"){ea.writeFileSync(this.path,t,{mode:this.#e.configFileMode});return}throw r}}_watch(){if(this._ensureDirectory(),!ea.existsSync(this.path))this._write(Xc());if(PH.platform==="win32")ea.watch(this.path,{persistent:!1},fw(()=>{this.events.dispatchEvent(new Event("change"))},{wait:100}));else ea.watchFile(this.path,{persistent:!1},fw(()=>{this.events.dispatchEvent(new Event("change"))},{wait:5000}))}_migrate(e,t,r){let n=this._get(kw,"0.0.0"),i=Object.keys(e).filter((s)=>this._shouldPerformMigration(s,n,t)),o={...this.store};for(let s of i)try{if(r)r(this,{fromVersion:n,toVersion:s,finalVersion:t,versions:i});let a=e[s];a?.(this),this._set(kw,s),n=s,o={...this.store}}catch(a){throw this.store=o,Error(`Something went wrong during the migration! Changes applied to the store until this failed migration will be restored. ${a}`)}if(this._isVersionInRangeFormat(n)||!ta.default.eq(n,t))this._set(kw,t)}_containsReservedKey(e){if(typeof e==="object"){if(Object.keys(e)[0]===w0)return!0}if(typeof e!=="string")return!1;if(this.#e.accessPropertiesByDotNotation){if(e.startsWith(`${w0}.`))return!0;return!1}return!1}_isVersionInRangeFormat(e){return ta.default.clean(e)===null}_shouldPerformMigration(e,t,r){if(this._isVersionInRangeFormat(e)){if(t!=="0.0.0"&&ta.default.satisfies(t,e))return!1;return ta.default.satisfies(r,e)}if(ta.default.lte(e,t))return!1;if(ta.default.gt(e,r))return!1;return!0}_get(e,t){return VN(this.store,e,t)}_set(e,t){let{store:r}=this;nv(r,e,t),this.store=r}}});import{copyFileSync as kqe,existsSync as MH,mkdirSync as Aqe}from"fs";import{homedir as S0}from"os";import{join as Qc}from"path";function Pqe(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 Aw(){return process.env.NEMAR_CONFIG_DIR||Qc(S0(),".config","nemar")}function Tqe(e){if(process.env.NEMAR_CONFIG_DIR)return;let t=Qc(e,"config.json");if(MH(t))return;let r=[];if(process.platform==="darwin")r.push(Qc(S0(),"Library","Preferences","nemar-nodejs","config.json"));if(process.platform==="win32"){let n=process.env.APPDATA||Qc(S0(),"AppData","Roaming");r.push(Qc(n,"nemar-nodejs","config.json"))}r.push(Qc(S0(),".config","nemar-nodejs","config.json"));for(let n of r)if(MH(n))try{Aqe(e,{recursive:!0}),kqe(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 mn(){let e=Aw();if(E0&&BH===e)return E0;if(Tqe(e),E0=new D0({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}),BH=e,!LH.has(e))LH.add(e),qqe(),jqe();return E0}function qqe(){let e=mn(),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",o={};for(let s of Nqe){let a=e.get(s);if(a!==void 0)o[s]=a}e.store={activeAccount:i,accounts:{[i]:o}}}catch(i){console.error("Config migration failed (legacy config preserved):",i)}}function jqe(){let e=mn(),t=e.store,r=t.accounts,n=!1;if(r)for(let[o,s]of Object.entries(r)){let a=s?.apiUrl;if(!a)continue;if(Fqe.has(Pqe(a)))r[o]={...s,apiUrl:ra},console.error(`[nemar] migrated stored apiUrl for account "${o}": ${a} -> ${ra}`),n=!0}let i=t.apiUrl;if(r&&Object.keys(r).length>0&&i!==void 0){let{apiUrl:o,...s}=t;try{e.store=s,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(o){console.error("API URL migration failed (config file unchanged):",o)}}function Yd(){return mn().get("activeAccount")}function na(){return mn().get("accounts")||{}}function nt(){let e={apiUrl:ra},t=Yd();if(!t)return e;return na()[t]||e}function tt(e,t){let r=mn(),n=r.get("activeAccount")||"default",i=r.get("accounts")||{};if(!i[n])i[n]={apiUrl:ra};i[n][e]=t,r.store={...r.store,accounts:i,activeAccount:n}}function Jd(e){let t=Yd();if(!t)return;let r=na();if(r[t])delete r[t][e],mn().set("accounts",r)}function UH(){let e=mn(),t=Yd();if(!t){e.clear();return}let r=na();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 VH(){mn().clear()}function Be(){return!!nt().apiKey}function GH(){return mn().path}function Xd(){let e=na(),t=Yd();return Object.entries(e).map(([r,n])=>({username:n.username||r,email:n.email,githubUsername:n.githubUsername,active:r===t}))}function zH(e,t){let r=mn(),n=na();n[e]=t,r.store={...r.store,accounts:n,activeAccount:e}}function HH(e){let t=e.trim();if(!t)return"unchanged";let r=mn(),n=Yd();if(!n||n===t)return"unchanged";let i=na(),o=i[n];if(!o)return"unchanged";if(i[t])return"key_taken";return delete i[n],i[t]={...o,username:t},r.store={...r.store,accounts:i,activeAccount:t},"renamed"}function WH(e){let t=mn(),r=na();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 ra="https://api.nemar.org",Fqe,Iqe,lat,E0=null,BH=null,LH,Nqe;var _i=O(()=>{jH();Wi();Fqe=new Set(["https://api.osc.earth/nemar","https://nemar-api.neuromechanist.workers.dev","https://nemar-api-dev.shirazi-10f.workers.dev"]);Iqe=Xe({field:k(),blocks:ht(k()).optional(),set_on:ht(k()).optional()}).passthrough(),lat=Xe({apiKey:k().optional(),apiUrl:k().url().default(ra),username:k().optional(),email:k().email().optional(),githubUsername:k().optional(),sandboxCompleted:Vt().optional(),sandboxDatasetId:k().optional(),dismissedNoticeIds:ht(W()).optional(),serviceAccess:Vt().optional(),profileGaps:ht(Iqe).optional(),orcidVerified:Vt().optional(),role:k().optional(),pendingEmailChange:k().email().optional()});LH=new Set;Nqe=["apiKey","apiUrl","username","email","githubUsername","sandboxCompleted","sandboxDatasetId","dismissedNoticeIds"]});function N(e){if(e instanceof Error)return e.message;return String(e)}var q,os;var Nt=O(()=>{q=class q extends Error{statusCode;details;step;blockReason;missing;constructor(e,t,r,n,i,o){super(t);this.statusCode=e;this.details=r;this.step=n;this.blockReason=i;this.missing=o;this.name="ApiError"}};os=class os extends q{mode;eta;constructor(e,t,r,n){super(503,t,n);this.mode=e;this.eta=r;this.name="MaintenanceError"}}});function KH(e){Fw=e}function Pw(){return Fw}function Qd(e){if(Fw)process.stderr.write(`${e}
100
+ [nemar] You can manually copy ${n} to ${t}`)}}function mn(){let e=Aw();if(E0&&BH===e)return E0;if(Tqe(e),E0=new D0({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}),BH=e,!LH.has(e))LH.add(e),qqe(),jqe();return E0}function qqe(){let e=mn(),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",o={};for(let s of Nqe){let a=e.get(s);if(a!==void 0)o[s]=a}e.store={activeAccount:i,accounts:{[i]:o}}}catch(i){console.error("Config migration failed (legacy config preserved):",i)}}function jqe(){let e=mn(),t=e.store,r=t.accounts,n=!1;if(r)for(let[o,s]of Object.entries(r)){let a=s?.apiUrl;if(!a)continue;if(Fqe.has(Pqe(a)))r[o]={...s,apiUrl:ra},console.error(`[nemar] migrated stored apiUrl for account "${o}": ${a} -> ${ra}`),n=!0}let i=t.apiUrl;if(r&&Object.keys(r).length>0&&i!==void 0){let{apiUrl:o,...s}=t;try{e.store=s,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(o){console.error("API URL migration failed (config file unchanged):",o)}}function Yd(){return mn().get("activeAccount")}function na(){return mn().get("accounts")||{}}function nt(){let e={apiUrl:ra},t=Yd();if(!t)return e;return na()[t]||e}function tt(e,t){let r=mn(),n=r.get("activeAccount")||"default",i=r.get("accounts")||{};if(!i[n])i[n]={apiUrl:ra};i[n][e]=t,r.store={...r.store,accounts:i,activeAccount:n}}function Jd(e){let t=Yd();if(!t)return;let r=na();if(r[t])delete r[t][e],mn().set("accounts",r)}function UH(){let e=mn(),t=Yd();if(!t){e.clear();return}let r=na();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 VH(){mn().clear()}function Be(){return!!nt().apiKey}function GH(){return mn().path}function Xd(){let e=na(),t=Yd();return Object.entries(e).map(([r,n])=>({username:n.username||r,email:n.email,githubUsername:n.githubUsername,active:r===t}))}function zH(e,t){let r=mn(),n=na();n[e]=t,r.store={...r.store,accounts:n,activeAccount:e}}function HH(e){let t=e.trim();if(!t)return"unchanged";let r=mn(),n=Yd();if(!n||n===t)return"unchanged";let i=na(),o=i[n];if(!o)return"unchanged";if(i[t])return"key_taken";return delete i[n],i[t]={...o,username:t},r.store={...r.store,accounts:i,activeAccount:t},"renamed"}function WH(e){let t=mn(),r=na();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 ra="https://nemar-api-dev.sccn-org.workers.dev",Fqe,Iqe,lat,E0=null,BH=null,LH,Nqe;var _i=O(()=>{jH();Wi();Fqe=new Set(["https://api.osc.earth/nemar","https://nemar-api.neuromechanist.workers.dev","https://nemar-api-dev.shirazi-10f.workers.dev"]);Iqe=Xe({field:k(),blocks:ht(k()).optional(),set_on:ht(k()).optional()}).passthrough(),lat=Xe({apiKey:k().optional(),apiUrl:k().url().default(ra),username:k().optional(),email:k().email().optional(),githubUsername:k().optional(),sandboxCompleted:Vt().optional(),sandboxDatasetId:k().optional(),dismissedNoticeIds:ht(W()).optional(),serviceAccess:Vt().optional(),profileGaps:ht(Iqe).optional(),orcidVerified:Vt().optional(),role:k().optional(),pendingEmailChange:k().email().optional()});LH=new Set;Nqe=["apiKey","apiUrl","username","email","githubUsername","sandboxCompleted","sandboxDatasetId","dismissedNoticeIds"]});function N(e){if(e instanceof Error)return e.message;return String(e)}var q,os;var Nt=O(()=>{q=class q extends Error{statusCode;details;step;blockReason;missing;constructor(e,t,r,n,i,o){super(t);this.statusCode=e;this.details=r;this.step=n;this.blockReason=i;this.missing=o;this.name="ApiError"}};os=class os extends q{mode;eta;constructor(e,t,r,n){super(503,t,n);this.mode=e;this.eta=r;this.name="MaintenanceError"}}});function KH(e){Fw=e}function Pw(){return Fw}function Qd(e){if(Fw)process.stderr.write(`${e}
101
101
  `)}var Fw=!1;var{spawn:Mqe}=globalThis.Bun;async function R(e,t={}){let r={...process.env,GIT_TERMINAL_PROMPT:"0",...t.env};for(let u of t.unsetEnv??[])delete r[u];let n=Mqe({cmd:e,cwd:t.cwd,stdout:"pipe",stderr:"pipe",env:r}),i=!1,o;if(t.timeout)o=setTimeout(()=>{i=!0,n.kill()},t.timeout);if(Pw()){let u=t.cwd?` (cwd=${t.cwd})`:"";Qd(l.dim(`$ ${e.join(" ")}${u}`))}let s=await new Response(n.stdout).text(),a=await new Response(n.stderr).text(),c=await n.exited;if(o)clearTimeout(o);if(Pw()){if(s.trim())Qd(l.dim(s.trimEnd()));if(a.trim())Qd(l.yellow(a.trimEnd()));Qd(l.dim(`(exit ${c})`))}if(i)return{stdout:s,stderr:a||`Command timed out after ${Math.round(t.timeout/1000)}s`,exitCode:c??1,timedOut:!0};return{stdout:s,stderr:a,exitCode:c,timedOut:!1}}var or=O(()=>{Ke()});function Lqe(){if(process.platform==="darwin")return"macos";if(process.platform==="win32")return"windows";return"linux"}function JH(e,t=Lqe()){return e.installInstructions[t]}function Uqe(e){let t=e.match(/(\d+\.\d+(?:\.\d+)?)/);return t?t[1]:void 0}function Gqe(){let e=Number(process.env.TEST_PROBE_TIMEOUT_MS);return Number.isFinite(e)&&e>0?e:Vqe}async function XH(e){try{let{exitCode:t,stdout:r,timedOut:n}=await R(e.cmd,{timeout:Gqe()});if(n)return{available:!1,timedOut:!0};if(t!==0)return{available:!1};return{available:!0,version:Uqe(r)}}catch(t){let r=t instanceof Error?t.message:String(t);if(!r.includes("ENOENT")&&!r.includes("not found"))console.error(` Warning: ${e.name} check failed unexpectedly: ${r}`);return{available:!1}}}async function Zd(){let e=Object.entries(YH);return Promise.all(e.map(async([t,r])=>{let{available:n,version:i,timedOut:o}=await XH(r);return{key:t,name:r.name,purpose:r.purpose,required:r.required,available:n,version:i,timedOut:o,installInstruction:JH(r)}}))}async function QH(){let t=(await Zd()).filter((r)=>r.required&&!r.available);if(t.length===0)return[];console.warn(`
102
102
  Heads up: some tools NEMAR needs for uploading/validating aren't installed yet:`);for(let r of t)console.warn(` - ${r.name} (${r.purpose})`),console.warn(` Install: ${r.installInstruction}`);return console.warn("Run `nemar doctor` anytime to re-check. You can finish signup without them.\n"),t}async function ia(e){let r=Bqe[e].map((s)=>YH[s]).filter(Boolean),n=await Promise.all(r.map(async(s)=>{let a=await XH(s);return{check:s,available:a.available,timedOut:a.timedOut}}));for(let s of n)if(s.timedOut&&s.check.required)console.warn(`Warning: ${s.check.name} did not respond to a version check in time; continuing anyway.`);let i=n.filter((s)=>!s.available&&!s.timedOut&&s.check.required).map((s)=>({tool:s.check.name,installInstruction:JH(s.check)}));if(i.length===0)return;let o=[`
103
103
  Missing required tools:`];for(let s of i)o.push(` ${s.tool} not installed`),o.push(` Install: ${s.installInstruction}`);throw Error(o.join(`
104
- `))}var YH,Bqe,Vqe=4000;var ef=O(()=>{or();YH={git:{name:"git",purpose:"version control for dataset metadata",cmd:["git","--version"],required:!0,installInstructions:{macos:"brew install git (or install Xcode Command Line Tools)",linux:"sudo apt-get install git OR sudo dnf install git",windows:"winget install Git.Git (or https://git-scm.com/download/win)"}},"git-annex":{name:"git-annex",purpose:"large-file data transfer (upload/download)",cmd:["git-annex","version"],required:!0,installInstructions:{macos:"brew install git-annex",linux:"sudo apt-get install git-annex OR sudo dnf install git-annex",windows:"Download the installer from https://git-annex.branchable.com/install/Windows/"}},gh:{name:"GitHub CLI (gh)",purpose:"GitHub authentication + repository operations",cmd:["gh","--version"],required:!0,installInstructions:{macos:"brew install gh",linux:"See https://cli.github.com/manual/installation",windows:"winget install GitHub.cli (or: scoop install gh)"}},aws:{name:"AWS CLI",purpose:"S3 data upload/download",cmd:["aws","--version"],required:!0,installInstructions:{macos:"brew install awscli",linux:"pip install awscli OR sudo snap install aws-cli --classic",windows:"winget install Amazon.AWSCLI (or the MSI from https://aws.amazon.com/cli/)"}},deno:{name:"Deno",purpose:"BIDS validation",cmd:["deno","--version"],required:!0,installInstructions:{macos:"brew install deno (or: curl -fsSL https://deno.land/install.sh | sh)",linux:"curl -fsSL https://deno.land/install.sh | sh",windows:"winget install DenoLand.Deno (or: irm https://deno.land/install.ps1 | iex)"}}},Bqe={upload:["git-annex","gh","aws","deno"],download:["gh"],clone:["git","gh"],push:["git-annex","gh"],publish:["gh","aws"],update:["git","gh"],release:["git","gh"]}});var eW;var ZH=O(()=>{eW={name:"nemar-cli",version:"0.9.16",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/","migrations:d1-check":"bun run scripts/d1-migration-check.ts","lint:fix":"biome check --fix src/",format:"biome format --write src/",typecheck:"tsc --noEmit && tsc --noEmit -p backend","generate-openapi":"bun run scripts/generate-openapi.ts",prepublishOnly:"bun run build",prepare:"husky",postinstall:"bun scripts/postinstall-check.mjs",deploy:"wrangler deploy",preview:"wrangler dev"},keywords:["nemar","bids","neuroimaging","eeg","emg","datalad","cli"],author:"NEMAR Team",license:"CC-BY-NC-ND-4.0",repository:{type:"git",url:"git+https://github.com/nemarOrg/nemar-cli.git"},bugs:{url:"https://github.com/nemarOrg/nemar-cli/issues"},homepage:"https://docs.nemar.org",engines:{bun:">=1.0.0"},files:["dist","scripts/postinstall-check.mjs","scripts/recover-datasets.json","scripts/withdrawn-datasets.json","README.md","LICENSE"],dependencies:{chalk:"^5.3.0",commander:"^12.1.0",conf:"^13.0.1",inquirer:"^9.2.15",ora:"^8.0.1",semver:"^7.8.5",zod:"^3.23.8"},"lint-staged":{"src/**/*.{ts,tsx}":["biome check --fix"],"backend/src/**/*.{ts,tsx}":["biome check --fix"]},devDependencies:{"@asteasolutions/zod-to-openapi":"^7.3.4","@biomejs/biome":"1.9.4","@types/bun":"latest","@types/inquirer":"^9.0.7","@types/semver":"^7.8.0",ajv:"^8.20.0","ajv-formats":"^3.0.1",bcryptjs:"^3.0.3",husky:"^9.1.7","lint-staged":"^16.3.2",typescript:"^5.5.4",wrangler:"^4.70.0",yaml:"^2.8.4"}}});var io;var tf=O(()=>{ZH();io=eW.version});import{mkdirSync as Hqe,readdirSync as Wqe,unlinkSync as Kqe,writeFileSync as Yqe}from"fs";import{join as Iw}from"path";function oW(){Zc=!0}function oa(){return Zc}function sW(e,t=process.env){return e.includes("--debug")||t.NEMAR_DEBUG==="1"}function nf(e){iW=e,Ln(`Step: ${e}`)}function aW(){nW=!0}function cW(){return nW}function Ln(e){if(Zc)process.stderr.write(`[debug] ${e}
104
+ `))}var YH,Bqe,Vqe=4000;var ef=O(()=>{or();YH={git:{name:"git",purpose:"version control for dataset metadata",cmd:["git","--version"],required:!0,installInstructions:{macos:"brew install git (or install Xcode Command Line Tools)",linux:"sudo apt-get install git OR sudo dnf install git",windows:"winget install Git.Git (or https://git-scm.com/download/win)"}},"git-annex":{name:"git-annex",purpose:"large-file data transfer (upload/download)",cmd:["git-annex","version"],required:!0,installInstructions:{macos:"brew install git-annex",linux:"sudo apt-get install git-annex OR sudo dnf install git-annex",windows:"Download the installer from https://git-annex.branchable.com/install/Windows/"}},gh:{name:"GitHub CLI (gh)",purpose:"GitHub authentication + repository operations",cmd:["gh","--version"],required:!0,installInstructions:{macos:"brew install gh",linux:"See https://cli.github.com/manual/installation",windows:"winget install GitHub.cli (or: scoop install gh)"}},aws:{name:"AWS CLI",purpose:"S3 data upload/download",cmd:["aws","--version"],required:!0,installInstructions:{macos:"brew install awscli",linux:"pip install awscli OR sudo snap install aws-cli --classic",windows:"winget install Amazon.AWSCLI (or the MSI from https://aws.amazon.com/cli/)"}},deno:{name:"Deno",purpose:"BIDS validation",cmd:["deno","--version"],required:!0,installInstructions:{macos:"brew install deno (or: curl -fsSL https://deno.land/install.sh | sh)",linux:"curl -fsSL https://deno.land/install.sh | sh",windows:"winget install DenoLand.Deno (or: irm https://deno.land/install.ps1 | iex)"}}},Bqe={upload:["git-annex","gh","aws","deno"],download:["gh"],clone:["git","gh"],push:["git-annex","gh"],publish:["gh","aws"],update:["git","gh"],release:["git","gh"]}});var eW;var ZH=O(()=>{eW={name:"nemar-cli",version:"0.9.17-dev.2347",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/","migrations:d1-check":"bun run scripts/d1-migration-check.ts","lint:fix":"biome check --fix src/",format:"biome format --write src/",typecheck:"tsc --noEmit && tsc --noEmit -p backend","generate-openapi":"bun run scripts/generate-openapi.ts",prepublishOnly:"bun run build",prepare:"husky",postinstall:"bun scripts/postinstall-check.mjs",deploy:"wrangler deploy",preview:"wrangler dev"},keywords:["nemar","bids","neuroimaging","eeg","emg","datalad","cli"],author:"NEMAR Team",license:"CC-BY-NC-ND-4.0",repository:{type:"git",url:"git+https://github.com/nemarOrg/nemar-cli.git"},bugs:{url:"https://github.com/nemarOrg/nemar-cli/issues"},homepage:"https://docs.nemar.org",engines:{bun:">=1.0.0"},files:["dist","scripts/postinstall-check.mjs","scripts/recover-datasets.json","scripts/withdrawn-datasets.json","README.md","LICENSE"],dependencies:{chalk:"^5.3.0",commander:"^12.1.0",conf:"^13.0.1",inquirer:"^9.2.15",ora:"^8.0.1",semver:"^7.8.5",zod:"^3.23.8"},"lint-staged":{"src/**/*.{ts,tsx}":["biome check --fix"],"backend/src/**/*.{ts,tsx}":["biome check --fix"]},devDependencies:{"@asteasolutions/zod-to-openapi":"^7.3.4","@biomejs/biome":"1.9.4","@types/bun":"latest","@types/inquirer":"^9.0.7","@types/semver":"^7.8.0",ajv:"^8.20.0","ajv-formats":"^3.0.1",bcryptjs:"^3.0.3",husky:"^9.1.7","lint-staged":"^16.3.2",typescript:"^5.5.4",wrangler:"^4.70.0",yaml:"^2.8.4"}}});var io;var tf=O(()=>{ZH();io=eW.version});import{mkdirSync as Hqe,readdirSync as Wqe,unlinkSync as Kqe,writeFileSync as Yqe}from"fs";import{join as Iw}from"path";function oW(){Zc=!0}function oa(){return Zc}function sW(e,t=process.env){return e.includes("--debug")||t.NEMAR_DEBUG==="1"}function nf(e){iW=e,Ln(`Step: ${e}`)}function aW(){nW=!0}function cW(){return nW}function Ln(e){if(Zc)process.stderr.write(`[debug] ${e}
105
105
  `)}function Zqe(e){let t={};for(let[r,n]of Object.entries(e))t[r]=Qqe.has(r.toLowerCase())?"[REDACTED]":n;return t}function uW(e){let t=e.indexOf("@");if(t<=0)return"***";return`${e[0]}***${e.slice(t)}`}function Tw(e,t,r=0){if(r>t9e)return"[REDACTED: depth]";if(Array.isArray(t))return t.map((n)=>Tw(e,n,r+1));if(t&&typeof t==="object"){let n={};for(let[i,o]of Object.entries(t))n[i]=Tw(i,o,r+1);return n}if(typeof t==="string"){if(e9e.test(e))return"[REDACTED]";return t.replace(lW,uW)}return t}function Nw(e){return e.replace(r9e,"Bearer [REDACTED]").replace(n9e,"[REDACTED_AWS_KEY]").replace(i9e,"$1[REDACTED]").replace(o9e,"$1$2=[REDACTED]").replace(lW,uW)}function s9e(e){return Nw(e)}function tW(e,t=Xqe){if(e===void 0)return;let r=e;try{let n=JSON.parse(e);r=JSON.stringify(Tw("",n))}catch{}if(r=Nw(r),Buffer.byteLength(r,"utf8")>t)r=`${Buffer.from(r,"utf8").subarray(0,t).toString("utf8")}... [truncated]`;return r}function R0(e){if(!Zc)return;let t=s9e(e.url);try{let r={...e,url:t,requestHeaders:e.requestHeaders?Zqe(e.requestHeaders):void 0,requestBody:tW(e.requestBody),responseBody:tW(e.responseBody)};C0.push(r),Ln(`${e.method} ${t} -> ${e.status??"ERROR"} (${e.durationMs}ms)`)}catch(r){let n=N(r);C0.push({method:e.method,url:t,status:e.status,durationMs:e.durationMs,note:`redaction failed: ${n}`}),Ln(`redaction failed for ${e.method} ${t}: ${n}`)}}async function a9e(){let e=[];try{let t=process.versions.bun?`Bun ${process.versions.bun}`:`Node ${process.version}`;e.push(`CLI version: ${io}`),e.push(`OS/Arch: ${process.platform}/${process.arch}`),e.push(`Runtime: ${t}`)}catch(t){e.push(`(could not read CLI/OS/runtime info: ${N(t)})`)}e.push(""),e.push("Active account:");try{let t=nt();if(t.apiKey){if(t.username)e.push(` Username: ${t.username}`);if(e.push(` API URL: ${t.apiUrl}`),t.role)e.push(` Role: ${t.role}`);e.push(` Sandbox completed: ${!!t.sandboxCompleted}`)}else e.push(" (not authenticated)")}catch(t){e.push(` (could not read account config: ${N(t)})`)}e.push(""),e.push("External tools:");try{let t=await Zd();for(let r of t){let n=r.available?r.version??"installed":r.timedOut?"(timed out)":"not installed";e.push(` ${r.name}: ${n}`)}}catch(t){e.push(` (could not probe external tools: ${N(t)})`)}return e}async function qw(){return(await a9e()).join(`
106
106
  `)}async function dW(){if(!Zc||$0!==void 0)return;try{$0=await qw()}catch(e){let t=N(e);$0=`(could not build environment report: ${t})`,Ln(`environment snapshot failed: ${t}`)}}function fW(e){if(rW.has(e))return{flag:e};for(let t of rW){if(!e.startsWith(t)||e.length<=t.length)continue;if(t.length===2)return{flag:t,kind:"short-attached"};if(e[t.length]==="=")return{flag:t,kind:"long-eq"}}return null}function c9e(e){let t=[];for(let r=0;r<e.length;r++){let n=e[r],i=fW(n);if(!i){t.push(n);continue}if(i.kind==="long-eq")t.push(`${i.flag}=[REDACTED]`);else if(i.kind==="short-attached")t.push(`${i.flag}[REDACTED]`);else if(t.push(n),r+1<e.length)t.push("[REDACTED]"),r++}return t}function l9e(e){let t=[];for(let r=0;r<e.length;r++){let n=e[r],i=fW(n);if(!i){t.push(n);continue}if(!i.kind&&r+1<e.length)r++}return t}function u9e(e){let t=[];for(let n of l9e(e)){if(n.startsWith("-"))continue;if(t.push(n),t.length===2)break}return(t.length>0?t.join("-"):"nemar").replace(/[^a-zA-Z0-9_-]/g,"_")}function d9e(e,t){let r=[];if(r.push("NEMAR CLI Debug Log"),r.push(`Generated: ${new Date().toISOString()}`),r.push(`Command: nemar ${Nw(c9e(e).join(" "))}`),r.push(""),r.push($0??"(environment snapshot unavailable)"),r.push(""),r.push("HTTP requests:"),C0.length===0)r.push(" (none)");else C0.forEach((n,i)=>{if(r.push(` [${i+1}] ${n.method} ${n.url} -> ${n.status??"ERROR"} (${n.durationMs}ms)`),n.error)r.push(` Error: ${n.error}`);if(n.note)r.push(` Note: ${n.note}`);if(n.requestHeaders)r.push(` Request headers: ${JSON.stringify(n.requestHeaders)}`);if(n.requestBody)r.push(` Request body: ${n.requestBody}`);if(n.responseBody)r.push(` Response body: ${n.responseBody}`)});return r.push(""),r.push(`Failing step: ${iW??"(none recorded)"}`),r.push(`Exit code: ${t}`),`${r.join(`
107
107
  `)}
@@ -110,7 +110,7 @@ ${l.dim(`eta: ${e.eta}`)}`:"";process.stderr.write(`${t}
110
110
  ${r} ${e.message}
111
111
  ${n}${i}
112
112
  ${t}
113
- `)}var hW=!1;var jw=O(()=>{Ke()});function gW(){if(process.env.TEST_API_URL)return process.env.TEST_API_URL;if(Bw)return Mw;return nt().apiUrl||Mw}async function F(e,t={},r=!1,n){let i=`${gW()}${e}`,o={"Content-Type":"application/json","X-CLI-Version":io,...t.headers};if(r){let m=nt();if(!m.apiKey&&r===!0)throw new q(401,"Not authenticated. Run 'nemar auth login' first.");if(m.apiKey)o.Authorization=`Bearer ${m.apiKey}`}let s=t.method||"GET",a=typeof t.body==="string"?t.body:void 0,c=Date.now(),u;try{u=await fetch(i,{...t,headers:o})}catch(m){if(oa())R0({method:s,url:i,status:null,durationMs:Date.now()-c,requestHeaders:o,requestBody:a,error:m instanceof Error?m.message:String(m)});throw new q(0,`Network error: Could not connect to ${gW()}`,{originalError:m instanceof Error?m.message:String(m)})}let d;try{d=await u.text()}catch(m){if(oa())R0({method:s,url:i,status:u.status,durationMs:Date.now()-c,requestHeaders:o,requestBody:a,error:m instanceof Error?m.message:String(m)});throw new q(0,"Failed to read response body",{httpStatus:u.status,originalError:m instanceof Error?m.message:String(m)})}if(oa())R0({method:s,url:i,status:u.status,durationMs:Date.now()-c,requestHeaders:o,requestBody:a,responseBody:d});let f;try{f=JSON.parse(d)}catch{throw new q(u.status,`Invalid response from server (status ${u.status})`)}if(!u.ok){if(u.status===503&&(f.mode==="read-only"||f.mode==="full")){let _=typeof f.message==="string"?f.message:"NEMAR is in maintenance mode. Please retry shortly.",v=typeof f.eta==="string"?f.eta:null,E=new os(f.mode,_,v,f.details);throw O0(E),E}let m=typeof f.block_reason==="string",p=Array.isArray(f.missing)?f.missing.filter((_)=>typeof _==="string"):void 0,g=typeof f.error==="string"&&($N.includes(f.error)||PN.includes(f.error)),x=m||g||p!==void 0&&typeof f.error==="string"&&SN.includes(f.error)?f.message||f.error:f.error||f.message;if(u.status===404&&f.error==="Not Found"&&typeof f.message==="string")x=`${f.message}. This NEMAR backend does not support this command yet.`;throw new q(u.status,x||"Request failed",f.details,typeof f.step==="string"?f.step:void 0,m?f.block_reason:void 0,p)}if(n){let m=n.safeParse(f);if(!m.success)throw new q(u.status,`Response for ${e} did not match the expected NEMAR contract`,{issues:m.error.issues});return m.data}return f}var Mw="https://api.nemar.org",Bw;var ss=O(()=>{Q_();jm();_i();sa();jw();tf();Nt();Bw=Mw.includes("workers.dev")});function k0(e){if(e.service_access===void 0||e.service_access===null)return"unknown";return e.service_access?"upload":"browse"}async function yW(e,t,r){let n=new URLSearchParams;if(e)n.set("status",e);if(t)n.set("role",t);if(r)n.set("awaiting_approval","1");let i=n.toString()?`?${n.toString()}`:"";return F(`/admin/users${i}`,{},!0,EN)}async function xW(e){return F(`/admin/approve/${e}`,{method:"POST"},!0)}async function bW(e){return F(`/admin/approve/by-id/${e}`,{method:"POST"},!0)}async function _W(e){return F(`/admin/revoke/${e}`,{method:"POST"},!0)}async function vW(e){return F(`/admin/revoke/by-id/${e}`,{method:"POST"},!0)}async function wW(e,t){return F(`/admin/users/${e}/role`,{method:"POST",body:JSON.stringify({role:t})},!0)}async function Lw(e,t){return F(`/admin/datasets/${e}/visibility`,{method:"PATCH",body:JSON.stringify({visibility:t})},!0)}async function DW(e){return F(`/datasets/${e}/publish`,{method:"POST"},!0)}async function EW(e){return F(`/admin/datasets/${e}/ci`,{},!0)}async function oo(e){return F(`/admin/datasets/${e}/ci`,{method:"POST"},!0)}async function Uw(e){return F(`/admin/datasets/${e}/ci/validate`,{method:"POST"},!0)}async function Vw(e){return F(`/admin/datasets/${e}/ci/sync`,{method:"POST"},!0)}async function SW(e,t){return F(`/admin/datasets/${e}/doi/concept`,{method:"POST",body:JSON.stringify(t)},!0)}async function of(e){return F(`/admin/datasets/${e}/doi`,{},!0)}async function Gw(e,t){return F(`/admin/datasets/${e}/doi/update`,{method:"POST",body:JSON.stringify(t)},!0)}async function $W(e,t){return F(`/admin/datasets/${e}/withdraw`,{method:"POST",body:JSON.stringify({reason:t.reason,dry_run:t.dryRun})},!0)}async function CW(e,t){return F(`/admin/datasets/${e}/restore`,{method:"POST",body:JSON.stringify({dry_run:t.dryRun})},!0)}async function RW(e){return F(`/admin/datasets/${e}/reset`,{method:"POST"},!0)}async function OW(e,t=!1){return F(`/admin/datasets/${e}`,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({force:t})},!0)}async function kW(e){return F("/admin/datasets/bulk-delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dataset_ids:e})},!0)}async function AW(e){return F("/admin/datasets/import",{method:"POST",body:JSON.stringify(e)},!0)}async function FW(e){return F("/admin/datasets/exemplar",{method:"POST",body:JSON.stringify(e)},!0)}async function PW(e){return F(`/admin/datasets/${e}/exemplar/remint-dois`,{method:"POST"},!0)}async function zw(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 F(`/admin/imports${n?`?${n}`:""}`,{},!0)}async function IW(e){return F(`/admin/imports/${e}/rollback`,{method:"POST"},!0)}async function TW(e){return F(`/admin/imports/${e}/retry`,{method:"POST"},!0)}async function Hw(e){return F(`/admin/imports/${e}/verify`,{method:"POST"},!0)}async function NW(e){return F("/admin/imports/dispatch-cooldown",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dataset_ids:e})},!0)}async function el(e,t){return F(`/admin/datasets/${e}/reindex`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t??{})},!0)}async function qW(e,t){return F("/admin/datasets/reindex/bulk",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filter:e,...t??{}})},!0)}async function jW(e){let t=e?.limit??15;return F(`/admin/datasets/hed-sweep?limit=${encodeURIComponent(String(t))}`,{method:"POST",headers:{"Content-Type":"application/json"}},!0)}async function MW(){return F("/admin/datasets/hed-sweep?reset=1",{method:"POST",headers:{"Content-Type":"application/json"}},!0)}async function BW(e){let t=e?.limit??50;return F(`/admin/datasets/recording-stats-sweep?limit=${encodeURIComponent(String(t))}`,{method:"POST",headers:{"Content-Type":"application/json"}},!0)}async function LW(){return F("/admin/datasets/recording-stats-sweep?reset=1",{method:"POST",headers:{"Content-Type":"application/json"}},!0)}async function UW(e){let t=e?.limit??15;return F(`/admin/datasets/signal-defaults-sweep?limit=${encodeURIComponent(String(t))}`,{method:"POST",headers:{"Content-Type":"application/json"}},!0)}async function VW(){return F("/admin/datasets/signal-defaults-sweep?reset=1",{method:"POST",headers:{"Content-Type":"application/json"}},!0)}async function GW(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 F(`/admin/datasets/data-integrity-sweep?${r.toString()}`,{method:"POST",headers:{"Content-Type":"application/json"}},!0)}async function zW(){return F("/admin/datasets/data-integrity-sweep?reset=1",{method:"POST",headers:{"Content-Type":"application/json"}},!0)}async function HW(e,t){let r=t?.write?"":"?dry_run=1";return F(`/admin/datasets/${e}/availability-report${r}`,{method:"POST",headers:{"Content-Type":"application/json"}},!0)}async function WW(e){let t=e?.limit??30,r=new URLSearchParams({limit:String(t)});if(e?.missingOnly)r.set("missing-only","1");return F(`/admin/datasets/availability-report-sweep?${r.toString()}`,{method:"POST",headers:{"Content-Type":"application/json"}},!0)}async function KW(){return F("/admin/datasets/availability-report-sweep?reset=1",{method:"POST",headers:{"Content-Type":"application/json"}},!0)}async function YW(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 F(`/admin/fleet/drift${r}`,{},!0)}async function tl(e,t){return F(`/admin/datasets/${e}/enforce`,{method:"POST",body:JSON.stringify({dry_run:t})},!0)}async function JW(e){return F("/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 XW(e,t=!1){return F(`/admin/datasets/${e}/revalidate${t?"?force=true":""}`,{method:"POST"},!0)}async function QW(e){let t=e?`?user=${encodeURIComponent(e)}`:"";return F(`/admin/email-preferences${t}`,{},!0)}async function ZW(e,t){let r=t?`?user=${encodeURIComponent(t)}`:"";return F(`/admin/email-preferences${r}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)},!0)}async function Ww(e){return F("/admin/notify",{method:"POST",body:JSON.stringify(e)},!0)}async function eK(){return F("/admin/summary/coverage",{},!0)}async function tK(e,t,r){return F("/admin/manifest/dispatch",{method:"POST",body:JSON.stringify({dataset_id:e,version:t,skip_canary:r?.skipCanary??!1})},!0)}async function Kw(e){return F("/admin/doctor/scan",{method:"POST",body:JSON.stringify({...e?.check&&{check:e.check},...e?.datasetId&&{dataset_id:e.datasetId}})},!0)}async function Yw(e){return F("/admin/doctor/fix",{method:"POST",body:JSON.stringify({check:e.check,...e.datasetId&&{dataset_id:e.datasetId},...e.dryRun&&{dry_run:!0}})},!0)}async function rK(){return F("/admin/zarr-catalog/publish",{method:"POST"},!0)}async function nK(e){let t=new URLSearchParams;if(e?.limit!=null)t.set("limit",String(e.limit));let r=t.toString()?`?${t.toString()}`:"";return F(`/admin/datasets/zarr-fidelity-sweep${r}`,{method:"POST",headers:{"Content-Type":"application/json"}},!0)}async function iK(e){return F("/admin/users/backfill-names",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apply:e?.apply??!1,...e?.limit!=null?{limit:e.limit}:{}})},!0)}async function oK(e){return F("/admin/users/backfill-usernames",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apply:e?.apply??!1,...e?.limit!=null?{limit:e.limit}:{}})},!0)}async function sK(){return F("/admin/users/duplicates",{},!0,IN)}async function aK(e){return F(`/admin/users/${e}/clear-identity-conflict`,{method:"POST"},!0,TN)}var rl=O(()=>{Gu();ss()});async function vi(e,t){return F(`/datasets/${e}/upload-credentials`,{method:"POST",body:JSON.stringify({duration_seconds:t})},!0)}async function Jw(e,t){return F(`/datasets/${e}/download-credentials`,{method:"POST",body:JSON.stringify({duration_seconds:t})},!0)}async function cK(e){return F(`/admin/datasets/${e}/files`,{},!0)}async function lK(e){let t,r=0,n=[],i=!0;while(i){let o=await F(`/admin/datasets/${e}/s3-lock`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({continuation_token:t})},!0);if(r+=o.locked,o.failed?.length)n.push(...o.failed);if(i=o.hasMore,t=o.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 nl=O(()=>{ss();Nt()});async function F0(e){return F(`/datasets/${e}/ci/status`,{},!0)}async function uK(e){return F(`/datasets/${e}/manifest`,{},!0)}async function P0(e,t){return F(`/datasets/${e}/manifest/${t}`,{},!0)}function dK(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 il(e={}){let t=new URLSearchParams;if(e.mine)t.set("mine","true");if(e.search)t.set("search",e.search);if(e.modality)t.set("modality",e.modality);if(e.author)t.set("author",e.author);if(e.task)t.set("task",e.task);if(e.license)t.set("license",e.license);if(e.hasDoi)t.set("has_doi","true");if(e.hasHed)t.set("has_hed","1");if(e.hasZarr)t.set("has_zarr","1");if(e.hasZarrVerified)t.set("has_zarr_verified","1");if(e.dataComplete)t.set("data_complete","1");if(e.recent)t.set("recent",String(e.recent));if(e.sort)t.set("sort",e.sort);if(e.limit!=null)t.set("limit",String(e.limit));if(e.offset!=null)t.set("offset",String(e.offset));if(e.owner)t.set("owner",e.owner);if(e.facets)for(let[i,o]of Object.entries(e.facets))t.set(i,o);if(e.includeUnknown)t.set("include_unknown","1");let r=t.toString()?`?${t.toString()}`:"",n=await F(`/datasets${r}`,{},e.mine?!0:"optional");return n.datasets=n.datasets.map(dK),n}async function fK(e){return F(`/datasets/resolve/${e}`,{},"optional")}async function pK(){return F("/datasets/facets",{signal:AbortSignal.timeout(5000)},"optional",Mm)}async function mK(e,t={}){let r=new URLSearchParams({q:e});if(t.modality)r.set("modality",t.modality);if(t.limit)r.set("limit",String(t.limit));if(t.hasHed)r.set("has_hed","1");if(t.hasZarr)r.set("has_zarr","1");if(t.hasZarrVerified)r.set("has_zarr_verified","1");if(t.author)r.set("author",t.author);if(t.task)r.set("task",t.task);if(t.license)r.set("license",t.license);if(t.hasDoi)r.set("has_doi","true");if(t.dataComplete)r.set("data_complete","1");if(t.recent)r.set("recent",String(t.recent));if(t.facets)for(let[i,o]of Object.entries(t.facets))r.set(i,o);if(t.includeUnknown)r.set("include_unknown","1");return await F(`/datasets/search?${r.toString()}`,{},"optional",AN)}async function Ct(e){let t=await F(`/datasets/${e}`,{},"optional");return dK(t.dataset)}async function hK(e){return F(`/datasets/${e}/versions`,{},!0)}async function I0(e){return F("/datasets",{method:"POST",body:JSON.stringify(e)},!0)}async function T0(e){return F(`/datasets/${e}/finalize`,{method:"POST"},!0)}async function Xw(e){return F(`/datasets/${e}/request-access`,{method:"POST"},!0)}async function gK(e,t){let r=t?`?status=${t}`:"";return F(`/datasets/${e}/access-requests${r}`,{},!0)}async function yK(e,t){return F(`/datasets/${e}/access-requests/${t}/approve`,{method:"POST"},!0)}async function xK(e,t){return F(`/datasets/${e}/access-requests/${t}/deny`,{method:"POST"},!0)}async function bK(e,t){return F(`/datasets/${e}/invite`,{method:"POST",body:JSON.stringify({username:t})},!0)}async function _K(e){return F(`/datasets/${e}/collaborators`,{},!0)}async function vK(e,t){return F(`/admin/datasets/${e}/enrichment`,{method:"POST",body:JSON.stringify(t)},!0)}var A0;var as=O(()=>{Gu();ss();A0=/^\d{4}-\d{4}-\d{4}-\d{3}[\dX]$/});var ol;var $K=O(()=>{ol=["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 sl(e){return F(`/datasets/${e}/publish/request`,{method:"POST"},!0)}async function RK(e){return F(`/datasets/${e}/publish/status`,{},!0)}async function OK(e){return F(`/datasets/${e}/publish/resend`,{method:"POST"},!0)}async function kK(e){let t=e?`?status=${e}`:"";return F(`/admin/publish/requests${t}`,{},!0)}async function AK(e,t){return F(`/admin/publish/${e}/deny`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({reason:t})},!0)}function p9e(e,t=[]){if(e){let r=ol.indexOf(e);if(r>=0)return r+1}return Math.min(t.length+1,ol.length)}function m9e(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 al(e,t=!1,r=!1,n=!1,i,o){let c,u,d=0,f=!1,m,p=t,g=[],y;function x(_,v,E,S){if(!o)return;o({step:_,stepIndex:p9e(_,v),stepTotal:ol.length,s3LockLocked:E,s3LockTotal:S,s3LockResumed:_==="s3_lock"&&f?!0:void 0})}for(let _=1;_<=5;_++)try{let v,E=!0;do{if(v=await F(`/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:u,skip_ci_check:n})},!0),E=!1,v.step_results)g.push(...v.step_results);if(v.s3_lock_total!==void 0)u=v.s3_lock_total;if(v.s3_lock_batch_count!==void 0)d+=v.s3_lock_batch_count;let S=v.step??v.step_results?.[v.step_results.length-1]?.step;if(S&&(S!==m||S==="s3_lock"))x(S,v.steps_completed??[],S==="s3_lock"?d:void 0,S==="s3_lock"?u:void 0),m=S;if(v.hasMore&&v.s3_lock_continuation_token!==void 0)c=v.s3_lock_continuation_token;else break}while(v.hasMore);if(g.length>0)v.step_results=CK(g);return v}catch(v){if(y=v,_===5||!m9e(v)){if(v instanceof q&&g.length>0)v.stepResults=CK(g);throw v}let S=v;if(i?.({attempt:_,maxAttempts:5,delayMs:1e4,step:S.step,error:S.message}),await new Promise((D)=>setTimeout(D,1e4)),p=!0,c!==void 0)f=!0}throw y}function CK(e){let t=new Map;for(let r of e)t.set(r.step,r);return Array.from(t.values())}var sf=O(()=>{$K();ss();Nt()});async function h9e(){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 af(){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 N0(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 o=i.toLowerCase()===e.toLowerCase();return{authenticated:!0,username:i,matches:o,error:o?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 q0(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((u)=>u.repository.full_name===e)?.id??null}catch(a){let c=a instanceof Error?a.message:String(a);return console.error("Failed to parse GitHub invitations response:",c),console.error(" Raw response (first 500 chars):",(t||"").slice(0,500)),{accepted:!1,error:`Failed to parse GitHub API response: ${c}`}}if(!i){let{exitCode:a}=await 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:o,stderr:s}=await R(["gh","api","--method","PATCH",`/user/repository_invitations/${i}`]);if(o!==0)return{accepted:!1,error:`Failed to accept invitation: ${s.trim()||"unknown error"}`};return{accepted:!0}}async function wi(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:",""),o=await af();if(o.token)n=`https://github.com/${i}`,await R(["git","config","credential.https://github.com.helper",`!printf 'username=x-access-token\\npassword=${o.token}'`],{cwd:e});else{let s=await h9e();if(s.works)n=t;else return{success:!1,error:`GitHub authentication not configured.
113
+ `)}var hW=!1;var jw=O(()=>{Ke()});function gW(){if(process.env.TEST_API_URL)return process.env.TEST_API_URL;if(Bw)return Mw;return nt().apiUrl||Mw}async function F(e,t={},r=!1,n){let i=`${gW()}${e}`,o={"Content-Type":"application/json","X-CLI-Version":io,...t.headers};if(r){let m=nt();if(!m.apiKey&&r===!0)throw new q(401,"Not authenticated. Run 'nemar auth login' first.");if(m.apiKey)o.Authorization=`Bearer ${m.apiKey}`}let s=t.method||"GET",a=typeof t.body==="string"?t.body:void 0,c=Date.now(),u;try{u=await fetch(i,{...t,headers:o})}catch(m){if(oa())R0({method:s,url:i,status:null,durationMs:Date.now()-c,requestHeaders:o,requestBody:a,error:m instanceof Error?m.message:String(m)});throw new q(0,`Network error: Could not connect to ${gW()}`,{originalError:m instanceof Error?m.message:String(m)})}let d;try{d=await u.text()}catch(m){if(oa())R0({method:s,url:i,status:u.status,durationMs:Date.now()-c,requestHeaders:o,requestBody:a,error:m instanceof Error?m.message:String(m)});throw new q(0,"Failed to read response body",{httpStatus:u.status,originalError:m instanceof Error?m.message:String(m)})}if(oa())R0({method:s,url:i,status:u.status,durationMs:Date.now()-c,requestHeaders:o,requestBody:a,responseBody:d});let f;try{f=JSON.parse(d)}catch{throw new q(u.status,`Invalid response from server (status ${u.status})`)}if(!u.ok){if(u.status===503&&(f.mode==="read-only"||f.mode==="full")){let _=typeof f.message==="string"?f.message:"NEMAR is in maintenance mode. Please retry shortly.",v=typeof f.eta==="string"?f.eta:null,E=new os(f.mode,_,v,f.details);throw O0(E),E}let m=typeof f.block_reason==="string",p=Array.isArray(f.missing)?f.missing.filter((_)=>typeof _==="string"):void 0,g=typeof f.error==="string"&&($N.includes(f.error)||PN.includes(f.error)),x=m||g||p!==void 0&&typeof f.error==="string"&&SN.includes(f.error)?f.message||f.error:f.error||f.message;if(u.status===404&&f.error==="Not Found"&&typeof f.message==="string")x=`${f.message}. This NEMAR backend does not support this command yet.`;throw new q(u.status,x||"Request failed",f.details,typeof f.step==="string"?f.step:void 0,m?f.block_reason:void 0,p)}if(n){let m=n.safeParse(f);if(!m.success)throw new q(u.status,`Response for ${e} did not match the expected NEMAR contract`,{issues:m.error.issues});return m.data}return f}var Mw="https://nemar-api-dev.sccn-org.workers.dev",Bw;var ss=O(()=>{Q_();jm();_i();sa();jw();tf();Nt();Bw=Mw.includes("workers.dev")});function k0(e){if(e.service_access===void 0||e.service_access===null)return"unknown";return e.service_access?"upload":"browse"}async function yW(e,t,r){let n=new URLSearchParams;if(e)n.set("status",e);if(t)n.set("role",t);if(r)n.set("awaiting_approval","1");let i=n.toString()?`?${n.toString()}`:"";return F(`/admin/users${i}`,{},!0,EN)}async function xW(e){return F(`/admin/approve/${e}`,{method:"POST"},!0)}async function bW(e){return F(`/admin/approve/by-id/${e}`,{method:"POST"},!0)}async function _W(e){return F(`/admin/revoke/${e}`,{method:"POST"},!0)}async function vW(e){return F(`/admin/revoke/by-id/${e}`,{method:"POST"},!0)}async function wW(e,t){return F(`/admin/users/${e}/role`,{method:"POST",body:JSON.stringify({role:t})},!0)}async function Lw(e,t){return F(`/admin/datasets/${e}/visibility`,{method:"PATCH",body:JSON.stringify({visibility:t})},!0)}async function DW(e){return F(`/datasets/${e}/publish`,{method:"POST"},!0)}async function EW(e){return F(`/admin/datasets/${e}/ci`,{},!0)}async function oo(e){return F(`/admin/datasets/${e}/ci`,{method:"POST"},!0)}async function Uw(e){return F(`/admin/datasets/${e}/ci/validate`,{method:"POST"},!0)}async function Vw(e){return F(`/admin/datasets/${e}/ci/sync`,{method:"POST"},!0)}async function SW(e,t){return F(`/admin/datasets/${e}/doi/concept`,{method:"POST",body:JSON.stringify(t)},!0)}async function of(e){return F(`/admin/datasets/${e}/doi`,{},!0)}async function Gw(e,t){return F(`/admin/datasets/${e}/doi/update`,{method:"POST",body:JSON.stringify(t)},!0)}async function $W(e,t){return F(`/admin/datasets/${e}/withdraw`,{method:"POST",body:JSON.stringify({reason:t.reason,dry_run:t.dryRun})},!0)}async function CW(e,t){return F(`/admin/datasets/${e}/restore`,{method:"POST",body:JSON.stringify({dry_run:t.dryRun})},!0)}async function RW(e){return F(`/admin/datasets/${e}/reset`,{method:"POST"},!0)}async function OW(e,t=!1){return F(`/admin/datasets/${e}`,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({force:t})},!0)}async function kW(e){return F("/admin/datasets/bulk-delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dataset_ids:e})},!0)}async function AW(e){return F("/admin/datasets/import",{method:"POST",body:JSON.stringify(e)},!0)}async function FW(e){return F("/admin/datasets/exemplar",{method:"POST",body:JSON.stringify(e)},!0)}async function PW(e){return F(`/admin/datasets/${e}/exemplar/remint-dois`,{method:"POST"},!0)}async function zw(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 F(`/admin/imports${n?`?${n}`:""}`,{},!0)}async function IW(e){return F(`/admin/imports/${e}/rollback`,{method:"POST"},!0)}async function TW(e){return F(`/admin/imports/${e}/retry`,{method:"POST"},!0)}async function Hw(e){return F(`/admin/imports/${e}/verify`,{method:"POST"},!0)}async function NW(e){return F("/admin/imports/dispatch-cooldown",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dataset_ids:e})},!0)}async function el(e,t){return F(`/admin/datasets/${e}/reindex`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t??{})},!0)}async function qW(e,t){return F("/admin/datasets/reindex/bulk",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filter:e,...t??{}})},!0)}async function jW(e){let t=e?.limit??15;return F(`/admin/datasets/hed-sweep?limit=${encodeURIComponent(String(t))}`,{method:"POST",headers:{"Content-Type":"application/json"}},!0)}async function MW(){return F("/admin/datasets/hed-sweep?reset=1",{method:"POST",headers:{"Content-Type":"application/json"}},!0)}async function BW(e){let t=e?.limit??50;return F(`/admin/datasets/recording-stats-sweep?limit=${encodeURIComponent(String(t))}`,{method:"POST",headers:{"Content-Type":"application/json"}},!0)}async function LW(){return F("/admin/datasets/recording-stats-sweep?reset=1",{method:"POST",headers:{"Content-Type":"application/json"}},!0)}async function UW(e){let t=e?.limit??15;return F(`/admin/datasets/signal-defaults-sweep?limit=${encodeURIComponent(String(t))}`,{method:"POST",headers:{"Content-Type":"application/json"}},!0)}async function VW(){return F("/admin/datasets/signal-defaults-sweep?reset=1",{method:"POST",headers:{"Content-Type":"application/json"}},!0)}async function GW(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 F(`/admin/datasets/data-integrity-sweep?${r.toString()}`,{method:"POST",headers:{"Content-Type":"application/json"}},!0)}async function zW(){return F("/admin/datasets/data-integrity-sweep?reset=1",{method:"POST",headers:{"Content-Type":"application/json"}},!0)}async function HW(e,t){let r=t?.write?"":"?dry_run=1";return F(`/admin/datasets/${e}/availability-report${r}`,{method:"POST",headers:{"Content-Type":"application/json"}},!0)}async function WW(e){let t=e?.limit??30,r=new URLSearchParams({limit:String(t)});if(e?.missingOnly)r.set("missing-only","1");return F(`/admin/datasets/availability-report-sweep?${r.toString()}`,{method:"POST",headers:{"Content-Type":"application/json"}},!0)}async function KW(){return F("/admin/datasets/availability-report-sweep?reset=1",{method:"POST",headers:{"Content-Type":"application/json"}},!0)}async function YW(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 F(`/admin/fleet/drift${r}`,{},!0)}async function tl(e,t){return F(`/admin/datasets/${e}/enforce`,{method:"POST",body:JSON.stringify({dry_run:t})},!0)}async function JW(e){return F("/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 XW(e,t=!1){return F(`/admin/datasets/${e}/revalidate${t?"?force=true":""}`,{method:"POST"},!0)}async function QW(e){let t=e?`?user=${encodeURIComponent(e)}`:"";return F(`/admin/email-preferences${t}`,{},!0)}async function ZW(e,t){let r=t?`?user=${encodeURIComponent(t)}`:"";return F(`/admin/email-preferences${r}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)},!0)}async function Ww(e){return F("/admin/notify",{method:"POST",body:JSON.stringify(e)},!0)}async function eK(){return F("/admin/summary/coverage",{},!0)}async function tK(e,t,r){return F("/admin/manifest/dispatch",{method:"POST",body:JSON.stringify({dataset_id:e,version:t,skip_canary:r?.skipCanary??!1})},!0)}async function Kw(e){return F("/admin/doctor/scan",{method:"POST",body:JSON.stringify({...e?.check&&{check:e.check},...e?.datasetId&&{dataset_id:e.datasetId}})},!0)}async function Yw(e){return F("/admin/doctor/fix",{method:"POST",body:JSON.stringify({check:e.check,...e.datasetId&&{dataset_id:e.datasetId},...e.dryRun&&{dry_run:!0}})},!0)}async function rK(){return F("/admin/zarr-catalog/publish",{method:"POST"},!0)}async function nK(e){let t=new URLSearchParams;if(e?.limit!=null)t.set("limit",String(e.limit));let r=t.toString()?`?${t.toString()}`:"";return F(`/admin/datasets/zarr-fidelity-sweep${r}`,{method:"POST",headers:{"Content-Type":"application/json"}},!0)}async function iK(e){return F("/admin/users/backfill-names",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apply:e?.apply??!1,...e?.limit!=null?{limit:e.limit}:{}})},!0)}async function oK(e){return F("/admin/users/backfill-usernames",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apply:e?.apply??!1,...e?.limit!=null?{limit:e.limit}:{}})},!0)}async function sK(){return F("/admin/users/duplicates",{},!0,IN)}async function aK(e){return F(`/admin/users/${e}/clear-identity-conflict`,{method:"POST"},!0,TN)}var rl=O(()=>{Gu();ss()});async function vi(e,t){return F(`/datasets/${e}/upload-credentials`,{method:"POST",body:JSON.stringify({duration_seconds:t})},!0)}async function Jw(e,t){return F(`/datasets/${e}/download-credentials`,{method:"POST",body:JSON.stringify({duration_seconds:t})},!0)}async function cK(e){return F(`/admin/datasets/${e}/files`,{},!0)}async function lK(e){let t,r=0,n=[],i=!0;while(i){let o=await F(`/admin/datasets/${e}/s3-lock`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({continuation_token:t})},!0);if(r+=o.locked,o.failed?.length)n.push(...o.failed);if(i=o.hasMore,t=o.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 nl=O(()=>{ss();Nt()});async function F0(e){return F(`/datasets/${e}/ci/status`,{},!0)}async function uK(e){return F(`/datasets/${e}/manifest`,{},!0)}async function P0(e,t){return F(`/datasets/${e}/manifest/${t}`,{},!0)}function dK(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 il(e={}){let t=new URLSearchParams;if(e.mine)t.set("mine","true");if(e.search)t.set("search",e.search);if(e.modality)t.set("modality",e.modality);if(e.author)t.set("author",e.author);if(e.task)t.set("task",e.task);if(e.license)t.set("license",e.license);if(e.hasDoi)t.set("has_doi","true");if(e.hasHed)t.set("has_hed","1");if(e.hasZarr)t.set("has_zarr","1");if(e.hasZarrVerified)t.set("has_zarr_verified","1");if(e.dataComplete)t.set("data_complete","1");if(e.recent)t.set("recent",String(e.recent));if(e.sort)t.set("sort",e.sort);if(e.limit!=null)t.set("limit",String(e.limit));if(e.offset!=null)t.set("offset",String(e.offset));if(e.owner)t.set("owner",e.owner);if(e.facets)for(let[i,o]of Object.entries(e.facets))t.set(i,o);if(e.includeUnknown)t.set("include_unknown","1");let r=t.toString()?`?${t.toString()}`:"",n=await F(`/datasets${r}`,{},e.mine?!0:"optional");return n.datasets=n.datasets.map(dK),n}async function fK(e){return F(`/datasets/resolve/${e}`,{},"optional")}async function pK(){return F("/datasets/facets",{signal:AbortSignal.timeout(5000)},"optional",Mm)}async function mK(e,t={}){let r=new URLSearchParams({q:e});if(t.modality)r.set("modality",t.modality);if(t.limit)r.set("limit",String(t.limit));if(t.hasHed)r.set("has_hed","1");if(t.hasZarr)r.set("has_zarr","1");if(t.hasZarrVerified)r.set("has_zarr_verified","1");if(t.author)r.set("author",t.author);if(t.task)r.set("task",t.task);if(t.license)r.set("license",t.license);if(t.hasDoi)r.set("has_doi","true");if(t.dataComplete)r.set("data_complete","1");if(t.recent)r.set("recent",String(t.recent));if(t.facets)for(let[i,o]of Object.entries(t.facets))r.set(i,o);if(t.includeUnknown)r.set("include_unknown","1");return await F(`/datasets/search?${r.toString()}`,{},"optional",AN)}async function Ct(e){let t=await F(`/datasets/${e}`,{},"optional");return dK(t.dataset)}async function hK(e){return F(`/datasets/${e}/versions`,{},!0)}async function I0(e){return F("/datasets",{method:"POST",body:JSON.stringify(e)},!0)}async function T0(e){return F(`/datasets/${e}/finalize`,{method:"POST"},!0)}async function Xw(e){return F(`/datasets/${e}/request-access`,{method:"POST"},!0)}async function gK(e,t){let r=t?`?status=${t}`:"";return F(`/datasets/${e}/access-requests${r}`,{},!0)}async function yK(e,t){return F(`/datasets/${e}/access-requests/${t}/approve`,{method:"POST"},!0)}async function xK(e,t){return F(`/datasets/${e}/access-requests/${t}/deny`,{method:"POST"},!0)}async function bK(e,t){return F(`/datasets/${e}/invite`,{method:"POST",body:JSON.stringify({username:t})},!0)}async function _K(e){return F(`/datasets/${e}/collaborators`,{},!0)}async function vK(e,t){return F(`/admin/datasets/${e}/enrichment`,{method:"POST",body:JSON.stringify(t)},!0)}var A0;var as=O(()=>{Gu();ss();A0=/^\d{4}-\d{4}-\d{4}-\d{3}[\dX]$/});var ol;var $K=O(()=>{ol=["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 sl(e){return F(`/datasets/${e}/publish/request`,{method:"POST"},!0)}async function RK(e){return F(`/datasets/${e}/publish/status`,{},!0)}async function OK(e){return F(`/datasets/${e}/publish/resend`,{method:"POST"},!0)}async function kK(e){let t=e?`?status=${e}`:"";return F(`/admin/publish/requests${t}`,{},!0)}async function AK(e,t){return F(`/admin/publish/${e}/deny`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({reason:t})},!0)}function p9e(e,t=[]){if(e){let r=ol.indexOf(e);if(r>=0)return r+1}return Math.min(t.length+1,ol.length)}function m9e(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 al(e,t=!1,r=!1,n=!1,i,o){let c,u,d=0,f=!1,m,p=t,g=[],y;function x(_,v,E,S){if(!o)return;o({step:_,stepIndex:p9e(_,v),stepTotal:ol.length,s3LockLocked:E,s3LockTotal:S,s3LockResumed:_==="s3_lock"&&f?!0:void 0})}for(let _=1;_<=5;_++)try{let v,E=!0;do{if(v=await F(`/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:u,skip_ci_check:n})},!0),E=!1,v.step_results)g.push(...v.step_results);if(v.s3_lock_total!==void 0)u=v.s3_lock_total;if(v.s3_lock_batch_count!==void 0)d+=v.s3_lock_batch_count;let S=v.step??v.step_results?.[v.step_results.length-1]?.step;if(S&&(S!==m||S==="s3_lock"))x(S,v.steps_completed??[],S==="s3_lock"?d:void 0,S==="s3_lock"?u:void 0),m=S;if(v.hasMore&&v.s3_lock_continuation_token!==void 0)c=v.s3_lock_continuation_token;else break}while(v.hasMore);if(g.length>0)v.step_results=CK(g);return v}catch(v){if(y=v,_===5||!m9e(v)){if(v instanceof q&&g.length>0)v.stepResults=CK(g);throw v}let S=v;if(i?.({attempt:_,maxAttempts:5,delayMs:1e4,step:S.step,error:S.message}),await new Promise((D)=>setTimeout(D,1e4)),p=!0,c!==void 0)f=!0}throw y}function CK(e){let t=new Map;for(let r of e)t.set(r.step,r);return Array.from(t.values())}var sf=O(()=>{$K();ss();Nt()});async function h9e(){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 af(){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 N0(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 o=i.toLowerCase()===e.toLowerCase();return{authenticated:!0,username:i,matches:o,error:o?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 q0(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((u)=>u.repository.full_name===e)?.id??null}catch(a){let c=a instanceof Error?a.message:String(a);return console.error("Failed to parse GitHub invitations response:",c),console.error(" Raw response (first 500 chars):",(t||"").slice(0,500)),{accepted:!1,error:`Failed to parse GitHub API response: ${c}`}}if(!i){let{exitCode:a}=await 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:o,stderr:s}=await R(["gh","api","--method","PATCH",`/user/repository_invitations/${i}`]);if(o!==0)return{accepted:!1,error:`Failed to accept invitation: ${s.trim()||"unknown error"}`};return{accepted:!0}}async function wi(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:",""),o=await af();if(o.token)n=`https://github.com/${i}`,await R(["git","config","credential.https://github.com.helper",`!printf 'username=x-access-token\\npassword=${o.token}'`],{cwd:e});else{let s=await h9e();if(s.works)n=t;else return{success:!1,error:`GitHub authentication not configured.
114
114
 
115
115
  gh CLI failed: ${o.error||"could not get token"}
116
116
  SSH failed: ${s.error||"could not connect"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nemar-cli",
3
- "version": "0.9.16",
3
+ "version": "0.9.17-dev.2347",
4
4
  "description": "CLI for NEMAR (Neuroelectromagnetic Data Archive and Tools Resource) dataset management",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",