@doguyilmaz/tapster 1.2.0 → 1.3.0

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 +4 -3
  2. package/dist/cli.js +220 -208
  3. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -1,170 +1,170 @@
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(`
5
- `)?Qs(n,t):n.includes(`
3
+ var Ty=Object.defineProperty;var T=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Py=(e)=>e;function Ey(e,t){this[e]=Py.bind(null,t)}var Wl=(e,t)=>{for(var n in t)Ty(e,n,{get:t[n],enumerable:!0,configurable:!0,set:Ey.bind(t,n)})};var ze=import.meta.require;var j=T(function(Ly){var ci=Symbol.for("yaml.alias"),Vl=Symbol.for("yaml.document"),Kr=Symbol.for("yaml.map"),Yl=Symbol.for("yaml.pair"),li=Symbol.for("yaml.scalar"),Wr=Symbol.for("yaml.seq"),rt=Symbol.for("yaml.node.type"),Oy=(e)=>!!e&&typeof e==="object"&&e[rt]===ci,Cy=(e)=>!!e&&typeof e==="object"&&e[rt]===Vl,Ry=(e)=>!!e&&typeof e==="object"&&e[rt]===Kr,Iy=(e)=>!!e&&typeof e==="object"&&e[rt]===Yl,Jl=(e)=>!!e&&typeof e==="object"&&e[rt]===li,Ny=(e)=>!!e&&typeof e==="object"&&e[rt]===Wr;function Ql(e){if(e&&typeof e==="object")switch(e[rt]){case Kr:case Wr:return!0}return!1}function zy(e){if(e&&typeof e==="object")switch(e[rt]){case ci:case Kr:case li:case Wr:return!0}return!1}var jy=(e)=>(Jl(e)||Ql(e))&&!!e.anchor;Ly.ALIAS=ci;Ly.DOC=Vl;Ly.MAP=Kr;Ly.NODE_TYPE=rt;Ly.PAIR=Yl;Ly.SCALAR=li;Ly.SEQ=Wr;Ly.hasAnchor=jy;Ly.isAlias=Oy;Ly.isCollection=Ql;Ly.isDocument=Cy;Ly.isMap=Ry;Ly.isNode=zy;Ly.isPair=Iy;Ly.isScalar=Jl;Ly.isSeq=Ny});var jn=T(function(e0){var Q=j(),me=Symbol("break visit"),Xl=Symbol("skip children"),Ge=Symbol("remove node");function Vr(e,t){let n=eu(t);if(Q.isDocument(e)){if(on(null,e.contents,n,Object.freeze([e]))===Ge)e.contents=null}else on(null,e,n,Object.freeze([]))}Vr.BREAK=me;Vr.SKIP=Xl;Vr.REMOVE=Ge;function on(e,t,n,r){let s=tu(e,t,n,r);if(Q.isNode(s)||Q.isPair(s))return nu(e,r,s),on(e,s,n,r);if(typeof s!=="symbol"){if(Q.isCollection(t)){r=Object.freeze(r.concat(t));for(let o=0;o<t.items.length;++o){let i=on(o,t.items[o],n,r);if(typeof i==="number")o=i-1;else if(i===me)return me;else if(i===Ge)t.items.splice(o,1),o-=1}}else if(Q.isPair(t)){r=Object.freeze(r.concat(t));let o=on("key",t.key,n,r);if(o===me)return me;else if(o===Ge)t.key=null;let i=on("value",t.value,n,r);if(i===me)return me;else if(i===Ge)t.value=null}}return s}async function Yr(e,t){let n=eu(t);if(Q.isDocument(e)){if(await an(null,e.contents,n,Object.freeze([e]))===Ge)e.contents=null}else await an(null,e,n,Object.freeze([]))}Yr.BREAK=me;Yr.SKIP=Xl;Yr.REMOVE=Ge;async function an(e,t,n,r){let s=await tu(e,t,n,r);if(Q.isNode(s)||Q.isPair(s))return nu(e,r,s),an(e,s,n,r);if(typeof s!=="symbol"){if(Q.isCollection(t)){r=Object.freeze(r.concat(t));for(let o=0;o<t.items.length;++o){let i=await an(o,t.items[o],n,r);if(typeof i==="number")o=i-1;else if(i===me)return me;else if(i===Ge)t.items.splice(o,1),o-=1}}else if(Q.isPair(t)){r=Object.freeze(r.concat(t));let o=await an("key",t.key,n,r);if(o===me)return me;else if(o===Ge)t.key=null;let i=await an("value",t.value,n,r);if(i===me)return me;else if(i===Ge)t.value=null}}return s}function eu(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 tu(e,t,n,r){if(typeof n==="function")return n(e,t,r);if(Q.isMap(t))return n.Map?.(e,t,r);if(Q.isSeq(t))return n.Seq?.(e,t,r);if(Q.isPair(t))return n.Pair?.(e,t,r);if(Q.isScalar(t))return n.Scalar?.(e,t,r);if(Q.isAlias(t))return n.Alias?.(e,t,r);return}function nu(e,t,n){let r=t[t.length-1];if(Q.isCollection(r))r.items[e]=n;else if(Q.isPair(r))if(e==="key")r.key=n;else r.value=n;else if(Q.isDocument(r))r.contents=n;else{let s=Q.isAlias(r)?"alias":"scalar";throw Error(`Cannot replace node with ${s} parent`)}}e0.visit=Vr;e0.visitAsync=Yr});var ui=T(function(i0){var ru=j(),r0=jn(),s0={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},o0=(e)=>e.replace(/[!,[\]{}]/g,(t)=>s0[t]);class $e{constructor(e,t){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},$e.defaultYaml,e),this.tags=Object.assign({},$e.defaultTags,t)}clone(){let e=new $e(this.yaml,this.tags);return e.docStart=this.docStart,e}atDocument(){let e=new $e(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:$e.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},$e.defaultTags);break}return e}add(e,t){if(this.atNextDocument)this.yaml={explicit:$e.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},$e.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[s,o]=n;return this.tags[s]=o,!0}case"%YAML":{if(this.yaml.explicit=!0,n.length!==1)return t(0,"%YAML directive should contain exactly one part"),!1;let[s]=n;if(s==="1.1"||s==="1.2")return this.yaml.version=s,!0;else{let o=/^\d+\.\d+$/.test(s);return t(6,`Unsupported YAML version ${s}`,o),!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 o=e.slice(2,-1);if(o==="!"||o==="!!")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 o}let[,n,r]=e.match(/^(.*!)([^!]*)$/s);if(!r)t(`The ${e} tag has no suffix`);let s=this.tags[n];if(s)try{return s+decodeURIComponent(r)}catch(o){return t(String(o)),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+o0(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&&ru.isNode(e.contents)){let s={};r0.visit(e.contents,(o,i)=>{if(ru.isNode(i)&&i.tag)s[i.tag]=!0}),r=Object.keys(s)}else r=[];for(let[s,o]of n){if(s==="!!"&&o==="tag:yaml.org,2002:")continue;if(!e||r.some((i)=>i.startsWith(o)))t.push(`%TAG ${s} ${o}`)}return t.join(`
4
+ `)}}$e.defaultYaml={explicit:!1,version:"1.2"};$e.defaultTags={"!!":"tag:yaml.org,2002:"};i0.Directives=$e});var Jr=T(function(p0){var su=j(),c0=jn();function l0(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 ou(e){let t=new Set;return c0.visit(e,{Value(n,r){if(r.anchor)t.add(r.anchor)}}),t}function iu(e,t){for(let n=1;;++n){let r=`${e}${n}`;if(!t.has(r))return r}}function u0(e,t){let n=[],r=new Map,s=null;return{onAnchor:(o)=>{n.push(o),s??(s=ou(e));let i=iu(t,s);return s.add(i),i},setAnchors:()=>{for(let o of n){let i=r.get(o);if(typeof i==="object"&&i.anchor&&(su.isScalar(i.node)||su.isCollection(i.node)))i.node.anchor=i.anchor;else{let a=Error("Failed to resolve repeated object (this should not happen)");throw a.source=o,a}}},sourceObjects:r}}p0.anchorIsValid=l0;p0.anchorNames=ou;p0.createNodeAnchors=u0;p0.findNewAnchor=iu});var pi=T(function(g0){function Ln(e,t,n,r){if(r&&typeof r==="object")if(Array.isArray(r))for(let s=0,o=r.length;s<o;++s){let i=r[s],a=Ln(e,r,String(s),i);if(a===void 0)delete r[s];else if(a!==i)r[s]=a}else if(r instanceof Map)for(let s of Array.from(r.keys())){let o=r.get(s),i=Ln(e,r,s,o);if(i===void 0)r.delete(s);else if(i!==o)r.set(s,i)}else if(r instanceof Set)for(let s of Array.from(r)){let o=Ln(e,r,s,s);if(o===void 0)r.delete(s);else if(o!==s)r.delete(s),r.add(o)}else for(let[s,o]of Object.entries(r)){let i=Ln(e,r,s,o);if(i===void 0)delete r[s];else if(i!==o)r[s]=i}return e.call(t,n,r)}g0.applyReviver=Ln});var ht=T(function(y0){var b0=j();function au(e,t,n){if(Array.isArray(e))return e.map((r,s)=>au(r,String(s),n));if(e&&typeof e.toJSON==="function"){if(!n||!b0.hasAnchor(e))return e.toJSON(t,n);let r={aliasCount:0,count:1,res:void 0};n.anchors.set(e,r),n.onCreate=(o)=>{r.res=o,delete n.onCreate};let s=e.toJSON(t,n);if(n.onCreate)n.onCreate(s);return s}if(typeof e==="bigint"&&!n?.keep)return Number(e);return e}y0.toJS=au});var Qr=T(function(x0){var _0=pi(),cu=j(),k0=ht();class lu{constructor(e){Object.defineProperty(this,cu.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:s}={}){if(!cu.isDocument(e))throw TypeError("A document argument is required");let o={anchors:new Map,doc:e,keep:!0,mapAsMap:t===!0,mapKeyWarned:!1,maxAliasCount:typeof n==="number"?n:100},i=k0.toJS(this,"",o);if(typeof r==="function")for(let{count:a,res:c}of o.anchors.values())r(c,a);return typeof s==="function"?_0.applyReviver(s,{"":i},"",i):i}}x0.NodeBase=lu});var Dn=T(function(E0){var A0=Jr(),$0=jn(),cn=j(),T0=Qr(),P0=ht();class uu extends T0.NodeBase{constructor(e){super(cn.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=[],$0.visit(e,{Node:(s,o)=>{if(cn.isAlias(o)||cn.hasAnchor(o))n.push(o)}}),t)t.aliasResolveCache=n;let r=void 0;for(let s of n){if(s===this)break;if(s.anchor===this.source)r=s}if(r&&t){let{anchors:s,doc:o,maxAliasCount:i}=t,a=s.get(r);if(!a)P0.toJS(r,null,t),a=s.get(r);if(a?.res===void 0)throw ReferenceError("This should not happen: Alias anchor was not resolved?");if(i>=0){if(a.count+=1,a.aliasCount===0)a.aliasCount=Xr(o,r,s);if(a.count*a.aliasCount>i)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(A0.anchorIsValid(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){let s=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw Error(s)}if(e.implicitKey)return`${r} `}return r}}function Xr(e,t,n){if(cn.isAlias(t)){let r=t.resolve(e),s=n&&r&&n.get(r);return s?s.count*s.aliasCount:0}else if(cn.isCollection(t)){let r=0;for(let s of t.items){let o=Xr(e,s,n);if(o>r)r=o}return r}else if(cn.isPair(t)){let r=Xr(e,t.key,n),s=Xr(e,t.value,n);return Math.max(r,s)}return 1}E0.Alias=uu});var J=T(function(z0){var C0=j(),R0=Qr(),I0=ht(),N0=(e)=>!e||typeof e!=="function"&&typeof e!=="object";class jt extends R0.NodeBase{constructor(e){super(C0.SCALAR);this.value=e}toJSON(e,t){return t?.keep?this.value:I0.toJS(this.value,e,t)}toString(){return String(this.value)}}jt.BLOCK_FOLDED="BLOCK_FOLDED";jt.BLOCK_LITERAL="BLOCK_LITERAL";jt.PLAIN="PLAIN";jt.QUOTE_DOUBLE="QUOTE_DOUBLE";jt.QUOTE_SINGLE="QUOTE_SINGLE";z0.Scalar=jt;z0.isScalarValue=N0});var Mn=T(function(H0){var D0=Dn(),Lt=j(),pu=J(),M0="tag:yaml.org,2002:";function U0(e,t,n){if(t){let r=n.filter((o)=>o.tag===t),s=r.find((o)=>!o.format)??r[0];if(!s)throw Error(`Tag ${t} not found`);return s}return n.find((r)=>r.identify?.(e)&&!r.format)}function G0(e,t,n){if(Lt.isDocument(e))e=e.contents;if(Lt.isNode(e))return e;if(Lt.isPair(e)){let p=n.schema[Lt.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:s,onTagObj:o,schema:i,sourceObjects:a}=n,c=void 0;if(r&&e&&typeof e==="object")if(c=a.get(e),c)return c.anchor??(c.anchor=s(e)),new D0.Alias(c.anchor);else c={anchor:null,node:null},a.set(e,c);if(t?.startsWith("!!"))t=M0+t.slice(2);let l=U0(e,t,i.tags);if(!l){if(e&&typeof e.toJSON==="function")e=e.toJSON();if(!e||typeof e!=="object"){let p=new pu.Scalar(e);if(c)c.node=p;return p}l=e instanceof Map?i[Lt.MAP]:(Symbol.iterator in Object(e))?i[Lt.SEQ]:i[Lt.MAP]}if(o)o(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 pu.Scalar(e);if(t)u.tag=t;else if(!l.default)u.tag=l.tag;if(c)c.node=u;return u}H0.createNode=G0});var es=T(function(F0){var q0=Mn(),He=j(),B0=Qr();function di(e,t,n){let r=n;for(let s=t.length-1;s>=0;--s){let o=t[s];if(typeof o==="number"&&Number.isInteger(o)&&o>=0){let i=[];i[o]=r,r=i}else r=new Map([[o,r]])}return q0.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 du=(e)=>e==null||typeof e==="object"&&!!e[Symbol.iterator]().next().done;class hu extends B0.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)=>He.isNode(n)||He.isPair(n)?n.clone(e):n),this.range)t.range=this.range.slice();return t}addIn(e,t){if(du(e))this.add(t);else{let[n,...r]=e,s=this.get(n,!0);if(He.isCollection(s))s.addIn(r,t);else if(s===void 0&&this.schema)this.set(n,di(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(He.isCollection(r))return r.deleteIn(n);else throw Error(`Expected YAML collection at ${t}. Remaining path: ${n}`)}getIn(e,t){let[n,...r]=e,s=this.get(n,!0);if(r.length===0)return!t&&He.isScalar(s)?s.value:s;else return He.isCollection(s)?s.getIn(r,t):void 0}hasAllNullValues(e){return this.items.every((t)=>{if(!He.isPair(t))return!1;let n=t.value;return n==null||e&&He.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 He.isCollection(r)?r.hasIn(n):!1}setIn(e,t){let[n,...r]=e;if(r.length===0)this.set(n,t);else{let s=this.get(n,!0);if(He.isCollection(s))s.setIn(r,t);else if(s===void 0&&this.schema)this.set(n,di(this.schema,r,t));else throw Error(`Expected YAML collection at ${n}. Remaining path: ${r}`)}}}F0.Collection=hu;F0.collectionFromPath=di;F0.isEmptyPath=du});var Un=T(function(Q0){var Y0=(e)=>e.replace(/^(?!$)(?: $)?/gm,"#");function hi(e,t){if(/^\n+$/.test(e))return e.substring(1);return t?e.replace(/^(?! *$)/gm,t):e}var J0=(e,t,n)=>e.endsWith(`
5
+ `)?hi(n,t):n.includes(`
6
6
  `)?`
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(_===`
8
- `){if(n==="block")m=Hl(e,m,t.length);p=m+t.length+c,d=void 0}else{if(_===" "&&h&&h!==" "&&h!==`
9
- `&&h!=="\t"){let y=e[m+1];if(y&&y!==" "&&y!==`
10
- `&&y!=="\t")d=m}if(m>=p)if(d)l.push(d),p=d+c,d=void 0;else if(n==="quoted"){while(h===" "||h==="\t")h=_,_=e[m+=1],f=!0;let y=m>w+1?m-2:g-1;if(u[y])return e;l.push(y),u[y]=!0,p=y+c,d=void 0}else f=!0}h=_}if(f&&a)a();if(l.length===0)return e;if(o)o();let k=e.slice(0,l[0]);for(let _=0;_<l.length;++_){let y=l[_],x=l[_+1]||e.length;if(y===0)k=`
11
- ${t}${e.slice(0,x)}`;else{if(n==="quoted"&&u[y])k+=`${e[y]}\\`;k+=`
12
- ${t}${e.slice(y+1,x)}`}}return k}function Hl(e,t,n){let r=t,i=t+1,s=e[i];while(s===" "||s==="\t")if(t<i+n)s=e[++t];else{do s=e[++t];while(s&&s!==`
13
- `);r=t,i=t+1,s=e[i]}return r}_w.FOLD_BLOCK="block";_w.FOLD_FLOW="flow";_w.FOLD_QUOTED="quoted";_w.foldFlowLines=ww});var Rn=P(function(Ew){var Re=W(),lt=Fl(),Fr=(e,t)=>({indentAtStart:t?e.indent.length:e.indentAtStart,lineWidth:e.options.lineWidth,minContentWidth:e.options.minContentWidth}),Kr=(e)=>/^(%|---|\.\.\.)/m.test(e);function $w(e,t,n){if(!t||t<0)return!1;let r=t-n,i=e.length;if(i<=r)return!1;for(let s=0,o=0;s<i;++s)if(e[s]===`
14
- `){if(s-o>r)return!0;if(o=s+1,i-o<=r)return!1}return!0}function Cn(e,t){let n=JSON.stringify(e);if(t.options.doubleQuotedAsJSON)return n;let{implicitKey:r}=t,i=t.options.doubleQuotedMinMultiLineLength,s=t.indent||(Kr(e)?" ":""),o="",a=0;for(let c=0,l=n[c];l;l=n[++c]){if(l===" "&&n[c+1]==="\\"&&n[c+2]==="n")o+=n.slice(a,c)+"\\ ",c+=1,a=c,l="\\";if(l==="\\")switch(n[c+1]){case"u":{o+=n.slice(a,c);let u=n.substr(c+2,4);switch(u){case"0000":o+="\\0";break;case"0007":o+="\\a";break;case"000b":o+="\\v";break;case"001b":o+="\\e";break;case"0085":o+="\\N";break;case"00a0":o+="\\_";break;case"2028":o+="\\L";break;case"2029":o+="\\P";break;default:if(u.substr(0,2)==="00")o+="\\x"+u.substr(2);else o+=n.substr(c,6)}c+=5,a=c+1}break;case"n":if(r||n[c+2]==='"'||n.length<i)c+=1;else{o+=n.slice(a,c)+`
15
-
16
- `;while(n[c+2]==="\\"&&n[c+3]==="n"&&n[c+4]!=='"')o+=`
17
- `,c+=2;if(o+=s,n[c+2]===" ")o+="\\";c+=1,a=c+1}break;default:c+=1}}return o=a?o+n.slice(a):n,r?o:lt.foldFlowLines(o,s,lt.FOLD_QUOTED,Fr(t,!1))}function Xs(e,t){if(t.options.singleQuote===!1||t.implicitKey&&e.includes(`
18
- `)||/[ \t]\n|\n[ \t]/.test(e))return Cn(e,t);let n=t.indent||(Kr(e)?" ":""),r="'"+e.replace(/'/g,"''").replace(/\n+/g,`$&
19
- ${n}`)+"'";return t.implicitKey?r:lt.foldFlowLines(r,n,lt.FOLD_FLOW,Fr(t,!1))}function Jt(e,t){let{singleQuote:n}=t.options,r;if(n===!1)r=Cn;else{let i=e.includes('"'),s=e.includes("'");if(i&&!s)r=Xs;else if(s&&!i)r=Cn;else r=n?Xs:Cn}return r(e,t)}var eo;try{eo=new RegExp(`(^|(?<!
7
+ `+hi(n,t):(e.endsWith(" ")?"":" ")+n;Q0.indentComment=hi;Q0.lineComment=J0;Q0.stringifyComment=Y0});var mu=T(function(rw){function nw(e,t,n="flow",{indentAtStart:r,lineWidth:s=80,minContentWidth:o=20,onFold:i,onOverflow:a}={}){if(!s||s<0)return e;if(s<o)o=0;let c=Math.max(1+o,1+s-t.length);if(e.length<=c)return e;let l=[],u={},p=s-t.length;if(typeof r==="number")if(r>s-Math.max(2,o))l.push(0);else p=s-r;let d=void 0,h=void 0,f=!1,m=-1,v=-1,_=-1;if(n==="block"){if(m=fu(e,m,t.length),m!==-1)p=m+c}for(let y;y=e[m+=1];){if(n==="quoted"&&y==="\\"){switch(v=m,e[m+1]){case"x":m+=3;break;case"u":m+=5;break;case"U":m+=9;break;default:m+=1}_=m}if(y===`
8
+ `){if(n==="block")m=fu(e,m,t.length);p=m+t.length+c,d=void 0}else{if(y===" "&&h&&h!==" "&&h!==`
9
+ `&&h!=="\t"){let b=e[m+1];if(b&&b!==" "&&b!==`
10
+ `&&b!=="\t")d=m}if(m>=p)if(d)l.push(d),p=d+c,d=void 0;else if(n==="quoted"){while(h===" "||h==="\t")h=y,y=e[m+=1],f=!0;let b=m>_+1?m-2:v-1;if(u[b])return e;l.push(b),u[b]=!0,p=b+c,d=void 0}else f=!0}h=y}if(f&&a)a();if(l.length===0)return e;if(i)i();let A=e.slice(0,l[0]);for(let y=0;y<l.length;++y){let b=l[y],k=l[y+1]||e.length;if(b===0)A=`
11
+ ${t}${e.slice(0,k)}`;else{if(n==="quoted"&&u[b])A+=`${e[b]}\\`;A+=`
12
+ ${t}${e.slice(b+1,k)}`}}return A}function fu(e,t,n){let r=t,s=t+1,o=e[s];while(o===" "||o==="\t")if(t<s+n)o=e[++t];else{do o=e[++t];while(o&&o!==`
13
+ `);r=t,s=t+1,o=e[s]}return r}rw.FOLD_BLOCK="block";rw.FOLD_FLOW="flow";rw.FOLD_QUOTED="quoted";rw.foldFlowLines=nw});var Hn=T(function(pw){var je=J(),ft=mu(),ns=(e,t)=>({indentAtStart:t?e.indent.length:e.indentAtStart,lineWidth:e.options.lineWidth,minContentWidth:e.options.minContentWidth}),rs=(e)=>/^(%|---|\.\.\.)/m.test(e);function cw(e,t,n){if(!t||t<0)return!1;let r=t-n,s=e.length;if(s<=r)return!1;for(let o=0,i=0;o<s;++o)if(e[o]===`
14
+ `){if(o-i>r)return!0;if(i=o+1,s-i<=r)return!1}return!0}function Gn(e,t){let n=JSON.stringify(e);if(t.options.doubleQuotedAsJSON)return n;let{implicitKey:r}=t,s=t.options.doubleQuotedMinMultiLineLength,o=t.indent||(rs(e)?" ":""),i="",a=0;for(let c=0,l=n[c];l;l=n[++c]){if(l===" "&&n[c+1]==="\\"&&n[c+2]==="n")i+=n.slice(a,c)+"\\ ",c+=1,a=c,l="\\";if(l==="\\")switch(n[c+1]){case"u":{i+=n.slice(a,c);let u=n.substr(c+2,4);switch(u){case"0000":i+="\\0";break;case"0007":i+="\\a";break;case"000b":i+="\\v";break;case"001b":i+="\\e";break;case"0085":i+="\\N";break;case"00a0":i+="\\_";break;case"2028":i+="\\L";break;case"2029":i+="\\P";break;default:if(u.substr(0,2)==="00")i+="\\x"+u.substr(2);else i+=n.substr(c,6)}c+=5,a=c+1}break;case"n":if(r||n[c+2]==='"'||n.length<s)c+=1;else{i+=n.slice(a,c)+`
15
+
16
+ `;while(n[c+2]==="\\"&&n[c+3]==="n"&&n[c+4]!=='"')i+=`
17
+ `,c+=2;if(i+=o,n[c+2]===" ")i+="\\";c+=1,a=c+1}break;default:c+=1}}return i=a?i+n.slice(a):n,r?i:ft.foldFlowLines(i,o,ft.FOLD_QUOTED,ns(t,!1))}function fi(e,t){if(t.options.singleQuote===!1||t.implicitKey&&e.includes(`
18
+ `)||/[ \t]\n|\n[ \t]/.test(e))return Gn(e,t);let n=t.indent||(rs(e)?" ":""),r="'"+e.replace(/'/g,"''").replace(/\n+/g,`$&
19
+ ${n}`)+"'";return t.implicitKey?r:ft.foldFlowLines(r,n,ft.FOLD_FLOW,ns(t,!1))}function ln(e,t){let{singleQuote:n}=t.options,r;if(n===!1)r=Gn;else{let s=e.includes('"'),o=e.includes("'");if(s&&!o)r=fi;else if(o&&!s)r=Gn;else r=n?fi:Gn}return r(e,t)}var mi;try{mi=new RegExp(`(^|(?<!
20
20
  ))
21
21
  +(?!
22
- |$)`,"g")}catch{eo=/\n+(?!\n|$)/g}function Hr({comment:e,type:t,value:n},r,i,s){let{blockQuote:o,commentString:a,lineWidth:c}=r.options;if(!o||/\n[\t ]+$/.test(n))return Jt(n,r);let l=r.indent||(r.forceBlockIndent||Kr(n)?" ":""),u=o==="literal"?!0:o==="folded"||t===Re.Scalar.BLOCK_FOLDED?!1:t===Re.Scalar.BLOCK_LITERAL?!0:!$w(n,c,l.length);if(!n)return u?`|
22
+ |$)`,"g")}catch{mi=/\n+(?!\n|$)/g}function ts({comment:e,type:t,value:n},r,s,o){let{blockQuote:i,commentString:a,lineWidth:c}=r.options;if(!i||/\n[\t ]+$/.test(n))return ln(n,r);let l=r.indent||(r.forceBlockIndent||rs(n)?" ":""),u=i==="literal"?!0:i==="folded"||t===je.Scalar.BLOCK_FOLDED?!1:t===je.Scalar.BLOCK_LITERAL?!0:!cw(n,c,l.length);if(!n)return u?`|
23
23
  `:`>
24
- `;let p,d;for(d=n.length;d>0;--d){let x=n[d-1];if(x!==`
25
- `&&x!=="\t"&&x!==" ")break}let h=n.substring(d),f=h.indexOf(`
26
- `);if(f===-1)p="-";else if(n===h||f!==h.length-1){if(p="+",s)s()}else p="";if(h){if(n=n.slice(0,-h.length),h[h.length-1]===`
27
- `)h=h.slice(0,-1);h=h.replace(eo,`$&${l}`)}let m=!1,g,w=-1;for(g=0;g<n.length;++g){let x=n[g];if(x===" ")m=!0;else if(x===`
28
- `)w=g;else break}let k=n.substring(0,w<g?w+1:g);if(k)n=n.substring(k.length),k=k.replace(/\n+/g,`$&${l}`);let y=(m?l?"2":"1":"")+p;if(e){if(y+=" "+a(e.replace(/ ?[\r\n]+/g," ")),i)i()}if(!u){let x=n.replace(/\n+/g,`
29
- $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${l}`),S=!1,O=Fr(r,!0);if(o!=="folded"&&t!==Re.Scalar.BLOCK_FOLDED)O.onOverflow=()=>{S=!0};let A=lt.foldFlowLines(`${k}${x}${h}`,l,lt.FOLD_BLOCK,O);if(!S)return`>${y}
30
- ${l}${A}`}return n=n.replace(/\n+/g,`$&${l}`),`|${y}
31
- ${l}${k}${n}${h}`}function Pw(e,t,n,r){let{type:i,value:s}=e,{actualString:o,implicitKey:a,indent:c,indentStep:l,inFlow:u}=t;if(a&&s.includes(`
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
- `)?Jt(s,t):Hr(e,t,n,r);if(!a&&!u&&i!==Re.Scalar.PLAIN&&s.includes(`
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}
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
- `:"",k){let O=l(k);S+=`
39
- ${Nn.indentComment(O,n.indent)}`}if(x===""&&!n.inFlow){if(S===`
40
- `&&_)S=`
24
+ `;let p,d;for(d=n.length;d>0;--d){let k=n[d-1];if(k!==`
25
+ `&&k!=="\t"&&k!==" ")break}let h=n.substring(d),f=h.indexOf(`
26
+ `);if(f===-1)p="-";else if(n===h||f!==h.length-1){if(p="+",o)o()}else p="";if(h){if(n=n.slice(0,-h.length),h[h.length-1]===`
27
+ `)h=h.slice(0,-1);h=h.replace(mi,`$&${l}`)}let m=!1,v,_=-1;for(v=0;v<n.length;++v){let k=n[v];if(k===" ")m=!0;else if(k===`
28
+ `)_=v;else break}let A=n.substring(0,_<v?_+1:v);if(A)n=n.substring(A.length),A=A.replace(/\n+/g,`$&${l}`);let b=(m?l?"2":"1":"")+p;if(e){if(b+=" "+a(e.replace(/ ?[\r\n]+/g," ")),s)s()}if(!u){let k=n.replace(/\n+/g,`
29
+ $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${l}`),S=!1,O=ns(r,!0);if(i!=="folded"&&t!==je.Scalar.BLOCK_FOLDED)O.onOverflow=()=>{S=!0};let x=ft.foldFlowLines(`${A}${k}${h}`,l,ft.FOLD_BLOCK,O);if(!S)return`>${b}
30
+ ${l}${x}`}return n=n.replace(/\n+/g,`$&${l}`),`|${b}
31
+ ${l}${A}${n}${h}`}function lw(e,t,n,r){let{type:s,value:o}=e,{actualString:i,implicitKey:a,indent:c,indentStep:l,inFlow:u}=t;if(a&&o.includes(`
32
+ `)||u&&/[[\]{},]/.test(o))return ln(o,t);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(o))return a||u||!o.includes(`
33
+ `)?ln(o,t):ts(e,t,n,r);if(!a&&!u&&s!==je.Scalar.PLAIN&&o.includes(`
34
+ `))return ts(e,t,n,r);if(rs(o)){if(c==="")return t.forceBlockIndent=!0,ts(e,t,n,r);else if(a&&c===l)return ln(o,t)}let p=o.replace(/\n+/g,`$&
35
+ ${c}`);if(i){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 ln(o,t)}return a?p:ft.foldFlowLines(p,c,ft.FOLD_FLOW,ns(t,!1))}function uw(e,t,n,r){let{implicitKey:s,inFlow:o}=t,i=typeof e.value==="string"?e:Object.assign({},e,{value:String(e.value)}),{type:a}=e;if(a!==je.Scalar.QUOTE_DOUBLE){if(/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(i.value))a=je.Scalar.QUOTE_DOUBLE}let c=(u)=>{switch(u){case je.Scalar.BLOCK_FOLDED:case je.Scalar.BLOCK_LITERAL:return s||o?ln(i.value,t):ts(i,t,n,r);case je.Scalar.QUOTE_DOUBLE:return Gn(i.value,t);case je.Scalar.QUOTE_SINGLE:return fi(i.value,t);case je.Scalar.PLAIN:return lw(i,t,n,r);default:return null}},l=c(a);if(l===null){let{defaultKeyType:u,defaultStringType:p}=t.options,d=s&&u||p;if(l=c(d),l===null)throw Error(`Unsupported default string type ${d}`)}return l}pw.stringifyString=uw});var Zn=T(function(ww){var hw=Jr(),mt=j(),fw=Un(),mw=Hn();function gw(e,t){let n=Object.assign({blockQuote:!0,commentString:fw.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 vw(e,t){if(t.tag){let s=e.filter((o)=>o.tag===t.tag);if(s.length>0)return s.find((o)=>o.format===t.format)??s[0]}let n=void 0,r;if(mt.isScalar(t)){r=t.value;let s=e.filter((o)=>o.identify?.(r));if(s.length>1){let o=s.filter((i)=>i.test);if(o.length>0)s=o}n=s.find((o)=>o.format===t.format)??s.find((o)=>!o.format)}else r=t,n=e.find((s)=>s.nodeClass&&r instanceof s.nodeClass);if(!n){let s=r?.constructor?.name??(r===null?"null":typeof r);throw Error(`Tag not resolved for ${s} value`)}return n}function bw(e,t,{anchors:n,doc:r}){if(!r.directives)return"";let s=[],o=(mt.isScalar(e)||mt.isCollection(e))&&e.anchor;if(o&&hw.anchorIsValid(o))n.add(o),s.push(`&${o}`);let i=e.tag??(t.default?null:t.tag);if(i)s.push(r.directives.tagString(i));return s.join(" ")}function yw(e,t,n,r){if(mt.isPair(e))return e.toString(t,n,r);if(mt.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 s=void 0,o=mt.isNode(e)?e:t.doc.createNode(e,{onTagObj:(c)=>s=c});s??(s=vw(t.doc.schema.tags,o));let i=bw(o,s,t);if(i.length>0)t.indentAtStart=(t.indentAtStart??0)+i.length+1;let a=typeof s.stringify==="function"?s.stringify(o,t,n,r):mt.isScalar(o)?mw.stringifyString(o,t,n,r):o.toString(t,n,r);if(!i)return a;return mt.isScalar(o)||a[0]==="{"||a[0]==="["?`${i} ${a}`:`${i}
36
+ ${t.indent}${a}`}ww.createStringifyContext=gw;ww.stringify=yw});var bu=T(function(Sw){var st=j(),gu=J(),vu=Zn(),qn=Un();function xw({key:e,value:t},n,r,s){let{allNullValues:o,doc:i,indent:a,indentStep:c,options:{commentString:l,indentSeq:u,simpleKeys:p}}=n,d=st.isNode(e)&&e.comment||null;if(p){if(d)throw Error("With simple keys, key nodes cannot have comments");if(st.isCollection(e)||!st.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||st.isCollection(e)||(st.isScalar(e)?e.type===gu.Scalar.BLOCK_FOLDED||e.type===gu.Scalar.BLOCK_LITERAL:typeof e==="object"));n=Object.assign({},n,{allNullValues:!1,implicitKey:!h&&(p||!o),indent:a+c});let f=!1,m=!1,v=vu.stringify(e,n,()=>f=!0,()=>m=!0);if(!h&&!n.inFlow&&v.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(o||t==null){if(f&&r)r();return v===""?"?":h?`? ${v}`:v}}else if(o&&!p||t==null&&h){if(v=`? ${v}`,d&&!f)v+=qn.lineComment(v,n.indent,l(d));else if(m&&s)s();return v}if(f)d=null;if(h){if(d)v+=qn.lineComment(v,n.indent,l(d));v=`? ${v}
37
+ ${a}:`}else if(v=`${v}:`,d)v+=qn.lineComment(v,n.indent,l(d));let _,A,y;if(st.isNode(t))_=!!t.spaceBefore,A=t.commentBefore,y=t.comment;else if(_=!1,A=null,y=null,t&&typeof t==="object")t=i.createNode(t);if(n.implicitKey=!1,!h&&!d&&st.isScalar(t))n.indentAtStart=v.length+1;if(m=!1,!u&&c.length>=2&&!n.inFlow&&!h&&st.isSeq(t)&&!t.flow&&!t.tag&&!t.anchor)n.indent=n.indent.substring(2);let b=!1,k=vu.stringify(t,n,()=>b=!0,()=>m=!0),S=" ";if(d||_||A){if(S=_?`
38
+ `:"",A){let O=l(A);S+=`
39
+ ${qn.indentComment(O,n.indent)}`}if(k===""&&!n.inFlow){if(S===`
40
+ `&&y)S=`
41
41
 
42
42
  `}else S+=`
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=`
45
- ${n.indent}`}}else if(x===""||x[0]===`
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?`
43
+ ${n.indent}`}else if(!h&&st.isCollection(t)){let O=k[0],x=k.indexOf(`
44
+ `),N=x!==-1,pe=n.inFlow??t.flow??t.items.length===0;if(N||!pe){let Ae=!1;if(N&&(O==="&"||O==="!")){let q=k.indexOf(" ");if(O==="&"&&q!==-1&&q<x&&k[q+1]==="!")q=k.indexOf(" ",q+1);if(q===-1||x<q)Ae=!0}if(!Ae)S=`
45
+ ${n.indent}`}}else if(k===""||k[0]===`
46
+ `)S="";if(v+=S+k,n.inFlow){if(b&&r)r()}else if(y&&!b)v+=qn.lineComment(v,n.indent,l(y));else if(m&&s)s();return v}Sw.stringifyPair=xw});var gi=T(function(Pw){var yu=ze("process");function $w(e,...t){if(e==="debug")console.log(...t)}function Tw(e,t){if(e==="debug"||e==="warn")if(typeof yu.emitWarning==="function")yu.emitWarning(t);else console.warn(t)}Pw.debug=$w;Pw.warn=Tw});var as=T(function(Rw){var is=j(),wu=J(),ss="<<",os={identify:(e)=>e===ss||typeof e==="symbol"&&e.description===ss,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new wu.Scalar(Symbol(ss)),{addToJSMap:_u}),stringify:()=>ss},Cw=(e,t)=>(os.identify(t)||is.isScalar(t)&&(!t.type||t.type===wu.Scalar.PLAIN)&&os.identify(t.value))&&e?.doc.schema.tags.some((n)=>n.tag===os.tag&&n.default);function _u(e,t,n){let r=ku(e,n);if(is.isSeq(r))for(let s of r.items)vi(e,t,s);else if(Array.isArray(r))for(let s of r)vi(e,t,s);else vi(e,t,r)}function vi(e,t,n){let r=ku(e,n);if(!is.isMap(r))throw Error("Merge sources must be maps or map aliases");let s=r.toJSON(null,e,Map);for(let[o,i]of s)if(t instanceof Map){if(!t.has(o))t.set(o,i)}else if(t instanceof Set)t.add(o);else if(!Object.prototype.hasOwnProperty.call(t,o))Object.defineProperty(t,o,{value:i,writable:!0,enumerable:!0,configurable:!0});return t}function ku(e,t){return e&&is.isAlias(t)?t.resolve(e.doc,e):t}Rw.addMergeToJSMap=_u;Rw.isMergeKey=Cw;Rw.merge=os});var yi=T(function(Uw){var jw=gi(),xu=as(),Lw=Zn(),Su=j(),bi=ht();function Dw(e,t,{key:n,value:r}){if(Su.isNode(n)&&n.addToJSMap)n.addToJSMap(e,t,r);else if(xu.isMergeKey(e,n))xu.addMergeToJSMap(e,t,r);else{let s=bi.toJS(n,"",e);if(t instanceof Map)t.set(s,bi.toJS(r,s,e));else if(t instanceof Set)t.add(s);else{let o=Mw(n,s,e),i=bi.toJS(r,o,e);if(o in t)Object.defineProperty(t,o,{value:i,writable:!0,enumerable:!0,configurable:!0});else t[o]=i}}return t}function Mw(e,t,n){if(t===null)return"";if(typeof t!=="object")return String(t);if(Su.isNode(e)&&n?.doc){let r=Lw.createStringifyContext(n.doc,{});r.anchors=new Set;for(let o of n.anchors.keys())r.anchors.add(o.anchor);r.inFlow=!0,r.inStringifyKey=!0;let s=e.toString(r);if(!n.mapKeyWarned){let o=JSON.stringify(s);if(o.length>40)o=o.substring(0,36)+'..."';jw.warn(n.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${o}. Set mapAsMap: true to use object keys.`),n.mapKeyWarned=!0}return s}return JSON.stringify(t)}Uw.addPairToJSMap=Dw});var gt=T(function(Bw){var Au=Mn(),Hw=bu(),Zw=yi(),cs=j();function qw(e,t,n){let r=Au.createNode(e,void 0,n),s=Au.createNode(t,void 0,n);return new ls(r,s)}class ls{constructor(e,t=null){Object.defineProperty(this,cs.NODE_TYPE,{value:cs.PAIR}),this.key=e,this.value=t}clone(e){let{key:t,value:n}=this;if(cs.isNode(t))t=t.clone(e);if(cs.isNode(n))n=n.clone(e);return new ls(t,n)}toJSON(e,t){let n=t?.mapAsMap?new Map:{};return Zw.addPairToJSMap(t,n,this)}toString(e,t,n){return e?.doc?Hw.stringifyPair(this,e,t,n):JSON.stringify(this)}}Bw.Pair=ls;Bw.createPair=qw});var wi=T(function(Jw){var Dt=j(),$u=Zn(),us=Un();function Ww(e,t,n){return(t.inFlow??e.flow?Yw:Vw)(e,t,n)}function Vw({comment:e,items:t},n,{blockItemPrefix:r,flowChars:s,itemIndent:o,onChompKeep:i,onComment:a}){let{indent:c,options:{commentString:l}}=n,u=Object.assign({},n,{indent:o,type:null}),p=!1,d=[];for(let f=0;f<t.length;++f){let m=t[f],v=null;if(Dt.isNode(m)){if(!p&&m.spaceBefore)d.push("");if(ps(n,d,m.commentBefore,p),m.comment)v=m.comment}else if(Dt.isPair(m)){let A=Dt.isNode(m.key)?m.key:null;if(A){if(!p&&A.spaceBefore)d.push("");ps(n,d,A.commentBefore,p)}}p=!1;let _=$u.stringify(m,u,()=>v=null,()=>p=!0);if(v)_+=us.lineComment(_,o,l(v));if(p&&v)p=!1;d.push(r+_)}let h;if(d.length===0)h=s.start+s.end;else{h=d[0];for(let f=1;f<d.length;++f){let m=d[f];h+=m?`
47
47
  ${c}${m}`:`
48
48
  `}}if(e){if(h+=`
49
- `+ei.indentComment(l(e),c),a)a()}else if(p&&o)o();return h}function f0({items:e},t,{flowChars:n,itemIndent:r}){let{indent:i,indentStep:s,flowCollectionPadding:o,options:{commentString:a}}=t;r+=s;let c=Object.assign({},t,{indent:r,inFlow:!0,type:null}),l=!1,u=0,p=[];for(let f=0;f<e.length;++f){let m=e[f],g=null;if(Ct.isNode(m)){if(m.spaceBefore)p.push("");if(ti(t,p,m.commentBefore,!1),m.comment)g=m.comment}else if(Ct.isPair(m)){let k=Ct.isNode(m.key)?m.key:null;if(k){if(k.spaceBefore)p.push("");if(ti(t,p,k.commentBefore,!1),k.comment)l=!0}let _=Ct.isNode(m.value)?m.value:null;if(_){if(_.comment)g=_.comment;if(_.commentBefore)l=!0}else if(m.value==null&&k?.comment)g=k.comment}if(g)l=!0;let w=ru.stringify(m,c,()=>g=null);if(l||(l=p.length>u||w.includes(`
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
- ${s}${i}${m}`:`
49
+ `+us.indentComment(l(e),c),a)a()}else if(p&&i)i();return h}function Yw({items:e},t,{flowChars:n,itemIndent:r}){let{indent:s,indentStep:o,flowCollectionPadding:i,options:{commentString:a}}=t;r+=o;let c=Object.assign({},t,{indent:r,inFlow:!0,type:null}),l=!1,u=0,p=[];for(let f=0;f<e.length;++f){let m=e[f],v=null;if(Dt.isNode(m)){if(m.spaceBefore)p.push("");if(ps(t,p,m.commentBefore,!1),m.comment)v=m.comment}else if(Dt.isPair(m)){let A=Dt.isNode(m.key)?m.key:null;if(A){if(A.spaceBefore)p.push("");if(ps(t,p,A.commentBefore,!1),A.comment)l=!0}let y=Dt.isNode(m.value)?m.value:null;if(y){if(y.comment)v=y.comment;if(y.commentBefore)l=!0}else if(m.value==null&&A?.comment)v=A.comment}if(v)l=!0;let _=$u.stringify(m,c,()=>v=null);if(l||(l=p.length>u||_.includes(`
50
+ `)),f<e.length-1)_+=",";else if(t.options.trailingComma){if(t.options.lineWidth>0)l||(l=p.reduce((A,y)=>A+y.length+2,2)+(_.length+2)>t.options.lineWidth);if(l)_+=","}if(v)_+=us.lineComment(_,r,a(v));p.push(_),u=p.length}let{start:d,end:h}=n;if(p.length===0)return d+h;else{if(!l){let f=p.reduce((m,v)=>m+v.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
+ ${o}${s}${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?`
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
- ${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(`
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(`
53
+ ${s}${h}`}else return`${d}${i}${p.join(" ")}${i}${h}`}}function ps({indent:e,options:{commentString:t}},n,r,s){if(r&&s)r=r.replace(/^\n+/,"");if(r){let o=us.indentComment(t(r),e);n.push(o.trimStart())}}Jw.stringifyCollection=Ww});var bt=T(function(r_){var Xw=wi(),e_=yi(),t_=es(),vt=j(),ds=gt(),n_=J();function Bn(e,t){let n=vt.isScalar(t)?t.value:t;for(let r of e)if(vt.isPair(r)){if(r.key===t||r.key===n)return r;if(vt.isScalar(r.key)&&r.key.value===n)return r}return}class Tu extends t_.Collection{static get tagName(){return"tag:yaml.org,2002:map"}constructor(e){super(vt.MAP,e);this.items=[]}static from(e,t,n){let{keepUndefined:r,replacer:s}=n,o=new this(e),i=(a,c)=>{if(typeof s==="function")c=s.call(t,a,c);else if(Array.isArray(s)&&!s.includes(a))return;if(c!==void 0||r)o.items.push(ds.createPair(a,c,n))};if(t instanceof Map)for(let[a,c]of t)i(a,c);else if(t&&typeof t==="object")for(let a of Object.keys(t))i(a,t[a]);if(typeof e.sortMapEntries==="function")o.items.sort(e.sortMapEntries);return o}add(e,t){let n;if(vt.isPair(e))n=e;else if(!e||typeof e!=="object"||!("key"in e))n=new ds.Pair(e,e?.value);else n=new ds.Pair(e.key,e.value);let r=Bn(this.items,n.key),s=this.schema?.sortMapEntries;if(r){if(!t)throw Error(`Key ${n.key} already set`);if(vt.isScalar(r.value)&&n_.isScalarValue(n.value))r.value.value=n.value;else r.value=n.value}else if(s){let o=this.items.findIndex((i)=>s(n,i)<0);if(o===-1)this.items.push(n);else this.items.splice(o,0,n)}else this.items.push(n)}delete(e){let t=Bn(this.items,e);if(!t)return!1;return this.items.splice(this.items.indexOf(t),1).length>0}get(e,t){let r=Bn(this.items,e)?.value;return(!t&&vt.isScalar(r)?r.value:r)??void 0}has(e){return!!Bn(this.items,e)}set(e,t){this.add(new ds.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 s of this.items)e_.addPairToJSMap(t,r,s);return r}toString(e,t,n){if(!e)return JSON.stringify(this);for(let r of this.items)if(!vt.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 Xw.stringifyCollection(this,e,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:e.indent||"",onChompKeep:n,onComment:t})}}r_.YAMLMap=Tu;r_.findPair=Bn});var un=T(function(c_){var i_=j(),Pu=bt(),a_={collection:"map",default:!0,nodeClass:Pu.YAMLMap,tag:"tag:yaml.org,2002:map",resolve(e,t){if(!i_.isMap(e))t("Expected a mapping for this tag");return e},createNode:(e,t,n)=>Pu.YAMLMap.from(e,t,n)};c_.map=a_});var yt=T(function(m_){var u_=Mn(),p_=wi(),d_=es(),fs=j(),h_=J(),f_=ht();class Eu extends d_.Collection{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(e){super(fs.SEQ,e);this.items=[]}add(e){this.items.push(e)}delete(e){let t=hs(e);if(typeof t!=="number")return!1;return this.items.splice(t,1).length>0}get(e,t){let n=hs(e);if(typeof n!=="number")return;let r=this.items[n];return!t&&fs.isScalar(r)?r.value:r}has(e){let t=hs(e);return typeof t==="number"&&t<this.items.length}set(e,t){let n=hs(e);if(typeof n!=="number")throw Error(`Expected a valid index, not ${e}.`);let r=this.items[n];if(fs.isScalar(r)&&h_.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 s of this.items)n.push(f_.toJS(s,String(r++),t));return n}toString(e,t,n){if(!e)return JSON.stringify(this);return p_.stringifyCollection(this,e,{blockItemPrefix:"- ",flowChars:{start:"[",end:"]"},itemIndent:(e.indent||"")+" ",onChompKeep:n,onComment:t})}static from(e,t,n){let{replacer:r}=n,s=new this(e);if(t&&Symbol.iterator in Object(t)){let o=0;for(let i of t){if(typeof r==="function"){let a=t instanceof Set?i:String(o++);i=r.call(t,a,i)}s.items.push(u_.createNode(i,void 0,n))}}return s}}function hs(e){let t=fs.isScalar(e)?e.value:e;if(t&&typeof t==="string")t=Number(t);return typeof t==="number"&&Number.isInteger(t)&&t>=0?t:null}m_.YAMLSeq=Eu});var pn=T(function(y_){var v_=j(),Ou=yt(),b_={collection:"seq",default:!0,nodeClass:Ou.YAMLSeq,tag:"tag:yaml.org,2002:seq",resolve(e,t){if(!v_.isSeq(e))t("Expected a sequence for this tag");return e},createNode:(e,t,n)=>Ou.YAMLSeq.from(e,t,n)};y_.seq=b_});var Fn=T(function(x_){var __=Hn(),k_={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),__.stringifyString(e,t,n,r)}};x_.string=k_});var ms=T(function(A_){var Cu=J(),Ru={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"&&Ru.test.test(e)?e:t.options.nullStr};A_.nullTag=Ru});var _i=T(function(P_){var T_=J(),Iu={identify:(e)=>typeof e==="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:(e)=>new T_.Scalar(e[0]==="t"||e[0]==="T"),stringify({source:e,value:t},n){if(e&&Iu.test.test(e)){let r=e[0]==="t"||e[0]==="T";if(t===r)return e}return t?n.options.trueStr:n.options.falseStr}};P_.boolTag=Iu});var dn=T(function(C_){function O_({format:e,minFractionDigits:t,tag:n,value:r}){if(typeof r==="bigint")return String(r);let s=typeof r==="number"?r:Number(r);if(!isFinite(s))return isNaN(s)?".nan":s<0?"-.inf":".inf";let o=Object.is(r,-0)?"-0":JSON.stringify(r);if(!e&&t&&(!n||n==="tag:yaml.org,2002:float")&&/^-?\d/.test(o)&&!o.includes("e")){let i=o.indexOf(".");if(i<0)i=o.length,o+=".";let a=t-(o.length-i-1);while(a-- >0)o+="0"}return o}C_.stringifyNumber=O_});var xi=T(function(L_){var I_=J(),ki=dn(),N_={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:ki.stringifyNumber},z_={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():ki.stringifyNumber(e)}},j_={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 I_.Scalar(parseFloat(e)),n=e.indexOf(".");if(n!==-1&&e[e.length-1]==="0")t.minFractionDigits=e.length-n-1;return t},stringify:ki.stringifyNumber};L_.float=j_;L_.floatExp=z_;L_.floatNaN=N_});var Ai=T(function(q_){var Nu=dn(),gs=(e)=>typeof e==="bigint"||Number.isInteger(e),Si=(e,t,n,{intAsBigInt:r})=>r?BigInt(e):parseInt(e.substring(t),n);function zu(e,t,n){let{value:r}=e;if(gs(r)&&r>=0)return n+r.toString(t);return Nu.stringifyNumber(e)}var G_={identify:(e)=>gs(e)&&e>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(e,t,n)=>Si(e,2,8,n),stringify:(e)=>zu(e,8,"0o")},H_={identify:gs,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(e,t,n)=>Si(e,0,10,n),stringify:Nu.stringifyNumber},Z_={identify:(e)=>gs(e)&&e>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(e,t,n)=>Si(e,2,16,n),stringify:(e)=>zu(e,16,"0x")};q_.int=H_;q_.intHex=Z_;q_.intOct=G_});var ju=T(function(ek){var W_=un(),V_=ms(),Y_=pn(),J_=Fn(),Q_=_i(),$i=xi(),Ti=Ai(),X_=[W_.map,Y_.seq,J_.string,V_.nullTag,Q_.boolTag,Ti.intOct,Ti.int,Ti.intHex,$i.floatNaN,$i.floatExp,$i.float];ek.schema=X_});var Du=T(function(ck){var nk=J(),rk=un(),sk=pn();function Lu(e){return typeof e==="bigint"||Number.isInteger(e)}var vs=({value:e})=>JSON.stringify(e),ok=[{identify:(e)=>typeof e==="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:(e)=>e,stringify:vs},{identify:(e)=>e==null,createNode:()=>new nk.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:vs},{identify:(e)=>typeof e==="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:(e)=>e==="true",stringify:vs},{identify:Lu,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})=>Lu(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:vs}],ik={default:!0,tag:"",test:/^/,resolve(e,t){return t(`Unresolved plain scalar ${JSON.stringify(e)}`),e}},ak=[rk.map,sk.seq].concat(ok,ik);ck.schema=ak});var Ei=T(function(dk){var Kn=ze("buffer"),Pi=J(),uk=Hn(),pk={identify:(e)=>e instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(e,t){if(typeof Kn.Buffer==="function")return Kn.Buffer.from(e,"base64");else if(typeof atob==="function"){let n=atob(e.replace(/[\n\r]/g,"")),r=new Uint8Array(n.length);for(let s=0;s<n.length;++s)r[s]=n.charCodeAt(s);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,s,o){if(!n)return"";let i=n,a;if(typeof Kn.Buffer==="function")a=i instanceof Kn.Buffer?i.toString("base64"):Kn.Buffer.from(i.buffer).toString("base64");else if(typeof btoa==="function"){let c="";for(let l=0;l<i.length;++l)c+=String.fromCharCode(i[l]);a=btoa(c)}else throw Error("This environment does not support writing binary tags; either Buffer or btoa is required");if(t??(t=Pi.Scalar.BLOCK_LITERAL),t!==Pi.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===Pi.Scalar.BLOCK_LITERAL?`
54
+ `:" ")}return uk.stringifyString({comment:e,type:t,value:a},r,s,o)}};dk.binary=pk});var ys=T(function(vk){var bs=j(),Oi=gt(),fk=J(),mk=yt();function Mu(e,t){if(bs.isSeq(e))for(let n=0;n<e.items.length;++n){let r=e.items[n];if(bs.isPair(r))continue;else if(bs.isMap(r)){if(r.items.length>1)t("Each pair must have its own sequence indicator");let s=r.items[0]||new Oi.Pair(new fk.Scalar(null));if(r.commentBefore)s.key.commentBefore=s.key.commentBefore?`${r.commentBefore}
55
+ ${s.key.commentBefore}`:r.commentBefore;if(r.comment){let o=s.value??s.key;o.comment=o.comment?`${r.comment}
56
+ ${o.comment}`:r.comment}r=s}e.items[n]=bs.isPair(r)?r:new Oi.Pair(r)}else t("Expected a sequence for this tag");return e}function Uu(e,t,n){let{replacer:r}=n,s=new mk.YAMLSeq(e);s.tag="tag:yaml.org,2002:pairs";let o=0;if(t&&Symbol.iterator in Object(t))for(let i of t){if(typeof r==="function")i=r.call(t,String(o++),i);let a,c;if(Array.isArray(i))if(i.length===2)a=i[0],c=i[1];else throw TypeError(`Expected [key, value] tuple: ${i}`);else if(i&&i instanceof Object){let l=Object.keys(i);if(l.length===1)a=l[0],c=i[a];else throw TypeError(`Expected tuple with one key, not ${l.length} keys`)}else a=i;s.items.push(Oi.createPair(a,c,n))}return s}var gk={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:Mu,createNode:Uu};vk.createPairs=Uu;vk.pairs=gk;vk.resolvePairs=Mu});var Ri=T(function(xk){var Gu=j(),Ci=ht(),Wn=bt(),_k=yt(),Hu=ys();class Mt extends _k.YAMLSeq{constructor(){super();this.add=Wn.YAMLMap.prototype.add.bind(this),this.delete=Wn.YAMLMap.prototype.delete.bind(this),this.get=Wn.YAMLMap.prototype.get.bind(this),this.has=Wn.YAMLMap.prototype.has.bind(this),this.set=Wn.YAMLMap.prototype.set.bind(this),this.tag=Mt.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 s,o;if(Gu.isPair(r))s=Ci.toJS(r.key,"",t),o=Ci.toJS(r.value,s,t);else s=Ci.toJS(r,"",t);if(n.has(s))throw Error("Ordered maps must not include duplicate keys");n.set(s,o)}return n}static from(e,t,n){let r=Hu.createPairs(e,t,n),s=new this;return s.items=r.items,s}}Mt.tag="tag:yaml.org,2002:omap";var kk={collection:"seq",identify:(e)=>e instanceof Map,nodeClass:Mt,default:!1,tag:"tag:yaml.org,2002:omap",resolve(e,t){let n=Hu.resolvePairs(e,t),r=[];for(let{key:s}of n.items)if(Gu.isScalar(s))if(r.includes(s.value))t(`Ordered maps must not include duplicate keys: ${s.value}`);else r.push(s.value);return Object.assign(new Mt,n)},createNode:(e,t,n)=>Mt.from(e,t,n)};xk.YAMLOMap=Mt;xk.omap=kk});var Ku=T(function($k){var Zu=J();function qu({value:e,source:t},n){if(t&&(e?Bu:Fu).test.test(t))return t;return e?n.options.trueStr:n.options.falseStr}var Bu={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 Zu.Scalar(!0),stringify:qu},Fu={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 Zu.Scalar(!1),stringify:qu};$k.falseTag=Fu;$k.trueTag=Bu});var Wu=T(function(Ik){var Ek=J(),Ii=dn(),Ok={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:Ii.stringifyNumber},Ck={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():Ii.stringifyNumber(e)}},Rk={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 Ek.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:Ii.stringifyNumber};Ik.float=Rk;Ik.floatExp=Ck;Ik.floatNaN=Ok});var Yu=T(function(Gk){var Vu=dn(),Vn=(e)=>typeof e==="bigint"||Number.isInteger(e);function ws(e,t,n,{intAsBigInt:r}){let s=e[0];if(s==="-"||s==="+")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 i=BigInt(e);return s==="-"?BigInt(-1)*i:i}let o=parseInt(e,n);return s==="-"?-1*o:o}function Ni(e,t,n){let{value:r}=e;if(Vn(r)){let s=r.toString(t);return r<0?"-"+n+s.substr(1):n+s}return Vu.stringifyNumber(e)}var Lk={identify:Vn,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(e,t,n)=>ws(e,2,2,n),stringify:(e)=>Ni(e,2,"0b")},Dk={identify:Vn,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(e,t,n)=>ws(e,1,8,n),stringify:(e)=>Ni(e,8,"0")},Mk={identify:Vn,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(e,t,n)=>ws(e,0,10,n),stringify:Vu.stringifyNumber},Uk={identify:Vn,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(e,t,n)=>ws(e,2,16,n),stringify:(e)=>Ni(e,16,"0x")};Gk.int=Mk;Gk.intBin=Lk;Gk.intHex=Uk;Gk.intOct=Dk});var zi=T(function(Kk){var xs=j(),_s=gt(),ks=bt();class Ut extends ks.YAMLMap{constructor(e){super(e);this.tag=Ut.tag}add(e){let t;if(xs.isPair(e))t=e;else if(e&&typeof e==="object"&&"key"in e&&"value"in e&&e.value===null)t=new _s.Pair(e.key,null);else t=new _s.Pair(e,null);if(!ks.findPair(this.items,t.key))this.items.push(t)}get(e,t){let n=ks.findPair(this.items,e);return!t&&xs.isPair(n)?xs.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=ks.findPair(this.items,e);if(n&&!t)this.items.splice(this.items.indexOf(n),1);else if(!n&&t)this.items.push(new _s.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,s=new this(e);if(t&&Symbol.iterator in Object(t))for(let o of t){if(typeof r==="function")o=r.call(t,o,o);s.items.push(_s.createPair(o,null,n))}return s}}Ut.tag="tag:yaml.org,2002:set";var Fk={collection:"map",identify:(e)=>e instanceof Set,nodeClass:Ut,default:!1,tag:"tag:yaml.org,2002:set",createNode:(e,t,n)=>Ut.from(e,t,n),resolve(e,t){if(xs.isMap(e))if(e.hasAllNullValues(!0))return Object.assign(new Ut,e);else t("Set items must all have null values");else t("Expected a mapping for this tag");return e}};Kk.YAMLSet=Ut;Kk.set=Fk});var Li=T(function(Xk){var Yk=dn();function ji(e,t){let n=e[0],r=n==="-"||n==="+"?e.substring(1):e,s=(i)=>t?BigInt(i):Number(i),o=r.replace(/_/g,"").split(":").reduce((i,a)=>i*s(60)+s(a),s(0));return n==="-"?s(-1)*o:o}function Ju(e){let{value:t}=e,n=(i)=>i;if(typeof t==="bigint")n=(i)=>BigInt(i);else if(isNaN(t)||!isFinite(t))return Yk.stringifyNumber(e);let r="";if(t<0)r="-",t*=n(-1);let s=n(60),o=[t%s];if(t<60)o.unshift(0);else if(t=(t-o[0])/s,o.unshift(t%s),t>=60)t=(t-o[0])/s,o.unshift(t);return r+o.map((i)=>String(i).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}var Jk={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})=>ji(e,n),stringify:Ju},Qk={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)=>ji(e,!1),stringify:Ju},Qu={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(Qu.test);if(!t)throw Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,n,r,s,o,i,a]=t.map(Number),c=t[7]?Number((t[7]+"00").substr(1,3)):0,l=Date.UTC(n,r-1,s,o||0,i||0,a||0,c),u=t[8];if(u&&u!=="Z"){let p=ji(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$/,"")??""};Xk.floatTime=Qk;Xk.intTime=Jk;Xk.timestamp=Qu});var ep=T(function(hx){var rx=un(),sx=ms(),ox=pn(),ix=Fn(),ax=Ei(),Xu=Ku(),Di=Wu(),Ss=Yu(),cx=as(),lx=Ri(),ux=ys(),px=zi(),Mi=Li(),dx=[rx.map,ox.seq,ix.string,sx.nullTag,Xu.trueTag,Xu.falseTag,Ss.intBin,Ss.intOct,Ss.int,Ss.intHex,Di.floatNaN,Di.floatExp,Di.float,ax.binary,cx.merge,lx.omap,ux.pairs,px.set,Mi.intTime,Mi.floatTime,Mi.timestamp];hx.schema=dx});var up=T(function(kx){var sp=un(),mx=ms(),op=pn(),gx=Fn(),vx=_i(),Ui=xi(),Gi=Ai(),bx=ju(),yx=Du(),ip=Ei(),Yn=as(),ap=Ri(),cp=ys(),tp=ep(),lp=zi(),As=Li(),np=new Map([["core",bx.schema],["failsafe",[sp.map,op.seq,gx.string]],["json",yx.schema],["yaml11",tp.schema],["yaml-1.1",tp.schema]]),rp={binary:ip.binary,bool:vx.boolTag,float:Ui.float,floatExp:Ui.floatExp,floatNaN:Ui.floatNaN,floatTime:As.floatTime,int:Gi.int,intHex:Gi.intHex,intOct:Gi.intOct,intTime:As.intTime,map:sp.map,merge:Yn.merge,null:mx.nullTag,omap:ap.omap,pairs:cp.pairs,seq:op.seq,set:lp.set,timestamp:As.timestamp},wx={"tag:yaml.org,2002:binary":ip.binary,"tag:yaml.org,2002:merge":Yn.merge,"tag:yaml.org,2002:omap":ap.omap,"tag:yaml.org,2002:pairs":cp.pairs,"tag:yaml.org,2002:set":lp.set,"tag:yaml.org,2002:timestamp":As.timestamp};function _x(e,t,n){let r=np.get(t);if(r&&!e)return n&&!r.includes(Yn.merge)?r.concat(Yn.merge):r.slice();let s=r;if(!s)if(Array.isArray(e))s=[];else{let o=Array.from(np.keys()).filter((i)=>i!=="yaml11").map((i)=>JSON.stringify(i)).join(", ");throw Error(`Unknown schema "${t}"; use one of ${o} or define customTags array`)}if(Array.isArray(e))for(let o of e)s=s.concat(o);else if(typeof e==="function")s=e(s.slice());if(n)s=s.concat(Yn.merge);return s.reduce((o,i)=>{let a=typeof i==="string"?rp[i]:i;if(!a){let c=JSON.stringify(i),l=Object.keys(rp).map((u)=>JSON.stringify(u)).join(", ");throw Error(`Unknown custom tag ${c}; use one of ${l}`)}if(!o.includes(a))o.push(a);return o},[])}kx.coreKnownTags=wx;kx.getTags=_x});var qi=T(function(Ex){var Hi=j(),Ax=un(),$x=pn(),Tx=Fn(),$s=up(),Px=(e,t)=>e.key<t.key?-1:e.key>t.key?1:0;class Zi{constructor({compat:e,customTags:t,merge:n,resolveKnownTags:r,schema:s,sortMapEntries:o,toStringDefaults:i}){this.compat=Array.isArray(e)?$s.getTags(e,"compat"):e?$s.getTags(null,e):null,this.name=typeof s==="string"&&s||"core",this.knownTags=r?$s.coreKnownTags:{},this.tags=$s.getTags(t,this.name,n),this.toStringOptions=i??null,Object.defineProperty(this,Hi.MAP,{value:Ax.map}),Object.defineProperty(this,Hi.SCALAR,{value:Tx.string}),Object.defineProperty(this,Hi.SEQ,{value:$x.seq}),this.sortMapEntries=typeof o==="function"?o:o===!0?Px:null}clone(){let e=Object.create(Zi.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}}Ex.Schema=Zi});var pp=T(function(Ix){var Cx=j(),Bi=Zn(),Jn=Un();function Rx(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 s=Bi.createStringifyContext(e,t),{commentString:o}=s.options;if(e.commentBefore){if(n.length!==1)n.unshift("");let c=o(e.commentBefore);n.unshift(Jn.indentComment(c,""))}let i=!1,a=null;if(e.contents){if(Cx.isNode(e.contents)){if(e.contents.spaceBefore&&r)n.push("");if(e.contents.commentBefore){let u=o(e.contents.commentBefore);n.push(Jn.indentComment(u,""))}s.forceBlockIndent=!!e.comment,a=e.contents.comment}let c=a?void 0:()=>i=!0,l=Bi.stringify(e.contents,s,()=>a=null,c);if(a)l+=Jn.lineComment(l,"",o(a));if((l[0]==="|"||l[0]===">")&&n[n.length-1]==="---")n[n.length-1]=`--- ${l}`;else n.push(l)}else n.push(Bi.stringify(e.contents,s));if(e.directives?.docEnd)if(e.comment){let c=o(e.comment);if(c.includes(`
57
+ `))n.push("..."),n.push(Jn.indentComment(c,""));else n.push(`... ${c}`)}else n.push("...");else{let c=e.comment;if(c&&i)c=c.replace(/^\n+/,"");if(c){if((!i||a)&&n[n.length-1]!=="")n.push("");n.push(Jn.indentComment(o(c),""))}}return n.join(`
58
58
  `)+`
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
60
- `;o=a+o}if(/[^ ]/.test(o)){let a=1,c=n.linePos[1];if(c?.line===r&&c.col>i)a=Math.max(1,Math.min(c.col-i,80-s));let l=" ".repeat(s)+"^".repeat(a);n.message+=`:
59
+ `}Ix.stringifyDocument=Rx});var Qn=T(function(Hx){var zx=Dn(),hn=es(),Te=j(),jx=gt(),Lx=ht(),Dx=qi(),Mx=pp(),Fi=Jr(),Ux=pi(),Gx=Mn(),Ki=ui();class Wi{constructor(e,t,n){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,Te.NODE_TYPE,{value:Te.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 s=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:"warn",prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:"1.2"},n);this.options=s;let{version:o}=s;if(n?._directives){if(this.directives=n._directives.atDocument(),this.directives.yaml.explicit)o=this.directives.yaml.version}else this.directives=new Ki.Directives({version:o});this.setSchema(o,n),this.contents=e===void 0?null:this.createNode(e,r,n)}clone(){let e=Object.create(Wi.prototype,{[Te.NODE_TYPE]:{value:Te.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=Te.isNode(this.contents)?this.contents.clone(e.schema):this.contents,this.range)e.range=this.range.slice();return e}add(e){if(fn(this.contents))this.contents.add(e)}addIn(e,t){if(fn(this.contents))this.contents.addIn(e,t)}createAlias(e,t){if(!e.anchor){let n=Fi.anchorNames(this);e.anchor=!t||n.has(t)?Fi.findNewAnchor(t||"a",n):t}return new zx.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=(_)=>typeof _==="number"||_ instanceof String||_ instanceof Number,v=t.filter(m).map(String);if(v.length>0)t=t.concat(v);r=t}else if(n===void 0&&t)n=t,t=void 0;let{aliasDuplicateObjects:s,anchorPrefix:o,flow:i,keepUndefined:a,onTagObj:c,tag:l}=n??{},{onAnchor:u,setAnchors:p,sourceObjects:d}=Fi.createNodeAnchors(this,o||"a"),h={aliasDuplicateObjects:s??!0,keepUndefined:a??!1,onAnchor:u,onTagObj:c,replacer:r,schema:this.schema,sourceObjects:d},f=Gx.createNode(e,l,h);if(i&&Te.isCollection(f))f.flow=!0;return p(),f}createPair(e,t,n={}){let r=this.createNode(e,null,n),s=this.createNode(t,null,n);return new jx.Pair(r,s)}delete(e){return fn(this.contents)?this.contents.delete(e):!1}deleteIn(e){if(hn.isEmptyPath(e)){if(this.contents==null)return!1;return this.contents=null,!0}return fn(this.contents)?this.contents.deleteIn(e):!1}get(e,t){return Te.isCollection(this.contents)?this.contents.get(e,t):void 0}getIn(e,t){if(hn.isEmptyPath(e))return!t&&Te.isScalar(this.contents)?this.contents.value:this.contents;return Te.isCollection(this.contents)?this.contents.getIn(e,t):void 0}has(e){return Te.isCollection(this.contents)?this.contents.has(e):!1}hasIn(e){if(hn.isEmptyPath(e))return this.contents!==void 0;return Te.isCollection(this.contents)?this.contents.hasIn(e):!1}set(e,t){if(this.contents==null)this.contents=hn.collectionFromPath(this.schema,[e],t);else if(fn(this.contents))this.contents.set(e,t)}setIn(e,t){if(hn.isEmptyPath(e))this.contents=t;else if(this.contents==null)this.contents=hn.collectionFromPath(this.schema,Array.from(e),t);else if(fn(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 Ki.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 Ki.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 Dx.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:s,reviver:o}={}){let i={anchors:new Map,doc:this,keep:!e,mapAsMap:n===!0,mapKeyWarned:!1,maxAliasCount:typeof r==="number"?r:100},a=Lx.toJS(this.contents,t??"",i);if(typeof s==="function")for(let{count:c,res:l}of i.anchors.values())s(l,c);return typeof o==="function"?Ux.applyReviver(o,{"":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 Mx.stringifyDocument(this,e)}}function fn(e){if(Te.isCollection(e))return!0;throw Error("Expected a YAML collection as document contents")}Hx.Document=Wi});var Xn=T(function(Bx){class Ts extends Error{constructor(e,t,n,r){super();this.name=e,this.code=n,this.message=r,this.pos=t}}class dp extends Ts{constructor(e,t,n){super("YAMLParseError",e,t,n)}}class hp extends Ts{constructor(e,t,n){super("YAMLWarning",e,t,n)}}var qx=(e,t)=>(n)=>{if(n.pos[0]===-1)return;n.linePos=n.pos.map((a)=>t.linePos(a));let{line:r,col:s}=n.linePos[0];n.message+=` at line ${r}, column ${s}`;let o=s-1,i=e.substring(t.lineStarts[r-1],t.lineStarts[r]).replace(/[\n\r]+$/,"");if(o>=60&&i.length>80){let a=Math.min(o-39,i.length-79);i="\u2026"+i.substring(a),o-=a-1}if(i.length>80)i=i.substring(0,79)+"\u2026";if(r>1&&/^ *$/.test(i.substring(0,o))){let a=e.substring(t.lineStarts[r-2],t.lineStarts[r-1]);if(a.length>80)a=a.substring(0,79)+`\u2026
60
+ `;i=a+i}if(/[^ ]/.test(i)){let a=1,c=n.linePos[1];if(c?.line===r&&c.col>s)a=Math.max(1,Math.min(c.col-s,80-o));let l=" ".repeat(o)+"^".repeat(a);n.message+=`:
61
61
 
62
- ${o}
62
+ ${i}
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+=`
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+=`
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+=`
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
- `.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
- `;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=`
74
- `;else if(g.length>c||w[0]==="\t"){if(d===" ")d=`
64
+ `}};Bx.YAMLError=Ts;Bx.YAMLParseError=dp;Bx.YAMLWarning=hp;Bx.prettifyError=qx});var er=T(function(Jx){function Yx(e,{flow:t,indicator:n,next:r,offset:s,onError:o,parentIndent:i,startOnNewline:a}){let c=!1,l=a,u=a,p="",d="",h=!1,f=!1,m=null,v=null,_=null,A=null,y=null,b=null,k=null;for(let x of e){if(f){if(x.type!=="space"&&x.type!=="newline"&&x.type!=="comma")o(x.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space");f=!1}if(m){if(l&&x.type!=="comment"&&x.type!=="newline")o(m,"TAB_AS_INDENT","Tabs are not allowed as indentation");m=null}switch(x.type){case"space":if(!t&&(n!=="doc-start"||r?.type!=="flow-collection")&&x.source.includes("\t"))m=x;u=!0;break;case"comment":{if(!u)o(x,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let N=x.source.substring(1)||" ";if(!p)p=N;else p+=d+N;d="",l=!1;break}case"newline":if(l){if(p)p+=x.source;else if(!b||n!=="seq-item-ind")c=!0}else d+=x.source;if(l=!0,h=!0,v||_)A=x;u=!0;break;case"anchor":if(v)o(x,"MULTIPLE_ANCHORS","A node can have at most one anchor");if(x.source.endsWith(":"))o(x.offset+x.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0);v=x,k??(k=x.offset),l=!1,u=!1,f=!0;break;case"tag":{if(_)o(x,"MULTIPLE_TAGS","A node can have at most one tag");_=x,k??(k=x.offset),l=!1,u=!1,f=!0;break}case n:if(v||_)o(x,"BAD_PROP_ORDER",`Anchors and tags must be after the ${x.source} indicator`);if(b)o(x,"UNEXPECTED_TOKEN",`Unexpected ${x.source} in ${t??"collection"}`);b=x,l=n==="seq-item-ind"||n==="explicit-key-ind",u=!1;break;case"comma":if(t){if(y)o(x,"UNEXPECTED_TOKEN",`Unexpected , in ${t}`);y=x,l=!1,u=!1;break}default:o(x,"UNEXPECTED_TOKEN",`Unexpected ${x.type} token`),l=!1,u=!1}}let S=e[e.length-1],O=S?S.offset+S.source.length:s;if(f&&r&&r.type!=="space"&&r.type!=="newline"&&r.type!=="comma"&&(r.type!=="scalar"||r.source!==""))o(r.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space");if(m&&(l&&m.indent<=i||r?.type==="block-map"||r?.type==="block-seq"))o(m,"TAB_AS_INDENT","Tabs are not allowed as indentation");return{comma:y,found:b,spaceBefore:c,comment:p,hasNewline:h,anchor:v,tag:_,newlineAfterProp:A,end:O,start:k??O}}Jx.resolveProps=Yx});var Ps=T(function(Xx){function Vi(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(Vi(t.key)||Vi(t.value))return!0}return!1;default:return!0}}Xx.containsNewline=Vi});var Yi=T(function(r1){var t1=Ps();function n1(e,t,n){if(t?.type==="flow-collection"){let r=t.end[0];if(r.indent===e&&(r.source==="]"||r.source==="}")&&t1.containsNewline(t))n(r,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}r1.flowIndentCheck=n1});var Ji=T(function(i1){var fp=j();function o1(e,t,n){let{uniqueKeys:r}=e.options;if(r===!1)return!1;let s=typeof r==="function"?r:(o,i)=>o===i||fp.isScalar(o)&&fp.isScalar(i)&&o.value===i.value;return t.some((o)=>s(o.key,n))}i1.mapIncludes=o1});var yp=T(function(d1){var mp=gt(),c1=bt(),gp=er(),l1=Ps(),vp=Yi(),u1=Ji(),bp="All mapping items must start at the same column";function p1({composeNode:e,composeEmptyNode:t},n,r,s,o){let a=new(o?.nodeClass??c1.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=gp.resolveProps(p,{indicator:"explicit-key-ind",next:d??h?.[0],offset:c,onError:s,parentIndent:r.indent,startOnNewline:!0}),v=!m.found;if(v){if(d){if(d.type==="block-seq")s(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)s(c,"BAD_INDENT",bp)}if(!m.anchor&&!m.tag&&!h){if(l=m.end,m.comment)if(a.comment)a.comment+=`
66
+ `+m.comment;else a.comment=m.comment;continue}if(m.newlineAfterProp||l1.containsNewline(d))s(d??p[p.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else if(m.found?.indent!==r.indent)s(c,"BAD_INDENT",bp);n.atKey=!0;let _=m.end,A=d?e(n,d,m,s):t(n,_,p,null,m,s);if(n.schema.compat)vp.flowIndentCheck(r.indent,d,s);if(n.atKey=!1,u1.mapIncludes(n,a.items,A))s(_,"DUPLICATE_KEY","Map keys must be unique");let y=gp.resolveProps(h??[],{indicator:"map-value-ind",next:f,offset:A.range[2],onError:s,parentIndent:r.indent,startOnNewline:!d||d.type==="block-scalar"});if(c=y.end,y.found){if(v){if(f?.type==="block-map"&&!y.hasNewline)s(c,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings");if(n.options.strict&&m.start<y.found.offset-1024)s(A.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key")}let b=f?e(n,f,y,s):t(n,c,h,null,y,s);if(n.schema.compat)vp.flowIndentCheck(r.indent,f,s);c=b.range[2];let k=new mp.Pair(A,b);if(n.options.keepSourceTokens)k.srcToken=u;a.items.push(k)}else{if(v)s(A.range,"MISSING_CHAR","Implicit map keys need to be followed by map values");if(y.comment)if(A.comment)A.comment+=`
67
+ `+y.comment;else A.comment=y.comment;let b=new mp.Pair(A);if(n.options.keepSourceTokens)b.srcToken=u;a.items.push(b)}}if(l&&l<c)s(l,"IMPOSSIBLE","Map comment with trailing content");return a.range=[r.offset,c,l??c],a}d1.resolveBlockMap=p1});var wp=T(function(b1){var f1=yt(),m1=er(),g1=Yi();function v1({composeNode:e,composeEmptyNode:t},n,r,s,o){let a=new(o?.nodeClass??f1.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=m1.resolveProps(u,{indicator:"seq-item-ind",next:p,offset:c,onError:s,parentIndent:r.indent,startOnNewline:!0});if(!d.found)if(d.anchor||d.tag||p)if(p?.type==="block-seq")s(d.end,"BAD_INDENT","All sequence items must start at the same column");else s(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,s):t(n,d.end,u,null,d,s);if(n.schema.compat)g1.flowIndentCheck(r.indent,p,s);c=h.range[2],a.items.push(h)}return a.range=[r.offset,c,l??c],a}b1.resolveBlockSeq=v1});var mn=T(function(_1){function w1(e,t,n,r){let s="";if(e){let o=!1,i="";for(let a of e){let{source:c,type:l}=a;switch(l){case"space":o=!0;break;case"comment":{if(n&&!o)r(a,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let u=c.substring(1)||" ";if(!s)s=u;else s+=i+u;i="";break}case"newline":if(s)i+=c;o=!0;break;default:r(a,"UNEXPECTED_TOKEN",`Unexpected ${l} at node end`)}t+=c.length}}return{comment:s,offset:t}}_1.resolveEnd=w1});var xp=T(function(O1){var x1=j(),S1=gt(),_p=bt(),A1=yt(),$1=mn(),kp=er(),T1=Ps(),P1=Ji(),Qi="Block collections are not allowed within flow collections",Xi=(e)=>e&&(e.type==="block-map"||e.type==="block-seq");function E1({composeNode:e,composeEmptyNode:t},n,r,s,o){let i=r.start.source==="{",a=i?"flow map":"flow sequence",l=new(o?.nodeClass??(i?_p.YAMLMap:A1.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 v=0;v<r.items.length;++v){let _=r.items[v],{start:A,key:y,sep:b,value:k}=_,S=kp.resolveProps(A,{flow:a,indicator:"explicit-key-ind",next:y??b?.[0],offset:p,onError:s,parentIndent:r.indent,startOnNewline:!1});if(!S.found){if(!S.anchor&&!S.tag&&!b&&!k){if(v===0&&S.comma)s(S.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`);else if(v<r.items.length-1)s(S.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${a}`);if(S.comment)if(l.comment)l.comment+=`
68
+ `+S.comment;else l.comment=S.comment;p=S.end;continue}if(!i&&n.options.strict&&T1.containsNewline(y))s(y,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(v===0){if(S.comma)s(S.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`)}else{if(!S.comma)s(S.start,"MISSING_CHAR",`Missing , between ${a} items`);if(S.comment){let O="";e:for(let x of A)switch(x.type){case"comma":case"space":break;case"comment":O=x.source.substring(1);break e;default:break e}if(O){let x=l.items[l.items.length-1];if(x1.isPair(x))x=x.value??x.key;if(x.comment)x.comment+=`
69
+ `+O;else x.comment=O;S.comment=S.comment.substring(O.length+1)}}}if(!i&&!b&&!S.found){let O=k?e(n,k,S,s):t(n,S.end,b,null,S,s);if(l.items.push(O),p=O.range[2],Xi(k))s(O.range,"BLOCK_IN_FLOW",Qi)}else{n.atKey=!0;let O=S.end,x=y?e(n,y,S,s):t(n,O,A,null,S,s);if(Xi(y))s(x.range,"BLOCK_IN_FLOW",Qi);n.atKey=!1;let N=kp.resolveProps(b??[],{flow:a,indicator:"map-value-ind",next:k,offset:x.range[2],onError:s,parentIndent:r.indent,startOnNewline:!1});if(N.found){if(!i&&!S.found&&n.options.strict){if(b)for(let q of b){if(q===N.found)break;if(q.type==="newline"){s(q,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line");break}}if(S.start<N.found.offset-1024)s(N.found,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit flow sequence key")}}else if(k)if("source"in k&&k.source?.[0]===":")s(k,"MISSING_CHAR",`Missing space after : in ${a}`);else s(N.start,"MISSING_CHAR",`Missing , or : between ${a} items`);let pe=k?e(n,k,N,s):N.found?t(n,N.end,b,null,N,s):null;if(pe){if(Xi(k))s(pe.range,"BLOCK_IN_FLOW",Qi)}else if(N.comment)if(x.comment)x.comment+=`
70
+ `+N.comment;else x.comment=N.comment;let Ae=new S1.Pair(x,pe);if(n.options.keepSourceTokens)Ae.srcToken=_;if(i){let q=l;if(P1.mapIncludes(n,q.items,x))s(O,"DUPLICATE_KEY","Map keys must be unique");q.items.push(Ae)}else{let q=new _p.YAMLMap(n.schema);q.flow=!0,q.items.push(Ae);let zt=(pe??x).range;q.range=[x.range[0],zt[1],zt[2]],l.items.push(q)}p=pe?pe.range[2]:N.end}}let d=i?"}":"]",[h,...f]=r.end,m=p;if(h?.source===d)m=h.offset+h.source.length;else{let v=a[0].toUpperCase()+a.substring(1),_=u?`${v} must end with a ${d}`:`${v} in block collection must be sufficiently indented and end with a ${d}`;if(s(p,u?"MISSING_CHAR":"BAD_INDENT",_),h&&h.source.length!==1)f.unshift(h)}if(f.length>0){let v=$1.resolveEnd(f,m,n.options.strict,s);if(v.comment)if(l.comment)l.comment+=`
71
+ `+v.comment;else l.comment=v.comment;l.range=[r.offset,m,v.offset]}else l.range=[r.offset,m,m];return l}O1.resolveFlowCollection=E1});var Sp=T(function(U1){var R1=j(),I1=J(),N1=bt(),z1=yt(),j1=yp(),L1=wp(),D1=xp();function ea(e,t,n,r,s,o){let i=n.type==="block-map"?j1.resolveBlockMap(e,t,n,r,o):n.type==="block-seq"?L1.resolveBlockSeq(e,t,n,r,o):D1.resolveFlowCollection(e,t,n,r,o),a=i.constructor;if(s==="!"||s===a.tagName)return i.tag=a.tagName,i;if(s)i.tag=s;return i}function M1(e,t,n,r,s){let o=r.tag,i=!o?null:t.directives.tagName(o.source,(d)=>s(o,"TAG_RESOLVE_FAILED",d));if(n.type==="block-seq"){let{anchor:d,newlineAfterProp:h}=r,f=d&&o?d.offset>o.offset?d:o:d??o;if(f&&(!h||h.offset<f.offset))s(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(!o||!i||i==="!"||i===N1.YAMLMap.tagName&&a==="map"||i===z1.YAMLSeq.tagName&&a==="seq")return ea(e,t,n,s,i);let c=t.schema.tags.find((d)=>d.tag===i&&d.collection===a);if(!c){let d=t.schema.knownTags[i];if(d?.collection===a)t.schema.tags.push(Object.assign({},d,{default:!1})),c=d;else{if(d)s(o,"BAD_COLLECTION_TYPE",`${d.tag} used for ${a} collection, but expects ${d.collection??"scalar"}`,!0);else s(o,"TAG_RESOLVE_FAILED",`Unresolved tag: ${i}`,!0);return ea(e,t,n,s,i)}}let l=ea(e,t,n,s,i,c),u=c.resolve?.(l,(d)=>s(o,"TAG_RESOLVE_FAILED",d),t.options)??l,p=R1.isNode(u)?u:new I1.Scalar(u);if(p.range=l.range,p.tag=i,c?.format)p.format=c.format;return p}U1.composeCollection=M1});var na=T(function(B1){var ta=J();function H1(e,t,n){let r=t.offset,s=Z1(t,e.options.strict,n);if(!s)return{value:"",type:null,comment:"",range:[r,r,r]};let o=s.mode===">"?ta.Scalar.BLOCK_FOLDED:ta.Scalar.BLOCK_LITERAL,i=t.source?q1(t.source):[],a=i.length;for(let m=i.length-1;m>=0;--m){let v=i[m][1];if(v===""||v==="\r")a=m;else break}if(a===0){let m=s.chomp==="+"&&i.length>0?`
72
+ `.repeat(Math.max(1,i.length-1)):"",v=r+s.length;if(t.source)v+=t.source.length;return{value:m,type:o,comment:s.comment,range:[r,v,v]}}let c=t.indent+s.indent,l=t.offset+s.length,u=0;for(let m=0;m<a;++m){let[v,_]=i[m];if(_===""||_==="\r"){if(s.indent===0&&v.length>c)c=v.length}else{if(v.length<c)n(l+v.length,"MISSING_CHAR","Block scalars with more-indented leading empty lines must use an explicit indentation indicator");if(s.indent===0)c=v.length;if(u=m,c===0&&!e.atRoot)n(l,"BAD_INDENT","Block scalar values in collections must be indented");break}l+=v.length+_.length+1}for(let m=i.length-1;m>=a;--m)if(i[m][0].length>c)a=m+1;let p="",d="",h=!1;for(let m=0;m<u;++m)p+=i[m][0].slice(c)+`
73
+ `;for(let m=u;m<a;++m){let[v,_]=i[m];l+=v.length+_.length+1;let A=_[_.length-1]==="\r";if(A)_=_.slice(0,-1);if(_&&v.length<c){let b=`Block scalar lines must not be less indented than their ${s.indent?"explicit indentation indicator":"first line"}`;n(l-_.length-(A?2:1),"BAD_INDENT",b),v=""}if(o===ta.Scalar.BLOCK_LITERAL)p+=d+v.slice(c)+_,d=`
74
+ `;else if(v.length>c||_[0]==="\t"){if(d===" ")d=`
75
75
  `;else if(!h&&d===`
76
76
  `)d=`
77
77
 
78
- `;p+=d+g.slice(c)+w,d=`
79
- `,h=!0}else if(w==="")if(d===`
78
+ `;p+=d+v.slice(c)+_,d=`
79
+ `,h=!0}else if(_==="")if(d===`
80
80
  `)p+=`
81
81
  `;else d=`
82
- `;else p+=d+w,d=" ",h=!1}switch(i.chomp){case"-":break;case"+":for(let m=a;m<o.length;++m)p+=`
83
- `+o[m][0].slice(c);if(p[p.length-1]!==`
82
+ `;else p+=d+_,d=" ",h=!1}switch(s.chomp){case"-":break;case"+":for(let m=a;m<i.length;++m)p+=`
83
+ `+i[m][0].slice(c);if(p[p.length-1]!==`
84
84
  `)p+=`
85
85
  `;break;default:p+=`
86
- `}let f=r+i.length+t.source.length;return{value:p,type:s,comment:i.comment,range:[r,f,f]}}function aS({offset:e,props:t},n,r){if(t[0].type!=="block-scalar-header")return r(t[0],"IMPOSSIBLE","Block scalar header not found"),null;let{source:i}=t[0],s=i[0],o=0,a="",c=-1;for(let d=1;d<i.length;++d){let h=i[d];if(!a&&(h==="-"||h==="+"))a=h;else{let f=Number(h);if(!o&&f)o=f;else if(c===-1)c=e+d}}if(c!==-1)r(c,"UNEXPECTED_TOKEN",`Block scalar header includes extra characters: ${i}`);let l=!1,u="",p=i.length;for(let d=1;d<t.length;++d){let h=t[d];switch(h.type){case"space":l=!0;case"newline":p+=h.source.length;break;case"comment":if(n&&!l)r(h,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");p+=h.source.length,u=h.source.substring(1);break;case"error":r(h,"UNEXPECTED_TOKEN",h.message),p+=h.source.length;break;default:{let f=`Unexpected token in block scalar header: ${h.type}`;r(h,"UNEXPECTED_TOKEN",f);let m=h.source;if(m&&typeof m==="string")p+=m.length}}}return{mode:s,indent:o,chomp:a,comment:u,length:p}}function cS(e){let t=e.split(/\n( *)/),n=t[0],r=n.match(/^( *)/),s=[r?.[1]?[r[1],n.slice(r[1].length)]:["",n]];for(let o=1;o<t.length;o+=2)s.push([t[o],t[o+1]]);return s}lS.resolveBlockScalar=oS});var Bo=P(function(bS){var qo=W(),pS=rn();function dS(e,t,n){let{offset:r,type:i,source:s,end:o}=e,a,c,l=(d,h,f)=>n(r+d,h,f);switch(i){case"scalar":a=qo.Scalar.PLAIN,c=hS(s,l);break;case"single-quoted-scalar":a=qo.Scalar.QUOTE_SINGLE,c=fS(s,l);break;case"double-quoted-scalar":a=qo.Scalar.QUOTE_DOUBLE,c=mS(s,l);break;default:return n(e,"UNEXPECTED_TOKEN",`Expected a flow scalar value, but found: ${i}`),{value:"",type:null,comment:"",range:[r,r+s.length,r+s.length]}}let u=r+s.length,p=pS.resolveEnd(o,u,t,n);return{value:c,type:a,comment:p.comment,range:[r,u,p.offset]}}function hS(e,t){let n="";switch(e[0]){case"\t":n="a tab character";break;case",":n="flow indicator character ,";break;case"%":n="directive indicator character %";break;case"|":case">":{n=`block scalar indicator ${e[0]}`;break}case"@":case"`":{n=`reserved character ${e[0]}`;break}}if(n)t(0,"BAD_SCALAR_START",`Plain value cannot start with ${n}`);return np(e)}function fS(e,t){if(e[e.length-1]!=="'"||e.length===1)t(e.length,"MISSING_CHAR","Missing closing 'quote");return np(e.slice(1,-1)).replace(/''/g,"'")}function np(e){let t=/(.*?)\r?\n/sy,n=t.exec(e);if(!n)return e;let r,i;try{r=new RegExp("(?<![ \t])[ \t]+$"),i=new RegExp("^[ \t]+|(?<![ \t])[ \t]+$","g")}catch{r=/[ \t]+$/,i=/^[ \t]+|[ \t]+$/g}let s=n[1].replace(r,""),o=" ",a=t.lastIndex;while(n=t.exec(e)){let l=n[1].replace(i,"");if(l==="")if(o===`
87
- `)s+=o;else o=`
88
- `;else s+=o+l,o=" ";a=t.lastIndex}let c=/[ \t]*(.*)/sy;return c.lastIndex=a,n=c.exec(e),s+o+(n?.[1]??"")}function mS(e,t){let n="";for(let r=1;r<e.length-1;++r){let i=e[r];if(i==="\r"&&e[r+1]===`
89
- `)continue;if(i===`
90
- `){let{fold:s,offset:o}=gS(e,r);n+=s,r=o}else if(i==="\\"){let s=e[++r],o=vS[s];if(o)n+=o;else if(s===`
91
- `){s=e[r+1];while(s===" "||s==="\t")s=e[++r+1]}else if(s==="\r"&&e[r+1]===`
92
- `){s=e[++r+1];while(s===" "||s==="\t")s=e[++r+1]}else if(s==="x"||s==="u"||s==="U"){let a=s==="x"?2:s==="u"?4:8;n+=yS(e,r+1,a,t),r+=a}else{let a=e.substr(r-1,2);t(r-1,"BAD_DQ_ESCAPE",`Invalid escape sequence ${a}`),n+=a}}else if(i===" "||i==="\t"){let s=r,o=e[r+1];while(o===" "||o==="\t")o=e[++r+1];if(o!==`
93
- `&&!(o==="\r"&&e[r+2]===`
94
- `))n+=r>s?e.slice(s,r+1):i}else n+=i}if(e[e.length-1]!=='"'||e.length===1)t(e.length,"MISSING_CHAR",'Missing closing "quote');return n}function gS(e,t){let n="",r=e[t+1];while(r===" "||r==="\t"||r===`
86
+ `}let f=r+s.length+t.source.length;return{value:p,type:o,comment:s.comment,range:[r,f,f]}}function Z1({offset:e,props:t},n,r){if(t[0].type!=="block-scalar-header")return r(t[0],"IMPOSSIBLE","Block scalar header not found"),null;let{source:s}=t[0],o=s[0],i=0,a="",c=-1;for(let d=1;d<s.length;++d){let h=s[d];if(!a&&(h==="-"||h==="+"))a=h;else{let f=Number(h);if(!i&&f)i=f;else if(c===-1)c=e+d}}if(c!==-1)r(c,"UNEXPECTED_TOKEN",`Block scalar header includes extra characters: ${s}`);let l=!1,u="",p=s.length;for(let d=1;d<t.length;++d){let h=t[d];switch(h.type){case"space":l=!0;case"newline":p+=h.source.length;break;case"comment":if(n&&!l)r(h,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");p+=h.source.length,u=h.source.substring(1);break;case"error":r(h,"UNEXPECTED_TOKEN",h.message),p+=h.source.length;break;default:{let f=`Unexpected token in block scalar header: ${h.type}`;r(h,"UNEXPECTED_TOKEN",f);let m=h.source;if(m&&typeof m==="string")p+=m.length}}}return{mode:o,indent:i,chomp:a,comment:u,length:p}}function q1(e){let t=e.split(/\n( *)/),n=t[0],r=n.match(/^( *)/),o=[r?.[1]?[r[1],n.slice(r[1].length)]:["",n]];for(let i=1;i<t.length;i+=2)o.push([t[i],t[i+1]]);return o}B1.resolveBlockScalar=H1});var sa=T(function(tS){var ra=J(),K1=mn();function W1(e,t,n){let{offset:r,type:s,source:o,end:i}=e,a,c,l=(d,h,f)=>n(r+d,h,f);switch(s){case"scalar":a=ra.Scalar.PLAIN,c=V1(o,l);break;case"single-quoted-scalar":a=ra.Scalar.QUOTE_SINGLE,c=Y1(o,l);break;case"double-quoted-scalar":a=ra.Scalar.QUOTE_DOUBLE,c=J1(o,l);break;default:return n(e,"UNEXPECTED_TOKEN",`Expected a flow scalar value, but found: ${s}`),{value:"",type:null,comment:"",range:[r,r+o.length,r+o.length]}}let u=r+o.length,p=K1.resolveEnd(i,u,t,n);return{value:c,type:a,comment:p.comment,range:[r,u,p.offset]}}function V1(e,t){let n="";switch(e[0]){case"\t":n="a tab character";break;case",":n="flow indicator character ,";break;case"%":n="directive indicator character %";break;case"|":case">":{n=`block scalar indicator ${e[0]}`;break}case"@":case"`":{n=`reserved character ${e[0]}`;break}}if(n)t(0,"BAD_SCALAR_START",`Plain value cannot start with ${n}`);return Ap(e)}function Y1(e,t){if(e[e.length-1]!=="'"||e.length===1)t(e.length,"MISSING_CHAR","Missing closing 'quote");return Ap(e.slice(1,-1)).replace(/''/g,"'")}function Ap(e){let t=/(.*?)\r?\n/sy,n=t.exec(e);if(!n)return e;let r,s;try{r=new RegExp("(?<![ \t])[ \t]+$"),s=new RegExp("^[ \t]+|(?<![ \t])[ \t]+$","g")}catch{r=/[ \t]+$/,s=/^[ \t]+|[ \t]+$/g}let o=n[1].replace(r,""),i=" ",a=t.lastIndex;while(n=t.exec(e)){let l=n[1].replace(s,"");if(l==="")if(i===`
87
+ `)o+=i;else i=`
88
+ `;else o+=i+l,i=" ";a=t.lastIndex}let c=/[ \t]*(.*)/sy;return c.lastIndex=a,n=c.exec(e),o+i+(n?.[1]??"")}function J1(e,t){let n="";for(let r=1;r<e.length-1;++r){let s=e[r];if(s==="\r"&&e[r+1]===`
89
+ `)continue;if(s===`
90
+ `){let{fold:o,offset:i}=Q1(e,r);n+=o,r=i}else if(s==="\\"){let o=e[++r],i=X1[o];if(i)n+=i;else if(o===`
91
+ `){o=e[r+1];while(o===" "||o==="\t")o=e[++r+1]}else if(o==="\r"&&e[r+1]===`
92
+ `){o=e[++r+1];while(o===" "||o==="\t")o=e[++r+1]}else if(o==="x"||o==="u"||o==="U"){let a=o==="x"?2:o==="u"?4:8;n+=eS(e,r+1,a,t),r+=a}else{let a=e.substr(r-1,2);t(r-1,"BAD_DQ_ESCAPE",`Invalid escape sequence ${a}`),n+=a}}else if(s===" "||s==="\t"){let o=r,i=e[r+1];while(i===" "||i==="\t")i=e[++r+1];if(i!==`
93
+ `&&!(i==="\r"&&e[r+2]===`
94
+ `))n+=r>o?e.slice(o,r+1):s}else n+=s}if(e[e.length-1]!=='"'||e.length===1)t(e.length,"MISSING_CHAR",'Missing closing "quote');return n}function Q1(e,t){let n="",r=e[t+1];while(r===" "||r==="\t"||r===`
95
95
  `||r==="\r"){if(r==="\r"&&e[t+2]!==`
96
96
  `)break;if(r===`
97
97
  `)n+=`
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?`
98
+ `;t+=1,r=e[t+1]}if(!n)n=" ";return{fold:n,offset:t}}var X1={"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 eS(e,t,n,r){let s=e.substr(t,n),i=s.length===n&&/^[0-9a-fA-F]+$/.test(s)?parseInt(s,16):NaN;try{return String.fromCodePoint(i)}catch{let a=e.substr(t-2,n+2);return r(t-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${a}`),a}}tS.resolveFlowScalar=W1});var Tp=T(function(cS){var Gt=j(),$p=J(),rS=na(),sS=sa();function oS(e,t,n,r){let{value:s,type:o,comment:i,range:a}=t.type==="block-scalar"?rS.resolveBlockScalar(e,t,r):sS.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[Gt.SCALAR];else if(c)l=iS(e.schema,s,c,n,r);else if(t.type==="scalar")l=aS(e,s,t,r);else l=e.schema[Gt.SCALAR];let u;try{let p=l.resolve(s,(d)=>r(n??t,"TAG_RESOLVE_FAILED",d),e.options);u=Gt.isScalar(p)?p:new $p.Scalar(p)}catch(p){let d=p instanceof Error?p.message:String(p);r(n??t,"TAG_RESOLVE_FAILED",d),u=new $p.Scalar(s)}if(u.range=a,u.source=s,o)u.type=o;if(c)u.tag=c;if(l.format)u.format=l.format;if(i)u.comment=i;return u}function iS(e,t,n,r,s){if(n==="!")return e[Gt.SCALAR];let o=[];for(let a of e.tags)if(!a.collection&&a.tag===n)if(a.default&&a.test)o.push(a);else return a;for(let a of o)if(a.test?.test(t))return a;let i=e.knownTags[n];if(i&&!i.collection)return e.tags.push(Object.assign({},i,{default:!1,test:void 0})),i;return s(r,"TAG_RESOLVE_FAILED",`Unresolved tag: ${n}`,n!=="tag:yaml.org,2002:str"),e[Gt.SCALAR]}function aS({atKey:e,directives:t,schema:n},r,s,o){let i=n.tags.find((a)=>(a.default===!0||e&&a.default==="key")&&a.test?.test(r))||n[Gt.SCALAR];if(n.compat){let a=n.compat.find((c)=>c.default&&c.test?.test(r))??n[Gt.SCALAR];if(i.tag!==a.tag){let c=t.tagString(i.tag),l=t.tagString(a.tag),u=`Value may be parsed as either ${c} or ${l}`;o(s,"TAG_RESOLVE_FAILED",u,!0)}}return i}cS.composeScalar=oS});var Pp=T(function(pS){function uS(e,t,n){if(t){n??(n=t.length);for(let r=n-1;r>=0;--r){let s=t[r];switch(s.type){case"space":case"comment":case"newline":e-=s.source.length;continue}s=t[++r];while(s?.type==="space")e+=s.source.length,s=t[++r];break}}return e}pS.emptyScalarPosition=uS});var Cp=T(function(wS){var hS=Dn(),fS=j(),mS=Sp(),Ep=Tp(),gS=mn(),vS=Pp(),bS={composeNode:Op,composeEmptyNode:oa};function Op(e,t,n,r){let s=e.atKey,{spaceBefore:o,comment:i,anchor:a,tag:c}=n,l,u=!0;switch(t.type){case"alias":if(l=yS(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=Ep.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=mS.composeCollection(bS,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=oa(e,t.offset,void 0,null,n,r)),a&&l.anchor==="")r(a,"BAD_ALIAS","Anchor cannot be an empty string");if(s&&e.options.stringKeys&&(!fS.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(o)l.spaceBefore=!0;if(i)if(t.type==="scalar"&&t.source==="")l.comment=i;else l.commentBefore=i;if(e.options.keepSourceTokens&&u)l.srcToken=t;return l}function oa(e,t,n,r,{spaceBefore:s,comment:o,anchor:i,tag:a,end:c},l){let u={type:"scalar",offset:vS.emptyScalarPosition(t,n,r),indent:-1,source:""},p=Ep.composeScalar(e,u,a,l);if(i){if(p.anchor=i.source.substring(1),p.anchor==="")l(i,"BAD_ALIAS","Anchor cannot be an empty string")}if(s)p.spaceBefore=!0;if(o)p.comment=o,p.range[2]=c;return p}function yS({options:e},{offset:t,source:n,end:r},s){let o=new hS.Alias(n.substring(1));if(o.source==="")s(t,"BAD_ALIAS","Alias cannot be an empty string");if(o.source.endsWith(":"))s(t+n.length-1,"BAD_ALIAS","Alias ending in : is ambiguous",!0);let i=t+n.length,a=gS.resolveEnd(r,i,e.strict,s);if(o.range=[t,i,a.offset],a.comment)o.comment=a.comment;return o}wS.composeEmptyNode=oa;wS.composeNode=Op});var Ip=T(function(TS){var xS=Qn(),Rp=Cp(),SS=mn(),AS=er();function $S(e,t,{offset:n,start:r,value:s,end:o},i){let a=Object.assign({_directives:t},e),c=new xS.Document(void 0,a),l={atKey:!1,atRoot:!0,directives:c.directives,options:c.options,schema:c.schema},u=AS.resolveProps(r,{indicator:"doc-start",next:s??o?.[0],offset:n,onError:i,parentIndent:0,startOnNewline:!0});if(u.found){if(c.directives.docStart=!0,s&&(s.type==="block-map"||s.type==="block-seq")&&!u.hasNewline)i(u.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")}c.contents=s?Rp.composeNode(l,s,u,i):Rp.composeEmptyNode(l,u.end,r,null,u,i);let p=c.contents.range[2],d=SS.resolveEnd(o,p,!1,i);if(d.comment)c.comment=d.comment;return c.range=[n,p,d.offset],c}TS.composeDoc=$S});var ia=T(function(NS){var ES=ze("process"),OS=ui(),CS=Qn(),tr=Xn(),Np=j(),RS=Ip(),IS=mn();function nr(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 zp(e){let t="",n=!1,r=!1;for(let s=0;s<e.length;++s){let o=e[s];switch(o[0]){case"#":t+=(t===""?"":r?`
100
100
 
101
101
  `:`
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}
103
- ${n}`:n;else if(r||e.directives.docStart||!i)e.commentBefore=n;else if(pp.isCollection(i)&&!i.flow&&i.items.length>0){let s=i.items[0];if(pp.isPair(s))s=s.key;let o=s.commentBefore;s.commentBefore=o?`${n}
104
- ${o}`:n}else{let s=i.commentBefore;i.commentBefore=s?`${n}
105
- ${s}`:n}}if(t){for(let i=0;i<this.errors.length;++i)e.errors.push(this.errors[i]);for(let i=0;i<this.warnings.length;++i)e.warnings.push(this.warnings[i])}else e.errors=this.errors,e.warnings=this.warnings;this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:dp(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,t=!1,n=-1){for(let r of e)yield*this.next(r);yield*this.end(t,n)}*next(e){if(KS.env.LOG_STREAM)console.dir(e,{depth:null});switch(e.type){case"directive":this.directives.add(e.source,(t,n,r)=>{let i=Fn(e);i[0]+=t,this.onError(i,"BAD_DIRECTIVE",n,r)}),this.prelude.push(e.source),this.atDirectives=!0;break;case"document":{let t=YS.composeDoc(this.options,this.directives,e,this.onError);if(this.atDirectives&&!t.directives.docStart)this.onError(e,"MISSING_CHAR","Missing directives-end/doc-start indicator line");if(this.decorate(t,!1),this.doc)yield this.doc;this.doc=t,this.atDirectives=!1;break}case"byte-order-mark":case"space":break;case"comment":case"newline":this.prelude.push(e.source);break;case"error":{let t=e.source?`${e.message}: ${JSON.stringify(e.source)}`:e.message,n=new Hn.YAMLParseError(Fn(e),"UNEXPECTED_TOKEN",t);if(this.atDirectives||!this.doc)this.errors.push(n);else this.doc.errors.push(n);break}case"doc-end":{if(!this.doc){this.errors.push(new Hn.YAMLParseError(Fn(e),"UNEXPECTED_TOKEN","Unexpected doc-end without preceding document"));break}this.doc.directives.docEnd=!0;let t=JS.resolveEnd(e.end,e.offset+e.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),t.comment){let n=this.doc.comment;this.doc.comment=n?`${n}
106
- ${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.push(new Hn.YAMLParseError(Fn(e),"UNEXPECTED_TOKEN",`Unsupported token ${e.type}`))}}*end(e=!1,t=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(e){let n=Object.assign({_directives:this.directives},this.options),r=new VS.Document(void 0,n);if(this.atDirectives)this.onError(t,"MISSING_CHAR","Missing directives-end indicator line");r.range=[0,t,t],this.decorate(r,!1),yield r}}}QS.Composer=hp});var gp=P(function(a1){var e1=Go(),t1=Bo(),n1=qn(),fp=Rn();function r1(e,t=!0,n){if(e){let r=(i,s,o)=>{let a=typeof i==="number"?i:Array.isArray(i)?i[0]:i.offset;if(n)n(a,s,o);else throw new n1.YAMLParseError([a,a+1],s,o)};switch(e.type){case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return t1.resolveFlowScalar(e,t,r);case"block-scalar":return e1.resolveBlockScalar({options:{strict:t}},e,r)}}return null}function i1(e,t){let{implicitKey:n=!1,indent:r,inFlow:i=!1,offset:s=-1,type:o="PLAIN"}=t,a=fp.stringifyString({type:o,value:e},{implicitKey:n,indent:r>0?" ".repeat(r):"",inFlow:i,options:{blockQuote:!0,lineWidth:-1}}),c=t.end??[{type:"newline",offset:-1,indent:r,source:`
102
+ `)+(o.substring(1)||" "),n=!0,r=!1;break;case"%":if(e[s+1]?.[0]!=="#")s+=1;n=!1;break;default:if(!n)r=!0;n=!1}}return{comment:t,afterEmptyLine:r}}class jp{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(t,n,r,s)=>{let o=nr(t);if(s)this.warnings.push(new tr.YAMLWarning(o,n,r));else this.errors.push(new tr.YAMLParseError(o,n,r))},this.directives=new OS.Directives({version:e.version||"1.2"}),this.options=e}decorate(e,t){let{comment:n,afterEmptyLine:r}=zp(this.prelude);if(n){let s=e.contents;if(t)e.comment=e.comment?`${e.comment}
103
+ ${n}`:n;else if(r||e.directives.docStart||!s)e.commentBefore=n;else if(Np.isCollection(s)&&!s.flow&&s.items.length>0){let o=s.items[0];if(Np.isPair(o))o=o.key;let i=o.commentBefore;o.commentBefore=i?`${n}
104
+ ${i}`:n}else{let o=s.commentBefore;s.commentBefore=o?`${n}
105
+ ${o}`:n}}if(t){for(let s=0;s<this.errors.length;++s)e.errors.push(this.errors[s]);for(let s=0;s<this.warnings.length;++s)e.warnings.push(this.warnings[s])}else e.errors=this.errors,e.warnings=this.warnings;this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:zp(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,t=!1,n=-1){for(let r of e)yield*this.next(r);yield*this.end(t,n)}*next(e){if(ES.env.LOG_STREAM)console.dir(e,{depth:null});switch(e.type){case"directive":this.directives.add(e.source,(t,n,r)=>{let s=nr(e);s[0]+=t,this.onError(s,"BAD_DIRECTIVE",n,r)}),this.prelude.push(e.source),this.atDirectives=!0;break;case"document":{let t=RS.composeDoc(this.options,this.directives,e,this.onError);if(this.atDirectives&&!t.directives.docStart)this.onError(e,"MISSING_CHAR","Missing directives-end/doc-start indicator line");if(this.decorate(t,!1),this.doc)yield this.doc;this.doc=t,this.atDirectives=!1;break}case"byte-order-mark":case"space":break;case"comment":case"newline":this.prelude.push(e.source);break;case"error":{let t=e.source?`${e.message}: ${JSON.stringify(e.source)}`:e.message,n=new tr.YAMLParseError(nr(e),"UNEXPECTED_TOKEN",t);if(this.atDirectives||!this.doc)this.errors.push(n);else this.doc.errors.push(n);break}case"doc-end":{if(!this.doc){this.errors.push(new tr.YAMLParseError(nr(e),"UNEXPECTED_TOKEN","Unexpected doc-end without preceding document"));break}this.doc.directives.docEnd=!0;let t=IS.resolveEnd(e.end,e.offset+e.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),t.comment){let n=this.doc.comment;this.doc.comment=n?`${n}
106
+ ${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.push(new tr.YAMLParseError(nr(e),"UNEXPECTED_TOKEN",`Unsupported token ${e.type}`))}}*end(e=!1,t=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(e){let n=Object.assign({_directives:this.directives},this.options),r=new CS.Document(void 0,n);if(this.atDirectives)this.onError(t,"MISSING_CHAR","Missing directives-end indicator line");r.range=[0,t,t],this.decorate(r,!1),yield r}}}NS.Composer=jp});var Mp=T(function(ZS){var jS=na(),LS=sa(),DS=Xn(),Lp=Hn();function MS(e,t=!0,n){if(e){let r=(s,o,i)=>{let a=typeof s==="number"?s:Array.isArray(s)?s[0]:s.offset;if(n)n(a,o,i);else throw new DS.YAMLParseError([a,a+1],o,i)};switch(e.type){case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return LS.resolveFlowScalar(e,t,r);case"block-scalar":return jS.resolveBlockScalar({options:{strict:t}},e,r)}}return null}function US(e,t){let{implicitKey:n=!1,indent:r,inFlow:s=!1,offset:o=-1,type:i="PLAIN"}=t,a=Lp.stringifyString({type:i,value:e},{implicitKey:n,indent:r>0?" ".repeat(r):"",inFlow:s,options:{blockQuote:!0,lineWidth:-1}}),c=t.end??[{type:"newline",offset:-1,indent:r,source:`
107
107
  `}];switch(a[0]){case"|":case">":{let l=a.indexOf(`
108
108
  `),u=a.substring(0,l),p=a.substring(l+1)+`
109
- `,d=[{type:"block-scalar-header",offset:s,indent:r,source:u}];if(!mp(d,c))d.push({type:"newline",offset:-1,indent:r,source:`
110
- `});return{type:"block-scalar",offset:s,indent:r,props:d,source:p}}case'"':return{type:"double-quoted-scalar",offset:s,indent:r,source:a,end:c};case"'":return{type:"single-quoted-scalar",offset:s,indent:r,source:a,end:c};default:return{type:"scalar",offset:s,indent:r,source:a,end:c}}}function s1(e,t,n={}){let{afterKey:r=!1,implicitKey:i=!1,inFlow:s=!1,type:o}=n,a="indent"in e?e.indent:null;if(r&&typeof a==="number")a+=2;if(!o)switch(e.type){case"single-quoted-scalar":o="QUOTE_SINGLE";break;case"double-quoted-scalar":o="QUOTE_DOUBLE";break;case"block-scalar":{let l=e.props[0];if(l.type!=="block-scalar-header")throw Error("Invalid block scalar header");o=l.source[0]===">"?"BLOCK_FOLDED":"BLOCK_LITERAL";break}default:o="PLAIN"}let c=fp.stringifyString({type:o,value:t},{implicitKey:i||a===null,indent:a!==null&&a>0?" ".repeat(a):"",inFlow:s,options:{blockQuote:!0,lineWidth:-1}});switch(c[0]){case"|":case">":o1(e,c);break;case'"':Ko(e,c,"double-quoted-scalar");break;case"'":Ko(e,c,"single-quoted-scalar");break;default:Ko(e,c,"scalar")}}function o1(e,t){let n=t.indexOf(`
111
- `),r=t.substring(0,n),i=t.substring(n+1)+`
112
- `;if(e.type==="block-scalar"){let s=e.props[0];if(s.type!=="block-scalar-header")throw Error("Invalid block scalar header");s.source=r,e.source=i}else{let{offset:s}=e,o="indent"in e?e.indent:-1,a=[{type:"block-scalar-header",offset:s,indent:o,source:r}];if(!mp(a,"end"in e?e.end:void 0))a.push({type:"newline",offset:-1,indent:o,source:`
113
- `});for(let c of Object.keys(e))if(c!=="type"&&c!=="offset")delete e[c];Object.assign(e,{type:"block-scalar",indent:o,props:a,source:i})}}function mp(e,t){if(t)for(let n of t)switch(n.type){case"space":case"comment":e.push(n);break;case"newline":return e.push(n),!0}return!1}function Ko(e,t,n){switch(e.type){case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":e.type=n,e.source=t;break;case"block-scalar":{let r=e.props.slice(1),i=t.length;if(e.props[0].type==="block-scalar-header")i-=e.props[0].source.length;for(let s of r)s.offset+=i;delete e.props,Object.assign(e,{type:n,source:t,end:r});break}case"block-map":case"block-seq":{let i={type:"newline",offset:e.offset+t.length,indent:e.indent,source:`
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`
109
+ `,d=[{type:"block-scalar-header",offset:o,indent:r,source:u}];if(!Dp(d,c))d.push({type:"newline",offset:-1,indent:r,source:`
110
+ `});return{type:"block-scalar",offset:o,indent:r,props:d,source:p}}case'"':return{type:"double-quoted-scalar",offset:o,indent:r,source:a,end:c};case"'":return{type:"single-quoted-scalar",offset:o,indent:r,source:a,end:c};default:return{type:"scalar",offset:o,indent:r,source:a,end:c}}}function GS(e,t,n={}){let{afterKey:r=!1,implicitKey:s=!1,inFlow:o=!1,type:i}=n,a="indent"in e?e.indent:null;if(r&&typeof a==="number")a+=2;if(!i)switch(e.type){case"single-quoted-scalar":i="QUOTE_SINGLE";break;case"double-quoted-scalar":i="QUOTE_DOUBLE";break;case"block-scalar":{let l=e.props[0];if(l.type!=="block-scalar-header")throw Error("Invalid block scalar header");i=l.source[0]===">"?"BLOCK_FOLDED":"BLOCK_LITERAL";break}default:i="PLAIN"}let c=Lp.stringifyString({type:i,value:t},{implicitKey:s||a===null,indent:a!==null&&a>0?" ".repeat(a):"",inFlow:o,options:{blockQuote:!0,lineWidth:-1}});switch(c[0]){case"|":case">":HS(e,c);break;case'"':aa(e,c,"double-quoted-scalar");break;case"'":aa(e,c,"single-quoted-scalar");break;default:aa(e,c,"scalar")}}function HS(e,t){let n=t.indexOf(`
111
+ `),r=t.substring(0,n),s=t.substring(n+1)+`
112
+ `;if(e.type==="block-scalar"){let o=e.props[0];if(o.type!=="block-scalar-header")throw Error("Invalid block scalar header");o.source=r,e.source=s}else{let{offset:o}=e,i="indent"in e?e.indent:-1,a=[{type:"block-scalar-header",offset:o,indent:i,source:r}];if(!Dp(a,"end"in e?e.end:void 0))a.push({type:"newline",offset:-1,indent:i,source:`
113
+ `});for(let c of Object.keys(e))if(c!=="type"&&c!=="offset")delete e[c];Object.assign(e,{type:"block-scalar",indent:i,props:a,source:s})}}function Dp(e,t){if(t)for(let n of t)switch(n.type){case"space":case"comment":e.push(n);break;case"newline":return e.push(n),!0}return!1}function aa(e,t,n){switch(e.type){case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":e.type=n,e.source=t;break;case"block-scalar":{let r=e.props.slice(1),s=t.length;if(e.props[0].type==="block-scalar-header")s-=e.props[0].source.length;for(let o of r)o.offset+=s;delete e.props,Object.assign(e,{type:n,source:t,end:r});break}case"block-map":case"block-seq":{let s={type:"newline",offset:e.offset+t.length,indent:e.indent,source:`
114
+ `};delete e.items,Object.assign(e,{type:n,source:t,end:[s]});break}default:{let r="indent"in e?e.indent:-1,s="end"in e&&Array.isArray(e.end)?e.end.filter((o)=>o.type==="space"||o.type==="comment"||o.type==="newline"):[];for(let o of Object.keys(e))if(o!=="type"&&o!=="offset")delete e[o];Object.assign(e,{type:n,indent:r,source:t,end:s})}}}ZS.createScalarToken=US;ZS.resolveAsScalar=MS;ZS.setScalarValue=GS});var Up=T(function(WS){var KS=(e)=>("type"in e)?Os(e):Es(e);function Os(e){switch(e.type){case"block-scalar":{let t="";for(let n of e.props)t+=Os(n);return t+e.source}case"block-map":case"block-seq":{let t="";for(let n of e.items)t+=Es(n);return t}case"flow-collection":{let t=e.start.source;for(let n of e.items)t+=Es(n);for(let n of e.end)t+=n.source;return t}case"document":{let t=Es(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 Es({start:e,key:t,sep:n,value:r}){let s="";for(let o of e)s+=o.source;if(t)s+=Os(t);if(n)for(let o of n)s+=o.source;if(r)s+=Os(r);return s}WS.stringify=KS});var Zp=T(function(JS){var ca=Symbol("break visit"),YS=Symbol("skip children"),Gp=Symbol("remove item");function Ht(e,t){if("type"in e&&e.type==="document")e={start:e.start,value:e.value};Hp(Object.freeze([]),e,t)}Ht.BREAK=ca;Ht.SKIP=YS;Ht.REMOVE=Gp;Ht.itemAtPath=(e,t)=>{let n=e;for(let[r,s]of t){let o=n?.[r];if(o&&"items"in o)n=o.items[s];else return}return n};Ht.parentCollection=(e,t)=>{let n=Ht.itemAtPath(e,t.slice(0,-1)),r=t[t.length-1][0],s=n?.[r];if(s&&"items"in s)return s;throw Error("Parent collection not found")};function Hp(e,t,n){let r=n(t,e);if(typeof r==="symbol")return r;for(let s of["key","value"]){let o=t[s];if(o&&"items"in o){for(let i=0;i<o.items.length;++i){let a=Hp(Object.freeze(e.concat([[s,i]])),o.items[i],n);if(typeof a==="number")i=a-1;else if(a===ca)return ca;else if(a===Gp)o.items.splice(i,1),i-=1}if(typeof r==="function"&&s==="key")r=r(t,e)}}return typeof r==="function"?r(t,e):r}JS.visit=Ht});var Cs=T(function(oA){var la=Mp(),XS=Up(),eA=Zp(),ua="\uFEFF",pa="\x02",da="\x18",ha="\x1F",tA=(e)=>!!e&&("items"in e),nA=(e)=>!!e&&(e.type==="scalar"||e.type==="single-quoted-scalar"||e.type==="double-quoted-scalar"||e.type==="block-scalar");function rA(e){switch(e){case ua:return"<BOM>";case pa:return"<DOC>";case da:return"<FLOW_END>";case ha:return"<SCALAR>";default:return JSON.stringify(e)}}function sA(e){switch(e){case ua:return"byte-order-mark";case pa:return"doc-mode";case da:return"flow-error-end";case ha:return"scalar";case"---":return"doc-start";case"...":return"doc-end";case"":case`
115
115
  `:case`\r
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===`
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}oA.createScalarToken=la.createScalarToken;oA.resolveAsScalar=la.resolveAsScalar;oA.setScalarValue=la.setScalarValue;oA.stringify=XS.stringify;oA.visit=eA.visit;oA.BOM=ua;oA.DOCUMENT=pa;oA.FLOW_END=da;oA.SCALAR=ha;oA.isCollection=tA;oA.isScalar=nA;oA.prettyToken=rA;oA.tokenType=sA});var ma=T(function(_A){var rr=Cs();function Le(e){switch(e){case void 0:case" ":case`
117
+ `:case"\r":case"\t":return!0;default:return!1}}var qp=new Set("0123456789ABCDEFabcdef"),yA=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),Rs=new Set(",[]{}"),wA=new Set(` ,[]{}
118
+ \r `),fa=(e)=>!e||wA.has(e);class Bp{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===`
122
- `||n>=this.indentNext||!t&&!this.atEnd?e+n:-1}if(t==="-"||t==="."){let n=this.buffer.substr(e,3);if((n==="---"||n==="...")&&Ie(this.buffer[e+3]))return-1}return e}getLine(){let e=this.lineEndPos;if(typeof e!=="number"||e!==-1&&e<this.pos)e=this.buffer.indexOf(`
123
- `,this.pos),this.lineEndPos=e;if(e===-1)return this.atEnd?this.buffer.substring(this.pos):null;if(this.buffer[e-1]==="\r")e-=1;return this.buffer.substring(this.pos,e)}hasChars(e){return this.pos+e<=this.buffer.length}setNext(e){return this.buffer=this.buffer.substring(this.pos),this.pos=0,this.lineEndPos=null,this.next=e,null}peek(e){return this.buffer.substr(this.pos,e)}*parseNext(e){switch(e){case"stream":return yield*this.parseStream();case"line-start":return yield*this.parseLineStart();case"block-start":return yield*this.parseBlockStart();case"doc":return yield*this.parseDocument();case"flow":return yield*this.parseFlowCollection();case"quoted-scalar":return yield*this.parseQuotedScalar();case"block-scalar":return yield*this.parseBlockScalar();case"plain-scalar":return yield*this.parsePlainScalar()}}*parseStream(){let e=this.getLine();if(e===null)return this.setNext("stream");if(e[0]===Kn.BOM)yield*this.pushCount(1),e=e.substring(1);if(e[0]==="%"){let t=e.length,n=e.indexOf("#");while(n!==-1){let i=e[n-1];if(i===" "||i==="\t"){t=n-1;break}else n=e.indexOf("#",n+1)}while(!0){let i=e[t-1];if(i===" "||i==="\t")t-=1;else break}let r=(yield*this.pushCount(t))+(yield*this.pushSpaces(!0));return yield*this.pushCount(e.length-r),this.pushNewline(),"stream"}if(this.atLineEnd()){let t=yield*this.pushSpaces(!0);return yield*this.pushCount(e.length-t),yield*this.pushNewline(),"stream"}return yield Kn.DOCUMENT,yield*this.parseLineStart()}*parseLineStart(){let e=this.charAt(0);if(!e&&!this.atEnd)return this.setNext("line-start");if(e==="-"||e==="."){if(!this.atEnd&&!this.hasChars(4))return this.setNext("line-start");let t=this.peek(3);if((t==="---"||t==="...")&&Ie(this.charAt(3)))return yield*this.pushCount(3),this.indentValue=0,this.indentNext=0,t==="---"?"doc":"stream"}if(this.indentValue=yield*this.pushSpaces(!1),this.indentNext>this.indentValue&&!Ie(this.charAt(1)))this.indentNext=this.indentValue;return yield*this.parseBlockStart()}*parseBlockStart(){let[e,t]=this.peek(2);if(!t&&!this.atEnd)return this.setNext("block-start");if((e==="-"||e==="?"||e===":")&&Ie(t)){let n=(yield*this.pushCount(1))+(yield*this.pushSpaces(!0));return this.indentNext=this.indentValue+1,this.indentValue+=n,"block-start"}return"doc"}*parseDocument(){yield*this.pushSpaces(!0);let e=this.getLine();if(e===null)return this.setNext("doc");let t=yield*this.pushIndicators();switch(e[t]){case"#":yield*this.pushCount(e.length-t);case void 0:return yield*this.pushNewline(),yield*this.parseLineStart();case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel=1,"flow";case"}":case"]":return yield*this.pushCount(1),"doc";case"*":return yield*this.pushUntil(ea),"doc";case'"':case"'":return yield*this.parseQuotedScalar();case"|":case">":return t+=yield*this.parseBlockScalarHeader(),t+=yield*this.pushSpaces(!0),yield*this.pushCount(e.length-t),yield*this.pushNewline(),yield*this.parseBlockScalar();default:return yield*this.parsePlainScalar()}}*parseFlowCollection(){let e,t,n=-1;do{if(e=yield*this.pushNewline(),e>0)t=yield*this.pushSpaces(!1),this.indentValue=n=t;else t=0;t+=yield*this.pushSpaces(!0)}while(e+t>0);let r=this.getLine();if(r===null)return this.setNext("flow");if(n!==-1&&n<this.indentNext&&r[0]!=="#"||n===0&&(r.startsWith("---")||r.startsWith("..."))&&Ie(r[3])){if(!(n===this.indentNext-1&&this.flowLevel===1&&(r[0]==="]"||r[0]==="}")))return this.flowLevel=0,yield Kn.FLOW_END,yield*this.parseLineStart()}let i=0;while(r[i]===",")i+=yield*this.pushCount(1),i+=yield*this.pushSpaces(!0),this.flowKey=!1;switch(i+=yield*this.pushIndicators(),r[i]){case void 0:return"flow";case"#":return yield*this.pushCount(r.length-i),"flow";case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel+=1,"flow";case"}":case"]":return yield*this.pushCount(1),this.flowKey=!0,this.flowLevel-=1,this.flowLevel?"flow":"doc";case"*":return yield*this.pushUntil(ea),"flow";case'"':case"'":return this.flowKey=!0,yield*this.parseQuotedScalar();case":":{let s=this.charAt(1);if(this.flowKey||Ie(s)||s===",")return this.flowKey=!1,yield*this.pushCount(1),yield*this.pushSpaces(!0),"flow"}default:return this.flowKey=!1,yield*this.parsePlainScalar()}}*parseQuotedScalar(){let e=this.charAt(0),t=this.buffer.indexOf(e,this.pos+1);if(e==="'")while(t!==-1&&this.buffer[t+1]==="'")t=this.buffer.indexOf("'",t+2);else while(t!==-1){let i=0;while(this.buffer[t-1-i]==="\\")i+=1;if(i%2===0)break;t=this.buffer.indexOf('"',t+1)}let n=this.buffer.substring(0,t),r=n.indexOf(`
124
- `,this.pos);if(r!==-1){while(r!==-1){let i=this.continueScalar(r+1);if(i===-1)break;r=n.indexOf(`
125
- `,i)}if(r!==-1)t=r-(n[r-1]==="\r"?2:1)}if(t===-1){if(!this.atEnd)return this.setNext("quoted-scalar");t=this.buffer.length}return yield*this.pushToIndex(t+1,!1),this.flowLevel?"flow":"doc"}*parseBlockScalarHeader(){this.blockScalarIndent=-1,this.blockScalarKeep=!1;let e=this.pos;while(!0){let t=this.buffer[++e];if(t==="+")this.blockScalarKeep=!0;else if(t>"0"&&t<="9")this.blockScalarIndent=Number(t)-1;else if(t!=="-")break}return yield*this.pushUntil((t)=>Ie(t)||t==="#")}*parseBlockScalar(){let e=this.pos-1,t=0,n;e:for(let i=this.pos;n=this.buffer[i];++i)switch(n){case" ":t+=1;break;case`
126
- `:e=i,t=0;break;case"\r":{let s=this.buffer[i+1];if(!s&&!this.atEnd)return this.setNext("block-scalar");if(s===`
127
- `)break}default:break e}if(!n&&!this.atEnd)return this.setNext("block-scalar");if(t>=this.indentNext){if(this.blockScalarIndent===-1)this.indentNext=t;else this.indentNext=this.blockScalarIndent+(this.indentNext===0?1:this.indentNext);do{let i=this.continueScalar(e+1);if(i===-1)break;e=this.buffer.indexOf(`
128
- `,i)}while(e!==-1);if(e===-1){if(!this.atEnd)return this.setNext("block-scalar");e=this.buffer.length}}let r=e+1;n=this.buffer[r];while(n===" ")n=this.buffer[++r];if(n==="\t"){while(n==="\t"||n===" "||n==="\r"||n===`
129
- `)n=this.buffer[++r];e=r-1}else if(!this.blockScalarKeep)do{let i=e-1,s=this.buffer[i];if(s==="\r")s=this.buffer[--i];let o=i;while(s===" ")s=this.buffer[--i];if(s===`
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===`
122
+ `||n>=this.indentNext||!t&&!this.atEnd?e+n:-1}if(t==="-"||t==="."){let n=this.buffer.substr(e,3);if((n==="---"||n==="...")&&Le(this.buffer[e+3]))return-1}return e}getLine(){let e=this.lineEndPos;if(typeof e!=="number"||e!==-1&&e<this.pos)e=this.buffer.indexOf(`
123
+ `,this.pos),this.lineEndPos=e;if(e===-1)return this.atEnd?this.buffer.substring(this.pos):null;if(this.buffer[e-1]==="\r")e-=1;return this.buffer.substring(this.pos,e)}hasChars(e){return this.pos+e<=this.buffer.length}setNext(e){return this.buffer=this.buffer.substring(this.pos),this.pos=0,this.lineEndPos=null,this.next=e,null}peek(e){return this.buffer.substr(this.pos,e)}*parseNext(e){switch(e){case"stream":return yield*this.parseStream();case"line-start":return yield*this.parseLineStart();case"block-start":return yield*this.parseBlockStart();case"doc":return yield*this.parseDocument();case"flow":return yield*this.parseFlowCollection();case"quoted-scalar":return yield*this.parseQuotedScalar();case"block-scalar":return yield*this.parseBlockScalar();case"plain-scalar":return yield*this.parsePlainScalar()}}*parseStream(){let e=this.getLine();if(e===null)return this.setNext("stream");if(e[0]===rr.BOM)yield*this.pushCount(1),e=e.substring(1);if(e[0]==="%"){let t=e.length,n=e.indexOf("#");while(n!==-1){let s=e[n-1];if(s===" "||s==="\t"){t=n-1;break}else n=e.indexOf("#",n+1)}while(!0){let s=e[t-1];if(s===" "||s==="\t")t-=1;else break}let r=(yield*this.pushCount(t))+(yield*this.pushSpaces(!0));return yield*this.pushCount(e.length-r),this.pushNewline(),"stream"}if(this.atLineEnd()){let t=yield*this.pushSpaces(!0);return yield*this.pushCount(e.length-t),yield*this.pushNewline(),"stream"}return yield rr.DOCUMENT,yield*this.parseLineStart()}*parseLineStart(){let e=this.charAt(0);if(!e&&!this.atEnd)return this.setNext("line-start");if(e==="-"||e==="."){if(!this.atEnd&&!this.hasChars(4))return this.setNext("line-start");let t=this.peek(3);if((t==="---"||t==="...")&&Le(this.charAt(3)))return yield*this.pushCount(3),this.indentValue=0,this.indentNext=0,t==="---"?"doc":"stream"}if(this.indentValue=yield*this.pushSpaces(!1),this.indentNext>this.indentValue&&!Le(this.charAt(1)))this.indentNext=this.indentValue;return yield*this.parseBlockStart()}*parseBlockStart(){let[e,t]=this.peek(2);if(!t&&!this.atEnd)return this.setNext("block-start");if((e==="-"||e==="?"||e===":")&&Le(t)){let n=(yield*this.pushCount(1))+(yield*this.pushSpaces(!0));return this.indentNext=this.indentValue+1,this.indentValue+=n,"block-start"}return"doc"}*parseDocument(){yield*this.pushSpaces(!0);let e=this.getLine();if(e===null)return this.setNext("doc");let t=yield*this.pushIndicators();switch(e[t]){case"#":yield*this.pushCount(e.length-t);case void 0:return yield*this.pushNewline(),yield*this.parseLineStart();case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel=1,"flow";case"}":case"]":return yield*this.pushCount(1),"doc";case"*":return yield*this.pushUntil(fa),"doc";case'"':case"'":return yield*this.parseQuotedScalar();case"|":case">":return t+=yield*this.parseBlockScalarHeader(),t+=yield*this.pushSpaces(!0),yield*this.pushCount(e.length-t),yield*this.pushNewline(),yield*this.parseBlockScalar();default:return yield*this.parsePlainScalar()}}*parseFlowCollection(){let e,t,n=-1;do{if(e=yield*this.pushNewline(),e>0)t=yield*this.pushSpaces(!1),this.indentValue=n=t;else t=0;t+=yield*this.pushSpaces(!0)}while(e+t>0);let r=this.getLine();if(r===null)return this.setNext("flow");if(n!==-1&&n<this.indentNext&&r[0]!=="#"||n===0&&(r.startsWith("---")||r.startsWith("..."))&&Le(r[3])){if(!(n===this.indentNext-1&&this.flowLevel===1&&(r[0]==="]"||r[0]==="}")))return this.flowLevel=0,yield rr.FLOW_END,yield*this.parseLineStart()}let s=0;while(r[s]===",")s+=yield*this.pushCount(1),s+=yield*this.pushSpaces(!0),this.flowKey=!1;switch(s+=yield*this.pushIndicators(),r[s]){case void 0:return"flow";case"#":return yield*this.pushCount(r.length-s),"flow";case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel+=1,"flow";case"}":case"]":return yield*this.pushCount(1),this.flowKey=!0,this.flowLevel-=1,this.flowLevel?"flow":"doc";case"*":return yield*this.pushUntil(fa),"flow";case'"':case"'":return this.flowKey=!0,yield*this.parseQuotedScalar();case":":{let o=this.charAt(1);if(this.flowKey||Le(o)||o===",")return this.flowKey=!1,yield*this.pushCount(1),yield*this.pushSpaces(!0),"flow"}default:return this.flowKey=!1,yield*this.parsePlainScalar()}}*parseQuotedScalar(){let e=this.charAt(0),t=this.buffer.indexOf(e,this.pos+1);if(e==="'")while(t!==-1&&this.buffer[t+1]==="'")t=this.buffer.indexOf("'",t+2);else while(t!==-1){let s=0;while(this.buffer[t-1-s]==="\\")s+=1;if(s%2===0)break;t=this.buffer.indexOf('"',t+1)}let n=this.buffer.substring(0,t),r=n.indexOf(`
124
+ `,this.pos);if(r!==-1){while(r!==-1){let s=this.continueScalar(r+1);if(s===-1)break;r=n.indexOf(`
125
+ `,s)}if(r!==-1)t=r-(n[r-1]==="\r"?2:1)}if(t===-1){if(!this.atEnd)return this.setNext("quoted-scalar");t=this.buffer.length}return yield*this.pushToIndex(t+1,!1),this.flowLevel?"flow":"doc"}*parseBlockScalarHeader(){this.blockScalarIndent=-1,this.blockScalarKeep=!1;let e=this.pos;while(!0){let t=this.buffer[++e];if(t==="+")this.blockScalarKeep=!0;else if(t>"0"&&t<="9")this.blockScalarIndent=Number(t)-1;else if(t!=="-")break}return yield*this.pushUntil((t)=>Le(t)||t==="#")}*parseBlockScalar(){let e=this.pos-1,t=0,n;e:for(let s=this.pos;n=this.buffer[s];++s)switch(n){case" ":t+=1;break;case`
126
+ `:e=s,t=0;break;case"\r":{let o=this.buffer[s+1];if(!o&&!this.atEnd)return this.setNext("block-scalar");if(o===`
127
+ `)break}default:break e}if(!n&&!this.atEnd)return this.setNext("block-scalar");if(t>=this.indentNext){if(this.blockScalarIndent===-1)this.indentNext=t;else this.indentNext=this.blockScalarIndent+(this.indentNext===0?1:this.indentNext);do{let s=this.continueScalar(e+1);if(s===-1)break;e=this.buffer.indexOf(`
128
+ `,s)}while(e!==-1);if(e===-1){if(!this.atEnd)return this.setNext("block-scalar");e=this.buffer.length}}let r=e+1;n=this.buffer[r];while(n===" ")n=this.buffer[++r];if(n==="\t"){while(n==="\t"||n===" "||n==="\r"||n===`
129
+ `)n=this.buffer[++r];e=r-1}else if(!this.blockScalarKeep)do{let s=e-1,o=this.buffer[s];if(o==="\r")o=this.buffer[--s];let i=s;while(o===" ")o=this.buffer[--s];if(o===`
130
+ `&&s>=this.pos&&s+1+t>i)e=s;else break}while(!0);return yield rr.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 s=this.buffer[n+1];if(Le(s)||e&&Rs.has(s))break;t=n}else if(Le(r)){let s=this.buffer[n+1];if(r==="\r")if(s===`
131
131
  `)n+=1,r=`
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===`
132
+ `,s=this.buffer[n+1];else t=n;if(s==="#"||e&&Rs.has(s))break;if(r===`
133
+ `){let o=this.continueScalar(n+1);if(o===-1)break;n=Math.max(n,o-2)}}else{if(e&&Rs.has(r))break;t=n}if(!r&&!this.atEnd)return this.setNext("plain-scalar");return yield rr.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(fa),e+=yield*this.pushSpaces(!0);continue e;case"-":case"?":case":":{let t=this.flowLevel>0,n=this.charAt(1);if(Le(n)||t&&Rs.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(!Le(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(yA.has(t))t=this.buffer[++e];else if(t==="%"&&qp.has(this.buffer[e+1])&&qp.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
- `)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(`
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)}}_A.Lexer=Bp});var ga=T(function(xA){class Fp{constructor(){this.lineStarts=[],this.addNewLine=(e)=>this.lineStarts.push(e),this.linePos=(e)=>{let t=0,n=this.lineStarts.length;while(t<n){let s=t+n>>1;if(this.lineStarts[s]<e)t=s+1;else n=s}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}}}}xA.LineCounter=Fp});var va=T(function(TA){var AA=ze("process"),Kp=Cs(),$A=ma();function wt(e,t){for(let n=0;n<e.length;++n)if(e[n].type===t)return!0;return!1}function Wp(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 Yp(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 Is(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 gn(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 Ns(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 Vp(e){if(e.start.type==="flow-seq-start"){for(let t of e.items)if(t.sep&&!t.value&&!wt(t.start,"explicit-key-ind")&&!wt(t.sep,"map-value-ind")){if(t.key)t.value=t.key;if(delete t.key,Yp(t.value))if(t.value.end)Ns(t.value.end,t.sep);else t.value.end=t.sep;else Ns(t.start,t.sep);delete t.sep}}}class Jp{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 $A.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,AA.env.LOG_TOKENS)console.log("|",Kp.prettyToken(e));if(this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let t=Kp.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")Vp(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&&Wp(r.start)===-1&&(t.indent===0||r.start.every((s)=>s.type!=="comment"||s.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(Wp(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=Is(this.peek(2)),n=gn(t),r;if(e.end)r=e.end,r.push(this.sourceToken),delete e.end;else r=[this.sourceToken];let s={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]=s}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
- `,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(`
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)){Ns(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",s=[];if(r&&t.sep&&!t.value){let o=[];for(let i=0;i<t.sep.length;++i){let a=t.sep[i];switch(a.type){case"newline":o.push(i);break;case"space":break;case"comment":if(a.indent>e.indent)o.length=0;break;default:o.length=0}}if(o.length>=2)s=t.sep.splice(o[1])}switch(this.type){case"anchor":case"tag":if(r||t.value)s.push(this.sourceToken),e.items.push({start:s}),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)s.push(this.sourceToken),e.items.push({start:s,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(wt(t.start,"newline"))Object.assign(t,{key:null,sep:[this.sourceToken]});else{let o=gn(t.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:o,key:null,sep:[this.sourceToken]}]})}else if(t.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(wt(t.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:s,key:null,sep:[this.sourceToken]}]});else if(Yp(t.key)&&!wt(t.sep,"newline")){let o=gn(t.start),{key:i,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:o,key:i,sep:a}]})}else if(s.length>0)t.sep=t.sep.concat(s,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:s,key:null,sep:[this.sourceToken]});else if(wt(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 o=this.flowScalar(this.type);if(r||t.value)e.items.push({start:s,key:o,sep:[]}),this.onKeyLine=!0;else if(t.sep)this.stack.push(o);else Object.assign(t,{key:o,sep:[]}),this.onKeyLine=!0;return}default:{let o=this.startBlockValue(e);if(o){if(o.type==="block-seq"){if(!t.explicitKey&&t.sep&&!wt(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:s});this.stack.push(o);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)){Ns(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||wt(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=Is(n),s=gn(r);Vp(e);let o=e.end.splice(1,e.end.length);o.push(this.sourceToken);let i={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:s,key:e,sep:o}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=i}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(`
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(", ")}) {
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=Is(e),n=gn(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=Is(e),n=gn(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()}}}TA.Parser=Jp});var nd=T(function(jA){var Qp=ia(),EA=Qn(),sr=Xn(),OA=gi(),CA=j(),RA=ga(),Xp=va();function ed(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new RA.LineCounter||null,prettyErrors:t}}function IA(e,t={}){let{lineCounter:n,prettyErrors:r}=ed(t),s=new Xp.Parser(n?.addNewLine),o=new Qp.Composer(t),i=Array.from(o.compose(s.parse(e)));if(r&&n)for(let a of i)a.errors.forEach(sr.prettifyError(e,n)),a.warnings.forEach(sr.prettifyError(e,n));if(i.length>0)return i;return Object.assign([],{empty:!0},o.streamInfo())}function td(e,t={}){let{lineCounter:n,prettyErrors:r}=ed(t),s=new Xp.Parser(n?.addNewLine),o=new Qp.Composer(t),i=null;for(let a of o.compose(s.parse(e),!0,e.length))if(!i)i=a;else if(i.options.logLevel!=="silent"){i.errors.push(new sr.YAMLParseError(a.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}if(r&&n)i.errors.forEach(sr.prettifyError(e,n)),i.warnings.forEach(sr.prettifyError(e,n));return i}function NA(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 s=td(e,n);if(!s)return null;if(s.warnings.forEach((o)=>OA.warn(s.options.logLevel,o)),s.errors.length>0)if(s.options.logLevel!=="silent")throw s.errors[0];else s.errors=[];return s.toJS(Object.assign({reviver:r},n))}function zA(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 s=Math.round(n);n=s<1?void 0:s>8?{indent:8}:{indent:s}}if(e===void 0){let{keepUndefined:s}=n??t??{};if(!s)return}if(CA.isDocument(e)&&!r)return e.toString(n);return new EA.Document(e,r,n).toString(n)}jA.parse=NA;jA.parseAllDocuments=IA;jA.parseDocument=td;jA.stringify=zA});var Kc={};Wl(Kc,{default:()=>jE});var Wc={};Wl(Wc,{default:()=>DE});class g extends Error{reason;fix;constructor(e,t){super(e);this.reason=e;this.fix=t;this.name="TapsterError"}}class R extends g{status;constructor(e,t,n){super(e,t);this.status=n;this.name="GitHubError"}}import{existsSync as Nt,readdirSync as Jv,readFileSync as Fv}from"fs";import{basename as Ir,join as ie}from"path";var GA=ia(),HA=Qn(),ZA=qi(),ba=Xn(),qA=Dn(),_t=j(),BA=gt(),FA=J(),KA=bt(),WA=yt(),jI=Cs(),VA=ma(),YA=ga(),JA=va(),zs=nd(),rd=jn();var QA=GA.Composer,XA=HA.Document,e$=ZA.Schema,{YAMLError:t$,YAMLParseError:n$,YAMLWarning:r$}=ba,s$=qA.Alias,{isAlias:o$,isCollection:i$,isDocument:a$,isMap:Pe,isNode:c$,isPair:l$,isScalar:u$,isSeq:kt}=_t,p$=BA.Pair,d$=FA.Scalar,h$=KA.YAMLMap,f$=WA.YAMLSeq;var m$=VA.Lexer,g$=YA.LineCounter,v$=JA.Parser,{parse:Y,parseAllDocuments:b$,parseDocument:xt,stringify:y$}=zs,{visit:w$,visitAsync:_$}=rd;function ir(e){let t=Object.values(e).filter((r)=>typeof r==="number");return Object.entries(e).filter(([r,s])=>t.indexOf(+r)===-1).map(([r,s])=>s)}function wa(e,t="|"){return e.map((n)=>xa(n)).join(t)}function ar(e,t){if(typeof t==="bigint")return t.toString();return t}class sd{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 cr(e){return new sd(e)}function od(e){return e===null||e===void 0}function js(e){let t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function id(e,t){let n=e/t,r=Math.round(n),s=4*Number.EPSILON*Math.max(Math.abs(n),1);if(Math.abs(n-r)<s)return 0;return n-r}function ye(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function lr(e){let t=Object.getOwnPropertyDescriptor(e,"shape");return t?.get?t.get.raw:t?.value}function ot(e){return lr(e._zod.def)??e._zod.def.shape}function ad(e,t,n){Object.defineProperty(e,t,{get(){let r=n();return ye(this,t,r),r},enumerable:!0,configurable:!0})}function cd(e,t,n){if(t in e)ye(e,t,n);else e[t]=n}function Zt(e,t,n,r){let s=ot(t);for(let o of n){let i=Object.getOwnPropertyDescriptor(s,o);if(!i.enumerable)continue;if(i.get)ad(e,o,()=>{let a=t._zod.def.shape[o];return r?r(a,o):a});else cd(e,o,r?r(i.value,o):i.value)}}function k$(e,t){for(let n of Reflect.ownKeys(t)){let r=Object.getOwnPropertyDescriptor(t,n);if(!r.enumerable)continue;if(r.get)ad(e,n,()=>t[n]);else cd(e,n,r.value)}}function we(...e){let t={};for(let n of e){let r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function ld(e){return JSON.stringify(e)}function ud(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var _a="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function vn(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}var pd=cr(()=>{if(de.jitless)return!1;if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function qt(e){if(vn(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(vn(n)===!1)return!1;if(Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)return!1;return!0}function ka(e){if(qt(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 dd=new Set(["string","number","symbol"]);function At(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ze(e,t,n){let r=new e._zod.constr(t??e._zod.def);if(!t||n?.parent)r._zod.parent=e;return r}function E(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 xa(e){if(typeof e==="bigint")return e.toString()+"n";if(typeof e==="string")return`"${e}"`;return`${e}`}function hd(e){return Object.keys(e).filter((t)=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}var Ls=(()=>({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]}))(),Sa={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function x$(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 o={};return Zt(o,e,Ds(e,t)),Ze(e,we(n,{shape:o,checks:[]}))}function Ds(e,t){let n=ot(e),r=[];for(let s of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(n,s)?.enumerable)throw Error(`Unrecognized key: "${String(s)}"`);if(t[s])r.push(s)}return r}function S$(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 o=new Set(Ds(e,t)),i={};return Zt(i,e,Reflect.ownKeys(ot(e)).filter((a)=>!o.has(a))),Ze(e,we(n,{shape:i,checks:[]}))}function A$(e,t){if(!qt(t))throw Error("Invalid input to extend: expected a plain object");let n=e._zod.def.checks;if(n&&n.length>0){let s=ot(e);for(let o of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(s,o)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return Ze(e,we(e._zod.def,{shape:fd(e,t)}))}function fd(e,t){let n={};return Zt(n,e,Reflect.ownKeys(ot(e))),k$(n,t),n}function $$(e,t){if(!qt(t))throw Error("Invalid input to safeExtend: expected a plain object");return Ze(e,we(e._zod.def,{shape:fd(e,t)}))}function T$(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={};Zt(n,e,Reflect.ownKeys(ot(e))),Zt(n,t,Reflect.ownKeys(ot(t)));let r=we(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return Ze(e,r)}function md(e,t,n,r="partial"){let o=t._zod.def.checks;if(o&&o.length>0)throw Error(`.${r}() cannot be used on object schemas containing refinements`);let a=n?new Set(Ds(t,n)):void 0,c={};return Zt(c,t,Reflect.ownKeys(ot(t)),e&&((l,u)=>a&&!a.has(u)?l:new e({type:"optional",innerType:l}))),Ze(t,we(t._zod.def,{shape:c,checks:[]}))}function P$(e,t,n){let r=n?new Set(Ds(t,n)):void 0,s={};return Zt(s,t,Reflect.ownKeys(ot(t)),(o,i)=>r&&!r.has(i)?o:new e({type:"nonoptional",innerType:o})),Ze(t,we(t._zod.def,{shape:s}))}function Ee(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 gd(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 qe(e,t){return t.map((n)=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function or(e){return typeof e==="string"?e:e?.message}function Aa(e){let t=[];for(let n of e??[]){let r=n._zod.def;if(!/_(length|size)$|_equals$/.test(r.check))break;let s=r.maximum??r.length??r.size;if(s>=0)t.push([s,n])}return t}function Ms(e,t,n){var r;for(let s=t;s<e.length;s++)(r=e[s]).schema??(r.schema=n)}function Be(e,t,n){var r;let s=e.inst?._zod?.traits;if(s?.has("$ZodType"))if(s.has("$ZodCheck"))(r=e).schema??(r.schema=e.inst);else e.schema=e.inst;let o=e.schema!==e.inst?e.schema?._zod.def?.error:void 0,i=e.message?e.message:or(e.inst?._zod.def?.error?.(e))??or(o?.(e))??or(t?.error?.(e))??or(n.customError?.(e))??or(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=i,t?.reportInput)a.input=e.input;return a}var E$=/[\uD800-\uDBFF]/;function Us(e){let t=e.length;if(!E$.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 Gs(e){if(Array.isArray(e))return"array";if(typeof e==="string")return"string";return"unknown"}function vd(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 Bt(...e){let[t,n,r]=e;if(typeof t==="string")return{message:t,code:"custom",input:n,inst:r};return{...t}}function bd(e,t){for(let n in t){let r=Object.getOwnPropertyDescriptor(t,n);if(r.get)Object.defineProperty(e,n,{...r,enumerable:!1});else O$(e,n,r.value)}}function it(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function Hs(e,t,n){return it(e,t,n,!1)}function yd(e,t){for(let n in e){let r=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return it(this,n,r(this))},set(s){it(this,n,s)}})}return t}function O$(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:it(this,t,n.bind(this))},set(r){it(this,t,r)}})}function C$(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}var ya,St=!1,R$={configurable:!0,get(){St=!0;return}};function D(e,t,n){let r=Object.getPrototypeOf(e._zod);if(t in r&&ya!==e._zod){ya=void 0;return}ya=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,R$);let s=St;St=!1;try{let o=n(this);if(St)delete this[t];else Object.defineProperty(this,t,{configurable:!0,writable:!0,value:o});return St=St||s,o}catch(o){throw delete this[t],St=St||s,o}},set(s){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:s})}})}function I$(e,t,n,r){let s=C$(e,t);if(!s)return;Object.defineProperty(s,t,{configurable:!0,get(){let o={configurable:!0,writable:!0,enumerable:r,value:void 0};return Object.defineProperty(this,t,o),o.value=n(this),Object.defineProperty(this,t,o),o.value},set(o){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:r,value:o})}})}var N$="~constantCatch";function wd(e){let t=()=>e;return t[N$]=!0,t}var _d;var $a={value:void 0,enumerable:!1},kd="captureStackTrace"in Error?Error:null;function z$(e){let t=kd;if(t){let n=t.stackTraceLimit;if(typeof n==="number"){try{t.stackTraceLimit=0}catch{return kd=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function w(e,t,n,r){let s={};function o(d){this.def=d,this.constr=p,this.traits=new Set}o.prototype=s;let i=n,a=i&&new WeakSet;function c(d,h){if(!d._zod){$a.value=new o(h);try{Object.defineProperty(d,"_zod",$a)}finally{$a.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),v=d._zod.constr.prototype,_=m;while(_&&_!==v)_=Object.getPrototypeOf(_);let A=_??m;if(!a.has(A))a.add(A),bd(A,i)}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?z$(u):this;c(h,d);let f=h._zod.deferred;if(f){for(let v of f)v();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 Fe extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class ur extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`);this.name="ZodEncodeError"}}(_d=globalThis).__zod_globalConfig??(_d.__zod_globalConfig={});var de=globalThis.__zod_globalConfig;function _e(e){if(e)Object.assign(de,e);return de}function j$(){let e=this._zod;return e.message??(e.message=JSON.stringify(e.def,ar,2)),e.message}function L$(e){this._zod.message=e}var D$={get:j$,set:L$,enumerable:!0,configurable:!0},Pa={value:void 0,enumerable:!1},xd=new WeakSet([Object.prototype,Error.prototype]),Sd=(e,t)=>{e.name="$ZodError",Pa.value=t,Object.defineProperty(e,"issues",Pa),Pa.value=void 0,Object.defineProperty(e,"message",D$);let n=Object.getPrototypeOf(e);if(!xd.has(n))xd.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})}})},Ad=w("$ZodError",Sd),GI=w("$ZodError",Sd,void 0,{Parent:Error});function M$(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 $d(e,t=(n)=>n.message){let n={},r=[];for(let s of e.issues)if(s.path.length>0)M$(n,s.path[0],()=>[]).push(t(s));else r.push(t(s));return{formErrors:r,fieldErrors:n}}function Td(e,t=(n)=>n.message){let n={_errors:[]},r=(s,o=[])=>{for(let i of s.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map((a)=>r({issues:a},[...o,...i.path]));else if(i.code==="invalid_key")r({issues:i.issues},[...o,...i.path]);else if(i.code==="invalid_element")r({issues:i.issues},[...o,...i.path]);else{let a=[...o,...i.path];if(a.length===0)n._errors.push(t(i));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(i));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(i));c=d,l++}}}};return r(e),n}function Zs(e,t){return{callee:t?.callee??e,Err:t?.Err}}var qs=(e)=>{let t=(n,r,s,o)=>{let i=s?{...s,async:!1}:{async:!1},a=n._zod.run({value:r,issues:[]},i);if(a instanceof Promise)throw new Fe;if(a.issues.length){let c=new(o?.Err??e)(a.issues.map((l)=>Be(l,i,_e())));throw _a(c,o?.callee??t),c}return a.value};return t};var Bs=(e)=>{let t=async(n,r,s,o)=>{let i=s?{...s,async:!0}:{async:!0},a=n._zod.run({value:r,issues:[]},i);if(a instanceof Promise)a=await a;if(a.issues.length){let c=new(o?.Err??e)(a.issues.map((l)=>Be(l,i,_e())));throw _a(c,o?.callee??t),c}return a.value};return t};var Fs=(e)=>(t,n,r)=>{let s=r?{...r,async:!1}:{async:!1},o=t._zod.run({value:n,issues:[]},s);if(o instanceof Promise)throw new Fe;return o.issues.length?Pd(e,o.issues,s):{success:!0,data:o.value}};function Pd(e,t,n){let r;return{success:!1,get error(){if(!r)r=new e(t.map((s)=>Be(s,n,_e()))),t=void 0,n=void 0;return r},set error(s){r=s,t=void 0,n=void 0}}}var Ks=(e)=>async(t,n,r)=>{let s=r?{...r,async:!0}:{async:!0},o=t._zod.run({value:n,issues:[]},s);if(o instanceof Promise)o=await o;return o.issues.length?Pd(e,o.issues,s):{success:!0,data:o.value}};var U$=Symbol.for("zod.compile.invalid"),G$=Symbol.for("zod.compile.fallback"),Ea=(e,t,n)=>{let r=e._zod.bag.validator;if(r!==void 0){if(r(t)!==U$)return!0;if(r.definite===!0&&n===void 0)return!1}return H$(e,t,n)};function H$(e,t,n){let r=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},s=e._zod.bag.fallbackRun,o;if(s)r[G$]=!0,o=s({value:t,issues:[]},r);else o=e._zod.run({value:t,issues:[]},r);if(o instanceof Promise)throw new Fe;return o.issues.length===0}var Oa=async(e,t,n)=>{let r=n?{...n,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},s=e._zod.run({value:t,issues:[]},r);if(s instanceof Promise)s=await s;return s.issues.length===0},Ed=(e)=>{let t=qs(e),n=(r,s,o,i)=>{let a=o?{...o,direction:"backward"}:{direction:"backward"};return t(r,s,a,Zs(n,i))};return n};var Od=(e)=>{let t=qs(e),n=(r,s,o,i)=>t(r,s,o,Zs(n,i));return n};var Cd=(e)=>{let t=Bs(e),n=async(r,s,o,i)=>{let a=o?{...o,direction:"backward"}:{direction:"backward"};return await t(r,s,a,Zs(n,i))};return n};var Rd=(e)=>{let t=Bs(e),n=async(r,s,o,i)=>await t(r,s,o,Zs(n,i));return n};var Id=(e)=>(t,n,r)=>{let s=r?{...r,direction:"backward"}:{direction:"backward"};return Fs(e)(t,n,s)};var Nd=(e)=>(t,n,r)=>Fs(e)(t,n,r);var zd=(e)=>async(t,n,r)=>{let s=r?{...r,direction:"backward"}:{direction:"backward"};return Ks(e)(t,n,s)};var jd=(e)=>async(t,n,r)=>Ks(e)(t,n,r);var Ld=/^[cC][0-9a-z]{6,}$/,Dd=/^[0-9a-z]+$/,Md=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,Ud=/^[0-9a-vA-V]{20}$/,Gd=/^[A-Za-z0-9]{27}$/,Hd=/^[a-zA-Z0-9_-]{21}$/;function Zd(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var qd=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var Bd=/^([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})$/,Ra=(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 Fd=/^(?:[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 Z$="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function Kd(){return new RegExp(Z$,"u")}var Wd=/^(?:(?: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])$/,Vd=/^(([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 Yd=/^((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])$/,Jd=/^(([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])$/,Qd=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Xd=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/;var eh=/^https?$/,th=/^\+[1-9]\d{6,14}$/;var nh="(?:(?:\\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 q$(e){return new RegExp(`^${e}$`)}var rh=q$(nh);function Ca(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 sh(e){return new RegExp(`^${Ca(e)}$`)}function oh(e){let t=["Z"];if(e.offset)t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let n=`${Ca({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,r=e.local?`${n}|${Ca({precision:e.precision})}`:n;return new RegExp(`^${nh}T(?:${r})$`)}var ih=/^[\s\S]{0,}$/;var Ia=/^-?\d+$/,pr=/^-?\d+(?:\.\d+)?$/,ah=/^(?:true|false)$/i;var ch=/^[^A-Z]*$/,lh=/^[^a-z]*$/;var ce=w("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])});var Na=(e)=>{let t=e.value;return!od(t)&&t.length!==void 0},Ws={number:"number",bigint:"bigint",object:"date"},za=w("$ZodCheckLessThan",(e,t)=>{ce.init(e,t);let n=Ws[typeof t.value];e._zod.check=(r)=>{if(t.inclusive?r.value<=t.value:r.value<t.value)return;r.issues.push({origin:Ws[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})}}),ja=w("$ZodCheckGreaterThan",(e,t)=>{ce.init(e,t);let n=Ws[typeof t.value];e._zod.check=(r)=>{if(t.inclusive?r.value>=t.value:r.value>t.value)return;r.issues.push({origin:Ws[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})}}),uh=w("$ZodCheckMultipleOf",(e,t)=>{ce.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):id(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})}}),ph=w("$ZodCheckNumberFormat",(e,t)=>{ce.init(e,t),t.format=t.format||"float64";let n=t.format?.includes("int"),r=n?"int":"number",[s,o]=Ls[t.format];e._zod.check=(i)=>{let a=i.value;if(n){if(!Number.isInteger(a)){i.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:a,inst:e});return}if(!Number.isSafeInteger(a)){if(a>0)i.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 i.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<s)i.issues.push({origin:"number",input:a,code:"too_small",minimum:s,inclusive:!0,inst:e,continue:!t.abort});if(a>o)i.issues.push({origin:"number",input:a,code:"too_big",maximum:o,inclusive:!0,inst:e,continue:!t.abort})}});var dh=w("$ZodCheckMaxLength",(e,t)=>{var n;ce.init(e,t),(n=e._zod.def).when??(n.when=Na),e._zod.check=(r)=>{let s=r.value,o=s.length;if((typeof s==="string"&&o>t.maximum?Us(s):o)<=t.maximum)return;let a=Gs(s);r.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:s,inst:e,continue:!t.abort})}}),hh=w("$ZodCheckMinLength",(e,t)=>{var n;ce.init(e,t),(n=e._zod.def).when??(n.when=Na),e._zod.check=(r)=>{let s=r.value,o=s.length;if((typeof s==="string"&&o>=t.minimum&&o<t.minimum*2?Us(s):o)>=t.minimum)return;let a=Gs(s);r.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:s,inst:e,continue:!t.abort})}}),fh=w("$ZodCheckLengthEquals",(e,t)=>{var n;ce.init(e,t),(n=e._zod.def).when??(n.when=Na),e._zod.check=(r)=>{let s=r.value,o=s.length,i=typeof s==="string"&&o>=t.length&&o<=t.length*2?Us(s):o;if(i===t.length)return;let a=Gs(s),c=i>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})}}),hr=w("$ZodCheckStringFormat",(e,t)=>{var n,r;if(ce.init(e,t),t.pattern)(n=e._zod).check??(n.check=(s)=>{if(t.pattern.lastIndex=0,t.pattern.test(s.value))return;s.issues.push({origin:"string",code:"invalid_format",format:t.format,input:s.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})});else(r=e._zod).check??(r.check=()=>{})}),mh=w("$ZodCheckRegex",(e,t)=>{hr.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})}}),gh=w("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=ch),hr.init(e,t)}),vh=w("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=lh),hr.init(e,t)}),bh=w("$ZodCheckIncludes",(e,t)=>{ce.init(e,t);let n=At(t.includes),r=new RegExp(typeof t.position==="number"?`^.{${t.position},}${n}`:n);t.pattern=r,e._zod.check=(s)=>{if(s.value.includes(t.includes,t.position))return;s.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:s.value,inst:e,continue:!t.abort})}}),yh=w("$ZodCheckStartsWith",(e,t)=>{ce.init(e,t);let n=new RegExp(`^${At(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})}}),wh=w("$ZodCheckEndsWith",(e,t)=>{ce.init(e,t);let n=new RegExp(`.*${At(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 _h=w("$ZodCheckOverwrite",(e,t)=>{ce.init(e,t),e._zod.check=(n)=>{n.value=t.tx(n.value)}});class La{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
+ `).filter((o)=>o),r=Math.min(...n.map((o)=>o.length-o.trimStart().length)),s=n.map((o)=>o.slice(r)).map((o)=>" ".repeat(this.indent*2)+o);for(let o of s)this.content.push(o)}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)=>`
144
- let ${x}_ab = false;
145
- for (let i = 0; i < ${x}.issues.length; i++) {
146
- const iss = ${x}.issues[i];
143
+ };`)(...Object.values(this.closed))}}var xh={major:4,minor:6,patch:7};var G=w("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=xh;let r=e._zod.def.checks,s=e._zod.traits.has("$ZodCheck")?[e,...r??[]]:r?.length?[...r]:[];for(let o of s)for(let i of o._zod.onattach)i(e);if(s.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let o=(a,c,l)=>{if(a.memo)return a;let u=Ee(a),p;for(let d of c){if(d._zod.def.when){if(gd(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 Fe;if(p||f instanceof Promise)p=(p??Promise.resolve()).then(async()=>{if(await f,a.issues.length===h)return;if(Ms(a.issues,h,e),!u)u=Ee(a,h)});else{if(a.issues.length===h)continue;if(Ms(a.issues,h,e),!u)u=Ee(a,h)}}if(p)return p.then(()=>a);return a},i=(a,c,l)=>{if(Ee(a))return a.aborted=!0,a;let u=o(c,s,l);if(u instanceof Promise){if(l.async===!1)throw new Fe;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)=>i(p,a,c));return i(u,a,c)}let l=e._zod.parse(a,c);if(l instanceof Promise){if(c.async===!1)throw new Fe;return l.then((u)=>o(u,s,c))}return o(l,s,c)}}},{get "~standard"(){return Hs(this,"~standard",Ma(this))},set "~standard"(e){it(this,"~standard",e)}}),Lh=(e,t)=>e.issues.length?{issues:e.issues.map((n)=>Be(n,t,_e()))}:{value:e.value};async function B$(e,t){let n={async:!0};return Lh(await e._zod.run({value:t,issues:[]},n),n)}function Ma(e){return{validate:(t)=>{let n={async:!1};try{let r=e._zod.run({value:t,issues:[]},n);if(!(r instanceof Promise))return Lh(r,n)}catch(r){}return B$(e,t)},vendor:"zod",version:1}}var Qs=w("$ZodString",(e,t)=>{G.init(e,t),e._zod.pattern=t.pattern??ih,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch(s){}if(typeof n.value==="string")return n;return n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),H=w("$ZodStringFormat",(e,t)=>{hr.init(e,t),Qs.init(e,t)}),Dh=w("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Bd),H.init(e,t)}),Mh=w("$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=Ra(r))}else t.pattern??(t.pattern=Ra());H.init(e,t)}),Uh=w("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Fd),H.init(e,t)}),Gh=1,Ys=2;function Hh(e){try{if(typeof URL<"u"&&typeof URL.canParse==="function")return URL.canParse(e);return new URL(e),!0}catch{return!1}}function F$(e,t){if(!("normalize"in t)&&!("hostname"in t)&&!("protocol"in t))return Hh(e)||Ys;return K$(e,t)}function K$(e,t){if(!t.normalize&&t.protocol?.source===eh.source&&!/^https?:\/\//i.test(e))return Gh;try{if(typeof URL<"u"){let n=URL;if(typeof n.parse==="function")return n.parse(e)??Ys}return new URL(e)}catch{return Ys}}var W$=/[\t\n\r]/g;function Sh(e){return e.replace(W$,"")}function V$(e,t){return t.lastIndex=0,t.test(e.hostname)}function Y$(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}var Zh=w("$ZodURL",(e,t)=>{H.init(e,t),e._zod.check=(n)=>{try{let r=n.value.trim(),s=F$(r,t);if(s===Gh){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});return}if(s===Ys){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort});return}if(s===!0){n.value=Sh(r);return}if(t.hostname&&!V$(s,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&&!Y$(s,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?s.href:Sh(r);return}catch(r){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),qh=w("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Kd()),H.init(e,t)}),Bh=w("$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?Hd:Zd(t.length)),H.init(e,t)}),Fh=w("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Ld),H.init(e,t)}),Kh=w("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Dd),H.init(e,t)}),Wh=w("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Md),H.init(e,t)}),Vh=w("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Ud),H.init(e,t)}),Yh=w("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Gd),H.init(e,t)}),Jh=w("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=oh(t)),H.init(e,t)}),Qh=w("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=rh),H.init(e,t)}),Xh=w("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=sh(t)),H.init(e,t)}),ef=w("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=qd),H.init(e,t)}),tf=w("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Wd),H.init(e,t)}),J$=/^[0-9a-fA-F:.]+$/;function nf(e){if(!J$.test(e))return!1;return Hh(`http://[${e}]`)}var rf=w("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Vd),H.init(e,t),e._zod.check=(n)=>{if(!nf(n.value))n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}});var sf=w("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Yd),H.init(e,t)});function Q$(e){let t=e.split("/");if(t.length!==2)return!1;let[n,r]=t;if(!r)return!1;let s=Number(r);if(`${s}`!==r)return!1;if(s<0||s>128)return!1;return nf(n)}var of=w("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Jd),H.init(e,t),e._zod.check=(n)=>{if(!Q$(n.value))n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}});function af(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 Ua=/^[0-9a-zA-Z+/]*={0,2}$/,cf=w("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Ua),H.init(e,t),e._zod.check=(n)=>{if(af(n.value))return;n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}}),Xs=/^[A-Za-z0-9_-]*$/;function X$(e){if(!Xs.test(e))return!1;let t=e.replace(/[-_]/g,(r)=>r==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return af(n)}var lf=w("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Xs),H.init(e,t),e._zod.check=(n)=>{if(X$(n.value))return;n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),uf=w("$ZodE164",(e,t)=>{t.pattern??(t.pattern=th),H.init(e,t)});function eT(e,t=null){try{let n=e.split(".");if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let s=JSON.parse(atob(r));if("typ"in s&&s?.typ!=="JWT")return!1;if(!s.alg)return!1;if(t&&(!("alg"in s)||s.alg!==t))return!1;return!0}catch{return!1}}var pf=w("$ZodJWT",(e,t)=>{H.init(e,t),e._zod.check=(n)=>{if(eT(n.value,t.alg))return;n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}});var Ga=w("$ZodNumber",(e,t)=>{G.init(e,t),e._zod.pattern=pr,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch(i){}let s=n.value;if(typeof s==="number"&&!Number.isNaN(s)&&Number.isFinite(s))return n;let o=typeof s==="number"?Number.isNaN(s)?"NaN":!Number.isFinite(s)?String(s):void 0:void 0;return n.issues.push({expected:"number",code:"invalid_type",input:s,inst:e,...o?{received:o}:{}}),n}}),df=w("$ZodNumberFormat",(e,t)=>{ph.init(e,t),Ga.init(e,t)}),hf=w("$ZodBoolean",(e,t)=>{G.init(e,t),e._zod.pattern=ah,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Boolean(n.value)}catch(o){}let s=n.value;if(typeof s==="boolean")return n;return n.issues.push({expected:"boolean",code:"invalid_type",input:s,inst:e}),n}});var ff=w("$ZodUnknown",(e,t)=>{G.init(e,t),e._zod.parse=(n)=>n}),mf=w("$ZodNever",(e,t)=>{G.init(e,t),e._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function tT(e,t){let n=Aa(e._zod.def.checks);if(!n.length)return;let r=Math.min(...n.map((o)=>o[0])),s=e._zod.parse;e._zod.parse=(o,i)=>{let a=t(o.value);if(a>r&&!i?.skipChecks&&i?.direction!=="backward"){for(let[c,l]of Aa(e._zod.def.checks))if(a>c&&l._zod.def.when(o)){let u=o.issues.length;return l._zod.check(o),o.issues[u].continue=!1,Ms(o.issues,u,e),o}}return s(o,i)}}var nT=(e)=>Array.isArray(e)?e.length:-1;function Ah(e,t,n){if(e.issues.length)t.issues.push(...qe(n,e.issues));t.value[n]=e.value}var gf=w("$ZodArray",(e,t)=>{G.init(e,t);let n=de.memoizer;n?.attach(e),e._zod.parse=(r,s)=>{let o=r.value;if(!Array.isArray(o))return r.issues.push({expected:"array",code:"invalid_type",input:o,inst:e}),r;r.value=n?n.alloc(e,r,Array(o.length),s):Array(o.length);let i=[],a=s?.abortEarly;for(let c=0;c<o.length;c++){let l=o[c],u=t.element._zod.run({value:l,issues:[]},s);if(u instanceof Promise)i.push(u.then((p)=>Ah(p,r,c)));else if(Ah(u,r,c),a&&u.issues.length!==0&&Ee(u))break}if(i.length)return Promise.all(i).then(()=>r);return r},tT(e,nT)});function Js(e,t,n,r,s,o){let i=n in r,a=o==="optional";if(!i&&a&&s==="optional")return;if(e.issues.length){if(s!==void 0&&a&&!i)return;t.issues.push(...qe(n,e.issues))}if(!i&&s===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(i||s==="defaulted"&&!a)t.value[n]=void 0}else t.value[n]=e.value}var rT=[];function vf(e){let t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:rT,s=r.length?[...t,...r]:t;for(let i of s)if(!e.shape?.[i]?._zod?.traits?.has("$ZodType"))throw Error(`Invalid element at key "${String(i)}": expected a Zod schema`);let o=hd(e.shape);return{...e,allKeys:s,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(o)}}function bf(e,t,n,r,s,o,i){let a=[],c=s.keySet,l=s.catchall._zod,u=l.def.type,{optin:p,optout:d}=l,h=0;for(let f in t){if(i&&n.issues.length!==h){if(Ee(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((v)=>Js(v,n,f,t,p,d)));else Js(m,n,f,t,p,d)}if(a.length)n.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:o,continue:!0});if(!e.length)return n;return Promise.all(e).then(()=>n)}var sT=w("$ZodObject",(e,t)=>{G.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 s=cr(()=>vf(t));D(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))ye(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 o=vn,i=t.catchall,a,c=de.memoizer;c?.attach(e),e._zod.parse=(l,u)=>{a??(a=s.value);let p=l.value;if(!o(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 v of a.allKeys){if(f&&l.issues.length!==m){if(Ee(l,m))break;m=l.issues.length}if(v==="__proto__")continue;let _=h[v],A=_._zod.optin,y=_._zod.optout,b=_._zod.run({value:p[v],issues:[]},u);if(b instanceof Promise)d.push(b.then((k)=>Js(k,l,v,p,A,y)));else Js(b,l,v,p,A,y)}if(!i)return d.length?Promise.all(d).then(()=>l):l;return bf(d,p,l,u,s.value,e,f===!0)}}),yf=w("$ZodObjectJIT",(e,t)=>{sT.init(e,t);let n=e._zod.parse,r=cr(()=>vf(t)),s=de.memoizer,o=(h)=>{let f=r.value,m=f.symbolKeys,v=new La(["payload","ctx"],{shape:h,inst:e,memo:s,syms:m}),_=(k)=>`shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`,A=(k,S)=>`
144
+ let ${k}_ab = false;
145
+ for (let i = 0; i < ${k}.issues.length; i++) {
146
+ const iss = ${k}.issues[i];
147
147
  iss.path = iss.path ? [${S}, ...iss.path] : [${S}];
148
148
  payload.issues.push(iss);
149
- if (iss.continue !== true) ${x}_ab = true;
149
+ if (iss.continue !== true) ${k}_ab = true;
150
150
  }
151
- if (${x}_ab && ctx && ctx.abortEarly) {
151
+ if (${k}_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(`
155
- const ${S}_present = ${A};
154
+ }`;v.write("const input = payload.value;");let y=Object.create(null),b=0;for(let k of f.allKeys)y[k]=`key_${b++}`;v.write(s?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(let k of f.allKeys){if(k==="__proto__")continue;let S=y[k],O=typeof k==="symbol"?`syms[${m.indexOf(k)}]`:ld(k),x=`${O} in input`,N=h[k],pe=N?._zod?.optin,Ae=pe!==void 0,q=N?._zod?.optout==="optional";if(v.write(`const ${S} = ${_(O)};`),Ae&&q){let zt=pe==="optional"?`${S}_present`:`${S}.value !== undefined || ${S}_present`;v.write(`
155
+ const ${S}_present = ${x};
156
156
  if (!${S}.issues.length || ${S}_present) {
157
- if (${S}.issues.length) {${k(S,O)}
157
+ if (${S}.issues.length) {${A(S,O)}
158
158
  }
159
159
 
160
- if (${Tt}) {
160
+ if (${zt}) {
161
161
  newResult[${O}] = ${S}.value;
162
162
  }
163
163
  }
164
164
 
165
- `)}else if(!ke)g.write(`
166
- const ${S}_present = ${A};
167
- if (${S}.issues.length) {${k(S,O)}
165
+ `)}else if(!Ae)v.write(`
166
+ const ${S}_present = ${x};
167
+ if (${S}.issues.length) {${A(S,O)}
168
168
  }
169
169
  if (!${S}_present && !${S}.issues.length) {
170
170
  payload.issues.push({
@@ -183,17 +183,17 @@ ${t.join(`
183
183
  newResult[${O}] = ${S}.value;
184
184
  }
185
185
 
186
- `);else if(g.write(`
187
- if (${S}.issues.length) {${k(S,O)}
186
+ `);else if(v.write(`
187
+ if (${S}.issues.length) {${A(S,O)}
188
188
  }
189
- `),ce==="defaulted")g.write(`newResult[${O}] = ${S}.value;`);else g.write(`
190
- if (${S}.value !== undefined || ${A}) {
189
+ `),pe==="defaulted")v.write(`newResult[${O}] = ${S}.value;`);else v.write(`
190
+ if (${S}.value !== undefined || ${x}) {
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 v.write("payload.value = newResult;"),v.write("return payload;"),v.compile()},i,a=vn,c=!de.jitless,u=c&&pd.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(!i)i=o(t.shape);if(h=i(h,f),!p)return h;return bf([],m,h,f,d,e,f?.abortEarly===!0)}return n(h,f)}});function $h(e,t,n,r){for(let o of e)if(o.issues.length===0)return t.value=o.value,t;let s=e.filter((o)=>!Ee(o));if(s.length===1)return t.value=s[0].value,s[0];return t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map((o)=>o.issues.map((i)=>Be(i,r,_e())))}),t}var Ha=w("$ZodUnion",(e,t)=>{G.init(e,t),D(e,"optin",(r)=>r.def.options.some((s)=>s._zod.optin==="defaulted")?"defaulted":r.def.options.some((s)=>s._zod.optin!==void 0)?"optional":void 0),D(e,"optout",(r)=>r.def.options.some((s)=>s._zod.optout==="optional")?"optional":void 0),D(e,"values",(r)=>{if(r.def.options.every((s)=>s._zod.values))return new Set(r.def.options.flatMap((s)=>Array.from(s._zod.values)));return}),D(e,"pattern",(r)=>{if(r.def.options.every((s)=>s._zod.pattern)){let s=r.def.options.map((o)=>o._zod.pattern);return new RegExp(`^(${s.map((o)=>js(o.source)).join("|")})$`)}return});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,s)=>{if(n)return n(r,s);let o=!1,i=[];for(let a of t.options){let c=a._zod.run({value:r.value,issues:[]},s);if(c instanceof Promise)i.push(c),o=!0;else{if(c.issues.length===0)return c;i.push(c)}}if(!o)return $h(i,r,e,s);return Promise.all(i).then((a)=>$h(a,r,e,s))}});function oT(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 s of r)if(t.has(s)){if(s!==void 0)throw Error(`Duplicate discriminator value "${String(s)}"`);t.set(s,null)}else t.set(s,n)}return t}var wf=w("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Ha.init(e,t);let n=e._zod.parse;D(e,"propValues",(s)=>{let o={},i=0;for(let a of s.def.options){let c=a._zod.propValues;if(!c||Object.keys(c).length===0)throw Error(`Invalid discriminated union option at index "${s.def.options.indexOf(a)}"`);if(c[s.def.discriminator]?.has(void 0))i++;for(let[l,u]of Object.entries(c)){if(!Object.prototype.hasOwnProperty.call(o,l))ye(o,l,new Set);for(let p of u)o[l].add(p)}}if(!s.def.unionFallback&&i>1)o[s.def.discriminator]?.delete(void 0);return o}),t.options.forEach((s,o)=>{let i=lr(s._zod.def);if(i&&!Object.prototype.hasOwnProperty.call(i,t.discriminator))throw Error(`Invalid discriminated union option at index "${o}"`)});let r=cr(()=>oT(t));e._zod.parse=(s,o)=>{let i=s.value;if(!vn(i))return s.issues.push({code:"invalid_type",expected:"object",input:i,inst:e}),s;let a=i?.[t.discriminator],c=r.value.get(a);if(c&&(a!==void 0||o.direction!=="backward"))return c._zod.run(s,o);if(t.unionFallback||o.direction==="backward")return n(s,o);return s.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:i,path:[t.discriminator],inst:e}),s}}),_f=w("$ZodIntersection",(e,t)=>{G.init(e,t),e._zod.parse=(n,r)=>{let s=n.value,o=t.left._zod.run({value:s,issues:[]},r),i=t.right._zod.run({value:s,issues:[]},r);if(o instanceof Promise||i instanceof Promise)return Promise.all([o,i]).then(([c,l])=>Th(n,c,l));return Th(n,o,i)}});function Da(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(qt(e)&&qt(t)){let n=Object.keys(t),r=Object.keys(e).filter((o)=>n.indexOf(o)!==-1),s={...e,...t};if(Object.prototype.hasOwnProperty.call(s,"__proto__"))delete s.__proto__;for(let o of r){if(o==="__proto__")continue;let i=Da(e[o],t[o]);if(!i.valid)return{valid:!1,mergeErrorPath:[o,...i.mergeErrorPath]};s[o]=i.data}return{valid:!0,data:s}}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 s=e[r],o=t[r],i=Da(s,o);if(!i.valid)return{valid:!1,mergeErrorPath:[r,...i.mergeErrorPath]};n.push(i.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Th(e,t,n){let r=new Map,s,o=new Map,i=(l,u)=>{let p;if(l.code==="unrecognized_keys"&&!l.path?.length)s??(s=l),p=l.keys;else if(l.code==="invalid_key"&&l.origin==="record"&&l.path?.length===1){let d=String(l.path[0]);if(!o.has(d))o.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(!i(l,"l"))e.issues.push(l);for(let l of n.issues)if(!i(l,"r"))e.issues.push(l);let a=[...r].filter(([,l])=>l.l&&l.r).map(([l])=>l);if(a.length){let l=s?a.filter((u)=>s.keys.includes(u)):[];if(l.length)e.issues.push({...s,keys:l});for(let u of a)if(!l.includes(u)&&o.has(u))e.issues.push(o.get(u))}let c=Da(t.value,n.value);if(!c.valid){if(Ee(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var kf=w("$ZodTuple",(e,t)=>{G.init(e,t);let n=t.items,r=de.memoizer;r?.attach(e),e._zod.parse=(s,o)=>{let i=s.value;if(!Array.isArray(i))return s.issues.push({input:i,inst:e,expected:"tuple",code:"invalid_type"}),s;s.value=r?r.alloc(e,s,[],o):[];let a=[],c=Ph(n,"optin"),l=Ph(n,"optout");if(!t.rest){if(i.length<c)return s.issues.push({code:"too_small",minimum:c,inclusive:!0,input:i,inst:e,origin:"array"}),s;if(i.length>n.length)s.issues.push({code:"too_big",maximum:n.length,inclusive:!0,input:i,inst:e,origin:"array"})}let u=Array(n.length),p=t.rest?o?.abortEarly:void 0,d=!1;for(let h=0;h<n.length;h++){let f=n[h]._zod.run({value:i[h],issues:[]},o);if(f instanceof Promise)a.push(f.then((m)=>{u[h]=m}));else if(u[h]=f,p&&!d&&f.issues.length)d=Ee(f)}if(t.rest&&!d){let h=n.length-1,f=i.slice(n.length),m=s.issues.length;for(let v of f){if(p&&s.issues.length!==m){if(Ee(s,m))break;m=s.issues.length}h++;let _=t.rest._zod.run({value:v,issues:[]},o);if(_ instanceof Promise)a.push(_.then((A)=>Eh(A,s,h)));else Eh(_,s,h)}}if(a.length)return Promise.all(a).then(()=>Oh(u,s,n,i,l));return Oh(u,s,n,i,l)}});function Ph(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 Eh(e,t,n){if(e.issues.length)t.issues.push(...qe(n,e.issues));t.value[n]=e.value}function Oh(e,t,n,r,s){for(let o=0;o<n.length;o++){let i=e[o],a=o<r.length;if(!a&&o>=s&&n[o]._zod.optin==="optional"){t.value.length=o;break}if(i.issues.length){if(!a&&o>=s){t.value.length=o;break}t.issues.push(...qe(o,i.issues))}t.value[o]=i.value}for(let o=t.value.length-1;o>=r.length;o--)if(n[o]._zod.optout==="optional"&&t.value[o]===void 0)t.value.length=o;else break;return t}var xf=w("$ZodRecord",(e,t)=>{G.init(e,t);let n=de.memoizer;n?.attach(e),e._zod.parse=(r,s)=>{let o=r.value;if(!qt(o))return r.issues.push({expected:"record",code:"invalid_type",input:o,inst:e}),r;let i=[],a=t.keyType._zod.values;if(a&&!t.partial){r.value=n?n.alloc(e,r,{},s):{};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:[]},s);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)=>Be(f,s,_e())),input:u,path:[u],inst:e});continue}let d=p.value;if(d==="__proto__")continue;let h=t.valueType._zod.run({value:o[u],issues:[]},s);if(h instanceof Promise)i.push(h.then((f)=>{if(f.issues.length)r.issues.push(...qe(u,f.issues));r.value[d]=f.value}));else{if(h.issues.length)r.issues.push(...qe(u,h.issues));r.value[d]=h.value}}let l;for(let u in o)if(!c.has(u))if(t.mode==="loose"){if(u==="__proto__")continue;r.value[u]=o[u]}else l=l??[],l.push(u);if(l&&l.length>0)r.issues.push({code:"unrecognized_keys",input:o,inst:e,keys:l,continue:!0})}else{r.value=n?n.alloc(e,r,{},s):{};let c;for(let l of Reflect.ownKeys(o)){if(l==="__proto__")continue;if(!Object.prototype.propertyIsEnumerable.call(o,l))continue;let u=t.keyType._zod.run({value:l,issues:[]},s);if(u instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(typeof l==="string"&&pr.test(l)&&u.issues.length){let f=t.keyType._zod.run({value:Number(l),issues:[]},s);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]=o[l];else if(a)c=c??[],c.push(l);else r.issues.push({code:"invalid_key",origin:"record",issues:u.issues.map((f)=>Be(f,s,_e())),input:l,path:[l],inst:e});continue}let d=u.value;if(d==="__proto__")continue;let h=t.valueType._zod.run({value:o[l],issues:[]},s);if(h instanceof Promise)i.push(h.then((f)=>{if(f.issues.length)r.issues.push(...qe(l,f.issues));r.value[d]=f.value}));else{if(h.issues.length)r.issues.push(...qe(l,h.issues));r.value[d]=h.value}}if(c&&c.length>0)r.issues.push({code:"unrecognized_keys",input:o,inst:e,keys:c,continue:!0})}if(i.length)return Promise.all(i).then(()=>r);return r}});var Sf=w("$ZodEnum",(e,t)=>{G.init(e,t);let n=ir(t.entries),r=new Set(n);e._zod.values=r,D(e,"pattern",(s)=>{let o=ir(s.def.entries).filter((i)=>dd.has(typeof i));return new RegExp(o.length?`^(${o.map((i)=>At(i.toString())).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(s,o)=>{let i=s.value;if(r.has(i))return s;return s.issues.push({code:"invalid_value",values:n,input:i,inst:e}),s}}),Af=w("$ZodLiteral",(e,t)=>{G.init(e,t);let n=new Set(t.values);e._zod.values=n,D(e,"pattern",(r)=>{let s=r.def.values;return new RegExp(s.length?`^(${s.map((o)=>typeof o==="string"?At(o):o?At(o.toString()):String(o)).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(r,s)=>{let o=r.value;if(n.has(o))return r;return r.issues.push({code:"invalid_value",values:t.values,input:o,inst:e}),r}});var $f=w("$ZodTransform",(e,t)=>{G.init(e,t),e._zod.optin="optional",de.memoizer?.guard(e),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new ur(e.constructor.name);let s=t.transform(n.value,n);if(r.async)return(s instanceof Promise?s:Promise.resolve(s)).then((i)=>(n.value=i,n));if(s instanceof Promise)throw new Fe;return n.value=s,n}});function Ch(e,t){return e.value=t.issues.length?void 0:t.value,e}var Za=w("$ZodOptional",(e,t)=>{G.init(e,t),D(e,"optin",(n)=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",D(e,"values",(n)=>{let r=n.def.innerType._zod.values;return r?new Set([...r,void 0]):void 0}),D(e,"pattern",(n)=>{let r=n.def.innerType._zod.pattern;return r?new RegExp(`^(${js(r.source)})?$`):void 0}),e._zod.parse=(n,r)=>{if(n.value===void 0){if(t.innerType._zod.optin!=="defaulted")return n;let s=t.innerType._zod.run({value:n.value,issues:[]},r);if(s instanceof Promise)return s.then((o)=>Ch(n,o));return Ch(n,s)}return t.innerType._zod.run(n,r)}}),Tf=w("$ZodExactOptional",(e,t)=>{Za.init(e,t),D(e,"values",(n)=>n.def.innerType._zod.values),D(e,"pattern",(n)=>n.def.innerType._zod.pattern),e._zod.parse=(n,r)=>t.innerType._zod.run(n,r)}),Pf=w("$ZodNullable",(e,t)=>{G.init(e,t),D(e,"optin",(n)=>n.def.innerType._zod.optin),D(e,"optout",(n)=>n.def.innerType._zod.optout),D(e,"pattern",(n)=>{let r=n.def.innerType._zod.pattern;return r?new RegExp(`^(${js(r.source)}|null)$`):void 0}),D(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)}}),Ef=w("$ZodDefault",(e,t)=>{G.init(e,t),e._zod.optin="defaulted",D(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 s=t.innerType._zod.run(n,r);if(s instanceof Promise)return s.then((o)=>Rh(o,t));return Rh(s,t)}});function Rh(e,t){if(e.value===void 0)e.value=t.defaultValue;return e}var Of=w("$ZodPrefault",(e,t)=>{G.init(e,t),e._zod.optin="defaulted",D(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=w("$ZodNonOptional",(e,t)=>{G.init(e,t),D(e,"values",(n)=>{let r=n.def.innerType._zod.values;return r?new Set([...r].filter((s)=>s!==void 0)):void 0}),e._zod.parse=(n,r)=>{let s=t.innerType._zod.run(n,r);if(s instanceof Promise)return s.then((o)=>Ih(o,e));return Ih(s,e)}});function Ih(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 Nh(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((s)=>Be(s,r,_e()))},input:e.value}),e}var Rf=w("$ZodCatch",(e,t)=>{G.init(e,t),D(e,"optin",(n)=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),D(e,"optout",(n)=>n.def.innerType._zod.optout),D(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 s=t.innerType._zod.run({value:n.value,issues:[]},r);if(s instanceof Promise)return s.then((o)=>Nh(n,o,t,r));return Nh(n,s,t,r)}});var qa=w("$ZodPipe",(e,t)=>{G.init(e,t),D(e,"values",(n)=>n.def.in._zod.values),D(e,"optin",(n)=>n.def.in._zod.optin),D(e,"optout",(n)=>n.def.out._zod.optout),D(e,"propValues",(n)=>n.def.in._zod.propValues),e._zod.parse=(n,r)=>{if(r.direction==="backward"){let o=t.out._zod.run(n,r);if(o instanceof Promise)return o.then((i)=>Vs(i,t.in,r));return Vs(o,t.in,r)}let s=t.in._zod.run(n,r);if(s instanceof Promise)return s.then((o)=>Vs(o,t.out,r));return Vs(s,t.out,r)}});function Vs(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 If=w("$ZodPreprocess",(e,t)=>{qa.init(e,t)}),Nf=w("$ZodReadonly",(e,t)=>{G.init(e,t),D(e,"propValues",(n)=>n.def.innerType._zod.propValues),D(e,"values",(n)=>n.def.innerType._zod.values),D(e,"optin",(n)=>n.def.innerType?._zod?.optin),D(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 s=t.innerType._zod.run(n,r);if(s instanceof Promise)return s.then(zh);return zh(s)}});function zh(e){if(!e.memo)e.value=Object.freeze(e.value);return e}var zf=w("$ZodCustom",(e,t)=>{ce.init(e,t),G.init(e,t),e._zod.parse=(n,r)=>n,e._zod.check=(n)=>{let r=n.value,s=t.fn(r);if(s instanceof Promise)return s.then((o)=>jh(o,n,r,e));jh(s,n,r,e);return}});function jh(e,t,n,r){if(!e){let s={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};if(r._zod.def.params)s.params=r._zod.def.params;t.issues.push(Bt(s))}}class Lf extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform");this.name="ZodCyclicError"}}var Fa="~memo",jf=[];function Df(e){return e!==null&&typeof e==="object"}function Ba(e){return e.map((t)=>t.path?{...t,path:t.path.slice()}:{...t})}var Mf=new WeakMap,fr=0,no=1,mr=2;function ro(e,t,n){let r=Mf.get(e);if(r!==void 0)return r?mr:fr;if(t.has(e))return mr;t.add(e);let s=fr,o=(u)=>{if(s!==mr&&u?._zod){let p=ro(u,t,n);if(p>s)s=p}},i=(u,p)=>{let d=fr;for(let h of Reflect.ownKeys(u)){let f=Object.getOwnPropertyDescriptor(u,h);if(p&&!f.enumerable)continue;let m=f.get?no:f.value?._zod?ro(f.value,t,n):fr;if(m>d)d=m}return d},a=(u)=>{if(u>s)s=u},c=e._zod.def,l=c.type;switch(l){case"object":{let u=lr(c);a(u?i(u,!0):no),o(c.catchall);break}case"array":o(c.element);break;case"tuple":for(let u of c.items)o(u);o(c.rest);break;case"record":case"map":o(c.keyType),o(c.valueType);break;case"set":o(c.valueType);break;case"union":for(let u of c.options)o(u);break;case"intersection":o(c.left),o(c.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":o(c.innerType);break;case"pipe":o(c.in),o(c.out);break;case"function":o(c.input),o(c.output);break;case"lazy":{let u=c._cachedInner??(n?e._zod.innerType:void 0);a(u?ro(u,t,!1):no);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)o(d);else if(Array.isArray(d))for(let h of d)o(h)}}return t.delete(e),iT(e,s)}function iT(e,t){if(t!==no)Mf.set(e,t===mr);return t}function aT(e,t){let n=e.buckets.get(t);if(!n)n=new WeakMap,e.buckets.set(t,n);return n}var eo,to=[],cT={alloc(e,t,n){let r=eo;if(!r)return n;eo=void 0;let s={value:n,issues:null};return r.set(t.value,s),to.push(s),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let n=e._zod.parse,r=(s,o)=>{if(o.direction!=="backward"&&lT(o,s.value))throw new Lf;return n(s,o)};if(e._zod.parse=r,e._zod.run===n)e._zod.run=r})},attach(e){var t;let n,r=!1,s,o;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let i=e._zod.parse,a=(c,l)=>{if(n===void 0){let _=ro(e,new Set,!1);if(_===fr){if(e._zod.parse=i,e._zod.run===a)e._zod.run=i;return i(c,l)}if(_===mr||r)n=!0;else r=!0}let u=c.value;if(!Df(u))return i(c,l);let p=l[Fa];if(!p)p={buckets:new WeakMap,backEdges:void 0},l[Fa]=p;let d;if(s===l)d=o;else d=aT(p,e),s=l,o=d;let h=d.get(u);if(h){if(c.value=h.value,h.issues){if(h.issues.length)c.issues.push(...Ba(h.issues))}else c.memo=!0,p.backEdges??(p.backEdges=new WeakSet),p.backEdges.add(h.value);return c}eo=d;let f=to.length,m=i(c,l);eo=void 0;let v=to.length>f?to.pop():void 0;if(m instanceof Promise)return m.then((_)=>{if(v)v.issues=_.issues.length?Ba(_.issues):jf;return _});if(v)v.issues=m.issues.length?Ba(m.issues):jf;return m};if(e._zod.parse=a,e._zod.run===i)e._zod.run=a})}};function Uf(){return cT}function lT(e,t){let n=e[Fa]?.backEdges;return n!==void 0&&Df(t)&&n.has(t)}var uT=()=>{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(o){return e[o]??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 s(o,i){if(o==="number"&&typeof i==="number"&&!Number.isFinite(i))return String(i);return r[o]??o}return(o)=>{switch(o.code){case"invalid_type":{let i=s(o.expected),a=vd(o.input),c=s(a,o.input);return`Invalid input: expected ${i}, received ${c}`}case"invalid_value":if(o.values.length===1)return`Invalid input: expected ${xa(o.values[0])}`;return`Invalid option: expected one of ${wa(o.values,"|")}`;case"too_big":{let i=o.exact?"exactly ":o.inclusive?"<=":"<",a=t(o.origin);if(a)return`Too big: expected ${o.origin??"value"} to have ${i}${o.maximum.toString()} ${a.unit??"elements"}`;return`Too big: expected ${o.origin??"value"} to be ${i}${o.maximum.toString()}`}case"too_small":{let i=o.exact?"exactly ":o.inclusive?">=":">",a=t(o.origin);if(a)return`Too small: expected ${o.origin} to have ${i}${o.minimum.toString()} ${a.unit}`;return`Too small: expected ${o.origin} to be ${i}${o.minimum.toString()}`}case"invalid_format":{let i=o;if(i.format==="starts_with")return`Invalid string: must start with "${i.prefix}"`;if(i.format==="ends_with")return`Invalid string: must end with "${i.suffix}"`;if(i.format==="includes")return`Invalid string: must include "${i.includes}"`;if(i.format==="regex")return`Invalid string: must match pattern ${i.pattern}`;return`Invalid ${n[i.format]??o.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${o.divisor}`;case"unrecognized_keys":return`Unrecognized key${o.keys.length>1?"s":""}: ${wa(o.keys,", ")}`;case"invalid_key":return`Invalid key in ${o.origin}`;case"invalid_union":if(o.options&&Array.isArray(o.options)&&o.options.length>0)return`Invalid discriminator value. Expected ${o.options.map((a)=>`'${a}'`).join(" | ")}`;if(o.inclusive===!1)return"Invalid input: more than one option matched";return"Invalid input";case"invalid_element":return`Invalid value in ${o.origin}`;default:return"Invalid input"}}};function Ka(){return{localeError:uT()}}var Gf;class Hf{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 pT(){return new Hf}(Gf=globalThis).__zod_globalRegistry??(Gf.__zod_globalRegistry=pT());var Ft=globalThis.__zod_globalRegistry;function Zf(e){if(e.checks)e.checks=[...e.checks];return e}function qf(e,t){return new e(Zf({type:"string",...E(t)}))}function Bf(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...E(t)})}function Ff(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...E(t)})}function Kf(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...E(t)})}function Wf(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...E(t)})}function Vf(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...E(t)})}function Yf(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...E(t)})}function Wa(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...E(t)})}function Jf(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...E(t)})}function Qf(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...E(t)})}function Xf(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...E(t)})}function em(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...E(t)})}function tm(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...E(t)})}function nm(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...E(t)})}function rm(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...E(t)})}function sm(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...E(t)})}function om(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...E(t)})}function im(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...E(t)})}function am(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...E(t)})}function cm(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...E(t)})}function lm(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...E(t)})}function um(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...E(t)})}function pm(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...E(t)})}function dm(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...E(t)})}function hm(e,t){return new e({type:"string",format:"date",check:"string_format",...E(t)})}function fm(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...E(t)})}function mm(e,t){return new e({type:"string",format:"duration",check:"string_format",...E(t)})}function gm(e,t){return new e(Zf({type:"number",checks:[],...E(t)}))}function vm(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...E(t)})}function bm(e,t){return new e({type:"boolean",...E(t)})}function ym(e){return new e({type:"unknown"})}function wm(e,t){return new e({type:"never",...E(t)})}function so(e,t){return new za({check:"less_than",...E(t),value:e,inclusive:!1})}function gr(e,t){return new za({check:"less_than",...E(t),value:e,inclusive:!0})}function oo(e,t){return new ja({check:"greater_than",...E(t),value:e,inclusive:!1})}function vr(e,t){return new ja({check:"greater_than",...E(t),value:e,inclusive:!0})}function io(e,t){return new uh({check:"multiple_of",...E(t),value:e})}function ao(e,t){return new dh({check:"max_length",...E(t),maximum:e})}function bn(e,t){return new hh({check:"min_length",...E(t),minimum:e})}function co(e,t){return new fh({check:"length_equals",...E(t),length:e})}function Va(e,t){return new mh({check:"string_format",format:"regex",...E(t),pattern:e})}function Ya(e){return new gh({check:"string_format",format:"lowercase",...E(e)})}function Ja(e){return new vh({check:"string_format",format:"uppercase",...E(e)})}function Qa(e,t){return new bh({check:"string_format",format:"includes",...E(t),includes:e})}function Xa(e,t){return new yh({check:"string_format",format:"starts_with",...E(t),prefix:e})}function ec(e,t){return new wh({check:"string_format",format:"ends_with",...E(t),suffix:e})}function $t(e){return new _h({check:"overwrite",tx:e})}function tc(e){return $t((t)=>t.normalize(e))}function nc(){return $t((e)=>e.trim())}function rc(){return $t((e)=>e.toLowerCase())}function sc(){return $t((e)=>e.toUpperCase())}function oc(){return $t((e)=>ud(e))}function _m(e,t,n){return new e({type:"array",element:t,...E(n)})}function km(e,t,n){return new e({type:"custom",check:"custom",fn:t,...E(n)})}function xm(e,t){let n=dT((r)=>(r.addIssue=(s)=>{if(typeof s==="string")r.issues.push(Bt(s,r.value,n._zod.def));else{let o=s;if(o.fatal)o.continue=!1;if(o.code??(o.code="custom"),!("input"in o))o.input=r.value;o.inst??(o.inst=n),o.continue??(o.continue=!n._zod.def.abort),r.issues.push(Bt(o))}},e(r.value,r)),t);return n}function dT(e,t){let n=new ce({check:"custom",...E(t)});return n._zod.check=e,n}function br(e,...t){for(let n of t)for(let r of Reflect.ownKeys(n))if(Object.prototype.propertyIsEnumerable.call(n,r))ye(e,r,n[r]);return e}function wr(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??Ft,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 ne(e,t,n,r,s){let o=typeof t.unrepresentable==="function"?t.unrepresentable({zodSchema:e,path:r.path,message:s}):t.unrepresentable;if(o==="any")return!1;if(o===void 0||o==="throw")throw Error(s);return Object.assign(n,o),!0}function U(e,t,n={path:[],schemaPath:[]}){var r;let s=e._zod.def,o=t.seen.get(e);if(o){if(o.count++,n.schemaPath.includes(e))o.cycle=n.path;return o.schema}let i={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,i),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let a=e._zod.toJSONSchema?.();if(a)i.schema=a;else{let u={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,i.schema,u);else{let d=i.schema,h=t.processors[s.type];if(!h)throw Error(`[toJSONSchema]: Non-representable type encountered: ${s.type}`);h(e,t,d,u)}let p=e._zod.parent;if(p){if(!i.ref)i.ref=p;U(p,t,u),t.seen.get(p).isParent=!0}}let c=t.metadataRegistry.get(e);if(c)br(i.schema,c);if(t.io==="input"&&he(e))delete i.schema.examples,delete i.schema.default;if(t.io==="input"&&"_prefault"in i.schema)(r=i.schema).default??(r.default=i.schema._prefault);return delete i.schema._prefault,t.seen.get(e).schema}function Sm(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function _r(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 i of e.seen.entries()){let a=e.metadataRegistry.get(i[0])?.id;if(a){let c=r.get(a);if(c&&c!==i[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,i[0])}}let s=(i)=>{let a=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let p=e.external.registry.get(i[0])?.id,d=e.external.uri??((f)=>f);if(p)return{ref:d(p)};let h=i[1].defId??i[1].schema.id??`schema${e.counter++}`;return i[1].defId=h,{defId:h,ref:`${d("__shared")}#/${a}/${Sm(h)}`}}let c="#",l=`${c}/${a}/`;if(i[1]===n&&!i[1].schema.id)return{ref:c};let u=i[1].schema.id??`__schema${e.counter++}`;return{defId:u,ref:l+Sm(u)}},o=(i)=>{if(i[1].schema.$ref)return;let a=i[1],{ref:c,defId:l}=s(i);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 i of e.seen.entries()){let a=i[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 i of e.seen.entries()){let a=i[1];if(t===i[0]){o(i);continue}if(e.external){let l=e.external.registry.get(i[0])?.id;if(t!==i[0]&&l){o(i);continue}}if(e.metadataRegistry.get(i[0])?.id){o(i);continue}if(a.cycle){o(i);continue}if(a.count>1){if(e.reused==="ref")o(i)}}if(e.external)e.sharedDefsExtractedFor=e.external}function Tm(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;Tm(r);let s=Object.keys(r);if(s.length!==1||s[0]!=="type")return;let o=r.type;for(let i of Array.isArray(o)?o:[o]){if(typeof i!=="string")return;if(!n.includes(i))n.push(i)}}delete e.anyOf,e.type=n.length===1?n[0]:n}var Pm=new Set(["type","properties","required","additionalProperties"]),Am=["oneOf","anyOf"];function $m(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 ic(e){let t=[];for(let o of e){if(typeof o!=="object"||o.type!=="object")return null;for(let i in o)if(!Pm.has(i))return null;t.push(o)}let n={},r=new Set;for(let o of t){for(let i in o.properties){if(Object.prototype.hasOwnProperty.call(n,i))continue;let a=[];for(let l of t){let u=l.properties?.[i]??$m(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]:ic(a)??{allOf:a};ye(n,i,c)}for(let i of o.required??[])r.add(i)}let s={type:"object",properties:n};if(r.size)s.required=[...r];if(t.every((o)=>o.additionalProperties===!1))s.additionalProperties=!1;else{let o=[];for(let i of t){let a=$m(i);if(a&&!o.some((c)=>JSON.stringify(c)===JSON.stringify(a)))o.push(a)}if(o.length===1)s.additionalProperties=o[0];else if(o.length>1)s.additionalProperties={allOf:o}}return s}function hT(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let s of Pm)if(s in e)return;let n=t.filter((s)=>Am.some((o)=>Array.isArray(s[o]))),r=null;if(!n.length)r=ic(t);else{let s=n[0],o=Am.find((c)=>Array.isArray(s[c]));if(Object.keys(s).length!==1)return;let i=t.filter((c)=>c!==s),a=s[o].map((c)=>ic([...i,c]));if(a.some((c)=>!c))return;r={[o]:a}}if(!r)return;delete e.allOf,br(e,r)}function kr(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 br(l,f);if(br(l,u),a._zod.parent===p)for(let v in l){if(v==="$ref"||v==="allOf")continue;if(!(v in u))delete l[v]}if(f.$ref&&h.def)for(let v in l){if(v==="$ref"||v==="allOf")continue;if(v in h.def&&JSON.stringify(l[v])===JSON.stringify(h.def[v]))delete l[v]}}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())Tm(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)??[])hT(l)}}let s={};if(e.target==="draft-2020-12")s.$schema="https://json-schema.org/draft/2020-12/schema";else if(e.target==="draft-07")s.$schema="http://json-schema.org/draft-07/schema#";else if(e.target==="draft-04")s.$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");s.$id=e.external.uri(a)}br(s,n.defId?n.schema:n.def??n.schema);let o=e.metadataRegistry.get(t)?.id;if(o!==void 0&&s.id===o)delete s.id;let i=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;ye(i,c.defId,c.def)}}if(e.external)e.sharedEmitDoneFor=e.external;if(e.external);else if(Object.keys(i).length>0)if(e.target==="draft-2020-12")s.$defs=i;else s.definitions=i;try{let a=JSON.parse(JSON.stringify(s));return Object.defineProperty(a,"~standard",{value:{...t["~standard"],jsonSchema:{input:yr(t,"input",e.processors),output:yr(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch(a){throw Error("Error converting schema to JSON.")}}function he(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 he(r.element,n);if(r.type==="set")return he(r.valueType,n);if(r.type==="lazy")return he(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 he(r.innerType,n);if(r.type==="intersection")return he(r.left,n)||he(r.right,n);if(r.type==="record"||r.type==="map")return he(r.keyType,n)||he(r.valueType,n);if(r.type==="pipe"){if(e._zod.traits.has("$ZodCodec"))return!0;return he(r.in,n)||he(r.out,n)}if(r.type==="object"){for(let s in r.shape)if(he(r.shape[s],n))return!0;return!1}if(r.type==="union"){for(let s of r.options)if(he(s,n))return!0;return!1}if(r.type==="tuple"){for(let s of r.items)if(he(s,n))return!0;if(r.rest&&he(r.rest,n))return!0;return!1}return!1}var Em=(e,t={})=>(n)=>{let r=wr({...n,processors:t});return U(e,r),_r(r,e),kr(r,e)},yr=(e,t,n={})=>(r)=>{let{libraryOptions:s,target:o}=r??{},i=wr({...s??{},target:o,io:t,processors:n});return U(e,i),_r(i,e),kr(i,e)};var yn=(e,t,n)=>{if(e[t]===void 0||n>e[t])e[t]=n},wn=(e,t,n)=>{if(e[t]===void 0||n<e[t])e[t]=n},Om=(e,t)=>{yn(e,"minimum",t),wn(e,"maximum",t)},zm=(e,t)=>{if(e.multipleOf??(e.multipleOf=[]),!e.multipleOf.includes(t))e.multipleOf.push(t)},jm=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},Lm=(e,t)=>{e.mime=e.mime?e.mime.filter((n)=>t.includes(n)):[...t]},Dm=(e,t)=>{if(e.format=t,t.includes("int"))e.isInt=!0},Cm=(e,t)=>yn(e,"minimum",t.minimum),Rm=(e,t)=>wn(e,"maximum",t.maximum),Im=(e)=>(t,n)=>{Dm(t,n.format);let[r,s]=e[n.format];yn(t,"minimum",r),wn(t,"maximum",s)},fT={greater_than:(e,t)=>yn(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>wn(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>zm(e,t.value),number_format:Im(Ls),bigint_format:Im(Sa),min_length:Cm,max_length:Rm,length_equals:(e,t)=>Om(e,t.length),min_size:Cm,max_size:Rm,size_equals:(e,t)=>Om(e,t.size),string_format:(e,t)=>{if(Dm(e,t.format),t.pattern)jm(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)=>Lm(e,t.mime)};function ge(e){let t={},n=e._zod.def,r=e._zod.traits.has("$ZodCheck")?[e,...n.checks??[]]:n.checks??[];for(let o of r)fT[o._zod.def.check]?.(t,o._zod.def);let s=e._zod.bag;if(s.minimum!==void 0)yn(t,"minimum",s.minimum);if(s.exclusiveMinimum!==void 0)yn(t,"exclusiveMinimum",s.exclusiveMinimum);if(s.maximum!==void 0)wn(t,"maximum",s.maximum);if(s.exclusiveMaximum!==void 0)wn(t,"exclusiveMaximum",s.exclusiveMaximum);if(s.multipleOf!==void 0)zm(t,s.multipleOf);if(s.format!==void 0){if(t.format??(t.format=s.format),s.format.includes("int"))t.isInt=!0}if(s.mime)Lm(t,s.mime);for(let o of s.patterns??[])jm(t,o);return t}var mT={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},gT=new Map([[Ua,Qd],[Xs,Xd]]),Mm=(e)=>gT.get(e)??e,lc=(e,t,n,r)=>{let s=n;s.type="string";let{minimum:o,maximum:i,format:a,patterns:c,contentEncoding:l,laxFormat:u}=ge(e);if(typeof o==="number")s.minLength=o;if(typeof i==="number")s.maxLength=i;if(a){if(s.format=mT[a]??a,s.format==="")delete s.format;if(a==="time"||u)delete s.format}if(l)s.contentEncoding=l;if(c&&c.size>0){let p=[...c].map(Mm);if(p.length===1)s.pattern=p[0].source;else if(p.length>1)s.allOf=[...p.map((d)=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:d.source}))]}},uc=(e,t,n,r)=>{let s=n,{minimum:o,maximum:i,multipleOf:a,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=ge(e);s.type=u?"integer":"number";let p=typeof l==="number"&&l>=(o??Number.NEGATIVE_INFINITY),d=typeof c==="number"&&c<=(i??Number.POSITIVE_INFINITY),h=t.target==="draft-04"||t.target==="openapi-3.0";if(p)if(h)s.minimum=l,s.exclusiveMinimum=!0;else s.exclusiveMinimum=l;else if(typeof o==="number")s.minimum=o;if(d)if(h)s.maximum=c,s.exclusiveMaximum=!0;else s.exclusiveMaximum=c;else if(typeof i==="number")s.maximum=i;if(a){let f=new Set;for(let _ of a)if(Number.isFinite(_)&&_!==0)f.add(Math.abs(_));else ne(e,t,s,r,`A multipleOf divisor of ${_} cannot be represented in JSON Schema`);let[m,...v]=f;if(m!==void 0)s.multipleOf=m;if(v.length)s.allOf=[...s.allOf??[],...v.map((_)=>({multipleOf:_}))]}},pc=(e,t,n,r)=>{n.type="boolean"},Um=(e,t,n,r)=>{ne(e,t,n,r,"BigInt cannot be represented in JSON Schema")},Gm=(e,t,n,r)=>{ne(e,t,n,r,"Symbols cannot be represented in JSON Schema")},Hm=(e,t,n,r)=>{if(t.target==="openapi-3.0")n.type="string",n.nullable=!0,n.enum=[null];else n.type="null"},Zm=(e,t,n,r)=>{ne(e,t,n,r,"Undefined cannot be represented in JSON Schema")},qm=(e,t,n,r)=>{ne(e,t,n,r,"Void cannot be represented in JSON Schema")},dc=(e,t,n,r)=>{n.not={}},Bm=(e,t,n,r)=>{},hc=(e,t,n,r)=>{},Fm=(e,t,n,r)=>{ne(e,t,n,r,"Date cannot be represented in JSON Schema")},fc=(e,t,n,r)=>{let s=e._zod.def,o=ir(s.entries);if(o.length===0){n.not={};return}if(o.every((i)=>typeof i==="number"))n.type="number";if(o.every((i)=>typeof i==="string"))n.type="string";n.enum=o},mc=(e,t,n,r)=>{let s=e._zod.def;if(s.values.length===0){n.not={};return}let o=[];for(let i of s.values)if(i===void 0){if(ne(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof i==="bigint"){if(ne(e,t,n,r,"BigInt literals cannot be represented in JSON Schema"))return;o.push(Number(i))}else o.push(i);if(o.length===0);else if(o.length===1){let i=o[0];if(n.type=i===null?"null":typeof i,t.target==="draft-04"||t.target==="openapi-3.0")n.enum=[i];else n.const=i}else{if(o.every((i)=>typeof i==="number"))n.type="number";if(o.every((i)=>typeof i==="string"))n.type="string";if(o.every((i)=>typeof i==="boolean"))n.type="boolean";if(o.every((i)=>i===null))n.type="null";n.enum=o}},Km=(e,t,n,r)=>{ne(e,t,n,r,"NaN cannot be represented in JSON Schema")},Wm=(e,t,n,r)=>{let s=n,o=e._zod.pattern;if(!o)throw Error("Pattern not found in template literal");s.type="string",s.pattern=o.source},Vm=(e,t,n,r)=>{let s=n;s.type="string",s.format="binary",s.contentEncoding="binary";let{minimum:o,maximum:i,mime:a}=ge(e);if(o!==void 0)s.minLength=o;if(i!==void 0)s.maxLength=i;if(!a)return;if(a.length===0)s.not={};else if(a.length===1)s.contentMediaType=a[0];else s.anyOf=a.map((c)=>({contentMediaType:c}))},Ym=(e,t,n,r)=>{n.type="boolean"},gc=(e,t,n,r)=>{ne(e,t,n,r,"Custom types cannot be represented in JSON Schema")},Jm=(e,t,n,r)=>{ne(e,t,n,r,"Function types cannot be represented in JSON Schema")},vc=(e,t,n,r)=>{ne(e,t,n,r,"Transforms cannot be represented in JSON Schema")},Qm=(e,t,n,r)=>{ne(e,t,n,r,"Map cannot be represented in JSON Schema")},Xm=(e,t,n,r)=>{ne(e,t,n,r,"Set cannot be represented in JSON Schema")},bc=(e,t,n,r)=>{let s=n,o=e._zod.def,{minimum:i,maximum:a}=ge(e);if(typeof i==="number")s.minItems=i;if(typeof a==="number")s.maxItems=a;s.type="array",s.items=U(o.element,t,{...r,path:[...r.path,"items"]})};function xr(e){let t=e._zod.def;if(t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform"))return xr(t.out);if(t.type==="catch")return xr(t.innerType);return e._zod.optin}var yc=(e,t,n,r)=>{let s=n,o=e._zod.def,i=o.shape;if(Object.getOwnPropertySymbols(i).length&&ne(e,t,s,r,"Symbol keys cannot be represented in JSON Schema"))return;s.type="object",s.properties={};for(let l in i)ye(s.properties,l,U(i[l],t,{...r,path:[...r.path,"properties",l]}));let c=[];for(let l of Object.keys(i)){let u=o.shape[l];if(t.io==="input"?xr(u)===void 0:u._zod.optout===void 0)c.push(l)}if(c.length>0)s.required=c;if(o.catchall?._zod.def.type==="never")s.additionalProperties=!1;else if(!o.catchall){if(t.io==="output")s.additionalProperties=!1}else if(o.catchall)s.additionalProperties=U(o.catchall,t,{...r,path:[...r.path,"additionalProperties"]})},wc=(e,t,n,r)=>{let s=e._zod.def,o=s.inclusive===!1,i=s.options.map((a,c)=>U(a,t,{...r,path:[...r.path,o?"oneOf":"anyOf",c]}));if(o)n.oneOf=i;else n.anyOf=i},_c=(e,t,n,r)=>{let s=e._zod.def,o=U(s.left,t,{...r,path:[...r.path,"allOf",0]}),i=U(s.right,t,{...r,path:[...r.path,"allOf",1]}),a=(l)=>("allOf"in l)&&Object.keys(l).length===1,c=[...a(o)?o.allOf:[o],...a(i)?i.allOf:[i]];n.allOf=c,t.intersections.push(c)},kc=(e,t,n,r)=>{let s=n,o=e._zod.def;s.type="array";let i=t.target==="draft-2020-12"?"prefixItems":"items",a=t.target==="draft-2020-12"?"items":t.target==="openapi-3.0"?"items":"additionalItems",c=o.items.map((m,v)=>U(m,t,{...r,path:[...r.path,i,v]})),l=o.rest?U(o.rest,t,{...r,path:[...r.path,a,...t.target==="openapi-3.0"?[o.items.length]:[]]}):null,u=o.items.length;while(u>0){let m=o.items[u-1];if(!(t.io==="input"?xr(m)!==void 0:m._zod.optout==="optional"))break;u--}let p=o.items.length,d=!o.rest;if(t.target==="draft-2020-12"){if(s.prefixItems=c,d)s.items=!1;else if(l)s.items=l;if(u>0)s.minItems=u;if(d)s.maxItems=p}else if(t.target==="openapi-3.0"){if(s.items={anyOf:c},l)s.items.anyOf.push(l);if(u>0)s.minItems=u;if(d)s.maxItems=p}else{if(s.items=c,d)s.additionalItems=!1;else if(l)s.additionalItems=l;if(u>0)s.minItems=u;if(d)s.maxItems=p}let{minimum:h,maximum:f}=ge(e);if(typeof h==="number")s.minItems=h;if(typeof f==="number")s.maxItems=f};function ac(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=ac(e,f,n);return m===f?t:m}for(let f of["anyOf","oneOf"]){let m=t[f];if(!Array.isArray(m))continue;let v=m.map((_)=>ac(e,_,n));if(v.some((_,A)=>_!==m[A]))t={...t,[f]:v}}let r=Array.isArray(t.type)?t.type:[t.type],s=!r.includes("string")&&r.some((f)=>f==="number"||f==="integer"),o=t.enum??(t.const!==void 0?[t.const]:void 0);if(!s&&!o?.some((f)=>typeof f==="number"))return t;let{minimum:i,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(!s)return h;if(h.type="string",!o)h.pattern=(r.includes("number")?pr:Ia).source;return h}var cc=new WeakMap;function vT(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 cc.get(e)??[]){let s=e.seen.get(r),o=(s?.def??s?.schema)?.propertyNames;if(!o||o===!0||n.has(o))continue;let i=ac(t,o,new Set);if(i!==o)n.set(o,i)}if(!n.size)return;for(let r of e.seen.values())for(let s of[r.schema,r.def]){let o=s&&n.get(s.propertyNames);if(o)s.propertyNames=o}}var xc=(e,t,n,r)=>{let s=n,o=e._zod.def;s.type="object";let i=o.keyType,a=ge(i).patterns;if(o.mode==="loose"&&a&&a.size>0){let u=U(o.valueType,t,{...r,path:[...r.path,"patternProperties","*"]});s.patternProperties={};for(let p of a)ye(s.patternProperties,Mm(p).source,u)}else{if(t.target==="draft-07"||t.target==="draft-2020-12"){s.propertyNames=U(o.keyType,t,{...r,path:[...r.path,"propertyNames"]});let u=cc.get(t);if(!u)u=[],cc.set(t,u),t.deferred.push(()=>vT(t));u.push(e)}s.additionalProperties=U(o.valueType,t,{...r,path:[...r.path,"additionalProperties"]})}let c=i._zod.values,l=t.io==="input"&&xr(o.valueType)!==void 0;if(c&&!o.partial&&!l){let u=[...c].filter((p)=>typeof p==="string"||typeof p==="number");if(u.length>0)s.required=u.map(String)}},Sc=(e,t,n,r)=>{let s=e._zod.def,o=U(s.innerType,t,r),i=t.seen.get(e);if(t.target==="openapi-3.0")i.ref=s.innerType,n.nullable=!0;else n.anyOf=[o,{type:"null"}]},Ac=(e,t,n,r)=>{let s=e._zod.def;U(s.innerType,t,r);let o=t.seen.get(e);o.ref=s.innerType},$c=Symbol();function eg(e,t,n,r,s){let o=!1,i=JSON.stringify(e,(a,c)=>{if(typeof c!=="bigint")return c;return o=!0,null});if(!o)return JSON.parse(i);return ne(t,n,r,s,"BigInt defaults cannot be represented in JSON Schema"),$c}var Tc=(e,t,n,r)=>{let s=e._zod.def;U(s.innerType,t,r);let o=t.seen.get(e);o.ref=s.innerType;let i=eg(s.defaultValue,e,t,n,r);if(i!==$c)n.default=i},Pc=(e,t,n,r)=>{let s=e._zod.def;U(s.innerType,t,r);let o=t.seen.get(e);if(o.ref=s.innerType,t.io!=="input")return;let i=eg(s.defaultValue,e,t,n,r);if(i!==$c)n._prefault=i},Ec=(e,t,n,r)=>{let s=e._zod.def;U(s.innerType,t,r);let o=t.seen.get(e);o.ref=s.innerType;let i;try{i=s.catchValue(void 0)}catch{ne(e,t,n,r,"Dynamic catch values are not supported in JSON Schema");return}n.default=i},Oc=(e,t,n,r)=>{let s=e._zod.def,o=s.in._zod.traits.has("$ZodTransform"),i=t.io==="input"?o?s.out:s.in:s.out;U(i,t,r);let a=t.seen.get(e);a.ref=i},Cc=(e,t,n,r)=>{let s=e._zod.def;U(s.innerType,t,r);let o=t.seen.get(e);o.ref=s.innerType,n.readOnly=!0},tg=(e,t,n,r)=>{let s=e._zod.def;U(s.innerType,t,r);let o=t.seen.get(e);o.ref=s.innerType},lo=(e,t,n,r)=>{let s=e._zod.def;U(s.innerType,t,r);let o=t.seen.get(e);o.ref=s.innerType},ng=(e,t,n,r)=>{let s=e._zod.innerType;U(s,t,r);let o=t.seen.get(e);o.ref=s},Nm={string:lc,number:uc,boolean:pc,bigint:Um,symbol:Gm,null:Hm,undefined:Zm,void:qm,never:dc,any:Bm,unknown:hc,date:Fm,enum:fc,literal:mc,nan:Km,template_literal:Wm,file:Vm,success:Ym,custom:gc,function:Jm,transform:vc,map:Qm,set:Xm,array:bc,object:yc,union:wc,intersection:_c,tuple:kc,record:xc,nullable:Sc,nonoptional:Ac,default:Tc,prefault:Pc,catch:Ec,pipe:Oc,readonly:Cc,promise:tg,optional:lo,lazy:ng};function rg(e,t){if("_idmap"in e){let r=e,s=wr({...t,processors:Nm}),o={};for(let c of r._idmap.entries()){let[l,u]=c;U(u,s)}let i={},a={registry:r,uri:t?.uri,defs:o};s.external=a;for(let c of r._idmap.entries()){let[l,u]=c;_r(s,u),ye(i,l,kr(s,u))}if(Object.keys(o).length>0){let c=s.target==="draft-2020-12"?"$defs":"definitions";i.__shared={[c]:o}}return{schemas:i}}let n=wr({...t,processors:Nm});return U(e,n),_r(n,e),kr(n,e)}var sg=new WeakSet([Object.prototype,Error.prototype]);function po(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 $T=(e,t)=>{Ad.init(e,t),e.name="ZodError";let n=Object.getPrototypeOf(e);if(sg.has(n))return;sg.add(n),po(n,"format",(r)=>(s)=>Td(r,s)),po(n,"flatten",(r)=>(s)=>$d(r,s)),po(n,"addIssue",(r)=>(s)=>{r.issues.push(s),r.message=JSON.stringify(r.issues,ar,2)}),po(n,"addIssues",(r)=>(s)=>{r.issues.push(...s),r.message=JSON.stringify(r.issues,ar,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}})};var ke=w("ZodError",$T,void 0,{Parent:Error});var og=qs(ke),ig=Bs(ke),ag=Fs(ke),cg=Ks(ke),lg=Ed(ke),ug=Od(ke),pg=Cd(ke),dg=Rd(ke),hg=Id(ke),fg=Nd(ke),mg=zd(ke),gg=jd(ke);function PT(){if(!de.localeError)_e(Ka())}function Sr(){if(!de.memoizer)_e({memoizer:Uf()})}var Z=w("ZodType",(e,t)=>(PT(),G.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(we(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 Ze(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(AP(e,t))},superRefine(e,t){return this.check($P(e,t))},overwrite(e){return this.check($t(e))},optional(){return bg(this)},exactOptional(){return dP(this)},nullable(){return yg(this)},nullish(){return bg(yg(this))},nonoptional(e){return bP(this,e)},array(){return re(this)},or(e){return $g([this,e])},and(e){return aP(this,e)},transform(e){return wg(this,Tg(e))},default(e){return mP(this,e)},prefault(e){return vP(this,e)},catch(e){return wP(this,e)},pipe(e){return wg(this,e)},readonly(){return xP(this)},describe(e){let t=this.clone();return Ft.add(t,{description:e}),t},meta(...e){if(e.length===0)return Ft.get(this);let t=this.clone();return Ft.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 Hs(this,"~standard",{...Ma(this),jsonSchema:{input:yr(this,"input"),output:yr(this,"output")}})},set "~standard"(e){it(this,"~standard",e)},parse:function e(t,n){return og(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await ig(this,t,n,{callee:e})},safeParse(e,t){return ag(this,e,t)},async safeParseAsync(e,t){return cg(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){it(this,"spa",e)},validate(e,t){return Ea(this,e,t)},validateAsync(e,t){return Oa(this,e,t)},encode:function e(t,n){return lg(this,t,n,{callee:e})},decode:function e(t,n){return ug(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await pg(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await dg(this,t,n,{callee:e})},safeEncode(e,t){return hg(this,e,t)},safeDecode(e,t){return fg(this,e,t)},async safeEncodeAsync(e,t){return mg(this,e,t)},async safeDecodeAsync(e,t){return gg(this,e,t)},toJSONSchema(e){return Em(this,{})(e)},get description(){return Ft.get(this)?.description},get _def(){return this._zod.def}}),_g=w("_ZodString",(e,t)=>{Qs.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,r,s)=>lc(e,n,r,s)},yd({format:(e)=>ge(e).format??null,minLength:(e)=>ge(e).minimum??null,maxLength:(e)=>ge(e).maximum??null},{regex(...e){return this.check(Va(...e))},includes(...e){return this.check(Qa(...e))},startsWith(...e){return this.check(Xa(...e))},endsWith(...e){return this.check(ec(...e))},min(...e){return this.check(bn(...e))},max(...e){return this.check(ao(...e))},length(...e){return this.check(co(...e))},nonempty(...e){return this.check(bn(1,...e))},lowercase(e){return this.check(Ya(e))},uppercase(e){return this.check(Ja(e))},trim(){return this.check(nc())},normalize(...e){return this.check(tc(...e))},toLowerCase(){return this.check(rc())},toUpperCase(){return this.check(sc())},slugify(){return this.check(oc())}})),ET=w("ZodString",(e,t)=>{Qs.init(e,t),_g.init(e,t)},{email(e){return this.check(Bf(NT,e))},url(e){return this.check(Wa(kg,e))},jwt(e){return this.check(pm(YT,e))},emoji(e){return this.check(Jf(jT,e))},guid(e){return this.check(Ff(zT,e))},uuid(e){return this.check(Kf(ho,e))},uuidv4(e){return this.check(Wf(ho,e))},uuidv6(e){return this.check(Vf(ho,e))},uuidv7(e){return this.check(Yf(ho,e))},nanoid(e){return this.check(Qf(LT,e))},cuid(e){return this.check(Xf(DT,e))},cuid2(e){return this.check(em(MT,e))},ulid(e){return this.check(tm(UT,e))},base64(e){return this.check(cm(KT,e))},base64url(e){return this.check(lm(WT,e))},xid(e){return this.check(nm(GT,e))},ksuid(e){return this.check(rm(HT,e))},ipv4(e){return this.check(sm(ZT,e))},ipv6(e){return this.check(om(qT,e))},cidrv4(e){return this.check(im(BT,e))},cidrv6(e){return this.check(am(FT,e))},e164(e){return this.check(um(VT,e))},datetime(e){return this.check(dm(OT,e))},date(e){return this.check(hm(CT,e))},time(e){return this.check(fm(RT,e))},duration(e){return this.check(mm(IT,e))}});function P(e){return qf(ET,e)}var B=w("ZodStringFormat",(e,t)=>{H.init(e,t),_g.init(e,t)}),OT=w("ZodISODateTime",(e,t)=>{Jh.init(e,t),B.init(e,t)}),CT=w("ZodISODate",(e,t)=>{Qh.init(e,t),B.init(e,t)}),RT=w("ZodISOTime",(e,t)=>{Xh.init(e,t),B.init(e,t)}),IT=w("ZodISODuration",(e,t)=>{ef.init(e,t),B.init(e,t)}),NT=w("ZodEmail",(e,t)=>{Uh.init(e,t),B.init(e,t)});var zT=w("ZodGUID",(e,t)=>{Dh.init(e,t),B.init(e,t)});var ho=w("ZodUUID",(e,t)=>{Mh.init(e,t),B.init(e,t)});var kg=w("ZodURL",(e,t)=>{Zh.init(e,t),B.init(e,t)});function xg(e){return Wa(kg,e)}var jT=w("ZodEmoji",(e,t)=>{qh.init(e,t),B.init(e,t)});var LT=w("ZodNanoID",(e,t)=>{Bh.init(e,t),B.init(e,t)});var DT=w("ZodCUID",(e,t)=>{Fh.init(e,t),B.init(e,t)});var MT=w("ZodCUID2",(e,t)=>{Kh.init(e,t),B.init(e,t)});var UT=w("ZodULID",(e,t)=>{Wh.init(e,t),B.init(e,t)});var GT=w("ZodXID",(e,t)=>{Vh.init(e,t),B.init(e,t)});var HT=w("ZodKSUID",(e,t)=>{Yh.init(e,t),B.init(e,t)});var ZT=w("ZodIPv4",(e,t)=>{tf.init(e,t),B.init(e,t)});var qT=w("ZodIPv6",(e,t)=>{rf.init(e,t),B.init(e,t)});var BT=w("ZodCIDRv4",(e,t)=>{sf.init(e,t),B.init(e,t)});var FT=w("ZodCIDRv6",(e,t)=>{of.init(e,t),B.init(e,t)});var KT=w("ZodBase64",(e,t)=>{cf.init(e,t),B.init(e,t)});var WT=w("ZodBase64URL",(e,t)=>{lf.init(e,t),B.init(e,t)});var VT=w("ZodE164",(e,t)=>{uf.init(e,t),B.init(e,t)});var YT=w("ZodJWT",(e,t)=>{pf.init(e,t),B.init(e,t)});var Sg=w("ZodNumber",(e,t)=>{Ga.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,r,s)=>uc(e,n,r,s),e.isFinite=!0},yd({minValue:(e)=>{let{minimum:t,exclusiveMinimum:n}=ge(e);return Math.max(t??Number.NEGATIVE_INFINITY,n??Number.NEGATIVE_INFINITY)},maxValue:(e)=>{let{maximum:t,exclusiveMaximum:n}=ge(e);return Math.min(t??Number.POSITIVE_INFINITY,n??Number.POSITIVE_INFINITY)},isInt:(e)=>{let{isInt:t,multipleOf:n}=ge(e);return!!t||!!n?.some(Number.isSafeInteger)},format:(e)=>ge(e).format??null},{gt(e,t){return this.check(oo(e,t))},gte(e,t){return this.check(vr(e,t))},min(e,t){return this.check(vr(e,t))},lt(e,t){return this.check(so(e,t))},lte(e,t){return this.check(gr(e,t))},max(e,t){return this.check(gr(e,t))},int(e){return this.check(vg(e))},safe(e){return this.check(vg(e))},positive(e){return this.check(oo(0,e))},nonnegative(e){return this.check(vr(0,e))},negative(e){return this.check(so(0,e))},nonpositive(e){return this.check(gr(0,e))},multipleOf(e,t){return this.check(io(e,t))},step(e,t){return this.check(io(e,t))},finite(){return this}}));function zc(e){return gm(Sg,e)}var JT=w("ZodNumberFormat",(e,t)=>{df.init(e,t),Sg.init(e,t)});function vg(e){return vm(JT,e)}var QT=w("ZodBoolean",(e,t)=>{hf.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,r,s)=>pc(e,n,r,s)});function at(e){return bm(QT,e)}var XT=w("ZodUnknown",(e,t)=>{ff.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,r,s)=>hc(e,n,r,s)});function Rc(){return ym(XT)}var eP=w("ZodNever",(e,t)=>{mf.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,r,s)=>dc(e,n,r,s)});function tP(e){return wm(eP,e)}var nP=w("ZodArray",(e,t)=>{Sr(),gf.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,r,s)=>bc(e,n,r,s),e.element=t.element},{min(e,t){return this.check(bn(e,t))},nonempty(e){return this.check(bn(1,e))},max(e,t){return this.check(ao(e,t))},length(e,t){return this.check(co(e,t))},unwrap(){return this.element}});function re(e,t){return _m(nP,e,t)}var rP=w("ZodObject",(e,t)=>{Sr(),yf.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,r,s)=>yc(e,n,r,s),I$(e,"shape",(n)=>n._zod.def.shape,!1)},{keyof(){return Tt(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(we(this._zod.def,{catchall:e}))},passthrough(){return this.clone(we(this._zod.def,{catchall:Rc()}))},loose(){return this.clone(we(this._zod.def,{catchall:Rc()}))},strict(){return this.clone(we(this._zod.def,{catchall:tP()}))},strip(){return this.clone(we(this._zod.def,{catchall:void 0}))},extend(e){return A$(this,e)},safeExtend(e){return $$(this,e)},merge(e){return T$(this,e)},pick(e){return x$(this,e)},omit(e){return S$(this,e)},partial(...e){return md(Dc,this,e[0])},exactPartial(...e){return md(Pg,this,e[0],"exactPartial")},required(...e){return P$(Eg,this,e[0])}});function I(e,t){let n={type:"object",shape:e??{},...E(t)};return new rP(n)}var Ag=w("ZodUnion",(e,t)=>{Ha.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,r,s)=>wc(e,n,r,s),e.options=t.options});function $g(e,t){return new Ag({type:"union",options:e,...E(t)})}var sP=w("ZodDiscriminatedUnion",(e,t)=>{Ag.init(e,t),wf.init(e,t)});function oP(e,t,n){return new sP({type:"union",options:t,discriminator:e,...E(n)})}var iP=w("ZodIntersection",(e,t)=>{_f.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,r,s)=>_c(e,n,r,s)});function aP(e,t){return new iP({type:"intersection",left:e,right:t})}var cP=w("ZodTuple",(e,t)=>{Sr(),kf.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,r,s)=>kc(e,n,r,s)},{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 Dc({type:"optional",innerType:t}))})}});function jc(e,t,n){let r=t instanceof G,s=r?n:t;return new cP({type:"tuple",items:e,rest:r?t:null,...E(s)})}var Ic=w("ZodRecord",(e,t)=>{Sr(),xf.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,r,s)=>xc(e,n,r,s),e.keyType=t.keyType,e.valueType=t.valueType});function fo(e,t,n){if(!t||!t._zod)return new Ic({type:"record",keyType:P(),valueType:e,...E(t)});return new Ic({type:"record",keyType:e,valueType:t,...E(n)})}function lP(e,t,n){return new Ic({type:"record",keyType:e,valueType:t,...E(n),partial:!0})}var Nc=w("ZodEnum",(e,t)=>{Sf.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(r,s,o)=>fc(e,r,s,o),e.enum=t.entries,e.options=[...e._zod.values];let n=new Set(Object.keys(t.entries));e.extract=(r,s)=>{let o={};for(let i of r)if(n.has(i))o[i]=t.entries[i];else throw Error(`Key ${i} not found in enum`);return new Nc({...t,checks:[],...E(s),entries:o})},e.exclude=(r,s)=>{let o={...t.entries};for(let i of r)if(n.has(i))delete o[i];else throw Error(`Key ${i} not found in enum`);return new Nc({...t,checks:[],...E(s),entries:o})}});function Tt(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map((r)=>[r,r])):e;return new Nc({type:"enum",entries:n,...E(t)})}var uP=w("ZodLiteral",(e,t)=>{Af.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,r,s)=>mc(e,n,r,s),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 Lc(e,t){return new uP({type:"literal",values:Array.isArray(e)?e:[e],...E(t)})}var pP=w("ZodTransform",(e,t)=>{Sr(),$f.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,r,s)=>vc(e,n,r,s),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new ur(e.constructor.name);n.addIssue=(o)=>{if(typeof o==="string")n.issues.push(Bt(o,n.value,t));else{let i=o;if(i.fatal)i.continue=!1;if(i.code??(i.code="custom"),!("input"in i))i.input=n.value;i.inst??(i.inst=e),n.issues.push(Bt(i))}};let s=t.transform(n.value,n);if(s instanceof Promise)return s.then((o)=>(n.value=o,n));return n.value=s,n}});function Tg(e){return new pP({type:"transform",transform:e})}var Dc=w("ZodOptional",(e,t)=>{Za.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,r,s)=>lo(e,n,r,s),e.unwrap=()=>e._zod.def.innerType});function bg(e){return new Dc({type:"optional",innerType:e})}var Pg=w("ZodExactOptional",(e,t)=>{Tf.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,r,s)=>lo(e,n,r,s),e.unwrap=()=>e._zod.def.innerType});function dP(e){return new Pg({type:"optional",innerType:e})}var hP=w("ZodNullable",(e,t)=>{Pf.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,r,s)=>Sc(e,n,r,s),e.unwrap=()=>e._zod.def.innerType});function yg(e){return new hP({type:"nullable",innerType:e})}var fP=w("ZodDefault",(e,t)=>{Ef.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,r,s)=>Tc(e,n,r,s),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function mP(e,t){return new fP({type:"default",innerType:e,get defaultValue(){return typeof t==="function"?t():ka(t)}})}var gP=w("ZodPrefault",(e,t)=>{Of.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,r,s)=>Pc(e,n,r,s),e.unwrap=()=>e._zod.def.innerType});function vP(e,t){return new gP({type:"prefault",innerType:e,get defaultValue(){return typeof t==="function"?t():ka(t)}})}var Eg=w("ZodNonOptional",(e,t)=>{Cf.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,r,s)=>Ac(e,n,r,s),e.unwrap=()=>e._zod.def.innerType});function bP(e,t){return new Eg({type:"nonoptional",innerType:e,...E(t)})}var yP=w("ZodCatch",(e,t)=>{Rf.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,r,s)=>Ec(e,n,r,s),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function wP(e,t){return new yP({type:"catch",innerType:e,catchValue:typeof t==="function"?t:wd(t)})}var Og=w("ZodPipe",(e,t)=>{qa.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,r,s)=>Oc(e,n,r,s),e.in=t.in,e.out=t.out});function wg(e,t){return new Og({type:"pipe",in:e,out:t})}var _P=w("ZodPreprocess",(e,t)=>{Og.init(e,t),If.init(e,t)}),kP=w("ZodReadonly",(e,t)=>{Nf.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,r,s)=>Cc(e,n,r,s),e.unwrap=()=>e._zod.def.innerType});function xP(e){return new kP({type:"readonly",innerType:e})}var SP=w("ZodCustom",(e,t)=>{zf.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,r,s)=>gc(e,n,r,s)});function AP(e,t={}){return km(SP,e,t)}function $P(e,t){return xm(e,t)}function TP(e,t){return new _P({type:"pipe",in:Tg(e),out:t})}var PP=["iOS","iPhone","macOS"];function Et(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)&&!PP.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 Ke=/^v(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([0-9A-Za-z]+(?:\.[0-9A-Za-z]+)*))?$/;function ee(e){let t=Ke.exec(e);if(!t)return null;return{major:Number(t[1]),minor:Number(t[2]),patch:Number(t[3]),pre:t[4]??null}}function Oe(e,t){for(let s of["major","minor","patch"])if(e[s]!==t[s])return e[s]-t[s];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 s=0;s<Math.max(n.length,r.length);s++){let o=n[s],i=r[s];if(o===void 0)return-1;if(i===void 0)return 1;let a=/^\d+$/.test(o),c=/^\d+$/.test(i);if(a&&c&&Number(o)!==Number(i))return Number(o)-Number(i);if(a!==c)return a?-1:1;if(o!==i)return o<i?-1:1}return 0}var Ng=["darwin-universal","darwin-arm64","darwin-amd64","linux-arm64","linux-amd64","windows-amd64","windows-arm64"],Kt=/^[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"],Ot=P().regex(/^[A-Za-z0-9._-]+(\/[A-Za-z0-9._-]+)*$/).refine((e)=>!e.split("/").includes(".."),"must stay inside the archive"),Rg=P().regex(/^[A-Za-z0-9.-]+$/),zg={postflight:I({binary:P().regex(/^[A-Za-z0-9._-]+$/),args:re(P().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:I({launchctl:re(Rg).optional(),quit:re(Rg).optional()}).strict().optional(),zap:I({trash:re(P().regex(/^~\/[A-Za-z0-9 ._\/-]+$/))}).strict().optional(),caveats:P().min(1).max(2000).optional()},jg={name:P().regex(Kt),repo:P().regex(/^[A-Za-z0-9-]+\/[A-Za-z0-9._-]+$/),workflow:P().regex(/^[A-Za-z0-9._-]+\.ya?ml$/).default("release.yml"),assets:lP(Tt(Ng),P().regex(/^[A-Za-z0-9._{}-]+$/)),description:P().min(1).max(200).optional(),homepage:xg().optional(),license:P().regex(/^[A-Za-z0-9.+-]+$/).optional(),attestation:Tt(["auto","off"]).default("auto"),protection:Tt(["on","off","dependabot"]).default("on")},Lg=/^[A-Za-z0-9 ._-]+\.app$/,_n=/^[A-Za-z0-9-]+(\.[A-Za-z0-9-]+)+$/,EP=I({...jg,kind:Tt(["go","bun"]),binaries:re(Ot).min(1),app:I({name:P().regex(Lg),bundle_id:P().regex(_n),binaries:re(Ot).default([]),entitlements:re(Tt(Cg)).default([])}).strict().optional(),completions:I({bash:Ot.optional(),zsh:Ot.optional(),fish:Ot.optional()}).strict().optional(),scoop:at().default(!1),entitlements:re(Tt(Cg)).default([]),cask:I(zg).strict().default({}),linux:at().default(!1)}).strict(),ct=zc().int().min(0).max(5000),OP=$g([at(),P().regex(/^[A-Za-z0-9._*{}-]+$/),re(P().regex(/^[A-Za-z0-9._*{}-]+$/))]),CP=I({...jg,kind:Lc("app"),app:P().regex(Lg),bundle_id:P().regex(_n),carry:fo(P().regex(/^[A-Za-z0-9._-]+$/),P().regex(/^sha256:[0-9a-f]{64}$/)).default({}),dmg:I({name:P().regex(/^[A-Za-z0-9._{}-]+\.dmg$/),volume:P().regex(/^[A-Za-z0-9 ._-]{1,27}$/).optional(),volume_icon:Ot.optional(),layout:I({window:jc([ct,ct,ct,ct]),icon_size:ct,app:jc([ct,ct]),applications:jc([ct,ct])}).strict().optional()}).strict(),sparkle:I({key:P().regex(/^[a-z0-9]+$/),feed:P().regex(/^[A-Za-z0-9._-]+\.xml$/).default("appcast.xml"),public_key:P().regex(/^[A-Za-z0-9+/]{43}=$/),next_key:P().regex(/^[a-z0-9]+$/).optional(),next_public_key:P().regex(/^[A-Za-z0-9+/]{43}=$/).optional()}).strict().optional(),code:fo(Ot,I({identifier:P().regex(_n).optional(),entitlements:fo(P().regex(/^[A-Za-z0-9.-]+$/),OP).optional()}).strict()).default({}),cask:I({...zg,binaries:re(Ot).optional(),auto_updates:at().optional()}).strict().default({})}).strict(),Dg=TP((e)=>e&&typeof e==="object"&&!Array.isArray(e)&&!("kind"in e)?{...e,kind:"go"}:e,oP("kind",[EP,CP])),RP=I({version:Lc(1),tap:P().regex(/^[A-Za-z0-9-]+\/[a-z0-9-]+$/),linux:I({maintainer:P().regex(/^[A-Za-z0-9 .'-]+ <[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}>$/),url:xg({protocol:/^https$/}).regex(/^https:\/\/[A-Za-z0-9.-]+(\/[A-Za-z0-9._-]+)*$/).optional()}).strict().optional(),packages:re(Dg)}).strict(),X=(e)=>e.kind==="app",Mc=(e)=>(X(e)?e.cask.binaries??[]:[...e.binaries,...e.app?.binaries??[]]).map((t)=>t.split("/").pop()),mo=(e)=>X(e)||Object.keys(e.assets).some((t)=>t.startsWith("darwin")),Ig=(e)=>e.map((t)=>`${t.path.join(".")||"(root)"}: ${t.message}`).join("; ");function IP(e,t,n){if(X(e))jP(e);else if(e.app)zP(e,e.app);let r=e.cask.postflight;if(r&&!Mc(e).includes(r.binary))throw new g(`${e.name}: cask.postflight runs ${r.binary}, which the cask does not link`,`Name one of the commands the cask links: ${Mc(e).join(", ")||"none yet"}.`);if(e.repo.split("/")[0].toLowerCase()!==n.toLowerCase())throw new g(`${e.name}: ${e.repo} is not owned by ${n}`,"tapster publishes only repositories of the hub's owner.");let s=e.description===void 0?[]:Et(e.description,e.name);if(s.length)throw new g(`${e.name}: Homebrew rejects the description because ${s.join(" and ")}`,"Rewrite description in tapster.yml.");let o=Object.entries(e.assets);if(o.length===0)throw new g(`${e.name}: assets is empty`,"Map at least one platform to an asset name.");for(let[i,a]of o){if(a.replaceAll("{version}","").includes("{")||a.replaceAll("{version}","").includes("}"))throw new g(`${e.name}: ${a} uses a placeholder other than {version}`,"Only {version} is replaced in asset names.");if(i.startsWith("darwin")&&!a.endsWith(".tar.gz"))throw new g(`${e.name}: the ${i} asset must be a .tar.gz`,"Pack macOS builds as tar.gz; tapster reads them itself.")}if(X(e)&&/[{}]/.test(e.dmg.name.replaceAll("{version}","")))throw new g(`${e.name}: ${e.dmg.name} uses a placeholder other than {version}`,"Only {version} is replaced in dmg.name.");if(!X(e)&&e.scoop&&!Object.keys(e.assets).some((i)=>i.startsWith("windows-")))throw new g(`${e.name}: scoop needs a Windows asset`,"Map windows-amd64 or windows-arm64. Otherwise remove scoop: true.");if(X(e)||!e.linux)return;if(!Object.keys(e.assets).some((i)=>i.startsWith("linux-")))throw new g(`${e.name}: linux needs a Linux asset`,"Map linux-amd64 or linux-arm64. Otherwise remove linux: true.");if(!t.linux)throw new g(`${e.name} ships Linux packages, but tapster.yml names no linux.maintainer`,'Add linux: { maintainer: "Name <address>" } at the top of tapster.yml.')}function NP(e){let t=new Map,n=(i,a)=>t.has(i)||t.set(i,a);for(let[i,a]of e)if(e.filter(([l,u])=>l!==i&&u.name===a.name).length)n(i,new g(`package ${a.name} is listed twice`,"Keep one entry per package."));let r=e.flatMap(([i,a])=>Mc(a).map((c)=>({i,p:a,id:c})));for(let i of r)for(let a of r){if(i.i===a.i||i.id!==a.id||i.p.name===a.p.name)continue;n(i.i,new g(`${i.p.name} and ${a.p.name} both ship a binary named ${i.id}`,"Signed tools are identified by name, so each name may belong to one package."))}let s=(i,a)=>{let c=i.toLowerCase(),l=a.toLowerCase();return c===l||c.startsWith(`${l}.`)||l.startsWith(`${c}.`)},o=e.flatMap(([i,a])=>X(a)?[{i,name:a.name,id:a.bundle_id}]:a.app?[{i,name:a.name,id:a.app.bundle_id}]:[]);for(let i of o){for(let a of o)if(i.i!==a.i&&s(i.id,a.id))n(i.i,new g(`${i.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!==i.id.toLowerCase()&&!c.startsWith(`${i.id.toLowerCase()}.`))continue;let l=new g(`the binary ${a.id} would carry ${i.name}'s identity`,"Rename the binary.");n(i.i,l),n(a.i,l)}}return t}function ve(e,t){let n;try{n=Y(e)}catch(u){let p=u.linePos?.[0]?.line;throw new g(`tapster.yml is not valid YAML${p?` at line ${p}`:""}`,"Fix the YAML syntax there.")}let r=RP.extend({packages:re(Rc())}).safeParse(n);if(!r.success)throw new g(`tapster.yml is invalid: ${Ig(r.error.issues)}`,"Fix the listed fields.");let{packages:s,...o}=r.data,i=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"&&Kt.test(d)?d:`packages[${p}]`},l=[];for(let[u,p]of s.entries()){let d=Dg.safeParse(p);if(!d.success){i.set(u,{name:c(p,u),repo:a(p),reason:`${c(p,u)} is invalid: ${Ig(d.error.issues)}`,fix:"Fix the listed fields in tapster.yml."});continue}let h=d.data;try{IP(h,o,t),l.push([u,h])}catch(f){if(!(f instanceof g))throw f;i.set(u,{name:h.name,repo:h.repo,reason:f.reason,fix:f.fix})}}for(let[u,p]of NP(l)){let d=l.find(([h])=>h===u)[1];i.set(u,{name:d.name,repo:d.repo,reason:p.reason,fix:p.fix})}return{config:{...o,packages:l.filter(([u])=>!i.has(u)).map(([,u])=>u)},invalid:[...i.entries()].sort(([u],[p])=>u-p).map(([,u])=>u)}}function zP(e,t){let n=Object.keys(e.assets);if(!n.some((s)=>s.startsWith("darwin")))throw new g(`${e.name}: app needs a macOS archive that holds ${t.name}`,"Map a darwin-* asset or remove app.");if(n.some((s)=>s.startsWith("linux")))throw new g(`${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((s)=>s===t.name||s.startsWith(`${t.name}/`));if(r)throw new g(`${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 jP(e){if(Object.keys(e.assets).filter((n)=>n.startsWith("darwin")).length!==1||Object.keys(e.assets).length!==1)throw new g(`${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 g(`${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 g(`${e.name}: the identifier for ${n} is outside ${e.bundle_id}`,`Use an identifier that starts with ${e.bundle_id}.`)}function Mg(e,t){let[n,r]=t.split("/");return e.linux?.url??`https://${n.toLowerCase()}.github.io/${r}`}import{spawn as fE}from"child_process";import{existsSync as mE}from"fs";import*as Gg from"os";function Ar(e){if(e===null||e===void 0)return"";else if(typeof e==="string"||e instanceof String)return e;return JSON.stringify(e)}function Hg(e,t,n){let r=new Zg(e,t,n);process.stdout.write(r.toString()+Gg.EOL)}var Ug="::";class Zg{constructor(e,t,n){if(!e)e="missing.command";this.command=e,this.properties=t,this.message=n}toString(){let e=Ug+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}=${DP(r)}`}}}return e+=`${Ug}${LP(this.message)}`,e}}function LP(e){return Ar(e).replace(/%/g,"%25").replace(/\r/g,"%0D").replace(/\n/g,"%0A")}function DP(e){return Ar(e).replace(/%/g,"%25").replace(/\r/g,"%0D").replace(/\n/g,"%0A").replace(/:/g,"%3A").replace(/,/g,"%2C")}var hj=ze("net"),fj=ze("tls"),UP=ze("http"),mj=ze("https"),GP=ze("events"),gj=ze("assert"),HP=ze("util");function go(e){var t=this;t.options=e||{},t.proxyOptions=t.options.proxy||{},t.maxSockets=t.options.maxSockets||UP.Agent.defaultMaxSockets,t.requests=[],t.sockets=[],t.on("free",function(r,s,o,i){var a=qg(s,o,i);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)})}HP.inherits(go,GP.EventEmitter);go.prototype.addRequest=function(t,n,r,s){var o=this,i=Bg({request:t},o.options,qg(n,r,s));if(o.sockets.length>=this.maxSockets){o.requests.push(i);return}o.createSocket(i,function(a){a.on("free",c),a.on("close",l),a.on("agentRemove",l),t.onSocket(a);function c(){o.emit("free",a,i)}function l(u){o.removeSocket(a),a.removeListener("free",c),a.removeListener("close",l),a.removeListener("agentRemove",l)}})};go.prototype.createSocket=function(t,n){var r=this,s={};r.sockets.push(s);var o=Bg({},r.proxyOptions,{method:"CONNECT",path:t.host+":"+t.port,agent:!1,headers:{host:t.host+":"+t.port}});if(t.localAddress)o.localAddress=t.localAddress;if(o.proxyAuth)o.headers=o.headers||{},o.headers["Proxy-Authorization"]="Basic "+new Buffer(o.proxyAuth).toString("base64");Wt("making CONNECT request");var i=r.request(o);i.useChunkedEncodingByDefault=!1,i.once("response",a),i.once("upgrade",c),i.once("connect",l),i.once("error",u),i.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(i.removeAllListeners(),d.removeAllListeners(),p.statusCode!==200){Wt("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(s);return}if(h.length>0){Wt("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(s);return}return Wt("tunneling connection has established"),r.sockets[r.sockets.indexOf(s)]=d,n(d)}function u(p){i.removeAllListeners(),Wt(`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(s)}};go.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(s){r.request.onSocket(s)})};function qg(e,t,n){if(typeof e==="string")return{host:e,port:t,localAddress:n};return e}function Bg(e){for(var t=1,n=arguments.length;t<n;++t){var r=arguments[t];if(typeof r==="object"){var s=Object.keys(r);for(var o=0,i=s.length;o<i;++o){var a=s[o];if(r[a]!==void 0)e[a]=r[a]}}}return e}var Wt;if(process.env.NODE_DEBUG&&/\btunnel\b/.test(process.env.NODE_DEBUG))Wt=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 Wt=function(){};var We;(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"})(We||(We={}));var Fg;(function(e){e.Accept="accept",e.ContentType="content-type"})(Fg||(Fg={}));var Kg;(function(e){e.ApplicationJson="application/json"})(Kg||(Kg={}));var kj=[We.MovedPermanently,We.ResourceMoved,We.SeeOther,We.TemporaryRedirect,We.PermanentRedirect],xj=[We.BadGateway,We.ServiceUnavailable,We.GatewayTimeout];import{EOL as qP}from"os";import{constants as Wg,promises as BP}from"fs";var Gc=function(e,t,n,r){function s(o){return o instanceof n?o:new n(function(i){i(o)})}return new(n||(n=Promise))(function(o,i){function a(u){try{l(r.next(u))}catch(p){i(p)}}function c(u){try{l(r.throw(u))}catch(p){i(p)}}function l(u){u.done?o(u.value):s(u.value).then(a,c)}l((r=r.apply(e,t||[])).next())})},{access:FP,appendFile:KP,writeFile:WP}=BP,Vg="GITHUB_STEP_SUMMARY";class Yg{constructor(){this._buffer=""}filePath(){return Gc(this,void 0,void 0,function*(){if(this._filePath)return this._filePath;let e=process.env[Vg];if(!e)throw Error(`Unable to find environment variable for $${Vg}. Check if your runtime environment supports job summaries.`);try{yield FP(e,Wg.R_OK|Wg.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(([s,o])=>` ${s}="${o}"`).join("");if(!t)return`<${e}${r}>`;return`<${e}${r}>${t}</${e}>`}write(e){return Gc(this,void 0,void 0,function*(){let t=!!(e===null||e===void 0?void 0:e.overwrite),n=yield this.filePath();return yield(t?WP:KP)(n,this._buffer,{encoding:"utf8"}),this.emptyBuffer()})}clear(){return Gc(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(qP)}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((o)=>this.wrap("li",o)).join(""),s=this.wrap(n,r);return this.addRaw(s).addEOL()}addTable(e){let t=e.map((r)=>{let s=r.map((o)=>{if(typeof o==="string")return this.wrap("td",o);let{header:i,data:a,colspan:c,rowspan:l}=o,u=i?"th":"td",p=Object.assign(Object.assign({},c&&{colspan:c}),l&&{rowspan:l});return this.wrap(u,a,p)}).join("");return this.wrap("tr",s)}).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:s}=n||{},o=Object.assign(Object.assign({},r&&{width:r}),s&&{height:s}),i=this.wrap("img",null,Object.assign({src:e,alt:t},o));return this.addRaw(i).addEOL()}addHeading(e,t){let n=`h${t}`,r=["h1","h2","h3","h4","h5","h6"].includes(n)?n:"h1",s=this.wrap(r,e);return this.addRaw(s).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 zj=new Yg;import Qg from"os";import*as vo from"fs";var{chmod:VP,copyFile:YP,lstat:JP,mkdir:QP,open:Dj,readdir:XP,rename:eE,rm:tE,rmdir:Mj,stat:nE,symlink:rE,unlink:sE}=vo.promises,oE=process.platform==="win32";var Uj=vo.constants.O_RDONLY;var Bj=process.platform==="win32";var Yj=Qg.platform(),Jj=Qg.arch();var Xg;(function(e){e[e.Success=0]="Success",e[e.Failure=1]="Failure"})(Xg||(Xg={}));function Uc(e){Hg("add-mask",{},e)}var ev=4;var Hc=new Set;function hE(e){if(e.length<ev)return[];let t=new Set,n=(s)=>{if(s.length>=ev)t.add(s)};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 s of e.split(/\r?\n/))n(s.trim());return[...t]}function kn(e){for(let t of hE(e)){if(Hc.has(t))continue;if(Hc.add(t),process.env.GITHUB_ACTIONS==="true")Uc(t)}}function xn(e){let t=e;for(let n of[...Hc].sort((r,s)=>s.length-r.length))t=t.split(n).join("***");return t}var Ct={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"},gE=["/opt/homebrew/bin/gh","/usr/local/bin/gh","/usr/bin/gh"];function vE(e={}){return{PATH:"/usr/bin:/bin",HOME:process.env.HOME??"/tmp",TMPDIR:process.env.RUNNER_TEMP??process.env.TMPDIR??"/tmp",...e}}function bE(e,t=5){return xn(e).split(/\r?\n/).filter((n)=>n.trim()!==""&&!/keychain/i.test(n)).slice(-t).join(" | ")}function tv(e=gE){let t=e.find((n)=>mE(n));if(!t)throw new g("gh is not installed on this runner","Use a GitHub-hosted runner image, which ships gh.");return t}function Vt(e,t,n={}){return L(Ct[e],e,t,n)}function L(e,t,n,r={}){return new Promise((s,o)=>{let i=fE(e,n,{env:vE(r.env),cwd:r.cwd,shell:!1,stdio:["pipe","pipe","pipe"]}),a=[],c=[],l=0,u=null,p=(f)=>{u??=f,i.kill("SIGKILL")},d=r.timeoutMs?setTimeout(()=>p(new g(`${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 g(`${t} wrote more output than tapster reads`,"Check the input it read."));else f.push(m)};i.stdout.on("data",h(a)),i.stderr.on("data",h(c)),i.on("error",()=>o(new g(`${t} could not start`,`Check that ${e} exists on this runner.`))),i.on("close",(f)=>{if(d)clearTimeout(d);if(u){o(u);return}let m=Buffer.concat(a),v={code:f??-1,stdout:m.toString("utf8"),stderr:Buffer.concat(c).toString("utf8"),bytes:m};if(v.code!==0&&!r.allowFail){o(new g(`${t} exited with ${v.code}`,bE(v.stderr)||"No error output."));return}s(v)}),i.stdin.end(r.stdin??"")})}var yE={GIT_TERMINAL_PROMPT:"0",GIT_NO_LAZY_FETCH:"1",GIT_ALLOW_PROTOCOL:"none"},Ve=(e,t,n={})=>L(Ct.git,"git",["-C",e,...t],{env:yE,allowFail:!0,timeoutMs:n.timeoutMs??20000,maxOutput:n.maxOutput??4194304});var wE=1048576,nv=32,_E=1e5,C=(e)=>new g(`an Info.plist ${e}`,"Rebuild the app; tapster reads XML and binary property lists.");function Zc(e){if(e.length>wE)throw C("is larger than 1 MiB");if(e.subarray(0,8).toString("latin1")==="bplist00")return $E(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 AE(t)}var kE={amp:"&",lt:"<",gt:">",quot:'"',apos:"'"};function xE(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=kE[n];if(r===void 0)throw C(`uses an unknown entity ${t}`);return r})}function SE(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 s=e.slice(n+1,r).trim(),o=/^(\/)?([A-Za-z]+)(?:\s[^/]*)?(\/)?$/.exec(s);if(!o)throw C("has a tag tapster does not read");t.push({kind:o[1]?"close":o[3]?"empty":"open",name:o[2]}),n=r+1}else{let r=e.indexOf("<",n),s=e.slice(n,r===-1?e.length:r);t.push({kind:"text",text:xE(s)}),n=r===-1?e.length:r}return t}function AE(e){let t=SE(e).filter((u)=>!(u.kind==="text"&&u.text.trim()==="")),n=0,r=()=>t[n++],s=()=>t[n],o=(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}>`)}},i=(u)=>{if(u>nv)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 o("string");case"integer":{let d=o("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(o("real").trim());if(!Number.isFinite(d))throw C("has an invalid real");return d}case"date":{let d=new Date(o("date").trim());if(Number.isNaN(d.getTime()))throw C("has an invalid date");return d}case"data":return Buffer.from(o("data").replace(/\s+/g,""),"base64");case"array":{let d=[];for(;;){let h=s();if(h?.kind==="close"&&h.name==="array")return n++,d;d.push(i(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=o("key");if(Object.hasOwn(d,f))throw C(`lists the key ${f} twice`);Object.defineProperty(d,f,{value:i(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=i(1),l=r();if(!l||l.kind!=="close"||l.name!=="plist"||n!==t.length)throw C("has content after its value");return c}function $E(e){if(e.length<40)throw C("is truncated");let t=e.subarray(e.length-32),n=t[6],r=t[7],s=Number(t.readBigUInt64BE(8)),o=Number(t.readBigUInt64BE(16)),i=Number(t.readBigUInt64BE(24));if(![1,2,4,8].includes(n)||![1,2,4,8].includes(r))throw C("has a damaged trailer");if(s<1||o>=s||i<8||i+s*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>=s)throw C("has a reference outside its objects");let h=a(i+d*n,n);if(h<8||h>=i)throw C("has an object outside its body");return h},l=new Set,u=0,p=(d,h)=>{if(h>nv)throw C("is nested too deeply");if(++u>_E)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],v=m>>4,_=m&15,A=()=>{if(_!==15)return[_,f+1];let y=e[f+1];if(y>>4!==1)throw C("has a damaged length");let b=1<<(y&15);return[a(f+2,b),f+2+b]};switch(v){case 0:if(m===8)return!1;if(m===9)return!0;throw C("has an object tapster does not read");case 1:{let y=1<<_;if(y===8){if(f+9>e.length-32)throw C("is truncated");let b=e.readBigInt64BE(f+1);if(b>BigInt(Number.MAX_SAFE_INTEGER)||b<BigInt(Number.MIN_SAFE_INTEGER))throw C("has a number tapster does not read");return Number(b)}if(y>8)throw C("has a number tapster does not read");return a(f+1,y)}case 2:{if(_===2)return e.readFloatBE(f+1);if(_===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,b]=A();if(b+y>i)throw C("is truncated");return Buffer.from(e.subarray(b,b+y))}case 5:{let[y,b]=A();if(b+y>i)throw C("is truncated");return e.subarray(b,b+y).toString("latin1")}case 6:{let[y,b]=A();if(b+y*2>i)throw C("is truncated");let k=Buffer.from(e.subarray(b,b+y*2));return k.swap16(),k.toString("utf16le")}case 10:{let[y,b]=A();if(b+y*r>i)throw C("is truncated");return Array.from({length:y},(k,S)=>p(a(b+S*r,r),h+1))}case 13:{let[y,b]=A();if(b+2*y*r>i)throw C("is truncated");let k={};for(let S=0;S<y;S++){let O=p(a(b+S*r,r),h+1);if(typeof O!=="string")throw C("has a dict key that is not a string");if(Object.hasOwn(k,O))throw C(`lists the key ${O} twice`);Object.defineProperty(k,O,{value:p(a(b+(y+S)*r,r),h+1),enumerable:!0,writable:!0,configurable:!0})}return k}default:throw C("has an object tapster does not read")}}finally{l.delete(d)}};return p(o,1)}var bo=[{actor_id:5,actor_type:"RepositoryRole",bypass_mode:"always"}],TE={actor_id:null,actor_type:"DeployKey",bypass_mode:"always"},qc={name:"tapster tags",target:"tag",enforcement:"active",bypass_actors:bo,conditions:{ref_name:{include:["~ALL"],exclude:[]}},rules:[{type:"creation"},{type:"update"},{type:"deletion"}]},Bc={name:"tapster branches",target:"branch",enforcement:"active",bypass_actors:bo,conditions:{ref_name:{include:["~ALL"],exclude:[]}},rules:[{type:"creation"},{type:"update"},{type:"deletion"},{type:"non_fast_forward"}]},yo="refs/heads/dependabot/**";function PE(e,t=!1){let n=e?[...bo,TE]:bo,r={ref_name:{include:["~ALL"],exclude:t?[yo]:[]}};return[{...qc,bypass_actors:n},{...Bc,bypass_actors:n,conditions:r}]}function rv(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 sv(e,t,n,r,s,o){let i;try{i=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(i.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"&&o?[yo]:[],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)=>rv(h,s)).map((h)=>`the App or another actor can bypass ${h.name}`),p=new Set(l.filter((h)=>!rv(h,s)).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 ov(e,t,n,r,s=!1){let o=await sv(e,t,"tag",qc.rules.map((a)=>a.type),r,!1),i=await sv(e,t,"branch",Bc.rules.map((a)=>a.type),r,s);if(i.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)))i.problems.push("GitHub does not enforce rulesets on this repository; private repositories need a paid plan for them")}return{tag:o.problems,branch:i.problems}}async function Yt(e,t,n,r,s=!1){let o=await ov(e,t,n,r,s);return[...o.tag,...o.branch]}async function iv(e,t,n,r=!1,s=!1){let o;try{o=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:s};throw f}let i=await Promise.all(o.filter((f)=>f.name===qc.name||f.name===Bc.name).map((f)=>e.json("GET",`/repos/${t}/rulesets/${f.id}`))),a=r||i.some((f)=>(f.bypass_actors??[]).some((m)=>m.actor_type==="DeployKey")),c=s||i.some((f)=>(f.conditions?.ref_name?.exclude??[]).includes(yo)),l=(f)=>({status:f,deployKeys:a,dependabot:c}),u=await ov(e,t,n,"admin",c);if(u.tag.concat(u.branch).some((f)=>f.includes("offers no rulesets")))return l("unavailable");let p=a!==i.some((f)=>(f.bypass_actors??[]).some((m)=>m.actor_type==="DeployKey"))||c!==i.some((f)=>(f.conditions?.ref_name?.exclude??[]).includes(yo));if(u.tag.length+u.branch.length===0&&!p)return l("exists");let[d,h]=PE(a,c);try{for(let[f,m]of[[d,u.tag],[h,u.branch]]){if(m.length===0&&!p)continue;let v=o.find((_)=>_.name===f.name);if(v)await e.json("PUT",`/repos/${t}/rulesets/${v.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 Yt(e,t,n,"admin",c)).length===0?"created":"unavailable")}import{createPrivateKey as rO}from"crypto";import{spawn as sO}from"child_process";import{existsSync as kv,readFileSync as oO}from"fs";import{writeFile as Pr}from"fs/promises";import{delimiter as el,join as Xe}from"path";var EE={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."},OE={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 Fc(e){try{return new URL(e).pathname}catch{return"(url)"}}class fe{token;fetchImpl;sleep;who;constructor(e,t=fetch,n=(s)=>new Promise((o)=>setTimeout(o,s)),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}`,s={Accept:n.accept??"application/vnd.github+json","X-GitHub-Api-Version":"2022-11-28","User-Agent":"tapster"};if(n.auth!==!1)s.Authorization=`Bearer ${this.token}`;if(n.contentType)s["Content-Type"]=n.contentType;else if(n.body!==void 0)s["Content-Type"]="application/json";let o=n.raw??(n.body!==void 0?JSON.stringify(n.body):void 0);for(let i=0;;i++){let a;try{a=await this.fetchImpl(r,{method:e,headers:s,body:o,redirect:"manual"})}catch{if(i<4){await this.sleep(1000*2**i);continue}throw new R(`GitHub ${e} ${Fc(r)}: network error`,"GitHub did not answer; the next run retries.",0)}if((a.status>=500||a.status===429)&&i<4){await this.sleep(1000*2**i);continue}if(a.status>=400){await a.body?.cancel();let c=this.who==="user"?EE:OE;throw new R(`GitHub ${e} ${Fc(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 s=0;r.status>=300&&r.status<400;s++){let o=r.headers.get("location"),i=null;try{i=o?new URL(o):null}catch{i=null}if(s>=3||!i||i.protocol!=="https:"||i.host!=="api.github.com")throw new R(`GitHub ${e} ${Fc(t)} moved somewhere tapster does not follow`,"Update the repository name in tapster.yml.",r.status);r=await this.request(e,i.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 s=await this.request("GET",r,{auth:!1,accept:"application/octet-stream"});return Buffer.from(await s.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 CE}from"crypto";var av=(e)=>Buffer.from(e).toString("base64url");function Ye(e,t,n=Date.now()){let r=Math.floor(n/1000)-60,s=av(JSON.stringify({alg:"RS256",typ:"JWT"})),o=av(JSON.stringify({iat:r,exp:r+540,iss:e})),i=CE("RSA-SHA256").update(`${s}.${o}`).sign(t).toString("base64url"),a=`${s}.${o}.${i}`;return kn(a),a}async function wo(e,t,n,r){let s=new fe(Ye(e,t),r),o;try{o=await s.json("GET",`/users/${n}/installation`)}catch(c){if(c instanceof R&&c.status===404)return null;throw c}let{token:i}=await s.json("POST",`/app/installations/${o.id}/access_tokens`,{permissions:{metadata:"read"}});kn(i);let a=new fe(i,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 g("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 cv=`- name: Ring the tapster hub
197
197
  if: \${{ vars.TAPSTER_DOORBELL != '' }}
198
198
  continue-on-error: true
199
199
  env: { DOORBELL: "\${{ vars.TAPSTER_DOORBELL }}" }
@@ -202,7 +202,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
202
202
  token=$(curl -fsS -G --data-urlencode "audience=$DOORBELL" -H "Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" "$ACTIONS_ID_TOKEN_REQUEST_URL" | jq -r .value)
203
203
  echo "::add-mask::$token"
204
204
  curl -fsS -X POST -H "Authorization: Bearer $token" "$DOORBELL"
205
- `;var Zg=`{
205
+ `;var lv=`{
206
206
  "lockfileVersion": 2,
207
207
  "configVersion": 1,
208
208
  "workspaces": {
@@ -396,7 +396,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
396
396
  "youch-core": ["youch-core@0.3.3", "", { "dependencies": { "@poppinss/exception": "^1.2.2", "error-stack-parser-es": "^1.0.5" } }, "sha512-ho7XuGjLaJ2hWHoK8yFnsUGy2Y5uDpqSTq1FkHLK4/oqKtyUU1AFbOOxY4IpC9f0fTLjwYbslUz0Po5BpD1wrA=="],
397
397
  }
398
398
  }
399
- `;var Gg={private:!0,devDependencies:{wrangler:"4.151.1"}};var XT=`export class DoorbellError extends Error {
399
+ `;var uv={private:!0,devDependencies:{wrangler:"4.151.1"}};var jE=`export class DoorbellError extends Error {
400
400
  constructor(
401
401
  readonly status: 401 | 409 | 502,
402
402
  readonly reason: string,
@@ -492,7 +492,7 @@ export async function verifyOidc(token: string, origin: string, ownerId: string,
492
492
  if (!(exp >= now - SKEW) || !(nbf <= now + SKEW) || !(iat <= now + SKEW) || !(exp - iat <= 3600)) throw refuse("token time is off");
493
493
  return c;
494
494
  }
495
- `;var tE=`import { DoorbellError, type KeySource, jwksSource, verifyOidc } from "./jwt";
495
+ `;var DE=`import { DoorbellError, type KeySource, jwksSource, verifyOidc } from "./jwt";
496
496
 
497
497
  export type Env = { APP_ID: string; INSTALLATION_ID: string; HUB: string; HUB_ID: string; OWNER_ID: string; INTERVAL?: string; APP_KEY: string };
498
498
 
@@ -598,7 +598,7 @@ export default {
598
598
  ctx.waitUntil(tick(env, boundFetch, Math.floor(Date.now() / 1000), (line) => console.log(line)));
599
599
  },
600
600
  };
601
- `;import{randomBytes as sE}from"crypto";var gn="data:image/webp;base64,UklGRowIAABXRUJQVlA4WAoAAAAQAAAAXwAAXwAAQUxQSPUAAAARd6C2kaQ2+x7vCYnIICICUE9IY/s3w78ZkGLbVh2dZmbmVpD6MjIiCTEQCX+UMflABQ1TlBDm5F0TH6r+FtAV0f8JUPhr6ctZgp16el3x80tL/O0qVsEZsHMdw1sZ8m8jampQP6Jm2LuQ0wWnuRaoGngvMCX5kjxDb0ifrEdpwirq1LE6azmDb7VpBwNaakTLzGjlBa25ov05Wsf+PexonRXtb0FrzmjlES0zoKXatIMcbevUsTprmrCK0ifrUfJYG5KmJF+SqqS9wOmC01wLqMa5U/iU4ivSWzH+NqJUcITOteLml8m9XSn+a+nLJdGpp9cVDgBWUDggcAcAAJAgAJ0BKmAAYAA+UR6NRKOhoRY9tXQ4BQS1AzgGCB/ee/5/8jPwz+bO5P5nkZD2ds843bX+Yj9kf2Z93z0U+gB0iPoAdKF+7v7Ye2RWO+UP077gbq9qQdr/7Thr+EWT3fpuZ8LGkp0APFRz2/VPsD/rf1s/SAQZ5oTHtl5+vGqupge+ws2FsPRaD62UdfItG+n1jDbxzytDaxkYsfS4x8lyBJig6aGlb22hCpshcpjipYUza1imkCH7/l2ZjIFhBOTUiHjNyQuxrYQXfSzMNW1qzW+dlsu1I6MDyqqn7zU4iamwVEUEZv5FyU7p6Vd3Pt5gooS7O2sYSecahovpLIhR64hfvZcljfG+tM8AAP70trGbK//s2rvZwfoB//09wZcz+Cfcx4XrAXrpQJ6C6jE5BgpOcnxZ94NNLPUOQ4HzkpZyLh3++badZ9IidhzLX4r2n8RmqVxYLMZCsUfCsBh4gaG52xAAJ4KN2H4DdWmH2DbIYA3oQzXK9Osexvr9qYEMv8qPWnBnq8nAuaL7WKQ187LR/6cONyjd9mVdTUP16wap5lgEINV1rSgcICC0OkPfqub61tJlCjn8uh0cXVNKOSx8W9AeuB9dFZSMBJa++eYv+YTIYyGHTpI04pjOpIDq3AOqPYESwBhWE9A42ImX8x6VtXYVOmwv8lW41Vgj09tdrrcZW1DZvWWGvOoIuk/rgKYrNbIx3qS48b+WBGqI50gCeoBcvIxNGUXBgfHz5rvFiKgBBT9jJzd8QC104TXXDX3YslDeVhutM/CEVJ7qO9mLcA0YwRhtkjMiOen7bo9hTRao1/KGhCsS/e4tYJMdRJjNYKsZ+Kp540o7pJM7zIhx5E+BN2oZjElAPt8O6koCFZsFT8W+Y2SvoBneW9Vk9O/6mQz4bmauo8KWSyQNUCGAIWMsE7iWA+kt4RsWAl+gw0V+01q5W5TI4PA2Kx8juMUKTsPInerJyWvSZcNxVLwG3+5dbicBchRRlYSKukU2Jp4ZVDe7I2fnLJ+UIOEomr9p+CBlPQARIxKHmaXm5V9a0+m7Cw/kpNojQus6JnAg86e/ianKAk5BhIisTy0pyIjUrBya7MJDsZH/v/DaPm7QFNK9hgzybPRJEY6KuL7bwQHVQ0jcboqu/tQvI+mhsDNz2K2tNCNOcMCA8HWf+pwu0GaQgSajBefemZ6reFjnoc1LBgmrFHFyyflxua7ool5jW9/r9hjxKVxHxs3o3F5Kc+vV/mdHDj50DHL+9duz30i+Jf82JCXGMbp7+FjGKhzcGyarYjXbiPFFl1Be4iW8OEVyWe7H241eXMl/qp5y5Q8B2dBYymhibQNm5UPgyzuM155RLLPrnrnc3xSPFbqv9fl7j5bSrdzwBZ8DjnI0dcr5UDCNGGZkglw5FB2rgioiB7jYrrnPfGrfuvrsAH0GodU+o0erjag24oZX6Sam8/LPLY8EiCVWAQMG6r5sTCO/idTDXTuMcAkBgzVgphSyUmDTduYey7e2NtCgoWS5wdflZstX4FceW4AVoWWuAOU+xs1jI9C7yCqQ+IMHeJjmB1qFaBGy4z14f5Y7tK6u57xfo7bCBu61laMUi+5mBj4Ba3kuu6YrskddXtCDx9z9cvgNTjJDgKdfDk/df4MCI49ZGVmOeTQ0Z9tt09gfxHuqiGCGmKYZzmeaA7dy2dHc8VbIAbfp0JKwq3RDugIs0J6AdPhFmM84ci3/NV0xDACfDfZcd8t3is54tH+5YGhIGswMHwYGo8VAHM8p+ORY7zU0zJdhF1/y8xEsp/hNm7ukLLZZN9qKY7OAX9uQCc0Ww0j8lEJMgBsUlMy8r7gBif1ipeFRE//+P9zTMtS9Qonr/60Dp8R3/quzj4Jslgk92itTQdNH3iPVCLA2aJT1L8cKf3ft1LyBsKJI4RPDrV9i5v+Ym9+CltyZq3JKlFVgAfrb3dawijRMdvj1x1y73VR6gzLFjyVv/sOtb6b+6K2JGHmnVIRmaw51s8qg9s1KxNdYetYQfGuG/0+M4ZqdGRzuDFTnoNmUz2QPjkXnF3cyguivLl3y+Lm+BmR5j1Ya1Uj0govN2frgHKjQjvWj5wwZFPFbyruAplSrHUAJQNqXZK6RQSpUOSi6JOGoXak2pTlPbQWayU3Ktn4HKXn0jW/HJxX7y9aHwuukGIVKGOzEVBTiB5HQ4hxfL+DZsNeViPXYmYJcQwZc01C/kXkVBxWpOy9Trs66Tr6k5aHmVSdHO8adOlCg2wEgbzREaX+7VfDTl0nI2YIN8w6KkwupCrkbBsPrWtkCYBeuEGFmKeZnf7KhveiRPinbtnmNAPcln00zDbiLs2Lbe6G0BMvfZIoORkHFoAzgqMYpHtMB1Vwrm+QYFcoOcQumhppN8dnidf78TWLer4Zf9DfMfVIyuMon+1lbhH5hDoSNQ/ChJH4bArnAZL9ODY8B/r4neoNTwEuZHNzVoqV/hRvSZYzs9bvRFMFdllnZXDFpCFvyJ8jdJ1PspW7B9XIilKsDMBmPs0BL3rPoQErXAAAA",us="data:image/webp;base64,UklGRqQeAABXRUJQVlA4WAoAAAAQAAAAZwEAZwEAQUxQSJgDAAARCjqybbuNqweiGkj0jbyUOvIbuQgxC1GnzGRYmAFTRsiRcQCs4jQ4gs45CPkYKateQAfzIJxvcd69ETEBdGN4ezzN8vV297Hc256opey4zrPp+HZofgxvvcg2X2zPpcqLW912O12VvjfrKpVuGk2W323vVuGoY4LfC9vbC2F3PFjYnq/SCUGytQBkErjualZaEOqMLosyC0WJXBW+tXB8K05K9xaQmrrnyY0HJZ+4Jc4tMDV2SGLBmbgiKiw8i8gJk9ICVOmAuQXpvG3xxsJU41Y9/miBKmzRGw9Wtubaw5UtyTxgpRULD1ltwdKDVhonHrbSMPXA1UZlHrrSoGsPXjbmjYcvG/LYA5iNiD8iSOImbCyEtQFzC+J5bRMLY9YUlTjSqJ7CArmoJbFQTmqILZjj6nI0aWVPPJxZ1Q2eWFHqAa2VhHtEqVTx1kL6bQWRBXV0WYYquejKw5qXzHClFwQlrpTnJRbYyXlbZPGsBx7acs4CW3pG4MHNU7+jS04V6CpOjCy8R8cm+OKxJb7k2Hd86ZHbHuBykCJMD1YI04MSYUryloe4kC8wRsMMY0JuMKbkF4zRhB7kchtlMkaZTlE2zVAmOcp0jbL1FmXcoWz3EWVSokz3KFM/+H/w/+D/wf+D/wf/D/4f/D/4f/D/4P/B/4P/B/8P/h/8P/j/vz8VZVqiTAVlskPZjijjGmXrHGWaoUymKJuOUaa3USYhysR8wRgNNxhTMsOYkC8wRsNbGBOSJcKUJFcI04MUYXpwG2FywO/4Uh5d4kuOTfDFYyN8jY6xQFfBk7+jS04F6OIpLrClPPMBtuQcbpFFc3aCrOS8oMSV8jzOcKW88ApXvIQZqoQXR6iKLuNbTL1lheEeUSpVMEWUstobPNFU/ARPrIo5mpSVx2iKq2OCpYR1FkgqWGtU4kijejjBEU3dcxTNWf8GQ8oGxh8RJHET+BhBNM18gx+apl6jh6a5GXaETV4gR9nsJW6ETRfUCJuvmFG2MUOMsJ3XeKFp6xu00LT38UekCE2b4w1ONGbL5yiZs/2TEiFK48KowEcR0ZEJOhK6M86RoTGd+uQGFXxinJvuEaEpXRy+xcNboaOjDAsS0eFXsxIFOqNxfJBsEcAkMF34YNH3VNiZwe9FfyuEpltHk+X3/qXCkenk2+mq7E+6SoWdfutFtvnSd6jy4pb5MQxvj6dZvt7uPpb7vqCl7LjOs+n4dmjcCFZQOCDmGgAAcJcAnQEqaAFoAT5tNpdIpCMiJCSTCSiADYllbvGALXqNzACijUqXk0Wm07e87qnWF6f+984PYvmk9K+b//r+rP9QewR+svT38zfnJf8D9pPfJ/efUW/uP/A61L0C/259PP2bv7Z/3PSV1QExq6YwCPafC5D75RP1Yx6HiO+79g+wl0uRn7uwevJYFxyd1XE1Edf/cXmY5/8ym/s587lniL9JNao71PqB5+xWOr/uWkKE+nwMaqRAi7A0ipKx5/+u2Hm94uGHewwoqtCl0y05kqKuh83e7SfxJbG0Aj/Wy7LpU++ISqGq4Do0GbhDXrBmB85VuaoIiAP1xOB3XymwbUtosSjGUIBbz9zuHaLckWg3/bi+f9df6XMS16utmeYrmibH/G01byjmU6uYJOKo2ibNUDw5lbSFjYNXmZrdpchl4MVzaapq4/8Aa65QcN/S12ZpsHAQZFy9IvroCMnlngOHbk/2xf3IqwNxAB3JJhybP8SxKWzK4oYeoR8HPZnFv85VWoRdnFoAd1VELS2Uz/sF+MyS+XWWqagqRmDTMj8knJ5kVayI43AYXdS2UVfc5bcmYM454t7d9GX/B4tUtAKq8YSgjhp/1wTaUSlufJssPKqJkle6MTpbsbP6ADWsxN0VHpk6mhBsDFoLTzfZaR5cx4TNMzUDrM9BIbfwWYgHfwXvyp+laVH8Af2JQQXSfM0GZi53BDDwRRcLHZVJ7eMbygvSEWE2sMwon162McjwZ5wHCajEFotQGwigvo+3s7rOhKCFimFUvAZkzJHrUbrnkYXBEaxPtsE+ASgr2oNVJkDSkroX7zNrPeIPgPNnKfs2kDE8qRY++QoEc0Uhqe7hYXpT4SiLkuzIj5d4WTGaAQ0nkn0GuE1TV84efp2GHE8vjisdShkoYq/0U+S1Kk08ACZssJSN7Of/50d0R9AfuVQSef+33m4Ggr/jNhD4Jq+N2RYtYW8lFWLYZhxGdwB+uCoREi7HpgZB51XX3Teg1QcPU5hBl6XkmYQbFP62076Wgw/vUvWx35HxVkXd17dPFIytFirK7p7J+b+4//9FPp5hvlifDzunBXZV6UxFVnGySwZTAnWf6YjLzzCD0TeWAhKmHIjfj/45O/uCJ05Rp9Ow9JUzXX4clTMVLf0kTC1EN5BWljFNkrXBiFyMsEtcEa1BFIit57H7zNONlSaHKB7zbc05sq8s7qSZ2LU1ayQfw/LHEq+NgVG7UEvKtJ5i4QhBlRrFWFC2KA+bfgOVReky7NYoEHgQMS33+noHkwXN38QCQUMYuwALRfsZjSKSl4SDhQ2KbQKBVLtzP64UAeqV3/N3O32i2afo5124BGF73Wc4ZFDz/kWllmg5bNgdVK6RcRKY/BcYHruFe8oq5E9Q0oGqcbcQkLE45PqaHhUAD+shNP/pwFo3HcEwxwzY6FGD1EbFcGTryelZTiIMB3iKfN0oBt4D3WgOaWGXxTYh3H3B1svg3BvHEbpcI7q4mZKX+F5lI5dm4nlM2RyXN33s1yriZiX6fXmOlwio9Lk8M2WT1JufZW2pfSSNIH8Idf1Qssd07F57ZR0Kie3JL84fZ0sTByIIPeKFf1Rg9RG0XPF+CqSZ+vJWsN/VGDT4urQA/u244/8Uj99f5OJR//m9/+WX9zeOEa228N0vEHIkUYZkO5PJm3LqbXtSkDp1LloVr821s3WOuX3voNznIz6pyRXgvbAVCQgC72kaMYHB1AMMlJ14VTDI+sW/uc7TmLba9sZTWI0YjqQg9Gk87qQ7c+9mMi9G645ag1md/EUDuiPQvLdprf0NgjCFtrT4XTn9LPQZEgftBILDARKHFHhHR93d3/5WxNAP3WLcrPQgGWoG7HWC+b426FhKlFESSokD+JQnAwxe83twiAmyR1KGzbDtCMmXJ5ou4FPHKE3dyfVicNPjvmfSYE1RY8lbDtPOwXwR3H/vEz4qGZEJseRlSs6KFoaYXqunYQ3/0fl6D2bVgm1V9Ivg/U0FqvKC4DyDNfg4FjUQqniJxcHXP6T3HbDi+mfLLs4BmE26EMVmDt8+0ifq1fki0v+gx6kBrIONSniKvLZq2Hee+9zHCXLxzpX74+G6oPgOVBzadQFk8vq9YYkGiWBRrBcAx8+n8TQEM7UTZhXxbiR7b3YPMadt/NHRRRDucAm0X2rPL6BHrg96eG8uzdSAyv4Edpt5LOGC8Uf2/nb6wtFuuJ61j6EXv5cF+p2wMxxzkjGHvkXq0wXHRouJFW/J8Cay2b4OwZAHLcohBRifhKW9l6S4WpkSAh4sv2pdGAv2uH4jZ+j658zNHNH7WQvPbvoFjt1H7eBRvSk5CgIzhn/HFH0bXKBZps1UYrRwtDwLAknGRbiuyNxM6azWXZtTfnhGhFlymgwPNDkfZZhRpA28zoBtVmMmvbjicAQtqXGRHpd6ByNZCuWhccLG8fvggZv+Go3MF85oEjI122B6cJ6A4jmG1Nzildm8XvV/c4r6XPQIFgw3QcJQrWRm3yGk29sdvb5zM8dlOFzl0w2ang1qFSG7AbZF+dmerMNDphPBSXoK68D4WtFMJQUuXIk3W5zj/cc/e8OKT6cg0JsQYD5+YlKdOUYPZJS+UjV3UMZhbUwAFJ3Y5zlXE+mqL4Qd0WuzZPROUGytTFgiCA8f61BCYiJWFQirIiKd9kznI3If2Gw682KJfAMPrYYBklLX81Rzwmt9CnaG8f9QLQW+cfE56LYRKfR4fVKxHkPfDXGBEOOUCII7SSnKeqpYlODK2csgjCdiWwkTr1Or4XSFuAW02fS3fct3MCi685wSGCjhDbgythwxZAvsXMKq93fAA3sR6g1w+Xft841GjLX0UDFVJ1uhBTYcjRGENIO8mKM5zhqbD5zrTcF1JDrVOsDgE0zHZKMlumzFynx4jbyZF7dIzZreVgIv8vDQWnBpSK2FcT5yG2Yp/p2U4RMrbG4nE5ZlVHvP2KGl12KisXVe1OOGB/dr37hxCre2iopacuE9d2iLQmU9EQ+BDuD0mWDm3xIfG3uVJAq1GDt/lqx4ei/JA02jlhS75a41lV56Yg/PjdoROL2XfS+TOY8Q9A4D8WG73oiLy5smCLhEzvCjDE4a/eTgbWj5CP/nCSgvZq+N/+8mAzl8NFdbzt3VO6jd2fAZ5F+tncPlmk04NWevzzKI5fbyyrPe67d7Cgv+Pr/dlgIIlacBLzcE/2BCes8lGxnof7j6xkeXHXTUs+YKRlJGq1etQ9e5USMv/eHDCBJAbVQ/PUUyS/e+2Hm6aOdm44YlHxtBUmlf89JauKNYcDSW1HT7SmtTV0D2PIEFR/0CMA8DWK8IxfvQPqNcr/i9/cn8RNekoRp+YDgZlhhwCKuYnv11E+7R/C2xgeOwhUwX+X5DXb3fg20z9OGgwXR4I0iC9NbOmwXeIBqCur/evL9bqrycvEqaS22mTqxg4mWYyJNdU3d5ZolwseCB/9iCLmHAwn/q1+qMDlWrsT5TwLjYmQsjqeWzXZ59OShVaHrJV5CDLyeAkBChkwYAW6YzGn2Ca5tTJh9Q8Ez1U/F1iyGxe7z6xm/CN3jP/Vb+NTO7KYXo1KWyFz6A7pCWj1XeG3XDe+w+6gWBye7U3jjAVAlE91goZ4MdkT21XR45+bWjFvozNmoU8pUm/u48M3IQubdYnoCgNaOhWYPuF5e5iOJMTT0pXFpU05y1JRTm8FtyH6opFNCA34+jl/X67jxkGPiOYf41F70Wi5B5Af3mf6/0GMVqCLtX96qnPe+4R5tP2buUz8jtJLxs36oTazYPSSrC+z7jHwQ0Ek3/TNkPeN53TgdfKzn2PsGQqwjWLjQwNY79FtmjzpfiV3+mMWlc9o5Vyj6qbxcg7pQP3u40jaB7iOf6EzB7e7ehIfnhzBUcbwIdej0Quek5/MnT5sRLA72Opd3HliZLljRmc2EFo/o8W4coXVaYSh1L9JDGEafGJ2MKGywwln2RMfKEZmorTeZzq/AA64leofH2knVdnrIlVyhdL4sgZR7CweKekREo1dHiL/efhmxrmT97J3MjfTHbjAa3+mr2QnYGb0/N8YGbe55csrr/ZTZkwQ0n10nfGYPOkEZAEAyHvYz+V0I46bq1TWWddBhq/MJLU/Exl/14oPvdjI28QuZyiuPn6Bteyzm8UkKhETz9mefl32jM1EsGgT2Njk0Lc+2ItNs39EoaQdh42VAaaHzy6AI0Fg9EAXwXmQwTdBDwC1Vy+k5oyFZUWMPVmBuLqFGlZCK8cYVGUp3hq9wNo9dMgbYWorC7iPMB2+eYNQ+NTSkkZZ4Dr2tE7TbEViNggxc4fkIiRKd/6prcQ+ycE3l9kJgufJ1dlQ4ahhFQzl6NYTk4BGpxTecseDaNqH1U/gsUhkSJZq4M5Az44Qy6YsZ6BWuFvoo5jtsfQNUvFsfUsOqGC72EGlvPvYiJ9W7/EGA2xeisch5LZn+6Qjdk6o1aX6ttNmzX+5aHY/vL52PWdpegrm+bXnnxrhtp5KqY4H7jQbfWKO+aClmbTE/8iL2zU61pEd9jFXk8icHRB4OZO5TvWhj1MgoORytZKT2ZrmA61Qw5jRYK3iYqeOeMkHQz/F7JzSbj2QeJV/uvPhBkjh5C/sfA++4UN3AUdxtS3eaN7CgY2jV2KpH65KvhiveXkkiG7SoqdDSlHNnKK/3HoNtGp1YwboQ8W1z0DOhkwNebHh7RGfwsGqpmnyNPZg4K1chsEdW51VpU6txPpxrjRTYMaYM0ejNofpIUB7Cr7kk9KO5/DZBMn3E6I3HonL4SC/gSNEhovtxZ46qHOVme5z0p87Xnlsp9L45FCBz/AJCTEJ2RytoHRXtmxrRpPBrB2Nawg9ceRE4/cqmMj0MYMxYDWlq/U7hdb6tq4AfEhOLtwLaVEM8h+6qMtz9JGb9FLruC+dX1rftXshZUvNec6hq6iDdPzgAAH3YmgUw9B34eZiHClFQm9OJtp8IQaKaGfV+HFFNYZc7nNTyC4LVMqNCa7PvGy3VbYjWPtNIhsAo1aZkFi4e+aa56UcC4XTW+usgxo31BJs8pTD3FCa3s2un+IG06/AJunrXYeMmEo8wm5L4X8agp49iigav2YGB/FAzmAjgWPxa16KXUx7i0Efc1GFrLJ8eK0ZPzMGRvbfssmOwjh36198MD7ZZZDjSBtB4uV+knbkL4BEsu28RBYxZczPv45c6lwJnhemk3PpYgr5IucEh38P8ILuEHpsKfqhSDeUM/87Ld1xHwzsJDjRxZHJ2OQWRnfKU7w7e3Tp3cvL7hIN0SX1OFZjrRKzUAvVXXq//qq8TXWfubhw+fDR5sxqtanbdut3qmnp7lIy2OGCfS40IJbXZySjLkQFMG87oI5Fhs6UpBPPgg3GyWPQ2/qbqwTi9D5X1uAU4uEwoIUm6ULMrj9FXotlq2Vm7LRABY7WFkcgtV5eOh2tTDy1C7UJBQNoPb9L8hQfYpZoh41Rmebqym3p1GiuofIPmcacqWdq3kiyvQBkMTD6QSYEJAEat0kne6w+1etUlrhUwhPoiUNroG4Blfdc6jpoohobETPZPMj0+morn8BC/reVLacxr902N/eGVQTkknBCMJWwgpnSwk78qkCyWAD10fO+pI8NulWb0QG5TZZfx97pkRhELPV87Kp0E/Uzjon8iK6Hy4F33SGNd9dCLvNrYQ/LV7tzb7H7y0wEBnVHfP98ecnLXWih5dGvuns3OaqHAs4OyWQx1zS+9ZMxni7lAD/hK7GDOmemySF2orKWmmwE1aGEt7DD+Fws/1IkgdG8XYt1fz3S6MgTf4yRFZvCHNfNHlmdyha8hypZT1+76zwc8kPtdUNGZHuwvJ2+mBxtWvfU7z857mcn52CpQUwCSJeA4a1DOYtq0W2/YktKZozrAA+ZWhte76U4J8LkN3ZhB4ZK2YoxHlgO6DPOfTClsaE42hM+GkHC6CsEEuABCs68aNilKdsM048xuEh2AuX/+LWehsL3DnKJfPjqcsod2cdEQPCArWS/UX/3OXgwANBi9smGJAqlSAqxFaLYgfmPdUsYR6G4IWWabfX/1PlVyYowyl+2Zit9s8pUGKnwVvo0x4GTBB6fohn1PO4U3NqK5r3ORCi0Iml3w7JCOlbdwazGHC9BP6uHJA2EHSLCUVS2vtRfuyMFF3Y2Td0EN0xQ3HBLGtJfQDJ4OEyBW3DxRe+jWFz/FgOyoyMegiRh+IV02bptyTgprfj8TASylp87G1nIVzqrLqZTYCxZHNPa0fTFss9L0CaCO35GPvV53HaeUZplvwOQZ9MRs80miIxlc2NHU1TWlWGKfqpbUpldSnVvcKaV6EAqBmvCpIb88NFbKclbeWZkrVSTwAfsG0zzpV1Xfy/6lmRrT4aBmhIEJPnFJMB2dQdZ571m3pvqloVClhUo0+RyntJuGkTWgEmMcrZCI7PtsTxXli9xzAa4OJIDXPmuJKqd2PoyZ9du86z/MbcKUm9F/JOWmO54zs9SNxBPK5uzVbn3Z7BSsPZOnbEb38+j/tRLCe0K9tpgEuLxNtZICCjQvCw0/GWL8wGV1p0UdEFyMV+FISXlG4HzxZxD14IxdncU0tOx7CXHLmYtEHWqyDARYMS5oQ5zAc0QCbXQjQcYSizHmm04qUmPHE//1Ine9gS9OnrMpGBJ/TSgsm6p6rmqlrIr1Qldu5xCBoKVoUWdZu1nSZ2dFp86oyQIQ9cCjr+JSl3jyySxD2k6pr01tkkibk1uxdkKQC3c3tgP2pUDy2lZknkYnBQRtN3RJqR0OqLQHk8b16I0eJhetI54O+utB0/03zpCk1T1LGf4XZe7LVVSUbhzX+UgfSGAss0FhNuTRp5nCpExulVswcCBTi5wDz3UGKMy1deBXoB95ZGIuXNb+x3RDLoJXIaZJ+1SbThtN56kmr0MjIKzncpZRPJ0vhFkhDqRgI7w/7WnPOxa3TQZzdUsTnllf80c/A2xdfWiYwI6v110fl4RrC/P1HFRFTOnKmSzdh+4ig3sUo7Hn9qwtjtoJajNFMyWdxtnbtLp4nolH+GKWHv7Ebi0Sxj4rqyhazDfrmVaUScvHvVCyF6+ftjzV5EElFMWUV+lQ0ixeP/R/n6Cl5MJ7uh2vciXOki+0Fc4Jt/HkrvWety06soCdg67yRyPJtGGk5PT0umfsf6KLCsA6xzNl6Uaygy+odr1tN/+zUkpsH+5gqHt5TI615FTmn/DBP+WJK/3Noy/uS9adMghMSy2maPG1xxEioYZkUgihi6aw+aDS65m4gU/gu+PPn15LbXcPOjmw2V2IghGeP2Z26/A0fnFlkj9WnAPD0LOL+iQNi4KlHSUYM7X8TpKMvBa159loQ2mQKk/1oIPfYcO5dWxwP6w38MHtv9Q6FrW/fzXgIOZGM+1ctu6QiS1GDevnwDiBPpNTfjQ5l3tt4WDxbJ1hyLW4/EXX6vVy+g4bhXqjVpk70k+5opGyzXg9nu3nClgScIhd1Q3SKwhYYSuIhpIsOXh3Z7OE7vV5+satxmDxLtAPUZ/t0LykWGojE9rAKMZEruBqjDHLl4l7z2ZEbBokv3tlwt1q/XP79NQpUpYsrhr3xIJvskZ4yz0olaJ9ABtKf+9LmuWKQ2iccN4LDMYLobykpVZfxXgJvbMfmzJosZ+wvKFQK4zlJAroQ8hywt4raFsCxrDK1lg046X8nUYiPO4k3rm4j3wS4V7fjX+AJY/ErEsaHwyacTo/uYRrxPYsN6GvM9ZO4cJ70kAtjk6+AF+Ch4F0JQpdJ3RX0oMHevLPH0fvqN2zDpEJFh+JrnTIeokmdcSlWzmgffw6UoIbzMiCBr2NB5LTUICNFuUfqdGF+HqORK1zf+PWEhaS4H4c3lY2ciFZ6R6KnbZ69fW3q0+/ut9EnHuCqFjP+9NscRieJ6gLWsHjwc6plBdN8qGEvbzkHAYMA4at29GvTSICnRcfqEvR+dyt/CjRG39ZbweM/8bu+MNOJUpKqz1NXhbRKgI1i4LMqTC1M/JQGBX3BXkXzKJw9TI8QeZpRGmttYkjOGJcGp3dML13H0Yu7uIY9GvsVlsIuAUN4c9BAMtvPstmfKNwPVXdoQVoqQmmDcXtw+oiW45KpszAQRM0BMh8wJHPvK21zEIJvyNzeppRE5tJ+LjZ3uLmfX6bVIkuYhmXa/tW86wCCUW5jvpkkGCm6F/G5ToabUoAJ+RXjIUM0bi/dF7H4OVbtDLyXqbpAw8XhDJGarT5HCsjPVWJ5x3F6NR9RTkWL0rcBAxqDlqakYhnVWnlLMkhppDW8qdCr+soPebafKd+ZQir2TpGhiHa7wiBbQAXDxE/8APNjjwXRPu8uRtMAY8nnIrcAZHNNyqqeOdv7Py4e/Pq9Ga5gq2evXUaThB5q0lWdcNXJQlQ++gljAGLUXxx4KaDFreOMWC3KLJsjbd7j+QY2lh5NUlFMvHfas1dK7hP7fU60xomDs90k7WhzeUruFQC00lUfilioyygNyoT+yhQ1t6CMRNxqfk+XRNwbSRQOnyKiS8dTNoKwk20B4mq4s21X9vJWIfV8KEfRAMIwRyx5zAgsnTsoCn+jQkpD0Y/j22uGfwS7SjZAoRNOU8yv8sgezkZ49CgiAFcdWuBGSH9PCU5N6GON3RtfmnLJIwA4LnxviRGak9yMid04i5t0PVpVF5vBG0WiHQLdjCA9Ui5cDlG3mCc0U/WRdo4pE/eHGpp9V+LQMs89HVGleEYwRVXhR7jPaRiABl5x/f5yInJCz+pF+bRoKuKXbrgdaoprJX2v1QNlYJ5hjKDGTxZ7I71sQb3XbejtP7Uzc9dqwJlqVR1BCJ+OhD+yRRqKpIXyn+bnky2+JO1XRag7Uc9qqFsErYddHYrTQ2+MiXGnTDqWmdWpQ8pSvQvRMmiGqS8GdQBm+TzivYwbETUhImusk6zgz1qpLCgI3uhdx2L2BPfPQJJ4teknHLrRxG8xJk1+TuYEIE/tjjXlxPF1q191ghe4IeBMLXZbrQ5oyGQ8x3pi5FO3YGkSQ1Prr86aQf0gQycLBo+/hqnm0JRzCtkWiA7up0/pAZ/mkJQ8ktMVQJDfC79y1YfoTdkHb9o/FP5D6GilMHIBK/r+DFCk5STDhklv+4ebu1KaJ9VIdfM0cneqLIlQFoBVx1GrOXlDUlqS+lz9eGvIA4Pu711k6Dq8QAAAAA==";var Te=(e)=>e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;");var nE=`
601
+ `;import{randomBytes as HE}from"crypto";var Sn="data:image/webp;base64,UklGRowIAABXRUJQVlA4WAoAAAAQAAAAXwAAXwAAQUxQSPUAAAARd6C2kaQ2+x7vCYnIICICUE9IY/s3w78ZkGLbVh2dZmbmVpD6MjIiCTEQCX+UMflABQ1TlBDm5F0TH6r+FtAV0f8JUPhr6ctZgp16el3x80tL/O0qVsEZsHMdw1sZ8m8jampQP6Jm2LuQ0wWnuRaoGngvMCX5kjxDb0ifrEdpwirq1LE6azmDb7VpBwNaakTLzGjlBa25ov05Wsf+PexonRXtb0FrzmjlES0zoKXatIMcbevUsTprmrCK0ifrUfJYG5KmJF+SqqS9wOmC01wLqMa5U/iU4ivSWzH+NqJUcITOteLml8m9XSn+a+nLJdGpp9cVDgBWUDggcAcAAJAgAJ0BKmAAYAA+UR6NRKOhoRY9tXQ4BQS1AzgGCB/ee/5/8jPwz+bO5P5nkZD2ds843bX+Yj9kf2Z93z0U+gB0iPoAdKF+7v7Ye2RWO+UP077gbq9qQdr/7Thr+EWT3fpuZ8LGkp0APFRz2/VPsD/rf1s/SAQZ5oTHtl5+vGqupge+ws2FsPRaD62UdfItG+n1jDbxzytDaxkYsfS4x8lyBJig6aGlb22hCpshcpjipYUza1imkCH7/l2ZjIFhBOTUiHjNyQuxrYQXfSzMNW1qzW+dlsu1I6MDyqqn7zU4iamwVEUEZv5FyU7p6Vd3Pt5gooS7O2sYSecahovpLIhR64hfvZcljfG+tM8AAP70trGbK//s2rvZwfoB//09wZcz+Cfcx4XrAXrpQJ6C6jE5BgpOcnxZ94NNLPUOQ4HzkpZyLh3++badZ9IidhzLX4r2n8RmqVxYLMZCsUfCsBh4gaG52xAAJ4KN2H4DdWmH2DbIYA3oQzXK9Osexvr9qYEMv8qPWnBnq8nAuaL7WKQ187LR/6cONyjd9mVdTUP16wap5lgEINV1rSgcICC0OkPfqub61tJlCjn8uh0cXVNKOSx8W9AeuB9dFZSMBJa++eYv+YTIYyGHTpI04pjOpIDq3AOqPYESwBhWE9A42ImX8x6VtXYVOmwv8lW41Vgj09tdrrcZW1DZvWWGvOoIuk/rgKYrNbIx3qS48b+WBGqI50gCeoBcvIxNGUXBgfHz5rvFiKgBBT9jJzd8QC104TXXDX3YslDeVhutM/CEVJ7qO9mLcA0YwRhtkjMiOen7bo9hTRao1/KGhCsS/e4tYJMdRJjNYKsZ+Kp540o7pJM7zIhx5E+BN2oZjElAPt8O6koCFZsFT8W+Y2SvoBneW9Vk9O/6mQz4bmauo8KWSyQNUCGAIWMsE7iWA+kt4RsWAl+gw0V+01q5W5TI4PA2Kx8juMUKTsPInerJyWvSZcNxVLwG3+5dbicBchRRlYSKukU2Jp4ZVDe7I2fnLJ+UIOEomr9p+CBlPQARIxKHmaXm5V9a0+m7Cw/kpNojQus6JnAg86e/ianKAk5BhIisTy0pyIjUrBya7MJDsZH/v/DaPm7QFNK9hgzybPRJEY6KuL7bwQHVQ0jcboqu/tQvI+mhsDNz2K2tNCNOcMCA8HWf+pwu0GaQgSajBefemZ6reFjnoc1LBgmrFHFyyflxua7ool5jW9/r9hjxKVxHxs3o3F5Kc+vV/mdHDj50DHL+9duz30i+Jf82JCXGMbp7+FjGKhzcGyarYjXbiPFFl1Be4iW8OEVyWe7H241eXMl/qp5y5Q8B2dBYymhibQNm5UPgyzuM155RLLPrnrnc3xSPFbqv9fl7j5bSrdzwBZ8DjnI0dcr5UDCNGGZkglw5FB2rgioiB7jYrrnPfGrfuvrsAH0GodU+o0erjag24oZX6Sam8/LPLY8EiCVWAQMG6r5sTCO/idTDXTuMcAkBgzVgphSyUmDTduYey7e2NtCgoWS5wdflZstX4FceW4AVoWWuAOU+xs1jI9C7yCqQ+IMHeJjmB1qFaBGy4z14f5Y7tK6u57xfo7bCBu61laMUi+5mBj4Ba3kuu6YrskddXtCDx9z9cvgNTjJDgKdfDk/df4MCI49ZGVmOeTQ0Z9tt09gfxHuqiGCGmKYZzmeaA7dy2dHc8VbIAbfp0JKwq3RDugIs0J6AdPhFmM84ci3/NV0xDACfDfZcd8t3is54tH+5YGhIGswMHwYGo8VAHM8p+ORY7zU0zJdhF1/y8xEsp/hNm7ukLLZZN9qKY7OAX9uQCc0Ww0j8lEJMgBsUlMy8r7gBif1ipeFRE//+P9zTMtS9Qonr/60Dp8R3/quzj4Jslgk92itTQdNH3iPVCLA2aJT1L8cKf3ft1LyBsKJI4RPDrV9i5v+Ym9+CltyZq3JKlFVgAfrb3dawijRMdvj1x1y73VR6gzLFjyVv/sOtb6b+6K2JGHmnVIRmaw51s8qg9s1KxNdYetYQfGuG/0+M4ZqdGRzuDFTnoNmUz2QPjkXnF3cyguivLl3y+Lm+BmR5j1Ya1Uj0govN2frgHKjQjvWj5wwZFPFbyruAplSrHUAJQNqXZK6RQSpUOSi6JOGoXak2pTlPbQWayU3Ktn4HKXn0jW/HJxX7y9aHwuukGIVKGOzEVBTiB5HQ4hxfL+DZsNeViPXYmYJcQwZc01C/kXkVBxWpOy9Trs66Tr6k5aHmVSdHO8adOlCg2wEgbzREaX+7VfDTl0nI2YIN8w6KkwupCrkbBsPrWtkCYBeuEGFmKeZnf7KhveiRPinbtnmNAPcln00zDbiLs2Lbe6G0BMvfZIoORkHFoAzgqMYpHtMB1Vwrm+QYFcoOcQumhppN8dnidf78TWLer4Zf9DfMfVIyuMon+1lbhH5hDoSNQ/ChJH4bArnAZL9ODY8B/r4neoNTwEuZHNzVoqV/hRvSZYzs9bvRFMFdllnZXDFpCFvyJ8jdJ1PspW7B9XIilKsDMBmPs0BL3rPoQErXAAAA",_o="data:image/webp;base64,UklGRqQeAABXRUJQVlA4WAoAAAAQAAAAZwEAZwEAQUxQSJgDAAARCjqybbuNqweiGkj0jbyUOvIbuQgxC1GnzGRYmAFTRsiRcQCs4jQ4gs45CPkYKateQAfzIJxvcd69ETEBdGN4ezzN8vV297Hc256opey4zrPp+HZofgxvvcg2X2zPpcqLW912O12VvjfrKpVuGk2W323vVuGoY4LfC9vbC2F3PFjYnq/SCUGytQBkErjualZaEOqMLosyC0WJXBW+tXB8K05K9xaQmrrnyY0HJZ+4Jc4tMDV2SGLBmbgiKiw8i8gJk9ICVOmAuQXpvG3xxsJU41Y9/miBKmzRGw9Wtubaw5UtyTxgpRULD1ltwdKDVhonHrbSMPXA1UZlHrrSoGsPXjbmjYcvG/LYA5iNiD8iSOImbCyEtQFzC+J5bRMLY9YUlTjSqJ7CArmoJbFQTmqILZjj6nI0aWVPPJxZ1Q2eWFHqAa2VhHtEqVTx1kL6bQWRBXV0WYYquejKw5qXzHClFwQlrpTnJRbYyXlbZPGsBx7acs4CW3pG4MHNU7+jS04V6CpOjCy8R8cm+OKxJb7k2Hd86ZHbHuBykCJMD1YI04MSYUryloe4kC8wRsMMY0JuMKbkF4zRhB7kchtlMkaZTlE2zVAmOcp0jbL1FmXcoWz3EWVSokz3KFM/+H/w/+D/wf+D/wf/D/4f/D/4f/D/4P/B/4P/B/8P/h/8P/j/vz8VZVqiTAVlskPZjijjGmXrHGWaoUymKJuOUaa3USYhysR8wRgNNxhTMsOYkC8wRsNbGBOSJcKUJFcI04MUYXpwG2FywO/4Uh5d4kuOTfDFYyN8jY6xQFfBk7+jS04F6OIpLrClPPMBtuQcbpFFc3aCrOS8oMSV8jzOcKW88ApXvIQZqoQXR6iKLuNbTL1lheEeUSpVMEWUstobPNFU/ARPrIo5mpSVx2iKq2OCpYR1FkgqWGtU4kijejjBEU3dcxTNWf8GQ8oGxh8RJHET+BhBNM18gx+apl6jh6a5GXaETV4gR9nsJW6ETRfUCJuvmFG2MUOMsJ3XeKFp6xu00LT38UekCE2b4w1ONGbL5yiZs/2TEiFK48KowEcR0ZEJOhK6M86RoTGd+uQGFXxinJvuEaEpXRy+xcNboaOjDAsS0eFXsxIFOqNxfJBsEcAkMF34YNH3VNiZwe9FfyuEpltHk+X3/qXCkenk2+mq7E+6SoWdfutFtvnSd6jy4pb5MQxvj6dZvt7uPpb7vqCl7LjOs+n4dmjcCFZQOCDmGgAAcJcAnQEqaAFoAT5tNpdIpCMiJCSTCSiADYllbvGALXqNzACijUqXk0Wm07e87qnWF6f+984PYvmk9K+b//r+rP9QewR+svT38zfnJf8D9pPfJ/efUW/uP/A61L0C/259PP2bv7Z/3PSV1QExq6YwCPafC5D75RP1Yx6HiO+79g+wl0uRn7uwevJYFxyd1XE1Edf/cXmY5/8ym/s587lniL9JNao71PqB5+xWOr/uWkKE+nwMaqRAi7A0ipKx5/+u2Hm94uGHewwoqtCl0y05kqKuh83e7SfxJbG0Aj/Wy7LpU++ISqGq4Do0GbhDXrBmB85VuaoIiAP1xOB3XymwbUtosSjGUIBbz9zuHaLckWg3/bi+f9df6XMS16utmeYrmibH/G01byjmU6uYJOKo2ibNUDw5lbSFjYNXmZrdpchl4MVzaapq4/8Aa65QcN/S12ZpsHAQZFy9IvroCMnlngOHbk/2xf3IqwNxAB3JJhybP8SxKWzK4oYeoR8HPZnFv85VWoRdnFoAd1VELS2Uz/sF+MyS+XWWqagqRmDTMj8knJ5kVayI43AYXdS2UVfc5bcmYM454t7d9GX/B4tUtAKq8YSgjhp/1wTaUSlufJssPKqJkle6MTpbsbP6ADWsxN0VHpk6mhBsDFoLTzfZaR5cx4TNMzUDrM9BIbfwWYgHfwXvyp+laVH8Af2JQQXSfM0GZi53BDDwRRcLHZVJ7eMbygvSEWE2sMwon162McjwZ5wHCajEFotQGwigvo+3s7rOhKCFimFUvAZkzJHrUbrnkYXBEaxPtsE+ASgr2oNVJkDSkroX7zNrPeIPgPNnKfs2kDE8qRY++QoEc0Uhqe7hYXpT4SiLkuzIj5d4WTGaAQ0nkn0GuE1TV84efp2GHE8vjisdShkoYq/0U+S1Kk08ACZssJSN7Of/50d0R9AfuVQSef+33m4Ggr/jNhD4Jq+N2RYtYW8lFWLYZhxGdwB+uCoREi7HpgZB51XX3Teg1QcPU5hBl6XkmYQbFP62076Wgw/vUvWx35HxVkXd17dPFIytFirK7p7J+b+4//9FPp5hvlifDzunBXZV6UxFVnGySwZTAnWf6YjLzzCD0TeWAhKmHIjfj/45O/uCJ05Rp9Ow9JUzXX4clTMVLf0kTC1EN5BWljFNkrXBiFyMsEtcEa1BFIit57H7zNONlSaHKB7zbc05sq8s7qSZ2LU1ayQfw/LHEq+NgVG7UEvKtJ5i4QhBlRrFWFC2KA+bfgOVReky7NYoEHgQMS33+noHkwXN38QCQUMYuwALRfsZjSKSl4SDhQ2KbQKBVLtzP64UAeqV3/N3O32i2afo5124BGF73Wc4ZFDz/kWllmg5bNgdVK6RcRKY/BcYHruFe8oq5E9Q0oGqcbcQkLE45PqaHhUAD+shNP/pwFo3HcEwxwzY6FGD1EbFcGTryelZTiIMB3iKfN0oBt4D3WgOaWGXxTYh3H3B1svg3BvHEbpcI7q4mZKX+F5lI5dm4nlM2RyXN33s1yriZiX6fXmOlwio9Lk8M2WT1JufZW2pfSSNIH8Idf1Qssd07F57ZR0Kie3JL84fZ0sTByIIPeKFf1Rg9RG0XPF+CqSZ+vJWsN/VGDT4urQA/u244/8Uj99f5OJR//m9/+WX9zeOEa228N0vEHIkUYZkO5PJm3LqbXtSkDp1LloVr821s3WOuX3voNznIz6pyRXgvbAVCQgC72kaMYHB1AMMlJ14VTDI+sW/uc7TmLba9sZTWI0YjqQg9Gk87qQ7c+9mMi9G645ag1md/EUDuiPQvLdprf0NgjCFtrT4XTn9LPQZEgftBILDARKHFHhHR93d3/5WxNAP3WLcrPQgGWoG7HWC+b426FhKlFESSokD+JQnAwxe83twiAmyR1KGzbDtCMmXJ5ou4FPHKE3dyfVicNPjvmfSYE1RY8lbDtPOwXwR3H/vEz4qGZEJseRlSs6KFoaYXqunYQ3/0fl6D2bVgm1V9Ivg/U0FqvKC4DyDNfg4FjUQqniJxcHXP6T3HbDi+mfLLs4BmE26EMVmDt8+0ifq1fki0v+gx6kBrIONSniKvLZq2Hee+9zHCXLxzpX74+G6oPgOVBzadQFk8vq9YYkGiWBRrBcAx8+n8TQEM7UTZhXxbiR7b3YPMadt/NHRRRDucAm0X2rPL6BHrg96eG8uzdSAyv4Edpt5LOGC8Uf2/nb6wtFuuJ61j6EXv5cF+p2wMxxzkjGHvkXq0wXHRouJFW/J8Cay2b4OwZAHLcohBRifhKW9l6S4WpkSAh4sv2pdGAv2uH4jZ+j658zNHNH7WQvPbvoFjt1H7eBRvSk5CgIzhn/HFH0bXKBZps1UYrRwtDwLAknGRbiuyNxM6azWXZtTfnhGhFlymgwPNDkfZZhRpA28zoBtVmMmvbjicAQtqXGRHpd6ByNZCuWhccLG8fvggZv+Go3MF85oEjI122B6cJ6A4jmG1Nzildm8XvV/c4r6XPQIFgw3QcJQrWRm3yGk29sdvb5zM8dlOFzl0w2ang1qFSG7AbZF+dmerMNDphPBSXoK68D4WtFMJQUuXIk3W5zj/cc/e8OKT6cg0JsQYD5+YlKdOUYPZJS+UjV3UMZhbUwAFJ3Y5zlXE+mqL4Qd0WuzZPROUGytTFgiCA8f61BCYiJWFQirIiKd9kznI3If2Gw682KJfAMPrYYBklLX81Rzwmt9CnaG8f9QLQW+cfE56LYRKfR4fVKxHkPfDXGBEOOUCII7SSnKeqpYlODK2csgjCdiWwkTr1Or4XSFuAW02fS3fct3MCi685wSGCjhDbgythwxZAvsXMKq93fAA3sR6g1w+Xft841GjLX0UDFVJ1uhBTYcjRGENIO8mKM5zhqbD5zrTcF1JDrVOsDgE0zHZKMlumzFynx4jbyZF7dIzZreVgIv8vDQWnBpSK2FcT5yG2Yp/p2U4RMrbG4nE5ZlVHvP2KGl12KisXVe1OOGB/dr37hxCre2iopacuE9d2iLQmU9EQ+BDuD0mWDm3xIfG3uVJAq1GDt/lqx4ei/JA02jlhS75a41lV56Yg/PjdoROL2XfS+TOY8Q9A4D8WG73oiLy5smCLhEzvCjDE4a/eTgbWj5CP/nCSgvZq+N/+8mAzl8NFdbzt3VO6jd2fAZ5F+tncPlmk04NWevzzKI5fbyyrPe67d7Cgv+Pr/dlgIIlacBLzcE/2BCes8lGxnof7j6xkeXHXTUs+YKRlJGq1etQ9e5USMv/eHDCBJAbVQ/PUUyS/e+2Hm6aOdm44YlHxtBUmlf89JauKNYcDSW1HT7SmtTV0D2PIEFR/0CMA8DWK8IxfvQPqNcr/i9/cn8RNekoRp+YDgZlhhwCKuYnv11E+7R/C2xgeOwhUwX+X5DXb3fg20z9OGgwXR4I0iC9NbOmwXeIBqCur/evL9bqrycvEqaS22mTqxg4mWYyJNdU3d5ZolwseCB/9iCLmHAwn/q1+qMDlWrsT5TwLjYmQsjqeWzXZ59OShVaHrJV5CDLyeAkBChkwYAW6YzGn2Ca5tTJh9Q8Ez1U/F1iyGxe7z6xm/CN3jP/Vb+NTO7KYXo1KWyFz6A7pCWj1XeG3XDe+w+6gWBye7U3jjAVAlE91goZ4MdkT21XR45+bWjFvozNmoU8pUm/u48M3IQubdYnoCgNaOhWYPuF5e5iOJMTT0pXFpU05y1JRTm8FtyH6opFNCA34+jl/X67jxkGPiOYf41F70Wi5B5Af3mf6/0GMVqCLtX96qnPe+4R5tP2buUz8jtJLxs36oTazYPSSrC+z7jHwQ0Ek3/TNkPeN53TgdfKzn2PsGQqwjWLjQwNY79FtmjzpfiV3+mMWlc9o5Vyj6qbxcg7pQP3u40jaB7iOf6EzB7e7ehIfnhzBUcbwIdej0Quek5/MnT5sRLA72Opd3HliZLljRmc2EFo/o8W4coXVaYSh1L9JDGEafGJ2MKGywwln2RMfKEZmorTeZzq/AA64leofH2knVdnrIlVyhdL4sgZR7CweKekREo1dHiL/efhmxrmT97J3MjfTHbjAa3+mr2QnYGb0/N8YGbe55csrr/ZTZkwQ0n10nfGYPOkEZAEAyHvYz+V0I46bq1TWWddBhq/MJLU/Exl/14oPvdjI28QuZyiuPn6Bteyzm8UkKhETz9mefl32jM1EsGgT2Njk0Lc+2ItNs39EoaQdh42VAaaHzy6AI0Fg9EAXwXmQwTdBDwC1Vy+k5oyFZUWMPVmBuLqFGlZCK8cYVGUp3hq9wNo9dMgbYWorC7iPMB2+eYNQ+NTSkkZZ4Dr2tE7TbEViNggxc4fkIiRKd/6prcQ+ycE3l9kJgufJ1dlQ4ahhFQzl6NYTk4BGpxTecseDaNqH1U/gsUhkSJZq4M5Az44Qy6YsZ6BWuFvoo5jtsfQNUvFsfUsOqGC72EGlvPvYiJ9W7/EGA2xeisch5LZn+6Qjdk6o1aX6ttNmzX+5aHY/vL52PWdpegrm+bXnnxrhtp5KqY4H7jQbfWKO+aClmbTE/8iL2zU61pEd9jFXk8icHRB4OZO5TvWhj1MgoORytZKT2ZrmA61Qw5jRYK3iYqeOeMkHQz/F7JzSbj2QeJV/uvPhBkjh5C/sfA++4UN3AUdxtS3eaN7CgY2jV2KpH65KvhiveXkkiG7SoqdDSlHNnKK/3HoNtGp1YwboQ8W1z0DOhkwNebHh7RGfwsGqpmnyNPZg4K1chsEdW51VpU6txPpxrjRTYMaYM0ejNofpIUB7Cr7kk9KO5/DZBMn3E6I3HonL4SC/gSNEhovtxZ46qHOVme5z0p87Xnlsp9L45FCBz/AJCTEJ2RytoHRXtmxrRpPBrB2Nawg9ceRE4/cqmMj0MYMxYDWlq/U7hdb6tq4AfEhOLtwLaVEM8h+6qMtz9JGb9FLruC+dX1rftXshZUvNec6hq6iDdPzgAAH3YmgUw9B34eZiHClFQm9OJtp8IQaKaGfV+HFFNYZc7nNTyC4LVMqNCa7PvGy3VbYjWPtNIhsAo1aZkFi4e+aa56UcC4XTW+usgxo31BJs8pTD3FCa3s2un+IG06/AJunrXYeMmEo8wm5L4X8agp49iigav2YGB/FAzmAjgWPxa16KXUx7i0Efc1GFrLJ8eK0ZPzMGRvbfssmOwjh36198MD7ZZZDjSBtB4uV+knbkL4BEsu28RBYxZczPv45c6lwJnhemk3PpYgr5IucEh38P8ILuEHpsKfqhSDeUM/87Ld1xHwzsJDjRxZHJ2OQWRnfKU7w7e3Tp3cvL7hIN0SX1OFZjrRKzUAvVXXq//qq8TXWfubhw+fDR5sxqtanbdut3qmnp7lIy2OGCfS40IJbXZySjLkQFMG87oI5Fhs6UpBPPgg3GyWPQ2/qbqwTi9D5X1uAU4uEwoIUm6ULMrj9FXotlq2Vm7LRABY7WFkcgtV5eOh2tTDy1C7UJBQNoPb9L8hQfYpZoh41Rmebqym3p1GiuofIPmcacqWdq3kiyvQBkMTD6QSYEJAEat0kne6w+1etUlrhUwhPoiUNroG4Blfdc6jpoohobETPZPMj0+morn8BC/reVLacxr902N/eGVQTkknBCMJWwgpnSwk78qkCyWAD10fO+pI8NulWb0QG5TZZfx97pkRhELPV87Kp0E/Uzjon8iK6Hy4F33SGNd9dCLvNrYQ/LV7tzb7H7y0wEBnVHfP98ecnLXWih5dGvuns3OaqHAs4OyWQx1zS+9ZMxni7lAD/hK7GDOmemySF2orKWmmwE1aGEt7DD+Fws/1IkgdG8XYt1fz3S6MgTf4yRFZvCHNfNHlmdyha8hypZT1+76zwc8kPtdUNGZHuwvJ2+mBxtWvfU7z857mcn52CpQUwCSJeA4a1DOYtq0W2/YktKZozrAA+ZWhte76U4J8LkN3ZhB4ZK2YoxHlgO6DPOfTClsaE42hM+GkHC6CsEEuABCs68aNilKdsM048xuEh2AuX/+LWehsL3DnKJfPjqcsod2cdEQPCArWS/UX/3OXgwANBi9smGJAqlSAqxFaLYgfmPdUsYR6G4IWWabfX/1PlVyYowyl+2Zit9s8pUGKnwVvo0x4GTBB6fohn1PO4U3NqK5r3ORCi0Iml3w7JCOlbdwazGHC9BP6uHJA2EHSLCUVS2vtRfuyMFF3Y2Td0EN0xQ3HBLGtJfQDJ4OEyBW3DxRe+jWFz/FgOyoyMegiRh+IV02bptyTgprfj8TASylp87G1nIVzqrLqZTYCxZHNPa0fTFss9L0CaCO35GPvV53HaeUZplvwOQZ9MRs80miIxlc2NHU1TWlWGKfqpbUpldSnVvcKaV6EAqBmvCpIb88NFbKclbeWZkrVSTwAfsG0zzpV1Xfy/6lmRrT4aBmhIEJPnFJMB2dQdZ571m3pvqloVClhUo0+RyntJuGkTWgEmMcrZCI7PtsTxXli9xzAa4OJIDXPmuJKqd2PoyZ9du86z/MbcKUm9F/JOWmO54zs9SNxBPK5uzVbn3Z7BSsPZOnbEb38+j/tRLCe0K9tpgEuLxNtZICCjQvCw0/GWL8wGV1p0UdEFyMV+FISXlG4HzxZxD14IxdncU0tOx7CXHLmYtEHWqyDARYMS5oQ5zAc0QCbXQjQcYSizHmm04qUmPHE//1Ine9gS9OnrMpGBJ/TSgsm6p6rmqlrIr1Qldu5xCBoKVoUWdZu1nSZ2dFp86oyQIQ9cCjr+JSl3jyySxD2k6pr01tkkibk1uxdkKQC3c3tgP2pUDy2lZknkYnBQRtN3RJqR0OqLQHk8b16I0eJhetI54O+utB0/03zpCk1T1LGf4XZe7LVVSUbhzX+UgfSGAss0FhNuTRp5nCpExulVswcCBTi5wDz3UGKMy1deBXoB95ZGIuXNb+x3RDLoJXIaZJ+1SbThtN56kmr0MjIKzncpZRPJ0vhFkhDqRgI7w/7WnPOxa3TQZzdUsTnllf80c/A2xdfWiYwI6v110fl4RrC/P1HFRFTOnKmSzdh+4ig3sUo7Hn9qwtjtoJajNFMyWdxtnbtLp4nolH+GKWHv7Ebi0Sxj4rqyhazDfrmVaUScvHvVCyF6+ftjzV5EElFMWUV+lQ0ixeP/R/n6Cl5MJ7uh2vciXOki+0Fc4Jt/HkrvWety06soCdg67yRyPJtGGk5PT0umfsf6KLCsA6xzNl6Uaygy+odr1tN/+zUkpsH+5gqHt5TI615FTmn/DBP+WJK/3Noy/uS9adMghMSy2maPG1xxEioYZkUgihi6aw+aDS65m4gU/gu+PPn15LbXcPOjmw2V2IghGeP2Z26/A0fnFlkj9WnAPD0LOL+iQNi4KlHSUYM7X8TpKMvBa159loQ2mQKk/1oIPfYcO5dWxwP6w38MHtv9Q6FrW/fzXgIOZGM+1ctu6QiS1GDevnwDiBPpNTfjQ5l3tt4WDxbJ1hyLW4/EXX6vVy+g4bhXqjVpk70k+5opGyzXg9nu3nClgScIhd1Q3SKwhYYSuIhpIsOXh3Z7OE7vV5+satxmDxLtAPUZ/t0LykWGojE9rAKMZEruBqjDHLl4l7z2ZEbBokv3tlwt1q/XP79NQpUpYsrhr3xIJvskZ4yz0olaJ9ABtKf+9LmuWKQ2iccN4LDMYLobykpVZfxXgJvbMfmzJosZ+wvKFQK4zlJAroQ8hywt4raFsCxrDK1lg046X8nUYiPO4k3rm4j3wS4V7fjX+AJY/ErEsaHwyacTo/uYRrxPYsN6GvM9ZO4cJ70kAtjk6+AF+Ch4F0JQpdJ3RX0oMHevLPH0fvqN2zDpEJFh+JrnTIeokmdcSlWzmgffw6UoIbzMiCBr2NB5LTUICNFuUfqdGF+HqORK1zf+PWEhaS4H4c3lY2ciFZ6R6KnbZ69fW3q0+/ut9EnHuCqFjP+9NscRieJ6gLWsHjwc6plBdN8qGEvbzkHAYMA4at29GvTSICnRcfqEvR+dyt/CjRG39ZbweM/8bu+MNOJUpKqz1NXhbRKgI1i4LMqTC1M/JQGBX3BXkXzKJw9TI8QeZpRGmttYkjOGJcGp3dML13H0Yu7uIY9GvsVlsIuAUN4c9BAMtvPstmfKNwPVXdoQVoqQmmDcXtw+oiW45KpszAQRM0BMh8wJHPvK21zEIJvyNzeppRE5tJ+LjZ3uLmfX6bVIkuYhmXa/tW86wCCUW5jvpkkGCm6F/G5ToabUoAJ+RXjIUM0bi/dF7H4OVbtDLyXqbpAw8XhDJGarT5HCsjPVWJ5x3F6NR9RTkWL0rcBAxqDlqakYhnVWnlLMkhppDW8qdCr+soPebafKd+ZQir2TpGhiHa7wiBbQAXDxE/8APNjjwXRPu8uRtMAY8nnIrcAZHNNyqqeOdv7Py4e/Pq9Ga5gq2evXUaThB5q0lWdcNXJQlQ++gljAGLUXxx4KaDFreOMWC3KLJsjbd7j+QY2lh5NUlFMvHfas1dK7hP7fU60xomDs90k7WhzeUruFQC00lUfilioyygNyoT+yhQ1t6CMRNxqfk+XRNwbSRQOnyKiS8dTNoKwk20B4mq4s21X9vJWIfV8KEfRAMIwRyx5zAgsnTsoCn+jQkpD0Y/j22uGfwS7SjZAoRNOU8yv8sgezkZ49CgiAFcdWuBGSH9PCU5N6GON3RtfmnLJIwA4LnxviRGak9yMid04i5t0PVpVF5vBG0WiHQLdjCA9Ui5cDlG3mCc0U/WRdo4pE/eHGpp9V+LQMs89HVGleEYwRVXhR7jPaRiABl5x/f5yInJCz+pF+bRoKuKXbrgdaoprJX2v1QNlYJ5hjKDGTxZ7I71sQb3XbejtP7Uzc9dqwJlqVR1BCJ+OhD+yRRqKpIXyn+bnky2+JO1XRag7Uc9qqFsErYddHYrTQ2+MiXGnTDqWmdWpQ8pSvQvRMmiGqS8GdQBm+TzivYwbETUhImusk6zgz1qpLCgI3uhdx2L2BPfPQJJ4teknHLrRxG8xJk1+TuYEIE/tjjXlxPF1q191ghe4IeBMLXZbrQ5oyGQ8x3pi5FO3YGkSQ1Prr86aQf0gQycLBo+/hqnm0JRzCtkWiA7up0/pAZ/mkJQ8ktMVQJDfC79y1YfoTdkHb9o/FP5D6GilMHIBK/r+DFCk5STDhklv+4ebu1KaJ9VIdfM0cneqLIlQFoBVx1GrOXlDUlqS+lz9eGvIA4Pu711k6Dq8QAAAAA==";var Ce=(e)=>e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;");var ME=`
602
602
  :root {
603
603
  --page: #f6f5f3; --paper: #ffffff; --ink: #1c1b19; --muted: #6f6b64; --line: #e4e2de; --code: #f3f2ef;
604
604
  --orange: #f2891f; --link: #b9560a; --wax: #c8392f; --navy: #26315f;
@@ -648,16 +648,16 @@ th { font-weight: 700; }
648
648
  .button:focus-visible, a:focus-visible { outline: 3px solid color-mix(in srgb, var(--orange) 55%, transparent); outline-offset: 2px; }
649
649
  .brand { display: inline-flex; align-items: center; gap: 0.6rem; font-weight: 700; font-size: 1.15rem; color: var(--ink); text-decoration: none; letter-spacing: -0.01em; }
650
650
  .brand img { border-radius: 22%; }
651
- `;function qg(e,t,n,r=`<link rel="icon" href="${gn}">`){return`<!doctype html>
651
+ `;function pv(e,t,n,r=`<link rel="icon" href="${Sn}">`){return`<!doctype html>
652
652
  <html lang="en">
653
653
  <head>
654
654
  <meta charset="utf-8">
655
655
  <meta name="viewport" content="width=device-width, initial-scale=1">
656
- <title>${Te(e)}</title>
657
- ${n?`<meta name="description" content="${Te(n)}">
656
+ <title>${Ce(e)}</title>
657
+ ${n?`<meta name="description" content="${Ce(n)}">
658
658
  `:""}${r}
659
- <style>${nE}${t}</style>
660
- </head>`}var rE=`
659
+ <style>${ME}${t}</style>
660
+ </head>`}var UE=`
661
661
  body { padding: 7vh 16px 48px; }
662
662
  .card { max-width: 580px; margin: 0 auto; background: var(--paper); border: 1px solid var(--line); border-radius: 16px; padding: 2rem 2rem 1.4rem; box-shadow: 0 1px 2px rgb(0 0 0 / 4%), 0 14px 36px rgb(20 20 30 / 7%); }
663
663
  .card .brand { margin-bottom: 1.6rem; }
@@ -673,41 +673,41 @@ 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="">
677
- `:n?`<div class="status fail">${iE}</div>
678
- `:"";return`${qg(`${e} \xB7 tapster`,rE)}
676
+ `,GE='<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 Vc(e,t,n){let r=n==="ok"?`<img class="hero" src="${_o}" width="168" height="168" alt="">
677
+ `:n?`<div class="status fail">${GE}</div>
678
+ `:"";return`${pv(`${e} \xB7 tapster`,UE)}
679
679
  <body>
680
680
  <main class="card">
681
- <span class="brand"><img src="${gn}" width="34" height="34" alt="">tapster</span>
682
- ${r}<h1>${Te(e)}</h1>
681
+ <span class="brand"><img src="${Sn}" width="34" height="34" alt="">tapster</span>
682
+ ${r}<h1>${Ce(e)}</h1>
683
683
  ${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 dv(e){return Vc(e.title,`<p class="lead">${Ce(e.lead)}</p>
688
688
  <dl class="facts">
689
689
  <dt>What it may do</dt>
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>
690
+ <dd><ul>${e.permissions.map((t)=>`<li>${Ce(t)}</li>`).join("")}<li>Nothing else. It has no webhook and receives no events.</li></ul></dd>
691
691
  <dt>Where its key goes</dt>
692
- <dd>${Te(e.key)}</dd>
692
+ <dd>${Ce(e.key)}</dd>
693
693
  </dl>
694
- <form method="post" action="${Te(e.action)}">
695
- <input type="hidden" name="manifest" value="${Te(e.manifest)}">
694
+ <form method="post" action="${Ce(e.action)}">
695
+ <input type="hidden" name="manifest" value="${Ce(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>
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>
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(`
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(`
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 hv(e){return Vc(e.title,`<p class="lead">Back in your terminal, tapster takes it from here:</p>
699
+ <ol class="next">${e.next.map((t)=>`<li>${Ce(t)}</li>`).join("")}</ol>
700
+ <p class="local">You can close this tab.</p>`,"ok")}function Yc(e){return Vc("Nothing was set up",`<p class="lead">${Ce(e.reason)}</p>
701
+ <p>Run <code>${Ce(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 Jt(e){console.log(` ${e}`),L(process.platform==="darwin"?"/usr/bin/open":"/usr/bin/xdg-open","open",[e],{allowFail:!0}).catch(()=>{return})}var ZE={"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 Jc(e){let t=e.default_permissions??{};return Object.entries(t).map(([n,r])=>{let s=ZE[`${n}:${r}`];if(!s)throw new g(`the App asks for ${n}: ${r}, which tapster cannot explain`,"Report this at https://github.com/doguyilmaz/tapster/issues.");return s})}var qE={"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 BE(e){let t=`http://127.0.0.1:${e.port}`,n=!1,r=(s,o=200)=>new Response(s,{status:o,headers:qE});return(s)=>{if(s.headers.get("host")!==`127.0.0.1:${e.port}`)return new Response("Forbidden",{status:403});let o=new URL(s.url);if(o.pathname==="/start"){let a=e.manifest(`${t}/callback`);return r(dv({...e.copy,permissions:Jc(a),action:`https://github.com/settings/apps/new?state=${e.state}`,manifest:JSON.stringify(a)}))}if(o.pathname!=="/callback")return new Response("Not found",{status:404});if(n)return r(Yc({reason:"This App was already handled.",again:e.copy.again}),409);let i=o.searchParams.get("code");if(o.searchParams.get("state")!==e.state||!i||!/^[A-Za-z0-9_-]{1,128}$/.test(i))return r(Yc({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:i}),r(hv({title:e.copy.done,next:e.copy.next}))}}function FE(e,t){let n=e.owner?.login??"nobody";if(n.toLowerCase()!==t.toLowerCase())throw new g(`the new App belongs to ${n}, not ${t}`,"tapster stored nothing. Create the App from your own account, then run this again.")}async function ko(e,t,n){let r=HE(16).toString("hex"),s=()=>{},o=new Promise((p)=>s=p),i=()=>new Response(null,{status:503}),a=Bun.serve({hostname:"127.0.0.1",port:0,fetch:(p)=>i(p)});i=BE({manifest:e,copy:t,state:r,port:a.port,settle:s}),console.log(`Opening GitHub to create ${t.what}. Read the page, then click "Continue to GitHub" and "Create GitHub App".`),Jt(`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(()=>s({error:new g("no App was created within 30 minutes",`${c} Then run ${t.again} again.`)}),1800000),u=await o;if(clearTimeout(l),setTimeout(()=>a.stop(),1000),"error"in u)throw u.error;return Qc(u.code,n,`${c} Then run ${t.again} again.`)}async function Qc(e,t,n,r=fetch){let s=await r(`https://api.github.com/app-manifests/${e}/conversions`,{method:"POST",headers:{Accept:"application/vnd.github+json"}});if(!s.ok)throw new g(`GitHub did not hand over the new App (status ${s.status})`,n);let o=await s.json();return FE(o,t),o}var fv=()=>({HOME:process.env.HOME??"/tmp",...process.env.GH_CONFIG_DIR?{GH_CONFIG_DIR:process.env.GH_CONFIG_DIR}:{},GH_PROMPT_DISABLED:"1"});function mv(e){try{return tv(e)}catch{throw new g("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 Rt(){let e=await L(mv(),"gh",["auth","token"],{env:fv(),allowFail:!0}),t=e.stdout.trim();if(e.code!==0||!t)throw new g("gh is not signed in","Run gh auth login, then try again.");return new fe(t,fetch,void 0,"user")}async function Je(e=process.cwd()){let t=(await Ve(e,["remote","get-url","origin"])).stdout.trim(),n=/github\.com[:/]([A-Za-z0-9-]+\/[A-Za-z0-9._-]+?)(?:\.git)?$/.exec(t);if(!n)throw new g("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 xo=async(e,t)=>{await L(mv(),"gh",e,{env:fv(),stdin:t})};var se=(e,t,n,r="tapster")=>xo(["secret","set",t,"--env",r,"--repo",e],n),Me=(e,t,n)=>xo(["variable","set",t,"--env","tapster","--repo",e,"--body",n]),So=(e,t,n)=>xo(["variable","set",t,"--repo",e,"--body",n]),gv=(e,t,n="tapster")=>xo(["secret","delete",t,"--env",n,"--repo",e]);async function Qt(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 g(`${t} has no tapster environment yet`,"Run tapster init in a clone of the hub first.");throw r}}import{lstatSync as yv,readFileSync as KE}from"fs";import{mkdir as WE,readFile as VE,writeFile as YE}from"fs/promises";import{join as vv}from"path";function An(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 g("no path was given","Type the path or drag the file into the terminal.");return n.replace(/^~(?=\/|$)/,t)}async function $n(e,t){try{return await VE(e)}catch(n){let r=n.code;if(r==="ENOENT")throw new g(`${e} does not exist`,`Check the path of ${t}.`);if(r==="EISDIR")throw new g(`${e} is a folder`,`Give the path of ${t} itself.`);throw new g(`${e} cannot be read`,`Check that you can open ${t}.`)}}function Ao(e,t=1048576){try{let n=yv(e);if(!n.isFile()||n.size>t)return null;return KE(e)}catch{return null}}var oe=(e,t=1048576)=>Ao(e,t)?.toString("utf8")??null;function $r(e,t,n=1048576){let r=oe(e,n);if(r===null)throw new g(`${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 bv=(e)=>{try{return yv(e)}catch{return null}};async function Tr(e,t,n){let r=t.split("/"),s=e;for(let a of r.slice(0,-1)){s=vv(s,a);let c=bv(s);if(c&&!c.isDirectory())throw new g(`${t} would be written through a link or a file`,"Replace the link with a real folder, then try again.");if(!c)await WE(s)}let o=vv(e,t),i=bv(o);if(i&&!i.isFile())throw new g(`${t} is not a regular file`,"Replace the link with the file itself, then try again.");await YE(o,n)}async function $o(e,t={}){let{timeoutMs:n=600000,intervalMs:r=3000,sleep:s=(a)=>new Promise((c)=>setTimeout(c,a)),now:o=Date.now}=t,i=o()+n;for(;;){let a=await e();if(a!==null)return a;if(o()+r>i)return null;await s(r)}}import{createInterface as JE}from"readline";function be(e,t=!1){return new Promise((n)=>{let r=JE({input:process.stdin,output:process.stdout,terminal:!0});if(t)r._writeToOutput=(s)=>{if(s.includes(e))process.stdout.write(e)};r.question(e,(s)=>{if(r.close(),t)process.stdout.write(`
703
+ `);n(s.trim())})})}import{mkdtempSync as QE,rmSync as XE}from"fs";import{tmpdir as eO}from"os";import{join as tO}from"path";var Xc=new Set;function It(e){let t=QE(tO(eO(),e));return Xc.add(t),t}function Qe(e){XE(e,{recursive:!0,force:!0}),Xc.delete(e)}function nO(){for(let e of[...Xc])Qe(e)}process.on("SIGINT",()=>{nO(),process.exit(130)});function To(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 g(`${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 lt(e){let t=Y(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 wv(e){if(e<60)return`*/${e} * * * *`;return e===60?"0 * * * *":`0 */${e/60} * * *`}var _v=(e)=>e.default,Or=(e)=>cv.trimEnd().split(`
704
704
  `).map((t)=>`${" ".repeat(e)}${t}`).join(`
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)}
706
- `}function AE(e){for(let t of e.split(`
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}
705
+ `);function iO(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 aO(e){for(let n of["APP_ID","INSTALLATION_ID","HUB_ID","OWNER_ID","INTERVAL"])if(!/^[0-9]+$/.test(e[n]))throw new g(`${n} must be a number`,"Run tapster init --doorbell again.");if(!/^[A-Za-z0-9-]+\/[A-Za-z0-9._-]+$/.test(e.HUB))throw new g("the hub name is not owner/repo","Run it in the hub clone.");let t={crons:[wv(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)}
706
+ `}function cO(e){for(let t of e.split(`
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 lO(e){let t=`${e.stdout}
708
708
  ${e.stderr??""}`.split(`
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
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 uO=(e)=>({PATH:e,BUN_BE_BUN:"1"});function xv(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 Er="Run tapster init --doorbell again; it continues with the App it already created.";async function Sv(e,t){console.log(`Open the doorbell App's settings, scroll to "Private keys" and click "Generate a private key":`),Jt(`https://github.com/settings/apps/${t}`);let n=An(await be("Path of the downloaded .pem file (drag it here): ")),r=(await $n(n,"the .pem file")).toString("utf8");return await new fe(Ye(e,r)).json("GET","/app").catch(()=>{throw new g("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 pO(){for(let e of(process.env.PATH??"").split(el))if(e&&kv(Xe(e,"node")))return Xe(e,"node");throw new g("Wrangler needs Node.js, which is not on PATH","Install Node.js 20 or newer, then run this again.")}async function Av(){let e=It("tapster-doorbell-");await Pr(Xe(e,"package.json"),`${JSON.stringify(uv,null,2)}
710
+ `),await Pr(Xe(e,"bun.lock"),lv),await L(process.execPath,"bun",["install","--frozen-lockfile","--ignore-scripts"],{cwd:e,env:uO(process.env.PATH??"")});let t=pO(),n=Xe(e,"node_modules","wrangler","bin","wrangler.js"),r=Object.fromEntries(["CLOUDFLARE_API_TOKEN","CLOUDFLARE_ACCOUNT_ID"].flatMap((o)=>process.env[o]?[[o,process.env[o]]]:[])),s={PATH:`${Xe(t,"..")}${el}/usr/bin${el}/bin`,WRANGLER_SEND_METRICS:"false",...r};return{dir:e,run(o,i={}){if(i.interactive)return new Promise((a)=>{sO(t,[n,...o],{cwd:e,stdio:"inherit",env:{HOME:process.env.HOME??"",...s,...i.env}}).on("close",(l)=>a({code:l??1,stdout:""}))});return L(t,"wrangler",[n,...o],{cwd:e,env:{...s,...i.env},stdin:i.stdin,allowFail:!0})}}}async function $v(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 g("Wrangler could not sign in to Cloudflare","Run tapster init --doorbell again.")}async function Tv(e,t,n){let r=new fe(Ye(e,t));console.log(`Waiting until the App is installed on ${n} (only that repository); tapster continues by itself.`);let s=await $o(()=>r.json("GET",`/repos/${n}/installation`).then((o)=>o.id,()=>null));if(s!==null)return s;throw new g(`the doorbell App was not installed on ${n} within 10 minutes`,`Install it on ${n}, then ${Er.charAt(0).toLowerCase()}${Er.slice(1)}`)}async function Pv(e,t,n,r,s,o,i){let a=(await t.json("GET",`/users/${n.split("/")[0]}`)).id,c=(await t.getRepo(n)).id;await Pr(Xe(e.dir,"worker.ts"),_v(Wc)),await Pr(Xe(e.dir,"jwt.ts"),_v(Kc)),await Pr(Xe(e.dir,"wrangler.jsonc"),aO({APP_ID:r,INSTALLATION_ID:String(i),HUB:n,HUB_ID:String(c),OWNER_ID:String(a),INTERVAL:String(o)}));let l=Xe(e.dir,"out.ndjson"),u=await e.run(["deploy"],{env:{WRANGLER_OUTPUT_FILE_PATH:l}});if(u.code!==0)throw new g(`Wrangler could not deploy the doorbell: ${lO(u)}`,Er);let p=cO(kv(l)?oO(l,"utf8"):"");if(!p)throw new g("the doorbell has no workers.dev address",`Create your workers.dev subdomain in the Cloudflare dashboard (Workers & Pages). ${Er}`);let d=rO(s).export({type:"pkcs8",format:"pem"}).toString();if((await e.run(["secret","put","APP_KEY"],{stdin:d})).code!==0)throw new g("Wrangler could not store the doorbell key",Er);return await Me(n,"TAPSTER_DOORBELL_EVERY",String(o)),p}async function Ev(e,t,n,r,s){let o={variables:(await Qt(e,t,"variables")).map((c)=>({name:c.name,value:c.value??""}))},i=xv(o);if(i==="done")throw new g("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 Av();try{await $v(a);let[c]=t.split("/"),l,u;if(i==="resume")l=o.variables.find((d)=>d.name==="TAPSTER_DOORBELL_APP_ID").value,console.log("Continuing with the doorbell App created earlier."),u=await Sv(l,o.variables.find((d)=>d.name==="TAPSTER_DOORBELL_APP_SLUG").value);else{let d=await ko((h)=>iO(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 Me(t,"TAPSTER_DOORBELL_APP_ID",l),await Me(t,"TAPSTER_DOORBELL_APP_SLUG",d.slug),Jt(`https://github.com/apps/${d.slug}/installations/new`)}let p=await Pv(a,e,t,l,u,s,await Tv(l,u,t));for(let d of n.packages)await r(d.repo,"TAPSTER_DOORBELL",p);await Me(t,"TAPSTER_DOORBELL",p),console.log(`The doorbell answers at ${p}. Projects ring it after opening a draft.`)}finally{Qe(a.dir)}}async function Ov(e,t,n){let r=await e.json("GET",`/repos/${t}/environments/tapster/variables`);if(xv(r)!=="done")throw new g("the hub has no working doorbell yet","Run tapster init --doorbell.");let s=r.variables.find((a)=>a.name==="TAPSTER_DOORBELL_APP_ID").value,o=await Sv(s,r.variables.find((a)=>a.name==="TAPSTER_DOORBELL_APP_SLUG").value),i=await Av();try{await $v(i),await Pv(i,e,t,s,o,n,await Tv(s,o,t))}finally{Qe(i.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 et={"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 Cv=`name: release
711
711
  on:
712
712
  push:
713
713
  tags: ["v[0-9]+.[0-9]+.[0-9]+"]
@@ -760,7 +760,7 @@ __CARRY__
760
760
  env: { GH_TOKEN: "\${{ github.token }}", TAG: "\${{ github.ref_name }}" }
761
761
  run: gh release create "$TAG" dist/* --draft --verify-tag --generate-notes --title "$TAG"
762
762
  __RING__
763
- `;var qc=`name: release
763
+ `;var tl=`name: release
764
764
  on:
765
765
  push:
766
766
  tags: ["v[0-9]+.[0-9]+.[0-9]+", "v[0-9]+.[0-9]+.[0-9]+-*"]
@@ -811,39 +811,42 @@ jobs:
811
811
  env: { GH_TOKEN: "\${{ github.token }}", TAG: "\${{ github.ref_name }}" }
812
812
  run: gh release create "$TAG" dist/*.tar.gz dist/*.zip dist/checksums.txt --draft --verify-tag --generate-notes --title "$TAG" $( [ "\${TAG#*-}" != "$TAG" ] && echo --prerelease )
813
813
  __RING__
814
- `;function ys(e){if(!/^[A-Za-z0-9-]+\/[A-Za-z0-9._-]+$/.test(e))throw new v(`${e} is not a repository name`,"Name the hub as owner/repo, for example you/homebrew-tap.");return e}function bs(e,t){let n=(i)=>i.replace(/^\.\//,"");if(typeof e.bin==="string")return{bin:(e.name??t).replace(/^@[^/]+\//,""),entry:n(e.bin)};let r=Object.entries(e.bin??{})[0];return r?{bin:r[0],entry:n(r[1])}:null}var RE=[["darwin-arm64","darwin_arm64.tar.gz"],["darwin-amd64","darwin_amd64.tar.gz"],["linux-arm64","linux_arm64.tar.gz"],["linux-amd64","linux_amd64.tar.gz"],["windows-amd64","windows_amd64.zip"]];function Hc(e,t,n,r,i,s){return[` - name: ${e}`,` repo: ${t}`,` kind: ${n}`,` binaries: [${r.join(", ")}]`," assets:",...i.map(([o,a])=>` ${o}: "${a}"`),` scoop: ${s}`].join(`
815
- `)}var uv=(e,t,n)=>Hc(e,t,"bun",[n],RE.map(([r,i])=>[r,`${n}_{version}_${i}`]),!0),vs={darwin_all:"darwin-universal",darwin_universal:"darwin-universal",darwin_arm64:"darwin-arm64",darwin_amd64:"darwin-amd64",linux_arm64:"linux-arm64",linux_amd64:"linux-amd64",windows_amd64:"windows-amd64",windows_arm64:"windows-arm64"};function Fc(e,t,n,r,i){if(!i)return{entry:null,reason:"the project has its own release workflow and no release yet; run tapster add again after the first draft"};let s=[];for(let o of i.assets){let a=Object.keys(vs).find((c)=>o.includes(c));if(a&&!s.some(([c])=>c===vs[a]))s.push([vs[a],o.replaceAll(i.version,"{version}")])}if(s.length===0)return{entry:null,reason:"the latest release has no archives tapster recognizes"};return{entry:Hc(e,t,n,r,s,s.some(([o,a])=>o.startsWith("windows")&&a.endsWith(".zip"))),reason:null}}function pv(e,t,n,r){let i=(n?ne(n):null)??{},s=i.project_name??e,o=[...new Set((i.builds??[]).map((h)=>h.binary??s))],a=o.length?o:[s];if(r)return Fc(e,t,"go",a,r);if((i.archives??[]).some((h)=>h.name_template!==void 0))return{entry:null,reason:"GoReleaser names the archives with its own template; run tapster add again after the first draft"};let c=(i.archives??[]).some((h)=>(h.format_overrides??[]).some((f)=>f.goos==="windows"&&(f.format==="zip"||f.formats?.includes("zip")))),l=i.builds?.[0]?.goos??["linux","darwin","windows"],u=i.builds?.[0]?.goarch??["amd64","arm64"],p=[],d=i.universal_binaries?.[0];for(let h of l)for(let f of u){let m=vs[`${h}_${f}`];if(!m||h==="darwin"&&d?.replace)continue;p.push([m,`${s}_{version}_${h}_${f}.${h==="windows"&&c?"zip":"tar.gz"}`])}if(d&&l.includes("darwin"))p.unshift(["darwin-universal",`${s}_{version}_darwin_all.tar.gz`]);return{entry:Hc(e,t,"go",a,p,c&&l.includes("windows")),reason:null}}var kr={lineWidth:0,blockQuote:"literal"},Bc=(e)=>e.replace(/([[{])\s+/g,"$1").replace(/\s+([\]}])/g,"$1");function xr(e,t){let n=new Map;for(let r of e.split(`
816
- `))n.set(Bc(r),[...n.get(Bc(r))??[],r]);return t.split(`
817
- `).map((r)=>n.get(Bc(r))?.shift()??r).join(`
818
- `)}function IE(e,t,n){let r=yt(e);if((r.toJS().packages??[]).some((l)=>l?.name===n))throw new v(`${n} is already in the hub's tapster.yml`,"Edit its entry there instead.");let s=r.get("packages",!0);if(!vt(s))throw new v("the hub's tapster.yml has no packages list","Add packages: [] to it.");let[o,a]=s.range??[0,0];if(s.flow&&s.items.length===0)return`${e.slice(0,o).replace(/[ \t]+$/,"")}
819
- ${t}${e.slice(a)}`;if(!s.flow){let l=e.slice(0,a);return`${l}${l.endsWith(`
814
+ `;function Xt(e){let t=null;for(let n of e){let r=ee(n);if(r&&(t===null||Oe(r,ee(t))>0))t=n}return t}function Po(e){let t=e?ee(e):null;if(!t)return"v0.1.0";return t.pre===null?`v${t.major}.${t.minor}.${t.patch+1}`:`v${t.major}.${t.minor}.${t.patch}`}function Rv(e,t){let n=ee(e);if(!n)return"Use the shape v1.2.3, such as v1.2.3 or v1.2.3-rc.1";if(t&&Oe(n,ee(t))<=0)return`Pick a version higher than ${t}, the highest tag on GitHub`;return null}function Iv(e,t,n){let r=`gh api --method POST repos/${e}/git/refs -f ref=refs/tags/${t} -f sha=`;if("sha"in n)return/^[0-9a-f]{40,64}$/.test(n.sha)?`${r}${n.sha}`:null;return/^[A-Za-z0-9._/-]+$/.test(n.branch)?`${r}"$(gh api repos/${e}/commits/${n.branch} --jq .sha)"`:null}var mO=(e,t)=>`${e} ${t}${e===1?"":"s"}`;function Nv(e){if(e.unreadable)return[{id:"setup",state:"attention",label:"GitHub did not show it"}];let t=e.release,n=t.draft?.note?{id:"release",state:"attention",label:`Fix the draft ${t.draft.tag}`}:t.draft?{id:"release",state:"wait",label:`The hub publishes ${t.draft.tag} next`}:t.latest?.byHub?{id:"release",state:"done",label:`Published ${t.latest.tag}`}:t.atHead?{id:"release",state:"done",label:`Nothing new since ${t.atHead}`}:{id:"release",state:"open",label:t.autoTag?"Release from the workflow":`Release ${t.next}`},r=[{id:"setup",state:e.setup.ok?"done":"open",label:"Set up the release workflow"},{id:"protect",state:e.protection.ok||e.protection.off?"done":"open",label:"Protect the repository"},{id:"entry",state:e.entry.state==="merged"?"done":"open",label:e.entry.state==="proposed"?"Merge the hub entry":"Propose the hub entry"},e.app.reaches===!0?{id:"app",state:"done",label:"Install the App"}:e.app.running?{id:"app",state:"wait",label:"The hub checks its App"}:{id:"app",state:"open",label:e.app.reaches===!1?"Install the App":"Let the hub check its App"},n];if(e.secrets.names.length&&e.secrets.published)r.push({id:"secrets",state:"open",label:`Delete ${mO(e.secrets.names.length,"old secret")}`});return r}var gO=(e)=>Nv(e).find((t)=>t.state!=="done")??null,vO=["setup","protect","entry","app"],bO=(e)=>Nv(e).every((t)=>!vO.includes(t.id)||t.state==="done");function zv(e,t){if(e===null)return{done:t>0,status:t?`${t} in the hub`:"None yet"};let n=e.filter((s)=>!bO(s));if(n.length===1)return{done:!1,status:`${n[0].name}: ${gO(n[0]).label}`};if(n.length>1)return{done:!1,status:`${n.length} projects need you`};let r=e.filter((s)=>s.entry.state==="merged").length;return{done:r>0,status:r?`${r} in the hub`:"None yet"}}async function F(e,t,n,r){try{let s=await e.json("GET",`/repos/${t}/contents/${n}?ref=${r}`);return Buffer.from(s.content,"base64").toString("utf8")}catch(s){if(s instanceof R&&s.status===404)return null;throw s}}async function nl(e,t,n,r){for(let s=0;s<5;s++){let i=(await e.json("GET",`/repos/${t}/git/ref/heads/main`)).object.sha,a=await e.json("GET",`/repos/${t}/git/commits/${i}`),c=await r((p)=>F(e,t,p,i));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:[i]});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 g("the hub's main branch kept moving","The next run retries.")}function Co(e){if(!/^[A-Za-z0-9-]+\/[A-Za-z0-9._-]+$/.test(e))throw new g(`${e} is not a repository name`,"Name the hub as owner/repo, for example you/homebrew-tap.");return e}function Ro(e,t){let n=(s)=>s.replace(/^\.\//,"");if(typeof e.bin==="string")return{bin:(e.name??t).replace(/^@[^/]+\//,""),entry:n(e.bin)};let r=Object.entries(e.bin??{})[0];return r?{bin:r[0],entry:n(r[1])}:null}var yO=[["darwin-arm64","darwin_arm64.tar.gz"],["darwin-amd64","darwin_amd64.tar.gz"],["linux-arm64","linux_arm64.tar.gz"],["linux-amd64","linux_amd64.tar.gz"],["windows-amd64","windows_amd64.zip"]];function sl(e,t,n,r,s,o){return[` - name: ${e}`,` repo: ${t}`,` kind: ${n}`,` binaries: [${r.join(", ")}]`," assets:",...s.map(([i,a])=>` ${i}: "${a}"`),` scoop: ${o}`].join(`
815
+ `)}var jv=(e,t,n)=>sl(e,t,"bun",[n],yO.map(([r,s])=>[r,`${n}_{version}_${s}`]),!0),Eo={darwin_all:"darwin-universal",darwin_universal:"darwin-universal",darwin_arm64:"darwin-arm64",darwin_amd64:"darwin-amd64",linux_arm64:"linux-arm64",linux_amd64:"linux-amd64",windows_amd64:"windows-amd64",windows_arm64:"windows-arm64"};function ol(e,t,n,r,s){if(!s)return{entry:null,reason:"the project has its own release workflow and no release yet; run tapster add again after the first draft"};let o=[];for(let i of s.assets){let a=Object.keys(Eo).find((c)=>i.includes(c));if(a&&!o.some(([c])=>c===Eo[a]))o.push([Eo[a],i.replaceAll(s.version,"{version}")])}if(o.length===0)return{entry:null,reason:"the latest release has no archives tapster recognizes"};return{entry:sl(e,t,n,r,o,o.some(([i,a])=>i.startsWith("windows")&&a.endsWith(".zip"))),reason:null}}function Lv(e,t,n,r){let s=(n?Y(n):null)??{},o=s.project_name??e,i=[...new Set((s.builds??[]).map((h)=>h.binary??o))],a=i.length?i:[o];if(r)return ol(e,t,"go",a,r);if((s.archives??[]).some((h)=>h.name_template!==void 0))return{entry:null,reason:"GoReleaser names the archives with its own template; run tapster add again after the first draft"};let c=(s.archives??[]).some((h)=>(h.format_overrides??[]).some((f)=>f.goos==="windows"&&(f.format==="zip"||f.formats?.includes("zip")))),l=s.builds?.[0]?.goos??["linux","darwin","windows"],u=s.builds?.[0]?.goarch??["amd64","arm64"],p=[],d=s.universal_binaries?.[0];for(let h of l)for(let f of u){let m=Eo[`${h}_${f}`];if(!m||h==="darwin"&&d?.replace)continue;p.push([m,`${o}_{version}_${h}_${f}.${h==="windows"&&c?"zip":"tar.gz"}`])}if(d&&l.includes("darwin"))p.unshift(["darwin-universal",`${o}_{version}_darwin_all.tar.gz`]);return{entry:sl(e,t,"go",a,p,c&&l.includes("windows")),reason:null}}var Cr={lineWidth:0,blockQuote:"literal"},rl=(e)=>e.replace(/([[{])\s+/g,"$1").replace(/\s+([\]}])/g,"$1");function Rr(e,t){let n=new Map;for(let r of e.split(`
816
+ `))n.set(rl(r),[...n.get(rl(r))??[],r]);return t.split(`
817
+ `).map((r)=>n.get(rl(r))?.shift()??r).join(`
818
+ `)}function wO(e,t,n){let r=xt(e);if((r.toJS().packages??[]).some((l)=>l?.name===n))throw new g(`${n} is already in the hub's tapster.yml`,"Edit its entry there instead.");let o=r.get("packages",!0);if(!kt(o))throw new g("the hub's tapster.yml has no packages list","Add packages: [] to it.");let[i,a]=o.range??[0,0];if(o.flow&&o.items.length===0)return`${e.slice(0,i).replace(/[ \t]+$/,"")}
819
+ ${t}${e.slice(a)}`;if(!o.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=xt(t).contents;if(!kt(c)||c.items.length!==1)throw new g("the entry is not one package","Report this as a tapster bug.");return o.flow=!1,o.items.push(c.items[0]),Rr(e,r.toString(Cr))}function _O(e,t){if(!e||Et(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),Et(n,t).length===0?n:null}var kO=["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"],xO=/^system_command\s+"#\{HOMEBREW_PREFIX\}\/bin\/([A-Za-z0-9._-]+)"(?:,\s*args:\s*\[((?:\s*"[A-Za-z0-9._:=@%+,\/-]+"\s*,?)*)\])?,\s*must_succeed:\s*false$/,SO=/^[A-Za-z0-9._-]+(\/[A-Za-z0-9._-]+)*$/;function Dv(e,t={}){let n=null;try{n=e?Y(e):null}catch{n=null}let r=n?.homebrew_casks?.[0]??n?.brews?.[0];if(!r)return{lines:[],description:null,carried:[],notes:[]};let s=(y)=>typeof y==="string"&&y.trim()&&!y.includes("{{")?y.trim():null,o=(y,b)=>Array.isArray(y)?y.map(s).filter((k)=>k!==null&&b.test(k)):[],i=[],a=[],c=[],l=Object.keys(r).filter((y)=>!kO.includes(y));l.push(...Object.keys(r.uninstall??{}).filter((y)=>y!=="launchctl"&&y!=="quit").map((y)=>`uninstall.${y}`)),l.push(...Object.keys(r.zap??{}).filter((y)=>y!=="trash").map((y)=>`zap.${y}`));let u=null;for(let y of String(r.custom_block??"").split(`
823
+ `).map((b)=>b.trim()).filter(Boolean)){let b=/^app\s+"([A-Za-z0-9 ._-]+\.app)"$/.exec(y)?.[1];if(b&&!u)u=b;else l.push(`custom_block: ${y}`)}let p=null;for(let[y,b]of Object.entries(r.hooks??{}))for(let[k,S]of Object.entries(b??{})){let O=y==="post"&&k==="install"?xO.exec(String(S).trim()):null;if(O)p={binary:O[1],args:[...(O[2]??"").matchAll(/"([^"]+)"/g)].map((x)=>x[1])};else l.push(`hooks.${y}.${k}`)}let d=s(r.homepage);if(d&&/^https:\/\/[^\s"]+$/.test(d))i.push(` homepage: ${JSON.stringify(d)}`),a.push("homepage");let h=s(r.license);if(h&&/^[A-Za-z0-9.+-]+$/.test(h))i.push(` license: ${h}`),a.push("license");let f=Object.entries(r.completions??{}).filter(([y,b])=>["bash","zsh","fish"].includes(y)&&/^[A-Za-z0-9._-]+(\/[A-Za-z0-9._-]+)*$/.test(s(b)??""));if(f.length)i.push(" completions:",...f.map(([y,b])=>` ${y}: ${s(b)}`)),a.push("completions");if(u&&t.mac!==!1){let y=`#{appdir}/${u}/`,b=o(r.binaries,/^#\{appdir\}\//).filter((S)=>S.startsWith(y)&&SO.test(S.slice(y.length))).map((S)=>S.slice(y.length)),k=t.bundleId?.(u)??null;if(i.push(" app:",` name: ${JSON.stringify(u)}`,` bundle_id: ${k??"<bundle id>"}`,...b.length?[` binaries: ${JSON.stringify(b)}`]:[]),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 -)`),!k)c.push(`no Info.plist here names ${u}; set app.bundle_id in the hub entry`)}let m=o(r.uninstall?.launchctl,/^[A-Za-z0-9.-]+$/),v=o(r.uninstall?.quit,/^[A-Za-z0-9.-]+$/),_=o(r.zap?.trash,/^~\/[A-Za-z0-9 ._\/-]+$/),A=s(r.caveats);if(m.length||v.length||_.length||p||A){if(i.push(" cask:"),m.length||v.length)i.push(" uninstall:",...m.length?[` launchctl: ${JSON.stringify(m)}`]:[],...v.length?[` quit: ${JSON.stringify(v)}`]:[]);if(_.length)i.push(" zap:",` trash: ${JSON.stringify(_)}`);if(p)i.push(` postflight: { binary: ${JSON.stringify(p.binary)}, args: ${JSON.stringify(p.args)} }`);if(A)i.push(` caveats: ${JSON.stringify(A.slice(0,2000))}`);a.push(...[m.length||v.length?"uninstall":"",_.length?"zap":"",p?"post-install command":"",A?"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:i,description:s(r.description),carried:a,notes:c}}function Mv(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(`
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
- `);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(`
825
+ protection: dependabot`;return n}function il(e,t,n=!1){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 r=Et(e,t);if(!r.length)return{};let s=_O(e,t);if(!s)return{line:`- Homebrew would reject the repository's description (${r.join(" and ")}); add description: to the hub entry before the first release`};if(n)return{line:`- Homebrew would reject the repository's description (${r.join(" and ")}); add description: ${JSON.stringify(s)} to the hub entry before the next release`};return{line:`- Homebrew would reject the repository's description (${r.join(" and ")}); the entry says "${s}" instead`,add:` description: ${JSON.stringify(s)}`}}async function Io(e,t){return(await e.json("GET",`/repos/${t}/git/matching-refs/tags/v`)).map((r)=>({name:r.ref.replace(/^refs\/tags\//,""),sha:r.object.sha,type:r.object.type??"commit"}))}async function Uv(e,t,n=!1){let r=(i,a)=>n?i:i.catch(()=>a),[s,o]=await Promise.all([r(Io(e,t),[]),r(e.json("GET",`/repos/${t}/releases?per_page=100`),[])]);return[...s.map((i)=>i.name),...o.map((i)=>i.tag_name)]}var al=async(e,t,n)=>n.type==="tag"?e.json("GET",`/repos/${t}/git/tags/${n.sha}`).then((r)=>r.object.sha,()=>null):n.sha;async function cl(e,t,n,r){let s=n.filter((a)=>Ke.test(a.name)),o=Xt(s.filter((a)=>a.type==="commit"&&a.sha===r).map((a)=>a.name));if(o)return o;let i=s.filter((a)=>a.type==="tag").sort((a,c)=>Oe(ee(c.name),ee(a.name))).slice(0,5);for(let a of i)if(await al(e,t,a)===r)return a.name;return null}var Tn=(e)=>e.filter((t)=>/^(HOMEBREW_TAP_|MACOS_)/.test(t)),ll=(e,t,n)=>`https://github.com/apps/${e}/installations/new/permissions?suggested_target_id=${t}&repository_ids[]=${n}`;function Gv(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
+ `)}async function AO(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 g(`${t} has no tapster.yml on main`,"Run tapster init in a clone of the hub and push it first.");throw n}}async function Hv(e,t,n,r,s){if(!Kt.test(n))throw new g(`${n} is not a valid package name`,"Use lowercase letters, digits and dashes.");let{text:o,sha:i}=await AO(e,t),a=wO(o,s,n),{invalid:c}=ve(a,t.split("/")[0]),l=c.find((f)=>f.name===n);if(l)throw new g(`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 g(`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:i,branch:u});let d=[`tapster add prepared this entry for ${r}:`,"","```yaml",s,"```","",`Merge it to let the hub publish ${r}.`].join(`
827
+ `);return(await e.json("POST",`/repos/${t}/pulls`,{title:`Add ${n}`,head:u,base:"main",body:d})).html_url}var $O=/^[A-Za-z0-9-]+\/[A-Za-z0-9._-]+$/;function Oo(e,t){let n=null;try{n=e?Y(e):null}catch{n=null}let r=n?.packages;if(!Array.isArray(r))return[];return r.flatMap((s)=>{let o=s&&typeof s==="object"?s:{};if(typeof o.name!=="string"||!Kt.test(o.name)||typeof o.repo!=="string"||!$O.test(o.repo))return[];if(o.repo.split("/")[0].toLowerCase()!==t.toLowerCase())return[];return[{name:o.name,repo:o.repo,kind:o.kind==="bun"||o.kind==="app"?o.kind:"go",workflow:typeof o.workflow==="string"&&/^[A-Za-z0-9._-]+\.ya?ml$/.test(o.workflow)?o.workflow:"release.yml",protection:o.protection==="off"||o.protection==="dependabot"?o.protection:"on",description:typeof o.description==="string"?o.description:null}]})}async function tt(e,t){let n=t.split("/")[0],r=Oo(await F(e,t,"tapster.yml","main"),n).map((o)=>({...o,state:"merged",pr:null})),s=await e.json("GET",`/repos/${t}/pulls?state=open&per_page=100`).catch(()=>[]);for(let o of s){let i=/^tapster-add-([a-z0-9][a-z0-9-]*)$/.exec(o.head?.ref??"")?.[1];if(!i||r.some((c)=>c.name===i))continue;let a=Oo(await F(e,t,"tapster.yml",o.head.ref).catch(()=>null),n).find((c)=>c.name===i);if(a&&!r.some((c)=>c.repo.toLowerCase()===a.repo.toLowerCase()))r.push({...a,state:"proposed",pr:o.html_url})}return r}async function en(e,t){let n=await Qt(e,t,"variables"),r=n.find((s)=>s.name==="TAPSTER_APP_SLUG")?.value;if(!r)throw new g(`${t} has no App yet`,"Run tapster init in a clone of the hub first.");return{slug:r,apple:n.some((s)=>s.name==="TAPSTER_TEAM_ID")}}function Zv(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"):
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
- `)[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
- `,`${_r(6)}
833
- `)}var KE=new Set([".git",".build","build","dist","DerivedData","node_modules","Pods","Carthage"]),qt=(e)=>typeof e==="string"&&!e.includes("$(")?e:null,_v=(e)=>typeof e==="string"?/\/releases\/latest\/download\/([A-Za-z0-9._-]+\.xml)$/.exec(e)?.[1]??null:null;function Wc(e,t=0){if(t>5)return[];let n=[];for(let r of Sv(e,{withFileTypes:!0})){if(r.isSymbolicLink()||KE.has(r.name)||r.name.endsWith(".app")||r.name.endsWith(".xcodeproj"))continue;if(r.isDirectory())n.push(...Wc(te(e,r.name),t+1));else if(r.name==="Info.plist")n.push(te(e,r.name))}return n}function WE(e){let t=oe(te(e,"Makefile"))??"";return{build:/^app:/m.test(t)?"make app":null,appPath:/^APP\s*:?=\s*([^\s].*?\.app)\s*$/m.exec(t)?.[1]??null}}function Vc(e){let t=Sv(e);if(!t.some((s)=>s==="project.yml"||s==="Package.swift"||s.endsWith(".xcodeproj")))return null;let n=WE(e),r=oe(te(e,"project.yml"));if(r!==null){let s=ne(r);for(let[o,a]of Object.entries(s?.targets??{})){if(a.type!=="application")continue;let c=a.info?.properties??{},l=_v(c.SUFeedURL);if(!l)continue;let u={...s.settings?.base??{},...a.settings?.base??{}};return{name:qt(u.PRODUCT_NAME)??o,bundleId:qt(u.PRODUCT_BUNDLE_IDENTIFIER),feed:l,publicKey:qt(c.SUPublicEDKey),universal:String(u.ARCHS??"").includes("x86_64"),...n}}}let i=t.find((s)=>s.endsWith(".xcodeproj"));for(let s of Wc(e)){let o;try{let u=fs(s);if(!u)continue;o=Cc(u)}catch{continue}let a=_v(o.SUFeedURL);if(!a)continue;let c=i&&oe(te(e,i,"project.pbxproj"),16777216)||"",l=/PRODUCT_BUNDLE_IDENTIFIER = "?([A-Za-z0-9.-]+)"?;/.exec(c)?.[1]??null;return{name:qt(o.CFBundleName)??(i?Ar(i,".xcodeproj"):Ar(e)),bundleId:qt(o.CFBundleIdentifier)??l,feed:a,publicKey:qt(o.SUPublicEDKey),universal:/ARCHS = [^;]*x86_64/.test(c),...n}}return null}function VE(e,t,n){let r={...n,name:n.appPath?Ar(n.appPath,".app"):n.name};return[` - name: ${e}`,` repo: ${t}`," kind: app",` app: ${r.name}.app`,` bundle_id: ${r.bundleId&&pn.test(r.bundleId)?r.bundleId:"<bundle id>"}`," assets:",` ${r.universal?"darwin-universal":"darwin-arm64"}: "${r.name}-{version}.app.tar.gz"`," dmg:",` name: "${r.name}-{version}.dmg"`," sparkle:",` key: ${e.replace(/[^a-z0-9]/g,"")}`,...r.feed==="appcast.xml"?[]:[` feed: ${r.feed}`],` public_key: "${r.publicKey??"<SUPublicEDKey>"}"`].join(`
834
- `)}function YE(e,t){if(/[\r\n]/.test(e.build))throw new v("the build command must be one line","Wrap several steps in a make target or a script.");if(!/^[A-Za-z0-9 ._\/-]+\.app$/.test(e.appPath))throw new v(`${e.appPath} is not a path to an .app`,"Pass the path the build writes the app to.");if(!/^macos-[0-9a-z.-]+$/.test(e.runner))throw new v(`${e.runner} is not a macOS runner`,"Use a runner like macos-15.");let n=e.carry.map((r)=>{let[i,s]=r.split(":");if(!i||!s||!/^[A-Za-z0-9._\/-]+$/.test(i)||!/^[A-Za-z0-9._-]+$/.test(s))throw new v(`${r} is not <path>:<asset name>`,"Name each carried file as path:name.");return` cp "${i}" "dist/${s}"`});return lv.replaceAll("__CHECKOUT_SHA__",t["actions/checkout"].sha).replaceAll("__CHECKOUT_TAG__",t["actions/checkout"].tag).replaceAll("__UPLOAD_SHA__",t["actions/upload-artifact"].sha).replaceAll("__UPLOAD_TAG__",t["actions/upload-artifact"].tag).replaceAll("__DOWNLOAD_SHA__",t["actions/download-artifact"].sha).replaceAll("__DOWNLOAD_TAG__",t["actions/download-artifact"].tag).replaceAll("__ATTEST_SHA__",t["actions/attest-build-provenance"].sha).replaceAll("__ATTEST_TAG__",t["actions/attest-build-provenance"].tag).replaceAll("__RUNNER__",e.runner).replaceAll("__BUILD__",e.build).replaceAll("__APP_PATH__",e.appPath).replaceAll("__APP_NAME__",Ar(e.appPath,".app")).replace(`__CARRY__
829
+ `)}async function qv(e,t,n){let r=await e.getRepo(n),s=await e.json("GET",`/users/${n.split("/")[0]}`);return ll(t,s.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
+ ${t}`;function TO(e){let t=xt(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:Rr(e,t.toString(Cr)),notes:n}}var ul=(e)=>e.value,Qv="Ring the tapster hub",PO=/git\/refs\/heads\/|git push\b[^\n]*refs\/heads\//;function EO(e){let t=[];for(let n of e.items){let r=ul(n).get("steps");if(!kt(r))continue;for(let s of r.items){let o=Pe(s)?String(s.get("run")??""):"";if(PO.test(o))t.push(String(s.get("name")??o.trim().split(`
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 OO(e,t,n){let r=xt(e),s=[],o=r.get("jobs");if(!Pe(o))throw new g("the release workflow has no jobs","Add the GoReleaser job first.");s.push(...EO(o));for(let i of o.items){let a=i.value.get("steps");if(!kt(a))continue;let c=a.items.findIndex((v)=>Pe(v)&&String(v.get("uses")??"").startsWith("goreleaser/goreleaser-action"));if(c===-1)continue;let u=a.items[c].get("env");if(Pe(u))for(let v of[...u.items]){let _=String(v.key.value??v.key);if(/^(MACOS_|HOMEBREW_TAP_)/.test(_))u.delete(_),s.push(`removed ${_} from the GoReleaser step`)}let p=a.items.some((v)=>Pe(v)&&String(v.get("uses")??"").startsWith("actions/attest-build-provenance@")),d=ul(i),h=d.get("permissions"),f=r.get("permissions"),m=h??f;if(m!=="write-all"){let v=Pe(m)?m.toJSON():{};d.set("permissions",r.createNode({...v,contents:"write","id-token":"write",attestations:"write"}))}if(p)s.push("the attestation step is already there; permissions checked");else{let v=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"}});v.get("uses",!0).comment=` ${n}`,a.items.splice(c+1,0,v),s.push(`added the attestation step (actions/attest-build-provenance ${n}) and its permissions`)}if(!a.items.some((v)=>Pe(v)&&v.get("name")===Qv))a.items.push(r.createNode(Y(Or(0))[0])),s.push("added the step that rings the hub's doorbell after the draft is open");return{text:Rr(e,r.toString(Cr)),notes:s}}throw new g("no GoReleaser step found in the release workflow","tapster add edits the job that runs goreleaser/goreleaser-action.")}function CO(e){let t;try{t=xt(e)}catch{return null}let n=t.get("jobs");if(!Pe(n))return null;for(let r of n.items){let s=ul(r).get("steps");if(!kt(s))continue;if(!s.items.some((i)=>Pe(i)&&/gh release create[^\n]*--draft/.test(String(i.get("run")??""))))continue;if(s.items.some((i)=>Pe(i)&&i.get("name")===Qv))return e;return s.items.push(t.createNode(Y(Or(0))[0])),Rr(e,t.toString(Cr))}return null}function RO(e,t){let n=Ir(t,".app");for(let r of pl(e))try{let s=Ao(r),o=s?Zc(s):{},i=tn(o.CFBundleIdentifier);if((o.CFBundleExecutable===n||o.CFBundleName===n)&&i&&_n.test(i))return i}catch{continue}return null}function IO(e,t,n,r=!0){return(r?tl:tl.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
+ `,`${Or(6)}
833
+ `)}var NO=new Set([".git",".build","build","dist","DerivedData","node_modules","Pods","Carthage"]),tn=(e)=>typeof e==="string"&&!e.includes("$(")?e:null,Kv=(e)=>typeof e==="string"?/\/releases\/latest\/download\/([A-Za-z0-9._-]+\.xml)$/.exec(e)?.[1]??null:null;function pl(e,t=0){if(t>5)return[];let n=[];for(let r of Jv(e,{withFileTypes:!0})){if(r.isSymbolicLink()||NO.has(r.name)||r.name.endsWith(".app")||r.name.endsWith(".xcodeproj"))continue;if(r.isDirectory())n.push(...pl(ie(e,r.name),t+1));else if(r.name==="Info.plist")n.push(ie(e,r.name))}return n}function zO(e){let t=oe(ie(e,"Makefile"))??"";return{build:/^app:/m.test(t)?"make app":null,appPath:/^APP\s*:?=\s*([^\s].*?\.app)\s*$/m.exec(t)?.[1]??null}}function dl(e){let t=Jv(e);if(!t.some((o)=>o==="project.yml"||o==="Package.swift"||o.endsWith(".xcodeproj")))return null;let n=zO(e),r=oe(ie(e,"project.yml"));if(r!==null){let o=Y(r);for(let[i,a]of Object.entries(o?.targets??{})){if(a.type!=="application")continue;let c=a.info?.properties??{},l=Kv(c.SUFeedURL);if(!l)continue;let u={...o.settings?.base??{},...a.settings?.base??{}};return{name:tn(u.PRODUCT_NAME)??i,bundleId:tn(u.PRODUCT_BUNDLE_IDENTIFIER),feed:l,publicKey:tn(c.SUPublicEDKey),universal:String(u.ARCHS??"").includes("x86_64"),...n}}}let s=t.find((o)=>o.endsWith(".xcodeproj"));for(let o of pl(e)){let i;try{let u=Ao(o);if(!u)continue;i=Zc(u)}catch{continue}let a=Kv(i.SUFeedURL);if(!a)continue;let c=s&&oe(ie(e,s,"project.pbxproj"),16777216)||"",l=/PRODUCT_BUNDLE_IDENTIFIER = "?([A-Za-z0-9.-]+)"?;/.exec(c)?.[1]??null;return{name:tn(i.CFBundleName)??(s?Ir(s,".xcodeproj"):Ir(e)),bundleId:tn(i.CFBundleIdentifier)??l,feed:a,publicKey:tn(i.SUPublicEDKey),universal:/ARCHS = [^;]*x86_64/.test(c),...n}}return null}function jO(e,t,n){let r={...n,name:n.appPath?Ir(n.appPath,".app"):n.name};return[` - name: ${e}`,` repo: ${t}`," kind: app",` app: ${r.name}.app`,` bundle_id: ${r.bundleId&&_n.test(r.bundleId)?r.bundleId:"<bundle id>"}`," assets:",` ${r.universal?"darwin-universal":"darwin-arm64"}: "${r.name}-{version}.app.tar.gz"`," dmg:",` name: "${r.name}-{version}.dmg"`," sparkle:",` key: ${e.replace(/[^a-z0-9]/g,"")}`,...r.feed==="appcast.xml"?[]:[` feed: ${r.feed}`],` public_key: "${r.publicKey??"<SUPublicEDKey>"}"`].join(`
834
+ `)}function LO(e,t){if(/[\r\n]/.test(e.build))throw new g("the build command must be one line","Wrap several steps in a make target or a script.");if(!/^[A-Za-z0-9 ._\/-]+\.app$/.test(e.appPath))throw new g(`${e.appPath} is not a path to an .app`,"Pass the path the build writes the app to.");if(!/^macos-[0-9a-z.-]+$/.test(e.runner))throw new g(`${e.runner} is not a macOS runner`,"Use a runner like macos-15.");let n=e.carry.map((r)=>{let[s,o]=r.split(":");if(!s||!o||!/^[A-Za-z0-9._\/-]+$/.test(s)||!/^[A-Za-z0-9._-]+$/.test(o))throw new g(`${r} is not <path>:<asset name>`,"Name each carried file as path:name.");return` cp "${s}" "dist/${o}"`});return Cv.replaceAll("__CHECKOUT_SHA__",t["actions/checkout"].sha).replaceAll("__CHECKOUT_TAG__",t["actions/checkout"].tag).replaceAll("__UPLOAD_SHA__",t["actions/upload-artifact"].sha).replaceAll("__UPLOAD_TAG__",t["actions/upload-artifact"].tag).replaceAll("__DOWNLOAD_SHA__",t["actions/download-artifact"].sha).replaceAll("__DOWNLOAD_TAG__",t["actions/download-artifact"].tag).replaceAll("__ATTEST_SHA__",t["actions/attest-build-provenance"].sha).replaceAll("__ATTEST_TAG__",t["actions/attest-build-provenance"].tag).replaceAll("__RUNNER__",e.runner).replaceAll("__BUILD__",e.build).replaceAll("__APP_PATH__",e.appPath).replaceAll("__APP_NAME__",Ir(e.appPath,".app")).replace(`__CARRY__
835
835
  `,n.map((r)=>`${r}
836
836
  `).join("")).replace(`__RING__
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(`
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
- ${k.lines.join(`
841
- `)}`;let _=k.description&&xt(k.description,a).length===0?k.description:null;if(_)d=`${d}
842
- description: ${JSON.stringify(_)}`,k.carried.unshift("description");else{let y=fv(p.description,a);if(y.line)o(y.line);if(y.add)d=`${d}
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}
837
+ `,`${Or(6)}
838
+ `)}async function DO(e,t,n=!1,r=!1){let s=(await e.getRepo(t)).default_branch,o=await iv(e,t,s,n,r),i=[o.deployKeys&&!n?"--auto-tag":"",o.dependabot&&!r?"--allow-dependabot":""].filter(Boolean),a=i.length?` It keeps what an earlier ${i.join(" and ")} opened.`:"";if(o.status==="exists")return`- ${t} is already protected: only an admin can create, move or delete its branches and tags.${a}`;if(o.status==="created")return`- protected ${t}: only you can create, move or delete branches and tags; workflows and Apps, the hub's included, cannot. Release tags come from you; GitHub then notes "Bypassed rule violations", which is your admin right at work.${o.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 hl(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=Co(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 g(`unknown option ${r}`,"Run tapster add --help for the options.")}return t}async function Wv(e,t,n,r){let s=ie(e,".github/workflows",t);if(Nt(s)&&!r){let o=CO($r(s,`.github/workflows/${t}`));if(o===null)throw new g(`.github/workflows/${t} already exists`,"Move it aside and run tapster add again. To replace it, run tapster add --force.");return await Tr(e,`.github/workflows/${t}`,o),`- kept .github/workflows/${t}; it rings the hub after opening the draft`}return await Tr(e,`.github/workflows/${t}`,n),`- wrote .github/workflows/${t} (build, attest, draft, ring the hub)`}var Xv=(e)=>{try{let t=Y(e);return Boolean(t?.homebrew_casks?.[0]??t?.brews?.[0])}catch{return!1}},Vv=(e,t,n)=>Ve(e,t,{timeoutMs:1e4,maxOutput:n}).catch(()=>null);async function MO(e){let t=[".goreleaser.yaml",".goreleaser.yml"],n=await Vv(e,["rev-list","--max-count=50","HEAD","--",...t],65536);for(let r of n?.code===0?n.stdout.split(`
839
+ `).filter((s)=>/^[0-9a-f]{40,64}$/.test(s)):[])for(let s of t){let o=await Vv(e,["cat-file","blob",`${r}:${s}`],1048576);if(o?.code===0&&Xv(o.stdout))return o.stdout}return null}async function UO(e,t,n,r,s=!0){let o=dl(e);if(o&&!s)throw new g("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(o){let a=o.build??'echo "Set the build command in .github/workflows/release.yml" && exit 1',c=o.appPath??`build/${o.name}.app`,l=[await Wv(e,"release.yml",LO({build:a,appPath:c,runner:"macos-15",carry:[]},et),r.force)];if(!o.build||!o.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:jO(n,t,o),reason:null,notes:l,goreleaser:null,files:[".github/workflows/release.yml"]}}let i=[".goreleaser.yaml",".goreleaser.yml"].find((a)=>Nt(ie(e,a)));if(i&&Nt(ie(e,"go.mod"))){let a=$r(ie(e,i),i),c=TO(a);await Tr(e,i,c.text);let l=ie(e,".github/workflows",r.workflow);if(!Nt(l))throw new g(`no .github/workflows/${r.workflow} found`,"Name the workflow that runs GoReleaser with --workflow.");let u=OO($r(l,`.github/workflows/${r.workflow}`),et["actions/attest-build-provenance"].sha,et["actions/attest-build-provenance"].tag);await Tr(e,`.github/workflows/${r.workflow}`,u.text);let p=Xv(a)?a:await MO(e);return{kind:"go",entry:null,reason:null,notes:[...c.notes,...u.notes].map((d)=>`- ${d}`),goreleaser:c.text,original:p??a,files:[i,`.github/workflows/${r.workflow}`]}}if(Nt(ie(e,"package.json"))&&(Nt(ie(e,"bun.lock"))||Nt(ie(e,"bun.lockb")))){let a;try{a=JSON.parse($r(ie(e,"package.json"),"package.json"))}catch(p){if(p instanceof g)throw p;throw new g("package.json is not valid JSON","Fix package.json, then try again.")}let c=Ro(a,n);if(!c)throw new g("package.json has no bin entry","Add the CLI entry file to bin in package.json.");let l=await Wv(e,"release.yml",IO(c.bin,c.entry,et,s),r.force),u=l.startsWith("- kept");return{kind:"bun",entry:u?null:jv(n,t,c.bin),reason:null,notes:[l],goreleaser:null,bin:u?c.bin:null,files:[".github/workflows/release.yml"]}}throw new g("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 GO(e,t){let n=(await Ve(e,["config","--get","tapster.hub"])).stdout.trim(),r=t??(n?Co(n):Co(await be("Which hub publishes this project (owner/repo)? ")));return{hub:r,remember:async()=>void(r!==n&&await Vt("git",["-C",e,"config","tapster.hub",r]))}}async function HO(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 g(`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 o=It("tapster-tag-");try{await L("/usr/bin/ssh-keygen","ssh-keygen",["-q","-t","ed25519","-N","","-C",`tapster tags for ${t}`,"-f",ie(o,"key")]),await se(t,"TAPSTER_TAG_KEY",Fv(ie(o,"key"),"utf8"),"release"),await e.json("POST",`/repos/${t}/keys`,{title:"tapster tags",key:Fv(ie(o,"key.pub"),"utf8").trim(),read_only:!1})}finally{Qe(o)}let i=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.`,...i.length?[` Every deploy key with write access can now tag too: ${i.join(", ")}. Remove the ones you do not need in the repository settings.`]:[]," Push tags from your release workflow like this:",Gv(et["actions/checkout"])].join(`
840
+ `)}async function ZO(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 Yv(e,t){let r=(await e.listReleases(t)).filter((s)=>/^v\d/.test(s.tag_name)).sort((s,o)=>o.created_at.localeCompare(s.created_at))[0];return r?{assets:r.assets.map((s)=>s.name),version:r.tag_name.slice(1)}:null}async function fl(e,t,n,r,s,o,i){let a=ml(n),{slug:c,apple:l}=s,u=await UO(t,n,a,o,l);for(let y of u.notes)i(y);let p=await e.getRepo(n);if(i(await DO(e,n,o.autoTag,o.dependabot)),!o.dependabot&&[".github/dependabot.yml",".github/dependabot.yaml"].some((y)=>Nt(ie(t,y))))i("- Dependabot cannot open pull requests here now: GitHub does not let personal repositories exempt it from the rules."),i(" 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(o.autoTag)i(await HO(e,n,p.default_branch));let d=(await tt(e,r)).find((y)=>y.name===a||y.repo.toLowerCase()===n.toLowerCase()),{entry:h,reason:f}=u;if(d){if(h=null,i(d.pr?`- the hub entry for ${d.name} waits in ${d.pr}; merge it to start publishing`:`- ${r} already has the entry for ${d.name}; tapster leaves it as it is`),!d.description){let y=il(p.description,a,!0);if(y.line)i(y.line)}}else if(u.kind==="go")({entry:h,reason:f}=Lv(a,n,u.goreleaser,await Yv(e,n)));else if(u.kind==="bun"&&u.bin)({entry:h,reason:f}=ol(a,n,"bun",[u.bin],await Yv(e,n)));if(h&&!l){if(h=Zv(h),h)i("- the hub has no Apple credentials, so the entry leaves out the macOS builds");else f="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)i(` 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 m=d?.pr??null;if(h){h=Mv(h,{kind:u.kind,workflow:o.workflow,dependabot:o.dependabot});let y=Dv(u.original??null,{mac:l,bundleId:(k)=>RO(t,k)});if(y.lines.length)h=`${h}
841
+ ${y.lines.join(`
842
+ `)}`;let b=y.description&&Et(y.description,a).length===0?y.description:null;if(b)h=`${h}
843
+ description: ${JSON.stringify(b)}`,y.carried.unshift("description");else{let k=il(p.description,a);if(k.line)i(k.line);if(k.add)h=`${h}
844
+ ${k.add}`}if(y.carried.length)i(`- carried the ${y.carried.join(", ")} of GoReleaser's Homebrew section into the hub entry`);for(let k of y.notes)i(`- ${k}`);try{m=await Hv(e,r,a,n,h),i(`- proposed the hub entry in ${m}; merge it to start publishing`)}catch(k){if(!(k instanceof g))throw k;if(i(`- the hub entry was not proposed: ${k.reason}. ${k.fix}
844
845
  The entry for ${r}'s tapster.yml:
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
+ ${h}`),o.dependabot&&k.reason.includes("is already in"))i(" Its existing entry needs protection: dependabot, or the hub refuses the project.")}}else if(!d)i(`- no hub entry yet: ${f}`);let v=await ZO(e,r);if(v)await So(n,"TAPSTER_DOORBELL",v),i("- the release workflow rings the hub's doorbell, so the hub publishes right after the draft opens");let _=await e.json("GET",`/repos/${n}/actions/secrets?per_page=100`).then((y)=>Tn(y.secrets.map((b)=>b.name)),()=>[]);if(_.length)i(`- ${n} still holds release secrets that the hub replaces: ${_.join(", ")}. Delete them once the hub has published a release: gh secret delete <name> --repo ${n}`);let A=await qv(e,c,n);return i(Bv(n,A)),{pr:m,entry:h,installUrl:A,files:u.files,kind:u.kind}}var ml=(e)=>e.split("/")[1].toLowerCase().replace(/[^a-z0-9-]/g,"-");async function eb(e){let t=hl(e),n=process.cwd(),r=await Je(n),s=await Rt(),{hub:o,remember:i}=await GO(n,t.hub),a=await en(s,o);await i(),await fl(s,n,r,o,a,t,(l)=>console.log(l));let c=await qO(s,r).catch(()=>"Once they are on the default branch, release from tapster setup, under Projects.");console.log(`
847
+ Review the changes with git diff, then commit and push them.
848
+ ${c}`)}async function qO(e,t){if((await e.json("GET",`/repos/${t}/keys`).catch(()=>[])).some((i)=>i.title==="tapster tags"))return"Your release workflow tags each release by itself.";let r=(await e.getRepo(t)).default_branch,s=Po(Xt(await Uv(e,t))),o=Iv(t,s,{branch:r});return o?`Once they are on ${r} and the hub entry is merged, release ${s} by tagging the latest commit of ${r} on GitHub:
849
+ ${o}`:`Once they are on ${r} and the hub entry is merged, release ${s} from tapster setup, under Projects.`}var ue={version:"1.3.0",sha:"8ff573f8af7c5a864452f21200e44f2f1359bff4"};var No=`name: tapster
847
850
  on:
848
851
  schedule:
849
852
  - cron: "__CRON__"
@@ -1046,7 +1049,7 @@ jobs:
1046
1049
  - name: Deploy the Linux repositories
1047
1050
  id: deploy
1048
1051
  uses: actions/deploy-pages@__PAGES_DEPLOY_SHA__ # __PAGES_DEPLOY_TAG__
1049
- `;var Pv=`# __TAP__
1052
+ `;var tb=`# __TAP__
1050
1053
 
1051
1054
  \`\`\`sh
1052
1055
  brew tap __TAP__
@@ -1071,16 +1074,16 @@ scoop install __OWNER__/<name>
1071
1074
  | \`.tapster/state.json\` | the releases tapster published |
1072
1075
 
1073
1076
  Releases are signed and published by the \`tapster\` workflow; change the projects, not these files.
1074
- `;var J=".github/workflows/tapster.yml";function Ee(e){let t=e.packages.filter(Y).flatMap((n)=>n.sparkle?[n.sparkle.key,...n.sparkle.next_key?[n.sparkle.next_key]:[]]:[]);return[...new Set(t)]}function Tv(e){let t=e.map((n)=>`SPARKLE_KEY_${n.toUpperCase()}: "\${{ secrets.SPARKLE_KEY_${n.toUpperCase()} }}"`);return t.length?`{ ${t.join(", ")} }`:"{}"}function Xc(e,t,n,r=[],i=10){return e.replaceAll("__CRON__",gs(i)).replaceAll("__SPARKLE_ENV__",Tv(r)).replaceAll("__CHECKOUT_SHA__",t["actions/checkout"].sha).replaceAll("__CHECKOUT_TAG__",t["actions/checkout"].tag).replaceAll("__ATTEST_SHA__",t["actions/attest-build-provenance"].sha).replaceAll("__ATTEST_TAG__",t["actions/attest-build-provenance"].tag).replaceAll("__UPLOAD_SHA__",t["actions/upload-artifact"].sha).replaceAll("__UPLOAD_TAG__",t["actions/upload-artifact"].tag).replaceAll("__DOWNLOAD_SHA__",t["actions/download-artifact"].sha).replaceAll("__DOWNLOAD_TAG__",t["actions/download-artifact"].tag).replaceAll("__PAGES_UPLOAD_SHA__",t["actions/upload-pages-artifact"].sha).replaceAll("__PAGES_UPLOAD_TAG__",t["actions/upload-pages-artifact"].tag).replaceAll("__PAGES_DEPLOY_SHA__",t["actions/deploy-pages"].sha).replaceAll("__PAGES_DEPLOY_TAG__",t["actions/deploy-pages"].tag).replaceAll("__TAPSTER_SHA__",n.sha).replaceAll("__TAPSTER_TAG__",n.tag)}async function iO(e,t,n){if(n===null){if(t.sha)return{sha:t.sha,tag:`v${t.version}`};throw new v("this tapster was built from a checkout, so it does not know which tapster the hub should run","Pass --tapster <commit> with a full commit SHA from tapster's main or use a released tapster.")}if(!/^[0-9a-f]{40}$/.test(n))throw new v(`${n} is not a full commit SHA`,"Pass all 40 characters of the commit.");let r=await e.json("GET",`/repos/doguyilmaz/tapster/compare/${n}...main`);if(r.status!=="ahead"&&r.status!=="identical")throw new v(`${n} is not on tapster's main`,"Pin a commit that is on main.");return{sha:n,tag:"main"}}var Bt=/doguyilmaz\/tapster@([0-9a-f]{40}) # (\S+)/;function sO(e,t){let n=(s)=>`${s[2]} (${s[1].slice(0,7)})`,r=Bt.exec(t),i=e===null?null:Bt.exec(e);if(!i)return`tapster ${n(r)}`;return i[1]===r[1]&&i[2]===r[2]?`tapster ${n(i)}, unchanged`:`tapster ${n(i)} -> ${n(r)}`}function el(e,t,n){if(e===null)return"missing";let r=Bt.exec(e),i=n??t.sha;if(!r)return"other";if(r[1]===i)return"current";if(n!==null||!t.sha)return"other";let s=ss(r[2]),o=ss(`v${t.version}`);if(!s||!o)return"other";let a=Pc(s,o);return a<0?"older":a>0?"newer":"other"}function xs(e,t){let n=/(\n\s+with: \{ mode: sparkle(?:, template: \d+)? \}\n\s+env: ).*\n/;if(!n.test(e))throw new v("the hub workflow has no sparkle step","Run tapster init --workflow to rewrite it from the template.");return e.replace(n,(r,i)=>`${i}${Tv(t)}
1075
- `)}function oO(e,t,n){if(e===t)return[];let r=[`The hub looks for new drafts every ${e} minutes; change it with tapster init --workflow --every <minutes>.`];if(t!==null)r.push("If the hub has a doorbell, run tapster init --rotate doorbell after you push, so it keeps the same schedule.");if(n.isPrivate&&e>=60&&n.every===null)r.push("GitHub bills every run of a private hub as at least one minute: every 10 minutes would use about 4,300 of the 2,000 free minutes a month. The doorbell (tapster init --doorbell) still publishes right after each release.");return r}async function tl(e,t,n,r,i){let s=await iO(e,ae,r),o=t===null?null:rt(t),a=i.every??o??(i.isPrivate?60:10),c=Xc(ks,We,s,n,a);return{file:{path:J,content:c,before:t},change:sO(t,c),notes:oO(a,o,i)}}function Ss(e){let[t,n]=e.split("/"),r=`${t}/${n.replace(/^homebrew-/,"")}`;return[{path:"tapster.yml",content:`version: 1
1077
+ `;var te=".github/workflows/tapster.yml";function Re(e){let t=e.packages.filter(X).flatMap((n)=>n.sparkle?[n.sparkle.key,...n.sparkle.next_key?[n.sparkle.next_key]:[]]:[]);return[...new Set(t)]}function nb(e){let t=e.map((n)=>`SPARKLE_KEY_${n.toUpperCase()}: "\${{ secrets.SPARKLE_KEY_${n.toUpperCase()} }}"`);return t.length?`{ ${t.join(", ")} }`:"{}"}function gl(e,t,n,r=[],s=10){return e.replaceAll("__CRON__",To(s)).replaceAll("__SPARKLE_ENV__",nb(r)).replaceAll("__CHECKOUT_SHA__",t["actions/checkout"].sha).replaceAll("__CHECKOUT_TAG__",t["actions/checkout"].tag).replaceAll("__ATTEST_SHA__",t["actions/attest-build-provenance"].sha).replaceAll("__ATTEST_TAG__",t["actions/attest-build-provenance"].tag).replaceAll("__UPLOAD_SHA__",t["actions/upload-artifact"].sha).replaceAll("__UPLOAD_TAG__",t["actions/upload-artifact"].tag).replaceAll("__DOWNLOAD_SHA__",t["actions/download-artifact"].sha).replaceAll("__DOWNLOAD_TAG__",t["actions/download-artifact"].tag).replaceAll("__PAGES_UPLOAD_SHA__",t["actions/upload-pages-artifact"].sha).replaceAll("__PAGES_UPLOAD_TAG__",t["actions/upload-pages-artifact"].tag).replaceAll("__PAGES_DEPLOY_SHA__",t["actions/deploy-pages"].sha).replaceAll("__PAGES_DEPLOY_TAG__",t["actions/deploy-pages"].tag).replaceAll("__TAPSTER_SHA__",n.sha).replaceAll("__TAPSTER_TAG__",n.tag)}async function KO(e,t,n){if(n===null){if(t.sha)return{sha:t.sha,tag:`v${t.version}`};throw new g("this tapster was built from a checkout, so it does not know which tapster the hub should run","Pass --tapster <commit> with a full commit SHA from tapster's main or use a released tapster.")}if(!/^[0-9a-f]{40}$/.test(n))throw new g(`${n} is not a full commit SHA`,"Pass all 40 characters of the commit.");let r=await e.json("GET",`/repos/doguyilmaz/tapster/compare/${n}...main`);if(r.status!=="ahead"&&r.status!=="identical")throw new g(`${n} is not on tapster's main`,"Pin a commit that is on main.");return{sha:n,tag:"main"}}var nn=/doguyilmaz\/tapster@([0-9a-f]{40}) # (\S+)/;function WO(e,t){let n=(o)=>`${o[2]} (${o[1].slice(0,7)})`,r=nn.exec(t),s=e===null?null:nn.exec(e);if(!s)return`tapster ${n(r)}`;return s[1]===r[1]&&s[2]===r[2]?`tapster ${n(s)}, unchanged`:`tapster ${n(s)} -> ${n(r)}`}function vl(e,t,n){if(e===null)return"missing";let r=nn.exec(e),s=n??t.sha;if(!r)return"other";if(r[1]===s)return"current";if(n!==null||!t.sha)return"other";let o=ee(r[2]),i=ee(`v${t.version}`);if(!o||!i)return"other";let a=Oe(o,i);return a<0?"older":a>0?"newer":"other"}function zo(e,t){let n=/(\n\s+with: \{ mode: sparkle(?:, template: \d+)? \}\n\s+env: ).*\n/;if(!n.test(e))throw new g("the hub workflow has no sparkle step","Run tapster init --workflow to rewrite it from the template.");return e.replace(n,(r,s)=>`${s}${nb(t)}
1078
+ `)}function VO(e,t,n){if(e===t)return[];let r=[`The hub looks for new drafts every ${e} minutes; change it with tapster init --workflow --every <minutes>.`];if(t!==null)r.push("If the hub has a doorbell, run tapster init --rotate doorbell after you push, so it keeps the same schedule.");if(n.isPrivate&&e>=60&&n.every===null)r.push("GitHub bills every run of a private hub as at least one minute: every 10 minutes would use about 4,300 of the 2,000 free minutes a month. The doorbell (tapster init --doorbell) still publishes right after each release.");return r}async function bl(e,t,n,r,s){let o=await KO(e,ue,r),i=t===null?null:lt(t),a=s.every??i??(s.isPrivate?60:10),c=gl(No,et,o,n,a);return{file:{path:te,content:c,before:t},change:WO(t,c),notes:VO(a,i,s)}}function jo(e){let[t,n]=e.split("/"),r=`${t}/${n.replace(/^homebrew-/,"")}`;return[{path:"tapster.yml",content:`version: 1
1076
1079
  tap: ${r}
1077
1080
  packages: []
1078
1081
  `,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")}
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");
1082
+ `,before:null},{path:"README.md",content:tb.replaceAll("__TAP__",r).replaceAll("__OWNER__",t).replaceAll("__HUB__",e),before:null}]}async function Lo(e,t,n,r,s){let o=[],i=[];for(let u of jo(t))if(await n(u.path)===null)o.push(u);else i.push(u.path);let a=await n("tapster.yml"),c=a===null?[]:Re(ve(a,t.split("/")[0]).config),l=await bl(e,await n(te),c,r,s);return o.push(l.file),{files:o,kept:i,change:l.change,notes:l.notes}}var K=(e,t)=>({name:e,ok:!0,fix:"",...t?{note:t}:{}}),M=(e,t)=>({name:e,ok:!1,fix:t});function YO(e){let n=Y(e)?.on,r=n&&typeof n==="object"&&!Array.isArray(n)?Object.keys(n):[];return r.length>0&&r.every((s)=>s==="schedule"||s==="workflow_dispatch")?K("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 JO(e){let n=(s)=>{let o;try{o=Y(s)}catch{return!0}let i=o?.jobs;if(!i||typeof i!=="object")return!1;return Object.values(i).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(([,s])=>n(s)).map(([s])=>s);return r.length===0?K("no other workflow uses the tapster environment"):M("no other workflow uses the tapster environment",`Remove the tapster environment from ${r.join(", ")}.`)}function QO(e,t,n){let s=Re(e),o=s.filter((a)=>!t.includes(`SPARKLE_KEY_${a.toUpperCase()}`));if(o.length)return M("every Sparkle key is stored and passed to the sparkle step",o.map((a)=>`Run tapster init --sparkle ${a}.`).join(" "));let i=s.filter((a)=>!n.includes(`SPARKLE_KEY_${a.toUpperCase()}: "\${{ secrets.SPARKLE_KEY_${a.toUpperCase()} }}"`));if(i.length)return M("every Sparkle key is stored and passed to the sparkle step",`The workflow does not pass ${i.map((a)=>`SPARKLE_KEY_${a.toUpperCase()}`).join(", ")}. Run tapster init --workflow.`);return K("every Sparkle key is stored and passed to the sparkle step")}function XO(e,t){let r=Object.entries(t).filter(([,s])=>s!==e).map(([s])=>s);return r.length?M("every project rings the hub's doorbell",r.map((s)=>`gh variable set TAPSTER_DOORBELL --repo ${s} --body ${e}`).join("; ")):K("every project rings the hub's doorbell")}function eC(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 o=r.html_url.replace(/\/$/,"");if(o!==Mg(e,t))return M("the Linux repositories can be signed and deployed",`Pages serves ${o}; set linux.url in tapster.yml to it.`);return K("the Linux repositories can be signed and deployed")}var rb=["MACOS_SIGN_P12","MACOS_SIGN_PASSWORD","MACOS_NOTARY_KEY","MACOS_NOTARY_KEY_ID","MACOS_NOTARY_ISSUER_ID"],tC=[...rb,"TAPSTER_APP_PRIVATE_KEY"];function nC(e,t,n){let s=e?.packages.some(mo)??!1,o=[...["TAPSTER_APP_PRIVATE_KEY",...s?rb:[]].filter((a)=>!t.includes(a)),...["TAPSTER_APP_ID","TAPSTER_APP_SLUG",...s?["TAPSTER_TEAM_ID"]:[]].filter((a)=>!n.includes(a))];if(o.length===0)return K("the credentials this hub needs are stored");let i=[...o.some((a)=>a.startsWith("TAPSTER_APP"))?["tapster init"]:[],...o.some((a)=>a.startsWith("MACOS_SIGN")||a==="TAPSTER_TEAM_ID")?["tapster init --rotate certificate"]:[],...o.some((a)=>a.startsWith("MACOS_NOTARY"))?["tapster init --rotate notary"]:[]];return M("the credentials this hub needs are stored",`Missing: ${o.join(", ")}. Run ${i.join(" and ")}.`)}function rC(e,t){let r=nn.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 K("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 s=[...e.matchAll(/SPARKLE_KEY_([A-Z0-9]+): "/g)].map((i)=>i[1].toLowerCase());return gl(No,et,{sha:r[1],tag:r[2]},s,lt(e)??10)===e?K("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 yl(e){return e.some((r)=>r.enforcement==="active"&&r.target==="branch"&&(r.conditions?.ref_name?.include??[]).some((s)=>s==="~DEFAULT_BRANCH"||s==="~ALL"||s==="refs/heads/main")&&(r.conditions?.ref_name?.exclude??[]).length===0&&["deletion","non_fast_forward"].every((s)=>(r.rules??[]).some((o)=>o.type===s))&&(r.bypass_actors??[]).every((s)=>s.actor_type==="RepositoryRole"&&s.actor_id===5))?K("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 wl(e,t){return e.allowed_actions==="selected"&&e.sha_pinning_required===!0&&t?.verified_allowed===!1&&(t.patterns_allowed??[]).every((s)=>s==="doguyilmaz/tapster@*")?K("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 sC(e,t,n){let s=e.map((a)=>a.login).filter((a)=>a.toLowerCase()!==n.toLowerCase()),o=t.filter((a)=>!a.read_only).map((a)=>a.title);if(s.length===0&&o.length===0)return K("only you can change the hub");let i=[...s.length?[`collaborators ${s.join(", ")} can push to main and change what the hub signs`]:[],...o.length?[`deploy keys ${o.join(", ")} can push too`]:[]];return M("only you can change the hub",`${i.join("; ")}. Remove them in the hub's settings unless you trust them with your signing keys.`)}function oC(e,t){if(e===String(t))return K("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 iC(e,t,n){if(e.some((o)=>(o.event==="schedule"||o.event==="workflow_dispatch")&&t-Date.parse(o.created_at)<86400000))return K("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 ut(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 aC(e,t,n,r,s){let o=[],i=await e.json("GET",`/repos/${t}/environments/tapster`).catch(()=>null);if(!i)return[M("the tapster environment exists","Run tapster init.")];let a=await e.json("GET",`/repos/${t}/environments/tapster/deployment-branch-policies`);o.push(i.deployment_branch_policy?.custom_branch_policies&&a.branch_policies.length===1&&a.branch_policies[0].name==="main"&&(a.branch_policies[0].type??"branch")==="branch"?K("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 ut(e,`/repos/${t}/environments/tapster/secrets?per_page=100`,"secrets")).map((b)=>b.name),l=await ut(e,`/repos/${t}/environments/tapster/variables?per_page=100`,"variables");o.push(nC(r,c,l.map((b)=>b.name)));let u=l.find((b)=>b.name==="TAPSTER_CERT_EXPIRES")?.value;if(u&&Date.parse(`${u}T00:00:00Z`)-Date.now()<2592000000)o.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&&Re(r).length)o.push(QO(r,c,s));if(r?.packages.some((b)=>!X(b)&&b.linux)){let b=await e.json("GET",`/repos/${t}/pages`).catch(()=>null);if(o.push(eC(r,t,c,b)),c.includes("TAPSTER_LINUX_KEY_PREVIOUS"))o.push(K("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 ut(e,`/repos/${t}/actions/variables?per_page=100`,"variables"),d=[...l,...p].map((b)=>b.name).filter((b)=>tC.includes(b)||/^SPARKLE_KEY_/.test(b)||b.startsWith("TAPSTER_LINUX_KEY"));o.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.`):K("credentials are secrets, not variables"));let h=l.find((b)=>b.name==="TAPSTER_DOORBELL")?.value;if(h&&r){let b={};for(let k of r.packages)b[k.repo]=await e.json("GET",`/repos/${k.repo}/actions/variables/TAPSTER_DOORBELL`).then((S)=>S.value).catch(()=>null);o.push(XO(h,b)),o.push(oC(l.find((k)=>k.name==="TAPSTER_DOORBELL_EVERY")?.value,lt(s)??10))}let f=await e.json("GET",`/repos/${t}/actions/permissions/workflow`);o.push(f.default_workflow_permissions==="read"?K("the default workflow token is read-only"):M("the default workflow token is read-only","Run tapster init."));let m=await Promise.all((await ut(e,`/repos/${t}/rulesets`)).map((b)=>e.json("GET",`/repos/${t}/rulesets/${b.id}`)));o.push(yl(m));let v=await e.json("GET",`/repos/${t}/actions/permissions`),_=v.allowed_actions==="selected"?await e.json("GET",`/repos/${t}/actions/permissions/selected-actions`):null;o.push(wl(v,_)),o.push(sC(await ut(e,`/repos/${t}/collaborators?affiliation=direct&per_page=100`),await ut(e,`/repos/${t}/keys?per_page=100`),n));let A=await e.json("GET",`/repos/${t}/actions/workflows/tapster.yml`).catch(()=>null);o.push(A?.state==="active"?K("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 y=await ut(e,`/repos/${t}/actions/workflows/tapster.yml/runs?per_page=30`,"workflow_runs");o.push(iC(y,Date.now(),Boolean(h)));for(let b of r?.packages??[]){let k=await e.getRepo(b.repo).catch((x)=>x instanceof R?null:Promise.reject(x));if(!k){o.push(M(`${b.repo} exists`,"Fix the repo field in tapster.yml."));continue}if(k.private)o.push(K(`${b.repo} is published by the hub`,`${b.repo} is private: the hub publishes its releases, but Homebrew, Scoop, apt and dnf users can only install from public projects`));if(b.protection==="off")o.push(K(`${b.repo} is protected`,`protection is off for ${b.name}: a stolen App key could tag code there that the hub would sign`));else{let x=await Yt(e,b.repo,k.default_branch,"admin",b.protection==="dependabot"),N=b.protection==="dependabot"?`branches named dependabot/... are open on ${b.repo}, so a stolen App key could run its workflows on code of its own there`:void 0;o.push(x.length?M(`${b.repo} is protected`,`${x.join("; ")}. Run tapster add in a clone of ${b.repo}.`):K(`${b.repo} is protected`,N))}let S=(await ut(e,`/repos/${b.repo}/actions/secrets?per_page=100`,"secrets")).map((x)=>x.name),O=Tn(S);o.push(O.length?M(`${b.repo} holds no release secrets`,`Delete ${O.join(", ")}: gh secret delete <name> --repo ${b.repo}`):K(`${b.repo} holds no release secrets`))}return o}async function cC(e,t,n){let s=(await e.json("GET",`/repos/${t}/environments/tapster/variables`).catch(()=>null))?.variables.find((o)=>o.name==="TAPSTER_APP_SLUG")?.value;if(!s||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/${s}/installations/new (the hub's check job also reports both)`}function lC(e,t){if(e===null)return{checks:[M("tapster.yml is valid","Run tapster init.")],config:null};try{let{config:n,invalid:r}=ve(e,t);if(r.length===0)return{checks:[K("tapster.yml is valid")],config:n};return{checks:r.map((s)=>M(`${s.name} in tapster.yml is valid`,`${s.reason}. ${s.fix}`)),config:n}}catch(n){return{checks:[M("tapster.yml is valid",n instanceof g?`${n.reason}. ${n.fix}`:"Run tapster init.")],config:null}}}async function uC(e,t){let n=(await ut(e,`/repos/${t}/contents/.github/workflows?ref=main`)).filter((s)=>s.type==="file").map((s)=>s.name),r={};for(let s of n)r[s]=await F(e,t,`.github/workflows/${s}`,"main")??"";return{config:await F(e,t,"tapster.yml","main"),flows:r}}async function Nr(e,t){let n=t.split("/")[0],r=await uC(e,t),s=[],o=lC(r.config,n),i=o.config;s.push(...o.checks);let a=r.flows["tapster.yml"];if(a)s.push(YO(a),rC(a,ue));else s.push(M("the hub workflow exists","Run tapster init, commit and push."));let{"tapster.yml":c,...l}=r.flows;return s.push(JO(l)),s.push(...await aC(e,t,n,i,a??"")),{checks:s,note:await cC(e,t,i?.packages.map((u)=>u.repo)??[])}}async function sb(e){let t=await Je(process.cwd()),n=await Rt();console.log(`Checking ${t} as it is on GitHub's main branch.`);let{checks:r,note:s}=await Nr(n,t);for(let o of r)if(console.log(o.ok?`ok ${o.name}`:`fix ${o.name}
1083
+ ${o.fix}`),o.note)console.log(` note: ${o.note}`);if(s)console.log(s);return r.every((o)=>o.ok)?0:1}import{createHash as NC,createPrivateKey as zC,createPublicKey as jC}from"crypto";import{existsSync as Pn,readFileSync as Gr}from"fs";import{mkdir as Sb,writeFile as El}from"fs/promises";import{join as Ie}from"path";import{createHash as pC,createPrivateKey as dC,createPublicKey as ob,sign as hC,verify as fC}from"crypto";var rn=2n**255n-19n,_l=2n**252n+27742317777372353535851937790883648493n,W=(e,t=rn)=>(e%t+t)%t,kl=(e,t)=>{let n=1n,r=W(e);for(let s=t;s>0n;s>>=1n){if(s&1n)n=n*r%rn;r=r*r%rn}return n},Uo=(e)=>kl(e,rn-2n),cb=W(-121665n*Uo(121666n));function ib([e,t,n,r],[s,o,i,a]){let c=W((t-e)*(o-s)),l=W((t+e)*(o+s)),u=W(2n*r*a*cb),p=W(2n*n*i),d=l-c,h=p-u,f=p+u,m=l+c;return[W(d*h),W(f*m),W(h*f),W(d*m)]}function lb(e,t){let n=[0n,1n,1n,0n],r=t;for(let s=e;s>0n;s>>=1n){if(s&1n)n=ib(n,r);r=ib(r,r)}return n}var ub=(()=>{let e=W(4n*Uo(5n)),t=W(e*e-1n),n=W(cb*e*e+1n),r=kl(W(t*Uo(n)),(rn+3n)/8n);if(W(r*r*n-t)!==0n)r=W(r*kl(2n,(rn-1n)/4n));if(r&1n)r=rn-r;return[r,e,1n,W(r*e)]})(),Mo=(e)=>e.reduceRight((t,n)=>t<<8n|BigInt(n),0n);function pb(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 db([e,t,n]){let r=Uo(n),s=W(e*r),o=W(t*r);return pb(o|(s&1n)<<255n)}var ab=(...e)=>pC("sha512").update(Buffer.concat(e)).digest();function mC(e,t,n){let r=Mo(e.subarray(0,32)),s=W(Mo(ab(e.subarray(32,64),n)),_l),o=db(lb(s,ub)),i=W(Mo(ab(o,t,n)),_l);return Buffer.concat([o,pb(W(s+i*r,_l))])}var gC=Buffer.from("302e020100300506032b657004220420","hex"),vC=Buffer.from("302a300506032b6570032100","hex"),Do=(e)=>new g(`the Sparkle key ${e}`,"Store the app's Sparkle key again with tapster init --sparkle <label> --account <keychain account>.");function Go(e){let t=e.trim();if(!/^[A-Za-z0-9+/]+={0,2}$/.test(t))throw Do("is not base64");let n=Buffer.from(t,"base64");kn(n.toString("hex"));let r,s;if(n.length===32){let i=dC({key:Buffer.concat([gC,n]),format:"der",type:"pkcs8"}),a=ob(i).export({format:"der",type:"spki"});r=a.subarray(a.length-32),s=(c)=>hC(null,c,i)}else if(n.length===96){let i=n.subarray(0,64);if(kn(i.toString("base64")),r=Buffer.from(n.subarray(64)),!db(lb(Mo(i.subarray(0,32)),ub)).equals(r))throw Do("is damaged: its two halves do not match");s=(a)=>mC(i,r,a)}else throw Do(`decodes to ${n.length} bytes, not 32 or 96`);let o=ob({key:Buffer.concat([vC,r]),format:"der",type:"spki"});return{publicKey:r.toString("base64"),sign(i){let a=s(i);if(!fC(null,i,o,a))throw Do("produced a signature that does not verify");return a}}}function Ho(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 zr(e,t){await Me(e,"TAPSTER_APP_ID",String(t.id)),await Me(e,"TAPSTER_APP_SLUG",t.slug),await se(e,"TAPSTER_APP_PRIVATE_KEY",t.pem)}async function Zo(e,t,n,r,s=new fe(Ye(e,t))){let o;try{o=(await s.json("GET",`/users/${n}/installation`)).id}catch(a){if(a instanceof R&&a.status===404)return{id:null,onHub:!1};throw a}let i=await s.json("GET",`/repos/${r}/installation`).then(()=>!0,(a)=>a instanceof R&&a.status===404?!1:Promise.reject(a));return{id:o,onHub:i}}import{existsSync as bC}from"fs";import{writeFile as yC}from"fs/promises";import{join as wC}from"path";var xl=65536,Sl=8192;function _C(e){return/(?:^|[,/]\s*)OU=([A-Z0-9]{10})(?:[,/]|$)/.exec(e)?.[1]??null}function kC(e,t,n=Date.now()){let r=/(?:^|,)CN=((?:[^,\\]|\\.)*)/.exec(e)?.[1]??"";if(!r.startsWith("Developer ID Application:"))throw new g(`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 s=_C(e);if(!s)throw new g("the certificate has no team ID","Export the Developer ID Application certificate from Keychain Access.");let o=Date.parse(t);if(Number.isNaN(o))throw new g("the certificate's expiry date cannot be read","Export the certificate again from Keychain Access.");let i=new Date(o).toISOString().slice(0,10);if(o<n)throw new g(`the certificate expired on ${i}`,"Create a new Developer ID Application certificate at developer.apple.com.");return{team:s,expires:i,name:r.replace(/\\(.)/g,"$1")}}function xC(e,t){if(/mac verify error|invalid password/i.test(e.stdout))throw new g("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 g("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 g("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 g("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 g("the .p12 could not be read","Export it again from My Certificates in Keychain Access.")}async function qo(e,t,n=Date.now()){if(e.length===0||e.length>xl)throw new g("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",s=(p)=>Vt("openssl",["pkcs12",...p,"-passin",r],{env:{TAPSTER_P12:t},stdin:e,allowFail:!0}),o=[],i=await s(["-info","-noout"]);if(/unsupported/i.test(i.stderr))o=["-legacy"],i=await s([...o,"-info","-noout"]);let a=await s([...o,"-nokeys","-clcerts"]);xC({code:i.code,stdout:`${i.stdout}
1084
+ ${i.stderr}`},a);let c=await Vt("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 kC(l,u,n)}async function Bo(e,t,n,r){await se(e,"MACOS_SIGN_P12",Buffer.from(t).toString("base64")),await se(e,"MACOS_SIGN_PASSWORD",n),await Me(e,"TAPSTER_TEAM_ID",r.team),await Me(e,"TAPSTER_CERT_EXPIRES",r.expires)}var SC=(e,t,n)=>["notarytool","history","--key",e,"--key-id",t,"--issuer",n,"--output-format","json"];function AC(e){if(/HTTP status code: 401\b/.test(e))return new g("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 g("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(`
1085
+ `).find((r)=>r.trim()!=="")?.trim()??"no message",n=/unable to find utility|notarytool.*not found/i.test(e);return new g(`notarytool could not check the key: ${xn(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 Al(e){if(e.length===0||e.length>Sl||!Buffer.from(e).toString("utf8").includes("BEGIN PRIVATE KEY"))throw new g("that file is not an App Store Connect key","Download the .p8 from App Store Connect, Users and Access, Integrations.")}function $l(e){let t=e.trim();if(!/^[A-Z0-9]{10}$/.test(t))throw new g(`${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 Fo(e,t,n){Al(e);let r=$l(t),s=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(s))throw new g("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:s}}async function Ko(e){if(process.platform!=="darwin"||!bC(Ct.xcrun))return!1;let t=It("tapster-notary-");try{let n=wC(t,`AuthKey_${e.keyId}.p8`);await yC(n,e.p8,{mode:384});let r=await L(Ct.xcrun,"xcrun",SC(n,e.keyId,e.issuer),{allowFail:!0});if(r.code!==0)throw AC(r.stderr);return!0}finally{Qe(t)}}async function Wo(e,t){await se(e,"MACOS_NOTARY_KEY",Buffer.from(t.p8).toString("base64")),await se(e,"MACOS_NOTARY_KEY_ID",t.keyId),await se(e,"MACOS_NOTARY_ISSUER_ID",t.issuer)}import{generateKeyPairSync as $C}from"crypto";import{existsSync as TC}from"fs";function hb(){let{privateKey:e,publicKey:t}=$C("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 PC=/^[A-Za-z0-9 .:/@_+=()-]+$/;function Lr(e){for(let t of[e.service,e.account,e.label,...e.comment===void 0?[]:[e.comment]])if(!PC.test(t))throw new g(`"${t}" cannot name a keychain item`,"Use letters, digits and simple punctuation.")}function EC(e,t){Lr(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")}
1086
+ `;if(r.length>4000)throw new g("the key is too long for one security command","tapster stores large keys through the Security API instead.");return r}var OC=`ObjC.import("Security");
1084
1087
  ObjC.import("Foundation");
1085
1088
  function run(argv) {
1086
1089
  const k = (ref) => ObjC.castRefToObject(ref);
@@ -1095,15 +1098,15 @@ function run(argv) {
1095
1098
  q.setObjectForKey($(argv[2]), k($.kSecAttrLabel));
1096
1099
  q.setObjectForKey($.NSFileHandle.fileHandleWithStandardInput.readDataToEndOfFile, k($.kSecValueData));
1097
1100
  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(`
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
+ }`;function CC(e){return Lr(e),["-l","JavaScript","-e",OC,e.service,e.account,e.label]}function RC(e){return Lr(e),["store","--label",e.label,"service",e.service,"account",e.account]}var jr="/usr/bin/security",fb="/usr/bin/osascript",Vo="/usr/bin/secret-tool",IC={kind:"keychain",exists:async(e)=>(await L(jr,"security",["find-generic-password","-s",e.service,"-a",e.account],{allowFail:!0})).code===0,async save(e,t){let n=null;try{n=EC(e,t)}catch(s){if(!(s instanceof g)||!s.reason.includes("too long"))throw s}if(n!==null){let s=await L(jr,"security",["-i"],{stdin:n,allowFail:!0});if(s.code===0&&!/error|returned/i.test(s.stderr))return;throw new g("the login keychain refused the key","Unlock the login keychain and run this again.")}let r=await L(fb,"osascript",CC(e),{stdin:t,allowFail:!0});if(r.code!==0||r.stdout.trim()!=="0")throw new g(`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(jr,"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(jr,"security",["delete-generic-password","-s",e.service,"-a",e.account],{allowFail:!0})}},mb={kind:"secret-service",exists:async(e)=>await mb.read(e)!==null,async save(e,t){if((await L(Vo,"secret-tool",RC(e),{stdin:t,allowFail:!0})).code!==0)throw new g("the Secret Service refused the key","Unlock your keyring (GNOME Keyring or KWallet) and run this again.")},async read(e){Lr(e);let t=await L(Vo,"secret-tool",["lookup","service",e.service,"account",e.account],{allowFail:!0});return t.code===0&&t.stdout!==""?t.stdout:null},async remove(e){Lr(e),await L(Vo,"secret-tool",["clear","service",e.service,"account",e.account],{allowFail:!0})}};function Tl(e=process.platform,t=TC){if(e==="darwin")return t(jr)&&t(fb)?IC:null;if(e==="linux")return t(Vo)?mb:null;return null}async function gb(e,t){let n=await e.read(t);if(n!==null||!await e.exists(t))return n;throw new g("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 Dr(e){let t=Tl();if(t)return t;throw new g(`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 LC(e,t){let n=new Set(e.vars),r=new Set(e.secrets),s=[];if(!(n.has("TAPSTER_APP_ID")&&n.has("TAPSTER_APP_SLUG")))s.push("app");else if(!r.has("TAPSTER_APP_PRIVATE_KEY"))s.push("app-key");if(t&&!(n.has("TAPSTER_TEAM_ID")&&r.has("MACOS_SIGN_P12")&&r.has("MACOS_SIGN_PASSWORD")))s.push("certificate");if(t&&!["MACOS_NOTARY_KEY","MACOS_NOTARY_KEY_ID","MACOS_NOTARY_ISSUER_ID"].every((o)=>r.has(o)))s.push("notary");return s.push("files"),s}var Ab=(e)=>e.trim().toLowerCase()==="yes";function DC(e,t){return["app","certificate","notary"].filter((n)=>!e.includes(n)&&(n==="app"?!e.includes("app-key"):t))}function MC(e,t){if(!(e instanceof R)||!t||![403,404,422].includes(e.status))return e;return new g("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 Ol(e,t,n){let r=[];for(let s of e.packages.filter(X)){let o=s.sparkle?.key===t?s.sparkle.public_key:s.sparkle?.next_key===t?s.sparkle.next_public_key:void 0;if(o===void 0)continue;if(o!==n)throw new g(`${s.name} pins ${o} 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(s.name)}if(r.length===0)throw new g(`no package in tapster.yml uses the Sparkle key ${t}`,"Add the package with its sparkle section first.");return r}async function $b(e,t,n,r,s){console.log("Waiting up to 10 minutes until the App is installed; tapster continues by itself once you choose Install.");let o=await $o(async()=>{let i=await Zo(e,t,n,r).catch(()=>null);return i?.id?i:null});if(o===null){console.log(`The App is not installed yet. Install it at https://github.com/apps/${s}/installations/new; tapster add links there for each project too.`);return}if(o.onHub)console.log(`The App is installed on ${r}. Remove ${r} from it at https://github.com/settings/installations/${o.id}; the hub refuses to run until you do.`)}async function UC(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 ko((r)=>Ho(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 zr(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.`),Jt(`https://github.com/apps/${n.slug}/installations/new`),await $b(String(n.id),n.pem,e,t,n.slug)}function GC(e){let t;try{t=zC(e)}catch{throw new g("that file is not a private key","Use the .pem file GitHub downloaded when you generated the key.")}if(t.asymmetricKeyType!=="rsa")throw new g("that file is not a GitHub App key","Use the .pem file GitHub downloaded when you generated the key.");let n=jC(t).export({type:"spki",format:"der"});return`SHA256:${NC("sha256").update(n).digest("base64")}`}async function vb(e,t){let n=await e.json("GET",`/repos/${t}/environments/tapster/variables`),r=n.variables.find((c)=>c.name==="TAPSTER_APP_ID")?.value,s=n.variables.find((c)=>c.name==="TAPSTER_APP_SLUG")?.value;if(!r||!s)throw new g("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":`),Jt(`https://github.com/settings/apps/${s}`);let o=An(await be("Path of the downloaded .pem file (drag it here): ")),i=(await $n(o,"the .pem file")).toString("utf8"),a=GC(i);await new fe(Ye(r,i)).json("GET","/app").catch(()=>{throw new g("that key does not belong to the hub's App",`Generate the key on https://github.com/settings/apps/${s}.`)}),await se(t,"TAPSTER_APP_PRIVATE_KEY",i),console.log(`Stored the new key (${a}).`),await $b(r,i,t.split("/")[0],t,s),console.log(`Now delete every other key on that page so the old one stops working. Then delete ${o}.`)}async function bb(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=An(await be(".p12 file (drag it here): ")),n=await $n(t,"the .p12 file"),r=await be(".p12 password: ",!0),s=await qo(n,r);await Bo(e,n,r,s),console.log(`Certificate stored for team ${s.team}. It expires on ${s.expires}; the hub warns 30 days before.`)}async function yb(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=An(await be(".p8 file (drag it here): ")),n=await $n(t,"the .p8 file");Al(n);let r=$l(await be("Key ID: ")),s=Fo(n,r,await be("Issuer ID: "));console.log(await Ko(s)?"Apple accepted the key.":"Not on macOS, so the key is checked at the first release instead."),await Wo(e,s),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 Cl(e,t,n){try{await e.json("PUT",`/repos/${t}/environments/tapster`,{deployment_branch_policy:{protected_branches:!1,custom_branch_policies:!0}})}catch(o){throw MC(o,n)}let r=await e.json("GET",`/repos/${t}/environments/tapster/deployment-branch-policies`);for(let o of r.branch_policies.filter((i)=>i.name!=="main"))await e.json("DELETE",`/repos/${t}/environments/tapster/deployment-branch-policies/${o.id}`);if(!r.branch_policies.some((o)=>o.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 s=(await e.json("GET",`/repos/${t}/rulesets`)).find((o)=>o.name===Pl.name);if(s)await e.json("PUT",`/repos/${t}/rulesets/${s.id}`,Pl);else await e.json("POST",`/repos/${t}/rulesets`,Pl)}function Ur(e,t){let n=Ie(e,"tapster.yml");if(!Pn(n))throw new g("tapster.yml is missing","Run tapster init in the hub first.");let{config:r,invalid:s}=ve(Gr(n,"utf8"),t.split("/")[0]);for(let o of s)console.log(`note: ${o.name} in tapster.yml is invalid and left out: ${o.reason}`);return r}async function HC(e,t,n,r,s){let o=Pn(Ie(t,te))?Gr(Ie(t,te),"utf8"):null,i=await bl(e,o,n,r,s);await Sb(Ie(t,".github/workflows"),{recursive:!0}),await El(Ie(t,te),i.file.content),console.log(`wrote ${te} from the template, ${i.change}; hand edits in it are replaced`);for(let a of i.notes)console.log(a)}async function Tb(e,t){let n=Ie(e,te);if(!Pn(n))throw new g(`${te} is missing`,"Run tapster init --workflow first.");await El(n,zo(Gr(n,"utf8"),t)),console.log(`updated the sparkle step in ${te}`)}async function ZC(e,t,n,r,s){if(!/^[a-z0-9]+$/.test(r))throw new g(`${r} is not a valid label`,"Use lowercase letters and digits, as in sparkle.key.");let o=Ur(t,n);console.log("macOS asks whether tapster may read the Sparkle key from your keychain; choose Allow.");let i=await Vt("security",["find-generic-password","-s","https://sparkle-project.org","-a",s,"-w"],{allowFail:!0});if(i.code!==0)throw new g(`the login keychain has no Sparkle key for the account ${s}`,"Pass the account generate_keys used with --account (ed25519 by default).");let a=i.stdout.trim(),c=Go(a),l=Ol(o,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 be("Do you keep an offline backup of this key? Type yes to store it in the hub: ");if(!Ab(u))throw new g("no offline backup confirmed","Back the key up first (generate_keys -x exports it), then run this again.");await se(n,`SPARKLE_KEY_${r.toUpperCase()}`,a),console.log(`Stored SPARKLE_KEY_${r.toUpperCase()}.`),await Tb(t,Re(o)),console.log("Review and commit the workflow change, then push.")}async function qC(e,t,n){if(!/^[a-z0-9]+$/.test(n))throw new g(`${n} is not a valid label`,"Use lowercase letters and digits, as in sparkle.key.");let r=Ur(e,t),s=r.packages.filter(X).filter((c)=>c.sparkle?.key===n||c.sparkle?.next_key===n);if(s.length)throw new g(`${s.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 o=Dr("the Sparkle key"),i={service:"https://sparkle-project.org",account:n,label:"Private key for signing Sparkle updates"};if(await o.exists(i))throw new g(`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=hb();if(await o.save({...i,comment:`Public key (SUPublicEDKey value) for this key is: ${a.publicKey}`},a.seed),console.log(`Saved a new Sparkle key in your ${o.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(o.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}`),!Ab(await be("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 se(t,`SPARKLE_KEY_${n.toUpperCase()}`,a.seed),console.log(`Stored SPARKLE_KEY_${n.toUpperCase()} in the hub.`),await Tb(e,[...new Set([...Re(r),n])]),console.log("Review and commit the workflow change, then push.")}async function wb(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 Mr=(e,t=!1)=>({service:"tapster-linux-key",account:t?`${e} previous`:e,label:`tapster Linux key for ${e}${t?" (previous)":""}`});async function BC(e,t){let n=(await Qt(e,t,"secrets")).map((r)=>r.name);if(await Tl()?.remove(Mr(t,!0)),!n.includes("TAPSTER_LINUX_KEY_PREVIOUS")){console.log("No Linux key rotation is running, so there is nothing to finish.");return}await gv(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 FC(e,t){if(e.includes("TAPSTER_LINUX_KEY")&&!t)throw new g("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 _b(e,t,n,r){let s=Ur(t,n),o=(await Qt(e,n,"secrets")).map((u)=>u.name);FC(o,r);let i=Dr("the Linux signing key"),a=["/opt/homebrew/bin/gpg","/usr/local/bin/gpg","/usr/bin/gpg"].find((u)=>Pn(u));if(!a)throw new g("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 g("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=It("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(`
1102
+ `).find((f)=>f.startsWith("fpr:"))?.split(":")[9],d=null;if(r){if(i.kind==="keychain")console.log("macOS asks whether tapster may read the previous key from your keychain; choose Allow.");d=await gb(i,Mr(n))}let h={...Mr(n),account:`${n} new`,label:`tapster Linux key for ${n} (new)`};if(await i.remove(h),await i.save(h,u),await se(n,"TAPSTER_LINUX_KEY",u),d)await se(n,"TAPSTER_LINUX_KEY_PREVIOUS",d);if(d)await wb(i,Mr(n,!0),d);if(await wb(i,Mr(n),u),await i.remove(h),console.log(`Stored the Linux key (fingerprint ${p}) in the hub and in your ${i.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(Ie(a,"..","gpgconf"),"gpgconf",["--kill","all"],{env:l,allowFail:!0}).catch(()=>{return}),Qe(c)}if(!s.packages.some((u)=>!X(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 KC(e,t,n,r,s){let i=await Lo(e,n,async(a)=>Pn(Ie(t,a))?Gr(Ie(t,a),"utf8"):null,r,s);for(let a of i.files)await Sb(Ie(t,a.path,".."),{recursive:!0}),await El(Ie(t,a.path),a.content),console.log(a.path===te?`wrote ${te} from the template, ${i.change}; hand edits in it are replaced`:`wrote ${a.path}`);for(let a of i.notes)console.log(a)}async function WC(e){let t=(await be(e)).toLowerCase();return t===""||t==="y"||t==="yes"}async function VC(e,t){let n=async(r)=>{try{return((await e.json("GET",`/repos/${t}/environments/tapster/${r}?per_page=100`))[r]??[]).map((o)=>o.name)}catch(s){if(s instanceof R&&s.status===404)return[];throw s}};return{vars:await n("variables"),secrets:await n("secrets"),private:(await e.getRepo(t)).private}}function kb(e,t){let n=e.indexOf(t);if(n<0)return{value:null,rest:e};return{value:e[n+1]??"",rest:e.filter((r,s)=>s!==n&&s!==n+1)}}var YC="Run tapster init --help for the options.";function JC(e){let[t,n,r,s]=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"&&s&&e.length===4)return{kind:"sparkle",label:n,account:s}}throw new g(`unknown option ${e.join(" ")}`,YC)}function xb(e){let t=Ie(e,te);return Pn(t)&&lt(Gr(t,"utf8"))||10}async function Pb(e){let t=kb(e,"--tapster"),n=kb(t.rest,"--every"),r=t.value,s=n.value===null?null:Number(n.value),o=JC(n.rest);if(s!==null)To(s);if((r!==null||s!==null)&&o.kind!=="setup"&&o.kind!=="workflow")throw new g("--tapster and --every go only with tapster init or init --workflow","Those are the commands that write the workflow.");let i=process.cwd(),a=await Je(i),c=await Rt();if(o.kind==="rotate"){if(o.what==="app")return vb(c,a);if(o.what==="certificate")return bb(a);if(o.what==="notary")return yb(a);if(o.what==="doorbell")return Ov(c,a,xb(i));if(o.what==="linux-finish")return BC(c,a);return _b(c,i,a,!0)}if(o.kind==="doorbell")return Ev(c,a,Ur(i,a),So,xb(i));if(o.kind==="linux")return _b(c,i,a,!1);if(o.kind==="sparkle-new")return qC(i,a,o.label);if(o.kind==="sparkle")return ZC(c,i,a,o.label,o.account);if(o.kind==="workflow")return HC(c,i,Re(Ur(i,a)),r,{every:s,isPrivate:(await c.getRepo(a)).private});let l=await VC(c,a);await Cl(c,a,l.private);let p=l.vars.includes("TAPSTER_TEAM_ID")||l.secrets.includes("MACOS_NOTARY_KEY")||await WC("Will this hub sign software for macOS (Mac apps or CLI tools with macOS builds)? [Y/n] "),d=LC(l,p),h=DC(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 UC(a.split("/")[0],a);if(f==="app-key")await vb(c,a);if(f==="certificate")await bb(a);if(f==="notary")await yb(a);if(f==="files")await KC(c,i,a,r,{every:s,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(`
1103
+ Done. Review and commit the new files, push, then run tapster add in each project.`)}import{homedir as r2}from"os";import{randomBytes as aR}from"crypto";var QC=/^(\.tapster|Casks|bucket)\//;async function Rl(e,t,n){let r=encodeURIComponent("refs/heads/main"),[s]=await e.json("GET",`/repos/${t}/activity?ref=${r}&actor=${n}&per_page=1`);if(!s)return[`GitHub shows no push by ${n} to main`];let o=s.after.slice(0,7),i=(await e.json("GET",`/repos/${t}/git/ref/heads/main`)).object.sha,a=await e.json("GET",`/repos/${t}/compare/${s.after}...${i}`);if(a.status==="identical")return[];if(a.status!=="ahead")return[`main no longer contains your last push (${o})`];let c=a.files??[];if(c.length>=300)return[`more files changed after your last push (${o}) than GitHub lists`];return c.filter((l)=>!QC.test(l.filename)).map((l)=>`${l.filename} changed after your last push (${o})`)}import{randomBytes as Il}from"crypto";var Eb=async()=>'var Ke,A,on,yt,ce,en,an,rn,bt,Ge,Ae,ln,_t,vt,gt,gs,We={},ze=[],ys=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,Ye=Array.isArray;function se(e,n){for(var s in n)e[s]=n[s];return e}function wt(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function _s(e,n,s){var o,a,r,i={};for(r in n)r=="key"?o=n[r]:r=="ref"?a=n[r]:i[r]=n[r];if(arguments.length>2&&(i.children=arguments.length>3?Ke.call(arguments,2):s),typeof e=="function"&&e.defaultProps!=null)for(r in e.defaultProps)i[r]===void 0&&(i[r]=e.defaultProps[r]);return Ue(e,i,o,a,null)}function Ue(e,n,s,o,a){var r={type:e,props:n,key:s,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:a==null?++on:a,__i:-1,__u:0};return a==null&&A.vnode!=null&&A.vnode(r),r}function x(e){return e.children}function ye(e,n){this.props=e,this.context=n}function he(e,n){if(n==null)return e.__?he(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"?he(e):null}function ws(e){if(e.__P&&e.__d){var n=e.__v,s=n.__e,o=[],a=[],r=se({},n);r.__v=n.__v+1,A.vnode&&A.vnode(r),kt(e.__P,r,n,e.__n,e.__P.namespaceURI,32&n.__u?[s]:null,o,s==null?he(n):s,!!(32&n.__u),a),r.__v=n.__v,r.__.__k[r.__i]=r,hn(o,r,a),n.__e=n.__=null,r.__e!=s&&cn(r)}}function cn(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}),cn(e)}function tn(e){(!e.__d&&(e.__d=!0)&&ce.push(e)&&!qe.__r++||en!=A.debounceRendering)&&((en=A.debounceRendering)||an)(qe)}function qe(){try{for(var e,n=1;ce.length;)ce.length>n&&ce.sort(rn),e=ce.shift(),n=ce.length,ws(e)}finally{ce.length=qe.__r=0}}function un(e,n,s,o,a,r,i,l,d,p,h){var f,c,u,v,k,g,w=o&&o.__k||ze,b=n.length;for(d=ks(s,n,w,d,b),f=0;f<b;f++)(u=s.__k[f])!=null&&(c=u.__i!=-1&&w[u.__i]||We,u.__i=f,g=kt(e,u,c,a,r,i,l,d,p,h),v=u.__e,u.ref&&c.ref!=u.ref&&(c.ref&&xt(c.ref,null,u),h.push(u.ref,u.__c||v,u)),k==null&&v!=null&&(k=v),4&u.__u?(d=pn(u,d,e),c.__e&&(c.__e=null)):typeof u.type=="function"&&g!==void 0?d=g:v&&(d=v.nextSibling),u.__u&=-7);return s.__e=k,d}function ks(e,n,s,o,a){var r,i,l,d,p,h=s.length,f=h,c=0;for(e.__k=Array(a),r=0;r<a;r++)(i=n[r])!=null&&typeof i!="boolean"&&typeof i!="function"?(typeof i=="string"||typeof i=="number"||typeof i=="bigint"||i.constructor==String?i=e.__k[r]=Ue(null,i,null,null,null):Ye(i)?i=e.__k[r]=Ue(x,{children:i},null,null,null):i.constructor===void 0&&i.__b>0?i=e.__k[r]=Ue(i.type,i.props,i.key,i.ref?i.ref:null,i.__v):e.__k[r]=i,d=r+c,i.__=e,i.__b=e.__b+1,l=null,(p=i.__i=xs(i,s,d,f))!=-1&&(f--,(l=s[p])&&(l.__u|=2)),l==null||l.__v==null?(p==-1&&(a>h?c--:a<h&&c++),typeof i.type!="function"&&(i.__u|=4)):p!=d&&(p==d-1?c--:p==d+1?c++:(p>d?c--:c++,i.__u|=4))):e.__k[r]=null;if(f)for(r=0;r<h;r++)(l=s[r])!=null&&(2&l.__u)==0&&(l.__e==o&&(o=he(l)),mn(l,l));return o}function pn(e,n,s){var o,a;if(typeof e.type=="function"){for(o=e.__k,a=0;o&&a<o.length;a++)o[a]&&(o[a].__=e,n=pn(o[a],n,s));return n}e.__e!=n&&(n&&e.type&&!n.parentNode&&(n=he(e)),n=s.insertBefore(e.__e,n||null));do n=n&&n.nextSibling;while(n!=null&&n.nodeType==8);return n}function xs(e,n,s,o){var a,r,i,{key:l,type:d}=e,p=n[s],h=p!=null&&(2&p.__u)==0;if(p===null&&l==null||h&&l==p.key&&d==p.type)return s;if(o>(h?1:0)){for(a=s-1,r=s+1;a>=0||r<n.length;)if((p=n[i=a>=0?a--:r++])!=null&&(2&p.__u)==0&&l==p.key&&d==p.type)return i}return-1}function nn(e,n,s){n[0]=="-"?e.setProperty(n,s==null?"":s):e[n]=s==null?"":typeof s!="number"||ys.test(n)?s:s+"px"}function Fe(e,n,s,o,a){var r,i;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||nn(e.style,n,"");if(s)for(n in s)o&&s[n]==o[n]||nn(e.style,n,s[n])}else if(n[0]=="o"&&n[1]=="n")r=n!=(n=n.replace(ln,"$1")),i=n.toLowerCase(),n=i in e||n=="onFocusOut"||n=="onFocusIn"?i.slice(2):n.slice(2),e.l||(e.l={}),e.l[n+r]=s,s?o?s[Ae]=o[Ae]:(s[Ae]=_t,e.addEventListener(n,r?gt:vt,r)):e.removeEventListener(n,r?gt:vt,r);else{if(a=="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(l){}typeof s=="function"||(s==null||s===!1&&n[4]!="-"?e.removeAttribute(n):e.setAttribute(n,n=="popover"&&s==1?"":s))}}function sn(e){return function(n){if(this.l){var s=this.l[n.type+e];if(n[Ge]==null)n[Ge]=_t++;else if(n[Ge]<s[Ae])return;return s(A.event?A.event(n):n)}}}function kt(e,n,s,o,a,r,i,l,d,p){var h,f,c,u,v,k,g,w,b,T,_,R,W,X,C,Z,P=n.type;if(n.constructor!==void 0)return null;128&s.__u&&(d=!!(32&s.__u),r=[l=n.__e=s.__e]),(h=A.__b)&&h(n);e:if(typeof P=="function"){f=i.length;try{if(b=n.props,T=P.prototype&&P.prototype.render,_=(h=P.contextType)&&o[h.__c],R=h?_?_.props.value:h.__:o,s.__c?w=(c=n.__c=s.__c).__=c.__E:(T?n.__c=c=new P(b,R):(n.__c=c=new ye(b,R),c.constructor=P,c.render=Cs),_&&_.sub(c),c.state||(c.state={}),c.__n=o,u=c.__d=!0,c.__h=[],c._sb=[]),T&&c.__s==null&&(c.__s=c.state),T&&P.getDerivedStateFromProps!=null&&(c.__s==c.state&&(c.__s=se({},c.__s)),se(c.__s,P.getDerivedStateFromProps(b,c.__s))),v=c.props,k=c.state,c.__v=n,u)T&&P.getDerivedStateFromProps==null&&c.componentWillMount!=null&&c.componentWillMount(),T&&c.componentDidMount!=null&&c.__h.push(c.componentDidMount);else{if(T&&P.getDerivedStateFromProps==null&&b!==v&&c.componentWillReceiveProps!=null&&c.componentWillReceiveProps(b,R),n.__v==s.__v||!c.__e&&c.shouldComponentUpdate!=null&&c.shouldComponentUpdate(b,c.__s,R)===!1){n.__v!=s.__v&&(c.props=b,c.state=c.__s,c.__d=!1),n.__e=s.__e,n.__k=s.__k,n.__k.some(function(z){z&&(z.__=n)}),ze.push.apply(c.__h,c._sb),c._sb=[],c.__h.length&&i.push(c),l=he(s);break e}c.componentWillUpdate!=null&&c.componentWillUpdate(b,c.__s,R),T&&c.componentDidUpdate!=null&&c.__h.push(function(){c.componentDidUpdate(v,k,g)})}if(c.context=R,c.props=b,c.__P=e,c.__e=!1,W=A.__r,X=0,T)c.state=c.__s,c.__d=!1,W&&W(n),h=c.render(c.props,c.state,c.context),ze.push.apply(c.__h,c._sb),c._sb=[];else do c.__d=!1,W&&W(n),h=c.render(c.props,c.state,c.context),c.state=c.__s;while(c.__d&&++X<25);c.state=c.__s,c.getChildContext!=null&&(o=se(se({},o),c.getChildContext())),T&&!u&&c.getSnapshotBeforeUpdate!=null&&(g=c.getSnapshotBeforeUpdate(v,k)),C=h!=null&&h.type===x&&h.key==null?fn(h.props.children):h,l=un(e,Ye(C)?C:[C],n,s,o,a,r,i,l,d,p),c.base=n.__e,n.__u&=-161,c.__h.length&&i.push(c),w&&(c.__E=c.__=null)}catch(z){if(i.length=f,n.__v=null,d||r!=null){if(z.then){for(n.__u|=d?160:128;l&&l.nodeType==8&&l.nextSibling;)l=l.nextSibling;r!=null&&(r[r.indexOf(l)]=null),n.__e=l}else if(r!=null)for(Z=r.length;Z--;)wt(r[Z])}else n.__e=s.__e;n.__k==null&&(n.__k=s.__k||[]),z.then||dn(n),A.__e(z,n,s)}}else r==null&&n.__v==s.__v?(n.__k=s.__k,n.__e=s.__e):l=n.__e=Ss(s.__e,n,s,o,a,r,i,d,p);return(h=A.diffed)&&h(n),128&n.__u?void 0:l}function dn(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(dn))}function hn(e,n,s){for(var o=0;o<s.length;o++)xt(s[o],s[++o],s[++o]);A.__c&&A.__c(n,e),e.some(function(a){try{e=a.__h,a.__h=[],e.some(function(r){r.call(a)})}catch(r){A.__e(r,a.__v)}})}function fn(e){return typeof e!="object"||e==null||e.__b>0?e:Ye(e)?e.map(fn):e.constructor!==void 0?null:se({},e)}function Ss(e,n,s,o,a,r,i,l,d){var p,h,f,c,u,v,k,g=s.props||We,{props:w,type:b}=n;if(b=="svg"?a="http://www.w3.org/2000/svg":b=="math"?a="http://www.w3.org/1998/Math/MathML":a||(a="http://www.w3.org/1999/xhtml"),r!=null){for(p=0;p<r.length;p++)if((u=r[p])&&"setAttribute"in u==!!b&&(b?u.localName==b:u.nodeType==3)){e=u,r[p]=null;break}}if(e==null){if(b==null)return document.createTextNode(w);e=document.createElementNS(a,b,w.is&&w),l&&(A.__m&&A.__m(n,r),l=!1),r=null}if(b==null)g===w||l&&e.data==w||(e.data=w);else{if(r=b=="textarea"&&w.defaultValue!=null?null:r&&Ke.call(e.childNodes),!l&&r!=null)for(g={},p=0;p<e.attributes.length;p++)g[(u=e.attributes[p]).name]=u.value;for(p in g)u=g[p],p=="dangerouslySetInnerHTML"?f=u:p=="children"||(p in w)||p=="value"&&("defaultValue"in w)||p=="checked"&&("defaultChecked"in w)||Fe(e,p,null,u,a);for(p in w)u=w[p],p=="children"?c=u:p=="dangerouslySetInnerHTML"?h=u:p=="value"?v=u:p=="checked"?k=u:l&&typeof u!="function"||g[p]===u||Fe(e,p,u,g[p],a);if(h)l||f&&(h.__html==f.__html||h.__html==e.innerHTML)||(e.innerHTML=h.__html),n.__k=[];else if(f&&(e.innerHTML=""),un(n.type=="template"?e.content:e,Ye(c)?c:[c],n,s,o,b=="foreignObject"?"http://www.w3.org/1999/xhtml":a,r,i,r?r[0]:s.__k&&he(s,0),l,d),r!=null)for(p=r.length;p--;)wt(r[p]);l&&b!="textarea"||(p="value",b=="progress"&&v==null?e.removeAttribute("value"):v!=null&&(v!==e[p]||b=="progress"&&!v||b=="option"&&v!=g[p])&&Fe(e,p,v,g[p],a),p="checked",k!=null&&k!=e[p]&&Fe(e,p,k,g[p],a))}return e}function xt(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(a){A.__e(a,s)}}function mn(e,n,s){var o,a;if(A.unmount&&A.unmount(e),(o=e.ref)&&(o.current&&o.current!=e.__e||xt(o,null,n)),(o=e.__c)!=null){if(o.componentWillUnmount)try{o.componentWillUnmount()}catch(r){A.__e(r,n)}o.base=o.__P=o.__n=null}if(o=e.__k)for(a=0;a<o.length;a++)o[a]&&mn(o[a],n,s||typeof e.type!="function");s||wt(e.__e),e.__c=e.__=e.__e=void 0}function Cs(e,n,s){return this.constructor(e,s)}function bn(e,n,s){var o,a,r,i;n==document&&(n=document.documentElement),A.__&&A.__(e,n),a=(o=typeof s=="function")?null:s&&s.__k||n.__k,r=[],i=[],kt(n,e=(!o&&s||n).__k=_s(x,null,[e]),a||We,We,n.namespaceURI,!o&&s?[s]:a?null:n.firstChild?Ke.call(n.childNodes):null,r,!o&&s?s:a?a.__e:n.firstChild,o,i),hn(r,e,i),e.props.children=null}Ke=ze.slice,A={__e:function(e,n,s,o){for(var a,r,i;n=n.__;)if((a=n.__c)&&!a.__)try{if((r=a.constructor)&&r.getDerivedStateFromError!=null&&(a.setState(r.getDerivedStateFromError(e)),i=a.__d),a.componentDidCatch!=null&&(a.componentDidCatch(e,o||{}),i=a.__d),i)return a.__E=a}catch(l){e=l}throw e}},on=0,yt=function(e){return e!=null&&e.constructor===void 0},ye.prototype.setState=function(e,n){var s;s=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=se({},this.state),typeof e=="function"&&(e=e(se({},s),this.props)),e&&se(s,e),e!=null&&this.__v&&(n&&this._sb.push(n),tn(this))},ye.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),tn(this))},ye.prototype.render=x,ce=[],an=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,rn=function(e,n){return e.__v.__b-n.__v.__b},qe.__r=0,bt=Math.random().toString(8),Ge="__d"+bt,Ae="__a"+bt,ln=/(PointerCapture)$|Capture$/i,_t=0,vt=sn(!1),gt=sn(!0),gs=0;var He,B,St,vn,Ze=0,Cn=[],L=A,{__b:gn,__r:yn,diffed:_n,__c:wn,unmount:kn,__:xn}=L;function Tt(e,n){L.__h&&L.__h(B,e,Ze||n),Ze=0;var s=B.__H||(B.__H={__:[],__h:[]});return e>=s.__.length&&s.__.push({}),s.__[e]}function m(e){return Ze=1,Ts(Pn,e)}function Ts(e,n,s){var o=Tt(He++,2);if(o.t=e,!o.__c&&(o.__=[s?s(n):Pn(void 0,n),function(l){var d=o.__N?o.__N[0]:o.__[0],p=o.t(d,l);d!==p&&(o.__N=[p,o.__[1]],o.__c.setState({}))}],o.__c=B,!B.__f)){var a=function(l,d,p){if(!o.__c.__H)return!0;var h=!1,f=o.__c.props!==l;if(o.__c.__H.__.some(function(u){if(u.__N){h=!0;var v=u.__[0];u.__=u.__N,u.__N=void 0,v!==u.__[0]&&(f=!0)}}),r){var c=r.call(this,l,d,p);return h?c||f:c}return!h||f};B.__f=!0;var r=B.shouldComponentUpdate,i=B.componentWillUpdate;B.componentWillUpdate=function(l,d,p){if(this.__e){var h=r;r=void 0,a(l,d,p),r=h}i&&i.call(this,l,d,p)},B.shouldComponentUpdate=a}return o.__N||o.__}function E(e,n){var s=Tt(He++,3);!L.__s&&Tn(s.__H,n)&&(s.__=e,s.u=n,B.__H.__h.push(s))}function fe(e){return Ze=5,Xe(function(){return{current:e}},[])}function Xe(e,n){var s=Tt(He++,7);return Tn(s.__H,n)&&(s.__=e(),s.__H=n,s.__h=e),s.__}function Ps(){for(var e;e=Cn.shift();){var n=e.__H;if(e.__P&&n)try{n.__h.some(Je),n.__h.some(Ct),n.__h=[]}catch(s){n.__h=[],L.__e(s,e.__v)}}}L.__b=function(e){B=null,gn&&gn(e)},L.__=function(e,n){e&&n.__k&&n.__k.__m&&(e.__m=n.__k.__m),xn&&xn(e,n)},L.__r=function(e){yn&&yn(e),He=0;var n=(B=e.__c).__H;n&&(St===B?(n.__h=[],B.__h=[],n.__.some(function(s){s.__N&&(s.__=s.__N),s.u=s.__N=void 0})):(n.__h.some(Je),n.__h.some(Ct),n.__h=[],He=0)),St=B},L.diffed=function(e){_n&&_n(e);var n=e.__c;n&&n.__H&&(n.__H.__h.length&&(Cn.push(n)!==1&&vn===L.requestAnimationFrame||((vn=L.requestAnimationFrame)||$s)(Ps)),n.__H.__.some(function(s){s.u&&(s.__H=s.u,s.u=void 0)})),St=B=null},L.__c=function(e,n){n.some(function(s){try{s.__h.some(Je),s.__h=s.__h.filter(function(o){return!o.__||Ct(o)})}catch(o){n.some(function(a){a.__h&&(a.__h=[])}),n=[],L.__e(o,s.__v)}}),wn&&wn(e,n)},L.unmount=function(e){kn&&kn(e);var n,s=e.__c;s&&s.__H&&(s.__H.__.some(function(o){try{Je(o)}catch(a){n=a}}),s.__H=void 0,n&&L.__e(n,s.__v))};var Sn=typeof requestAnimationFrame=="function";function $s(e){var n,s=function(){clearTimeout(o),Sn&&cancelAnimationFrame(n),setTimeout(e)},o=setTimeout(s,35);Sn&&(n=requestAnimationFrame(s))}function Je(e){var n=B,s=e.__c;typeof s=="function"&&(e.__c=void 0,s()),B=n}function Ct(e){var n=B;e.__c=e.__(),B=n}function Tn(e,n){return!e||e.length!==n.length||n.some(function(s,o){return s!==e[o]})}function Pn(e,n){return typeof n=="function"?n(e):n}var As=Symbol.for("preact-signals");function nt(){if(!(oe>1)){var e,n=!1;(function(){var a=et;et=void 0;while(a!==void 0){var r=a.S;if(r.v===a.v){for(var i=r.t;i!==void 0;i=i.x)if(i.i===a.i)i.i=r.i}a=a.o}})();while(Ne!==void 0){var s=Ne;Ne=void 0,Qe++;while(s!==void 0){var o=s.u;if(s.u=void 0,s.f&=-3,!(8&s.f)&&An(s))try{s.c()}catch(a){if(!n)e=a,n=!0}s=o}}if(Qe=0,oe--,n)throw e}else oe--}function $t(e){if(oe>0)return e();Pt=++Hs,oe++;try{return e()}finally{nt()}}var je,M=void 0;function Ie(e){var n=M,s=je;M=void 0,je=void 0;try{return e()}finally{M=n,je=s}}var Ne=void 0,oe=0,Qe=0,Hs=0,Pt=0,et=void 0,tt=0;function $n(e){if(M!==void 0){var n=e.n;if(n===void 0||n.t!==M){if(n={i:0,S:e,p:M.s,n:void 0,t:M,e:void 0,x:void 0,r:n},M.s!==void 0)M.s.n=n;if(M.s=n,e.n=n,32&M.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=M.s,n.n=void 0,M.s.n=n,M.s=n}return n}}}function G(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}G.prototype.brand=As;G.prototype.h=function(){return!0};G.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 Ie(function(){var o;(o=n.W)==null||o.call(n)})};G.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)Ie(function(){var a;(a=n.Z)==null||a.call(n)})}}};G.prototype.subscribe=function(e){var n=this;return be(function(){var s=n.value;Ie(function(){return e(s)})},{name:"sub"})};G.prototype.valueOf=function(){return this.value};G.prototype.toString=function(){return this.value+""};G.prototype.toJSON=function(){return this.value};G.prototype.peek=function(){var e=this;return Ie(function(){return e.value})};Object.defineProperty(G.prototype,"value",{get:function(){var e=$n(this);if(e!==void 0)e.i=this.i;return this.v},set:function(e){if(e!==this.v){if(Qe>100)throw Error("Cycle detected");(function(s){if(oe!==0&&Qe===0){if(s.l!==Pt)s.l=Pt,et={S:s,v:s.v,i:s.i,o:et}}})(this),this.v=e,this.i++,tt++,oe++;try{for(var n=this.t;n!==void 0;n=n.x)n.t.N()}finally{nt()}}}});function D(e,n){return new G(e,n)}function An(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 Hn(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 jn(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 me(e,n){G.call(this,void 0,n),this.x=e,this.s=void 0,this.g=tt-1,this.f=4}me.prototype=new G;me.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===tt)return!0;if(this.g=tt,this.f|=1,this.i>0&&!An(this))return this.f&=-2,!0;var e=M;try{Hn(this),M=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 M=e,jn(this),this.f&=-2,!0};me.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)}G.prototype.S.call(this,e)};me.prototype.U=function(e){if(this.t!==void 0){if(G.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)}}};me.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(me.prototype,"value",{get:function(){if(1&this.f)throw Error("Cycle detected");var e=$n(this);if(this.h(),e!==void 0)e.i=this.i;if(16&this.f)throw this.v;return this.v}});function st(e,n){return new me(e,n)}function Nn(e){var n=e.m;if(e.m=void 0,typeof n=="function"){oe++;var s=M;M=void 0;try{n()}catch(o){throw e.f&=-2,e.f|=8,At(e),o}finally{M=s,nt()}}}function At(e){for(var n=e.s;n!==void 0;n=n.n)n.S.U(n);e.x=void 0,e.s=void 0,Nn(e)}function js(e){if(M!==this)throw Error("Out-of-order effect");if(jn(this),M=e,this.f&=-2,8&this.f)At(this);nt()}function _e(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,je)je.push(this)}_e.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()}};_e.prototype.S=function(){if(1&this.f)throw Error("Cycle detected");this.f|=1,this.f&=-9,Nn(this),Hn(this),oe++;var e=M;return M=this,js.bind(this,e)};_e.prototype.N=function(){if(!(2&this.f))this.f|=2,this.u=Ne,Ne=this};_e.prototype.d=function(){if(this.f|=8,!(1&this.f))At(this)};_e.prototype.dispose=function(){this.d()};function be(e,n){var s=new _e(e,n);try{s.c()}catch(a){throw s.d(),a}var o=s.d.bind(s);return o[Symbol.dispose]=o,o}var In,at,ot,Ns=typeof window<"u"&&!!window.__PREACT_SIGNALS_DEVTOOLS__;var Rn=[];be(function(){In=this.N})();function we(e,n){A[e]=n.bind(null,A[e]||function(){})}function Re(e){if(ot){var n=ot;ot=void 0,n()}ot=e&&e.S()}function En(e){var n=this,s=e.data,o=Rs(s);o.name="ReactiveDom",o.value=s;var a=Xe(function(){var l=n,d=n.__v;while(d=d.__)if(d.__c){d.__c.__$f|=4;break}var p=st(function(){var u=o.value.value;return u===0?0:u===!0?"":u||""}),h=st(function(){return!Array.isArray(p.value)&&!yt(p.value)}),f=be(function(){if(this.N=On,h.value){var u=p.value;if(l.__v&&l.__v.__e&&l.__v.__e.nodeType===3)l.__v.__e.data=u}}),c=n.__$u.d;return n.__$u.d=function(){f(),c.call(this)},[h,p]},[]),r=a[0],i=a[1];return r.value?i.peek():i.value}En.displayName="ReactiveTextNode";Object.defineProperties(G.prototype,{constructor:{configurable:!0,value:void 0},type:{configurable:!0,value:En},props:{configurable:!0,get:function(){var e=this;return{data:{get value(){return e.value}}}}},__b:{configurable:!0,value:1}});we("__b",function(e,n){if(Re(),at=void 0,typeof n.type=="string"){var s,o=n.props;for(var a in o)if(a!=="children"){var r=o[a];if(r instanceof G){if(!s)n.__np=s={};s[a]=r,o[a]=r.peek()}}}e(n)});we("__r",function(e,n){if(e(n),n.type!==x){Re();var s,o=n.__c;if(o){if(o.__$f&=-2,(s=o.__$u)===void 0)o.__$u=s=function(a,r){var i;return be(function(){i=this},{name:r}),i.c=a,i}(function(a){return function(){var r;if(Ns)(r=this.y)==null||r.call(this);a.__$f|=1,a.setState({})}}(o),typeof n.type=="function"?n.type.displayName||n.type.name:"")}at=o,Re(s)}});we("__e",function(e,n,s,o){Re(),at=void 0,e(n,s,o)});we("diffed",function(e,n){Re(),at=void 0;var s;if(typeof n.type=="string"&&(s=n.__e)){var{__np:o,props:a}=n,r=s.U;if(r)for(var i in r){var l=r[i];if(!(l===void 0||o&&(i in o)))l.d(),r[i]=void 0}if(o){if(!r)r={},s.U=r;for(var d in o){var p=r[d],h=o[d];if(p===void 0)p=Is(s,d,h,a),r[d]=p;else p.o(h,a)}}}e(n)});function Is(e,n,s,o){var a=n in e&&e.ownerSVGElement===void 0,r=D(s);return{o:function(i,l){r.value=i,o=l},d:be(function(){this.N=On;var i=r.value.value;if(o[n]!==i)if(o[n]=i,a)e[n]=i;else if(i!=null&&(i!==!1||n[4]==="-"))e.setAttribute(n,i);else e.removeAttribute(n)})}}we("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 a in o){var r=o[a];if(r)r.d()}}}var i=n.__np;if(i){var l=n.props;for(var d in i)l[d]=i[d]}n.__np=void 0}else{var p=n.__c;if(p){p.__$f|=8;var h=p.__$u;if(h)p.__$u=void 0,h.d()}}e(n)});we("__h",function(e,n,s,o){if(o<3)n.__$f|=2;e(n,s,o)});ye.prototype.shouldComponentUpdate=function(e,n){if(this.__R)return!0;var s=this.__$u,o=s&&s.s!==void 0;for(var a in n)return!0;if(this.__f||typeof this.u=="boolean"&&this.u===!0){var r=2&this.__$f;if(!(o||r||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 i in e)if(i!=="__source"&&e[i]!==this.props[i])return!0;for(var l in this.props)if(!(l in e))return!0;return!1};function Rs(e,n){return Xe(function(){return D(e,n)},[])}var Es=function(e){queueMicrotask(function(){queueMicrotask(e)})};function Os(){$t(function(){var e;while(e=Rn.shift())In.call(e)})}function On(){if(Rn.push(this)===1)(A.requestAnimationFrame||Es)(Os)}class ae extends Error{problem;status;constructor(e,n){super(e.reason);this.problem=e;this.status=n}}var Ht={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}}},Ee=Ht.get(),Mn=()=>{},Dn=()=>Ee!==null,Vn=(e)=>{Mn=e};async function Bn(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 ae(s.error??{reason:"the link did not work",fix:"Press Enter in the terminal that runs tapster setup for a fresh link."},n.status);Ee=s.token,Ht.set(Ee)}async function Ln(e,n,s){let o={authorization:`Bearer ${Ee??""}`},a;if(s instanceof FormData)a=s;else if(s!==void 0)o["content-type"]="application/json",a=JSON.stringify(s);let r;try{r=await fetch(n,{method:e,headers:o,body:a})}catch{throw new ae({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 i=await r.json().catch(()=>null);if(r.status===401)Ee=null,Ht.set(null),Mn();if(!r.ok||i===null)throw new ae(i?.error??{reason:`tapster setup answered ${r.status}`,fix:"Reload the page and try again."},r.status);return i}var K=(e)=>Ln("GET",e),j=(e,n)=>Ln("POST",e,n??{});var Fn="tapster.hub",jt=(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}},Ms=jt,ve=D(location.pathname),De=D(null),re=D(null),Oe=D(null),It=D(null),H=D(jt(Fn)),te=D(null),it=D(!1),xe=D(null),ke=D(null);function pe(e,n=!1){if(n)history.replaceState(null,"",e);else history.pushState(null,"",e);ve.value=location.pathname,window.scrollTo({top:0})}addEventListener("popstate",()=>{ve.value=location.pathname});function Y(e,n){ke.value={tone:e,text:n},setTimeout(()=>{if(ke.value?.text===n)ke.value=null},5000)}var I=(e)=>e instanceof ae?e.problem:{reason:"something went wrong",fix:"Reload the page and try again."};async function lt(){try{re.value=await K("/api/account"),Oe.value=null}catch(e){Oe.value=I(e)}}async function Gn(){let e=await K("/api/hubs");It.value=e.hubs}function ct(e){if(e!==H.value)ne.value=null;if(H.value=e,Nt(Fn,e),te.value=null,xe.value=null,q.value=null,ue.value=null,ie.value=null,e)J()}var q=D(null),ue=D(null),rt=null;function Ve(){let e=H.value;if(!e)return Promise.resolve();if(rt?.hub===e)return rt.done;let n=(async()=>{try{let s=await K(`/api/projects/status?hub=${encodeURIComponent(e)}`);if(H.value!==e)return;q.value={hub:e,list:s.projects},ue.value=null}catch(s){if(H.value===e)ue.value=I(s)}finally{rt=null}})();return rt={hub:e,done:n},n}async function de(e){let n=H.value;if(!n)return null;let s=(await K(`/api/projects/status?hub=${encodeURIComponent(n)}&repo=${encodeURIComponent(e)}`)).projects[0]??null,o=q.value;if(s&&o?.hub===n&&s.entry.state!=="missing"){let a=o.list.some((r)=>r.repo===s.repo);q.value={hub:n,list:a?o.list.map((r)=>r.repo===s.repo?s:r):[...o.list,s]}}return s}var Un="tapster.roots";function Rt(){try{let e=JSON.parse(Ms(Un)??"[]");return Array.isArray(e)?e.filter((n)=>typeof n==="string").slice(0,10):[]}catch{return[]}}var Wn=(e)=>Nt(Un,JSON.stringify(e)),ie=D(null);async function Se(e=Rt()){let n=H.value;if(!n)return;let s=await j("/api/projects/scan",{hub:n,extra:e});if(H.value===n)ie.value={hub:n,scan:s}}async function J(){let e=H.value;if(!e)return;it.value=!0;try{let n=await K(`/api/hub?hub=${encodeURIComponent(e)}`);if(H.value===e)te.value=n,xe.value=null}catch(n){if(H.value===e)xe.value=I(n)}finally{it.value=!1}}var zn=(e)=>`tapster.mac.${e}`,Me=D({});function qn(e){return Me.value[e]??(jt(zn(e))||null)}function Et(e,n){Nt(zn(e),n),Me.value={...Me.value,[e]:n}}var Be=D(null),ne=D(null);function le(e){let n=De.value?.home;if(!n)return e;return e===n?"~":e.startsWith(`${n}/`)?`~${e.slice(n.length)}`:e}var Ds=0;function t(e,n,s,o,a,r){n||(n={});var i,l,d=n;if("ref"in d)for(l in d={},n)l=="ref"?i=n[l]:d[l]=n[l];var p={type:e,props:d,key:s,ref:i,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Ds,__i:-1,__u:0,__source:a,__self:r};if(typeof e=="function"&&(i=e.defaultProps))for(l in i)d[l]===void 0&&(d[l]=i[l]);return A.vnode&&A.vnode(p),p}var Vs={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(x,{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(x,{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(x,{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(x,{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(x,{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(x,{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(x,{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 y({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:Vs[e]},void 0,!1,void 0,this)}function O({label:e="Working"}){return t(y,{name:"loader",spin:!0,label:e},void 0,!1,void 0,this)}var Bs={keys:"lock",ok:"check",warn:"alert",error:"alert",info:"info"};function S({tone:e="info",title:n,children:s}){return t("div",{class:`note ${e}`,role:e==="error"?"alert":void 0,children:[t(y,{name:Bs[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(S,{tone:"error",title:`${n}.`,children:t("span",{children:e.fix},void 0,!1,void 0,this)},void 0,!1,void 0,this)}function V({tone:e,children:n}){return t("span",{class:`badge${e?` ${e}`:""}`,children:n},void 0,!1,void 0,this)}function Ot({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(y,{name:s?"check":"copy"},void 0,!1,void 0,this),s?"Copied":n]},void 0,!0,void 0,this)}function U({text:e}){return t("div",{class:"cmd",children:[t("code",{tabIndex:0,children:e},void 0,!1,void 0,this),t(Ot,{text:e},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function Q({href:e,children:n,class:s="btn secondary",onClick:o}){return t("a",{class:s,href:e,target:"_blank",rel:"noopener noreferrer",onClick:o,children:[n,t(y,{name:"external"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function Mt(e){let[n,s]=m(!1),o=(a)=>e.onFile(a&&a[0]?a[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:(a)=>{a.preventDefault(),s(!0)},onDragLeave:()=>s(!1),onDrop:(a)=>{a.preventDefault(),s(!1),o(a.dataTransfer?.files??null)},children:[t("input",{type:"file",name:e.name,accept:e.accept,"aria-labelledby":`${e.name}-label`,onChange:(a)=>o(a.currentTarget.files)},void 0,!1,void 0,this),t(y,{name:e.file?"check":"upload"},void 0,!1,void 0,this),t("span",{children:e.file?t(x,{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(x,{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 Dt({name:e,label:n,hint:s,autoComplete:o="current-password"}){let[a,r]=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:a?"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:()=>r(!a),"aria-pressed":a,children:a?"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 Ce({name:e,label:n,hint:s,value:o,placeholder:a,mono:r,autoComplete:i="off",onInput:l}){return t("div",{class:"field",children:[t("label",{for:e,children:n},void 0,!1,void 0,this),t("input",{class:`input${r?" mono":""}`,id:e,name:e,value:o,placeholder:a,autoComplete:i,spellcheck:!1,autoCapitalize:"off",autoCorrect:"off",onInput:l?(d)=>l(d.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 F({busy:e,children:n,...s}){return t("button",{...s,disabled:e||s.disabled,"aria-busy":e,children:[e&&t(O,{},void 0,!1,void 0,this),n]},void 0,!0,void 0,this)}function Vt({text:e}){return t("div",{class:"gate",children:t("div",{class:"row muted",role:"status",children:[t(O,{},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 Te({title:e,children:n}){return t(x,{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 Kn({problem:e}){return t(Te,{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(U,{text:"bunx @doguyilmaz/tapster setup"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function Yn(){return t(Te,{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(U,{text:"bunx @doguyilmaz/tapster setup"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function Jn(){let e=re.value;E(()=>{let o=3000,a=0,r=async()=>{if(!document.hidden)await lt();o=Math.min(o*1.4,15000),a=window.setTimeout(r,o)};return a=window.setTimeout(r,o),()=>clearTimeout(a)},[]);let n=t("p",{class:"row muted small",children:[t(O,{},void 0,!1,void 0,this)," tapster checks again by itself every few seconds."]},void 0,!0,void 0,this);if(Oe.value)return t(Te,{title:"tapster could not reach GitHub",children:[t(N,{problem:Oe.value},void 0,!1,void 0,this),n]},void 0,!0,void 0,this);if(e?.state==="no-gh")return t(Te,{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(U,{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(U,{text:"gh auth login"},void 0,!1,void 0,this),n]},void 0,!0,void 0,this);if(e?.state==="signed-out")return t(Te,{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(U,{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(Te,{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(U,{text:`gh auth refresh -s ${s.join(",")}`},void 0,!1,void 0,this),t(S,{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 Zn=(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()},Ls=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"]),Fs=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 Gs({name:e,fix:n,hub:s,onFixed:o}){let[a,r]=m(!1),[i,l]=m(null);if(Ls.has(e))return t("span",{class:"stack tight",children:[t("span",{class:"row",children:t(F,{busy:a,class:"btn secondary small",onClick:async()=>{r(!0),l(null);try{await j("/api/hub/protect",{hub:s}),await J(),o()}catch(p){l(I(p))}finally{r(!1)}},children:[t(y,{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:i},void 0,!1,void 0,this)]},void 0,!0,void 0,this);let d=Fs.has(e)&&!(e==="tapster.yml is valid"&&n!=="Run tapster init.")?"files":e==="the credentials this hub needs are stored"?null:void 0;if(d===void 0)return null;return t("span",{class:"row",children:t("button",{type:"button",class:"btn secondary small",onClick:()=>{Be.value=d,pe("/setup")},children:["Fix it in Setup",t(y,{name:"arrow"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}var Bt=(e)=>e.charAt(0).toUpperCase()+e.slice(1),Us={success:{tone:"ok",text:"Done"},failure:{tone:"error",text:"Failed"},cancelled:{text:"Cancelled"},skipped:{text:"Skipped"}};function Xn(){let e=te.value,[n,s]=m(null),[o,a]=m(null),[r,i]=m(!1),[l,d]=m(!1),p=async()=>{if(!e)return;i(!0),a(null);try{s(await K(`/api/hub/health?hub=${encodeURIComponent(e.name)}`))}catch(u){a(I(u))}finally{i(!1)}};if(E(()=>{p()},[e?.name]),!e)return null;let h=n?.checks.filter((u)=>!u.ok)??[],f=n?.checks.filter((u)=>u.ok)??[],c=async()=>{d(!0);try{let u=await j("/api/hub/run",{hub:e.name});Y("ok",u.started?"The hub run started. It shows up below in a few seconds.":"A hub run is already queued or running. It shows up below."),setTimeout(()=>void p(),4000)}catch(u){a(I(u))}finally{d(!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 p(),disabled:r,children:[t(y,{name:"refresh",spin:r},void 0,!1,void 0,this),"Check again"]},void 0,!0,void 0,this),t(F,{busy:l,class:"btn primary",onClick:c,children:[t(y,{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(S,{tone:"warn",title:`The hub opened issue #${e.issue.number}: tapster: the hub needs attention`,children:[t("span",{children:["Updated ",Zn(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),r&&!n&&t("p",{class:"row muted",role:"status",children:[t(O,{},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((u)=>t("div",{class:"item",style:"grid-template-columns: auto minmax(0, 1fr); align-items: start",children:[t("span",{class:u.ok?"ok":"bad",style:`color: var(--${u.ok?"green":"wax"}); padding-top: 0.15rem`,children:t(y,{name:u.ok?"check":"alert",label:u.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:Bt(u.name)},void 0,!1,void 0,this),!u.ok&&t("span",{class:"muted small",children:u.fix},void 0,!1,void 0,this),!u.ok&&t(Gs,{name:u.name,fix:u.fix,hub:e.name,onFixed:()=>void p()},void 0,!1,void 0,this),u.note&&t("span",{class:"faint small",children:[Bt(u.note),"."]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},u.name,!0,void 0,this))},void 0,!1,void 0,this),n?.note&&t("p",{class:"muted small",children:[Bt(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((u)=>{let v=u.status==="completed"?Us[u.conclusion??""]??{text:u.conclusion??"Done"}:{tone:"warn",text:u.status==="queued"?"Queued":"Running"};return t("div",{class:"item",children:[t("span",{class:"stack tight",style:"gap: 0.1rem",children:[t("span",{children:u.event==="schedule"?"On schedule":u.event==="workflow_dispatch"?"Started by hand or the doorbell":u.event},void 0,!1,void 0,this),t("span",{class:"faint small",children:Zn(u.created)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),t("span",{class:"row",children:[t(V,{tone:v.tone,children:v.text},void 0,!1,void 0,this),t(Q,{href:u.url,class:"btn quiet small",children:"Log"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},u.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 Qn({onChosen:e,onCancel:n}){let[s,o]=m(null),[a,r]=m("homebrew-tap"),[i,l]=m("public"),[d,p]=m(!1),h=re.value?.state==="ok"?re.value.login:"you";E(()=>{Gn().catch((g)=>o(I(g)))},[]);let f=It.value,c=De.value?.here.hub??null,u=f?.some((g)=>g.name.toLowerCase()===`${h}/${a}`.toLowerCase())??!1,v=/^homebrew-[A-Za-z0-9._-]{1,80}$/.test(a),k=async(g)=>{g.preventDefault(),p(!0),o(null);try{let w=await j("/api/hubs",{name:a,private:i==="private"});e(w.hub)}catch(w){o(I(w))}finally{p(!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(O,{},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(y,{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===c&&t(V,{tone:"next",children:"This folder"},void 0,!1,void 0,this),t(V,{tone:g.private?"warn":void 0,children:g.private?"Private":"Public"},void 0,!1,void 0,this),t(y,{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:k,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:a,onInput:(g)=>r(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,"/",a.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:i==="public",onChange:()=>l("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:i==="private",onChange:()=>l("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),u&&t(S,{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(F,{busy:d,class:"btn primary",type:"submit",disabled:!v||u,children:["Create ",h,"/",a]},void 0,!0,void 0,this),!v&&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)}var Ws=/^v(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-([0-9A-Za-z]+(?:\\.[0-9A-Za-z]+)*))?$/;function Lt(e){let n=Ws.exec(e);if(!n)return null;return{major:Number(n[1]),minor:Number(n[2]),patch:Number(n[3]),pre:n[4]??null}}function es(e,n){for(let a of["major","minor","patch"])if(e[a]!==n[a])return e[a]-n[a];if(e.pre===n.pre)return 0;if(e.pre===null)return 1;if(n.pre===null)return-1;let s=e.pre.split("."),o=n.pre.split(".");for(let a=0;a<Math.max(s.length,o.length);a++){let r=s[a],i=o[a];if(r===void 0)return-1;if(i===void 0)return 1;let l=/^\\d+$/.test(r),d=/^\\d+$/.test(i);if(l&&d&&Number(r)!==Number(i))return Number(r)-Number(i);if(l!==d)return l?-1:1;if(r!==i)return r<i?-1:1}return 0}function ts(e,n){let s=Lt(e);if(!s)return"Use the shape v1.2.3, such as v1.2.3 or v1.2.3-rc.1";if(n&&es(s,Lt(n))<=0)return`Pick a version higher than ${n}, the highest tag on GitHub`;return null}function ns(e,n,s){let o=`gh api --method POST repos/${e}/git/refs -f ref=refs/tags/${n} -f sha=`;if("sha"in s)return/^[0-9a-f]{40,64}$/.test(s.sha)?`${o}${s.sha}`:null;return/^[A-Za-z0-9._/-]+$/.test(s.branch)?`${o}"$(gh api repos/${e}/commits/${s.branch} --jq .sha)"`:null}var zs=(e,n)=>`${e} ${n}${e===1?"":"s"}`;function ut(e){if(e.unreadable)return[{id:"setup",state:"attention",label:"GitHub did not show it"}];let n=e.release,s=n.draft?.note?{id:"release",state:"attention",label:`Fix the draft ${n.draft.tag}`}:n.draft?{id:"release",state:"wait",label:`The hub publishes ${n.draft.tag} next`}:n.latest?.byHub?{id:"release",state:"done",label:`Published ${n.latest.tag}`}:n.atHead?{id:"release",state:"done",label:`Nothing new since ${n.atHead}`}:{id:"release",state:"open",label:n.autoTag?"Release from the workflow":`Release ${n.next}`},o=[{id:"setup",state:e.setup.ok?"done":"open",label:"Set up the release workflow"},{id:"protect",state:e.protection.ok||e.protection.off?"done":"open",label:"Protect the repository"},{id:"entry",state:e.entry.state==="merged"?"done":"open",label:e.entry.state==="proposed"?"Merge the hub entry":"Propose the hub entry"},e.app.reaches===!0?{id:"app",state:"done",label:"Install the App"}:e.app.running?{id:"app",state:"wait",label:"The hub checks its App"}:{id:"app",state:"open",label:e.app.reaches===!1?"Install the App":"Let the hub check its App"},s];if(e.secrets.names.length&&e.secrets.published)o.push({id:"secrets",state:"open",label:`Delete ${zs(e.secrets.names.length,"old secret")}`});return o}var Ft=(e)=>ut(e).find((n)=>n.state!=="done")??null,qs=["setup","protect","entry","app"],Ks=(e)=>ut(e).every((n)=>!qs.includes(n.id)||n.state==="done");function ss(e){if(e.unreadable)return{ok:!1,why:e.unreadable};if(e.release.autoTag)return{ok:!1,why:"The release workflow tags each release by itself."};if(!e.setup.ok)return{ok:!1,why:`First the release workflow on ${e.defaultBranch} must be tapster\'s.`};if(!e.release.head)return{ok:!1,why:`GitHub did not show the latest commit on ${e.defaultBranch}. Check again in a moment.`};if(e.release.atHead)return{ok:!1,why:`Nothing new on ${e.defaultBranch} since ${e.release.atHead}.`};return{ok:!0,why:null}}function os(e,n){if(e===null)return{done:n>0,status:n?`${n} in the hub`:"None yet"};let s=e.filter((a)=>!Ks(a));if(s.length===1)return{done:!1,status:`${s[0].name}: ${Ft(s[0]).label}`};if(s.length>1)return{done:!1,status:`${s.length} projects need you`};let o=e.filter((a)=>a.entry.state==="merged").length;return{done:o>0,status:o?`${o} in the hub`:"None yet"}}var Ys=86400000;function Gt(e,n=Date.now()){let s=Date.parse(`${e}T00:00:00Z`);return!Number.isNaN(s)&&s-n<30*Ys}function Ut(e,n){if(e.apple.needed)return!0;return n===null?null:n==="yes"}function as(e,n,s=Date.now(),o=null){let a=Ut(e,n),r=e.protect.checks.filter((p)=>p.ok).length,i=os(o,e.packages.length),l=[{id:"protect",name:"Protect the hub",done:e.protect.done,status:e.protect.done?"All protections are on":r?`${r} 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:a===!0,skipped:a===!1,status:a===!0?"Signs macOS software":a===!1?"No macOS builds":"Your answer",open:"Your answer"},{id:"certificate",name:"Apple certificate",done:Boolean(e.apple.certificate&&e.apple.certificateStored),skipped:a===!1,attention:Boolean(e.apple.certificate&&Gt(e.apple.certificate.expires,s)),status:a===!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:a===!1,status:a===!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:i.done,status:i.status,open:"None yet"}],d=!1;return l.map((p)=>{let h;if(p.skipped)h="skipped";else if(p.attention)h="attention";else if(p.done)h="done";else if(!d)h="now",d=!0;else h="later";return{id:p.id,name:p.name,state:h,status:p.status}})}var rs=(e)=>(e.find((n)=>n.state==="now"||n.state==="attention")??e[e.length-1]).id;function pt(e,n){let s=e.split(`\n`),o=n.split(`\n`),a=s.length,r=o.length;if(a*r>4000000)return[...s.map((h)=>({kind:"del",text:h})),...o.map((h)=>({kind:"add",text:h}))];let i=Array.from({length:a+1},()=>Array(r+1).fill(0));for(let h=a-1;h>=0;h--)for(let f=r-1;f>=0;f--)i[h][f]=s[h]===o[f]?i[h+1][f+1]+1:Math.max(i[h+1][f],i[h][f+1]);let l=[],d=0,p=0;while(d<a&&p<r)if(s[d]===o[p])l.push({kind:"ctx",text:s[d]}),d++,p++;else if(i[d+1][p]>=i[d][p+1])l.push({kind:"del",text:s[d++]});else l.push({kind:"add",text:o[p++]});while(d<a)l.push({kind:"del",text:s[d++]});while(p<r)l.push({kind:"add",text:o[p++]});return l}function dt(e,n=3){let s=e.map((r,i)=>r.kind!=="ctx"||e.slice(Math.max(0,i-n),i+n+1).some((l)=>l.kind!=="ctx")),o=[],a=0;if(e.forEach((r,i)=>{if(s[i]){if(a)o.push({kind:"gap",text:`${a} unchanged lines`});a=0,o.push(r)}else a++}),a)o.push({kind:"gap",text:`${a} unchanged lines`});return o}var Js=(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 is(e){let n=[];for(let s of e){let[o="",...a]=s.split(`\n`),r=o.trim().replace(/^- /,"");if(!r||/^proposed the hub entry in |^open this page and choose Install/.test(r))continue;let i=n.at(-1),l;if(o.startsWith(" ")&&i&&i.block===null)l=i,l.text+=`${/[.:;!?]$/.test(l.text)?"":"."} ${r}`;else l={text:/^[a-z]+[\\s:;,]/.test(r)?r.charAt(0).toUpperCase()+r.slice(1):r,block:null},n.push(l);let d=0;while(d<a.length&&!l.text.endsWith(":"))l.text+=` ${a[d++].trim()}`;if(d<a.length)l.block=Js(a.slice(d))}return n}var Le={go:"Go with GoReleaser",bun:"Bun",app:"Mac app with Sparkle"},Wt=(e)=>{let n=new Date(e);return Number.isNaN(n.getTime())?e:n.toLocaleString(void 0,{dateStyle:"medium",timeStyle:"short"})},ls=(e)=>`hub=${encodeURIComponent(H.value??"")}&repo=${encodeURIComponent(e.repo)}`;function Zs({s:e}){let n=Ft(e);if(!n)return t(V,{tone:"ok",children:e.release.latest?`Published ${e.release.latest.tag}`:"Ready"},void 0,!1,void 0,this);return t(V,{tone:n.state==="attention"?"error":n.state==="wait"?void 0:"next",children:n.label},void 0,!1,void 0,this)}function ht({list:e,paths:n,onOpen:s}){return t("div",{class:"card list",children:e.map((o)=>{let a=n.get(o.repo.toLowerCase());return t("div",{class:"item",children:[t("button",{type:"button",class:"link",onClick:()=>s(o),children:[t("span",{class:"name",children:o.repo},void 0,!1,void 0,this),t("span",{class:"path",children:a?le(a):"No clone on this computer"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),t("span",{class:"row",children:[t(V,{children:Le[o.kind]??o.kind},void 0,!1,void 0,this),t(Zs,{s:o},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},o.repo,!0,void 0,this)})},void 0,!1,void 0,this)}var Xs={done:{icon:"check",cls:"ok",label:"Done"},open:{icon:"circle",cls:"no",label:"To do"},wait:{icon:"loader",cls:"no",label:"Waiting"},attention:{icon:"alert",cls:"bad",label:"Needs you"}};function cs({state:e}){let n=Xs[e];return t("span",{class:n.cls,children:e==="wait"?t(O,{label:n.label},void 0,!1,void 0,this):t(y,{name:n.icon,label:n.label},void 0,!1,void 0,this)},void 0,!1,void 0,this)}var zt=(e)=>{let n=e.join("; ");return`${n.charAt(0).toUpperCase()}${n.slice(1)}.`};function Pe({state:e,title:n,children:s}){return t("li",{children:[t(cs,{state:e},void 0,!1,void 0,this),t("span",{class:"stack tight",style:"gap: 0.3rem; flex: 1; min-width: 0",children:[t("strong",{children:n},void 0,!1,void 0,this),s]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function us(e){let n=e.app;if(n.how==="key")return n.reaches?`The App reaches ${e.repo}; tapster checked with the App\'s key.`:`The App does not reach ${e.repo} yet; tapster checked with the App\'s key.`;if(n.how==="run")return n.reaches?`The hub\'s check on ${Wt(n.at??"")} reached ${e.repo}.`:`The hub\'s check on ${Wt(n.at??"")} could not reach ${e.repo}: ${n.reason}.`;if(n.how==="release")return`The hub has published a release of ${e.name}, so its App reached ${e.repo} then.`;return zt([n.reason??"the hub has not checked it yet"])}function Qs({s:e,onStatus:n}){let[s,o]=m(!1),[a,r]=m(null),[i,l]=m(null),[d,p]=m(null),h=async()=>{p(null),o(!1);try{if(e.app.how==="key"){let v=await de(e.repo);if(v)n(v);return}let u=await j("/api/projects/check",{hub:H.value});l({running:!0,run:u.run}),r(Date.parse(u.at))}catch(u){p(I(u))}};E(()=>{if(!s)return;let u=()=>{if(document.hidden)return;o(!1),h()};return document.addEventListener("visibilitychange",u),addEventListener("focus",u),()=>{document.removeEventListener("visibilitychange",u),removeEventListener("focus",u)}},[s]),E(()=>{if(a===null)return;let u=0,v=6000,k=!1,g=Date.now()+1200000,w=async()=>{if(!document.hidden)try{let b=await K(`/api/projects/reach?${ls(e)}`);if(l({running:b.running,run:b.run}),!b.running&&b.since&&Date.parse(b.since)>=a-15000){let T=await de(e.repo);if(T)n(T);r(null),l(null);return}if(!b.running&&!k)k=!0,await j("/api/projects/check",{hub:H.value});v=6000}catch{v=Math.min(v*2,30000)}if(Date.now()<g)u=window.setTimeout(w,v);else r(null),l(null)};return u=window.setTimeout(w,3000),()=>clearTimeout(u)},[a,e.repo]);let f=a!==null||e.app.running,c=i?.run??(e.app.running?e.app.run:null);return t(x,{children:[t("span",{class:"muted",children:us(e)},void 0,!1,void 0,this),e.app.reaches===!1&&t("span",{class:"muted",children:["The hub cannot publish ",e.repo,\' until its App reaches it. GitHub preselects the project; keep "Only select repositories".\']},void 0,!0,void 0,this),f&&t("p",{class:"row muted small",role:"status",children:[t(O,{label:"Checking"},void 0,!1,void 0,this)," The hub checks its App now. This updates by itself when its run ends.",c&&t("a",{href:c,target:"_blank",rel:"noopener noreferrer",children:"Open the run"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),s&&!f&&t("p",{class:"muted small",role:"status",children:"Once you have clicked Install on GitHub, come back to this page: tapster then asks the hub to check."},void 0,!1,void 0,this),t(N,{problem:d},void 0,!1,void 0,this),e.app.reaches!==!0&&t("div",{class:"row",children:[e.app.installUrl?t(Q,{href:e.app.installUrl,class:e.app.reaches===!1?"btn primary small":"btn secondary small",onClick:()=>o(!0),children:["Install the App on ",e.name]},void 0,!0,void 0,this):t("span",{class:"muted small",children:"Create the hub\'s GitHub App in Setup first."},void 0,!1,void 0,this),t("button",{type:"button",class:"btn secondary small",onClick:()=>void h(),disabled:f,children:[t(y,{name:"refresh"},void 0,!1,void 0,this),"Check again"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function eo({s:e,tag:n,onStatus:s}){let[o,a]=m(null),[r,i]=m(null);E(()=>{let w=0,b=5000,T=!1,_=async()=>{if(!document.hidden)try{let R=await K(`/api/projects/follow?${ls(e)}&tag=${encodeURIComponent(n)}`);if(a(R),b=5000,R.draft&&!R.draft.note&&!T)T=!0,i(await j("/api/projects/publish",{hub:H.value,repo:e.repo}));let W=R.run?.status==="completed"&&R.run.conclusion!=="success"&&!R.draft&&!R.published;if(R.published||R.draft?.note||W){let X=await de(e.repo).catch(()=>null);if(X)s(X);return}}catch{b=Math.min(b*2,30000)}w=window.setTimeout(_,b)};return w=window.setTimeout(_,1000),()=>clearTimeout(w)},[n,e.repo]);let l=o?.run??null,d=l?.status==="completed",p=d&&l.conclusion==="success",h=Boolean(o?.draft||o?.published),f=r?o?.hubRun??null:null,c=fe(!1);if(f&&f.status!=="completed")c.current=!0;let u=f!==null&&f.status!=="completed"||Boolean(r?.started&&!c.current),v=o?.published?"Published":o?.draft?.note?"The hub will not publish it until the draft is fixed":u?r?.doorbell?"The doorbell started the hub; it signs and publishes it now":"The hub signs and publishes it now":r?.doorbell?"The doorbell starts the hub":"The hub signs and publishes it on its next run",k=te.value?.files.every??10,g=(w,b,T)=>t("li",{children:[t(cs,{state:w},void 0,!1,void 0,this),t("span",{class:"row",style:"gap: 0.5rem",children:[t("span",{children:b},void 0,!1,void 0,this),T&&t("a",{href:T.href,target:"_blank",rel:"noopener noreferrer",class:"small",children:T.label},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this);return t("div",{class:"stack tight",children:[t("p",{children:[t("strong",{children:["Tagged ",n]},void 0,!0,void 0,this)," ",t("span",{class:"muted",children:["on ",e.defaultBranch,"."]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),t("ol",{class:"checks","aria-live":"polite",children:[g(!l?"wait":!d?"wait":p||h?"done":"attention",!l?"The release workflow starts":!d?"The release workflow runs":p||h?"The release workflow finished":`The release workflow ended: ${l.conclusion??"unknown"}`,l?{href:l.url,label:"Open the run"}:void 0),g(o?.draft?.note?"attention":h?"done":"wait",o?.draft?.note?o.draft.note:h?"The workflow opened the draft":"The workflow opens a draft",o?.draft?{href:o.draft.url,label:"Open the draft"}:void 0),g(o?.published?"done":o?.draft?.note?"open":"wait",v,o?.published?{href:o.published.url,label:"Open the release"}:u&&f?{href:f.url,label:"Open the hub\'s run"}:{href:o?.hub??"#",label:"Hub runs"})]},void 0,!0,void 0,this),!o?.published&&t("p",{class:"muted small",children:["Without this page open, the hub still publishes it on its schedule, within about ",k," minutes."]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function to({s:e,onStatus:n}){let[s,o]=m(e.release.next),[a,r]=m(!1),[i,l]=m(null),[d,p]=m(null);if(E(()=>o(e.release.next),[e.release.next]),d)return t(eo,{s:e,tag:d,onStatus:n},void 0,!1,void 0,this);let h=ss(e);if(!h.ok)return t("p",{class:"muted",children:h.why},void 0,!1,void 0,this);let f=e.release.head,c=s.trim(),u=ts(c,e.release.highest),v=`version-${e.name}`,k=async()=>{r(!0),l(null);try{await j("/api/projects/release",{hub:H.value,repo:e.repo,tag:c,sha:f.sha}),p(c),Y("ok",`Tagged ${c} on ${e.repo}.`)}catch(g){l(I(g))}finally{r(!1)}};return t("div",{class:"release stack tight",children:[t("p",{class:"muted small",children:"tapster tags this commit on GitHub with your sign-in, never the clone on this computer. The tag starts the release workflow."},void 0,!1,void 0,this),t("dl",{class:"facts",children:[t("dt",{children:"Commit"},void 0,!1,void 0,this),t("dd",{children:[t("a",{href:f.url,target:"_blank",rel:"noopener noreferrer",class:"mono",children:f.sha.slice(0,7)},void 0,!1,void 0,this)," ",f.subject]},void 0,!0,void 0,this),t("dt",{children:"Date"},void 0,!1,void 0,this),t("dd",{children:Wt(f.date)},void 0,!1,void 0,this),t("dt",{children:"Branch"},void 0,!1,void 0,this),t("dd",{class:"mono",children:e.defaultBranch},void 0,!1,void 0,this)]},void 0,!0,void 0,this),t("div",{class:"field",children:[t("label",{for:v,children:"Version"},void 0,!1,void 0,this),t("input",{id:v,class:"input mono",value:s,onInput:(g)=>o(g.currentTarget.value),spellcheck:!1,autoComplete:"off","aria-invalid":u?"true":void 0,"aria-describedby":`${v}-hint`},void 0,!1,void 0,this),t("span",{class:u?"hint bad":"hint",id:`${v}-hint`,children:u?`${u}.`:e.release.highest?`The next patch after ${e.release.highest}, the highest tag on GitHub.`:"GitHub has no version tag for this project yet."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),e.entry.state!=="merged"&&t(S,{tone:"info",children:"The hub publishes it once you merge the hub entry."},void 0,!1,void 0,this),t("p",{class:"muted small",children:[us(e),e.app.reaches===!1?" The hub cannot publish this release until its App reaches the project.":""]},void 0,!0,void 0,this),t(N,{problem:i},void 0,!1,void 0,this),t("div",{class:"row",children:t(F,{busy:a,class:"btn primary",onClick:k,disabled:Boolean(u),children:[t(y,{name:"play"},void 0,!1,void 0,this),"Release ",c||"a version"]},void 0,!0,void 0,this)},void 0,!1,void 0,this),!u&&t("details",{class:"more",children:[t("summary",{children:"Or tag it from a terminal"},void 0,!1,void 0,this),t(U,{text:ns(e.repo,c,{sha:f.sha})??""},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function ps({s:e,onStatus:n,fix:s}){let[o,a]=m(!1),r=ut(e),i=(h)=>r.find((f)=>f.id===h)?.state??"done",l=e.release,d=async()=>{a(!0);try{let h=await de(e.repo);if(h)n(h)}catch(h){Y("error",I(h).reason)}finally{a(!1)}},p=e.secrets.names.map((h)=>`gh secret delete ${h} --repo ${e.repo}`);return t("section",{class:"stack tight","aria-labelledby":`status-${e.name}`,children:[t("div",{class:"spread",children:[t("h3",{id:`status-${e.name}`,class:"section-title",children:["Where ",e.name," stands"]},void 0,!0,void 0,this),t(F,{busy:o,class:"btn quiet small",onClick:d,children:[!o&&t(y,{name:"refresh"},void 0,!1,void 0,this),"Refresh"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),e.unreadable?t(S,{tone:"error",title:`GitHub did not show ${e.repo}`,children:t("span",{children:[e.unreadable," If the repository was renamed or deleted, change or remove its entry in the hub\'s tapster.yml."]},void 0,!0,void 0,this)},void 0,!1,void 0,this):t("ol",{class:"checks status",children:[t(Pe,{state:i("setup"),title:"Release workflow",children:e.setup.ok?t("span",{class:"muted",children:["On ",e.defaultBranch,", the release workflow opens drafts, attests the archives and leaves signing to the hub."]},void 0,!0,void 0,this):t(x,{children:[t("span",{class:"muted",children:zt(e.setup.problems)},void 0,!1,void 0,this),s("setup")]},void 0,!0,void 0,this)},void 0,!1,void 0,this),t(Pe,{state:i("protect"),title:"Protection",children:e.protection.off?t("span",{class:"muted",children:"The hub entry sets protection: off, so a stolen App key could tag code the hub would sign."},void 0,!1,void 0,this):e.protection.ok?t("span",{class:"muted",children:"Only you can create, move or delete its branches and tags."},void 0,!1,void 0,this):t(x,{children:[t("span",{class:"muted",children:["Not protected by tapster\'s rulesets. ",zt(e.protection.problems)]},void 0,!0,void 0,this),s("protect")]},void 0,!0,void 0,this)},void 0,!1,void 0,this),t(Pe,{state:i("entry"),title:"Hub entry",children:e.entry.state==="merged"?t("span",{class:"muted",children:["In ",H.value,"\'s tapster.yml."]},void 0,!0,void 0,this):e.entry.state==="proposed"?t(x,{children:[t("span",{class:"muted",children:["Waiting in a pull request on ",H.value,". Merge it to let the hub publish ",e.name,"."]},void 0,!0,void 0,this),t("div",{class:"row",children:t(Q,{href:e.entry.pr,class:"btn primary small",children:[t(y,{name:"pr"},void 0,!1,void 0,this),"Review and merge"]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this):t(x,{children:[t("span",{class:"muted",children:"Not in the hub yet."},void 0,!1,void 0,this),s("entry")]},void 0,!0,void 0,this)},void 0,!1,void 0,this),t(Pe,{state:i("app"),title:"The hub\'s App",children:t(Qs,{s:e,onStatus:n},void 0,!1,void 0,this)},void 0,!1,void 0,this),t(Pe,{state:i("release"),title:"Releases",children:[l.draft?l.draft.note?t(S,{tone:"error",title:`The hub will not publish the draft ${l.draft.tag}`,children:[t("span",{children:l.draft.note},void 0,!1,void 0,this),t("a",{href:l.draft.url,target:"_blank",rel:"noopener noreferrer",children:"Open the draft"},void 0,!1,void 0,this)]},void 0,!0,void 0,this):t("span",{class:"muted",children:[l.draft.tag," waits as a draft; the hub publishes it on its next run."," ",t("a",{href:l.draft.url,target:"_blank",rel:"noopener noreferrer",children:"Open the draft"},void 0,!1,void 0,this)]},void 0,!0,void 0,this):l.latest?t("span",{class:"muted",children:["The latest release is"," ",t("a",{href:l.latest.url,target:"_blank",rel:"noopener noreferrer",children:l.latest.tag},void 0,!1,void 0,this),l.latest.byHub?", published by the hub.":". The hub did not publish it."]},void 0,!0,void 0,this):t("span",{class:"muted",children:"No release yet."},void 0,!1,void 0,this),t(to,{s:e,onStatus:n},void 0,!1,void 0,this)]},void 0,!0,void 0,this),e.secrets.names.length>0&&e.secrets.published&&t(Pe,{state:"open",title:"Old release secrets",children:[t("span",{class:"muted",children:["The hub has published a release of ",e.name,", so these secrets are no longer needed. tapster shows their names only."]},void 0,!0,void 0,this),p.map((h)=>t(U,{text:h},h,!1,void 0,this))]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),e.secrets.names.length>0&&!e.secrets.published&&t(S,{tone:"info",title:"Old release secrets",children:t("span",{children:[e.repo," still holds ",e.secrets.names.join(", "),". Delete them once the hub has published a release of ",e.name,"; this card then shows the commands."]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function no({title:e,sub:n,onClose:s,children:o}){let a=fe(null);return E(()=>{let r=document.activeElement;a.current?.querySelector("button")?.focus();let i=(l)=>{if(l.key==="Escape")s();if(l.key!=="Tab"||!a.current)return;let d=[...a.current.querySelectorAll("a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), summary, [tabindex]:not([tabindex=\'-1\'])")],p=d[0],h=d[d.length-1];if(!p||!h)return;if(!a.current.contains(document.activeElement))l.preventDefault(),p.focus();else if(l.shiftKey&&document.activeElement===p)l.preventDefault(),h.focus();else if(!l.shiftKey&&document.activeElement===h)l.preventDefault(),p.focus()};return addEventListener("keydown",i),()=>{removeEventListener("keydown",i),r?.focus()}},[]),t(x,{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:a,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},void 0,!1,void 0,this),t("span",{class:"faint small",style:"overflow-wrap: anywhere",children:n},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(y,{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:o},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function qt({checked:e,onChange:n,title:s,children:o}){return t("label",{class:"switch",children:[t("input",{type:"checkbox",checked:e,onChange:(a)=>n(a.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)}var ds={create:{label:"New",tone:"next"},remove:{label:"Removed",tone:"error"},update:{label:"Changed",tone:"warn"},same:{label:"No changes"}};function so({view:e}){return t("div",{class:"stack tight files",children:e.files.map((n)=>{let s=n.before===null?null:dt(pt(n.before,n.after??""));return t("details",{class:"file",open:n.change!=="same",children:[t("summary",{children:[t(y,{name:"file"},void 0,!1,void 0,this),t("code",{children:n.path},void 0,!1,void 0,this),t(V,{tone:ds[n.change].tone,children:ds[n.change].label},void 0,!1,void 0,this)]},void 0,!0,void 0,this),t("pre",{class:"block diff",tabIndex:0,children:s?s.map((o,a)=>t("span",{class:o.kind==="gap"?"hunk":o.kind,children:[o.kind==="add"?"+ ":o.kind==="del"?"- ":o.kind==="gap"?"@ ":" ",o.text,`\n`]},a,!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 Kt({repo:e,path:n,files:s,ahead:o}){let[a,r]=m(null),[i,l]=m(null),[d,p]=m(null),[h,f]=m(!1),[c,u]=m(!1);E(()=>{if(r(null),s.length)j("/api/projects/diff",{path:n,files:s}).then(r,(b)=>l(I(b)))},[n,s.join(`\n`)]);let v=async(b,T)=>{p(b),l(null);try{await T()}catch(_){l(I(_))}finally{p(null)}},k=a?.files.filter((b)=>b.change!=="same")??[],g=s.length===0||a!==null&&k.length===0,w=t(F,{busy:d==="push",class:"btn primary",onClick:()=>v("push",async()=>{await j("/api/projects/push",{path:n}),u(!0),Y("ok",`Pushed ${e}.`)}),children:"Push"},void 0,!1,void 0,this);return t("div",{class:"stack tight",children:[s.length>0&&!a&&!i&&t(O,{label:"Reading the changes"},void 0,!1,void 0,this),a&&t(so,{view:a},void 0,!1,void 0,this),t(N,{problem:i},void 0,!1,void 0,this),g?t("div",{class:"row",children:[t("span",{class:"row muted",children:[t(y,{name:"check"},void 0,!1,void 0,this)," No changes: the clone\'s files match its last commit."]},void 0,!0,void 0,this),o!==null&&o>0&&(c?t(V,{tone:"ok",children:"Pushed"},void 0,!1,void 0,this):w)]},void 0,!0,void 0,this):a&&t(x,{children:[t("div",{class:"row",children:[h?t(V,{tone:"ok",children:"Committed"},void 0,!1,void 0,this):t(F,{busy:d==="commit",class:"btn primary",onClick:()=>v("commit",async()=>{await j("/api/projects/commit",{path:n,files:k.map((b)=>b.path)}),f(!0)}),children:["Commit ",k.length===1?"this file":"these files"]},void 0,!0,void 0,this),h&&(c?t(V,{tone:"ok",children:"Pushed"},void 0,!1,void 0,this):w)]},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)]},void 0,!0,void 0,this)}function oo({info:e,hubName:n,status:s,onAdded:o,onCancel:a}){let[r,i]=m(e.workflow??"release.yml"),[l,d]=m(s?.release.autoTag??!1),[p,h]=m(e.dependabot),[f,c]=m(!1),[u,v]=m(!1),[k,g]=m(null),w=e.kind==="go"&&e.workflows.length===0,b=async()=>{v(!0),g(null);try{o(await j("/api/projects/add",{hub:n,path:e.path,options:{workflow:r,autoTag:l,dependabot:p,force:f}})),J()}catch(T){g(I(T))}finally{v(!1)}};return t(x,{children:[t("dl",{class:"facts",children:[t("dt",{children:"Kind"},void 0,!1,void 0,this),t("dd",{children:Le[e.kind]},void 0,!1,void 0,this),t("dt",{children:"Branch"},void 0,!1,void 0,this),t("dd",{class:"mono",children:e.branch},void 0,!1,void 0,this),t("dt",{children:"Repository"},void 0,!1,void 0,this),t("dd",{children:[e.private?"Private":"Public",", ",e.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:e.inHub?"Already in the hub":e.proposed?"Proposed, waiting for you to merge":"Not in the hub yet"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),e.branch!==e.defaultBranch&&t(S,{tone:"warn",title:`This clone is on ${e.branch}, not ${e.defaultBranch}`,children:t("span",{children:["tapster changes the files on ",e.branch,". Releases use the workflow on ",e.defaultBranch,", so the change counts once it is merged there."]},void 0,!0,void 0,this)},void 0,!1,void 0,this),e.dirty.length>0&&t(S,{tone:"warn",title:"Uncommitted changes in files tapster edits",children:t("span",{children:[e.dirty.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),e.private&&t(S,{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),!e.apple&&t(S,{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),e.kind==="go"&&(w?t(S,{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:r,onChange:(T)=>i(T.currentTarget.value),children:e.workflows.map((T)=>t("option",{value:T,children:[".github/workflows/",T]},T,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)),e.kind!=="go"&&e.releaseFlow==="other"&&t(qt,{checked:f,onChange:c,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(qt,{checked:l,onChange:d,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(qt,{checked:p,onChange:h,title:"Keep Dependabot\'s pull requests",children:[e.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(y,{name:"right"},void 0,!1,void 0,this),t("span",{children:[e.kind==="go"?`Edits .goreleaser.yaml and .github/workflows/${r}: 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(y,{name:"right"},void 0,!1,void 0,this),t("span",{children:["Protects ",e.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(y,{name:"right"},void 0,!1,void 0,this),t("span",{children:s&&s.entry.state!=="missing"?`Keeps the project\'s entry in ${n} as it is.`:`Proposes the project\'s entry to ${n} as a pull request.`},void 0,!1,void 0,this)]},void 0,!0,void 0,this),l&&t("li",{children:[t(y,{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(N,{problem:k},void 0,!1,void 0,this),t("div",{class:"row",children:[t(F,{busy:u,class:"btn primary",onClick:b,disabled:w,children:s?"Update the project":`Add to ${n}`},void 0,!1,void 0,this),a&&t("button",{type:"button",class:"btn quiet",onClick:a,children:"Cancel"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function ao({path:e,others:n,onPick:s}){return t(S,{tone:"info",title:"This repository has more than one clone here",children:[t("span",{children:["tapster uses ",le(e),", the clone on the default branch or the one changed last. You can pick another:"]},void 0,!0,void 0,this),t("ul",{class:"log",children:n.map((o)=>t("li",{class:"row",style:"justify-content: space-between",children:[t("code",{children:le(o)},void 0,!1,void 0,this),t("button",{type:"button",class:"btn secondary small",onClick:()=>s(o),children:"Use this clone"},void 0,!1,void 0,this)]},o,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function ft({target:e,hubName:n,onClose:s}){let[o,a]=m(e.path),[r,i]=m(e.others),l=q.value?.hub===n?q.value.list.find((P)=>P.repo.toLowerCase()===e.repo.toLowerCase())??null:null,[d,p]=m(l),[h,f]=m(e.listed&&!l),[c,u]=m(null),[v,k]=m(null),[g,w]=m(!1),[b,T]=m(null),_=(P)=>j("/api/projects/inspect",{hub:n,path:P}).then(u,(z)=>k(I(z)));E(()=>{if(u(null),k(null),o)_(o)},[o]),E(()=>{if(!h)return;de(e.repo).then((P)=>p(P&&P.entry.state!=="missing"?P:null),(P)=>k(I(P))).finally(()=>f(!1))},[]);let R=(P)=>{i([...r.filter((z)=>z!==P),...o?[o]:[]]),a(P),w(!1),T(null)},W=(P)=>{if(T(P),w(!1),o)_(o);Se().catch(()=>{return}),de(e.repo).then(p,(z)=>k(I(z)))},X=d!==null&&(d.entry.state==="missing"||!d.protection.ok&&!d.protection.off||!d.setup.ok&&(!c||!c.ready)),Z=d&&t(ps,{s:d,onStatus:p,fix:(P)=>{if(!o)return P==="setup"||X?t("span",{class:"muted small",children:"No clone of it turned up on this computer. Add its folder in Projects or run tapster add in a clone."},void 0,!1,void 0,this):null;if(P!=="setup"||!c)return null;if(b?.files.length)return t("span",{class:"muted small",children:["Commit and push the changes above",c.branch===c.defaultBranch?"":`, then merge them into ${c.defaultBranch}`,". Then click Refresh."]},void 0,!0,void 0,this);if(!c.ready)return t("span",{class:"muted small",children:"The clone does not have tapster\'s release files yet. Update the project below."},void 0,!1,void 0,this);if(c.dirty.length)return t(x,{children:[t("span",{class:"muted small",children:["The clone has tapster\'s files. Commit and push them, then merge them into ",c.defaultBranch," if you work on another branch."]},void 0,!0,void 0,this),t(Kt,{repo:e.repo,path:c.path,files:c.dirty,ahead:c.ahead},void 0,!1,void 0,this)]},void 0,!0,void 0,this);if(c.ahead!==null&&c.ahead>0)return t(x,{children:[t("span",{class:"muted small",children:"The clone\'s last commit has tapster\'s files but is not on GitHub yet."},void 0,!1,void 0,this),t(Kt,{repo:e.repo,path:c.path,files:[],ahead:c.ahead},void 0,!1,void 0,this)]},void 0,!0,void 0,this);return t("span",{class:"muted small",children:c.branch===c.defaultBranch?`The clone has tapster\'s files. Push ${c.branch}, then check again.`:`The clone\'s branch ${c.branch} has tapster\'s files. Merge it into ${c.defaultBranch} on GitHub.`},void 0,!1,void 0,this)}},void 0,!1,void 0,this);return t(no,{title:e.repo,sub:o?le(o):"No clone on this computer",onClose:s,children:[o&&!c&&!v&&t("p",{class:"row muted",role:"status",children:[t(O,{},void 0,!1,void 0,this)," Reading the clone and its repository"]},void 0,!0,void 0,this),t(N,{problem:v},void 0,!1,void 0,this),o&&r.length>0&&!b&&t(ao,{path:o,others:r,onPick:R},void 0,!1,void 0,this),h?t("p",{class:"row muted",role:"status",children:[t(O,{},void 0,!1,void 0,this)," Reading where ",e.repo," stands"]},void 0,!0,void 0,this):b?t(x,{children:[t(S,{tone:"ok",title:`tapster prepared ${e.repo}`},void 0,!1,void 0,this),t("ul",{class:"checks small",children:is(b.lines).map((P,z)=>t("li",{children:[t(y,{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:P.text},void 0,!1,void 0,this),P.block&&t("pre",{class:"block",tabIndex:0,children:P.block},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},z,!0,void 0,this))},void 0,!1,void 0,this),t("section",{class:"stack tight",children:[t("h3",{class:"section-title",children:"Review and commit the changes"},void 0,!1,void 0,this),t(Kt,{repo:e.repo,path:o,files:b.files,ahead:c?.ahead??null},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Z??t(O,{label:"Reading the project\'s status"},void 0,!1,void 0,this)]},void 0,!0,void 0,this):d&&!g?t(x,{children:[Z,X&&c&&t("div",{class:"row",style:"border-top: 1px solid var(--line); padding-top: 1rem",children:[t("button",{type:"button",class:"btn primary",onClick:()=>w(!0),children:["Update the project",t(y,{name:"arrow"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),t("span",{class:"muted small",children:"tapster prepares the release files, protects the repository and proposes a missing entry."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),X&&!o&&t(U,{text:"bunx @doguyilmaz/tapster add"},void 0,!1,void 0,this)]},void 0,!0,void 0,this):c&&t(oo,{info:c,hubName:n,status:d,onAdded:W,onCancel:d?()=>w(!1):null},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function hs({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:[le(e.path),e.others.length?` and ${e.others.length} more ${e.others.length===1?"clone":"clones"}`:""]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),t("span",{class:"row",children:[e.kind?t(V,{children:Le[e.kind]},void 0,!1,void 0,this):t("span",{class:"muted small",children:e.why},void 0,!1,void 0,this),e.kind&&t("button",{type:"button",class:"btn secondary small",onClick:()=>n(e),"aria-label":`Add ${e.repo}`,children:["Add",t(y,{name:"arrow"},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 Yt=(e)=>new Map(e.map((n)=>[n.repo.toLowerCase(),n]));function Jt(e,n){let s=n.get(e.repo.toLowerCase());return{repo:e.repo,path:s?.path??null,others:s?.others??[],listed:!0}}function fs(){let e=te.value,[n,s]=m(null),[o,a]=m(Rt()),[r,i]=m(""),[l,d]=m(!1),[p,h]=m(null),[f,c]=m(!1),u=async(C=o)=>{if(!e)return;c(!0),s(null);try{await Promise.all([Se(C),Ve()])}catch(Z){s(I(Z))}finally{c(!1)}};if(E(()=>{u()},[e?.name]),!e)return null;let v=(C)=>{C.preventDefault();let Z=r.trim().replace(/^[\'"]|[\'"]$/g,"");if(!Z)return;let P=[Z,...o.filter((z)=>z!==Z)].slice(0,10);a(P),Wn(P),i(""),u(P)},k=ie.value?.hub===e.name?ie.value.scan:null,g=q.value?.hub===e.name?q.value.list:null,w=k?.projects??[],b=Yt(w),T=new Set((g??[]).map((C)=>C.repo.toLowerCase())),_=(C)=>T.has(C.repo.toLowerCase())||C.inHub||C.proposed!==null,R=w.filter((C)=>C.kind&&!_(C)),W=w.filter((C)=>!C.kind&&!_(C)),X=(C)=>h({repo:C.repo,path:C.path,others:C.others,listed:_(C)});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 u(),disabled:f,children:[t(y,{name:"refresh",spin:f},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:v,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:r,onInput:(C)=>i(C.currentTarget.value),spellcheck:!1,autoComplete:"off"},void 0,!1,void 0,this),t("button",{class:"btn secondary",type:"submit",children:[t(y,{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:n??ue.value},void 0,!1,void 0,this),f&&!k&&t("p",{class:"row muted",role:"status",children:[t(O,{},void 0,!1,void 0,this)," Looking through your folders"]},void 0,!0,void 0,this),(g?.length??0)>0&&t("section",{class:"stack tight","aria-labelledby":"in-hub",children:[t("h2",{id:"in-hub",class:"section-title",children:["In the hub (",g.length,")"]},void 0,!0,void 0,this),t(ht,{list:g,paths:new Map([...b].map(([C,Z])=>[C,Z.path])),onOpen:(C)=>h(Jt(C,b))},void 0,!1,void 0,this)]},void 0,!0,void 0,this),k&&t(x,{children:[t("section",{class:"stack tight","aria-labelledby":"ready",children:[t("h2",{id:"ready",class:"section-title",children:["Ready to add (",R.length,")"]},void 0,!0,void 0,this),R.length?t("div",{class:"card list",children:R.map((C)=>t(hs,{p:C,onOpen:X},C.path,!1,void 0,this))},void 0,!1,void 0,this):t("p",{class:"muted",children:[w.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),W.length>0&&t("section",{class:"stack tight",children:[t("button",{type:"button",class:"btn quiet",onClick:()=>d(!l),"aria-expanded":l,style:"justify-self: start",children:[t(y,{name:l?"down":"right"},void 0,!1,void 0,this),W.length," other ",W.length===1?"clone":"clones"," tapster cannot publish yet"]},void 0,!0,void 0,this),l&&t("div",{class:"card list",children:W.map((C)=>t(hs,{p:C,onOpen:X},C.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 ",k.roots.map(le).join(", "),k.truncated?"; it stopped early because there were many folders":"",". ",k.others?`${k.others} ${k.others===1?"clone belongs":"clones belong"} to other owners and ${k.others===1?"is":"are"} not listed.`:""]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),p&&t(ft,{target:p,hubName:e.name,onClose:()=>h(null)},p.repo,!1,void 0,this)]},void 0,!0,void 0,this)}function ro({stop:e,index:n}){if(e.state==="done")return t("span",{class:"dot",children:t(y,{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(y,{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 ee({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 Zt({text:e}){return t("div",{class:"row",children:[t("span",{class:"seal","aria-hidden":"true",children:t(y,{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 ge(){let[e,n]=m(!1),[s,o]=m(null);return[e,s,async(r)=>{n(!0),o(null);try{await r()}catch(i){o(I(i))}finally{n(!1)}}]}var ms=[["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 io({h:e}){let[n,s,o]=ge();return t("div",{class:"panel",children:[t(ee,{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((a,r)=>t("li",{children:[t("span",{class:a.ok?"ok":"no",children:t(y,{name:a.ok?"check":"circle",label:a.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:ms[r]?.[0]??a.label},void 0,!1,void 0,this),t("span",{class:"muted small",children:ms[r]?.[1]},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},a.label,!0,void 0,this))},void 0,!1,void 0,this),e.protect.others.length>0&&t(S,{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((a)=>t("li",{children:[t("code",{children:[".github/workflows/",a.file]},void 0,!0,void 0,this),": ",a.actions.slice(0,3).join(", ")]},a.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(Zt,{text:`${e.name} is protected`},void 0,!1,void 0,this):t("div",{class:"row",children:t(F,{busy:n,class:"btn primary",onClick:()=>o(async()=>{await j("/api/hub/protect",{hub:e.name}),await J(),Y("ok",`${e.name} is protected.`)}),children:[t(y,{name:"shield"},void 0,!1,void 0,this),e.protect.checks.some((a)=>a.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 lo({h:e,slug:n}){let[s,o]=m(e.app.installed);E(()=>{if(!e.app.installed)return;let r=0,i=4000,l=async()=>{if(!document.hidden)try{let d=await K(`/api/hub/installation?hub=${encodeURIComponent(e.name)}`);o(d),i=d.id!==null&&!d.onHub?30000:4000}catch{i=Math.min(i*2,30000)}r=window.setTimeout(l,i)};return r=window.setTimeout(l,500),()=>clearTimeout(r)},[e.name,Boolean(e.app.installed)]);let a=`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(S,{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(S,{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(O,{},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:a,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 co({h:e,what:n,onGo:s}){return t("div",{class:"panel",children:[t(ee,{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(S,{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(y,{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 bs({h:e}){let[n,s]=m(null),[o,a]=m(null),[r,i,l]=ge(),d=ne.value,p=Boolean(e.app.id&&e.app.slug&&e.app.key);if(E(()=>{if(p||e.app.id||e.app.held||d?.kind==="unstored")return;j("/api/hub/app",{hub:e.name}).then(s,(h)=>a(I(h)))},[e.name,p,d?.kind]),(d?.kind==="unstored"||e.app.held)&&!p)return t("div",{class:"panel",children:[t(ee,{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),d?.kind==="unstored"&&t(N,{problem:d.problem},void 0,!1,void 0,this),t(N,{problem:i},void 0,!1,void 0,this),t("div",{class:"row",children:t(F,{busy:r,class:"btn primary",onClick:()=>l(async()=>{await j("/api/hub/app/store",{hub:e.name}),await J(),ne.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(ee,{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(U,{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(p)return t("div",{class:"panel",children:[t(ee,{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),d?.kind==="created"&&t(S,{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(lo,{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(ee,{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),d?.kind==="failed"&&t(N,{problem:d.problem},void 0,!1,void 0,this),d?.kind==="unknown"&&t(S,{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(y,{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(S,{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(y,{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(O,{},void 0,!1,void 0,this)," Preparing the App"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function uo({h:e,choice:n}){let s=Ut(e,n);return t("div",{class:"panel",children:[t(ee,{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(S,{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:()=>Et(e.name,"yes"),children:[t(y,{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:()=>Et(e.name,"no"),children:[t(y,{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 Xt(e){history.pushState(null,"",`/setup?saved=${encodeURIComponent(e)}`),setTimeout(()=>history.replaceState(null,"","/setup"),1500)}function po({h:e}){let[n,s]=m(null),[o,a]=m(!1),[r,i,l]=ge(),d=e.apple.certificate,p=!d||!e.apple.certificateStored||o,h=(f)=>{f.preventDefault();let c=f.currentTarget;l(async()=>{if(!n)throw new ae({reason:"no .p12 file is chosen",fix:"Drop the .p12 you exported from Keychain Access."},0);let u=new FormData(c);u.delete("username"),u.set("hub",e.name),u.set("p12",n);let v=await j("/api/hub/certificate",u);Xt("certificate"),a(!1),s(null),await J(),Y("ok",`Certificate stored for team ${v.team}. It expires on ${v.expires}.`)})};return t("div",{class:"panel",children:[t(ee,{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),d&&e.apple.certificateStored&&t(x,{children:[t("dl",{class:"facts",children:[t("dt",{children:"Team"},void 0,!1,void 0,this),t("dd",{class:"mono",children:d.team},void 0,!1,void 0,this),t("dt",{children:"Expires"},void 0,!1,void 0,this),t("dd",{children:[d.expires," ",Gt(d.expires)&&t(V,{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:()=>a(!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),p&&t(x,{children:[t("details",{class:"card pad",open:!d,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(Ce,{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(Mt,{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(Dt,{name:"password",label:"Its password",hint:"The password you set when exporting it."},void 0,!1,void 0,this),t(S,{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:i},void 0,!1,void 0,this),t("div",{class:"row",children:[t(F,{busy:r,class:"btn primary",type:"submit",children:"Check and store"},void 0,!1,void 0,this),o&&t("button",{type:"button",class:"btn quiet",onClick:()=>a(!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 ho({h:e}){let[n,s]=m(null),[o,a]=m(!1),[r,i,l]=ge(),d=!e.apple.notary||o,p=(h)=>{h.preventDefault();let f=h.currentTarget;l(async()=>{if(!n)throw new ae({reason:"no .p8 file is chosen",fix:"Drop the AuthKey_\u2026.p8 you downloaded from App Store Connect."},0);let c=new FormData(f);c.set("hub",e.name),c.set("p8",n);let u=await j("/api/hub/notary",c);Xt("notary"),a(!1),s(null),await J(),Y("ok",u.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(ee,{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(x,{children:[t(Zt,{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:()=>a(!0),children:"Replace the key"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),d&&t(x,{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:p,autoComplete:"off",children:[t(Mt,{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(Ce,{name:"keyId",label:"Key ID",mono:!0,placeholder:"ABCDE12345"},void 0,!1,void 0,this),t(Ce,{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(S,{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:i},void 0,!1,void 0,this),t("div",{class:"row",children:[t(F,{busy:r,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:()=>a(!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 fo=[5,10,15,20,30,60,120,180,360];function mo({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?dt(pt(e.before,e.content)):null;return t("details",{class:"file",children:[t("summary",{children:[t(y,{name:"file"},void 0,!1,void 0,this),t("code",{children:e.path},void 0,!1,void 0,this),t(V,{tone:n,children:s},void 0,!1,void 0,this),t(y,{name:"down"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),t("pre",{class:"block diff",children:o?o.map((a,r)=>t("span",{class:a.kind==="gap"?"hunk":a.kind,children:[a.kind==="add"?"+ ":a.kind==="del"?"- ":a.kind==="gap"?"@ ":" ",a.text,`\n`]},r,!0,void 0,this)):e.change==="remove"?e.before:e.content},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function bo({h:e}){let[n,s]=m(e.files.every),[o,a]=m([]),[r,i]=m(!1),[l,d]=m(null),[p,h,f]=ge(),[c,u,v]=ge(),[k,g]=m(!1),w=e.protect.others.map((_)=>_.file);E(()=>{f(async()=>d(await j("/api/hub/files/preview",{hub:e.name,every:n,remove:o,readme:r})))},[e.name,n,o.join(","),r]);let b=l?.files.filter((_)=>_.change!=="same")??[],T=()=>v(async()=>{let _=await j("/api/hub/files",{hub:e.name,every:n,remove:o,readme:r});g(!0),await J(),d(await j("/api/hub/files/preview",{hub:e.name,every:n,remove:[],readme:!1})),a([]),i(!1),Y("ok",_.result==="committed"?`Wrote the hub files to ${e.name}.`:"The hub files were already up to date.")});return t("div",{class:"panel",children:[t(ee,{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:(_)=>s(Number(_.currentTarget.value)),children:fo.map((_)=>t("option",{value:_,children:_<60?`${_} minutes`:_===60?"hour":`${_/60} hours`},_,!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(S,{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),w.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),w.map((_)=>t("label",{class:"switch",children:[t("input",{type:"checkbox",checked:o.includes(_),onChange:(R)=>a(R.currentTarget.checked?[...o,_]:o.filter((W)=>W!==_))},void 0,!1,void 0,this),t("span",{children:[t("strong",{children:["Remove .github/workflows/",_]},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)]},_,!0,void 0,this))]},void 0,!0,void 0,this),(l?.readme||r)&&t("label",{class:"switch",children:[t("input",{type:"checkbox",checked:r,onChange:(_)=>i(_.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),p&&!l&&t("p",{class:"row muted",children:[t(O,{},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),l&&t("div",{class:"stack tight files",children:[t("div",{class:"spread",children:[t("h3",{class:"section-title",children:b.length?`${b.length} ${b.length===1?"change":"changes"} for main`:"main is up to date"},void 0,!1,void 0,this),t("span",{class:"muted small",children:["Workflow: ",l.pin]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),l.files.map((_)=>t(mo,{f:_},_.path,!1,void 0,this)),l.kept.length>0&&t("p",{class:"muted small",children:["Kept as they are: ",l.kept.join(", "),"."]},void 0,!0,void 0,this),l.notes.filter((_)=>!_.startsWith("The hub looks for new drafts every")).map((_)=>t("p",{class:"muted small",children:_},_,!1,void 0,this))]},void 0,!0,void 0,this),l&&l.foreign.length>0&&t(S,{tone:"error",title:"main changed in ways only you may change it",children:[t("ul",{class:"log",children:l.foreign.map((_)=>t("li",{children:_},_,!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:u},void 0,!1,void 0,this),k&&t(S,{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),l&&b.length>0&&l.foreign.length===0&&t("div",{class:"row",children:t(F,{busy:c,class:"btn primary",onClick:T,children:["Write ",b.length===1?"the change":`the ${b.length} changes`," to main"]},void 0,!0,void 0,this)},void 0,!1,void 0,this),l&&b.length===0&&t(Zt,{text:"The hub files are up to date"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function vo({h:e}){let[n,s]=m(null);E(()=>{if(Ve(),ie.value?.hub!==e.name)Se().catch(()=>{return})},[e.name]);let o=q.value?.hub===e.name?q.value.list:null,a=Yt(ie.value?.hub===e.name?ie.value.scan.projects:[]);return t("div",{class:"panel",children:[t(ee,{title:e.packages.length||o?.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. Open a project to see where it stands."},void 0,!1,void 0,this),t(N,{problem:ue.value},void 0,!1,void 0,this),o===null&&e.packages.length>0&&!ue.value&&t("p",{class:"row muted",role:"status",children:[t(O,{},void 0,!1,void 0,this)," Reading where your projects stand"]},void 0,!0,void 0,this),o!==null&&o.length>0&&t(ht,{list:o,paths:new Map([...a].map(([r,i])=>[r,i.path])),onOpen:(r)=>s(Jt(r,a))},void 0,!1,void 0,this),n&&t(ft,{target:n,hubName:e.name,onClose:()=>s(null)},n.repo,!1,void 0,this),e.invalid.length>0&&t(S,{tone:"warn",title:"The hub leaves these entries out",children:t("ul",{class:"log",children:e.invalid.map((r)=>t("li",{children:[t("code",{children:r.name},void 0,!1,void 0,this),": ",r.reason]},r.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:()=>pe("/projects"),children:[e.packages.length?"Add more projects":"Find my projects",t(y,{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 go({h:e,label:n}){let[s,o]=m("ed25519"),[a,r]=m(null),[i,l]=m(!1),[d,p,h]=ge();if(!a)return t("form",{class:"card pad stack tight",onSubmit:(c)=>{c.preventDefault(),h(async()=>r(await j("/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(Ce,{name:`account-${n}`,label:"Keychain account",value:s,mono:!0,onInput:o},void 0,!1,void 0,this),t(F,{busy:d,class:"btn primary",type:"submit",children:[t(y,{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:p},void 0,!1,void 0,this)]},void 0,!0,void 0,this);let f=(c)=>{c.preventDefault();let u=String(new FormData(c.currentTarget).get("password")??"");h(async()=>{await j("/api/hub/sparkle/store",{hub:e.name,label:n,pasted:u}),Xt(`sparkle-${n}`),await J(),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 ",a.users.join(", "),". Its public key, ",t("code",{children:a.publicKey},void 0,!1,void 0,this),", matches tapster.yml."]},void 0,!0,void 0,this),t("div",{class:"cmd",children:[t("code",{children:i?a.key:"\u2022".repeat(32)},void 0,!1,void 0,this),t("button",{type:"button",class:"btn quiet small",onClick:()=>l(!i),"aria-pressed":i,children:i?"Hide":"Show"},void 0,!1,void 0,this),t(Ot,{text:a.key},void 0,!1,void 0,this)]},void 0,!0,void 0,this),t(S,{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(Ce,{name:"username",label:"Name in your password manager",value:`${e.name}: Sparkle key ${n}`,autoComplete:"username"},void 0,!1,void 0,this),t(Dt,{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:p},void 0,!1,void 0,this),t("div",{class:"row",children:t(F,{busy:d,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 yo({h:e}){let n=e.name.split("/")[1],s=e.extras.sparkle.filter((o)=>!o.stored);return t("div",{class:"panel",children:[t(ee,{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(U,{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(V,{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(U,{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(V,{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(U,{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(V,{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(go,{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 _o({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:"Open a project under Your projects and click Release: tapster tags its latest commit on GitHub 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 vs(){let e=te.value,[n,s]=m(()=>{let u=Be.value;return Be.value=null,u}),o=fe(null);Me.value;let a=Boolean(e&&e.name===H.value&&e.files.config);if(E(()=>{if(a&&q.value?.hub!==e.name)Ve()},[e?.name,a]),xe.value)return t("div",{class:"stack",style:"max-width: 640px",children:[t(N,{problem:xe.value},void 0,!1,void 0,this),t("div",{class:"row",children:t("button",{type:"button",class:"btn secondary",onClick:()=>void J(),children:[t(y,{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!==H.value)return t("p",{class:"row muted",role:"status",children:[t(O,{},void 0,!1,void 0,this)," Reading ",H.value," from GitHub"]},void 0,!0,void 0,this);let r=qn(e.name),i=as(e,r,Date.now(),q.value?.hub===e.name?q.value.list:null),l=n??(ne.value?.kind==="created"?"app":rs(i)),d=i.filter((u)=>u.state==="done"||u.state==="skipped").length,p=i.find((u)=>u.state==="now"||u.state==="attention"),h=(u)=>{if(s(u),window.matchMedia("(max-width: 900px)").matches)o.current?.scrollIntoView({behavior:"smooth",block:"start"})},f=(u,v)=>e.protect.environment?v:t(co,{h:e,what:u,onGo:()=>h("protect")},void 0,!1,void 0,this),c={extras:t(yo,{h:e},void 0,!1,void 0,this),protect:t(io,{h:e},void 0,!1,void 0,this),app:e.app.id||e.app.held||ne.value?.kind==="unstored"?t(bs,{h:e},void 0,!1,void 0,this):f("Create the GitHub App",t(bs,{h:e},void 0,!1,void 0,this)),macos:t(uo,{h:e,choice:r},void 0,!1,void 0,this),certificate:f("Apple certificate",t(po,{h:e},void 0,!1,void 0,this)),notary:f("Notarization key",t(ho,{h:e},void 0,!1,void 0,this)),files:t(bo,{h:e},void 0,!1,void 0,this),project:t(vo,{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:[d," of ",i.length," done",p?`. Next: ${p.name}`:"",it.value&&t(O,{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: ${d/i.length*100}%`},void 0,!1,void 0,this)},void 0,!1,void 0,this),!p&&t(_o,{h:e},void 0,!1,void 0,this),e.empty&&t(S,{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:[i.map((u,v)=>t("li",{class:`${u.state}${u.id===l?" open":""}`,children:t("button",{type:"button",onClick:()=>h(u.id),"aria-current":u.id===l?"step":void 0,"aria-label":`${u.name}: ${u.status}${u.state==="now"?", next":u.state==="attention"?", needs you":""}`,children:[t(ro,{stop:u,index:v},void 0,!1,void 0,this),t("span",{children:[t("span",{class:"stop-name",children:u.name},void 0,!1,void 0,this),t("span",{class:"stop-state",children:u.status},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},u.id,!1,void 0,this)),t("li",{class:`extra${l==="extras"?" open":""}`,children:t("button",{type:"button",onClick:()=>h("extras"),"aria-current":l==="extras"?"step":void 0,children:[t("span",{class:"dot",children:t(y,{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:[c[l],(()=>{let u=i.findIndex((g)=>g.id===l),v=i[u],k=i.slice(u+1).find((g)=>g.state!=="done"&&g.state!=="skipped");if(!v||v.state!=="done"&&v.state!=="skipped"||!k)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:()=>h(k.id),children:["Continue: ",k.name,t(y,{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 $e=D({kind:"claiming"}),mt=D(!1);function wo(){let e=new URLSearchParams(location.search),n=e.get("app");if(!n)return;let s=e.get("hub");if(s&&s!==H.value)ct(s);let o={reason:e.get("reason")??"the App could not be created",fix:e.get("fix")??"Try again."};if(n==="created")ne.value={kind:"created"};else if(n==="failed"||n==="unstored")ne.value={kind:n,problem:o};else ne.value={kind:"unknown"};history.replaceState(null,"",location.pathname)}async function ko(){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 Bn(e)}catch(n){$e.value={kind:"failed",problem:I(n)};return}if(!Dn()){$e.value={kind:"no-session"};return}if(wo(),$e.value={kind:"ready"},K("/api/session").then((n)=>{if(De.value=n,!H.value&&n.here.hub)ct(n.here.hub)}),await lt(),H.value)J()}Vn(()=>{$e.value={kind:"no-session"}});async function xo(){try{await j("/api/quit")}catch{return}$e.value={kind:"stopped"}}function Qt({to:e,children:n}){let s=ve.value===e||e==="/setup"&&ve.value==="/";return t("a",{href:e,"aria-current":s?"page":void 0,onClick:(o)=>{o.preventDefault(),pe(e)},children:n},void 0,!1,void 0,this)}function So(){let e=re.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(),pe("/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),H.value&&t("nav",{class:"nav","aria-label":"Sections",children:[t(Qt,{to:"/setup",children:"Setup"},void 0,!1,void 0,this),t(Qt,{to:"/projects",children:"Projects"},void 0,!1,void 0,this),t(Qt,{to:"/health",children:"Health"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),t("div",{class:"end",children:[H.value&&t("button",{type:"button",class:"picker",onClick:()=>mt.value=!0,"aria-label":`Hub: ${H.value}. Choose another hub`,children:[t(y,{name:"package"},void 0,!1,void 0,this),t("span",{children:H.value},void 0,!1,void 0,this),t(y,{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:xo,title:"Stop tapster setup",children:[t(y,{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 Co(){let e=ke.value;if(!e)return null;return t("div",{class:"toast",role:"status",onClick:()=>ke.value=null,children:t(S,{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 To(){if(!H.value||mt.value)return t(Qn,{onChosen:(e)=>{mt.value=!1,ct(e),pe("/setup",!0)},onCancel:H.value?()=>mt.value=!1:null},void 0,!1,void 0,this);if(ve.value==="/projects")return t(fs,{},void 0,!1,void 0,this);if(ve.value==="/health")return t(Xn,{},void 0,!1,void 0,this);return t(vs,{},void 0,!1,void 0,this)}function Po(){let e=$e.value;if(e.kind==="claiming")return t(Vt,{text:"Opening tapster setup"},void 0,!1,void 0,this);if(e.kind==="stopped")return t(Yn,{},void 0,!1,void 0,this);if(e.kind==="no-session"||e.kind==="failed")return t(Kn,{problem:e.kind==="failed"?e.problem:null},void 0,!1,void 0,this);let n=re.value;if(!n)return t(Vt,{text:"Checking your GitHub sign-in"},void 0,!1,void 0,this);if(n.state!=="ok"||n.missing.length)return t(Jn,{},void 0,!1,void 0,this);return t(x,{children:[t(So,{},void 0,!1,void 0,this),t("main",{id:"main",children:t(To,{},void 0,!1,void 0,this)},void 0,!1,void 0,this),t(Co,{},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}bn(t(Po,{},void 0,!1,void 0,this),document.getElementById("app"));ko().catch((e)=>Y("error",I(e).reason));\n';import{timingSafeEqual as XC}from"crypto";var eR="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'",tR={"content-security-policy":eR,"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 nt(e,t,n,r={}){return new Response(e,{status:t,headers:{...tR,...n?{"content-type":n}:{},...r}})}var pt=(e,t=200)=>nt(JSON.stringify(e),t,"application/json; charset=utf-8");function Ob(e){if(e instanceof R)return{status:502,body:{error:{reason:e.reason,fix:e.fix}}};if(e instanceof g)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 Cb(e,t){return e===`127.0.0.1:${t}`||e===`localhost:${t}`}function Rb(e,t){let n=/^Bearer ([0-9a-f]{64})$/.exec(e??"")?.[1];if(!n)return!1;let r=Buffer.from(n),s=Buffer.from(t);return r.length===s.length&&XC(r,s)}var Ib=`:root {
1101
1104
  --page: #f3f4f6;
1102
1105
  --paper: #ffffff;
1103
1106
  --raised: #fafafb;
1104
1107
  --ink: #16171b;
1105
1108
  --muted: #5c606c;
1106
- --faint: #6e7280;
1109
+ --faint: #6a6e7b;
1107
1110
  --line: #e1e3e8;
1108
1111
  --line-strong: #cdd0d7;
1109
1112
  --orange: #f2891f;
@@ -1231,7 +1234,7 @@ main { max-width: 1180px; margin: 0 auto; padding: 1.75rem 1.25rem 4rem; }
1231
1234
  .badge { display: inline-flex; align-items: center; gap: 0.3rem; font-size: 0.78rem; font-weight: 600; padding: 0.14rem 0.5rem; border-radius: 999px; background: var(--raised); border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
1232
1235
  .badge.ok { background: var(--green-soft); color: var(--green); border-color: transparent; }
1233
1236
  .badge.warn { background: var(--amber-soft); color: var(--amber); border-color: transparent; }
1234
- .badge.error { background: var(--wax-soft); color: var(--wax); border-color: transparent; }
1237
+ .badge.error { background: var(--wax-soft); color: color-mix(in srgb, var(--wax) 85%, var(--ink)); border-color: transparent; }
1235
1238
  .badge.next { background: var(--orange-soft); color: var(--link); border-color: transparent; }
1236
1239
 
1237
1240
  /* command rows */
@@ -1245,6 +1248,7 @@ form.secret { display: grid; gap: 1rem; }
1245
1248
  .field { display: grid; gap: 0.35rem; }
1246
1249
  .field > label, .field > .label { font-weight: 600; font-size: 0.92rem; }
1247
1250
  .field .hint { color: var(--muted); font-size: 0.86rem; }
1251
+ .field .hint.bad { color: var(--wax); }
1248
1252
  .input { width: 100%; border: 1px solid var(--line-strong); background: var(--paper); border-radius: 9px; padding: 0.55rem 0.75rem; min-width: 0; }
1249
1253
  .input:hover { border-color: var(--faint); }
1250
1254
  .input:focus { outline: 3px solid var(--focus); outline-offset: 0; border-color: var(--orange); }
@@ -1300,6 +1304,12 @@ select.input { appearance: auto; }
1300
1304
  .checks .no { color: var(--faint); }
1301
1305
  .checks .bad { color: var(--wax); }
1302
1306
  .section-title { font-size: 0.95rem; font-weight: 650; }
1307
+ .checks.status { gap: 0; }
1308
+ .checks.status > li { padding: 0.85rem 0; border-top: 1px solid var(--line); }
1309
+ .checks.status > li:first-child { border-top: 0; padding-top: 0.25rem; }
1310
+ .release { border: 1px solid var(--line); border-radius: 10px; padding: 0.9rem 1rem; background: var(--paper); margin-top: 0.35rem; }
1311
+ details.more summary { cursor: pointer; color: var(--link); font-size: 0.88rem; width: fit-content; }
1312
+ details.more[open] summary { margin-bottom: 0.5rem; }
1303
1313
  .seal { display: inline-grid; place-items: center; width: 54px; height: 54px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #ee6b56, #c8392f 60%, #8f2019); color: #ffe0d8; box-shadow: 0 6px 14px -6px rgb(143 32 25 / 0.6); }
1304
1314
  .seal .icon { width: 26px; height: 26px; stroke-width: 3; }
1305
1315
  .progress { height: 6px; border-radius: 999px; background: var(--line); overflow: hidden; }
@@ -1321,7 +1331,7 @@ select.input { appearance: auto; }
1321
1331
  .files summary code { flex: 1; }
1322
1332
  .files .file pre { border: 0; border-top: 1px solid var(--line); border-radius: 0 0 10px 10px; }
1323
1333
  .diff .add { background: var(--green-soft); color: var(--green); display: block; }
1324
- .diff .del { background: var(--wax-soft); color: var(--wax); display: block; }
1334
+ .diff .del { background: var(--wax-soft); color: color-mix(in srgb, var(--wax) 85%, var(--ink)); display: block; }
1325
1335
  .diff .ctx { display: block; color: var(--muted); }
1326
1336
  .diff .hunk { display: block; color: var(--navy); }
1327
1337
  .log { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.45rem; font-size: 0.92rem; }
@@ -1381,7 +1391,7 @@ select.input { appearance: auto; }
1381
1391
  @media (prefers-reduced-motion: reduce) {
1382
1392
  *, *::before, *::after { animation: none !important; transition: none !important; }
1383
1393
  }
1384
- `;var f2=600000,m2=new Set(["/","/setup","/projects","/health"]),oy=(e)=>Buffer.from(e.slice(e.indexOf(",")+1),"base64"),ay={"/logo.webp":oy(gn),"/courier.webp":oy(us)},g2=`<!doctype html>
1394
+ `;var rR=600000,sR=new Set(["/","/setup","/projects","/health"]),Nb=(e)=>Buffer.from(e.slice(e.indexOf(",")+1),"base64"),zb={"/logo.webp":Nb(Sn),"/courier.webp":Nb(_o)},oR=`<!doctype html>
1385
1395
  <html lang="en">
1386
1396
  <head>
1387
1397
  <meta charset="utf-8">
@@ -1397,16 +1407,18 @@ select.input { appearance: auto; }
1397
1407
  <noscript><p class="noscript">tapster setup needs JavaScript. The same steps work in a terminal: tapster init and tapster add.</p></noscript>
1398
1408
  </body>
1399
1409
  </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(`
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
- ${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(`
1410
+ `;function Yo(e,t){let n={deps:e,port:t,token:Il(32).toString("hex"),codes:new Map,claimed:new Set,pending:new Map,apps:new Map,sparkle:new Map,dispatched:new Map,touched:Date.now(),login:null,link:()=>{let r=Il(16).toString("hex");return n.codes.set(r,Date.now()+rR),`http://127.0.0.1:${n.port}/#c=${r}`}};return n}async function V(e,t){let n;try{n=await e.json()}catch{throw new g("the request was not JSON","Reload the page and try again.")}let r=t.safeParse(n);if(!r.success)throw new g("the request did not have the expected fields","Reload the page and try again.");return r.data}function iR(e,t){if(typeof t!=="string"||!/^[0-9a-f]{32}$/.test(t))return pt({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=Il(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()}`),pt({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 pt({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(),pt({token:e.token})}function jb(e,t,n){return async(r)=>{if(!Cb(r.headers.get("host"),e.port))return nt("Misdirected request",421,"text/plain; charset=utf-8");let s=new URL(r.url),o=s.pathname;if(r.method==="GET"&&sR.has(o))return nt(oR,200,"text/html; charset=utf-8");if(r.method==="GET"&&o==="/app.css")return nt(Ib,200,"text/css; charset=utf-8");if(r.method==="GET"&&o==="/app.js")return nt(await Eb(),200,"text/javascript; charset=utf-8");if(r.method==="GET"&&zb[o])return nt(new Uint8Array(zb[o]),200,"image/webp");if(r.method==="GET"&&o==="/app/callback")return n({s:e,req:r,url:s});if(r.method==="POST"&&o==="/api/claim"){let a=await r.json().catch(()=>null);return iR(e,a?.code)}if(!o.startsWith("/api/"))return nt("Not found",404,"text/plain; charset=utf-8");if(!Rb(r.headers.get("authorization"),e.token))return pt({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 i=t[`${r.method} ${o}`];if(!i)return pt({error:{reason:"unknown request",fix:"Reload the page."}},404);try{return pt(await i({s:e,req:r,url:s})??{})}catch(a){let c=Ob(a);if(c.status===500)e.deps.log(`tapster setup: ${r.method} ${o} failed: ${xn(a instanceof Error?`${a.name}: ${a.message}`:"unknown error")}`);return pt(c.body,c.status)}}}var cR=/^[A-Za-z0-9-]+\/homebrew-[A-Za-z0-9._-]+$/,lR="tapster: the hub needs attention";async function uR(e){let t;try{t=await e.deps.github()}catch(i){if(i instanceof g&&/not installed/.test(i.reason))return{state:"no-gh"};return{state:"signed-out"}}let n;try{n=await t.request("GET","/user")}catch(i){if(i instanceof R&&i.status===401)return{state:"signed-out"};throw i}let r=await n.json();e.login=r.login;let s=n.headers.get("x-oauth-scopes"),o=s===null?null:s.split(",").map((i)=>i.trim());return{state:"ok",login:r.login,missing:o===null?[]:["repo","workflow"].filter((i)=>!o.includes(i))}}async function ae(e){let t=await e.deps.github();return e.login??=(await t.json("GET","/user")).login,{gh:t,login:e.login}}function le(e,t){if(typeof e!=="string"||!cR.test(e))throw new g("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 g(`${e} does not belong to ${t}`,"tapster serves repositories of your own account.");return e}async function xe(e,t){let{gh:n,login:r}=await ae(e.s);return{gh:n,hub:le(t,r),login:r}}var Nl=async(e)=>{try{return await e}catch(t){if(t instanceof R&&t.status===404)return null;throw t}},Lb=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 zl(e,t){let n=[];for(let s=1;s<=5;s++){let o=await e.json("GET",`/user/repos?affiliation=owner&sort=updated&per_page=100&page=${s}`);if(n.push(...o),o.length<100)break}let r=n.filter((s)=>s.name.startsWith("homebrew-")&&s.owner.login.toLowerCase()===t.toLowerCase());return Promise.all(r.map(async(s)=>({name:s.full_name,private:s.private,url:s.html_url,tapster:await Nl(e.json("GET",`/repos/${s.full_name}/environments/tapster`))!==null})))}function pR(e){let t=[];for(let[n,r]of Object.entries(e)){if(n==="tapster.yml")continue;let s;try{s=Y(r)}catch{t.push({file:n,actions:["(the file is not valid YAML)"]});continue}let o=s?.jobs??{},a=Object.values(o).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 jl(e,t,n){let r=await t.json("GET",`/repos/${n}`),o=await Lb(t,n)===null,i=await Nl(t.json("GET",`/repos/${n}/environments/tapster`)),a=async(z)=>i?(await t.json("GET",`/repos/${n}/environments/tapster/${z}?per_page=100`))[z]??[]:[],[c,l,u,p,d,h]=await Promise.all([a("variables"),a("secrets"),i?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((z)=>t.json("GET",`/repos/${n}/rulesets/${z.id}`))),m=d.allowed_actions==="selected"?await t.json("GET",`/repos/${n}/actions/permissions/selected-actions`):null,v=(z)=>o?Promise.resolve(null):F(t,n,z,"main"),[_,A,y,b,k]=await Promise.all([v("tapster.yml"),v(".tapster/state.json"),v("README.md"),v(te),o?Promise.resolve([]):t.json("GET",`/repos/${n}/contents/.github/workflows?ref=main`).catch(()=>[])]),S={};for(let z of k.filter((sn)=>sn.type==="file"&&/\.ya?ml$/.test(sn.name)))S[z.name]=await v(`.github/workflows/${z.name}`)??"";let O=(z)=>z.map((sn)=>sn.name),x=(z)=>c.find((sn)=>sn.name===z)?.value??null,N=_===null?null:(()=>{try{return ve(_,n.split("/")[0])}catch{return null}})(),pe=Boolean(i?.deployment_branch_policy?.custom_branch_policies)&&u.branch_policies.length===1&&u.branch_policies[0].name==="main",Ae=[{label:"a tapster environment that only main may open",ok:pe},{label:"main cannot be deleted or force-pushed",ok:yl(f).ok},{label:"workflows run only GitHub's and tapster's actions, pinned by commit",ok:wl(d,m).ok},{label:"the workflows' default token is read-only",ok:h.default_workflow_permissions==="read"}],q=x("TAPSTER_APP_ID"),zt=e.apps.get(n),Ay=N?.config.packages.some(mo)??!1,$y=Boolean(x("TAPSTER_TEAM_ID"))||O(l).includes("MACOS_NOTARY_KEY"),ai=b?nn.exec(b):null,zn=(await t.json("GET",`/repos/${n}/issues?state=open&creator=${encodeURIComponent("github-actions[bot]")}&per_page=100`).catch(()=>[])).find((z)=>z.title===lR&&z.user?.login==="github-actions[bot]");return{name:n,url:r.html_url,private:r.private,empty:o,protect:{done:Ae.every((z)=>z.ok),environment:pe,checks:Ae,others:pR(S)},app:{id:q,slug:x("TAPSTER_APP_SLUG"),key:O(l).includes("TAPSTER_APP_PRIVATE_KEY"),held:Boolean(zt),installed:zt?await Db(e,n):null},apple:{needed:$y||Ay?!0:null,certificate:x("TAPSTER_TEAM_ID")?{team:x("TAPSTER_TEAM_ID"),expires:x("TAPSTER_CERT_EXPIRES")??""}:null,certificateStored:["MACOS_SIGN_P12","MACOS_SIGN_PASSWORD"].every((z)=>O(l).includes(z)),notary:["MACOS_NOTARY_KEY","MACOS_NOTARY_KEY_ID","MACOS_NOTARY_ISSUER_ID"].every((z)=>O(l).includes(z))},files:{config:_!==null,state:A!==null,readme:y!==null,workflow:vl(b,ue,e.deps.pin),pinned:ai?`${ai[2]} (${ai[1].slice(0,7)})`:null,every:b?lt(b):null},packages:(N?.config.packages??[]).map((z)=>({name:z.name,repo:z.repo,kind:X(z)?"app":z.kind})),invalid:(N?.invalid??[]).map((z)=>({name:z.name,reason:z.reason})),issue:zn?{url:zn.html_url,number:zn.number,updated:zn.updated_at,body:zn.body??""}:null,extras:{doorbell:x("TAPSTER_DOORBELL")!==null,linux:{wanted:N?.config.packages.some((z)=>!X(z)&&z.linux)??!1,stored:O(l).includes("TAPSTER_LINUX_KEY")},sparkle:(N?Re(N.config):[]).map((z)=>({label:z,stored:O(l).includes(`SPARKLE_KEY_${z.toUpperCase()}`)}))}}}async function Db(e,t){let n=e.apps.get(t);if(!n)return{checked:!1,id:null,onHub:!1,repos:[]};let r=t.split("/")[0],s=await Zo(n.id,n.pem,r,t,new fe(Ye(n.id,n.pem),e.deps.fetch)),o=s.id===null?[]:await wo(n.id,n.pem,r,e.deps.fetch)??[];return{checked:!0,id:s.id,onHub:s.onHub,repos:o}}async function En(e,t){let n=await Nl(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 g(`${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 Mb(e,t,n){let s=(await Rl(e,t,n).catch((o)=>{if(o instanceof R&&o.status===404)return[];throw o})).filter((o)=>!o.startsWith("GitHub shows no push by"));if(s.length)throw new g(`main changed in ways only you may change it: ${s.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 Jo=I({hub:P()}).strict();async function dR(e){let{hub:t}=await V(e.req,Jo),{gh:n}=await xe(e,t),r=await n.json("GET",`/repos/${t}`);return await Cl(n,t,r.private),{done:!0}}async function hR(e){let{hub:t}=await V(e.req,Jo),{gh:n,login:r}=await xe(e,t);await En(n,t);let s=aR(16).toString("hex");for(let[i,a]of e.s.pending)if(Date.now()-a.at>3600000)e.s.pending.delete(i);e.s.pending.set(s,{hub:t,owner:r,at:Date.now()});let o=Ho(r,t,`http://127.0.0.1:${e.s.port}/app/callback`);return{action:`https://github.com/settings/apps/new?state=${s}`,manifest:JSON.stringify(o),permissions:Jc(o),name:o.name}}async function Ub(e){let t=(i)=>new Response(null,{status:303,headers:{location:`/setup?${new URLSearchParams(i)}`,"cache-control":"no-store","referrer-policy":"no-referrer"}}),n=e.url.searchParams.get("state")??"",r=e.url.searchParams.get("code")??"",s=e.s.pending.get(n);if(!s||!/^[A-Za-z0-9_-]{1,128}$/.test(r))return t({app:"unknown"});e.s.pending.delete(n);let o;try{o=await Qc(r,s.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(i){let a=i instanceof g?i:new g("GitHub did not hand over the new App","Try again from Setup.");return t({app:"failed",hub:s.hub,reason:a.reason,fix:a.fix})}e.s.apps.set(s.hub,{id:String(o.id),pem:o.pem,slug:o.slug});try{return await En(await e.s.deps.github(),s.hub),await zr(s.hub,o),t({app:"created",hub:s.hub})}catch(i){let a=i instanceof g?i:new g("the App's key could not be stored","Try again.");return t({app:"unstored",hub:s.hub,reason:a.reason,fix:a.fix})}}async function fR(e){let{hub:t}=await V(e.req,Jo),{gh:n}=await xe(e,t);await En(n,t);let r=e.s.apps.get(t);if(!r)throw new g("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 zr(t,{id:Number(r.id),slug:r.slug,pem:r.pem}),{stored:!0}}async function mR(e){let{hub:t}=await xe(e,e.url.searchParams.get("hub"));return Db(e.s,t)}var Gb=(e,t,n)=>{let r=e.get(t);if(!(r instanceof File)||r.size===0)throw new g(`no ${t} file was attached`,"Choose the file and try again.");if(r.size>n)throw new g(`that ${t} file is too large`,"Choose the file Apple or Keychain Access gave you.");return r.arrayBuffer().then((s)=>new Uint8Array(s))};async function Hb(e){try{return await e.req.formData()}catch{throw new g("the form could not be read","Reload the page and try again.")}}async function gR(e){let t=await Hb(e),{gh:n,hub:r}=await xe(e,t.get("hub"));await En(n,r);let s=await Gb(t,"p12",xl),o=String(t.get("password")??""),i=await qo(s,o);return await Bo(r,s,o,i),i}async function vR(e){let t=await Hb(e),{gh:n,hub:r}=await xe(e,t.get("hub"));await En(n,r);let s=Fo(await Gb(t,"p8",Sl),String(t.get("keyId")??""),String(t.get("issuerId")??"")),o=await e.s.deps.notary(s);return await Wo(r,s),{checked:o}}var Zb=I({hub:P(),every:zc().int().nullable(),remove:re(P()).max(20),readme:at()}).strict();async function qb(e,t,n,r,s,o,i){let a=await t.json("GET",`/repos/${n}`),c=await Lo(t,n,i,e.s.deps.pin,{every:r,isPrivate:a.private}),l=vl(await i(te),ue,e.s.deps.pin)==="newer",u=[];for(let f of c.files.filter((m)=>!(l&&m.path===te)))u.push({path:f.path,content:f.content,before:f.before,change:f.before===null?"create":f.before===f.content?"same":"update"});let p=jo(n).find((f)=>f.path==="README.md"),d=c.kept.includes("README.md")?await i("README.md"):null;if(o&&d!==null&&d!==p.content)u.push({path:"README.md",content:p.content,before:d,change:"update"});let h=s.filter((f)=>/^[A-Za-z0-9._-]+\.ya?ml$/.test(f)&&f!=="tapster.yml");for(let f of h){let m=await i(`.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 bR(e){let t=await V(e.req,Zb),{gh:n,hub:r,login:s}=await xe(e,t.hub),o=await qb(e,n,r,t.every,t.remove,t.readme,(a)=>F(n,r,a,"main")),i=await Rl(n,r,s).catch(()=>[]);return{...o,foreign:i.filter((a)=>!a.startsWith("GitHub shows no push by"))}}async function yR(e){let t=await V(e.req,Zb),{gh:n,hub:r,login:s}=await xe(e,t.hub);if(await Lb(n,r)===null){let i=jo(r).find((a)=>a.path==="README.md");if(await n.json("PUT",`/repos/${r}/contents/README.md`,{message:"Start the tap",content:Buffer.from(i.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 Mb(n,r,s),{result:await nl(n,r,"Set up tapster",async(i)=>(await qb(e,n,r,t.every,t.remove,t.readme,i)).files.filter((c)=>c.change!=="same").map((c)=>({path:c.path,content:c.change==="remove"?null:c.content})))}}async function wR(e){let t=await V(e.req,I({name:P().regex(/^homebrew-[A-Za-z0-9._-]{1,80}$/),private:at()}).strict()),{gh:n,login:r}=await ae(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(s){if(s instanceof R&&s.status===422)throw new g(`${r}/${t.name} already exists`,"Pick it from the list instead.");throw s}}var _R=I({hub:P(),label:P().regex(/^[a-z0-9]{1,40}$/),account:P().regex(/^[A-Za-z0-9 ._@-]{1,64}$/)}).strict();async function Bb(e,t,n){let r=await F(e,t,"tapster.yml","main"),s=r===null?null:ve(r,t.split("/")[0]).config;if(!s||!Re(s).includes(n))throw new g(`no app in ${t}'s tapster.yml signs with the Sparkle key ${n}`,"Add the app with its sparkle section first.");return s}async function kR(e){let t=await V(e.req,_R),{gh:n,hub:r}=await xe(e,t.hub),s=await Bb(n,r,t.label),o=await e.s.deps.keychain(t.account);if(o===null)throw new g(`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 i=Go(o),a=Ol(s,t.label,i.publicKey);return e.s.sparkle.set(`${r} ${t.label}`,{seed:o.trim(),at:Date.now()}),{publicKey:i.publicKey,users:a,key:o.trim()}}async function xR(e){let t=await V(e.req,I({hub:P(),label:P().regex(/^[a-z0-9]{1,40}$/),pasted:P().max(400)}).strict()),{gh:n,hub:r,login:s}=await xe(e,t.hub),o=e.s.sparkle.get(`${r} ${t.label}`);if(!o||Date.now()-o.at>1800000)throw new g("read the key from your keychain first","Click Read it from my keychain again.");if(t.pasted.trim()!==o.seed)throw new g("that is not the key shown above","Paste the key itself, so the copy your password manager keeps is the right one.");let i=await Bb(n,r,t.label);await En(n,r),await Mb(n,r,s),await se(r,`SPARKLE_KEY_${t.label.toUpperCase()}`,o.seed);let a=await nl(n,r,`Pass the Sparkle key ${t.label} to the hub workflow`,async(c)=>{let l=await c(te);if(l===null)return[];let u=zo(l,Re(i));return u===l?[]:[{path:te,content:u}]});return e.s.sparkle.delete(`${r} ${t.label}`),{stored:!0,workflow:a}}async function SR(e){let{gh:t,hub:n}=await xe(e,e.url.searchParams.get("hub")),[{checks:r,note:s},o]=await Promise.all([Nr(t,n),t.json("GET",`/repos/${n}/actions/workflows/tapster.yml/runs?per_page=8`).catch(()=>({workflow_runs:[]}))]);return{checks:r,note:s,runs:o.workflow_runs.map((i)=>({id:i.id,url:i.html_url,event:i.event,status:i.status,conclusion:i.conclusion,created:i.created_at}))}}var On=(e,t)=>e.json("GET",`/repos/${t}/actions/workflows/tapster.yml/runs?per_page=10`).then((n)=>n.workflow_runs,()=>[]);async function Hr(e,t,n){let r=await On(t,n),s=r.find((i)=>i.status!=="completed");if(s)return{started:!1,run:s.html_url};let o=e.dispatched.get(n);if(o&&Date.now()-o.at<60000&&r.every((i)=>o.known.includes(i.id)))return{started:!1,run:null};e.dispatched.set(n,{at:Date.now(),known:r.map((i)=>i.id)});try{await t.json("POST",`/repos/${n}/actions/workflows/tapster.yml/dispatches`,{ref:"main"})}catch(i){if(o)e.dispatched.set(n,o);else e.dispatched.delete(n);throw i}return{started:!0,run:null}}async function AR(e){let{hub:t}=await V(e.req,Jo),{gh:n}=await xe(e,t);return{started:(await Hr(e.s,n,t)).started}}var Fb={"GET /api/account":(e)=>uR(e.s),"GET /api/hubs":async(e)=>{let{gh:t,login:n}=await ae(e.s);return{hubs:await zl(t,n)}},"POST /api/hubs":wR,"GET /api/hub":async(e)=>{let{gh:t,hub:n}=await xe(e,e.url.searchParams.get("hub"));return jl(e.s,t,n)},"POST /api/hub/protect":dR,"POST /api/hub/app":hR,"POST /api/hub/app/store":fR,"GET /api/hub/installation":mR,"POST /api/hub/certificate":gR,"POST /api/hub/notary":vR,"POST /api/hub/files/preview":bR,"POST /api/hub/files":yR,"GET /api/hub/health":SR,"POST /api/hub/run":AR,"POST /api/hub/sparkle/read":kR,"POST /api/hub/sparkle/store":xR};import{existsSync as oi,lstatSync as ay,readdirSync as ly}from"fs";import{isAbsolute as Fl,join as Ne,normalize as uy,resolve as py}from"path";import{lstatSync as Qo,readdirSync as $R,realpathSync as Jb}from"fs";import{dirname as TR,join as Ue,resolve as Xo,sep as Kb}from"path";var PR=new Set(["node_modules","Library","Applications","Pictures","Music","Movies","Documents","Desktop","Downloads","Public","vendor","Pods","DerivedData","build","dist","target","out"]),ER=["Developer","Projects","projects","code","Code","src","dev","git","GitHub","repos","workspace","work"];var OR=(e)=>{try{return Qo(e).isFile()}catch{return!1}};function Ll(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 Dl(e,t){let n=(r)=>t.includes(r)&&OR(Ue(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(Ue(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 ei(e,t){return[t,TR(t),...ER.map((n)=>Ue(e,n))].filter((n)=>ti(n,e)&&n!==Xo(e))}var Wb=(e,t)=>e===t||e.startsWith(t.endsWith(Kb)?t:`${t}${Kb}`),Vb=(e)=>{try{return Jb(e)}catch{return Xo(e)}};function ti(e,t){return Wb(Xo(e),Xo(t))||Wb(Vb(e),Vb(t))}function ni(e,t={}){let n=t.depth??3,r=t.maxDirs??4000,s=t.deadline??Date.now()+3000,o=new Set,i=[],a=0,c=!1,l=(u,p)=>{if(a>=r||Date.now()>s){c=!0;return}let d;try{d=Jb(u)}catch{return}if(o.has(d))return;o.add(d),a++;let h;try{h=$R(d)}catch{return}if(h.includes(".git")){let f=null;try{f=Qo(Ue(d,".git"))}catch{f=null}let m=f?.isDirectory()?oe(Ue(d,".git","config"),65536):null,v=m?Ll(m):null;if(v)i.push({path:u,repo:v,owner:v.split("/")[0],inHub:!1,proposed:null,others:[],...Dl(d,h)});return}if(p>=n)return;for(let f of h){if(f.startsWith(".")||PR.has(f))continue;try{if(!Qo(Ue(d,f)).isDirectory())continue}catch{continue}l(Ue(u,f),p+1)}};for(let u of e)l(u,0);return{found:i,truncated:c}}function CR(e){let t=(r,s)=>new RegExp(`^ref: ${s}(.+)$`).exec(oe(Ue(e,".git",r),4096)?.trim()??"")?.[1]??null,n=(r)=>{try{return Qo(Ue(e,".git",r)).mtimeMs}catch{return 0}};return{branch:t("HEAD","refs/heads/"),defaultBranch:t(Ue("refs","remotes","origin","HEAD"),"refs/remotes/origin/"),changed:Math.max(n("HEAD"),n("index"),n(Ue("logs","HEAD")))}}var Yb=(e)=>e.branch!==null&&e.branch===(e.defaultBranch??(e.branch==="main"||e.branch==="master"?e.branch:null));function Qb(e,t=CR){let n=new Map;for(let r of e)n.set(r.repo.toLowerCase(),[...n.get(r.repo.toLowerCase())??[],r]);return[...n.values()].map((r)=>{let s=r.length===1?r:r.map((o)=>({f:o,c:t(o.path)})).sort((o,i)=>Number(Yb(i.c))-Number(Yb(o.c))||i.c.changed-o.c.changed).map((o)=>o.f);return{...s[0],others:s.slice(1).map((o)=>o.path)}})}function Zr(e){let t=new RegExp("<!-- tapster -->\\s*([\\s\\S]*?)<!-- /tapster -->").exec(e??"")?.[1];return t?t.replace(/^>\s*/,"").replace(/\*\*/g,"").trim():null}var RR=I({tag:P().regex(Ke),releaseId:zc().int().positive(),checksums:P().regex(/^[0-9a-f]{64}$/),status:Tt(["publishing","published"]),app:I({macos:P().regex(/^[a-z_]+$/),identifiers:re(P().regex(/^[A-Za-z0-9.-]+$/))}).strict().optional()}).strict(),IR=I({version:Lc(1),packages:fo(P().regex(Kt),re(RR))}).strict(),Ml=()=>({version:1,packages:{}}),Xb=()=>new g(".tapster/state.json is damaged","Restore it from the hub's git history.");function ri(e){if(e===null)return Ml();let t;try{t=JSON.parse(e)}catch{throw Xb()}let n=IR.safeParse(t);if(!n.success)throw Xb();return n.data}var ey="tapster reach";function ty(e){let t={};if(!/^[a-z0-9][a-z0-9-]*: (yes|no)(, [a-z0-9][a-z0-9-]*: (yes|no))*$/.test(e))return t;for(let n of e.matchAll(/([a-z0-9][a-z0-9-]*): (yes|no)/g))t[n[1]]=n[2]==="yes";return t}var ny=/App is not installed on /;function NR(e,t,n,r){let s=n?"the hub's last check did not say":"the hub has not checked it yet";if(n&&!n.listed.includes(t.toLowerCase()))s=`${e} was not in tapster.yml at the hub's last check`;else if(n){let o=n.reached?.[e];if(o===!0)return{reaches:!0,how:"run",reason:null};let i=n.failures.filter((l)=>l.startsWith(`${e}: `)).map((l)=>l.slice(e.length+2)),a=i.find((l)=>ny.test(l))??n.failures.find((l)=>/^tapster: the App is not installed on any/.test(l))?.slice(9);if(o===!1||a)return{reaches:!1,how:"run",reason:a??i[0]??`the hub's App could not reach ${t}`};let c=n.failures.find((l)=>/^(tapster|hub): /.test(l));if(c)s=c.replace(/^(tapster|hub): /,"");else if(n.reached)s=`the hub's last check did not include ${e}`}return r?{reaches:!0,how:"release",reason:null}:{reaches:null,how:null,reason:s}}async function Ul(e,t,n){let r=e.apps.get(n),s=r?await wo(r.id,r.pem,n.split("/")[0],e.deps.fetch).then((m)=>new Set((m??[]).map((v)=>v.toLowerCase())),()=>null):null,o=await On(t,n),i=o.find((m)=>m.status!=="completed")?.html_url??null,a=o.find((m)=>m.status==="completed"&&m.conclusion!=="cancelled"&&m.conclusion!=="skipped");if(!a)return{done:null,running:i,direct:s};let l=(await t.json("GET",`/repos/${n}/actions/runs/${a.id}/jobs?per_page=50`).then((m)=>m.jobs,()=>[])).find((m)=>m.name==="check"),[u,p,d]=await Promise.all([l?t.json("GET",`/repos/${n}/check-runs/${l.id}/annotations?per_page=100`).catch(()=>[]):Promise.resolve([]),F(t,n,"tapster.yml",a.head_sha).catch(()=>null),t.json("GET",`/repos/${n}/issues?state=open&creator=${encodeURIComponent("github-actions[bot]")}&per_page=20`).catch(()=>[])]),f=(d.find((m)=>m.title==="tapster: the hub needs attention"&&m.user?.login==="github-actions[bot]"&&m.updated_at>=a.created_at)?.body??"").split(`
1411
+ `).filter((m)=>/^[a-z0-9][a-z0-9-]*: /.test(m)&&ny.test(m));return{done:{conclusion:l?.conclusion??null,created:a.created_at,at:l?.completed_at??a.updated_at??null,url:l?.html_url??a.html_url,listed:Oo(p,n.split("/")[0]).map((m)=>m.repo.toLowerCase()),failures:[...u.filter((m)=>m.annotation_level==="failure").map((m)=>m.message),...f],reached:((m)=>m?ty(m.message):null)(u.find((m)=>m.annotation_level==="notice"&&m.title===ey))},running:i,direct:s}}function Gl(e,t,n,r){let s=e.running!==null;if(e.direct)return{reaches:e.direct.has(n.toLowerCase()),how:"key",at:new Date().toISOString(),since:new Date().toISOString(),reason:null,run:e.running,running:s};let o=(r.packages[t]??[]).some((a)=>a.status==="published"),i=NR(t,n,e.done,o);return{...i,at:i.how==="run"?e.done?.at??null:null,since:e.done?.created??null,run:e.running??e.done?.url??null,running:s}}var zR=/^[A-Za-z0-9-]+\/[A-Za-z0-9._-]+$/;async function jR(e){let{gh:t,login:n}=await ae(e.s),r=le(e.url.searchParams.get("hub"),n),s=e.url.searchParams.get("repo")??"";if(!zR.test(s))throw new g(`${s} is not a repository name`,"Reload the page and try again.");if(!e.s.apps.has(r)){let a=(await On(t,r)).find((c)=>c.status!=="completed");if(a)return{reaches:null,how:null,at:null,since:null,reason:null,run:a.html_url,running:!0}}let o=(await tt(t,r)).find((a)=>a.repo.toLowerCase()===s.toLowerCase());if(!o)throw new g(`${s} is not in ${r}`,"Add the project to the hub first.");let i=si(await F(t,r,".tapster/state.json","main").catch(()=>null));return Gl(await Ul(e.s,t,r),o.name,o.repo,i)}function si(e){try{return ri(e)}catch{return Ml()}}async function LR(e){let t=await V(e.req,I({hub:P()}).strict()),{gh:n,login:r}=await ae(e.s),s=le(t.hub,r);return{...await Hr(e.s,n,s),at:new Date().toISOString()}}var ry={"GET /api/projects/reach":jR,"POST /api/projects/check":LR};var DR=["notarize","homebrew_casks","brews","scoops"];function Zl(e){let t=[];if(e.kind==="go"){let r=null;try{r=e.goreleaser===null?null:Y(e.goreleaser)??{}}catch{t.push("GoReleaser's config is not valid YAML")}if(e.goreleaser===null)t.push(`there is no .goreleaser.yaml on ${e.branch}`);if(r){if(r.release?.draft!==!0)t.push("GoReleaser publishes releases instead of opening drafts");let s=DR.filter((o)=>(o in r));if(s.length)t.push(`GoReleaser still has ${s.join(", ")}, which the hub does now`)}}if(e.workflow===null)return[...t,`there is no .github/workflows/${e.workflowName} on ${e.branch}`];if(e.kind!=="go"&&!/--draft\b/.test(e.workflow))t.push("the workflow publishes releases instead of opening drafts");if(!e.workflow.includes("actions/attest-build-provenance@"))t.push("the workflow does not attest the archives");let n=[...new Set(e.workflow.match(/\b(?:MACOS|HOMEBREW_TAP)_[A-Z0-9_]+/g)??[])];if(n.length)t.push(`the workflow still uses ${n.join(", ")}`);return t}async function MR(e,t,n,r){let[s,o,i,a]=await Promise.all([en(t,n).then((c)=>c.slug,(c)=>c instanceof g?null:Promise.reject(c)),F(t,n,".tapster/state.json","main"),t.json("GET",`/users/${r}`),Ul(e,t,n)]);return{gh:t,hub:n,slug:s,ownerId:i.id,state:si(o),checks:a}}var UR=(e)=>e.replace(/[\u0000-\u001f\u007f-\u009f]/g," ").trim(),sy=(e)=>e.filter((t)=>Ke.test(t.tag_name)).sort((t,n)=>Oe(ee(n.tag_name),ee(t.tag_name)))[0]??null;async function oy(e,t,n){try{let r=(await e.json("GET",`/repos/${t}/git/ref/heads/${encodeURIComponent(n)}`)).object.sha,s=await e.json("GET",`/repos/${t}/commits/${r}`);return{sha:s.sha,subject:UR(s.commit.message.split(`
1412
+ `)[0]??"").slice(0,120),date:s.commit.committer?.date??"",url:s.html_url}}catch(r){if(r instanceof R)return null;throw r}}async function GR(e,t){let{gh:n}=e,r=await n.getRepo(t.repo),s=r.default_branch,o=(b)=>F(n,t.repo,b,encodeURIComponent(s)),[i,a,c,l,u,p,d,h]=await Promise.all([t.kind==="go"?o(".goreleaser.yaml").then((b)=>b??o(".goreleaser.yml")):Promise.resolve(null),o(`.github/workflows/${t.workflow}`),t.protection==="off"?Promise.resolve([]):Yt(n,t.repo,s,"admin",t.protection==="dependabot").catch(()=>["GitHub did not show the repository's rulesets"]),n.json("GET",`/repos/${t.repo}/keys`).catch(()=>[]),n.json("GET",`/repos/${t.repo}/releases?per_page=30`).catch(()=>[]),Io(n,t.repo).catch(()=>[]),oy(n,t.repo,s),n.json("GET",`/repos/${t.repo}/actions/secrets?per_page=100`).then((b)=>Tn(b.secrets.map((k)=>k.name)),()=>[])]),f=e.state.packages[t.name]??[],m=sy(u.filter((b)=>!b.draft)),v=sy(u.filter((b)=>b.draft&&Ke.test(b.tag_name)&&(!m||Oe(ee(b.tag_name),ee(m.tag_name))>0))),_=Xt([...p.map((b)=>b.name),...u.map((b)=>b.tag_name)]),A=d?await cl(n,t.repo,p,d.sha):null,y=Zl({kind:t.kind,branch:s,workflowName:t.workflow,goreleaser:i,workflow:a});return{name:t.name,repo:t.repo,url:r.html_url,kind:t.kind,defaultBranch:s,setup:{ok:y.length===0,problems:y},protection:{ok:c.length===0,off:t.protection==="off",problems:c},entry:{state:t.state,pr:t.pr},app:{...Gl(e.checks,t.name,t.repo,e.state),installUrl:e.slug?ll(e.slug,e.ownerId,r.id):""},release:{latest:m?{tag:m.tag_name,url:m.html_url,byHub:f.some((b)=>b.tag===m.tag_name&&b.status==="published")}:null,draft:v?{tag:v.tag_name,url:v.html_url,note:Zr(v.body)}:null,highest:_,next:Po(_),autoTag:l.some((b)=>b.title==="tapster tags"),atHead:A,head:d},secrets:{names:h,published:f.some((b)=>b.status==="published")},unreadable:null}}async function Hl(e,t){try{return await GR(e,t)}catch(n){if(!(n instanceof g))throw n;return{name:t.name,repo:t.repo,url:`https://github.com/${t.repo}`,kind:t.kind,defaultBranch:"main",setup:{ok:!1,problems:[]},protection:{ok:!1,off:!1,problems:[]},entry:{state:t.state,pr:t.pr},app:{reaches:null,how:null,at:null,since:null,reason:null,run:null,running:!1,installUrl:""},release:{latest:null,draft:null,highest:null,next:"v0.1.0",autoTag:!1,atHead:null,head:null},secrets:{names:[],published:!1},unreadable:`${n.reason}. ${n.fix}`}}}async function HR(e,t,n){let r=async(s)=>await F(e,t,s,encodeURIComponent(n)).catch(()=>null)!==null;if(await r(".goreleaser.yaml")||await r(".goreleaser.yml"))return"go";return await r("package.json")?"bun":"app"}var ql=/^[A-Za-z0-9-]+\/[A-Za-z0-9._-]+$/;async function ZR(e){let{gh:t,login:n}=await ae(e.s),r=le(e.url.searchParams.get("hub"),n),s=e.url.searchParams.get("repo");if(s!==null&&(!ql.test(s)||s.split("/")[0].toLowerCase()!==n.toLowerCase()))throw new g(`${s} is not one of your repositories`,"Reload the page and try again.");let o=await tt(t,r),i=await MR(e.s,t,r,n);if(s!==null){let a=o.find((u)=>u.repo.toLowerCase()===s.toLowerCase());if(a)return{projects:[await Hl(i,a)]};let c=s.split("/")[1].toLowerCase().replace(/[^a-z0-9-]/g,"-"),l=await HR(t,s,(await t.getRepo(s)).default_branch);return{projects:[await Hl(i,{name:c,repo:s,kind:l,workflow:"release.yml",protection:"on",description:null,state:"missing",pr:null})]}}return{projects:await Promise.all(o.map((a)=>Hl(i,a)))}}var qR=I({hub:P(),repo:P().regex(ql),tag:P().max(100),sha:P().regex(/^[0-9a-f]{40,64}$/)}).strict();async function Bl(e,t,n){let r=(await tt(e,t)).find((s)=>s.repo.toLowerCase()===n.toLowerCase());if(!r)throw new g(`${n} is not in ${t}`,"Add the project to the hub first.");return r}async function BR(e){let t=await V(e.req,qR),{gh:n,login:r}=await ae(e.s),s=le(t.hub,r),o=await Bl(n,s,t.repo),i=(await n.getRepo(o.repo)).default_branch,a=await oy(n,o.repo,i);if(!a)throw new g(`GitHub did not show the latest commit on ${i}`,"Try again in a moment.");if(a.sha!==t.sha)throw new g(`${i} moved since this page read it`,`It now ends at ${a.sha.slice(0,7)}, ${a.subject}. Check that commit, then click Release again.`);let[c,l]=await Promise.all([Io(n,o.repo),n.json("GET",`/repos/${o.repo}/releases?per_page=100`)]).catch(()=>{throw new g(`GitHub did not list the tags of ${o.repo}`,"Try again in a moment. tapster releases only once it has checked the versions.")}),u={tag:t.tag,sha:t.sha},p=await cl(n,o.repo,c,a.sha);if(p===t.tag)return u;if(p)throw new g(`${i} has nothing new since ${p}`,`Push the changes you want to release to ${i}, then click Release again.`);let d=Rv(t.tag,Xt([...c.map((h)=>h.name),...l.map((h)=>h.tag_name)]));if(d)throw new g(`${t.tag} cannot be released`,`${d}.`);try{await n.json("POST",`/repos/${o.repo}/git/refs`,{ref:`refs/tags/${t.tag}`,sha:t.sha})}catch(h){if(!(h instanceof R&&h.status===422))throw h;let f=await n.json("GET",`/repos/${o.repo}/git/ref/tags/${encodeURIComponent(t.tag)}`).catch(()=>null);if(f&&await al(n,o.repo,{sha:f.object.sha,type:f.object.type??"commit"})===t.sha)return u;throw new g(`${t.tag} already exists on ${o.repo}`,"Pick the next version and click Release again.")}return u}async function FR(e){let{gh:t,login:n}=await ae(e.s),r=le(e.url.searchParams.get("hub"),n),s=e.url.searchParams.get("tag")??"";if(!Ke.test(s))throw new g(`${s} is not a version tag`,"Reload the page and try again.");let o=await Bl(t,r,e.url.searchParams.get("repo")??""),[i,a,c,l]=await Promise.all([t.json("GET",`/repos/${o.repo}/actions/runs?event=push&branch=${encodeURIComponent(s)}&per_page=5`).catch(()=>({workflow_runs:[]})),t.json("GET",`/repos/${o.repo}/releases?per_page=30`).catch(()=>[]),F(t,r,".tapster/state.json","main").catch(()=>null),On(t,r)]),u=si(c),p=i.workflow_runs[0],d=l[0],h=a.find((m)=>m.tag_name===s),f=(u.packages[o.name]??[]).some((m)=>m.tag===s&&m.status==="published");return{run:p?{status:p.status,conclusion:p.conclusion,url:p.html_url}:null,draft:h?.draft?{url:h.html_url,note:Zr(h.body)}:null,published:h&&!h.draft?{url:h.html_url,byHub:f}:null,hub:`https://github.com/${r}/actions/workflows/tapster.yml`,hubRun:d?{status:d.status,conclusion:d.conclusion,url:d.html_url}:null}}async function KR(e){let t=await V(e.req,I({hub:P(),repo:P().regex(ql)}).strict()),{gh:n,login:r}=await ae(e.s),s=le(t.hub,r),o=await Bl(n,s,t.repo);if(await n.json("GET",`/repos/${o.repo}/actions/variables/TAPSTER_DOORBELL`).then(()=>!0,(a)=>a instanceof R&&a.status===404?!1:Promise.reject(a)))return{started:!1,run:null,doorbell:!0};return{...await Hr(e.s,n,s),doorbell:!1}}var iy={...ry,"GET /api/projects/status":ZR,"POST /api/projects/release":BR,"GET /api/projects/follow":FR,"POST /api/projects/publish":KR};var cy="Release through the tapster hub";function qr(e,t){if(typeof e!=="string"||!Fl(e))throw new g("that is not a full folder path","Give the folder's full path, such as /Users/you/Developer/my-tool.");let n=py(uy(e));if(!ti(n,t))throw new g(`${n} is outside your home folder`,"tapster reads clones inside your home folder only.");let r;try{r=ay(n)}catch{throw new g(`${n} does not exist`,"Check the path.")}if(!r.isDirectory())throw new g(`${n} is not a folder`,"Give the folder of the clone.");if(!oi(Ne(n,".git"))||!ay(Ne(n,".git")).isDirectory())throw new g(`${n} is not a git clone`,"Give the top folder of a clone, the one that holds .git.");return n}function Br(e,t){let n=Ll(oe(Ne(e,".git","config"),65536)??"");if(!n)throw new g("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 g(`${n} does not belong to ${t}`,"tapster publishes repositories of your own account.");return n}async function Cn(e,t,n={}){if(!n.user)return Ve(e,t,n);let r={...process.env,GIT_TERMINAL_PROMPT:"0",GIT_SSH_COMMAND:process.env.GIT_SSH_COMMAND??"ssh -o BatchMode=yes"};return L(Ct.git,"git",["-C",e,...t],{env:r,allowFail:!0,timeoutMs:n.timeoutMs??20000,maxOutput:4194304})}async function dy(e,t){let n=await Ve(e,["cat-file","-p",`HEAD:${t}`]);return n.code===0?n.stdout:null}function WR(e){let t=oe(Ne(e,".git","HEAD"),4096)?.trim()??"";return/^ref: refs\/heads\/(.+)$/.exec(t)?.[1]??"a detached HEAD"}async function hy(e,t){let n=[];for(let r of t){let s=oe(Ne(e,r));if(s!==null&&s!==await dy(e,r))n.push(r)}return n}var fy={hub:P()};async function VR(e){let t=await V(e.req,I({hub:P(),extra:re(P()).max(10)}).strict()),{gh:n,login:r}=await ae(e.s),s=le(t.hub,r),o=t.extra.map((h)=>py(h)).filter((h)=>Fl(h)&&ti(h,e.s.deps.home)&&oi(h)),i=[...new Set([...o,...ei(e.s.deps.home,e.s.deps.cwd)])].filter((h)=>oi(h)),{found:a,truncated:c}=ni(i),l=await tt(n,s).catch(()=>[]),u=(h)=>l.find((f)=>f.repo.toLowerCase()===h.toLowerCase()),p=a.filter((h)=>h.owner.toLowerCase()===r.toLowerCase()&&h.repo.toLowerCase()!==s.toLowerCase());return{projects:Qb([...new Map(p.map((h)=>[h.path,h])).values()]).map(({owner:h,...f})=>({...f,inHub:u(f.repo)?.state==="merged",proposed:u(f.repo)?.pr??null})).sort((h,f)=>Number(f.kind!==null)-Number(h.kind!==null)||h.repo.localeCompare(f.repo)),roots:i,others:a.length-p.length,truncated:c}}function YR(e){let t=Ne(e,".github","workflows"),n;try{n=ly(t).filter((r)=>/^[A-Za-z0-9._-]+\.ya?ml$/.test(r))}catch{return[]}return n.filter((r)=>(oe(Ne(t,r))??"").includes("goreleaser/goreleaser-action")).sort()}async function JR(e){let t=await V(e.req,I({...fy,path:P()}).strict()),{gh:n,login:r}=await ae(e.s),s=le(t.hub,r),o=qr(t.path,e.s.deps.home),i=Br(o,r),a=ml(i),c=ly(o),{kind:l,why:u}=Dl(o,c);if(l==="app"&&!dl(o))l=null,u="an Xcode project without a Sparkle feed (SUFeedURL ending in /releases/latest/download/<name>.xml)";if(l==="bun"){let x=oe(Ne(o,"package.json")),N=null;try{N=x?JSON.parse(x):null}catch{N=null}if(!N||!Ro(N,a))l=null,u="package.json has no bin entry, so there is no command to publish"}if(l===null)throw new g(`tapster cannot publish ${i} yet: it is ${u}`,"tapster publishes GoReleaser Go tools, Bun command line tools and Mac apps that update with Sparkle.");let p=l==="go"?YR(o):[],d=oe(Ne(o,".github","workflows","release.yml")),h=await hy(o,[".github/workflows/release.yml",".goreleaser.yaml",".goreleaser.yml",...p.map((x)=>`.github/workflows/${x}`)]),f=WR(o),[m,v,_]=await Promise.all([n.getRepo(i),en(n,s).catch(()=>null),tt(n,s).catch(()=>[])]),A=await Yt(n,i,m.default_branch,"admin").catch(()=>["unknown"]),y=_.find((x)=>x.repo.toLowerCase()===i.toLowerCase());if(!v)throw new g(`${s} has no App yet`,"Finish the hub's setup first.");let b=p.includes("release.yml")?"release.yml":p[0]??(l==="go"?null:"release.yml"),k=(x)=>oe(Ne(o,x)),S=b!==null&&Zl({kind:l,branch:f,workflowName:b,goreleaser:l==="go"?k(".goreleaser.yaml")??k(".goreleaser.yml"):null,workflow:k(`.github/workflows/${b}`)}).length===0,O=await Cn(o,["rev-list","--count","@{u}..HEAD"]);return{path:o,repo:i,name:a,kind:l,branch:f,defaultBranch:m.default_branch,dirty:[...new Set(h)],workflows:p,workflow:l==="go"?b:null,releaseFlow:d===null?"missing":d.includes("Ring the tapster hub")?"ours":"other",dependabot:[".github/dependabot.yml",".github/dependabot.yaml"].some((x)=>oi(Ne(o,x))),private:m.private,protected:A.length===0,inHub:y?.state==="merged",proposed:y?.pr??null,apple:v.apple,ready:S,ahead:O.code===0&&/^\d+$/.test(O.stdout.trim())?Number(O.stdout.trim()):null}}var QR=I({...fy,path:P(),options:I({workflow:P().regex(/^[A-Za-z0-9._-]+\.ya?ml$/),autoTag:at(),dependabot:at(),force:at()}).strict()}).strict();async function XR(e){let t=await V(e.req,QR),{gh:n,login:r}=await ae(e.s),s=le(t.hub,r),o=qr(t.path,e.s.deps.home),i=Br(o,r),a=t.options,c=hl([...a.force?["--force"]:[],...a.autoTag?["--auto-tag"]:[],...a.dependabot?["--allow-dependabot"]:[],"--workflow",a.workflow]),l=await en(n,s);await Cn(o,["config","tapster.hub",s],{user:!0});let u=[],p=await fl(n,o,i,s,l,c,(d)=>u.push(d));return{lines:u,pr:p.pr,entry:p.entry,installUrl:p.installUrl,files:await hy(o,p.files)}}function my(e){for(let t of e)if(Fl(t)||uy(t).startsWith("..")||!/^[A-Za-z0-9._/-]+$/.test(t))throw new g(`${t} is not a file of this clone`,"Reload the page and try again.");return e}var gy=I({path:P(),files:re(P()).min(1).max(10)}).strict();async function e2(e){let t=await V(e.req,gy),{login:n}=await ae(e.s),r=qr(t.path,e.s.deps.home);Br(r,n);let s=[];for(let o of my(t.files)){let i=await dy(r,o),a=oe(Ne(r,o));s.push({path:o,before:i,after:a,change:i===null?"create":a===null?"remove":i===a?"same":"update"})}return{files:s}}async function t2(e){let t=await V(e.req,gy),{login:n}=await ae(e.s),r=qr(t.path,e.s.deps.home);Br(r,n);let s=my(t.files),o=await Cn(r,["add","--",...s],{user:!0});if(o.code!==0)throw new g("git could not stage the files",o.stderr.trim().split(`
1413
+ `).at(-1)??"Run git status in the clone.");let i=await Cn(r,["commit","-m",cy,"--",...s],{user:!0,timeoutMs:60000});if(i.code!==0){let a=`${i.stdout}
1414
+ ${i.stderr}`;if(/nothing to commit|no changes added/i.test(a))return{committed:!1};throw new g("git could not commit",`${a.trim().split(`
1415
+ `).at(-1)??""} Commit in a terminal: git commit -m "${cy}" -- ${s.join(" ")}`)}return{committed:!0}}async function n2(e){let t=await V(e.req,I({path:P()}).strict()),{login:n}=await ae(e.s),r=qr(t.path,e.s.deps.home);Br(r,n);let o=(await Cn(r,["rev-parse","--abbrev-ref","--symbolic-full-name","@{u}"])).code===0?["push"]:["push","--set-upstream","origin","HEAD"];if((await Cn(r,o,{user:!0,timeoutMs:90000}).catch((a)=>{if(a instanceof g)return{code:1,stdout:"",stderr:a.reason};throw a})).code!==0)throw new g("git could not push without asking for a password or passphrase",`Push from a terminal in ${r}: git ${o.join(" ")}`);return{pushed:!0}}var vy={"POST /api/projects/scan":VR,"POST /api/projects/inspect":JR,"POST /api/projects/add":XR,"POST /api/projects/diff":e2,"POST /api/projects/commit":t2,"POST /api/projects/push":n2};var Fr=8277,s2=7200000;function o2(e){let t={open:!0,port:null,pin:null};for(let n=0;n<e.length;n++){let r=e[n],s=e[n+1];if(r==="--no-open")t.open=!1;else if(r==="--port"&&s&&/^\d{2,5}$/.test(s)&&Number(s)>=1024&&Number(s)<=65535)t.port=Number(e[++n]);else if(r==="--tapster"&&s&&/^[0-9a-f]{40}$/.test(s))t.pin=e[++n];else throw new g(`unknown option ${r}`,"Run tapster setup --help for the options.")}return t}function i2(e,t){return{...Fb,...vy,...iy,"GET /api/session":async()=>{let n=await Je(e.deps.cwd).catch(()=>null),r=n!==null&&/\/homebrew-/.test(n);return{version:ue.version,dev:ue.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 a2(e){let t=process.platform==="darwin"?"/usr/bin/open":"/usr/bin/xdg-open";L(t,"open",[e],{allowFail:!0}).catch(()=>{return})}function Kl(e){let t=null;return{async github(){if(t&&Date.now()-t.at<60000)return t.gh;let n=await Rt();return t={gh:n,at:Date.now()},n},fetch,home:r2(),cwd:process.cwd(),pin:e,log:(n)=>console.log(n),open:a2,notary:Ko,keychain:(n)=>Dr("the Sparkle key").read({service:"https://sparkle-project.org",account:n,label:"Private key for signing Sparkle updates"})}}function by(e,t){return Bun.serve({hostname:"127.0.0.1",port:e,fetch:t,development:!1,error:()=>nt("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 yy(e,t){let n=o2(e);if(process.platform==="win32")throw new g("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??Kl(n.pin),s=async()=>new Response(null,{status:503}),o;try{o=by(n.port??Fr,(d)=>s(d))}catch{if(n.port!==null)throw new g(`port ${n.port} is in use`,"Pick another one with --port or close the program that uses it.");o=by(0,(d)=>s(d)),r.log(`Port ${Fr} is in use (another tapster setup may be open), so this one uses ${o.port}. Password managers save entries per address, so they may not offer the ones saved on ${Fr}.`)}let i=()=>{},a=new Promise((d)=>i=d),c=Yo(r,o.port),l=()=>{clearInterval(u),process.stdin.pause(),o.stop(),i()};s=jb(c,i2(c,l),(d)=>Ub(d));let u=setInterval(()=>{if(Date.now()-c.touched>s2)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
1416
  ${d}
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}
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
- `)};await pC({deps:t,gh:()=>t.github()})}var dC=`tapster: publish your projects' releases from one Homebrew tap
1417
+ `),n.open)r.open(d)};if(r.log(`tapster setup runs on this computer at http://127.0.0.1:${o.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(`
1418
+ `))p()}),process.stdin.resume();await a,r.log("tapster setup stopped.")}import{createInterface as p2}from"readline";var c2=86400000;function l2(e,t=Date.now()){let n=Date.parse(`${e}T00:00:00Z`);return!Number.isNaN(n)&&n-t<30*c2}function u2(e,t){if(e.apple.needed)return!0;return t===null?null:t==="yes"}function wy(e,t,n=Date.now(),r=null){let s=u2(e,t),o=e.protect.checks.filter((l)=>l.ok).length,i=zv(r,e.packages.length),a=[{id:"protect",name:"Protect the hub",done:e.protect.done,status:e.protect.done?"All protections are on":o?`${o} 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:s===!0,skipped:s===!1,status:s===!0?"Signs macOS software":s===!1?"No macOS builds":"Your answer",open:"Your answer"},{id:"certificate",name:"Apple certificate",done:Boolean(e.apple.certificate&&e.apple.certificateStored),skipped:s===!1,attention:Boolean(e.apple.certificate&&l2(e.apple.certificate.expires,n)),status:s===!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:s===!1,status:s===!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:i.done,status:i.status,open:"None yet"}],c=!1;return a.map((l)=>{let u;if(l.skipped)u="skipped";else if(l.attention)u="attention";else if(l.done)u="done";else if(!c)u="now",c=!0;else u="later";return{id:l.id,name:l.name,state:u,status:l.status}})}var _y=["2025-11-25","2025-06-18","2025-03-26","2024-11-05"],d2=`tapster turns the user's Homebrew tap into a release hub that signs, notarizes and publishes the releases of their projects.
1419
+ 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/`,Rn={hub:P().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 In(e,t){let n=await e.gh(),r=(await n.json("GET","/user")).login;if(typeof t==="string"&&t)return{gh:n,hub:le(t,r),login:r};let s=(u)=>u&&u.split("/")[0].toLowerCase()===r.toLowerCase()&&/\/homebrew-/.test(u)?u:null,o=s((await Ve(e.deps.cwd,["config","--get","tapster.hub"])).stdout.trim());if(o)return{gh:n,hub:le(o,r),login:r};let i=s(await Je(e.deps.cwd).catch(()=>null));if(i)return{gh:n,hub:le(i,r),login:r};let a=await zl(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 g("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 ky=[{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:I(Rn),readOnly:!0,async run(e,t){let{gh:n,hub:r}=await In(t,e.hub),s=await jl(Yo(t.deps,0),n,r);return{hub:r,steps:wy(s,null).map((o)=>({step:o.name,state:o.state,status:o.status})),projects:s.packages,refused:s.invalid,healthIssue:s.issue?{url:s.issue.url,updated:s.issue.updated,body:s.issue.body}:null,extras:s.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:I(Rn),readOnly:!0,async run(e,t){let{gh:n,hub:r}=await In(t,e.hub),{checks:s,note:o}=await Nr(n,r);return{hub:r,problems:s.filter((i)=>!i.ok),passed:s.filter((i)=>i.ok).map((i)=>i.name),note:o}}},{name:"hub_runs",title:"Recent hub runs",description:"The hub workflow's latest runs with their result and a link to each log.",input:I(Rn),readOnly:!0,async run(e,t){let{gh:n,hub:r}=await In(t,e.hub),s=await n.json("GET",`/repos/${r}/actions/workflows/tapster.yml/runs?per_page=10`);return{hub:r,runs:s.workflow_runs.map((o)=>({started:o.created_at,by:o.event,status:o.status,result:o.conclusion,log:o.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:I({...Rn,repo:P().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:s}=await In(t,e.hub),o=String(e.repo),i=(await n.listReleases(o)).slice(0,8),a=await F(n,r,"tapster.yml","main"),c=a?ve(a,s).config.packages.find((u)=>u.repo.toLowerCase()===o.toLowerCase()):void 0,l=ri(await F(n,r,".tapster/state.json","main"));return{hub:r,repo:o,inHub:c?c.name:null,releases:i.map((u)=>({tag:u.tag_name,draft:u.draft,published:u.published_at,files:u.assets.length,hubNote:Zr(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:I(Rn),readOnly:!0,async run(e,t){let{gh:n,hub:r,login:s}=await In(t,e.hub),o=await F(n,r,"tapster.yml","main"),i=new Set(o?ve(o,s).config.packages.map((l)=>l.repo.toLowerCase()):[]),{found:a,truncated:c}=ni(ei(t.deps.home,t.deps.cwd).filter(Boolean));return{hub:r,projects:a.filter((l)=>l.owner.toLowerCase()===s.toLowerCase()).map((l)=>({repo:l.repo,path:l.path,kind:l.kind,notSupported:l.why,inHub:i.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:I(Rn),readOnly:!1,async run(e,t){let{gh:n,hub:r}=await In(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`}}}],Nn=(e,t)=>({jsonrpc:"2.0",id:e,result:t}),ii=(e,t,n)=>({jsonrpc:"2.0",id:e??null,error:{code:t,message:n}});async function h2(e,t){if(e===null||typeof e!=="object"||Array.isArray(e))return ii(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 Nn(e.id,{protocolVersion:_y.includes(n)?n:_y[0],capabilities:{tools:{listChanged:!1}},serverInfo:{name:"tapster",title:"tapster",version:ue.version},instructions:d2})}if(e.method==="ping")return Nn(e.id,{});if(e.method==="tools/list")return Nn(e.id,{tools:ky.map((n)=>({name:n.name,title:n.title,description:n.description,inputSchema:rg(n.input),annotations:{readOnlyHint:n.readOnly,openWorldHint:!0}}))});if(e.method==="tools/call"){let n=ky.find((s)=>s.name===e.params?.name);if(!n)return ii(e.id,-32602,`unknown tool ${String(e.params?.name)}`);let r=n.input.safeParse(e.params?.arguments??{});if(!r.success)return Nn(e.id,{content:[{type:"text",text:`Invalid arguments: ${r.error.issues.map((s)=>`${s.path.join(".")}: ${s.message}`).join("; ")}`}],isError:!0});try{let s=await n.run(r.data,t);return Nn(e.id,{content:[{type:"text",text:JSON.stringify(s,null,2)}],structuredContent:s})}catch(s){let o=s instanceof g?`${s.reason}. ${s.fix}`:"tapster hit an unexpected error. Try again; if it repeats, the user can run the same check in a terminal.";return Nn(e.id,{content:[{type:"text",text:o}],isError:!0})}}return ii(e.id,-32601,`unknown method ${String(e.method)}`)}async function f2(e,t=process.stdin,n=(r)=>process.stdout.write(`${r}
1420
+ `)){let r=p2({input:t,crlfDelay:1/0});for await(let s of r){if(!s.trim())continue;let o;try{o=JSON.parse(s)}catch{n(JSON.stringify(ii(null,-32700,"parse error")));continue}let i=await h2(o,e);if(i)n(JSON.stringify(i))}}async function xy(e){if(e.length)throw new g(`unknown option ${e.join(" ")}`,"tapster mcp takes no options.");let t={...Kl(null),log:(n)=>process.stderr.write(`${n}
1421
+ `)};await f2({deps:t,gh:()=>t.github()})}var m2=`tapster: publish your projects' releases from one Homebrew tap
1410
1422
 
1411
1423
  tapster setup open the setup in your browser: the hub, your projects and their health
1412
1424
  tapster init set up this hub clone; run it again to finish or repair the setup
@@ -1415,11 +1427,11 @@ These tools read the hub and the projects through the user's GitHub CLI sign-in
1415
1427
  tapster mcp serve tapster's tools to an AI assistant over MCP (stdio)
1416
1428
  tapster --version show this tapster and the commit it pins hubs to
1417
1429
 
1418
- Run tapster <command> --help for the options: Sparkle and Linux keys, the doorbell, rotations and more.`,Gy={setup:`tapster setup: set up the hub and add your projects in your browser
1430
+ Run tapster <command> --help for the options: Sparkle and Linux keys, the doorbell, rotations and more.`,Sy={setup:`tapster setup: set up the hub and add your projects in your browser
1419
1431
 
1420
1432
  tapster setup [--no-open] [--port <port>] [--tapster <commit>]
1421
1433
  --no-open print the link instead of opening the browser
1422
- --port listen on this port instead of ${jr}
1434
+ --port listen on this port instead of ${Fr}
1423
1435
  --tapster pin the hub workflow to this commit (for a tapster built from a checkout)
1424
1436
 
1425
1437
  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
@@ -1448,5 +1460,5 @@ Run tapster <command> --help for the options: Sparkle and Linux keys, the doorbe
1448
1460
  claude mcp add tapster -- bunx @doguyilmaz/tapster mcp
1449
1461
 
1450
1462
  The tools read the hub, its runs, a project's releases and the projects on this computer. One of them starts a hub run.
1451
- They use your GitHub CLI sign-in and never touch your keys.`},[_e,...at]=process.argv.slice(2);try{if(_e==="--version"||_e==="-v")console.log(`tapster ${ae.version} (${ae.sha?ae.sha.slice(0,12):"built from a checkout; init --workflow needs --tapster <commit>"})`);else if(_e&&Gy[_e]&&(at[0]==="--help"||at[0]==="-h"))console.log(Gy[_e]);else if(_e==="setup")await Ny(at);else if(_e==="mcp")await Zy(at);else if(_e==="init")await ey(at);else if(_e==="add")await $v(at);else if(_e==="doctor"){if(at.length)throw new v(`unknown option ${at.join(" ")}`,"tapster doctor takes no options.");process.exitCode=await Ov(at)}else console.log(dC),process.exitCode=_e&&_e!=="help"&&_e!=="--help"?1:0}catch(e){console.error(e instanceof v?`tapster: ${e.reason}
1463
+ They use your GitHub CLI sign-in and never touch your keys.`},[Se,...dt]=process.argv.slice(2);try{if(Se==="--version"||Se==="-v")console.log(`tapster ${ue.version} (${ue.sha?ue.sha.slice(0,12):"built from a checkout; init --workflow needs --tapster <commit>"})`);else if(Se&&Sy[Se]&&(dt[0]==="--help"||dt[0]==="-h"))console.log(Sy[Se]);else if(Se==="setup")await yy(dt);else if(Se==="mcp")await xy(dt);else if(Se==="init")await Pb(dt);else if(Se==="add")await eb(dt);else if(Se==="doctor"){if(dt.length)throw new g(`unknown option ${dt.join(" ")}`,"tapster doctor takes no options.");process.exitCode=await sb(dt)}else console.log(m2),process.exitCode=Se&&Se!=="help"&&Se!=="--help"?1:0}catch(e){console.error(e instanceof g?`tapster: ${e.reason}
1452
1464
  ${e.fix}`:"tapster: unexpected error"),process.exitCode=1}