@pubnio/cli 0.2.1 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +2 -2
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -32,7 +32,7 @@ ${t}}`;return n},Dg="~effect/Fiber",T2={_A:Ie,_E:Ie},O2=0,yC=(()=>{try{return gl
32
32
  `)===-1&&e.indexOf("\r")===-1?e:e.replace(/[\n\r]/g,"");var Xf=(e)=>Yz(typeof e==="string"?UR.encode(e):e),em=(e)=>{let t=RR(e),r=t.length;if(r%4!==0)return Dt(new ac({kind:"Decode",module:"Base64",input:t,message:`Length must be a multiple of 4, but is ${r}`}));let n=t.indexOf("=");if(n!==-1&&(n<r-2||n===r-2&&t[r-1]!=="="))return Dt(new ac({kind:"Decode",module:"Base64",input:t,message:"Found a '=' character, but it is not at the end"}));let o=t.endsWith("==")?2:t.endsWith("=")?1:0,i=3*(r/4)-o,s=TR(t,i,void 0);if(s)return Jt(s);if(s===null){let c=tj.exec(t);if(c!==null)return Dt(new ac({kind:"Decode",module:"Base64",input:t,message:`Invalid character ${c[0]}`}))}try{let c=new Uint8Array(i);for(let l=0,S=0;l<r;l+=4,S+=3){let m=Zf(t.charCodeAt(l))<<18|Zf(t.charCodeAt(l+1))<<12|Zf(t.charCodeAt(l+2))<<6|Zf(t.charCodeAt(l+3));c[S]=m>>16,c[S+1]=m>>8&255,c[S+2]=m&255}return Jt(c)}catch(c){return Dt(new ac({kind:"Decode",module:"Base64",input:t,message:c instanceof Error?c.message:"Invalid input"}))}};var Yz=(e)=>{let t=e.length,r=Uint8Array.prototype.toBase64;if(t>=32){if(typeof r==="function")return r.call(e);let n=PR(e,"base64");if(n!==void 0)return n}return t<128?Zz(e):Xz(e)},Zz=(e)=>{let t=e.length,r="",n;for(n=2;n<t;n+=3)r+=Dn[e[n-2]>>2],r+=Dn[(e[n-2]&3)<<4|e[n-1]>>4],r+=Dn[(e[n-1]&15)<<2|e[n]>>6],r+=Dn[e[n]&63];if(n===t+1)r+=Dn[e[n-2]>>2],r+=Dn[(e[n-2]&3)<<4],r+="==";if(n===t)r+=Dn[e[n-2]>>2],r+=Dn[(e[n-2]&3)<<4|e[n-1]>>4],r+=Dn[(e[n-1]&15)<<2],r+="=";return r},Xz=(e)=>{let t=e.length,r=new Uint8Array(Math.ceil(t/3)*4),n,o=0;for(n=2;n<t;n+=3,o+=4)r[o]=ai[e[n-2]>>2],r[o+1]=ai[(e[n-2]&3)<<4|e[n-1]>>4],r[o+2]=ai[(e[n-1]&15)<<2|e[n]>>6],r[o+3]=ai[e[n]&63];if(n===t+1)r[o]=ai[e[n-2]>>2],r[o+1]=ai[(e[n-2]&3)<<4],r[o+2]=oS,r[o+3]=oS;if(n===t)r[o]=ai[e[n-2]>>2],r[o+1]=ai[(e[n-2]&3)<<4|e[n-1]>>4],r[o+2]=ai[(e[n-1]&15)<<2],r[o+3]=oS;return ej.decode(r)},UR=new TextEncoder,ej=new TextDecoder("utf-8",{ignoreBOM:!0}),Dn="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",ai=UR.encode(Dn),oS=61,tj=/[^A-Za-z0-9+/=]/,Nd=new Uint8Array(123).fill(255);for(let e=0;e<Dn.length;e++)Nd[Dn.charCodeAt(e)]=e;Nd[61]=0;var Zf=(e)=>{if(e>=Nd.length||Nd[e]===255)throw TypeError(`Invalid character ${String.fromCharCode(e)}`);return Nd[e]};var Bd=(e)=>Object.assign(Object.create(Ey),e);var rj=Bd({_tag:"Passthrough"});function To(){return rj}function Lt(e){return Bd({_tag:"Transform",transform:e})}function ea(e){return Bd({_tag:"TransformEffect",transform:e})}function iS(e){return Bd({_tag:"TransformOptional",transform:e})}function nj(e){return Bd({_tag:"TransformOptionalEffect",transform:e})}function MR(){return iS(()=>he())}function FR(e){return nj((t)=>{let r=Pv(t,Qt);return O(r)?W(r):Uf(e,Re)})}function tm(){return Lt(globalThis.String)}function rm(){return Lt(globalThis.Number)}function NR(){return Lt(gO)}function BR(){return Lt(yO)}function oj(e){return ea((t,r)=>typeof t==="string"&&!xO(t)?fe(new jr({expected:"a well-formed Unicode string"},t,r)):W(e(t)))}function KR(){return oj(Xf)}function $R(){return ea((e,t)=>Df(lx(em(e)),()=>new jr({expected:"a valid Base64 string"},e,t)))}var sS=class extends Ba{_tag="Middleware";decode;encode;constructor(e,t){super();this.decode=e,this.encode=t}flip(){return new sS(this.encode,this.decode)}},$d="~effect/SchemaTransformation/Transformation",ir=class extends Ba{[$d]=$d;_tag="Transformation";decode;encode;constructor(e,t){super();this.decode=e,this.encode=t}flip(){return new ir(this.encode,this.decode)}};function aj(e){return je(e,$d)&&e[$d]===$d}var aS=(e)=>{if(aj(e))return e;return new ir(e.decode,e.encode)};function nm(e){return new ir(ea(e.decode),ea(e.encode))}function om(e){return new ir(Lt(e.decode),Lt(e.encode))}function qR(){return new ir(NR(),To())}function cj(){return new ir(BR(),To())}var pj=new ir(To(),To());function im(){return pj}var qd=new ir(rm(),Lt((e)=>Object.is(e,-0)?"-0":globalThis.String(e)));var dj=(e)=>jA(e)&&typeof e.message==="string",uj=(e)=>{let r=Object.hasOwn(e,"cause")?Error(e.message,{cause:WR(e.cause)}):Error(e.message);if(typeof e.name==="string"&&e.name!=="Error")r.name=e.name;if(typeof e.stack==="string")r.stack=e.stack;return r},lj=(e)=>{try{let t=Os(e);return t===void 0?et(e):JSON.parse(t)}catch{return et(e)}},fj=(e,t,r)=>{let n={name:e.name,message:typeof e.message==="string"?e.message:""};if(t?.includeStack&&typeof e.stack==="string")n.stack=e.stack;if(!t?.excludeCause&&e.cause!==void 0)n.cause=r(e.cause);return n},mj=(e)=>{let t=new WeakSet,r=(n)=>{if(QA(n)){if(t.has(n))return"[Circular]";t.add(n);let o=fj(n,e,r);return t.delete(n),o}return lj(n)};return r},WR=(e)=>dj(e)?uj(e):e;var GR=(e)=>om({decode:WR,encode:mj(e)});var zR=nm({decode:(e,t)=>URL.canParse(e)?W(new URL(e)):fe(new jr({expected:"a valid URL string"},e,t)),encode:(e)=>W(e.href)});var jR=new ir($R(),KR());function ra(e){return(t)=>t._tag===e}var yS=ra("Declaration");var gj=ra("Never");var Uc=ra("Literal"),pS=ra("UniqueSymbol");var n0=ra("Arrays"),o0=ra("Objects");var na=ra("Suspend"),Ur=class{to;transformation;constructor(e,t){this.to=e,this.transformation=t}},oa={},gS=class{isOptional;isMutable;constructorDefault;annotations;constructor(e,t,r=void 0,n=void 0){this.isOptional=e,this.isMutable=t,this.constructorDefault=r,this.annotations=n}},QR="~effect/Schema";class Ln{[QR]=QR;annotations;checks;encoding;context;constructor(e=void 0,t=void 0,r=void 0,n=void 0){this.annotations=e,this.checks=t,this.encoding=r,this.context=n}toString(){return`<${this._tag}>`}}function dm(e){return e.checks===e.encodingChecks?e:mn(e,{checks:e.encodingChecks,encodingChecks:e.checks,encoding:void 0})}var Qd=class extends Ln{_tag="Declaration";typeParameters;run;encodingChecks;encodingRun;constructor(e,t,r,n,o,i,s,c){super(r,n,o,i);this.typeParameters=e,this.run=t,this.encodingChecks=s,this.encodingRun=c}getParser(){let e;return(t,r)=>{if(t===$e)return Un;e??=this.run(this.typeParameters);try{return e(t,this,r)}catch(n){return Cr(n)}}}recur(e){let t=Dc(this.typeParameters,e);return t===this.typeParameters?this:mn(this,{typeParameters:t,encoding:void 0})}flip(e){let t=dm(this.recur(e));return this.run===this.encodingRun?t:mn(t,{run:this.encodingRun??this.run,encodingRun:this.run,encoding:void 0})}getExpected(){let e=this.annotations?.expected;if(typeof e==="string")return e;return"<Declaration>"}},xj=class extends Ln{_tag="Null";getParser(){return RS(this,null)}getExpected(){return"null"}},um=new xj;var Sj=class extends Ln{_tag="Undefined";getParser(){return RS(this,void 0)}toCodecJson(){return _r(this,[bj])}getExpected(){return"undefined"}},bj=new Ur(um,new ir(Lt(()=>{return}),Lt(()=>null))),xS=new Sj;var Ij=class extends Ln{_tag="Unknown";getParser(){return Jd(this,zA)}getExpected(){return"unknown"}},zd=new Ij;var Oo=class extends Ln{_tag="Literal";literal;constructor(e,t,r,n,o){super(t,r,n,o);if(typeof e==="number"&&!globalThis.Number.isFinite(e))throw Error(`A numeric literal must be finite, got ${et(e)}`);this.literal=e}getParser(){return RS(this,this.literal)}matchPart(e,t){return e===globalThis.String(this.literal)?this.literal:void 0}toCodecJson(){return typeof this.literal==="bigint"?HR(this):this}toCodecStringTree(){return typeof this.literal==="string"?this:HR(this)}getExpected(){return typeof this.literal==="string"?JSON.stringify(this.literal):globalThis.String(this.literal)}};function HR(e){let t=globalThis.String(e.literal);return _r(e,[new Ur(new Oo(t),new ir(Lt(()=>e.literal),Lt(()=>t)))])}var wj=class extends Ln{_tag="String";getParser(){return Jd(this,qo)}matchPart(e,t){let r=this.checks;return r&&!t.disableChecks&&Xi(r,e,void 0,this,t)?void 0:e}getExpected(){return"string"}},Yi=new wj,Ej=class extends Ln{_tag="Number";getParser(){return Jd(this,Cp)}matchKey(e,t){return this._match(Qj,e,t)}matchPart(e,t){return this._match(hS,e,t)}_match(e,t,r){if(!e.test(t))return;let n=globalThis.Number(t);if(r.disableChecks||!this.checks)return n;return Xi(this.checks,n,void 0,this,r)?void 0:n}toCodecJson(){if(this.checks&&(dS(this.checks,"effect/schema/isFinite")||dS(this.checks,"effect/schema/isInt")))return this;return _r(this,[Lj])}toCodecStringTree(){if(this.toCodecJson()===this)return _r(this,[Hj]);return _r(this,[Vj])}getExpected(){return"number"}};function dS(e,t){return e.some((r)=>r.annotations?.representation?.id===t||r._tag==="FilterGroup"&&dS(r.checks,t))}var SS=new Ej,kj=class extends Ln{_tag="Boolean";getParser(){return Jd(this,yl)}getExpected(){return"boolean"}},i0=new kj;var lm=class extends Ln{_tag="Arrays";isMutable;elements;rest;encodingChecks;constructor(e,t,r,n,o,i,s,c){super(n,o,i,s);this.isMutable=e,this.elements=t,this.rest=r,this.encodingChecks=c;let l=!1;for(let S=0;S<t.length;S++)if(Po(t[S]))l=!0;else if(l)throw Error("A required element cannot follow an optional element. ts(1257)");if(l&&r.length>1)throw Error("A required element cannot follow an optional element. ts(1257)");for(let S=1;S<r.length;S++)if(Po(r[S]))throw Error("An optional element cannot follow a rest element. ts(1266)")}getParser(e,t=e){let r=this,n,o,i=r.elements.length,s=Math.max(0,r.rest.length-1);function c(m,g){if(g<i)return n[g];else if(g>=m)return o[g-m+1];return o[0]}let l=(m)=>{let{input:g,len:w,options:k}=m;if(r.rest.length===0&&w>i)for(let A=i;A<w;A++){let y=new rS(r,g[A],k),h=new ii([A],y);if(k.errors==="all")if(m.issues)m.issues.push(h);else m.issues=[h];else return fe(new Rr(r,[h],g,k))}if(m.issues)return fe(new Rr(r,m.issues,g,k));return kr(m.output)},S=(m,g)=>{let w=m.length,k={ast:r,getParser:c,input:m,len:w,tailThreshold:Math.max(i,w-s),output:[],issues:void 0,options:g},A=r.rest.length===0?i:Math.max(w,i+s),y=g.concurrency===void 0?1:rd(g.concurrency),h=y===1?vj(k,m,0,A):Cj(k,m,{concurrency:y,end:A});if(!h)return l(k);if(ut(h))return zr(h,()=>l(k));let x=!0;return Qe(()=>{if(!x)return S(m,g);return x=!1,Ee(h,()=>l(k))})};return(m,g)=>{if(m===$e)return Un;try{if(!Array.isArray(m))return fe(new eo(r,m,g));if(!n)n=r.elements.map((w)=>({ast:w,parser:t(w)})),o=r.rest.map((w)=>({ast:w,parser:t(w)}));return S(m,g)}catch(w){return Cr(w)}}}recur(e){let t=Dc(this.elements,e),r=Dc(this.rest,e);return t===this.elements&&r===this.rest?this:new lm(this.isMutable,t,r,this.annotations,this.checks,void 0,this.context,this.encodingChecks)}flip(e){return dm(this.recur(e))}getExpected(){return"array"}};function Aj(e,t,r,n){if(r._tag==="Failure")return cm(e,e.ast,n,r);let o=Yt(r)?t:r[De];if(o!==$e)e.output[n]=o;else{let i=e.getParser(e.tailThreshold,n);if(Po(i.ast))return;let s=new ii([n],new Ld(i.ast.context?.annotations));if(e.options.errors==="all")if(e.issues)e.issues.push(s);else e.issues=[s];else return Pn(new Rr(e.ast,[s],e.input,e.options))}}var s0={onItem(e,t,r){let n=r<e.len?t:$e;return e.getParser(e.tailThreshold,r).parser(n,e.options)},step:Aj},vj=uf()(s0),Cj=lf()(s0),cm=(e,t,r,n)=>{if(n.cause.reasons.length===0)return n;let o=Fd(n.cause);if(o===void 0)return $i(qi(n.cause,(s)=>new Rr(t,[new ii([r],s)],e.input,e.options)));let i=new ii([r],o);if(e.options.errors==="all")if(e.issues)e.issues.push(i);else e.issues=[i];else return Pn(new Rr(t,[i],e.input,e.options))},a0="[+-]?(?:\\d+(?:\\.\\d+)?|\\.\\d+)(?:[Ee][+-]?\\d+)?";function cS(e,t,r=oa){let n,o;function i(s){switch(s._tag){case"String":case"TemplateLiteral":return(n??=Object.keys(e)).filter((c)=>s.matchPart(c,r)!==void 0);case"Number":return(n??=Object.keys(e)).filter((c)=>s.matchKey(c,r)!==void 0);case"Symbol":return(o??=Object.getOwnPropertySymbols(e)).filter((c)=>Object.prototype.propertyIsEnumerable.call(e,c)&&s.matchKey(c,r)!==void 0);case"Union":return[...new Set(s.types.flatMap(i))];default:return[]}}return i(_S(pi(t)))}var bS=class{name;type;constructor(e,t){this.name=e,this.type=t}};function c0(e){switch(e._tag){case"String":case"Number":case"Symbol":case"TemplateLiteral":return!0;case"Union":return e.types.every(c0);default:return!1}}function p0(e){let t=AS(e);switch(t._tag){case"String":case"Number":case"Symbol":case"TemplateLiteral":return!0;case"Union":return t.types.every(p0);default:return!1}}function Tj(e){return c0(e)&&p0(e)}var d0=class{parameter;type;constructor(e,t){if(!Tj(e))throw Error(`Invalid index signature parameter ${e._tag}`);if(this.parameter=e,this.type=t,Po(t)||t.encoding!==void 0&&Po(pi(t)))throw Error("Cannot use `Schema.optionalKey` or `Schema.optional` with index signatures. Index signatures already allow keys to be absent; use `Schema.UndefinedOr` to allow `undefined` values.")}},IS=class extends Ln{_tag="Objects";propertySignatures;indexSignatures;encodingChecks;constructor(e,t,r,n,o,i,s){super(r,n,o,i);this.propertySignatures=e,this.indexSignatures=t,this.encodingChecks=s}getParser(e,t=e){let r=this,n=r.propertySignatures.length,o=r.indexSignatures.length;if(!n&&!o)return Jd(r,Dy);let i,s,c=()=>{if(!i)i=r.propertySignatures.map((g)=>({parser:t(g.type),name:g.name,type:g.type,ownOnly:m0(g.name)})),s=o?r.indexSignatures.map((g)=>({is:g,parserKey:e(_S(g.parameter)),parserValue:t(g.type)})):void 0;return i},l=()=>{let g=new Set(r.propertySignatures.map((h)=>typeof h.name==="number"?globalThis.String(h.name):h.name)),w=(h,x,q,Y,I)=>{if(I._tag==="Failure")return cm(h,r,x,I)??Hn;let le=Yt(I)?Y:I[De];if(q!==$e&&le!==$e){if(n&&(g.has(x)||g.has(typeof q==="number"?globalThis.String(q):q)))return Hn;Jr(h.out,q,le)}return Hn},k=(h,x,q,Y)=>{if(!Y){let N=q.parserKey(x,h.options);if(!ut(N))return Ee(Ec(N),(Z)=>k(h,x,q,Z));Y=N}if(Y._tag==="Failure")return cm(h,r,x,Y)??Hn;let I=Yt(Y)?x:Y[De],le=h.input[x],ae=q.parserValue(le,h.options);return ut(ae)?w(h,x,I,le,ae):Ee(Ec(ae),(N)=>w(h,x,I,le,N))},A=(h,x,q)=>{let Y=h.input[x],I=q.parserValue(Y,h.options);return ut(I)?w(h,x,x,Y,I):Ee(Ec(I),(le)=>w(h,x,x,Y,le))},y=o?lf()({onItem:(h,[x,q])=>q.is.parameter===Yi?A(h,x,q):k(h,x,q),step:(h,x,q)=>q._tag==="Failure"?q:void 0}):void 0;return RO(function*(h,x){if(h===$e)return $e;if(!(typeof h==="object"&&h!==null&&!Array.isArray(h)))return yield*fe(new eo(r,h,x));c();let q=h,Y={},I={ast:r,input:q,out:Y,issues:void 0,options:x},le=x.errors==="all",ae=x.onExcessProperty==="error",N=x.concurrency===void 0?1:rd(x.concurrency),Z=o&&ae?r.indexSignatures.map((z)=>cS(q,z.parameter,x)):void 0;if(ae){let z=Z?new Set(g):g;if(Z)for(let ee of Z)for(let ie of ee)z.add(ie);let X=Vr(q);for(let ee=0;ee<X.length;ee++){let ie=X[ee];if(!z.has(ie)){let oe=new rS(r,q[ie],x),de=new ii([ie],oe);if(le){if(I.issues)I.issues.push(de);else I.issues=[de];continue}else return yield*fe(new Rr(r,[de],h,x))}}}if(n){let z=N===1?VR(I,i):Oj(I,i,{concurrency:N});if(z)yield*z}if(o&&N===1)for(let z=0;z<o;z++){let X=s[z],ee=X.is.parameter===Yi?A:k,ie=Z?.[z]??(X.is.parameter===Yi?Object.keys(q):cS(q,X.is.parameter,x));for(let oe=0;oe<ie.length;oe++){let de=ee(I,ie[oe],X);if(!ut(de))yield*de;else if(de._tag==="Failure")return yield*de}}else if(y){let z=Ns();for(let ee=0;ee<o;ee++){let ie=s[ee],oe=Z?.[ee]??(ie.is.parameter===Yi?Object.keys(q):cS(q,ie.is.parameter,x));for(let de=0;de<oe.length;de++)z.push([oe[de],ie])}let X=y(I,z,{concurrency:N});if(X)yield*X}if(I.issues)return yield*fe(new Rr(r,I.issues,h,x));return Y})};if(o)return l();let S,m=(g,w,k)=>{let A=i[w];return Ee(Ec(k),(y)=>{let h={...g,out:{...g.out}},x=uS(h,A,y);if(x)return x;let q=()=>kr(h.out),Y=VR(h,i.slice(w+1));return Y?zr(Y,q):q()})};return(g,w)=>{if(g===$e)return Un;if(w.errors==="all"||w.onExcessProperty!==void 0||w.concurrency!==void 0&&rd(w.concurrency)!==1)return(S??=l())(g,w);if(!(typeof g==="object"&&g!==null&&!Array.isArray(g)))return fe(new eo(r,g,w));let k=c(),A=g,y={},h={ast:r,input:A,out:y,issues:void 0,options:w};try{for(let x=0;x<k.length;x++){let q=k[x],Y=q.name,I=q.ownOnly?Object.hasOwn(A,Y):(Y in A),le=I?A[Y]:$e,ae=q.parser(le,w);if(!ut(ae))return m(h,x,ae);if(Yt(ae)){if(I)Jr(y,Y,le);continue}let N=uS(h,q,ae);if(N)return N}}catch(x){return Cr(x)}return kr(y)}}recur(e,t=e){let r=Dc(this.propertySignatures,(o)=>{let i=e(o.type);return i===o.type?o:new bS(o.name,i)}),n=Dc(this.indexSignatures,(o)=>{let i=t(o.parameter),s=e(o.type);return i===o.parameter&&s===o.type?o:new d0(i,s)});return r===this.propertySignatures&&n===this.indexSignatures?this:mn(this,{propertySignatures:r,indexSignatures:n,encoding:void 0})}flip(e){return dm(this.recur(e))}getExpected(){if(this.propertySignatures.length===0&&this.indexSignatures.length===0)return"object | array";return"object"}};function uS(e,t,r){if(r._tag==="Failure")return cm(e,e.ast,t.name,r);if(Yt(r))return;let n=r[De];if(n!==$e){Jr(e.out,t.name,n);return}if(delete e.out[t.name],!Po(t.type)){let o=new ii([t.name],new Ld(t.type.context?.annotations));if(e.options.errors==="all"){if(e.issues)e.issues.push(o);else e.issues=[o];return}else return Pn(new Rr(e.ast,[o],e.input,e.options))}}var u0={onItem(e,t){if(!(t.ownOnly?Object.hasOwn(e.input,t.name):(t.name in e.input)))return t.parser($e,e.options);let r=e.input[t.name];return Jr(e.out,t.name,r),t.parser(r,e.options)},step:uS},VR=uf()(u0),Oj=lf()(u0);function wS(e,t){if(!e)return t;if(!t)return e;return[...e,...t]}function fm(e,t,r){return new IS(Vr(e).map((n)=>new bS(n,e[n].ast)),[],r,t)}function mm(e){return e.ast}function hm(e,t,r){return new Zi(e.map(mm),t,void 0,r)}function l0(e,t){if(e.encoding||t.some((i)=>i.encoding))throw Error("StructWithRest does not support encodings");let{propertySignatures:r,indexSignatures:n,checks:o}=e;for(let i of t){for(let s of i.propertySignatures)if(r.some((c)=>c.name===s.name))throw Error(`Duplicate identifier: ${JSON.stringify(s.name)}. ts(2300)`);r=r.concat(i.propertySignatures),n=n.concat(i.indexSignatures),o=wS(o,i.checks)}return new IS(r,n,void 0,o)}var ES=bp((e)=>{while(!0){if(na(e))return zd;let t=e.encoding;if(!t)return e.recur?.(ES,Ie)??e;if(t.some((r)=>r.transformation._tag==="Middleware"&&r.transformation.decode!==Ie))return zd;e=t[t.length-1].to}});function f0(e){switch(e._tag){case"Null":return["null"];case"Undefined":return["undefined"];case"String":case"TemplateLiteral":return["string"];case"Number":return["number"];case"Boolean":return["boolean"];case"Symbol":case"UniqueSymbol":return["symbol"];case"BigInt":return["bigint"];case"Arrays":return["array"];case"ObjectKeyword":return["object","array","function"];case"Objects":return e.propertySignatures.length||e.indexSignatures.length?["object"]:["string","number","boolean","symbol","bigint","object","array","function"];case"Enum":return Array.from(new Set(e.enums.map(([,t])=>typeof t)));case"Literal":return[typeof e.literal];case"Union":return Array.from(new Set(e.types.flatMap(f0)));default:return["null","undefined","string","number","boolean","symbol","bigint","object","array","function"]}}function jd(e){switch(e._tag){default:return[];case"Declaration":{let t=e.annotations?.[Vf];return Array.isArray(t)?t:[]}case"Objects":return e.propertySignatures.flatMap((t)=>{let r=t.type;if(!Po(r)){if(Uc(r))return[{key:t.name,literal:r.literal}];if(pS(r))return[{key:t.name,literal:r.symbol}]}return[]});case"Arrays":return e.elements.flatMap((t,r)=>{if(!Po(t)){if(Uc(t))return[{key:r,literal:t.literal}];if(pS(t))return[{key:r,literal:t.symbol}]}return[]});case"Union":{if(e.types.length===0)return[];let t=e.types.map((r)=>jd(ES(r)));return t[0].filter((r)=>t.every((n)=>n.some((o)=>o.key===r.key&&o.literal===r.literal)))}case"Suspend":return jd(e.thunk())}}var JR=new WeakMap,sm=Object.freeze([]),YR=(e)=>e===null?"null":Array.isArray(e)?"array":typeof e,Pj=new Set(Reflect.ownKeys(Object.prototype)).add("__proto__"),m0=(e)=>Pj.has(typeof e==="number"?globalThis.String(e):e),am=(e,t)=>Object.hasOwn(e,t)||(t in e)&&!m0(t);function Rj(e){let t=JR.get(e);if(t)return t;let r,n=0,o,i,s=!0,c=[];for(let m=0;m<e.length;m++){let g=e[m],w=ES(g);if(gj(w))continue;if(Uc(w)||pS(w)){i??=new Map;let A=Uc(w)?w.literal:w.symbol;c[m]=A;let y=i.get(A);if(!y)i.set(A,y=[]);y.push(m)}else s=!1;let k=jd(w);if(k.length){r??=new Map,n++;for(let{key:A,literal:y}of k){let h=r.get(A);if(!h)r.set(A,h=[new Map,new Set]);h[1].add(m);let x=h[0].get(y);if(!x)h[0].set(y,x=new Set);x.add(m)}}else{o??={};let A=f0(w);for(let y of A)(o[y]??=[]).push(m)}}let l={},S=(m)=>l[m]??=Object.freeze(o?.[m]??sm);if(s&&i)i.forEach(Object.freeze),t=(m)=>i.get(m)??sm;else if(r?.size===1&&!o){let[m,[g]]=r.entries().next().value,w=new Map;for(let[A,y]of g)w.set(A,Object.freeze(Array.from(y)));let k=Object.freeze(e.map((A,y)=>y));t=(A,y)=>{if(Tp(A)){let h=am(A,m)?A[m]:void 0;if(h!==void 0)return w.get(h)??sm;if(y)return k}return sm}}else if(r){let m;for(let g of r)if((!m||g[1][0].size>m[1][0].size)&&g[1][1].size===n)m=g;t=(g,w)=>{let k=YR(g);if(!Tp(g))return S(k);let A=new Set(o?.[k]),y;if(m){let[h,[x]]=m,q=am(g,h),Y=q?g[h]:void 0;if(q&&(!w||Y!==void 0)){let I=x.get(Y);if(!I)return S(k);for(let le of I)A.add(le);y=h}}if(y===void 0)for(let[h,[x,q]]of r){let Y=am(g,h),I=Y?g[h]:void 0;if(Y&&(!w||I!==void 0)){let le=x.get(I);if(le)for(let ae of le)A.add(ae)}else if(w)for(let le of q)A.add(le)}for(let[h,[x,q]]of r){if(h===y)continue;let Y=am(g,h),I=Y?g[h]:void 0;if(Y&&(!w||I!==void 0)){let le=x.get(I);for(let ae of A)if(q.has(ae)&&!le?.has(ae))A.delete(ae)}}return Array.from(A).sort((h,x)=>h-x)}}else t=(m)=>{let g=S(YR(m));return i?g.filter((w)=>c[w]===void 0||c[w]===m):g};return JR.set(e,t),t}var Zi=class extends Ln{_tag="Union";types;options;encodingChecks;constructor(e,t,r,n,o,i,s){super(r,n,o,i);this.types=e,this.options=t,this.encodingChecks=s}getParser(e,t){let r=this,n=t!==void 0,o=[],i=(c)=>o[c]??=e(r.types[c]),s;return(c,l)=>{if(c===$e)return Un;let S=(s??=Rj(r.types))(c,n);if(S.length===0)return fe(new Md(r,[],c,l));if(S.length===1){let m=i(S[0])(c,l);if(m._tag==="Success")return m;return ut(m)?h0(r,m.cause,c,l):_j(r,m,c,l)}return y0(r,i,S,c,l)}}recur(e){let t=Dc(this.types,e);return t===this.types?this:mn(this,{types:t,encoding:void 0})}flip(e){return dm(this.recur(e))}matchPart(e,t){for(let r of this.types){let n=r.matchPart(e,t);if(n!==void 0)return n}return}getExpected(e){let t=this.annotations?.expected;if(typeof t==="string")return t;if(this.types.length===0)return"never";let r=this.types.map((n)=>{let o=pi(n);switch(o._tag){case"Arrays":{let i=o.elements.filter(Uc);if(i.length>0)return`${XR(o.isMutable)}[ ${i.map((s)=>e(s)+e0(s.context?.isOptional)).join(", ")}, ... ]`;break}case"Objects":{let i=o.propertySignatures.filter((s)=>Uc(s.type));if(i.length>0)return`{ ${i.map((s)=>`${XR(s.type.context?.isMutable)}${ja(s.name)}${e0(s.type.context?.isOptional)}: ${e(s.type)}`).join(", ")}, ... }`;break}}return e(o)});return Array.from(new Set(r)).join(" | ")}};function h0(e,t,r,n){let o=Fd(t);if(!o)return $i(t);return Pn(new Md(e,[o],r,n))}function _j(e,t,r,n){return Gr(t,(o)=>h0(e,o,r,n))}function y0(e,t,r,n,o){let i={ast:e,parser:t,input:n,out:void 0,successes:e.options?.mode==="oneOf"?[]:void 0,issues:void 0,options:o},s=Uj(i,r);if(!s){if(i.out)return i.out;return fe(new Md(e,i.issues??[],n,o))}if(ut(s))return ZR(s,i);let c=!0;return Qe(()=>{if(!c)return y0(e,t,r,n,o);return c=!1,ZR(s,i)})}function ZR(e,t){return zr(e,(r)=>{if(t.out)return Yt(t.out)?W(t.input):t.out;return fe(new Md(t.ast,t.issues??[],t.input,t.options))})}var Uj=uf()({onItem(e,t){return e.parser(t)(e.input,e.options)},step(e,t,r){if(r._tag==="Failure"){let n=Fd(r.cause);if(n===void 0)return r;if(e.issues)e.issues.push(n);else e.issues=[n]}else{if(e.out&&e.successes)return e.successes.push(e.ast.types[t]),Pn(new xR(e.ast,e.successes,e.input,e.options));if(e.out=r,e.successes)e.successes.push(e.ast.types[t]);else return Hn}}}),g0=new Zi([new Oo("Infinity"),new Oo("-Infinity"),new Oo("NaN")]);function XR(e){return e?"":"readonly "}function e0(e){return e?"?":""}function Dj(e){let t;return()=>t??=e()}var lS=class extends Ba{_tag="Filter";run;annotations;aborted;constructor(e,t=void 0,r=!1){super();this.run=e,this.annotations=t,this.aborted=r}annotate(e){return new lS(this.run,{...this.annotations,...e},this.aborted)}abort(){return new lS(this.run,this.annotations,!0)}and(e,t){return new pm([this,e],t)}},pm=class extends Ba{_tag="FilterGroup";checks;annotations;constructor(e,t=void 0){super();this.checks=e,this.annotations=t}annotate(e){return new pm(this.checks,{...this.annotations,...e})}and(e,t){return new pm([this,e],t)}};function ym(e,t,r=!1){return new lS((n,o,i)=>bR(o,e(n,o,i),n,i),t,r)}function x0(e){return ym((t)=>globalThis.Number.isFinite(t),{expected:"a finite number",representation:{id:"effect/schema/isFinite",payload:null},toJsonSchema:()=>({type:"number"}),arbitraryConstraint:{number:"finite"},...e})}var S0=ia(SS,[x0()]),Lj=new Ur(new Zi([S0,g0]),new ir(rm(),Lt((e)=>globalThis.Number.isFinite(e)?e:globalThis.String(e))));function kS(e,t){let r=new globalThis.RegExp(e),n={source:r.source,flags:r.flags};return ym((o)=>(r.lastIndex=0,r.test(o)),{expected:`a string matching the RegExp ${n.source}`,representation:{id:"effect/schema/isPattern",payload:n},toJsonSchema:()=>[{},!0],arbitraryConstraint:{patterns:[n]},...t})}var fS=new WeakMap;function mn(e,t){return Object.assign(Object.create(Object.getPrototypeOf(e)),e,t)}function b0(e,t){let r=mn(e,t);return fS.set(r,Hd(e)),r}function Hd(e){let t=fS.get(e);if(t!==void 0)return t;if(e.encoding===void 0)return e;let r=mn(e,{encoding:void 0});return fS.set(e,r),r}function _r(e,t){return e.encoding===t?e:b0(e,{encoding:t})}function Lc(e,t){if(e.context===t)return e;let r=Hd(e);if(r.context===t&&r.encoding===e.encoding)return r;return b0(e,{context:t})}function AS(e){return e.encoding?AS(e.encoding[e.encoding.length-1].to):e}function gm(e,t){if(e.checks)return vS(e,I0(e.checks,(r)=>r.annotate(t)));return mn(e,{annotations:{...e.annotations,...t}})}function vS(e,t){if(e._tag==="Suspend"&&t)throw Error("Cannot add checks to Suspend");if(e.checks===t)return e;return mn(e,{checks:t})}function ia(e,t){return vS(e,wS(e.checks,t))}function xm(e,t){let r=t(e.to);return r===e.to?e:new Ur(r,e.transformation)}function I0(e,t){let r=e[e.length-1],n=t(r);if(r===n)return e;let o=[...e];return o[o.length-1]=n,o}function w0(e,t){return I0(e,(r)=>xm(r,t))}function E0(e){return(t)=>t.encoding?_r(t,w0(t.encoding,e)):t}function k0(e,t){return E0((r)=>Lc(r,t))(e)}function Sm(e,t){function r(n){if(n.encoding){let o=n.encoding[n.encoding.length-1];return t?.stopAt?.(o)?n:_r(n,w0(n.encoding,r))}return e(n)}return bp(r)}function A0(e,t){return v0(e,t,ci(e))}function v0(e,t,r){let n=new Ur(e,t);return _r(r,r.encoding?[...r.encoding,n]:[n])}function Dc(e,t){let r;for(let n=0;n<e.length;n++){let o=e[n],i=t(o);if(r)r[n]=i;else if(i!==o){r=Array(e.length);for(let s=0;s<n;s++)r[s]=e[s];r[n]=i}}return r??e}function CS(e,t=Po(e),r=Nj(e),n=e.context?.constructorDefault,o=e.context?.annotations){return Lc(e,new gS(t,r,n,o))}function Mj(e){let t=e==="isOptional"?!0:void 0,r=e==="isMutable"?!0:void 0,n=bp((i)=>o(i.context?.[e]?i:CS(i,t,r))),o=E0(n);return n}function bm(e,t){return CS(e,void 0,void 0,void 0,e.context?{...e.context.annotations,...t}:t)}var Im=Mj("isOptional"),C0=Ti((e)=>Im(new Zi([e,xS])));function T0(e,t){return CS(e,void 0,void 0,t)}function TS(e,t,r){return v0(e,r,t)}function Fj(e){let t=[],r=[];function n(i){if(!t.includes(i))t.push(i)}function o(i){switch(i._tag){case"Literal":if(Uy(i.literal))n(i.literal);return;case"UniqueSymbol":n(i.symbol);return;case"Enum":for(let[,s]of i.enums)n(s);return;case"Never":return;case"Union":for(let s=0;s<i.types.length;s++)o(i.types[s]);return;default:r.push(i)}}return o(e),{literals:t,parameters:r}}function OS(e,t){let{literals:r,parameters:n}=Fj(e);return new IS(r.map((o)=>new bS(o,t)),n.map((o)=>new d0(o,t)))}function Po(e){return e.context?.isOptional??!1}function Nj(e){return e.context?.isMutable??!1}function PS(e){return e.annotations?.[Td]===!0||e._tag==="FilterGroup"&&e.checks.every(PS)}function Bj(e){function t(n){if(PS(n))return[n];return n._tag==="FilterGroup"?n.checks.flatMap(t):[]}let r=e.flatMap(t);return Fl(r)?r:void 0}function O0(e,t,r){let n=new Set([e]);for(let i of n){if(r?.has(i))continue;if(!t(i))return!1;if(!na(i)&&"recur"in i)i.recur(o)}if(r)for(let i of n)r.add(i);return!0;function o(i){return n.add(i),i}}var Kj=new WeakSet;function P0(e,t){let r=n0(e)||o0(e)||yS(e)&&e.typeParameters.length>0;if(r&&t.every(PS)||O0(e,(n)=>!n.encoding&&!na(n),Kj))return t;if(r)return Bj(t)}function R0(e){return yS(e)&&e.encodingRun!==void 0&&e.encodingRun!==e.run}function $j(e,t){function r(n){if(na(n))return n.thunk===t;return!R0(n)&&!(("encodingChecks"in n)&&n.checks&&P0(n,n.checks)!==n.checks)}return O0(e,r)}var Gd=new WeakMap,_c=new WeakMap,t0=new WeakSet,r0=new WeakSet,Vd=new WeakMap,mS=new WeakMap,ci=(e)=>Vd.has(e)?qj(e):ta(e),qj=Ti((e)=>{let t=Vd.get(e);if(t&&t0.has(t))return t;let r=ta(e);if(t)t0.add(r);return r});function ta(e){let t=Gd.get(e);if(t)return t;let r=Vd.get(e),n=r&&Gd.get(r)===r,o=r&&_c.get(r)||Wj(e);if(n)_c.set(r,o);if(Gd.set(e,o),o!==e)Gd.set(o,o);return o}function _0(e,t){let r=Hd(e);if(r!==e){let n=t(r);return n===r&&!e.encoding?e:Lc(n,e.context)}}function Wj(e){let t=_0(e,ta);if(t)return t;if(na(e))return mS.get(e.thunk)?.project(e)??e.recur(ta);let r="recur"in e?e.recur(ta):e;if("encodingChecks"in r&&r.encodingChecks)return mn(r,{encodingChecks:void 0,checks:wS(P0(e,r.encodingChecks),r.checks)});return r===e&&R0(r)&&Vd.has(e)?mn(r,{}):r}var pi=(e)=>ci(fn(e));function Gj(e,t){let r=_r(e,void 0),n=t.map((i)=>{let s=new Ur(fn(r),i.transformation.flip());return r=i.to,s}).reverse(),o=fn(r);return _r(o,o.encoding?[...o.encoding,...n]:n)}var fn=Ti((e)=>{let t=zj(e);if(t!==e)Vd.set(t,e);return t});function zj(e){if(e.encoding)return Gj(e,e.encoding);let t=_0(e,fn);if(t)return t;if(na(e)){let r=mS.get(e.thunk);if(r)return mn(e,{thunk:r.source.thunk});let n=e.recur(fn);return mS.set(n.thunk,{source:e,project(o){let i=Dj(()=>jj(e.thunk(),i));return mn(o,{thunk:i})}}),n}return"flip"in e?e.flip(fn):e}function jj(e,t){if(Gd.get(e)!==e)return ta(fn(e));let r=_c.get(e);if(r)return r;if($j(e,t))return _c.set(e,e),e;let n=ta(fn(e));if(r0.has(e)&&!_c.has(n))_c.set(n,e);return r0.add(n),n}function RS(e,t){let r=t===0?oi:kr(t);return(n,o)=>{if(n===$e)return Un;if(n===t)return r;return fe(new eo(e,n,o))}}function Jd(e,t){return(r,n)=>{if(r===$e)return Un;if(t(r))return oi;return fe(new eo(e,r,n))}}var _S=Sm((e)=>{switch(e._tag){default:return e;case"Number":return e.toCodecStringTree();case"Union":return e.recur(_S)}}),US=Sm((e)=>{switch(e._tag){default:return e;case"Symbol":case"UniqueSymbol":return e.toCodecStringTree();case"Union":return e.recur(US)}});var hS=new globalThis.RegExp(`^${a0}$`),Qj=new globalThis.RegExp(`^(?:${a0}|Infinity|-Infinity|NaN)$`);function U0(e){return kS(hS,{expected:"a string representing a finite number",representation:{id:"effect/schema/isStringFinite",payload:null},toJsonSchema:()=>({pattern:hS.source}),...e})}var D0=ia(Yi,[U0()]),Hj=new Ur(D0,qd),Vj=new Ur(new Zi([D0,g0]),qd),Jj="-?\\d+",Hie=new globalThis.RegExp(`^${Jj}$`);var Yj="Symbol\\(([\\s\\S]*)\\)",Vie=new globalThis.RegExp(`^${Yj}$`);function Xi(e,t,r,n,o){for(let i=0;i<e.length;i++){let s=e[i];if(s._tag==="FilterGroup"){if(r=Xi(s.checks,t,r,n,o),r&&(o.errors!=="all"||r[r.length-1].filter.aborted))return r}else{let c=s.run(t,n,o);if(c){let l=new yR(s,c,t,o);if(r)r.push(l);else r=[l];if(o.errors!=="all"||s.aborted)return r}}}return r}function wm(e){if(!yS(e))return;let t=e.annotations?.[Jf];return yo(t)?t(e.typeParameters):void 0}function Zj(e){return e===null||typeof e==="string"||typeof e==="boolean"||typeof e==="number"&&globalThis.Number.isFinite(e)}function Xj(e){return e===void 0||typeof e==="string"}function L0(e,t){let r=new WeakMap,n=[];e:while(!0){if(typeof e!=="object"||e===null){if(!t(e))return!1}else{let o=e,i=r.get(o);if(i===!1)return!1;if(i===void 0){let s=Array.isArray(o);if(!s){let c=Object.getPrototypeOf(o);if(c!==null&&c!==Object.prototype&&Object.getPrototypeOf(c)!==null)return!1}r.set(o,!1),n.push({value:o,keys:s?o.length:Object.keys(o),index:0})}}while(n.length>0){let o=n[n.length-1],i=o.keys;if(typeof i==="number"){if(o.index<i){e=o.value[o.index++];continue e}}else if(o.index<i.length){e=o.value[i[o.index++]];continue e}r.set(o.value,!0),n.pop()}return!0}}function eQ(e){return L0(e,Zj)}var M0=new Qd([],()=>(e,t,r)=>eQ(e)?oi:fe(new eo(t,e,r)),{representation:{id:"effect/schema/Json",payload:null},expected:"JSON value",toCodecJson:()=>{return},toCodecStringTree:()=>DS});function tQ(e){return L0(e,Xj)}var rQ=new Qd([],()=>(e,t,r)=>tQ(e)?oi:fe(new eo(t,e,r)),{expected:"StringTree",toCodecStringTree:()=>{return}}),DS=new Ur(rQ,im());function LS(){return Object.assign((e)=>e,{option:(e)=>Re(e),result:(e)=>Jt(e),is:(e)=>!0})}var B0=LS(),K0=LS(),N0="~effect/process/ChildProcessSpawner/ChildProcessHandle",nQ={[N0]:N0,...Pi,toJSON(){return{_id:"ChildProcessHandle",pid:this.pid}}},MS=(e)=>Object.setPrototypeOf({...e},nQ),$0=(e)=>{let t=(n,o)=>e(n).pipe(_e((i)=>aR(o?.includeStderr===!0?i.all:oR(i.stdout,i.stderr))),Co),r=(n,o)=>cR(t(n,o));return Fc.of({spawn:e,exitCode:(n)=>js(Ee(e(n),(o)=>Rn(o.exitCode,Jn(Vx(o.all),fd)))),streamString:t,streamLines:r,lines:(n,o)=>dR(r(n,o)),string:(n,o)=>uR(t(n,o))})};class Fc extends Vt()("effect/process/ChildProcessSpawner"){}var sa=new WeakMap,q0=(e)=>{if(sa.has(e))return sa.get(e);else throw Error("Unable to get redacted value"+(e.label?` with label: "${e.label}"`:""))};var W0="~effect/Redacted",to=(e)=>je(e,W0),aa=(e,t)=>{let r=Object.create(iQ);if(t?.label)r.label=t.label;return sa.set(r,e),r},iQ={[W0]:{_A:(e)=>e},label:void 0,...Br,toJSON(){return this.toString()},toString(){return`<redacted${qo(this.label)?":"+this.label:""}>`},[wt](){return Ge(sa.get(this))},[Et](e){return to(e)&&tr(sa.get(this),sa.get(e))}},Nc=q0;class ca extends Ho("CommandLineError"){}var z0=(e,t)=>{if(e.length===0)return"";let r=t?.format??"posix";return pQ(r,e.map((n,o)=>to(n)?"<redacted>":xQ(cQ(r,n,o===0))))},j0=(e,...t)=>{let r=e.findIndex((n)=>n===void 0);if(r!==-1)return Dt(new ca({reason:"InvalidEscape",message:`Template part ${r} contains an invalid escape sequence`}));return AQ(e,t)},sQ=(e)=>to(e)?Nc(e):String(e),G0=(e)=>to(e)?e:String(e);var aQ=new Set(["!","{","}","and","begin","case","coproc","do","done","elif","else","end","esac","fi","for","foreach","function","if","in","nocorrect","not","or","repeat","select","switch","then","time","until","while"]),cQ=(e,t,r)=>{switch(e){case"posix":return r&&aQ.has(t)?`'${t}'`:uQ(t);case"powershell":return lQ(t);case"windows":return r&&!t.includes('"')?hQ(t):mQ(t)}},pQ=(e,t)=>e==="powershell"?`& ${t.join(" ")}`:t.join(" "),dQ=/^[A-Za-z0-9_@+:,./-]+$/,uQ=(e)=>dQ.test(e)?e:`'${e.replace(/['\\]/g,(t)=>`'\\${t}'`)}'`,lQ=(e)=>`'${e.replace(/['\u2018\u2019\u201A\u201B]/g,"$&$&")}'`,fQ=/[ \t\n\v"]/,mQ=(e)=>{if(e.length>0&&!fQ.test(e))return e;let t='"',r=0;for(let n of e)if(n==="\\")r++;else if(n==='"')t+="\\".repeat(r*2+1)+'"',r=0;else t+="\\".repeat(r)+n,r=0;return t+"\\".repeat(r*2)+'"'},hQ=(e)=>e.length>0&&!/[ \t]/.test(e)?e:`"${e}"`,yQ=/[\u0000-\u001f\u007f-\u009f\u2028\u2029]/g,gQ={"\n":"\\n","\r":"\\r","\t":"\\t"},xQ=(e)=>e.replace(yQ,(t)=>gQ[t]??`\\u${t.charCodeAt(0).toString(16).padStart(4,"0")}`),SQ="|&;<>()",bQ="*?[",IQ=/[A-Za-z_0-9{(@*#?$!'"-]/,wQ=/[A-Za-z_0-9{(@*#?$!-]/,EQ=/^[A-Za-z_][A-Za-z0-9_]*\+?$/,FS=(e)=>e===" "||e==="\t"||e===`
33
33
  `,kQ=(e,t,r)=>{if(SQ.includes(e))return`The operator "${e}" needs a shell`;if(e==="`")return"Command substitution needs a shell";if(e==="$"&&t!==void 0&&IQ.test(t))return`The expansion "$${t}" needs a shell`;if(bQ.includes(e))return`The glob character "${e}" needs a shell`;if(!r)return;if(e==="#")return"A comment needs a shell";if(e==="~")return"Tilde expansion needs a shell";if(e==="="&&t!==void 0&&!FS(t))return'A leading "=" is expanded by zsh';return},AQ=(e,t)=>{let r=[],n=[],o=!0,i=0,s=void 0,c=0,l=0,S=(w,k,A=l)=>Dt(new ca({reason:w,message:`${k} in template part ${A}`})),m=()=>{if(n.length===0)return;let w=n.map(sQ).join("");r.push(n.length===1&&to(n[0])?n[0]:n.some(to)?aa(w):w),n=[],o=!0,i=0},g=(w)=>{for(let k=0;k<w.length;k++){let A=w[k],y=w[k+1];if(s==="'")if(A==="'")s=void 0;else n.push(A);else if(s==='"')if(A==='"')s=void 0;else if(A==="\\"&&y!==void 0&&'$`"\\\n'.includes(y)){if(y!==`
34
34
  `)n.push(y);k++}else if(A==="`")return S("UnsupportedSyntax","Command substitution needs a shell");else if(A==="$"&&y!==void 0&&wQ.test(y))return S("UnsupportedSyntax",`The expansion "$${y}" needs a shell`);else n.push(A);else if(FS(A))m();else if(A==="\\"){if(y===void 0)return S("InvalidEscape","A trailing backslash escapes nothing");if(y!==`
35
- `)n.push(y),o=!1;k++}else if(A==="'"||A==='"')s=A,c=l,n.push(""),o=!1;else{let h=kQ(A,y,n.length===0);if(h!==void 0)return S("UnsupportedSyntax",h);if(A==="{")i++;else if(A==="}"){if(i>0)i--}else if(i>0&&(A===","||A==="."&&y==="."))return S("UnsupportedSyntax","Brace expansion needs a shell");else if(A==="="&&r.length===0&&o&&EQ.test(n.join("")))return S("UnsupportedSyntax","A variable assignment needs a shell");n.push(A)}}return};for(;l<e.length;l++){let w=g(e[l]);if(w!==void 0)return w;if(l===t.length)break;let k=t[l];if(Array.isArray(k)){let A=e[l+1][0];if(n.length>0||(A===void 0?l+1<t.length:!FS(A)))return S("UnsupportedSyntax","An interpolated array must be a separate argument");for(let y of k)r.push(G0(y))}else n.push(G0(k)),o=!1}if(s!==void 0)return S("UnterminatedQuote","The quote is not closed",c);return m(),Jt(r)};var H0="~effect/process/ChildProcess",vQ={...Ri({label:"Command",evaluate(e){return $p(e.context,Fc).spawn(this)}}),[H0]:H0};var Yd=(e,t,r)=>Object.assign(Object.create(vQ),{_tag:"StandardCommand",command:e,args:t,options:r});var Em=function(...t){if(V0(t[0])){let[i,...s]=t,[c,l]=J0(i,s);return Yd(c,l,{})}if(typeof t[0]==="object"&&!Array.isArray(t[0])&&!V0(t[0])){let i=t[0];return function(s,...c){if(i.shell!==void 0&&i.shell!==!1)return Yd(CQ(s,c),[],i);let[l,S]=J0(s,c);return Yd(l,S,i)}}if(typeof t[0]==="string"&&!Array.isArray(t[1])){let[i,s={}]=t;return Yd(i,[],s)}let[r,n=[],o={}]=t;return Yd(r,n,o)};var V0=(e)=>Array.isArray(e)&&("raw"in e)&&Array.isArray(e.raw),km=(e)=>{let t=/^fd(\d+)$/.exec(e);if(t===null)return;let r=parseInt(t[1],10);return r>=3?r:void 0},Y0=(e)=>`fd${e}`,J0=(e,t)=>{let[r="",...n]=lg(j0(e,...t));if(typeof r!=="string")throw new ca({reason:"InvalidArgument",message:"The program name of a command cannot be Redacted"});return[r,n]},CQ=(e,t)=>{if(t.length>0)throw new ca({reason:"UnsupportedSyntax",message:"A shell template cannot interpolate values; build the script with CommandLine.quote"});let r=e[0];if(r===void 0)throw new ca({reason:"InvalidEscape",message:"Template part 0 contains an invalid escape sequence"});return r};import*as Tm from"child_process";import{PassThrough as NS}from"stream";var Z0=(e,t,r)=>{let n=e.detached??r!=="win32";return{...t,detached:n,shell:e.shell,windowsHide:e.windowsHide??!n}};var st=(e,t)=>(r,[n])=>{let o="Unknown";switch(r.code){case"ENOENT":o="NotFound";break;case"EACCES":case"EPERM":o="PermissionDenied";break;case"EEXIST":o="AlreadyExists";break;case"EISDIR":o="BadResource";break;case"ENOTDIR":o="BadResource";break;case"EBUSY":o="Busy";break;case"ELOOP":o="BadResource";break}return Yn({_tag:o,module:e,method:t,pathOrDescriptor:n,syscall:r.syscall,cause:r})};import{finished as X0}from"stream";var Am=(e,t,r)=>{if(!("closed"in e)){t(),r?.();return}let n=()=>{clearImmediate(i),e.off("error",n),e.off("close",n),r?.()},o=()=>{if(e.closed)n();else if(i=setImmediate(o),!r)i.unref()},i=setImmediate(o);if(!r)i.unref();if(e.once("error",n),e.once("close",n),t(),!e.closed)e.destroy()};var Kc=(e)=>Gx(Bx(OQ(e),(t)=>[t])),OQ=(e)=>Er((t)=>{let r=e.evaluate(),n=RQ({...e,writable:r,pull:t});return W(e.endOnDone===!1?n:ri(n,(o)=>ei(o)?He:PQ(r)))}),PQ=(e)=>tn((t)=>{let r=()=>t(He);if(e.closed){let n=X0(e,{readable:!1},()=>{n(),r()})}else Am(e,Ko,r)}),RQ=(e)=>wc((t)=>{let r=t.currentDispatcher,n=bo(),o=bo(),i=(S)=>Qn(o,Ef(()=>e.onError(S))),s=!1,c=(S)=>{s=!0,i(S)};e.writable.on("error",c);let l=X0(e.writable,{readable:!1},(S)=>{if(S)i(S);else Qn(n,He)});return e.pull.pipe(Ee((S)=>{let m=0;return tn((g)=>{let w=!1,k=()=>r.scheduleTask(A,0),A=()=>{e.writable.off("drain",A),e.writable.off("finish",k);for(;m<S.length;){if(w)return;if(!e.writable.write(S[m++],e.encoding,(h)=>{if(!h)return;if(e.writable.closed)i(h);else r.scheduleTask(()=>i(h),0)})){if(!w)e.writable.once("drain",A),e.writable.once("finish",k);return}}if(!w)g(He)};return A(),Fe(()=>{w=!0,e.writable.off("drain",A),e.writable.off("finish",k)})})}),ko({disableYield:!0}),e.endOnDone!==!1?Vn((S)=>(e.writable.end(),Jn(Wr(n),fr(S)))):Ie,Rn(Wr(o)),Eo(Fe(()=>{l();let S=()=>{e.writable.off("error",c),e.writable.off("error",S),e.writable.off("close",S)};if(e.writable.errored&&!e.writable.closed&&!s)e.writable.once("error",S),e.writable.once("close",S);else S()})))});import{finished as UQ,Readable as Cse}from"stream";var $c=(e)=>rn(DQ(e)),DQ=(e)=>Er((t,r)=>LQ({scope:r,readable:e.evaluate(),onError:e.onError??MQ,chunkSize:e.chunkSize,readSize:e.readSize,closeOnDone:e.closeOnDone}));var LQ=(e)=>{let t=e.readable,r=e.chunkSize??4096,n=e.closeOnDone??!0,o=e.exit??sP(void 0),i=e.latch??nP(!1);function s(){i.openUnsafe()}t.on("readable",s);let c=UQ(t,{readable:!0,writable:!1},(S)=>{o.current??=Pn(S?e.onError(S):dd()),i.openUnsafe()}),l=Qe(function S(){let m=e.readable.read(e.readSize);if(m===null){if(o.current)return o.current;if(t.readableEnded)return fe(dd());return i.closeUnsafe(),Ee(i.await,S)}let g=Ui(m);while(g.length<r){if(m=e.readable.read(e.readSize),m===null)break;g.push(m)}return W(g)});return or(sd(e.scope,Fe(()=>{if(t.off("readable",s),n)Am(t,c);else c()})),l)};var MQ=(e)=>new fO(e);var pa=(e)=>e instanceof globalThis.Error?e:new globalThis.Error(String(e)),ro=(e,t,r)=>{let{commands:n}=$S(r),o=globalThis.process.platform==="win32"?"windows":"posix",i=n.map((s)=>z0([s.command,...s.args],{format:o})).join(" | ");return st("ChildProcess",e)(t,[i])},Cm=(e)=>to(e)?Nc(e):e,NQ=(e)=>{if(e.command.includes("\x00"))return"The command contains a NUL character";let t=e.args.findIndex((r)=>Cm(r).includes("\x00"));if(t!==-1)return`Argument ${t+1} contains a NUL character`;for(let[r,n]of Object.entries(e.options.env??{}))if(n!==void 0&&Cm(n).includes("\x00"))return`The environment variable ${r} contains a NUL character`;return},e_=1000,BQ=10,t_=(e)=>{let t=()=>{};e.on("error",t),e.once("close",()=>e.off("error",t))},BS=(e)=>e.exitCode!==null||e.signalCode!==null,vm=(e)=>globalThis.process.platform!=="win32"&&e.options.detached!==!1,n_=(e)=>e?.code==="EPERM",r_=(e,t)=>{if(t.lost===!0)return!1;if(!BS(t))return!0;if(!vm(e))return!1;try{return globalThis.process.kill(-t.pid,0),!0}catch(r){return n_(r)}},KQ=(e,t=()=>{})=>{if(BS(e)){t(null);return}Tm.execFile("taskkill",["/pid",String(e.pid),"/T","/F"],{windowsHide:!0},t)},$Q=(e,t,r,n)=>{let o=Tm.spawn(e,t,r);for(let i of n){let s=o.stdio[i];if(s&&"allowHalfOpen"in s)s.allowHalfOpen=!0}return o},qQ=Se(function*(e){let t=yield*Cd,r=yield*Zs,n=Se(function*(N){if(Ga(N.cwd))return;return yield*t.access(N.cwd),r.resolve(N.cwd)}),o=(N)=>{if(N.env===void 0)return;let Z=N.extendEnv===!0?{...globalThis.process.env}:{};for(let[z,X]of Object.entries(N.env))if(X===void 0)delete Z[z];else Z[z]=Cm(X);return Z},i=(N)=>Js(N)?"pipe":N,s=(N)=>kd(N)?"pipe":N,c=(N)=>{let Z={stream:"pipe",encoding:"utf-8",endOnDone:!0};if(Ga(N.stdin))return Z;if(typeof N.stdin==="string")return{...Z,stream:N.stdin};if(Js(N.stdin))return{...Z,stream:N.stdin};return{stream:N.stdin.stream,encoding:N.stdin.encoding??Z.encoding,endOnDone:N.stdin.endOnDone??Z.endOnDone}},l=(N,Z)=>{let z=N[Z];if(Ga(z))return{stream:"pipe"};if(typeof z==="string")return{stream:z};if(kd(z))return{stream:z};return{stream:z.stream}},S=(N)=>{if(Ga(N.additionalFds))return[];let Z=[];for(let[z,X]of Object.entries(N.additionalFds)){let ee=km(z);if(Qt(ee))Z.push({fd:ee,config:X})}return Z.sort((z,X)=>z.fd-X.fd)},m=(N,Z,z,X)=>{let ee=[i(N.stream),s(Z.stream),s(z.stream)];if(X.length===0)return ee;let ie=X.reduce((oe,{fd:de})=>Math.max(oe,de),2);for(let oe=3;oe<=ie;oe++)ee[oe]="ignore";for(let{fd:oe}of X)ee[oe]="pipe";return ee},g=(N,Z,z)=>Pf(pR(sR(N,(X)=>eO(z,X)),Z)),w=Se(function*(N,Z,z,X){if(z.length===0)return{getInputFd:()=>Ad,getOutputFd:()=>Oc};let ee=new Map,ie=new Map,oe=(ge,ke,me)=>Qe(()=>{let Ke=Ad;if(ke&&"write"in ke)t_(ke),Ke=Kc({evaluate:()=>ke,onError:(Pe)=>ro(`fromWritable(fd${ge})`,pa(Pe),N)});if(me)return _e(g(me,Ke,X),()=>{ee.set(ge,Ke)});return ee.set(ge,Ke),He}),de=(ge,ke,me)=>{let Ke=Oc;if(ke&&"read"in ke){let Pe=new NS,er=void 0;Pe.on("error",(Mr)=>{er??=Mr}),ke.on("error",(Mr)=>Pe.destroy(Mr)),ke.pipe(Pe);let dr=(Mr)=>ro(`fromReadable(fd${ge})`,pa(Mr),N);Ke=nR(()=>er===void 0?$c({evaluate:()=>Pe,onError:dr}):Hx(dr(er)))}if(me)Ke=zf(Ke,me);ie.set(ge,Ke)};for(let{config:ge,fd:ke}of z){let me=Z.stdio[ke];switch(ge.type){case"input":{yield*oe(ke,me,ge.stream);break}case"output":{de(ke,me,ge.sink);break}case"duplex":{de(ke,me,ge.sink),yield*oe(ke,me,ge.stream);break}}}return{getInputFd:(ge)=>ee.get(ge)??Ad,getOutputFd:(ge)=>ie.get(ge)??Oc}}),k=(N,Z,z,X)=>Qe(()=>{let ee=Ad;if(gl(Z.stdin))t_(Z.stdin),ee=Kc({evaluate:()=>Z.stdin,onError:(ie)=>ro("fromWritable(stdin)",pa(ie),N),endOnDone:z.endOnDone,encoding:z.encoding});if(Js(z.stream))return or(g(z.stream,ee,X),ee);return W(ee)}),A=(N,Z,z,X)=>{let ee=Z.stdout?(()=>{let de=new NS;return Z.stdout.on("error",(ge)=>de.destroy(ge)),Z.stdout.pipe(de),$c({evaluate:()=>de,onError:(ge)=>ro("fromReadable(stdout)",pa(ge),N)})})():Oc,ie=Z.stderr?(()=>{let de=new NS;return Z.stderr.on("error",(ge)=>de.destroy(ge)),Z.stderr.pipe(de),$c({evaluate:()=>de,onError:(ge)=>ro("fromReadable(stderr)",pa(ge),N)})})():Oc;if(kd(z.stream))ee=zf(ee,z.stream);if(kd(X.stream))ie=zf(ie,X.stream);let oe=iR(ee,ie);return{stdout:ee,stderr:ie,all:oe}},y=(N,Z,z,X)=>tn((ee)=>{let ie=bo(),oe=N(Z.command,Z.args.map(Cm),z,X);return oe.on("error",(de)=>{if(Z.args.some(to))Object.assign(de,{spawnargs:[Z.command,...Z.args.map((ge)=>to(ge)?"<redacted>":ge)]});ee(fe(ro("spawn",de,Z)))}),oe.on("exit",(...de)=>{Qn(ie,qs(de))}),oe.on("lost",(de)=>{Qn(ie,Pn(ro("exitCode",de,Z)))}),oe.on("spawn",()=>{ee(W([oe,ie]))}),Fe(()=>{oe.kill("SIGTERM")})}),h=(N,Z,z)=>{if(globalThis.process.platform==="win32")return tn((X)=>{KQ(Z,(ee)=>{if(ee)X(fe(ro("kill",pa(ee),N)));else X(He)})});return Tr({try:()=>{globalThis.process.kill(-Z.pid,z)},catch:(X)=>ro("kill",pa(X),N)})},x=(N,Z)=>{try{globalThis.process.kill(-N.pid,Z)}catch{}},q=(N,Z,z)=>Qe(()=>{if(!Z.kill(z)){let ee=new globalThis.Error("Failed to kill child process");return fe(ro("kill",ee,N))}return He}),Y=(N,Z,z)=>tn((X)=>{let ee=Date.now()+z,ie,oe=()=>{clearTimeout(ie),Z.removeListener("exit",de),Z.removeListener("lost",de)},de=()=>{if(clearTimeout(ie),Date.now()>=ee||!r_(N,Z)){oe(),X(He);return}ie=setTimeout(de,BQ)};return Z.on("exit",de),Z.on("lost",de),de(),Fe(oe)}),I=Se(function*(N,Z,z,X){let ee=(ie)=>globalThis.process.platform==="win32"||vm(N)?h(N,Z,ie).pipe(zs((oe)=>BS(Z)&&n_(oe.cause)?He:q(N,Z,ie))):q(N,Z,ie);if(yield*ee(X?.killSignal??"SIGTERM"),Ga(X?.forceKillAfter))yield*Wr(z),yield*Y(N,Z,e_);else if(yield*Y(N,Z,$l(X.forceKillAfter)),r_(N,Z))yield*ee("SIGKILL"),yield*Y(N,Z,e_);yield*Wr(z)}),le=(N,Z)=>{let z=Z??"stdout";switch(z){case"stdout":return N.stdout;case"stderr":return N.stderr;case"all":return N.all;default:{let X=km(z);if(Qt(X))return N.getOutputFd(X);return N.stdout}}},ae=Se(function*(N){switch(N._tag){case"StandardCommand":{if(N.options.shell!==void 0&&N.options.shell!==!1&&N.args.length>0)return yield*fe(ln({module:"ChildProcess",method:"spawn",description:"The shell option cannot be combined with arguments; pass the whole script as the command"}));let Z=NQ(N);if(Z!==void 0)return yield*fe(ln({module:"ChildProcess",method:"spawn",description:Z}));let z=c(N.options),X=l(N.options,"stdout"),ee=l(N.options,"stderr"),ie=S(N.options),oe=!0,de=yield*n(N.options),ge=o(N.options),ke=m(z,X,ee,ie),me=ie.flatMap(({config:br,fd:En})=>br.type==="duplex"?[En]:[]),Ke=Se(function*(br,En){if(br.lost===!0||!oe)return;if(hf(En)){let[Fo]=yield*wo(Wr(En));if((Fo===0||WA(Fo))&&!vm(N))return}yield*hx(I(N,br,En,N.options))}),Pe=yield*e,er=Fi(),[dr,Mr]=yield*_n(y(Pe,N,Z0(N.options,{cwd:de,env:ge,stdio:ke},process.platform),me),([br,En],Fo)=>Ic([Zr(er,Fo),Ke(br,En)],{concurrency:"unbounded",discard:!0})),bs=K0(dr.pid);if(vm(N))dr.on("exit",(br)=>{if(oe&&br!==0&&gl(br))x(dr,N.options.killSignal??"SIGTERM")});let Is=Fe(()=>{if(!oe)dr.ref(),oe=!0}),ws=Fe(()=>{if(oe)dr.unref(),oe=!1;return Is}),mo=bo(),ol=yield*Ni(er)(k(N,dr,z,mo)),{all:il,stderr:sl,stdout:al}=A(N,dr,X,ee),{getInputFd:cl,getOutputFd:pl}=yield*Ni(er)(w(N,dr,ie,mo)),dl=Qe(()=>hf(Mr)?or(Wr(Mr),!1):W(!0)),ul=Ee(Rn(Wr(Mr),Wr(mo)),([br,En])=>{if(hf(mo))return Wr(mo);if(gl(br))return W(B0(br));let Fo=new globalThis.Error(`Process interrupted due to receipt of signal: '${En}'`);return fe(ro("exitCode",Fo,N))});return MS({pid:bs,exitCode:ul,isRunning:dl,kill:(br)=>I(N,dr,Mr,br),stdin:ol,stdout:al,stderr:sl,all:il,getInputFd:cl,getOutputFd:pl,unref:ws})}case"PipedCommand":{let{commands:Z,pipeOptions:z}=$S(N),[X,...ee]=Z,ie=[yield*ae(X)];for(let ke=0;ke<ee.length;ke++){let me=ee[ke],Ke=z[ke]??{},Pe=c(me.options),er=Co(W(le(ie[ie.length-1],Ke.from))),dr=Ke.to??"stdin";if(dr==="stdin")ie.push(yield*ae(Em(me.command,me.args,{...me.options,stdin:{...Pe,stream:er}})));else{let Mr=km(dr);if(Qt(Mr)){let bs=Y0(Mr),Is=me.options.additionalFds??{},ws=Is[bs],mo=ws?.type==="duplex"?{...ws,stream:er}:{type:"input",stream:er};ie.push(yield*ae(Em(me.command,me.args,{...me.options,additionalFds:{...Is,[bs]:mo}})))}else ie.push(yield*ae(Em(me.command,me.args,{...me.options,stdin:{...Pe,stream:er}})))}}let oe=ie[ie.length-1],de=(ke)=>Wi([...ie].reverse(),(me)=>hx(me.kill(ke)),{discard:!0}),ge=wr(function*(){let ke=[];for(let me of ie)ke.push(yield*me.unref);return Wi([...ke].reverse(),(me)=>me,{discard:!0})});return MS({pid:oe.pid,exitCode:oe.exitCode,isRunning:oe.isRunning,kill:de,stdin:ie[0].stdin,stdout:oe.stdout,stderr:oe.stderr,all:oe.all,getInputFd:oe.getInputFd,getOutputFd:oe.getOutputFd,unref:ge})}}});return $0(ae)}),KS=Sc(Fc,qQ(W($Q)));var $S=(e)=>{let t=[],r=[],n=(c)=>{switch(c._tag){case"StandardCommand":{t.push(c);break}case"PipedCommand":{n(c.left),r.push(c.options),n(c.right);break}}};if(n(e),t.length===0)throw Error("flattenCommand produced empty commands array");let[o,...i]=t;return{commands:[o,...i],pipeOptions:r}};import*as s_ from"crypto";import*as be from"fs";import*as a_ from"os";import*as di from"path";var ht=(e)=>(t)=>ln({module:"FileSystem",method:e,description:t.message??String(t)}),c_=(e,t)=>{let r=Number(e);if(!Number.isSafeInteger(r))throw RangeError(`${t} exceeds the safe integer range: ${e}`);return r},o_=(e)=>ng(Ms(e),UO),p_=(e)=>BigInt.asUintN(64,e),qS=(e)=>Rl(Ms(e),p_),GQ=(e,t)=>Tr({try:()=>c_(e,"position"),catch:ht(t)}),zQ=(()=>{let e=Ot(be.access,st("FileSystem","access"),ht("access"));return(t,r)=>{let n=be.constants.F_OK;if(r?.readable)n|=be.constants.R_OK;if(r?.writable)n|=be.constants.W_OK;return e(t,n)}})(),jQ=(()=>{let e=Ot(be.cp,st("FileSystem","copy"),ht("copy"));return(t,r,n)=>e(t,r,{force:n?.overwrite??!1,preserveTimestamps:n?.preserveTimestamps??!1,recursive:!0})})(),QQ=(()=>{let e=Ot(be.copyFile,st("FileSystem","copyFile"),ht("copyFile"));return(t,r)=>e(t,r)})(),HQ=(()=>{let e=Ot(be.chmod,st("FileSystem","chmod"),ht("chmod"));return(t,r)=>e(t,r)})(),VQ=(()=>{let e=Ot(be.chown,st("FileSystem","chown"),ht("chown"));return(t,r,n)=>e(t,r,n)})(),JQ=(()=>{let e=Ot(be.link,st("FileSystem","link"),ht("link"));return(t,r)=>e(t,r)})(),YQ=(()=>{let e=Ot(be.mkdir,st("FileSystem","makeDirectory"),ht("makeDirectory"));return(t,r)=>e(t,{recursive:r?.recursive??!1,mode:r?.mode})})(),WS=(e)=>{let t=Ot(be.mkdtemp,st("FileSystem",e),ht(e));return(r)=>Qe(()=>{let n=r?.prefix??"",o=typeof r?.directory==="string"?di.join(r.directory,"."):a_.tmpdir();return t(n?di.join(o,n):o+"/")})},ZQ=WS("makeTempDirectory"),GS=(e)=>{let t=Ot(be.rm,st("FileSystem",e),ht(e));return(r,n)=>t(r,{recursive:n?.recursive??!1,force:n?.force??!1})},XQ=GS("remove"),eH=(()=>{let e=WS("makeTempDirectoryScoped"),t=GS("makeTempDirectoryScoped");return(r)=>_n(e(r),(n)=>wo(t(n,{recursive:!0,force:!0})))})(),tH=(e)=>{let{O_APPEND:t,O_CREAT:r,O_EXCL:n,O_RDONLY:o,O_RDWR:i,O_TRUNC:s,O_WRONLY:c}=be.constants;switch(e){case"r":return o;case"r+":return i;case"w":return s|r|c;case"wx":return s|r|c|n;case"w+":return s|r|i;case"wx+":return s|r|i|n;case"a":return t|r|c;case"ax":return t|r|c|n;case"a+":return t|r|i;case"ax+":return t|r|i|n}},rH=(e,t)=>Qe(()=>{let{O_NOFOLLOW:r}=be.constants;if(process.platform==="win32"||typeof r!=="number"||r===0)return fe(ln({module:"FileSystem",method:e,description:"noFollow is not supported on this platform"}));return W(tH(t)|r)}),nH=(e)=>{let t=Ot(be.open,st("FileSystem",e),ht(e)),r=Ot(be.close,st("FileSystem",e),ht(e));return(n,o)=>Ci(_n(o?.noFollow===!0?Ee(rH(e,o.flag??"r"),(i)=>t(n,i,o.mode)):t(n,o?.flag??"r",o?.mode),(i)=>wo(r(i))),_e((i)=>sH(i,o?.flag?.startsWith("a")??!1)))},oH=nH("open"),iH=(e)=>e.reason.cause?.code==="ESPIPE",i_=(e)=>ln({module:"FileSystem",method:e,description:"Cannot read before the start of the file"}),sH=(()=>{let e=(m)=>Ot(be.read,st("FileSystem",m),ht(m)),t=e("read"),r=e("readAlloc"),n=Ot(be.fstat,st("FileSystem","stat"),ht("stat")),o=Ot(be.ftruncate,st("FileSystem","truncate"),ht("truncate")),i=Ot(be.fsync,st("FileSystem","sync"),ht("sync")),s=(m)=>{let g=Ot(be.write,st("FileSystem",m),ht(m));return(w,k,A)=>g(w,k,0,k.length,A)},c=s("write"),l=s("writeAll");class S{[jf];fd;append;position=BigInt(0);sequential=!1;constructor(m,g){this[jf]=jf,this.fd=m,this.append=g}get stat(){return Ee(n(this.fd,{bigint:!0}),l_)}get sync(){return i(this.fd)}atCursor(m){return Qe(()=>{if(this.sequential)return m(null);let g=this.position;return zi(_e(m(g),(w)=>(this.position=g+BigInt(w),w)),iH,()=>(this.sequential=!0,m(null)))})}writeOnce(m,g,w){return this.append?Qe(()=>g(this.fd,w,void 0)):this.atCursor((k)=>k===null?g(this.fd,w,void 0):Ee(GQ(k,m),(A)=>g(this.fd,w,A)))}seek(m,g){return Qe(()=>{let w=g==="start"?m:this.position+m;if(w<BigInt(0))return fe(ln({module:"FileSystem",method:"seek",description:"Cannot seek before the start of the file"}));return this.position=w,W(w)})}read(m,g){return Qe(()=>{let w=g?.position;if(w===void 0)return this.atCursor((k)=>t(this.fd,{buffer:m,position:k}));return w<BigInt(0)?fe(i_("read")):t(this.fd,{buffer:m,position:w})})}readAlloc(m,g){return Qe(()=>{try{if(!Number.isInteger(m)||m<0)throw RangeError("size must be a non-negative integer");let w=g?.position;if(w!==void 0&&w<BigInt(0))return fe(i_("readAlloc"));let k=Buffer.allocUnsafeSlow(m),A=(y)=>r(this.fd,{buffer:k,position:y});return _e(w===void 0?this.atCursor(A):A(w),(y)=>{if(y===0)return he();if(y===m)return Re(k);let h=Buffer.allocUnsafeSlow(y);return k.copy(h,0,0,y),Re(h)})}catch(w){return fe(ht("readAlloc")(w))}})}truncate(m){return _e(o(this.fd,m||void 0),()=>{if(!this.append){let g=BigInt(m??0);if(this.position>g)this.position=g}})}write(m){return this.writeOnce("write",c,m)}writeAllChunk(m){return Ee(this.writeOnce("writeAll",l,m),(g)=>{if(g===0)return fe(Yn({module:"FileSystem",method:"writeAll",_tag:"WriteZero",pathOrDescriptor:this.fd,description:"write returned 0 bytes written"}));return g<m.length?this.writeAllChunk(m.subarray(g)):He})}writeAll(m){return m.length===0?He:this.writeAllChunk(m)}}return(m,g)=>new S(m,g)})(),d_=(e)=>{let t=WS(e);return Se(function*(r){let n=yield*t(r),o=s_.randomBytes(6).toString("hex"),i=di.join(n,r?.suffix?`${o}${r.suffix}`:o);return yield*m_(i,new Uint8Array(0)),i})},aH=d_("makeTempFile"),cH=(()=>{let e=d_("makeTempFileScoped"),t=GS("makeTempFileScoped");return(r)=>_n(e(r),(n)=>wo(t(di.dirname(n),{recursive:!0,force:!0})))})(),pH=(e,t)=>Ws({try:()=>be.promises.readdir(e,t),catch:(r)=>st("FileSystem","readDirectory")(r,[e])}),dH=(e)=>Ws({try:()=>be.promises.readdir(e,{withFileTypes:!0}),catch:(t)=>st("FileSystem","readDirectoryEntries")(t,[e])}).pipe(_e((t)=>t.map((r)=>({name:r.name,type:u_(r)})))),uH=(e)=>tn((t,r)=>{try{be.readFile(e,{signal:r},(n,o)=>{if(n)t(fe(st("FileSystem","readFile")(n,[e])));else t(W(o))})}catch(n){t(fe(ht("readFile")(n)))}}),lH=(()=>{let e=Ot(be.readlink,st("FileSystem","readLink"),ht("readLink"));return(t)=>e(t)})(),fH=(()=>{let e=Ot(process.platform==="win32"?be.realpath.native:be.realpath,st("FileSystem","realPath"),ht("realPath"));return(t)=>e(t)})(),mH=(()=>{let e=Ot(be.rename,st("FileSystem","rename"),ht("rename"));return(t,r)=>e(t,r)})(),u_=(e)=>e.isFile()?"File":e.isDirectory()?"Directory":e.isSymbolicLink()?"SymbolicLink":e.isBlockDevice()?"BlockDevice":e.isCharacterDevice()?"CharacterDevice":e.isFIFO()?"FIFO":e.isSocket()?"Socket":"Unknown",l_=(e,t="stat")=>Tr({try:()=>({type:u_(e),mtime:Ms(e.mtime),atime:Ms(e.atime),birthtime:Ms(e.birthtime),dev:p_(e.dev),rdev:qS(e.rdev),ino:qS(e.ino),mode:c_(e.mode,"mode"),nlink:qS(e.nlink),uid:o_(e.uid),gid:o_(e.gid),size:Ex(e.size),blksize:e.blksize!==void 0?Re(Ex(e.blksize)):he(),blocks:Ms(e.blocks)}),catch:ht(t)}),f_=(e,t)=>{let r=Ot(t,st("FileSystem",e),ht(e));return(n)=>Ee(r(n,{bigint:!0}),(o)=>l_(o,e))},zS=f_("stat",be.stat),hH=f_("lstat",be.lstat),yH=(()=>{let e=Ot(be.symlink,st("FileSystem","symlink"),ht("symlink"));return(t,r)=>e(t,r)})(),gH=(()=>{let e=Ot(be.truncate,st("FileSystem","truncate"),ht("truncate"));return(t,r)=>e(t,r)})(),xH=(()=>{let e=Ot(be.utimes,st("FileSystem","utime"),ht("utime"));return(t,r,n)=>e(t,r,n)})(),SH=(e,t,r)=>rR((n)=>_n(Fe(()=>{let o=t.type==="Directory"?e:di.dirname(e),i=be.watch(e,{recursive:r?.recursive??!1},(s,c)=>{if(!c)return;switch(s){case"rename":{Rf(AO(zS(di.resolve(o,c)),{onSuccess:(l)=>bd(n,{_tag:"Create",path:c}),onFailure:(l)=>bd(n,{_tag:"Remove",path:c})}));return}case"change":{Ji(n,{_tag:"Update",path:c});return}}});return i.on("error",(s)=>{Id(n,lO(Yn({module:"FileSystem",_tag:"Unknown",method:"watch",pathOrDescriptor:e,cause:s})))}),i.on("close",()=>{vo(n)}),i}),(o)=>Fe(()=>o.close())).pipe(Gi(()=>Fe(()=>r?.onReady?.())))),bH=(e,t,r)=>Ic([zS(t),Af(Qf)]).pipe(_e(([n,o])=>Ov(o,()=>e).pipe(ng((i)=>i.register(t,n,r)),ur(()=>SH(t,n,r)))),Co),m_=(e,t,r)=>tn((n,o)=>{try{be.writeFile(e,t,{signal:o,flag:r?.flag,mode:r?.mode},(i)=>{if(i)n(fe(st("FileSystem","writeFile")(i,[e])));else n(He)})}catch(i){n(fe(ht("writeFile")(i)))}}),IH=_e(Af(Qf),(e)=>fR({access:zQ,chmod:HQ,chown:VQ,copy:jQ,copyFile:QQ,link:JQ,lstat:hH,makeDirectory:YQ,makeTempDirectory:ZQ,makeTempDirectoryScoped:eH,makeTempFile:aH,makeTempFileScoped:cH,open:oH,readDirectory:pH,readDirectoryEntries:dH,readFile:uH,readLink:lH,realPath:fH,remove:XQ,rename:mH,stat:zS,symlink:yH,truncate:gH,utimes:xH,watch(t,r){return bH(e,t,r)},writeFile:m_})),h_=Sc(Cd)(IH);var y_=h_;import*as Zd from"path";import*as Om from"url";var jS=(e)=>({fromFileUrl:(t)=>Tr({try:()=>Om.fileURLToPath(t,{windows:e}),catch:(r)=>new Sd({module:"Path",method:"fromFileUrl",cause:r})}),toFileUrl:(t)=>Tr({try:()=>Om.pathToFileURL(t,{windows:e}),catch:(r)=>new Sd({module:"Path",method:"toFileUrl",cause:r})})}),kH=xc(Zs)(Hf({...Zd.posix,...jS(!1)})),AH=xc(Zs)(Hf({...Zd.win32,...jS(!0)})),g_=xc(Zs)(Hf({...Zd,...jS(void 0)}));var x_=g_;var QS="~effect/Stdio",S_=Vt(QS),b_=(e)=>({[QS]:QS,stdinIsTerminal:W(!1),stdoutIsTerminal:W(!1),stderrIsTerminal:W(!1),...e});var TH=Fe(()=>{process.nextTick(()=>{if(process.stdin.readableFlowing===null)process.stdin.pause()})}),w_=xc(S_,b_({args:Fe(()=>process.argv.slice(2)),stdinIsTerminal:Fe(()=>process.stdin.isTTY===!0),stdoutIsTerminal:Fe(()=>process.stdout.isTTY===!0),stderrIsTerminal:Fe(()=>process.stderr.isTTY===!0),stdout:(e)=>Kc({evaluate:()=>process.stdout,onError:(t)=>Yn({module:"Stdio",method:"stdout",_tag:"Unknown",cause:t}),endOnDone:e?.endOnDone??!1}),stderr:(e)=>Kc({evaluate:()=>process.stderr,onError:(t)=>Yn({module:"Stdio",method:"stderr",_tag:"Unknown",cause:t}),endOnDone:e?.endOnDone??!1}),stdin:Co(or(kc(()=>TH),$c({evaluate:()=>process.stdin,onError:(e)=>Yn({module:"Stdio",method:"stdin",_tag:"Unknown",cause:e}),closeOnDone:!1})))}));var E_=w_;var k_="~effect/http/Cookies";var A_="~effect/http/Cookies/Cookie";var RH={[k_]:k_,...Pi,toJSON(){return{_id:"effect/Cookies",cookies:qv(this.cookies,(e)=>e.toJSON())}},pipe(){return Ze(this,arguments)}},_H=(e)=>{let t=Object.create(RH);return t.cookies=e,t},UH=(e)=>{let t={};for(let r of e)Jr(t,r.name,r);return _H(t)};var v_=UH([]);var Qse={[A_]:A_,...Pi,toJSON(){return{_id:"effect/Cookies/Cookie",name:this.name,value:this.value,options:this.options}}};var T_=Symbol.for("~effect/http/Headers");var Pm=Object.defineProperties(Object.create(null),{[T_]:{value:T_},[Ts]:{value(e){return LH(this,cn(e,MH))}},toJSON:{value(){return Wn(this)}},[Et]:{value(e){return DH(this,e)}},[wt]:{value(){return Ap(this)}},toString:{value:Pi.toString},[Yr]:{value:Pi[Yr]}});var DH=Gv(mv()),da=Object.create(Pm),O_=(e)=>{if(e===void 0)return da;else if(Symbol.iterator in e){let r=Object.create(Pm);for(let[n,o]of e){let i=n.toLowerCase();r[i]=i in r?`${r[i]}, ${o}`:o}return r}let t=Object.create(Pm);for(let[r,n]of Object.entries(e))if(Array.isArray(n))t[r.toLowerCase()]=n.join(", ");else if(n!==void 0)t[r.toLowerCase()]=n;return t},P_=(e)=>Object.setPrototypeOf(e,Pm);var LH=B(2,(e,t)=>{let r={...e},n=(o)=>{if(typeof o==="string"){let i=o.toLowerCase();if(i in e)r[i]=aa(e[i])}else for(let i in e)if(i.search(o)!==-1)r[i]=aa(e[i])};if(Array.isArray(t))for(let o=0;o<t.length;o++)n(t[o]);else n(t);return r});var MH=jt("effect/Headers/CurrentRedactedNames",{defaultValue:()=>["authorization","cookie","set-cookie","x-api-key"]});var Rm=(e,t,r)=>Yt(e)?r(t):zr(e,r);function __(e){let t=FH(e);return(r,n,o)=>{try{return t(r,n,o)}catch(i){return Cr(i)}}}function FH(e){if(e._tag==="Middleware")return(r,n,o)=>{let i=Yt(r)?e.decode(kr(Pd(n)),o):e.decode(Uf(r,Pd),o);return R_(i)};let t=e.decode;switch(t._tag){case"Passthrough":return(r,n)=>Yt(r)?kr(n):r;case"Transform":{let r=(n)=>n===$e?Un:kr(t.transform(n));return(n,o)=>Rm(n,o,r)}case"TransformOptional":{let r=(n)=>Xx(t.transform(Pd(n)));return(n,o)=>Rm(n,o,r)}case"TransformEffect":return(r,n,o)=>Rm(r,n,(i)=>i===$e?Un:t.transform(i,o));case"TransformOptionalEffect":return(r,n,o)=>Rm(r,n,(i)=>R_(t.transform(Pd(i),o)))}}var R_=(e)=>zr(e,Xx),U_=(e,t,r,n)=>Gr(n,(o)=>Gs(()=>qi(o,(i)=>new gR(e,i,t,r))));function NH(e,t){let r=__(e.link.transformation),n;return(o,i)=>{if(o===$e)return Un;if(e.isConstructed(o))return oi;let s=(n??=t(e.link.to))(o,i);return r(s,o,i)}}function BH(e,t){let r=e.context.constructorDefault;return(n,o)=>{if(n!==$e&&n!==void 0)return t(n,o);let i=r;if(ut(i)&&i._tag==="Success"){let s=t(i[De],o);return Yt(s)?i:s}return zr(U_(e,n,o,i),(s)=>{let c=t(s,o);return Yt(c)?kr(s):c})}}function VS(e,t){let r=t(e);return e.context?.constructorDefault===void 0?r:BH(e,r)}function Xd(e,t,r,n,o){if(e._tag==="Declaration")for(let A of e.typeParameters)t(A);let i=r?wm(e):void 0,s=i?NH(i,t):n??e.getParser(t,r),{checks:c,encoding:l}=e,S=l?.map((A)=>__(A.transformation)),m=e.encodingChecks;if(!l&&!c&&!m)return s;let g,w=(A,y)=>{let h=s(A,y);try{if(m&&!y.disableChecks)if(ut(h)){if(h._tag==="Success"){let x=Yt(h)?A:h[De];if(A!==$e&&x!==$e){let q=Xi(m,A,void 0,e,y);if(q)h=fe(new Rr(e,q,A,y))}}}else h=Ee(h,(x)=>{if(A!==$e&&x!==$e){let q=Xi(m,A,void 0,e,y);if(q)return fe(new Rr(e,q,A,y))}return W(x)});if(c&&!y.disableChecks)if(ut(h)){if(h._tag==="Success"){let x=Yt(h)?A:h[De];if(x===$e)return h;let q=Xi(c,x,void 0,e,y);if(q)h=fe(new Rr(e,q,x,y))}}else h=Ee(h,(x)=>{if(x!==$e){let q=Xi(c,x,void 0,e,y);if(q)return fe(new Rr(e,q,x,y))}return W(x)});return h}catch(x){return Cr(x)}},k=o===void 0?w:o(w);if(!l)return k;return(A,y)=>{let h=g??=l.map((Y)=>t(Y.to)),x=A,q=h[h.length-1](A,y);for(let Y=l.length-1;Y>=0;Y--)if(q=S[Y](q,x,y),Y!==0){let I=h[Y-1];if(q._tag==="Success")x=q[De],q=I(x,y);else q=zr(q,(le)=>{let ae=I(le,y);return Yt(ae)?kr(le):ae})}if(q._tag==="Success"){let Y=q[De],I=k(Y,y);return Yt(I)?q:I}return q=U_(e,A,y,q),zr(q,(Y)=>{let I=k(Y,y);return Yt(I)?kr(Y):I})}}var JS=Symbol(),D_=new WeakMap,L_,eu=!1;var $H=(e)=>eu?_m(hn,e,"parser"):hn(e).parser,M_=(e)=>eu?_m(hn,e,"makeEffect"):hn(e).makeEffect,qH=(e)=>VS(e,M_);class YS{ast;constructor(e){this.ast=e}get decodeEffect(){return this.cachedDecodeEffect??=Xd(this.ast,$H)}get parser(){return this.decodeEffect}get makeEffect(){return this.cachedMakeEffect??=Xd(this.ast,M_,qH)}}class F_ extends YS{compiled;resolve;constructor(e,t,r){super(e);this.compiled=t,this.resolve=r}save(e,t){return Object.defineProperty(this,e,{value:t}),t}operation(e){let t=this.compiled;return typeof t==="function"?t(this.ast,this.resolve,e):t?.[e]}get is(){return this.save("is",this.operation("is"))}get decode(){return this.save("decode",this.operation("decode"))}get make(){return this.save("make",this.operation("make"))}get compiledMakeEffect(){return this.save("compiledMakeEffect",this.operation("makeEffect"))}get decodeEffect(){return this.save("decodeEffect",this.operation("decodeEffect")??Xd(this.ast,(e)=>_m(this.resolve,e,"parser")))}get parser(){let e=this.decode;return e===void 0?this.decodeEffect:this.save("parser",WH(e,()=>this.decodeEffect))}get makeEffect(){let e=this.compiledMakeEffect;if(e!==void 0)return this.save("makeEffect",e);let t=(r)=>_m(this.resolve,r,"makeEffect");return this.save("makeEffect",Xd(this.ast,t,(r)=>VS(r,t)))}}function WH(e,t){let r;return(n,o)=>{if(n!==$e)try{let i=e(n,o);if(i!==JS)return i===n?oi:kr(i)}catch(i){return Cr(i)}return(r??=t())(n,o)}}function _m(e,t,r){let n=e(t);if(n.compiled===void 0||Object.hasOwn(n,r))return n[r];let o;return(i,s)=>(o??=n[r])(i,s)}function hn(e){let t=D_.get(e);if(t!==void 0)return t;let r=L_===void 0?new YS(e):new F_(e,L_(e,hn),hn);return D_.set(e,r),r}function XS(e){let t=e.ast,r;return(n,o)=>H_(r??=hn(ci(t)),n,Q_(o))}function Um(e){let t=XS(e);return(r,n)=>VH(Hs(t(r,n)))}function B_(e){return YH(ci(e.ast))}function K_(e){return jH(e.ast)}function zH(e){if(!eu){let o=G_(tb(e));return(i)=>{let s=o(i,oa);if(Xr(s))return!0;return Xs(s.cause,"Type guard adapter can only return false for schema issues"),!1}}let t=hn(e),r=t.is;if(r!==void 0)return(o)=>{try{return r(o,oa)}catch(i){return Xs(bf(i),"Type guard adapter can only return false for schema issues"),!1}};let n=t.parser;return(o)=>{let i=Hs(rb(n(o,oa),o));if(Xr(i))return!0;return Xs(i.cause,"Type guard adapter can only return false for schema issues"),!1}}function jH(e){let t=ci(e),r=(n)=>(r=zH(t),r(n));return(n)=>r(n)}function eb(e,t){let r=tb(e.ast);return W_(r,t)}function $_(e,t){return HH(eb(e,t))}function q_(e,t){let r=tb(fn(e.ast));return W_(r,t)}function W_(e,t){return t===void 0?e:(r,n)=>e(r,n?{...t,...n}:t)}var N_=(e)=>{if(e===$e)return fe(new jr);return W(e)};function tb(e){return QH(ZH,e)}function rb(e,t){if(Yt(e))return W(t);if(!ut(e))return zr(e,N_);return e[De]===$e?N_($e):e}function QH(e,t){let r;return(n,o)=>rb((r??=e(t))(n,o??oa),n)}function G_(e){return(t,r)=>Hs(e(t,r))}function HH(e){let t=G_(e);return(r,n)=>{let o=t(r,n);if(Xr(o))return Re(o.value);return Xs(o.cause,"Option adapter can only return none for schema issues"),he()}}function VH(e){if(Xr(e))return Re(e.value);return Xs(e.cause,"Option adapter can only return none for schema issues"),he()}function JH(e,t){let r=Hs(e);if(Xr(r))return r.value;let n=Xs(r.cause,t);throw Error("Schema validation failed",{cause:n})}var z_="Constructor adapter can only throw schema issues";function j_(e){throw Error(z_,{cause:bf(e)})}function YH(e){let t;return(r,n)=>ZS(t??=hn(e),r,n)}function Q_(e){return e?.disableChecks?{...e.parseOptions,disableChecks:!0}:e?.parseOptions??oa}function H_(e,t,r){return rb(e.makeEffect(t,r),t)}function ZS(e,t,r){let n=Q_(r),o=eu?e.make:void 0;if(o!==void 0&&t!==$e){let i;try{i=o(t,n)}catch(s){j_(s)}if(i!==JS&&i!==$e)return i}return JH(H_(e,t,n),z_)}function V_(e,t,r,n){let o=hn(e),i=wm(e);if(i===void 0||o.make!==void 0||o.compiledMakeEffect!==void 0)return ZS(o,t,r);if(i.isConstructed(t))return t;let s=ZS((o.resolve??hn)(i.link.to),t,r);try{return n(s)}catch(c){j_(c)}}var ZH=(e)=>hn(e).parser;var Dm="~effect/Schema/Schema",J_=Symbol(),XH={[Dm]:Dm,get make(){let e=B_(this);return Object.defineProperty(this,"make",{value:e,enumerable:!0}),e},get makeEffect(){let e=XS(this);return Object.defineProperty(this,"makeEffect",{value:e,enumerable:!0}),e},get makeOption(){let e=Um(this);return Object.defineProperty(this,"makeOption",{value:e,enumerable:!0}),e},pipe(){return Ze(this,arguments)},annotate(e){return this.rebuild(gm(this.ast,e))},annotateKey(e){return this.rebuild(bm(this.ast,e))},check(...e){return this.rebuild(ia(this.ast,e))},rebuild(e){return qc(e,this[J_])}};function qc(e,t){function r(){}let n=Object.setPrototypeOf(r,XH);if(t&&(Object.hasOwn(t,"name")||Object.hasOwn(t,"length")||Object.hasOwn(t,"__proto__")))Object.defineProperties(n,Object.getOwnPropertyDescriptors({...t}));else Object.assign(n,t);return n[J_]=t,n.ast=e,n}function nV(e,t){let r=Ti((o)=>{let i=Lc(o,void 0),s=e(i,n);return s===i?null:s}),n=Sm((o)=>{let i=r(Hd(o));if(i===null)return o;let s=Lc(i,o.context);return o.context===void 0?s:k0(s,oV(o.context))},t);return n}function oV(e){return e.constructorDefault===void 0?e:new gS(e.isOptional,e.isMutable,void 0,e.annotations)}function iV(e){if(e.propertySignatures.some((t)=>typeof t.name!=="string"))throw new globalThis.Error("Objects property names must be strings",{cause:e})}function sV(e){return(t)=>{let r=[...t].sort((o,i)=>e(pi(o))-e(pi(i)));if(!r.some((o,i)=>o!==t[i]))return t;return r}}function Z_(e){return qc(fV(e.ast),{schema:e})}var aV=sV((e)=>{switch(e._tag){case"Null":case"Boolean":case"Number":case"BigInt":case"Symbol":case"UniqueSymbol":return 0;default:return 1}});function cV(e,t,r){switch(e._tag){case"Declaration":{let n=e.typeParameters.map((S)=>qc(t(pi(S)))),o=e.annotations?.toCodecStringTree;if(yo(o)){let S=o(n);if(S===void 0)return e;return _r(e,[xm(S,t)])}let i=e.annotations?.toCodecJson,s=yo(i)?i(n):void 0,c=s===void 0?e.annotations?.toCodec:void 0,l=s??(yo(c)?c(n):void 0);return l===void 0?r(e):_r(e,[xm(l,t)])}case"Null":return _r(e,[pV]);case"Boolean":return _r(e,[dV]);case"Unknown":case"ObjectKeyword":return _r(e,[DS]);case"Enum":case"Number":case"Literal":case"UniqueSymbol":case"Symbol":case"BigInt":return e.toCodecStringTree();case"Objects":return iV(e),e.recur(t,US);case"Union":{let n=aV(e.types);if(n!==e.types)return new Zi(n,e.options,e.annotations,e.checks,e.encoding,e.context,e.encodingChecks).recur(t);return e.recur(t)}case"Arrays":case"Suspend":return e.recur(t)}return e}var pV=new Ur(new Oo("null"),new ir(Lt(()=>null),Lt(()=>"null"))),dV=new Ur(new Zi([new Oo("true"),new Oo("false")]),new ir(Lt((e)=>e==="true"),tm())),uV=new ir(Lt((e)=>typeof e==="string"?[e]:e),To()),lV=(e)=>e.transformation===uV,fV=nV((e,t)=>cV(e,t,(r)=>{throw new globalThis.Error("Missing structural codec for StringTree",{cause:r})}),{stopAt:lV});var ua=(e)=>e;var Wc="~effect/Schema/SchemaError";function eU(e){return je(e,Wc)&&e[Wc]===Wc}var tu=Dm;function hV(){return(e,t,r)=>vt(new Qd(e.map(mm),(n)=>t(n.map((o)=>vt(o))),r))}function yV(e,t){return hV()([],()=>(r,n,o)=>e(r)?W(r):fe(new eo(n,r,o)),t)}function gV(e){return(t)=>tU(tU(t).annotate(e))}class ib extends Ho("SchemaError"){[Wc]=Wc;constructor(e){let t=Ps();Gn(0);try{super({issue:e})}finally{Gn(t)}}get message(){return vR(this.issue)}toJSON(){return{_tag:this._tag,message:this.message}}[Yr](){return this.toJSON()}toString(){return`SchemaError(${this.message})`}}function xV(e){return eU(e)}function oU(e){if(ut(e))return SV(e);return Gr(e,(t)=>Gs(()=>qi(t,(r)=>new ib(r))))}function SV(e){return Xr(e)?e:$i(qi(e.cause,(t)=>new ib(t)))}function iU(e,t){let r;for(let n of e.reasons){if(!Sf(n)||!xV(n.error))throw new globalThis.Error(t,{cause:e});r??=n.error}if(r===void 0)throw new globalThis.Error(t,{cause:e});return r}function bV(e){return Ix(e).then((t)=>{if(Xr(t))return t.value;throw iU(t.cause,"Promise adapter can only reject schema errors")})}function IV(e){let t=Hs(e);if(Xr(t))return t.value;throw iU(t.cause,"Sync adapter can only throw schema errors")}var sb=K_;function es(e,t){let r=eb(e,t);return(n,o)=>oU(r(n,o))}var ts=$_;function no(e,t){let r=es(e,t);return(n,o)=>bV(r(n,o))}function wV(e,t){let r=es(e,t);return(n,o)=>IV(r(n,o))}function sU(e,t){let r=q_(e,t);return(n,o)=>oU(r(n,o))}var vt=qc;function EV(e){return je(e,tu)&&e[tu]===tu}var u=ua((e)=>vt(Im(e.ast),{schema:e}));var ab=ua((e)=>{let t=CV(e);return vt(C0(e.ast),{schema:t})});var kV=ua((e)=>vt(pi(e.ast),{schema:e})),ru="~effect/Schema/flip";function AV(e){return je(e,ru)&&e[ru]===ru}function tU(e){if(AV(e))return e.schema.rebuild(fn(e.ast));return vt(fn(e.ast),{[ru]:ru,schema:e})}function v(e){let t=vt(new Oo(e),{literal:e,transform(r){return t.pipe(rs(v(r),{decode:Lt(()=>r),encode:Lt(()=>e)}))}});return t}var j=vt(zd),aU=vt(um),vV=vt(xS),a=vt(Yi);var mr=vt(SS),V=vt(i0);function cb(e,t){return vt(e,{fields:t,mapFields(r,n){let o=r(this.fields);return cb(fm(o,n?.unsafePreserveChecks?this.ast.checks:void 0),o)}})}function p(e){return cb(fm(e,void 0),e)}function $t(e,t){return vt(OS(e.ast,t.ast),{key:e,value:t})}function cU(e,t){return vt(l0(e.ast,t.map(mm)),{schema:e,records:t})}var _=ua((e)=>vt(new lm(!1,[],[e.ast]),{value:e}));function pU(e,t){return vt(e,{members:t,mapMembers(r,n){let o=r(this.members);return pU(hm(o,this.ast.options,n?.unsafePreserveChecks?this.ast.checks:void 0),o)}})}function lt(e,t){return pU(hm(e,t,void 0),e)}function G(e){let t=e.map(v);return vt(hm(t,void 0,void 0),{literals:e,members:t,mapMembers(r){return lt(r(this.members))},pick(r){return G(r)},transform(r){return lt(t.map((n,o)=>n.transform(r[o])))}})}var U=ua((e)=>lt([e,aU])),CV=ua((e)=>lt([e,vV]));function at(e){return(t)=>vt(t.ast,{schema:t,identifier:e})}function TV(e){return(t)=>vt(A0(t.ast,new sS(e,Ie)),{schema:t})}function pb(e){return OV(e)}function OV(e){return(t)=>TV(PO(e))(t)}function rs(e,t){return(r)=>vt(TS(r.ast,e.ast,t?aS(t):im()),{from:r,to:e})}var db=G(["true","yes","on","1","y"]),ub=G(["false","no","off","0","n"]),dU=G([...db.literals,...ub.literals]).pipe(rs(V,om({decode:(e)=>e==="true"||e==="yes"||e==="on"||e==="1"||e==="y",encode:(e)=>e?"true":"false"})));function PV(e){return(t)=>vt(T0(t.ast,e),{schema:t})}function RV(e){if(ut(e)&&e._tag==="Success")return e;return Gr(e,(t)=>Gs(()=>qi(t,(r)=>r.issue)))}function uU(e,t){let r=t?.encodingStrategy==="omit"?MR():To();return(n)=>u(kV(n)).pipe(rs(n,{decode:FR(RV(e)),encode:r}))}function ns(e){return v(e).pipe(PV(W(e)))}function _V(e,t){return p({_tag:ns(e),...t})}function la(e,t){return yV((r)=>r instanceof e,t)}function ou(){return(e,t)=>new Ur(e.ast,aS(t))}var qt=ym;var rU="^\\S[\\s\\S]*\\S$|^\\S$|^$";function UV(e){let t=new globalThis.RegExp(rU);return qt((r)=>r.trim()===r,{expected:"a string with no leading or trailing whitespace",representation:{id:"effect/schema/isTrimmed",payload:null},toJsonSchema:()=>({pattern:t.source}),arbitraryConstraint:{patterns:[{source:rU,flags:""}]},...e})}function qe(e,t){let{source:r,flags:n}=e,o=/^[dg]*uy?$/.test(n);return kS(e,{toJsonSchema:()=>o?{pattern:n.endsWith("y")?`^(?:${r})`:r}:[{},!0],...t})}var DV=(e)=>{if(e)return new globalThis.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})$`);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|[fF]{8}-[fF]{4}-[fF]{4}-[fF]{4}-[fF]{12})$/};function D(e,t){let r=DV(e);return qe(r,{expected:e?`a UUID v${e}`:"a UUID",representation:{id:"effect/schema/isUUID",payload:{version:e??null}},toJsonSchema:()=>({pattern:r.source,format:"uuid"}),...t})}function LV(e){let r=/^[0-9a-zA-Z+/]*={0,2}$/;return qt((n)=>n.length%4===0&&r.test(n),{expected:"a base64 encoded string",representation:{id:"effect/schema/isBase64",payload:null},toJsonSchema:()=>({pattern:"^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$"}),arbitraryConstraint:{patterns:[{source:"^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$",flags:""}]},...e})}function MV(e){let t=Bp(e.order),r=e.formatter??et;return(n,o)=>qt((i)=>t(i,n),{expected:`a value greater than ${r(n)}`,arbitraryConstraint:{order:e.order,minimum:n,exclusiveMinimum:!0},...e.annotate?.(n),...o})}function FV(e){let t=rg(e.order),r=e.formatter??et;return(n,o)=>qt((i)=>t(i,n),{expected:`a value greater than or equal to ${r(n)}`,arbitraryConstraint:{order:e.order,minimum:n},...e.annotate?.(n),...o})}function NV(e){let t=tg(e.order),r=e.formatter??et;return(n,o)=>qt((i)=>t(i,n),{expected:`a value less than or equal to ${r(n)}`,arbitraryConstraint:{order:e.order,maximum:n},...e.annotate?.(n),...o})}function BV(e){let t=rg(e.order),r=Bp(e.order),n=tg(e.order),o=Tv(e.order),i=e.formatter??et;return(s,c)=>{let l=s.exclusiveMinimum?r:t,S=s.exclusiveMaximum?o:n;return qt((m)=>l(m,s.minimum)&&S(m,s.maximum),{expected:`a value between ${i(s.minimum)}${s.exclusiveMinimum?" (excluded)":""} and ${i(s.maximum)}${s.exclusiveMaximum?" (excluded)":""}`,arbitraryConstraint:{order:e.order,minimum:s.minimum,maximum:s.maximum,...s.exclusiveMinimum&&{exclusiveMinimum:!0},...s.exclusiveMaximum&&{exclusiveMaximum:!0}},...e.annotate?.(s),...c})}}function nu(e){if(!globalThis.Number.isFinite(e))throw new globalThis.RangeError(`Expected a finite number, got ${et(e)}`);return e}var Ro=MV({order:Ls,annotate:(e)=>({representation:{id:"effect/schema/isGreaterThan",payload:{exclusiveMinimum:nu(e)}},toJsonSchema:()=>({exclusiveMinimum:e})})}),Te=FV({order:Ls,annotate:(e)=>({representation:{id:"effect/schema/isGreaterThanOrEqualTo",payload:{minimum:nu(e)}},toJsonSchema:()=>({minimum:e})})});var lU=NV({order:Ls,annotate:(e)=>({representation:{id:"effect/schema/isLessThanOrEqualTo",payload:{maximum:nu(e)}},toJsonSchema:()=>({maximum:e})})}),Dr=BV({order:Ls,annotate:(e)=>{let t=e.exclusiveMinimum?!0:void 0,r=e.exclusiveMaximum?!0:void 0;return{representation:{id:"effect/schema/isBetween",payload:{minimum:nu(e.minimum),maximum:nu(e.maximum),...t&&{exclusiveMinimum:t},...r&&{exclusiveMaximum:r}}},toJsonSchema:()=>({[t?"exclusiveMinimum":"minimum"]:e.minimum,[r?"exclusiveMaximum":"maximum"]:e.maximum})}}});function iu(e){return qt((t)=>globalThis.Number.isSafeInteger(t),{expected:"an integer",representation:{id:"effect/schema/isInt",payload:null},toJsonSchema:()=>({type:"integer",minimum:globalThis.Number.MIN_SAFE_INTEGER,maximum:globalThis.Number.MAX_SAFE_INTEGER}),arbitraryConstraint:{number:"integer"},...e})}var L=mr.check(iu());function xe(e,t){return e=fU(e),KV(e,Math.ceil(e/2),t)}function KV(e,t,r){return qt((n)=>n.length>=e,{expected:`a value with a length of at least ${e}`,representation:{id:"effect/schema/isMinLength",payload:{minLength:e}},toJsonSchema:({type:n})=>n==="string"?e<=1?{minLength:t}:[{minLength:t},!0]:n==="array"?{minItems:e}:n===void 0?[{minLength:t,minItems:e},!0]:[{},!0],[Td]:!0,arbitraryConstraint:{minLength:e},...r})}function re(e,t){return e=fU(e),qt((r)=>r.length<=e,{expected:`a value with a length of at most ${e}`,representation:{id:"effect/schema/isMaxLength",payload:{maxLength:e}},toJsonSchema:({type:r})=>r==="string"?e===0?{maxLength:e}:[{maxLength:e},!0]:r==="array"?{maxItems:e}:r===void 0?[{maxLength:e,maxItems:e},!0]:[{},!0],[Td]:!0,arbitraryConstraint:{maxLength:e},...t})}function fU(e){if(!globalThis.Number.isFinite(e))throw new globalThis.RangeError(`Expected a finite number, got ${e}`);return Math.max(0,Math.floor(e))}var $V=(e)=>(e?.includeStack===!0?1:0)|(e?.excludeCause===!0?2:0),qV=(e)=>{switch(e){case 0:return;case 1:return{includeStack:!0};case 2:return{excludeCause:!0};case 3:return{includeStack:!0,excludeCause:!0}}};var nU=[];function mU(e){let t=$V(e),r=nU[t];if(r!==void 0)return r;let n=YV.pipe(rs(j,GR(qV(t))));return nU[t]=n,n}var kce=la(globalThis.RegExp,{representation:{id:"effect/schema/RegExp",payload:null},expected:"RegExp",toCodecJson:()=>ou()(p({source:a,flags:a}),nm({decode:(e,t)=>Tr({try:()=>new globalThis.RegExp(e.source,e.flags),catch:()=>new jr({expected:"valid RegExp source and flags"},e,t)}),encode:(e)=>W({source:e.source,flags:e.flags})}))}),WV=a.annotate({expected:"a string that will be decoded as a URL"}),Ace=la(globalThis.URL,{representation:{id:"effect/schema/URL",payload:null},expected:"URL",toCodecJson:()=>ou()(WV,zR)});var vce=la(globalThis.File,{representation:{id:"effect/schema/File",payload:null},expected:"File",toCodecJson:()=>ou()(p({data:a.check(LV()),type:a,name:a,lastModified:L}),nm({decode:(e,t)=>Ll(em(e.data),{onFailure:()=>fe(new jr({expected:"a valid Base64 string"},e.data,t)),onSuccess:(r)=>{let n=new globalThis.Uint8Array(r);return W(new globalThis.File([n],e.name,{type:e.type,lastModified:e.lastModified}))}}),encode:(e,t)=>Ws({try:async()=>{let r=new globalThis.Uint8Array(await e.arrayBuffer());return{data:Xf(r),type:e.type,name:e.name,lastModified:e.lastModified}},catch:()=>new jr({expected:"a readable File"},e,t)})}))});var Cce=la(globalThis.URLSearchParams,{representation:{id:"effect/schema/URLSearchParams",payload:null},expected:"URLSearchParams",toCodecJson:()=>ou()(a.annotate({expected:"a query string that will be decoded as URLSearchParams"}),om({decode:(e)=>new globalThis.URLSearchParams(e),encode:(e)=>e.toString()}))});var Lm=a.annotate({expected:"a string that will be decoded as a number"}).pipe(rs(mr,qd));var GV=a.check(UV()),Lr=a.annotate({expected:"a string that will be decoded as a trimmed string"}).pipe(rs(GV,qR()));var zV=a.annotate({expected:"a base64 encoded string that will be decoded as Uint8Array",format:"byte",contentEncoding:"base64"}),Tce=la(globalThis.Uint8Array,{representation:{id:"effect/schema/Uint8Array",payload:null},expected:"Uint8Array",toCodecJson:()=>ou()(zV,jR)});var jV=-8640000000000000,QV=8640000000000000,Oce=jV+50400000,Pce=QV-50400000;var HV=globalThis.Symbol.for("immer-draftable"),ob={};function hU(e,t,r,n,o){let i=JV(r,t,n),s=gU(t),c=class extends e{constructor(...[l,S]){let g=S?.["~payload"],w=g?.token===ob?g.value:r.make(l??{},S);super(w,{...S,disableChecks:!0,"~payload":{token:ob,value:w}})}static[tu]=tu;get[s](){return s}static[HV]=!0;static identifier=t;static fields=r.fields;static get ast(){return i(this).ast}static pipe(){return Ze(this,arguments)}static rebuild(l){return i(this).rebuild(l)}static make(l,S){return V_(ci(i(this).ast),l??{},S,(m)=>yU(this,m))}static makeOption(l,S){return Um(i(this))(l??{},S)}static makeEffect(l,S){return i(this).makeEffect(l??{},S)}static annotate(l){return this.rebuild(gm(this.ast,l))}static annotateKey(l){return this.rebuild(bm(this.ast,l))}static check(...l){return this.rebuild(ia(this.ast,l))}static extend(l){return(S,m)=>{let g=lb(S)?S:p(S),w={...r.fields,...g.fields},k=fm(w,r.ast.checks,{identifier:l});return hU(this,l,cb(ia(k,g.ast.checks),w),m,o)}}static mapFields(l,S){return r.mapFields(l,S)}};if(o!==void 0)Object.assign(c.prototype,o(t));return c}function yU(e,t){return new e(t,{"~payload":{token:ob,value:t}})}function VV(e){return new ir(Lt((t)=>yU(e,t)),To())}function gU(e){return`~effect/Schema/Class/${e}`}function JV(e,t,r){let n;return(o)=>{if(n!==void 0)return n;let i=gU(t),s=(S)=>S instanceof o||je(S,i),c=VV(o),l=vt(new Qd([e.ast],()=>(S,m,g)=>s(S)?W(S):fe(new eo(m,S,g)),{identifier:t,[Jf]:([S])=>({isConstructed:s,link:new Ur(S,c)}),toCodec:([S])=>new Ur(S.ast,c),toEquivalence:([S])=>S,toFormatter:([S])=>(m)=>`${o.identifier}(${S(m)})`,[Vf]:jd(e.ast),...r}));return n=rs(l,c)(e)}}function lb(e){return EV(e)}var su=(e)=>(t,r)=>{let n=lb(t)?t:p(t);return hU(Mp,e,n,r,(i)=>({name:i}))},oo=(e)=>(t,r,n)=>{let o=lb(r)?r.mapFields((i)=>({_tag:ns(t),...i}),{unsafePreserveChecks:!0}):_V(t,r);return su(e??t)(o,n)};var xU=Z_;var YV=vt(M0);var SU="~effect/Terminal",fb="~effect/Terminal/QuitError";class au extends su("QuitError")({_tag:ns("QuitError")}){[fb]=fb}var bU=(e)=>je(e,fb),io=Vt("effect/Terminal"),IU=(e)=>io.of({...e,[SU]:SU});import*as Fm from"readline";var wU=Se(function*(e=kU){let t=yield*Vs(),r=!1,n=!1,o=()=>{if(r=!0,!n)vo(t)},i,s=()=>{if(i===void 0)if(i=process.stdin,i.readableEnded)o();else i.once("end",o);return i};yield*kc(()=>Fe(()=>i?.off("end",o)));let c=yield*jx({acquire:_n(Fe(()=>{let h=s(),x=Fm.createInterface({input:h,escapeCodeTimeout:50}),q=(I)=>Ji(t,I),Y=()=>{n=!1,vo(t)};return n=!0,Fm.emitKeypressEvents(h,x),x.on("line",q),x.once("close",Y),{rl:x,onClose:Y,onLine:q}}),({rl:h,onClose:x,onLine:q})=>Fe(()=>{if(n=!1,h.off("line",q),h.off("close",x),h.close(),r)vo(t)})),idleTimeToLive:"10 millis"}),l=(h)=>Fe(()=>{let x=s();if(x.isTTY)x.setRawMode(h)}),S=yield*jx({acquire:_n(l(!0),()=>l(!1)),idleTimeToLive:"10 millis"}),m=Fe(()=>process.stdout.columns??0),g=Fe(()=>process.stdout.rows??0),w=wr(function*(){let h=process.stdout,x=yield*mP(1),q=()=>Ji(x,{columns:h.columns??0,rows:h.rows??0});return yield*kc(()=>Fe(()=>{h.off("resize",q),vo(x)})),h.on("resize",q),q(),x}),k=wr(function*(){let h=s(),x=yield*Vs(),q=(le,ae)=>{let N={input:Za(le),key:{name:ae.name??"",ctrl:!!ae.ctrl,meta:!!ae.meta,shift:!!ae.shift}};if(Ji(x,N),e(N))vo(x)},Y=setInterval(()=>{},2147483647),I=()=>{clearInterval(Y),vo(x)};if(yield*kc(()=>Fe(()=>{clearInterval(Y),h.off("keypress",q),h.off("end",I)})),h.on("keypress",q),r)I();else yield*Gf(c),yield*Gf(S),h.once("end",I);return x}),A=Qe(()=>gP(t).pipe(Ee(Kr({onNone:()=>js(Jn(Gf(c),ni(t))),onSome:W})),Or(()=>new au({}))));return IU({columns:m,rows:g,size:w,readInput:k,readLine:A,display:(h)=>Cf(tn((x)=>{process.stdout.write(h,(q)=>GA(q)?x(He):x(fe(ln({module:"Terminal",method:"display",description:"Failed to write prompt to stdout",cause:q}))))}))})}),EU=Sc(io,wU(kU));function kU(e){let t=e.key;return t.name==="escape"||t.ctrl&&(t.name==="c"||t.name==="d")}var AU=EU;var e4=KS.pipe(uO(gf(y_,x_,E_,AU)));var t4=nx,CU=(e)=>Ye((t)=>e(t.getRef(t4)));var Nm=(...e)=>CU((t)=>kt(()=>{t.error(...e)}));var hr=(...e)=>CU((t)=>kt(()=>{t.log(...e)}));var Bm="~effect/ErrorReporter/ignore";var TU="~effect/Runtime/errorExitCode";var pu="~effect/Runtime/errorReported";var ct=a.check(D()),ce=at("WorkspaceId")(ct),ui=at("WorkspaceInviteId")(ct),os=at("UserId")(ct),yb=at("AuditEventId")(ct),Pt=at("PostId")(ct),sr=at("TargetId")(ct),Wt=at("AttemptId")(ct),H=at("AccountId")(ct),yn=at("MediaId")(ct),xt=at("ProfileId")(ct),fa=at("ApiKeyId")(ct),du=at("WebhookEndpointId")(ct),gn=at("InboxConversationId")(ct),Mn=at("InboxMessageId")(ct),Gc=at("InboxCommentThreadId")(ct),zc=at("InboxCommentId")(ct),jc=at("InboxMentionId")(ct),Km=at("InboxReviewId")(ct),gb=at("InboxAttachmentId")(ct),li=at("InboxActionId")(ct),Nde=at("InboundEventId")(ct),Bde=at("WebhookDeliveryId")(ct),_o=at("AdCampaignId")(ct),ma=at("AdGroupId")(ct),Qc=at("AdCreativeId")(ct),is=at("AdId")(ct),OU=at("AdInsightId")(ct),fi=at("AdOperationId")(ct),PU=at("AdBoostId")(ct),RU=at("AdRequestId")(ct);var _U=(e)=>e,UU=(e)=>e;var xb=Lr.check(xe(1),re(100)),Sb=a.check(xe(1),re(100)).annotate({description:"An IANA time zone such as America/New_York."}),ha=p({id:ce,name:xb,defaultTimezone:Sb,role:G(["owner","member"])}),DU=p({workspaces:_(ha)}),LU=p({name:xb,defaultTimezone:u(Sb).annotate({description:"Default IANA time zone for new queues. Defaults to UTC; existing queues keep their own time zone."})}),Wde=p({name:u(xb),defaultTimezone:u(Sb)}).check(qt(({name:e,defaultTimezone:t})=>e!==void 0||t!==void 0||"Provide a name, a default time zone, or both.")),Gde=p({workspaceId:ce}),MU=Lr.check(xe(1),re(100)),bb=p({id:a.check(D()),email:a,displayName:U(MU)}),FU=p({displayName:U(MU)}),NU=p({deactivated:v(!0)}),BU=p({archived:v(!0)});var Fn=a.check(qe(/^[A-Z]{3}$/)),yt=p({amountMinor:L,currency:Fn}).annotate({identifier:"Money"});var uu=p({estimatedCostMicros:L,estimatedCost:yt,includedRemaining:L,overagePublishes:L,xPublishes:L,blocked:U(p({code:G(["insufficient_credit","spend_cap_reached","billing_inactive"]),nextAction:a}))}).annotate({identifier:"PostBillingEstimate"});var r4=50,KU=100;var $U=a.check(xe(1),re(2048)).annotate({description:"Opaque cursor from a previous list response. Pass nextCursor verbatim."}),St=p({cursor:u($U),limit:u(Lm.check(iu(),Dr({minimum:1,maximum:KU})).annotate({description:`Page size from 1 to ${KU}. Defaults to ${r4}.`}))}).annotate({identifier:"PageQuery"}),We={hasMore:V,nextCursor:u($U)},n4=p({v:v(1),k:a.check(re(512)),id:a.check(xe(1),re(256))}),Zde=wV(n4);var o4=G(["no_targets","schedule_out_of_range","publishing_not_supported","publish_permission_required","duplicate_target","account_not_found","provider_mismatch","account_not_ready","account_unverified","caption_too_long","empty_content","media_required","media_unresolved","media_not_ready","media_count","media_type","media_mime_type","media_too_large","media_upload_required","media_unverified","settings_conflict","tiktok_privacy_unsupported","tiktok_disclosure_required","tiktok_upload_required","tiktok_too_many_mentions","queue_and_time_conflict","invalid_field","account_ambiguous","unsupported_placement","schedule_required","selector_required","selector_conflict"]),so=p({code:o4,path:_(lt([a,L])),message:a}),tue=zz();var ss=["bluesky","facebook","instagram","linkedin","pinterest","reddit","snapchat","tiktok","threads","x","youtube","google_business"],xn=G(ss),i4=[...ss,"meta_ads","google_ads","reddit_ads","pinterest_ads","tiktok_ads","linkedin_ads","snapchat_ads","amazon_ads","openai_ads"],Be=G(i4);var $m=G(["na","eu","fe"]),ar=G(["social_page","social_account","social_board","social_channel","ad_account"]),s4=G(["auth","permission","access_pending","rate_limit","not_found","deleted","conflict","invalid_request","transient","invalid_response","unsupported"]),oue=p({provider:Be,operation:a,kind:s4,providerStatus:u(L),providerCode:u(a),requestId:u(a),retryable:V,retryAfterSeconds:u(L),missingScopes:u(_(a)),detail:u(a)}).annotate({identifier:"ProviderError"}),iue=G(["publish","read_insights","engage","ads"]),a4=p({provider:xn});var Zt=G(ss),Hc=a.check(D()),ao=L.check(Te(1)),Qr=a.check(qe(/^[A-Za-z0-9._~-]{1,128}$/)),fue=p({"idempotency-key":Qr}),mue=p({"idempotency-key":u(Qr)}),qU=86400,Rt=a.check(qe(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,3})?(?:Z|[+-](?:[01]\d|2[0-3]):[0-5]\d)$/),qt((e)=>{let t=new Date(`${e.slice(0,19)}Z`);return Number.isFinite(t.getTime())&&t.toISOString().slice(0,19)===e.slice(0,19)&&Number.isFinite(Date.parse(e))||"Use a valid date and time with Z or an explicit offset"})),yr=G(["feed","reel","story","carousel","video","pin"]),qm=lt([Rt,aU]),c4=p({accountId:H,placement:yr,scheduledAt:u(qm),queueId:u(Hc)}).annotate({identifier:"DestinationSelection"}),hue=p({expectedRevision:ao,scheduledAt:u(Rt),accountIds:u(_(H).check(xe(1),re(50)).annotate({description:"Select every draft placement for these accounts. Use targets for exact selection instead."})),targets:u(_(c4).check(xe(1),re(50)).annotate({description:"Select exact draft destinations and optionally override each schedule. Omit accountIds when using targets."}))}),WU=p({postId:Pt}),Ib=p({postId:Pt,targetId:sr}),yue=p({expectedAttemptId:Wt}),gue=lt([p({expectedAttemptId:Wt,action:v("reschedule"),scheduledAt:Rt}),p({expectedAttemptId:Wt,action:v("reschedule"),queueId:Hc,pinned:u(p({slotId:Hc,occurrenceDate:a.check(qe(/^\d{4}-\d{2}-\d{2}$/))}))}),p({expectedAttemptId:Wt,action:G(["publish_now","cancel"])})]).annotate({identifier:"ScheduleChange"}),p4=u(a),GU={queueId:u(Hc),slotId:u(Hc),assignmentId:u(Hc),occurrenceDate:u(a.check(qe(/^\d{4}-\d{2}-\d{2}$/))),localDate:u(a.check(qe(/^\d{4}-\d{2}-\d{2}$/))),localTime:u(a.check(qe(/^(?:[01]\d|2[0-3]):[0-5]\d$/))),timezone:u(a)},zU={targetId:sr,attemptId:Wt,accountId:H,scheduledAt:p4,...GU},Vc=G(["scheduled","queued","submitting","confirming","published","provider_draft","failed","unresolved","cancelled"]),Wm=lt([v("draft"),Vc]).annotate({identifier:"PostState"}),lu=p({id:a.check(xe(1)),kind:a.check(xe(1))}).annotate({identifier:"DeliveryProviderRef"}),wb=p({...zU,status:Vc}),d4=p({targetId:sr,attemptId:Wt,accountId:H,provider:Zt,placement:yr,status:Vc,scheduledAt:U(a),url:U(a),issue:U(a),canRetry:V,canReconcile:V,...GU}).annotate({identifier:"PublishAcceptedTarget"}),ya=p({postId:Pt,idempotencyKey:Qr,targets:_(d4),warnings:_(so),billing:u(uu)}).annotate({identifier:"PublishAccepted"}),fu=G(["authorization_changed","account_not_ready","credential_unavailable","media_preparation_failed","video_compression_failed","audio_unavailable","provider_rejected","tiktok_settings_unavailable","tiktok_settings_not_allowed","tiktok_processing_failed","submission_uncertain","confirmation_unavailable"]),xue=G(["pending","sending","posted","failed","unresolved"]),Sue=G(["pending","updating","updated","failed","unresolved"]),bue=G(["pending","sending","invited","failed","unresolved"]),u4={...zU,revision:ao,provider:Zt,placement:yr},Gm=p({...u4,status:Vc,providerRef:u(lu),url:u(a),issue:u(fu),canRetry:V,canReconcile:V,nextAction:u(a)}).annotate({identifier:"DeliveryStatus"}),Eb=p({postId:Pt,status:Wm,targets:_(Gm)}),Iue=p({settled:V,post:Eb,retryAfterSeconds:u(L)}).annotate({identifier:"PublishWait"});function jU(e){return e==="draft"||!["scheduled","queued","submitting","confirming"].includes(e)}var l4=p({postId:Pt,isDraft:V,status:Wm,textPreview:a,targetCount:L.check(Te(0)),mediaCount:L.check(Te(0)),revision:ao,createdAt:a,updatedAt:a}).annotate({identifier:"PostSummary"}),QU=p({data:_(l4),...We}).annotate({identifier:"PostList"}),f4=p({delivery:Gm,createdAt:a,updatedAt:a,replacesAttemptId:u(Wt)}).annotate({identifier:"DeliveryAttemptSummary"}),HU=p({currentAttemptId:Wt,data:_(f4),...We}).annotate({identifier:"DeliveryHistory"});var Jc=G(["payg","pro","platform","enterprise"]),zm=G(["month","year"]),jm=G(["fake","stripe"]),mu=G(["active","trialing","past_due","canceled","incomplete","unpaid"]),Qm=G(["confirmed_publish","x_passthrough","managed_ad","inbox_reply","automation_run"]),m4=p({meter:Qm,includedPerPeriod:L,overageUnitPriceMicros:U(L),unitLabel:a}).annotate({identifier:"BillingPlanMeter"}),h4=p({id:Jc,name:a,monthlyPrice:U(yt),annualPrice:U(yt),meters:_(m4),seatsLimit:U(L),analyticsRetentionDays:L,whiteLabelOAuth:V,ssoSaml:V}).annotate({identifier:"BillingPlan"}),VU=p({data:_(h4)}).annotate({identifier:"BillingPlanList"}),y4=p({meter:Qm,includedPerPeriod:L,used:L,billable:L,costMicros:L}).annotate({identifier:"BillingMeterUsage"}),g4=p({monthlySpendCapMicros:U(L),version:L}).annotate({identifier:"BillingSpendControls"}),x4=G(["ok","payment_required","insufficient_credit","spend_cap_reached"]),Ab=p({workspaceId:ce,plan:Jc,status:mu,paymentStatus:x4,interval:U(zm),gateway:jm,periodStart:a,periodEnd:a,cancelAtPeriodEnd:V,creditBalanceMicros:L,creditBalance:yt,spendControls:g4,currentPeriod:p({meters:_(y4),totalVariableSpendMicros:L,seatsUsed:L,seatsLimit:U(L)})}).annotate({identifier:"WorkspaceBilling"}),ga=a.check(qe(/^\d{4}-\d{2}-\d{2}$/)),kb=a.check(qe(/^https?:\/\/[^\s]+$/)),Tue=p({from:u(ga),to:u(ga),meter:u(Qm),provider:u(Zt)}).annotate({identifier:"BillingUsageQuery"}),S4=p({date:ga,meter:Qm,provider:U(Zt),quantity:L,billableQuantity:L,costMicros:L}).annotate({identifier:"BillingUsageDailyPoint"}),JU=p({from:ga,to:ga,totals:p({quantity:L,billableQuantity:L,costMicros:L}),data:_(S4)}).annotate({identifier:"BillingUsage"}),Hm=G(["top_up","auto_top_up","overage_debit","x_passthrough_debit","refund","adjustment"]),Oue=p({kind:u(Hm),from:u(ga),to:u(ga),...St.fields}).annotate({identifier:"BillingLedgerQuery"}),b4=p({id:a.check(D()),kind:Hm,deltaMicros:L,balanceAfterMicros:L,description:a,referenceKind:U(a),referenceId:U(a),createdAt:a}).annotate({identifier:"BillingLedgerEntry"}),YU=p({data:_(b4),...We}).annotate({identifier:"BillingLedgerList"}),Pue=lt([p({mode:v("subscription"),plan:G(["pro","platform"]),interval:zm,returnUrl:u(kb)}),p({mode:v("top_up"),amountMinor:L.check(Te(1000),lU(1e7)),returnUrl:u(kb)})]).annotate({identifier:"CreateBillingCheckout"}),ZU=p({url:a,expiresAt:u(a)}).annotate({identifier:"BillingCheckoutSession"}),Rue=p({returnUrl:u(kb)}).annotate({identifier:"CreateBillingPortal"}),XU=p({url:a}).annotate({identifier:"BillingPortalSession"}),_ue=p({version:L,monthlySpendCapMicros:U(L)}).annotate({identifier:"UpdateBillingSpendControls"});var eD=180,tD=365,oD=["workspace.updated","workspace.archived","workspace.member.role_updated","workspace.member.removed","workspace.invite.created","workspace.invite.resent","workspace.invite.revoked","workspace.invite.accepted","workspace.invite.declined","api_key.created","api_key.updated","api_key.revoked","webhook.endpoint.created","webhook.endpoint.updated","webhook.endpoint.deleted","webhook.delivery.replayed","account.connected","account.reconnected","account.disconnected","account.enabled","account.disabled","account.moved","profile.created","profile.updated","profile.archived","queue.created","queue.updated","queue.paused","queue.resumed","queue.archived","queue.slots.replaced","queue.skip.created","queue.skip.deleted","queue.blackout.created","queue.blackout.deleted","billing.subscription.updated","billing.credit.topped_up","billing.spend_controls.updated"],vb=G(oD).annotate({identifier:"AuditAction"}),iD=["workspace","workspace_member","workspace_invite","workspace_profile","api_key","webhook_endpoint","webhook_delivery","integration_connection","provider_account","schedule_queue","schedule_queue_skip","schedule_queue_blackout","workspace_billing"],Vm=G(iD).annotate({identifier:"AuditTargetKind"}),I4=G(["user","api_key"]).annotate({identifier:"AuditActorType"}),w4=lt([p({type:v("user"),id:os,email:U(a),displayName:U(a)}),p({type:v("api_key"),id:fa,name:U(a),prefix:U(a)})]).annotate({identifier:"AuditActor"}),Cb=p({id:yb,workspaceId:ce,profileId:U(xt),actor:w4,action:vb,targetKind:Vm,targetId:a.check(D()),detail:$t(a,j),createdAt:a}).annotate({identifier:"AuditEvent"}),sD=p({data:_(Cb),...We}).annotate({identifier:"AuditEventList"}),Bue=p({workspaceId:ce,eventId:yb}),rD=lt([Rt,a.check(qe(/^\d{4}-\d{2}-\d{2}$/))]),Kue=p({action:u(vb),targetKind:u(Vm),targetId:u(a.check(D())),actorType:u(I4),actorId:u(a.check(D())),profileId:u(xt),from:u(rD).annotate({description:"Inclusive start instant (ISO 8601 timestamp or YYYY-MM-DD UTC date)."}),to:u(rD).annotate({description:"Inclusive end instant (ISO 8601 timestamp or YYYY-MM-DD UTC date)."}),...St.fields}),E4=p({action:vb,targetKind:Vm,description:a,retentionDays:L}).annotate({identifier:"AuditActionCatalogEntry"}),aD=p({actions:_(E4),targetKinds:_(Vm),retention:p({standardDays:L,spendDays:L})}).annotate({identifier:"AuditActionCatalog"}),nD={"workspace.updated":{targetKind:"workspace",description:"Workspace name or default timezone updated."},"workspace.archived":{targetKind:"workspace",description:"Workspace archived by an owner."},"workspace.member.role_updated":{targetKind:"workspace_member",description:"Workspace member role changed between owner and member."},"workspace.member.removed":{targetKind:"workspace_member",description:"Workspace member removed or left the workspace."},"workspace.invite.created":{targetKind:"workspace_invite",description:"Workspace member invitation created."},"workspace.invite.resent":{targetKind:"workspace_invite",description:"Workspace member invitation token rotated and resent."},"workspace.invite.revoked":{targetKind:"workspace_invite",description:"Pending workspace invitation revoked."},"workspace.invite.accepted":{targetKind:"workspace_invite",description:"Workspace invitation accepted by the invited user."},"workspace.invite.declined":{targetKind:"workspace_invite",description:"A workspace invitation was declined."},"api_key.created":{targetKind:"api_key",description:"Workspace API key created (redacted prefix only)."},"api_key.updated":{targetKind:"api_key",description:"Workspace API key name or scopes updated."},"api_key.revoked":{targetKind:"api_key",description:"Workspace API key revoked."},"webhook.endpoint.created":{targetKind:"webhook_endpoint",description:"Outbound webhook endpoint registered."},"webhook.endpoint.updated":{targetKind:"webhook_endpoint",description:"Outbound webhook endpoint configuration updated."},"webhook.endpoint.deleted":{targetKind:"webhook_endpoint",description:"Outbound webhook endpoint permanently disabled."},"webhook.delivery.replayed":{targetKind:"webhook_delivery",description:"Settled webhook delivery queued for replay."},"account.connected":{targetKind:"provider_account",description:"Social or ad account connected via OAuth."},"account.reconnected":{targetKind:"provider_account",description:"Existing account grant reconnected via OAuth."},"account.disconnected":{targetKind:"integration_connection",description:"Provider connection disconnected and credentials cleared."},"account.enabled":{targetKind:"provider_account",description:"Connected publishing destination enabled."},"account.disabled":{targetKind:"provider_account",description:"Connected publishing destination disabled."},"account.moved":{targetKind:"provider_account",description:"Connected account moved to another workspace profile."},"profile.created":{targetKind:"workspace_profile",description:"Workspace brand profile created."},"profile.updated":{targetKind:"workspace_profile",description:"Workspace brand profile updated."},"profile.archived":{targetKind:"workspace_profile",description:"Workspace brand profile archived."},"queue.created":{targetKind:"schedule_queue",description:"Account schedule queue created."},"queue.updated":{targetKind:"schedule_queue",description:"Account schedule queue configuration updated."},"queue.paused":{targetKind:"schedule_queue",description:"Account schedule queue paused."},"queue.resumed":{targetKind:"schedule_queue",description:"Account schedule queue resumed."},"queue.archived":{targetKind:"schedule_queue",description:"Account schedule queue archived."},"queue.slots.replaced":{targetKind:"schedule_queue",description:"Weekly schedule queue slots replaced."},"queue.skip.created":{targetKind:"schedule_queue_skip",description:"Single queue slot occurrence skipped."},"queue.skip.deleted":{targetKind:"schedule_queue_skip",description:"Skipped queue slot occurrence restored."},"queue.blackout.created":{targetKind:"schedule_queue_blackout",description:"Queue blackout date range created."},"queue.blackout.deleted":{targetKind:"schedule_queue_blackout",description:"Queue blackout date range removed."},"billing.subscription.updated":{targetKind:"workspace_billing",description:"Workspace billing plan or subscription status updated."},"billing.credit.topped_up":{targetKind:"workspace_billing",description:"Workspace prepaid credit balance topped up."},"billing.spend_controls.updated":{targetKind:"workspace_billing",description:"Workspace monthly spend cap or auto-top-up controls updated."}},$ue={actions:oD.map((e)=>({action:e,targetKind:nD[e].targetKind,description:nD[e].description,retentionDays:e.startsWith("billing.")||e.startsWith("ads.")?tD:eD})),targetKinds:[...iD],retention:{standardDays:eD,spendDays:tD}};var Tb=p({workspaceId:ce,deliveryFailures:V,connectionExpiring:V,webhookFailures:V,billingAlerts:V,weeklyDigest:V,updatedAt:U(a)}).annotate({identifier:"NotificationPreferences"}),zue=p({deliveryFailures:u(V),connectionExpiring:u(V),webhookFailures:u(V),billingAlerts:u(V),weeklyDigest:u(V)}).check(qt((e)=>Object.values(e).some((t)=>t!==void 0)||"Provide at least one notification preference to update.")).annotate({identifier:"UpdateNotificationPreferences"});var Yc=G(["owner","member"]).annotate({identifier:"WorkspaceRole"}),k4=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,A4=Lr.pipe(rs(a.check(xe(3),re(320),qe(k4)),cj())).annotate({identifier:"NormalizedEmail",description:"Email address, trimmed and lowercased."}),Jm=p({workspaceId:ce,userId:os,email:a,displayName:U(a),role:Yc,joinedAt:a}).annotate({identifier:"WorkspaceMember"}),cD=p({data:_(Jm),...We}).annotate({identifier:"WorkspaceMemberList"}),Yue=p({role:u(Yc),...St.fields}),Zue=p({workspaceId:ce,userId:os}),Xue=p({role:Yc}).annotate({identifier:"UpdateWorkspaceMemberRole"}),pD=p({removed:v(!0)}).annotate({identifier:"WorkspaceMemberRemoved"}),dD=G(["pending","accepted","revoked","expired"]).annotate({identifier:"WorkspaceInviteStatus"}),Ob=p({id:ui,workspaceId:ce,email:a,role:Yc,status:dD,deliveryState:G(["queued","sending","uncertain","sent"]),remoteRevocationPending:V,invitedByUserId:os,invitedByEmail:U(a),expiresAt:a,acceptedAt:U(a),revokedAt:U(a),createdAt:a}).annotate({identifier:"WorkspaceInvite"}),uD=p({data:_(Ob),...We}).annotate({identifier:"WorkspaceInviteList"}),ele=p({status:u(dD),...St.fields}),tle=p({workspaceId:ce,inviteId:ui}),rle=p({email:A4,role:u(Yc)}).annotate({identifier:"CreateWorkspaceInvite"}),lD=p({invite:Ob}).annotate({identifier:"WorkspaceInviteCreated"}),fD=p({invite:Ob,resendState:G(["sending","sent","uncertain"])}).annotate({identifier:"WorkspaceInviteResent"}),mD=p({revoked:v(!0),remoteRevocationPending:V}).annotate({identifier:"WorkspaceInviteRevoked"}),v4=p({id:ui,workspaceId:ce,workspaceName:a,role:Yc,invitedByEmail:U(a),invitedByName:U(a),expiresAt:a,createdAt:a}).annotate({identifier:"PendingUserInvite"}),hD=p({data:_(v4)}).annotate({identifier:"PendingUserInviteList"}),nle=lt([p({token:Lr.check(xe(1),re(256))}),p({inviteId:ui})]).annotate({identifier:"AcceptWorkspaceInvite"}),yD=p({workspace:ha,membership:Jm}).annotate({identifier:"WorkspaceInviteAccepted"}),gD=p({declined:v(!0),remoteRevocationPending:V}).annotate({identifier:"WorkspaceInviteDeclined"}),ole=p({inviteId:ui});var C4="pubnio_sk_",Pb=new RegExp(`^${C4}[A-Za-z0-9_-]{43}$`),hu=G(["read","publish","engage","ads_read","ads_manage"]),Rb=_(hu).check(xe(1),re(hu.literals.length),qt((e)=>new Set(e).size===e.length||"Choose each scope once.")),_b=Lr.check(xe(1),re(100)),yu=p({id:fa,workspaceId:ce,name:_b,prefix:a,scopes:Rb,createdAt:a,updatedAt:a,expiresAt:U(a),revokedAt:U(a)}).annotate({identifier:"ApiKey"}),dle=p({name:_b,scopes:u(Rb).annotate({description:"Defaults to read. publish permits delivery writes; engage permits inbox replies; ads_read and ads_manage permit ad operations. ads_spend requires a signed-in owner."}),expiresAt:u(Rt)}),ule=p({name:u(_b),scopes:u(Rb)}).check(qt(({name:e,scopes:t})=>e!==void 0||t!==void 0||"Provide a name or scopes."));var lle=hu.literals;var fle=p({workspaceId:ce,keyId:fa}),xD=p({key:yu,secret:a.check(qe(Pb)).annotate({description:"Copy this secret now. This is the only response that returns it."})}),SD=p({data:_(yu),...We}).annotate({identifier:"ApiKeyList"}),bD=p({revoked:v(!0)});var Ym=26214400,Zm=268435456,Xm=16777216,T4=8388608;var xa=a.check(re(2048),qe(/^https:\/\//i),qt((e)=>{let t=URL.parse(e);return Boolean(t?.hostname&&t.protocol==="https:"&&!t.username&&!t.password)||"Expected an HTTPS media URL without credentials"})),ID=p({mediaId:yn}),O4=p({url:xa}),P4=lt([ID,O4]).annotate({identifier:"MediaInput"}),Ub=35,as=_(P4).check(re(Ub)),gu=G(["image","video","document"]),Zc=G(["image/jpeg","image/png","image/gif","image/webp","video/mp4","video/quicktime","video/webm","application/pdf"]);function R4(e,t){let r=(n)=>n.every((o,i)=>e[i]===o);switch(t){case"image/jpeg":return r([255,216,255]);case"image/png":return r([137,80,78,71,13,10,26,10]);case"image/webp":{let n=new TextDecoder().decode(e.subarray(0,12));return n.startsWith("RIFF")&&n.endsWith("WEBP")}case"video/webm":{if(!r([26,69,223,163]))return!1;let n=[66,130,132,119,101,98,109];return e.some((o,i)=>n.every((s,c)=>e[i+c]===s))}case"image/gif":{let n=new TextDecoder().decode(e.subarray(0,6));return n==="GIF87a"||n==="GIF89a"}case"video/mp4":case"video/quicktime":{if(e.length<16)return!1;let n=new TextDecoder().decode(e.subarray(4,12));return n.startsWith("ftyp")&&(t==="video/quicktime"?n==="ftypqt ":n!=="ftypqt ")}case"application/pdf":return r([37,80,68,70,45])}}function wD(e){return Zc.literals.find((t)=>R4(e,t))}var ble=p({workspaceId:ce,mimeType:Zc}),Db=p({mediaId:yn,type:gu,mimeType:Zc,sizeBytes:L.check(Dr({minimum:1,maximum:Zm})),createdAt:a}).annotate({identifier:"MediaAsset"}),ED=p({data:_(Db),...We}).annotate({identifier:"MediaList"}),kD=p({deleted:v(!0)}),Ile=p({url:a.check(xe(1),re(8192))}).annotate({identifier:"MediaImport"}),wle=p({sizeBytes:L.check(Te(1))}).annotate({identifier:"MediaUploadStart"}),AD=Dr({minimum:1,maximum:Math.ceil(Zm/Xm)}),_4=L.check(AD),Ele=p({...ID.fields,partNumber:Lm.check(iu(),AD)}),vD=p({mediaId:yn,partSizeBytes:v(Xm),expiresAt:a}).annotate({identifier:"MediaUploadSession"}),CD=p({partNumber:_4}).annotate({identifier:"MediaPartReceipt"}),TD=p({code:G(["media_source_unavailable","media_storage_unavailable","media_too_large","unsupported_media","upload_expired"]),maxBytes:u(L)}).annotate({identifier:"MediaIntakeIssue"}),U4=G(["awaiting_upload","processing","ready","failed"]),D4=p({receivedPartCount:L.check(Te(0)),partDigests:_(a.check(qe(/^[A-Za-z0-9_-]{43}$/))),expiresAt:a}).annotate({identifier:"MediaUploadProgress"}),Sa=p({mediaId:yn,status:U4,asset:u(Db),issue:u(TD),upload:u(D4),idempotencyKey:u(Qr),retryAfterSeconds:u(L)}).annotate({identifier:"MediaIntake"}),kle=p({mediaId:yn,status:G(["ready","failed","timeout"]),asset:u(Db),issue:u(TD),retryAfterSeconds:u(L)}).annotate({identifier:"MediaWait"}),Ale=p({data:a.check(xe(1),re(Math.ceil(T4/3)*4+4)).annotate({description:"Base64-encoded file bytes. Maximum 8 MiB after decoding."}),mimeType:Zc,filename:u(a.check(xe(1),re(255)))}).annotate({identifier:"MediaInlineUpload"}),OD=G(["part_conflict","part_out_of_order","parts_missing","upload_closed","upload_expired"]);var Lb=["live","beta","upcoming"];var L4=["publish","read_insights","manage_comments"],eh=[...L4,"send_messages"],Sn={bluesky:{label:"Bluesky",availability:"beta",authFamily:"bluesky",accountKinds:["social_account"],capabilities:{social_account:eh},approvalRequired:{},limited:{}},facebook:{label:"Facebook",availability:"live",authFamily:"facebook",accountKinds:["social_page"],capabilities:{social_page:eh},approvalRequired:{},limited:{}},instagram:{label:"Instagram",availability:"live",authFamily:"instagram",accountKinds:["social_account"],capabilities:{social_account:eh},approvalRequired:{},limited:{}},linkedin:{label:"LinkedIn",availability:"live",authFamily:"linkedin",accountKinds:["social_account","social_page"],capabilities:{social_account:["publish","manage_comments"],social_page:["publish","read_insights","manage_comments"]},approvalRequired:{},limited:{}},pinterest:{label:"Pinterest",availability:"live",authFamily:"pinterest",accountKinds:["social_board"],capabilities:{social_board:["publish","read_insights"]},approvalRequired:{},limited:{}},reddit:{label:"Reddit",availability:"upcoming",authFamily:"reddit",accountKinds:["social_account"],capabilities:{social_account:eh},approvalRequired:{},limited:{}},snapchat:{label:"Snapchat",availability:"beta",authFamily:"snapchat",accountKinds:["social_page"],capabilities:{social_page:["publish"]},approvalRequired:{},limited:{}},tiktok:{label:"TikTok",availability:"live",authFamily:"tiktok",accountKinds:["social_account"],capabilities:{social_account:["publish","read_insights"]},approvalRequired:{},limited:{}},threads:{label:"Threads",availability:"upcoming",authFamily:"threads",accountKinds:["social_account"],capabilities:{social_account:["publish","read_insights","manage_comments"]},approvalRequired:{},limited:{}},x:{label:"X",availability:"live",authFamily:"x",accountKinds:["social_account"],capabilities:{social_account:["publish","read_insights","manage_comments","send_messages"]},approvalRequired:{},limited:{}},youtube:{label:"YouTube",availability:"live",authFamily:"youtube",accountKinds:["social_channel"],capabilities:{social_channel:["publish","read_insights"]},approvalRequired:{},limited:{}},google_business:{label:"Google Business Profile",availability:"upcoming",authFamily:"google_business",accountKinds:["social_page"],capabilities:{social_page:["publish","read_insights"]},approvalRequired:{},limited:{}}};var Tle={bluesky:{...Sn.bluesky,publishCapable:!0},facebook:{...Sn.facebook,publishCapable:!0},instagram:{...Sn.instagram,publishCapable:!0},linkedin:{...Sn.linkedin,publishCapable:!0},pinterest:{...Sn.pinterest,publishCapable:!0},reddit:{...Sn.reddit,publishCapable:!0},snapchat:{...Sn.snapchat,publishCapable:!0},tiktok:{...Sn.tiktok,publishCapable:!0},threads:{...Sn.threads,publishCapable:!0},x:{...Sn.x,publishCapable:!0},youtube:{...Sn.youtube,publishCapable:!0},google_business:{...Sn.google_business,publishCapable:!0},meta_ads:{label:"Meta Ads",availability:"live",authFamily:"meta_ads",accountKinds:["ad_account"],capabilities:{ad_account:["ads_read"]},approvalRequired:{},limited:{},publishCapable:!1,integrationState:"connectable"},google_ads:{label:"Google Ads",availability:"live",authFamily:"google_ads",accountKinds:["ad_account"],capabilities:{ad_account:["ads_read"]},approvalRequired:{},limited:{},publishCapable:!1,integrationState:"connectable"},reddit_ads:{label:"Reddit Ads",availability:"live",authFamily:"reddit_ads",accountKinds:["ad_account"],capabilities:{ad_account:["ads_read"]},approvalRequired:{},limited:{},publishCapable:!1,integrationState:"connectable"},pinterest_ads:{label:"Pinterest Ads",availability:"live",authFamily:"pinterest_ads",accountKinds:["ad_account"],capabilities:{ad_account:["ads_read"]},approvalRequired:{},limited:{},publishCapable:!1,integrationState:"connectable"},tiktok_ads:{label:"TikTok Ads",availability:"live",authFamily:"tiktok_ads",accountKinds:["ad_account"],capabilities:{ad_account:["ads_read"]},approvalRequired:{},limited:{},publishCapable:!1,integrationState:"connectable"},linkedin_ads:{label:"LinkedIn Ads",availability:"live",authFamily:"linkedin_ads",accountKinds:["ad_account"],capabilities:{ad_account:["ads_read"]},approvalRequired:{},limited:{},publishCapable:!1,integrationState:"connectable"},snapchat_ads:{label:"Snapchat Ads",availability:"live",authFamily:"snapchat_ads",accountKinds:["ad_account"],capabilities:{ad_account:["ads_read"]},approvalRequired:{},limited:{},publishCapable:!1,integrationState:"connectable"},amazon_ads:{label:"Amazon Ads",availability:"live",authFamily:"amazon_ads",accountKinds:["ad_account"],capabilities:{ad_account:["ads_read"]},approvalRequired:{},limited:{},publishCapable:!1,integrationState:"connectable"},openai_ads:{label:"OpenAI Ads",availability:"beta",authFamily:"openai_ads",accountKinds:["ad_account"],capabilities:{ad_account:["ads_read"]},approvalRequired:{},limited:{},publishCapable:!1,integrationState:"connectable"}},Ole=ss.flatMap((e)=>{let t=Sn[e];return t.accountKinds.map((r)=>({provider:e,availability:t.availability,accountKind:r,capabilities:[...t.capabilities[r]??[]],approvalRequired:[...t.approvalRequired[r]??[]],limited:[...t.limited[r]??[]]}))});var M4=60,F4=3600;var N4={requestsPerMinute:300,publishesPerMinute:30,mediaUploadsPerMinute:10,windowSeconds:60},hi=lt([p({status:G(["ready","disabled","unavailable"])}),p({status:v("needs_reconnect"),reason:G(["disconnected","token_expired"])}),p({status:v("unverified"),reason:G(["scopes_unknown","page_tasks_unknown"])}),p({status:v("permission_required"),reason:v("missing_scope"),missingScopes:_(a)}),p({status:v("permission_required"),reason:v("missing_page_task")})]).annotate({identifier:"AccountReadiness"}),mi=G(["publish","read_insights","manage_comments","send_messages","ads_read","ads_write","ads_spend"]),B4=G(["supported","not_supported","access_pending","permission_missing","unverified","reconnect_required","unavailable"]),Fle=p({scopes:u(_(a)),pageTasks:u(_(a)),roles:u(_(a)),loginMethods:u(_(a))}),yi=p({capability:mi,state:B4,missingScopes:_(a),missingRoles:_(a),reason:u(a)}).annotate({identifier:"AccountCapability"}),K4=p({accountId:H,profileId:xt,provider:Be,accountKind:ar,enabled:V,publishingReadiness:hi,capabilities:_(yi),checkedAt:a}).annotate({identifier:"AccountCapabilities"}),PD=p({capabilities:_(K4)}),Nle=p({workspaceId:ce,profileId:u(xt),accountId:u(H),capability:u(mi)}),$4=p({provider:Be,availability:G(Lb),accountKind:ar,capabilities:_(mi),approvalRequired:_(mi),limited:_(mi)}).annotate({identifier:"CapabilityCatalogEntry"}),RD=p({entries:_($4)}).annotate({identifier:"CapabilityCatalog"}),q4=p({accountId:H,provider:Be,accountKind:ar,name:a,enabled:V,readiness:hi}).annotate({identifier:"AccountSummary"}),Ble=p({accounts:_(q4)}).annotate({identifier:"AccountSummaryList"}),W4=p({requestsPerMinute:L,publishesPerMinute:L,mediaUploadsPerMinute:L,windowSeconds:L}).annotate({identifier:"RateLimits"}),_D=p({uploadMaxBytes:L,assetMaxBytes:L,partMaxBytes:L,types:_(gu)}).annotate({identifier:"MediaLimits"}),Mb=p({targetsPerRequest:L,draftTextCharacters:L,idempotencyTtlSeconds:L,wait:p({defaultSeconds:L,maxSeconds:L}),media:_D,rateLimits:W4}).annotate({identifier:"ApiLimits"}),G4=p({placement:yr,default:V,mediaTypes:_(gu),maxMedia:L,captionCharacters:L}).annotate({identifier:"PlacementCapability"}),z4=p({provider:xn,label:a,availability:G(Lb),accountKinds:_(ar),placements:_(G4),requiredScopes:_(a)}).annotate({identifier:"ProviderCapability"}),UD=p({providers:_(z4),accountKinds:_(ar),media:_D,limits:Mb}).annotate({identifier:"PublishCapabilities"}),Kle={targetsPerRequest:50,draftTextCharacters:128000,idempotencyTtlSeconds:qU,wait:{defaultSeconds:M4,maxSeconds:F4},media:{uploadMaxBytes:Ym,assetMaxBytes:Zm,partMaxBytes:Xm,types:[...gu.literals]},rateLimits:N4};var th=G(["instagram_login","facebook_login","unified_login"]),DD=u(th),j4=lt([p({provider:v("bluesky"),kind:v("account"),handle:a,did:a,service:a}),p({provider:v("facebook"),kind:v("page"),tasks:u(_(a))}),p({provider:v("instagram"),kind:v("professional_account"),username:a,loginMethod:DD,accountType:u(G(["business","creator"])),pageId:u(a),clientBusinessId:u(a),configId:u(a)}),p({provider:v("linkedin"),kind:v("member")}),p({provider:v("linkedin"),kind:v("organization")}),p({provider:v("pinterest"),kind:v("board"),username:u(a)}),p({provider:v("reddit"),kind:v("account"),username:a}),p({provider:v("snapchat"),kind:v("public_profile"),profileId:a,organizationId:u(a),username:u(a)}),p({provider:v("tiktok"),kind:v("account"),username:u(a),isBusiness:u(V)}),p({provider:v("threads"),kind:v("account"),username:u(a)}),p({provider:v("x"),kind:v("account"),username:u(a)}),p({provider:v("youtube"),kind:v("channel")}),p({provider:v("google_business"),kind:v("location")}),p({provider:v("meta_ads"),kind:v("ad_account"),externalId:a,currency:a.check(qe(/^[A-Z]{3}$/)),timezone:a,status:G(["active","disabled","pending","closed","unknown"]),businessId:u(a)}),p({provider:v("google_ads"),kind:v("ad_account"),externalId:a,currency:a.check(qe(/^[A-Z]{3}$/)),timezone:a,status:G(["active","disabled","pending","closed","unknown"]),managerId:u(a),loginCustomerId:u(a)}),p({provider:v("reddit_ads"),kind:v("ad_account"),externalId:a,currency:a.check(qe(/^[A-Z]{3}$/)),timezone:a,status:G(["active","disabled","pending","closed","unknown"]),businessId:u(a)}),p({provider:v("pinterest_ads"),kind:v("ad_account"),externalId:a,currency:a.check(qe(/^[A-Z]{3}$/)),timezone:a,status:G(["active","disabled","pending","closed","unknown"]),businessId:u(a),managerId:u(a)}),p({provider:v("tiktok_ads"),kind:v("ad_account"),externalId:a,currency:a.check(qe(/^[A-Z]{3}$/)),timezone:a,status:G(["active","disabled","pending","closed","unknown"]),businessId:u(a)}),p({provider:v("linkedin_ads"),kind:v("ad_account"),externalId:a,currency:a.check(qe(/^[A-Z]{3}$/)),timezone:a,status:G(["active","disabled","pending","closed","unknown"]),businessId:u(a),managerId:u(a)}),p({provider:v("snapchat_ads"),kind:v("ad_account"),externalId:a,currency:a.check(qe(/^[A-Z]{3}$/)),timezone:a,status:G(["active","disabled","pending","closed","unknown"]),businessId:u(a)}),p({provider:v("amazon_ads"),kind:v("ad_account"),externalId:a,currency:a.check(qe(/^[A-Z]{3}$/)),timezone:a,status:G(["active","disabled","pending","closed","unknown"]),region:$m,businessId:u(a),managerId:u(a)}),p({provider:v("openai_ads"),kind:v("ad_account"),externalId:a,currency:a.check(qe(/^[A-Z]{3}$/)),timezone:a,status:G(["active","disabled","pending","closed","unknown"])})]);var Xc=p({id:H,profileId:xt,connectionId:a.check(D()),provider:Be,accountKind:ar,parentAccountId:U(H),name:a,enabled:V,available:V,details:j4,readiness:hi,capabilities:_(yi)}).annotate({identifier:"ProviderAccount"}),Fb=p({accounts:_(Xc)}),Q4=p({id:H,enabled:V});var rh=a.check(D()),Bb=p({attemptId:rh}),xu=p({accountId:H}),LD=p({connectionId:rh}),Kb=p({attemptId:rh,url:a,expiresAt:u(a)}),H4=G(["provider_error","invalid_callback","account_mismatch","connection_changed","connection_failed"]),Nb={attemptId:rh,provider:Be},MD=lt([p({...Nb,status:G(["pending","denied","expired"])}),p({...Nb,status:v("connected"),accountIds:_(H)}),p({...Nb,status:v("failed"),reason:H4})]).annotate({identifier:"ConnectionStatus"}),FD=p({disconnected:v(!0)}),V4=p({handle:Lr.check(xe(1),re(253)),appPassword:Lr.check(xe(1),re(256)),service:u(a.check(re(2048),qe(/^https:\/\//i)))}).annotate({identifier:"BlueskyConnect"}),Jle=p({...V4.fields,accountId:u(H),profileId:u(xt)}).annotate({identifier:"BlueskySessionConnect"}),ND=p({used:L.check(Te(0)),limit:L.check(Ro(0)),windowSeconds:L.check(Ro(0))}).annotate({identifier:"InstagramPublishingLimit"}),nh=G(["music","original_sound"]),ep=a.check(qe(/^\d{1,32}$/)),Yle=p({...xu.fields,audioId:ep}),Zle=p({audioType:nh,q:u(Lr.check(xe(1),re(200)))}),$b=p({audioId:ep,audioType:nh,title:a,durationMs:u(L.check(Te(0))),artist:u(a),creator:u(a),previewUrl:u(a),coverUrl:u(a),instagramPreviewUrl:u(a)}).annotate({identifier:"InstagramAudio"}),BD=p({audio:_($b)});var Wb=128000;var zb=1250,J4=300;var KD=500,Y4=100,Z4=1e5,qb=50;var cs=a.check(re(Wb)),qD=L.check(Te(1)),ffe=p({workspaceId:ce,isDraft:u(V).annotate({description:"Filter to drafts (true) or submitted posts (false)."}),accountId:u(H).annotate({description:"Filter to posts targeting this connected account (applies to both drafts and submitted posts; pairs with deliveryStatus on the same target)."}),profileId:u(xt).annotate({description:"Filter to posts targeting any account in this workspace profile."}),...St.fields}),X4=Ub,Ar={text:u(cs),media:u(as),scheduledAt:u(qm),queueId:u(a.check(D()).annotate({description:"Assign this destination to its connected account's schedule queue."}))},Su=a.check(qe(/^\d+$/)),eJ=_(a.check(qe(/^[A-Z]{2}$/))).check(xe(1),re(25)),WD={firstComment:u(cs),thread:u(_(a.check(xe(1),re(zb))).check(re(24))),nativeDraft:u(V),countries:u(eJ)},GD=p({...WD,link:u(xa),textFormatPresetId:u(Su),albumId:u(Su)}).annotate({identifier:"FacebookFeedSettings"}),zD=p({...WD,title:u(cs),isAiGenerated:u(V),collaboratorPageIds:u(_(Su).check(xe(1),re(10),qt((e)=>new Set(e).size===e.length||"Choose each collaborator Page once")))}).annotate({identifier:"FacebookReelSettings"}),jD=p({isAiGenerated:u(V)}).annotate({identifier:"FacebookStorySettings"}),Gb=a.check(qe(/^@?[a-zA-Z0-9._]{1,30}$/)),$D=mr.check(Dr({minimum:0,maximum:1})),tJ=p({username:Gb,x:u($D),y:u($D)}),QD={isAiGenerated:u(V)},jb={...QD,firstComment:u(cs),commentsEnabled:u(V),collaborators:u(_(Gb).check(re(3))),locationId:u(Su),isPaidPartnership:u(V),brandedContentSponsors:u(_(lt([Su,Gb])).check(xe(1),re(2)))},oh=u(_(tJ).check(re(20))),HD=u(a.check(re(1000))),VD=p({...jb,altText:HD,userTags:oh}).annotate({identifier:"InstagramFeedSettings"}),JD=p({...jb,shareToFeed:u(V),muteAudio:u(V),audioConfiguration:u(p({audioId:ep,audioVolume:u(L.check(Dr({minimum:1,maximum:100}))),videoVolume:u(L.check(Dr({minimum:0,maximum:100})))})),coverUrl:u(xa),thumbOffset:u(L.check(Te(0))),audioName:u(a.check(re(255))),trial:u(p({graduationStrategy:G(["MANUAL","SS_PERFORMANCE"])})),userTags:oh}).annotate({identifier:"InstagramReelSettings"}),YD=p({...jb,muteAudio:u(V),slides:u(_(p({altText:HD,userTags:oh})).check(re(20)))}).annotate({identifier:"InstagramCarouselSettings"}),ZD=p({...QD,muteAudio:u(V),userTags:oh}).annotate({identifier:"InstagramStorySettings"}),XD=p({firstComment:u(a.check(xe(1),re(300))),thread:u(_(a.check(xe(1),re(300))).check(re(24))),altText:u(a.check(re(1000)))}).annotate({identifier:"BlueskyFeedSettings"}),eL=p({firstComment:u(cs),thread:u(_(a.check(xe(1),re(zb))).check(re(24))),visibility:u(G(["PUBLIC","CONNECTIONS"])),altText:u(a.check(re(4086))),documentTitle:u(Lr.check(xe(1),re(100)))}).annotate({identifier:"LinkedInFeedSettings"}),tL=p({title:u(a.check(xe(1),re(100))),description:u(a.check(xe(1),re(800))),link:u(xa),altText:u(a.check(re(500)))}).annotate({identifier:"PinterestPinSettings"}),rJ=a.check(qe(/^(?:r\/)?[A-Za-z0-9_]{2,21}$/)),rL=p({subreddit:rJ,title:a.check(xe(1),re(J4)),link:u(xa),flairId:u(a.check(xe(1),re(100))),flairText:u(a.check(xe(1),re(64))),nsfw:u(V),spoiler:u(V),sendReplies:u(V),thumbnailMediaId:u(yn),firstComment:u(cs)}).annotate({identifier:"RedditFeedSettings"}),nL=p({contentType:u(G(["story","saved_story","spotlight"])),title:u(a.check(xe(1),re(45))),description:u(a.check(xe(1),re(160))),link:u(xa),locale:u(a.check(qe(/^[a-z]{2}_[A-Z]{2}$/)))}).annotate({identifier:"SnapchatStorySettings"}),oL=p({title:a.check(xe(1),re(100)),description:u(a.check(re(5000))),privacyStatus:G(["public","unlisted","private"]),tags:u(_(a.check(re(100))).check(re(30))),categoryId:u(a.check(qe(/^\d{1,3}$/))),madeForKids:u(V),containsSyntheticMedia:u(V),thumbnailMediaId:u(yn),notifySubscribers:u(V),license:u(G(["youtube","creativeCommon"])),embeddable:u(V),publicStatsViewable:u(V)}).annotate({identifier:"YouTubeVideoSettings"}),nJ=p({title:a.check(xe(1),re(Y4)),content:a.check(xe(1),re(Z4))}).annotate({identifier:"XArticleDraftSettings"}),iL=p({firstComment:u(cs),thread:u(_(a.check(xe(1),re(280))).check(re(24))),article:u(nJ)}).annotate({identifier:"XFeedSettings"}),sL=p({}).annotate({identifier:"GoogleBusinessFeedSettings"}),aL=p({firstComment:u(a.check(xe(1),re(KD))),thread:u(_(a.check(xe(1),re(KD))).check(re(24)))}).annotate({identifier:"ThreadsFeedSettings"}),cL={privacy:G(["PUBLIC_TO_EVERYONE","MUTUAL_FOLLOW_FRIENDS","FOLLOWER_OF_CREATOR","SELF_ONLY"]),commercialDisclosure:u(G(["none","own_brand","paid_partnership"])),isAiGenerated:u(V),disableComment:u(V),nativeDraft:u(V)},oJ=p({...cL,format:u(v("video")),disableDuet:u(V),disableStitch:u(V)}).annotate({identifier:"TikTokVideoSettings"}),iJ=p({...cL,format:v("photo"),title:u(a.check(re(90))),coverIndex:u(L.check(Dr({minimum:0,maximum:X4-1}))),autoAddMusic:u(V)}).annotate({identifier:"TikTokPhotoSettings"}),pL=lt([oJ,iJ]).annotate({identifier:"TikTokFeedSettings"}),dL=lt([p({accountId:H,provider:v("bluesky"),placement:v("feed"),...Ar,settings:u(XD)}),p({accountId:H,provider:v("facebook"),placement:v("feed"),...Ar,settings:u(GD)}),p({accountId:H,provider:v("facebook"),placement:v("reel"),...Ar,settings:u(zD)}),p({accountId:H,provider:v("facebook"),placement:v("story"),...Ar,settings:u(jD)}),p({accountId:H,provider:v("instagram"),placement:v("feed"),...Ar,settings:u(VD)}),p({accountId:H,provider:v("instagram"),placement:v("reel"),...Ar,settings:u(JD)}),p({accountId:H,provider:v("instagram"),placement:v("carousel"),...Ar,settings:u(YD)}),p({accountId:H,provider:v("instagram"),placement:v("story"),...Ar,settings:u(ZD)}),p({accountId:H,provider:v("linkedin"),placement:v("feed"),...Ar,settings:u(eL)}),p({accountId:H,provider:v("threads"),placement:v("feed"),...Ar,settings:u(aL)}),p({accountId:H,provider:v("x"),placement:v("feed"),...Ar,settings:u(iL)}),p({accountId:H,provider:v("youtube"),placement:v("video"),...Ar,settings:oL}),p({accountId:H,provider:v("pinterest"),placement:v("pin"),...Ar,settings:u(tL)}),p({accountId:H,provider:v("reddit"),placement:v("feed"),...Ar,settings:rL}),p({accountId:H,provider:v("snapchat"),placement:v("story"),...Ar,settings:u(nL)}),p({accountId:H,provider:v("tiktok"),placement:v("feed"),...Ar,settings:u(pL)}),p({accountId:H,provider:v("google_business"),placement:v("feed"),...Ar,settings:u(sL)})]).annotate({identifier:"PublishTarget"}),mfe=es(dL,{onExcessProperty:"error"}),sJ=a.check(xe(1),re(zb)),aJ=_(sJ).check(xe(1),re(24)),cJ=lt([XD,GD,zD,jD,VD,JD,YD,ZD,eL,rL,nL,aL,iL,oL,tL,pL,sL]),pJ=p({accountId:H,provider:u(xn),placement:u(yr),text:u(cs),thread:u(aJ),media:u(as),scheduledAt:u(qm),queueId:u(a.check(D()).annotate({description:"Assign this destination to its connected account's schedule queue."})),settings:u(cJ)}).annotate({identifier:"CreatePostTarget"}),Qb=Lr.check(re(Wb)).pipe(gV({description:`At most ${Wb} characters after trimming.`})),uL=_(dL).check(re(50)),Hb={text:u(Qb),targets:u(uL),media:u(as)},hfe=p(Hb).annotate({identifier:"PostContent"}),yfe=p({...Hb,scheduledAt:u(Rt)}).annotate({identifier:"PostPreflight"}),lL=p({text:u(Qb),platforms:u(_(xn).check(xe(1),re(qb))),accounts:u(_(H).check(xe(1),re(qb))),targets:u(_(pJ).check(xe(1),re(qb))),media:u(as),scheduledAt:u(Rt),publishNow:u(V),isDraft:u(V).annotate({description:"Save the post as a draft without submitting it. Defaults to false."})}).annotate({identifier:"CreatePost"}).annotate({description:"Send exactly one selector for a direct post: platforms resolves the single ready account per provider, accounts selects exact account IDs, and targets selects exact destinations. Provider and placement are derived when omitted. publishNow defaults to true when scheduledAt is absent. Set isDraft to true to save a draft without submitting; drafts accept text, media, and targets."}),dJ=p({...Hb,expectedRevision:u(qD)}).annotate({identifier:"UpdatePost"}),tp=p({postId:Pt,isDraft:V,revision:qD,text:Qb,media:as,targets:uL,deliveries:_(Gm),status:Wm,createdAt:a,updatedAt:a}).annotate({identifier:"Post"}),gfe=p({...tp.fields,idempotencyKey:u(Qr)}).annotate({identifier:"PostCreated"}),xfe=lt([tp,ya]).annotate({identifier:"PostCreateResult"}),fL=p({archived:v(!0)}),Sfe=es(dJ,{onExcessProperty:"error"}),uJ=p({accountId:H,provider:xn,placement:yr,canPublish:V,caption:p({count:L,limit:L}),errors:_(so),warnings:_(so)}),mL=p({canPublish:V,errors:_(so),warnings:_(so),targets:_(uJ),billing:u(uu)}).annotate({identifier:"PostValidation"});var co=a.check(D()),Xt=co,hL=co,ih=Lr.check(xe(1),re(100)),rp=a.check(xe(1),re(100)),yL=L.check(Dr({minimum:0,maximum:6})),sh=a.check(qe(/^(?:[01]\d|2[0-3]):[0-5]\d$/)),lJ=50,bn=a.check(qe(/^\d{4}-\d{2}-\d{2}$/)),fJ=p({id:u(co).annotate({description:"Round-trip an existing slot ID. Omit to create a new slot; a removed slot reports no ID."}),dayOfWeek:yL,time:sh}).annotate({identifier:"QueueSlotInput"}),mJ=p({id:co,dayOfWeek:yL,time:sh}).annotate({identifier:"QueueSlot"}),gL=_(fJ).check(re(lJ)),hJ=p({maxPerDay:U(L.check(Te(1))).annotate({description:"Null uses the provider limit."}),maxPending:L.check(Te(1)),minGapSeconds:L.check(Te(1)),horizonDays:L.check(Dr({minimum:1,maximum:90})),providerMaxPerDay:L.check(Te(1)),providerMinGapSeconds:L.check(Te(1))}).annotate({identifier:"QueueLimits"}),yJ=G(["active","paused","archived"]),np=p({id:Xt,workspaceId:ce,accountId:H,name:ih,timezone:rp,status:yJ,isDefault:V.annotate({description:"The queue nextSlot assignment uses for this account when none is given."}),limits:hJ,slots:_(mJ),version:L.check(Te(1)),pausedAt:U(a),archivedAt:U(a),createdAt:a,updatedAt:a}).annotate({identifier:"Queue"}),xL=p({data:_(np),...We}).annotate({identifier:"QueueList"}),SL=p({archived:v(!0),version:L.check(Te(1))}).annotate({identifier:"QueueArchived"}),bL={maxPending:u(L.check(Dr({minimum:1,maximum:1000}))),minGapSeconds:u(L.check(Dr({minimum:60,maximum:604800}))),horizonDays:u(L.check(Dr({minimum:1,maximum:90})))},IL=p({accountId:H,name:ih,timezone:u(rp).annotate({description:"An IANA time zone such as America/New_York. Defaults to the workspace default time zone."}),slots:gL,isDefault:u(V).annotate({description:"Promote this queue to the account default. The first active queue is always the default."}),maxPerDay:u(L.check(Dr({minimum:1,maximum:1000}))).annotate({description:"Defaults to the provider limit."}),...bL}).annotate({identifier:"CreateQueue"}),wL=p({expectedVersion:L.check(Te(1)),name:u(ih),timezone:u(rp),paused:u(V),isDefault:u(V).annotate({description:"Promote or demote the account default. Demoting the current default requires promoting another queue first."}),maxPerDay:u(U(L.check(Dr({minimum:1,maximum:1000})))),...bL}).annotate({identifier:"UpdateQueue"}),EL=p({expectedVersion:L.check(Te(1)),slots:gL}).annotate({identifier:"ReplaceQueueSlots"}),kL=G(["paused","archived","account_not_ready"]),AL=G(["max_per_day","max_pending"]),gJ=G(["occupied","capacity","skipped","blacked_out"]),vL=p({queueId:Xt,slotId:U(co),scheduledFor:a.annotate({description:"The resolved UTC instant."}),occurrenceDate:bn.annotate({description:"The local date the assignment counts toward."}),localDate:bn,localTime:sh,timezone:rp,available:V,unavailableReason:u(gJ)}).annotate({identifier:"QueueOccurrence"}),CL=p({queueId:Xt,occurrence:U(vL),horizonEndsAt:a}).annotate({identifier:"QueueNextSlot"}),TL=p({queueId:Xt,timezone:rp,horizonEndsAt:a,occurrences:_(vL)}).annotate({identifier:"QueueSlotPreview"}),xJ=G(["published_now","cancelled","archived","submitted","rescheduled"]),Cfe=p({id:hL,queueId:Xt,slotId:U(co),postId:Pt,targetId:sr,attemptId:Wt,scheduledFor:a,occurrenceDate:bn,releasedAt:U(a),releaseReason:U(xJ)}).annotate({identifier:"QueueAssignment"}),bu=co,ah=co,OL=p({slotId:co,occurrenceDate:bn}).annotate({identifier:"SkipQueueSlot"}),Vb=p({id:bu,queueId:Xt,slotId:co,occurrenceDate:bn,createdAt:a}).annotate({identifier:"QueueSkip"}),PL=p({data:_(Vb),...We}).annotate({identifier:"QueueSkipList"}),RL=Lr.check(re(200)).annotate({description:"Optional note for why these dates are unavailable."}),_L=p({startsOn:bn,endsOn:bn,reason:u(RL)}).annotate({identifier:"CreateQueueBlackout"}),Jb=p({id:ah,queueId:Xt,startsOn:bn,endsOn:bn,reason:U(RL),createdAt:a}).annotate({identifier:"QueueBlackout"}),UL=p({data:_(Jb),...We}).annotate({identifier:"QueueBlackoutList"}),Yb=p({deleted:v(!0)}).annotate({identifier:"QueueDeleted"});var SJ=G(["scheduled","queued"]),bJ=p({postId:Pt,targetId:sr,attemptId:Wt,accountId:H,provider:Zt,placement:yr,queueId:u(Xt),slotId:u(co),assignmentId:u(hL),queueName:u(ih),scheduledFor:a.annotate({description:"The queued attempt's UTC instant."}),occurrenceDate:u(bn),timezone:u(rp),localDate:u(bn),localTime:u(sh),status:SJ.annotate({description:"scheduled when scheduledFor is in the future; queued otherwise."}),textPreview:a.check(re(160)).annotate({description:"Short single-line preview of the post text."})}).annotate({identifier:"ScheduleEntry"}),DL=p({data:_(bJ),...We}).annotate({identifier:"ScheduleList"}),Tfe=p({results:_(p({index:L.check(Te(0)),accepted:u(ya),problem:u(a)}))}).annotate({identifier:"BulkPublishResult"}),IJ=G(["invalid_timezone","invalid_slot_time","duplicate_slot","too_many_slots","slot_gap_too_short","limit_above_provider_default","queue_account_mismatch","queue_and_time_conflict","queue_archived","occurrence_in_past","occurrence_outside_horizon","invalid_blackout_range"]),LL=p({code:IJ,path:_(lt([a,L])),message:a}).annotate({identifier:"QueueIssue"}),Ofe=p({workspaceId:ce,accountId:u(H),...St.fields}),Pfe=p({workspaceId:ce}),Rfe=p({workspaceId:ce,expectedVersion:Lm.check(iu(),Te(1))}),_fe=p({workspaceId:ce,after:u(Rt)}),Ufe=p({workspaceId:ce,count:Lm.check(iu(),Dr({minimum:1,maximum:100})),after:u(Rt),includeOccupied:u(V)}),Dfe=p({workspaceId:ce,...St.fields}),Lfe=p({workspaceId:ce,...St.fields}),Mfe=p({workspaceId:ce,from:Rt.annotate({description:"Inclusive ISO start instant."}),to:Rt.annotate({description:"Inclusive ISO end instant, after from and within 90 days."}),accountId:u(H),queueId:u(Xt),...St.fields}),Ffe=p({queueId:Xt,skipId:bu}),Nfe=p({queueId:Xt,blackoutId:ah});var wJ=G(["queued","running","succeeded","partial","failed","cancelled"]),EJ=G(["active","backoff","paused","inaccessible","deleted","complete"]),ML=a.check(D()),FL=a.check(D()),Zb=p({id:ML,workspaceId:ce,cursorId:FL,domain:a,provider:a,subjectKind:a,subjectId:a.check(D()),scope:a,status:wJ,startedAt:a,finishedAt:U(a),requestCount:L,pageCount:L,errorKind:U(a),providerStatus:U(L),retryAfterSeconds:U(L),detail:U($t(a,j)),createdAt:a}).annotate({identifier:"SyncRun"}),qfe=p({cursorId:U(FL),state:EJ,lastSuccessAt:U(a),nextDueAt:U(a),syncRunId:U(ML)}).annotate({identifier:"SyncResource"});var ps="/api/v1/inbox",Yfe=`${ps}/conversations`,Zfe=`${ps}/comments`,Xfe=`${ps}/mentions`,kJ=`${ps}/reviews`,eme=`${kJ}/:reviewId`,tme=`${ps}/unread-count`,rme=`${ps}/capabilities`,nme=`${ps}/sync`,ome=`${ps}/attachments`,AJ=G(["conversation","message","comment_thread","comment","mention"]),NL=G(["inbox","message_request","spam","other"]),eI=G(["active","archived"]),tI=G(["inbound","outbound"]),vJ=G(["received","pending","sending","sent","delivered","failed","unresolved","deleted"]),rI=G(["text","media","template","interactive","system","unknown"]),CJ=G(["post","comment","story","other"]),TJ=G(["image","video","audio","file","unknown"]),OJ=G(["pending","succeeded","failed","unresolved"]),PJ=G(["list","read","send","reply","edit","delete","hide","unhide","like","unlike"]),RJ=G(["webhook","polling","webhook_with_reconciliation"]),Iu=p({externalId:a,name:U(a),handle:U(a)}).annotate({identifier:"InboxParticipant"}),nI=G(["none","24_hours","x_dm_30_days"]),BL=p({open:V,policy:nI,endsAt:U(a)}).annotate({identifier:"InboxReplyWindow"}),_J=G(["fresh","stale","pending","failed"]),oI=p({status:_J,observedAt:U(a),nextDueAt:U(a),syncRunId:U(a)}).annotate({identifier:"InboxFreshness"}),UJ=p({id:gb,messageId:Mn,kind:TJ,mimeType:U(a),sizeBytes:U(L),width:U(L),height:U(L),durationSeconds:U(mr),url:a.annotate({description:"Workspace-scoped PubNio attachment URL. It never contains a provider URL or token."}),createdAt:a}).annotate({identifier:"InboxAttachment"}),iI=p({id:Mn,conversationId:gn,accountId:H,provider:Be,direction:tI,state:vJ,kind:rI,text:U(a),sender:Iu,replyToMessageId:U(Mn),attachments:_(UJ),actionId:U(li),providerCreatedAt:a,providerUpdatedAt:U(a),readAt:U(a),deletedAt:U(a),createdAt:a}).annotate({identifier:"InboxMessage"}),ch=p({id:gn,workspaceId:ce,accountId:H,provider:Be,participant:Iu,folder:NL,status:eI,unreadCount:L,lastMessageAt:U(a),lastInboundAt:U(a),lastOutboundAt:U(a),lastMessagePreview:U(a),providerUrl:U(a),lastReadAt:U(a),archivedAt:U(a),replyWindow:BL,freshness:oI,createdAt:a}).annotate({identifier:"InboxConversation"}),ph=p({id:zc,threadId:Gc,accountId:H,provider:Be,parentCommentId:U(zc),author:Iu,text:U(a),likeCount:L,replyCount:L,likedByAccount:V,hidden:V,canReply:V,canHide:V,canLike:V,canDelete:V,permalink:U(a),actionId:U(li),providerCreatedAt:a,providerUpdatedAt:U(a),deletedAt:U(a),createdAt:a}).annotate({identifier:"InboxComment"}),KL=p({id:Gc,workspaceId:ce,accountId:H,provider:Be,providerPostId:a,postId:U(a.check(D())),permalink:U(a),caption:U(a),commentCount:L,unreadCount:L,lastCommentAt:U(a),lastReadAt:U(a),freshness:oI,createdAt:a}).annotate({identifier:"InboxCommentThread"}),DJ=p({id:jc,workspaceId:ce,accountId:H,provider:Be,kind:CJ,author:Iu,text:U(a),permalink:U(a),parentExternalId:U(a),canReply:V,freshness:oI,providerCreatedAt:a,deletedAt:U(a),createdAt:a}).annotate({identifier:"InboxMention"}),LJ=G(["positive","negative"]),sI=p({id:Km,workspaceId:ce,accountId:H,provider:Be,locationExternalId:U(a),author:Iu,rating:U(L.check(Dr({minimum:1,maximum:5}))),recommendation:U(LJ),text:U(a),permalink:U(a),providerCreatedAt:a,providerUpdatedAt:U(a),repliedAt:U(a),replyText:U(a),canReply:V,deletedAt:U(a),createdAt:a}).annotate({identifier:"InboxReview"}),$L=p({data:_(ch),...We}).annotate({identifier:"InboxConversationList"}),qL=p({data:_(iI),...We}).annotate({identifier:"InboxMessageList"}),WL=p({data:_(KL),...We}).annotate({identifier:"InboxCommentThreadList"}),GL=p({thread:KL,data:_(ph),...We}).annotate({identifier:"InboxCommentThreadDetail"}),zL=p({data:_(DJ),...We}).annotate({identifier:"InboxMentionList"}),jL=p({data:_(sI),...We}).annotate({identifier:"InboxReviewList"}),QL=p({unreadCount:L}).annotate({identifier:"InboxUnreadCount"}),Xb=p({resource:AJ,supported:V,operations:_(PJ),attachments:V,quickReplies:V,buttons:V,readReceipts:V,moderation:V,syncMode:RJ,backfillDays:L,missingScopes:_(a),missingTasks:_(a)}).annotate({identifier:"InboxChannelCapability"}),MJ=p({accountId:H,profileId:a.check(D()),provider:Be,accountKind:ar,enabled:V,publishingReadiness:hi,accountCapabilities:_(yi),messaging:Xb,comments:Xb,mentions:Xb,replyWindow:BL,lastSyncError:U(a),checkedAt:a}).annotate({identifier:"InboxAccountCapabilities"}),HL=p({accounts:_(MJ)}).annotate({identifier:"InboxCapabilities"}),ime=p({workspaceId:ce,accountId:u(H)}),sme=p({workspaceId:ce,conversationId:gn}),ame=p({workspaceId:ce,threadId:Gc}),cme=p({workspaceId:ce,commentId:zc}),pme=p({workspaceId:ce,mentionId:jc}),dme=p({workspaceId:ce,attachmentId:gb}),ume=p({workspaceId:ce,accountId:u(H),provider:u(Be),status:u(eI),folder:u(NL),unread:u(V),search:u(a.check(re(200))),...St.fields}),lme=p({workspaceId:ce,order:u(G(["oldest","newest"])),...St.fields}),fme=p({workspaceId:ce,accountId:u(H),postId:u(a.check(D())),providerPostId:u(a),unread:u(V),...St.fields}),mme=p({workspaceId:ce,...St.fields}),hme=p({workspaceId:ce,accountId:u(H),provider:u(Be),...St.fields}),yme=p({workspaceId:ce,accountId:u(H),includeDeleted:u(V),...St.fields}),gme=p({status:u(eI),read:u(V)}).check(qt(({status:e,read:t})=>e!==void 0||t!==void 0||"Provide status or read.")),aI=Lr.check(xe(1),re(1e4)),xme=p({text:aI}).annotate({identifier:"SendInboxMessage"}),Sme=p({text:aI}).annotate({identifier:"ReplyInboxComment"}),bme=p({text:aI}).annotate({identifier:"ReplyInboxReview"}),Ime=p({hidden:u(V),liked:u(V)}).check(qt(({hidden:e,liked:t})=>e!==void 0!==(t!==void 0)||"Provide exactly one of hidden or liked for one provider call.")),wme=p({"idempotency-key":Qr}),VL=p({deleted:v(!0),actionId:li}).annotate({identifier:"InboxDeleted"}),JL=p({mentionId:jc,actionId:li,status:OJ,providerResultId:U(a)}).annotate({identifier:"InboxMentionReply"}),Eme=p({workspaceId:ce,accountId:u(H)}),YL=p({syncRunId:a.check(D()),status:Zb.fields.status}).annotate({identifier:"InboxSyncAccepted"}),ZL=p({syncRun:Zb,counts:p({conversations:L,messages:L,commentThreads:L,comments:L,mentions:L})}).annotate({identifier:"InboxSyncStatus"}),kme=p({workspaceId:ce,syncRunId:a.check(D())});var wu=G(["post","comment"]);var FJ=Lr.check(xe(1)),Rme=p({accountId:u(H).annotate({description:"Account that comments; derived when unambiguous."}),provider:u(xn),target:a.check(xe(1),re(2048)).annotate({description:"Provider ID or permalink."}),targetKind:u(wu),text:FJ.annotate({description:"Max 8000 characters."})}).annotate({identifier:"CreateComment"}),_me=p({actionId:li,idempotencyKey:Qr,commentId:a.check(xe(1)),target:a,targetId:a.check(xe(1)),targetKind:wu,accountId:H,provider:xn,status:v("posted"),permalink:u(a),replayed:V}).annotate({identifier:"CommentCreated"});var NJ=["meta_ads","google_ads","reddit_ads","pinterest_ads","tiktok_ads","linkedin_ads","snapchat_ads","amazon_ads","openai_ads"],Ct=G(NJ);var BJ=G(["available","selected"]),cI=G(["active","disabled","pending","closed","unknown"]),KJ=p({provider:Ct,kind:v("ad_account"),externalId:a,currency:Fn,timezone:a,status:cI,businessId:u(a),managerId:u(a),loginCustomerId:u(a),region:u($m)}).annotate({identifier:"AdAccountDetails"}),$J=p({configured:V,killSwitchActive:V,monthlyCap:U(yt),dailyCap:U(yt),maxCampaignDailyBudget:U(yt),maxCampaignLifetimeBudget:U(yt),revision:L.check(Te(0))}).annotate({identifier:"AdAccountPolicy"}),po=p({code:a,message:a,field:u(a),providerCode:u(a),missingScopes:u(_(a)),retryable:V,providerMessage:u(a)}).annotate({identifier:"AdIssue"}),ds=G(["draft","paused","activating","active","pending_review","rejected","completed","archived","unknown"]),us=p({amountMinor:L.check(Te(0)),currency:Fn,kind:G(["daily","lifetime"])}).annotate({identifier:"AdBudget"}),uh=p({accountId:H,currency:Fn,configured:V,monthlyCap:U(yt),dailyCap:U(yt),maxCampaignDailyBudget:U(yt),maxCampaignLifetimeBudget:U(yt),killSwitchActive:V,killSwitchAt:U(a),killSwitchReason:U(a),revision:L.check(Te(0)),updatedAt:a}).annotate({identifier:"AdSpendPolicy"}),dh=U(yt),Gme=p({expectedRevision:L.check(Te(0)),monthlyCap:dh,dailyCap:dh,maxCampaignDailyBudget:dh,maxCampaignLifetimeBudget:dh}).annotate({identifier:"AdSpendPolicyUpdate"}),zme=p({active:V,reason:u(a.check(re(500)))}).annotate({identifier:"AdKillSwitchInput"}),XL=p({policy:uh,changed:V,paused:p({campaigns:L.check(Te(0)),adGroups:L.check(Te(0)),ads:L.check(Te(0))}),nextAction:a}).annotate({identifier:"AdKillSwitchResult"}),lh=G(["boost.create","campaign.create","campaign.activate","campaign.pause","campaign.archive","ad_group.status","ad_group.create","ad.status","ad.attach","creative.create","campaign.duplicate","budget.update"]),ku=G(["queued","preflight","creating","recording","reviewing","activating","succeeded","partial","failed","unresolved","cancelled"]),qJ=G(["queued","preflight","create","record","review","activate","finish"]),nn=p({id:fi,accountId:H,kind:lh,status:ku,step:qJ,input:$t(a,j),result:U($t(a,j)),issues:_(po),attempts:L.check(Te(0)),canRetry:V,nextAction:a,createdAt:a,updatedAt:a,startedAt:U(a),completedAt:U(a)}).annotate({identifier:"AdOperation"}),jme=p({id:RU,accountId:H,idempotencyKey:a,intentHash:a,requestedByType:G(["user","api_key"]),requestedByUserId:U(os),requestedByApiKeyId:U(fa),operationId:U(fi),createdAt:a}).annotate({identifier:"AdRequest"}),Qme=p({id:PU,accountId:H,provider:Ct,postId:Pt,targetId:sr,actorAccountId:H,creativeId:U(Qc),campaignId:U(_o),providerPostId:a,permalink:U(a),sourceHash:a,status:ds,revision:L.check(Te(1)),operationId:U(fi),createdAt:a,updatedAt:a}).annotate({identifier:"AdBoost"}),Hme=p({expectedRevision:L.check(Ro(0)),confirmation:v("activate_spend")}).annotate({identifier:"AdCampaignActivationInput"}),Vme=p({expectedRevision:L.check(Ro(0))}).annotate({identifier:"AdCampaignPauseInput"}),Jme=p({expectedRevision:L.check(Ro(0))}).annotate({identifier:"AdCampaignArchiveInput"}),Yme=p({status:G(["active","paused","archived"]),expectedRevision:L.check(Ro(0))}).annotate({identifier:"AdEntityStatusUpdate"}),Zme=p({budget:us,expectedRevision:L.check(Ro(0))}).annotate({identifier:"AdBudgetUpdateInput"}),WJ=p({headline:u(a.check(re(255))),body:u(a.check(re(2000))),callToAction:u(a.check(re(64))),destinationUrl:u(a.check(re(2048))),providerSettings:u($t(a,j))}).annotate({identifier:"AdAttachAdCreative"}),Xme=p({name:a.check(xe(1),re(255)),budget:u(us),targeting:u($t(a,j)),providerSettings:u($t(a,j))}).annotate({identifier:"AdAdGroupCreateInput"}),ehe=p({actorAccountId:H,mediaId:a.check(D()),headline:u(a.check(re(255))),body:u(a.check(re(2000))),callToAction:u(a.check(re(64))),destinationUrl:a.check(re(2048)),providerSettings:u($t(a,j))}).annotate({identifier:"AdCreativeCreateInput"}),the=p({name:u(a.check(xe(1),re(255)))}).annotate({identifier:"AdCampaignDuplicateInput"}),rhe=p({name:a.check(xe(1),re(255)),creativeId:u(Qc),creative:u(WJ),providerSettings:u($t(a,j))}).annotate({identifier:"AdAttachAdInput"}),nhe=p({"idempotency-key":Qr}),GJ=p({id:H,name:a,provider:Ct,accountKind:v("ad_account"),available:V,selected:V,details:KJ,readiness:hi,capabilities:_(yi),policy:$J,issues:_(po),createdAt:a,updatedAt:a}).annotate({identifier:"AdAccount"}),eM=p({data:_(GJ),...We}).annotate({identifier:"AdAccountList"}),ohe=p({workspaceId:ce,state:u(BJ),...St.fields}),ihe=p({workspaceId:ce,provider:Ct,accountId:u(H)}),tM=p({attemptId:a.check(D()),provider:Ct,url:a,status:v("pending")}).annotate({identifier:"AdConnectLaunch"}),she=p({workspaceId:ce,provider:v("openai_ads"),apiKey:a.check(xe(1),re(2048)),accountId:u(H),profileId:u(xt)}).annotate({identifier:"AdApiKeyConnectInput"}),rM=p({provider:v("openai_ads"),accountId:H,status:v("connected")}).annotate({identifier:"AdApiKeyConnectResult"}),ahe=p({workspaceId:ce,accountId:H}),nM=p({accountId:H,selected:v(!0),campaignSyncQueued:V,insightSyncQueued:V}).annotate({identifier:"AdAccountSelection"}),oM=p({accountId:H,disconnected:v(!0),historyRetained:v(!0)}).annotate({identifier:"AdAccountDisconnected"}),iM=G(["awareness","traffic","engagement","leads","sales","app_promotion","video_views","reach","conversions","unknown"]),zJ=G(["provider","pubnio"]),sM=a,Eu=$t(a,j),Au=p({startAt:U(Rt),endAt:U(Rt),timezone:a}).annotate({identifier:"AdSchedule"}),aM=p({valid:V,accountId:H,provider:Ct,actorAccountId:U(H),currency:Fn,budget:U(us),schedule:U(Au),killSwitchActive:V,issues:_(po),nextAction:a}).annotate({identifier:"AdValidation"}),jJ=p({postId:Pt,postTargetId:u(sr),actorAccountId:u(H),budget:us,schedule:u(Au),targeting:u($t(a,j))}).annotate({identifier:"AdBoostDraft"}),che=p({workspaceId:ce,accountId:H,...jJ.fields}).annotate({identifier:"AdBoostInput"}),QJ=G(["campaign.create","ad_group.create","creative.create","ad.create","campaign.activate","campaign.pause","campaign.archive","ad_group.activate","ad_group.pause","ad_group.archive","ad.activate","ad.pause","ad.archive","budget.update","boost.create"]),HJ=p({budgetOwner:G(["campaign","ad_group","shared"]),maxAdGroups:u(L.check(Te(1))),budgetUnit:G(["minor","micros"]),hierarchy:_(G(["campaign","ad_group","creative","ad"])),actor:G(["required","none"]),creative:G(["separate","embedded"]),review:G(["sync","pending","async"]),activation:G(["campaign","ad_group"])}).annotate({identifier:"AdCampaignPlanProfile"}),VJ=p({accountId:H,actorAccountId:u(H),budget:u(us),schedule:u(Au),providerSettings:u($t(a,j))}).annotate({identifier:"AdCampaignPlanTarget"}),JJ=p({headline:u(a.check(re(255))),body:u(a.check(re(2000))),callToAction:u(a.check(re(64))),destinationUrl:u(a.check(re(2048))),media:u(as),providerSettings:u($t(a,j))}).annotate({identifier:"AdCampaignPlanCreative"}),YJ=p({name:a.check(xe(1),re(255)),creative:JJ,providerSettings:u($t(a,j))}).annotate({identifier:"AdCampaignPlanAd"}),ZJ=p({name:a.check(xe(1),re(255)),budget:u(us),targeting:u($t(a,j)),providerSettings:u($t(a,j)),ads:_(YJ).check(xe(1),re(50))}).annotate({identifier:"AdCampaignPlanAdGroup"}),phe=p({name:a.check(xe(1),re(255)),objective:iM,budget:u(us),schedule:u(Au),targets:_(VJ).check(xe(1),re(50)),adGroups:_(ZJ).check(xe(1),re(50)),providerSettings:u($t(a,j))}).annotate({identifier:"AdCampaignPlan"}),XJ=p({accountId:H,provider:u(Ct),name:u(a),currency:u(Fn),budget:u(U(us)),profile:u(HJ),capabilities:u(_(QJ)),issues:_(po)}).annotate({identifier:"AdCampaignPlanTargetValidation"}),cM=p({valid:V,issues:_(po),targets:_(XJ)}).annotate({identifier:"AdCampaignPlanValidation"}),pI=G(["queued","creating","partial","succeeded","failed","unresolved"]),pM=p({accountId:H,provider:Ct,operationId:fi,status:ku}).annotate({identifier:"AdCampaignPlanTargetAccepted"}),dM=p({planId:a.check(D()),status:pI,targets:_(pM)}).annotate({identifier:"AdCampaignPlanAccepted"}),e3=p({planId:a.check(D()),status:pI,createdAt:a,targets:_(pM)}).annotate({identifier:"AdCampaignPlanListRow"}),uM=p({data:_(e3),...We}).annotate({identifier:"AdCampaignPlanList"}),t3=p({accountId:H,provider:Ct,operationId:fi,campaignId:U(_o),status:ku,issues:_(po)}).annotate({identifier:"AdCampaignPlanTargetDetail"}),lM=p({planId:a.check(D()),status:pI,createdAt:a,targets:_(t3),issues:_(po)}).annotate({identifier:"AdCampaignPlanDetail"}),fM=p({id:_o,accountId:H,provider:Ct,externalId:a,name:a,objective:iM,status:ds,providerStatus:U(a),managed:zJ,revision:L.check(Te(1)),budget:U(yt),bidStrategy:U(sM),schedule:Au,providerSettings:Eu,syncedAt:a}).annotate({identifier:"AdCampaign"}),mM=p({id:ma,campaignId:_o,accountId:H,provider:Ct,kind:a,externalId:a,name:a,status:ds,providerStatus:U(a),revision:L.check(Te(1)),budget:U(yt),bidStrategy:U(sM),targeting:Eu,providerSettings:Eu,syncedAt:a}).annotate({identifier:"AdGroup"}),vu=p({id:Qc,accountId:H,provider:Ct,externalId:a,kind:a,actorAccountId:U(H),mediaId:U(a.check(D())),headline:U(a),body:U(a),callToAction:U(a),destinationUrl:U(a),providerSettings:Eu,syncedAt:a}).annotate({identifier:"AdCreative"}),dI=G(["campaign","ad_group","ad"]),r3=a,n3=G(["fresh","stale","pending","partial","unavailable"]),ba=p({status:n3,syncedAt:U(a),nextSyncAt:u(a),retryAfter:u(a)}).annotate({identifier:"AdFreshness"}),dhe=p({accountId:u(H),campaignId:u(_o),adGroupId:u(ma),adId:u(is),from:u(a.check(qe(/^\d{4}-\d{2}-\d{2}$/))),to:u(a.check(qe(/^\d{4}-\d{2}-\d{2}$/))),level:u(dI),metrics:u(_(r3).check(re(30))),cursor:St.fields.cursor,limit:u(L.check(Te(1),lU(100)))}).annotate({identifier:"AdInsightQuery"}),o3=p({id:OU,accountId:H,level:dI,campaignId:U(_o),adGroupId:U(ma),adId:U(is),creativeId:U(Qc),date:a.check(qe(/^\d{4}-\d{2}-\d{2}$/)),currency:Fn,spend:yt,impressions:L.check(Te(0)),clicks:L.check(Te(0)),conversions:mr.check(Te(0)),revenue:yt,metrics:$t(a,mr),syncedAt:a}).annotate({identifier:"AdInsightRow"}),i3=p({currency:Fn,spend:yt,impressions:L.check(Te(0)),clicks:L.check(Te(0)),conversions:mr.check(Te(0)),revenue:yt,metrics:$t(a,mr)}).annotate({identifier:"AdInsightTotals"}),uI=p({from:a,to:a,level:dI,totals:_(i3),rowCount:L.check(Te(0)),freshness:ba}).annotate({identifier:"AdInsightSummary"}),fh=p({id:is,accountId:H,campaignId:_o,adGroupId:ma,creativeId:U(Qc),provider:Ct,externalId:a,name:a,format:U(a),status:ds,providerStatus:U(a),revision:L.check(Te(1)),providerSettings:Eu,syncedAt:a,creative:u(U(vu)),insights:u(U(uI))}).annotate({identifier:"Ad"}),lI=p({data:_(fM),...We,freshness:ba}).annotate({identifier:"AdCampaignList"}),s3=p({...mM.fields,insights:u(U(uI))}).annotate({identifier:"AdGroupListRow"}),hM=p({data:_(s3),...We,freshness:ba}).annotate({identifier:"AdGroupList"}),yM=p({data:_(fh),...We,freshness:ba}).annotate({identifier:"AdList"}),gM=p({data:_(vu),...We,freshness:ba}).annotate({identifier:"AdCreativeList"}),fI=p({data:_(o3),summary:uI,...We,freshness:ba}).annotate({identifier:"AdInsightList"}),a3=p({adGroup:mM,ads:_(p({ad:fh,creative:U(vu)}))}).annotate({identifier:"AdTreeNode"}),c3=p({campaign:fM,adGroups:_(a3)}).annotate({identifier:"AdTreeCampaign"}),xM=p({data:_(c3),...We,freshness:ba}).annotate({identifier:"AdTree"}),SM=p({accountId:H,queuedScopes:_(G(["campaigns","ads_insights"])),nextDueAt:a,retryAfterSeconds:u(L)}).annotate({identifier:"AdRefreshAccepted"});var mI="2026-12-02",bM=[mI],mh=G(bM),IM="PubNio-Version";var hI=Lr.check(xe(1),re(100)),yI=a.check(xe(1),re(128)),Cu=p({id:xt,workspaceId:ce,name:hI,externalId:U(yI),isDefault:V,archived:V,createdAt:a,updatedAt:a}).annotate({identifier:"WorkspaceProfile"}),wM=p({data:_(Cu),...We}).annotate({identifier:"ProfileList"}),ghe=p({workspaceId:ce,includeArchived:u(V),...St.fields}),xhe=p({name:hI,externalId:u(yI)}),She=p({name:u(hI),externalId:u(U(yI))}).check(qt(({name:e,externalId:t})=>e!==void 0||t!==void 0||"Provide a name or external ID.")),bhe=p({profileId:xt}),EM=p({archived:v(!0)});var vhe=G(["publishing","inbox","analytics","ads","scheduling","accounts","billing"]),hh=G(["post.delivery.published","post.delivery.provider_draft","post.delivery.failed","post.delivery.unresolved","post.delivery.cancelled","post.scheduled","post.published","post.partial","post.failed","post.cancelled","inbox.message.received","inbox.comment.received","inbox.review.new","inbox.review.updated","inbox.review.deleted","inbox.review.restored","inbox.review.replied","inbox.mention.received","inbox.message.sent","inbox.message.delivered","inbox.message.read","inbox.message.edited","inbox.message.deleted","inbox.reaction.received","inbox.referral.received","inbox.conversation.started","analytics.post.synced","analytics.account.synced","ads.operation.succeeded","ads.operation.failed","ads.campaign.activated","ads.campaign.paused","ads.budget.changed","ads.kill_switch.activated","ads.lead.received","ads.campaign.status_changed","ads.ad_group.status_changed","ads.ad.status_changed","ads.ad_account.status_changed","ads.ad.review.approved","ads.ad.review.rejected","ads.sync.failed","ads.sync.recovered","ads.initial_sync.completed","schedule.assignment.changed","account.connected","account.disconnected","account.permissions_changed","account.restricted","account.recovered","billing.subscription.updated","billing.credit.topped_up","billing.credit.low","billing.spend_cap.reached","billing.invoice.payment_failed"]);var kM=p({id:a.check(D()),type:hh,version:v(1),timestamp:Rt.check(qe(/Z$/)),workspaceId:ce,profileId:u(xt)}).annotate({identifier:"WorkspaceEventEnvelope"});var gI=a.check(D()),p3=a.check(D()),AM=hh,TM=G([...hh.literals,"webhook.test"]),Khe=p({eventTypes:_(TM)}).annotate({identifier:"WebhookEventTypes"}),Oe=kM.fields,Tu={postId:Pt,targetId:sr,attemptId:Wt,accountId:H,provider:Zt,placement:yr,revision:ao},vM={providerRef:lu,url:u(a)},yh={canRetry:V,canReconcile:V,nextAction:a},d3=G(["published","provider_draft","failed","unresolved","cancelled"]),u3={targetId:sr,accountId:H,provider:Zt,placement:yr,status:d3,url:u(a),issue:u(fu)},l3={targetId:sr,accountId:H,scheduledAt:U(a)},gh={postId:Pt,revision:ao,targets:_(p(u3))},xI=G(["live","backfill"]),CM={messageId:Mn,conversationId:gn,accountId:H,provider:Zt,direction:tI,kind:rI,providerCreatedAt:a,freshness:xI},f3={threadId:Gc,commentId:zc,accountId:H,provider:Zt,providerCreatedAt:a,freshness:xI},m3={mentionId:jc,accountId:H,provider:Zt,providerCreatedAt:a,freshness:xI},Ou={reviewId:Km,accountId:H,provider:Be,locationId:u(a)},Pu={accountId:H,provider:Be,accountKind:ar},$he=lt([p({...Oe,type:v("post.delivery.published"),data:p({...Tu,status:v("published"),...vM})}),p({...Oe,type:v("post.delivery.provider_draft"),data:p({...Tu,status:v("provider_draft"),...vM})}),p({...Oe,type:v("post.delivery.failed"),data:p({...Tu,status:v("failed"),issue:fu,canRetry:yh.canRetry,nextAction:yh.nextAction,providerRef:u(lu),url:u(a)})}),p({...Oe,type:v("post.delivery.unresolved"),data:p({...Tu,status:v("unresolved"),issue:fu,canReconcile:yh.canReconcile,nextAction:yh.nextAction,providerRef:u(lu),url:u(a)})}),p({...Oe,type:v("post.delivery.cancelled"),data:p({...Tu,status:v("cancelled")})}),p({...Oe,type:v("post.scheduled"),data:p({postId:Pt,revision:ao,targets:_(p(l3))})}),p({...Oe,type:v("post.published"),data:p(gh)}),p({...Oe,type:v("post.partial"),data:p(gh)}),p({...Oe,type:v("post.failed"),data:p(gh)}),p({...Oe,type:v("post.cancelled"),data:p(gh)}),p({...Oe,type:v("inbox.message.received"),data:p(CM)}),p({...Oe,type:v("inbox.message.sent"),data:p(CM)}),p({...Oe,type:v("inbox.comment.received"),data:p(f3)}),p({...Oe,type:v("inbox.review.new"),data:p(Ou)}),p({...Oe,type:v("inbox.review.updated"),data:p(Ou)}),p({...Oe,type:v("inbox.review.deleted"),data:p(Ou)}),p({...Oe,type:v("inbox.review.restored"),data:p(Ou)}),p({...Oe,type:v("inbox.review.replied"),data:p(Ou)}),p({...Oe,type:v("inbox.mention.received"),data:p(m3)}),p({...Oe,type:v("inbox.message.delivered"),data:p({messageIds:_(Mn),conversationId:u(gn),accountId:H,provider:Zt,deliveredAt:a})}),p({...Oe,type:v("inbox.message.read"),data:p({messageIds:_(Mn),conversationId:u(gn),accountId:H,provider:Zt,readAt:a})}),p({...Oe,type:v("inbox.message.edited"),data:p({messageId:Mn,conversationId:gn,accountId:H,provider:Zt})}),p({...Oe,type:v("inbox.message.deleted"),data:p({messageId:Mn,conversationId:gn,accountId:H,provider:Zt})}),p({...Oe,type:v("inbox.reaction.received"),data:p({messageId:u(Mn),conversationId:u(gn),accountId:H,provider:Zt,reaction:a,action:G(["add","remove"])})}),p({...Oe,type:v("inbox.referral.received"),data:p({messageId:u(Mn),conversationId:u(gn),accountId:H,provider:Zt,ref:a,source:a,adId:u(a)})}),p({...Oe,type:v("inbox.conversation.started"),data:p({conversationId:gn,accountId:H,provider:Zt,participantExternalId:a})}),p({...Oe,type:v("analytics.post.synced"),data:p({postId:Pt,accountId:H,provider:Be})}),p({...Oe,type:v("analytics.account.synced"),data:p({accountId:H,provider:Be})}),p({...Oe,type:v("ads.operation.succeeded"),data:p({operationId:fi,accountId:H,kind:lh,status:G(["succeeded","partial"]),nextAction:a})}),p({...Oe,type:v("ads.operation.failed"),data:p({operationId:fi,accountId:H,kind:lh,status:G(["failed","unresolved","cancelled"]),issue:po,canRetry:V,nextAction:a})}),p({...Oe,type:v("ads.kill_switch.activated"),data:p({accountId:H,revision:L.check(Te(1)),reason:U(a),pausedCampaigns:L.check(Te(0)),pausedAdGroups:L.check(Te(0)),pausedAds:L.check(Te(0))})}),p({...Oe,type:v("ads.lead.received"),data:p({accountId:H,leadId:a,pageId:u(a),formId:u(a),adId:u(a),adGroupId:u(a)})}),p({...Oe,type:v("ads.campaign.status_changed"),data:p({accountId:H,campaignId:_o,provider:Ct,status:ds})}),p({...Oe,type:v("ads.ad_group.status_changed"),data:p({accountId:H,adGroupId:ma,provider:Ct,status:ds})}),p({...Oe,type:v("ads.ad.status_changed"),data:p({accountId:H,adId:is,provider:Ct,status:ds})}),p({...Oe,type:v("ads.ad_account.status_changed"),data:p({accountId:H,provider:Ct,status:cI})}),p({...Oe,type:v("ads.ad.review.approved"),data:p({accountId:H,adId:is,provider:Ct})}),p({...Oe,type:v("ads.ad.review.rejected"),data:p({accountId:H,adId:is,provider:Ct})}),p({...Oe,type:v("ads.sync.failed"),data:p({accountId:H,provider:Ct})}),p({...Oe,type:v("ads.sync.recovered"),data:p({accountId:H,provider:Ct})}),p({...Oe,type:v("ads.initial_sync.completed"),data:p({accountId:H,provider:Ct})}),p({...Oe,type:v("account.connected"),data:p({...Pu,reconnected:V})}),p({...Oe,type:v("account.disconnected"),data:p({...Pu,reason:G(["disconnected","expired","revoked","deauthorized"])})}),p({...Oe,type:v("account.permissions_changed"),data:p({...Pu,missingScopes:_(a),missingTasks:_(a)})}),p({...Oe,type:v("account.restricted"),data:p({...Pu,reason:v("publish_failures")})}),p({...Oe,type:v("account.recovered"),data:p(Pu)}),p({...Oe,type:v("billing.subscription.updated"),data:p({plan:Jc,status:mu,interval:U(zm),periodStart:a,periodEnd:a,cancelAtPeriodEnd:V})}),p({...Oe,type:v("billing.credit.topped_up"),data:p({amountMicros:L,balanceAfterMicros:L,kind:Hm})}),p({...Oe,type:v("billing.credit.low"),data:p({balanceMicros:L,thresholdMicros:L})}),p({...Oe,type:v("billing.spend_cap.reached"),data:p({capMicros:L,periodSpendMicros:L,estimatedMicros:L})}),p({...Oe,type:v("billing.invoice.payment_failed"),data:p({invoiceId:a,amountDueMinor:L,hostedInvoiceUrl:U(a)})}),p({...Oe,type:v("webhook.test"),data:p({endpointId:du})})]).annotate({identifier:"WebhookEvent"}),SI=G(["publishing","inbox","analytics","ads","scheduling","accounts","billing"]),bI=Lr.check(xe(1),re(100)),OM=a.check(re(2048)),h3=u(_(H)).annotate({description:"Only deliver events for these accounts. Empty or omitted means every account. Duplicates are ignored."}),y3=u(_(SI)).annotate({description:"Drop every event in these families. Empty or omitted means no family is dropped. Duplicates are ignored."}),g3=u(U(_(H))).annotate({description:"Only deliver events for these accounts. Omit to keep the current filter; null or an empty array clears it to every account."}),x3=u(U(_(SI))).annotate({description:"Drop every event in these families. Omit to keep the current denylist; null or an empty array clears it."}),II=_(AM).check(xe(1),re(AM.literals.length),qt((e)=>new Set(e).size===e.length||"Choose each event type only once.")),S3=p({workspaceId:ce,endpointId:du}),qhe=p({...S3.fields,deliveryId:gI}),Whe=p({name:bI,url:OM,eventTypes:II,enabled:u(V),profileId:u(xt),accountIds:h3,disabledResourceGroups:y3}),Ghe=p({name:u(bI),eventTypes:u(II),enabled:u(V),profileId:u(U(xt)),accountIds:g3,disabledResourceGroups:x3}).check(qt((e)=>Object.keys(e).length>0||"Provide at least one endpoint change.")),xh=p({id:du,workspaceId:ce,name:bI,eventTypes:II,enabled:V,profileId:U(xt),accountIds:_(H),disabledResourceGroups:_(SI),apiVersion:mh,destinationOrigin:a,createdAt:a,updatedAt:a,deletedAt:U(a)}).annotate({identifier:"WebhookEndpoint"}),wI=p({...xh.fields,url:U(OM)}),b3=a.check(qe(/^whsec_[A-Za-z0-9+/]{43}=$/)),PM=p({endpoint:wI,secret:b3}),RM=p({data:_(xh),...We}).annotate({identifier:"WebhookEndpointList"}),_M=p({deleted:v(!0)}),UM=p({deliveryId:gI}),EI=G(["pending","sending","delivered","failed","cancelled"]),I3=G(["timeout","network","http_status","redirect","destination_rejected","configuration_unavailable","expired","attempts_exhausted"]),Sh=p({id:gI,workspaceId:ce,endpointId:du,eventId:p3,eventType:TM,status:EI,attemptCount:L,createdAt:a,nextAttemptAt:U(a),lastAttemptAt:U(a),lastHttpStatus:U(L),lastError:U(I3),completedAt:U(a)}).annotate({identifier:"WebhookDelivery"}),DM=p({data:_(Sh),...We}).annotate({identifier:"WebhookDeliveryList"});var kI="~effect/http/HttpBody";class vI{[kI];constructor(){this[kI]=kI}[Yr](){return this.toJSON()}toString(){return et(this,{ignoreToString:!0})}}class LM extends vI{_tag="Empty";toJSON(){return{_id:"effect/HttpBody",_tag:"Empty"}}}var MM=new LM;class AI extends vI{_tag="Uint8Array";contentType;contentLength;text;_body;constructor(e,t,r,n){super();this._body=e,this.text=n,this.contentType=t,this.contentLength=r}get body(){return this._body??=w3(this.text)}toJSON(){return{_id:"effect/HttpBody",_tag:"Uint8Array",body:this.contentType.startsWith("text/")||this.contentType.endsWith("json")?new TextDecoder().decode(this.body):`Uint8Array(${this.body.length})`,contentType:this.contentType,contentLength:this.contentLength}}}var FM=new TextEncoder,bh=globalThis.Buffer,w3=bh!==void 0?(e)=>bh.from(e,"utf8"):(e)=>FM.encode(e),NM=(e,t)=>{if(typeof e!=="string")e=e===void 0?"":String(e);if(bh!==void 0)return new AI(void 0,t??"text/plain",bh.byteLength(e,"utf8"),e);let r=FM.encode(e);return new AI(r,t??"text/plain",r.length,e)},BM=(e,t)=>NM(JSON.stringify(e),t??"application/json");var E3=Object.getPrototypeOf(da),$M=()=>Object.create(E3);var qM="~effect/http/HttpServerResponse";var A3=(e,t)=>{if(e?.contentType)return e.contentType;else if(e?.headers)return t["content-type"]};var WM=(e,t)=>{let r=t?.headers?O_(t.headers):da;return C3({status:t?.status??200,statusText:t?.statusText,headers:r,cookies:t?.cookies,body:BM(e,A3(t,r))})};var v3={...Br,[qM]:qM,[Bm]:!0,toJSON(){return{_id:"HttpServerResponse",status:this.status,statusText:this.statusText,headers:Wn(this.headers),cookies:this.cookies.toJSON(),body:this.body.toJSON()}}},C3=(e,t)=>{let r=Object.create(v3);if(r.status=e.status,r.statusText=e.statusText,r.cookies=e.cookies??v_,r.body=e.body??MM,r.body._tag!=="Empty"&&(r.body.contentType||r.body.contentLength!==void 0)){let n=t!==void 0,o=n?t:e.headers===void 0||e.headers===da?$M():P_({...e.headers});if(r.body.contentType&&(!n||o["content-type"]===void 0))o["content-type"]=r.body.contentType;if(r.body.contentLength!==void 0&&(!n||o["content-length"]===void 0))o["content-length"]=r.body.contentLength.toString();r.headers=o}else r.headers=t??e.headers??da;return r};var zM="~effect/http/HttpServerRespondable";var Ih="application/problem+json",QM="about:blank",Ia=(e)=>u(e).pipe(pb(()=>ld)),HM=(e,t)=>uU(W(t))(e).pipe(pb(()=>ux(t))),CI=(e)=>HM(ns(e),e),T3=cU(p({type:HM(a,QM),status:Ia(mr),title:Ia(a),detail:Ia(a),instance:Ia(a)}),[$t(a,j)]);var O3={_tag:"Json",contentType:Ih},pe=()=>(e,t,r,n)=>{let o=p({detail:Ia(a),instance:Ia(a),...r,type:ns(t.type),status:CI(t.status),title:CI(t.title)}),i=sU(o),s=su(e)(o,{description:t.title,httpApiStatus:t.status,"~httpApiEncoding":O3,...n});return Object.assign(s.prototype,{_tag:e,[Bm]:t.status<500,[zM](){return _e(i(this),(c)=>WM(c,{status:t.status,contentType:Ih}))}}),Object.defineProperty(s.prototype,"message",{get(){return this.detail??t.title},configurable:!0}),s},P3=p({path:_(lt([a,mr])),message:a});class R3 extends pe()("UploadTooLarge",{type:"about:blank",status:413,title:"Content Too Large"}){}class JM extends pe()("AuthenticationRequired",{type:"urn:pubnio:problem:authentication-required",status:401,title:"Unauthorized"},{docUrl:u(a)}){}class YM extends pe()("Forbidden",{type:"urn:pubnio:problem:forbidden",status:403,title:"Forbidden"},{requiredScope:u(hu),docUrl:u(a)}){}class ZM extends pe()("HumanActorRequired",{type:"urn:pubnio:problem:human-actor-required",status:403,title:"Human actor required"},{code:v("human_actor_required"),nextAction:a}){}class XM extends pe()("OwnerRequired",{type:"urn:pubnio:problem:owner-required",status:403,title:"Owner permission required"},{code:v("owner_required"),nextAction:a}){}class eF extends pe()("SeatLimitReached",{type:"urn:pubnio:problem:seat-limit-reached",status:402,title:"Seat limit reached"},{code:v("seat_limit_reached"),seatsUsed:L,seatsLimit:L,nextAction:a}){}class tF extends pe()("AlreadyMember",{type:"urn:pubnio:problem:already-member",status:409,title:"Already a workspace member"},{code:v("already_member"),nextAction:a}){}class rF extends pe()("InviteAlreadyPending",{type:"urn:pubnio:problem:invite-already-pending",status:409,title:"Invite already pending"},{code:v("invite_already_pending"),nextAction:a}){}class nF extends pe()("LastOwnerRequired",{type:"urn:pubnio:problem:last-owner-required",status:409,title:"Last owner required"},{code:v("last_owner_required"),nextAction:a}){}class oF extends pe()("InviteExpired",{type:"urn:pubnio:problem:invite-expired",status:410,title:"Invite expired"},{code:v("invite_expired"),nextAction:a}){}class iF extends pe()("InviteEmailMismatch",{type:"urn:pubnio:problem:invite-email-mismatch",status:403,title:"Invite email mismatch"},{code:v("invite_email_mismatch"),nextAction:a}){}class sF extends pe()("NotFound",{type:"urn:pubnio:problem:not-found",status:404,title:"Not Found"}){}class aF extends pe()("Conflict",{type:"urn:pubnio:problem:conflict",status:409,title:"Conflict"}){}class cF extends pe()("Unavailable",{type:"urn:pubnio:problem:unavailable",status:503,title:"Service Unavailable"}){}class pF extends pe()("UnsupportedApiVersion",{type:"urn:pubnio:problem:unsupported-api-version",status:400,title:"Unsupported API version"},{code:v("unsupported_api_version"),param:a,supportedVersions:_(mh),nextAction:a}){}class _3 extends pe()("InvalidCursor",{type:"urn:pubnio:problem:invalid-cursor",status:400,title:"Invalid cursor"},{code:u(v("invalid_cursor")),nextAction:u(a)}){}var Ru=p({accountId:H,name:a}).annotate({identifier:"ProblemCandidate"});class dF extends pe()("InvalidPublication",{type:"urn:pubnio:problem:invalid-publication",status:422,title:"Invalid publication"},{issues:_(so),candidates:u(_(Ru)),code:u(v("invalid_publication")),nextAction:u(a)}){}var uF="x-request-id",lF=P3;class fF extends pe()("InternalFailure",{type:"urn:pubnio:problem:internal-error",status:500,title:"Internal Server Error"},{requestId:a.check(D())}){}class mF extends pe()("AttemptChanged",{type:"urn:pubnio:problem:attempt-changed",status:409,title:"Delivery attempt changed"},{currentAttemptId:Wt}){}class hF extends pe()("IdempotencyConflict",{type:"urn:pubnio:problem:idempotency-conflict",status:409,title:"Idempotency key already used"},{code:u(v("idempotency_conflict")),nextAction:u(a)}){}class yF extends pe()("AccountAmbiguous",{type:"urn:pubnio:problem:account-ambiguous",status:422,title:"Account ambiguous"},{code:v("account_ambiguous"),provider:Be,param:a,candidates:_(Ru),nextAction:a}){}class gF extends pe()("ProviderMismatch",{type:"urn:pubnio:problem:provider-mismatch",status:422,title:"Provider mismatch"},{code:v("provider_mismatch"),provider:Be,expectedProvider:Be,param:a,nextAction:a}){}class xF extends pe()("PublishAccountNotFound",{type:"urn:pubnio:problem:publish-account-not-found",status:422,title:"Publishing account not found"},{code:v("account_not_found"),provider:u(Be),accountId:u(H),param:a,candidates:u(_(Ru)),nextAction:a}){}class SF extends pe()("MediaUploadConflict",{type:"urn:pubnio:problem:media-upload-conflict",status:409,title:"Media upload conflict"},{reason:OD}){}class bF extends pe()("DestinationAlreadySubmitted",{type:"urn:pubnio:problem:destination-already-submitted",status:409,title:"Destination already submitted"}){}class IF extends pe()("DeliveryNotRetryable",{type:"urn:pubnio:problem:delivery-not-retryable",status:409,title:"Delivery cannot be retried"}){}class wF extends pe()("DeliveryNotReconcilable",{type:"urn:pubnio:problem:delivery-not-reconcilable",status:409,title:"Delivery cannot be reconciled"}){}class EF extends pe()("DeliveryScheduleLocked",{type:"urn:pubnio:problem:delivery-schedule-locked",status:409,title:"Delivery schedule cannot change"}){}class kF extends pe()("PostRevisionConflict",{type:"urn:pubnio:problem:post-revision-conflict",status:409,title:"Post revision changed"},{currentRevision:ao}){}class AF extends pe()("QueueNotFound",{type:"urn:pubnio:problem:queue-not-found",status:404,title:"Queue not found"}){}class vF extends pe()("QueueAlreadyExists",{type:"urn:pubnio:problem:queue-already-exists",status:409,title:"Queue already exists"}){}class CF extends pe()("QueueDefaultRequired",{type:"urn:pubnio:problem:queue-default-required",status:409,title:"Queue default required"},{code:v("queue_default_required"),accountId:H,nextAction:a}){}class TF extends pe()("QueueVersionConflict",{type:"urn:pubnio:problem:queue-version-conflict",status:409,title:"Queue version changed"},{currentVersion:L.check(Te(1))}){}class OF extends pe()("QueueUnavailable",{type:"urn:pubnio:problem:queue-unavailable",status:409,title:"Queue unavailable"},{reason:kL}){}class PF extends pe()("QueueCapacityReached",{type:"urn:pubnio:problem:queue-capacity-reached",status:409,title:"Queue capacity reached"},{reason:AL}){}class RF extends pe()("QueueNoSlotAvailable",{type:"urn:pubnio:problem:queue-no-slot-available",status:409,title:"No queue slot available"},{horizonEndsAt:a}){}class _F extends pe()("QueueSlotConflict",{type:"urn:pubnio:problem:queue-slot-conflict",status:409,title:"Queue slot conflict"},{scheduledAt:a,suggestedSlots:_(a)}){}class UF extends pe()("InvalidTimezone",{type:"urn:pubnio:problem:invalid-timezone",status:422,title:"Invalid time zone"},{code:v("invalid_timezone"),timezone:a,nextAction:a}){}class DF extends pe()("InvalidQueue",{type:"urn:pubnio:problem:invalid-queue",status:422,title:"Invalid queue"},{issues:_(LL)}){}class LF extends pe()("ScheduleRangeTooWide",{type:"urn:pubnio:problem:schedule-range-too-wide",status:422,title:"Schedule range too wide"},{maxDays:L}){}class MF extends pe()("WebhookTestRateLimited",{type:"urn:pubnio:problem:webhook-test-rate-limited",status:429,title:"Webhook test rate limited"}){}class FF extends pe()("WebhookDeliveryNotReplayable",{type:"urn:pubnio:problem:webhook-delivery-not-replayable",status:409,title:"Webhook delivery not replayable"},{code:v("webhook_delivery_not_replayable"),deliveryStatus:EI,nextAction:a}){}class NF extends pe()("ProviderPermissionRequired",{type:"urn:pubnio:problem:provider-permission-required",status:403,title:"Provider permission required"},{provider:Be,missingScopes:_(a),missingRoles:_(a),reason:u(a),reconnectRequired:u(V)}){}class BF extends pe()("ProviderReconnectRequired",{type:"urn:pubnio:problem:provider-reconnect-required",status:409,title:"Provider reconnect required"},{provider:Be,missingScopes:_(a),reason:u(a)}){}class KF extends pe()("ProviderRateLimited",{type:"urn:pubnio:problem:provider-rate-limited",status:429,title:"Provider rate limited"},{provider:Be,retryAfterSeconds:u(L)}){}class $F extends pe()("ProviderUnavailable",{type:"urn:pubnio:problem:provider-unavailable",status:503,title:"Provider unavailable"},{provider:Be,retryAfterSeconds:u(L)}){}class qF extends pe()("CapabilityUnsupported",{type:"urn:pubnio:problem:capability-unsupported",status:422,title:"Capability unsupported"},{capability:mi,provider:Be,accountKind:ar}){}class WF extends pe()("AnalyticsRangeInvalid",{type:"urn:pubnio:problem:analytics-range-invalid",status:400,title:"Analytics range invalid"},{reason:G(["invalid_timezone","invalid_range","range_too_wide"])}){}class GF extends pe()("AnalyticsMetricUnsupported",{type:"urn:pubnio:problem:analytics-metric-unsupported",status:400,title:"Analytics metric unsupported"},{metrics:_(a),maxMetrics:u(L)}){}class zF extends pe()("AnalyticsRefreshConflict",{type:"urn:pubnio:problem:analytics-refresh-conflict",status:409,title:"Analytics refresh conflict"},{reason:G(["not_published","deleted","account_analytics_pending"])}){}class jF extends pe()("CapabilityUnverified",{type:"urn:pubnio:problem:capability-unverified",status:409,title:"Capability unverified"},{capability:mi,provider:Be}){}class QF extends pe()("InboxReplyWindowClosed",{type:"urn:pubnio:problem:inbox-reply-window-closed",status:409,title:"Inbox reply window closed"},{provider:Be,policy:nI,endsAt:U(a)}){}class HF extends pe()("InboxTargetChanged",{type:"urn:pubnio:problem:inbox-target-changed",status:409,title:"Inbox target changed"},{targetId:a,state:G(["deleted","changed","unsupported"])}){}class VF extends pe()("InboxSyncInProgress",{type:"urn:pubnio:problem:inbox-sync-in-progress",status:409,title:"Inbox sync already running"},{syncRunId:a.check(D()),retryAfterSeconds:L}){}class JF extends pe()("InboxUnsupportedContent",{type:"urn:pubnio:problem:inbox-unsupported-content",status:422,title:"Inbox content unsupported"},{kind:G(["image","video","audio","file","text","unknown"]),capability:mi}){}var U3=[QF,HF,VF,JF];class YF extends pe()("AdAccountNotReady",{type:"urn:pubnio:problem:ad-account-not-ready",status:409,title:"Ad account not ready"},{reason:G(["unavailable","needs_reconnect","permission_missing","account_disabled"]),missingScopes:u(_(a))}){}class ZF extends pe()("AdAccountNotSelected",{type:"urn:pubnio:problem:ad-account-not-selected",status:409,title:"Ad account not selected"},{accountId:a}){}class XF extends pe()("AdInsightRangeInvalid",{type:"urn:pubnio:problem:ad-insight-range-invalid",status:422,title:"Ad insight range invalid"},{reason:G(["invalid_range","range_too_wide"]),maxDays:u(L)}){}class eN extends pe()("AdRefreshRateLimited",{type:"urn:pubnio:problem:ad-refresh-rate-limited",status:429,title:"Ad refresh rate limited"},{retryAfterSeconds:L.check(Te(0))}){}class tN extends pe()("AdRevisionConflict",{type:"urn:pubnio:problem:ad-revision-conflict",status:409,title:"Ad resource revision conflict"},{resource:G(["spend_policy","campaign","ad_group","ad","boost"]),expectedRevision:L.check(Te(0)),actualRevision:L.check(Te(0)),nextAction:a}){}class rN extends pe()("AdBudgetExceeded",{type:"urn:pubnio:problem:ad-budget-exceeded",status:422,title:"Ad budget exceeds a spend cap"},{reason:G(["daily_cap","monthly_cap","campaign_daily_max","campaign_lifetime_max"]),limit:yt,requested:yt,committed:yt,nextAction:a}){}class nN extends pe()("AdBudgetBelowMinimum",{type:"urn:pubnio:problem:ad-budget-below-minimum",status:422,title:"Ad budget is below the provider minimum"},{minimum:yt,requested:yt,nextAction:a}){}class oN extends pe()("AdCurrencyMismatch",{type:"urn:pubnio:problem:ad-currency-mismatch",status:422,title:"Ad currency does not match the account"},{expected:Fn,actual:Fn,nextAction:a}){}class iN extends pe()("AdSpendForbidden",{type:"urn:pubnio:problem:ad-spend-forbidden",status:403,title:"Ad spend permission required"},{reason:G(["owner_required","api_key_forbidden","confirmation_required","monthly_cap_required","provider_managed"]),nextAction:a}){}class sN extends pe()("AdKillSwitchActive",{type:"urn:pubnio:problem:ad-kill-switch-active",status:409,title:"Ad kill switch is active"},{accountId:H,activatedAt:U(a),reason:U(a),nextAction:a}){}class aN extends pe()("AdOperationNotRetryable",{type:"urn:pubnio:problem:ad-operation-not-retryable",status:409,title:"Ad operation is not retryable"},{operationStatus:ku,nextAction:a}){}class cN extends pe()("AdProviderRejected",{type:"urn:pubnio:problem:ad-provider-rejected",status:422,title:"Ad provider rejected the request"},{provider:Ct,code:a,retryable:V,providerCode:u(a),providerMessage:u(a),issues:_(po),nextAction:a}){}class pN extends pe()("InvalidAdRequest",{type:"urn:pubnio:problem:invalid-ad-request",status:400,title:"Invalid ad request"},{reason:a,field:u(a),nextAction:a}){}var D3=[NF,BF,KF,$F,qF,jF];class L3 extends pe()("CommentTargetInvalid",{type:"urn:pubnio:problem:comment-target-invalid",status:400,title:"Comment target invalid"},{code:v("comment_target_invalid"),reason:a,targetKind:u(wu),nextAction:a}){}class M3 extends pe()("CommentRejected",{type:"urn:pubnio:problem:comment-rejected",status:422,title:"Comment rejected"},{code:v("comment_rejected"),provider:Be,targetKind:wu,nextAction:a}){}class F3 extends pe()("CommentUnresolved",{type:"urn:pubnio:problem:comment-unresolved",status:409,title:"Comment outcome unresolved"},{code:v("comment_unresolved"),actionId:li,nextAction:a}){}var N3=[dF,mF,hF,bF,IF,wF,EF,kF,yF,gF,xF],B3=[WF,GF,zF],K3=[YF,ZF,XF,eN,tN,rN,nN,oN,iN,sN,aN,cN,pN],$3=[AF,vF,CF,TF,OF,PF,RF,_F,DF,LF],q3=[UF];class dN extends pe()("InsufficientCredit",{type:"urn:pubnio:problem:insufficient-credit",status:402,title:"Insufficient prepaid credit"},{code:v("insufficient_credit"),balanceMicros:L,requiredMicros:L,fundingUrl:a,canManageBilling:V,nextAction:a}){}class uN extends pe()("SpendCapReached",{type:"urn:pubnio:problem:spend-cap-reached",status:402,title:"Monthly spend cap reached"},{code:v("spend_cap_reached"),capMicros:L,periodSpendMicros:L,estimatedMicros:L,fundingUrl:a,canManageBilling:V,nextAction:a}){}class lN extends pe()("BillingInactive",{type:"urn:pubnio:problem:billing-inactive",status:402,title:"Workspace billing is inactive"},{code:v("billing_inactive"),subscriptionStatus:mu,fundingUrl:a,canManageBilling:V,nextAction:a}){}class fN extends pe()("TopUpAmountInvalid",{type:"urn:pubnio:problem:top-up-amount-invalid",status:400,title:"Top-up amount is out of range"},{code:v("top_up_amount_invalid"),minMinor:L,maxMinor:L,nextAction:a}){}class mN extends pe()("InvalidBillingDateRange",{type:"urn:pubnio:problem:invalid-billing-date-range",status:400,title:"Invalid billing date range"},{code:v("invalid_billing_date_range"),nextAction:a}){}class hN extends pe()("BillingRevisionConflict",{type:"urn:pubnio:problem:billing-revision-conflict",status:409,title:"Billing settings changed concurrently"},{code:v("billing_revision_conflict"),expectedVersion:L,actualVersion:L,nextAction:a}){}class yN extends pe()("SubscriptionAlreadyActive",{type:"urn:pubnio:problem:subscription-already-active",status:409,title:"Subscription is already active"},{code:v("subscription_already_active"),plan:Jc,nextAction:a}){}class gN extends pe()("CheckoutAlreadyCompleted",{type:"urn:pubnio:problem:checkout-already-completed",status:409,title:"Checkout session already completed"},{code:v("checkout_already_completed"),checkoutId:a,nextAction:a}){}class xN extends pe()("BillingCustomerMissing",{type:"urn:pubnio:problem:billing-customer-missing",status:409,title:"No billing customer exists yet"},{code:v("billing_customer_missing"),nextAction:a}){}class SN extends pe()("BillingProviderMismatch",{type:"urn:pubnio:problem:billing-provider-mismatch",status:409,title:"Workspace billing gateway mismatch"},{code:v("billing_provider_mismatch"),workspaceGateway:jm,requestedGateway:jm,nextAction:a}){}class bN extends pe()("BillingNotConfigured",{type:"urn:pubnio:problem:billing-not-configured",status:503,title:"Billing gateway is not configured"},{code:v("billing_not_configured"),nextAction:a}){}class IN extends pe()("BillingUnavailable",{type:"urn:pubnio:problem:billing-unavailable",status:503,title:"Billing gateway is temporarily unavailable"},{code:v("billing_unavailable"),retryable:V,nextAction:a}){}var W3=[dN,uN,lN],G3=[...W3,fN,mN,hN,yN,gN,xN,SN,bN,IN],z3=[eF,tF,rF,nF,oF,iF],wN=lt([JM,YM,ZM,XM,sF,aF,cF,pF,...N3,...G3,...$3,...q3,...z3,...U3,...D3,...B3,...K3,fF,MF,FF,SF]);var wa=G(["impressions","reach","views","likes","comments","shares","saves","clicks","link_clicks","profile_visits","page_views","follows","followers","follower_gained","follower_lost","watch_time_ms","avg_watch_time_ms","completion_rate","engagement","engagement_rate"]),EN=G(["count","milliseconds","ratio"]),kN=G(["sum","unique","latest","weighted","ratio"]),AN=G(["post","account"]),j3=G(["total","day"]),vN=G(["available","pending","unsupported","deprecated","renamed","permission_missing","access_pending","stale","deleted","private","not_applicable"]),Q3=$t(a,mr),wh=p({key:wa,value:U(mr),availability:vN,reason:u(a),replacedBy:u(wa),renamedTo:u(wa),missingScopes:u(_(a)),reconnectRequired:u(V),retryAfter:u(a),observedAt:u(a),total:u(U(mr)),breakdown:u(Q3)}).annotate({identifier:"MetricReading"}),H3=p({key:wa,scopes:_(AN),unit:EN,aggregation:kN,definition:a}).annotate({identifier:"MetricDefinition"}),V3=p({key:wa,scope:AN,granularity:j3,unit:EN,aggregation:kN,availability:vN,supported:V,reason:u(a),renamedFrom:u(a),replacedBy:u(wa)}).annotate({identifier:"MetricCapability"}),J3=G(["ready","permission_required","access_pending","reconnect_required","disabled"]),Y3=p({provider:Be,accountKinds:_(ar),placements:_(yr),metrics:_(V3),historyDays:L.check(Ro(0)),latencySeconds:L.check(Te(0)),firstAvailableAfterSeconds:L.check(Te(0)),requiredScopes:_(a),comments:V}).annotate({identifier:"ProviderCapabilities"}),Z3=p({accountId:H,provider:Be,accountKind:ar,readiness:J3,capability:yi,missingScopes:_(a),reconnectRequired:V,accessPending:V}).annotate({identifier:"AnalyticsAccountCapability"}),CN=p({metrics:_(H3),providers:_(Y3),accounts:_(Z3),checkedAt:a}).annotate({identifier:"AnalyticsCapabilities"}),X3=G(["fresh","stale","pending","partial","unavailable"]),Eh=p({status:X3,observedAt:U(a),retryAfter:u(a)}).annotate({identifier:"AnalyticsFreshness"}),TN=p({from:a.check(qe(/^\d{4}-\d{2}-\d{2}$/)),to:a.check(qe(/^\d{4}-\d{2}-\d{2}$/)),timezone:v("UTC"),dayBasis:v("provider_utc")}).annotate({identifier:"AnalyticsDateRange"}),nge=G(["provider_daily","snapshot_delta","provider_lifetime","provider_total"]),ON=p({date:a.check(qe(/^\d{4}-\d{2}-\d{2}$/)),metrics:_(wh)}).annotate({identifier:"AnalyticsPoint"}),e6=G(["available","pending","unavailable"]),t6=p({targetId:sr,attemptId:U(Wt),accountId:H,provider:Be,placement:yr,providerPostId:U(a),publishedAt:U(a),state:e6,metrics:_(wh),series:u(_(ON)),freshness:Eh}).annotate({identifier:"PostAnalyticsTarget"}),OI=p({postId:Pt,workspaceId:ce,range:TN,targets:_(t6),freshness:Eh}).annotate({identifier:"PostAnalytics"}),r6=p({accountId:H,provider:Be,accountKind:ar,profileId:xt,name:a,metrics:_(wh),freshness:Eh}).annotate({identifier:"AnalyticsAccountSummary"}),PN=p({accountId:H,workspaceId:ce,provider:Be,accountKind:ar,profileId:xt,name:a,range:TN,metrics:_(wh),series:u(_(ON)),freshness:Eh}).annotate({identifier:"AccountAnalytics"}),RN=p({data:_(r6),...We}).annotate({identifier:"AccountAnalyticsList"}),oge=p({workspaceId:ce,postId:u(Pt),targetId:u(sr),metrics:u(_(wa).check(re(30)))}).check(qt(({postId:e,targetId:t})=>e!==void 0||t!==void 0||"Send postId or targetId to refresh a published post.")),n6=G(["queued","running","succeeded","failed","paused","deleted","inaccessible"]),PI=p({id:a.check(D()),workspaceId:ce,subjectKind:a,subjectId:a.check(D()),status:n6,nextDueAt:U(a),lastSuccessAt:U(a),errorKind:U(a),createdAt:a}).annotate({identifier:"AnalyticsRefresh"});var _N={name:"@pubnio/sdk",version:"0.2.1",description:"JavaScript and TypeScript client for the PubNio API",type:"module",exports:{".":"./src/index.ts","./solid":"./src/solid.ts","./internal":"./src/internal.ts","./package.json":"./package.json"},dependencies:{"@pubnio/protocol":"workspace:*",effect:"4.1.7"},peerDependencies:{"@tanstack/solid-query":"6.0.0-rc.6"},peerDependenciesMeta:{"@tanstack/solid-query":{optional:!0}},devDependencies:{"@hey-api/openapi-ts":"0.99.0","@tanstack/solid-query":"6.0.0-rc.6","dts-bundle-generator":"10.0.0",typescript:"6.0.3"},scripts:{generate:"bun script/generate.ts","check:generated":"bun script/generate.ts --check",pack:"bun script/pack.ts",build:"bun script/pack.ts"},sideEffects:!1,engines:{node:">=20.19.0"},publishConfig:{access:"public"},files:["dist","README.md"]};function UN({onRequest:e,onSseError:t,onSseEvent:r,responseTransformer:n,responseValidator:o,sseDefaultRetryDelay:i,sseMaxRetryAttempts:s,sseMaxRetryDelay:c,sseSleepFn:l,url:S,...m}){let g,w=l??((y)=>new Promise((h)=>setTimeout(h,y)));return{stream:async function*(){let y=i??3000,h=0,x=m.signal??new AbortController().signal;while(!0){if(x.aborted)break;h++;let q=m.headers instanceof Headers?m.headers:new Headers(m.headers);if(g!==void 0)q.set("Last-Event-ID",g);try{let Y={redirect:"follow",...m,body:m.serializedBody,headers:q,signal:x},I=new Request(S,Y);if(e)I=await e(S,Y);let ae=await(m.fetch??globalThis.fetch)(I);if(!ae.ok)throw Error(`SSE failed: ${ae.status} ${ae.statusText}`);if(!ae.body)throw Error("No body in SSE response");let N=ae.body.pipeThrough(new TextDecoderStream).getReader(),Z="",z=()=>{try{N.cancel()}catch{}};x.addEventListener("abort",z);try{while(!0){let{done:X,value:ee}=await N.read();if(X)break;Z+=ee,Z=Z.replace(/\r\n?/g,`
35
+ `)n.push(y),o=!1;k++}else if(A==="'"||A==='"')s=A,c=l,n.push(""),o=!1;else{let h=kQ(A,y,n.length===0);if(h!==void 0)return S("UnsupportedSyntax",h);if(A==="{")i++;else if(A==="}"){if(i>0)i--}else if(i>0&&(A===","||A==="."&&y==="."))return S("UnsupportedSyntax","Brace expansion needs a shell");else if(A==="="&&r.length===0&&o&&EQ.test(n.join("")))return S("UnsupportedSyntax","A variable assignment needs a shell");n.push(A)}}return};for(;l<e.length;l++){let w=g(e[l]);if(w!==void 0)return w;if(l===t.length)break;let k=t[l];if(Array.isArray(k)){let A=e[l+1][0];if(n.length>0||(A===void 0?l+1<t.length:!FS(A)))return S("UnsupportedSyntax","An interpolated array must be a separate argument");for(let y of k)r.push(G0(y))}else n.push(G0(k)),o=!1}if(s!==void 0)return S("UnterminatedQuote","The quote is not closed",c);return m(),Jt(r)};var H0="~effect/process/ChildProcess",vQ={...Ri({label:"Command",evaluate(e){return $p(e.context,Fc).spawn(this)}}),[H0]:H0};var Yd=(e,t,r)=>Object.assign(Object.create(vQ),{_tag:"StandardCommand",command:e,args:t,options:r});var Em=function(...t){if(V0(t[0])){let[i,...s]=t,[c,l]=J0(i,s);return Yd(c,l,{})}if(typeof t[0]==="object"&&!Array.isArray(t[0])&&!V0(t[0])){let i=t[0];return function(s,...c){if(i.shell!==void 0&&i.shell!==!1)return Yd(CQ(s,c),[],i);let[l,S]=J0(s,c);return Yd(l,S,i)}}if(typeof t[0]==="string"&&!Array.isArray(t[1])){let[i,s={}]=t;return Yd(i,[],s)}let[r,n=[],o={}]=t;return Yd(r,n,o)};var V0=(e)=>Array.isArray(e)&&("raw"in e)&&Array.isArray(e.raw),km=(e)=>{let t=/^fd(\d+)$/.exec(e);if(t===null)return;let r=parseInt(t[1],10);return r>=3?r:void 0},Y0=(e)=>`fd${e}`,J0=(e,t)=>{let[r="",...n]=lg(j0(e,...t));if(typeof r!=="string")throw new ca({reason:"InvalidArgument",message:"The program name of a command cannot be Redacted"});return[r,n]},CQ=(e,t)=>{if(t.length>0)throw new ca({reason:"UnsupportedSyntax",message:"A shell template cannot interpolate values; build the script with CommandLine.quote"});let r=e[0];if(r===void 0)throw new ca({reason:"InvalidEscape",message:"Template part 0 contains an invalid escape sequence"});return r};import*as Tm from"child_process";import{PassThrough as NS}from"stream";var Z0=(e,t,r)=>{let n=e.detached??r!=="win32";return{...t,detached:n,shell:e.shell,windowsHide:e.windowsHide??!n}};var st=(e,t)=>(r,[n])=>{let o="Unknown";switch(r.code){case"ENOENT":o="NotFound";break;case"EACCES":case"EPERM":o="PermissionDenied";break;case"EEXIST":o="AlreadyExists";break;case"EISDIR":o="BadResource";break;case"ENOTDIR":o="BadResource";break;case"EBUSY":o="Busy";break;case"ELOOP":o="BadResource";break}return Yn({_tag:o,module:e,method:t,pathOrDescriptor:n,syscall:r.syscall,cause:r})};import{finished as X0}from"stream";var Am=(e,t,r)=>{if(!("closed"in e)){t(),r?.();return}let n=()=>{clearImmediate(i),e.off("error",n),e.off("close",n),r?.()},o=()=>{if(e.closed)n();else if(i=setImmediate(o),!r)i.unref()},i=setImmediate(o);if(!r)i.unref();if(e.once("error",n),e.once("close",n),t(),!e.closed)e.destroy()};var Kc=(e)=>Gx(Bx(OQ(e),(t)=>[t])),OQ=(e)=>Er((t)=>{let r=e.evaluate(),n=RQ({...e,writable:r,pull:t});return W(e.endOnDone===!1?n:ri(n,(o)=>ei(o)?He:PQ(r)))}),PQ=(e)=>tn((t)=>{let r=()=>t(He);if(e.closed){let n=X0(e,{readable:!1},()=>{n(),r()})}else Am(e,Ko,r)}),RQ=(e)=>wc((t)=>{let r=t.currentDispatcher,n=bo(),o=bo(),i=(S)=>Qn(o,Ef(()=>e.onError(S))),s=!1,c=(S)=>{s=!0,i(S)};e.writable.on("error",c);let l=X0(e.writable,{readable:!1},(S)=>{if(S)i(S);else Qn(n,He)});return e.pull.pipe(Ee((S)=>{let m=0;return tn((g)=>{let w=!1,k=()=>r.scheduleTask(A,0),A=()=>{e.writable.off("drain",A),e.writable.off("finish",k);for(;m<S.length;){if(w)return;if(!e.writable.write(S[m++],e.encoding,(h)=>{if(!h)return;if(e.writable.closed)i(h);else r.scheduleTask(()=>i(h),0)})){if(!w)e.writable.once("drain",A),e.writable.once("finish",k);return}}if(!w)g(He)};return A(),Fe(()=>{w=!0,e.writable.off("drain",A),e.writable.off("finish",k)})})}),ko({disableYield:!0}),e.endOnDone!==!1?Vn((S)=>(e.writable.end(),Jn(Wr(n),fr(S)))):Ie,Rn(Wr(o)),Eo(Fe(()=>{l();let S=()=>{e.writable.off("error",c),e.writable.off("error",S),e.writable.off("close",S)};if(e.writable.errored&&!e.writable.closed&&!s)e.writable.once("error",S),e.writable.once("close",S);else S()})))});import{finished as UQ,Readable as Cse}from"stream";var $c=(e)=>rn(DQ(e)),DQ=(e)=>Er((t,r)=>LQ({scope:r,readable:e.evaluate(),onError:e.onError??MQ,chunkSize:e.chunkSize,readSize:e.readSize,closeOnDone:e.closeOnDone}));var LQ=(e)=>{let t=e.readable,r=e.chunkSize??4096,n=e.closeOnDone??!0,o=e.exit??sP(void 0),i=e.latch??nP(!1);function s(){i.openUnsafe()}t.on("readable",s);let c=UQ(t,{readable:!0,writable:!1},(S)=>{o.current??=Pn(S?e.onError(S):dd()),i.openUnsafe()}),l=Qe(function S(){let m=e.readable.read(e.readSize);if(m===null){if(o.current)return o.current;if(t.readableEnded)return fe(dd());return i.closeUnsafe(),Ee(i.await,S)}let g=Ui(m);while(g.length<r){if(m=e.readable.read(e.readSize),m===null)break;g.push(m)}return W(g)});return or(sd(e.scope,Fe(()=>{if(t.off("readable",s),n)Am(t,c);else c()})),l)};var MQ=(e)=>new fO(e);var pa=(e)=>e instanceof globalThis.Error?e:new globalThis.Error(String(e)),ro=(e,t,r)=>{let{commands:n}=$S(r),o=globalThis.process.platform==="win32"?"windows":"posix",i=n.map((s)=>z0([s.command,...s.args],{format:o})).join(" | ");return st("ChildProcess",e)(t,[i])},Cm=(e)=>to(e)?Nc(e):e,NQ=(e)=>{if(e.command.includes("\x00"))return"The command contains a NUL character";let t=e.args.findIndex((r)=>Cm(r).includes("\x00"));if(t!==-1)return`Argument ${t+1} contains a NUL character`;for(let[r,n]of Object.entries(e.options.env??{}))if(n!==void 0&&Cm(n).includes("\x00"))return`The environment variable ${r} contains a NUL character`;return},e_=1000,BQ=10,t_=(e)=>{let t=()=>{};e.on("error",t),e.once("close",()=>e.off("error",t))},BS=(e)=>e.exitCode!==null||e.signalCode!==null,vm=(e)=>globalThis.process.platform!=="win32"&&e.options.detached!==!1,n_=(e)=>e?.code==="EPERM",r_=(e,t)=>{if(t.lost===!0)return!1;if(!BS(t))return!0;if(!vm(e))return!1;try{return globalThis.process.kill(-t.pid,0),!0}catch(r){return n_(r)}},KQ=(e,t=()=>{})=>{if(BS(e)){t(null);return}Tm.execFile("taskkill",["/pid",String(e.pid),"/T","/F"],{windowsHide:!0},t)},$Q=(e,t,r,n)=>{let o=Tm.spawn(e,t,r);for(let i of n){let s=o.stdio[i];if(s&&"allowHalfOpen"in s)s.allowHalfOpen=!0}return o},qQ=Se(function*(e){let t=yield*Cd,r=yield*Zs,n=Se(function*(N){if(Ga(N.cwd))return;return yield*t.access(N.cwd),r.resolve(N.cwd)}),o=(N)=>{if(N.env===void 0)return;let Z=N.extendEnv===!0?{...globalThis.process.env}:{};for(let[z,X]of Object.entries(N.env))if(X===void 0)delete Z[z];else Z[z]=Cm(X);return Z},i=(N)=>Js(N)?"pipe":N,s=(N)=>kd(N)?"pipe":N,c=(N)=>{let Z={stream:"pipe",encoding:"utf-8",endOnDone:!0};if(Ga(N.stdin))return Z;if(typeof N.stdin==="string")return{...Z,stream:N.stdin};if(Js(N.stdin))return{...Z,stream:N.stdin};return{stream:N.stdin.stream,encoding:N.stdin.encoding??Z.encoding,endOnDone:N.stdin.endOnDone??Z.endOnDone}},l=(N,Z)=>{let z=N[Z];if(Ga(z))return{stream:"pipe"};if(typeof z==="string")return{stream:z};if(kd(z))return{stream:z};return{stream:z.stream}},S=(N)=>{if(Ga(N.additionalFds))return[];let Z=[];for(let[z,X]of Object.entries(N.additionalFds)){let ee=km(z);if(Qt(ee))Z.push({fd:ee,config:X})}return Z.sort((z,X)=>z.fd-X.fd)},m=(N,Z,z,X)=>{let ee=[i(N.stream),s(Z.stream),s(z.stream)];if(X.length===0)return ee;let ie=X.reduce((oe,{fd:de})=>Math.max(oe,de),2);for(let oe=3;oe<=ie;oe++)ee[oe]="ignore";for(let{fd:oe}of X)ee[oe]="pipe";return ee},g=(N,Z,z)=>Pf(pR(sR(N,(X)=>eO(z,X)),Z)),w=Se(function*(N,Z,z,X){if(z.length===0)return{getInputFd:()=>Ad,getOutputFd:()=>Oc};let ee=new Map,ie=new Map,oe=(ge,ke,me)=>Qe(()=>{let Ke=Ad;if(ke&&"write"in ke)t_(ke),Ke=Kc({evaluate:()=>ke,onError:(Pe)=>ro(`fromWritable(fd${ge})`,pa(Pe),N)});if(me)return _e(g(me,Ke,X),()=>{ee.set(ge,Ke)});return ee.set(ge,Ke),He}),de=(ge,ke,me)=>{let Ke=Oc;if(ke&&"read"in ke){let Pe=new NS,er=void 0;Pe.on("error",(Mr)=>{er??=Mr}),ke.on("error",(Mr)=>Pe.destroy(Mr)),ke.pipe(Pe);let dr=(Mr)=>ro(`fromReadable(fd${ge})`,pa(Mr),N);Ke=nR(()=>er===void 0?$c({evaluate:()=>Pe,onError:dr}):Hx(dr(er)))}if(me)Ke=zf(Ke,me);ie.set(ge,Ke)};for(let{config:ge,fd:ke}of z){let me=Z.stdio[ke];switch(ge.type){case"input":{yield*oe(ke,me,ge.stream);break}case"output":{de(ke,me,ge.sink);break}case"duplex":{de(ke,me,ge.sink),yield*oe(ke,me,ge.stream);break}}}return{getInputFd:(ge)=>ee.get(ge)??Ad,getOutputFd:(ge)=>ie.get(ge)??Oc}}),k=(N,Z,z,X)=>Qe(()=>{let ee=Ad;if(gl(Z.stdin))t_(Z.stdin),ee=Kc({evaluate:()=>Z.stdin,onError:(ie)=>ro("fromWritable(stdin)",pa(ie),N),endOnDone:z.endOnDone,encoding:z.encoding});if(Js(z.stream))return or(g(z.stream,ee,X),ee);return W(ee)}),A=(N,Z,z,X)=>{let ee=Z.stdout?(()=>{let de=new NS;return Z.stdout.on("error",(ge)=>de.destroy(ge)),Z.stdout.pipe(de),$c({evaluate:()=>de,onError:(ge)=>ro("fromReadable(stdout)",pa(ge),N)})})():Oc,ie=Z.stderr?(()=>{let de=new NS;return Z.stderr.on("error",(ge)=>de.destroy(ge)),Z.stderr.pipe(de),$c({evaluate:()=>de,onError:(ge)=>ro("fromReadable(stderr)",pa(ge),N)})})():Oc;if(kd(z.stream))ee=zf(ee,z.stream);if(kd(X.stream))ie=zf(ie,X.stream);let oe=iR(ee,ie);return{stdout:ee,stderr:ie,all:oe}},y=(N,Z,z,X)=>tn((ee)=>{let ie=bo(),oe=N(Z.command,Z.args.map(Cm),z,X);return oe.on("error",(de)=>{if(Z.args.some(to))Object.assign(de,{spawnargs:[Z.command,...Z.args.map((ge)=>to(ge)?"<redacted>":ge)]});ee(fe(ro("spawn",de,Z)))}),oe.on("exit",(...de)=>{Qn(ie,qs(de))}),oe.on("lost",(de)=>{Qn(ie,Pn(ro("exitCode",de,Z)))}),oe.on("spawn",()=>{ee(W([oe,ie]))}),Fe(()=>{oe.kill("SIGTERM")})}),h=(N,Z,z)=>{if(globalThis.process.platform==="win32")return tn((X)=>{KQ(Z,(ee)=>{if(ee)X(fe(ro("kill",pa(ee),N)));else X(He)})});return Tr({try:()=>{globalThis.process.kill(-Z.pid,z)},catch:(X)=>ro("kill",pa(X),N)})},x=(N,Z)=>{try{globalThis.process.kill(-N.pid,Z)}catch{}},q=(N,Z,z)=>Qe(()=>{if(!Z.kill(z)){let ee=new globalThis.Error("Failed to kill child process");return fe(ro("kill",ee,N))}return He}),Y=(N,Z,z)=>tn((X)=>{let ee=Date.now()+z,ie,oe=()=>{clearTimeout(ie),Z.removeListener("exit",de),Z.removeListener("lost",de)},de=()=>{if(clearTimeout(ie),Date.now()>=ee||!r_(N,Z)){oe(),X(He);return}ie=setTimeout(de,BQ)};return Z.on("exit",de),Z.on("lost",de),de(),Fe(oe)}),I=Se(function*(N,Z,z,X){let ee=(ie)=>globalThis.process.platform==="win32"||vm(N)?h(N,Z,ie).pipe(zs((oe)=>BS(Z)&&n_(oe.cause)?He:q(N,Z,ie))):q(N,Z,ie);if(yield*ee(X?.killSignal??"SIGTERM"),Ga(X?.forceKillAfter))yield*Wr(z),yield*Y(N,Z,e_);else if(yield*Y(N,Z,$l(X.forceKillAfter)),r_(N,Z))yield*ee("SIGKILL"),yield*Y(N,Z,e_);yield*Wr(z)}),le=(N,Z)=>{let z=Z??"stdout";switch(z){case"stdout":return N.stdout;case"stderr":return N.stderr;case"all":return N.all;default:{let X=km(z);if(Qt(X))return N.getOutputFd(X);return N.stdout}}},ae=Se(function*(N){switch(N._tag){case"StandardCommand":{if(N.options.shell!==void 0&&N.options.shell!==!1&&N.args.length>0)return yield*fe(ln({module:"ChildProcess",method:"spawn",description:"The shell option cannot be combined with arguments; pass the whole script as the command"}));let Z=NQ(N);if(Z!==void 0)return yield*fe(ln({module:"ChildProcess",method:"spawn",description:Z}));let z=c(N.options),X=l(N.options,"stdout"),ee=l(N.options,"stderr"),ie=S(N.options),oe=!0,de=yield*n(N.options),ge=o(N.options),ke=m(z,X,ee,ie),me=ie.flatMap(({config:br,fd:En})=>br.type==="duplex"?[En]:[]),Ke=Se(function*(br,En){if(br.lost===!0||!oe)return;if(hf(En)){let[Fo]=yield*wo(Wr(En));if((Fo===0||WA(Fo))&&!vm(N))return}yield*hx(I(N,br,En,N.options))}),Pe=yield*e,er=Fi(),[dr,Mr]=yield*_n(y(Pe,N,Z0(N.options,{cwd:de,env:ge,stdio:ke},process.platform),me),([br,En],Fo)=>Ic([Zr(er,Fo),Ke(br,En)],{concurrency:"unbounded",discard:!0})),bs=K0(dr.pid);if(vm(N))dr.on("exit",(br)=>{if(oe&&br!==0&&gl(br))x(dr,N.options.killSignal??"SIGTERM")});let Is=Fe(()=>{if(!oe)dr.ref(),oe=!0}),ws=Fe(()=>{if(oe)dr.unref(),oe=!1;return Is}),mo=bo(),ol=yield*Ni(er)(k(N,dr,z,mo)),{all:il,stderr:sl,stdout:al}=A(N,dr,X,ee),{getInputFd:cl,getOutputFd:pl}=yield*Ni(er)(w(N,dr,ie,mo)),dl=Qe(()=>hf(Mr)?or(Wr(Mr),!1):W(!0)),ul=Ee(Rn(Wr(Mr),Wr(mo)),([br,En])=>{if(hf(mo))return Wr(mo);if(gl(br))return W(B0(br));let Fo=new globalThis.Error(`Process interrupted due to receipt of signal: '${En}'`);return fe(ro("exitCode",Fo,N))});return MS({pid:bs,exitCode:ul,isRunning:dl,kill:(br)=>I(N,dr,Mr,br),stdin:ol,stdout:al,stderr:sl,all:il,getInputFd:cl,getOutputFd:pl,unref:ws})}case"PipedCommand":{let{commands:Z,pipeOptions:z}=$S(N),[X,...ee]=Z,ie=[yield*ae(X)];for(let ke=0;ke<ee.length;ke++){let me=ee[ke],Ke=z[ke]??{},Pe=c(me.options),er=Co(W(le(ie[ie.length-1],Ke.from))),dr=Ke.to??"stdin";if(dr==="stdin")ie.push(yield*ae(Em(me.command,me.args,{...me.options,stdin:{...Pe,stream:er}})));else{let Mr=km(dr);if(Qt(Mr)){let bs=Y0(Mr),Is=me.options.additionalFds??{},ws=Is[bs],mo=ws?.type==="duplex"?{...ws,stream:er}:{type:"input",stream:er};ie.push(yield*ae(Em(me.command,me.args,{...me.options,additionalFds:{...Is,[bs]:mo}})))}else ie.push(yield*ae(Em(me.command,me.args,{...me.options,stdin:{...Pe,stream:er}})))}}let oe=ie[ie.length-1],de=(ke)=>Wi([...ie].reverse(),(me)=>hx(me.kill(ke)),{discard:!0}),ge=wr(function*(){let ke=[];for(let me of ie)ke.push(yield*me.unref);return Wi([...ke].reverse(),(me)=>me,{discard:!0})});return MS({pid:oe.pid,exitCode:oe.exitCode,isRunning:oe.isRunning,kill:de,stdin:ie[0].stdin,stdout:oe.stdout,stderr:oe.stderr,all:oe.all,getInputFd:oe.getInputFd,getOutputFd:oe.getOutputFd,unref:ge})}}});return $0(ae)}),KS=Sc(Fc,qQ(W($Q)));var $S=(e)=>{let t=[],r=[],n=(c)=>{switch(c._tag){case"StandardCommand":{t.push(c);break}case"PipedCommand":{n(c.left),r.push(c.options),n(c.right);break}}};if(n(e),t.length===0)throw Error("flattenCommand produced empty commands array");let[o,...i]=t;return{commands:[o,...i],pipeOptions:r}};import*as s_ from"crypto";import*as be from"fs";import*as a_ from"os";import*as di from"path";var ht=(e)=>(t)=>ln({module:"FileSystem",method:e,description:t.message??String(t)}),c_=(e,t)=>{let r=Number(e);if(!Number.isSafeInteger(r))throw RangeError(`${t} exceeds the safe integer range: ${e}`);return r},o_=(e)=>ng(Ms(e),UO),p_=(e)=>BigInt.asUintN(64,e),qS=(e)=>Rl(Ms(e),p_),GQ=(e,t)=>Tr({try:()=>c_(e,"position"),catch:ht(t)}),zQ=(()=>{let e=Ot(be.access,st("FileSystem","access"),ht("access"));return(t,r)=>{let n=be.constants.F_OK;if(r?.readable)n|=be.constants.R_OK;if(r?.writable)n|=be.constants.W_OK;return e(t,n)}})(),jQ=(()=>{let e=Ot(be.cp,st("FileSystem","copy"),ht("copy"));return(t,r,n)=>e(t,r,{force:n?.overwrite??!1,preserveTimestamps:n?.preserveTimestamps??!1,recursive:!0})})(),QQ=(()=>{let e=Ot(be.copyFile,st("FileSystem","copyFile"),ht("copyFile"));return(t,r)=>e(t,r)})(),HQ=(()=>{let e=Ot(be.chmod,st("FileSystem","chmod"),ht("chmod"));return(t,r)=>e(t,r)})(),VQ=(()=>{let e=Ot(be.chown,st("FileSystem","chown"),ht("chown"));return(t,r,n)=>e(t,r,n)})(),JQ=(()=>{let e=Ot(be.link,st("FileSystem","link"),ht("link"));return(t,r)=>e(t,r)})(),YQ=(()=>{let e=Ot(be.mkdir,st("FileSystem","makeDirectory"),ht("makeDirectory"));return(t,r)=>e(t,{recursive:r?.recursive??!1,mode:r?.mode})})(),WS=(e)=>{let t=Ot(be.mkdtemp,st("FileSystem",e),ht(e));return(r)=>Qe(()=>{let n=r?.prefix??"",o=typeof r?.directory==="string"?di.join(r.directory,"."):a_.tmpdir();return t(n?di.join(o,n):o+"/")})},ZQ=WS("makeTempDirectory"),GS=(e)=>{let t=Ot(be.rm,st("FileSystem",e),ht(e));return(r,n)=>t(r,{recursive:n?.recursive??!1,force:n?.force??!1})},XQ=GS("remove"),eH=(()=>{let e=WS("makeTempDirectoryScoped"),t=GS("makeTempDirectoryScoped");return(r)=>_n(e(r),(n)=>wo(t(n,{recursive:!0,force:!0})))})(),tH=(e)=>{let{O_APPEND:t,O_CREAT:r,O_EXCL:n,O_RDONLY:o,O_RDWR:i,O_TRUNC:s,O_WRONLY:c}=be.constants;switch(e){case"r":return o;case"r+":return i;case"w":return s|r|c;case"wx":return s|r|c|n;case"w+":return s|r|i;case"wx+":return s|r|i|n;case"a":return t|r|c;case"ax":return t|r|c|n;case"a+":return t|r|i;case"ax+":return t|r|i|n}},rH=(e,t)=>Qe(()=>{let{O_NOFOLLOW:r}=be.constants;if(process.platform==="win32"||typeof r!=="number"||r===0)return fe(ln({module:"FileSystem",method:e,description:"noFollow is not supported on this platform"}));return W(tH(t)|r)}),nH=(e)=>{let t=Ot(be.open,st("FileSystem",e),ht(e)),r=Ot(be.close,st("FileSystem",e),ht(e));return(n,o)=>Ci(_n(o?.noFollow===!0?Ee(rH(e,o.flag??"r"),(i)=>t(n,i,o.mode)):t(n,o?.flag??"r",o?.mode),(i)=>wo(r(i))),_e((i)=>sH(i,o?.flag?.startsWith("a")??!1)))},oH=nH("open"),iH=(e)=>e.reason.cause?.code==="ESPIPE",i_=(e)=>ln({module:"FileSystem",method:e,description:"Cannot read before the start of the file"}),sH=(()=>{let e=(m)=>Ot(be.read,st("FileSystem",m),ht(m)),t=e("read"),r=e("readAlloc"),n=Ot(be.fstat,st("FileSystem","stat"),ht("stat")),o=Ot(be.ftruncate,st("FileSystem","truncate"),ht("truncate")),i=Ot(be.fsync,st("FileSystem","sync"),ht("sync")),s=(m)=>{let g=Ot(be.write,st("FileSystem",m),ht(m));return(w,k,A)=>g(w,k,0,k.length,A)},c=s("write"),l=s("writeAll");class S{[jf];fd;append;position=BigInt(0);sequential=!1;constructor(m,g){this[jf]=jf,this.fd=m,this.append=g}get stat(){return Ee(n(this.fd,{bigint:!0}),l_)}get sync(){return i(this.fd)}atCursor(m){return Qe(()=>{if(this.sequential)return m(null);let g=this.position;return zi(_e(m(g),(w)=>(this.position=g+BigInt(w),w)),iH,()=>(this.sequential=!0,m(null)))})}writeOnce(m,g,w){return this.append?Qe(()=>g(this.fd,w,void 0)):this.atCursor((k)=>k===null?g(this.fd,w,void 0):Ee(GQ(k,m),(A)=>g(this.fd,w,A)))}seek(m,g){return Qe(()=>{let w=g==="start"?m:this.position+m;if(w<BigInt(0))return fe(ln({module:"FileSystem",method:"seek",description:"Cannot seek before the start of the file"}));return this.position=w,W(w)})}read(m,g){return Qe(()=>{let w=g?.position;if(w===void 0)return this.atCursor((k)=>t(this.fd,{buffer:m,position:k}));return w<BigInt(0)?fe(i_("read")):t(this.fd,{buffer:m,position:w})})}readAlloc(m,g){return Qe(()=>{try{if(!Number.isInteger(m)||m<0)throw RangeError("size must be a non-negative integer");let w=g?.position;if(w!==void 0&&w<BigInt(0))return fe(i_("readAlloc"));let k=Buffer.allocUnsafeSlow(m),A=(y)=>r(this.fd,{buffer:k,position:y});return _e(w===void 0?this.atCursor(A):A(w),(y)=>{if(y===0)return he();if(y===m)return Re(k);let h=Buffer.allocUnsafeSlow(y);return k.copy(h,0,0,y),Re(h)})}catch(w){return fe(ht("readAlloc")(w))}})}truncate(m){return _e(o(this.fd,m||void 0),()=>{if(!this.append){let g=BigInt(m??0);if(this.position>g)this.position=g}})}write(m){return this.writeOnce("write",c,m)}writeAllChunk(m){return Ee(this.writeOnce("writeAll",l,m),(g)=>{if(g===0)return fe(Yn({module:"FileSystem",method:"writeAll",_tag:"WriteZero",pathOrDescriptor:this.fd,description:"write returned 0 bytes written"}));return g<m.length?this.writeAllChunk(m.subarray(g)):He})}writeAll(m){return m.length===0?He:this.writeAllChunk(m)}}return(m,g)=>new S(m,g)})(),d_=(e)=>{let t=WS(e);return Se(function*(r){let n=yield*t(r),o=s_.randomBytes(6).toString("hex"),i=di.join(n,r?.suffix?`${o}${r.suffix}`:o);return yield*m_(i,new Uint8Array(0)),i})},aH=d_("makeTempFile"),cH=(()=>{let e=d_("makeTempFileScoped"),t=GS("makeTempFileScoped");return(r)=>_n(e(r),(n)=>wo(t(di.dirname(n),{recursive:!0,force:!0})))})(),pH=(e,t)=>Ws({try:()=>be.promises.readdir(e,t),catch:(r)=>st("FileSystem","readDirectory")(r,[e])}),dH=(e)=>Ws({try:()=>be.promises.readdir(e,{withFileTypes:!0}),catch:(t)=>st("FileSystem","readDirectoryEntries")(t,[e])}).pipe(_e((t)=>t.map((r)=>({name:r.name,type:u_(r)})))),uH=(e)=>tn((t,r)=>{try{be.readFile(e,{signal:r},(n,o)=>{if(n)t(fe(st("FileSystem","readFile")(n,[e])));else t(W(o))})}catch(n){t(fe(ht("readFile")(n)))}}),lH=(()=>{let e=Ot(be.readlink,st("FileSystem","readLink"),ht("readLink"));return(t)=>e(t)})(),fH=(()=>{let e=Ot(process.platform==="win32"?be.realpath.native:be.realpath,st("FileSystem","realPath"),ht("realPath"));return(t)=>e(t)})(),mH=(()=>{let e=Ot(be.rename,st("FileSystem","rename"),ht("rename"));return(t,r)=>e(t,r)})(),u_=(e)=>e.isFile()?"File":e.isDirectory()?"Directory":e.isSymbolicLink()?"SymbolicLink":e.isBlockDevice()?"BlockDevice":e.isCharacterDevice()?"CharacterDevice":e.isFIFO()?"FIFO":e.isSocket()?"Socket":"Unknown",l_=(e,t="stat")=>Tr({try:()=>({type:u_(e),mtime:Ms(e.mtime),atime:Ms(e.atime),birthtime:Ms(e.birthtime),dev:p_(e.dev),rdev:qS(e.rdev),ino:qS(e.ino),mode:c_(e.mode,"mode"),nlink:qS(e.nlink),uid:o_(e.uid),gid:o_(e.gid),size:Ex(e.size),blksize:e.blksize!==void 0?Re(Ex(e.blksize)):he(),blocks:Ms(e.blocks)}),catch:ht(t)}),f_=(e,t)=>{let r=Ot(t,st("FileSystem",e),ht(e));return(n)=>Ee(r(n,{bigint:!0}),(o)=>l_(o,e))},zS=f_("stat",be.stat),hH=f_("lstat",be.lstat),yH=(()=>{let e=Ot(be.symlink,st("FileSystem","symlink"),ht("symlink"));return(t,r)=>e(t,r)})(),gH=(()=>{let e=Ot(be.truncate,st("FileSystem","truncate"),ht("truncate"));return(t,r)=>e(t,r)})(),xH=(()=>{let e=Ot(be.utimes,st("FileSystem","utime"),ht("utime"));return(t,r,n)=>e(t,r,n)})(),SH=(e,t,r)=>rR((n)=>_n(Fe(()=>{let o=t.type==="Directory"?e:di.dirname(e),i=be.watch(e,{recursive:r?.recursive??!1},(s,c)=>{if(!c)return;switch(s){case"rename":{Rf(AO(zS(di.resolve(o,c)),{onSuccess:(l)=>bd(n,{_tag:"Create",path:c}),onFailure:(l)=>bd(n,{_tag:"Remove",path:c})}));return}case"change":{Ji(n,{_tag:"Update",path:c});return}}});return i.on("error",(s)=>{Id(n,lO(Yn({module:"FileSystem",_tag:"Unknown",method:"watch",pathOrDescriptor:e,cause:s})))}),i.on("close",()=>{vo(n)}),i}),(o)=>Fe(()=>o.close())).pipe(Gi(()=>Fe(()=>r?.onReady?.())))),bH=(e,t,r)=>Ic([zS(t),Af(Qf)]).pipe(_e(([n,o])=>Ov(o,()=>e).pipe(ng((i)=>i.register(t,n,r)),ur(()=>SH(t,n,r)))),Co),m_=(e,t,r)=>tn((n,o)=>{try{be.writeFile(e,t,{signal:o,flag:r?.flag,mode:r?.mode},(i)=>{if(i)n(fe(st("FileSystem","writeFile")(i,[e])));else n(He)})}catch(i){n(fe(ht("writeFile")(i)))}}),IH=_e(Af(Qf),(e)=>fR({access:zQ,chmod:HQ,chown:VQ,copy:jQ,copyFile:QQ,link:JQ,lstat:hH,makeDirectory:YQ,makeTempDirectory:ZQ,makeTempDirectoryScoped:eH,makeTempFile:aH,makeTempFileScoped:cH,open:oH,readDirectory:pH,readDirectoryEntries:dH,readFile:uH,readLink:lH,realPath:fH,remove:XQ,rename:mH,stat:zS,symlink:yH,truncate:gH,utimes:xH,watch(t,r){return bH(e,t,r)},writeFile:m_})),h_=Sc(Cd)(IH);var y_=h_;import*as Zd from"path";import*as Om from"url";var jS=(e)=>({fromFileUrl:(t)=>Tr({try:()=>Om.fileURLToPath(t,{windows:e}),catch:(r)=>new Sd({module:"Path",method:"fromFileUrl",cause:r})}),toFileUrl:(t)=>Tr({try:()=>Om.pathToFileURL(t,{windows:e}),catch:(r)=>new Sd({module:"Path",method:"toFileUrl",cause:r})})}),kH=xc(Zs)(Hf({...Zd.posix,...jS(!1)})),AH=xc(Zs)(Hf({...Zd.win32,...jS(!0)})),g_=xc(Zs)(Hf({...Zd,...jS(void 0)}));var x_=g_;var QS="~effect/Stdio",S_=Vt(QS),b_=(e)=>({[QS]:QS,stdinIsTerminal:W(!1),stdoutIsTerminal:W(!1),stderrIsTerminal:W(!1),...e});var TH=Fe(()=>{process.nextTick(()=>{if(process.stdin.readableFlowing===null)process.stdin.pause()})}),w_=xc(S_,b_({args:Fe(()=>process.argv.slice(2)),stdinIsTerminal:Fe(()=>process.stdin.isTTY===!0),stdoutIsTerminal:Fe(()=>process.stdout.isTTY===!0),stderrIsTerminal:Fe(()=>process.stderr.isTTY===!0),stdout:(e)=>Kc({evaluate:()=>process.stdout,onError:(t)=>Yn({module:"Stdio",method:"stdout",_tag:"Unknown",cause:t}),endOnDone:e?.endOnDone??!1}),stderr:(e)=>Kc({evaluate:()=>process.stderr,onError:(t)=>Yn({module:"Stdio",method:"stderr",_tag:"Unknown",cause:t}),endOnDone:e?.endOnDone??!1}),stdin:Co(or(kc(()=>TH),$c({evaluate:()=>process.stdin,onError:(e)=>Yn({module:"Stdio",method:"stdin",_tag:"Unknown",cause:e}),closeOnDone:!1})))}));var E_=w_;var k_="~effect/http/Cookies";var A_="~effect/http/Cookies/Cookie";var RH={[k_]:k_,...Pi,toJSON(){return{_id:"effect/Cookies",cookies:qv(this.cookies,(e)=>e.toJSON())}},pipe(){return Ze(this,arguments)}},_H=(e)=>{let t=Object.create(RH);return t.cookies=e,t},UH=(e)=>{let t={};for(let r of e)Jr(t,r.name,r);return _H(t)};var v_=UH([]);var Qse={[A_]:A_,...Pi,toJSON(){return{_id:"effect/Cookies/Cookie",name:this.name,value:this.value,options:this.options}}};var T_=Symbol.for("~effect/http/Headers");var Pm=Object.defineProperties(Object.create(null),{[T_]:{value:T_},[Ts]:{value(e){return LH(this,cn(e,MH))}},toJSON:{value(){return Wn(this)}},[Et]:{value(e){return DH(this,e)}},[wt]:{value(){return Ap(this)}},toString:{value:Pi.toString},[Yr]:{value:Pi[Yr]}});var DH=Gv(mv()),da=Object.create(Pm),O_=(e)=>{if(e===void 0)return da;else if(Symbol.iterator in e){let r=Object.create(Pm);for(let[n,o]of e){let i=n.toLowerCase();r[i]=i in r?`${r[i]}, ${o}`:o}return r}let t=Object.create(Pm);for(let[r,n]of Object.entries(e))if(Array.isArray(n))t[r.toLowerCase()]=n.join(", ");else if(n!==void 0)t[r.toLowerCase()]=n;return t},P_=(e)=>Object.setPrototypeOf(e,Pm);var LH=B(2,(e,t)=>{let r={...e},n=(o)=>{if(typeof o==="string"){let i=o.toLowerCase();if(i in e)r[i]=aa(e[i])}else for(let i in e)if(i.search(o)!==-1)r[i]=aa(e[i])};if(Array.isArray(t))for(let o=0;o<t.length;o++)n(t[o]);else n(t);return r});var MH=jt("effect/Headers/CurrentRedactedNames",{defaultValue:()=>["authorization","cookie","set-cookie","x-api-key"]});var Rm=(e,t,r)=>Yt(e)?r(t):zr(e,r);function __(e){let t=FH(e);return(r,n,o)=>{try{return t(r,n,o)}catch(i){return Cr(i)}}}function FH(e){if(e._tag==="Middleware")return(r,n,o)=>{let i=Yt(r)?e.decode(kr(Pd(n)),o):e.decode(Uf(r,Pd),o);return R_(i)};let t=e.decode;switch(t._tag){case"Passthrough":return(r,n)=>Yt(r)?kr(n):r;case"Transform":{let r=(n)=>n===$e?Un:kr(t.transform(n));return(n,o)=>Rm(n,o,r)}case"TransformOptional":{let r=(n)=>Xx(t.transform(Pd(n)));return(n,o)=>Rm(n,o,r)}case"TransformEffect":return(r,n,o)=>Rm(r,n,(i)=>i===$e?Un:t.transform(i,o));case"TransformOptionalEffect":return(r,n,o)=>Rm(r,n,(i)=>R_(t.transform(Pd(i),o)))}}var R_=(e)=>zr(e,Xx),U_=(e,t,r,n)=>Gr(n,(o)=>Gs(()=>qi(o,(i)=>new gR(e,i,t,r))));function NH(e,t){let r=__(e.link.transformation),n;return(o,i)=>{if(o===$e)return Un;if(e.isConstructed(o))return oi;let s=(n??=t(e.link.to))(o,i);return r(s,o,i)}}function BH(e,t){let r=e.context.constructorDefault;return(n,o)=>{if(n!==$e&&n!==void 0)return t(n,o);let i=r;if(ut(i)&&i._tag==="Success"){let s=t(i[De],o);return Yt(s)?i:s}return zr(U_(e,n,o,i),(s)=>{let c=t(s,o);return Yt(c)?kr(s):c})}}function VS(e,t){let r=t(e);return e.context?.constructorDefault===void 0?r:BH(e,r)}function Xd(e,t,r,n,o){if(e._tag==="Declaration")for(let A of e.typeParameters)t(A);let i=r?wm(e):void 0,s=i?NH(i,t):n??e.getParser(t,r),{checks:c,encoding:l}=e,S=l?.map((A)=>__(A.transformation)),m=e.encodingChecks;if(!l&&!c&&!m)return s;let g,w=(A,y)=>{let h=s(A,y);try{if(m&&!y.disableChecks)if(ut(h)){if(h._tag==="Success"){let x=Yt(h)?A:h[De];if(A!==$e&&x!==$e){let q=Xi(m,A,void 0,e,y);if(q)h=fe(new Rr(e,q,A,y))}}}else h=Ee(h,(x)=>{if(A!==$e&&x!==$e){let q=Xi(m,A,void 0,e,y);if(q)return fe(new Rr(e,q,A,y))}return W(x)});if(c&&!y.disableChecks)if(ut(h)){if(h._tag==="Success"){let x=Yt(h)?A:h[De];if(x===$e)return h;let q=Xi(c,x,void 0,e,y);if(q)h=fe(new Rr(e,q,x,y))}}else h=Ee(h,(x)=>{if(x!==$e){let q=Xi(c,x,void 0,e,y);if(q)return fe(new Rr(e,q,x,y))}return W(x)});return h}catch(x){return Cr(x)}},k=o===void 0?w:o(w);if(!l)return k;return(A,y)=>{let h=g??=l.map((Y)=>t(Y.to)),x=A,q=h[h.length-1](A,y);for(let Y=l.length-1;Y>=0;Y--)if(q=S[Y](q,x,y),Y!==0){let I=h[Y-1];if(q._tag==="Success")x=q[De],q=I(x,y);else q=zr(q,(le)=>{let ae=I(le,y);return Yt(ae)?kr(le):ae})}if(q._tag==="Success"){let Y=q[De],I=k(Y,y);return Yt(I)?q:I}return q=U_(e,A,y,q),zr(q,(Y)=>{let I=k(Y,y);return Yt(I)?kr(Y):I})}}var JS=Symbol(),D_=new WeakMap,L_,eu=!1;var $H=(e)=>eu?_m(hn,e,"parser"):hn(e).parser,M_=(e)=>eu?_m(hn,e,"makeEffect"):hn(e).makeEffect,qH=(e)=>VS(e,M_);class YS{ast;constructor(e){this.ast=e}get decodeEffect(){return this.cachedDecodeEffect??=Xd(this.ast,$H)}get parser(){return this.decodeEffect}get makeEffect(){return this.cachedMakeEffect??=Xd(this.ast,M_,qH)}}class F_ extends YS{compiled;resolve;constructor(e,t,r){super(e);this.compiled=t,this.resolve=r}save(e,t){return Object.defineProperty(this,e,{value:t}),t}operation(e){let t=this.compiled;return typeof t==="function"?t(this.ast,this.resolve,e):t?.[e]}get is(){return this.save("is",this.operation("is"))}get decode(){return this.save("decode",this.operation("decode"))}get make(){return this.save("make",this.operation("make"))}get compiledMakeEffect(){return this.save("compiledMakeEffect",this.operation("makeEffect"))}get decodeEffect(){return this.save("decodeEffect",this.operation("decodeEffect")??Xd(this.ast,(e)=>_m(this.resolve,e,"parser")))}get parser(){let e=this.decode;return e===void 0?this.decodeEffect:this.save("parser",WH(e,()=>this.decodeEffect))}get makeEffect(){let e=this.compiledMakeEffect;if(e!==void 0)return this.save("makeEffect",e);let t=(r)=>_m(this.resolve,r,"makeEffect");return this.save("makeEffect",Xd(this.ast,t,(r)=>VS(r,t)))}}function WH(e,t){let r;return(n,o)=>{if(n!==$e)try{let i=e(n,o);if(i!==JS)return i===n?oi:kr(i)}catch(i){return Cr(i)}return(r??=t())(n,o)}}function _m(e,t,r){let n=e(t);if(n.compiled===void 0||Object.hasOwn(n,r))return n[r];let o;return(i,s)=>(o??=n[r])(i,s)}function hn(e){let t=D_.get(e);if(t!==void 0)return t;let r=L_===void 0?new YS(e):new F_(e,L_(e,hn),hn);return D_.set(e,r),r}function XS(e){let t=e.ast,r;return(n,o)=>H_(r??=hn(ci(t)),n,Q_(o))}function Um(e){let t=XS(e);return(r,n)=>VH(Hs(t(r,n)))}function B_(e){return YH(ci(e.ast))}function K_(e){return jH(e.ast)}function zH(e){if(!eu){let o=G_(tb(e));return(i)=>{let s=o(i,oa);if(Xr(s))return!0;return Xs(s.cause,"Type guard adapter can only return false for schema issues"),!1}}let t=hn(e),r=t.is;if(r!==void 0)return(o)=>{try{return r(o,oa)}catch(i){return Xs(bf(i),"Type guard adapter can only return false for schema issues"),!1}};let n=t.parser;return(o)=>{let i=Hs(rb(n(o,oa),o));if(Xr(i))return!0;return Xs(i.cause,"Type guard adapter can only return false for schema issues"),!1}}function jH(e){let t=ci(e),r=(n)=>(r=zH(t),r(n));return(n)=>r(n)}function eb(e,t){let r=tb(e.ast);return W_(r,t)}function $_(e,t){return HH(eb(e,t))}function q_(e,t){let r=tb(fn(e.ast));return W_(r,t)}function W_(e,t){return t===void 0?e:(r,n)=>e(r,n?{...t,...n}:t)}var N_=(e)=>{if(e===$e)return fe(new jr);return W(e)};function tb(e){return QH(ZH,e)}function rb(e,t){if(Yt(e))return W(t);if(!ut(e))return zr(e,N_);return e[De]===$e?N_($e):e}function QH(e,t){let r;return(n,o)=>rb((r??=e(t))(n,o??oa),n)}function G_(e){return(t,r)=>Hs(e(t,r))}function HH(e){let t=G_(e);return(r,n)=>{let o=t(r,n);if(Xr(o))return Re(o.value);return Xs(o.cause,"Option adapter can only return none for schema issues"),he()}}function VH(e){if(Xr(e))return Re(e.value);return Xs(e.cause,"Option adapter can only return none for schema issues"),he()}function JH(e,t){let r=Hs(e);if(Xr(r))return r.value;let n=Xs(r.cause,t);throw Error("Schema validation failed",{cause:n})}var z_="Constructor adapter can only throw schema issues";function j_(e){throw Error(z_,{cause:bf(e)})}function YH(e){let t;return(r,n)=>ZS(t??=hn(e),r,n)}function Q_(e){return e?.disableChecks?{...e.parseOptions,disableChecks:!0}:e?.parseOptions??oa}function H_(e,t,r){return rb(e.makeEffect(t,r),t)}function ZS(e,t,r){let n=Q_(r),o=eu?e.make:void 0;if(o!==void 0&&t!==$e){let i;try{i=o(t,n)}catch(s){j_(s)}if(i!==JS&&i!==$e)return i}return JH(H_(e,t,n),z_)}function V_(e,t,r,n){let o=hn(e),i=wm(e);if(i===void 0||o.make!==void 0||o.compiledMakeEffect!==void 0)return ZS(o,t,r);if(i.isConstructed(t))return t;let s=ZS((o.resolve??hn)(i.link.to),t,r);try{return n(s)}catch(c){j_(c)}}var ZH=(e)=>hn(e).parser;var Dm="~effect/Schema/Schema",J_=Symbol(),XH={[Dm]:Dm,get make(){let e=B_(this);return Object.defineProperty(this,"make",{value:e,enumerable:!0}),e},get makeEffect(){let e=XS(this);return Object.defineProperty(this,"makeEffect",{value:e,enumerable:!0}),e},get makeOption(){let e=Um(this);return Object.defineProperty(this,"makeOption",{value:e,enumerable:!0}),e},pipe(){return Ze(this,arguments)},annotate(e){return this.rebuild(gm(this.ast,e))},annotateKey(e){return this.rebuild(bm(this.ast,e))},check(...e){return this.rebuild(ia(this.ast,e))},rebuild(e){return qc(e,this[J_])}};function qc(e,t){function r(){}let n=Object.setPrototypeOf(r,XH);if(t&&(Object.hasOwn(t,"name")||Object.hasOwn(t,"length")||Object.hasOwn(t,"__proto__")))Object.defineProperties(n,Object.getOwnPropertyDescriptors({...t}));else Object.assign(n,t);return n[J_]=t,n.ast=e,n}function nV(e,t){let r=Ti((o)=>{let i=Lc(o,void 0),s=e(i,n);return s===i?null:s}),n=Sm((o)=>{let i=r(Hd(o));if(i===null)return o;let s=Lc(i,o.context);return o.context===void 0?s:k0(s,oV(o.context))},t);return n}function oV(e){return e.constructorDefault===void 0?e:new gS(e.isOptional,e.isMutable,void 0,e.annotations)}function iV(e){if(e.propertySignatures.some((t)=>typeof t.name!=="string"))throw new globalThis.Error("Objects property names must be strings",{cause:e})}function sV(e){return(t)=>{let r=[...t].sort((o,i)=>e(pi(o))-e(pi(i)));if(!r.some((o,i)=>o!==t[i]))return t;return r}}function Z_(e){return qc(fV(e.ast),{schema:e})}var aV=sV((e)=>{switch(e._tag){case"Null":case"Boolean":case"Number":case"BigInt":case"Symbol":case"UniqueSymbol":return 0;default:return 1}});function cV(e,t,r){switch(e._tag){case"Declaration":{let n=e.typeParameters.map((S)=>qc(t(pi(S)))),o=e.annotations?.toCodecStringTree;if(yo(o)){let S=o(n);if(S===void 0)return e;return _r(e,[xm(S,t)])}let i=e.annotations?.toCodecJson,s=yo(i)?i(n):void 0,c=s===void 0?e.annotations?.toCodec:void 0,l=s??(yo(c)?c(n):void 0);return l===void 0?r(e):_r(e,[xm(l,t)])}case"Null":return _r(e,[pV]);case"Boolean":return _r(e,[dV]);case"Unknown":case"ObjectKeyword":return _r(e,[DS]);case"Enum":case"Number":case"Literal":case"UniqueSymbol":case"Symbol":case"BigInt":return e.toCodecStringTree();case"Objects":return iV(e),e.recur(t,US);case"Union":{let n=aV(e.types);if(n!==e.types)return new Zi(n,e.options,e.annotations,e.checks,e.encoding,e.context,e.encodingChecks).recur(t);return e.recur(t)}case"Arrays":case"Suspend":return e.recur(t)}return e}var pV=new Ur(new Oo("null"),new ir(Lt(()=>null),Lt(()=>"null"))),dV=new Ur(new Zi([new Oo("true"),new Oo("false")]),new ir(Lt((e)=>e==="true"),tm())),uV=new ir(Lt((e)=>typeof e==="string"?[e]:e),To()),lV=(e)=>e.transformation===uV,fV=nV((e,t)=>cV(e,t,(r)=>{throw new globalThis.Error("Missing structural codec for StringTree",{cause:r})}),{stopAt:lV});var ua=(e)=>e;var Wc="~effect/Schema/SchemaError";function eU(e){return je(e,Wc)&&e[Wc]===Wc}var tu=Dm;function hV(){return(e,t,r)=>vt(new Qd(e.map(mm),(n)=>t(n.map((o)=>vt(o))),r))}function yV(e,t){return hV()([],()=>(r,n,o)=>e(r)?W(r):fe(new eo(n,r,o)),t)}function gV(e){return(t)=>tU(tU(t).annotate(e))}class ib extends Ho("SchemaError"){[Wc]=Wc;constructor(e){let t=Ps();Gn(0);try{super({issue:e})}finally{Gn(t)}}get message(){return vR(this.issue)}toJSON(){return{_tag:this._tag,message:this.message}}[Yr](){return this.toJSON()}toString(){return`SchemaError(${this.message})`}}function xV(e){return eU(e)}function oU(e){if(ut(e))return SV(e);return Gr(e,(t)=>Gs(()=>qi(t,(r)=>new ib(r))))}function SV(e){return Xr(e)?e:$i(qi(e.cause,(t)=>new ib(t)))}function iU(e,t){let r;for(let n of e.reasons){if(!Sf(n)||!xV(n.error))throw new globalThis.Error(t,{cause:e});r??=n.error}if(r===void 0)throw new globalThis.Error(t,{cause:e});return r}function bV(e){return Ix(e).then((t)=>{if(Xr(t))return t.value;throw iU(t.cause,"Promise adapter can only reject schema errors")})}function IV(e){let t=Hs(e);if(Xr(t))return t.value;throw iU(t.cause,"Sync adapter can only throw schema errors")}var sb=K_;function es(e,t){let r=eb(e,t);return(n,o)=>oU(r(n,o))}var ts=$_;function no(e,t){let r=es(e,t);return(n,o)=>bV(r(n,o))}function wV(e,t){let r=es(e,t);return(n,o)=>IV(r(n,o))}function sU(e,t){let r=q_(e,t);return(n,o)=>oU(r(n,o))}var vt=qc;function EV(e){return je(e,tu)&&e[tu]===tu}var u=ua((e)=>vt(Im(e.ast),{schema:e}));var ab=ua((e)=>{let t=CV(e);return vt(C0(e.ast),{schema:t})});var kV=ua((e)=>vt(pi(e.ast),{schema:e})),ru="~effect/Schema/flip";function AV(e){return je(e,ru)&&e[ru]===ru}function tU(e){if(AV(e))return e.schema.rebuild(fn(e.ast));return vt(fn(e.ast),{[ru]:ru,schema:e})}function v(e){let t=vt(new Oo(e),{literal:e,transform(r){return t.pipe(rs(v(r),{decode:Lt(()=>r),encode:Lt(()=>e)}))}});return t}var j=vt(zd),aU=vt(um),vV=vt(xS),a=vt(Yi);var mr=vt(SS),V=vt(i0);function cb(e,t){return vt(e,{fields:t,mapFields(r,n){let o=r(this.fields);return cb(fm(o,n?.unsafePreserveChecks?this.ast.checks:void 0),o)}})}function p(e){return cb(fm(e,void 0),e)}function $t(e,t){return vt(OS(e.ast,t.ast),{key:e,value:t})}function cU(e,t){return vt(l0(e.ast,t.map(mm)),{schema:e,records:t})}var _=ua((e)=>vt(new lm(!1,[],[e.ast]),{value:e}));function pU(e,t){return vt(e,{members:t,mapMembers(r,n){let o=r(this.members);return pU(hm(o,this.ast.options,n?.unsafePreserveChecks?this.ast.checks:void 0),o)}})}function lt(e,t){return pU(hm(e,t,void 0),e)}function G(e){let t=e.map(v);return vt(hm(t,void 0,void 0),{literals:e,members:t,mapMembers(r){return lt(r(this.members))},pick(r){return G(r)},transform(r){return lt(t.map((n,o)=>n.transform(r[o])))}})}var U=ua((e)=>lt([e,aU])),CV=ua((e)=>lt([e,vV]));function at(e){return(t)=>vt(t.ast,{schema:t,identifier:e})}function TV(e){return(t)=>vt(A0(t.ast,new sS(e,Ie)),{schema:t})}function pb(e){return OV(e)}function OV(e){return(t)=>TV(PO(e))(t)}function rs(e,t){return(r)=>vt(TS(r.ast,e.ast,t?aS(t):im()),{from:r,to:e})}var db=G(["true","yes","on","1","y"]),ub=G(["false","no","off","0","n"]),dU=G([...db.literals,...ub.literals]).pipe(rs(V,om({decode:(e)=>e==="true"||e==="yes"||e==="on"||e==="1"||e==="y",encode:(e)=>e?"true":"false"})));function PV(e){return(t)=>vt(T0(t.ast,e),{schema:t})}function RV(e){if(ut(e)&&e._tag==="Success")return e;return Gr(e,(t)=>Gs(()=>qi(t,(r)=>r.issue)))}function uU(e,t){let r=t?.encodingStrategy==="omit"?MR():To();return(n)=>u(kV(n)).pipe(rs(n,{decode:FR(RV(e)),encode:r}))}function ns(e){return v(e).pipe(PV(W(e)))}function _V(e,t){return p({_tag:ns(e),...t})}function la(e,t){return yV((r)=>r instanceof e,t)}function ou(){return(e,t)=>new Ur(e.ast,aS(t))}var qt=ym;var rU="^\\S[\\s\\S]*\\S$|^\\S$|^$";function UV(e){let t=new globalThis.RegExp(rU);return qt((r)=>r.trim()===r,{expected:"a string with no leading or trailing whitespace",representation:{id:"effect/schema/isTrimmed",payload:null},toJsonSchema:()=>({pattern:t.source}),arbitraryConstraint:{patterns:[{source:rU,flags:""}]},...e})}function qe(e,t){let{source:r,flags:n}=e,o=/^[dg]*uy?$/.test(n);return kS(e,{toJsonSchema:()=>o?{pattern:n.endsWith("y")?`^(?:${r})`:r}:[{},!0],...t})}var DV=(e)=>{if(e)return new globalThis.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})$`);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|[fF]{8}-[fF]{4}-[fF]{4}-[fF]{4}-[fF]{12})$/};function D(e,t){let r=DV(e);return qe(r,{expected:e?`a UUID v${e}`:"a UUID",representation:{id:"effect/schema/isUUID",payload:{version:e??null}},toJsonSchema:()=>({pattern:r.source,format:"uuid"}),...t})}function LV(e){let r=/^[0-9a-zA-Z+/]*={0,2}$/;return qt((n)=>n.length%4===0&&r.test(n),{expected:"a base64 encoded string",representation:{id:"effect/schema/isBase64",payload:null},toJsonSchema:()=>({pattern:"^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$"}),arbitraryConstraint:{patterns:[{source:"^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$",flags:""}]},...e})}function MV(e){let t=Bp(e.order),r=e.formatter??et;return(n,o)=>qt((i)=>t(i,n),{expected:`a value greater than ${r(n)}`,arbitraryConstraint:{order:e.order,minimum:n,exclusiveMinimum:!0},...e.annotate?.(n),...o})}function FV(e){let t=rg(e.order),r=e.formatter??et;return(n,o)=>qt((i)=>t(i,n),{expected:`a value greater than or equal to ${r(n)}`,arbitraryConstraint:{order:e.order,minimum:n},...e.annotate?.(n),...o})}function NV(e){let t=tg(e.order),r=e.formatter??et;return(n,o)=>qt((i)=>t(i,n),{expected:`a value less than or equal to ${r(n)}`,arbitraryConstraint:{order:e.order,maximum:n},...e.annotate?.(n),...o})}function BV(e){let t=rg(e.order),r=Bp(e.order),n=tg(e.order),o=Tv(e.order),i=e.formatter??et;return(s,c)=>{let l=s.exclusiveMinimum?r:t,S=s.exclusiveMaximum?o:n;return qt((m)=>l(m,s.minimum)&&S(m,s.maximum),{expected:`a value between ${i(s.minimum)}${s.exclusiveMinimum?" (excluded)":""} and ${i(s.maximum)}${s.exclusiveMaximum?" (excluded)":""}`,arbitraryConstraint:{order:e.order,minimum:s.minimum,maximum:s.maximum,...s.exclusiveMinimum&&{exclusiveMinimum:!0},...s.exclusiveMaximum&&{exclusiveMaximum:!0}},...e.annotate?.(s),...c})}}function nu(e){if(!globalThis.Number.isFinite(e))throw new globalThis.RangeError(`Expected a finite number, got ${et(e)}`);return e}var Ro=MV({order:Ls,annotate:(e)=>({representation:{id:"effect/schema/isGreaterThan",payload:{exclusiveMinimum:nu(e)}},toJsonSchema:()=>({exclusiveMinimum:e})})}),Te=FV({order:Ls,annotate:(e)=>({representation:{id:"effect/schema/isGreaterThanOrEqualTo",payload:{minimum:nu(e)}},toJsonSchema:()=>({minimum:e})})});var lU=NV({order:Ls,annotate:(e)=>({representation:{id:"effect/schema/isLessThanOrEqualTo",payload:{maximum:nu(e)}},toJsonSchema:()=>({maximum:e})})}),Dr=BV({order:Ls,annotate:(e)=>{let t=e.exclusiveMinimum?!0:void 0,r=e.exclusiveMaximum?!0:void 0;return{representation:{id:"effect/schema/isBetween",payload:{minimum:nu(e.minimum),maximum:nu(e.maximum),...t&&{exclusiveMinimum:t},...r&&{exclusiveMaximum:r}}},toJsonSchema:()=>({[t?"exclusiveMinimum":"minimum"]:e.minimum,[r?"exclusiveMaximum":"maximum"]:e.maximum})}}});function iu(e){return qt((t)=>globalThis.Number.isSafeInteger(t),{expected:"an integer",representation:{id:"effect/schema/isInt",payload:null},toJsonSchema:()=>({type:"integer",minimum:globalThis.Number.MIN_SAFE_INTEGER,maximum:globalThis.Number.MAX_SAFE_INTEGER}),arbitraryConstraint:{number:"integer"},...e})}var L=mr.check(iu());function xe(e,t){return e=fU(e),KV(e,Math.ceil(e/2),t)}function KV(e,t,r){return qt((n)=>n.length>=e,{expected:`a value with a length of at least ${e}`,representation:{id:"effect/schema/isMinLength",payload:{minLength:e}},toJsonSchema:({type:n})=>n==="string"?e<=1?{minLength:t}:[{minLength:t},!0]:n==="array"?{minItems:e}:n===void 0?[{minLength:t,minItems:e},!0]:[{},!0],[Td]:!0,arbitraryConstraint:{minLength:e},...r})}function re(e,t){return e=fU(e),qt((r)=>r.length<=e,{expected:`a value with a length of at most ${e}`,representation:{id:"effect/schema/isMaxLength",payload:{maxLength:e}},toJsonSchema:({type:r})=>r==="string"?e===0?{maxLength:e}:[{maxLength:e},!0]:r==="array"?{maxItems:e}:r===void 0?[{maxLength:e,maxItems:e},!0]:[{},!0],[Td]:!0,arbitraryConstraint:{maxLength:e},...t})}function fU(e){if(!globalThis.Number.isFinite(e))throw new globalThis.RangeError(`Expected a finite number, got ${e}`);return Math.max(0,Math.floor(e))}var $V=(e)=>(e?.includeStack===!0?1:0)|(e?.excludeCause===!0?2:0),qV=(e)=>{switch(e){case 0:return;case 1:return{includeStack:!0};case 2:return{excludeCause:!0};case 3:return{includeStack:!0,excludeCause:!0}}};var nU=[];function mU(e){let t=$V(e),r=nU[t];if(r!==void 0)return r;let n=YV.pipe(rs(j,GR(qV(t))));return nU[t]=n,n}var kce=la(globalThis.RegExp,{representation:{id:"effect/schema/RegExp",payload:null},expected:"RegExp",toCodecJson:()=>ou()(p({source:a,flags:a}),nm({decode:(e,t)=>Tr({try:()=>new globalThis.RegExp(e.source,e.flags),catch:()=>new jr({expected:"valid RegExp source and flags"},e,t)}),encode:(e)=>W({source:e.source,flags:e.flags})}))}),WV=a.annotate({expected:"a string that will be decoded as a URL"}),Ace=la(globalThis.URL,{representation:{id:"effect/schema/URL",payload:null},expected:"URL",toCodecJson:()=>ou()(WV,zR)});var vce=la(globalThis.File,{representation:{id:"effect/schema/File",payload:null},expected:"File",toCodecJson:()=>ou()(p({data:a.check(LV()),type:a,name:a,lastModified:L}),nm({decode:(e,t)=>Ll(em(e.data),{onFailure:()=>fe(new jr({expected:"a valid Base64 string"},e.data,t)),onSuccess:(r)=>{let n=new globalThis.Uint8Array(r);return W(new globalThis.File([n],e.name,{type:e.type,lastModified:e.lastModified}))}}),encode:(e,t)=>Ws({try:async()=>{let r=new globalThis.Uint8Array(await e.arrayBuffer());return{data:Xf(r),type:e.type,name:e.name,lastModified:e.lastModified}},catch:()=>new jr({expected:"a readable File"},e,t)})}))});var Cce=la(globalThis.URLSearchParams,{representation:{id:"effect/schema/URLSearchParams",payload:null},expected:"URLSearchParams",toCodecJson:()=>ou()(a.annotate({expected:"a query string that will be decoded as URLSearchParams"}),om({decode:(e)=>new globalThis.URLSearchParams(e),encode:(e)=>e.toString()}))});var Lm=a.annotate({expected:"a string that will be decoded as a number"}).pipe(rs(mr,qd));var GV=a.check(UV()),Lr=a.annotate({expected:"a string that will be decoded as a trimmed string"}).pipe(rs(GV,qR()));var zV=a.annotate({expected:"a base64 encoded string that will be decoded as Uint8Array",format:"byte",contentEncoding:"base64"}),Tce=la(globalThis.Uint8Array,{representation:{id:"effect/schema/Uint8Array",payload:null},expected:"Uint8Array",toCodecJson:()=>ou()(zV,jR)});var jV=-8640000000000000,QV=8640000000000000,Oce=jV+50400000,Pce=QV-50400000;var HV=globalThis.Symbol.for("immer-draftable"),ob={};function hU(e,t,r,n,o){let i=JV(r,t,n),s=gU(t),c=class extends e{constructor(...[l,S]){let g=S?.["~payload"],w=g?.token===ob?g.value:r.make(l??{},S);super(w,{...S,disableChecks:!0,"~payload":{token:ob,value:w}})}static[tu]=tu;get[s](){return s}static[HV]=!0;static identifier=t;static fields=r.fields;static get ast(){return i(this).ast}static pipe(){return Ze(this,arguments)}static rebuild(l){return i(this).rebuild(l)}static make(l,S){return V_(ci(i(this).ast),l??{},S,(m)=>yU(this,m))}static makeOption(l,S){return Um(i(this))(l??{},S)}static makeEffect(l,S){return i(this).makeEffect(l??{},S)}static annotate(l){return this.rebuild(gm(this.ast,l))}static annotateKey(l){return this.rebuild(bm(this.ast,l))}static check(...l){return this.rebuild(ia(this.ast,l))}static extend(l){return(S,m)=>{let g=lb(S)?S:p(S),w={...r.fields,...g.fields},k=fm(w,r.ast.checks,{identifier:l});return hU(this,l,cb(ia(k,g.ast.checks),w),m,o)}}static mapFields(l,S){return r.mapFields(l,S)}};if(o!==void 0)Object.assign(c.prototype,o(t));return c}function yU(e,t){return new e(t,{"~payload":{token:ob,value:t}})}function VV(e){return new ir(Lt((t)=>yU(e,t)),To())}function gU(e){return`~effect/Schema/Class/${e}`}function JV(e,t,r){let n;return(o)=>{if(n!==void 0)return n;let i=gU(t),s=(S)=>S instanceof o||je(S,i),c=VV(o),l=vt(new Qd([e.ast],()=>(S,m,g)=>s(S)?W(S):fe(new eo(m,S,g)),{identifier:t,[Jf]:([S])=>({isConstructed:s,link:new Ur(S,c)}),toCodec:([S])=>new Ur(S.ast,c),toEquivalence:([S])=>S,toFormatter:([S])=>(m)=>`${o.identifier}(${S(m)})`,[Vf]:jd(e.ast),...r}));return n=rs(l,c)(e)}}function lb(e){return EV(e)}var su=(e)=>(t,r)=>{let n=lb(t)?t:p(t);return hU(Mp,e,n,r,(i)=>({name:i}))},oo=(e)=>(t,r,n)=>{let o=lb(r)?r.mapFields((i)=>({_tag:ns(t),...i}),{unsafePreserveChecks:!0}):_V(t,r);return su(e??t)(o,n)};var xU=Z_;var YV=vt(M0);var SU="~effect/Terminal",fb="~effect/Terminal/QuitError";class au extends su("QuitError")({_tag:ns("QuitError")}){[fb]=fb}var bU=(e)=>je(e,fb),io=Vt("effect/Terminal"),IU=(e)=>io.of({...e,[SU]:SU});import*as Fm from"readline";var wU=Se(function*(e=kU){let t=yield*Vs(),r=!1,n=!1,o=()=>{if(r=!0,!n)vo(t)},i,s=()=>{if(i===void 0)if(i=process.stdin,i.readableEnded)o();else i.once("end",o);return i};yield*kc(()=>Fe(()=>i?.off("end",o)));let c=yield*jx({acquire:_n(Fe(()=>{let h=s(),x=Fm.createInterface({input:h,escapeCodeTimeout:50}),q=(I)=>Ji(t,I),Y=()=>{n=!1,vo(t)};return n=!0,Fm.emitKeypressEvents(h,x),x.on("line",q),x.once("close",Y),{rl:x,onClose:Y,onLine:q}}),({rl:h,onClose:x,onLine:q})=>Fe(()=>{if(n=!1,h.off("line",q),h.off("close",x),h.close(),r)vo(t)})),idleTimeToLive:"10 millis"}),l=(h)=>Fe(()=>{let x=s();if(x.isTTY)x.setRawMode(h)}),S=yield*jx({acquire:_n(l(!0),()=>l(!1)),idleTimeToLive:"10 millis"}),m=Fe(()=>process.stdout.columns??0),g=Fe(()=>process.stdout.rows??0),w=wr(function*(){let h=process.stdout,x=yield*mP(1),q=()=>Ji(x,{columns:h.columns??0,rows:h.rows??0});return yield*kc(()=>Fe(()=>{h.off("resize",q),vo(x)})),h.on("resize",q),q(),x}),k=wr(function*(){let h=s(),x=yield*Vs(),q=(le,ae)=>{let N={input:Za(le),key:{name:ae.name??"",ctrl:!!ae.ctrl,meta:!!ae.meta,shift:!!ae.shift}};if(Ji(x,N),e(N))vo(x)},Y=setInterval(()=>{},2147483647),I=()=>{clearInterval(Y),vo(x)};if(yield*kc(()=>Fe(()=>{clearInterval(Y),h.off("keypress",q),h.off("end",I)})),h.on("keypress",q),r)I();else yield*Gf(c),yield*Gf(S),h.once("end",I);return x}),A=Qe(()=>gP(t).pipe(Ee(Kr({onNone:()=>js(Jn(Gf(c),ni(t))),onSome:W})),Or(()=>new au({}))));return IU({columns:m,rows:g,size:w,readInput:k,readLine:A,display:(h)=>Cf(tn((x)=>{process.stdout.write(h,(q)=>GA(q)?x(He):x(fe(ln({module:"Terminal",method:"display",description:"Failed to write prompt to stdout",cause:q}))))}))})}),EU=Sc(io,wU(kU));function kU(e){let t=e.key;return t.name==="escape"||t.ctrl&&(t.name==="c"||t.name==="d")}var AU=EU;var e4=KS.pipe(uO(gf(y_,x_,E_,AU)));var t4=nx,CU=(e)=>Ye((t)=>e(t.getRef(t4)));var Nm=(...e)=>CU((t)=>kt(()=>{t.error(...e)}));var hr=(...e)=>CU((t)=>kt(()=>{t.log(...e)}));var Bm="~effect/ErrorReporter/ignore";var TU="~effect/Runtime/errorExitCode";var pu="~effect/Runtime/errorReported";var ct=a.check(D()),ce=at("WorkspaceId")(ct),ui=at("WorkspaceInviteId")(ct),os=at("UserId")(ct),yb=at("AuditEventId")(ct),Pt=at("PostId")(ct),sr=at("TargetId")(ct),Wt=at("AttemptId")(ct),H=at("AccountId")(ct),yn=at("MediaId")(ct),xt=at("ProfileId")(ct),fa=at("ApiKeyId")(ct),du=at("WebhookEndpointId")(ct),gn=at("InboxConversationId")(ct),Mn=at("InboxMessageId")(ct),Gc=at("InboxCommentThreadId")(ct),zc=at("InboxCommentId")(ct),jc=at("InboxMentionId")(ct),Km=at("InboxReviewId")(ct),gb=at("InboxAttachmentId")(ct),li=at("InboxActionId")(ct),Nde=at("InboundEventId")(ct),Bde=at("WebhookDeliveryId")(ct),_o=at("AdCampaignId")(ct),ma=at("AdGroupId")(ct),Qc=at("AdCreativeId")(ct),is=at("AdId")(ct),OU=at("AdInsightId")(ct),fi=at("AdOperationId")(ct),PU=at("AdBoostId")(ct),RU=at("AdRequestId")(ct);var _U=(e)=>e,UU=(e)=>e;var xb=Lr.check(xe(1),re(100)),Sb=a.check(xe(1),re(100)).annotate({description:"An IANA time zone such as America/New_York."}),ha=p({id:ce,name:xb,defaultTimezone:Sb,role:G(["owner","member"])}),DU=p({workspaces:_(ha)}),LU=p({name:xb,defaultTimezone:u(Sb).annotate({description:"Default IANA time zone for new queues. Defaults to UTC; existing queues keep their own time zone."})}),Wde=p({name:u(xb),defaultTimezone:u(Sb)}).check(qt(({name:e,defaultTimezone:t})=>e!==void 0||t!==void 0||"Provide a name, a default time zone, or both.")),Gde=p({workspaceId:ce}),MU=Lr.check(xe(1),re(100)),bb=p({id:a.check(D()),email:a,displayName:U(MU)}),FU=p({displayName:U(MU)}),NU=p({deactivated:v(!0)}),BU=p({archived:v(!0)});var Fn=a.check(qe(/^[A-Z]{3}$/)),yt=p({amountMinor:L,currency:Fn}).annotate({identifier:"Money"});var uu=p({estimatedCostMicros:L,estimatedCost:yt,includedRemaining:L,overagePublishes:L,xPublishes:L,blocked:U(p({code:G(["insufficient_credit","spend_cap_reached","billing_inactive"]),nextAction:a}))}).annotate({identifier:"PostBillingEstimate"});var r4=50,KU=100;var $U=a.check(xe(1),re(2048)).annotate({description:"Opaque cursor from a previous list response. Pass nextCursor verbatim."}),St=p({cursor:u($U),limit:u(Lm.check(iu(),Dr({minimum:1,maximum:KU})).annotate({description:`Page size from 1 to ${KU}. Defaults to ${r4}.`}))}).annotate({identifier:"PageQuery"}),We={hasMore:V,nextCursor:u($U)},n4=p({v:v(1),k:a.check(re(512)),id:a.check(xe(1),re(256))}),Zde=wV(n4);var o4=G(["no_targets","schedule_out_of_range","publishing_not_supported","publish_permission_required","duplicate_target","account_not_found","provider_mismatch","account_not_ready","account_unverified","caption_too_long","empty_content","media_required","media_unresolved","media_not_ready","media_count","media_type","media_mime_type","media_too_large","media_upload_required","media_unverified","settings_conflict","tiktok_privacy_unsupported","tiktok_disclosure_required","tiktok_upload_required","tiktok_too_many_mentions","queue_and_time_conflict","invalid_field","account_ambiguous","unsupported_placement","schedule_required","selector_required","selector_conflict"]),so=p({code:o4,path:_(lt([a,L])),message:a}),tue=zz();var ss=["bluesky","facebook","instagram","linkedin","pinterest","reddit","snapchat","tiktok","threads","x","youtube","google_business"],xn=G(ss),i4=[...ss,"meta_ads","google_ads","reddit_ads","pinterest_ads","tiktok_ads","linkedin_ads","snapchat_ads","amazon_ads","openai_ads"],Be=G(i4);var $m=G(["na","eu","fe"]),ar=G(["social_page","social_account","social_board","social_channel","ad_account"]),s4=G(["auth","permission","access_pending","rate_limit","not_found","deleted","conflict","invalid_request","transient","invalid_response","unsupported"]),oue=p({provider:Be,operation:a,kind:s4,providerStatus:u(L),providerCode:u(a),requestId:u(a),retryable:V,retryAfterSeconds:u(L),missingScopes:u(_(a)),detail:u(a)}).annotate({identifier:"ProviderError"}),iue=G(["publish","read_insights","engage","ads"]),a4=p({provider:xn});var Zt=G(ss),Hc=a.check(D()),ao=L.check(Te(1)),Qr=a.check(qe(/^[A-Za-z0-9._~-]{1,128}$/)),fue=p({"idempotency-key":Qr}),mue=p({"idempotency-key":u(Qr)}),qU=86400,Rt=a.check(qe(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,3})?(?:Z|[+-](?:[01]\d|2[0-3]):[0-5]\d)$/),qt((e)=>{let t=new Date(`${e.slice(0,19)}Z`);return Number.isFinite(t.getTime())&&t.toISOString().slice(0,19)===e.slice(0,19)&&Number.isFinite(Date.parse(e))||"Use a valid date and time with Z or an explicit offset"})),yr=G(["feed","reel","story","carousel","video","pin"]),qm=lt([Rt,aU]),c4=p({accountId:H,placement:yr,scheduledAt:u(qm),queueId:u(Hc)}).annotate({identifier:"DestinationSelection"}),hue=p({expectedRevision:ao,scheduledAt:u(Rt),accountIds:u(_(H).check(xe(1),re(50)).annotate({description:"Select every draft placement for these accounts. Use targets for exact selection instead."})),targets:u(_(c4).check(xe(1),re(50)).annotate({description:"Select exact draft destinations and optionally override each schedule. Omit accountIds when using targets."}))}),WU=p({postId:Pt}),Ib=p({postId:Pt,targetId:sr}),yue=p({expectedAttemptId:Wt}),gue=lt([p({expectedAttemptId:Wt,action:v("reschedule"),scheduledAt:Rt}),p({expectedAttemptId:Wt,action:v("reschedule"),queueId:Hc,pinned:u(p({slotId:Hc,occurrenceDate:a.check(qe(/^\d{4}-\d{2}-\d{2}$/))}))}),p({expectedAttemptId:Wt,action:G(["publish_now","cancel"])})]).annotate({identifier:"ScheduleChange"}),p4=u(a),GU={queueId:u(Hc),slotId:u(Hc),assignmentId:u(Hc),occurrenceDate:u(a.check(qe(/^\d{4}-\d{2}-\d{2}$/))),localDate:u(a.check(qe(/^\d{4}-\d{2}-\d{2}$/))),localTime:u(a.check(qe(/^(?:[01]\d|2[0-3]):[0-5]\d$/))),timezone:u(a)},zU={targetId:sr,attemptId:Wt,accountId:H,scheduledAt:p4,...GU},Vc=G(["scheduled","queued","submitting","confirming","published","provider_draft","failed","unresolved","cancelled"]),Wm=lt([v("draft"),Vc]).annotate({identifier:"PostState"}),lu=p({id:a.check(xe(1)),kind:a.check(xe(1))}).annotate({identifier:"DeliveryProviderRef"}),wb=p({...zU,status:Vc}),d4=p({targetId:sr,attemptId:Wt,accountId:H,provider:Zt,placement:yr,status:Vc,scheduledAt:U(a),url:U(a),issue:U(a),canRetry:V,canReconcile:V,...GU}).annotate({identifier:"PublishAcceptedTarget"}),ya=p({postId:Pt,idempotencyKey:Qr,targets:_(d4),warnings:_(so),billing:u(uu)}).annotate({identifier:"PublishAccepted"}),fu=G(["authorization_changed","account_not_ready","credential_unavailable","media_preparation_failed","video_compression_failed","audio_unavailable","provider_rejected","tiktok_settings_unavailable","tiktok_settings_not_allowed","tiktok_processing_failed","submission_uncertain","confirmation_unavailable"]),xue=G(["pending","sending","posted","failed","unresolved"]),Sue=G(["pending","updating","updated","failed","unresolved"]),bue=G(["pending","sending","invited","failed","unresolved"]),u4={...zU,revision:ao,provider:Zt,placement:yr},Gm=p({...u4,status:Vc,providerRef:u(lu),url:u(a),issue:u(fu),canRetry:V,canReconcile:V,nextAction:u(a)}).annotate({identifier:"DeliveryStatus"}),Eb=p({postId:Pt,status:Wm,targets:_(Gm)}),Iue=p({settled:V,post:Eb,retryAfterSeconds:u(L)}).annotate({identifier:"PublishWait"});function jU(e){return e==="draft"||!["scheduled","queued","submitting","confirming"].includes(e)}var l4=p({postId:Pt,isDraft:V,status:Wm,textPreview:a,targetCount:L.check(Te(0)),mediaCount:L.check(Te(0)),revision:ao,createdAt:a,updatedAt:a}).annotate({identifier:"PostSummary"}),QU=p({data:_(l4),...We}).annotate({identifier:"PostList"}),f4=p({delivery:Gm,createdAt:a,updatedAt:a,replacesAttemptId:u(Wt)}).annotate({identifier:"DeliveryAttemptSummary"}),HU=p({currentAttemptId:Wt,data:_(f4),...We}).annotate({identifier:"DeliveryHistory"});var Jc=G(["payg","pro","platform","enterprise"]),zm=G(["month","year"]),jm=G(["fake","stripe"]),mu=G(["active","trialing","past_due","canceled","incomplete","unpaid"]),Qm=G(["confirmed_publish","x_passthrough","managed_ad","inbox_reply","automation_run"]),m4=p({meter:Qm,includedPerPeriod:L,overageUnitPriceMicros:U(L),unitLabel:a}).annotate({identifier:"BillingPlanMeter"}),h4=p({id:Jc,name:a,monthlyPrice:U(yt),annualPrice:U(yt),meters:_(m4),seatsLimit:U(L),analyticsRetentionDays:L,whiteLabelOAuth:V,ssoSaml:V}).annotate({identifier:"BillingPlan"}),VU=p({data:_(h4)}).annotate({identifier:"BillingPlanList"}),y4=p({meter:Qm,includedPerPeriod:L,used:L,billable:L,costMicros:L}).annotate({identifier:"BillingMeterUsage"}),g4=p({monthlySpendCapMicros:U(L),version:L}).annotate({identifier:"BillingSpendControls"}),x4=G(["ok","payment_required","insufficient_credit","spend_cap_reached"]),Ab=p({workspaceId:ce,plan:Jc,status:mu,paymentStatus:x4,interval:U(zm),gateway:jm,periodStart:a,periodEnd:a,cancelAtPeriodEnd:V,creditBalanceMicros:L,creditBalance:yt,spendControls:g4,currentPeriod:p({meters:_(y4),totalVariableSpendMicros:L,seatsUsed:L,seatsLimit:U(L)})}).annotate({identifier:"WorkspaceBilling"}),ga=a.check(qe(/^\d{4}-\d{2}-\d{2}$/)),kb=a.check(qe(/^https?:\/\/[^\s]+$/)),Tue=p({from:u(ga),to:u(ga),meter:u(Qm),provider:u(Zt)}).annotate({identifier:"BillingUsageQuery"}),S4=p({date:ga,meter:Qm,provider:U(Zt),quantity:L,billableQuantity:L,costMicros:L}).annotate({identifier:"BillingUsageDailyPoint"}),JU=p({from:ga,to:ga,totals:p({quantity:L,billableQuantity:L,costMicros:L}),data:_(S4)}).annotate({identifier:"BillingUsage"}),Hm=G(["top_up","auto_top_up","overage_debit","x_passthrough_debit","refund","adjustment"]),Oue=p({kind:u(Hm),from:u(ga),to:u(ga),...St.fields}).annotate({identifier:"BillingLedgerQuery"}),b4=p({id:a.check(D()),kind:Hm,deltaMicros:L,balanceAfterMicros:L,description:a,referenceKind:U(a),referenceId:U(a),createdAt:a}).annotate({identifier:"BillingLedgerEntry"}),YU=p({data:_(b4),...We}).annotate({identifier:"BillingLedgerList"}),Pue=lt([p({mode:v("subscription"),plan:G(["pro","platform"]),interval:zm,returnUrl:u(kb)}),p({mode:v("top_up"),amountMinor:L.check(Te(1000),lU(1e7)),returnUrl:u(kb)})]).annotate({identifier:"CreateBillingCheckout"}),ZU=p({url:a,expiresAt:u(a)}).annotate({identifier:"BillingCheckoutSession"}),Rue=p({returnUrl:u(kb)}).annotate({identifier:"CreateBillingPortal"}),XU=p({url:a}).annotate({identifier:"BillingPortalSession"}),_ue=p({version:L,monthlySpendCapMicros:U(L)}).annotate({identifier:"UpdateBillingSpendControls"});var eD=180,tD=365,oD=["workspace.updated","workspace.archived","workspace.member.role_updated","workspace.member.removed","workspace.invite.created","workspace.invite.resent","workspace.invite.revoked","workspace.invite.accepted","workspace.invite.declined","api_key.created","api_key.updated","api_key.revoked","webhook.endpoint.created","webhook.endpoint.updated","webhook.endpoint.deleted","webhook.delivery.replayed","account.connected","account.reconnected","account.disconnected","account.enabled","account.disabled","account.moved","profile.created","profile.updated","profile.archived","queue.created","queue.updated","queue.paused","queue.resumed","queue.archived","queue.slots.replaced","queue.skip.created","queue.skip.deleted","queue.blackout.created","queue.blackout.deleted","billing.subscription.updated","billing.credit.topped_up","billing.spend_controls.updated"],vb=G(oD).annotate({identifier:"AuditAction"}),iD=["workspace","workspace_member","workspace_invite","workspace_profile","api_key","webhook_endpoint","webhook_delivery","integration_connection","provider_account","schedule_queue","schedule_queue_skip","schedule_queue_blackout","workspace_billing"],Vm=G(iD).annotate({identifier:"AuditTargetKind"}),I4=G(["user","api_key"]).annotate({identifier:"AuditActorType"}),w4=lt([p({type:v("user"),id:os,email:U(a),displayName:U(a)}),p({type:v("api_key"),id:fa,name:U(a),prefix:U(a)})]).annotate({identifier:"AuditActor"}),Cb=p({id:yb,workspaceId:ce,profileId:U(xt),actor:w4,action:vb,targetKind:Vm,targetId:a.check(D()),detail:$t(a,j),createdAt:a}).annotate({identifier:"AuditEvent"}),sD=p({data:_(Cb),...We}).annotate({identifier:"AuditEventList"}),Bue=p({workspaceId:ce,eventId:yb}),rD=lt([Rt,a.check(qe(/^\d{4}-\d{2}-\d{2}$/))]),Kue=p({action:u(vb),targetKind:u(Vm),targetId:u(a.check(D())),actorType:u(I4),actorId:u(a.check(D())),profileId:u(xt),from:u(rD).annotate({description:"Inclusive start instant (ISO 8601 timestamp or YYYY-MM-DD UTC date)."}),to:u(rD).annotate({description:"Inclusive end instant (ISO 8601 timestamp or YYYY-MM-DD UTC date)."}),...St.fields}),E4=p({action:vb,targetKind:Vm,description:a,retentionDays:L}).annotate({identifier:"AuditActionCatalogEntry"}),aD=p({actions:_(E4),targetKinds:_(Vm),retention:p({standardDays:L,spendDays:L})}).annotate({identifier:"AuditActionCatalog"}),nD={"workspace.updated":{targetKind:"workspace",description:"Workspace name or default timezone updated."},"workspace.archived":{targetKind:"workspace",description:"Workspace archived by an owner."},"workspace.member.role_updated":{targetKind:"workspace_member",description:"Workspace member role changed between owner and member."},"workspace.member.removed":{targetKind:"workspace_member",description:"Workspace member removed or left the workspace."},"workspace.invite.created":{targetKind:"workspace_invite",description:"Workspace member invitation created."},"workspace.invite.resent":{targetKind:"workspace_invite",description:"Workspace member invitation token rotated and resent."},"workspace.invite.revoked":{targetKind:"workspace_invite",description:"Pending workspace invitation revoked."},"workspace.invite.accepted":{targetKind:"workspace_invite",description:"Workspace invitation accepted by the invited user."},"workspace.invite.declined":{targetKind:"workspace_invite",description:"A workspace invitation was declined."},"api_key.created":{targetKind:"api_key",description:"Workspace API key created (redacted prefix only)."},"api_key.updated":{targetKind:"api_key",description:"Workspace API key name or scopes updated."},"api_key.revoked":{targetKind:"api_key",description:"Workspace API key revoked."},"webhook.endpoint.created":{targetKind:"webhook_endpoint",description:"Outbound webhook endpoint registered."},"webhook.endpoint.updated":{targetKind:"webhook_endpoint",description:"Outbound webhook endpoint configuration updated."},"webhook.endpoint.deleted":{targetKind:"webhook_endpoint",description:"Outbound webhook endpoint permanently disabled."},"webhook.delivery.replayed":{targetKind:"webhook_delivery",description:"Settled webhook delivery queued for replay."},"account.connected":{targetKind:"provider_account",description:"Social or ad account connected via OAuth."},"account.reconnected":{targetKind:"provider_account",description:"Existing account grant reconnected via OAuth."},"account.disconnected":{targetKind:"integration_connection",description:"Provider connection disconnected and credentials cleared."},"account.enabled":{targetKind:"provider_account",description:"Connected publishing destination enabled."},"account.disabled":{targetKind:"provider_account",description:"Connected publishing destination disabled."},"account.moved":{targetKind:"provider_account",description:"Connected account moved to another workspace profile."},"profile.created":{targetKind:"workspace_profile",description:"Workspace brand profile created."},"profile.updated":{targetKind:"workspace_profile",description:"Workspace brand profile updated."},"profile.archived":{targetKind:"workspace_profile",description:"Workspace brand profile archived."},"queue.created":{targetKind:"schedule_queue",description:"Account schedule queue created."},"queue.updated":{targetKind:"schedule_queue",description:"Account schedule queue configuration updated."},"queue.paused":{targetKind:"schedule_queue",description:"Account schedule queue paused."},"queue.resumed":{targetKind:"schedule_queue",description:"Account schedule queue resumed."},"queue.archived":{targetKind:"schedule_queue",description:"Account schedule queue archived."},"queue.slots.replaced":{targetKind:"schedule_queue",description:"Weekly schedule queue slots replaced."},"queue.skip.created":{targetKind:"schedule_queue_skip",description:"Single queue slot occurrence skipped."},"queue.skip.deleted":{targetKind:"schedule_queue_skip",description:"Skipped queue slot occurrence restored."},"queue.blackout.created":{targetKind:"schedule_queue_blackout",description:"Queue blackout date range created."},"queue.blackout.deleted":{targetKind:"schedule_queue_blackout",description:"Queue blackout date range removed."},"billing.subscription.updated":{targetKind:"workspace_billing",description:"Workspace billing plan or subscription status updated."},"billing.credit.topped_up":{targetKind:"workspace_billing",description:"Workspace prepaid credit balance topped up."},"billing.spend_controls.updated":{targetKind:"workspace_billing",description:"Workspace monthly spend cap or auto-top-up controls updated."}},$ue={actions:oD.map((e)=>({action:e,targetKind:nD[e].targetKind,description:nD[e].description,retentionDays:e.startsWith("billing.")||e.startsWith("ads.")?tD:eD})),targetKinds:[...iD],retention:{standardDays:eD,spendDays:tD}};var Tb=p({workspaceId:ce,deliveryFailures:V,connectionExpiring:V,webhookFailures:V,billingAlerts:V,weeklyDigest:V,updatedAt:U(a)}).annotate({identifier:"NotificationPreferences"}),zue=p({deliveryFailures:u(V),connectionExpiring:u(V),webhookFailures:u(V),billingAlerts:u(V),weeklyDigest:u(V)}).check(qt((e)=>Object.values(e).some((t)=>t!==void 0)||"Provide at least one notification preference to update.")).annotate({identifier:"UpdateNotificationPreferences"});var Yc=G(["owner","member"]).annotate({identifier:"WorkspaceRole"}),k4=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,A4=Lr.pipe(rs(a.check(xe(3),re(320),qe(k4)),cj())).annotate({identifier:"NormalizedEmail",description:"Email address, trimmed and lowercased."}),Jm=p({workspaceId:ce,userId:os,email:a,displayName:U(a),role:Yc,joinedAt:a}).annotate({identifier:"WorkspaceMember"}),cD=p({data:_(Jm),...We}).annotate({identifier:"WorkspaceMemberList"}),Yue=p({role:u(Yc),...St.fields}),Zue=p({workspaceId:ce,userId:os}),Xue=p({role:Yc}).annotate({identifier:"UpdateWorkspaceMemberRole"}),pD=p({removed:v(!0)}).annotate({identifier:"WorkspaceMemberRemoved"}),dD=G(["pending","accepted","revoked","expired"]).annotate({identifier:"WorkspaceInviteStatus"}),Ob=p({id:ui,workspaceId:ce,email:a,role:Yc,status:dD,deliveryState:G(["queued","sending","uncertain","sent"]),remoteRevocationPending:V,invitedByUserId:os,invitedByEmail:U(a),expiresAt:a,acceptedAt:U(a),revokedAt:U(a),createdAt:a}).annotate({identifier:"WorkspaceInvite"}),uD=p({data:_(Ob),...We}).annotate({identifier:"WorkspaceInviteList"}),ele=p({status:u(dD),...St.fields}),tle=p({workspaceId:ce,inviteId:ui}),rle=p({email:A4,role:u(Yc)}).annotate({identifier:"CreateWorkspaceInvite"}),lD=p({invite:Ob}).annotate({identifier:"WorkspaceInviteCreated"}),fD=p({invite:Ob,resendState:G(["sending","sent","uncertain"])}).annotate({identifier:"WorkspaceInviteResent"}),mD=p({revoked:v(!0),remoteRevocationPending:V}).annotate({identifier:"WorkspaceInviteRevoked"}),v4=p({id:ui,workspaceId:ce,workspaceName:a,role:Yc,invitedByEmail:U(a),invitedByName:U(a),expiresAt:a,createdAt:a}).annotate({identifier:"PendingUserInvite"}),hD=p({data:_(v4)}).annotate({identifier:"PendingUserInviteList"}),nle=lt([p({token:Lr.check(xe(1),re(256))}),p({inviteId:ui})]).annotate({identifier:"AcceptWorkspaceInvite"}),yD=p({workspace:ha,membership:Jm}).annotate({identifier:"WorkspaceInviteAccepted"}),gD=p({declined:v(!0),remoteRevocationPending:V}).annotate({identifier:"WorkspaceInviteDeclined"}),ole=p({inviteId:ui});var C4="pubnio_sk_",Pb=new RegExp(`^${C4}[A-Za-z0-9_-]{43}$`),hu=G(["read","publish","engage","ads_read","ads_manage"]),Rb=_(hu).check(xe(1),re(hu.literals.length),qt((e)=>new Set(e).size===e.length||"Choose each scope once.")),_b=Lr.check(xe(1),re(100)),yu=p({id:fa,workspaceId:ce,name:_b,prefix:a,scopes:Rb,createdAt:a,updatedAt:a,expiresAt:U(a),revokedAt:U(a)}).annotate({identifier:"ApiKey"}),dle=p({name:_b,scopes:u(Rb).annotate({description:"Defaults to read. publish permits delivery writes; engage permits inbox replies; ads_read and ads_manage permit ad operations. ads_spend requires a signed-in owner."}),expiresAt:u(Rt)}),ule=p({name:u(_b),scopes:u(Rb)}).check(qt(({name:e,scopes:t})=>e!==void 0||t!==void 0||"Provide a name or scopes."));var lle=hu.literals;var fle=p({workspaceId:ce,keyId:fa}),xD=p({key:yu,secret:a.check(qe(Pb)).annotate({description:"Copy this secret now. This is the only response that returns it."})}),SD=p({data:_(yu),...We}).annotate({identifier:"ApiKeyList"}),bD=p({revoked:v(!0)});var Ym=26214400,Zm=268435456,Xm=16777216,T4=8388608;var xa=a.check(re(2048),qe(/^https:\/\//i),qt((e)=>{let t=URL.parse(e);return Boolean(t?.hostname&&t.protocol==="https:"&&!t.username&&!t.password)||"Expected an HTTPS media URL without credentials"})),ID=p({mediaId:yn}),O4=p({url:xa}),P4=lt([ID,O4]).annotate({identifier:"MediaInput"}),Ub=35,as=_(P4).check(re(Ub)),gu=G(["image","video","document"]),Zc=G(["image/jpeg","image/png","image/gif","image/webp","video/mp4","video/quicktime","video/webm","application/pdf"]);function R4(e,t){let r=(n)=>n.every((o,i)=>e[i]===o);switch(t){case"image/jpeg":return r([255,216,255]);case"image/png":return r([137,80,78,71,13,10,26,10]);case"image/webp":{let n=new TextDecoder().decode(e.subarray(0,12));return n.startsWith("RIFF")&&n.endsWith("WEBP")}case"video/webm":{if(!r([26,69,223,163]))return!1;let n=[66,130,132,119,101,98,109];return e.some((o,i)=>n.every((s,c)=>e[i+c]===s))}case"image/gif":{let n=new TextDecoder().decode(e.subarray(0,6));return n==="GIF87a"||n==="GIF89a"}case"video/mp4":case"video/quicktime":{if(e.length<16)return!1;let n=new TextDecoder().decode(e.subarray(4,12));return n.startsWith("ftyp")&&(t==="video/quicktime"?n==="ftypqt ":n!=="ftypqt ")}case"application/pdf":return r([37,80,68,70,45])}}function wD(e){return Zc.literals.find((t)=>R4(e,t))}var ble=p({workspaceId:ce,mimeType:Zc}),Db=p({mediaId:yn,type:gu,mimeType:Zc,sizeBytes:L.check(Dr({minimum:1,maximum:Zm})),createdAt:a}).annotate({identifier:"MediaAsset"}),ED=p({data:_(Db),...We}).annotate({identifier:"MediaList"}),kD=p({deleted:v(!0)}),Ile=p({url:a.check(xe(1),re(8192))}).annotate({identifier:"MediaImport"}),wle=p({sizeBytes:L.check(Te(1))}).annotate({identifier:"MediaUploadStart"}),AD=Dr({minimum:1,maximum:Math.ceil(Zm/Xm)}),_4=L.check(AD),Ele=p({...ID.fields,partNumber:Lm.check(iu(),AD)}),vD=p({mediaId:yn,partSizeBytes:v(Xm),expiresAt:a}).annotate({identifier:"MediaUploadSession"}),CD=p({partNumber:_4}).annotate({identifier:"MediaPartReceipt"}),TD=p({code:G(["media_source_unavailable","media_storage_unavailable","media_too_large","unsupported_media","upload_expired"]),maxBytes:u(L)}).annotate({identifier:"MediaIntakeIssue"}),U4=G(["awaiting_upload","processing","ready","failed"]),D4=p({receivedPartCount:L.check(Te(0)),partDigests:_(a.check(qe(/^[A-Za-z0-9_-]{43}$/))),expiresAt:a}).annotate({identifier:"MediaUploadProgress"}),Sa=p({mediaId:yn,status:U4,asset:u(Db),issue:u(TD),upload:u(D4),idempotencyKey:u(Qr),retryAfterSeconds:u(L)}).annotate({identifier:"MediaIntake"}),kle=p({mediaId:yn,status:G(["ready","failed","timeout"]),asset:u(Db),issue:u(TD),retryAfterSeconds:u(L)}).annotate({identifier:"MediaWait"}),Ale=p({data:a.check(xe(1),re(Math.ceil(T4/3)*4+4)).annotate({description:"Base64-encoded file bytes. Maximum 8 MiB after decoding."}),mimeType:Zc,filename:u(a.check(xe(1),re(255)))}).annotate({identifier:"MediaInlineUpload"}),OD=G(["part_conflict","part_out_of_order","parts_missing","upload_closed","upload_expired"]);var Lb=["live","beta","upcoming"];var L4=["publish","read_insights","manage_comments"],eh=[...L4,"send_messages"],Sn={bluesky:{label:"Bluesky",availability:"beta",authFamily:"bluesky",accountKinds:["social_account"],capabilities:{social_account:eh},approvalRequired:{},limited:{}},facebook:{label:"Facebook",availability:"live",authFamily:"facebook",accountKinds:["social_page"],capabilities:{social_page:eh},approvalRequired:{},limited:{}},instagram:{label:"Instagram",availability:"live",authFamily:"instagram",accountKinds:["social_account"],capabilities:{social_account:eh},approvalRequired:{},limited:{}},linkedin:{label:"LinkedIn",availability:"live",authFamily:"linkedin",accountKinds:["social_account","social_page"],capabilities:{social_account:["publish","manage_comments"],social_page:["publish","read_insights","manage_comments"]},approvalRequired:{},limited:{}},pinterest:{label:"Pinterest",availability:"live",authFamily:"pinterest",accountKinds:["social_board"],capabilities:{social_board:["publish","read_insights"]},approvalRequired:{},limited:{}},reddit:{label:"Reddit",availability:"upcoming",authFamily:"reddit",accountKinds:["social_account"],capabilities:{social_account:eh},approvalRequired:{},limited:{}},snapchat:{label:"Snapchat",availability:"beta",authFamily:"snapchat",accountKinds:["social_page"],capabilities:{social_page:["publish"]},approvalRequired:{},limited:{}},tiktok:{label:"TikTok",availability:"live",authFamily:"tiktok",accountKinds:["social_account"],capabilities:{social_account:["publish","read_insights"]},approvalRequired:{},limited:{}},threads:{label:"Threads",availability:"upcoming",authFamily:"threads",accountKinds:["social_account"],capabilities:{social_account:["publish","read_insights","manage_comments"]},approvalRequired:{},limited:{}},x:{label:"X",availability:"live",authFamily:"x",accountKinds:["social_account"],capabilities:{social_account:["publish","read_insights","manage_comments","send_messages"]},approvalRequired:{},limited:{}},youtube:{label:"YouTube",availability:"live",authFamily:"youtube",accountKinds:["social_channel"],capabilities:{social_channel:["publish","read_insights"]},approvalRequired:{},limited:{}},google_business:{label:"Google Business Profile",availability:"upcoming",authFamily:"google_business",accountKinds:["social_page"],capabilities:{social_page:["publish","read_insights"]},approvalRequired:{},limited:{}}};var Tle={bluesky:{...Sn.bluesky,publishCapable:!0},facebook:{...Sn.facebook,publishCapable:!0},instagram:{...Sn.instagram,publishCapable:!0},linkedin:{...Sn.linkedin,publishCapable:!0},pinterest:{...Sn.pinterest,publishCapable:!0},reddit:{...Sn.reddit,publishCapable:!0},snapchat:{...Sn.snapchat,publishCapable:!0},tiktok:{...Sn.tiktok,publishCapable:!0},threads:{...Sn.threads,publishCapable:!0},x:{...Sn.x,publishCapable:!0},youtube:{...Sn.youtube,publishCapable:!0},google_business:{...Sn.google_business,publishCapable:!0},meta_ads:{label:"Meta Ads",availability:"live",authFamily:"meta_ads",accountKinds:["ad_account"],capabilities:{ad_account:["ads_read"]},approvalRequired:{},limited:{},publishCapable:!1,integrationState:"connectable"},google_ads:{label:"Google Ads",availability:"live",authFamily:"google_ads",accountKinds:["ad_account"],capabilities:{ad_account:["ads_read"]},approvalRequired:{},limited:{},publishCapable:!1,integrationState:"connectable"},reddit_ads:{label:"Reddit Ads",availability:"live",authFamily:"reddit_ads",accountKinds:["ad_account"],capabilities:{ad_account:["ads_read"]},approvalRequired:{},limited:{},publishCapable:!1,integrationState:"connectable"},pinterest_ads:{label:"Pinterest Ads",availability:"live",authFamily:"pinterest_ads",accountKinds:["ad_account"],capabilities:{ad_account:["ads_read"]},approvalRequired:{},limited:{},publishCapable:!1,integrationState:"connectable"},tiktok_ads:{label:"TikTok Ads",availability:"live",authFamily:"tiktok_ads",accountKinds:["ad_account"],capabilities:{ad_account:["ads_read"]},approvalRequired:{},limited:{},publishCapable:!1,integrationState:"connectable"},linkedin_ads:{label:"LinkedIn Ads",availability:"live",authFamily:"linkedin_ads",accountKinds:["ad_account"],capabilities:{ad_account:["ads_read"]},approvalRequired:{},limited:{},publishCapable:!1,integrationState:"connectable"},snapchat_ads:{label:"Snapchat Ads",availability:"live",authFamily:"snapchat_ads",accountKinds:["ad_account"],capabilities:{ad_account:["ads_read"]},approvalRequired:{},limited:{},publishCapable:!1,integrationState:"connectable"},amazon_ads:{label:"Amazon Ads",availability:"live",authFamily:"amazon_ads",accountKinds:["ad_account"],capabilities:{ad_account:["ads_read"]},approvalRequired:{},limited:{},publishCapable:!1,integrationState:"connectable"},openai_ads:{label:"OpenAI Ads",availability:"beta",authFamily:"openai_ads",accountKinds:["ad_account"],capabilities:{ad_account:["ads_read"]},approvalRequired:{},limited:{},publishCapable:!1,integrationState:"connectable"}},Ole=ss.flatMap((e)=>{let t=Sn[e];return t.accountKinds.map((r)=>({provider:e,availability:t.availability,accountKind:r,capabilities:[...t.capabilities[r]??[]],approvalRequired:[...t.approvalRequired[r]??[]],limited:[...t.limited[r]??[]]}))});var M4=60,F4=3600;var N4={requestsPerMinute:300,publishesPerMinute:30,mediaUploadsPerMinute:10,windowSeconds:60},hi=lt([p({status:G(["ready","disabled","unavailable"])}),p({status:v("needs_reconnect"),reason:G(["disconnected","token_expired"])}),p({status:v("unverified"),reason:G(["scopes_unknown","page_tasks_unknown"])}),p({status:v("permission_required"),reason:v("missing_scope"),missingScopes:_(a)}),p({status:v("permission_required"),reason:v("missing_page_task")})]).annotate({identifier:"AccountReadiness"}),mi=G(["publish","read_insights","manage_comments","send_messages","ads_read","ads_write","ads_spend"]),B4=G(["supported","not_supported","access_pending","permission_missing","unverified","reconnect_required","unavailable"]),Fle=p({scopes:u(_(a)),pageTasks:u(_(a)),roles:u(_(a)),loginMethods:u(_(a))}),yi=p({capability:mi,state:B4,missingScopes:_(a),missingRoles:_(a),reason:u(a)}).annotate({identifier:"AccountCapability"}),K4=p({accountId:H,profileId:xt,provider:Be,accountKind:ar,enabled:V,publishingReadiness:hi,capabilities:_(yi),checkedAt:a}).annotate({identifier:"AccountCapabilities"}),PD=p({capabilities:_(K4)}),Nle=p({workspaceId:ce,profileId:u(xt),accountId:u(H),capability:u(mi)}),$4=p({provider:Be,availability:G(Lb),accountKind:ar,capabilities:_(mi),approvalRequired:_(mi),limited:_(mi)}).annotate({identifier:"CapabilityCatalogEntry"}),RD=p({entries:_($4)}).annotate({identifier:"CapabilityCatalog"}),q4=p({accountId:H,provider:Be,accountKind:ar,name:a,enabled:V,readiness:hi}).annotate({identifier:"AccountSummary"}),Ble=p({accounts:_(q4)}).annotate({identifier:"AccountSummaryList"}),W4=p({requestsPerMinute:L,publishesPerMinute:L,mediaUploadsPerMinute:L,windowSeconds:L}).annotate({identifier:"RateLimits"}),_D=p({uploadMaxBytes:L,assetMaxBytes:L,partMaxBytes:L,types:_(gu)}).annotate({identifier:"MediaLimits"}),Mb=p({targetsPerRequest:L,draftTextCharacters:L,idempotencyTtlSeconds:L,wait:p({defaultSeconds:L,maxSeconds:L}),media:_D,rateLimits:W4}).annotate({identifier:"ApiLimits"}),G4=p({placement:yr,default:V,mediaTypes:_(gu),maxMedia:L,captionCharacters:L}).annotate({identifier:"PlacementCapability"}),z4=p({provider:xn,label:a,availability:G(Lb),accountKinds:_(ar),placements:_(G4),requiredScopes:_(a)}).annotate({identifier:"ProviderCapability"}),UD=p({providers:_(z4),accountKinds:_(ar),media:_D,limits:Mb}).annotate({identifier:"PublishCapabilities"}),Kle={targetsPerRequest:50,draftTextCharacters:128000,idempotencyTtlSeconds:qU,wait:{defaultSeconds:M4,maxSeconds:F4},media:{uploadMaxBytes:Ym,assetMaxBytes:Zm,partMaxBytes:Xm,types:[...gu.literals]},rateLimits:N4};var th=G(["instagram_login","facebook_login","unified_login"]),DD=u(th),j4=lt([p({provider:v("bluesky"),kind:v("account"),handle:a,did:a,service:a}),p({provider:v("facebook"),kind:v("page"),tasks:u(_(a))}),p({provider:v("instagram"),kind:v("professional_account"),username:a,loginMethod:DD,accountType:u(G(["business","creator"])),pageId:u(a),clientBusinessId:u(a),configId:u(a)}),p({provider:v("linkedin"),kind:v("member")}),p({provider:v("linkedin"),kind:v("organization")}),p({provider:v("pinterest"),kind:v("board"),username:u(a)}),p({provider:v("reddit"),kind:v("account"),username:a}),p({provider:v("snapchat"),kind:v("public_profile"),profileId:a,organizationId:u(a),username:u(a)}),p({provider:v("tiktok"),kind:v("account"),username:u(a),isBusiness:u(V)}),p({provider:v("threads"),kind:v("account"),username:u(a)}),p({provider:v("x"),kind:v("account"),username:u(a)}),p({provider:v("youtube"),kind:v("channel")}),p({provider:v("google_business"),kind:v("location")}),p({provider:v("meta_ads"),kind:v("ad_account"),externalId:a,currency:a.check(qe(/^[A-Z]{3}$/)),timezone:a,status:G(["active","disabled","pending","closed","unknown"]),businessId:u(a)}),p({provider:v("google_ads"),kind:v("ad_account"),externalId:a,currency:a.check(qe(/^[A-Z]{3}$/)),timezone:a,status:G(["active","disabled","pending","closed","unknown"]),managerId:u(a),loginCustomerId:u(a)}),p({provider:v("reddit_ads"),kind:v("ad_account"),externalId:a,currency:a.check(qe(/^[A-Z]{3}$/)),timezone:a,status:G(["active","disabled","pending","closed","unknown"]),businessId:u(a)}),p({provider:v("pinterest_ads"),kind:v("ad_account"),externalId:a,currency:a.check(qe(/^[A-Z]{3}$/)),timezone:a,status:G(["active","disabled","pending","closed","unknown"]),businessId:u(a),managerId:u(a)}),p({provider:v("tiktok_ads"),kind:v("ad_account"),externalId:a,currency:a.check(qe(/^[A-Z]{3}$/)),timezone:a,status:G(["active","disabled","pending","closed","unknown"]),businessId:u(a)}),p({provider:v("linkedin_ads"),kind:v("ad_account"),externalId:a,currency:a.check(qe(/^[A-Z]{3}$/)),timezone:a,status:G(["active","disabled","pending","closed","unknown"]),businessId:u(a),managerId:u(a)}),p({provider:v("snapchat_ads"),kind:v("ad_account"),externalId:a,currency:a.check(qe(/^[A-Z]{3}$/)),timezone:a,status:G(["active","disabled","pending","closed","unknown"]),businessId:u(a)}),p({provider:v("amazon_ads"),kind:v("ad_account"),externalId:a,currency:a.check(qe(/^[A-Z]{3}$/)),timezone:a,status:G(["active","disabled","pending","closed","unknown"]),region:$m,businessId:u(a),managerId:u(a)}),p({provider:v("openai_ads"),kind:v("ad_account"),externalId:a,currency:a.check(qe(/^[A-Z]{3}$/)),timezone:a,status:G(["active","disabled","pending","closed","unknown"])})]);var Xc=p({id:H,profileId:xt,connectionId:a.check(D()),provider:Be,accountKind:ar,parentAccountId:U(H),name:a,enabled:V,available:V,details:j4,readiness:hi,capabilities:_(yi)}).annotate({identifier:"ProviderAccount"}),Fb=p({accounts:_(Xc)}),Q4=p({id:H,enabled:V});var rh=a.check(D()),Bb=p({attemptId:rh}),xu=p({accountId:H}),LD=p({connectionId:rh}),Kb=p({attemptId:rh,url:a,expiresAt:u(a)}),H4=G(["provider_error","invalid_callback","account_mismatch","connection_changed","connection_failed"]),Nb={attemptId:rh,provider:Be},MD=lt([p({...Nb,status:G(["pending","denied","expired"])}),p({...Nb,status:v("connected"),accountIds:_(H)}),p({...Nb,status:v("failed"),reason:H4})]).annotate({identifier:"ConnectionStatus"}),FD=p({disconnected:v(!0)}),V4=p({handle:Lr.check(xe(1),re(253)),appPassword:Lr.check(xe(1),re(256)),service:u(a.check(re(2048),qe(/^https:\/\//i)))}).annotate({identifier:"BlueskyConnect"}),Jle=p({...V4.fields,accountId:u(H),profileId:u(xt)}).annotate({identifier:"BlueskySessionConnect"}),ND=p({used:L.check(Te(0)),limit:L.check(Ro(0)),windowSeconds:L.check(Ro(0))}).annotate({identifier:"InstagramPublishingLimit"}),nh=G(["music","original_sound"]),ep=a.check(qe(/^\d{1,32}$/)),Yle=p({...xu.fields,audioId:ep}),Zle=p({audioType:nh,q:u(Lr.check(xe(1),re(200)))}),$b=p({audioId:ep,audioType:nh,title:a,durationMs:u(L.check(Te(0))),artist:u(a),creator:u(a),previewUrl:u(a),coverUrl:u(a),instagramPreviewUrl:u(a)}).annotate({identifier:"InstagramAudio"}),BD=p({audio:_($b)});var Wb=128000;var zb=1250,J4=300;var KD=500,Y4=100,Z4=1e5,qb=50;var cs=a.check(re(Wb)),qD=L.check(Te(1)),ffe=p({workspaceId:ce,isDraft:u(V).annotate({description:"Filter to drafts (true) or submitted posts (false)."}),accountId:u(H).annotate({description:"Filter to posts targeting this connected account (applies to both drafts and submitted posts; pairs with deliveryStatus on the same target)."}),profileId:u(xt).annotate({description:"Filter to posts targeting any account in this workspace profile."}),...St.fields}),X4=Ub,Ar={text:u(cs),media:u(as),scheduledAt:u(qm),queueId:u(a.check(D()).annotate({description:"Assign this destination to its connected account's schedule queue."}))},Su=a.check(qe(/^\d+$/)),eJ=_(a.check(qe(/^[A-Z]{2}$/))).check(xe(1),re(25)),WD={firstComment:u(cs),thread:u(_(a.check(xe(1),re(zb))).check(re(24))),nativeDraft:u(V),countries:u(eJ)},GD=p({...WD,link:u(xa),textFormatPresetId:u(Su),albumId:u(Su)}).annotate({identifier:"FacebookFeedSettings"}),zD=p({...WD,title:u(cs),isAiGenerated:u(V),collaboratorPageIds:u(_(Su).check(xe(1),re(10),qt((e)=>new Set(e).size===e.length||"Choose each collaborator Page once")))}).annotate({identifier:"FacebookReelSettings"}),jD=p({isAiGenerated:u(V)}).annotate({identifier:"FacebookStorySettings"}),Gb=a.check(qe(/^@?[a-zA-Z0-9._]{1,30}$/)),$D=mr.check(Dr({minimum:0,maximum:1})),tJ=p({username:Gb,x:u($D),y:u($D)}),QD={isAiGenerated:u(V)},jb={...QD,firstComment:u(cs),commentsEnabled:u(V),collaborators:u(_(Gb).check(re(3))),locationId:u(Su),isPaidPartnership:u(V),brandedContentSponsors:u(_(lt([Su,Gb])).check(xe(1),re(2)))},oh=u(_(tJ).check(re(20))),HD=u(a.check(re(1000))),VD=p({...jb,altText:HD,userTags:oh}).annotate({identifier:"InstagramFeedSettings"}),JD=p({...jb,shareToFeed:u(V),muteAudio:u(V),audioConfiguration:u(p({audioId:ep,audioVolume:u(L.check(Dr({minimum:1,maximum:100}))),videoVolume:u(L.check(Dr({minimum:0,maximum:100})))})),coverUrl:u(xa),thumbOffset:u(L.check(Te(0))),audioName:u(a.check(re(255))),trial:u(p({graduationStrategy:G(["MANUAL","SS_PERFORMANCE"])})),userTags:oh}).annotate({identifier:"InstagramReelSettings"}),YD=p({...jb,muteAudio:u(V),slides:u(_(p({altText:HD,userTags:oh})).check(re(20)))}).annotate({identifier:"InstagramCarouselSettings"}),ZD=p({...QD,muteAudio:u(V),userTags:oh}).annotate({identifier:"InstagramStorySettings"}),XD=p({firstComment:u(a.check(xe(1),re(300))),thread:u(_(a.check(xe(1),re(300))).check(re(24))),altText:u(a.check(re(1000)))}).annotate({identifier:"BlueskyFeedSettings"}),eL=p({firstComment:u(cs),thread:u(_(a.check(xe(1),re(zb))).check(re(24))),visibility:u(G(["PUBLIC","CONNECTIONS"])),altText:u(a.check(re(4086))),documentTitle:u(Lr.check(xe(1),re(100)))}).annotate({identifier:"LinkedInFeedSettings"}),tL=p({title:u(a.check(xe(1),re(100))),description:u(a.check(xe(1),re(800))),link:u(xa),altText:u(a.check(re(500)))}).annotate({identifier:"PinterestPinSettings"}),rJ=a.check(qe(/^(?:r\/)?[A-Za-z0-9_]{2,21}$/)),rL=p({subreddit:rJ,title:a.check(xe(1),re(J4)),link:u(xa),flairId:u(a.check(xe(1),re(100))),flairText:u(a.check(xe(1),re(64))),nsfw:u(V),spoiler:u(V),sendReplies:u(V),thumbnailMediaId:u(yn),firstComment:u(cs)}).annotate({identifier:"RedditFeedSettings"}),nL=p({contentType:u(G(["story","saved_story","spotlight"])),title:u(a.check(xe(1),re(45))),description:u(a.check(xe(1),re(160))),link:u(xa),locale:u(a.check(qe(/^[a-z]{2}_[A-Z]{2}$/)))}).annotate({identifier:"SnapchatStorySettings"}),oL=p({title:a.check(xe(1),re(100)),description:u(a.check(re(5000))),privacyStatus:G(["public","unlisted","private"]),tags:u(_(a.check(re(100))).check(re(30))),categoryId:u(a.check(qe(/^\d{1,3}$/))),madeForKids:u(V),containsSyntheticMedia:u(V),thumbnailMediaId:u(yn),notifySubscribers:u(V),license:u(G(["youtube","creativeCommon"])),embeddable:u(V),publicStatsViewable:u(V)}).annotate({identifier:"YouTubeVideoSettings"}),nJ=p({title:a.check(xe(1),re(Y4)),content:a.check(xe(1),re(Z4))}).annotate({identifier:"XArticleDraftSettings"}),iL=p({firstComment:u(cs),thread:u(_(a.check(xe(1),re(280))).check(re(24))),article:u(nJ)}).annotate({identifier:"XFeedSettings"}),sL=p({}).annotate({identifier:"GoogleBusinessFeedSettings"}),aL=p({firstComment:u(a.check(xe(1),re(KD))),thread:u(_(a.check(xe(1),re(KD))).check(re(24)))}).annotate({identifier:"ThreadsFeedSettings"}),cL={privacy:G(["PUBLIC_TO_EVERYONE","MUTUAL_FOLLOW_FRIENDS","FOLLOWER_OF_CREATOR","SELF_ONLY"]),commercialDisclosure:u(G(["none","own_brand","paid_partnership"])),isAiGenerated:u(V),disableComment:u(V),nativeDraft:u(V)},oJ=p({...cL,format:u(v("video")),disableDuet:u(V),disableStitch:u(V)}).annotate({identifier:"TikTokVideoSettings"}),iJ=p({...cL,format:v("photo"),title:u(a.check(re(90))),coverIndex:u(L.check(Dr({minimum:0,maximum:X4-1}))),autoAddMusic:u(V)}).annotate({identifier:"TikTokPhotoSettings"}),pL=lt([oJ,iJ]).annotate({identifier:"TikTokFeedSettings"}),dL=lt([p({accountId:H,provider:v("bluesky"),placement:v("feed"),...Ar,settings:u(XD)}),p({accountId:H,provider:v("facebook"),placement:v("feed"),...Ar,settings:u(GD)}),p({accountId:H,provider:v("facebook"),placement:v("reel"),...Ar,settings:u(zD)}),p({accountId:H,provider:v("facebook"),placement:v("story"),...Ar,settings:u(jD)}),p({accountId:H,provider:v("instagram"),placement:v("feed"),...Ar,settings:u(VD)}),p({accountId:H,provider:v("instagram"),placement:v("reel"),...Ar,settings:u(JD)}),p({accountId:H,provider:v("instagram"),placement:v("carousel"),...Ar,settings:u(YD)}),p({accountId:H,provider:v("instagram"),placement:v("story"),...Ar,settings:u(ZD)}),p({accountId:H,provider:v("linkedin"),placement:v("feed"),...Ar,settings:u(eL)}),p({accountId:H,provider:v("threads"),placement:v("feed"),...Ar,settings:u(aL)}),p({accountId:H,provider:v("x"),placement:v("feed"),...Ar,settings:u(iL)}),p({accountId:H,provider:v("youtube"),placement:v("video"),...Ar,settings:oL}),p({accountId:H,provider:v("pinterest"),placement:v("pin"),...Ar,settings:u(tL)}),p({accountId:H,provider:v("reddit"),placement:v("feed"),...Ar,settings:rL}),p({accountId:H,provider:v("snapchat"),placement:v("story"),...Ar,settings:u(nL)}),p({accountId:H,provider:v("tiktok"),placement:v("feed"),...Ar,settings:u(pL)}),p({accountId:H,provider:v("google_business"),placement:v("feed"),...Ar,settings:u(sL)})]).annotate({identifier:"PublishTarget"}),mfe=es(dL,{onExcessProperty:"error"}),sJ=a.check(xe(1),re(zb)),aJ=_(sJ).check(xe(1),re(24)),cJ=lt([XD,GD,zD,jD,VD,JD,YD,ZD,eL,rL,nL,aL,iL,oL,tL,pL,sL]),pJ=p({accountId:H,provider:u(xn),placement:u(yr),text:u(cs),thread:u(aJ),media:u(as),scheduledAt:u(qm),queueId:u(a.check(D()).annotate({description:"Assign this destination to its connected account's schedule queue."})),settings:u(cJ)}).annotate({identifier:"CreatePostTarget"}),Qb=Lr.check(re(Wb)).pipe(gV({description:`At most ${Wb} characters after trimming.`})),uL=_(dL).check(re(50)),Hb={text:u(Qb),targets:u(uL),media:u(as)},hfe=p(Hb).annotate({identifier:"PostContent"}),yfe=p({...Hb,scheduledAt:u(Rt)}).annotate({identifier:"PostPreflight"}),lL=p({text:u(Qb),platforms:u(_(xn).check(xe(1),re(qb))),accounts:u(_(H).check(xe(1),re(qb))),targets:u(_(pJ).check(xe(1),re(qb))),media:u(as),scheduledAt:u(Rt),publishNow:u(V),isDraft:u(V).annotate({description:"Save the post as a draft without submitting it. Defaults to false."})}).annotate({identifier:"CreatePost"}).annotate({description:"Send exactly one selector for a direct post: platforms resolves the single ready account per provider, accounts selects exact account IDs, and targets selects exact destinations. Provider and placement are derived when omitted. publishNow defaults to true when scheduledAt is absent. Set isDraft to true to save a draft without submitting; drafts accept text, media, and targets."}),dJ=p({...Hb,expectedRevision:u(qD)}).annotate({identifier:"UpdatePost"}),tp=p({postId:Pt,isDraft:V,revision:qD,text:Qb,media:as,targets:uL,deliveries:_(Gm),status:Wm,createdAt:a,updatedAt:a}).annotate({identifier:"Post"}),gfe=p({...tp.fields,idempotencyKey:u(Qr)}).annotate({identifier:"PostCreated"}),xfe=lt([tp,ya]).annotate({identifier:"PostCreateResult"}),fL=p({archived:v(!0)}),Sfe=es(dJ,{onExcessProperty:"error"}),uJ=p({accountId:H,provider:xn,placement:yr,canPublish:V,caption:p({count:L,limit:L}),errors:_(so),warnings:_(so)}),mL=p({canPublish:V,errors:_(so),warnings:_(so),targets:_(uJ),billing:u(uu)}).annotate({identifier:"PostValidation"});var co=a.check(D()),Xt=co,hL=co,ih=Lr.check(xe(1),re(100)),rp=a.check(xe(1),re(100)),yL=L.check(Dr({minimum:0,maximum:6})),sh=a.check(qe(/^(?:[01]\d|2[0-3]):[0-5]\d$/)),lJ=50,bn=a.check(qe(/^\d{4}-\d{2}-\d{2}$/)),fJ=p({id:u(co).annotate({description:"Round-trip an existing slot ID. Omit to create a new slot; a removed slot reports no ID."}),dayOfWeek:yL,time:sh}).annotate({identifier:"QueueSlotInput"}),mJ=p({id:co,dayOfWeek:yL,time:sh}).annotate({identifier:"QueueSlot"}),gL=_(fJ).check(re(lJ)),hJ=p({maxPerDay:U(L.check(Te(1))).annotate({description:"Null uses the provider limit."}),maxPending:L.check(Te(1)),minGapSeconds:L.check(Te(1)),horizonDays:L.check(Dr({minimum:1,maximum:90})),providerMaxPerDay:L.check(Te(1)),providerMinGapSeconds:L.check(Te(1))}).annotate({identifier:"QueueLimits"}),yJ=G(["active","paused","archived"]),np=p({id:Xt,workspaceId:ce,accountId:H,name:ih,timezone:rp,status:yJ,isDefault:V.annotate({description:"The queue nextSlot assignment uses for this account when none is given."}),limits:hJ,slots:_(mJ),version:L.check(Te(1)),pausedAt:U(a),archivedAt:U(a),createdAt:a,updatedAt:a}).annotate({identifier:"Queue"}),xL=p({data:_(np),...We}).annotate({identifier:"QueueList"}),SL=p({archived:v(!0),version:L.check(Te(1))}).annotate({identifier:"QueueArchived"}),bL={maxPending:u(L.check(Dr({minimum:1,maximum:1000}))),minGapSeconds:u(L.check(Dr({minimum:60,maximum:604800}))),horizonDays:u(L.check(Dr({minimum:1,maximum:90})))},IL=p({accountId:H,name:ih,timezone:u(rp).annotate({description:"An IANA time zone such as America/New_York. Defaults to the workspace default time zone."}),slots:gL,isDefault:u(V).annotate({description:"Promote this queue to the account default. The first active queue is always the default."}),maxPerDay:u(L.check(Dr({minimum:1,maximum:1000}))).annotate({description:"Defaults to the provider limit."}),...bL}).annotate({identifier:"CreateQueue"}),wL=p({expectedVersion:L.check(Te(1)),name:u(ih),timezone:u(rp),paused:u(V),isDefault:u(V).annotate({description:"Promote or demote the account default. Demoting the current default requires promoting another queue first."}),maxPerDay:u(U(L.check(Dr({minimum:1,maximum:1000})))),...bL}).annotate({identifier:"UpdateQueue"}),EL=p({expectedVersion:L.check(Te(1)),slots:gL}).annotate({identifier:"ReplaceQueueSlots"}),kL=G(["paused","archived","account_not_ready"]),AL=G(["max_per_day","max_pending"]),gJ=G(["occupied","capacity","skipped","blacked_out"]),vL=p({queueId:Xt,slotId:U(co),scheduledFor:a.annotate({description:"The resolved UTC instant."}),occurrenceDate:bn.annotate({description:"The local date the assignment counts toward."}),localDate:bn,localTime:sh,timezone:rp,available:V,unavailableReason:u(gJ)}).annotate({identifier:"QueueOccurrence"}),CL=p({queueId:Xt,occurrence:U(vL),horizonEndsAt:a}).annotate({identifier:"QueueNextSlot"}),TL=p({queueId:Xt,timezone:rp,horizonEndsAt:a,occurrences:_(vL)}).annotate({identifier:"QueueSlotPreview"}),xJ=G(["published_now","cancelled","archived","submitted","rescheduled"]),Cfe=p({id:hL,queueId:Xt,slotId:U(co),postId:Pt,targetId:sr,attemptId:Wt,scheduledFor:a,occurrenceDate:bn,releasedAt:U(a),releaseReason:U(xJ)}).annotate({identifier:"QueueAssignment"}),bu=co,ah=co,OL=p({slotId:co,occurrenceDate:bn}).annotate({identifier:"SkipQueueSlot"}),Vb=p({id:bu,queueId:Xt,slotId:co,occurrenceDate:bn,createdAt:a}).annotate({identifier:"QueueSkip"}),PL=p({data:_(Vb),...We}).annotate({identifier:"QueueSkipList"}),RL=Lr.check(re(200)).annotate({description:"Optional note for why these dates are unavailable."}),_L=p({startsOn:bn,endsOn:bn,reason:u(RL)}).annotate({identifier:"CreateQueueBlackout"}),Jb=p({id:ah,queueId:Xt,startsOn:bn,endsOn:bn,reason:U(RL),createdAt:a}).annotate({identifier:"QueueBlackout"}),UL=p({data:_(Jb),...We}).annotate({identifier:"QueueBlackoutList"}),Yb=p({deleted:v(!0)}).annotate({identifier:"QueueDeleted"});var SJ=G(["scheduled","queued"]),bJ=p({postId:Pt,targetId:sr,attemptId:Wt,accountId:H,provider:Zt,placement:yr,queueId:u(Xt),slotId:u(co),assignmentId:u(hL),queueName:u(ih),scheduledFor:a.annotate({description:"The queued attempt's UTC instant."}),occurrenceDate:u(bn),timezone:u(rp),localDate:u(bn),localTime:u(sh),status:SJ.annotate({description:"scheduled when scheduledFor is in the future; queued otherwise."}),textPreview:a.check(re(160)).annotate({description:"Short single-line preview of the post text."})}).annotate({identifier:"ScheduleEntry"}),DL=p({data:_(bJ),...We}).annotate({identifier:"ScheduleList"}),Tfe=p({results:_(p({index:L.check(Te(0)),accepted:u(ya),problem:u(a)}))}).annotate({identifier:"BulkPublishResult"}),IJ=G(["invalid_timezone","invalid_slot_time","duplicate_slot","too_many_slots","slot_gap_too_short","limit_above_provider_default","queue_account_mismatch","queue_and_time_conflict","queue_archived","occurrence_in_past","occurrence_outside_horizon","invalid_blackout_range"]),LL=p({code:IJ,path:_(lt([a,L])),message:a}).annotate({identifier:"QueueIssue"}),Ofe=p({workspaceId:ce,accountId:u(H),...St.fields}),Pfe=p({workspaceId:ce}),Rfe=p({workspaceId:ce,expectedVersion:Lm.check(iu(),Te(1))}),_fe=p({workspaceId:ce,after:u(Rt)}),Ufe=p({workspaceId:ce,count:Lm.check(iu(),Dr({minimum:1,maximum:100})),after:u(Rt),includeOccupied:u(V)}),Dfe=p({workspaceId:ce,...St.fields}),Lfe=p({workspaceId:ce,...St.fields}),Mfe=p({workspaceId:ce,from:Rt.annotate({description:"Inclusive ISO start instant."}),to:Rt.annotate({description:"Inclusive ISO end instant, after from and within 90 days."}),accountId:u(H),queueId:u(Xt),...St.fields}),Ffe=p({queueId:Xt,skipId:bu}),Nfe=p({queueId:Xt,blackoutId:ah});var wJ=G(["queued","running","succeeded","partial","failed","cancelled"]),EJ=G(["active","backoff","paused","inaccessible","deleted","complete"]),ML=a.check(D()),FL=a.check(D()),Zb=p({id:ML,workspaceId:ce,cursorId:FL,domain:a,provider:a,subjectKind:a,subjectId:a.check(D()),scope:a,status:wJ,startedAt:a,finishedAt:U(a),requestCount:L,pageCount:L,errorKind:U(a),providerStatus:U(L),retryAfterSeconds:U(L),detail:U($t(a,j)),createdAt:a}).annotate({identifier:"SyncRun"}),qfe=p({cursorId:U(FL),state:EJ,lastSuccessAt:U(a),nextDueAt:U(a),syncRunId:U(ML)}).annotate({identifier:"SyncResource"});var ps="/api/v1/inbox",Yfe=`${ps}/conversations`,Zfe=`${ps}/comments`,Xfe=`${ps}/mentions`,kJ=`${ps}/reviews`,eme=`${kJ}/:reviewId`,tme=`${ps}/unread-count`,rme=`${ps}/capabilities`,nme=`${ps}/sync`,ome=`${ps}/attachments`,AJ=G(["conversation","message","comment_thread","comment","mention"]),NL=G(["inbox","message_request","spam","other"]),eI=G(["active","archived"]),tI=G(["inbound","outbound"]),vJ=G(["received","pending","sending","sent","delivered","failed","unresolved","deleted"]),rI=G(["text","media","template","interactive","system","unknown"]),CJ=G(["post","comment","story","other"]),TJ=G(["image","video","audio","file","unknown"]),OJ=G(["pending","succeeded","failed","unresolved"]),PJ=G(["list","read","send","reply","edit","delete","hide","unhide","like","unlike"]),RJ=G(["webhook","polling","webhook_with_reconciliation"]),Iu=p({externalId:a,name:U(a),handle:U(a)}).annotate({identifier:"InboxParticipant"}),nI=G(["none","24_hours","x_dm_30_days"]),BL=p({open:V,policy:nI,endsAt:U(a)}).annotate({identifier:"InboxReplyWindow"}),_J=G(["fresh","stale","pending","failed"]),oI=p({status:_J,observedAt:U(a),nextDueAt:U(a),syncRunId:U(a)}).annotate({identifier:"InboxFreshness"}),UJ=p({id:gb,messageId:Mn,kind:TJ,mimeType:U(a),sizeBytes:U(L),width:U(L),height:U(L),durationSeconds:U(mr),url:a.annotate({description:"Workspace-scoped PubNio attachment URL. It never contains a provider URL or token."}),createdAt:a}).annotate({identifier:"InboxAttachment"}),iI=p({id:Mn,conversationId:gn,accountId:H,provider:Be,direction:tI,state:vJ,kind:rI,text:U(a),sender:Iu,replyToMessageId:U(Mn),attachments:_(UJ),actionId:U(li),providerCreatedAt:a,providerUpdatedAt:U(a),readAt:U(a),deletedAt:U(a),createdAt:a}).annotate({identifier:"InboxMessage"}),ch=p({id:gn,workspaceId:ce,accountId:H,provider:Be,participant:Iu,folder:NL,status:eI,unreadCount:L,lastMessageAt:U(a),lastInboundAt:U(a),lastOutboundAt:U(a),lastMessagePreview:U(a),providerUrl:U(a),lastReadAt:U(a),archivedAt:U(a),replyWindow:BL,freshness:oI,createdAt:a}).annotate({identifier:"InboxConversation"}),ph=p({id:zc,threadId:Gc,accountId:H,provider:Be,parentCommentId:U(zc),author:Iu,text:U(a),likeCount:L,replyCount:L,likedByAccount:V,hidden:V,canReply:V,canHide:V,canLike:V,canDelete:V,permalink:U(a),actionId:U(li),providerCreatedAt:a,providerUpdatedAt:U(a),deletedAt:U(a),createdAt:a}).annotate({identifier:"InboxComment"}),KL=p({id:Gc,workspaceId:ce,accountId:H,provider:Be,providerPostId:a,postId:U(a.check(D())),permalink:U(a),caption:U(a),commentCount:L,unreadCount:L,lastCommentAt:U(a),lastReadAt:U(a),freshness:oI,createdAt:a}).annotate({identifier:"InboxCommentThread"}),DJ=p({id:jc,workspaceId:ce,accountId:H,provider:Be,kind:CJ,author:Iu,text:U(a),permalink:U(a),parentExternalId:U(a),canReply:V,freshness:oI,providerCreatedAt:a,deletedAt:U(a),createdAt:a}).annotate({identifier:"InboxMention"}),LJ=G(["positive","negative"]),sI=p({id:Km,workspaceId:ce,accountId:H,provider:Be,locationExternalId:U(a),author:Iu,rating:U(L.check(Dr({minimum:1,maximum:5}))),recommendation:U(LJ),text:U(a),permalink:U(a),providerCreatedAt:a,providerUpdatedAt:U(a),repliedAt:U(a),replyText:U(a),canReply:V,deletedAt:U(a),createdAt:a}).annotate({identifier:"InboxReview"}),$L=p({data:_(ch),...We}).annotate({identifier:"InboxConversationList"}),qL=p({data:_(iI),...We}).annotate({identifier:"InboxMessageList"}),WL=p({data:_(KL),...We}).annotate({identifier:"InboxCommentThreadList"}),GL=p({thread:KL,data:_(ph),...We}).annotate({identifier:"InboxCommentThreadDetail"}),zL=p({data:_(DJ),...We}).annotate({identifier:"InboxMentionList"}),jL=p({data:_(sI),...We}).annotate({identifier:"InboxReviewList"}),QL=p({unreadCount:L}).annotate({identifier:"InboxUnreadCount"}),Xb=p({resource:AJ,supported:V,operations:_(PJ),attachments:V,quickReplies:V,buttons:V,readReceipts:V,moderation:V,syncMode:RJ,backfillDays:L,missingScopes:_(a),missingTasks:_(a)}).annotate({identifier:"InboxChannelCapability"}),MJ=p({accountId:H,profileId:a.check(D()),provider:Be,accountKind:ar,enabled:V,publishingReadiness:hi,accountCapabilities:_(yi),messaging:Xb,comments:Xb,mentions:Xb,replyWindow:BL,lastSyncError:U(a),checkedAt:a}).annotate({identifier:"InboxAccountCapabilities"}),HL=p({accounts:_(MJ)}).annotate({identifier:"InboxCapabilities"}),ime=p({workspaceId:ce,accountId:u(H)}),sme=p({workspaceId:ce,conversationId:gn}),ame=p({workspaceId:ce,threadId:Gc}),cme=p({workspaceId:ce,commentId:zc}),pme=p({workspaceId:ce,mentionId:jc}),dme=p({workspaceId:ce,attachmentId:gb}),ume=p({workspaceId:ce,accountId:u(H),provider:u(Be),status:u(eI),folder:u(NL),unread:u(V),search:u(a.check(re(200))),...St.fields}),lme=p({workspaceId:ce,order:u(G(["oldest","newest"])),...St.fields}),fme=p({workspaceId:ce,accountId:u(H),postId:u(a.check(D())),providerPostId:u(a),unread:u(V),...St.fields}),mme=p({workspaceId:ce,...St.fields}),hme=p({workspaceId:ce,accountId:u(H),provider:u(Be),...St.fields}),yme=p({workspaceId:ce,accountId:u(H),includeDeleted:u(V),...St.fields}),gme=p({status:u(eI),read:u(V)}).check(qt(({status:e,read:t})=>e!==void 0||t!==void 0||"Provide status or read.")),aI=Lr.check(xe(1),re(1e4)),xme=p({text:aI}).annotate({identifier:"SendInboxMessage"}),Sme=p({text:aI}).annotate({identifier:"ReplyInboxComment"}),bme=p({text:aI}).annotate({identifier:"ReplyInboxReview"}),Ime=p({hidden:u(V),liked:u(V)}).check(qt(({hidden:e,liked:t})=>e!==void 0!==(t!==void 0)||"Provide exactly one of hidden or liked for one provider call.")),wme=p({"idempotency-key":Qr}),VL=p({deleted:v(!0),actionId:li}).annotate({identifier:"InboxDeleted"}),JL=p({mentionId:jc,actionId:li,status:OJ,providerResultId:U(a)}).annotate({identifier:"InboxMentionReply"}),Eme=p({workspaceId:ce,accountId:u(H)}),YL=p({syncRunId:a.check(D()),status:Zb.fields.status}).annotate({identifier:"InboxSyncAccepted"}),ZL=p({syncRun:Zb,counts:p({conversations:L,messages:L,commentThreads:L,comments:L,mentions:L})}).annotate({identifier:"InboxSyncStatus"}),kme=p({workspaceId:ce,syncRunId:a.check(D())});var wu=G(["post","comment"]);var FJ=Lr.check(xe(1)),Rme=p({accountId:u(H).annotate({description:"Account that comments; derived when unambiguous."}),provider:u(xn),target:a.check(xe(1),re(2048)).annotate({description:"Provider ID or permalink."}),targetKind:u(wu),text:FJ.annotate({description:"Max 8000 characters."})}).annotate({identifier:"CreateComment"}),_me=p({actionId:li,idempotencyKey:Qr,commentId:a.check(xe(1)),target:a,targetId:a.check(xe(1)),targetKind:wu,accountId:H,provider:xn,status:v("posted"),permalink:u(a),replayed:V}).annotate({identifier:"CommentCreated"});var NJ=["meta_ads","google_ads","reddit_ads","pinterest_ads","tiktok_ads","linkedin_ads","snapchat_ads","amazon_ads","openai_ads"],Ct=G(NJ);var BJ=G(["available","selected"]),cI=G(["active","disabled","pending","closed","unknown"]),KJ=p({provider:Ct,kind:v("ad_account"),externalId:a,currency:Fn,timezone:a,status:cI,businessId:u(a),managerId:u(a),loginCustomerId:u(a),region:u($m)}).annotate({identifier:"AdAccountDetails"}),$J=p({configured:V,killSwitchActive:V,monthlyCap:U(yt),dailyCap:U(yt),maxCampaignDailyBudget:U(yt),maxCampaignLifetimeBudget:U(yt),revision:L.check(Te(0))}).annotate({identifier:"AdAccountPolicy"}),po=p({code:a,message:a,field:u(a),providerCode:u(a),missingScopes:u(_(a)),retryable:V,providerMessage:u(a)}).annotate({identifier:"AdIssue"}),ds=G(["draft","paused","activating","active","pending_review","rejected","completed","archived","unknown"]),us=p({amountMinor:L.check(Te(0)),currency:Fn,kind:G(["daily","lifetime"])}).annotate({identifier:"AdBudget"}),uh=p({accountId:H,currency:Fn,configured:V,monthlyCap:U(yt),dailyCap:U(yt),maxCampaignDailyBudget:U(yt),maxCampaignLifetimeBudget:U(yt),killSwitchActive:V,killSwitchAt:U(a),killSwitchReason:U(a),revision:L.check(Te(0)),updatedAt:a}).annotate({identifier:"AdSpendPolicy"}),dh=U(yt),Gme=p({expectedRevision:L.check(Te(0)),monthlyCap:dh,dailyCap:dh,maxCampaignDailyBudget:dh,maxCampaignLifetimeBudget:dh}).annotate({identifier:"AdSpendPolicyUpdate"}),zme=p({active:V,reason:u(a.check(re(500)))}).annotate({identifier:"AdKillSwitchInput"}),XL=p({policy:uh,changed:V,paused:p({campaigns:L.check(Te(0)),adGroups:L.check(Te(0)),ads:L.check(Te(0))}),nextAction:a}).annotate({identifier:"AdKillSwitchResult"}),lh=G(["boost.create","campaign.create","campaign.activate","campaign.pause","campaign.archive","ad_group.status","ad_group.create","ad.status","ad.attach","creative.create","campaign.duplicate","budget.update"]),ku=G(["queued","preflight","creating","recording","reviewing","activating","succeeded","partial","failed","unresolved","cancelled"]),qJ=G(["queued","preflight","create","record","review","activate","finish"]),nn=p({id:fi,accountId:H,kind:lh,status:ku,step:qJ,input:$t(a,j),result:U($t(a,j)),issues:_(po),attempts:L.check(Te(0)),canRetry:V,nextAction:a,createdAt:a,updatedAt:a,startedAt:U(a),completedAt:U(a)}).annotate({identifier:"AdOperation"}),jme=p({id:RU,accountId:H,idempotencyKey:a,intentHash:a,requestedByType:G(["user","api_key"]),requestedByUserId:U(os),requestedByApiKeyId:U(fa),operationId:U(fi),createdAt:a}).annotate({identifier:"AdRequest"}),Qme=p({id:PU,accountId:H,provider:Ct,postId:Pt,targetId:sr,actorAccountId:H,creativeId:U(Qc),campaignId:U(_o),providerPostId:a,permalink:U(a),sourceHash:a,status:ds,revision:L.check(Te(1)),operationId:U(fi),createdAt:a,updatedAt:a}).annotate({identifier:"AdBoost"}),Hme=p({expectedRevision:L.check(Ro(0)),confirmation:v("activate_spend")}).annotate({identifier:"AdCampaignActivationInput"}),Vme=p({expectedRevision:L.check(Ro(0))}).annotate({identifier:"AdCampaignPauseInput"}),Jme=p({expectedRevision:L.check(Ro(0))}).annotate({identifier:"AdCampaignArchiveInput"}),Yme=p({status:G(["active","paused","archived"]),expectedRevision:L.check(Ro(0))}).annotate({identifier:"AdEntityStatusUpdate"}),Zme=p({budget:us,expectedRevision:L.check(Ro(0))}).annotate({identifier:"AdBudgetUpdateInput"}),WJ=p({headline:u(a.check(re(255))),body:u(a.check(re(2000))),callToAction:u(a.check(re(64))),destinationUrl:u(a.check(re(2048))),providerSettings:u($t(a,j))}).annotate({identifier:"AdAttachAdCreative"}),Xme=p({name:a.check(xe(1),re(255)),budget:u(us),targeting:u($t(a,j)),providerSettings:u($t(a,j))}).annotate({identifier:"AdAdGroupCreateInput"}),ehe=p({actorAccountId:H,mediaId:a.check(D()),headline:u(a.check(re(255))),body:u(a.check(re(2000))),callToAction:u(a.check(re(64))),destinationUrl:a.check(re(2048)),providerSettings:u($t(a,j))}).annotate({identifier:"AdCreativeCreateInput"}),the=p({name:u(a.check(xe(1),re(255)))}).annotate({identifier:"AdCampaignDuplicateInput"}),rhe=p({name:a.check(xe(1),re(255)),creativeId:u(Qc),creative:u(WJ),providerSettings:u($t(a,j))}).annotate({identifier:"AdAttachAdInput"}),nhe=p({"idempotency-key":Qr}),GJ=p({id:H,name:a,provider:Ct,accountKind:v("ad_account"),available:V,selected:V,details:KJ,readiness:hi,capabilities:_(yi),policy:$J,issues:_(po),createdAt:a,updatedAt:a}).annotate({identifier:"AdAccount"}),eM=p({data:_(GJ),...We}).annotate({identifier:"AdAccountList"}),ohe=p({workspaceId:ce,state:u(BJ),...St.fields}),ihe=p({workspaceId:ce,provider:Ct,accountId:u(H)}),tM=p({attemptId:a.check(D()),provider:Ct,url:a,status:v("pending")}).annotate({identifier:"AdConnectLaunch"}),she=p({workspaceId:ce,provider:v("openai_ads"),apiKey:a.check(xe(1),re(2048)),accountId:u(H),profileId:u(xt)}).annotate({identifier:"AdApiKeyConnectInput"}),rM=p({provider:v("openai_ads"),accountId:H,status:v("connected")}).annotate({identifier:"AdApiKeyConnectResult"}),ahe=p({workspaceId:ce,accountId:H}),nM=p({accountId:H,selected:v(!0),campaignSyncQueued:V,insightSyncQueued:V}).annotate({identifier:"AdAccountSelection"}),oM=p({accountId:H,disconnected:v(!0),historyRetained:v(!0)}).annotate({identifier:"AdAccountDisconnected"}),iM=G(["awareness","traffic","engagement","leads","sales","app_promotion","video_views","reach","conversions","unknown"]),zJ=G(["provider","pubnio"]),sM=a,Eu=$t(a,j),Au=p({startAt:U(Rt),endAt:U(Rt),timezone:a}).annotate({identifier:"AdSchedule"}),aM=p({valid:V,accountId:H,provider:Ct,actorAccountId:U(H),currency:Fn,budget:U(us),schedule:U(Au),killSwitchActive:V,issues:_(po),nextAction:a}).annotate({identifier:"AdValidation"}),jJ=p({postId:Pt,postTargetId:u(sr),actorAccountId:u(H),budget:us,schedule:u(Au),targeting:u($t(a,j))}).annotate({identifier:"AdBoostDraft"}),che=p({workspaceId:ce,accountId:H,...jJ.fields}).annotate({identifier:"AdBoostInput"}),QJ=G(["campaign.create","ad_group.create","creative.create","ad.create","campaign.activate","campaign.pause","campaign.archive","ad_group.activate","ad_group.pause","ad_group.archive","ad.activate","ad.pause","ad.archive","budget.update","boost.create"]),HJ=p({budgetOwner:G(["campaign","ad_group","shared"]),maxAdGroups:u(L.check(Te(1))),budgetUnit:G(["minor","micros"]),hierarchy:_(G(["campaign","ad_group","creative","ad"])),actor:G(["required","none"]),creative:G(["separate","embedded"]),review:G(["sync","pending","async"]),activation:G(["campaign","ad_group"])}).annotate({identifier:"AdCampaignPlanProfile"}),VJ=p({accountId:H,actorAccountId:u(H),budget:u(us),schedule:u(Au),providerSettings:u($t(a,j))}).annotate({identifier:"AdCampaignPlanTarget"}),JJ=p({headline:u(a.check(re(255))),body:u(a.check(re(2000))),callToAction:u(a.check(re(64))),destinationUrl:u(a.check(re(2048))),media:u(as),providerSettings:u($t(a,j))}).annotate({identifier:"AdCampaignPlanCreative"}),YJ=p({name:a.check(xe(1),re(255)),creative:JJ,providerSettings:u($t(a,j))}).annotate({identifier:"AdCampaignPlanAd"}),ZJ=p({name:a.check(xe(1),re(255)),budget:u(us),targeting:u($t(a,j)),providerSettings:u($t(a,j)),ads:_(YJ).check(xe(1),re(50))}).annotate({identifier:"AdCampaignPlanAdGroup"}),phe=p({name:a.check(xe(1),re(255)),objective:iM,budget:u(us),schedule:u(Au),targets:_(VJ).check(xe(1),re(50)),adGroups:_(ZJ).check(xe(1),re(50)),providerSettings:u($t(a,j))}).annotate({identifier:"AdCampaignPlan"}),XJ=p({accountId:H,provider:u(Ct),name:u(a),currency:u(Fn),budget:u(U(us)),profile:u(HJ),capabilities:u(_(QJ)),issues:_(po)}).annotate({identifier:"AdCampaignPlanTargetValidation"}),cM=p({valid:V,issues:_(po),targets:_(XJ)}).annotate({identifier:"AdCampaignPlanValidation"}),pI=G(["queued","creating","partial","succeeded","failed","unresolved"]),pM=p({accountId:H,provider:Ct,operationId:fi,status:ku}).annotate({identifier:"AdCampaignPlanTargetAccepted"}),dM=p({planId:a.check(D()),status:pI,targets:_(pM)}).annotate({identifier:"AdCampaignPlanAccepted"}),e3=p({planId:a.check(D()),status:pI,createdAt:a,targets:_(pM)}).annotate({identifier:"AdCampaignPlanListRow"}),uM=p({data:_(e3),...We}).annotate({identifier:"AdCampaignPlanList"}),t3=p({accountId:H,provider:Ct,operationId:fi,campaignId:U(_o),status:ku,issues:_(po)}).annotate({identifier:"AdCampaignPlanTargetDetail"}),lM=p({planId:a.check(D()),status:pI,createdAt:a,targets:_(t3),issues:_(po)}).annotate({identifier:"AdCampaignPlanDetail"}),fM=p({id:_o,accountId:H,provider:Ct,externalId:a,name:a,objective:iM,status:ds,providerStatus:U(a),managed:zJ,revision:L.check(Te(1)),budget:U(yt),bidStrategy:U(sM),schedule:Au,providerSettings:Eu,syncedAt:a}).annotate({identifier:"AdCampaign"}),mM=p({id:ma,campaignId:_o,accountId:H,provider:Ct,kind:a,externalId:a,name:a,status:ds,providerStatus:U(a),revision:L.check(Te(1)),budget:U(yt),bidStrategy:U(sM),targeting:Eu,providerSettings:Eu,syncedAt:a}).annotate({identifier:"AdGroup"}),vu=p({id:Qc,accountId:H,provider:Ct,externalId:a,kind:a,actorAccountId:U(H),mediaId:U(a.check(D())),headline:U(a),body:U(a),callToAction:U(a),destinationUrl:U(a),providerSettings:Eu,syncedAt:a}).annotate({identifier:"AdCreative"}),dI=G(["campaign","ad_group","ad"]),r3=a,n3=G(["fresh","stale","pending","partial","unavailable"]),ba=p({status:n3,syncedAt:U(a),nextSyncAt:u(a),retryAfter:u(a)}).annotate({identifier:"AdFreshness"}),dhe=p({accountId:u(H),campaignId:u(_o),adGroupId:u(ma),adId:u(is),from:u(a.check(qe(/^\d{4}-\d{2}-\d{2}$/))),to:u(a.check(qe(/^\d{4}-\d{2}-\d{2}$/))),level:u(dI),metrics:u(_(r3).check(re(30))),cursor:St.fields.cursor,limit:u(L.check(Te(1),lU(100)))}).annotate({identifier:"AdInsightQuery"}),o3=p({id:OU,accountId:H,level:dI,campaignId:U(_o),adGroupId:U(ma),adId:U(is),creativeId:U(Qc),date:a.check(qe(/^\d{4}-\d{2}-\d{2}$/)),currency:Fn,spend:yt,impressions:L.check(Te(0)),clicks:L.check(Te(0)),conversions:mr.check(Te(0)),revenue:yt,metrics:$t(a,mr),syncedAt:a}).annotate({identifier:"AdInsightRow"}),i3=p({currency:Fn,spend:yt,impressions:L.check(Te(0)),clicks:L.check(Te(0)),conversions:mr.check(Te(0)),revenue:yt,metrics:$t(a,mr)}).annotate({identifier:"AdInsightTotals"}),uI=p({from:a,to:a,level:dI,totals:_(i3),rowCount:L.check(Te(0)),freshness:ba}).annotate({identifier:"AdInsightSummary"}),fh=p({id:is,accountId:H,campaignId:_o,adGroupId:ma,creativeId:U(Qc),provider:Ct,externalId:a,name:a,format:U(a),status:ds,providerStatus:U(a),revision:L.check(Te(1)),providerSettings:Eu,syncedAt:a,creative:u(U(vu)),insights:u(U(uI))}).annotate({identifier:"Ad"}),lI=p({data:_(fM),...We,freshness:ba}).annotate({identifier:"AdCampaignList"}),s3=p({...mM.fields,insights:u(U(uI))}).annotate({identifier:"AdGroupListRow"}),hM=p({data:_(s3),...We,freshness:ba}).annotate({identifier:"AdGroupList"}),yM=p({data:_(fh),...We,freshness:ba}).annotate({identifier:"AdList"}),gM=p({data:_(vu),...We,freshness:ba}).annotate({identifier:"AdCreativeList"}),fI=p({data:_(o3),summary:uI,...We,freshness:ba}).annotate({identifier:"AdInsightList"}),a3=p({adGroup:mM,ads:_(p({ad:fh,creative:U(vu)}))}).annotate({identifier:"AdTreeNode"}),c3=p({campaign:fM,adGroups:_(a3)}).annotate({identifier:"AdTreeCampaign"}),xM=p({data:_(c3),...We,freshness:ba}).annotate({identifier:"AdTree"}),SM=p({accountId:H,queuedScopes:_(G(["campaigns","ads_insights"])),nextDueAt:a,retryAfterSeconds:u(L)}).annotate({identifier:"AdRefreshAccepted"});var mI="2026-12-02",bM=[mI],mh=G(bM),IM="PubNio-Version";var hI=Lr.check(xe(1),re(100)),yI=a.check(xe(1),re(128)),Cu=p({id:xt,workspaceId:ce,name:hI,externalId:U(yI),isDefault:V,archived:V,createdAt:a,updatedAt:a}).annotate({identifier:"WorkspaceProfile"}),wM=p({data:_(Cu),...We}).annotate({identifier:"ProfileList"}),ghe=p({workspaceId:ce,includeArchived:u(V),...St.fields}),xhe=p({name:hI,externalId:u(yI)}),She=p({name:u(hI),externalId:u(U(yI))}).check(qt(({name:e,externalId:t})=>e!==void 0||t!==void 0||"Provide a name or external ID.")),bhe=p({profileId:xt}),EM=p({archived:v(!0)});var vhe=G(["publishing","inbox","analytics","ads","scheduling","accounts","billing"]),hh=G(["post.delivery.published","post.delivery.provider_draft","post.delivery.failed","post.delivery.unresolved","post.delivery.cancelled","post.scheduled","post.published","post.partial","post.failed","post.cancelled","inbox.message.received","inbox.comment.received","inbox.review.new","inbox.review.updated","inbox.review.deleted","inbox.review.restored","inbox.review.replied","inbox.mention.received","inbox.message.sent","inbox.message.delivered","inbox.message.read","inbox.message.edited","inbox.message.deleted","inbox.reaction.received","inbox.referral.received","inbox.conversation.started","analytics.post.synced","analytics.account.synced","ads.operation.succeeded","ads.operation.failed","ads.campaign.activated","ads.campaign.paused","ads.budget.changed","ads.kill_switch.activated","ads.lead.received","ads.campaign.status_changed","ads.ad_group.status_changed","ads.ad.status_changed","ads.ad_account.status_changed","ads.ad.review.approved","ads.ad.review.rejected","ads.sync.failed","ads.sync.recovered","ads.initial_sync.completed","schedule.assignment.changed","account.connected","account.disconnected","account.permissions_changed","account.restricted","account.recovered","billing.subscription.updated","billing.credit.topped_up","billing.credit.low","billing.spend_cap.reached","billing.invoice.payment_failed"]);var kM=p({id:a.check(D()),type:hh,version:v(1),timestamp:Rt.check(qe(/Z$/)),workspaceId:ce,profileId:u(xt)}).annotate({identifier:"WorkspaceEventEnvelope"});var gI=a.check(D()),p3=a.check(D()),AM=hh,TM=G([...hh.literals,"webhook.test"]),Khe=p({eventTypes:_(TM)}).annotate({identifier:"WebhookEventTypes"}),Oe=kM.fields,Tu={postId:Pt,targetId:sr,attemptId:Wt,accountId:H,provider:Zt,placement:yr,revision:ao},vM={providerRef:lu,url:u(a)},yh={canRetry:V,canReconcile:V,nextAction:a},d3=G(["published","provider_draft","failed","unresolved","cancelled"]),u3={targetId:sr,accountId:H,provider:Zt,placement:yr,status:d3,url:u(a),issue:u(fu)},l3={targetId:sr,accountId:H,scheduledAt:U(a)},gh={postId:Pt,revision:ao,targets:_(p(u3))},xI=G(["live","backfill"]),CM={messageId:Mn,conversationId:gn,accountId:H,provider:Zt,direction:tI,kind:rI,providerCreatedAt:a,freshness:xI},f3={threadId:Gc,commentId:zc,accountId:H,provider:Zt,providerCreatedAt:a,freshness:xI},m3={mentionId:jc,accountId:H,provider:Zt,providerCreatedAt:a,freshness:xI},Ou={reviewId:Km,accountId:H,provider:Be,locationId:u(a)},Pu={accountId:H,provider:Be,accountKind:ar},$he=lt([p({...Oe,type:v("post.delivery.published"),data:p({...Tu,status:v("published"),...vM})}),p({...Oe,type:v("post.delivery.provider_draft"),data:p({...Tu,status:v("provider_draft"),...vM})}),p({...Oe,type:v("post.delivery.failed"),data:p({...Tu,status:v("failed"),issue:fu,canRetry:yh.canRetry,nextAction:yh.nextAction,providerRef:u(lu),url:u(a)})}),p({...Oe,type:v("post.delivery.unresolved"),data:p({...Tu,status:v("unresolved"),issue:fu,canReconcile:yh.canReconcile,nextAction:yh.nextAction,providerRef:u(lu),url:u(a)})}),p({...Oe,type:v("post.delivery.cancelled"),data:p({...Tu,status:v("cancelled")})}),p({...Oe,type:v("post.scheduled"),data:p({postId:Pt,revision:ao,targets:_(p(l3))})}),p({...Oe,type:v("post.published"),data:p(gh)}),p({...Oe,type:v("post.partial"),data:p(gh)}),p({...Oe,type:v("post.failed"),data:p(gh)}),p({...Oe,type:v("post.cancelled"),data:p(gh)}),p({...Oe,type:v("inbox.message.received"),data:p(CM)}),p({...Oe,type:v("inbox.message.sent"),data:p(CM)}),p({...Oe,type:v("inbox.comment.received"),data:p(f3)}),p({...Oe,type:v("inbox.review.new"),data:p(Ou)}),p({...Oe,type:v("inbox.review.updated"),data:p(Ou)}),p({...Oe,type:v("inbox.review.deleted"),data:p(Ou)}),p({...Oe,type:v("inbox.review.restored"),data:p(Ou)}),p({...Oe,type:v("inbox.review.replied"),data:p(Ou)}),p({...Oe,type:v("inbox.mention.received"),data:p(m3)}),p({...Oe,type:v("inbox.message.delivered"),data:p({messageIds:_(Mn),conversationId:u(gn),accountId:H,provider:Zt,deliveredAt:a})}),p({...Oe,type:v("inbox.message.read"),data:p({messageIds:_(Mn),conversationId:u(gn),accountId:H,provider:Zt,readAt:a})}),p({...Oe,type:v("inbox.message.edited"),data:p({messageId:Mn,conversationId:gn,accountId:H,provider:Zt})}),p({...Oe,type:v("inbox.message.deleted"),data:p({messageId:Mn,conversationId:gn,accountId:H,provider:Zt})}),p({...Oe,type:v("inbox.reaction.received"),data:p({messageId:u(Mn),conversationId:u(gn),accountId:H,provider:Zt,reaction:a,action:G(["add","remove"])})}),p({...Oe,type:v("inbox.referral.received"),data:p({messageId:u(Mn),conversationId:u(gn),accountId:H,provider:Zt,ref:a,source:a,adId:u(a)})}),p({...Oe,type:v("inbox.conversation.started"),data:p({conversationId:gn,accountId:H,provider:Zt,participantExternalId:a})}),p({...Oe,type:v("analytics.post.synced"),data:p({postId:Pt,accountId:H,provider:Be})}),p({...Oe,type:v("analytics.account.synced"),data:p({accountId:H,provider:Be})}),p({...Oe,type:v("ads.operation.succeeded"),data:p({operationId:fi,accountId:H,kind:lh,status:G(["succeeded","partial"]),nextAction:a})}),p({...Oe,type:v("ads.operation.failed"),data:p({operationId:fi,accountId:H,kind:lh,status:G(["failed","unresolved","cancelled"]),issue:po,canRetry:V,nextAction:a})}),p({...Oe,type:v("ads.kill_switch.activated"),data:p({accountId:H,revision:L.check(Te(1)),reason:U(a),pausedCampaigns:L.check(Te(0)),pausedAdGroups:L.check(Te(0)),pausedAds:L.check(Te(0))})}),p({...Oe,type:v("ads.lead.received"),data:p({accountId:H,leadId:a,pageId:u(a),formId:u(a),adId:u(a),adGroupId:u(a)})}),p({...Oe,type:v("ads.campaign.status_changed"),data:p({accountId:H,campaignId:_o,provider:Ct,status:ds})}),p({...Oe,type:v("ads.ad_group.status_changed"),data:p({accountId:H,adGroupId:ma,provider:Ct,status:ds})}),p({...Oe,type:v("ads.ad.status_changed"),data:p({accountId:H,adId:is,provider:Ct,status:ds})}),p({...Oe,type:v("ads.ad_account.status_changed"),data:p({accountId:H,provider:Ct,status:cI})}),p({...Oe,type:v("ads.ad.review.approved"),data:p({accountId:H,adId:is,provider:Ct})}),p({...Oe,type:v("ads.ad.review.rejected"),data:p({accountId:H,adId:is,provider:Ct})}),p({...Oe,type:v("ads.sync.failed"),data:p({accountId:H,provider:Ct})}),p({...Oe,type:v("ads.sync.recovered"),data:p({accountId:H,provider:Ct})}),p({...Oe,type:v("ads.initial_sync.completed"),data:p({accountId:H,provider:Ct})}),p({...Oe,type:v("account.connected"),data:p({...Pu,reconnected:V})}),p({...Oe,type:v("account.disconnected"),data:p({...Pu,reason:G(["disconnected","expired","revoked","deauthorized"])})}),p({...Oe,type:v("account.permissions_changed"),data:p({...Pu,missingScopes:_(a),missingTasks:_(a)})}),p({...Oe,type:v("account.restricted"),data:p({...Pu,reason:v("publish_failures")})}),p({...Oe,type:v("account.recovered"),data:p(Pu)}),p({...Oe,type:v("billing.subscription.updated"),data:p({plan:Jc,status:mu,interval:U(zm),periodStart:a,periodEnd:a,cancelAtPeriodEnd:V})}),p({...Oe,type:v("billing.credit.topped_up"),data:p({amountMicros:L,balanceAfterMicros:L,kind:Hm})}),p({...Oe,type:v("billing.credit.low"),data:p({balanceMicros:L,thresholdMicros:L})}),p({...Oe,type:v("billing.spend_cap.reached"),data:p({capMicros:L,periodSpendMicros:L,estimatedMicros:L})}),p({...Oe,type:v("billing.invoice.payment_failed"),data:p({invoiceId:a,amountDueMinor:L,hostedInvoiceUrl:U(a)})}),p({...Oe,type:v("webhook.test"),data:p({endpointId:du})})]).annotate({identifier:"WebhookEvent"}),SI=G(["publishing","inbox","analytics","ads","scheduling","accounts","billing"]),bI=Lr.check(xe(1),re(100)),OM=a.check(re(2048)),h3=u(_(H)).annotate({description:"Only deliver events for these accounts. Empty or omitted means every account. Duplicates are ignored."}),y3=u(_(SI)).annotate({description:"Drop every event in these families. Empty or omitted means no family is dropped. Duplicates are ignored."}),g3=u(U(_(H))).annotate({description:"Only deliver events for these accounts. Omit to keep the current filter; null or an empty array clears it to every account."}),x3=u(U(_(SI))).annotate({description:"Drop every event in these families. Omit to keep the current denylist; null or an empty array clears it."}),II=_(AM).check(xe(1),re(AM.literals.length),qt((e)=>new Set(e).size===e.length||"Choose each event type only once.")),S3=p({workspaceId:ce,endpointId:du}),qhe=p({...S3.fields,deliveryId:gI}),Whe=p({name:bI,url:OM,eventTypes:II,enabled:u(V),profileId:u(xt),accountIds:h3,disabledResourceGroups:y3}),Ghe=p({name:u(bI),eventTypes:u(II),enabled:u(V),profileId:u(U(xt)),accountIds:g3,disabledResourceGroups:x3}).check(qt((e)=>Object.keys(e).length>0||"Provide at least one endpoint change.")),xh=p({id:du,workspaceId:ce,name:bI,eventTypes:II,enabled:V,profileId:U(xt),accountIds:_(H),disabledResourceGroups:_(SI),apiVersion:mh,destinationOrigin:a,createdAt:a,updatedAt:a,deletedAt:U(a)}).annotate({identifier:"WebhookEndpoint"}),wI=p({...xh.fields,url:U(OM)}),b3=a.check(qe(/^whsec_[A-Za-z0-9+/]{43}=$/)),PM=p({endpoint:wI,secret:b3}),RM=p({data:_(xh),...We}).annotate({identifier:"WebhookEndpointList"}),_M=p({deleted:v(!0)}),UM=p({deliveryId:gI}),EI=G(["pending","sending","delivered","failed","cancelled"]),I3=G(["timeout","network","http_status","redirect","destination_rejected","configuration_unavailable","expired","attempts_exhausted"]),Sh=p({id:gI,workspaceId:ce,endpointId:du,eventId:p3,eventType:TM,status:EI,attemptCount:L,createdAt:a,nextAttemptAt:U(a),lastAttemptAt:U(a),lastHttpStatus:U(L),lastError:U(I3),completedAt:U(a)}).annotate({identifier:"WebhookDelivery"}),DM=p({data:_(Sh),...We}).annotate({identifier:"WebhookDeliveryList"});var kI="~effect/http/HttpBody";class vI{[kI];constructor(){this[kI]=kI}[Yr](){return this.toJSON()}toString(){return et(this,{ignoreToString:!0})}}class LM extends vI{_tag="Empty";toJSON(){return{_id:"effect/HttpBody",_tag:"Empty"}}}var MM=new LM;class AI extends vI{_tag="Uint8Array";contentType;contentLength;text;_body;constructor(e,t,r,n){super();this._body=e,this.text=n,this.contentType=t,this.contentLength=r}get body(){return this._body??=w3(this.text)}toJSON(){return{_id:"effect/HttpBody",_tag:"Uint8Array",body:this.contentType.startsWith("text/")||this.contentType.endsWith("json")?new TextDecoder().decode(this.body):`Uint8Array(${this.body.length})`,contentType:this.contentType,contentLength:this.contentLength}}}var FM=new TextEncoder,bh=globalThis.Buffer,w3=bh!==void 0?(e)=>bh.from(e,"utf8"):(e)=>FM.encode(e),NM=(e,t)=>{if(typeof e!=="string")e=e===void 0?"":String(e);if(bh!==void 0)return new AI(void 0,t??"text/plain",bh.byteLength(e,"utf8"),e);let r=FM.encode(e);return new AI(r,t??"text/plain",r.length,e)},BM=(e,t)=>NM(JSON.stringify(e),t??"application/json");var E3=Object.getPrototypeOf(da),$M=()=>Object.create(E3);var qM="~effect/http/HttpServerResponse";var A3=(e,t)=>{if(e?.contentType)return e.contentType;else if(e?.headers)return t["content-type"]};var WM=(e,t)=>{let r=t?.headers?O_(t.headers):da;return C3({status:t?.status??200,statusText:t?.statusText,headers:r,cookies:t?.cookies,body:BM(e,A3(t,r))})};var v3={...Br,[qM]:qM,[Bm]:!0,toJSON(){return{_id:"HttpServerResponse",status:this.status,statusText:this.statusText,headers:Wn(this.headers),cookies:this.cookies.toJSON(),body:this.body.toJSON()}}},C3=(e,t)=>{let r=Object.create(v3);if(r.status=e.status,r.statusText=e.statusText,r.cookies=e.cookies??v_,r.body=e.body??MM,r.body._tag!=="Empty"&&(r.body.contentType||r.body.contentLength!==void 0)){let n=t!==void 0,o=n?t:e.headers===void 0||e.headers===da?$M():P_({...e.headers});if(r.body.contentType&&(!n||o["content-type"]===void 0))o["content-type"]=r.body.contentType;if(r.body.contentLength!==void 0&&(!n||o["content-length"]===void 0))o["content-length"]=r.body.contentLength.toString();r.headers=o}else r.headers=t??e.headers??da;return r};var zM="~effect/http/HttpServerRespondable";var Ih="application/problem+json",QM="about:blank",Ia=(e)=>u(e).pipe(pb(()=>ld)),HM=(e,t)=>uU(W(t))(e).pipe(pb(()=>ux(t))),CI=(e)=>HM(ns(e),e),T3=cU(p({type:HM(a,QM),status:Ia(mr),title:Ia(a),detail:Ia(a),instance:Ia(a)}),[$t(a,j)]);var O3={_tag:"Json",contentType:Ih},pe=()=>(e,t,r,n)=>{let o=p({detail:Ia(a),instance:Ia(a),...r,type:ns(t.type),status:CI(t.status),title:CI(t.title)}),i=sU(o),s=su(e)(o,{description:t.title,httpApiStatus:t.status,"~httpApiEncoding":O3,...n});return Object.assign(s.prototype,{_tag:e,[Bm]:t.status<500,[zM](){return _e(i(this),(c)=>WM(c,{status:t.status,contentType:Ih}))}}),Object.defineProperty(s.prototype,"message",{get(){return this.detail??t.title},configurable:!0}),s},P3=p({path:_(lt([a,mr])),message:a});class R3 extends pe()("UploadTooLarge",{type:"about:blank",status:413,title:"Content Too Large"}){}class JM extends pe()("AuthenticationRequired",{type:"urn:pubnio:problem:authentication-required",status:401,title:"Unauthorized"},{docUrl:u(a)}){}class YM extends pe()("Forbidden",{type:"urn:pubnio:problem:forbidden",status:403,title:"Forbidden"},{requiredScope:u(hu),docUrl:u(a)}){}class ZM extends pe()("HumanActorRequired",{type:"urn:pubnio:problem:human-actor-required",status:403,title:"Human actor required"},{code:v("human_actor_required"),nextAction:a}){}class XM extends pe()("OwnerRequired",{type:"urn:pubnio:problem:owner-required",status:403,title:"Owner permission required"},{code:v("owner_required"),nextAction:a}){}class eF extends pe()("SeatLimitReached",{type:"urn:pubnio:problem:seat-limit-reached",status:402,title:"Seat limit reached"},{code:v("seat_limit_reached"),seatsUsed:L,seatsLimit:L,nextAction:a}){}class tF extends pe()("AlreadyMember",{type:"urn:pubnio:problem:already-member",status:409,title:"Already a workspace member"},{code:v("already_member"),nextAction:a}){}class rF extends pe()("InviteAlreadyPending",{type:"urn:pubnio:problem:invite-already-pending",status:409,title:"Invite already pending"},{code:v("invite_already_pending"),nextAction:a}){}class nF extends pe()("LastOwnerRequired",{type:"urn:pubnio:problem:last-owner-required",status:409,title:"Last owner required"},{code:v("last_owner_required"),nextAction:a}){}class oF extends pe()("InviteExpired",{type:"urn:pubnio:problem:invite-expired",status:410,title:"Invite expired"},{code:v("invite_expired"),nextAction:a}){}class iF extends pe()("InviteEmailMismatch",{type:"urn:pubnio:problem:invite-email-mismatch",status:403,title:"Invite email mismatch"},{code:v("invite_email_mismatch"),nextAction:a}){}class sF extends pe()("NotFound",{type:"urn:pubnio:problem:not-found",status:404,title:"Not Found"}){}class aF extends pe()("Conflict",{type:"urn:pubnio:problem:conflict",status:409,title:"Conflict"}){}class cF extends pe()("Unavailable",{type:"urn:pubnio:problem:unavailable",status:503,title:"Service Unavailable"}){}class pF extends pe()("UnsupportedApiVersion",{type:"urn:pubnio:problem:unsupported-api-version",status:400,title:"Unsupported API version"},{code:v("unsupported_api_version"),param:a,supportedVersions:_(mh),nextAction:a}){}class _3 extends pe()("InvalidCursor",{type:"urn:pubnio:problem:invalid-cursor",status:400,title:"Invalid cursor"},{code:u(v("invalid_cursor")),nextAction:u(a)}){}var Ru=p({accountId:H,name:a}).annotate({identifier:"ProblemCandidate"});class dF extends pe()("InvalidPublication",{type:"urn:pubnio:problem:invalid-publication",status:422,title:"Invalid publication"},{issues:_(so),candidates:u(_(Ru)),code:u(v("invalid_publication")),nextAction:u(a)}){}var uF="x-request-id",lF=P3;class fF extends pe()("InternalFailure",{type:"urn:pubnio:problem:internal-error",status:500,title:"Internal Server Error"},{requestId:a.check(D())}){}class mF extends pe()("AttemptChanged",{type:"urn:pubnio:problem:attempt-changed",status:409,title:"Delivery attempt changed"},{currentAttemptId:Wt}){}class hF extends pe()("IdempotencyConflict",{type:"urn:pubnio:problem:idempotency-conflict",status:409,title:"Idempotency key already used"},{code:u(v("idempotency_conflict")),nextAction:u(a)}){}class yF extends pe()("AccountAmbiguous",{type:"urn:pubnio:problem:account-ambiguous",status:422,title:"Account ambiguous"},{code:v("account_ambiguous"),provider:Be,param:a,candidates:_(Ru),nextAction:a}){}class gF extends pe()("ProviderMismatch",{type:"urn:pubnio:problem:provider-mismatch",status:422,title:"Provider mismatch"},{code:v("provider_mismatch"),provider:Be,expectedProvider:Be,param:a,nextAction:a}){}class xF extends pe()("PublishAccountNotFound",{type:"urn:pubnio:problem:publish-account-not-found",status:422,title:"Publishing account not found"},{code:v("account_not_found"),provider:u(Be),accountId:u(H),param:a,candidates:u(_(Ru)),nextAction:a}){}class SF extends pe()("MediaUploadConflict",{type:"urn:pubnio:problem:media-upload-conflict",status:409,title:"Media upload conflict"},{reason:OD}){}class bF extends pe()("DestinationAlreadySubmitted",{type:"urn:pubnio:problem:destination-already-submitted",status:409,title:"Destination already submitted"}){}class IF extends pe()("DeliveryNotRetryable",{type:"urn:pubnio:problem:delivery-not-retryable",status:409,title:"Delivery cannot be retried"}){}class wF extends pe()("DeliveryNotReconcilable",{type:"urn:pubnio:problem:delivery-not-reconcilable",status:409,title:"Delivery cannot be reconciled"}){}class EF extends pe()("DeliveryScheduleLocked",{type:"urn:pubnio:problem:delivery-schedule-locked",status:409,title:"Delivery schedule cannot change"}){}class kF extends pe()("PostRevisionConflict",{type:"urn:pubnio:problem:post-revision-conflict",status:409,title:"Post revision changed"},{currentRevision:ao}){}class AF extends pe()("QueueNotFound",{type:"urn:pubnio:problem:queue-not-found",status:404,title:"Queue not found"}){}class vF extends pe()("QueueAlreadyExists",{type:"urn:pubnio:problem:queue-already-exists",status:409,title:"Queue already exists"}){}class CF extends pe()("QueueDefaultRequired",{type:"urn:pubnio:problem:queue-default-required",status:409,title:"Queue default required"},{code:v("queue_default_required"),accountId:H,nextAction:a}){}class TF extends pe()("QueueVersionConflict",{type:"urn:pubnio:problem:queue-version-conflict",status:409,title:"Queue version changed"},{currentVersion:L.check(Te(1))}){}class OF extends pe()("QueueUnavailable",{type:"urn:pubnio:problem:queue-unavailable",status:409,title:"Queue unavailable"},{reason:kL}){}class PF extends pe()("QueueCapacityReached",{type:"urn:pubnio:problem:queue-capacity-reached",status:409,title:"Queue capacity reached"},{reason:AL}){}class RF extends pe()("QueueNoSlotAvailable",{type:"urn:pubnio:problem:queue-no-slot-available",status:409,title:"No queue slot available"},{horizonEndsAt:a}){}class _F extends pe()("QueueSlotConflict",{type:"urn:pubnio:problem:queue-slot-conflict",status:409,title:"Queue slot conflict"},{scheduledAt:a,suggestedSlots:_(a)}){}class UF extends pe()("InvalidTimezone",{type:"urn:pubnio:problem:invalid-timezone",status:422,title:"Invalid time zone"},{code:v("invalid_timezone"),timezone:a,nextAction:a}){}class DF extends pe()("InvalidQueue",{type:"urn:pubnio:problem:invalid-queue",status:422,title:"Invalid queue"},{issues:_(LL)}){}class LF extends pe()("ScheduleRangeTooWide",{type:"urn:pubnio:problem:schedule-range-too-wide",status:422,title:"Schedule range too wide"},{maxDays:L}){}class MF extends pe()("WebhookTestRateLimited",{type:"urn:pubnio:problem:webhook-test-rate-limited",status:429,title:"Webhook test rate limited"}){}class FF extends pe()("WebhookDeliveryNotReplayable",{type:"urn:pubnio:problem:webhook-delivery-not-replayable",status:409,title:"Webhook delivery not replayable"},{code:v("webhook_delivery_not_replayable"),deliveryStatus:EI,nextAction:a}){}class NF extends pe()("ProviderPermissionRequired",{type:"urn:pubnio:problem:provider-permission-required",status:403,title:"Provider permission required"},{provider:Be,missingScopes:_(a),missingRoles:_(a),reason:u(a),reconnectRequired:u(V)}){}class BF extends pe()("ProviderReconnectRequired",{type:"urn:pubnio:problem:provider-reconnect-required",status:409,title:"Provider reconnect required"},{provider:Be,missingScopes:_(a),reason:u(a)}){}class KF extends pe()("ProviderRateLimited",{type:"urn:pubnio:problem:provider-rate-limited",status:429,title:"Provider rate limited"},{provider:Be,retryAfterSeconds:u(L)}){}class $F extends pe()("ProviderUnavailable",{type:"urn:pubnio:problem:provider-unavailable",status:503,title:"Provider unavailable"},{provider:Be,retryAfterSeconds:u(L)}){}class qF extends pe()("CapabilityUnsupported",{type:"urn:pubnio:problem:capability-unsupported",status:422,title:"Capability unsupported"},{capability:mi,provider:Be,accountKind:ar}){}class WF extends pe()("AnalyticsRangeInvalid",{type:"urn:pubnio:problem:analytics-range-invalid",status:400,title:"Analytics range invalid"},{reason:G(["invalid_timezone","invalid_range","range_too_wide"])}){}class GF extends pe()("AnalyticsMetricUnsupported",{type:"urn:pubnio:problem:analytics-metric-unsupported",status:400,title:"Analytics metric unsupported"},{metrics:_(a),maxMetrics:u(L)}){}class zF extends pe()("AnalyticsRefreshConflict",{type:"urn:pubnio:problem:analytics-refresh-conflict",status:409,title:"Analytics refresh conflict"},{reason:G(["not_published","deleted","account_analytics_pending"])}){}class jF extends pe()("CapabilityUnverified",{type:"urn:pubnio:problem:capability-unverified",status:409,title:"Capability unverified"},{capability:mi,provider:Be}){}class QF extends pe()("InboxReplyWindowClosed",{type:"urn:pubnio:problem:inbox-reply-window-closed",status:409,title:"Inbox reply window closed"},{provider:Be,policy:nI,endsAt:U(a)}){}class HF extends pe()("InboxTargetChanged",{type:"urn:pubnio:problem:inbox-target-changed",status:409,title:"Inbox target changed"},{targetId:a,state:G(["deleted","changed","unsupported"])}){}class VF extends pe()("InboxSyncInProgress",{type:"urn:pubnio:problem:inbox-sync-in-progress",status:409,title:"Inbox sync already running"},{syncRunId:a.check(D()),retryAfterSeconds:L}){}class JF extends pe()("InboxUnsupportedContent",{type:"urn:pubnio:problem:inbox-unsupported-content",status:422,title:"Inbox content unsupported"},{kind:G(["image","video","audio","file","text","unknown"]),capability:mi}){}var U3=[QF,HF,VF,JF];class YF extends pe()("AdAccountNotReady",{type:"urn:pubnio:problem:ad-account-not-ready",status:409,title:"Ad account not ready"},{reason:G(["unavailable","needs_reconnect","permission_missing","account_disabled"]),missingScopes:u(_(a))}){}class ZF extends pe()("AdAccountNotSelected",{type:"urn:pubnio:problem:ad-account-not-selected",status:409,title:"Ad account not selected"},{accountId:a}){}class XF extends pe()("AdInsightRangeInvalid",{type:"urn:pubnio:problem:ad-insight-range-invalid",status:422,title:"Ad insight range invalid"},{reason:G(["invalid_range","range_too_wide"]),maxDays:u(L)}){}class eN extends pe()("AdRefreshRateLimited",{type:"urn:pubnio:problem:ad-refresh-rate-limited",status:429,title:"Ad refresh rate limited"},{retryAfterSeconds:L.check(Te(0))}){}class tN extends pe()("AdRevisionConflict",{type:"urn:pubnio:problem:ad-revision-conflict",status:409,title:"Ad resource revision conflict"},{resource:G(["spend_policy","campaign","ad_group","ad","boost"]),expectedRevision:L.check(Te(0)),actualRevision:L.check(Te(0)),nextAction:a}){}class rN extends pe()("AdBudgetExceeded",{type:"urn:pubnio:problem:ad-budget-exceeded",status:422,title:"Ad budget exceeds a spend cap"},{reason:G(["daily_cap","monthly_cap","campaign_daily_max","campaign_lifetime_max"]),limit:yt,requested:yt,committed:yt,nextAction:a}){}class nN extends pe()("AdBudgetBelowMinimum",{type:"urn:pubnio:problem:ad-budget-below-minimum",status:422,title:"Ad budget is below the provider minimum"},{minimum:yt,requested:yt,nextAction:a}){}class oN extends pe()("AdCurrencyMismatch",{type:"urn:pubnio:problem:ad-currency-mismatch",status:422,title:"Ad currency does not match the account"},{expected:Fn,actual:Fn,nextAction:a}){}class iN extends pe()("AdSpendForbidden",{type:"urn:pubnio:problem:ad-spend-forbidden",status:403,title:"Ad spend permission required"},{reason:G(["owner_required","api_key_forbidden","confirmation_required","monthly_cap_required","provider_managed"]),nextAction:a}){}class sN extends pe()("AdKillSwitchActive",{type:"urn:pubnio:problem:ad-kill-switch-active",status:409,title:"Ad kill switch is active"},{accountId:H,activatedAt:U(a),reason:U(a),nextAction:a}){}class aN extends pe()("AdOperationNotRetryable",{type:"urn:pubnio:problem:ad-operation-not-retryable",status:409,title:"Ad operation is not retryable"},{operationStatus:ku,nextAction:a}){}class cN extends pe()("AdProviderRejected",{type:"urn:pubnio:problem:ad-provider-rejected",status:422,title:"Ad provider rejected the request"},{provider:Ct,code:a,retryable:V,providerCode:u(a),providerMessage:u(a),issues:_(po),nextAction:a}){}class pN extends pe()("InvalidAdRequest",{type:"urn:pubnio:problem:invalid-ad-request",status:400,title:"Invalid ad request"},{reason:a,field:u(a),nextAction:a}){}var D3=[NF,BF,KF,$F,qF,jF];class L3 extends pe()("CommentTargetInvalid",{type:"urn:pubnio:problem:comment-target-invalid",status:400,title:"Comment target invalid"},{code:v("comment_target_invalid"),reason:a,targetKind:u(wu),nextAction:a}){}class M3 extends pe()("CommentRejected",{type:"urn:pubnio:problem:comment-rejected",status:422,title:"Comment rejected"},{code:v("comment_rejected"),provider:Be,targetKind:wu,nextAction:a}){}class F3 extends pe()("CommentUnresolved",{type:"urn:pubnio:problem:comment-unresolved",status:409,title:"Comment outcome unresolved"},{code:v("comment_unresolved"),actionId:li,nextAction:a}){}var N3=[dF,mF,hF,bF,IF,wF,EF,kF,yF,gF,xF],B3=[WF,GF,zF],K3=[YF,ZF,XF,eN,tN,rN,nN,oN,iN,sN,aN,cN,pN],$3=[AF,vF,CF,TF,OF,PF,RF,_F,DF,LF],q3=[UF];class dN extends pe()("InsufficientCredit",{type:"urn:pubnio:problem:insufficient-credit",status:402,title:"Insufficient prepaid credit"},{code:v("insufficient_credit"),balanceMicros:L,requiredMicros:L,fundingUrl:a,canManageBilling:V,nextAction:a}){}class uN extends pe()("SpendCapReached",{type:"urn:pubnio:problem:spend-cap-reached",status:402,title:"Monthly spend cap reached"},{code:v("spend_cap_reached"),capMicros:L,periodSpendMicros:L,estimatedMicros:L,fundingUrl:a,canManageBilling:V,nextAction:a}){}class lN extends pe()("BillingInactive",{type:"urn:pubnio:problem:billing-inactive",status:402,title:"Workspace billing is inactive"},{code:v("billing_inactive"),subscriptionStatus:mu,fundingUrl:a,canManageBilling:V,nextAction:a}){}class fN extends pe()("TopUpAmountInvalid",{type:"urn:pubnio:problem:top-up-amount-invalid",status:400,title:"Top-up amount is out of range"},{code:v("top_up_amount_invalid"),minMinor:L,maxMinor:L,nextAction:a}){}class mN extends pe()("InvalidBillingDateRange",{type:"urn:pubnio:problem:invalid-billing-date-range",status:400,title:"Invalid billing date range"},{code:v("invalid_billing_date_range"),nextAction:a}){}class hN extends pe()("BillingRevisionConflict",{type:"urn:pubnio:problem:billing-revision-conflict",status:409,title:"Billing settings changed concurrently"},{code:v("billing_revision_conflict"),expectedVersion:L,actualVersion:L,nextAction:a}){}class yN extends pe()("SubscriptionAlreadyActive",{type:"urn:pubnio:problem:subscription-already-active",status:409,title:"Subscription is already active"},{code:v("subscription_already_active"),plan:Jc,nextAction:a}){}class gN extends pe()("CheckoutAlreadyCompleted",{type:"urn:pubnio:problem:checkout-already-completed",status:409,title:"Checkout session already completed"},{code:v("checkout_already_completed"),checkoutId:a,nextAction:a}){}class xN extends pe()("BillingCustomerMissing",{type:"urn:pubnio:problem:billing-customer-missing",status:409,title:"No billing customer exists yet"},{code:v("billing_customer_missing"),nextAction:a}){}class SN extends pe()("BillingProviderMismatch",{type:"urn:pubnio:problem:billing-provider-mismatch",status:409,title:"Workspace billing gateway mismatch"},{code:v("billing_provider_mismatch"),workspaceGateway:jm,requestedGateway:jm,nextAction:a}){}class bN extends pe()("BillingNotConfigured",{type:"urn:pubnio:problem:billing-not-configured",status:503,title:"Billing gateway is not configured"},{code:v("billing_not_configured"),nextAction:a}){}class IN extends pe()("BillingUnavailable",{type:"urn:pubnio:problem:billing-unavailable",status:503,title:"Billing gateway is temporarily unavailable"},{code:v("billing_unavailable"),retryable:V,nextAction:a}){}var W3=[dN,uN,lN],G3=[...W3,fN,mN,hN,yN,gN,xN,SN,bN,IN],z3=[eF,tF,rF,nF,oF,iF],wN=lt([JM,YM,ZM,XM,sF,aF,cF,pF,...N3,...G3,...$3,...q3,...z3,...U3,...D3,...B3,...K3,fF,MF,FF,SF]);var wa=G(["impressions","reach","views","likes","comments","shares","saves","clicks","link_clicks","profile_visits","page_views","follows","followers","follower_gained","follower_lost","watch_time_ms","avg_watch_time_ms","completion_rate","engagement","engagement_rate"]),EN=G(["count","milliseconds","ratio"]),kN=G(["sum","unique","latest","weighted","ratio"]),AN=G(["post","account"]),j3=G(["total","day"]),vN=G(["available","pending","unsupported","deprecated","renamed","permission_missing","access_pending","stale","deleted","private","not_applicable"]),Q3=$t(a,mr),wh=p({key:wa,value:U(mr),availability:vN,reason:u(a),replacedBy:u(wa),renamedTo:u(wa),missingScopes:u(_(a)),reconnectRequired:u(V),retryAfter:u(a),observedAt:u(a),total:u(U(mr)),breakdown:u(Q3)}).annotate({identifier:"MetricReading"}),H3=p({key:wa,scopes:_(AN),unit:EN,aggregation:kN,definition:a}).annotate({identifier:"MetricDefinition"}),V3=p({key:wa,scope:AN,granularity:j3,unit:EN,aggregation:kN,availability:vN,supported:V,reason:u(a),renamedFrom:u(a),replacedBy:u(wa)}).annotate({identifier:"MetricCapability"}),J3=G(["ready","permission_required","access_pending","reconnect_required","disabled"]),Y3=p({provider:Be,accountKinds:_(ar),placements:_(yr),metrics:_(V3),historyDays:L.check(Ro(0)),latencySeconds:L.check(Te(0)),firstAvailableAfterSeconds:L.check(Te(0)),requiredScopes:_(a),comments:V}).annotate({identifier:"ProviderCapabilities"}),Z3=p({accountId:H,provider:Be,accountKind:ar,readiness:J3,capability:yi,missingScopes:_(a),reconnectRequired:V,accessPending:V}).annotate({identifier:"AnalyticsAccountCapability"}),CN=p({metrics:_(H3),providers:_(Y3),accounts:_(Z3),checkedAt:a}).annotate({identifier:"AnalyticsCapabilities"}),X3=G(["fresh","stale","pending","partial","unavailable"]),Eh=p({status:X3,observedAt:U(a),retryAfter:u(a)}).annotate({identifier:"AnalyticsFreshness"}),TN=p({from:a.check(qe(/^\d{4}-\d{2}-\d{2}$/)),to:a.check(qe(/^\d{4}-\d{2}-\d{2}$/)),timezone:v("UTC"),dayBasis:v("provider_utc")}).annotate({identifier:"AnalyticsDateRange"}),nge=G(["provider_daily","snapshot_delta","provider_lifetime","provider_total"]),ON=p({date:a.check(qe(/^\d{4}-\d{2}-\d{2}$/)),metrics:_(wh)}).annotate({identifier:"AnalyticsPoint"}),e6=G(["available","pending","unavailable"]),t6=p({targetId:sr,attemptId:U(Wt),accountId:H,provider:Be,placement:yr,providerPostId:U(a),publishedAt:U(a),state:e6,metrics:_(wh),series:u(_(ON)),freshness:Eh}).annotate({identifier:"PostAnalyticsTarget"}),OI=p({postId:Pt,workspaceId:ce,range:TN,targets:_(t6),freshness:Eh}).annotate({identifier:"PostAnalytics"}),r6=p({accountId:H,provider:Be,accountKind:ar,profileId:xt,name:a,metrics:_(wh),freshness:Eh}).annotate({identifier:"AnalyticsAccountSummary"}),PN=p({accountId:H,workspaceId:ce,provider:Be,accountKind:ar,profileId:xt,name:a,range:TN,metrics:_(wh),series:u(_(ON)),freshness:Eh}).annotate({identifier:"AccountAnalytics"}),RN=p({data:_(r6),...We}).annotate({identifier:"AccountAnalyticsList"}),oge=p({workspaceId:ce,postId:u(Pt),targetId:u(sr),metrics:u(_(wa).check(re(30)))}).check(qt(({postId:e,targetId:t})=>e!==void 0||t!==void 0||"Send postId or targetId to refresh a published post.")),n6=G(["queued","running","succeeded","failed","paused","deleted","inaccessible"]),PI=p({id:a.check(D()),workspaceId:ce,subjectKind:a,subjectId:a.check(D()),status:n6,nextDueAt:U(a),lastSuccessAt:U(a),errorKind:U(a),createdAt:a}).annotate({identifier:"AnalyticsRefresh"});var _N={name:"@pubnio/sdk",version:"0.2.3",description:"JavaScript and TypeScript client for the PubNio API",type:"module",exports:{".":"./src/index.ts","./solid":"./src/solid.ts","./internal":"./src/internal.ts","./package.json":"./package.json"},dependencies:{"@pubnio/protocol":"workspace:*",effect:"4.1.7"},peerDependencies:{"@tanstack/solid-query":"6.0.0-rc.6"},peerDependenciesMeta:{"@tanstack/solid-query":{optional:!0}},devDependencies:{"@hey-api/openapi-ts":"0.99.0","@tanstack/solid-query":"6.0.0-rc.6","dts-bundle-generator":"10.0.0",typescript:"6.0.3"},scripts:{generate:"bun script/generate.ts","check:generated":"bun script/generate.ts --check",pack:"bun script/pack.ts",build:"bun script/pack.ts"},sideEffects:!1,engines:{node:">=20.19.0"},publishConfig:{access:"public"},files:["dist","README.md"]};function UN({onRequest:e,onSseError:t,onSseEvent:r,responseTransformer:n,responseValidator:o,sseDefaultRetryDelay:i,sseMaxRetryAttempts:s,sseMaxRetryDelay:c,sseSleepFn:l,url:S,...m}){let g,w=l??((y)=>new Promise((h)=>setTimeout(h,y)));return{stream:async function*(){let y=i??3000,h=0,x=m.signal??new AbortController().signal;while(!0){if(x.aborted)break;h++;let q=m.headers instanceof Headers?m.headers:new Headers(m.headers);if(g!==void 0)q.set("Last-Event-ID",g);try{let Y={redirect:"follow",...m,body:m.serializedBody,headers:q,signal:x},I=new Request(S,Y);if(e)I=await e(S,Y);let ae=await(m.fetch??globalThis.fetch)(I);if(!ae.ok)throw Error(`SSE failed: ${ae.status} ${ae.statusText}`);if(!ae.body)throw Error("No body in SSE response");let N=ae.body.pipeThrough(new TextDecoderStream).getReader(),Z="",z=()=>{try{N.cancel()}catch{}};x.addEventListener("abort",z);try{while(!0){let{done:X,value:ee}=await N.read();if(X)break;Z+=ee,Z=Z.replace(/\r\n?/g,`
36
36
  `);let ie=Z.split(`
37
37
 
38
38
  `);Z=ie.pop()??"";for(let oe of ie){let de=oe.split(`
@@ -268,5 +268,5 @@ ${s}${i}ERRORS${o}`);for(let[,m]of l)for(let g of m)S.push(` ${jh(g.message)}${
268
268
  `)};var r$=(e)=>Rk(e),n$=(e,t,r)=>{switch(t){case"bash":return $K(e,r);case"zsh":return t$(e,r);case"fish":return GK(e,r);case"powershell":return HK(e,r)}};var C=(e)=>Kh(uo,e),ft=(e)=>PK(uo,e),Ue=(e)=>gk(uo,e);var Nk=(e,t)=>$h(uo,e,t),we=(e,t)=>qh(uo,e,t);var Bk=B(2,(e,t)=>RK(e,t)),Ce=B(2,(e,t)=>xk(e,t));var Kk=B(2,(e,t)=>kk(e,t));var E=(e)=>pp(e),Xe=Ik;var Sr=B(2,(e,t)=>Ek(e,t)),p9=B(2,(e,t)=>wk(e,t));var ue=B(2,(e,t)=>Gh(e,t));var $k=(e)=>{let t=new Set,r=[];for(let n of e){if(t.has(n))continue;t.add(n),r.push(n)}return r},i$=(e,t)=>{let r=[e],n=e;for(let o=1;o<t.length;o++){let i=t[o],s=void 0;for(let c of n.subcommands)if(s=c.commands.find((l)=>l.name===i),s)break;if(!s)break;r.push(s),n=s}return r},qk=(e,t,r)=>{let o=i$(e,t).flatMap((i)=>Ft(i).globalFlags);return $k([...r,...o])},d9=(e)=>{let t=[],r=(n)=>{let o=Ft(n);for(let i of o.globalFlags)t.push(i);for(let i of n.subcommands)for(let s of i.commands)r(s)};return r(e),$k(t)},u9=(e,t)=>{if(e.length<=1)return[];let r=new Set(t.map((o)=>o.name)),n=[];for(let o of e.slice(0,-1)){let i=Ft(o);for(let s of i.contextConfig.flags){let c=Mt(s),l=Lo(s);for(let S of c){if(r.has(S.name))continue;if(S.hidden)continue;r.add(S.name),n.push(Jh(S,l))}}}return n},s$=(e,t)=>$k([...t,...d9(e)]),Xh=(e,t,r)=>wr(function*(){let n=i$(e,t),o=n.length>0?n[n.length-1]:e,i=Ft(o).buildHelpDoc(t),s=u9(n,i.flags),c=qk(e,t,r),l=[];for(let m of c){let g=Mt(m.flag),w=Lo(m.flag);for(let k of g){if(k.hidden)continue;l.push({...Jh(k,w),required:!1})}}let S=1;for(let m=n.length-1;m>0;m--)if(Ft(n[m]).globalFlags.length>0){S=m+1;break}return{...i,inheritedFlags:s,globalFlags:l,globalFlagsScope:t.slice(0,S),commandPath:t}});var ey=(e)=>({_tag:"Action",flag:e.flag,run:e.run}),f9=(e)=>(t)=>{a$+=1;let r=Vt(`effect/cli/GlobalFlag/${e}/${a$}`);return Object.assign(r,{_tag:"Setting",id:e,flag:t.flag})},a$=0,m9=ey({flag:ft("help").pipe(Bk("h"),Ce("Show help information"),Xe(!1)),run:Se(function*(e,{builtIns:t,command:r,commandPath:n}){let o=yield*up,i=yield*Xh(r,n,t);yield*o.present({_tag:"Help",reason:"Requested",commandPath:n,helpDoc:i})})}),h9=ey({flag:ft("version").pipe(Bk("v"),Ce("Show version information"),Xe(!1)),run:Se(function*(e,{command:t,version:r}){yield*(yield*up).present({_tag:"Version",name:t.name,version:r})})}),Wk=ey({flag:ft("wizard").pipe(Ce("Start wizard mode for a command"),Xe(!1)),run:()=>He}),y9=ey({flag:Nk("completions",[["bash","bash"],["zsh","zsh"],["fish","fish"],["powershell","powershell"],["sh","bash"],["pwsh","powershell"]]).pipe(E,Kk("<bash|zsh|fish|powershell|sh|pwsh>"),Ce("Print shell completion script")),run:Se(function*(e,{command:t}){if(nr(e))return;let r=r$(t);yield*hr(n$(t.name,e.value,r))})}),lp=f9("log-level")({flag:Nk("log-level",[["all","All"],["trace","Trace"],["debug","Debug"],["info","Info"],["warn","Warn"],["warning","Warn"],["error","Error"],["fatal","Fatal"],["none","None"]]).pipe(E,Ce("Sets the minimum log level"),Kk("<all|trace|debug|info|warn|warning|error|fatal|none>"))}),c$=[m9,h9,Wk,y9,lp];class ty extends jt("effect/cli/CliConfig",{defaultValue:()=>g9}){}var g9={builtIns:c$};var d$=Sx((e)=>W(tc(e,Ck)??Hh({colors:cn(e,Nh).canColor})));function l$(e){let t=e.indexOf("--");if(t===-1)return{tokens:u$(e),trailingOperands:[]};return{tokens:u$(e.slice(0,t)),trailingOperands:e.slice(t+1)}}var f$=(e)=>{if(e._tag==="Value")return e.value;if(e._tag==="LongOption")return e.raw;let t=m$.test(e.raw)?`--${e.flag}`:e.raw;return e.value===void 0?t:`${t}=${e.value}`},m$=/^-(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?$/,u$=(e)=>{let t=[];for(let r of e)if(!r.startsWith("-")||m$.test(r))t.push({_tag:"Value",value:r});else if(r.startsWith("--")){let n=r.indexOf("=");if(n!==-1){let o=r.slice(2,n);if(o==="")t.push({_tag:"Value",value:r});else{let i=r.slice(n+1);t.push({_tag:"LongOption",name:o,raw:r,value:i})}}else t.push({_tag:"LongOption",name:r.slice(2),raw:r})}else if(r.length>1){let n=r.slice(1),o=n.indexOf("=");if(o!==-1){let i=Array.from(n.slice(0,o)),s=i.pop()??"";for(let c of i)t.push({_tag:"ShortOption",flag:c,raw:`-${c}`});t.push({_tag:"ShortOption",flag:s,raw:`-${s}`,value:n.slice(o+1)})}else for(let i of n)t.push({_tag:"ShortOption",flag:i,raw:`-${i}`})}else t.push({_tag:"Value",value:r});return t};var S9=(e,t)=>{let r=e.length,n=t.length,o=Array.from({length:r+1},()=>Array(n+1).fill(0));for(let i=0;i<=r;i++)o[i][0]=i;for(let i=0;i<=n;i++)o[0][i]=i;for(let i=1;i<=r;i++)for(let s=1;s<=n;s++){let c=e[i-1]===t[s-1]?0:1;o[i][s]=Math.min(o[i-1][s]+1,o[i][s-1]+1,o[i-1][s-1]+c)}return o[r][n]},zk=(e,t)=>{let r=t.map((o)=>[S9(e,o),o]).filter(([o])=>o<=2).sort(([o],[i])=>o-i);if(r.length===0)return[];let n=r[0][0];return r.filter(([o])=>o===n).map(([,o])=>o)};var Qk=(e)=>Kr(e.subcommand,{onNone:()=>[],onSome:(t)=>[t.name,...Qk(t.parsedInput)]}),Hk=(e,t,r=[])=>wr(function*(){let{tokens:n,trailingOperands:o}=e,i=[...r,t.name],s=v$(n,A$(t,i));if(s._tag==="Leaf")return{flags:s.flags,arguments:[...s.arguments,...o],subcommand:he(),...s.errors.length>0&&{errors:s.errors}};let c={tokens:s.childTokens,trailingOperands:o},l=yield*Hk(c,s.sub,i),S=[...s.errors,...l.errors??[]];return{flags:s.flags,arguments:[],subcommand:Re({name:s.sub.name,parsedInput:l}),...S.length>0&&{errors:S}}}),Vk=(e,t)=>{let r=v$(e,A$(t,[]));return r._tag==="Leaf"?e:Vk(r.childTokens,r.sub)},ry=(e)=>{let t=0;return{peek:()=>e[t],take:()=>e[t++],rest:()=>e.slice(t)}},g$=(e)=>!ZE(e.primitiveType)||e.negation===!1?void 0:e.negation??`no-${e.name}`,mp=(e)=>{let t=new Map,r=new Map;for(let n of e){if(t.has(n.name))throw Error(`Duplicate flag name "${n.name}" in command definition`);t.set(n.name,n);for(let i of n.aliases){if(t.has(i))throw Error(`Duplicate flag/alias "${i}" in command definition (conflicts with "${t.get(i).name}")`);t.set(i,n)}let o=g$(n);if(o!==void 0){if(r.has(o))throw Error(`Duplicate negation "${o}" in command definition (conflicts with "${r.get(o).name}")`);r.set(o,n)}}return{params:e,index:t,negations:r}},x$=(e)=>{let t=new Map,r=(n,o)=>{let i=t.get(n);if(i&&i!==o)throw Error(`Duplicate subcommand name/alias "${n}" in command definition (conflicts with "${i.name}")`);t.set(n,o)};for(let n of e)for(let o of n.commands)if(r(o.name,o),o.alias&&o.alias!==o.name)r(o.alias,o);return t},Jk=(e)=>Object.fromEntries(e.map((t)=>[t.name,[]])),b9=(e)=>{let t=Jk(e);return{add:(r,n)=>{if(n!==void 0)t[r].push(n)},merge:(r)=>{for(let n in r){let o=r[n];if(o?.length)for(let i=0;i<o.length;i++)t[n].push(o[i])}},snapshot:()=>t}},ny=(e)=>e._tag==="LongOption"||e._tag==="ShortOption",S$=(e)=>e._tag==="LongOption"?e.name:e.flag,fp=(e,t)=>{let r=S$(e),n=t.index.get(r);if(n&&n.name===r)return{param:n,negated:!1};let o=e._tag==="LongOption"?t.negations.get(e.name):void 0;if(o)return{param:o,negated:!0};if(n)return{param:n,negated:!1};return},h$=(e,t,r)=>new In({option:t.name,value:r,expected:`omit the value and use ${e.raw} by itself to set --${t.name} to false`,kind:"flag"}),I9=(e)=>{let t=xi(e.primitiveType);return new In({option:e.name,value:"",expected:t===void 0?e.typeName??Fu(e.primitiveType):t.join(" | "),kind:"flag"})},y$=(e)=>e?._tag==="Value"&&(LB(e.value)||MB(e.value))?e.value:void 0,b$=(e,t,r,n=!1)=>{let o=Hu(e,t,r,n);switch(o._tag){case"Value":return{_tag:"Value",value:o.value};case"Error":return{_tag:"Error",error:o.error}}},Hu=(e,t,r,n=!1)=>{if(n){if(t.value!==void 0)return{_tag:"Error",error:h$(t,r,t.value),tokens:[]};let i=r.optionalValue===void 0?y$(e.peek()):void 0;if(i!==void 0){let s=e.take();return{_tag:"Error",error:h$(t,r,i),tokens:s===void 0?[]:[s]}}return{_tag:"Value",value:"false",tokens:[]}}if(t.value!==void 0)return{_tag:"Value",value:t.value,tokens:[]};if(r.optionalValue!==void 0)return{_tag:"Value",value:r.optionalValue,tokens:[]};if(ZE(r.primitiveType)){let i=y$(e.peek()),s=i!==void 0?e.take():void 0;return{_tag:"Value",value:i??"true",tokens:s===void 0?[]:[s]}}let o=e.peek();if(o?._tag==="Value"){let i=e.take();return{_tag:"Value",value:o.value,tokens:i===void 0?[]:[i]}}return{_tag:"Error",error:I9(r),tokens:[]}},w9=(e,t)=>{let r=Jk(t.params),n=[],o=[],i=ry(e);for(let s=i.take();s;s=i.take()){if(!ny(s)){n.push(s);continue}let c=fp(s,t);if(!c){n.push(s);continue}let l=b$(i,s,c.param,c.negated);if(l._tag==="Error"){o.push(l.error);continue}if(l.value!==void 0)r[c.param.name].push(l.value)}return{flagMap:r,remainder:n,errors:o}},I$=(e)=>Ft(e).config.flags.flatMap(Mt).filter(Wu),w$=(e)=>Ft(e).contextConfig.flags.flatMap(Mt).filter(Wu),E$=(e,t)=>{for(let r of t){let n=fp(e,r);if(n!==void 0)return n}return},jk=(e,t,r,n)=>{e.push(r);let o=Hu(t,r,n.param,n.negated);e.push(...o.tokens)},E9=(e,t,r,n,o)=>{let i=ry(t);Hu(i,e,r.param,r.negated);for(let s=i.take();s;s=i.take()){if(ny(s)){let c=E$(s,o);if(c!==void 0)Hu(i,s,c.param,c.negated);continue}if(s._tag==="Value")return n.has(s.value)}return!1},k$=(e,t,r)=>{let n=Jk(r.params),o=[],i=(s,c,l)=>{let S=mp(I$(c)),m=mp(w$(c)),g=x$(c.subcommands),w=ry(s),k=[],A=!0;for(let y=w.take();y;y=w.take()){if(ny(y)){let h=E$(y,l);if(h!==void 0){jk(k,w,y,h);continue}let x=fp(y,m);if(x!==void 0){jk(k,w,y,x);continue}let q=fp(y,S),Y=fp(y,r);if(q!==void 0){if(Y===void 0||!A||!E9(y,w.rest(),q,g,[S,m,r])){jk(k,w,y,q);continue}}if(Y!==void 0){let I=Hu(w,y,Y.param,Y.negated);if(I._tag==="Error"){o.push(I.error);continue}if(I.value!==void 0)n[Y.param.name].push(I.value);continue}k.push(y);continue}if(y._tag==="Value"&&A){let h=g.get(y.value);if(h!==void 0)return k.push(y),k.push(...i(w.rest(),h,[...l,m])),k;A=!1}k.push(y)}return k};return{flagMap:n,remainder:i(e,t,[]),errors:o}},k9=(e,t,r)=>{let n=e._tag==="LongOption"?`--${e.name}`:`-${e.flag}`,o=[];for(let s of t){if(s.hidden)continue;o.push(s.name);let c=g$(s);if(c!==void 0)o.push(c);for(let l of s.aliases)o.push(l)}let i=zk(S$(e),o).map((s)=>s.length===1?`-${s}`:`--${s}`);return new ka({option:n,suggestions:i,command:r})},A9=(e)=>({flags:b9(e.params),arguments:[],errors:[],mode:{_tag:"AwaitingFirstValue"}}),v9=(e)=>({_tag:"Leaf",flags:e.flags.snapshot(),arguments:e.arguments,errors:e.errors}),C9=(e,t,r,n)=>{let{command:o,commandPath:i,inheritedFlagRegistry:s,localFlagNames:c}=r,l=x$(o.subcommands),S=l.get(e);if(S){let g=[...i,S.name],w=n.flags.snapshot();for(let A of c){let y=w[A];if(y!==void 0&&y.length>0)n.errors.push(new ka({option:`--${A}`,suggestions:[],command:g}))}let k=w9(t.rest(),s);return n.flags.merge(k.flagMap),n.errors.push(...k.errors),{_tag:"Subcommand",result:{_tag:"Sub",flags:n.flags.snapshot(),sub:S,childTokens:k.remainder,errors:n.errors}}}if(!(Ft(o).config.arguments.length>0)&&l.size>0){let g=[];for(let[k,A]of l)if(!A.unlisted)g.push(k);let w=zk(e,g);n.errors.push(new _h({subcommand:e,parent:i,suggestions:w}))}return{_tag:"Argument"}},T9=(e,t,r,n)=>{let{commandPath:o,flagRegistry:i}=r,s=fp(e,i);if(!s){n.errors.push(k9(e,i.params,o));return}let c=b$(t,e,s.param,s.negated);if(c._tag==="Error"){n.errors.push(c.error);return}n.flags.add(s.param.name,c.value)},O9=(e,t,r,n)=>{if(n.mode._tag==="AwaitingFirstValue"){let o=C9(e,t,r,n);if(o._tag==="Subcommand")return o.result;n.mode={_tag:"CollectingArguments"}}n.arguments.push(e);return},A$=(e,t)=>{let r=I$(e),n=w$(e),o=new Set(n.map((i)=>i.name));return{command:e,commandPath:t,flagRegistry:mp(r),inheritedFlagRegistry:mp(n),localFlagNames:r.filter((i)=>!o.has(i.name)).map((i)=>i.name)}},v$=(e,t)=>{let r=ry(e),n=A9(t.flagRegistry);for(let o=r.take();o;o=r.take()){if(ny(o)){T9(o,r,t,n);continue}if(o._tag==="Value"){let i=O9(o.value,r,t,n);if(i)return i}}return v9(n)};var O$=Se(function*(e,t){let r=t?.commandPath??[e.name],n=R9(e,r),o=(t?.prefix??r).map((s)=>Kn(s)),{colors:i}=yield*Ku;return yield*oy(o,i),yield*P$(n,o,n===e?"ROOT":n.name,i),{args:o.map((s)=>s.value),displayArgs:o.map((s)=>s.displayValue)}}),R9=(e,t)=>{let r=e;for(let n of t.slice(1)){let o=r.subcommands.flatMap((i)=>i.commands).find((i)=>i.name===n||i.alias===n);if(o===void 0)break;r=o}return r},P$=Se(function*(e,t,r,n){let o=Ft(e),i=e.subcommands.flatMap((l)=>l.commands.filter((S)=>!S.unlisted)),s=i.length===0?o.config:o.contextConfig;if(s.flags.length>0){yield*hr(T$(r,"FLAGS",n));for(let l of s.flags)t.push(...yield*C$(l));if(s.arguments.length>0||i.length>0)yield*oy(t,n)}if(s.arguments.length>0){if(yield*hr(T$(r,"ARGUMENTS",n)),i.length===0)t.push(Kn("--"));for(let l of s.arguments)t.push(...yield*C$(l));if(i.length>0)yield*oy(t,n)}if(i.length===0)return;let c=yield*on(ak({message:"Command",choices:i.map((l)=>({title:l.name,value:l,...l.shortDescription!==void 0?{description:l.shortDescription}:l.description!==void 0?{description:l.description}:{}}))}));if(yield*hr(),t.push(Kn(c.name)),_9(c))yield*oy(t,n);yield*P$(c,t,c.name,n)}),_9=(e)=>e.subcommands.some((r)=>r.commands.some((n)=>!n.unlisted))||Ft(e).config.orderedParams.length>0,C$=Se(function*(e){let t=zh(e),r=Lo(e);if(r.isOptional){if(!(yield*on(ik({message:`Set ${Yk(t)}?`,initial:!1}))))return yield*hr(),[]}let n=!r.isVariadic?1:yield*on(sk({message:`${Yk(t)} count`,default:ur(r.variadicMin,()=>0),min:ur(r.variadicMin,()=>0),...O(r.variadicMax)?{max:r.variadicMax.value}:{}})),o=[];for(let s=0;s<n;s++)o.push(yield*U9(t));let i=t.kind===uo?{flags:{[t.name]:o.map((s)=>s.value)},arguments:[]}:{flags:{},arguments:o.map((s)=>s.value)};if(yield*e.parse(i),yield*hr(),t.kind===dp)return o;return o.flatMap((s)=>t.optionalValue!==void 0||s.value.startsWith("-")&&s.value.length>1?[Kn(`--${t.name}=${s.value}`,`--${t.name}=${s.displayValue}`)]:[Kn(`--${t.name}`),s])}),U9=(e)=>{let t=L9(e);switch(e.primitiveType._tag){case"Boolean":return _e(on(ik({message:t,label:{confirm:"true",deny:"false"},placeholder:{defaultConfirm:"(T/f)",defaultDeny:"(t/F)"}})),(r)=>Kn(String(r)));case"Choice":{let r=xi(e.primitiveType)??[];return _e(on(ak({message:t,choices:r.map((n)=>({title:n,value:n}))})),Kn)}case"Date":return _e(on(nK({message:t})),(r)=>Kn(r.toISOString()));case"Finite":return _e(on(oK({message:t})),(r)=>Kn(String(r)));case"Int":return _e(on(sk({message:t})),(r)=>Kn(String(r)));case"Redacted":return _e(on(iK({message:t})),(r)=>Kn(Nc(r),"<redacted>"));default:return _e(on(sK({message:t})),Kn)}},Kn=(e,t=e)=>({value:e,displayValue:t}),D9=(e)=>e.kind===uo?`--${e.name}`:e.name,L9=(e)=>Yk(e),Yk=(e)=>{let t=f(e.description)?.trim(),r=e.kind===uo&&t!==void 0&&t.length<=32?t:M9(e.name);return e.kind===uo?`${r} (${D9(e)})`:r},M9=(e)=>{let t=e.split(/[-_]+/).filter((r)=>r.length>0);if(t.length===0)return e;return[t[0][0].toUpperCase()+t[0].slice(1),...t.slice(1)].join(" ")},oy=(e,t)=>hr(D$("Current command",e.map((r)=>r.displayValue),t,jB)),T$=(e,t,r)=>`${bt(r,e.toUpperCase(),Si,ap)} ${bt(r,"\xB7",Bu)} ${bt(r,t,Si,Ca)}`,R$=(e,t,r,n)=>[`${bt(n,e,Si,ap)} ${bt(n,`v${t}`,Ca)} ${bt(n,"\xB7 Command wizard",Si,Ca)}`,...r===void 0||r.length===0?[]:[r],bt(n,"Build a command interactively. Press Ctrl+C to cancel.",Bu),""].join(`
269
269
  `),_$=(e,t)=>D$("Command ready",e,t,ap,Mh),U$=(e)=>`
270
270
  ${bt(e,"Wizard cancelled.",Lh)}`,D$=(e,t,r,n,o=Ca)=>{let i=F9(t);return[bt(r,e,Si,o),...i.map((s)=>bt(r,s,n)),""].join(`
271
- `)},F9=(e)=>{let o=e.map(N9),i=[],s=" $ ";for(let c of o){let l=s===" $ "||s===" "?"":" ";if(s.length+l.length+c.length>88&&s!==" $ ")i.push(`${s} \\`),s=` ${c}`;else s+=`${l}${c}`}if(s!==" $ ")i.push(s);return i},N9=(e)=>/^[A-Za-z0-9_./:@%+=,-]+$/.test(e)?e:`'${e.replaceAll("'",`'"'"'`)}'`;var K9=(e)=>je(e,zu),T=(e,t,r)=>{let n=Tk(t??{});return Vh({name:e,config:n,...Qt(r)?{handle:r}:{}})};var $9=(e)=>{let t=[],r=new Map,n=(s,c)=>{t.push(c);let l=r.get(s);if(l)l.push(c);else r.set(s,[c])};for(let s of e){if(K9(s)){n(void 0,s);continue}for(let c of s.commands)n(s.group,c)}let o=[],i=r.get(void 0);if(i&&i.length>0)o.push({group:void 0,commands:i});for(let[s,c]of r){if(s===void 0)continue;o.push({group:s,commands:c})}return{flat:t,groups:o}},Je=B(2,(e,t)=>{let r=$9(t);FK(e,r.flat);let n=Ft(e),o=new Map(r.flat.map((l)=>[l.name,Ft(l)])),i=Symbol("effect/cli/SubcommandState"),s=Se(function*(l){if(nr(l.subcommand))return yield*n.parse(l);let S=o.get(l.subcommand.value.name);if(!S)return yield*n.parse(l);let m=yield*n.parseContext(l),g=yield*S.parse(l.subcommand.value.parsedInput);return{...m,[i]:{name:S.name,result:g}}}),c=Se(function*(l,S){let g=l[i];if(g){let w=o.get(g.name);if(!w)return yield*new gi({commandPath:S,errors:[]});return yield*w.handle(g.result,[...S,w.name]).pipe(Qi(n.service,l))}return yield*n.handle(l,S)});return Vh({name:n.name,config:n.config,contextConfig:n.contextConfig,description:n.description,shortDescription:n.shortDescription,alias:n.alias,unlisted:n.unlisted,annotations:n.annotations,globalFlags:n.globalFlags,resolveExamples:n.resolveExamples,service:n.service,subcommands:r.groups,parse:s,parseContext:n.parseContext,handle:c})});var P=B(2,(e,t)=>Vh({...Ft(e),description:t}));var q9=(e,t,r,n)=>{let o=new Set(t),i=[],s=new Set;for(let c of e){if(o.has(c))continue;let l=Mt(c.flag);for(let S of l){let m=r[S.name];if(!m||m.length===0)continue;let g=`--${S.name}`;if(s.has(g))continue;s.add(g),i.push(new ka({option:g,suggestions:[],command:n}))}}return i},W9=(e,t,r)=>wr(function*(){let{builtIns:n}=yield*ty,o=yield*up,{commandPath:i,errors:s}=t,c=yield*Xh(e,i,n);yield*o.present(r&&s.length>0?{_tag:"InvalidInvocation",commandPath:i,helpDoc:c,errors:s}:{_tag:"Help",reason:"Implicit",commandPath:i,helpDoc:c})}),G9=(e,t)=>wr(function*(){let r=yield*d$,n=e instanceof Mu?e:new Mu({cause:e,userMessage:t});yield*Nm(r.formatError(n)),Object.assign(e,{[pu]:!1})});var L$=(e,t)=>{let r=Ft(e);return Se(function*(n){let{builtIns:o}=yield*ty,{tokens:i,trailingOperands:s}=l$(n),c=s$(e,o),l=c.flatMap((z)=>Mt(z.flag)),S=mp(l.filter(Wu)),{flagMap:m,remainder:g,errors:w}=k$(i,e,S),k={flags:m,arguments:[]},A=yield*Hk({tokens:g,trailingOperands:s},e),y=[e.name,...Qk(A)],h=(z)=>z._tag==="ShowHelp"?z:new gi({commandPath:y,errors:[z]}),x=Or(h),q={builtIns:o,command:e,commandPath:y,version:t.version},Y=qk(e,y,o),I=q9(c,Y,m,y);if(I.length>0||w.length>0){let z=A.errors??[];return yield*new gi({commandPath:y,errors:[...w,...I,...z]})}for(let z of Y){if(z._tag!=="Action")continue;if(!Mt(z.flag).some((oe)=>{let de=m[oe.name];return de!==void 0&&de.length>0}))continue;let[,ie]=yield*z.flag.parse(k).pipe(x);if(z===Wk){let{colors:oe}=yield*Ku;return yield*wr(function*(){yield*hr(R$(e.name,t.version,e.description,oe));let de=new Set(Vk(g,e)),ge=[e.name,...i.filter((Ke)=>!de.has(Ke)&&!(Ke._tag==="LongOption"&&Ke.name==="wizard")).map(f$)],ke=yield*O$(e,{commandPath:y,prefix:ge});if(yield*hr(_$(ke.displayArgs,oe)),yield*on(aK({message:"Run this command?",initial:!0,active:"yes",inactive:"no"})))yield*hr(),yield*L$(e,{...t,renderErrors:!1})(ke.args.slice(1))}).pipe(md("QuitError",()=>hr(U$(oe))))}yield*z.run(ie,q);return}if(A.errors&&A.errors.length>0)return yield*new gi({commandPath:y,errors:A.errors});let le=yield*r.parse(A).pipe(Or((z)=>YE(z)?h(z):z)),ae=r.handle(le,[e.name]),N=Y.includes(lp)?(yield*lp.flag.parse(k).pipe(x))[1]:he();ae=Qi(ae,lp,N);for(let z of Y){if(z._tag!=="Setting"||z===lp)continue;let[,X]=yield*z.flag.parse(k).pipe(x);ae=Qi(ae,z,X)}let Z=Kr(N,{onNone:()=>pn(),onSome:(z)=>Fs(tO,z)});yield*ji(ae,Z)},kf((n)=>YE(n)&&n._tag==="ShowHelp"?Jt(n):Dt(n),(n)=>Jn(W9(e,n,t.renderErrors!==!1),fe(n))),kf((n)=>{if(t.renderErrors===!1||!Tp(n))return Dt(n);let o=UB(n);return o===void 0?Dt(n):Jt({error:n,userMessage:o})},({error:n,userMessage:o})=>Jn(G9(n,o),fe(n))),kf((n)=>bU(n)?Jt(n):Dt(n),(n)=>gd))};var Vu={name:"@pubnio/cli",version:"0.2.1",type:"module",description:"PubNio command-line interface.",homepage:"https://pubnio.com/docs/cli/",keywords:["pubnio","cli","social","publishing","api","agents","mcp"],publishConfig:{access:"public"},bin:{pnio:"./dist/index.js"},files:["dist","README.md"],engines:{bun:">=1.4.0"},scripts:{generate:"bun script/generate.ts","generate:check":"bun script/generate.ts --check",build:"bun build --target=bun --minify --outfile dist/index.js ./src/index.ts && bun run copy:skill","copy:skill":"mkdir -p dist/skills/pnio && cp ../docs/skills/pnio/SKILL.md dist/skills/pnio/SKILL.md",pack:"bun script/pack.ts",compile:"bun build --compile --minify --compile-exec-argv=--use-system-ca --outfile dist/pnio ./src/index.ts","compile:all":"bun run compile:darwin-arm64 && bun run compile:darwin-x64 && bun run compile:linux-x64 && bun run compile:linux-arm64 && bun run compile:windows-x64","compile:darwin-arm64":"bun build --compile --minify --compile-exec-argv=--use-system-ca --target=bun-darwin-arm64 --outfile dist/pnio-darwin-arm64 ./src/index.ts","compile:darwin-x64":"bun build --compile --minify --compile-exec-argv=--use-system-ca --target=bun-darwin-x64 --outfile dist/pnio-darwin-x64 ./src/index.ts","compile:linux-x64":"bun build --compile --minify --compile-exec-argv=--use-system-ca --target=bun-linux-x64 --outfile dist/pnio-linux-x64 ./src/index.ts","compile:linux-arm64":"bun build --compile --minify --compile-exec-argv=--use-system-ca --target=bun-linux-arm64 --outfile dist/pnio-linux-arm64 ./src/index.ts","compile:windows-x64":"bun build --compile --minify --compile-exec-argv=--use-system-ca --target=bun-windows-x64 --outfile dist/pnio-windows-x64.exe ./src/index.ts",prepack:"bun run build"},dependencies:{"@effect/platform-bun":"4.1.7","@pubnio/protocol":"workspace:*","@pubnio/sdk":"workspace:*",effect:"4.1.7",jose:"6.2.19","proper-lockfile":"4.1.2"},devDependencies:{"@types/proper-lockfile":"4.1.4"}};function M$(e){let t,r=Ea({...e,onRuntime:(n)=>{t=n}});if(!t)throw Error("PubNio client runtime was not captured.");return{client:r,runtime:t}}function F$(e={}){let t=process.env,r=e.json===!0||t.PUBNIO_NON_INTERACTIVE==="1"||t.CI==="1"||t.CI==="true"||Boolean(t.OPENCODE_AGENT)||Boolean(t.CLAUDECODE)||!process.stdout.isTTY;return{interactive:!r,browser:!r}}var M=C("workspace").pipe(ue(ce),E,Ce("Workspace ID. Defaults to PUBNIO_WORKSPACE_ID or your only workspace.")),N$=te("id").pipe(ne(ce)),gbe=C("name").pipe(ue(LU.fields.name)),xbe=C("default-timezone").pipe(E,Ce("Default IANA time zone for new queues, e.g. America/New_York.")),Ju=ft("browser").pipe(Xe(F$().browser),Ce("Open the browser automatically. Defaults to on only for an interactive terminal; pass --browser or --no-browser to override.")),Zk=C("account").pipe(ue(H),E,Ce("Publishing account ID.")),B$=C("account").pipe(ue(H),Sr(0),Ce("Publish to this exact publishing account ID, or save it as a draft target. Repeat for several accounts.")),K$=C("account").pipe(ue(xu.fields.accountId),E,Ce("Publish to this existing post target account.")),rt=C("idempotency-key").pipe(ue(Qr),E,Ce("Reuse a key to replay this request safely. Generated when omitted.")),ys={cursor:C("cursor").pipe(E),limit:Ue("limit").pipe(E)};class Le extends Error{}function It(e){return(e==="-"?Bun.stdin:Bun.file(e)).json().catch(()=>{throw new Le("Could not read JSON input.")})}function R(e){return Ws({try:e,catch:(t)=>t}).pipe(Gi((t)=>Fe(()=>console.log(JSON.stringify(t,null,2)))))}function iy(e){let t=process.platform==="darwin"?"open":process.platform==="linux"?"xdg-open":void 0;if(!t||!Bun.which(t))return;Bun.spawn([t,e],{stdin:"ignore",stdout:"ignore",stderr:"ignore"}).unref()}var $$=p({clientId:a});var q$="/api/auth/cli";var W$=new TextDecoder,G$=new TextDecoder("utf-8",{fatal:!0});function z$(e,t=!1){if(Uint8Array.fromBase64)return Uint8Array.fromBase64(e,{alphabet:t?"base64url":"base64"});if(t){if(e.includes("+")||e.includes("/"))throw TypeError("Invalid base64url");e=e.replace(/-/g,"+").replace(/_/g,"/")}let r=atob(e),n=new Uint8Array(r.length);for(let o=0;o<r.length;o++)n[o]=r.charCodeAt(o);return n}class j$ extends Error{static code="ERR_JOSE_GENERIC";code="ERR_JOSE_GENERIC";constructor(e,t){super(e,t),this.name=this.constructor.name,Error.captureStackTrace?.(this,this.constructor)}}class Ii extends j${static code="ERR_JWT_INVALID";code="ERR_JWT_INVALID"}var j9="The input to be decoded is not correctly encoded.";function Q$(e){try{return z$(typeof e=="string"?e:W$.decode(e),!0)}catch(t){throw TypeError(j9,{cause:t})}}function H$(e){if(typeof e!="object"||e===null||Object.prototype.toString.call(e)!=="[object Object]")return!1;let t=Object.getPrototypeOf(e);return t===null||Object.getPrototypeOf(t)===null}function Xk(e){if(typeof e!="string")throw new Ii("JWTs must use Compact JWS serialization, JWT must be a string");let{1:t,length:r}=e.split(".");if(r===5)throw new Ii("Only JWTs using Compact JWS serialization can be decoded");if(r!==3)throw new Ii("Invalid JWT");if(!t)throw new Ii("JWTs must contain a payload");let n;try{n=Q$(t)}catch(i){throw new Ii("Failed to base64url decode the payload",{cause:i})}let o;try{o=JSON.parse(G$.decode(n))}catch(i){throw new Ii("Failed to parse the decoded payload as JSON",{cause:i})}if(!H$(o))throw new Ii("Invalid JWT Claims Set");return o}var kq=j1(Iq(),1);import{mkdir as R5,rename as wq,rm as Fa,writeFile as Eq}from"fs/promises";import{homedir as _5}from"os";import{join as yA}from"path";var U5="https://api.workos.com/user_management",D5=(e)=>{let t=yA(process.env.XDG_CONFIG_HOME||yA(_5(),".config"),"pubnio"),r=new Bun.CryptoHasher("sha256").update(e).digest("hex");return{dir:t,file:yA(t,`${r}.json`)}},gA=p({access_token:a,refresh_token:a}),L5=p({clientId:a,...gA.fields,workspaceId:u(ce)}),Aq=p({device_code:a,user_code:a,verification_uri:a,verification_uri_complete:a,expires_in:mr.check(Ro(0)),interval:mr.check(Ro(0))});class xy extends Error{code;status;constructor(e,t){super(`WorkOS request failed (HTTP ${t}).`);this.code=e;this.status=t}}var M5="Sign in with `pnio auth login`.";async function xA(e,t,r,n){let o=await e(`${U5}/${t}`,{method:"POST",body:new URLSearchParams(r),redirect:"error",signal:AbortSignal.timeout(1e4)}),i=await o.json().catch(()=>null);if(o.ok)return no(n)(i);let s=i&&typeof i==="object"&&"error"in i&&typeof i.error==="string"?i.error:"unknown";throw new xy(s,o.status)}var F5=p({clientId:a,device:Aq,expiresAt:mr}),vq=(e)=>`${e}.device.json`;async function N5(e,t){let r=`${e}.${crypto.randomUUID()}.tmp`;try{await Eq(r,JSON.stringify(t),{mode:384,flag:"wx"}),await wq(r,e)}finally{await Fa(r,{force:!0})}}async function B5(e,t=fetch){let r=await xA(t,"authorize/device",{client_id:e},Aq),n=new URL(r.verification_uri),o=new URL(r.verification_uri_complete);if(n.protocol!=="https:"||o.origin!==n.origin)throw Error("WorkOS returned an invalid sign-in URL.");return{device:r,url:n.href,completeUrl:o.href}}async function Cq(e){let t=await wA(e,"GET"),{clientId:r}=await no($$)(await t.json()),{device:n,url:o,completeUrl:i}=await B5(r),s=Date.now()+n.expires_in*1000;return await rl(e,async(c)=>{await N5(vq(c),{clientId:r,device:n,expiresAt:s})}),{url:o,completeUrl:i,userCode:n.user_code,expiresAt:new Date(s).toISOString()}}async function K5(e,t,r,n=fetch){let o=Math.min(Date.now()+t.expires_in*1000,Date.now()+r),i=t.interval*1000;while(Date.now()+i<o){await Bun.sleep(i);try{let s=await xA(n,"authenticate",{client_id:e,grant_type:"urn:ietf:params:oauth:grant-type:device_code",device_code:t.device_code},gA);return{clientId:e,...s}}catch(s){if(s instanceof xy){if(s.code==="authorization_pending")continue;if(s.code==="slow_down"||s.status===429||s.status>=500){i+=5000;continue}if(s.code==="expired_token")break;if(s.code==="access_denied")throw Error("Sign-in was declined.",{cause:s})}if(s instanceof Error&&s.name==="TimeoutError"){i*=2;continue}throw s}}throw Error("Sign-in is still pending. Run `pnio auth complete` to keep waiting, or `pnio auth login` to start over.")}async function SA(e,{timeoutMs:t=600000}={}){return rl(e,async(r)=>{let n=vq(r),o=await $5(n);if(!o)throw Error("No sign-in is pending. Run `pnio auth login`.");if(o.expiresAt<=Date.now())throw await Fa(n,{force:!0}),Error("Sign-in expired. Run `pnio auth login` again.");let i=await K5(o.clientId,o.device,Math.min(t,o.expiresAt-Date.now())).catch(async(s)=>{throw await Fa(n,{force:!0}),s});return await wA(e,"POST",i.access_token),await IA(r,i),await Fa(n,{force:!0}),i.access_token})}async function $5(e){let t=Bun.file(e);if(!await t.exists())return;return no(F5)(await t.json())}async function bA(e){let t=Bun.file(e);if(!await t.exists())return;return no(L5)(await t.json())}async function IA(e,t){let r=`${e}.${crypto.randomUUID()}.tmp`;try{await Eq(r,JSON.stringify(t),{mode:384,flag:"wx"}),await wq(r,e)}finally{await Fa(r,{force:!0})}}async function rl(e,t){let{dir:r,file:n}=D5(e);await R5(r,{recursive:!0,mode:448});let o=await kq.default.lock(n,{realpath:!1,retries:{retries:20,minTimeout:100,maxTimeout:1000}});try{return await t(n)}finally{await o()}}async function wA(e,t,r){let n=await fetch(`${e}${q$}`,{method:t,headers:r?{Authorization:`Bearer ${r}`}:{},redirect:"error",signal:AbortSignal.timeout(15000)});if(!n.ok)throw Error(`PubNio sign-in request failed (HTTP ${n.status}).`);return n}async function Tq(e,t){let{exp:r}=Xk(t.access_token);if(r&&r*1000>Date.now()+30000)return t.access_token;try{let n=await xA(fetch,"authenticate",{client_id:t.clientId,grant_type:"refresh_token",refresh_token:t.refresh_token},gA);return await IA(e,{...t,...n}),n.access_token}catch(n){if(!(n instanceof xy&&n.code==="invalid_grant"))throw n;await Fa(e,{force:!0});return}}async function Oq(e){return rl(e,async(t)=>{let r=await bA(t),n=r&&await Tq(t,r);if(!n||!r)throw Error(M5);return{token:n,workspaceId:r.workspaceId}})}async function Pq(e,t,r){await rl(e,async(n)=>{let o=await bA(n);if(o?.access_token!==t)throw Error("The CLI session changed. Run the workspace command again.");await IA(n,{...o,workspaceId:r})})}async function Rq(e){return rl(e,async(t)=>{let r=await bA(t),n=r&&await Tq(t,r);if(n)await wA(e,"DELETE",n);await Fa(t,{force:!0})})}function Ei(){let e=URL.parse(process.env.PUBNIO_BASE_URL??"https://pubnio.com");if(!e||e.username||e.password||e.pathname!=="/"||e.search||e.hash||e.protocol!=="https:"&&!(e.protocol==="http:"&&["localhost","127.0.0.1","[::1]"].includes(e.hostname)))throw new Le("PUBNIO_BASE_URL must be an HTTPS origin or a local HTTP origin.");return e.origin}async function _q(e,t){let r=t==="default"?process.env.PUBNIO_API_KEY:void 0;if(r!==void 0&&!Pb.test(r))throw new Le("PUBNIO_API_KEY is not a valid PubNio API key.");let n=r===void 0?await Oq(e):void 0;return{apiKey:r,session:n}}async function fo(e=Ei(),t="default"){let{apiKey:r,session:n}=await _q(e,t),o=Ea({baseUrl:e,clientName:"cli",clientVersion:Vu.version,...r!==void 0?{apiKey:r}:{accessToken:n?.token}});return{...o,selectedWorkspaceId:n?.workspaceId,useWorkspace:async(i)=>{let s=await o.workspaces.get(i);if(n)await Pq(e,n.token,s.id);return s}}}async function Q(e=Ei(),t="default"){let{apiKey:r,session:n}=await _q(e,t);return{...M$({baseUrl:e,clientName:"cli",clientVersion:Vu.version,...r!==void 0?{apiKey:r}:{accessToken:n?.token}}),selectedWorkspaceId:n?.workspaceId}}async function J(e,t,r){let n=t??process.env.PUBNIO_WORKSPACE_ID??e.selectedWorkspaceId??r;if(n!==void 0){let i=ts(ce)(n);if(i._tag==="None")throw new Le("Expected a workspace UUID.");return i.value}let{workspaces:o}=await e.workspaces.list();if(o.length!==1)throw new Le("Select a workspace with `pnio workspaces use <id>` or pass --workspace. Run `pnio workspaces list` to see your workspaces.");return o[0].id}async function Ne(e,{origin:t,auth:r}={}){let n=await fo(t,r);return n.workspace(await J(n,e))}var Uq=[T("list-accounts",{workspace:M,state:we("state",["available","selected"]).pipe(E),cursor:C("cursor").pipe(E),limit:Ue("limit").pipe(E)},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,Hw({client:t.runtime.client,query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId),...O(e.state)?{state:f(e.state)}:{},...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(P("List available and selected ad accounts")),T("connect-account",{workspaceId:C("workspace-id").pipe(ue(a.check(D()))),provider:we("provider",["meta_ads","google_ads","reddit_ads","pinterest_ads","tiktok_ads","linkedin_ads","snapchat_ads","amazon_ads","openai_ads"]),accountId:C("account-id").pipe(ue(a.check(D()))).pipe(E)},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,Vw({client:t.runtime.client,body:{workspaceId:e.workspaceId,provider:e.provider,...O(e.accountId)?{accountId:f(e.accountId)}:{}},...t.runtime.transport()}))})).pipe(P("Start an ad account OAuth connection")),T("connect-api-key-account",{workspaceId:C("workspace-id").pipe(ue(a.check(D()))),provider:we("provider",["openai_ads"]),apiKey:C("api-key"),accountId:C("account-id").pipe(ue(a.check(D()))).pipe(E),profileId:C("profile-id").pipe(ue(a.check(D()))).pipe(E)},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,Jw({client:t.runtime.client,body:{workspaceId:e.workspaceId,provider:e.provider,apiKey:e.apiKey,...O(e.accountId)?{accountId:f(e.accountId)}:{},...O(e.profileId)?{profileId:f(e.profileId)}:{}},...t.runtime.transport()}))})).pipe(P("Connect an ad account with an API key")),T("disconnect-account",{workspace:M,accountId:te("account-id").pipe(ne(a.check(D())))},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,nE({client:t.runtime.client,path:{accountId:e.accountId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(P("Stop syncing an ad account")),T("select-account",{workspace:M,accountId:te("account-id").pipe(ne(a.check(D())))},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,rE({client:t.runtime.client,path:{accountId:e.accountId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(P("Select a discovered ad account")),T("list-campaigns",{workspace:M,accountId:te("account-id").pipe(ne(a.check(D()))),provider:we("provider",["meta_ads","google_ads","reddit_ads","pinterest_ads","tiktok_ads","linkedin_ads","snapchat_ads","amazon_ads","openai_ads"]).pipe(E),status:we("status",["draft","paused","activating","active","pending_review","rejected","completed","archived","unknown"]).pipe(E),managed:we("managed",["provider","pubnio"]).pipe(E),cursor:C("cursor").pipe(E),limit:Ue("limit").pipe(E)},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,oE({client:t.runtime.client,path:{accountId:e.accountId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId),...O(e.provider)?{provider:f(e.provider)}:{},...O(e.status)?{status:f(e.status)}:{},...O(e.managed)?{managed:f(e.managed)}:{},...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(P("List one account's campaigns newest first")),T("list-workspace-campaigns",{workspace:M,accountId:C("account-id").pipe(ue(a.check(D()))).pipe(E),provider:we("provider",["meta_ads","google_ads","reddit_ads","pinterest_ads","tiktok_ads","linkedin_ads","snapchat_ads","amazon_ads","openai_ads"]).pipe(E),status:we("status",["draft","paused","activating","active","pending_review","rejected","completed","archived","unknown"]).pipe(E),managed:we("managed",["provider","pubnio"]).pipe(E),cursor:C("cursor").pipe(E),limit:Ue("limit").pipe(E)},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,Zw({client:t.runtime.client,query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId),...O(e.accountId)?{accountId:f(e.accountId)}:{},...O(e.provider)?{provider:f(e.provider)}:{},...O(e.status)?{status:f(e.status)}:{},...O(e.managed)?{managed:f(e.managed)}:{},...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(P("List campaigns across selected ad accounts")),T("get-tree",{workspace:M,accountId:C("account-id").pipe(ue(a.check(D()))).pipe(E),campaignId:C("campaign-id").pipe(ue(a.check(D()))).pipe(E),cursor:C("cursor").pipe(E),limit:Ue("limit").pipe(E)},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,iE({client:t.runtime.client,query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId),...O(e.accountId)?{accountId:f(e.accountId)}:{},...O(e.campaignId)?{campaignId:f(e.campaignId)}:{},...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(P("Read a campaign, ad group, ad, and creative tree")),T("list-ads",{workspace:M,accountId:C("account-id").pipe(ue(a.check(D()))).pipe(E),campaignId:C("campaign-id").pipe(ue(a.check(D()))).pipe(E),adGroupId:C("ad-group-id").pipe(ue(a.check(D()))).pipe(E),provider:we("provider",["meta_ads","google_ads","reddit_ads","pinterest_ads","tiktok_ads","linkedin_ads","snapchat_ads","amazon_ads","openai_ads"]).pipe(E),status:we("status",["draft","paused","activating","active","pending_review","rejected","completed","archived","unknown"]).pipe(E),from:C("from").pipe(E),to:C("to").pipe(E),cursor:C("cursor").pipe(E),limit:Ue("limit").pipe(E)},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,sE({client:t.runtime.client,query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId),...O(e.accountId)?{accountId:f(e.accountId)}:{},...O(e.campaignId)?{campaignId:f(e.campaignId)}:{},...O(e.adGroupId)?{adGroupId:f(e.adGroupId)}:{},...O(e.provider)?{provider:f(e.provider)}:{},...O(e.status)?{status:f(e.status)}:{},...O(e.from)?{from:f(e.from)}:{},...O(e.to)?{to:f(e.to)}:{},...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(P("List ads with a performance summary")),T("list-ad-groups",{workspace:M,accountId:C("account-id").pipe(ue(a.check(D()))).pipe(E),campaignId:C("campaign-id").pipe(ue(a.check(D()))).pipe(E),provider:we("provider",["meta_ads","google_ads","reddit_ads","pinterest_ads","tiktok_ads","linkedin_ads","snapchat_ads","amazon_ads","openai_ads"]).pipe(E),status:we("status",["draft","paused","activating","active","pending_review","rejected","completed","archived","unknown"]).pipe(E),from:C("from").pipe(E),to:C("to").pipe(E),cursor:C("cursor").pipe(E),limit:Ue("limit").pipe(E)},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,aE({client:t.runtime.client,query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId),...O(e.accountId)?{accountId:f(e.accountId)}:{},...O(e.campaignId)?{campaignId:f(e.campaignId)}:{},...O(e.provider)?{provider:f(e.provider)}:{},...O(e.status)?{status:f(e.status)}:{},...O(e.from)?{from:f(e.from)}:{},...O(e.to)?{to:f(e.to)}:{},...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(P("List ad groups with a performance summary")),T("get-ad",{workspace:M,adId:te("ad-id").pipe(ne(a.check(D())))},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,cE({client:t.runtime.client,path:{adId:e.adId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(P("Read one ad with its creative and metrics")),T("list-creatives",{workspace:M,accountId:C("account-id").pipe(ue(a.check(D()))).pipe(E),adId:C("ad-id").pipe(ue(a.check(D()))).pipe(E),cursor:C("cursor").pipe(E),limit:Ue("limit").pipe(E)},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,pE({client:t.runtime.client,query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId),...O(e.accountId)?{accountId:f(e.accountId)}:{},...O(e.adId)?{adId:f(e.adId)}:{},...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(P("List ad creatives")),T("get-creative",{workspace:M,creativeId:te("creative-id").pipe(ne(a.check(D())))},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,uE({client:t.runtime.client,path:{creativeId:e.creativeId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(P("Read one ad creative")),T("list-insights",{workspace:M,accountId:te("account-id").pipe(ne(a.check(D()))),campaignId:C("campaign-id").pipe(ue(a.check(D()))).pipe(E),adGroupId:C("ad-group-id").pipe(ue(a.check(D()))).pipe(E),adId:C("ad-id").pipe(ue(a.check(D()))).pipe(E),from:C("from").pipe(E),to:C("to").pipe(E),level:we("level",["campaign","ad_group","ad"]).pipe(E),metrics:C("metrics").pipe(Sr(0)),cursor:C("cursor").pipe(E),limit:Ue("limit").pipe(E)},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,fE({client:t.runtime.client,path:{accountId:e.accountId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId),...O(e.campaignId)?{campaignId:f(e.campaignId)}:{},...O(e.adGroupId)?{adGroupId:f(e.adGroupId)}:{},...O(e.adId)?{adId:f(e.adId)}:{},...O(e.from)?{from:f(e.from)}:{},...O(e.to)?{to:f(e.to)}:{},...O(e.level)?{level:f(e.level)}:{},...e.metrics.length?{metrics:[...e.metrics]}:{},...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(P("Read one ad account's daily insights")),T("list-workspace-insights",{workspace:M,accountId:C("account-id").pipe(ue(a.check(D()))).pipe(E),campaignId:C("campaign-id").pipe(ue(a.check(D()))).pipe(E),adGroupId:C("ad-group-id").pipe(ue(a.check(D()))).pipe(E),adId:C("ad-id").pipe(ue(a.check(D()))).pipe(E),from:C("from").pipe(E),to:C("to").pipe(E),level:we("level",["campaign","ad_group","ad"]).pipe(E),metrics:C("metrics").pipe(Sr(0)),cursor:C("cursor").pipe(E),limit:Ue("limit").pipe(E)},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,lE({client:t.runtime.client,query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId),...O(e.accountId)?{accountId:f(e.accountId)}:{},...O(e.campaignId)?{campaignId:f(e.campaignId)}:{},...O(e.adGroupId)?{adGroupId:f(e.adGroupId)}:{},...O(e.adId)?{adId:f(e.adId)}:{},...O(e.from)?{from:f(e.from)}:{},...O(e.to)?{to:f(e.to)}:{},...O(e.level)?{level:f(e.level)}:{},...e.metrics.length?{metrics:[...e.metrics]}:{},...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(P("Read daily insights across selected ad accounts")),T("refresh-insights",{workspace:M,accountId:te("account-id").pipe(ne(a.check(D())))},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,mE({client:t.runtime.client,path:{accountId:e.accountId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(P("Queue an ad insight refresh")),T("activate-campaign",{workspace:M,accountId:te("account-id").pipe(ne(a.check(D()))),campaignId:te("campaign-id").pipe(ne(a.check(D()))),expectedRevision:Ue("expected-revision"),confirmation:we("confirmation",["activate_spend"]),idempotencyKey:rt},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,IE({client:t.runtime.client,path:{accountId:e.accountId,campaignId:e.campaignId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{expectedRevision:e.expectedRevision,confirmation:e.confirmation},headers:{"idempotency-key":f(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()}))})).pipe(P("Activate one paused boost campaign")),T("pause-campaign",{workspace:M,accountId:te("account-id").pipe(ne(a.check(D()))),campaignId:te("campaign-id").pipe(ne(a.check(D()))),expectedRevision:Ue("expected-revision"),idempotencyKey:rt},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,wE({client:t.runtime.client,path:{accountId:e.accountId,campaignId:e.campaignId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{expectedRevision:e.expectedRevision},headers:{"idempotency-key":f(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()}))})).pipe(P("Pause one campaign")),T("archive-campaign",{workspace:M,accountId:te("account-id").pipe(ne(a.check(D()))),campaignId:te("campaign-id").pipe(ne(a.check(D()))),expectedRevision:Ue("expected-revision"),idempotencyKey:rt},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,EE({client:t.runtime.client,path:{accountId:e.accountId,campaignId:e.campaignId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{expectedRevision:e.expectedRevision},headers:{"idempotency-key":f(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()}))})).pipe(P("Archive one campaign")),T("duplicate-campaign",{workspace:M,accountId:te("account-id").pipe(ne(a.check(D()))),campaignId:te("campaign-id").pipe(ne(a.check(D()))),name:C("name").pipe(E),idempotencyKey:rt},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,kE({client:t.runtime.client,path:{accountId:e.accountId,campaignId:e.campaignId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{...O(e.name)?{name:f(e.name)}:{}},headers:{"idempotency-key":f(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()}))})).pipe(P("Duplicate a campaign tree as paused")),T("create-ad-group",{workspace:M,accountId:te("account-id").pipe(ne(a.check(D()))),campaignId:te("campaign-id").pipe(ne(a.check(D()))),name:C("name"),idempotencyKey:rt,file:C("file").pipe(E,Ce("Read the body JSON from a file or stdin with -."))},(e)=>R(async()=>{let t=await Q(),r=f(e.file),n=r===void 0?{name:e.name}:await It(r);return t.runtime.decode(j,TE({client:t.runtime.client,path:{accountId:e.accountId,campaignId:e.campaignId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},body:n,headers:{"idempotency-key":f(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()}))})).pipe(P("Create a paused ad group under a campaign")),T("create-creative",{workspace:M,accountId:te("account-id").pipe(ne(a.check(D()))),actorAccountId:C("actor-account-id").pipe(ue(a.check(D()))),mediaId:C("media-id").pipe(ue(a.check(D()))),headline:C("headline").pipe(E),body:C("body").pipe(E),callToAction:C("call-to-action").pipe(E),destinationUrl:C("destination-url"),idempotencyKey:rt,file:C("file").pipe(E,Ce("Read the body JSON from a file or stdin with -."))},(e)=>R(async()=>{let t=await Q(),r=f(e.file),n=r===void 0?{actorAccountId:e.actorAccountId,mediaId:e.mediaId,...O(e.headline)?{headline:f(e.headline)}:{},...O(e.body)?{body:f(e.body)}:{},...O(e.callToAction)?{callToAction:f(e.callToAction)}:{},destinationUrl:e.destinationUrl}:await It(r);return t.runtime.decode(j,dE({client:t.runtime.client,path:{accountId:e.accountId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},body:n,headers:{"idempotency-key":f(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()}))})).pipe(P("Create a paused provider creative")),T("set-campaign-budget",{workspace:M,accountId:te("account-id").pipe(ne(a.check(D()))),campaignId:te("campaign-id").pipe(ne(a.check(D()))),expectedRevision:Ue("expected-revision"),idempotencyKey:rt,file:C("file").pipe(E,Ce("Read the body JSON from a file or stdin with -."))},(e)=>R(async()=>{let t=await Q(),r=f(e.file),n=r===void 0?{expectedRevision:e.expectedRevision}:await It(r);return t.runtime.decode(j,AE({client:t.runtime.client,path:{accountId:e.accountId,campaignId:e.campaignId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},body:n,headers:{"idempotency-key":f(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()}))})).pipe(P("Update a campaign budget")),T("set-ad-group-budget",{workspace:M,accountId:te("account-id").pipe(ne(a.check(D()))),adGroupId:te("ad-group-id").pipe(ne(a.check(D()))),expectedRevision:Ue("expected-revision"),idempotencyKey:rt,file:C("file").pipe(E,Ce("Read the body JSON from a file or stdin with -."))},(e)=>R(async()=>{let t=await Q(),r=f(e.file),n=r===void 0?{expectedRevision:e.expectedRevision}:await It(r);return t.runtime.decode(j,vE({client:t.runtime.client,path:{accountId:e.accountId,adGroupId:e.adGroupId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},body:n,headers:{"idempotency-key":f(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()}))})).pipe(P("Update an ad group budget")),T("set-ad-group-status",{workspace:M,accountId:te("account-id").pipe(ne(a.check(D()))),adGroupId:te("ad-group-id").pipe(ne(a.check(D()))),status:we("status",["active","paused","archived"]),expectedRevision:Ue("expected-revision"),idempotencyKey:rt},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,CE({client:t.runtime.client,path:{accountId:e.accountId,adGroupId:e.adGroupId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{status:e.status,expectedRevision:e.expectedRevision},headers:{"idempotency-key":f(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()}))})).pipe(P("Pause, resume, or archive an ad group")),T("set-ad-status",{workspace:M,accountId:te("account-id").pipe(ne(a.check(D()))),adId:te("ad-id").pipe(ne(a.check(D()))),status:we("status",["active","paused","archived"]),expectedRevision:Ue("expected-revision"),idempotencyKey:rt},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,PE({client:t.runtime.client,path:{accountId:e.accountId,adId:e.adId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{status:e.status,expectedRevision:e.expectedRevision},headers:{"idempotency-key":f(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()}))})).pipe(P("Pause, resume, or archive an ad")),T("attach-ad",{workspace:M,accountId:te("account-id").pipe(ne(a.check(D()))),adGroupId:te("ad-group-id").pipe(ne(a.check(D()))),name:C("name"),creativeId:C("creative-id").pipe(ue(a.check(D()))).pipe(E),idempotencyKey:rt,file:C("file").pipe(E,Ce("Read the body JSON from a file or stdin with -."))},(e)=>R(async()=>{let t=await Q(),r=f(e.file),n=r===void 0?{name:e.name,...O(e.creativeId)?{creativeId:f(e.creativeId)}:{}}:await It(r);return t.runtime.decode(j,OE({client:t.runtime.client,path:{accountId:e.accountId,adGroupId:e.adGroupId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},body:n,headers:{"idempotency-key":f(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()}))})).pipe(P("Attach a paused ad to an existing ad group")),T("create-boost",{workspace:M,accountId:te("account-id").pipe(ne(a.check(D()))),postId:C("post-id").pipe(ue(a.check(D()))),postTargetId:C("post-target-id").pipe(ue(a.check(D()))).pipe(E),actorAccountId:C("actor-account-id").pipe(ue(a.check(D()))).pipe(E),idempotencyKey:rt,file:C("file").pipe(E,Ce("Read the body JSON from a file or stdin with -."))},(e)=>R(async()=>{let t=await Q(),r=f(e.file),n=r===void 0?{postId:e.postId,...O(e.postTargetId)?{postTargetId:f(e.postTargetId)}:{},...O(e.actorAccountId)?{actorAccountId:f(e.actorAccountId)}:{}}:await It(r);return t.runtime.decode(j,bE({client:t.runtime.client,path:{accountId:e.accountId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},body:n,headers:{"idempotency-key":f(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()}))})).pipe(P("Create a paused Facebook Page post boost")),T("validate-boost",{workspace:M,accountId:te("account-id").pipe(ne(a.check(D()))),postId:C("post-id").pipe(ue(a.check(D()))),postTargetId:C("post-target-id").pipe(ue(a.check(D()))).pipe(E),actorAccountId:C("actor-account-id").pipe(ue(a.check(D()))).pipe(E),file:C("file").pipe(E,Ce("Read the body JSON from a file or stdin with -."))},(e)=>R(async()=>{let t=await Q(),r=f(e.file),n=r===void 0?{postId:e.postId,...O(e.postTargetId)?{postTargetId:f(e.postTargetId)}:{},...O(e.actorAccountId)?{actorAccountId:f(e.actorAccountId)}:{}}:await It(r);return t.runtime.decode(j,SE({client:t.runtime.client,path:{accountId:e.accountId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},body:n,...t.runtime.transport()}))})).pipe(P("Validate a Facebook Page post boost")),T("validate-campaign-plan",{workspace:M,name:C("name"),objective:we("objective",["awareness","traffic","engagement","leads","sales","app_promotion","video_views","reach","conversions","unknown"]),file:C("file").pipe(E,Ce("Read the body JSON from a file or stdin with -."))},(e)=>R(async()=>{let t=await Q(),r=f(e.file),n=r===void 0?{name:e.name,objective:e.objective}:await It(r);return t.runtime.decode(j,Yw({client:t.runtime.client,query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},body:n,...t.runtime.transport()}))})).pipe(P("Validate a unified campaign plan")),T("create-campaign-plan",{workspace:M,name:C("name"),objective:we("objective",["awareness","traffic","engagement","leads","sales","app_promotion","video_views","reach","conversions","unknown"]),idempotencyKey:rt,file:C("file").pipe(E,Ce("Read the body JSON from a file or stdin with -."))},(e)=>R(async()=>{let t=await Q(),r=f(e.file),n=r===void 0?{name:e.name,objective:e.objective}:await It(r);return t.runtime.decode(j,Xw({client:t.runtime.client,query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},body:n,headers:{"idempotency-key":f(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()}))})).pipe(P("Create a paused campaign plan")),T("get-campaign-plan",{workspace:M,planId:te("plan-id").pipe(ne(a.check(D())))},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,tE({client:t.runtime.client,path:{planId:e.planId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(P("Read a campaign plan and its target operations")),T("list-campaign-plans",{workspace:M,status:we("status",["queued","creating","partial","succeeded","failed","unresolved"]).pipe(E),cursor:C("cursor").pipe(E),limit:Ue("limit").pipe(E)},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,eE({client:t.runtime.client,query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId),...O(e.status)?{status:f(e.status)}:{},...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(P("List campaign plans")),T("get-operation",{workspace:M,accountId:te("account-id").pipe(ne(a.check(D()))),operationId:te("operation-id").pipe(ne(a.check(D())))},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,xE({client:t.runtime.client,path:{accountId:e.accountId,operationId:e.operationId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(P("Read one ad operation")),T("get-spend-policy",{workspace:M,accountId:te("account-id").pipe(ne(a.check(D())))},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,hE({client:t.runtime.client,path:{accountId:e.accountId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(P("Read an ad account's spend policy")),T("update-spend-policy",{workspace:M,accountId:te("account-id").pipe(ne(a.check(D()))),expectedRevision:Ue("expected-revision"),file:C("file").pipe(E,Ce("Read the body JSON from a file or stdin with -."))},(e)=>R(async()=>{let t=await Q(),r=f(e.file),n=r===void 0?{expectedRevision:e.expectedRevision}:await It(r);return t.runtime.decode(j,yE({client:t.runtime.client,path:{accountId:e.accountId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},body:n,...t.runtime.transport()}))})).pipe(P("Replace an ad account's spend policy")),T("set-kill-switch",{workspace:M,accountId:te("account-id").pipe(ne(a.check(D()))),active:ft("active").pipe(Xe(!1)),reason:C("reason").pipe(E)},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,gE({client:t.runtime.client,path:{accountId:e.accountId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{active:e.active,...O(e.reason)?{reason:f(e.reason)}:{}},...t.runtime.transport()}))})).pipe(P("Set or clear an ad account kill switch"))];var Dq=T("ads").pipe(P("Read and manage ad accounts, campaigns, and boosts."),Je(Uq));var Lq=[T("accounts").pipe(P(""),Je([T("list",{workspace:M,accountId:C("account-id").pipe(Sr(0)),platform:we("platform",["bluesky","facebook","instagram","linkedin","pinterest","reddit","snapchat","tiktok","threads","x","youtube","google_business","meta_ads","google_ads","reddit_ads","pinterest_ads","tiktok_ads","linkedin_ads","snapchat_ads","amazon_ads","openai_ads"]).pipe(E),from:C("from").pipe(E),to:C("to").pipe(E),timezone:C("timezone").pipe(E),granularity:we("granularity",["day","total"]).pipe(E),metrics:C("metrics").pipe(Sr(0)),cursor:C("cursor").pipe(E),limit:Ue("limit").pipe(E)},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,gw({client:t.runtime.client,path:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},query:{...e.accountId.length?{accountId:[...e.accountId]}:{},...O(e.platform)?{platform:f(e.platform)}:{},...O(e.from)?{from:f(e.from)}:{},...O(e.to)?{to:f(e.to)}:{},...O(e.timezone)?{timezone:f(e.timezone)}:{},...O(e.granularity)?{granularity:f(e.granularity)}:{},...e.metrics.length?{metrics:[...e.metrics]}:{},...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(P("List account analytics summaries")),T("get",{workspace:M,accountId:te("account-id").pipe(ne(a.check(D()))),from:C("from").pipe(E),to:C("to").pipe(E),timezone:C("timezone").pipe(E),granularity:we("granularity",["day","total"]).pipe(E),metrics:C("metrics").pipe(Sr(0))},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,xw({client:t.runtime.client,path:{accountId:e.accountId,workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},query:{...O(e.from)?{from:f(e.from)}:{},...O(e.to)?{to:f(e.to)}:{},...O(e.timezone)?{timezone:f(e.timezone)}:{},...O(e.granularity)?{granularity:f(e.granularity)}:{},...e.metrics.length?{metrics:[...e.metrics]}:{}},...t.runtime.transport()}))})).pipe(P("Read one account's analytics"))])),T("posts").pipe(P(""),Je([T("get",{workspace:M,postId:te("post-id").pipe(ne(a.check(D()))),targetId:C("target-id").pipe(ue(a.check(D()))).pipe(E),from:C("from").pipe(E),to:C("to").pipe(E),timezone:C("timezone").pipe(E),granularity:we("granularity",["day","total"]).pipe(E),metrics:C("metrics").pipe(Sr(0))},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,hw({client:t.runtime.client,path:{postId:e.postId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId),...O(e.targetId)?{targetId:f(e.targetId)}:{},...O(e.from)?{from:f(e.from)}:{},...O(e.to)?{to:f(e.to)}:{},...O(e.timezone)?{timezone:f(e.timezone)}:{},...O(e.granularity)?{granularity:f(e.granularity)}:{},...e.metrics.length?{metrics:[...e.metrics]}:{}},...t.runtime.transport()}))})).pipe(P("Read target-scoped post analytics totals")),T("series",{workspace:M,postId:te("post-id").pipe(ne(a.check(D()))),targetId:C("target-id").pipe(ue(a.check(D()))).pipe(E),from:C("from").pipe(E),to:C("to").pipe(E),timezone:C("timezone").pipe(E),granularity:we("granularity",["day","total"]).pipe(E),metrics:C("metrics").pipe(Sr(0))},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,yw({client:t.runtime.client,path:{postId:e.postId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId),...O(e.targetId)?{targetId:f(e.targetId)}:{},...O(e.from)?{from:f(e.from)}:{},...O(e.to)?{to:f(e.to)}:{},...O(e.timezone)?{timezone:f(e.timezone)}:{},...O(e.granularity)?{granularity:f(e.granularity)}:{},...e.metrics.length?{metrics:[...e.metrics]}:{}},...t.runtime.transport()}))})).pipe(P("Read daily post analytics series"))])),T("capabilities").pipe(P(""),Je([T("get",{workspace:M},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,Sw({client:t.runtime.client,path:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(P("Read the analytics metric catalog and provider support"))])),T("refreshes").pipe(P(""),Je([T("create",{workspaceId:C("workspace-id").pipe(ue(a.check(D()))),postId:C("post-id").pipe(ue(a.check(D()))).pipe(E),targetId:C("target-id").pipe(ue(a.check(D()))).pipe(E),metrics:we("metrics",["impressions","reach","views","likes","comments","shares","saves","clicks","link_clicks","profile_visits","page_views","follows","followers","follower_gained","follower_lost","watch_time_ms","avg_watch_time_ms","completion_rate","engagement","engagement_rate"]).pipe(Sr(0))},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,bw({client:t.runtime.client,body:{workspaceId:e.workspaceId,...O(e.postId)?{postId:f(e.postId)}:{},...O(e.targetId)?{targetId:f(e.targetId)}:{},...e.metrics.length?{metrics:[...e.metrics]}:{}},...t.runtime.transport()}))})).pipe(P("Queue a priority analytics refresh")),T("get",{workspace:M,refreshId:te("refresh-id").pipe(ne(a.check(D())))},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,Iw({client:t.runtime.client,path:{refreshId:e.refreshId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(P("Read an analytics refresh status"))]))];var Mq=T("analytics").pipe(P("Read post, account, and refresh analytics."),Je(Lq));var Fq=[T("list",{workspace:M,cursor:C("cursor").pipe(E),limit:Ue("limit").pipe(E)},(e)=>R(async()=>{let t=await Q(void 0,"human");return t.runtime.decode(j,KI({client:t.runtime.client,path:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},query:{...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(P("List workspace API keys")),T("create",{workspace:M,name:C("name"),scopes:we("scope",["read","publish","engage","ads_read","ads_manage"]).pipe(Sr(0)),expiresAt:C("expires-at").pipe(E)},(e)=>R(async()=>{let t=await Q(void 0,"human");return t.runtime.decode(j,$I({client:t.runtime.client,path:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{name:e.name,...e.scopes.length?{scopes:[...e.scopes]}:{},...O(e.expiresAt)?{expiresAt:f(e.expiresAt)}:{}},...t.runtime.transport()}))})).pipe(P("Create a workspace API key")),T("get",{workspace:M,keyId:te("key-id").pipe(ne(a.check(D())))},(e)=>R(async()=>{let t=await Q(void 0,"human");return t.runtime.decode(j,WI({client:t.runtime.client,path:{keyId:e.keyId,workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(P("Read API key metadata")),T("update",{workspace:M,keyId:te("key-id").pipe(ne(a.check(D()))),name:C("name").pipe(E),scopes:we("scope",["read","publish","engage","ads_read","ads_manage"]).pipe(Sr(0))},(e)=>R(async()=>{let t=await Q(void 0,"human");return t.runtime.decode(j,GI({client:t.runtime.client,path:{keyId:e.keyId,workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{...O(e.name)?{name:f(e.name)}:{},...e.scopes.length?{scopes:[...e.scopes]}:{}},...t.runtime.transport()}))})).pipe(P("Rename an API key or change its access")),T("revoke",{workspace:M,keyId:te("key-id").pipe(ne(a.check(D())))},(e)=>R(async()=>{let t=await Q(void 0,"human");return t.runtime.decode(j,qI({client:t.runtime.client,path:{keyId:e.keyId,workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(P("Revoke a workspace API key"))];var Nq=T("api-keys").pipe(P("Manage workspace API keys as a signed-in owner."),Je(Fq));var Bq=[T("list",{workspace:M,action:we("action",["workspace.updated","workspace.archived","workspace.member.role_updated","workspace.member.removed","workspace.invite.created","workspace.invite.resent","workspace.invite.revoked","workspace.invite.accepted","workspace.invite.declined","api_key.created","api_key.updated","api_key.revoked","webhook.endpoint.created","webhook.endpoint.updated","webhook.endpoint.deleted","webhook.delivery.replayed","account.connected","account.reconnected","account.disconnected","account.enabled","account.disabled","account.moved","profile.created","profile.updated","profile.archived","queue.created","queue.updated","queue.paused","queue.resumed","queue.archived","queue.slots.replaced","queue.skip.created","queue.skip.deleted","queue.blackout.created","queue.blackout.deleted","billing.subscription.updated","billing.credit.topped_up","billing.spend_controls.updated"]).pipe(E),targetKind:we("target-kind",["workspace","workspace_member","workspace_invite","workspace_profile","api_key","webhook_endpoint","webhook_delivery","integration_connection","provider_account","schedule_queue","schedule_queue_skip","schedule_queue_blackout","workspace_billing"]).pipe(E),targetId:C("target-id").pipe(ue(a.check(D()))).pipe(E),actorType:we("actor-type",["user","api_key"]).pipe(E),actorId:C("actor-id").pipe(ue(a.check(D()))).pipe(E),profileId:C("profile-id").pipe(ue(a.check(D()))).pipe(E),from:C("from").pipe(E),to:C("to").pipe(E),cursor:C("cursor").pipe(E),limit:Ue("limit").pipe(E)},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,RE({client:t.runtime.client,path:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},query:{...O(e.action)?{action:f(e.action)}:{},...O(e.targetKind)?{targetKind:f(e.targetKind)}:{},...O(e.targetId)?{targetId:f(e.targetId)}:{},...O(e.actorType)?{actorType:f(e.actorType)}:{},...O(e.actorId)?{actorId:f(e.actorId)}:{},...O(e.profileId)?{profileId:f(e.profileId)}:{},...O(e.from)?{from:f(e.from)}:{},...O(e.to)?{to:f(e.to)}:{},...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(P("List workspace audit events")),T("get",{workspace:M,eventId:te("event-id").pipe(ne(a.check(D())))},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,_E({client:t.runtime.client,path:{eventId:e.eventId,workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(P("Read one audit event")),T("actions").pipe(P(""),Je([T("list",{},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,VE({client:t.runtime.client,...t.runtime.transport()}))})).pipe(P("List documented audit actions"))]))];var Kq=T("audit").pipe(P("Read the workspace audit history."),Je(Bq));var $q=Ue("timeout").pipe(Xe(600),Ce("Maximum seconds to wait for sign-in.")),q5=T("login",{browser:Ju,timeout:$q,noWait:ft("no-wait").pipe(Xe(!1),Ce("Print the verification URL and code, then exit. Finish with `pnio auth complete`."))},(e)=>R(async()=>{let t=Ei(),r=await Cq(t);if(console.error(`Open ${r.url} and confirm code ${r.userCode}.`),e.browser)iy(r.completeUrl);if(e.noWait)return r;let n=await SA(t,{timeoutMs:e.timeout*1000});return Ea({baseUrl:t,accessToken:n}).me.get()})).pipe(P("Sign in with a WorkOS device code, or hand off with --no-wait.")),W5=T("complete",{timeout:$q},(e)=>R(async()=>{let t=Ei(),r=await SA(t,{timeoutMs:e.timeout*1000});return Ea({baseUrl:t,accessToken:r}).me.get()})).pipe(P("Finish a sign-in started with `pnio auth login --no-wait`.")),G5=T("status",{},()=>R(async()=>(await fo(void 0,"human")).me.get())).pipe(P("Show the current PubNio account.")),z5=T("logout",{},()=>R(async()=>(await Rq(Ei()),{signedOut:!0}))).pipe(P("Revoke the CLI session and clear local credentials.")),qq=T("auth").pipe(P("Manage your CLI session."),Je([q5,W5,G5,z5]));var Wq=[T("status",{workspace:M},(e)=>R(async()=>{let t=await Q(void 0,"human");return t.runtime.decode(j,qE({client:t.runtime.client,path:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(P("Get workspace billing status")),T("usage",{workspace:M,from:C("from").pipe(E),to:C("to").pipe(E),meter:we("meter",["confirmed_publish","x_passthrough","managed_ad","inbox_reply","automation_run"]).pipe(E),provider:we("provider",["bluesky","facebook","instagram","linkedin","pinterest","reddit","snapchat","tiktok","threads","x","youtube","google_business"]).pipe(E)},(e)=>R(async()=>{let t=await Q(void 0,"human");return t.runtime.decode(j,WE({client:t.runtime.client,path:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},query:{...O(e.from)?{from:f(e.from)}:{},...O(e.to)?{to:f(e.to)}:{},...O(e.meter)?{meter:f(e.meter)}:{},...O(e.provider)?{provider:f(e.provider)}:{}},...t.runtime.transport()}))})).pipe(P("Get workspace daily usage summary")),T("ledger",{workspace:M,kind:we("kind",["top_up","auto_top_up","overage_debit","x_passthrough_debit","refund","adjustment"]).pipe(E),from:C("from").pipe(E),to:C("to").pipe(E),cursor:C("cursor").pipe(E),limit:Ue("limit").pipe(E)},(e)=>R(async()=>{let t=await Q(void 0,"human");return t.runtime.decode(j,GE({client:t.runtime.client,path:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},query:{...O(e.kind)?{kind:f(e.kind)}:{},...O(e.from)?{from:f(e.from)}:{},...O(e.to)?{to:f(e.to)}:{},...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(P("List workspace prepaid credit ledger")),T("plans",{},(e)=>R(async()=>{let t=await Q(void 0,"human");return t.runtime.decode(j,HE({client:t.runtime.client,...t.runtime.transport()}))})).pipe(P("List public billing plans")),T("top-up",{workspace:M,idempotencyKey:rt,file:C("file").pipe(E,Ce("Read the body JSON from a file or stdin with -."))},(e)=>R(async()=>{let t=await Q(void 0,"human"),r=f(e.file),n=r===void 0?{}:await It(r);return t.runtime.decode(j,zE({client:t.runtime.client,path:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},body:n,headers:{"idempotency-key":f(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()}))})).pipe(P("Create a hosted checkout session for a plan upgrade or credit top-up")),T("portal",{workspace:M,returnUrl:C("return-url").pipe(E)},(e)=>R(async()=>{let t=await Q(void 0,"human");return t.runtime.decode(j,jE({client:t.runtime.client,path:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{...O(e.returnUrl)?{returnUrl:f(e.returnUrl)}:{}},...t.runtime.transport()}))})).pipe(P("Create a hosted billing portal session")),T("spend-cap",{workspace:M,version:Ue("version"),file:C("file").pipe(E,Ce("Read the body JSON from a file or stdin with -."))},(e)=>R(async()=>{let t=await Q(void 0,"human"),r=f(e.file),n=r===void 0?{version:e.version}:await It(r);return t.runtime.decode(j,QE({client:t.runtime.client,path:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},body:n,...t.runtime.transport()}))})).pipe(P("Update monthly spend cap"))];var Gq=T("billing").pipe(P("Manage workspace billing, usage, and checkout."),Je(Wq));var zq=[T("catalog",{},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,dw({client:t.runtime.client,...t.runtime.transport()}))})).pipe(P("Read the static provider capability catalog")),T("get",{},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,cw({client:t.runtime.client,...t.runtime.transport()}))})).pipe(P("Read the publish capability catalog")),T("list",{workspace:M,profileId:C("profile-id").pipe(ue(a.check(D()))).pipe(E),accountId:C("account-id").pipe(ue(a.check(D()))).pipe(E),capability:we("capability",["publish","read_insights","manage_comments","send_messages","ads_read","ads_write","ads_spend"]).pipe(E)},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,pw({client:t.runtime.client,query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId),...O(e.profileId)?{profileId:f(e.profileId)}:{},...O(e.accountId)?{accountId:f(e.accountId)}:{},...O(e.capability)?{capability:f(e.capability)}:{}},...t.runtime.transport()}))})).pipe(P("List computed capabilities for connected accounts"))];var jq=T("capabilities").pipe(P("Read publishing capabilities, placements, and limits."),Je(zq));var Qq=[T("create",{workspace:M,accountId:C("account-id").pipe(ue(a.check(D()))).pipe(E),provider:we("provider",["bluesky","facebook","instagram","linkedin","pinterest","reddit","snapchat","tiktok","threads","x","youtube","google_business"]).pipe(E),target:C("target"),targetKind:we("target-kind",["post","comment"]).pipe(E),text:C("text"),idempotencyKey:rt},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,b6({client:t.runtime.client,query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{...O(e.accountId)?{accountId:f(e.accountId)}:{},...O(e.provider)?{provider:f(e.provider)}:{},target:e.target,...O(e.targetKind)?{targetKind:f(e.targetKind)}:{},text:e.text},headers:{"idempotency-key":f(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()}))})).pipe(P("Comment on or reply to a provider post"))];var Hq=T("comments").pipe(P("Create comments where a destination supports them."),Je(Qq));var Vq=[T("get",{},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,uw({client:t.runtime.client,...t.runtime.transport()}))})).pipe(P("Read documented API limits"))];var Jq=T("limits").pipe(P("Read workspace publishing limits."),Je(Vq));var Yq=[T("capabilities",{workspace:M,accountId:C("account-id").pipe(ue(a.check(D()))).pipe(E)},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,Fw({client:t.runtime.client,query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId),...O(e.accountId)?{accountId:f(e.accountId)}:{}},...t.runtime.transport()}))})).pipe(P("Read per-account inbox channel capabilities")),T("unread-count",{workspace:M},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,Mw({client:t.runtime.client,query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(P("Count conversations with at least one unread inbound message")),T("conversations").pipe(P(""),Je([T("list",{workspace:M,accountId:C("account-id").pipe(ue(a.check(D()))).pipe(E),provider:we("provider",["bluesky","facebook","instagram","linkedin","pinterest","reddit","snapchat","tiktok","threads","x","youtube","google_business","meta_ads","google_ads","reddit_ads","pinterest_ads","tiktok_ads","linkedin_ads","snapchat_ads","amazon_ads","openai_ads"]).pipe(E),status:we("status",["active","archived"]).pipe(E),folder:we("folder",["inbox","message_request","spam","other"]).pipe(E),unread:we("unread",["true","false"]).pipe(E),search:C("search").pipe(E),cursor:C("cursor").pipe(E),limit:Ue("limit").pipe(E)},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,ww({client:t.runtime.client,query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId),...O(e.accountId)?{accountId:f(e.accountId)}:{},...O(e.provider)?{provider:f(e.provider)}:{},...O(e.status)?{status:f(e.status)}:{},...O(e.folder)?{folder:f(e.folder)}:{},...O(e.unread)?{unread:f(e.unread)}:{},...O(e.search)?{search:f(e.search)}:{},...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(P("List DM conversations newest first")),T("get",{workspace:M,conversationId:te("conversation-id").pipe(ne(a.check(D())))},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,Ew({client:t.runtime.client,path:{conversationId:e.conversationId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(P("Read one conversation and reply window")),T("update",{workspace:M,conversationId:te("conversation-id").pipe(ne(a.check(D()))),status:we("status",["active","archived"]).pipe(E),read:ft("read").pipe(Xe(!1))},(e)=>R(async()=>{let t=await Q();if(!(O(e.status)||e.read))throw new Le("Provide --status or --read.");return t.runtime.decode(j,kw({client:t.runtime.client,path:{conversationId:e.conversationId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{...O(e.status)?{status:f(e.status)}:{},...e.read?{read:!0}:{}},...t.runtime.transport()}))})).pipe(P("Mark read or archive a conversation"))])),T("messages").pipe(P(""),Je([T("list",{workspace:M,conversationId:te("conversation-id").pipe(ne(a.check(D()))),order:we("order",["oldest","newest"]).pipe(E),cursor:C("cursor").pipe(E),limit:Ue("limit").pipe(E)},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,Aw({client:t.runtime.client,path:{conversationId:e.conversationId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId),...O(e.order)?{order:f(e.order)}:{},...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(P("Page messages oldest or newest first")),T("send",{workspace:M,conversationId:te("conversation-id").pipe(ne(a.check(D()))),text:C("text"),idempotencyKey:rt},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,vw({client:t.runtime.client,path:{conversationId:e.conversationId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{text:e.text},headers:{"idempotency-key":f(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()}))})).pipe(P("Send a text reply inside the provider window"))])),T("comments").pipe(P(""),Je([T("list",{workspace:M,accountId:C("account-id").pipe(ue(a.check(D()))).pipe(E),postId:C("post-id").pipe(ue(a.check(D()))).pipe(E),providerPostId:C("provider-post-id").pipe(E),unread:we("unread",["true","false"]).pipe(E),cursor:C("cursor").pipe(E),limit:Ue("limit").pipe(E)},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,Cw({client:t.runtime.client,query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId),...O(e.accountId)?{accountId:f(e.accountId)}:{},...O(e.postId)?{postId:f(e.postId)}:{},...O(e.providerPostId)?{providerPostId:f(e.providerPostId)}:{},...O(e.unread)?{unread:f(e.unread)}:{},...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(P("List comment threads with counts")),T("get",{workspace:M,threadId:te("thread-id").pipe(ne(a.check(D()))),cursor:C("cursor").pipe(E),limit:Ue("limit").pipe(E)},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,Tw({client:t.runtime.client,path:{threadId:e.threadId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId),...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(P("Read a comment thread and its comments")),T("reply",{workspace:M,commentId:te("comment-id").pipe(ne(a.check(D()))),text:C("text"),idempotencyKey:rt},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,Ow({client:t.runtime.client,path:{commentId:e.commentId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{text:e.text},headers:{"idempotency-key":f(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()}))})).pipe(P("Reply to a comment")),T("moderate",{workspace:M,commentId:te("comment-id").pipe(ne(a.check(D()))),hidden:ft("hidden").pipe(Xe(!1)),liked:ft("liked").pipe(Xe(!1))},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,Rw({client:t.runtime.client,path:{commentId:e.commentId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{...e.hidden?{hidden:!0}:{},...e.liked?{liked:!0}:{}},...t.runtime.transport()}))})).pipe(P("Hide, unhide, like, or unlike a comment")),T("delete",{workspace:M,commentId:te("comment-id").pipe(ne(a.check(D())))},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,Pw({client:t.runtime.client,path:{commentId:e.commentId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(P("Delete a comment where the provider supports it"))])),T("mentions").pipe(P(""),Je([T("list",{workspace:M,accountId:C("account-id").pipe(ue(a.check(D()))).pipe(E),provider:we("provider",["bluesky","facebook","instagram","linkedin","pinterest","reddit","snapchat","tiktok","threads","x","youtube","google_business","meta_ads","google_ads","reddit_ads","pinterest_ads","tiktok_ads","linkedin_ads","snapchat_ads","amazon_ads","openai_ads"]).pipe(E),cursor:C("cursor").pipe(E),limit:Ue("limit").pipe(E)},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,_w({client:t.runtime.client,query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId),...O(e.accountId)?{accountId:f(e.accountId)}:{},...O(e.provider)?{provider:f(e.provider)}:{},...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(P("List mentions of a connected account")),T("reply",{workspace:M,mentionId:te("mention-id").pipe(ne(a.check(D()))),text:C("text"),idempotencyKey:rt},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,Uw({client:t.runtime.client,path:{mentionId:e.mentionId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{text:e.text},headers:{"idempotency-key":f(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()}))})).pipe(P("Reply to a mention where supported"))])),T("sync").pipe(P(""),Je([T("start",{workspaceId:C("workspace-id").pipe(ue(a.check(D()))),accountId:C("account-id").pipe(ue(a.check(D()))).pipe(E)},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,Nw({client:t.runtime.client,body:{workspaceId:e.workspaceId,...O(e.accountId)?{accountId:f(e.accountId)}:{}},...t.runtime.transport()}))})).pipe(P("Queue a bounded inbox sync")),T("status",{workspace:M,syncRunId:te("sync-run-id").pipe(ne(a.check(D())))},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,Bw({client:t.runtime.client,path:{syncRunId:e.syncRunId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(P("Read a sync run and current inbox counts"))])),T("attachments").pipe(P(""),Je([T("get",{workspace:M,attachmentId:te("attachment-id").pipe(ne(a.check(D())))},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,Kw({client:t.runtime.client,path:{attachmentId:e.attachmentId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(P("Stream an inbound attachment"))])),T("reviews").pipe(P(""),Je([T("list",{workspace:M,accountId:C("account-id").pipe(ue(a.check(D()))).pipe(E),includeDeleted:we("include-deleted",["true","false"]).pipe(E),cursor:C("cursor").pipe(E),limit:Ue("limit").pipe(E)},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,Dw({client:t.runtime.client,query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId),...O(e.accountId)?{accountId:f(e.accountId)}:{},...O(e.includeDeleted)?{includeDeleted:f(e.includeDeleted)}:{},...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(P("List stored Google Business Profile reviews newest first")),T("get",{workspace:M,reviewId:te("review-id").pipe(ne(a.check(D())))},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,Lw({client:t.runtime.client,path:{reviewId:e.reviewId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(P("Read one stored Google Business Profile review")),T("reply",{workspace:M,reviewId:te("review-id").pipe(ne(a.check(D()))),text:C("text"),idempotencyKey:rt},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,S6({client:t.runtime.client,path:{reviewId:e.reviewId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{text:e.text},headers:{"idempotency-key":f(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()}))})).pipe(P("Reply to a Google Business Profile review"))]))];var Zq=T("inbox").pipe(P("Read and reply from the unified inbox."),Je(Yq));var Xq=[T("get-account",{workspace:M,accountId:te("account-id").pipe(ne(a.check(D()))),includeAdAccounts:we("include-ad-accounts",["true","false"]).pipe(E)},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,tw({client:t.runtime.client,path:{accountId:e.accountId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId),...O(e.includeAdAccounts)?{includeAdAccounts:f(e.includeAdAccounts)}:{}},...t.runtime.transport()}))})).pipe(P("Check account readiness")),T("bluesky-session",{workspace:M,handle:C("handle"),appPassword:C("app-password"),service:C("service").pipe(E),accountId:C("account-id").pipe(ue(a.check(D()))).pipe(E),profileId:C("profile-id").pipe(ue(a.check(D()))).pipe(E)},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,x6({client:t.runtime.client,query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{handle:e.handle,appPassword:e.appPassword,...O(e.service)?{service:f(e.service)}:{},...O(e.accountId)?{accountId:f(e.accountId)}:{},...O(e.profileId)?{profileId:f(e.profileId)}:{}},...t.runtime.transport()}))})).pipe(P("Connect Bluesky with an app password")),T("get-instagram-audio",{workspace:M,accountId:te("account-id").pipe(ne(a.check(D()))),audioId:te("audio-id")},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,rw({client:t.runtime.client,path:{accountId:e.accountId,audioId:e.audioId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(P("Read current Instagram audio metadata and refresh its preview URL")),T("move-account",{workspace:M,accountId:te("account-id").pipe(ne(a.check(D()))),profileId:C("profile-id").pipe(ue(a.check(D())))},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,ew({client:t.runtime.client,path:{accountId:e.accountId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{profileId:e.profileId},...t.runtime.transport()}))})).pipe(P("Move an account to another profile"))];var xp=te("account-id").pipe(ne(xu.fields.accountId)),t1=we("login-method",th.literals).pipe(E),r1=Ue("timeout").pipe(Xe(120),Ce("Maximum seconds to wait for consent."));async function n1(e,t,r){let n=Date.now()+Math.max(0,r)*1000;for(;;){let o=await e.accounts.connectionStatus(t);if(o.status!=="pending")return o;if(Date.now()>=n)return{...o,timedOut:!0};await Bun.sleep(1000)}}function o1(e,t,r){if(new URL(e.url).origin!==t)throw Error("PubNio returned an invalid connection URL.");if(console.error(`Open the URL as the same PubNio user, then check \`pnio integrations wait ${e.attemptId}\`.`),r)iy(e.url);return e}var j5=T("list",{workspace:M},({workspace:e})=>R(async()=>(await Ne(f(e))).accounts.list())).pipe(P("List publishing destinations.")),Q5=T("connect",{provider:O8("provider",xn.literals),workspace:M,browser:Ju,loginMethod:t1,wait:ft("wait").pipe(Xe(!1),Ce("Wait for consent before returning.")),timeout:r1},(e)=>R(async()=>{let t=Ei(),r=await Ne(f(e.workspace),{origin:t}),n=await r.accounts.prepareConnection(e.provider,f(e.loginMethod)),o=o1(n,t,e.browser);if(!e.wait)return o;let i=await n1(r,n.attemptId,e.timeout);if(i.status!=="connected")process.exitCode=1;return{...o,connection:i}})).pipe(P("Connect Facebook, Instagram, or TikTok.")),H5=T("wait",{attempt:te("attempt-id").pipe(ne(Bb.fields.attemptId)),workspace:M,timeout:r1},(e)=>R(async()=>{let t=await Ne(f(e.workspace)),r=await n1(t,e.attempt,e.timeout);if(r.status!=="connected")process.exitCode=1;return r})).pipe(P("Wait for an account connection to finish.")),V5=T("status",{attempt:te("attempt-id").pipe(ne(Bb.fields.attemptId)),workspace:M},({attempt:e,workspace:t})=>R(async()=>(await Ne(f(t))).accounts.connectionStatus(e))).pipe(P("Check whether social account OAuth completed.")),J5=T("health",{account:xp,workspace:M},({account:e,workspace:t})=>R(async()=>(await Ne(f(t))).accounts.get(e))).pipe(P("Check account readiness using the last recorded grant.")),Y5=T("instagram-quota",{account:xp,workspace:M},({account:e,workspace:t})=>R(async()=>(await Ne(f(t))).accounts.instagramPublishingLimit(e))).pipe(P("Read the Instagram account\u2019s current publishing quota.")),Z5=T("instagram-audio",{account:xp,workspace:M,type:we("type",nh.literals).pipe(Xe("music")),query:C("query").pipe(E)},({account:e,workspace:t,type:r,query:n})=>R(async()=>(await Ne(f(t))).accounts.searchInstagramAudio(e,{audioType:r,q:f(n)}))).pipe(P("Search Instagram\u2019s catalog or list trending audio.")),X5=T("instagram-audio-info",{account:xp,workspace:M,audioId:te("audio-id").pipe(ne(ep))},({account:e,workspace:t,audioId:r})=>R(async()=>(await Ne(f(t))).accounts.getInstagramAudio(e,r))).pipe(P("Read current metadata for an Instagram audio track.")),eZ=T("reconnect",{account:xp,workspace:M,browser:Ju,loginMethod:t1},(e)=>R(async()=>{let t=Ei(),r=await Ne(f(e.workspace),{origin:t});return o1(await r.accounts.reconnect(e.account,f(e.loginMethod)),t,e.browser)})).pipe(P("Reauthorize a connected account while keeping its ID.")),tZ=T("disconnect",{connection:te("connection-id").pipe(ne(LD.fields.connectionId)),workspace:M,yes:ft("yes").pipe(Xe(!1))},({connection:e,workspace:t,yes:r})=>R(async()=>{if(!r)throw new Le("Pass --yes to disconnect the grant and disable all accounts using it.");return(await Ne(f(t))).accounts.disconnect(e)})).pipe(P("Remove a grant and disable its accounts."));function e1(e){return T(e,{account:xp,workspace:M},({account:t,workspace:r})=>R(async()=>(await Ne(f(r))).accounts.setEnabled({id:t,enabled:e==="enable"}))).pipe(P(`${e==="enable"?"Enable":"Disable"} a publishing destination.`))}var i1=T("integrations").pipe(P("Connect and select publishing destinations."),Je([j5,Q5,H5,V5,J5,Y5,Z5,X5,eZ,tZ,e1("enable"),e1("disable"),...Xq]));import{writeFile as rZ}from"fs/promises";var s1=[T("status",{workspace:M,mediaId:te("media-id").pipe(ne(a.check(D())))},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,Th({client:t.runtime.client,path:{mediaId:e.mediaId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(P("Get workspace media intake status")),T("get",{workspace:M,mediaId:te("media-id").pipe(ne(a.check(D())))},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,mw({client:t.runtime.client,path:{mediaId:e.mediaId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(P("Get workspace media metadata")),T("list",{workspace:M,cursor:C("cursor").pipe(E),limit:Ue("limit").pipe(E),type:we("type",["image","video","document"]).pipe(E)},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,lw({client:t.runtime.client,query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId),...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{},...O(e.type)?{type:f(e.type)}:{}},...t.runtime.transport()}))})).pipe(P("List ready workspace media")),T("delete",{workspace:M,mediaId:te("media-id").pipe(ne(a.check(D())))},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,fw({client:t.runtime.client,path:{mediaId:e.mediaId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(P("Delete unused workspace media"))];var a1=te("media-id").pipe(ne(yn)),nZ=T("upload",{file:te("file"),workspace:M,mime:we("mime",Zc.literals).pipe(E),key:rt},(e)=>R(async()=>{let t=Bun.file(e.file);if(!await t.exists())throw new Le("Choose an existing media file.");return(await Ne(f(e.workspace))).media.upload(t,{mimeType:f(e.mime),idempotencyKey:f(e.key)})})).pipe(P("Upload an image, video, or document for use in posts.")),oZ=T("import",{url:te("url"),workspace:M,key:rt},(e)=>R(async()=>(await Ne(f(e.workspace))).media.importUrl(e.url,{idempotencyKey:f(e.key)}))).pipe(P("Copy a public or signed HTTPS URL into private workspace media.")),iZ=T("wait",{mediaId:a1,workspace:M,timeoutSeconds:Ue("timeout").pipe(Xe(30),Ce("Maximum seconds to wait for media readiness."))},(e)=>R(async()=>{if(e.timeoutSeconds<0||e.timeoutSeconds>300)throw new Le("Use a timeout between 0 and 300 seconds.");let t=await(await Ne(f(e.workspace))).media.wait(e.mediaId,{timeoutMs:e.timeoutSeconds*1000});if(t.status!=="ready")process.exitCode=1;return t})).pipe(P("Wait for media readiness and return ready, failed, or timeout.")),sZ=T("download",{mediaId:a1,workspace:M,out:C("out")},(e)=>R(async()=>{let t=await(await Ne(f(e.workspace))).media.download(e.mediaId);return await rZ(e.out,new Uint8Array(await t.arrayBuffer()),{flag:"wx"}),{path:e.out,sizeBytes:t.size}})).pipe(P("Save private media to a new local file.")),c1=T("media").pipe(P("Manage workspace media files."),Je([nZ,oZ,...s1,iZ,sZ]));var p1=[T("get",{workspace:M,postId:te("post-id").pipe(ne(a.check(D())))},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,Ww({client:t.runtime.client,path:{postId:e.postId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(P("Read a post or draft")),T("attempts",{workspace:M,postId:te("post-id").pipe(ne(a.check(D()))),targetId:te("target-id").pipe(ne(a.check(D()))),cursor:C("cursor").pipe(E),limit:Ue("limit").pipe(E)},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,zw({client:t.runtime.client,path:{postId:e.postId,targetId:e.targetId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId),...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(P("Read a destination's delivery attempt history")),T("retry",{workspace:M,postId:te("post-id").pipe(ne(a.check(D()))),targetId:te("target-id").pipe(ne(a.check(D()))),expectedAttemptId:C("expected-attempt-id").pipe(ue(a.check(D())))},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,jw({client:t.runtime.client,path:{postId:e.postId,targetId:e.targetId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{expectedAttemptId:e.expectedAttemptId},...t.runtime.transport()}))})).pipe(P("Retry a failed delivery")),T("reconcile",{workspace:M,postId:te("post-id").pipe(ne(a.check(D()))),targetId:te("target-id").pipe(ne(a.check(D()))),expectedAttemptId:C("expected-attempt-id").pipe(ue(a.check(D())))},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,Qw({client:t.runtime.client,path:{postId:e.postId,targetId:e.targetId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{expectedAttemptId:e.expectedAttemptId},...t.runtime.transport()}))})).pipe(P("Recheck a recorded provider receipt")),T("update",{workspace:M,postId:te("post-id").pipe(ne(a.check(D()))),text:C("text").pipe(E),expectedRevision:Ue("revision").pipe(E),file:C("file").pipe(E,Ce("Read the body JSON from a file or stdin with -."))},(e)=>R(async()=>{let t=await Q(),r=f(e.file),n=r===void 0?{...O(e.text)?{text:f(e.text)}:{},...O(e.expectedRevision)?{expectedRevision:f(e.expectedRevision)}:{}}:await It(r);return t.runtime.decode(j,Gw({client:t.runtime.client,path:{postId:e.postId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},body:n,...t.runtime.transport()}))})).pipe(P("Edit a draft")),T("delete",{workspace:M,postId:te("post-id").pipe(ne(a.check(D())))},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,qw({client:t.runtime.client,path:{postId:e.postId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(P("Archive a post or draft"))];var aZ=no(lL,{onExcessProperty:"error"}),Sy=te("post-id").pipe(ne(WU.fields.postId)),cZ=Ue("revision").pipe(ue(ao),Ce("Expected revision from posts get.")),pZ=T("create",{workspace:M,text:C("text").pipe(E,Ce("Post text for the one-call path.")),platform:we("platform",ss).pipe(Sr(0),Ce("Publish to the single ready account for this provider. Repeat for several platforms.")),account:B$,mediaId:C("media-id").pipe(ue(yn),Sr(0),Ce("Attach ready workspace media by ID.")),mediaUrl:C("media-url").pipe(Sr(0),Ce("Attach a public HTTPS media URL.")),schedule:C("schedule").pipe(ue(Rt),E,Ce("Schedule with an ISO time and explicit offset.")),publishNow:ft("publish-now").pipe(Xe(!0),Ce("Publish now when --schedule is absent.")),draft:ft("draft").pipe(Xe(!1),Ce("Save a draft without submitting it.")),file:C("file").pipe(E,Ce("Advanced: read a full Level 2 post JSON document from a file or stdin with -.")),key:rt,queue:C("queue").pipe(ue(Xt),E,Ce("Assign every file-provided destination to this account queue."))},(e)=>R(async()=>{let t=await Ne(f(e.workspace)),r=f(e.key),n=f(e.file),o=f(e.schedule);if(e.draft&&o)throw new Le("Drafts cannot set --schedule until published.");if(n){if(O(e.text)||e.platform.length||e.account.length||e.mediaId.length||e.mediaUrl.length||o&&!e.draft||!e.publishNow&&!e.draft)throw new Le("Use --file alone, or provide --text with --platform or --account.");let c=await aZ(await It(n)).catch(()=>{throw new Le("Post JSON does not match the PubNio API contract.")}),l=f(e.queue);if(l&&e.draft)throw new Le("Drafts cannot be assigned a queue.");if(l&&(c.targets??[]).some((S)=>S.scheduledAt!==void 0||S.queueId!==void 0))throw new Le("Remove per-target schedules or queues when using --queue.");return t.posts.create({...l?{...c,targets:(c.targets??[]).map((S)=>({...S,queueId:l}))}:c,...e.draft?{isDraft:!0}:{},...r?{idempotencyKey:r}:{}})}let i=f(e.text);if(i===void 0)throw new Le("Provide --text or --file.");if(e.draft&&e.platform.length)throw new Le("Drafts select exact --account IDs, not platforms.");if(!e.draft&&O(e.queue))throw new Le("--queue requires --file.");if(!e.draft&&e.platform.length&&e.account.length)throw new Le("Use --platform or --account, not both.");if(!e.draft&&!e.platform.length&&!e.account.length)throw new Le("Provide at least one --platform or --account.");let s=[...e.mediaId.map((c)=>({mediaId:c})),...e.mediaUrl.map((c)=>({url:c}))];if(e.draft)return t.posts.create({text:i,isDraft:!0,...e.account.length?{targets:e.account.map((c)=>({accountId:c}))}:{},...s.length?{media:s}:{}});return t.posts.create({text:i,...e.platform.length?{platforms:[...e.platform]}:{},...e.account.length?{accounts:[...e.account]}:{},...s.length?{media:s}:{},...o?{scheduledAt:o}:{},publishNow:e.publishNow,...r?{idempotencyKey:r}:{}})})).pipe(P("Create and submit a post in one call, or save a draft with --draft.")),dZ=T("list",{workspace:M,...ys,draft:ft("draft").pipe(Xe(!1),Ce("List only drafts. Omit to list posts and drafts.")),deliveryStatus:we("delivery-status",Vc.literals).pipe(E)},(e)=>R(async()=>(await Ne(f(e.workspace))).posts.list({cursor:f(e.cursor),limit:f(e.limit),...e.draft?{isDraft:!0}:{},deliveryStatus:f(e.deliveryStatus)}))).pipe(P("List posts and drafts, and filter their current deliveries.")),uZ=T("validate",{workspace:M,id:Sy},(e)=>R(async()=>{let t=await(await Ne(f(e.workspace))).posts.validate(e.id);if(!t.canPublish)process.exitCode=1;return t})).pipe(P("Validate a saved draft before publishing.")),lZ=T("publish",{id:Sy,workspace:M,revision:cZ,key:rt,at:C("at").pipe(ue(Rt),E),queue:C("queue").pipe(ue(Xt),E),account:K$,placement:we("placement",yr.literals).pipe(E)},(e)=>R(async()=>{let t=f(e.placement),r=f(e.account),n=f(e.at),o=f(e.queue),i=f(e.key);if(t&&!r)throw new Le("Use --placement with --account.");if(n&&o)throw new Le("Use --at or --queue, not both.");let s=await Ne(f(e.workspace));if(o){let l=(await s.posts.get(e.id)).targets.filter((S)=>!r||S.accountId.toLowerCase()===r.toLowerCase());if(!l.length||t&&l.some((S)=>S.placement!==t))throw new Le("No matching destination exists in this post for --queue.");return s.posts.publish(e.id,{expectedRevision:e.revision,idempotencyKey:i,targets:l.map((S)=>({accountId:S.accountId,placement:S.placement,queueId:o}))})}return s.posts.publish(e.id,{expectedRevision:e.revision,scheduledAt:n,idempotencyKey:i,...r&&t?{targets:[{accountId:r,placement:t,scheduledAt:n}]}:r?{accountIds:[r]}:{}})})).pipe(P("Publish a saved draft now or at --at.")),fZ=T("status",{workspace:M,id:Sy},(e)=>R(async()=>(await Ne(f(e.workspace))).posts.status(e.id))).pipe(P("Read delivery outcomes for a post.")),mZ=T("wait",{workspace:M,id:Sy,timeoutSeconds:Ue("timeout").pipe(Xe(60),Ce("Maximum seconds to wait for delivery."))},(e)=>R(async()=>{if(e.timeoutSeconds<0||e.timeoutSeconds>3600)throw new Le("Use a timeout between 0 and 3600 seconds.");let t=await(await Ne(f(e.workspace))).posts.wait(e.id,{timeoutMs:e.timeoutSeconds*1000});if(!t.settled)process.exitCode=1;return t})).pipe(P("Wait for a post to reach a settled delivery outcome."));function EA(e,t){return R(async()=>(await Ne(f(e.workspace))).schedule.change(_U(e.postId),UU(e.targetId),t))}var kA={postId:te("post-id").pipe(ne(Ib.fields.postId)),targetId:te("target-id").pipe(ne(Ib.fields.targetId)),expectedAttemptId:C("attempt").pipe(ue(Wt),Ce("Current attempt ID from posts status.")),workspace:M},hZ=T("reschedule",{...kA,at:C("at").pipe(ue(Rt),E),queue:C("queue").pipe(ue(Xt),E),slot:C("slot").pipe(ue(a.check(D())),E),date:C("date").pipe(ue(bn),E)},(e)=>{let t=f(e.at),r=f(e.queue),n=f(e.slot),o=f(e.date);if(t===void 0===(r===void 0))throw new Le("Use exactly one of --at or --queue.");if(r&&n===void 0!==(o===void 0))throw new Le("Use --slot and --date together to pin a slot.");return EA(e,r?{action:"reschedule",expectedAttemptId:e.expectedAttemptId,queueId:r,...n&&o?{pinned:{slotId:n,occurrenceDate:o}}:{}}:{action:"reschedule",expectedAttemptId:e.expectedAttemptId,scheduledAt:t})}).pipe(P("Move a pending delivery to a queue slot or time.")),yZ=T("cancel",kA,(e)=>EA(e,{action:"cancel",expectedAttemptId:e.expectedAttemptId})).pipe(P("Cancel a delivery before the provider write is reserved.")),gZ=T("publish-now",kA,(e)=>EA(e,{action:"publish_now",expectedAttemptId:e.expectedAttemptId})).pipe(P("Bring a pending delivery forward.")),d1=T("posts").pipe(P("Create and publish posts, save drafts, and manage delivery status."),Je([pZ,dZ,...p1,uZ,lZ,fZ,mZ,hZ,yZ,gZ]));var wn=te("queue-id").pipe(ne(Xt)),by=Ue("version").pipe(Ce("Expected version from the last queue read.")),l1={maxPerDay:Ue("max-per-day").pipe(E),maxPending:Ue("max-pending").pipe(E),minGap:Ue("min-gap").pipe(E),horizon:Ue("horizon-days").pipe(E)},f1={slot:C("slot").pipe(p9(50),Ce("Weekly slot as DAY:HH:mm where 0 is Sunday."))},xZ=no(IL,{onExcessProperty:"error"}),SZ=no(wL,{onExcessProperty:"error"}),bZ=no(EL,{onExcessProperty:"error"}),IZ=no(OL,{onExcessProperty:"error"}),wZ=no(_L,{onExcessProperty:"error"});function m1(e){let t=/^([0-6]):((?:[01]\d|2[0-3]):[0-5]\d)$/.exec(e);if(!t)throw new Le("Use --slot DAY:HH:mm where DAY is 0-6, 0 Sunday.");return{dayOfWeek:Number(t[1]),time:t[2]}}function h1(e){let t=f(e.maxPerDay),r=f(e.maxPending),n=f(e.minGap),o=f(e.horizon);return{...t===void 0?{}:{maxPerDay:t},...r===void 0?{}:{maxPending:r},...n===void 0?{}:{minGapSeconds:n},...o===void 0?{}:{horizonDays:o}}}var EZ=T("list",{workspace:M,account:Zk,...ys},(e)=>R(async()=>(await Ne(f(e.workspace))).queues.list({accountId:f(e.account),cursor:f(e.cursor),limit:f(e.limit)}))).pipe(P("List account schedule queues.")),kZ=T("create",{workspace:M,file:C("file").pipe(E,Ce("Read CreateQueue JSON from a file or stdin with -.")),account:Zk,name:C("name").pipe(E),timezone:C("timezone").pipe(E,Ce("IANA time zone, e.g. America/New_York. Defaults to the workspace default time zone.")),default:ft("default").pipe(E,Ce("Promote the new queue to the account default. The first active queue is always the default.")),...f1,...l1},(e)=>R(async()=>{let t=await Ne(f(e.workspace)),r=f(e.file),n=await xZ(r?await It(r):{accountId:f(e.account),name:f(e.name),...nr(e.timezone)?{}:{timezone:e.timezone.value},slots:e.slot.map(m1),...nr(e.default)?{}:{isDefault:e.default.value},...h1(e)}).catch(()=>{throw new Le("Queue JSON does not match the PubNio API contract.")});return t.queues.create(n)})).pipe(P("Create a weekly queue for an account; the first is the default. Omit --timezone to use the workspace default.")),AZ=T("get",{workspace:M,queueId:wn},(e)=>R(async()=>(await Ne(f(e.workspace))).queues.get(e.queueId))).pipe(P("Read a queue, its slots, and its limits.")),vZ=T("update",{workspace:M,queueId:wn,version:by,file:C("file").pipe(E,Ce("Read UpdateQueue JSON from a file or stdin with -.")),name:C("name").pipe(E),timezone:C("timezone").pipe(E),pause:ft("pause").pipe(Xe(!1)),resume:ft("resume").pipe(Xe(!1)),default:ft("default").pipe(E,Ce("Promote or demote the account default. Demote only after promoting another queue.")),...l1},(e)=>R(async()=>{if(e.pause&&e.resume)throw new Le("Use --pause or --resume, not both.");let t=await Ne(f(e.workspace)),r=f(e.file),n=await SZ(r?await It(r):{expectedVersion:e.version,...nr(e.name)?{}:{name:e.name.value},...nr(e.timezone)?{}:{timezone:e.timezone.value},...e.pause?{paused:!0}:e.resume?{paused:!1}:{},...nr(e.default)?{}:{isDefault:e.default.value},...h1(e)}).catch(()=>{throw new Le("Queue update JSON does not match the PubNio API contract.")});return t.queues.update(e.queueId,n)})).pipe(P("Update limits, name, time zone, default, pause, or resume a queue.")),CZ=T("archive",{workspace:M,queueId:wn,version:by},(e)=>R(async()=>(await Ne(f(e.workspace))).queues.archive(e.queueId,e.version))).pipe(P("Archive a queue and keep queued work.")),TZ=T("slots",{workspace:M,queueId:wn,version:by,file:C("file").pipe(E,Ce("Read ReplaceQueueSlots JSON from a file or stdin.")),...f1},(e)=>R(async()=>{let t=await Ne(f(e.workspace)),r=f(e.file),n=await bZ(r?await It(r):{expectedVersion:e.version,slots:e.slot.map(m1)}).catch(()=>{throw new Le("Queue slot JSON does not match the PubNio API contract.")});return t.queues.replaceSlots(e.queueId,n)})).pipe(P("Replace every weekly queue slot.")),OZ=T("next-slot",{workspace:M,queueId:wn,after:C("after").pipe(E)},(e)=>R(async()=>(await Ne(f(e.workspace))).queues.nextSlot(e.queueId,f(e.after)))).pipe(P("Read the next free queue occurrence.")),PZ=T("preview",{workspace:M,queueId:wn,count:Ue("count").pipe(Xe(10)),after:C("after").pipe(E),includeOccupied:ft("include-occupied").pipe(Xe(!1))},(e)=>R(async()=>(await Ne(f(e.workspace))).queues.previewSlots(e.queueId,{count:e.count,after:f(e.after),includeOccupied:e.includeOccupied}))).pipe(P("Preview upcoming queue occurrences.")),RZ=T("skips",{workspace:M,queueId:wn,...ys},(e)=>R(async()=>(await Ne(f(e.workspace))).queues.skips(e.queueId,{cursor:f(e.cursor),limit:f(e.limit)}))).pipe(P("List skipped queue occurrences.")),_Z=T("skip",{workspace:M,queueId:wn,slotId:C("slot-id").pipe(ue(bu)),occurrenceDate:C("occurrence-date")},(e)=>R(async()=>{let t=await Ne(f(e.workspace)),r=await IZ({slotId:e.slotId,occurrenceDate:e.occurrenceDate}).catch(()=>{throw new Le("Use --slot-id with a queue slot UUID and --occurrence-date YYYY-MM-DD.")});return t.queues.skip(e.queueId,r.slotId,r.occurrenceDate)})).pipe(P("Skip one queue occurrence.")),UZ=T("unskip",{workspace:M,queueId:wn,skipId:C("skip-id").pipe(ue(bu))},(e)=>R(async()=>(await Ne(f(e.workspace))).queues.unskip(e.queueId,e.skipId))).pipe(P("Restore a skipped queue occurrence.")),DZ=T("blackouts",{workspace:M,queueId:wn,...ys},(e)=>R(async()=>(await Ne(f(e.workspace))).queues.blackouts(e.queueId,{cursor:f(e.cursor),limit:f(e.limit)}))).pipe(P("List queue blackout date ranges.")),LZ=T("blackout",{workspace:M,queueId:wn,startsOn:C("starts-on"),endsOn:C("ends-on"),reason:C("reason").pipe(E)},(e)=>R(async()=>{let t=await Ne(f(e.workspace)),r=await wZ({startsOn:e.startsOn,endsOn:e.endsOn,reason:f(e.reason)}).catch(()=>{throw new Le("Use --starts-on and --ends-on as YYYY-MM-DD; --reason is at most 200 characters.")});return t.queues.blackout(e.queueId,r)})).pipe(P("Black out a queue date range.")),MZ=T("unblackout",{workspace:M,queueId:wn,blackoutId:C("blackout-id").pipe(ue(ah))},(e)=>R(async()=>(await Ne(f(e.workspace))).queues.unblackout(e.queueId,e.blackoutId))).pipe(P("Remove a queue blackout.")),u1=(e)=>T(e?"pause":"resume",{workspace:M,queueId:wn,version:by},(t)=>R(async()=>(await Ne(f(t.workspace))).queues.update(t.queueId,{expectedVersion:t.version,paused:e}))).pipe(P(e?"Pause new assignments while queued attempts still publish.":"Resume new assignments.")),y1=T("queues").pipe(P("Manage weekly account publishing queues."),Je([EZ,kZ,AZ,vZ,CZ,TZ,OZ,PZ,RZ,_Z,UZ,DZ,LZ,MZ,u1(!0),u1(!1)]));var FZ=T("list",{workspace:M,from:C("from").pipe(Ce("Inclusive ISO start instant, for example 2026-12-01T00:00:00Z.")),to:C("to").pipe(Ce("Inclusive ISO end instant, at most 90 days after --from.")),accountId:C("account-id").pipe(ue(H),E,Ce("Filter by the target publishing account.")),queueId:C("queue-id").pipe(ue(Xt),E,Ce("Filter by the open queue assignment.")),...ys},(e)=>R(async()=>(await Ne(f(e.workspace))).schedule.list({from:e.from,to:e.to,accountId:f(e.accountId),queueId:f(e.queueId),cursor:f(e.cursor),limit:f(e.limit)}))).pipe(P("List queued attempts in a time range.")),NZ=T("skip-to-next",{workspace:M,postId:C("post-id").pipe(ue(Pt)),targetId:C("target-id").pipe(ue(sr)),queueId:C("queue-id").pipe(ue(Xt),E,Ce("Override the target delivery's current queue.")),expectedAttemptId:C("expected-attempt-id").pipe(ue(Wt),E,Ce("Override the target delivery's current attempt."))},(e)=>R(async()=>(await Ne(f(e.workspace))).schedule.skipToNext(e.postId,e.targetId,{queueId:f(e.queueId),expectedAttemptId:f(e.expectedAttemptId)}))).pipe(P("Move a queue-assigned target to the next free occurrence.")),g1=T("schedule").pipe(P("Read the publishing calendar and skip ahead."),Je([FZ,NZ]));var x1=[T("preferences").pipe(P(""),Je([T("get",{workspace:M},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,UE({client:t.runtime.client,path:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(P("Read email notification preferences")),T("update",{workspace:M,deliveryFailures:ft("delivery-failures").pipe(Xe(!1)),connectionExpiring:ft("connection-expiring").pipe(Xe(!1)),webhookFailures:ft("webhook-failures").pipe(Xe(!1)),billingAlerts:ft("billing-alerts").pipe(Xe(!1)),weeklyDigest:ft("weekly-digest").pipe(Xe(!1))},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,DE({client:t.runtime.client,path:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{...e.deliveryFailures?{deliveryFailures:!0}:{},...e.connectionExpiring?{connectionExpiring:!0}:{},...e.webhookFailures?{webhookFailures:!0}:{},...e.billingAlerts?{billingAlerts:!0}:{},...e.weeklyDigest?{weeklyDigest:!0}:{}},...t.runtime.transport()}))})).pipe(P("Update email notification preferences"))]))];var S1=T("notifications").pipe(P("Read and update notification preferences."),Je(x1));var b1=[T("get",{},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,DI({client:t.runtime.client,...t.runtime.transport()}))})).pipe(P("Get your profile"))];var BZ=T("update",{name:C("name").pipe(E),clear:ft("clear-name").pipe(Xe(!1))},({name:e,clear:t})=>R(async()=>{if(e._tag==="Some"===t)throw new Le("Provide exactly one of --name or --clear-name.");let r=ts(FU)({displayName:e._tag==="Some"?e.value:null});if(r._tag==="None")throw new Le("Display name must be between 1 and 100 characters.");return(await fo()).me.update(r.value)})).pipe(P("Change or clear your display name.")),KZ=T("deactivate",{yes:ft("yes").pipe(Xe(!1))},({yes:e})=>R(async()=>{if(!e)throw new Le("Pass --yes to deactivate the current profile.");return(await fo()).me.deactivate()})).pipe(P("Deactivate your profile after archiving owned workspaces.")),$Z=T("list",{},()=>R(async()=>(await fo(void 0,"human")).me.invites())),qZ=T("accept",{inviteId:te("invite-id").pipe(ne(ui))},({inviteId:e})=>R(async()=>(await fo(void 0,"human")).me.acceptInvite({inviteId:e}))),WZ=T("decline",{inviteId:te("invite-id").pipe(ne(ui))},({inviteId:e})=>R(async()=>(await fo(void 0,"human")).me.declineInvite(e))),GZ=T("invites").pipe(P("Manage your workspace invitations."),Je([$Z,qZ,WZ])),I1=T("profile").pipe(P("Manage your PubNio profile."),Je([...b1,BZ,KZ,GZ]));var w1=[T("list",{workspace:M,includeArchived:we("include-archived",["true","false"]).pipe(E),cursor:C("cursor").pipe(E),limit:Ue("limit").pipe(E)},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,nw({client:t.runtime.client,query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId),...O(e.includeArchived)?{includeArchived:f(e.includeArchived)}:{},...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(P("List workspace profiles")),T("create",{workspace:M,name:C("name"),externalId:C("external-id").pipe(E)},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,ow({client:t.runtime.client,query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{name:e.name,...O(e.externalId)?{externalId:f(e.externalId)}:{}},...t.runtime.transport()}))})).pipe(P("Create a workspace profile")),T("get",{workspace:M,profileId:te("profile-id").pipe(ne(a.check(D())))},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,sw({client:t.runtime.client,path:{profileId:e.profileId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(P("Read a workspace profile")),T("update",{workspace:M,profileId:te("profile-id").pipe(ne(a.check(D()))),name:C("name").pipe(E),file:C("file").pipe(E,Ce("Read the body JSON from a file or stdin with -."))},(e)=>R(async()=>{let t=await Q(),r=f(e.file),n=r===void 0?{...O(e.name)?{name:f(e.name)}:{}}:await It(r);return t.runtime.decode(j,aw({client:t.runtime.client,path:{profileId:e.profileId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},body:n,...t.runtime.transport()}))})).pipe(P("Rename a profile or change its external ID")),T("archive",{workspace:M,profileId:te("profile-id").pipe(ne(a.check(D())))},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,iw({client:t.runtime.client,path:{profileId:e.profileId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(P("Archive a workspace profile"))];var E1=T("profiles").pipe(P("Manage posting profiles."),Je(w1));var k1=[T("list",{workspace:M,cursor:C("cursor").pipe(E),limit:Ue("limit").pipe(E)},(e)=>R(async()=>{let t=await Q(void 0,"human");return t.runtime.decode(j,zI({client:t.runtime.client,path:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},query:{...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(P("List webhook endpoints")),T("create",{workspace:M,name:C("name"),url:C("url"),eventTypes:we("event",["post.delivery.published","post.delivery.provider_draft","post.delivery.failed","post.delivery.unresolved","post.delivery.cancelled","post.scheduled","post.published","post.partial","post.failed","post.cancelled","inbox.message.received","inbox.comment.received","inbox.review.new","inbox.review.updated","inbox.review.deleted","inbox.review.restored","inbox.review.replied","inbox.mention.received","inbox.message.sent","inbox.message.delivered","inbox.message.read","inbox.message.edited","inbox.message.deleted","inbox.reaction.received","inbox.referral.received","inbox.conversation.started","analytics.post.synced","analytics.account.synced","ads.operation.succeeded","ads.operation.failed","ads.campaign.activated","ads.campaign.paused","ads.budget.changed","ads.kill_switch.activated","ads.lead.received","ads.campaign.status_changed","ads.ad_group.status_changed","ads.ad.status_changed","ads.ad_account.status_changed","ads.ad.review.approved","ads.ad.review.rejected","ads.sync.failed","ads.sync.recovered","ads.initial_sync.completed","schedule.assignment.changed","account.connected","account.disconnected","account.permissions_changed","account.restricted","account.recovered","billing.subscription.updated","billing.credit.topped_up","billing.credit.low","billing.spend_cap.reached","billing.invoice.payment_failed"]).pipe(Sr(0)),enabled:ft("paused").pipe(Xe(!1)),profileId:C("profile-id").pipe(ue(a.check(D()))).pipe(E),accountIds:C("account-ids").pipe(Sr(0)),disabledResourceGroups:we("disabled-resource-groups",["publishing","inbox","analytics","ads","scheduling","accounts","billing"]).pipe(Sr(0))},(e)=>R(async()=>{let t=await Q(void 0,"human");return t.runtime.decode(j,jI({client:t.runtime.client,path:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{name:e.name,url:e.url,eventTypes:[...e.eventTypes],...e.enabled?{enabled:!1}:{},...O(e.profileId)?{profileId:f(e.profileId)}:{},...e.accountIds.length?{accountIds:[...e.accountIds]}:{},...e.disabledResourceGroups.length?{disabledResourceGroups:[...e.disabledResourceGroups]}:{}},...t.runtime.transport()}))})).pipe(P("Register a webhook endpoint")),T("get",{workspace:M,endpointId:te("endpoint-id").pipe(ne(a.check(D())))},(e)=>R(async()=>{let t=await Q(void 0,"human");return t.runtime.decode(j,HI({client:t.runtime.client,path:{endpointId:e.endpointId,workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(P("Inspect a webhook endpoint")),T("update",{workspace:M,endpointId:te("endpoint-id").pipe(ne(a.check(D()))),name:C("name").pipe(E),eventTypes:we("event",["post.delivery.published","post.delivery.provider_draft","post.delivery.failed","post.delivery.unresolved","post.delivery.cancelled","post.scheduled","post.published","post.partial","post.failed","post.cancelled","inbox.message.received","inbox.comment.received","inbox.review.new","inbox.review.updated","inbox.review.deleted","inbox.review.restored","inbox.review.replied","inbox.mention.received","inbox.message.sent","inbox.message.delivered","inbox.message.read","inbox.message.edited","inbox.message.deleted","inbox.reaction.received","inbox.referral.received","inbox.conversation.started","analytics.post.synced","analytics.account.synced","ads.operation.succeeded","ads.operation.failed","ads.campaign.activated","ads.campaign.paused","ads.budget.changed","ads.kill_switch.activated","ads.lead.received","ads.campaign.status_changed","ads.ad_group.status_changed","ads.ad.status_changed","ads.ad_account.status_changed","ads.ad.review.approved","ads.ad.review.rejected","ads.sync.failed","ads.sync.recovered","ads.initial_sync.completed","schedule.assignment.changed","account.connected","account.disconnected","account.permissions_changed","account.restricted","account.recovered","billing.subscription.updated","billing.credit.topped_up","billing.credit.low","billing.spend_cap.reached","billing.invoice.payment_failed"]).pipe(Sr(0)),enabled:ft("paused").pipe(Xe(!1)),file:C("file").pipe(E,Ce("Read the body JSON from a file or stdin with -."))},(e)=>R(async()=>{let t=await Q(void 0,"human"),r=f(e.file),n=r===void 0?{...O(e.name)?{name:f(e.name)}:{},...e.eventTypes.length?{eventTypes:[...e.eventTypes]}:{},...e.enabled?{enabled:!1}:{}}:await It(r);return t.runtime.decode(j,VI({client:t.runtime.client,path:{endpointId:e.endpointId,workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},body:n,...t.runtime.transport()}))})).pipe(P("Edit or pause a webhook endpoint")),T("delete",{workspace:M,endpointId:te("endpoint-id").pipe(ne(a.check(D())))},(e)=>R(async()=>{let t=await Q(void 0,"human");return t.runtime.decode(j,QI({client:t.runtime.client,path:{endpointId:e.endpointId,workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(P("Permanently disable a webhook endpoint")),T("test",{workspace:M,endpointId:te("endpoint-id").pipe(ne(a.check(D())))},(e)=>R(async()=>{let t=await Q(void 0,"human");return t.runtime.decode(j,JI({client:t.runtime.client,path:{endpointId:e.endpointId,workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(P("Enqueue a webhook test event")),T("list-deliveries",{workspace:M,endpointId:te("endpoint-id").pipe(ne(a.check(D()))),cursor:C("cursor").pipe(E),limit:Ue("limit").pipe(E)},(e)=>R(async()=>{let t=await Q(void 0,"human");return t.runtime.decode(j,YI({client:t.runtime.client,path:{endpointId:e.endpointId,workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},query:{...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(P("List webhook deliveries")),T("get-delivery",{workspace:M,endpointId:te("endpoint-id").pipe(ne(a.check(D()))),deliveryId:te("delivery-id").pipe(ne(a.check(D())))},(e)=>R(async()=>{let t=await Q(void 0,"human");return t.runtime.decode(j,ZI({client:t.runtime.client,path:{endpointId:e.endpointId,deliveryId:e.deliveryId,workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(P("Inspect a webhook delivery")),T("replay-delivery",{workspace:M,endpointId:te("endpoint-id").pipe(ne(a.check(D()))),deliveryId:te("delivery-id").pipe(ne(a.check(D())))},(e)=>R(async()=>{let t=await Q(void 0,"human");return t.runtime.decode(j,XI({client:t.runtime.client,path:{endpointId:e.endpointId,deliveryId:e.deliveryId,workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(P("Replay a settled webhook delivery")),T("event-types",{},(e)=>R(async()=>{let t=await Q(void 0,"human");return t.runtime.decode(j,g6({client:t.runtime.client,...t.runtime.transport()}))})).pipe(P("List supported webhook event types"))];var A1=T("webhooks").pipe(P("Manage workspace webhooks as a signed-in owner."),Je(k1));var v1=[T("list",{},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,LI({client:t.runtime.client,...t.runtime.transport()}))})).pipe(P("List workspaces")),T("create",{name:C("name"),defaultTimezone:C("default-timezone").pipe(E)},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,MI({client:t.runtime.client,body:{name:e.name,...O(e.defaultTimezone)?{defaultTimezone:f(e.defaultTimezone)}:{}},...t.runtime.transport()}))})).pipe(P("Create a workspace")),T("get",{id:te("id").pipe(ne(a.check(D())))},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,NI({client:t.runtime.client,path:{workspaceId:e.id},...t.runtime.transport()}))})).pipe(P("Get a workspace")),T("update",{id:te("id").pipe(ne(a.check(D()))),name:C("name").pipe(E),defaultTimezone:C("default-timezone").pipe(E)},(e)=>R(async()=>{let t=await Q();if(!(O(e.name)||O(e.defaultTimezone)))throw new Le("Provide --name or --default-timezone.");return t.runtime.decode(j,BI({client:t.runtime.client,path:{workspaceId:e.id},body:{...O(e.name)?{name:f(e.name)}:{},...O(e.defaultTimezone)?{defaultTimezone:f(e.defaultTimezone)}:{}},...t.runtime.transport()}))})).pipe(P("Update a workspace you own")),T("archive",{id:te("id").pipe(ne(a.check(D())))},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,FI({client:t.runtime.client,path:{workspaceId:e.id},...t.runtime.transport()}))})).pipe(P("Archive a workspace you own")),T("invites").pipe(P(""),Je([T("list",{workspace:M,status:we("status",["pending","accepted","revoked","expired"]).pipe(E),cursor:C("cursor").pipe(E),limit:Ue("limit").pipe(E)},(e)=>R(async()=>{let t=await Q(void 0,"human");return t.runtime.decode(j,NE({client:t.runtime.client,path:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},query:{...O(e.status)?{status:f(e.status)}:{},...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(P("List workspace invitations")),T("create",{workspace:M,email:C("email"),role:we("role",["owner","member"]).pipe(E),idempotencyKey:rt},(e)=>R(async()=>{let t=await Q(void 0,"human");return t.runtime.decode(j,BE({client:t.runtime.client,path:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{email:e.email,...O(e.role)?{role:f(e.role)}:{}},headers:{"idempotency-key":f(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()}))})).pipe(P("Create a workspace invitation")),T("resend",{workspace:M,inviteId:te("invite-id").pipe(ne(a.check(D()))),idempotencyKey:rt},(e)=>R(async()=>{let t=await Q(void 0,"human");return t.runtime.decode(j,KE({client:t.runtime.client,path:{inviteId:e.inviteId,workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},headers:{"idempotency-key":f(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()}))})).pipe(P("Resend a pending invitation email")),T("revoke",{workspace:M,inviteId:te("invite-id").pipe(ne(a.check(D())))},(e)=>R(async()=>{let t=await Q(void 0,"human");return t.runtime.decode(j,$E({client:t.runtime.client,path:{inviteId:e.inviteId,workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(P("Revoke a pending workspace invitation"))])),T("members").pipe(P(""),Je([T("list",{workspace:M,role:we("role",["owner","member"]).pipe(E),cursor:C("cursor").pipe(E),limit:Ue("limit").pipe(E)},(e)=>R(async()=>{let t=await Q(void 0,"human");return t.runtime.decode(j,LE({client:t.runtime.client,path:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},query:{...O(e.role)?{role:f(e.role)}:{},...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(P("List workspace members")),T("remove",{workspace:M,userId:te("user-id").pipe(ne(a.check(D())))},(e)=>R(async()=>{let t=await Q(void 0,"human");return t.runtime.decode(j,ME({client:t.runtime.client,path:{userId:e.userId,workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(P("Remove a workspace member or leave the workspace")),T("update-role",{workspace:M,userId:te("user-id").pipe(ne(a.check(D()))),role:we("role",["owner","member"])},(e)=>R(async()=>{let t=await Q(void 0,"human");return t.runtime.decode(j,FE({client:t.runtime.client,path:{userId:e.userId,workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{role:e.role},...t.runtime.transport()}))})).pipe(P("Update a workspace member's role"))]))];var zZ=T("use",{id:N$},({id:e})=>R(async()=>(await fo()).useWorkspace(e))).pipe(P("Remember the active workspace for this CLI session.")),C1=T("workspaces").pipe(P("Manage PubNio workspaces."),Je([...v1,zZ]));var T1=T("pnio").pipe(P("Connect accounts and manage PubNio content."),Je([qq,I1,C1,E1,Nq,Mq,Kq,S1,i1,jq,Hq,Jq,Dq,d1,y1,g1,c1,A1,Zq,Gq]));var jZ=L$(T1,{version:Vu.version}),nl=process.argv.slice(2);try{await OO(jZ(nl.length?nl:["--help"]).pipe(vO(e4),Qi(up,{present:(e)=>e._tag==="InvalidInvocation"?Fe(()=>console.error(e.errors.map((t)=>t.message).join(`
271
+ `)},F9=(e)=>{let o=e.map(N9),i=[],s=" $ ";for(let c of o){let l=s===" $ "||s===" "?"":" ";if(s.length+l.length+c.length>88&&s!==" $ ")i.push(`${s} \\`),s=` ${c}`;else s+=`${l}${c}`}if(s!==" $ ")i.push(s);return i},N9=(e)=>/^[A-Za-z0-9_./:@%+=,-]+$/.test(e)?e:`'${e.replaceAll("'",`'"'"'`)}'`;var K9=(e)=>je(e,zu),T=(e,t,r)=>{let n=Tk(t??{});return Vh({name:e,config:n,...Qt(r)?{handle:r}:{}})};var $9=(e)=>{let t=[],r=new Map,n=(s,c)=>{t.push(c);let l=r.get(s);if(l)l.push(c);else r.set(s,[c])};for(let s of e){if(K9(s)){n(void 0,s);continue}for(let c of s.commands)n(s.group,c)}let o=[],i=r.get(void 0);if(i&&i.length>0)o.push({group:void 0,commands:i});for(let[s,c]of r){if(s===void 0)continue;o.push({group:s,commands:c})}return{flat:t,groups:o}},Je=B(2,(e,t)=>{let r=$9(t);FK(e,r.flat);let n=Ft(e),o=new Map(r.flat.map((l)=>[l.name,Ft(l)])),i=Symbol("effect/cli/SubcommandState"),s=Se(function*(l){if(nr(l.subcommand))return yield*n.parse(l);let S=o.get(l.subcommand.value.name);if(!S)return yield*n.parse(l);let m=yield*n.parseContext(l),g=yield*S.parse(l.subcommand.value.parsedInput);return{...m,[i]:{name:S.name,result:g}}}),c=Se(function*(l,S){let g=l[i];if(g){let w=o.get(g.name);if(!w)return yield*new gi({commandPath:S,errors:[]});return yield*w.handle(g.result,[...S,w.name]).pipe(Qi(n.service,l))}return yield*n.handle(l,S)});return Vh({name:n.name,config:n.config,contextConfig:n.contextConfig,description:n.description,shortDescription:n.shortDescription,alias:n.alias,unlisted:n.unlisted,annotations:n.annotations,globalFlags:n.globalFlags,resolveExamples:n.resolveExamples,service:n.service,subcommands:r.groups,parse:s,parseContext:n.parseContext,handle:c})});var P=B(2,(e,t)=>Vh({...Ft(e),description:t}));var q9=(e,t,r,n)=>{let o=new Set(t),i=[],s=new Set;for(let c of e){if(o.has(c))continue;let l=Mt(c.flag);for(let S of l){let m=r[S.name];if(!m||m.length===0)continue;let g=`--${S.name}`;if(s.has(g))continue;s.add(g),i.push(new ka({option:g,suggestions:[],command:n}))}}return i},W9=(e,t,r)=>wr(function*(){let{builtIns:n}=yield*ty,o=yield*up,{commandPath:i,errors:s}=t,c=yield*Xh(e,i,n);yield*o.present(r&&s.length>0?{_tag:"InvalidInvocation",commandPath:i,helpDoc:c,errors:s}:{_tag:"Help",reason:"Implicit",commandPath:i,helpDoc:c})}),G9=(e,t)=>wr(function*(){let r=yield*d$,n=e instanceof Mu?e:new Mu({cause:e,userMessage:t});yield*Nm(r.formatError(n)),Object.assign(e,{[pu]:!1})});var L$=(e,t)=>{let r=Ft(e);return Se(function*(n){let{builtIns:o}=yield*ty,{tokens:i,trailingOperands:s}=l$(n),c=s$(e,o),l=c.flatMap((z)=>Mt(z.flag)),S=mp(l.filter(Wu)),{flagMap:m,remainder:g,errors:w}=k$(i,e,S),k={flags:m,arguments:[]},A=yield*Hk({tokens:g,trailingOperands:s},e),y=[e.name,...Qk(A)],h=(z)=>z._tag==="ShowHelp"?z:new gi({commandPath:y,errors:[z]}),x=Or(h),q={builtIns:o,command:e,commandPath:y,version:t.version},Y=qk(e,y,o),I=q9(c,Y,m,y);if(I.length>0||w.length>0){let z=A.errors??[];return yield*new gi({commandPath:y,errors:[...w,...I,...z]})}for(let z of Y){if(z._tag!=="Action")continue;if(!Mt(z.flag).some((oe)=>{let de=m[oe.name];return de!==void 0&&de.length>0}))continue;let[,ie]=yield*z.flag.parse(k).pipe(x);if(z===Wk){let{colors:oe}=yield*Ku;return yield*wr(function*(){yield*hr(R$(e.name,t.version,e.description,oe));let de=new Set(Vk(g,e)),ge=[e.name,...i.filter((Ke)=>!de.has(Ke)&&!(Ke._tag==="LongOption"&&Ke.name==="wizard")).map(f$)],ke=yield*O$(e,{commandPath:y,prefix:ge});if(yield*hr(_$(ke.displayArgs,oe)),yield*on(aK({message:"Run this command?",initial:!0,active:"yes",inactive:"no"})))yield*hr(),yield*L$(e,{...t,renderErrors:!1})(ke.args.slice(1))}).pipe(md("QuitError",()=>hr(U$(oe))))}yield*z.run(ie,q);return}if(A.errors&&A.errors.length>0)return yield*new gi({commandPath:y,errors:A.errors});let le=yield*r.parse(A).pipe(Or((z)=>YE(z)?h(z):z)),ae=r.handle(le,[e.name]),N=Y.includes(lp)?(yield*lp.flag.parse(k).pipe(x))[1]:he();ae=Qi(ae,lp,N);for(let z of Y){if(z._tag!=="Setting"||z===lp)continue;let[,X]=yield*z.flag.parse(k).pipe(x);ae=Qi(ae,z,X)}let Z=Kr(N,{onNone:()=>pn(),onSome:(z)=>Fs(tO,z)});yield*ji(ae,Z)},kf((n)=>YE(n)&&n._tag==="ShowHelp"?Jt(n):Dt(n),(n)=>Jn(W9(e,n,t.renderErrors!==!1),fe(n))),kf((n)=>{if(t.renderErrors===!1||!Tp(n))return Dt(n);let o=UB(n);return o===void 0?Dt(n):Jt({error:n,userMessage:o})},({error:n,userMessage:o})=>Jn(G9(n,o),fe(n))),kf((n)=>bU(n)?Jt(n):Dt(n),(n)=>gd))};var Vu={name:"@pubnio/cli",version:"0.2.3",type:"module",description:"PubNio command-line interface.",homepage:"https://pubnio.com/docs/cli/",keywords:["pubnio","cli","social","publishing","api","agents","mcp"],publishConfig:{access:"public"},bin:{pnio:"./dist/index.js"},files:["dist","README.md"],engines:{bun:">=1.4.0"},scripts:{generate:"bun script/generate.ts","generate:check":"bun script/generate.ts --check",build:"bun build --target=bun --minify --outfile dist/index.js ./src/index.ts && bun run copy:skill","copy:skill":"mkdir -p dist/skills/pnio && cp ../docs/skills/pnio/SKILL.md dist/skills/pnio/SKILL.md",pack:"bun script/pack.ts",compile:"bun build --compile --minify --compile-exec-argv=--use-system-ca --outfile dist/pnio ./src/index.ts","compile:all":"bun run compile:darwin-arm64 && bun run compile:darwin-x64 && bun run compile:linux-x64 && bun run compile:linux-arm64 && bun run compile:windows-x64","compile:darwin-arm64":"bun build --compile --minify --compile-exec-argv=--use-system-ca --target=bun-darwin-arm64 --outfile dist/pnio-darwin-arm64 ./src/index.ts","compile:darwin-x64":"bun build --compile --minify --compile-exec-argv=--use-system-ca --target=bun-darwin-x64 --outfile dist/pnio-darwin-x64 ./src/index.ts","compile:linux-x64":"bun build --compile --minify --compile-exec-argv=--use-system-ca --target=bun-linux-x64 --outfile dist/pnio-linux-x64 ./src/index.ts","compile:linux-arm64":"bun build --compile --minify --compile-exec-argv=--use-system-ca --target=bun-linux-arm64 --outfile dist/pnio-linux-arm64 ./src/index.ts","compile:windows-x64":"bun build --compile --minify --compile-exec-argv=--use-system-ca --target=bun-windows-x64 --outfile dist/pnio-windows-x64.exe ./src/index.ts",prepack:"bun run build"},dependencies:{"@effect/platform-bun":"4.1.7","@pubnio/protocol":"workspace:*","@pubnio/sdk":"workspace:*",effect:"4.1.7",jose:"6.2.19","proper-lockfile":"4.1.2"},devDependencies:{"@types/proper-lockfile":"4.1.4"}};function M$(e){let t,r=Ea({...e,onRuntime:(n)=>{t=n}});if(!t)throw Error("PubNio client runtime was not captured.");return{client:r,runtime:t}}function F$(e={}){let t=process.env,r=e.json===!0||t.PUBNIO_NON_INTERACTIVE==="1"||t.CI==="1"||t.CI==="true"||Boolean(t.OPENCODE_AGENT)||Boolean(t.CLAUDECODE)||!process.stdout.isTTY;return{interactive:!r,browser:!r}}var M=C("workspace").pipe(ue(ce),E,Ce("Workspace ID. Defaults to PUBNIO_WORKSPACE_ID or your only workspace.")),N$=te("id").pipe(ne(ce)),gbe=C("name").pipe(ue(LU.fields.name)),xbe=C("default-timezone").pipe(E,Ce("Default IANA time zone for new queues, e.g. America/New_York.")),Ju=ft("browser").pipe(Xe(F$().browser),Ce("Open the browser automatically. Defaults to on only for an interactive terminal; pass --browser or --no-browser to override.")),Zk=C("account").pipe(ue(H),E,Ce("Publishing account ID.")),B$=C("account").pipe(ue(H),Sr(0),Ce("Publish to this exact publishing account ID, or save it as a draft target. Repeat for several accounts.")),K$=C("account").pipe(ue(xu.fields.accountId),E,Ce("Publish to this existing post target account.")),rt=C("idempotency-key").pipe(ue(Qr),E,Ce("Reuse a key to replay this request safely. Generated when omitted.")),ys={cursor:C("cursor").pipe(E),limit:Ue("limit").pipe(E)};class Le extends Error{}function It(e){return(e==="-"?Bun.stdin:Bun.file(e)).json().catch(()=>{throw new Le("Could not read JSON input.")})}function R(e){return Ws({try:e,catch:(t)=>t}).pipe(Gi((t)=>Fe(()=>console.log(JSON.stringify(t,null,2)))))}function iy(e){let t=process.platform==="darwin"?"open":process.platform==="linux"?"xdg-open":void 0;if(!t||!Bun.which(t))return;Bun.spawn([t,e],{stdin:"ignore",stdout:"ignore",stderr:"ignore"}).unref()}var $$=p({clientId:a});var q$="/api/auth/cli";var W$=new TextDecoder,G$=new TextDecoder("utf-8",{fatal:!0});function z$(e,t=!1){if(Uint8Array.fromBase64)return Uint8Array.fromBase64(e,{alphabet:t?"base64url":"base64"});if(t){if(e.includes("+")||e.includes("/"))throw TypeError("Invalid base64url");e=e.replace(/-/g,"+").replace(/_/g,"/")}let r=atob(e),n=new Uint8Array(r.length);for(let o=0;o<r.length;o++)n[o]=r.charCodeAt(o);return n}class j$ extends Error{static code="ERR_JOSE_GENERIC";code="ERR_JOSE_GENERIC";constructor(e,t){super(e,t),this.name=this.constructor.name,Error.captureStackTrace?.(this,this.constructor)}}class Ii extends j${static code="ERR_JWT_INVALID";code="ERR_JWT_INVALID"}var j9="The input to be decoded is not correctly encoded.";function Q$(e){try{return z$(typeof e=="string"?e:W$.decode(e),!0)}catch(t){throw TypeError(j9,{cause:t})}}function H$(e){if(typeof e!="object"||e===null||Object.prototype.toString.call(e)!=="[object Object]")return!1;let t=Object.getPrototypeOf(e);return t===null||Object.getPrototypeOf(t)===null}function Xk(e){if(typeof e!="string")throw new Ii("JWTs must use Compact JWS serialization, JWT must be a string");let{1:t,length:r}=e.split(".");if(r===5)throw new Ii("Only JWTs using Compact JWS serialization can be decoded");if(r!==3)throw new Ii("Invalid JWT");if(!t)throw new Ii("JWTs must contain a payload");let n;try{n=Q$(t)}catch(i){throw new Ii("Failed to base64url decode the payload",{cause:i})}let o;try{o=JSON.parse(G$.decode(n))}catch(i){throw new Ii("Failed to parse the decoded payload as JSON",{cause:i})}if(!H$(o))throw new Ii("Invalid JWT Claims Set");return o}var kq=j1(Iq(),1);import{mkdir as R5,rename as wq,rm as Fa,writeFile as Eq}from"fs/promises";import{homedir as _5}from"os";import{join as yA}from"path";var U5="https://api.workos.com/user_management",D5=(e)=>{let t=yA(process.env.XDG_CONFIG_HOME||yA(_5(),".config"),"pubnio"),r=new Bun.CryptoHasher("sha256").update(e).digest("hex");return{dir:t,file:yA(t,`${r}.json`)}},gA=p({access_token:a,refresh_token:a}),L5=p({clientId:a,...gA.fields,workspaceId:u(ce)}),Aq=p({device_code:a,user_code:a,verification_uri:a,verification_uri_complete:a,expires_in:mr.check(Ro(0)),interval:mr.check(Ro(0))});class xy extends Error{code;status;constructor(e,t){super(`WorkOS request failed (HTTP ${t}).`);this.code=e;this.status=t}}var M5="Sign in with `pnio auth login`.";async function xA(e,t,r,n){let o=await e(`${U5}/${t}`,{method:"POST",body:new URLSearchParams(r),redirect:"error",signal:AbortSignal.timeout(1e4)}),i=await o.json().catch(()=>null);if(o.ok)return no(n)(i);let s=i&&typeof i==="object"&&"error"in i&&typeof i.error==="string"?i.error:"unknown";throw new xy(s,o.status)}var F5=p({clientId:a,device:Aq,expiresAt:mr}),vq=(e)=>`${e}.device.json`;async function N5(e,t){let r=`${e}.${crypto.randomUUID()}.tmp`;try{await Eq(r,JSON.stringify(t),{mode:384,flag:"wx"}),await wq(r,e)}finally{await Fa(r,{force:!0})}}async function B5(e,t=fetch){let r=await xA(t,"authorize/device",{client_id:e},Aq),n=new URL(r.verification_uri),o=new URL(r.verification_uri_complete);if(n.protocol!=="https:"||o.origin!==n.origin)throw Error("WorkOS returned an invalid sign-in URL.");return{device:r,url:n.href,completeUrl:o.href}}async function Cq(e){let t=await wA(e,"GET"),{clientId:r}=await no($$)(await t.json()),{device:n,url:o,completeUrl:i}=await B5(r),s=Date.now()+n.expires_in*1000;return await rl(e,async(c)=>{await N5(vq(c),{clientId:r,device:n,expiresAt:s})}),{url:o,completeUrl:i,userCode:n.user_code,expiresAt:new Date(s).toISOString()}}async function K5(e,t,r,n=fetch){let o=Math.min(Date.now()+t.expires_in*1000,Date.now()+r),i=t.interval*1000;while(Date.now()+i<o){await Bun.sleep(i);try{let s=await xA(n,"authenticate",{client_id:e,grant_type:"urn:ietf:params:oauth:grant-type:device_code",device_code:t.device_code},gA);return{clientId:e,...s}}catch(s){if(s instanceof xy){if(s.code==="authorization_pending")continue;if(s.code==="slow_down"||s.status===429||s.status>=500){i+=5000;continue}if(s.code==="expired_token")break;if(s.code==="access_denied")throw Error("Sign-in was declined.",{cause:s})}if(s instanceof Error&&s.name==="TimeoutError"){i*=2;continue}throw s}}throw Error("Sign-in is still pending. Run `pnio auth complete` to keep waiting, or `pnio auth login` to start over.")}async function SA(e,{timeoutMs:t=600000}={}){return rl(e,async(r)=>{let n=vq(r),o=await $5(n);if(!o)throw Error("No sign-in is pending. Run `pnio auth login`.");if(o.expiresAt<=Date.now())throw await Fa(n,{force:!0}),Error("Sign-in expired. Run `pnio auth login` again.");let i=await K5(o.clientId,o.device,Math.min(t,o.expiresAt-Date.now())).catch(async(s)=>{throw await Fa(n,{force:!0}),s});return await wA(e,"POST",i.access_token),await IA(r,i),await Fa(n,{force:!0}),i.access_token})}async function $5(e){let t=Bun.file(e);if(!await t.exists())return;return no(F5)(await t.json())}async function bA(e){let t=Bun.file(e);if(!await t.exists())return;return no(L5)(await t.json())}async function IA(e,t){let r=`${e}.${crypto.randomUUID()}.tmp`;try{await Eq(r,JSON.stringify(t),{mode:384,flag:"wx"}),await wq(r,e)}finally{await Fa(r,{force:!0})}}async function rl(e,t){let{dir:r,file:n}=D5(e);await R5(r,{recursive:!0,mode:448});let o=await kq.default.lock(n,{realpath:!1,retries:{retries:20,minTimeout:100,maxTimeout:1000}});try{return await t(n)}finally{await o()}}async function wA(e,t,r){let n=await fetch(`${e}${q$}`,{method:t,headers:r?{Authorization:`Bearer ${r}`}:{},redirect:"error",signal:AbortSignal.timeout(15000)});if(!n.ok)throw Error(`PubNio sign-in request failed (HTTP ${n.status}).`);return n}async function Tq(e,t){let{exp:r}=Xk(t.access_token);if(r&&r*1000>Date.now()+30000)return t.access_token;try{let n=await xA(fetch,"authenticate",{client_id:t.clientId,grant_type:"refresh_token",refresh_token:t.refresh_token},gA);return await IA(e,{...t,...n}),n.access_token}catch(n){if(!(n instanceof xy&&n.code==="invalid_grant"))throw n;await Fa(e,{force:!0});return}}async function Oq(e){return rl(e,async(t)=>{let r=await bA(t),n=r&&await Tq(t,r);if(!n||!r)throw Error(M5);return{token:n,workspaceId:r.workspaceId}})}async function Pq(e,t,r){await rl(e,async(n)=>{let o=await bA(n);if(o?.access_token!==t)throw Error("The CLI session changed. Run the workspace command again.");await IA(n,{...o,workspaceId:r})})}async function Rq(e){return rl(e,async(t)=>{let r=await bA(t),n=r&&await Tq(t,r);if(n)await wA(e,"DELETE",n);await Fa(t,{force:!0})})}function Ei(){let e=URL.parse(process.env.PUBNIO_BASE_URL??"https://pubnio.com");if(!e||e.username||e.password||e.pathname!=="/"||e.search||e.hash||e.protocol!=="https:"&&!(e.protocol==="http:"&&["localhost","127.0.0.1","[::1]"].includes(e.hostname)))throw new Le("PUBNIO_BASE_URL must be an HTTPS origin or a local HTTP origin.");return e.origin}async function _q(e,t){let r=t==="default"?process.env.PUBNIO_API_KEY:void 0;if(r!==void 0&&!Pb.test(r))throw new Le("PUBNIO_API_KEY is not a valid PubNio API key.");let n=r===void 0?await Oq(e):void 0;return{apiKey:r,session:n}}async function fo(e=Ei(),t="default"){let{apiKey:r,session:n}=await _q(e,t),o=Ea({baseUrl:e,clientName:"cli",clientVersion:Vu.version,...r!==void 0?{apiKey:r}:{accessToken:n?.token}});return{...o,selectedWorkspaceId:n?.workspaceId,useWorkspace:async(i)=>{let s=await o.workspaces.get(i);if(n)await Pq(e,n.token,s.id);return s}}}async function Q(e=Ei(),t="default"){let{apiKey:r,session:n}=await _q(e,t);return{...M$({baseUrl:e,clientName:"cli",clientVersion:Vu.version,...r!==void 0?{apiKey:r}:{accessToken:n?.token}}),selectedWorkspaceId:n?.workspaceId}}async function J(e,t,r){let n=t??process.env.PUBNIO_WORKSPACE_ID??e.selectedWorkspaceId??r;if(n!==void 0){let i=ts(ce)(n);if(i._tag==="None")throw new Le("Expected a workspace UUID.");return i.value}let{workspaces:o}=await e.workspaces.list();if(o.length!==1)throw new Le("Select a workspace with `pnio workspaces use <id>` or pass --workspace. Run `pnio workspaces list` to see your workspaces.");return o[0].id}async function Ne(e,{origin:t,auth:r}={}){let n=await fo(t,r);return n.workspace(await J(n,e))}var Uq=[T("list-accounts",{workspace:M,state:we("state",["available","selected"]).pipe(E),cursor:C("cursor").pipe(E),limit:Ue("limit").pipe(E)},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,Hw({client:t.runtime.client,query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId),...O(e.state)?{state:f(e.state)}:{},...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(P("List available and selected ad accounts")),T("connect-account",{workspaceId:C("workspace-id").pipe(ue(a.check(D()))),provider:we("provider",["meta_ads","google_ads","reddit_ads","pinterest_ads","tiktok_ads","linkedin_ads","snapchat_ads","amazon_ads","openai_ads"]),accountId:C("account-id").pipe(ue(a.check(D()))).pipe(E)},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,Vw({client:t.runtime.client,body:{workspaceId:e.workspaceId,provider:e.provider,...O(e.accountId)?{accountId:f(e.accountId)}:{}},...t.runtime.transport()}))})).pipe(P("Start an ad account OAuth connection")),T("connect-api-key-account",{workspaceId:C("workspace-id").pipe(ue(a.check(D()))),provider:we("provider",["openai_ads"]),apiKey:C("api-key"),accountId:C("account-id").pipe(ue(a.check(D()))).pipe(E),profileId:C("profile-id").pipe(ue(a.check(D()))).pipe(E)},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,Jw({client:t.runtime.client,body:{workspaceId:e.workspaceId,provider:e.provider,apiKey:e.apiKey,...O(e.accountId)?{accountId:f(e.accountId)}:{},...O(e.profileId)?{profileId:f(e.profileId)}:{}},...t.runtime.transport()}))})).pipe(P("Connect an ad account with an API key")),T("disconnect-account",{workspace:M,accountId:te("account-id").pipe(ne(a.check(D())))},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,nE({client:t.runtime.client,path:{accountId:e.accountId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(P("Stop syncing an ad account")),T("select-account",{workspace:M,accountId:te("account-id").pipe(ne(a.check(D())))},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,rE({client:t.runtime.client,path:{accountId:e.accountId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(P("Select a discovered ad account")),T("list-campaigns",{workspace:M,accountId:te("account-id").pipe(ne(a.check(D()))),provider:we("provider",["meta_ads","google_ads","reddit_ads","pinterest_ads","tiktok_ads","linkedin_ads","snapchat_ads","amazon_ads","openai_ads"]).pipe(E),status:we("status",["draft","paused","activating","active","pending_review","rejected","completed","archived","unknown"]).pipe(E),managed:we("managed",["provider","pubnio"]).pipe(E),cursor:C("cursor").pipe(E),limit:Ue("limit").pipe(E)},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,oE({client:t.runtime.client,path:{accountId:e.accountId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId),...O(e.provider)?{provider:f(e.provider)}:{},...O(e.status)?{status:f(e.status)}:{},...O(e.managed)?{managed:f(e.managed)}:{},...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(P("List one account's campaigns newest first")),T("list-workspace-campaigns",{workspace:M,accountId:C("account-id").pipe(ue(a.check(D()))).pipe(E),provider:we("provider",["meta_ads","google_ads","reddit_ads","pinterest_ads","tiktok_ads","linkedin_ads","snapchat_ads","amazon_ads","openai_ads"]).pipe(E),status:we("status",["draft","paused","activating","active","pending_review","rejected","completed","archived","unknown"]).pipe(E),managed:we("managed",["provider","pubnio"]).pipe(E),cursor:C("cursor").pipe(E),limit:Ue("limit").pipe(E)},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,Zw({client:t.runtime.client,query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId),...O(e.accountId)?{accountId:f(e.accountId)}:{},...O(e.provider)?{provider:f(e.provider)}:{},...O(e.status)?{status:f(e.status)}:{},...O(e.managed)?{managed:f(e.managed)}:{},...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(P("List campaigns across selected ad accounts")),T("get-tree",{workspace:M,accountId:C("account-id").pipe(ue(a.check(D()))).pipe(E),campaignId:C("campaign-id").pipe(ue(a.check(D()))).pipe(E),cursor:C("cursor").pipe(E),limit:Ue("limit").pipe(E)},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,iE({client:t.runtime.client,query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId),...O(e.accountId)?{accountId:f(e.accountId)}:{},...O(e.campaignId)?{campaignId:f(e.campaignId)}:{},...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(P("Read a campaign, ad group, ad, and creative tree")),T("list-ads",{workspace:M,accountId:C("account-id").pipe(ue(a.check(D()))).pipe(E),campaignId:C("campaign-id").pipe(ue(a.check(D()))).pipe(E),adGroupId:C("ad-group-id").pipe(ue(a.check(D()))).pipe(E),provider:we("provider",["meta_ads","google_ads","reddit_ads","pinterest_ads","tiktok_ads","linkedin_ads","snapchat_ads","amazon_ads","openai_ads"]).pipe(E),status:we("status",["draft","paused","activating","active","pending_review","rejected","completed","archived","unknown"]).pipe(E),from:C("from").pipe(E),to:C("to").pipe(E),cursor:C("cursor").pipe(E),limit:Ue("limit").pipe(E)},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,sE({client:t.runtime.client,query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId),...O(e.accountId)?{accountId:f(e.accountId)}:{},...O(e.campaignId)?{campaignId:f(e.campaignId)}:{},...O(e.adGroupId)?{adGroupId:f(e.adGroupId)}:{},...O(e.provider)?{provider:f(e.provider)}:{},...O(e.status)?{status:f(e.status)}:{},...O(e.from)?{from:f(e.from)}:{},...O(e.to)?{to:f(e.to)}:{},...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(P("List ads with a performance summary")),T("list-ad-groups",{workspace:M,accountId:C("account-id").pipe(ue(a.check(D()))).pipe(E),campaignId:C("campaign-id").pipe(ue(a.check(D()))).pipe(E),provider:we("provider",["meta_ads","google_ads","reddit_ads","pinterest_ads","tiktok_ads","linkedin_ads","snapchat_ads","amazon_ads","openai_ads"]).pipe(E),status:we("status",["draft","paused","activating","active","pending_review","rejected","completed","archived","unknown"]).pipe(E),from:C("from").pipe(E),to:C("to").pipe(E),cursor:C("cursor").pipe(E),limit:Ue("limit").pipe(E)},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,aE({client:t.runtime.client,query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId),...O(e.accountId)?{accountId:f(e.accountId)}:{},...O(e.campaignId)?{campaignId:f(e.campaignId)}:{},...O(e.provider)?{provider:f(e.provider)}:{},...O(e.status)?{status:f(e.status)}:{},...O(e.from)?{from:f(e.from)}:{},...O(e.to)?{to:f(e.to)}:{},...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(P("List ad groups with a performance summary")),T("get-ad",{workspace:M,adId:te("ad-id").pipe(ne(a.check(D())))},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,cE({client:t.runtime.client,path:{adId:e.adId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(P("Read one ad with its creative and metrics")),T("list-creatives",{workspace:M,accountId:C("account-id").pipe(ue(a.check(D()))).pipe(E),adId:C("ad-id").pipe(ue(a.check(D()))).pipe(E),cursor:C("cursor").pipe(E),limit:Ue("limit").pipe(E)},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,pE({client:t.runtime.client,query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId),...O(e.accountId)?{accountId:f(e.accountId)}:{},...O(e.adId)?{adId:f(e.adId)}:{},...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(P("List ad creatives")),T("get-creative",{workspace:M,creativeId:te("creative-id").pipe(ne(a.check(D())))},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,uE({client:t.runtime.client,path:{creativeId:e.creativeId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(P("Read one ad creative")),T("list-insights",{workspace:M,accountId:te("account-id").pipe(ne(a.check(D()))),campaignId:C("campaign-id").pipe(ue(a.check(D()))).pipe(E),adGroupId:C("ad-group-id").pipe(ue(a.check(D()))).pipe(E),adId:C("ad-id").pipe(ue(a.check(D()))).pipe(E),from:C("from").pipe(E),to:C("to").pipe(E),level:we("level",["campaign","ad_group","ad"]).pipe(E),metrics:C("metrics").pipe(Sr(0)),cursor:C("cursor").pipe(E),limit:Ue("limit").pipe(E)},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,fE({client:t.runtime.client,path:{accountId:e.accountId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId),...O(e.campaignId)?{campaignId:f(e.campaignId)}:{},...O(e.adGroupId)?{adGroupId:f(e.adGroupId)}:{},...O(e.adId)?{adId:f(e.adId)}:{},...O(e.from)?{from:f(e.from)}:{},...O(e.to)?{to:f(e.to)}:{},...O(e.level)?{level:f(e.level)}:{},...e.metrics.length?{metrics:[...e.metrics]}:{},...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(P("Read one ad account's daily insights")),T("list-workspace-insights",{workspace:M,accountId:C("account-id").pipe(ue(a.check(D()))).pipe(E),campaignId:C("campaign-id").pipe(ue(a.check(D()))).pipe(E),adGroupId:C("ad-group-id").pipe(ue(a.check(D()))).pipe(E),adId:C("ad-id").pipe(ue(a.check(D()))).pipe(E),from:C("from").pipe(E),to:C("to").pipe(E),level:we("level",["campaign","ad_group","ad"]).pipe(E),metrics:C("metrics").pipe(Sr(0)),cursor:C("cursor").pipe(E),limit:Ue("limit").pipe(E)},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,lE({client:t.runtime.client,query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId),...O(e.accountId)?{accountId:f(e.accountId)}:{},...O(e.campaignId)?{campaignId:f(e.campaignId)}:{},...O(e.adGroupId)?{adGroupId:f(e.adGroupId)}:{},...O(e.adId)?{adId:f(e.adId)}:{},...O(e.from)?{from:f(e.from)}:{},...O(e.to)?{to:f(e.to)}:{},...O(e.level)?{level:f(e.level)}:{},...e.metrics.length?{metrics:[...e.metrics]}:{},...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(P("Read daily insights across selected ad accounts")),T("refresh-insights",{workspace:M,accountId:te("account-id").pipe(ne(a.check(D())))},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,mE({client:t.runtime.client,path:{accountId:e.accountId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(P("Queue an ad insight refresh")),T("activate-campaign",{workspace:M,accountId:te("account-id").pipe(ne(a.check(D()))),campaignId:te("campaign-id").pipe(ne(a.check(D()))),expectedRevision:Ue("expected-revision"),confirmation:we("confirmation",["activate_spend"]),idempotencyKey:rt},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,IE({client:t.runtime.client,path:{accountId:e.accountId,campaignId:e.campaignId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{expectedRevision:e.expectedRevision,confirmation:e.confirmation},headers:{"idempotency-key":f(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()}))})).pipe(P("Activate one paused boost campaign")),T("pause-campaign",{workspace:M,accountId:te("account-id").pipe(ne(a.check(D()))),campaignId:te("campaign-id").pipe(ne(a.check(D()))),expectedRevision:Ue("expected-revision"),idempotencyKey:rt},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,wE({client:t.runtime.client,path:{accountId:e.accountId,campaignId:e.campaignId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{expectedRevision:e.expectedRevision},headers:{"idempotency-key":f(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()}))})).pipe(P("Pause one campaign")),T("archive-campaign",{workspace:M,accountId:te("account-id").pipe(ne(a.check(D()))),campaignId:te("campaign-id").pipe(ne(a.check(D()))),expectedRevision:Ue("expected-revision"),idempotencyKey:rt},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,EE({client:t.runtime.client,path:{accountId:e.accountId,campaignId:e.campaignId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{expectedRevision:e.expectedRevision},headers:{"idempotency-key":f(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()}))})).pipe(P("Archive one campaign")),T("duplicate-campaign",{workspace:M,accountId:te("account-id").pipe(ne(a.check(D()))),campaignId:te("campaign-id").pipe(ne(a.check(D()))),name:C("name").pipe(E),idempotencyKey:rt},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,kE({client:t.runtime.client,path:{accountId:e.accountId,campaignId:e.campaignId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{...O(e.name)?{name:f(e.name)}:{}},headers:{"idempotency-key":f(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()}))})).pipe(P("Duplicate a campaign tree as paused")),T("create-ad-group",{workspace:M,accountId:te("account-id").pipe(ne(a.check(D()))),campaignId:te("campaign-id").pipe(ne(a.check(D()))),name:C("name"),idempotencyKey:rt,file:C("file").pipe(E,Ce("Read the body JSON from a file or stdin with -."))},(e)=>R(async()=>{let t=await Q(),r=f(e.file),n=r===void 0?{name:e.name}:await It(r);return t.runtime.decode(j,TE({client:t.runtime.client,path:{accountId:e.accountId,campaignId:e.campaignId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},body:n,headers:{"idempotency-key":f(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()}))})).pipe(P("Create a paused ad group under a campaign")),T("create-creative",{workspace:M,accountId:te("account-id").pipe(ne(a.check(D()))),actorAccountId:C("actor-account-id").pipe(ue(a.check(D()))),mediaId:C("media-id").pipe(ue(a.check(D()))),headline:C("headline").pipe(E),body:C("body").pipe(E),callToAction:C("call-to-action").pipe(E),destinationUrl:C("destination-url"),idempotencyKey:rt,file:C("file").pipe(E,Ce("Read the body JSON from a file or stdin with -."))},(e)=>R(async()=>{let t=await Q(),r=f(e.file),n=r===void 0?{actorAccountId:e.actorAccountId,mediaId:e.mediaId,...O(e.headline)?{headline:f(e.headline)}:{},...O(e.body)?{body:f(e.body)}:{},...O(e.callToAction)?{callToAction:f(e.callToAction)}:{},destinationUrl:e.destinationUrl}:await It(r);return t.runtime.decode(j,dE({client:t.runtime.client,path:{accountId:e.accountId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},body:n,headers:{"idempotency-key":f(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()}))})).pipe(P("Create a paused provider creative")),T("set-campaign-budget",{workspace:M,accountId:te("account-id").pipe(ne(a.check(D()))),campaignId:te("campaign-id").pipe(ne(a.check(D()))),expectedRevision:Ue("expected-revision"),idempotencyKey:rt,file:C("file").pipe(E,Ce("Read the body JSON from a file or stdin with -."))},(e)=>R(async()=>{let t=await Q(),r=f(e.file),n=r===void 0?{expectedRevision:e.expectedRevision}:await It(r);return t.runtime.decode(j,AE({client:t.runtime.client,path:{accountId:e.accountId,campaignId:e.campaignId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},body:n,headers:{"idempotency-key":f(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()}))})).pipe(P("Update a campaign budget")),T("set-ad-group-budget",{workspace:M,accountId:te("account-id").pipe(ne(a.check(D()))),adGroupId:te("ad-group-id").pipe(ne(a.check(D()))),expectedRevision:Ue("expected-revision"),idempotencyKey:rt,file:C("file").pipe(E,Ce("Read the body JSON from a file or stdin with -."))},(e)=>R(async()=>{let t=await Q(),r=f(e.file),n=r===void 0?{expectedRevision:e.expectedRevision}:await It(r);return t.runtime.decode(j,vE({client:t.runtime.client,path:{accountId:e.accountId,adGroupId:e.adGroupId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},body:n,headers:{"idempotency-key":f(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()}))})).pipe(P("Update an ad group budget")),T("set-ad-group-status",{workspace:M,accountId:te("account-id").pipe(ne(a.check(D()))),adGroupId:te("ad-group-id").pipe(ne(a.check(D()))),status:we("status",["active","paused","archived"]),expectedRevision:Ue("expected-revision"),idempotencyKey:rt},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,CE({client:t.runtime.client,path:{accountId:e.accountId,adGroupId:e.adGroupId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{status:e.status,expectedRevision:e.expectedRevision},headers:{"idempotency-key":f(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()}))})).pipe(P("Pause, resume, or archive an ad group")),T("set-ad-status",{workspace:M,accountId:te("account-id").pipe(ne(a.check(D()))),adId:te("ad-id").pipe(ne(a.check(D()))),status:we("status",["active","paused","archived"]),expectedRevision:Ue("expected-revision"),idempotencyKey:rt},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,PE({client:t.runtime.client,path:{accountId:e.accountId,adId:e.adId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{status:e.status,expectedRevision:e.expectedRevision},headers:{"idempotency-key":f(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()}))})).pipe(P("Pause, resume, or archive an ad")),T("attach-ad",{workspace:M,accountId:te("account-id").pipe(ne(a.check(D()))),adGroupId:te("ad-group-id").pipe(ne(a.check(D()))),name:C("name"),creativeId:C("creative-id").pipe(ue(a.check(D()))).pipe(E),idempotencyKey:rt,file:C("file").pipe(E,Ce("Read the body JSON from a file or stdin with -."))},(e)=>R(async()=>{let t=await Q(),r=f(e.file),n=r===void 0?{name:e.name,...O(e.creativeId)?{creativeId:f(e.creativeId)}:{}}:await It(r);return t.runtime.decode(j,OE({client:t.runtime.client,path:{accountId:e.accountId,adGroupId:e.adGroupId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},body:n,headers:{"idempotency-key":f(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()}))})).pipe(P("Attach a paused ad to an existing ad group")),T("create-boost",{workspace:M,accountId:te("account-id").pipe(ne(a.check(D()))),postId:C("post-id").pipe(ue(a.check(D()))),postTargetId:C("post-target-id").pipe(ue(a.check(D()))).pipe(E),actorAccountId:C("actor-account-id").pipe(ue(a.check(D()))).pipe(E),idempotencyKey:rt,file:C("file").pipe(E,Ce("Read the body JSON from a file or stdin with -."))},(e)=>R(async()=>{let t=await Q(),r=f(e.file),n=r===void 0?{postId:e.postId,...O(e.postTargetId)?{postTargetId:f(e.postTargetId)}:{},...O(e.actorAccountId)?{actorAccountId:f(e.actorAccountId)}:{}}:await It(r);return t.runtime.decode(j,bE({client:t.runtime.client,path:{accountId:e.accountId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},body:n,headers:{"idempotency-key":f(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()}))})).pipe(P("Create a paused Facebook Page post boost")),T("validate-boost",{workspace:M,accountId:te("account-id").pipe(ne(a.check(D()))),postId:C("post-id").pipe(ue(a.check(D()))),postTargetId:C("post-target-id").pipe(ue(a.check(D()))).pipe(E),actorAccountId:C("actor-account-id").pipe(ue(a.check(D()))).pipe(E),file:C("file").pipe(E,Ce("Read the body JSON from a file or stdin with -."))},(e)=>R(async()=>{let t=await Q(),r=f(e.file),n=r===void 0?{postId:e.postId,...O(e.postTargetId)?{postTargetId:f(e.postTargetId)}:{},...O(e.actorAccountId)?{actorAccountId:f(e.actorAccountId)}:{}}:await It(r);return t.runtime.decode(j,SE({client:t.runtime.client,path:{accountId:e.accountId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},body:n,...t.runtime.transport()}))})).pipe(P("Validate a Facebook Page post boost")),T("validate-campaign-plan",{workspace:M,name:C("name"),objective:we("objective",["awareness","traffic","engagement","leads","sales","app_promotion","video_views","reach","conversions","unknown"]),file:C("file").pipe(E,Ce("Read the body JSON from a file or stdin with -."))},(e)=>R(async()=>{let t=await Q(),r=f(e.file),n=r===void 0?{name:e.name,objective:e.objective}:await It(r);return t.runtime.decode(j,Yw({client:t.runtime.client,query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},body:n,...t.runtime.transport()}))})).pipe(P("Validate a unified campaign plan")),T("create-campaign-plan",{workspace:M,name:C("name"),objective:we("objective",["awareness","traffic","engagement","leads","sales","app_promotion","video_views","reach","conversions","unknown"]),idempotencyKey:rt,file:C("file").pipe(E,Ce("Read the body JSON from a file or stdin with -."))},(e)=>R(async()=>{let t=await Q(),r=f(e.file),n=r===void 0?{name:e.name,objective:e.objective}:await It(r);return t.runtime.decode(j,Xw({client:t.runtime.client,query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},body:n,headers:{"idempotency-key":f(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()}))})).pipe(P("Create a paused campaign plan")),T("get-campaign-plan",{workspace:M,planId:te("plan-id").pipe(ne(a.check(D())))},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,tE({client:t.runtime.client,path:{planId:e.planId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(P("Read a campaign plan and its target operations")),T("list-campaign-plans",{workspace:M,status:we("status",["queued","creating","partial","succeeded","failed","unresolved"]).pipe(E),cursor:C("cursor").pipe(E),limit:Ue("limit").pipe(E)},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,eE({client:t.runtime.client,query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId),...O(e.status)?{status:f(e.status)}:{},...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(P("List campaign plans")),T("get-operation",{workspace:M,accountId:te("account-id").pipe(ne(a.check(D()))),operationId:te("operation-id").pipe(ne(a.check(D())))},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,xE({client:t.runtime.client,path:{accountId:e.accountId,operationId:e.operationId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(P("Read one ad operation")),T("get-spend-policy",{workspace:M,accountId:te("account-id").pipe(ne(a.check(D())))},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,hE({client:t.runtime.client,path:{accountId:e.accountId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(P("Read an ad account's spend policy")),T("update-spend-policy",{workspace:M,accountId:te("account-id").pipe(ne(a.check(D()))),expectedRevision:Ue("expected-revision"),file:C("file").pipe(E,Ce("Read the body JSON from a file or stdin with -."))},(e)=>R(async()=>{let t=await Q(),r=f(e.file),n=r===void 0?{expectedRevision:e.expectedRevision}:await It(r);return t.runtime.decode(j,yE({client:t.runtime.client,path:{accountId:e.accountId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},body:n,...t.runtime.transport()}))})).pipe(P("Replace an ad account's spend policy")),T("set-kill-switch",{workspace:M,accountId:te("account-id").pipe(ne(a.check(D()))),active:ft("active").pipe(Xe(!1)),reason:C("reason").pipe(E)},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,gE({client:t.runtime.client,path:{accountId:e.accountId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{active:e.active,...O(e.reason)?{reason:f(e.reason)}:{}},...t.runtime.transport()}))})).pipe(P("Set or clear an ad account kill switch"))];var Dq=T("ads").pipe(P("Read and manage ad accounts, campaigns, and boosts."),Je(Uq));var Lq=[T("accounts").pipe(P(""),Je([T("list",{workspace:M,accountId:C("account-id").pipe(Sr(0)),platform:we("platform",["bluesky","facebook","instagram","linkedin","pinterest","reddit","snapchat","tiktok","threads","x","youtube","google_business","meta_ads","google_ads","reddit_ads","pinterest_ads","tiktok_ads","linkedin_ads","snapchat_ads","amazon_ads","openai_ads"]).pipe(E),from:C("from").pipe(E),to:C("to").pipe(E),timezone:C("timezone").pipe(E),granularity:we("granularity",["day","total"]).pipe(E),metrics:C("metrics").pipe(Sr(0)),cursor:C("cursor").pipe(E),limit:Ue("limit").pipe(E)},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,gw({client:t.runtime.client,path:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},query:{...e.accountId.length?{accountId:[...e.accountId]}:{},...O(e.platform)?{platform:f(e.platform)}:{},...O(e.from)?{from:f(e.from)}:{},...O(e.to)?{to:f(e.to)}:{},...O(e.timezone)?{timezone:f(e.timezone)}:{},...O(e.granularity)?{granularity:f(e.granularity)}:{},...e.metrics.length?{metrics:[...e.metrics]}:{},...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(P("List account analytics summaries")),T("get",{workspace:M,accountId:te("account-id").pipe(ne(a.check(D()))),from:C("from").pipe(E),to:C("to").pipe(E),timezone:C("timezone").pipe(E),granularity:we("granularity",["day","total"]).pipe(E),metrics:C("metrics").pipe(Sr(0))},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,xw({client:t.runtime.client,path:{accountId:e.accountId,workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},query:{...O(e.from)?{from:f(e.from)}:{},...O(e.to)?{to:f(e.to)}:{},...O(e.timezone)?{timezone:f(e.timezone)}:{},...O(e.granularity)?{granularity:f(e.granularity)}:{},...e.metrics.length?{metrics:[...e.metrics]}:{}},...t.runtime.transport()}))})).pipe(P("Read one account's analytics"))])),T("posts").pipe(P(""),Je([T("get",{workspace:M,postId:te("post-id").pipe(ne(a.check(D()))),targetId:C("target-id").pipe(ue(a.check(D()))).pipe(E),from:C("from").pipe(E),to:C("to").pipe(E),timezone:C("timezone").pipe(E),granularity:we("granularity",["day","total"]).pipe(E),metrics:C("metrics").pipe(Sr(0))},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,hw({client:t.runtime.client,path:{postId:e.postId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId),...O(e.targetId)?{targetId:f(e.targetId)}:{},...O(e.from)?{from:f(e.from)}:{},...O(e.to)?{to:f(e.to)}:{},...O(e.timezone)?{timezone:f(e.timezone)}:{},...O(e.granularity)?{granularity:f(e.granularity)}:{},...e.metrics.length?{metrics:[...e.metrics]}:{}},...t.runtime.transport()}))})).pipe(P("Read target-scoped post analytics totals")),T("series",{workspace:M,postId:te("post-id").pipe(ne(a.check(D()))),targetId:C("target-id").pipe(ue(a.check(D()))).pipe(E),from:C("from").pipe(E),to:C("to").pipe(E),timezone:C("timezone").pipe(E),granularity:we("granularity",["day","total"]).pipe(E),metrics:C("metrics").pipe(Sr(0))},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,yw({client:t.runtime.client,path:{postId:e.postId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId),...O(e.targetId)?{targetId:f(e.targetId)}:{},...O(e.from)?{from:f(e.from)}:{},...O(e.to)?{to:f(e.to)}:{},...O(e.timezone)?{timezone:f(e.timezone)}:{},...O(e.granularity)?{granularity:f(e.granularity)}:{},...e.metrics.length?{metrics:[...e.metrics]}:{}},...t.runtime.transport()}))})).pipe(P("Read daily post analytics series"))])),T("capabilities").pipe(P(""),Je([T("get",{workspace:M},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,Sw({client:t.runtime.client,path:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(P("Read the analytics metric catalog and provider support"))])),T("refreshes").pipe(P(""),Je([T("create",{workspaceId:C("workspace-id").pipe(ue(a.check(D()))),postId:C("post-id").pipe(ue(a.check(D()))).pipe(E),targetId:C("target-id").pipe(ue(a.check(D()))).pipe(E),metrics:we("metrics",["impressions","reach","views","likes","comments","shares","saves","clicks","link_clicks","profile_visits","page_views","follows","followers","follower_gained","follower_lost","watch_time_ms","avg_watch_time_ms","completion_rate","engagement","engagement_rate"]).pipe(Sr(0))},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,bw({client:t.runtime.client,body:{workspaceId:e.workspaceId,...O(e.postId)?{postId:f(e.postId)}:{},...O(e.targetId)?{targetId:f(e.targetId)}:{},...e.metrics.length?{metrics:[...e.metrics]}:{}},...t.runtime.transport()}))})).pipe(P("Queue a priority analytics refresh")),T("get",{workspace:M,refreshId:te("refresh-id").pipe(ne(a.check(D())))},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,Iw({client:t.runtime.client,path:{refreshId:e.refreshId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(P("Read an analytics refresh status"))]))];var Mq=T("analytics").pipe(P("Read post, account, and refresh analytics."),Je(Lq));var Fq=[T("list",{workspace:M,cursor:C("cursor").pipe(E),limit:Ue("limit").pipe(E)},(e)=>R(async()=>{let t=await Q(void 0,"human");return t.runtime.decode(j,KI({client:t.runtime.client,path:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},query:{...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(P("List workspace API keys")),T("create",{workspace:M,name:C("name"),scopes:we("scope",["read","publish","engage","ads_read","ads_manage"]).pipe(Sr(0)),expiresAt:C("expires-at").pipe(E)},(e)=>R(async()=>{let t=await Q(void 0,"human");return t.runtime.decode(j,$I({client:t.runtime.client,path:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{name:e.name,...e.scopes.length?{scopes:[...e.scopes]}:{},...O(e.expiresAt)?{expiresAt:f(e.expiresAt)}:{}},...t.runtime.transport()}))})).pipe(P("Create a workspace API key")),T("get",{workspace:M,keyId:te("key-id").pipe(ne(a.check(D())))},(e)=>R(async()=>{let t=await Q(void 0,"human");return t.runtime.decode(j,WI({client:t.runtime.client,path:{keyId:e.keyId,workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(P("Read API key metadata")),T("update",{workspace:M,keyId:te("key-id").pipe(ne(a.check(D()))),name:C("name").pipe(E),scopes:we("scope",["read","publish","engage","ads_read","ads_manage"]).pipe(Sr(0))},(e)=>R(async()=>{let t=await Q(void 0,"human");return t.runtime.decode(j,GI({client:t.runtime.client,path:{keyId:e.keyId,workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{...O(e.name)?{name:f(e.name)}:{},...e.scopes.length?{scopes:[...e.scopes]}:{}},...t.runtime.transport()}))})).pipe(P("Rename an API key or change its access")),T("revoke",{workspace:M,keyId:te("key-id").pipe(ne(a.check(D())))},(e)=>R(async()=>{let t=await Q(void 0,"human");return t.runtime.decode(j,qI({client:t.runtime.client,path:{keyId:e.keyId,workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(P("Revoke a workspace API key"))];var Nq=T("api-keys").pipe(P("Manage workspace API keys as a signed-in owner."),Je(Fq));var Bq=[T("list",{workspace:M,action:we("action",["workspace.updated","workspace.archived","workspace.member.role_updated","workspace.member.removed","workspace.invite.created","workspace.invite.resent","workspace.invite.revoked","workspace.invite.accepted","workspace.invite.declined","api_key.created","api_key.updated","api_key.revoked","webhook.endpoint.created","webhook.endpoint.updated","webhook.endpoint.deleted","webhook.delivery.replayed","account.connected","account.reconnected","account.disconnected","account.enabled","account.disabled","account.moved","profile.created","profile.updated","profile.archived","queue.created","queue.updated","queue.paused","queue.resumed","queue.archived","queue.slots.replaced","queue.skip.created","queue.skip.deleted","queue.blackout.created","queue.blackout.deleted","billing.subscription.updated","billing.credit.topped_up","billing.spend_controls.updated"]).pipe(E),targetKind:we("target-kind",["workspace","workspace_member","workspace_invite","workspace_profile","api_key","webhook_endpoint","webhook_delivery","integration_connection","provider_account","schedule_queue","schedule_queue_skip","schedule_queue_blackout","workspace_billing"]).pipe(E),targetId:C("target-id").pipe(ue(a.check(D()))).pipe(E),actorType:we("actor-type",["user","api_key"]).pipe(E),actorId:C("actor-id").pipe(ue(a.check(D()))).pipe(E),profileId:C("profile-id").pipe(ue(a.check(D()))).pipe(E),from:C("from").pipe(E),to:C("to").pipe(E),cursor:C("cursor").pipe(E),limit:Ue("limit").pipe(E)},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,RE({client:t.runtime.client,path:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},query:{...O(e.action)?{action:f(e.action)}:{},...O(e.targetKind)?{targetKind:f(e.targetKind)}:{},...O(e.targetId)?{targetId:f(e.targetId)}:{},...O(e.actorType)?{actorType:f(e.actorType)}:{},...O(e.actorId)?{actorId:f(e.actorId)}:{},...O(e.profileId)?{profileId:f(e.profileId)}:{},...O(e.from)?{from:f(e.from)}:{},...O(e.to)?{to:f(e.to)}:{},...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(P("List workspace audit events")),T("get",{workspace:M,eventId:te("event-id").pipe(ne(a.check(D())))},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,_E({client:t.runtime.client,path:{eventId:e.eventId,workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(P("Read one audit event")),T("actions").pipe(P(""),Je([T("list",{},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,VE({client:t.runtime.client,...t.runtime.transport()}))})).pipe(P("List documented audit actions"))]))];var Kq=T("audit").pipe(P("Read the workspace audit history."),Je(Bq));var $q=Ue("timeout").pipe(Xe(600),Ce("Maximum seconds to wait for sign-in.")),q5=T("login",{browser:Ju,timeout:$q,noWait:ft("no-wait").pipe(Xe(!1),Ce("Print the verification URL and code, then exit. Finish with `pnio auth complete`."))},(e)=>R(async()=>{let t=Ei(),r=await Cq(t);if(console.error(`Open ${r.url} and confirm code ${r.userCode}.`),e.browser)iy(r.completeUrl);if(e.noWait)return r;let n=await SA(t,{timeoutMs:e.timeout*1000});return Ea({baseUrl:t,accessToken:n}).me.get()})).pipe(P("Sign in with a WorkOS device code, or hand off with --no-wait.")),W5=T("complete",{timeout:$q},(e)=>R(async()=>{let t=Ei(),r=await SA(t,{timeoutMs:e.timeout*1000});return Ea({baseUrl:t,accessToken:r}).me.get()})).pipe(P("Finish a sign-in started with `pnio auth login --no-wait`.")),G5=T("status",{},()=>R(async()=>(await fo(void 0,"human")).me.get())).pipe(P("Show the current PubNio account.")),z5=T("logout",{},()=>R(async()=>(await Rq(Ei()),{signedOut:!0}))).pipe(P("Revoke the CLI session and clear local credentials.")),qq=T("auth").pipe(P("Manage your CLI session."),Je([q5,W5,G5,z5]));var Wq=[T("status",{workspace:M},(e)=>R(async()=>{let t=await Q(void 0,"human");return t.runtime.decode(j,qE({client:t.runtime.client,path:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(P("Get workspace billing status")),T("usage",{workspace:M,from:C("from").pipe(E),to:C("to").pipe(E),meter:we("meter",["confirmed_publish","x_passthrough","managed_ad","inbox_reply","automation_run"]).pipe(E),provider:we("provider",["bluesky","facebook","instagram","linkedin","pinterest","reddit","snapchat","tiktok","threads","x","youtube","google_business"]).pipe(E)},(e)=>R(async()=>{let t=await Q(void 0,"human");return t.runtime.decode(j,WE({client:t.runtime.client,path:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},query:{...O(e.from)?{from:f(e.from)}:{},...O(e.to)?{to:f(e.to)}:{},...O(e.meter)?{meter:f(e.meter)}:{},...O(e.provider)?{provider:f(e.provider)}:{}},...t.runtime.transport()}))})).pipe(P("Get workspace daily usage summary")),T("ledger",{workspace:M,kind:we("kind",["top_up","auto_top_up","overage_debit","x_passthrough_debit","refund","adjustment"]).pipe(E),from:C("from").pipe(E),to:C("to").pipe(E),cursor:C("cursor").pipe(E),limit:Ue("limit").pipe(E)},(e)=>R(async()=>{let t=await Q(void 0,"human");return t.runtime.decode(j,GE({client:t.runtime.client,path:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},query:{...O(e.kind)?{kind:f(e.kind)}:{},...O(e.from)?{from:f(e.from)}:{},...O(e.to)?{to:f(e.to)}:{},...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(P("List workspace prepaid credit ledger")),T("plans",{},(e)=>R(async()=>{let t=await Q(void 0,"human");return t.runtime.decode(j,HE({client:t.runtime.client,...t.runtime.transport()}))})).pipe(P("List public billing plans")),T("top-up",{workspace:M,idempotencyKey:rt,file:C("file").pipe(E,Ce("Read the body JSON from a file or stdin with -."))},(e)=>R(async()=>{let t=await Q(void 0,"human"),r=f(e.file),n=r===void 0?{}:await It(r);return t.runtime.decode(j,zE({client:t.runtime.client,path:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},body:n,headers:{"idempotency-key":f(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()}))})).pipe(P("Create a hosted checkout session for a plan upgrade or credit top-up")),T("portal",{workspace:M,returnUrl:C("return-url").pipe(E)},(e)=>R(async()=>{let t=await Q(void 0,"human");return t.runtime.decode(j,jE({client:t.runtime.client,path:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{...O(e.returnUrl)?{returnUrl:f(e.returnUrl)}:{}},...t.runtime.transport()}))})).pipe(P("Create a hosted billing portal session")),T("spend-cap",{workspace:M,version:Ue("version"),file:C("file").pipe(E,Ce("Read the body JSON from a file or stdin with -."))},(e)=>R(async()=>{let t=await Q(void 0,"human"),r=f(e.file),n=r===void 0?{version:e.version}:await It(r);return t.runtime.decode(j,QE({client:t.runtime.client,path:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},body:n,...t.runtime.transport()}))})).pipe(P("Update monthly spend cap"))];var Gq=T("billing").pipe(P("Manage workspace billing, usage, and checkout."),Je(Wq));var zq=[T("catalog",{},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,dw({client:t.runtime.client,...t.runtime.transport()}))})).pipe(P("Read the static provider capability catalog")),T("get",{},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,cw({client:t.runtime.client,...t.runtime.transport()}))})).pipe(P("Read the publish capability catalog")),T("list",{workspace:M,profileId:C("profile-id").pipe(ue(a.check(D()))).pipe(E),accountId:C("account-id").pipe(ue(a.check(D()))).pipe(E),capability:we("capability",["publish","read_insights","manage_comments","send_messages","ads_read","ads_write","ads_spend"]).pipe(E)},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,pw({client:t.runtime.client,query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId),...O(e.profileId)?{profileId:f(e.profileId)}:{},...O(e.accountId)?{accountId:f(e.accountId)}:{},...O(e.capability)?{capability:f(e.capability)}:{}},...t.runtime.transport()}))})).pipe(P("List computed capabilities for connected accounts"))];var jq=T("capabilities").pipe(P("Read publishing capabilities, placements, and limits."),Je(zq));var Qq=[T("create",{workspace:M,accountId:C("account-id").pipe(ue(a.check(D()))).pipe(E),provider:we("provider",["bluesky","facebook","instagram","linkedin","pinterest","reddit","snapchat","tiktok","threads","x","youtube","google_business"]).pipe(E),target:C("target"),targetKind:we("target-kind",["post","comment"]).pipe(E),text:C("text"),idempotencyKey:rt},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,b6({client:t.runtime.client,query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{...O(e.accountId)?{accountId:f(e.accountId)}:{},...O(e.provider)?{provider:f(e.provider)}:{},target:e.target,...O(e.targetKind)?{targetKind:f(e.targetKind)}:{},text:e.text},headers:{"idempotency-key":f(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()}))})).pipe(P("Comment on or reply to a provider post"))];var Hq=T("comments").pipe(P("Create comments where a destination supports them."),Je(Qq));var Vq=[T("get",{},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,uw({client:t.runtime.client,...t.runtime.transport()}))})).pipe(P("Read documented API limits"))];var Jq=T("limits").pipe(P("Read workspace publishing limits."),Je(Vq));var Yq=[T("capabilities",{workspace:M,accountId:C("account-id").pipe(ue(a.check(D()))).pipe(E)},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,Fw({client:t.runtime.client,query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId),...O(e.accountId)?{accountId:f(e.accountId)}:{}},...t.runtime.transport()}))})).pipe(P("Read per-account inbox channel capabilities")),T("unread-count",{workspace:M},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,Mw({client:t.runtime.client,query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(P("Count conversations with at least one unread inbound message")),T("conversations").pipe(P(""),Je([T("list",{workspace:M,accountId:C("account-id").pipe(ue(a.check(D()))).pipe(E),provider:we("provider",["bluesky","facebook","instagram","linkedin","pinterest","reddit","snapchat","tiktok","threads","x","youtube","google_business","meta_ads","google_ads","reddit_ads","pinterest_ads","tiktok_ads","linkedin_ads","snapchat_ads","amazon_ads","openai_ads"]).pipe(E),status:we("status",["active","archived"]).pipe(E),folder:we("folder",["inbox","message_request","spam","other"]).pipe(E),unread:we("unread",["true","false"]).pipe(E),search:C("search").pipe(E),cursor:C("cursor").pipe(E),limit:Ue("limit").pipe(E)},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,ww({client:t.runtime.client,query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId),...O(e.accountId)?{accountId:f(e.accountId)}:{},...O(e.provider)?{provider:f(e.provider)}:{},...O(e.status)?{status:f(e.status)}:{},...O(e.folder)?{folder:f(e.folder)}:{},...O(e.unread)?{unread:f(e.unread)}:{},...O(e.search)?{search:f(e.search)}:{},...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(P("List DM conversations newest first")),T("get",{workspace:M,conversationId:te("conversation-id").pipe(ne(a.check(D())))},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,Ew({client:t.runtime.client,path:{conversationId:e.conversationId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(P("Read one conversation and reply window")),T("update",{workspace:M,conversationId:te("conversation-id").pipe(ne(a.check(D()))),status:we("status",["active","archived"]).pipe(E),read:ft("read").pipe(Xe(!1))},(e)=>R(async()=>{let t=await Q();if(!(O(e.status)||e.read))throw new Le("Provide --status or --read.");return t.runtime.decode(j,kw({client:t.runtime.client,path:{conversationId:e.conversationId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{...O(e.status)?{status:f(e.status)}:{},...e.read?{read:!0}:{}},...t.runtime.transport()}))})).pipe(P("Mark read or archive a conversation"))])),T("messages").pipe(P(""),Je([T("list",{workspace:M,conversationId:te("conversation-id").pipe(ne(a.check(D()))),order:we("order",["oldest","newest"]).pipe(E),cursor:C("cursor").pipe(E),limit:Ue("limit").pipe(E)},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,Aw({client:t.runtime.client,path:{conversationId:e.conversationId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId),...O(e.order)?{order:f(e.order)}:{},...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(P("Page messages oldest or newest first")),T("send",{workspace:M,conversationId:te("conversation-id").pipe(ne(a.check(D()))),text:C("text"),idempotencyKey:rt},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,vw({client:t.runtime.client,path:{conversationId:e.conversationId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{text:e.text},headers:{"idempotency-key":f(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()}))})).pipe(P("Send a text reply inside the provider window"))])),T("comments").pipe(P(""),Je([T("list",{workspace:M,accountId:C("account-id").pipe(ue(a.check(D()))).pipe(E),postId:C("post-id").pipe(ue(a.check(D()))).pipe(E),providerPostId:C("provider-post-id").pipe(E),unread:we("unread",["true","false"]).pipe(E),cursor:C("cursor").pipe(E),limit:Ue("limit").pipe(E)},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,Cw({client:t.runtime.client,query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId),...O(e.accountId)?{accountId:f(e.accountId)}:{},...O(e.postId)?{postId:f(e.postId)}:{},...O(e.providerPostId)?{providerPostId:f(e.providerPostId)}:{},...O(e.unread)?{unread:f(e.unread)}:{},...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(P("List comment threads with counts")),T("get",{workspace:M,threadId:te("thread-id").pipe(ne(a.check(D()))),cursor:C("cursor").pipe(E),limit:Ue("limit").pipe(E)},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,Tw({client:t.runtime.client,path:{threadId:e.threadId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId),...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(P("Read a comment thread and its comments")),T("reply",{workspace:M,commentId:te("comment-id").pipe(ne(a.check(D()))),text:C("text"),idempotencyKey:rt},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,Ow({client:t.runtime.client,path:{commentId:e.commentId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{text:e.text},headers:{"idempotency-key":f(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()}))})).pipe(P("Reply to a comment")),T("moderate",{workspace:M,commentId:te("comment-id").pipe(ne(a.check(D()))),hidden:ft("hidden").pipe(Xe(!1)),liked:ft("liked").pipe(Xe(!1))},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,Rw({client:t.runtime.client,path:{commentId:e.commentId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{...e.hidden?{hidden:!0}:{},...e.liked?{liked:!0}:{}},...t.runtime.transport()}))})).pipe(P("Hide, unhide, like, or unlike a comment")),T("delete",{workspace:M,commentId:te("comment-id").pipe(ne(a.check(D())))},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,Pw({client:t.runtime.client,path:{commentId:e.commentId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(P("Delete a comment where the provider supports it"))])),T("mentions").pipe(P(""),Je([T("list",{workspace:M,accountId:C("account-id").pipe(ue(a.check(D()))).pipe(E),provider:we("provider",["bluesky","facebook","instagram","linkedin","pinterest","reddit","snapchat","tiktok","threads","x","youtube","google_business","meta_ads","google_ads","reddit_ads","pinterest_ads","tiktok_ads","linkedin_ads","snapchat_ads","amazon_ads","openai_ads"]).pipe(E),cursor:C("cursor").pipe(E),limit:Ue("limit").pipe(E)},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,_w({client:t.runtime.client,query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId),...O(e.accountId)?{accountId:f(e.accountId)}:{},...O(e.provider)?{provider:f(e.provider)}:{},...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(P("List mentions of a connected account")),T("reply",{workspace:M,mentionId:te("mention-id").pipe(ne(a.check(D()))),text:C("text"),idempotencyKey:rt},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,Uw({client:t.runtime.client,path:{mentionId:e.mentionId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{text:e.text},headers:{"idempotency-key":f(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()}))})).pipe(P("Reply to a mention where supported"))])),T("sync").pipe(P(""),Je([T("start",{workspaceId:C("workspace-id").pipe(ue(a.check(D()))),accountId:C("account-id").pipe(ue(a.check(D()))).pipe(E)},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,Nw({client:t.runtime.client,body:{workspaceId:e.workspaceId,...O(e.accountId)?{accountId:f(e.accountId)}:{}},...t.runtime.transport()}))})).pipe(P("Queue a bounded inbox sync")),T("status",{workspace:M,syncRunId:te("sync-run-id").pipe(ne(a.check(D())))},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,Bw({client:t.runtime.client,path:{syncRunId:e.syncRunId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(P("Read a sync run and current inbox counts"))])),T("attachments").pipe(P(""),Je([T("get",{workspace:M,attachmentId:te("attachment-id").pipe(ne(a.check(D())))},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,Kw({client:t.runtime.client,path:{attachmentId:e.attachmentId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(P("Stream an inbound attachment"))])),T("reviews").pipe(P(""),Je([T("list",{workspace:M,accountId:C("account-id").pipe(ue(a.check(D()))).pipe(E),includeDeleted:we("include-deleted",["true","false"]).pipe(E),cursor:C("cursor").pipe(E),limit:Ue("limit").pipe(E)},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,Dw({client:t.runtime.client,query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId),...O(e.accountId)?{accountId:f(e.accountId)}:{},...O(e.includeDeleted)?{includeDeleted:f(e.includeDeleted)}:{},...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(P("List stored Google Business Profile reviews newest first")),T("get",{workspace:M,reviewId:te("review-id").pipe(ne(a.check(D())))},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,Lw({client:t.runtime.client,path:{reviewId:e.reviewId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(P("Read one stored Google Business Profile review")),T("reply",{workspace:M,reviewId:te("review-id").pipe(ne(a.check(D()))),text:C("text"),idempotencyKey:rt},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,S6({client:t.runtime.client,path:{reviewId:e.reviewId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{text:e.text},headers:{"idempotency-key":f(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()}))})).pipe(P("Reply to a Google Business Profile review"))]))];var Zq=T("inbox").pipe(P("Read and reply from the unified inbox."),Je(Yq));var Xq=[T("get-account",{workspace:M,accountId:te("account-id").pipe(ne(a.check(D()))),includeAdAccounts:we("include-ad-accounts",["true","false"]).pipe(E)},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,tw({client:t.runtime.client,path:{accountId:e.accountId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId),...O(e.includeAdAccounts)?{includeAdAccounts:f(e.includeAdAccounts)}:{}},...t.runtime.transport()}))})).pipe(P("Check account readiness")),T("bluesky-session",{workspace:M,handle:C("handle"),appPassword:C("app-password"),service:C("service").pipe(E),accountId:C("account-id").pipe(ue(a.check(D()))).pipe(E),profileId:C("profile-id").pipe(ue(a.check(D()))).pipe(E)},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,x6({client:t.runtime.client,query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{handle:e.handle,appPassword:e.appPassword,...O(e.service)?{service:f(e.service)}:{},...O(e.accountId)?{accountId:f(e.accountId)}:{},...O(e.profileId)?{profileId:f(e.profileId)}:{}},...t.runtime.transport()}))})).pipe(P("Connect Bluesky with an app password")),T("get-instagram-audio",{workspace:M,accountId:te("account-id").pipe(ne(a.check(D()))),audioId:te("audio-id")},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,rw({client:t.runtime.client,path:{accountId:e.accountId,audioId:e.audioId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(P("Read current Instagram audio metadata and refresh its preview URL")),T("move-account",{workspace:M,accountId:te("account-id").pipe(ne(a.check(D()))),profileId:C("profile-id").pipe(ue(a.check(D())))},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,ew({client:t.runtime.client,path:{accountId:e.accountId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{profileId:e.profileId},...t.runtime.transport()}))})).pipe(P("Move an account to another profile"))];var xp=te("account-id").pipe(ne(xu.fields.accountId)),t1=we("login-method",th.literals).pipe(E),r1=Ue("timeout").pipe(Xe(120),Ce("Maximum seconds to wait for consent."));async function n1(e,t,r){let n=Date.now()+Math.max(0,r)*1000;for(;;){let o=await e.accounts.connectionStatus(t);if(o.status!=="pending")return o;if(Date.now()>=n)return{...o,timedOut:!0};await Bun.sleep(1000)}}function o1(e,t,r){if(new URL(e.url).origin!==t)throw Error("PubNio returned an invalid connection URL.");if(console.error(`Open the URL as the same PubNio user, then check \`pnio integrations wait ${e.attemptId}\`.`),r)iy(e.url);return e}var j5=T("list",{workspace:M},({workspace:e})=>R(async()=>(await Ne(f(e))).accounts.list())).pipe(P("List publishing destinations.")),Q5=T("connect",{provider:O8("provider",xn.literals),workspace:M,browser:Ju,loginMethod:t1,wait:ft("wait").pipe(Xe(!1),Ce("Wait for consent before returning.")),timeout:r1},(e)=>R(async()=>{let t=Ei(),r=await Ne(f(e.workspace),{origin:t}),n=await r.accounts.prepareConnection(e.provider,f(e.loginMethod)),o=o1(n,t,e.browser);if(!e.wait)return o;let i=await n1(r,n.attemptId,e.timeout);if(i.status!=="connected")process.exitCode=1;return{...o,connection:i}})).pipe(P("Connect Facebook, Instagram, or TikTok.")),H5=T("wait",{attempt:te("attempt-id").pipe(ne(Bb.fields.attemptId)),workspace:M,timeout:r1},(e)=>R(async()=>{let t=await Ne(f(e.workspace)),r=await n1(t,e.attempt,e.timeout);if(r.status!=="connected")process.exitCode=1;return r})).pipe(P("Wait for an account connection to finish.")),V5=T("status",{attempt:te("attempt-id").pipe(ne(Bb.fields.attemptId)),workspace:M},({attempt:e,workspace:t})=>R(async()=>(await Ne(f(t))).accounts.connectionStatus(e))).pipe(P("Check whether social account OAuth completed.")),J5=T("health",{account:xp,workspace:M},({account:e,workspace:t})=>R(async()=>(await Ne(f(t))).accounts.get(e))).pipe(P("Check account readiness using the last recorded grant.")),Y5=T("instagram-quota",{account:xp,workspace:M},({account:e,workspace:t})=>R(async()=>(await Ne(f(t))).accounts.instagramPublishingLimit(e))).pipe(P("Read the Instagram account\u2019s current publishing quota.")),Z5=T("instagram-audio",{account:xp,workspace:M,type:we("type",nh.literals).pipe(Xe("music")),query:C("query").pipe(E)},({account:e,workspace:t,type:r,query:n})=>R(async()=>(await Ne(f(t))).accounts.searchInstagramAudio(e,{audioType:r,q:f(n)}))).pipe(P("Search Instagram\u2019s catalog or list trending audio.")),X5=T("instagram-audio-info",{account:xp,workspace:M,audioId:te("audio-id").pipe(ne(ep))},({account:e,workspace:t,audioId:r})=>R(async()=>(await Ne(f(t))).accounts.getInstagramAudio(e,r))).pipe(P("Read current metadata for an Instagram audio track.")),eZ=T("reconnect",{account:xp,workspace:M,browser:Ju,loginMethod:t1},(e)=>R(async()=>{let t=Ei(),r=await Ne(f(e.workspace),{origin:t});return o1(await r.accounts.reconnect(e.account,f(e.loginMethod)),t,e.browser)})).pipe(P("Reauthorize a connected account while keeping its ID.")),tZ=T("disconnect",{connection:te("connection-id").pipe(ne(LD.fields.connectionId)),workspace:M,yes:ft("yes").pipe(Xe(!1))},({connection:e,workspace:t,yes:r})=>R(async()=>{if(!r)throw new Le("Pass --yes to disconnect the grant and disable all accounts using it.");return(await Ne(f(t))).accounts.disconnect(e)})).pipe(P("Remove a grant and disable its accounts."));function e1(e){return T(e,{account:xp,workspace:M},({account:t,workspace:r})=>R(async()=>(await Ne(f(r))).accounts.setEnabled({id:t,enabled:e==="enable"}))).pipe(P(`${e==="enable"?"Enable":"Disable"} a publishing destination.`))}var i1=T("integrations").pipe(P("Connect and select publishing destinations."),Je([j5,Q5,H5,V5,J5,Y5,Z5,X5,eZ,tZ,e1("enable"),e1("disable"),...Xq]));import{writeFile as rZ}from"fs/promises";var s1=[T("status",{workspace:M,mediaId:te("media-id").pipe(ne(a.check(D())))},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,Th({client:t.runtime.client,path:{mediaId:e.mediaId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(P("Get workspace media intake status")),T("get",{workspace:M,mediaId:te("media-id").pipe(ne(a.check(D())))},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,mw({client:t.runtime.client,path:{mediaId:e.mediaId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(P("Get workspace media metadata")),T("list",{workspace:M,cursor:C("cursor").pipe(E),limit:Ue("limit").pipe(E),type:we("type",["image","video","document"]).pipe(E)},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,lw({client:t.runtime.client,query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId),...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{},...O(e.type)?{type:f(e.type)}:{}},...t.runtime.transport()}))})).pipe(P("List ready workspace media")),T("delete",{workspace:M,mediaId:te("media-id").pipe(ne(a.check(D())))},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,fw({client:t.runtime.client,path:{mediaId:e.mediaId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(P("Delete unused workspace media"))];var a1=te("media-id").pipe(ne(yn)),nZ=T("upload",{file:te("file"),workspace:M,mime:we("mime",Zc.literals).pipe(E),key:rt},(e)=>R(async()=>{let t=Bun.file(e.file);if(!await t.exists())throw new Le("Choose an existing media file.");return(await Ne(f(e.workspace))).media.upload(t,{mimeType:f(e.mime),idempotencyKey:f(e.key)})})).pipe(P("Upload an image, video, or document for use in posts.")),oZ=T("import",{url:te("url"),workspace:M,key:rt},(e)=>R(async()=>(await Ne(f(e.workspace))).media.importUrl(e.url,{idempotencyKey:f(e.key)}))).pipe(P("Copy a public or signed HTTPS URL into private workspace media.")),iZ=T("wait",{mediaId:a1,workspace:M,timeoutSeconds:Ue("timeout").pipe(Xe(30),Ce("Maximum seconds to wait for media readiness."))},(e)=>R(async()=>{if(e.timeoutSeconds<0||e.timeoutSeconds>300)throw new Le("Use a timeout between 0 and 300 seconds.");let t=await(await Ne(f(e.workspace))).media.wait(e.mediaId,{timeoutMs:e.timeoutSeconds*1000});if(t.status!=="ready")process.exitCode=1;return t})).pipe(P("Wait for media readiness and return ready, failed, or timeout.")),sZ=T("download",{mediaId:a1,workspace:M,out:C("out")},(e)=>R(async()=>{let t=await(await Ne(f(e.workspace))).media.download(e.mediaId);return await rZ(e.out,new Uint8Array(await t.arrayBuffer()),{flag:"wx"}),{path:e.out,sizeBytes:t.size}})).pipe(P("Save private media to a new local file.")),c1=T("media").pipe(P("Manage workspace media files."),Je([nZ,oZ,...s1,iZ,sZ]));var p1=[T("get",{workspace:M,postId:te("post-id").pipe(ne(a.check(D())))},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,Ww({client:t.runtime.client,path:{postId:e.postId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(P("Read a post or draft")),T("attempts",{workspace:M,postId:te("post-id").pipe(ne(a.check(D()))),targetId:te("target-id").pipe(ne(a.check(D()))),cursor:C("cursor").pipe(E),limit:Ue("limit").pipe(E)},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,zw({client:t.runtime.client,path:{postId:e.postId,targetId:e.targetId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId),...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(P("Read a destination's delivery attempt history")),T("retry",{workspace:M,postId:te("post-id").pipe(ne(a.check(D()))),targetId:te("target-id").pipe(ne(a.check(D()))),expectedAttemptId:C("expected-attempt-id").pipe(ue(a.check(D())))},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,jw({client:t.runtime.client,path:{postId:e.postId,targetId:e.targetId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{expectedAttemptId:e.expectedAttemptId},...t.runtime.transport()}))})).pipe(P("Retry a failed delivery")),T("reconcile",{workspace:M,postId:te("post-id").pipe(ne(a.check(D()))),targetId:te("target-id").pipe(ne(a.check(D()))),expectedAttemptId:C("expected-attempt-id").pipe(ue(a.check(D())))},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,Qw({client:t.runtime.client,path:{postId:e.postId,targetId:e.targetId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{expectedAttemptId:e.expectedAttemptId},...t.runtime.transport()}))})).pipe(P("Recheck a recorded provider receipt")),T("update",{workspace:M,postId:te("post-id").pipe(ne(a.check(D()))),text:C("text").pipe(E),expectedRevision:Ue("revision").pipe(E),file:C("file").pipe(E,Ce("Read the body JSON from a file or stdin with -."))},(e)=>R(async()=>{let t=await Q(),r=f(e.file),n=r===void 0?{...O(e.text)?{text:f(e.text)}:{},...O(e.expectedRevision)?{expectedRevision:f(e.expectedRevision)}:{}}:await It(r);return t.runtime.decode(j,Gw({client:t.runtime.client,path:{postId:e.postId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},body:n,...t.runtime.transport()}))})).pipe(P("Edit a draft")),T("delete",{workspace:M,postId:te("post-id").pipe(ne(a.check(D())))},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,qw({client:t.runtime.client,path:{postId:e.postId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(P("Archive a post or draft"))];var aZ=no(lL,{onExcessProperty:"error"}),Sy=te("post-id").pipe(ne(WU.fields.postId)),cZ=Ue("revision").pipe(ue(ao),Ce("Expected revision from posts get.")),pZ=T("create",{workspace:M,text:C("text").pipe(E,Ce("Post text for the one-call path.")),platform:we("platform",ss).pipe(Sr(0),Ce("Publish to the single ready account for this provider. Repeat for several platforms.")),account:B$,mediaId:C("media-id").pipe(ue(yn),Sr(0),Ce("Attach ready workspace media by ID.")),mediaUrl:C("media-url").pipe(Sr(0),Ce("Attach a public HTTPS media URL.")),schedule:C("schedule").pipe(ue(Rt),E,Ce("Schedule with an ISO time and explicit offset.")),publishNow:ft("publish-now").pipe(Xe(!0),Ce("Publish now when --schedule is absent.")),draft:ft("draft").pipe(Xe(!1),Ce("Save a draft without submitting it.")),file:C("file").pipe(E,Ce("Advanced: read a full Level 2 post JSON document from a file or stdin with -.")),key:rt,queue:C("queue").pipe(ue(Xt),E,Ce("Assign every file-provided destination to this account queue."))},(e)=>R(async()=>{let t=await Ne(f(e.workspace)),r=f(e.key),n=f(e.file),o=f(e.schedule);if(e.draft&&o)throw new Le("Drafts cannot set --schedule until published.");if(n){if(O(e.text)||e.platform.length||e.account.length||e.mediaId.length||e.mediaUrl.length||o&&!e.draft||!e.publishNow&&!e.draft)throw new Le("Use --file alone, or provide --text with --platform or --account.");let c=await aZ(await It(n)).catch(()=>{throw new Le("Post JSON does not match the PubNio API contract.")}),l=f(e.queue);if(l&&e.draft)throw new Le("Drafts cannot be assigned a queue.");if(l&&(c.targets??[]).some((S)=>S.scheduledAt!==void 0||S.queueId!==void 0))throw new Le("Remove per-target schedules or queues when using --queue.");return t.posts.create({...l?{...c,targets:(c.targets??[]).map((S)=>({...S,queueId:l}))}:c,...e.draft?{isDraft:!0}:{},...r?{idempotencyKey:r}:{}})}let i=f(e.text);if(i===void 0)throw new Le("Provide --text or --file.");if(e.draft&&e.platform.length)throw new Le("Drafts select exact --account IDs, not platforms.");if(!e.draft&&O(e.queue))throw new Le("--queue requires --file.");if(!e.draft&&e.platform.length&&e.account.length)throw new Le("Use --platform or --account, not both.");if(!e.draft&&!e.platform.length&&!e.account.length)throw new Le("Provide at least one --platform or --account.");let s=[...e.mediaId.map((c)=>({mediaId:c})),...e.mediaUrl.map((c)=>({url:c}))];if(e.draft)return t.posts.create({text:i,isDraft:!0,...e.account.length?{targets:e.account.map((c)=>({accountId:c}))}:{},...s.length?{media:s}:{}});return t.posts.create({text:i,...e.platform.length?{platforms:[...e.platform]}:{},...e.account.length?{accounts:[...e.account]}:{},...s.length?{media:s}:{},...o?{scheduledAt:o}:{},publishNow:e.publishNow,...r?{idempotencyKey:r}:{}})})).pipe(P("Create and submit a post in one call, or save a draft with --draft.")),dZ=T("list",{workspace:M,...ys,draft:ft("draft").pipe(Xe(!1),Ce("List only drafts. Omit to list posts and drafts.")),deliveryStatus:we("delivery-status",Vc.literals).pipe(E)},(e)=>R(async()=>(await Ne(f(e.workspace))).posts.list({cursor:f(e.cursor),limit:f(e.limit),...e.draft?{isDraft:!0}:{},deliveryStatus:f(e.deliveryStatus)}))).pipe(P("List posts and drafts, and filter their current deliveries.")),uZ=T("validate",{workspace:M,id:Sy},(e)=>R(async()=>{let t=await(await Ne(f(e.workspace))).posts.validate(e.id);if(!t.canPublish)process.exitCode=1;return t})).pipe(P("Validate a saved draft before publishing.")),lZ=T("publish",{id:Sy,workspace:M,revision:cZ,key:rt,at:C("at").pipe(ue(Rt),E),queue:C("queue").pipe(ue(Xt),E),account:K$,placement:we("placement",yr.literals).pipe(E)},(e)=>R(async()=>{let t=f(e.placement),r=f(e.account),n=f(e.at),o=f(e.queue),i=f(e.key);if(t&&!r)throw new Le("Use --placement with --account.");if(n&&o)throw new Le("Use --at or --queue, not both.");let s=await Ne(f(e.workspace));if(o){let l=(await s.posts.get(e.id)).targets.filter((S)=>!r||S.accountId.toLowerCase()===r.toLowerCase());if(!l.length||t&&l.some((S)=>S.placement!==t))throw new Le("No matching destination exists in this post for --queue.");return s.posts.publish(e.id,{expectedRevision:e.revision,idempotencyKey:i,targets:l.map((S)=>({accountId:S.accountId,placement:S.placement,queueId:o}))})}return s.posts.publish(e.id,{expectedRevision:e.revision,scheduledAt:n,idempotencyKey:i,...r&&t?{targets:[{accountId:r,placement:t,scheduledAt:n}]}:r?{accountIds:[r]}:{}})})).pipe(P("Publish a saved draft now or at --at.")),fZ=T("status",{workspace:M,id:Sy},(e)=>R(async()=>(await Ne(f(e.workspace))).posts.status(e.id))).pipe(P("Read delivery outcomes for a post.")),mZ=T("wait",{workspace:M,id:Sy,timeoutSeconds:Ue("timeout").pipe(Xe(60),Ce("Maximum seconds to wait for delivery."))},(e)=>R(async()=>{if(e.timeoutSeconds<0||e.timeoutSeconds>3600)throw new Le("Use a timeout between 0 and 3600 seconds.");let t=await(await Ne(f(e.workspace))).posts.wait(e.id,{timeoutMs:e.timeoutSeconds*1000});if(!t.settled)process.exitCode=1;return t})).pipe(P("Wait for a post to reach a settled delivery outcome."));function EA(e,t){return R(async()=>(await Ne(f(e.workspace))).schedule.change(_U(e.postId),UU(e.targetId),t))}var kA={postId:te("post-id").pipe(ne(Ib.fields.postId)),targetId:te("target-id").pipe(ne(Ib.fields.targetId)),expectedAttemptId:C("attempt").pipe(ue(Wt),Ce("Current attempt ID from posts status.")),workspace:M},hZ=T("reschedule",{...kA,at:C("at").pipe(ue(Rt),E),queue:C("queue").pipe(ue(Xt),E),slot:C("slot").pipe(ue(a.check(D())),E),date:C("date").pipe(ue(bn),E)},(e)=>{let t=f(e.at),r=f(e.queue),n=f(e.slot),o=f(e.date);if(t===void 0===(r===void 0))throw new Le("Use exactly one of --at or --queue.");if(r&&n===void 0!==(o===void 0))throw new Le("Use --slot and --date together to pin a slot.");return EA(e,r?{action:"reschedule",expectedAttemptId:e.expectedAttemptId,queueId:r,...n&&o?{pinned:{slotId:n,occurrenceDate:o}}:{}}:{action:"reschedule",expectedAttemptId:e.expectedAttemptId,scheduledAt:t})}).pipe(P("Move a pending delivery to a queue slot or time.")),yZ=T("cancel",kA,(e)=>EA(e,{action:"cancel",expectedAttemptId:e.expectedAttemptId})).pipe(P("Cancel a delivery before the provider write is reserved.")),gZ=T("publish-now",kA,(e)=>EA(e,{action:"publish_now",expectedAttemptId:e.expectedAttemptId})).pipe(P("Bring a pending delivery forward.")),d1=T("posts").pipe(P("Create and publish posts, save drafts, and manage delivery status."),Je([pZ,dZ,...p1,uZ,lZ,fZ,mZ,hZ,yZ,gZ]));var wn=te("queue-id").pipe(ne(Xt)),by=Ue("version").pipe(Ce("Expected version from the last queue read.")),l1={maxPerDay:Ue("max-per-day").pipe(E),maxPending:Ue("max-pending").pipe(E),minGap:Ue("min-gap").pipe(E),horizon:Ue("horizon-days").pipe(E)},f1={slot:C("slot").pipe(p9(50),Ce("Weekly slot as DAY:HH:mm where 0 is Sunday."))},xZ=no(IL,{onExcessProperty:"error"}),SZ=no(wL,{onExcessProperty:"error"}),bZ=no(EL,{onExcessProperty:"error"}),IZ=no(OL,{onExcessProperty:"error"}),wZ=no(_L,{onExcessProperty:"error"});function m1(e){let t=/^([0-6]):((?:[01]\d|2[0-3]):[0-5]\d)$/.exec(e);if(!t)throw new Le("Use --slot DAY:HH:mm where DAY is 0-6, 0 Sunday.");return{dayOfWeek:Number(t[1]),time:t[2]}}function h1(e){let t=f(e.maxPerDay),r=f(e.maxPending),n=f(e.minGap),o=f(e.horizon);return{...t===void 0?{}:{maxPerDay:t},...r===void 0?{}:{maxPending:r},...n===void 0?{}:{minGapSeconds:n},...o===void 0?{}:{horizonDays:o}}}var EZ=T("list",{workspace:M,account:Zk,...ys},(e)=>R(async()=>(await Ne(f(e.workspace))).queues.list({accountId:f(e.account),cursor:f(e.cursor),limit:f(e.limit)}))).pipe(P("List account schedule queues.")),kZ=T("create",{workspace:M,file:C("file").pipe(E,Ce("Read CreateQueue JSON from a file or stdin with -.")),account:Zk,name:C("name").pipe(E),timezone:C("timezone").pipe(E,Ce("IANA time zone, e.g. America/New_York. Defaults to the workspace default time zone.")),default:ft("default").pipe(E,Ce("Promote the new queue to the account default. The first active queue is always the default.")),...f1,...l1},(e)=>R(async()=>{let t=await Ne(f(e.workspace)),r=f(e.file),n=await xZ(r?await It(r):{accountId:f(e.account),name:f(e.name),...nr(e.timezone)?{}:{timezone:e.timezone.value},slots:e.slot.map(m1),...nr(e.default)?{}:{isDefault:e.default.value},...h1(e)}).catch(()=>{throw new Le("Queue JSON does not match the PubNio API contract.")});return t.queues.create(n)})).pipe(P("Create a weekly queue for an account; the first is the default. Omit --timezone to use the workspace default.")),AZ=T("get",{workspace:M,queueId:wn},(e)=>R(async()=>(await Ne(f(e.workspace))).queues.get(e.queueId))).pipe(P("Read a queue, its slots, and its limits.")),vZ=T("update",{workspace:M,queueId:wn,version:by,file:C("file").pipe(E,Ce("Read UpdateQueue JSON from a file or stdin with -.")),name:C("name").pipe(E),timezone:C("timezone").pipe(E),pause:ft("pause").pipe(Xe(!1)),resume:ft("resume").pipe(Xe(!1)),default:ft("default").pipe(E,Ce("Promote or demote the account default. Demote only after promoting another queue.")),...l1},(e)=>R(async()=>{if(e.pause&&e.resume)throw new Le("Use --pause or --resume, not both.");let t=await Ne(f(e.workspace)),r=f(e.file),n=await SZ(r?await It(r):{expectedVersion:e.version,...nr(e.name)?{}:{name:e.name.value},...nr(e.timezone)?{}:{timezone:e.timezone.value},...e.pause?{paused:!0}:e.resume?{paused:!1}:{},...nr(e.default)?{}:{isDefault:e.default.value},...h1(e)}).catch(()=>{throw new Le("Queue update JSON does not match the PubNio API contract.")});return t.queues.update(e.queueId,n)})).pipe(P("Update limits, name, time zone, default, pause, or resume a queue.")),CZ=T("archive",{workspace:M,queueId:wn,version:by},(e)=>R(async()=>(await Ne(f(e.workspace))).queues.archive(e.queueId,e.version))).pipe(P("Archive a queue and keep queued work.")),TZ=T("slots",{workspace:M,queueId:wn,version:by,file:C("file").pipe(E,Ce("Read ReplaceQueueSlots JSON from a file or stdin.")),...f1},(e)=>R(async()=>{let t=await Ne(f(e.workspace)),r=f(e.file),n=await bZ(r?await It(r):{expectedVersion:e.version,slots:e.slot.map(m1)}).catch(()=>{throw new Le("Queue slot JSON does not match the PubNio API contract.")});return t.queues.replaceSlots(e.queueId,n)})).pipe(P("Replace every weekly queue slot.")),OZ=T("next-slot",{workspace:M,queueId:wn,after:C("after").pipe(E)},(e)=>R(async()=>(await Ne(f(e.workspace))).queues.nextSlot(e.queueId,f(e.after)))).pipe(P("Read the next free queue occurrence.")),PZ=T("preview",{workspace:M,queueId:wn,count:Ue("count").pipe(Xe(10)),after:C("after").pipe(E),includeOccupied:ft("include-occupied").pipe(Xe(!1))},(e)=>R(async()=>(await Ne(f(e.workspace))).queues.previewSlots(e.queueId,{count:e.count,after:f(e.after),includeOccupied:e.includeOccupied}))).pipe(P("Preview upcoming queue occurrences.")),RZ=T("skips",{workspace:M,queueId:wn,...ys},(e)=>R(async()=>(await Ne(f(e.workspace))).queues.skips(e.queueId,{cursor:f(e.cursor),limit:f(e.limit)}))).pipe(P("List skipped queue occurrences.")),_Z=T("skip",{workspace:M,queueId:wn,slotId:C("slot-id").pipe(ue(bu)),occurrenceDate:C("occurrence-date")},(e)=>R(async()=>{let t=await Ne(f(e.workspace)),r=await IZ({slotId:e.slotId,occurrenceDate:e.occurrenceDate}).catch(()=>{throw new Le("Use --slot-id with a queue slot UUID and --occurrence-date YYYY-MM-DD.")});return t.queues.skip(e.queueId,r.slotId,r.occurrenceDate)})).pipe(P("Skip one queue occurrence.")),UZ=T("unskip",{workspace:M,queueId:wn,skipId:C("skip-id").pipe(ue(bu))},(e)=>R(async()=>(await Ne(f(e.workspace))).queues.unskip(e.queueId,e.skipId))).pipe(P("Restore a skipped queue occurrence.")),DZ=T("blackouts",{workspace:M,queueId:wn,...ys},(e)=>R(async()=>(await Ne(f(e.workspace))).queues.blackouts(e.queueId,{cursor:f(e.cursor),limit:f(e.limit)}))).pipe(P("List queue blackout date ranges.")),LZ=T("blackout",{workspace:M,queueId:wn,startsOn:C("starts-on"),endsOn:C("ends-on"),reason:C("reason").pipe(E)},(e)=>R(async()=>{let t=await Ne(f(e.workspace)),r=await wZ({startsOn:e.startsOn,endsOn:e.endsOn,reason:f(e.reason)}).catch(()=>{throw new Le("Use --starts-on and --ends-on as YYYY-MM-DD; --reason is at most 200 characters.")});return t.queues.blackout(e.queueId,r)})).pipe(P("Black out a queue date range.")),MZ=T("unblackout",{workspace:M,queueId:wn,blackoutId:C("blackout-id").pipe(ue(ah))},(e)=>R(async()=>(await Ne(f(e.workspace))).queues.unblackout(e.queueId,e.blackoutId))).pipe(P("Remove a queue blackout.")),u1=(e)=>T(e?"pause":"resume",{workspace:M,queueId:wn,version:by},(t)=>R(async()=>(await Ne(f(t.workspace))).queues.update(t.queueId,{expectedVersion:t.version,paused:e}))).pipe(P(e?"Pause new assignments while queued attempts still publish.":"Resume new assignments.")),y1=T("queues").pipe(P("Manage weekly account publishing queues."),Je([EZ,kZ,AZ,vZ,CZ,TZ,OZ,PZ,RZ,_Z,UZ,DZ,LZ,MZ,u1(!0),u1(!1)]));var FZ=T("list",{workspace:M,from:C("from").pipe(Ce("Inclusive ISO start instant, for example 2026-12-01T00:00:00Z.")),to:C("to").pipe(Ce("Inclusive ISO end instant, at most 90 days after --from.")),accountId:C("account-id").pipe(ue(H),E,Ce("Filter by the target publishing account.")),queueId:C("queue-id").pipe(ue(Xt),E,Ce("Filter by the open queue assignment.")),...ys},(e)=>R(async()=>(await Ne(f(e.workspace))).schedule.list({from:e.from,to:e.to,accountId:f(e.accountId),queueId:f(e.queueId),cursor:f(e.cursor),limit:f(e.limit)}))).pipe(P("List queued attempts in a time range.")),NZ=T("skip-to-next",{workspace:M,postId:C("post-id").pipe(ue(Pt)),targetId:C("target-id").pipe(ue(sr)),queueId:C("queue-id").pipe(ue(Xt),E,Ce("Override the target delivery's current queue.")),expectedAttemptId:C("expected-attempt-id").pipe(ue(Wt),E,Ce("Override the target delivery's current attempt."))},(e)=>R(async()=>(await Ne(f(e.workspace))).schedule.skipToNext(e.postId,e.targetId,{queueId:f(e.queueId),expectedAttemptId:f(e.expectedAttemptId)}))).pipe(P("Move a queue-assigned target to the next free occurrence.")),g1=T("schedule").pipe(P("Read the publishing calendar and skip ahead."),Je([FZ,NZ]));var x1=[T("preferences").pipe(P(""),Je([T("get",{workspace:M},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,UE({client:t.runtime.client,path:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(P("Read email notification preferences")),T("update",{workspace:M,deliveryFailures:ft("delivery-failures").pipe(Xe(!1)),connectionExpiring:ft("connection-expiring").pipe(Xe(!1)),webhookFailures:ft("webhook-failures").pipe(Xe(!1)),billingAlerts:ft("billing-alerts").pipe(Xe(!1)),weeklyDigest:ft("weekly-digest").pipe(Xe(!1))},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,DE({client:t.runtime.client,path:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{...e.deliveryFailures?{deliveryFailures:!0}:{},...e.connectionExpiring?{connectionExpiring:!0}:{},...e.webhookFailures?{webhookFailures:!0}:{},...e.billingAlerts?{billingAlerts:!0}:{},...e.weeklyDigest?{weeklyDigest:!0}:{}},...t.runtime.transport()}))})).pipe(P("Update email notification preferences"))]))];var S1=T("notifications").pipe(P("Read and update notification preferences."),Je(x1));var b1=[T("get",{},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,DI({client:t.runtime.client,...t.runtime.transport()}))})).pipe(P("Get your profile"))];var BZ=T("update",{name:C("name").pipe(E),clear:ft("clear-name").pipe(Xe(!1))},({name:e,clear:t})=>R(async()=>{if(e._tag==="Some"===t)throw new Le("Provide exactly one of --name or --clear-name.");let r=ts(FU)({displayName:e._tag==="Some"?e.value:null});if(r._tag==="None")throw new Le("Display name must be between 1 and 100 characters.");return(await fo()).me.update(r.value)})).pipe(P("Change or clear your display name.")),KZ=T("deactivate",{yes:ft("yes").pipe(Xe(!1))},({yes:e})=>R(async()=>{if(!e)throw new Le("Pass --yes to deactivate the current profile.");return(await fo()).me.deactivate()})).pipe(P("Deactivate your profile after archiving owned workspaces.")),$Z=T("list",{},()=>R(async()=>(await fo(void 0,"human")).me.invites())),qZ=T("accept",{inviteId:te("invite-id").pipe(ne(ui))},({inviteId:e})=>R(async()=>(await fo(void 0,"human")).me.acceptInvite({inviteId:e}))),WZ=T("decline",{inviteId:te("invite-id").pipe(ne(ui))},({inviteId:e})=>R(async()=>(await fo(void 0,"human")).me.declineInvite(e))),GZ=T("invites").pipe(P("Manage your workspace invitations."),Je([$Z,qZ,WZ])),I1=T("profile").pipe(P("Manage your PubNio profile."),Je([...b1,BZ,KZ,GZ]));var w1=[T("list",{workspace:M,includeArchived:we("include-archived",["true","false"]).pipe(E),cursor:C("cursor").pipe(E),limit:Ue("limit").pipe(E)},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,nw({client:t.runtime.client,query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId),...O(e.includeArchived)?{includeArchived:f(e.includeArchived)}:{},...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(P("List workspace profiles")),T("create",{workspace:M,name:C("name"),externalId:C("external-id").pipe(E)},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,ow({client:t.runtime.client,query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{name:e.name,...O(e.externalId)?{externalId:f(e.externalId)}:{}},...t.runtime.transport()}))})).pipe(P("Create a workspace profile")),T("get",{workspace:M,profileId:te("profile-id").pipe(ne(a.check(D())))},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,sw({client:t.runtime.client,path:{profileId:e.profileId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(P("Read a workspace profile")),T("update",{workspace:M,profileId:te("profile-id").pipe(ne(a.check(D()))),name:C("name").pipe(E),file:C("file").pipe(E,Ce("Read the body JSON from a file or stdin with -."))},(e)=>R(async()=>{let t=await Q(),r=f(e.file),n=r===void 0?{...O(e.name)?{name:f(e.name)}:{}}:await It(r);return t.runtime.decode(j,aw({client:t.runtime.client,path:{profileId:e.profileId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},body:n,...t.runtime.transport()}))})).pipe(P("Rename a profile or change its external ID")),T("archive",{workspace:M,profileId:te("profile-id").pipe(ne(a.check(D())))},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,iw({client:t.runtime.client,path:{profileId:e.profileId},query:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(P("Archive a workspace profile"))];var E1=T("profiles").pipe(P("Manage posting profiles."),Je(w1));var k1=[T("list",{workspace:M,cursor:C("cursor").pipe(E),limit:Ue("limit").pipe(E)},(e)=>R(async()=>{let t=await Q(void 0,"human");return t.runtime.decode(j,zI({client:t.runtime.client,path:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},query:{...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(P("List webhook endpoints")),T("create",{workspace:M,name:C("name"),url:C("url"),eventTypes:we("event",["post.delivery.published","post.delivery.provider_draft","post.delivery.failed","post.delivery.unresolved","post.delivery.cancelled","post.scheduled","post.published","post.partial","post.failed","post.cancelled","inbox.message.received","inbox.comment.received","inbox.review.new","inbox.review.updated","inbox.review.deleted","inbox.review.restored","inbox.review.replied","inbox.mention.received","inbox.message.sent","inbox.message.delivered","inbox.message.read","inbox.message.edited","inbox.message.deleted","inbox.reaction.received","inbox.referral.received","inbox.conversation.started","analytics.post.synced","analytics.account.synced","ads.operation.succeeded","ads.operation.failed","ads.campaign.activated","ads.campaign.paused","ads.budget.changed","ads.kill_switch.activated","ads.lead.received","ads.campaign.status_changed","ads.ad_group.status_changed","ads.ad.status_changed","ads.ad_account.status_changed","ads.ad.review.approved","ads.ad.review.rejected","ads.sync.failed","ads.sync.recovered","ads.initial_sync.completed","schedule.assignment.changed","account.connected","account.disconnected","account.permissions_changed","account.restricted","account.recovered","billing.subscription.updated","billing.credit.topped_up","billing.credit.low","billing.spend_cap.reached","billing.invoice.payment_failed"]).pipe(Sr(0)),enabled:ft("paused").pipe(Xe(!1)),profileId:C("profile-id").pipe(ue(a.check(D()))).pipe(E),accountIds:C("account-ids").pipe(Sr(0)),disabledResourceGroups:we("disabled-resource-groups",["publishing","inbox","analytics","ads","scheduling","accounts","billing"]).pipe(Sr(0))},(e)=>R(async()=>{let t=await Q(void 0,"human");return t.runtime.decode(j,jI({client:t.runtime.client,path:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{name:e.name,url:e.url,eventTypes:[...e.eventTypes],...e.enabled?{enabled:!1}:{},...O(e.profileId)?{profileId:f(e.profileId)}:{},...e.accountIds.length?{accountIds:[...e.accountIds]}:{},...e.disabledResourceGroups.length?{disabledResourceGroups:[...e.disabledResourceGroups]}:{}},...t.runtime.transport()}))})).pipe(P("Register a webhook endpoint")),T("get",{workspace:M,endpointId:te("endpoint-id").pipe(ne(a.check(D())))},(e)=>R(async()=>{let t=await Q(void 0,"human");return t.runtime.decode(j,HI({client:t.runtime.client,path:{endpointId:e.endpointId,workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(P("Inspect a webhook endpoint")),T("update",{workspace:M,endpointId:te("endpoint-id").pipe(ne(a.check(D()))),name:C("name").pipe(E),eventTypes:we("event",["post.delivery.published","post.delivery.provider_draft","post.delivery.failed","post.delivery.unresolved","post.delivery.cancelled","post.scheduled","post.published","post.partial","post.failed","post.cancelled","inbox.message.received","inbox.comment.received","inbox.review.new","inbox.review.updated","inbox.review.deleted","inbox.review.restored","inbox.review.replied","inbox.mention.received","inbox.message.sent","inbox.message.delivered","inbox.message.read","inbox.message.edited","inbox.message.deleted","inbox.reaction.received","inbox.referral.received","inbox.conversation.started","analytics.post.synced","analytics.account.synced","ads.operation.succeeded","ads.operation.failed","ads.campaign.activated","ads.campaign.paused","ads.budget.changed","ads.kill_switch.activated","ads.lead.received","ads.campaign.status_changed","ads.ad_group.status_changed","ads.ad.status_changed","ads.ad_account.status_changed","ads.ad.review.approved","ads.ad.review.rejected","ads.sync.failed","ads.sync.recovered","ads.initial_sync.completed","schedule.assignment.changed","account.connected","account.disconnected","account.permissions_changed","account.restricted","account.recovered","billing.subscription.updated","billing.credit.topped_up","billing.credit.low","billing.spend_cap.reached","billing.invoice.payment_failed"]).pipe(Sr(0)),enabled:ft("paused").pipe(Xe(!1)),file:C("file").pipe(E,Ce("Read the body JSON from a file or stdin with -."))},(e)=>R(async()=>{let t=await Q(void 0,"human"),r=f(e.file),n=r===void 0?{...O(e.name)?{name:f(e.name)}:{},...e.eventTypes.length?{eventTypes:[...e.eventTypes]}:{},...e.enabled?{enabled:!1}:{}}:await It(r);return t.runtime.decode(j,VI({client:t.runtime.client,path:{endpointId:e.endpointId,workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},body:n,...t.runtime.transport()}))})).pipe(P("Edit or pause a webhook endpoint")),T("delete",{workspace:M,endpointId:te("endpoint-id").pipe(ne(a.check(D())))},(e)=>R(async()=>{let t=await Q(void 0,"human");return t.runtime.decode(j,QI({client:t.runtime.client,path:{endpointId:e.endpointId,workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(P("Permanently disable a webhook endpoint")),T("test",{workspace:M,endpointId:te("endpoint-id").pipe(ne(a.check(D())))},(e)=>R(async()=>{let t=await Q(void 0,"human");return t.runtime.decode(j,JI({client:t.runtime.client,path:{endpointId:e.endpointId,workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(P("Enqueue a webhook test event")),T("list-deliveries",{workspace:M,endpointId:te("endpoint-id").pipe(ne(a.check(D()))),cursor:C("cursor").pipe(E),limit:Ue("limit").pipe(E)},(e)=>R(async()=>{let t=await Q(void 0,"human");return t.runtime.decode(j,YI({client:t.runtime.client,path:{endpointId:e.endpointId,workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},query:{...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(P("List webhook deliveries")),T("get-delivery",{workspace:M,endpointId:te("endpoint-id").pipe(ne(a.check(D()))),deliveryId:te("delivery-id").pipe(ne(a.check(D())))},(e)=>R(async()=>{let t=await Q(void 0,"human");return t.runtime.decode(j,ZI({client:t.runtime.client,path:{endpointId:e.endpointId,deliveryId:e.deliveryId,workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(P("Inspect a webhook delivery")),T("replay-delivery",{workspace:M,endpointId:te("endpoint-id").pipe(ne(a.check(D()))),deliveryId:te("delivery-id").pipe(ne(a.check(D())))},(e)=>R(async()=>{let t=await Q(void 0,"human");return t.runtime.decode(j,XI({client:t.runtime.client,path:{endpointId:e.endpointId,deliveryId:e.deliveryId,workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(P("Replay a settled webhook delivery")),T("event-types",{},(e)=>R(async()=>{let t=await Q(void 0,"human");return t.runtime.decode(j,g6({client:t.runtime.client,...t.runtime.transport()}))})).pipe(P("List supported webhook event types"))];var A1=T("webhooks").pipe(P("Manage workspace webhooks as a signed-in owner."),Je(k1));var v1=[T("list",{},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,LI({client:t.runtime.client,...t.runtime.transport()}))})).pipe(P("List workspaces")),T("create",{name:C("name"),defaultTimezone:C("default-timezone").pipe(E)},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,MI({client:t.runtime.client,body:{name:e.name,...O(e.defaultTimezone)?{defaultTimezone:f(e.defaultTimezone)}:{}},...t.runtime.transport()}))})).pipe(P("Create a workspace")),T("get",{id:te("id").pipe(ne(a.check(D())))},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,NI({client:t.runtime.client,path:{workspaceId:e.id},...t.runtime.transport()}))})).pipe(P("Get a workspace")),T("update",{id:te("id").pipe(ne(a.check(D()))),name:C("name").pipe(E),defaultTimezone:C("default-timezone").pipe(E)},(e)=>R(async()=>{let t=await Q();if(!(O(e.name)||O(e.defaultTimezone)))throw new Le("Provide --name or --default-timezone.");return t.runtime.decode(j,BI({client:t.runtime.client,path:{workspaceId:e.id},body:{...O(e.name)?{name:f(e.name)}:{},...O(e.defaultTimezone)?{defaultTimezone:f(e.defaultTimezone)}:{}},...t.runtime.transport()}))})).pipe(P("Update a workspace you own")),T("archive",{id:te("id").pipe(ne(a.check(D())))},(e)=>R(async()=>{let t=await Q();return t.runtime.decode(j,FI({client:t.runtime.client,path:{workspaceId:e.id},...t.runtime.transport()}))})).pipe(P("Archive a workspace you own")),T("invites").pipe(P(""),Je([T("list",{workspace:M,status:we("status",["pending","accepted","revoked","expired"]).pipe(E),cursor:C("cursor").pipe(E),limit:Ue("limit").pipe(E)},(e)=>R(async()=>{let t=await Q(void 0,"human");return t.runtime.decode(j,NE({client:t.runtime.client,path:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},query:{...O(e.status)?{status:f(e.status)}:{},...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(P("List workspace invitations")),T("create",{workspace:M,email:C("email"),role:we("role",["owner","member"]).pipe(E),idempotencyKey:rt},(e)=>R(async()=>{let t=await Q(void 0,"human");return t.runtime.decode(j,BE({client:t.runtime.client,path:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{email:e.email,...O(e.role)?{role:f(e.role)}:{}},headers:{"idempotency-key":f(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()}))})).pipe(P("Create a workspace invitation")),T("resend",{workspace:M,inviteId:te("invite-id").pipe(ne(a.check(D()))),idempotencyKey:rt},(e)=>R(async()=>{let t=await Q(void 0,"human");return t.runtime.decode(j,KE({client:t.runtime.client,path:{inviteId:e.inviteId,workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},headers:{"idempotency-key":f(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()}))})).pipe(P("Resend a pending invitation email")),T("revoke",{workspace:M,inviteId:te("invite-id").pipe(ne(a.check(D())))},(e)=>R(async()=>{let t=await Q(void 0,"human");return t.runtime.decode(j,$E({client:t.runtime.client,path:{inviteId:e.inviteId,workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(P("Revoke a pending workspace invitation"))])),T("members").pipe(P(""),Je([T("list",{workspace:M,role:we("role",["owner","member"]).pipe(E),cursor:C("cursor").pipe(E),limit:Ue("limit").pipe(E)},(e)=>R(async()=>{let t=await Q(void 0,"human");return t.runtime.decode(j,LE({client:t.runtime.client,path:{workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},query:{...O(e.role)?{role:f(e.role)}:{},...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(P("List workspace members")),T("remove",{workspace:M,userId:te("user-id").pipe(ne(a.check(D())))},(e)=>R(async()=>{let t=await Q(void 0,"human");return t.runtime.decode(j,ME({client:t.runtime.client,path:{userId:e.userId,workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(P("Remove a workspace member or leave the workspace")),T("update-role",{workspace:M,userId:te("user-id").pipe(ne(a.check(D()))),role:we("role",["owner","member"])},(e)=>R(async()=>{let t=await Q(void 0,"human");return t.runtime.decode(j,FE({client:t.runtime.client,path:{userId:e.userId,workspaceId:await J(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{role:e.role},...t.runtime.transport()}))})).pipe(P("Update a workspace member's role"))]))];var zZ=T("use",{id:N$},({id:e})=>R(async()=>(await fo()).useWorkspace(e))).pipe(P("Remember the active workspace for this CLI session.")),C1=T("workspaces").pipe(P("Manage PubNio workspaces."),Je([...v1,zZ]));var T1=T("pnio").pipe(P("Connect accounts and manage PubNio content."),Je([qq,I1,C1,E1,Nq,Mq,Kq,S1,i1,jq,Hq,Jq,Dq,d1,y1,g1,c1,A1,Zq,Gq]));var jZ=L$(T1,{version:Vu.version}),nl=process.argv.slice(2);try{await OO(jZ(nl.length?nl:["--help"]).pipe(vO(e4),Qi(up,{present:(e)=>e._tag==="InvalidInvocation"?Fe(()=>console.error(e.errors.map((t)=>t.message).join(`
272
272
  `))):DK.present(e)})))}catch(e){if(e instanceof gi){if(e.errors.length)process.exitCode=2}else if(e instanceof Nn){let t=e.status===401?process.env.PUBNIO_API_KEY!==void 0&&nl[0]!=="api-keys"&&nl[0]!=="webhooks"&&nl[0]!=="auth"?"PubNio rejected the API key. Check PUBNIO_API_KEY.":"PubNio session is unavailable. Run `pnio auth login`.":e.message;console.error(JSON.stringify({kind:e.kind,message:t,status:e.status,type:e.problemType,requestId:e.requestId,issues:e.issues.length?e.issues:void 0,errors:e.requestIssues.length?e.requestIssues:void 0,retryable:e.retryable,idempotencyKey:e.idempotencyKey,currentAttemptId:e.currentAttemptId,currentRevision:e.currentRevision})),process.exitCode=1}else console.error(e instanceof Error?e.message:"PubNio command failed."),process.exitCode=e instanceof Le?2:1}