@doguyilmaz/tapster 1.2.0 → 1.2.1

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 (3) hide show
  1. package/README.md +1 -1
  2. package/dist/cli.js +45 -45
  3. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env bun
2
2
  // @bun
3
- var Hy=Object.defineProperty;var P=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Fy=(e)=>e;function Ky(e,t){this[e]=Fy.bind(null,t)}var Al=(e,t)=>{for(var n in t)Hy(e,n,{get:t[n],enumerable:!0,configurable:!0,set:Ky.bind(t,n)})};var Ce=import.meta.require;var z=P(function(tb){var Ks=Symbol.for("yaml.alias"),$l=Symbol.for("yaml.document"),Dr=Symbol.for("yaml.map"),Pl=Symbol.for("yaml.pair"),Ws=Symbol.for("yaml.scalar"),Lr=Symbol.for("yaml.seq"),Je=Symbol.for("yaml.node.type"),Wy=(e)=>!!e&&typeof e==="object"&&e[Je]===Ks,Vy=(e)=>!!e&&typeof e==="object"&&e[Je]===$l,Yy=(e)=>!!e&&typeof e==="object"&&e[Je]===Dr,Jy=(e)=>!!e&&typeof e==="object"&&e[Je]===Pl,Tl=(e)=>!!e&&typeof e==="object"&&e[Je]===Ws,Qy=(e)=>!!e&&typeof e==="object"&&e[Je]===Lr;function El(e){if(e&&typeof e==="object")switch(e[Je]){case Dr:case Lr:return!0}return!1}function Xy(e){if(e&&typeof e==="object")switch(e[Je]){case Ks:case Dr:case Ws:case Lr:return!0}return!1}var eb=(e)=>(Tl(e)||El(e))&&!!e.anchor;tb.ALIAS=Ks;tb.DOC=$l;tb.MAP=Dr;tb.NODE_TYPE=Je;tb.PAIR=Pl;tb.SCALAR=Ws;tb.SEQ=Lr;tb.hasAnchor=eb;tb.isAlias=Wy;tb.isCollection=El;tb.isDocument=Vy;tb.isMap=Yy;tb.isNode=Xy;tb.isPair=Jy;tb.isScalar=Tl;tb.isSeq=Qy});var $n=P(function(yb){var V=z(),he=Symbol("break visit"),Ol=Symbol("skip children"),De=Symbol("remove node");function Mr(e,t){let n=Cl(t);if(V.isDocument(e)){if(Wt(null,e.contents,n,Object.freeze([e]))===De)e.contents=null}else Wt(null,e,n,Object.freeze([]))}Mr.BREAK=he;Mr.SKIP=Ol;Mr.REMOVE=De;function Wt(e,t,n,r){let i=Rl(e,t,n,r);if(V.isNode(i)||V.isPair(i))return Il(e,r,i),Wt(e,i,n,r);if(typeof i!=="symbol"){if(V.isCollection(t)){r=Object.freeze(r.concat(t));for(let s=0;s<t.items.length;++s){let o=Wt(s,t.items[s],n,r);if(typeof o==="number")s=o-1;else if(o===he)return he;else if(o===De)t.items.splice(s,1),s-=1}}else if(V.isPair(t)){r=Object.freeze(r.concat(t));let s=Wt("key",t.key,n,r);if(s===he)return he;else if(s===De)t.key=null;let o=Wt("value",t.value,n,r);if(o===he)return he;else if(o===De)t.value=null}}return i}async function Ur(e,t){let n=Cl(t);if(V.isDocument(e)){if(await Vt(null,e.contents,n,Object.freeze([e]))===De)e.contents=null}else await Vt(null,e,n,Object.freeze([]))}Ur.BREAK=he;Ur.SKIP=Ol;Ur.REMOVE=De;async function Vt(e,t,n,r){let i=await Rl(e,t,n,r);if(V.isNode(i)||V.isPair(i))return Il(e,r,i),Vt(e,i,n,r);if(typeof i!=="symbol"){if(V.isCollection(t)){r=Object.freeze(r.concat(t));for(let s=0;s<t.items.length;++s){let o=await Vt(s,t.items[s],n,r);if(typeof o==="number")s=o-1;else if(o===he)return he;else if(o===De)t.items.splice(s,1),s-=1}}else if(V.isPair(t)){r=Object.freeze(r.concat(t));let s=await Vt("key",t.key,n,r);if(s===he)return he;else if(s===De)t.key=null;let o=await Vt("value",t.value,n,r);if(o===he)return he;else if(o===De)t.value=null}}return i}function Cl(e){if(typeof e==="object"&&(e.Collection||e.Node||e.Value))return Object.assign({Alias:e.Node,Map:e.Node,Scalar:e.Node,Seq:e.Node},e.Value&&{Map:e.Value,Scalar:e.Value,Seq:e.Value},e.Collection&&{Map:e.Collection,Seq:e.Collection},e);return e}function Rl(e,t,n,r){if(typeof n==="function")return n(e,t,r);if(V.isMap(t))return n.Map?.(e,t,r);if(V.isSeq(t))return n.Seq?.(e,t,r);if(V.isPair(t))return n.Pair?.(e,t,r);if(V.isScalar(t))return n.Scalar?.(e,t,r);if(V.isAlias(t))return n.Alias?.(e,t,r);return}function Il(e,t,n){let r=t[t.length-1];if(V.isCollection(r))r.items[e]=n;else if(V.isPair(r))if(e==="key")r.key=n;else r.value=n;else if(V.isDocument(r))r.contents=n;else{let i=V.isAlias(r)?"alias":"scalar";throw Error(`Cannot replace node with ${i} parent`)}}yb.visit=Mr;yb.visitAsync=Ur});var Vs=P(function(Sb){var Nl=z(),_b=$n(),kb={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},xb=(e)=>e.replace(/[!,[\]{}]/g,(t)=>kb[t]);class xe{constructor(e,t){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},xe.defaultYaml,e),this.tags=Object.assign({},xe.defaultTags,t)}clone(){let e=new xe(this.yaml,this.tags);return e.docStart=this.docStart,e}atDocument(){let e=new xe(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:xe.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},xe.defaultTags);break}return e}add(e,t){if(this.atNextDocument)this.yaml={explicit:xe.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},xe.defaultTags),this.atNextDocument=!1;let n=e.trim().split(/[ \t]+/),r=n.shift();switch(r){case"%TAG":{if(n.length!==2){if(t(0,"%TAG directive should contain exactly two parts"),n.length<2)return!1}let[i,s]=n;return this.tags[i]=s,!0}case"%YAML":{if(this.yaml.explicit=!0,n.length!==1)return t(0,"%YAML directive should contain exactly one part"),!1;let[i]=n;if(i==="1.1"||i==="1.2")return this.yaml.version=i,!0;else{let s=/^\d+\.\d+$/.test(i);return t(6,`Unsupported YAML version ${i}`,s),!1}}default:return t(0,`Unknown directive ${r}`,!0),!1}}tagName(e,t){if(e==="!")return"!";if(e[0]!=="!")return t(`Not a valid tag: ${e}`),null;if(e[1]==="<"){let s=e.slice(2,-1);if(s==="!"||s==="!!")return t(`Verbatim tags aren't resolved, so ${e} is invalid.`),null;if(e[e.length-1]!==">")t("Verbatim tags must end with a >");return s}let[,n,r]=e.match(/^(.*!)([^!]*)$/s);if(!r)t(`The ${e} tag has no suffix`);let i=this.tags[n];if(i)try{return i+decodeURIComponent(r)}catch(s){return t(String(s)),null}if(n==="!")return e;return t(`Could not resolve tag: ${e}`),null}tagString(e){for(let[t,n]of Object.entries(this.tags))if(e.startsWith(n))return t+xb(e.substring(n.length));return e[0]==="!"?e:`!<${e}>`}toString(e){let t=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],n=Object.entries(this.tags),r;if(e&&n.length>0&&Nl.isNode(e.contents)){let i={};_b.visit(e.contents,(s,o)=>{if(Nl.isNode(o)&&o.tag)i[o.tag]=!0}),r=Object.keys(i)}else r=[];for(let[i,s]of n){if(i==="!!"&&s==="tag:yaml.org,2002:")continue;if(!e||r.some((o)=>o.startsWith(s)))t.push(`%TAG ${i} ${s}`)}return t.join(`
4
- `)}}xe.defaultYaml={explicit:!1,version:"1.2"};xe.defaultTags={"!!":"tag:yaml.org,2002:"};Sb.Directives=xe});var Zr=P(function(Eb){var zl=z(),$b=$n();function Pb(e){if(/[\x00-\x19\s,[\]{}]/.test(e)){let n=`Anchor must not contain whitespace or control characters: ${JSON.stringify(e)}`;throw Error(n)}return!0}function jl(e){let t=new Set;return $b.visit(e,{Value(n,r){if(r.anchor)t.add(r.anchor)}}),t}function Dl(e,t){for(let n=1;;++n){let r=`${e}${n}`;if(!t.has(r))return r}}function Tb(e,t){let n=[],r=new Map,i=null;return{onAnchor:(s)=>{n.push(s),i??(i=jl(e));let o=Dl(t,i);return i.add(o),o},setAnchors:()=>{for(let s of n){let o=r.get(s);if(typeof o==="object"&&o.anchor&&(zl.isScalar(o.node)||zl.isCollection(o.node)))o.node.anchor=o.anchor;else{let a=Error("Failed to resolve repeated object (this should not happen)");throw a.source=s,a}}},sourceObjects:r}}Eb.anchorIsValid=Pb;Eb.anchorNames=jl;Eb.createNodeAnchors=Tb;Eb.findNewAnchor=Dl});var Ys=P(function(Nb){function Pn(e,t,n,r){if(r&&typeof r==="object")if(Array.isArray(r))for(let i=0,s=r.length;i<s;++i){let o=r[i],a=Pn(e,r,String(i),o);if(a===void 0)delete r[i];else if(a!==o)r[i]=a}else if(r instanceof Map)for(let i of Array.from(r.keys())){let s=r.get(i),o=Pn(e,r,i,s);if(o===void 0)r.delete(i);else if(o!==s)r.set(i,o)}else if(r instanceof Set)for(let i of Array.from(r)){let s=Pn(e,r,i,i);if(s===void 0)r.delete(i);else if(s!==i)r.delete(i),r.add(s)}else for(let[i,s]of Object.entries(r)){let o=Pn(e,r,i,s);if(o===void 0)delete r[i];else if(o!==s)r[i]=o}return e.call(t,n,r)}Nb.applyReviver=Pn});var ct=P(function(Db){var jb=z();function Ll(e,t,n){if(Array.isArray(e))return e.map((r,i)=>Ll(r,String(i),n));if(e&&typeof e.toJSON==="function"){if(!n||!jb.hasAnchor(e))return e.toJSON(t,n);let r={aliasCount:0,count:1,res:void 0};n.anchors.set(e,r),n.onCreate=(s)=>{r.res=s,delete n.onCreate};let i=e.toJSON(t,n);if(n.onCreate)n.onCreate(i);return i}if(typeof e==="bigint"&&!n?.keep)return Number(e);return e}Db.toJS=Ll});var Gr=P(function(Zb){var Mb=Ys(),Ml=z(),Ub=ct();class Ul{constructor(e){Object.defineProperty(this,Ml.NODE_TYPE,{value:e})}clone(){let e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));if(this.range)e.range=this.range.slice();return e}toJS(e,{mapAsMap:t,maxAliasCount:n,onAnchor:r,reviver:i}={}){if(!Ml.isDocument(e))throw TypeError("A document argument is required");let s={anchors:new Map,doc:e,keep:!0,mapAsMap:t===!0,mapKeyWarned:!1,maxAliasCount:typeof n==="number"?n:100},o=Ub.toJS(this,"",s);if(typeof r==="function")for(let{count:a,res:c}of s.anchors.values())r(c,a);return typeof i==="function"?Mb.applyReviver(i,{"":o},"",o):o}}Zb.NodeBase=Ul});var Tn=P(function(Kb){var qb=Zr(),Bb=$n(),Yt=z(),Hb=Gr(),Fb=ct();class Zl extends Hb.NodeBase{constructor(e){super(Yt.ALIAS);this.source=e,Object.defineProperty(this,"tag",{set(){throw Error("Alias nodes cannot have tags")}})}resolve(e,t){if(t?.maxAliasCount===0)throw ReferenceError("Alias resolution is disabled");let n;if(t?.aliasResolveCache)n=t.aliasResolveCache;else if(n=[],Bb.visit(e,{Node:(i,s)=>{if(Yt.isAlias(s)||Yt.hasAnchor(s))n.push(s)}}),t)t.aliasResolveCache=n;let r=void 0;for(let i of n){if(i===this)break;if(i.anchor===this.source)r=i}if(r&&t){let{anchors:i,doc:s,maxAliasCount:o}=t,a=i.get(r);if(!a)Fb.toJS(r,null,t),a=i.get(r);if(a?.res===void 0)throw ReferenceError("This should not happen: Alias anchor was not resolved?");if(o>=0){if(a.count+=1,a.aliasCount===0)a.aliasCount=qr(s,r,i);if(a.count*a.aliasCount>o)throw ReferenceError("Excessive alias count indicates a resource exhaustion attack")}}return r}toJSON(e,t){if(!t)return{source:this.source};let n=this.resolve(t.doc,t);if(!n){let r=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw ReferenceError(r)}return t.anchors.get(n).res}toString(e,t,n){let r=`*${this.source}`;if(e){if(qb.anchorIsValid(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){let i=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw Error(i)}if(e.implicitKey)return`${r} `}return r}}function qr(e,t,n){if(Yt.isAlias(t)){let r=t.resolve(e),i=n&&r&&n.get(r);return i?i.count*i.aliasCount:0}else if(Yt.isCollection(t)){let r=0;for(let i of t.items){let s=qr(e,i,n);if(s>r)r=s}return r}else if(Yt.isPair(t)){let r=qr(e,t.key,n),i=qr(e,t.value,n);return Math.max(r,i)}return 1}Kb.Alias=Zl});var W=P(function(Xb){var Vb=z(),Yb=Gr(),Jb=ct(),Qb=(e)=>!e||typeof e!=="function"&&typeof e!=="object";class Et extends Yb.NodeBase{constructor(e){super(Vb.SCALAR);this.value=e}toJSON(e,t){return t?.keep?this.value:Jb.toJS(this.value,e,t)}toString(){return String(this.value)}}Et.BLOCK_FOLDED="BLOCK_FOLDED";Et.BLOCK_LITERAL="BLOCK_LITERAL";Et.PLAIN="PLAIN";Et.QUOTE_DOUBLE="QUOTE_DOUBLE";Et.QUOTE_SINGLE="QUOTE_SINGLE";Xb.Scalar=Et;Xb.isScalarValue=Qb});var En=P(function(ow){var nw=Tn(),Ot=z(),Gl=W(),rw="tag:yaml.org,2002:";function iw(e,t,n){if(t){let r=n.filter((s)=>s.tag===t),i=r.find((s)=>!s.format)??r[0];if(!i)throw Error(`Tag ${t} not found`);return i}return n.find((r)=>r.identify?.(e)&&!r.format)}function sw(e,t,n){if(Ot.isDocument(e))e=e.contents;if(Ot.isNode(e))return e;if(Ot.isPair(e)){let p=n.schema[Ot.MAP].createNode?.(n.schema,null,n);return p.items.push(e),p}if(e instanceof String||e instanceof Number||e instanceof Boolean||typeof BigInt<"u"&&e instanceof BigInt)e=e.valueOf();let{aliasDuplicateObjects:r,onAnchor:i,onTagObj:s,schema:o,sourceObjects:a}=n,c=void 0;if(r&&e&&typeof e==="object")if(c=a.get(e),c)return c.anchor??(c.anchor=i(e)),new nw.Alias(c.anchor);else c={anchor:null,node:null},a.set(e,c);if(t?.startsWith("!!"))t=rw+t.slice(2);let l=iw(e,t,o.tags);if(!l){if(e&&typeof e.toJSON==="function")e=e.toJSON();if(!e||typeof e!=="object"){let p=new Gl.Scalar(e);if(c)c.node=p;return p}l=e instanceof Map?o[Ot.MAP]:(Symbol.iterator in Object(e))?o[Ot.SEQ]:o[Ot.MAP]}if(s)s(l),delete n.onTagObj;let u=l?.createNode?l.createNode(n.schema,e,n):typeof l?.nodeClass?.from==="function"?l.nodeClass.from(n.schema,e,n):new Gl.Scalar(e);if(t)u.tag=t;else if(!l.default)u.tag=l.tag;if(c)c.node=u;return u}ow.createNode=sw});var Br=P(function(uw){var cw=En(),Le=z(),lw=Gr();function Js(e,t,n){let r=n;for(let i=t.length-1;i>=0;--i){let s=t[i];if(typeof s==="number"&&Number.isInteger(s)&&s>=0){let o=[];o[s]=r,r=o}else r=new Map([[s,r]])}return cw.createNode(r,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw Error("This should not happen, please report a bug.")},schema:e,sourceObjects:new Map})}var ql=(e)=>e==null||typeof e==="object"&&!!e[Symbol.iterator]().next().done;class Bl extends lw.NodeBase{constructor(e,t){super(e);Object.defineProperty(this,"schema",{value:t,configurable:!0,enumerable:!1,writable:!0})}clone(e){let t=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));if(e)t.schema=e;if(t.items=t.items.map((n)=>Le.isNode(n)||Le.isPair(n)?n.clone(e):n),this.range)t.range=this.range.slice();return t}addIn(e,t){if(ql(e))this.add(t);else{let[n,...r]=e,i=this.get(n,!0);if(Le.isCollection(i))i.addIn(r,t);else if(i===void 0&&this.schema)this.set(n,Js(this.schema,r,t));else throw Error(`Expected YAML collection at ${n}. Remaining path: ${r}`)}}deleteIn(e){let[t,...n]=e;if(n.length===0)return this.delete(t);let r=this.get(t,!0);if(Le.isCollection(r))return r.deleteIn(n);else throw Error(`Expected YAML collection at ${t}. Remaining path: ${n}`)}getIn(e,t){let[n,...r]=e,i=this.get(n,!0);if(r.length===0)return!t&&Le.isScalar(i)?i.value:i;else return Le.isCollection(i)?i.getIn(r,t):void 0}hasAllNullValues(e){return this.items.every((t)=>{if(!Le.isPair(t))return!1;let n=t.value;return n==null||e&&Le.isScalar(n)&&n.value==null&&!n.commentBefore&&!n.comment&&!n.tag})}hasIn(e){let[t,...n]=e;if(n.length===0)return this.has(t);let r=this.get(t,!0);return Le.isCollection(r)?r.hasIn(n):!1}setIn(e,t){let[n,...r]=e;if(r.length===0)this.set(n,t);else{let i=this.get(n,!0);if(Le.isCollection(i))i.setIn(r,t);else if(i===void 0&&this.schema)this.set(n,Js(this.schema,r,t));else throw Error(`Expected YAML collection at ${n}. Remaining path: ${r}`)}}}uw.Collection=Bl;uw.collectionFromPath=Js;uw.isEmptyPath=ql});var On=P(function(gw){var fw=(e)=>e.replace(/^(?!$)(?: $)?/gm,"#");function Qs(e,t){if(/^\n+$/.test(e))return e.substring(1);return t?e.replace(/^(?! *$)/gm,t):e}var mw=(e,t,n)=>e.endsWith(`
3
+ var Hy=Object.defineProperty;var P=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Fy=(e)=>e;function Ky(e,t){this[e]=Fy.bind(null,t)}var Al=(e,t)=>{for(var n in t)Hy(e,n,{get:t[n],enumerable:!0,configurable:!0,set:Ky.bind(t,n)})};var Ce=import.meta.require;var z=P(function(tb){var Ks=Symbol.for("yaml.alias"),$l=Symbol.for("yaml.document"),jr=Symbol.for("yaml.map"),Pl=Symbol.for("yaml.pair"),Ws=Symbol.for("yaml.scalar"),Dr=Symbol.for("yaml.seq"),Je=Symbol.for("yaml.node.type"),Wy=(e)=>!!e&&typeof e==="object"&&e[Je]===Ks,Vy=(e)=>!!e&&typeof e==="object"&&e[Je]===$l,Yy=(e)=>!!e&&typeof e==="object"&&e[Je]===jr,Jy=(e)=>!!e&&typeof e==="object"&&e[Je]===Pl,Tl=(e)=>!!e&&typeof e==="object"&&e[Je]===Ws,Qy=(e)=>!!e&&typeof e==="object"&&e[Je]===Dr;function El(e){if(e&&typeof e==="object")switch(e[Je]){case jr:case Dr:return!0}return!1}function Xy(e){if(e&&typeof e==="object")switch(e[Je]){case Ks:case jr:case Ws:case Dr:return!0}return!1}var eb=(e)=>(Tl(e)||El(e))&&!!e.anchor;tb.ALIAS=Ks;tb.DOC=$l;tb.MAP=jr;tb.NODE_TYPE=Je;tb.PAIR=Pl;tb.SCALAR=Ws;tb.SEQ=Dr;tb.hasAnchor=eb;tb.isAlias=Wy;tb.isCollection=El;tb.isDocument=Vy;tb.isMap=Yy;tb.isNode=Xy;tb.isPair=Jy;tb.isScalar=Tl;tb.isSeq=Qy});var $n=P(function(yb){var V=z(),he=Symbol("break visit"),Ol=Symbol("skip children"),je=Symbol("remove node");function Mr(e,t){let n=Cl(t);if(V.isDocument(e)){if(Wt(null,e.contents,n,Object.freeze([e]))===je)e.contents=null}else Wt(null,e,n,Object.freeze([]))}Mr.BREAK=he;Mr.SKIP=Ol;Mr.REMOVE=je;function Wt(e,t,n,r){let i=Rl(e,t,n,r);if(V.isNode(i)||V.isPair(i))return Il(e,r,i),Wt(e,i,n,r);if(typeof i!=="symbol"){if(V.isCollection(t)){r=Object.freeze(r.concat(t));for(let s=0;s<t.items.length;++s){let o=Wt(s,t.items[s],n,r);if(typeof o==="number")s=o-1;else if(o===he)return he;else if(o===je)t.items.splice(s,1),s-=1}}else if(V.isPair(t)){r=Object.freeze(r.concat(t));let s=Wt("key",t.key,n,r);if(s===he)return he;else if(s===je)t.key=null;let o=Wt("value",t.value,n,r);if(o===he)return he;else if(o===je)t.value=null}}return i}async function Ur(e,t){let n=Cl(t);if(V.isDocument(e)){if(await Vt(null,e.contents,n,Object.freeze([e]))===je)e.contents=null}else await Vt(null,e,n,Object.freeze([]))}Ur.BREAK=he;Ur.SKIP=Ol;Ur.REMOVE=je;async function Vt(e,t,n,r){let i=await Rl(e,t,n,r);if(V.isNode(i)||V.isPair(i))return Il(e,r,i),Vt(e,i,n,r);if(typeof i!=="symbol"){if(V.isCollection(t)){r=Object.freeze(r.concat(t));for(let s=0;s<t.items.length;++s){let o=await Vt(s,t.items[s],n,r);if(typeof o==="number")s=o-1;else if(o===he)return he;else if(o===je)t.items.splice(s,1),s-=1}}else if(V.isPair(t)){r=Object.freeze(r.concat(t));let s=await Vt("key",t.key,n,r);if(s===he)return he;else if(s===je)t.key=null;let o=await Vt("value",t.value,n,r);if(o===he)return he;else if(o===je)t.value=null}}return i}function Cl(e){if(typeof e==="object"&&(e.Collection||e.Node||e.Value))return Object.assign({Alias:e.Node,Map:e.Node,Scalar:e.Node,Seq:e.Node},e.Value&&{Map:e.Value,Scalar:e.Value,Seq:e.Value},e.Collection&&{Map:e.Collection,Seq:e.Collection},e);return e}function Rl(e,t,n,r){if(typeof n==="function")return n(e,t,r);if(V.isMap(t))return n.Map?.(e,t,r);if(V.isSeq(t))return n.Seq?.(e,t,r);if(V.isPair(t))return n.Pair?.(e,t,r);if(V.isScalar(t))return n.Scalar?.(e,t,r);if(V.isAlias(t))return n.Alias?.(e,t,r);return}function Il(e,t,n){let r=t[t.length-1];if(V.isCollection(r))r.items[e]=n;else if(V.isPair(r))if(e==="key")r.key=n;else r.value=n;else if(V.isDocument(r))r.contents=n;else{let i=V.isAlias(r)?"alias":"scalar";throw Error(`Cannot replace node with ${i} parent`)}}yb.visit=Mr;yb.visitAsync=Ur});var Vs=P(function(Sb){var Nl=z(),_b=$n(),kb={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},xb=(e)=>e.replace(/[!,[\]{}]/g,(t)=>kb[t]);class xe{constructor(e,t){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},xe.defaultYaml,e),this.tags=Object.assign({},xe.defaultTags,t)}clone(){let e=new xe(this.yaml,this.tags);return e.docStart=this.docStart,e}atDocument(){let e=new xe(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:xe.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},xe.defaultTags);break}return e}add(e,t){if(this.atNextDocument)this.yaml={explicit:xe.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},xe.defaultTags),this.atNextDocument=!1;let n=e.trim().split(/[ \t]+/),r=n.shift();switch(r){case"%TAG":{if(n.length!==2){if(t(0,"%TAG directive should contain exactly two parts"),n.length<2)return!1}let[i,s]=n;return this.tags[i]=s,!0}case"%YAML":{if(this.yaml.explicit=!0,n.length!==1)return t(0,"%YAML directive should contain exactly one part"),!1;let[i]=n;if(i==="1.1"||i==="1.2")return this.yaml.version=i,!0;else{let s=/^\d+\.\d+$/.test(i);return t(6,`Unsupported YAML version ${i}`,s),!1}}default:return t(0,`Unknown directive ${r}`,!0),!1}}tagName(e,t){if(e==="!")return"!";if(e[0]!=="!")return t(`Not a valid tag: ${e}`),null;if(e[1]==="<"){let s=e.slice(2,-1);if(s==="!"||s==="!!")return t(`Verbatim tags aren't resolved, so ${e} is invalid.`),null;if(e[e.length-1]!==">")t("Verbatim tags must end with a >");return s}let[,n,r]=e.match(/^(.*!)([^!]*)$/s);if(!r)t(`The ${e} tag has no suffix`);let i=this.tags[n];if(i)try{return i+decodeURIComponent(r)}catch(s){return t(String(s)),null}if(n==="!")return e;return t(`Could not resolve tag: ${e}`),null}tagString(e){for(let[t,n]of Object.entries(this.tags))if(e.startsWith(n))return t+xb(e.substring(n.length));return e[0]==="!"?e:`!<${e}>`}toString(e){let t=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],n=Object.entries(this.tags),r;if(e&&n.length>0&&Nl.isNode(e.contents)){let i={};_b.visit(e.contents,(s,o)=>{if(Nl.isNode(o)&&o.tag)i[o.tag]=!0}),r=Object.keys(i)}else r=[];for(let[i,s]of n){if(i==="!!"&&s==="tag:yaml.org,2002:")continue;if(!e||r.some((o)=>o.startsWith(s)))t.push(`%TAG ${i} ${s}`)}return t.join(`
4
+ `)}}xe.defaultYaml={explicit:!1,version:"1.2"};xe.defaultTags={"!!":"tag:yaml.org,2002:"};Sb.Directives=xe});var Zr=P(function(Eb){var zl=z(),$b=$n();function Pb(e){if(/[\x00-\x19\s,[\]{}]/.test(e)){let n=`Anchor must not contain whitespace or control characters: ${JSON.stringify(e)}`;throw Error(n)}return!0}function Ll(e){let t=new Set;return $b.visit(e,{Value(n,r){if(r.anchor)t.add(r.anchor)}}),t}function jl(e,t){for(let n=1;;++n){let r=`${e}${n}`;if(!t.has(r))return r}}function Tb(e,t){let n=[],r=new Map,i=null;return{onAnchor:(s)=>{n.push(s),i??(i=Ll(e));let o=jl(t,i);return i.add(o),o},setAnchors:()=>{for(let s of n){let o=r.get(s);if(typeof o==="object"&&o.anchor&&(zl.isScalar(o.node)||zl.isCollection(o.node)))o.node.anchor=o.anchor;else{let a=Error("Failed to resolve repeated object (this should not happen)");throw a.source=s,a}}},sourceObjects:r}}Eb.anchorIsValid=Pb;Eb.anchorNames=Ll;Eb.createNodeAnchors=Tb;Eb.findNewAnchor=jl});var Ys=P(function(Nb){function Pn(e,t,n,r){if(r&&typeof r==="object")if(Array.isArray(r))for(let i=0,s=r.length;i<s;++i){let o=r[i],a=Pn(e,r,String(i),o);if(a===void 0)delete r[i];else if(a!==o)r[i]=a}else if(r instanceof Map)for(let i of Array.from(r.keys())){let s=r.get(i),o=Pn(e,r,i,s);if(o===void 0)r.delete(i);else if(o!==s)r.set(i,o)}else if(r instanceof Set)for(let i of Array.from(r)){let s=Pn(e,r,i,i);if(s===void 0)r.delete(i);else if(s!==i)r.delete(i),r.add(s)}else for(let[i,s]of Object.entries(r)){let o=Pn(e,r,i,s);if(o===void 0)delete r[i];else if(o!==s)r[i]=o}return e.call(t,n,r)}Nb.applyReviver=Pn});var ct=P(function(jb){var Lb=z();function Dl(e,t,n){if(Array.isArray(e))return e.map((r,i)=>Dl(r,String(i),n));if(e&&typeof e.toJSON==="function"){if(!n||!Lb.hasAnchor(e))return e.toJSON(t,n);let r={aliasCount:0,count:1,res:void 0};n.anchors.set(e,r),n.onCreate=(s)=>{r.res=s,delete n.onCreate};let i=e.toJSON(t,n);if(n.onCreate)n.onCreate(i);return i}if(typeof e==="bigint"&&!n?.keep)return Number(e);return e}jb.toJS=Dl});var Gr=P(function(Zb){var Mb=Ys(),Ml=z(),Ub=ct();class Ul{constructor(e){Object.defineProperty(this,Ml.NODE_TYPE,{value:e})}clone(){let e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));if(this.range)e.range=this.range.slice();return e}toJS(e,{mapAsMap:t,maxAliasCount:n,onAnchor:r,reviver:i}={}){if(!Ml.isDocument(e))throw TypeError("A document argument is required");let s={anchors:new Map,doc:e,keep:!0,mapAsMap:t===!0,mapKeyWarned:!1,maxAliasCount:typeof n==="number"?n:100},o=Ub.toJS(this,"",s);if(typeof r==="function")for(let{count:a,res:c}of s.anchors.values())r(c,a);return typeof i==="function"?Mb.applyReviver(i,{"":o},"",o):o}}Zb.NodeBase=Ul});var Tn=P(function(Kb){var qb=Zr(),Bb=$n(),Yt=z(),Hb=Gr(),Fb=ct();class Zl extends Hb.NodeBase{constructor(e){super(Yt.ALIAS);this.source=e,Object.defineProperty(this,"tag",{set(){throw Error("Alias nodes cannot have tags")}})}resolve(e,t){if(t?.maxAliasCount===0)throw ReferenceError("Alias resolution is disabled");let n;if(t?.aliasResolveCache)n=t.aliasResolveCache;else if(n=[],Bb.visit(e,{Node:(i,s)=>{if(Yt.isAlias(s)||Yt.hasAnchor(s))n.push(s)}}),t)t.aliasResolveCache=n;let r=void 0;for(let i of n){if(i===this)break;if(i.anchor===this.source)r=i}if(r&&t){let{anchors:i,doc:s,maxAliasCount:o}=t,a=i.get(r);if(!a)Fb.toJS(r,null,t),a=i.get(r);if(a?.res===void 0)throw ReferenceError("This should not happen: Alias anchor was not resolved?");if(o>=0){if(a.count+=1,a.aliasCount===0)a.aliasCount=qr(s,r,i);if(a.count*a.aliasCount>o)throw ReferenceError("Excessive alias count indicates a resource exhaustion attack")}}return r}toJSON(e,t){if(!t)return{source:this.source};let n=this.resolve(t.doc,t);if(!n){let r=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw ReferenceError(r)}return t.anchors.get(n).res}toString(e,t,n){let r=`*${this.source}`;if(e){if(qb.anchorIsValid(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){let i=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw Error(i)}if(e.implicitKey)return`${r} `}return r}}function qr(e,t,n){if(Yt.isAlias(t)){let r=t.resolve(e),i=n&&r&&n.get(r);return i?i.count*i.aliasCount:0}else if(Yt.isCollection(t)){let r=0;for(let i of t.items){let s=qr(e,i,n);if(s>r)r=s}return r}else if(Yt.isPair(t)){let r=qr(e,t.key,n),i=qr(e,t.value,n);return Math.max(r,i)}return 1}Kb.Alias=Zl});var W=P(function(Xb){var Vb=z(),Yb=Gr(),Jb=ct(),Qb=(e)=>!e||typeof e!=="function"&&typeof e!=="object";class Et extends Yb.NodeBase{constructor(e){super(Vb.SCALAR);this.value=e}toJSON(e,t){return t?.keep?this.value:Jb.toJS(this.value,e,t)}toString(){return String(this.value)}}Et.BLOCK_FOLDED="BLOCK_FOLDED";Et.BLOCK_LITERAL="BLOCK_LITERAL";Et.PLAIN="PLAIN";Et.QUOTE_DOUBLE="QUOTE_DOUBLE";Et.QUOTE_SINGLE="QUOTE_SINGLE";Xb.Scalar=Et;Xb.isScalarValue=Qb});var En=P(function(ow){var nw=Tn(),Ot=z(),Gl=W(),rw="tag:yaml.org,2002:";function iw(e,t,n){if(t){let r=n.filter((s)=>s.tag===t),i=r.find((s)=>!s.format)??r[0];if(!i)throw Error(`Tag ${t} not found`);return i}return n.find((r)=>r.identify?.(e)&&!r.format)}function sw(e,t,n){if(Ot.isDocument(e))e=e.contents;if(Ot.isNode(e))return e;if(Ot.isPair(e)){let p=n.schema[Ot.MAP].createNode?.(n.schema,null,n);return p.items.push(e),p}if(e instanceof String||e instanceof Number||e instanceof Boolean||typeof BigInt<"u"&&e instanceof BigInt)e=e.valueOf();let{aliasDuplicateObjects:r,onAnchor:i,onTagObj:s,schema:o,sourceObjects:a}=n,c=void 0;if(r&&e&&typeof e==="object")if(c=a.get(e),c)return c.anchor??(c.anchor=i(e)),new nw.Alias(c.anchor);else c={anchor:null,node:null},a.set(e,c);if(t?.startsWith("!!"))t=rw+t.slice(2);let l=iw(e,t,o.tags);if(!l){if(e&&typeof e.toJSON==="function")e=e.toJSON();if(!e||typeof e!=="object"){let p=new Gl.Scalar(e);if(c)c.node=p;return p}l=e instanceof Map?o[Ot.MAP]:(Symbol.iterator in Object(e))?o[Ot.SEQ]:o[Ot.MAP]}if(s)s(l),delete n.onTagObj;let u=l?.createNode?l.createNode(n.schema,e,n):typeof l?.nodeClass?.from==="function"?l.nodeClass.from(n.schema,e,n):new Gl.Scalar(e);if(t)u.tag=t;else if(!l.default)u.tag=l.tag;if(c)c.node=u;return u}ow.createNode=sw});var Br=P(function(uw){var cw=En(),De=z(),lw=Gr();function Js(e,t,n){let r=n;for(let i=t.length-1;i>=0;--i){let s=t[i];if(typeof s==="number"&&Number.isInteger(s)&&s>=0){let o=[];o[s]=r,r=o}else r=new Map([[s,r]])}return cw.createNode(r,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw Error("This should not happen, please report a bug.")},schema:e,sourceObjects:new Map})}var ql=(e)=>e==null||typeof e==="object"&&!!e[Symbol.iterator]().next().done;class Bl extends lw.NodeBase{constructor(e,t){super(e);Object.defineProperty(this,"schema",{value:t,configurable:!0,enumerable:!1,writable:!0})}clone(e){let t=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));if(e)t.schema=e;if(t.items=t.items.map((n)=>De.isNode(n)||De.isPair(n)?n.clone(e):n),this.range)t.range=this.range.slice();return t}addIn(e,t){if(ql(e))this.add(t);else{let[n,...r]=e,i=this.get(n,!0);if(De.isCollection(i))i.addIn(r,t);else if(i===void 0&&this.schema)this.set(n,Js(this.schema,r,t));else throw Error(`Expected YAML collection at ${n}. Remaining path: ${r}`)}}deleteIn(e){let[t,...n]=e;if(n.length===0)return this.delete(t);let r=this.get(t,!0);if(De.isCollection(r))return r.deleteIn(n);else throw Error(`Expected YAML collection at ${t}. Remaining path: ${n}`)}getIn(e,t){let[n,...r]=e,i=this.get(n,!0);if(r.length===0)return!t&&De.isScalar(i)?i.value:i;else return De.isCollection(i)?i.getIn(r,t):void 0}hasAllNullValues(e){return this.items.every((t)=>{if(!De.isPair(t))return!1;let n=t.value;return n==null||e&&De.isScalar(n)&&n.value==null&&!n.commentBefore&&!n.comment&&!n.tag})}hasIn(e){let[t,...n]=e;if(n.length===0)return this.has(t);let r=this.get(t,!0);return De.isCollection(r)?r.hasIn(n):!1}setIn(e,t){let[n,...r]=e;if(r.length===0)this.set(n,t);else{let i=this.get(n,!0);if(De.isCollection(i))i.setIn(r,t);else if(i===void 0&&this.schema)this.set(n,Js(this.schema,r,t));else throw Error(`Expected YAML collection at ${n}. Remaining path: ${r}`)}}}uw.Collection=Bl;uw.collectionFromPath=Js;uw.isEmptyPath=ql});var On=P(function(gw){var fw=(e)=>e.replace(/^(?!$)(?: $)?/gm,"#");function Qs(e,t){if(/^\n+$/.test(e))return e.substring(1);return t?e.replace(/^(?! *$)/gm,t):e}var mw=(e,t,n)=>e.endsWith(`
5
5
  `)?Qs(n,t):n.includes(`
6
6
  `)?`
7
7
  `+Qs(n,t):(e.endsWith(" ")?"":" ")+n;gw.indentComment=Qs;gw.lineComment=mw;gw.stringifyComment=fw});var Fl=P(function(_w){function ww(e,t,n="flow",{indentAtStart:r,lineWidth:i=80,minContentWidth:s=20,onFold:o,onOverflow:a}={}){if(!i||i<0)return e;if(i<s)s=0;let c=Math.max(1+s,1+i-t.length);if(e.length<=c)return e;let l=[],u={},p=i-t.length;if(typeof r==="number")if(r>i-Math.max(2,s))l.push(0);else p=i-r;let d=void 0,h=void 0,f=!1,m=-1,g=-1,w=-1;if(n==="block"){if(m=Hl(e,m,t.length),m!==-1)p=m+c}for(let _;_=e[m+=1];){if(n==="quoted"&&_==="\\"){switch(g=m,e[m+1]){case"x":m+=3;break;case"u":m+=5;break;case"U":m+=9;break;default:m+=1}w=m}if(_===`
@@ -32,8 +32,8 @@ ${l}${k}${n}${h}`}function Pw(e,t,n,r){let{type:i,value:s}=e,{actualString:o,imp
32
32
  `)||u&&/[[\]{},]/.test(s))return Jt(s,t);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(s))return a||u||!s.includes(`
33
33
  `)?Jt(s,t):Hr(e,t,n,r);if(!a&&!u&&i!==Re.Scalar.PLAIN&&s.includes(`
34
34
  `))return Hr(e,t,n,r);if(Kr(s)){if(c==="")return t.forceBlockIndent=!0,Hr(e,t,n,r);else if(a&&c===l)return Jt(s,t)}let p=s.replace(/\n+/g,`$&
35
- ${c}`);if(o){let d=(m)=>m.default&&m.tag!=="tag:yaml.org,2002:str"&&m.test?.test(p),{compat:h,tags:f}=t.doc.schema;if(f.some(d)||h?.some(d))return Jt(s,t)}return a?p:lt.foldFlowLines(p,c,lt.FOLD_FLOW,Fr(t,!1))}function Tw(e,t,n,r){let{implicitKey:i,inFlow:s}=t,o=typeof e.value==="string"?e:Object.assign({},e,{value:String(e.value)}),{type:a}=e;if(a!==Re.Scalar.QUOTE_DOUBLE){if(/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(o.value))a=Re.Scalar.QUOTE_DOUBLE}let c=(u)=>{switch(u){case Re.Scalar.BLOCK_FOLDED:case Re.Scalar.BLOCK_LITERAL:return i||s?Jt(o.value,t):Hr(o,t,n,r);case Re.Scalar.QUOTE_DOUBLE:return Cn(o.value,t);case Re.Scalar.QUOTE_SINGLE:return Xs(o.value,t);case Re.Scalar.PLAIN:return Pw(o,t,n,r);default:return null}},l=c(a);if(l===null){let{defaultKeyType:u,defaultStringType:p}=t.options,d=i&&u||p;if(l=c(d),l===null)throw Error(`Unsupported default string type ${d}`)}return l}Ew.stringifyString=Tw});var In=P(function(Lw){var Cw=Zr(),ut=z(),Rw=On(),Iw=Rn();function Nw(e,t){let n=Object.assign({blockQuote:!0,commentString:Rw.stringifyComment,defaultKeyType:null,defaultStringType:"PLAIN",directives:null,doubleQuotedAsJSON:!1,doubleQuotedMinMultiLineLength:40,falseStr:"false",flowCollectionPadding:!0,indentSeq:!0,lineWidth:80,minContentWidth:20,nullStr:"null",simpleKeys:!1,singleQuote:null,trailingComma:!1,trueStr:"true",verifyAliasOrder:!0},e.schema.toStringOptions,t),r;switch(n.collectionStyle){case"block":r=!1;break;case"flow":r=!0;break;default:r=null}return{anchors:new Set,doc:e,flowCollectionPadding:n.flowCollectionPadding?" ":"",indent:"",indentStep:typeof n.indent==="number"?" ".repeat(n.indent):" ",inFlow:r,options:n}}function zw(e,t){if(t.tag){let i=e.filter((s)=>s.tag===t.tag);if(i.length>0)return i.find((s)=>s.format===t.format)??i[0]}let n=void 0,r;if(ut.isScalar(t)){r=t.value;let i=e.filter((s)=>s.identify?.(r));if(i.length>1){let s=i.filter((o)=>o.test);if(s.length>0)i=s}n=i.find((s)=>s.format===t.format)??i.find((s)=>!s.format)}else r=t,n=e.find((i)=>i.nodeClass&&r instanceof i.nodeClass);if(!n){let i=r?.constructor?.name??(r===null?"null":typeof r);throw Error(`Tag not resolved for ${i} value`)}return n}function jw(e,t,{anchors:n,doc:r}){if(!r.directives)return"";let i=[],s=(ut.isScalar(e)||ut.isCollection(e))&&e.anchor;if(s&&Cw.anchorIsValid(s))n.add(s),i.push(`&${s}`);let o=e.tag??(t.default?null:t.tag);if(o)i.push(r.directives.tagString(o));return i.join(" ")}function Dw(e,t,n,r){if(ut.isPair(e))return e.toString(t,n,r);if(ut.isAlias(e)){if(t.doc.directives)return e.toString(t);if(t.resolvedAliases?.has(e))throw TypeError("Cannot stringify circular structure without alias nodes");else{if(t.resolvedAliases)t.resolvedAliases.add(e);else t.resolvedAliases=new Set([e]);e=e.resolve(t.doc)}}let i=void 0,s=ut.isNode(e)?e:t.doc.createNode(e,{onTagObj:(c)=>i=c});i??(i=zw(t.doc.schema.tags,s));let o=jw(s,i,t);if(o.length>0)t.indentAtStart=(t.indentAtStart??0)+o.length+1;let a=typeof i.stringify==="function"?i.stringify(s,t,n,r):ut.isScalar(s)?Iw.stringifyString(s,t,n,r):s.toString(t,n,r);if(!o)return a;return ut.isScalar(s)||a[0]==="{"||a[0]==="["?`${o} ${a}`:`${o}
36
- ${t.indent}${a}`}Lw.createStringifyContext=Nw;Lw.stringify=Dw});var Vl=P(function(Gw){var Qe=z(),Kl=W(),Wl=In(),Nn=On();function Zw({key:e,value:t},n,r,i){let{allNullValues:s,doc:o,indent:a,indentStep:c,options:{commentString:l,indentSeq:u,simpleKeys:p}}=n,d=Qe.isNode(e)&&e.comment||null;if(p){if(d)throw Error("With simple keys, key nodes cannot have comments");if(Qe.isCollection(e)||!Qe.isNode(e)&&typeof e==="object")throw Error("With simple keys, collection cannot be used as a key value")}let h=!p&&(!e||d&&t==null&&!n.inFlow||Qe.isCollection(e)||(Qe.isScalar(e)?e.type===Kl.Scalar.BLOCK_FOLDED||e.type===Kl.Scalar.BLOCK_LITERAL:typeof e==="object"));n=Object.assign({},n,{allNullValues:!1,implicitKey:!h&&(p||!s),indent:a+c});let f=!1,m=!1,g=Wl.stringify(e,n,()=>f=!0,()=>m=!0);if(!h&&!n.inFlow&&g.length>1024){if(p)throw Error("With simple keys, single line scalar must not span more than 1024 characters");h=!0}if(n.inFlow){if(s||t==null){if(f&&r)r();return g===""?"?":h?`? ${g}`:g}}else if(s&&!p||t==null&&h){if(g=`? ${g}`,d&&!f)g+=Nn.lineComment(g,n.indent,l(d));else if(m&&i)i();return g}if(f)d=null;if(h){if(d)g+=Nn.lineComment(g,n.indent,l(d));g=`? ${g}
35
+ ${c}`);if(o){let d=(m)=>m.default&&m.tag!=="tag:yaml.org,2002:str"&&m.test?.test(p),{compat:h,tags:f}=t.doc.schema;if(f.some(d)||h?.some(d))return Jt(s,t)}return a?p:lt.foldFlowLines(p,c,lt.FOLD_FLOW,Fr(t,!1))}function Tw(e,t,n,r){let{implicitKey:i,inFlow:s}=t,o=typeof e.value==="string"?e:Object.assign({},e,{value:String(e.value)}),{type:a}=e;if(a!==Re.Scalar.QUOTE_DOUBLE){if(/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(o.value))a=Re.Scalar.QUOTE_DOUBLE}let c=(u)=>{switch(u){case Re.Scalar.BLOCK_FOLDED:case Re.Scalar.BLOCK_LITERAL:return i||s?Jt(o.value,t):Hr(o,t,n,r);case Re.Scalar.QUOTE_DOUBLE:return Cn(o.value,t);case Re.Scalar.QUOTE_SINGLE:return Xs(o.value,t);case Re.Scalar.PLAIN:return Pw(o,t,n,r);default:return null}},l=c(a);if(l===null){let{defaultKeyType:u,defaultStringType:p}=t.options,d=i&&u||p;if(l=c(d),l===null)throw Error(`Unsupported default string type ${d}`)}return l}Ew.stringifyString=Tw});var In=P(function(Dw){var Cw=Zr(),ut=z(),Rw=On(),Iw=Rn();function Nw(e,t){let n=Object.assign({blockQuote:!0,commentString:Rw.stringifyComment,defaultKeyType:null,defaultStringType:"PLAIN",directives:null,doubleQuotedAsJSON:!1,doubleQuotedMinMultiLineLength:40,falseStr:"false",flowCollectionPadding:!0,indentSeq:!0,lineWidth:80,minContentWidth:20,nullStr:"null",simpleKeys:!1,singleQuote:null,trailingComma:!1,trueStr:"true",verifyAliasOrder:!0},e.schema.toStringOptions,t),r;switch(n.collectionStyle){case"block":r=!1;break;case"flow":r=!0;break;default:r=null}return{anchors:new Set,doc:e,flowCollectionPadding:n.flowCollectionPadding?" ":"",indent:"",indentStep:typeof n.indent==="number"?" ".repeat(n.indent):" ",inFlow:r,options:n}}function zw(e,t){if(t.tag){let i=e.filter((s)=>s.tag===t.tag);if(i.length>0)return i.find((s)=>s.format===t.format)??i[0]}let n=void 0,r;if(ut.isScalar(t)){r=t.value;let i=e.filter((s)=>s.identify?.(r));if(i.length>1){let s=i.filter((o)=>o.test);if(s.length>0)i=s}n=i.find((s)=>s.format===t.format)??i.find((s)=>!s.format)}else r=t,n=e.find((i)=>i.nodeClass&&r instanceof i.nodeClass);if(!n){let i=r?.constructor?.name??(r===null?"null":typeof r);throw Error(`Tag not resolved for ${i} value`)}return n}function Lw(e,t,{anchors:n,doc:r}){if(!r.directives)return"";let i=[],s=(ut.isScalar(e)||ut.isCollection(e))&&e.anchor;if(s&&Cw.anchorIsValid(s))n.add(s),i.push(`&${s}`);let o=e.tag??(t.default?null:t.tag);if(o)i.push(r.directives.tagString(o));return i.join(" ")}function jw(e,t,n,r){if(ut.isPair(e))return e.toString(t,n,r);if(ut.isAlias(e)){if(t.doc.directives)return e.toString(t);if(t.resolvedAliases?.has(e))throw TypeError("Cannot stringify circular structure without alias nodes");else{if(t.resolvedAliases)t.resolvedAliases.add(e);else t.resolvedAliases=new Set([e]);e=e.resolve(t.doc)}}let i=void 0,s=ut.isNode(e)?e:t.doc.createNode(e,{onTagObj:(c)=>i=c});i??(i=zw(t.doc.schema.tags,s));let o=Lw(s,i,t);if(o.length>0)t.indentAtStart=(t.indentAtStart??0)+o.length+1;let a=typeof i.stringify==="function"?i.stringify(s,t,n,r):ut.isScalar(s)?Iw.stringifyString(s,t,n,r):s.toString(t,n,r);if(!o)return a;return ut.isScalar(s)||a[0]==="{"||a[0]==="["?`${o} ${a}`:`${o}
36
+ ${t.indent}${a}`}Dw.createStringifyContext=Nw;Dw.stringify=jw});var Vl=P(function(Gw){var Qe=z(),Kl=W(),Wl=In(),Nn=On();function Zw({key:e,value:t},n,r,i){let{allNullValues:s,doc:o,indent:a,indentStep:c,options:{commentString:l,indentSeq:u,simpleKeys:p}}=n,d=Qe.isNode(e)&&e.comment||null;if(p){if(d)throw Error("With simple keys, key nodes cannot have comments");if(Qe.isCollection(e)||!Qe.isNode(e)&&typeof e==="object")throw Error("With simple keys, collection cannot be used as a key value")}let h=!p&&(!e||d&&t==null&&!n.inFlow||Qe.isCollection(e)||(Qe.isScalar(e)?e.type===Kl.Scalar.BLOCK_FOLDED||e.type===Kl.Scalar.BLOCK_LITERAL:typeof e==="object"));n=Object.assign({},n,{allNullValues:!1,implicitKey:!h&&(p||!s),indent:a+c});let f=!1,m=!1,g=Wl.stringify(e,n,()=>f=!0,()=>m=!0);if(!h&&!n.inFlow&&g.length>1024){if(p)throw Error("With simple keys, single line scalar must not span more than 1024 characters");h=!0}if(n.inFlow){if(s||t==null){if(f&&r)r();return g===""?"?":h?`? ${g}`:g}}else if(s&&!p||t==null&&h){if(g=`? ${g}`,d&&!f)g+=Nn.lineComment(g,n.indent,l(d));else if(m&&i)i();return g}if(f)d=null;if(h){if(d)g+=Nn.lineComment(g,n.indent,l(d));g=`? ${g}
37
37
  ${a}:`}else if(g=`${g}:`,d)g+=Nn.lineComment(g,n.indent,l(d));let w,k,_;if(Qe.isNode(t))w=!!t.spaceBefore,k=t.commentBefore,_=t.comment;else if(w=!1,k=null,_=null,t&&typeof t==="object")t=o.createNode(t);if(n.implicitKey=!1,!h&&!d&&Qe.isScalar(t))n.indentAtStart=g.length+1;if(m=!1,!u&&c.length>=2&&!n.inFlow&&!h&&Qe.isSeq(t)&&!t.flow&&!t.tag&&!t.anchor)n.indent=n.indent.substring(2);let y=!1,x=Wl.stringify(t,n,()=>y=!0,()=>m=!0),S=" ";if(d||w||k){if(S=w?`
38
38
  `:"",k){let O=l(k);S+=`
39
39
  ${Nn.indentComment(O,n.indent)}`}if(x===""&&!n.inFlow){if(S===`
@@ -41,7 +41,7 @@ ${Nn.indentComment(O,n.indent)}`}if(x===""&&!n.inFlow){if(S===`
41
41
 
42
42
  `}else S+=`
43
43
  ${n.indent}`}else if(!h&&Qe.isCollection(t)){let O=x[0],A=x.indexOf(`
44
- `),D=A!==-1,ce=n.inFlow??t.flow??t.items.length===0;if(D||!ce){let ke=!1;if(D&&(O==="&"||O==="!")){let B=x.indexOf(" ");if(O==="&"&&B!==-1&&B<A&&x[B+1]==="!")B=x.indexOf(" ",B+1);if(B===-1||A<B)ke=!0}if(!ke)S=`
44
+ `),j=A!==-1,ce=n.inFlow??t.flow??t.items.length===0;if(j||!ce){let ke=!1;if(j&&(O==="&"||O==="!")){let B=x.indexOf(" ");if(O==="&"&&B!==-1&&B<A&&x[B+1]==="!")B=x.indexOf(" ",B+1);if(B===-1||A<B)ke=!0}if(!ke)S=`
45
45
  ${n.indent}`}}else if(x===""||x[0]===`
46
46
  `)S="";if(g+=S+x,n.inFlow){if(y&&r)r()}else if(_&&!y)g+=Nn.lineComment(g,n.indent,l(_));else if(m&&i)i();return g}Gw.stringifyPair=Zw});var to=P(function(Fw){var Yl=Ce("process");function Bw(e,...t){if(e==="debug")console.log(...t)}function Hw(e,t){if(e==="debug"||e==="warn")if(typeof Yl.emitWarning==="function")Yl.emitWarning(t);else console.warn(t)}Fw.debug=Bw;Fw.warn=Hw});var Jr=P(function(Yw){var Yr=z(),Jl=W(),Wr="<<",Vr={identify:(e)=>e===Wr||typeof e==="symbol"&&e.description===Wr,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new Jl.Scalar(Symbol(Wr)),{addToJSMap:Ql}),stringify:()=>Wr},Vw=(e,t)=>(Vr.identify(t)||Yr.isScalar(t)&&(!t.type||t.type===Jl.Scalar.PLAIN)&&Vr.identify(t.value))&&e?.doc.schema.tags.some((n)=>n.tag===Vr.tag&&n.default);function Ql(e,t,n){let r=Xl(e,n);if(Yr.isSeq(r))for(let i of r.items)no(e,t,i);else if(Array.isArray(r))for(let i of r)no(e,t,i);else no(e,t,r)}function no(e,t,n){let r=Xl(e,n);if(!Yr.isMap(r))throw Error("Merge sources must be maps or map aliases");let i=r.toJSON(null,e,Map);for(let[s,o]of i)if(t instanceof Map){if(!t.has(s))t.set(s,o)}else if(t instanceof Set)t.add(s);else if(!Object.prototype.hasOwnProperty.call(t,s))Object.defineProperty(t,s,{value:o,writable:!0,enumerable:!0,configurable:!0});return t}function Xl(e,t){return e&&Yr.isAlias(t)?t.resolve(e.doc,e):t}Yw.addMergeToJSMap=Ql;Yw.isMergeKey=Vw;Yw.merge=Vr});var io=P(function(i0){var e0=to(),eu=Jr(),t0=In(),tu=z(),ro=ct();function n0(e,t,{key:n,value:r}){if(tu.isNode(n)&&n.addToJSMap)n.addToJSMap(e,t,r);else if(eu.isMergeKey(e,n))eu.addMergeToJSMap(e,t,r);else{let i=ro.toJS(n,"",e);if(t instanceof Map)t.set(i,ro.toJS(r,i,e));else if(t instanceof Set)t.add(i);else{let s=r0(n,i,e),o=ro.toJS(r,s,e);if(s in t)Object.defineProperty(t,s,{value:o,writable:!0,enumerable:!0,configurable:!0});else t[s]=o}}return t}function r0(e,t,n){if(t===null)return"";if(typeof t!=="object")return String(t);if(tu.isNode(e)&&n?.doc){let r=t0.createStringifyContext(n.doc,{});r.anchors=new Set;for(let s of n.anchors.keys())r.anchors.add(s.anchor);r.inFlow=!0,r.inStringifyKey=!0;let i=e.toString(r);if(!n.mapKeyWarned){let s=JSON.stringify(i);if(s.length>40)s=s.substring(0,36)+'..."';e0.warn(n.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${s}. Set mapAsMap: true to use object keys.`),n.mapKeyWarned=!0}return i}return JSON.stringify(t)}i0.addPairToJSMap=n0});var pt=P(function(l0){var nu=En(),o0=Vl(),a0=io(),Qr=z();function c0(e,t,n){let r=nu.createNode(e,void 0,n),i=nu.createNode(t,void 0,n);return new Xr(r,i)}class Xr{constructor(e,t=null){Object.defineProperty(this,Qr.NODE_TYPE,{value:Qr.PAIR}),this.key=e,this.value=t}clone(e){let{key:t,value:n}=this;if(Qr.isNode(t))t=t.clone(e);if(Qr.isNode(n))n=n.clone(e);return new Xr(t,n)}toJSON(e,t){let n=t?.mapAsMap?new Map:{};return a0.addPairToJSMap(t,n,this)}toString(e,t,n){return e?.doc?o0.stringifyPair(this,e,t,n):JSON.stringify(this)}}l0.Pair=Xr;l0.createPair=c0});var so=P(function(m0){var Ct=z(),ru=In(),ei=On();function d0(e,t,n){return(t.inFlow??e.flow?f0:h0)(e,t,n)}function h0({comment:e,items:t},n,{blockItemPrefix:r,flowChars:i,itemIndent:s,onChompKeep:o,onComment:a}){let{indent:c,options:{commentString:l}}=n,u=Object.assign({},n,{indent:s,type:null}),p=!1,d=[];for(let f=0;f<t.length;++f){let m=t[f],g=null;if(Ct.isNode(m)){if(!p&&m.spaceBefore)d.push("");if(ti(n,d,m.commentBefore,p),m.comment)g=m.comment}else if(Ct.isPair(m)){let k=Ct.isNode(m.key)?m.key:null;if(k){if(!p&&k.spaceBefore)d.push("");ti(n,d,k.commentBefore,p)}}p=!1;let w=ru.stringify(m,u,()=>g=null,()=>p=!0);if(g)w+=ei.lineComment(w,s,l(g));if(p&&g)p=!1;d.push(r+w)}let h;if(d.length===0)h=i.start+i.end;else{h=d[0];for(let f=1;f<d.length;++f){let m=d[f];h+=m?`
47
47
  ${c}${m}`:`
@@ -50,10 +50,10 @@ ${c}${m}`:`
50
50
  `)),f<e.length-1)w+=",";else if(t.options.trailingComma){if(t.options.lineWidth>0)l||(l=p.reduce((k,_)=>k+_.length+2,2)+(w.length+2)>t.options.lineWidth);if(l)w+=","}if(g)w+=ei.lineComment(w,r,a(g));p.push(w),u=p.length}let{start:d,end:h}=n;if(p.length===0)return d+h;else{if(!l){let f=p.reduce((m,g)=>m+g.length+2,2);l=t.options.lineWidth>0&&f>t.options.lineWidth}if(l){let f=d;for(let m of p)f+=m?`
51
51
  ${s}${i}${m}`:`
52
52
  `;return`${f}
53
- ${i}${h}`}else return`${d}${o}${p.join(" ")}${o}${h}`}}function ti({indent:e,options:{commentString:t}},n,r,i){if(r&&i)r=r.replace(/^\n+/,"");if(r){let s=ei.indentComment(t(r),e);n.push(s.trimStart())}}m0.stringifyCollection=d0});var ht=P(function(_0){var v0=so(),y0=io(),b0=Br(),dt=z(),ni=pt(),w0=W();function zn(e,t){let n=dt.isScalar(t)?t.value:t;for(let r of e)if(dt.isPair(r)){if(r.key===t||r.key===n)return r;if(dt.isScalar(r.key)&&r.key.value===n)return r}return}class iu extends b0.Collection{static get tagName(){return"tag:yaml.org,2002:map"}constructor(e){super(dt.MAP,e);this.items=[]}static from(e,t,n){let{keepUndefined:r,replacer:i}=n,s=new this(e),o=(a,c)=>{if(typeof i==="function")c=i.call(t,a,c);else if(Array.isArray(i)&&!i.includes(a))return;if(c!==void 0||r)s.items.push(ni.createPair(a,c,n))};if(t instanceof Map)for(let[a,c]of t)o(a,c);else if(t&&typeof t==="object")for(let a of Object.keys(t))o(a,t[a]);if(typeof e.sortMapEntries==="function")s.items.sort(e.sortMapEntries);return s}add(e,t){let n;if(dt.isPair(e))n=e;else if(!e||typeof e!=="object"||!("key"in e))n=new ni.Pair(e,e?.value);else n=new ni.Pair(e.key,e.value);let r=zn(this.items,n.key),i=this.schema?.sortMapEntries;if(r){if(!t)throw Error(`Key ${n.key} already set`);if(dt.isScalar(r.value)&&w0.isScalarValue(n.value))r.value.value=n.value;else r.value=n.value}else if(i){let s=this.items.findIndex((o)=>i(n,o)<0);if(s===-1)this.items.push(n);else this.items.splice(s,0,n)}else this.items.push(n)}delete(e){let t=zn(this.items,e);if(!t)return!1;return this.items.splice(this.items.indexOf(t),1).length>0}get(e,t){let r=zn(this.items,e)?.value;return(!t&&dt.isScalar(r)?r.value:r)??void 0}has(e){return!!zn(this.items,e)}set(e,t){this.add(new ni.Pair(e,t),!0)}toJSON(e,t,n){let r=n?new n:t?.mapAsMap?new Map:{};if(t?.onCreate)t.onCreate(r);for(let i of this.items)y0.addPairToJSMap(t,r,i);return r}toString(e,t,n){if(!e)return JSON.stringify(this);for(let r of this.items)if(!dt.isPair(r))throw Error(`Map items must all be pairs; found ${JSON.stringify(r)} instead`);if(!e.allNullValues&&this.hasAllNullValues(!1))e=Object.assign({},e,{allNullValues:!0});return v0.stringifyCollection(this,e,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:e.indent||"",onChompKeep:n,onComment:t})}}_0.YAMLMap=iu;_0.findPair=zn});var Qt=P(function($0){var S0=z(),su=ht(),A0={collection:"map",default:!0,nodeClass:su.YAMLMap,tag:"tag:yaml.org,2002:map",resolve(e,t){if(!S0.isMap(e))t("Expected a mapping for this tag");return e},createNode:(e,t,n)=>su.YAMLMap.from(e,t,n)};$0.map=A0});var ft=P(function(I0){var T0=En(),E0=so(),O0=Br(),ii=z(),C0=W(),R0=ct();class ou extends O0.Collection{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(e){super(ii.SEQ,e);this.items=[]}add(e){this.items.push(e)}delete(e){let t=ri(e);if(typeof t!=="number")return!1;return this.items.splice(t,1).length>0}get(e,t){let n=ri(e);if(typeof n!=="number")return;let r=this.items[n];return!t&&ii.isScalar(r)?r.value:r}has(e){let t=ri(e);return typeof t==="number"&&t<this.items.length}set(e,t){let n=ri(e);if(typeof n!=="number")throw Error(`Expected a valid index, not ${e}.`);let r=this.items[n];if(ii.isScalar(r)&&C0.isScalarValue(t))r.value=t;else this.items[n]=t}toJSON(e,t){let n=[];if(t?.onCreate)t.onCreate(n);let r=0;for(let i of this.items)n.push(R0.toJS(i,String(r++),t));return n}toString(e,t,n){if(!e)return JSON.stringify(this);return E0.stringifyCollection(this,e,{blockItemPrefix:"- ",flowChars:{start:"[",end:"]"},itemIndent:(e.indent||"")+" ",onChompKeep:n,onComment:t})}static from(e,t,n){let{replacer:r}=n,i=new this(e);if(t&&Symbol.iterator in Object(t)){let s=0;for(let o of t){if(typeof r==="function"){let a=t instanceof Set?o:String(s++);o=r.call(t,a,o)}i.items.push(T0.createNode(o,void 0,n))}}return i}}function ri(e){let t=ii.isScalar(e)?e.value:e;if(t&&typeof t==="string")t=Number(t);return typeof t==="number"&&Number.isInteger(t)&&t>=0?t:null}I0.YAMLSeq=ou});var Xt=P(function(D0){var z0=z(),au=ft(),j0={collection:"seq",default:!0,nodeClass:au.YAMLSeq,tag:"tag:yaml.org,2002:seq",resolve(e,t){if(!z0.isSeq(e))t("Expected a sequence for this tag");return e},createNode:(e,t,n)=>au.YAMLSeq.from(e,t,n)};D0.seq=j0});var jn=P(function(Z0){var M0=Rn(),U0={identify:(e)=>typeof e==="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:(e)=>e,stringify(e,t,n,r){return t=Object.assign({actualString:!0},t),M0.stringifyString(e,t,n,r)}};Z0.string=U0});var si=P(function(q0){var cu=W(),lu={identify:(e)=>e==null,createNode:()=>new cu.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new cu.Scalar(null),stringify:({source:e},t)=>typeof e==="string"&&lu.test.test(e)?e:t.options.nullStr};q0.nullTag=lu});var oo=P(function(F0){var H0=W(),uu={identify:(e)=>typeof e==="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:(e)=>new H0.Scalar(e[0]==="t"||e[0]==="T"),stringify({source:e,value:t},n){if(e&&uu.test.test(e)){let r=e[0]==="t"||e[0]==="T";if(t===r)return e}return t?n.options.trueStr:n.options.falseStr}};F0.boolTag=uu});var en=P(function(V0){function W0({format:e,minFractionDigits:t,tag:n,value:r}){if(typeof r==="bigint")return String(r);let i=typeof r==="number"?r:Number(r);if(!isFinite(i))return isNaN(i)?".nan":i<0?"-.inf":".inf";let s=Object.is(r,-0)?"-0":JSON.stringify(r);if(!e&&t&&(!n||n==="tag:yaml.org,2002:float")&&/^-?\d/.test(s)&&!s.includes("e")){let o=s.indexOf(".");if(o<0)o=s.length,s+=".";let a=t-(s.length-o-1);while(a-- >0)s+="0"}return s}V0.stringifyNumber=W0});var co=P(function(t_){var J0=W(),ao=en(),Q0={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:(e)=>e.slice(-3).toLowerCase()==="nan"?NaN:e[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:ao.stringifyNumber},X0={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:(e)=>parseFloat(e),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():ao.stringifyNumber(e)}},e_={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(e){let t=new J0.Scalar(parseFloat(e)),n=e.indexOf(".");if(n!==-1&&e[e.length-1]==="0")t.minFractionDigits=e.length-n-1;return t},stringify:ao.stringifyNumber};t_.float=e_;t_.floatExp=X0;t_.floatNaN=Q0});var uo=P(function(c_){var pu=en(),oi=(e)=>typeof e==="bigint"||Number.isInteger(e),lo=(e,t,n,{intAsBigInt:r})=>r?BigInt(e):parseInt(e.substring(t),n);function du(e,t,n){let{value:r}=e;if(oi(r)&&r>=0)return n+r.toString(t);return pu.stringifyNumber(e)}var s_={identify:(e)=>oi(e)&&e>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(e,t,n)=>lo(e,2,8,n),stringify:(e)=>du(e,8,"0o")},o_={identify:oi,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(e,t,n)=>lo(e,0,10,n),stringify:pu.stringifyNumber},a_={identify:(e)=>oi(e)&&e>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(e,t,n)=>lo(e,2,16,n),stringify:(e)=>du(e,16,"0x")};c_.int=o_;c_.intHex=a_;c_.intOct=s_});var hu=P(function(y_){var d_=Qt(),h_=si(),f_=Xt(),m_=jn(),g_=oo(),po=co(),ho=uo(),v_=[d_.map,f_.seq,m_.string,h_.nullTag,g_.boolTag,ho.intOct,ho.int,ho.intHex,po.floatNaN,po.floatExp,po.float];y_.schema=v_});var mu=P(function($_){var w_=W(),__=Qt(),k_=Xt();function fu(e){return typeof e==="bigint"||Number.isInteger(e)}var ai=({value:e})=>JSON.stringify(e),x_=[{identify:(e)=>typeof e==="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:(e)=>e,stringify:ai},{identify:(e)=>e==null,createNode:()=>new w_.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:ai},{identify:(e)=>typeof e==="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:(e)=>e==="true",stringify:ai},{identify:fu,default:!0,tag:"tag:yaml.org,2002:int",test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(e,t,{intAsBigInt:n})=>n?BigInt(e):parseInt(e,10),stringify:({value:e})=>fu(e)?e.toString():JSON.stringify(e)},{identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:(e)=>parseFloat(e),stringify:ai}],S_={default:!0,tag:"",test:/^/,resolve(e,t){return t(`Unresolved plain scalar ${JSON.stringify(e)}`),e}},A_=[__.map,k_.seq].concat(x_,S_);$_.schema=A_});var mo=P(function(O_){var Dn=Ce("buffer"),fo=W(),T_=Rn(),E_={identify:(e)=>e instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(e,t){if(typeof Dn.Buffer==="function")return Dn.Buffer.from(e,"base64");else if(typeof atob==="function"){let n=atob(e.replace(/[\n\r]/g,"")),r=new Uint8Array(n.length);for(let i=0;i<n.length;++i)r[i]=n.charCodeAt(i);return r}else return t("This environment does not support reading binary tags; either Buffer or atob is required"),e},stringify({comment:e,type:t,value:n},r,i,s){if(!n)return"";let o=n,a;if(typeof Dn.Buffer==="function")a=o instanceof Dn.Buffer?o.toString("base64"):Dn.Buffer.from(o.buffer).toString("base64");else if(typeof btoa==="function"){let c="";for(let l=0;l<o.length;++l)c+=String.fromCharCode(o[l]);a=btoa(c)}else throw Error("This environment does not support writing binary tags; either Buffer or btoa is required");if(t??(t=fo.Scalar.BLOCK_LITERAL),t!==fo.Scalar.QUOTE_DOUBLE){let c=Math.max(r.options.lineWidth-r.indent.length,r.options.minContentWidth),l=Math.ceil(a.length/c),u=Array(l);for(let p=0,d=0;p<l;++p,d+=c)u[p]=a.substr(d,c);a=u.join(t===fo.Scalar.BLOCK_LITERAL?`
53
+ ${i}${h}`}else return`${d}${o}${p.join(" ")}${o}${h}`}}function ti({indent:e,options:{commentString:t}},n,r,i){if(r&&i)r=r.replace(/^\n+/,"");if(r){let s=ei.indentComment(t(r),e);n.push(s.trimStart())}}m0.stringifyCollection=d0});var ht=P(function(_0){var v0=so(),y0=io(),b0=Br(),dt=z(),ni=pt(),w0=W();function zn(e,t){let n=dt.isScalar(t)?t.value:t;for(let r of e)if(dt.isPair(r)){if(r.key===t||r.key===n)return r;if(dt.isScalar(r.key)&&r.key.value===n)return r}return}class iu extends b0.Collection{static get tagName(){return"tag:yaml.org,2002:map"}constructor(e){super(dt.MAP,e);this.items=[]}static from(e,t,n){let{keepUndefined:r,replacer:i}=n,s=new this(e),o=(a,c)=>{if(typeof i==="function")c=i.call(t,a,c);else if(Array.isArray(i)&&!i.includes(a))return;if(c!==void 0||r)s.items.push(ni.createPair(a,c,n))};if(t instanceof Map)for(let[a,c]of t)o(a,c);else if(t&&typeof t==="object")for(let a of Object.keys(t))o(a,t[a]);if(typeof e.sortMapEntries==="function")s.items.sort(e.sortMapEntries);return s}add(e,t){let n;if(dt.isPair(e))n=e;else if(!e||typeof e!=="object"||!("key"in e))n=new ni.Pair(e,e?.value);else n=new ni.Pair(e.key,e.value);let r=zn(this.items,n.key),i=this.schema?.sortMapEntries;if(r){if(!t)throw Error(`Key ${n.key} already set`);if(dt.isScalar(r.value)&&w0.isScalarValue(n.value))r.value.value=n.value;else r.value=n.value}else if(i){let s=this.items.findIndex((o)=>i(n,o)<0);if(s===-1)this.items.push(n);else this.items.splice(s,0,n)}else this.items.push(n)}delete(e){let t=zn(this.items,e);if(!t)return!1;return this.items.splice(this.items.indexOf(t),1).length>0}get(e,t){let r=zn(this.items,e)?.value;return(!t&&dt.isScalar(r)?r.value:r)??void 0}has(e){return!!zn(this.items,e)}set(e,t){this.add(new ni.Pair(e,t),!0)}toJSON(e,t,n){let r=n?new n:t?.mapAsMap?new Map:{};if(t?.onCreate)t.onCreate(r);for(let i of this.items)y0.addPairToJSMap(t,r,i);return r}toString(e,t,n){if(!e)return JSON.stringify(this);for(let r of this.items)if(!dt.isPair(r))throw Error(`Map items must all be pairs; found ${JSON.stringify(r)} instead`);if(!e.allNullValues&&this.hasAllNullValues(!1))e=Object.assign({},e,{allNullValues:!0});return v0.stringifyCollection(this,e,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:e.indent||"",onChompKeep:n,onComment:t})}}_0.YAMLMap=iu;_0.findPair=zn});var Qt=P(function($0){var S0=z(),su=ht(),A0={collection:"map",default:!0,nodeClass:su.YAMLMap,tag:"tag:yaml.org,2002:map",resolve(e,t){if(!S0.isMap(e))t("Expected a mapping for this tag");return e},createNode:(e,t,n)=>su.YAMLMap.from(e,t,n)};$0.map=A0});var ft=P(function(I0){var T0=En(),E0=so(),O0=Br(),ii=z(),C0=W(),R0=ct();class ou extends O0.Collection{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(e){super(ii.SEQ,e);this.items=[]}add(e){this.items.push(e)}delete(e){let t=ri(e);if(typeof t!=="number")return!1;return this.items.splice(t,1).length>0}get(e,t){let n=ri(e);if(typeof n!=="number")return;let r=this.items[n];return!t&&ii.isScalar(r)?r.value:r}has(e){let t=ri(e);return typeof t==="number"&&t<this.items.length}set(e,t){let n=ri(e);if(typeof n!=="number")throw Error(`Expected a valid index, not ${e}.`);let r=this.items[n];if(ii.isScalar(r)&&C0.isScalarValue(t))r.value=t;else this.items[n]=t}toJSON(e,t){let n=[];if(t?.onCreate)t.onCreate(n);let r=0;for(let i of this.items)n.push(R0.toJS(i,String(r++),t));return n}toString(e,t,n){if(!e)return JSON.stringify(this);return E0.stringifyCollection(this,e,{blockItemPrefix:"- ",flowChars:{start:"[",end:"]"},itemIndent:(e.indent||"")+" ",onChompKeep:n,onComment:t})}static from(e,t,n){let{replacer:r}=n,i=new this(e);if(t&&Symbol.iterator in Object(t)){let s=0;for(let o of t){if(typeof r==="function"){let a=t instanceof Set?o:String(s++);o=r.call(t,a,o)}i.items.push(T0.createNode(o,void 0,n))}}return i}}function ri(e){let t=ii.isScalar(e)?e.value:e;if(t&&typeof t==="string")t=Number(t);return typeof t==="number"&&Number.isInteger(t)&&t>=0?t:null}I0.YAMLSeq=ou});var Xt=P(function(j0){var z0=z(),au=ft(),L0={collection:"seq",default:!0,nodeClass:au.YAMLSeq,tag:"tag:yaml.org,2002:seq",resolve(e,t){if(!z0.isSeq(e))t("Expected a sequence for this tag");return e},createNode:(e,t,n)=>au.YAMLSeq.from(e,t,n)};j0.seq=L0});var Ln=P(function(Z0){var M0=Rn(),U0={identify:(e)=>typeof e==="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:(e)=>e,stringify(e,t,n,r){return t=Object.assign({actualString:!0},t),M0.stringifyString(e,t,n,r)}};Z0.string=U0});var si=P(function(q0){var cu=W(),lu={identify:(e)=>e==null,createNode:()=>new cu.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new cu.Scalar(null),stringify:({source:e},t)=>typeof e==="string"&&lu.test.test(e)?e:t.options.nullStr};q0.nullTag=lu});var oo=P(function(F0){var H0=W(),uu={identify:(e)=>typeof e==="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:(e)=>new H0.Scalar(e[0]==="t"||e[0]==="T"),stringify({source:e,value:t},n){if(e&&uu.test.test(e)){let r=e[0]==="t"||e[0]==="T";if(t===r)return e}return t?n.options.trueStr:n.options.falseStr}};F0.boolTag=uu});var en=P(function(V0){function W0({format:e,minFractionDigits:t,tag:n,value:r}){if(typeof r==="bigint")return String(r);let i=typeof r==="number"?r:Number(r);if(!isFinite(i))return isNaN(i)?".nan":i<0?"-.inf":".inf";let s=Object.is(r,-0)?"-0":JSON.stringify(r);if(!e&&t&&(!n||n==="tag:yaml.org,2002:float")&&/^-?\d/.test(s)&&!s.includes("e")){let o=s.indexOf(".");if(o<0)o=s.length,s+=".";let a=t-(s.length-o-1);while(a-- >0)s+="0"}return s}V0.stringifyNumber=W0});var co=P(function(t_){var J0=W(),ao=en(),Q0={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:(e)=>e.slice(-3).toLowerCase()==="nan"?NaN:e[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:ao.stringifyNumber},X0={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:(e)=>parseFloat(e),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():ao.stringifyNumber(e)}},e_={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(e){let t=new J0.Scalar(parseFloat(e)),n=e.indexOf(".");if(n!==-1&&e[e.length-1]==="0")t.minFractionDigits=e.length-n-1;return t},stringify:ao.stringifyNumber};t_.float=e_;t_.floatExp=X0;t_.floatNaN=Q0});var uo=P(function(c_){var pu=en(),oi=(e)=>typeof e==="bigint"||Number.isInteger(e),lo=(e,t,n,{intAsBigInt:r})=>r?BigInt(e):parseInt(e.substring(t),n);function du(e,t,n){let{value:r}=e;if(oi(r)&&r>=0)return n+r.toString(t);return pu.stringifyNumber(e)}var s_={identify:(e)=>oi(e)&&e>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(e,t,n)=>lo(e,2,8,n),stringify:(e)=>du(e,8,"0o")},o_={identify:oi,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(e,t,n)=>lo(e,0,10,n),stringify:pu.stringifyNumber},a_={identify:(e)=>oi(e)&&e>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(e,t,n)=>lo(e,2,16,n),stringify:(e)=>du(e,16,"0x")};c_.int=o_;c_.intHex=a_;c_.intOct=s_});var hu=P(function(y_){var d_=Qt(),h_=si(),f_=Xt(),m_=Ln(),g_=oo(),po=co(),ho=uo(),v_=[d_.map,f_.seq,m_.string,h_.nullTag,g_.boolTag,ho.intOct,ho.int,ho.intHex,po.floatNaN,po.floatExp,po.float];y_.schema=v_});var mu=P(function($_){var w_=W(),__=Qt(),k_=Xt();function fu(e){return typeof e==="bigint"||Number.isInteger(e)}var ai=({value:e})=>JSON.stringify(e),x_=[{identify:(e)=>typeof e==="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:(e)=>e,stringify:ai},{identify:(e)=>e==null,createNode:()=>new w_.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:ai},{identify:(e)=>typeof e==="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:(e)=>e==="true",stringify:ai},{identify:fu,default:!0,tag:"tag:yaml.org,2002:int",test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(e,t,{intAsBigInt:n})=>n?BigInt(e):parseInt(e,10),stringify:({value:e})=>fu(e)?e.toString():JSON.stringify(e)},{identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:(e)=>parseFloat(e),stringify:ai}],S_={default:!0,tag:"",test:/^/,resolve(e,t){return t(`Unresolved plain scalar ${JSON.stringify(e)}`),e}},A_=[__.map,k_.seq].concat(x_,S_);$_.schema=A_});var mo=P(function(O_){var jn=Ce("buffer"),fo=W(),T_=Rn(),E_={identify:(e)=>e instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(e,t){if(typeof jn.Buffer==="function")return jn.Buffer.from(e,"base64");else if(typeof atob==="function"){let n=atob(e.replace(/[\n\r]/g,"")),r=new Uint8Array(n.length);for(let i=0;i<n.length;++i)r[i]=n.charCodeAt(i);return r}else return t("This environment does not support reading binary tags; either Buffer or atob is required"),e},stringify({comment:e,type:t,value:n},r,i,s){if(!n)return"";let o=n,a;if(typeof jn.Buffer==="function")a=o instanceof jn.Buffer?o.toString("base64"):jn.Buffer.from(o.buffer).toString("base64");else if(typeof btoa==="function"){let c="";for(let l=0;l<o.length;++l)c+=String.fromCharCode(o[l]);a=btoa(c)}else throw Error("This environment does not support writing binary tags; either Buffer or btoa is required");if(t??(t=fo.Scalar.BLOCK_LITERAL),t!==fo.Scalar.QUOTE_DOUBLE){let c=Math.max(r.options.lineWidth-r.indent.length,r.options.minContentWidth),l=Math.ceil(a.length/c),u=Array(l);for(let p=0,d=0;p<l;++p,d+=c)u[p]=a.substr(d,c);a=u.join(t===fo.Scalar.BLOCK_LITERAL?`
54
54
  `:" ")}return T_.stringifyString({comment:e,type:t,value:a},r,i,s)}};O_.binary=E_});var li=P(function(z_){var ci=z(),go=pt(),R_=W(),I_=ft();function gu(e,t){if(ci.isSeq(e))for(let n=0;n<e.items.length;++n){let r=e.items[n];if(ci.isPair(r))continue;else if(ci.isMap(r)){if(r.items.length>1)t("Each pair must have its own sequence indicator");let i=r.items[0]||new go.Pair(new R_.Scalar(null));if(r.commentBefore)i.key.commentBefore=i.key.commentBefore?`${r.commentBefore}
55
55
  ${i.key.commentBefore}`:r.commentBefore;if(r.comment){let s=i.value??i.key;s.comment=s.comment?`${r.comment}
56
- ${s.comment}`:r.comment}r=i}e.items[n]=ci.isPair(r)?r:new go.Pair(r)}else t("Expected a sequence for this tag");return e}function vu(e,t,n){let{replacer:r}=n,i=new I_.YAMLSeq(e);i.tag="tag:yaml.org,2002:pairs";let s=0;if(t&&Symbol.iterator in Object(t))for(let o of t){if(typeof r==="function")o=r.call(t,String(s++),o);let a,c;if(Array.isArray(o))if(o.length===2)a=o[0],c=o[1];else throw TypeError(`Expected [key, value] tuple: ${o}`);else if(o&&o instanceof Object){let l=Object.keys(o);if(l.length===1)a=l[0],c=o[a];else throw TypeError(`Expected tuple with one key, not ${l.length} keys`)}else a=o;i.items.push(go.createPair(a,c,n))}return i}var N_={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:gu,createNode:vu};z_.createPairs=vu;z_.pairs=N_;z_.resolvePairs=gu});var yo=P(function(Z_){var yu=z(),vo=ct(),Ln=ht(),M_=ft(),bu=li();class Rt extends M_.YAMLSeq{constructor(){super();this.add=Ln.YAMLMap.prototype.add.bind(this),this.delete=Ln.YAMLMap.prototype.delete.bind(this),this.get=Ln.YAMLMap.prototype.get.bind(this),this.has=Ln.YAMLMap.prototype.has.bind(this),this.set=Ln.YAMLMap.prototype.set.bind(this),this.tag=Rt.tag}toJSON(e,t){if(!t)return super.toJSON(e);let n=new Map;if(t?.onCreate)t.onCreate(n);for(let r of this.items){let i,s;if(yu.isPair(r))i=vo.toJS(r.key,"",t),s=vo.toJS(r.value,i,t);else i=vo.toJS(r,"",t);if(n.has(i))throw Error("Ordered maps must not include duplicate keys");n.set(i,s)}return n}static from(e,t,n){let r=bu.createPairs(e,t,n),i=new this;return i.items=r.items,i}}Rt.tag="tag:yaml.org,2002:omap";var U_={collection:"seq",identify:(e)=>e instanceof Map,nodeClass:Rt,default:!1,tag:"tag:yaml.org,2002:omap",resolve(e,t){let n=bu.resolvePairs(e,t),r=[];for(let{key:i}of n.items)if(yu.isScalar(i))if(r.includes(i.value))t(`Ordered maps must not include duplicate keys: ${i.value}`);else r.push(i.value);return Object.assign(new Rt,n)},createNode:(e,t,n)=>Rt.from(e,t,n)};Z_.YAMLOMap=Rt;Z_.omap=U_});var Su=P(function(B_){var wu=W();function _u({value:e,source:t},n){if(t&&(e?ku:xu).test.test(t))return t;return e?n.options.trueStr:n.options.falseStr}var ku={identify:(e)=>e===!0,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new wu.Scalar(!0),stringify:_u},xu={identify:(e)=>e===!1,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new wu.Scalar(!1),stringify:_u};B_.falseTag=xu;B_.trueTag=ku});var Au=P(function(J_){var K_=W(),bo=en(),W_={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:(e)=>e.slice(-3).toLowerCase()==="nan"?NaN:e[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:bo.stringifyNumber},V_={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:(e)=>parseFloat(e.replace(/_/g,"")),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():bo.stringifyNumber(e)}},Y_={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(e){let t=new K_.Scalar(parseFloat(e.replace(/_/g,""))),n=e.indexOf(".");if(n!==-1){let r=e.substring(n+1).replace(/_/g,"");if(r[r.length-1]==="0")t.minFractionDigits=r.length}return t},stringify:bo.stringifyNumber};J_.float=Y_;J_.floatExp=V_;J_.floatNaN=W_});var Pu=P(function(sk){var $u=en(),Mn=(e)=>typeof e==="bigint"||Number.isInteger(e);function ui(e,t,n,{intAsBigInt:r}){let i=e[0];if(i==="-"||i==="+")t+=1;if(e=e.substring(t).replace(/_/g,""),r){switch(n){case 2:e=`0b${e}`;break;case 8:e=`0o${e}`;break;case 16:e=`0x${e}`;break}let o=BigInt(e);return i==="-"?BigInt(-1)*o:o}let s=parseInt(e,n);return i==="-"?-1*s:s}function wo(e,t,n){let{value:r}=e;if(Mn(r)){let i=r.toString(t);return r<0?"-"+n+i.substr(1):n+i}return $u.stringifyNumber(e)}var tk={identify:Mn,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(e,t,n)=>ui(e,2,2,n),stringify:(e)=>wo(e,2,"0b")},nk={identify:Mn,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(e,t,n)=>ui(e,1,8,n),stringify:(e)=>wo(e,8,"0")},rk={identify:Mn,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(e,t,n)=>ui(e,0,10,n),stringify:$u.stringifyNumber},ik={identify:Mn,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(e,t,n)=>ui(e,2,16,n),stringify:(e)=>wo(e,16,"0x")};sk.int=rk;sk.intBin=tk;sk.intHex=ik;sk.intOct=nk});var _o=P(function(pk){var hi=z(),pi=pt(),di=ht();class It extends di.YAMLMap{constructor(e){super(e);this.tag=It.tag}add(e){let t;if(hi.isPair(e))t=e;else if(e&&typeof e==="object"&&"key"in e&&"value"in e&&e.value===null)t=new pi.Pair(e.key,null);else t=new pi.Pair(e,null);if(!di.findPair(this.items,t.key))this.items.push(t)}get(e,t){let n=di.findPair(this.items,e);return!t&&hi.isPair(n)?hi.isScalar(n.key)?n.key.value:n.key:n}set(e,t){if(typeof t!=="boolean")throw Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof t}`);let n=di.findPair(this.items,e);if(n&&!t)this.items.splice(this.items.indexOf(n),1);else if(!n&&t)this.items.push(new pi.Pair(e))}toJSON(e,t){return super.toJSON(e,t,Set)}toString(e,t,n){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),t,n);else throw Error("Set items must all have null values")}static from(e,t,n){let{replacer:r}=n,i=new this(e);if(t&&Symbol.iterator in Object(t))for(let s of t){if(typeof r==="function")s=r.call(t,s,s);i.items.push(pi.createPair(s,null,n))}return i}}It.tag="tag:yaml.org,2002:set";var uk={collection:"map",identify:(e)=>e instanceof Set,nodeClass:It,default:!1,tag:"tag:yaml.org,2002:set",createNode:(e,t,n)=>It.from(e,t,n),resolve(e,t){if(hi.isMap(e))if(e.hasAllNullValues(!0))return Object.assign(new It,e);else t("Set items must all have null values");else t("Expected a mapping for this tag");return e}};pk.YAMLSet=It;pk.set=uk});var xo=P(function(vk){var fk=en();function ko(e,t){let n=e[0],r=n==="-"||n==="+"?e.substring(1):e,i=(o)=>t?BigInt(o):Number(o),s=r.replace(/_/g,"").split(":").reduce((o,a)=>o*i(60)+i(a),i(0));return n==="-"?i(-1)*s:s}function Tu(e){let{value:t}=e,n=(o)=>o;if(typeof t==="bigint")n=(o)=>BigInt(o);else if(isNaN(t)||!isFinite(t))return fk.stringifyNumber(e);let r="";if(t<0)r="-",t*=n(-1);let i=n(60),s=[t%i];if(t<60)s.unshift(0);else if(t=(t-s[0])/i,s.unshift(t%i),t>=60)t=(t-s[0])/i,s.unshift(t);return r+s.map((o)=>String(o).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}var mk={identify:(e)=>typeof e==="bigint"||Number.isInteger(e),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(e,t,{intAsBigInt:n})=>ko(e,n),stringify:Tu},gk={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:(e)=>ko(e,!1),stringify:Tu},Eu={identify:(e)=>e instanceof Date,default:!0,tag:"tag:yaml.org,2002:timestamp",test:RegExp("^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$"),resolve(e){let t=e.match(Eu.test);if(!t)throw Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,n,r,i,s,o,a]=t.map(Number),c=t[7]?Number((t[7]+"00").substr(1,3)):0,l=Date.UTC(n,r-1,i,s||0,o||0,a||0,c),u=t[8];if(u&&u!=="Z"){let p=ko(u,!1);if(Math.abs(p)<30)p*=60;l-=60000*p}return new Date(l)},stringify:({value:e})=>e?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};vk.floatTime=gk;vk.intTime=mk;vk.timestamp=Eu});var Cu=P(function(Ck){var _k=Qt(),kk=si(),xk=Xt(),Sk=jn(),Ak=mo(),Ou=Su(),So=Au(),fi=Pu(),$k=Jr(),Pk=yo(),Tk=li(),Ek=_o(),Ao=xo(),Ok=[_k.map,xk.seq,Sk.string,kk.nullTag,Ou.trueTag,Ou.falseTag,fi.intBin,fi.intOct,fi.int,fi.intHex,So.floatNaN,So.floatExp,So.float,Ak.binary,$k.merge,Pk.omap,Tk.pairs,Ek.set,Ao.intTime,Ao.floatTime,Ao.timestamp];Ck.schema=Ok});var Zu=P(function(Uk){var zu=Qt(),Ik=si(),ju=Xt(),Nk=jn(),zk=oo(),$o=co(),Po=uo(),jk=hu(),Dk=mu(),Du=mo(),Un=Jr(),Lu=yo(),Mu=li(),Ru=Cu(),Uu=_o(),mi=xo(),Iu=new Map([["core",jk.schema],["failsafe",[zu.map,ju.seq,Nk.string]],["json",Dk.schema],["yaml11",Ru.schema],["yaml-1.1",Ru.schema]]),Nu={binary:Du.binary,bool:zk.boolTag,float:$o.float,floatExp:$o.floatExp,floatNaN:$o.floatNaN,floatTime:mi.floatTime,int:Po.int,intHex:Po.intHex,intOct:Po.intOct,intTime:mi.intTime,map:zu.map,merge:Un.merge,null:Ik.nullTag,omap:Lu.omap,pairs:Mu.pairs,seq:ju.seq,set:Uu.set,timestamp:mi.timestamp},Lk={"tag:yaml.org,2002:binary":Du.binary,"tag:yaml.org,2002:merge":Un.merge,"tag:yaml.org,2002:omap":Lu.omap,"tag:yaml.org,2002:pairs":Mu.pairs,"tag:yaml.org,2002:set":Uu.set,"tag:yaml.org,2002:timestamp":mi.timestamp};function Mk(e,t,n){let r=Iu.get(t);if(r&&!e)return n&&!r.includes(Un.merge)?r.concat(Un.merge):r.slice();let i=r;if(!i)if(Array.isArray(e))i=[];else{let s=Array.from(Iu.keys()).filter((o)=>o!=="yaml11").map((o)=>JSON.stringify(o)).join(", ");throw Error(`Unknown schema "${t}"; use one of ${s} or define customTags array`)}if(Array.isArray(e))for(let s of e)i=i.concat(s);else if(typeof e==="function")i=e(i.slice());if(n)i=i.concat(Un.merge);return i.reduce((s,o)=>{let a=typeof o==="string"?Nu[o]:o;if(!a){let c=JSON.stringify(o),l=Object.keys(Nu).map((u)=>JSON.stringify(u)).join(", ");throw Error(`Unknown custom tag ${c}; use one of ${l}`)}if(!s.includes(a))s.push(a);return s},[])}Uk.coreKnownTags=Lk;Uk.getTags=Mk});var Oo=P(function(Kk){var To=z(),qk=Qt(),Bk=Xt(),Hk=jn(),gi=Zu(),Fk=(e,t)=>e.key<t.key?-1:e.key>t.key?1:0;class Eo{constructor({compat:e,customTags:t,merge:n,resolveKnownTags:r,schema:i,sortMapEntries:s,toStringDefaults:o}){this.compat=Array.isArray(e)?gi.getTags(e,"compat"):e?gi.getTags(null,e):null,this.name=typeof i==="string"&&i||"core",this.knownTags=r?gi.coreKnownTags:{},this.tags=gi.getTags(t,this.name,n),this.toStringOptions=o??null,Object.defineProperty(this,To.MAP,{value:qk.map}),Object.defineProperty(this,To.SCALAR,{value:Hk.string}),Object.defineProperty(this,To.SEQ,{value:Bk.seq}),this.sortMapEntries=typeof s==="function"?s:s===!0?Fk:null}clone(){let e=Object.create(Eo.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}}Kk.Schema=Eo});var Gu=P(function(Jk){var Vk=z(),Co=In(),Zn=On();function Yk(e,t){let n=[],r=t.directives===!0;if(t.directives!==!1&&e.directives){let c=e.directives.toString(e);if(c)n.push(c),r=!0;else if(e.directives.docStart)r=!0}if(r)n.push("---");let i=Co.createStringifyContext(e,t),{commentString:s}=i.options;if(e.commentBefore){if(n.length!==1)n.unshift("");let c=s(e.commentBefore);n.unshift(Zn.indentComment(c,""))}let o=!1,a=null;if(e.contents){if(Vk.isNode(e.contents)){if(e.contents.spaceBefore&&r)n.push("");if(e.contents.commentBefore){let u=s(e.contents.commentBefore);n.push(Zn.indentComment(u,""))}i.forceBlockIndent=!!e.comment,a=e.contents.comment}let c=a?void 0:()=>o=!0,l=Co.stringify(e.contents,i,()=>a=null,c);if(a)l+=Zn.lineComment(l,"",s(a));if((l[0]==="|"||l[0]===">")&&n[n.length-1]==="---")n[n.length-1]=`--- ${l}`;else n.push(l)}else n.push(Co.stringify(e.contents,i));if(e.directives?.docEnd)if(e.comment){let c=s(e.comment);if(c.includes(`
56
+ ${s.comment}`:r.comment}r=i}e.items[n]=ci.isPair(r)?r:new go.Pair(r)}else t("Expected a sequence for this tag");return e}function vu(e,t,n){let{replacer:r}=n,i=new I_.YAMLSeq(e);i.tag="tag:yaml.org,2002:pairs";let s=0;if(t&&Symbol.iterator in Object(t))for(let o of t){if(typeof r==="function")o=r.call(t,String(s++),o);let a,c;if(Array.isArray(o))if(o.length===2)a=o[0],c=o[1];else throw TypeError(`Expected [key, value] tuple: ${o}`);else if(o&&o instanceof Object){let l=Object.keys(o);if(l.length===1)a=l[0],c=o[a];else throw TypeError(`Expected tuple with one key, not ${l.length} keys`)}else a=o;i.items.push(go.createPair(a,c,n))}return i}var N_={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:gu,createNode:vu};z_.createPairs=vu;z_.pairs=N_;z_.resolvePairs=gu});var yo=P(function(Z_){var yu=z(),vo=ct(),Dn=ht(),M_=ft(),bu=li();class Rt extends M_.YAMLSeq{constructor(){super();this.add=Dn.YAMLMap.prototype.add.bind(this),this.delete=Dn.YAMLMap.prototype.delete.bind(this),this.get=Dn.YAMLMap.prototype.get.bind(this),this.has=Dn.YAMLMap.prototype.has.bind(this),this.set=Dn.YAMLMap.prototype.set.bind(this),this.tag=Rt.tag}toJSON(e,t){if(!t)return super.toJSON(e);let n=new Map;if(t?.onCreate)t.onCreate(n);for(let r of this.items){let i,s;if(yu.isPair(r))i=vo.toJS(r.key,"",t),s=vo.toJS(r.value,i,t);else i=vo.toJS(r,"",t);if(n.has(i))throw Error("Ordered maps must not include duplicate keys");n.set(i,s)}return n}static from(e,t,n){let r=bu.createPairs(e,t,n),i=new this;return i.items=r.items,i}}Rt.tag="tag:yaml.org,2002:omap";var U_={collection:"seq",identify:(e)=>e instanceof Map,nodeClass:Rt,default:!1,tag:"tag:yaml.org,2002:omap",resolve(e,t){let n=bu.resolvePairs(e,t),r=[];for(let{key:i}of n.items)if(yu.isScalar(i))if(r.includes(i.value))t(`Ordered maps must not include duplicate keys: ${i.value}`);else r.push(i.value);return Object.assign(new Rt,n)},createNode:(e,t,n)=>Rt.from(e,t,n)};Z_.YAMLOMap=Rt;Z_.omap=U_});var Su=P(function(B_){var wu=W();function _u({value:e,source:t},n){if(t&&(e?ku:xu).test.test(t))return t;return e?n.options.trueStr:n.options.falseStr}var ku={identify:(e)=>e===!0,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new wu.Scalar(!0),stringify:_u},xu={identify:(e)=>e===!1,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new wu.Scalar(!1),stringify:_u};B_.falseTag=xu;B_.trueTag=ku});var Au=P(function(J_){var K_=W(),bo=en(),W_={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:(e)=>e.slice(-3).toLowerCase()==="nan"?NaN:e[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:bo.stringifyNumber},V_={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:(e)=>parseFloat(e.replace(/_/g,"")),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():bo.stringifyNumber(e)}},Y_={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(e){let t=new K_.Scalar(parseFloat(e.replace(/_/g,""))),n=e.indexOf(".");if(n!==-1){let r=e.substring(n+1).replace(/_/g,"");if(r[r.length-1]==="0")t.minFractionDigits=r.length}return t},stringify:bo.stringifyNumber};J_.float=Y_;J_.floatExp=V_;J_.floatNaN=W_});var Pu=P(function(sk){var $u=en(),Mn=(e)=>typeof e==="bigint"||Number.isInteger(e);function ui(e,t,n,{intAsBigInt:r}){let i=e[0];if(i==="-"||i==="+")t+=1;if(e=e.substring(t).replace(/_/g,""),r){switch(n){case 2:e=`0b${e}`;break;case 8:e=`0o${e}`;break;case 16:e=`0x${e}`;break}let o=BigInt(e);return i==="-"?BigInt(-1)*o:o}let s=parseInt(e,n);return i==="-"?-1*s:s}function wo(e,t,n){let{value:r}=e;if(Mn(r)){let i=r.toString(t);return r<0?"-"+n+i.substr(1):n+i}return $u.stringifyNumber(e)}var tk={identify:Mn,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(e,t,n)=>ui(e,2,2,n),stringify:(e)=>wo(e,2,"0b")},nk={identify:Mn,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(e,t,n)=>ui(e,1,8,n),stringify:(e)=>wo(e,8,"0")},rk={identify:Mn,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(e,t,n)=>ui(e,0,10,n),stringify:$u.stringifyNumber},ik={identify:Mn,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(e,t,n)=>ui(e,2,16,n),stringify:(e)=>wo(e,16,"0x")};sk.int=rk;sk.intBin=tk;sk.intHex=ik;sk.intOct=nk});var _o=P(function(pk){var hi=z(),pi=pt(),di=ht();class It extends di.YAMLMap{constructor(e){super(e);this.tag=It.tag}add(e){let t;if(hi.isPair(e))t=e;else if(e&&typeof e==="object"&&"key"in e&&"value"in e&&e.value===null)t=new pi.Pair(e.key,null);else t=new pi.Pair(e,null);if(!di.findPair(this.items,t.key))this.items.push(t)}get(e,t){let n=di.findPair(this.items,e);return!t&&hi.isPair(n)?hi.isScalar(n.key)?n.key.value:n.key:n}set(e,t){if(typeof t!=="boolean")throw Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof t}`);let n=di.findPair(this.items,e);if(n&&!t)this.items.splice(this.items.indexOf(n),1);else if(!n&&t)this.items.push(new pi.Pair(e))}toJSON(e,t){return super.toJSON(e,t,Set)}toString(e,t,n){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),t,n);else throw Error("Set items must all have null values")}static from(e,t,n){let{replacer:r}=n,i=new this(e);if(t&&Symbol.iterator in Object(t))for(let s of t){if(typeof r==="function")s=r.call(t,s,s);i.items.push(pi.createPair(s,null,n))}return i}}It.tag="tag:yaml.org,2002:set";var uk={collection:"map",identify:(e)=>e instanceof Set,nodeClass:It,default:!1,tag:"tag:yaml.org,2002:set",createNode:(e,t,n)=>It.from(e,t,n),resolve(e,t){if(hi.isMap(e))if(e.hasAllNullValues(!0))return Object.assign(new It,e);else t("Set items must all have null values");else t("Expected a mapping for this tag");return e}};pk.YAMLSet=It;pk.set=uk});var xo=P(function(vk){var fk=en();function ko(e,t){let n=e[0],r=n==="-"||n==="+"?e.substring(1):e,i=(o)=>t?BigInt(o):Number(o),s=r.replace(/_/g,"").split(":").reduce((o,a)=>o*i(60)+i(a),i(0));return n==="-"?i(-1)*s:s}function Tu(e){let{value:t}=e,n=(o)=>o;if(typeof t==="bigint")n=(o)=>BigInt(o);else if(isNaN(t)||!isFinite(t))return fk.stringifyNumber(e);let r="";if(t<0)r="-",t*=n(-1);let i=n(60),s=[t%i];if(t<60)s.unshift(0);else if(t=(t-s[0])/i,s.unshift(t%i),t>=60)t=(t-s[0])/i,s.unshift(t);return r+s.map((o)=>String(o).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}var mk={identify:(e)=>typeof e==="bigint"||Number.isInteger(e),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(e,t,{intAsBigInt:n})=>ko(e,n),stringify:Tu},gk={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:(e)=>ko(e,!1),stringify:Tu},Eu={identify:(e)=>e instanceof Date,default:!0,tag:"tag:yaml.org,2002:timestamp",test:RegExp("^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$"),resolve(e){let t=e.match(Eu.test);if(!t)throw Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,n,r,i,s,o,a]=t.map(Number),c=t[7]?Number((t[7]+"00").substr(1,3)):0,l=Date.UTC(n,r-1,i,s||0,o||0,a||0,c),u=t[8];if(u&&u!=="Z"){let p=ko(u,!1);if(Math.abs(p)<30)p*=60;l-=60000*p}return new Date(l)},stringify:({value:e})=>e?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};vk.floatTime=gk;vk.intTime=mk;vk.timestamp=Eu});var Cu=P(function(Ck){var _k=Qt(),kk=si(),xk=Xt(),Sk=Ln(),Ak=mo(),Ou=Su(),So=Au(),fi=Pu(),$k=Jr(),Pk=yo(),Tk=li(),Ek=_o(),Ao=xo(),Ok=[_k.map,xk.seq,Sk.string,kk.nullTag,Ou.trueTag,Ou.falseTag,fi.intBin,fi.intOct,fi.int,fi.intHex,So.floatNaN,So.floatExp,So.float,Ak.binary,$k.merge,Pk.omap,Tk.pairs,Ek.set,Ao.intTime,Ao.floatTime,Ao.timestamp];Ck.schema=Ok});var Zu=P(function(Uk){var zu=Qt(),Ik=si(),Lu=Xt(),Nk=Ln(),zk=oo(),$o=co(),Po=uo(),Lk=hu(),jk=mu(),ju=mo(),Un=Jr(),Du=yo(),Mu=li(),Ru=Cu(),Uu=_o(),mi=xo(),Iu=new Map([["core",Lk.schema],["failsafe",[zu.map,Lu.seq,Nk.string]],["json",jk.schema],["yaml11",Ru.schema],["yaml-1.1",Ru.schema]]),Nu={binary:ju.binary,bool:zk.boolTag,float:$o.float,floatExp:$o.floatExp,floatNaN:$o.floatNaN,floatTime:mi.floatTime,int:Po.int,intHex:Po.intHex,intOct:Po.intOct,intTime:mi.intTime,map:zu.map,merge:Un.merge,null:Ik.nullTag,omap:Du.omap,pairs:Mu.pairs,seq:Lu.seq,set:Uu.set,timestamp:mi.timestamp},Dk={"tag:yaml.org,2002:binary":ju.binary,"tag:yaml.org,2002:merge":Un.merge,"tag:yaml.org,2002:omap":Du.omap,"tag:yaml.org,2002:pairs":Mu.pairs,"tag:yaml.org,2002:set":Uu.set,"tag:yaml.org,2002:timestamp":mi.timestamp};function Mk(e,t,n){let r=Iu.get(t);if(r&&!e)return n&&!r.includes(Un.merge)?r.concat(Un.merge):r.slice();let i=r;if(!i)if(Array.isArray(e))i=[];else{let s=Array.from(Iu.keys()).filter((o)=>o!=="yaml11").map((o)=>JSON.stringify(o)).join(", ");throw Error(`Unknown schema "${t}"; use one of ${s} or define customTags array`)}if(Array.isArray(e))for(let s of e)i=i.concat(s);else if(typeof e==="function")i=e(i.slice());if(n)i=i.concat(Un.merge);return i.reduce((s,o)=>{let a=typeof o==="string"?Nu[o]:o;if(!a){let c=JSON.stringify(o),l=Object.keys(Nu).map((u)=>JSON.stringify(u)).join(", ");throw Error(`Unknown custom tag ${c}; use one of ${l}`)}if(!s.includes(a))s.push(a);return s},[])}Uk.coreKnownTags=Dk;Uk.getTags=Mk});var Oo=P(function(Kk){var To=z(),qk=Qt(),Bk=Xt(),Hk=Ln(),gi=Zu(),Fk=(e,t)=>e.key<t.key?-1:e.key>t.key?1:0;class Eo{constructor({compat:e,customTags:t,merge:n,resolveKnownTags:r,schema:i,sortMapEntries:s,toStringDefaults:o}){this.compat=Array.isArray(e)?gi.getTags(e,"compat"):e?gi.getTags(null,e):null,this.name=typeof i==="string"&&i||"core",this.knownTags=r?gi.coreKnownTags:{},this.tags=gi.getTags(t,this.name,n),this.toStringOptions=o??null,Object.defineProperty(this,To.MAP,{value:qk.map}),Object.defineProperty(this,To.SCALAR,{value:Hk.string}),Object.defineProperty(this,To.SEQ,{value:Bk.seq}),this.sortMapEntries=typeof s==="function"?s:s===!0?Fk:null}clone(){let e=Object.create(Eo.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}}Kk.Schema=Eo});var Gu=P(function(Jk){var Vk=z(),Co=In(),Zn=On();function Yk(e,t){let n=[],r=t.directives===!0;if(t.directives!==!1&&e.directives){let c=e.directives.toString(e);if(c)n.push(c),r=!0;else if(e.directives.docStart)r=!0}if(r)n.push("---");let i=Co.createStringifyContext(e,t),{commentString:s}=i.options;if(e.commentBefore){if(n.length!==1)n.unshift("");let c=s(e.commentBefore);n.unshift(Zn.indentComment(c,""))}let o=!1,a=null;if(e.contents){if(Vk.isNode(e.contents)){if(e.contents.spaceBefore&&r)n.push("");if(e.contents.commentBefore){let u=s(e.contents.commentBefore);n.push(Zn.indentComment(u,""))}i.forceBlockIndent=!!e.comment,a=e.contents.comment}let c=a?void 0:()=>o=!0,l=Co.stringify(e.contents,i,()=>a=null,c);if(a)l+=Zn.lineComment(l,"",s(a));if((l[0]==="|"||l[0]===">")&&n[n.length-1]==="---")n[n.length-1]=`--- ${l}`;else n.push(l)}else n.push(Co.stringify(e.contents,i));if(e.directives?.docEnd)if(e.comment){let c=s(e.comment);if(c.includes(`
57
57
  `))n.push("..."),n.push(Zn.indentComment(c,""));else n.push(`... ${c}`)}else n.push("...");else{let c=e.comment;if(c&&o)c=c.replace(/^\n+/,"");if(c){if((!o||a)&&n[n.length-1]!=="")n.push("");n.push(Zn.indentComment(s(c),""))}}return n.join(`
58
58
  `)+`
59
59
  `}Jk.stringifyDocument=Yk});var Gn=P(function(ox){var Xk=Tn(),tn=Br(),Se=z(),ex=pt(),tx=ct(),nx=Oo(),rx=Gu(),Ro=Zr(),ix=Ys(),sx=En(),Io=Vs();class No{constructor(e,t,n){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,Se.NODE_TYPE,{value:Se.DOC});let r=null;if(typeof t==="function"||Array.isArray(t))r=t;else if(n===void 0&&t)n=t,t=void 0;let i=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:"warn",prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:"1.2"},n);this.options=i;let{version:s}=i;if(n?._directives){if(this.directives=n._directives.atDocument(),this.directives.yaml.explicit)s=this.directives.yaml.version}else this.directives=new Io.Directives({version:s});this.setSchema(s,n),this.contents=e===void 0?null:this.createNode(e,r,n)}clone(){let e=Object.create(No.prototype,{[Se.NODE_TYPE]:{value:Se.DOC}});if(e.commentBefore=this.commentBefore,e.comment=this.comment,e.errors=this.errors.slice(),e.warnings=this.warnings.slice(),e.options=Object.assign({},this.options),this.directives)e.directives=this.directives.clone();if(e.schema=this.schema.clone(),e.contents=Se.isNode(this.contents)?this.contents.clone(e.schema):this.contents,this.range)e.range=this.range.slice();return e}add(e){if(nn(this.contents))this.contents.add(e)}addIn(e,t){if(nn(this.contents))this.contents.addIn(e,t)}createAlias(e,t){if(!e.anchor){let n=Ro.anchorNames(this);e.anchor=!t||n.has(t)?Ro.findNewAnchor(t||"a",n):t}return new Xk.Alias(e.anchor)}createNode(e,t,n){let r=void 0;if(typeof t==="function")e=t.call({"":e},"",e),r=t;else if(Array.isArray(t)){let m=(w)=>typeof w==="number"||w instanceof String||w instanceof Number,g=t.filter(m).map(String);if(g.length>0)t=t.concat(g);r=t}else if(n===void 0&&t)n=t,t=void 0;let{aliasDuplicateObjects:i,anchorPrefix:s,flow:o,keepUndefined:a,onTagObj:c,tag:l}=n??{},{onAnchor:u,setAnchors:p,sourceObjects:d}=Ro.createNodeAnchors(this,s||"a"),h={aliasDuplicateObjects:i??!0,keepUndefined:a??!1,onAnchor:u,onTagObj:c,replacer:r,schema:this.schema,sourceObjects:d},f=sx.createNode(e,l,h);if(o&&Se.isCollection(f))f.flow=!0;return p(),f}createPair(e,t,n={}){let r=this.createNode(e,null,n),i=this.createNode(t,null,n);return new ex.Pair(r,i)}delete(e){return nn(this.contents)?this.contents.delete(e):!1}deleteIn(e){if(tn.isEmptyPath(e)){if(this.contents==null)return!1;return this.contents=null,!0}return nn(this.contents)?this.contents.deleteIn(e):!1}get(e,t){return Se.isCollection(this.contents)?this.contents.get(e,t):void 0}getIn(e,t){if(tn.isEmptyPath(e))return!t&&Se.isScalar(this.contents)?this.contents.value:this.contents;return Se.isCollection(this.contents)?this.contents.getIn(e,t):void 0}has(e){return Se.isCollection(this.contents)?this.contents.has(e):!1}hasIn(e){if(tn.isEmptyPath(e))return this.contents!==void 0;return Se.isCollection(this.contents)?this.contents.hasIn(e):!1}set(e,t){if(this.contents==null)this.contents=tn.collectionFromPath(this.schema,[e],t);else if(nn(this.contents))this.contents.set(e,t)}setIn(e,t){if(tn.isEmptyPath(e))this.contents=t;else if(this.contents==null)this.contents=tn.collectionFromPath(this.schema,Array.from(e),t);else if(nn(this.contents))this.contents.setIn(e,t)}setSchema(e,t={}){if(typeof e==="number")e=String(e);let n;switch(e){case"1.1":if(this.directives)this.directives.yaml.version="1.1";else this.directives=new Io.Directives({version:"1.1"});n={resolveKnownTags:!1,schema:"yaml-1.1"};break;case"1.2":case"next":if(this.directives)this.directives.yaml.version=e;else this.directives=new Io.Directives({version:e});n={resolveKnownTags:!0,schema:"core"};break;case null:if(this.directives)delete this.directives;n=null;break;default:{let r=JSON.stringify(e);throw Error(`Expected '1.1', '1.2' or null as first argument, but found: ${r}`)}}if(t.schema instanceof Object)this.schema=t.schema;else if(n)this.schema=new nx.Schema(Object.assign(n,t));else throw Error("With a null YAML version, the { schema: Schema } option is required")}toJS({json:e,jsonArg:t,mapAsMap:n,maxAliasCount:r,onAnchor:i,reviver:s}={}){let o={anchors:new Map,doc:this,keep:!e,mapAsMap:n===!0,mapKeyWarned:!1,maxAliasCount:typeof r==="number"?r:100},a=tx.toJS(this.contents,t??"",o);if(typeof i==="function")for(let{count:c,res:l}of o.anchors.values())i(l,c);return typeof s==="function"?ix.applyReviver(s,{"":a},"",a):a}toJSON(e,t){return this.toJS({json:!0,jsonArg:e,mapAsMap:!1,onAnchor:t})}toString(e={}){if(this.errors.length>0)throw Error("Document with errors cannot be stringified");if("indent"in e&&(!Number.isInteger(e.indent)||Number(e.indent)<=0)){let t=JSON.stringify(e.indent);throw Error(`"indent" option must be a positive integer, not ${t}`)}return rx.stringifyDocument(this,e)}}function nn(e){if(Se.isCollection(e))return!0;throw Error("Expected a YAML collection as document contents")}ox.Document=No});var qn=P(function(lx){class vi extends Error{constructor(e,t,n,r){super();this.name=e,this.code=n,this.message=r,this.pos=t}}class qu extends vi{constructor(e,t,n){super("YAMLParseError",e,t,n)}}class Bu extends vi{constructor(e,t,n){super("YAMLWarning",e,t,n)}}var cx=(e,t)=>(n)=>{if(n.pos[0]===-1)return;n.linePos=n.pos.map((a)=>t.linePos(a));let{line:r,col:i}=n.linePos[0];n.message+=` at line ${r}, column ${i}`;let s=i-1,o=e.substring(t.lineStarts[r-1],t.lineStarts[r]).replace(/[\n\r]+$/,"");if(s>=60&&o.length>80){let a=Math.min(s-39,o.length-79);o="\u2026"+o.substring(a),s-=a-1}if(o.length>80)o=o.substring(0,79)+"\u2026";if(r>1&&/^ *$/.test(o.substring(0,s))){let a=e.substring(t.lineStarts[r-2],t.lineStarts[r-1]);if(a.length>80)a=a.substring(0,79)+`\u2026
@@ -61,13 +61,13 @@ ${s.comment}`:r.comment}r=i}e.items[n]=ci.isPair(r)?r:new go.Pair(r)}else t("Exp
61
61
 
62
62
  ${o}
63
63
  ${l}
64
- `}};lx.YAMLError=vi;lx.YAMLParseError=qu;lx.YAMLWarning=Bu;lx.prettifyError=cx});var Bn=P(function(mx){function fx(e,{flow:t,indicator:n,next:r,offset:i,onError:s,parentIndent:o,startOnNewline:a}){let c=!1,l=a,u=a,p="",d="",h=!1,f=!1,m=null,g=null,w=null,k=null,_=null,y=null,x=null;for(let A of e){if(f){if(A.type!=="space"&&A.type!=="newline"&&A.type!=="comma")s(A.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space");f=!1}if(m){if(l&&A.type!=="comment"&&A.type!=="newline")s(m,"TAB_AS_INDENT","Tabs are not allowed as indentation");m=null}switch(A.type){case"space":if(!t&&(n!=="doc-start"||r?.type!=="flow-collection")&&A.source.includes("\t"))m=A;u=!0;break;case"comment":{if(!u)s(A,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let D=A.source.substring(1)||" ";if(!p)p=D;else p+=d+D;d="",l=!1;break}case"newline":if(l){if(p)p+=A.source;else if(!y||n!=="seq-item-ind")c=!0}else d+=A.source;if(l=!0,h=!0,g||w)k=A;u=!0;break;case"anchor":if(g)s(A,"MULTIPLE_ANCHORS","A node can have at most one anchor");if(A.source.endsWith(":"))s(A.offset+A.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0);g=A,x??(x=A.offset),l=!1,u=!1,f=!0;break;case"tag":{if(w)s(A,"MULTIPLE_TAGS","A node can have at most one tag");w=A,x??(x=A.offset),l=!1,u=!1,f=!0;break}case n:if(g||w)s(A,"BAD_PROP_ORDER",`Anchors and tags must be after the ${A.source} indicator`);if(y)s(A,"UNEXPECTED_TOKEN",`Unexpected ${A.source} in ${t??"collection"}`);y=A,l=n==="seq-item-ind"||n==="explicit-key-ind",u=!1;break;case"comma":if(t){if(_)s(A,"UNEXPECTED_TOKEN",`Unexpected , in ${t}`);_=A,l=!1,u=!1;break}default:s(A,"UNEXPECTED_TOKEN",`Unexpected ${A.type} token`),l=!1,u=!1}}let S=e[e.length-1],O=S?S.offset+S.source.length:i;if(f&&r&&r.type!=="space"&&r.type!=="newline"&&r.type!=="comma"&&(r.type!=="scalar"||r.source!==""))s(r.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space");if(m&&(l&&m.indent<=o||r?.type==="block-map"||r?.type==="block-seq"))s(m,"TAB_AS_INDENT","Tabs are not allowed as indentation");return{comma:_,found:y,spaceBefore:c,comment:p,hasNewline:h,anchor:g,tag:w,newlineAfterProp:k,end:O,start:x??O}}mx.resolveProps=fx});var yi=P(function(vx){function zo(e){if(!e)return null;switch(e.type){case"alias":case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":if(e.source.includes(`
65
- `))return!0;if(e.end){for(let t of e.end)if(t.type==="newline")return!0}return!1;case"flow-collection":for(let t of e.items){for(let n of t.start)if(n.type==="newline")return!0;if(t.sep){for(let n of t.sep)if(n.type==="newline")return!0}if(zo(t.key)||zo(t.value))return!0}return!1;default:return!0}}vx.containsNewline=zo});var jo=P(function(_x){var bx=yi();function wx(e,t,n){if(t?.type==="flow-collection"){let r=t.end[0];if(r.indent===e&&(r.source==="]"||r.source==="}")&&bx.containsNewline(t))n(r,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}_x.flowIndentCheck=wx});var Do=P(function(Sx){var Hu=z();function xx(e,t,n){let{uniqueKeys:r}=e.options;if(r===!1)return!1;let i=typeof r==="function"?r:(s,o)=>s===o||Hu.isScalar(s)&&Hu.isScalar(o)&&s.value===o.value;return t.some((s)=>i(s.key,n))}Sx.mapIncludes=xx});var Yu=P(function(Ox){var Fu=pt(),$x=ht(),Ku=Bn(),Px=yi(),Wu=jo(),Tx=Do(),Vu="All mapping items must start at the same column";function Ex({composeNode:e,composeEmptyNode:t},n,r,i,s){let a=new(s?.nodeClass??$x.YAMLMap)(n.schema);if(n.atRoot)n.atRoot=!1;let c=r.offset,l=null;for(let u of r.items){let{start:p,key:d,sep:h,value:f}=u,m=Ku.resolveProps(p,{indicator:"explicit-key-ind",next:d??h?.[0],offset:c,onError:i,parentIndent:r.indent,startOnNewline:!0}),g=!m.found;if(g){if(d){if(d.type==="block-seq")i(c,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key");else if("indent"in d&&d.indent!==r.indent)i(c,"BAD_INDENT",Vu)}if(!m.anchor&&!m.tag&&!h){if(l=m.end,m.comment)if(a.comment)a.comment+=`
64
+ `}};lx.YAMLError=vi;lx.YAMLParseError=qu;lx.YAMLWarning=Bu;lx.prettifyError=cx});var Bn=P(function(mx){function fx(e,{flow:t,indicator:n,next:r,offset:i,onError:s,parentIndent:o,startOnNewline:a}){let c=!1,l=a,u=a,p="",d="",h=!1,f=!1,m=null,g=null,w=null,k=null,_=null,y=null,x=null;for(let A of e){if(f){if(A.type!=="space"&&A.type!=="newline"&&A.type!=="comma")s(A.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space");f=!1}if(m){if(l&&A.type!=="comment"&&A.type!=="newline")s(m,"TAB_AS_INDENT","Tabs are not allowed as indentation");m=null}switch(A.type){case"space":if(!t&&(n!=="doc-start"||r?.type!=="flow-collection")&&A.source.includes("\t"))m=A;u=!0;break;case"comment":{if(!u)s(A,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let j=A.source.substring(1)||" ";if(!p)p=j;else p+=d+j;d="",l=!1;break}case"newline":if(l){if(p)p+=A.source;else if(!y||n!=="seq-item-ind")c=!0}else d+=A.source;if(l=!0,h=!0,g||w)k=A;u=!0;break;case"anchor":if(g)s(A,"MULTIPLE_ANCHORS","A node can have at most one anchor");if(A.source.endsWith(":"))s(A.offset+A.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0);g=A,x??(x=A.offset),l=!1,u=!1,f=!0;break;case"tag":{if(w)s(A,"MULTIPLE_TAGS","A node can have at most one tag");w=A,x??(x=A.offset),l=!1,u=!1,f=!0;break}case n:if(g||w)s(A,"BAD_PROP_ORDER",`Anchors and tags must be after the ${A.source} indicator`);if(y)s(A,"UNEXPECTED_TOKEN",`Unexpected ${A.source} in ${t??"collection"}`);y=A,l=n==="seq-item-ind"||n==="explicit-key-ind",u=!1;break;case"comma":if(t){if(_)s(A,"UNEXPECTED_TOKEN",`Unexpected , in ${t}`);_=A,l=!1,u=!1;break}default:s(A,"UNEXPECTED_TOKEN",`Unexpected ${A.type} token`),l=!1,u=!1}}let S=e[e.length-1],O=S?S.offset+S.source.length:i;if(f&&r&&r.type!=="space"&&r.type!=="newline"&&r.type!=="comma"&&(r.type!=="scalar"||r.source!==""))s(r.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space");if(m&&(l&&m.indent<=o||r?.type==="block-map"||r?.type==="block-seq"))s(m,"TAB_AS_INDENT","Tabs are not allowed as indentation");return{comma:_,found:y,spaceBefore:c,comment:p,hasNewline:h,anchor:g,tag:w,newlineAfterProp:k,end:O,start:x??O}}mx.resolveProps=fx});var yi=P(function(vx){function zo(e){if(!e)return null;switch(e.type){case"alias":case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":if(e.source.includes(`
65
+ `))return!0;if(e.end){for(let t of e.end)if(t.type==="newline")return!0}return!1;case"flow-collection":for(let t of e.items){for(let n of t.start)if(n.type==="newline")return!0;if(t.sep){for(let n of t.sep)if(n.type==="newline")return!0}if(zo(t.key)||zo(t.value))return!0}return!1;default:return!0}}vx.containsNewline=zo});var Lo=P(function(_x){var bx=yi();function wx(e,t,n){if(t?.type==="flow-collection"){let r=t.end[0];if(r.indent===e&&(r.source==="]"||r.source==="}")&&bx.containsNewline(t))n(r,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}_x.flowIndentCheck=wx});var jo=P(function(Sx){var Hu=z();function xx(e,t,n){let{uniqueKeys:r}=e.options;if(r===!1)return!1;let i=typeof r==="function"?r:(s,o)=>s===o||Hu.isScalar(s)&&Hu.isScalar(o)&&s.value===o.value;return t.some((s)=>i(s.key,n))}Sx.mapIncludes=xx});var Yu=P(function(Ox){var Fu=pt(),$x=ht(),Ku=Bn(),Px=yi(),Wu=Lo(),Tx=jo(),Vu="All mapping items must start at the same column";function Ex({composeNode:e,composeEmptyNode:t},n,r,i,s){let a=new(s?.nodeClass??$x.YAMLMap)(n.schema);if(n.atRoot)n.atRoot=!1;let c=r.offset,l=null;for(let u of r.items){let{start:p,key:d,sep:h,value:f}=u,m=Ku.resolveProps(p,{indicator:"explicit-key-ind",next:d??h?.[0],offset:c,onError:i,parentIndent:r.indent,startOnNewline:!0}),g=!m.found;if(g){if(d){if(d.type==="block-seq")i(c,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key");else if("indent"in d&&d.indent!==r.indent)i(c,"BAD_INDENT",Vu)}if(!m.anchor&&!m.tag&&!h){if(l=m.end,m.comment)if(a.comment)a.comment+=`
66
66
  `+m.comment;else a.comment=m.comment;continue}if(m.newlineAfterProp||Px.containsNewline(d))i(d??p[p.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else if(m.found?.indent!==r.indent)i(c,"BAD_INDENT",Vu);n.atKey=!0;let w=m.end,k=d?e(n,d,m,i):t(n,w,p,null,m,i);if(n.schema.compat)Wu.flowIndentCheck(r.indent,d,i);if(n.atKey=!1,Tx.mapIncludes(n,a.items,k))i(w,"DUPLICATE_KEY","Map keys must be unique");let _=Ku.resolveProps(h??[],{indicator:"map-value-ind",next:f,offset:k.range[2],onError:i,parentIndent:r.indent,startOnNewline:!d||d.type==="block-scalar"});if(c=_.end,_.found){if(g){if(f?.type==="block-map"&&!_.hasNewline)i(c,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings");if(n.options.strict&&m.start<_.found.offset-1024)i(k.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key")}let y=f?e(n,f,_,i):t(n,c,h,null,_,i);if(n.schema.compat)Wu.flowIndentCheck(r.indent,f,i);c=y.range[2];let x=new Fu.Pair(k,y);if(n.options.keepSourceTokens)x.srcToken=u;a.items.push(x)}else{if(g)i(k.range,"MISSING_CHAR","Implicit map keys need to be followed by map values");if(_.comment)if(k.comment)k.comment+=`
67
- `+_.comment;else k.comment=_.comment;let y=new Fu.Pair(k);if(n.options.keepSourceTokens)y.srcToken=u;a.items.push(y)}}if(l&&l<c)i(l,"IMPOSSIBLE","Map comment with trailing content");return a.range=[r.offset,c,l??c],a}Ox.resolveBlockMap=Ex});var Ju=P(function(jx){var Rx=ft(),Ix=Bn(),Nx=jo();function zx({composeNode:e,composeEmptyNode:t},n,r,i,s){let a=new(s?.nodeClass??Rx.YAMLSeq)(n.schema);if(n.atRoot)n.atRoot=!1;if(n.atKey)n.atKey=!1;let c=r.offset,l=null;for(let{start:u,value:p}of r.items){let d=Ix.resolveProps(u,{indicator:"seq-item-ind",next:p,offset:c,onError:i,parentIndent:r.indent,startOnNewline:!0});if(!d.found)if(d.anchor||d.tag||p)if(p?.type==="block-seq")i(d.end,"BAD_INDENT","All sequence items must start at the same column");else i(c,"MISSING_CHAR","Sequence item without - indicator");else{if(l=d.end,d.comment)a.comment=d.comment;continue}let h=p?e(n,p,d,i):t(n,d.end,u,null,d,i);if(n.schema.compat)Nx.flowIndentCheck(r.indent,p,i);c=h.range[2],a.items.push(h)}return a.range=[r.offset,c,l??c],a}jx.resolveBlockSeq=zx});var rn=P(function(Mx){function Lx(e,t,n,r){let i="";if(e){let s=!1,o="";for(let a of e){let{source:c,type:l}=a;switch(l){case"space":s=!0;break;case"comment":{if(n&&!s)r(a,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let u=c.substring(1)||" ";if(!i)i=u;else i+=o+u;o="";break}case"newline":if(i)o+=c;s=!0;break;default:r(a,"UNEXPECTED_TOKEN",`Unexpected ${l} at node end`)}t+=c.length}}return{comment:i,offset:t}}Mx.resolveEnd=Lx});var ep=P(function(Wx){var Zx=z(),Gx=pt(),Qu=ht(),qx=ft(),Bx=rn(),Xu=Bn(),Hx=yi(),Fx=Do(),Lo="Block collections are not allowed within flow collections",Mo=(e)=>e&&(e.type==="block-map"||e.type==="block-seq");function Kx({composeNode:e,composeEmptyNode:t},n,r,i,s){let o=r.start.source==="{",a=o?"flow map":"flow sequence",l=new(s?.nodeClass??(o?Qu.YAMLMap:qx.YAMLSeq))(n.schema);l.flow=!0;let u=n.atRoot;if(u)n.atRoot=!1;if(n.atKey)n.atKey=!1;let p=r.offset+r.start.source.length;for(let g=0;g<r.items.length;++g){let w=r.items[g],{start:k,key:_,sep:y,value:x}=w,S=Xu.resolveProps(k,{flow:a,indicator:"explicit-key-ind",next:_??y?.[0],offset:p,onError:i,parentIndent:r.indent,startOnNewline:!1});if(!S.found){if(!S.anchor&&!S.tag&&!y&&!x){if(g===0&&S.comma)i(S.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`);else if(g<r.items.length-1)i(S.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${a}`);if(S.comment)if(l.comment)l.comment+=`
67
+ `+_.comment;else k.comment=_.comment;let y=new Fu.Pair(k);if(n.options.keepSourceTokens)y.srcToken=u;a.items.push(y)}}if(l&&l<c)i(l,"IMPOSSIBLE","Map comment with trailing content");return a.range=[r.offset,c,l??c],a}Ox.resolveBlockMap=Ex});var Ju=P(function(Lx){var Rx=ft(),Ix=Bn(),Nx=Lo();function zx({composeNode:e,composeEmptyNode:t},n,r,i,s){let a=new(s?.nodeClass??Rx.YAMLSeq)(n.schema);if(n.atRoot)n.atRoot=!1;if(n.atKey)n.atKey=!1;let c=r.offset,l=null;for(let{start:u,value:p}of r.items){let d=Ix.resolveProps(u,{indicator:"seq-item-ind",next:p,offset:c,onError:i,parentIndent:r.indent,startOnNewline:!0});if(!d.found)if(d.anchor||d.tag||p)if(p?.type==="block-seq")i(d.end,"BAD_INDENT","All sequence items must start at the same column");else i(c,"MISSING_CHAR","Sequence item without - indicator");else{if(l=d.end,d.comment)a.comment=d.comment;continue}let h=p?e(n,p,d,i):t(n,d.end,u,null,d,i);if(n.schema.compat)Nx.flowIndentCheck(r.indent,p,i);c=h.range[2],a.items.push(h)}return a.range=[r.offset,c,l??c],a}Lx.resolveBlockSeq=zx});var rn=P(function(Mx){function Dx(e,t,n,r){let i="";if(e){let s=!1,o="";for(let a of e){let{source:c,type:l}=a;switch(l){case"space":s=!0;break;case"comment":{if(n&&!s)r(a,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let u=c.substring(1)||" ";if(!i)i=u;else i+=o+u;o="";break}case"newline":if(i)o+=c;s=!0;break;default:r(a,"UNEXPECTED_TOKEN",`Unexpected ${l} at node end`)}t+=c.length}}return{comment:i,offset:t}}Mx.resolveEnd=Dx});var ep=P(function(Wx){var Zx=z(),Gx=pt(),Qu=ht(),qx=ft(),Bx=rn(),Xu=Bn(),Hx=yi(),Fx=jo(),Do="Block collections are not allowed within flow collections",Mo=(e)=>e&&(e.type==="block-map"||e.type==="block-seq");function Kx({composeNode:e,composeEmptyNode:t},n,r,i,s){let o=r.start.source==="{",a=o?"flow map":"flow sequence",l=new(s?.nodeClass??(o?Qu.YAMLMap:qx.YAMLSeq))(n.schema);l.flow=!0;let u=n.atRoot;if(u)n.atRoot=!1;if(n.atKey)n.atKey=!1;let p=r.offset+r.start.source.length;for(let g=0;g<r.items.length;++g){let w=r.items[g],{start:k,key:_,sep:y,value:x}=w,S=Xu.resolveProps(k,{flow:a,indicator:"explicit-key-ind",next:_??y?.[0],offset:p,onError:i,parentIndent:r.indent,startOnNewline:!1});if(!S.found){if(!S.anchor&&!S.tag&&!y&&!x){if(g===0&&S.comma)i(S.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`);else if(g<r.items.length-1)i(S.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${a}`);if(S.comment)if(l.comment)l.comment+=`
68
68
  `+S.comment;else l.comment=S.comment;p=S.end;continue}if(!o&&n.options.strict&&Hx.containsNewline(_))i(_,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(g===0){if(S.comma)i(S.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`)}else{if(!S.comma)i(S.start,"MISSING_CHAR",`Missing , between ${a} items`);if(S.comment){let O="";e:for(let A of k)switch(A.type){case"comma":case"space":break;case"comment":O=A.source.substring(1);break e;default:break e}if(O){let A=l.items[l.items.length-1];if(Zx.isPair(A))A=A.value??A.key;if(A.comment)A.comment+=`
69
- `+O;else A.comment=O;S.comment=S.comment.substring(O.length+1)}}}if(!o&&!y&&!S.found){let O=x?e(n,x,S,i):t(n,S.end,y,null,S,i);if(l.items.push(O),p=O.range[2],Mo(x))i(O.range,"BLOCK_IN_FLOW",Lo)}else{n.atKey=!0;let O=S.end,A=_?e(n,_,S,i):t(n,O,k,null,S,i);if(Mo(_))i(A.range,"BLOCK_IN_FLOW",Lo);n.atKey=!1;let D=Xu.resolveProps(y??[],{flow:a,indicator:"map-value-ind",next:x,offset:A.range[2],onError:i,parentIndent:r.indent,startOnNewline:!1});if(D.found){if(!o&&!S.found&&n.options.strict){if(y)for(let B of y){if(B===D.found)break;if(B.type==="newline"){i(B,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line");break}}if(S.start<D.found.offset-1024)i(D.found,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit flow sequence key")}}else if(x)if("source"in x&&x.source?.[0]===":")i(x,"MISSING_CHAR",`Missing space after : in ${a}`);else i(D.start,"MISSING_CHAR",`Missing , or : between ${a} items`);let ce=x?e(n,x,D,i):D.found?t(n,D.end,y,null,D,i):null;if(ce){if(Mo(x))i(ce.range,"BLOCK_IN_FLOW",Lo)}else if(D.comment)if(A.comment)A.comment+=`
70
- `+D.comment;else A.comment=D.comment;let ke=new Gx.Pair(A,ce);if(n.options.keepSourceTokens)ke.srcToken=w;if(o){let B=l;if(Fx.mapIncludes(n,B.items,A))i(O,"DUPLICATE_KEY","Map keys must be unique");B.items.push(ke)}else{let B=new Qu.YAMLMap(n.schema);B.flow=!0,B.items.push(ke);let Tt=(ce??A).range;B.range=[A.range[0],Tt[1],Tt[2]],l.items.push(B)}p=ce?ce.range[2]:D.end}}let d=o?"}":"]",[h,...f]=r.end,m=p;if(h?.source===d)m=h.offset+h.source.length;else{let g=a[0].toUpperCase()+a.substring(1),w=u?`${g} must end with a ${d}`:`${g} in block collection must be sufficiently indented and end with a ${d}`;if(i(p,u?"MISSING_CHAR":"BAD_INDENT",w),h&&h.source.length!==1)f.unshift(h)}if(f.length>0){let g=Bx.resolveEnd(f,m,n.options.strict,i);if(g.comment)if(l.comment)l.comment+=`
69
+ `+O;else A.comment=O;S.comment=S.comment.substring(O.length+1)}}}if(!o&&!y&&!S.found){let O=x?e(n,x,S,i):t(n,S.end,y,null,S,i);if(l.items.push(O),p=O.range[2],Mo(x))i(O.range,"BLOCK_IN_FLOW",Do)}else{n.atKey=!0;let O=S.end,A=_?e(n,_,S,i):t(n,O,k,null,S,i);if(Mo(_))i(A.range,"BLOCK_IN_FLOW",Do);n.atKey=!1;let j=Xu.resolveProps(y??[],{flow:a,indicator:"map-value-ind",next:x,offset:A.range[2],onError:i,parentIndent:r.indent,startOnNewline:!1});if(j.found){if(!o&&!S.found&&n.options.strict){if(y)for(let B of y){if(B===j.found)break;if(B.type==="newline"){i(B,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line");break}}if(S.start<j.found.offset-1024)i(j.found,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit flow sequence key")}}else if(x)if("source"in x&&x.source?.[0]===":")i(x,"MISSING_CHAR",`Missing space after : in ${a}`);else i(j.start,"MISSING_CHAR",`Missing , or : between ${a} items`);let ce=x?e(n,x,j,i):j.found?t(n,j.end,y,null,j,i):null;if(ce){if(Mo(x))i(ce.range,"BLOCK_IN_FLOW",Do)}else if(j.comment)if(A.comment)A.comment+=`
70
+ `+j.comment;else A.comment=j.comment;let ke=new Gx.Pair(A,ce);if(n.options.keepSourceTokens)ke.srcToken=w;if(o){let B=l;if(Fx.mapIncludes(n,B.items,A))i(O,"DUPLICATE_KEY","Map keys must be unique");B.items.push(ke)}else{let B=new Qu.YAMLMap(n.schema);B.flow=!0,B.items.push(ke);let Tt=(ce??A).range;B.range=[A.range[0],Tt[1],Tt[2]],l.items.push(B)}p=ce?ce.range[2]:j.end}}let d=o?"}":"]",[h,...f]=r.end,m=p;if(h?.source===d)m=h.offset+h.source.length;else{let g=a[0].toUpperCase()+a.substring(1),w=u?`${g} must end with a ${d}`:`${g} in block collection must be sufficiently indented and end with a ${d}`;if(i(p,u?"MISSING_CHAR":"BAD_INDENT",w),h&&h.source.length!==1)f.unshift(h)}if(f.length>0){let g=Bx.resolveEnd(f,m,n.options.strict,i);if(g.comment)if(l.comment)l.comment+=`
71
71
  `+g.comment;else l.comment=g.comment;l.range=[r.offset,m,g.offset]}else l.range=[r.offset,m,m];return l}Wx.resolveFlowCollection=Kx});var tp=P(function(iS){var Yx=z(),Jx=W(),Qx=ht(),Xx=ft(),eS=Yu(),tS=Ju(),nS=ep();function Uo(e,t,n,r,i,s){let o=n.type==="block-map"?eS.resolveBlockMap(e,t,n,r,s):n.type==="block-seq"?tS.resolveBlockSeq(e,t,n,r,s):nS.resolveFlowCollection(e,t,n,r,s),a=o.constructor;if(i==="!"||i===a.tagName)return o.tag=a.tagName,o;if(i)o.tag=i;return o}function rS(e,t,n,r,i){let s=r.tag,o=!s?null:t.directives.tagName(s.source,(d)=>i(s,"TAG_RESOLVE_FAILED",d));if(n.type==="block-seq"){let{anchor:d,newlineAfterProp:h}=r,f=d&&s?d.offset>s.offset?d:s:d??s;if(f&&(!h||h.offset<f.offset))i(f,"MISSING_CHAR","Missing newline after block sequence props")}let a=n.type==="block-map"?"map":n.type==="block-seq"?"seq":n.start.source==="{"?"map":"seq";if(!s||!o||o==="!"||o===Qx.YAMLMap.tagName&&a==="map"||o===Xx.YAMLSeq.tagName&&a==="seq")return Uo(e,t,n,i,o);let c=t.schema.tags.find((d)=>d.tag===o&&d.collection===a);if(!c){let d=t.schema.knownTags[o];if(d?.collection===a)t.schema.tags.push(Object.assign({},d,{default:!1})),c=d;else{if(d)i(s,"BAD_COLLECTION_TYPE",`${d.tag} used for ${a} collection, but expects ${d.collection??"scalar"}`,!0);else i(s,"TAG_RESOLVE_FAILED",`Unresolved tag: ${o}`,!0);return Uo(e,t,n,i,o)}}let l=Uo(e,t,n,i,o,c),u=c.resolve?.(l,(d)=>i(s,"TAG_RESOLVE_FAILED",d),t.options)??l,p=Yx.isNode(u)?u:new Jx.Scalar(u);if(p.range=l.range,p.tag=o,c?.format)p.format=c.format;return p}iS.composeCollection=rS});var Go=P(function(lS){var Zo=W();function oS(e,t,n){let r=t.offset,i=aS(t,e.options.strict,n);if(!i)return{value:"",type:null,comment:"",range:[r,r,r]};let s=i.mode===">"?Zo.Scalar.BLOCK_FOLDED:Zo.Scalar.BLOCK_LITERAL,o=t.source?cS(t.source):[],a=o.length;for(let m=o.length-1;m>=0;--m){let g=o[m][1];if(g===""||g==="\r")a=m;else break}if(a===0){let m=i.chomp==="+"&&o.length>0?`
72
72
  `.repeat(Math.max(1,o.length-1)):"",g=r+i.length;if(t.source)g+=t.source.length;return{value:m,type:s,comment:i.comment,range:[r,g,g]}}let c=t.indent+i.indent,l=t.offset+i.length,u=0;for(let m=0;m<a;++m){let[g,w]=o[m];if(w===""||w==="\r"){if(i.indent===0&&g.length>c)c=g.length}else{if(g.length<c)n(l+g.length,"MISSING_CHAR","Block scalars with more-indented leading empty lines must use an explicit indentation indicator");if(i.indent===0)c=g.length;if(u=m,c===0&&!e.atRoot)n(l,"BAD_INDENT","Block scalar values in collections must be indented");break}l+=g.length+w.length+1}for(let m=o.length-1;m>=a;--m)if(o[m][0].length>c)a=m+1;let p="",d="",h=!1;for(let m=0;m<u;++m)p+=o[m][0].slice(c)+`
73
73
  `;for(let m=u;m<a;++m){let[g,w]=o[m];l+=g.length+w.length+1;let k=w[w.length-1]==="\r";if(k)w=w.slice(0,-1);if(w&&g.length<c){let y=`Block scalar lines must not be less indented than their ${i.indent?"explicit indentation indicator":"first line"}`;n(l-w.length-(k?2:1),"BAD_INDENT",y),g=""}if(s===Zo.Scalar.BLOCK_LITERAL)p+=d+g.slice(c)+w,d=`
@@ -96,7 +96,7 @@ ${l}
96
96
  `)break;if(r===`
97
97
  `)n+=`
98
98
  `;t+=1,r=e[t+1]}if(!n)n=" ";return{fold:n,offset:t}}var vS={"0":"\x00",a:"\x07",b:"\b",e:"\x1B",f:"\f",n:`
99
- `,r:"\r",t:"\t",v:"\v",N:"\x85",_:"\xA0",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\","\t":"\t"};function yS(e,t,n,r){let i=e.substr(t,n),o=i.length===n&&/^[0-9a-fA-F]+$/.test(i)?parseInt(i,16):NaN;try{return String.fromCodePoint(o)}catch{let a=e.substr(t-2,n+2);return r(t-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${a}`),a}}bS.resolveFlowScalar=dS});var ip=P(function($S){var Nt=z(),rp=W(),_S=Go(),kS=Bo();function xS(e,t,n,r){let{value:i,type:s,comment:o,range:a}=t.type==="block-scalar"?_S.resolveBlockScalar(e,t,r):kS.resolveFlowScalar(t,e.options.strict,r),c=n?e.directives.tagName(n.source,(p)=>r(n,"TAG_RESOLVE_FAILED",p)):null,l;if(e.options.stringKeys&&e.atKey)l=e.schema[Nt.SCALAR];else if(c)l=SS(e.schema,i,c,n,r);else if(t.type==="scalar")l=AS(e,i,t,r);else l=e.schema[Nt.SCALAR];let u;try{let p=l.resolve(i,(d)=>r(n??t,"TAG_RESOLVE_FAILED",d),e.options);u=Nt.isScalar(p)?p:new rp.Scalar(p)}catch(p){let d=p instanceof Error?p.message:String(p);r(n??t,"TAG_RESOLVE_FAILED",d),u=new rp.Scalar(i)}if(u.range=a,u.source=i,s)u.type=s;if(c)u.tag=c;if(l.format)u.format=l.format;if(o)u.comment=o;return u}function SS(e,t,n,r,i){if(n==="!")return e[Nt.SCALAR];let s=[];for(let a of e.tags)if(!a.collection&&a.tag===n)if(a.default&&a.test)s.push(a);else return a;for(let a of s)if(a.test?.test(t))return a;let o=e.knownTags[n];if(o&&!o.collection)return e.tags.push(Object.assign({},o,{default:!1,test:void 0})),o;return i(r,"TAG_RESOLVE_FAILED",`Unresolved tag: ${n}`,n!=="tag:yaml.org,2002:str"),e[Nt.SCALAR]}function AS({atKey:e,directives:t,schema:n},r,i,s){let o=n.tags.find((a)=>(a.default===!0||e&&a.default==="key")&&a.test?.test(r))||n[Nt.SCALAR];if(n.compat){let a=n.compat.find((c)=>c.default&&c.test?.test(r))??n[Nt.SCALAR];if(o.tag!==a.tag){let c=t.tagString(o.tag),l=t.tagString(a.tag),u=`Value may be parsed as either ${c} or ${l}`;s(i,"TAG_RESOLVE_FAILED",u,!0)}}return o}$S.composeScalar=xS});var sp=P(function(ES){function TS(e,t,n){if(t){n??(n=t.length);for(let r=n-1;r>=0;--r){let i=t[r];switch(i.type){case"space":case"comment":case"newline":e-=i.source.length;continue}i=t[++r];while(i?.type==="space")e+=i.source.length,i=t[++r];break}}return e}ES.emptyScalarPosition=TS});var cp=P(function(LS){var CS=Tn(),RS=z(),IS=tp(),op=ip(),NS=rn(),zS=sp(),jS={composeNode:ap,composeEmptyNode:Ho};function ap(e,t,n,r){let i=e.atKey,{spaceBefore:s,comment:o,anchor:a,tag:c}=n,l,u=!0;switch(t.type){case"alias":if(l=DS(e,t,r),a||c)r(t,"ALIAS_PROPS","An alias node must not specify any properties");break;case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"block-scalar":if(l=op.composeScalar(e,t,c,r),a)l.anchor=a.source.substring(1);break;case"block-map":case"block-seq":case"flow-collection":try{if(l=IS.composeCollection(jS,e,t,n,r),a)l.anchor=a.source.substring(1)}catch(p){let d=p instanceof Error?p.message:String(p);r(t,"RESOURCE_EXHAUSTION",d)}break;default:{let p=t.type==="error"?t.message:`Unsupported token (type: ${t.type})`;r(t,"UNEXPECTED_TOKEN",p),u=!1}}if(l??(l=Ho(e,t.offset,void 0,null,n,r)),a&&l.anchor==="")r(a,"BAD_ALIAS","Anchor cannot be an empty string");if(i&&e.options.stringKeys&&(!RS.isScalar(l)||typeof l.value!=="string"||l.tag&&l.tag!=="tag:yaml.org,2002:str"))r(c??t,"NON_STRING_KEY","With stringKeys, all keys must be strings");if(s)l.spaceBefore=!0;if(o)if(t.type==="scalar"&&t.source==="")l.comment=o;else l.commentBefore=o;if(e.options.keepSourceTokens&&u)l.srcToken=t;return l}function Ho(e,t,n,r,{spaceBefore:i,comment:s,anchor:o,tag:a,end:c},l){let u={type:"scalar",offset:zS.emptyScalarPosition(t,n,r),indent:-1,source:""},p=op.composeScalar(e,u,a,l);if(o){if(p.anchor=o.source.substring(1),p.anchor==="")l(o,"BAD_ALIAS","Anchor cannot be an empty string")}if(i)p.spaceBefore=!0;if(s)p.comment=s,p.range[2]=c;return p}function DS({options:e},{offset:t,source:n,end:r},i){let s=new CS.Alias(n.substring(1));if(s.source==="")i(t,"BAD_ALIAS","Alias cannot be an empty string");if(s.source.endsWith(":"))i(t+n.length-1,"BAD_ALIAS","Alias ending in : is ambiguous",!0);let o=t+n.length,a=NS.resolveEnd(r,o,e.strict,i);if(s.range=[t,o,a.offset],a.comment)s.comment=a.comment;return s}LS.composeEmptyNode=Ho;LS.composeNode=ap});var up=P(function(HS){var ZS=Gn(),lp=cp(),GS=rn(),qS=Bn();function BS(e,t,{offset:n,start:r,value:i,end:s},o){let a=Object.assign({_directives:t},e),c=new ZS.Document(void 0,a),l={atKey:!1,atRoot:!0,directives:c.directives,options:c.options,schema:c.schema},u=qS.resolveProps(r,{indicator:"doc-start",next:i??s?.[0],offset:n,onError:o,parentIndent:0,startOnNewline:!0});if(u.found){if(c.directives.docStart=!0,i&&(i.type==="block-map"||i.type==="block-seq")&&!u.hasNewline)o(u.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")}c.contents=i?lp.composeNode(l,i,u,o):lp.composeEmptyNode(l,u.end,r,null,u,o);let p=c.contents.range[2],d=GS.resolveEnd(s,p,!1,o);if(d.comment)c.comment=d.comment;return c.range=[n,p,d.offset],c}HS.composeDoc=BS});var Fo=P(function(QS){var KS=Ce("process"),WS=Vs(),VS=Gn(),Hn=qn(),pp=z(),YS=up(),JS=rn();function Fn(e){if(typeof e==="number")return[e,e+1];if(Array.isArray(e))return e.length===2?e:[e[0],e[1]];let{offset:t,source:n}=e;return[t,t+(typeof n==="string"?n.length:1)]}function dp(e){let t="",n=!1,r=!1;for(let i=0;i<e.length;++i){let s=e[i];switch(s[0]){case"#":t+=(t===""?"":r?`
99
+ `,r:"\r",t:"\t",v:"\v",N:"\x85",_:"\xA0",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\","\t":"\t"};function yS(e,t,n,r){let i=e.substr(t,n),o=i.length===n&&/^[0-9a-fA-F]+$/.test(i)?parseInt(i,16):NaN;try{return String.fromCodePoint(o)}catch{let a=e.substr(t-2,n+2);return r(t-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${a}`),a}}bS.resolveFlowScalar=dS});var ip=P(function($S){var Nt=z(),rp=W(),_S=Go(),kS=Bo();function xS(e,t,n,r){let{value:i,type:s,comment:o,range:a}=t.type==="block-scalar"?_S.resolveBlockScalar(e,t,r):kS.resolveFlowScalar(t,e.options.strict,r),c=n?e.directives.tagName(n.source,(p)=>r(n,"TAG_RESOLVE_FAILED",p)):null,l;if(e.options.stringKeys&&e.atKey)l=e.schema[Nt.SCALAR];else if(c)l=SS(e.schema,i,c,n,r);else if(t.type==="scalar")l=AS(e,i,t,r);else l=e.schema[Nt.SCALAR];let u;try{let p=l.resolve(i,(d)=>r(n??t,"TAG_RESOLVE_FAILED",d),e.options);u=Nt.isScalar(p)?p:new rp.Scalar(p)}catch(p){let d=p instanceof Error?p.message:String(p);r(n??t,"TAG_RESOLVE_FAILED",d),u=new rp.Scalar(i)}if(u.range=a,u.source=i,s)u.type=s;if(c)u.tag=c;if(l.format)u.format=l.format;if(o)u.comment=o;return u}function SS(e,t,n,r,i){if(n==="!")return e[Nt.SCALAR];let s=[];for(let a of e.tags)if(!a.collection&&a.tag===n)if(a.default&&a.test)s.push(a);else return a;for(let a of s)if(a.test?.test(t))return a;let o=e.knownTags[n];if(o&&!o.collection)return e.tags.push(Object.assign({},o,{default:!1,test:void 0})),o;return i(r,"TAG_RESOLVE_FAILED",`Unresolved tag: ${n}`,n!=="tag:yaml.org,2002:str"),e[Nt.SCALAR]}function AS({atKey:e,directives:t,schema:n},r,i,s){let o=n.tags.find((a)=>(a.default===!0||e&&a.default==="key")&&a.test?.test(r))||n[Nt.SCALAR];if(n.compat){let a=n.compat.find((c)=>c.default&&c.test?.test(r))??n[Nt.SCALAR];if(o.tag!==a.tag){let c=t.tagString(o.tag),l=t.tagString(a.tag),u=`Value may be parsed as either ${c} or ${l}`;s(i,"TAG_RESOLVE_FAILED",u,!0)}}return o}$S.composeScalar=xS});var sp=P(function(ES){function TS(e,t,n){if(t){n??(n=t.length);for(let r=n-1;r>=0;--r){let i=t[r];switch(i.type){case"space":case"comment":case"newline":e-=i.source.length;continue}i=t[++r];while(i?.type==="space")e+=i.source.length,i=t[++r];break}}return e}ES.emptyScalarPosition=TS});var cp=P(function(DS){var CS=Tn(),RS=z(),IS=tp(),op=ip(),NS=rn(),zS=sp(),LS={composeNode:ap,composeEmptyNode:Ho};function ap(e,t,n,r){let i=e.atKey,{spaceBefore:s,comment:o,anchor:a,tag:c}=n,l,u=!0;switch(t.type){case"alias":if(l=jS(e,t,r),a||c)r(t,"ALIAS_PROPS","An alias node must not specify any properties");break;case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"block-scalar":if(l=op.composeScalar(e,t,c,r),a)l.anchor=a.source.substring(1);break;case"block-map":case"block-seq":case"flow-collection":try{if(l=IS.composeCollection(LS,e,t,n,r),a)l.anchor=a.source.substring(1)}catch(p){let d=p instanceof Error?p.message:String(p);r(t,"RESOURCE_EXHAUSTION",d)}break;default:{let p=t.type==="error"?t.message:`Unsupported token (type: ${t.type})`;r(t,"UNEXPECTED_TOKEN",p),u=!1}}if(l??(l=Ho(e,t.offset,void 0,null,n,r)),a&&l.anchor==="")r(a,"BAD_ALIAS","Anchor cannot be an empty string");if(i&&e.options.stringKeys&&(!RS.isScalar(l)||typeof l.value!=="string"||l.tag&&l.tag!=="tag:yaml.org,2002:str"))r(c??t,"NON_STRING_KEY","With stringKeys, all keys must be strings");if(s)l.spaceBefore=!0;if(o)if(t.type==="scalar"&&t.source==="")l.comment=o;else l.commentBefore=o;if(e.options.keepSourceTokens&&u)l.srcToken=t;return l}function Ho(e,t,n,r,{spaceBefore:i,comment:s,anchor:o,tag:a,end:c},l){let u={type:"scalar",offset:zS.emptyScalarPosition(t,n,r),indent:-1,source:""},p=op.composeScalar(e,u,a,l);if(o){if(p.anchor=o.source.substring(1),p.anchor==="")l(o,"BAD_ALIAS","Anchor cannot be an empty string")}if(i)p.spaceBefore=!0;if(s)p.comment=s,p.range[2]=c;return p}function jS({options:e},{offset:t,source:n,end:r},i){let s=new CS.Alias(n.substring(1));if(s.source==="")i(t,"BAD_ALIAS","Alias cannot be an empty string");if(s.source.endsWith(":"))i(t+n.length-1,"BAD_ALIAS","Alias ending in : is ambiguous",!0);let o=t+n.length,a=NS.resolveEnd(r,o,e.strict,i);if(s.range=[t,o,a.offset],a.comment)s.comment=a.comment;return s}DS.composeEmptyNode=Ho;DS.composeNode=ap});var up=P(function(HS){var ZS=Gn(),lp=cp(),GS=rn(),qS=Bn();function BS(e,t,{offset:n,start:r,value:i,end:s},o){let a=Object.assign({_directives:t},e),c=new ZS.Document(void 0,a),l={atKey:!1,atRoot:!0,directives:c.directives,options:c.options,schema:c.schema},u=qS.resolveProps(r,{indicator:"doc-start",next:i??s?.[0],offset:n,onError:o,parentIndent:0,startOnNewline:!0});if(u.found){if(c.directives.docStart=!0,i&&(i.type==="block-map"||i.type==="block-seq")&&!u.hasNewline)o(u.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")}c.contents=i?lp.composeNode(l,i,u,o):lp.composeEmptyNode(l,u.end,r,null,u,o);let p=c.contents.range[2],d=GS.resolveEnd(s,p,!1,o);if(d.comment)c.comment=d.comment;return c.range=[n,p,d.offset],c}HS.composeDoc=BS});var Fo=P(function(QS){var KS=Ce("process"),WS=Vs(),VS=Gn(),Hn=qn(),pp=z(),YS=up(),JS=rn();function Fn(e){if(typeof e==="number")return[e,e+1];if(Array.isArray(e))return e.length===2?e:[e[0],e[1]];let{offset:t,source:n}=e;return[t,t+(typeof n==="string"?n.length:1)]}function dp(e){let t="",n=!1,r=!1;for(let i=0;i<e.length;++i){let s=e[i];switch(s[0]){case"#":t+=(t===""?"":r?`
100
100
 
101
101
  `:`
102
102
  `)+(s.substring(1)||" "),n=!0,r=!1;break;case"%":if(e[i+1]?.[0]!=="#")i+=1;n=!1;break;default:if(!n)r=!0;n=!1}}return{comment:t,afterEmptyLine:r}}class hp{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(t,n,r,i)=>{let s=Fn(t);if(i)this.warnings.push(new Hn.YAMLWarning(s,n,r));else this.errors.push(new Hn.YAMLParseError(s,n,r))},this.directives=new WS.Directives({version:e.version||"1.2"}),this.options=e}decorate(e,t){let{comment:n,afterEmptyLine:r}=dp(this.prelude);if(n){let i=e.contents;if(t)e.comment=e.comment?`${e.comment}
@@ -114,8 +114,8 @@ ${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.pus
114
114
  `};delete e.items,Object.assign(e,{type:n,source:t,end:[i]});break}default:{let r="indent"in e?e.indent:-1,i="end"in e&&Array.isArray(e.end)?e.end.filter((s)=>s.type==="space"||s.type==="comment"||s.type==="newline"):[];for(let s of Object.keys(e))if(s!=="type"&&s!=="offset")delete e[s];Object.assign(e,{type:n,indent:r,source:t,end:i})}}}a1.createScalarToken=i1;a1.resolveAsScalar=r1;a1.setScalarValue=s1});var vp=P(function(d1){var p1=(e)=>("type"in e)?wi(e):bi(e);function wi(e){switch(e.type){case"block-scalar":{let t="";for(let n of e.props)t+=wi(n);return t+e.source}case"block-map":case"block-seq":{let t="";for(let n of e.items)t+=bi(n);return t}case"flow-collection":{let t=e.start.source;for(let n of e.items)t+=bi(n);for(let n of e.end)t+=n.source;return t}case"document":{let t=bi(e);if(e.end)for(let n of e.end)t+=n.source;return t}default:{let t=e.source;if("end"in e&&e.end)for(let n of e.end)t+=n.source;return t}}}function bi({start:e,key:t,sep:n,value:r}){let i="";for(let s of e)i+=s.source;if(t)i+=wi(t);if(n)for(let s of n)i+=s.source;if(r)i+=wi(r);return i}d1.stringify=p1});var wp=P(function(m1){var Wo=Symbol("break visit"),f1=Symbol("skip children"),yp=Symbol("remove item");function zt(e,t){if("type"in e&&e.type==="document")e={start:e.start,value:e.value};bp(Object.freeze([]),e,t)}zt.BREAK=Wo;zt.SKIP=f1;zt.REMOVE=yp;zt.itemAtPath=(e,t)=>{let n=e;for(let[r,i]of t){let s=n?.[r];if(s&&"items"in s)n=s.items[i];else return}return n};zt.parentCollection=(e,t)=>{let n=zt.itemAtPath(e,t.slice(0,-1)),r=t[t.length-1][0],i=n?.[r];if(i&&"items"in i)return i;throw Error("Parent collection not found")};function bp(e,t,n){let r=n(t,e);if(typeof r==="symbol")return r;for(let i of["key","value"]){let s=t[i];if(s&&"items"in s){for(let o=0;o<s.items.length;++o){let a=bp(Object.freeze(e.concat([[i,o]])),s.items[o],n);if(typeof a==="number")o=a-1;else if(a===Wo)return Wo;else if(a===yp)s.items.splice(o,1),o-=1}if(typeof r==="function"&&i==="key")r=r(t,e)}}return typeof r==="function"?r(t,e):r}m1.visit=zt});var _i=P(function(x1){var Vo=gp(),v1=vp(),y1=wp(),Yo="\uFEFF",Jo="\x02",Qo="\x18",Xo="\x1F",b1=(e)=>!!e&&("items"in e),w1=(e)=>!!e&&(e.type==="scalar"||e.type==="single-quoted-scalar"||e.type==="double-quoted-scalar"||e.type==="block-scalar");function _1(e){switch(e){case Yo:return"<BOM>";case Jo:return"<DOC>";case Qo:return"<FLOW_END>";case Xo:return"<SCALAR>";default:return JSON.stringify(e)}}function k1(e){switch(e){case Yo:return"byte-order-mark";case Jo:return"doc-mode";case Qo:return"flow-error-end";case Xo:return"scalar";case"---":return"doc-start";case"...":return"doc-end";case"":case`
115
115
  `:case`\r
116
116
  `:return"newline";case"-":return"seq-item-ind";case"?":return"explicit-key-ind";case":":return"map-value-ind";case"{":return"flow-map-start";case"}":return"flow-map-end";case"[":return"flow-seq-start";case"]":return"flow-seq-end";case",":return"comma"}switch(e[0]){case" ":case"\t":return"space";case"#":return"comment";case"%":return"directive-line";case"*":return"alias";case"&":return"anchor";case"!":return"tag";case"'":return"single-quoted-scalar";case'"':return"double-quoted-scalar";case"|":case">":return"block-scalar-header"}return null}x1.createScalarToken=Vo.createScalarToken;x1.resolveAsScalar=Vo.resolveAsScalar;x1.setScalarValue=Vo.setScalarValue;x1.stringify=v1.stringify;x1.visit=y1.visit;x1.BOM=Yo;x1.DOCUMENT=Jo;x1.FLOW_END=Qo;x1.SCALAR=Xo;x1.isCollection=b1;x1.isScalar=w1;x1.prettyToken=_1;x1.tokenType=k1});var ta=P(function(M1){var Kn=_i();function Ie(e){switch(e){case void 0:case" ":case`
117
- `:case"\r":case"\t":return!0;default:return!1}}var _p=new Set("0123456789ABCDEFabcdef"),D1=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),ki=new Set(",[]{}"),L1=new Set(` ,[]{}
118
- \r `),ea=(e)=>!e||L1.has(e);class kp{constructor(){this.atEnd=!1,this.blockScalarIndent=-1,this.blockScalarKeep=!1,this.buffer="",this.flowKey=!1,this.flowLevel=0,this.indentNext=0,this.indentValue=0,this.lineEndPos=null,this.next=null,this.pos=0}*lex(e,t=!1){if(e){if(typeof e!=="string")throw TypeError("source is not a string");this.buffer=this.buffer?this.buffer+e:e,this.lineEndPos=null}this.atEnd=!t;let n=this.next??"stream";while(n&&(t||this.hasChars(1)))n=yield*this.parseNext(n)}atLineEnd(){let e=this.pos,t=this.buffer[e];while(t===" "||t==="\t")t=this.buffer[++e];if(!t||t==="#"||t===`
117
+ `:case"\r":case"\t":return!0;default:return!1}}var _p=new Set("0123456789ABCDEFabcdef"),j1=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),ki=new Set(",[]{}"),D1=new Set(` ,[]{}
118
+ \r `),ea=(e)=>!e||D1.has(e);class kp{constructor(){this.atEnd=!1,this.blockScalarIndent=-1,this.blockScalarKeep=!1,this.buffer="",this.flowKey=!1,this.flowLevel=0,this.indentNext=0,this.indentValue=0,this.lineEndPos=null,this.next=null,this.pos=0}*lex(e,t=!1){if(e){if(typeof e!=="string")throw TypeError("source is not a string");this.buffer=this.buffer?this.buffer+e:e,this.lineEndPos=null}this.atEnd=!t;let n=this.next??"stream";while(n&&(t||this.hasChars(1)))n=yield*this.parseNext(n)}atLineEnd(){let e=this.pos,t=this.buffer[e];while(t===" "||t==="\t")t=this.buffer[++e];if(!t||t==="#"||t===`
119
119
  `)return!0;if(t==="\r")return this.buffer[e+1]===`
120
120
  `;return!1}charAt(e){return this.buffer[this.pos+e]}continueScalar(e){let t=this.buffer[e];if(this.indentNext>0){let n=0;while(t===" ")t=this.buffer[++n+e];if(t==="\r"){let r=this.buffer[n+e+1];if(r===`
121
121
  `||!r&&!this.atEnd)return e+n+1}return t===`
@@ -130,17 +130,17 @@ ${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.pus
130
130
  `&&i>=this.pos&&i+1+t>o)e=i;else break}while(!0);return yield Kn.SCALAR,yield*this.pushToIndex(e+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let e=this.flowLevel>0,t=this.pos-1,n=this.pos-1,r;while(r=this.buffer[++n])if(r===":"){let i=this.buffer[n+1];if(Ie(i)||e&&ki.has(i))break;t=n}else if(Ie(r)){let i=this.buffer[n+1];if(r==="\r")if(i===`
131
131
  `)n+=1,r=`
132
132
  `,i=this.buffer[n+1];else t=n;if(i==="#"||e&&ki.has(i))break;if(r===`
133
- `){let s=this.continueScalar(n+1);if(s===-1)break;n=Math.max(n,s-2)}}else{if(e&&ki.has(r))break;t=n}if(!r&&!this.atEnd)return this.setNext("plain-scalar");return yield Kn.SCALAR,yield*this.pushToIndex(t+1,!0),e?"flow":"doc"}*pushCount(e){if(e>0)return yield this.buffer.substr(this.pos,e),this.pos+=e,e;return 0}*pushToIndex(e,t){let n=this.buffer.slice(this.pos,e);if(n)return yield n,this.pos+=n.length,n.length;else if(t)yield"";return 0}*pushIndicators(){let e=0;e:while(!0){switch(this.charAt(0)){case"!":e+=yield*this.pushTag(),e+=yield*this.pushSpaces(!0);continue e;case"&":e+=yield*this.pushUntil(ea),e+=yield*this.pushSpaces(!0);continue e;case"-":case"?":case":":{let t=this.flowLevel>0,n=this.charAt(1);if(Ie(n)||t&&ki.has(n)){if(!t)this.indentNext=this.indentValue+1;else if(this.flowKey)this.flowKey=!1;e+=yield*this.pushCount(1),e+=yield*this.pushSpaces(!0);continue e}}}break e}return e}*pushTag(){if(this.charAt(1)==="<"){let e=this.pos+2,t=this.buffer[e];while(!Ie(t)&&t!==">")t=this.buffer[++e];return yield*this.pushToIndex(t===">"?e+1:e,!1)}else{let e=this.pos+1,t=this.buffer[e];while(t)if(D1.has(t))t=this.buffer[++e];else if(t==="%"&&_p.has(this.buffer[e+1])&&_p.has(this.buffer[e+2]))t=this.buffer[e+=3];else break;return yield*this.pushToIndex(e,!1)}}*pushNewline(){let e=this.buffer[this.pos];if(e===`
133
+ `){let s=this.continueScalar(n+1);if(s===-1)break;n=Math.max(n,s-2)}}else{if(e&&ki.has(r))break;t=n}if(!r&&!this.atEnd)return this.setNext("plain-scalar");return yield Kn.SCALAR,yield*this.pushToIndex(t+1,!0),e?"flow":"doc"}*pushCount(e){if(e>0)return yield this.buffer.substr(this.pos,e),this.pos+=e,e;return 0}*pushToIndex(e,t){let n=this.buffer.slice(this.pos,e);if(n)return yield n,this.pos+=n.length,n.length;else if(t)yield"";return 0}*pushIndicators(){let e=0;e:while(!0){switch(this.charAt(0)){case"!":e+=yield*this.pushTag(),e+=yield*this.pushSpaces(!0);continue e;case"&":e+=yield*this.pushUntil(ea),e+=yield*this.pushSpaces(!0);continue e;case"-":case"?":case":":{let t=this.flowLevel>0,n=this.charAt(1);if(Ie(n)||t&&ki.has(n)){if(!t)this.indentNext=this.indentValue+1;else if(this.flowKey)this.flowKey=!1;e+=yield*this.pushCount(1),e+=yield*this.pushSpaces(!0);continue e}}}break e}return e}*pushTag(){if(this.charAt(1)==="<"){let e=this.pos+2,t=this.buffer[e];while(!Ie(t)&&t!==">")t=this.buffer[++e];return yield*this.pushToIndex(t===">"?e+1:e,!1)}else{let e=this.pos+1,t=this.buffer[e];while(t)if(j1.has(t))t=this.buffer[++e];else if(t==="%"&&_p.has(this.buffer[e+1])&&_p.has(this.buffer[e+2]))t=this.buffer[e+=3];else break;return yield*this.pushToIndex(e,!1)}}*pushNewline(){let e=this.buffer[this.pos];if(e===`
134
134
  `)return yield*this.pushCount(1);else if(e==="\r"&&this.charAt(1)===`
135
135
  `)return yield*this.pushCount(2);else return 0}*pushSpaces(e){let t=this.pos-1,n;do n=this.buffer[++t];while(n===" "||e&&n==="\t");let r=t-this.pos;if(r>0)yield this.buffer.substr(this.pos,r),this.pos=t;return r}*pushUntil(e){let t=this.pos,n=this.buffer[t];while(!e(n))n=this.buffer[++t];return yield*this.pushToIndex(t,!1)}}M1.Lexer=kp});var na=P(function(Z1){class xp{constructor(){this.lineStarts=[],this.addNewLine=(e)=>this.lineStarts.push(e),this.linePos=(e)=>{let t=0,n=this.lineStarts.length;while(t<n){let i=t+n>>1;if(this.lineStarts[i]<e)t=i+1;else n=i}if(this.lineStarts[t]===e)return{line:t+1,col:1};if(t===0)return{line:0,col:e};let r=this.lineStarts[t-1];return{line:t,col:e-r+1}}}}Z1.LineCounter=xp});var ra=P(function(H1){var q1=Ce("process"),Sp=_i(),B1=ta();function mt(e,t){for(let n=0;n<e.length;++n)if(e[n].type===t)return!0;return!1}function Ap(e){for(let t=0;t<e.length;++t)switch(e[t].type){case"space":case"comment":case"newline":break;default:return t}return-1}function Pp(e){switch(e?.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"flow-collection":return!0;default:return!1}}function xi(e){switch(e.type){case"document":return e.start;case"block-map":{let t=e.items[e.items.length-1];return t.sep??t.start}case"block-seq":return e.items[e.items.length-1].start;default:return[]}}function sn(e){if(e.length===0)return[];let t=e.length;e:while(--t>=0)switch(e[t].type){case"doc-start":case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":case"newline":break e}while(e[++t]?.type==="space");return e.splice(t,e.length)}function Si(e,t){if(t.length<1e5)Array.prototype.push.apply(e,t);else for(let n=0;n<t.length;++n)e.push(t[n])}function $p(e){if(e.start.type==="flow-seq-start"){for(let t of e.items)if(t.sep&&!t.value&&!mt(t.start,"explicit-key-ind")&&!mt(t.sep,"map-value-ind")){if(t.key)t.value=t.key;if(delete t.key,Pp(t.value))if(t.value.end)Si(t.value.end,t.sep);else t.value.end=t.sep;else Si(t.start,t.sep);delete t.sep}}}class Tp{constructor(e){this.atNewLine=!0,this.atScalar=!1,this.indent=0,this.offset=0,this.onKeyLine=!1,this.stack=[],this.source="",this.type="",this.lexer=new B1.Lexer,this.onNewLine=e}*parse(e,t=!1){if(this.onNewLine&&this.offset===0)this.onNewLine(0);for(let n of this.lexer.lex(e,t))yield*this.next(n);if(!t)yield*this.end()}*next(e){if(this.source=e,q1.env.LOG_TOKENS)console.log("|",Sp.prettyToken(e));if(this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let t=Sp.tokenType(e);if(!t){let n=`Not a YAML token: ${e}`;yield*this.pop({type:"error",offset:this.offset,message:n,source:e}),this.offset+=e.length}else if(t==="scalar")this.atNewLine=!1,this.atScalar=!0,this.type="scalar";else{switch(this.type=t,yield*this.step(),t){case"newline":if(this.atNewLine=!0,this.indent=0,this.onNewLine)this.onNewLine(this.offset+e.length);break;case"space":if(this.atNewLine&&e[0]===" ")this.indent+=e.length;break;case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":if(this.atNewLine)this.indent+=e.length;break;case"doc-mode":case"flow-error-end":return;default:this.atNewLine=!1}this.offset+=e.length}}*end(){while(this.stack.length>0)yield*this.pop()}get sourceToken(){return{type:this.type,offset:this.offset,indent:this.indent,source:this.source}}*step(){let e=this.peek(1);if(this.type==="doc-end"&&e?.type!=="doc-end"){while(this.stack.length>0)yield*this.pop();this.stack.push({type:"doc-end",offset:this.offset,source:this.source});return}if(!e)return yield*this.stream();switch(e.type){case"document":return yield*this.document(e);case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return yield*this.scalar(e);case"block-scalar":return yield*this.blockScalar(e);case"block-map":return yield*this.blockMap(e);case"block-seq":return yield*this.blockSequence(e);case"flow-collection":return yield*this.flowCollection(e);case"doc-end":return yield*this.documentEnd(e)}yield*this.pop()}peek(e){return this.stack[this.stack.length-e]}*pop(e){let t=e??this.stack.pop();if(!t)yield{type:"error",offset:this.offset,source:"",message:"Tried to pop an empty stack"};else if(this.stack.length===0)yield t;else{let n=this.peek(1);if(t.type==="block-scalar")t.indent="indent"in n?n.indent:0;else if(t.type==="flow-collection"&&n.type==="document")t.indent=0;if(t.type==="flow-collection")$p(t);switch(n.type){case"document":n.value=t;break;case"block-scalar":n.props.push(t);break;case"block-map":{let r=n.items[n.items.length-1];if(r.value){n.items.push({start:[],key:t,sep:[]}),this.onKeyLine=!0;return}else if(r.sep)r.value=t;else{Object.assign(r,{key:t,sep:[]}),this.onKeyLine=!r.explicitKey;return}break}case"block-seq":{let r=n.items[n.items.length-1];if(r.value)n.items.push({start:[],value:t});else r.value=t;break}case"flow-collection":{let r=n.items[n.items.length-1];if(!r||r.value)n.items.push({start:[],key:t,sep:[]});else if(r.sep)r.value=t;else Object.assign(r,{key:t,sep:[]});return}default:yield*this.pop(),yield*this.pop(t)}if((n.type==="document"||n.type==="block-map"||n.type==="block-seq")&&(t.type==="block-map"||t.type==="block-seq")){let r=t.items[t.items.length-1];if(r&&!r.sep&&!r.value&&r.start.length>0&&Ap(r.start)===-1&&(t.indent===0||r.start.every((i)=>i.type!=="comment"||i.indent<t.indent))){if(n.type==="document")n.end=r.start;else n.items.push({start:r.start});t.items.splice(-1,1)}}}}*stream(){switch(this.type){case"directive-line":yield{type:"directive",offset:this.offset,source:this.source};return;case"byte-order-mark":case"space":case"comment":case"newline":yield this.sourceToken;return;case"doc-mode":case"doc-start":{let e={type:"document",offset:this.offset,start:[]};if(this.type==="doc-start")e.start.push(this.sourceToken);this.stack.push(e);return}}yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML stream`,source:this.source}}*document(e){if(e.value)return yield*this.lineEnd(e);switch(this.type){case"doc-start":{if(Ap(e.start)!==-1)yield*this.pop(),yield*this.step();else e.start.push(this.sourceToken);return}case"anchor":case"tag":case"space":case"comment":case"newline":e.start.push(this.sourceToken);return}let t=this.startBlockValue(e);if(t)this.stack.push(t);else yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML document`,source:this.source}}*scalar(e){if(this.type==="map-value-ind"){let t=xi(this.peek(2)),n=sn(t),r;if(e.end)r=e.end,r.push(this.sourceToken),delete e.end;else r=[this.sourceToken];let i={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:n,key:e,sep:r}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=i}else yield*this.lineEnd(e)}*blockScalar(e){switch(this.type){case"space":case"comment":case"newline":e.props.push(this.sourceToken);return;case"scalar":if(e.source=this.source,this.atNewLine=!0,this.indent=0,this.onNewLine){let t=this.source.indexOf(`
136
136
  `)+1;while(t!==0)this.onNewLine(this.offset+t),t=this.source.indexOf(`
137
137
  `,t)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(e){let t=e.items[e.items.length-1];switch(this.type){case"newline":if(this.onKeyLine=!1,t.value){let n="end"in t.value?t.value.end:void 0;if((Array.isArray(n)?n[n.length-1]:void 0)?.type==="comment")n?.push(this.sourceToken);else e.items.push({start:[this.sourceToken]})}else if(t.sep)t.sep.push(this.sourceToken);else t.start.push(this.sourceToken);return;case"space":case"comment":if(t.value)e.items.push({start:[this.sourceToken]});else if(t.sep)t.sep.push(this.sourceToken);else{if(this.atIndentedComment(t.start,e.indent)){let r=e.items[e.items.length-2]?.value?.end;if(Array.isArray(r)){Si(r,t.start),r.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return}if(this.indent>=e.indent){let n=!this.onKeyLine&&this.indent===e.indent,r=n&&(t.sep||t.explicitKey)&&this.type!=="seq-item-ind",i=[];if(r&&t.sep&&!t.value){let s=[];for(let o=0;o<t.sep.length;++o){let a=t.sep[o];switch(a.type){case"newline":s.push(o);break;case"space":break;case"comment":if(a.indent>e.indent)s.length=0;break;default:s.length=0}}if(s.length>=2)i=t.sep.splice(s[1])}switch(this.type){case"anchor":case"tag":if(r||t.value)i.push(this.sourceToken),e.items.push({start:i}),this.onKeyLine=!0;else if(t.sep)t.sep.push(this.sourceToken);else t.start.push(this.sourceToken);return;case"explicit-key-ind":if(!t.sep&&!t.explicitKey)t.start.push(this.sourceToken),t.explicitKey=!0;else if(r||t.value)i.push(this.sourceToken),e.items.push({start:i,explicitKey:!0});else this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]});this.onKeyLine=!0;return;case"map-value-ind":if(t.explicitKey)if(!t.sep)if(mt(t.start,"newline"))Object.assign(t,{key:null,sep:[this.sourceToken]});else{let s=sn(t.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:s,key:null,sep:[this.sourceToken]}]})}else if(t.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(mt(t.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:i,key:null,sep:[this.sourceToken]}]});else if(Pp(t.key)&&!mt(t.sep,"newline")){let s=sn(t.start),{key:o,sep:a}=t;a.push(this.sourceToken),delete t.key,delete t.sep,this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:s,key:o,sep:a}]})}else if(i.length>0)t.sep=t.sep.concat(i,this.sourceToken);else t.sep.push(this.sourceToken);else if(!t.sep)Object.assign(t,{key:null,sep:[this.sourceToken]});else if(t.value||r)e.items.push({start:i,key:null,sep:[this.sourceToken]});else if(mt(t.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]});else t.sep.push(this.sourceToken);this.onKeyLine=!0;return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let s=this.flowScalar(this.type);if(r||t.value)e.items.push({start:i,key:s,sep:[]}),this.onKeyLine=!0;else if(t.sep)this.stack.push(s);else Object.assign(t,{key:s,sep:[]}),this.onKeyLine=!0;return}default:{let s=this.startBlockValue(e);if(s){if(s.type==="block-seq"){if(!t.explicitKey&&t.sep&&!mt(t.sep,"newline")){yield*this.pop({type:"error",offset:this.offset,message:"Unexpected block-seq-ind on same line with key",source:this.source});return}}else if(n)e.items.push({start:i});this.stack.push(s);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(e){let t=e.items[e.items.length-1];switch(this.type){case"newline":if(t.value){let n="end"in t.value?t.value.end:void 0;if((Array.isArray(n)?n[n.length-1]:void 0)?.type==="comment")n?.push(this.sourceToken);else e.items.push({start:[this.sourceToken]})}else t.start.push(this.sourceToken);return;case"space":case"comment":if(t.value)e.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(t.start,e.indent)){let r=e.items[e.items.length-2]?.value?.end;if(Array.isArray(r)){Si(r,t.start),r.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return;case"anchor":case"tag":if(t.value||this.indent<=e.indent)break;t.start.push(this.sourceToken);return;case"seq-item-ind":if(this.indent!==e.indent)break;if(t.value||mt(t.start,"seq-item-ind"))e.items.push({start:[this.sourceToken]});else t.start.push(this.sourceToken);return}if(this.indent>e.indent){let n=this.startBlockValue(e);if(n){this.stack.push(n);return}}yield*this.pop(),yield*this.step()}*flowCollection(e){let t=e.items[e.items.length-1];if(this.type==="flow-error-end"){let n;do yield*this.pop(),n=this.peek(1);while(n?.type==="flow-collection")}else if(e.end.length===0){switch(this.type){case"comma":case"explicit-key-ind":if(!t||t.sep)e.items.push({start:[this.sourceToken]});else t.start.push(this.sourceToken);return;case"map-value-ind":if(!t||t.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(t.sep)t.sep.push(this.sourceToken);else Object.assign(t,{key:null,sep:[this.sourceToken]});return;case"space":case"comment":case"newline":case"anchor":case"tag":if(!t||t.value)e.items.push({start:[this.sourceToken]});else if(t.sep)t.sep.push(this.sourceToken);else t.start.push(this.sourceToken);return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let r=this.flowScalar(this.type);if(!t||t.value)e.items.push({start:[],key:r,sep:[]});else if(t.sep)this.stack.push(r);else Object.assign(t,{key:r,sep:[]});return}case"flow-map-end":case"flow-seq-end":e.end.push(this.sourceToken);return}let n=this.startBlockValue(e);if(n)this.stack.push(n);else yield*this.pop(),yield*this.step()}else{let n=this.peek(2);if(n.type==="block-map"&&(this.type==="map-value-ind"&&n.indent===e.indent||this.type==="newline"&&!n.items[n.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type==="map-value-ind"&&n.type!=="flow-collection"){let r=xi(n),i=sn(r);$p(e);let s=e.end.splice(1,e.end.length);s.push(this.sourceToken);let o={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:i,key:e,sep:s}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=o}else yield*this.lineEnd(e)}}flowScalar(e){if(this.onNewLine){let t=this.source.indexOf(`
138
138
  `)+1;while(t!==0)this.onNewLine(this.offset+t),t=this.source.indexOf(`
139
- `,t)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;let t=xi(e),n=sn(t);return n.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:n,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;let t=xi(e),n=sn(t);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:n,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,t){if(this.type!=="comment")return!1;if(this.indent<=t)return!1;return e.every((n)=>n.type==="newline"||n.type==="space")}*documentEnd(e){if(this.type!=="doc-mode"){if(e.end)e.end.push(this.sourceToken);else e.end=[this.sourceToken];if(this.type==="newline")yield*this.pop()}}*lineEnd(e){switch(this.type){case"comma":case"doc-start":case"doc-end":case"flow-seq-end":case"flow-map-end":case"map-value-ind":yield*this.pop(),yield*this.step();break;case"newline":this.onKeyLine=!1;case"space":case"comment":default:if(e.end)e.end.push(this.sourceToken);else e.end=[this.sourceToken];if(this.type==="newline")yield*this.pop()}}}H1.Parser=Tp});var Ip=P(function(eA){var Ep=Fo(),K1=Gn(),Wn=qn(),W1=to(),V1=z(),Y1=na(),Op=ra();function Cp(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new Y1.LineCounter||null,prettyErrors:t}}function J1(e,t={}){let{lineCounter:n,prettyErrors:r}=Cp(t),i=new Op.Parser(n?.addNewLine),s=new Ep.Composer(t),o=Array.from(s.compose(i.parse(e)));if(r&&n)for(let a of o)a.errors.forEach(Wn.prettifyError(e,n)),a.warnings.forEach(Wn.prettifyError(e,n));if(o.length>0)return o;return Object.assign([],{empty:!0},s.streamInfo())}function Rp(e,t={}){let{lineCounter:n,prettyErrors:r}=Cp(t),i=new Op.Parser(n?.addNewLine),s=new Ep.Composer(t),o=null;for(let a of s.compose(i.parse(e),!0,e.length))if(!o)o=a;else if(o.options.logLevel!=="silent"){o.errors.push(new Wn.YAMLParseError(a.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}if(r&&n)o.errors.forEach(Wn.prettifyError(e,n)),o.warnings.forEach(Wn.prettifyError(e,n));return o}function Q1(e,t,n){let r=void 0;if(typeof t==="function")r=t;else if(n===void 0&&t&&typeof t==="object")n=t;let i=Rp(e,n);if(!i)return null;if(i.warnings.forEach((s)=>W1.warn(i.options.logLevel,s)),i.errors.length>0)if(i.options.logLevel!=="silent")throw i.errors[0];else i.errors=[];return i.toJS(Object.assign({reviver:r},n))}function X1(e,t,n){let r=null;if(typeof t==="function"||Array.isArray(t))r=t;else if(n===void 0&&t)n=t;if(typeof n==="string")n=n.length;if(typeof n==="number"){let i=Math.round(n);n=i<1?void 0:i>8?{indent:8}:{indent:i}}if(e===void 0){let{keepUndefined:i}=n??t??{};if(!i)return}if(V1.isDocument(e)&&!r)return e.toString(n);return new K1.Document(e,r,n).toString(n)}eA.parse=Q1;eA.parseAllDocuments=J1;eA.parseDocument=Rp;eA.stringify=X1});var zc={};Al(zc,{default:()=>XT});var jc={};Al(jc,{default:()=>tE});class v extends Error{reason;fix;constructor(e,t){super(e);this.reason=e;this.fix=t;this.name="TapsterError"}}class R extends v{status;constructor(e,t,n){super(e,t);this.status=n;this.name="GitHubError"}}import{existsSync as Pt,readdirSync as Sv,readFileSync as wv}from"fs";import{basename as Ar,join as te}from"path";var sA=Fo(),oA=Gn(),aA=Oo(),ia=qn(),cA=Tn(),gt=z(),lA=pt(),uA=W(),pA=ht(),dA=ft(),IR=_i(),hA=ta(),fA=na(),mA=ra(),Ai=Ip(),Np=$n();var gA=sA.Composer,vA=oA.Document,yA=aA.Schema,{YAMLError:bA,YAMLParseError:wA,YAMLWarning:_A}=ia,kA=cA.Alias,{isAlias:xA,isCollection:SA,isDocument:AA,isMap:Ae,isNode:$A,isPair:PA,isScalar:TA,isSeq:vt}=gt,EA=lA.Pair,OA=uA.Scalar,CA=pA.YAMLMap,RA=dA.YAMLSeq;var IA=hA.Lexer,NA=fA.LineCounter,zA=mA.Parser,{parse:ne,parseAllDocuments:jA,parseDocument:yt,stringify:DA}=Ai,{visit:LA,visitAsync:MA}=Np;function Yn(e){let t=Object.values(e).filter((r)=>typeof r==="number");return Object.entries(e).filter(([r,i])=>t.indexOf(+r)===-1).map(([r,i])=>i)}function oa(e,t="|"){return e.map((n)=>la(n)).join(t)}function Jn(e,t){if(typeof t==="bigint")return t.toString();return t}class zp{constructor(e){this._getter=e,this._value=void 0}get value(){let e=this._getter;if(e!==void 0)this._value=e(),this._getter=void 0;return this._value}}function Qn(e){return new zp(e)}function jp(e){return e===null||e===void 0}function $i(e){let t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function Dp(e,t){let n=e/t,r=Math.round(n),i=4*Number.EPSILON*Math.max(Math.abs(n),1);if(Math.abs(n-r)<i)return 0;return n-r}function ge(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Xn(e){let t=Object.getOwnPropertyDescriptor(e,"shape");return t?.get?t.get.raw:t?.value}function Xe(e){return Xn(e._zod.def)??e._zod.def.shape}function Lp(e,t,n){Object.defineProperty(e,t,{get(){let r=n();return ge(this,t,r),r},enumerable:!0,configurable:!0})}function Mp(e,t,n){if(t in e)ge(e,t,n);else e[t]=n}function jt(e,t,n,r){let i=Xe(t);for(let s of n){let o=Object.getOwnPropertyDescriptor(i,s);if(!o.enumerable)continue;if(o.get)Lp(e,s,()=>{let a=t._zod.def.shape[s];return r?r(a,s):a});else Mp(e,s,r?r(o.value,s):o.value)}}function UA(e,t){for(let n of Reflect.ownKeys(t)){let r=Object.getOwnPropertyDescriptor(t,n);if(!r.enumerable)continue;if(r.get)Lp(e,n,()=>t[n]);else Mp(e,n,r.value)}}function ve(...e){let t={};for(let n of e){let r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function Up(e){return JSON.stringify(e)}function Zp(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var aa="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function on(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}var Gp=Qn(()=>{if(le.jitless)return!1;if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function Dt(e){if(on(e)===!1)return!1;let t=e.constructor;if(t===void 0)return!0;if(typeof t!=="function")return!0;let n=t.prototype;if(on(n)===!1)return!1;if(Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)return!1;return!0}function ca(e){if(Dt(e))return{...e};if(Array.isArray(e))return[...e];if(e instanceof Map)return new Map(e);if(e instanceof Set)return new Set(e);return e}var qp=new Set(["string","number","symbol"]);function wt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Me(e,t,n){let r=new e._zod.constr(t??e._zod.def);if(!t||n?.parent)r._zod.parent=e;return r}function T(e){let t=e;if(!t)return{};if(typeof t==="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}if(delete t.message,typeof t.error==="string")return{...t,error:()=>t.error};return t}function la(e){if(typeof e==="bigint")return e.toString()+"n";if(typeof e==="string")return`"${e}"`;return`${e}`}function Bp(e){return Object.keys(e).filter((t)=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}var Pi=(()=>({safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-340282346638528860000000000000000000000,340282346638528860000000000000000000000],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]}))(),ua={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function ZA(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(".pick() cannot be used on object schemas containing refinements");let s={};return jt(s,e,Ti(e,t)),Me(e,ve(n,{shape:s,checks:[]}))}function Ti(e,t){let n=Xe(e),r=[];for(let i of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(n,i)?.enumerable)throw Error(`Unrecognized key: "${String(i)}"`);if(t[i])r.push(i)}return r}function GA(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(".omit() cannot be used on object schemas containing refinements");let s=new Set(Ti(e,t)),o={};return jt(o,e,Reflect.ownKeys(Xe(e)).filter((a)=>!s.has(a))),Me(e,ve(n,{shape:o,checks:[]}))}function qA(e,t){if(!Dt(t))throw Error("Invalid input to extend: expected a plain object");let n=e._zod.def.checks;if(n&&n.length>0){let i=Xe(e);for(let s of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(i,s)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return Me(e,ve(e._zod.def,{shape:Hp(e,t)}))}function Hp(e,t){let n={};return jt(n,e,Reflect.ownKeys(Xe(e))),UA(n,t),n}function BA(e,t){if(!Dt(t))throw Error("Invalid input to safeExtend: expected a plain object");return Me(e,ve(e._zod.def,{shape:Hp(e,t)}))}function HA(e,t){if(!t?._zod?.def)throw Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let n={};jt(n,e,Reflect.ownKeys(Xe(e))),jt(n,t,Reflect.ownKeys(Xe(t)));let r=ve(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return Me(e,r)}function Fp(e,t,n,r="partial"){let s=t._zod.def.checks;if(s&&s.length>0)throw Error(`.${r}() cannot be used on object schemas containing refinements`);let a=n?new Set(Ti(t,n)):void 0,c={};return jt(c,t,Reflect.ownKeys(Xe(t)),e&&((l,u)=>a&&!a.has(u)?l:new e({type:"optional",innerType:l}))),Me(t,ve(t._zod.def,{shape:c,checks:[]}))}function FA(e,t,n){let r=n?new Set(Ti(t,n)):void 0,i={};return jt(i,t,Reflect.ownKeys(Xe(t)),(s,o)=>r&&!r.has(o)?s:new e({type:"nonoptional",innerType:s})),Me(t,ve(t._zod.def,{shape:i}))}function $e(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function Kp(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function Ue(e,t){return t.map((n)=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function Vn(e){return typeof e==="string"?e:e?.message}function pa(e){let t=[];for(let n of e??[]){let r=n._zod.def;if(!/_(length|size)$|_equals$/.test(r.check))break;let i=r.maximum??r.length??r.size;if(i>=0)t.push([i,n])}return t}function Ei(e,t,n){var r;for(let i=t;i<e.length;i++)(r=e[i]).schema??(r.schema=n)}function Ze(e,t,n){var r;let i=e.inst?._zod?.traits;if(i?.has("$ZodType"))if(i.has("$ZodCheck"))(r=e).schema??(r.schema=e.inst);else e.schema=e.inst;let s=e.schema!==e.inst?e.schema?._zod.def?.error:void 0,o=e.message?e.message:Vn(e.inst?._zod.def?.error?.(e))??Vn(s?.(e))??Vn(t?.error?.(e))??Vn(n.customError?.(e))??Vn(n.localeError?.(e))??"Invalid input",a={};for(let c of Object.keys(e)){if(c==="inst"||c==="schema"||c==="continue"||c==="input"||c==="__proto__")continue;a[c]=e[c]}if(a.path??(a.path=[]),a.message=o,t?.reportInput)a.input=e.input;return a}var KA=/[\uD800-\uDBFF]/;function Oi(e){let t=e.length;if(!KA.test(e))return t;let n=t;for(let r=0;r<t-1;r++)if((e.charCodeAt(r)&64512)===55296&&(e.charCodeAt(r+1)&64512)===56320)n--,r++;return n}function Ci(e){if(Array.isArray(e))return"array";if(typeof e==="string")return"string";return"unknown"}function Wp(e){let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(e===null)return"null";if(Array.isArray(e))return"array";let n=e;if(n&&Object.getPrototypeOf(n)!==Object.prototype&&"constructor"in n&&n.constructor)return n.constructor.name}}return t}function Lt(...e){let[t,n,r]=e;if(typeof t==="string")return{message:t,code:"custom",input:n,inst:r};return{...t}}function Vp(e,t){for(let n in t){let r=Object.getOwnPropertyDescriptor(t,n);if(r.get)Object.defineProperty(e,n,{...r,enumerable:!1});else WA(e,n,r.value)}}function et(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function Ri(e,t,n){return et(e,t,n,!1)}function Yp(e,t){for(let n in e){let r=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return et(this,n,r(this))},set(i){et(this,n,i)}})}return t}function WA(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:et(this,t,n.bind(this))},set(r){et(this,t,r)}})}function VA(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}var sa,bt=!1,YA={configurable:!0,get(){bt=!0;return}};function j(e,t,n){let r=Object.getPrototypeOf(e._zod);if(t in r&&sa!==e._zod){sa=void 0;return}sa=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,YA);let i=bt;bt=!1;try{let s=n(this);if(bt)delete this[t];else Object.defineProperty(this,t,{configurable:!0,writable:!0,value:s});return bt=bt||i,s}catch(s){throw delete this[t],bt=bt||i,s}},set(i){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:i})}})}function JA(e,t,n,r){let i=VA(e,t);if(!i)return;Object.defineProperty(i,t,{configurable:!0,get(){let s={configurable:!0,writable:!0,enumerable:r,value:void 0};return Object.defineProperty(this,t,s),s.value=n(this),Object.defineProperty(this,t,s),s.value},set(s){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:r,value:s})}})}var QA="~constantCatch";function Jp(e){let t=()=>e;return t[QA]=!0,t}var Qp;var da={value:void 0,enumerable:!1},Xp="captureStackTrace"in Error?Error:null;function XA(e){let t=Xp;if(t){let n=t.stackTraceLimit;if(typeof n==="number"){try{t.stackTraceLimit=0}catch{return Xp=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function b(e,t,n,r){let i={};function s(d){this.def=d,this.constr=p,this.traits=new Set}s.prototype=i;let o=n,a=o&&new WeakSet;function c(d,h){if(!d._zod){da.value=new s(h);try{Object.defineProperty(d,"_zod",da)}finally{da.value=void 0}}else if(d._zod.traits.has(e))return;if(d._zod.traits.add(e),t(d,h),a){let m=Object.getPrototypeOf(d),g=d._zod.constr.prototype,w=m;while(w&&w!==g)w=Object.getPrototypeOf(w);let k=w??m;if(!a.has(k))a.add(k),Vp(k,o)}let f=p.prototype;for(let m in f){if(!Object.prototype.hasOwnProperty.call(f,m))continue;if(!(m in d))d[m]=f[m].bind(d)}}let l=r?.Parent??Object;class u extends l{}Object.defineProperty(u,"name",{value:e});function p(d){let h=r?.Parent?XA(u):this;c(h,d);let f=h._zod.deferred;if(f){for(let g of f)g();h._zod.deferred=void 0}let m=globalThis.__zod_globalConfig?.postProcessor;if(m)m(h);return h}return Object.defineProperty(p,"init",{value:c}),Object.defineProperty(p,Symbol.hasInstance,{value:(d)=>{if(r?.Parent&&d instanceof r.Parent)return!0;return d?._zod?.traits?.has(e)}}),Object.defineProperty(p,"name",{value:e}),p}class Ge extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class er extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`);this.name="ZodEncodeError"}}(Qp=globalThis).__zod_globalConfig??(Qp.__zod_globalConfig={});var le=globalThis.__zod_globalConfig;function ye(e){if(e)Object.assign(le,e);return le}function e$(){let e=this._zod;return e.message??(e.message=JSON.stringify(e.def,Jn,2)),e.message}function t$(e){this._zod.message=e}var n$={get:e$,set:t$,enumerable:!0,configurable:!0},fa={value:void 0,enumerable:!1},ed=new WeakSet([Object.prototype,Error.prototype]),td=(e,t)=>{e.name="$ZodError",fa.value=t,Object.defineProperty(e,"issues",fa),fa.value=void 0,Object.defineProperty(e,"message",n$);let n=Object.getPrototypeOf(e);if(!ed.has(n))ed.add(n),Object.defineProperty(n,"toString",{configurable:!0,enumerable:!1,get(){let r=()=>this.message;return Object.defineProperty(this,"toString",{value:r,configurable:!0,writable:!0}),r},set(r){Object.defineProperty(this,"toString",{value:r,configurable:!0,writable:!0})}})},nd=b("$ZodError",td),LR=b("$ZodError",td,void 0,{Parent:Error});function r$(e,t,n){if(!Object.prototype.hasOwnProperty.call(e,t))if(t==="__proto__")Object.defineProperty(e,t,{value:n(),writable:!0,enumerable:!0,configurable:!0});else e[t]=n();return e[t]}function rd(e,t=(n)=>n.message){let n={},r=[];for(let i of e.issues)if(i.path.length>0)r$(n,i.path[0],()=>[]).push(t(i));else r.push(t(i));return{formErrors:r,fieldErrors:n}}function id(e,t=(n)=>n.message){let n={_errors:[]},r=(i,s=[])=>{for(let o of i.issues)if(o.code==="invalid_union"&&o.errors.length)o.errors.map((a)=>r({issues:a},[...s,...o.path]));else if(o.code==="invalid_key")r({issues:o.issues},[...s,...o.path]);else if(o.code==="invalid_element")r({issues:o.issues},[...s,...o.path]);else{let a=[...s,...o.path];if(a.length===0)n._errors.push(t(o));else{let c=n,l=0;while(l<a.length){let u=a[l],p=l===a.length-1;if(u==="_errors"){if(p)c._errors.push(t(o));l++;continue}if(!Object.prototype.hasOwnProperty.call(c,u))Object.defineProperty(c,u,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let d=c[u];if(p)d._errors.push(t(o));c=d,l++}}}};return r(e),n}function Ii(e,t){return{callee:t?.callee??e,Err:t?.Err}}var Ni=(e)=>{let t=(n,r,i,s)=>{let o=i?{...i,async:!1}:{async:!1},a=n._zod.run({value:r,issues:[]},o);if(a instanceof Promise)throw new Ge;if(a.issues.length){let c=new(s?.Err??e)(a.issues.map((l)=>Ze(l,o,ye())));throw aa(c,s?.callee??t),c}return a.value};return t};var zi=(e)=>{let t=async(n,r,i,s)=>{let o=i?{...i,async:!0}:{async:!0},a=n._zod.run({value:r,issues:[]},o);if(a instanceof Promise)a=await a;if(a.issues.length){let c=new(s?.Err??e)(a.issues.map((l)=>Ze(l,o,ye())));throw aa(c,s?.callee??t),c}return a.value};return t};var ji=(e)=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},s=t._zod.run({value:n,issues:[]},i);if(s instanceof Promise)throw new Ge;return s.issues.length?sd(e,s.issues,i):{success:!0,data:s.value}};function sd(e,t,n){let r;return{success:!1,get error(){if(!r)r=new e(t.map((i)=>Ze(i,n,ye()))),t=void 0,n=void 0;return r},set error(i){r=i,t=void 0,n=void 0}}}var Di=(e)=>async(t,n,r)=>{let i=r?{...r,async:!0}:{async:!0},s=t._zod.run({value:n,issues:[]},i);if(s instanceof Promise)s=await s;return s.issues.length?sd(e,s.issues,i):{success:!0,data:s.value}};var i$=Symbol.for("zod.compile.invalid"),s$=Symbol.for("zod.compile.fallback"),ma=(e,t,n)=>{let r=e._zod.bag.validator;if(r!==void 0){if(r(t)!==i$)return!0;if(r.definite===!0&&n===void 0)return!1}return o$(e,t,n)};function o$(e,t,n){let r=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},i=e._zod.bag.fallbackRun,s;if(i)r[s$]=!0,s=i({value:t,issues:[]},r);else s=e._zod.run({value:t,issues:[]},r);if(s instanceof Promise)throw new Ge;return s.issues.length===0}var ga=async(e,t,n)=>{let r=n?{...n,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},i=e._zod.run({value:t,issues:[]},r);if(i instanceof Promise)i=await i;return i.issues.length===0},od=(e)=>{let t=Ni(e),n=(r,i,s,o)=>{let a=s?{...s,direction:"backward"}:{direction:"backward"};return t(r,i,a,Ii(n,o))};return n};var ad=(e)=>{let t=Ni(e),n=(r,i,s,o)=>t(r,i,s,Ii(n,o));return n};var cd=(e)=>{let t=zi(e),n=async(r,i,s,o)=>{let a=s?{...s,direction:"backward"}:{direction:"backward"};return await t(r,i,a,Ii(n,o))};return n};var ld=(e)=>{let t=zi(e),n=async(r,i,s,o)=>await t(r,i,s,Ii(n,o));return n};var ud=(e)=>(t,n,r)=>{let i=r?{...r,direction:"backward"}:{direction:"backward"};return ji(e)(t,n,i)};var pd=(e)=>(t,n,r)=>ji(e)(t,n,r);var dd=(e)=>async(t,n,r)=>{let i=r?{...r,direction:"backward"}:{direction:"backward"};return Di(e)(t,n,i)};var hd=(e)=>async(t,n,r)=>Di(e)(t,n,r);var fd=/^[cC][0-9a-z]{6,}$/,md=/^[0-9a-z]+$/,gd=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,vd=/^[0-9a-vA-V]{20}$/,yd=/^[A-Za-z0-9]{27}$/,bd=/^[a-zA-Z0-9_-]{21}$/;function wd(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var _d=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var kd=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,ya=(e)=>{if(!e)return/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`)};var xd=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var a$="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function Sd(){return new RegExp(a$,"u")}var Ad=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,$d=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/;var Pd=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,Td=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Ed=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Od=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/;var Cd=/^https?$/,Rd=/^\+[1-9]\d{6,14}$/;var Id="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))";function c$(e){return new RegExp(`^${e}$`)}var Nd=c$(Id);function va(e){return typeof e.precision==="number"?e.precision===-1?"(?:[01]\\d|2[0-3]):[0-5]\\d":e.precision===0?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d":`(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?":"(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?"}function zd(e){return new RegExp(`^${va(e)}$`)}function jd(e){let t=["Z"];if(e.offset)t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let n=`${va({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,r=e.local?`${n}|${va({precision:e.precision})}`:n;return new RegExp(`^${Id}T(?:${r})$`)}var Dd=/^[\s\S]{0,}$/;var ba=/^-?\d+$/,tr=/^-?\d+(?:\.\d+)?$/,Ld=/^(?:true|false)$/i;var Md=/^[^A-Z]*$/,Ud=/^[^a-z]*$/;var re=b("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])});var wa=(e)=>{let t=e.value;return!jp(t)&&t.length!==void 0},Li={number:"number",bigint:"bigint",object:"date"},_a=b("$ZodCheckLessThan",(e,t)=>{re.init(e,t);let n=Li[typeof t.value];e._zod.check=(r)=>{if(t.inclusive?r.value<=t.value:r.value<t.value)return;r.issues.push({origin:Li[typeof r.value]??n,code:"too_big",maximum:typeof t.value==="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),ka=b("$ZodCheckGreaterThan",(e,t)=>{re.init(e,t);let n=Li[typeof t.value];e._zod.check=(r)=>{if(t.inclusive?r.value>=t.value:r.value>t.value)return;r.issues.push({origin:Li[typeof r.value]??n,code:"too_small",minimum:typeof t.value==="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Zd=b("$ZodCheckMultipleOf",(e,t)=>{re.init(e,t),e._zod.check=(n)=>{if(typeof n.value!==typeof t.value)throw Error("Cannot mix number and bigint in multiple_of check.");if(typeof n.value==="bigint"?t.value!==BigInt(0)&&n.value%t.value===BigInt(0):Dp(n.value,t.value)===0)return;n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),Gd=b("$ZodCheckNumberFormat",(e,t)=>{re.init(e,t),t.format=t.format||"float64";let n=t.format?.includes("int"),r=n?"int":"number",[i,s]=Pi[t.format];e._zod.check=(o)=>{let a=o.value;if(n){if(!Number.isInteger(a)){o.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:a,inst:e});return}if(!Number.isSafeInteger(a)){if(a>0)o.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort});else o.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}if(a<i)o.issues.push({origin:"number",input:a,code:"too_small",minimum:i,inclusive:!0,inst:e,continue:!t.abort});if(a>s)o.issues.push({origin:"number",input:a,code:"too_big",maximum:s,inclusive:!0,inst:e,continue:!t.abort})}});var qd=b("$ZodCheckMaxLength",(e,t)=>{var n;re.init(e,t),(n=e._zod.def).when??(n.when=wa),e._zod.check=(r)=>{let i=r.value,s=i.length;if((typeof i==="string"&&s>t.maximum?Oi(i):s)<=t.maximum)return;let a=Ci(i);r.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),Bd=b("$ZodCheckMinLength",(e,t)=>{var n;re.init(e,t),(n=e._zod.def).when??(n.when=wa),e._zod.check=(r)=>{let i=r.value,s=i.length;if((typeof i==="string"&&s>=t.minimum&&s<t.minimum*2?Oi(i):s)>=t.minimum)return;let a=Ci(i);r.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),Hd=b("$ZodCheckLengthEquals",(e,t)=>{var n;re.init(e,t),(n=e._zod.def).when??(n.when=wa),e._zod.check=(r)=>{let i=r.value,s=i.length,o=typeof i==="string"&&s>=t.length&&s<=t.length*2?Oi(i):s;if(o===t.length)return;let a=Ci(i),c=o>t.length;r.issues.push({origin:a,...c?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),rr=b("$ZodCheckStringFormat",(e,t)=>{var n,r;if(re.init(e,t),t.pattern)(n=e._zod).check??(n.check=(i)=>{if(t.pattern.lastIndex=0,t.pattern.test(i.value))return;i.issues.push({origin:"string",code:"invalid_format",format:t.format,input:i.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})});else(r=e._zod).check??(r.check=()=>{})}),Fd=b("$ZodCheckRegex",(e,t)=>{rr.init(e,t),e._zod.check=(n)=>{if(t.pattern.lastIndex=0,t.pattern.test(n.value))return;n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Kd=b("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Md),rr.init(e,t)}),Wd=b("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Ud),rr.init(e,t)}),Vd=b("$ZodCheckIncludes",(e,t)=>{re.init(e,t);let n=wt(t.includes),r=new RegExp(typeof t.position==="number"?`^.{${t.position},}${n}`:n);t.pattern=r,e._zod.check=(i)=>{if(i.value.includes(t.includes,t.position))return;i.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:i.value,inst:e,continue:!t.abort})}}),Yd=b("$ZodCheckStartsWith",(e,t)=>{re.init(e,t);let n=new RegExp(`^${wt(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.check=(r)=>{if(r.value.startsWith(t.prefix))return;r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort})}}),Jd=b("$ZodCheckEndsWith",(e,t)=>{re.init(e,t);let n=new RegExp(`.*${wt(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.check=(r)=>{if(r.value.endsWith(t.suffix))return;r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort})}});var Qd=b("$ZodCheckOverwrite",(e,t)=>{re.init(e,t),e._zod.check=(n)=>{n.value=t.tx(n.value)}});class xa{constructor(e=[],t={}){this.content=[],this.indent=0,this.args=e,this.closed=t}indented(e){this.indent+=1;try{e(this)}finally{this.indent-=1}}write(e){if(typeof e==="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}let n=e.split(`
139
+ `,t)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;let t=xi(e),n=sn(t);return n.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:n,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;let t=xi(e),n=sn(t);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:n,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,t){if(this.type!=="comment")return!1;if(this.indent<=t)return!1;return e.every((n)=>n.type==="newline"||n.type==="space")}*documentEnd(e){if(this.type!=="doc-mode"){if(e.end)e.end.push(this.sourceToken);else e.end=[this.sourceToken];if(this.type==="newline")yield*this.pop()}}*lineEnd(e){switch(this.type){case"comma":case"doc-start":case"doc-end":case"flow-seq-end":case"flow-map-end":case"map-value-ind":yield*this.pop(),yield*this.step();break;case"newline":this.onKeyLine=!1;case"space":case"comment":default:if(e.end)e.end.push(this.sourceToken);else e.end=[this.sourceToken];if(this.type==="newline")yield*this.pop()}}}H1.Parser=Tp});var Ip=P(function(eA){var Ep=Fo(),K1=Gn(),Wn=qn(),W1=to(),V1=z(),Y1=na(),Op=ra();function Cp(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new Y1.LineCounter||null,prettyErrors:t}}function J1(e,t={}){let{lineCounter:n,prettyErrors:r}=Cp(t),i=new Op.Parser(n?.addNewLine),s=new Ep.Composer(t),o=Array.from(s.compose(i.parse(e)));if(r&&n)for(let a of o)a.errors.forEach(Wn.prettifyError(e,n)),a.warnings.forEach(Wn.prettifyError(e,n));if(o.length>0)return o;return Object.assign([],{empty:!0},s.streamInfo())}function Rp(e,t={}){let{lineCounter:n,prettyErrors:r}=Cp(t),i=new Op.Parser(n?.addNewLine),s=new Ep.Composer(t),o=null;for(let a of s.compose(i.parse(e),!0,e.length))if(!o)o=a;else if(o.options.logLevel!=="silent"){o.errors.push(new Wn.YAMLParseError(a.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}if(r&&n)o.errors.forEach(Wn.prettifyError(e,n)),o.warnings.forEach(Wn.prettifyError(e,n));return o}function Q1(e,t,n){let r=void 0;if(typeof t==="function")r=t;else if(n===void 0&&t&&typeof t==="object")n=t;let i=Rp(e,n);if(!i)return null;if(i.warnings.forEach((s)=>W1.warn(i.options.logLevel,s)),i.errors.length>0)if(i.options.logLevel!=="silent")throw i.errors[0];else i.errors=[];return i.toJS(Object.assign({reviver:r},n))}function X1(e,t,n){let r=null;if(typeof t==="function"||Array.isArray(t))r=t;else if(n===void 0&&t)n=t;if(typeof n==="string")n=n.length;if(typeof n==="number"){let i=Math.round(n);n=i<1?void 0:i>8?{indent:8}:{indent:i}}if(e===void 0){let{keepUndefined:i}=n??t??{};if(!i)return}if(V1.isDocument(e)&&!r)return e.toString(n);return new K1.Document(e,r,n).toString(n)}eA.parse=Q1;eA.parseAllDocuments=J1;eA.parseDocument=Rp;eA.stringify=X1});var zc={};Al(zc,{default:()=>XT});var Lc={};Al(Lc,{default:()=>tE});class v extends Error{reason;fix;constructor(e,t){super(e);this.reason=e;this.fix=t;this.name="TapsterError"}}class R extends v{status;constructor(e,t,n){super(e,t);this.status=n;this.name="GitHubError"}}import{existsSync as Pt,readdirSync as Sv,readFileSync as wv}from"fs";import{basename as Ar,join as te}from"path";var sA=Fo(),oA=Gn(),aA=Oo(),ia=qn(),cA=Tn(),gt=z(),lA=pt(),uA=W(),pA=ht(),dA=ft(),IR=_i(),hA=ta(),fA=na(),mA=ra(),Ai=Ip(),Np=$n();var gA=sA.Composer,vA=oA.Document,yA=aA.Schema,{YAMLError:bA,YAMLParseError:wA,YAMLWarning:_A}=ia,kA=cA.Alias,{isAlias:xA,isCollection:SA,isDocument:AA,isMap:Ae,isNode:$A,isPair:PA,isScalar:TA,isSeq:vt}=gt,EA=lA.Pair,OA=uA.Scalar,CA=pA.YAMLMap,RA=dA.YAMLSeq;var IA=hA.Lexer,NA=fA.LineCounter,zA=mA.Parser,{parse:ne,parseAllDocuments:LA,parseDocument:yt,stringify:jA}=Ai,{visit:DA,visitAsync:MA}=Np;function Yn(e){let t=Object.values(e).filter((r)=>typeof r==="number");return Object.entries(e).filter(([r,i])=>t.indexOf(+r)===-1).map(([r,i])=>i)}function oa(e,t="|"){return e.map((n)=>la(n)).join(t)}function Jn(e,t){if(typeof t==="bigint")return t.toString();return t}class zp{constructor(e){this._getter=e,this._value=void 0}get value(){let e=this._getter;if(e!==void 0)this._value=e(),this._getter=void 0;return this._value}}function Qn(e){return new zp(e)}function Lp(e){return e===null||e===void 0}function $i(e){let t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function jp(e,t){let n=e/t,r=Math.round(n),i=4*Number.EPSILON*Math.max(Math.abs(n),1);if(Math.abs(n-r)<i)return 0;return n-r}function ge(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Xn(e){let t=Object.getOwnPropertyDescriptor(e,"shape");return t?.get?t.get.raw:t?.value}function Xe(e){return Xn(e._zod.def)??e._zod.def.shape}function Dp(e,t,n){Object.defineProperty(e,t,{get(){let r=n();return ge(this,t,r),r},enumerable:!0,configurable:!0})}function Mp(e,t,n){if(t in e)ge(e,t,n);else e[t]=n}function Lt(e,t,n,r){let i=Xe(t);for(let s of n){let o=Object.getOwnPropertyDescriptor(i,s);if(!o.enumerable)continue;if(o.get)Dp(e,s,()=>{let a=t._zod.def.shape[s];return r?r(a,s):a});else Mp(e,s,r?r(o.value,s):o.value)}}function UA(e,t){for(let n of Reflect.ownKeys(t)){let r=Object.getOwnPropertyDescriptor(t,n);if(!r.enumerable)continue;if(r.get)Dp(e,n,()=>t[n]);else Mp(e,n,r.value)}}function ve(...e){let t={};for(let n of e){let r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function Up(e){return JSON.stringify(e)}function Zp(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var aa="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function on(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}var Gp=Qn(()=>{if(le.jitless)return!1;if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function jt(e){if(on(e)===!1)return!1;let t=e.constructor;if(t===void 0)return!0;if(typeof t!=="function")return!0;let n=t.prototype;if(on(n)===!1)return!1;if(Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)return!1;return!0}function ca(e){if(jt(e))return{...e};if(Array.isArray(e))return[...e];if(e instanceof Map)return new Map(e);if(e instanceof Set)return new Set(e);return e}var qp=new Set(["string","number","symbol"]);function wt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Me(e,t,n){let r=new e._zod.constr(t??e._zod.def);if(!t||n?.parent)r._zod.parent=e;return r}function T(e){let t=e;if(!t)return{};if(typeof t==="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}if(delete t.message,typeof t.error==="string")return{...t,error:()=>t.error};return t}function la(e){if(typeof e==="bigint")return e.toString()+"n";if(typeof e==="string")return`"${e}"`;return`${e}`}function Bp(e){return Object.keys(e).filter((t)=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}var Pi=(()=>({safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-340282346638528860000000000000000000000,340282346638528860000000000000000000000],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]}))(),ua={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function ZA(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(".pick() cannot be used on object schemas containing refinements");let s={};return Lt(s,e,Ti(e,t)),Me(e,ve(n,{shape:s,checks:[]}))}function Ti(e,t){let n=Xe(e),r=[];for(let i of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(n,i)?.enumerable)throw Error(`Unrecognized key: "${String(i)}"`);if(t[i])r.push(i)}return r}function GA(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(".omit() cannot be used on object schemas containing refinements");let s=new Set(Ti(e,t)),o={};return Lt(o,e,Reflect.ownKeys(Xe(e)).filter((a)=>!s.has(a))),Me(e,ve(n,{shape:o,checks:[]}))}function qA(e,t){if(!jt(t))throw Error("Invalid input to extend: expected a plain object");let n=e._zod.def.checks;if(n&&n.length>0){let i=Xe(e);for(let s of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(i,s)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return Me(e,ve(e._zod.def,{shape:Hp(e,t)}))}function Hp(e,t){let n={};return Lt(n,e,Reflect.ownKeys(Xe(e))),UA(n,t),n}function BA(e,t){if(!jt(t))throw Error("Invalid input to safeExtend: expected a plain object");return Me(e,ve(e._zod.def,{shape:Hp(e,t)}))}function HA(e,t){if(!t?._zod?.def)throw Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let n={};Lt(n,e,Reflect.ownKeys(Xe(e))),Lt(n,t,Reflect.ownKeys(Xe(t)));let r=ve(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return Me(e,r)}function Fp(e,t,n,r="partial"){let s=t._zod.def.checks;if(s&&s.length>0)throw Error(`.${r}() cannot be used on object schemas containing refinements`);let a=n?new Set(Ti(t,n)):void 0,c={};return Lt(c,t,Reflect.ownKeys(Xe(t)),e&&((l,u)=>a&&!a.has(u)?l:new e({type:"optional",innerType:l}))),Me(t,ve(t._zod.def,{shape:c,checks:[]}))}function FA(e,t,n){let r=n?new Set(Ti(t,n)):void 0,i={};return Lt(i,t,Reflect.ownKeys(Xe(t)),(s,o)=>r&&!r.has(o)?s:new e({type:"nonoptional",innerType:s})),Me(t,ve(t._zod.def,{shape:i}))}function $e(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function Kp(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function Ue(e,t){return t.map((n)=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function Vn(e){return typeof e==="string"?e:e?.message}function pa(e){let t=[];for(let n of e??[]){let r=n._zod.def;if(!/_(length|size)$|_equals$/.test(r.check))break;let i=r.maximum??r.length??r.size;if(i>=0)t.push([i,n])}return t}function Ei(e,t,n){var r;for(let i=t;i<e.length;i++)(r=e[i]).schema??(r.schema=n)}function Ze(e,t,n){var r;let i=e.inst?._zod?.traits;if(i?.has("$ZodType"))if(i.has("$ZodCheck"))(r=e).schema??(r.schema=e.inst);else e.schema=e.inst;let s=e.schema!==e.inst?e.schema?._zod.def?.error:void 0,o=e.message?e.message:Vn(e.inst?._zod.def?.error?.(e))??Vn(s?.(e))??Vn(t?.error?.(e))??Vn(n.customError?.(e))??Vn(n.localeError?.(e))??"Invalid input",a={};for(let c of Object.keys(e)){if(c==="inst"||c==="schema"||c==="continue"||c==="input"||c==="__proto__")continue;a[c]=e[c]}if(a.path??(a.path=[]),a.message=o,t?.reportInput)a.input=e.input;return a}var KA=/[\uD800-\uDBFF]/;function Oi(e){let t=e.length;if(!KA.test(e))return t;let n=t;for(let r=0;r<t-1;r++)if((e.charCodeAt(r)&64512)===55296&&(e.charCodeAt(r+1)&64512)===56320)n--,r++;return n}function Ci(e){if(Array.isArray(e))return"array";if(typeof e==="string")return"string";return"unknown"}function Wp(e){let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(e===null)return"null";if(Array.isArray(e))return"array";let n=e;if(n&&Object.getPrototypeOf(n)!==Object.prototype&&"constructor"in n&&n.constructor)return n.constructor.name}}return t}function Dt(...e){let[t,n,r]=e;if(typeof t==="string")return{message:t,code:"custom",input:n,inst:r};return{...t}}function Vp(e,t){for(let n in t){let r=Object.getOwnPropertyDescriptor(t,n);if(r.get)Object.defineProperty(e,n,{...r,enumerable:!1});else WA(e,n,r.value)}}function et(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function Ri(e,t,n){return et(e,t,n,!1)}function Yp(e,t){for(let n in e){let r=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return et(this,n,r(this))},set(i){et(this,n,i)}})}return t}function WA(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:et(this,t,n.bind(this))},set(r){et(this,t,r)}})}function VA(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}var sa,bt=!1,YA={configurable:!0,get(){bt=!0;return}};function L(e,t,n){let r=Object.getPrototypeOf(e._zod);if(t in r&&sa!==e._zod){sa=void 0;return}sa=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,YA);let i=bt;bt=!1;try{let s=n(this);if(bt)delete this[t];else Object.defineProperty(this,t,{configurable:!0,writable:!0,value:s});return bt=bt||i,s}catch(s){throw delete this[t],bt=bt||i,s}},set(i){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:i})}})}function JA(e,t,n,r){let i=VA(e,t);if(!i)return;Object.defineProperty(i,t,{configurable:!0,get(){let s={configurable:!0,writable:!0,enumerable:r,value:void 0};return Object.defineProperty(this,t,s),s.value=n(this),Object.defineProperty(this,t,s),s.value},set(s){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:r,value:s})}})}var QA="~constantCatch";function Jp(e){let t=()=>e;return t[QA]=!0,t}var Qp;var da={value:void 0,enumerable:!1},Xp="captureStackTrace"in Error?Error:null;function XA(e){let t=Xp;if(t){let n=t.stackTraceLimit;if(typeof n==="number"){try{t.stackTraceLimit=0}catch{return Xp=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function b(e,t,n,r){let i={};function s(d){this.def=d,this.constr=p,this.traits=new Set}s.prototype=i;let o=n,a=o&&new WeakSet;function c(d,h){if(!d._zod){da.value=new s(h);try{Object.defineProperty(d,"_zod",da)}finally{da.value=void 0}}else if(d._zod.traits.has(e))return;if(d._zod.traits.add(e),t(d,h),a){let m=Object.getPrototypeOf(d),g=d._zod.constr.prototype,w=m;while(w&&w!==g)w=Object.getPrototypeOf(w);let k=w??m;if(!a.has(k))a.add(k),Vp(k,o)}let f=p.prototype;for(let m in f){if(!Object.prototype.hasOwnProperty.call(f,m))continue;if(!(m in d))d[m]=f[m].bind(d)}}let l=r?.Parent??Object;class u extends l{}Object.defineProperty(u,"name",{value:e});function p(d){let h=r?.Parent?XA(u):this;c(h,d);let f=h._zod.deferred;if(f){for(let g of f)g();h._zod.deferred=void 0}let m=globalThis.__zod_globalConfig?.postProcessor;if(m)m(h);return h}return Object.defineProperty(p,"init",{value:c}),Object.defineProperty(p,Symbol.hasInstance,{value:(d)=>{if(r?.Parent&&d instanceof r.Parent)return!0;return d?._zod?.traits?.has(e)}}),Object.defineProperty(p,"name",{value:e}),p}class Ge extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class er extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`);this.name="ZodEncodeError"}}(Qp=globalThis).__zod_globalConfig??(Qp.__zod_globalConfig={});var le=globalThis.__zod_globalConfig;function ye(e){if(e)Object.assign(le,e);return le}function e$(){let e=this._zod;return e.message??(e.message=JSON.stringify(e.def,Jn,2)),e.message}function t$(e){this._zod.message=e}var n$={get:e$,set:t$,enumerable:!0,configurable:!0},fa={value:void 0,enumerable:!1},ed=new WeakSet([Object.prototype,Error.prototype]),td=(e,t)=>{e.name="$ZodError",fa.value=t,Object.defineProperty(e,"issues",fa),fa.value=void 0,Object.defineProperty(e,"message",n$);let n=Object.getPrototypeOf(e);if(!ed.has(n))ed.add(n),Object.defineProperty(n,"toString",{configurable:!0,enumerable:!1,get(){let r=()=>this.message;return Object.defineProperty(this,"toString",{value:r,configurable:!0,writable:!0}),r},set(r){Object.defineProperty(this,"toString",{value:r,configurable:!0,writable:!0})}})},nd=b("$ZodError",td),DR=b("$ZodError",td,void 0,{Parent:Error});function r$(e,t,n){if(!Object.prototype.hasOwnProperty.call(e,t))if(t==="__proto__")Object.defineProperty(e,t,{value:n(),writable:!0,enumerable:!0,configurable:!0});else e[t]=n();return e[t]}function rd(e,t=(n)=>n.message){let n={},r=[];for(let i of e.issues)if(i.path.length>0)r$(n,i.path[0],()=>[]).push(t(i));else r.push(t(i));return{formErrors:r,fieldErrors:n}}function id(e,t=(n)=>n.message){let n={_errors:[]},r=(i,s=[])=>{for(let o of i.issues)if(o.code==="invalid_union"&&o.errors.length)o.errors.map((a)=>r({issues:a},[...s,...o.path]));else if(o.code==="invalid_key")r({issues:o.issues},[...s,...o.path]);else if(o.code==="invalid_element")r({issues:o.issues},[...s,...o.path]);else{let a=[...s,...o.path];if(a.length===0)n._errors.push(t(o));else{let c=n,l=0;while(l<a.length){let u=a[l],p=l===a.length-1;if(u==="_errors"){if(p)c._errors.push(t(o));l++;continue}if(!Object.prototype.hasOwnProperty.call(c,u))Object.defineProperty(c,u,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let d=c[u];if(p)d._errors.push(t(o));c=d,l++}}}};return r(e),n}function Ii(e,t){return{callee:t?.callee??e,Err:t?.Err}}var Ni=(e)=>{let t=(n,r,i,s)=>{let o=i?{...i,async:!1}:{async:!1},a=n._zod.run({value:r,issues:[]},o);if(a instanceof Promise)throw new Ge;if(a.issues.length){let c=new(s?.Err??e)(a.issues.map((l)=>Ze(l,o,ye())));throw aa(c,s?.callee??t),c}return a.value};return t};var zi=(e)=>{let t=async(n,r,i,s)=>{let o=i?{...i,async:!0}:{async:!0},a=n._zod.run({value:r,issues:[]},o);if(a instanceof Promise)a=await a;if(a.issues.length){let c=new(s?.Err??e)(a.issues.map((l)=>Ze(l,o,ye())));throw aa(c,s?.callee??t),c}return a.value};return t};var Li=(e)=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},s=t._zod.run({value:n,issues:[]},i);if(s instanceof Promise)throw new Ge;return s.issues.length?sd(e,s.issues,i):{success:!0,data:s.value}};function sd(e,t,n){let r;return{success:!1,get error(){if(!r)r=new e(t.map((i)=>Ze(i,n,ye()))),t=void 0,n=void 0;return r},set error(i){r=i,t=void 0,n=void 0}}}var ji=(e)=>async(t,n,r)=>{let i=r?{...r,async:!0}:{async:!0},s=t._zod.run({value:n,issues:[]},i);if(s instanceof Promise)s=await s;return s.issues.length?sd(e,s.issues,i):{success:!0,data:s.value}};var i$=Symbol.for("zod.compile.invalid"),s$=Symbol.for("zod.compile.fallback"),ma=(e,t,n)=>{let r=e._zod.bag.validator;if(r!==void 0){if(r(t)!==i$)return!0;if(r.definite===!0&&n===void 0)return!1}return o$(e,t,n)};function o$(e,t,n){let r=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},i=e._zod.bag.fallbackRun,s;if(i)r[s$]=!0,s=i({value:t,issues:[]},r);else s=e._zod.run({value:t,issues:[]},r);if(s instanceof Promise)throw new Ge;return s.issues.length===0}var ga=async(e,t,n)=>{let r=n?{...n,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},i=e._zod.run({value:t,issues:[]},r);if(i instanceof Promise)i=await i;return i.issues.length===0},od=(e)=>{let t=Ni(e),n=(r,i,s,o)=>{let a=s?{...s,direction:"backward"}:{direction:"backward"};return t(r,i,a,Ii(n,o))};return n};var ad=(e)=>{let t=Ni(e),n=(r,i,s,o)=>t(r,i,s,Ii(n,o));return n};var cd=(e)=>{let t=zi(e),n=async(r,i,s,o)=>{let a=s?{...s,direction:"backward"}:{direction:"backward"};return await t(r,i,a,Ii(n,o))};return n};var ld=(e)=>{let t=zi(e),n=async(r,i,s,o)=>await t(r,i,s,Ii(n,o));return n};var ud=(e)=>(t,n,r)=>{let i=r?{...r,direction:"backward"}:{direction:"backward"};return Li(e)(t,n,i)};var pd=(e)=>(t,n,r)=>Li(e)(t,n,r);var dd=(e)=>async(t,n,r)=>{let i=r?{...r,direction:"backward"}:{direction:"backward"};return ji(e)(t,n,i)};var hd=(e)=>async(t,n,r)=>ji(e)(t,n,r);var fd=/^[cC][0-9a-z]{6,}$/,md=/^[0-9a-z]+$/,gd=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,vd=/^[0-9a-vA-V]{20}$/,yd=/^[A-Za-z0-9]{27}$/,bd=/^[a-zA-Z0-9_-]{21}$/;function wd(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var _d=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var kd=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,ya=(e)=>{if(!e)return/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`)};var xd=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var a$="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function Sd(){return new RegExp(a$,"u")}var Ad=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,$d=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/;var Pd=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,Td=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Ed=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Od=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/;var Cd=/^https?$/,Rd=/^\+[1-9]\d{6,14}$/;var Id="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))";function c$(e){return new RegExp(`^${e}$`)}var Nd=c$(Id);function va(e){return typeof e.precision==="number"?e.precision===-1?"(?:[01]\\d|2[0-3]):[0-5]\\d":e.precision===0?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d":`(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?":"(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?"}function zd(e){return new RegExp(`^${va(e)}$`)}function Ld(e){let t=["Z"];if(e.offset)t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let n=`${va({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,r=e.local?`${n}|${va({precision:e.precision})}`:n;return new RegExp(`^${Id}T(?:${r})$`)}var jd=/^[\s\S]{0,}$/;var ba=/^-?\d+$/,tr=/^-?\d+(?:\.\d+)?$/,Dd=/^(?:true|false)$/i;var Md=/^[^A-Z]*$/,Ud=/^[^a-z]*$/;var re=b("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])});var wa=(e)=>{let t=e.value;return!Lp(t)&&t.length!==void 0},Di={number:"number",bigint:"bigint",object:"date"},_a=b("$ZodCheckLessThan",(e,t)=>{re.init(e,t);let n=Di[typeof t.value];e._zod.check=(r)=>{if(t.inclusive?r.value<=t.value:r.value<t.value)return;r.issues.push({origin:Di[typeof r.value]??n,code:"too_big",maximum:typeof t.value==="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),ka=b("$ZodCheckGreaterThan",(e,t)=>{re.init(e,t);let n=Di[typeof t.value];e._zod.check=(r)=>{if(t.inclusive?r.value>=t.value:r.value>t.value)return;r.issues.push({origin:Di[typeof r.value]??n,code:"too_small",minimum:typeof t.value==="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Zd=b("$ZodCheckMultipleOf",(e,t)=>{re.init(e,t),e._zod.check=(n)=>{if(typeof n.value!==typeof t.value)throw Error("Cannot mix number and bigint in multiple_of check.");if(typeof n.value==="bigint"?t.value!==BigInt(0)&&n.value%t.value===BigInt(0):jp(n.value,t.value)===0)return;n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),Gd=b("$ZodCheckNumberFormat",(e,t)=>{re.init(e,t),t.format=t.format||"float64";let n=t.format?.includes("int"),r=n?"int":"number",[i,s]=Pi[t.format];e._zod.check=(o)=>{let a=o.value;if(n){if(!Number.isInteger(a)){o.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:a,inst:e});return}if(!Number.isSafeInteger(a)){if(a>0)o.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort});else o.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}if(a<i)o.issues.push({origin:"number",input:a,code:"too_small",minimum:i,inclusive:!0,inst:e,continue:!t.abort});if(a>s)o.issues.push({origin:"number",input:a,code:"too_big",maximum:s,inclusive:!0,inst:e,continue:!t.abort})}});var qd=b("$ZodCheckMaxLength",(e,t)=>{var n;re.init(e,t),(n=e._zod.def).when??(n.when=wa),e._zod.check=(r)=>{let i=r.value,s=i.length;if((typeof i==="string"&&s>t.maximum?Oi(i):s)<=t.maximum)return;let a=Ci(i);r.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),Bd=b("$ZodCheckMinLength",(e,t)=>{var n;re.init(e,t),(n=e._zod.def).when??(n.when=wa),e._zod.check=(r)=>{let i=r.value,s=i.length;if((typeof i==="string"&&s>=t.minimum&&s<t.minimum*2?Oi(i):s)>=t.minimum)return;let a=Ci(i);r.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),Hd=b("$ZodCheckLengthEquals",(e,t)=>{var n;re.init(e,t),(n=e._zod.def).when??(n.when=wa),e._zod.check=(r)=>{let i=r.value,s=i.length,o=typeof i==="string"&&s>=t.length&&s<=t.length*2?Oi(i):s;if(o===t.length)return;let a=Ci(i),c=o>t.length;r.issues.push({origin:a,...c?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),rr=b("$ZodCheckStringFormat",(e,t)=>{var n,r;if(re.init(e,t),t.pattern)(n=e._zod).check??(n.check=(i)=>{if(t.pattern.lastIndex=0,t.pattern.test(i.value))return;i.issues.push({origin:"string",code:"invalid_format",format:t.format,input:i.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})});else(r=e._zod).check??(r.check=()=>{})}),Fd=b("$ZodCheckRegex",(e,t)=>{rr.init(e,t),e._zod.check=(n)=>{if(t.pattern.lastIndex=0,t.pattern.test(n.value))return;n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Kd=b("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Md),rr.init(e,t)}),Wd=b("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Ud),rr.init(e,t)}),Vd=b("$ZodCheckIncludes",(e,t)=>{re.init(e,t);let n=wt(t.includes),r=new RegExp(typeof t.position==="number"?`^.{${t.position},}${n}`:n);t.pattern=r,e._zod.check=(i)=>{if(i.value.includes(t.includes,t.position))return;i.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:i.value,inst:e,continue:!t.abort})}}),Yd=b("$ZodCheckStartsWith",(e,t)=>{re.init(e,t);let n=new RegExp(`^${wt(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.check=(r)=>{if(r.value.startsWith(t.prefix))return;r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort})}}),Jd=b("$ZodCheckEndsWith",(e,t)=>{re.init(e,t);let n=new RegExp(`.*${wt(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.check=(r)=>{if(r.value.endsWith(t.suffix))return;r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort})}});var Qd=b("$ZodCheckOverwrite",(e,t)=>{re.init(e,t),e._zod.check=(n)=>{n.value=t.tx(n.value)}});class xa{constructor(e=[],t={}){this.content=[],this.indent=0,this.args=e,this.closed=t}indented(e){this.indent+=1;try{e(this)}finally{this.indent-=1}}write(e){if(typeof e==="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}let n=e.split(`
140
140
  `).filter((s)=>s),r=Math.min(...n.map((s)=>s.length-s.trimStart().length)),i=n.map((s)=>s.slice(r)).map((s)=>" ".repeat(this.indent*2)+s);for(let s of i)this.content.push(s)}compile(){let e=Function,t=this?.content??[""];return new e(...Object.keys(this.closed),`return function (${this.args.join(", ")}) {
141
141
  ${t.join(`
142
142
  `)}
143
- };`)(...Object.values(this.closed))}}var eh={major:4,minor:6,patch:7};var Z=b("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=eh;let r=e._zod.def.checks,i=e._zod.traits.has("$ZodCheck")?[e,...r??[]]:r?.length?[...r]:[];for(let s of i)for(let o of s._zod.onattach)o(e);if(i.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let s=(a,c,l)=>{if(a.memo)return a;let u=$e(a),p;for(let d of c){if(d._zod.def.when){if(Kp(a))continue;if(!d._zod.def.when(a))continue}else if(u)continue;let h=a.issues.length,f=d._zod.check(a);if(f instanceof Promise&&l?.async===!1)throw new Ge;if(p||f instanceof Promise)p=(p??Promise.resolve()).then(async()=>{if(await f,a.issues.length===h)return;if(Ei(a.issues,h,e),!u)u=$e(a,h)});else{if(a.issues.length===h)continue;if(Ei(a.issues,h,e),!u)u=$e(a,h)}}if(p)return p.then(()=>a);return a},o=(a,c,l)=>{if($e(a))return a.aborted=!0,a;let u=s(c,i,l);if(u instanceof Promise){if(l.async===!1)throw new Ge;return u.then((p)=>e._zod.parse(p,l))}return e._zod.parse(u,l)};e._zod.run=(a,c)=>{if(c.skipChecks)return e._zod.parse(a,c);if(c.direction==="backward"){let u=e._zod.parse({value:a.value,issues:[]},{...c,skipChecks:!0});if(u instanceof Promise)return u.then((p)=>o(p,a,c));return o(u,a,c)}let l=e._zod.parse(a,c);if(l instanceof Promise){if(c.async===!1)throw new Ge;return l.then((u)=>s(u,i,c))}return s(l,i,c)}}},{get "~standard"(){return Ri(this,"~standard",Aa(this))},set "~standard"(e){et(this,"~standard",e)}}),fh=(e,t)=>e.issues.length?{issues:e.issues.map((n)=>Ze(n,t,ye()))}:{value:e.value};async function l$(e,t){let n={async:!0};return fh(await e._zod.run({value:t,issues:[]},n),n)}function Aa(e){return{validate:(t)=>{let n={async:!1};try{let r=e._zod.run({value:t,issues:[]},n);if(!(r instanceof Promise))return fh(r,n)}catch(r){}return l$(e,t)},vendor:"zod",version:1}}var Gi=b("$ZodString",(e,t)=>{Z.init(e,t),e._zod.pattern=t.pattern??Dd,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch(i){}if(typeof n.value==="string")return n;return n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),G=b("$ZodStringFormat",(e,t)=>{rr.init(e,t),Gi.init(e,t)}),mh=b("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=kd),G.init(e,t)}),gh=b("$ZodUUID",(e,t)=>{if(t.version){let r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(r===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=ya(r))}else t.pattern??(t.pattern=ya());G.init(e,t)}),vh=b("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=xd),G.init(e,t)}),yh=1,Ui=2;function bh(e){try{if(typeof URL<"u"&&typeof URL.canParse==="function")return URL.canParse(e);return new URL(e),!0}catch{return!1}}function u$(e,t){if(!("normalize"in t)&&!("hostname"in t)&&!("protocol"in t))return bh(e)||Ui;return p$(e,t)}function p$(e,t){if(!t.normalize&&t.protocol?.source===Cd.source&&!/^https?:\/\//i.test(e))return yh;try{if(typeof URL<"u"){let n=URL;if(typeof n.parse==="function")return n.parse(e)??Ui}return new URL(e)}catch{return Ui}}var d$=/[\t\n\r]/g;function th(e){return e.replace(d$,"")}function h$(e,t){return t.lastIndex=0,t.test(e.hostname)}function f$(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}var wh=b("$ZodURL",(e,t)=>{G.init(e,t),e._zod.check=(n)=>{try{let r=n.value.trim(),i=u$(r,t);if(i===yh){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});return}if(i===Ui){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort});return}if(i===!0){n.value=th(r);return}if(t.hostname&&!h$(i,t.hostname))n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort});if(t.protocol&&!f$(i,t.protocol))n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort});n.value=t.normalize?i.href:th(r);return}catch(r){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),_h=b("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Sd()),G.init(e,t)}),kh=b("$ZodNanoID",(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw Error(`Invalid nanoid length: ${t.length}`);t.pattern??(t.pattern=t.length===void 0?bd:wd(t.length)),G.init(e,t)}),xh=b("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=fd),G.init(e,t)}),Sh=b("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=md),G.init(e,t)}),Ah=b("$ZodULID",(e,t)=>{t.pattern??(t.pattern=gd),G.init(e,t)}),$h=b("$ZodXID",(e,t)=>{t.pattern??(t.pattern=vd),G.init(e,t)}),Ph=b("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=yd),G.init(e,t)}),Th=b("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=jd(t)),G.init(e,t)}),Eh=b("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Nd),G.init(e,t)}),Oh=b("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=zd(t)),G.init(e,t)}),Ch=b("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=_d),G.init(e,t)}),Rh=b("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Ad),G.init(e,t)}),m$=/^[0-9a-fA-F:.]+$/;function Ih(e){if(!m$.test(e))return!1;return bh(`http://[${e}]`)}var Nh=b("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=$d),G.init(e,t),e._zod.check=(n)=>{if(!Ih(n.value))n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}});var zh=b("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Pd),G.init(e,t)});function g$(e){let t=e.split("/");if(t.length!==2)return!1;let[n,r]=t;if(!r)return!1;let i=Number(r);if(`${i}`!==r)return!1;if(i<0||i>128)return!1;return Ih(n)}var jh=b("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Td),G.init(e,t),e._zod.check=(n)=>{if(!g$(n.value))n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}});function Dh(e){if(e==="")return!0;if(/\s/.test(e))return!1;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var $a=/^[0-9a-zA-Z+/]*={0,2}$/,Lh=b("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=$a),G.init(e,t),e._zod.check=(n)=>{if(Dh(n.value))return;n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}}),qi=/^[A-Za-z0-9_-]*$/;function v$(e){if(!qi.test(e))return!1;let t=e.replace(/[-_]/g,(r)=>r==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return Dh(n)}var Mh=b("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=qi),G.init(e,t),e._zod.check=(n)=>{if(v$(n.value))return;n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),Uh=b("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Rd),G.init(e,t)});function y$(e,t=null){try{let n=e.split(".");if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));if("typ"in i&&i?.typ!=="JWT")return!1;if(!i.alg)return!1;if(t&&(!("alg"in i)||i.alg!==t))return!1;return!0}catch{return!1}}var Zh=b("$ZodJWT",(e,t)=>{G.init(e,t),e._zod.check=(n)=>{if(y$(n.value,t.alg))return;n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}});var Pa=b("$ZodNumber",(e,t)=>{Z.init(e,t),e._zod.pattern=tr,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch(o){}let i=n.value;if(typeof i==="number"&&!Number.isNaN(i)&&Number.isFinite(i))return n;let s=typeof i==="number"?Number.isNaN(i)?"NaN":!Number.isFinite(i)?String(i):void 0:void 0;return n.issues.push({expected:"number",code:"invalid_type",input:i,inst:e,...s?{received:s}:{}}),n}}),Gh=b("$ZodNumberFormat",(e,t)=>{Gd.init(e,t),Pa.init(e,t)}),qh=b("$ZodBoolean",(e,t)=>{Z.init(e,t),e._zod.pattern=Ld,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Boolean(n.value)}catch(s){}let i=n.value;if(typeof i==="boolean")return n;return n.issues.push({expected:"boolean",code:"invalid_type",input:i,inst:e}),n}});var Bh=b("$ZodUnknown",(e,t)=>{Z.init(e,t),e._zod.parse=(n)=>n}),Hh=b("$ZodNever",(e,t)=>{Z.init(e,t),e._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function b$(e,t){let n=pa(e._zod.def.checks);if(!n.length)return;let r=Math.min(...n.map((s)=>s[0])),i=e._zod.parse;e._zod.parse=(s,o)=>{let a=t(s.value);if(a>r&&!o?.skipChecks&&o?.direction!=="backward"){for(let[c,l]of pa(e._zod.def.checks))if(a>c&&l._zod.def.when(s)){let u=s.issues.length;return l._zod.check(s),s.issues[u].continue=!1,Ei(s.issues,u,e),s}}return i(s,o)}}var w$=(e)=>Array.isArray(e)?e.length:-1;function nh(e,t,n){if(e.issues.length)t.issues.push(...Ue(n,e.issues));t.value[n]=e.value}var Fh=b("$ZodArray",(e,t)=>{Z.init(e,t);let n=le.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let s=r.value;if(!Array.isArray(s))return r.issues.push({expected:"array",code:"invalid_type",input:s,inst:e}),r;r.value=n?n.alloc(e,r,Array(s.length),i):Array(s.length);let o=[],a=i?.abortEarly;for(let c=0;c<s.length;c++){let l=s[c],u=t.element._zod.run({value:l,issues:[]},i);if(u instanceof Promise)o.push(u.then((p)=>nh(p,r,c)));else if(nh(u,r,c),a&&u.issues.length!==0&&$e(u))break}if(o.length)return Promise.all(o).then(()=>r);return r},b$(e,w$)});function Zi(e,t,n,r,i,s){let o=n in r,a=s==="optional";if(!o&&a&&i==="optional")return;if(e.issues.length){if(i!==void 0&&a&&!o)return;t.issues.push(...Ue(n,e.issues))}if(!o&&i===void 0){if(!e.issues.length)t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]});return}if(e.value===void 0){if(o||i==="defaulted"&&!a)t.value[n]=void 0}else t.value[n]=e.value}var _$=[];function Kh(e){let t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:_$,i=r.length?[...t,...r]:t;for(let o of i)if(!e.shape?.[o]?._zod?.traits?.has("$ZodType"))throw Error(`Invalid element at key "${String(o)}": expected a Zod schema`);let s=Bp(e.shape);return{...e,allKeys:i,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(s)}}function Wh(e,t,n,r,i,s,o){let a=[],c=i.keySet,l=i.catchall._zod,u=l.def.type,{optin:p,optout:d}=l,h=0;for(let f in t){if(o&&n.issues.length!==h){if($e(n,h))break;h=n.issues.length}if(c.has(f))continue;if(f==="__proto__"){if(u==="never")a.push(f);continue}if(u==="never"){a.push(f);continue}let m=l.run({value:t[f],issues:[]},r);if(m instanceof Promise)e.push(m.then((g)=>Zi(g,n,f,t,p,d)));else Zi(m,n,f,t,p,d)}if(a.length)n.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:s,continue:!0});if(!e.length)return n;return Promise.all(e).then(()=>n)}var k$=b("$ZodObject",(e,t)=>{Z.init(e,t);let n=Object.getOwnPropertyDescriptor(t,"shape"),r=n?.get?n.get.raw:t.shape??{};if(r){let l=()=>{let u={...r};return Object.defineProperty(t,"shape",{value:u}),l.raw=u,u};l.raw=r,Object.defineProperty(t,"shape",{get:l})}let i=Qn(()=>Kh(t));j(e,"propValues",(l)=>{let u=l.def.shape,p={};for(let d in u){let h=u[d]._zod;if(h.values){if(!Object.prototype.hasOwnProperty.call(p,d))ge(p,d,new Set);for(let f of h.values)p[d].add(f);if(h.optin!==void 0)p[d].add(void 0)}}return p});let s=on,o=t.catchall,a,c=le.memoizer;c?.attach(e),e._zod.parse=(l,u)=>{a??(a=i.value);let p=l.value;if(!s(p))return l.issues.push({expected:"object",code:"invalid_type",input:p,inst:e}),l;l.value=c?c.alloc(e,l,{},u):{};let d=[],h=a.shape,f=u?.abortEarly,m=l.issues.length;for(let g of a.allKeys){if(f&&l.issues.length!==m){if($e(l,m))break;m=l.issues.length}if(g==="__proto__")continue;let w=h[g],k=w._zod.optin,_=w._zod.optout,y=w._zod.run({value:p[g],issues:[]},u);if(y instanceof Promise)d.push(y.then((x)=>Zi(x,l,g,p,k,_)));else Zi(y,l,g,p,k,_)}if(!o)return d.length?Promise.all(d).then(()=>l):l;return Wh(d,p,l,u,i.value,e,f===!0)}}),Vh=b("$ZodObjectJIT",(e,t)=>{k$.init(e,t);let n=e._zod.parse,r=Qn(()=>Kh(t)),i=le.memoizer,s=(h)=>{let f=r.value,m=f.symbolKeys,g=new xa(["payload","ctx"],{shape:h,inst:e,memo:i,syms:m}),w=(x)=>`shape[${x}]._zod.run({ value: input[${x}], issues: [] }, ctx)`,k=(x,S)=>`
143
+ };`)(...Object.values(this.closed))}}var eh={major:4,minor:6,patch:7};var Z=b("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=eh;let r=e._zod.def.checks,i=e._zod.traits.has("$ZodCheck")?[e,...r??[]]:r?.length?[...r]:[];for(let s of i)for(let o of s._zod.onattach)o(e);if(i.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let s=(a,c,l)=>{if(a.memo)return a;let u=$e(a),p;for(let d of c){if(d._zod.def.when){if(Kp(a))continue;if(!d._zod.def.when(a))continue}else if(u)continue;let h=a.issues.length,f=d._zod.check(a);if(f instanceof Promise&&l?.async===!1)throw new Ge;if(p||f instanceof Promise)p=(p??Promise.resolve()).then(async()=>{if(await f,a.issues.length===h)return;if(Ei(a.issues,h,e),!u)u=$e(a,h)});else{if(a.issues.length===h)continue;if(Ei(a.issues,h,e),!u)u=$e(a,h)}}if(p)return p.then(()=>a);return a},o=(a,c,l)=>{if($e(a))return a.aborted=!0,a;let u=s(c,i,l);if(u instanceof Promise){if(l.async===!1)throw new Ge;return u.then((p)=>e._zod.parse(p,l))}return e._zod.parse(u,l)};e._zod.run=(a,c)=>{if(c.skipChecks)return e._zod.parse(a,c);if(c.direction==="backward"){let u=e._zod.parse({value:a.value,issues:[]},{...c,skipChecks:!0});if(u instanceof Promise)return u.then((p)=>o(p,a,c));return o(u,a,c)}let l=e._zod.parse(a,c);if(l instanceof Promise){if(c.async===!1)throw new Ge;return l.then((u)=>s(u,i,c))}return s(l,i,c)}}},{get "~standard"(){return Ri(this,"~standard",Aa(this))},set "~standard"(e){et(this,"~standard",e)}}),fh=(e,t)=>e.issues.length?{issues:e.issues.map((n)=>Ze(n,t,ye()))}:{value:e.value};async function l$(e,t){let n={async:!0};return fh(await e._zod.run({value:t,issues:[]},n),n)}function Aa(e){return{validate:(t)=>{let n={async:!1};try{let r=e._zod.run({value:t,issues:[]},n);if(!(r instanceof Promise))return fh(r,n)}catch(r){}return l$(e,t)},vendor:"zod",version:1}}var Gi=b("$ZodString",(e,t)=>{Z.init(e,t),e._zod.pattern=t.pattern??jd,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch(i){}if(typeof n.value==="string")return n;return n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),G=b("$ZodStringFormat",(e,t)=>{rr.init(e,t),Gi.init(e,t)}),mh=b("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=kd),G.init(e,t)}),gh=b("$ZodUUID",(e,t)=>{if(t.version){let r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(r===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=ya(r))}else t.pattern??(t.pattern=ya());G.init(e,t)}),vh=b("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=xd),G.init(e,t)}),yh=1,Ui=2;function bh(e){try{if(typeof URL<"u"&&typeof URL.canParse==="function")return URL.canParse(e);return new URL(e),!0}catch{return!1}}function u$(e,t){if(!("normalize"in t)&&!("hostname"in t)&&!("protocol"in t))return bh(e)||Ui;return p$(e,t)}function p$(e,t){if(!t.normalize&&t.protocol?.source===Cd.source&&!/^https?:\/\//i.test(e))return yh;try{if(typeof URL<"u"){let n=URL;if(typeof n.parse==="function")return n.parse(e)??Ui}return new URL(e)}catch{return Ui}}var d$=/[\t\n\r]/g;function th(e){return e.replace(d$,"")}function h$(e,t){return t.lastIndex=0,t.test(e.hostname)}function f$(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}var wh=b("$ZodURL",(e,t)=>{G.init(e,t),e._zod.check=(n)=>{try{let r=n.value.trim(),i=u$(r,t);if(i===yh){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});return}if(i===Ui){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort});return}if(i===!0){n.value=th(r);return}if(t.hostname&&!h$(i,t.hostname))n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort});if(t.protocol&&!f$(i,t.protocol))n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort});n.value=t.normalize?i.href:th(r);return}catch(r){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),_h=b("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Sd()),G.init(e,t)}),kh=b("$ZodNanoID",(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw Error(`Invalid nanoid length: ${t.length}`);t.pattern??(t.pattern=t.length===void 0?bd:wd(t.length)),G.init(e,t)}),xh=b("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=fd),G.init(e,t)}),Sh=b("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=md),G.init(e,t)}),Ah=b("$ZodULID",(e,t)=>{t.pattern??(t.pattern=gd),G.init(e,t)}),$h=b("$ZodXID",(e,t)=>{t.pattern??(t.pattern=vd),G.init(e,t)}),Ph=b("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=yd),G.init(e,t)}),Th=b("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=Ld(t)),G.init(e,t)}),Eh=b("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Nd),G.init(e,t)}),Oh=b("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=zd(t)),G.init(e,t)}),Ch=b("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=_d),G.init(e,t)}),Rh=b("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Ad),G.init(e,t)}),m$=/^[0-9a-fA-F:.]+$/;function Ih(e){if(!m$.test(e))return!1;return bh(`http://[${e}]`)}var Nh=b("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=$d),G.init(e,t),e._zod.check=(n)=>{if(!Ih(n.value))n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}});var zh=b("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Pd),G.init(e,t)});function g$(e){let t=e.split("/");if(t.length!==2)return!1;let[n,r]=t;if(!r)return!1;let i=Number(r);if(`${i}`!==r)return!1;if(i<0||i>128)return!1;return Ih(n)}var Lh=b("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Td),G.init(e,t),e._zod.check=(n)=>{if(!g$(n.value))n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}});function jh(e){if(e==="")return!0;if(/\s/.test(e))return!1;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var $a=/^[0-9a-zA-Z+/]*={0,2}$/,Dh=b("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=$a),G.init(e,t),e._zod.check=(n)=>{if(jh(n.value))return;n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}}),qi=/^[A-Za-z0-9_-]*$/;function v$(e){if(!qi.test(e))return!1;let t=e.replace(/[-_]/g,(r)=>r==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return jh(n)}var Mh=b("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=qi),G.init(e,t),e._zod.check=(n)=>{if(v$(n.value))return;n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),Uh=b("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Rd),G.init(e,t)});function y$(e,t=null){try{let n=e.split(".");if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));if("typ"in i&&i?.typ!=="JWT")return!1;if(!i.alg)return!1;if(t&&(!("alg"in i)||i.alg!==t))return!1;return!0}catch{return!1}}var Zh=b("$ZodJWT",(e,t)=>{G.init(e,t),e._zod.check=(n)=>{if(y$(n.value,t.alg))return;n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}});var Pa=b("$ZodNumber",(e,t)=>{Z.init(e,t),e._zod.pattern=tr,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch(o){}let i=n.value;if(typeof i==="number"&&!Number.isNaN(i)&&Number.isFinite(i))return n;let s=typeof i==="number"?Number.isNaN(i)?"NaN":!Number.isFinite(i)?String(i):void 0:void 0;return n.issues.push({expected:"number",code:"invalid_type",input:i,inst:e,...s?{received:s}:{}}),n}}),Gh=b("$ZodNumberFormat",(e,t)=>{Gd.init(e,t),Pa.init(e,t)}),qh=b("$ZodBoolean",(e,t)=>{Z.init(e,t),e._zod.pattern=Dd,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Boolean(n.value)}catch(s){}let i=n.value;if(typeof i==="boolean")return n;return n.issues.push({expected:"boolean",code:"invalid_type",input:i,inst:e}),n}});var Bh=b("$ZodUnknown",(e,t)=>{Z.init(e,t),e._zod.parse=(n)=>n}),Hh=b("$ZodNever",(e,t)=>{Z.init(e,t),e._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function b$(e,t){let n=pa(e._zod.def.checks);if(!n.length)return;let r=Math.min(...n.map((s)=>s[0])),i=e._zod.parse;e._zod.parse=(s,o)=>{let a=t(s.value);if(a>r&&!o?.skipChecks&&o?.direction!=="backward"){for(let[c,l]of pa(e._zod.def.checks))if(a>c&&l._zod.def.when(s)){let u=s.issues.length;return l._zod.check(s),s.issues[u].continue=!1,Ei(s.issues,u,e),s}}return i(s,o)}}var w$=(e)=>Array.isArray(e)?e.length:-1;function nh(e,t,n){if(e.issues.length)t.issues.push(...Ue(n,e.issues));t.value[n]=e.value}var Fh=b("$ZodArray",(e,t)=>{Z.init(e,t);let n=le.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let s=r.value;if(!Array.isArray(s))return r.issues.push({expected:"array",code:"invalid_type",input:s,inst:e}),r;r.value=n?n.alloc(e,r,Array(s.length),i):Array(s.length);let o=[],a=i?.abortEarly;for(let c=0;c<s.length;c++){let l=s[c],u=t.element._zod.run({value:l,issues:[]},i);if(u instanceof Promise)o.push(u.then((p)=>nh(p,r,c)));else if(nh(u,r,c),a&&u.issues.length!==0&&$e(u))break}if(o.length)return Promise.all(o).then(()=>r);return r},b$(e,w$)});function Zi(e,t,n,r,i,s){let o=n in r,a=s==="optional";if(!o&&a&&i==="optional")return;if(e.issues.length){if(i!==void 0&&a&&!o)return;t.issues.push(...Ue(n,e.issues))}if(!o&&i===void 0){if(!e.issues.length)t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]});return}if(e.value===void 0){if(o||i==="defaulted"&&!a)t.value[n]=void 0}else t.value[n]=e.value}var _$=[];function Kh(e){let t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:_$,i=r.length?[...t,...r]:t;for(let o of i)if(!e.shape?.[o]?._zod?.traits?.has("$ZodType"))throw Error(`Invalid element at key "${String(o)}": expected a Zod schema`);let s=Bp(e.shape);return{...e,allKeys:i,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(s)}}function Wh(e,t,n,r,i,s,o){let a=[],c=i.keySet,l=i.catchall._zod,u=l.def.type,{optin:p,optout:d}=l,h=0;for(let f in t){if(o&&n.issues.length!==h){if($e(n,h))break;h=n.issues.length}if(c.has(f))continue;if(f==="__proto__"){if(u==="never")a.push(f);continue}if(u==="never"){a.push(f);continue}let m=l.run({value:t[f],issues:[]},r);if(m instanceof Promise)e.push(m.then((g)=>Zi(g,n,f,t,p,d)));else Zi(m,n,f,t,p,d)}if(a.length)n.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:s,continue:!0});if(!e.length)return n;return Promise.all(e).then(()=>n)}var k$=b("$ZodObject",(e,t)=>{Z.init(e,t);let n=Object.getOwnPropertyDescriptor(t,"shape"),r=n?.get?n.get.raw:t.shape??{};if(r){let l=()=>{let u={...r};return Object.defineProperty(t,"shape",{value:u}),l.raw=u,u};l.raw=r,Object.defineProperty(t,"shape",{get:l})}let i=Qn(()=>Kh(t));L(e,"propValues",(l)=>{let u=l.def.shape,p={};for(let d in u){let h=u[d]._zod;if(h.values){if(!Object.prototype.hasOwnProperty.call(p,d))ge(p,d,new Set);for(let f of h.values)p[d].add(f);if(h.optin!==void 0)p[d].add(void 0)}}return p});let s=on,o=t.catchall,a,c=le.memoizer;c?.attach(e),e._zod.parse=(l,u)=>{a??(a=i.value);let p=l.value;if(!s(p))return l.issues.push({expected:"object",code:"invalid_type",input:p,inst:e}),l;l.value=c?c.alloc(e,l,{},u):{};let d=[],h=a.shape,f=u?.abortEarly,m=l.issues.length;for(let g of a.allKeys){if(f&&l.issues.length!==m){if($e(l,m))break;m=l.issues.length}if(g==="__proto__")continue;let w=h[g],k=w._zod.optin,_=w._zod.optout,y=w._zod.run({value:p[g],issues:[]},u);if(y instanceof Promise)d.push(y.then((x)=>Zi(x,l,g,p,k,_)));else Zi(y,l,g,p,k,_)}if(!o)return d.length?Promise.all(d).then(()=>l):l;return Wh(d,p,l,u,i.value,e,f===!0)}}),Vh=b("$ZodObjectJIT",(e,t)=>{k$.init(e,t);let n=e._zod.parse,r=Qn(()=>Kh(t)),i=le.memoizer,s=(h)=>{let f=r.value,m=f.symbolKeys,g=new xa(["payload","ctx"],{shape:h,inst:e,memo:i,syms:m}),w=(x)=>`shape[${x}]._zod.run({ value: input[${x}], issues: [] }, ctx)`,k=(x,S)=>`
144
144
  let ${x}_ab = false;
145
145
  for (let i = 0; i < ${x}.issues.length; i++) {
146
146
  const iss = ${x}.issues[i];
@@ -151,7 +151,7 @@ ${t.join(`
151
151
  if (${x}_ab && ctx && ctx.abortEarly) {
152
152
  payload.value = newResult;
153
153
  return payload;
154
- }`;g.write("const input = payload.value;");let _=Object.create(null),y=0;for(let x of f.allKeys)_[x]=`key_${y++}`;g.write(i?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(let x of f.allKeys){if(x==="__proto__")continue;let S=_[x],O=typeof x==="symbol"?`syms[${m.indexOf(x)}]`:Up(x),A=`${O} in input`,D=h[x],ce=D?._zod?.optin,ke=ce!==void 0,B=D?._zod?.optout==="optional";if(g.write(`const ${S} = ${w(O)};`),ke&&B){let Tt=ce==="optional"?`${S}_present`:`${S}.value !== undefined || ${S}_present`;g.write(`
154
+ }`;g.write("const input = payload.value;");let _=Object.create(null),y=0;for(let x of f.allKeys)_[x]=`key_${y++}`;g.write(i?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(let x of f.allKeys){if(x==="__proto__")continue;let S=_[x],O=typeof x==="symbol"?`syms[${m.indexOf(x)}]`:Up(x),A=`${O} in input`,j=h[x],ce=j?._zod?.optin,ke=ce!==void 0,B=j?._zod?.optout==="optional";if(g.write(`const ${S} = ${w(O)};`),ke&&B){let Tt=ce==="optional"?`${S}_present`:`${S}.value !== undefined || ${S}_present`;g.write(`
155
155
  const ${S}_present = ${A};
156
156
  if (!${S}.issues.length || ${S}_present) {
157
157
  if (${S}.issues.length) {${k(S,O)}
@@ -190,10 +190,10 @@ ${t.join(`
190
190
  if (${S}.value !== undefined || ${A}) {
191
191
  newResult[${O}] = ${S}.value;
192
192
  }
193
- `)}return g.write("payload.value = newResult;"),g.write("return payload;"),g.compile()},o,a=on,c=!le.jitless,u=c&&Gp.value,p=t.catchall,d;e._zod.parse=(h,f)=>{d??(d=r.value);let m=h.value;if(!a(m))return h.issues.push({expected:"object",code:"invalid_type",input:m,inst:e}),h;if(c&&u&&f?.async===!1&&f.jitless!==!0){if(!o)o=s(t.shape);if(h=o(h,f),!p)return h;return Wh([],m,h,f,d,e,f?.abortEarly===!0)}return n(h,f)}});function rh(e,t,n,r){for(let s of e)if(s.issues.length===0)return t.value=s.value,t;let i=e.filter((s)=>!$e(s));if(i.length===1)return t.value=i[0].value,i[0];return t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map((s)=>s.issues.map((o)=>Ze(o,r,ye())))}),t}var Ta=b("$ZodUnion",(e,t)=>{Z.init(e,t),j(e,"optin",(r)=>r.def.options.some((i)=>i._zod.optin==="defaulted")?"defaulted":r.def.options.some((i)=>i._zod.optin!==void 0)?"optional":void 0),j(e,"optout",(r)=>r.def.options.some((i)=>i._zod.optout==="optional")?"optional":void 0),j(e,"values",(r)=>{if(r.def.options.every((i)=>i._zod.values))return new Set(r.def.options.flatMap((i)=>Array.from(i._zod.values)));return}),j(e,"pattern",(r)=>{if(r.def.options.every((i)=>i._zod.pattern)){let i=r.def.options.map((s)=>s._zod.pattern);return new RegExp(`^(${i.map((s)=>$i(s.source)).join("|")})$`)}return});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let s=!1,o=[];for(let a of t.options){let c=a._zod.run({value:r.value,issues:[]},i);if(c instanceof Promise)o.push(c),s=!0;else{if(c.issues.length===0)return c;o.push(c)}}if(!s)return rh(o,r,e,i);return Promise.all(o).then((a)=>rh(a,r,e,i))}});function x$(e){let t=new Map;for(let n of e.options){let r=n._zod.propValues?.[e.discriminator];if(!r||r.size===0)throw Error(`Invalid discriminated union option at index "${e.options.indexOf(n)}"`);for(let i of r)if(t.has(i)){if(i!==void 0)throw Error(`Duplicate discriminator value "${String(i)}"`);t.set(i,null)}else t.set(i,n)}return t}var Yh=b("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Ta.init(e,t);let n=e._zod.parse;j(e,"propValues",(i)=>{let s={},o=0;for(let a of i.def.options){let c=a._zod.propValues;if(!c||Object.keys(c).length===0)throw Error(`Invalid discriminated union option at index "${i.def.options.indexOf(a)}"`);if(c[i.def.discriminator]?.has(void 0))o++;for(let[l,u]of Object.entries(c)){if(!Object.prototype.hasOwnProperty.call(s,l))ge(s,l,new Set);for(let p of u)s[l].add(p)}}if(!i.def.unionFallback&&o>1)s[i.def.discriminator]?.delete(void 0);return s}),t.options.forEach((i,s)=>{let o=Xn(i._zod.def);if(o&&!Object.prototype.hasOwnProperty.call(o,t.discriminator))throw Error(`Invalid discriminated union option at index "${s}"`)});let r=Qn(()=>x$(t));e._zod.parse=(i,s)=>{let o=i.value;if(!on(o))return i.issues.push({code:"invalid_type",expected:"object",input:o,inst:e}),i;let a=o?.[t.discriminator],c=r.value.get(a);if(c&&(a!==void 0||s.direction!=="backward"))return c._zod.run(i,s);if(t.unionFallback||s.direction==="backward")return n(i,s);return i.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(r.value.keys()).filter((l)=>r.value.get(l)!==null),input:o,path:[t.discriminator],inst:e}),i}}),Jh=b("$ZodIntersection",(e,t)=>{Z.init(e,t),e._zod.parse=(n,r)=>{let i=n.value,s=t.left._zod.run({value:i,issues:[]},r),o=t.right._zod.run({value:i,issues:[]},r);if(s instanceof Promise||o instanceof Promise)return Promise.all([s,o]).then(([c,l])=>ih(n,c,l));return ih(n,s,o)}});function Sa(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e===+t)return{valid:!0,data:e};if(Dt(e)&&Dt(t)){let n=Object.keys(t),r=Object.keys(e).filter((s)=>n.indexOf(s)!==-1),i={...e,...t};if(Object.prototype.hasOwnProperty.call(i,"__proto__"))delete i.__proto__;for(let s of r){if(s==="__proto__")continue;let o=Sa(e[s],t[s]);if(!o.valid)return{valid:!1,mergeErrorPath:[s,...o.mergeErrorPath]};i[s]=o.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],s=t[r],o=Sa(i,s);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function ih(e,t,n){let r=new Map,i,s=new Map,o=(l,u)=>{let p;if(l.code==="unrecognized_keys"&&!l.path?.length)i??(i=l),p=l.keys;else if(l.code==="invalid_key"&&l.origin==="record"&&l.path?.length===1){let d=String(l.path[0]);if(!s.has(d))s.set(d,l);p=[d]}else return!1;for(let d of p){if(!r.has(d))r.set(d,{});r.get(d)[u]=!0}return!0};for(let l of t.issues)if(!o(l,"l"))e.issues.push(l);for(let l of n.issues)if(!o(l,"r"))e.issues.push(l);let a=[...r].filter(([,l])=>l.l&&l.r).map(([l])=>l);if(a.length){let l=i?a.filter((u)=>i.keys.includes(u)):[];if(l.length)e.issues.push({...i,keys:l});for(let u of a)if(!l.includes(u)&&s.has(u))e.issues.push(s.get(u))}let c=Sa(t.value,n.value);if(!c.valid){if($e(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var Qh=b("$ZodTuple",(e,t)=>{Z.init(e,t);let n=t.items,r=le.memoizer;r?.attach(e),e._zod.parse=(i,s)=>{let o=i.value;if(!Array.isArray(o))return i.issues.push({input:o,inst:e,expected:"tuple",code:"invalid_type"}),i;i.value=r?r.alloc(e,i,[],s):[];let a=[],c=sh(n,"optin"),l=sh(n,"optout");if(!t.rest){if(o.length<c)return i.issues.push({code:"too_small",minimum:c,inclusive:!0,input:o,inst:e,origin:"array"}),i;if(o.length>n.length)i.issues.push({code:"too_big",maximum:n.length,inclusive:!0,input:o,inst:e,origin:"array"})}let u=Array(n.length),p=t.rest?s?.abortEarly:void 0,d=!1;for(let h=0;h<n.length;h++){let f=n[h]._zod.run({value:o[h],issues:[]},s);if(f instanceof Promise)a.push(f.then((m)=>{u[h]=m}));else if(u[h]=f,p&&!d&&f.issues.length)d=$e(f)}if(t.rest&&!d){let h=n.length-1,f=o.slice(n.length),m=i.issues.length;for(let g of f){if(p&&i.issues.length!==m){if($e(i,m))break;m=i.issues.length}h++;let w=t.rest._zod.run({value:g,issues:[]},s);if(w instanceof Promise)a.push(w.then((k)=>oh(k,i,h)));else oh(w,i,h)}}if(a.length)return Promise.all(a).then(()=>ah(u,i,n,o,l));return ah(u,i,n,o,l)}});function sh(e,t){for(let n=e.length-1;n>=0;n--)if(!(t==="optin"?e[n]._zod.optin!==void 0:e[n]._zod.optout==="optional"))return n+1;return 0}function oh(e,t,n){if(e.issues.length)t.issues.push(...Ue(n,e.issues));t.value[n]=e.value}function ah(e,t,n,r,i){for(let s=0;s<n.length;s++){let o=e[s],a=s<r.length;if(!a&&s>=i&&n[s]._zod.optin==="optional"){t.value.length=s;break}if(o.issues.length){if(!a&&s>=i){t.value.length=s;break}t.issues.push(...Ue(s,o.issues))}t.value[s]=o.value}for(let s=t.value.length-1;s>=r.length;s--)if(n[s]._zod.optout==="optional"&&t.value[s]===void 0)t.value.length=s;else break;return t}var Xh=b("$ZodRecord",(e,t)=>{Z.init(e,t);let n=le.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let s=r.value;if(!Dt(s))return r.issues.push({expected:"record",code:"invalid_type",input:s,inst:e}),r;let o=[],a=t.keyType._zod.values;if(a&&!t.partial){r.value=n?n.alloc(e,r,{},i):{};let c=new Set;for(let u of a)if(typeof u==="string"||typeof u==="number"||typeof u==="symbol"){if(c.add(typeof u==="number"?u.toString():u),u==="__proto__")continue;let p=t.keyType._zod.run({value:u,issues:[]},i);if(p instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(p.issues.length){r.issues.push({code:"invalid_key",origin:"record",issues:p.issues.map((f)=>Ze(f,i,ye())),input:u,path:[u],inst:e});continue}let d=p.value;if(d==="__proto__")continue;let h=t.valueType._zod.run({value:s[u],issues:[]},i);if(h instanceof Promise)o.push(h.then((f)=>{if(f.issues.length)r.issues.push(...Ue(u,f.issues));r.value[d]=f.value}));else{if(h.issues.length)r.issues.push(...Ue(u,h.issues));r.value[d]=h.value}}let l;for(let u in s)if(!c.has(u))if(t.mode==="loose"){if(u==="__proto__")continue;r.value[u]=s[u]}else l=l??[],l.push(u);if(l&&l.length>0)r.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:l,continue:!0})}else{r.value=n?n.alloc(e,r,{},i):{};let c;for(let l of Reflect.ownKeys(s)){if(l==="__proto__")continue;if(!Object.prototype.propertyIsEnumerable.call(s,l))continue;let u=t.keyType._zod.run({value:l,issues:[]},i);if(u instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(typeof l==="string"&&tr.test(l)&&u.issues.length){let f=t.keyType._zod.run({value:Number(l),issues:[]},i);if(f instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(f.issues.length===0)u=f}if(u.issues.length){if(t.mode==="loose")r.value[l]=s[l];else if(a)c=c??[],c.push(l);else r.issues.push({code:"invalid_key",origin:"record",issues:u.issues.map((f)=>Ze(f,i,ye())),input:l,path:[l],inst:e});continue}let d=u.value;if(d==="__proto__")continue;let h=t.valueType._zod.run({value:s[l],issues:[]},i);if(h instanceof Promise)o.push(h.then((f)=>{if(f.issues.length)r.issues.push(...Ue(l,f.issues));r.value[d]=f.value}));else{if(h.issues.length)r.issues.push(...Ue(l,h.issues));r.value[d]=h.value}}if(c&&c.length>0)r.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:c,continue:!0})}if(o.length)return Promise.all(o).then(()=>r);return r}});var ef=b("$ZodEnum",(e,t)=>{Z.init(e,t);let n=Yn(t.entries),r=new Set(n);e._zod.values=r,j(e,"pattern",(i)=>{let s=Yn(i.def.entries).filter((o)=>qp.has(typeof o));return new RegExp(s.length?`^(${s.map((o)=>wt(o.toString())).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(i,s)=>{let o=i.value;if(r.has(o))return i;return i.issues.push({code:"invalid_value",values:n,input:o,inst:e}),i}}),tf=b("$ZodLiteral",(e,t)=>{Z.init(e,t);let n=new Set(t.values);e._zod.values=n,j(e,"pattern",(r)=>{let i=r.def.values;return new RegExp(i.length?`^(${i.map((s)=>typeof s==="string"?wt(s):s?wt(s.toString()):String(s)).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(r,i)=>{let s=r.value;if(n.has(s))return r;return r.issues.push({code:"invalid_value",values:t.values,input:s,inst:e}),r}});var nf=b("$ZodTransform",(e,t)=>{Z.init(e,t),e._zod.optin="optional",le.memoizer?.guard(e),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new er(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then((o)=>(n.value=o,n));if(i instanceof Promise)throw new Ge;return n.value=i,n}});function ch(e,t){return e.value=t.issues.length?void 0:t.value,e}var Ea=b("$ZodOptional",(e,t)=>{Z.init(e,t),j(e,"optin",(n)=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",j(e,"values",(n)=>{let r=n.def.innerType._zod.values;return r?new Set([...r,void 0]):void 0}),j(e,"pattern",(n)=>{let r=n.def.innerType._zod.pattern;return r?new RegExp(`^(${$i(r.source)})?$`):void 0}),e._zod.parse=(n,r)=>{if(n.value===void 0){if(t.innerType._zod.optin!=="defaulted")return n;let i=t.innerType._zod.run({value:n.value,issues:[]},r);if(i instanceof Promise)return i.then((s)=>ch(n,s));return ch(n,i)}return t.innerType._zod.run(n,r)}}),rf=b("$ZodExactOptional",(e,t)=>{Ea.init(e,t),j(e,"values",(n)=>n.def.innerType._zod.values),j(e,"pattern",(n)=>n.def.innerType._zod.pattern),e._zod.parse=(n,r)=>t.innerType._zod.run(n,r)}),sf=b("$ZodNullable",(e,t)=>{Z.init(e,t),j(e,"optin",(n)=>n.def.innerType._zod.optin),j(e,"optout",(n)=>n.def.innerType._zod.optout),j(e,"pattern",(n)=>{let r=n.def.innerType._zod.pattern;return r?new RegExp(`^(${$i(r.source)}|null)$`):void 0}),j(e,"values",(n)=>n.def.innerType._zod.values?new Set([...n.def.innerType._zod.values,null]):void 0),e._zod.parse=(n,r)=>{if(n.value===null)return n;return t.innerType._zod.run(n,r)}}),of=b("$ZodDefault",(e,t)=>{Z.init(e,t),e._zod.optin="defaulted",j(e,"values",(n)=>n.def.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);if(n.value===void 0)return n.value=t.defaultValue,n;let i=t.innerType._zod.run(n,r);if(i instanceof Promise)return i.then((s)=>lh(s,t));return lh(i,t)}});function lh(e,t){if(e.value===void 0)e.value=t.defaultValue;return e}var af=b("$ZodPrefault",(e,t)=>{Z.init(e,t),e._zod.optin="defaulted",j(e,"values",(n)=>n.def.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);if(n.value===void 0)n.value=t.defaultValue;return t.innerType._zod.run(n,r)}}),cf=b("$ZodNonOptional",(e,t)=>{Z.init(e,t),j(e,"values",(n)=>{let r=n.def.innerType._zod.values;return r?new Set([...r].filter((i)=>i!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);if(i instanceof Promise)return i.then((s)=>uh(s,e));return uh(i,e)}});function uh(e,t){if(!e.issues.length&&e.value===void 0)e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t});return e}function ph(e,t,n,r){if(!t.issues.length){if(e.value=t.value,t.memo)e.memo=!0;return e}return e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map((i)=>Ze(i,r,ye()))},input:e.value}),e}var lf=b("$ZodCatch",(e,t)=>{Z.init(e,t),j(e,"optin",(n)=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),j(e,"optout",(n)=>n.def.innerType._zod.optout),j(e,"values",(n)=>n.def.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);let i=t.innerType._zod.run({value:n.value,issues:[]},r);if(i instanceof Promise)return i.then((s)=>ph(n,s,t,r));return ph(n,i,t,r)}});var Oa=b("$ZodPipe",(e,t)=>{Z.init(e,t),j(e,"values",(n)=>n.def.in._zod.values),j(e,"optin",(n)=>n.def.in._zod.optin),j(e,"optout",(n)=>n.def.out._zod.optout),j(e,"propValues",(n)=>n.def.in._zod.propValues),e._zod.parse=(n,r)=>{if(r.direction==="backward"){let s=t.out._zod.run(n,r);if(s instanceof Promise)return s.then((o)=>Mi(o,t.in,r));return Mi(s,t.in,r)}let i=t.in._zod.run(n,r);if(i instanceof Promise)return i.then((s)=>Mi(s,t.out,r));return Mi(i,t.out,r)}});function Mi(e,t,n){if(e.issues.some((r)=>r.code!=="unrecognized_keys"))return e.aborted=!0,e;return t._zod.run({value:e.value,issues:e.issues},n)}var uf=b("$ZodPreprocess",(e,t)=>{Oa.init(e,t)}),pf=b("$ZodReadonly",(e,t)=>{Z.init(e,t),j(e,"propValues",(n)=>n.def.innerType._zod.propValues),j(e,"values",(n)=>n.def.innerType._zod.values),j(e,"optin",(n)=>n.def.innerType?._zod?.optin),j(e,"optout",(n)=>n.def.innerType?._zod?.optout),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);let i=t.innerType._zod.run(n,r);if(i instanceof Promise)return i.then(dh);return dh(i)}});function dh(e){if(!e.memo)e.value=Object.freeze(e.value);return e}var df=b("$ZodCustom",(e,t)=>{re.init(e,t),Z.init(e,t),e._zod.parse=(n,r)=>n,e._zod.check=(n)=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then((s)=>hh(s,n,r,e));hh(i,n,r,e);return}});function hh(e,t,n,r){if(!e){let i={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};if(r._zod.def.params)i.params=r._zod.def.params;t.issues.push(Lt(i))}}class ff extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform");this.name="ZodCyclicError"}}var Ra="~memo",hf=[];function mf(e){return e!==null&&typeof e==="object"}function Ca(e){return e.map((t)=>t.path?{...t,path:t.path.slice()}:{...t})}var gf=new WeakMap,ir=0,Fi=1,sr=2;function Ki(e,t,n){let r=gf.get(e);if(r!==void 0)return r?sr:ir;if(t.has(e))return sr;t.add(e);let i=ir,s=(u)=>{if(i!==sr&&u?._zod){let p=Ki(u,t,n);if(p>i)i=p}},o=(u,p)=>{let d=ir;for(let h of Reflect.ownKeys(u)){let f=Object.getOwnPropertyDescriptor(u,h);if(p&&!f.enumerable)continue;let m=f.get?Fi:f.value?._zod?Ki(f.value,t,n):ir;if(m>d)d=m}return d},a=(u)=>{if(u>i)i=u},c=e._zod.def,l=c.type;switch(l){case"object":{let u=Xn(c);a(u?o(u,!0):Fi),s(c.catchall);break}case"array":s(c.element);break;case"tuple":for(let u of c.items)s(u);s(c.rest);break;case"record":case"map":s(c.keyType),s(c.valueType);break;case"set":s(c.valueType);break;case"union":for(let u of c.options)s(u);break;case"intersection":s(c.left),s(c.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":s(c.innerType);break;case"pipe":s(c.in),s(c.out);break;case"function":s(c.input),s(c.output);break;case"lazy":{let u=c._cachedInner??(n?e._zod.innerType:void 0);a(u?Ki(u,t,!1):Fi);break}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":break;default:for(let u in c){let p=Object.getOwnPropertyDescriptor(c,u);if(!p||p.get)continue;let d=p.value;if(!d||typeof d!=="object")continue;if(d._zod)s(d);else if(Array.isArray(d))for(let h of d)s(h)}}return t.delete(e),S$(e,i)}function S$(e,t){if(t!==Fi)gf.set(e,t===sr);return t}function A$(e,t){let n=e.buckets.get(t);if(!n)n=new WeakMap,e.buckets.set(t,n);return n}var Bi,Hi=[],$$={alloc(e,t,n){let r=Bi;if(!r)return n;Bi=void 0;let i={value:n,issues:null};return r.set(t.value,i),Hi.push(i),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let n=e._zod.parse,r=(i,s)=>{if(s.direction!=="backward"&&P$(s,i.value))throw new ff;return n(i,s)};if(e._zod.parse=r,e._zod.run===n)e._zod.run=r})},attach(e){var t;let n,r=!1,i,s;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let o=e._zod.parse,a=(c,l)=>{if(n===void 0){let w=Ki(e,new Set,!1);if(w===ir){if(e._zod.parse=o,e._zod.run===a)e._zod.run=o;return o(c,l)}if(w===sr||r)n=!0;else r=!0}let u=c.value;if(!mf(u))return o(c,l);let p=l[Ra];if(!p)p={buckets:new WeakMap,backEdges:void 0},l[Ra]=p;let d;if(i===l)d=s;else d=A$(p,e),i=l,s=d;let h=d.get(u);if(h){if(c.value=h.value,h.issues){if(h.issues.length)c.issues.push(...Ca(h.issues))}else c.memo=!0,p.backEdges??(p.backEdges=new WeakSet),p.backEdges.add(h.value);return c}Bi=d;let f=Hi.length,m=o(c,l);Bi=void 0;let g=Hi.length>f?Hi.pop():void 0;if(m instanceof Promise)return m.then((w)=>{if(g)g.issues=w.issues.length?Ca(w.issues):hf;return w});if(g)g.issues=m.issues.length?Ca(m.issues):hf;return m};if(e._zod.parse=a,e._zod.run===o)e._zod.run=a})}};function vf(){return $$}function P$(e,t){let n=e[Ra]?.backEdges;return n!==void 0&&mf(t)&&n.has(t)}var T$=()=>{let e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function t(s){return e[s]??null}let n={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",currency_code:"currency code",credit_card:"credit card number",iban:"IBAN",jwt:"JWT",template_literal:"input"},r={nan:"NaN"};function i(s,o){if(s==="number"&&typeof o==="number"&&!Number.isFinite(o))return String(o);return r[s]??s}return(s)=>{switch(s.code){case"invalid_type":{let o=i(s.expected),a=Wp(s.input),c=i(a,s.input);return`Invalid input: expected ${o}, received ${c}`}case"invalid_value":if(s.values.length===1)return`Invalid input: expected ${la(s.values[0])}`;return`Invalid option: expected one of ${oa(s.values,"|")}`;case"too_big":{let o=s.exact?"exactly ":s.inclusive?"<=":"<",a=t(s.origin);if(a)return`Too big: expected ${s.origin??"value"} to have ${o}${s.maximum.toString()} ${a.unit??"elements"}`;return`Too big: expected ${s.origin??"value"} to be ${o}${s.maximum.toString()}`}case"too_small":{let o=s.exact?"exactly ":s.inclusive?">=":">",a=t(s.origin);if(a)return`Too small: expected ${s.origin} to have ${o}${s.minimum.toString()} ${a.unit}`;return`Too small: expected ${s.origin} to be ${o}${s.minimum.toString()}`}case"invalid_format":{let o=s;if(o.format==="starts_with")return`Invalid string: must start with "${o.prefix}"`;if(o.format==="ends_with")return`Invalid string: must end with "${o.suffix}"`;if(o.format==="includes")return`Invalid string: must include "${o.includes}"`;if(o.format==="regex")return`Invalid string: must match pattern ${o.pattern}`;return`Invalid ${n[o.format]??s.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${s.divisor}`;case"unrecognized_keys":return`Unrecognized key${s.keys.length>1?"s":""}: ${oa(s.keys,", ")}`;case"invalid_key":return`Invalid key in ${s.origin}`;case"invalid_union":if(s.options&&Array.isArray(s.options)&&s.options.length>0)return`Invalid discriminator value. Expected ${s.options.map((a)=>`'${a}'`).join(" | ")}`;if(s.inclusive===!1)return"Invalid input: more than one option matched";return"Invalid input";case"invalid_element":return`Invalid value in ${s.origin}`;default:return"Invalid input"}}};function Ia(){return{localeError:T$()}}var yf;class bf{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];if(this._map.set(e,n),n&&typeof n==="object"&&"id"in n)this._idmap.set(n.id,e);return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);if(t&&typeof t==="object"&&"id"in t)this._idmap.delete(t.id);return this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}function E$(){return new bf}(yf=globalThis).__zod_globalRegistry??(yf.__zod_globalRegistry=E$());var Mt=globalThis.__zod_globalRegistry;function wf(e){if(e.checks)e.checks=[...e.checks];return e}function _f(e,t){return new e(wf({type:"string",...T(t)}))}function kf(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...T(t)})}function xf(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...T(t)})}function Sf(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...T(t)})}function Af(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...T(t)})}function $f(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...T(t)})}function Pf(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...T(t)})}function Na(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...T(t)})}function Tf(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...T(t)})}function Ef(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...T(t)})}function Of(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...T(t)})}function Cf(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...T(t)})}function Rf(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...T(t)})}function If(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...T(t)})}function Nf(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...T(t)})}function zf(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...T(t)})}function jf(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...T(t)})}function Df(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...T(t)})}function Lf(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...T(t)})}function Mf(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...T(t)})}function Uf(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...T(t)})}function Zf(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...T(t)})}function Gf(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...T(t)})}function qf(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...T(t)})}function Bf(e,t){return new e({type:"string",format:"date",check:"string_format",...T(t)})}function Hf(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...T(t)})}function Ff(e,t){return new e({type:"string",format:"duration",check:"string_format",...T(t)})}function Kf(e,t){return new e(wf({type:"number",checks:[],...T(t)}))}function Wf(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...T(t)})}function Vf(e,t){return new e({type:"boolean",...T(t)})}function Yf(e){return new e({type:"unknown"})}function Jf(e,t){return new e({type:"never",...T(t)})}function Wi(e,t){return new _a({check:"less_than",...T(t),value:e,inclusive:!1})}function or(e,t){return new _a({check:"less_than",...T(t),value:e,inclusive:!0})}function Vi(e,t){return new ka({check:"greater_than",...T(t),value:e,inclusive:!1})}function ar(e,t){return new ka({check:"greater_than",...T(t),value:e,inclusive:!0})}function Yi(e,t){return new Zd({check:"multiple_of",...T(t),value:e})}function Ji(e,t){return new qd({check:"max_length",...T(t),maximum:e})}function an(e,t){return new Bd({check:"min_length",...T(t),minimum:e})}function Qi(e,t){return new Hd({check:"length_equals",...T(t),length:e})}function za(e,t){return new Fd({check:"string_format",format:"regex",...T(t),pattern:e})}function ja(e){return new Kd({check:"string_format",format:"lowercase",...T(e)})}function Da(e){return new Wd({check:"string_format",format:"uppercase",...T(e)})}function La(e,t){return new Vd({check:"string_format",format:"includes",...T(t),includes:e})}function Ma(e,t){return new Yd({check:"string_format",format:"starts_with",...T(t),prefix:e})}function Ua(e,t){return new Jd({check:"string_format",format:"ends_with",...T(t),suffix:e})}function _t(e){return new Qd({check:"overwrite",tx:e})}function Za(e){return _t((t)=>t.normalize(e))}function Ga(){return _t((e)=>e.trim())}function qa(){return _t((e)=>e.toLowerCase())}function Ba(){return _t((e)=>e.toUpperCase())}function Ha(){return _t((e)=>Zp(e))}function Qf(e,t,n){return new e({type:"array",element:t,...T(n)})}function Xf(e,t,n){return new e({type:"custom",check:"custom",fn:t,...T(n)})}function em(e,t){let n=O$((r)=>(r.addIssue=(i)=>{if(typeof i==="string")r.issues.push(Lt(i,r.value,n._zod.def));else{let s=i;if(s.fatal)s.continue=!1;if(s.code??(s.code="custom"),!("input"in s))s.input=r.value;s.inst??(s.inst=n),s.continue??(s.continue=!n._zod.def.abort),r.issues.push(Lt(s))}},e(r.value,r)),t);return n}function O$(e,t){let n=new re({check:"custom",...T(t)});return n._zod.check=e,n}function cr(e,...t){for(let n of t)for(let r of Reflect.ownKeys(n))if(Object.prototype.propertyIsEnumerable.call(n,r))ge(e,r,n[r]);return e}function ur(e){let t=e?.target??"draft-2020-12";if(t==="draft-4")t="draft-04";if(t==="draft-7")t="draft-07";return{processors:e.processors??{},metadataRegistry:e?.metadata??Mt,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??"ref",reused:e?.reused??"inline",intersections:[],deferred:[],external:e?.external??void 0}}function Q(e,t,n,r,i){let s=typeof t.unrepresentable==="function"?t.unrepresentable({zodSchema:e,path:r.path,message:i}):t.unrepresentable;if(s==="any")return!1;if(s===void 0||s==="throw")throw Error(i);return Object.assign(n,s),!0}function U(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,s=t.seen.get(e);if(s){if(s.count++,n.schemaPath.includes(e))s.cycle=n.path;return s.schema}let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let a=e._zod.toJSONSchema?.();if(a)o.schema=a;else{let u={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,u);else{let d=o.schema,h=t.processors[i.type];if(!h)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);h(e,t,d,u)}let p=e._zod.parent;if(p){if(!o.ref)o.ref=p;U(p,t,u),t.seen.get(p).isParent=!0}}let c=t.metadataRegistry.get(e);if(c)cr(o.schema,c);if(t.io==="input"&&ue(e))delete o.schema.examples,delete o.schema.default;if(t.io==="input"&&"_prefault"in o.schema)(r=o.schema).default??(r.default=o.schema._prefault);return delete o.schema._prefault,t.seen.get(e).schema}function tm(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function pr(e,t){let n=e.seen.get(t);if(!n)throw Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;let r=new Map;for(let o of e.seen.entries()){let a=e.metadataRegistry.get(o[0])?.id;if(a){let c=r.get(a);if(c&&c!==o[0])throw Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(a,o[0])}}let i=(o)=>{let a=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let p=e.external.registry.get(o[0])?.id,d=e.external.uri??((f)=>f);if(p)return{ref:d(p)};let h=o[1].defId??o[1].schema.id??`schema${e.counter++}`;return o[1].defId=h,{defId:h,ref:`${d("__shared")}#/${a}/${tm(h)}`}}let c="#",l=`${c}/${a}/`;if(o[1]===n&&!o[1].schema.id)return{ref:c};let u=o[1].schema.id??`__schema${e.counter++}`;return{defId:u,ref:l+tm(u)}},s=(o)=>{if(o[1].schema.$ref)return;let a=o[1],{ref:c,defId:l}=i(o);if(a.def={...a.schema},l)a.defId=l;let u=a.schema;for(let p in u)delete u[p];u.$ref=c};if(e.cycles==="throw")for(let o of e.seen.entries()){let a=o[1];if(a.cycle)throw Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
193
+ `)}return g.write("payload.value = newResult;"),g.write("return payload;"),g.compile()},o,a=on,c=!le.jitless,u=c&&Gp.value,p=t.catchall,d;e._zod.parse=(h,f)=>{d??(d=r.value);let m=h.value;if(!a(m))return h.issues.push({expected:"object",code:"invalid_type",input:m,inst:e}),h;if(c&&u&&f?.async===!1&&f.jitless!==!0){if(!o)o=s(t.shape);if(h=o(h,f),!p)return h;return Wh([],m,h,f,d,e,f?.abortEarly===!0)}return n(h,f)}});function rh(e,t,n,r){for(let s of e)if(s.issues.length===0)return t.value=s.value,t;let i=e.filter((s)=>!$e(s));if(i.length===1)return t.value=i[0].value,i[0];return t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map((s)=>s.issues.map((o)=>Ze(o,r,ye())))}),t}var Ta=b("$ZodUnion",(e,t)=>{Z.init(e,t),L(e,"optin",(r)=>r.def.options.some((i)=>i._zod.optin==="defaulted")?"defaulted":r.def.options.some((i)=>i._zod.optin!==void 0)?"optional":void 0),L(e,"optout",(r)=>r.def.options.some((i)=>i._zod.optout==="optional")?"optional":void 0),L(e,"values",(r)=>{if(r.def.options.every((i)=>i._zod.values))return new Set(r.def.options.flatMap((i)=>Array.from(i._zod.values)));return}),L(e,"pattern",(r)=>{if(r.def.options.every((i)=>i._zod.pattern)){let i=r.def.options.map((s)=>s._zod.pattern);return new RegExp(`^(${i.map((s)=>$i(s.source)).join("|")})$`)}return});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let s=!1,o=[];for(let a of t.options){let c=a._zod.run({value:r.value,issues:[]},i);if(c instanceof Promise)o.push(c),s=!0;else{if(c.issues.length===0)return c;o.push(c)}}if(!s)return rh(o,r,e,i);return Promise.all(o).then((a)=>rh(a,r,e,i))}});function x$(e){let t=new Map;for(let n of e.options){let r=n._zod.propValues?.[e.discriminator];if(!r||r.size===0)throw Error(`Invalid discriminated union option at index "${e.options.indexOf(n)}"`);for(let i of r)if(t.has(i)){if(i!==void 0)throw Error(`Duplicate discriminator value "${String(i)}"`);t.set(i,null)}else t.set(i,n)}return t}var Yh=b("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Ta.init(e,t);let n=e._zod.parse;L(e,"propValues",(i)=>{let s={},o=0;for(let a of i.def.options){let c=a._zod.propValues;if(!c||Object.keys(c).length===0)throw Error(`Invalid discriminated union option at index "${i.def.options.indexOf(a)}"`);if(c[i.def.discriminator]?.has(void 0))o++;for(let[l,u]of Object.entries(c)){if(!Object.prototype.hasOwnProperty.call(s,l))ge(s,l,new Set);for(let p of u)s[l].add(p)}}if(!i.def.unionFallback&&o>1)s[i.def.discriminator]?.delete(void 0);return s}),t.options.forEach((i,s)=>{let o=Xn(i._zod.def);if(o&&!Object.prototype.hasOwnProperty.call(o,t.discriminator))throw Error(`Invalid discriminated union option at index "${s}"`)});let r=Qn(()=>x$(t));e._zod.parse=(i,s)=>{let o=i.value;if(!on(o))return i.issues.push({code:"invalid_type",expected:"object",input:o,inst:e}),i;let a=o?.[t.discriminator],c=r.value.get(a);if(c&&(a!==void 0||s.direction!=="backward"))return c._zod.run(i,s);if(t.unionFallback||s.direction==="backward")return n(i,s);return i.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(r.value.keys()).filter((l)=>r.value.get(l)!==null),input:o,path:[t.discriminator],inst:e}),i}}),Jh=b("$ZodIntersection",(e,t)=>{Z.init(e,t),e._zod.parse=(n,r)=>{let i=n.value,s=t.left._zod.run({value:i,issues:[]},r),o=t.right._zod.run({value:i,issues:[]},r);if(s instanceof Promise||o instanceof Promise)return Promise.all([s,o]).then(([c,l])=>ih(n,c,l));return ih(n,s,o)}});function Sa(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e===+t)return{valid:!0,data:e};if(jt(e)&&jt(t)){let n=Object.keys(t),r=Object.keys(e).filter((s)=>n.indexOf(s)!==-1),i={...e,...t};if(Object.prototype.hasOwnProperty.call(i,"__proto__"))delete i.__proto__;for(let s of r){if(s==="__proto__")continue;let o=Sa(e[s],t[s]);if(!o.valid)return{valid:!1,mergeErrorPath:[s,...o.mergeErrorPath]};i[s]=o.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],s=t[r],o=Sa(i,s);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function ih(e,t,n){let r=new Map,i,s=new Map,o=(l,u)=>{let p;if(l.code==="unrecognized_keys"&&!l.path?.length)i??(i=l),p=l.keys;else if(l.code==="invalid_key"&&l.origin==="record"&&l.path?.length===1){let d=String(l.path[0]);if(!s.has(d))s.set(d,l);p=[d]}else return!1;for(let d of p){if(!r.has(d))r.set(d,{});r.get(d)[u]=!0}return!0};for(let l of t.issues)if(!o(l,"l"))e.issues.push(l);for(let l of n.issues)if(!o(l,"r"))e.issues.push(l);let a=[...r].filter(([,l])=>l.l&&l.r).map(([l])=>l);if(a.length){let l=i?a.filter((u)=>i.keys.includes(u)):[];if(l.length)e.issues.push({...i,keys:l});for(let u of a)if(!l.includes(u)&&s.has(u))e.issues.push(s.get(u))}let c=Sa(t.value,n.value);if(!c.valid){if($e(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var Qh=b("$ZodTuple",(e,t)=>{Z.init(e,t);let n=t.items,r=le.memoizer;r?.attach(e),e._zod.parse=(i,s)=>{let o=i.value;if(!Array.isArray(o))return i.issues.push({input:o,inst:e,expected:"tuple",code:"invalid_type"}),i;i.value=r?r.alloc(e,i,[],s):[];let a=[],c=sh(n,"optin"),l=sh(n,"optout");if(!t.rest){if(o.length<c)return i.issues.push({code:"too_small",minimum:c,inclusive:!0,input:o,inst:e,origin:"array"}),i;if(o.length>n.length)i.issues.push({code:"too_big",maximum:n.length,inclusive:!0,input:o,inst:e,origin:"array"})}let u=Array(n.length),p=t.rest?s?.abortEarly:void 0,d=!1;for(let h=0;h<n.length;h++){let f=n[h]._zod.run({value:o[h],issues:[]},s);if(f instanceof Promise)a.push(f.then((m)=>{u[h]=m}));else if(u[h]=f,p&&!d&&f.issues.length)d=$e(f)}if(t.rest&&!d){let h=n.length-1,f=o.slice(n.length),m=i.issues.length;for(let g of f){if(p&&i.issues.length!==m){if($e(i,m))break;m=i.issues.length}h++;let w=t.rest._zod.run({value:g,issues:[]},s);if(w instanceof Promise)a.push(w.then((k)=>oh(k,i,h)));else oh(w,i,h)}}if(a.length)return Promise.all(a).then(()=>ah(u,i,n,o,l));return ah(u,i,n,o,l)}});function sh(e,t){for(let n=e.length-1;n>=0;n--)if(!(t==="optin"?e[n]._zod.optin!==void 0:e[n]._zod.optout==="optional"))return n+1;return 0}function oh(e,t,n){if(e.issues.length)t.issues.push(...Ue(n,e.issues));t.value[n]=e.value}function ah(e,t,n,r,i){for(let s=0;s<n.length;s++){let o=e[s],a=s<r.length;if(!a&&s>=i&&n[s]._zod.optin==="optional"){t.value.length=s;break}if(o.issues.length){if(!a&&s>=i){t.value.length=s;break}t.issues.push(...Ue(s,o.issues))}t.value[s]=o.value}for(let s=t.value.length-1;s>=r.length;s--)if(n[s]._zod.optout==="optional"&&t.value[s]===void 0)t.value.length=s;else break;return t}var Xh=b("$ZodRecord",(e,t)=>{Z.init(e,t);let n=le.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let s=r.value;if(!jt(s))return r.issues.push({expected:"record",code:"invalid_type",input:s,inst:e}),r;let o=[],a=t.keyType._zod.values;if(a&&!t.partial){r.value=n?n.alloc(e,r,{},i):{};let c=new Set;for(let u of a)if(typeof u==="string"||typeof u==="number"||typeof u==="symbol"){if(c.add(typeof u==="number"?u.toString():u),u==="__proto__")continue;let p=t.keyType._zod.run({value:u,issues:[]},i);if(p instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(p.issues.length){r.issues.push({code:"invalid_key",origin:"record",issues:p.issues.map((f)=>Ze(f,i,ye())),input:u,path:[u],inst:e});continue}let d=p.value;if(d==="__proto__")continue;let h=t.valueType._zod.run({value:s[u],issues:[]},i);if(h instanceof Promise)o.push(h.then((f)=>{if(f.issues.length)r.issues.push(...Ue(u,f.issues));r.value[d]=f.value}));else{if(h.issues.length)r.issues.push(...Ue(u,h.issues));r.value[d]=h.value}}let l;for(let u in s)if(!c.has(u))if(t.mode==="loose"){if(u==="__proto__")continue;r.value[u]=s[u]}else l=l??[],l.push(u);if(l&&l.length>0)r.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:l,continue:!0})}else{r.value=n?n.alloc(e,r,{},i):{};let c;for(let l of Reflect.ownKeys(s)){if(l==="__proto__")continue;if(!Object.prototype.propertyIsEnumerable.call(s,l))continue;let u=t.keyType._zod.run({value:l,issues:[]},i);if(u instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(typeof l==="string"&&tr.test(l)&&u.issues.length){let f=t.keyType._zod.run({value:Number(l),issues:[]},i);if(f instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(f.issues.length===0)u=f}if(u.issues.length){if(t.mode==="loose")r.value[l]=s[l];else if(a)c=c??[],c.push(l);else r.issues.push({code:"invalid_key",origin:"record",issues:u.issues.map((f)=>Ze(f,i,ye())),input:l,path:[l],inst:e});continue}let d=u.value;if(d==="__proto__")continue;let h=t.valueType._zod.run({value:s[l],issues:[]},i);if(h instanceof Promise)o.push(h.then((f)=>{if(f.issues.length)r.issues.push(...Ue(l,f.issues));r.value[d]=f.value}));else{if(h.issues.length)r.issues.push(...Ue(l,h.issues));r.value[d]=h.value}}if(c&&c.length>0)r.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:c,continue:!0})}if(o.length)return Promise.all(o).then(()=>r);return r}});var ef=b("$ZodEnum",(e,t)=>{Z.init(e,t);let n=Yn(t.entries),r=new Set(n);e._zod.values=r,L(e,"pattern",(i)=>{let s=Yn(i.def.entries).filter((o)=>qp.has(typeof o));return new RegExp(s.length?`^(${s.map((o)=>wt(o.toString())).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(i,s)=>{let o=i.value;if(r.has(o))return i;return i.issues.push({code:"invalid_value",values:n,input:o,inst:e}),i}}),tf=b("$ZodLiteral",(e,t)=>{Z.init(e,t);let n=new Set(t.values);e._zod.values=n,L(e,"pattern",(r)=>{let i=r.def.values;return new RegExp(i.length?`^(${i.map((s)=>typeof s==="string"?wt(s):s?wt(s.toString()):String(s)).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(r,i)=>{let s=r.value;if(n.has(s))return r;return r.issues.push({code:"invalid_value",values:t.values,input:s,inst:e}),r}});var nf=b("$ZodTransform",(e,t)=>{Z.init(e,t),e._zod.optin="optional",le.memoizer?.guard(e),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new er(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then((o)=>(n.value=o,n));if(i instanceof Promise)throw new Ge;return n.value=i,n}});function ch(e,t){return e.value=t.issues.length?void 0:t.value,e}var Ea=b("$ZodOptional",(e,t)=>{Z.init(e,t),L(e,"optin",(n)=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",L(e,"values",(n)=>{let r=n.def.innerType._zod.values;return r?new Set([...r,void 0]):void 0}),L(e,"pattern",(n)=>{let r=n.def.innerType._zod.pattern;return r?new RegExp(`^(${$i(r.source)})?$`):void 0}),e._zod.parse=(n,r)=>{if(n.value===void 0){if(t.innerType._zod.optin!=="defaulted")return n;let i=t.innerType._zod.run({value:n.value,issues:[]},r);if(i instanceof Promise)return i.then((s)=>ch(n,s));return ch(n,i)}return t.innerType._zod.run(n,r)}}),rf=b("$ZodExactOptional",(e,t)=>{Ea.init(e,t),L(e,"values",(n)=>n.def.innerType._zod.values),L(e,"pattern",(n)=>n.def.innerType._zod.pattern),e._zod.parse=(n,r)=>t.innerType._zod.run(n,r)}),sf=b("$ZodNullable",(e,t)=>{Z.init(e,t),L(e,"optin",(n)=>n.def.innerType._zod.optin),L(e,"optout",(n)=>n.def.innerType._zod.optout),L(e,"pattern",(n)=>{let r=n.def.innerType._zod.pattern;return r?new RegExp(`^(${$i(r.source)}|null)$`):void 0}),L(e,"values",(n)=>n.def.innerType._zod.values?new Set([...n.def.innerType._zod.values,null]):void 0),e._zod.parse=(n,r)=>{if(n.value===null)return n;return t.innerType._zod.run(n,r)}}),of=b("$ZodDefault",(e,t)=>{Z.init(e,t),e._zod.optin="defaulted",L(e,"values",(n)=>n.def.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);if(n.value===void 0)return n.value=t.defaultValue,n;let i=t.innerType._zod.run(n,r);if(i instanceof Promise)return i.then((s)=>lh(s,t));return lh(i,t)}});function lh(e,t){if(e.value===void 0)e.value=t.defaultValue;return e}var af=b("$ZodPrefault",(e,t)=>{Z.init(e,t),e._zod.optin="defaulted",L(e,"values",(n)=>n.def.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);if(n.value===void 0)n.value=t.defaultValue;return t.innerType._zod.run(n,r)}}),cf=b("$ZodNonOptional",(e,t)=>{Z.init(e,t),L(e,"values",(n)=>{let r=n.def.innerType._zod.values;return r?new Set([...r].filter((i)=>i!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);if(i instanceof Promise)return i.then((s)=>uh(s,e));return uh(i,e)}});function uh(e,t){if(!e.issues.length&&e.value===void 0)e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t});return e}function ph(e,t,n,r){if(!t.issues.length){if(e.value=t.value,t.memo)e.memo=!0;return e}return e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map((i)=>Ze(i,r,ye()))},input:e.value}),e}var lf=b("$ZodCatch",(e,t)=>{Z.init(e,t),L(e,"optin",(n)=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),L(e,"optout",(n)=>n.def.innerType._zod.optout),L(e,"values",(n)=>n.def.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);let i=t.innerType._zod.run({value:n.value,issues:[]},r);if(i instanceof Promise)return i.then((s)=>ph(n,s,t,r));return ph(n,i,t,r)}});var Oa=b("$ZodPipe",(e,t)=>{Z.init(e,t),L(e,"values",(n)=>n.def.in._zod.values),L(e,"optin",(n)=>n.def.in._zod.optin),L(e,"optout",(n)=>n.def.out._zod.optout),L(e,"propValues",(n)=>n.def.in._zod.propValues),e._zod.parse=(n,r)=>{if(r.direction==="backward"){let s=t.out._zod.run(n,r);if(s instanceof Promise)return s.then((o)=>Mi(o,t.in,r));return Mi(s,t.in,r)}let i=t.in._zod.run(n,r);if(i instanceof Promise)return i.then((s)=>Mi(s,t.out,r));return Mi(i,t.out,r)}});function Mi(e,t,n){if(e.issues.some((r)=>r.code!=="unrecognized_keys"))return e.aborted=!0,e;return t._zod.run({value:e.value,issues:e.issues},n)}var uf=b("$ZodPreprocess",(e,t)=>{Oa.init(e,t)}),pf=b("$ZodReadonly",(e,t)=>{Z.init(e,t),L(e,"propValues",(n)=>n.def.innerType._zod.propValues),L(e,"values",(n)=>n.def.innerType._zod.values),L(e,"optin",(n)=>n.def.innerType?._zod?.optin),L(e,"optout",(n)=>n.def.innerType?._zod?.optout),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);let i=t.innerType._zod.run(n,r);if(i instanceof Promise)return i.then(dh);return dh(i)}});function dh(e){if(!e.memo)e.value=Object.freeze(e.value);return e}var df=b("$ZodCustom",(e,t)=>{re.init(e,t),Z.init(e,t),e._zod.parse=(n,r)=>n,e._zod.check=(n)=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then((s)=>hh(s,n,r,e));hh(i,n,r,e);return}});function hh(e,t,n,r){if(!e){let i={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};if(r._zod.def.params)i.params=r._zod.def.params;t.issues.push(Dt(i))}}class ff extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform");this.name="ZodCyclicError"}}var Ra="~memo",hf=[];function mf(e){return e!==null&&typeof e==="object"}function Ca(e){return e.map((t)=>t.path?{...t,path:t.path.slice()}:{...t})}var gf=new WeakMap,ir=0,Fi=1,sr=2;function Ki(e,t,n){let r=gf.get(e);if(r!==void 0)return r?sr:ir;if(t.has(e))return sr;t.add(e);let i=ir,s=(u)=>{if(i!==sr&&u?._zod){let p=Ki(u,t,n);if(p>i)i=p}},o=(u,p)=>{let d=ir;for(let h of Reflect.ownKeys(u)){let f=Object.getOwnPropertyDescriptor(u,h);if(p&&!f.enumerable)continue;let m=f.get?Fi:f.value?._zod?Ki(f.value,t,n):ir;if(m>d)d=m}return d},a=(u)=>{if(u>i)i=u},c=e._zod.def,l=c.type;switch(l){case"object":{let u=Xn(c);a(u?o(u,!0):Fi),s(c.catchall);break}case"array":s(c.element);break;case"tuple":for(let u of c.items)s(u);s(c.rest);break;case"record":case"map":s(c.keyType),s(c.valueType);break;case"set":s(c.valueType);break;case"union":for(let u of c.options)s(u);break;case"intersection":s(c.left),s(c.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":s(c.innerType);break;case"pipe":s(c.in),s(c.out);break;case"function":s(c.input),s(c.output);break;case"lazy":{let u=c._cachedInner??(n?e._zod.innerType:void 0);a(u?Ki(u,t,!1):Fi);break}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":break;default:for(let u in c){let p=Object.getOwnPropertyDescriptor(c,u);if(!p||p.get)continue;let d=p.value;if(!d||typeof d!=="object")continue;if(d._zod)s(d);else if(Array.isArray(d))for(let h of d)s(h)}}return t.delete(e),S$(e,i)}function S$(e,t){if(t!==Fi)gf.set(e,t===sr);return t}function A$(e,t){let n=e.buckets.get(t);if(!n)n=new WeakMap,e.buckets.set(t,n);return n}var Bi,Hi=[],$$={alloc(e,t,n){let r=Bi;if(!r)return n;Bi=void 0;let i={value:n,issues:null};return r.set(t.value,i),Hi.push(i),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let n=e._zod.parse,r=(i,s)=>{if(s.direction!=="backward"&&P$(s,i.value))throw new ff;return n(i,s)};if(e._zod.parse=r,e._zod.run===n)e._zod.run=r})},attach(e){var t;let n,r=!1,i,s;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let o=e._zod.parse,a=(c,l)=>{if(n===void 0){let w=Ki(e,new Set,!1);if(w===ir){if(e._zod.parse=o,e._zod.run===a)e._zod.run=o;return o(c,l)}if(w===sr||r)n=!0;else r=!0}let u=c.value;if(!mf(u))return o(c,l);let p=l[Ra];if(!p)p={buckets:new WeakMap,backEdges:void 0},l[Ra]=p;let d;if(i===l)d=s;else d=A$(p,e),i=l,s=d;let h=d.get(u);if(h){if(c.value=h.value,h.issues){if(h.issues.length)c.issues.push(...Ca(h.issues))}else c.memo=!0,p.backEdges??(p.backEdges=new WeakSet),p.backEdges.add(h.value);return c}Bi=d;let f=Hi.length,m=o(c,l);Bi=void 0;let g=Hi.length>f?Hi.pop():void 0;if(m instanceof Promise)return m.then((w)=>{if(g)g.issues=w.issues.length?Ca(w.issues):hf;return w});if(g)g.issues=m.issues.length?Ca(m.issues):hf;return m};if(e._zod.parse=a,e._zod.run===o)e._zod.run=a})}};function vf(){return $$}function P$(e,t){let n=e[Ra]?.backEdges;return n!==void 0&&mf(t)&&n.has(t)}var T$=()=>{let e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function t(s){return e[s]??null}let n={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",currency_code:"currency code",credit_card:"credit card number",iban:"IBAN",jwt:"JWT",template_literal:"input"},r={nan:"NaN"};function i(s,o){if(s==="number"&&typeof o==="number"&&!Number.isFinite(o))return String(o);return r[s]??s}return(s)=>{switch(s.code){case"invalid_type":{let o=i(s.expected),a=Wp(s.input),c=i(a,s.input);return`Invalid input: expected ${o}, received ${c}`}case"invalid_value":if(s.values.length===1)return`Invalid input: expected ${la(s.values[0])}`;return`Invalid option: expected one of ${oa(s.values,"|")}`;case"too_big":{let o=s.exact?"exactly ":s.inclusive?"<=":"<",a=t(s.origin);if(a)return`Too big: expected ${s.origin??"value"} to have ${o}${s.maximum.toString()} ${a.unit??"elements"}`;return`Too big: expected ${s.origin??"value"} to be ${o}${s.maximum.toString()}`}case"too_small":{let o=s.exact?"exactly ":s.inclusive?">=":">",a=t(s.origin);if(a)return`Too small: expected ${s.origin} to have ${o}${s.minimum.toString()} ${a.unit}`;return`Too small: expected ${s.origin} to be ${o}${s.minimum.toString()}`}case"invalid_format":{let o=s;if(o.format==="starts_with")return`Invalid string: must start with "${o.prefix}"`;if(o.format==="ends_with")return`Invalid string: must end with "${o.suffix}"`;if(o.format==="includes")return`Invalid string: must include "${o.includes}"`;if(o.format==="regex")return`Invalid string: must match pattern ${o.pattern}`;return`Invalid ${n[o.format]??s.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${s.divisor}`;case"unrecognized_keys":return`Unrecognized key${s.keys.length>1?"s":""}: ${oa(s.keys,", ")}`;case"invalid_key":return`Invalid key in ${s.origin}`;case"invalid_union":if(s.options&&Array.isArray(s.options)&&s.options.length>0)return`Invalid discriminator value. Expected ${s.options.map((a)=>`'${a}'`).join(" | ")}`;if(s.inclusive===!1)return"Invalid input: more than one option matched";return"Invalid input";case"invalid_element":return`Invalid value in ${s.origin}`;default:return"Invalid input"}}};function Ia(){return{localeError:T$()}}var yf;class bf{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];if(this._map.set(e,n),n&&typeof n==="object"&&"id"in n)this._idmap.set(n.id,e);return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);if(t&&typeof t==="object"&&"id"in t)this._idmap.delete(t.id);return this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}function E$(){return new bf}(yf=globalThis).__zod_globalRegistry??(yf.__zod_globalRegistry=E$());var Mt=globalThis.__zod_globalRegistry;function wf(e){if(e.checks)e.checks=[...e.checks];return e}function _f(e,t){return new e(wf({type:"string",...T(t)}))}function kf(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...T(t)})}function xf(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...T(t)})}function Sf(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...T(t)})}function Af(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...T(t)})}function $f(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...T(t)})}function Pf(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...T(t)})}function Na(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...T(t)})}function Tf(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...T(t)})}function Ef(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...T(t)})}function Of(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...T(t)})}function Cf(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...T(t)})}function Rf(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...T(t)})}function If(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...T(t)})}function Nf(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...T(t)})}function zf(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...T(t)})}function Lf(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...T(t)})}function jf(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...T(t)})}function Df(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...T(t)})}function Mf(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...T(t)})}function Uf(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...T(t)})}function Zf(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...T(t)})}function Gf(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...T(t)})}function qf(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...T(t)})}function Bf(e,t){return new e({type:"string",format:"date",check:"string_format",...T(t)})}function Hf(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...T(t)})}function Ff(e,t){return new e({type:"string",format:"duration",check:"string_format",...T(t)})}function Kf(e,t){return new e(wf({type:"number",checks:[],...T(t)}))}function Wf(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...T(t)})}function Vf(e,t){return new e({type:"boolean",...T(t)})}function Yf(e){return new e({type:"unknown"})}function Jf(e,t){return new e({type:"never",...T(t)})}function Wi(e,t){return new _a({check:"less_than",...T(t),value:e,inclusive:!1})}function or(e,t){return new _a({check:"less_than",...T(t),value:e,inclusive:!0})}function Vi(e,t){return new ka({check:"greater_than",...T(t),value:e,inclusive:!1})}function ar(e,t){return new ka({check:"greater_than",...T(t),value:e,inclusive:!0})}function Yi(e,t){return new Zd({check:"multiple_of",...T(t),value:e})}function Ji(e,t){return new qd({check:"max_length",...T(t),maximum:e})}function an(e,t){return new Bd({check:"min_length",...T(t),minimum:e})}function Qi(e,t){return new Hd({check:"length_equals",...T(t),length:e})}function za(e,t){return new Fd({check:"string_format",format:"regex",...T(t),pattern:e})}function La(e){return new Kd({check:"string_format",format:"lowercase",...T(e)})}function ja(e){return new Wd({check:"string_format",format:"uppercase",...T(e)})}function Da(e,t){return new Vd({check:"string_format",format:"includes",...T(t),includes:e})}function Ma(e,t){return new Yd({check:"string_format",format:"starts_with",...T(t),prefix:e})}function Ua(e,t){return new Jd({check:"string_format",format:"ends_with",...T(t),suffix:e})}function _t(e){return new Qd({check:"overwrite",tx:e})}function Za(e){return _t((t)=>t.normalize(e))}function Ga(){return _t((e)=>e.trim())}function qa(){return _t((e)=>e.toLowerCase())}function Ba(){return _t((e)=>e.toUpperCase())}function Ha(){return _t((e)=>Zp(e))}function Qf(e,t,n){return new e({type:"array",element:t,...T(n)})}function Xf(e,t,n){return new e({type:"custom",check:"custom",fn:t,...T(n)})}function em(e,t){let n=O$((r)=>(r.addIssue=(i)=>{if(typeof i==="string")r.issues.push(Dt(i,r.value,n._zod.def));else{let s=i;if(s.fatal)s.continue=!1;if(s.code??(s.code="custom"),!("input"in s))s.input=r.value;s.inst??(s.inst=n),s.continue??(s.continue=!n._zod.def.abort),r.issues.push(Dt(s))}},e(r.value,r)),t);return n}function O$(e,t){let n=new re({check:"custom",...T(t)});return n._zod.check=e,n}function cr(e,...t){for(let n of t)for(let r of Reflect.ownKeys(n))if(Object.prototype.propertyIsEnumerable.call(n,r))ge(e,r,n[r]);return e}function ur(e){let t=e?.target??"draft-2020-12";if(t==="draft-4")t="draft-04";if(t==="draft-7")t="draft-07";return{processors:e.processors??{},metadataRegistry:e?.metadata??Mt,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??"ref",reused:e?.reused??"inline",intersections:[],deferred:[],external:e?.external??void 0}}function Q(e,t,n,r,i){let s=typeof t.unrepresentable==="function"?t.unrepresentable({zodSchema:e,path:r.path,message:i}):t.unrepresentable;if(s==="any")return!1;if(s===void 0||s==="throw")throw Error(i);return Object.assign(n,s),!0}function U(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,s=t.seen.get(e);if(s){if(s.count++,n.schemaPath.includes(e))s.cycle=n.path;return s.schema}let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let a=e._zod.toJSONSchema?.();if(a)o.schema=a;else{let u={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,u);else{let d=o.schema,h=t.processors[i.type];if(!h)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);h(e,t,d,u)}let p=e._zod.parent;if(p){if(!o.ref)o.ref=p;U(p,t,u),t.seen.get(p).isParent=!0}}let c=t.metadataRegistry.get(e);if(c)cr(o.schema,c);if(t.io==="input"&&ue(e))delete o.schema.examples,delete o.schema.default;if(t.io==="input"&&"_prefault"in o.schema)(r=o.schema).default??(r.default=o.schema._prefault);return delete o.schema._prefault,t.seen.get(e).schema}function tm(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function pr(e,t){let n=e.seen.get(t);if(!n)throw Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;let r=new Map;for(let o of e.seen.entries()){let a=e.metadataRegistry.get(o[0])?.id;if(a){let c=r.get(a);if(c&&c!==o[0])throw Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(a,o[0])}}let i=(o)=>{let a=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let p=e.external.registry.get(o[0])?.id,d=e.external.uri??((f)=>f);if(p)return{ref:d(p)};let h=o[1].defId??o[1].schema.id??`schema${e.counter++}`;return o[1].defId=h,{defId:h,ref:`${d("__shared")}#/${a}/${tm(h)}`}}let c="#",l=`${c}/${a}/`;if(o[1]===n&&!o[1].schema.id)return{ref:c};let u=o[1].schema.id??`__schema${e.counter++}`;return{defId:u,ref:l+tm(u)}},s=(o)=>{if(o[1].schema.$ref)return;let a=o[1],{ref:c,defId:l}=i(o);if(a.def={...a.schema},l)a.defId=l;let u=a.schema;for(let p in u)delete u[p];u.$ref=c};if(e.cycles==="throw")for(let o of e.seen.entries()){let a=o[1];if(a.cycle)throw Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
194
194
 
195
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let o of e.seen.entries()){let a=o[1];if(t===o[0]){s(o);continue}if(e.external){let l=e.external.registry.get(o[0])?.id;if(t!==o[0]&&l){s(o);continue}}if(e.metadataRegistry.get(o[0])?.id){s(o);continue}if(a.cycle){s(o);continue}if(a.count>1){if(e.reused==="ref")s(o)}}if(e.external)e.sharedDefsExtractedFor=e.external}function im(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let n=[];for(let r of t){if(!r||typeof r!=="object")return;im(r);let i=Object.keys(r);if(i.length!==1||i[0]!=="type")return;let s=r.type;for(let o of Array.isArray(s)?s:[s]){if(typeof o!=="string")return;if(!n.includes(o))n.push(o)}}delete e.anyOf,e.type=n.length===1?n[0]:n}var sm=new Set(["type","properties","required","additionalProperties"]),nm=["oneOf","anyOf"];function rm(e){let t=e.additionalProperties;if(t===void 0||t===!1||typeof t!=="object"||t===null)return null;return Object.keys(t).length?t:null}function Fa(e){let t=[];for(let s of e){if(typeof s!=="object"||s.type!=="object")return null;for(let o in s)if(!sm.has(o))return null;t.push(s)}let n={},r=new Set;for(let s of t){for(let o in s.properties){if(Object.prototype.hasOwnProperty.call(n,o))continue;let a=[];for(let l of t){let u=l.properties?.[o]??rm(l);if(u===null||u===void 0)continue;if(!a.some((p)=>JSON.stringify(p)===JSON.stringify(u)))a.push(u)}let c=a.length===1?a[0]:Fa(a)??{allOf:a};ge(n,o,c)}for(let o of s.required??[])r.add(o)}let i={type:"object",properties:n};if(r.size)i.required=[...r];if(t.every((s)=>s.additionalProperties===!1))i.additionalProperties=!1;else{let s=[];for(let o of t){let a=rm(o);if(a&&!s.some((c)=>JSON.stringify(c)===JSON.stringify(a)))s.push(a)}if(s.length===1)i.additionalProperties=s[0];else if(s.length>1)i.additionalProperties={allOf:s}}return i}function C$(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let i of sm)if(i in e)return;let n=t.filter((i)=>nm.some((s)=>Array.isArray(i[s]))),r=null;if(!n.length)r=Fa(t);else{let i=n[0],s=nm.find((c)=>Array.isArray(i[c]));if(Object.keys(i).length!==1)return;let o=t.filter((c)=>c!==i),a=i[s].map((c)=>Fa([...o,c]));if(a.some((c)=>!c))return;r={[s]:a}}if(!r)return;delete e.allOf,cr(e,r)}function dr(e,t){let n=e.seen.get(t);if(!n)throw Error("Unprocessed schema. This is a bug in Zod.");let r=(a)=>{let c=e.seen.get(a);if(c.ref===null)return;let l=c.def??c.schema,u={...l},p=c.ref;if(c.ref=null,p){r(p);let h=e.seen.get(p),f=h.schema;if(f.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"))l.allOf=l.allOf??[],l.allOf.push(f);else cr(l,f);if(cr(l,u),a._zod.parent===p)for(let g in l){if(g==="$ref"||g==="allOf")continue;if(!(g in u))delete l[g]}if(f.$ref&&h.def)for(let g in l){if(g==="$ref"||g==="allOf")continue;if(g in h.def&&JSON.stringify(l[g])===JSON.stringify(h.def[g]))delete l[g]}}let d=a._zod.parent;if(d&&d!==p){r(d);let h=e.seen.get(d);if(h?.schema.$ref){if(l.$ref=h.schema.$ref,h.def)for(let f in l){if(f==="$ref"||f==="allOf")continue;if(f in h.def&&JSON.stringify(l[f])===JSON.stringify(h.def[f]))delete l[f]}}}e.override({zodSchema:a,jsonSchema:l,path:c.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let a of[...e.seen.entries()].reverse())r(a[0]);if(e.target!=="openapi-3.0")for(let a of e.seen.entries())im(a[1].def??a[1].schema);for(let a of e.deferred)a();if(e.intersections.length){let a=new Map;for(let c of e.seen.values())for(let l of[c.schema,c.def]){let u=l?.allOf;if(!Array.isArray(u))continue;let p=a.get(u);if(p)p.push(l);else a.set(u,[l])}for(let c of e.intersections)for(let l of a.get(c)??[])C$(l)}}let i={};if(e.target==="draft-2020-12")i.$schema="https://json-schema.org/draft/2020-12/schema";else if(e.target==="draft-07")i.$schema="http://json-schema.org/draft-07/schema#";else if(e.target==="draft-04")i.$schema="http://json-schema.org/draft-04/schema#";else if(e.target==="openapi-3.0");if(e.external?.uri){let a=e.external.registry.get(t)?.id;if(!a)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(a)}cr(i,n.defId?n.schema:n.def??n.schema);let s=e.metadataRegistry.get(t)?.id;if(s!==void 0&&i.id===s)delete i.id;let o=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let a of e.seen.entries()){let c=a[1];if(c.def&&c.defId){if(c.def.id===c.defId)delete c.def.id;ge(o,c.defId,c.def)}}if(e.external)e.sharedEmitDoneFor=e.external;if(e.external);else if(Object.keys(o).length>0)if(e.target==="draft-2020-12")i.$defs=o;else i.definitions=o;try{let a=JSON.parse(JSON.stringify(i));return Object.defineProperty(a,"~standard",{value:{...t["~standard"],jsonSchema:{input:lr(t,"input",e.processors),output:lr(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch(a){throw Error("Error converting schema to JSON.")}}function ue(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return ue(r.element,n);if(r.type==="set")return ue(r.valueType,n);if(r.type==="lazy")return ue(r.getter(),n);if(r.type==="promise"||r.type==="optional"||r.type==="nonoptional"||r.type==="nullable"||r.type==="readonly"||r.type==="default"||r.type==="prefault"||r.type==="catch")return ue(r.innerType,n);if(r.type==="intersection")return ue(r.left,n)||ue(r.right,n);if(r.type==="record"||r.type==="map")return ue(r.keyType,n)||ue(r.valueType,n);if(r.type==="pipe"){if(e._zod.traits.has("$ZodCodec"))return!0;return ue(r.in,n)||ue(r.out,n)}if(r.type==="object"){for(let i in r.shape)if(ue(r.shape[i],n))return!0;return!1}if(r.type==="union"){for(let i of r.options)if(ue(i,n))return!0;return!1}if(r.type==="tuple"){for(let i of r.items)if(ue(i,n))return!0;if(r.rest&&ue(r.rest,n))return!0;return!1}return!1}var om=(e,t={})=>(n)=>{let r=ur({...n,processors:t});return U(e,r),pr(r,e),dr(r,e)},lr=(e,t,n={})=>(r)=>{let{libraryOptions:i,target:s}=r??{},o=ur({...i??{},target:s,io:t,processors:n});return U(e,o),pr(o,e),dr(o,e)};var cn=(e,t,n)=>{if(e[t]===void 0||n>e[t])e[t]=n},ln=(e,t,n)=>{if(e[t]===void 0||n<e[t])e[t]=n},am=(e,t)=>{cn(e,"minimum",t),ln(e,"maximum",t)},dm=(e,t)=>{if(e.multipleOf??(e.multipleOf=[]),!e.multipleOf.includes(t))e.multipleOf.push(t)},hm=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},fm=(e,t)=>{e.mime=e.mime?e.mime.filter((n)=>t.includes(n)):[...t]},mm=(e,t)=>{if(e.format=t,t.includes("int"))e.isInt=!0},cm=(e,t)=>cn(e,"minimum",t.minimum),lm=(e,t)=>ln(e,"maximum",t.maximum),um=(e)=>(t,n)=>{mm(t,n.format);let[r,i]=e[n.format];cn(t,"minimum",r),ln(t,"maximum",i)},R$={greater_than:(e,t)=>cn(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>ln(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>dm(e,t.value),number_format:um(Pi),bigint_format:um(ua),min_length:cm,max_length:lm,length_equals:(e,t)=>am(e,t.length),min_size:cm,max_size:lm,size_equals:(e,t)=>am(e,t.size),string_format:(e,t)=>{if(mm(e,t.format),t.pattern)hm(e,t.pattern);if(t.format==="base64"||t.format==="base64url")e.contentEncoding=t.format;if(t.local||t.precision===-1)e.laxFormat=!0},mime_type:(e,t)=>fm(e,t.mime)};function fe(e){let t={},n=e._zod.def,r=e._zod.traits.has("$ZodCheck")?[e,...n.checks??[]]:n.checks??[];for(let s of r)R$[s._zod.def.check]?.(t,s._zod.def);let i=e._zod.bag;if(i.minimum!==void 0)cn(t,"minimum",i.minimum);if(i.exclusiveMinimum!==void 0)cn(t,"exclusiveMinimum",i.exclusiveMinimum);if(i.maximum!==void 0)ln(t,"maximum",i.maximum);if(i.exclusiveMaximum!==void 0)ln(t,"exclusiveMaximum",i.exclusiveMaximum);if(i.multipleOf!==void 0)dm(t,i.multipleOf);if(i.format!==void 0){if(t.format??(t.format=i.format),i.format.includes("int"))t.isInt=!0}if(i.mime)fm(t,i.mime);for(let s of i.patterns??[])hm(t,s);return t}var I$={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},N$=new Map([[$a,Ed],[qi,Od]]),gm=(e)=>N$.get(e)??e,Va=(e,t,n,r)=>{let i=n;i.type="string";let{minimum:s,maximum:o,format:a,patterns:c,contentEncoding:l,laxFormat:u}=fe(e);if(typeof s==="number")i.minLength=s;if(typeof o==="number")i.maxLength=o;if(a){if(i.format=I$[a]??a,i.format==="")delete i.format;if(a==="time"||u)delete i.format}if(l)i.contentEncoding=l;if(c&&c.size>0){let p=[...c].map(gm);if(p.length===1)i.pattern=p[0].source;else if(p.length>1)i.allOf=[...p.map((d)=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:d.source}))]}},Ya=(e,t,n,r)=>{let i=n,{minimum:s,maximum:o,multipleOf:a,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=fe(e);i.type=u?"integer":"number";let p=typeof l==="number"&&l>=(s??Number.NEGATIVE_INFINITY),d=typeof c==="number"&&c<=(o??Number.POSITIVE_INFINITY),h=t.target==="draft-04"||t.target==="openapi-3.0";if(p)if(h)i.minimum=l,i.exclusiveMinimum=!0;else i.exclusiveMinimum=l;else if(typeof s==="number")i.minimum=s;if(d)if(h)i.maximum=c,i.exclusiveMaximum=!0;else i.exclusiveMaximum=c;else if(typeof o==="number")i.maximum=o;if(a){let f=new Set;for(let w of a)if(Number.isFinite(w)&&w!==0)f.add(Math.abs(w));else Q(e,t,i,r,`A multipleOf divisor of ${w} cannot be represented in JSON Schema`);let[m,...g]=f;if(m!==void 0)i.multipleOf=m;if(g.length)i.allOf=[...i.allOf??[],...g.map((w)=>({multipleOf:w}))]}},Ja=(e,t,n,r)=>{n.type="boolean"},vm=(e,t,n,r)=>{Q(e,t,n,r,"BigInt cannot be represented in JSON Schema")},ym=(e,t,n,r)=>{Q(e,t,n,r,"Symbols cannot be represented in JSON Schema")},bm=(e,t,n,r)=>{if(t.target==="openapi-3.0")n.type="string",n.nullable=!0,n.enum=[null];else n.type="null"},wm=(e,t,n,r)=>{Q(e,t,n,r,"Undefined cannot be represented in JSON Schema")},_m=(e,t,n,r)=>{Q(e,t,n,r,"Void cannot be represented in JSON Schema")},Qa=(e,t,n,r)=>{n.not={}},km=(e,t,n,r)=>{},Xa=(e,t,n,r)=>{},xm=(e,t,n,r)=>{Q(e,t,n,r,"Date cannot be represented in JSON Schema")},ec=(e,t,n,r)=>{let i=e._zod.def,s=Yn(i.entries);if(s.length===0){n.not={};return}if(s.every((o)=>typeof o==="number"))n.type="number";if(s.every((o)=>typeof o==="string"))n.type="string";n.enum=s},tc=(e,t,n,r)=>{let i=e._zod.def;if(i.values.length===0){n.not={};return}let s=[];for(let o of i.values)if(o===void 0){if(Q(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof o==="bigint"){if(Q(e,t,n,r,"BigInt literals cannot be represented in JSON Schema"))return;s.push(Number(o))}else s.push(o);if(s.length===0);else if(s.length===1){let o=s[0];if(n.type=o===null?"null":typeof o,t.target==="draft-04"||t.target==="openapi-3.0")n.enum=[o];else n.const=o}else{if(s.every((o)=>typeof o==="number"))n.type="number";if(s.every((o)=>typeof o==="string"))n.type="string";if(s.every((o)=>typeof o==="boolean"))n.type="boolean";if(s.every((o)=>o===null))n.type="null";n.enum=s}},Sm=(e,t,n,r)=>{Q(e,t,n,r,"NaN cannot be represented in JSON Schema")},Am=(e,t,n,r)=>{let i=n,s=e._zod.pattern;if(!s)throw Error("Pattern not found in template literal");i.type="string",i.pattern=s.source},$m=(e,t,n,r)=>{let i=n;i.type="string",i.format="binary",i.contentEncoding="binary";let{minimum:s,maximum:o,mime:a}=fe(e);if(s!==void 0)i.minLength=s;if(o!==void 0)i.maxLength=o;if(!a)return;if(a.length===0)i.not={};else if(a.length===1)i.contentMediaType=a[0];else i.anyOf=a.map((c)=>({contentMediaType:c}))},Pm=(e,t,n,r)=>{n.type="boolean"},nc=(e,t,n,r)=>{Q(e,t,n,r,"Custom types cannot be represented in JSON Schema")},Tm=(e,t,n,r)=>{Q(e,t,n,r,"Function types cannot be represented in JSON Schema")},rc=(e,t,n,r)=>{Q(e,t,n,r,"Transforms cannot be represented in JSON Schema")},Em=(e,t,n,r)=>{Q(e,t,n,r,"Map cannot be represented in JSON Schema")},Om=(e,t,n,r)=>{Q(e,t,n,r,"Set cannot be represented in JSON Schema")},ic=(e,t,n,r)=>{let i=n,s=e._zod.def,{minimum:o,maximum:a}=fe(e);if(typeof o==="number")i.minItems=o;if(typeof a==="number")i.maxItems=a;i.type="array",i.items=U(s.element,t,{...r,path:[...r.path,"items"]})};function hr(e){let t=e._zod.def;if(t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform"))return hr(t.out);if(t.type==="catch")return hr(t.innerType);return e._zod.optin}var sc=(e,t,n,r)=>{let i=n,s=e._zod.def,o=s.shape;if(Object.getOwnPropertySymbols(o).length&&Q(e,t,i,r,"Symbol keys cannot be represented in JSON Schema"))return;i.type="object",i.properties={};for(let l in o)ge(i.properties,l,U(o[l],t,{...r,path:[...r.path,"properties",l]}));let c=[];for(let l of Object.keys(o)){let u=s.shape[l];if(t.io==="input"?hr(u)===void 0:u._zod.optout===void 0)c.push(l)}if(c.length>0)i.required=c;if(s.catchall?._zod.def.type==="never")i.additionalProperties=!1;else if(!s.catchall){if(t.io==="output")i.additionalProperties=!1}else if(s.catchall)i.additionalProperties=U(s.catchall,t,{...r,path:[...r.path,"additionalProperties"]})},oc=(e,t,n,r)=>{let i=e._zod.def,s=i.inclusive===!1,o=i.options.map((a,c)=>U(a,t,{...r,path:[...r.path,s?"oneOf":"anyOf",c]}));if(s)n.oneOf=o;else n.anyOf=o},ac=(e,t,n,r)=>{let i=e._zod.def,s=U(i.left,t,{...r,path:[...r.path,"allOf",0]}),o=U(i.right,t,{...r,path:[...r.path,"allOf",1]}),a=(l)=>("allOf"in l)&&Object.keys(l).length===1,c=[...a(s)?s.allOf:[s],...a(o)?o.allOf:[o]];n.allOf=c,t.intersections.push(c)},cc=(e,t,n,r)=>{let i=n,s=e._zod.def;i.type="array";let o=t.target==="draft-2020-12"?"prefixItems":"items",a=t.target==="draft-2020-12"?"items":t.target==="openapi-3.0"?"items":"additionalItems",c=s.items.map((m,g)=>U(m,t,{...r,path:[...r.path,o,g]})),l=s.rest?U(s.rest,t,{...r,path:[...r.path,a,...t.target==="openapi-3.0"?[s.items.length]:[]]}):null,u=s.items.length;while(u>0){let m=s.items[u-1];if(!(t.io==="input"?hr(m)!==void 0:m._zod.optout==="optional"))break;u--}let p=s.items.length,d=!s.rest;if(t.target==="draft-2020-12"){if(i.prefixItems=c,d)i.items=!1;else if(l)i.items=l;if(u>0)i.minItems=u;if(d)i.maxItems=p}else if(t.target==="openapi-3.0"){if(i.items={anyOf:c},l)i.items.anyOf.push(l);if(u>0)i.minItems=u;if(d)i.maxItems=p}else{if(i.items=c,d)i.additionalItems=!1;else if(l)i.additionalItems=l;if(u>0)i.minItems=u;if(d)i.maxItems=p}let{minimum:h,maximum:f}=fe(e);if(typeof h==="number")i.minItems=h;if(typeof f==="number")i.maxItems=f};function Ka(e,t,n){if(t.$ref){if(n.has(t))return t;n.add(t);let f=e.get(t)?.def;if(!f)return t;let m=Ka(e,f,n);return m===f?t:m}for(let f of["anyOf","oneOf"]){let m=t[f];if(!Array.isArray(m))continue;let g=m.map((w)=>Ka(e,w,n));if(g.some((w,k)=>w!==m[k]))t={...t,[f]:g}}let r=Array.isArray(t.type)?t.type:[t.type],i=!r.includes("string")&&r.some((f)=>f==="number"||f==="integer"),s=t.enum??(t.const!==void 0?[t.const]:void 0);if(!i&&!s?.some((f)=>typeof f==="number"))return t;let{minimum:o,maximum:a,exclusiveMinimum:c,exclusiveMaximum:l,multipleOf:u,format:p,id:d,...h}=t;if(h.enum)h.enum=h.enum.map((f)=>typeof f==="number"?String(f):f);else if(typeof h.const==="number")h.const=String(h.const);if(!i)return h;if(h.type="string",!s)h.pattern=(r.includes("number")?tr:ba).source;return h}var Wa=new WeakMap;function z$(e){let t=new Map;for(let r of e.seen.values())if(r.def&&!t.has(r.schema))t.set(r.schema,r);let n=new Map;for(let r of Wa.get(e)??[]){let i=e.seen.get(r),s=(i?.def??i?.schema)?.propertyNames;if(!s||s===!0||n.has(s))continue;let o=Ka(t,s,new Set);if(o!==s)n.set(s,o)}if(!n.size)return;for(let r of e.seen.values())for(let i of[r.schema,r.def]){let s=i&&n.get(i.propertyNames);if(s)i.propertyNames=s}}var lc=(e,t,n,r)=>{let i=n,s=e._zod.def;i.type="object";let o=s.keyType,a=fe(o).patterns;if(s.mode==="loose"&&a&&a.size>0){let u=U(s.valueType,t,{...r,path:[...r.path,"patternProperties","*"]});i.patternProperties={};for(let p of a)ge(i.patternProperties,gm(p).source,u)}else{if(t.target==="draft-07"||t.target==="draft-2020-12"){i.propertyNames=U(s.keyType,t,{...r,path:[...r.path,"propertyNames"]});let u=Wa.get(t);if(!u)u=[],Wa.set(t,u),t.deferred.push(()=>z$(t));u.push(e)}i.additionalProperties=U(s.valueType,t,{...r,path:[...r.path,"additionalProperties"]})}let c=o._zod.values,l=t.io==="input"&&hr(s.valueType)!==void 0;if(c&&!s.partial&&!l){let u=[...c].filter((p)=>typeof p==="string"||typeof p==="number");if(u.length>0)i.required=u.map(String)}},uc=(e,t,n,r)=>{let i=e._zod.def,s=U(i.innerType,t,r),o=t.seen.get(e);if(t.target==="openapi-3.0")o.ref=i.innerType,n.nullable=!0;else n.anyOf=[s,{type:"null"}]},pc=(e,t,n,r)=>{let i=e._zod.def;U(i.innerType,t,r);let s=t.seen.get(e);s.ref=i.innerType},dc=Symbol();function Cm(e,t,n,r,i){let s=!1,o=JSON.stringify(e,(a,c)=>{if(typeof c!=="bigint")return c;return s=!0,null});if(!s)return JSON.parse(o);return Q(t,n,r,i,"BigInt defaults cannot be represented in JSON Schema"),dc}var hc=(e,t,n,r)=>{let i=e._zod.def;U(i.innerType,t,r);let s=t.seen.get(e);s.ref=i.innerType;let o=Cm(i.defaultValue,e,t,n,r);if(o!==dc)n.default=o},fc=(e,t,n,r)=>{let i=e._zod.def;U(i.innerType,t,r);let s=t.seen.get(e);if(s.ref=i.innerType,t.io!=="input")return;let o=Cm(i.defaultValue,e,t,n,r);if(o!==dc)n._prefault=o},mc=(e,t,n,r)=>{let i=e._zod.def;U(i.innerType,t,r);let s=t.seen.get(e);s.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{Q(e,t,n,r,"Dynamic catch values are not supported in JSON Schema");return}n.default=o},gc=(e,t,n,r)=>{let i=e._zod.def,s=i.in._zod.traits.has("$ZodTransform"),o=t.io==="input"?s?i.out:i.in:i.out;U(o,t,r);let a=t.seen.get(e);a.ref=o},vc=(e,t,n,r)=>{let i=e._zod.def;U(i.innerType,t,r);let s=t.seen.get(e);s.ref=i.innerType,n.readOnly=!0},Rm=(e,t,n,r)=>{let i=e._zod.def;U(i.innerType,t,r);let s=t.seen.get(e);s.ref=i.innerType},Xi=(e,t,n,r)=>{let i=e._zod.def;U(i.innerType,t,r);let s=t.seen.get(e);s.ref=i.innerType},Im=(e,t,n,r)=>{let i=e._zod.innerType;U(i,t,r);let s=t.seen.get(e);s.ref=i},pm={string:Va,number:Ya,boolean:Ja,bigint:vm,symbol:ym,null:bm,undefined:wm,void:_m,never:Qa,any:km,unknown:Xa,date:xm,enum:ec,literal:tc,nan:Sm,template_literal:Am,file:$m,success:Pm,custom:nc,function:Tm,transform:rc,map:Em,set:Om,array:ic,object:sc,union:oc,intersection:ac,tuple:cc,record:lc,nullable:uc,nonoptional:pc,default:hc,prefault:fc,catch:mc,pipe:gc,readonly:vc,promise:Rm,optional:Xi,lazy:Im};function Nm(e,t){if("_idmap"in e){let r=e,i=ur({...t,processors:pm}),s={};for(let c of r._idmap.entries()){let[l,u]=c;U(u,i)}let o={},a={registry:r,uri:t?.uri,defs:s};i.external=a;for(let c of r._idmap.entries()){let[l,u]=c;pr(i,u),ge(o,l,dr(i,u))}if(Object.keys(s).length>0){let c=i.target==="draft-2020-12"?"$defs":"definitions";o.__shared={[c]:s}}return{schemas:o}}let n=ur({...t,processors:pm});return U(e,n),pr(n,e),dr(n,e)}var zm=new WeakSet([Object.prototype,Error.prototype]);function ts(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let r=n(this);return Object.defineProperty(this,t,{value:r,configurable:!0,writable:!0}),r},set(r){Object.defineProperty(this,t,{value:r,configurable:!0,writable:!0})}})}var B$=(e,t)=>{nd.init(e,t),e.name="ZodError";let n=Object.getPrototypeOf(e);if(zm.has(n))return;zm.add(n),ts(n,"format",(r)=>(i)=>id(r,i)),ts(n,"flatten",(r)=>(i)=>rd(r,i)),ts(n,"addIssue",(r)=>(i)=>{r.issues.push(i),r.message=JSON.stringify(r.issues,Jn,2)}),ts(n,"addIssues",(r)=>(i)=>{r.issues.push(...i),r.message=JSON.stringify(r.issues,Jn,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}})};var be=b("ZodError",B$,void 0,{Parent:Error});var jm=Ni(be),Dm=zi(be),Lm=ji(be),Mm=Di(be),Um=od(be),Zm=ad(be),Gm=cd(be),qm=ld(be),Bm=ud(be),Hm=pd(be),Fm=dd(be),Km=hd(be);function F$(){if(!le.localeError)ye(Ia())}function fr(){if(!le.memoizer)ye({memoizer:vf()})}var q=b("ZodType",(e,t)=>(F$(),Z.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(ve(t,{checks:[...t.checks??[],...e.map((n)=>typeof n==="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return Me(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(qP(e,t))},superRefine(e,t){return this.check(BP(e,t))},overwrite(e){return this.check(_t(e))},optional(){return Vm(this)},exactOptional(){return OP(this)},nullable(){return Ym(this)},nullish(){return Vm(Ym(this))},nonoptional(e){return jP(this,e)},array(){return X(this)},or(e){return rg([this,e])},and(e){return AP(this,e)},transform(e){return Jm(this,ig(e))},default(e){return IP(this,e)},prefault(e){return zP(this,e)},catch(e){return LP(this,e)},pipe(e){return Jm(this,e)},readonly(){return ZP(this)},describe(e){let t=this.clone();return Mt.add(t,{description:e}),t},meta(...e){if(e.length===0)return Mt.get(this);let t=this.clone();return Mt.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get "~standard"(){return Ri(this,"~standard",{...Aa(this),jsonSchema:{input:lr(this,"input"),output:lr(this,"output")}})},set "~standard"(e){et(this,"~standard",e)},parse:function e(t,n){return jm(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await Dm(this,t,n,{callee:e})},safeParse(e,t){return Lm(this,e,t)},async safeParseAsync(e,t){return Mm(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){et(this,"spa",e)},validate(e,t){return ma(this,e,t)},validateAsync(e,t){return ga(this,e,t)},encode:function e(t,n){return Um(this,t,n,{callee:e})},decode:function e(t,n){return Zm(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await Gm(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await qm(this,t,n,{callee:e})},safeEncode(e,t){return Bm(this,e,t)},safeDecode(e,t){return Hm(this,e,t)},async safeEncodeAsync(e,t){return Fm(this,e,t)},async safeDecodeAsync(e,t){return Km(this,e,t)},toJSONSchema(e){return om(this,{})(e)},get description(){return Mt.get(this)?.description},get _def(){return this._zod.def}}),Qm=b("_ZodString",(e,t)=>{Gi.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Va(e,n,r,i)},Yp({format:(e)=>fe(e).format??null,minLength:(e)=>fe(e).minimum??null,maxLength:(e)=>fe(e).maximum??null},{regex(...e){return this.check(za(...e))},includes(...e){return this.check(La(...e))},startsWith(...e){return this.check(Ma(...e))},endsWith(...e){return this.check(Ua(...e))},min(...e){return this.check(an(...e))},max(...e){return this.check(Ji(...e))},length(...e){return this.check(Qi(...e))},nonempty(...e){return this.check(an(1,...e))},lowercase(e){return this.check(ja(e))},uppercase(e){return this.check(Da(e))},trim(){return this.check(Ga())},normalize(...e){return this.check(Za(...e))},toLowerCase(){return this.check(qa())},toUpperCase(){return this.check(Ba())},slugify(){return this.check(Ha())}})),K$=b("ZodString",(e,t)=>{Gi.init(e,t),Qm.init(e,t)},{email(e){return this.check(kf(Q$,e))},url(e){return this.check(Na(Xm,e))},jwt(e){return this.check(Gf(fP,e))},emoji(e){return this.check(Tf(eP,e))},guid(e){return this.check(xf(X$,e))},uuid(e){return this.check(Sf(ns,e))},uuidv4(e){return this.check(Af(ns,e))},uuidv6(e){return this.check($f(ns,e))},uuidv7(e){return this.check(Pf(ns,e))},nanoid(e){return this.check(Ef(tP,e))},cuid(e){return this.check(Of(nP,e))},cuid2(e){return this.check(Cf(rP,e))},ulid(e){return this.check(Rf(iP,e))},base64(e){return this.check(Mf(pP,e))},base64url(e){return this.check(Uf(dP,e))},xid(e){return this.check(If(sP,e))},ksuid(e){return this.check(Nf(oP,e))},ipv4(e){return this.check(zf(aP,e))},ipv6(e){return this.check(jf(cP,e))},cidrv4(e){return this.check(Df(lP,e))},cidrv6(e){return this.check(Lf(uP,e))},e164(e){return this.check(Zf(hP,e))},datetime(e){return this.check(qf(W$,e))},date(e){return this.check(Bf(V$,e))},time(e){return this.check(Hf(Y$,e))},duration(e){return this.check(Ff(J$,e))}});function E(e){return _f(K$,e)}var H=b("ZodStringFormat",(e,t)=>{G.init(e,t),Qm.init(e,t)}),W$=b("ZodISODateTime",(e,t)=>{Th.init(e,t),H.init(e,t)}),V$=b("ZodISODate",(e,t)=>{Eh.init(e,t),H.init(e,t)}),Y$=b("ZodISOTime",(e,t)=>{Oh.init(e,t),H.init(e,t)}),J$=b("ZodISODuration",(e,t)=>{Ch.init(e,t),H.init(e,t)}),Q$=b("ZodEmail",(e,t)=>{vh.init(e,t),H.init(e,t)});var X$=b("ZodGUID",(e,t)=>{mh.init(e,t),H.init(e,t)});var ns=b("ZodUUID",(e,t)=>{gh.init(e,t),H.init(e,t)});var Xm=b("ZodURL",(e,t)=>{wh.init(e,t),H.init(e,t)});function eg(e){return Na(Xm,e)}var eP=b("ZodEmoji",(e,t)=>{_h.init(e,t),H.init(e,t)});var tP=b("ZodNanoID",(e,t)=>{kh.init(e,t),H.init(e,t)});var nP=b("ZodCUID",(e,t)=>{xh.init(e,t),H.init(e,t)});var rP=b("ZodCUID2",(e,t)=>{Sh.init(e,t),H.init(e,t)});var iP=b("ZodULID",(e,t)=>{Ah.init(e,t),H.init(e,t)});var sP=b("ZodXID",(e,t)=>{$h.init(e,t),H.init(e,t)});var oP=b("ZodKSUID",(e,t)=>{Ph.init(e,t),H.init(e,t)});var aP=b("ZodIPv4",(e,t)=>{Rh.init(e,t),H.init(e,t)});var cP=b("ZodIPv6",(e,t)=>{Nh.init(e,t),H.init(e,t)});var lP=b("ZodCIDRv4",(e,t)=>{zh.init(e,t),H.init(e,t)});var uP=b("ZodCIDRv6",(e,t)=>{jh.init(e,t),H.init(e,t)});var pP=b("ZodBase64",(e,t)=>{Lh.init(e,t),H.init(e,t)});var dP=b("ZodBase64URL",(e,t)=>{Mh.init(e,t),H.init(e,t)});var hP=b("ZodE164",(e,t)=>{Uh.init(e,t),H.init(e,t)});var fP=b("ZodJWT",(e,t)=>{Zh.init(e,t),H.init(e,t)});var tg=b("ZodNumber",(e,t)=>{Pa.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Ya(e,n,r,i),e.isFinite=!0},Yp({minValue:(e)=>{let{minimum:t,exclusiveMinimum:n}=fe(e);return Math.max(t??Number.NEGATIVE_INFINITY,n??Number.NEGATIVE_INFINITY)},maxValue:(e)=>{let{maximum:t,exclusiveMaximum:n}=fe(e);return Math.min(t??Number.POSITIVE_INFINITY,n??Number.POSITIVE_INFINITY)},isInt:(e)=>{let{isInt:t,multipleOf:n}=fe(e);return!!t||!!n?.some(Number.isSafeInteger)},format:(e)=>fe(e).format??null},{gt(e,t){return this.check(Vi(e,t))},gte(e,t){return this.check(ar(e,t))},min(e,t){return this.check(ar(e,t))},lt(e,t){return this.check(Wi(e,t))},lte(e,t){return this.check(or(e,t))},max(e,t){return this.check(or(e,t))},int(e){return this.check(Wm(e))},safe(e){return this.check(Wm(e))},positive(e){return this.check(Vi(0,e))},nonnegative(e){return this.check(ar(0,e))},negative(e){return this.check(Wi(0,e))},nonpositive(e){return this.check(or(0,e))},multipleOf(e,t){return this.check(Yi(e,t))},step(e,t){return this.check(Yi(e,t))},finite(){return this}}));function _c(e){return Kf(tg,e)}var mP=b("ZodNumberFormat",(e,t)=>{Gh.init(e,t),tg.init(e,t)});function Wm(e){return Wf(mP,e)}var gP=b("ZodBoolean",(e,t)=>{qh.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Ja(e,n,r,i)});function tt(e){return Vf(gP,e)}var vP=b("ZodUnknown",(e,t)=>{Bh.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Xa(e,n,r,i)});function yc(){return Yf(vP)}var yP=b("ZodNever",(e,t)=>{Hh.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Qa(e,n,r,i)});function bP(e){return Jf(yP,e)}var wP=b("ZodArray",(e,t)=>{fr(),Fh.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,r,i)=>ic(e,n,r,i),e.element=t.element},{min(e,t){return this.check(an(e,t))},nonempty(e){return this.check(an(1,e))},max(e,t){return this.check(Ji(e,t))},length(e,t){return this.check(Qi(e,t))},unwrap(){return this.element}});function X(e,t){return Qf(wP,e,t)}var _P=b("ZodObject",(e,t)=>{fr(),Vh.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,r,i)=>sc(e,n,r,i),JA(e,"shape",(n)=>n._zod.def.shape,!1)},{keyof(){return kt(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(ve(this._zod.def,{catchall:e}))},passthrough(){return this.clone(ve(this._zod.def,{catchall:yc()}))},loose(){return this.clone(ve(this._zod.def,{catchall:yc()}))},strict(){return this.clone(ve(this._zod.def,{catchall:bP()}))},strip(){return this.clone(ve(this._zod.def,{catchall:void 0}))},extend(e){return qA(this,e)},safeExtend(e){return BA(this,e)},merge(e){return HA(this,e)},pick(e){return ZA(this,e)},omit(e){return GA(this,e)},partial(...e){return Fp(Sc,this,e[0])},exactPartial(...e){return Fp(sg,this,e[0],"exactPartial")},required(...e){return FA(og,this,e[0])}});function N(e,t){let n={type:"object",shape:e??{},...T(t)};return new _P(n)}var ng=b("ZodUnion",(e,t)=>{Ta.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,r,i)=>oc(e,n,r,i),e.options=t.options});function rg(e,t){return new ng({type:"union",options:e,...T(t)})}var kP=b("ZodDiscriminatedUnion",(e,t)=>{ng.init(e,t),Yh.init(e,t)});function xP(e,t,n){return new kP({type:"union",options:t,discriminator:e,...T(n)})}var SP=b("ZodIntersection",(e,t)=>{Jh.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,r,i)=>ac(e,n,r,i)});function AP(e,t){return new SP({type:"intersection",left:e,right:t})}var $P=b("ZodTuple",(e,t)=>{fr(),Qh.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,r,i)=>cc(e,n,r,i)},{rest(e){return this.clone({...this._zod.def,rest:e})},partial(){let e=this._zod.def;if(e.checks?.length)throw Error(".partial() cannot be used on tuple schemas containing refinements");return this.clone({...e,items:e.items.map((t)=>new Sc({type:"optional",innerType:t}))})}});function kc(e,t,n){let r=t instanceof Z,i=r?n:t;return new $P({type:"tuple",items:e,rest:r?t:null,...T(i)})}var bc=b("ZodRecord",(e,t)=>{fr(),Xh.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,r,i)=>lc(e,n,r,i),e.keyType=t.keyType,e.valueType=t.valueType});function rs(e,t,n){if(!t||!t._zod)return new bc({type:"record",keyType:E(),valueType:e,...T(t)});return new bc({type:"record",keyType:e,valueType:t,...T(n)})}function PP(e,t,n){return new bc({type:"record",keyType:e,valueType:t,...T(n),partial:!0})}var wc=b("ZodEnum",(e,t)=>{ef.init(e,t),q.init(e,t),e._zod.processJSONSchema=(r,i,s)=>ec(e,r,i,s),e.enum=t.entries,e.options=[...e._zod.values];let n=new Set(Object.keys(t.entries));e.extract=(r,i)=>{let s={};for(let o of r)if(n.has(o))s[o]=t.entries[o];else throw Error(`Key ${o} not found in enum`);return new wc({...t,checks:[],...T(i),entries:s})},e.exclude=(r,i)=>{let s={...t.entries};for(let o of r)if(n.has(o))delete s[o];else throw Error(`Key ${o} not found in enum`);return new wc({...t,checks:[],...T(i),entries:s})}});function kt(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map((r)=>[r,r])):e;return new wc({type:"enum",entries:n,...T(t)})}var TP=b("ZodLiteral",(e,t)=>{tf.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,r,i)=>tc(e,n,r,i),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function xc(e,t){return new TP({type:"literal",values:Array.isArray(e)?e:[e],...T(t)})}var EP=b("ZodTransform",(e,t)=>{fr(),nf.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,r,i)=>rc(e,n,r,i),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new er(e.constructor.name);n.addIssue=(s)=>{if(typeof s==="string")n.issues.push(Lt(s,n.value,t));else{let o=s;if(o.fatal)o.continue=!1;if(o.code??(o.code="custom"),!("input"in o))o.input=n.value;o.inst??(o.inst=e),n.issues.push(Lt(o))}};let i=t.transform(n.value,n);if(i instanceof Promise)return i.then((s)=>(n.value=s,n));return n.value=i,n}});function ig(e){return new EP({type:"transform",transform:e})}var Sc=b("ZodOptional",(e,t)=>{Ea.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Xi(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function Vm(e){return new Sc({type:"optional",innerType:e})}var sg=b("ZodExactOptional",(e,t)=>{rf.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Xi(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function OP(e){return new sg({type:"optional",innerType:e})}var CP=b("ZodNullable",(e,t)=>{sf.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,r,i)=>uc(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function Ym(e){return new CP({type:"nullable",innerType:e})}var RP=b("ZodDefault",(e,t)=>{of.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,r,i)=>hc(e,n,r,i),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function IP(e,t){return new RP({type:"default",innerType:e,get defaultValue(){return typeof t==="function"?t():ca(t)}})}var NP=b("ZodPrefault",(e,t)=>{af.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,r,i)=>fc(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function zP(e,t){return new NP({type:"prefault",innerType:e,get defaultValue(){return typeof t==="function"?t():ca(t)}})}var og=b("ZodNonOptional",(e,t)=>{cf.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,r,i)=>pc(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function jP(e,t){return new og({type:"nonoptional",innerType:e,...T(t)})}var DP=b("ZodCatch",(e,t)=>{lf.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,r,i)=>mc(e,n,r,i),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function LP(e,t){return new DP({type:"catch",innerType:e,catchValue:typeof t==="function"?t:Jp(t)})}var ag=b("ZodPipe",(e,t)=>{Oa.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,r,i)=>gc(e,n,r,i),e.in=t.in,e.out=t.out});function Jm(e,t){return new ag({type:"pipe",in:e,out:t})}var MP=b("ZodPreprocess",(e,t)=>{ag.init(e,t),uf.init(e,t)}),UP=b("ZodReadonly",(e,t)=>{pf.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,r,i)=>vc(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function ZP(e){return new UP({type:"readonly",innerType:e})}var GP=b("ZodCustom",(e,t)=>{df.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,r,i)=>nc(e,n,r,i)});function qP(e,t={}){return Xf(GP,e,t)}function BP(e,t){return em(e,t)}function HP(e,t){return new MP({type:"pipe",in:ig(e),out:t})}var FP=["iOS","iPhone","macOS"];function xt(e,t){let n=[];if(e==="")return["it is empty"];if(/^\s/.test(e)||/\s$/.test(e))n.push("it has leading or trailing spaces");if(/command ?line/i.test(e))n.push('it should say "command-line"');if(/^(?:the|an?)(?=\s)/i.test(e))n.push("it starts with an article");if(/^[a-z]/.test(e)&&!FP.includes(e.split(/\s+/)[0]))n.push("it starts with a lowercase letter");if(new RegExp(`^${t.replaceAll("-","").split("").join("[\\s\\-]?")}\\b`,"i").test(e))n.push("it starts with the package name");let r=/\b(macOS|Mac(?: ?OS(?: ?X)?)?|OS ?X)(?! virtual machines?)\b/i.exec(e);if(r&&r[1]!=="MAC")n.push("it names the platform");if(/\.$/.test(e)&&!e.endsWith("etc."))n.push("it ends with a full stop");if(/\p{So}/u.test(e))n.push("it contains a symbol or emoji");if([...e].length>80)n.push("it is longer than 80 characters");return n}var pg=["darwin-universal","darwin-arm64","darwin-amd64","linux-arm64","linux-amd64","windows-amd64","windows-arm64"],$c=/^v(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([0-9A-Za-z]+(?:\.[0-9A-Za-z]+)*))?$/,dn=/^[a-z0-9][a-z0-9-]*$/,cg=["com.apple.security.cs.allow-jit","com.apple.security.cs.allow-unsigned-executable-memory","com.apple.security.cs.disable-executable-page-protection","com.apple.security.cs.allow-dyld-environment-variables","com.apple.security.cs.disable-library-validation"],St=E().regex(/^[A-Za-z0-9._-]+(\/[A-Za-z0-9._-]+)*$/).refine((e)=>!e.split("/").includes(".."),"must stay inside the archive"),lg=E().regex(/^[A-Za-z0-9.-]+$/),dg={postflight:N({binary:E().regex(/^[A-Za-z0-9._-]+$/),args:X(E().regex(/^[A-Za-z0-9._:=@%+,\/-]{1,90}$/)).max(10).refine((e)=>e.reduce((t,n)=>t+n.length+4,0)<=90,"must fit on one line of the cask (90 characters)").default([])}).strict().optional(),uninstall:N({launchctl:X(lg).optional(),quit:X(lg).optional()}).strict().optional(),zap:N({trash:X(E().regex(/^~\/[A-Za-z0-9 ._\/-]+$/))}).strict().optional(),caveats:E().min(1).max(2000).optional()},hg={name:E().regex(dn),repo:E().regex(/^[A-Za-z0-9-]+\/[A-Za-z0-9._-]+$/),workflow:E().regex(/^[A-Za-z0-9._-]+\.ya?ml$/).default("release.yml"),assets:PP(kt(pg),E().regex(/^[A-Za-z0-9._{}-]+$/)),description:E().min(1).max(200).optional(),homepage:eg().optional(),license:E().regex(/^[A-Za-z0-9.+-]+$/).optional(),attestation:kt(["auto","off"]).default("auto"),protection:kt(["on","off","dependabot"]).default("on")},fg=/^[A-Za-z0-9 ._-]+\.app$/,pn=/^[A-Za-z0-9-]+(\.[A-Za-z0-9-]+)+$/,KP=N({...hg,kind:kt(["go","bun"]),binaries:X(St).min(1),app:N({name:E().regex(fg),bundle_id:E().regex(pn),binaries:X(St).default([]),entitlements:X(kt(cg)).default([])}).strict().optional(),completions:N({bash:St.optional(),zsh:St.optional(),fish:St.optional()}).strict().optional(),scoop:tt().default(!1),entitlements:X(kt(cg)).default([]),cask:N(dg).strict().default({}),linux:tt().default(!1)}).strict(),nt=_c().int().min(0).max(5000),WP=rg([tt(),E().regex(/^[A-Za-z0-9._*{}-]+$/),X(E().regex(/^[A-Za-z0-9._*{}-]+$/))]),VP=N({...hg,kind:xc("app"),app:E().regex(fg),bundle_id:E().regex(pn),carry:rs(E().regex(/^[A-Za-z0-9._-]+$/),E().regex(/^sha256:[0-9a-f]{64}$/)).default({}),dmg:N({name:E().regex(/^[A-Za-z0-9._{}-]+\.dmg$/),volume:E().regex(/^[A-Za-z0-9 ._-]{1,27}$/).optional(),volume_icon:St.optional(),layout:N({window:kc([nt,nt,nt,nt]),icon_size:nt,app:kc([nt,nt]),applications:kc([nt,nt])}).strict().optional()}).strict(),sparkle:N({key:E().regex(/^[a-z0-9]+$/),feed:E().regex(/^[A-Za-z0-9._-]+\.xml$/).default("appcast.xml"),public_key:E().regex(/^[A-Za-z0-9+/]{43}=$/),next_key:E().regex(/^[a-z0-9]+$/).optional(),next_public_key:E().regex(/^[A-Za-z0-9+/]{43}=$/).optional()}).strict().optional(),code:rs(St,N({identifier:E().regex(pn).optional(),entitlements:rs(E().regex(/^[A-Za-z0-9.-]+$/),WP).optional()}).strict()).default({}),cask:N({...dg,binaries:X(St).optional(),auto_updates:tt().optional()}).strict().default({})}).strict(),mg=HP((e)=>e&&typeof e==="object"&&!Array.isArray(e)&&!("kind"in e)?{...e,kind:"go"}:e,xP("kind",[KP,VP])),YP=N({version:xc(1),tap:E().regex(/^[A-Za-z0-9-]+\/[a-z0-9-]+$/),linux:N({maintainer:E().regex(/^[A-Za-z0-9 .'-]+ <[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}>$/),url:eg({protocol:/^https$/}).regex(/^https:\/\/[A-Za-z0-9.-]+(\/[A-Za-z0-9._-]+)*$/).optional()}).strict().optional(),packages:X(mg)}).strict(),Y=(e)=>e.kind==="app",Ac=(e)=>(Y(e)?e.cask.binaries??[]:[...e.binaries,...e.app?.binaries??[]]).map((t)=>t.split("/").pop()),is=(e)=>Y(e)||Object.keys(e.assets).some((t)=>t.startsWith("darwin")),ug=(e)=>e.map((t)=>`${t.path.join(".")||"(root)"}: ${t.message}`).join("; ");function JP(e,t,n){if(Y(e))eT(e);else if(e.app)XP(e,e.app);let r=e.cask.postflight;if(r&&!Ac(e).includes(r.binary))throw new v(`${e.name}: cask.postflight runs ${r.binary}, which the cask does not link`,`Name one of the commands the cask links: ${Ac(e).join(", ")||"none yet"}.`);if(e.repo.split("/")[0].toLowerCase()!==n.toLowerCase())throw new v(`${e.name}: ${e.repo} is not owned by ${n}`,"tapster publishes only repositories of the hub's owner.");let i=e.description===void 0?[]:xt(e.description,e.name);if(i.length)throw new v(`${e.name}: Homebrew rejects the description because ${i.join(" and ")}`,"Rewrite description in tapster.yml.");let s=Object.entries(e.assets);if(s.length===0)throw new v(`${e.name}: assets is empty`,"Map at least one platform to an asset name.");for(let[o,a]of s){if(a.replaceAll("{version}","").includes("{")||a.replaceAll("{version}","").includes("}"))throw new v(`${e.name}: ${a} uses a placeholder other than {version}`,"Only {version} is replaced in asset names.");if(o.startsWith("darwin")&&!a.endsWith(".tar.gz"))throw new v(`${e.name}: the ${o} asset must be a .tar.gz`,"Pack macOS builds as tar.gz; tapster reads them itself.")}if(Y(e)&&/[{}]/.test(e.dmg.name.replaceAll("{version}","")))throw new v(`${e.name}: ${e.dmg.name} uses a placeholder other than {version}`,"Only {version} is replaced in dmg.name.");if(!Y(e)&&e.scoop&&!Object.keys(e.assets).some((o)=>o.startsWith("windows-")))throw new v(`${e.name}: scoop needs a Windows asset`,"Map windows-amd64 or windows-arm64. Otherwise remove scoop: true.");if(Y(e)||!e.linux)return;if(!Object.keys(e.assets).some((o)=>o.startsWith("linux-")))throw new v(`${e.name}: linux needs a Linux asset`,"Map linux-amd64 or linux-arm64. Otherwise remove linux: true.");if(!t.linux)throw new v(`${e.name} ships Linux packages, but tapster.yml names no linux.maintainer`,'Add linux: { maintainer: "Name <address>" } at the top of tapster.yml.')}function QP(e){let t=new Map,n=(o,a)=>t.has(o)||t.set(o,a);for(let[o,a]of e)if(e.filter(([l,u])=>l!==o&&u.name===a.name).length)n(o,new v(`package ${a.name} is listed twice`,"Keep one entry per package."));let r=e.flatMap(([o,a])=>Ac(a).map((c)=>({i:o,p:a,id:c})));for(let o of r)for(let a of r){if(o.i===a.i||o.id!==a.id||o.p.name===a.p.name)continue;n(o.i,new v(`${o.p.name} and ${a.p.name} both ship a binary named ${o.id}`,"Signed tools are identified by name, so each name may belong to one package."))}let i=(o,a)=>{let c=o.toLowerCase(),l=a.toLowerCase();return c===l||c.startsWith(`${l}.`)||l.startsWith(`${c}.`)},s=e.flatMap(([o,a])=>Y(a)?[{i:o,name:a.name,id:a.bundle_id}]:a.app?[{i:o,name:a.name,id:a.app.bundle_id}]:[]);for(let o of s){for(let a of s)if(o.i!==a.i&&i(o.id,a.id))n(o.i,new v(`${o.name} and ${a.name} have overlapping bundle ids`,"Each app needs its own bundle id, not one inside another."));for(let a of r){let c=a.id.toLowerCase();if(c!==o.id.toLowerCase()&&!c.startsWith(`${o.id.toLowerCase()}.`))continue;let l=new v(`the binary ${a.id} would carry ${o.name}'s identity`,"Rename the binary.");n(o.i,l),n(a.i,l)}}return t}function ie(e,t){let n;try{n=ne(e)}catch(u){let p=u.linePos?.[0]?.line;throw new v(`tapster.yml is not valid YAML${p?` at line ${p}`:""}`,"Fix the YAML syntax there.")}let r=YP.extend({packages:X(yc())}).safeParse(n);if(!r.success)throw new v(`tapster.yml is invalid: ${ug(r.error.issues)}`,"Fix the listed fields.");let{packages:i,...s}=r.data,o=new Map,a=(u)=>{let p=u&&typeof u==="object"&&"repo"in u?u.repo:void 0;return typeof p==="string"?p:null},c=(u,p)=>{let d=u&&typeof u==="object"&&"name"in u?u.name:void 0;return typeof d==="string"&&dn.test(d)?d:`packages[${p}]`},l=[];for(let[u,p]of i.entries()){let d=mg.safeParse(p);if(!d.success){o.set(u,{name:c(p,u),repo:a(p),reason:`${c(p,u)} is invalid: ${ug(d.error.issues)}`,fix:"Fix the listed fields in tapster.yml."});continue}let h=d.data;try{JP(h,s,t),l.push([u,h])}catch(f){if(!(f instanceof v))throw f;o.set(u,{name:h.name,repo:h.repo,reason:f.reason,fix:f.fix})}}for(let[u,p]of QP(l)){let d=l.find(([h])=>h===u)[1];o.set(u,{name:d.name,repo:d.repo,reason:p.reason,fix:p.fix})}return{config:{...s,packages:l.filter(([u])=>!o.has(u)).map(([,u])=>u)},invalid:[...o.entries()].sort(([u],[p])=>u-p).map(([,u])=>u)}}function XP(e,t){let n=Object.keys(e.assets);if(!n.some((i)=>i.startsWith("darwin")))throw new v(`${e.name}: app needs a macOS archive that holds ${t.name}`,"Map a darwin-* asset or remove app.");if(n.some((i)=>i.startsWith("linux")))throw new v(`${e.name}: a tool with an app has a cask for macOS only, but it also has a Linux archive`,"Remove the linux-* assets or remove app.");let r=e.binaries.find((i)=>i===t.name||i.startsWith(`${t.name}/`));if(r)throw new v(`${e.name}: ${r} is inside ${t.name}`,"Remove it from binaries: the hub signs the app as a whole. List commands to link under app.binaries.")}function eT(e){if(Object.keys(e.assets).filter((n)=>n.startsWith("darwin")).length!==1||Object.keys(e.assets).length!==1)throw new v(`${e.name}: an app needs exactly one darwin asset and nothing else`,"Map one of darwin-arm64, darwin-amd64 or darwin-universal to the app archive.");if(e.dmg.volume??=e.app.replace(/\.app$/,"").slice(0,27),e.sparkle&&e.sparkle.next_key===void 0!==(e.sparkle.next_public_key===void 0))throw new v(`${e.name}: a rotation needs both sparkle.next_key and next_public_key`,"Set both or neither.");for(let[n,r]of Object.entries(e.code))if(r.identifier&&!r.identifier.startsWith(`${e.bundle_id}.`))throw new v(`${e.name}: the identifier for ${n} is outside ${e.bundle_id}`,`Use an identifier that starts with ${e.bundle_id}.`)}function ss(e){let t=$c.exec(e);if(!t)return null;return{major:Number(t[1]),minor:Number(t[2]),patch:Number(t[3]),pre:t[4]??null}}function Pc(e,t){for(let i of["major","minor","patch"])if(e[i]!==t[i])return e[i]-t[i];if(e.pre===t.pre)return 0;if(e.pre===null)return 1;if(t.pre===null)return-1;let n=e.pre.split("."),r=t.pre.split(".");for(let i=0;i<Math.max(n.length,r.length);i++){let s=n[i],o=r[i];if(s===void 0)return-1;if(o===void 0)return 1;let a=/^\d+$/.test(s),c=/^\d+$/.test(o);if(a&&c&&Number(s)!==Number(o))return Number(s)-Number(o);if(a!==c)return a?-1:1;if(s!==o)return s<o?-1:1}return 0}function gg(e,t){let[n,r]=t.split("/");return e.linux?.url??`https://${n.toLowerCase()}.github.io/${r}`}import{spawn as RT}from"child_process";import{existsSync as IT}from"fs";import*as yg from"os";function mr(e){if(e===null||e===void 0)return"";else if(typeof e==="string"||e instanceof String)return e;return JSON.stringify(e)}function bg(e,t,n){let r=new wg(e,t,n);process.stdout.write(r.toString()+yg.EOL)}var vg="::";class wg{constructor(e,t,n){if(!e)e="missing.command";this.command=e,this.properties=t,this.message=n}toString(){let e=vg+this.command;if(this.properties&&Object.keys(this.properties).length>0){e+=" ";let t=!0;for(let n in this.properties)if(this.properties.hasOwnProperty(n)){let r=this.properties[n];if(r){if(t)t=!1;else e+=",";e+=`${n}=${nT(r)}`}}}return e+=`${vg}${tT(this.message)}`,e}}function tT(e){return mr(e).replace(/%/g,"%25").replace(/\r/g,"%0D").replace(/\n/g,"%0A")}function nT(e){return mr(e).replace(/%/g,"%25").replace(/\r/g,"%0D").replace(/\n/g,"%0A").replace(/:/g,"%3A").replace(/,/g,"%2C")}var cz=Ce("net"),lz=Ce("tls"),iT=Ce("http"),uz=Ce("https"),sT=Ce("events"),pz=Ce("assert"),oT=Ce("util");function os(e){var t=this;t.options=e||{},t.proxyOptions=t.options.proxy||{},t.maxSockets=t.options.maxSockets||iT.Agent.defaultMaxSockets,t.requests=[],t.sockets=[],t.on("free",function(r,i,s,o){var a=_g(i,s,o);for(var c=0,l=t.requests.length;c<l;++c){var u=t.requests[c];if(u.host===a.host&&u.port===a.port){t.requests.splice(c,1),u.request.onSocket(r);return}}r.destroy(),t.removeSocket(r)})}oT.inherits(os,sT.EventEmitter);os.prototype.addRequest=function(t,n,r,i){var s=this,o=kg({request:t},s.options,_g(n,r,i));if(s.sockets.length>=this.maxSockets){s.requests.push(o);return}s.createSocket(o,function(a){a.on("free",c),a.on("close",l),a.on("agentRemove",l),t.onSocket(a);function c(){s.emit("free",a,o)}function l(u){s.removeSocket(a),a.removeListener("free",c),a.removeListener("close",l),a.removeListener("agentRemove",l)}})};os.prototype.createSocket=function(t,n){var r=this,i={};r.sockets.push(i);var s=kg({},r.proxyOptions,{method:"CONNECT",path:t.host+":"+t.port,agent:!1,headers:{host:t.host+":"+t.port}});if(t.localAddress)s.localAddress=t.localAddress;if(s.proxyAuth)s.headers=s.headers||{},s.headers["Proxy-Authorization"]="Basic "+new Buffer(s.proxyAuth).toString("base64");Ut("making CONNECT request");var o=r.request(s);o.useChunkedEncodingByDefault=!1,o.once("response",a),o.once("upgrade",c),o.once("connect",l),o.once("error",u),o.end();function a(p){p.upgrade=!0}function c(p,d,h){process.nextTick(function(){l(p,d,h)})}function l(p,d,h){if(o.removeAllListeners(),d.removeAllListeners(),p.statusCode!==200){Ut("tunneling socket could not be established, statusCode=%d",p.statusCode),d.destroy();var f=Error("tunneling socket could not be established, statusCode="+p.statusCode);f.code="ECONNRESET",t.request.emit("error",f),r.removeSocket(i);return}if(h.length>0){Ut("got illegal response body from proxy"),d.destroy();var f=Error("got illegal response body from proxy");f.code="ECONNRESET",t.request.emit("error",f),r.removeSocket(i);return}return Ut("tunneling connection has established"),r.sockets[r.sockets.indexOf(i)]=d,n(d)}function u(p){o.removeAllListeners(),Ut(`tunneling socket could not be established, cause=%s
196
- `,p.message,p.stack);var d=Error("tunneling socket could not be established, cause="+p.message);d.code="ECONNRESET",t.request.emit("error",d),r.removeSocket(i)}};os.prototype.removeSocket=function(t){var n=this.sockets.indexOf(t);if(n===-1)return;this.sockets.splice(n,1);var r=this.requests.shift();if(r)this.createSocket(r,function(i){r.request.onSocket(i)})};function _g(e,t,n){if(typeof e==="string")return{host:e,port:t,localAddress:n};return e}function kg(e){for(var t=1,n=arguments.length;t<n;++t){var r=arguments[t];if(typeof r==="object"){var i=Object.keys(r);for(var s=0,o=i.length;s<o;++s){var a=i[s];if(r[a]!==void 0)e[a]=r[a]}}}return e}var Ut;if(process.env.NODE_DEBUG&&/\btunnel\b/.test(process.env.NODE_DEBUG))Ut=function(){var e=Array.prototype.slice.call(arguments);if(typeof e[0]==="string")e[0]="TUNNEL: "+e[0];else e.unshift("TUNNEL:");console.error.apply(console,e)};else Ut=function(){};var qe;(function(e){e[e.OK=200]="OK",e[e.MultipleChoices=300]="MultipleChoices",e[e.MovedPermanently=301]="MovedPermanently",e[e.ResourceMoved=302]="ResourceMoved",e[e.SeeOther=303]="SeeOther",e[e.NotModified=304]="NotModified",e[e.UseProxy=305]="UseProxy",e[e.SwitchProxy=306]="SwitchProxy",e[e.TemporaryRedirect=307]="TemporaryRedirect",e[e.PermanentRedirect=308]="PermanentRedirect",e[e.BadRequest=400]="BadRequest",e[e.Unauthorized=401]="Unauthorized",e[e.PaymentRequired=402]="PaymentRequired",e[e.Forbidden=403]="Forbidden",e[e.NotFound=404]="NotFound",e[e.MethodNotAllowed=405]="MethodNotAllowed",e[e.NotAcceptable=406]="NotAcceptable",e[e.ProxyAuthenticationRequired=407]="ProxyAuthenticationRequired",e[e.RequestTimeout=408]="RequestTimeout",e[e.Conflict=409]="Conflict",e[e.Gone=410]="Gone",e[e.TooManyRequests=429]="TooManyRequests",e[e.InternalServerError=500]="InternalServerError",e[e.NotImplemented=501]="NotImplemented",e[e.BadGateway=502]="BadGateway",e[e.ServiceUnavailable=503]="ServiceUnavailable",e[e.GatewayTimeout=504]="GatewayTimeout"})(qe||(qe={}));var xg;(function(e){e.Accept="accept",e.ContentType="content-type"})(xg||(xg={}));var Sg;(function(e){e.ApplicationJson="application/json"})(Sg||(Sg={}));var vz=[qe.MovedPermanently,qe.ResourceMoved,qe.SeeOther,qe.TemporaryRedirect,qe.PermanentRedirect],yz=[qe.BadGateway,qe.ServiceUnavailable,qe.GatewayTimeout];import{EOL as cT}from"os";import{constants as Ag,promises as lT}from"fs";var Ec=function(e,t,n,r){function i(s){return s instanceof n?s:new n(function(o){o(s)})}return new(n||(n=Promise))(function(s,o){function a(u){try{l(r.next(u))}catch(p){o(p)}}function c(u){try{l(r.throw(u))}catch(p){o(p)}}function l(u){u.done?s(u.value):i(u.value).then(a,c)}l((r=r.apply(e,t||[])).next())})},{access:uT,appendFile:pT,writeFile:dT}=lT,$g="GITHUB_STEP_SUMMARY";class Pg{constructor(){this._buffer=""}filePath(){return Ec(this,void 0,void 0,function*(){if(this._filePath)return this._filePath;let e=process.env[$g];if(!e)throw Error(`Unable to find environment variable for $${$g}. Check if your runtime environment supports job summaries.`);try{yield uT(e,Ag.R_OK|Ag.W_OK)}catch(t){throw Error(`Unable to access summary file: '${e}'. Check if the file has correct read/write permissions.`)}return this._filePath=e,this._filePath})}wrap(e,t,n={}){let r=Object.entries(n).map(([i,s])=>` ${i}="${s}"`).join("");if(!t)return`<${e}${r}>`;return`<${e}${r}>${t}</${e}>`}write(e){return Ec(this,void 0,void 0,function*(){let t=!!(e===null||e===void 0?void 0:e.overwrite),n=yield this.filePath();return yield(t?dT:pT)(n,this._buffer,{encoding:"utf8"}),this.emptyBuffer()})}clear(){return Ec(this,void 0,void 0,function*(){return this.emptyBuffer().write({overwrite:!0})})}stringify(){return this._buffer}isEmptyBuffer(){return this._buffer.length===0}emptyBuffer(){return this._buffer="",this}addRaw(e,t=!1){return this._buffer+=e,t?this.addEOL():this}addEOL(){return this.addRaw(cT)}addCodeBlock(e,t){let n=Object.assign({},t&&{lang:t}),r=this.wrap("pre",this.wrap("code",e),n);return this.addRaw(r).addEOL()}addList(e,t=!1){let n=t?"ol":"ul",r=e.map((s)=>this.wrap("li",s)).join(""),i=this.wrap(n,r);return this.addRaw(i).addEOL()}addTable(e){let t=e.map((r)=>{let i=r.map((s)=>{if(typeof s==="string")return this.wrap("td",s);let{header:o,data:a,colspan:c,rowspan:l}=s,u=o?"th":"td",p=Object.assign(Object.assign({},c&&{colspan:c}),l&&{rowspan:l});return this.wrap(u,a,p)}).join("");return this.wrap("tr",i)}).join(""),n=this.wrap("table",t);return this.addRaw(n).addEOL()}addDetails(e,t){let n=this.wrap("details",this.wrap("summary",e)+t);return this.addRaw(n).addEOL()}addImage(e,t,n){let{width:r,height:i}=n||{},s=Object.assign(Object.assign({},r&&{width:r}),i&&{height:i}),o=this.wrap("img",null,Object.assign({src:e,alt:t},s));return this.addRaw(o).addEOL()}addHeading(e,t){let n=`h${t}`,r=["h1","h2","h3","h4","h5","h6"].includes(n)?n:"h1",i=this.wrap(r,e);return this.addRaw(i).addEOL()}addSeparator(){let e=this.wrap("hr",null);return this.addRaw(e).addEOL()}addBreak(){let e=this.wrap("br",null);return this.addRaw(e).addEOL()}addQuote(e,t){let n=Object.assign({},t&&{cite:t}),r=this.wrap("blockquote",e,n);return this.addRaw(r).addEOL()}addLink(e,t){let n=this.wrap("a",e,{href:t});return this.addRaw(n).addEOL()}}var Oz=new Pg;import Eg from"os";import*as as from"fs";var{chmod:hT,copyFile:fT,lstat:mT,mkdir:gT,open:Iz,readdir:vT,rename:yT,rm:bT,rmdir:Nz,stat:wT,symlink:_T,unlink:kT}=as.promises,xT=process.platform==="win32";var zz=as.constants.O_RDONLY;var Uz=process.platform==="win32";var Hz=Eg.platform(),Fz=Eg.arch();var Og;(function(e){e[e.Success=0]="Success",e[e.Failure=1]="Failure"})(Og||(Og={}));function Tc(e){bg("add-mask",{},e)}var Cg=4;var Oc=new Set;function CT(e){if(e.length<Cg)return[];let t=new Set,n=(i)=>{if(i.length>=Cg)t.add(i)};n(e);let r=Buffer.from(e,"utf8");n(r.toString("base64")),n(r.toString("hex")),n(r.toString("hex").toUpperCase()),n(encodeURIComponent(e));for(let i of e.split(/\r?\n/))n(i.trim());return[...t]}function hn(e){for(let t of CT(e)){if(Oc.has(t))continue;if(Oc.add(t),process.env.GITHUB_ACTIONS==="true")Tc(t)}}function fn(e){let t=e;for(let n of[...Oc].sort((r,i)=>i.length-r.length))t=t.split(n).join("***");return t}var mn={codesign:"/usr/bin/codesign",security:"/usr/bin/security",xcrun:"/usr/bin/xcrun",openssl:"/usr/bin/openssl",ditto:"/usr/bin/ditto",git:"/usr/bin/git",hdiutil:"/usr/bin/hdiutil",xattr:"/usr/bin/xattr",plutil:"/usr/bin/plutil",spctl:"/usr/sbin/spctl",gpg:"/usr/bin/gpg",gpgconf:"/usr/bin/gpgconf",rpm:"/usr/bin/rpm",rpmsign:"/usr/bin/rpmsign",rpm2archive:"/usr/bin/rpm2archive","dpkg-deb":"/usr/bin/dpkg-deb",createrepo_c:"/usr/bin/createrepo_c","apt-ftparchive":"/usr/bin/apt-ftparchive"},NT=["/opt/homebrew/bin/gh","/usr/local/bin/gh","/usr/bin/gh"];function zT(e={}){return{PATH:"/usr/bin:/bin",HOME:process.env.HOME??"/tmp",TMPDIR:process.env.RUNNER_TEMP??process.env.TMPDIR??"/tmp",...e}}function jT(e,t=5){return fn(e).split(/\r?\n/).filter((n)=>n.trim()!==""&&!/keychain/i.test(n)).slice(-t).join(" | ")}function Rg(e=NT){let t=e.find((n)=>IT(n));if(!t)throw new v("gh is not installed on this runner","Use a GitHub-hosted runner image, which ships gh.");return t}function Pe(e,t,n={}){return L(mn[e],e,t,n)}function L(e,t,n,r={}){return new Promise((i,s)=>{let o=RT(e,n,{env:zT(r.env),cwd:r.cwd,shell:!1,stdio:["pipe","pipe","pipe"]}),a=[],c=[],l=0,u=null,p=(f)=>{u??=f,o.kill("SIGKILL")},d=r.timeoutMs?setTimeout(()=>p(new v(`${t} did not finish in time`,"Re-run the workflow; if it happens again, check the input it read.")),r.timeoutMs):null,h=(f)=>(m)=>{if(l+=m.length,r.maxOutput&&l>r.maxOutput)p(new v(`${t} wrote more output than tapster reads`,"Check the input it read."));else f.push(m)};o.stdout.on("data",h(a)),o.stderr.on("data",h(c)),o.on("error",()=>s(new v(`${t} could not start`,`Check that ${e} exists on this runner.`))),o.on("close",(f)=>{if(d)clearTimeout(d);if(u){s(u);return}let m=Buffer.concat(a),g={code:f??-1,stdout:m.toString("utf8"),stderr:Buffer.concat(c).toString("utf8"),bytes:m};if(g.code!==0&&!r.allowFail){s(new v(`${t} exited with ${g.code}`,jT(g.stderr)||"No error output."));return}i(g)}),o.stdin.end(r.stdin??"")})}var DT=1048576,Ig=32,LT=1e5,C=(e)=>new v(`an Info.plist ${e}`,"Rebuild the app; tapster reads XML and binary property lists.");function Cc(e){if(e.length>DT)throw C("is larger than 1 MiB");if(e.subarray(0,8).toString("latin1")==="bplist00")return qT(e);if(e[0]===254||e[0]===255||e[0]===0)throw C("is not UTF-8");let t=e.toString("utf8").replace(/^\ufeff/,""),n=/^\s*<\?xml[^>]*\bencoding\s*=\s*["']([^"']*)["']/.exec(t)?.[1];if(n!==void 0&&!/^utf-?8$/i.test(n))throw C(`declares the encoding ${n}, not UTF-8`);return GT(t)}var MT={amp:"&",lt:"<",gt:">",quot:'"',apos:"'"};function UT(e){return e.replace(/&(#x[0-9a-fA-F]+|#[0-9]+|[a-z]+);/g,(t,n)=>{if(n.startsWith("#x"))return String.fromCodePoint(Number.parseInt(n.slice(2),16));if(n.startsWith("#"))return String.fromCodePoint(Number.parseInt(n.slice(1),10));let r=MT[n];if(r===void 0)throw C(`uses an unknown entity ${t}`);return r})}function ZT(e){let t=[],n=0;while(n<e.length)if(e.startsWith("<!--",n)){let r=e.indexOf("-->",n+4);if(r===-1)throw C("has an unclosed comment");n=r+3}else if(e.startsWith("<![CDATA[",n)){let r=e.indexOf("]]>",n+9);if(r===-1)throw C("has an unclosed CDATA section");t.push({kind:"text",text:e.slice(n+9,r)}),n=r+3}else if(e.startsWith("<?",n)||e.startsWith("<!",n)){let r=e.indexOf(">",n);if(r===-1)throw C("is not valid XML");n=r+1}else if(e[n]==="<"){let r=e.indexOf(">",n);if(r===-1)throw C("is not valid XML");let i=e.slice(n+1,r).trim(),s=/^(\/)?([A-Za-z]+)(?:\s[^/]*)?(\/)?$/.exec(i);if(!s)throw C("has a tag tapster does not read");t.push({kind:s[1]?"close":s[3]?"empty":"open",name:s[2]}),n=r+1}else{let r=e.indexOf("<",n),i=e.slice(n,r===-1?e.length:r);t.push({kind:"text",text:UT(i)}),n=r===-1?e.length:r}return t}function GT(e){let t=ZT(e).filter((u)=>!(u.kind==="text"&&u.text.trim()==="")),n=0,r=()=>t[n++],i=()=>t[n],s=(u)=>{let p="";for(;;){let d=r();if(!d)throw C(`has an unclosed <${u}>`);if(d.kind==="text")p+=d.text;else if(d.kind==="close"&&d.name===u)return p;else throw C(`has markup inside <${u}>`)}},o=(u)=>{if(u>Ig)throw C("is nested too deeply");let p=r();if(!p||p.kind==="text"||p.kind==="close")throw C("is missing a value");if(p.kind==="empty"){if(p.name==="true")return!0;if(p.name==="false")return!1;if(p.name==="string")return"";if(p.name==="dict")return{};if(p.name==="array")return[];if(p.name==="data")return Buffer.alloc(0);throw C(`has an unknown <${p.name}/>`)}switch(p.name){case"string":return s("string");case"integer":{let d=s("integer").trim();if(!/^[+-]?\d{1,15}$/.test(d))throw C("has an integer tapster does not read");return Number(d)}case"real":{let d=Number(s("real").trim());if(!Number.isFinite(d))throw C("has an invalid real");return d}case"date":{let d=new Date(s("date").trim());if(Number.isNaN(d.getTime()))throw C("has an invalid date");return d}case"data":return Buffer.from(s("data").replace(/\s+/g,""),"base64");case"array":{let d=[];for(;;){let h=i();if(h?.kind==="close"&&h.name==="array")return n++,d;d.push(o(u+1))}}case"dict":{let d={};for(;;){let h=r();if(h?.kind==="close"&&h.name==="dict")return d;if(h?.kind!=="open"||h.name!=="key")throw C("has a dict entry without a key");let f=s("key");if(Object.hasOwn(d,f))throw C(`lists the key ${f} twice`);Object.defineProperty(d,f,{value:o(u+1),enumerable:!0,writable:!0,configurable:!0})}}default:throw C(`has an unknown <${p.name}>`)}},a=r();if(!a||a.kind!=="open"||a.name!=="plist")throw C("does not start with <plist>");let c=o(1),l=r();if(!l||l.kind!=="close"||l.name!=="plist"||n!==t.length)throw C("has content after its value");return c}function qT(e){if(e.length<40)throw C("is truncated");let t=e.subarray(e.length-32),n=t[6],r=t[7],i=Number(t.readBigUInt64BE(8)),s=Number(t.readBigUInt64BE(16)),o=Number(t.readBigUInt64BE(24));if(![1,2,4,8].includes(n)||![1,2,4,8].includes(r))throw C("has a damaged trailer");if(i<1||s>=i||o<8||o+i*n>e.length-32)throw C("has a damaged offset table");let a=(d,h)=>{if(d+h>e.length-32)throw C("is truncated");let f=h===8?e.readBigUInt64BE(d):BigInt(e.readUIntBE(d,h));if(f>BigInt(Number.MAX_SAFE_INTEGER))throw C("has a number tapster does not read");return Number(f)},c=(d)=>{if(d>=i)throw C("has a reference outside its objects");let h=a(o+d*n,n);if(h<8||h>=o)throw C("has an object outside its body");return h},l=new Set,u=0,p=(d,h)=>{if(h>Ig)throw C("is nested too deeply");if(++u>LT)throw C("has too many objects");if(l.has(d))throw C("refers to itself");l.add(d);try{let f=c(d),m=e[f],g=m>>4,w=m&15,k=()=>{if(w!==15)return[w,f+1];let _=e[f+1];if(_>>4!==1)throw C("has a damaged length");let y=1<<(_&15);return[a(f+2,y),f+2+y]};switch(g){case 0:if(m===8)return!1;if(m===9)return!0;throw C("has an object tapster does not read");case 1:{let _=1<<w;if(_===8){if(f+9>e.length-32)throw C("is truncated");let y=e.readBigInt64BE(f+1);if(y>BigInt(Number.MAX_SAFE_INTEGER)||y<BigInt(Number.MIN_SAFE_INTEGER))throw C("has a number tapster does not read");return Number(y)}if(_>8)throw C("has a number tapster does not read");return a(f+1,_)}case 2:{if(w===2)return e.readFloatBE(f+1);if(w===3)return e.readDoubleBE(f+1);throw C("has a real tapster does not read")}case 3:if(m!==51)throw C("has a damaged date");return new Date((978307200+e.readDoubleBE(f+1))*1000);case 4:{let[_,y]=k();if(y+_>o)throw C("is truncated");return Buffer.from(e.subarray(y,y+_))}case 5:{let[_,y]=k();if(y+_>o)throw C("is truncated");return e.subarray(y,y+_).toString("latin1")}case 6:{let[_,y]=k();if(y+_*2>o)throw C("is truncated");let x=Buffer.from(e.subarray(y,y+_*2));return x.swap16(),x.toString("utf16le")}case 10:{let[_,y]=k();if(y+_*r>o)throw C("is truncated");return Array.from({length:_},(x,S)=>p(a(y+S*r,r),h+1))}case 13:{let[_,y]=k();if(y+2*_*r>o)throw C("is truncated");let x={};for(let S=0;S<_;S++){let O=p(a(y+S*r,r),h+1);if(typeof O!=="string")throw C("has a dict key that is not a string");if(Object.hasOwn(x,O))throw C(`lists the key ${O} twice`);Object.defineProperty(x,O,{value:p(a(y+(_+S)*r,r),h+1),enumerable:!0,writable:!0,configurable:!0})}return x}default:throw C("has an object tapster does not read")}}finally{l.delete(d)}};return p(s,1)}var cs=[{actor_id:5,actor_type:"RepositoryRole",bypass_mode:"always"}],BT={actor_id:null,actor_type:"DeployKey",bypass_mode:"always"},Rc={name:"tapster tags",target:"tag",enforcement:"active",bypass_actors:cs,conditions:{ref_name:{include:["~ALL"],exclude:[]}},rules:[{type:"creation"},{type:"update"},{type:"deletion"}]},Ic={name:"tapster branches",target:"branch",enforcement:"active",bypass_actors:cs,conditions:{ref_name:{include:["~ALL"],exclude:[]}},rules:[{type:"creation"},{type:"update"},{type:"deletion"},{type:"non_fast_forward"}]},ls="refs/heads/dependabot/**";function HT(e,t=!1){let n=e?[...cs,BT]:cs,r={ref_name:{include:["~ALL"],exclude:t?[ls]:[]}};return[{...Rc,bypass_actors:n},{...Ic,bypass_actors:n,conditions:r}]}function Ng(e,t){if(t==="app")return e.current_user_can_bypass!=="never";return(e.bypass_actors??[]).some((n)=>!(n.actor_type==="DeployKey"||n.actor_type==="RepositoryRole"&&n.actor_id===5))}async function zg(e,t,n,r,i,s){let o;try{o=await e.json("GET",`/repos/${t}/rulesets?targets=${n}`)}catch(h){if(h instanceof R&&(h.status===403||h.status===404))return{problems:["GitHub offers no rulesets on this repository; private repositories need a paid plan for them"],ok:!1};throw h}let a=await Promise.all(o.filter((h)=>h.target===n&&h.enforcement==="active").map((h)=>e.json("GET",`/repos/${t}/rulesets/${h.id}`)));if(a.length===0)return{problems:[`no active ${n} ruleset protects every ${n}`],ok:!1};let c=n==="branch"&&s?[ls]:[],l=a.filter((h)=>(h.conditions?.ref_name?.include??[]).includes("~ALL")&&(h.conditions?.ref_name?.exclude??[]).every((f)=>c.includes(f)));if(l.length===0)return{problems:[`no active ${n} ruleset covers every ${n} (~ALL) without exclusions`],ok:!1};let u=l.filter((h)=>Ng(h,i)).map((h)=>`the App or another actor can bypass ${h.name}`),p=new Set(l.filter((h)=>!Ng(h,i)).flatMap((h)=>(h.rules??[]).map((f)=>f.type))),d=r.filter((h)=>!p.has(h));if(d.length)u.push(`the ${n} rulesets do not restrict ${d.join(", ")}`);return{problems:u,ok:u.length===0}}async function jg(e,t,n,r,i=!1){let s=await zg(e,t,"tag",Rc.rules.map((a)=>a.type),r,!1),o=await zg(e,t,"branch",Ic.rules.map((a)=>a.type),r,i);if(o.ok){let a=new Set((await e.json("GET",`/repos/${t}/rules/branches/${encodeURIComponent(n)}`)).map((c)=>c.type));if(!["update","deletion","non_fast_forward"].every((c)=>a.has(c)))o.problems.push("GitHub does not enforce rulesets on this repository; private repositories need a paid plan for them")}return{tag:s.problems,branch:o.problems}}async function gr(e,t,n,r,i=!1){let s=await jg(e,t,n,r,i);return[...s.tag,...s.branch]}async function Dg(e,t,n,r=!1,i=!1){let s;try{s=await e.json("GET",`/repos/${t}/rulesets`)}catch(f){if(f instanceof R&&(f.status===403||f.status===404))return{status:"unavailable",deployKeys:r,dependabot:i};throw f}let o=await Promise.all(s.filter((f)=>f.name===Rc.name||f.name===Ic.name).map((f)=>e.json("GET",`/repos/${t}/rulesets/${f.id}`))),a=r||o.some((f)=>(f.bypass_actors??[]).some((m)=>m.actor_type==="DeployKey")),c=i||o.some((f)=>(f.conditions?.ref_name?.exclude??[]).includes(ls)),l=(f)=>({status:f,deployKeys:a,dependabot:c}),u=await jg(e,t,n,"admin",c);if(u.tag.concat(u.branch).some((f)=>f.includes("offers no rulesets")))return l("unavailable");let p=a!==o.some((f)=>(f.bypass_actors??[]).some((m)=>m.actor_type==="DeployKey"))||c!==o.some((f)=>(f.conditions?.ref_name?.exclude??[]).includes(ls));if(u.tag.length+u.branch.length===0&&!p)return l("exists");let[d,h]=HT(a,c);try{for(let[f,m]of[[d,u.tag],[h,u.branch]]){if(m.length===0&&!p)continue;let g=s.find((w)=>w.name===f.name);if(g)await e.json("PUT",`/repos/${t}/rulesets/${g.id}`,f);else await e.json("POST",`/repos/${t}/rulesets`,f)}}catch(f){if(f instanceof R&&(f.status===403||f.status===422))return l("unavailable");throw f}return l((await gr(e,t,n,"admin",c)).length===0?"created":"unavailable")}import{createPrivateKey as wE}from"crypto";import{spawn as _E}from"child_process";import{existsSync as ev,readFileSync as kE}from"fs";import{writeFile as br}from"fs/promises";import{delimiter as Gc,join as Ke}from"path";var FT={401:"Your GitHub sign-in was rejected; run gh auth login again.",403:"Your account may not do this here; check that you own the repository, then run gh auth refresh to renew the sign-in.",404:"Not found or not visible to your gh sign-in; check the name and run gh auth status.",409:"GitHub reported a conflict; run the command again.",422:"GitHub rejected the request."},KT={401:"The credential was rejected; rotate it with tapster init --rotate.",403:"Access denied: check the App's permissions and that it is installed on this repository.",404:"Not found. The App may not be installed on this repository.",409:"GitHub reported a conflict; the next run retries.",422:"GitHub rejected the request."};function Nc(e){try{return new URL(e).pathname}catch{return"(url)"}}class pe{token;fetchImpl;sleep;who;constructor(e,t=fetch,n=(i)=>new Promise((s)=>setTimeout(s,i)),r="app"){this.token=e;this.fetchImpl=t;this.sleep=n;this.who=r}async request(e,t,n={}){let r=t.startsWith("https://")?t:`https://api.github.com${t}`,i={Accept:n.accept??"application/vnd.github+json","X-GitHub-Api-Version":"2022-11-28","User-Agent":"tapster"};if(n.auth!==!1)i.Authorization=`Bearer ${this.token}`;if(n.contentType)i["Content-Type"]=n.contentType;else if(n.body!==void 0)i["Content-Type"]="application/json";let s=n.raw??(n.body!==void 0?JSON.stringify(n.body):void 0);for(let o=0;;o++){let a;try{a=await this.fetchImpl(r,{method:e,headers:i,body:s,redirect:"manual"})}catch{if(o<4){await this.sleep(1000*2**o);continue}throw new R(`GitHub ${e} ${Nc(r)}: network error`,"GitHub did not answer; the next run retries.",0)}if((a.status>=500||a.status===429)&&o<4){await this.sleep(1000*2**o);continue}if(a.status>=400){await a.body?.cancel();let c=this.who==="user"?FT:KT;throw new R(`GitHub ${e} ${Nc(r)} returned ${a.status}`,c[a.status]??(this.who==="user"?"Try again in a moment.":"The next run retries."),a.status)}return a}}async json(e,t,n){let r=await this.request(e,t,n===void 0?{}:{body:n});for(let i=0;r.status>=300&&r.status<400;i++){let s=r.headers.get("location"),o=null;try{o=s?new URL(s):null}catch{o=null}if(i>=3||!o||o.protocol!=="https:"||o.host!=="api.github.com")throw new R(`GitHub ${e} ${Nc(t)} moved somewhere tapster does not follow`,"Update the repository name in tapster.yml.",r.status);r=await this.request(e,o.toString(),n===void 0?{}:{body:n})}if(r.status===204)return;return await r.json()}async listReleases(e){let t=[];for(let n=1;n<=10;n++){let r=await this.json("GET",`/repos/${e}/releases?per_page=100&page=${n}`);if(t.push(...r),r.length<100)break}return t}getRelease=(e,t)=>this.json("GET",`/repos/${e}/releases/${t}`);getRepo=(e)=>this.json("GET",`/repos/${e}`);async downloadAsset(e,t){let n=await this.request("GET",`/repos/${e}/releases/assets/${t}`,{accept:"application/octet-stream"});if(n.status>=300&&n.status<400){let r=n.headers.get("location");if(!r)throw new R(`GitHub sent a redirect without a location for asset ${t}`,"The next run retries.",n.status);let i=await this.request("GET",r,{auth:!1,accept:"application/octet-stream"});return Buffer.from(await i.arrayBuffer())}return Buffer.from(await n.arrayBuffer())}async uploadAsset(e,t,n){let r=e.upload_url.replace(/\{.*\}$/,"");return await(await this.request("POST",`${r}?name=${encodeURIComponent(t)}`,{raw:n,contentType:"application/octet-stream"})).json()}deleteAsset=(e,t)=>this.request("DELETE",`/repos/${e}/releases/assets/${t}`).then(()=>{return});renameAsset=(e,t,n)=>this.json("PATCH",`/repos/${e}/releases/assets/${t}`,{name:n});updateRelease=(e,t,n,r)=>this.json("PATCH",`/repos/${e}/releases/${t}`,{...r,tag_name:n})}import{createSign as WT}from"crypto";var Lg=(e)=>Buffer.from(e).toString("base64url");function Be(e,t,n=Date.now()){let r=Math.floor(n/1000)-60,i=Lg(JSON.stringify({alg:"RS256",typ:"JWT"})),s=Lg(JSON.stringify({iat:r,exp:r+540,iss:e})),o=WT("RSA-SHA256").update(`${i}.${s}`).sign(t).toString("base64url"),a=`${i}.${s}.${o}`;return hn(a),a}async function Mg(e,t,n,r){let i=new pe(Be(e,t),r),s;try{s=await i.json("GET",`/users/${n}/installation`)}catch(c){if(c instanceof R&&c.status===404)return null;throw c}let{token:o}=await i.json("POST",`/app/installations/${s.id}/access_tokens`,{permissions:{metadata:"read"}});hn(o);let a=new pe(o,r);try{let c=[];for(let l=1;l<=10;l++){let u=await a.json("GET",`/installation/repositories?per_page=100&page=${l}`);if(c.push(...u.repositories.map((p)=>p.full_name)),u.repositories.length<100)return c}throw new v("the App is installed on more than 1000 repositories","Install it only on the projects tapster.yml lists.")}finally{await a.request("DELETE","/installation/token").catch(()=>{return})}}var Ug=`- name: Ring the tapster hub
195
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let o of e.seen.entries()){let a=o[1];if(t===o[0]){s(o);continue}if(e.external){let l=e.external.registry.get(o[0])?.id;if(t!==o[0]&&l){s(o);continue}}if(e.metadataRegistry.get(o[0])?.id){s(o);continue}if(a.cycle){s(o);continue}if(a.count>1){if(e.reused==="ref")s(o)}}if(e.external)e.sharedDefsExtractedFor=e.external}function im(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let n=[];for(let r of t){if(!r||typeof r!=="object")return;im(r);let i=Object.keys(r);if(i.length!==1||i[0]!=="type")return;let s=r.type;for(let o of Array.isArray(s)?s:[s]){if(typeof o!=="string")return;if(!n.includes(o))n.push(o)}}delete e.anyOf,e.type=n.length===1?n[0]:n}var sm=new Set(["type","properties","required","additionalProperties"]),nm=["oneOf","anyOf"];function rm(e){let t=e.additionalProperties;if(t===void 0||t===!1||typeof t!=="object"||t===null)return null;return Object.keys(t).length?t:null}function Fa(e){let t=[];for(let s of e){if(typeof s!=="object"||s.type!=="object")return null;for(let o in s)if(!sm.has(o))return null;t.push(s)}let n={},r=new Set;for(let s of t){for(let o in s.properties){if(Object.prototype.hasOwnProperty.call(n,o))continue;let a=[];for(let l of t){let u=l.properties?.[o]??rm(l);if(u===null||u===void 0)continue;if(!a.some((p)=>JSON.stringify(p)===JSON.stringify(u)))a.push(u)}let c=a.length===1?a[0]:Fa(a)??{allOf:a};ge(n,o,c)}for(let o of s.required??[])r.add(o)}let i={type:"object",properties:n};if(r.size)i.required=[...r];if(t.every((s)=>s.additionalProperties===!1))i.additionalProperties=!1;else{let s=[];for(let o of t){let a=rm(o);if(a&&!s.some((c)=>JSON.stringify(c)===JSON.stringify(a)))s.push(a)}if(s.length===1)i.additionalProperties=s[0];else if(s.length>1)i.additionalProperties={allOf:s}}return i}function C$(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let i of sm)if(i in e)return;let n=t.filter((i)=>nm.some((s)=>Array.isArray(i[s]))),r=null;if(!n.length)r=Fa(t);else{let i=n[0],s=nm.find((c)=>Array.isArray(i[c]));if(Object.keys(i).length!==1)return;let o=t.filter((c)=>c!==i),a=i[s].map((c)=>Fa([...o,c]));if(a.some((c)=>!c))return;r={[s]:a}}if(!r)return;delete e.allOf,cr(e,r)}function dr(e,t){let n=e.seen.get(t);if(!n)throw Error("Unprocessed schema. This is a bug in Zod.");let r=(a)=>{let c=e.seen.get(a);if(c.ref===null)return;let l=c.def??c.schema,u={...l},p=c.ref;if(c.ref=null,p){r(p);let h=e.seen.get(p),f=h.schema;if(f.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"))l.allOf=l.allOf??[],l.allOf.push(f);else cr(l,f);if(cr(l,u),a._zod.parent===p)for(let g in l){if(g==="$ref"||g==="allOf")continue;if(!(g in u))delete l[g]}if(f.$ref&&h.def)for(let g in l){if(g==="$ref"||g==="allOf")continue;if(g in h.def&&JSON.stringify(l[g])===JSON.stringify(h.def[g]))delete l[g]}}let d=a._zod.parent;if(d&&d!==p){r(d);let h=e.seen.get(d);if(h?.schema.$ref){if(l.$ref=h.schema.$ref,h.def)for(let f in l){if(f==="$ref"||f==="allOf")continue;if(f in h.def&&JSON.stringify(l[f])===JSON.stringify(h.def[f]))delete l[f]}}}e.override({zodSchema:a,jsonSchema:l,path:c.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let a of[...e.seen.entries()].reverse())r(a[0]);if(e.target!=="openapi-3.0")for(let a of e.seen.entries())im(a[1].def??a[1].schema);for(let a of e.deferred)a();if(e.intersections.length){let a=new Map;for(let c of e.seen.values())for(let l of[c.schema,c.def]){let u=l?.allOf;if(!Array.isArray(u))continue;let p=a.get(u);if(p)p.push(l);else a.set(u,[l])}for(let c of e.intersections)for(let l of a.get(c)??[])C$(l)}}let i={};if(e.target==="draft-2020-12")i.$schema="https://json-schema.org/draft/2020-12/schema";else if(e.target==="draft-07")i.$schema="http://json-schema.org/draft-07/schema#";else if(e.target==="draft-04")i.$schema="http://json-schema.org/draft-04/schema#";else if(e.target==="openapi-3.0");if(e.external?.uri){let a=e.external.registry.get(t)?.id;if(!a)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(a)}cr(i,n.defId?n.schema:n.def??n.schema);let s=e.metadataRegistry.get(t)?.id;if(s!==void 0&&i.id===s)delete i.id;let o=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let a of e.seen.entries()){let c=a[1];if(c.def&&c.defId){if(c.def.id===c.defId)delete c.def.id;ge(o,c.defId,c.def)}}if(e.external)e.sharedEmitDoneFor=e.external;if(e.external);else if(Object.keys(o).length>0)if(e.target==="draft-2020-12")i.$defs=o;else i.definitions=o;try{let a=JSON.parse(JSON.stringify(i));return Object.defineProperty(a,"~standard",{value:{...t["~standard"],jsonSchema:{input:lr(t,"input",e.processors),output:lr(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch(a){throw Error("Error converting schema to JSON.")}}function ue(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return ue(r.element,n);if(r.type==="set")return ue(r.valueType,n);if(r.type==="lazy")return ue(r.getter(),n);if(r.type==="promise"||r.type==="optional"||r.type==="nonoptional"||r.type==="nullable"||r.type==="readonly"||r.type==="default"||r.type==="prefault"||r.type==="catch")return ue(r.innerType,n);if(r.type==="intersection")return ue(r.left,n)||ue(r.right,n);if(r.type==="record"||r.type==="map")return ue(r.keyType,n)||ue(r.valueType,n);if(r.type==="pipe"){if(e._zod.traits.has("$ZodCodec"))return!0;return ue(r.in,n)||ue(r.out,n)}if(r.type==="object"){for(let i in r.shape)if(ue(r.shape[i],n))return!0;return!1}if(r.type==="union"){for(let i of r.options)if(ue(i,n))return!0;return!1}if(r.type==="tuple"){for(let i of r.items)if(ue(i,n))return!0;if(r.rest&&ue(r.rest,n))return!0;return!1}return!1}var om=(e,t={})=>(n)=>{let r=ur({...n,processors:t});return U(e,r),pr(r,e),dr(r,e)},lr=(e,t,n={})=>(r)=>{let{libraryOptions:i,target:s}=r??{},o=ur({...i??{},target:s,io:t,processors:n});return U(e,o),pr(o,e),dr(o,e)};var cn=(e,t,n)=>{if(e[t]===void 0||n>e[t])e[t]=n},ln=(e,t,n)=>{if(e[t]===void 0||n<e[t])e[t]=n},am=(e,t)=>{cn(e,"minimum",t),ln(e,"maximum",t)},dm=(e,t)=>{if(e.multipleOf??(e.multipleOf=[]),!e.multipleOf.includes(t))e.multipleOf.push(t)},hm=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},fm=(e,t)=>{e.mime=e.mime?e.mime.filter((n)=>t.includes(n)):[...t]},mm=(e,t)=>{if(e.format=t,t.includes("int"))e.isInt=!0},cm=(e,t)=>cn(e,"minimum",t.minimum),lm=(e,t)=>ln(e,"maximum",t.maximum),um=(e)=>(t,n)=>{mm(t,n.format);let[r,i]=e[n.format];cn(t,"minimum",r),ln(t,"maximum",i)},R$={greater_than:(e,t)=>cn(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>ln(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>dm(e,t.value),number_format:um(Pi),bigint_format:um(ua),min_length:cm,max_length:lm,length_equals:(e,t)=>am(e,t.length),min_size:cm,max_size:lm,size_equals:(e,t)=>am(e,t.size),string_format:(e,t)=>{if(mm(e,t.format),t.pattern)hm(e,t.pattern);if(t.format==="base64"||t.format==="base64url")e.contentEncoding=t.format;if(t.local||t.precision===-1)e.laxFormat=!0},mime_type:(e,t)=>fm(e,t.mime)};function fe(e){let t={},n=e._zod.def,r=e._zod.traits.has("$ZodCheck")?[e,...n.checks??[]]:n.checks??[];for(let s of r)R$[s._zod.def.check]?.(t,s._zod.def);let i=e._zod.bag;if(i.minimum!==void 0)cn(t,"minimum",i.minimum);if(i.exclusiveMinimum!==void 0)cn(t,"exclusiveMinimum",i.exclusiveMinimum);if(i.maximum!==void 0)ln(t,"maximum",i.maximum);if(i.exclusiveMaximum!==void 0)ln(t,"exclusiveMaximum",i.exclusiveMaximum);if(i.multipleOf!==void 0)dm(t,i.multipleOf);if(i.format!==void 0){if(t.format??(t.format=i.format),i.format.includes("int"))t.isInt=!0}if(i.mime)fm(t,i.mime);for(let s of i.patterns??[])hm(t,s);return t}var I$={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},N$=new Map([[$a,Ed],[qi,Od]]),gm=(e)=>N$.get(e)??e,Va=(e,t,n,r)=>{let i=n;i.type="string";let{minimum:s,maximum:o,format:a,patterns:c,contentEncoding:l,laxFormat:u}=fe(e);if(typeof s==="number")i.minLength=s;if(typeof o==="number")i.maxLength=o;if(a){if(i.format=I$[a]??a,i.format==="")delete i.format;if(a==="time"||u)delete i.format}if(l)i.contentEncoding=l;if(c&&c.size>0){let p=[...c].map(gm);if(p.length===1)i.pattern=p[0].source;else if(p.length>1)i.allOf=[...p.map((d)=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:d.source}))]}},Ya=(e,t,n,r)=>{let i=n,{minimum:s,maximum:o,multipleOf:a,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=fe(e);i.type=u?"integer":"number";let p=typeof l==="number"&&l>=(s??Number.NEGATIVE_INFINITY),d=typeof c==="number"&&c<=(o??Number.POSITIVE_INFINITY),h=t.target==="draft-04"||t.target==="openapi-3.0";if(p)if(h)i.minimum=l,i.exclusiveMinimum=!0;else i.exclusiveMinimum=l;else if(typeof s==="number")i.minimum=s;if(d)if(h)i.maximum=c,i.exclusiveMaximum=!0;else i.exclusiveMaximum=c;else if(typeof o==="number")i.maximum=o;if(a){let f=new Set;for(let w of a)if(Number.isFinite(w)&&w!==0)f.add(Math.abs(w));else Q(e,t,i,r,`A multipleOf divisor of ${w} cannot be represented in JSON Schema`);let[m,...g]=f;if(m!==void 0)i.multipleOf=m;if(g.length)i.allOf=[...i.allOf??[],...g.map((w)=>({multipleOf:w}))]}},Ja=(e,t,n,r)=>{n.type="boolean"},vm=(e,t,n,r)=>{Q(e,t,n,r,"BigInt cannot be represented in JSON Schema")},ym=(e,t,n,r)=>{Q(e,t,n,r,"Symbols cannot be represented in JSON Schema")},bm=(e,t,n,r)=>{if(t.target==="openapi-3.0")n.type="string",n.nullable=!0,n.enum=[null];else n.type="null"},wm=(e,t,n,r)=>{Q(e,t,n,r,"Undefined cannot be represented in JSON Schema")},_m=(e,t,n,r)=>{Q(e,t,n,r,"Void cannot be represented in JSON Schema")},Qa=(e,t,n,r)=>{n.not={}},km=(e,t,n,r)=>{},Xa=(e,t,n,r)=>{},xm=(e,t,n,r)=>{Q(e,t,n,r,"Date cannot be represented in JSON Schema")},ec=(e,t,n,r)=>{let i=e._zod.def,s=Yn(i.entries);if(s.length===0){n.not={};return}if(s.every((o)=>typeof o==="number"))n.type="number";if(s.every((o)=>typeof o==="string"))n.type="string";n.enum=s},tc=(e,t,n,r)=>{let i=e._zod.def;if(i.values.length===0){n.not={};return}let s=[];for(let o of i.values)if(o===void 0){if(Q(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof o==="bigint"){if(Q(e,t,n,r,"BigInt literals cannot be represented in JSON Schema"))return;s.push(Number(o))}else s.push(o);if(s.length===0);else if(s.length===1){let o=s[0];if(n.type=o===null?"null":typeof o,t.target==="draft-04"||t.target==="openapi-3.0")n.enum=[o];else n.const=o}else{if(s.every((o)=>typeof o==="number"))n.type="number";if(s.every((o)=>typeof o==="string"))n.type="string";if(s.every((o)=>typeof o==="boolean"))n.type="boolean";if(s.every((o)=>o===null))n.type="null";n.enum=s}},Sm=(e,t,n,r)=>{Q(e,t,n,r,"NaN cannot be represented in JSON Schema")},Am=(e,t,n,r)=>{let i=n,s=e._zod.pattern;if(!s)throw Error("Pattern not found in template literal");i.type="string",i.pattern=s.source},$m=(e,t,n,r)=>{let i=n;i.type="string",i.format="binary",i.contentEncoding="binary";let{minimum:s,maximum:o,mime:a}=fe(e);if(s!==void 0)i.minLength=s;if(o!==void 0)i.maxLength=o;if(!a)return;if(a.length===0)i.not={};else if(a.length===1)i.contentMediaType=a[0];else i.anyOf=a.map((c)=>({contentMediaType:c}))},Pm=(e,t,n,r)=>{n.type="boolean"},nc=(e,t,n,r)=>{Q(e,t,n,r,"Custom types cannot be represented in JSON Schema")},Tm=(e,t,n,r)=>{Q(e,t,n,r,"Function types cannot be represented in JSON Schema")},rc=(e,t,n,r)=>{Q(e,t,n,r,"Transforms cannot be represented in JSON Schema")},Em=(e,t,n,r)=>{Q(e,t,n,r,"Map cannot be represented in JSON Schema")},Om=(e,t,n,r)=>{Q(e,t,n,r,"Set cannot be represented in JSON Schema")},ic=(e,t,n,r)=>{let i=n,s=e._zod.def,{minimum:o,maximum:a}=fe(e);if(typeof o==="number")i.minItems=o;if(typeof a==="number")i.maxItems=a;i.type="array",i.items=U(s.element,t,{...r,path:[...r.path,"items"]})};function hr(e){let t=e._zod.def;if(t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform"))return hr(t.out);if(t.type==="catch")return hr(t.innerType);return e._zod.optin}var sc=(e,t,n,r)=>{let i=n,s=e._zod.def,o=s.shape;if(Object.getOwnPropertySymbols(o).length&&Q(e,t,i,r,"Symbol keys cannot be represented in JSON Schema"))return;i.type="object",i.properties={};for(let l in o)ge(i.properties,l,U(o[l],t,{...r,path:[...r.path,"properties",l]}));let c=[];for(let l of Object.keys(o)){let u=s.shape[l];if(t.io==="input"?hr(u)===void 0:u._zod.optout===void 0)c.push(l)}if(c.length>0)i.required=c;if(s.catchall?._zod.def.type==="never")i.additionalProperties=!1;else if(!s.catchall){if(t.io==="output")i.additionalProperties=!1}else if(s.catchall)i.additionalProperties=U(s.catchall,t,{...r,path:[...r.path,"additionalProperties"]})},oc=(e,t,n,r)=>{let i=e._zod.def,s=i.inclusive===!1,o=i.options.map((a,c)=>U(a,t,{...r,path:[...r.path,s?"oneOf":"anyOf",c]}));if(s)n.oneOf=o;else n.anyOf=o},ac=(e,t,n,r)=>{let i=e._zod.def,s=U(i.left,t,{...r,path:[...r.path,"allOf",0]}),o=U(i.right,t,{...r,path:[...r.path,"allOf",1]}),a=(l)=>("allOf"in l)&&Object.keys(l).length===1,c=[...a(s)?s.allOf:[s],...a(o)?o.allOf:[o]];n.allOf=c,t.intersections.push(c)},cc=(e,t,n,r)=>{let i=n,s=e._zod.def;i.type="array";let o=t.target==="draft-2020-12"?"prefixItems":"items",a=t.target==="draft-2020-12"?"items":t.target==="openapi-3.0"?"items":"additionalItems",c=s.items.map((m,g)=>U(m,t,{...r,path:[...r.path,o,g]})),l=s.rest?U(s.rest,t,{...r,path:[...r.path,a,...t.target==="openapi-3.0"?[s.items.length]:[]]}):null,u=s.items.length;while(u>0){let m=s.items[u-1];if(!(t.io==="input"?hr(m)!==void 0:m._zod.optout==="optional"))break;u--}let p=s.items.length,d=!s.rest;if(t.target==="draft-2020-12"){if(i.prefixItems=c,d)i.items=!1;else if(l)i.items=l;if(u>0)i.minItems=u;if(d)i.maxItems=p}else if(t.target==="openapi-3.0"){if(i.items={anyOf:c},l)i.items.anyOf.push(l);if(u>0)i.minItems=u;if(d)i.maxItems=p}else{if(i.items=c,d)i.additionalItems=!1;else if(l)i.additionalItems=l;if(u>0)i.minItems=u;if(d)i.maxItems=p}let{minimum:h,maximum:f}=fe(e);if(typeof h==="number")i.minItems=h;if(typeof f==="number")i.maxItems=f};function Ka(e,t,n){if(t.$ref){if(n.has(t))return t;n.add(t);let f=e.get(t)?.def;if(!f)return t;let m=Ka(e,f,n);return m===f?t:m}for(let f of["anyOf","oneOf"]){let m=t[f];if(!Array.isArray(m))continue;let g=m.map((w)=>Ka(e,w,n));if(g.some((w,k)=>w!==m[k]))t={...t,[f]:g}}let r=Array.isArray(t.type)?t.type:[t.type],i=!r.includes("string")&&r.some((f)=>f==="number"||f==="integer"),s=t.enum??(t.const!==void 0?[t.const]:void 0);if(!i&&!s?.some((f)=>typeof f==="number"))return t;let{minimum:o,maximum:a,exclusiveMinimum:c,exclusiveMaximum:l,multipleOf:u,format:p,id:d,...h}=t;if(h.enum)h.enum=h.enum.map((f)=>typeof f==="number"?String(f):f);else if(typeof h.const==="number")h.const=String(h.const);if(!i)return h;if(h.type="string",!s)h.pattern=(r.includes("number")?tr:ba).source;return h}var Wa=new WeakMap;function z$(e){let t=new Map;for(let r of e.seen.values())if(r.def&&!t.has(r.schema))t.set(r.schema,r);let n=new Map;for(let r of Wa.get(e)??[]){let i=e.seen.get(r),s=(i?.def??i?.schema)?.propertyNames;if(!s||s===!0||n.has(s))continue;let o=Ka(t,s,new Set);if(o!==s)n.set(s,o)}if(!n.size)return;for(let r of e.seen.values())for(let i of[r.schema,r.def]){let s=i&&n.get(i.propertyNames);if(s)i.propertyNames=s}}var lc=(e,t,n,r)=>{let i=n,s=e._zod.def;i.type="object";let o=s.keyType,a=fe(o).patterns;if(s.mode==="loose"&&a&&a.size>0){let u=U(s.valueType,t,{...r,path:[...r.path,"patternProperties","*"]});i.patternProperties={};for(let p of a)ge(i.patternProperties,gm(p).source,u)}else{if(t.target==="draft-07"||t.target==="draft-2020-12"){i.propertyNames=U(s.keyType,t,{...r,path:[...r.path,"propertyNames"]});let u=Wa.get(t);if(!u)u=[],Wa.set(t,u),t.deferred.push(()=>z$(t));u.push(e)}i.additionalProperties=U(s.valueType,t,{...r,path:[...r.path,"additionalProperties"]})}let c=o._zod.values,l=t.io==="input"&&hr(s.valueType)!==void 0;if(c&&!s.partial&&!l){let u=[...c].filter((p)=>typeof p==="string"||typeof p==="number");if(u.length>0)i.required=u.map(String)}},uc=(e,t,n,r)=>{let i=e._zod.def,s=U(i.innerType,t,r),o=t.seen.get(e);if(t.target==="openapi-3.0")o.ref=i.innerType,n.nullable=!0;else n.anyOf=[s,{type:"null"}]},pc=(e,t,n,r)=>{let i=e._zod.def;U(i.innerType,t,r);let s=t.seen.get(e);s.ref=i.innerType},dc=Symbol();function Cm(e,t,n,r,i){let s=!1,o=JSON.stringify(e,(a,c)=>{if(typeof c!=="bigint")return c;return s=!0,null});if(!s)return JSON.parse(o);return Q(t,n,r,i,"BigInt defaults cannot be represented in JSON Schema"),dc}var hc=(e,t,n,r)=>{let i=e._zod.def;U(i.innerType,t,r);let s=t.seen.get(e);s.ref=i.innerType;let o=Cm(i.defaultValue,e,t,n,r);if(o!==dc)n.default=o},fc=(e,t,n,r)=>{let i=e._zod.def;U(i.innerType,t,r);let s=t.seen.get(e);if(s.ref=i.innerType,t.io!=="input")return;let o=Cm(i.defaultValue,e,t,n,r);if(o!==dc)n._prefault=o},mc=(e,t,n,r)=>{let i=e._zod.def;U(i.innerType,t,r);let s=t.seen.get(e);s.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{Q(e,t,n,r,"Dynamic catch values are not supported in JSON Schema");return}n.default=o},gc=(e,t,n,r)=>{let i=e._zod.def,s=i.in._zod.traits.has("$ZodTransform"),o=t.io==="input"?s?i.out:i.in:i.out;U(o,t,r);let a=t.seen.get(e);a.ref=o},vc=(e,t,n,r)=>{let i=e._zod.def;U(i.innerType,t,r);let s=t.seen.get(e);s.ref=i.innerType,n.readOnly=!0},Rm=(e,t,n,r)=>{let i=e._zod.def;U(i.innerType,t,r);let s=t.seen.get(e);s.ref=i.innerType},Xi=(e,t,n,r)=>{let i=e._zod.def;U(i.innerType,t,r);let s=t.seen.get(e);s.ref=i.innerType},Im=(e,t,n,r)=>{let i=e._zod.innerType;U(i,t,r);let s=t.seen.get(e);s.ref=i},pm={string:Va,number:Ya,boolean:Ja,bigint:vm,symbol:ym,null:bm,undefined:wm,void:_m,never:Qa,any:km,unknown:Xa,date:xm,enum:ec,literal:tc,nan:Sm,template_literal:Am,file:$m,success:Pm,custom:nc,function:Tm,transform:rc,map:Em,set:Om,array:ic,object:sc,union:oc,intersection:ac,tuple:cc,record:lc,nullable:uc,nonoptional:pc,default:hc,prefault:fc,catch:mc,pipe:gc,readonly:vc,promise:Rm,optional:Xi,lazy:Im};function Nm(e,t){if("_idmap"in e){let r=e,i=ur({...t,processors:pm}),s={};for(let c of r._idmap.entries()){let[l,u]=c;U(u,i)}let o={},a={registry:r,uri:t?.uri,defs:s};i.external=a;for(let c of r._idmap.entries()){let[l,u]=c;pr(i,u),ge(o,l,dr(i,u))}if(Object.keys(s).length>0){let c=i.target==="draft-2020-12"?"$defs":"definitions";o.__shared={[c]:s}}return{schemas:o}}let n=ur({...t,processors:pm});return U(e,n),pr(n,e),dr(n,e)}var zm=new WeakSet([Object.prototype,Error.prototype]);function ts(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let r=n(this);return Object.defineProperty(this,t,{value:r,configurable:!0,writable:!0}),r},set(r){Object.defineProperty(this,t,{value:r,configurable:!0,writable:!0})}})}var B$=(e,t)=>{nd.init(e,t),e.name="ZodError";let n=Object.getPrototypeOf(e);if(zm.has(n))return;zm.add(n),ts(n,"format",(r)=>(i)=>id(r,i)),ts(n,"flatten",(r)=>(i)=>rd(r,i)),ts(n,"addIssue",(r)=>(i)=>{r.issues.push(i),r.message=JSON.stringify(r.issues,Jn,2)}),ts(n,"addIssues",(r)=>(i)=>{r.issues.push(...i),r.message=JSON.stringify(r.issues,Jn,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}})};var be=b("ZodError",B$,void 0,{Parent:Error});var Lm=Ni(be),jm=zi(be),Dm=Li(be),Mm=ji(be),Um=od(be),Zm=ad(be),Gm=cd(be),qm=ld(be),Bm=ud(be),Hm=pd(be),Fm=dd(be),Km=hd(be);function F$(){if(!le.localeError)ye(Ia())}function fr(){if(!le.memoizer)ye({memoizer:vf()})}var q=b("ZodType",(e,t)=>(F$(),Z.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(ve(t,{checks:[...t.checks??[],...e.map((n)=>typeof n==="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return Me(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(qP(e,t))},superRefine(e,t){return this.check(BP(e,t))},overwrite(e){return this.check(_t(e))},optional(){return Vm(this)},exactOptional(){return OP(this)},nullable(){return Ym(this)},nullish(){return Vm(Ym(this))},nonoptional(e){return LP(this,e)},array(){return X(this)},or(e){return rg([this,e])},and(e){return AP(this,e)},transform(e){return Jm(this,ig(e))},default(e){return IP(this,e)},prefault(e){return zP(this,e)},catch(e){return DP(this,e)},pipe(e){return Jm(this,e)},readonly(){return ZP(this)},describe(e){let t=this.clone();return Mt.add(t,{description:e}),t},meta(...e){if(e.length===0)return Mt.get(this);let t=this.clone();return Mt.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get "~standard"(){return Ri(this,"~standard",{...Aa(this),jsonSchema:{input:lr(this,"input"),output:lr(this,"output")}})},set "~standard"(e){et(this,"~standard",e)},parse:function e(t,n){return Lm(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await jm(this,t,n,{callee:e})},safeParse(e,t){return Dm(this,e,t)},async safeParseAsync(e,t){return Mm(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){et(this,"spa",e)},validate(e,t){return ma(this,e,t)},validateAsync(e,t){return ga(this,e,t)},encode:function e(t,n){return Um(this,t,n,{callee:e})},decode:function e(t,n){return Zm(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await Gm(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await qm(this,t,n,{callee:e})},safeEncode(e,t){return Bm(this,e,t)},safeDecode(e,t){return Hm(this,e,t)},async safeEncodeAsync(e,t){return Fm(this,e,t)},async safeDecodeAsync(e,t){return Km(this,e,t)},toJSONSchema(e){return om(this,{})(e)},get description(){return Mt.get(this)?.description},get _def(){return this._zod.def}}),Qm=b("_ZodString",(e,t)=>{Gi.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Va(e,n,r,i)},Yp({format:(e)=>fe(e).format??null,minLength:(e)=>fe(e).minimum??null,maxLength:(e)=>fe(e).maximum??null},{regex(...e){return this.check(za(...e))},includes(...e){return this.check(Da(...e))},startsWith(...e){return this.check(Ma(...e))},endsWith(...e){return this.check(Ua(...e))},min(...e){return this.check(an(...e))},max(...e){return this.check(Ji(...e))},length(...e){return this.check(Qi(...e))},nonempty(...e){return this.check(an(1,...e))},lowercase(e){return this.check(La(e))},uppercase(e){return this.check(ja(e))},trim(){return this.check(Ga())},normalize(...e){return this.check(Za(...e))},toLowerCase(){return this.check(qa())},toUpperCase(){return this.check(Ba())},slugify(){return this.check(Ha())}})),K$=b("ZodString",(e,t)=>{Gi.init(e,t),Qm.init(e,t)},{email(e){return this.check(kf(Q$,e))},url(e){return this.check(Na(Xm,e))},jwt(e){return this.check(Gf(fP,e))},emoji(e){return this.check(Tf(eP,e))},guid(e){return this.check(xf(X$,e))},uuid(e){return this.check(Sf(ns,e))},uuidv4(e){return this.check(Af(ns,e))},uuidv6(e){return this.check($f(ns,e))},uuidv7(e){return this.check(Pf(ns,e))},nanoid(e){return this.check(Ef(tP,e))},cuid(e){return this.check(Of(nP,e))},cuid2(e){return this.check(Cf(rP,e))},ulid(e){return this.check(Rf(iP,e))},base64(e){return this.check(Mf(pP,e))},base64url(e){return this.check(Uf(dP,e))},xid(e){return this.check(If(sP,e))},ksuid(e){return this.check(Nf(oP,e))},ipv4(e){return this.check(zf(aP,e))},ipv6(e){return this.check(Lf(cP,e))},cidrv4(e){return this.check(jf(lP,e))},cidrv6(e){return this.check(Df(uP,e))},e164(e){return this.check(Zf(hP,e))},datetime(e){return this.check(qf(W$,e))},date(e){return this.check(Bf(V$,e))},time(e){return this.check(Hf(Y$,e))},duration(e){return this.check(Ff(J$,e))}});function E(e){return _f(K$,e)}var H=b("ZodStringFormat",(e,t)=>{G.init(e,t),Qm.init(e,t)}),W$=b("ZodISODateTime",(e,t)=>{Th.init(e,t),H.init(e,t)}),V$=b("ZodISODate",(e,t)=>{Eh.init(e,t),H.init(e,t)}),Y$=b("ZodISOTime",(e,t)=>{Oh.init(e,t),H.init(e,t)}),J$=b("ZodISODuration",(e,t)=>{Ch.init(e,t),H.init(e,t)}),Q$=b("ZodEmail",(e,t)=>{vh.init(e,t),H.init(e,t)});var X$=b("ZodGUID",(e,t)=>{mh.init(e,t),H.init(e,t)});var ns=b("ZodUUID",(e,t)=>{gh.init(e,t),H.init(e,t)});var Xm=b("ZodURL",(e,t)=>{wh.init(e,t),H.init(e,t)});function eg(e){return Na(Xm,e)}var eP=b("ZodEmoji",(e,t)=>{_h.init(e,t),H.init(e,t)});var tP=b("ZodNanoID",(e,t)=>{kh.init(e,t),H.init(e,t)});var nP=b("ZodCUID",(e,t)=>{xh.init(e,t),H.init(e,t)});var rP=b("ZodCUID2",(e,t)=>{Sh.init(e,t),H.init(e,t)});var iP=b("ZodULID",(e,t)=>{Ah.init(e,t),H.init(e,t)});var sP=b("ZodXID",(e,t)=>{$h.init(e,t),H.init(e,t)});var oP=b("ZodKSUID",(e,t)=>{Ph.init(e,t),H.init(e,t)});var aP=b("ZodIPv4",(e,t)=>{Rh.init(e,t),H.init(e,t)});var cP=b("ZodIPv6",(e,t)=>{Nh.init(e,t),H.init(e,t)});var lP=b("ZodCIDRv4",(e,t)=>{zh.init(e,t),H.init(e,t)});var uP=b("ZodCIDRv6",(e,t)=>{Lh.init(e,t),H.init(e,t)});var pP=b("ZodBase64",(e,t)=>{Dh.init(e,t),H.init(e,t)});var dP=b("ZodBase64URL",(e,t)=>{Mh.init(e,t),H.init(e,t)});var hP=b("ZodE164",(e,t)=>{Uh.init(e,t),H.init(e,t)});var fP=b("ZodJWT",(e,t)=>{Zh.init(e,t),H.init(e,t)});var tg=b("ZodNumber",(e,t)=>{Pa.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Ya(e,n,r,i),e.isFinite=!0},Yp({minValue:(e)=>{let{minimum:t,exclusiveMinimum:n}=fe(e);return Math.max(t??Number.NEGATIVE_INFINITY,n??Number.NEGATIVE_INFINITY)},maxValue:(e)=>{let{maximum:t,exclusiveMaximum:n}=fe(e);return Math.min(t??Number.POSITIVE_INFINITY,n??Number.POSITIVE_INFINITY)},isInt:(e)=>{let{isInt:t,multipleOf:n}=fe(e);return!!t||!!n?.some(Number.isSafeInteger)},format:(e)=>fe(e).format??null},{gt(e,t){return this.check(Vi(e,t))},gte(e,t){return this.check(ar(e,t))},min(e,t){return this.check(ar(e,t))},lt(e,t){return this.check(Wi(e,t))},lte(e,t){return this.check(or(e,t))},max(e,t){return this.check(or(e,t))},int(e){return this.check(Wm(e))},safe(e){return this.check(Wm(e))},positive(e){return this.check(Vi(0,e))},nonnegative(e){return this.check(ar(0,e))},negative(e){return this.check(Wi(0,e))},nonpositive(e){return this.check(or(0,e))},multipleOf(e,t){return this.check(Yi(e,t))},step(e,t){return this.check(Yi(e,t))},finite(){return this}}));function _c(e){return Kf(tg,e)}var mP=b("ZodNumberFormat",(e,t)=>{Gh.init(e,t),tg.init(e,t)});function Wm(e){return Wf(mP,e)}var gP=b("ZodBoolean",(e,t)=>{qh.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Ja(e,n,r,i)});function tt(e){return Vf(gP,e)}var vP=b("ZodUnknown",(e,t)=>{Bh.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Xa(e,n,r,i)});function yc(){return Yf(vP)}var yP=b("ZodNever",(e,t)=>{Hh.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Qa(e,n,r,i)});function bP(e){return Jf(yP,e)}var wP=b("ZodArray",(e,t)=>{fr(),Fh.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,r,i)=>ic(e,n,r,i),e.element=t.element},{min(e,t){return this.check(an(e,t))},nonempty(e){return this.check(an(1,e))},max(e,t){return this.check(Ji(e,t))},length(e,t){return this.check(Qi(e,t))},unwrap(){return this.element}});function X(e,t){return Qf(wP,e,t)}var _P=b("ZodObject",(e,t)=>{fr(),Vh.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,r,i)=>sc(e,n,r,i),JA(e,"shape",(n)=>n._zod.def.shape,!1)},{keyof(){return kt(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(ve(this._zod.def,{catchall:e}))},passthrough(){return this.clone(ve(this._zod.def,{catchall:yc()}))},loose(){return this.clone(ve(this._zod.def,{catchall:yc()}))},strict(){return this.clone(ve(this._zod.def,{catchall:bP()}))},strip(){return this.clone(ve(this._zod.def,{catchall:void 0}))},extend(e){return qA(this,e)},safeExtend(e){return BA(this,e)},merge(e){return HA(this,e)},pick(e){return ZA(this,e)},omit(e){return GA(this,e)},partial(...e){return Fp(Sc,this,e[0])},exactPartial(...e){return Fp(sg,this,e[0],"exactPartial")},required(...e){return FA(og,this,e[0])}});function N(e,t){let n={type:"object",shape:e??{},...T(t)};return new _P(n)}var ng=b("ZodUnion",(e,t)=>{Ta.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,r,i)=>oc(e,n,r,i),e.options=t.options});function rg(e,t){return new ng({type:"union",options:e,...T(t)})}var kP=b("ZodDiscriminatedUnion",(e,t)=>{ng.init(e,t),Yh.init(e,t)});function xP(e,t,n){return new kP({type:"union",options:t,discriminator:e,...T(n)})}var SP=b("ZodIntersection",(e,t)=>{Jh.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,r,i)=>ac(e,n,r,i)});function AP(e,t){return new SP({type:"intersection",left:e,right:t})}var $P=b("ZodTuple",(e,t)=>{fr(),Qh.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,r,i)=>cc(e,n,r,i)},{rest(e){return this.clone({...this._zod.def,rest:e})},partial(){let e=this._zod.def;if(e.checks?.length)throw Error(".partial() cannot be used on tuple schemas containing refinements");return this.clone({...e,items:e.items.map((t)=>new Sc({type:"optional",innerType:t}))})}});function kc(e,t,n){let r=t instanceof Z,i=r?n:t;return new $P({type:"tuple",items:e,rest:r?t:null,...T(i)})}var bc=b("ZodRecord",(e,t)=>{fr(),Xh.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,r,i)=>lc(e,n,r,i),e.keyType=t.keyType,e.valueType=t.valueType});function rs(e,t,n){if(!t||!t._zod)return new bc({type:"record",keyType:E(),valueType:e,...T(t)});return new bc({type:"record",keyType:e,valueType:t,...T(n)})}function PP(e,t,n){return new bc({type:"record",keyType:e,valueType:t,...T(n),partial:!0})}var wc=b("ZodEnum",(e,t)=>{ef.init(e,t),q.init(e,t),e._zod.processJSONSchema=(r,i,s)=>ec(e,r,i,s),e.enum=t.entries,e.options=[...e._zod.values];let n=new Set(Object.keys(t.entries));e.extract=(r,i)=>{let s={};for(let o of r)if(n.has(o))s[o]=t.entries[o];else throw Error(`Key ${o} not found in enum`);return new wc({...t,checks:[],...T(i),entries:s})},e.exclude=(r,i)=>{let s={...t.entries};for(let o of r)if(n.has(o))delete s[o];else throw Error(`Key ${o} not found in enum`);return new wc({...t,checks:[],...T(i),entries:s})}});function kt(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map((r)=>[r,r])):e;return new wc({type:"enum",entries:n,...T(t)})}var TP=b("ZodLiteral",(e,t)=>{tf.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,r,i)=>tc(e,n,r,i),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function xc(e,t){return new TP({type:"literal",values:Array.isArray(e)?e:[e],...T(t)})}var EP=b("ZodTransform",(e,t)=>{fr(),nf.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,r,i)=>rc(e,n,r,i),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new er(e.constructor.name);n.addIssue=(s)=>{if(typeof s==="string")n.issues.push(Dt(s,n.value,t));else{let o=s;if(o.fatal)o.continue=!1;if(o.code??(o.code="custom"),!("input"in o))o.input=n.value;o.inst??(o.inst=e),n.issues.push(Dt(o))}};let i=t.transform(n.value,n);if(i instanceof Promise)return i.then((s)=>(n.value=s,n));return n.value=i,n}});function ig(e){return new EP({type:"transform",transform:e})}var Sc=b("ZodOptional",(e,t)=>{Ea.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Xi(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function Vm(e){return new Sc({type:"optional",innerType:e})}var sg=b("ZodExactOptional",(e,t)=>{rf.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Xi(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function OP(e){return new sg({type:"optional",innerType:e})}var CP=b("ZodNullable",(e,t)=>{sf.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,r,i)=>uc(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function Ym(e){return new CP({type:"nullable",innerType:e})}var RP=b("ZodDefault",(e,t)=>{of.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,r,i)=>hc(e,n,r,i),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function IP(e,t){return new RP({type:"default",innerType:e,get defaultValue(){return typeof t==="function"?t():ca(t)}})}var NP=b("ZodPrefault",(e,t)=>{af.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,r,i)=>fc(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function zP(e,t){return new NP({type:"prefault",innerType:e,get defaultValue(){return typeof t==="function"?t():ca(t)}})}var og=b("ZodNonOptional",(e,t)=>{cf.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,r,i)=>pc(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function LP(e,t){return new og({type:"nonoptional",innerType:e,...T(t)})}var jP=b("ZodCatch",(e,t)=>{lf.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,r,i)=>mc(e,n,r,i),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function DP(e,t){return new jP({type:"catch",innerType:e,catchValue:typeof t==="function"?t:Jp(t)})}var ag=b("ZodPipe",(e,t)=>{Oa.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,r,i)=>gc(e,n,r,i),e.in=t.in,e.out=t.out});function Jm(e,t){return new ag({type:"pipe",in:e,out:t})}var MP=b("ZodPreprocess",(e,t)=>{ag.init(e,t),uf.init(e,t)}),UP=b("ZodReadonly",(e,t)=>{pf.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,r,i)=>vc(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function ZP(e){return new UP({type:"readonly",innerType:e})}var GP=b("ZodCustom",(e,t)=>{df.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,r,i)=>nc(e,n,r,i)});function qP(e,t={}){return Xf(GP,e,t)}function BP(e,t){return em(e,t)}function HP(e,t){return new MP({type:"pipe",in:ig(e),out:t})}var FP=["iOS","iPhone","macOS"];function xt(e,t){let n=[];if(e==="")return["it is empty"];if(/^\s/.test(e)||/\s$/.test(e))n.push("it has leading or trailing spaces");if(/command ?line/i.test(e))n.push('it should say "command-line"');if(/^(?:the|an?)(?=\s)/i.test(e))n.push("it starts with an article");if(/^[a-z]/.test(e)&&!FP.includes(e.split(/\s+/)[0]))n.push("it starts with a lowercase letter");if(new RegExp(`^${t.replaceAll("-","").split("").join("[\\s\\-]?")}\\b`,"i").test(e))n.push("it starts with the package name");let r=/\b(macOS|Mac(?: ?OS(?: ?X)?)?|OS ?X)(?! virtual machines?)\b/i.exec(e);if(r&&r[1]!=="MAC")n.push("it names the platform");if(/\.$/.test(e)&&!e.endsWith("etc."))n.push("it ends with a full stop");if(/\p{So}/u.test(e))n.push("it contains a symbol or emoji");if([...e].length>80)n.push("it is longer than 80 characters");return n}var pg=["darwin-universal","darwin-arm64","darwin-amd64","linux-arm64","linux-amd64","windows-amd64","windows-arm64"],$c=/^v(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([0-9A-Za-z]+(?:\.[0-9A-Za-z]+)*))?$/,dn=/^[a-z0-9][a-z0-9-]*$/,cg=["com.apple.security.cs.allow-jit","com.apple.security.cs.allow-unsigned-executable-memory","com.apple.security.cs.disable-executable-page-protection","com.apple.security.cs.allow-dyld-environment-variables","com.apple.security.cs.disable-library-validation"],St=E().regex(/^[A-Za-z0-9._-]+(\/[A-Za-z0-9._-]+)*$/).refine((e)=>!e.split("/").includes(".."),"must stay inside the archive"),lg=E().regex(/^[A-Za-z0-9.-]+$/),dg={postflight:N({binary:E().regex(/^[A-Za-z0-9._-]+$/),args:X(E().regex(/^[A-Za-z0-9._:=@%+,\/-]{1,90}$/)).max(10).refine((e)=>e.reduce((t,n)=>t+n.length+4,0)<=90,"must fit on one line of the cask (90 characters)").default([])}).strict().optional(),uninstall:N({launchctl:X(lg).optional(),quit:X(lg).optional()}).strict().optional(),zap:N({trash:X(E().regex(/^~\/[A-Za-z0-9 ._\/-]+$/))}).strict().optional(),caveats:E().min(1).max(2000).optional()},hg={name:E().regex(dn),repo:E().regex(/^[A-Za-z0-9-]+\/[A-Za-z0-9._-]+$/),workflow:E().regex(/^[A-Za-z0-9._-]+\.ya?ml$/).default("release.yml"),assets:PP(kt(pg),E().regex(/^[A-Za-z0-9._{}-]+$/)),description:E().min(1).max(200).optional(),homepage:eg().optional(),license:E().regex(/^[A-Za-z0-9.+-]+$/).optional(),attestation:kt(["auto","off"]).default("auto"),protection:kt(["on","off","dependabot"]).default("on")},fg=/^[A-Za-z0-9 ._-]+\.app$/,pn=/^[A-Za-z0-9-]+(\.[A-Za-z0-9-]+)+$/,KP=N({...hg,kind:kt(["go","bun"]),binaries:X(St).min(1),app:N({name:E().regex(fg),bundle_id:E().regex(pn),binaries:X(St).default([]),entitlements:X(kt(cg)).default([])}).strict().optional(),completions:N({bash:St.optional(),zsh:St.optional(),fish:St.optional()}).strict().optional(),scoop:tt().default(!1),entitlements:X(kt(cg)).default([]),cask:N(dg).strict().default({}),linux:tt().default(!1)}).strict(),nt=_c().int().min(0).max(5000),WP=rg([tt(),E().regex(/^[A-Za-z0-9._*{}-]+$/),X(E().regex(/^[A-Za-z0-9._*{}-]+$/))]),VP=N({...hg,kind:xc("app"),app:E().regex(fg),bundle_id:E().regex(pn),carry:rs(E().regex(/^[A-Za-z0-9._-]+$/),E().regex(/^sha256:[0-9a-f]{64}$/)).default({}),dmg:N({name:E().regex(/^[A-Za-z0-9._{}-]+\.dmg$/),volume:E().regex(/^[A-Za-z0-9 ._-]{1,27}$/).optional(),volume_icon:St.optional(),layout:N({window:kc([nt,nt,nt,nt]),icon_size:nt,app:kc([nt,nt]),applications:kc([nt,nt])}).strict().optional()}).strict(),sparkle:N({key:E().regex(/^[a-z0-9]+$/),feed:E().regex(/^[A-Za-z0-9._-]+\.xml$/).default("appcast.xml"),public_key:E().regex(/^[A-Za-z0-9+/]{43}=$/),next_key:E().regex(/^[a-z0-9]+$/).optional(),next_public_key:E().regex(/^[A-Za-z0-9+/]{43}=$/).optional()}).strict().optional(),code:rs(St,N({identifier:E().regex(pn).optional(),entitlements:rs(E().regex(/^[A-Za-z0-9.-]+$/),WP).optional()}).strict()).default({}),cask:N({...dg,binaries:X(St).optional(),auto_updates:tt().optional()}).strict().default({})}).strict(),mg=HP((e)=>e&&typeof e==="object"&&!Array.isArray(e)&&!("kind"in e)?{...e,kind:"go"}:e,xP("kind",[KP,VP])),YP=N({version:xc(1),tap:E().regex(/^[A-Za-z0-9-]+\/[a-z0-9-]+$/),linux:N({maintainer:E().regex(/^[A-Za-z0-9 .'-]+ <[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}>$/),url:eg({protocol:/^https$/}).regex(/^https:\/\/[A-Za-z0-9.-]+(\/[A-Za-z0-9._-]+)*$/).optional()}).strict().optional(),packages:X(mg)}).strict(),Y=(e)=>e.kind==="app",Ac=(e)=>(Y(e)?e.cask.binaries??[]:[...e.binaries,...e.app?.binaries??[]]).map((t)=>t.split("/").pop()),is=(e)=>Y(e)||Object.keys(e.assets).some((t)=>t.startsWith("darwin")),ug=(e)=>e.map((t)=>`${t.path.join(".")||"(root)"}: ${t.message}`).join("; ");function JP(e,t,n){if(Y(e))eT(e);else if(e.app)XP(e,e.app);let r=e.cask.postflight;if(r&&!Ac(e).includes(r.binary))throw new v(`${e.name}: cask.postflight runs ${r.binary}, which the cask does not link`,`Name one of the commands the cask links: ${Ac(e).join(", ")||"none yet"}.`);if(e.repo.split("/")[0].toLowerCase()!==n.toLowerCase())throw new v(`${e.name}: ${e.repo} is not owned by ${n}`,"tapster publishes only repositories of the hub's owner.");let i=e.description===void 0?[]:xt(e.description,e.name);if(i.length)throw new v(`${e.name}: Homebrew rejects the description because ${i.join(" and ")}`,"Rewrite description in tapster.yml.");let s=Object.entries(e.assets);if(s.length===0)throw new v(`${e.name}: assets is empty`,"Map at least one platform to an asset name.");for(let[o,a]of s){if(a.replaceAll("{version}","").includes("{")||a.replaceAll("{version}","").includes("}"))throw new v(`${e.name}: ${a} uses a placeholder other than {version}`,"Only {version} is replaced in asset names.");if(o.startsWith("darwin")&&!a.endsWith(".tar.gz"))throw new v(`${e.name}: the ${o} asset must be a .tar.gz`,"Pack macOS builds as tar.gz; tapster reads them itself.")}if(Y(e)&&/[{}]/.test(e.dmg.name.replaceAll("{version}","")))throw new v(`${e.name}: ${e.dmg.name} uses a placeholder other than {version}`,"Only {version} is replaced in dmg.name.");if(!Y(e)&&e.scoop&&!Object.keys(e.assets).some((o)=>o.startsWith("windows-")))throw new v(`${e.name}: scoop needs a Windows asset`,"Map windows-amd64 or windows-arm64. Otherwise remove scoop: true.");if(Y(e)||!e.linux)return;if(!Object.keys(e.assets).some((o)=>o.startsWith("linux-")))throw new v(`${e.name}: linux needs a Linux asset`,"Map linux-amd64 or linux-arm64. Otherwise remove linux: true.");if(!t.linux)throw new v(`${e.name} ships Linux packages, but tapster.yml names no linux.maintainer`,'Add linux: { maintainer: "Name <address>" } at the top of tapster.yml.')}function QP(e){let t=new Map,n=(o,a)=>t.has(o)||t.set(o,a);for(let[o,a]of e)if(e.filter(([l,u])=>l!==o&&u.name===a.name).length)n(o,new v(`package ${a.name} is listed twice`,"Keep one entry per package."));let r=e.flatMap(([o,a])=>Ac(a).map((c)=>({i:o,p:a,id:c})));for(let o of r)for(let a of r){if(o.i===a.i||o.id!==a.id||o.p.name===a.p.name)continue;n(o.i,new v(`${o.p.name} and ${a.p.name} both ship a binary named ${o.id}`,"Signed tools are identified by name, so each name may belong to one package."))}let i=(o,a)=>{let c=o.toLowerCase(),l=a.toLowerCase();return c===l||c.startsWith(`${l}.`)||l.startsWith(`${c}.`)},s=e.flatMap(([o,a])=>Y(a)?[{i:o,name:a.name,id:a.bundle_id}]:a.app?[{i:o,name:a.name,id:a.app.bundle_id}]:[]);for(let o of s){for(let a of s)if(o.i!==a.i&&i(o.id,a.id))n(o.i,new v(`${o.name} and ${a.name} have overlapping bundle ids`,"Each app needs its own bundle id, not one inside another."));for(let a of r){let c=a.id.toLowerCase();if(c!==o.id.toLowerCase()&&!c.startsWith(`${o.id.toLowerCase()}.`))continue;let l=new v(`the binary ${a.id} would carry ${o.name}'s identity`,"Rename the binary.");n(o.i,l),n(a.i,l)}}return t}function ie(e,t){let n;try{n=ne(e)}catch(u){let p=u.linePos?.[0]?.line;throw new v(`tapster.yml is not valid YAML${p?` at line ${p}`:""}`,"Fix the YAML syntax there.")}let r=YP.extend({packages:X(yc())}).safeParse(n);if(!r.success)throw new v(`tapster.yml is invalid: ${ug(r.error.issues)}`,"Fix the listed fields.");let{packages:i,...s}=r.data,o=new Map,a=(u)=>{let p=u&&typeof u==="object"&&"repo"in u?u.repo:void 0;return typeof p==="string"?p:null},c=(u,p)=>{let d=u&&typeof u==="object"&&"name"in u?u.name:void 0;return typeof d==="string"&&dn.test(d)?d:`packages[${p}]`},l=[];for(let[u,p]of i.entries()){let d=mg.safeParse(p);if(!d.success){o.set(u,{name:c(p,u),repo:a(p),reason:`${c(p,u)} is invalid: ${ug(d.error.issues)}`,fix:"Fix the listed fields in tapster.yml."});continue}let h=d.data;try{JP(h,s,t),l.push([u,h])}catch(f){if(!(f instanceof v))throw f;o.set(u,{name:h.name,repo:h.repo,reason:f.reason,fix:f.fix})}}for(let[u,p]of QP(l)){let d=l.find(([h])=>h===u)[1];o.set(u,{name:d.name,repo:d.repo,reason:p.reason,fix:p.fix})}return{config:{...s,packages:l.filter(([u])=>!o.has(u)).map(([,u])=>u)},invalid:[...o.entries()].sort(([u],[p])=>u-p).map(([,u])=>u)}}function XP(e,t){let n=Object.keys(e.assets);if(!n.some((i)=>i.startsWith("darwin")))throw new v(`${e.name}: app needs a macOS archive that holds ${t.name}`,"Map a darwin-* asset or remove app.");if(n.some((i)=>i.startsWith("linux")))throw new v(`${e.name}: a tool with an app has a cask for macOS only, but it also has a Linux archive`,"Remove the linux-* assets or remove app.");let r=e.binaries.find((i)=>i===t.name||i.startsWith(`${t.name}/`));if(r)throw new v(`${e.name}: ${r} is inside ${t.name}`,"Remove it from binaries: the hub signs the app as a whole. List commands to link under app.binaries.")}function eT(e){if(Object.keys(e.assets).filter((n)=>n.startsWith("darwin")).length!==1||Object.keys(e.assets).length!==1)throw new v(`${e.name}: an app needs exactly one darwin asset and nothing else`,"Map one of darwin-arm64, darwin-amd64 or darwin-universal to the app archive.");if(e.dmg.volume??=e.app.replace(/\.app$/,"").slice(0,27),e.sparkle&&e.sparkle.next_key===void 0!==(e.sparkle.next_public_key===void 0))throw new v(`${e.name}: a rotation needs both sparkle.next_key and next_public_key`,"Set both or neither.");for(let[n,r]of Object.entries(e.code))if(r.identifier&&!r.identifier.startsWith(`${e.bundle_id}.`))throw new v(`${e.name}: the identifier for ${n} is outside ${e.bundle_id}`,`Use an identifier that starts with ${e.bundle_id}.`)}function ss(e){let t=$c.exec(e);if(!t)return null;return{major:Number(t[1]),minor:Number(t[2]),patch:Number(t[3]),pre:t[4]??null}}function Pc(e,t){for(let i of["major","minor","patch"])if(e[i]!==t[i])return e[i]-t[i];if(e.pre===t.pre)return 0;if(e.pre===null)return 1;if(t.pre===null)return-1;let n=e.pre.split("."),r=t.pre.split(".");for(let i=0;i<Math.max(n.length,r.length);i++){let s=n[i],o=r[i];if(s===void 0)return-1;if(o===void 0)return 1;let a=/^\d+$/.test(s),c=/^\d+$/.test(o);if(a&&c&&Number(s)!==Number(o))return Number(s)-Number(o);if(a!==c)return a?-1:1;if(s!==o)return s<o?-1:1}return 0}function gg(e,t){let[n,r]=t.split("/");return e.linux?.url??`https://${n.toLowerCase()}.github.io/${r}`}import{spawn as RT}from"child_process";import{existsSync as IT}from"fs";import*as yg from"os";function mr(e){if(e===null||e===void 0)return"";else if(typeof e==="string"||e instanceof String)return e;return JSON.stringify(e)}function bg(e,t,n){let r=new wg(e,t,n);process.stdout.write(r.toString()+yg.EOL)}var vg="::";class wg{constructor(e,t,n){if(!e)e="missing.command";this.command=e,this.properties=t,this.message=n}toString(){let e=vg+this.command;if(this.properties&&Object.keys(this.properties).length>0){e+=" ";let t=!0;for(let n in this.properties)if(this.properties.hasOwnProperty(n)){let r=this.properties[n];if(r){if(t)t=!1;else e+=",";e+=`${n}=${nT(r)}`}}}return e+=`${vg}${tT(this.message)}`,e}}function tT(e){return mr(e).replace(/%/g,"%25").replace(/\r/g,"%0D").replace(/\n/g,"%0A")}function nT(e){return mr(e).replace(/%/g,"%25").replace(/\r/g,"%0D").replace(/\n/g,"%0A").replace(/:/g,"%3A").replace(/,/g,"%2C")}var cz=Ce("net"),lz=Ce("tls"),iT=Ce("http"),uz=Ce("https"),sT=Ce("events"),pz=Ce("assert"),oT=Ce("util");function os(e){var t=this;t.options=e||{},t.proxyOptions=t.options.proxy||{},t.maxSockets=t.options.maxSockets||iT.Agent.defaultMaxSockets,t.requests=[],t.sockets=[],t.on("free",function(r,i,s,o){var a=_g(i,s,o);for(var c=0,l=t.requests.length;c<l;++c){var u=t.requests[c];if(u.host===a.host&&u.port===a.port){t.requests.splice(c,1),u.request.onSocket(r);return}}r.destroy(),t.removeSocket(r)})}oT.inherits(os,sT.EventEmitter);os.prototype.addRequest=function(t,n,r,i){var s=this,o=kg({request:t},s.options,_g(n,r,i));if(s.sockets.length>=this.maxSockets){s.requests.push(o);return}s.createSocket(o,function(a){a.on("free",c),a.on("close",l),a.on("agentRemove",l),t.onSocket(a);function c(){s.emit("free",a,o)}function l(u){s.removeSocket(a),a.removeListener("free",c),a.removeListener("close",l),a.removeListener("agentRemove",l)}})};os.prototype.createSocket=function(t,n){var r=this,i={};r.sockets.push(i);var s=kg({},r.proxyOptions,{method:"CONNECT",path:t.host+":"+t.port,agent:!1,headers:{host:t.host+":"+t.port}});if(t.localAddress)s.localAddress=t.localAddress;if(s.proxyAuth)s.headers=s.headers||{},s.headers["Proxy-Authorization"]="Basic "+new Buffer(s.proxyAuth).toString("base64");Ut("making CONNECT request");var o=r.request(s);o.useChunkedEncodingByDefault=!1,o.once("response",a),o.once("upgrade",c),o.once("connect",l),o.once("error",u),o.end();function a(p){p.upgrade=!0}function c(p,d,h){process.nextTick(function(){l(p,d,h)})}function l(p,d,h){if(o.removeAllListeners(),d.removeAllListeners(),p.statusCode!==200){Ut("tunneling socket could not be established, statusCode=%d",p.statusCode),d.destroy();var f=Error("tunneling socket could not be established, statusCode="+p.statusCode);f.code="ECONNRESET",t.request.emit("error",f),r.removeSocket(i);return}if(h.length>0){Ut("got illegal response body from proxy"),d.destroy();var f=Error("got illegal response body from proxy");f.code="ECONNRESET",t.request.emit("error",f),r.removeSocket(i);return}return Ut("tunneling connection has established"),r.sockets[r.sockets.indexOf(i)]=d,n(d)}function u(p){o.removeAllListeners(),Ut(`tunneling socket could not be established, cause=%s
196
+ `,p.message,p.stack);var d=Error("tunneling socket could not be established, cause="+p.message);d.code="ECONNRESET",t.request.emit("error",d),r.removeSocket(i)}};os.prototype.removeSocket=function(t){var n=this.sockets.indexOf(t);if(n===-1)return;this.sockets.splice(n,1);var r=this.requests.shift();if(r)this.createSocket(r,function(i){r.request.onSocket(i)})};function _g(e,t,n){if(typeof e==="string")return{host:e,port:t,localAddress:n};return e}function kg(e){for(var t=1,n=arguments.length;t<n;++t){var r=arguments[t];if(typeof r==="object"){var i=Object.keys(r);for(var s=0,o=i.length;s<o;++s){var a=i[s];if(r[a]!==void 0)e[a]=r[a]}}}return e}var Ut;if(process.env.NODE_DEBUG&&/\btunnel\b/.test(process.env.NODE_DEBUG))Ut=function(){var e=Array.prototype.slice.call(arguments);if(typeof e[0]==="string")e[0]="TUNNEL: "+e[0];else e.unshift("TUNNEL:");console.error.apply(console,e)};else Ut=function(){};var qe;(function(e){e[e.OK=200]="OK",e[e.MultipleChoices=300]="MultipleChoices",e[e.MovedPermanently=301]="MovedPermanently",e[e.ResourceMoved=302]="ResourceMoved",e[e.SeeOther=303]="SeeOther",e[e.NotModified=304]="NotModified",e[e.UseProxy=305]="UseProxy",e[e.SwitchProxy=306]="SwitchProxy",e[e.TemporaryRedirect=307]="TemporaryRedirect",e[e.PermanentRedirect=308]="PermanentRedirect",e[e.BadRequest=400]="BadRequest",e[e.Unauthorized=401]="Unauthorized",e[e.PaymentRequired=402]="PaymentRequired",e[e.Forbidden=403]="Forbidden",e[e.NotFound=404]="NotFound",e[e.MethodNotAllowed=405]="MethodNotAllowed",e[e.NotAcceptable=406]="NotAcceptable",e[e.ProxyAuthenticationRequired=407]="ProxyAuthenticationRequired",e[e.RequestTimeout=408]="RequestTimeout",e[e.Conflict=409]="Conflict",e[e.Gone=410]="Gone",e[e.TooManyRequests=429]="TooManyRequests",e[e.InternalServerError=500]="InternalServerError",e[e.NotImplemented=501]="NotImplemented",e[e.BadGateway=502]="BadGateway",e[e.ServiceUnavailable=503]="ServiceUnavailable",e[e.GatewayTimeout=504]="GatewayTimeout"})(qe||(qe={}));var xg;(function(e){e.Accept="accept",e.ContentType="content-type"})(xg||(xg={}));var Sg;(function(e){e.ApplicationJson="application/json"})(Sg||(Sg={}));var vz=[qe.MovedPermanently,qe.ResourceMoved,qe.SeeOther,qe.TemporaryRedirect,qe.PermanentRedirect],yz=[qe.BadGateway,qe.ServiceUnavailable,qe.GatewayTimeout];import{EOL as cT}from"os";import{constants as Ag,promises as lT}from"fs";var Ec=function(e,t,n,r){function i(s){return s instanceof n?s:new n(function(o){o(s)})}return new(n||(n=Promise))(function(s,o){function a(u){try{l(r.next(u))}catch(p){o(p)}}function c(u){try{l(r.throw(u))}catch(p){o(p)}}function l(u){u.done?s(u.value):i(u.value).then(a,c)}l((r=r.apply(e,t||[])).next())})},{access:uT,appendFile:pT,writeFile:dT}=lT,$g="GITHUB_STEP_SUMMARY";class Pg{constructor(){this._buffer=""}filePath(){return Ec(this,void 0,void 0,function*(){if(this._filePath)return this._filePath;let e=process.env[$g];if(!e)throw Error(`Unable to find environment variable for $${$g}. Check if your runtime environment supports job summaries.`);try{yield uT(e,Ag.R_OK|Ag.W_OK)}catch(t){throw Error(`Unable to access summary file: '${e}'. Check if the file has correct read/write permissions.`)}return this._filePath=e,this._filePath})}wrap(e,t,n={}){let r=Object.entries(n).map(([i,s])=>` ${i}="${s}"`).join("");if(!t)return`<${e}${r}>`;return`<${e}${r}>${t}</${e}>`}write(e){return Ec(this,void 0,void 0,function*(){let t=!!(e===null||e===void 0?void 0:e.overwrite),n=yield this.filePath();return yield(t?dT:pT)(n,this._buffer,{encoding:"utf8"}),this.emptyBuffer()})}clear(){return Ec(this,void 0,void 0,function*(){return this.emptyBuffer().write({overwrite:!0})})}stringify(){return this._buffer}isEmptyBuffer(){return this._buffer.length===0}emptyBuffer(){return this._buffer="",this}addRaw(e,t=!1){return this._buffer+=e,t?this.addEOL():this}addEOL(){return this.addRaw(cT)}addCodeBlock(e,t){let n=Object.assign({},t&&{lang:t}),r=this.wrap("pre",this.wrap("code",e),n);return this.addRaw(r).addEOL()}addList(e,t=!1){let n=t?"ol":"ul",r=e.map((s)=>this.wrap("li",s)).join(""),i=this.wrap(n,r);return this.addRaw(i).addEOL()}addTable(e){let t=e.map((r)=>{let i=r.map((s)=>{if(typeof s==="string")return this.wrap("td",s);let{header:o,data:a,colspan:c,rowspan:l}=s,u=o?"th":"td",p=Object.assign(Object.assign({},c&&{colspan:c}),l&&{rowspan:l});return this.wrap(u,a,p)}).join("");return this.wrap("tr",i)}).join(""),n=this.wrap("table",t);return this.addRaw(n).addEOL()}addDetails(e,t){let n=this.wrap("details",this.wrap("summary",e)+t);return this.addRaw(n).addEOL()}addImage(e,t,n){let{width:r,height:i}=n||{},s=Object.assign(Object.assign({},r&&{width:r}),i&&{height:i}),o=this.wrap("img",null,Object.assign({src:e,alt:t},s));return this.addRaw(o).addEOL()}addHeading(e,t){let n=`h${t}`,r=["h1","h2","h3","h4","h5","h6"].includes(n)?n:"h1",i=this.wrap(r,e);return this.addRaw(i).addEOL()}addSeparator(){let e=this.wrap("hr",null);return this.addRaw(e).addEOL()}addBreak(){let e=this.wrap("br",null);return this.addRaw(e).addEOL()}addQuote(e,t){let n=Object.assign({},t&&{cite:t}),r=this.wrap("blockquote",e,n);return this.addRaw(r).addEOL()}addLink(e,t){let n=this.wrap("a",e,{href:t});return this.addRaw(n).addEOL()}}var Oz=new Pg;import Eg from"os";import*as as from"fs";var{chmod:hT,copyFile:fT,lstat:mT,mkdir:gT,open:Iz,readdir:vT,rename:yT,rm:bT,rmdir:Nz,stat:wT,symlink:_T,unlink:kT}=as.promises,xT=process.platform==="win32";var zz=as.constants.O_RDONLY;var Uz=process.platform==="win32";var Hz=Eg.platform(),Fz=Eg.arch();var Og;(function(e){e[e.Success=0]="Success",e[e.Failure=1]="Failure"})(Og||(Og={}));function Tc(e){bg("add-mask",{},e)}var Cg=4;var Oc=new Set;function CT(e){if(e.length<Cg)return[];let t=new Set,n=(i)=>{if(i.length>=Cg)t.add(i)};n(e);let r=Buffer.from(e,"utf8");n(r.toString("base64")),n(r.toString("hex")),n(r.toString("hex").toUpperCase()),n(encodeURIComponent(e));for(let i of e.split(/\r?\n/))n(i.trim());return[...t]}function hn(e){for(let t of CT(e)){if(Oc.has(t))continue;if(Oc.add(t),process.env.GITHUB_ACTIONS==="true")Tc(t)}}function fn(e){let t=e;for(let n of[...Oc].sort((r,i)=>i.length-r.length))t=t.split(n).join("***");return t}var mn={codesign:"/usr/bin/codesign",security:"/usr/bin/security",xcrun:"/usr/bin/xcrun",openssl:"/usr/bin/openssl",ditto:"/usr/bin/ditto",git:"/usr/bin/git",hdiutil:"/usr/bin/hdiutil",xattr:"/usr/bin/xattr",plutil:"/usr/bin/plutil",spctl:"/usr/sbin/spctl",gpg:"/usr/bin/gpg",gpgconf:"/usr/bin/gpgconf",rpm:"/usr/bin/rpm",rpmsign:"/usr/bin/rpmsign",rpm2archive:"/usr/bin/rpm2archive","dpkg-deb":"/usr/bin/dpkg-deb",createrepo_c:"/usr/bin/createrepo_c","apt-ftparchive":"/usr/bin/apt-ftparchive"},NT=["/opt/homebrew/bin/gh","/usr/local/bin/gh","/usr/bin/gh"];function zT(e={}){return{PATH:"/usr/bin:/bin",HOME:process.env.HOME??"/tmp",TMPDIR:process.env.RUNNER_TEMP??process.env.TMPDIR??"/tmp",...e}}function LT(e,t=5){return fn(e).split(/\r?\n/).filter((n)=>n.trim()!==""&&!/keychain/i.test(n)).slice(-t).join(" | ")}function Rg(e=NT){let t=e.find((n)=>IT(n));if(!t)throw new v("gh is not installed on this runner","Use a GitHub-hosted runner image, which ships gh.");return t}function Pe(e,t,n={}){return D(mn[e],e,t,n)}function D(e,t,n,r={}){return new Promise((i,s)=>{let o=RT(e,n,{env:zT(r.env),cwd:r.cwd,shell:!1,stdio:["pipe","pipe","pipe"]}),a=[],c=[],l=0,u=null,p=(f)=>{u??=f,o.kill("SIGKILL")},d=r.timeoutMs?setTimeout(()=>p(new v(`${t} did not finish in time`,"Re-run the workflow; if it happens again, check the input it read.")),r.timeoutMs):null,h=(f)=>(m)=>{if(l+=m.length,r.maxOutput&&l>r.maxOutput)p(new v(`${t} wrote more output than tapster reads`,"Check the input it read."));else f.push(m)};o.stdout.on("data",h(a)),o.stderr.on("data",h(c)),o.on("error",()=>s(new v(`${t} could not start`,`Check that ${e} exists on this runner.`))),o.on("close",(f)=>{if(d)clearTimeout(d);if(u){s(u);return}let m=Buffer.concat(a),g={code:f??-1,stdout:m.toString("utf8"),stderr:Buffer.concat(c).toString("utf8"),bytes:m};if(g.code!==0&&!r.allowFail){s(new v(`${t} exited with ${g.code}`,LT(g.stderr)||"No error output."));return}i(g)}),o.stdin.end(r.stdin??"")})}var jT=1048576,Ig=32,DT=1e5,C=(e)=>new v(`an Info.plist ${e}`,"Rebuild the app; tapster reads XML and binary property lists.");function Cc(e){if(e.length>jT)throw C("is larger than 1 MiB");if(e.subarray(0,8).toString("latin1")==="bplist00")return qT(e);if(e[0]===254||e[0]===255||e[0]===0)throw C("is not UTF-8");let t=e.toString("utf8").replace(/^\ufeff/,""),n=/^\s*<\?xml[^>]*\bencoding\s*=\s*["']([^"']*)["']/.exec(t)?.[1];if(n!==void 0&&!/^utf-?8$/i.test(n))throw C(`declares the encoding ${n}, not UTF-8`);return GT(t)}var MT={amp:"&",lt:"<",gt:">",quot:'"',apos:"'"};function UT(e){return e.replace(/&(#x[0-9a-fA-F]+|#[0-9]+|[a-z]+);/g,(t,n)=>{if(n.startsWith("#x"))return String.fromCodePoint(Number.parseInt(n.slice(2),16));if(n.startsWith("#"))return String.fromCodePoint(Number.parseInt(n.slice(1),10));let r=MT[n];if(r===void 0)throw C(`uses an unknown entity ${t}`);return r})}function ZT(e){let t=[],n=0;while(n<e.length)if(e.startsWith("<!--",n)){let r=e.indexOf("-->",n+4);if(r===-1)throw C("has an unclosed comment");n=r+3}else if(e.startsWith("<![CDATA[",n)){let r=e.indexOf("]]>",n+9);if(r===-1)throw C("has an unclosed CDATA section");t.push({kind:"text",text:e.slice(n+9,r)}),n=r+3}else if(e.startsWith("<?",n)||e.startsWith("<!",n)){let r=e.indexOf(">",n);if(r===-1)throw C("is not valid XML");n=r+1}else if(e[n]==="<"){let r=e.indexOf(">",n);if(r===-1)throw C("is not valid XML");let i=e.slice(n+1,r).trim(),s=/^(\/)?([A-Za-z]+)(?:\s[^/]*)?(\/)?$/.exec(i);if(!s)throw C("has a tag tapster does not read");t.push({kind:s[1]?"close":s[3]?"empty":"open",name:s[2]}),n=r+1}else{let r=e.indexOf("<",n),i=e.slice(n,r===-1?e.length:r);t.push({kind:"text",text:UT(i)}),n=r===-1?e.length:r}return t}function GT(e){let t=ZT(e).filter((u)=>!(u.kind==="text"&&u.text.trim()==="")),n=0,r=()=>t[n++],i=()=>t[n],s=(u)=>{let p="";for(;;){let d=r();if(!d)throw C(`has an unclosed <${u}>`);if(d.kind==="text")p+=d.text;else if(d.kind==="close"&&d.name===u)return p;else throw C(`has markup inside <${u}>`)}},o=(u)=>{if(u>Ig)throw C("is nested too deeply");let p=r();if(!p||p.kind==="text"||p.kind==="close")throw C("is missing a value");if(p.kind==="empty"){if(p.name==="true")return!0;if(p.name==="false")return!1;if(p.name==="string")return"";if(p.name==="dict")return{};if(p.name==="array")return[];if(p.name==="data")return Buffer.alloc(0);throw C(`has an unknown <${p.name}/>`)}switch(p.name){case"string":return s("string");case"integer":{let d=s("integer").trim();if(!/^[+-]?\d{1,15}$/.test(d))throw C("has an integer tapster does not read");return Number(d)}case"real":{let d=Number(s("real").trim());if(!Number.isFinite(d))throw C("has an invalid real");return d}case"date":{let d=new Date(s("date").trim());if(Number.isNaN(d.getTime()))throw C("has an invalid date");return d}case"data":return Buffer.from(s("data").replace(/\s+/g,""),"base64");case"array":{let d=[];for(;;){let h=i();if(h?.kind==="close"&&h.name==="array")return n++,d;d.push(o(u+1))}}case"dict":{let d={};for(;;){let h=r();if(h?.kind==="close"&&h.name==="dict")return d;if(h?.kind!=="open"||h.name!=="key")throw C("has a dict entry without a key");let f=s("key");if(Object.hasOwn(d,f))throw C(`lists the key ${f} twice`);Object.defineProperty(d,f,{value:o(u+1),enumerable:!0,writable:!0,configurable:!0})}}default:throw C(`has an unknown <${p.name}>`)}},a=r();if(!a||a.kind!=="open"||a.name!=="plist")throw C("does not start with <plist>");let c=o(1),l=r();if(!l||l.kind!=="close"||l.name!=="plist"||n!==t.length)throw C("has content after its value");return c}function qT(e){if(e.length<40)throw C("is truncated");let t=e.subarray(e.length-32),n=t[6],r=t[7],i=Number(t.readBigUInt64BE(8)),s=Number(t.readBigUInt64BE(16)),o=Number(t.readBigUInt64BE(24));if(![1,2,4,8].includes(n)||![1,2,4,8].includes(r))throw C("has a damaged trailer");if(i<1||s>=i||o<8||o+i*n>e.length-32)throw C("has a damaged offset table");let a=(d,h)=>{if(d+h>e.length-32)throw C("is truncated");let f=h===8?e.readBigUInt64BE(d):BigInt(e.readUIntBE(d,h));if(f>BigInt(Number.MAX_SAFE_INTEGER))throw C("has a number tapster does not read");return Number(f)},c=(d)=>{if(d>=i)throw C("has a reference outside its objects");let h=a(o+d*n,n);if(h<8||h>=o)throw C("has an object outside its body");return h},l=new Set,u=0,p=(d,h)=>{if(h>Ig)throw C("is nested too deeply");if(++u>DT)throw C("has too many objects");if(l.has(d))throw C("refers to itself");l.add(d);try{let f=c(d),m=e[f],g=m>>4,w=m&15,k=()=>{if(w!==15)return[w,f+1];let _=e[f+1];if(_>>4!==1)throw C("has a damaged length");let y=1<<(_&15);return[a(f+2,y),f+2+y]};switch(g){case 0:if(m===8)return!1;if(m===9)return!0;throw C("has an object tapster does not read");case 1:{let _=1<<w;if(_===8){if(f+9>e.length-32)throw C("is truncated");let y=e.readBigInt64BE(f+1);if(y>BigInt(Number.MAX_SAFE_INTEGER)||y<BigInt(Number.MIN_SAFE_INTEGER))throw C("has a number tapster does not read");return Number(y)}if(_>8)throw C("has a number tapster does not read");return a(f+1,_)}case 2:{if(w===2)return e.readFloatBE(f+1);if(w===3)return e.readDoubleBE(f+1);throw C("has a real tapster does not read")}case 3:if(m!==51)throw C("has a damaged date");return new Date((978307200+e.readDoubleBE(f+1))*1000);case 4:{let[_,y]=k();if(y+_>o)throw C("is truncated");return Buffer.from(e.subarray(y,y+_))}case 5:{let[_,y]=k();if(y+_>o)throw C("is truncated");return e.subarray(y,y+_).toString("latin1")}case 6:{let[_,y]=k();if(y+_*2>o)throw C("is truncated");let x=Buffer.from(e.subarray(y,y+_*2));return x.swap16(),x.toString("utf16le")}case 10:{let[_,y]=k();if(y+_*r>o)throw C("is truncated");return Array.from({length:_},(x,S)=>p(a(y+S*r,r),h+1))}case 13:{let[_,y]=k();if(y+2*_*r>o)throw C("is truncated");let x={};for(let S=0;S<_;S++){let O=p(a(y+S*r,r),h+1);if(typeof O!=="string")throw C("has a dict key that is not a string");if(Object.hasOwn(x,O))throw C(`lists the key ${O} twice`);Object.defineProperty(x,O,{value:p(a(y+(_+S)*r,r),h+1),enumerable:!0,writable:!0,configurable:!0})}return x}default:throw C("has an object tapster does not read")}}finally{l.delete(d)}};return p(s,1)}var cs=[{actor_id:5,actor_type:"RepositoryRole",bypass_mode:"always"}],BT={actor_id:null,actor_type:"DeployKey",bypass_mode:"always"},Rc={name:"tapster tags",target:"tag",enforcement:"active",bypass_actors:cs,conditions:{ref_name:{include:["~ALL"],exclude:[]}},rules:[{type:"creation"},{type:"update"},{type:"deletion"}]},Ic={name:"tapster branches",target:"branch",enforcement:"active",bypass_actors:cs,conditions:{ref_name:{include:["~ALL"],exclude:[]}},rules:[{type:"creation"},{type:"update"},{type:"deletion"},{type:"non_fast_forward"}]},ls="refs/heads/dependabot/**";function HT(e,t=!1){let n=e?[...cs,BT]:cs,r={ref_name:{include:["~ALL"],exclude:t?[ls]:[]}};return[{...Rc,bypass_actors:n},{...Ic,bypass_actors:n,conditions:r}]}function Ng(e,t){if(t==="app")return e.current_user_can_bypass!=="never";return(e.bypass_actors??[]).some((n)=>!(n.actor_type==="DeployKey"||n.actor_type==="RepositoryRole"&&n.actor_id===5))}async function zg(e,t,n,r,i,s){let o;try{o=await e.json("GET",`/repos/${t}/rulesets?targets=${n}`)}catch(h){if(h instanceof R&&(h.status===403||h.status===404))return{problems:["GitHub offers no rulesets on this repository; private repositories need a paid plan for them"],ok:!1};throw h}let a=await Promise.all(o.filter((h)=>h.target===n&&h.enforcement==="active").map((h)=>e.json("GET",`/repos/${t}/rulesets/${h.id}`)));if(a.length===0)return{problems:[`no active ${n} ruleset protects every ${n}`],ok:!1};let c=n==="branch"&&s?[ls]:[],l=a.filter((h)=>(h.conditions?.ref_name?.include??[]).includes("~ALL")&&(h.conditions?.ref_name?.exclude??[]).every((f)=>c.includes(f)));if(l.length===0)return{problems:[`no active ${n} ruleset covers every ${n} (~ALL) without exclusions`],ok:!1};let u=l.filter((h)=>Ng(h,i)).map((h)=>`the App or another actor can bypass ${h.name}`),p=new Set(l.filter((h)=>!Ng(h,i)).flatMap((h)=>(h.rules??[]).map((f)=>f.type))),d=r.filter((h)=>!p.has(h));if(d.length)u.push(`the ${n} rulesets do not restrict ${d.join(", ")}`);return{problems:u,ok:u.length===0}}async function Lg(e,t,n,r,i=!1){let s=await zg(e,t,"tag",Rc.rules.map((a)=>a.type),r,!1),o=await zg(e,t,"branch",Ic.rules.map((a)=>a.type),r,i);if(o.ok){let a=new Set((await e.json("GET",`/repos/${t}/rules/branches/${encodeURIComponent(n)}`)).map((c)=>c.type));if(!["update","deletion","non_fast_forward"].every((c)=>a.has(c)))o.problems.push("GitHub does not enforce rulesets on this repository; private repositories need a paid plan for them")}return{tag:s.problems,branch:o.problems}}async function gr(e,t,n,r,i=!1){let s=await Lg(e,t,n,r,i);return[...s.tag,...s.branch]}async function jg(e,t,n,r=!1,i=!1){let s;try{s=await e.json("GET",`/repos/${t}/rulesets`)}catch(f){if(f instanceof R&&(f.status===403||f.status===404))return{status:"unavailable",deployKeys:r,dependabot:i};throw f}let o=await Promise.all(s.filter((f)=>f.name===Rc.name||f.name===Ic.name).map((f)=>e.json("GET",`/repos/${t}/rulesets/${f.id}`))),a=r||o.some((f)=>(f.bypass_actors??[]).some((m)=>m.actor_type==="DeployKey")),c=i||o.some((f)=>(f.conditions?.ref_name?.exclude??[]).includes(ls)),l=(f)=>({status:f,deployKeys:a,dependabot:c}),u=await Lg(e,t,n,"admin",c);if(u.tag.concat(u.branch).some((f)=>f.includes("offers no rulesets")))return l("unavailable");let p=a!==o.some((f)=>(f.bypass_actors??[]).some((m)=>m.actor_type==="DeployKey"))||c!==o.some((f)=>(f.conditions?.ref_name?.exclude??[]).includes(ls));if(u.tag.length+u.branch.length===0&&!p)return l("exists");let[d,h]=HT(a,c);try{for(let[f,m]of[[d,u.tag],[h,u.branch]]){if(m.length===0&&!p)continue;let g=s.find((w)=>w.name===f.name);if(g)await e.json("PUT",`/repos/${t}/rulesets/${g.id}`,f);else await e.json("POST",`/repos/${t}/rulesets`,f)}}catch(f){if(f instanceof R&&(f.status===403||f.status===422))return l("unavailable");throw f}return l((await gr(e,t,n,"admin",c)).length===0?"created":"unavailable")}import{createPrivateKey as wE}from"crypto";import{spawn as _E}from"child_process";import{existsSync as ev,readFileSync as kE}from"fs";import{writeFile as br}from"fs/promises";import{delimiter as Gc,join as Ke}from"path";var FT={401:"Your GitHub sign-in was rejected; run gh auth login again.",403:"Your account may not do this here; check that you own the repository, then run gh auth refresh to renew the sign-in.",404:"Not found or not visible to your gh sign-in; check the name and run gh auth status.",409:"GitHub reported a conflict; run the command again.",422:"GitHub rejected the request."},KT={401:"The credential was rejected; rotate it with tapster init --rotate.",403:"Access denied: check the App's permissions and that it is installed on this repository.",404:"Not found. The App may not be installed on this repository.",409:"GitHub reported a conflict; the next run retries.",422:"GitHub rejected the request."};function Nc(e){try{return new URL(e).pathname}catch{return"(url)"}}class pe{token;fetchImpl;sleep;who;constructor(e,t=fetch,n=(i)=>new Promise((s)=>setTimeout(s,i)),r="app"){this.token=e;this.fetchImpl=t;this.sleep=n;this.who=r}async request(e,t,n={}){let r=t.startsWith("https://")?t:`https://api.github.com${t}`,i={Accept:n.accept??"application/vnd.github+json","X-GitHub-Api-Version":"2022-11-28","User-Agent":"tapster"};if(n.auth!==!1)i.Authorization=`Bearer ${this.token}`;if(n.contentType)i["Content-Type"]=n.contentType;else if(n.body!==void 0)i["Content-Type"]="application/json";let s=n.raw??(n.body!==void 0?JSON.stringify(n.body):void 0);for(let o=0;;o++){let a;try{a=await this.fetchImpl(r,{method:e,headers:i,body:s,redirect:"manual"})}catch{if(o<4){await this.sleep(1000*2**o);continue}throw new R(`GitHub ${e} ${Nc(r)}: network error`,"GitHub did not answer; the next run retries.",0)}if((a.status>=500||a.status===429)&&o<4){await this.sleep(1000*2**o);continue}if(a.status>=400){await a.body?.cancel();let c=this.who==="user"?FT:KT;throw new R(`GitHub ${e} ${Nc(r)} returned ${a.status}`,c[a.status]??(this.who==="user"?"Try again in a moment.":"The next run retries."),a.status)}return a}}async json(e,t,n){let r=await this.request(e,t,n===void 0?{}:{body:n});for(let i=0;r.status>=300&&r.status<400;i++){let s=r.headers.get("location"),o=null;try{o=s?new URL(s):null}catch{o=null}if(i>=3||!o||o.protocol!=="https:"||o.host!=="api.github.com")throw new R(`GitHub ${e} ${Nc(t)} moved somewhere tapster does not follow`,"Update the repository name in tapster.yml.",r.status);r=await this.request(e,o.toString(),n===void 0?{}:{body:n})}if(r.status===204)return;return await r.json()}async listReleases(e){let t=[];for(let n=1;n<=10;n++){let r=await this.json("GET",`/repos/${e}/releases?per_page=100&page=${n}`);if(t.push(...r),r.length<100)break}return t}getRelease=(e,t)=>this.json("GET",`/repos/${e}/releases/${t}`);getRepo=(e)=>this.json("GET",`/repos/${e}`);async downloadAsset(e,t){let n=await this.request("GET",`/repos/${e}/releases/assets/${t}`,{accept:"application/octet-stream"});if(n.status>=300&&n.status<400){let r=n.headers.get("location");if(!r)throw new R(`GitHub sent a redirect without a location for asset ${t}`,"The next run retries.",n.status);let i=await this.request("GET",r,{auth:!1,accept:"application/octet-stream"});return Buffer.from(await i.arrayBuffer())}return Buffer.from(await n.arrayBuffer())}async uploadAsset(e,t,n){let r=e.upload_url.replace(/\{.*\}$/,"");return await(await this.request("POST",`${r}?name=${encodeURIComponent(t)}`,{raw:n,contentType:"application/octet-stream"})).json()}deleteAsset=(e,t)=>this.request("DELETE",`/repos/${e}/releases/assets/${t}`).then(()=>{return});renameAsset=(e,t,n)=>this.json("PATCH",`/repos/${e}/releases/assets/${t}`,{name:n});updateRelease=(e,t,n,r)=>this.json("PATCH",`/repos/${e}/releases/${t}`,{...r,tag_name:n})}import{createSign as WT}from"crypto";var Dg=(e)=>Buffer.from(e).toString("base64url");function Be(e,t,n=Date.now()){let r=Math.floor(n/1000)-60,i=Dg(JSON.stringify({alg:"RS256",typ:"JWT"})),s=Dg(JSON.stringify({iat:r,exp:r+540,iss:e})),o=WT("RSA-SHA256").update(`${i}.${s}`).sign(t).toString("base64url"),a=`${i}.${s}.${o}`;return hn(a),a}async function Mg(e,t,n,r){let i=new pe(Be(e,t),r),s;try{s=await i.json("GET",`/users/${n}/installation`)}catch(c){if(c instanceof R&&c.status===404)return null;throw c}let{token:o}=await i.json("POST",`/app/installations/${s.id}/access_tokens`,{permissions:{metadata:"read"}});hn(o);let a=new pe(o,r);try{let c=[];for(let l=1;l<=10;l++){let u=await a.json("GET",`/installation/repositories?per_page=100&page=${l}`);if(c.push(...u.repositories.map((p)=>p.full_name)),u.repositories.length<100)return c}throw new v("the App is installed on more than 1000 repositories","Install it only on the projects tapster.yml lists.")}finally{await a.request("DELETE","/installation/token").catch(()=>{return})}}var Ug=`- name: Ring the tapster hub
197
197
  if: \${{ vars.TAPSTER_DOORBELL != '' }}
198
198
  continue-on-error: true
199
199
  env: { DOORBELL: "\${{ vars.TAPSTER_DOORBELL }}" }
@@ -673,7 +673,7 @@ h1 { font-size: 1.6rem; }
673
673
  ol.next { padding-left: 1.3rem; }
674
674
  .local { margin: 1.6rem 0 0; padding-top: 1rem; border-top: 1px solid var(--line); font-size: 0.85rem; color: var(--muted); }
675
675
  @media (max-width: 520px) { body { padding-top: 16px; } .card { padding: 1.4rem 1.2rem 1.1rem; } }
676
- `,iE='<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.6" stroke-linecap="round" aria-hidden="true"><path d="M7 7l10 10M17 7L7 17"/></svg>';function Dc(e,t,n){let r=n==="ok"?`<img class="hero" src="${us}" width="168" height="168" alt="">
676
+ `,iE='<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.6" stroke-linecap="round" aria-hidden="true"><path d="M7 7l10 10M17 7L7 17"/></svg>';function jc(e,t,n){let r=n==="ok"?`<img class="hero" src="${us}" width="168" height="168" alt="">
677
677
  `:n?`<div class="status fail">${iE}</div>
678
678
  `:"";return`${qg(`${e} \xB7 tapster`,rE)}
679
679
  <body>
@@ -684,7 +684,7 @@ ${t}
684
684
  </main>
685
685
  </body>
686
686
  </html>
687
- `}function Bg(e){return Dc(e.title,`<p class="lead">${Te(e.lead)}</p>
687
+ `}function Bg(e){return jc(e.title,`<p class="lead">${Te(e.lead)}</p>
688
688
  <dl class="facts">
689
689
  <dt>What it may do</dt>
690
690
  <dd><ul>${e.permissions.map((t)=>`<li>${Te(t)}</li>`).join("")}<li>Nothing else. It has no webhook and receives no events.</li></ul></dd>
@@ -695,11 +695,11 @@ ${t}
695
695
  <input type="hidden" name="manifest" value="${Te(e.manifest)}">
696
696
  <button class="button" type="submit">Continue to GitHub</button>
697
697
  </form>
698
- <p class="local">This page comes from tapster on your computer (127.0.0.1). The button sends GitHub only this App's description: its name, these permissions and the address to return to. GitHub shows it to you again; click <strong>Create GitHub App</strong> there.</p>`)}function Hg(e){return Dc(e.title,`<p class="lead">Back in your terminal, tapster takes it from here:</p>
698
+ <p class="local">This page comes from tapster on your computer (127.0.0.1). The button sends GitHub only this App's description: its name, these permissions and the address to return to. GitHub shows it to you again; click <strong>Create GitHub App</strong> there.</p>`)}function Hg(e){return jc(e.title,`<p class="lead">Back in your terminal, tapster takes it from here:</p>
699
699
  <ol class="next">${e.next.map((t)=>`<li>${Te(t)}</li>`).join("")}</ol>
700
- <p class="local">You can close this tab.</p>`,"ok")}function Lc(e){return Dc("Nothing was set up",`<p class="lead">${Te(e.reason)}</p>
700
+ <p class="local">You can close this tab.</p>`,"ok")}function Dc(e){return jc("Nothing was set up",`<p class="lead">${Te(e.reason)}</p>
701
701
  <p>Run <code>${Te(e.again)}</code> again in your terminal. It continues where it stopped.</p>
702
- <p class="local">You can close this tab.</p>`,"fail")}function Zt(e){console.log(` ${e}`),L(process.platform==="darwin"?"/usr/bin/open":"/usr/bin/xdg-open","open",[e],{allowFail:!0}).catch(()=>{return})}var oE={"contents:write":"Contents, read and write: publish releases and their files in the repositories you install it on. Your rulesets keep it from creating or moving branches and tags.","attestations:read":"Attestations, read: check that each file was built by the project's own workflow.","metadata:read":"Metadata, read: every GitHub App has this. It sees the names of the repositories you install it on.","actions:write":"Actions, read and write, on the hub only: start the tapster workflow and turn it back on when GitHub pauses it."};function Mc(e){let t=e.default_permissions??{};return Object.entries(t).map(([n,r])=>{let i=oE[`${n}:${r}`];if(!i)throw new v(`the App asks for ${n}: ${r}, which tapster cannot explain`,"Report this at https://github.com/doguyilmaz/tapster/issues.");return i})}var aE={"content-type":"text/html; charset=utf-8","content-security-policy":"default-src 'none'; style-src 'unsafe-inline'; img-src data:; form-action https://github.com; base-uri 'none'; frame-ancestors 'none'","cache-control":"no-store","referrer-policy":"no-referrer","x-content-type-options":"nosniff"};function cE(e){let t=`http://127.0.0.1:${e.port}`,n=!1,r=(i,s=200)=>new Response(i,{status:s,headers:aE});return(i)=>{if(i.headers.get("host")!==`127.0.0.1:${e.port}`)return new Response("Forbidden",{status:403});let s=new URL(i.url);if(s.pathname==="/start"){let a=e.manifest(`${t}/callback`);return r(Bg({...e.copy,permissions:Mc(a),action:`https://github.com/settings/apps/new?state=${e.state}`,manifest:JSON.stringify(a)}))}if(s.pathname!=="/callback")return new Response("Not found",{status:404});if(n)return r(Lc({reason:"This App was already handled.",again:e.copy.again}),409);let o=s.searchParams.get("code");if(s.searchParams.get("state")!==e.state||!o||!/^[A-Za-z0-9_-]{1,128}$/.test(o))return r(Lc({reason:"This answer did not belong to the App this terminal started, so tapster ignored it.",again:e.copy.again}),400);return n=!0,e.settle({code:o}),r(Hg({title:e.copy.done,next:e.copy.next}))}}function lE(e,t){let n=e.owner?.login??"nobody";if(n.toLowerCase()!==t.toLowerCase())throw new v(`the new App belongs to ${n}, not ${t}`,"tapster stored nothing. Create the App from your own account, then run this again.")}async function ps(e,t,n){let r=sE(16).toString("hex"),i=()=>{},s=new Promise((p)=>i=p),o=()=>new Response(null,{status:503}),a=Bun.serve({hostname:"127.0.0.1",port:0,fetch:(p)=>o(p)});o=cE({manifest:e,copy:t,state:r,port:a.port,settle:i}),console.log(`Opening GitHub to create ${t.what}. Read the page, then click "Continue to GitHub" and "Create GitHub App".`),Zt(`http://127.0.0.1:${a.port}/start`),console.log("tapster waits up to 30 minutes until GitHub sends you back. If no page opened, open the address above. Ctrl+C stops it.");let c="If GitHub created the App anyway, delete it at https://github.com/settings/apps first, because its name would block a new one.",l=setTimeout(()=>i({error:new v("no App was created within 30 minutes",`${c} Then run ${t.again} again.`)}),1800000),u=await s;if(clearTimeout(l),setTimeout(()=>a.stop(),1000),"error"in u)throw u.error;return Uc(u.code,n,`${c} Then run ${t.again} again.`)}async function Uc(e,t,n,r=fetch){let i=await r(`https://api.github.com/app-manifests/${e}/conversions`,{method:"POST",headers:{Accept:"application/vnd.github+json"}});if(!i.ok)throw new v(`GitHub did not hand over the new App (status ${i.status})`,n);let s=await i.json();return lE(s,t),s}var Fg=()=>({HOME:process.env.HOME??"/tmp",...process.env.GH_CONFIG_DIR?{GH_CONFIG_DIR:process.env.GH_CONFIG_DIR}:{},GH_PROMPT_DISABLED:"1"});function Kg(e){try{return Rg(e)}catch{throw new v("the GitHub CLI (gh) is not installed","Install it (brew install gh or see https://cli.github.com), sign in with gh auth login, then run this again.")}}async function At(){let e=await L(Kg(),"gh",["auth","token"],{env:Fg(),allowFail:!0}),t=e.stdout.trim();if(e.code!==0||!t)throw new v("gh is not signed in","Run gh auth login, then try again.");return new pe(t,fetch,void 0,"user")}async function He(e=process.cwd()){let t=(await Pe("git",["-C",e,"remote","get-url","origin"],{allowFail:!0})).stdout.trim(),n=/github\.com[:/]([A-Za-z0-9-]+\/[A-Za-z0-9._-]+?)(?:\.git)?$/.exec(t);if(!n)throw new v("this folder is not a clone of a GitHub repository","Run tapster inside a clone (git remote origin on github.com).");return n[1]}var ds=async(e,t)=>{await L(Kg(),"gh",e,{env:Fg(),stdin:t})};var ee=(e,t,n,r="tapster")=>ds(["secret","set",t,"--env",r,"--repo",e],n),ze=(e,t,n)=>ds(["variable","set",t,"--env","tapster","--repo",e,"--body",n]),hs=(e,t,n)=>ds(["variable","set",t,"--repo",e,"--body",n]),Wg=(e,t,n="tapster")=>ds(["secret","delete",t,"--env",n,"--repo",e]);async function Gt(e,t,n){try{return(await e.json("GET",`/repos/${t}/environments/tapster/${n}?per_page=100`))[n]??[]}catch(r){if(r instanceof R&&r.status===404)throw new v(`${t} has no tapster environment yet`,"Run tapster init in a clone of the hub first.");throw r}}import{lstatSync as Jg,readFileSync as uE}from"fs";import{mkdir as pE,readFile as dE,writeFile as hE}from"fs/promises";import{join as Vg}from"path";function vn(e,t=process.env.HOME??""){let n=e.trim();if(n=n.length>1&&(n[0]==="'"||n[0]==='"')&&n.at(-1)===n[0]?n.slice(1,-1):n.replace(/\\(.)/g,"$1"),!n)throw new v("no path was given","Type the path or drag the file into the terminal.");return n.replace(/^~(?=\/|$)/,t)}async function yn(e,t){try{return await dE(e)}catch(n){let r=n.code;if(r==="ENOENT")throw new v(`${e} does not exist`,`Check the path of ${t}.`);if(r==="EISDIR")throw new v(`${e} is a folder`,`Give the path of ${t} itself.`);throw new v(`${e} cannot be read`,`Check that you can open ${t}.`)}}function fs(e,t=1048576){try{let n=Jg(e);if(!n.isFile()||n.size>t)return null;return uE(e)}catch{return null}}var oe=(e,t=1048576)=>fs(e,t)?.toString("utf8")??null;function vr(e,t,n=1048576){let r=oe(e,n);if(r===null)throw new v(`${t} is not a regular file tapster can read`,"Replace a link or a very large file with the file itself, then try again.");return r}var Yg=(e)=>{try{return Jg(e)}catch{return null}};async function yr(e,t,n){let r=t.split("/"),i=e;for(let a of r.slice(0,-1)){i=Vg(i,a);let c=Yg(i);if(c&&!c.isDirectory())throw new v(`${t} would be written through a link or a file`,"Replace the link with a real folder, then try again.");if(!c)await pE(i)}let s=Vg(e,t),o=Yg(s);if(o&&!o.isFile())throw new v(`${t} is not a regular file`,"Replace the link with the file itself, then try again.");await hE(s,n)}async function ms(e,t={}){let{timeoutMs:n=600000,intervalMs:r=3000,sleep:i=(a)=>new Promise((c)=>setTimeout(c,a)),now:s=Date.now}=t,o=s()+n;for(;;){let a=await e();if(a!==null)return a;if(s()+r>o)return null;await i(r)}}import{createInterface as fE}from"readline";function me(e,t=!1){return new Promise((n)=>{let r=fE({input:process.stdin,output:process.stdout,terminal:!0});if(t)r._writeToOutput=(i)=>{if(i.includes(e))process.stdout.write(e)};r.question(e,(i)=>{if(r.close(),t)process.stdout.write(`
702
+ <p class="local">You can close this tab.</p>`,"fail")}function Zt(e){console.log(` ${e}`),D(process.platform==="darwin"?"/usr/bin/open":"/usr/bin/xdg-open","open",[e],{allowFail:!0}).catch(()=>{return})}var oE={"contents:write":"Contents, read and write: publish releases and their files in the repositories you install it on. Your rulesets keep it from creating or moving branches and tags.","attestations:read":"Attestations, read: check that each file was built by the project's own workflow.","metadata:read":"Metadata, read: every GitHub App has this. It sees the names of the repositories you install it on.","actions:write":"Actions, read and write, on the hub only: start the tapster workflow and turn it back on when GitHub pauses it."};function Mc(e){let t=e.default_permissions??{};return Object.entries(t).map(([n,r])=>{let i=oE[`${n}:${r}`];if(!i)throw new v(`the App asks for ${n}: ${r}, which tapster cannot explain`,"Report this at https://github.com/doguyilmaz/tapster/issues.");return i})}var aE={"content-type":"text/html; charset=utf-8","content-security-policy":"default-src 'none'; style-src 'unsafe-inline'; img-src data:; form-action https://github.com; base-uri 'none'; frame-ancestors 'none'","cache-control":"no-store","referrer-policy":"no-referrer","x-content-type-options":"nosniff"};function cE(e){let t=`http://127.0.0.1:${e.port}`,n=!1,r=(i,s=200)=>new Response(i,{status:s,headers:aE});return(i)=>{if(i.headers.get("host")!==`127.0.0.1:${e.port}`)return new Response("Forbidden",{status:403});let s=new URL(i.url);if(s.pathname==="/start"){let a=e.manifest(`${t}/callback`);return r(Bg({...e.copy,permissions:Mc(a),action:`https://github.com/settings/apps/new?state=${e.state}`,manifest:JSON.stringify(a)}))}if(s.pathname!=="/callback")return new Response("Not found",{status:404});if(n)return r(Dc({reason:"This App was already handled.",again:e.copy.again}),409);let o=s.searchParams.get("code");if(s.searchParams.get("state")!==e.state||!o||!/^[A-Za-z0-9_-]{1,128}$/.test(o))return r(Dc({reason:"This answer did not belong to the App this terminal started, so tapster ignored it.",again:e.copy.again}),400);return n=!0,e.settle({code:o}),r(Hg({title:e.copy.done,next:e.copy.next}))}}function lE(e,t){let n=e.owner?.login??"nobody";if(n.toLowerCase()!==t.toLowerCase())throw new v(`the new App belongs to ${n}, not ${t}`,"tapster stored nothing. Create the App from your own account, then run this again.")}async function ps(e,t,n){let r=sE(16).toString("hex"),i=()=>{},s=new Promise((p)=>i=p),o=()=>new Response(null,{status:503}),a=Bun.serve({hostname:"127.0.0.1",port:0,fetch:(p)=>o(p)});o=cE({manifest:e,copy:t,state:r,port:a.port,settle:i}),console.log(`Opening GitHub to create ${t.what}. Read the page, then click "Continue to GitHub" and "Create GitHub App".`),Zt(`http://127.0.0.1:${a.port}/start`),console.log("tapster waits up to 30 minutes until GitHub sends you back. If no page opened, open the address above. Ctrl+C stops it.");let c="If GitHub created the App anyway, delete it at https://github.com/settings/apps first, because its name would block a new one.",l=setTimeout(()=>i({error:new v("no App was created within 30 minutes",`${c} Then run ${t.again} again.`)}),1800000),u=await s;if(clearTimeout(l),setTimeout(()=>a.stop(),1000),"error"in u)throw u.error;return Uc(u.code,n,`${c} Then run ${t.again} again.`)}async function Uc(e,t,n,r=fetch){let i=await r(`https://api.github.com/app-manifests/${e}/conversions`,{method:"POST",headers:{Accept:"application/vnd.github+json"}});if(!i.ok)throw new v(`GitHub did not hand over the new App (status ${i.status})`,n);let s=await i.json();return lE(s,t),s}var Fg=()=>({HOME:process.env.HOME??"/tmp",...process.env.GH_CONFIG_DIR?{GH_CONFIG_DIR:process.env.GH_CONFIG_DIR}:{},GH_PROMPT_DISABLED:"1"});function Kg(e){try{return Rg(e)}catch{throw new v("the GitHub CLI (gh) is not installed","Install it (brew install gh or see https://cli.github.com), sign in with gh auth login, then run this again.")}}async function At(){let e=await D(Kg(),"gh",["auth","token"],{env:Fg(),allowFail:!0}),t=e.stdout.trim();if(e.code!==0||!t)throw new v("gh is not signed in","Run gh auth login, then try again.");return new pe(t,fetch,void 0,"user")}async function He(e=process.cwd()){let t=(await Pe("git",["-C",e,"remote","get-url","origin"],{allowFail:!0})).stdout.trim(),n=/github\.com[:/]([A-Za-z0-9-]+\/[A-Za-z0-9._-]+?)(?:\.git)?$/.exec(t);if(!n)throw new v("this folder is not a clone of a GitHub repository","Run tapster inside a clone (git remote origin on github.com).");return n[1]}var ds=async(e,t)=>{await D(Kg(),"gh",e,{env:Fg(),stdin:t})};var ee=(e,t,n,r="tapster")=>ds(["secret","set",t,"--env",r,"--repo",e],n),ze=(e,t,n)=>ds(["variable","set",t,"--env","tapster","--repo",e,"--body",n]),hs=(e,t,n)=>ds(["variable","set",t,"--repo",e,"--body",n]),Wg=(e,t,n="tapster")=>ds(["secret","delete",t,"--env",n,"--repo",e]);async function Gt(e,t,n){try{return(await e.json("GET",`/repos/${t}/environments/tapster/${n}?per_page=100`))[n]??[]}catch(r){if(r instanceof R&&r.status===404)throw new v(`${t} has no tapster environment yet`,"Run tapster init in a clone of the hub first.");throw r}}import{lstatSync as Jg,readFileSync as uE}from"fs";import{mkdir as pE,readFile as dE,writeFile as hE}from"fs/promises";import{join as Vg}from"path";function vn(e,t=process.env.HOME??""){let n=e.trim();if(n=n.length>1&&(n[0]==="'"||n[0]==='"')&&n.at(-1)===n[0]?n.slice(1,-1):n.replace(/\\(.)/g,"$1"),!n)throw new v("no path was given","Type the path or drag the file into the terminal.");return n.replace(/^~(?=\/|$)/,t)}async function yn(e,t){try{return await dE(e)}catch(n){let r=n.code;if(r==="ENOENT")throw new v(`${e} does not exist`,`Check the path of ${t}.`);if(r==="EISDIR")throw new v(`${e} is a folder`,`Give the path of ${t} itself.`);throw new v(`${e} cannot be read`,`Check that you can open ${t}.`)}}function fs(e,t=1048576){try{let n=Jg(e);if(!n.isFile()||n.size>t)return null;return uE(e)}catch{return null}}var oe=(e,t=1048576)=>fs(e,t)?.toString("utf8")??null;function vr(e,t,n=1048576){let r=oe(e,n);if(r===null)throw new v(`${t} is not a regular file tapster can read`,"Replace a link or a very large file with the file itself, then try again.");return r}var Yg=(e)=>{try{return Jg(e)}catch{return null}};async function yr(e,t,n){let r=t.split("/"),i=e;for(let a of r.slice(0,-1)){i=Vg(i,a);let c=Yg(i);if(c&&!c.isDirectory())throw new v(`${t} would be written through a link or a file`,"Replace the link with a real folder, then try again.");if(!c)await pE(i)}let s=Vg(e,t),o=Yg(s);if(o&&!o.isFile())throw new v(`${t} is not a regular file`,"Replace the link with the file itself, then try again.");await hE(s,n)}async function ms(e,t={}){let{timeoutMs:n=600000,intervalMs:r=3000,sleep:i=(a)=>new Promise((c)=>setTimeout(c,a)),now:s=Date.now}=t,o=s()+n;for(;;){let a=await e();if(a!==null)return a;if(s()+r>o)return null;await i(r)}}import{createInterface as fE}from"readline";function me(e,t=!1){return new Promise((n)=>{let r=fE({input:process.stdin,output:process.stdout,terminal:!0});if(t)r._writeToOutput=(i)=>{if(i.includes(e))process.stdout.write(e)};r.question(e,(i)=>{if(r.close(),t)process.stdout.write(`
703
703
  `);n(i.trim())})})}import{mkdtempSync as mE,rmSync as gE}from"fs";import{tmpdir as vE}from"os";import{join as yE}from"path";var Zc=new Set;function $t(e){let t=mE(yE(vE(),e));return Zc.add(t),t}function Fe(e){gE(e,{recursive:!0,force:!0}),Zc.delete(e)}function bE(){for(let e of[...Zc])Fe(e)}process.on("SIGINT",()=>{bE(),process.exit(130)});function gs(e){if(Number.isInteger(e)&&e>=5&&e<60&&60%e===0)return`7-59/${e} * * * *`;if(e===60)return"7 * * * *";let t=e/60;if(Number.isInteger(t)&&t>1&&t<=24&&24%t===0)return`7 */${t} * * *`;throw new v(`${e} minutes is not an interval tapster can schedule`,"Use 5, 6, 10, 12, 15, 20 or 30 minutes. Longer intervals must be 60 minutes times a divisor of 24.")}function rt(e){let t=ne(e)?.on?.schedule?.[0]?.cron;if(!t)return null;let n=/^7-59\/(\d+) \* \* \* \*$/.exec(t)??null;if(n)return Number(n[1]);if(t==="7 * * * *")return 60;let r=/^7 \*\/(\d+) \* \* \*$/.exec(t);return r?Number(r[1])*60:null}function Qg(e){if(e<60)return`*/${e} * * * *`;return e===60?"0 * * * *":`0 */${e/60} * * *`}var Xg=(e)=>e.default,_r=(e)=>Ug.trimEnd().split(`
704
704
  `).map((t)=>`${" ".repeat(e)}${t}`).join(`
705
705
  `);function xE(e,t,n){return{name:`tapster-doorbell-${e}-${t.split("/")[1].replace(/^homebrew-/,"")}`.toLowerCase().slice(0,34),url:`https://github.com/${t}`,redirect_url:n,public:!1,default_permissions:{actions:"write",metadata:"read"},default_events:[],hook_attributes:{url:"https://example.com/tapster-has-no-webhook",active:!1}}}function SE(e){for(let n of["APP_ID","INSTALLATION_ID","HUB_ID","OWNER_ID","INTERVAL"])if(!/^[0-9]+$/.test(e[n]))throw new v(`${n} must be a number`,"Run tapster init --doorbell again.");if(!/^[A-Za-z0-9-]+\/[A-Za-z0-9._-]+$/.test(e.HUB))throw new v("the hub name is not owner/repo","Run it in the hub clone.");let t={crons:[Qg(Number(e.INTERVAL))]};return`${JSON.stringify({name:"tapster-doorbell",main:"worker.ts",compatibility_date:"2026-10-01",workers_dev:!0,vars:e,triggers:t},null,2)}
@@ -707,7 +707,7 @@ ${t}
707
707
  `)){let n;try{n=JSON.parse(t)}catch{continue}if(n.type!=="deploy"||!Array.isArray(n.targets))continue;for(let r of n.targets)if(typeof r==="string"&&/^https:\/\/[a-z0-9-]+\.[a-z0-9-]+\.workers\.dev\/?$/.test(r))return new URL(r).origin}return null}function $E(e){let t=`${e.stdout}
708
708
  ${e.stderr??""}`.split(`
709
709
  `).map((r)=>r.trim()).filter(Boolean),n=t.filter((r)=>/\[ERROR\]/.test(r));return(n.length?n:t).slice(-2).join(" / ")||"no output"}var PE=(e)=>({PATH:e,BUN_BE_BUN:"1"});function tv(e){let t=(n)=>e.variables.some((r)=>r.name===n);if(t("TAPSTER_DOORBELL"))return"done";return t("TAPSTER_DOORBELL_APP_ID")&&t("TAPSTER_DOORBELL_APP_SLUG")?"resume":"new"}var wr="Run tapster init --doorbell again; it continues with the App it already created.";async function nv(e,t){console.log(`Open the doorbell App's settings, scroll to "Private keys" and click "Generate a private key":`),Zt(`https://github.com/settings/apps/${t}`);let n=vn(await me("Path of the downloaded .pem file (drag it here): ")),r=(await yn(n,"the .pem file")).toString("utf8");return await new pe(Be(e,r)).json("GET","/app").catch(()=>{throw new v("that key does not belong to the doorbell App",`Generate the key on https://github.com/settings/apps/${t}.`)}),console.log(`Once tapster is done, delete ${n} and every older key on that page.`),r}function TE(){for(let e of(process.env.PATH??"").split(Gc))if(e&&ev(Ke(e,"node")))return Ke(e,"node");throw new v("Wrangler needs Node.js, which is not on PATH","Install Node.js 20 or newer, then run this again.")}async function rv(){let e=$t("tapster-doorbell-");await br(Ke(e,"package.json"),`${JSON.stringify(Gg,null,2)}
710
- `),await br(Ke(e,"bun.lock"),Zg),await L(process.execPath,"bun",["install","--frozen-lockfile","--ignore-scripts"],{cwd:e,env:PE(process.env.PATH??"")});let t=TE(),n=Ke(e,"node_modules","wrangler","bin","wrangler.js"),r=Object.fromEntries(["CLOUDFLARE_API_TOKEN","CLOUDFLARE_ACCOUNT_ID"].flatMap((s)=>process.env[s]?[[s,process.env[s]]]:[])),i={PATH:`${Ke(t,"..")}${Gc}/usr/bin${Gc}/bin`,WRANGLER_SEND_METRICS:"false",...r};return{dir:e,run(s,o={}){if(o.interactive)return new Promise((a)=>{_E(t,[n,...s],{cwd:e,stdio:"inherit",env:{HOME:process.env.HOME??"",...i,...o.env}}).on("close",(l)=>a({code:l??1,stdout:""}))});return L(t,"wrangler",[n,...s],{cwd:e,env:{...i,...o.env},stdin:o.stdin,allowFail:!0})}}}async function iv(e){if((await e.run(["whoami"])).code===0)return;if(console.log("Sign in to Cloudflare in the browser that opens."),(await e.run(["login"],{interactive:!0})).code!==0)throw new v("Wrangler could not sign in to Cloudflare","Run tapster init --doorbell again.")}async function sv(e,t,n){let r=new pe(Be(e,t));console.log(`Waiting until the App is installed on ${n} (only that repository); tapster continues by itself.`);let i=await ms(()=>r.json("GET",`/repos/${n}/installation`).then((s)=>s.id,()=>null));if(i!==null)return i;throw new v(`the doorbell App was not installed on ${n} within 10 minutes`,`Install it on ${n}, then ${wr.charAt(0).toLowerCase()}${wr.slice(1)}`)}async function ov(e,t,n,r,i,s,o){let a=(await t.json("GET",`/users/${n.split("/")[0]}`)).id,c=(await t.getRepo(n)).id;await br(Ke(e.dir,"worker.ts"),Xg(jc)),await br(Ke(e.dir,"jwt.ts"),Xg(zc)),await br(Ke(e.dir,"wrangler.jsonc"),SE({APP_ID:r,INSTALLATION_ID:String(o),HUB:n,HUB_ID:String(c),OWNER_ID:String(a),INTERVAL:String(s)}));let l=Ke(e.dir,"out.ndjson"),u=await e.run(["deploy"],{env:{WRANGLER_OUTPUT_FILE_PATH:l}});if(u.code!==0)throw new v(`Wrangler could not deploy the doorbell: ${$E(u)}`,wr);let p=AE(ev(l)?kE(l,"utf8"):"");if(!p)throw new v("the doorbell has no workers.dev address",`Create your workers.dev subdomain in the Cloudflare dashboard (Workers & Pages). ${wr}`);let d=wE(i).export({type:"pkcs8",format:"pem"}).toString();if((await e.run(["secret","put","APP_KEY"],{stdin:d})).code!==0)throw new v("Wrangler could not store the doorbell key",wr);return await ze(n,"TAPSTER_DOORBELL_EVERY",String(s)),p}async function av(e,t,n,r,i){let s={variables:(await Gt(e,t,"variables")).map((c)=>({name:c.name,value:c.value??""}))},o=tv(s);if(o==="done")throw new v("the hub already has a doorbell","Run tapster init --rotate doorbell to replace its key. To start over, delete the App and the TAPSTER_DOORBELL variables.");let a=await rv();try{await iv(a);let[c]=t.split("/"),l,u;if(o==="resume")l=s.variables.find((d)=>d.name==="TAPSTER_DOORBELL_APP_ID").value,console.log("Continuing with the doorbell App created earlier."),u=await nv(l,s.variables.find((d)=>d.name==="TAPSTER_DOORBELL_APP_SLUG").value);else{let d=await ps((h)=>xE(c,t,h),{what:"the doorbell App",title:"Create the doorbell App",lead:`GitHub asks you to confirm a second private App. The doorbell uses it only to start ${t}'s workflow when a project releases.`,key:"GitHub hands the App's private key to tapster in your terminal, once. tapster stores it as a secret of the doorbell Worker in your Cloudflare account. It goes nowhere else and no one else receives it.",done:"The doorbell App is created",next:["tapster opens the App's install page in a new tab.",`There, choose "Only select repositories" and pick ${t}, only that one.`,'Click "Install". tapster notices within seconds and deploys the Worker.'],again:"tapster init --doorbell"},c);l=String(d.id),u=d.pem,await ze(t,"TAPSTER_DOORBELL_APP_ID",l),await ze(t,"TAPSTER_DOORBELL_APP_SLUG",d.slug),Zt(`https://github.com/apps/${d.slug}/installations/new`)}let p=await ov(a,e,t,l,u,i,await sv(l,u,t));for(let d of n.packages)await r(d.repo,"TAPSTER_DOORBELL",p);await ze(t,"TAPSTER_DOORBELL",p),console.log(`The doorbell answers at ${p}. Projects ring it after opening a draft.`)}finally{Fe(a.dir)}}async function cv(e,t,n){let r=await e.json("GET",`/repos/${t}/environments/tapster/variables`);if(tv(r)!=="done")throw new v("the hub has no working doorbell yet","Run tapster init --doorbell.");let i=r.variables.find((a)=>a.name==="TAPSTER_DOORBELL_APP_ID").value,s=await nv(i,r.variables.find((a)=>a.name==="TAPSTER_DOORBELL_APP_SLUG").value),o=await rv();try{await iv(o),await ov(o,e,t,i,s,n,await sv(i,s,t))}finally{Fe(o.dir)}console.log(`Deployed the doorbell again with the new key; it starts the hub every ${n} minutes. Now delete every other key on the App's settings page.`)}var We={"actions/checkout":{tag:"v7.0.1",sha:"3d3c42e5aac5ba805825da76410c181273ba90b1"},"actions/attest-build-provenance":{tag:"v4.2.2",sha:"4d101475d8b20a2381f78447822ac1eab6504dd8"},"oven-sh/setup-bun":{tag:"v2.2.0",sha:"0c5077e51419868618aeaa5fe8019c62421857d6"},"actions/upload-artifact":{tag:"v7.0.1",sha:"043fb46d1a93c77aae656e7c1c64a875d1fc6a0a"},"actions/download-artifact":{tag:"v8.0.1",sha:"3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c"},"actions/upload-pages-artifact":{tag:"v5.0.0",sha:"fc324d3547104276b827a68afc52ff2a11cc49c9"},"actions/deploy-pages":{tag:"v5.0.1",sha:"368f82528645a54fb793d4d04e342629a3f51346"}};var lv=`name: release
710
+ `),await br(Ke(e,"bun.lock"),Zg),await D(process.execPath,"bun",["install","--frozen-lockfile","--ignore-scripts"],{cwd:e,env:PE(process.env.PATH??"")});let t=TE(),n=Ke(e,"node_modules","wrangler","bin","wrangler.js"),r=Object.fromEntries(["CLOUDFLARE_API_TOKEN","CLOUDFLARE_ACCOUNT_ID"].flatMap((s)=>process.env[s]?[[s,process.env[s]]]:[])),i={PATH:`${Ke(t,"..")}${Gc}/usr/bin${Gc}/bin`,WRANGLER_SEND_METRICS:"false",...r};return{dir:e,run(s,o={}){if(o.interactive)return new Promise((a)=>{_E(t,[n,...s],{cwd:e,stdio:"inherit",env:{HOME:process.env.HOME??"",...i,...o.env}}).on("close",(l)=>a({code:l??1,stdout:""}))});return D(t,"wrangler",[n,...s],{cwd:e,env:{...i,...o.env},stdin:o.stdin,allowFail:!0})}}}async function iv(e){if((await e.run(["whoami"])).code===0)return;if(console.log("Sign in to Cloudflare in the browser that opens."),(await e.run(["login"],{interactive:!0})).code!==0)throw new v("Wrangler could not sign in to Cloudflare","Run tapster init --doorbell again.")}async function sv(e,t,n){let r=new pe(Be(e,t));console.log(`Waiting until the App is installed on ${n} (only that repository); tapster continues by itself.`);let i=await ms(()=>r.json("GET",`/repos/${n}/installation`).then((s)=>s.id,()=>null));if(i!==null)return i;throw new v(`the doorbell App was not installed on ${n} within 10 minutes`,`Install it on ${n}, then ${wr.charAt(0).toLowerCase()}${wr.slice(1)}`)}async function ov(e,t,n,r,i,s,o){let a=(await t.json("GET",`/users/${n.split("/")[0]}`)).id,c=(await t.getRepo(n)).id;await br(Ke(e.dir,"worker.ts"),Xg(Lc)),await br(Ke(e.dir,"jwt.ts"),Xg(zc)),await br(Ke(e.dir,"wrangler.jsonc"),SE({APP_ID:r,INSTALLATION_ID:String(o),HUB:n,HUB_ID:String(c),OWNER_ID:String(a),INTERVAL:String(s)}));let l=Ke(e.dir,"out.ndjson"),u=await e.run(["deploy"],{env:{WRANGLER_OUTPUT_FILE_PATH:l}});if(u.code!==0)throw new v(`Wrangler could not deploy the doorbell: ${$E(u)}`,wr);let p=AE(ev(l)?kE(l,"utf8"):"");if(!p)throw new v("the doorbell has no workers.dev address",`Create your workers.dev subdomain in the Cloudflare dashboard (Workers & Pages). ${wr}`);let d=wE(i).export({type:"pkcs8",format:"pem"}).toString();if((await e.run(["secret","put","APP_KEY"],{stdin:d})).code!==0)throw new v("Wrangler could not store the doorbell key",wr);return await ze(n,"TAPSTER_DOORBELL_EVERY",String(s)),p}async function av(e,t,n,r,i){let s={variables:(await Gt(e,t,"variables")).map((c)=>({name:c.name,value:c.value??""}))},o=tv(s);if(o==="done")throw new v("the hub already has a doorbell","Run tapster init --rotate doorbell to replace its key. To start over, delete the App and the TAPSTER_DOORBELL variables.");let a=await rv();try{await iv(a);let[c]=t.split("/"),l,u;if(o==="resume")l=s.variables.find((d)=>d.name==="TAPSTER_DOORBELL_APP_ID").value,console.log("Continuing with the doorbell App created earlier."),u=await nv(l,s.variables.find((d)=>d.name==="TAPSTER_DOORBELL_APP_SLUG").value);else{let d=await ps((h)=>xE(c,t,h),{what:"the doorbell App",title:"Create the doorbell App",lead:`GitHub asks you to confirm a second private App. The doorbell uses it only to start ${t}'s workflow when a project releases.`,key:"GitHub hands the App's private key to tapster in your terminal, once. tapster stores it as a secret of the doorbell Worker in your Cloudflare account. It goes nowhere else and no one else receives it.",done:"The doorbell App is created",next:["tapster opens the App's install page in a new tab.",`There, choose "Only select repositories" and pick ${t}, only that one.`,'Click "Install". tapster notices within seconds and deploys the Worker.'],again:"tapster init --doorbell"},c);l=String(d.id),u=d.pem,await ze(t,"TAPSTER_DOORBELL_APP_ID",l),await ze(t,"TAPSTER_DOORBELL_APP_SLUG",d.slug),Zt(`https://github.com/apps/${d.slug}/installations/new`)}let p=await ov(a,e,t,l,u,i,await sv(l,u,t));for(let d of n.packages)await r(d.repo,"TAPSTER_DOORBELL",p);await ze(t,"TAPSTER_DOORBELL",p),console.log(`The doorbell answers at ${p}. Projects ring it after opening a draft.`)}finally{Fe(a.dir)}}async function cv(e,t,n){let r=await e.json("GET",`/repos/${t}/environments/tapster/variables`);if(tv(r)!=="done")throw new v("the hub has no working doorbell yet","Run tapster init --doorbell.");let i=r.variables.find((a)=>a.name==="TAPSTER_DOORBELL_APP_ID").value,s=await nv(i,r.variables.find((a)=>a.name==="TAPSTER_DOORBELL_APP_SLUG").value),o=await rv();try{await iv(o),await ov(o,e,t,i,s,n,await sv(i,s,t))}finally{Fe(o.dir)}console.log(`Deployed the doorbell again with the new key; it starts the hub every ${n} minutes. Now delete every other key on the App's settings page.`)}var We={"actions/checkout":{tag:"v7.0.1",sha:"3d3c42e5aac5ba805825da76410c181273ba90b1"},"actions/attest-build-provenance":{tag:"v4.2.2",sha:"4d101475d8b20a2381f78447822ac1eab6504dd8"},"oven-sh/setup-bun":{tag:"v2.2.0",sha:"0c5077e51419868618aeaa5fe8019c62421857d6"},"actions/upload-artifact":{tag:"v7.0.1",sha:"043fb46d1a93c77aae656e7c1c64a875d1fc6a0a"},"actions/download-artifact":{tag:"v8.0.1",sha:"3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c"},"actions/upload-pages-artifact":{tag:"v5.0.0",sha:"fc324d3547104276b827a68afc52ff2a11cc49c9"},"actions/deploy-pages":{tag:"v5.0.1",sha:"368f82528645a54fb793d4d04e342629a3f51346"}};var lv=`name: release
711
711
  on:
712
712
  push:
713
713
  tags: ["v[0-9]+.[0-9]+.[0-9]+"]
@@ -819,14 +819,14 @@ __RING__
819
819
  ${t}${e.slice(a)}`;if(!s.flow){let l=e.slice(0,a);return`${l}${l.endsWith(`
820
820
  `)?"":`
821
821
  `}${t}
822
- ${e.slice(a)}`}let c=yt(t).contents;if(!vt(c)||c.items.length!==1)throw new v("the entry is not one package","Report this as a tapster bug.");return s.flow=!1,s.items.push(c.items[0]),xr(e,r.toString(kr))}function NE(e,t){if(!e||xt(e,t).length===0)return null;let n=e.trim().replace(/^(?:the|an?)\s+/i,"").replace(/command ?line/gi,"command-line").replace(/\.$/,"");return n=n.charAt(0).toUpperCase()+n.slice(1),xt(n,t).length===0?n:null}var zE=["name","ids","repository","commit_msg_template","commit_author","directory","skip_upload","url","url_template","description","homepage","license","completions","custom_block","binaries","uninstall","zap","hooks","caveats"],jE=/^system_command\s+"#\{HOMEBREW_PREFIX\}\/bin\/([A-Za-z0-9._-]+)"(?:,\s*args:\s*\[((?:\s*"[A-Za-z0-9._:=@%+,\/-]+"\s*,?)*)\])?,\s*must_succeed:\s*false$/,DE=/^[A-Za-z0-9._-]+(\/[A-Za-z0-9._-]+)*$/;function dv(e,t={}){let n=null;try{n=e?ne(e):null}catch{n=null}let r=n?.homebrew_casks?.[0]??n?.brews?.[0];if(!r)return{lines:[],description:null,carried:[],notes:[]};let i=(_)=>typeof _==="string"&&_.trim()&&!_.includes("{{")?_.trim():null,s=(_,y)=>Array.isArray(_)?_.map(i).filter((x)=>x!==null&&y.test(x)):[],o=[],a=[],c=[],l=Object.keys(r).filter((_)=>!zE.includes(_));l.push(...Object.keys(r.uninstall??{}).filter((_)=>_!=="launchctl"&&_!=="quit").map((_)=>`uninstall.${_}`)),l.push(...Object.keys(r.zap??{}).filter((_)=>_!=="trash").map((_)=>`zap.${_}`));let u=null;for(let _ of String(r.custom_block??"").split(`
823
- `).map((y)=>y.trim()).filter(Boolean)){let y=/^app\s+"([A-Za-z0-9 ._-]+\.app)"$/.exec(_)?.[1];if(y&&!u)u=y;else l.push(`custom_block: ${_}`)}let p=null;for(let[_,y]of Object.entries(r.hooks??{}))for(let[x,S]of Object.entries(y??{})){let O=_==="post"&&x==="install"?jE.exec(String(S).trim()):null;if(O)p={binary:O[1],args:[...(O[2]??"").matchAll(/"([^"]+)"/g)].map((A)=>A[1])};else l.push(`hooks.${_}.${x}`)}let d=i(r.homepage);if(d&&/^https:\/\/[^\s"]+$/.test(d))o.push(` homepage: ${JSON.stringify(d)}`),a.push("homepage");let h=i(r.license);if(h&&/^[A-Za-z0-9.+-]+$/.test(h))o.push(` license: ${h}`),a.push("license");let f=Object.entries(r.completions??{}).filter(([_,y])=>["bash","zsh","fish"].includes(_)&&/^[A-Za-z0-9._-]+(\/[A-Za-z0-9._-]+)*$/.test(i(y)??""));if(f.length)o.push(" completions:",...f.map(([_,y])=>` ${_}: ${i(y)}`)),a.push("completions");if(u&&t.mac!==!1){let _=`#{appdir}/${u}/`,y=s(r.binaries,/^#\{appdir\}\//).filter((S)=>S.startsWith(_)&&DE.test(S.slice(_.length))).map((S)=>S.slice(_.length)),x=t.bundleId?.(u)??null;if(o.push(" app:",` name: ${JSON.stringify(u)}`,` bundle_id: ${x??"<bundle id>"}`,...y.length?[` binaries: ${JSON.stringify(y)}`]:[]),a.push("app"),c.push(`the hub signs, notarizes and staples ${u}; a build hook must now sign it ad hoc only (codesign --force --sign -)`),!x)c.push(`no Info.plist here names ${u}; set app.bundle_id in the hub entry`)}let m=s(r.uninstall?.launchctl,/^[A-Za-z0-9.-]+$/),g=s(r.uninstall?.quit,/^[A-Za-z0-9.-]+$/),w=s(r.zap?.trash,/^~\/[A-Za-z0-9 ._\/-]+$/),k=i(r.caveats);if(m.length||g.length||w.length||p||k){if(o.push(" cask:"),m.length||g.length)o.push(" uninstall:",...m.length?[` launchctl: ${JSON.stringify(m)}`]:[],...g.length?[` quit: ${JSON.stringify(g)}`]:[]);if(w.length)o.push(" zap:",` trash: ${JSON.stringify(w)}`);if(p)o.push(` postflight: { binary: ${JSON.stringify(p.binary)}, args: ${JSON.stringify(p.args)} }`);if(k)o.push(` caveats: ${JSON.stringify(k.slice(0,2000))}`);a.push(...[m.length||g.length?"uninstall":"",w.length?"zap":"",p?"post-install command":"",k?"caveats":""].filter(Boolean))}if(p)c.push(`Homebrew runs the post-install command in its sandbox, without network or your home folder; check that ${[p.binary,...p.args].join(" ")} works there`);if(l.length)c.push(`not carried from GoReleaser's Homebrew section: ${l.join(", ").replace(/[\u0000-\u001f\u007f-\u009f]/g,"")}`);return{lines:o,description:i(r.description),carried:a,notes:c}}function hv(e,t){let n=e;if(t.kind==="go"&&t.workflow!=="release.yml")n+=`
822
+ ${e.slice(a)}`}let c=yt(t).contents;if(!vt(c)||c.items.length!==1)throw new v("the entry is not one package","Report this as a tapster bug.");return s.flow=!1,s.items.push(c.items[0]),xr(e,r.toString(kr))}function NE(e,t){if(!e||xt(e,t).length===0)return null;let n=e.trim().replace(/^(?:the|an?)\s+/i,"").replace(/command ?line/gi,"command-line").replace(/\.$/,"");return n=n.charAt(0).toUpperCase()+n.slice(1),xt(n,t).length===0?n:null}var zE=["name","ids","repository","commit_msg_template","commit_author","directory","skip_upload","url","url_template","description","homepage","license","completions","custom_block","binaries","uninstall","zap","hooks","caveats"],LE=/^system_command\s+"#\{HOMEBREW_PREFIX\}\/bin\/([A-Za-z0-9._-]+)"(?:,\s*args:\s*\[((?:\s*"[A-Za-z0-9._:=@%+,\/-]+"\s*,?)*)\])?,\s*must_succeed:\s*false$/,jE=/^[A-Za-z0-9._-]+(\/[A-Za-z0-9._-]+)*$/;function dv(e,t={}){let n=null;try{n=e?ne(e):null}catch{n=null}let r=n?.homebrew_casks?.[0]??n?.brews?.[0];if(!r)return{lines:[],description:null,carried:[],notes:[]};let i=(_)=>typeof _==="string"&&_.trim()&&!_.includes("{{")?_.trim():null,s=(_,y)=>Array.isArray(_)?_.map(i).filter((x)=>x!==null&&y.test(x)):[],o=[],a=[],c=[],l=Object.keys(r).filter((_)=>!zE.includes(_));l.push(...Object.keys(r.uninstall??{}).filter((_)=>_!=="launchctl"&&_!=="quit").map((_)=>`uninstall.${_}`)),l.push(...Object.keys(r.zap??{}).filter((_)=>_!=="trash").map((_)=>`zap.${_}`));let u=null;for(let _ of String(r.custom_block??"").split(`
823
+ `).map((y)=>y.trim()).filter(Boolean)){let y=/^app\s+"([A-Za-z0-9 ._-]+\.app)"$/.exec(_)?.[1];if(y&&!u)u=y;else l.push(`custom_block: ${_}`)}let p=null;for(let[_,y]of Object.entries(r.hooks??{}))for(let[x,S]of Object.entries(y??{})){let O=_==="post"&&x==="install"?LE.exec(String(S).trim()):null;if(O)p={binary:O[1],args:[...(O[2]??"").matchAll(/"([^"]+)"/g)].map((A)=>A[1])};else l.push(`hooks.${_}.${x}`)}let d=i(r.homepage);if(d&&/^https:\/\/[^\s"]+$/.test(d))o.push(` homepage: ${JSON.stringify(d)}`),a.push("homepage");let h=i(r.license);if(h&&/^[A-Za-z0-9.+-]+$/.test(h))o.push(` license: ${h}`),a.push("license");let f=Object.entries(r.completions??{}).filter(([_,y])=>["bash","zsh","fish"].includes(_)&&/^[A-Za-z0-9._-]+(\/[A-Za-z0-9._-]+)*$/.test(i(y)??""));if(f.length)o.push(" completions:",...f.map(([_,y])=>` ${_}: ${i(y)}`)),a.push("completions");if(u&&t.mac!==!1){let _=`#{appdir}/${u}/`,y=s(r.binaries,/^#\{appdir\}\//).filter((S)=>S.startsWith(_)&&jE.test(S.slice(_.length))).map((S)=>S.slice(_.length)),x=t.bundleId?.(u)??null;if(o.push(" app:",` name: ${JSON.stringify(u)}`,` bundle_id: ${x??"<bundle id>"}`,...y.length?[` binaries: ${JSON.stringify(y)}`]:[]),a.push("app"),c.push(`the hub signs, notarizes and staples ${u}; a build hook must now sign it ad hoc only (codesign --force --sign -)`),!x)c.push(`no Info.plist here names ${u}; set app.bundle_id in the hub entry`)}let m=s(r.uninstall?.launchctl,/^[A-Za-z0-9.-]+$/),g=s(r.uninstall?.quit,/^[A-Za-z0-9.-]+$/),w=s(r.zap?.trash,/^~\/[A-Za-z0-9 ._\/-]+$/),k=i(r.caveats);if(m.length||g.length||w.length||p||k){if(o.push(" cask:"),m.length||g.length)o.push(" uninstall:",...m.length?[` launchctl: ${JSON.stringify(m)}`]:[],...g.length?[` quit: ${JSON.stringify(g)}`]:[]);if(w.length)o.push(" zap:",` trash: ${JSON.stringify(w)}`);if(p)o.push(` postflight: { binary: ${JSON.stringify(p.binary)}, args: ${JSON.stringify(p.args)} }`);if(k)o.push(` caveats: ${JSON.stringify(k.slice(0,2000))}`);a.push(...[m.length||g.length?"uninstall":"",w.length?"zap":"",p?"post-install command":"",k?"caveats":""].filter(Boolean))}if(p)c.push(`Homebrew runs the post-install command in its sandbox, without network or your home folder; check that ${[p.binary,...p.args].join(" ")} works there`);if(l.length)c.push(`not carried from GoReleaser's Homebrew section: ${l.join(", ").replace(/[\u0000-\u001f\u007f-\u009f]/g,"")}`);return{lines:o,description:i(r.description),carried:a,notes:c}}function hv(e,t){let n=e;if(t.kind==="go"&&t.workflow!=="release.yml")n+=`
824
824
  workflow: ${t.workflow}`;if(t.dependabot)n+=`
825
- protection: dependabot`;return n}function fv(e,t){if(!e)return{line:"- the repository has no description, which Homebrew needs; set one on GitHub or add description: to the hub entry before the first release"};let n=xt(e,t);if(!n.length)return{};let r=NE(e,t);if(!r)return{line:`- Homebrew would reject the repository's description (${n.join(" and ")}); add description: to the hub entry before the first release`};return{line:`- Homebrew would reject the repository's description (${n.join(" and ")}); the entry says "${r}" instead`,add:` description: ${JSON.stringify(r)}`}}var ws=(e)=>e.filter((t)=>/^(HOMEBREW_TAP_|MACOS_)/.test(t)),LE=(e,t,n)=>`https://github.com/apps/${e}/installations/new/permissions?suggested_target_id=${t}&repository_ids[]=${n}`;function mv(e){return[" # in the job that decides the version, on the default branch:"," environment: release"," steps:",` - uses: actions/checkout@${e.sha} # ${e.tag}`,' with: { ssh-key: "${{ secrets.TAPSTER_TAG_KEY }}" }'," # ... compute VERSION ..."," - name: Push the release tag",' run: git tag "v$VERSION" && git push origin "v$VERSION"'].join(`
825
+ protection: dependabot`;return n}function fv(e,t){if(!e)return{line:"- the repository has no description, which Homebrew needs; set one on GitHub or add description: to the hub entry before the first release"};let n=xt(e,t);if(!n.length)return{};let r=NE(e,t);if(!r)return{line:`- Homebrew would reject the repository's description (${n.join(" and ")}); add description: to the hub entry before the first release`};return{line:`- Homebrew would reject the repository's description (${n.join(" and ")}); the entry says "${r}" instead`,add:` description: ${JSON.stringify(r)}`}}var ws=(e)=>e.filter((t)=>/^(HOMEBREW_TAP_|MACOS_)/.test(t)),DE=(e,t,n)=>`https://github.com/apps/${e}/installations/new/permissions?suggested_target_id=${t}&repository_ids[]=${n}`;function mv(e){return[" # in the job that decides the version, on the default branch:"," environment: release"," steps:",` - uses: actions/checkout@${e.sha} # ${e.tag}`,' with: { ssh-key: "${{ secrets.TAPSTER_TAG_KEY }}" }'," # ... compute VERSION ..."," - name: Push the release tag",' run: git tag "v$VERSION" && git push origin "v$VERSION"'].join(`
826
826
  `)}async function ME(e,t){try{let n=await e.json("GET",`/repos/${t}/contents/tapster.yml?ref=main`);return{text:Buffer.from(n.content,"base64").toString("utf8"),sha:n.sha}}catch(n){if(n instanceof R&&n.status===404)throw new v(`${t} has no tapster.yml on main`,"Run tapster init in a clone of the hub and push it first.");throw n}}async function gv(e,t,n,r,i){if(!dn.test(n))throw new v(`${n} is not a valid package name`,"Use lowercase letters, digits and dashes.");let{text:s,sha:o}=await ME(e,t),a=IE(s,i,n),{invalid:c}=ie(a,t.split("/")[0]),l=c.find((f)=>f.name===n);if(l)throw new v(`the hub would refuse this entry: ${l.reason}`,l.fix);let u=`tapster-add-${n}`,p=(await e.json("GET",`/repos/${t}/git/ref/heads/main`)).object.sha;try{await e.json("POST",`/repos/${t}/git/refs`,{ref:`refs/heads/${u}`,sha:p})}catch(f){if(f instanceof R&&f.status===422)throw new v(`the hub already has a branch ${u}`,`Merge or delete it on ${t}, then run tapster add again.`);throw f}await e.json("PUT",`/repos/${t}/contents/tapster.yml`,{message:`Add ${n}`,content:Buffer.from(a).toString("base64"),sha:o,branch:u});let d=[`tapster add prepared this entry for ${r}:`,"","```yaml",i,"```","",`Merge it to let the hub publish ${r}.`].join(`
827
827
  `);return(await e.json("POST",`/repos/${t}/pulls`,{title:`Add ${n}`,head:u,base:"main",body:d})).html_url}async function Sr(e,t){let n=await Gt(e,t,"variables"),r=n.find((i)=>i.name==="TAPSTER_APP_SLUG")?.value;if(!r)throw new v(`${t} has no App yet`,"Run tapster init in a clone of the hub first.");return{slug:r,apple:n.some((i)=>i.name==="TAPSTER_TEAM_ID")}}function vv(e){let t=e.split(`
828
828
  `).filter((r)=>!/^ {6}darwin-[a-z0-9]+: /.test(r)),n=t.findIndex((r)=>/^ {4}assets:\s*$/.test(r));if(n>=0&&!/^ {6}\S/.test(t[n+1]??""))return null;return t.join(`
829
- `)}async function yv(e,t,n){let r=await e.getRepo(n),i=await e.json("GET",`/users/${n.split("/")[0]}`);return LE(t,i.id,r.id)}var bv=(e,t)=>`- open this page and choose Install, unless the hub's App already reaches ${e}; the project is preselected (keep "Only select repositories"):
829
+ `)}async function yv(e,t,n){let r=await e.getRepo(n),i=await e.json("GET",`/users/${n.split("/")[0]}`);return DE(t,i.id,r.id)}var bv=(e,t)=>`- open this page and choose Install, unless the hub's App already reaches ${e}; the project is preselected (keep "Only select repositories"):
830
830
  ${t}`;function UE(e){let t=yt(e),n=[];t.setIn(["release","draft"],!0),n.push("release.draft: true; the tapster hub publishes after signing"),t.setIn(["checksum","name_template"],"checksums.txt"),n.push("checksum.name_template: checksums.txt; the hub reads this name");for(let r of["notarize","homebrew_casks","brews","scoops"])if(t.has(r))t.delete(r),n.push(`removed ${r}; the hub does this now`);return{text:xr(e,t.toString(kr)),notes:n}}var Kc=(e)=>e.value,Av="Ring the tapster hub",ZE=/git\/refs\/heads\/|git push\b[^\n]*refs\/heads\//;function GE(e){let t=[];for(let n of e.items){let r=Kc(n).get("steps");if(!vt(r))continue;for(let i of r.items){let s=Ae(i)?String(i.get("run")??""):"";if(ZE.test(s))t.push(String(i.get("name")??s.trim().split(`
831
831
  `)[0]))}}return t.map((n)=>`the step "${n}" moves a branch, which the branch rules now refuse to the workflow's token; see "A branch that follows releases" in the GoReleaser guide`)}function qE(e,t,n){let r=yt(e),i=[],s=r.get("jobs");if(!Ae(s))throw new v("the release workflow has no jobs","Add the GoReleaser job first.");i.push(...GE(s));for(let o of s.items){let a=o.value.get("steps");if(!vt(a))continue;let c=a.items.findIndex((g)=>Ae(g)&&String(g.get("uses")??"").startsWith("goreleaser/goreleaser-action"));if(c===-1)continue;let u=a.items[c].get("env");if(Ae(u))for(let g of[...u.items]){let w=String(g.key.value??g.key);if(/^(MACOS_|HOMEBREW_TAP_)/.test(w))u.delete(w),i.push(`removed ${w} from the GoReleaser step`)}let p=a.items.some((g)=>Ae(g)&&String(g.get("uses")??"").startsWith("actions/attest-build-provenance@")),d=Kc(o),h=d.get("permissions"),f=r.get("permissions"),m=h??f;if(m!=="write-all"){let g=Ae(m)?m.toJSON():{};d.set("permissions",r.createNode({...g,contents:"write","id-token":"write",attestations:"write"}))}if(p)i.push("the attestation step is already there; permissions checked");else{let g=r.createNode({name:"Attest the archives for tapster",uses:`actions/attest-build-provenance@${t}`,if:"${{ !github.event.repository.private }}",with:{"subject-checksums":"dist/checksums.txt"}});g.get("uses",!0).comment=` ${n}`,a.items.splice(c+1,0,g),i.push(`added the attestation step (actions/attest-build-provenance ${n}) and its permissions`)}if(!a.items.some((g)=>Ae(g)&&g.get("name")===Av))a.items.push(r.createNode(ne(_r(0))[0])),i.push("added the step that rings the hub's doorbell after the draft is open");return{text:xr(e,r.toString(kr)),notes:i}}throw new v("no GoReleaser step found in the release workflow","tapster add edits the job that runs goreleaser/goreleaser-action.")}function BE(e){let t;try{t=yt(e)}catch{return null}let n=t.get("jobs");if(!Ae(n))return null;for(let r of n.items){let i=Kc(r).get("steps");if(!vt(i))continue;if(!i.items.some((o)=>Ae(o)&&/gh release create[^\n]*--draft/.test(String(o.get("run")??""))))continue;if(i.items.some((o)=>Ae(o)&&o.get("name")===Av))return e;return i.items.push(t.createNode(ne(_r(0))[0])),xr(e,t.toString(kr))}return null}function HE(e,t){let n=Ar(t,".app");for(let r of Wc(e))try{let i=fs(r),s=i?Cc(i):{},o=qt(s.CFBundleIdentifier);if((s.CFBundleExecutable===n||s.CFBundleName===n)&&o&&pn.test(o))return o}catch{continue}return null}function FE(e,t,n,r=!0){return(r?qc:qc.replaceAll("darwin-arm64 darwin-x64 ","")).replaceAll("__CHECKOUT_SHA__",n["actions/checkout"].sha).replaceAll("__CHECKOUT_TAG__",n["actions/checkout"].tag).replaceAll("__SETUP_BUN_SHA__",n["oven-sh/setup-bun"].sha).replaceAll("__SETUP_BUN_TAG__",n["oven-sh/setup-bun"].tag).replaceAll("__UPLOAD_SHA__",n["actions/upload-artifact"].sha).replaceAll("__UPLOAD_TAG__",n["actions/upload-artifact"].tag).replaceAll("__DOWNLOAD_SHA__",n["actions/download-artifact"].sha).replaceAll("__DOWNLOAD_TAG__",n["actions/download-artifact"].tag).replaceAll("__ATTEST_SHA__",n["actions/attest-build-provenance"].sha).replaceAll("__ATTEST_TAG__",n["actions/attest-build-provenance"].tag).replaceAll("__NAME__",e).replaceAll("__ENTRY__",t).replace(`__RING__
832
832
  `,`${_r(6)}
@@ -835,7 +835,7 @@ ${e.slice(a)}`}let c=yt(t).contents;if(!vt(c)||c.items.length!==1)throw new v("t
835
835
  `,n.map((r)=>`${r}
836
836
  `).join("")).replace(`__RING__
837
837
  `,`${_r(6)}
838
- `)}async function JE(e,t,n=!1,r=!1){let i=(await e.getRepo(t)).default_branch,s=await Dg(e,t,i,n,r),o=[s.deployKeys&&!n?"--auto-tag":"",s.dependabot&&!r?"--allow-dependabot":""].filter(Boolean),a=o.length?` It keeps what an earlier ${o.join(" and ")} opened.`:"";if(s.status==="exists")return`- ${t} is already protected: only an admin can create, move or delete its branches and tags.${a}`;if(s.status==="created")return`- protected ${t}: only you can create, move or delete branches and tags; workflows and Apps, the hub's included, cannot. Push release tags yourself; GitHub then notes "Bypassed rule violations", which is your admin right at work.${s.dependabot?" Branches named dependabot/... stay open, so Dependabot can open pull requests; the hub accepts that only with protection: dependabot in its entry.":""}${a}`;return`- GitHub does not enforce rulesets on ${t} (private repositories need a paid plan for them). A stolen App key could tag code the hub would sign. Make it public or use a paid plan. To accept the risk, set protection: off for this package in the hub's tapster.yml; until then the hub refuses it.`}function Yc(e){let t={hub:null,force:!1,workflow:"release.yml",autoTag:!1,dependabot:!1};for(let n=0;n<e.length;n++){let r=e[n];if(r==="--force")t.force=!0;else if(r==="--auto-tag")t.autoTag=!0;else if(r==="--allow-dependabot")t.dependabot=!0;else if(r==="--hub"&&e[n+1])t.hub=ys(e[++n]);else if(r==="--workflow"&&e[n+1]&&/^[A-Za-z0-9._-]+\.ya?ml$/.test(e[n+1]))t.workflow=e[++n];else throw new v(`unknown option ${r}`,"Run tapster add --help for the options.")}return t}async function kv(e,t,n,r){let i=te(e,".github/workflows",t);if(Pt(i)&&!r){let s=BE(vr(i,`.github/workflows/${t}`));if(s===null)throw new v(`.github/workflows/${t} already exists`,"Move it aside and run tapster add again. To replace it, run tapster add --force.");return await yr(e,`.github/workflows/${t}`,s),`- kept .github/workflows/${t}; it rings the hub after opening the draft`}return await yr(e,`.github/workflows/${t}`,n),`- wrote .github/workflows/${t} (build, attest, draft, ring the hub)`}async function QE(e,t,n,r,i=!0){let s=Vc(e);if(s&&!i)throw new v("the hub has no Apple credentials, which a Mac app needs","Run tapster init --rotate certificate and tapster init --rotate notary in the hub clone, then tapster add again.");if(s){let a=s.build??'echo "Set the build command in .github/workflows/release.yml" && exit 1',c=s.appPath??`build/${s.name}.app`,l=[await kv(e,"release.yml",YE({build:a,appPath:c,runner:"macos-15",carry:[]},We),r.force)];if(!s.build||!s.appPath)l.push("- set the build command and the app path in that file; the build must sign the app ad hoc");return l.push("- the app must set SURequireSignedFeed and SUVerifyUpdateBeforeExtraction to true and stamp both version keys with the tag"),l.push(`- store the Sparkle key in the hub with tapster init --sparkle ${n.replace(/[^a-z0-9]/g,"")} (add --new to create one)`),{kind:"app",entry:VE(n,t,s),reason:null,notes:l,goreleaser:null,files:[".github/workflows/release.yml"]}}let o=[".goreleaser.yaml",".goreleaser.yml"].find((a)=>Pt(te(e,a)));if(o&&Pt(te(e,"go.mod"))){let a=vr(te(e,o),o),c=UE(a);await yr(e,o,c.text);let l=te(e,".github/workflows",r.workflow);if(!Pt(l))throw new v(`no .github/workflows/${r.workflow} found`,"Name the workflow that runs GoReleaser with --workflow.");let u=qE(vr(l,`.github/workflows/${r.workflow}`),We["actions/attest-build-provenance"].sha,We["actions/attest-build-provenance"].tag);return await yr(e,`.github/workflows/${r.workflow}`,u.text),{kind:"go",entry:null,reason:null,notes:[...c.notes,...u.notes].map((p)=>`- ${p}`),goreleaser:c.text,original:a,files:[o,`.github/workflows/${r.workflow}`]}}if(Pt(te(e,"package.json"))&&(Pt(te(e,"bun.lock"))||Pt(te(e,"bun.lockb")))){let a;try{a=JSON.parse(vr(te(e,"package.json"),"package.json"))}catch(p){if(p instanceof v)throw p;throw new v("package.json is not valid JSON","Fix package.json, then try again.")}let c=bs(a,n);if(!c)throw new v("package.json has no bin entry","Add the CLI entry file to bin in package.json.");let l=await kv(e,"release.yml",FE(c.bin,c.entry,We,i),r.force),u=l.startsWith("- kept");return{kind:"bun",entry:u?null:uv(n,t,c.bin),reason:null,notes:[l],goreleaser:null,bin:u?c.bin:null,files:[".github/workflows/release.yml"]}}throw new v("this project is not a GoReleaser-based Go CLI, a Bun CLI or an app with a Sparkle feed","tapster add supports those three.")}async function XE(e,t){let n=(await Pe("git",["-C",e,"config","--get","tapster.hub"],{allowFail:!0})).stdout.trim(),r=t??(n?ys(n):ys(await me("Which hub publishes this project (owner/repo)? ")));return{hub:r,remember:async()=>void(r!==n&&await Pe("git",["-C",e,"config","tapster.hub",r]))}}async function eO(e,t,n){let r=await e.json("GET",`/repos/${t}/keys`);if(r.some((a)=>a.title==="tapster tags"))return'- the tag key already exists; to replace it, delete the deploy key "tapster tags" and run this again';try{await e.json("PUT",`/repos/${t}/environments/release`,{deployment_branch_policy:{protected_branches:!1,custom_branch_policies:!0}})}catch(a){if(a instanceof R&&[403,404,422].includes(a.status))throw new v(`GitHub refused environments on ${t}`,"Automatic tags keep their key in an environment, which private repositories get with GitHub Pro. Make the project public or upgrade.");throw a}if(!(await e.json("GET",`/repos/${t}/environments/release/deployment-branch-policies`)).branch_policies.some((a)=>a.name===n))await e.json("POST",`/repos/${t}/environments/release/deployment-branch-policies`,{name:n,type:"branch"});let s=$t("tapster-tag-");try{await L("/usr/bin/ssh-keygen","ssh-keygen",["-q","-t","ed25519","-N","","-C",`tapster tags for ${t}`,"-f",te(s,"key")]),await ee(t,"TAPSTER_TAG_KEY",wv(te(s,"key"),"utf8"),"release"),await e.json("POST",`/repos/${t}/keys`,{title:"tapster tags",key:wv(te(s,"key.pub"),"utf8").trim(),read_only:!1})}finally{Fe(s)}let o=r.filter((a)=>!a.read_only).map((a)=>a.title);return[`- automatic tags: a deploy key for ${t} lives in its "release" environment, which only ${n} may use. The rulesets let deploy keys tag.`,...o.length?[` Every deploy key with write access can now tag too: ${o.join(", ")}. Remove the ones you do not need in the repository settings.`]:[]," Push tags from your release workflow like this:",mv(We["actions/checkout"])].join(`
838
+ `)}async function JE(e,t,n=!1,r=!1){let i=(await e.getRepo(t)).default_branch,s=await jg(e,t,i,n,r),o=[s.deployKeys&&!n?"--auto-tag":"",s.dependabot&&!r?"--allow-dependabot":""].filter(Boolean),a=o.length?` It keeps what an earlier ${o.join(" and ")} opened.`:"";if(s.status==="exists")return`- ${t} is already protected: only an admin can create, move or delete its branches and tags.${a}`;if(s.status==="created")return`- protected ${t}: only you can create, move or delete branches and tags; workflows and Apps, the hub's included, cannot. Push release tags yourself; GitHub then notes "Bypassed rule violations", which is your admin right at work.${s.dependabot?" Branches named dependabot/... stay open, so Dependabot can open pull requests; the hub accepts that only with protection: dependabot in its entry.":""}${a}`;return`- GitHub does not enforce rulesets on ${t} (private repositories need a paid plan for them). A stolen App key could tag code the hub would sign. Make it public or use a paid plan. To accept the risk, set protection: off for this package in the hub's tapster.yml; until then the hub refuses it.`}function Yc(e){let t={hub:null,force:!1,workflow:"release.yml",autoTag:!1,dependabot:!1};for(let n=0;n<e.length;n++){let r=e[n];if(r==="--force")t.force=!0;else if(r==="--auto-tag")t.autoTag=!0;else if(r==="--allow-dependabot")t.dependabot=!0;else if(r==="--hub"&&e[n+1])t.hub=ys(e[++n]);else if(r==="--workflow"&&e[n+1]&&/^[A-Za-z0-9._-]+\.ya?ml$/.test(e[n+1]))t.workflow=e[++n];else throw new v(`unknown option ${r}`,"Run tapster add --help for the options.")}return t}async function kv(e,t,n,r){let i=te(e,".github/workflows",t);if(Pt(i)&&!r){let s=BE(vr(i,`.github/workflows/${t}`));if(s===null)throw new v(`.github/workflows/${t} already exists`,"Move it aside and run tapster add again. To replace it, run tapster add --force.");return await yr(e,`.github/workflows/${t}`,s),`- kept .github/workflows/${t}; it rings the hub after opening the draft`}return await yr(e,`.github/workflows/${t}`,n),`- wrote .github/workflows/${t} (build, attest, draft, ring the hub)`}async function QE(e,t,n,r,i=!0){let s=Vc(e);if(s&&!i)throw new v("the hub has no Apple credentials, which a Mac app needs","Run tapster init --rotate certificate and tapster init --rotate notary in the hub clone, then tapster add again.");if(s){let a=s.build??'echo "Set the build command in .github/workflows/release.yml" && exit 1',c=s.appPath??`build/${s.name}.app`,l=[await kv(e,"release.yml",YE({build:a,appPath:c,runner:"macos-15",carry:[]},We),r.force)];if(!s.build||!s.appPath)l.push("- set the build command and the app path in that file; the build must sign the app ad hoc");return l.push("- the app must set SURequireSignedFeed and SUVerifyUpdateBeforeExtraction to true and stamp both version keys with the tag"),l.push(`- store the Sparkle key in the hub with tapster init --sparkle ${n.replace(/[^a-z0-9]/g,"")} (add --new to create one)`),{kind:"app",entry:VE(n,t,s),reason:null,notes:l,goreleaser:null,files:[".github/workflows/release.yml"]}}let o=[".goreleaser.yaml",".goreleaser.yml"].find((a)=>Pt(te(e,a)));if(o&&Pt(te(e,"go.mod"))){let a=vr(te(e,o),o),c=UE(a);await yr(e,o,c.text);let l=te(e,".github/workflows",r.workflow);if(!Pt(l))throw new v(`no .github/workflows/${r.workflow} found`,"Name the workflow that runs GoReleaser with --workflow.");let u=qE(vr(l,`.github/workflows/${r.workflow}`),We["actions/attest-build-provenance"].sha,We["actions/attest-build-provenance"].tag);return await yr(e,`.github/workflows/${r.workflow}`,u.text),{kind:"go",entry:null,reason:null,notes:[...c.notes,...u.notes].map((p)=>`- ${p}`),goreleaser:c.text,original:a,files:[o,`.github/workflows/${r.workflow}`]}}if(Pt(te(e,"package.json"))&&(Pt(te(e,"bun.lock"))||Pt(te(e,"bun.lockb")))){let a;try{a=JSON.parse(vr(te(e,"package.json"),"package.json"))}catch(p){if(p instanceof v)throw p;throw new v("package.json is not valid JSON","Fix package.json, then try again.")}let c=bs(a,n);if(!c)throw new v("package.json has no bin entry","Add the CLI entry file to bin in package.json.");let l=await kv(e,"release.yml",FE(c.bin,c.entry,We,i),r.force),u=l.startsWith("- kept");return{kind:"bun",entry:u?null:uv(n,t,c.bin),reason:null,notes:[l],goreleaser:null,bin:u?c.bin:null,files:[".github/workflows/release.yml"]}}throw new v("this project is not a GoReleaser-based Go CLI, a Bun CLI or an app with a Sparkle feed","tapster add supports those three.")}async function XE(e,t){let n=(await Pe("git",["-C",e,"config","--get","tapster.hub"],{allowFail:!0})).stdout.trim(),r=t??(n?ys(n):ys(await me("Which hub publishes this project (owner/repo)? ")));return{hub:r,remember:async()=>void(r!==n&&await Pe("git",["-C",e,"config","tapster.hub",r]))}}async function eO(e,t,n){let r=await e.json("GET",`/repos/${t}/keys`);if(r.some((a)=>a.title==="tapster tags"))return'- the tag key already exists; to replace it, delete the deploy key "tapster tags" and run this again';try{await e.json("PUT",`/repos/${t}/environments/release`,{deployment_branch_policy:{protected_branches:!1,custom_branch_policies:!0}})}catch(a){if(a instanceof R&&[403,404,422].includes(a.status))throw new v(`GitHub refused environments on ${t}`,"Automatic tags keep their key in an environment, which private repositories get with GitHub Pro. Make the project public or upgrade.");throw a}if(!(await e.json("GET",`/repos/${t}/environments/release/deployment-branch-policies`)).branch_policies.some((a)=>a.name===n))await e.json("POST",`/repos/${t}/environments/release/deployment-branch-policies`,{name:n,type:"branch"});let s=$t("tapster-tag-");try{await D("/usr/bin/ssh-keygen","ssh-keygen",["-q","-t","ed25519","-N","","-C",`tapster tags for ${t}`,"-f",te(s,"key")]),await ee(t,"TAPSTER_TAG_KEY",wv(te(s,"key"),"utf8"),"release"),await e.json("POST",`/repos/${t}/keys`,{title:"tapster tags",key:wv(te(s,"key.pub"),"utf8").trim(),read_only:!1})}finally{Fe(s)}let o=r.filter((a)=>!a.read_only).map((a)=>a.title);return[`- automatic tags: a deploy key for ${t} lives in its "release" environment, which only ${n} may use. The rulesets let deploy keys tag.`,...o.length?[` Every deploy key with write access can now tag too: ${o.join(", ")}. Remove the ones you do not need in the repository settings.`]:[]," Push tags from your release workflow like this:",mv(We["actions/checkout"])].join(`
839
839
  `)}async function tO(e,t){try{return(await e.json("GET",`/repos/${t}/environments/tapster/variables/TAPSTER_DOORBELL`)).value}catch(n){if(n instanceof R&&n.status===404)return null;throw n}}async function xv(e,t){let r=(await e.listReleases(t)).filter((i)=>/^v\d/.test(i.tag_name)).sort((i,s)=>s.created_at.localeCompare(i.created_at))[0];return r?{assets:r.assets.map((i)=>i.name),version:r.tag_name.slice(1)}:null}async function Jc(e,t,n,r,i,s,o){let a=_s(n),{slug:c,apple:l}=i,u=await QE(t,n,a,s,l);for(let k of u.notes)o(k);let p=await e.getRepo(n);if(o(await JE(e,n,s.autoTag,s.dependabot)),!s.dependabot&&[".github/dependabot.yml",".github/dependabot.yaml"].some((k)=>Pt(te(t,k))))o("- Dependabot cannot open pull requests here now: GitHub does not let personal repositories exempt it from the rules."),o(" To keep it, run tapster add --allow-dependabot. Branches named dependabot/... then stay open to anything with write access, the hub's App included, so a stolen App key could run your workflows on its own code there.");if(s.autoTag)o(await eO(e,n,p.default_branch));let{entry:d,reason:h}=u;if(u.kind==="go")({entry:d,reason:h}=pv(a,n,u.goreleaser,await xv(e,n)));if(u.kind==="bun"&&u.bin)({entry:d,reason:h}=Fc(a,n,"bun",[u.bin],await xv(e,n)));if(d&&!l){if(d=vv(d),d)o("- the hub has no Apple credentials, so the entry leaves out the macOS builds");else h="the hub has no Apple credentials and the project builds only for macOS; run tapster init --rotate certificate and tapster init --rotate notary in the hub, then tapster add again";if(u.kind==="go"||u.bin)o(` Remove the macOS builds from ${u.kind==="go"?"the GoReleaser builds (goos: darwin)":".github/workflows/release.yml"} too: the hub refuses macOS code it cannot sign.`)}let f=null;if(d){d=hv(d,{kind:u.kind,workflow:s.workflow,dependabot:s.dependabot});let k=dv(u.original??null,{mac:l,bundleId:(y)=>HE(t,y)});if(k.lines.length)d=`${d}
840
840
  ${k.lines.join(`
841
841
  `)}`;let _=k.description&&xt(k.description,a).length===0?k.description:null;if(_)d=`${d}
@@ -843,7 +843,7 @@ ${k.lines.join(`
843
843
  ${y.add}`}if(k.carried.length)o(`- carried the ${k.carried.join(", ")} of GoReleaser's Homebrew section into the hub entry`);for(let y of k.notes)o(`- ${y}`);try{f=await gv(e,r,a,n,d),o(`- proposed the hub entry in ${f}; merge it to start publishing`)}catch(y){if(!(y instanceof v))throw y;if(o(`- the hub entry was not proposed: ${y.reason}. ${y.fix}
844
844
  The entry for ${r}'s tapster.yml:
845
845
  ${d}`),s.dependabot&&y.reason.includes("is already in"))o(" Its existing entry needs protection: dependabot, or the hub refuses the project.")}}else o(`- no hub entry yet: ${h}`);let m=await tO(e,r);if(m)await hs(n,"TAPSTER_DOORBELL",m),o("- the release workflow rings the hub's doorbell, so the hub publishes right after the draft opens");let g=await e.json("GET",`/repos/${n}/actions/secrets?per_page=100`).then((k)=>ws(k.secrets.map((_)=>_.name)),()=>[]);if(g.length)o(`- ${n} still holds release secrets that the hub replaces: ${g.join(", ")}. Delete them once the hub has published a release: gh secret delete <name> --repo ${n}`);let w=await yv(e,c,n);return o(bv(n,w)),{pr:f,entry:d,installUrl:w,files:u.files,kind:u.kind}}var _s=(e)=>e.split("/")[1].toLowerCase().replace(/[^a-z0-9-]/g,"-");async function $v(e){let t=Yc(e),n=process.cwd(),r=await He(n),i=await At(),{hub:s,remember:o}=await XE(n,t.hub),a=await Sr(i,s);await o(),await Jc(i,n,r,s,a,t,(c)=>console.log(c)),console.log(`
846
- Review the changes with git diff, commit and push them, then push a tag to release.`)}async function de(e,t,n,r){try{let i=await e.json("GET",`/repos/${t}/contents/${n}?ref=${r}`);return Buffer.from(i.content,"base64").toString("utf8")}catch(i){if(i instanceof R&&i.status===404)return null;throw i}}async function Qc(e,t,n,r){for(let i=0;i<5;i++){let o=(await e.json("GET",`/repos/${t}/git/ref/heads/main`)).object.sha,a=await e.json("GET",`/repos/${t}/git/commits/${o}`),c=await r((p)=>de(e,t,p,o));if(c.length===0)return"unchanged";let l=await e.json("POST",`/repos/${t}/git/trees`,{base_tree:a.tree.sha,tree:c.map((p)=>({path:p.path,mode:"100644",type:"blob",...p.content===null?{sha:null}:{content:p.content}}))}),u=await e.json("POST",`/repos/${t}/git/commits`,{message:n,tree:l.sha,parents:[o]});try{return await e.json("PATCH",`/repos/${t}/git/refs/heads/main`,{sha:u.sha,force:!1}),"committed"}catch(p){if(p instanceof R&&p.status===422)continue;throw p}}throw new v("the hub's main branch kept moving","The next run retries.")}var ae={version:"1.2.0",sha:"ac0b4890723e1cac109eaef9d83d22310fead51b"};var ks=`name: tapster
846
+ Review the changes with git diff, commit and push them, then push a tag to release.`)}async function de(e,t,n,r){try{let i=await e.json("GET",`/repos/${t}/contents/${n}?ref=${r}`);return Buffer.from(i.content,"base64").toString("utf8")}catch(i){if(i instanceof R&&i.status===404)return null;throw i}}async function Qc(e,t,n,r){for(let i=0;i<5;i++){let o=(await e.json("GET",`/repos/${t}/git/ref/heads/main`)).object.sha,a=await e.json("GET",`/repos/${t}/git/commits/${o}`),c=await r((p)=>de(e,t,p,o));if(c.length===0)return"unchanged";let l=await e.json("POST",`/repos/${t}/git/trees`,{base_tree:a.tree.sha,tree:c.map((p)=>({path:p.path,mode:"100644",type:"blob",...p.content===null?{sha:null}:{content:p.content}}))}),u=await e.json("POST",`/repos/${t}/git/commits`,{message:n,tree:l.sha,parents:[o]});try{return await e.json("PATCH",`/repos/${t}/git/refs/heads/main`,{sha:u.sha,force:!1}),"committed"}catch(p){if(p instanceof R&&p.status===422)continue;throw p}}throw new v("the hub's main branch kept moving","The next run retries.")}var ae={version:"1.2.1",sha:"cb14a7816934bf7ae108a9a404c01f9e56d94769"};var ks=`name: tapster
847
847
  on:
848
848
  schedule:
849
849
  - cron: "__CRON__"
@@ -1076,10 +1076,10 @@ Releases are signed and published by the \`tapster\` workflow; change the projec
1076
1076
  tap: ${r}
1077
1077
  packages: []
1078
1078
  `,before:null},{path:".tapster/state.json",content:`${JSON.stringify({version:1,packages:{}},null,2)}
1079
- `,before:null},{path:"README.md",content:Pv.replaceAll("__TAP__",r).replaceAll("__OWNER__",t).replaceAll("__HUB__",e),before:null}]}async function As(e,t,n,r,i){let s=[],o=[];for(let u of Ss(t))if(await n(u.path)===null)s.push(u);else o.push(u.path);let a=await n("tapster.yml"),c=a===null?[]:Ee(ie(a,t.split("/")[0]).config),l=await tl(e,await n(J),c,r,i);return s.push(l.file),{files:s,kept:o,change:l.change,notes:l.notes}}var F=(e,t)=>({name:e,ok:!0,fix:"",...t?{note:t}:{}}),M=(e,t)=>({name:e,ok:!1,fix:t});function aO(e){let n=ne(e)?.on,r=n&&typeof n==="object"&&!Array.isArray(n)?Object.keys(n):[];return r.length>0&&r.every((i)=>i==="schedule"||i==="workflow_dispatch")?F("the hub workflow runs only on schedule and manual dispatch"):M("the hub workflow runs only on schedule and manual dispatch","Other triggers (pull_request_target, issue_comment, workflow_run) would reach the credentials. Restore .github/workflows/tapster.yml with tapster init.")}function cO(e){let n=(i)=>{let s;try{s=ne(i)}catch{return!0}let o=s?.jobs;if(!o||typeof o!=="object")return!1;return Object.values(o).some((a)=>{let c=a?.environment,l=typeof c==="object"&&c!==null?c.name:c;return typeof l==="string"&&(l.trim().toLowerCase()==="tapster"||l.includes("${{"))})},r=Object.entries(e).filter(([,i])=>n(i)).map(([i])=>i);return r.length===0?F("no other workflow uses the tapster environment"):M("no other workflow uses the tapster environment",`Remove the tapster environment from ${r.join(", ")}.`)}function lO(e,t,n){let i=Ee(e),s=i.filter((a)=>!t.includes(`SPARKLE_KEY_${a.toUpperCase()}`));if(s.length)return M("every Sparkle key is stored and passed to the sparkle step",s.map((a)=>`Run tapster init --sparkle ${a}.`).join(" "));let o=i.filter((a)=>!n.includes(`SPARKLE_KEY_${a.toUpperCase()}: "\${{ secrets.SPARKLE_KEY_${a.toUpperCase()} }}"`));if(o.length)return M("every Sparkle key is stored and passed to the sparkle step",`The workflow does not pass ${o.map((a)=>`SPARKLE_KEY_${a.toUpperCase()}`).join(", ")}. Run tapster init --workflow.`);return F("every Sparkle key is stored and passed to the sparkle step")}function uO(e,t){let r=Object.entries(t).filter(([,i])=>i!==e).map(([i])=>i);return r.length?M("every project rings the hub's doorbell",r.map((i)=>`gh variable set TAPSTER_DOORBELL --repo ${i} --body ${e}`).join("; ")):F("every project rings the hub's doorbell")}function pO(e,t,n,r){if(!n.includes("TAPSTER_LINUX_KEY"))return M("the Linux repositories can be signed and deployed","Run tapster init --linux to make and store the signing key.");if(!r)return M("the Linux repositories can be signed and deployed","Turn on GitHub Pages for the hub; tapster init --linux does it.");if(r.build_type!=="workflow")return M("the Linux repositories can be signed and deployed","Set the hub's Pages source to GitHub Actions; tapster init --linux does it.");let s=r.html_url.replace(/\/$/,"");if(s!==gg(e,t))return M("the Linux repositories can be signed and deployed",`Pages serves ${s}; set linux.url in tapster.yml to it.`);return F("the Linux repositories can be signed and deployed")}var Ev=["MACOS_SIGN_P12","MACOS_SIGN_PASSWORD","MACOS_NOTARY_KEY","MACOS_NOTARY_KEY_ID","MACOS_NOTARY_ISSUER_ID"],dO=[...Ev,"TAPSTER_APP_PRIVATE_KEY"];function hO(e,t,n){let i=e?.packages.some(is)??!1,s=[...["TAPSTER_APP_PRIVATE_KEY",...i?Ev:[]].filter((a)=>!t.includes(a)),...["TAPSTER_APP_ID","TAPSTER_APP_SLUG",...i?["TAPSTER_TEAM_ID"]:[]].filter((a)=>!n.includes(a))];if(s.length===0)return F("the credentials this hub needs are stored");let o=[...s.some((a)=>a.startsWith("TAPSTER_APP"))?["tapster init"]:[],...s.some((a)=>a.startsWith("MACOS_SIGN")||a==="TAPSTER_TEAM_ID")?["tapster init --rotate certificate"]:[],...s.some((a)=>a.startsWith("MACOS_NOTARY"))?["tapster init --rotate notary"]:[]];return M("the credentials this hub needs are stored",`Missing: ${s.join(", ")}. Run ${o.join(" and ")}.`)}function fO(e,t){let r=Bt.exec(e);if(!r)return M("the hub workflow is tapster's template","The workflow does not pin tapster. Run tapster init --workflow.");if(r[1]!==t.sha)return F("the hub workflow is tapster's template",`the hub runs tapster ${r[2]} (${r[1].slice(0,7)}) and this is tapster ${t.version}; tapster init --workflow moves the hub to this one. The tapster that wrote the workflow checks it byte for byte`);let i=[...e.matchAll(/SPARKLE_KEY_([A-Z0-9]+): "/g)].map((o)=>o[1].toLowerCase());return Xc(ks,We,{sha:r[1],tag:r[2]},i,rt(e)??10)===e?F("the hub workflow is tapster's template"):M("the hub workflow is tapster's template","The workflow differs from the template; hand edits can reach the credentials. Run tapster init --workflow and review the diff.")}function nl(e){return e.some((r)=>r.enforcement==="active"&&r.target==="branch"&&(r.conditions?.ref_name?.include??[]).some((i)=>i==="~DEFAULT_BRANCH"||i==="~ALL"||i==="refs/heads/main")&&(r.conditions?.ref_name?.exclude??[]).length===0&&["deletion","non_fast_forward"].every((i)=>(r.rules??[]).some((s)=>s.type===i))&&(r.bypass_actors??[]).every((i)=>i.actor_type==="RepositoryRole"&&i.actor_id===5))?F("main cannot be deleted or force-pushed, by anyone"):M("main cannot be deleted or force-pushed, by anyone",'Run tapster init to restore the ruleset "tapster main" (active, deletion and force pushes blocked, no one else may bypass).')}function rl(e,t){return e.allowed_actions==="selected"&&e.sha_pinning_required===!0&&t?.verified_allowed===!1&&(t.patterns_allowed??[]).every((i)=>i==="doguyilmaz/tapster@*")?F("the hub runs only GitHub's and tapster's actions, pinned by commit"):M("the hub runs only GitHub's and tapster's actions, pinned by commit","Run tapster init to restore the hub's Actions policy.")}function mO(e,t,n){let i=e.map((a)=>a.login).filter((a)=>a.toLowerCase()!==n.toLowerCase()),s=t.filter((a)=>!a.read_only).map((a)=>a.title);if(i.length===0&&s.length===0)return F("only you can change the hub");let o=[...i.length?[`collaborators ${i.join(", ")} can push to main and change what the hub signs`]:[],...s.length?[`deploy keys ${s.join(", ")} can push too`]:[]];return M("only you can change the hub",`${o.join("; ")}. Remove them in the hub's settings unless you trust them with your signing keys.`)}function gO(e,t){if(e===String(t))return F("the doorbell keeps the workflow's schedule");return M("the doorbell keeps the workflow's schedule",`The doorbell starts the hub every ${e??"10"} minutes and the workflow every ${t}. Run tapster init --rotate doorbell to move the doorbell to the workflow's schedule.`)}function vO(e,t,n){if(e.some((s)=>(s.event==="schedule"||s.event==="workflow_dispatch")&&t-Date.parse(s.created_at)<86400000))return F("the hub ran in the last day");return M("the hub ran in the last day",n?"Neither GitHub's schedule nor the doorbell started a run. Check the doorbell's logs with wrangler tail and the workflow in the Actions tab.":"GitHub's schedule did not start a run; it is best effort. tapster init --doorbell adds a second clock that starts the hub on time.")}async function it(e,t,n){try{let r=await e.json("GET",t);return(n?r[n]:r)??[]}catch(r){if(r instanceof R&&r.status===404)return[];throw r}}async function yO(e,t,n,r,i){let s=[],o=await e.json("GET",`/repos/${t}/environments/tapster`).catch(()=>null);if(!o)return[M("the tapster environment exists","Run tapster init.")];let a=await e.json("GET",`/repos/${t}/environments/tapster/deployment-branch-policies`);s.push(o.deployment_branch_policy?.custom_branch_policies&&a.branch_policies.length===1&&a.branch_policies[0].name==="main"&&(a.branch_policies[0].type??"branch")==="branch"?F("only main may open the tapster environment"):M("only main may open the tapster environment","Run tapster init to restore the branch rule."));let c=(await it(e,`/repos/${t}/environments/tapster/secrets?per_page=100`,"secrets")).map((y)=>y.name),l=await it(e,`/repos/${t}/environments/tapster/variables?per_page=100`,"variables");s.push(hO(r,c,l.map((y)=>y.name)));let u=l.find((y)=>y.name==="TAPSTER_CERT_EXPIRES")?.value;if(u&&Date.parse(`${u}T00:00:00Z`)-Date.now()<2592000000)s.push(M("the Developer ID certificate is valid for 30 more days",`It expires on ${u}. Renew it at developer.apple.com, then run tapster init --rotate certificate.`));if(r&&Ee(r).length)s.push(lO(r,c,i));if(r?.packages.some((y)=>!Y(y)&&y.linux)){let y=await e.json("GET",`/repos/${t}/pages`).catch(()=>null);if(s.push(pO(r,t,c,y)),c.includes("TAPSTER_LINUX_KEY_PREVIOUS"))s.push(F("the Linux key rotation is running","the previous Linux key still signs; once apt and dnf users have the new key, run tapster init --rotate linux --finish"))}let p=await it(e,`/repos/${t}/actions/variables?per_page=100`,"variables"),d=[...l,...p].map((y)=>y.name).filter((y)=>dO.includes(y)||/^SPARKLE_KEY_/.test(y)||y.startsWith("TAPSTER_LINUX_KEY"));s.push(d.length?M("credentials are secrets, not variables",`Variables are readable by anyone with access; delete ${d.join(", ")} and store them with tapster init --rotate.`):F("credentials are secrets, not variables"));let h=l.find((y)=>y.name==="TAPSTER_DOORBELL")?.value;if(h&&r){let y={};for(let x of r.packages)y[x.repo]=await e.json("GET",`/repos/${x.repo}/actions/variables/TAPSTER_DOORBELL`).then((S)=>S.value).catch(()=>null);s.push(uO(h,y)),s.push(gO(l.find((x)=>x.name==="TAPSTER_DOORBELL_EVERY")?.value,rt(i)??10))}let f=await e.json("GET",`/repos/${t}/actions/permissions/workflow`);s.push(f.default_workflow_permissions==="read"?F("the default workflow token is read-only"):M("the default workflow token is read-only","Run tapster init."));let m=await Promise.all((await it(e,`/repos/${t}/rulesets`)).map((y)=>e.json("GET",`/repos/${t}/rulesets/${y.id}`)));s.push(nl(m));let g=await e.json("GET",`/repos/${t}/actions/permissions`),w=g.allowed_actions==="selected"?await e.json("GET",`/repos/${t}/actions/permissions/selected-actions`):null;s.push(rl(g,w)),s.push(mO(await it(e,`/repos/${t}/collaborators?affiliation=direct&per_page=100`),await it(e,`/repos/${t}/keys?per_page=100`),n));let k=await e.json("GET",`/repos/${t}/actions/workflows/tapster.yml`).catch(()=>null);s.push(k?.state==="active"?F("the hub workflow is enabled"):M("the hub workflow is enabled","Enable the tapster workflow in the hub's Actions tab (GitHub pauses it after 60 days without activity; the doorbell turns it back on)."));let _=await it(e,`/repos/${t}/actions/workflows/tapster.yml/runs?per_page=30`,"workflow_runs");s.push(vO(_,Date.now(),Boolean(h)));for(let y of r?.packages??[]){let x=await e.getRepo(y.repo).catch((A)=>A instanceof R?null:Promise.reject(A));if(!x){s.push(M(`${y.repo} exists`,"Fix the repo field in tapster.yml."));continue}if(x.private)s.push(F(`${y.repo} is published by the hub`,`${y.repo} is private: the hub publishes its releases, but Homebrew, Scoop, apt and dnf users can only install from public projects`));if(y.protection==="off")s.push(F(`${y.repo} is protected`,`protection is off for ${y.name}: a stolen App key could tag code there that the hub would sign`));else{let A=await gr(e,y.repo,x.default_branch,"admin",y.protection==="dependabot"),D=y.protection==="dependabot"?`branches named dependabot/... are open on ${y.repo}, so a stolen App key could run its workflows on code of its own there`:void 0;s.push(A.length?M(`${y.repo} is protected`,`${A.join("; ")}. Run tapster add in a clone of ${y.repo}.`):F(`${y.repo} is protected`,D))}let S=(await it(e,`/repos/${y.repo}/actions/secrets?per_page=100`,"secrets")).map((A)=>A.name),O=ws(S);s.push(O.length?M(`${y.repo} holds no release secrets`,`Delete ${O.join(", ")}: gh secret delete <name> --repo ${y.repo}`):F(`${y.repo} holds no release secrets`))}return s}async function bO(e,t,n){let i=(await e.json("GET",`/repos/${t}/environments/tapster/variables`).catch(()=>null))?.variables.find((s)=>s.name==="TAPSTER_APP_SLUG")?.value;if(!i||n.length===0)return null;return`note: the App must be installed on ${n.join(", ")} and not on ${t}; GitHub shows its repositories only to the App itself, so check them at https://github.com/apps/${i}/installations/new (the hub's check job also reports both)`}function wO(e,t){if(e===null)return{checks:[M("tapster.yml is valid","Run tapster init.")],config:null};try{let{config:n,invalid:r}=ie(e,t);if(r.length===0)return{checks:[F("tapster.yml is valid")],config:n};return{checks:r.map((i)=>M(`${i.name} in tapster.yml is valid`,`${i.reason}. ${i.fix}`)),config:n}}catch(n){return{checks:[M("tapster.yml is valid",n instanceof v?`${n.reason}. ${n.fix}`:"Run tapster init.")],config:null}}}async function _O(e,t){let n=(await it(e,`/repos/${t}/contents/.github/workflows?ref=main`)).filter((i)=>i.type==="file").map((i)=>i.name),r={};for(let i of n)r[i]=await de(e,t,`.github/workflows/${i}`,"main")??"";return{config:await de(e,t,"tapster.yml","main"),flows:r}}async function $r(e,t){let n=t.split("/")[0],r=await _O(e,t),i=[],s=wO(r.config,n),o=s.config;i.push(...s.checks);let a=r.flows["tapster.yml"];if(a)i.push(aO(a),fO(a,ae));else i.push(M("the hub workflow exists","Run tapster init, commit and push."));let{"tapster.yml":c,...l}=r.flows;return i.push(cO(l)),i.push(...await yO(e,t,n,o,a??"")),{checks:i,note:await bO(e,t,o?.packages.map((u)=>u.repo)??[])}}async function Ov(e){let t=await He(process.cwd()),n=await At();console.log(`Checking ${t} as it is on GitHub's main branch.`);let{checks:r,note:i}=await $r(n,t);for(let s of r)if(console.log(s.ok?`ok ${s.name}`:`fix ${s.name}
1080
- ${s.fix}`),s.note)console.log(` note: ${s.note}`);if(i)console.log(i);return r.every((s)=>s.ok)?0:1}import{createHash as HO,createPrivateKey as FO,createPublicKey as KO}from"crypto";import{existsSync as bn,readFileSync as Ir}from"fs";import{mkdir as Yv,writeFile as dl}from"fs/promises";import{join as Oe}from"path";import{createHash as kO,createPrivateKey as xO,createPublicKey as Cv,sign as SO,verify as AO}from"crypto";var Ht=2n**255n-19n,il=2n**252n+27742317777372353535851937790883648493n,K=(e,t=Ht)=>(e%t+t)%t,sl=(e,t)=>{let n=1n,r=K(e);for(let i=t;i>0n;i>>=1n){if(i&1n)n=n*r%Ht;r=r*r%Ht}return n},Ts=(e)=>sl(e,Ht-2n),Nv=K(-121665n*Ts(121666n));function Rv([e,t,n,r],[i,s,o,a]){let c=K((t-e)*(s-i)),l=K((t+e)*(s+i)),u=K(2n*r*a*Nv),p=K(2n*n*o),d=l-c,h=p-u,f=p+u,m=l+c;return[K(d*h),K(f*m),K(h*f),K(d*m)]}function zv(e,t){let n=[0n,1n,1n,0n],r=t;for(let i=e;i>0n;i>>=1n){if(i&1n)n=Rv(n,r);r=Rv(r,r)}return n}var jv=(()=>{let e=K(4n*Ts(5n)),t=K(e*e-1n),n=K(Nv*e*e+1n),r=sl(K(t*Ts(n)),(Ht+3n)/8n);if(K(r*r*n-t)!==0n)r=K(r*sl(2n,(Ht-1n)/4n));if(r&1n)r=Ht-r;return[r,e,1n,K(r*e)]})(),Ps=(e)=>e.reduceRight((t,n)=>t<<8n|BigInt(n),0n);function Dv(e){let t=Buffer.alloc(32),n=e;for(let r=0;r<32;r++)t[r]=Number(n&255n),n>>=8n;return t}function Lv([e,t,n]){let r=Ts(n),i=K(e*r),s=K(t*r);return Dv(s|(i&1n)<<255n)}var Iv=(...e)=>kO("sha512").update(Buffer.concat(e)).digest();function $O(e,t,n){let r=Ps(e.subarray(0,32)),i=K(Ps(Iv(e.subarray(32,64),n)),il),s=Lv(zv(i,jv)),o=K(Ps(Iv(s,t,n)),il);return Buffer.concat([s,Dv(K(i+o*r,il))])}var PO=Buffer.from("302e020100300506032b657004220420","hex"),TO=Buffer.from("302a300506032b6570032100","hex"),$s=(e)=>new v(`the Sparkle key ${e}`,"Store the app's Sparkle key again with tapster init --sparkle <label> --account <keychain account>.");function Es(e){let t=e.trim();if(!/^[A-Za-z0-9+/]+={0,2}$/.test(t))throw $s("is not base64");let n=Buffer.from(t,"base64");hn(n.toString("hex"));let r,i;if(n.length===32){let o=xO({key:Buffer.concat([PO,n]),format:"der",type:"pkcs8"}),a=Cv(o).export({format:"der",type:"spki"});r=a.subarray(a.length-32),i=(c)=>SO(null,c,o)}else if(n.length===96){let o=n.subarray(0,64);if(hn(o.toString("base64")),r=Buffer.from(n.subarray(64)),!Lv(zv(Ps(o.subarray(0,32)),jv)).equals(r))throw $s("is damaged: its two halves do not match");i=(a)=>$O(o,r,a)}else throw $s(`decodes to ${n.length} bytes, not 32 or 96`);let s=Cv({key:Buffer.concat([TO,r]),format:"der",type:"spki"});return{publicKey:r.toString("base64"),sign(o){let a=i(o);if(!AO(null,o,s,a))throw $s("produced a signature that does not verify");return a}}}function Os(e,t,n){return{name:`tapster-${e}-${t.split("/")[1].replace(/^homebrew-/,"")}`.toLowerCase().slice(0,34),url:`https://github.com/${t}`,redirect_url:n,public:!1,default_permissions:{contents:"write",attestations:"read",metadata:"read"},default_events:[],hook_attributes:{url:"https://example.com/tapster-has-no-webhook",active:!1}}}async function Pr(e,t){await ze(e,"TAPSTER_APP_ID",String(t.id)),await ze(e,"TAPSTER_APP_SLUG",t.slug),await ee(e,"TAPSTER_APP_PRIVATE_KEY",t.pem)}async function Cs(e,t,n,r,i=new pe(Be(e,t))){let s;try{s=(await i.json("GET",`/users/${n}/installation`)).id}catch(a){if(a instanceof R&&a.status===404)return{id:null,onHub:!1};throw a}let o=await i.json("GET",`/repos/${r}/installation`).then(()=>!0,(a)=>a instanceof R&&a.status===404?!1:Promise.reject(a));return{id:s,onHub:o}}import{existsSync as EO}from"fs";import{writeFile as OO}from"fs/promises";import{join as CO}from"path";var ol=65536,al=8192;function RO(e){return/(?:^|[,/]\s*)OU=([A-Z0-9]{10})(?:[,/]|$)/.exec(e)?.[1]??null}function IO(e,t,n=Date.now()){let r=/(?:^|,)CN=((?:[^,\\]|\\.)*)/.exec(e)?.[1]??"";if(!r.startsWith("Developer ID Application:"))throw new v(`the certificate is "${r||"unnamed"}", not a Developer ID Application certificate`,"Create a Developer ID Application certificate at developer.apple.com, export it with its key from Keychain Access as .p12, then run this again.");let i=RO(e);if(!i)throw new v("the certificate has no team ID","Export the Developer ID Application certificate from Keychain Access.");let s=Date.parse(t);if(Number.isNaN(s))throw new v("the certificate's expiry date cannot be read","Export the certificate again from Keychain Access.");let o=new Date(s).toISOString().slice(0,10);if(s<n)throw new v(`the certificate expired on ${o}`,"Create a new Developer ID Application certificate at developer.apple.com.");return{team:i,expires:o,name:r.replace(/\\(.)/g,"$1")}}function NO(e,t){if(/mac verify error|invalid password/i.test(e.stdout))throw new v("the .p12 could not be opened with that password","Check the password you set when exporting it or export it again.");if(/unsupported/i.test(e.stdout))throw new v("this system's openssl cannot read the .p12","Run this on macOS or export the certificate again from Keychain Access.");if(!/certificate bag/i.test(e.stdout))throw new v("the .p12 holds no certificate","Export the Developer ID Application certificate from My Certificates in Keychain Access.");if(!/key ?bag/i.test(e.stdout))throw new v("the .p12 holds the certificate but not its private key","Export it from My Certificates in Keychain Access on the Mac that holds the key.");if(t.code!==0||!t.stdout.includes("BEGIN CERTIFICATE"))throw new v("the .p12 could not be read","Export it again from My Certificates in Keychain Access.")}async function Rs(e,t,n=Date.now()){if(e.length===0||e.length>ol)throw new v("that file is not a .p12 certificate","Export the Developer ID Application certificate from Keychain Access as .p12.");let r=t===""?"pass:":"env:TAPSTER_P12",i=(p)=>Pe("openssl",["pkcs12",...p,"-passin",r],{env:{TAPSTER_P12:t},stdin:e,allowFail:!0}),s=[],o=await i(["-info","-noout"]);if(/unsupported/i.test(o.stderr))s=["-legacy"],o=await i([...s,"-info","-noout"]);let a=await i([...s,"-nokeys","-clcerts"]);NO({code:o.code,stdout:`${o.stdout}
1081
- ${o.stderr}`},a);let c=await Pe("openssl",["x509","-noout","-subject","-enddate","-nameopt","RFC2253"],{stdin:a.stdout}),l=/^subject=\s*(.*)$/m.exec(c.stdout)?.[1]?.trim()??"",u=/^notAfter=(.*)$/m.exec(c.stdout)?.[1]?.trim()??"";return IO(l,u,n)}async function Is(e,t,n,r){await ee(e,"MACOS_SIGN_P12",Buffer.from(t).toString("base64")),await ee(e,"MACOS_SIGN_PASSWORD",n),await ze(e,"TAPSTER_TEAM_ID",r.team),await ze(e,"TAPSTER_CERT_EXPIRES",r.expires)}var zO=(e,t,n)=>["notarytool","history","--key",e,"--key-id",t,"--issuer",n,"--output-format","json"];function jO(e){if(/HTTP status code: 401\b/.test(e))return new v("Apple rejected the notary key (HTTP 401)","Check the .p8 file, the Key ID and the Issuer ID in App Store Connect, then run this again.");if(/HTTP status code: 403\b/.test(e))return new v("Apple refused the notary key (HTTP 403)","Accept the latest agreements in App Store Connect and check that the key has Developer access, then run this again.");let t=e.split(`
1082
- `).find((r)=>r.trim()!=="")?.trim()??"no message",n=/unable to find utility|notarytool.*not found/i.test(e);return new v(`notarytool could not check the key: ${fn(t).slice(0,300)}`,n?"Install Xcode or its command line tools (xcode-select --install), then run this again.":"Check your connection and the key in App Store Connect, then run this again.")}function cl(e){if(e.length===0||e.length>al||!Buffer.from(e).toString("utf8").includes("BEGIN PRIVATE KEY"))throw new v("that file is not an App Store Connect key","Download the .p8 from App Store Connect, Users and Access, Integrations.")}function ll(e){let t=e.trim();if(!/^[A-Z0-9]{10}$/.test(t))throw new v(`${t||"an empty Key ID"} is not a Key ID`,"Copy the 10-character Key ID next to the key in App Store Connect.");return t}function Ns(e,t,n){cl(e);let r=ll(t),i=n.trim().toLowerCase();if(!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/.test(i))throw new v("that is not an Issuer ID","Copy the Issuer ID shown above the key list in App Store Connect.");return{p8:e,keyId:r,issuer:i}}async function zs(e){if(process.platform!=="darwin"||!EO(mn.xcrun))return!1;let t=$t("tapster-notary-");try{let n=CO(t,`AuthKey_${e.keyId}.p8`);await OO(n,e.p8,{mode:384});let r=await L(mn.xcrun,"xcrun",zO(n,e.keyId,e.issuer),{allowFail:!0});if(r.code!==0)throw jO(r.stderr);return!0}finally{Fe(t)}}async function js(e,t){await ee(e,"MACOS_NOTARY_KEY",Buffer.from(t.p8).toString("base64")),await ee(e,"MACOS_NOTARY_KEY_ID",t.keyId),await ee(e,"MACOS_NOTARY_ISSUER_ID",t.issuer)}import{generateKeyPairSync as DO}from"crypto";import{existsSync as LO}from"fs";function Mv(){let{privateKey:e,publicKey:t}=DO("ed25519"),n=e.export({format:"der",type:"pkcs8"}).subarray(-32),r=t.export({format:"der",type:"spki"}).subarray(-32);return{seed:n.toString("base64"),publicKey:r.toString("base64")}}var MO=/^[A-Za-z0-9 .:/@_+=()-]+$/;function Er(e){for(let t of[e.service,e.account,e.label,...e.comment===void 0?[]:[e.comment]])if(!MO.test(t))throw new v(`"${t}" cannot name a keychain item`,"Use letters, digits and simple punctuation.")}function UO(e,t){Er(e);let n=e.comment===void 0?"":` -j "${e.comment}"`,r=`add-generic-password -s "${e.service}" -a "${e.account}" -l "${e.label}" -D "private key"${n} -T "" -X ${Buffer.from(t).toString("hex")}
1079
+ `,before:null},{path:"README.md",content:Pv.replaceAll("__TAP__",r).replaceAll("__OWNER__",t).replaceAll("__HUB__",e),before:null}]}async function As(e,t,n,r,i){let s=[],o=[];for(let u of Ss(t))if(await n(u.path)===null)s.push(u);else o.push(u.path);let a=await n("tapster.yml"),c=a===null?[]:Ee(ie(a,t.split("/")[0]).config),l=await tl(e,await n(J),c,r,i);return s.push(l.file),{files:s,kept:o,change:l.change,notes:l.notes}}var F=(e,t)=>({name:e,ok:!0,fix:"",...t?{note:t}:{}}),M=(e,t)=>({name:e,ok:!1,fix:t});function aO(e){let n=ne(e)?.on,r=n&&typeof n==="object"&&!Array.isArray(n)?Object.keys(n):[];return r.length>0&&r.every((i)=>i==="schedule"||i==="workflow_dispatch")?F("the hub workflow runs only on schedule and manual dispatch"):M("the hub workflow runs only on schedule and manual dispatch","Other triggers (pull_request_target, issue_comment, workflow_run) would reach the credentials. Restore .github/workflows/tapster.yml with tapster init.")}function cO(e){let n=(i)=>{let s;try{s=ne(i)}catch{return!0}let o=s?.jobs;if(!o||typeof o!=="object")return!1;return Object.values(o).some((a)=>{let c=a?.environment,l=typeof c==="object"&&c!==null?c.name:c;return typeof l==="string"&&(l.trim().toLowerCase()==="tapster"||l.includes("${{"))})},r=Object.entries(e).filter(([,i])=>n(i)).map(([i])=>i);return r.length===0?F("no other workflow uses the tapster environment"):M("no other workflow uses the tapster environment",`Remove the tapster environment from ${r.join(", ")}.`)}function lO(e,t,n){let i=Ee(e),s=i.filter((a)=>!t.includes(`SPARKLE_KEY_${a.toUpperCase()}`));if(s.length)return M("every Sparkle key is stored and passed to the sparkle step",s.map((a)=>`Run tapster init --sparkle ${a}.`).join(" "));let o=i.filter((a)=>!n.includes(`SPARKLE_KEY_${a.toUpperCase()}: "\${{ secrets.SPARKLE_KEY_${a.toUpperCase()} }}"`));if(o.length)return M("every Sparkle key is stored and passed to the sparkle step",`The workflow does not pass ${o.map((a)=>`SPARKLE_KEY_${a.toUpperCase()}`).join(", ")}. Run tapster init --workflow.`);return F("every Sparkle key is stored and passed to the sparkle step")}function uO(e,t){let r=Object.entries(t).filter(([,i])=>i!==e).map(([i])=>i);return r.length?M("every project rings the hub's doorbell",r.map((i)=>`gh variable set TAPSTER_DOORBELL --repo ${i} --body ${e}`).join("; ")):F("every project rings the hub's doorbell")}function pO(e,t,n,r){if(!n.includes("TAPSTER_LINUX_KEY"))return M("the Linux repositories can be signed and deployed","Run tapster init --linux to make and store the signing key.");if(!r)return M("the Linux repositories can be signed and deployed","Turn on GitHub Pages for the hub; tapster init --linux does it.");if(r.build_type!=="workflow")return M("the Linux repositories can be signed and deployed","Set the hub's Pages source to GitHub Actions; tapster init --linux does it.");let s=r.html_url.replace(/\/$/,"");if(s!==gg(e,t))return M("the Linux repositories can be signed and deployed",`Pages serves ${s}; set linux.url in tapster.yml to it.`);return F("the Linux repositories can be signed and deployed")}var Ev=["MACOS_SIGN_P12","MACOS_SIGN_PASSWORD","MACOS_NOTARY_KEY","MACOS_NOTARY_KEY_ID","MACOS_NOTARY_ISSUER_ID"],dO=[...Ev,"TAPSTER_APP_PRIVATE_KEY"];function hO(e,t,n){let i=e?.packages.some(is)??!1,s=[...["TAPSTER_APP_PRIVATE_KEY",...i?Ev:[]].filter((a)=>!t.includes(a)),...["TAPSTER_APP_ID","TAPSTER_APP_SLUG",...i?["TAPSTER_TEAM_ID"]:[]].filter((a)=>!n.includes(a))];if(s.length===0)return F("the credentials this hub needs are stored");let o=[...s.some((a)=>a.startsWith("TAPSTER_APP"))?["tapster init"]:[],...s.some((a)=>a.startsWith("MACOS_SIGN")||a==="TAPSTER_TEAM_ID")?["tapster init --rotate certificate"]:[],...s.some((a)=>a.startsWith("MACOS_NOTARY"))?["tapster init --rotate notary"]:[]];return M("the credentials this hub needs are stored",`Missing: ${s.join(", ")}. Run ${o.join(" and ")}.`)}function fO(e,t){let r=Bt.exec(e);if(!r)return M("the hub workflow is tapster's template","The workflow does not pin tapster. Run tapster init --workflow.");if(r[1]!==t.sha)return F("the hub workflow is tapster's template",`the hub runs tapster ${r[2]} (${r[1].slice(0,7)}) and this is tapster ${t.version}; tapster init --workflow moves the hub to this one. The tapster that wrote the workflow checks it byte for byte`);let i=[...e.matchAll(/SPARKLE_KEY_([A-Z0-9]+): "/g)].map((o)=>o[1].toLowerCase());return Xc(ks,We,{sha:r[1],tag:r[2]},i,rt(e)??10)===e?F("the hub workflow is tapster's template"):M("the hub workflow is tapster's template","The workflow differs from the template; hand edits can reach the credentials. Run tapster init --workflow and review the diff.")}function nl(e){return e.some((r)=>r.enforcement==="active"&&r.target==="branch"&&(r.conditions?.ref_name?.include??[]).some((i)=>i==="~DEFAULT_BRANCH"||i==="~ALL"||i==="refs/heads/main")&&(r.conditions?.ref_name?.exclude??[]).length===0&&["deletion","non_fast_forward"].every((i)=>(r.rules??[]).some((s)=>s.type===i))&&(r.bypass_actors??[]).every((i)=>i.actor_type==="RepositoryRole"&&i.actor_id===5))?F("main cannot be deleted or force-pushed, by anyone"):M("main cannot be deleted or force-pushed, by anyone",'Run tapster init to restore the ruleset "tapster main" (active, deletion and force pushes blocked, no one else may bypass).')}function rl(e,t){return e.allowed_actions==="selected"&&e.sha_pinning_required===!0&&t?.verified_allowed===!1&&(t.patterns_allowed??[]).every((i)=>i==="doguyilmaz/tapster@*")?F("the hub runs only GitHub's and tapster's actions, pinned by commit"):M("the hub runs only GitHub's and tapster's actions, pinned by commit","Run tapster init to restore the hub's Actions policy.")}function mO(e,t,n){let i=e.map((a)=>a.login).filter((a)=>a.toLowerCase()!==n.toLowerCase()),s=t.filter((a)=>!a.read_only).map((a)=>a.title);if(i.length===0&&s.length===0)return F("only you can change the hub");let o=[...i.length?[`collaborators ${i.join(", ")} can push to main and change what the hub signs`]:[],...s.length?[`deploy keys ${s.join(", ")} can push too`]:[]];return M("only you can change the hub",`${o.join("; ")}. Remove them in the hub's settings unless you trust them with your signing keys.`)}function gO(e,t){if(e===String(t))return F("the doorbell keeps the workflow's schedule");return M("the doorbell keeps the workflow's schedule",`The doorbell starts the hub every ${e??"10"} minutes and the workflow every ${t}. Run tapster init --rotate doorbell to move the doorbell to the workflow's schedule.`)}function vO(e,t,n){if(e.some((s)=>(s.event==="schedule"||s.event==="workflow_dispatch")&&t-Date.parse(s.created_at)<86400000))return F("the hub ran in the last day");return M("the hub ran in the last day",n?"Neither GitHub's schedule nor the doorbell started a run. Check the doorbell's logs with wrangler tail and the workflow in the Actions tab.":"GitHub's schedule did not start a run; it is best effort. tapster init --doorbell adds a second clock that starts the hub on time.")}async function it(e,t,n){try{let r=await e.json("GET",t);return(n?r[n]:r)??[]}catch(r){if(r instanceof R&&r.status===404)return[];throw r}}async function yO(e,t,n,r,i){let s=[],o=await e.json("GET",`/repos/${t}/environments/tapster`).catch(()=>null);if(!o)return[M("the tapster environment exists","Run tapster init.")];let a=await e.json("GET",`/repos/${t}/environments/tapster/deployment-branch-policies`);s.push(o.deployment_branch_policy?.custom_branch_policies&&a.branch_policies.length===1&&a.branch_policies[0].name==="main"&&(a.branch_policies[0].type??"branch")==="branch"?F("only main may open the tapster environment"):M("only main may open the tapster environment","Run tapster init to restore the branch rule."));let c=(await it(e,`/repos/${t}/environments/tapster/secrets?per_page=100`,"secrets")).map((y)=>y.name),l=await it(e,`/repos/${t}/environments/tapster/variables?per_page=100`,"variables");s.push(hO(r,c,l.map((y)=>y.name)));let u=l.find((y)=>y.name==="TAPSTER_CERT_EXPIRES")?.value;if(u&&Date.parse(`${u}T00:00:00Z`)-Date.now()<2592000000)s.push(M("the Developer ID certificate is valid for 30 more days",`It expires on ${u}. Renew it at developer.apple.com, then run tapster init --rotate certificate.`));if(r&&Ee(r).length)s.push(lO(r,c,i));if(r?.packages.some((y)=>!Y(y)&&y.linux)){let y=await e.json("GET",`/repos/${t}/pages`).catch(()=>null);if(s.push(pO(r,t,c,y)),c.includes("TAPSTER_LINUX_KEY_PREVIOUS"))s.push(F("the Linux key rotation is running","the previous Linux key still signs; once apt and dnf users have the new key, run tapster init --rotate linux --finish"))}let p=await it(e,`/repos/${t}/actions/variables?per_page=100`,"variables"),d=[...l,...p].map((y)=>y.name).filter((y)=>dO.includes(y)||/^SPARKLE_KEY_/.test(y)||y.startsWith("TAPSTER_LINUX_KEY"));s.push(d.length?M("credentials are secrets, not variables",`Variables are readable by anyone with access; delete ${d.join(", ")} and store them with tapster init --rotate.`):F("credentials are secrets, not variables"));let h=l.find((y)=>y.name==="TAPSTER_DOORBELL")?.value;if(h&&r){let y={};for(let x of r.packages)y[x.repo]=await e.json("GET",`/repos/${x.repo}/actions/variables/TAPSTER_DOORBELL`).then((S)=>S.value).catch(()=>null);s.push(uO(h,y)),s.push(gO(l.find((x)=>x.name==="TAPSTER_DOORBELL_EVERY")?.value,rt(i)??10))}let f=await e.json("GET",`/repos/${t}/actions/permissions/workflow`);s.push(f.default_workflow_permissions==="read"?F("the default workflow token is read-only"):M("the default workflow token is read-only","Run tapster init."));let m=await Promise.all((await it(e,`/repos/${t}/rulesets`)).map((y)=>e.json("GET",`/repos/${t}/rulesets/${y.id}`)));s.push(nl(m));let g=await e.json("GET",`/repos/${t}/actions/permissions`),w=g.allowed_actions==="selected"?await e.json("GET",`/repos/${t}/actions/permissions/selected-actions`):null;s.push(rl(g,w)),s.push(mO(await it(e,`/repos/${t}/collaborators?affiliation=direct&per_page=100`),await it(e,`/repos/${t}/keys?per_page=100`),n));let k=await e.json("GET",`/repos/${t}/actions/workflows/tapster.yml`).catch(()=>null);s.push(k?.state==="active"?F("the hub workflow is enabled"):M("the hub workflow is enabled","Enable the tapster workflow in the hub's Actions tab (GitHub pauses it after 60 days without activity; the doorbell turns it back on)."));let _=await it(e,`/repos/${t}/actions/workflows/tapster.yml/runs?per_page=30`,"workflow_runs");s.push(vO(_,Date.now(),Boolean(h)));for(let y of r?.packages??[]){let x=await e.getRepo(y.repo).catch((A)=>A instanceof R?null:Promise.reject(A));if(!x){s.push(M(`${y.repo} exists`,"Fix the repo field in tapster.yml."));continue}if(x.private)s.push(F(`${y.repo} is published by the hub`,`${y.repo} is private: the hub publishes its releases, but Homebrew, Scoop, apt and dnf users can only install from public projects`));if(y.protection==="off")s.push(F(`${y.repo} is protected`,`protection is off for ${y.name}: a stolen App key could tag code there that the hub would sign`));else{let A=await gr(e,y.repo,x.default_branch,"admin",y.protection==="dependabot"),j=y.protection==="dependabot"?`branches named dependabot/... are open on ${y.repo}, so a stolen App key could run its workflows on code of its own there`:void 0;s.push(A.length?M(`${y.repo} is protected`,`${A.join("; ")}. Run tapster add in a clone of ${y.repo}.`):F(`${y.repo} is protected`,j))}let S=(await it(e,`/repos/${y.repo}/actions/secrets?per_page=100`,"secrets")).map((A)=>A.name),O=ws(S);s.push(O.length?M(`${y.repo} holds no release secrets`,`Delete ${O.join(", ")}: gh secret delete <name> --repo ${y.repo}`):F(`${y.repo} holds no release secrets`))}return s}async function bO(e,t,n){let i=(await e.json("GET",`/repos/${t}/environments/tapster/variables`).catch(()=>null))?.variables.find((s)=>s.name==="TAPSTER_APP_SLUG")?.value;if(!i||n.length===0)return null;return`note: the App must be installed on ${n.join(", ")} and not on ${t}; GitHub shows its repositories only to the App itself, so check them at https://github.com/apps/${i}/installations/new (the hub's check job also reports both)`}function wO(e,t){if(e===null)return{checks:[M("tapster.yml is valid","Run tapster init.")],config:null};try{let{config:n,invalid:r}=ie(e,t);if(r.length===0)return{checks:[F("tapster.yml is valid")],config:n};return{checks:r.map((i)=>M(`${i.name} in tapster.yml is valid`,`${i.reason}. ${i.fix}`)),config:n}}catch(n){return{checks:[M("tapster.yml is valid",n instanceof v?`${n.reason}. ${n.fix}`:"Run tapster init.")],config:null}}}async function _O(e,t){let n=(await it(e,`/repos/${t}/contents/.github/workflows?ref=main`)).filter((i)=>i.type==="file").map((i)=>i.name),r={};for(let i of n)r[i]=await de(e,t,`.github/workflows/${i}`,"main")??"";return{config:await de(e,t,"tapster.yml","main"),flows:r}}async function $r(e,t){let n=t.split("/")[0],r=await _O(e,t),i=[],s=wO(r.config,n),o=s.config;i.push(...s.checks);let a=r.flows["tapster.yml"];if(a)i.push(aO(a),fO(a,ae));else i.push(M("the hub workflow exists","Run tapster init, commit and push."));let{"tapster.yml":c,...l}=r.flows;return i.push(cO(l)),i.push(...await yO(e,t,n,o,a??"")),{checks:i,note:await bO(e,t,o?.packages.map((u)=>u.repo)??[])}}async function Ov(e){let t=await He(process.cwd()),n=await At();console.log(`Checking ${t} as it is on GitHub's main branch.`);let{checks:r,note:i}=await $r(n,t);for(let s of r)if(console.log(s.ok?`ok ${s.name}`:`fix ${s.name}
1080
+ ${s.fix}`),s.note)console.log(` note: ${s.note}`);if(i)console.log(i);return r.every((s)=>s.ok)?0:1}import{createHash as HO,createPrivateKey as FO,createPublicKey as KO}from"crypto";import{existsSync as bn,readFileSync as Ir}from"fs";import{mkdir as Yv,writeFile as dl}from"fs/promises";import{join as Oe}from"path";import{createHash as kO,createPrivateKey as xO,createPublicKey as Cv,sign as SO,verify as AO}from"crypto";var Ht=2n**255n-19n,il=2n**252n+27742317777372353535851937790883648493n,K=(e,t=Ht)=>(e%t+t)%t,sl=(e,t)=>{let n=1n,r=K(e);for(let i=t;i>0n;i>>=1n){if(i&1n)n=n*r%Ht;r=r*r%Ht}return n},Ts=(e)=>sl(e,Ht-2n),Nv=K(-121665n*Ts(121666n));function Rv([e,t,n,r],[i,s,o,a]){let c=K((t-e)*(s-i)),l=K((t+e)*(s+i)),u=K(2n*r*a*Nv),p=K(2n*n*o),d=l-c,h=p-u,f=p+u,m=l+c;return[K(d*h),K(f*m),K(h*f),K(d*m)]}function zv(e,t){let n=[0n,1n,1n,0n],r=t;for(let i=e;i>0n;i>>=1n){if(i&1n)n=Rv(n,r);r=Rv(r,r)}return n}var Lv=(()=>{let e=K(4n*Ts(5n)),t=K(e*e-1n),n=K(Nv*e*e+1n),r=sl(K(t*Ts(n)),(Ht+3n)/8n);if(K(r*r*n-t)!==0n)r=K(r*sl(2n,(Ht-1n)/4n));if(r&1n)r=Ht-r;return[r,e,1n,K(r*e)]})(),Ps=(e)=>e.reduceRight((t,n)=>t<<8n|BigInt(n),0n);function jv(e){let t=Buffer.alloc(32),n=e;for(let r=0;r<32;r++)t[r]=Number(n&255n),n>>=8n;return t}function Dv([e,t,n]){let r=Ts(n),i=K(e*r),s=K(t*r);return jv(s|(i&1n)<<255n)}var Iv=(...e)=>kO("sha512").update(Buffer.concat(e)).digest();function $O(e,t,n){let r=Ps(e.subarray(0,32)),i=K(Ps(Iv(e.subarray(32,64),n)),il),s=Dv(zv(i,Lv)),o=K(Ps(Iv(s,t,n)),il);return Buffer.concat([s,jv(K(i+o*r,il))])}var PO=Buffer.from("302e020100300506032b657004220420","hex"),TO=Buffer.from("302a300506032b6570032100","hex"),$s=(e)=>new v(`the Sparkle key ${e}`,"Store the app's Sparkle key again with tapster init --sparkle <label> --account <keychain account>.");function Es(e){let t=e.trim();if(!/^[A-Za-z0-9+/]+={0,2}$/.test(t))throw $s("is not base64");let n=Buffer.from(t,"base64");hn(n.toString("hex"));let r,i;if(n.length===32){let o=xO({key:Buffer.concat([PO,n]),format:"der",type:"pkcs8"}),a=Cv(o).export({format:"der",type:"spki"});r=a.subarray(a.length-32),i=(c)=>SO(null,c,o)}else if(n.length===96){let o=n.subarray(0,64);if(hn(o.toString("base64")),r=Buffer.from(n.subarray(64)),!Dv(zv(Ps(o.subarray(0,32)),Lv)).equals(r))throw $s("is damaged: its two halves do not match");i=(a)=>$O(o,r,a)}else throw $s(`decodes to ${n.length} bytes, not 32 or 96`);let s=Cv({key:Buffer.concat([TO,r]),format:"der",type:"spki"});return{publicKey:r.toString("base64"),sign(o){let a=i(o);if(!AO(null,o,s,a))throw $s("produced a signature that does not verify");return a}}}function Os(e,t,n){return{name:`tapster-${e}-${t.split("/")[1].replace(/^homebrew-/,"")}`.toLowerCase().slice(0,34),url:`https://github.com/${t}`,redirect_url:n,public:!1,default_permissions:{contents:"write",attestations:"read",metadata:"read"},default_events:[],hook_attributes:{url:"https://example.com/tapster-has-no-webhook",active:!1}}}async function Pr(e,t){await ze(e,"TAPSTER_APP_ID",String(t.id)),await ze(e,"TAPSTER_APP_SLUG",t.slug),await ee(e,"TAPSTER_APP_PRIVATE_KEY",t.pem)}async function Cs(e,t,n,r,i=new pe(Be(e,t))){let s;try{s=(await i.json("GET",`/users/${n}/installation`)).id}catch(a){if(a instanceof R&&a.status===404)return{id:null,onHub:!1};throw a}let o=await i.json("GET",`/repos/${r}/installation`).then(()=>!0,(a)=>a instanceof R&&a.status===404?!1:Promise.reject(a));return{id:s,onHub:o}}import{existsSync as EO}from"fs";import{writeFile as OO}from"fs/promises";import{join as CO}from"path";var ol=65536,al=8192;function RO(e){return/(?:^|[,/]\s*)OU=([A-Z0-9]{10})(?:[,/]|$)/.exec(e)?.[1]??null}function IO(e,t,n=Date.now()){let r=/(?:^|,)CN=((?:[^,\\]|\\.)*)/.exec(e)?.[1]??"";if(!r.startsWith("Developer ID Application:"))throw new v(`the certificate is "${r||"unnamed"}", not a Developer ID Application certificate`,"Create a Developer ID Application certificate at developer.apple.com, export it with its key from Keychain Access as .p12, then run this again.");let i=RO(e);if(!i)throw new v("the certificate has no team ID","Export the Developer ID Application certificate from Keychain Access.");let s=Date.parse(t);if(Number.isNaN(s))throw new v("the certificate's expiry date cannot be read","Export the certificate again from Keychain Access.");let o=new Date(s).toISOString().slice(0,10);if(s<n)throw new v(`the certificate expired on ${o}`,"Create a new Developer ID Application certificate at developer.apple.com.");return{team:i,expires:o,name:r.replace(/\\(.)/g,"$1")}}function NO(e,t){if(/mac verify error|invalid password/i.test(e.stdout))throw new v("the .p12 could not be opened with that password","Check the password you set when exporting it or export it again.");if(/unsupported/i.test(e.stdout))throw new v("this system's openssl cannot read the .p12","Run this on macOS or export the certificate again from Keychain Access.");if(!/certificate bag/i.test(e.stdout))throw new v("the .p12 holds no certificate","Export the Developer ID Application certificate from My Certificates in Keychain Access.");if(!/key ?bag/i.test(e.stdout))throw new v("the .p12 holds the certificate but not its private key","Export it from My Certificates in Keychain Access on the Mac that holds the key.");if(t.code!==0||!t.stdout.includes("BEGIN CERTIFICATE"))throw new v("the .p12 could not be read","Export it again from My Certificates in Keychain Access.")}async function Rs(e,t,n=Date.now()){if(e.length===0||e.length>ol)throw new v("that file is not a .p12 certificate","Export the Developer ID Application certificate from Keychain Access as .p12.");let r=t===""?"pass:":"env:TAPSTER_P12",i=(p)=>Pe("openssl",["pkcs12",...p,"-passin",r],{env:{TAPSTER_P12:t},stdin:e,allowFail:!0}),s=[],o=await i(["-info","-noout"]);if(/unsupported/i.test(o.stderr))s=["-legacy"],o=await i([...s,"-info","-noout"]);let a=await i([...s,"-nokeys","-clcerts"]);NO({code:o.code,stdout:`${o.stdout}
1081
+ ${o.stderr}`},a);let c=await Pe("openssl",["x509","-noout","-subject","-enddate","-nameopt","RFC2253"],{stdin:a.stdout}),l=/^subject=\s*(.*)$/m.exec(c.stdout)?.[1]?.trim()??"",u=/^notAfter=(.*)$/m.exec(c.stdout)?.[1]?.trim()??"";return IO(l,u,n)}async function Is(e,t,n,r){await ee(e,"MACOS_SIGN_P12",Buffer.from(t).toString("base64")),await ee(e,"MACOS_SIGN_PASSWORD",n),await ze(e,"TAPSTER_TEAM_ID",r.team),await ze(e,"TAPSTER_CERT_EXPIRES",r.expires)}var zO=(e,t,n)=>["notarytool","history","--key",e,"--key-id",t,"--issuer",n,"--output-format","json"];function LO(e){if(/HTTP status code: 401\b/.test(e))return new v("Apple rejected the notary key (HTTP 401)","Check the .p8 file, the Key ID and the Issuer ID in App Store Connect, then run this again.");if(/HTTP status code: 403\b/.test(e))return new v("Apple refused the notary key (HTTP 403)","Accept the latest agreements in App Store Connect and check that the key has Developer access, then run this again.");let t=e.split(`
1082
+ `).find((r)=>r.trim()!=="")?.trim()??"no message",n=/unable to find utility|notarytool.*not found/i.test(e);return new v(`notarytool could not check the key: ${fn(t).slice(0,300)}`,n?"Install Xcode or its command line tools (xcode-select --install), then run this again.":"Check your connection and the key in App Store Connect, then run this again.")}function cl(e){if(e.length===0||e.length>al||!Buffer.from(e).toString("utf8").includes("BEGIN PRIVATE KEY"))throw new v("that file is not an App Store Connect key","Download the .p8 from App Store Connect, Users and Access, Integrations.")}function ll(e){let t=e.trim();if(!/^[A-Z0-9]{10}$/.test(t))throw new v(`${t||"an empty Key ID"} is not a Key ID`,"Copy the 10-character Key ID next to the key in App Store Connect.");return t}function Ns(e,t,n){cl(e);let r=ll(t),i=n.trim().toLowerCase();if(!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/.test(i))throw new v("that is not an Issuer ID","Copy the Issuer ID shown above the key list in App Store Connect.");return{p8:e,keyId:r,issuer:i}}async function zs(e){if(process.platform!=="darwin"||!EO(mn.xcrun))return!1;let t=$t("tapster-notary-");try{let n=CO(t,`AuthKey_${e.keyId}.p8`);await OO(n,e.p8,{mode:384});let r=await D(mn.xcrun,"xcrun",zO(n,e.keyId,e.issuer),{allowFail:!0});if(r.code!==0)throw LO(r.stderr);return!0}finally{Fe(t)}}async function Ls(e,t){await ee(e,"MACOS_NOTARY_KEY",Buffer.from(t.p8).toString("base64")),await ee(e,"MACOS_NOTARY_KEY_ID",t.keyId),await ee(e,"MACOS_NOTARY_ISSUER_ID",t.issuer)}import{generateKeyPairSync as jO}from"crypto";import{existsSync as DO}from"fs";function Mv(){let{privateKey:e,publicKey:t}=jO("ed25519"),n=e.export({format:"der",type:"pkcs8"}).subarray(-32),r=t.export({format:"der",type:"spki"}).subarray(-32);return{seed:n.toString("base64"),publicKey:r.toString("base64")}}var MO=/^[A-Za-z0-9 .:/@_+=()-]+$/;function Er(e){for(let t of[e.service,e.account,e.label,...e.comment===void 0?[]:[e.comment]])if(!MO.test(t))throw new v(`"${t}" cannot name a keychain item`,"Use letters, digits and simple punctuation.")}function UO(e,t){Er(e);let n=e.comment===void 0?"":` -j "${e.comment}"`,r=`add-generic-password -s "${e.service}" -a "${e.account}" -l "${e.label}" -D "private key"${n} -T "" -X ${Buffer.from(t).toString("hex")}
1083
1083
  `;if(r.length>4000)throw new v("the key is too long for one security command","tapster stores large keys through the Security API instead.");return r}var ZO=`ObjC.import("Security");
1084
1084
  ObjC.import("Foundation");
1085
1085
  function run(argv) {
@@ -1095,8 +1095,8 @@ function run(argv) {
1095
1095
  q.setObjectForKey($(argv[2]), k($.kSecAttrLabel));
1096
1096
  q.setObjectForKey($.NSFileHandle.fileHandleWithStandardInput.readDataToEndOfFile, k($.kSecValueData));
1097
1097
  return String($.SecItemAdd(q, null));
1098
- }`;function GO(e){return Er(e),["-l","JavaScript","-e",ZO,e.service,e.account,e.label]}function qO(e){return Er(e),["store","--label",e.label,"service",e.service,"account",e.account]}var Tr="/usr/bin/security",Uv="/usr/bin/osascript",Ds="/usr/bin/secret-tool",BO={kind:"keychain",exists:async(e)=>(await L(Tr,"security",["find-generic-password","-s",e.service,"-a",e.account],{allowFail:!0})).code===0,async save(e,t){let n=null;try{n=UO(e,t)}catch(i){if(!(i instanceof v)||!i.reason.includes("too long"))throw i}if(n!==null){let i=await L(Tr,"security",["-i"],{stdin:n,allowFail:!0});if(i.code===0&&!/error|returned/i.test(i.stderr))return;throw new v("the login keychain refused the key","Unlock the login keychain and run this again.")}let r=await L(Uv,"osascript",GO(e),{stdin:t,allowFail:!0});if(r.code!==0||r.stdout.trim()!=="0")throw new v(`the login keychain refused the key (status ${r.stdout.trim()||r.code})`,"Unlock the login keychain and run this again.")},async read(e){let t=await L(Tr,"security",["find-generic-password","-s",e.service,"-a",e.account,"-w"],{allowFail:!0});return t.code===0?t.stdout.replace(/\n$/,""):null},async remove(e){await L(Tr,"security",["delete-generic-password","-s",e.service,"-a",e.account],{allowFail:!0})}},Zv={kind:"secret-service",exists:async(e)=>await Zv.read(e)!==null,async save(e,t){if((await L(Ds,"secret-tool",qO(e),{stdin:t,allowFail:!0})).code!==0)throw new v("the Secret Service refused the key","Unlock your keyring (GNOME Keyring or KWallet) and run this again.")},async read(e){Er(e);let t=await L(Ds,"secret-tool",["lookup","service",e.service,"account",e.account],{allowFail:!0});return t.code===0&&t.stdout!==""?t.stdout:null},async remove(e){Er(e),await L(Ds,"secret-tool",["clear","service",e.service,"account",e.account],{allowFail:!0})}};function ul(e=process.platform,t=LO){if(e==="darwin")return t(Tr)&&t(Uv)?BO:null;if(e==="linux")return t(Ds)?Zv:null;return null}async function Gv(e,t){let n=await e.read(t);if(n!==null||!await e.exists(t))return n;throw new v("the previous key is in your keychain, but tapster could not read it","Choose Allow when macOS asks. Run this where you can see that question (not over SSH). Nothing was changed.")}function Or(e){let t=ul();if(t)return t;throw new v(`tapster keeps a copy of ${e} in your keychain, but this system has none it can use`,"Run this on macOS or on Linux with secret-tool (libsecret-tools) installed. The key must never live only in GitHub, which never gives secrets back.")}function WO(e,t){let n=new Set(e.vars),r=new Set(e.secrets),i=[];if(!(n.has("TAPSTER_APP_ID")&&n.has("TAPSTER_APP_SLUG")))i.push("app");else if(!r.has("TAPSTER_APP_PRIVATE_KEY"))i.push("app-key");if(t&&!(n.has("TAPSTER_TEAM_ID")&&r.has("MACOS_SIGN_P12")&&r.has("MACOS_SIGN_PASSWORD")))i.push("certificate");if(t&&!["MACOS_NOTARY_KEY","MACOS_NOTARY_KEY_ID","MACOS_NOTARY_ISSUER_ID"].every((s)=>r.has(s)))i.push("notary");return i.push("files"),i}var Jv=(e)=>e.trim().toLowerCase()==="yes";function VO(e,t){return["app","certificate","notary"].filter((n)=>!e.includes(n)&&(n==="app"?!e.includes("app-key"):t))}function YO(e,t){if(!(e instanceof R)||!t||![403,404,422].includes(e.status))return e;return new v("GitHub refused environments on this private hub","Environments and their secrets need a public hub or GitHub Pro. Make the hub public or upgrade at https://github.com/settings/billing, then run tapster init again.")}function hl(e,t,n){let r=[];for(let i of e.packages.filter(Y)){let s=i.sparkle?.key===t?i.sparkle.public_key:i.sparkle?.next_key===t?i.sparkle.next_public_key:void 0;if(s===void 0)continue;if(s!==n)throw new v(`${i.name} pins ${s} for ${t}, but this key's public half is ${n}`,"Pick the keychain account of the key the app ships with or fix tapster.yml.");r.push(i.name)}if(r.length===0)throw new v(`no package in tapster.yml uses the Sparkle key ${t}`,"Add the package with its sparkle section first.");return r}async function Qv(e,t,n,r,i){console.log("Waiting up to 10 minutes until the App is installed; tapster continues by itself once you choose Install.");let s=await ms(async()=>{let o=await Cs(e,t,n,r).catch(()=>null);return o?.id?o:null});if(s===null){console.log(`The App is not installed yet. Install it at https://github.com/apps/${i}/installations/new; tapster add links there for each project too.`);return}if(s.onHub)console.log(`The App is installed on ${r}. Remove ${r} from it at https://github.com/settings/installations/${s.id}; the hub refuses to run until you do.`)}async function JO(e,t){console.log("GitHub creates a private App for your hub; it lets the hub publish your projects' releases. Confirm it on the page that opens.");let n=await ps((r)=>Os(e,t,r),{what:"your tapster App",title:"Create your tapster App",lead:`GitHub asks you to confirm a private App on your account. ${t} uses it to publish the releases of the projects you install it on.`,key:`GitHub hands the App's private key to tapster in your terminal, once. tapster stores it as a secret of the tapster environment in ${t}. It goes nowhere else and no one else receives it.`,done:"Your tapster App is created",next:[`tapster stores the App's ID and key in ${t} and opens the App's install page in a new tab.`,`There, choose "Only select repositories" and pick the projects tapster should publish. Never pick ${t}: it holds your signing keys.`,'Click "Install". tapster notices within seconds and continues.'],again:"tapster init"},e);await Pr(t,n),console.log('Stored the App and its key in the hub. Now install it: choose "Only select repositories" and pick the projects tapster should publish.'),console.log(`Never pick ${t}: the App can write to every repository it is installed on. The hub holds your signing keys. tapster add can also install it on a project later.`),Zt(`https://github.com/apps/${n.slug}/installations/new`),await Qv(String(n.id),n.pem,e,t,n.slug)}function QO(e){let t;try{t=FO(e)}catch{throw new v("that file is not a private key","Use the .pem file GitHub downloaded when you generated the key.")}if(t.asymmetricKeyType!=="rsa")throw new v("that file is not a GitHub App key","Use the .pem file GitHub downloaded when you generated the key.");let n=KO(t).export({type:"spki",format:"der"});return`SHA256:${HO("sha256").update(n).digest("base64")}`}async function qv(e,t){let n=await e.json("GET",`/repos/${t}/environments/tapster/variables`),r=n.variables.find((c)=>c.name==="TAPSTER_APP_ID")?.value,i=n.variables.find((c)=>c.name==="TAPSTER_APP_SLUG")?.value;if(!r||!i)throw new v("the hub has no App yet","Run tapster init first.");console.log(`Open the App's settings, scroll to "Private keys" and click "Generate a private key":`),Zt(`https://github.com/settings/apps/${i}`);let s=vn(await me("Path of the downloaded .pem file (drag it here): ")),o=(await yn(s,"the .pem file")).toString("utf8"),a=QO(o);await new pe(Be(r,o)).json("GET","/app").catch(()=>{throw new v("that key does not belong to the hub's App",`Generate the key on https://github.com/settings/apps/${i}.`)}),await ee(t,"TAPSTER_APP_PRIVATE_KEY",o),console.log(`Stored the new key (${a}).`),await Qv(r,o,t.split("/")[0],t,i),console.log(`Now delete every other key on that page so the old one stops working. Then delete ${s}.`)}async function Bv(e){console.log("Apple certificate: a Developer ID Application certificate exported as .p12. In Keychain Access, open My Certificates,"),console.log('right-click "Developer ID Application: ...", choose Export and save it as .p12 with a password. Create one at'),console.log("https://developer.apple.com/account/resources/certificates if you have none. It stays in your hub's secrets only.");let t=vn(await me(".p12 file (drag it here): ")),n=await yn(t,"the .p12 file"),r=await me(".p12 password: ",!0),i=await Rs(n,r);await Is(e,n,r,i),console.log(`Certificate stored for team ${i.team}. It expires on ${i.expires}; the hub warns 30 days before.`)}async function Hv(e){console.log("Notarization key: an App Store Connect API key. In App Store Connect open Users and Access, Integrations,"),console.log("App Store Connect API, Team Keys; create a key with Developer access and download AuthKey_<id>.p8 (Apple offers"),console.log("the download once). The Key ID is in the list and the Issuer ID above it. It stays in your hub's secrets only.");let t=vn(await me(".p8 file (drag it here): ")),n=await yn(t,"the .p8 file");cl(n);let r=ll(await me("Key ID: ")),i=Ns(n,r,await me("Issuer ID: "));console.log(await zs(i)?"Apple accepted the key.":"Not on macOS, so the key is checked at the first release instead."),await js(e,i),console.log(`Notarization key stored. You may delete ${t} once you keep a backup.`)}var pl={name:"tapster main",target:"branch",enforcement:"active",bypass_actors:[],conditions:{ref_name:{include:["~DEFAULT_BRANCH"],exclude:[]}},rules:[{type:"deletion"},{type:"non_fast_forward"}]};async function fl(e,t,n){try{await e.json("PUT",`/repos/${t}/environments/tapster`,{deployment_branch_policy:{protected_branches:!1,custom_branch_policies:!0}})}catch(s){throw YO(s,n)}let r=await e.json("GET",`/repos/${t}/environments/tapster/deployment-branch-policies`);for(let s of r.branch_policies.filter((o)=>o.name!=="main"))await e.json("DELETE",`/repos/${t}/environments/tapster/deployment-branch-policies/${s.id}`);if(!r.branch_policies.some((s)=>s.name==="main"))await e.json("POST",`/repos/${t}/environments/tapster/deployment-branch-policies`,{name:"main",type:"branch"});await e.json("PUT",`/repos/${t}/actions/permissions/workflow`,{default_workflow_permissions:"read",can_approve_pull_request_reviews:!1}),await e.json("PUT",`/repos/${t}/actions/permissions`,{enabled:!0,allowed_actions:"selected",sha_pinning_required:!0}),await e.json("PUT",`/repos/${t}/actions/permissions/selected-actions`,{github_owned_allowed:!0,verified_allowed:!1,patterns_allowed:["doguyilmaz/tapster@*"]});let i=(await e.json("GET",`/repos/${t}/rulesets`)).find((s)=>s.name===pl.name);if(i)await e.json("PUT",`/repos/${t}/rulesets/${i.id}`,pl);else await e.json("POST",`/repos/${t}/rulesets`,pl)}function Rr(e,t){let n=Oe(e,"tapster.yml");if(!bn(n))throw new v("tapster.yml is missing","Run tapster init in the hub first.");let{config:r,invalid:i}=ie(Ir(n,"utf8"),t.split("/")[0]);for(let s of i)console.log(`note: ${s.name} in tapster.yml is invalid and left out: ${s.reason}`);return r}async function XO(e,t,n,r,i){let s=bn(Oe(t,J))?Ir(Oe(t,J),"utf8"):null,o=await tl(e,s,n,r,i);await Yv(Oe(t,".github/workflows"),{recursive:!0}),await dl(Oe(t,J),o.file.content),console.log(`wrote ${J} from the template, ${o.change}; hand edits in it are replaced`);for(let a of o.notes)console.log(a)}async function Xv(e,t){let n=Oe(e,J);if(!bn(n))throw new v(`${J} is missing`,"Run tapster init --workflow first.");await dl(n,xs(Ir(n,"utf8"),t)),console.log(`updated the sparkle step in ${J}`)}async function e2(e,t,n,r,i){if(!/^[a-z0-9]+$/.test(r))throw new v(`${r} is not a valid label`,"Use lowercase letters and digits, as in sparkle.key.");let s=Rr(t,n);console.log("macOS asks whether tapster may read the Sparkle key from your keychain; choose Allow.");let o=await Pe("security",["find-generic-password","-s","https://sparkle-project.org","-a",i,"-w"],{allowFail:!0});if(o.code!==0)throw new v(`the login keychain has no Sparkle key for the account ${i}`,"Pass the account generate_keys used with --account (ed25519 by default).");let a=o.stdout.trim(),c=Es(a),l=hl(s,r,c.publicKey);console.log(`The key ${c.publicKey} signs updates for ${l.join(", ")}.`),console.log("If it is lost, installed copies can never update again; if it leaks, anyone can sign updates for them.");let u=await me("Do you keep an offline backup of this key? Type yes to store it in the hub: ");if(!Jv(u))throw new v("no offline backup confirmed","Back the key up first (generate_keys -x exports it), then run this again.");await ee(n,`SPARKLE_KEY_${r.toUpperCase()}`,a),console.log(`Stored SPARKLE_KEY_${r.toUpperCase()}.`),await Xv(t,Ee(s)),console.log("Review and commit the workflow change, then push.")}async function t2(e,t,n){if(!/^[a-z0-9]+$/.test(n))throw new v(`${n} is not a valid label`,"Use lowercase letters and digits, as in sparkle.key.");let r=Rr(e,t),i=r.packages.filter(Y).filter((c)=>c.sparkle?.key===n||c.sparkle?.next_key===n);if(i.length)throw new v(`${i.map((c)=>c.name).join(", ")} already sign with the Sparkle key ${n}`,"A new key needs a new label. To change an app's key, follow Rotate a Sparkle key in the tapster docs (Mac apps with Sparkle).");let s=Or("the Sparkle key"),o={service:"https://sparkle-project.org",account:n,label:"Private key for signing Sparkle updates"};if(await s.exists(o))throw new v(`your keychain already has a Sparkle key for the account ${n}`,`Store that one with tapster init --sparkle ${n} --account ${n} or pick another label.`);let a=Mv();if(await s.save({...o,comment:`Public key (SUPublicEDKey value) for this key is: ${a.publicKey}`},a.seed),console.log(`Saved a new Sparkle key in your ${s.kind==="keychain"?"login keychain":"keyring"} under the account ${n}. Sparkle's own tools find it there. macOS asks you before any app reads it.`),console.log(`Its public key is ${a.publicKey}. Put it in the app as SUPublicEDKey and in tapster.yml as sparkle.public_key.`),console.log("If this key is lost, installed copies can never update again. Keep an offline copy too, for example in your password manager:"),console.log(s.kind==="keychain"?` security find-generic-password -s https://sparkle-project.org -a ${n} -w (macOS asks you first)`:` secret-tool lookup service https://sparkle-project.org account ${n}`),!Jv(await me("Type yes once you keep an offline copy, to store the key in the hub: "))){console.log(`Not stored in the hub yet. Once you keep a copy, run tapster init --sparkle ${n} --account ${n}.`);return}await ee(t,`SPARKLE_KEY_${n.toUpperCase()}`,a.seed),console.log(`Stored SPARKLE_KEY_${n.toUpperCase()} in the hub.`),await Xv(e,[...new Set([...Ee(r),n])]),console.log("Review and commit the workflow change, then push.")}async function Fv(e,t,n){let r={...t,account:`${t.account} pending`,label:`${t.label} (pending)`};await e.remove(r),await e.save(r,n),await e.remove(t),await e.save(t,n),await e.remove(r)}var Cr=(e,t=!1)=>({service:"tapster-linux-key",account:t?`${e} previous`:e,label:`tapster Linux key for ${e}${t?" (previous)":""}`});async function n2(e,t){let n=(await Gt(e,t,"secrets")).map((r)=>r.name);if(await ul()?.remove(Cr(t,!0)),!n.includes("TAPSTER_LINUX_KEY_PREVIOUS")){console.log("No Linux key rotation is running, so there is nothing to finish.");return}await Wg(t,"TAPSTER_LINUX_KEY_PREVIOUS"),console.log("The previous Linux key no longer signs; apt and dnf trust only the new one from the next run.")}function r2(e,t){if(e.includes("TAPSTER_LINUX_KEY")&&!t)throw new v("the hub already has a Linux signing key","Replacing it makes every apt and dnf user fetch the new key. To do that, run tapster init --rotate linux.")}async function Kv(e,t,n,r){let i=Rr(t,n),s=(await Gt(e,n,"secrets")).map((u)=>u.name);r2(s,r);let o=Or("the Linux signing key"),a=["/opt/homebrew/bin/gpg","/usr/local/bin/gpg","/usr/bin/gpg"].find((u)=>bn(u));if(!a)throw new v("gpg is not installed","Install it with brew install gnupg, then run this again.");await e.json("POST",`/repos/${n}/pages`,{build_type:"workflow"}).catch(async(u)=>{if(!(u instanceof R)||u.status!==409)throw new v("GitHub Pages could not be turned on for the hub","A private hub needs a paid plan for Pages; make the hub public or turn Pages on by hand with GitHub Actions as the source.");await e.json("PUT",`/repos/${n}/pages`,{build_type:"workflow"})}),console.log("GitHub Pages serves the hub from GitHub Actions.");let c=$t("tl-"),l={GNUPGHOME:c};try{await L(a,"gpg",["--batch","--pinentry-mode","loopback","--passphrase","","--quick-gen-key",`${n.split("/")[0]} tapster (${n})`,"rsa4096","sign","never"],{env:l});let u=(await L(a,"gpg",["--batch","--armor","--export-secret-keys"],{env:l})).stdout,p=(await L(a,"gpg",["--batch","--with-colons","--list-secret-keys"],{env:l})).stdout.split(`
1099
- `).find((f)=>f.startsWith("fpr:"))?.split(":")[9],d=null;if(r){if(o.kind==="keychain")console.log("macOS asks whether tapster may read the previous key from your keychain; choose Allow.");d=await Gv(o,Cr(n))}let h={...Cr(n),account:`${n} new`,label:`tapster Linux key for ${n} (new)`};if(await o.remove(h),await o.save(h,u),await ee(n,"TAPSTER_LINUX_KEY",u),d)await ee(n,"TAPSTER_LINUX_KEY_PREVIOUS",d);if(d)await Fv(o,Cr(n,!0),d);if(await Fv(o,Cr(n),u),await o.remove(h),console.log(`Stored the Linux key (fingerprint ${p}) in the hub and in your ${o.kind==="keychain"?"login keychain":"keyring"} as "tapster-linux-key".`),d)console.log("The previous key keeps signing next to the new one, so apt and dnf users can fetch the new key. Once they have, run tapster init --rotate linux --finish.");else if(r)console.log("The previous key is not in your keychain, so apt and dnf users must fetch the new key before they can update.")}finally{await L(Oe(a,"..","gpgconf"),"gpgconf",["--kill","all"],{env:l,allowFail:!0}).catch(()=>{return}),Fe(c)}if(!i.packages.some((u)=>!Y(u)&&u.linux))console.log("No package sets linux: true yet; add it to the CLI packages that should ship to apt and dnf.")}async function i2(e,t,n,r,i){let o=await As(e,n,async(a)=>bn(Oe(t,a))?Ir(Oe(t,a),"utf8"):null,r,i);for(let a of o.files)await Yv(Oe(t,a.path,".."),{recursive:!0}),await dl(Oe(t,a.path),a.content),console.log(a.path===J?`wrote ${J} from the template, ${o.change}; hand edits in it are replaced`:`wrote ${a.path}`);for(let a of o.notes)console.log(a)}async function s2(e){let t=(await me(e)).toLowerCase();return t===""||t==="y"||t==="yes"}async function o2(e,t){let n=async(r)=>{try{return((await e.json("GET",`/repos/${t}/environments/tapster/${r}?per_page=100`))[r]??[]).map((s)=>s.name)}catch(i){if(i instanceof R&&i.status===404)return[];throw i}};return{vars:await n("variables"),secrets:await n("secrets"),private:(await e.getRepo(t)).private}}function Wv(e,t){let n=e.indexOf(t);if(n<0)return{value:null,rest:e};return{value:e[n+1]??"",rest:e.filter((r,i)=>i!==n&&i!==n+1)}}var a2="Run tapster init --help for the options.";function c2(e){let[t,n,r,i]=e;if(e.length===0)return{kind:"setup"};if(t==="--rotate"&&e.length===2&&["app","certificate","notary","doorbell","linux"].includes(n??""))return{kind:"rotate",what:n};if(t==="--rotate"&&n==="linux"&&r==="--finish"&&e.length===3)return{kind:"rotate",what:"linux-finish"};if(t==="--doorbell"&&e.length===1)return{kind:"doorbell"};if(t==="--linux"&&e.length===1)return{kind:"linux"};if(t==="--workflow"&&e.length===1)return{kind:"workflow"};if(t==="--sparkle"&&n&&!n.startsWith("-")){if(e.length===2)return{kind:"sparkle",label:n,account:"ed25519"};if(r==="--new"&&e.length===3)return{kind:"sparkle-new",label:n};if(r==="--account"&&i&&e.length===4)return{kind:"sparkle",label:n,account:i}}throw new v(`unknown option ${e.join(" ")}`,a2)}function Vv(e){let t=Oe(e,J);return bn(t)&&rt(Ir(t,"utf8"))||10}async function ey(e){let t=Wv(e,"--tapster"),n=Wv(t.rest,"--every"),r=t.value,i=n.value===null?null:Number(n.value),s=c2(n.rest);if(i!==null)gs(i);if((r!==null||i!==null)&&s.kind!=="setup"&&s.kind!=="workflow")throw new v("--tapster and --every go only with tapster init or init --workflow","Those are the commands that write the workflow.");let o=process.cwd(),a=await He(o),c=await At();if(s.kind==="rotate"){if(s.what==="app")return qv(c,a);if(s.what==="certificate")return Bv(a);if(s.what==="notary")return Hv(a);if(s.what==="doorbell")return cv(c,a,Vv(o));if(s.what==="linux-finish")return n2(c,a);return Kv(c,o,a,!0)}if(s.kind==="doorbell")return av(c,a,Rr(o,a),hs,Vv(o));if(s.kind==="linux")return Kv(c,o,a,!1);if(s.kind==="sparkle-new")return t2(o,a,s.label);if(s.kind==="sparkle")return e2(c,o,a,s.label,s.account);if(s.kind==="workflow")return XO(c,o,Ee(Rr(o,a)),r,{every:i,isPrivate:(await c.getRepo(a)).private});let l=await o2(c,a);await fl(c,a,l.private);let p=l.vars.includes("TAPSTER_TEAM_ID")||l.secrets.includes("MACOS_NOTARY_KEY")||await s2("Will this hub sign software for macOS (Mac apps or CLI tools with macOS builds)? [Y/n] "),d=WO(l,p),h=VO(d,p);if(h.length)console.log(`Already done: ${h.join(", ")}. To redo one, run tapster init --rotate <name>.`);for(let f of d){if(f==="app")await JO(a.split("/")[0],a);if(f==="app-key")await qv(c,a);if(f==="certificate")await Bv(a);if(f==="notary")await Hv(a);if(f==="files")await i2(c,o,a,r,{every:i,isPrivate:l.private})}if(!p)console.log("Skipped the Apple credentials. Add them later with tapster init --rotate certificate and tapster init --rotate notary.");console.log(`
1098
+ }`;function GO(e){return Er(e),["-l","JavaScript","-e",ZO,e.service,e.account,e.label]}function qO(e){return Er(e),["store","--label",e.label,"service",e.service,"account",e.account]}var Tr="/usr/bin/security",Uv="/usr/bin/osascript",js="/usr/bin/secret-tool",BO={kind:"keychain",exists:async(e)=>(await D(Tr,"security",["find-generic-password","-s",e.service,"-a",e.account],{allowFail:!0})).code===0,async save(e,t){let n=null;try{n=UO(e,t)}catch(i){if(!(i instanceof v)||!i.reason.includes("too long"))throw i}if(n!==null){let i=await D(Tr,"security",["-i"],{stdin:n,allowFail:!0});if(i.code===0&&!/error|returned/i.test(i.stderr))return;throw new v("the login keychain refused the key","Unlock the login keychain and run this again.")}let r=await D(Uv,"osascript",GO(e),{stdin:t,allowFail:!0});if(r.code!==0||r.stdout.trim()!=="0")throw new v(`the login keychain refused the key (status ${r.stdout.trim()||r.code})`,"Unlock the login keychain and run this again.")},async read(e){let t=await D(Tr,"security",["find-generic-password","-s",e.service,"-a",e.account,"-w"],{allowFail:!0});return t.code===0?t.stdout.replace(/\n$/,""):null},async remove(e){await D(Tr,"security",["delete-generic-password","-s",e.service,"-a",e.account],{allowFail:!0})}},Zv={kind:"secret-service",exists:async(e)=>await Zv.read(e)!==null,async save(e,t){if((await D(js,"secret-tool",qO(e),{stdin:t,allowFail:!0})).code!==0)throw new v("the Secret Service refused the key","Unlock your keyring (GNOME Keyring or KWallet) and run this again.")},async read(e){Er(e);let t=await D(js,"secret-tool",["lookup","service",e.service,"account",e.account],{allowFail:!0});return t.code===0&&t.stdout!==""?t.stdout:null},async remove(e){Er(e),await D(js,"secret-tool",["clear","service",e.service,"account",e.account],{allowFail:!0})}};function ul(e=process.platform,t=DO){if(e==="darwin")return t(Tr)&&t(Uv)?BO:null;if(e==="linux")return t(js)?Zv:null;return null}async function Gv(e,t){let n=await e.read(t);if(n!==null||!await e.exists(t))return n;throw new v("the previous key is in your keychain, but tapster could not read it","Choose Allow when macOS asks. Run this where you can see that question (not over SSH). Nothing was changed.")}function Or(e){let t=ul();if(t)return t;throw new v(`tapster keeps a copy of ${e} in your keychain, but this system has none it can use`,"Run this on macOS or on Linux with secret-tool (libsecret-tools) installed. The key must never live only in GitHub, which never gives secrets back.")}function WO(e,t){let n=new Set(e.vars),r=new Set(e.secrets),i=[];if(!(n.has("TAPSTER_APP_ID")&&n.has("TAPSTER_APP_SLUG")))i.push("app");else if(!r.has("TAPSTER_APP_PRIVATE_KEY"))i.push("app-key");if(t&&!(n.has("TAPSTER_TEAM_ID")&&r.has("MACOS_SIGN_P12")&&r.has("MACOS_SIGN_PASSWORD")))i.push("certificate");if(t&&!["MACOS_NOTARY_KEY","MACOS_NOTARY_KEY_ID","MACOS_NOTARY_ISSUER_ID"].every((s)=>r.has(s)))i.push("notary");return i.push("files"),i}var Jv=(e)=>e.trim().toLowerCase()==="yes";function VO(e,t){return["app","certificate","notary"].filter((n)=>!e.includes(n)&&(n==="app"?!e.includes("app-key"):t))}function YO(e,t){if(!(e instanceof R)||!t||![403,404,422].includes(e.status))return e;return new v("GitHub refused environments on this private hub","Environments and their secrets need a public hub or GitHub Pro. Make the hub public or upgrade at https://github.com/settings/billing, then run tapster init again.")}function hl(e,t,n){let r=[];for(let i of e.packages.filter(Y)){let s=i.sparkle?.key===t?i.sparkle.public_key:i.sparkle?.next_key===t?i.sparkle.next_public_key:void 0;if(s===void 0)continue;if(s!==n)throw new v(`${i.name} pins ${s} for ${t}, but this key's public half is ${n}`,"Pick the keychain account of the key the app ships with or fix tapster.yml.");r.push(i.name)}if(r.length===0)throw new v(`no package in tapster.yml uses the Sparkle key ${t}`,"Add the package with its sparkle section first.");return r}async function Qv(e,t,n,r,i){console.log("Waiting up to 10 minutes until the App is installed; tapster continues by itself once you choose Install.");let s=await ms(async()=>{let o=await Cs(e,t,n,r).catch(()=>null);return o?.id?o:null});if(s===null){console.log(`The App is not installed yet. Install it at https://github.com/apps/${i}/installations/new; tapster add links there for each project too.`);return}if(s.onHub)console.log(`The App is installed on ${r}. Remove ${r} from it at https://github.com/settings/installations/${s.id}; the hub refuses to run until you do.`)}async function JO(e,t){console.log("GitHub creates a private App for your hub; it lets the hub publish your projects' releases. Confirm it on the page that opens.");let n=await ps((r)=>Os(e,t,r),{what:"your tapster App",title:"Create your tapster App",lead:`GitHub asks you to confirm a private App on your account. ${t} uses it to publish the releases of the projects you install it on.`,key:`GitHub hands the App's private key to tapster in your terminal, once. tapster stores it as a secret of the tapster environment in ${t}. It goes nowhere else and no one else receives it.`,done:"Your tapster App is created",next:[`tapster stores the App's ID and key in ${t} and opens the App's install page in a new tab.`,`There, choose "Only select repositories" and pick the projects tapster should publish. Never pick ${t}: it holds your signing keys.`,'Click "Install". tapster notices within seconds and continues.'],again:"tapster init"},e);await Pr(t,n),console.log('Stored the App and its key in the hub. Now install it: choose "Only select repositories" and pick the projects tapster should publish.'),console.log(`Never pick ${t}: the App can write to every repository it is installed on. The hub holds your signing keys. tapster add can also install it on a project later.`),Zt(`https://github.com/apps/${n.slug}/installations/new`),await Qv(String(n.id),n.pem,e,t,n.slug)}function QO(e){let t;try{t=FO(e)}catch{throw new v("that file is not a private key","Use the .pem file GitHub downloaded when you generated the key.")}if(t.asymmetricKeyType!=="rsa")throw new v("that file is not a GitHub App key","Use the .pem file GitHub downloaded when you generated the key.");let n=KO(t).export({type:"spki",format:"der"});return`SHA256:${HO("sha256").update(n).digest("base64")}`}async function qv(e,t){let n=await e.json("GET",`/repos/${t}/environments/tapster/variables`),r=n.variables.find((c)=>c.name==="TAPSTER_APP_ID")?.value,i=n.variables.find((c)=>c.name==="TAPSTER_APP_SLUG")?.value;if(!r||!i)throw new v("the hub has no App yet","Run tapster init first.");console.log(`Open the App's settings, scroll to "Private keys" and click "Generate a private key":`),Zt(`https://github.com/settings/apps/${i}`);let s=vn(await me("Path of the downloaded .pem file (drag it here): ")),o=(await yn(s,"the .pem file")).toString("utf8"),a=QO(o);await new pe(Be(r,o)).json("GET","/app").catch(()=>{throw new v("that key does not belong to the hub's App",`Generate the key on https://github.com/settings/apps/${i}.`)}),await ee(t,"TAPSTER_APP_PRIVATE_KEY",o),console.log(`Stored the new key (${a}).`),await Qv(r,o,t.split("/")[0],t,i),console.log(`Now delete every other key on that page so the old one stops working. Then delete ${s}.`)}async function Bv(e){console.log("Apple certificate: a Developer ID Application certificate exported as .p12. In Keychain Access, open My Certificates,"),console.log('right-click "Developer ID Application: ...", choose Export and save it as .p12 with a password. Create one at'),console.log("https://developer.apple.com/account/resources/certificates if you have none. It stays in your hub's secrets only.");let t=vn(await me(".p12 file (drag it here): ")),n=await yn(t,"the .p12 file"),r=await me(".p12 password: ",!0),i=await Rs(n,r);await Is(e,n,r,i),console.log(`Certificate stored for team ${i.team}. It expires on ${i.expires}; the hub warns 30 days before.`)}async function Hv(e){console.log("Notarization key: an App Store Connect API key. In App Store Connect open Users and Access, Integrations,"),console.log("App Store Connect API, Team Keys; create a key with Developer access and download AuthKey_<id>.p8 (Apple offers"),console.log("the download once). The Key ID is in the list and the Issuer ID above it. It stays in your hub's secrets only.");let t=vn(await me(".p8 file (drag it here): ")),n=await yn(t,"the .p8 file");cl(n);let r=ll(await me("Key ID: ")),i=Ns(n,r,await me("Issuer ID: "));console.log(await zs(i)?"Apple accepted the key.":"Not on macOS, so the key is checked at the first release instead."),await Ls(e,i),console.log(`Notarization key stored. You may delete ${t} once you keep a backup.`)}var pl={name:"tapster main",target:"branch",enforcement:"active",bypass_actors:[],conditions:{ref_name:{include:["~DEFAULT_BRANCH"],exclude:[]}},rules:[{type:"deletion"},{type:"non_fast_forward"}]};async function fl(e,t,n){try{await e.json("PUT",`/repos/${t}/environments/tapster`,{deployment_branch_policy:{protected_branches:!1,custom_branch_policies:!0}})}catch(s){throw YO(s,n)}let r=await e.json("GET",`/repos/${t}/environments/tapster/deployment-branch-policies`);for(let s of r.branch_policies.filter((o)=>o.name!=="main"))await e.json("DELETE",`/repos/${t}/environments/tapster/deployment-branch-policies/${s.id}`);if(!r.branch_policies.some((s)=>s.name==="main"))await e.json("POST",`/repos/${t}/environments/tapster/deployment-branch-policies`,{name:"main",type:"branch"});await e.json("PUT",`/repos/${t}/actions/permissions/workflow`,{default_workflow_permissions:"read",can_approve_pull_request_reviews:!1}),await e.json("PUT",`/repos/${t}/actions/permissions`,{enabled:!0,allowed_actions:"selected",sha_pinning_required:!0}),await e.json("PUT",`/repos/${t}/actions/permissions/selected-actions`,{github_owned_allowed:!0,verified_allowed:!1,patterns_allowed:["doguyilmaz/tapster@*"]});let i=(await e.json("GET",`/repos/${t}/rulesets`)).find((s)=>s.name===pl.name);if(i)await e.json("PUT",`/repos/${t}/rulesets/${i.id}`,pl);else await e.json("POST",`/repos/${t}/rulesets`,pl)}function Rr(e,t){let n=Oe(e,"tapster.yml");if(!bn(n))throw new v("tapster.yml is missing","Run tapster init in the hub first.");let{config:r,invalid:i}=ie(Ir(n,"utf8"),t.split("/")[0]);for(let s of i)console.log(`note: ${s.name} in tapster.yml is invalid and left out: ${s.reason}`);return r}async function XO(e,t,n,r,i){let s=bn(Oe(t,J))?Ir(Oe(t,J),"utf8"):null,o=await tl(e,s,n,r,i);await Yv(Oe(t,".github/workflows"),{recursive:!0}),await dl(Oe(t,J),o.file.content),console.log(`wrote ${J} from the template, ${o.change}; hand edits in it are replaced`);for(let a of o.notes)console.log(a)}async function Xv(e,t){let n=Oe(e,J);if(!bn(n))throw new v(`${J} is missing`,"Run tapster init --workflow first.");await dl(n,xs(Ir(n,"utf8"),t)),console.log(`updated the sparkle step in ${J}`)}async function e2(e,t,n,r,i){if(!/^[a-z0-9]+$/.test(r))throw new v(`${r} is not a valid label`,"Use lowercase letters and digits, as in sparkle.key.");let s=Rr(t,n);console.log("macOS asks whether tapster may read the Sparkle key from your keychain; choose Allow.");let o=await Pe("security",["find-generic-password","-s","https://sparkle-project.org","-a",i,"-w"],{allowFail:!0});if(o.code!==0)throw new v(`the login keychain has no Sparkle key for the account ${i}`,"Pass the account generate_keys used with --account (ed25519 by default).");let a=o.stdout.trim(),c=Es(a),l=hl(s,r,c.publicKey);console.log(`The key ${c.publicKey} signs updates for ${l.join(", ")}.`),console.log("If it is lost, installed copies can never update again; if it leaks, anyone can sign updates for them.");let u=await me("Do you keep an offline backup of this key? Type yes to store it in the hub: ");if(!Jv(u))throw new v("no offline backup confirmed","Back the key up first (generate_keys -x exports it), then run this again.");await ee(n,`SPARKLE_KEY_${r.toUpperCase()}`,a),console.log(`Stored SPARKLE_KEY_${r.toUpperCase()}.`),await Xv(t,Ee(s)),console.log("Review and commit the workflow change, then push.")}async function t2(e,t,n){if(!/^[a-z0-9]+$/.test(n))throw new v(`${n} is not a valid label`,"Use lowercase letters and digits, as in sparkle.key.");let r=Rr(e,t),i=r.packages.filter(Y).filter((c)=>c.sparkle?.key===n||c.sparkle?.next_key===n);if(i.length)throw new v(`${i.map((c)=>c.name).join(", ")} already sign with the Sparkle key ${n}`,"A new key needs a new label. To change an app's key, follow Rotate a Sparkle key in the tapster docs (Mac apps with Sparkle).");let s=Or("the Sparkle key"),o={service:"https://sparkle-project.org",account:n,label:"Private key for signing Sparkle updates"};if(await s.exists(o))throw new v(`your keychain already has a Sparkle key for the account ${n}`,`Store that one with tapster init --sparkle ${n} --account ${n} or pick another label.`);let a=Mv();if(await s.save({...o,comment:`Public key (SUPublicEDKey value) for this key is: ${a.publicKey}`},a.seed),console.log(`Saved a new Sparkle key in your ${s.kind==="keychain"?"login keychain":"keyring"} under the account ${n}. Sparkle's own tools find it there. macOS asks you before any app reads it.`),console.log(`Its public key is ${a.publicKey}. Put it in the app as SUPublicEDKey and in tapster.yml as sparkle.public_key.`),console.log("If this key is lost, installed copies can never update again. Keep an offline copy too, for example in your password manager:"),console.log(s.kind==="keychain"?` security find-generic-password -s https://sparkle-project.org -a ${n} -w (macOS asks you first)`:` secret-tool lookup service https://sparkle-project.org account ${n}`),!Jv(await me("Type yes once you keep an offline copy, to store the key in the hub: "))){console.log(`Not stored in the hub yet. Once you keep a copy, run tapster init --sparkle ${n} --account ${n}.`);return}await ee(t,`SPARKLE_KEY_${n.toUpperCase()}`,a.seed),console.log(`Stored SPARKLE_KEY_${n.toUpperCase()} in the hub.`),await Xv(e,[...new Set([...Ee(r),n])]),console.log("Review and commit the workflow change, then push.")}async function Fv(e,t,n){let r={...t,account:`${t.account} pending`,label:`${t.label} (pending)`};await e.remove(r),await e.save(r,n),await e.remove(t),await e.save(t,n),await e.remove(r)}var Cr=(e,t=!1)=>({service:"tapster-linux-key",account:t?`${e} previous`:e,label:`tapster Linux key for ${e}${t?" (previous)":""}`});async function n2(e,t){let n=(await Gt(e,t,"secrets")).map((r)=>r.name);if(await ul()?.remove(Cr(t,!0)),!n.includes("TAPSTER_LINUX_KEY_PREVIOUS")){console.log("No Linux key rotation is running, so there is nothing to finish.");return}await Wg(t,"TAPSTER_LINUX_KEY_PREVIOUS"),console.log("The previous Linux key no longer signs; apt and dnf trust only the new one from the next run.")}function r2(e,t){if(e.includes("TAPSTER_LINUX_KEY")&&!t)throw new v("the hub already has a Linux signing key","Replacing it makes every apt and dnf user fetch the new key. To do that, run tapster init --rotate linux.")}async function Kv(e,t,n,r){let i=Rr(t,n),s=(await Gt(e,n,"secrets")).map((u)=>u.name);r2(s,r);let o=Or("the Linux signing key"),a=["/opt/homebrew/bin/gpg","/usr/local/bin/gpg","/usr/bin/gpg"].find((u)=>bn(u));if(!a)throw new v("gpg is not installed","Install it with brew install gnupg, then run this again.");await e.json("POST",`/repos/${n}/pages`,{build_type:"workflow"}).catch(async(u)=>{if(!(u instanceof R)||u.status!==409)throw new v("GitHub Pages could not be turned on for the hub","A private hub needs a paid plan for Pages; make the hub public or turn Pages on by hand with GitHub Actions as the source.");await e.json("PUT",`/repos/${n}/pages`,{build_type:"workflow"})}),console.log("GitHub Pages serves the hub from GitHub Actions.");let c=$t("tl-"),l={GNUPGHOME:c};try{await D(a,"gpg",["--batch","--pinentry-mode","loopback","--passphrase","","--quick-gen-key",`${n.split("/")[0]} tapster (${n})`,"rsa4096","sign","never"],{env:l});let u=(await D(a,"gpg",["--batch","--armor","--export-secret-keys"],{env:l})).stdout,p=(await D(a,"gpg",["--batch","--with-colons","--list-secret-keys"],{env:l})).stdout.split(`
1099
+ `).find((f)=>f.startsWith("fpr:"))?.split(":")[9],d=null;if(r){if(o.kind==="keychain")console.log("macOS asks whether tapster may read the previous key from your keychain; choose Allow.");d=await Gv(o,Cr(n))}let h={...Cr(n),account:`${n} new`,label:`tapster Linux key for ${n} (new)`};if(await o.remove(h),await o.save(h,u),await ee(n,"TAPSTER_LINUX_KEY",u),d)await ee(n,"TAPSTER_LINUX_KEY_PREVIOUS",d);if(d)await Fv(o,Cr(n,!0),d);if(await Fv(o,Cr(n),u),await o.remove(h),console.log(`Stored the Linux key (fingerprint ${p}) in the hub and in your ${o.kind==="keychain"?"login keychain":"keyring"} as "tapster-linux-key".`),d)console.log("The previous key keeps signing next to the new one, so apt and dnf users can fetch the new key. Once they have, run tapster init --rotate linux --finish.");else if(r)console.log("The previous key is not in your keychain, so apt and dnf users must fetch the new key before they can update.")}finally{await D(Oe(a,"..","gpgconf"),"gpgconf",["--kill","all"],{env:l,allowFail:!0}).catch(()=>{return}),Fe(c)}if(!i.packages.some((u)=>!Y(u)&&u.linux))console.log("No package sets linux: true yet; add it to the CLI packages that should ship to apt and dnf.")}async function i2(e,t,n,r,i){let o=await As(e,n,async(a)=>bn(Oe(t,a))?Ir(Oe(t,a),"utf8"):null,r,i);for(let a of o.files)await Yv(Oe(t,a.path,".."),{recursive:!0}),await dl(Oe(t,a.path),a.content),console.log(a.path===J?`wrote ${J} from the template, ${o.change}; hand edits in it are replaced`:`wrote ${a.path}`);for(let a of o.notes)console.log(a)}async function s2(e){let t=(await me(e)).toLowerCase();return t===""||t==="y"||t==="yes"}async function o2(e,t){let n=async(r)=>{try{return((await e.json("GET",`/repos/${t}/environments/tapster/${r}?per_page=100`))[r]??[]).map((s)=>s.name)}catch(i){if(i instanceof R&&i.status===404)return[];throw i}};return{vars:await n("variables"),secrets:await n("secrets"),private:(await e.getRepo(t)).private}}function Wv(e,t){let n=e.indexOf(t);if(n<0)return{value:null,rest:e};return{value:e[n+1]??"",rest:e.filter((r,i)=>i!==n&&i!==n+1)}}var a2="Run tapster init --help for the options.";function c2(e){let[t,n,r,i]=e;if(e.length===0)return{kind:"setup"};if(t==="--rotate"&&e.length===2&&["app","certificate","notary","doorbell","linux"].includes(n??""))return{kind:"rotate",what:n};if(t==="--rotate"&&n==="linux"&&r==="--finish"&&e.length===3)return{kind:"rotate",what:"linux-finish"};if(t==="--doorbell"&&e.length===1)return{kind:"doorbell"};if(t==="--linux"&&e.length===1)return{kind:"linux"};if(t==="--workflow"&&e.length===1)return{kind:"workflow"};if(t==="--sparkle"&&n&&!n.startsWith("-")){if(e.length===2)return{kind:"sparkle",label:n,account:"ed25519"};if(r==="--new"&&e.length===3)return{kind:"sparkle-new",label:n};if(r==="--account"&&i&&e.length===4)return{kind:"sparkle",label:n,account:i}}throw new v(`unknown option ${e.join(" ")}`,a2)}function Vv(e){let t=Oe(e,J);return bn(t)&&rt(Ir(t,"utf8"))||10}async function ey(e){let t=Wv(e,"--tapster"),n=Wv(t.rest,"--every"),r=t.value,i=n.value===null?null:Number(n.value),s=c2(n.rest);if(i!==null)gs(i);if((r!==null||i!==null)&&s.kind!=="setup"&&s.kind!=="workflow")throw new v("--tapster and --every go only with tapster init or init --workflow","Those are the commands that write the workflow.");let o=process.cwd(),a=await He(o),c=await At();if(s.kind==="rotate"){if(s.what==="app")return qv(c,a);if(s.what==="certificate")return Bv(a);if(s.what==="notary")return Hv(a);if(s.what==="doorbell")return cv(c,a,Vv(o));if(s.what==="linux-finish")return n2(c,a);return Kv(c,o,a,!0)}if(s.kind==="doorbell")return av(c,a,Rr(o,a),hs,Vv(o));if(s.kind==="linux")return Kv(c,o,a,!1);if(s.kind==="sparkle-new")return t2(o,a,s.label);if(s.kind==="sparkle")return e2(c,o,a,s.label,s.account);if(s.kind==="workflow")return XO(c,o,Ee(Rr(o,a)),r,{every:i,isPrivate:(await c.getRepo(a)).private});let l=await o2(c,a);await fl(c,a,l.private);let p=l.vars.includes("TAPSTER_TEAM_ID")||l.secrets.includes("MACOS_NOTARY_KEY")||await s2("Will this hub sign software for macOS (Mac apps or CLI tools with macOS builds)? [Y/n] "),d=WO(l,p),h=VO(d,p);if(h.length)console.log(`Already done: ${h.join(", ")}. To redo one, run tapster init --rotate <name>.`);for(let f of d){if(f==="app")await JO(a.split("/")[0],a);if(f==="app-key")await qv(c,a);if(f==="certificate")await Bv(a);if(f==="notary")await Hv(a);if(f==="files")await i2(c,o,a,r,{every:i,isPrivate:l.private})}if(!p)console.log("Skipped the Apple credentials. Add them later with tapster init --rotate certificate and tapster init --rotate notary.");console.log(`
1100
1100
  Done. Review and commit the new files, push, then run tapster add in each project.`)}import{homedir as Q2}from"os";import{randomBytes as y2}from"crypto";var l2=/^(\.tapster|Casks|bucket)\//;async function ml(e,t,n){let r=encodeURIComponent("refs/heads/main"),[i]=await e.json("GET",`/repos/${t}/activity?ref=${r}&actor=${n}&per_page=1`);if(!i)return[`GitHub shows no push by ${n} to main`];let s=i.after.slice(0,7),o=(await e.json("GET",`/repos/${t}/git/ref/heads/main`)).object.sha,a=await e.json("GET",`/repos/${t}/compare/${i.after}...${o}`);if(a.status==="identical")return[];if(a.status!=="ahead")return[`main no longer contains your last push (${s})`];let c=a.files??[];if(c.length>=300)return[`more files changed after your last push (${s}) than GitHub lists`];return c.filter((l)=>!l2.test(l.filename)).map((l)=>`${l.filename} changed after your last push (${s})`)}import{randomBytes as gl}from"crypto";var ty=async()=>'var Ge,S,qt,ft,re,Gt,Kt,Yt,pt,Ve,Se,Jt,mt,dt,ht,Zn,Fe={},Le=[],Qn=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,Ue=Array.isArray;function te(e,n){for(var s in n)e[s]=n[s];return e}function vt(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function es(e,n,s){var o,i,a,r={};for(a in n)a=="key"?o=n[a]:a=="ref"?i=n[a]:r[a]=n[a];if(arguments.length>2&&(r.children=arguments.length>3?Ge.call(arguments,2):s),typeof e=="function"&&e.defaultProps!=null)for(a in e.defaultProps)r[a]===void 0&&(r[a]=e.defaultProps[a]);return je(e,r,o,i,null)}function je(e,n,s,o,i){var a={type:e,props:n,key:s,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i==null?++qt:i,__i:-1,__u:0};return i==null&&S.vnode!=null&&S.vnode(a),a}function C(e){return e.children}function me(e,n){this.props=e,this.context=n}function ue(e,n){if(n==null)return e.__?ue(e.__,e.__i+1):null;for(var s;n<e.__k.length;n++)if((s=e.__k[n])!=null&&s.__e!=null)return s.__e;return typeof e.type=="function"?ue(e):null}function ts(e){if(e.__P&&e.__d){var n=e.__v,s=n.__e,o=[],i=[],a=te({},n);a.__v=n.__v+1,S.vnode&&S.vnode(a),bt(e.__P,a,n,e.__n,e.__P.namespaceURI,32&n.__u?[s]:null,o,s==null?ue(n):s,!!(32&n.__u),i),a.__v=n.__v,a.__.__k[a.__i]=a,tn(o,a,i),n.__e=n.__=null,a.__e!=s&&Xt(a)}}function Xt(e){if((e=e.__)!=null&&e.__c!=null)return e.__e=e.__c.base=null,e.__k.some(function(n){if(n!=null&&n.__e!=null)return e.__e=e.__c.base=n.__e}),Xt(e)}function Ut(e){(!e.__d&&(e.__d=!0)&&re.push(e)&&!Be.__r++||Gt!=S.debounceRendering)&&((Gt=S.debounceRendering)||Kt)(Be)}function Be(){try{for(var e,n=1;re.length;)re.length>n&&re.sort(Yt),e=re.shift(),n=re.length,ts(e)}finally{re.length=Be.__r=0}}function Zt(e,n,s,o,i,a,r,c,p,u,h){var f,l,d,_,T,g,k=o&&o.__k||Le,y=n.length;for(p=ns(s,n,k,p,y),f=0;f<y;f++)(d=s.__k[f])!=null&&(l=d.__i!=-1&&k[d.__i]||Fe,d.__i=f,g=bt(e,d,l,i,a,r,c,p,u,h),_=d.__e,d.ref&&l.ref!=d.ref&&(l.ref&&yt(l.ref,null,d),h.push(d.ref,d.__c||_,d)),T==null&&_!=null&&(T=_),4&d.__u?(p=Qt(d,p,e),l.__e&&(l.__e=null)):typeof d.type=="function"&&g!==void 0?p=g:_&&(p=_.nextSibling),d.__u&=-7);return s.__e=T,p}function ns(e,n,s,o,i){var a,r,c,p,u,h=s.length,f=h,l=0;for(e.__k=Array(i),a=0;a<i;a++)(r=n[a])!=null&&typeof r!="boolean"&&typeof r!="function"?(typeof r=="string"||typeof r=="number"||typeof r=="bigint"||r.constructor==String?r=e.__k[a]=je(null,r,null,null,null):Ue(r)?r=e.__k[a]=je(C,{children:r},null,null,null):r.constructor===void 0&&r.__b>0?r=e.__k[a]=je(r.type,r.props,r.key,r.ref?r.ref:null,r.__v):e.__k[a]=r,p=a+l,r.__=e,r.__b=e.__b+1,c=null,(u=r.__i=ss(r,s,p,f))!=-1&&(f--,(c=s[u])&&(c.__u|=2)),c==null||c.__v==null?(u==-1&&(i>h?l--:i<h&&l++),typeof r.type!="function"&&(r.__u|=4)):u!=p&&(u==p-1?l--:u==p+1?l++:(u>p?l--:l++,r.__u|=4))):e.__k[a]=null;if(f)for(a=0;a<h;a++)(c=s[a])!=null&&(2&c.__u)==0&&(c.__e==o&&(o=ue(c)),sn(c,c));return o}function Qt(e,n,s){var o,i;if(typeof e.type=="function"){for(o=e.__k,i=0;o&&i<o.length;i++)o[i]&&(o[i].__=e,n=Qt(o[i],n,s));return n}e.__e!=n&&(n&&e.type&&!n.parentNode&&(n=ue(e)),n=s.insertBefore(e.__e,n||null));do n=n&&n.nextSibling;while(n!=null&&n.nodeType==8);return n}function ss(e,n,s,o){var i,a,r,{key:c,type:p}=e,u=n[s],h=u!=null&&(2&u.__u)==0;if(u===null&&c==null||h&&c==u.key&&p==u.type)return s;if(o>(h?1:0)){for(i=s-1,a=s+1;i>=0||a<n.length;)if((u=n[r=i>=0?i--:a++])!=null&&(2&u.__u)==0&&c==u.key&&p==u.type)return r}return-1}function Wt(e,n,s){n[0]=="-"?e.setProperty(n,s==null?"":s):e[n]=s==null?"":typeof s!="number"||Qn.test(n)?s:s+"px"}function Re(e,n,s,o,i){var a,r;e:if(n=="style")if(typeof s=="string")e.style.cssText=s;else{if(typeof o=="string"&&(e.style.cssText=o=""),o)for(n in o)s&&n in s||Wt(e.style,n,"");if(s)for(n in s)o&&s[n]==o[n]||Wt(e.style,n,s[n])}else if(n[0]=="o"&&n[1]=="n")a=n!=(n=n.replace(Jt,"$1")),r=n.toLowerCase(),n=r in e||n=="onFocusOut"||n=="onFocusIn"?r.slice(2):n.slice(2),e.l||(e.l={}),e.l[n+a]=s,s?o?s[Se]=o[Se]:(s[Se]=mt,e.addEventListener(n,a?ht:dt,a)):e.removeEventListener(n,a?ht:dt,a);else{if(i=="http://www.w3.org/2000/svg")n=n.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(n!="width"&&n!="height"&&n!="href"&&n!="list"&&n!="form"&&n!="tabIndex"&&n!="download"&&n!="rowSpan"&&n!="colSpan"&&n!="role"&&n!="popover"&&n in e)try{e[n]=s==null?"":s;break e}catch(c){}typeof s=="function"||(s==null||s===!1&&n[4]!="-"?e.removeAttribute(n):e.setAttribute(n,n=="popover"&&s==1?"":s))}}function zt(e){return function(n){if(this.l){var s=this.l[n.type+e];if(n[Ve]==null)n[Ve]=mt++;else if(n[Ve]<s[Se])return;return s(S.event?S.event(n):n)}}}function bt(e,n,s,o,i,a,r,c,p,u){var h,f,l,d,_,T,g,k,y,H,b,w,B,ee,ae,xe,K=n.type;if(n.constructor!==void 0)return null;128&s.__u&&(p=!!(32&s.__u),a=[c=n.__e=s.__e]),(h=S.__b)&&h(n);e:if(typeof K=="function"){f=r.length;try{if(y=n.props,H=K.prototype&&K.prototype.render,b=(h=K.contextType)&&o[h.__c],w=h?b?b.props.value:h.__:o,s.__c?k=(l=n.__c=s.__c).__=l.__E:(H?n.__c=l=new K(y,w):(n.__c=l=new me(y,w),l.constructor=K,l.render=as),b&&b.sub(l),l.state||(l.state={}),l.__n=o,d=l.__d=!0,l.__h=[],l._sb=[]),H&&l.__s==null&&(l.__s=l.state),H&&K.getDerivedStateFromProps!=null&&(l.__s==l.state&&(l.__s=te({},l.__s)),te(l.__s,K.getDerivedStateFromProps(y,l.__s))),_=l.props,T=l.state,l.__v=n,d)H&&K.getDerivedStateFromProps==null&&l.componentWillMount!=null&&l.componentWillMount(),H&&l.componentDidMount!=null&&l.__h.push(l.componentDidMount);else{if(H&&K.getDerivedStateFromProps==null&&y!==_&&l.componentWillReceiveProps!=null&&l.componentWillReceiveProps(y,w),n.__v==s.__v||!l.__e&&l.shouldComponentUpdate!=null&&l.shouldComponentUpdate(y,l.__s,w)===!1){n.__v!=s.__v&&(l.props=y,l.state=l.__s,l.__d=!1),n.__e=s.__e,n.__k=s.__k,n.__k.some(function(X){X&&(X.__=n)}),Le.push.apply(l.__h,l._sb),l._sb=[],l.__h.length&&r.push(l),c=ue(s);break e}l.componentWillUpdate!=null&&l.componentWillUpdate(y,l.__s,w),H&&l.componentDidUpdate!=null&&l.__h.push(function(){l.componentDidUpdate(_,T,g)})}if(l.context=w,l.props=y,l.__P=e,l.__e=!1,B=S.__r,ee=0,H)l.state=l.__s,l.__d=!1,B&&B(n),h=l.render(l.props,l.state,l.context),Le.push.apply(l.__h,l._sb),l._sb=[];else do l.__d=!1,B&&B(n),h=l.render(l.props,l.state,l.context),l.state=l.__s;while(l.__d&&++ee<25);l.state=l.__s,l.getChildContext!=null&&(o=te(te({},o),l.getChildContext())),H&&!d&&l.getSnapshotBeforeUpdate!=null&&(g=l.getSnapshotBeforeUpdate(_,T)),ae=h!=null&&h.type===C&&h.key==null?nn(h.props.children):h,c=Zt(e,Ue(ae)?ae:[ae],n,s,o,i,a,r,c,p,u),l.base=n.__e,n.__u&=-161,l.__h.length&&r.push(l),k&&(l.__E=l.__=null)}catch(X){if(r.length=f,n.__v=null,p||a!=null){if(X.then){for(n.__u|=p?160:128;c&&c.nodeType==8&&c.nextSibling;)c=c.nextSibling;a!=null&&(a[a.indexOf(c)]=null),n.__e=c}else if(a!=null)for(xe=a.length;xe--;)vt(a[xe])}else n.__e=s.__e;n.__k==null&&(n.__k=s.__k||[]),X.then||en(n),S.__e(X,n,s)}}else a==null&&n.__v==s.__v?(n.__k=s.__k,n.__e=s.__e):c=n.__e=os(s.__e,n,s,o,i,a,r,p,u);return(h=S.diffed)&&h(n),128&n.__u?void 0:c}function en(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(en))}function tn(e,n,s){for(var o=0;o<s.length;o++)yt(s[o],s[++o],s[++o]);S.__c&&S.__c(n,e),e.some(function(i){try{e=i.__h,i.__h=[],e.some(function(a){a.call(i)})}catch(a){S.__e(a,i.__v)}})}function nn(e){return typeof e!="object"||e==null||e.__b>0?e:Ue(e)?e.map(nn):e.constructor!==void 0?null:te({},e)}function os(e,n,s,o,i,a,r,c,p){var u,h,f,l,d,_,T,g=s.props||Fe,{props:k,type:y}=n;if(y=="svg"?i="http://www.w3.org/2000/svg":y=="math"?i="http://www.w3.org/1998/Math/MathML":i||(i="http://www.w3.org/1999/xhtml"),a!=null){for(u=0;u<a.length;u++)if((d=a[u])&&"setAttribute"in d==!!y&&(y?d.localName==y:d.nodeType==3)){e=d,a[u]=null;break}}if(e==null){if(y==null)return document.createTextNode(k);e=document.createElementNS(i,y,k.is&&k),c&&(S.__m&&S.__m(n,a),c=!1),a=null}if(y==null)g===k||c&&e.data==k||(e.data=k);else{if(a=y=="textarea"&&k.defaultValue!=null?null:a&&Ge.call(e.childNodes),!c&&a!=null)for(g={},u=0;u<e.attributes.length;u++)g[(d=e.attributes[u]).name]=d.value;for(u in g)d=g[u],u=="dangerouslySetInnerHTML"?f=d:u=="children"||(u in k)||u=="value"&&("defaultValue"in k)||u=="checked"&&("defaultChecked"in k)||Re(e,u,null,d,i);for(u in k)d=k[u],u=="children"?l=d:u=="dangerouslySetInnerHTML"?h=d:u=="value"?_=d:u=="checked"?T=d:c&&typeof d!="function"||g[u]===d||Re(e,u,d,g[u],i);if(h)c||f&&(h.__html==f.__html||h.__html==e.innerHTML)||(e.innerHTML=h.__html),n.__k=[];else if(f&&(e.innerHTML=""),Zt(n.type=="template"?e.content:e,Ue(l)?l:[l],n,s,o,y=="foreignObject"?"http://www.w3.org/1999/xhtml":i,a,r,a?a[0]:s.__k&&ue(s,0),c,p),a!=null)for(u=a.length;u--;)vt(a[u]);c&&y!="textarea"||(u="value",y=="progress"&&_==null?e.removeAttribute("value"):_!=null&&(_!==e[u]||y=="progress"&&!_||y=="option"&&_!=g[u])&&Re(e,u,_,g[u],i),u="checked",T!=null&&T!=e[u]&&Re(e,u,T,g[u],i))}return e}function yt(e,n,s){try{if(typeof e=="function"){var o=typeof e.__u=="function";o&&e.__u(),o&&n==null||(e.__u=e(n))}else e.current=n}catch(i){S.__e(i,s)}}function sn(e,n,s){var o,i;if(S.unmount&&S.unmount(e),(o=e.ref)&&(o.current&&o.current!=e.__e||yt(o,null,n)),(o=e.__c)!=null){if(o.componentWillUnmount)try{o.componentWillUnmount()}catch(a){S.__e(a,n)}o.base=o.__P=o.__n=null}if(o=e.__k)for(i=0;i<o.length;i++)o[i]&&sn(o[i],n,s||typeof e.type!="function");s||vt(e.__e),e.__c=e.__=e.__e=void 0}function as(e,n,s){return this.constructor(e,s)}function on(e,n,s){var o,i,a,r;n==document&&(n=document.documentElement),S.__&&S.__(e,n),i=(o=typeof s=="function")?null:s&&s.__k||n.__k,a=[],r=[],bt(n,e=(!o&&s||n).__k=es(C,null,[e]),i||Fe,Fe,n.namespaceURI,!o&&s?[s]:i?null:n.firstChild?Ge.call(n.childNodes):null,a,!o&&s?s:i?i.__e:n.firstChild,o,r),tn(a,e,r),e.props.children=null}Ge=Le.slice,S={__e:function(e,n,s,o){for(var i,a,r;n=n.__;)if((i=n.__c)&&!i.__)try{if((a=i.constructor)&&a.getDerivedStateFromError!=null&&(i.setState(a.getDerivedStateFromError(e)),r=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(e,o||{}),r=i.__d),r)return i.__E=i}catch(c){e=c}throw e}},qt=0,ft=function(e){return e!=null&&e.constructor===void 0},me.prototype.setState=function(e,n){var s;s=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=te({},this.state),typeof e=="function"&&(e=e(te({},s),this.props)),e&&te(s,e),e!=null&&this.__v&&(n&&this._sb.push(n),Ut(this))},me.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),Ut(this))},me.prototype.render=C,re=[],Kt=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,Yt=function(e,n){return e.__v.__b-n.__v.__b},Be.__r=0,pt=Math.random().toString(8),Ve="__d"+pt,Se="__a"+pt,Jt=/(PointerCapture)$|Capture$/i,mt=0,dt=zt(!1),ht=zt(!0),Zn=0;var Ce,I,_t,an,ze=0,fn=[],M=S,{__b:rn,__r:ln,diffed:cn,__c:un,unmount:pn,__:dn}=M;function wt(e,n){M.__h&&M.__h(I,e,ze||n),ze=0;var s=I.__H||(I.__H={__:[],__h:[]});return e>=s.__.length&&s.__.push({}),s.__[e]}function m(e){return ze=1,is(vn,e)}function is(e,n,s){var o=wt(Ce++,2);if(o.t=e,!o.__c&&(o.__=[s?s(n):vn(void 0,n),function(c){var p=o.__N?o.__N[0]:o.__[0],u=o.t(p,c);p!==u&&(o.__N=[u,o.__[1]],o.__c.setState({}))}],o.__c=I,!I.__f)){var i=function(c,p,u){if(!o.__c.__H)return!0;var h=!1,f=o.__c.props!==c;if(o.__c.__H.__.some(function(d){if(d.__N){h=!0;var _=d.__[0];d.__=d.__N,d.__N=void 0,_!==d.__[0]&&(f=!0)}}),a){var l=a.call(this,c,p,u);return h?l||f:l}return!h||f};I.__f=!0;var a=I.shouldComponentUpdate,r=I.componentWillUpdate;I.componentWillUpdate=function(c,p,u){if(this.__e){var h=a;a=void 0,i(c,p,u),a=h}r&&r.call(this,c,p,u)},I.shouldComponentUpdate=i}return o.__N||o.__}function U(e,n){var s=wt(Ce++,3);!M.__s&&mn(s.__H,n)&&(s.__=e,s.u=n,I.__H.__h.push(s))}function Te(e){return ze=5,qe(function(){return{current:e}},[])}function qe(e,n){var s=wt(Ce++,7);return mn(s.__H,n)&&(s.__=e(),s.__H=n,s.__h=e),s.__}function rs(){for(var e;e=fn.shift();){var n=e.__H;if(e.__P&&n)try{n.__h.some(We),n.__h.some(gt),n.__h=[]}catch(s){n.__h=[],M.__e(s,e.__v)}}}M.__b=function(e){I=null,rn&&rn(e)},M.__=function(e,n){e&&n.__k&&n.__k.__m&&(e.__m=n.__k.__m),dn&&dn(e,n)},M.__r=function(e){ln&&ln(e),Ce=0;var n=(I=e.__c).__H;n&&(_t===I?(n.__h=[],I.__h=[],n.__.some(function(s){s.__N&&(s.__=s.__N),s.u=s.__N=void 0})):(n.__h.some(We),n.__h.some(gt),n.__h=[],Ce=0)),_t=I},M.diffed=function(e){cn&&cn(e);var n=e.__c;n&&n.__H&&(n.__H.__h.length&&(fn.push(n)!==1&&an===M.requestAnimationFrame||((an=M.requestAnimationFrame)||ls)(rs)),n.__H.__.some(function(s){s.u&&(s.__H=s.u,s.u=void 0)})),_t=I=null},M.__c=function(e,n){n.some(function(s){try{s.__h.some(We),s.__h=s.__h.filter(function(o){return!o.__||gt(o)})}catch(o){n.some(function(i){i.__h&&(i.__h=[])}),n=[],M.__e(o,s.__v)}}),un&&un(e,n)},M.unmount=function(e){pn&&pn(e);var n,s=e.__c;s&&s.__H&&(s.__H.__.some(function(o){try{We(o)}catch(i){n=i}}),s.__H=void 0,n&&M.__e(n,s.__v))};var hn=typeof requestAnimationFrame=="function";function ls(e){var n,s=function(){clearTimeout(o),hn&&cancelAnimationFrame(n),setTimeout(e)},o=setTimeout(s,35);hn&&(n=requestAnimationFrame(s))}function We(e){var n=I,s=e.__c;typeof s=="function"&&(e.__c=void 0,s()),I=n}function gt(e){var n=I;e.__c=e.__(),I=n}function mn(e,n){return!e||e.length!==n.length||n.some(function(s,o){return s!==e[o]})}function vn(e,n){return typeof n=="function"?n(e):n}var cs=Symbol.for("preact-signals");function Xe(){if(!(ne>1)){var e,n=!1;(function(){var i=Ye;Ye=void 0;while(i!==void 0){var a=i.S;if(a.v===i.v){for(var r=a.t;r!==void 0;r=r.x)if(r.i===i.i)r.i=a.i}i=i.o}})();while(He!==void 0){var s=He;He=void 0,Ke++;while(s!==void 0){var o=s.u;if(s.u=void 0,s.f&=-3,!(8&s.f)&&yn(s))try{s.c()}catch(i){if(!n)e=i,n=!0}s=o}}if(Ke=0,ne--,n)throw e}else ne--}function xt(e){if(ne>0)return e();kt=++us,ne++;try{return e()}finally{Xe()}}var Ae,P=void 0;function Pe(e){var n=P,s=Ae;P=void 0,Ae=void 0;try{return e()}finally{P=n,Ae=s}}var He=void 0,ne=0,Ke=0,us=0,kt=0,Ye=void 0,Je=0;function bn(e){if(P!==void 0){var n=e.n;if(n===void 0||n.t!==P){if(n={i:0,S:e,p:P.s,n:void 0,t:P,e:void 0,x:void 0,r:n},P.s!==void 0)P.s.n=n;if(P.s=n,e.n=n,32&P.f)e.S(n);return n}else if(n.i===-1){if(n.i=0,n.n!==void 0){if(n.n.p=n.p,n.p!==void 0)n.p.n=n.n;n.p=P.s,n.n=void 0,P.s.n=n,P.s=n}return n}}}function O(e,n){this.v=e,this.i=0,this.n=void 0,this.t=void 0,this.l=0,this.W=n==null?void 0:n.watched,this.Z=n==null?void 0:n.unwatched,this.name=n==null?void 0:n.name}O.prototype.brand=cs;O.prototype.h=function(){return!0};O.prototype.S=function(e){var n=this,s=this.t;if(s!==e&&e.e===void 0)if(e.x=s,this.t=e,s!==void 0)s.e=e;else Pe(function(){var o;(o=n.W)==null||o.call(n)})};O.prototype.U=function(e){var n=this;if(this.t!==void 0){var{e:s,x:o}=e;if(s!==void 0)s.x=o,e.e=void 0;if(o!==void 0)o.e=s,e.x=void 0;if(e===this.t){if(this.t=o,o===void 0)Pe(function(){var i;(i=n.Z)==null||i.call(n)})}}};O.prototype.subscribe=function(e){var n=this;return de(function(){var s=n.value;Pe(function(){return e(s)})},{name:"sub"})};O.prototype.valueOf=function(){return this.value};O.prototype.toString=function(){return this.value+""};O.prototype.toJSON=function(){return this.value};O.prototype.peek=function(){var e=this;return Pe(function(){return e.value})};Object.defineProperty(O.prototype,"value",{get:function(){var e=bn(this);if(e!==void 0)e.i=this.i;return this.v},set:function(e){if(e!==this.v){if(Ke>100)throw Error("Cycle detected");(function(s){if(ne!==0&&Ke===0){if(s.l!==kt)s.l=kt,Ye={S:s,v:s.v,i:s.i,o:Ye}}})(this),this.v=e,this.i++,Je++,ne++;try{for(var n=this.t;n!==void 0;n=n.x)n.t.N()}finally{Xe()}}}});function E(e,n){return new O(e,n)}function yn(e){for(var n=e.s;n!==void 0;n=n.n)if(n.S.i!==n.i||!n.S.h()||n.S.i!==n.i)return!0;return!1}function _n(e){for(var n=e.s;n!==void 0;n=n.n){var s=n.S.n;if(s!==void 0)n.r=s;if(n.S.n=n,n.i=-1,n.n===void 0){e.s=n;break}}}function gn(e){var n=e.s,s=void 0;while(n!==void 0){var o=n.p;if(n.i===-1){if(n.S.U(n),o!==void 0)o.n=n.n;if(n.n!==void 0)n.n.p=o}else s=n;if(n.S.n=n.r,n.r!==void 0)n.r=void 0;n=o}e.s=s}function pe(e,n){O.call(this,void 0,n),this.x=e,this.s=void 0,this.g=Je-1,this.f=4}pe.prototype=new O;pe.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32)return!0;if(this.f&=-5,this.g===Je)return!0;if(this.g=Je,this.f|=1,this.i>0&&!yn(this))return this.f&=-2,!0;var e=P;try{_n(this),P=this;var n=this.x();if(16&this.f||this.v!==n||this.i===0)this.v=n,this.f&=-17,this.i++}catch(s){this.v=s,this.f|=16,this.i++}return P=e,gn(this),this.f&=-2,!0};pe.prototype.S=function(e){if(this.t===void 0){this.f|=36;for(var n=this.s;n!==void 0;n=n.n)n.S.S(n)}O.prototype.S.call(this,e)};pe.prototype.U=function(e){if(this.t!==void 0){if(O.prototype.U.call(this,e),this.t===void 0){this.f&=-33;for(var n=this.s;n!==void 0;n=n.n)n.S.U(n)}}};pe.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var e=this.t;e!==void 0;e=e.x)e.t.N()}};Object.defineProperty(pe.prototype,"value",{get:function(){if(1&this.f)throw Error("Cycle detected");var e=bn(this);if(this.h(),e!==void 0)e.i=this.i;if(16&this.f)throw this.v;return this.v}});function Ze(e,n){return new pe(e,n)}function wn(e){var n=e.m;if(e.m=void 0,typeof n=="function"){ne++;var s=P;P=void 0;try{n()}catch(o){throw e.f&=-2,e.f|=8,St(e),o}finally{P=s,Xe()}}}function St(e){for(var n=e.s;n!==void 0;n=n.n)n.S.U(n);e.x=void 0,e.s=void 0,wn(e)}function ps(e){if(P!==this)throw Error("Out-of-order effect");if(gn(this),P=e,this.f&=-2,8&this.f)St(this);Xe()}function ve(e,n){if(this.x=e,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=n==null?void 0:n.name,Ae)Ae.push(this)}ve.prototype.c=function(){var e=this.S();try{if(8&this.f)return;if(this.x===void 0)return;var n=this.x();if(typeof n=="function")this.m=n}finally{e()}};ve.prototype.S=function(){if(1&this.f)throw Error("Cycle detected");this.f|=1,this.f&=-9,wn(this),_n(this),ne++;var e=P;return P=this,ps.bind(this,e)};ve.prototype.N=function(){if(!(2&this.f))this.f|=2,this.u=He,He=this};ve.prototype.d=function(){if(this.f|=8,!(1&this.f))St(this)};ve.prototype.dispose=function(){this.d()};function de(e,n){var s=new ve(e,n);try{s.c()}catch(i){throw s.d(),i}var o=s.d.bind(s);return o[Symbol.dispose]=o,o}var kn,et,Qe,ds=typeof window<"u"&&!!window.__PREACT_SIGNALS_DEVTOOLS__;var xn=[];de(function(){kn=this.N})();function be(e,n){S[e]=n.bind(null,S[e]||function(){})}function Ne(e){if(Qe){var n=Qe;Qe=void 0,n()}Qe=e&&e.S()}function Sn(e){var n=this,s=e.data,o=fs(s);o.name="ReactiveDom",o.value=s;var i=qe(function(){var c=n,p=n.__v;while(p=p.__)if(p.__c){p.__c.__$f|=4;break}var u=Ze(function(){var d=o.value.value;return d===0?0:d===!0?"":d||""}),h=Ze(function(){return!Array.isArray(u.value)&&!ft(u.value)}),f=de(function(){if(this.N=Cn,h.value){var d=u.value;if(c.__v&&c.__v.__e&&c.__v.__e.nodeType===3)c.__v.__e.data=d}}),l=n.__$u.d;return n.__$u.d=function(){f(),l.call(this)},[h,u]},[]),a=i[0],r=i[1];return a.value?r.peek():r.value}Sn.displayName="ReactiveTextNode";Object.defineProperties(O.prototype,{constructor:{configurable:!0,value:void 0},type:{configurable:!0,value:Sn},props:{configurable:!0,get:function(){var e=this;return{data:{get value(){return e.value}}}}},__b:{configurable:!0,value:1}});be("__b",function(e,n){if(Ne(),et=void 0,typeof n.type=="string"){var s,o=n.props;for(var i in o)if(i!=="children"){var a=o[i];if(a instanceof O){if(!s)n.__np=s={};s[i]=a,o[i]=a.peek()}}}e(n)});be("__r",function(e,n){if(e(n),n.type!==C){Ne();var s,o=n.__c;if(o){if(o.__$f&=-2,(s=o.__$u)===void 0)o.__$u=s=function(i,a){var r;return de(function(){r=this},{name:a}),r.c=i,r}(function(i){return function(){var a;if(ds)(a=this.y)==null||a.call(this);i.__$f|=1,i.setState({})}}(o),typeof n.type=="function"?n.type.displayName||n.type.name:"")}et=o,Ne(s)}});be("__e",function(e,n,s,o){Ne(),et=void 0,e(n,s,o)});be("diffed",function(e,n){Ne(),et=void 0;var s;if(typeof n.type=="string"&&(s=n.__e)){var{__np:o,props:i}=n,a=s.U;if(a)for(var r in a){var c=a[r];if(!(c===void 0||o&&(r in o)))c.d(),a[r]=void 0}if(o){if(!a)a={},s.U=a;for(var p in o){var u=a[p],h=o[p];if(u===void 0)u=hs(s,p,h,i),a[p]=u;else u.o(h,i)}}}e(n)});function hs(e,n,s,o){var i=n in e&&e.ownerSVGElement===void 0,a=E(s);return{o:function(r,c){a.value=r,o=c},d:de(function(){this.N=Cn;var r=a.value.value;if(o[n]!==r)if(o[n]=r,i)e[n]=r;else if(r!=null&&(r!==!1||n[4]==="-"))e.setAttribute(n,r);else e.removeAttribute(n)})}}be("unmount",function(e,n){if(typeof n.type=="string"){var s=n.__e;if(s){var o=s.U;if(o){s.U=void 0;for(var i in o){var a=o[i];if(a)a.d()}}}var r=n.__np;if(r){var c=n.props;for(var p in r)c[p]=r[p]}n.__np=void 0}else{var u=n.__c;if(u){u.__$f|=8;var h=u.__$u;if(h)u.__$u=void 0,h.d()}}e(n)});be("__h",function(e,n,s,o){if(o<3)n.__$f|=2;e(n,s,o)});me.prototype.shouldComponentUpdate=function(e,n){if(this.__R)return!0;var s=this.__$u,o=s&&s.s!==void 0;for(var i in n)return!0;if(this.__f||typeof this.u=="boolean"&&this.u===!0){var a=2&this.__$f;if(!(o||a||4&this.__$f))return!0;if(1&this.__$f)return!0}else{if(!(o||4&this.__$f))return!0;if(3&this.__$f)return!0}for(var r in e)if(r!=="__source"&&e[r]!==this.props[r])return!0;for(var c in this.props)if(!(c in e))return!0;return!1};function fs(e,n){return qe(function(){return E(e,n)},[])}var ms=function(e){queueMicrotask(function(){queueMicrotask(e)})};function vs(){xt(function(){var e;while(e=xn.shift())kn.call(e)})}function Cn(){if(xn.push(this)===1)(S.requestAnimationFrame||ms)(vs)}class se extends Error{problem;status;constructor(e,n){super(e.reason);this.problem=e;this.status=n}}var Ct={get:()=>{try{return sessionStorage.getItem("tapster.session")}catch{return null}},set:(e)=>{try{if(e===null)sessionStorage.removeItem("tapster.session");else sessionStorage.setItem("tapster.session",e)}catch{return}}},$e=Ct.get(),Tn=()=>{},An=()=>$e!==null,Hn=(e)=>{Tn=e};async function Pn(e){let n=await fetch("/api/claim",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({code:e})}),s=await n.json().catch(()=>({}));if(!n.ok||!s.token)throw new se(s.error??{reason:"the link did not work",fix:"Press Enter in the terminal that runs tapster setup for a fresh link."},n.status);$e=s.token,Ct.set($e)}async function Nn(e,n,s){let o={authorization:`Bearer ${$e??""}`},i;if(s instanceof FormData)i=s;else if(s!==void 0)o["content-type"]="application/json",i=JSON.stringify(s);let a;try{a=await fetch(n,{method:e,headers:o,body:i})}catch{throw new se({reason:"tapster setup is not answering",fix:"Check that tapster setup still runs in your terminal. If it stopped, start it again with bunx @doguyilmaz/tapster setup."},0)}let r=await a.json().catch(()=>null);if(a.status===401)$e=null,Ct.set(null),Tn();if(!a.ok||r===null)throw new se(r?.error??{reason:`tapster setup answered ${a.status}`,fix:"Reload the page and try again."},a.status);return r}var Z=(e)=>Nn("GET",e),A=(e,n)=>Nn("POST",e,n??{});var $n="tapster.hub",Tt=(e)=>{try{return localStorage.getItem(e)}catch{return null}},nt=(e,n)=>{try{if(n===null)localStorage.removeItem(e);else localStorage.setItem(e,n)}catch{return}},In=Tt,he=E(location.pathname),Me=E(null),oe=E(null),Ie=E(null),At=E(null),V=E(Tt($n)),le=E(null),tt=E(!1),_e=E(null),ye=E(null);function ce(e,n=!1){if(n)history.replaceState(null,"",e);else history.pushState(null,"",e);he.value=location.pathname,window.scrollTo({top:0})}addEventListener("popstate",()=>{he.value=location.pathname});function Y(e,n){ye.value={tone:e,text:n},setTimeout(()=>{if(ye.value?.text===n)ye.value=null},5000)}var R=(e)=>e instanceof se?e.problem:{reason:"something went wrong",fix:"Reload the page and try again."};async function st(){try{oe.value=await Z("/api/account"),Ie.value=null}catch(e){Ie.value=R(e)}}async function En(){let e=await Z("/api/hubs");At.value=e.hubs}function ot(e){if(e!==V.value)Q.value=null;if(V.value=e,nt($n,e),le.value=null,_e.value=null,e)W()}async function W(){let e=V.value;if(!e)return;tt.value=!0;try{let n=await Z(`/api/hub?hub=${encodeURIComponent(e)}`);if(V.value===e)le.value=n,_e.value=null}catch(n){if(V.value===e)_e.value=R(n)}finally{tt.value=!1}}var Mn=(e)=>`tapster.mac.${e}`,Ee=E({});function Dn(e){return Ee.value[e]??(Tt(Mn(e))||null)}function Ht(e,n){nt(Mn(e),n),Ee.value={...Ee.value,[e]:n}}var De=E(null),Q=E(null);function at(e){let n=Me.value?.home;if(!n)return e;return e===n?"~":e.startsWith(`${n}/`)?`~${e.slice(n.length)}`:e}var bs=0;function t(e,n,s,o,i,a){n||(n={});var r,c,p=n;if("ref"in p)for(c in p={},n)c=="ref"?r=n[c]:p[c]=n[c];var u={type:e,props:p,key:s,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--bs,__i:-1,__u:0,__source:i,__self:a};if(typeof e=="function"&&(r=e.defaultProps))for(c in r)p[c]===void 0&&(p[c]=r[c]);return S.vnode&&S.vnode(u),u}var ys={check:t("path",{d:"M20 6 9 17l-5-5"},void 0,!1,void 0,this),x:t("path",{d:"M18 6 6 18M6 6l12 12"},void 0,!1,void 0,this),alert:t("path",{d:"M12 9v4M12 17h.01M10.3 3.9 1.8 18a2 2 0 0 0 1.7 3h17a2 2 0 0 0 1.7-3L13.7 3.9a2 2 0 0 0-3.4 0z"},void 0,!1,void 0,this),info:t(C,{children:[t("circle",{cx:"12",cy:"12",r:"10"},void 0,!1,void 0,this),t("path",{d:"M12 16v-4M12 8h.01"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),lock:t(C,{children:[t("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2"},void 0,!1,void 0,this),t("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),copy:t(C,{children:[t("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2"},void 0,!1,void 0,this),t("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),external:t("path",{d:"M15 3h6v6M10 14 21 3M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"},void 0,!1,void 0,this),file:t("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8zM14 2v6h6"},void 0,!1,void 0,this),folder:t("path",{d:"M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.7-.9L9.6 3.9A2 2 0 0 0 7.9 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2z"},void 0,!1,void 0,this),refresh:t("path",{d:"M21 12a9 9 0 1 1-3-6.7L21 8M21 3v5h-5"},void 0,!1,void 0,this),loader:t("path",{d:"M21 12a9 9 0 1 1-6.2-8.6"},void 0,!1,void 0,this),down:t("path",{d:"m6 9 6 6 6-6"},void 0,!1,void 0,this),right:t("path",{d:"m9 18 6-6-6-6"},void 0,!1,void 0,this),arrow:t("path",{d:"M5 12h14M12 5l7 7-7 7"},void 0,!1,void 0,this),eye:t(C,{children:[t("path",{d:"M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7S2 12 2 12z"},void 0,!1,void 0,this),t("circle",{cx:"12",cy:"12",r:"3"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),play:t("path",{d:"M7 4v16l13-8z"},void 0,!1,void 0,this),shield:t("path",{d:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"},void 0,!1,void 0,this),pr:t(C,{children:[t("circle",{cx:"18",cy:"18",r:"3"},void 0,!1,void 0,this),t("circle",{cx:"6",cy:"6",r:"3"},void 0,!1,void 0,this),t("path",{d:"M13 6h3a2 2 0 0 1 2 2v7M6 9v12"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),package:t("path",{d:"M21 16V8a2 2 0 0 0-1-1.7l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.7l7 4a2 2 0 0 0 2 0l7-4a2 2 0 0 0 1-1.7zM3.3 7 12 12l8.7-5M12 22V12"},void 0,!1,void 0,this),upload:t("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4M17 8l-5-5-5 5M12 3v12"},void 0,!1,void 0,this),key:t(C,{children:[t("circle",{cx:"7.5",cy:"15.5",r:"5.5"},void 0,!1,void 0,this),t("path",{d:"m21 2-9.6 9.6M15.5 7.5l3 3L22 7l-3-3"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),power:t("path",{d:"M18.4 6.6a9 9 0 1 1-12.8 0M12 2v10"},void 0,!1,void 0,this),plus:t("path",{d:"M12 5v14M5 12h14"},void 0,!1,void 0,this),circle:t("circle",{cx:"12",cy:"12",r:"9"},void 0,!1,void 0,this),git:t(C,{children:[t("circle",{cx:"12",cy:"12",r:"3"},void 0,!1,void 0,this),t("path",{d:"M12 3v6M12 15v6"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)};function v({name:e,spin:n,label:s}){return t("svg",{class:`icon${n?" spin":""}`,viewBox:"0 0 24 24","aria-hidden":s?void 0:"true",role:s?"img":void 0,"aria-label":s,children:ys[e]},void 0,!1,void 0,this)}function j({label:e="Working"}){return t(v,{name:"loader",spin:!0,label:e},void 0,!1,void 0,this)}var _s={keys:"lock",ok:"check",warn:"alert",error:"alert",info:"info"};function x({tone:e="info",title:n,children:s}){return t("div",{class:`note ${e}`,role:e==="error"?"alert":void 0,children:[t(v,{name:_s[e]},void 0,!1,void 0,this),t("div",{children:[n&&t("strong",{children:n},void 0,!1,void 0,this),s]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function N({problem:e}){if(!e)return null;let n=e.reason.charAt(0).toUpperCase()+e.reason.slice(1);return t(x,{tone:"error",title:`${n}.`,children:t("span",{children:e.fix},void 0,!1,void 0,this)},void 0,!1,void 0,this)}function F({tone:e,children:n}){return t("span",{class:`badge${e?` ${e}`:""}`,children:n},void 0,!1,void 0,this)}function Pt({text:e,label:n="Copy"}){let[s,o]=m(!1);return t("button",{type:"button",class:"btn secondary small",onClick:async()=>{try{await navigator.clipboard.writeText(e),o(!0),setTimeout(()=>o(!1),1600)}catch{o(!1)}},children:[t(v,{name:s?"check":"copy"},void 0,!1,void 0,this),s?"Copied":n]},void 0,!0,void 0,this)}function z({text:e}){return t("div",{class:"cmd",children:[t("code",{children:e},void 0,!1,void 0,this),t(Pt,{text:e},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function q({href:e,children:n,class:s="btn secondary"}){return t("a",{class:s,href:e,target:"_blank",rel:"noopener noreferrer",children:[n,t(v,{name:"external"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function Nt(e){let[n,s]=m(!1),o=(i)=>e.onFile(i&&i[0]?i[0]:null);return t("div",{class:"field",children:[t("span",{class:"label",id:`${e.name}-label`,children:e.label},void 0,!1,void 0,this),t("label",{class:`drop${n?" over":""}${e.file?" has":""}`,onDragOver:(i)=>{i.preventDefault(),s(!0)},onDragLeave:()=>s(!1),onDrop:(i)=>{i.preventDefault(),s(!1),o(i.dataTransfer?.files??null)},children:[t("input",{type:"file",name:e.name,accept:e.accept,"aria-labelledby":`${e.name}-label`,onChange:(i)=>o(i.currentTarget.files)},void 0,!1,void 0,this),t(v,{name:e.file?"check":"upload"},void 0,!1,void 0,this),t("span",{children:e.file?t(C,{children:[t("strong",{class:"mono",children:e.file.name},void 0,!1,void 0,this),t("span",{class:"muted small",children:[" (",Math.max(1,Math.round(e.file.size/1024))," KB). Drop or choose another file to replace it."]},void 0,!0,void 0,this)]},void 0,!0,void 0,this):t(C,{children:[t("strong",{children:"Drop the file here"},void 0,!1,void 0,this)," ",t("span",{class:"muted",children:"or click to choose it"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),t("span",{class:"hint",children:e.hint},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function $t({name:e,label:n,hint:s,autoComplete:o="current-password"}){let[i,a]=m(!1);return t("div",{class:"field",children:[t("label",{for:e,children:n},void 0,!1,void 0,this),t("div",{class:"with-toggle",children:[t("input",{class:"input",id:e,name:e,type:i?"text":"password",autoComplete:o,spellcheck:!1,autoCapitalize:"off",autoCorrect:"off"},void 0,!1,void 0,this),t("button",{type:"button",class:"btn quiet small",onClick:()=>a(!i),"aria-pressed":i,children:i?"Hide":"Show"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),s&&t("span",{class:"hint",children:s},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function ge({name:e,label:n,hint:s,value:o,placeholder:i,mono:a,autoComplete:r="off",onInput:c}){return t("div",{class:"field",children:[t("label",{for:e,children:n},void 0,!1,void 0,this),t("input",{class:`input${a?" mono":""}`,id:e,name:e,value:o,placeholder:i,autoComplete:r,spellcheck:!1,autoCapitalize:"off",autoCorrect:"off",onInput:c?(p)=>c(p.currentTarget.value):void 0},void 0,!1,void 0,this),s&&t("span",{class:"hint",children:s},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function L({busy:e,children:n,...s}){return t("button",{...s,disabled:e||s.disabled,"aria-busy":e,children:[e&&t(j,{},void 0,!1,void 0,this),n]},void 0,!0,void 0,this)}function It({text:e}){return t("div",{class:"gate",children:t("div",{class:"row muted",role:"status",children:[t(j,{},void 0,!1,void 0,this),t("span",{children:e},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}function we({title:e,children:n}){return t(C,{children:[t("div",{class:"stripe"},void 0,!1,void 0,this),t("div",{class:"gate",children:t("div",{class:"card",children:[t("img",{class:"mascot",src:"/logo.webp",alt:"",width:"112",height:"112"},void 0,!1,void 0,this),t("h1",{class:"title",children:e},void 0,!1,void 0,this),n]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function On({problem:e}){return t(we,{title:e?"This link did not open tapster setup":"Open tapster setup from your terminal",children:[e&&t(N,{problem:e},void 0,!1,void 0,this),t("p",{class:"lead",children:"Each link from the terminal works once, so a copy of it in your history or someone else\'s hands is worthless. To get a fresh one, press Enter in the terminal where tapster setup runs."},void 0,!1,void 0,this),t("p",{class:"muted",children:"If tapster setup is not running, start it again:"},void 0,!1,void 0,this),t(z,{text:"bunx @doguyilmaz/tapster setup"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function Rn(){return t(we,{title:"tapster setup stopped",children:[t("p",{class:"lead",children:"Everything you did is stored on GitHub. To continue later, start it again; it picks up where you left off."},void 0,!1,void 0,this),t(z,{text:"bunx @doguyilmaz/tapster setup"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function Vn(){let e=oe.value;U(()=>{let o=3000,i=0,a=async()=>{if(!document.hidden)await st();o=Math.min(o*1.4,15000),i=window.setTimeout(a,o)};return i=window.setTimeout(a,o),()=>clearTimeout(i)},[]);let n=t("p",{class:"row muted small",children:[t(j,{},void 0,!1,void 0,this)," tapster checks again by itself every few seconds."]},void 0,!0,void 0,this);if(Ie.value)return t(we,{title:"tapster could not reach GitHub",children:[t(N,{problem:Ie.value},void 0,!1,void 0,this),n]},void 0,!0,void 0,this);if(e?.state==="no-gh")return t(we,{title:"Install the GitHub CLI",children:[t("p",{class:"lead",children:"tapster talks to GitHub through the GitHub CLI, so your sign-in stays with it and tapster never sees a password."},void 0,!1,void 0,this),t(z,{text:"brew install gh"},void 0,!1,void 0,this),t("p",{class:"muted small",children:["Not on a Mac? See ",t("a",{href:"https://cli.github.com",target:"_blank",rel:"noopener noreferrer",children:"cli.github.com"},void 0,!1,void 0,this),". Then sign in:"]},void 0,!0,void 0,this),t(z,{text:"gh auth login"},void 0,!1,void 0,this),n]},void 0,!0,void 0,this);if(e?.state==="signed-out")return t(we,{title:"Sign in to GitHub",children:[t("p",{class:"lead",children:"Run this in a terminal and follow its steps. tapster uses that sign-in to set up your hub; it never sees your password."},void 0,!1,void 0,this),t(z,{text:"gh auth login"},void 0,!1,void 0,this),n]},void 0,!0,void 0,this);let s=e?.state==="ok"?e.missing:[];return t(we,{title:"Allow gh to change workflows",children:[t("p",{class:"lead",children:["Your GitHub CLI sign-in lacks ",s.join(" and "),". tapster needs it to write the hub\'s workflow file."]},void 0,!0,void 0,this),t(z,{text:`gh auth refresh -s ${s.join(",")}`},void 0,!1,void 0,this),t(x,{tone:"keys",children:t("span",{children:"The sign-in stays in the GitHub CLI on this computer. tapster asks it for a token each time and keeps nothing."},void 0,!1,void 0,this)},void 0,!1,void 0,this),n]},void 0,!0,void 0,this)}var jn=(e)=>{let n=new Date(e),s=Math.round((Date.now()-n.getTime())/60000);if(s<1)return"just now";if(s<60)return`${s} min ago`;if(s<2880)return`${Math.round(s/60)} h ago`;return n.toLocaleDateString()},gs=new Set(["the tapster environment exists","only main may open the tapster environment","main cannot be deleted or force-pushed, by anyone","the hub runs only GitHub\'s and tapster\'s actions, pinned by commit","the default workflow token is read-only"]),ws=new Set(["the hub workflow exists","the hub workflow is tapster\'s template","the hub workflow runs only on schedule and manual dispatch","tapster.yml is valid"]);function ks({name:e,fix:n,hub:s,onFixed:o}){let[i,a]=m(!1),[r,c]=m(null);if(gs.has(e))return t("span",{class:"stack tight",children:[t("span",{class:"row",children:t(L,{busy:i,class:"btn secondary small",onClick:async()=>{a(!0),c(null);try{await A("/api/hub/protect",{hub:s}),await W(),o()}catch(u){c(R(u))}finally{a(!1)}},children:[t(v,{name:"shield"},void 0,!1,void 0,this),"Restore the protection"]},void 0,!0,void 0,this)},void 0,!1,void 0,this),t(N,{problem:r},void 0,!1,void 0,this)]},void 0,!0,void 0,this);let p=ws.has(e)&&!(e==="tapster.yml is valid"&&n!=="Run tapster init.")?"files":e==="the credentials this hub needs are stored"?null:void 0;if(p===void 0)return null;return t("span",{class:"row",children:t("button",{type:"button",class:"btn secondary small",onClick:()=>{De.value=p,ce("/setup")},children:["Fix it in Setup",t(v,{name:"arrow"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}var Et=(e)=>e.charAt(0).toUpperCase()+e.slice(1),xs={success:{tone:"ok",text:"Done"},failure:{tone:"error",text:"Failed"},cancelled:{text:"Cancelled"},skipped:{text:"Skipped"}};function Fn(){let e=le.value,[n,s]=m(null),[o,i]=m(null),[a,r]=m(!1),[c,p]=m(!1),u=async()=>{if(!e)return;r(!0),i(null);try{s(await Z(`/api/hub/health?hub=${encodeURIComponent(e.name)}`))}catch(d){i(R(d))}finally{r(!1)}};if(U(()=>{u()},[e?.name]),!e)return null;let h=n?.checks.filter((d)=>!d.ok)??[],f=n?.checks.filter((d)=>d.ok)??[],l=async()=>{p(!0);try{await A("/api/hub/run",{hub:e.name}),Y("ok","The hub run started. It shows up below in a few seconds."),setTimeout(()=>void u(),4000)}catch(d){i(R(d))}finally{p(!1)}};return t("div",{class:"stack",style:"gap: 1.5rem; max-width: 900px",children:[t("div",{class:"spread",children:[t("div",{class:"stack tight",children:[t("p",{class:"eyebrow",children:"Health"},void 0,!1,void 0,this),t("h1",{class:"title",children:n?h.length?`${h.length} ${h.length===1?"thing needs":"things need"} you`:`${e.name} is healthy`:`Checking ${e.name}`},void 0,!1,void 0,this),t("p",{class:"lead",children:"The same checks as tapster doctor, run against the hub as it is on GitHub\'s main branch."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),t("div",{class:"row",children:[t("button",{type:"button",class:"btn secondary",onClick:()=>void u(),disabled:a,children:[t(v,{name:"refresh",spin:a},void 0,!1,void 0,this),"Check again"]},void 0,!0,void 0,this),t(L,{busy:c,class:"btn primary",onClick:l,children:[t(v,{name:"play"},void 0,!1,void 0,this),"Run the hub now"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),t(N,{problem:o},void 0,!1,void 0,this),e.issue&&t(x,{tone:"warn",title:`The hub opened issue #${e.issue.number}: tapster: the hub needs attention`,children:[t("span",{children:["Updated ",jn(e.issue.updated),". It closes itself once everything is fine."]},void 0,!0,void 0,this),t("details",{children:[t("summary",{class:"small",children:"Show what it says"},void 0,!1,void 0,this),t("pre",{class:"block",style:"white-space: pre-wrap; margin-top: 0.5rem",children:e.issue.body.replace(/<!--[\\s\\S]*?-->/g,"").trim()},void 0,!1,void 0,this)]},void 0,!0,void 0,this),t(q,{href:e.issue.url,class:"btn secondary small",children:"Open the issue"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),a&&!n&&t("p",{class:"row muted",role:"status",children:[t(j,{},void 0,!1,void 0,this)," Running the checks"]},void 0,!0,void 0,this),n&&t("div",{class:"card list",children:[...h,...f].map((d)=>t("div",{class:"item",style:"grid-template-columns: auto minmax(0, 1fr); align-items: start",children:[t("span",{class:d.ok?"ok":"bad",style:`color: var(--${d.ok?"green":"wax"}); padding-top: 0.15rem`,children:t(v,{name:d.ok?"check":"alert",label:d.ok?"ok":"needs a fix"},void 0,!1,void 0,this)},void 0,!1,void 0,this),t("div",{class:"stack tight",style:"gap: 0.2rem",children:[t("span",{style:"font-weight: 550",children:Et(d.name)},void 0,!1,void 0,this),!d.ok&&t("span",{class:"muted small",children:d.fix},void 0,!1,void 0,this),!d.ok&&t(ks,{name:d.name,fix:d.fix,hub:e.name,onFixed:()=>void u()},void 0,!1,void 0,this),d.note&&t("span",{class:"faint small",children:[Et(d.note),"."]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},d.name,!0,void 0,this))},void 0,!1,void 0,this),n?.note&&t("p",{class:"muted small",children:[Et(n.note.replace(/^note: /,"")),"."]},void 0,!0,void 0,this),n&&t("section",{class:"stack tight",children:[t("h2",{class:"section-title",children:"Recent hub runs"},void 0,!1,void 0,this),n.runs.length?t("div",{class:"card list",children:n.runs.map((d)=>{let _=d.status==="completed"?xs[d.conclusion??""]??{text:d.conclusion??"Done"}:{tone:"warn",text:d.status==="queued"?"Queued":"Running"};return t("div",{class:"item",children:[t("span",{class:"stack tight",style:"gap: 0.1rem",children:[t("span",{children:d.event==="schedule"?"On schedule":d.event==="workflow_dispatch"?"Started by hand or the doorbell":d.event},void 0,!1,void 0,this),t("span",{class:"faint small",children:jn(d.created)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),t("span",{class:"row",children:[t(F,{tone:_.tone,children:_.text},void 0,!1,void 0,this),t(q,{href:d.url,class:"btn quiet small",children:"Log"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},d.id,!0,void 0,this)})},void 0,!1,void 0,this):t("p",{class:"muted",children:"No runs yet. The workflow starts once the hub files are on main."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function Ln({onChosen:e,onCancel:n}){let[s,o]=m(null),[i,a]=m("homebrew-tap"),[r,c]=m("public"),[p,u]=m(!1),h=oe.value?.state==="ok"?oe.value.login:"you";U(()=>{En().catch((g)=>o(R(g)))},[]);let f=At.value,l=Me.value?.here.hub??null,d=f?.some((g)=>g.name.toLowerCase()===`${h}/${i}`.toLowerCase())??!1,_=/^homebrew-[A-Za-z0-9._-]{1,80}$/.test(i),T=async(g)=>{g.preventDefault(),u(!0),o(null);try{let k=await A("/api/hubs",{name:i,private:r==="private"});e(k.hub)}catch(k){o(R(k))}finally{u(!1)}};return t("div",{class:"stack",style:"gap: 2rem; max-width: 860px",children:[t("div",{class:"hello",children:[t("div",{class:"stack tight",children:[t("h1",{class:"title",children:"Choose your hub"},void 0,!1,void 0,this),t("p",{class:"lead",children:["Your hub is your Homebrew tap: a repository whose name starts with ",t("code",{children:"homebrew-"},void 0,!1,void 0,this),". tapster turns it into the one place that signs, notarizes and publishes the releases of all your projects."]},void 0,!0,void 0,this),n&&t("p",{children:t("button",{type:"button",class:"btn quiet",onClick:n,children:"Keep the current hub"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),t("img",{src:"/courier.webp",alt:"The tapster octopus courier with sealed parcels",width:"220",height:"220"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),t(N,{problem:s},void 0,!1,void 0,this),t("section",{class:"stack tight","aria-labelledby":"yours",children:[t("h2",{id:"yours",class:"section-title",children:"Your taps"},void 0,!1,void 0,this),f===null&&!s&&t("p",{class:"row muted",children:[t(j,{},void 0,!1,void 0,this)," Looking for repositories named homebrew-\u2026 on your account"]},void 0,!0,void 0,this),f?.length===0&&t("p",{class:"muted",children:"You have no repository named homebrew-\u2026 yet. Create one below."},void 0,!1,void 0,this),t("div",{class:"choices",children:f?.map((g)=>t("button",{type:"button",class:"choice",onClick:()=>e(g.name),children:[t(v,{name:"package"},void 0,!1,void 0,this),t("span",{class:"grow",children:[t("span",{class:"mono",children:g.name},void 0,!1,void 0,this),t("span",{class:"muted small",children:g.tapster?"Already a tapster hub":"A tap without tapster yet"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),g.name===l&&t(F,{tone:"next",children:"This folder"},void 0,!1,void 0,this),t(F,{tone:g.private?"warn":void 0,children:g.private?"Private":"Public"},void 0,!1,void 0,this),t(v,{name:"right"},void 0,!1,void 0,this)]},g.name,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this),t("section",{class:"card pad stack","aria-labelledby":"new",children:[t("h2",{id:"new",class:"section-title",children:"Or create a new tap"},void 0,!1,void 0,this),t("form",{class:"stack",onSubmit:T,children:[t("div",{class:"field",children:[t("label",{for:"tap-name",children:"Repository name"},void 0,!1,void 0,this),t("div",{class:"row",style:"flex-wrap: nowrap",children:[t("span",{class:"mono muted",children:[h,"/"]},void 0,!0,void 0,this),t("input",{class:"input mono",id:"tap-name",value:i,onInput:(g)=>a(g.currentTarget.value.trim()),spellcheck:!1,autoComplete:"off"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),t("span",{class:"hint",children:["Users install with ",t("code",{children:["brew install ",h,"/",i.replace(/^homebrew-/,"")||"tap","/<name>"]},void 0,!0,void 0,this),"."]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),t("fieldset",{class:"stack tight",style:"border: 0; padding: 0; margin: 0",children:[t("legend",{class:"label",style:"font-weight: 600; font-size: 0.92rem; margin-bottom: 0.4rem",children:"Visibility"},void 0,!1,void 0,this),t("label",{class:"switch",children:[t("input",{type:"radio",name:"visibility",checked:r==="public",onChange:()=>c("public")},void 0,!1,void 0,this),t("span",{children:[t("strong",{children:"Public (recommended)"},void 0,!1,void 0,this),t("span",{children:"GitHub gives public repositories free macOS runners, which signing needs. It also gives them the protected environment that holds your keys."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),t("label",{class:"switch",children:[t("input",{type:"radio",name:"visibility",checked:r==="private",onChange:()=>c("private")},void 0,!1,void 0,this),t("span",{children:[t("strong",{children:"Private"},void 0,!1,void 0,this),t("span",{children:"Needs GitHub Pro for the protected environment. Every run uses your plan\'s Actions minutes. Users can only install from public projects."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),d&&t(x,{tone:"warn",children:"You already have this repository. Pick it from the list above."},void 0,!1,void 0,this),t("div",{class:"row",children:[t(L,{busy:p,class:"btn primary",type:"submit",disabled:!_||d,children:["Create ",h,"/",i]},void 0,!0,void 0,this),!_&&t("span",{class:"muted small",children:"The name must start with homebrew-."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function Mt(e,n=Date.now()){let s=Date.parse(`${e}T00:00:00Z`);return!Number.isNaN(s)&&s-n<2592000000}function Dt(e,n){if(e.apple.needed)return!0;return n===null?null:n==="yes"}function Bn(e,n,s=Date.now()){let o=Dt(e,n),i=e.protect.checks.filter((c)=>c.ok).length,a=[{id:"protect",name:"Protect the hub",done:e.protect.done,status:e.protect.done?"All protections are on":i?`${i} of ${e.protect.checks.length} protections on`:"Not protected yet",open:"Not protected yet"},{id:"app",name:"Create the GitHub App",done:Boolean(e.app.id&&e.app.slug&&e.app.key),attention:Boolean(e.app.id&&!e.app.key),status:e.app.id&&!e.app.key?"The App\'s private key is missing":e.app.slug?e.app.slug:"Not created yet",open:"Not created yet"},{id:"macos",name:"macOS or not",done:o===!0,skipped:o===!1,status:o===!0?"Signs macOS software":o===!1?"No macOS builds":"Your answer",open:"Your answer"},{id:"certificate",name:"Apple certificate",done:Boolean(e.apple.certificate&&e.apple.certificateStored),skipped:o===!1,attention:Boolean(e.apple.certificate&&Mt(e.apple.certificate.expires,s)),status:o===!1?"Not needed":e.apple.certificate?`Team ${e.apple.certificate.team}, expires ${e.apple.certificate.expires}`:"Not stored yet",open:"Not stored yet"},{id:"notary",name:"Notarization key",done:e.apple.notary,skipped:o===!1,status:o===!1?"Not needed":e.apple.notary?"Stored":"Not stored yet",open:"Not stored yet"},{id:"files",name:"Hub files",done:e.files.config&&e.files.state&&e.files.workflow!=="missing",attention:e.files.workflow==="older"||e.files.workflow==="other",status:e.files.workflow==="missing"?"Not written yet":e.files.workflow==="older"?`Runs ${e.files.pinned}; update available`:e.files.workflow==="other"?`Runs ${e.files.pinned??"a workflow tapster did not write"}; review it`:e.files.workflow==="newer"?`Runs ${e.files.pinned}, newer than this tapster`:`Runs ${e.files.pinned}`,open:"Not written yet"},{id:"project",name:"Your projects",done:e.packages.length>0,status:e.packages.length?`${e.packages.length} in the hub`:"None yet",open:"None yet"}],r=!1;return a.map((c)=>{let p;if(c.skipped)p="skipped";else if(c.attention)p="attention";else if(c.done)p="done";else if(!r)p="now",r=!0;else p="later";return{id:c.id,name:c.name,state:p,status:c.status}})}var Gn=(e)=>(e.find((n)=>n.state==="now"||n.state==="attention")??e[e.length-1]).id;function it(e,n){let s=e.split(`\n`),o=n.split(`\n`),i=s.length,a=o.length;if(i*a>4000000)return[...s.map((h)=>({kind:"del",text:h})),...o.map((h)=>({kind:"add",text:h}))];let r=Array.from({length:i+1},()=>Array(a+1).fill(0));for(let h=i-1;h>=0;h--)for(let f=a-1;f>=0;f--)r[h][f]=s[h]===o[f]?r[h+1][f+1]+1:Math.max(r[h+1][f],r[h][f+1]);let c=[],p=0,u=0;while(p<i&&u<a)if(s[p]===o[u])c.push({kind:"ctx",text:s[p]}),p++,u++;else if(r[p+1][u]>=r[p][u+1])c.push({kind:"del",text:s[p++]});else c.push({kind:"add",text:o[u++]});while(p<i)c.push({kind:"del",text:s[p++]});while(u<a)c.push({kind:"add",text:o[u++]});return c}function rt(e,n=3){let s=e.map((a,r)=>a.kind!=="ctx"||e.slice(Math.max(0,r-n),r+n+1).some((c)=>c.kind!=="ctx")),o=[],i=0;if(e.forEach((a,r)=>{if(s[r]){if(i)o.push({kind:"gap",text:`${i} unchanged lines`});i=0,o.push(a)}else i++}),i)o.push({kind:"gap",text:`${i} unchanged lines`});return o}var Ss=(e)=>{let n=Math.min(...e.filter((s)=>s.trim()).map((s)=>/^ */.exec(s)[0].length));return e.map((s)=>s.slice(n)).join(`\n`).trimEnd()};function Un(e){let n=[];for(let s of e){let[o="",...i]=s.split(`\n`),a=o.trim().replace(/^- /,"");if(!a||/^proposed the hub entry in |^open this page and choose Install/.test(a))continue;let r=n.at(-1),c;if(o.startsWith(" ")&&r&&r.block===null)c=r,c.text+=`${/[.:;!?]$/.test(c.text)?"":"."} ${a}`;else c={text:/^[a-z]+[\\s:;,]/.test(a)?a.charAt(0).toUpperCase()+a.slice(1):a,block:null},n.push(c);let p=0;while(p<i.length&&!c.text.endsWith(":"))c.text+=` ${i[p++].trim()}`;if(p<i.length)c.block=Ss(i.slice(p))}return n}var Wn="tapster.roots",zn={go:"Go with GoReleaser",bun:"Bun",app:"Mac app with Sparkle"};function Cs(){try{let e=JSON.parse(In(Wn)??"[]");return Array.isArray(e)?e.filter((n)=>typeof n==="string").slice(0,10):[]}catch{return[]}}function Ot({p:e,onOpen:n}){return t("div",{class:"item",children:[t("button",{type:"button",class:"link",onClick:()=>n(e),disabled:!e.kind,children:[t("span",{class:"name",children:e.repo},void 0,!1,void 0,this),t("span",{class:"path",children:at(e.path)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),t("span",{class:"row",children:[e.kind?t(F,{children:zn[e.kind]},void 0,!1,void 0,this):t("span",{class:"muted small",children:e.why},void 0,!1,void 0,this),e.inHub?t(F,{tone:"ok",children:"In the hub"},void 0,!1,void 0,this):e.proposed?t(q,{href:e.proposed,class:"btn secondary small",children:"Merge the entry"},void 0,!1,void 0,this):e.kind?t("button",{type:"button",class:"btn secondary small",onClick:()=>n(e),children:["Add",t(v,{name:"arrow"},void 0,!1,void 0,this)]},void 0,!0,void 0,this):null]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function qn(){let e=le.value,[n,s]=m(null),[o,i]=m(null),[a,r]=m(Cs()),[c,p]=m(""),[u,h]=m(!1),[f,l]=m(null),[d,_]=m(!1),T=async(w=a)=>{if(!e)return;_(!0),i(null);try{s(await A("/api/projects/scan",{hub:e.name,extra:w}))}catch(B){i(R(B))}finally{_(!1)}};if(U(()=>{T()},[e?.name]),!e)return null;let g=(w)=>{w.preventDefault();let B=c.trim().replace(/^[\'"]|[\'"]$/g,"");if(!B)return;let ee=[B,...a.filter((ae)=>ae!==B)].slice(0,10);r(ee),nt(Wn,JSON.stringify(ee)),p(""),T(ee)},k=n?.projects??[],y=k.filter((w)=>w.kind&&!w.inHub),H=k.filter((w)=>w.inHub),b=k.filter((w)=>!w.kind&&!w.inHub);return t("div",{class:"stack",style:"gap: 1.5rem",children:[t("div",{class:"spread",children:[t("div",{class:"stack tight",children:[t("p",{class:"eyebrow",children:"Projects on this computer"},void 0,!1,void 0,this),t("h1",{class:"title",children:["Add your projects to ",e.name]},void 0,!0,void 0,this),t("p",{class:"lead",children:["tapster looks for clones of your own repositories here. It reads each clone\'s ",t("code",{children:".git/config"},void 0,!1,void 0,this)," and checks which build files exist. Nothing leaves this computer."]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),t("button",{type:"button",class:"btn secondary",onClick:()=>void T(),disabled:d,children:[t(v,{name:"refresh",spin:d},void 0,!1,void 0,this),"Look again"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),t("form",{class:"row",onSubmit:g,style:"flex-wrap: nowrap",children:[t("label",{class:"sr",for:"folder",children:"A folder to look in"},void 0,!1,void 0,this),t("input",{id:"folder",class:"input mono",placeholder:"A folder, such as /Users/you/Documents/code",value:c,onInput:(w)=>p(w.currentTarget.value),spellcheck:!1,autoComplete:"off"},void 0,!1,void 0,this),t("button",{class:"btn secondary",type:"submit",children:[t(v,{name:"folder"},void 0,!1,void 0,this),"Look there too"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),t(N,{problem:o},void 0,!1,void 0,this),d&&!n&&t("p",{class:"row muted",role:"status",children:[t(j,{},void 0,!1,void 0,this)," Looking through your folders"]},void 0,!0,void 0,this),n&&t(C,{children:[t("section",{class:"stack tight","aria-labelledby":"ready",children:[t("h2",{id:"ready",class:"section-title",children:["Ready to add (",y.length,")"]},void 0,!0,void 0,this),y.length?t("div",{class:"card list",children:y.map((w)=>t(Ot,{p:w,onOpen:l},w.path,!1,void 0,this))},void 0,!1,void 0,this):t("p",{class:"muted",children:[k.length?"Every supported clone here is in the hub already.":"No clone of your repositories turned up."," If a project lives elsewhere, add its folder above."]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),H.length>0&&t("section",{class:"stack tight","aria-labelledby":"in-hub",children:[t("h2",{id:"in-hub",class:"section-title",children:["In the hub (",H.length,")"]},void 0,!0,void 0,this),t("div",{class:"card list",children:H.map((w)=>t(Ot,{p:w,onOpen:l},w.path,!1,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this),b.length>0&&t("section",{class:"stack tight",children:[t("button",{type:"button",class:"btn quiet",onClick:()=>h(!u),"aria-expanded":u,style:"justify-self: start",children:[t(v,{name:u?"down":"right"},void 0,!1,void 0,this),b.length," other ",b.length===1?"clone":"clones"," tapster cannot publish yet"]},void 0,!0,void 0,this),u&&t("div",{class:"card list",children:b.map((w)=>t(Ot,{p:w,onOpen:l},w.path,!1,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this),t("p",{class:"faint small",children:["Looked in ",n.roots.map(at).join(", "),n.truncated?"; it stopped early because there were many folders":"",". ",n.others?`${n.others} ${n.others===1?"clone belongs":"clones belong"} to other owners and ${n.others===1?"is":"are"} not listed.`:""]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),f&&t(As,{p:f,hubName:e.name,onClose:()=>l(null),onAdded:()=>void T()},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function Rt({checked:e,onChange:n,title:s,children:o}){return t("label",{class:"switch",children:[t("input",{type:"checkbox",checked:e,onChange:(i)=>n(i.currentTarget.checked)},void 0,!1,void 0,this),t("span",{children:[t("strong",{children:s},void 0,!1,void 0,this),t("span",{children:o},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function Ts({view:e}){return t("div",{class:"stack tight files",children:e.files.map((n)=>{let s=n.before===null?null:rt(it(n.before,n.after??""));return t("details",{class:"file",open:!0,children:[t("summary",{children:[t(v,{name:"file"},void 0,!1,void 0,this),t("code",{children:n.path},void 0,!1,void 0,this),t(F,{tone:n.before===null?"next":n.after===null?"error":"warn",children:n.before===null?"New":n.after===null?"Removed":"Changed"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),t("pre",{class:"block diff",children:s?s.map((o,i)=>t("span",{class:o.kind==="gap"?"hunk":o.kind,children:[o.kind==="add"?"+ ":o.kind==="del"?"- ":o.kind==="gap"?"@ ":" ",o.text,`\n`]},i,!0,void 0,this)):n.after},void 0,!1,void 0,this)]},n.path,!0,void 0,this)})},void 0,!1,void 0,this)}function As({p:e,hubName:n,onClose:s,onAdded:o}){let i=Te(null);U(()=>{let D=document.activeElement;i.current?.querySelector("button")?.focus();let G=(ie)=>{if(ie.key!=="Tab"||!i.current)return;let ct=[...i.current.querySelectorAll("a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), summary, [tabindex]:not([tabindex=\'-1\'])")],Oe=ct[0],ut=ct[ct.length-1];if(!Oe||!ut)return;if(!i.current.contains(document.activeElement))ie.preventDefault(),Oe.focus();else if(ie.shiftKey&&document.activeElement===Oe)ie.preventDefault(),ut.focus();else if(!ie.shiftKey&&document.activeElement===ut)ie.preventDefault(),Oe.focus()};return addEventListener("keydown",G),()=>{removeEventListener("keydown",G),D?.focus()}},[]);let[a,r]=m(null),[c,p]=m(null),[u,h]=m("release.yml"),[f,l]=m(!1),[d,_]=m(!1),[T,g]=m(!1),[k,y]=m(null),[H,b]=m(null),[w,B]=m(null),[ee,ae]=m(!1),[xe,K]=m(!1);U(()=>{A("/api/projects/inspect",{hub:n,path:e.path}).then((G)=>{if(r(G),_(G.dependabot),G.workflow)h(G.workflow)},(G)=>p(R(G)));let D=(G)=>G.key==="Escape"&&s();return addEventListener("keydown",D),()=>removeEventListener("keydown",D)},[e.path]);let X=async(D,G)=>{y(D),p(null);try{await G()}catch(ie){p(R(ie))}finally{y(null)}},Xn=()=>X("add",async()=>{let D=await A("/api/projects/add",{hub:n,path:e.path,options:{workflow:u,autoTag:f,dependabot:d,force:T}});b(D),B(await A("/api/projects/diff",{path:e.path,files:D.files})),o(),W()}),Lt=a?.dirty??[],Bt=a?.kind==="go"&&a.workflows.length===0;return t(C,{children:[t("div",{class:"sheet-back",onClick:s},void 0,!1,void 0,this),t("div",{class:"sheet",role:"dialog","aria-modal":"true","aria-labelledby":"sheet-title",ref:i,children:[t("div",{class:"sheet-head",children:[t("div",{class:"stack tight",style:"flex: 1; min-width: 0; gap: 0.1rem",children:[t("h2",{id:"sheet-title",class:"section-title mono",style:"font-size: 1.05rem; overflow-wrap: anywhere",children:e.repo},void 0,!1,void 0,this),t("span",{class:"faint small",style:"overflow-wrap: anywhere",children:at(e.path)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),t("button",{type:"button",class:"btn quiet small",onClick:s,"aria-label":"Close",children:t(v,{name:"x"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),t("div",{class:"sheet-body",children:[!a&&!c&&t("p",{class:"row muted",role:"status",children:[t(j,{},void 0,!1,void 0,this)," Reading the clone and its repository"]},void 0,!0,void 0,this),t(N,{problem:c},void 0,!1,void 0,this),a&&!H&&t(C,{children:[t("dl",{class:"facts",children:[t("dt",{children:"Kind"},void 0,!1,void 0,this),t("dd",{children:zn[a.kind]},void 0,!1,void 0,this),t("dt",{children:"Branch"},void 0,!1,void 0,this),t("dd",{class:"mono",children:a.branch},void 0,!1,void 0,this),t("dt",{children:"Repository"},void 0,!1,void 0,this),t("dd",{children:[a.private?"Private":"Public",", ",a.protected?"protected by tapster\'s rulesets":"not protected yet"]},void 0,!0,void 0,this),t("dt",{children:"Hub"},void 0,!1,void 0,this),t("dd",{children:a.inHub?"Already in the hub":a.proposed?"Proposed, waiting for you to merge":"Not in the hub yet"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),a.proposed&&t(x,{tone:"info",title:"The hub entry is waiting for you",children:[t("span",{children:"Merge the pull request to let the hub publish this project."},void 0,!1,void 0,this),t(q,{href:a.proposed,class:"btn secondary small",children:"Review the pull request"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),a.branch!==a.defaultBranch&&t(x,{tone:"warn",title:`This clone is on ${a.branch}, not ${a.defaultBranch}`,children:t("span",{children:["tapster changes the files on ",a.branch,". Releases use the workflow on ",a.defaultBranch,", so the change counts once it is merged there."]},void 0,!0,void 0,this)},void 0,!1,void 0,this),Lt.length>0&&t(x,{tone:"warn",title:"Uncommitted changes in files tapster edits",children:t("span",{children:[Lt.join(", "),". Commit or stash them first, so tapster\'s changes stay apart from yours."]},void 0,!0,void 0,this)},void 0,!1,void 0,this),a.private&&t(x,{tone:"warn",title:"This repository is private",children:t("span",{children:"The hub can publish it, but Homebrew, Scoop, apt and dnf users can only install from public projects. Its rulesets need a paid plan; without them the hub refuses it unless you accept the risk with protection: off."},void 0,!1,void 0,this)},void 0,!1,void 0,this),!a.apple&&t(x,{tone:"info",title:"The hub has no Apple credentials",children:"tapster leaves the macOS builds out of this project\'s entry."},void 0,!1,void 0,this),t("div",{class:"stack tight",children:[t("h3",{class:"section-title",children:"Options"},void 0,!1,void 0,this),a.kind==="go"&&(Bt?t(x,{tone:"error",title:"No workflow runs GoReleaser",children:t("span",{children:"tapster edits the workflow that runs goreleaser/goreleaser-action. Add one to .github/workflows first."},void 0,!1,void 0,this)},void 0,!1,void 0,this):t("div",{class:"field",children:[t("label",{for:"workflow",children:"The workflow that runs GoReleaser"},void 0,!1,void 0,this),t("select",{id:"workflow",class:"input",value:u,onChange:(D)=>h(D.currentTarget.value),children:a.workflows.map((D)=>t("option",{value:D,children:[".github/workflows/",D]},D,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)),a.kind!=="go"&&a.releaseFlow==="other"&&t(Rt,{checked:T,onChange:g,title:"Replace the existing release workflow",children:".github/workflows/release.yml exists and tapster does not recognize it. Without this, tapster only adds the step that rings the hub, if the workflow opens a draft release."},void 0,!1,void 0,this),t(Rt,{checked:f,onChange:l,title:"Let the release workflow push tags",children:"For workflows that decide the version and tag by themselves. tapster adds a deploy key that only the default branch\'s release environment can use; the rulesets let deploy keys tag."},void 0,!1,void 0,this),t(Rt,{checked:d,onChange:_,title:"Keep Dependabot\'s pull requests",children:[a.dependabot?"This clone uses Dependabot. ":"","Branches named dependabot/... stay open to anything with write access, the hub\'s App included, so a stolen App key could run your workflows on its own code there."]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),t("div",{class:"stack tight",children:[t("h3",{class:"section-title",children:"What tapster does"},void 0,!1,void 0,this),t("ul",{class:"checks",children:[t("li",{children:[t(v,{name:"right"},void 0,!1,void 0,this),t("span",{children:[a.kind==="go"?`Edits .goreleaser.yaml and .github/workflows/${u}: drafts instead of releases, an attestation step and the step that rings the hub.`:"Writes .github/workflows/release.yml: build, attest, open a draft and ring the hub."," You review and commit these in the next step."]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),t("li",{children:[t(v,{name:"right"},void 0,!1,void 0,this),t("span",{children:["Protects ",a.repo,": only you can create, move or delete branches and tags."]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),t("li",{children:[t(v,{name:"right"},void 0,!1,void 0,this),t("span",{children:["Proposes the project\'s entry to ",n," as a pull request."]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),f&&t("li",{children:[t(v,{name:"right"},void 0,!1,void 0,this),t("span",{children:\'Adds the deploy key "tapster tags" and a release environment.\'},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),t("div",{class:"row",children:t(L,{busy:k==="add",class:"btn primary",onClick:Xn,disabled:Bt,children:a.inHub?"Update the project":`Add to ${n}`},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),H&&t(C,{children:[t(x,{tone:"ok",title:`tapster prepared ${e.repo}`},void 0,!1,void 0,this),t("ul",{class:"checks small",children:Un(H.lines).map((D,G)=>t("li",{children:[t(v,{name:"right"},void 0,!1,void 0,this),t("span",{class:"stack tight",style:"min-width: 0",children:[t("span",{class:"muted",style:"overflow-wrap: anywhere",children:D.text},void 0,!1,void 0,this),D.block&&t("pre",{class:"block",children:D.block},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},G,!0,void 0,this))},void 0,!1,void 0,this),t("section",{class:"stack tight",children:[t("h3",{class:"section-title",children:"1. Review and commit the changes"},void 0,!1,void 0,this),w?t(Ts,{view:w},void 0,!1,void 0,this):t(j,{},void 0,!1,void 0,this),t("div",{class:"row",children:[ee?t(F,{tone:"ok",children:"Committed"},void 0,!1,void 0,this):t(L,{busy:k==="commit",class:"btn primary",onClick:()=>X("commit",async()=>{await A("/api/projects/commit",{path:e.path,files:H.files}),ae(!0)}),children:"Commit these files"},void 0,!1,void 0,this),ee&&(xe?t(F,{tone:"ok",children:"Pushed"},void 0,!1,void 0,this):t(L,{busy:k==="push",class:"btn primary",onClick:()=>X("push",async()=>{await A("/api/projects/push",{path:e.path}),K(!0),Y("ok",`Pushed ${e.repo}.`)}),children:"Push"},void 0,!1,void 0,this))]},void 0,!0,void 0,this),t("p",{class:"muted small",children:"tapster commits only these files, in your own git setup: your hooks and commit signing apply."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),t("section",{class:"stack tight",children:[t("h3",{class:"section-title",children:"2. Merge the hub entry"},void 0,!1,void 0,this),H.pr?t(C,{children:[t("p",{class:"muted",children:"GitHub shows you the exact change to the hub\'s tapster.yml. Merge it to start publishing."},void 0,!1,void 0,this),t("div",{class:"row",children:t(q,{href:H.pr,class:"btn secondary",children:[t(v,{name:"pr"},void 0,!1,void 0,this),"Review and merge on GitHub"]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this):t("p",{class:"muted",children:"No pull request this time; the notes above say why."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),t("section",{class:"stack tight",children:[t("h3",{class:"section-title",children:"3. Let the hub reach it"},void 0,!1,void 0,this),t("p",{class:"muted",children:["Unless the App already reaches ",e.repo,\', install it there. GitHub preselects the project; keep "Only select repositories".\']},void 0,!0,void 0,this),t("div",{class:"row",children:t(q,{href:H.installUrl,class:"btn secondary",children:["Install the App on ",e.repo.split("/")[1]]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),t("section",{class:"stack tight",children:[t("h3",{class:"section-title",children:"4. Release"},void 0,!1,void 0,this),t("p",{class:"muted",children:"Push a version tag. The project\'s workflow opens a draft; the hub signs and publishes it on its next run."},void 0,!1,void 0,this),t(z,{text:`git -C ${JSON.stringify(e.path)} tag v1.0.0 && git -C ${JSON.stringify(e.path)} push origin v1.0.0`},void 0,!1,void 0,this),t("p",{class:"faint small",children:"Use your next version instead of v1.0.0."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function Hs({stop:e,index:n}){if(e.state==="done")return t("span",{class:"dot",children:t(v,{name:"check"},void 0,!1,void 0,this)},void 0,!1,void 0,this);if(e.state==="attention")return t("span",{class:"dot",children:t(v,{name:"alert"},void 0,!1,void 0,this)},void 0,!1,void 0,this);if(e.state==="skipped")return t("span",{class:"dot",children:"\u2013"},void 0,!1,void 0,this);return t("span",{class:"dot",children:n+1},void 0,!1,void 0,this)}function J({title:e,lead:n,children:s}){return t("div",{class:"panel-head",children:[t("div",{class:"spread",children:[t("h2",{class:"title",children:e},void 0,!1,void 0,this),s]},void 0,!0,void 0,this),t("p",{class:"lead",children:n},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function Vt({text:e}){return t("div",{class:"row",children:[t("span",{class:"seal","aria-hidden":"true",children:t(v,{name:"check"},void 0,!1,void 0,this)},void 0,!1,void 0,this),t("strong",{children:e},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function fe(){let[e,n]=m(!1),[s,o]=m(null);return[e,s,async(a)=>{n(!0),o(null);try{await a()}catch(r){o(R(r))}finally{n(!1)}}]}var Kn=[["A tapster environment that only main can open","Your keys go into it, so a workflow on another branch never sees them."],["main cannot be deleted or force-pushed","By anyone, you included, so the hub\'s history stays as you pushed it."],["Only GitHub\'s and tapster\'s actions, pinned by commit","No other code runs next to your keys."],["A read-only default token","Workflows get write access only where the template asks for it."]];function Ps({h:e}){let[n,s,o]=fe();return t("div",{class:"panel",children:[t(J,{title:"Protect the hub",lead:"These settings keep a stolen key or a stray workflow away from your signing keys. You can run this again at any time; it only restores what is missing."},void 0,!1,void 0,this),t("ul",{class:"checks",children:e.protect.checks.map((i,a)=>t("li",{children:[t("span",{class:i.ok?"ok":"no",children:t(v,{name:i.ok?"check":"circle",label:i.ok?"on":"off"},void 0,!1,void 0,this)},void 0,!1,void 0,this),t("span",{class:"stack tight",style:"gap: 0.1rem",children:[t("span",{children:Kn[a]?.[0]??i.label},void 0,!1,void 0,this),t("span",{class:"muted small",children:Kn[a]?.[1]},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},i.label,!0,void 0,this))},void 0,!1,void 0,this),e.protect.others.length>0&&t(x,{tone:"warn",title:"These workflows stop running once the hub is protected",children:[t("span",{children:"They use actions from others or actions not pinned by commit. The hub does not need them. Their commits would make the hub refuse to run. You can remove them in Hub files."},void 0,!1,void 0,this),t("ul",{class:"log",children:e.protect.others.map((i)=>t("li",{children:[t("code",{children:[".github/workflows/",i.file]},void 0,!0,void 0,this),": ",i.actions.slice(0,3).join(", ")]},i.file,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this),t(N,{problem:s},void 0,!1,void 0,this),e.protect.done?t(Vt,{text:`${e.name} is protected`},void 0,!1,void 0,this):t("div",{class:"row",children:t(L,{busy:n,class:"btn primary",onClick:()=>o(async()=>{await A("/api/hub/protect",{hub:e.name}),await W(),Y("ok",`${e.name} is protected.`)}),children:[t(v,{name:"shield"},void 0,!1,void 0,this),e.protect.checks.some((i)=>i.ok)?"Restore the protection":`Protect ${e.name}`]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function Ns({h:e,slug:n}){let[s,o]=m(e.app.installed);U(()=>{if(!e.app.installed)return;let a=0,r=4000,c=async()=>{if(!document.hidden)try{let p=await Z(`/api/hub/installation?hub=${encodeURIComponent(e.name)}`);o(p),r=p.id!==null&&!p.onHub?30000:4000}catch{r=Math.min(r*2,30000)}a=window.setTimeout(c,r)};return a=window.setTimeout(c,500),()=>clearTimeout(a)},[e.name,Boolean(e.app.installed)]);let i=`https://github.com/apps/${n}/installations/new`;return t("div",{class:"stack tight",children:[t("h3",{class:"section-title",children:"Install it on your projects"},void 0,!1,void 0,this),t("p",{class:"muted",children:["On GitHub, choose ",t("strong",{children:"Only select repositories"},void 0,!1,void 0,this)," and pick the projects the hub should publish. Never pick ",e.name,": the App can write to every repository it is installed on. The hub holds your signing keys. You can also install it per project later, from Projects."]},void 0,!0,void 0,this),s?.checked&&s.onHub&&t(x,{tone:"error",title:`The App is installed on ${e.name}`,children:[t("span",{children:["Remove ",e.name," from it; the hub refuses to run until you do."]},void 0,!0,void 0,this),t(q,{href:`https://github.com/settings/installations/${s.id}`,class:"btn secondary small",children:"Open the installation"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),s?.checked&&!s.onHub&&s.id!==null&&t(x,{tone:"ok",title:"The App is installed",children:t("span",{children:s.repos.length?`It reaches ${s.repos.join(", ")}.`:"It reaches no repository yet."},void 0,!1,void 0,this)},void 0,!1,void 0,this),s?.checked&&s.id===null&&t("p",{class:"row muted small",children:[t(j,{},void 0,!1,void 0,this)," Not installed yet. This updates by itself once you click Install on GitHub."]},void 0,!0,void 0,this),!s&&t("p",{class:"muted small",children:"GitHub shows an App\'s repositories only to the App itself. Each hub run reports a project the App cannot reach."},void 0,!1,void 0,this),t("div",{class:"row",children:[t(q,{href:i,class:s?.id?"btn secondary":"btn primary",children:s?.id?"Change its repositories":"Install the App"},void 0,!1,void 0,this),t(q,{href:`https://github.com/settings/apps/${n}`,class:"btn quiet",children:"App settings"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function $s({h:e,what:n,onGo:s}){return t("div",{class:"panel",children:[t(J,{title:n,lead:`This step stores a key in ${e.name}\'s tapster environment. Protect the hub first, so only workflows on main can open it.`},void 0,!1,void 0,this),t(x,{tone:"info",title:"Protect the hub first",children:t("span",{children:"Then come back here."},void 0,!1,void 0,this)},void 0,!1,void 0,this),t("div",{class:"row",children:t("button",{type:"button",class:"btn primary",onClick:s,children:[t(v,{name:"shield"},void 0,!1,void 0,this),"Go to Protect the hub"]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function Yn({h:e}){let[n,s]=m(null),[o,i]=m(null),[a,r,c]=fe(),p=Q.value,u=Boolean(e.app.id&&e.app.slug&&e.app.key);if(U(()=>{if(u||e.app.id||e.app.held||p?.kind==="unstored")return;A("/api/hub/app",{hub:e.name}).then(s,(h)=>i(R(h)))},[e.name,u,p?.kind]),(p?.kind==="unstored"||e.app.held)&&!u)return t("div",{class:"panel",children:[t(J,{title:"Store the App\'s key",lead:"GitHub created the App and handed its key to this setup, but storing it in the hub failed. The key is still in memory here, so try again."},void 0,!1,void 0,this),p?.kind==="unstored"&&t(N,{problem:p.problem},void 0,!1,void 0,this),t(N,{problem:r},void 0,!1,void 0,this),t("div",{class:"row",children:t(L,{busy:a,class:"btn primary",onClick:()=>c(async()=>{await A("/api/hub/app/store",{hub:e.name}),await W(),Q.value={kind:"created"}}),children:"Store the key again"},void 0,!1,void 0,this)},void 0,!1,void 0,this),t("p",{class:"muted small",children:"If this setup stops first, the key is gone. Then delete the App at github.com/settings/apps and create it again here."},void 0,!1,void 0,this)]},void 0,!0,void 0,this);if(e.app.id&&!e.app.key)return t("div",{class:"panel",children:[t(J,{title:"The App\'s key is missing",lead:`The hub knows its App (${e.app.slug??e.app.id}), but its private key is not stored. Generate a new key on GitHub and store it from a clone of the hub:`},void 0,!1,void 0,this),t(z,{text:"bunx @doguyilmaz/tapster init --rotate app"},void 0,!1,void 0,this),t(q,{href:`https://github.com/settings/apps/${e.app.slug??""}`,children:"Open the App on GitHub"},void 0,!1,void 0,this)]},void 0,!0,void 0,this);if(u)return t("div",{class:"panel",children:[t(J,{title:"The GitHub App",lead:"The hub uses this private App to write releases to the projects you install it on. It cannot touch anything else."},void 0,!1,void 0,this),p?.kind==="created"&&t(x,{tone:"ok",title:"GitHub created the App and tapster stored its key in the hub."},void 0,!1,void 0,this),t("dl",{class:"facts",children:[t("dt",{children:"App"},void 0,!1,void 0,this),t("dd",{class:"mono",children:e.app.slug},void 0,!1,void 0,this),t("dt",{children:"Key"},void 0,!1,void 0,this),t("dd",{children:["A secret of the tapster environment in ",e.name]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),t(Ns,{h:e,slug:e.app.slug},void 0,!1,void 0,this)]},void 0,!0,void 0,this);return t("div",{class:"panel",children:[t(J,{title:"Create the GitHub App",lead:`${e.name} needs a GitHub App to write releases to your projects. GitHub creates it on your account after you confirm.`},void 0,!1,void 0,this),p?.kind==="failed"&&t(N,{problem:p.problem},void 0,!1,void 0,this),p?.kind==="unknown"&&t(x,{tone:"warn",title:"That answer from GitHub did not belong to this setup",children:"Start the App again below; nothing was stored."},void 0,!1,void 0,this),n&&t("div",{class:"stack tight",children:[t("h3",{class:"section-title",children:"It asks for"},void 0,!1,void 0,this),t("ul",{class:"checks",children:n.permissions.map((h)=>t("li",{children:[t(v,{name:"right"},void 0,!1,void 0,this),t("span",{children:h},void 0,!1,void 0,this)]},h,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this),t(x,{tone:"keys",title:"Where its key goes",children:t("span",{children:["GitHub hands the App\'s private key to tapster on this computer, once. tapster stores it as a secret of the tapster environment in ",e.name,". It goes nowhere else."]},void 0,!0,void 0,this)},void 0,!1,void 0,this),t(N,{problem:o},void 0,!1,void 0,this),n?t("form",{method:"post",action:n.action,class:"stack tight",children:[t("input",{type:"hidden",name:"manifest",value:n.manifest},void 0,!1,void 0,this),t("div",{class:"row",children:t("button",{class:"btn primary",type:"submit",children:["Continue to GitHub",t(v,{name:"arrow"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),t("p",{class:"muted small",children:["GitHub shows the App ",t("code",{children:n.name},void 0,!1,void 0,this),". Click ",t("strong",{children:"Create GitHub App"},void 0,!1,void 0,this)," there and GitHub brings you back here."]},void 0,!0,void 0,this)]},void 0,!0,void 0,this):!o&&t("p",{class:"row muted",children:[t(j,{},void 0,!1,void 0,this)," Preparing the App"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function Is({h:e,choice:n}){let s=Dt(e,n);return t("div",{class:"panel",children:[t(J,{title:"Will this hub sign macOS software?",lead:"Mac apps and command line tools with macOS builds must be signed and notarized by Apple. That needs an Apple Developer Program membership and two files from Apple."},void 0,!1,void 0,this),e.apple.needed?t(x,{tone:"ok",title:"Yes",children:t("span",{children:e.apple.certificate||e.apple.notary?"The hub already holds Apple credentials.":"tapster.yml lists packages with macOS code."},void 0,!1,void 0,this)},void 0,!1,void 0,this):t("div",{class:"choices",children:[t("button",{type:"button",class:"choice","aria-pressed":s===!0,onClick:()=>Ht(e.name,"yes"),children:[t(v,{name:s===!0?"check":"circle"},void 0,!1,void 0,this),t("span",{class:"grow",children:[t("strong",{children:"Yes, sign macOS software"},void 0,!1,void 0,this),t("span",{class:"muted small",children:"Next: your Developer ID certificate and a notarization key."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),t("button",{type:"button",class:"choice","aria-pressed":s===!1,onClick:()=>Ht(e.name,"no"),children:[t(v,{name:s===!1?"check":"circle"},void 0,!1,void 0,this),t("span",{class:"grow",children:[t("strong",{children:"No, only Linux and Windows"},void 0,!1,void 0,this),t("span",{class:"muted small",children:"The hub leaves macOS builds out. You can add Apple credentials later, here."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function jt(e){history.pushState(null,"",`/setup?saved=${encodeURIComponent(e)}`),setTimeout(()=>history.replaceState(null,"","/setup"),1500)}function Es({h:e}){let[n,s]=m(null),[o,i]=m(!1),[a,r,c]=fe(),p=e.apple.certificate,u=!p||!e.apple.certificateStored||o,h=(f)=>{f.preventDefault();let l=f.currentTarget;c(async()=>{if(!n)throw new se({reason:"no .p12 file is chosen",fix:"Drop the .p12 you exported from Keychain Access."},0);let d=new FormData(l);d.delete("username"),d.set("hub",e.name),d.set("p12",n);let _=await A("/api/hub/certificate",d);jt("certificate"),i(!1),s(null),await W(),Y("ok",`Certificate stored for team ${_.team}. It expires on ${_.expires}.`)})};return t("div",{class:"panel",children:[t(J,{title:"Apple certificate",lead:"A Developer ID Application certificate, exported with its private key as a .p12 file. The hub signs your macOS code with it."},void 0,!1,void 0,this),p&&e.apple.certificateStored&&t(C,{children:[t("dl",{class:"facts",children:[t("dt",{children:"Team"},void 0,!1,void 0,this),t("dd",{class:"mono",children:p.team},void 0,!1,void 0,this),t("dt",{children:"Expires"},void 0,!1,void 0,this),t("dd",{children:[p.expires," ",Mt(p.expires)&&t(F,{tone:"error",children:"Renew it soon"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),!o&&t("div",{class:"row",children:[t("button",{type:"button",class:"btn secondary",onClick:()=>i(!0),children:"Replace the certificate"},void 0,!1,void 0,this),t("span",{class:"muted small",children:"For a renewal or a new team."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),u&&t(C,{children:[t("details",{class:"card pad",open:!p,children:[t("summary",{children:t("strong",{children:"How to get the .p12"},void 0,!1,void 0,this)},void 0,!1,void 0,this),t("ol",{class:"stack tight",style:"margin: 0.8rem 0 0; padding-left: 1.2rem",children:[t("li",{children:["No certificate yet? Create a ",t("strong",{children:"Developer ID Application"},void 0,!1,void 0,this)," certificate at"," ",t("a",{href:"https://developer.apple.com/account/resources/certificates",target:"_blank",rel:"noopener noreferrer",children:"developer.apple.com"},void 0,!1,void 0,this),"."]},void 0,!0,void 0,this),t("li",{children:["In Keychain Access, open ",t("strong",{children:"My Certificates"},void 0,!1,void 0,this),", right-click ",t("strong",{children:"Developer ID Application: \u2026"},void 0,!1,void 0,this)," and choose ",t("strong",{children:"Export"},void 0,!1,void 0,this),"."]},void 0,!0,void 0,this),t("li",{children:"Save it as .p12 with a password. Your password manager can make one."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),t("form",{class:"secret",onSubmit:h,autoComplete:"on",children:[t(ge,{name:"username",label:"Name in your password manager",value:`${e.name}: Developer ID certificate`,autoComplete:"username",hint:"Your password manager saves the .p12 password under this name, so it can fill it in next time."},void 0,!1,void 0,this),t(Nt,{name:"p12",accept:".p12,application/x-pkcs12",label:"The .p12 file",file:n,onFile:s,hint:"It stays in memory on this computer until tapster stores it in the hub."},void 0,!1,void 0,this),t($t,{name:"password",label:"Its password",hint:"The password you set when exporting it."},void 0,!1,void 0,this),t(x,{tone:"keys",title:"Where it goes",children:t("span",{children:["tapster opens the file with your password on this computer to check it is a Developer ID Application certificate that has not expired. Then the file and its password become secrets of the tapster environment in ",e.name,". Keep your own backup: GitHub never shows a secret again."]},void 0,!0,void 0,this)},void 0,!1,void 0,this),t(N,{problem:r},void 0,!1,void 0,this),t("div",{class:"row",children:[t(L,{busy:a,class:"btn primary",type:"submit",children:"Check and store"},void 0,!1,void 0,this),o&&t("button",{type:"button",class:"btn quiet",onClick:()=>i(!1),children:"Cancel"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function Ms({h:e}){let[n,s]=m(null),[o,i]=m(!1),[a,r,c]=fe(),p=!e.apple.notary||o,u=(h)=>{h.preventDefault();let f=h.currentTarget;c(async()=>{if(!n)throw new se({reason:"no .p8 file is chosen",fix:"Drop the AuthKey_\u2026.p8 you downloaded from App Store Connect."},0);let l=new FormData(f);l.set("hub",e.name),l.set("p8",n);let d=await A("/api/hub/notary",l);jt("notary"),i(!1),s(null),await W(),Y("ok",d.checked?"Apple accepted the key and tapster stored it.":"Key stored. Apple checks it at the first release.")})};return t("div",{class:"panel",children:[t(J,{title:"Notarization key",lead:"An App Store Connect API key. The hub sends your signed code to Apple with it; Apple notarizes it."},void 0,!1,void 0,this),e.apple.notary&&!o&&t(C,{children:[t(Vt,{text:"The notarization key is stored"},void 0,!1,void 0,this),t("div",{class:"row",children:t("button",{type:"button",class:"btn secondary",onClick:()=>i(!0),children:"Replace the key"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),p&&t(C,{children:[t("details",{class:"card pad",open:!e.apple.notary,children:[t("summary",{children:t("strong",{children:"How to get the key"},void 0,!1,void 0,this)},void 0,!1,void 0,this),t("ol",{class:"stack tight",style:"margin: 0.8rem 0 0; padding-left: 1.2rem",children:[t("li",{children:["In"," ",t("a",{href:"https://appstoreconnect.apple.com/access/integrations/api",target:"_blank",rel:"noopener noreferrer",children:"App Store Connect"},void 0,!1,void 0,this),", open ",t("strong",{children:"Users and Access"},void 0,!1,void 0,this),", ",t("strong",{children:"Integrations"},void 0,!1,void 0,this),", ",t("strong",{children:"App Store Connect API"},void 0,!1,void 0,this),", ",t("strong",{children:"Team Keys"},void 0,!1,void 0,this),"."]},void 0,!0,void 0,this),t("li",{children:["Create a key with ",t("strong",{children:"Developer"},void 0,!1,void 0,this)," access and download ",t("code",{children:"AuthKey_\u2026.p8"},void 0,!1,void 0,this),". Apple offers the download once."]},void 0,!0,void 0,this),t("li",{children:"The Key ID is in the list; the Issuer ID is above it."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),t("form",{class:"secret",onSubmit:u,autoComplete:"off",children:[t(Nt,{name:"p8",accept:".p8",label:"The .p8 file",file:n,onFile:s,hint:"It stays in memory on this computer until tapster stores it in the hub."},void 0,!1,void 0,this),t("div",{class:"grid2",children:[t(ge,{name:"keyId",label:"Key ID",mono:!0,placeholder:"ABCDE12345"},void 0,!1,void 0,this),t(ge,{name:"issuerId",label:"Issuer ID",mono:!0,placeholder:"00000000-0000-0000-0000-000000000000"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),t(x,{tone:"keys",title:"Where it goes",children:t("span",{children:["On a Mac, tapster asks Apple whether the key works before storing it. The key and its two IDs become secrets of the tapster environment in ",e.name,"."]},void 0,!0,void 0,this)},void 0,!1,void 0,this),t(N,{problem:r},void 0,!1,void 0,this),t("div",{class:"row",children:[t(L,{busy:a,class:"btn primary",type:"submit",children:"Check with Apple and store"},void 0,!1,void 0,this),o&&t("button",{type:"button",class:"btn quiet",onClick:()=>i(!1),children:"Cancel"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}var Ds=[5,10,15,20,30,60,120,180,360];function Os({f:e}){let n=e.change==="create"?"next":e.change==="update"?"warn":e.change==="remove"?"error":void 0,s={create:"New",update:"Changes",same:"Unchanged",remove:"Removed"}[e.change],o=e.change==="update"&&e.before!==null?rt(it(e.before,e.content)):null;return t("details",{class:"file",children:[t("summary",{children:[t(v,{name:"file"},void 0,!1,void 0,this),t("code",{children:e.path},void 0,!1,void 0,this),t(F,{tone:n,children:s},void 0,!1,void 0,this),t(v,{name:"down"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),t("pre",{class:"block diff",children:o?o.map((i,a)=>t("span",{class:i.kind==="gap"?"hunk":i.kind,children:[i.kind==="add"?"+ ":i.kind==="del"?"- ":i.kind==="gap"?"@ ":" ",i.text,`\n`]},a,!0,void 0,this)):e.change==="remove"?e.before:e.content},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function Rs({h:e}){let[n,s]=m(e.files.every),[o,i]=m([]),[a,r]=m(!1),[c,p]=m(null),[u,h,f]=fe(),[l,d,_]=fe(),[T,g]=m(!1),k=e.protect.others.map((b)=>b.file);U(()=>{f(async()=>p(await A("/api/hub/files/preview",{hub:e.name,every:n,remove:o,readme:a})))},[e.name,n,o.join(","),a]);let y=c?.files.filter((b)=>b.change!=="same")??[],H=()=>_(async()=>{let b=await A("/api/hub/files",{hub:e.name,every:n,remove:o,readme:a});g(!0),await W(),p(await A("/api/hub/files/preview",{hub:e.name,every:n,remove:[],readme:!1})),i([]),r(!1),Y("ok",b.result==="committed"?`Wrote the hub files to ${e.name}.`:"The hub files were already up to date.")});return t("div",{class:"panel",children:[t(J,{title:"Hub files",lead:"The hub\'s settings, its record of published releases, a README for your users and the workflow that does the work. tapster writes them to main in one commit."},void 0,!1,void 0,this),t("div",{class:"grid2",children:t("div",{class:"field",children:[t("label",{for:"every",children:"Look for new releases every"},void 0,!1,void 0,this),t("select",{id:"every",class:"input",value:String(n??(e.private?60:10)),onChange:(b)=>s(Number(b.currentTarget.value)),children:Ds.map((b)=>t("option",{value:b,children:b<60?`${b} minutes`:b===60?"hour":`${b/60} hours`},b,!1,void 0,this))},void 0,!1,void 0,this),t("span",{class:"hint",children:e.private?"A private hub bills every run as at least one minute; hourly keeps a hub within the free minutes.":"Public hubs run for free. The doorbell can start the hub right after each release."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),e.files.workflow==="newer"&&t(x,{tone:"warn",title:`The hub runs ${e.files.pinned}, newer than this tapster`,children:t("span",{children:["tapster keeps the hub\'s workflow, so it does not move the hub back. To change the workflow, run the latest: ",t("code",{children:"bunx @doguyilmaz/tapster@latest setup"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),k.length>0&&t("div",{class:"stack tight",children:[t("h3",{class:"section-title",children:"The tap\'s old workflows"},void 0,!1,void 0,this),k.map((b)=>t("label",{class:"switch",children:[t("input",{type:"checkbox",checked:o.includes(b),onChange:(w)=>i(w.currentTarget.checked?[...o,b]:o.filter((B)=>B!==b))},void 0,!1,void 0,this),t("span",{children:[t("strong",{children:["Remove .github/workflows/",b]},void 0,!0,void 0,this),t("span",{children:"It stops running once the hub is protected. Its commits would make the hub refuse to run."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},b,!0,void 0,this))]},void 0,!0,void 0,this),(c?.readme||a)&&t("label",{class:"switch",children:[t("input",{type:"checkbox",checked:a,onChange:(b)=>r(b.currentTarget.checked)},void 0,!1,void 0,this),t("span",{children:[t("strong",{children:"Replace README.md with tapster\'s"},void 0,!1,void 0,this),t("span",{children:"It tells your users how to install from the hub, including brew trust, which Homebrew asks for before it loads casks from a tap. Your current README goes away; the diff below shows both."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),u&&!c&&t("p",{class:"row muted",children:[t(j,{},void 0,!1,void 0,this)," Comparing with ",e.name]},void 0,!0,void 0,this),t(N,{problem:h},void 0,!1,void 0,this),c&&t("div",{class:"stack tight files",children:[t("div",{class:"spread",children:[t("h3",{class:"section-title",children:y.length?`${y.length} ${y.length===1?"change":"changes"} for main`:"main is up to date"},void 0,!1,void 0,this),t("span",{class:"muted small",children:["Workflow: ",c.pin]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),c.files.map((b)=>t(Os,{f:b},b.path,!1,void 0,this)),c.kept.length>0&&t("p",{class:"muted small",children:["Kept as they are: ",c.kept.join(", "),"."]},void 0,!0,void 0,this),c.notes.filter((b)=>!b.startsWith("The hub looks for new drafts every")).map((b)=>t("p",{class:"muted small",children:b},b,!1,void 0,this))]},void 0,!0,void 0,this),c&&c.foreign.length>0&&t(x,{tone:"error",title:"main changed in ways only you may change it",children:[t("ul",{class:"log",children:c.foreign.map((b)=>t("li",{children:b},b,!1,void 0,this))},void 0,!1,void 0,this),t("span",{children:"Review those commits on GitHub and revert what you did not make. tapster writes nothing to main until then, because a write from you would mark them as reviewed."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),t(N,{problem:d},void 0,!1,void 0,this),T&&t(x,{tone:"info",title:"Have a clone of the hub on this computer?",children:t("span",{children:["Run ",t("code",{children:"git pull"},void 0,!1,void 0,this)," in it, so it has the new files."]},void 0,!0,void 0,this)},void 0,!1,void 0,this),c&&y.length>0&&c.foreign.length===0&&t("div",{class:"row",children:t(L,{busy:l,class:"btn primary",onClick:H,children:["Write ",y.length===1?"the change":`the ${y.length} changes`," to main"]},void 0,!0,void 0,this)},void 0,!1,void 0,this),c&&y.length===0&&t(Vt,{text:"The hub files are up to date"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function Vs({h:e}){return t("div",{class:"panel",children:[t(J,{title:e.packages.length?"Your projects":"Add your first project",lead:"tapster finds the projects cloned on this computer and adds them to the hub: it prepares the release workflow, protects the repository and proposes the hub entry."},void 0,!1,void 0,this),e.packages.length>0&&t("div",{class:"card list",children:e.packages.map((n)=>t("div",{class:"item",children:[t("span",{children:[t("span",{class:"name",children:n.name},void 0,!1,void 0,this),t("span",{class:"path",children:[" ",n.repo]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),t(F,{children:n.kind==="app"?"Mac app":n.kind==="bun"?"Bun":"Go"},void 0,!1,void 0,this)]},n.name,!0,void 0,this))},void 0,!1,void 0,this),e.invalid.length>0&&t(x,{tone:"warn",title:"The hub leaves these entries out",children:t("ul",{class:"log",children:e.invalid.map((n)=>t("li",{children:[t("code",{children:n.name},void 0,!1,void 0,this),": ",n.reason]},n.name,!0,void 0,this))},void 0,!1,void 0,this)},void 0,!1,void 0,this),t("div",{class:"row",children:t("button",{type:"button",class:"btn primary",onClick:()=>ce("/projects"),children:[e.packages.length?"Add more projects":"Find my projects",t(v,{name:"arrow"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function js({h:e,label:n}){let[s,o]=m("ed25519"),[i,a]=m(null),[r,c]=m(!1),[p,u,h]=fe();if(!i)return t("form",{class:"card pad stack tight",onSubmit:(l)=>{l.preventDefault(),h(async()=>a(await A("/api/hub/sparkle/read",{hub:e.name,label:n,account:s})))},children:[t("strong",{children:["Sparkle key ",t("code",{children:n},void 0,!1,void 0,this)]},void 0,!0,void 0,this),t("p",{class:"muted small",children:"tapster reads it from your login keychain, where Sparkle\'s generate_keys keeps it. macOS asks you first; choose Allow."},void 0,!1,void 0,this),t("div",{class:"row",style:"flex-wrap: nowrap; align-items: end",children:[t(ge,{name:`account-${n}`,label:"Keychain account",value:s,mono:!0,onInput:o},void 0,!1,void 0,this),t(L,{busy:p,class:"btn primary",type:"submit",children:[t(v,{name:"key"},void 0,!1,void 0,this),"Read it from my keychain"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),t(N,{problem:u},void 0,!1,void 0,this)]},void 0,!0,void 0,this);let f=(l)=>{l.preventDefault();let d=String(new FormData(l.currentTarget).get("password")??"");h(async()=>{await A("/api/hub/sparkle/store",{hub:e.name,label:n,pasted:d}),jt(`sparkle-${n}`),await W(),Y("ok",`Stored the Sparkle key ${n} in the hub.`)})};return t("div",{class:"card pad stack tight",children:[t("strong",{children:["Sparkle key ",t("code",{children:n},void 0,!1,void 0,this)]},void 0,!0,void 0,this),t("p",{class:"muted small",children:["It signs updates for ",i.users.join(", "),". Its public key, ",t("code",{children:i.publicKey},void 0,!1,void 0,this),", matches tapster.yml."]},void 0,!0,void 0,this),t("div",{class:"cmd",children:[t("code",{children:r?i.key:"\u2022".repeat(32)},void 0,!1,void 0,this),t("button",{type:"button",class:"btn quiet small",onClick:()=>c(!r),"aria-pressed":r,children:r?"Hide":"Show"},void 0,!1,void 0,this),t(Pt,{text:i.key},void 0,!1,void 0,this)]},void 0,!0,void 0,this),t(x,{tone:"keys",title:"Keep a copy outside your Mac",children:t("span",{children:"If this key is lost, installed copies of the app can never update again. Paste it below: your password manager offers to save it when you store the key. tapster checks that the pasted key is the right one."},void 0,!1,void 0,this)},void 0,!1,void 0,this),t("form",{class:"secret",onSubmit:f,autoComplete:"on",children:[t(ge,{name:"username",label:"Name in your password manager",value:`${e.name}: Sparkle key ${n}`,autoComplete:"username"},void 0,!1,void 0,this),t($t,{name:"password",label:"Paste the key",hint:"The key from the box above, pasted as it is."},void 0,!1,void 0,this),t(N,{problem:u},void 0,!1,void 0,this),t("div",{class:"row",children:t(L,{busy:p,class:"btn primary",type:"submit",children:"Store in the hub"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function Fs({h:e}){let n=e.name.split("/")[1],s=e.extras.sparkle.filter((o)=>!o.stored);return t("div",{class:"panel",children:[t(J,{title:"Optional extras",lead:"The hub works without these. The doorbell and the apt and dnf key run in a terminal for now, in a clone of the hub, because they need Wrangler or gpg on your computer."},void 0,!1,void 0,this),t(z,{text:`gh repo clone ${e.name} && cd ${n}`},void 0,!1,void 0,this),t("section",{class:"stack tight",children:[t("div",{class:"spread",children:[t("h3",{class:"section-title",children:"Faster releases: the doorbell"},void 0,!1,void 0,this),t(F,{tone:e.extras.doorbell?"ok":void 0,children:e.extras.doorbell?"On":"Off"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),t("p",{class:"muted",children:"A small Worker on your own Cloudflare account starts the hub as soon as a project opens its draft, instead of at the next scheduled run. Wrangler asks you to sign in to Cloudflare in your browser."},void 0,!1,void 0,this),!e.extras.doorbell&&t(z,{text:"bunx @doguyilmaz/tapster init --doorbell"},void 0,!1,void 0,this),t("a",{href:"https://tapster.doguyilmaz.com/guides/doorbell/",target:"_blank",rel:"noopener noreferrer",class:"small",children:"Read the doorbell guide"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),t("section",{class:"stack tight",children:[t("div",{class:"spread",children:[t("h3",{class:"section-title",children:"apt and dnf repositories"},void 0,!1,void 0,this),t(F,{tone:e.extras.linux.stored?"ok":e.extras.linux.wanted?"warn":void 0,children:e.extras.linux.stored?"Key stored":e.extras.linux.wanted?"Key missing":"Off"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),t("p",{class:"muted",children:e.extras.linux.wanted&&!e.extras.linux.stored?"tapster.yml asks for Linux packages, but the hub has no key to sign them yet.":"Linux users install your command line tools with apt and dnf from the hub\'s GitHub Pages. tapster makes the signing key with gpg and keeps a copy in your keychain."},void 0,!1,void 0,this),!e.extras.linux.stored&&t(z,{text:"bunx @doguyilmaz/tapster init --linux"},void 0,!1,void 0,this),t("a",{href:"https://tapster.doguyilmaz.com/guides/linux/",target:"_blank",rel:"noopener noreferrer",class:"small",children:"Read the apt and dnf guide"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),e.extras.sparkle.length>0&&t("section",{class:"stack tight",children:[t("div",{class:"spread",children:[t("h3",{class:"section-title",children:"Sparkle keys"},void 0,!1,void 0,this),t(F,{tone:s.length?"warn":"ok",children:s.length?`${s.length} missing`:"All stored"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),t("p",{class:"muted",children:"Each Mac app signs its update feed with a Sparkle key. tapster keeps it in your keychain and in the hub."},void 0,!1,void 0,this),s[0]&&t(js,{h:e,label:s[0].label},s[0].label,!1,void 0,this),s.length>1&&t("p",{class:"muted small",children:["Then: ",s.slice(1).map((o)=>o.label).join(", "),". One key at a time, so your password manager saves each under its own name."]},void 0,!0,void 0,this),t("p",{class:"faint small",children:["No key yet? Make one in a terminal with ",t("code",{children:"bunx @doguyilmaz/tapster init --sparkle <label> --new"},void 0,!1,void 0,this),"; see the"," ",t("a",{href:"https://tapster.doguyilmaz.com/guides/sparkle/",target:"_blank",rel:"noopener noreferrer",children:"Sparkle guide"},void 0,!1,void 0,this),"."]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function Ls({h:e}){return t("div",{class:"card pad row",style:"gap: 1.25rem; flex-wrap: nowrap",children:[t("img",{src:"/courier.webp",alt:"",width:"96",height:"96",style:"border-radius: 20%; flex: none"},void 0,!1,void 0,this),t("div",{class:"stack tight",children:[t("h2",{class:"section-title",style:"font-size: 1.15rem",children:[e.name," is ready"]},void 0,!0,void 0,this),t("p",{class:"muted",children:"Push a version tag in a project and the hub signs and publishes it on its next run. Health shows how the hub is doing."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function Jn(){let e=le.value,[n,s]=m(()=>{let l=De.value;return De.value=null,l}),o=Te(null);if(Ee.value,_e.value)return t("div",{class:"stack",style:"max-width: 640px",children:[t(N,{problem:_e.value},void 0,!1,void 0,this),t("div",{class:"row",children:t("button",{type:"button",class:"btn secondary",onClick:()=>void W(),children:[t(v,{name:"refresh"},void 0,!1,void 0,this),"Try again"]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this);if(!e||e.name!==V.value)return t("p",{class:"row muted",role:"status",children:[t(j,{},void 0,!1,void 0,this)," Reading ",V.value," from GitHub"]},void 0,!0,void 0,this);let i=Dn(e.name),a=Bn(e,i),r=n??(Q.value?.kind==="created"?"app":Gn(a)),c=a.filter((l)=>l.state==="done"||l.state==="skipped").length,p=a.find((l)=>l.state==="now"||l.state==="attention"),u=(l)=>{if(s(l),window.matchMedia("(max-width: 900px)").matches)o.current?.scrollIntoView({behavior:"smooth",block:"start"})},h=(l,d)=>e.protect.environment?d:t($s,{h:e,what:l,onGo:()=>u("protect")},void 0,!1,void 0,this),f={extras:t(Fs,{h:e},void 0,!1,void 0,this),protect:t(Ps,{h:e},void 0,!1,void 0,this),app:e.app.id||e.app.held||Q.value?.kind==="unstored"?t(Yn,{h:e},void 0,!1,void 0,this):h("Create the GitHub App",t(Yn,{h:e},void 0,!1,void 0,this)),macos:t(Is,{h:e,choice:i},void 0,!1,void 0,this),certificate:h("Apple certificate",t(Es,{h:e},void 0,!1,void 0,this)),notary:h("Notarization key",t(Ms,{h:e},void 0,!1,void 0,this)),files:t(Rs,{h:e},void 0,!1,void 0,this),project:t(Vs,{h:e},void 0,!1,void 0,this)};return t("div",{class:"stack",style:"gap: 1.5rem",children:[t("div",{class:"spread",children:[t("div",{class:"stack tight",children:[t("p",{class:"eyebrow",children:[c," of ",a.length," done",p?`. Next: ${p.name}`:"",tt.value&&t(j,{label:"Checking GitHub"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),t("h1",{class:"title",children:p?`Set up ${e.name}`:`${e.name} is set up`},void 0,!1,void 0,this)]},void 0,!0,void 0,this),t(q,{href:e.url,class:"btn quiet",children:[e.name," on GitHub"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),t("div",{class:"progress","aria-hidden":"true",children:t("span",{style:`width: ${c/a.length*100}%`},void 0,!1,void 0,this)},void 0,!1,void 0,this),!p&&t(Ls,{h:e},void 0,!1,void 0,this),e.empty&&t(x,{tone:"info",title:`${e.name} has no commits yet`,children:"tapster gives it a first commit when it writes the hub files."},void 0,!1,void 0,this),t("div",{class:"setup",children:[t("ol",{class:"route","aria-label":"Setup steps",children:[a.map((l,d)=>t("li",{class:`${l.state}${l.id===r?" open":""}`,children:t("button",{type:"button",onClick:()=>u(l.id),"aria-current":l.id===r?"step":void 0,"aria-label":`${l.name}: ${l.status}${l.state==="now"?", next":l.state==="attention"?", needs you":""}`,children:[t(Hs,{stop:l,index:d},void 0,!1,void 0,this),t("span",{children:[t("span",{class:"stop-name",children:l.name},void 0,!1,void 0,this),t("span",{class:"stop-state",children:l.status},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},l.id,!1,void 0,this)),t("li",{class:`extra${r==="extras"?" open":""}`,children:t("button",{type:"button",onClick:()=>u("extras"),"aria-current":r==="extras"?"step":void 0,children:[t("span",{class:"dot",children:t(v,{name:"plus"},void 0,!1,void 0,this)},void 0,!1,void 0,this),t("span",{children:[t("span",{class:"stop-name",children:"Optional extras"},void 0,!1,void 0,this),t("span",{class:"stop-state",children:"Doorbell, apt and dnf, Sparkle"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),t("div",{class:"card pad stack",ref:o,style:"gap: 1.5rem",children:[f[r],(()=>{let l=a.findIndex((T)=>T.id===r),d=a[l],_=a.slice(l+1).find((T)=>T.state!=="done"&&T.state!=="skipped");if(!d||d.state!=="done"&&d.state!=="skipped"||!_)return null;return t("div",{class:"row",style:"border-top: 1px solid var(--line); padding-top: 1.25rem",children:t("button",{type:"button",class:"btn primary",onClick:()=>u(_.id),children:["Continue: ",_.name,t(v,{name:"arrow"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)})()]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}var ke=E({kind:"claiming"}),lt=E(!1);function Bs(){let e=new URLSearchParams(location.search),n=e.get("app");if(!n)return;let s=e.get("hub");if(s&&s!==V.value)ot(s);let o={reason:e.get("reason")??"the App could not be created",fix:e.get("fix")??"Try again."};if(n==="created")Q.value={kind:"created"};else if(n==="failed"||n==="unstored")Q.value={kind:n,problem:o};else Q.value={kind:"unknown"};history.replaceState(null,"",location.pathname)}async function Gs(){let e=/^#c=([0-9a-f]{32})$/.exec(location.hash)?.[1];if(location.hash)history.replaceState(null,"",location.pathname+location.search);if(e)try{await Pn(e)}catch(n){ke.value={kind:"failed",problem:R(n)};return}if(!An()){ke.value={kind:"no-session"};return}if(Bs(),ke.value={kind:"ready"},Z("/api/session").then((n)=>{if(Me.value=n,!V.value&&n.here.hub)ot(n.here.hub)}),await st(),V.value)W()}Hn(()=>{ke.value={kind:"no-session"}});async function Us(){try{await A("/api/quit")}catch{return}ke.value={kind:"stopped"}}function Ft({to:e,children:n}){let s=he.value===e||e==="/setup"&&he.value==="/";return t("a",{href:e,"aria-current":s?"page":void 0,onClick:(o)=>{o.preventDefault(),ce(e)},children:n},void 0,!1,void 0,this)}function Ws(){let e=oe.value;return t("header",{class:"top",children:[t("div",{class:"stripe"},void 0,!1,void 0,this),t("div",{class:"bar",children:[t("a",{class:"brand",href:"/setup",onClick:(n)=>{n.preventDefault(),ce("/setup")},children:[t("img",{src:"/logo.webp",alt:"",width:"28",height:"28"},void 0,!1,void 0,this),"tapster ",t("small",{children:"setup"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),V.value&&t("nav",{class:"nav","aria-label":"Sections",children:[t(Ft,{to:"/setup",children:"Setup"},void 0,!1,void 0,this),t(Ft,{to:"/projects",children:"Projects"},void 0,!1,void 0,this),t(Ft,{to:"/health",children:"Health"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),t("div",{class:"end",children:[V.value&&t("button",{type:"button",class:"picker",onClick:()=>lt.value=!0,"aria-label":`Hub: ${V.value}. Choose another hub`,children:[t(v,{name:"package"},void 0,!1,void 0,this),t("span",{children:V.value},void 0,!1,void 0,this),t(v,{name:"down"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),e?.state==="ok"&&t("span",{class:"who",children:["@",e.login]},void 0,!0,void 0,this),t("button",{type:"button",class:"btn quiet small",onClick:Us,title:"Stop tapster setup",children:[t(v,{name:"power"},void 0,!1,void 0,this),"Close"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function zs(){let e=ye.value;if(!e)return null;return t("div",{class:"toast",role:"status",onClick:()=>ye.value=null,children:t(x,{tone:e.tone==="ok"?"ok":"error",children:t("span",{children:e.text},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)}function qs(){if(!V.value||lt.value)return t(Ln,{onChosen:(e)=>{lt.value=!1,ot(e),ce("/setup",!0)},onCancel:V.value?()=>lt.value=!1:null},void 0,!1,void 0,this);if(he.value==="/projects")return t(qn,{},void 0,!1,void 0,this);if(he.value==="/health")return t(Fn,{},void 0,!1,void 0,this);return t(Jn,{},void 0,!1,void 0,this)}function Ks(){let e=ke.value;if(e.kind==="claiming")return t(It,{text:"Opening tapster setup"},void 0,!1,void 0,this);if(e.kind==="stopped")return t(Rn,{},void 0,!1,void 0,this);if(e.kind==="no-session"||e.kind==="failed")return t(On,{problem:e.kind==="failed"?e.problem:null},void 0,!1,void 0,this);let n=oe.value;if(!n)return t(It,{text:"Checking your GitHub sign-in"},void 0,!1,void 0,this);if(n.state!=="ok"||n.missing.length)return t(Vn,{},void 0,!1,void 0,this);return t(C,{children:[t(Ws,{},void 0,!1,void 0,this),t("main",{id:"main",children:t(qs,{},void 0,!1,void 0,this)},void 0,!1,void 0,this),t(zs,{},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}on(t(Ks,{},void 0,!1,void 0,this),document.getElementById("app"));Gs().catch((e)=>Y("error",R(e).reason));\n';import{timingSafeEqual as u2}from"crypto";var p2="default-src 'none'; script-src 'self'; style-src 'self'; img-src 'self' data:; connect-src 'self'; form-action 'self' https://github.com; frame-ancestors 'none'; base-uri 'none'",d2={"content-security-policy":p2,"x-content-type-options":"nosniff","referrer-policy":"no-referrer","cache-control":"no-store","cross-origin-opener-policy":"same-origin","cross-origin-resource-policy":"same-origin"};function Ve(e,t,n,r={}){return new Response(e,{status:t,headers:{...d2,...n?{"content-type":n}:{},...r}})}var st=(e,t=200)=>Ve(JSON.stringify(e),t,"application/json; charset=utf-8");function ny(e){if(e instanceof R)return{status:502,body:{error:{reason:e.reason,fix:e.fix}}};if(e instanceof v)return{status:400,body:{error:{reason:e.reason,fix:e.fix}}};return{status:500,body:{error:{reason:"tapster hit an unexpected error",fix:"The terminal that runs tapster setup shows the details. Try again; if it repeats, open an issue at https://github.com/doguyilmaz/tapster/issues."}}}}function ry(e,t){return e===`127.0.0.1:${t}`||e===`localhost:${t}`}function iy(e,t){let n=/^Bearer ([0-9a-f]{64})$/.exec(e??"")?.[1];if(!n)return!1;let r=Buffer.from(n),i=Buffer.from(t);return r.length===i.length&&u2(r,i)}var sy=`:root {
1101
1101
  --page: #f3f4f6;
1102
1102
  --paper: #ffffff;
@@ -1397,14 +1397,14 @@ select.input { appearance: auto; }
1397
1397
  <noscript><p class="noscript">tapster setup needs JavaScript. The same steps work in a terminal: tapster init and tapster add.</p></noscript>
1398
1398
  </body>
1399
1399
  </html>
1400
- `;function Ls(e,t){let n={deps:e,port:t,token:gl(32).toString("hex"),codes:new Map,claimed:new Set,pending:new Map,apps:new Map,sparkle:new Map,touched:Date.now(),login:null,link:()=>{let r=gl(16).toString("hex");return n.codes.set(r,Date.now()+f2),`http://127.0.0.1:${n.port}/#c=${r}`}};return n}async function se(e,t){let n;try{n=await e.json()}catch{throw new v("the request was not JSON","Reload the page and try again.")}let r=t.safeParse(n);if(!r.success)throw new v("the request did not have the expected fields","Reload the page and try again.");return r.data}function v2(e,t){if(typeof t!=="string"||!/^[0-9a-f]{32}$/.test(t))return st({error:{reason:"this link is not a tapster setup link",fix:"Press Enter in the terminal that runs tapster setup for a fresh link."}},400);if(e.claimed.has(t))return e.token=gl(32).toString("hex"),e.codes.clear(),e.deps.log("tapster setup: the same link was opened twice, so tapster ended every session for safety."),e.deps.log(`Open this fresh link in your browser: ${e.link()}`),st({error:{reason:"this link was already used",fix:"tapster ended every session for safety. Open the fresh link the terminal printed."}},409);let n=e.codes.get(t);if(n===void 0||n<Date.now())return st({error:{reason:"this link has expired",fix:"Press Enter in the terminal that runs tapster setup for a fresh link."}},410);return e.codes.delete(t),e.claimed.add(t),e.touched=Date.now(),st({token:e.token})}function cy(e,t,n){return async(r)=>{if(!ry(r.headers.get("host"),e.port))return Ve("Misdirected request",421,"text/plain; charset=utf-8");let i=new URL(r.url),s=i.pathname;if(r.method==="GET"&&m2.has(s))return Ve(g2,200,"text/html; charset=utf-8");if(r.method==="GET"&&s==="/app.css")return Ve(sy,200,"text/css; charset=utf-8");if(r.method==="GET"&&s==="/app.js")return Ve(await ty(),200,"text/javascript; charset=utf-8");if(r.method==="GET"&&ay[s])return Ve(new Uint8Array(ay[s]),200,"image/webp");if(r.method==="GET"&&s==="/app/callback")return n({s:e,req:r,url:i});if(r.method==="POST"&&s==="/api/claim"){let a=await r.json().catch(()=>null);return v2(e,a?.code)}if(!s.startsWith("/api/"))return Ve("Not found",404,"text/plain; charset=utf-8");if(!iy(r.headers.get("authorization"),e.token))return st({error:{reason:"this page is not signed in to tapster setup",fix:"Press Enter in the terminal that runs tapster setup for a fresh link."}},401);e.touched=Date.now();let o=t[`${r.method} ${s}`];if(!o)return st({error:{reason:"unknown request",fix:"Reload the page."}},404);try{return st(await o({s:e,req:r,url:i})??{})}catch(a){let c=ny(a);if(c.status===500)e.deps.log(`tapster setup: ${r.method} ${s} failed: ${fn(a instanceof Error?`${a.name}: ${a.message}`:"unknown error")}`);return st(c.body,c.status)}}}var b2=/^[A-Za-z0-9-]+\/homebrew-[A-Za-z0-9._-]+$/,w2="tapster: the hub needs attention";async function _2(e){let t;try{t=await e.deps.github()}catch(o){if(o instanceof v&&/not installed/.test(o.reason))return{state:"no-gh"};return{state:"signed-out"}}let n;try{n=await t.request("GET","/user")}catch(o){if(o instanceof R&&o.status===401)return{state:"signed-out"};throw o}let r=await n.json();e.login=r.login;let i=n.headers.get("x-oauth-scopes"),s=i===null?null:i.split(",").map((o)=>o.trim());return{state:"ok",login:r.login,missing:s===null?[]:["repo","workflow"].filter((o)=>!s.includes(o))}}async function Ye(e){let t=await e.deps.github();return e.login??=(await t.json("GET","/user")).login,{gh:t,login:e.login}}function ot(e,t){if(typeof e!=="string"||!b2.test(e))throw new v("that is not a hub name","A hub is one of your repositories whose name starts with homebrew-, such as you/homebrew-tap.");if(e.split("/")[0].toLowerCase()!==t.toLowerCase())throw new v(`${e} does not belong to ${t}`,"tapster serves repositories of your own account.");return e}async function we(e,t){let{gh:n,login:r}=await Ye(e.s);return{gh:n,hub:ot(t,r),login:r}}var vl=async(e)=>{try{return await e}catch(t){if(t instanceof R&&t.status===404)return null;throw t}},ly=async(e,t)=>{try{return(await e.json("GET",`/repos/${t}/git/ref/heads/main`)).object.sha}catch(n){if(n instanceof R&&(n.status===404||n.status===409))return null;throw n}};async function yl(e,t){let n=[];for(let i=1;i<=5;i++){let s=await e.json("GET",`/user/repos?affiliation=owner&sort=updated&per_page=100&page=${i}`);if(n.push(...s),s.length<100)break}let r=n.filter((i)=>i.name.startsWith("homebrew-")&&i.owner.login.toLowerCase()===t.toLowerCase());return Promise.all(r.map(async(i)=>({name:i.full_name,private:i.private,url:i.html_url,tapster:await vl(e.json("GET",`/repos/${i.full_name}/environments/tapster`))!==null})))}function k2(e){let t=[];for(let[n,r]of Object.entries(e)){if(n==="tapster.yml")continue;let i;try{i=ne(r)}catch{t.push({file:n,actions:["(the file is not valid YAML)"]});continue}let s=i?.jobs??{},a=Object.values(s).flatMap((c)=>[c?.uses,...(c?.steps??[]).map((l)=>l?.uses)]).filter((c)=>typeof c==="string").filter((c)=>{if(c.startsWith("./"))return!1;let[l,u]=c.split("@"),p=(l??"").split("/")[0].toLowerCase();return!(p==="actions"||p==="github"||(l??"").toLowerCase()==="doguyilmaz/tapster")||!/^[0-9a-f]{40}$/.test(u??"")});if(a.length)t.push({file:n,actions:[...new Set(a)]})}return t}async function bl(e,t,n){let r=await t.json("GET",`/repos/${n}`),s=await ly(t,n)===null,o=await vl(t.json("GET",`/repos/${n}/environments/tapster`)),a=async(I)=>o?(await t.json("GET",`/repos/${n}/environments/tapster/${I}?per_page=100`))[I]??[]:[],[c,l,u,p,d,h]=await Promise.all([a("variables"),a("secrets"),o?t.json("GET",`/repos/${n}/environments/tapster/deployment-branch-policies`):Promise.resolve({branch_policies:[]}),t.json("GET",`/repos/${n}/rulesets`).catch(()=>[]),t.json("GET",`/repos/${n}/actions/permissions`),t.json("GET",`/repos/${n}/actions/permissions/workflow`)]),f=await Promise.all(p.map((I)=>t.json("GET",`/repos/${n}/rulesets/${I.id}`))),m=d.allowed_actions==="selected"?await t.json("GET",`/repos/${n}/actions/permissions/selected-actions`):null,g=(I)=>s?Promise.resolve(null):de(t,n,I,"main"),[w,k,_,y,x]=await Promise.all([g("tapster.yml"),g(".tapster/state.json"),g("README.md"),g(J),s?Promise.resolve([]):t.json("GET",`/repos/${n}/contents/.github/workflows?ref=main`).catch(()=>[])]),S={};for(let I of x.filter((Kt)=>Kt.type==="file"&&/\.ya?ml$/.test(Kt.name)))S[I.name]=await g(`.github/workflows/${I.name}`)??"";let O=(I)=>I.map((Kt)=>Kt.name),A=(I)=>c.find((Kt)=>Kt.name===I)?.value??null,D=w===null?null:(()=>{try{return ie(w,n.split("/")[0])}catch{return null}})(),ce=Boolean(o?.deployment_branch_policy?.custom_branch_policies)&&u.branch_policies.length===1&&u.branch_policies[0].name==="main",ke=[{label:"a tapster environment that only main may open",ok:ce},{label:"main cannot be deleted or force-pushed",ok:nl(f).ok},{label:"workflows run only GitHub's and tapster's actions, pinned by commit",ok:rl(d,m).ok},{label:"the workflows' default token is read-only",ok:h.default_workflow_permissions==="read"}],B=A("TAPSTER_APP_ID"),Tt=e.apps.get(n),qy=D?.config.packages.some(is)??!1,By=Boolean(A("TAPSTER_TEAM_ID"))||O(l).includes("MACOS_NOTARY_KEY"),Fs=y?Bt.exec(y):null,An=(await t.json("GET",`/repos/${n}/issues?state=open&creator=${encodeURIComponent("github-actions[bot]")}&per_page=100`).catch(()=>[])).find((I)=>I.title===w2&&I.user?.login==="github-actions[bot]");return{name:n,url:r.html_url,private:r.private,empty:s,protect:{done:ke.every((I)=>I.ok),environment:ce,checks:ke,others:k2(S)},app:{id:B,slug:A("TAPSTER_APP_SLUG"),key:O(l).includes("TAPSTER_APP_PRIVATE_KEY"),held:Boolean(Tt),installed:Tt?await uy(e,n):null},apple:{needed:By||qy?!0:null,certificate:A("TAPSTER_TEAM_ID")?{team:A("TAPSTER_TEAM_ID"),expires:A("TAPSTER_CERT_EXPIRES")??""}:null,certificateStored:["MACOS_SIGN_P12","MACOS_SIGN_PASSWORD"].every((I)=>O(l).includes(I)),notary:["MACOS_NOTARY_KEY","MACOS_NOTARY_KEY_ID","MACOS_NOTARY_ISSUER_ID"].every((I)=>O(l).includes(I))},files:{config:w!==null,state:k!==null,readme:_!==null,workflow:el(y,ae,e.deps.pin),pinned:Fs?`${Fs[2]} (${Fs[1].slice(0,7)})`:null,every:y?rt(y):null},packages:(D?.config.packages??[]).map((I)=>({name:I.name,repo:I.repo,kind:Y(I)?"app":I.kind})),invalid:(D?.invalid??[]).map((I)=>({name:I.name,reason:I.reason})),issue:An?{url:An.html_url,number:An.number,updated:An.updated_at,body:An.body??""}:null,extras:{doorbell:A("TAPSTER_DOORBELL")!==null,linux:{wanted:D?.config.packages.some((I)=>!Y(I)&&I.linux)??!1,stored:O(l).includes("TAPSTER_LINUX_KEY")},sparkle:(D?Ee(D.config):[]).map((I)=>({label:I,stored:O(l).includes(`SPARKLE_KEY_${I.toUpperCase()}`)}))}}}async function uy(e,t){let n=e.apps.get(t);if(!n)return{checked:!1,id:null,onHub:!1,repos:[]};let r=t.split("/")[0],i=await Cs(n.id,n.pem,r,t,new pe(Be(n.id,n.pem),e.deps.fetch)),s=i.id===null?[]:await Mg(n.id,n.pem,r,e.deps.fetch)??[];return{checked:!0,id:i.id,onHub:i.onHub,repos:s}}async function wn(e,t){let n=await vl(e.json("GET",`/repos/${t}/environments/tapster`)),r=n?await e.json("GET",`/repos/${t}/environments/tapster/deployment-branch-policies`):{branch_policies:[]};if(!(Boolean(n?.deployment_branch_policy?.custom_branch_policies)&&r.branch_policies.length===1&&r.branch_policies[0].name==="main"&&(r.branch_policies[0].type??"branch")==="branch"))throw new v(`${t}'s tapster environment is not locked to main`,"Protect the hub first: keys go into that environment only once workflows on other branches cannot open it.")}async function py(e,t,n){let i=(await ml(e,t,n).catch((s)=>{if(s instanceof R&&s.status===404)return[];throw s})).filter((s)=>!s.startsWith("GitHub shows no push by"));if(i.length)throw new v(`main changed in ways only you may change it: ${i.join("; ")}`,"Review those commits on GitHub and revert what you did not make. tapster writes nothing to main until then, because a write from you would mark them as reviewed.")}var Ms=N({hub:E()}).strict();async function x2(e){let{hub:t}=await se(e.req,Ms),{gh:n}=await we(e,t),r=await n.json("GET",`/repos/${t}`);return await fl(n,t,r.private),{done:!0}}async function S2(e){let{hub:t}=await se(e.req,Ms),{gh:n,login:r}=await we(e,t);await wn(n,t);let i=y2(16).toString("hex");for(let[o,a]of e.s.pending)if(Date.now()-a.at>3600000)e.s.pending.delete(o);e.s.pending.set(i,{hub:t,owner:r,at:Date.now()});let s=Os(r,t,`http://127.0.0.1:${e.s.port}/app/callback`);return{action:`https://github.com/settings/apps/new?state=${i}`,manifest:JSON.stringify(s),permissions:Mc(s),name:s.name}}async function dy(e){let t=(o)=>new Response(null,{status:303,headers:{location:`/setup?${new URLSearchParams(o)}`,"cache-control":"no-store","referrer-policy":"no-referrer"}}),n=e.url.searchParams.get("state")??"",r=e.url.searchParams.get("code")??"",i=e.s.pending.get(n);if(!i||!/^[A-Za-z0-9_-]{1,128}$/.test(r))return t({app:"unknown"});e.s.pending.delete(n);let s;try{s=await Uc(r,i.owner,"If GitHub created the App anyway, delete it at https://github.com/settings/apps first, because its name would block a new one. Then create it again.",e.s.deps.fetch)}catch(o){let a=o instanceof v?o:new v("GitHub did not hand over the new App","Try again from Setup.");return t({app:"failed",hub:i.hub,reason:a.reason,fix:a.fix})}e.s.apps.set(i.hub,{id:String(s.id),pem:s.pem,slug:s.slug});try{return await wn(await e.s.deps.github(),i.hub),await Pr(i.hub,s),t({app:"created",hub:i.hub})}catch(o){let a=o instanceof v?o:new v("the App's key could not be stored","Try again.");return t({app:"unstored",hub:i.hub,reason:a.reason,fix:a.fix})}}async function A2(e){let{hub:t}=await se(e.req,Ms),{gh:n}=await we(e,t);await wn(n,t);let r=e.s.apps.get(t);if(!r)throw new v("this setup no longer holds the App's key","GitHub hands the key over only once. Delete the App at https://github.com/settings/apps, then create it again here.");return await Pr(t,{id:Number(r.id),slug:r.slug,pem:r.pem}),{stored:!0}}async function $2(e){let{hub:t}=await we(e,e.url.searchParams.get("hub"));return uy(e.s,t)}var hy=(e,t,n)=>{let r=e.get(t);if(!(r instanceof File)||r.size===0)throw new v(`no ${t} file was attached`,"Choose the file and try again.");if(r.size>n)throw new v(`that ${t} file is too large`,"Choose the file Apple or Keychain Access gave you.");return r.arrayBuffer().then((i)=>new Uint8Array(i))};async function fy(e){try{return await e.req.formData()}catch{throw new v("the form could not be read","Reload the page and try again.")}}async function P2(e){let t=await fy(e),{gh:n,hub:r}=await we(e,t.get("hub"));await wn(n,r);let i=await hy(t,"p12",ol),s=String(t.get("password")??""),o=await Rs(i,s);return await Is(r,i,s,o),o}async function T2(e){let t=await fy(e),{gh:n,hub:r}=await we(e,t.get("hub"));await wn(n,r);let i=Ns(await hy(t,"p8",al),String(t.get("keyId")??""),String(t.get("issuerId")??"")),s=await e.s.deps.notary(i);return await js(r,i),{checked:s}}var my=N({hub:E(),every:_c().int().nullable(),remove:X(E()).max(20),readme:tt()}).strict();async function gy(e,t,n,r,i,s,o){let a=await t.json("GET",`/repos/${n}`),c=await As(t,n,o,e.s.deps.pin,{every:r,isPrivate:a.private}),l=el(await o(J),ae,e.s.deps.pin)==="newer",u=[];for(let f of c.files.filter((m)=>!(l&&m.path===J)))u.push({path:f.path,content:f.content,before:f.before,change:f.before===null?"create":f.before===f.content?"same":"update"});let p=Ss(n).find((f)=>f.path==="README.md"),d=c.kept.includes("README.md")?await o("README.md"):null;if(s&&d!==null&&d!==p.content)u.push({path:"README.md",content:p.content,before:d,change:"update"});let h=i.filter((f)=>/^[A-Za-z0-9._-]+\.ya?ml$/.test(f)&&f!=="tapster.yml");for(let f of h){let m=await o(`.github/workflows/${f}`);if(m!==null)u.push({path:`.github/workflows/${f}`,content:"",before:m,change:"remove"})}return{files:u,kept:c.kept,pin:l?"kept: the hub runs a newer tapster than this one":c.change,notes:l?[]:c.notes,foreign:[],readme:d!==null&&d!==p.content}}async function E2(e){let t=await se(e.req,my),{gh:n,hub:r,login:i}=await we(e,t.hub),s=await gy(e,n,r,t.every,t.remove,t.readme,(a)=>de(n,r,a,"main")),o=await ml(n,r,i).catch(()=>[]);return{...s,foreign:o.filter((a)=>!a.startsWith("GitHub shows no push by"))}}async function O2(e){let t=await se(e.req,my),{gh:n,hub:r,login:i}=await we(e,t.hub);if(await ly(n,r)===null){let o=Ss(r).find((a)=>a.path==="README.md");if(await n.json("PUT",`/repos/${r}/contents/README.md`,{message:"Start the tap",content:Buffer.from(o.content).toString("base64"),branch:"main"}),(await n.json("GET",`/repos/${r}`)).default_branch!=="main")await n.json("PATCH",`/repos/${r}`,{default_branch:"main"})}return await py(n,r,i),{result:await Qc(n,r,"Set up tapster",async(o)=>(await gy(e,n,r,t.every,t.remove,t.readme,o)).files.filter((c)=>c.change!=="same").map((c)=>({path:c.path,content:c.change==="remove"?null:c.content})))}}async function C2(e){let t=await se(e.req,N({name:E().regex(/^homebrew-[A-Za-z0-9._-]{1,80}$/),private:tt()}).strict()),{gh:n,login:r}=await Ye(e.s);try{return{hub:(await n.json("POST","/user/repos",{name:t.name,private:t.private,auto_init:!1,description:"Homebrew tap, published by tapster"})).full_name}}catch(i){if(i instanceof R&&i.status===422)throw new v(`${r}/${t.name} already exists`,"Pick it from the list instead.");throw i}}var R2=N({hub:E(),label:E().regex(/^[a-z0-9]{1,40}$/),account:E().regex(/^[A-Za-z0-9 ._@-]{1,64}$/)}).strict();async function vy(e,t,n){let r=await de(e,t,"tapster.yml","main"),i=r===null?null:ie(r,t.split("/")[0]).config;if(!i||!Ee(i).includes(n))throw new v(`no app in ${t}'s tapster.yml signs with the Sparkle key ${n}`,"Add the app with its sparkle section first.");return i}async function I2(e){let t=await se(e.req,R2),{gh:n,hub:r}=await we(e,t.hub),i=await vy(n,r,t.label),s=await e.s.deps.keychain(t.account);if(s===null)throw new v(`your keychain gave no Sparkle key for the account ${t.account}`,"Choose Allow when macOS asks. generate_keys uses the account ed25519 unless you passed --account.");let o=Es(s),a=hl(i,t.label,o.publicKey);return e.s.sparkle.set(`${r} ${t.label}`,{seed:s.trim(),at:Date.now()}),{publicKey:o.publicKey,users:a,key:s.trim()}}async function N2(e){let t=await se(e.req,N({hub:E(),label:E().regex(/^[a-z0-9]{1,40}$/),pasted:E().max(400)}).strict()),{gh:n,hub:r,login:i}=await we(e,t.hub),s=e.s.sparkle.get(`${r} ${t.label}`);if(!s||Date.now()-s.at>1800000)throw new v("read the key from your keychain first","Click Read it from my keychain again.");if(t.pasted.trim()!==s.seed)throw new v("that is not the key shown above","Paste the key itself, so the copy your password manager keeps is the right one.");let o=await vy(n,r,t.label);await wn(n,r),await py(n,r,i),await ee(r,`SPARKLE_KEY_${t.label.toUpperCase()}`,s.seed);let a=await Qc(n,r,`Pass the Sparkle key ${t.label} to the hub workflow`,async(c)=>{let l=await c(J);if(l===null)return[];let u=xs(l,Ee(o));return u===l?[]:[{path:J,content:u}]});return e.s.sparkle.delete(`${r} ${t.label}`),{stored:!0,workflow:a}}async function z2(e){let{gh:t,hub:n}=await we(e,e.url.searchParams.get("hub")),[{checks:r,note:i},s]=await Promise.all([$r(t,n),t.json("GET",`/repos/${n}/actions/workflows/tapster.yml/runs?per_page=8`).catch(()=>({workflow_runs:[]}))]);return{checks:r,note:i,runs:s.workflow_runs.map((o)=>({id:o.id,url:o.html_url,event:o.event,status:o.status,conclusion:o.conclusion,created:o.created_at}))}}async function j2(e){let{hub:t}=await se(e.req,Ms),{gh:n}=await we(e,t);return await n.json("POST",`/repos/${t}/actions/workflows/tapster.yml/dispatches`,{ref:"main"}),{started:!0}}var yy={"GET /api/account":(e)=>_2(e.s),"GET /api/hubs":async(e)=>{let{gh:t,login:n}=await Ye(e.s);return{hubs:await yl(t,n)}},"POST /api/hubs":C2,"GET /api/hub":async(e)=>{let{gh:t,hub:n}=await we(e,e.url.searchParams.get("hub"));return bl(e.s,t,n)},"POST /api/hub/protect":x2,"POST /api/hub/app":S2,"POST /api/hub/app/store":A2,"GET /api/hub/installation":$2,"POST /api/hub/certificate":P2,"POST /api/hub/notary":T2,"POST /api/hub/files/preview":E2,"POST /api/hub/files":O2,"GET /api/hub/health":z2,"POST /api/hub/run":j2,"POST /api/hub/sparkle/read":I2,"POST /api/hub/sparkle/store":N2};import{existsSync as Bs,lstatSync as xy,readdirSync as Ay}from"fs";import{isAbsolute as xl,join as je,normalize as $y,resolve as Py}from"path";import{lstatSync as wl,readdirSync as D2,realpathSync as ky}from"fs";import{dirname as L2,join as Ft,resolve as Us,sep as by}from"path";var M2=new Set(["node_modules","Library","Applications","Pictures","Music","Movies","Documents","Desktop","Downloads","Public","vendor","Pods","DerivedData","build","dist","target","out"]),U2=["Developer","Projects","projects","code","Code","src","dev","git","GitHub","repos","workspace","work"];var Z2=(e)=>{try{return wl(e).isFile()}catch{return!1}};function _l(e){let t=/\[remote "origin"\]([\s\S]*?)(?=\n\s*\[|$)/.exec(e)?.[1]??"",n=/^\s*url\s*=\s*(\S+)\s*$/m.exec(t)?.[1]??"";return/^(?:https:\/\/github\.com\/|git@github\.com:|ssh:\/\/git@github\.com\/)([A-Za-z0-9-]+\/[A-Za-z0-9._-]+?)(?:\.git)?\/?$/.exec(n)?.[1]??null}function kl(e,t){let n=(r)=>t.includes(r)&&Z2(Ft(e,r));if(t.some((r)=>r==="project.yml"||r==="Package.swift"||r.endsWith(".xcodeproj")))return{kind:"app",why:null};if(n("go.mod"))return n(".goreleaser.yaml")||n(".goreleaser.yml")?{kind:"go",why:null}:{kind:null,why:"a Go project without GoReleaser"};if(n("package.json")){if(!n("bun.lock")&&!n("bun.lockb"))return{kind:null,why:"a JavaScript project without Bun"};let r=null;try{r=JSON.parse(oe(Ft(e,"package.json"))??"{}").bin}catch{r=null}return r?{kind:"bun",why:null}:{kind:null,why:"a Bun project without a command (no bin in package.json)"}}return{kind:null,why:"no build that tapster knows"}}function Zs(e,t){return[t,L2(t),...U2.map((n)=>Ft(e,n))].filter((n)=>Gs(n,e)&&n!==Us(e))}var wy=(e,t)=>e===t||e.startsWith(t.endsWith(by)?t:`${t}${by}`),_y=(e)=>{try{return ky(e)}catch{return Us(e)}};function Gs(e,t){return wy(Us(e),Us(t))||wy(_y(e),_y(t))}function qs(e,t={}){let n=t.depth??3,r=t.maxDirs??4000,i=t.deadline??Date.now()+3000,s=new Set,o=[],a=0,c=!1,l=(u,p)=>{if(a>=r||Date.now()>i){c=!0;return}let d;try{d=ky(u)}catch{return}if(s.has(d))return;s.add(d),a++;let h;try{h=D2(d)}catch{return}if(h.includes(".git")){let f=null;try{f=wl(Ft(d,".git"))}catch{f=null}let m=f?.isDirectory()?oe(Ft(d,".git","config"),65536):null,g=m?_l(m):null;if(g)o.push({path:u,repo:g,owner:g.split("/")[0],inHub:!1,proposed:null,...kl(d,h)});return}if(p>=n)return;for(let f of h){if(f.startsWith(".")||M2.has(f))continue;try{if(!wl(Ft(d,f)).isDirectory())continue}catch{continue}l(Ft(u,f),p+1)}};for(let u of e)l(u,0);return{found:o,truncated:c}}var Sy="Release through the tapster hub";function Nr(e,t){if(typeof e!=="string"||!xl(e))throw new v("that is not a full folder path","Give the folder's full path, such as /Users/you/Developer/my-tool.");let n=Py($y(e));if(!Gs(n,t))throw new v(`${n} is outside your home folder`,"tapster reads clones inside your home folder only.");let r;try{r=xy(n)}catch{throw new v(`${n} does not exist`,"Check the path.")}if(!r.isDirectory())throw new v(`${n} is not a folder`,"Give the folder of the clone.");if(!Bs(je(n,".git"))||!xy(je(n,".git")).isDirectory())throw new v(`${n} is not a git clone`,"Give the top folder of a clone, the one that holds .git.");return n}function zr(e,t){let n=_l(oe(je(e,".git","config"),65536)??"");if(!n)throw new v("this clone's origin is not a GitHub repository","tapster adds clones whose origin is on github.com.");if(n.split("/")[0].toLowerCase()!==t.toLowerCase())throw new v(`${n} does not belong to ${t}`,"tapster publishes repositories of your own account.");return n}async function _n(e,t,n={}){let r=n.user?{...process.env,GIT_TERMINAL_PROMPT:"0",GIT_SSH_COMMAND:process.env.GIT_SSH_COMMAND??"ssh -o BatchMode=yes"}:{GIT_TERMINAL_PROMPT:"0"};return L(mn.git,"git",["-C",e,...t],{env:r,allowFail:!0,timeoutMs:n.timeoutMs??20000,maxOutput:4194304})}async function Ty(e,t){let n=await _n(e,["cat-file","-p",`HEAD:${t}`]);return n.code===0?n.stdout:null}function G2(e){let t=oe(je(e,".git","HEAD"),4096)?.trim()??"";return/^ref: refs\/heads\/(.+)$/.exec(t)?.[1]??"a detached HEAD"}async function q2(e,t){let n=[];for(let r of t){let i=oe(je(e,r));if(i!==null&&i!==await Ty(e,r))n.push(r)}return n}var Ey={hub:E()};async function B2(e){let t=await se(e.req,N({hub:E(),extra:X(E()).max(10)}).strict()),{gh:n,login:r}=await Ye(e.s),i=ot(t.hub,r),s=t.extra.map((m)=>Py(m)).filter((m)=>xl(m)&&Gs(m,e.s.deps.home)&&Bs(m)),o=[...new Set([...s,...Zs(e.s.deps.home,e.s.deps.cwd)])].filter((m)=>Bs(m)),{found:a,truncated:c}=qs(o),l=await de(n,i,"tapster.yml","main").catch(()=>null),u=new Set(l?ie(l,r).config.packages.map((m)=>m.repo.toLowerCase()):[]),p=await n.json("GET",`/repos/${i}/pulls?state=open&per_page=100`).catch(()=>[]),d=new Map(p.filter((m)=>m.head?.ref?.startsWith("tapster-add-")).map((m)=>[m.head.ref.slice(12),m.html_url])),h=a.filter((m)=>m.owner.toLowerCase()===r.toLowerCase()&&m.repo.toLowerCase()!==i.toLowerCase());return{projects:[...new Map(h.map((m)=>[m.path,m])).values()].map(({owner:m,...g})=>({...g,inHub:u.has(g.repo.toLowerCase()),proposed:d.get(_s(g.repo))??null})).sort((m,g)=>Number(g.kind!==null)-Number(m.kind!==null)||m.repo.localeCompare(g.repo)),roots:o,others:a.length-h.length,truncated:c}}function H2(e){let t=je(e,".github","workflows"),n;try{n=Ay(t).filter((r)=>/^[A-Za-z0-9._-]+\.ya?ml$/.test(r))}catch{return[]}return n.filter((r)=>(oe(je(t,r))??"").includes("goreleaser/goreleaser-action")).sort()}async function F2(e){let t=await se(e.req,N({...Ey,path:E()}).strict()),{gh:n,login:r}=await Ye(e.s),i=ot(t.hub,r),s=Nr(t.path,e.s.deps.home),o=zr(s,r),a=_s(o),c=Ay(s),{kind:l,why:u}=kl(s,c);if(l==="app"&&!Vc(s))l=null,u="an Xcode project without a Sparkle feed (SUFeedURL ending in /releases/latest/download/<name>.xml)";if(l==="bun"){let x=oe(je(s,"package.json")),S=null;try{S=x?JSON.parse(x):null}catch{S=null}if(!S||!bs(S,a))l=null,u="package.json has no bin entry, so there is no command to publish"}if(l===null)throw new v(`tapster cannot publish ${o} yet: it is ${u}`,"tapster publishes GoReleaser Go tools, Bun command line tools and Mac apps that update with Sparkle.");let p=l==="go"?H2(s):[],d=oe(je(s,".github","workflows","release.yml")),h=await q2(s,[".github/workflows/release.yml",".goreleaser.yaml",".goreleaser.yml",...p.map((x)=>`.github/workflows/${x}`)]),f=G2(s),[m,g,w]=await Promise.all([n.getRepo(o),Sr(n,i).catch(()=>null),de(n,i,"tapster.yml","main").catch(()=>null)]),k=await gr(n,o,m.default_branch,"admin").catch(()=>["unknown"]),_=await n.json("GET",`/repos/${i}/pulls?state=open&head=${encodeURIComponent(`${r}:tapster-add-${a}`)}`).catch(()=>[]),y=w?ie(w,r).config.packages.some((x)=>x.repo.toLowerCase()===o.toLowerCase()):!1;if(!g)throw new v(`${i} has no App yet`,"Finish the hub's setup first.");return{path:s,repo:o,name:a,kind:l,branch:f,defaultBranch:m.default_branch,dirty:[...new Set(h)],workflows:p,workflow:p.includes("release.yml")?"release.yml":p[0]??null,releaseFlow:d===null?"missing":d.includes("Ring the tapster hub")?"ours":"other",dependabot:[".github/dependabot.yml",".github/dependabot.yaml"].some((x)=>Bs(je(s,x))),private:m.private,protected:k.length===0,inHub:y,proposed:_[0]?.html_url??null,apple:g.apple}}var K2=N({...Ey,path:E(),options:N({workflow:E().regex(/^[A-Za-z0-9._-]+\.ya?ml$/),autoTag:tt(),dependabot:tt(),force:tt()}).strict()}).strict();async function W2(e){let t=await se(e.req,K2),{gh:n,login:r}=await Ye(e.s),i=ot(t.hub,r),s=Nr(t.path,e.s.deps.home),o=zr(s,r),a=t.options,c=Yc([...a.force?["--force"]:[],...a.autoTag?["--auto-tag"]:[],...a.dependabot?["--allow-dependabot"]:[],"--workflow",a.workflow]),l=await Sr(n,i);await _n(s,["config","tapster.hub",i],{user:!0});let u=[],p=await Jc(n,s,o,i,l,c,(d)=>u.push(d));return{lines:u,pr:p.pr,entry:p.entry,installUrl:p.installUrl,files:p.files}}function Oy(e){for(let t of e)if(xl(t)||$y(t).startsWith("..")||!/^[A-Za-z0-9._/-]+$/.test(t))throw new v(`${t} is not a file of this clone`,"Reload the page and try again.");return e}var Cy=N({path:E(),files:X(E()).min(1).max(10)}).strict();async function V2(e){let t=await se(e.req,Cy),{login:n}=await Ye(e.s),r=Nr(t.path,e.s.deps.home);zr(r,n);let i=[];for(let s of Oy(t.files))i.push({path:s,before:await Ty(r,s),after:oe(je(r,s))});return{files:i}}async function Y2(e){let t=await se(e.req,Cy),{login:n}=await Ye(e.s),r=Nr(t.path,e.s.deps.home);zr(r,n);let i=Oy(t.files),s=await _n(r,["add","--",...i],{user:!0});if(s.code!==0)throw new v("git could not stage the files",s.stderr.trim().split(`
1400
+ `;function Ds(e,t){let n={deps:e,port:t,token:gl(32).toString("hex"),codes:new Map,claimed:new Set,pending:new Map,apps:new Map,sparkle:new Map,touched:Date.now(),login:null,link:()=>{let r=gl(16).toString("hex");return n.codes.set(r,Date.now()+f2),`http://127.0.0.1:${n.port}/#c=${r}`}};return n}async function se(e,t){let n;try{n=await e.json()}catch{throw new v("the request was not JSON","Reload the page and try again.")}let r=t.safeParse(n);if(!r.success)throw new v("the request did not have the expected fields","Reload the page and try again.");return r.data}function v2(e,t){if(typeof t!=="string"||!/^[0-9a-f]{32}$/.test(t))return st({error:{reason:"this link is not a tapster setup link",fix:"Press Enter in the terminal that runs tapster setup for a fresh link."}},400);if(e.claimed.has(t))return e.token=gl(32).toString("hex"),e.codes.clear(),e.deps.log("tapster setup: the same link was opened twice, so tapster ended every session for safety."),e.deps.log(`Open this fresh link in your browser: ${e.link()}`),st({error:{reason:"this link was already used",fix:"tapster ended every session for safety. Open the fresh link the terminal printed."}},409);let n=e.codes.get(t);if(n===void 0||n<Date.now())return st({error:{reason:"this link has expired",fix:"Press Enter in the terminal that runs tapster setup for a fresh link."}},410);return e.codes.delete(t),e.claimed.add(t),e.touched=Date.now(),st({token:e.token})}function cy(e,t,n){return async(r)=>{if(!ry(r.headers.get("host"),e.port))return Ve("Misdirected request",421,"text/plain; charset=utf-8");let i=new URL(r.url),s=i.pathname;if(r.method==="GET"&&m2.has(s))return Ve(g2,200,"text/html; charset=utf-8");if(r.method==="GET"&&s==="/app.css")return Ve(sy,200,"text/css; charset=utf-8");if(r.method==="GET"&&s==="/app.js")return Ve(await ty(),200,"text/javascript; charset=utf-8");if(r.method==="GET"&&ay[s])return Ve(new Uint8Array(ay[s]),200,"image/webp");if(r.method==="GET"&&s==="/app/callback")return n({s:e,req:r,url:i});if(r.method==="POST"&&s==="/api/claim"){let a=await r.json().catch(()=>null);return v2(e,a?.code)}if(!s.startsWith("/api/"))return Ve("Not found",404,"text/plain; charset=utf-8");if(!iy(r.headers.get("authorization"),e.token))return st({error:{reason:"this page is not signed in to tapster setup",fix:"Press Enter in the terminal that runs tapster setup for a fresh link."}},401);e.touched=Date.now();let o=t[`${r.method} ${s}`];if(!o)return st({error:{reason:"unknown request",fix:"Reload the page."}},404);try{return st(await o({s:e,req:r,url:i})??{})}catch(a){let c=ny(a);if(c.status===500)e.deps.log(`tapster setup: ${r.method} ${s} failed: ${fn(a instanceof Error?`${a.name}: ${a.message}`:"unknown error")}`);return st(c.body,c.status)}}}var b2=/^[A-Za-z0-9-]+\/homebrew-[A-Za-z0-9._-]+$/,w2="tapster: the hub needs attention";async function _2(e){let t;try{t=await e.deps.github()}catch(o){if(o instanceof v&&/not installed/.test(o.reason))return{state:"no-gh"};return{state:"signed-out"}}let n;try{n=await t.request("GET","/user")}catch(o){if(o instanceof R&&o.status===401)return{state:"signed-out"};throw o}let r=await n.json();e.login=r.login;let i=n.headers.get("x-oauth-scopes"),s=i===null?null:i.split(",").map((o)=>o.trim());return{state:"ok",login:r.login,missing:s===null?[]:["repo","workflow"].filter((o)=>!s.includes(o))}}async function Ye(e){let t=await e.deps.github();return e.login??=(await t.json("GET","/user")).login,{gh:t,login:e.login}}function ot(e,t){if(typeof e!=="string"||!b2.test(e))throw new v("that is not a hub name","A hub is one of your repositories whose name starts with homebrew-, such as you/homebrew-tap.");if(e.split("/")[0].toLowerCase()!==t.toLowerCase())throw new v(`${e} does not belong to ${t}`,"tapster serves repositories of your own account.");return e}async function we(e,t){let{gh:n,login:r}=await Ye(e.s);return{gh:n,hub:ot(t,r),login:r}}var vl=async(e)=>{try{return await e}catch(t){if(t instanceof R&&t.status===404)return null;throw t}},ly=async(e,t)=>{try{return(await e.json("GET",`/repos/${t}/git/ref/heads/main`)).object.sha}catch(n){if(n instanceof R&&(n.status===404||n.status===409))return null;throw n}};async function yl(e,t){let n=[];for(let i=1;i<=5;i++){let s=await e.json("GET",`/user/repos?affiliation=owner&sort=updated&per_page=100&page=${i}`);if(n.push(...s),s.length<100)break}let r=n.filter((i)=>i.name.startsWith("homebrew-")&&i.owner.login.toLowerCase()===t.toLowerCase());return Promise.all(r.map(async(i)=>({name:i.full_name,private:i.private,url:i.html_url,tapster:await vl(e.json("GET",`/repos/${i.full_name}/environments/tapster`))!==null})))}function k2(e){let t=[];for(let[n,r]of Object.entries(e)){if(n==="tapster.yml")continue;let i;try{i=ne(r)}catch{t.push({file:n,actions:["(the file is not valid YAML)"]});continue}let s=i?.jobs??{},a=Object.values(s).flatMap((c)=>[c?.uses,...(c?.steps??[]).map((l)=>l?.uses)]).filter((c)=>typeof c==="string").filter((c)=>{if(c.startsWith("./"))return!1;let[l,u]=c.split("@"),p=(l??"").split("/")[0].toLowerCase();return!(p==="actions"||p==="github"||(l??"").toLowerCase()==="doguyilmaz/tapster")||!/^[0-9a-f]{40}$/.test(u??"")});if(a.length)t.push({file:n,actions:[...new Set(a)]})}return t}async function bl(e,t,n){let r=await t.json("GET",`/repos/${n}`),s=await ly(t,n)===null,o=await vl(t.json("GET",`/repos/${n}/environments/tapster`)),a=async(I)=>o?(await t.json("GET",`/repos/${n}/environments/tapster/${I}?per_page=100`))[I]??[]:[],[c,l,u,p,d,h]=await Promise.all([a("variables"),a("secrets"),o?t.json("GET",`/repos/${n}/environments/tapster/deployment-branch-policies`):Promise.resolve({branch_policies:[]}),t.json("GET",`/repos/${n}/rulesets`).catch(()=>[]),t.json("GET",`/repos/${n}/actions/permissions`),t.json("GET",`/repos/${n}/actions/permissions/workflow`)]),f=await Promise.all(p.map((I)=>t.json("GET",`/repos/${n}/rulesets/${I.id}`))),m=d.allowed_actions==="selected"?await t.json("GET",`/repos/${n}/actions/permissions/selected-actions`):null,g=(I)=>s?Promise.resolve(null):de(t,n,I,"main"),[w,k,_,y,x]=await Promise.all([g("tapster.yml"),g(".tapster/state.json"),g("README.md"),g(J),s?Promise.resolve([]):t.json("GET",`/repos/${n}/contents/.github/workflows?ref=main`).catch(()=>[])]),S={};for(let I of x.filter((Kt)=>Kt.type==="file"&&/\.ya?ml$/.test(Kt.name)))S[I.name]=await g(`.github/workflows/${I.name}`)??"";let O=(I)=>I.map((Kt)=>Kt.name),A=(I)=>c.find((Kt)=>Kt.name===I)?.value??null,j=w===null?null:(()=>{try{return ie(w,n.split("/")[0])}catch{return null}})(),ce=Boolean(o?.deployment_branch_policy?.custom_branch_policies)&&u.branch_policies.length===1&&u.branch_policies[0].name==="main",ke=[{label:"a tapster environment that only main may open",ok:ce},{label:"main cannot be deleted or force-pushed",ok:nl(f).ok},{label:"workflows run only GitHub's and tapster's actions, pinned by commit",ok:rl(d,m).ok},{label:"the workflows' default token is read-only",ok:h.default_workflow_permissions==="read"}],B=A("TAPSTER_APP_ID"),Tt=e.apps.get(n),qy=j?.config.packages.some(is)??!1,By=Boolean(A("TAPSTER_TEAM_ID"))||O(l).includes("MACOS_NOTARY_KEY"),Fs=y?Bt.exec(y):null,An=(await t.json("GET",`/repos/${n}/issues?state=open&creator=${encodeURIComponent("github-actions[bot]")}&per_page=100`).catch(()=>[])).find((I)=>I.title===w2&&I.user?.login==="github-actions[bot]");return{name:n,url:r.html_url,private:r.private,empty:s,protect:{done:ke.every((I)=>I.ok),environment:ce,checks:ke,others:k2(S)},app:{id:B,slug:A("TAPSTER_APP_SLUG"),key:O(l).includes("TAPSTER_APP_PRIVATE_KEY"),held:Boolean(Tt),installed:Tt?await uy(e,n):null},apple:{needed:By||qy?!0:null,certificate:A("TAPSTER_TEAM_ID")?{team:A("TAPSTER_TEAM_ID"),expires:A("TAPSTER_CERT_EXPIRES")??""}:null,certificateStored:["MACOS_SIGN_P12","MACOS_SIGN_PASSWORD"].every((I)=>O(l).includes(I)),notary:["MACOS_NOTARY_KEY","MACOS_NOTARY_KEY_ID","MACOS_NOTARY_ISSUER_ID"].every((I)=>O(l).includes(I))},files:{config:w!==null,state:k!==null,readme:_!==null,workflow:el(y,ae,e.deps.pin),pinned:Fs?`${Fs[2]} (${Fs[1].slice(0,7)})`:null,every:y?rt(y):null},packages:(j?.config.packages??[]).map((I)=>({name:I.name,repo:I.repo,kind:Y(I)?"app":I.kind})),invalid:(j?.invalid??[]).map((I)=>({name:I.name,reason:I.reason})),issue:An?{url:An.html_url,number:An.number,updated:An.updated_at,body:An.body??""}:null,extras:{doorbell:A("TAPSTER_DOORBELL")!==null,linux:{wanted:j?.config.packages.some((I)=>!Y(I)&&I.linux)??!1,stored:O(l).includes("TAPSTER_LINUX_KEY")},sparkle:(j?Ee(j.config):[]).map((I)=>({label:I,stored:O(l).includes(`SPARKLE_KEY_${I.toUpperCase()}`)}))}}}async function uy(e,t){let n=e.apps.get(t);if(!n)return{checked:!1,id:null,onHub:!1,repos:[]};let r=t.split("/")[0],i=await Cs(n.id,n.pem,r,t,new pe(Be(n.id,n.pem),e.deps.fetch)),s=i.id===null?[]:await Mg(n.id,n.pem,r,e.deps.fetch)??[];return{checked:!0,id:i.id,onHub:i.onHub,repos:s}}async function wn(e,t){let n=await vl(e.json("GET",`/repos/${t}/environments/tapster`)),r=n?await e.json("GET",`/repos/${t}/environments/tapster/deployment-branch-policies`):{branch_policies:[]};if(!(Boolean(n?.deployment_branch_policy?.custom_branch_policies)&&r.branch_policies.length===1&&r.branch_policies[0].name==="main"&&(r.branch_policies[0].type??"branch")==="branch"))throw new v(`${t}'s tapster environment is not locked to main`,"Protect the hub first: keys go into that environment only once workflows on other branches cannot open it.")}async function py(e,t,n){let i=(await ml(e,t,n).catch((s)=>{if(s instanceof R&&s.status===404)return[];throw s})).filter((s)=>!s.startsWith("GitHub shows no push by"));if(i.length)throw new v(`main changed in ways only you may change it: ${i.join("; ")}`,"Review those commits on GitHub and revert what you did not make. tapster writes nothing to main until then, because a write from you would mark them as reviewed.")}var Ms=N({hub:E()}).strict();async function x2(e){let{hub:t}=await se(e.req,Ms),{gh:n}=await we(e,t),r=await n.json("GET",`/repos/${t}`);return await fl(n,t,r.private),{done:!0}}async function S2(e){let{hub:t}=await se(e.req,Ms),{gh:n,login:r}=await we(e,t);await wn(n,t);let i=y2(16).toString("hex");for(let[o,a]of e.s.pending)if(Date.now()-a.at>3600000)e.s.pending.delete(o);e.s.pending.set(i,{hub:t,owner:r,at:Date.now()});let s=Os(r,t,`http://127.0.0.1:${e.s.port}/app/callback`);return{action:`https://github.com/settings/apps/new?state=${i}`,manifest:JSON.stringify(s),permissions:Mc(s),name:s.name}}async function dy(e){let t=(o)=>new Response(null,{status:303,headers:{location:`/setup?${new URLSearchParams(o)}`,"cache-control":"no-store","referrer-policy":"no-referrer"}}),n=e.url.searchParams.get("state")??"",r=e.url.searchParams.get("code")??"",i=e.s.pending.get(n);if(!i||!/^[A-Za-z0-9_-]{1,128}$/.test(r))return t({app:"unknown"});e.s.pending.delete(n);let s;try{s=await Uc(r,i.owner,"If GitHub created the App anyway, delete it at https://github.com/settings/apps first, because its name would block a new one. Then create it again.",e.s.deps.fetch)}catch(o){let a=o instanceof v?o:new v("GitHub did not hand over the new App","Try again from Setup.");return t({app:"failed",hub:i.hub,reason:a.reason,fix:a.fix})}e.s.apps.set(i.hub,{id:String(s.id),pem:s.pem,slug:s.slug});try{return await wn(await e.s.deps.github(),i.hub),await Pr(i.hub,s),t({app:"created",hub:i.hub})}catch(o){let a=o instanceof v?o:new v("the App's key could not be stored","Try again.");return t({app:"unstored",hub:i.hub,reason:a.reason,fix:a.fix})}}async function A2(e){let{hub:t}=await se(e.req,Ms),{gh:n}=await we(e,t);await wn(n,t);let r=e.s.apps.get(t);if(!r)throw new v("this setup no longer holds the App's key","GitHub hands the key over only once. Delete the App at https://github.com/settings/apps, then create it again here.");return await Pr(t,{id:Number(r.id),slug:r.slug,pem:r.pem}),{stored:!0}}async function $2(e){let{hub:t}=await we(e,e.url.searchParams.get("hub"));return uy(e.s,t)}var hy=(e,t,n)=>{let r=e.get(t);if(!(r instanceof File)||r.size===0)throw new v(`no ${t} file was attached`,"Choose the file and try again.");if(r.size>n)throw new v(`that ${t} file is too large`,"Choose the file Apple or Keychain Access gave you.");return r.arrayBuffer().then((i)=>new Uint8Array(i))};async function fy(e){try{return await e.req.formData()}catch{throw new v("the form could not be read","Reload the page and try again.")}}async function P2(e){let t=await fy(e),{gh:n,hub:r}=await we(e,t.get("hub"));await wn(n,r);let i=await hy(t,"p12",ol),s=String(t.get("password")??""),o=await Rs(i,s);return await Is(r,i,s,o),o}async function T2(e){let t=await fy(e),{gh:n,hub:r}=await we(e,t.get("hub"));await wn(n,r);let i=Ns(await hy(t,"p8",al),String(t.get("keyId")??""),String(t.get("issuerId")??"")),s=await e.s.deps.notary(i);return await Ls(r,i),{checked:s}}var my=N({hub:E(),every:_c().int().nullable(),remove:X(E()).max(20),readme:tt()}).strict();async function gy(e,t,n,r,i,s,o){let a=await t.json("GET",`/repos/${n}`),c=await As(t,n,o,e.s.deps.pin,{every:r,isPrivate:a.private}),l=el(await o(J),ae,e.s.deps.pin)==="newer",u=[];for(let f of c.files.filter((m)=>!(l&&m.path===J)))u.push({path:f.path,content:f.content,before:f.before,change:f.before===null?"create":f.before===f.content?"same":"update"});let p=Ss(n).find((f)=>f.path==="README.md"),d=c.kept.includes("README.md")?await o("README.md"):null;if(s&&d!==null&&d!==p.content)u.push({path:"README.md",content:p.content,before:d,change:"update"});let h=i.filter((f)=>/^[A-Za-z0-9._-]+\.ya?ml$/.test(f)&&f!=="tapster.yml");for(let f of h){let m=await o(`.github/workflows/${f}`);if(m!==null)u.push({path:`.github/workflows/${f}`,content:"",before:m,change:"remove"})}return{files:u,kept:c.kept,pin:l?"kept: the hub runs a newer tapster than this one":c.change,notes:l?[]:c.notes,foreign:[],readme:d!==null&&d!==p.content}}async function E2(e){let t=await se(e.req,my),{gh:n,hub:r,login:i}=await we(e,t.hub),s=await gy(e,n,r,t.every,t.remove,t.readme,(a)=>de(n,r,a,"main")),o=await ml(n,r,i).catch(()=>[]);return{...s,foreign:o.filter((a)=>!a.startsWith("GitHub shows no push by"))}}async function O2(e){let t=await se(e.req,my),{gh:n,hub:r,login:i}=await we(e,t.hub);if(await ly(n,r)===null){let o=Ss(r).find((a)=>a.path==="README.md");if(await n.json("PUT",`/repos/${r}/contents/README.md`,{message:"Start the tap",content:Buffer.from(o.content).toString("base64"),branch:"main"}),(await n.json("GET",`/repos/${r}`)).default_branch!=="main")await n.json("PATCH",`/repos/${r}`,{default_branch:"main"})}return await py(n,r,i),{result:await Qc(n,r,"Set up tapster",async(o)=>(await gy(e,n,r,t.every,t.remove,t.readme,o)).files.filter((c)=>c.change!=="same").map((c)=>({path:c.path,content:c.change==="remove"?null:c.content})))}}async function C2(e){let t=await se(e.req,N({name:E().regex(/^homebrew-[A-Za-z0-9._-]{1,80}$/),private:tt()}).strict()),{gh:n,login:r}=await Ye(e.s);try{return{hub:(await n.json("POST","/user/repos",{name:t.name,private:t.private,auto_init:!1,description:"Homebrew tap, published by tapster"})).full_name}}catch(i){if(i instanceof R&&i.status===422)throw new v(`${r}/${t.name} already exists`,"Pick it from the list instead.");throw i}}var R2=N({hub:E(),label:E().regex(/^[a-z0-9]{1,40}$/),account:E().regex(/^[A-Za-z0-9 ._@-]{1,64}$/)}).strict();async function vy(e,t,n){let r=await de(e,t,"tapster.yml","main"),i=r===null?null:ie(r,t.split("/")[0]).config;if(!i||!Ee(i).includes(n))throw new v(`no app in ${t}'s tapster.yml signs with the Sparkle key ${n}`,"Add the app with its sparkle section first.");return i}async function I2(e){let t=await se(e.req,R2),{gh:n,hub:r}=await we(e,t.hub),i=await vy(n,r,t.label),s=await e.s.deps.keychain(t.account);if(s===null)throw new v(`your keychain gave no Sparkle key for the account ${t.account}`,"Choose Allow when macOS asks. generate_keys uses the account ed25519 unless you passed --account.");let o=Es(s),a=hl(i,t.label,o.publicKey);return e.s.sparkle.set(`${r} ${t.label}`,{seed:s.trim(),at:Date.now()}),{publicKey:o.publicKey,users:a,key:s.trim()}}async function N2(e){let t=await se(e.req,N({hub:E(),label:E().regex(/^[a-z0-9]{1,40}$/),pasted:E().max(400)}).strict()),{gh:n,hub:r,login:i}=await we(e,t.hub),s=e.s.sparkle.get(`${r} ${t.label}`);if(!s||Date.now()-s.at>1800000)throw new v("read the key from your keychain first","Click Read it from my keychain again.");if(t.pasted.trim()!==s.seed)throw new v("that is not the key shown above","Paste the key itself, so the copy your password manager keeps is the right one.");let o=await vy(n,r,t.label);await wn(n,r),await py(n,r,i),await ee(r,`SPARKLE_KEY_${t.label.toUpperCase()}`,s.seed);let a=await Qc(n,r,`Pass the Sparkle key ${t.label} to the hub workflow`,async(c)=>{let l=await c(J);if(l===null)return[];let u=xs(l,Ee(o));return u===l?[]:[{path:J,content:u}]});return e.s.sparkle.delete(`${r} ${t.label}`),{stored:!0,workflow:a}}async function z2(e){let{gh:t,hub:n}=await we(e,e.url.searchParams.get("hub")),[{checks:r,note:i},s]=await Promise.all([$r(t,n),t.json("GET",`/repos/${n}/actions/workflows/tapster.yml/runs?per_page=8`).catch(()=>({workflow_runs:[]}))]);return{checks:r,note:i,runs:s.workflow_runs.map((o)=>({id:o.id,url:o.html_url,event:o.event,status:o.status,conclusion:o.conclusion,created:o.created_at}))}}async function L2(e){let{hub:t}=await se(e.req,Ms),{gh:n}=await we(e,t);return await n.json("POST",`/repos/${t}/actions/workflows/tapster.yml/dispatches`,{ref:"main"}),{started:!0}}var yy={"GET /api/account":(e)=>_2(e.s),"GET /api/hubs":async(e)=>{let{gh:t,login:n}=await Ye(e.s);return{hubs:await yl(t,n)}},"POST /api/hubs":C2,"GET /api/hub":async(e)=>{let{gh:t,hub:n}=await we(e,e.url.searchParams.get("hub"));return bl(e.s,t,n)},"POST /api/hub/protect":x2,"POST /api/hub/app":S2,"POST /api/hub/app/store":A2,"GET /api/hub/installation":$2,"POST /api/hub/certificate":P2,"POST /api/hub/notary":T2,"POST /api/hub/files/preview":E2,"POST /api/hub/files":O2,"GET /api/hub/health":z2,"POST /api/hub/run":L2,"POST /api/hub/sparkle/read":I2,"POST /api/hub/sparkle/store":N2};import{existsSync as Bs,lstatSync as xy,readdirSync as Ay}from"fs";import{isAbsolute as xl,join as Le,normalize as $y,resolve as Py}from"path";import{lstatSync as wl,readdirSync as j2,realpathSync as ky}from"fs";import{dirname as D2,join as Ft,resolve as Us,sep as by}from"path";var M2=new Set(["node_modules","Library","Applications","Pictures","Music","Movies","Documents","Desktop","Downloads","Public","vendor","Pods","DerivedData","build","dist","target","out"]),U2=["Developer","Projects","projects","code","Code","src","dev","git","GitHub","repos","workspace","work"];var Z2=(e)=>{try{return wl(e).isFile()}catch{return!1}};function _l(e){let t=/\[remote "origin"\]([\s\S]*?)(?=\n\s*\[|$)/.exec(e)?.[1]??"",n=/^\s*url\s*=\s*(\S+)\s*$/m.exec(t)?.[1]??"";return/^(?:https:\/\/github\.com\/|git@github\.com:|ssh:\/\/git@github\.com\/)([A-Za-z0-9-]+\/[A-Za-z0-9._-]+?)(?:\.git)?\/?$/.exec(n)?.[1]??null}function kl(e,t){let n=(r)=>t.includes(r)&&Z2(Ft(e,r));if(t.some((r)=>r==="project.yml"||r==="Package.swift"||r.endsWith(".xcodeproj")))return{kind:"app",why:null};if(n("go.mod"))return n(".goreleaser.yaml")||n(".goreleaser.yml")?{kind:"go",why:null}:{kind:null,why:"a Go project without GoReleaser"};if(n("package.json")){if(!n("bun.lock")&&!n("bun.lockb"))return{kind:null,why:"a JavaScript project without Bun"};let r=null;try{r=JSON.parse(oe(Ft(e,"package.json"))??"{}").bin}catch{r=null}return r?{kind:"bun",why:null}:{kind:null,why:"a Bun project without a command (no bin in package.json)"}}return{kind:null,why:"no build that tapster knows"}}function Zs(e,t){return[t,D2(t),...U2.map((n)=>Ft(e,n))].filter((n)=>Gs(n,e)&&n!==Us(e))}var wy=(e,t)=>e===t||e.startsWith(t.endsWith(by)?t:`${t}${by}`),_y=(e)=>{try{return ky(e)}catch{return Us(e)}};function Gs(e,t){return wy(Us(e),Us(t))||wy(_y(e),_y(t))}function qs(e,t={}){let n=t.depth??3,r=t.maxDirs??4000,i=t.deadline??Date.now()+3000,s=new Set,o=[],a=0,c=!1,l=(u,p)=>{if(a>=r||Date.now()>i){c=!0;return}let d;try{d=ky(u)}catch{return}if(s.has(d))return;s.add(d),a++;let h;try{h=j2(d)}catch{return}if(h.includes(".git")){let f=null;try{f=wl(Ft(d,".git"))}catch{f=null}let m=f?.isDirectory()?oe(Ft(d,".git","config"),65536):null,g=m?_l(m):null;if(g)o.push({path:u,repo:g,owner:g.split("/")[0],inHub:!1,proposed:null,...kl(d,h)});return}if(p>=n)return;for(let f of h){if(f.startsWith(".")||M2.has(f))continue;try{if(!wl(Ft(d,f)).isDirectory())continue}catch{continue}l(Ft(u,f),p+1)}};for(let u of e)l(u,0);return{found:o,truncated:c}}var Sy="Release through the tapster hub";function Nr(e,t){if(typeof e!=="string"||!xl(e))throw new v("that is not a full folder path","Give the folder's full path, such as /Users/you/Developer/my-tool.");let n=Py($y(e));if(!Gs(n,t))throw new v(`${n} is outside your home folder`,"tapster reads clones inside your home folder only.");let r;try{r=xy(n)}catch{throw new v(`${n} does not exist`,"Check the path.")}if(!r.isDirectory())throw new v(`${n} is not a folder`,"Give the folder of the clone.");if(!Bs(Le(n,".git"))||!xy(Le(n,".git")).isDirectory())throw new v(`${n} is not a git clone`,"Give the top folder of a clone, the one that holds .git.");return n}function zr(e,t){let n=_l(oe(Le(e,".git","config"),65536)??"");if(!n)throw new v("this clone's origin is not a GitHub repository","tapster adds clones whose origin is on github.com.");if(n.split("/")[0].toLowerCase()!==t.toLowerCase())throw new v(`${n} does not belong to ${t}`,"tapster publishes repositories of your own account.");return n}async function _n(e,t,n={}){let r=n.user?{...process.env,GIT_TERMINAL_PROMPT:"0",GIT_SSH_COMMAND:process.env.GIT_SSH_COMMAND??"ssh -o BatchMode=yes"}:{GIT_TERMINAL_PROMPT:"0",GIT_NO_LAZY_FETCH:"1",GIT_ALLOW_PROTOCOL:"none"};return D(mn.git,"git",["-C",e,...t],{env:r,allowFail:!0,timeoutMs:n.timeoutMs??20000,maxOutput:4194304})}async function Ty(e,t){let n=await _n(e,["cat-file","-p",`HEAD:${t}`]);return n.code===0?n.stdout:null}function G2(e){let t=oe(Le(e,".git","HEAD"),4096)?.trim()??"";return/^ref: refs\/heads\/(.+)$/.exec(t)?.[1]??"a detached HEAD"}async function q2(e,t){let n=[];for(let r of t){let i=oe(Le(e,r));if(i!==null&&i!==await Ty(e,r))n.push(r)}return n}var Ey={hub:E()};async function B2(e){let t=await se(e.req,N({hub:E(),extra:X(E()).max(10)}).strict()),{gh:n,login:r}=await Ye(e.s),i=ot(t.hub,r),s=t.extra.map((m)=>Py(m)).filter((m)=>xl(m)&&Gs(m,e.s.deps.home)&&Bs(m)),o=[...new Set([...s,...Zs(e.s.deps.home,e.s.deps.cwd)])].filter((m)=>Bs(m)),{found:a,truncated:c}=qs(o),l=await de(n,i,"tapster.yml","main").catch(()=>null),u=new Set(l?ie(l,r).config.packages.map((m)=>m.repo.toLowerCase()):[]),p=await n.json("GET",`/repos/${i}/pulls?state=open&per_page=100`).catch(()=>[]),d=new Map(p.filter((m)=>m.head?.ref?.startsWith("tapster-add-")).map((m)=>[m.head.ref.slice(12),m.html_url])),h=a.filter((m)=>m.owner.toLowerCase()===r.toLowerCase()&&m.repo.toLowerCase()!==i.toLowerCase());return{projects:[...new Map(h.map((m)=>[m.path,m])).values()].map(({owner:m,...g})=>({...g,inHub:u.has(g.repo.toLowerCase()),proposed:d.get(_s(g.repo))??null})).sort((m,g)=>Number(g.kind!==null)-Number(m.kind!==null)||m.repo.localeCompare(g.repo)),roots:o,others:a.length-h.length,truncated:c}}function H2(e){let t=Le(e,".github","workflows"),n;try{n=Ay(t).filter((r)=>/^[A-Za-z0-9._-]+\.ya?ml$/.test(r))}catch{return[]}return n.filter((r)=>(oe(Le(t,r))??"").includes("goreleaser/goreleaser-action")).sort()}async function F2(e){let t=await se(e.req,N({...Ey,path:E()}).strict()),{gh:n,login:r}=await Ye(e.s),i=ot(t.hub,r),s=Nr(t.path,e.s.deps.home),o=zr(s,r),a=_s(o),c=Ay(s),{kind:l,why:u}=kl(s,c);if(l==="app"&&!Vc(s))l=null,u="an Xcode project without a Sparkle feed (SUFeedURL ending in /releases/latest/download/<name>.xml)";if(l==="bun"){let x=oe(Le(s,"package.json")),S=null;try{S=x?JSON.parse(x):null}catch{S=null}if(!S||!bs(S,a))l=null,u="package.json has no bin entry, so there is no command to publish"}if(l===null)throw new v(`tapster cannot publish ${o} yet: it is ${u}`,"tapster publishes GoReleaser Go tools, Bun command line tools and Mac apps that update with Sparkle.");let p=l==="go"?H2(s):[],d=oe(Le(s,".github","workflows","release.yml")),h=await q2(s,[".github/workflows/release.yml",".goreleaser.yaml",".goreleaser.yml",...p.map((x)=>`.github/workflows/${x}`)]),f=G2(s),[m,g,w]=await Promise.all([n.getRepo(o),Sr(n,i).catch(()=>null),de(n,i,"tapster.yml","main").catch(()=>null)]),k=await gr(n,o,m.default_branch,"admin").catch(()=>["unknown"]),_=await n.json("GET",`/repos/${i}/pulls?state=open&head=${encodeURIComponent(`${r}:tapster-add-${a}`)}`).catch(()=>[]),y=w?ie(w,r).config.packages.some((x)=>x.repo.toLowerCase()===o.toLowerCase()):!1;if(!g)throw new v(`${i} has no App yet`,"Finish the hub's setup first.");return{path:s,repo:o,name:a,kind:l,branch:f,defaultBranch:m.default_branch,dirty:[...new Set(h)],workflows:p,workflow:p.includes("release.yml")?"release.yml":p[0]??null,releaseFlow:d===null?"missing":d.includes("Ring the tapster hub")?"ours":"other",dependabot:[".github/dependabot.yml",".github/dependabot.yaml"].some((x)=>Bs(Le(s,x))),private:m.private,protected:k.length===0,inHub:y,proposed:_[0]?.html_url??null,apple:g.apple}}var K2=N({...Ey,path:E(),options:N({workflow:E().regex(/^[A-Za-z0-9._-]+\.ya?ml$/),autoTag:tt(),dependabot:tt(),force:tt()}).strict()}).strict();async function W2(e){let t=await se(e.req,K2),{gh:n,login:r}=await Ye(e.s),i=ot(t.hub,r),s=Nr(t.path,e.s.deps.home),o=zr(s,r),a=t.options,c=Yc([...a.force?["--force"]:[],...a.autoTag?["--auto-tag"]:[],...a.dependabot?["--allow-dependabot"]:[],"--workflow",a.workflow]),l=await Sr(n,i);await _n(s,["config","tapster.hub",i],{user:!0});let u=[],p=await Jc(n,s,o,i,l,c,(d)=>u.push(d));return{lines:u,pr:p.pr,entry:p.entry,installUrl:p.installUrl,files:p.files}}function Oy(e){for(let t of e)if(xl(t)||$y(t).startsWith("..")||!/^[A-Za-z0-9._/-]+$/.test(t))throw new v(`${t} is not a file of this clone`,"Reload the page and try again.");return e}var Cy=N({path:E(),files:X(E()).min(1).max(10)}).strict();async function V2(e){let t=await se(e.req,Cy),{login:n}=await Ye(e.s),r=Nr(t.path,e.s.deps.home);zr(r,n);let i=[];for(let s of Oy(t.files))i.push({path:s,before:await Ty(r,s),after:oe(Le(r,s))});return{files:i}}async function Y2(e){let t=await se(e.req,Cy),{login:n}=await Ye(e.s),r=Nr(t.path,e.s.deps.home);zr(r,n);let i=Oy(t.files),s=await _n(r,["add","--",...i],{user:!0});if(s.code!==0)throw new v("git could not stage the files",s.stderr.trim().split(`
1401
1401
  `).at(-1)??"Run git status in the clone.");let o=await _n(r,["commit","-m",Sy,"--",...i],{user:!0,timeoutMs:60000});if(o.code!==0){let a=`${o.stdout}
1402
1402
  ${o.stderr}`;if(/nothing to commit|no changes added/i.test(a))return{committed:!1};throw new v("git could not commit",`${a.trim().split(`
1403
- `).at(-1)??""} Commit in a terminal: git commit -m "${Sy}" -- ${i.join(" ")}`)}return{committed:!0}}async function J2(e){let t=await se(e.req,N({path:E()}).strict()),{login:n}=await Ye(e.s),r=Nr(t.path,e.s.deps.home);zr(r,n);let s=(await _n(r,["rev-parse","--abbrev-ref","--symbolic-full-name","@{u}"])).code===0?["push"]:["push","--set-upstream","origin","HEAD"];if((await _n(r,s,{user:!0,timeoutMs:90000}).catch((a)=>{if(a instanceof v)return{code:1,stdout:"",stderr:a.reason};throw a})).code!==0)throw new v("git could not push without asking for a password or passphrase",`Push from a terminal in ${r}: git ${s.join(" ")}`);return{pushed:!0}}var Ry={"POST /api/projects/scan":B2,"POST /api/projects/inspect":F2,"POST /api/projects/add":W2,"POST /api/projects/diff":V2,"POST /api/projects/commit":Y2,"POST /api/projects/push":J2};var jr=8277,X2=7200000;function eC(e){let t={open:!0,port:null,pin:null};for(let n=0;n<e.length;n++){let r=e[n],i=e[n+1];if(r==="--no-open")t.open=!1;else if(r==="--port"&&i&&/^\d{2,5}$/.test(i)&&Number(i)>=1024&&Number(i)<=65535)t.port=Number(e[++n]);else if(r==="--tapster"&&i&&/^[0-9a-f]{40}$/.test(i))t.pin=e[++n];else throw new v(`unknown option ${r}`,"Run tapster setup --help for the options.")}return t}function tC(e,t){return{...yy,...Ry,"GET /api/session":async()=>{let n=await He(e.deps.cwd).catch(()=>null),r=n!==null&&/\/homebrew-/.test(n);return{version:ae.version,dev:ae.sha===null&&e.deps.pin===null,platform:process.platform,home:e.deps.home,here:{hub:r?n:null,repo:r?null:n,path:e.deps.cwd}}},"POST /api/quit":async()=>(setTimeout(t,200),{stopping:!0})}}function nC(e){let t=process.platform==="darwin"?"/usr/bin/open":"/usr/bin/xdg-open";L(t,"open",[e],{allowFail:!0}).catch(()=>{return})}function Sl(e){let t=null;return{async github(){if(t&&Date.now()-t.at<60000)return t.gh;let n=await At();return t={gh:n,at:Date.now()},n},fetch,home:Q2(),cwd:process.cwd(),pin:e,log:(n)=>console.log(n),open:nC,notary:zs,keychain:(n)=>Or("the Sparkle key").read({service:"https://sparkle-project.org",account:n,label:"Private key for signing Sparkle updates"})}}function Iy(e,t){return Bun.serve({hostname:"127.0.0.1",port:e,fetch:t,development:!1,error:()=>Ve("tapster setup hit an unexpected error. The terminal that runs it may say more.",500,"text/plain; charset=utf-8"),maxRequestBodySize:1048576,idleTimeout:120})}async function Ny(e,t){let n=eC(e);if(process.platform==="win32")throw new v("tapster setup runs on macOS and Linux","Run it on a Mac or a Linux computer; the hub itself serves Windows users through Scoop.");let r=t??Sl(n.pin),i=async()=>new Response(null,{status:503}),s;try{s=Iy(n.port??jr,(d)=>i(d))}catch{if(n.port!==null)throw new v(`port ${n.port} is in use`,"Pick another one with --port or close the program that uses it.");s=Iy(0,(d)=>i(d)),r.log(`Port ${jr} is in use (another tapster setup may be open), so this one uses ${s.port}. Password managers save entries per address, so they may not offer the ones saved on ${jr}.`)}let o=()=>{},a=new Promise((d)=>o=d),c=Ls(r,s.port),l=()=>{clearInterval(u),process.stdin.pause(),s.stop(),o()};i=cy(c,tC(c,l),(d)=>dy(d));let u=setInterval(()=>{if(Date.now()-c.touched>X2)r.log("tapster setup stopped after two hours without use. Run it again to continue; everything you did is on GitHub."),l()},60000),p=()=>{let d=c.link();if(r.log(`
1403
+ `).at(-1)??""} Commit in a terminal: git commit -m "${Sy}" -- ${i.join(" ")}`)}return{committed:!0}}async function J2(e){let t=await se(e.req,N({path:E()}).strict()),{login:n}=await Ye(e.s),r=Nr(t.path,e.s.deps.home);zr(r,n);let s=(await _n(r,["rev-parse","--abbrev-ref","--symbolic-full-name","@{u}"])).code===0?["push"]:["push","--set-upstream","origin","HEAD"];if((await _n(r,s,{user:!0,timeoutMs:90000}).catch((a)=>{if(a instanceof v)return{code:1,stdout:"",stderr:a.reason};throw a})).code!==0)throw new v("git could not push without asking for a password or passphrase",`Push from a terminal in ${r}: git ${s.join(" ")}`);return{pushed:!0}}var Ry={"POST /api/projects/scan":B2,"POST /api/projects/inspect":F2,"POST /api/projects/add":W2,"POST /api/projects/diff":V2,"POST /api/projects/commit":Y2,"POST /api/projects/push":J2};var Lr=8277,X2=7200000;function eC(e){let t={open:!0,port:null,pin:null};for(let n=0;n<e.length;n++){let r=e[n],i=e[n+1];if(r==="--no-open")t.open=!1;else if(r==="--port"&&i&&/^\d{2,5}$/.test(i)&&Number(i)>=1024&&Number(i)<=65535)t.port=Number(e[++n]);else if(r==="--tapster"&&i&&/^[0-9a-f]{40}$/.test(i))t.pin=e[++n];else throw new v(`unknown option ${r}`,"Run tapster setup --help for the options.")}return t}function tC(e,t){return{...yy,...Ry,"GET /api/session":async()=>{let n=await He(e.deps.cwd).catch(()=>null),r=n!==null&&/\/homebrew-/.test(n);return{version:ae.version,dev:ae.sha===null&&e.deps.pin===null,platform:process.platform,home:e.deps.home,here:{hub:r?n:null,repo:r?null:n,path:e.deps.cwd}}},"POST /api/quit":async()=>(setTimeout(t,200),{stopping:!0})}}function nC(e){let t=process.platform==="darwin"?"/usr/bin/open":"/usr/bin/xdg-open";D(t,"open",[e],{allowFail:!0}).catch(()=>{return})}function Sl(e){let t=null;return{async github(){if(t&&Date.now()-t.at<60000)return t.gh;let n=await At();return t={gh:n,at:Date.now()},n},fetch,home:Q2(),cwd:process.cwd(),pin:e,log:(n)=>console.log(n),open:nC,notary:zs,keychain:(n)=>Or("the Sparkle key").read({service:"https://sparkle-project.org",account:n,label:"Private key for signing Sparkle updates"})}}function Iy(e,t){return Bun.serve({hostname:"127.0.0.1",port:e,fetch:t,development:!1,error:()=>Ve("tapster setup hit an unexpected error. The terminal that runs it may say more.",500,"text/plain; charset=utf-8"),maxRequestBodySize:1048576,idleTimeout:120})}async function Ny(e,t){let n=eC(e);if(process.platform==="win32")throw new v("tapster setup runs on macOS and Linux","Run it on a Mac or a Linux computer; the hub itself serves Windows users through Scoop.");let r=t??Sl(n.pin),i=async()=>new Response(null,{status:503}),s;try{s=Iy(n.port??Lr,(d)=>i(d))}catch{if(n.port!==null)throw new v(`port ${n.port} is in use`,"Pick another one with --port or close the program that uses it.");s=Iy(0,(d)=>i(d)),r.log(`Port ${Lr} is in use (another tapster setup may be open), so this one uses ${s.port}. Password managers save entries per address, so they may not offer the ones saved on ${Lr}.`)}let o=()=>{},a=new Promise((d)=>o=d),c=Ds(r,s.port),l=()=>{clearInterval(u),process.stdin.pause(),s.stop(),o()};i=cy(c,tC(c,l),(d)=>dy(d));let u=setInterval(()=>{if(Date.now()-c.touched>X2)r.log("tapster setup stopped after two hours without use. Run it again to continue; everything you did is on GitHub."),l()},60000),p=()=>{let d=c.link();if(r.log(`
1404
1404
  ${d}
1405
1405
  `),n.open)r.open(d)};if(r.log(`tapster setup runs on this computer at http://127.0.0.1:${s.port}. Your keys go from here to your own GitHub account only.`),r.log(n.open?"It opens in your browser now. If it does not, open this link (it works once):":"Open this link in your browser (it works once):"),p(),r.log("Press Enter for a fresh link, for example after closing the tab. Ctrl+C stops tapster setup."),process.stdin.isTTY)process.stdin.setEncoding("utf8"),process.stdin.on("data",(d)=>{if(d.includes(`
1406
- `))p()}),process.stdin.resume();await a,r.log("tapster setup stopped.")}import{createInterface as cC}from"readline";var rC=N({tag:E().regex($c),releaseId:_c().int().positive(),checksums:E().regex(/^[0-9a-f]{64}$/),status:kt(["publishing","published"]),app:N({macos:E().regex(/^[a-z_]+$/),identifiers:X(E().regex(/^[A-Za-z0-9.-]+$/))}).strict().optional()}).strict(),iC=N({version:xc(1),packages:rs(E().regex(dn),X(rC))}).strict(),sC=()=>({version:1,packages:{}}),zy=()=>new v(".tapster/state.json is damaged","Restore it from the hub's git history.");function jy(e){if(e===null)return sC();let t;try{t=JSON.parse(e)}catch{throw zy()}let n=iC.safeParse(t);if(!n.success)throw zy();return n.data}function Dy(e){let t=new RegExp("<!-- tapster -->\\s*([\\s\\S]*?)<!-- /tapster -->").exec(e??"")?.[1];return t?t.replace(/^>\s*/,"").replace(/\*\*/g,"").trim():null}function oC(e,t=Date.now()){let n=Date.parse(`${e}T00:00:00Z`);return!Number.isNaN(n)&&n-t<2592000000}function aC(e,t){if(e.apple.needed)return!0;return t===null?null:t==="yes"}function Ly(e,t,n=Date.now()){let r=aC(e,t),i=e.protect.checks.filter((a)=>a.ok).length,s=[{id:"protect",name:"Protect the hub",done:e.protect.done,status:e.protect.done?"All protections are on":i?`${i} of ${e.protect.checks.length} protections on`:"Not protected yet",open:"Not protected yet"},{id:"app",name:"Create the GitHub App",done:Boolean(e.app.id&&e.app.slug&&e.app.key),attention:Boolean(e.app.id&&!e.app.key),status:e.app.id&&!e.app.key?"The App's private key is missing":e.app.slug?e.app.slug:"Not created yet",open:"Not created yet"},{id:"macos",name:"macOS or not",done:r===!0,skipped:r===!1,status:r===!0?"Signs macOS software":r===!1?"No macOS builds":"Your answer",open:"Your answer"},{id:"certificate",name:"Apple certificate",done:Boolean(e.apple.certificate&&e.apple.certificateStored),skipped:r===!1,attention:Boolean(e.apple.certificate&&oC(e.apple.certificate.expires,n)),status:r===!1?"Not needed":e.apple.certificate?`Team ${e.apple.certificate.team}, expires ${e.apple.certificate.expires}`:"Not stored yet",open:"Not stored yet"},{id:"notary",name:"Notarization key",done:e.apple.notary,skipped:r===!1,status:r===!1?"Not needed":e.apple.notary?"Stored":"Not stored yet",open:"Not stored yet"},{id:"files",name:"Hub files",done:e.files.config&&e.files.state&&e.files.workflow!=="missing",attention:e.files.workflow==="older"||e.files.workflow==="other",status:e.files.workflow==="missing"?"Not written yet":e.files.workflow==="older"?`Runs ${e.files.pinned}; update available`:e.files.workflow==="other"?`Runs ${e.files.pinned??"a workflow tapster did not write"}; review it`:e.files.workflow==="newer"?`Runs ${e.files.pinned}, newer than this tapster`:`Runs ${e.files.pinned}`,open:"Not written yet"},{id:"project",name:"Your projects",done:e.packages.length>0,status:e.packages.length?`${e.packages.length} in the hub`:"None yet",open:"None yet"}],o=!1;return s.map((a)=>{let c;if(a.skipped)c="skipped";else if(a.attention)c="attention";else if(a.done)c="done";else if(!o)c="now",o=!0;else c="later";return{id:a.id,name:a.name,state:c,status:a.status}})}var My=["2025-11-25","2025-06-18","2025-03-26","2024-11-05"],lC=`tapster turns the user's Homebrew tap into a release hub that signs, notarizes and publishes the releases of their projects.
1407
- These tools read the hub and the projects through the user's GitHub CLI sign-in and can start a hub run. They cannot set up a hub: creating the GitHub App needs the user's click and the Apple files live on their computer. For setup, tell the user to run "bunx @doguyilmaz/tapster setup", which opens a local page that walks through it. In a project, "bunx @doguyilmaz/tapster add" does the same from a terminal. Docs: https://tapster.doguyilmaz.com/`,kn={hub:E().optional().describe("The hub as owner/homebrew-name. Leave it out to use the hub of the current folder or the user's only hub.")};async function xn(e,t){let n=await e.gh(),r=(await n.json("GET","/user")).login;if(typeof t==="string"&&t)return{gh:n,hub:ot(t,r),login:r};let i=(u)=>u&&u.split("/")[0].toLowerCase()===r.toLowerCase()&&/\/homebrew-/.test(u)?u:null,s=i((await Pe("git",["-C",e.deps.cwd,"config","--get","tapster.hub"],{allowFail:!0})).stdout.trim());if(s)return{gh:n,hub:ot(s,r),login:r};let o=i(await He(e.deps.cwd).catch(()=>null));if(o)return{gh:n,hub:ot(o,r),login:r};let a=await yl(n,r),c=a.filter((u)=>u.tapster),l=c.length===1?c[0]:a.length===1?a[0]:null;if(l)return{gh:n,hub:l.name,login:r};throw new v("there is no single hub to read",a.length?`Pass hub as one of: ${a.map((u)=>u.name).join(", ")}.`:"The user has no repository named homebrew-...; they can create one with bunx @doguyilmaz/tapster setup.")}var Uy=[{name:"hub_status",title:"Hub setup status",description:"Where the hub's setup stands: each step with its state, the projects it publishes, entries it refuses and the open health issue.",input:N(kn),readOnly:!0,async run(e,t){let{gh:n,hub:r}=await xn(t,e.hub),i=await bl(Ls(t.deps,0),n,r);return{hub:r,steps:Ly(i,null).map((s)=>({step:s.name,state:s.state,status:s.status})),projects:i.packages,refused:i.invalid,healthIssue:i.issue?{url:i.issue.url,updated:i.issue.updated,body:i.issue.body}:null,extras:i.extras}}},{name:"doctor",title:"Check the hub",description:"Run tapster doctor: every setting the hub's security depends on, each with the fix when it fails.",input:N(kn),readOnly:!0,async run(e,t){let{gh:n,hub:r}=await xn(t,e.hub),{checks:i,note:s}=await $r(n,r);return{hub:r,problems:i.filter((o)=>!o.ok),passed:i.filter((o)=>o.ok).map((o)=>o.name),note:s}}},{name:"hub_runs",title:"Recent hub runs",description:"The hub workflow's latest runs with their result and a link to each log.",input:N(kn),readOnly:!0,async run(e,t){let{gh:n,hub:r}=await xn(t,e.hub),i=await n.json("GET",`/repos/${r}/actions/workflows/tapster.yml/runs?per_page=10`);return{hub:r,runs:i.workflow_runs.map((s)=>({started:s.created_at,by:s.event,status:s.status,result:s.conclusion,log:s.html_url}))}}},{name:"release_status",title:"A project's releases",description:"A project's latest releases and drafts, what the hub wrote on a draft it will not publish and what the hub has published.",input:N({...kn,repo:E().regex(/^[A-Za-z0-9-]+\/[A-Za-z0-9._-]+$/).describe("The project as owner/name.")}),readOnly:!0,async run(e,t){let{gh:n,hub:r,login:i}=await xn(t,e.hub),s=String(e.repo),o=(await n.listReleases(s)).slice(0,8),a=await de(n,r,"tapster.yml","main"),c=a?ie(a,i).config.packages.find((u)=>u.repo.toLowerCase()===s.toLowerCase()):void 0,l=jy(await de(n,r,".tapster/state.json","main"));return{hub:r,repo:s,inHub:c?c.name:null,releases:o.map((u)=>({tag:u.tag_name,draft:u.draft,published:u.published_at,files:u.assets.length,hubNote:Dy(u.body)})),publishedByHub:c?(l.packages[c.name]??[]).map((u)=>({tag:u.tag,status:u.status})):[]}}},{name:"local_projects",title:"Projects on this computer",description:"Clones of the user's own repositories on this computer, the kind tapster recognizes and whether the hub publishes them.",input:N(kn),readOnly:!0,async run(e,t){let{gh:n,hub:r,login:i}=await xn(t,e.hub),s=await de(n,r,"tapster.yml","main"),o=new Set(s?ie(s,i).config.packages.map((l)=>l.repo.toLowerCase()):[]),{found:a,truncated:c}=qs(Zs(t.deps.home,t.deps.cwd).filter(Boolean));return{hub:r,projects:a.filter((l)=>l.owner.toLowerCase()===i.toLowerCase()).map((l)=>({repo:l.repo,path:l.path,kind:l.kind,notSupported:l.why,inHub:o.has(l.repo.toLowerCase())})),truncated:c,next:"To add one, the user runs bunx @doguyilmaz/tapster setup (Projects) or bunx @doguyilmaz/tapster add in its folder."}}},{name:"run_hub",title:"Start the hub",description:"Start a hub run now instead of waiting for its schedule. The hub then publishes the drafts that are ready.",input:N(kn),readOnly:!1,async run(e,t){let{gh:n,hub:r}=await xn(t,e.hub);return await n.json("POST",`/repos/${r}/actions/workflows/tapster.yml/dispatches`,{ref:"main"}),{hub:r,started:!0,runs:`https://github.com/${r}/actions/workflows/tapster.yml`}}}],Sn=(e,t)=>({jsonrpc:"2.0",id:e,result:t}),Hs=(e,t,n)=>({jsonrpc:"2.0",id:e??null,error:{code:t,message:n}});async function uC(e,t){if(e===null||typeof e!=="object"||Array.isArray(e))return Hs(null,-32600,"invalid request: send one JSON-RPC object per line");if(e.id===void 0||e.id===null)return null;if(e.method==="initialize"){let n=String(e.params?.protocolVersion??"");return Sn(e.id,{protocolVersion:My.includes(n)?n:My[0],capabilities:{tools:{listChanged:!1}},serverInfo:{name:"tapster",title:"tapster",version:ae.version},instructions:lC})}if(e.method==="ping")return Sn(e.id,{});if(e.method==="tools/list")return Sn(e.id,{tools:Uy.map((n)=>({name:n.name,title:n.title,description:n.description,inputSchema:Nm(n.input),annotations:{readOnlyHint:n.readOnly,openWorldHint:!0}}))});if(e.method==="tools/call"){let n=Uy.find((i)=>i.name===e.params?.name);if(!n)return Hs(e.id,-32602,`unknown tool ${String(e.params?.name)}`);let r=n.input.safeParse(e.params?.arguments??{});if(!r.success)return Sn(e.id,{content:[{type:"text",text:`Invalid arguments: ${r.error.issues.map((i)=>`${i.path.join(".")}: ${i.message}`).join("; ")}`}],isError:!0});try{let i=await n.run(r.data,t);return Sn(e.id,{content:[{type:"text",text:JSON.stringify(i,null,2)}],structuredContent:i})}catch(i){let s=i instanceof v?`${i.reason}. ${i.fix}`:"tapster hit an unexpected error. Try again; if it repeats, the user can run the same check in a terminal.";return Sn(e.id,{content:[{type:"text",text:s}],isError:!0})}}return Hs(e.id,-32601,`unknown method ${String(e.method)}`)}async function pC(e,t=process.stdin,n=(r)=>process.stdout.write(`${r}
1406
+ `))p()}),process.stdin.resume();await a,r.log("tapster setup stopped.")}import{createInterface as cC}from"readline";var rC=N({tag:E().regex($c),releaseId:_c().int().positive(),checksums:E().regex(/^[0-9a-f]{64}$/),status:kt(["publishing","published"]),app:N({macos:E().regex(/^[a-z_]+$/),identifiers:X(E().regex(/^[A-Za-z0-9.-]+$/))}).strict().optional()}).strict(),iC=N({version:xc(1),packages:rs(E().regex(dn),X(rC))}).strict(),sC=()=>({version:1,packages:{}}),zy=()=>new v(".tapster/state.json is damaged","Restore it from the hub's git history.");function Ly(e){if(e===null)return sC();let t;try{t=JSON.parse(e)}catch{throw zy()}let n=iC.safeParse(t);if(!n.success)throw zy();return n.data}function jy(e){let t=new RegExp("<!-- tapster -->\\s*([\\s\\S]*?)<!-- /tapster -->").exec(e??"")?.[1];return t?t.replace(/^>\s*/,"").replace(/\*\*/g,"").trim():null}function oC(e,t=Date.now()){let n=Date.parse(`${e}T00:00:00Z`);return!Number.isNaN(n)&&n-t<2592000000}function aC(e,t){if(e.apple.needed)return!0;return t===null?null:t==="yes"}function Dy(e,t,n=Date.now()){let r=aC(e,t),i=e.protect.checks.filter((a)=>a.ok).length,s=[{id:"protect",name:"Protect the hub",done:e.protect.done,status:e.protect.done?"All protections are on":i?`${i} of ${e.protect.checks.length} protections on`:"Not protected yet",open:"Not protected yet"},{id:"app",name:"Create the GitHub App",done:Boolean(e.app.id&&e.app.slug&&e.app.key),attention:Boolean(e.app.id&&!e.app.key),status:e.app.id&&!e.app.key?"The App's private key is missing":e.app.slug?e.app.slug:"Not created yet",open:"Not created yet"},{id:"macos",name:"macOS or not",done:r===!0,skipped:r===!1,status:r===!0?"Signs macOS software":r===!1?"No macOS builds":"Your answer",open:"Your answer"},{id:"certificate",name:"Apple certificate",done:Boolean(e.apple.certificate&&e.apple.certificateStored),skipped:r===!1,attention:Boolean(e.apple.certificate&&oC(e.apple.certificate.expires,n)),status:r===!1?"Not needed":e.apple.certificate?`Team ${e.apple.certificate.team}, expires ${e.apple.certificate.expires}`:"Not stored yet",open:"Not stored yet"},{id:"notary",name:"Notarization key",done:e.apple.notary,skipped:r===!1,status:r===!1?"Not needed":e.apple.notary?"Stored":"Not stored yet",open:"Not stored yet"},{id:"files",name:"Hub files",done:e.files.config&&e.files.state&&e.files.workflow!=="missing",attention:e.files.workflow==="older"||e.files.workflow==="other",status:e.files.workflow==="missing"?"Not written yet":e.files.workflow==="older"?`Runs ${e.files.pinned}; update available`:e.files.workflow==="other"?`Runs ${e.files.pinned??"a workflow tapster did not write"}; review it`:e.files.workflow==="newer"?`Runs ${e.files.pinned}, newer than this tapster`:`Runs ${e.files.pinned}`,open:"Not written yet"},{id:"project",name:"Your projects",done:e.packages.length>0,status:e.packages.length?`${e.packages.length} in the hub`:"None yet",open:"None yet"}],o=!1;return s.map((a)=>{let c;if(a.skipped)c="skipped";else if(a.attention)c="attention";else if(a.done)c="done";else if(!o)c="now",o=!0;else c="later";return{id:a.id,name:a.name,state:c,status:a.status}})}var My=["2025-11-25","2025-06-18","2025-03-26","2024-11-05"],lC=`tapster turns the user's Homebrew tap into a release hub that signs, notarizes and publishes the releases of their projects.
1407
+ These tools read the hub and the projects through the user's GitHub CLI sign-in and can start a hub run. They cannot set up a hub: creating the GitHub App needs the user's click and the Apple files live on their computer. For setup, tell the user to run "bunx @doguyilmaz/tapster setup", which opens a local page that walks through it. In a project, "bunx @doguyilmaz/tapster add" does the same from a terminal. Docs: https://tapster.doguyilmaz.com/`,kn={hub:E().optional().describe("The hub as owner/homebrew-name. Leave it out to use the hub of the current folder or the user's only hub.")};async function xn(e,t){let n=await e.gh(),r=(await n.json("GET","/user")).login;if(typeof t==="string"&&t)return{gh:n,hub:ot(t,r),login:r};let i=(u)=>u&&u.split("/")[0].toLowerCase()===r.toLowerCase()&&/\/homebrew-/.test(u)?u:null,s=i((await Pe("git",["-C",e.deps.cwd,"config","--get","tapster.hub"],{allowFail:!0})).stdout.trim());if(s)return{gh:n,hub:ot(s,r),login:r};let o=i(await He(e.deps.cwd).catch(()=>null));if(o)return{gh:n,hub:ot(o,r),login:r};let a=await yl(n,r),c=a.filter((u)=>u.tapster),l=c.length===1?c[0]:a.length===1?a[0]:null;if(l)return{gh:n,hub:l.name,login:r};throw new v("there is no single hub to read",a.length?`Pass hub as one of: ${a.map((u)=>u.name).join(", ")}.`:"The user has no repository named homebrew-...; they can create one with bunx @doguyilmaz/tapster setup.")}var Uy=[{name:"hub_status",title:"Hub setup status",description:"Where the hub's setup stands: each step with its state, the projects it publishes, entries it refuses and the open health issue.",input:N(kn),readOnly:!0,async run(e,t){let{gh:n,hub:r}=await xn(t,e.hub),i=await bl(Ds(t.deps,0),n,r);return{hub:r,steps:Dy(i,null).map((s)=>({step:s.name,state:s.state,status:s.status})),projects:i.packages,refused:i.invalid,healthIssue:i.issue?{url:i.issue.url,updated:i.issue.updated,body:i.issue.body}:null,extras:i.extras}}},{name:"doctor",title:"Check the hub",description:"Run tapster doctor: every setting the hub's security depends on, each with the fix when it fails.",input:N(kn),readOnly:!0,async run(e,t){let{gh:n,hub:r}=await xn(t,e.hub),{checks:i,note:s}=await $r(n,r);return{hub:r,problems:i.filter((o)=>!o.ok),passed:i.filter((o)=>o.ok).map((o)=>o.name),note:s}}},{name:"hub_runs",title:"Recent hub runs",description:"The hub workflow's latest runs with their result and a link to each log.",input:N(kn),readOnly:!0,async run(e,t){let{gh:n,hub:r}=await xn(t,e.hub),i=await n.json("GET",`/repos/${r}/actions/workflows/tapster.yml/runs?per_page=10`);return{hub:r,runs:i.workflow_runs.map((s)=>({started:s.created_at,by:s.event,status:s.status,result:s.conclusion,log:s.html_url}))}}},{name:"release_status",title:"A project's releases",description:"A project's latest releases and drafts, what the hub wrote on a draft it will not publish and what the hub has published.",input:N({...kn,repo:E().regex(/^[A-Za-z0-9-]+\/[A-Za-z0-9._-]+$/).describe("The project as owner/name.")}),readOnly:!0,async run(e,t){let{gh:n,hub:r,login:i}=await xn(t,e.hub),s=String(e.repo),o=(await n.listReleases(s)).slice(0,8),a=await de(n,r,"tapster.yml","main"),c=a?ie(a,i).config.packages.find((u)=>u.repo.toLowerCase()===s.toLowerCase()):void 0,l=Ly(await de(n,r,".tapster/state.json","main"));return{hub:r,repo:s,inHub:c?c.name:null,releases:o.map((u)=>({tag:u.tag_name,draft:u.draft,published:u.published_at,files:u.assets.length,hubNote:jy(u.body)})),publishedByHub:c?(l.packages[c.name]??[]).map((u)=>({tag:u.tag,status:u.status})):[]}}},{name:"local_projects",title:"Projects on this computer",description:"Clones of the user's own repositories on this computer, the kind tapster recognizes and whether the hub publishes them.",input:N(kn),readOnly:!0,async run(e,t){let{gh:n,hub:r,login:i}=await xn(t,e.hub),s=await de(n,r,"tapster.yml","main"),o=new Set(s?ie(s,i).config.packages.map((l)=>l.repo.toLowerCase()):[]),{found:a,truncated:c}=qs(Zs(t.deps.home,t.deps.cwd).filter(Boolean));return{hub:r,projects:a.filter((l)=>l.owner.toLowerCase()===i.toLowerCase()).map((l)=>({repo:l.repo,path:l.path,kind:l.kind,notSupported:l.why,inHub:o.has(l.repo.toLowerCase())})),truncated:c,next:"To add one, the user runs bunx @doguyilmaz/tapster setup (Projects) or bunx @doguyilmaz/tapster add in its folder."}}},{name:"run_hub",title:"Start the hub",description:"Start a hub run now instead of waiting for its schedule. The hub then publishes the drafts that are ready.",input:N(kn),readOnly:!1,async run(e,t){let{gh:n,hub:r}=await xn(t,e.hub);return await n.json("POST",`/repos/${r}/actions/workflows/tapster.yml/dispatches`,{ref:"main"}),{hub:r,started:!0,runs:`https://github.com/${r}/actions/workflows/tapster.yml`}}}],Sn=(e,t)=>({jsonrpc:"2.0",id:e,result:t}),Hs=(e,t,n)=>({jsonrpc:"2.0",id:e??null,error:{code:t,message:n}});async function uC(e,t){if(e===null||typeof e!=="object"||Array.isArray(e))return Hs(null,-32600,"invalid request: send one JSON-RPC object per line");if(e.id===void 0||e.id===null)return null;if(e.method==="initialize"){let n=String(e.params?.protocolVersion??"");return Sn(e.id,{protocolVersion:My.includes(n)?n:My[0],capabilities:{tools:{listChanged:!1}},serverInfo:{name:"tapster",title:"tapster",version:ae.version},instructions:lC})}if(e.method==="ping")return Sn(e.id,{});if(e.method==="tools/list")return Sn(e.id,{tools:Uy.map((n)=>({name:n.name,title:n.title,description:n.description,inputSchema:Nm(n.input),annotations:{readOnlyHint:n.readOnly,openWorldHint:!0}}))});if(e.method==="tools/call"){let n=Uy.find((i)=>i.name===e.params?.name);if(!n)return Hs(e.id,-32602,`unknown tool ${String(e.params?.name)}`);let r=n.input.safeParse(e.params?.arguments??{});if(!r.success)return Sn(e.id,{content:[{type:"text",text:`Invalid arguments: ${r.error.issues.map((i)=>`${i.path.join(".")}: ${i.message}`).join("; ")}`}],isError:!0});try{let i=await n.run(r.data,t);return Sn(e.id,{content:[{type:"text",text:JSON.stringify(i,null,2)}],structuredContent:i})}catch(i){let s=i instanceof v?`${i.reason}. ${i.fix}`:"tapster hit an unexpected error. Try again; if it repeats, the user can run the same check in a terminal.";return Sn(e.id,{content:[{type:"text",text:s}],isError:!0})}}return Hs(e.id,-32601,`unknown method ${String(e.method)}`)}async function pC(e,t=process.stdin,n=(r)=>process.stdout.write(`${r}
1408
1408
  `)){let r=cC({input:t,crlfDelay:1/0});for await(let i of r){if(!i.trim())continue;let s;try{s=JSON.parse(i)}catch{n(JSON.stringify(Hs(null,-32700,"parse error")));continue}let o=await uC(s,e);if(o)n(JSON.stringify(o))}}async function Zy(e){if(e.length)throw new v(`unknown option ${e.join(" ")}`,"tapster mcp takes no options.");let t={...Sl(null),log:(n)=>process.stderr.write(`${n}
1409
1409
  `)};await pC({deps:t,gh:()=>t.github()})}var dC=`tapster: publish your projects' releases from one Homebrew tap
1410
1410
 
@@ -1419,7 +1419,7 @@ Run tapster <command> --help for the options: Sparkle and Linux keys, the doorbe
1419
1419
 
1420
1420
  tapster setup [--no-open] [--port <port>] [--tapster <commit>]
1421
1421
  --no-open print the link instead of opening the browser
1422
- --port listen on this port instead of ${jr}
1422
+ --port listen on this port instead of ${Lr}
1423
1423
  --tapster pin the hub workflow to this commit (for a tapster built from a checkout)
1424
1424
 
1425
1425
  The page runs on this computer only and works until you stop tapster setup with Ctrl+C.`,init:`tapster init: set up the hub in this clone; every step can run again and skips what is done