@pubnio/cli 0.2.12 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,80 +1,81 @@
1
1
  #!/usr/bin/env bun
2
2
  // @bun
3
- var G1=Object.create;var{getPrototypeOf:z1,defineProperty:_A,getOwnPropertyNames:j1}=Object;var UA=Object.prototype.hasOwnProperty;function Q1(e){return this[e]}var H1,V1,J1=(e,t,r)=>{var n=e!=null&&typeof e==="object";if(n){var o=t?H1??=new WeakMap:V1??=new WeakMap,i=o.get(e);if(i)return i}r=e!=null?G1(z1(e)):{};let s=t||!e||!e.__esModule||!UA.call(e,"default")?_A(r,"default",{value:e,enumerable:!0}):r;if(e&&typeof e==="object"||typeof e==="function"){for(let c of j1(e))if(!UA.call(s,c))_A(s,c,{get:Q1.bind(e,c),enumerable:!0})}if(n)o.set(e,s);return s};var vn=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Ci=import.meta.require;var e$=vn(function(Hbe,Xq){var bs=Ci("constants"),X9=process.cwd,cy=null,e5=process.env.GRACEFUL_FS_PLATFORM||process.platform;process.cwd=function(){if(!cy)cy=X9.call(process);return cy};try{process.cwd()}catch(e){}if(typeof process.chdir==="function"){if(py=process.chdir,process.chdir=function(e){cy=null,py.call(process,e)},Object.setPrototypeOf)Object.setPrototypeOf(process.chdir,py)}var py;Xq.exports=t5;function t5(e){if(bs.hasOwnProperty("O_SYMLINK")&&process.version.match(/^v0\.6\.[0-2]|^v0\.5\./))t(e);if(!e.lutimes)r(e);if(e.chown=i(e.chown),e.fchown=i(e.fchown),e.lchown=i(e.lchown),e.chmod=n(e.chmod),e.fchmod=n(e.fchmod),e.lchmod=n(e.lchmod),e.chownSync=s(e.chownSync),e.fchownSync=s(e.fchownSync),e.lchownSync=s(e.lchownSync),e.chmodSync=o(e.chmodSync),e.fchmodSync=o(e.fchmodSync),e.lchmodSync=o(e.lchmodSync),e.stat=c(e.stat),e.fstat=c(e.fstat),e.lstat=c(e.lstat),e.statSync=l(e.statSync),e.fstatSync=l(e.fstatSync),e.lstatSync=l(e.lstatSync),e.chmod&&!e.lchmod)e.lchmod=function(m,g,w){if(w)process.nextTick(w)},e.lchmodSync=function(){};if(e.chown&&!e.lchown)e.lchown=function(m,g,w,k){if(k)process.nextTick(k)},e.lchownSync=function(){};if(e5==="win32")e.rename=typeof e.rename!=="function"?e.rename:function(m){function g(w,k,A){var y=Date.now(),h=0;m(w,k,function x(z){if(z&&(z.code==="EACCES"||z.code==="EPERM"||z.code==="EBUSY")&&Date.now()-y<60000){if(setTimeout(function(){e.stat(k,function(X,I){if(X&&X.code==="ENOENT")m(w,k,x);else A(z)})},h),h<100)h+=10;return}if(A)A(z)})}if(Object.setPrototypeOf)Object.setPrototypeOf(g,m);return g}(e.rename);e.read=typeof e.read!=="function"?e.read:function(m){function g(w,k,A,y,h,x){var z;if(x&&typeof x==="function"){var X=0;z=function(I,me,pe){if(I&&I.code==="EAGAIN"&&X<10)return X++,m.call(e,w,k,A,y,h,z);x.apply(this,arguments)}}return m.call(e,w,k,A,y,h,z)}if(Object.setPrototypeOf)Object.setPrototypeOf(g,m);return g}(e.read),e.readSync=typeof e.readSync!=="function"?e.readSync:function(m){return function(g,w,k,A,y){var h=0;while(!0)try{return m.call(e,g,w,k,A,y)}catch(x){if(x.code==="EAGAIN"&&h<10){h++;continue}throw x}}}(e.readSync);function t(m){m.lchmod=function(g,w,k){m.open(g,bs.O_WRONLY|bs.O_SYMLINK,w,function(A,y){if(A){if(k)k(A);return}m.fchmod(y,w,function(h){m.close(y,function(x){if(k)k(h||x)})})})},m.lchmodSync=function(g,w){var k=m.openSync(g,bs.O_WRONLY|bs.O_SYMLINK,w),A=!0,y;try{y=m.fchmodSync(k,w),A=!1}finally{if(A)try{m.closeSync(k)}catch(h){}else m.closeSync(k)}return y}}function r(m){if(bs.hasOwnProperty("O_SYMLINK")&&m.futimes)m.lutimes=function(g,w,k,A){m.open(g,bs.O_SYMLINK,function(y,h){if(y){if(A)A(y);return}m.futimes(h,w,k,function(x){m.close(h,function(z){if(A)A(x||z)})})})},m.lutimesSync=function(g,w,k){var A=m.openSync(g,bs.O_SYMLINK),y,h=!0;try{y=m.futimesSync(A,w,k),h=!1}finally{if(h)try{m.closeSync(A)}catch(x){}else m.closeSync(A)}return y};else if(m.futimes)m.lutimes=function(g,w,k,A){if(A)process.nextTick(A)},m.lutimesSync=function(){}}function n(m){if(!m)return m;return function(g,w,k){return m.call(e,g,w,function(A){if(S(A))A=null;if(k)k.apply(this,arguments)})}}function o(m){if(!m)return m;return function(g,w){try{return m.call(e,g,w)}catch(k){if(!S(k))throw k}}}function i(m){if(!m)return m;return function(g,w,k,A){return m.call(e,g,w,k,function(y){if(S(y))y=null;if(A)A.apply(this,arguments)})}}function s(m){if(!m)return m;return function(g,w,k){try{return m.call(e,g,w,k)}catch(A){if(!S(A))throw A}}}function c(m){if(!m)return m;return function(g,w,k){if(typeof w==="function")k=w,w=null;function A(y,h){if(h){if(h.uid<0)h.uid+=4294967296;if(h.gid<0)h.gid+=4294967296}if(k)k.apply(this,arguments)}return w?m.call(e,g,w,A):m.call(e,g,A)}}function l(m){if(!m)return m;return function(g,w){var k=w?m.call(e,g,w):m.call(e,g);if(k){if(k.uid<0)k.uid+=4294967296;if(k.gid<0)k.gid+=4294967296}return k}}function S(m){if(!m)return!0;if(m.code==="ENOSYS")return!0;var g=!process.getuid||process.getuid()!==0;if(g){if(m.code==="EINVAL"||m.code==="EPERM")return!0}return!1}}});var n$=vn(function(Vbe,r$){var t$=Ci("stream").Stream;r$.exports=r5;function r5(e){return{ReadStream:t,WriteStream:r};function t(n,o){if(!(this instanceof t))return new t(n,o);t$.call(this);var i=this;this.path=n,this.fd=null,this.readable=!0,this.paused=!1,this.flags="r",this.mode=438,this.bufferSize=65536,o=o||{};var s=Object.keys(o);for(var c=0,l=s.length;c<l;c++){var S=s[c];this[S]=o[S]}if(this.encoding)this.setEncoding(this.encoding);if(this.start!==void 0){if(typeof this.start!=="number")throw TypeError("start must be a Number");if(this.end===void 0)this.end=1/0;else if(typeof this.end!=="number")throw TypeError("end must be a Number");if(this.start>this.end)throw Error("start must be <= end");this.pos=this.start}if(this.fd!==null){process.nextTick(function(){i._read()});return}e.open(this.path,this.flags,this.mode,function(m,g){if(m){i.emit("error",m),i.readable=!1;return}i.fd=g,i.emit("open",g),i._read()})}function r(n,o){if(!(this instanceof r))return new r(n,o);t$.call(this),this.path=n,this.fd=null,this.writable=!0,this.flags="w",this.encoding="binary",this.mode=438,this.bytesWritten=0,o=o||{};var i=Object.keys(o);for(var s=0,c=i.length;s<c;s++){var l=i[s];this[l]=o[l]}if(this.start!==void 0){if(typeof this.start!=="number")throw TypeError("start must be a Number");if(this.start<0)throw Error("start must be >= zero");this.pos=this.start}if(this.busy=!1,this._queue=[],this.fd===null)this._open=e.open,this._queue.push([this._open,this.path,this.flags,this.mode,void 0]),this.flush()}}});var i$=vn(function(Jbe,o$){o$.exports=o5;var n5=Object.getPrototypeOf||function(e){return e.__proto__};function o5(e){if(e===null||typeof e!=="object")return e;if(e instanceof Object)var t={__proto__:n5(e)};else var t=Object.create(null);return Object.getOwnPropertyNames(e).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))}),t}});var sA=vn(function(Ybe,iA){var $t=Ci("fs"),i5=e$(),s5=n$(),a5=i$(),dy=Ci("util"),Tr,ly;if(typeof Symbol==="function"&&typeof Symbol.for==="function")Tr=Symbol.for("graceful-fs.queue"),ly=Symbol.for("graceful-fs.previous");else Tr="___graceful-fs.queue",ly="___graceful-fs.previous";function c5(){}function a$(e,t){Object.defineProperty(e,Tr,{get:function(){return t}})}var La=c5;if(dy.debuglog)La=dy.debuglog("gfs4");else if(/\bgfs4\b/i.test(process.env.NODE_DEBUG||""))La=function(){var e=dy.format.apply(dy,arguments);e="GFS4: "+e.split(/\n/).join(`
4
- GFS4: `),console.error(e)};if(!$t[Tr]){if(rA=global[Tr]||[],a$($t,rA),$t.close=function(e){function t(r,n){return e.call($t,r,function(o){if(!o)s$();if(typeof n==="function")n.apply(this,arguments)})}return Object.defineProperty(t,ly,{value:e}),t}($t.close),$t.closeSync=function(e){function t(r){e.apply($t,arguments),s$()}return Object.defineProperty(t,ly,{value:e}),t}($t.closeSync),/\bgfs4\b/i.test(process.env.NODE_DEBUG||""))process.on("exit",function(){La($t[Tr]),Ci("assert").equal($t[Tr].length,0)})}var rA;if(!global[Tr])a$(global,$t[Tr]);iA.exports=nA(a5($t));if(process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH&&!$t.__patched)iA.exports=nA($t),$t.__patched=!0;function nA(e){i5(e),e.gracefulify=nA,e.createReadStream=me,e.createWriteStream=pe;var t=e.readFile;e.readFile=r;function r(Q,te,re){if(typeof te==="function")re=te,te=null;return ae(Q,te,re);function ae(se,le,Se,ve){return t(se,le,function(ye){if(ye&&(ye.code==="EMFILE"||ye.code==="ENFILE"))gp([ae,[se,le,Se],ye,ve||Date.now(),Date.now()]);else if(typeof Se==="function")Se.apply(this,arguments)})}}var n=e.writeFile;e.writeFile=o;function o(Q,te,re,ae){if(typeof re==="function")ae=re,re=null;return se(Q,te,re,ae);function se(le,Se,ve,ye,$e){return n(le,Se,ve,function(_e){if(_e&&(_e.code==="EMFILE"||_e.code==="ENFILE"))gp([se,[le,Se,ve,ye],_e,$e||Date.now(),Date.now()]);else if(typeof ye==="function")ye.apply(this,arguments)})}}var i=e.appendFile;if(i)e.appendFile=s;function s(Q,te,re,ae){if(typeof re==="function")ae=re,re=null;return se(Q,te,re,ae);function se(le,Se,ve,ye,$e){return i(le,Se,ve,function(_e){if(_e&&(_e.code==="EMFILE"||_e.code==="ENFILE"))gp([se,[le,Se,ve,ye],_e,$e||Date.now(),Date.now()]);else if(typeof ye==="function")ye.apply(this,arguments)})}}var c=e.copyFile;if(c)e.copyFile=l;function l(Q,te,re,ae){if(typeof re==="function")ae=re,re=0;return se(Q,te,re,ae);function se(le,Se,ve,ye,$e){return c(le,Se,ve,function(_e){if(_e&&(_e.code==="EMFILE"||_e.code==="ENFILE"))gp([se,[le,Se,ve,ye],_e,$e||Date.now(),Date.now()]);else if(typeof ye==="function")ye.apply(this,arguments)})}}var S=e.readdir;e.readdir=g;var m=/^v[0-5]\./;function g(Q,te,re){if(typeof te==="function")re=te,te=null;var ae=m.test(process.version)?function(Se,ve,ye,$e){return S(Se,se(Se,ve,ye,$e))}:function(Se,ve,ye,$e){return S(Se,ve,se(Se,ve,ye,$e))};return ae(Q,te,re);function se(le,Se,ve,ye){return function($e,_e){if($e&&($e.code==="EMFILE"||$e.code==="ENFILE"))gp([ae,[le,Se,ve],$e,ye||Date.now(),Date.now()]);else{if(_e&&_e.sort)_e.sort();if(typeof ve==="function")ve.call(this,$e,_e)}}}}if(process.version.substr(0,4)==="v0.8"){var w=s5(e);x=w.ReadStream,X=w.WriteStream}var k=e.ReadStream;if(k)x.prototype=Object.create(k.prototype),x.prototype.open=z;var A=e.WriteStream;if(A)X.prototype=Object.create(A.prototype),X.prototype.open=I;Object.defineProperty(e,"ReadStream",{get:function(){return x},set:function(Q){x=Q},enumerable:!0,configurable:!0}),Object.defineProperty(e,"WriteStream",{get:function(){return X},set:function(Q){X=Q},enumerable:!0,configurable:!0});var y=x;Object.defineProperty(e,"FileReadStream",{get:function(){return y},set:function(Q){y=Q},enumerable:!0,configurable:!0});var h=X;Object.defineProperty(e,"FileWriteStream",{get:function(){return h},set:function(Q){h=Q},enumerable:!0,configurable:!0});function x(Q,te){if(this instanceof x)return k.apply(this,arguments),this;else return x.apply(Object.create(x.prototype),arguments)}function z(){var Q=this;ee(Q.path,Q.flags,Q.mode,function(te,re){if(te){if(Q.autoClose)Q.destroy();Q.emit("error",te)}else Q.fd=re,Q.emit("open",re),Q.read()})}function X(Q,te){if(this instanceof X)return A.apply(this,arguments),this;else return X.apply(Object.create(X.prototype),arguments)}function I(){var Q=this;ee(Q.path,Q.flags,Q.mode,function(te,re){if(te)Q.destroy(),Q.emit("error",te);else Q.fd=re,Q.emit("open",re)})}function me(Q,te){return new e.ReadStream(Q,te)}function pe(Q,te){return new e.WriteStream(Q,te)}var K=e.open;e.open=ee;function ee(Q,te,re,ae){if(typeof re==="function")ae=re,re=null;return se(Q,te,re,ae);function se(le,Se,ve,ye,$e){return K(le,Se,ve,function(_e,nr){if(_e&&(_e.code==="EMFILE"||_e.code==="ENFILE"))gp([se,[le,Se,ve,ye],_e,$e||Date.now(),Date.now()]);else if(typeof ye==="function")ye.apply(this,arguments)})}}return e}function gp(e){La("ENQUEUE",e[0].name,e[1]),$t[Tr].push(e),oA()}var uy;function s$(){var e=Date.now();for(var t=0;t<$t[Tr].length;++t)if($t[Tr][t].length>2)$t[Tr][t][3]=e,$t[Tr][t][4]=e;oA()}function oA(){if(clearTimeout(uy),uy=void 0,$t[Tr].length===0)return;var e=$t[Tr].shift(),t=e[0],r=e[1],n=e[2],o=e[3],i=e[4];if(o===void 0)La("RETRY",t.name,r),t.apply(null,r);else if(Date.now()-o>=60000){La("TIMEOUT",t.name,r);var s=r.pop();if(typeof s==="function")s.call(null,n)}else{var c=Date.now()-i,l=Math.max(i-o,1),S=Math.min(l*1.2,100);if(c>=S)La("RETRY",t.name,r),t.apply(null,r.concat([o]));else $t[Tr].push(e)}if(uy===void 0)uy=setTimeout(oA,0)}});var p$=vn(function(Zbe,c$){function zn(e,t){if(typeof t==="boolean")t={forever:t};if(this._originalTimeouts=JSON.parse(JSON.stringify(e)),this._timeouts=e,this._options=t||{},this._maxRetryTime=t&&t.maxRetryTime||1/0,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,this._operationStart=null,this._options.forever)this._cachedTimeouts=this._timeouts.slice(0)}c$.exports=zn;zn.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts};zn.prototype.stop=function(){if(this._timeout)clearTimeout(this._timeout);this._timeouts=[],this._cachedTimeouts=null};zn.prototype.retry=function(e){if(this._timeout)clearTimeout(this._timeout);if(!e)return!1;var t=new Date().getTime();if(e&&t-this._operationStart>=this._maxRetryTime)return this._errors.unshift(Error("RetryOperation timeout occurred")),!1;this._errors.push(e);var r=this._timeouts.shift();if(r===void 0)if(this._cachedTimeouts)this._errors.splice(this._errors.length-1,this._errors.length),this._timeouts=this._cachedTimeouts.slice(0),r=this._timeouts.shift();else return!1;var n=this,o=setTimeout(function(){if(n._attempts++,n._operationTimeoutCb){if(n._timeout=setTimeout(function(){n._operationTimeoutCb(n._attempts)},n._operationTimeout),n._options.unref)n._timeout.unref()}n._fn(n._attempts)},r);if(this._options.unref)o.unref();return!0};zn.prototype.attempt=function(e,t){if(this._fn=e,t){if(t.timeout)this._operationTimeout=t.timeout;if(t.cb)this._operationTimeoutCb=t.cb}var r=this;if(this._operationTimeoutCb)this._timeout=setTimeout(function(){r._operationTimeoutCb()},r._operationTimeout);this._operationStart=new Date().getTime(),this._fn(this._attempts)};zn.prototype.try=function(e){console.log("Using RetryOperation.try() is deprecated"),this.attempt(e)};zn.prototype.start=function(e){console.log("Using RetryOperation.start() is deprecated"),this.attempt(e)};zn.prototype.start=zn.prototype.try;zn.prototype.errors=function(){return this._errors};zn.prototype.attempts=function(){return this._attempts};zn.prototype.mainError=function(){if(this._errors.length===0)return null;var e={},t=null,r=0;for(var n=0;n<this._errors.length;n++){var o=this._errors[n],i=o.message,s=(e[i]||0)+1;if(e[i]=s,s>=r)t=o,r=s}return t}});var u$=vn(function(aA){var p5=p$();aA.operation=function(e){var t=aA.timeouts(e);return new p5(t,{forever:e&&e.forever,unref:e&&e.unref,maxRetryTime:e&&e.maxRetryTime})};aA.timeouts=function(e){if(e instanceof Array)return[].concat(e);var t={retries:10,factor:2,minTimeout:1000,maxTimeout:1/0,randomize:!1};for(var r in e)t[r]=e[r];if(t.minTimeout>t.maxTimeout)throw Error("minTimeout is greater than maxTimeout");var n=[];for(var o=0;o<t.retries;o++)n.push(this.createTimeout(o,t));if(e&&e.forever&&!n.length)n.push(this.createTimeout(o,t));return n.sort(function(i,s){return i-s}),n};aA.createTimeout=function(e,t){var r=t.randomize?Math.random()+1:1,n=Math.round(r*t.minTimeout*Math.pow(t.factor,e));return n=Math.min(n,t.maxTimeout),n};aA.wrap=function(e,t,r){if(t instanceof Array)r=t,t=null;if(!r){r=[];for(var n in e)if(typeof e[n]==="function")r.push(n)}for(var o=0;o<r.length;o++){var i=r[o],s=e[i];e[i]=function(l){var S=aA.operation(t),m=Array.prototype.slice.call(arguments,1),g=m.pop();m.push(function(w){if(S.retry(w))return;if(w)arguments[0]=S.mainError();g.apply(this,arguments)}),S.attempt(function(){l.apply(e,m)})}.bind(e,s),e[i].options=t}}});var l$=vn(function(eIe,fy){fy.exports=["SIGABRT","SIGALRM","SIGHUP","SIGINT","SIGTERM"];if(process.platform!=="win32")fy.exports.push("SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");if(process.platform==="linux")fy.exports.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT","SIGUNUSED")});var f$=vn(function(tIe,Sp){var Lt=global.process,Ma=function(e){return e&&typeof e==="object"&&typeof e.removeListener==="function"&&typeof e.emit==="function"&&typeof e.reallyExit==="function"&&typeof e.listeners==="function"&&typeof e.kill==="function"&&typeof e.pid==="number"&&typeof e.on==="function"};if(!Ma(Lt))Sp.exports=function(){return function(){}};else{if(cA=Ci("assert"),Fa=l$(),pA=/^win/i.test(Lt.platform),xp=Ci("events"),typeof xp!=="function")xp=xp.EventEmitter;if(Lt.__signal_exit_emitter__)ur=Lt.__signal_exit_emitter__;else ur=Lt.__signal_exit_emitter__=new xp,ur.count=0,ur.emitted={};if(!ur.infinite)ur.setMaxListeners(1/0),ur.infinite=!0;Sp.exports=function(e,t){if(!Ma(global.process))return function(){};if(cA.equal(typeof e,"function","a callback must be provided for exit handler"),Na===!1)my();var r="exit";if(t&&t.alwaysLast)r="afterexit";var n=function(){if(ur.removeListener(r,e),ur.listeners("exit").length===0&&ur.listeners("afterexit").length===0)el()};return ur.on(r,e),n},el=function(){if(!Na||!Ma(global.process))return;Na=!1,Fa.forEach(function(t){try{Lt.removeListener(t,tl[t])}catch(r){}}),Lt.emit=rl,Lt.reallyExit=hy,ur.count-=1},Sp.exports.unload=el,Is=function(t,r,n){if(ur.emitted[t])return;ur.emitted[t]=!0,ur.emit(t,r,n)},tl={},Fa.forEach(function(e){tl[e]=function(){if(!Ma(global.process))return;var r=Lt.listeners(e);if(r.length===ur.count){if(el(),Is("exit",null,e),Is("afterexit",null,e),pA&&e==="SIGHUP")e="SIGINT";Lt.kill(Lt.pid,e)}}}),Sp.exports.signals=function(){return Fa},Na=!1,my=function(){if(Na||!Ma(global.process))return;Na=!0,ur.count+=1,Fa=Fa.filter(function(t){try{return Lt.on(t,tl[t]),!0}catch(r){return!1}}),Lt.emit=uA,Lt.reallyExit=dA},Sp.exports.load=my,hy=Lt.reallyExit,dA=function(t){if(!Ma(global.process))return;Lt.exitCode=t||0,Is("exit",Lt.exitCode,null),Is("afterexit",Lt.exitCode,null),hy.call(Lt,Lt.exitCode)},rl=Lt.emit,uA=function(t,r){if(t==="exit"&&Ma(global.process)){if(r!==void 0)Lt.exitCode=r;var n=rl.apply(this,arguments);return Is("exit",Lt.exitCode,null),Is("afterexit",Lt.exitCode,null),n}else return rl.apply(this,arguments)}}var cA,Fa,pA,xp,ur,el,Is,tl,Na,my,hy,dA,rl,uA});var h$=vn(function(h5,lA){var m$=Symbol();function f5(e,t,r){let n=t[m$];if(n)return t.stat(e,(i,s)=>{if(i)return r(i);r(null,s.mtime,n)});let o=new Date(Math.ceil(Date.now()/1000)*1000+5);t.utimes(e,o,o,(i)=>{if(i)return r(i);t.stat(e,(s,c)=>{if(s)return r(s);let l=c.mtime.getTime()%1000===0?"s":"ms";Object.defineProperty(t,m$,{value:l}),r(null,c.mtime,l)})})}function m5(e){let t=Date.now();if(e==="s")t=Math.ceil(t/1000)*1000;return new Date(t)}h5.probe=f5;h5.getMtime=m5});var I$=vn(function(w5,ol){var y$=Ci("path"),hA=sA(),g$=u$(),x5=f$(),gy=h$(),ki={};function nl(e,t){return t.lockfilePath||`${e}.lock`}function yA(e,t,r){if(!t.realpath)return r(null,y$.resolve(e));t.fs.realpath(e,r)}function mA(e,t,r){let n=nl(e,t);t.fs.mkdir(n,(o)=>{if(!o)return gy.probe(n,t.fs,(i,s,c)=>{if(i)return t.fs.rmdir(n,()=>{}),r(i);r(null,s,c)});if(o.code!=="EEXIST")return r(o);if(t.stale<=0)return r(Object.assign(Error("Lock file is already being held"),{code:"ELOCKED",file:e}));t.fs.stat(n,(i,s)=>{if(i){if(i.code==="ENOENT")return mA(e,{...t,stale:0},r);return r(i)}if(!x$(s,t))return r(Object.assign(Error("Lock file is already being held"),{code:"ELOCKED",file:e}));S$(e,t,(c)=>{if(c)return r(c);mA(e,{...t,stale:0},r)})})})}function x$(e,t){return e.mtime.getTime()<Date.now()-t.stale}function S$(e,t,r){t.fs.rmdir(nl(e,t),(n)=>{if(n&&n.code!=="ENOENT")return r(n);r()})}function yy(e,t){let r=ki[e];if(r.updateTimeout)return;if(r.updateDelay=r.updateDelay||t.update,r.updateTimeout=setTimeout(()=>{r.updateTimeout=null,t.fs.stat(r.lockfilePath,(n,o)=>{let i=r.lastUpdate+t.stale<Date.now();if(n){if(n.code==="ENOENT"||i)return fA(e,r,Object.assign(n,{code:"ECOMPROMISED"}));return r.updateDelay=1000,yy(e,t)}if(r.mtime.getTime()!==o.mtime.getTime())return fA(e,r,Object.assign(Error("Unable to update lock within the stale threshold"),{code:"ECOMPROMISED"}));let c=gy.getMtime(r.mtimePrecision);t.fs.utimes(r.lockfilePath,c,c,(l)=>{let S=r.lastUpdate+t.stale<Date.now();if(r.released)return;if(l){if(l.code==="ENOENT"||S)return fA(e,r,Object.assign(l,{code:"ECOMPROMISED"}));return r.updateDelay=1000,yy(e,t)}r.mtime=c,r.lastUpdate=Date.now(),r.updateDelay=null,yy(e,t)})})},r.updateDelay),r.updateTimeout.unref)r.updateTimeout.unref()}function fA(e,t,r){if(t.released=!0,t.updateTimeout)clearTimeout(t.updateTimeout);if(ki[e]===t)delete ki[e];t.options.onCompromised(r)}function S5(e,t,r){t={stale:1e4,update:null,realpath:!0,retries:0,fs:hA,onCompromised:(n)=>{throw n},...t},t.retries=t.retries||0,t.retries=typeof t.retries==="number"?{retries:t.retries}:t.retries,t.stale=Math.max(t.stale||0,2000),t.update=t.update==null?t.stale/2:t.update||0,t.update=Math.max(Math.min(t.update,t.stale/2),1000),yA(e,t,(n,o)=>{if(n)return r(n);let i=g$.operation(t.retries);i.attempt(()=>{mA(o,t,(s,c,l)=>{if(i.retry(s))return;if(s)return r(i.mainError());let S=ki[o]={lockfilePath:nl(o,t),mtime:c,mtimePrecision:l,options:t,lastUpdate:Date.now()};yy(o,t),r(null,(m)=>{if(S.released)return m&&m(Object.assign(Error("Lock is already released"),{code:"ERELEASED"}));b$(o,{...t,realpath:!1},m)})})})})}function b$(e,t,r){t={fs:hA,realpath:!0,...t},yA(e,t,(n,o)=>{if(n)return r(n);let i=ki[o];if(!i)return r(Object.assign(Error("Lock is not acquired/owned by you"),{code:"ENOTACQUIRED"}));i.updateTimeout&&clearTimeout(i.updateTimeout),i.released=!0,delete ki[o],S$(o,t,r)})}function b5(e,t,r){t={stale:1e4,realpath:!0,fs:hA,...t},t.stale=Math.max(t.stale||0,2000),yA(e,t,(n,o)=>{if(n)return r(n);t.fs.stat(nl(o,t),(i,s)=>{if(i)return i.code==="ENOENT"?r(null,!1):r(i);return r(null,!x$(s,t))})})}function I5(){return ki}x5(()=>{for(let e in ki){let t=ki[e].options;try{t.fs.rmdirSync(nl(e,t))}catch(r){}}});w5.lock=S5;w5.unlock=b$;w5.check=b5;w5.getLocks=I5});var E$=vn(function(rIe,w$){var C5=sA();function T5(e){let t=["mkdir","realpath","stat","rmdir","utimes"],r={...e};return t.forEach((n)=>{r[n]=(...o)=>{let i=o.pop(),s;try{s=e[`${n}Sync`](...o)}catch(c){return i(c)}i(null,s)}}),r}function O5(e){return(...t)=>new Promise((r,n)=>{t.push((o,i)=>{if(o)n(o);else r(i)}),e(...t)})}function P5(e){return(...t)=>{let r,n;if(t.push((o,i)=>{r=o,n=i}),e(...t),r)throw r;return n}}function R5(e){if(e={...e},e.fs=T5(e.fs||C5),typeof e.retries==="number"&&e.retries>0||e.retries&&typeof e.retries.retries==="number"&&e.retries.retries>0)throw Object.assign(Error("Cannot use retries with the sync api"),{code:"ESYNC"});return e}w$.exports={toPromise:O5,toSync:P5,toSyncOptions:R5}});var A$=vn(function(nIe,ws){var jn=I$(),{toPromise:xy,toSync:Sy,toSyncOptions:gA}=E$();async function k$(e,t){let r=await xy(jn.lock)(e,t);return xy(r)}function _5(e,t){let r=Sy(jn.lock)(e,gA(t));return Sy(r)}function U5(e,t){return xy(jn.unlock)(e,t)}function D5(e,t){return Sy(jn.unlock)(e,gA(t))}function L5(e,t){return xy(jn.check)(e,t)}function M5(e,t){return Sy(jn.check)(e,gA(t))}ws.exports=k$;ws.exports.lock=k$;ws.exports.unlock=U5;ws.exports.lockSync=_5;ws.exports.unlockSync=D5;ws.exports.check=L5;ws.exports.checkSync=M5});var et=(e,t)=>{switch(t.length){case 0:return e;case 1:return t[0](e);case 2:return t[1](t[0](e));case 3:return t[2](t[1](t[0](e)));case 4:return t[3](t[2](t[1](t[0](e))));case 5:return t[4](t[3](t[2](t[1](t[0](e)))));case 6:return t[5](t[4](t[3](t[2](t[1](t[0](e))))));case 7:return t[6](t[5](t[4](t[3](t[2](t[1](t[0](e)))))));case 8:return t[7](t[6](t[5](t[4](t[3](t[2](t[1](t[0](e))))))));case 9:return t[8](t[7](t[6](t[5](t[4](t[3](t[2](t[1](t[0](e)))))))));default:{let r=e;for(let n=0,o=t.length;n<o;n++)r=t[n](r);return r}}},Ay={pipe(){return et(this,arguments)}},qa=function(){function e(){}return e.prototype=Ay,e}();var q=function(e,t){if(typeof e==="function")return function(){return e(arguments)?t.apply(this,arguments):(r)=>t(r,...arguments)};switch(e){case 0:case 1:throw RangeError(`Invalid arity ${e}`);case 2:return function(r,n){if(arguments.length>=2)return t(r,n);return function(o){return t(o,r)}};case 3:return function(r,n,o){if(arguments.length>=3)return t(r,n,o);return function(i){return t(i,r,n)}};default:return function(){if(arguments.length>=e)return t.apply(this,arguments);let r=arguments;return function(n){return t(n,...r)}}}};var Ee=(e)=>e;var cn=(e)=>()=>e,Ti=cn(!0),vy=cn(!1);var Wa=cn(void 0),Go=Wa;function Oi(e,...t){return et(e,t)}function Pi(e){let t=new WeakMap;return(r)=>{let n=t.get(r);if(n!==void 0)return n;let o=e(r);return t.set(r,o),o}}function wp(e){let t=new WeakMap;return(r)=>{let n=t.get(r);if(n!==void 0)return n;let o=e(r);if(t.set(r,o),o!==r)t.set(o,o);return o}}var Z1=["line","column","sourceURL","originalLine","originalColumn"],DA=(e)=>{let t=Object.getOwnPropertyNames(e),r=Object.getOwnPropertySymbols(e);return r.length>0?[...t,...r]:t},Ep=(e)=>{let t=DA(e),r=Object.getPrototypeOf(e);if(r===Object.prototype||r===null)return t;let n=new Set(t);if(e instanceof Error){n.delete("stack");for(let i of Z1)if(!Object.prototype.propertyIsEnumerable.call(e,i))n.delete(i)}let o=r;while(o!==null&&o!==Object.prototype){for(let i of DA(o))n.add(i);o=Object.getPrototypeOf(o)}if(typeof e.constructor==="function"&&r===e.constructor.prototype)n.delete("constructor");return n},kp=new WeakSet,Ga=(e)=>Array.isArray(e)?5:ArrayBuffer.isView(e)?e instanceof DataView?7:6:Object.getPrototypeOf(e)===Object.prototype?0:e instanceof Date?1:e instanceof RegExp?2:e instanceof Map?3:e instanceof Set?4:e instanceof ArrayBuffer?8:typeof SharedArrayBuffer<"u"&&e instanceof SharedArrayBuffer?9:0,Ap=(e,t)=>{try{return t===7?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e)}catch{return}},Ts=0,yl=()=>{Ts++},Os=new WeakMap,Cy=(e)=>(e^=e>>>16,e=Math.imul(e,2246822507),e^=e>>>13,e=Math.imul(e,3266489909),e^e>>>16),Jr=(e,t)=>Cy(Math.imul(e,2654435761)+Math.imul(t,2246822507));var Mt=(e,t)=>(typeof e==="object"&&e!==null||typeof e==="function")&&(t in e);var kt="~effect/Hash",je=(e)=>{switch(typeof e){case"number":return _y(e);case"bigint":return Kr(e.toString(10));case"string":return Kr(e);case"function":case"object":{if(e===null)break;let t=Ga(e);if(t===1){if(Number.isNaN(e.getTime()))return Kr("Invalid Date");return Kr(e.toISOString())}else if(t===2)return Kr(e.toString());else{if(kp.has(e))return Ty(e);let r=Os.get(e);if(r!==void 0)return r;if(Py.has(e))return yl(),Kr("[Circular]");Py.add(e);let n=Ts,o;try{if(gl(e))o=e[kt]();else if(typeof e==="function")o=Ty(e);else if(t>=7){let i=Ap(e,t);o=i===void 0?Ty(e):LA(i)}else if(t>=5)o=LA(e);else if(t===3)o=Ry(eW,e,tW);else if(t===4)o=Ry(NA,e,rW);else o=Cp(e)}finally{Py.delete(e)}if(n===Ts)Os.set(e,o);return o}}}return Ri(Cy(Kr(String(e))))},Ty=(e)=>{let t=MA.get(e);if(t===void 0)MA.set(e,t=Ri(Math.random()*4294967296|0));return t},vp=q(2,Jr),Ri=(e)=>e&3221225471|e>>>1&1073741824,gl=(e)=>Mt(e,kt)&&typeof e[kt]==="function",Oy=new DataView(new ArrayBuffer(8)),_y=(e)=>{let t=e|0;if(t===e)return Ri(t);return Oy.setFloat64(0,e!==e?NaN:e),Ri(Jr(Oy.getInt32(0),Oy.getInt32(4)))},Kr=(e)=>{let t=5381,r=e.length;while(r)t=t*33^e.charCodeAt(--r);return Ri(t)},Uy=(e,t)=>Ry(12289,t,(r)=>Jr(je(r),je(e[r]))),Cp=(e)=>Uy(e,Ep(e)),Ry=(e,t,r)=>{let n=e;for(let o of t)n^=r(o);return Ri(n)},FA=(e)=>{let t=6151;for(let r of e)t=Jr(t,je(r));return Ri(t)},LA=(e)=>{let t=6151;for(let r=0;r<e.length;r++)t=Jr(t,je(e[r]));return Ri(t)},eW=Kr("Map"),NA=Kr("Set"),tW=([e,t])=>Jr(je(e),je(t)),rW=(e)=>Jr(NA,je(e)),MA=new WeakMap,Py=new WeakSet;var At="~effect/Equal";function or(){if(arguments.length===1)return(e)=>Ps(e,arguments[0]);return Ps(arguments[0],arguments[1])}function Ps(e,t){if(e==null||t==null)return e===t;let r=typeof e;if(r!=="object"&&r!=="function")return e===t||e!==e&&t!==t;if(e===t){if(Tp.length>0&&!Os.has(e))je(e);return!0}if(r!==typeof t||kp.has(e)||kp.has(t))return!1;return nW(e,t)}function nW(e,t){let r=Tp.length,n=Dy.get(e);if(n===t)return!0;let o;if(!r||n!==void 0){o=BA.get(e);let l=o?.get(t);if(l!==void 0)return l}let i=!1;for(let l=r;l-- >0;){let S=Tp[l]===e;if(S||xl[l]===t){if(yl(),S&&xl[l]===t)return!0;i=!0}}if(i&&je(e)!==je(t))return!1;let s=Ts;Tp.push(e),xl.push(t);let c;try{c=oW(e,t)}finally{if(Tp.pop(),xl.pop(),!r)Dy.clear()}if(s!==Ts)return c&&je(e)===je(t);if(r&&n===void 0){if(c)Dy.set(e,t)}else{if(!o)BA.set(e,o=new WeakMap);o.set(t,c)}return c}var Tp=[],xl=[],Dy=new Map,BA=new WeakMap;function oW(e,t){let r=Os.get(e);if(r!==void 0&&r!==(Os.get(t)??r))return!1;let n=Ga(e);if(n===1||n===2){if(Ga(t)!==n)return!1;if(n===2)return e.toString()===t.toString();if(je(e)!==je(t))return!1;let i=e.getTime(),s=t.getTime();return i===s||i!==i&&s!==s}let o=$A(e);if(o!==$A(t)||typeof e==="function"&&!o)return!1;if((o||gl(e)||gl(t))&&je(e)!==je(t))return!1;if(o)return e[At](t);if(n!==Ga(t))return!1;if(n>=7){let i=Ap(e,n),s=Ap(t,n);return i!==void 0&&s!==void 0&&KA(i,s)}else if(n===5)return iW(e,t);else if(n===6)return e.byteLength===t.byteLength&&KA(e,t);else if(n===3)return e.size===t.size&&qA(e,t,aW,cW);else if(n===4)return e.size===t.size&&qA(e,t,je,Ps);return sW(e,t)}function iW(e,t){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!Ps(e[r],t[r]))return!1;return!0}function KA(e,t){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(e[r]!==t[r])return!1;return!0}function sW(e,t){let r=Ep(e),n=Ep(t),o=n instanceof Set;if((r instanceof Set?r.size:r.length)!==(o?n.size:n.length))return!1;for(let i of r)if(!(o?n.has(i):Object.hasOwn(t,i))||!Ps(e[i],t[i]))return!1;return!0}function qA(e,t,r,n){let o=new Map,i=0;for(let s of t){let c=r(s),l=o.get(c);if(l)l.push(s);else o.set(c,[s]);i++}e:for(let s of e){let c=o.get(r(s));if(c){for(let l=0;l<c.length;l++)if(n(s,c[l])){c[l]=c[c.length-1],c.pop(),i--;continue e}}return!1}return i===0}var aW=(e)=>je(e[0]),cW=(e,t)=>Ps(e[0],t[0])&&Ps(e[1],t[1]);var $A=(e)=>Mt(e,At)&&typeof e[At]==="function";function Yr(e){let t=Object.keys(e);for(let r of Object.getOwnPropertySymbols(e))if(Object.prototype.propertyIsEnumerable.call(e,r))t.push(r);return t}function Zr(e,t,r){if(t==="__proto__")Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0});else e[t]=r}function WA(e,t){if(!Object.hasOwn(t,"__proto__")){Object.assign(e,t);return}for(let r of Yr(t))Zr(e,r,t[r])}function jo(e){return typeof e==="string"}function Op(e){return typeof e==="number"}function Sl(e){return typeof e==="boolean"}function GA(e){return typeof e==="symbol"}function Ly(e){return jo(e)||Op(e)||GA(e)}function bo(e){return typeof e==="function"}function ja(e){return e===void 0}function Yt(e){return e!==void 0}function zA(e){return e===null}function bl(e){return e!==null}function jA(e){return e===null||e===void 0}function My(e){return e!=null}function QA(e){return!0}function HA(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function Pp(e){return typeof e==="object"&&e!==null||bo(e)}var He=q(2,Mt),Io=q(2,(e,t)=>He(e,"_tag")&&e._tag===t);function VA(e){return e instanceof Error}function JA(e){return He(e,Symbol.iterator)||jo(e)}var Rs=Symbol.for("~effect/Redactable"),pW=(e)=>He(e,Rs);function Qn(e){if(pW(e))return Fy(e);return e}function Fy(e){return e[Rs](globalThis[Qa]?.context??dW)}var Qa="~effect/Fiber/currentFiber",YA=new Map,dW={"~effect/Context":{},base:YA,depth:0,mapUnsafe:YA,pipe(){return et(this,arguments)}};function rt(e,t){let r=t?.space??0,n=new WeakSet,o=!r?"":typeof r==="number"?" ".repeat(r):r,i=(m)=>o.repeat(m),s=(m,g)=>{let w=m?.constructor;return w&&w!==Object.prototype.constructor&&w.name?`${w.name}(${g})`:g},c=(m)=>{try{return Reflect.ownKeys(m)}catch{return["[ownKeys threw]"]}};function l(m,g=0){try{return S(m,g)}catch{if(typeof m==="object"&&m!==null||typeof m==="function")n.delete(m);return"[inspection threw]"}}function S(m,g=0){if(typeof m==="string")return JSON.stringify(m);if(typeof m==="number"||m==null||typeof m==="boolean"||typeof m==="symbol")return String(m);if(typeof m==="bigint")return String(m)+"n";if(typeof m==="object"||typeof m==="function"){if(n.has(m))return uW;n.add(m);let w;if(Rs in m)w=l(Fy(m),g);else if(Array.isArray(m))w=!o||m.length<=1?`[${m.map((k)=>l(k,g)).join(",")}]`:`[
5
- ${i(g+1)}${m.map((k)=>l(k,g+1)).join(`,
3
+ var L2=Object.create;var{getPrototypeOf:M2,defineProperty:Mv,getOwnPropertyNames:F2}=Object;var Fv=Object.prototype.hasOwnProperty;function N2(e){return this[e]}var B2,K2,q2=(e,t,r)=>{var n=e!=null&&typeof e==="object";if(n){var o=t?B2??=new WeakMap:K2??=new WeakMap,i=o.get(e);if(i)return i}r=e!=null?L2(M2(e)):{};let s=t||!e||!e.__esModule||!Fv.call(e,"default")?Mv(r,"default",{value:e,enumerable:!0}):r;if(e&&typeof e==="object"||typeof e==="function"){for(let c of F2(e))if(!Fv.call(s,c))Mv(s,c,{get:N2.bind(e,c),enumerable:!0})}if(n)o.set(e,s);return s};var Dn=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Qi=import.meta.require;var G$=Dn(function(xke,W$){var qs=Qi("constants"),k7=process.cwd,Gy=null,w7=process.env.GRACEFUL_FS_PLATFORM||process.platform;process.cwd=function(){if(!Gy)Gy=k7.call(process);return Gy};try{process.cwd()}catch(e){}if(typeof process.chdir==="function"){if(jy=process.chdir,process.chdir=function(e){Gy=null,jy.call(process,e)},Object.setPrototypeOf)Object.setPrototypeOf(process.chdir,jy)}var jy;W$.exports=A7;function A7(e){if(qs.hasOwnProperty("O_SYMLINK")&&process.version.match(/^v0\.6\.[0-2]|^v0\.5\./))t(e);if(!e.lutimes)r(e);if(e.chown=i(e.chown),e.fchown=i(e.fchown),e.lchown=i(e.lchown),e.chmod=n(e.chmod),e.fchmod=n(e.fchmod),e.lchmod=n(e.lchmod),e.chownSync=s(e.chownSync),e.fchownSync=s(e.fchownSync),e.lchownSync=s(e.lchownSync),e.chmodSync=o(e.chmodSync),e.fchmodSync=o(e.fchmodSync),e.lchmodSync=o(e.lchmodSync),e.stat=c(e.stat),e.fstat=c(e.fstat),e.lstat=c(e.lstat),e.statSync=d(e.statSync),e.fstatSync=d(e.fstatSync),e.lstatSync=d(e.lstatSync),e.chmod&&!e.lchmod)e.lchmod=function(f,g,I){if(I)process.nextTick(I)},e.lchmodSync=function(){};if(e.chown&&!e.lchown)e.lchown=function(f,g,I,w){if(w)process.nextTick(w)},e.lchownSync=function(){};if(w7==="win32")e.rename=typeof e.rename!=="function"?e.rename:function(f){function g(I,w,A){var y=Date.now(),h=0;f(I,w,function S(H){if(H&&(H.code==="EACCES"||H.code==="EPERM"||H.code==="EBUSY")&&Date.now()-y<60000){if(setTimeout(function(){e.stat(w,function(te,E){if(te&&te.code==="ENOENT")f(I,w,S);else A(H)})},h),h<100)h+=10;return}if(A)A(H)})}if(Object.setPrototypeOf)Object.setPrototypeOf(g,f);return g}(e.rename);e.read=typeof e.read!=="function"?e.read:function(f){function g(I,w,A,y,h,S){var H;if(S&&typeof S==="function"){var te=0;H=function(E,ge,le){if(E&&E.code==="EAGAIN"&&te<10)return te++,f.call(e,I,w,A,y,h,H);S.apply(this,arguments)}}return f.call(e,I,w,A,y,h,H)}if(Object.setPrototypeOf)Object.setPrototypeOf(g,f);return g}(e.read),e.readSync=typeof e.readSync!=="function"?e.readSync:function(f){return function(g,I,w,A,y){var h=0;while(!0)try{return f.call(e,g,I,w,A,y)}catch(S){if(S.code==="EAGAIN"&&h<10){h++;continue}throw S}}}(e.readSync);function t(f){f.lchmod=function(g,I,w){f.open(g,qs.O_WRONLY|qs.O_SYMLINK,I,function(A,y){if(A){if(w)w(A);return}f.fchmod(y,I,function(h){f.close(y,function(S){if(w)w(h||S)})})})},f.lchmodSync=function(g,I){var w=f.openSync(g,qs.O_WRONLY|qs.O_SYMLINK,I),A=!0,y;try{y=f.fchmodSync(w,I),A=!1}finally{if(A)try{f.closeSync(w)}catch(h){}else f.closeSync(w)}return y}}function r(f){if(qs.hasOwnProperty("O_SYMLINK")&&f.futimes)f.lutimes=function(g,I,w,A){f.open(g,qs.O_SYMLINK,function(y,h){if(y){if(A)A(y);return}f.futimes(h,I,w,function(S){f.close(h,function(H){if(A)A(S||H)})})})},f.lutimesSync=function(g,I,w){var A=f.openSync(g,qs.O_SYMLINK),y,h=!0;try{y=f.futimesSync(A,I,w),h=!1}finally{if(h)try{f.closeSync(A)}catch(S){}else f.closeSync(A)}return y};else if(f.futimes)f.lutimes=function(g,I,w,A){if(A)process.nextTick(A)},f.lutimesSync=function(){}}function n(f){if(!f)return f;return function(g,I,w){return f.call(e,g,I,function(A){if(x(A))A=null;if(w)w.apply(this,arguments)})}}function o(f){if(!f)return f;return function(g,I){try{return f.call(e,g,I)}catch(w){if(!x(w))throw w}}}function i(f){if(!f)return f;return function(g,I,w,A){return f.call(e,g,I,w,function(y){if(x(y))y=null;if(A)A.apply(this,arguments)})}}function s(f){if(!f)return f;return function(g,I,w){try{return f.call(e,g,I,w)}catch(A){if(!x(A))throw A}}}function c(f){if(!f)return f;return function(g,I,w){if(typeof I==="function")w=I,I=null;function A(y,h){if(h){if(h.uid<0)h.uid+=4294967296;if(h.gid<0)h.gid+=4294967296}if(w)w.apply(this,arguments)}return I?f.call(e,g,I,A):f.call(e,g,A)}}function d(f){if(!f)return f;return function(g,I){var w=I?f.call(e,g,I):f.call(e,g);if(w){if(w.uid<0)w.uid+=4294967296;if(w.gid<0)w.gid+=4294967296}return w}}function x(f){if(!f)return!0;if(f.code==="ENOSYS")return!0;var g=!process.getuid||process.getuid()!==0;if(g){if(f.code==="EINVAL"||f.code==="EPERM")return!0}return!1}}});var Q$=Dn(function(Ske,z$){var j$=Qi("stream").Stream;z$.exports=v7;function v7(e){return{ReadStream:t,WriteStream:r};function t(n,o){if(!(this instanceof t))return new t(n,o);j$.call(this);var i=this;this.path=n,this.fd=null,this.readable=!0,this.paused=!1,this.flags="r",this.mode=438,this.bufferSize=65536,o=o||{};var s=Object.keys(o);for(var c=0,d=s.length;c<d;c++){var x=s[c];this[x]=o[x]}if(this.encoding)this.setEncoding(this.encoding);if(this.start!==void 0){if(typeof this.start!=="number")throw TypeError("start must be a Number");if(this.end===void 0)this.end=1/0;else if(typeof this.end!=="number")throw TypeError("end must be a Number");if(this.start>this.end)throw Error("start must be <= end");this.pos=this.start}if(this.fd!==null){process.nextTick(function(){i._read()});return}e.open(this.path,this.flags,this.mode,function(f,g){if(f){i.emit("error",f),i.readable=!1;return}i.fd=g,i.emit("open",g),i._read()})}function r(n,o){if(!(this instanceof r))return new r(n,o);j$.call(this),this.path=n,this.fd=null,this.writable=!0,this.flags="w",this.encoding="binary",this.mode=438,this.bytesWritten=0,o=o||{};var i=Object.keys(o);for(var s=0,c=i.length;s<c;s++){var d=i[s];this[d]=o[d]}if(this.start!==void 0){if(typeof this.start!=="number")throw TypeError("start must be a Number");if(this.start<0)throw Error("start must be >= zero");this.pos=this.start}if(this.busy=!1,this._queue=[],this.fd===null)this._open=e.open,this._queue.push([this._open,this.path,this.flags,this.mode,void 0]),this.flush()}}});var V$=Dn(function(bke,H$){H$.exports=T7;var C7=Object.getPrototypeOf||function(e){return e.__proto__};function T7(e){if(e===null||typeof e!=="object")return e;if(e instanceof Object)var t={__proto__:C7(e)};else var t=Object.create(null);return Object.getOwnPropertyNames(e).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))}),t}});var uv=Dn(function(Ike,dv){var er=Qi("fs"),O7=G$(),P7=Q$(),R7=V$(),zy=Qi("util"),$r,Hy;if(typeof Symbol==="function"&&typeof Symbol.for==="function")$r=Symbol.for("graceful-fs.queue"),Hy=Symbol.for("graceful-fs.previous");else $r="___graceful-fs.queue",Hy="___graceful-fs.previous";function _7(){}function Y$(e,t){Object.defineProperty(e,$r,{get:function(){return t}})}var pc=_7;if(zy.debuglog)pc=zy.debuglog("gfs4");else if(/\bgfs4\b/i.test(process.env.NODE_DEBUG||""))pc=function(){var e=zy.format.apply(zy,arguments);e="GFS4: "+e.split(/\n/).join(`
4
+ GFS4: `),console.error(e)};if(!er[$r]){if(av=global[$r]||[],Y$(er,av),er.close=function(e){function t(r,n){return e.call(er,r,function(o){if(!o)J$();if(typeof n==="function")n.apply(this,arguments)})}return Object.defineProperty(t,Hy,{value:e}),t}(er.close),er.closeSync=function(e){function t(r){e.apply(er,arguments),J$()}return Object.defineProperty(t,Hy,{value:e}),t}(er.closeSync),/\bgfs4\b/i.test(process.env.NODE_DEBUG||""))process.on("exit",function(){pc(er[$r]),Qi("assert").equal(er[$r].length,0)})}var av;if(!global[$r])Y$(global,er[$r]);dv.exports=cv(R7(er));if(process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH&&!er.__patched)dv.exports=cv(er),er.__patched=!0;function cv(e){O7(e),e.gracefulify=cv,e.createReadStream=ge,e.createWriteStream=le;var t=e.readFile;e.readFile=r;function r(V,ne,ie){if(typeof ne==="function")ie=ne,ne=null;return de(V,ne,ie);function de(pe,he,ke,Oe){return t(pe,he,function(Se){if(Se&&(Se.code==="EMFILE"||Se.code==="ENFILE"))$p([de,[pe,he,ke],Se,Oe||Date.now(),Date.now()]);else if(typeof ke==="function")ke.apply(this,arguments)})}}var n=e.writeFile;e.writeFile=o;function o(V,ne,ie,de){if(typeof ie==="function")de=ie,ie=null;return pe(V,ne,ie,de);function pe(he,ke,Oe,Se,Qe){return n(he,ke,Oe,function(Be){if(Be&&(Be.code==="EMFILE"||Be.code==="ENFILE"))$p([pe,[he,ke,Oe,Se],Be,Qe||Date.now(),Date.now()]);else if(typeof Se==="function")Se.apply(this,arguments)})}}var i=e.appendFile;if(i)e.appendFile=s;function s(V,ne,ie,de){if(typeof ie==="function")de=ie,ie=null;return pe(V,ne,ie,de);function pe(he,ke,Oe,Se,Qe){return i(he,ke,Oe,function(Be){if(Be&&(Be.code==="EMFILE"||Be.code==="ENFILE"))$p([pe,[he,ke,Oe,Se],Be,Qe||Date.now(),Date.now()]);else if(typeof Se==="function")Se.apply(this,arguments)})}}var c=e.copyFile;if(c)e.copyFile=d;function d(V,ne,ie,de){if(typeof ie==="function")de=ie,ie=0;return pe(V,ne,ie,de);function pe(he,ke,Oe,Se,Qe){return c(he,ke,Oe,function(Be){if(Be&&(Be.code==="EMFILE"||Be.code==="ENFILE"))$p([pe,[he,ke,Oe,Se],Be,Qe||Date.now(),Date.now()]);else if(typeof Se==="function")Se.apply(this,arguments)})}}var x=e.readdir;e.readdir=g;var f=/^v[0-5]\./;function g(V,ne,ie){if(typeof ne==="function")ie=ne,ne=null;var de=f.test(process.version)?function(ke,Oe,Se,Qe){return x(ke,pe(ke,Oe,Se,Qe))}:function(ke,Oe,Se,Qe){return x(ke,Oe,pe(ke,Oe,Se,Qe))};return de(V,ne,ie);function pe(he,ke,Oe,Se){return function(Qe,Be){if(Qe&&(Qe.code==="EMFILE"||Qe.code==="ENFILE"))$p([de,[he,ke,Oe],Qe,Se||Date.now(),Date.now()]);else{if(Be&&Be.sort)Be.sort();if(typeof Oe==="function")Oe.call(this,Qe,Be)}}}}if(process.version.substr(0,4)==="v0.8"){var I=P7(e);S=I.ReadStream,te=I.WriteStream}var w=e.ReadStream;if(w)S.prototype=Object.create(w.prototype),S.prototype.open=H;var A=e.WriteStream;if(A)te.prototype=Object.create(A.prototype),te.prototype.open=E;Object.defineProperty(e,"ReadStream",{get:function(){return S},set:function(V){S=V},enumerable:!0,configurable:!0}),Object.defineProperty(e,"WriteStream",{get:function(){return te},set:function(V){te=V},enumerable:!0,configurable:!0});var y=S;Object.defineProperty(e,"FileReadStream",{get:function(){return y},set:function(V){y=V},enumerable:!0,configurable:!0});var h=te;Object.defineProperty(e,"FileWriteStream",{get:function(){return h},set:function(V){h=V},enumerable:!0,configurable:!0});function S(V,ne){if(this instanceof S)return w.apply(this,arguments),this;else return S.apply(Object.create(S.prototype),arguments)}function H(){var V=this;re(V.path,V.flags,V.mode,function(ne,ie){if(ne){if(V.autoClose)V.destroy();V.emit("error",ne)}else V.fd=ie,V.emit("open",ie),V.read()})}function te(V,ne){if(this instanceof te)return A.apply(this,arguments),this;else return te.apply(Object.create(te.prototype),arguments)}function E(){var V=this;re(V.path,V.flags,V.mode,function(ne,ie){if(ne)V.destroy(),V.emit("error",ne);else V.fd=ie,V.emit("open",ie)})}function ge(V,ne){return new e.ReadStream(V,ne)}function le(V,ne){return new e.WriteStream(V,ne)}var z=e.open;e.open=re;function re(V,ne,ie,de){if(typeof ie==="function")de=ie,ie=null;return pe(V,ne,ie,de);function pe(he,ke,Oe,Se,Qe){return z(he,ke,Oe,function(Be,fr){if(Be&&(Be.code==="EMFILE"||Be.code==="ENFILE"))$p([pe,[he,ke,Oe,Se],Be,Qe||Date.now(),Date.now()]);else if(typeof Se==="function")Se.apply(this,arguments)})}}return e}function $p(e){pc("ENQUEUE",e[0].name,e[1]),er[$r].push(e),pv()}var Qy;function J$(){var e=Date.now();for(var t=0;t<er[$r].length;++t)if(er[$r][t].length>2)er[$r][t][3]=e,er[$r][t][4]=e;pv()}function pv(){if(clearTimeout(Qy),Qy=void 0,er[$r].length===0)return;var e=er[$r].shift(),t=e[0],r=e[1],n=e[2],o=e[3],i=e[4];if(o===void 0)pc("RETRY",t.name,r),t.apply(null,r);else if(Date.now()-o>=60000){pc("TIMEOUT",t.name,r);var s=r.pop();if(typeof s==="function")s.call(null,n)}else{var c=Date.now()-i,d=Math.max(i-o,1),x=Math.min(d*1.2,100);if(c>=x)pc("RETRY",t.name,r),t.apply(null,r.concat([o]));else er[$r].push(e)}if(Qy===void 0)Qy=setTimeout(pv,0)}});var X$=Dn(function(Eke,Z$){function ao(e,t){if(typeof t==="boolean")t={forever:t};if(this._originalTimeouts=JSON.parse(JSON.stringify(e)),this._timeouts=e,this._options=t||{},this._maxRetryTime=t&&t.maxRetryTime||1/0,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,this._operationStart=null,this._options.forever)this._cachedTimeouts=this._timeouts.slice(0)}Z$.exports=ao;ao.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts};ao.prototype.stop=function(){if(this._timeout)clearTimeout(this._timeout);this._timeouts=[],this._cachedTimeouts=null};ao.prototype.retry=function(e){if(this._timeout)clearTimeout(this._timeout);if(!e)return!1;var t=new Date().getTime();if(e&&t-this._operationStart>=this._maxRetryTime)return this._errors.unshift(Error("RetryOperation timeout occurred")),!1;this._errors.push(e);var r=this._timeouts.shift();if(r===void 0)if(this._cachedTimeouts)this._errors.splice(this._errors.length-1,this._errors.length),this._timeouts=this._cachedTimeouts.slice(0),r=this._timeouts.shift();else return!1;var n=this,o=setTimeout(function(){if(n._attempts++,n._operationTimeoutCb){if(n._timeout=setTimeout(function(){n._operationTimeoutCb(n._attempts)},n._operationTimeout),n._options.unref)n._timeout.unref()}n._fn(n._attempts)},r);if(this._options.unref)o.unref();return!0};ao.prototype.attempt=function(e,t){if(this._fn=e,t){if(t.timeout)this._operationTimeout=t.timeout;if(t.cb)this._operationTimeoutCb=t.cb}var r=this;if(this._operationTimeoutCb)this._timeout=setTimeout(function(){r._operationTimeoutCb()},r._operationTimeout);this._operationStart=new Date().getTime(),this._fn(this._attempts)};ao.prototype.try=function(e){console.log("Using RetryOperation.try() is deprecated"),this.attempt(e)};ao.prototype.start=function(e){console.log("Using RetryOperation.start() is deprecated"),this.attempt(e)};ao.prototype.start=ao.prototype.try;ao.prototype.errors=function(){return this._errors};ao.prototype.attempts=function(){return this._attempts};ao.prototype.mainError=function(){if(this._errors.length===0)return null;var e={},t=null,r=0;for(var n=0;n<this._errors.length;n++){var o=this._errors[n],i=o.message,s=(e[i]||0)+1;if(e[i]=s,s>=r)t=o,r=s}return t}});var tW=Dn(function(lv){var U7=X$();lv.operation=function(e){var t=lv.timeouts(e);return new U7(t,{forever:e&&e.forever,unref:e&&e.unref,maxRetryTime:e&&e.maxRetryTime})};lv.timeouts=function(e){if(e instanceof Array)return[].concat(e);var t={retries:10,factor:2,minTimeout:1000,maxTimeout:1/0,randomize:!1};for(var r in e)t[r]=e[r];if(t.minTimeout>t.maxTimeout)throw Error("minTimeout is greater than maxTimeout");var n=[];for(var o=0;o<t.retries;o++)n.push(this.createTimeout(o,t));if(e&&e.forever&&!n.length)n.push(this.createTimeout(o,t));return n.sort(function(i,s){return i-s}),n};lv.createTimeout=function(e,t){var r=t.randomize?Math.random()+1:1,n=Math.round(r*t.minTimeout*Math.pow(t.factor,e));return n=Math.min(n,t.maxTimeout),n};lv.wrap=function(e,t,r){if(t instanceof Array)r=t,t=null;if(!r){r=[];for(var n in e)if(typeof e[n]==="function")r.push(n)}for(var o=0;o<r.length;o++){var i=r[o],s=e[i];e[i]=function(d){var x=lv.operation(t),f=Array.prototype.slice.call(arguments,1),g=f.pop();f.push(function(I){if(x.retry(I))return;if(I)arguments[0]=x.mainError();g.apply(this,arguments)}),x.attempt(function(){d.apply(e,f)})}.bind(e,s),e[i].options=t}}});var rW=Dn(function(wke,Vy){Vy.exports=["SIGABRT","SIGALRM","SIGHUP","SIGINT","SIGTERM"];if(process.platform!=="win32")Vy.exports.push("SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");if(process.platform==="linux")Vy.exports.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT","SIGUNUSED")});var nW=Dn(function(Ake,Gp){var Gt=global.process,dc=function(e){return e&&typeof e==="object"&&typeof e.removeListener==="function"&&typeof e.emit==="function"&&typeof e.reallyExit==="function"&&typeof e.listeners==="function"&&typeof e.kill==="function"&&typeof e.pid==="number"&&typeof e.on==="function"};if(!dc(Gt))Gp.exports=function(){return function(){}};else{if(fv=Qi("assert"),uc=rW(),mv=/^win/i.test(Gt.platform),Wp=Qi("events"),typeof Wp!=="function")Wp=Wp.EventEmitter;if(Gt.__signal_exit_emitter__)Er=Gt.__signal_exit_emitter__;else Er=Gt.__signal_exit_emitter__=new Wp,Er.count=0,Er.emitted={};if(!Er.infinite)Er.setMaxListeners(1/0),Er.infinite=!0;Gp.exports=function(e,t){if(!dc(global.process))return function(){};if(fv.equal(typeof e,"function","a callback must be provided for exit handler"),lc===!1)Jy();var r="exit";if(t&&t.alwaysLast)r="afterexit";var n=function(){if(Er.removeListener(r,e),Er.listeners("exit").length===0&&Er.listeners("afterexit").length===0)Ol()};return Er.on(r,e),n},Ol=function(){if(!lc||!dc(global.process))return;lc=!1,uc.forEach(function(t){try{Gt.removeListener(t,Pl[t])}catch(r){}}),Gt.emit=Rl,Gt.reallyExit=Yy,Er.count-=1},Gp.exports.unload=Ol,$s=function(t,r,n){if(Er.emitted[t])return;Er.emitted[t]=!0,Er.emit(t,r,n)},Pl={},uc.forEach(function(e){Pl[e]=function(){if(!dc(global.process))return;var r=Gt.listeners(e);if(r.length===Er.count){if(Ol(),$s("exit",null,e),$s("afterexit",null,e),mv&&e==="SIGHUP")e="SIGINT";Gt.kill(Gt.pid,e)}}}),Gp.exports.signals=function(){return uc},lc=!1,Jy=function(){if(lc||!dc(global.process))return;lc=!0,Er.count+=1,uc=uc.filter(function(t){try{return Gt.on(t,Pl[t]),!0}catch(r){return!1}}),Gt.emit=yv,Gt.reallyExit=hv},Gp.exports.load=Jy,Yy=Gt.reallyExit,hv=function(t){if(!dc(global.process))return;Gt.exitCode=t||0,$s("exit",Gt.exitCode,null),$s("afterexit",Gt.exitCode,null),Yy.call(Gt,Gt.exitCode)},Rl=Gt.emit,yv=function(t,r){if(t==="exit"&&dc(global.process)){if(r!==void 0)Gt.exitCode=r;var n=Rl.apply(this,arguments);return $s("exit",Gt.exitCode,null),$s("afterexit",Gt.exitCode,null),n}else return Rl.apply(this,arguments)}}var fv,uc,mv,Wp,Er,Ol,$s,Pl,lc,Jy,Yy,hv,Rl,yv});var iW=Dn(function(B7,gv){var oW=Symbol();function F7(e,t,r){let n=t[oW];if(n)return t.stat(e,(i,s)=>{if(i)return r(i);r(null,s.mtime,n)});let o=new Date(Math.ceil(Date.now()/1000)*1000+5);t.utimes(e,o,o,(i)=>{if(i)return r(i);t.stat(e,(s,c)=>{if(s)return r(s);let d=c.mtime.getTime()%1000===0?"s":"ms";Object.defineProperty(t,oW,{value:d}),r(null,c.mtime,d)})})}function N7(e){let t=Date.now();if(e==="s")t=Math.ceil(t/1000)*1000;return new Date(t)}B7.probe=F7;B7.getMtime=N7});var uW=Dn(function(z7,Ul){var sW=Qi("path"),bv=uv(),aW=tW(),$7=nW(),Xy=iW(),Wi={};function _l(e,t){return t.lockfilePath||`${e}.lock`}function Iv(e,t,r){if(!t.realpath)return r(null,sW.resolve(e));t.fs.realpath(e,r)}function Sv(e,t,r){let n=_l(e,t);t.fs.mkdir(n,(o)=>{if(!o)return Xy.probe(n,t.fs,(i,s,c)=>{if(i)return t.fs.rmdir(n,()=>{}),r(i);r(null,s,c)});if(o.code!=="EEXIST")return r(o);if(t.stale<=0)return r(Object.assign(Error("Lock file is already being held"),{code:"ELOCKED",file:e}));t.fs.stat(n,(i,s)=>{if(i){if(i.code==="ENOENT")return Sv(e,{...t,stale:0},r);return r(i)}if(!cW(s,t))return r(Object.assign(Error("Lock file is already being held"),{code:"ELOCKED",file:e}));pW(e,t,(c)=>{if(c)return r(c);Sv(e,{...t,stale:0},r)})})})}function cW(e,t){return e.mtime.getTime()<Date.now()-t.stale}function pW(e,t,r){t.fs.rmdir(_l(e,t),(n)=>{if(n&&n.code!=="ENOENT")return r(n);r()})}function Zy(e,t){let r=Wi[e];if(r.updateTimeout)return;if(r.updateDelay=r.updateDelay||t.update,r.updateTimeout=setTimeout(()=>{r.updateTimeout=null,t.fs.stat(r.lockfilePath,(n,o)=>{let i=r.lastUpdate+t.stale<Date.now();if(n){if(n.code==="ENOENT"||i)return xv(e,r,Object.assign(n,{code:"ECOMPROMISED"}));return r.updateDelay=1000,Zy(e,t)}if(r.mtime.getTime()!==o.mtime.getTime())return xv(e,r,Object.assign(Error("Unable to update lock within the stale threshold"),{code:"ECOMPROMISED"}));let c=Xy.getMtime(r.mtimePrecision);t.fs.utimes(r.lockfilePath,c,c,(d)=>{let x=r.lastUpdate+t.stale<Date.now();if(r.released)return;if(d){if(d.code==="ENOENT"||x)return xv(e,r,Object.assign(d,{code:"ECOMPROMISED"}));return r.updateDelay=1000,Zy(e,t)}r.mtime=c,r.lastUpdate=Date.now(),r.updateDelay=null,Zy(e,t)})})},r.updateDelay),r.updateTimeout.unref)r.updateTimeout.unref()}function xv(e,t,r){if(t.released=!0,t.updateTimeout)clearTimeout(t.updateTimeout);if(Wi[e]===t)delete Wi[e];t.options.onCompromised(r)}function W7(e,t,r){t={stale:1e4,update:null,realpath:!0,retries:0,fs:bv,onCompromised:(n)=>{throw n},...t},t.retries=t.retries||0,t.retries=typeof t.retries==="number"?{retries:t.retries}:t.retries,t.stale=Math.max(t.stale||0,2000),t.update=t.update==null?t.stale/2:t.update||0,t.update=Math.max(Math.min(t.update,t.stale/2),1000),Iv(e,t,(n,o)=>{if(n)return r(n);let i=aW.operation(t.retries);i.attempt(()=>{Sv(o,t,(s,c,d)=>{if(i.retry(s))return;if(s)return r(i.mainError());let x=Wi[o]={lockfilePath:_l(o,t),mtime:c,mtimePrecision:d,options:t,lastUpdate:Date.now()};Zy(o,t),r(null,(f)=>{if(x.released)return f&&f(Object.assign(Error("Lock is already released"),{code:"ERELEASED"}));dW(o,{...t,realpath:!1},f)})})})})}function dW(e,t,r){t={fs:bv,realpath:!0,...t},Iv(e,t,(n,o)=>{if(n)return r(n);let i=Wi[o];if(!i)return r(Object.assign(Error("Lock is not acquired/owned by you"),{code:"ENOTACQUIRED"}));i.updateTimeout&&clearTimeout(i.updateTimeout),i.released=!0,delete Wi[o],pW(o,t,r)})}function G7(e,t,r){t={stale:1e4,realpath:!0,fs:bv,...t},t.stale=Math.max(t.stale||0,2000),Iv(e,t,(n,o)=>{if(n)return r(n);t.fs.stat(_l(o,t),(i,s)=>{if(i)return i.code==="ENOENT"?r(null,!1):r(i);return r(null,!cW(s,t))})})}function j7(){return Wi}$7(()=>{for(let e in Wi){let t=Wi[e].options;try{t.fs.rmdirSync(_l(e,t))}catch(r){}}});z7.lock=W7;z7.unlock=dW;z7.check=G7;z7.getLocks=j7});var fW=Dn(function(vke,lW){var Y7=uv();function Z7(e){let t=["mkdir","realpath","stat","rmdir","utimes"],r={...e};return t.forEach((n)=>{r[n]=(...o)=>{let i=o.pop(),s;try{s=e[`${n}Sync`](...o)}catch(c){return i(c)}i(null,s)}}),r}function X7(e){return(...t)=>new Promise((r,n)=>{t.push((o,i)=>{if(o)n(o);else r(i)}),e(...t)})}function eX(e){return(...t)=>{let r,n;if(t.push((o,i)=>{r=o,n=i}),e(...t),r)throw r;return n}}function tX(e){if(e={...e},e.fs=Z7(e.fs||Y7),typeof e.retries==="number"&&e.retries>0||e.retries&&typeof e.retries.retries==="number"&&e.retries.retries>0)throw Object.assign(Error("Cannot use retries with the sync api"),{code:"ESYNC"});return e}lW.exports={toPromise:X7,toSync:eX,toSyncOptions:tX}});var hW=Dn(function(Cke,Ws){var co=uW(),{toPromise:eg,toSync:tg,toSyncOptions:Ev}=fW();async function mW(e,t){let r=await eg(co.lock)(e,t);return eg(r)}function rX(e,t){let r=tg(co.lock)(e,Ev(t));return tg(r)}function nX(e,t){return eg(co.unlock)(e,t)}function oX(e,t){return tg(co.unlock)(e,Ev(t))}function iX(e,t){return eg(co.check)(e,t)}function sX(e,t){return tg(co.check)(e,Ev(t))}Ws.exports=mW;Ws.exports.lock=mW;Ws.exports.unlock=nX;Ws.exports.lockSync=rX;Ws.exports.unlockSync=oX;Ws.exports.check=iX;Ws.exports.checkSync=sX});var nt=(e,t)=>{switch(t.length){case 0:return e;case 1:return t[0](e);case 2:return t[1](t[0](e));case 3:return t[2](t[1](t[0](e)));case 4:return t[3](t[2](t[1](t[0](e))));case 5:return t[4](t[3](t[2](t[1](t[0](e)))));case 6:return t[5](t[4](t[3](t[2](t[1](t[0](e))))));case 7:return t[6](t[5](t[4](t[3](t[2](t[1](t[0](e)))))));case 8:return t[7](t[6](t[5](t[4](t[3](t[2](t[1](t[0](e))))))));case 9:return t[8](t[7](t[6](t[5](t[4](t[3](t[2](t[1](t[0](e)))))))));default:{let r=e;for(let n=0,o=t.length;n<o;n++)r=t[n](r);return r}}},pg={pipe(){return nt(this,arguments)}},mc=function(){function e(){}return e.prototype=pg,e}();var W=function(e,t){if(typeof e==="function")return function(){return e(arguments)?t.apply(this,arguments):(r)=>t(r,...arguments)};switch(e){case 0:case 1:throw RangeError(`Invalid arity ${e}`);case 2:return function(r,n){if(arguments.length>=2)return t(r,n);return function(o){return t(o,r)}};case 3:return function(r,n,o){if(arguments.length>=3)return t(r,n,o);return function(i){return t(i,r,n)}};default:return function(){if(arguments.length>=e)return t.apply(this,arguments);let r=arguments;return function(n){return t(n,...r)}}}};var Ce=(e)=>e;var hn=(e)=>()=>e,_o=hn(!0),Hp=hn(!1);var Uo=hn(void 0),pi=Uo;function Hi(e,...t){return nt(e,t)}function po(e){let t=new WeakMap;return(r)=>{let n=t.get(r);if(n!==void 0)return n;let o=e(r);return t.set(r,o),o}}function Vp(e){let t=new WeakMap;return(r)=>{let n=t.get(r);if(n!==void 0)return n;let o=e(r);if(t.set(r,o),o!==r)t.set(o,o);return o}}var W2=["line","column","sourceURL","originalLine","originalColumn"],Nv=(e)=>{let t=Object.getOwnPropertyNames(e),r=Object.getOwnPropertySymbols(e);return r.length>0?[...t,...r]:t},Jp=(e)=>{let t=Nv(e),r=Object.getPrototypeOf(e);if(r===Object.prototype||r===null)return t;let n=new Set(t);if(e instanceof Error){n.delete("stack");for(let i of W2)if(!Object.prototype.propertyIsEnumerable.call(e,i))n.delete(i)}let o=r;while(o!==null&&o!==Object.prototype){for(let i of Nv(o))n.add(i);o=Object.getPrototypeOf(o)}if(typeof e.constructor==="function"&&r===e.constructor.prototype)n.delete("constructor");return n},Yp=new WeakSet,yc=(e)=>Array.isArray(e)?5:ArrayBuffer.isView(e)?e instanceof DataView?7:6:Object.getPrototypeOf(e)===Object.prototype?0:e instanceof Date?1:e instanceof RegExp?2:e instanceof Map?3:e instanceof Set?4:e instanceof ArrayBuffer?8:typeof SharedArrayBuffer<"u"&&e instanceof SharedArrayBuffer?9:0,Zp=(e,t)=>{try{return t===7?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e)}catch{return}},Vs=0,jl=()=>{Vs++},Js=new WeakMap,dg=(e)=>(e^=e>>>16,e=Math.imul(e,2246822507),e^=e>>>13,e=Math.imul(e,3266489909),e^e>>>16),an=(e,t)=>dg(Math.imul(e,2654435761)+Math.imul(t,2246822507));var jt=(e,t)=>(typeof e==="object"&&e!==null||typeof e==="function")&&(t in e);var Ut="~effect/Hash",Je=(e)=>{switch(typeof e){case"number":return hg(e);case"bigint":return en(e.toString(10));case"string":return en(e);case"function":case"object":{if(e===null)break;let t=yc(e);if(t===1){if(Number.isNaN(e.getTime()))return en("Invalid Date");return en(e.toISOString())}else if(t===2)return en(e.toString());else{if(Yp.has(e))return ug(e);let r=Js.get(e);if(r!==void 0)return r;if(fg.has(e))return jl(),en("[Circular]");fg.add(e);let n=Vs,o;try{if(zl(e))o=e[Ut]();else if(typeof e==="function")o=ug(e);else if(t>=7){let i=Zp(e,t);o=i===void 0?ug(e):Bv(i)}else if(t>=5)o=Bv(e);else if(t===3)o=mg(j2,e,z2);else if(t===4)o=mg($v,e,Q2);else o=ed(e)}finally{fg.delete(e)}if(n===Vs)Js.set(e,o);return o}}}return Vi(dg(en(String(e))))},ug=(e)=>{let t=Kv.get(e);if(t===void 0)Kv.set(e,t=Vi(Math.random()*4294967296|0));return t},Xp=W(2,an),Vi=(e)=>e&3221225471|e>>>1&1073741824,zl=(e)=>jt(e,Ut)&&typeof e[Ut]==="function",lg=new DataView(new ArrayBuffer(8)),hg=(e)=>{let t=e|0;if(t===e)return Vi(t);return lg.setFloat64(0,e!==e?NaN:e),Vi(an(lg.getInt32(0),lg.getInt32(4)))},en=(e)=>{let t=5381,r=e.length;while(r)t=t*33^e.charCodeAt(--r);return Vi(t)},yg=(e,t)=>mg(12289,t,(r)=>an(Je(r),Je(e[r]))),ed=(e)=>yg(e,Jp(e)),mg=(e,t,r)=>{let n=e;for(let o of t)n^=r(o);return Vi(n)},qv=(e)=>{let t=6151;for(let r of e)t=an(t,Je(r));return Vi(t)},Bv=(e)=>{let t=6151;for(let r=0;r<e.length;r++)t=an(t,Je(e[r]));return Vi(t)},j2=en("Map"),$v=en("Set"),z2=([e,t])=>an(Je(e),Je(t)),Q2=(e)=>an($v,Je(e)),Kv=new WeakMap,fg=new WeakSet;var Dt="~effect/Equal";function mr(){if(arguments.length===1)return(e)=>Ys(e,arguments[0]);return Ys(arguments[0],arguments[1])}function Ys(e,t){if(e==null||t==null)return e===t;let r=typeof e;if(r!=="object"&&r!=="function")return e===t||e!==e&&t!==t;if(e===t){if(td.length>0&&!Js.has(e))Je(e);return!0}if(r!==typeof t||Yp.has(e)||Yp.has(t))return!1;return H2(e,t)}function H2(e,t){let r=td.length,n=gg.get(e);if(n===t)return!0;let o;if(!r||n!==void 0){o=Wv.get(e);let d=o?.get(t);if(d!==void 0)return d}let i=!1;for(let d=r;d-- >0;){let x=td[d]===e;if(x||Ql[d]===t){if(jl(),x&&Ql[d]===t)return!0;i=!0}}if(i&&Je(e)!==Je(t))return!1;let s=Vs;td.push(e),Ql.push(t);let c;try{c=V2(e,t)}finally{if(td.pop(),Ql.pop(),!r)gg.clear()}if(s!==Vs)return c&&Je(e)===Je(t);if(r&&n===void 0){if(c)gg.set(e,t)}else{if(!o)Wv.set(e,o=new WeakMap);o.set(t,c)}return c}var td=[],Ql=[],gg=new Map,Wv=new WeakMap;function V2(e,t){let r=Js.get(e);if(r!==void 0&&r!==(Js.get(t)??r))return!1;let n=yc(e);if(n===1||n===2){if(yc(t)!==n)return!1;if(n===2)return e.toString()===t.toString();if(Je(e)!==Je(t))return!1;let i=e.getTime(),s=t.getTime();return i===s||i!==i&&s!==s}let o=zv(e);if(o!==zv(t)||typeof e==="function"&&!o)return!1;if((o||zl(e)||zl(t))&&Je(e)!==Je(t))return!1;if(o)return e[Dt](t);if(n!==yc(t))return!1;if(n>=7){let i=Zp(e,n),s=Zp(t,n);return i!==void 0&&s!==void 0&&Gv(i,s)}else if(n===5)return J2(e,t);else if(n===6)return e.byteLength===t.byteLength&&Gv(e,t);else if(n===3)return e.size===t.size&&jv(e,t,Z2,X2);else if(n===4)return e.size===t.size&&jv(e,t,Je,Ys);return Y2(e,t)}function J2(e,t){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!Ys(e[r],t[r]))return!1;return!0}function Gv(e,t){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(e[r]!==t[r])return!1;return!0}function Y2(e,t){let r=Jp(e),n=Jp(t),o=n instanceof Set;if((r instanceof Set?r.size:r.length)!==(o?n.size:n.length))return!1;for(let i of r)if(!(o?n.has(i):Object.hasOwn(t,i))||!Ys(e[i],t[i]))return!1;return!0}function jv(e,t,r,n){let o=new Map,i=0;for(let s of t){let c=r(s),d=o.get(c);if(d)d.push(s);else o.set(c,[s]);i++}e:for(let s of e){let c=o.get(r(s));if(c){for(let d=0;d<c.length;d++)if(n(s,c[d])){c[d]=c[c.length-1],c.pop(),i--;continue e}}return!1}return i===0}var Z2=(e)=>Je(e[0]),X2=(e,t)=>Ys(e[0],t[0])&&Ys(e[1],t[1]);var zv=(e)=>jt(e,Dt)&&typeof e[Dt]==="function";function wr(e){let t=Object.keys(e);for(let r of Object.getOwnPropertySymbols(e))if(Object.prototype.propertyIsEnumerable.call(e,r))t.push(r);return t}function hr(e,t,r){if(t==="__proto__")Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0});else e[t]=r}function Qv(e,t){if(!Object.hasOwn(t,"__proto__")){Object.assign(e,t);return}for(let r of wr(t))hr(e,r,t[r])}function Lo(e){return typeof e==="string"}function rd(e){return typeof e==="number"}function Hl(e){return typeof e==="boolean"}function Hv(e){return typeof e==="symbol"}function xg(e){return Lo(e)||rd(e)||Hv(e)}function Mo(e){return typeof e==="function"}function gc(e){return e===void 0}function ir(e){return e!==void 0}function Vv(e){return e===null}function Vl(e){return e!==null}function Jv(e){return e===null||e===void 0}function Sg(e){return e!=null}function Yv(e){return!0}function Zv(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function nd(e){return typeof e==="object"&&e!==null||Mo(e)}var Ye=W(2,jt),Ln=W(2,(e,t)=>Ye(e,"_tag")&&e._tag===t);function Xv(e){return e instanceof Error}function eC(e){return Ye(e,Symbol.iterator)||Lo(e)}var Zs=Symbol.for("~effect/Redactable"),eG=(e)=>Ye(e,Zs);function uo(e){if(eG(e))return bg(e);return e}function bg(e){return e[Zs](globalThis[xc]?.context??tG)}var xc="~effect/Fiber/currentFiber",tC=new Map,tG={"~effect/Context":{},base:tC,depth:0,mapUnsafe:tC,pipe(){return nt(this,arguments)}};function it(e,t){let r=t?.space??0,n=new WeakSet,o=!r?"":typeof r==="number"?" ".repeat(r):r,i=(f)=>o.repeat(f),s=(f,g)=>{let I=f?.constructor;return I&&I!==Object.prototype.constructor&&I.name?`${I.name}(${g})`:g},c=(f)=>{try{return Reflect.ownKeys(f)}catch{return["[ownKeys threw]"]}};function d(f,g=0){try{return x(f,g)}catch{if(typeof f==="object"&&f!==null||typeof f==="function")n.delete(f);return"[inspection threw]"}}function x(f,g=0){if(typeof f==="string")return JSON.stringify(f);if(typeof f==="number"||f==null||typeof f==="boolean"||typeof f==="symbol")return String(f);if(typeof f==="bigint")return String(f)+"n";if(typeof f==="object"||typeof f==="function"){if(n.has(f))return rG;n.add(f);let I;if(Zs in f)I=d(bg(f),g);else if(Array.isArray(f))I=!o||f.length<=1?`[${f.map((w)=>d(w,g)).join(",")}]`:`[
5
+ ${i(g+1)}${f.map((w)=>d(w,g+1)).join(`,
6
6
  `+i(g+1))}
7
- ${i(g)}]`;else if(m instanceof Date)w=tv(m);else if(!t?.ignoreToString&&Mt(m,"toString")&&typeof m.toString==="function"&&m.toString!==Object.prototype.toString&&m.toString!==Array.prototype.toString){let k=lW(m);w=m instanceof Error&&m.cause!==void 0?`${k} (cause: ${l(m.cause,g)})`:k}else if(Symbol.iterator in m)w=`${m.constructor.name}(${l(Array.from(m),g)})`;else{let k=c(m);if(!o||k.length<=1){let A=`{${k.map((y)=>`${Ha(y)}:${l(XA(m,y),g)}`).join(",")}}`;w=s(m,A)}else{let A=`{
8
- ${k.map((y)=>`${i(g+1)}${Ha(y)}: ${l(XA(m,y),g+1)}`).join(`,
7
+ ${i(g)}]`;else if(f instanceof Date)I=iC(f);else if(!t?.ignoreToString&&jt(f,"toString")&&typeof f.toString==="function"&&f.toString!==Object.prototype.toString&&f.toString!==Array.prototype.toString){let w=nG(f);I=f instanceof Error&&f.cause!==void 0?`${w} (cause: ${d(f.cause,g)})`:w}else if(Symbol.iterator in f)I=`${f.constructor.name}(${d(Array.from(f),g)})`;else{let w=c(f);if(!o||w.length<=1){let A=`{${w.map((y)=>`${Sc(y)}:${d(nC(f,y),g)}`).join(",")}}`;I=s(f,A)}else{let A=`{
8
+ ${w.map((y)=>`${i(g+1)}${Sc(y)}: ${d(nC(f,y),g+1)}`).join(`,
9
9
  `)}
10
- ${i(g)}}`;w=s(m,A)}}return n.delete(m),w}return String(m)}return l(e,0)}var uW="[Circular]";function Ha(e){return typeof e==="string"?JSON.stringify(e):String(e)}function ev(e){return e.map((t)=>`[${Ha(t)}]`).join("")}function tv(e){try{return e.toISOString()}catch{return"Invalid Date"}}function lW(e){try{let t=e.toString();return typeof t==="string"?t:String(t)}catch{return"[toString threw]"}}function XA(e,t){try{return e[t]}catch{return"[property access threw]"}}function _s(e,t){let r=[],n=new WeakMap;return JSON.stringify(e,function(o,i){let s=Object.getOwnPropertyDescriptor(n.get(this)??this,o)?.value,c=Mt(s,Rs)?Qn(s):Qn(i);if(typeof c==="bigint")return rt(c);if(typeof c!=="object"||c===null)return c;let l=c instanceof Error&&!Mt(c,"toJSON")?{...c,name:c.name,message:c.message}:c;while(r.length>0&&r[r.length-1]!==this)r.pop();if(r.includes(c))return;if(r.push(c),l!==c)r.push(l);if(!fW(l)||hW(l))return l;let S=mW(l);return n.set(S,l),r.push(S),S},t?.space)??"null"}function fW(e){for(let t of Object.getOwnPropertyNames(e))if(Object.getOwnPropertyDescriptor(e,t)?.get!==void 0)return!0;return!1}function mW(e){let t=Array.isArray(e)?[]:{},r=Array.isArray(e)?Array.from({length:e.length},(n,o)=>String(o)):Object.keys(e);for(let n of r)Object.defineProperty(t,n,{enumerable:!0,get:()=>{let o=Reflect.get(e,n);return Object.getOwnPropertyDescriptor(e,n)?.get!==void 0?Qn(o):o}});return t}function hW(e){for(let t of[Number.prototype.valueOf,Boolean.prototype.valueOf,String.prototype.valueOf])try{return Reflect.apply(t,e,[]),!0}catch{}return!1}var Xr=Symbol.for("nodejs.util.inspect.custom"),wo=(e)=>{try{if(e=Qn(e),He(e,"toJSON")&&bo(e.toJSON)&&e.toJSON.length===0)return e.toJSON();else if(Array.isArray(e))return e.map(wo);return e}catch{return"[toJSON threw]"}},rv=(e,t=2)=>{if(typeof e==="string")return e;try{return typeof e==="object"?_s(e,{space:t}):rt(e,{space:t})}catch{return String(e)}},_i={toJSON(){return wo(this)},[Xr](){return this.toJSON()},toString(){return rt(this.toJSON())}};var gW=()=>{let e=Object.getOwnPropertyDescriptor(Error,"stackTraceLimit");if(e===void 0)return Object.isExtensible(Error);return Object.hasOwn(e,"writable")?e.writable===!0:e.set!==void 0},xW=gW(),Us=()=>Error.stackTraceLimit,Hn=(e)=>{if(xW)Error.stackTraceLimit=e};class Ds{constructor(e){this.value=e,this.done=!1}next(e){if(this.done)return this.value=e,this;return this.done=!0,{value:this.value,done:!1}}}var SW=()=>{let t={["~effect/Utils/internal"]:(i)=>i()},r={["~effect/Utils/internal"]:(i)=>{try{return i()}finally{}}},n=Us();if(n===0)return r["~effect/Utils/internal"];Hn(2);let o=t["~effect/Utils/internal"](()=>Error());return Hn(n),o.stack?.includes("~effect/Utils/internal")===!0?t["~effect/Utils/internal"]:r["~effect/Utils/internal"]},_p=SW();var Qo="~effect/Effect",Ls="~effect/Exit",IW={_A:Ee,_E:Ee,_R:Ee},Il=`${Qo}/identifier`,Me=`${Qo}/args`,lt=`${Qo}/evaluate`,Zt=`${Qo}/successCont`,pn=`${Qo}/failureCont`,Ms=`${Qo}/ensureCont`,Fs=Symbol.for("effect/Effect/Yield"),qr={pipe(){return et(this,arguments)},toJSON(){return{...this}},toString(){return rt(this.toJSON(),{ignoreToString:!0,space:2})},[Xr](){return this.toJSON()}},L7={[kt](){return Uy(this,Yr(this))},[At](e){let t=Yr(this);if(t.length!==Yr(e).length)return!1;for(let r of t)if(!Object.prototype.propertyIsEnumerable.call(e,r)||!or(this[r],e[r]))return!1;return!0}},ov={[Qo]:IW,...qr,[Symbol.iterator](){return new Ds(this)}},Ht=(e)=>Mt(e,Qo),El=(e)=>Mt(e,Ls),wl="~effect/Cause",Ny="~effect/Cause/Reason",Up=(e)=>Mt(e,wl);class Eo{constructor(e){this[wl]=wl,this.reasons=e}pipe(){return et(this,arguments)}toJSON(){return{_id:"Cause",reasons:this.reasons.map((e)=>e.toJSON())}}toString(){return`Cause(${rt(this.reasons)})`}[Xr](){return this.toJSON()}[At](e){return Up(e)&&this.reasons.length===e.reasons.length&&this.reasons.every((t,r)=>or(t,e.reasons[r]))}[kt](){return FA(this.reasons)}}var nv=new WeakMap,iv=(e,t,r)=>{if(t.size===0)return e;let n=r?.overwrite===!0,o=new Map(e.annotations);for(let[s,c]of t)if(n||!o.has(s))o.set(s,c);if(!n&&o.size===e.annotations.size)return e;let i=Object.assign(Object.create(Object.getPrototypeOf(e)),e);return i.annotations=o,i};class Ya{constructor(e,t,r){if(t!==Dp&&typeof r==="object"&&r!==null&&t.size>0){let n=nv.get(r);if(n)t=new Map([...n,...t]);nv.set(r,t)}this[Ny]=Ny,this.annotations=t,this._tag=e}annotate(e,t){return iv(this,e.mapUnsafe,t)}pipe(){return et(this,arguments)}[Xr](){return this.toString()}}var Dp=new Map;class Lp extends Ya{constructor(e,t=Dp){super("Fail",t,e);this.error=e}toString(){return`Fail(${rt(this.error)})`}toJSON(){return{_tag:"Fail",error:this.error}}[At](e){return Za(e)&&or(this.error,e.error)&&or(this.annotations,e.annotations)}[kt](){let e=je(this.error);return Jr(Jr(je(this.annotations),e),Kr(this._tag))}}var Ho=(e)=>new Eo(e),wW=(e,t)=>{let r=new Map,n=[];for(let o of e.concat(t)){let i=je(o),s=r.get(i);if(s===void 0)r.set(i,[o]);else if(s.some((c)=>or(c,o)))continue;else s.push(o);n.push(o)}return n},kl=q(2,(e,t)=>{if(e.reasons.length===0)return t;else if(t.reasons.length===0)return e;let r=new Eo(wW(e.reasons,t.reasons));return or(e,r)?e:r}),By=(e,t)=>{let r=e.reasons.slice();for(let n of t.reasons)if(Va(n)&&!r.some((o)=>Va(o)&&o.fiberId===n.fiberId&&o.annotations===n.annotations))r.push(n);return r.length===e.reasons.length?e:new Eo(r)},Ky=new Eo([]),Mp=(e)=>new Eo([new Lp(e)]);class Fp extends Ya{constructor(e,t=Dp){super("Die",t,e);this.defect=e}toString(){return`Die(${rt(this.defect)})`}toJSON(){return{_tag:"Die",defect:this.defect}}[At](e){return vl(e)&&or(this.defect,e.defect)&&or(this.annotations,e.annotations)}[kt](){let e=je(this.defect);return Jr(Jr(je(this.annotations),e),Kr(this._tag))}}var qy=(e)=>new Eo([new Fp(e)]),$y={},Al=(e,t,r,n)=>{if(t.size===0)return e;return new Eo(e.reasons.map((o)=>o.annotate===Ya.prototype.annotate?iv(o,t,r):o.annotate(n??$y.makeUnsafe(t),r)))};var Za=(e)=>e._tag==="Fail",vl=(e)=>e._tag==="Die",Va=(e)=>e._tag==="Interrupt";function EW(e){return On("Effect.evaluate: Not implemented")}var Cn=(e)=>({...ov,toJSON(){return{_id:"Effect",op:this[Il],...Me in this?{args:this[Me]}:void 0}},[Il]:e.op,[lt]:e[lt]??EW,[Zt]:e[Zt],[pn]:e[pn],[Ms]:e[Ms]}),Tn=(e)=>{let t=Cn(e),r=function(n){this[Me]=n};return r.prototype=t,function(n){return new r(n)}},sv=(e)=>{let t=Kr(e.op),r={[Ls]:Ls,_tag:e.op,get[e.prop](){return this[Me]},...ov,[Il]:e.op,[lt]:e[lt],toString(){return`${e.op}(${rt(this[Me])})`},toJSON(){return{_id:"Exit",_tag:e.op,[e.prop]:this[Me]}},[At](o){return El(o)&&o._tag===this._tag&&or(this[Me],o[Me])},[kt](){return Jr(t,je(this[Me]))}},n=function(o){this[Me]=o};return n.prototype=r,function(o){return new n(o)}},ft=sv({op:"Success",prop:"value",[lt](e){let t=e.getCont(Zt);return t?t[Zt](this[Me],e,this):e.yieldWith(this)}}),Cl="effect/Cause/StackTrace",Wy={key:"effect/Cause/InterruptorStackTrace"},ir=sv({op:"Failure",prop:"cause",[lt](e){let t=this[Me],r=!1;if(e.cache.stackFrame)t=Al(t,new Map([[Cl,e.cache.stackFrame]])),r=!0;let n=e.getCont(pn),o=e._interruptedCause;if(o&&e.interruptible){let i=!1;while(n&&e.interruptible)i||=Il in n,n=e.getCont(pn);if(i)t=Ho(t.reasons.filter((s)=>s._tag!=="Fail"));t=By(t,o),r=!0}return n?n[pn](t,e,r?void 0:this):e.yieldWith(r?ir(t):this)}}),Vn=(e)=>ir(Mp(e)),On=(e)=>ir(qy(e)),Xe=Tn({op:"WithFiber",[lt](e){return this[Me](e)}}),kW=Tn({op:"WithFiberSucceed",[lt](e){let t=this[Me](e),r=e.getCont(Zt);return r?r[Zt](t,e):e.yieldWith(ft(t))}}),AW=function(){class e extends globalThis.Error{}let t=Cn({op:"YieldableError",[lt](){return Vn(this)}});return delete t.toString,Object.assign(e.prototype,t),e}(),Np=function(){let e=Symbol.for("effect/Data/Error/plainArgs");return class extends AW{constructor(r){super(r?.message,r?.cause?{cause:r.cause}:void 0);if(r)WA(this,r),Object.defineProperty(this,e,{value:r,enumerable:!1})}toJSON(){return{...this[e],...this}}}}(),Bp=(e)=>{class t extends Np{_tag=e}return t.prototype.name=e,t};var Ja="~effect/Cause/Done",Tl=(e)=>Mt(e,Ja),av={[Ja]:Ja,_tag:"Done",value:void 0},Xa=(e)=>{if(e===void 0)return av;return{[Ja]:Ja,_tag:"Done",value:e}},vW=Vn(av),cv=(e)=>{if(e===void 0)return vW;return Vn(Xa(e))};var Ui=(e)=>Cn({op:e.label,[lt]:e.evaluate});var Ol="effect/Scheduler",pv="effect/Scheduler/MaxOpsBeforeYield",dv="effect/Scheduler/PreventSchedulerYield",uv="effect/Tracer",lv="effect/Tracer/ParentSpan",Gy="effect/References/TracerEnabled",zy="effect/References/CurrentStackFrame",jy="effect/References/CurrentLogLevel",Pl="effect/References/MinimumLogLevel",fv="effect/Metric/FiberRuntimeMetrics",mv=2048,hv=!1,Qy=!0,Hy="Info",Rl="Info",CW=["effect/Scheduler","effect/Tracer","effect/References/TracerEnabled","effect/Tracer/ParentSpan","effect/References/CurrentLogLevel","effect/References/MinimumLogLevel","effect/References/CurrentStackFrame","effect/Metric/FiberRuntimeMetrics","effect/Scheduler/MaxOpsBeforeYield","effect/Scheduler/PreventSchedulerYield"],Vy=new Set(CW);var TW=(e,t)=>e===t,yv=()=>TW;var xv="~effect/Option",Sv={[xv]:{_A:(e)=>e},...qr,[Symbol.iterator](){return new Ds(this)}},OW=Object.defineProperty(Object.assign(Object.create(Sv),{_tag:"Some",_op:"Some",[At](e){return Jy(e)&&Zy(e)&&or(this.value,e.value)},[kt](){return vp(je(this._tag))(je(this.value))},toString(){return`some(${rt(this.value)})`},toJSON(){return{_id:"Option",_tag:this._tag,value:wo(this.value)}}}),"valueOrUndefined",{get(){return this.value}}),PW=je("None"),RW=Object.assign(Object.create(Sv),{_tag:"None",_op:"None",valueOrUndefined:void 0,[At](e){return Jy(e)&&Yy(e)},[kt](){return PW},toString(){return"none()"},toJSON(){return{_id:"Option",_tag:this._tag}}}),Jy=(e)=>He(e,xv),Yy=(e)=>e._tag==="None",Zy=(e)=>e._tag==="Some",bv=Object.create(RW),Iv=function(e){this.value=e};Iv.prototype=OW;var wv=(e)=>new Iv(e);var Ev="~effect/Result",kv={[Ev]:{_A:(e)=>e,_E:(e)=>e},...qr,[Symbol.iterator](){return new Ds(this)}},UW=Object.assign(Object.create(kv),{_tag:"Success",_op:"Success",[At](e){return Xy(e)&&tg(e)&&or(this.success,e.success)},[kt](){return vp(je(this._tag))(je(this.success))},toString(){return`success(${rt(this.success)})`},toJSON(){return{_id:"Result",_tag:this._tag,success:wo(this.success)}}}),DW=Object.assign(Object.create(kv),{_tag:"Failure",_op:"Failure",[At](e){return Xy(e)&&eg(e)&&or(this.failure,e.failure)},[kt](){return vp(je(this._tag))(je(this.failure))},toString(){return`failure(${rt(this.failure)})`},toJSON(){return{_id:"Result",_tag:this._tag,failure:wo(this.failure)}}}),Xy=(e)=>He(e,Ev),eg=(e)=>e._tag==="Failure",tg=(e)=>e._tag==="Success",Av=function(e){this.failure=e};Av.prototype=DW;var vv=(e)=>new Av(e),Cv=function(e){this.success=e};Cv.prototype=UW;var Tv=(e)=>new Cv(e);function rg(e){return(t,r)=>t===r?0:e(t,r)}var Ov=rg((e,t)=>e<t?-1:1),Ns=rg((e,t)=>{if(globalThis.Number.isNaN(e)&&globalThis.Number.isNaN(t))return 0;if(globalThis.Number.isNaN(e))return-1;if(globalThis.Number.isNaN(t))return 1;return e<t?-1:1});var _l=q(2,(e,t)=>rg((r,n)=>e(t(r),t(n))));var Pv=(e)=>q(2,(t,r)=>e(t,r)===-1),qp=(e)=>q(2,(t,r)=>e(t,r)===1),ng=(e)=>q(2,(t,r)=>e(t,r)!==1),og=(e)=>q(2,(t,r)=>e(t,r)!==-1);var ge=()=>bv,Ue=wv;var sr=Yy,O=Zy,$r=q(2,(e,{onNone:t,onSome:r})=>sr(e)?t():r(e.value));var fr=q(2,(e,t)=>sr(e)?t():e.value),Rv=q(2,(e,t)=>sr(e)?t():e);var Bs=(e)=>e==null?ge():Ue(e),ec=(e)=>e===void 0?ge():Ue(e);var f=fr(Wa);var Dl=q(2,(e,t)=>sr(e)?ge():Ue(t(e.value)));var ig=q(2,(e,t)=>sr(e)?ge():t(e.value));var _v=q(2,(e,t)=>sr(e)?ge():t(e.value)?Ue(e.value):ge());var $p=q(2,(e,t)=>sr(e)?!1:t(e.value));var Uv="~effect/Context/Service",Vt=function(){function e(){}let t=e;Object.setPrototypeOf(t,FW);let r=(n,o)=>{if(t.key=n,o?.defaultValue)t[ag]=ag,t.defaultValue=o.defaultValue;if(o?.make)t.make=o.make;if(o?.fiberCached)Vy.add(n);return t};return arguments.length>0?r(arguments[0],arguments[1]):r},FW=Object.assign({[Uv]:Uv},Ui({label:"Service",evaluate(e){return ft(dn(e.context,this))}}),{toJSON(){return{_id:"Service",key:this.key}},of(e){return e},context(e){return Ks(this,e)},use(e){return Xe((t)=>e(dn(t.context,this)))},useSync(e){return Xe((t)=>ft(e(dn(t.context,this))))}}),ag="~effect/Context/Reference",Dv="~effect/Context",NW=8,Ll=(e,t,r)=>{let n=Object.create(Lv);return n.cacheRoot=e??n,n.base=t,n.depth=0,n.maxDepth=r,n},BW=(e,t,r,n,o)=>{let i=Object.create(WW);return i.cacheRoot=e??i,i.base=t,i.overlay=r,i.depth=n,i._flat=void 0,i.baseHits=0,i.maxDepth=o,i},cg=(e,t)=>{if(!t)return;cg(e,t.parent),e.set(t.key,t.value)},KW=(e)=>{if(e._flat)return e._flat;if(!e.overlay)return e._flat=e.base;let t=new Map(e.base);return cg(t,e.overlay),e._flat=t},qW=(e,t)=>{let r=new Map(e.mapUnsafe);return t(r),Ll(void 0,r,e.maxDepth)},tc=Symbol(),Ml=(e,t)=>{let r=e;if(r.overlay!==void 0)return $W(r,t);let n=r.base.get(t);return n===void 0&&!r.base.has(t)?tc:n},$W=(e,t)=>{for(let n=e.overlay;n;n=n.parent)if(n.key===t)return n.value;let r=e.base.get(t);if(r===void 0&&!e.base.has(t))return tc;if(++e.baseHits>=e.base.size&&e.baseHits>=NW)e.base=e.mapUnsafe,e.overlay=void 0,e.depth=0;return r},rc=(e,t)=>{let r=t?.maxDepth;return Ll(void 0,e,Number.isInteger(r)&&r>=0?r:8)};$y.makeUnsafe=(e)=>Ll(void 0,e,8);var Lv={get mapUnsafe(){return this.base},...qr,[Dv]:{_Services:Ee},toJSON(){return{_id:"Context",services:Array.from(this.mapUnsafe,([e,t])=>({key:e,value:t}))}},[At](e){if(!pg(e))return!1;let t=this.mapUnsafe,r=e.mapUnsafe;if(t.size!==r.size)return!1;for(let[n,o]of t)if(!r.has(n)||!or(o,r.get(n)))return!1;return!0},[kt](){return _y(this.mapUnsafe.size)}},WW=Object.create(Lv,{mapUnsafe:{get(){return KW(this)},enumerable:!0,configurable:!0}}),Mv=(e,t)=>e.cacheRoot===t.cacheRoot,pg=(e)=>Mt(e,Dv);var Fv=(e)=>!!e[ag],un=()=>GW,GW=rc(new Map),Ks=(e,t)=>rc(new Map([[e.key,t]])),ko=q(3,(e,t,r)=>dg(e,t.key,r)),dg=(e,t,r)=>{let n=e,o=Vy.has(t)?void 0:n.cacheRoot;if(n.depth>=n.maxDepth){let i=new Map(n._flat??n.base);if(!n._flat)cg(i,n.overlay);return i.set(t,r),Ll(o,i,n.maxDepth)}return BW(o,n.base,{key:t,value:r,parent:n.overlay},n.depth+1,n.maxDepth)};var nc=q(2,(e,t)=>ug(e,t.key)),ug=(e,t)=>{let r=Ml(e,t);return r===tc?void 0:r},Wp=q(2,(e,t)=>{let r=Ml(e,t.key);if(r===tc){if(Fv(t))return lg(t);throw zW(t)}return r}),dn=Wp,sg="~effect/Context/defaultValue",lg=(e)=>{if(sg in e)return e[sg];return e[sg]=e.defaultValue()};var Nv=(e,t)=>{let r=Ml(e,t.key);return r===tc?lg(t):r},zW=(e)=>{let t=Error(`Service not found${e.key?`: ${String(e.key)}`:""}`);if(t.stack){let r=t.stack.split(`
10
+ ${i(g)}}`;I=s(f,A)}}return n.delete(f),I}return String(f)}return d(e,0)}var rG="[Circular]";function Sc(e){return typeof e==="string"?JSON.stringify(e):String(e)}function oC(e){return e.map((t)=>`[${Sc(t)}]`).join("")}function iC(e){try{return e.toISOString()}catch{return"Invalid Date"}}function nG(e){try{let t=e.toString();return typeof t==="string"?t:String(t)}catch{return"[toString threw]"}}function nC(e,t){try{return e[t]}catch{return"[property access threw]"}}function Xs(e,t){let r=[],n=new WeakMap;return JSON.stringify(e,function(o,i){let s=Object.getOwnPropertyDescriptor(n.get(this)??this,o)?.value,c=jt(s,Zs)?uo(s):uo(i);if(typeof c==="bigint")return it(c);if(typeof c!=="object"||c===null)return c;let d=c instanceof Error&&!jt(c,"toJSON")?{...c,name:c.name,message:c.message}:c;while(r.length>0&&r[r.length-1]!==this)r.pop();if(r.includes(c))return;if(r.push(c),d!==c)r.push(d);if(!oG(d)||sG(d))return d;let x=iG(d);return n.set(x,d),r.push(x),x},t?.space)??"null"}function oG(e){for(let t of Object.getOwnPropertyNames(e))if(Object.getOwnPropertyDescriptor(e,t)?.get!==void 0)return!0;return!1}function iG(e){let t=Array.isArray(e)?[]:{},r=Array.isArray(e)?Array.from({length:e.length},(n,o)=>String(o)):Object.keys(e);for(let n of r)Object.defineProperty(t,n,{enumerable:!0,get:()=>{let o=Reflect.get(e,n);return Object.getOwnPropertyDescriptor(e,n)?.get!==void 0?uo(o):o}});return t}function sG(e){for(let t of[Number.prototype.valueOf,Boolean.prototype.valueOf,String.prototype.valueOf])try{return Reflect.apply(t,e,[]),!0}catch{}return!1}var cn=Symbol.for("nodejs.util.inspect.custom"),Fo=(e)=>{try{if(e=uo(e),Ye(e,"toJSON")&&Mo(e.toJSON)&&e.toJSON.length===0)return e.toJSON();else if(Array.isArray(e))return e.map(Fo);return e}catch{return"[toJSON threw]"}},sC=(e,t=2)=>{if(typeof e==="string")return e;try{return typeof e==="object"?Xs(e,{space:t}):it(e,{space:t})}catch{return String(e)}},Yi={toJSON(){return Fo(this)},[cn](){return this.toJSON()},toString(){return it(this.toJSON())}};var cG=()=>{let e=Object.getOwnPropertyDescriptor(Error,"stackTraceLimit");if(e===void 0)return Object.isExtensible(Error);return Object.hasOwn(e,"writable")?e.writable===!0:e.set!==void 0},pG=cG(),ui=()=>Error.stackTraceLimit,tn=(e)=>{if(pG)Error.stackTraceLimit=e};class ea{constructor(e){this.value=e,this.done=!1}next(e){if(this.done)return this.value=e,this;return this.done=!0,{value:this.value,done:!1}}}var dG=()=>{let t={["~effect/Utils/internal"]:(i)=>i()},r={["~effect/Utils/internal"]:(i)=>{try{return i()}finally{}}},n=ui();if(n===0)return r["~effect/Utils/internal"];tn(2);let o=t["~effect/Utils/internal"](()=>Error());return tn(n),o.stack?.includes("~effect/Utils/internal")===!0?t["~effect/Utils/internal"]:r["~effect/Utils/internal"]},id=dG();var li="~effect/Effect",ta="~effect/Exit",lG={_A:Ce,_E:Ce,_R:Ce},Jl=`${li}/identifier`,qe=`${li}/args`,xt=`${li}/evaluate`,sr=`${li}/successCont`,yn=`${li}/failureCont`,ra=`${li}/ensureCont`,na=Symbol.for("effect/Effect/Yield"),Lr={pipe(){return nt(this,arguments)},toJSON(){return{...this}},toString(){return it(this.toJSON(),{ignoreToString:!0,space:2})},[cn](){return this.toJSON()}},ote={[Ut](){return yg(this,wr(this))},[Dt](e){let t=wr(this);if(t.length!==wr(e).length)return!1;for(let r of t)if(!Object.prototype.propertyIsEnumerable.call(e,r)||!mr(this[r],e[r]))return!1;return!0}},cC={[li]:lG,...Lr,[Symbol.iterator](){return new ea(this)}},zt=(e)=>jt(e,li),Zl=(e)=>jt(e,ta),Yl="~effect/Cause",Ig="~effect/Cause/Reason",sd=(e)=>jt(e,Yl);class No{constructor(e){this[Yl]=Yl,this.reasons=e}pipe(){return nt(this,arguments)}toJSON(){return{_id:"Cause",reasons:this.reasons.map((e)=>e.toJSON())}}toString(){return`Cause(${it(this.reasons)})`}[cn](){return this.toJSON()}[Dt](e){return sd(e)&&this.reasons.length===e.reasons.length&&this.reasons.every((t,r)=>mr(t,e.reasons[r]))}[Ut](){return qv(this.reasons)}}var aC=new WeakMap,pC=(e,t,r)=>{if(t.size===0)return e;let n=r?.overwrite===!0,o=new Map(e.annotations);for(let[s,c]of t)if(n||!o.has(s))o.set(s,c);if(!n&&o.size===e.annotations.size)return e;let i=Object.assign(Object.create(Object.getPrototypeOf(e)),e);return i.annotations=o,i};class Ec{constructor(e,t,r){if(t!==ad&&typeof r==="object"&&r!==null&&t.size>0){let n=aC.get(r);if(n)t=new Map([...n,...t]);aC.set(r,t)}this[Ig]=Ig,this.annotations=t,this._tag=e}annotate(e,t){return pC(this,e.mapUnsafe,t)}pipe(){return nt(this,arguments)}[cn](){return this.toString()}}var ad=new Map;class kc extends Ec{constructor(e,t=ad){super("Fail",t,e);this.error=e}toString(){return`Fail(${it(this.error)})`}toJSON(){return{_tag:"Fail",error:this.error}}[Dt](e){return Ac(e)&&mr(this.error,e.error)&&mr(this.annotations,e.annotations)}[Ut](){let e=Je(this.error);return an(an(Je(this.annotations),e),en(this._tag))}}var fi=(e)=>new No(e),fG=(e,t)=>{let r=new Map,n=[];for(let o of e.concat(t)){let i=Je(o),s=r.get(i);if(s===void 0)r.set(i,[o]);else if(s.some((c)=>mr(c,o)))continue;else s.push(o);n.push(o)}return n},Xl=W(2,(e,t)=>{if(e.reasons.length===0)return t;else if(t.reasons.length===0)return e;let r=new No(fG(e.reasons,t.reasons));return mr(e,r)?e:r}),Eg=(e,t)=>{let r=e.reasons.slice();for(let n of t.reasons)if(bc(n)&&!r.some((o)=>bc(o)&&o.fiberId===n.fiberId&&o.annotations===n.annotations))r.push(n);return r.length===e.reasons.length?e:new No(r)},kg=new No([]),cd=(e)=>new No([new kc(e)]);class wc extends Ec{constructor(e,t=ad){super("Die",t,e);this.defect=e}toString(){return`Die(${it(this.defect)})`}toJSON(){return{_tag:"Die",defect:this.defect}}[Dt](e){return pd(e)&&mr(this.defect,e.defect)&&mr(this.annotations,e.annotations)}[Ut](){let e=Je(this.defect);return an(an(Je(this.annotations),e),en(this._tag))}}var wg=(e)=>new No([new wc(e)]),Ag={},ef=(e,t,r,n)=>{if(t.size===0)return e;return new No(e.reasons.map((o)=>o.annotate===Ec.prototype.annotate?pC(o,t,r):o.annotate(n??Ag.makeUnsafe(t),r)))};var Ac=(e)=>e._tag==="Fail",pd=(e)=>e._tag==="Die",bc=(e)=>e._tag==="Interrupt";function mG(e){return Nn("Effect.evaluate: Not implemented")}var Mn=(e)=>({...cC,toJSON(){return{_id:"Effect",op:this[Jl],...qe in this?{args:this[qe]}:void 0}},[Jl]:e.op,[xt]:e[xt]??mG,[sr]:e[sr],[yn]:e[yn],[ra]:e[ra]}),Fn=(e)=>{let t=Mn(e),r=function(n){this[qe]=n};return r.prototype=t,function(n){return new r(n)}},dC=(e)=>{let t=en(e.op),r={[ta]:ta,_tag:e.op,get[e.prop](){return this[qe]},...cC,[Jl]:e.op,[xt]:e[xt],toString(){return`${e.op}(${it(this[qe])})`},toJSON(){return{_id:"Exit",_tag:e.op,[e.prop]:this[qe]}},[Dt](o){return Zl(o)&&o._tag===this._tag&&mr(this[qe],o[qe])},[Ut](){return an(t,Je(this[qe]))}},n=function(o){this[qe]=o};return n.prototype=r,function(o){return new n(o)}},ft=dC({op:"Success",prop:"value",[xt](e){let t=e.getCont(sr);return t?t[sr](this[qe],e,this):e.yieldWith(this)}}),tf="effect/Cause/StackTrace",vg={key:"effect/Cause/InterruptorStackTrace"},ar=dC({op:"Failure",prop:"cause",[xt](e){let t=this[qe],r=!1;if(e.cache.stackFrame)t=ef(t,new Map([[tf,e.cache.stackFrame]])),r=!0;let n=e.getCont(yn),o=e._interruptedCause;if(o&&e.interruptible){let i=!1;while(n&&e.interruptible)i||=Jl in n,n=e.getCont(yn);if(i)t=fi(t.reasons.filter((s)=>s._tag!=="Fail"));t=Eg(t,o),r=!0}return n?n[yn](t,e,r?void 0:this):e.yieldWith(r?ar(t):this)}}),lo=(e)=>ar(cd(e)),Nn=(e)=>ar(wg(e)),tt=Fn({op:"WithFiber",[xt](e){return this[qe](e)}}),hG=Fn({op:"WithFiberSucceed",[xt](e){let t=this[qe](e),r=e.getCont(sr);return r?r[sr](t,e):e.yieldWith(ft(t))}}),yG=function(){class e extends globalThis.Error{}let t=Mn({op:"YieldableError",[xt](){return lo(this)}});return delete t.toString,Object.assign(e.prototype,t),e}(),dd=function(){let e=Symbol.for("effect/Data/Error/plainArgs");return class extends yG{constructor(r){super(r?.message,r?.cause?{cause:r.cause}:void 0);if(r)Qv(this,r),Object.defineProperty(this,e,{value:r,enumerable:!1})}toJSON(){return{...this[e],...this}}}}(),ud=(e)=>{class t extends dd{_tag=e}return t.prototype.name=e,t};var Ic="~effect/Cause/Done",rf=(e)=>jt(e,Ic),uC={[Ic]:Ic,_tag:"Done",value:void 0},vc=(e)=>{if(e===void 0)return uC;return{[Ic]:Ic,_tag:"Done",value:e}},gG=lo(uC),lC=(e)=>{if(e===void 0)return gG;return lo(vc(e))};var Bo=(e)=>Mn({op:e.label,[xt]:e.evaluate});var nf="effect/Scheduler",fC="effect/Scheduler/MaxOpsBeforeYield",mC="effect/Scheduler/PreventSchedulerYield",hC="effect/Tracer",yC="effect/Tracer/ParentSpan",Cg="effect/References/TracerEnabled",of="effect/References/CurrentStackFrame",Tg="effect/References/CurrentLogLevel",sf="effect/References/MinimumLogLevel",gC="effect/Metric/FiberRuntimeMetrics",xC=2048,SC=!1,Og=!0,Pg="Info",af="Info",xG=["effect/Scheduler","effect/Tracer","effect/References/TracerEnabled","effect/Tracer/ParentSpan","effect/References/CurrentLogLevel","effect/References/MinimumLogLevel","effect/References/CurrentStackFrame","effect/Metric/FiberRuntimeMetrics","effect/Scheduler/MaxOpsBeforeYield","effect/Scheduler/PreventSchedulerYield"],Rg=new Set(xG);var bC=(e)=>(t,r)=>t===r||e(t,r),SG=(e,t)=>e===t,IC=()=>SG;var EC="~effect/Option",kC={[EC]:{_A:(e)=>e},...Lr,[Symbol.iterator](){return new ea(this)}},bG=Object.defineProperty(Object.assign(Object.create(kC),{_tag:"Some",_op:"Some",[Dt](e){return Ug(e)&&Lg(e)&&mr(this.value,e.value)},[Ut](){return Xp(Je(this._tag))(Je(this.value))},toString(){return`some(${it(this.value)})`},toJSON(){return{_id:"Option",_tag:this._tag,value:Fo(this.value)}}}),"valueOrUndefined",{get(){return this.value}}),IG=Je("None"),EG=Object.assign(Object.create(kC),{_tag:"None",_op:"None",valueOrUndefined:void 0,[Dt](e){return Ug(e)&&Dg(e)},[Ut](){return IG},toString(){return"none()"},toJSON(){return{_id:"Option",_tag:this._tag}}}),Ug=(e)=>Ye(e,EC),Dg=(e)=>e._tag==="None",Lg=(e)=>e._tag==="Some",wC=Object.create(EG),AC=function(e){this.value=e};AC.prototype=bG;var vC=(e)=>new AC(e);var CC="~effect/Result",TC={[CC]:{_A:(e)=>e,_E:(e)=>e},...Lr,[Symbol.iterator](){return new ea(this)}},wG=Object.assign(Object.create(TC),{_tag:"Success",_op:"Success",[Dt](e){return Mg(e)&&Ng(e)&&mr(this.success,e.success)},[Ut](){return Xp(Je(this._tag))(Je(this.success))},toString(){return`success(${it(this.success)})`},toJSON(){return{_id:"Result",_tag:this._tag,success:Fo(this.success)}}}),AG=Object.assign(Object.create(TC),{_tag:"Failure",_op:"Failure",[Dt](e){return Mg(e)&&Fg(e)&&mr(this.failure,e.failure)},[Ut](){return Xp(Je(this._tag))(Je(this.failure))},toString(){return`failure(${it(this.failure)})`},toJSON(){return{_id:"Result",_tag:this._tag,failure:Fo(this.failure)}}}),Mg=(e)=>Ye(e,CC),Fg=(e)=>e._tag==="Failure",Ng=(e)=>e._tag==="Success",OC=function(e){this.failure=e};OC.prototype=AG;var PC=(e)=>new OC(e),RC=function(e){this.success=e};RC.prototype=wG;var _C=(e)=>new RC(e);function Bg(e){return(t,r)=>t===r?0:e(t,r)}var UC=Bg((e,t)=>e<t?-1:1),oa=Bg((e,t)=>{if(globalThis.Number.isNaN(e)&&globalThis.Number.isNaN(t))return 0;if(globalThis.Number.isNaN(e))return-1;if(globalThis.Number.isNaN(t))return 1;return e<t?-1:1});var cf=W(2,(e,t)=>Bg((r,n)=>e(t(r),t(n))));var DC=(e)=>W(2,(t,r)=>e(t,r)===-1),ld=(e)=>W(2,(t,r)=>e(t,r)===1),Kg=(e)=>W(2,(t,r)=>e(t,r)!==1),qg=(e)=>W(2,(t,r)=>e(t,r)!==-1);var xe=()=>wC,Le=vC;var cr=Dg,T=Lg,Wr=W(2,(e,{onNone:t,onSome:r})=>cr(e)?t():r(e.value));var yr=W(2,(e,t)=>cr(e)?t():e.value),LC=W(2,(e,t)=>cr(e)?t():e);var ia=(e)=>e==null?xe():Le(e),Tc=(e)=>e===void 0?xe():Le(e);var m=yr(Uo);var df=W(2,(e,t)=>cr(e)?xe():Le(t(e.value)));var $g=W(2,(e,t)=>cr(e)?xe():t(e.value));var Wg=W(2,(e,t)=>cr(e)?xe():t(e.value)?Le(e.value):xe());var fd=W(2,(e,t)=>cr(e)?!1:t(e.value));var MC="~effect/Context/Service",Qt=function(){function e(){}let t=e;Object.setPrototypeOf(t,TG);let r=(n,o)=>{if(t.key=n,o?.defaultValue)t[jg]=jg,t.defaultValue=o.defaultValue;if(o?.make)t.make=o.make;if(o?.fiberCached)Rg.add(n);return t};return arguments.length>0?r(arguments[0],arguments[1]):r},TG=Object.assign({[MC]:MC},Bo({label:"Service",evaluate(e){return ft(rn(e.context,this))}}),{toJSON(){return{_id:"Service",key:this.key}},of(e){return e},context(e){return aa(this,e)},use(e){return tt((t)=>e(rn(t.context,this)))},useSync(e){return tt((t)=>ft(e(rn(t.context,this))))}}),jg="~effect/Context/Reference",FC="~effect/Context",OG=8,uf=(e,t,r)=>{let n=Object.create(NC);return n.cacheRoot=e??n,n.base=t,n.depth=0,n.maxDepth=r,n},PG=(e,t,r,n,o)=>{let i=Object.create(DG);return i.cacheRoot=e??i,i.base=t,i.overlay=r,i.depth=n,i._flat=void 0,i.baseHits=0,i.maxDepth=o,i},zg=(e,t)=>{if(!t)return;zg(e,t.parent),e.set(t.key,t.value)},RG=(e)=>{if(e._flat)return e._flat;if(!e.overlay)return e._flat=e.base;let t=new Map(e.base);return zg(t,e.overlay),e._flat=t},_G=(e,t)=>{let r=new Map(e.mapUnsafe);return t(r),uf(void 0,r,e.maxDepth)},Oc=Symbol(),lf=(e,t)=>{let r=e;if(r.overlay!==void 0)return UG(r,t);let n=r.base.get(t);return n===void 0&&!r.base.has(t)?Oc:n},UG=(e,t)=>{for(let n=e.overlay;n;n=n.parent)if(n.key===t)return n.value;let r=e.base.get(t);if(r===void 0&&!e.base.has(t))return Oc;if(++e.baseHits>=e.base.size&&e.baseHits>=OG)e.base=e.mapUnsafe,e.overlay=void 0,e.depth=0;return r},sa=(e,t)=>{let r=t?.maxDepth;return uf(void 0,e,Number.isInteger(r)&&r>=0?r:8)};Ag.makeUnsafe=(e)=>uf(void 0,e,8);var NC={get mapUnsafe(){return this.base},...Lr,[FC]:{_Services:Ce},toJSON(){return{_id:"Context",services:Array.from(this.mapUnsafe,([e,t])=>({key:e,value:t}))}},[Dt](e){if(!Qg(e))return!1;let t=this.mapUnsafe,r=e.mapUnsafe;if(t.size!==r.size)return!1;for(let[n,o]of t)if(!r.has(n)||!mr(o,r.get(n)))return!1;return!0},[Ut](){return hg(this.mapUnsafe.size)}},DG=Object.create(NC,{mapUnsafe:{get(){return RG(this)},enumerable:!0,configurable:!0}}),BC=(e,t)=>e.cacheRoot===t.cacheRoot,Qg=(e)=>jt(e,FC);var KC=(e)=>!!e[jg],Gr=()=>LG,LG=sa(new Map),aa=(e,t)=>sa(new Map([[e.key,t]])),Bn=W(3,(e,t,r)=>Hg(e,t.key,r)),Hg=(e,t,r)=>{let n=e,o=Rg.has(t)?void 0:n.cacheRoot;if(n.depth>=n.maxDepth){let i=new Map(n._flat??n.base);if(!n._flat)zg(i,n.overlay);return i.set(t,r),uf(o,i,n.maxDepth)}return PG(o,n.base,{key:t,value:r,parent:n.overlay},n.depth+1,n.maxDepth)};var Pc=W(2,(e,t)=>Vg(e,t.key)),Vg=(e,t)=>{let r=lf(e,t);return r===Oc?void 0:r},Rc=W(2,(e,t)=>{let r=lf(e,t.key);if(r===Oc){if(KC(t))return Jg(t);throw MG(t)}return r}),rn=Rc,Gg="~effect/Context/defaultValue",Jg=(e)=>{if(Gg in e)return e[Gg];return e[Gg]=e.defaultValue()};var qC=(e,t)=>{let r=lf(e,t.key);return r===Oc?Jg(t):r},MG=(e)=>{let t=Error(`Service not found${e.key?`: ${String(e.key)}`:""}`);if(t.stack){let r=t.stack.split(`
11
11
  `);r.splice(1,3),t.stack=r.join(`
12
- `)}return t},Bv=q(2,(e,t)=>{let r=Ml(e,t.key);if(r!==tc)return Ue(r);return Fv(t)?Ue(lg(t)):ge()}),oc=q(2,(e,t)=>{if(e.mapUnsafe.size===0)return t;if(t.mapUnsafe.size===0)return e;return qW(e,(r)=>t.mapUnsafe.forEach((n,o)=>r.set(o,n)))}),Kv=(...e)=>{let t=new Map;for(let r=0;r<e.length;r++)e[r].mapUnsafe.forEach((n,o)=>{t.set(o,n)});return rc(t)};var Jt=Vt;var fg=(e)=>e.length>0;var ic=(e)=>e>0?Math.floor(e):0;var Xt=Tv,Nt=vv;var mr=eg,Fl=tg;var Nl=q(2,(e,{onFailure:t,onSuccess:r})=>mr(e)?t(e.failure):r(e.success));var QW=q(2,(e,t)=>{if(Fl(e))return e.success;throw t(e.failure)}),mg=QW(Ee);var $v=q(2,(e,t)=>{let r=0;for(let n of e){let o=t(n,r);if(Sl(o)){if(o)return Ue(n)}else if(O(o))return o;r++}return ge()});var sX={[Symbol.iterator](){return HW}},HW={next(){return{done:!0,value:void 0}}};var VW=q(2,(e,t)=>Object.hasOwn(e,t));var Gv=q(2,(e,t)=>{let r={...e};for(let n of zv(e))Zr(r,n,t(e[n],n));return r});var zv=(e)=>Object.keys(e);var JW=(e)=>q(2,(t,r)=>{for(let n of zv(t))if(!VW(r,n)||!e(t[n],r[n]))return!1;return!0});var jv=(e)=>{let t=JW(e);return(r,n)=>t(r,n)&&t(n,r)};var Bl=globalThis.Array;var Gp=(e)=>Bl.isArray(e)?e:Bl.from(e);var zp=q(2,(e,{onEmpty:t,onNonEmpty:r})=>Di(e)?r(e):t());var YW=Bl.isArray;var Kl=fg,Di=fg;var yg=q(2,(e,t)=>{let r=0;for(let n of e){if(t(n,r))return Ue(r);r++}return ge()});var Qv=$v;var Hv=q(2,(e,t)=>{let r=Gp(e);for(let n=r.length-1;n>=0;n--){let o=r[n],i=t(o,n);if(typeof i==="boolean"){if(i)return Ue(o)}else if(O(i))return i}return ge()});var Vv=q(2,(e,t)=>{let r=Bl.from(e);return r.sort(t),r});var qs=()=>[],Li=(e)=>[e],ln=q(2,(e,t)=>e.map(t));var ql=q(3,(e,t,r)=>Gp(e).reduce((n,o,i)=>r(n,o,i),t));var Wl="~effect/Duration",jp=BigInt(0),nC=BigInt(1),ZW=BigInt(2),XW=BigInt(10);var oC=BigInt(1000),Qp=BigInt(1e6),iC=BigInt(1e9),e2=BigInt(60000000000),t2=BigInt(3600000000000),r2=BigInt(86400000000000),n2=BigInt(604800000000000),sC=(e)=>BigInt(Math.sign(e)*Math.round(Math.abs(e))),xg=(e)=>Number.isInteger(e)?BigInt(e)*Qp:sC(e*1e6),Jv=(e)=>fn(Number.isFinite(e)?sC(e):e),o2=(e,t)=>{let r=Number(e);if(Number.isFinite(r))return r/t;let n=BigInt(t);return Number(e/n)+Number(e%n)/t},gg=(e,t)=>{let r=e.indexOf(".");if(r===-1)return BigInt(e)*t;let n=e[0]==="-",o=e.slice(r+1),i=XW**BigInt(o.length),s=(BigInt(e.slice(n?1:0,r))*i+BigInt(o))*t;return i2(n?-s:s,i)},i2=(e,t)=>{let r=e<jp?-e:e,n=r/t+(r%t*ZW>=t?nC:jp);return e<jp?-n:n},sc=(e,t)=>{let r=Number(e)*t;if(!Number.isFinite(r))return fn(r);let n=gg(e,BigInt(t)*Qp);return fn(Number.isInteger(r)&&BigInt(r)*Qp===n?r:n)};var s2=/^(-?\d+(?:\.\d+)?)\s+(nanos?|micros?|millis?|seconds?|minutes?|hours?|days?|weeks?)$/,ac=(e)=>{switch(typeof e){case"number":return l2(e);case"bigint":return $l(e);case"string":{if(e==="Infinity")return eC;if(e==="-Infinity")return tC;let t=s2.exec(e);if(!t)break;let[r,n,o]=t;if(o==="nano"||o==="nanos")return $l(gg(n,nC));if(o==="micro"||o==="micros")return $l(gg(n,oC));switch(o){case"milli":case"millis":return sc(n,1);case"second":case"seconds":return sc(n,1000);case"minute":case"minutes":return sc(n,60000);case"hour":case"hours":return sc(n,3600000);case"day":case"days":return sc(n,86400000);case"week":case"weeks":return sc(n,604800000)}break}case"object":{if(e===null)break;if(Wl in e)return e;if(Array.isArray(e)){if(e.length!==2||!e.every(Op))return Zv(e);if(Number.isNaN(e[0])||Number.isNaN(e[1]))return u2;if(e[0]===-1/0||e[1]===-1/0)return tC;if(e[0]===1/0||e[1]===1/0)return eC;let i=e[0]*1e9+e[1];return Number.isFinite(i)&&Number.isInteger(e[0])&&Number.isInteger(e[1])?fn(BigInt(e[0])*iC+BigInt(e[1])):Jv(i)}let t=e,r=0;if(t.weeks)r+=t.weeks*604800000;if(t.days)r+=t.days*86400000;if(t.hours)r+=t.hours*3600000;if(t.minutes)r+=t.minutes*60000;if(t.seconds)r+=t.seconds*1000;if(t.milliseconds)r+=t.milliseconds;if(!t.microseconds&&!t.nanoseconds){if(!Number.isFinite(r))return fn(r);let i=Yv(t);return i===void 0||BigInt(r)*Qp===i?fn(r):fn(i)}let n=r*1e6+(t.microseconds??0)*1000+(t.nanoseconds??0),o=Number.isFinite(n)?Yv(t):void 0;return o===void 0?Jv(n):fn(o)}}return Zv(e)},Mi=(e)=>!e||Number.isInteger(e),Yv=(e)=>{if(!Mi(e.weeks)||!Mi(e.days)||!Mi(e.hours)||!Mi(e.minutes)||!Mi(e.seconds)||!Mi(e.milliseconds)||!Mi(e.microseconds)||!Mi(e.nanoseconds))return;let t=jp;if(e.weeks)t+=BigInt(e.weeks)*n2;if(e.days)t+=BigInt(e.days)*r2;if(e.hours)t+=BigInt(e.hours)*t2;if(e.minutes)t+=BigInt(e.minutes)*e2;if(e.seconds)t+=BigInt(e.seconds)*iC;if(e.milliseconds)t+=BigInt(e.milliseconds)*Qp;if(e.microseconds)t+=BigInt(e.microseconds)*oC;if(e.nanoseconds)t+=BigInt(e.nanoseconds);return t},Zv=(e)=>{throw Error(`Invalid Input: ${e}`)};var Xv={_tag:"Millis",millis:0},a2={_tag:"Infinity"},c2={_tag:"NegativeInfinity"},p2={[Wl]:Wl,[kt](){switch(this.value._tag){case"Millis":return je(xg(this.value.millis));case"Nanos":return je(this.value.nanos);default:return Cp(this.value)}},[At](e){return d2(e)&&y2(this,e)},toString(){switch(this.value._tag){case"Infinity":return"Infinity";case"NegativeInfinity":return"-Infinity";case"Nanos":return`${this.value.nanos} nanos`;case"Millis":return`${this.value.millis} millis`}},toJSON(){switch(this.value._tag){case"Millis":return{_id:"Duration",_tag:"Millis",millis:this.value.millis};case"Nanos":return{_id:"Duration",_tag:"Nanos",nanos:String(this.value.nanos)};case"Infinity":return{_id:"Duration",_tag:"Infinity"};case"NegativeInfinity":return{_id:"Duration",_tag:"NegativeInfinity"}}},[Xr](){return this.toJSON()},pipe(){return et(this,arguments)}},fn=(e)=>{let t=Object.create(p2);if(typeof e==="number")if(isNaN(e)||e===0||Object.is(e,-0))t.value=Xv;else if(!Number.isFinite(e))t.value=e>0?a2:c2;else if(!Number.isInteger(e))t.value={_tag:"Nanos",nanos:xg(e)};else t.value={_tag:"Millis",millis:e};else if(e===jp)t.value=Xv;else t.value={_tag:"Nanos",nanos:e};return t},d2=(e)=>He(e,Wl),aC=(e)=>e.value._tag!=="Infinity"&&e.value._tag!=="NegativeInfinity";var u2=fn(0),eC=fn(1/0),tC=fn(-1/0),$l=(e)=>fn(e);var l2=(e)=>fn(e);var Gl=(e)=>f2(ac(e),{onMillis:Ee,onNanos:(t)=>o2(t,1e6),onInfinity:()=>1/0,onNegativeInfinity:()=>-1/0});var rC=(e)=>{let t=ac(e);switch(t.value._tag){case"Infinity":case"NegativeInfinity":throw Error("Cannot convert infinite duration to nanos");case"Nanos":return t.value.nanos;case"Millis":return xg(t.value.millis)}};var f2=q(2,(e,t)=>{switch(e.value._tag){case"Millis":return t.onMillis(e.value.millis);case"Nanos":return t.onNanos(e.value.nanos);case"Infinity":return t.onInfinity();case"NegativeInfinity":return(t.onNegativeInfinity??t.onInfinity)()}}),m2=q(3,(e,t,r)=>{if(e.value._tag==="Infinity"||e.value._tag==="NegativeInfinity"||t.value._tag==="Infinity"||t.value._tag==="NegativeInfinity")return r.onInfinity(e,t);if(e.value._tag==="Millis")return t.value._tag==="Millis"?r.onMillis(e.value.millis,t.value.millis):r.onNanos(rC(e),t.value.nanos);else return r.onNanos(e.value.nanos,rC(t))});var h2=(e,t)=>m2(e,t,{onMillis:(r,n)=>r===n,onNanos:(r,n)=>r===n,onInfinity:(r,n)=>r.value._tag===n.value._tag});var y2=q(2,(e,t)=>h2(e,t));var g2,cC=()=>g2??=new jl;var pC=(e)=>{let t=!1;return Promise.resolve().then(()=>{if(!t)e()}),()=>{t=!0}},x2="setImmediate"in globalThis?(e)=>{let t=globalThis.setImmediate(e);return()=>globalThis.clearImmediate(t)}:(e)=>{let t=setTimeout(e,0);return()=>clearTimeout(t)},dC=(e)=>{try{return x2(e)}catch{return pC(e)}};class uC{buckets=[];scheduleTask(e,t){let r=this.buckets,n=r.length,o,i=0;for(;i<n;i++){if(r[i][0]>t)break;o=r[i]}if(o&&o[0]===t)o[1].push(e);else if(i===n)r.push([t,[e]]);else r.splice(i,0,[t,[e]])}drain(){let e=this.buckets;return this.buckets=[],e}}class jl{executionMode;setImmediate;constructor(e="async",t){this.executionMode=e,this.setImmediate=t??(e==="sync"?pC:dC)}shouldYield(e){return e.currentOpCount>=e.cache.maxOpsBeforeYield}makeDispatcher(){return new lC(this.setImmediate)}}class lC{tasks=new uC;running=void 0;setImmediate;constructor(e=dC){this.setImmediate=e}scheduleTask(e,t){if(this.tasks.scheduleTask(e,t),this.running===void 0)this.running=this.setImmediate(this.afterScheduled)}afterScheduled=()=>{this.running=void 0,this.runTasks()};runTasks(){let e=this.tasks.drain();for(let t=0;t<e.length;t++){let r=e[t][1];for(let n=0;n<r.length;n++)r[n]()}}flush(){while(this.tasks.buckets.length>0){if(this.running!==void 0)this.running(),this.running=void 0;this.runTasks()}}}var mC=()=>new Proxy({},{get(e,t,r){if(t==="$is")return Io;else if(t==="$match")return S2;return(n)=>({...n,_tag:t})}});function S2(){if(arguments.length===1){let r=arguments[0];return function(n){return r[n._tag](n)}}let e=arguments[0];return arguments[1][e._tag](e)}var hC=Np,Yo=Bp;var yC="~effect/encoding/EncodingError";class pc extends Yo("EncodingError"){[yC]=yC}var Ql=Jt("effect/References/CurrentLogAnnotations",{defaultValue:()=>({})});var gC=Jt(Pl,{defaultValue:()=>Rl}),Sg=Jt("effect/References/UnhandledLogLevel",{defaultValue:()=>"Error"}),bg=Jt("effect/References/CurrentLogSpans",{defaultValue:()=>[]});class EC extends Ya{constructor(e,t=Dp){super("Interrupt",t,"Interrupted");this.fiberId=e}toString(){return`Interrupt(${this.fiberId})`}toJSON(){return{_tag:"Interrupt",fiberId:this.fiberId}}[At](e){return Va(e)&&this.fiberId===e.fiberId&&this.annotations===e.annotations}[kt](){return Kr(`${this._tag}:${this.fiberId}`)}}var lc=(e)=>new Eo([new EC(e)]),kC=(e)=>e.reasons.some(Za);var Rg=(e)=>{for(let t=0;t<e.reasons.length;t++){let r=e.reasons[t];if(r._tag==="Fail")return Xt(r.error)}return Nt(e)};var _g=(e)=>e.reasons.some(vl),Ug=(e)=>_g(e)&&kC(e)?Ho(e.reasons.map((t)=>t._tag==="Fail"&&!Tl(t.error)?new Fp(t.error,t.annotations):t)):e,Fi=(e)=>_g(e)?Nt(Ug(e)):Rg(e);var Dg=(e)=>e.reasons.some(Va);var Zl=q(2,(e,t)=>{let r=!1,n=e.reasons.map((o)=>{if(Za(o))return r=!0,new Lp(t(o.error),o.annotations);return o});return r?Ho(n):e}),AC=(e)=>{let t;for(let r of e.reasons){if(r._tag==="Fail")return r.error;if(r._tag==="Die")t??=r}if(t!==void 0)return t.defect;if(e.reasons.length>0)return new globalThis.Error("All fibers interrupted without error");return new globalThis.Error("Empty cause")},vC=(e,t)=>{let r=[],n=[];if(e.reasons.length===0)return r;let o=Us();if(o!==0)Hn(1);try{for(let i of e.reasons){if(i._tag==="Interrupt"){n.push(i);continue}r.push(wg(i._tag==="Die"?i.defect:i.error,i.annotations,t))}if(r.length===0){let i=Error("The fiber was interrupted by:");i.name="InterruptCause",i.stack=R2(i,n);let s=new globalThis.Error("All fibers interrupted without error",{cause:i});s.name="InterruptError",s.stack=`${s.name}: ${s.message}`,r.push(wg(s,n[0].annotations,t))}}finally{if(o!==0)Hn(o)}return r},wg=(e,t,r,n=new Set)=>{let o=typeof e,i;if(e&&o==="object"){n.add(e);let s=e.cause;if(i=new globalThis.Error(T2(e),{cause:s!==void 0&&!n.has(s)?wg(s,void 0,void 0,n):void 0}),typeof e.name==="string")i.name=e.name;if(typeof e.stack==="string")i.stack=P2(e.stack,i,t);else{let c=`${i.name}: ${i.message}`;i.stack=t?Eg(c,t):c}if(r?.includeCauseInStack)i.stack=TC(i);for(let c of Object.keys(e))if(!(c in i))i[c]=e[c]}else{i=new globalThis.Error(!e?`Unknown error: ${e}`:o==="string"?e:_s(e));let s=`${i.name}: ${i.message}`;i.stack=t?Eg(s,t):s}return i},T2=(e)=>{if(typeof e.message==="string")return e.message;else if(typeof e.toString==="function"&&e.toString!==Object.prototype.toString&&e.toString!==Array.prototype.toString)try{return e.toString()}catch{}return _s(e)},O2=/\((.*)\)/g,P2=(e,t,r)=>{let n=`${t.name}: ${t.message}`,o=(e.startsWith(n)?e.slice(n.length):e).split(`
13
- `),i=[n];for(let s=1;s<o.length;s++){if(/Generator\.next|~effect\/(?:Effect|Utils)/.test(o[s]))break;i.push(o[s])}return r?Eg(i.join(`
12
+ `)}return t},$C=W(2,(e,t)=>{let r=lf(e,t.key);if(r!==Oc)return Le(r);return KC(t)?Le(Jg(t)):xe()}),_c=W(2,(e,t)=>{if(e.mapUnsafe.size===0)return t;if(t.mapUnsafe.size===0)return e;return _G(e,(r)=>t.mapUnsafe.forEach((n,o)=>r.set(o,n)))}),WC=(...e)=>{let t=new Map;for(let r=0;r<e.length;r++)e[r].mapUnsafe.forEach((n,o)=>{t.set(o,n)});return sa(t)};var pt=Qt;var Yg=(e)=>e.length>0;var Uc=(e)=>e>0?Math.floor(e):0;var vt=_C,Mt=PC;var Ht=Fg,ca=Ng;var Zg=W(2,(e,t)=>ca(e)?vt(t(e.success)):e),md=W(2,(e,{onFailure:t,onSuccess:r})=>Ht(e)?t(e.failure):r(e.success));var NG=W(2,(e,t)=>{if(ca(e))return e.success;throw t(e.failure)}),Xg=NG(Ce);var ex=(e)=>{if(Symbol.iterator in e){let n=[];for(let o of e){if(Ht(o))return o;n.push(o.success)}return vt(n)}let t=e,r={};for(let n of wr(t)){let o=t[n];if(Ht(o))return o;hr(r,n,o.success)}return vt(r)};var jC=W(2,(e,t)=>{let r=0;for(let n of e){let o=t(n,r);if(Hl(o)){if(o)return Le(n)}else if(T(o))return o;r++}return xe()});var Ote={[Symbol.iterator](){return BG}},BG={next(){return{done:!0,value:void 0}}};var KG=W(2,(e,t)=>Object.hasOwn(e,t));var QC=W(2,(e,t)=>{let r={...e};for(let n of HC(e))hr(r,n,t(e[n],n));return r});var HC=(e)=>Object.keys(e);var qG=(e)=>W(2,(t,r)=>{for(let n of HC(t))if(!KG(r,n)||!e(t[n],r[n]))return!1;return!0});var VC=(e)=>{let t=qG(e);return(r,n)=>t(r,n)&&t(n,r)};var ff=globalThis.Array;var hd=(e)=>ff.isArray(e)?e:ff.from(e);var yd=W(2,(e,{onEmpty:t,onNonEmpty:r})=>Zi(e)?r(e):t());var $G=ff.isArray;var mf=Yg,Zi=Yg;function JC(e){let t=Number(e);return String(t)===e&&Number.isInteger(t)&&t>=0&&t<4294967295}var rx=W(2,(e,t)=>{let r=0;for(let n of e){if(t(n,r))return Le(r);r++}return xe()});var YC=jC;var ZC=W(2,(e,t)=>{let r=hd(e);for(let n=r.length-1;n>=0;n--){let o=r[n],i=t(o,n);if(typeof i==="boolean"){if(i)return Le(o)}else if(T(i))return i}return xe()});var XC=W(2,(e,t)=>{let r=ff.from(e);return r.sort(t),r});var pa=()=>[],Xi=(e)=>[e],gn=W(2,(e,t)=>e.map(t));var hf=W(3,(e,t,r)=>hd(e).reduce((n,o,i)=>r(n,o,i),t));var gf="~effect/Duration",gd=BigInt(0),aT=BigInt(1),WG=BigInt(2),GG=BigInt(10);var cT=BigInt(1000),xd=BigInt(1e6),pT=BigInt(1e9),jG=BigInt(60000000000),zG=BigInt(3600000000000),QG=BigInt(86400000000000),HG=BigInt(604800000000000),dT=(e)=>BigInt(Math.sign(e)*Math.round(Math.abs(e))),ox=(e)=>Number.isInteger(e)?BigInt(e)*xd:dT(e*1e6),eT=(e)=>xn(Number.isFinite(e)?dT(e):e),VG=(e,t)=>{let r=Number(e);if(Number.isFinite(r))return r/t;let n=BigInt(t);return Number(e/n)+Number(e%n)/t},nx=(e,t)=>{let r=e.indexOf(".");if(r===-1)return BigInt(e)*t;let n=e[0]==="-",o=e.slice(r+1),i=GG**BigInt(o.length),s=(BigInt(e.slice(n?1:0,r))*i+BigInt(o))*t;return JG(n?-s:s,i)},JG=(e,t)=>{let r=e<gd?-e:e,n=r/t+(r%t*WG>=t?aT:gd);return e<gd?-n:n},Dc=(e,t)=>{let r=Number(e)*t;if(!Number.isFinite(r))return xn(r);let n=nx(e,BigInt(t)*xd);return xn(Number.isInteger(r)&&BigInt(r)*xd===n?r:n)};var YG=/^(-?\d+(?:\.\d+)?)\s+(nanos?|micros?|millis?|seconds?|minutes?|hours?|days?|weeks?)$/,Lc=(e)=>{switch(typeof e){case"number":return nj(e);case"bigint":return yf(e);case"string":{if(e==="Infinity")return oT;if(e==="-Infinity")return iT;let t=YG.exec(e);if(!t)break;let[r,n,o]=t;if(o==="nano"||o==="nanos")return yf(nx(n,aT));if(o==="micro"||o==="micros")return yf(nx(n,cT));switch(o){case"milli":case"millis":return Dc(n,1);case"second":case"seconds":return Dc(n,1000);case"minute":case"minutes":return Dc(n,60000);case"hour":case"hours":return Dc(n,3600000);case"day":case"days":return Dc(n,86400000);case"week":case"weeks":return Dc(n,604800000)}break}case"object":{if(e===null)break;if(gf in e)return e;if(Array.isArray(e)){if(e.length!==2||!e.every(rd))return rT(e);if(Number.isNaN(e[0])||Number.isNaN(e[1]))return rj;if(e[0]===-1/0||e[1]===-1/0)return iT;if(e[0]===1/0||e[1]===1/0)return oT;let i=e[0]*1e9+e[1];return Number.isFinite(i)&&Number.isInteger(e[0])&&Number.isInteger(e[1])?xn(BigInt(e[0])*pT+BigInt(e[1])):eT(i)}let t=e,r=0;if(t.weeks)r+=t.weeks*604800000;if(t.days)r+=t.days*86400000;if(t.hours)r+=t.hours*3600000;if(t.minutes)r+=t.minutes*60000;if(t.seconds)r+=t.seconds*1000;if(t.milliseconds)r+=t.milliseconds;if(!t.microseconds&&!t.nanoseconds){if(!Number.isFinite(r))return xn(r);let i=tT(t);return i===void 0||BigInt(r)*xd===i?xn(r):xn(i)}let n=r*1e6+(t.microseconds??0)*1000+(t.nanoseconds??0),o=Number.isFinite(n)?tT(t):void 0;return o===void 0?eT(n):xn(o)}}return rT(e)},es=(e)=>!e||Number.isInteger(e),tT=(e)=>{if(!es(e.weeks)||!es(e.days)||!es(e.hours)||!es(e.minutes)||!es(e.seconds)||!es(e.milliseconds)||!es(e.microseconds)||!es(e.nanoseconds))return;let t=gd;if(e.weeks)t+=BigInt(e.weeks)*HG;if(e.days)t+=BigInt(e.days)*QG;if(e.hours)t+=BigInt(e.hours)*zG;if(e.minutes)t+=BigInt(e.minutes)*jG;if(e.seconds)t+=BigInt(e.seconds)*pT;if(e.milliseconds)t+=BigInt(e.milliseconds)*xd;if(e.microseconds)t+=BigInt(e.microseconds)*cT;if(e.nanoseconds)t+=BigInt(e.nanoseconds);return t},rT=(e)=>{throw Error(`Invalid Input: ${e}`)};var nT={_tag:"Millis",millis:0},ZG={_tag:"Infinity"},XG={_tag:"NegativeInfinity"},ej={[gf]:gf,[Ut](){switch(this.value._tag){case"Millis":return Je(ox(this.value.millis));case"Nanos":return Je(this.value.nanos);default:return ed(this.value)}},[Dt](e){return tj(e)&&aj(this,e)},toString(){switch(this.value._tag){case"Infinity":return"Infinity";case"NegativeInfinity":return"-Infinity";case"Nanos":return`${this.value.nanos} nanos`;case"Millis":return`${this.value.millis} millis`}},toJSON(){switch(this.value._tag){case"Millis":return{_id:"Duration",_tag:"Millis",millis:this.value.millis};case"Nanos":return{_id:"Duration",_tag:"Nanos",nanos:String(this.value.nanos)};case"Infinity":return{_id:"Duration",_tag:"Infinity"};case"NegativeInfinity":return{_id:"Duration",_tag:"NegativeInfinity"}}},[cn](){return this.toJSON()},pipe(){return nt(this,arguments)}},xn=(e)=>{let t=Object.create(ej);if(typeof e==="number")if(isNaN(e)||e===0||Object.is(e,-0))t.value=nT;else if(!Number.isFinite(e))t.value=e>0?ZG:XG;else if(!Number.isInteger(e))t.value={_tag:"Nanos",nanos:ox(e)};else t.value={_tag:"Millis",millis:e};else if(e===gd)t.value=nT;else t.value={_tag:"Nanos",nanos:e};return t},tj=(e)=>Ye(e,gf),uT=(e)=>e.value._tag!=="Infinity"&&e.value._tag!=="NegativeInfinity";var rj=xn(0),oT=xn(1/0),iT=xn(-1/0),yf=(e)=>xn(e);var nj=(e)=>xn(e);var xf=(e)=>oj(Lc(e),{onMillis:Ce,onNanos:(t)=>VG(t,1e6),onInfinity:()=>1/0,onNegativeInfinity:()=>-1/0});var sT=(e)=>{let t=Lc(e);switch(t.value._tag){case"Infinity":case"NegativeInfinity":throw Error("Cannot convert infinite duration to nanos");case"Nanos":return t.value.nanos;case"Millis":return ox(t.value.millis)}};var oj=W(2,(e,t)=>{switch(e.value._tag){case"Millis":return t.onMillis(e.value.millis);case"Nanos":return t.onNanos(e.value.nanos);case"Infinity":return t.onInfinity();case"NegativeInfinity":return(t.onNegativeInfinity??t.onInfinity)()}}),ij=W(3,(e,t,r)=>{if(e.value._tag==="Infinity"||e.value._tag==="NegativeInfinity"||t.value._tag==="Infinity"||t.value._tag==="NegativeInfinity")return r.onInfinity(e,t);if(e.value._tag==="Millis")return t.value._tag==="Millis"?r.onMillis(e.value.millis,t.value.millis):r.onNanos(sT(e),t.value.nanos);else return r.onNanos(e.value.nanos,sT(t))});var sj=(e,t)=>ij(e,t,{onMillis:(r,n)=>r===n,onNanos:(r,n)=>r===n,onInfinity:(r,n)=>r.value._tag===n.value._tag});var aj=W(2,(e,t)=>sj(e,t));var cj,lT=()=>cj??=new bf;var fT=(e)=>{let t=!1;return Promise.resolve().then(()=>{if(!t)e()}),()=>{t=!0}},pj="setImmediate"in globalThis?(e)=>{let t=globalThis.setImmediate(e);return()=>globalThis.clearImmediate(t)}:(e)=>{let t=setTimeout(e,0);return()=>clearTimeout(t)},mT=(e)=>{try{return pj(e)}catch{return fT(e)}};class hT{buckets=[];scheduleTask(e,t){let r=this.buckets,n=r.length,o,i=0;for(;i<n;i++){if(r[i][0]>t)break;o=r[i]}if(o&&o[0]===t)o[1].push(e);else if(i===n)r.push([t,[e]]);else r.splice(i,0,[t,[e]])}drain(){let e=this.buckets;return this.buckets=[],e}}class bf{executionMode;setImmediate;constructor(e="async",t){this.executionMode=e,this.setImmediate=t??(e==="sync"?fT:mT)}shouldYield(e){return e.currentOpCount>=e.cache.maxOpsBeforeYield}makeDispatcher(){return new yT(this.setImmediate)}}class yT{tasks=new hT;running=void 0;setImmediate;constructor(e=mT){this.setImmediate=e}scheduleTask(e,t){if(this.tasks.scheduleTask(e,t),this.running===void 0)this.running=this.setImmediate(this.afterScheduled)}afterScheduled=()=>{this.running=void 0,this.runTasks()};runTasks(){let e=this.tasks.drain();for(let t=0;t<e.length;t++){let r=e[t][1];for(let n=0;n<r.length;n++)r[n]()}}flush(){while(this.tasks.buckets.length>0){if(this.running!==void 0)this.running(),this.running=void 0;this.runTasks()}}}var xT=()=>new Proxy({},{get(e,t,r){if(t==="$is")return Ln;else if(t==="$match")return dj;return(n)=>({...n,_tag:t})}});function dj(){if(arguments.length===1){let r=arguments[0];return function(n){return r[n._tag](n)}}let e=arguments[0];return arguments[1][e._tag](e)}var ST=dd,Ko=ud;var bT="~effect/encoding/EncodingError";class Mc extends Ko("EncodingError"){[bT]=bT}var ix=(e)=>{switch(e){case 16:return lj();case 32:return fj();default:{let t="";for(let r=e>>>3;r>0;r--)t+=uj();return t}}},Ue=Uint8Array.from("0123456789abcdef",(e)=>e.charCodeAt(0)),ua=()=>Math.random()*4294967296>>>0,uj=()=>{let e=ua();return String.fromCharCode(Ue[e>>>28],Ue[e>>>24&15],Ue[e>>>20&15],Ue[e>>>16&15],Ue[e>>>12&15],Ue[e>>>8&15],Ue[e>>>4&15],Ue[e&15])},lj=()=>{let e=ua(),t=ua();return String.fromCharCode(Ue[e>>>28],Ue[e>>>24&15],Ue[e>>>20&15],Ue[e>>>16&15],Ue[e>>>12&15],Ue[e>>>8&15],Ue[e>>>4&15],Ue[e&15],Ue[t>>>28],Ue[t>>>24&15],Ue[t>>>20&15],Ue[t>>>16&15],Ue[t>>>12&15],Ue[t>>>8&15],Ue[t>>>4&15],Ue[t&15])},fj=()=>{let e=ua(),t=ua(),r=ua(),n=ua();return String.fromCharCode(Ue[e>>>28],Ue[e>>>24&15],Ue[e>>>20&15],Ue[e>>>16&15],Ue[e>>>12&15],Ue[e>>>8&15],Ue[e>>>4&15],Ue[e&15],Ue[t>>>28],Ue[t>>>24&15],Ue[t>>>20&15],Ue[t>>>16&15],Ue[t>>>12&15],Ue[t>>>8&15],Ue[t>>>4&15],Ue[t&15],Ue[r>>>28],Ue[r>>>24&15],Ue[r>>>20&15],Ue[r>>>16&15],Ue[r>>>12&15],Ue[r>>>8&15],Ue[r>>>4&15],Ue[r&15],Ue[n>>>28],Ue[n>>>24&15],Ue[n>>>20&15],Ue[n>>>16&15],Ue[n>>>12&15],Ue[n>>>8&15],Ue[n>>>4&15],Ue[n&15])};var hj="effect/Tracer/ParentSpan";class sx extends Qt()(hj){}var yj=(e)=>e;var If=pt("effect/Tracer/DisablePropagation",{defaultValue:Hp}),IT=pt("effect/Tracer/CurrentTraceLevel",{defaultValue:()=>"Info"}),ET=pt("effect/Tracer/MinimumTraceLevel",{defaultValue:()=>"All"});var kT=yj({span:(e)=>new wT(e)});class wT{_tag="Span";sampled;name;parent;annotations;links;startTime;kind;status;_traceId=void 0;_spanId=void 0;_attributes=void 0;_events=void 0;constructor(e){this.name=e.name,this.parent=e.parent,this.annotations=e.annotations,this.links=e.links,this.startTime=e.startTime,this.kind=e.kind,this.sampled=e.sampled,this.status={_tag:"Started",startTime:e.startTime}}get traceId(){return this._traceId??=m(this.parent)?.traceId??ix(32)}get spanId(){return this._spanId??=ix(16)}get attributes(){return this._attributes??=new Map}get events(){return this._events??=[]}end(e,t){if(this.status._tag==="Ended")return;this.status={_tag:"Ended",endTime:e,exit:t,startTime:this.status.startTime}}attribute(e,t){if(this.status._tag==="Ended")return;this.attributes.set(e,t)}event(e,t,r){if(this.status._tag==="Ended")return;this.events.push([e,t,r??{}])}addLinks(e){if(this.status._tag==="Ended")return;this.links.push(...e)}}var ax=pt(of,{defaultValue:Uo});var Ef=pt("effect/References/TracerTimingEnabled",{defaultValue:_o}),cx=pt("effect/References/TracerSpanAnnotations",{defaultValue:()=>({})}),px=pt("effect/References/TracerSpanLinks",{defaultValue:()=>[]}),kf=pt("effect/References/CurrentLogAnnotations",{defaultValue:()=>({})});var vT=pt(sf,{defaultValue:()=>af}),dx=pt("effect/References/UnhandledLogLevel",{defaultValue:()=>"Error"}),ux=pt("effect/References/CurrentLogSpans",{defaultValue:()=>[]});var CT=(e)=>(t)=>{let r;return()=>{if(r!==void 0)return r;let n=t();if(!n)return;let o=n.split(`
13
+ `);if(o[e]!==void 0)return r=o[e].trim(),r}};class LT extends Ec{constructor(e,t=ad){super("Interrupt",t,"Interrupted");this.fiberId=e}toString(){return`Interrupt(${this.fiberId})`}toJSON(){return{_tag:"Interrupt",fiberId:this.fiberId}}[Dt](e){return bc(e)&&this.fiberId===e.fiberId&&this.annotations===e.annotations}[Ut](){return en(`${this._tag}:${this.fiberId}`)}}var Fc=(e)=>new No([new LT(e)]),MT=(e)=>e.reasons.some(Ac);var Ex=(e)=>{for(let t=0;t<e.reasons.length;t++){let r=e.reasons[t];if(r._tag==="Fail")return vt(r.error)}return Mt(e)};var kx=(e)=>e.reasons.some(pd),wx=(e)=>kx(e)&&MT(e)?fi(e.reasons.map((t)=>t._tag==="Fail"&&!rf(t.error)?new wc(t.error,t.annotations):t)):e,ts=(e)=>kx(e)?Mt(wx(e)):Ex(e);var Ax=(e)=>e.reasons.some(bc);var FT=(e)=>sa(e.annotations);var Nc=W(2,(e,t)=>{let r=!1,n=e.reasons.map((o)=>{if(Ac(o))return r=!0,new kc(t(o.error),o.annotations);return o});return r?fi(n):e}),vx=(e)=>{let t;for(let r of e.reasons){if(r._tag==="Fail")return r.error;if(r._tag==="Die")t??=r}if(t!==void 0)return t.defect;if(e.reasons.length>0)return new globalThis.Error("All fibers interrupted without error");return new globalThis.Error("Empty cause")},NT=(e,t)=>{let r=[],n=[];if(e.reasons.length===0)return r;let o=ui();if(o!==0)tn(1);try{for(let i of e.reasons){if(i._tag==="Interrupt"){n.push(i);continue}r.push(fx(i._tag==="Die"?i.defect:i.error,i.annotations,t))}if(r.length===0){let i=Error("The fiber was interrupted by:");i.name="InterruptCause",i.stack=Aj(i,n);let s=new globalThis.Error("All fibers interrupted without error",{cause:i});s.name="InterruptError",s.stack=`${s.name}: ${s.message}`,r.push(fx(s,n[0].annotations,t))}}finally{if(o!==0)tn(o)}return r},fx=(e,t,r,n=new Set)=>{let o=typeof e,i;if(e&&o==="object"){n.add(e);let s=e.cause;if(i=new globalThis.Error(Ej(e),{cause:s!==void 0&&!n.has(s)?fx(s,void 0,void 0,n):void 0}),typeof e.name==="string")i.name=e.name;if(typeof e.stack==="string")i.stack=wj(e.stack,i,t);else{let c=`${i.name}: ${i.message}`;i.stack=t?mx(c,t):c}if(r?.includeCauseInStack)i.stack=KT(i);for(let c of Object.keys(e))if(!(c in i))i[c]=e[c]}else{i=new globalThis.Error(!e?`Unknown error: ${e}`:o==="string"?e:Xs(e));let s=`${i.name}: ${i.message}`;i.stack=t?mx(s,t):s}return i},Ej=(e)=>{if(typeof e.message==="string")return e.message;else if(typeof e.toString==="function"&&e.toString!==Object.prototype.toString&&e.toString!==Array.prototype.toString)try{return e.toString()}catch{}return Xs(e)},kj=/\((.*)\)/g,wj=(e,t,r)=>{let n=`${t.name}: ${t.message}`,o=(e.startsWith(n)?e.slice(n.length):e).split(`
14
+ `),i=[n];for(let s=1;s<o.length;s++){if(/Generator\.next|~effect\/(?:Effect|Utils)/.test(o[s]))break;i.push(o[s])}return r?mx(i.join(`
14
15
  `),r):i.join(`
15
- `)},Eg=(e,t)=>{let r=t?.get(Cl);if(r)e=`${e}
16
- ${CC(r)}`;return e},R2=(e,t)=>{let r=[`${e.name}: ${e.message}`];for(let n of t){let o=n.fiberId!==void 0?`#${n.fiberId}`:"unknown",i=n.annotations.get(Wy.key);if(r.push(` at fiber (${o})`),i)r.push(CC(i))}return r.join(`
17
- `)},CC=(e)=>{let t=[],r=e,n=0;while(r&&n<10){let o=r.stack();if(o){let i=o.matchAll(O2),s=!1;for(let[,c]of i)s=!0,t.push(` at ${r.name} (${c})`);if(!s)t.push(` at ${r.name} (${o.replace(/^at /,"")})`)}else t.push(` at ${r.name}`);r=r.parent,n++}return t.join(`
18
- `)},Lg=(e)=>vC(e).map(TC).join(`
19
- `),TC=(e)=>e.cause?`${e.stack} {
20
- ${OC(e.cause," ")}
21
- }`:e.stack,OC=(e,t)=>{let r=e.stack.split(`
16
+ `)},mx=(e,t)=>{let r=t?.get(tf);if(r)e=`${e}
17
+ ${BT(r)}`;return e},Aj=(e,t)=>{let r=[`${e.name}: ${e.message}`];for(let n of t){let o=n.fiberId!==void 0?`#${n.fiberId}`:"unknown",i=n.annotations.get(vg.key);if(r.push(` at fiber (${o})`),i)r.push(BT(i))}return r.join(`
18
+ `)},BT=(e)=>{let t=[],r=e,n=0;while(r&&n<10){let o=r.stack();if(o){let i=o.matchAll(kj),s=!1;for(let[,c]of i)s=!0,t.push(` at ${r.name} (${c})`);if(!s)t.push(` at ${r.name} (${o.replace(/^at /,"")})`)}else t.push(` at ${r.name}`);r=r.parent,n++}return t.join(`
19
+ `)},Cx=(e)=>NT(e).map(KT).join(`
20
+ `),KT=(e)=>e.cause?`${e.stack} {
21
+ ${qT(e.cause," ")}
22
+ }`:e.stack,qT=(e,t)=>{let r=e.stack.split(`
22
23
  `),n=`${t}[cause]: ${r[0]}`;for(let o=1,i=r.length;o<i;o++)n+=`
23
24
  ${t}${r[o]}`;if(e.cause)n+=` {
24
- ${OC(e.cause,`${t} `)}
25
- ${t}}`;return n},Mg="~effect/Fiber",_2={_A:Ee,_E:Ee},U2=0,xC=(()=>{try{return globalThis.process?.getBuiltinModule?.("node:async_hooks")?.AsyncResource}catch{return}})(),PC=()=>xC===void 0?void 0:new xC("effect/Fiber"),Xl=()=>globalThis[Qa];class fc{constructor(e,t=!0){this.setContext(e),this.id=++U2,this.currentOpCount=0,this.interruptible=t,this._stack=[],this._observers=void 0,this._exit=void 0,this._children=void 0,this._interruptedCause=void 0,this._yielded=void 0,this._autoYielded=!1,this._running=!1,this._deferredInterrupt=!1,this._parent=void 0,this._asyncContext=void 0,this.cache.runtimeMetrics?.recordFiberStart(this.context)}get[Mg](){return _2}get currentDispatcher(){return this._dispatcher??=this.cache.scheduler.makeDispatcher()}getRef(e){return Nv(this.context,e)}addObserver(e){if(this._exit)return e(this._exit),Go;return(this._observers??=[]).push(e),()=>this.removeObserver(e)}removeObserver(e){if(this._exit||this._observers===void 0)return;let t=this._observers.indexOf(e);if(t>=0)this._observers.splice(t,1)}interruptUnsafe(e,t){if(this._exit)return;let r=lc(e);if(this.cache.stackFrame)r=Al(r,new Map([[Cl,this.cache.stackFrame]]));if(t)r=Al(r,t.mapUnsafe);if(this._interruptedCause=this._interruptedCause?By(this._interruptedCause,r):r,this.interruptible)if(this._running)this._deferredInterrupt=!0;else this.evaluate(Ct(this._interruptedCause))}pollUnsafe(){return this._exit}evaluate(e){if(this._exit)return;else if(this._asyncContext!==void 0){let o=this._asyncContext;this._asyncContext=void 0;try{return o.runInAsyncScope(this.evaluate,this,e)}finally{o.emitDestroy()}}else if(this._yielded!==void 0){let o=this._yielded;this._yielded=void 0,o()}let t=this.runLoop(e);if(t===Fs){this._asyncContext=PC();return}let r=kg.interruptChildren&&kg.interruptChildren(this,t);if(r!==void 0)return this.interruptible=!1,this.evaluate(r);if(this._exit=t,this.cache.runtimeMetrics?.recordFiberEnd(this.context,this._exit),this._parent)this._parent._children?.delete(this),this._parent=void 0;if(this._observers!==void 0){let o=this._observers;this._observers=void 0;for(let i=0;i<o.length;i++)o[i](t)}this._stack.length=0,this._children=void 0,this.context=un();let n=this.cache;if(n.span!==void 0||n.stackFrame!==void 0)this.cache={...n,span:void 0,stackFrame:void 0}}runLoop(e){let t=globalThis[Qa];globalThis[Qa]=this;let r=this._running;this._running=!0;let n=!1,o=this._autoYielded;this._autoYielded=!1;let i=e;this.currentOpCount=o?1:0;try{while(!0)try{if(this._deferredInterrupt)this._deferredInterrupt=!1,i=Ct(this._interruptedCause);this.currentOpCount++;let s=this.cache;if(!o&&!n&&!s.preventYield&&s.scheduler.shouldYield(this))n=!0,i=this.yieldNow(i,0,!0);else o=!1,i=s.tracerContext?s.tracerContext(i,this):i[lt](this);if(i===Fs){let c=this._yielded;if(Ls in c)return this._deferredInterrupt=!1,this._yielded=void 0,c;else if(this._deferredInterrupt){this._yielded=void 0,c();continue}return Fs}}catch(s){if(!Mt(i,lt))return On(`Fiber.runLoop: Not a valid effect: ${String(i)}`);i=On(s)}}finally{this._running=r,globalThis[Qa]=t}}getCont(e){if(this._deferredInterrupt)return this._deferredInterrupt=!1,L2;while(!0){let t=this._stack.pop();if(!t)return;let r=t[Ms];if(r!==void 0){let n=r.call(t,this);if(n)return n[e]=n,n}if(t[e])return t}}succeedWith(e){if((++this.currentOpCount&M2-1)===0)return ft(e);let t=this.getCont(Zt);return t?t[Zt](e,this):this.yieldWith(ft(e))}yieldWith(e){return this._yielded=e,Fs}yieldNow(e,t=0,r=!1){let n=!1;return this.currentDispatcher.scheduleTask(()=>{if(n)return;this._autoYielded=r,this.evaluate(e)},t),this.yieldWith(()=>{n=!0})}children(){return this._children??=new Set}pipe(){return et(this,arguments)}setContext(e){let t=this.context;if(this.context=e,t!==void 0&&Mv(t,e))return;let r=e.cacheRoot,n=r._fiberCache??=D2(e);if(this.cache?.scheduler!==n.scheduler)this._dispatcher=void 0;this.cache=n}get currentSpanLocal(){let e=this.cache.span;return e?._tag==="Span"?e:void 0}}var D2=(e)=>{let t=(n)=>ug(e,n),r=t(uv);return{scheduler:t(Ol)??cC(),tracer:r,tracerContext:r?.context,tracerEnabled:t(Gy)??Qy,span:t(lv),logLevel:t(jy)??Hy,minimumLogLevel:t(Pl)??Rl,stackFrame:t(zy),runtimeMetrics:t(fv),maxOpsBeforeYield:t(pv)??mv,preventYield:t(dv)??hv}},L2={[Zt](e,t){return Ct(t._interruptedCause)},[pn](e,t){return Ct(t._interruptedCause)}},M2=32,kg={interruptChildren:void 0},mc=(e)=>{if(!e.cache.stackFrame)return;let t=new Map;return t.set(Wy.key,e.cache.stackFrame),rc(t)},F2=(e,t)=>{if(e._children===void 0||e._children.size===0)return;return Wt(Hp(e._children),()=>t)},RC=(e)=>{let t=e;if(t._exit)return it(t._exit);return Gr((r)=>{if(t._exit)return r(it(t._exit));return vt(e.addObserver((n)=>r(it(n))))})},Fg=(e)=>Gr((t)=>{let r=e[Symbol.iterator](),n=[],o=void 0;function i(){let s=r.next();while(!s.done){if(s.value._exit){n.push(s.value._exit),s=r.next();continue}o=s.value.addObserver((c)=>{n.push(c),i()});return}t(it(n))}return i(),vt(()=>o?.())}),Vl=(e)=>{let t=e;if(t._exit)return t._exit;return Gr((r)=>{if(t._exit)return r(t._exit);return vt(e.addObserver(r))})};var ef=(e)=>Xe((t)=>_C(e,t.id)),_C=q((e)=>Mt(e[0],Mg),(e,t,r)=>Xe((n)=>{let o=mc(n);return o=o&&r?oc(o,r):o??r,e.interruptUnsafe(t,o),of(RC(e))})),Hp=(e)=>Xe((t)=>{let r=mc(t),n=qs();for(let o of e)o.interruptUnsafe(t.id,r),n.push(o);return of(Fg(n))});var it=ft,Ct=ir,Ni=Vn,vt=Tn({op:"Sync",[lt](e){let t=this[Me],r=t(),n=e.getCont(Zt);return n?n[Zt](r,e):e.yieldWith(ft(r))}}),St=Tn({op:"Suspend",[lt](e){let t=this[Me];return t()}});var UC=Nl({onFailure:Ni,onSuccess:it});var DC=Tn({op:"Yield",[lt](e){return e.yieldNow(Wr,this[Me]??0)}}),Ng=DC(0),LC=(e)=>it(Ue(e)),MC=it(ge());var FC=(e)=>St(()=>Ct(e())),hc=(e)=>On(e),NC=(e)=>St(()=>Ni(e())),yt=it(void 0);var BC=(e)=>{let t=typeof e==="function"?e:e.try,r=typeof e==="function"?(n)=>new id(n,"An error occurred in Effect.try"):e.catch;return St(()=>{try{return it(t())}catch(n){return Ni(r(n))}})};var KC=(e)=>{let t=typeof e==="function"?e:e.try,r=typeof e==="function"?(n)=>new id(n,"An error occurred in Effect.tryPromise"):e.catch;return qC(function(n,o){let i=(s)=>St(()=>{try{return Ni(_p(()=>r(s)))}catch(c){return hc(c)}});try{t(o).then((s)=>n(it(s)),(s)=>n(i(s)))}catch(s){n(i(s))}},t.length!==0)};var qC=function(){let e=Cn({op:"Async",[lt](r){let n=!1,o=!1,i=this.withSignal?new AbortController:void 0,s=this.register.call(r.cache.scheduler,(c)=>{if(n)return;if(n=!0,o)r.evaluate(c);else o=c},i?.signal);if(o!==!1)return o;if(o=!0,r.yieldWith(()=>{n=!0}),i===void 0&&s===void 0)return Fs;return r._stack.push(N2(()=>(n=!0,i?.abort(),s??Wr))),Fs}}),t=function(r,n){this.register=r,this.withSignal=n};return t.prototype=e,function(r,n){return new t(r,n)}}(),N2=Tn({op:"AsyncFinalizer",[Ms](e){if(e.interruptible)e.interruptible=!1,e._stack.push(td)},[pn](e,t){return Dg(e)?Wt(IT(ir(e),this[Me]()),()=>Ct(e)):Ct(e)}}),Gr=(e)=>qC(e,e.length>=2),tf=Gr(Go),$C=(...e)=>{if(e.length===1){let n=e[0];return St(()=>dc(n()))}let[t,r]=e;return St(()=>dc(r.call(t.self)))},WC=(e,t)=>typeof e==="function"?e:t.shift().bind(e.self),Bg=(e,...t)=>{let r=WC(e,t),n=t.length===0?function(){return St(()=>dc(r.apply(this,arguments)))}:function(){let o=St(()=>dc(r.apply(this,arguments)));for(let i=0;i<t.length;i++)o=t[i](o,...arguments);return o};return GC(r.length,n)},GC=(e,t)=>Object.defineProperty(t,"length",{value:e,configurable:!0});var zC=(e,...t)=>{let r=WC(e,t);return GC(r.length,t.length===0?function(){return SC(()=>r.apply(this,arguments))}:function(){let n=SC(()=>r.apply(this,arguments));for(let o of t)n=o(n,...arguments);return n})},SC=(e)=>{try{let t=e(),r=void 0;while(!0){let n=t.next(r);if(n.done)return it(n.value);let o=n.value;if(o&&o._tag==="Success"){r=o.value;continue}else if(o&&o._tag==="Failure")return n.value;else{let i=!0;return St(()=>{if(i)return i=!1,Wt(n.value,(s)=>dc(t,s));else return St(()=>dc(e()))})}}}catch(t){return hc(t)}},dc=function(){let e=Cn({op:"Iterator",[Zt](r,n){let o=this.iterator;while(!0){let i=o.next(r);if(i.done)return it(i.value);if(!mt(i.value))return n._stack.push(this),i.value;else if(i.value._tag==="Failure")return i.value;r=i.value.value}},[lt](r){return this[Zt](this.initial,r)}}),t=function(r,n){this.iterator=r,this.initial=n};return t.prototype=e,function(r,n){return new t(r,n)}}(),yc=q(2,(e,t)=>new ei(e,Kg,it(t))),rf=function(e){return e._stack.push(this),this[Me]},B2=Cn({op:"OnSuccess",[lt]:rf}),ei=function(e,t,r){this[Me]=e,this[Zt]=t,this.payload=r};ei.prototype=B2;var Kg=function(){return this.payload},jC=function(e,t){return t.succeedWith(this.payload)},qg=(()=>{let e=Us();if(e===0)return!1;let t="~effect/Effect/stackProbe",r={[t]:function(){return Error()}};Hn(1);let n=r[t]();return Hn(e),n.stack?.includes("[as "+t+"]")===!0})(),K2=function(e,t){let r=this.payload;return t.succeedWith(qg?r(e):_p(()=>r(e)))},QC=function(e){let t=this.payload;return t(e)},q2=function(e){let t=this.payload;return new ei(t(e),jC,e)},$2=function(e){return new ei(this.payload,jC,e)};var Ws=q(2,(e,t)=>new ei(e,Ht(t)?Kg:QC,t)),nf=q(2,(e,t)=>new ei(e,Ht(t)?$2:q2,t)),of=(e)=>new ei(e,Kg,Wr);var HC=(e,t)=>Xe((r)=>{let n=new Set;return ff(r,()=>n.size===0?void 0:Hp(n)),Gr((o)=>{let i=!1,s=0;for(let c of e){if(i)break;let l=s++,S=new fc(r.context);if(n.add(S),S.addObserver((m)=>{n.delete(S);let g=!i;if(i=!0,o(m),g)W2(n,r),t?.onWinner?.({fiber:S,index:l,parentFiber:r})}),i)S.interruptUnsafe(r.id,mc(r));else S.evaluate(c);if(i)break}})}),W2=(e,t)=>{let r=mc(t);for(let n of e)n.interruptUnsafe(t.id,r)};var VC=q((e)=>Ht(e[1]),(e,t,r)=>HC([e,t],r)),Wt=q(2,(e,t)=>new ei(e,QC,t));var mt=(e)=>e[Ls]!==void 0,JC=q(2,(e,t)=>{if(mt(e))return e._tag==="Success"?t(e.value):e;return Wt(e,t)});var Pn=q(2,(e,t)=>new ei(e,K2,t)),YC=q(2,(e,t)=>mt(e)?nT(e,t):Pn(e,t)),ZC=q(2,(e,t)=>mt(e)?oT(e,t):jg(e,t));var XC=q(2,(e,t)=>{if(mt(e)){if(e._tag==="Success")return e;let r=Fi(e.cause);if(mr(r))return ir(r.failure);return t(r.success)}return Jp(e,t)}),$g=(e)=>ir(lc(e)),sf=(e)=>e._tag==="Success";var eT=(e)=>e._tag==="Failure";var tT=(e)=>e._tag==="Failure"?Xt(e.cause):Nt(e);var rT=(e)=>e._tag==="Failure"&&Dg(e.cause);var Wr=ft(void 0),nT=q(2,(e,t)=>e._tag==="Success"?ft(t(e.value)):e),oT=q(2,(e,t)=>{if(e._tag==="Success")return e;return ir(Zl(e.cause,t))});var iT=q(2,(e,t)=>sf(e)?t:e);var sT=(e)=>{let t=[];for(let r of e)if(r._tag==="Failure")t.push(...r.cause.reasons);return t.length===0?Wr:ir(Ho(t))};var aT=(e)=>Xe((t)=>it(Bv(t.context,e)));var Wg=q(2,(e,t)=>Xe((r)=>{let n=r.context,o=t(n);if(n===o)return e;return r.setContext(o),ff(r,()=>{r.setContext(n);return}),e}));var cT=()=>G2,G2=Xe((e)=>it(e.context)),af=(e)=>Xe((t)=>e(t.context));var ti=q(2,(e,t)=>{if(mt(e))return e;return Wg(e,oc(t))}),Vp=function(){if(arguments.length===1)return q(2,(e,t)=>bC(e,arguments[0],t));return q(3,(e,t,r)=>bC(e,t,r)).apply(this,arguments)},bC=(e,t,r)=>Wg(e,ko(t,r));var pT=q((e)=>Ht(e[1]),(e,t,r,n)=>n?.concurrent?Pn(tx([e,t],{concurrency:2}),([o,i])=>r(o,i)):Wt(e,(o)=>Pn(t,(i)=>r(o,i))));var dT=q((e)=>Ht(e[0]),(e,t)=>nd({while:Ti,body:cn(t?.disableYield?e:Wt(e,(r)=>Ng)),step:Go})),ri=q(2,(e,t)=>new uT(e,t.length!==1?(r)=>t(r):t)),z2=Cn({op:"OnFailure",[lt]:rf}),uT=function(e,t){this[Me]=e,this[pn]=t};uT.prototype=z2;var cf=q(3,(e,t,r)=>ri(e,(n)=>{let o=t(n);return mr(o)?Ct(o.failure):r(o.success,n)})),Jp=q(2,(e,t)=>cf(e,Fi,(r)=>t(r)));var lT=q(3,(e,t,r)=>ri(e,(n)=>{let o=t(n);if(mr(o))return Ct(n);return Ws(r(o.success,n),Ct(n))})),fT=q(2,(e,t)=>lT(e,Rg,(r)=>t(r)));var pf=q((e)=>Ht(e[0]),(e,t,r,n)=>ri(e,(o)=>{let i=Fi(o);if(mr(i))return Ct(i.failure);if(!t(i.success))return n?n(i.success):Ct(o);return r(i.success)})),Gg=q((e)=>Ht(e[0]),(e,t,r,n)=>ri(e,(o)=>{let i=Fi(o);if(mr(i))return Ct(i.failure);let s=t(i.success);if(mr(s))return n?n(s.failure):Ct(o);return r(s.success)})),zg=q((e)=>Ht(e[0]),(e,t,r,n)=>{let o=Array.isArray(t)?(i)=>Mt(i,"_tag")&&t.includes(i._tag):Io(t);return pf(e,o,r,n)}),mT=q((e)=>Ht(e[0]),(e,t,r)=>{let n;return Gg(e,(o)=>(n??=Object.keys(t),Mt(o,"_tag")&&jo(o._tag)&&n.includes(o._tag)?Xt(o):Nt(o)),(o)=>t[o._tag](o),r)}),hT=q((e)=>Ht(e[0]),(e,t,r,n,o)=>pf(e,(i)=>Io(i,t)&&Mt(i,"reason")&&(o!==void 0||Io(i.reason,r)),(i)=>{let s=i.reason;if(Io(s,r))return n(s,i);return o?o(s,i):Ni(i)}));var jg=q(2,(e,t)=>ri(e,(r)=>Ct(Zl(r,t))));var Qg=(e)=>Jp(e,hc);var yT=(e)=>e==="Unhandled"?(...t)=>Xe((r)=>{let n=r.getRef(Sg);return n===void 0?yt:Pg(n)(...t)}):Pg(e===!0?void 0:e),gT=q((e)=>Ht(e[0]),(e,t)=>{if(!t?.log)return Hg(e,{onFailure:(n)=>yt,onSuccess:(n)=>yt});let r=yT(t.log);return Xo(e,{onFailure(n){let o=Fi(n);return mr(o)?Ct(o.failure):t.message===void 0?r(n):r(t.message,n)},onSuccess:(n)=>yt})}),xT=q((e)=>Ht(e[0]),(e,t)=>{if(!t?.log)return Xo(e,{onFailure:(n)=>yt,onSuccess:(n)=>yt});let r=yT(t.log);return Xo(e,{onFailure:(n)=>t.message===void 0?r(n):r(t.message,n),onSuccess:(n)=>yt})});var Hl=(e)=>bT(e,{onFailure:Nt,onSuccess:Xt}),Xo=q(2,(e,t)=>new ST(e,t.onSuccess.length!==1?(r)=>t.onSuccess(r):t.onSuccess,t.onFailure.length!==1?(r)=>t.onFailure(r):t.onFailure)),j2=Cn({op:"OnSuccessAndFailure",[lt]:rf}),ST=function(e,t,r){this[Me]=e,this[Zt]=t,this[pn]=r};ST.prototype=j2;var Q2=function(e,t){let r=this.payload;return t.succeedWith(qg?r.onSuccess(e):_p(()=>r.onSuccess(e)))},H2=(e,t)=>{let r=Cn({op:e,[lt]:rf,[Zt]:Q2,[pn]:t}),n=function(o,i){this[Me]=o,this.payload=i};return n.prototype=r,n},V2=H2("Match",function(e,t){let r=Fi(e);if(mr(r))return Ct(r.failure);let n=this.payload;return t.succeedWith(qg?n.onFailure(r.success):_p(()=>n.onFailure(r.success)))});var Hg=q(2,(e,t)=>Xo(e,{onFailure:(r)=>{let n=Fi(r);return mr(n)?Ct(n.failure):t.onFailure(n.success)},onSuccess:t.onSuccess})),Vg=q(2,(e,t)=>new V2(e,t)),bT=q(2,(e,t)=>{if(mt(e)){if(e._tag==="Success")return ft(t.onSuccess(e.value));let r=Fi(e.cause);if(mr(r))return ir(r.failure);return ft(t.onFailure(r.success))}return Vg(e,t)});var Yp=(e)=>mt(e)?ft(e):J2(e),J2=Tn({op:"Exit",[lt](e){return e._stack.push(this),this[Me]},[Zt](e,t,r){return t.succeedWith(r??ft(e))},[pn](e,t,r){return t.succeedWith(r??ir(e))}});var Ag="~effect/Scope",vg="~effect/Scope/Closeable",Zp=Vt("effect/Scope"),Jg=(e,t)=>Xe((r)=>(rG(r),df(e,t)??yt)),df=(e,t)=>{let r=e.state;if(r._tag==="Closed")return;if(e.state={_tag:"Closed",exit:t},e.parent!==void 0)Yl(e.parent,e);if(r._tag==="Empty")return;if(r.finalizer!==void 0)return Jl(r.finalizer,t);let n=r.finalizers;if(n.size===1)return Jl(n.values().next().value,t);return Y2(e,n,t)},Jl=(e,t)=>{try{return e(t)}catch(r){return On(r)}},IT=(e,t)=>sf(e)?t:ri(t,(r)=>Ct(Ug(kl(e.cause,r)))),Y2=Bg(function*(e,t,r){let n=[],o=[],i=Array.from(t),s=Xl();for(let c=i.length-1;c>=0;c--){let[l,S]=i[c];if(e.strategy==="sequential")n.push(yield*Yp(Jl(S,r)));else if(l!==s)o.push(yf(s,Jl(S,r),!0,!0,"inherit"))}if(o.length>0)n=yield*Fg(o);return yield*sT(n)});var wT=(e,t)=>{let r=kT(t,e);if(e.state._tag==="Closed")return r.state=e.state,r;return gc(e,r,(n)=>Jg(r,n)),r},Xp=(e,t)=>St(()=>{if(e.state._tag==="Closed")return t(e.state.exit);return gc(e,{},t),yt}),ET=(e,t)=>Xp(e,cn(t)),gc=(e,t,r)=>{if(e.state._tag==="Empty")e.state={_tag:"Open",finalizerKey:t,finalizer:r,finalizers:void 0};else if(e.state._tag==="Open"){let n=e.state;if(n.finalizer!==void 0)n.finalizers=new Map([[n.finalizerKey,n.finalizer]]),n.finalizerKey=void 0,n.finalizer=void 0,n.finalizers.set(t,r);else n.finalizers.set(t,r)}},Yl=(e,t)=>{if(e.state._tag!=="Open")return;let r=e.state;if(r.finalizerKey===t)e.state=Cg;else if(r.finalizers!==void 0){if(r.finalizers.delete(t),r.finalizers.size===0)e.state=Cg}},uf=(e)=>kT(e,void 0),kT=(e="sequential",t)=>({[vg]:vg,[Ag]:Ag,strategy:e,parent:t,state:Cg}),Cg={_tag:"Empty"};var ed=Zp,AT=Vp(Zp),Yg=(e)=>Xe((t)=>{let r=t.context,n=uf();return t.setContext(ko(t.context,Zp,n)),ff(t,(o)=>(t.setContext(r),df(n,o))),e});var lf=(e)=>St(()=>{let t=uf();return Gs(e(t),(r)=>St(()=>df(t,r)??yt))}),Zg=(e,t,r)=>af((n)=>rd((o)=>Wt(ed,(i)=>nf(r?.interruptible?o(e):e,(s)=>Xp(i,(c)=>ti(t(s,c),n)))))),Xg=(e)=>Wt(ed,(t)=>af((r)=>Xp(t,(n)=>ti(e(n),r)))),vT=function(){let e=Cn({op:"OnExit",[lt](r){return r._stack.push(this),this.effect},[Ms](r){if(r.interruptible&&this.interruptible!==!0)r._stack.push(td),r.interruptible=!1},[Zt](r,n,o){o??=ft(r);let i;try{i=this.onExit(o)}catch(s){i=On(s)}return i?Wt(i,(s)=>o):o},[pn](r,n,o){o??=ir(r);let i;try{i=this.onExit(o)}catch(s){i=On(s)}return i?Wt(IT(o,i),(s)=>o):o}}),t=function(r,n,o){this.effect=r,this.onExit=n,this.interruptible=o};return t.prototype=e,t}(),xc=(e,t,r)=>new vT(e,t,r),ff=(e,t)=>{e._stack.push(new vT(void 0,t,void 0))},Gs=q(2,xc),CT=q(2,(e,t)=>Gs(e,(r)=>t));var TT=q(3,(e,t,r)=>Gs(e,(n)=>{let o=t(n);return mr(o)?yt:r(o.success,n)})),OT=q(2,(e,t)=>TT(e,tT,t));var Z2=cn(1/0),X2=(e,t)=>{let r=0,n,o,i=(s,c)=>(c.awaiters++,ff(s,()=>{if(--c.awaiters>0||c.done)return;if(o===c)o=void 0;return ef(c.fiber)}),Vl(c.fiber));return[Xe((s)=>{if(o!==void 0)return s===o.fiber?Vl(o.fiber):i(s,o);if(n!==void 0&&(r===1/0||s.getRef(uc).currentTimeMillisUnsafe()<r))return n;n=void 0;let c=s.getRef(uc),l={fiber:new fc(s.context),awaiters:0,done:!1};o=l;let S=i(s,l);return l.fiber.evaluate(xc(e,(m)=>{if(l.done=!0,o!==l)return;if(o=void 0,rT(m))return;let g=t(m);r=g===1/0?1/0:c.currentTimeMillisUnsafe()+g,n=m})),l.fiber._exit??S}),vt(()=>{o=void 0,n=void 0})]};var PT=(e)=>vt(()=>X2(e,Z2)[0]),RT=Xe((e)=>Ct(lc(e.id))),ex=(e)=>Xe((t)=>{if(!t.interruptible)return e;return t.interruptible=!1,t._stack.push(td),e}),_T=Tn({op:"SetInterruptible",[Ms](e){if(e.interruptible=this[Me],e._interruptedCause&&e.interruptible)return()=>Ct(e._interruptedCause)}}),td=_T(!0),eG=_T(!1),tG=(e)=>{if(e.interruptible=!0,e._stack.push(eG),e._interruptedCause)return Ct(e._interruptedCause)},rG=(e)=>{let t=e;if(!t.interruptible)return;t.interruptible=!1,t._stack.push(td)};var UT=(e)=>Xe((t)=>{if(t.interruptible)return e;return tG(t)??e}),rd=(e)=>Xe((t)=>{if(!t.interruptible)return e(Ee);return t.interruptible=!1,t._stack.push(td),e(UT)});var tx=(e,t)=>{if(JA(e))return t?.mode==="result"?Zo(e,Hl,t):Zo(e,Ee,t);let r=e;if(t?.discard){let n=Yr(r).map((o)=>r[o]);return t.mode==="result"?Zo(n,Hl,t):Zo(n,Ee,t)}return St(()=>Pn(Zo(Yr(r).map((n)=>[n,r[n]]),([n,o])=>Pn(t?.mode==="result"?Hl(o):o,(i)=>[n,i]),{concurrency:t?.concurrency}),Object.fromEntries))};var nd=Tn({op:"While",[Zt](e,t){if(this[Me].step(e),this[Me].while())return t._stack.push(this),this[Me].body();return Wr},[lt](e){if(this[Me].while())return e._stack.push(this),this[Me].body();return Wr}}),Zo=q((e)=>typeof e[1]==="function",(e,t,r)=>St(()=>{let n=od(r?.concurrency);if(n===1)return nG(e,t,r);let o=Gp(e),i=o.length;if(i===0)return r?.discard?yt:it([]);let s=r?.discard?void 0:Array(i),c=oG({f:t,out:s},o,{concurrency:n});return c?yc(c,s):it(s)}));var nG=(e,t,r)=>St(()=>{let n=r?.discard?void 0:[],o=e[Symbol.iterator](),i=o.next(),s=0;return yc(nd({while:()=>!i.done,body:()=>t(i.value,s++),step:(c)=>{if(n)n.push(c);i=o.next()}}),n)}),od=(e)=>e==="unbounded"?Number.POSITIVE_INFINITY:Math.max(1,e??1),mf=()=>(e)=>{let{onItem:t,step:r}=e,n=(i,s,c,l,S)=>Wt(Yp(S),(m)=>r(i,s[c],m,c)??o(i,s,c+1,l)??yt),o=(i,s,c=0,l=s.length)=>{for(;c<l;c++){let S=s[c],m=t(i,S,c);if(!mt(m))return n(i,s,c,l,m);let g=r(i,S,m,c);if(g)return g._tag==="Failure"?g:void 0}};return o},DT=(e)=>{let{onItem:t,step:r}=e;return(n,o,i)=>{let s=0,c=i.end??o.length,l=i.concurrency,S=!1,m,g,w,k,A,y=(x)=>{let z=On(x);return k=z,S=!0,g&&g.size>0?Wt(ex(Hp(Array.from(g))),()=>k??z):z},h=()=>{let x=!1;for(;!k&&s<c;s++){let z=o[s],X=A??t(n,z,s);if(mt(X)){if(k=r(n,z,X,s),k)break}else if(!m)return Gr((I)=>{m=Xl(),g=new Set,A=X,w=I;let me;try{me=h()}catch(pe){return I(y(pe))}if(me)return I(me);return St(()=>(k??=Wr,Wt(g?Hp(g):yt,()=>k?._tag==="Failure"?k:yt)))});else{A=void 0;let I=yf(m,X,!0,!0,"inherit");if(I._exit){if(k=r(n,z,I._exit,s),k)break;continue}g.add(I);let me=s;if(I.addObserver((pe)=>{g.delete(I);try{if(k){if(pe._tag==="Failure"){let K=pe.cause.reasons.filter((ee)=>ee._tag!=="Interrupt");if(K.length>0){let ee=Ho(K);k=ir(k._tag==="Failure"?Ug(kl(k.cause,ee)):ee)}}}else{let K=r(n,z,pe,me);if(K)k=K,h()}if(x){let K=h();if(K)w(K)}else if(S&&g.size===0)w(k??yt)}catch(K){w(y(K))}}),g.size<l)continue;x=!0,s++;return}}if(S=!0,k){if(g&&g.size>0){let z=mc(m);g.forEach((X)=>X.interruptUnsafe(m.id,z));return}if(w||k._tag==="Failure")return k}else if(w){if(!g)return Wr;else if(g.size===0)w(yt)}};return h()}},hf=()=>(e)=>DT(e),oG=DT({onItem(e,t,r){return e.f(t,r)},step(e,t,r,n){if(r._tag==="Failure")return r;else if(e.out)e.out[n]=r.value}});var LT=q((e)=>Ht(e[0]),(e,t)=>Xe((r)=>(gG(),it(yf(r,e,t?.startImmediately,!1,t?.uninterruptible??!1))))),yf=(e,t,r=!1,n=!1,o=!1)=>{let i=e,s=o==="inherit"?i.interruptible:!o,c=new fc(i.context,s);if(!n)i.children().add(c),c._parent=i;if(r)c.evaluate(t);else{c._asyncContext=PC();let l=!1;c.yieldWith(()=>{l=!0}),i.currentDispatcher.scheduleTask(()=>{if(l)return;c.evaluate(t)},0)}return c};var MT=(e)=>()=>Xe((t)=>t===e?yt:ef(e)),rx=q((e)=>Ht(e[0]),(e,t,r)=>Xe((n)=>{let o=t.state._tag==="Closed"?new fc(n.context):yf(n,e,r?.startImmediately,!0,r?.uninterruptible);if(!o._exit)if(t.state._tag!=="Closed")gc(t,o,MT(o)),o.addObserver(()=>Yl(t,o));else o.interruptUnsafe(n.id,mc(n));return it(o)})),FT=q((e)=>Ht(e[0]),(e,t)=>Wt(ed,(r)=>rx(e,r,t))),NT=(e,t,r)=>{let n=new fc(e,r?.uninterruptible!==!0);if(n.evaluate(t),!n._exit){let o=r?.signal;if(o)if(o.aborted)n.interruptUnsafe();else{let i=()=>n.interruptUnsafe();o.addEventListener("abort",i,{once:!0}),n.addObserver(()=>o.removeEventListener("abort",i))}r?.onFiberStart?.(n)}return n},gf=(e)=>(t,r)=>NT(r?.scheduler?dg(e,Ol,r.scheduler):e,t,r),BT=q(2,(e,t)=>{if(e._exit)return e;else if(t.state._tag==="Closed")return e.interruptUnsafe(e.id),e;return Yl(t,e),gc(t,e,MT(e)),e.addObserver(()=>Yl(t,e)),e}),KT=(e,t)=>NT(t?.scheduler?rc(new Map([[Ol,t.scheduler]])):un(),e,t);var nx=(e)=>{let t=gf(e);return(r,n)=>{let o=t(r,n);return new Promise((i)=>{o.addObserver((s)=>i(s))})}},qT=nx(un()),$T=(e)=>{let t=nx(e);return(r,n)=>t(r,n).then((o)=>{if(o._tag==="Failure")throw AC(o.cause);return o.value})},WT=$T(un()),GT=(e)=>{let t=gf(e);return(r)=>{if(mt(r))return r;let n=new jl("sync"),o=t(r,{scheduler:n});return o._dispatcher?.flush(),o._exit??On(new ox(o))}},zT=GT(un());var IC=it(!0),wC=it(!1);class jT{waiters=[];scheduled=void 0;_isOpen;constructor(e){this._isOpen=e}scheduleUnsafe(e){if(this.waiters.length===0)return IC;if(this.scheduled===void 0)this.scheduled=this.waiters,e.currentDispatcher.scheduleTask(this.flushScheduled,0);else for(let t=0;t<this.waiters.length;t++)this.scheduled.push(this.waiters[t]);return this.waiters=[],IC}flushScheduled=()=>{if(this.scheduled===void 0)return;let e=this.scheduled;this.scheduled=void 0;for(let t=0;t<e.length;t++)e[t](Wr)};flushWaiters(){let e=this.waiters;this.waiters=[],this.flushScheduled();for(let t=0;t<e.length;t++)e[t](Wr)}open=Xe((e)=>{if(this._isOpen)return wC;return this._isOpen=!0,this.scheduleUnsafe(e)});release=Xe((e)=>this._isOpen?wC:this.scheduleUnsafe(e));openUnsafe(){if(this._isOpen)return!1;return this._isOpen=!0,this.flushWaiters(),!0}await=Gr((e)=>{if(this._isOpen)return e(yt);return this.waiters.push(e),vt(()=>{let t=this.waiters.indexOf(e);if(t!==-1)this.waiters.splice(t,1);else if(this.scheduled!==void 0){if(t=this.scheduled.indexOf(e),t!==-1)this.scheduled.splice(t,1)}})});closeUnsafe(){if(!this._isOpen)return!1;return this._isOpen=!1,!0}close=vt(()=>this.closeUnsafe());whenOpen=(e)=>Wt(this.await,()=>e);isOpen(){return this._isOpen}}var QT=(e)=>new jT(e??!1);var uc=Jt("effect/Clock",{defaultValue:()=>new HT}),Ig=2147483647;class HT{currentTimeMillisUnsafe(){return Date.now()}currentTimeMillis=vt(()=>this.currentTimeMillisUnsafe());currentTimeNanosUnsafe(){return iG()}currentTimeNanos=vt(()=>this.currentTimeNanosUnsafe());monotonicTimeNanosUnsafe(){return JT()}monotonicTimeNanos=vt(()=>this.monotonicTimeNanosUnsafe());sleep(e){return this.sleepMillis(Gl(e))}sleepMillis(e){if(e<=0)return Ng;else if(!Number.isFinite(e))return tf;return Gr((t)=>{let r=e>Ig?this.sleepMillis(e-Ig):yt,n=setTimeout(()=>t(r),Math.min(e,Ig));return vt(()=>clearTimeout(n))})}}var VT=BigInt(1e6),JT=function(){let e=globalThis.process?.hrtime;if(typeof e?.bigint==="function")return()=>e.bigint();if(typeof performance<"u"&&typeof performance.now==="function")return()=>BigInt(Math.round(performance.now()*1e6));let t=BigInt(0);return()=>{let r=BigInt(Date.now())*VT;if(r>t)t=r;return t}}(),iG=function(){let e=BigInt(1e9),t;return()=>{let r=JT(),n=BigInt(Date.now())*VT;if(t===void 0)t=n-r;else{let o=t+r;if((n>o?n-o:o-n)>e)t=n-r}return t+r}}(),YT=(e)=>Xe((t)=>e(t.getRef(uc))),ZT=(e)=>YT((t)=>t.sleep(ac(e)));var Tg="~effect/Cause/AsyncFiberError";class ox extends Bp("AsyncFiberError"){[Tg]=Tg;constructor(e){super({message:"An asynchronous Effect was executed with Effect.runSync",fiber:e})}}var Og="~effect/Cause/UnknownError";class id extends Bp("UnknownError"){[Og]=Og;constructor(e,t){super({message:t,cause:e})}}var ix=Jt("effect/Console",{defaultValue:()=>globalThis.console}),sG=(e)=>{switch(e){case"All":return Number.MIN_SAFE_INTEGER;case"Fatal":return 50000;case"Error":return 40000;case"Warn":return 30000;case"Info":return 20000;case"Debug":return 1e4;case"Trace":return 0;case"None":return Number.MAX_SAFE_INTEGER}},aG=_l(Ns,sG),cG=qp(aG),XT=Jt("effect/Logger/CurrentLoggers",{defaultValue:()=>new Set([hG,yG])}),pG=Jt("effect/Logger/LogToStderr",{defaultValue:vy});var dG="~effect/Logger",uG={[dG]:{_Message:Ee,_Output:Ee},pipe(){return et(this,arguments)}},eO=(e)=>{let t=Object.create(uG);return t.log=e,t},lG=(e)=>e.replace(/[\s="]/g,"_"),fG=(e,t)=>`${lG(e[0])}=${t-e[1]}ms`;var Pg=(e)=>(...t)=>{let r=void 0;for(let n=0,o=t.length;n<o;n++){let i=t[n];if(Up(i)){if(r)t.splice(n,1);else t=t.slice(0,n).concat(t.slice(n+1));r=r?Ho(r.reasons.concat(i.reasons)):i,n--}}if(r===void 0)r=Ky;return Xe((n)=>{let o=e??n.cache.logLevel;if(cG(n.cache.minimumLogLevel,o))return yt;let i=n.getRef(uc),s=n.getRef(XT);if(s.size>0){let c=new Date(i.currentTimeMillisUnsafe());for(let l of s)l.log({cause:r,fiber:n,date:c,logLevel:o,message:t})}return yt})};var $s={bold:"1",red:"31",green:"32",yellow:"33",blue:"34",cyan:"36",white:"37",gray:"90",black:"30",bgBrightRed:"101"},UX={None:[],All:[],Trace:[$s.gray],Debug:[$s.blue],Info:[$s.green],Warn:[$s.yellow],Error:[$s.red],Fatal:[$s.bgBrightRed,$s.black]};var mG=(e)=>`${e.getHours().toString().padStart(2,"0")}:${e.getMinutes().toString().padStart(2,"0")}:${e.getSeconds().toString().padStart(2,"0")}.${e.getMilliseconds().toString().padStart(3,"0")}`;var hG=eO(({cause:e,date:t,fiber:r,logLevel:n,message:o})=>{let i=Array.isArray(o)?o.slice():[o];if(e.reasons.length>0)i.push(Lg(e));let s=t.getTime(),c=r.getRef(bg),l="";for(let w of c)l+=` ${fG(w,s)}`;let S=r.getRef(Ql);if(Object.keys(S).length>0)i.push(S);let m=r.getRef(ix);(r.getRef(pG)?m.error:m.log)(`[${mG(t)}] ${n.toUpperCase()} (#${r.id})${l}:`,...i)}),yG=eO(({cause:e,fiber:t,logLevel:r,message:n})=>{let o=t.getRef(uc),i=t.getRef(Ql),s=t.cache.span;if(s===void 0||s._tag==="ExternalSpan"||s.status._tag==="Ended")return;let c={};for(let[l,S]of Object.entries(i))Zr(c,l,S);if(c["effect.fiberId"]=t.id,c["effect.logLevel"]=r.toUpperCase(),e.reasons.length>0)c["effect.cause"]=Lg(e);s.event(rv(Array.isArray(n)&&n.length===1?n[0]:n),o.currentTimeNanosUnsafe(),c)});function gG(){kg.interruptChildren??=F2}var xG="~effect/Deferred";var SG={[xG]:{_A:Ee,_E:Ee},pipe(){return et(this,arguments)}},tO=function(){this.resumes=void 0,this.effect=void 0};tO.prototype=SG;var Ao=()=>new tO;var zr=(e)=>Gr((t)=>{if(e.effect)return t(e.effect);return e.resumes??=[],e.resumes.push(t),vt(()=>{let r=e.resumes;if(r===void 0)return;let n=r.indexOf(t);if(n>=0)r.splice(n,1)})});var bG=q(2,(e,t)=>vt(()=>Yn(e,t))),IG=bG,rO=q(2,(e,t)=>IG(e,Vn(t)));var xf=(e)=>e.effect!==void 0;var Yn=(e,t)=>{if(e.effect)return!1;if(e.effect=t,e.resumes){let r=e.resumes;e.resumes=void 0;for(let n=0;n<r.length;n++)r[n](t)}return!0};var nO=gC;var ad=Zp;var Bi=uf,Ki=AT,Sf=Xp,cd=ET;var qi=wT,en=Jg;var EG="~effect/Layer",iO="~effect/Layer/MemoMap",kG=(e,t)=>{let r={observers:0,deferred:Ao(),scope:Bi(),finalizer:(n)=>St(()=>{if(--r.observers>0)return yt;return e.map.delete(t),en(r.scope,n)})};return r},sO=(e,t)=>{if(t.state._tag==="Closed")return!1;return e.observers++,gc(t,{},e.finalizer),!0};var AG={[EG]:{_ROut:Ee,_E:Ee,_RIn:Ee},pipe(){return et(this,arguments)}},pO=(e)=>{let t=Object.create(AG);return t.build=e,t},vG=(e)=>pO((t,r)=>{let n=qi(r);return Gs(e(t,n),(o)=>o._tag==="Failure"?en(n,o):yt)}),sx=(e)=>{let t=vG((r,n)=>r.getOrElseMemoize(t,n,e));return t};class ax{get[iO](){return iO}parent;constructor(e){this.parent=e}map=new Map;get(e,t){let r=this.map.get(e);if(r)return sO(r,t),r.deferred.effect??zr(r.deferred);return this.parent?.get(e,t)}getOrElseMemoize(e,t,r){return St(()=>{let n;return xc(St(()=>{let o=this.get(e,t);if(o)return o;let i=kG(this,e);if(!sO(i,t))return r(this,t);return n=i.deferred,this.map.set(e,i),r(this,i.scope)}),(o)=>{if(n)Yn(n,o)})})}}var cx=()=>new ax,CG=(e)=>new ax(e);class pd extends Vt()("effect/Layer/CurrentMemoMap"){static forkOrCreate(e){let t=nc(e,pd);return t?CG(t):cx()}}var px=q(3,(e,t,r)=>Vp(Pn(St(()=>e.build(t,r)),ko(pd,t)),pd,t));var dO=q(2,(e,t)=>Xe((r)=>px(e,pd.forkOrCreate(r.context),t))),bc=function(){if(arguments.length===1)return(e)=>aO(Ks(arguments[0],e));return aO(Ks(arguments[0],arguments[1]))},aO=(e)=>pO(cn(it(e)));var Ic=function(){if(arguments.length===1)return(e)=>cO(arguments[0],e);return cO(arguments[0],arguments[1])},cO=(e,t)=>uO(Pn(t,(r)=>Ks(e,r))),uO=(e)=>sx((t,r)=>Ki(e,r));var lO=(e,t,r)=>{let n=qi(r,"parallel");return Zo(e,(o)=>o.build(t,qi(n,"sequential")),{concurrency:e.length}).pipe(Pn((o)=>Kv(...o)))},bf=(...e)=>sx((t,r)=>lO(e,t,r));var TG=(e,t,r)=>sx((n,o)=>Wt(Array.isArray(t)?lO(t,n,o):t.build(n,o),(i)=>e.build(n,o).pipe(ti(i),Pn((s)=>r(s,i)))));var fO=q(2,(e,t)=>TG(e,t,(r,n)=>oc(n,r)));var zs=ft,Wi=ir,_n=Vn;var Zn=Wr;var tn=sf,If=eT;var dx=Up;var wf=Za;var dd=Ho;var mO=Mp,Ef=qy;var Gi=Zl;var ud=Tl;var ld=Xa,hr=cv;var hO=id;var vee=globalThis.Number;var yO=q(2,(e,t)=>{let r=Math.pow(10,t);return Math.round(e*r)/r});var Cee=globalThis.String;var xO=(e)=>e.toLowerCase();var SO=(e)=>e.trim();var PG=/[\uD800-\uDFFF]/u;var bO=(e)=>e.isWellFormed?.()??!PG.test(e);var Xn=q(2,(e,t)=>cf(e,RG,(r)=>t(r))),ni=(e)=>e.reasons.some(ux),ux=(e)=>e._tag==="Fail"&&ud(e.error),kf=(e)=>{let t,r=!1;for(let n of e.reasons)if(ux(n))t??=n.error;else if(n._tag!=="Interrupt")r=!0;if(t===void 0)return Nt(e);return r?Nt(dd(e.reasons.filter((n)=>!ux(n)))):Xt(t)};var RG=(e)=>{let t=kf(e);return mr(t)?t:Xt(t.success.value)},lx=(e)=>{let t=kf(e);return!mr(t)?zs(t.success.value):Wi(t.failure)},wO=q(2,(e,t)=>Xo(e,{onSuccess:t.onSuccess,onFailure:(r)=>{let n=kf(r);return!mr(n)?t.onDone(n.success.value):t.onFailure(n.failure)}}));var _G=(e,t,r)=>lf((n)=>Wt(r?.local?px(t,cx(),n):dO(t,n),(o)=>ti(e,o))),EO=q((e)=>Ht(e[0]),(e,t,r)=>pg(t)?ti(e,t):_G(e,Array.isArray(t)?bf(...t):t,r));var wc=Ht,Ec=tx;var zi=Zo;var Af=nd;var js=KC,j=it,md=MC,fx=LC,Ve=St,Be=vt,Je=yt;var nn=Gr,hd=tf;var kr=$C,he=Ni,vf=NC,oi=Ct,Qs=FC,Or=hc,Pr=BC;var kc=Xe;var mx=UC;var Ae=Wt;var eo=Ws,ji=nf;var Ac=Yp,De=Pn,ar=yc;var hx=of;var yx=pT,Hs=Jp;var yd=zg,kO=mT,AO=hT;var jr=ri;var Qi=pf,Cf=Gg;var Rr=jg;var Co=Qg,vO=fT;var gx=gT,xx=xT;var Sx=ZT;var Un=VC;var gd=Vg;var bx=Xo,CO=Hg;var xd=cT,Ix=af,TO=EO,Hi=ti;var Tf=aT;var Vi=Vp;var Of=ed,Vs=Yg,OO=lf,Dn=Zg;var vc=Xg,To=CT,ii=OT;var wx=xc,Js=Gs;var PO=PT;var Sd=RT;var Pf=ex,Rf=rd;var Oo=dT;var _f=LT,bd=rx,Uf=FT;var Df=KT,Lf=gf;var RO=WT;var Ex=qT;var Ys=zT;var Ie=Bg;var _t=(e,t,r)=>(...n)=>nn((o)=>{let i=!0,s;try{e(...n,(c,l)=>{let S=c?t?Ve(()=>he(t(c,n))):he(c):j(l);if(i)s??=S;else o(S)})}catch(c){s=r?he(r(c,n)):Or(c)}if(i=!1,s)o(s)});var Mf=YC,Ff=ZC;var Qr=JC,_O=XC,UO=zC;var DO=globalThis.BigInt;var LO=(e)=>{if(e>DO(Number.MAX_SAFE_INTEGER)||e<DO(Number.MIN_SAFE_INTEGER))return ge();return Ue(Number(e))};var FO=BigInt(0),LG=BigInt(1),Po=BigInt(1000),Ji=BigInt(1024),NO=[{symbol:"B",factor:LG,names:["B","byte","bytes"]},{symbol:"kB",factor:Po,names:["kB","kilobyte","kilobytes"]},{symbol:"MB",factor:Po**BigInt(2),names:["MB","megabyte","megabytes"]},{symbol:"GB",factor:Po**BigInt(3),names:["GB","gigabyte","gigabytes"]},{symbol:"TB",factor:Po**BigInt(4),names:["TB","terabyte","terabytes"]},{symbol:"PB",factor:Po**BigInt(5),names:["PB","petabyte","petabytes"]},{symbol:"EB",factor:Po**BigInt(6),names:["EB","exabyte","exabytes"]},{symbol:"ZB",factor:Po**BigInt(7),names:["ZB","zettabyte","zettabytes"]},{symbol:"YB",factor:Po**BigInt(8),names:["YB","yottabyte","yottabytes"]},{symbol:"RB",factor:Po**BigInt(9),names:["RB","ronnabyte","ronnabytes"]},{symbol:"QB",factor:Po**BigInt(10),names:["QB","quettabyte","quettabytes"]}],MG=[NO[0],{symbol:"KiB",factor:Ji,names:["KiB","kibibyte","kibibytes"]},{symbol:"MiB",factor:Ji**BigInt(2),names:["MiB","mebibyte","mebibytes"]},{symbol:"GiB",factor:Ji**BigInt(3),names:["GiB","gibibyte","gibibytes"]},{symbol:"TiB",factor:Ji**BigInt(4),names:["TiB","tebibyte","tebibytes"]},{symbol:"PiB",factor:Ji**BigInt(5),names:["PiB","pebibyte","pebibytes"]},{symbol:"EiB",factor:Ji**BigInt(6),names:["EiB","exbibyte","exbibytes"]},{symbol:"ZiB",factor:Ji**BigInt(7),names:["ZiB","zebibyte","zebibytes"]},{symbol:"YiB",factor:Ji**BigInt(8),names:["YiB","yobibyte","yobibytes"]}],FG=[...NO,...MG.slice(1)],NG=new Map(FG.flatMap((e)=>e.names.map((t)=>[t,e])));var kx=(e)=>e;var Cc=(e)=>{throw Error(`Invalid ByteSize: ${e}`)},BO=(e)=>{if(!Number.isSafeInteger(e)||e<0)return Cc(`expected a non-negative safe integer, received ${e}`);return kx(BigInt(e))},Ere=BigInt(Number.MAX_SAFE_INTEGER),BG=(e,t)=>{let r=/^(\d+)(?:\.(\d+))?(?:e([+-]\d+))?$/.exec(e);if(r===null)return;let n=r[2]??"",o=BigInt(r[1]+n)*t,i=Number(r[3]??0)-n.length;if(i>=0)return o*BigInt(10)**BigInt(i);let s=BigInt(10)**BigInt(-i);return o%s===FO?o/s:void 0};var KG=(e)=>{let t=/^\s*(\d+(?:\.\d+)?)\s*([A-Za-z]+)\s*$/.exec(e);if(t===null)return Cc(`unsupported syntax ${JSON.stringify(e)}`);let r=NG.get(t[2]);if(r===void 0)return Cc(`unsupported unit ${JSON.stringify(t[2])}`);let n=BG(t[1],r.factor);if(n===void 0)return Cc(`${JSON.stringify(e)} does not represent an integral number of bytes`);return kx(n)};var Nf=(e)=>{switch(typeof e){case"bigint":if(e<FO)return Cc(`expected a non-negative bigint, received ${e}`);return kx(e);case"number":return BO(e);case"string":return KG(e)}return Cc(`unsupported input ${e}`)};var Ax=(e)=>typeof e==="bigint"?Nf(e):BO(e);var Bf=Vl;var Kf=ef;var KO=Xl,qO=BT;var VO=1e4,qG=4194304,$G=64,JO=(e,t)=>{let r=[],n=new Set;for(let i of e)for(let s of ez(i)){let c=r.length;if(zG(s,r))n.add(c)}let o=Ox(r,n);return{nodes:r,initial:o,dot:t,masks:r.length<=32?WG(r,o):void 0}},WG=(e,t)=>{let r=0;for(let s of t)r|=1<<s;let n=0,o=0,i=0;for(let s=0;s<e.length;s++){let c=e[s],l=1<<s;if(c._tag==="Globstar")n|=l;else if(c._tag==="End"){if(o|=l,!c.directoryOnly)i|=l}}return{initial:r,globstar:n,end:o,endFile:i}},GG=(e)=>e.startsWith("//")&&e[2]!==void 0&&e[2]!=="/",zG=(e,t)=>{if(e===""||GG(e))return!1;let r=jG(e),n=r.indexOf("**");if(n!==-1&&r.some((s,c)=>c>n&&(s==="."||s==="..")))return!1;let{directory:o,segments:i}=VG(r);if(i.length===0)return!1;for(let s of i)if(s!=="**")t.push(JG(Array.from(s)));else if(t[t.length-1]!==$O)t.push($O);return t.push({_tag:"End",directoryOnly:o}),!0},$O={_tag:"Globstar"},jG=(e)=>{let t=[],r=0;for(let n=0;n<e.length;n++)if(e[n]==="\\")n++;else if(e[n]==="/")t.push(e.slice(r,n)),r=n+1;return t.push(e.slice(r)),t},Rx=/^[A-Za-z]:/,QG=(e)=>e.length===2&&Rx.test(e),YO=(e)=>e===""||e.length===3&&e[2]==="/"&&Rx.test(e),HG=(e)=>e.startsWith("/")||e[2]==="/"&&Rx.test(e),VG=(e)=>{let t=[],r=0;if(e.length>1&&(e[0]===""||QG(e[0])))t.push(e[0]===""?"":`${e[0]}/`),r=1;let n=!1;for(;r<e.length;r++){let o=e[r];if(o===""||o===".")n=r===e.length-1&&t.length>0;else t.push(o),n=!1}if(t.length===0&&e.includes("."))t.push(".");return{segments:t,directory:n}},JG=(e)=>{let t=[],r="",n=!1,o=!0;for(let s=0;s<e.length;s++){let c=e[s];if(c==="\\"&&s+1<e.length)r+=e[++s],t.push({_tag:"Char",code:e[s].codePointAt(0)});else if(c==="*"){if(n=!0,t[t.length-1]?._tag!=="Star")t.push({_tag:"Star"})}else if(c==="?")n=!0,t.push({_tag:"Any"});else if(c==="["&&o){let l=ZO(e,s);if(l===void 0)o=!1,r+=c,t.push({_tag:"Char",code:c.codePointAt(0)});else n=!0,t.push(l.token),s=l.end}else r+=c,t.push({_tag:"Char",code:c.codePointAt(0)})}if(!n)return{_tag:"Literal",value:r};let i=t[0];return{_tag:"Wildcard",tokens:t,leadingDot:i._tag==="Char"&&i.code===46,affixes:YG(t)}},YG=(e)=>{let t="",r;for(let n of e)if(n._tag==="Star"&&r===void 0)r="";else if(n._tag==="Char"&&(n.code<55296||n.code>57343)){let o=String.fromCodePoint(n.code);if(r===void 0)t+=o;else r+=o}else return;return r===void 0?void 0:{prefix:t,suffix:r}},_r=(e,t)=>[e.codePointAt(0),t.codePointAt(0)],ZG={alnum:[..._r("0","9"),..._r("A","Z"),..._r("a","z")],alpha:[..._r("A","Z"),..._r("a","z")],blank:[9,9,32,32],cntrl:[0,31,127,127],digit:_r("0","9"),graph:[33,126],lower:_r("a","z"),print:[32,126],punct:[33,47,58,64,91,96,123,126],space:[9,13,32,32],upper:_r("A","Z"),word:[..._r("0","9"),..._r("A","Z"),95,95,..._r("a","z")],xdigit:[..._r("0","9"),..._r("A","F"),..._r("a","f")]},XG=(e,t)=>{for(let r=t+2;r<e.length&&r<=t+8;r++)if(e[r]===":"&&e[r+1]==="]"){let n=ZG[e.slice(t+2,r).join("")];return n===void 0?void 0:{ranges:n,end:r+1}}return},ZO=(e,t)=>{let r=t+1,n=e[r]==="!"||e[r]==="^";if(n)r++;let o=[];for(let i=!0;r<e.length;r++,i=!1){let s=e[r];if(s==="/")return;if(s==="]"&&!i)return{token:{_tag:"Class",ranges:o,negated:n},end:r};if(s==="["&&e[r+1]===":"){let c=XG(e,r);if(c!==void 0){o.push(...c.ranges),r=c.end;continue}}if(s==="\\"&&r+1<e.length)s=e[++r];if(e[r+1]==="-"&&r+2<e.length&&e[r+2]!=="]"){let c=r+2;if(e[c]==="/")return;if(e[c]==="\\"&&c+1<e.length)c++;o.push(..._r(s,e[c])),r=c;continue}o.push(..._r(s,s))}return},ez=(e)=>{let t=Array.from(e),r=tz(t);if(r.size===0)return[e];let n=XO(t,0,t.length,r,0);if(n===void 0)return[e];let o=eP(n);return o>VO||o*e.length>qG?[e]:tP(n)},tz=(e)=>{let t=new Map,r=[],n=!0;for(let o=0;o<e.length;o++){let i=e[o];if(i==="\\")o++;else if(i==="/")n=!0;else if(i==="["&&n){let s=ZO(e,o);if(s===void 0)n=!1;else o=s.end}else if(i==="{")r.push({open:o,commas:[]});else if(i===",")r[r.length-1]?.commas.push(o);else if(i==="}"){let s=r.pop();if(s!==void 0&&s.commas.length>0)t.set(s.open,{commas:s.commas,close:o})}}return t},XO=(e,t,r,n,o)=>{if(o>$G)return;let i=[],s="";for(let c=t;c<r;c++){let l=n.get(c);if(l===void 0){if(e[c]==="\\"&&c+1<r)s+=e[c++];s+=e[c];continue}let S=[],m=c+1;for(let g of[...l.commas,l.close]){let w=XO(e,m,g,n,o+1);if(w===void 0)return;S.push(w),m=g+1}if(s!=="")i.push(s),s="";i.push(S),c=l.close}if(s!=="")i.push(s);return i},eP=(e)=>{let t=1;for(let r of e)if(typeof r!=="string"){let n=0;for(let o of r)n+=eP(o);if(t*=n,t>VO)return 1/0}return t},tP=(e)=>{let t=[""];for(let r of e)if(typeof r==="string")t=t.map((n)=>n+r);else{let n=r.flatMap(tP);t=t.flatMap((o)=>n.map((i)=>o+i))}return t},rz=(e,t)=>{switch(e._tag){case"Char":return e.code===t;case"Any":return!0;case"Star":return!1;case"Class":{let r=!1;for(let n=0;n<e.ranges.length&&!r;n+=2)r=t>=e.ranges[n]&&t<=e.ranges[n+1];return r!==e.negated}}},WO=(e)=>e>65535?2:1,nz=(e,t,r)=>{if(t==="."||t===".."||t.startsWith(".")&&!r&&!e.leadingDot)return!1;if(e.affixes!==void 0){let{prefix:l,suffix:S}=e.affixes;return t.length>=l.length+S.length&&t.startsWith(l)&&t.endsWith(S)}let{tokens:n}=e,o=0,i=0,s=-1,c=0;while(i<t.length){if(n[o]?._tag==="Star"){s=o++,c=i;continue}let l=t.codePointAt(i);if(o<n.length&&rz(n[o],l))o++,i+=WO(l);else if(s!==-1)o=s+1,c+=WO(t.codePointAt(c)),i=c;else return!1}while(n[o]?._tag==="Star")o++;return o===n.length},Ox=(e,t)=>{for(let r of t)if(e[r]._tag==="Globstar")t.add(r+1);return t},GO=(e,t,r)=>{let n=new Set,o=new Set,i=YO(r);for(let s of t){let c=e.nodes[s];switch(c._tag){case"Globstar":{if(!i&&r!=="."&&r!==".."&&(e.dot||!r.startsWith(".")))o.add(s);break}case"Literal":{if(c.value===r)n.add(s+1);break}case"Wildcard":{if(!i&&nz(c,r,e.dot))n.add(s+1);break}}}return{explicit:Ox(e.nodes,n),globstar:Ox(e.nodes,o)}},zO=(e)=>{if(e.globstar.size===0)return e.explicit;let t=new Set(e.explicit);for(let r of e.globstar)t.add(r);return t},jO=(e,t,r)=>{for(let n of t){let o=e.nodes[n];if(o._tag==="End"&&(r||!o.directoryOnly))return!0}return!1},QO=(e,t)=>{for(let r of t)if(e.nodes[r]._tag!=="End")return!0;return!1},oz=(e,t)=>{for(let r of t){let n=e.nodes[r];if(n._tag==="End"&&n.directoryOnly)return!0}return!1};var Tx=(e,t)=>{if(e==="")return t===""?"/":t;return e.endsWith("/")?e+t:`${e}/${t}`},Px=(e)=>e.reason._tag==="NotFound"||e.reason._tag==="BadResource",qf=(e)=>Px(e)||e.reason._tag==="PermissionDenied",HO=(e)=>qf(e)||e.reason._tag==="Unknown",iz=16,sz=_l(Ov,(e)=>e.name),rP=(e)=>(t,r)=>az(e,JO([t],r?.dot??!1),r),az=Ie(function*(e,t,r){if(t.initial.size===0)return[];let n=r?.root??"",o=JO(r?.exclude??[],!0),i=o.nodes.some((h)=>h._tag==="End"&&h.directoryOnly),s=(h)=>HG(h)?h:h===""?n===""?".":n:Tx(n,h),c=(h)=>h==="."||h===".."||YO(h),l=(h,x,z)=>{let X=s(Tx(h,x));return e.stat(X).pipe(De((I)=>I.type),AO("PlatformError","NotFound",()=>e.readLink(X).pipe(ar("SymbolicLink"),Qi(HO,()=>j(void 0)))),Qi(z?Px:qf,()=>j(void 0)),De((I)=>I===void 0?void 0:{name:x,type:I}))},S=(h,x,z)=>{let X=new Set,I=!z;for(let pe of x){let K=t.nodes[pe];if(K._tag==="Literal")X.add(K.value);else if(K._tag!=="End")I=!0}let me=I?[...X].filter(c):[...X];return yx(I?Qi(e.readDirectoryEntries(s(h)),z?Px:qf,()=>j([])):j([]),zi(me,(pe)=>l(h,pe,z),{concurrency:16}),(pe,K)=>({entries:Vv([...pe,...K.filter(Yt)],sz),named:z&&!I}))},m=({name:h,type:x},z,X,I)=>{let me=GO(t,X,h),pe=zO(me);if(pe.size===0)return;let K=Tx(z,h),ee=zO(GO(o,I,h)),Q=QO(t,pe),te=(ae,se)=>{let le=jO(t,pe,ae);if(!le&&(!ae||!Q)||jO(o,ee,ae))return;return{relative:K,accepted:le,excluded:ee,next:!ae||!Q?void 0:!se||me.globstar.size===0?pe:QO(t,me.explicit)?me.explicit:void 0}};if(!Q&&!oz(t,pe)&&!i)return te(!1,!1);if(x!=="Unknown"&&x!=="SymbolicLink")return te(x==="Directory",!1);let re=s(K);return e.stat(re).pipe(De((ae)=>ae.type==="Directory"),Qi(qf,()=>j(!1)),Ae((ae)=>{let se=te(ae,x==="SymbolicLink");if(x==="SymbolicLink"||se?.next===void 0||me.globstar.size===0)return j(se);return e.readLink(re).pipe(ar(te(ae,!0)),Qi(HO,()=>j(se)))}))},g=iz,w=!1,k=Ao(),A=(h)=>h.pipe(ii((x)=>Be(()=>{if(!w)Yn(k,oi(x))})),To(Be(()=>{g++})),_f),y=Ie(function*(h,x,z,X){let I=yield*S(h,x,X),me=[],pe=[];for(let te of I.entries){let re=m(te,h,x,z);if(wc(re)){let ae=me.push(void 0)-1;pe.push(De(re,(se)=>{me[ae]=se}))}else me.push(re)}if(pe.length>0)yield*Ec(pe,{concurrency:16,discard:!0});let K=[];for(let te of me)if(te?.next!==void 0){let re=y(te.relative,te.next,te.excluded,I.named);if(g>0)g--,K.push(Bf(yield*A(re)));else K.push(j(yield*re))}let ee=[],Q=0;for(let te of me){if(te===void 0)continue;if(te.accepted)ee.push(te.relative);if(te.next!==void 0)for(let re of yield*K[Q++])ee.push(re)}return ee});return yield*Un(To(y("",t.initial,o.initial,!0),Be(()=>{w=!0})),zr(k))});var nP="~effect/PlatformError";class Id extends Yo("BadArgument"){get message(){return`${this.module}.${this.method}${this.description?`: ${this.description}`:""}`}}class oP extends hC{get message(){return`${this._tag}: ${this.module}.${this.method}${this.pathOrDescriptor!==void 0?` (${this.pathOrDescriptor})`:""}${this.description?`: ${this.description}`:""}`}}class _x extends Yo("PlatformError"){constructor(e){if("cause"in e)super({reason:e,cause:e.cause});else super({reason:e})}[nP]=nP;get message(){return this.reason.message}}var to=(e)=>new _x(new oP(e)),mn=(e)=>new _x(new Id(e));var iP=QT;var aP="~effect/MutableRef",pz={[aP]:aP,...qr,toJSON(){return{_id:"MutableRef",current:wo(this.current)}}},cP=(e)=>{let t=Object.create(pz);return t.current=e,t};var dz=Symbol.for("effect/MutableList/Empty"),uP=()=>({head:void 0,tail:void 0,length:0}),Ux=(e)=>{let t=e.head;if(t.offset>=1024&&t===e.tail&&t.mutable&&(t.array.length-t.offset)*8<=t.offset)e.head=e.tail={array:t.array.slice(t.offset),mutable:!0,offset:0,next:void 0}},dP=()=>({array:[],mutable:!0,offset:0,next:void 0}),Tc=(e,t)=>{if(!e.tail)e.head=e.tail=dP();else if(!e.tail.mutable)e.tail.next=dP(),e.tail=e.tail.next;e.tail.array.push(t),e.length++};var Yi=(e)=>{e.head=e.tail=void 0,e.length=0},lP=(e,t)=>{if(t=ic(t),t<=0||!e.head)return[];if(t=Math.min(t,e.length),t===e.length&&e.head?.offset===0&&!e.head.next){let i=e.head.array;return Yi(e),i}let r=Array(t),n=0,o=e.head;while(o){while(o.offset<o.array.length){if(r[n++]=o.array[o.offset],o.mutable)o.array[o.offset]=void 0;if(o.offset++,n===t){if(e.head=o.offset===o.array.length&&o.next?o.next:o,e.length-=t,e.length===0)Yi(e);else Ux(e);return r}}o=o.next}return Yi(e),r},fP=(e,t)=>{if(t=ic(t),t<=0||!e.head)return;if(t=Math.min(t,e.length),t===e.length&&e.head?.offset===0&&!e.head.next){Yi(e);return}let r=0,n=e.head;while(n){let o=n.array.length-n.offset;if(r+o>t){n.offset+=t-r,e.head=n,e.length-=t,Ux(e);return}r+=o,n=n.next}Yi(e);return};var Dx=(e)=>{if(!e.head)return dz;let t=e.head.array[e.head.offset];if(e.head.mutable)e.head.array[e.head.offset]=void 0;if(e.head.offset++,e.length--,e.head.offset===e.head.array.length)if(e.head.next)e.head=e.head.next;else Yi(e);else Ux(e);return t};var uz="~effect/Queue",lz="~effect/Queue/Enqueue",fz="~effect/Queue/Dequeue";var Lx={_A:Ee,_E:Ee},mz={[uz]:Lx,[lz]:Lx,[fz]:Lx,...qr,toJSON(){return{_id:"effect/Queue",state:this.state._tag,size:yz(this)}}},Zs=(e)=>Xe((t)=>{let r=Object.create(mz);return r.dispatcher=t.currentDispatcher,r.capacity=e?.capacity??Number.POSITIVE_INFINITY,r.strategy=e?.strategy??"suspend",r.messages=uP(),r.scheduleRunning=!1,r.state={_tag:"Open",takers:new Set,offers:new Set,awaiters:new Set},it(r)}),hP=(e)=>Zs({capacity:e}),yP=(e)=>Zs({capacity:e,strategy:"sliding"});var wd=q(2,(e,t)=>St(()=>Zi(e,t)?Wf:e.state._tag==="Open"&&e.strategy==="suspend"?bz(e,t):IP)),Zi=(e,t)=>{if(e.state._tag!=="Open")return!1;else if(e.messages.length>=e.capacity){if(e.capacity<=0&&e.state.takers.size>(e.strategy==="sliding"?0:e.messages.length)){if(Tc(e.messages,t),e.strategy==="sliding")fP(e.messages,e.messages.length-e.state.takers.size);return wP(e),!0}else if(e.strategy==="sliding"){if(e.capacity>0)Dx(e.messages),Tc(e.messages,t);return!0}return!1}return Tc(e.messages,t),EP(e),!0};var Oc=q(2,(e,t)=>vt(()=>Ed(e,t))),Ed=(e,t)=>{if(e.state._tag!=="Open")return!1;let r=ir(t),n=iT(r,gz);if(e.state.offers.size===0&&e.messages.length===0)return Gf(e,n),!0;return e.state={...e.state,_tag:"Closing",exit:n},EP(e),!0};var Ro=(e)=>Ed(e,Mp(Xa()));var Fx=(e)=>vt(()=>hz(e)),hz=(e)=>{if(e.state._tag==="Done")return!1;Yi(e.messages);let t=e.state.offers;Gf(e,e.state._tag==="Open"?xz:e.state.exit);for(let r of t)AP(r);return!0};var gP=(e)=>xP(e,1,Number.POSITIVE_INFINITY);var xP=q(3,(e,t,r)=>(t=ic(t),r=ic(r),Nx(()=>Sz(e,t,r)??Ws(kP(e,()=>Bx(e,t)),xP(e,t,r))))),si=(e)=>Nx(()=>bP(e)??Ws(kP(e,()=>Bx(e,1)),si(e))),SP=(e)=>Nx(()=>{let t=bP(e);if(t===void 0)return it(ge());if(t._tag==="Success")return it(Ue(t.value));return it(ge())});var bP=(e)=>{if(e.state._tag==="Done")return e.state.exit;if(e.messages.length>0){let t=Dx(e.messages);return Mx(e),ft(t)}else if(e.capacity<=0&&e.state.offers.size>0){let t=vP(e.state.offers);return Mx(e),ft(t)}return};var yz=(e)=>e.state._tag==="Done"?0:e.messages.length;var IP=ft(!1),Wf=ft(!0),gz=Vn(Xa()),xz=$g(),wP=(e)=>{if(e.state._tag==="Done"||e.state.takers.size===0)return;for(let t of e.state.takers){if(!t.ready())continue;if(e.state.takers.delete(t),t.resume(Wr),e.messages.length===0)break}},EP=(e)=>{if(e.scheduleRunning||e.state._tag==="Done"||e.state.takers.size===0)return;e.scheduleRunning=!0,e.dispatcher.scheduleTask(()=>{e.scheduleRunning=!1,wP(e)},0)},Sz=(e,t,r)=>{if(e.state._tag==="Done")return e.state.exit;else if(r<=0||t<=0)return ft([]);else if(!Bx(e,t))return;let n=e.messages.length>0?lP(e.messages,r):[vP(e.state.offers)];return Mx(e),ft(n)},Nx=Tn({op:"QueueTake",[lt](e){let t=this[Me]();return El(t)?t[lt](e):t}}),Bx=(e,t)=>e.messages.length>=(e.state._tag==="Closing"?1:Math.min(t,e.capacity||1))||e.capacity<=0&&e.state._tag!=="Done"&&e.state.offers.size>0,kP=(e,t)=>Gr((r)=>{if(e.state._tag==="Done")return r(e.state.exit);if(t())return r(Wr);let n={ready:t,resume:r};return e.state.takers.add(n),vt(()=>{if(e.state._tag!=="Done")e.state.takers.delete(n)})}),bz=(e,t)=>Gr((r)=>Zi(e,t)?r(Wf):Iz(e,{_tag:"Single",message:t,resume:r})),Iz=(e,t)=>{if(e.state._tag!=="Open")return AP(t);let r=e.state.offers;return r.add(t),vt(()=>{if(e.state._tag==="Done")return;if(r.delete(t),e.state._tag==="Closing"&&r.size===0&&e.messages.length===0)Gf(e,e.state.exit)})},AP=(e)=>e._tag==="Single"?e.resume(IP):e.resume(ft(e.remaining.slice(e.offset))),vP=(e)=>{let t=e.values().next().value;if(t._tag==="Single")return e.delete(t),t.resume(Wf),t.message;let r=t.remaining[t.offset++];if(t.offset===t.remaining.length)e.delete(t),t.resume(ft([]));return r},Mx=(e)=>{if(e.state._tag==="Done")return ni(e.state.exit.cause);else if(e.state.offers.size===0){if(e.state._tag==="Closing"&&e.messages.length===0)return Gf(e,e.state.exit,!0),ni(e.state.exit.cause);return!1}for(let t of e.state.offers){let r=e.capacity-e.messages.length;if(r<=0)break;else if(t._tag==="Single")Tc(e.messages,t.message),e.state.offers.delete(t),t.resume(Wf);else{for(;t.offset<t.remaining.length;t.offset++){if(r===0)return!1;Tc(e.messages,t.remaining[t.offset]),r--}e.state.offers.delete(t),t.resume(ft([]))}let n=e.state;if(n._tag==="Done")return ni(n.exit.cause)}return!1};var Gf=(e,t,r=!1)=>{if(e.state._tag==="Done")return;let n=e.state;if(e.state={_tag:"Done",exit:t},n.takers.size===0&&n.awaiters.size===0)return;let o=()=>{for(let i of n.takers)i.resume(t);n.takers.clear();for(let i of n.awaiters)i(t);n.awaiters.clear()};if(r)e.dispatcher.scheduleTask(o,0);else o()};var TP="~effect/Channel",CP=(e)=>He(e,TP),vz={[TP]:{_Env:Ee,_InErr:Ee,_InElem:Ee,_OutErr:Ee,_OutElem:Ee},pipe(){return et(this,arguments)}},Ar=(e)=>{let t=Object.create(vz);return t.transform=(r,n)=>jr(e(r,n),(o)=>j(oi(o))),t},Kx=(e,t)=>Ar((r,n)=>Ae(ro(e)(r,n),(o)=>t(o,n))),Pc=(e)=>Ar((t,r)=>e),OP=(e)=>Ar(Ie(function*(t,r){let n=qi(r),o=(s)=>en(n,lx(s)),i=yield*ii(e(t,r,n),o);return ii(i,o)})),ro=(e)=>e.transform;var Cz=(e,t,r)=>Zs({capacity:r?.bufferSize,strategy:r?.strategy}).pipe(ji((n)=>cd(e,Fx(n))),ji((n)=>Ki(t(n),e).pipe(jr((o)=>Oc(n,o)),bd(e,{startImmediately:!0}))));var PP=(e,t)=>Ar((r,n)=>De(Cz(n,e,t),gP)),RP=(e)=>Ar((t,r)=>Ve(()=>ro(e())(t,r)));var _P=Pc(j(hr()));var UP=(e)=>Pc(j(he(e)));var Tz=(e)=>Pc(Ae(e,()=>hr()));var qx=q(2,(e,t)=>DP(e,(r)=>j(t(r)))),DP=q(2,(e,t)=>Kx(e,(r)=>j(Xn(r,(n)=>Ae(t(n),hr)))));var LP=q(2,(e,t)=>Kx(e,(r)=>j(vO(r,(n)=>ud(n)?Je:hx(t(n))))));var $x=q((e)=>CP(e[0])&&CP(e[1]),(e,t,r)=>OP(Ie(function*(n,o,i){let s=r?.haltStrategy??"both",c=yield*hP(0);yield*cd(i,Fx(c));let l=0;function S(g,w){if(l++,!ni(w))return Oc(c,w);switch(s){case"both":return l===2?Oc(c,w):Je;case"left":case"right":return g===s?Oc(c,w):Je;case"either":return Oc(c,w)}}let m=(g,w,k)=>ro(w)(n,k).pipe(Ae((A)=>A.pipe(Ae((y)=>wd(c,y)),Oo)),ii((A)=>wx(lx(A),(y)=>en(k,y)).pipe(bx({onFailure:(y)=>S(g,y),onSuccess:()=>S(g,A)}))),bd(i,{startImmediately:!0}));return yield*m("left",e,qi(i)),yield*m("right",t,qi(i)),si(c)}))),MP=q(2,(e,t)=>$x(e,Tz(t),{haltStrategy:"left"})),FP=()=>Ar((e,t)=>Be(()=>{let r="",n=!1,o=ge();function i(l){let S=[];function m(g){if(r.length===0)S.push(g);else S.push(r+g),r=""}for(let g=0;g<l.length;g++){let w=l[g];if(w.length!==0){let k=0,A=w.indexOf("\r"),y=w.indexOf(`
26
- `);if(n){if(y===0)k=1,y=w.indexOf(`
27
- `,k);n=!1}while(A!==-1||y!==-1)if(A===-1||y!==-1&&y<A)m(w.substring(k,y)),k=y+1,y=w.indexOf(`
28
- `,k);else if(m(w.substring(k,A)),w.length===A+1)n=!0,k=w.length,A=-1;else k=A+(y===A+1?2:1),A=w.indexOf("\r",k),y=w.indexOf(`
29
- `,k);r=r+w.substring(k)}}return Di(S)?S:null}let s=Ve(()=>{if(o._tag==="Some")return hr(o.value);return wO(e,{onSuccess:c,onFailure:oi,onDone:(l)=>{if(o=Ue(l),r.length>0){let S=r;return r="",n=!1,j([S])}return hr(l)}})});function c(l){let S=i(l);return S!==null?j(S):s}return s})),NP=(e,t)=>Ar((r,n)=>Be(()=>{let o=new TextDecoder(e,t),i={stream:!0},s=r.pipe(De(ln((c)=>o.decode(c,i))),Xn((c)=>{s=hr(c);let l=o.decode();return l.length>0?j(Li(l)):s}));return Ve(()=>s)}));var Wx=q(2,(e,t)=>Ar((r,n)=>Ae(ro(e)(r,n),(o)=>ro(t)(o,n))));var BP=(e)=>e._tag==="Die"&&ud(e.defect)&&dx(e.defect.value),KP=(e)=>e.reasons.some(BP),qP=(e)=>jr(e,(t)=>ni(t)?oi(t):Or(ld(t))),Oz=(e)=>KP(e)?dd(e.reasons.flatMap((t)=>BP(t)?t.defect.value.reasons:[t])):e,$P=(e)=>jr(e,(t)=>oi(Oz(t))),zf=(e)=>Ar((t,r)=>{let n;return j(Ve(()=>{if(n)return n;return e.pipe(Ki(r),Ae((o)=>ro(o)(t,r)),Ae((o)=>n=o))}))});var WP=(e,t,r)=>Ve(()=>{let n=Bi(),o=ro(e)(hr(),n);return Xn(Ae(o,t),r?r:j).pipe(Js((i)=>en(n,i)))});var GP=(e)=>WP(e,(t)=>Oo(t,{disableYield:!0}));var Gx=q(3,(e,t,r)=>Ve(()=>{let n=t();return WP(e,(o)=>Af({while:Ti,body:()=>o,step:(i)=>{n=r(n,i)}}),()=>j(n))}));var zx=(e,t)=>ro(e)(hr(),t);var Pz="~effect/Stream",Rz={_R:Ee,_E:Ee,_A:Ee},zP=function(e){this.channel=e};zP.prototype={[Pz]:Rz,pipe(){return et(this,arguments)}};var jP=(e)=>new zP(e);var QP="~effect/Sink",HP=j([void 0]),Uz={_A:Ee,_In:Ee,_L:Ee,_E:Ee,_R:Ee},Dz={[QP]:Uz,pipe(){return et(this,arguments)}},vd=(e)=>He(e,QP),jx=(e)=>Qx((t,r)=>ro(e)(t,r).pipe(Ae(Oo({disableYield:!0})),Xn(j)));var Qx=(e)=>{let t=Object.create(Dz);return t.transform=e,t},Lz=(e)=>Ar((t,r)=>j(Ae(e.transform(t,r),hr)));var Cd=Qx((e)=>Xn(Oo(e,{disableYield:!0}),()=>HP));var VP=(e)=>Mz(zi((t)=>e(t),{discard:!0})),Mz=(e)=>Qx((t)=>t.pipe(Ae(e),Oo({disableYield:!0}),Xn(()=>HP)));var JP=(e)=>jx(zf(De(e,Lz)));var Fz="~effect/RcRef",Td={_tag:"Empty"},Nz={_tag:"Closed"},Bz={_A:Ee,_E:Ee};class ZP{[Fz]=Bz;pipe(){return et(this,arguments)}state=Td;acquire;context;scope;idleTimeToLive;constructor(e,t,r,n){this.acquire=e,this.context=t,this.scope=r,this.idleTimeToLive=n}}var XP=(e)=>kc((t)=>{let r=t.context,n=dn(r,ad),o=new ZP(e.acquire,r,n,e.idleTimeToLive!==void 0?ac(e.idleTimeToLive):void 0);return ar(Sf(n,()=>{let i=o.state;if(o.state=Nz,i._tag==="Acquired")return en(i.scope,Zn);if(i._tag==="Acquiring")return Kf(i.fiber);return Je}),o)}),Kz=(e,t)=>{switch(e.state._tag){case"Closed":return Sd;case"Acquired":{let r=e.state;return r.refCount++,r.fiber?ar(Kf(r.fiber),r):j(r)}case"Acquiring":{let r=e.state;return r.awaiters++,YP(e,r,t)}case"Empty":{let r={_tag:"Acquiring",fiber:void 0,awaiters:1,acquired:void 0};e.state=r;let n=Bi(),o=Hi(e.acquire,ko(e.context,ad,n)).pipe(Ae((i)=>{if(e.state!==r)return Sd;let s={_tag:"Acquired",value:i,scope:n,fiber:void 0,refCount:r.awaiters,invalidated:!1};return e.state=s,r.acquired=s,j(s)}),Js((i)=>{if(tn(i))return Je;if(e.state===r)e.state=Td;return en(n,i)}));return r.fiber=Lf(KO().context)(o),YP(e,r,t)}}},YP=(e,t,r)=>Js(r(Bf(t.fiber)),(n)=>{let o=t.acquired;if(o!==void 0)return If(n)?tR(e,o):Je;if(--t.awaiters>0||e.state!==t)return Je;return e.state=Td,Kf(t.fiber)}),eR=(e)=>{let t=e;return Rf((r)=>Ae(Of,(n)=>Ae(Kz(t,r),(o)=>ar(Sf(n,()=>tR(t,o)),o.value))))},tR=(e,t)=>{if(t.refCount--,t.refCount>0)return Je;let r=e.idleTimeToLive;if(r===void 0||t.invalidated){if(e.state===t)e.state=Td;return en(t.scope,Zn)}else if(!aC(r))return Je;return t.fiber=Rf((n)=>Ae(n(Sx(r)),()=>{if(e.state===t&&t.refCount===0)return e.state=Td,xx(en(t.scope,Zn),{log:"Unhandled",message:"Unhandled error in RcRef finalizer"});return Je})).pipe(To(Be(()=>{t.fiber=void 0})),Lf(e.context),qO(e.scope)),Je};var Hx=XP,Qf=eR;var Wz="~effect/Stream",Xs=(e)=>He(e,Wz);var on=jP;var nR=(e)=>on(Pc(e)),Gz=(e,t)=>on(Ar((r,n)=>Ae(zx(e.channel,n),(o)=>t(o,n))));var Vx=(e)=>e.channel,oR=(e,t)=>on(PP(e,t)),Rc=on(_P);var iR=(e)=>{let t=on(RP(()=>e().channel));return zz.set(t,e),t},zz=new WeakMap,Jx=(e)=>on(UP(e));var _o=(e)=>on(zf(De(e,Vx)));var sR=q(2,(e,t)=>jz(e,Yx(t)));var aR=q((e)=>Xs(e[0])&&Xs(e[1]),(e,t,r)=>on($x(Vx(e),Vx(t),r))),jz=q(2,(e,t)=>e.channel.pipe(MP(t),on));var cR=q(2,(e,t)=>e.channel.pipe(LP(t),on));var Hf=q(2,(e,t)=>Gz(e,(r,n)=>Be(()=>{let o,i,s=Ve(()=>{if(i!==void 0){let l=i;return i=void 0,j(l)}return r}).pipe(Hs((l)=>(o=_n(l),hr()))),c=De(Ve(()=>t.transform(s,n)),([l,S])=>(i=S,Li(l)));return Ve(()=>o?o:c)})));var pR=q((e)=>Xs(e[0]),(e,t)=>e.channel.pipe(Wx(NP(t?.encoding)),on));var dR=(e)=>e.channel.pipe(Wx(FP()),on);var uR=q(2,(e,t)=>OO((r)=>zx(e.channel,r).pipe(Ae((n)=>Qz(t,n,r)),De(([n])=>n)))),Qz=(e,t,r)=>$P(e.transform(qP(t),r)),lR=(e)=>Gx(e.channel,()=>[],(t,r)=>{for(let n=0;n<r.length;n++)t.push(r[n]);return t});var Yx=(e)=>GP(e.channel);var fR=(e)=>Gx(e.channel,()=>"",(t,r)=>t+r.join(""));var mR="~effect/FileSystem",Od=Vt("effect/FileSystem"),hR=(e)=>Od.of({...e,[mR]:mR,glob:rP(e),exists:(t)=>Oi(e.access(t),ar(!0),yd("PlatformError",(r)=>r.reason._tag==="NotFound"?j(!1):he(r))),readFileString:(t,r)=>Ae(e.readFile(t),(n)=>Pr({try:()=>new TextDecoder(r).decode(n),catch:(o)=>mn({module:"FileSystem",method:"readFileString",description:"invalid encoding",cause:o})})),stream:Ie(function*(t,r){let n=yield*e.open(t,{flag:"r"}),o=r?.offset===void 0?void 0:Nf(r.offset);if(o)yield*n.seek(o,"start");let i=r?.bytesToRead===void 0?void 0:Nf(r.bytesToRead),s=BigInt(0),c=Number(BigInt(r?.chunkSize??65536)),l=n.readAlloc(c);return nR(j(Ae(Ve(()=>{if(i!==void 0&&i<=s)return hr();return i!==void 0&&i-s<c?n.readAlloc(Number(i-s)):l}),$r({onNone:()=>hr(),onSome:(S)=>(s+=BigInt(S.length),j(Li(S)))}))))},_o),sink:(t,r)=>Oi(e.open(t,{...r,flag:r?.flag??"w"}),De((n)=>VP((o)=>n.writeAll(o))),JP),writeFileString:(t,r,n)=>Ae(Pr({try:()=>new TextEncoder().encode(r),catch:(o)=>mn({module:"FileSystem",method:"writeFileString",description:"could not encode string",cause:o})}),(o)=>e.writeFile(t,o,n))});var Vf="~effect/FileSystem/File";class Jf extends Vt()("effect/FileSystem/WatchBackend"){}var yR="~effect/Path",ta=Vt("effect/Path"),Yf=(e)=>ta.of({...e,[yR]:yR,resolveWithin(t,r){if(e.parse(r).root!=="")return ge();let n=e.resolve(t),o=e.resolve(n,r),i=e.relative(n,o);return i===".."||i.startsWith(`..${e.sep}`)||e.isAbsolute(i)?ge():Ue(o)}});function Xx(e){return e.checks?e.checks[e.checks.length-1].annotations:e.annotations}var Pd="~structural";var Zf="~sentinels",Xf="~constructor";var Rd=Pi((e)=>{let t=Xx(e)?.identifier;if(typeof t==="string")return t;return e.getExpected(Rd)});var We=Symbol.for("effect/schema/parser/missing");var vr=zs,Ln=vr(We),ai=Object.assign(vr(We),{[We]:!0}),er=(e)=>e[We]===!0,_d=(e)=>e===We?ge():Ue(e),tS=(e)=>e._tag==="None"?Ln:vr(e.value);var Md="~effect/SchemaIssue/Issue";function nS(e){return He(e,Md)&&e[Md]===Md}function Hz(e){return Object.hasOwn(e,"input")}class no{[Md]=Md;constructor(e,t){if(t?.reportInput===!0&&e!==We)this.input=e}}var xR=class extends no{_tag="Filter";filter;issue;constructor(e,t,r,n){super(r,n);this.filter=e,this.issue=t}},SR=class extends no{_tag="Encoding";ast;issue;constructor(e,t,r,n){super(r,n);this.ast=e,this.issue=t}},ci=class extends no{_tag="Pointer";path;issue;constructor(e,t){super();this.path=e,this.issue=t}},Fd=class extends no{_tag="MissingKey";annotations;constructor(e){super();this.annotations=e}},oS=class extends no{_tag="UnexpectedKey";ast;constructor(e,t,r){super(t,r);this.ast=e}},Ur=class extends no{_tag="Composite";ast;issues;constructor(e,t,r,n){super(r,n);this.ast=e,this.issues=t}},oo=class extends no{_tag="InvalidType";ast;constructor(e,t,r){super(t,r);this.ast=e}},Hr=class extends no{_tag="InvalidValue";annotations;constructor(e,t,r){super(t,r);this.annotations=e}};var Nd=class extends no{_tag="AnyOf";ast;issues;constructor(e,t,r,n){super(r,n);this.ast=e,this.issues=t}},bR=class extends no{_tag="OneOf";ast;successes;constructor(e,t,r,n){super(r,n);this.ast=e,this.successes=t}};function rS(e,t,r){if(nS(e))return e;if(typeof e==="string")return new Hr({message:e},t,r);let n=typeof e.issue==="string"?new Hr({message:e.issue},t,r):e.issue;return new ci(e.path,n)}function IR(e,t,r){if(e===void 0)return;if(typeof e==="boolean")return e?void 0:new Hr(void 0,t,r);return rS(e,t,r)}function wR(e,t,r,n){if(Array.isArray(t)){if(!Di(t))return;return t.length===1?rS(t[0],r,n):new Ur(e,ln(t,(o)=>rS(o,r,n)),r,n)}return IR(t,r,n)}var ER=(e)=>{let t=Uc(e);if(t!==void 0)return t;switch(e._tag){case"InvalidType":return _c(Rd(e.ast),e);case"InvalidValue":{let r=AR(e);if(r!==void 0)return _c(r,e);let n=em(e);return n===void 0?"Expected a valid value":`Invalid data ${n}`}case"MissingKey":return"Missing key";case"UnexpectedKey":{let r=em(e);return r===void 0?"Expected no excess property":`Unexpected key with value ${r}`}case"Forbidden":return"Forbidden operation";case"OneOf":{let r=em(e);return r===void 0?"Expected exactly one member to match":`Expected exactly one member to match the input ${r}`}}},kR=(e)=>Uc(e)??Uc(e.issue);function Vz(e){return(t)=>({issues:Dd(t,[],e?.leafHook??ER,e?.checkHook??kR)})}function em(e){return Hz(e)?rt(e.input):void 0}function AR(e){let t=e.annotations?.expected;return typeof t==="string"?t:void 0}function _c(e,t){let r=em(t);return r===void 0?`Expected ${e}`:`Expected ${e}, got ${r}`}function vR(e,t){let r=t(e);if(r!==void 0||e.issue._tag!=="InvalidValue")return r;let n=AR(e.issue);return n===void 0?_c(CR(e.filter),e):_c(n,e.issue)}function Dd(e,t,r,n,o){switch(e._tag){case"Filter":return Dd(e.issue,t,r,n,o??vR(e,n));case"Encoding":return Dd(e.issue,t,r,n,o);case"Pointer":return Dd(e.issue,[...t,...e.path],r,n,o);case"Composite":case"AnyOf":{if(e._tag==="Composite"||e.issues.length>0)return e.issues.flatMap((i)=>Dd(i,t,r,n,o));return[{path:t,message:o??Uc(e)??_c(Rd(e.ast),e)}]}default:return[{path:t,message:o??r(e)}]}}function CR(e){let t=e.annotations?.expected;if(typeof t==="string")return t;switch(e._tag){case"Filter":return"<filter>";case"FilterGroup":return e.checks.map((r)=>CR(r)).join(" & ")}}function Jz(){return(e)=>Ld(e,"")}var TR=Jz();function Ld(e,t,r){let n;switch(e._tag){case"Filter":return Ld(e.issue,t,r??vR(e,kR));case"Encoding":return Ld(e.issue,t,r);case"Pointer":return Ld(e.issue,t+ev(e.path),r);case"Composite":case"AnyOf":{if(e._tag==="Composite"||e.issues.length>0)return e.issues.map((o)=>Ld(o,t,r)).join(`
30
- `);n=r??Uc(e)??_c(Rd(e.ast),e);break}default:n=r??ER(e);break}return t?`${n}
31
- at ${t}`:n}function Uc(e){if(e._tag==="Pointer"||e._tag==="Composite")return;if(e._tag==="Encoding")return Uc(e.issue);let r=(e._tag==="Filter"?e.filter.annotations:("annotations"in e)?e.annotations:e.ast.annotations)?.[e._tag==="MissingKey"?"messageMissingKey":e._tag==="UnexpectedKey"?"messageUnexpectedKey":"message"];if(typeof r==="string")return r}function Bd(e){let t;for(let r of e.reasons){if(!wf(r)||!nS(r.error))return;t??=r.error}return t}function ra(e,t){let r=Bd(e);if(r===void 0)throw Error(t,{cause:e});return r}var PR=(e,t,r)=>{if(e.length<128)return;let n=Uint8Array;if(typeof n.fromBase64!=="function"){let o=RR();if(o===void 0)return;let i=r?.alphabet??"base64",s=new Uint8Array(t),c=o.from(s.buffer),l=r!==void 0&&e.endsWith("=")?e.slice(0,e.indexOf("=")):e;return c.write(e,i)===t&&c.toString(i)===l?s:null}try{let o=n.fromBase64(e,r);return o.length===t?o:null}catch{return null}},iS=Object.getPrototypeOf(Uint8Array.prototype),Yz=Object.getOwnPropertyDescriptor(iS,"buffer").get,Zz=Object.getOwnPropertyDescriptor(iS,"byteOffset").get,Xz=Object.getOwnPropertyDescriptor(iS,"byteLength").get,RR=()=>{let e=globalThis;return typeof e.process?.versions?.node==="string"&&typeof e.Buffer==="function"?e.Buffer:void 0},_R=(e,t)=>{let r=RR();if(r===void 0)return;let n=Xz.call(e);if(n<32)return;return r.from(Yz.call(e),Zz.call(e),n).toString(t)},UR=(e)=>e.indexOf(`
32
- `)===-1&&e.indexOf("\r")===-1?e:e.replace(/[\n\r]/g,"");var rm=(e)=>tj(typeof e==="string"?LR.encode(e):e),nm=(e)=>{let t=UR(e),r=t.length;if(r%4!==0)return Nt(new pc({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 Nt(new pc({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=PR(t,i,void 0);if(s)return Xt(s);if(s===null){let c=ij.exec(t);if(c!==null)return Nt(new pc({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=tm(t.charCodeAt(l))<<18|tm(t.charCodeAt(l+1))<<12|tm(t.charCodeAt(l+2))<<6|tm(t.charCodeAt(l+3));c[S]=m>>16,c[S+1]=m>>8&255,c[S+2]=m&255}return Xt(c)}catch(c){return Nt(new pc({kind:"Decode",module:"Base64",input:t,message:c instanceof Error?c.message:"Invalid input"}))}};var tj=(e)=>{let t=e.length,r=Uint8Array.prototype.toBase64;if(t>=32){if(typeof r==="function")return r.call(e);let n=_R(e,"base64");if(n!==void 0)return n}return t<128?rj(e):nj(e)},rj=(e)=>{let t=e.length,r="",n;for(n=2;n<t;n+=3)r+=Mn[e[n-2]>>2],r+=Mn[(e[n-2]&3)<<4|e[n-1]>>4],r+=Mn[(e[n-1]&15)<<2|e[n]>>6],r+=Mn[e[n]&63];if(n===t+1)r+=Mn[e[n-2]>>2],r+=Mn[(e[n-2]&3)<<4],r+="==";if(n===t)r+=Mn[e[n-2]>>2],r+=Mn[(e[n-2]&3)<<4|e[n-1]>>4],r+=Mn[(e[n-1]&15)<<2],r+="=";return r},nj=(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]=di[e[n-2]>>2],r[o+1]=di[(e[n-2]&3)<<4|e[n-1]>>4],r[o+2]=di[(e[n-1]&15)<<2|e[n]>>6],r[o+3]=di[e[n]&63];if(n===t+1)r[o]=di[e[n-2]>>2],r[o+1]=di[(e[n-2]&3)<<4],r[o+2]=sS,r[o+3]=sS;if(n===t)r[o]=di[e[n-2]>>2],r[o+1]=di[(e[n-2]&3)<<4|e[n-1]>>4],r[o+2]=di[(e[n-1]&15)<<2],r[o+3]=sS;return oj.decode(r)},LR=new TextEncoder,oj=new TextDecoder("utf-8",{ignoreBOM:!0}),Mn="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",di=LR.encode(Mn),sS=61,ij=/[^A-Za-z0-9+/=]/,Kd=new Uint8Array(123).fill(255);for(let e=0;e<Mn.length;e++)Kd[Mn.charCodeAt(e)]=e;Kd[61]=0;var tm=(e)=>{if(e>=Kd.length||Kd[e]===255)throw TypeError(`Invalid character ${String.fromCharCode(e)}`);return Kd[e]};var qd=(e)=>Object.assign(Object.create(Ay),e);var sj=qd({_tag:"Passthrough"});function Uo(){return sj}function Bt(e){return qd({_tag:"Transform",transform:e})}function na(e){return qd({_tag:"TransformEffect",transform:e})}function aS(e){return qd({_tag:"TransformOptional",transform:e})}function aj(e){return qd({_tag:"TransformOptionalEffect",transform:e})}function NR(){return aS(()=>ge())}function BR(e){return aj((t)=>{let r=_v(t,Yt);return O(r)?j(r):Mf(e,Ue)})}function om(){return Bt(globalThis.String)}function im(){return Bt(globalThis.Number)}function KR(){return Bt(SO)}function qR(){return Bt(xO)}function cj(e){return na((t,r)=>typeof t==="string"&&!bO(t)?he(new Hr({expected:"a well-formed Unicode string"},t,r)):j(e(t)))}function $R(){return cj(rm)}function WR(){return na((e,t)=>Ff(mx(nm(e)),()=>new Hr({expected:"a valid Base64 string"},e,t)))}var cS=class extends qa{_tag="Middleware";decode;encode;constructor(e,t){super();this.decode=e,this.encode=t}flip(){return new cS(this.encode,this.decode)}},Wd="~effect/SchemaTransformation/Transformation",cr=class extends qa{[Wd]=Wd;_tag="Transformation";decode;encode;constructor(e,t){super();this.decode=e,this.encode=t}flip(){return new cr(this.encode,this.decode)}};function uj(e){return He(e,Wd)&&e[Wd]===Wd}var pS=(e)=>{if(uj(e))return e;return new cr(e.decode,e.encode)};function sm(e){return new cr(na(e.decode),na(e.encode))}function am(e){return new cr(Bt(e.decode),Bt(e.encode))}function GR(){return new cr(KR(),Uo())}function lj(){return new cr(qR(),Uo())}var fj=new cr(Uo(),Uo());function cm(){return fj}var Gd=new cr(im(),Bt((e)=>Object.is(e,-0)?"-0":globalThis.String(e)));var mj=(e)=>HA(e)&&typeof e.message==="string",hj=(e)=>{let r=Object.hasOwn(e,"cause")?Error(e.message,{cause:zR(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},yj=(e)=>{try{let t=_s(e);return t===void 0?rt(e):JSON.parse(t)}catch{return rt(e)}},gj=(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},xj=(e)=>{let t=new WeakSet,r=(n)=>{if(VA(n)){if(t.has(n))return"[Circular]";t.add(n);let o=gj(n,e,r);return t.delete(n),o}return yj(n)};return r},zR=(e)=>mj(e)?hj(e):e;var jR=(e)=>am({decode:zR,encode:xj(e)});var QR=sm({decode:(e,t)=>URL.canParse(e)?j(new URL(e)):he(new Hr({expected:"a valid URL string"},e,t)),encode:(e)=>j(e.href)});var HR=new cr(WR(),$R());function ia(e){return(t)=>t._tag===e}var xS=ia("Declaration");var Ij=ia("Never");var Lc=ia("Literal"),uS=ia("UniqueSymbol");var i0=ia("Arrays"),s0=ia("Objects");var sa=ia("Suspend"),Lr=class{to;transformation;constructor(e,t){this.to=e,this.transformation=t}},aa={},SS=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}},VR="~effect/Schema";class Fn{[VR]=VR;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 fm(e){return e.checks===e.encodingChecks?e:yn(e,{checks:e.encodingChecks,encodingChecks:e.checks,encoding:void 0})}var Vd=class extends Fn{_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===We)return Ln;e??=this.run(this.typeParameters);try{return e(t,this,r)}catch(n){return Or(n)}}}recur(e){let t=Mc(this.typeParameters,e);return t===this.typeParameters?this:yn(this,{typeParameters:t,encoding:void 0})}flip(e){let t=fm(this.recur(e));return this.run===this.encodingRun?t:yn(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>"}},wj=class extends Fn{_tag="Null";getParser(){return US(this,null)}getExpected(){return"null"}},mm=new wj;var Ej=class extends Fn{_tag="Undefined";getParser(){return US(this,void 0)}toCodecJson(){return Dr(this,[kj])}getExpected(){return"undefined"}},kj=new Lr(mm,new cr(Bt(()=>{return}),Bt(()=>null))),bS=new Ej;var Aj=class extends Fn{_tag="Unknown";getParser(){return Zd(this,QA)}getExpected(){return"unknown"}},Qd=new Aj;var Do=class extends Fn{_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 ${rt(e)}`);this.literal=e}getParser(){return US(this,this.literal)}matchPart(e,t){return e===globalThis.String(this.literal)?this.literal:void 0}toCodecJson(){return typeof this.literal==="bigint"?JR(this):this}toCodecStringTree(){return typeof this.literal==="string"?this:JR(this)}getExpected(){return typeof this.literal==="string"?JSON.stringify(this.literal):globalThis.String(this.literal)}};function JR(e){let t=globalThis.String(e.literal);return Dr(e,[new Lr(new Do(t),new cr(Bt(()=>e.literal),Bt(()=>t)))])}var vj=class extends Fn{_tag="String";getParser(){return Zd(this,jo)}matchPart(e,t){let r=this.checks;return r&&!t.disableChecks&&ts(r,e,void 0,this,t)?void 0:e}getExpected(){return"string"}},Xi=new vj,Cj=class extends Fn{_tag="Number";getParser(){return Zd(this,Op)}matchKey(e,t){return this._match(Yj,e,t)}matchPart(e,t){return this._match(gS,e,t)}_match(e,t,r){if(!e.test(t))return;let n=globalThis.Number(t);if(r.disableChecks||!this.checks)return n;return ts(this.checks,n,void 0,this,r)?void 0:n}toCodecJson(){if(this.checks&&(lS(this.checks,"effect/schema/isFinite")||lS(this.checks,"effect/schema/isInt")))return this;return Dr(this,[Bj])}toCodecStringTree(){if(this.toCodecJson()===this)return Dr(this,[Zj]);return Dr(this,[Xj])}getExpected(){return"number"}};function lS(e,t){return e.some((r)=>r.annotations?.representation?.id===t||r._tag==="FilterGroup"&&lS(r.checks,t))}var IS=new Cj,Tj=class extends Fn{_tag="Boolean";getParser(){return Zd(this,Sl)}getExpected(){return"boolean"}},a0=new Tj;var hm=class extends Fn{_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(Lo(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(Lo(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 oS(r,g[A],k),h=new ci([A],y);if(k.errors==="all")if(m.issues)m.issues.push(h);else m.issues=[h];else return he(new Ur(r,[h],g,k))}if(m.issues)return he(new Ur(r,m.issues,g,k));return vr(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:od(g.concurrency),h=y===1?Pj(k,m,0,A):Rj(k,m,{concurrency:y,end:A});if(!h)return l(k);if(mt(h))return Qr(h,()=>l(k));let x=!0;return Ve(()=>{if(!x)return S(m,g);return x=!1,Ae(h,()=>l(k))})};return(m,g)=>{if(m===We)return Ln;try{if(!Array.isArray(m))return he(new oo(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 Or(w)}}}recur(e){let t=Mc(this.elements,e),r=Mc(this.rest,e);return t===this.elements&&r===this.rest?this:new hm(this.isMutable,t,r,this.annotations,this.checks,void 0,this.context,this.encodingChecks)}flip(e){return fm(this.recur(e))}getExpected(){return"array"}};function Oj(e,t,r,n){if(r._tag==="Failure")return um(e,e.ast,n,r);let o=er(r)?t:r[Me];if(o!==We)e.output[n]=o;else{let i=e.getParser(e.tailThreshold,n);if(Lo(i.ast))return;let s=new ci([n],new Fd(i.ast.context?.annotations));if(e.options.errors==="all")if(e.issues)e.issues.push(s);else e.issues=[s];else return _n(new Ur(e.ast,[s],e.input,e.options))}}var c0={onItem(e,t,r){let n=r<e.len?t:We;return e.getParser(e.tailThreshold,r).parser(n,e.options)},step:Oj},Pj=mf()(c0),Rj=hf()(c0),um=(e,t,r,n)=>{if(n.cause.reasons.length===0)return n;let o=Bd(n.cause);if(o===void 0)return Wi(Gi(n.cause,(s)=>new Ur(t,[new ci([r],s)],e.input,e.options)));let i=new ci([r],o);if(e.options.errors==="all")if(e.issues)e.issues.push(i);else e.issues=[i];else return _n(new Ur(t,[i],e.input,e.options))},p0="[+-]?(?:\\d+(?:\\.\\d+)?|\\.\\d+)(?:[Ee][+-]?\\d+)?";function dS(e,t,r=aa){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(DS(li(t)))}var wS=class{name;type;constructor(e,t){this.name=e,this.type=t}};function d0(e){switch(e._tag){case"String":case"Number":case"Symbol":case"TemplateLiteral":return!0;case"Union":return e.types.every(d0);default:return!1}}function u0(e){let t=CS(e);switch(t._tag){case"String":case"Number":case"Symbol":case"TemplateLiteral":return!0;case"Union":return t.types.every(u0);default:return!1}}function _j(e){return d0(e)&&u0(e)}var l0=class{parameter;type;constructor(e,t){if(!_j(e))throw Error(`Invalid index signature parameter ${e._tag}`);if(this.parameter=e,this.type=t,Lo(t)||t.encoding!==void 0&&Lo(li(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.")}},ES=class extends Fn{_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 Zd(r,My);let i,s,c=()=>{if(!i)i=r.propertySignatures.map((g)=>({parser:t(g.type),name:g.name,type:g.type,ownOnly:y0(g.name)})),s=o?r.indexSignatures.map((g)=>({is:g,parserKey:e(DS(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,z,X,I)=>{if(I._tag==="Failure")return um(h,r,x,I)??Zn;let me=er(I)?X:I[Me];if(z!==We&&me!==We){if(n&&(g.has(x)||g.has(typeof z==="number"?globalThis.String(z):z)))return Zn;Zr(h.out,z,me)}return Zn},k=(h,x,z,X)=>{if(!X){let K=z.parserKey(x,h.options);if(!mt(K))return Ae(Ac(K),(ee)=>k(h,x,z,ee));X=K}if(X._tag==="Failure")return um(h,r,x,X)??Zn;let I=er(X)?x:X[Me],me=h.input[x],pe=z.parserValue(me,h.options);return mt(pe)?w(h,x,I,me,pe):Ae(Ac(pe),(K)=>w(h,x,I,me,K))},A=(h,x,z)=>{let X=h.input[x],I=z.parserValue(X,h.options);return mt(I)?w(h,x,x,X,I):Ae(Ac(I),(me)=>w(h,x,x,X,me))},y=o?hf()({onItem:(h,[x,z])=>z.is.parameter===Xi?A(h,x,z):k(h,x,z),step:(h,x,z)=>z._tag==="Failure"?z:void 0}):void 0;return UO(function*(h,x){if(h===We)return We;if(!(typeof h==="object"&&h!==null&&!Array.isArray(h)))return yield*he(new oo(r,h,x));c();let z=h,X={},I={ast:r,input:z,out:X,issues:void 0,options:x},me=x.errors==="all",pe=x.onExcessProperty==="error",K=x.concurrency===void 0?1:od(x.concurrency),ee=o&&pe?r.indexSignatures.map((Q)=>dS(z,Q.parameter,x)):void 0;if(pe){let Q=ee?new Set(g):g;if(ee)for(let re of ee)for(let ae of re)Q.add(ae);let te=Yr(z);for(let re=0;re<te.length;re++){let ae=te[re];if(!Q.has(ae)){let se=new oS(r,z[ae],x),le=new ci([ae],se);if(me){if(I.issues)I.issues.push(le);else I.issues=[le];continue}else return yield*he(new Ur(r,[le],h,x))}}}if(n){let Q=K===1?YR(I,i):Uj(I,i,{concurrency:K});if(Q)yield*Q}if(o&&K===1)for(let Q=0;Q<o;Q++){let te=s[Q],re=te.is.parameter===Xi?A:k,ae=ee?.[Q]??(te.is.parameter===Xi?Object.keys(z):dS(z,te.is.parameter,x));for(let se=0;se<ae.length;se++){let le=re(I,ae[se],te);if(!mt(le))yield*le;else if(le._tag==="Failure")return yield*le}}else if(y){let Q=qs();for(let re=0;re<o;re++){let ae=s[re],se=ee?.[re]??(ae.is.parameter===Xi?Object.keys(z):dS(z,ae.is.parameter,x));for(let le=0;le<se.length;le++)Q.push([se[le],ae])}let te=y(I,Q,{concurrency:K});if(te)yield*te}if(I.issues)return yield*he(new Ur(r,I.issues,h,x));return X})};if(o)return l();let S,m=(g,w,k)=>{let A=i[w];return Ae(Ac(k),(y)=>{let h={...g,out:{...g.out}},x=fS(h,A,y);if(x)return x;let z=()=>vr(h.out),X=YR(h,i.slice(w+1));return X?Qr(X,z):z()})};return(g,w)=>{if(g===We)return Ln;if(w.errors==="all"||w.onExcessProperty!==void 0||w.concurrency!==void 0&&od(w.concurrency)!==1)return(S??=l())(g,w);if(!(typeof g==="object"&&g!==null&&!Array.isArray(g)))return he(new oo(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 z=k[x],X=z.name,I=z.ownOnly?Object.hasOwn(A,X):(X in A),me=I?A[X]:We,pe=z.parser(me,w);if(!mt(pe))return m(h,x,pe);if(er(pe)){if(I)Zr(y,X,me);continue}let K=fS(h,z,pe);if(K)return K}}catch(x){return Or(x)}return vr(y)}}recur(e,t=e){let r=Mc(this.propertySignatures,(o)=>{let i=e(o.type);return i===o.type?o:new wS(o.name,i)}),n=Mc(this.indexSignatures,(o)=>{let i=t(o.parameter),s=e(o.type);return i===o.parameter&&s===o.type?o:new l0(i,s)});return r===this.propertySignatures&&n===this.indexSignatures?this:yn(this,{propertySignatures:r,indexSignatures:n,encoding:void 0})}flip(e){return fm(this.recur(e))}getExpected(){if(this.propertySignatures.length===0&&this.indexSignatures.length===0)return"object | array";return"object"}};function fS(e,t,r){if(r._tag==="Failure")return um(e,e.ast,t.name,r);if(er(r))return;let n=r[Me];if(n!==We){Zr(e.out,t.name,n);return}if(delete e.out[t.name],!Lo(t.type)){let o=new ci([t.name],new Fd(t.type.context?.annotations));if(e.options.errors==="all"){if(e.issues)e.issues.push(o);else e.issues=[o];return}else return _n(new Ur(e.ast,[o],e.input,e.options))}}var f0={onItem(e,t){if(!(t.ownOnly?Object.hasOwn(e.input,t.name):(t.name in e.input)))return t.parser(We,e.options);let r=e.input[t.name];return Zr(e.out,t.name,r),t.parser(r,e.options)},step:fS},YR=mf()(f0),Uj=hf()(f0);function kS(e,t){if(!e)return t;if(!t)return e;return[...e,...t]}function ym(e,t,r){return new ES(Yr(e).map((n)=>new wS(n,e[n].ast)),[],r,t)}function gm(e){return e.ast}function xm(e,t,r){return new es(e.map(gm),t,void 0,r)}function m0(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=kS(o,i.checks)}return new ES(r,n,void 0,o)}var AS=wp((e)=>{while(!0){if(sa(e))return Qd;let t=e.encoding;if(!t)return e.recur?.(AS,Ee)??e;if(t.some((r)=>r.transformation._tag==="Middleware"&&r.transformation.decode!==Ee))return Qd;e=t[t.length-1].to}});function h0(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(h0)));default:return["null","undefined","string","number","boolean","symbol","bigint","object","array","function"]}}function Hd(e){switch(e._tag){default:return[];case"Declaration":{let t=e.annotations?.[Zf];return Array.isArray(t)?t:[]}case"Objects":return e.propertySignatures.flatMap((t)=>{let r=t.type;if(!Lo(r)){if(Lc(r))return[{key:t.name,literal:r.literal}];if(uS(r))return[{key:t.name,literal:r.symbol}]}return[]});case"Arrays":return e.elements.flatMap((t,r)=>{if(!Lo(t)){if(Lc(t))return[{key:r,literal:t.literal}];if(uS(t))return[{key:r,literal:t.symbol}]}return[]});case"Union":{if(e.types.length===0)return[];let t=e.types.map((r)=>Hd(AS(r)));return t[0].filter((r)=>t.every((n)=>n.some((o)=>o.key===r.key&&o.literal===r.literal)))}case"Suspend":return Hd(e.thunk())}}var ZR=new WeakMap,pm=Object.freeze([]),XR=(e)=>e===null?"null":Array.isArray(e)?"array":typeof e,Dj=new Set(Reflect.ownKeys(Object.prototype)).add("__proto__"),y0=(e)=>Dj.has(typeof e==="number"?globalThis.String(e):e),dm=(e,t)=>Object.hasOwn(e,t)||(t in e)&&!y0(t);function Lj(e){let t=ZR.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=AS(g);if(Ij(w))continue;if(Lc(w)||uS(w)){i??=new Map;let A=Lc(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=Hd(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=h0(w);for(let y of A)(o[y]??=[]).push(m)}}let l={},S=(m)=>l[m]??=Object.freeze(o?.[m]??pm);if(s&&i)i.forEach(Object.freeze),t=(m)=>i.get(m)??pm;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(Pp(A)){let h=dm(A,m)?A[m]:void 0;if(h!==void 0)return w.get(h)??pm;if(y)return k}return pm}}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=XR(g);if(!Pp(g))return S(k);let A=new Set(o?.[k]),y;if(m){let[h,[x]]=m,z=dm(g,h),X=z?g[h]:void 0;if(z&&(!w||X!==void 0)){let I=x.get(X);if(!I)return S(k);for(let me of I)A.add(me);y=h}}if(y===void 0)for(let[h,[x,z]]of r){let X=dm(g,h),I=X?g[h]:void 0;if(X&&(!w||I!==void 0)){let me=x.get(I);if(me)for(let pe of me)A.add(pe)}else if(w)for(let me of z)A.add(me)}for(let[h,[x,z]]of r){if(h===y)continue;let X=dm(g,h),I=X?g[h]:void 0;if(X&&(!w||I!==void 0)){let me=x.get(I);for(let pe of A)if(z.has(pe)&&!me?.has(pe))A.delete(pe)}}return Array.from(A).sort((h,x)=>h-x)}}else t=(m)=>{let g=S(XR(m));return i?g.filter((w)=>c[w]===void 0||c[w]===m):g};return ZR.set(e,t),t}var es=class extends Fn{_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===We)return Ln;let S=(s??=Lj(r.types))(c,n);if(S.length===0)return he(new Nd(r,[],c,l));if(S.length===1){let m=i(S[0])(c,l);if(m._tag==="Success")return m;return mt(m)?g0(r,m.cause,c,l):Mj(r,m,c,l)}return x0(r,i,S,c,l)}}recur(e){let t=Mc(this.types,e);return t===this.types?this:yn(this,{types:t,encoding:void 0})}flip(e){return fm(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=li(n);switch(o._tag){case"Arrays":{let i=o.elements.filter(Lc);if(i.length>0)return`${t0(o.isMutable)}[ ${i.map((s)=>e(s)+r0(s.context?.isOptional)).join(", ")}, ... ]`;break}case"Objects":{let i=o.propertySignatures.filter((s)=>Lc(s.type));if(i.length>0)return`{ ${i.map((s)=>`${t0(s.type.context?.isMutable)}${Ha(s.name)}${r0(s.type.context?.isOptional)}: ${e(s.type)}`).join(", ")}, ... }`;break}}return e(o)});return Array.from(new Set(r)).join(" | ")}};function g0(e,t,r,n){let o=Bd(t);if(!o)return Wi(t);return _n(new Nd(e,[o],r,n))}function Mj(e,t,r,n){return jr(t,(o)=>g0(e,o,r,n))}function x0(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=Fj(i,r);if(!s){if(i.out)return i.out;return he(new Nd(e,i.issues??[],n,o))}if(mt(s))return e0(s,i);let c=!0;return Ve(()=>{if(!c)return x0(e,t,r,n,o);return c=!1,e0(s,i)})}function e0(e,t){return Qr(e,(r)=>{if(t.out)return er(t.out)?j(t.input):t.out;return he(new Nd(t.ast,t.issues??[],t.input,t.options))})}var Fj=mf()({onItem(e,t){return e.parser(t)(e.input,e.options)},step(e,t,r){if(r._tag==="Failure"){let n=Bd(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]),_n(new bR(e.ast,e.successes,e.input,e.options));if(e.out=r,e.successes)e.successes.push(e.ast.types[t]);else return Zn}}}),S0=new es([new Do("Infinity"),new Do("-Infinity"),new Do("NaN")]);function t0(e){return e?"":"readonly "}function r0(e){return e?"?":""}function Nj(e){let t;return()=>t??=e()}var mS=class extends qa{_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 mS(this.run,{...this.annotations,...e},this.aborted)}abort(){return new mS(this.run,this.annotations,!0)}and(e,t){return new lm([this,e],t)}},lm=class extends qa{_tag="FilterGroup";checks;annotations;constructor(e,t=void 0){super();this.checks=e,this.annotations=t}annotate(e){return new lm(this.checks,{...this.annotations,...e})}and(e,t){return new lm([this,e],t)}};function Sm(e,t,r=!1){return new mS((n,o,i)=>wR(o,e(n,o,i),n,i),t,r)}function b0(e){return Sm((t)=>globalThis.Number.isFinite(t),{expected:"a finite number",representation:{id:"effect/schema/isFinite",payload:null},toJsonSchema:()=>({type:"number"}),arbitraryConstraint:{number:"finite"},...e})}var I0=ca(IS,[b0()]),Bj=new Lr(new es([I0,S0]),new cr(im(),Bt((e)=>globalThis.Number.isFinite(e)?e:globalThis.String(e))));function vS(e,t){let r=new globalThis.RegExp(e),n={source:r.source,flags:r.flags};return Sm((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 hS=new WeakMap;function yn(e,t){return Object.assign(Object.create(Object.getPrototypeOf(e)),e,t)}function w0(e,t){let r=yn(e,t);return hS.set(r,Jd(e)),r}function Jd(e){let t=hS.get(e);if(t!==void 0)return t;if(e.encoding===void 0)return e;let r=yn(e,{encoding:void 0});return hS.set(e,r),r}function Dr(e,t){return e.encoding===t?e:w0(e,{encoding:t})}function Fc(e,t){if(e.context===t)return e;let r=Jd(e);if(r.context===t&&r.encoding===e.encoding)return r;return w0(e,{context:t})}function CS(e){return e.encoding?CS(e.encoding[e.encoding.length-1].to):e}function bm(e,t){if(e.checks)return TS(e,E0(e.checks,(r)=>r.annotate(t)));return yn(e,{annotations:{...e.annotations,...t}})}function TS(e,t){if(e._tag==="Suspend"&&t)throw Error("Cannot add checks to Suspend");if(e.checks===t)return e;return yn(e,{checks:t})}function ca(e,t){return TS(e,kS(e.checks,t))}function Im(e,t){let r=t(e.to);return r===e.to?e:new Lr(r,e.transformation)}function E0(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 k0(e,t){return E0(e,(r)=>Im(r,t))}function A0(e){return(t)=>t.encoding?Dr(t,k0(t.encoding,e)):t}function v0(e,t){return A0((r)=>Fc(r,t))(e)}function wm(e,t){function r(n){if(n.encoding){let o=n.encoding[n.encoding.length-1];return t?.stopAt?.(o)?n:Dr(n,k0(n.encoding,r))}return e(n)}return wp(r)}function C0(e,t){return T0(e,t,ui(e))}function T0(e,t,r){let n=new Lr(e,t);return Dr(r,r.encoding?[...r.encoding,n]:[n])}function Mc(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 OS(e,t=Lo(e),r=$j(e),n=e.context?.constructorDefault,o=e.context?.annotations){return Fc(e,new SS(t,r,n,o))}function Kj(e){let t=e==="isOptional"?!0:void 0,r=e==="isMutable"?!0:void 0,n=wp((i)=>o(i.context?.[e]?i:OS(i,t,r))),o=A0(n);return n}function Em(e,t){return OS(e,void 0,void 0,void 0,e.context?{...e.context.annotations,...t}:t)}var km=Kj("isOptional"),O0=Pi((e)=>km(new es([e,bS])));function P0(e,t){return OS(e,void 0,void 0,t)}function PS(e,t,r){return T0(e,r,t)}function qj(e){let t=[],r=[];function n(i){if(!t.includes(i))t.push(i)}function o(i){switch(i._tag){case"Literal":if(Ly(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 RS(e,t){let{literals:r,parameters:n}=qj(e);return new ES(r.map((o)=>new wS(o,t)),n.map((o)=>new l0(o,t)))}function Lo(e){return e.context?.isOptional??!1}function $j(e){return e.context?.isMutable??!1}function _S(e){return e.annotations?.[Pd]===!0||e._tag==="FilterGroup"&&e.checks.every(_S)}function Wj(e){function t(n){if(_S(n))return[n];return n._tag==="FilterGroup"?n.checks.flatMap(t):[]}let r=e.flatMap(t);return Kl(r)?r:void 0}function R0(e,t,r){let n=new Set([e]);for(let i of n){if(r?.has(i))continue;if(!t(i))return!1;if(!sa(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 Gj=new WeakSet;function _0(e,t){let r=i0(e)||s0(e)||xS(e)&&e.typeParameters.length>0;if(r&&t.every(_S)||R0(e,(n)=>!n.encoding&&!sa(n),Gj))return t;if(r)return Wj(t)}function U0(e){return xS(e)&&e.encodingRun!==void 0&&e.encodingRun!==e.run}function zj(e,t){function r(n){if(sa(n))return n.thunk===t;return!U0(n)&&!(("encodingChecks"in n)&&n.checks&&_0(n,n.checks)!==n.checks)}return R0(e,r)}var jd=new WeakMap,Dc=new WeakMap,n0=new WeakSet,o0=new WeakSet,Yd=new WeakMap,yS=new WeakMap,ui=(e)=>Yd.has(e)?jj(e):oa(e),jj=Pi((e)=>{let t=Yd.get(e);if(t&&n0.has(t))return t;let r=oa(e);if(t)n0.add(r);return r});function oa(e){let t=jd.get(e);if(t)return t;let r=Yd.get(e),n=r&&jd.get(r)===r,o=r&&Dc.get(r)||Qj(e);if(n)Dc.set(r,o);if(jd.set(e,o),o!==e)jd.set(o,o);return o}function D0(e,t){let r=Jd(e);if(r!==e){let n=t(r);return n===r&&!e.encoding?e:Fc(n,e.context)}}function Qj(e){let t=D0(e,oa);if(t)return t;if(sa(e))return yS.get(e.thunk)?.project(e)??e.recur(oa);let r="recur"in e?e.recur(oa):e;if("encodingChecks"in r&&r.encodingChecks)return yn(r,{encodingChecks:void 0,checks:kS(_0(e,r.encodingChecks),r.checks)});return r===e&&U0(r)&&Yd.has(e)?yn(r,{}):r}var li=(e)=>ui(hn(e));function Hj(e,t){let r=Dr(e,void 0),n=t.map((i)=>{let s=new Lr(hn(r),i.transformation.flip());return r=i.to,s}).reverse(),o=hn(r);return Dr(o,o.encoding?[...o.encoding,...n]:n)}var hn=Pi((e)=>{let t=Vj(e);if(t!==e)Yd.set(t,e);return t});function Vj(e){if(e.encoding)return Hj(e,e.encoding);let t=D0(e,hn);if(t)return t;if(sa(e)){let r=yS.get(e.thunk);if(r)return yn(e,{thunk:r.source.thunk});let n=e.recur(hn);return yS.set(n.thunk,{source:e,project(o){let i=Nj(()=>Jj(e.thunk(),i));return yn(o,{thunk:i})}}),n}return"flip"in e?e.flip(hn):e}function Jj(e,t){if(jd.get(e)!==e)return oa(hn(e));let r=Dc.get(e);if(r)return r;if(zj(e,t))return Dc.set(e,e),e;let n=oa(hn(e));if(o0.has(e)&&!Dc.has(n))Dc.set(n,e);return o0.add(n),n}function US(e,t){let r=t===0?ai:vr(t);return(n,o)=>{if(n===We)return Ln;if(n===t)return r;return he(new oo(e,n,o))}}function Zd(e,t){return(r,n)=>{if(r===We)return Ln;if(t(r))return ai;return he(new oo(e,r,n))}}var DS=wm((e)=>{switch(e._tag){default:return e;case"Number":return e.toCodecStringTree();case"Union":return e.recur(DS)}}),LS=wm((e)=>{switch(e._tag){default:return e;case"Symbol":case"UniqueSymbol":return e.toCodecStringTree();case"Union":return e.recur(LS)}});var gS=new globalThis.RegExp(`^${p0}$`),Yj=new globalThis.RegExp(`^(?:${p0}|Infinity|-Infinity|NaN)$`);function L0(e){return vS(gS,{expected:"a string representing a finite number",representation:{id:"effect/schema/isStringFinite",payload:null},toJsonSchema:()=>({pattern:gS.source}),...e})}var M0=ca(Xi,[L0()]),Zj=new Lr(M0,Gd),Xj=new Lr(new es([M0,S0]),Gd),eQ="-?\\d+",ese=new globalThis.RegExp(`^${eQ}$`);var tQ="Symbol\\(([\\s\\S]*)\\)",tse=new globalThis.RegExp(`^${tQ}$`);function ts(e,t,r,n,o){for(let i=0;i<e.length;i++){let s=e[i];if(s._tag==="FilterGroup"){if(r=ts(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 xR(s,c,t,o);if(r)r.push(l);else r=[l];if(o.errors!=="all"||s.aborted)return r}}}return r}function Am(e){if(!xS(e))return;let t=e.annotations?.[Xf];return bo(t)?t(e.typeParameters):void 0}function rQ(e){return e===null||typeof e==="string"||typeof e==="boolean"||typeof e==="number"&&globalThis.Number.isFinite(e)}function nQ(e){return e===void 0||typeof e==="string"}function F0(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 oQ(e){return F0(e,rQ)}var N0=new Vd([],()=>(e,t,r)=>oQ(e)?ai:he(new oo(t,e,r)),{representation:{id:"effect/schema/Json",payload:null},expected:"JSON value",toCodecJson:()=>{return},toCodecStringTree:()=>MS});function iQ(e){return F0(e,nQ)}var sQ=new Vd([],()=>(e,t,r)=>iQ(e)?ai:he(new oo(t,e,r)),{expected:"StringTree",toCodecStringTree:()=>{return}}),MS=new Lr(sQ,cm());function FS(){return Object.assign((e)=>e,{option:(e)=>Ue(e),result:(e)=>Xt(e),is:(e)=>!0})}var q0=FS(),$0=FS(),K0="~effect/process/ChildProcessSpawner/ChildProcessHandle",aQ={[K0]:K0,..._i,toJSON(){return{_id:"ChildProcessHandle",pid:this.pid}}},NS=(e)=>Object.setPrototypeOf({...e},aQ),W0=(e)=>{let t=(n,o)=>e(n).pipe(De((i)=>pR(o?.includeStderr===!0?i.all:sR(i.stdout,i.stderr))),_o),r=(n,o)=>dR(t(n,o));return Bc.of({spawn:e,exitCode:(n)=>Vs(Ae(e(n),(o)=>Un(o.exitCode,eo(Yx(o.all),hd)))),streamString:t,streamLines:r,lines:(n,o)=>lR(r(n,o)),string:(n,o)=>fR(t(n,o))})};class Bc extends Vt()("effect/process/ChildProcessSpawner"){}var pa=new WeakMap,G0=(e)=>{if(pa.has(e))return pa.get(e);else throw Error("Unable to get redacted value"+(e.label?` with label: "${e.label}"`:""))};var z0="~effect/Redacted",io=(e)=>He(e,z0),da=(e,t)=>{let r=Object.create(pQ);if(t?.label)r.label=t.label;return pa.set(r,e),r},pQ={[z0]:{_A:(e)=>e},label:void 0,...qr,toJSON(){return this.toString()},toString(){return`<redacted${jo(this.label)?":"+this.label:""}>`},[kt](){return je(pa.get(this))},[At](e){return io(e)&&or(pa.get(this),pa.get(e))}},Kc=G0;class ua extends Yo("CommandLineError"){}var Q0=(e,t)=>{if(e.length===0)return"";let r=t?.format??"posix";return fQ(r,e.map((n,o)=>io(n)?"<redacted>":wQ(lQ(r,n,o===0))))},H0=(e,...t)=>{let r=e.findIndex((n)=>n===void 0);if(r!==-1)return Nt(new ua({reason:"InvalidEscape",message:`Template part ${r} contains an invalid escape sequence`}));return OQ(e,t)},dQ=(e)=>io(e)?Kc(e):String(e),j0=(e)=>io(e)?e:String(e);var uQ=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"]),lQ=(e,t,r)=>{switch(e){case"posix":return r&&uQ.has(t)?`'${t}'`:hQ(t);case"powershell":return yQ(t);case"windows":return r&&!t.includes('"')?SQ(t):xQ(t)}},fQ=(e,t)=>e==="powershell"?`& ${t.join(" ")}`:t.join(" "),mQ=/^[A-Za-z0-9_@+:,./-]+$/,hQ=(e)=>mQ.test(e)?e:`'${e.replace(/['\\]/g,(t)=>`'\\${t}'`)}'`,yQ=(e)=>`'${e.replace(/['\u2018\u2019\u201A\u201B]/g,"$&$&")}'`,gQ=/[ \t\n\v"]/,xQ=(e)=>{if(e.length>0&&!gQ.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)+'"'},SQ=(e)=>e.length>0&&!/[ \t]/.test(e)?e:`"${e}"`,bQ=/[\u0000-\u001f\u007f-\u009f\u2028\u2029]/g,IQ={"\n":"\\n","\r":"\\r","\t":"\\t"},wQ=(e)=>e.replace(bQ,(t)=>IQ[t]??`\\u${t.charCodeAt(0).toString(16).padStart(4,"0")}`),EQ="|&;<>()",kQ="*?[",AQ=/[A-Za-z_0-9{(@*#?$!'"-]/,vQ=/[A-Za-z_0-9{(@*#?$!-]/,CQ=/^[A-Za-z_][A-Za-z0-9_]*\+?$/,BS=(e)=>e===" "||e==="\t"||e===`
33
- `,TQ=(e,t,r)=>{if(EQ.includes(e))return`The operator "${e}" needs a shell`;if(e==="`")return"Command substitution needs a shell";if(e==="$"&&t!==void 0&&AQ.test(t))return`The expansion "$${t}" needs a shell`;if(kQ.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&&!BS(t))return'A leading "=" is expanded by zsh';return},OQ=(e,t)=>{let r=[],n=[],o=!0,i=0,s=void 0,c=0,l=0,S=(w,k,A=l)=>Nt(new ua({reason:w,message:`${k} in template part ${A}`})),m=()=>{if(n.length===0)return;let w=n.map(dQ).join("");r.push(n.length===1&&io(n[0])?n[0]:n.some(io)?da(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
- `)n.push(y);k++}else if(A==="`")return S("UnsupportedSyntax","Command substitution needs a shell");else if(A==="$"&&y!==void 0&&vQ.test(y))return S("UnsupportedSyntax",`The expansion "$${y}" needs a shell`);else n.push(A);else if(BS(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=TQ(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&&CQ.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:!BS(A)))return S("UnsupportedSyntax","An interpolated array must be a separate argument");for(let y of k)r.push(j0(y))}else n.push(j0(k)),o=!1}if(s!==void 0)return S("UnterminatedQuote","The quote is not closed",c);return m(),Xt(r)};var J0="~effect/process/ChildProcess",PQ={...Ui({label:"Command",evaluate(e){return Wp(e.context,Bc).spawn(this)}}),[J0]:J0};var Xd=(e,t,r)=>Object.assign(Object.create(PQ),{_tag:"StandardCommand",command:e,args:t,options:r});var vm=function(...t){if(Y0(t[0])){let[i,...s]=t,[c,l]=Z0(i,s);return Xd(c,l,{})}if(typeof t[0]==="object"&&!Array.isArray(t[0])&&!Y0(t[0])){let i=t[0];return function(s,...c){if(i.shell!==void 0&&i.shell!==!1)return Xd(RQ(s,c),[],i);let[l,S]=Z0(s,c);return Xd(l,S,i)}}if(typeof t[0]==="string"&&!Array.isArray(t[1])){let[i,s={}]=t;return Xd(i,[],s)}let[r,n=[],o={}]=t;return Xd(r,n,o)};var Y0=(e)=>Array.isArray(e)&&("raw"in e)&&Array.isArray(e.raw),Cm=(e)=>{let t=/^fd(\d+)$/.exec(e);if(t===null)return;let r=parseInt(t[1],10);return r>=3?r:void 0},X0=(e)=>`fd${e}`,Z0=(e,t)=>{let[r="",...n]=mg(H0(e,...t));if(typeof r!=="string")throw new ua({reason:"InvalidArgument",message:"The program name of a command cannot be Redacted"});return[r,n]},RQ=(e,t)=>{if(t.length>0)throw new ua({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 ua({reason:"InvalidEscape",message:"Template part 0 contains an invalid escape sequence"});return r};import*as Rm from"child_process";import{PassThrough as KS}from"stream";var e_=(e,t,r)=>{let n=e.detached??r!=="win32";return{...t,detached:n,shell:e.shell,windowsHide:e.windowsHide??!n}};var ct=(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 to({_tag:o,module:e,method:t,pathOrDescriptor:n,syscall:r.syscall,cause:r})};import{finished as t_}from"stream";var Tm=(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 $c=(e)=>jx(qx(UQ(e),(t)=>[t])),UQ=(e)=>Ar((t)=>{let r=e.evaluate(),n=LQ({...e,writable:r,pull:t});return j(e.endOnDone===!1?n:ii(n,(o)=>ni(o)?Je:DQ(r)))}),DQ=(e)=>nn((t)=>{let r=()=>t(Je);if(e.closed){let n=t_(e,{readable:!1},()=>{n(),r()})}else Tm(e,Go,r)}),LQ=(e)=>kc((t)=>{let r=t.currentDispatcher,n=Ao(),o=Ao(),i=(S)=>Yn(o,vf(()=>e.onError(S))),s=!1,c=(S)=>{s=!0,i(S)};e.writable.on("error",c);let l=t_(e.writable,{readable:!1},(S)=>{if(S)i(S);else Yn(n,Je)});return e.pull.pipe(Ae((S)=>{let m=0;return nn((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(Je)};return A(),Be(()=>{w=!0,e.writable.off("drain",A),e.writable.off("finish",k)})})}),Oo({disableYield:!0}),e.endOnDone!==!1?Xn((S)=>(e.writable.end(),eo(zr(n),hr(S)))):Ee,Un(zr(o)),To(Be(()=>{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 FQ,Readable as Use}from"stream";var Wc=(e)=>on(NQ(e)),NQ=(e)=>Ar((t,r)=>BQ({scope:r,readable:e.evaluate(),onError:e.onError??KQ,chunkSize:e.chunkSize,readSize:e.readSize,closeOnDone:e.closeOnDone}));var BQ=(e)=>{let t=e.readable,r=e.chunkSize??4096,n=e.closeOnDone??!0,o=e.exit??cP(void 0),i=e.latch??iP(!1);function s(){i.openUnsafe()}t.on("readable",s);let c=FQ(t,{readable:!0,writable:!1},(S)=>{o.current??=_n(S?e.onError(S):ld()),i.openUnsafe()}),l=Ve(function S(){let m=e.readable.read(e.readSize);if(m===null){if(o.current)return o.current;if(t.readableEnded)return he(ld());return i.closeUnsafe(),Ae(i.await,S)}let g=Li(m);while(g.length<r){if(m=e.readable.read(e.readSize),m===null)break;g.push(m)}return j(g)});return ar(cd(e.scope,Be(()=>{if(t.off("readable",s),n)Tm(t,c);else c()})),l)};var KQ=(e)=>new hO(e);var la=(e)=>e instanceof globalThis.Error?e:new globalThis.Error(String(e)),so=(e,t,r)=>{let{commands:n}=WS(r),o=globalThis.process.platform==="win32"?"windows":"posix",i=n.map((s)=>Q0([s.command,...s.args],{format:o})).join(" | ");return ct("ChildProcess",e)(t,[i])},Pm=(e)=>io(e)?Kc(e):e,$Q=(e)=>{if(e.command.includes("\x00"))return"The command contains a NUL character";let t=e.args.findIndex((r)=>Pm(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&&Pm(n).includes("\x00"))return`The environment variable ${r} contains a NUL character`;return},r_=1000,WQ=10,n_=(e)=>{let t=()=>{};e.on("error",t),e.once("close",()=>e.off("error",t))},qS=(e)=>e.exitCode!==null||e.signalCode!==null,Om=(e)=>globalThis.process.platform!=="win32"&&e.options.detached!==!1,i_=(e)=>e?.code==="EPERM",o_=(e,t)=>{if(t.lost===!0)return!1;if(!qS(t))return!0;if(!Om(e))return!1;try{return globalThis.process.kill(-t.pid,0),!0}catch(r){return i_(r)}},GQ=(e,t=()=>{})=>{if(qS(e)){t(null);return}Rm.execFile("taskkill",["/pid",String(e.pid),"/T","/F"],{windowsHide:!0},t)},zQ=(e,t,r,n)=>{let o=Rm.spawn(e,t,r);for(let i of n){let s=o.stdio[i];if(s&&"allowHalfOpen"in s)s.allowHalfOpen=!0}return o},jQ=Ie(function*(e){let t=yield*Od,r=yield*ta,n=Ie(function*(K){if(ja(K.cwd))return;return yield*t.access(K.cwd),r.resolve(K.cwd)}),o=(K)=>{if(K.env===void 0)return;let ee=K.extendEnv===!0?{...globalThis.process.env}:{};for(let[Q,te]of Object.entries(K.env))if(te===void 0)delete ee[Q];else ee[Q]=Pm(te);return ee},i=(K)=>Xs(K)?"pipe":K,s=(K)=>vd(K)?"pipe":K,c=(K)=>{let ee={stream:"pipe",encoding:"utf-8",endOnDone:!0};if(ja(K.stdin))return ee;if(typeof K.stdin==="string")return{...ee,stream:K.stdin};if(Xs(K.stdin))return{...ee,stream:K.stdin};return{stream:K.stdin.stream,encoding:K.stdin.encoding??ee.encoding,endOnDone:K.stdin.endOnDone??ee.endOnDone}},l=(K,ee)=>{let Q=K[ee];if(ja(Q))return{stream:"pipe"};if(typeof Q==="string")return{stream:Q};if(vd(Q))return{stream:Q};return{stream:Q.stream}},S=(K)=>{if(ja(K.additionalFds))return[];let ee=[];for(let[Q,te]of Object.entries(K.additionalFds)){let re=Cm(Q);if(Yt(re))ee.push({fd:re,config:te})}return ee.sort((Q,te)=>Q.fd-te.fd)},m=(K,ee,Q,te)=>{let re=[i(K.stream),s(ee.stream),s(Q.stream)];if(te.length===0)return re;let ae=te.reduce((se,{fd:le})=>Math.max(se,le),2);for(let se=3;se<=ae;se++)re[se]="ignore";for(let{fd:se}of te)re[se]="pipe";return re},g=(K,ee,Q)=>Uf(uR(cR(K,(te)=>rO(Q,te)),ee)),w=Ie(function*(K,ee,Q,te){if(Q.length===0)return{getInputFd:()=>Cd,getOutputFd:()=>Rc};let re=new Map,ae=new Map,se=(Se,ve,ye)=>Ve(()=>{let $e=Cd;if(ve&&"write"in ve)n_(ve),$e=$c({evaluate:()=>ve,onError:(_e)=>so(`fromWritable(fd${Se})`,la(_e),K)});if(ye)return De(g(ye,$e,te),()=>{re.set(Se,$e)});return re.set(Se,$e),Je}),le=(Se,ve,ye)=>{let $e=Rc;if(ve&&"read"in ve){let _e=new KS,nr=void 0;_e.on("error",(Nr)=>{nr??=Nr}),ve.on("error",(Nr)=>_e.destroy(Nr)),ve.pipe(_e);let lr=(Nr)=>so(`fromReadable(fd${Se})`,la(Nr),K);$e=iR(()=>nr===void 0?Wc({evaluate:()=>_e,onError:lr}):Jx(lr(nr)))}if(ye)$e=Hf($e,ye);ae.set(Se,$e)};for(let{config:Se,fd:ve}of Q){let ye=ee.stdio[ve];switch(Se.type){case"input":{yield*se(ve,ye,Se.stream);break}case"output":{le(ve,ye,Se.sink);break}case"duplex":{le(ve,ye,Se.sink),yield*se(ve,ye,Se.stream);break}}}return{getInputFd:(Se)=>re.get(Se)??Cd,getOutputFd:(Se)=>ae.get(Se)??Rc}}),k=(K,ee,Q,te)=>Ve(()=>{let re=Cd;if(bl(ee.stdin))n_(ee.stdin),re=$c({evaluate:()=>ee.stdin,onError:(ae)=>so("fromWritable(stdin)",la(ae),K),endOnDone:Q.endOnDone,encoding:Q.encoding});if(Xs(Q.stream))return ar(g(Q.stream,re,te),re);return j(re)}),A=(K,ee,Q,te)=>{let re=ee.stdout?(()=>{let le=new KS;return ee.stdout.on("error",(Se)=>le.destroy(Se)),ee.stdout.pipe(le),Wc({evaluate:()=>le,onError:(Se)=>so("fromReadable(stdout)",la(Se),K)})})():Rc,ae=ee.stderr?(()=>{let le=new KS;return ee.stderr.on("error",(Se)=>le.destroy(Se)),ee.stderr.pipe(le),Wc({evaluate:()=>le,onError:(Se)=>so("fromReadable(stderr)",la(Se),K)})})():Rc;if(vd(Q.stream))re=Hf(re,Q.stream);if(vd(te.stream))ae=Hf(ae,te.stream);let se=aR(re,ae);return{stdout:re,stderr:ae,all:se}},y=(K,ee,Q,te)=>nn((re)=>{let ae=Ao(),se=K(ee.command,ee.args.map(Pm),Q,te);return se.on("error",(le)=>{if(ee.args.some(io))Object.assign(le,{spawnargs:[ee.command,...ee.args.map((Se)=>io(Se)?"<redacted>":Se)]});re(he(so("spawn",le,ee)))}),se.on("exit",(...le)=>{Yn(ae,zs(le))}),se.on("lost",(le)=>{Yn(ae,_n(so("exitCode",le,ee)))}),se.on("spawn",()=>{re(j([se,ae]))}),Be(()=>{se.kill("SIGTERM")})}),h=(K,ee,Q)=>{if(globalThis.process.platform==="win32")return nn((te)=>{GQ(ee,(re)=>{if(re)te(he(so("kill",la(re),K)));else te(Je)})});return Pr({try:()=>{globalThis.process.kill(-ee.pid,Q)},catch:(te)=>so("kill",la(te),K)})},x=(K,ee)=>{try{globalThis.process.kill(-K.pid,ee)}catch{}},z=(K,ee,Q)=>Ve(()=>{if(!ee.kill(Q)){let re=new globalThis.Error("Failed to kill child process");return he(so("kill",re,K))}return Je}),X=(K,ee,Q)=>nn((te)=>{let re=Date.now()+Q,ae,se=()=>{clearTimeout(ae),ee.removeListener("exit",le),ee.removeListener("lost",le)},le=()=>{if(clearTimeout(ae),Date.now()>=re||!o_(K,ee)){se(),te(Je);return}ae=setTimeout(le,WQ)};return ee.on("exit",le),ee.on("lost",le),le(),Be(se)}),I=Ie(function*(K,ee,Q,te){let re=(ae)=>globalThis.process.platform==="win32"||Om(K)?h(K,ee,ae).pipe(Hs((se)=>qS(ee)&&i_(se.cause)?Je:z(K,ee,ae))):z(K,ee,ae);if(yield*re(te?.killSignal??"SIGTERM"),ja(te?.forceKillAfter))yield*zr(Q),yield*X(K,ee,r_);else if(yield*X(K,ee,Gl(te.forceKillAfter)),o_(K,ee))yield*re("SIGKILL"),yield*X(K,ee,r_);yield*zr(Q)}),me=(K,ee)=>{let Q=ee??"stdout";switch(Q){case"stdout":return K.stdout;case"stderr":return K.stderr;case"all":return K.all;default:{let te=Cm(Q);if(Yt(te))return K.getOutputFd(te);return K.stdout}}},pe=Ie(function*(K){switch(K._tag){case"StandardCommand":{if(K.options.shell!==void 0&&K.options.shell!==!1&&K.args.length>0)return yield*he(mn({module:"ChildProcess",method:"spawn",description:"The shell option cannot be combined with arguments; pass the whole script as the command"}));let ee=$Q(K);if(ee!==void 0)return yield*he(mn({module:"ChildProcess",method:"spawn",description:ee}));let Q=c(K.options),te=l(K.options,"stdout"),re=l(K.options,"stderr"),ae=S(K.options),se=!0,le=yield*n(K.options),Se=o(K.options),ve=m(Q,te,re,ae),ye=ae.flatMap(({config:wr,fd:An})=>wr.type==="duplex"?[An]:[]),$e=Ie(function*(wr,An){if(wr.lost===!0||!se)return;if(xf(An)){let[qo]=yield*Co(zr(An));if((qo===0||zA(qo))&&!Om(K))return}yield*gx(I(K,wr,An,K.options))}),_e=yield*e,nr=Bi(),[lr,Nr]=yield*Dn(y(_e,K,e_(K.options,{cwd:le,env:Se,stdio:ve},process.platform),ye),([wr,An],qo)=>Ec([en(nr,qo),$e(wr,An)],{concurrency:"unbounded",discard:!0})),Es=$0(lr.pid);if(Om(K))lr.on("exit",(wr)=>{if(se&&wr!==0&&bl(wr))x(lr,K.options.killSignal??"SIGTERM")});let ks=Be(()=>{if(!se)lr.ref(),se=!0}),As=Be(()=>{if(se)lr.unref(),se=!1;return ks}),xo=Ao(),al=yield*Ki(nr)(k(K,lr,Q,xo)),{all:cl,stderr:pl,stdout:dl}=A(K,lr,te,re),{getInputFd:ul,getOutputFd:ll}=yield*Ki(nr)(w(K,lr,ae,xo)),fl=Ve(()=>xf(Nr)?ar(zr(Nr),!1):j(!0)),ml=Ae(Un(zr(Nr),zr(xo)),([wr,An])=>{if(xf(xo))return zr(xo);if(bl(wr))return j(q0(wr));let qo=new globalThis.Error(`Process interrupted due to receipt of signal: '${An}'`);return he(so("exitCode",qo,K))});return NS({pid:Es,exitCode:ml,isRunning:fl,kill:(wr)=>I(K,lr,Nr,wr),stdin:al,stdout:dl,stderr:pl,all:cl,getInputFd:ul,getOutputFd:ll,unref:As})}case"PipedCommand":{let{commands:ee,pipeOptions:Q}=WS(K),[te,...re]=ee,ae=[yield*pe(te)];for(let ve=0;ve<re.length;ve++){let ye=re[ve],$e=Q[ve]??{},_e=c(ye.options),nr=_o(j(me(ae[ae.length-1],$e.from))),lr=$e.to??"stdin";if(lr==="stdin")ae.push(yield*pe(vm(ye.command,ye.args,{...ye.options,stdin:{..._e,stream:nr}})));else{let Nr=Cm(lr);if(Yt(Nr)){let Es=X0(Nr),ks=ye.options.additionalFds??{},As=ks[Es],xo=As?.type==="duplex"?{...As,stream:nr}:{type:"input",stream:nr};ae.push(yield*pe(vm(ye.command,ye.args,{...ye.options,additionalFds:{...ks,[Es]:xo}})))}else ae.push(yield*pe(vm(ye.command,ye.args,{...ye.options,stdin:{..._e,stream:nr}})))}}let se=ae[ae.length-1],le=(ve)=>zi([...ae].reverse(),(ye)=>gx(ye.kill(ve)),{discard:!0}),Se=kr(function*(){let ve=[];for(let ye of ae)ve.push(yield*ye.unref);return zi([...ve].reverse(),(ye)=>ye,{discard:!0})});return NS({pid:se.pid,exitCode:se.exitCode,isRunning:se.isRunning,kill:le,stdin:ae[0].stdin,stdout:se.stdout,stderr:se.stderr,all:se.all,getInputFd:se.getInputFd,getOutputFd:se.getOutputFd,unref:Se})}}});return W0(pe)}),$S=Ic(Bc,jQ(j(zQ)));var WS=(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 c_ from"crypto";import*as we from"fs";import*as p_ from"os";import*as fi from"path";var gt=(e)=>(t)=>mn({module:"FileSystem",method:e,description:t.message??String(t)}),d_=(e,t)=>{let r=Number(e);if(!Number.isSafeInteger(r))throw RangeError(`${t} exceeds the safe integer range: ${e}`);return r},s_=(e)=>ig(Bs(e),LO),u_=(e)=>BigInt.asUintN(64,e),GS=(e)=>Dl(Bs(e),u_),HQ=(e,t)=>Pr({try:()=>d_(e,"position"),catch:gt(t)}),VQ=(()=>{let e=_t(we.access,ct("FileSystem","access"),gt("access"));return(t,r)=>{let n=we.constants.F_OK;if(r?.readable)n|=we.constants.R_OK;if(r?.writable)n|=we.constants.W_OK;return e(t,n)}})(),JQ=(()=>{let e=_t(we.cp,ct("FileSystem","copy"),gt("copy"));return(t,r,n)=>e(t,r,{force:n?.overwrite??!1,preserveTimestamps:n?.preserveTimestamps??!1,recursive:!0})})(),YQ=(()=>{let e=_t(we.copyFile,ct("FileSystem","copyFile"),gt("copyFile"));return(t,r)=>e(t,r)})(),ZQ=(()=>{let e=_t(we.chmod,ct("FileSystem","chmod"),gt("chmod"));return(t,r)=>e(t,r)})(),XQ=(()=>{let e=_t(we.chown,ct("FileSystem","chown"),gt("chown"));return(t,r,n)=>e(t,r,n)})(),eH=(()=>{let e=_t(we.link,ct("FileSystem","link"),gt("link"));return(t,r)=>e(t,r)})(),tH=(()=>{let e=_t(we.mkdir,ct("FileSystem","makeDirectory"),gt("makeDirectory"));return(t,r)=>e(t,{recursive:r?.recursive??!1,mode:r?.mode})})(),zS=(e)=>{let t=_t(we.mkdtemp,ct("FileSystem",e),gt(e));return(r)=>Ve(()=>{let n=r?.prefix??"",o=typeof r?.directory==="string"?fi.join(r.directory,"."):p_.tmpdir();return t(n?fi.join(o,n):o+"/")})},rH=zS("makeTempDirectory"),jS=(e)=>{let t=_t(we.rm,ct("FileSystem",e),gt(e));return(r,n)=>t(r,{recursive:n?.recursive??!1,force:n?.force??!1})},nH=jS("remove"),oH=(()=>{let e=zS("makeTempDirectoryScoped"),t=jS("makeTempDirectoryScoped");return(r)=>Dn(e(r),(n)=>Co(t(n,{recursive:!0,force:!0})))})(),iH=(e)=>{let{O_APPEND:t,O_CREAT:r,O_EXCL:n,O_RDONLY:o,O_RDWR:i,O_TRUNC:s,O_WRONLY:c}=we.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}},sH=(e,t)=>Ve(()=>{let{O_NOFOLLOW:r}=we.constants;if(process.platform==="win32"||typeof r!=="number"||r===0)return he(mn({module:"FileSystem",method:e,description:"noFollow is not supported on this platform"}));return j(iH(t)|r)}),aH=(e)=>{let t=_t(we.open,ct("FileSystem",e),gt(e)),r=_t(we.close,ct("FileSystem",e),gt(e));return(n,o)=>Oi(Dn(o?.noFollow===!0?Ae(sH(e,o.flag??"r"),(i)=>t(n,i,o.mode)):t(n,o?.flag??"r",o?.mode),(i)=>Co(r(i))),De((i)=>dH(i,o?.flag?.startsWith("a")??!1)))},cH=aH("open"),pH=(e)=>e.reason.cause?.code==="ESPIPE",a_=(e)=>mn({module:"FileSystem",method:e,description:"Cannot read before the start of the file"}),dH=(()=>{let e=(m)=>_t(we.read,ct("FileSystem",m),gt(m)),t=e("read"),r=e("readAlloc"),n=_t(we.fstat,ct("FileSystem","stat"),gt("stat")),o=_t(we.ftruncate,ct("FileSystem","truncate"),gt("truncate")),i=_t(we.fsync,ct("FileSystem","sync"),gt("sync")),s=(m)=>{let g=_t(we.write,ct("FileSystem",m),gt(m));return(w,k,A)=>g(w,k,0,k.length,A)},c=s("write"),l=s("writeAll");class S{[Vf];fd;append;position=BigInt(0);sequential=!1;constructor(m,g){this[Vf]=Vf,this.fd=m,this.append=g}get stat(){return Ae(n(this.fd,{bigint:!0}),m_)}get sync(){return i(this.fd)}atCursor(m){return Ve(()=>{if(this.sequential)return m(null);let g=this.position;return Qi(De(m(g),(w)=>(this.position=g+BigInt(w),w)),pH,()=>(this.sequential=!0,m(null)))})}writeOnce(m,g,w){return this.append?Ve(()=>g(this.fd,w,void 0)):this.atCursor((k)=>k===null?g(this.fd,w,void 0):Ae(HQ(k,m),(A)=>g(this.fd,w,A)))}seek(m,g){return Ve(()=>{let w=g==="start"?m:this.position+m;if(w<BigInt(0))return he(mn({module:"FileSystem",method:"seek",description:"Cannot seek before the start of the file"}));return this.position=w,j(w)})}read(m,g){return Ve(()=>{let w=g?.position;if(w===void 0)return this.atCursor((k)=>t(this.fd,{buffer:m,position:k}));return w<BigInt(0)?he(a_("read")):t(this.fd,{buffer:m,position:w})})}readAlloc(m,g){return Ve(()=>{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 he(a_("readAlloc"));let k=Buffer.allocUnsafeSlow(m),A=(y)=>r(this.fd,{buffer:k,position:y});return De(w===void 0?this.atCursor(A):A(w),(y)=>{if(y===0)return ge();if(y===m)return Ue(k);let h=Buffer.allocUnsafeSlow(y);return k.copy(h,0,0,y),Ue(h)})}catch(w){return he(gt("readAlloc")(w))}})}truncate(m){return De(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 Ae(this.writeOnce("writeAll",l,m),(g)=>{if(g===0)return he(to({module:"FileSystem",method:"writeAll",_tag:"WriteZero",pathOrDescriptor:this.fd,description:"write returned 0 bytes written"}));return g<m.length?this.writeAllChunk(m.subarray(g)):Je})}writeAll(m){return m.length===0?Je:this.writeAllChunk(m)}}return(m,g)=>new S(m,g)})(),l_=(e)=>{let t=zS(e);return Ie(function*(r){let n=yield*t(r),o=c_.randomBytes(6).toString("hex"),i=fi.join(n,r?.suffix?`${o}${r.suffix}`:o);return yield*y_(i,new Uint8Array(0)),i})},uH=l_("makeTempFile"),lH=(()=>{let e=l_("makeTempFileScoped"),t=jS("makeTempFileScoped");return(r)=>Dn(e(r),(n)=>Co(t(fi.dirname(n),{recursive:!0,force:!0})))})(),fH=(e,t)=>js({try:()=>we.promises.readdir(e,t),catch:(r)=>ct("FileSystem","readDirectory")(r,[e])}),mH=(e)=>js({try:()=>we.promises.readdir(e,{withFileTypes:!0}),catch:(t)=>ct("FileSystem","readDirectoryEntries")(t,[e])}).pipe(De((t)=>t.map((r)=>({name:r.name,type:f_(r)})))),hH=(e)=>nn((t,r)=>{try{we.readFile(e,{signal:r},(n,o)=>{if(n)t(he(ct("FileSystem","readFile")(n,[e])));else t(j(o))})}catch(n){t(he(gt("readFile")(n)))}}),yH=(()=>{let e=_t(we.readlink,ct("FileSystem","readLink"),gt("readLink"));return(t)=>e(t)})(),gH=(()=>{let e=_t(process.platform==="win32"?we.realpath.native:we.realpath,ct("FileSystem","realPath"),gt("realPath"));return(t)=>e(t)})(),xH=(()=>{let e=_t(we.rename,ct("FileSystem","rename"),gt("rename"));return(t,r)=>e(t,r)})(),f_=(e)=>e.isFile()?"File":e.isDirectory()?"Directory":e.isSymbolicLink()?"SymbolicLink":e.isBlockDevice()?"BlockDevice":e.isCharacterDevice()?"CharacterDevice":e.isFIFO()?"FIFO":e.isSocket()?"Socket":"Unknown",m_=(e,t="stat")=>Pr({try:()=>({type:f_(e),mtime:Bs(e.mtime),atime:Bs(e.atime),birthtime:Bs(e.birthtime),dev:u_(e.dev),rdev:GS(e.rdev),ino:GS(e.ino),mode:d_(e.mode,"mode"),nlink:GS(e.nlink),uid:s_(e.uid),gid:s_(e.gid),size:Ax(e.size),blksize:e.blksize!==void 0?Ue(Ax(e.blksize)):ge(),blocks:Bs(e.blocks)}),catch:gt(t)}),h_=(e,t)=>{let r=_t(t,ct("FileSystem",e),gt(e));return(n)=>Ae(r(n,{bigint:!0}),(o)=>m_(o,e))},QS=h_("stat",we.stat),SH=h_("lstat",we.lstat),bH=(()=>{let e=_t(we.symlink,ct("FileSystem","symlink"),gt("symlink"));return(t,r)=>e(t,r)})(),IH=(()=>{let e=_t(we.truncate,ct("FileSystem","truncate"),gt("truncate"));return(t,r)=>e(t,r)})(),wH=(()=>{let e=_t(we.utimes,ct("FileSystem","utime"),gt("utime"));return(t,r,n)=>e(t,r,n)})(),EH=(e,t,r)=>oR((n)=>Dn(Be(()=>{let o=t.type==="Directory"?e:fi.dirname(e),i=we.watch(e,{recursive:r?.recursive??!1},(s,c)=>{if(!c)return;switch(s){case"rename":{Df(CO(QS(fi.resolve(o,c)),{onSuccess:(l)=>wd(n,{_tag:"Create",path:c}),onFailure:(l)=>wd(n,{_tag:"Remove",path:c})}));return}case"change":{Zi(n,{_tag:"Update",path:c});return}}});return i.on("error",(s)=>{Ed(n,mO(to({module:"FileSystem",_tag:"Unknown",method:"watch",pathOrDescriptor:e,cause:s})))}),i.on("close",()=>{Ro(n)}),i}),(o)=>Be(()=>o.close())).pipe(ji(()=>Be(()=>r?.onReady?.())))),kH=(e,t,r)=>Ec([QS(t),Tf(Jf)]).pipe(De(([n,o])=>Rv(o,()=>e).pipe(ig((i)=>i.register(t,n,r)),fr(()=>EH(t,n,r)))),_o),y_=(e,t,r)=>nn((n,o)=>{try{we.writeFile(e,t,{signal:o,flag:r?.flag,mode:r?.mode},(i)=>{if(i)n(he(ct("FileSystem","writeFile")(i,[e])));else n(Je)})}catch(i){n(he(gt("writeFile")(i)))}}),AH=De(Tf(Jf),(e)=>hR({access:VQ,chmod:ZQ,chown:XQ,copy:JQ,copyFile:YQ,link:eH,lstat:SH,makeDirectory:tH,makeTempDirectory:rH,makeTempDirectoryScoped:oH,makeTempFile:uH,makeTempFileScoped:lH,open:cH,readDirectory:fH,readDirectoryEntries:mH,readFile:hH,readLink:yH,realPath:gH,remove:nH,rename:xH,stat:QS,symlink:bH,truncate:IH,utimes:wH,watch(t,r){return kH(e,t,r)},writeFile:y_})),g_=Ic(Od)(AH);var x_=g_;import*as eu from"path";import*as _m from"url";var HS=(e)=>({fromFileUrl:(t)=>Pr({try:()=>_m.fileURLToPath(t,{windows:e}),catch:(r)=>new Id({module:"Path",method:"fromFileUrl",cause:r})}),toFileUrl:(t)=>Pr({try:()=>_m.pathToFileURL(t,{windows:e}),catch:(r)=>new Id({module:"Path",method:"toFileUrl",cause:r})})}),TH=bc(ta)(Yf({...eu.posix,...HS(!1)})),OH=bc(ta)(Yf({...eu.win32,...HS(!0)})),S_=bc(ta)(Yf({...eu,...HS(void 0)}));var b_=S_;var VS="~effect/Stdio",I_=Vt(VS),w_=(e)=>({[VS]:VS,stdinIsTerminal:j(!1),stdoutIsTerminal:j(!1),stderrIsTerminal:j(!1),...e});var _H=Be(()=>{process.nextTick(()=>{if(process.stdin.readableFlowing===null)process.stdin.pause()})}),k_=bc(I_,w_({args:Be(()=>process.argv.slice(2)),stdinIsTerminal:Be(()=>process.stdin.isTTY===!0),stdoutIsTerminal:Be(()=>process.stdout.isTTY===!0),stderrIsTerminal:Be(()=>process.stderr.isTTY===!0),stdout:(e)=>$c({evaluate:()=>process.stdout,onError:(t)=>to({module:"Stdio",method:"stdout",_tag:"Unknown",cause:t}),endOnDone:e?.endOnDone??!1}),stderr:(e)=>$c({evaluate:()=>process.stderr,onError:(t)=>to({module:"Stdio",method:"stderr",_tag:"Unknown",cause:t}),endOnDone:e?.endOnDone??!1}),stdin:_o(ar(vc(()=>_H),Wc({evaluate:()=>process.stdin,onError:(e)=>to({module:"Stdio",method:"stdin",_tag:"Unknown",cause:e}),closeOnDone:!1})))}));var A_=k_;var v_="~effect/http/Cookies";var C_="~effect/http/Cookies/Cookie";var LH={[v_]:v_,..._i,toJSON(){return{_id:"effect/Cookies",cookies:Gv(this.cookies,(e)=>e.toJSON())}},pipe(){return et(this,arguments)}},MH=(e)=>{let t=Object.create(LH);return t.cookies=e,t},FH=(e)=>{let t={};for(let r of e)Zr(t,r.name,r);return MH(t)};var T_=FH([]);var Xse={[C_]:C_,..._i,toJSON(){return{_id:"effect/Cookies/Cookie",name:this.name,value:this.value,options:this.options}}};var P_=Symbol.for("~effect/http/Headers");var Um=Object.defineProperties(Object.create(null),{[P_]:{value:P_},[Rs]:{value(e){return BH(this,dn(e,KH))}},toJSON:{value(){return Qn(this)}},[At]:{value(e){return NH(this,e)}},[kt]:{value(){return Cp(this)}},toString:{value:_i.toString},[Xr]:{value:_i[Xr]}});var NH=jv(yv()),fa=Object.create(Um),R_=(e)=>{if(e===void 0)return fa;else if(Symbol.iterator in e){let r=Object.create(Um);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(Um);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},__=(e)=>Object.setPrototypeOf(e,Um);var BH=q(2,(e,t)=>{let r={...e},n=(o)=>{if(typeof o==="string"){let i=o.toLowerCase();if(i in e)r[i]=da(e[i])}else for(let i in e)if(i.search(o)!==-1)r[i]=da(e[i])};if(Array.isArray(t))for(let o=0;o<t.length;o++)n(t[o]);else n(t);return r});var KH=Jt("effect/Headers/CurrentRedactedNames",{defaultValue:()=>["authorization","cookie","set-cookie","x-api-key"]});var Dm=(e,t,r)=>er(e)?r(t):Qr(e,r);function D_(e){let t=qH(e);return(r,n,o)=>{try{return t(r,n,o)}catch(i){return Or(i)}}}function qH(e){if(e._tag==="Middleware")return(r,n,o)=>{let i=er(r)?e.decode(vr(_d(n)),o):e.decode(Mf(r,_d),o);return U_(i)};let t=e.decode;switch(t._tag){case"Passthrough":return(r,n)=>er(r)?vr(n):r;case"Transform":{let r=(n)=>n===We?Ln:vr(t.transform(n));return(n,o)=>Dm(n,o,r)}case"TransformOptional":{let r=(n)=>tS(t.transform(_d(n)));return(n,o)=>Dm(n,o,r)}case"TransformEffect":return(r,n,o)=>Dm(r,n,(i)=>i===We?Ln:t.transform(i,o));case"TransformOptionalEffect":return(r,n,o)=>Dm(r,n,(i)=>U_(t.transform(_d(i),o)))}}var U_=(e)=>Qr(e,tS),L_=(e,t,r,n)=>jr(n,(o)=>Qs(()=>Gi(o,(i)=>new SR(e,i,t,r))));function $H(e,t){let r=D_(e.link.transformation),n;return(o,i)=>{if(o===We)return Ln;if(e.isConstructed(o))return ai;let s=(n??=t(e.link.to))(o,i);return r(s,o,i)}}function WH(e,t){let r=e.context.constructorDefault;return(n,o)=>{if(n!==We&&n!==void 0)return t(n,o);let i=r;if(mt(i)&&i._tag==="Success"){let s=t(i[Me],o);return er(s)?i:s}return Qr(L_(e,n,o,i),(s)=>{let c=t(s,o);return er(c)?vr(s):c})}}function YS(e,t){let r=t(e);return e.context?.constructorDefault===void 0?r:WH(e,r)}function tu(e,t,r,n,o){if(e._tag==="Declaration")for(let A of e.typeParameters)t(A);let i=r?Am(e):void 0,s=i?$H(i,t):n??e.getParser(t,r),{checks:c,encoding:l}=e,S=l?.map((A)=>D_(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(mt(h)){if(h._tag==="Success"){let x=er(h)?A:h[Me];if(A!==We&&x!==We){let z=ts(m,A,void 0,e,y);if(z)h=he(new Ur(e,z,A,y))}}}else h=Ae(h,(x)=>{if(A!==We&&x!==We){let z=ts(m,A,void 0,e,y);if(z)return he(new Ur(e,z,A,y))}return j(x)});if(c&&!y.disableChecks)if(mt(h)){if(h._tag==="Success"){let x=er(h)?A:h[Me];if(x===We)return h;let z=ts(c,x,void 0,e,y);if(z)h=he(new Ur(e,z,x,y))}}else h=Ae(h,(x)=>{if(x!==We){let z=ts(c,x,void 0,e,y);if(z)return he(new Ur(e,z,x,y))}return j(x)});return h}catch(x){return Or(x)}},k=o===void 0?w:o(w);if(!l)return k;return(A,y)=>{let h=g??=l.map((X)=>t(X.to)),x=A,z=h[h.length-1](A,y);for(let X=l.length-1;X>=0;X--)if(z=S[X](z,x,y),X!==0){let I=h[X-1];if(z._tag==="Success")x=z[Me],z=I(x,y);else z=Qr(z,(me)=>{let pe=I(me,y);return er(pe)?vr(me):pe})}if(z._tag==="Success"){let X=z[Me],I=k(X,y);return er(I)?z:I}return z=L_(e,A,y,z),Qr(z,(X)=>{let I=k(X,y);return er(I)?vr(X):I})}}var ZS=Symbol(),M_=new WeakMap,F_,ru=!1;var zH=(e)=>ru?Lm(gn,e,"parser"):gn(e).parser,N_=(e)=>ru?Lm(gn,e,"makeEffect"):gn(e).makeEffect,jH=(e)=>YS(e,N_);class XS{ast;constructor(e){this.ast=e}get decodeEffect(){return this.cachedDecodeEffect??=tu(this.ast,zH)}get parser(){return this.decodeEffect}get makeEffect(){return this.cachedMakeEffect??=tu(this.ast,N_,jH)}}class B_ extends XS{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")??tu(this.ast,(e)=>Lm(this.resolve,e,"parser")))}get parser(){let e=this.decode;return e===void 0?this.decodeEffect:this.save("parser",QH(e,()=>this.decodeEffect))}get makeEffect(){let e=this.compiledMakeEffect;if(e!==void 0)return this.save("makeEffect",e);let t=(r)=>Lm(this.resolve,r,"makeEffect");return this.save("makeEffect",tu(this.ast,t,(r)=>YS(r,t)))}}function QH(e,t){let r;return(n,o)=>{if(n!==We)try{let i=e(n,o);if(i!==ZS)return i===n?ai:vr(i)}catch(i){return Or(i)}return(r??=t())(n,o)}}function Lm(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 gn(e){let t=M_.get(e);if(t!==void 0)return t;let r=F_===void 0?new XS(e):new B_(e,F_(e,gn),gn);return M_.set(e,r),r}function tb(e){let t=e.ast,r;return(n,o)=>J_(r??=gn(ui(t)),n,V_(o))}function Mm(e){let t=tb(e);return(r,n)=>XH(Ys(t(r,n)))}function q_(e){return tV(ui(e.ast))}function $_(e){return JH(e.ast)}function VH(e){if(!ru){let o=j_(nb(e));return(i)=>{let s=o(i,aa);if(tn(s))return!0;return ra(s.cause,"Type guard adapter can only return false for schema issues"),!1}}let t=gn(e),r=t.is;if(r!==void 0)return(o)=>{try{return r(o,aa)}catch(i){return ra(Ef(i),"Type guard adapter can only return false for schema issues"),!1}};let n=t.parser;return(o)=>{let i=Ys(ob(n(o,aa),o));if(tn(i))return!0;return ra(i.cause,"Type guard adapter can only return false for schema issues"),!1}}function JH(e){let t=ui(e),r=(n)=>(r=VH(t),r(n));return(n)=>r(n)}function rb(e,t){let r=nb(e.ast);return z_(r,t)}function W_(e,t){return ZH(rb(e,t))}function G_(e,t){let r=nb(hn(e.ast));return z_(r,t)}function z_(e,t){return t===void 0?e:(r,n)=>e(r,n?{...t,...n}:t)}var K_=(e)=>{if(e===We)return he(new Hr);return j(e)};function nb(e){return YH(rV,e)}function ob(e,t){if(er(e))return j(t);if(!mt(e))return Qr(e,K_);return e[Me]===We?K_(We):e}function YH(e,t){let r;return(n,o)=>ob((r??=e(t))(n,o??aa),n)}function j_(e){return(t,r)=>Ys(e(t,r))}function ZH(e){let t=j_(e);return(r,n)=>{let o=t(r,n);if(tn(o))return Ue(o.value);return ra(o.cause,"Option adapter can only return none for schema issues"),ge()}}function XH(e){if(tn(e))return Ue(e.value);return ra(e.cause,"Option adapter can only return none for schema issues"),ge()}function eV(e,t){let r=Ys(e);if(tn(r))return r.value;let n=ra(r.cause,t);throw Error("Schema validation failed",{cause:n})}var Q_="Constructor adapter can only throw schema issues";function H_(e){throw Error(Q_,{cause:Ef(e)})}function tV(e){let t;return(r,n)=>eb(t??=gn(e),r,n)}function V_(e){return e?.disableChecks?{...e.parseOptions,disableChecks:!0}:e?.parseOptions??aa}function J_(e,t,r){return ob(e.makeEffect(t,r),t)}function eb(e,t,r){let n=V_(r),o=ru?e.make:void 0;if(o!==void 0&&t!==We){let i;try{i=o(t,n)}catch(s){H_(s)}if(i!==ZS&&i!==We)return i}return eV(J_(e,t,n),Q_)}function Y_(e,t,r,n){let o=gn(e),i=Am(e);if(i===void 0||o.make!==void 0||o.compiledMakeEffect!==void 0)return eb(o,t,r);if(i.isConstructed(t))return t;let s=eb((o.resolve??gn)(i.link.to),t,r);try{return n(s)}catch(c){H_(c)}}var rV=(e)=>gn(e).parser;var Fm="~effect/Schema/Schema",Z_=Symbol(),nV={[Fm]:Fm,get make(){let e=q_(this);return Object.defineProperty(this,"make",{value:e,enumerable:!0}),e},get makeEffect(){let e=tb(this);return Object.defineProperty(this,"makeEffect",{value:e,enumerable:!0}),e},get makeOption(){let e=Mm(this);return Object.defineProperty(this,"makeOption",{value:e,enumerable:!0}),e},pipe(){return et(this,arguments)},annotate(e){return this.rebuild(bm(this.ast,e))},annotateKey(e){return this.rebuild(Em(this.ast,e))},check(...e){return this.rebuild(ca(this.ast,e))},rebuild(e){return Gc(e,this[Z_])}};function Gc(e,t){function r(){}let n=Object.setPrototypeOf(r,nV);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[Z_]=t,n.ast=e,n}function aV(e,t){let r=Pi((o)=>{let i=Fc(o,void 0),s=e(i,n);return s===i?null:s}),n=wm((o)=>{let i=r(Jd(o));if(i===null)return o;let s=Fc(i,o.context);return o.context===void 0?s:v0(s,cV(o.context))},t);return n}function cV(e){return e.constructorDefault===void 0?e:new SS(e.isOptional,e.isMutable,void 0,e.annotations)}function pV(e){if(e.propertySignatures.some((t)=>typeof t.name!=="string"))throw new globalThis.Error("Objects property names must be strings",{cause:e})}function dV(e){return(t)=>{let r=[...t].sort((o,i)=>e(li(o))-e(li(i)));if(!r.some((o,i)=>o!==t[i]))return t;return r}}function eU(e){return Gc(gV(e.ast),{schema:e})}var uV=dV((e)=>{switch(e._tag){case"Null":case"Boolean":case"Number":case"BigInt":case"Symbol":case"UniqueSymbol":return 0;default:return 1}});function lV(e,t,r){switch(e._tag){case"Declaration":{let n=e.typeParameters.map((S)=>Gc(t(li(S)))),o=e.annotations?.toCodecStringTree;if(bo(o)){let S=o(n);if(S===void 0)return e;return Dr(e,[Im(S,t)])}let i=e.annotations?.toCodecJson,s=bo(i)?i(n):void 0,c=s===void 0?e.annotations?.toCodec:void 0,l=s??(bo(c)?c(n):void 0);return l===void 0?r(e):Dr(e,[Im(l,t)])}case"Null":return Dr(e,[fV]);case"Boolean":return Dr(e,[mV]);case"Unknown":case"ObjectKeyword":return Dr(e,[MS]);case"Enum":case"Number":case"Literal":case"UniqueSymbol":case"Symbol":case"BigInt":return e.toCodecStringTree();case"Objects":return pV(e),e.recur(t,LS);case"Union":{let n=uV(e.types);if(n!==e.types)return new es(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 fV=new Lr(new Do("null"),new cr(Bt(()=>null),Bt(()=>"null"))),mV=new Lr(new es([new Do("true"),new Do("false")]),new cr(Bt((e)=>e==="true"),om())),hV=new cr(Bt((e)=>typeof e==="string"?[e]:e),Uo()),yV=(e)=>e.transformation===hV,gV=aV((e,t)=>lV(e,t,(r)=>{throw new globalThis.Error("Missing structural codec for StringTree",{cause:r})}),{stopAt:yV});var ma=(e)=>e;var zc="~effect/Schema/SchemaError";function rU(e){return He(e,zc)&&e[zc]===zc}var nu=Fm;function SV(){return(e,t,r)=>Tt(new Vd(e.map(gm),(n)=>t(n.map((o)=>Tt(o))),r))}function bV(e,t){return SV()([],()=>(r,n,o)=>e(r)?j(r):he(new oo(n,r,o)),t)}function IV(e){return(t)=>nU(nU(t).annotate(e))}class ab extends Yo("SchemaError"){[zc]=zc;constructor(e){let t=Us();Hn(0);try{super({issue:e})}finally{Hn(t)}}get message(){return TR(this.issue)}toJSON(){return{_tag:this._tag,message:this.message}}[Xr](){return this.toJSON()}toString(){return`SchemaError(${this.message})`}}function wV(e){return rU(e)}function sU(e){if(mt(e))return EV(e);return jr(e,(t)=>Qs(()=>Gi(t,(r)=>new ab(r))))}function EV(e){return tn(e)?e:Wi(Gi(e.cause,(t)=>new ab(t)))}function aU(e,t){let r;for(let n of e.reasons){if(!wf(n)||!wV(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 kV(e){return Ex(e).then((t)=>{if(tn(t))return t.value;throw aU(t.cause,"Promise adapter can only reject schema errors")})}function AV(e){let t=Ys(e);if(tn(t))return t.value;throw aU(t.cause,"Sync adapter can only throw schema errors")}var cb=$_;function rs(e,t){let r=rb(e,t);return(n,o)=>sU(r(n,o))}var ns=W_;function ao(e,t){let r=rs(e,t);return(n,o)=>kV(r(n,o))}function vV(e,t){let r=rs(e,t);return(n,o)=>AV(r(n,o))}function cU(e,t){let r=G_(e,t);return(n,o)=>sU(r(n,o))}var Tt=Gc;function CV(e){return He(e,nu)&&e[nu]===nu}var u=ma((e)=>Tt(km(e.ast),{schema:e}));var pb=ma((e)=>{let t=RV(e);return Tt(O0(e.ast),{schema:t})});var TV=ma((e)=>Tt(li(e.ast),{schema:e})),ou="~effect/Schema/flip";function OV(e){return He(e,ou)&&e[ou]===ou}function nU(e){if(OV(e))return e.schema.rebuild(hn(e.ast));return Tt(hn(e.ast),{[ou]:ou,schema:e})}function v(e){let t=Tt(new Do(e),{literal:e,transform(r){return t.pipe(os(v(r),{decode:Bt(()=>r),encode:Bt(()=>e)}))}});return t}var H=Tt(Qd),pU=Tt(mm),PV=Tt(bS),a=Tt(Xi);var yr=Tt(IS),Y=Tt(a0);function db(e,t){return Tt(e,{fields:t,mapFields(r,n){let o=r(this.fields);return db(ym(o,n?.unsafePreserveChecks?this.ast.checks:void 0),o)}})}function p(e){return db(ym(e,void 0),e)}function Gt(e,t){return Tt(RS(e.ast,t.ast),{key:e,value:t})}function dU(e,t){return Tt(m0(e.ast,t.map(gm)),{schema:e,records:t})}var U=ma((e)=>Tt(new hm(!1,[],[e.ast]),{value:e}));function uU(e,t){return Tt(e,{members:t,mapMembers(r,n){let o=r(this.members);return uU(xm(o,this.ast.options,n?.unsafePreserveChecks?this.ast.checks:void 0),o)}})}function pt(e,t){return uU(xm(e,t,void 0),e)}function G(e){let t=e.map(v);return Tt(xm(t,void 0,void 0),{literals:e,members:t,mapMembers(r){return pt(r(this.members))},pick(r){return G(r)},transform(r){return pt(t.map((n,o)=>n.transform(r[o])))}})}var D=ma((e)=>pt([e,pU])),RV=ma((e)=>pt([e,PV]));function dt(e){return(t)=>Tt(t.ast,{schema:t,identifier:e})}function _V(e){return(t)=>Tt(C0(t.ast,new cS(e,Ee)),{schema:t})}function ub(e){return UV(e)}function UV(e){return(t)=>_V(_O(e))(t)}function os(e,t){return(r)=>Tt(PS(r.ast,e.ast,t?pS(t):cm()),{from:r,to:e})}var lb=G(["true","yes","on","1","y"]),fb=G(["false","no","off","0","n"]),lU=G([...lb.literals,...fb.literals]).pipe(os(Y,am({decode:(e)=>e==="true"||e==="yes"||e==="on"||e==="1"||e==="y",encode:(e)=>e?"true":"false"})));function DV(e){return(t)=>Tt(P0(t.ast,e),{schema:t})}function LV(e){if(mt(e)&&e._tag==="Success")return e;return jr(e,(t)=>Qs(()=>Gi(t,(r)=>r.issue)))}function fU(e,t){let r=t?.encodingStrategy==="omit"?NR():Uo();return(n)=>u(TV(n)).pipe(os(n,{decode:BR(LV(e)),encode:r}))}function is(e){return v(e).pipe(DV(j(e)))}function MV(e,t){return p({_tag:is(e),...t})}function ha(e,t){return bV((r)=>r instanceof e,t)}function su(){return(e,t)=>new Lr(e.ast,pS(t))}var zt=Sm;var oU="^\\S[\\s\\S]*\\S$|^\\S$|^$";function FV(e){let t=new globalThis.RegExp(oU);return zt((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:oU,flags:""}]},...e})}function Ge(e,t){let{source:r,flags:n}=e,o=/^[dg]*uy?$/.test(n);return vS(e,{toJsonSchema:()=>o?{pattern:n.endsWith("y")?`^(?:${r})`:r}:[{},!0],...t})}var NV=(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 L(e,t){let r=NV(e);return Ge(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 BV(e){let r=/^[0-9a-zA-Z+/]*={0,2}$/;return zt((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 KV(e){let t=qp(e.order),r=e.formatter??rt;return(n,o)=>zt((i)=>t(i,n),{expected:`a value greater than ${r(n)}`,arbitraryConstraint:{order:e.order,minimum:n,exclusiveMinimum:!0},...e.annotate?.(n),...o})}function qV(e){let t=og(e.order),r=e.formatter??rt;return(n,o)=>zt((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 $V(e){let t=ng(e.order),r=e.formatter??rt;return(n,o)=>zt((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 WV(e){let t=og(e.order),r=qp(e.order),n=ng(e.order),o=Pv(e.order),i=e.formatter??rt;return(s,c)=>{let l=s.exclusiveMinimum?r:t,S=s.exclusiveMaximum?o:n;return zt((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 iu(e){if(!globalThis.Number.isFinite(e))throw new globalThis.RangeError(`Expected a finite number, got ${rt(e)}`);return e}var Mo=KV({order:Ns,annotate:(e)=>({representation:{id:"effect/schema/isGreaterThan",payload:{exclusiveMinimum:iu(e)}},toJsonSchema:()=>({exclusiveMinimum:e})})}),Re=qV({order:Ns,annotate:(e)=>({representation:{id:"effect/schema/isGreaterThanOrEqualTo",payload:{minimum:iu(e)}},toJsonSchema:()=>({minimum:e})})});var mU=$V({order:Ns,annotate:(e)=>({representation:{id:"effect/schema/isLessThanOrEqualTo",payload:{maximum:iu(e)}},toJsonSchema:()=>({maximum:e})})}),Mr=WV({order:Ns,annotate:(e)=>{let t=e.exclusiveMinimum?!0:void 0,r=e.exclusiveMaximum?!0:void 0;return{representation:{id:"effect/schema/isBetween",payload:{minimum:iu(e.minimum),maximum:iu(e.maximum),...t&&{exclusiveMinimum:t},...r&&{exclusiveMaximum:r}}},toJsonSchema:()=>({[t?"exclusiveMinimum":"minimum"]:e.minimum,[r?"exclusiveMaximum":"maximum"]:e.maximum})}}});function au(e){return zt((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 M=yr.check(au());function be(e,t){return e=hU(e),GV(e,Math.ceil(e/2),t)}function GV(e,t,r){return zt((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],[Pd]:!0,arbitraryConstraint:{minLength:e},...r})}function oe(e,t){return e=hU(e),zt((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],[Pd]:!0,arbitraryConstraint:{maxLength:e},...t})}function hU(e){if(!globalThis.Number.isFinite(e))throw new globalThis.RangeError(`Expected a finite number, got ${e}`);return Math.max(0,Math.floor(e))}var zV=(e)=>(e?.includeStack===!0?1:0)|(e?.excludeCause===!0?2:0),jV=(e)=>{switch(e){case 0:return;case 1:return{includeStack:!0};case 2:return{excludeCause:!0};case 3:return{includeStack:!0,excludeCause:!0}}};var iU=[];function yU(e){let t=zV(e),r=iU[t];if(r!==void 0)return r;let n=t4.pipe(os(H,jR(jV(t))));return iU[t]=n,n}var Pce=ha(globalThis.RegExp,{representation:{id:"effect/schema/RegExp",payload:null},expected:"RegExp",toCodecJson:()=>su()(p({source:a,flags:a}),sm({decode:(e,t)=>Pr({try:()=>new globalThis.RegExp(e.source,e.flags),catch:()=>new Hr({expected:"valid RegExp source and flags"},e,t)}),encode:(e)=>j({source:e.source,flags:e.flags})}))}),QV=a.annotate({expected:"a string that will be decoded as a URL"}),Rce=ha(globalThis.URL,{representation:{id:"effect/schema/URL",payload:null},expected:"URL",toCodecJson:()=>su()(QV,QR)});var _ce=ha(globalThis.File,{representation:{id:"effect/schema/File",payload:null},expected:"File",toCodecJson:()=>su()(p({data:a.check(BV()),type:a,name:a,lastModified:M}),sm({decode:(e,t)=>Nl(nm(e.data),{onFailure:()=>he(new Hr({expected:"a valid Base64 string"},e.data,t)),onSuccess:(r)=>{let n=new globalThis.Uint8Array(r);return j(new globalThis.File([n],e.name,{type:e.type,lastModified:e.lastModified}))}}),encode:(e,t)=>js({try:async()=>{let r=new globalThis.Uint8Array(await e.arrayBuffer());return{data:rm(r),type:e.type,name:e.name,lastModified:e.lastModified}},catch:()=>new Hr({expected:"a readable File"},e,t)})}))});var Uce=ha(globalThis.URLSearchParams,{representation:{id:"effect/schema/URLSearchParams",payload:null},expected:"URLSearchParams",toCodecJson:()=>su()(a.annotate({expected:"a query string that will be decoded as URLSearchParams"}),am({decode:(e)=>new globalThis.URLSearchParams(e),encode:(e)=>e.toString()}))});var Nm=a.annotate({expected:"a string that will be decoded as a number"}).pipe(os(yr,Gd));var HV=a.check(FV()),Fr=a.annotate({expected:"a string that will be decoded as a trimmed string"}).pipe(os(HV,GR()));var VV=a.annotate({expected:"a base64 encoded string that will be decoded as Uint8Array",format:"byte",contentEncoding:"base64"}),Dce=ha(globalThis.Uint8Array,{representation:{id:"effect/schema/Uint8Array",payload:null},expected:"Uint8Array",toCodecJson:()=>su()(VV,HR)});var JV=-8640000000000000,YV=8640000000000000,Lce=JV+50400000,Mce=YV-50400000;var ZV=globalThis.Symbol.for("immer-draftable"),sb={};function gU(e,t,r,n,o){let i=e4(r,t,n),s=SU(t),c=class extends e{constructor(...[l,S]){let g=S?.["~payload"],w=g?.token===sb?g.value:r.make(l??{},S);super(w,{...S,disableChecks:!0,"~payload":{token:sb,value:w}})}static[nu]=nu;get[s](){return s}static[ZV]=!0;static identifier=t;static fields=r.fields;static get ast(){return i(this).ast}static pipe(){return et(this,arguments)}static rebuild(l){return i(this).rebuild(l)}static make(l,S){return Y_(ui(i(this).ast),l??{},S,(m)=>xU(this,m))}static makeOption(l,S){return Mm(i(this))(l??{},S)}static makeEffect(l,S){return i(this).makeEffect(l??{},S)}static annotate(l){return this.rebuild(bm(this.ast,l))}static annotateKey(l){return this.rebuild(Em(this.ast,l))}static check(...l){return this.rebuild(ca(this.ast,l))}static extend(l){return(S,m)=>{let g=mb(S)?S:p(S),w={...r.fields,...g.fields},k=ym(w,r.ast.checks,{identifier:l});return gU(this,l,db(ca(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 xU(e,t){return new e(t,{"~payload":{token:sb,value:t}})}function XV(e){return new cr(Bt((t)=>xU(e,t)),Uo())}function SU(e){return`~effect/Schema/Class/${e}`}function e4(e,t,r){let n;return(o)=>{if(n!==void 0)return n;let i=SU(t),s=(S)=>S instanceof o||He(S,i),c=XV(o),l=Tt(new Vd([e.ast],()=>(S,m,g)=>s(S)?j(S):he(new oo(m,S,g)),{identifier:t,[Xf]:([S])=>({isConstructed:s,link:new Lr(S,c)}),toCodec:([S])=>new Lr(S.ast,c),toEquivalence:([S])=>S,toFormatter:([S])=>(m)=>`${o.identifier}(${S(m)})`,[Zf]:Hd(e.ast),...r}));return n=os(l,c)(e)}}function mb(e){return CV(e)}var cu=(e)=>(t,r)=>{let n=mb(t)?t:p(t);return gU(Np,e,n,r,(i)=>({name:i}))},co=(e)=>(t,r,n)=>{let o=mb(r)?r.mapFields((i)=>({_tag:is(t),...i}),{unsafePreserveChecks:!0}):MV(t,r);return cu(e??t)(o,n)};var bU=eU;var t4=Tt(N0);var IU="~effect/Terminal",hb="~effect/Terminal/QuitError";class pu extends cu("QuitError")({_tag:is("QuitError")}){[hb]=hb}var wU=(e)=>He(e,hb),po=Vt("effect/Terminal"),EU=(e)=>po.of({...e,[IU]:IU});import*as Km from"readline";var kU=Ie(function*(e=vU){let t=yield*Zs(),r=!1,n=!1,o=()=>{if(r=!0,!n)Ro(t)},i,s=()=>{if(i===void 0)if(i=process.stdin,i.readableEnded)o();else i.once("end",o);return i};yield*vc(()=>Be(()=>i?.off("end",o)));let c=yield*Hx({acquire:Dn(Be(()=>{let h=s(),x=Km.createInterface({input:h,escapeCodeTimeout:50}),z=(I)=>Zi(t,I),X=()=>{n=!1,Ro(t)};return n=!0,Km.emitKeypressEvents(h,x),x.on("line",z),x.once("close",X),{rl:x,onClose:X,onLine:z}}),({rl:h,onClose:x,onLine:z})=>Be(()=>{if(n=!1,h.off("line",z),h.off("close",x),h.close(),r)Ro(t)})),idleTimeToLive:"10 millis"}),l=(h)=>Be(()=>{let x=s();if(x.isTTY)x.setRawMode(h)}),S=yield*Hx({acquire:Dn(l(!0),()=>l(!1)),idleTimeToLive:"10 millis"}),m=Be(()=>process.stdout.columns??0),g=Be(()=>process.stdout.rows??0),w=kr(function*(){let h=process.stdout,x=yield*yP(1),z=()=>Zi(x,{columns:h.columns??0,rows:h.rows??0});return yield*vc(()=>Be(()=>{h.off("resize",z),Ro(x)})),h.on("resize",z),z(),x}),k=kr(function*(){let h=s(),x=yield*Zs(),z=(me,pe)=>{let K={input:ec(me),key:{name:pe.name??"",ctrl:!!pe.ctrl,meta:!!pe.meta,shift:!!pe.shift}};if(Zi(x,K),e(K))Ro(x)},X=setInterval(()=>{},2147483647),I=()=>{clearInterval(X),Ro(x)};if(yield*vc(()=>Be(()=>{clearInterval(X),h.off("keypress",z),h.off("end",I)})),h.on("keypress",z),r)I();else yield*Qf(c),yield*Qf(S),h.once("end",I);return x}),A=Ve(()=>SP(t).pipe(Ae($r({onNone:()=>Vs(eo(Qf(c),si(t))),onSome:j})),Rr(()=>new pu({}))));return EU({columns:m,rows:g,size:w,readInput:k,readLine:A,display:(h)=>Pf(nn((x)=>{process.stdout.write(h,(z)=>jA(z)?x(Je):x(he(mn({module:"Terminal",method:"display",description:"Failed to write prompt to stdout",cause:z}))))}))})}),AU=Ic(po,kU(vU));function vU(e){let t=e.key;return t.name==="escape"||t.ctrl&&(t.name==="c"||t.name==="d")}var CU=AU;var o4=$S.pipe(fO(bf(x_,b_,A_,CU)));var i4=ix,OU=(e)=>Xe((t)=>e(t.getRef(i4)));var qm=(...e)=>OU((t)=>vt(()=>{t.error(...e)}));var gr=(...e)=>OU((t)=>vt(()=>{t.log(...e)}));var $m="~effect/ErrorReporter/ignore";var PU="~effect/Runtime/errorExitCode";var uu="~effect/Runtime/errorReported";var ut=a.check(L()),de=dt("WorkspaceId")(ut),mi=dt("WorkspaceInviteId")(ut),ss=dt("UserId")(ut),xb=dt("AuditEventId")(ut),Ot=dt("PostId")(ut),tr=dt("TargetId")(ut),Kt=dt("AttemptId")(ut),V=dt("AccountId")(ut),xn=dt("MediaId")(ut),bt=dt("ProfileId")(ut),ya=dt("ApiKeyId")(ut),lu=dt("WebhookEndpointId")(ut),Sn=dt("InboxConversationId")(ut),Nn=dt("InboxMessageId")(ut),jc=dt("InboxCommentThreadId")(ut),Qc=dt("InboxCommentId")(ut),Hc=dt("InboxMentionId")(ut),Wm=dt("InboxReviewId")(ut),Sb=dt("InboxAttachmentId")(ut),hi=dt("InboxActionId")(ut),Gde=dt("InboundEventId")(ut),zde=dt("WebhookDeliveryId")(ut),Bn=dt("AdCampaignId")(ut),as=dt("AdGroupId")(ut),Vc=dt("AdCreativeId")(ut),cs=dt("AdId")(ut),RU=dt("AdInsightId")(ut),Kn=dt("AdOperationId")(ut),_U=dt("AdBoostId")(ut),UU=dt("AdRequestId")(ut);var DU=(e)=>e,LU=(e)=>e;var bb=Fr.check(be(1),oe(100)),Ib=a.check(be(1),oe(100)).annotate({description:"An IANA time zone such as America/New_York."}),ga=p({id:de,name:bb,defaultTimezone:Ib,role:G(["owner","member"])}),MU=p({workspaces:U(ga)}),FU=p({name:bb,defaultTimezone:u(Ib).annotate({description:"Default IANA time zone for new queues. Defaults to UTC; existing queues keep their own time zone."})}),Vde=p({name:u(bb),defaultTimezone:u(Ib)}).check(zt(({name:e,defaultTimezone:t})=>e!==void 0||t!==void 0||"Provide a name, a default time zone, or both.")),Jde=p({workspaceId:de}),NU=Fr.check(be(1),oe(100)),wb=p({id:a.check(L()),email:a,displayName:D(NU)}),BU=p({displayName:D(NU)}),KU=p({deactivated:v(!0)}),qU=p({archived:v(!0)});var qn=a.check(Ge(/^[A-Z]{3}$/)),xt=p({amountMinor:M,currency:qn}).annotate({identifier:"Money"});var fu=p({estimatedCostMicros:M,estimatedCost:xt,includedRemaining:M,overagePublishes:M,xPublishes:M,blocked:D(p({code:G(["insufficient_credit","spend_cap_reached","billing_inactive"]),nextAction:a}))}).annotate({identifier:"PostBillingEstimate"});var s4=50,$U=100;var WU=a.check(be(1),oe(2048)).annotate({description:"Opaque cursor from a previous list response. Pass nextCursor verbatim."}),It=p({cursor:u(WU),limit:u(Nm.check(au(),Mr({minimum:1,maximum:$U})).annotate({description:`Page size from 1 to ${$U}. Defaults to ${s4}.`}))}).annotate({identifier:"PageQuery"}),ze={hasMore:Y,nextCursor:u(WU)},a4=p({v:v(1),k:a.check(oe(512)),id:a.check(be(1),oe(256))}),oue=vV(a4);var c4=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"]),uo=p({code:c4,path:U(pt([a,M])),message:a}),aue=Vz();var ps=["bluesky","facebook","instagram","linkedin","pinterest","reddit","snapchat","tiktok","threads","x","youtube","google_business"],bn=G(ps),p4=[...ps,"meta_ads","google_ads","reddit_ads","pinterest_ads","tiktok_ads","linkedin_ads","snapchat_ads","amazon_ads","openai_ads"],qe=G(p4);var Gm=G(["na","eu","fe"]),pr=G(["social_page","social_account","social_board","social_channel","ad_account"]),d4=G(["auth","permission","access_pending","rate_limit","not_found","deleted","conflict","invalid_request","transient","invalid_response","unsupported"]),due=p({provider:qe,operation:a,kind:d4,providerStatus:u(M),providerCode:u(a),requestId:u(a),retryable:Y,retryAfterSeconds:u(M),missingScopes:u(U(a)),detail:u(a)}).annotate({identifier:"ProviderError"}),uue=G(["publish","read_insights","engage","ads"]),u4=p({provider:bn});var rr=G(ps),Jc=a.check(L()),lo=M.check(Re(1)),l4=128,Vr=a.check(Ge(new RegExp(`^[A-Za-z0-9._~-]{1,${l4}}$`))),Sue=p({"idempotency-key":Vr}),bue=p({"idempotency-key":u(Vr)}),GU=86400,Ut=a.check(Ge(/^\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)$/),zt((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"})),xr=G(["feed","reel","story","carousel","video","pin"]),zm=pt([Ut,pU]),f4=p({accountId:V,placement:xr,scheduledAt:u(zm),queueId:u(Jc)}).annotate({identifier:"DestinationSelection"}),Iue=p({expectedRevision:lo,scheduledAt:u(Ut),accountIds:u(U(V).check(be(1),oe(50)).annotate({description:"Select every draft placement for these accounts. Use targets for exact selection instead."})),targets:u(U(f4).check(be(1),oe(50)).annotate({description:"Select exact draft destinations and optionally override each schedule. Omit accountIds when using targets."}))}),zU=p({postId:Ot}),Eb=p({postId:Ot,targetId:tr}),wue=p({expectedAttemptId:Kt}),Eue=pt([p({expectedAttemptId:Kt,action:v("reschedule"),scheduledAt:Ut}),p({expectedAttemptId:Kt,action:v("reschedule"),queueId:Jc,pinned:u(p({slotId:Jc,occurrenceDate:a.check(Ge(/^\d{4}-\d{2}-\d{2}$/))}))}),p({expectedAttemptId:Kt,action:G(["publish_now","cancel"])})]).annotate({identifier:"ScheduleChange"}),m4=u(a),jU={queueId:u(Jc),slotId:u(Jc),assignmentId:u(Jc),occurrenceDate:u(a.check(Ge(/^\d{4}-\d{2}-\d{2}$/))),localDate:u(a.check(Ge(/^\d{4}-\d{2}-\d{2}$/))),localTime:u(a.check(Ge(/^(?:[01]\d|2[0-3]):[0-5]\d$/))),timezone:u(a)},QU={targetId:tr,attemptId:Kt,accountId:V,scheduledAt:m4,...jU},Yc=G(["scheduled","queued","submitting","confirming","published","provider_draft","failed","unresolved","cancelled"]),jm=pt([v("draft"),Yc]).annotate({identifier:"PostState"}),mu=p({id:a.check(be(1)),kind:a.check(be(1))}).annotate({identifier:"DeliveryProviderRef"}),kb=p({...QU,status:Yc}),h4=p({targetId:tr,attemptId:Kt,accountId:V,provider:rr,placement:xr,status:Yc,scheduledAt:D(a),url:D(a),issue:D(a),canRetry:Y,canReconcile:Y,...jU}).annotate({identifier:"PublishAcceptedTarget"}),xa=p({postId:Ot,idempotencyKey:Vr,targets:U(h4),warnings:U(uo),billing:u(fu)}).annotate({identifier:"PublishAccepted"}),hu=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"]),kue=G(["pending","sending","posted","failed","unresolved"]),Aue=G(["pending","updating","updated","failed","unresolved"]),vue=G(["pending","sending","invited","failed","unresolved"]),y4={...QU,revision:lo,provider:rr,placement:xr},Qm=p({...y4,status:Yc,providerRef:u(mu),url:u(a),issue:u(hu),canRetry:Y,canReconcile:Y,nextAction:u(a)}).annotate({identifier:"DeliveryStatus"}),Ab=p({postId:Ot,status:jm,targets:U(Qm)}),Cue=p({settled:Y,post:Ab,retryAfterSeconds:u(M)}).annotate({identifier:"PublishWait"});function HU(e){return e==="draft"||!["scheduled","queued","submitting","confirming"].includes(e)}var g4=p({postId:Ot,isDraft:Y,status:jm,textPreview:a,targetCount:M.check(Re(0)),mediaCount:M.check(Re(0)),revision:lo,createdAt:a,updatedAt:a}).annotate({identifier:"PostSummary"}),VU=p({data:U(g4),...ze}).annotate({identifier:"PostList"}),x4=p({delivery:Qm,createdAt:a,updatedAt:a,replacesAttemptId:u(Kt)}).annotate({identifier:"DeliveryAttemptSummary"}),JU=p({currentAttemptId:Kt,data:U(x4),...ze}).annotate({identifier:"DeliveryHistory"});var Zc=G(["payg","pro","platform","enterprise"]),Hm=G(["month","year"]),Vm=G(["fake","stripe"]),yu=G(["active","trialing","past_due","canceled","incomplete","unpaid"]),Jm=G(["confirmed_publish","x_passthrough","managed_ad","inbox_reply","automation_run"]),S4=p({meter:Jm,includedPerPeriod:M,overageUnitPriceMicros:D(M),unitLabel:a}).annotate({identifier:"BillingPlanMeter"}),b4=p({id:Zc,name:a,monthlyPrice:D(xt),annualPrice:D(xt),meters:U(S4),seatsLimit:D(M),analyticsRetentionDays:M,whiteLabelOAuth:Y,ssoSaml:Y}).annotate({identifier:"BillingPlan"}),YU=p({data:U(b4)}).annotate({identifier:"BillingPlanList"}),I4=p({meter:Jm,includedPerPeriod:M,used:M,billable:M,costMicros:M}).annotate({identifier:"BillingMeterUsage"}),w4=p({monthlySpendCapMicros:D(M),version:M}).annotate({identifier:"BillingSpendControls"}),E4=G(["ok","payment_required","insufficient_credit","spend_cap_reached"]),Cb=p({workspaceId:de,plan:Zc,status:yu,paymentStatus:E4,interval:D(Hm),gateway:Vm,periodStart:a,periodEnd:a,cancelAtPeriodEnd:Y,creditBalanceMicros:M,creditBalance:xt,spendControls:w4,currentPeriod:p({meters:U(I4),totalVariableSpendMicros:M,seatsUsed:M,seatsLimit:D(M)})}).annotate({identifier:"WorkspaceBilling"}),Sa=a.check(Ge(/^\d{4}-\d{2}-\d{2}$/)),vb=a.check(Ge(/^https?:\/\/[^\s]+$/)),Due=p({from:u(Sa),to:u(Sa),meter:u(Jm),provider:u(rr)}).annotate({identifier:"BillingUsageQuery"}),k4=p({date:Sa,meter:Jm,provider:D(rr),quantity:M,billableQuantity:M,costMicros:M}).annotate({identifier:"BillingUsageDailyPoint"}),ZU=p({from:Sa,to:Sa,totals:p({quantity:M,billableQuantity:M,costMicros:M}),data:U(k4)}).annotate({identifier:"BillingUsage"}),Ym=G(["top_up","auto_top_up","overage_debit","x_passthrough_debit","refund","adjustment"]),Lue=p({kind:u(Ym),from:u(Sa),to:u(Sa),...It.fields}).annotate({identifier:"BillingLedgerQuery"}),A4=p({id:a.check(L()),kind:Ym,deltaMicros:M,balanceAfterMicros:M,description:a,referenceKind:D(a),referenceId:D(a),createdAt:a}).annotate({identifier:"BillingLedgerEntry"}),XU=p({data:U(A4),...ze}).annotate({identifier:"BillingLedgerList"}),Mue=pt([p({mode:v("subscription"),plan:G(["pro","platform"]),interval:Hm,returnUrl:u(vb)}),p({mode:v("top_up"),amountMinor:M.check(Re(1000),mU(1e7)),returnUrl:u(vb)})]).annotate({identifier:"CreateBillingCheckout"}),eD=p({url:a,expiresAt:u(a)}).annotate({identifier:"BillingCheckoutSession"}),Fue=p({returnUrl:u(vb)}).annotate({identifier:"CreateBillingPortal"}),tD=p({url:a}).annotate({identifier:"BillingPortalSession"}),Nue=p({version:M,monthlySpendCapMicros:D(M)}).annotate({identifier:"UpdateBillingSpendControls"});var rD=180,nD=365,sD=["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.deleted","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"],Tb=G(sD).annotate({identifier:"AuditAction"}),aD=["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"],Zm=G(aD).annotate({identifier:"AuditTargetKind"}),v4=G(["user","api_key"]).annotate({identifier:"AuditActorType"}),C4=pt([p({type:v("user"),id:ss,email:D(a),displayName:D(a)}),p({type:v("api_key"),id:ya,name:D(a),prefix:D(a)})]).annotate({identifier:"AuditActor"}),Ob=p({id:xb,workspaceId:de,profileId:D(bt),actor:C4,action:Tb,targetKind:Zm,targetId:a.check(L()),detail:Gt(a,H),createdAt:a}).annotate({identifier:"AuditEvent"}),cD=p({data:U(Ob),...ze}).annotate({identifier:"AuditEventList"}),zue=p({workspaceId:de,eventId:xb}),oD=pt([Ut,a.check(Ge(/^\d{4}-\d{2}-\d{2}$/))]),jue=p({action:u(Tb),targetKind:u(Zm),targetId:u(a.check(L())),actorType:u(v4),actorId:u(a.check(L())),profileId:u(bt),from:u(oD).annotate({description:"Inclusive start instant (ISO 8601 timestamp or YYYY-MM-DD UTC date)."}),to:u(oD).annotate({description:"Inclusive end instant (ISO 8601 timestamp or YYYY-MM-DD UTC date)."}),...It.fields}),T4=p({action:Tb,targetKind:Zm,description:a,retentionDays:M}).annotate({identifier:"AuditActionCatalogEntry"}),pD=p({actions:U(T4),targetKinds:U(Zm),retention:p({standardDays:M,spendDays:M})}).annotate({identifier:"AuditActionCatalog"}),iD={"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.deleted":{targetKind:"integration_connection",description:"Disconnected provider grant permanently deleted with its accounts and their publishing, ads, inbox, and analytics records."},"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."}},Que={actions:sD.map((e)=>({action:e,targetKind:iD[e].targetKind,description:iD[e].description,retentionDays:e.startsWith("billing.")||e.startsWith("ads.")?nD:rD})),targetKinds:[...aD],retention:{standardDays:rD,spendDays:nD}};var Pb=p({workspaceId:de,deliveryFailures:Y,connectionExpiring:Y,webhookFailures:Y,billingAlerts:Y,weeklyDigest:Y,updatedAt:D(a)}).annotate({identifier:"NotificationPreferences"}),Yue=p({deliveryFailures:u(Y),connectionExpiring:u(Y),webhookFailures:u(Y),billingAlerts:u(Y),weeklyDigest:u(Y)}).check(zt((e)=>Object.values(e).some((t)=>t!==void 0)||"Provide at least one notification preference to update.")).annotate({identifier:"UpdateNotificationPreferences"});var Xc=G(["owner","member"]).annotate({identifier:"WorkspaceRole"}),O4=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,P4=Fr.pipe(os(a.check(be(3),oe(320),Ge(O4)),lj())).annotate({identifier:"NormalizedEmail",description:"Email address, trimmed and lowercased."}),Xm=p({workspaceId:de,userId:ss,email:a,displayName:D(a),role:Xc,joinedAt:a}).annotate({identifier:"WorkspaceMember"}),dD=p({data:U(Xm),...ze}).annotate({identifier:"WorkspaceMemberList"}),nle=p({role:u(Xc),...It.fields}),ole=p({workspaceId:de,userId:ss}),ile=p({role:Xc}).annotate({identifier:"UpdateWorkspaceMemberRole"}),uD=p({removed:v(!0)}).annotate({identifier:"WorkspaceMemberRemoved"}),lD=G(["pending","accepted","revoked","expired"]).annotate({identifier:"WorkspaceInviteStatus"}),Rb=p({id:mi,workspaceId:de,email:a,role:Xc,status:lD,deliveryState:G(["queued","sending","uncertain","sent"]),remoteRevocationPending:Y,invitedByUserId:ss,invitedByEmail:D(a),expiresAt:a,acceptedAt:D(a),revokedAt:D(a),createdAt:a}).annotate({identifier:"WorkspaceInvite"}),fD=p({data:U(Rb),...ze}).annotate({identifier:"WorkspaceInviteList"}),sle=p({status:u(lD),...It.fields}),ale=p({workspaceId:de,inviteId:mi}),cle=p({email:P4,role:u(Xc)}).annotate({identifier:"CreateWorkspaceInvite"}),mD=p({invite:Rb}).annotate({identifier:"WorkspaceInviteCreated"}),hD=p({invite:Rb,resendState:G(["sending","sent","uncertain"])}).annotate({identifier:"WorkspaceInviteResent"}),yD=p({revoked:v(!0),remoteRevocationPending:Y}).annotate({identifier:"WorkspaceInviteRevoked"}),R4=p({id:mi,workspaceId:de,workspaceName:a,role:Xc,invitedByEmail:D(a),invitedByName:D(a),expiresAt:a,createdAt:a}).annotate({identifier:"PendingUserInvite"}),gD=p({data:U(R4)}).annotate({identifier:"PendingUserInviteList"}),ple=pt([p({token:Fr.check(be(1),oe(256))}),p({inviteId:mi})]).annotate({identifier:"AcceptWorkspaceInvite"}),xD=p({workspace:ga,membership:Xm}).annotate({identifier:"WorkspaceInviteAccepted"}),SD=p({declined:v(!0),remoteRevocationPending:Y}).annotate({identifier:"WorkspaceInviteDeclined"}),dle=p({inviteId:mi});var _4="pubnio_sk_",_b=new RegExp(`^${_4}[A-Za-z0-9_-]{43}$`),gu=G(["read","publish","engage","ads_read","ads_manage"]),Ub=U(gu).check(be(1),oe(gu.literals.length),zt((e)=>new Set(e).size===e.length||"Choose each scope once.")),Db=Fr.check(be(1),oe(100)),xu=p({id:ya,workspaceId:de,name:Db,prefix:a,scopes:Ub,createdAt:a,updatedAt:a,expiresAt:D(a),revokedAt:D(a)}).annotate({identifier:"ApiKey"}),yle=p({name:Db,scopes:u(Ub).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(Ut)}),gle=p({name:u(Db),scopes:u(Ub)}).check(zt(({name:e,scopes:t})=>e!==void 0||t!==void 0||"Provide a name or scopes."));var xle=gu.literals;var Sle=p({workspaceId:de,keyId:ya}),bD=p({key:xu,secret:a.check(Ge(_b)).annotate({description:"Copy this secret now. This is the only response that returns it."})}),ID=p({data:U(xu),...ze}).annotate({identifier:"ApiKeyList"}),wD=p({revoked:v(!0)});var eh=26214400,th=268435456,rh=16777216,U4=8388608;var ba=a.check(oe(2048),Ge(/^https:\/\//i),zt((e)=>{let t=URL.parse(e);return Boolean(t?.hostname&&t.protocol==="https:"&&!t.username&&!t.password)||"Expected an HTTPS media URL without credentials"})),ED=p({mediaId:xn}),D4=p({url:ba}),L4=pt([ED,D4]).annotate({identifier:"MediaInput"}),Lb=35,ds=U(L4).check(oe(Lb)),Su=G(["image","video","document"]),ep=G(["image/jpeg","image/png","image/gif","image/webp","video/mp4","video/quicktime","video/webm","application/pdf"]);function M4(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 kD(e){return ep.literals.find((t)=>M4(e,t))}var vle=p({workspaceId:de,mimeType:ep}),Mb=p({mediaId:xn,type:Su,mimeType:ep,sizeBytes:M.check(Mr({minimum:1,maximum:th})),createdAt:a}).annotate({identifier:"MediaAsset"}),AD=p({data:U(Mb),...ze}).annotate({identifier:"MediaList"}),vD=p({deleted:v(!0)}),Cle=p({url:a.check(be(1),oe(8192))}).annotate({identifier:"MediaImport"}),Tle=p({sizeBytes:M.check(Re(1))}).annotate({identifier:"MediaUploadStart"}),CD=Mr({minimum:1,maximum:Math.ceil(th/rh)}),F4=M.check(CD),Ole=p({...ED.fields,partNumber:Nm.check(au(),CD)}),TD=p({mediaId:xn,partSizeBytes:v(rh),expiresAt:a}).annotate({identifier:"MediaUploadSession"}),OD=p({partNumber:F4}).annotate({identifier:"MediaPartReceipt"}),PD=p({code:G(["media_source_unavailable","media_storage_unavailable","media_too_large","unsupported_media","upload_expired"]),maxBytes:u(M)}).annotate({identifier:"MediaIntakeIssue"}),N4=G(["awaiting_upload","processing","ready","failed"]),B4=p({receivedPartCount:M.check(Re(0)),partDigests:U(a.check(Ge(/^[A-Za-z0-9_-]{43}$/))),expiresAt:a}).annotate({identifier:"MediaUploadProgress"}),Ia=p({mediaId:xn,status:N4,asset:u(Mb),issue:u(PD),upload:u(B4),idempotencyKey:u(Vr),retryAfterSeconds:u(M)}).annotate({identifier:"MediaIntake"}),Ple=p({mediaId:xn,status:G(["ready","failed","timeout"]),asset:u(Mb),issue:u(PD),retryAfterSeconds:u(M)}).annotate({identifier:"MediaWait"}),Rle=p({data:a.check(be(1),oe(Math.ceil(U4/3)*4+4)).annotate({description:"Base64-encoded file bytes. Maximum 8 MiB after decoding."}),mimeType:ep,filename:u(a.check(be(1),oe(255)))}).annotate({identifier:"MediaInlineUpload"}),RD=G(["part_conflict","part_out_of_order","parts_missing","upload_closed","upload_expired"]);var Fb=["live","beta","upcoming"];var K4=["publish","read_insights","manage_comments"],nh=[...K4,"send_messages"],In={bluesky:{label:"Bluesky",availability:"beta",authFamily:"bluesky",accountKinds:["social_account"],capabilities:{social_account:nh},approvalRequired:{},limited:{}},facebook:{label:"Facebook",availability:"live",authFamily:"facebook",accountKinds:["social_page"],capabilities:{social_page:nh},approvalRequired:{},limited:{}},instagram:{label:"Instagram",availability:"live",authFamily:"instagram",accountKinds:["social_account"],capabilities:{social_account:nh},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:nh},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 Dle={bluesky:{...In.bluesky,publishCapable:!0},facebook:{...In.facebook,publishCapable:!0},instagram:{...In.instagram,publishCapable:!0},linkedin:{...In.linkedin,publishCapable:!0},pinterest:{...In.pinterest,publishCapable:!0},reddit:{...In.reddit,publishCapable:!0},snapchat:{...In.snapchat,publishCapable:!0},tiktok:{...In.tiktok,publishCapable:!0},threads:{...In.threads,publishCapable:!0},x:{...In.x,publishCapable:!0},youtube:{...In.youtube,publishCapable:!0},google_business:{...In.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"}},Lle=ps.flatMap((e)=>{let t=In[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 q4=60,$4=3600;var W4={requestsPerMinute:300,publishesPerMinute:30,mediaUploadsPerMinute:10,windowSeconds:60},gi=pt([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:U(a)}),p({status:v("permission_required"),reason:v("missing_page_task")})]).annotate({identifier:"AccountReadiness"}),yi=G(["publish","read_insights","manage_comments","send_messages","ads_read","ads_write","ads_spend"]),G4=G(["supported","not_supported","access_pending","permission_missing","unverified","reconnect_required","unavailable"]),Wle=p({scopes:u(U(a)),pageTasks:u(U(a)),roles:u(U(a)),loginMethods:u(U(a))}),xi=p({capability:yi,state:G4,missingScopes:U(a),missingRoles:U(a),reason:u(a)}).annotate({identifier:"AccountCapability"}),z4=p({accountId:V,profileId:bt,provider:qe,accountKind:pr,enabled:Y,publishingReadiness:gi,capabilities:U(xi),checkedAt:a}).annotate({identifier:"AccountCapabilities"}),_D=p({capabilities:U(z4)}),Gle=p({workspaceId:de,profileId:u(bt),accountId:u(V),capability:u(yi)}),j4=p({provider:qe,availability:G(Fb),accountKind:pr,capabilities:U(yi),approvalRequired:U(yi),limited:U(yi)}).annotate({identifier:"CapabilityCatalogEntry"}),UD=p({entries:U(j4)}).annotate({identifier:"CapabilityCatalog"}),Q4=p({accountId:V,provider:qe,accountKind:pr,name:a,enabled:Y,readiness:gi}).annotate({identifier:"AccountSummary"}),zle=p({accounts:U(Q4)}).annotate({identifier:"AccountSummaryList"}),H4=p({requestsPerMinute:M,publishesPerMinute:M,mediaUploadsPerMinute:M,windowSeconds:M}).annotate({identifier:"RateLimits"}),DD=p({uploadMaxBytes:M,assetMaxBytes:M,partMaxBytes:M,types:U(Su)}).annotate({identifier:"MediaLimits"}),Nb=p({targetsPerRequest:M,draftTextCharacters:M,idempotencyTtlSeconds:M,wait:p({defaultSeconds:M,maxSeconds:M}),media:DD,rateLimits:H4}).annotate({identifier:"ApiLimits"}),V4=p({placement:xr,default:Y,mediaTypes:U(Su),maxMedia:M,captionCharacters:M}).annotate({identifier:"PlacementCapability"}),J4=p({provider:bn,label:a,availability:G(Fb),accountKinds:U(pr),placements:U(V4),requiredScopes:U(a)}).annotate({identifier:"ProviderCapability"}),LD=p({providers:U(J4),accountKinds:U(pr),media:DD,limits:Nb}).annotate({identifier:"PublishCapabilities"}),jle={targetsPerRequest:50,draftTextCharacters:128000,idempotencyTtlSeconds:GU,wait:{defaultSeconds:q4,maxSeconds:$4},media:{uploadMaxBytes:eh,assetMaxBytes:th,partMaxBytes:rh,types:[...Su.literals]},rateLimits:W4};var oh=G(["instagram_login","facebook_login","unified_login"]),MD=u(oh),Y4=pt([p({provider:v("bluesky"),kind:v("account"),handle:a,did:a,service:a}),p({provider:v("facebook"),kind:v("page"),tasks:u(U(a))}),p({provider:v("instagram"),kind:v("professional_account"),username:a,loginMethod:MD,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(Y)}),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(Ge(/^[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(Ge(/^[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(Ge(/^[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(Ge(/^[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(Ge(/^[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(Ge(/^[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(Ge(/^[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(Ge(/^[A-Z]{3}$/)),timezone:a,status:G(["active","disabled","pending","closed","unknown"]),region:Gm,businessId:u(a),managerId:u(a)}),p({provider:v("openai_ads"),kind:v("ad_account"),externalId:a,currency:a.check(Ge(/^[A-Z]{3}$/)),timezone:a,status:G(["active","disabled","pending","closed","unknown"])})]);var tp=p({id:V,profileId:bt,connectionId:a.check(L()),provider:qe,accountKind:pr,parentAccountId:D(V),name:a,platformUserId:a,avatarUrl:D(a),enabled:Y,available:Y,details:Y4,readiness:gi,capabilities:U(xi)}).annotate({identifier:"ProviderAccount"}),Bb=p({accounts:U(tp)}),Z4=p({id:V,enabled:Y});var ih=a.check(L()),qb=p({attemptId:ih}),bu=p({accountId:V}),FD=p({connectionId:ih}),$b=p({attemptId:ih,url:a,expiresAt:u(a)}),X4=G(["provider_error","invalid_callback","account_mismatch","connection_changed","connection_failed"]),Kb={attemptId:ih,provider:qe},ND=pt([p({...Kb,status:G(["pending","denied","expired"])}),p({...Kb,status:v("connected"),accountIds:U(V)}),p({...Kb,status:v("failed"),reason:X4})]).annotate({identifier:"ConnectionStatus"}),BD=p({disconnected:v(!0)}),KD=p({deleted:v(!0)}),eJ=p({handle:Fr.check(be(1),oe(253)),appPassword:Fr.check(be(1),oe(256)),service:u(a.check(oe(2048),Ge(/^https:\/\//i)))}).annotate({identifier:"BlueskyConnect"}),rfe=p({...eJ.fields,accountId:u(V),profileId:u(bt)}).annotate({identifier:"BlueskySessionConnect"}),qD=p({used:M.check(Re(0)),limit:M.check(Mo(0)),windowSeconds:M.check(Mo(0))}).annotate({identifier:"InstagramPublishingLimit"}),sh=G(["music","original_sound"]),rp=a.check(Ge(/^\d{1,32}$/)),nfe=p({...bu.fields,audioId:rp}),ofe=p({audioType:sh,q:u(Fr.check(be(1),oe(200)))}),Wb=p({audioId:rp,audioType:sh,title:a,durationMs:u(M.check(Re(0))),artist:u(a),creator:u(a),previewUrl:u(a),coverUrl:u(a),instagramPreviewUrl:u(a)}).annotate({identifier:"InstagramAudio"}),$D=p({audio:U(Wb)});var zb=128000;var Qb=1250,tJ=300;var WD=500,rJ=100,nJ=1e5,Gb=50,oJ=100;var us=a.check(oe(zb)),zD=M.check(Re(1)),Sfe=p({workspaceId:de,isDraft:u(Y).annotate({description:"Filter to drafts (true) or submitted posts (false)."}),accountId:u(V).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(bt).annotate({description:"Filter to posts targeting any account in this workspace profile."}),...It.fields}),iJ=Lb,Cr={text:u(us),media:u(ds),scheduledAt:u(zm),queueId:u(a.check(L()).annotate({description:"Assign this destination to its connected account's schedule queue."}))},Iu=a.check(Ge(/^\d+$/)),sJ=U(a.check(Ge(/^[A-Z]{2}$/))).check(be(1),oe(25)),jD={firstComment:u(us),thread:u(U(a.check(be(1),oe(Qb))).check(oe(24))),nativeDraft:u(Y),countries:u(sJ)},QD=p({...jD,link:u(ba),textFormatPresetId:u(Iu),albumId:u(Iu)}).annotate({identifier:"FacebookFeedSettings"}),HD=p({...jD,title:u(us),isAiGenerated:u(Y),collaboratorPageIds:u(U(Iu).check(be(1),oe(10),zt((e)=>new Set(e).size===e.length||"Choose each collaborator Page once")))}).annotate({identifier:"FacebookReelSettings"}),VD=p({isAiGenerated:u(Y)}).annotate({identifier:"FacebookStorySettings"}),jb=a.check(Ge(/^@?[a-zA-Z0-9._]{1,30}$/)),GD=yr.check(Mr({minimum:0,maximum:1})),aJ=p({username:jb,x:u(GD),y:u(GD)}),JD={isAiGenerated:u(Y)},Hb={...JD,firstComment:u(us),commentsEnabled:u(Y),collaborators:u(U(jb).check(oe(3))),locationId:u(Iu),isPaidPartnership:u(Y),brandedContentSponsors:u(U(pt([Iu,jb])).check(be(1),oe(2)))},ah=u(U(aJ).check(oe(20))),YD=u(a.check(oe(1000))),ZD=p({...Hb,altText:YD,userTags:ah}).annotate({identifier:"InstagramFeedSettings"}),XD=p({...Hb,shareToFeed:u(Y),muteAudio:u(Y),audioConfiguration:u(p({audioId:rp,audioVolume:u(M.check(Mr({minimum:1,maximum:100}))),videoVolume:u(M.check(Mr({minimum:0,maximum:100})))})),coverUrl:u(ba),thumbOffset:u(M.check(Re(0))),audioName:u(a.check(oe(255))),trial:u(p({graduationStrategy:G(["MANUAL","SS_PERFORMANCE"])})),userTags:ah}).annotate({identifier:"InstagramReelSettings"}),eL=p({...Hb,muteAudio:u(Y),slides:u(U(p({altText:YD,userTags:ah})).check(oe(20)))}).annotate({identifier:"InstagramCarouselSettings"}),tL=p({...JD,muteAudio:u(Y),userTags:ah}).annotate({identifier:"InstagramStorySettings"}),rL=p({firstComment:u(a.check(be(1),oe(300))),thread:u(U(a.check(be(1),oe(300))).check(oe(24))),altText:u(a.check(oe(1000)))}).annotate({identifier:"BlueskyFeedSettings"}),nL=p({firstComment:u(us),thread:u(U(a.check(be(1),oe(Qb))).check(oe(24))),visibility:u(G(["PUBLIC","CONNECTIONS"])),altText:u(a.check(oe(4086))),documentTitle:u(Fr.check(be(1),oe(oJ)))}).annotate({identifier:"LinkedInFeedSettings"}),oL=p({title:u(a.check(be(1),oe(100))),description:u(a.check(be(1),oe(800))),link:u(ba),altText:u(a.check(oe(500)))}).annotate({identifier:"PinterestPinSettings"}),cJ=a.check(Ge(/^(?:r\/)?[A-Za-z0-9_]{2,21}$/)),iL=p({subreddit:cJ,title:a.check(be(1),oe(tJ)),link:u(ba),flairId:u(a.check(be(1),oe(100))),flairText:u(a.check(be(1),oe(64))),nsfw:u(Y),spoiler:u(Y),sendReplies:u(Y),thumbnailMediaId:u(xn),firstComment:u(us)}).annotate({identifier:"RedditFeedSettings"}),sL=p({contentType:u(G(["story","saved_story","spotlight"])),title:u(a.check(be(1),oe(45))),description:u(a.check(be(1),oe(160))),link:u(ba),locale:u(a.check(Ge(/^[a-z]{2}_[A-Z]{2}$/)))}).annotate({identifier:"SnapchatStorySettings"}),aL=p({title:a.check(be(1),oe(100)),description:u(a.check(oe(5000))),privacyStatus:G(["public","unlisted","private"]),tags:u(U(a.check(oe(100))).check(oe(30))),categoryId:u(a.check(Ge(/^\d{1,3}$/))),madeForKids:u(Y),containsSyntheticMedia:u(Y),thumbnailMediaId:u(xn),notifySubscribers:u(Y),license:u(G(["youtube","creativeCommon"])),embeddable:u(Y),publicStatsViewable:u(Y)}).annotate({identifier:"YouTubeVideoSettings"}),pJ=p({title:a.check(be(1),oe(rJ)),content:a.check(be(1),oe(nJ))}).annotate({identifier:"XArticleDraftSettings"}),cL=p({firstComment:u(us),thread:u(U(a.check(be(1),oe(280))).check(oe(24))),article:u(pJ)}).annotate({identifier:"XFeedSettings"}),pL=p({}).annotate({identifier:"GoogleBusinessFeedSettings"}),dL=p({firstComment:u(a.check(be(1),oe(WD))),thread:u(U(a.check(be(1),oe(WD))).check(oe(24)))}).annotate({identifier:"ThreadsFeedSettings"}),uL={privacy:G(["PUBLIC_TO_EVERYONE","MUTUAL_FOLLOW_FRIENDS","FOLLOWER_OF_CREATOR","SELF_ONLY"]),commercialDisclosure:u(G(["none","own_brand","paid_partnership"])),isAiGenerated:u(Y),disableComment:u(Y),nativeDraft:u(Y)},dJ=p({...uL,format:u(v("video")),disableDuet:u(Y),disableStitch:u(Y)}).annotate({identifier:"TikTokVideoSettings"}),uJ=p({...uL,format:v("photo"),title:u(a.check(oe(90))),coverIndex:u(M.check(Mr({minimum:0,maximum:iJ-1}))),autoAddMusic:u(Y)}).annotate({identifier:"TikTokPhotoSettings"}),lL=pt([dJ,uJ]).annotate({identifier:"TikTokFeedSettings"}),fL=pt([p({accountId:V,provider:v("bluesky"),placement:v("feed"),...Cr,settings:u(rL)}),p({accountId:V,provider:v("facebook"),placement:v("feed"),...Cr,settings:u(QD)}),p({accountId:V,provider:v("facebook"),placement:v("reel"),...Cr,settings:u(HD)}),p({accountId:V,provider:v("facebook"),placement:v("story"),...Cr,settings:u(VD)}),p({accountId:V,provider:v("instagram"),placement:v("feed"),...Cr,settings:u(ZD)}),p({accountId:V,provider:v("instagram"),placement:v("reel"),...Cr,settings:u(XD)}),p({accountId:V,provider:v("instagram"),placement:v("carousel"),...Cr,settings:u(eL)}),p({accountId:V,provider:v("instagram"),placement:v("story"),...Cr,settings:u(tL)}),p({accountId:V,provider:v("linkedin"),placement:v("feed"),...Cr,settings:u(nL)}),p({accountId:V,provider:v("threads"),placement:v("feed"),...Cr,settings:u(dL)}),p({accountId:V,provider:v("x"),placement:v("feed"),...Cr,settings:u(cL)}),p({accountId:V,provider:v("youtube"),placement:v("video"),...Cr,settings:aL}),p({accountId:V,provider:v("pinterest"),placement:v("pin"),...Cr,settings:u(oL)}),p({accountId:V,provider:v("reddit"),placement:v("feed"),...Cr,settings:iL}),p({accountId:V,provider:v("snapchat"),placement:v("story"),...Cr,settings:u(sL)}),p({accountId:V,provider:v("tiktok"),placement:v("feed"),...Cr,settings:u(lL)}),p({accountId:V,provider:v("google_business"),placement:v("feed"),...Cr,settings:u(pL)})]).annotate({identifier:"PublishTarget"}),bfe=rs(fL,{onExcessProperty:"error"}),lJ=a.check(be(1),oe(Qb)),fJ=U(lJ).check(be(1),oe(24)),mJ=pt([rL,QD,HD,VD,ZD,XD,eL,tL,nL,iL,sL,dL,cL,aL,oL,lL,pL]),hJ=p({accountId:V,provider:u(bn),placement:u(xr),text:u(us),thread:u(fJ),media:u(ds),scheduledAt:u(zm),queueId:u(a.check(L()).annotate({description:"Assign this destination to its connected account's schedule queue."})),settings:u(mJ)}).annotate({identifier:"CreatePostTarget"}),Vb=Fr.check(oe(zb)).pipe(IV({description:`At most ${zb} characters after trimming.`})),mL=U(fL).check(oe(50)),Jb={text:u(Vb),targets:u(mL),media:u(ds)},Ife=p(Jb).annotate({identifier:"PostContent"}),wfe=p({...Jb,scheduledAt:u(Ut)}).annotate({identifier:"PostPreflight"}),hL=p({text:u(Vb),platforms:u(U(bn).check(be(1),oe(Gb))),accounts:u(U(V).check(be(1),oe(Gb))),targets:u(U(hJ).check(be(1),oe(Gb))),media:u(ds),scheduledAt:u(Ut),publishNow:u(Y),isDraft:u(Y).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."}),yJ=p({...Jb,expectedRevision:u(zD)}).annotate({identifier:"UpdatePost"}),np=p({postId:Ot,isDraft:Y,revision:zD,text:Vb,media:ds,targets:mL,deliveries:U(Qm),status:jm,createdAt:a,updatedAt:a}).annotate({identifier:"Post"}),Efe=p({...np.fields,idempotencyKey:u(Vr)}).annotate({identifier:"PostCreated"}),kfe=pt([np,xa]).annotate({identifier:"PostCreateResult"}),yL=p({archived:v(!0)}),Afe=rs(yJ,{onExcessProperty:"error"}),gJ=p({accountId:V,provider:bn,placement:xr,canPublish:Y,caption:p({count:M,limit:M}),errors:U(uo),warnings:U(uo)}),gL=p({canPublish:Y,errors:U(uo),warnings:U(uo),targets:U(gJ),billing:u(fu)}).annotate({identifier:"PostValidation"});var fo=a.check(L()),jt=fo,xL=fo,ch=Fr.check(be(1),oe(100)),op=a.check(be(1),oe(100)),SL=M.check(Mr({minimum:0,maximum:6})),ph=a.check(Ge(/^(?:[01]\d|2[0-3]):[0-5]\d$/)),xJ=50,wn=a.check(Ge(/^\d{4}-\d{2}-\d{2}$/)),SJ=p({id:u(fo).annotate({description:"Round-trip an existing slot ID. Omit to create a new slot; a removed slot reports no ID."}),dayOfWeek:SL,time:ph}).annotate({identifier:"QueueSlotInput"}),bJ=p({id:fo,dayOfWeek:SL,time:ph}).annotate({identifier:"QueueSlot"}),bL=U(SJ).check(oe(xJ)),IJ=p({maxPerDay:D(M.check(Re(1))).annotate({description:"Null uses the provider limit."}),maxPending:M.check(Re(1)),minGapSeconds:M.check(Re(1)),horizonDays:M.check(Mr({minimum:1,maximum:90})),providerMaxPerDay:M.check(Re(1)),providerMinGapSeconds:M.check(Re(1))}).annotate({identifier:"QueueLimits"}),wJ=G(["active","paused","archived"]),ip=p({id:jt,workspaceId:de,accountId:V,name:ch,timezone:op,status:wJ,isDefault:Y.annotate({description:"The queue nextSlot assignment uses for this account when none is given."}),limits:IJ,slots:U(bJ),version:M.check(Re(1)),pausedAt:D(a),archivedAt:D(a),createdAt:a,updatedAt:a}).annotate({identifier:"Queue"}),IL=p({data:U(ip),...ze}).annotate({identifier:"QueueList"}),wL=p({archived:v(!0),version:M.check(Re(1))}).annotate({identifier:"QueueArchived"}),EL={maxPending:u(M.check(Mr({minimum:1,maximum:1000}))),minGapSeconds:u(M.check(Mr({minimum:60,maximum:604800}))),horizonDays:u(M.check(Mr({minimum:1,maximum:90})))},kL=p({accountId:V,name:ch,timezone:u(op).annotate({description:"An IANA time zone such as America/New_York. Defaults to the workspace default time zone."}),slots:bL,isDefault:u(Y).annotate({description:"Promote this queue to the account default. The first active queue is always the default."}),maxPerDay:u(M.check(Mr({minimum:1,maximum:1000}))).annotate({description:"Defaults to the provider limit."}),...EL}).annotate({identifier:"CreateQueue"}),AL=p({expectedVersion:M.check(Re(1)),name:u(ch),timezone:u(op),paused:u(Y),isDefault:u(Y).annotate({description:"Promote or demote the account default. Demoting the current default requires promoting another queue first."}),maxPerDay:u(D(M.check(Mr({minimum:1,maximum:1000})))),...EL}).annotate({identifier:"UpdateQueue"}),vL=p({expectedVersion:M.check(Re(1)),slots:bL}).annotate({identifier:"ReplaceQueueSlots"}),CL=G(["paused","archived","account_not_ready"]),TL=G(["max_per_day","max_pending"]),EJ=G(["occupied","capacity","skipped","blacked_out"]),OL=p({queueId:jt,slotId:D(fo),scheduledFor:a.annotate({description:"The resolved UTC instant."}),occurrenceDate:wn.annotate({description:"The local date the assignment counts toward."}),localDate:wn,localTime:ph,timezone:op,available:Y,unavailableReason:u(EJ)}).annotate({identifier:"QueueOccurrence"}),PL=p({queueId:jt,occurrence:D(OL),horizonEndsAt:a}).annotate({identifier:"QueueNextSlot"}),RL=p({queueId:jt,timezone:op,horizonEndsAt:a,occurrences:U(OL)}).annotate({identifier:"QueueSlotPreview"}),kJ=G(["published_now","cancelled","archived","submitted","rescheduled"]),Ufe=p({id:xL,queueId:jt,slotId:D(fo),postId:Ot,targetId:tr,attemptId:Kt,scheduledFor:a,occurrenceDate:wn,releasedAt:D(a),releaseReason:D(kJ)}).annotate({identifier:"QueueAssignment"}),wu=fo,dh=fo,_L=p({slotId:fo,occurrenceDate:wn}).annotate({identifier:"SkipQueueSlot"}),Yb=p({id:wu,queueId:jt,slotId:fo,occurrenceDate:wn,createdAt:a}).annotate({identifier:"QueueSkip"}),UL=p({data:U(Yb),...ze}).annotate({identifier:"QueueSkipList"}),DL=Fr.check(oe(200)).annotate({description:"Optional note for why these dates are unavailable."}),LL=p({startsOn:wn,endsOn:wn,reason:u(DL)}).annotate({identifier:"CreateQueueBlackout"}),Zb=p({id:dh,queueId:jt,startsOn:wn,endsOn:wn,reason:D(DL),createdAt:a}).annotate({identifier:"QueueBlackout"}),ML=p({data:U(Zb),...ze}).annotate({identifier:"QueueBlackoutList"}),Xb=p({deleted:v(!0)}).annotate({identifier:"QueueDeleted"});var AJ=G(["scheduled","queued"]),vJ=p({postId:Ot,targetId:tr,attemptId:Kt,accountId:V,provider:rr,placement:xr,queueId:u(jt),slotId:u(fo),assignmentId:u(xL),queueName:u(ch),scheduledFor:a.annotate({description:"The queued attempt's UTC instant."}),occurrenceDate:u(wn),timezone:u(op),localDate:u(wn),localTime:u(ph),status:AJ.annotate({description:"scheduled when scheduledFor is in the future; queued otherwise."}),textPreview:a.check(oe(160)).annotate({description:"Short single-line preview of the post text."})}).annotate({identifier:"ScheduleEntry"}),FL=p({data:U(vJ),...ze}).annotate({identifier:"ScheduleList"}),Dfe=p({results:U(p({index:M.check(Re(0)),accepted:u(xa),problem:u(a)}))}).annotate({identifier:"BulkPublishResult"}),CJ=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"]),NL=p({code:CJ,path:U(pt([a,M])),message:a}).annotate({identifier:"QueueIssue"}),Lfe=p({workspaceId:de,accountId:u(V),...It.fields}),Mfe=p({workspaceId:de}),Ffe=p({workspaceId:de,expectedVersion:Nm.check(au(),Re(1))}),Nfe=p({workspaceId:de,after:u(Ut)}),Bfe=p({workspaceId:de,count:Nm.check(au(),Mr({minimum:1,maximum:100})),after:u(Ut),includeOccupied:u(Y)}),Kfe=p({workspaceId:de,...It.fields}),qfe=p({workspaceId:de,...It.fields}),$fe=p({workspaceId:de,from:Ut.annotate({description:"Inclusive ISO start instant."}),to:Ut.annotate({description:"Inclusive ISO end instant, after from and within 90 days."}),accountId:u(V),queueId:u(jt),...It.fields}),Wfe=p({queueId:jt,skipId:wu}),Gfe=p({queueId:jt,blackoutId:dh});var TJ=G(["queued","running","succeeded","partial","failed","cancelled"]),OJ=G(["active","backoff","paused","inaccessible","deleted","complete"]),BL=a.check(L()),KL=a.check(L()),eI=p({id:BL,workspaceId:de,cursorId:KL,domain:a,provider:a,subjectKind:a,subjectId:a.check(L()),scope:a,status:TJ,startedAt:a,finishedAt:D(a),requestCount:M,pageCount:M,errorKind:D(a),providerStatus:D(M),retryAfterSeconds:D(M),detail:D(Gt(a,H)),createdAt:a}).annotate({identifier:"SyncRun"}),Hfe=p({cursorId:D(KL),state:OJ,lastSuccessAt:D(a),nextDueAt:D(a),syncRunId:D(BL)}).annotate({identifier:"SyncResource"});var ls="/api/v1/inbox",nme=`${ls}/conversations`,ome=`${ls}/comments`,ime=`${ls}/mentions`,PJ=`${ls}/reviews`,sme=`${PJ}/:reviewId`,ame=`${ls}/unread-count`,cme=`${ls}/capabilities`,pme=`${ls}/sync`,dme=`${ls}/attachments`,RJ=G(["conversation","message","comment_thread","comment","mention"]),qL=G(["inbox","message_request","spam","other"]),rI=G(["active","archived"]),nI=G(["inbound","outbound"]),_J=G(["received","pending","sending","sent","delivered","failed","unresolved","deleted"]),oI=G(["text","media","template","interactive","system","unknown"]),UJ=G(["post","comment","story","other"]),DJ=G(["image","video","audio","file","unknown"]),LJ=G(["pending","succeeded","failed","unresolved"]),MJ=G(["list","read","send","reply","edit","delete","hide","unhide","like","unlike"]),FJ=G(["webhook","polling","webhook_with_reconciliation"]),Eu=p({externalId:a,name:D(a),handle:D(a)}).annotate({identifier:"InboxParticipant"}),iI=G(["none","24_hours","x_dm_30_days"]),$L=p({open:Y,policy:iI,endsAt:D(a)}).annotate({identifier:"InboxReplyWindow"}),NJ=G(["fresh","stale","pending","failed"]),sI=p({status:NJ,observedAt:D(a),nextDueAt:D(a),syncRunId:D(a)}).annotate({identifier:"InboxFreshness"}),BJ=p({id:Sb,messageId:Nn,kind:DJ,mimeType:D(a),sizeBytes:D(M),width:D(M),height:D(M),durationSeconds:D(yr),url:a.annotate({description:"Workspace-scoped PubNio attachment URL. It never contains a provider URL or token."}),createdAt:a}).annotate({identifier:"InboxAttachment"}),aI=p({id:Nn,conversationId:Sn,accountId:V,provider:qe,direction:nI,state:_J,kind:oI,text:D(a),sender:Eu,replyToMessageId:D(Nn),attachments:U(BJ),actionId:D(hi),providerCreatedAt:a,providerUpdatedAt:D(a),readAt:D(a),deletedAt:D(a),createdAt:a}).annotate({identifier:"InboxMessage"}),uh=p({id:Sn,workspaceId:de,accountId:V,provider:qe,participant:Eu,folder:qL,status:rI,unreadCount:M,lastMessageAt:D(a),lastInboundAt:D(a),lastOutboundAt:D(a),lastMessagePreview:D(a),providerUrl:D(a),lastReadAt:D(a),archivedAt:D(a),replyWindow:$L,freshness:sI,createdAt:a}).annotate({identifier:"InboxConversation"}),lh=p({id:Qc,threadId:jc,accountId:V,provider:qe,parentCommentId:D(Qc),author:Eu,text:D(a),likeCount:M,replyCount:M,likedByAccount:Y,hidden:Y,canReply:Y,canHide:Y,canLike:Y,canDelete:Y,permalink:D(a),actionId:D(hi),providerCreatedAt:a,providerUpdatedAt:D(a),deletedAt:D(a),createdAt:a}).annotate({identifier:"InboxComment"}),WL=p({id:jc,workspaceId:de,accountId:V,provider:qe,providerPostId:a,postId:D(a.check(L())),permalink:D(a),caption:D(a),commentCount:M,unreadCount:M,lastCommentAt:D(a),lastReadAt:D(a),freshness:sI,createdAt:a}).annotate({identifier:"InboxCommentThread"}),KJ=p({id:Hc,workspaceId:de,accountId:V,provider:qe,kind:UJ,author:Eu,text:D(a),permalink:D(a),parentExternalId:D(a),canReply:Y,freshness:sI,providerCreatedAt:a,deletedAt:D(a),createdAt:a}).annotate({identifier:"InboxMention"}),qJ=G(["positive","negative"]),cI=p({id:Wm,workspaceId:de,accountId:V,provider:qe,locationExternalId:D(a),author:Eu,rating:D(M.check(Mr({minimum:1,maximum:5}))),recommendation:D(qJ),text:D(a),permalink:D(a),providerCreatedAt:a,providerUpdatedAt:D(a),repliedAt:D(a),replyText:D(a),canReply:Y,deletedAt:D(a),createdAt:a}).annotate({identifier:"InboxReview"}),GL=p({data:U(uh),...ze}).annotate({identifier:"InboxConversationList"}),zL=p({data:U(aI),...ze}).annotate({identifier:"InboxMessageList"}),jL=p({data:U(WL),...ze}).annotate({identifier:"InboxCommentThreadList"}),QL=p({thread:WL,data:U(lh),...ze}).annotate({identifier:"InboxCommentThreadDetail"}),HL=p({data:U(KJ),...ze}).annotate({identifier:"InboxMentionList"}),VL=p({data:U(cI),...ze}).annotate({identifier:"InboxReviewList"}),JL=p({unreadCount:M}).annotate({identifier:"InboxUnreadCount"}),tI=p({resource:RJ,supported:Y,operations:U(MJ),attachments:Y,quickReplies:Y,buttons:Y,readReceipts:Y,moderation:Y,syncMode:FJ,backfillDays:M,missingScopes:U(a),missingTasks:U(a)}).annotate({identifier:"InboxChannelCapability"}),$J=p({accountId:V,profileId:a.check(L()),provider:qe,accountKind:pr,enabled:Y,publishingReadiness:gi,accountCapabilities:U(xi),messaging:tI,comments:tI,mentions:tI,replyWindow:$L,lastSyncError:D(a),checkedAt:a}).annotate({identifier:"InboxAccountCapabilities"}),YL=p({accounts:U($J)}).annotate({identifier:"InboxCapabilities"}),ume=p({workspaceId:de,accountId:u(V)}),lme=p({workspaceId:de,conversationId:Sn}),fme=p({workspaceId:de,threadId:jc}),mme=p({workspaceId:de,commentId:Qc}),hme=p({workspaceId:de,mentionId:Hc}),yme=p({workspaceId:de,attachmentId:Sb}),gme=p({workspaceId:de,accountId:u(V),provider:u(qe),status:u(rI),folder:u(qL),unread:u(Y),search:u(a.check(oe(200))),...It.fields}),xme=p({workspaceId:de,order:u(G(["oldest","newest"])),...It.fields}),Sme=p({workspaceId:de,accountId:u(V),postId:u(a.check(L())),providerPostId:u(a),unread:u(Y),...It.fields}),bme=p({workspaceId:de,...It.fields}),Ime=p({workspaceId:de,accountId:u(V),provider:u(qe),...It.fields}),wme=p({workspaceId:de,accountId:u(V),includeDeleted:u(Y),...It.fields}),Eme=p({status:u(rI),read:u(Y)}).check(zt(({status:e,read:t})=>e!==void 0||t!==void 0||"Provide status or read.")),pI=Fr.check(be(1),oe(1e4)),kme=p({text:pI}).annotate({identifier:"SendInboxMessage"}),Ame=p({text:pI}).annotate({identifier:"ReplyInboxComment"}),vme=p({text:pI}).annotate({identifier:"ReplyInboxReview"}),Cme=p({hidden:u(Y),liked:u(Y)}).check(zt(({hidden:e,liked:t})=>e!==void 0!==(t!==void 0)||"Provide exactly one of hidden or liked for one provider call.")),Tme=p({"idempotency-key":Vr}),ZL=p({deleted:v(!0),actionId:hi}).annotate({identifier:"InboxDeleted"}),XL=p({mentionId:Hc,actionId:hi,status:LJ,providerResultId:D(a)}).annotate({identifier:"InboxMentionReply"}),Ome=p({workspaceId:de,accountId:u(V)}),eM=p({syncRunId:a.check(L()),status:eI.fields.status}).annotate({identifier:"InboxSyncAccepted"}),tM=p({syncRun:eI,counts:p({conversations:M,messages:M,commentThreads:M,comments:M,mentions:M})}).annotate({identifier:"InboxSyncStatus"}),Pme=p({workspaceId:de,syncRunId:a.check(L())});var ku=G(["post","comment"]);var WJ=Fr.check(be(1)),Fme=p({accountId:u(V).annotate({description:"Account that comments; derived when unambiguous."}),provider:u(bn),target:a.check(be(1),oe(2048)).annotate({description:"Provider ID or permalink."}),targetKind:u(ku),text:WJ.annotate({description:"Max 8000 characters."})}).annotate({identifier:"CreateComment"}),Nme=p({actionId:hi,idempotencyKey:Vr,commentId:a.check(be(1)),target:a,targetId:a.check(be(1)),targetKind:ku,accountId:V,provider:bn,status:v("posted"),permalink:u(a),replayed:Y}).annotate({identifier:"CommentCreated"});var GJ=["meta_ads","google_ads","reddit_ads","pinterest_ads","tiktok_ads","linkedin_ads","snapchat_ads","amazon_ads","openai_ads"],Pt=G(GJ);var zJ=G(["available","selected"]),dI=G(["active","disabled","pending","closed","unknown"]),jJ=p({provider:Pt,kind:v("ad_account"),externalId:a,currency:qn,timezone:a,status:dI,businessId:u(a),managerId:u(a),loginCustomerId:u(a),region:u(Gm)}).annotate({identifier:"AdAccountDetails"}),QJ=p({configured:Y,killSwitchActive:Y,monthlyCap:D(xt),dailyCap:D(xt),maxCampaignDailyBudget:D(xt),maxCampaignLifetimeBudget:D(xt),revision:M.check(Re(0))}).annotate({identifier:"AdAccountPolicy"}),mo=p({code:a,message:a,field:u(a),providerCode:u(a),missingScopes:u(U(a)),retryable:Y,providerMessage:u(a)}).annotate({identifier:"AdIssue"}),fs=G(["draft","paused","activating","active","pending_review","rejected","completed","archived","unknown"]),ms=p({amountMinor:M.check(Re(0)),currency:qn,kind:G(["daily","lifetime"])}).annotate({identifier:"AdBudget"}),mh=p({accountId:V,currency:qn,configured:Y,monthlyCap:D(xt),dailyCap:D(xt),maxCampaignDailyBudget:D(xt),maxCampaignLifetimeBudget:D(xt),killSwitchActive:Y,killSwitchAt:D(a),killSwitchReason:D(a),revision:M.check(Re(0)),updatedAt:a}).annotate({identifier:"AdSpendPolicy"}),fh=D(xt),Jme=p({expectedRevision:M.check(Re(0)),monthlyCap:fh,dailyCap:fh,maxCampaignDailyBudget:fh,maxCampaignLifetimeBudget:fh}).annotate({identifier:"AdSpendPolicyUpdate"}),Yme=p({active:Y,reason:u(a.check(oe(500)))}).annotate({identifier:"AdKillSwitchInput"}),rM=p({policy:mh,changed:Y,paused:p({campaigns:M.check(Re(0)),adGroups:M.check(Re(0)),ads:M.check(Re(0))}),nextAction:a}).annotate({identifier:"AdKillSwitchResult"}),hh=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"]),vu=G(["queued","preflight","creating","recording","reviewing","activating","succeeded","partial","failed","unresolved","cancelled"]),HJ=G(["queued","preflight","create","record","review","activate","finish"]),sn=p({id:Kn,accountId:V,kind:hh,status:vu,step:HJ,input:Gt(a,H),result:D(Gt(a,H)),issues:U(mo),attempts:M.check(Re(0)),canRetry:Y,nextAction:a,createdAt:a,updatedAt:a,startedAt:D(a),completedAt:D(a)}).annotate({identifier:"AdOperation"}),Zme=p({id:UU,accountId:V,idempotencyKey:a,intentHash:a,requestedByType:G(["user","api_key"]),requestedByUserId:D(ss),requestedByApiKeyId:D(ya),operationId:D(Kn),createdAt:a}).annotate({identifier:"AdRequest"}),Xme=p({id:_U,accountId:V,provider:Pt,postId:Ot,targetId:tr,actorAccountId:V,creativeId:D(Vc),campaignId:D(Bn),providerPostId:a,permalink:D(a),sourceHash:a,status:fs,revision:M.check(Re(1)),operationId:D(Kn),createdAt:a,updatedAt:a}).annotate({identifier:"AdBoost"}),ehe=p({expectedRevision:M.check(Mo(0)),confirmation:v("activate_spend")}).annotate({identifier:"AdCampaignActivationInput"}),the=p({expectedRevision:M.check(Mo(0))}).annotate({identifier:"AdCampaignPauseInput"}),rhe=p({expectedRevision:M.check(Mo(0))}).annotate({identifier:"AdCampaignArchiveInput"}),nhe=p({status:G(["active","paused","archived"]),expectedRevision:M.check(Mo(0))}).annotate({identifier:"AdEntityStatusUpdate"}),ohe=p({budget:ms,expectedRevision:M.check(Mo(0))}).annotate({identifier:"AdBudgetUpdateInput"}),VJ=p({headline:u(a.check(oe(255))),body:u(a.check(oe(2000))),callToAction:u(a.check(oe(64))),destinationUrl:u(a.check(oe(2048))),providerSettings:u(Gt(a,H))}).annotate({identifier:"AdAttachAdCreative"}),ihe=p({name:a.check(be(1),oe(255)),budget:u(ms),targeting:u(Gt(a,H)),providerSettings:u(Gt(a,H))}).annotate({identifier:"AdAdGroupCreateInput"}),she=p({actorAccountId:V,mediaId:a.check(L()),headline:u(a.check(oe(255))),body:u(a.check(oe(2000))),callToAction:u(a.check(oe(64))),destinationUrl:a.check(oe(2048)),providerSettings:u(Gt(a,H))}).annotate({identifier:"AdCreativeCreateInput"}),ahe=p({name:u(a.check(be(1),oe(255)))}).annotate({identifier:"AdCampaignDuplicateInput"}),che=p({name:a.check(be(1),oe(255)),creativeId:u(Vc),creative:u(VJ),providerSettings:u(Gt(a,H))}).annotate({identifier:"AdAttachAdInput"}),phe=p({"idempotency-key":Vr}),JJ=p({id:V,name:a,provider:Pt,accountKind:v("ad_account"),available:Y,selected:Y,details:jJ,readiness:gi,capabilities:U(xi),policy:QJ,issues:U(mo),createdAt:a,updatedAt:a}).annotate({identifier:"AdAccount"}),nM=p({data:U(JJ),...ze}).annotate({identifier:"AdAccountList"}),dhe=p({workspaceId:de,state:u(zJ),...It.fields}),uhe=p({workspaceId:de,provider:Pt,accountId:u(V)}),oM=p({attemptId:a.check(L()),provider:Pt,url:a,status:v("pending")}).annotate({identifier:"AdConnectLaunch"}),lhe=p({workspaceId:de,provider:v("openai_ads"),apiKey:a.check(be(1),oe(2048)),accountId:u(V),profileId:u(bt)}).annotate({identifier:"AdApiKeyConnectInput"}),iM=p({provider:v("openai_ads"),accountId:V,status:v("connected")}).annotate({identifier:"AdApiKeyConnectResult"}),fhe=p({workspaceId:de,accountId:V}),sM=p({accountId:V,selected:v(!0),campaignSyncQueued:Y,insightSyncQueued:Y}).annotate({identifier:"AdAccountSelection"}),aM=p({accountId:V,disconnected:v(!0),historyRetained:v(!0)}).annotate({identifier:"AdAccountDisconnected"}),cM=G(["awareness","traffic","engagement","leads","sales","app_promotion","video_views","reach","conversions","unknown"]),YJ=G(["provider","pubnio"]),pM=a,Au=Gt(a,H),Cu=p({startAt:D(Ut),endAt:D(Ut),timezone:a}).annotate({identifier:"AdSchedule"}),dM=p({valid:Y,accountId:V,provider:Pt,actorAccountId:D(V),currency:qn,budget:D(ms),schedule:D(Cu),killSwitchActive:Y,issues:U(mo),nextAction:a}).annotate({identifier:"AdValidation"}),ZJ=p({postId:Ot,postTargetId:u(tr),actorAccountId:u(V),budget:ms,schedule:u(Cu),targeting:u(Gt(a,H))}).annotate({identifier:"AdBoostDraft"}),mhe=p({workspaceId:de,accountId:V,...ZJ.fields}).annotate({identifier:"AdBoostInput"}),XJ=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"]),e3=p({budgetOwner:G(["campaign","ad_group","shared"]),maxAdGroups:u(M.check(Re(1))),budgetUnit:G(["minor","micros"]),hierarchy:U(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"}),t3=p({accountId:V,actorAccountId:u(V),budget:u(ms),schedule:u(Cu),providerSettings:u(Gt(a,H))}).annotate({identifier:"AdCampaignPlanTarget"}),r3=p({headline:u(a.check(oe(255))),body:u(a.check(oe(2000))),callToAction:u(a.check(oe(64))),destinationUrl:u(a.check(oe(2048))),media:u(ds),providerSettings:u(Gt(a,H))}).annotate({identifier:"AdCampaignPlanCreative"}),n3=p({name:a.check(be(1),oe(255)),creative:r3,providerSettings:u(Gt(a,H))}).annotate({identifier:"AdCampaignPlanAd"}),o3=p({name:a.check(be(1),oe(255)),budget:u(ms),targeting:u(Gt(a,H)),providerSettings:u(Gt(a,H)),ads:U(n3).check(be(1),oe(50))}).annotate({identifier:"AdCampaignPlanAdGroup"}),hhe=p({name:a.check(be(1),oe(255)),objective:cM,budget:u(ms),schedule:u(Cu),targets:U(t3).check(be(1),oe(50)),adGroups:U(o3).check(be(1),oe(50)),providerSettings:u(Gt(a,H))}).annotate({identifier:"AdCampaignPlan"}),i3=p({accountId:V,provider:u(Pt),name:u(a),currency:u(qn),budget:u(D(ms)),profile:u(e3),capabilities:u(U(XJ)),issues:U(mo)}).annotate({identifier:"AdCampaignPlanTargetValidation"}),uM=p({valid:Y,issues:U(mo),targets:U(i3)}).annotate({identifier:"AdCampaignPlanValidation"}),uI=G(["queued","creating","partial","succeeded","failed","unresolved"]),lM=p({accountId:V,provider:Pt,operationId:Kn,status:vu}).annotate({identifier:"AdCampaignPlanTargetAccepted"}),fM=p({planId:a.check(L()),status:uI,targets:U(lM)}).annotate({identifier:"AdCampaignPlanAccepted"}),s3=p({planId:a.check(L()),status:uI,createdAt:a,targets:U(lM)}).annotate({identifier:"AdCampaignPlanListRow"}),mM=p({data:U(s3),...ze}).annotate({identifier:"AdCampaignPlanList"}),a3=p({accountId:V,provider:Pt,operationId:Kn,campaignId:D(Bn),status:vu,issues:U(mo)}).annotate({identifier:"AdCampaignPlanTargetDetail"}),hM=p({planId:a.check(L()),status:uI,createdAt:a,targets:U(a3),issues:U(mo)}).annotate({identifier:"AdCampaignPlanDetail"}),yM=p({id:Bn,accountId:V,provider:Pt,externalId:a,name:a,objective:cM,status:fs,providerStatus:D(a),managed:YJ,revision:M.check(Re(1)),budget:D(xt),bidStrategy:D(pM),schedule:Cu,providerSettings:Au,syncedAt:a}).annotate({identifier:"AdCampaign"}),gM=p({id:as,campaignId:Bn,accountId:V,provider:Pt,kind:a,externalId:a,name:a,status:fs,providerStatus:D(a),revision:M.check(Re(1)),budget:D(xt),bidStrategy:D(pM),targeting:Au,providerSettings:Au,syncedAt:a}).annotate({identifier:"AdGroup"}),Tu=p({id:Vc,accountId:V,provider:Pt,externalId:a,kind:a,actorAccountId:D(V),mediaId:D(a.check(L())),headline:D(a),body:D(a),callToAction:D(a),destinationUrl:D(a),providerSettings:Au,syncedAt:a}).annotate({identifier:"AdCreative"}),lI=G(["campaign","ad_group","ad"]),c3=a,p3=G(["fresh","stale","pending","partial","unavailable"]),wa=p({status:p3,syncedAt:D(a),nextSyncAt:u(a),retryAfter:u(a)}).annotate({identifier:"AdFreshness"}),yhe=p({accountId:u(V),campaignId:u(Bn),adGroupId:u(as),adId:u(cs),from:u(a.check(Ge(/^\d{4}-\d{2}-\d{2}$/))),to:u(a.check(Ge(/^\d{4}-\d{2}-\d{2}$/))),level:u(lI),metrics:u(U(c3).check(oe(30))),cursor:It.fields.cursor,limit:u(M.check(Re(1),mU(100)))}).annotate({identifier:"AdInsightQuery"}),d3=p({id:RU,accountId:V,level:lI,campaignId:D(Bn),adGroupId:D(as),adId:D(cs),creativeId:D(Vc),date:a.check(Ge(/^\d{4}-\d{2}-\d{2}$/)),currency:qn,spend:xt,impressions:M.check(Re(0)),clicks:M.check(Re(0)),conversions:yr.check(Re(0)),revenue:xt,metrics:Gt(a,yr),syncedAt:a}).annotate({identifier:"AdInsightRow"}),u3=p({currency:qn,spend:xt,impressions:M.check(Re(0)),clicks:M.check(Re(0)),conversions:yr.check(Re(0)),revenue:xt,metrics:Gt(a,yr)}).annotate({identifier:"AdInsightTotals"}),fI=p({from:a,to:a,level:lI,totals:U(u3),rowCount:M.check(Re(0)),freshness:wa}).annotate({identifier:"AdInsightSummary"}),yh=p({id:cs,accountId:V,campaignId:Bn,adGroupId:as,creativeId:D(Vc),provider:Pt,externalId:a,name:a,format:D(a),status:fs,providerStatus:D(a),revision:M.check(Re(1)),providerSettings:Au,syncedAt:a,creative:u(D(Tu)),insights:u(D(fI))}).annotate({identifier:"Ad"}),mI=p({data:U(yM),...ze,freshness:wa}).annotate({identifier:"AdCampaignList"}),l3=p({...gM.fields,insights:u(D(fI))}).annotate({identifier:"AdGroupListRow"}),xM=p({data:U(l3),...ze,freshness:wa}).annotate({identifier:"AdGroupList"}),SM=p({data:U(yh),...ze,freshness:wa}).annotate({identifier:"AdList"}),bM=p({data:U(Tu),...ze,freshness:wa}).annotate({identifier:"AdCreativeList"}),hI=p({data:U(d3),summary:fI,...ze,freshness:wa}).annotate({identifier:"AdInsightList"}),f3=p({adGroup:gM,ads:U(p({ad:yh,creative:D(Tu)}))}).annotate({identifier:"AdTreeNode"}),m3=p({campaign:yM,adGroups:U(f3)}).annotate({identifier:"AdTreeCampaign"}),IM=p({data:U(m3),...ze,freshness:wa}).annotate({identifier:"AdTree"}),wM=p({accountId:V,queuedScopes:U(G(["campaigns","ads_insights"])),nextDueAt:a,retryAfterSeconds:u(M)}).annotate({identifier:"AdRefreshAccepted"});var yI="2026-12-02",EM=[yI],gh=G(EM),kM="PubNio-Version";var gI=Fr.check(be(1),oe(100)),xI=a.check(be(1),oe(128)),Ou=p({id:bt,workspaceId:de,name:gI,externalId:D(xI),isDefault:Y,archived:Y,createdAt:a,updatedAt:a}).annotate({identifier:"WorkspaceProfile"}),AM=p({data:U(Ou),...ze}).annotate({identifier:"ProfileList"}),Ehe=p({workspaceId:de,includeArchived:u(Y),...It.fields}),khe=p({name:gI,externalId:u(xI)}),Ahe=p({name:u(gI),externalId:u(D(xI))}).check(zt(({name:e,externalId:t})=>e!==void 0||t!==void 0||"Provide a name or external ID.")),vhe=p({profileId:bt}),vM=p({archived:v(!0)});var _he=G(["publishing","inbox","analytics","ads","scheduling","accounts","billing"]),xh=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 CM=p({id:a.check(L()),type:xh,version:v(1),timestamp:Ut.check(Ge(/Z$/)),workspaceId:de,profileId:u(bt)}).annotate({identifier:"WorkspaceEventEnvelope"});var SI=a.check(L()),h3=a.check(L()),TM=xh,RM=G([...xh.literals,"webhook.test"]),Qhe=p({eventTypes:U(RM)}).annotate({identifier:"WebhookEventTypes"}),Pe=CM.fields,Pu={postId:Ot,targetId:tr,attemptId:Kt,accountId:V,provider:rr,placement:xr,revision:lo},OM={providerRef:mu,url:u(a)},Sh={canRetry:Y,canReconcile:Y,nextAction:a},y3=G(["published","provider_draft","failed","unresolved","cancelled"]),g3={targetId:tr,accountId:V,provider:rr,placement:xr,status:y3,url:u(a),issue:u(hu)},x3={targetId:tr,accountId:V,scheduledAt:D(a)},bh={postId:Ot,revision:lo,targets:U(p(g3))},bI=G(["live","backfill"]),PM={messageId:Nn,conversationId:Sn,accountId:V,provider:rr,direction:nI,kind:oI,providerCreatedAt:a,freshness:bI},S3={threadId:jc,commentId:Qc,accountId:V,provider:rr,providerCreatedAt:a,freshness:bI},b3={mentionId:Hc,accountId:V,provider:rr,providerCreatedAt:a,freshness:bI},Ru={reviewId:Wm,accountId:V,provider:qe,locationId:u(a)},_u={accountId:V,provider:qe,accountKind:pr},Hhe=pt([p({...Pe,type:v("post.delivery.published"),data:p({...Pu,status:v("published"),...OM})}),p({...Pe,type:v("post.delivery.provider_draft"),data:p({...Pu,status:v("provider_draft"),...OM})}),p({...Pe,type:v("post.delivery.failed"),data:p({...Pu,status:v("failed"),issue:hu,canRetry:Sh.canRetry,nextAction:Sh.nextAction,providerRef:u(mu),url:u(a)})}),p({...Pe,type:v("post.delivery.unresolved"),data:p({...Pu,status:v("unresolved"),issue:hu,canReconcile:Sh.canReconcile,nextAction:Sh.nextAction,providerRef:u(mu),url:u(a)})}),p({...Pe,type:v("post.delivery.cancelled"),data:p({...Pu,status:v("cancelled")})}),p({...Pe,type:v("post.scheduled"),data:p({postId:Ot,revision:lo,targets:U(p(x3))})}),p({...Pe,type:v("schedule.assignment.changed"),data:p({postId:Ot,targetId:tr,accountId:V,attemptId:Kt,previousScheduledAt:D(a),scheduledAt:D(a),queueId:D(jt)})}),p({...Pe,type:v("post.published"),data:p(bh)}),p({...Pe,type:v("post.partial"),data:p(bh)}),p({...Pe,type:v("post.failed"),data:p(bh)}),p({...Pe,type:v("post.cancelled"),data:p(bh)}),p({...Pe,type:v("inbox.message.received"),data:p(PM)}),p({...Pe,type:v("inbox.message.sent"),data:p(PM)}),p({...Pe,type:v("inbox.comment.received"),data:p(S3)}),p({...Pe,type:v("inbox.review.new"),data:p(Ru)}),p({...Pe,type:v("inbox.review.updated"),data:p(Ru)}),p({...Pe,type:v("inbox.review.deleted"),data:p(Ru)}),p({...Pe,type:v("inbox.review.restored"),data:p(Ru)}),p({...Pe,type:v("inbox.review.replied"),data:p(Ru)}),p({...Pe,type:v("inbox.mention.received"),data:p(b3)}),p({...Pe,type:v("inbox.message.delivered"),data:p({messageIds:U(Nn),conversationId:u(Sn),accountId:V,provider:rr,deliveredAt:a})}),p({...Pe,type:v("inbox.message.read"),data:p({messageIds:U(Nn),conversationId:u(Sn),accountId:V,provider:rr,readAt:a})}),p({...Pe,type:v("inbox.message.edited"),data:p({messageId:Nn,conversationId:Sn,accountId:V,provider:rr})}),p({...Pe,type:v("inbox.message.deleted"),data:p({messageId:Nn,conversationId:Sn,accountId:V,provider:rr})}),p({...Pe,type:v("inbox.reaction.received"),data:p({messageId:u(Nn),conversationId:u(Sn),accountId:V,provider:rr,reaction:a,action:G(["add","remove"])})}),p({...Pe,type:v("inbox.referral.received"),data:p({messageId:u(Nn),conversationId:u(Sn),accountId:V,provider:rr,ref:a,source:a,adId:u(a)})}),p({...Pe,type:v("inbox.conversation.started"),data:p({conversationId:Sn,accountId:V,provider:rr,participantExternalId:a})}),p({...Pe,type:v("analytics.post.synced"),data:p({postId:Ot,accountId:V,provider:qe})}),p({...Pe,type:v("analytics.account.synced"),data:p({accountId:V,provider:qe})}),p({...Pe,type:v("ads.operation.succeeded"),data:p({operationId:Kn,accountId:V,kind:hh,status:G(["succeeded","partial"]),nextAction:a})}),p({...Pe,type:v("ads.operation.failed"),data:p({operationId:Kn,accountId:V,kind:hh,status:G(["failed","unresolved","cancelled"]),issue:mo,canRetry:Y,nextAction:a})}),p({...Pe,type:G(["ads.campaign.activated","ads.campaign.paused"]),data:p({operationId:Kn,accountId:V,campaignId:Bn})}),p({...Pe,type:v("ads.budget.changed"),data:pt([p({operationId:Kn,accountId:V,level:v("campaign"),campaignId:Bn}),p({operationId:Kn,accountId:V,level:v("ad_group"),adGroupId:as})])}),p({...Pe,type:v("ads.kill_switch.activated"),data:p({accountId:V,revision:M.check(Re(1)),reason:D(a),pausedCampaigns:M.check(Re(0)),pausedAdGroups:M.check(Re(0)),pausedAds:M.check(Re(0))})}),p({...Pe,type:v("ads.lead.received"),data:p({accountId:V,leadId:a,pageId:u(a),formId:u(a),adId:u(a),adGroupId:u(a)})}),p({...Pe,type:v("ads.campaign.status_changed"),data:p({accountId:V,campaignId:Bn,provider:Pt,status:fs})}),p({...Pe,type:v("ads.ad_group.status_changed"),data:p({accountId:V,adGroupId:as,provider:Pt,status:fs})}),p({...Pe,type:v("ads.ad.status_changed"),data:p({accountId:V,adId:cs,provider:Pt,status:fs})}),p({...Pe,type:v("ads.ad_account.status_changed"),data:p({accountId:V,provider:Pt,status:dI})}),p({...Pe,type:v("ads.ad.review.approved"),data:p({accountId:V,adId:cs,provider:Pt})}),p({...Pe,type:v("ads.ad.review.rejected"),data:p({accountId:V,adId:cs,provider:Pt})}),p({...Pe,type:v("ads.sync.failed"),data:p({accountId:V,provider:Pt})}),p({...Pe,type:v("ads.sync.recovered"),data:p({accountId:V,provider:Pt})}),p({...Pe,type:v("ads.initial_sync.completed"),data:p({accountId:V,provider:Pt})}),p({...Pe,type:v("account.connected"),data:p({..._u,reconnected:Y})}),p({...Pe,type:v("account.disconnected"),data:p({..._u,reason:G(["disconnected","expired","revoked","deauthorized"])})}),p({...Pe,type:v("account.permissions_changed"),data:p({..._u,missingScopes:U(a),missingTasks:U(a)})}),p({...Pe,type:v("account.restricted"),data:p({..._u,reason:v("publish_failures")})}),p({...Pe,type:v("account.recovered"),data:p(_u)}),p({...Pe,type:v("billing.subscription.updated"),data:p({plan:Zc,status:yu,interval:D(Hm),periodStart:a,periodEnd:a,cancelAtPeriodEnd:Y})}),p({...Pe,type:v("billing.credit.topped_up"),data:p({amountMicros:M,balanceAfterMicros:M,kind:Ym})}),p({...Pe,type:v("billing.credit.low"),data:p({balanceMicros:M,thresholdMicros:M})}),p({...Pe,type:v("billing.spend_cap.reached"),data:p({capMicros:M,periodSpendMicros:M,estimatedMicros:M})}),p({...Pe,type:v("billing.invoice.payment_failed"),data:p({invoiceId:a,amountDueMinor:M,hostedInvoiceUrl:D(a)})}),p({...Pe,type:v("webhook.test"),data:p({endpointId:lu})})]).annotate({identifier:"WebhookEvent"}),II=G(["publishing","inbox","analytics","ads","scheduling","accounts","billing"]),wI=Fr.check(be(1),oe(100)),_M=a.check(oe(2048)),I3=u(U(V)).annotate({description:"Only deliver events for these accounts. Empty or omitted means every account. Duplicates are ignored."}),w3=u(U(II)).annotate({description:"Drop every event in these families. Empty or omitted means no family is dropped. Duplicates are ignored."}),E3=u(D(U(V))).annotate({description:"Only deliver events for these accounts. Omit to keep the current filter; null or an empty array clears it to every account."}),k3=u(D(U(II))).annotate({description:"Drop every event in these families. Omit to keep the current denylist; null or an empty array clears it."}),EI=U(TM).check(be(1),oe(TM.literals.length),zt((e)=>new Set(e).size===e.length||"Choose each event type only once.")),A3=p({workspaceId:de,endpointId:lu}),Vhe=p({...A3.fields,deliveryId:SI}),Jhe=p({name:wI,url:_M,eventTypes:EI,enabled:u(Y),profileId:u(bt),accountIds:I3,disabledResourceGroups:w3}),Yhe=p({name:u(wI),eventTypes:u(EI),enabled:u(Y),profileId:u(D(bt)),accountIds:E3,disabledResourceGroups:k3}).check(zt((e)=>Object.keys(e).length>0||"Provide at least one endpoint change.")),Ih=p({id:lu,workspaceId:de,name:wI,eventTypes:EI,enabled:Y,profileId:D(bt),accountIds:U(V),disabledResourceGroups:U(II),apiVersion:gh,destinationOrigin:a,createdAt:a,updatedAt:a,deletedAt:D(a)}).annotate({identifier:"WebhookEndpoint"}),kI=p({...Ih.fields,url:D(_M)}),v3=a.check(Ge(/^whsec_[A-Za-z0-9+/]{43}=$/)),UM=p({endpoint:kI,secret:v3}),DM=p({data:U(Ih),...ze}).annotate({identifier:"WebhookEndpointList"}),LM=p({deleted:v(!0)}),MM=p({deliveryId:SI}),AI=G(["pending","sending","delivered","failed","cancelled"]),C3=G(["timeout","network","http_status","redirect","destination_rejected","configuration_unavailable","expired","attempts_exhausted"]),wh=p({id:SI,workspaceId:de,endpointId:lu,eventId:h3,eventType:RM,status:AI,attemptCount:M,createdAt:a,nextAttemptAt:D(a),lastAttemptAt:D(a),lastHttpStatus:D(M),lastError:D(C3),completedAt:D(a)}).annotate({identifier:"WebhookDelivery"}),FM=p({data:U(wh),...ze}).annotate({identifier:"WebhookDeliveryList"});var vI="~effect/http/HttpBody";class TI{[vI];constructor(){this[vI]=vI}[Xr](){return this.toJSON()}toString(){return rt(this,{ignoreToString:!0})}}class NM extends TI{_tag="Empty";toJSON(){return{_id:"effect/HttpBody",_tag:"Empty"}}}var BM=new NM;class CI extends TI{_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??=T3(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 KM=new TextEncoder,Eh=globalThis.Buffer,T3=Eh!==void 0?(e)=>Eh.from(e,"utf8"):(e)=>KM.encode(e),qM=(e,t)=>{if(typeof e!=="string")e=e===void 0?"":String(e);if(Eh!==void 0)return new CI(void 0,t??"text/plain",Eh.byteLength(e,"utf8"),e);let r=KM.encode(e);return new CI(r,t??"text/plain",r.length,e)},$M=(e,t)=>qM(JSON.stringify(e),t??"application/json");var O3=Object.getPrototypeOf(fa),GM=()=>Object.create(O3);var zM="~effect/http/HttpServerResponse";var R3=(e,t)=>{if(e?.contentType)return e.contentType;else if(e?.headers)return t["content-type"]};var jM=(e,t)=>{let r=t?.headers?R_(t.headers):fa;return U3({status:t?.status??200,statusText:t?.statusText,headers:r,cookies:t?.cookies,body:$M(e,R3(t,r))})};var _3={...qr,[zM]:zM,[$m]:!0,toJSON(){return{_id:"HttpServerResponse",status:this.status,statusText:this.statusText,headers:Qn(this.headers),cookies:this.cookies.toJSON(),body:this.body.toJSON()}}},U3=(e,t)=>{let r=Object.create(_3);if(r.status=e.status,r.statusText=e.statusText,r.cookies=e.cookies??T_,r.body=e.body??BM,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===fa?GM():__({...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??fa;return r};var HM="~effect/http/HttpServerRespondable";var kh="application/problem+json",JM="about:blank",Ea=(e)=>u(e).pipe(ub(()=>md)),YM=(e,t)=>fU(j(t))(e).pipe(ub(()=>fx(t))),OI=(e)=>YM(is(e),e),D3=dU(p({type:YM(a,JM),status:Ea(yr),title:Ea(a),detail:Ea(a),instance:Ea(a)}),[Gt(a,H)]);var L3={_tag:"Json",contentType:kh},ue=()=>(e,t,r,n)=>{let o=p({detail:Ea(a),instance:Ea(a),...r,type:is(t.type),status:OI(t.status),title:OI(t.title)}),i=cU(o),s=cu(e)(o,{description:t.title,httpApiStatus:t.status,"~httpApiEncoding":L3,...n});return Object.assign(s.prototype,{_tag:e,[$m]:t.status<500,[HM](){return De(i(this),(c)=>jM(c,{status:t.status,contentType:kh}))}}),Object.defineProperty(s.prototype,"message",{get(){return this.detail??t.title},configurable:!0}),s},M3=p({path:U(pt([a,yr])),message:a});class F3 extends ue()("UploadTooLarge",{type:"about:blank",status:413,title:"Content Too Large"}){}class XM extends ue()("AuthenticationRequired",{type:"urn:pubnio:problem:authentication-required",status:401,title:"Unauthorized"},{docUrl:u(a)}){}class eF extends ue()("Forbidden",{type:"urn:pubnio:problem:forbidden",status:403,title:"Forbidden"},{requiredScope:u(gu),docUrl:u(a)}){}class tF extends ue()("HumanActorRequired",{type:"urn:pubnio:problem:human-actor-required",status:403,title:"Human actor required"},{code:v("human_actor_required"),nextAction:a}){}class rF extends ue()("OwnerRequired",{type:"urn:pubnio:problem:owner-required",status:403,title:"Owner permission required"},{code:v("owner_required"),nextAction:a}){}class nF extends ue()("SeatLimitReached",{type:"urn:pubnio:problem:seat-limit-reached",status:402,title:"Seat limit reached"},{code:v("seat_limit_reached"),seatsUsed:M,seatsLimit:M,nextAction:a}){}class oF extends ue()("AlreadyMember",{type:"urn:pubnio:problem:already-member",status:409,title:"Already a workspace member"},{code:v("already_member"),nextAction:a}){}class iF extends ue()("InviteAlreadyPending",{type:"urn:pubnio:problem:invite-already-pending",status:409,title:"Invite already pending"},{code:v("invite_already_pending"),nextAction:a}){}class sF extends ue()("LastOwnerRequired",{type:"urn:pubnio:problem:last-owner-required",status:409,title:"Last owner required"},{code:v("last_owner_required"),nextAction:a}){}class aF extends ue()("InviteExpired",{type:"urn:pubnio:problem:invite-expired",status:410,title:"Invite expired"},{code:v("invite_expired"),nextAction:a}){}class cF extends ue()("InviteEmailMismatch",{type:"urn:pubnio:problem:invite-email-mismatch",status:403,title:"Invite email mismatch"},{code:v("invite_email_mismatch"),nextAction:a}){}class pF extends ue()("NotFound",{type:"urn:pubnio:problem:not-found",status:404,title:"Not Found"}){}class dF extends ue()("Conflict",{type:"urn:pubnio:problem:conflict",status:409,title:"Conflict"}){}class uF extends ue()("Unavailable",{type:"urn:pubnio:problem:unavailable",status:503,title:"Service Unavailable"}){}class lF extends ue()("UnsupportedApiVersion",{type:"urn:pubnio:problem:unsupported-api-version",status:400,title:"Unsupported API version"},{code:v("unsupported_api_version"),param:a,supportedVersions:U(gh),nextAction:a}){}class N3 extends ue()("InvalidCursor",{type:"urn:pubnio:problem:invalid-cursor",status:400,title:"Invalid cursor"},{code:u(v("invalid_cursor")),nextAction:u(a)}){}var Uu=p({accountId:V,name:a}).annotate({identifier:"ProblemCandidate"});class fF extends ue()("InvalidPublication",{type:"urn:pubnio:problem:invalid-publication",status:422,title:"Invalid publication"},{issues:U(uo),candidates:u(U(Uu)),code:u(v("invalid_publication")),nextAction:u(a)}){}var mF="x-request-id",hF=M3;class yF extends ue()("InternalFailure",{type:"urn:pubnio:problem:internal-error",status:500,title:"Internal Server Error"},{requestId:a.check(L())}){}class gF extends ue()("AttemptChanged",{type:"urn:pubnio:problem:attempt-changed",status:409,title:"Delivery attempt changed"},{currentAttemptId:Kt}){}class xF extends ue()("IdempotencyConflict",{type:"urn:pubnio:problem:idempotency-conflict",status:409,title:"Idempotency key already used"},{code:u(v("idempotency_conflict")),nextAction:u(a)}){}class SF extends ue()("AccountAmbiguous",{type:"urn:pubnio:problem:account-ambiguous",status:422,title:"Account ambiguous"},{code:v("account_ambiguous"),provider:qe,param:a,candidates:U(Uu),nextAction:a}){}class bF extends ue()("ProviderMismatch",{type:"urn:pubnio:problem:provider-mismatch",status:422,title:"Provider mismatch"},{code:v("provider_mismatch"),provider:qe,expectedProvider:qe,param:a,nextAction:a}){}class IF extends ue()("PublishAccountNotFound",{type:"urn:pubnio:problem:publish-account-not-found",status:422,title:"Publishing account not found"},{code:v("account_not_found"),provider:u(qe),accountId:u(V),param:a,candidates:u(U(Uu)),nextAction:a}){}class wF extends ue()("MediaUploadConflict",{type:"urn:pubnio:problem:media-upload-conflict",status:409,title:"Media upload conflict"},{reason:RD}){}class EF extends ue()("DestinationAlreadySubmitted",{type:"urn:pubnio:problem:destination-already-submitted",status:409,title:"Destination already submitted"}){}class kF extends ue()("DeliveryNotRetryable",{type:"urn:pubnio:problem:delivery-not-retryable",status:409,title:"Delivery cannot be retried"}){}class AF extends ue()("DeliveryNotReconcilable",{type:"urn:pubnio:problem:delivery-not-reconcilable",status:409,title:"Delivery cannot be reconciled"}){}class vF extends ue()("DeliveryScheduleLocked",{type:"urn:pubnio:problem:delivery-schedule-locked",status:409,title:"Delivery schedule cannot change"}){}class CF extends ue()("PostRevisionConflict",{type:"urn:pubnio:problem:post-revision-conflict",status:409,title:"Post revision changed"},{currentRevision:lo}){}class TF extends ue()("QueueNotFound",{type:"urn:pubnio:problem:queue-not-found",status:404,title:"Queue not found"}){}class OF extends ue()("QueueAlreadyExists",{type:"urn:pubnio:problem:queue-already-exists",status:409,title:"Queue already exists"}){}class PF extends ue()("QueueDefaultRequired",{type:"urn:pubnio:problem:queue-default-required",status:409,title:"Queue default required"},{code:v("queue_default_required"),accountId:V,nextAction:a}){}class RF extends ue()("QueueVersionConflict",{type:"urn:pubnio:problem:queue-version-conflict",status:409,title:"Queue version changed"},{currentVersion:M.check(Re(1))}){}class _F extends ue()("QueueUnavailable",{type:"urn:pubnio:problem:queue-unavailable",status:409,title:"Queue unavailable"},{reason:CL}){}class UF extends ue()("QueueCapacityReached",{type:"urn:pubnio:problem:queue-capacity-reached",status:409,title:"Queue capacity reached"},{reason:TL}){}class DF extends ue()("QueueNoSlotAvailable",{type:"urn:pubnio:problem:queue-no-slot-available",status:409,title:"No queue slot available"},{horizonEndsAt:a}){}class LF extends ue()("QueueSlotConflict",{type:"urn:pubnio:problem:queue-slot-conflict",status:409,title:"Queue slot conflict"},{scheduledAt:a,suggestedSlots:U(a)}){}class MF extends ue()("InvalidTimezone",{type:"urn:pubnio:problem:invalid-timezone",status:422,title:"Invalid time zone"},{code:v("invalid_timezone"),timezone:a,nextAction:a}){}class FF extends ue()("InvalidQueue",{type:"urn:pubnio:problem:invalid-queue",status:422,title:"Invalid queue"},{issues:U(NL)}){}class NF extends ue()("ScheduleRangeTooWide",{type:"urn:pubnio:problem:schedule-range-too-wide",status:422,title:"Schedule range too wide"},{maxDays:M}){}class BF extends ue()("WebhookTestRateLimited",{type:"urn:pubnio:problem:webhook-test-rate-limited",status:429,title:"Webhook test rate limited"}){}class KF extends ue()("WebhookDeliveryNotReplayable",{type:"urn:pubnio:problem:webhook-delivery-not-replayable",status:409,title:"Webhook delivery not replayable"},{code:v("webhook_delivery_not_replayable"),deliveryStatus:AI,nextAction:a}){}class qF extends ue()("ProviderPermissionRequired",{type:"urn:pubnio:problem:provider-permission-required",status:403,title:"Provider permission required"},{provider:qe,missingScopes:U(a),missingRoles:U(a),reason:u(a),reconnectRequired:u(Y)}){}class $F extends ue()("ProviderReconnectRequired",{type:"urn:pubnio:problem:provider-reconnect-required",status:409,title:"Provider reconnect required"},{provider:qe,missingScopes:U(a),reason:u(a)}){}class WF extends ue()("ProviderRateLimited",{type:"urn:pubnio:problem:provider-rate-limited",status:429,title:"Provider rate limited"},{provider:qe,retryAfterSeconds:u(M)}){}class GF extends ue()("ProviderUnavailable",{type:"urn:pubnio:problem:provider-unavailable",status:503,title:"Provider unavailable"},{provider:qe,retryAfterSeconds:u(M)}){}class zF extends ue()("CapabilityUnsupported",{type:"urn:pubnio:problem:capability-unsupported",status:422,title:"Capability unsupported"},{capability:yi,provider:qe,accountKind:pr}){}class jF extends ue()("AnalyticsRangeInvalid",{type:"urn:pubnio:problem:analytics-range-invalid",status:400,title:"Analytics range invalid"},{reason:G(["invalid_timezone","invalid_range","range_too_wide"])}){}class QF extends ue()("AnalyticsMetricUnsupported",{type:"urn:pubnio:problem:analytics-metric-unsupported",status:400,title:"Analytics metric unsupported"},{metrics:U(a),maxMetrics:u(M)}){}class HF extends ue()("AnalyticsRefreshConflict",{type:"urn:pubnio:problem:analytics-refresh-conflict",status:409,title:"Analytics refresh conflict"},{reason:G(["not_published","deleted","account_analytics_pending"])}){}class VF extends ue()("CapabilityUnverified",{type:"urn:pubnio:problem:capability-unverified",status:409,title:"Capability unverified"},{capability:yi,provider:qe}){}class JF extends ue()("InboxReplyWindowClosed",{type:"urn:pubnio:problem:inbox-reply-window-closed",status:409,title:"Inbox reply window closed"},{provider:qe,policy:iI,endsAt:D(a)}){}class YF extends ue()("InboxTargetChanged",{type:"urn:pubnio:problem:inbox-target-changed",status:409,title:"Inbox target changed"},{targetId:a,state:G(["deleted","changed","unsupported"])}){}class ZF extends ue()("InboxSyncInProgress",{type:"urn:pubnio:problem:inbox-sync-in-progress",status:409,title:"Inbox sync already running"},{syncRunId:a.check(L()),retryAfterSeconds:M}){}class XF extends ue()("InboxUnsupportedContent",{type:"urn:pubnio:problem:inbox-unsupported-content",status:422,title:"Inbox content unsupported"},{kind:G(["image","video","audio","file","text","unknown"]),capability:yi}){}var B3=[JF,YF,ZF,XF];class eN extends ue()("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(U(a))}){}class tN extends ue()("AdAccountNotSelected",{type:"urn:pubnio:problem:ad-account-not-selected",status:409,title:"Ad account not selected"},{accountId:a}){}class rN extends ue()("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(M)}){}class nN extends ue()("AdRefreshRateLimited",{type:"urn:pubnio:problem:ad-refresh-rate-limited",status:429,title:"Ad refresh rate limited"},{retryAfterSeconds:M.check(Re(0))}){}class oN extends ue()("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:M.check(Re(0)),actualRevision:M.check(Re(0)),nextAction:a}){}class iN extends ue()("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:xt,requested:xt,committed:xt,nextAction:a}){}class sN extends ue()("AdBudgetBelowMinimum",{type:"urn:pubnio:problem:ad-budget-below-minimum",status:422,title:"Ad budget is below the provider minimum"},{minimum:xt,requested:xt,nextAction:a}){}class aN extends ue()("AdCurrencyMismatch",{type:"urn:pubnio:problem:ad-currency-mismatch",status:422,title:"Ad currency does not match the account"},{expected:qn,actual:qn,nextAction:a}){}class cN extends ue()("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 pN extends ue()("AdKillSwitchActive",{type:"urn:pubnio:problem:ad-kill-switch-active",status:409,title:"Ad kill switch is active"},{accountId:V,activatedAt:D(a),reason:D(a),nextAction:a}){}class dN extends ue()("AdOperationNotRetryable",{type:"urn:pubnio:problem:ad-operation-not-retryable",status:409,title:"Ad operation is not retryable"},{operationStatus:vu,nextAction:a}){}class uN extends ue()("AdProviderRejected",{type:"urn:pubnio:problem:ad-provider-rejected",status:422,title:"Ad provider rejected the request"},{provider:Pt,code:a,retryable:Y,providerCode:u(a),providerMessage:u(a),issues:U(mo),nextAction:a}){}class lN extends ue()("InvalidAdRequest",{type:"urn:pubnio:problem:invalid-ad-request",status:400,title:"Invalid ad request"},{reason:a,field:u(a),nextAction:a}){}var K3=[qF,$F,WF,GF,zF,VF];class q3 extends ue()("CommentTargetInvalid",{type:"urn:pubnio:problem:comment-target-invalid",status:400,title:"Comment target invalid"},{code:v("comment_target_invalid"),reason:a,targetKind:u(ku),nextAction:a}){}class $3 extends ue()("CommentRejected",{type:"urn:pubnio:problem:comment-rejected",status:422,title:"Comment rejected"},{code:v("comment_rejected"),provider:qe,targetKind:ku,nextAction:a}){}class W3 extends ue()("CommentUnresolved",{type:"urn:pubnio:problem:comment-unresolved",status:409,title:"Comment outcome unresolved"},{code:v("comment_unresolved"),actionId:hi,nextAction:a}){}var G3=[fF,gF,xF,EF,kF,AF,vF,CF,SF,bF,IF],z3=[jF,QF,HF],j3=[eN,tN,rN,nN,oN,iN,sN,aN,cN,pN,dN,uN,lN],Q3=[TF,OF,PF,RF,_F,UF,DF,LF,FF,NF],H3=[MF];class fN extends ue()("InsufficientCredit",{type:"urn:pubnio:problem:insufficient-credit",status:402,title:"Insufficient prepaid credit"},{code:v("insufficient_credit"),balanceMicros:M,requiredMicros:M,fundingUrl:a,canManageBilling:Y,nextAction:a}){}class mN extends ue()("SpendCapReached",{type:"urn:pubnio:problem:spend-cap-reached",status:402,title:"Monthly spend cap reached"},{code:v("spend_cap_reached"),capMicros:M,periodSpendMicros:M,estimatedMicros:M,fundingUrl:a,canManageBilling:Y,nextAction:a}){}class hN extends ue()("BillingInactive",{type:"urn:pubnio:problem:billing-inactive",status:402,title:"Workspace billing is inactive"},{code:v("billing_inactive"),subscriptionStatus:yu,fundingUrl:a,canManageBilling:Y,nextAction:a}){}class yN extends ue()("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:M,maxMinor:M,nextAction:a}){}class gN extends ue()("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 xN extends ue()("BillingRevisionConflict",{type:"urn:pubnio:problem:billing-revision-conflict",status:409,title:"Billing settings changed concurrently"},{code:v("billing_revision_conflict"),expectedVersion:M,actualVersion:M,nextAction:a}){}class SN extends ue()("SubscriptionAlreadyActive",{type:"urn:pubnio:problem:subscription-already-active",status:409,title:"Subscription is already active"},{code:v("subscription_already_active"),plan:Zc,nextAction:a}){}class bN extends ue()("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 IN extends ue()("BillingCustomerMissing",{type:"urn:pubnio:problem:billing-customer-missing",status:409,title:"No billing customer exists yet"},{code:v("billing_customer_missing"),nextAction:a}){}class wN extends ue()("BillingProviderMismatch",{type:"urn:pubnio:problem:billing-provider-mismatch",status:409,title:"Workspace billing gateway mismatch"},{code:v("billing_provider_mismatch"),workspaceGateway:Vm,requestedGateway:Vm,nextAction:a}){}class EN extends ue()("BillingNotConfigured",{type:"urn:pubnio:problem:billing-not-configured",status:503,title:"Billing gateway is not configured"},{code:v("billing_not_configured"),nextAction:a}){}class kN extends ue()("BillingUnavailable",{type:"urn:pubnio:problem:billing-unavailable",status:503,title:"Billing gateway is temporarily unavailable"},{code:v("billing_unavailable"),retryable:Y,nextAction:a}){}var V3=[fN,mN,hN],J3=[...V3,yN,gN,xN,SN,bN,IN,wN,EN,kN],Y3=[nF,oF,iF,sF,aF,cF],AN=pt([XM,eF,tF,rF,pF,dF,uF,lF,...G3,...J3,...Q3,...H3,...Y3,...B3,...K3,...z3,...j3,yF,BF,KF,wF]);var ka=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"]),vN=G(["count","milliseconds","ratio"]),CN=G(["sum","unique","latest","weighted","ratio"]),TN=G(["post","account"]),Z3=G(["total","day"]),ON=G(["available","pending","unsupported","deprecated","renamed","permission_missing","access_pending","stale","deleted","private","not_applicable"]),X3=Gt(a,yr),Ah=p({key:ka,value:D(yr),availability:ON,reason:u(a),replacedBy:u(ka),renamedTo:u(ka),missingScopes:u(U(a)),reconnectRequired:u(Y),retryAfter:u(a),observedAt:u(a),total:u(D(yr)),breakdown:u(X3)}).annotate({identifier:"MetricReading"}),e6=p({key:ka,scopes:U(TN),unit:vN,aggregation:CN,definition:a}).annotate({identifier:"MetricDefinition"}),t6=p({key:ka,scope:TN,granularity:Z3,unit:vN,aggregation:CN,availability:ON,supported:Y,reason:u(a),renamedFrom:u(a),replacedBy:u(ka)}).annotate({identifier:"MetricCapability"}),r6=G(["ready","permission_required","access_pending","reconnect_required","disabled"]),n6=p({provider:qe,accountKinds:U(pr),placements:U(xr),metrics:U(t6),historyDays:M.check(Mo(0)),latencySeconds:M.check(Re(0)),firstAvailableAfterSeconds:M.check(Re(0)),requiredScopes:U(a),comments:Y}).annotate({identifier:"ProviderCapabilities"}),o6=p({accountId:V,provider:qe,accountKind:pr,readiness:r6,capability:xi,missingScopes:U(a),reconnectRequired:Y,accessPending:Y}).annotate({identifier:"AnalyticsAccountCapability"}),PN=p({metrics:U(e6),providers:U(n6),accounts:U(o6),checkedAt:a}).annotate({identifier:"AnalyticsCapabilities"}),i6=G(["fresh","stale","pending","partial","unavailable"]),vh=p({status:i6,observedAt:D(a),retryAfter:u(a)}).annotate({identifier:"AnalyticsFreshness"}),RN=p({from:a.check(Ge(/^\d{4}-\d{2}-\d{2}$/)),to:a.check(Ge(/^\d{4}-\d{2}-\d{2}$/)),timezone:v("UTC"),dayBasis:v("provider_utc")}).annotate({identifier:"AnalyticsDateRange"}),dge=G(["provider_daily","snapshot_delta","provider_lifetime","provider_total"]),_N=p({date:a.check(Ge(/^\d{4}-\d{2}-\d{2}$/)),metrics:U(Ah)}).annotate({identifier:"AnalyticsPoint"}),s6=G(["available","pending","unavailable"]),a6=p({targetId:tr,attemptId:D(Kt),accountId:V,provider:qe,placement:xr,providerPostId:D(a),publishedAt:D(a),state:s6,metrics:U(Ah),series:u(U(_N)),freshness:vh}).annotate({identifier:"PostAnalyticsTarget"}),RI=p({postId:Ot,workspaceId:de,range:RN,targets:U(a6),freshness:vh}).annotate({identifier:"PostAnalytics"}),c6=p({accountId:V,provider:qe,accountKind:pr,profileId:bt,name:a,metrics:U(Ah),freshness:vh}).annotate({identifier:"AnalyticsAccountSummary"}),UN=p({accountId:V,workspaceId:de,provider:qe,accountKind:pr,profileId:bt,name:a,range:RN,metrics:U(Ah),series:u(U(_N)),freshness:vh}).annotate({identifier:"AccountAnalytics"}),DN=p({data:U(c6),...ze}).annotate({identifier:"AccountAnalyticsList"}),uge=p({workspaceId:de,postId:u(Ot),targetId:u(tr),metrics:u(U(ka).check(oe(30)))}).check(zt(({postId:e,targetId:t})=>e!==void 0||t!==void 0||"Send postId or targetId to refresh a published post.")),p6=G(["queued","running","succeeded","failed","paused","deleted","inaccessible"]),_I=p({id:a.check(L()),workspaceId:de,subjectKind:a,subjectId:a.check(L()),status:p6,nextDueAt:D(a),lastSuccessAt:D(a),errorKind:D(a),createdAt:a}).annotate({identifier:"AnalyticsRefresh"});var LN={name:"@pubnio/sdk",version:"0.2.12",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:{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 MN({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 z=m.headers instanceof Headers?m.headers:new Headers(m.headers);if(g!==void 0)z.set("Last-Event-ID",g);try{let X={redirect:"follow",...m,body:m.serializedBody,headers:z,signal:x},I=new Request(S,X);if(e)I=await e(S,X);let pe=await(m.fetch??globalThis.fetch)(I);if(!pe.ok)throw Error(`SSE failed: ${pe.status} ${pe.statusText}`);if(!pe.body)throw Error("No body in SSE response");let K=pe.body.pipeThrough(new TextDecoderStream).getReader(),ee="",Q=()=>{try{K.cancel()}catch{}};x.addEventListener("abort",Q);try{while(!0){let{done:te,value:re}=await K.read();if(te)break;ee+=re,ee=ee.replace(/\r\n?/g,`
36
- `);let ae=ee.split(`
25
+ ${qT(e.cause,`${t} `)}
26
+ ${t}}`;return n},Tx="~effect/Fiber",vj={_A:Ce,_E:Ce},Cj=0,TT=(()=>{try{return globalThis.process?.getBuiltinModule?.("node:async_hooks")?.AsyncResource}catch{return}})(),$T=()=>TT===void 0?void 0:new TT("effect/Fiber"),Tf=()=>globalThis[xc];class Bc{constructor(e,t=!0){this.setContext(e),this.id=++Cj,this.currentOpCount=0,this.interruptible=t,this._stack=[],this._observers=void 0,this._exit=void 0,this._children=void 0,this._interruptedCause=void 0,this._yielded=void 0,this._autoYielded=!1,this._running=!1,this._deferredInterrupt=!1,this._parent=void 0,this._asyncContext=void 0,this.cache.runtimeMetrics?.recordFiberStart(this.context)}get[Tx](){return vj}get currentDispatcher(){return this._dispatcher??=this.cache.scheduler.makeDispatcher()}getRef(e){return qC(this.context,e)}addObserver(e){if(this._exit)return e(this._exit),pi;return(this._observers??=[]).push(e),()=>this.removeObserver(e)}removeObserver(e){if(this._exit||this._observers===void 0)return;let t=this._observers.indexOf(e);if(t>=0)this._observers.splice(t,1)}interruptUnsafe(e,t){if(this._exit)return;let r=Fc(e);if(this.cache.stackFrame)r=ef(r,new Map([[tf,this.cache.stackFrame]]));if(t)r=ef(r,t.mapUnsafe);if(this._interruptedCause=this._interruptedCause?Eg(this._interruptedCause,r):r,this.interruptible)if(this._running)this._deferredInterrupt=!0;else this.evaluate(Ct(this._interruptedCause))}pollUnsafe(){return this._exit}evaluate(e){if(this._exit)return;else if(this._asyncContext!==void 0){let o=this._asyncContext;this._asyncContext=void 0;try{return o.runInAsyncScope(this.evaluate,this,e)}finally{o.emitDestroy()}}else if(this._yielded!==void 0){let o=this._yielded;this._yielded=void 0,o()}let t=this.runLoop(e);if(t===na){this._asyncContext=$T();return}let r=hx.interruptChildren&&hx.interruptChildren(this,t);if(r!==void 0)return this.interruptible=!1,this.evaluate(r);if(this._exit=t,this.cache.runtimeMetrics?.recordFiberEnd(this.context,this._exit),this._parent)this._parent._children?.delete(this),this._parent=void 0;if(this._observers!==void 0){let o=this._observers;this._observers=void 0;for(let i=0;i<o.length;i++)o[i](t)}this._stack.length=0,this._children=void 0,this.context=Gr();let n=this.cache;if(n.span!==void 0||n.stackFrame!==void 0)this.cache={...n,span:void 0,stackFrame:void 0}}runLoop(e){let t=globalThis[xc];globalThis[xc]=this;let r=this._running;this._running=!0;let n=!1,o=this._autoYielded;this._autoYielded=!1;let i=e;this.currentOpCount=o?1:0;try{while(!0)try{if(this._deferredInterrupt)this._deferredInterrupt=!1,i=Ct(this._interruptedCause);this.currentOpCount++;let s=this.cache;if(!o&&!n&&!s.preventYield&&s.scheduler.shouldYield(this))n=!0,i=this.yieldNow(i,0,!0);else o=!1,i=s.tracerContext?s.tracerContext(i,this):i[xt](this);if(i===na){let c=this._yielded;if(ta in c)return this._deferredInterrupt=!1,this._yielded=void 0,c;else if(this._deferredInterrupt){this._yielded=void 0,c();continue}return na}}catch(s){if(!jt(i,xt))return Nn(`Fiber.runLoop: Not a valid effect: ${String(i)}`);i=Nn(s)}}finally{this._running=r,globalThis[xc]=t}}getCont(e){if(this._deferredInterrupt)return this._deferredInterrupt=!1,Oj;while(!0){let t=this._stack.pop();if(!t)return;let r=t[ra];if(r!==void 0){let n=r.call(t,this);if(n)return n[e]=n,n}if(t[e])return t}}succeedWith(e){if((++this.currentOpCount&Pj-1)===0)return ft(e);let t=this.getCont(sr);return t?t[sr](e,this):this.yieldWith(ft(e))}yieldWith(e){return this._yielded=e,na}yieldNow(e,t=0,r=!1){let n=!1;return this.currentDispatcher.scheduleTask(()=>{if(n)return;this._autoYielded=r,this.evaluate(e)},t),this.yieldWith(()=>{n=!0})}children(){return this._children??=new Set}pipe(){return nt(this,arguments)}setContext(e){let t=this.context;if(this.context=e,t!==void 0&&BC(t,e))return;let r=e.cacheRoot,n=r._fiberCache??=Tj(e);if(this.cache?.scheduler!==n.scheduler)this._dispatcher=void 0;this.cache=n}get currentSpanLocal(){let e=this.cache.span;return e?._tag==="Span"?e:void 0}}var Tj=(e)=>{let t=(n)=>Vg(e,n),r=t(hC);return{scheduler:t(nf)??lT(),tracer:r,tracerContext:r?.context,tracerEnabled:t(Cg)??Og,span:t(yC),logLevel:t(Tg)??Pg,minimumLogLevel:t(sf)??af,stackFrame:t(of),runtimeMetrics:t(gC),maxOpsBeforeYield:t(fC)??xC,preventYield:t(mC)??SC}},Oj={[sr](e,t){return Ct(t._interruptedCause)},[yn](e,t){return Ct(t._interruptedCause)}},Pj=32,hx={interruptChildren:void 0},Kc=(e)=>{if(!e.cache.stackFrame)return;let t=new Map;return t.set(vg.key,e.cache.stackFrame),sa(t)},Rj=(e,t)=>{if(e._children===void 0||e._children.size===0)return;return Vt(bd(e._children),()=>t)},WT=(e)=>{let t=e;if(t._exit)return dt(t._exit);return nn((r)=>{if(t._exit)return r(dt(t._exit));return It(e.addObserver((n)=>r(dt(n))))})},Ox=(e)=>nn((t)=>{let r=e[Symbol.iterator](),n=[],o=void 0;function i(){let s=r.next();while(!s.done){if(s.value._exit){n.push(s.value._exit),s=r.next();continue}o=s.value.addObserver((c)=>{n.push(c),i()});return}t(dt(n))}return i(),It(()=>o?.())}),wf=(e)=>{let t=e;if(t._exit)return t._exit;return nn((r)=>{if(t._exit)return r(t._exit);return It(e.addObserver(r))})};var Of=(e)=>tt((t)=>GT(e,t.id)),GT=W((e)=>jt(e[0],Tx),(e,t,r)=>tt((n)=>{let o=Kc(n);return o=o&&r?_c(o,r):o??r,e.interruptUnsafe(t,o),Uf(WT(e))})),bd=(e)=>tt((t)=>{let r=Kc(t),n=pa();for(let o of e)o.interruptUnsafe(t.id,r),n.push(o);return Uf(Ox(n))});var dt=ft,Ct=ar,rs=lo,It=Fn({op:"Sync",[xt](e){let t=this[qe],r=t(),n=e.getCont(sr);return n?n[sr](r,e):e.yieldWith(ft(r))}}),St=Fn({op:"Suspend",[xt](e){let t=this[qe];return t()}});var jT=md({onFailure:rs,onSuccess:dt});var zT=Fn({op:"Yield",[xt](e){return e.yieldNow(jr,this[qe]??0)}}),Px=zT(0),QT=(e)=>dt(Le(e)),HT=dt(xe());var VT=(e)=>St(()=>Ct(e())),qc=(e)=>Nn(e),JT=(e)=>St(()=>rs(e())),Et=dt(void 0);var YT=(e)=>{let t=typeof e==="function"?e:e.try,r=typeof e==="function"?(n)=>new Od(n,"An error occurred in Effect.try"):e.catch;return St(()=>{try{return dt(t())}catch(n){return rs(r(n))}})};var ZT=(e)=>{let t=typeof e==="function"?e:e.try,r=typeof e==="function"?(n)=>new Od(n,"An error occurred in Effect.tryPromise"):e.catch;return XT(function(n,o){let i=(s)=>St(()=>{try{return rs(id(()=>r(s)))}catch(c){return qc(c)}});try{t(o).then((s)=>n(dt(s)),(s)=>n(i(s)))}catch(s){n(i(s))}},t.length!==0)};var XT=function(){let e=Mn({op:"Async",[xt](r){let n=!1,o=!1,i=this.withSignal?new AbortController:void 0,s=this.register.call(r.cache.scheduler,(c)=>{if(n)return;if(n=!0,o)r.evaluate(c);else o=c},i?.signal);if(o!==!1)return o;if(o=!0,r.yieldWith(()=>{n=!0}),i===void 0&&s===void 0)return na;return r._stack.push(_j(()=>(n=!0,i?.abort(),s??jr))),na}}),t=function(r,n){this.register=r,this.withSignal=n};return t.prototype=e,function(r,n){return new t(r,n)}}(),_j=Fn({op:"AsyncFinalizer",[ra](e){if(e.interruptible)e.interruptible=!1,e._stack.push(vd)},[yn](e,t){return Ax(e)?Vt(FO(ar(e),this[qe]()),()=>Ct(e)):Ct(e)}}),nn=(e)=>XT(e,e.length>=2),Pf=nn(pi),eO=(...e)=>{if(e.length===1){let n=e[0];return St(()=>fa(n()))}let[t,r]=e;return St(()=>fa(r.call(t.self)))},Rx=(e,t)=>typeof e==="function"?e:t.shift().bind(e.self),_x=(e,...t)=>{let r=Rx(e,t),n=t.length===0?function(){return St(()=>fa(r.apply(this,arguments)))}:function(){let o=St(()=>fa(r.apply(this,arguments)));for(let i=0;i<t.length;i++)o=t[i](o,...arguments);return o};return Ux(r.length,n)},Ux=(e,t)=>Object.defineProperty(t,"length",{value:e,configurable:!0}),OT=CT(2),tO=function(){let e=typeof arguments[0]==="string",t=e?arguments[0]:"Effect.fn",r=e?arguments[1]:void 0,n=ui(),o;if(n!==0)tn(2),o=new globalThis.Error,tn(n);if(e)return(i,...s)=>PT(t,i,o,s,e,r);return PT(t,arguments[0],o,Array.prototype.slice.call(arguments,1),e,r)},PT=(e,t,r,n,o,i)=>{let s=Rx(t,n),c=`${e} (definition)`,d=r?OT(()=>r.stack):Uo,x=(f)=>(g)=>({name:e,stack:f?OT(()=>f.stack):Uo,parent:{name:c,stack:d,parent:g}});return Ux(s.length,function(...f){let g=St(()=>{let A=s.apply(this,arguments);return zt(A)?A:fa(A)});for(let A=0;A<n.length;A++)g=n[A](g,...f);if(!zt(g))return g;let I=ui(),w;if(I!==0)tn(2),w=new globalThis.Error,tn(I);return IO(o?uP(e,i,(A)=>nz(g,A)):g,ax,x(w))})},rO=(e,...t)=>{let r=Rx(e,t);return Ux(r.length,t.length===0?function(){return RT(()=>r.apply(this,arguments))}:function(){let n=RT(()=>r.apply(this,arguments));for(let o of t)n=o(n,...arguments);return n})},RT=(e)=>{try{let t=e(),r=void 0;while(!0){let n=t.next(r);if(n.done)return dt(n.value);let o=n.value;if(o&&o._tag==="Success"){r=o.value;continue}else if(o&&o._tag==="Failure")return n.value;else{let i=!0;return St(()=>{if(i)return i=!1,Vt(n.value,(s)=>fa(t,s));else return St(()=>fa(e()))})}}}catch(t){return qc(t)}},fa=function(){let e=Mn({op:"Iterator",[sr](r,n){let o=this.iterator;while(!0){let i=o.next(r);if(i.done)return dt(i.value);if(!mt(i.value))return n._stack.push(this),i.value;else if(i.value._tag==="Failure")return i.value;r=i.value.value}},[xt](r){return this[sr](this.initial,r)}}),t=function(r,n){this.iterator=r,this.initial=n};return t.prototype=e,function(r,n){return new t(r,n)}}(),$c=W(2,(e,t)=>new gi(e,Dx,dt(t))),Rf=function(e){return e._stack.push(this),this[qe]},Uj=Mn({op:"OnSuccess",[xt]:Rf}),gi=function(e,t,r){this[qe]=e,this[sr]=t,this.payload=r};gi.prototype=Uj;var Dx=function(){return this.payload},nO=function(e,t){return t.succeedWith(this.payload)},Lx=(()=>{let e=ui();if(e===0)return!1;let t="~effect/Effect/stackProbe",r={[t]:function(){return Error()}};tn(1);let n=r[t]();return tn(e),n.stack?.includes("[as "+t+"]")===!0})(),Dj=function(e,t){let r=this.payload;return t.succeedWith(Lx?r(e):id(()=>r(e)))},oO=function(e){let t=this.payload;return t(e)},Lj=function(e){let t=this.payload;return new gi(t(e),nO,e)},Mj=function(e){return new gi(this.payload,nO,e)};var ma=W(2,(e,t)=>new gi(e,zt(t)?Dx:oO,t)),_f=W(2,(e,t)=>new gi(e,zt(t)?Mj:Lj,t)),Uf=(e)=>new gi(e,Dx,jr);var iO=(e,t)=>tt((r)=>{let n=new Set;return Ad(r,()=>n.size===0?void 0:bd(n)),nn((o)=>{let i=!1,s=0;for(let c of e){if(i)break;let d=s++,x=new Bc(r.context);if(n.add(x),x.addObserver((f)=>{n.delete(x);let g=!i;if(i=!0,o(f),g)Fj(n,r),t?.onWinner?.({fiber:x,index:d,parentFiber:r})}),i)x.interruptUnsafe(r.id,Kc(r));else x.evaluate(c);if(i)break}})}),Fj=(e,t)=>{let r=Kc(t);for(let n of e)n.interruptUnsafe(t.id,r)};var sO=W((e)=>zt(e[1]),(e,t,r)=>iO([e,t],r)),Vt=W(2,(e,t)=>new gi(e,oO,t));var mt=(e)=>e[ta]!==void 0,aO=W(2,(e,t)=>{if(mt(e))return e._tag==="Success"?t(e.value):e;return Vt(e,t)});var qn=W(2,(e,t)=>new gi(e,Dj,t)),cO=W(2,(e,t)=>mt(e)?hO(e,t):qn(e,t)),pO=W(2,(e,t)=>mt(e)?yO(e,t):Bx(e,t)),dO=W(2,(e,t)=>mt(e)?gO(e,t):PO(e,t)),uO=W(2,(e,t)=>{if(mt(e)){if(e._tag==="Success")return e;let r=ts(e.cause);if(Ht(r))return ar(r.failure);return t(r.success)}return Gc(e,t)}),Mx=(e)=>ar(Fc(e)),Df=(e)=>e._tag==="Success";var lO=(e)=>e._tag==="Failure";var fO=(e)=>e._tag==="Failure"?vt(e.cause):Mt(e);var mO=(e)=>e._tag==="Failure"&&Ax(e.cause);var jr=ft(void 0),hO=W(2,(e,t)=>e._tag==="Success"?ft(t(e.value)):e),yO=W(2,(e,t)=>{if(e._tag==="Success")return e;return ar(Nc(e.cause,t))}),gO=W(2,(e,t)=>{if(e._tag==="Success")return ft(t.onSuccess(e.value));return ar(Nc(e.cause,t.onFailure))});var xO=W(2,(e,t)=>Df(e)?t:e);var SO=(e)=>{let t=[];for(let r of e)if(r._tag==="Failure")t.push(...r.cause.reasons);return t.length===0?jr:ar(fi(t))};var bO=(e)=>tt((t)=>dt($C(t.context,e)));var Lf=W(2,(e,t)=>tt((r)=>{let n=r.context,o=t(n);if(n===o)return e;return r.setContext(o),Ad(r,()=>{r.setContext(n);return}),e})),IO=W(3,(e,t,r)=>Lf(e,(n)=>{let o=Rc(n,t),i=r(o);if(o===i)return n;return Bn(n,t,i)}));var EO=()=>Nj,Nj=tt((e)=>dt(e.context)),Mf=(e)=>tt((t)=>e(t.context));var xi=W(2,(e,t)=>{if(mt(e))return e;return Lf(e,_c(t))}),Wc=function(){if(arguments.length===1)return W(2,(e,t)=>_T(e,arguments[0],t));return W(3,(e,t,r)=>_T(e,t,r)).apply(this,arguments)},_T=(e,t,r)=>Lf(e,Bn(t,r));var kO=W((e)=>zt(e[1]),(e,t,r,n)=>n?.concurrent?qn(Vx([e,t],{concurrency:2}),([o,i])=>r(o,i)):Vt(e,(o)=>qn(t,(i)=>r(o,i))));var wO=W((e)=>zt(e[0]),(e,t)=>Cd({while:_o,body:hn(t?.disableYield?e:Vt(e,(r)=>Px)),step:pi})),Si=W(2,(e,t)=>new AO(e,t.length!==1?(r)=>t(r):t)),Bj=Mn({op:"OnFailure",[xt]:Rf}),AO=function(e,t){this[qe]=e,this[yn]=t};AO.prototype=Bj;var Ff=W(3,(e,t,r)=>Si(e,(n)=>{let o=t(n);return Ht(o)?Ct(o.failure):r(o.success,n)})),Gc=W(2,(e,t)=>Ff(e,ts,(r)=>t(r)));var vO=W(3,(e,t,r)=>Si(e,(n)=>{let o=t(n);if(Ht(o))return Ct(n);return ma(r(o.success,n),Ct(n))})),CO=W(2,(e,t)=>vO(e,Ex,(r)=>t(r)));var Nf=W((e)=>zt(e[0]),(e,t,r,n)=>Si(e,(o)=>{let i=ts(o);if(Ht(i))return Ct(i.failure);if(!t(i.success))return n?n(i.success):Ct(o);return r(i.success)})),Fx=W((e)=>zt(e[0]),(e,t,r,n)=>Si(e,(o)=>{let i=ts(o);if(Ht(i))return Ct(i.failure);let s=t(i.success);if(Ht(s))return n?n(s.failure):Ct(o);return r(s.success)})),Nx=W((e)=>zt(e[0]),(e,t,r,n)=>{let o=Array.isArray(t)?(i)=>jt(i,"_tag")&&t.includes(i._tag):Ln(t);return Nf(e,o,r,n)}),TO=W((e)=>zt(e[0]),(e,t,r)=>{let n;return Fx(e,(o)=>(n??=Object.keys(t),jt(o,"_tag")&&Lo(o._tag)&&n.includes(o._tag)?vt(o):Mt(o)),(o)=>t[o._tag](o),r)}),OO=W((e)=>zt(e[0]),(e,t,r,n,o)=>Nf(e,(i)=>Ln(i,t)&&jt(i,"reason")&&(o!==void 0||Ln(i.reason,r)),(i)=>{let s=i.reason;if(Ln(s,r))return n(s,i);return o?o(s,i):rs(i)}));var Bx=W(2,(e,t)=>Si(e,(r)=>Ct(Nc(r,t)))),PO=W(2,(e,t)=>qo(e,{onFailure:(r)=>Ct(Nc(r,t.onFailure)),onSuccess:(r)=>It(()=>t.onSuccess(r))})),Kx=(e)=>Gc(e,qc),RO=W(2,(e,t)=>Gc(e,(r)=>It(()=>t(r))));var _O=(e)=>e==="Unhandled"?(...t)=>tt((r)=>{let n=r.getRef(dx);return n===void 0?Et:Ix(n)(...t)}):Ix(e===!0?void 0:e),UO=W((e)=>zt(e[0]),(e,t)=>{if(!t?.log)return qx(e,{onFailure:(n)=>Et,onSuccess:(n)=>Et});let r=_O(t.log);return qo(e,{onFailure(n){let o=ts(n);return Ht(o)?Ct(o.failure):t.message===void 0?r(n):r(t.message,n)},onSuccess:(n)=>Et})}),DO=W((e)=>zt(e[0]),(e,t)=>{if(!t?.log)return qo(e,{onFailure:(n)=>Et,onSuccess:(n)=>Et});let r=_O(t.log);return qo(e,{onFailure:(n)=>t.message===void 0?r(n):r(t.message,n),onSuccess:(n)=>Et})});var Sd=(e)=>MO(e,{onFailure:Mt,onSuccess:vt}),qo=W(2,(e,t)=>new LO(e,t.onSuccess.length!==1?(r)=>t.onSuccess(r):t.onSuccess,t.onFailure.length!==1?(r)=>t.onFailure(r):t.onFailure)),Kj=Mn({op:"OnSuccessAndFailure",[xt]:Rf}),LO=function(e,t,r){this[qe]=e,this[sr]=t,this[yn]=r};LO.prototype=Kj;var qj=function(e,t){let r=this.payload;return t.succeedWith(Lx?r.onSuccess(e):id(()=>r.onSuccess(e)))},$j=(e,t)=>{let r=Mn({op:e,[xt]:Rf,[sr]:qj,[yn]:t}),n=function(o,i){this[qe]=o,this.payload=i};return n.prototype=r,n},Wj=$j("Match",function(e,t){let r=ts(e);if(Ht(r))return Ct(r.failure);let n=this.payload;return t.succeedWith(Lx?n.onFailure(r.success):id(()=>n.onFailure(r.success)))});var qx=W(2,(e,t)=>qo(e,{onFailure:(r)=>{let n=ts(r);return Ht(n)?Ct(n.failure):t.onFailure(n.success)},onSuccess:t.onSuccess})),$x=W(2,(e,t)=>new Wj(e,t)),MO=W(2,(e,t)=>{if(mt(e)){if(e._tag==="Success")return ft(t.onSuccess(e.value));let r=ts(e.cause);if(Ht(r))return ar(r.failure);return ft(t.onFailure(r.success))}return $x(e,t)});var Id=(e)=>mt(e)?ft(e):Gj(e),Gj=Fn({op:"Exit",[xt](e){return e._stack.push(this),this[qe]},[sr](e,t,r){return t.succeedWith(r??ft(e))},[yn](e,t,r){return t.succeedWith(r??ar(e))}});var yx="~effect/Scope",gx="~effect/Scope/Closeable",Ed=Qt("effect/Scope"),Wx=(e,t)=>tt((r)=>(Jj(r),Bf(e,t)??Et)),Bf=(e,t)=>{let r=e.state;if(r._tag==="Closed")return;if(e.state={_tag:"Closed",exit:t},e.parent!==void 0)vf(e.parent,e);if(r._tag==="Empty")return;if(r.finalizer!==void 0)return Af(r.finalizer,t);let n=r.finalizers;if(n.size===1)return Af(n.values().next().value,t);return jj(e,n,t)},Af=(e,t)=>{try{return e(t)}catch(r){return Nn(r)}},FO=(e,t)=>Df(e)?t:Si(t,(r)=>Ct(wx(Xl(e.cause,r)))),jj=_x(function*(e,t,r){let n=[],o=[],i=Array.from(t),s=Tf();for(let c=i.length-1;c>=0;c--){let[d,x]=i[c];if(e.strategy==="sequential")n.push(yield*Id(Af(x,r)));else if(d!==s)o.push(Gf(s,Af(x,r),!0,!0,"inherit"))}if(o.length>0)n=yield*Ox(o);return yield*SO(n)});var NO=(e,t)=>{let r=KO(t,e);if(e.state._tag==="Closed")return r.state=e.state,r;return jc(e,r,(n)=>Wx(r,n)),r},kd=(e,t)=>St(()=>{if(e.state._tag==="Closed")return t(e.state.exit);return jc(e,{},t),Et}),BO=(e,t)=>kd(e,hn(t)),jc=(e,t,r)=>{if(e.state._tag==="Empty")e.state={_tag:"Open",finalizerKey:t,finalizer:r,finalizers:void 0};else if(e.state._tag==="Open"){let n=e.state;if(n.finalizer!==void 0)n.finalizers=new Map([[n.finalizerKey,n.finalizer]]),n.finalizerKey=void 0,n.finalizer=void 0,n.finalizers.set(t,r);else n.finalizers.set(t,r)}},vf=(e,t)=>{if(e.state._tag!=="Open")return;let r=e.state;if(r.finalizerKey===t)e.state=xx;else if(r.finalizers!==void 0){if(r.finalizers.delete(t),r.finalizers.size===0)e.state=xx}},Kf=(e)=>KO(e,void 0),KO=(e="sequential",t)=>({[gx]:gx,[yx]:yx,strategy:e,parent:t,state:xx}),xx={_tag:"Empty"};var wd=Ed,qO=Wc(Ed),Gx=(e)=>tt((t)=>{let r=t.context,n=Kf();return t.setContext(Bn(t.context,Ed,n)),Ad(t,(o)=>(t.setContext(r),Bf(n,o))),e});var qf=(e)=>St(()=>{let t=Kf();return ya(e(t),(r)=>St(()=>Bf(t,r)??Et))}),jx=(e,t,r)=>Mf((n)=>zc((o)=>Vt(wd,(i)=>_f(r?.interruptible?o(e):e,(s)=>kd(i,(c)=>xi(t(s,c),n)))))),zx=(e)=>Vt(wd,(t)=>Mf((r)=>kd(t,(n)=>xi(e(n),r)))),$O=function(){let e=Mn({op:"OnExit",[xt](r){return r._stack.push(this),this.effect},[ra](r){if(r.interruptible&&this.interruptible!==!0)r._stack.push(vd),r.interruptible=!1},[sr](r,n,o){o??=ft(r);let i;try{i=this.onExit(o)}catch(s){i=Nn(s)}return i?Vt(i,(s)=>o):o},[yn](r,n,o){o??=ar(r);let i;try{i=this.onExit(o)}catch(s){i=Nn(s)}return i?Vt(FO(o,i),(s)=>o):o}}),t=function(r,n,o){this.effect=r,this.onExit=n,this.interruptible=o};return t.prototype=e,t}(),ha=(e,t,r)=>new $O(e,t,r),Ad=(e,t)=>{e._stack.push(new $O(void 0,t,void 0))},ya=W(2,ha),WO=W(2,(e,t)=>ya(e,(r)=>t));var GO=W(3,(e,t,r)=>ya(e,(n)=>{let o=t(n);return Ht(o)?Et:r(o.success,n)})),jO=W(2,(e,t)=>GO(e,fO,t));var Qx=(e,t,r)=>zc((n)=>Vt(e,(o)=>ha(St(()=>n(t(o))),(i)=>r(o,i),!0)));var zj=hn(1/0),Qj=(e,t)=>{let r=0,n,o,i=(s,c)=>(c.awaiters++,Ad(s,()=>{if(--c.awaiters>0||c.done)return;if(o===c)o=void 0;return Of(c.fiber)}),wf(c.fiber));return[tt((s)=>{if(o!==void 0)return s===o.fiber?wf(o.fiber):i(s,o);if(n!==void 0&&(r===1/0||s.getRef(yi).currentTimeMillisUnsafe()<r))return n;n=void 0;let c=s.getRef(yi),d={fiber:new Bc(s.context),awaiters:0,done:!1};o=d;let x=i(s,d);return d.fiber.evaluate(ha(e,(f)=>{if(d.done=!0,o!==d)return;if(o=void 0,mO(f))return;let g=t(f);r=g===1/0?1/0:c.currentTimeMillisUnsafe()+g,n=f})),d.fiber._exit??x}),It(()=>{o=void 0,n=void 0})]};var zO=(e)=>It(()=>Qj(e,zj)[0]),QO=tt((e)=>Ct(Fc(e.id))),Hx=(e)=>tt((t)=>{if(!t.interruptible)return e;return t.interruptible=!1,t._stack.push(vd),e}),HO=Fn({op:"SetInterruptible",[ra](e){if(e.interruptible=this[qe],e._interruptedCause&&e.interruptible)return()=>Ct(e._interruptedCause)}}),vd=HO(!0),Hj=HO(!1),Vj=(e)=>{if(e.interruptible=!0,e._stack.push(Hj),e._interruptedCause)return Ct(e._interruptedCause)},Jj=(e)=>{let t=e;if(!t.interruptible)return;t.interruptible=!1,t._stack.push(vd)};var VO=(e)=>tt((t)=>{if(t.interruptible)return e;return Vj(t)??e}),zc=(e)=>tt((t)=>{if(!t.interruptible)return e(Ce);return t.interruptible=!1,t._stack.push(vd),e(VO)});var Vx=(e,t)=>{if(eC(e))return t?.mode==="result"?hi(e,Sd,t):hi(e,Ce,t);let r=e;if(t?.discard){let n=wr(r).map((o)=>r[o]);return t.mode==="result"?hi(n,Sd,t):hi(n,Ce,t)}return St(()=>qn(hi(wr(r).map((n)=>[n,r[n]]),([n,o])=>qn(t?.mode==="result"?Sd(o):o,(i)=>[n,i]),{concurrency:t?.concurrency}),Object.fromEntries))};var Cd=Fn({op:"While",[sr](e,t){if(this[qe].step(e),this[qe].while())return t._stack.push(this),this[qe].body();return jr},[xt](e){if(this[qe].while())return e._stack.push(this),this[qe].body();return jr}}),hi=W((e)=>typeof e[1]==="function",(e,t,r)=>St(()=>{let n=Td(r?.concurrency);if(n===1)return Yj(e,t,r);let o=hd(e),i=o.length;if(i===0)return r?.discard?Et:dt([]);let s=r?.discard?void 0:Array(i),c=Zj({f:t,out:s},o,{concurrency:n});return c?$c(c,s):dt(s)}));var Yj=(e,t,r)=>St(()=>{let n=r?.discard?void 0:[],o=e[Symbol.iterator](),i=o.next(),s=0;return $c(Cd({while:()=>!i.done,body:()=>t(i.value,s++),step:(c)=>{if(n)n.push(c);i=o.next()}}),n)}),Td=(e)=>e==="unbounded"?Number.POSITIVE_INFINITY:Math.max(1,e??1),$f=()=>(e)=>{let{onItem:t,step:r}=e,n=(i,s,c,d,x)=>Vt(Id(x),(f)=>r(i,s[c],f,c)??o(i,s,c+1,d)??Et),o=(i,s,c=0,d=s.length)=>{for(;c<d;c++){let x=s[c],f=t(i,x,c);if(!mt(f))return n(i,s,c,d,f);let g=r(i,x,f,c);if(g)return g._tag==="Failure"?g:void 0}};return o},JO=(e)=>{let{onItem:t,step:r}=e;return(n,o,i)=>{let s=0,c=i.end??o.length,d=i.concurrency,x=!1,f,g,I,w,A,y=(S)=>{let H=Nn(S);return w=H,x=!0,g&&g.size>0?Vt(Hx(bd(Array.from(g))),()=>w??H):H},h=()=>{let S=!1;for(;!w&&s<c;s++){let H=o[s],te=A??t(n,H,s);if(mt(te)){if(w=r(n,H,te,s),w)break}else if(!f)return nn((E)=>{f=Tf(),g=new Set,A=te,I=E;let ge;try{ge=h()}catch(le){return E(y(le))}if(ge)return E(ge);return St(()=>(w??=jr,Vt(g?bd(g):Et,()=>w?._tag==="Failure"?w:Et)))});else{A=void 0;let E=Gf(f,te,!0,!0,"inherit");if(E._exit){if(w=r(n,H,E._exit,s),w)break;continue}g.add(E);let ge=s;if(E.addObserver((le)=>{g.delete(E);try{if(w){if(le._tag==="Failure"){let z=le.cause.reasons.filter((re)=>re._tag!=="Interrupt");if(z.length>0){let re=fi(z);w=ar(w._tag==="Failure"?wx(Xl(w.cause,re)):re)}}}else{let z=r(n,H,le,ge);if(z)w=z,h()}if(S){let z=h();if(z)I(z)}else if(x&&g.size===0)I(w??Et)}catch(z){I(y(z))}}),g.size<d)continue;S=!0,s++;return}}if(x=!0,w){if(g&&g.size>0){let H=Kc(f);g.forEach((te)=>te.interruptUnsafe(f.id,H));return}if(I||w._tag==="Failure")return w}else if(I){if(!g)return jr;else if(g.size===0)I(Et)}};return h()}},Wf=()=>(e)=>JO(e),Zj=JO({onItem(e,t,r){return e.f(t,r)},step(e,t,r,n){if(r._tag==="Failure")return r;else if(e.out)e.out[n]=r.value}});var YO=W((e)=>zt(e[0]),(e,t)=>tt((r)=>(hz(),dt(Gf(r,e,t?.startImmediately,!1,t?.uninterruptible??!1))))),Gf=(e,t,r=!1,n=!1,o=!1)=>{let i=e,s=o==="inherit"?i.interruptible:!o,c=new Bc(i.context,s);if(!n)i.children().add(c),c._parent=i;if(r)c.evaluate(t);else{c._asyncContext=$T();let d=!1;c.yieldWith(()=>{d=!0}),i.currentDispatcher.scheduleTask(()=>{if(d)return;c.evaluate(t)},0)}return c};var ZO=(e)=>()=>tt((t)=>t===e?Et:Of(e)),Jx=W((e)=>zt(e[0]),(e,t,r)=>tt((n)=>{let o=t.state._tag==="Closed"?new Bc(n.context):Gf(n,e,r?.startImmediately,!0,r?.uninterruptible);if(!o._exit)if(t.state._tag!=="Closed")jc(t,o,ZO(o)),o.addObserver(()=>vf(t,o));else o.interruptUnsafe(n.id,Kc(n));return dt(o)})),XO=W((e)=>zt(e[0]),(e,t)=>Vt(wd,(r)=>Jx(e,r,t))),eP=(e,t,r)=>{let n=new Bc(e,r?.uninterruptible!==!0);if(n.evaluate(t),!n._exit){let o=r?.signal;if(o)if(o.aborted)n.interruptUnsafe();else{let i=()=>n.interruptUnsafe();o.addEventListener("abort",i,{once:!0}),n.addObserver(()=>o.removeEventListener("abort",i))}r?.onFiberStart?.(n)}return n},jf=(e)=>(t,r)=>eP(r?.scheduler?Hg(e,nf,r.scheduler):e,t,r),tP=W(2,(e,t)=>{if(e._exit)return e;else if(t.state._tag==="Closed")return e.interruptUnsafe(e.id),e;return vf(t,e),jc(t,e,ZO(e)),e.addObserver(()=>vf(t,e)),e}),rP=(e,t)=>eP(t?.scheduler?sa(new Map([[nf,t.scheduler]])):Gr(),e,t);var Yx=(e)=>{let t=jf(e);return(r,n)=>{let o=t(r,n);return new Promise((i)=>{o.addObserver((s)=>i(s))})}},nP=Yx(Gr()),oP=(e)=>{let t=Yx(e);return(r,n)=>t(r,n).then((o)=>{if(o._tag==="Failure")throw vx(o.cause);return o.value})},iP=oP(Gr()),sP=(e)=>{let t=jf(e);return(r)=>{if(mt(r))return r;let n=new bf("sync"),o=t(r,{scheduler:n});return o._dispatcher?.flush(),o._exit??Nn(new Xx(o))}},aP=sP(Gr());var UT=dt(!0),DT=dt(!1);class cP{waiters=[];scheduled=void 0;_isOpen;constructor(e){this._isOpen=e}scheduleUnsafe(e){if(this.waiters.length===0)return UT;if(this.scheduled===void 0)this.scheduled=this.waiters,e.currentDispatcher.scheduleTask(this.flushScheduled,0);else for(let t=0;t<this.waiters.length;t++)this.scheduled.push(this.waiters[t]);return this.waiters=[],UT}flushScheduled=()=>{if(this.scheduled===void 0)return;let e=this.scheduled;this.scheduled=void 0;for(let t=0;t<e.length;t++)e[t](jr)};flushWaiters(){let e=this.waiters;this.waiters=[],this.flushScheduled();for(let t=0;t<e.length;t++)e[t](jr)}open=tt((e)=>{if(this._isOpen)return DT;return this._isOpen=!0,this.scheduleUnsafe(e)});release=tt((e)=>this._isOpen?DT:this.scheduleUnsafe(e));openUnsafe(){if(this._isOpen)return!1;return this._isOpen=!0,this.flushWaiters(),!0}await=nn((e)=>{if(this._isOpen)return e(Et);return this.waiters.push(e),It(()=>{let t=this.waiters.indexOf(e);if(t!==-1)this.waiters.splice(t,1);else if(this.scheduled!==void 0){if(t=this.scheduled.indexOf(e),t!==-1)this.scheduled.splice(t,1)}})});closeUnsafe(){if(!this._isOpen)return!1;return this._isOpen=!1,!0}close=It(()=>this.closeUnsafe());whenOpen=(e)=>Vt(this.await,()=>e);isOpen(){return this._isOpen}}var pP=(e)=>new cP(e??!1);var Cf=BigInt(0),Xj={_tag:"Span",spanId:"noop",traceId:"noop",sampled:!1,status:{_tag:"Ended",startTime:Cf,endTime:Cf,exit:jr},attributes:new Map,links:[],kind:"internal",attribute(){},event(){},end(){},addLinks(){}},ez=(e)=>Object.assign(Object.create(Xj),e),dP=(e)=>{if(!e)return xe();return rn(e.annotations,If)?e._tag==="Span"?dP(m(e.parent)):xe():Le(e)},tz=(e,t,r)=>{let n=!e.cache.tracerEnabled||r?.annotations&&rn(r.annotations,If),o=r?.parent!==void 0?Le(r.parent):r?.root?xe():dP(e.cache.span),i;if(n)i=ez({name:t,parent:o,annotations:Bn(r?.annotations??Gr(),If,!0)});else{let s=e.cache.tracer??kT,c=e.getRef(yi),d=e.getRef(Ef),x=e.getRef(cx),f=e.getRef(px),g=r?.level??e.getRef(IT),I=r?.links!==void 0?[...f,...r.links]:f.length===0?[]:f.slice();i=s.span({name:t,parent:o,annotations:r?.annotations??Gr(),links:I,startTime:d?c.currentTimeNanosUnsafe():Cf,kind:r?.kind??"internal",root:r?.root??!1,sampled:r?.sampled??(T(o)&&o.value.sampled===!1?!1:!yP(e.getRef(ET),g))});for(let w in x)i.attribute(w,x[w]);if(r?.attributes!==void 0)for(let w in r.attributes)i.attribute(w,r.attributes[w])}return i};var rz=(e,t,r,n)=>It(()=>{if(e.status._tag==="Ended")return;e.end(n?r.currentTimeNanosUnsafe():Cf,t)}),uP=(e,...t)=>{let r=t.length===1?void 0:t[0],n=t[t.length-1];return tt((o)=>{let i=tz(o,e,r),s=o.getRef(yi),c=o.getRef(Ef);return Ad(o,(d)=>rz(i,d,s,c)),n(i)})},nz=Wc(sx);var yi=pt("effect/Clock",{defaultValue:()=>new lP}),lx=2147483647;class lP{currentTimeMillisUnsafe(){return Date.now()}currentTimeMillis=It(()=>this.currentTimeMillisUnsafe());currentTimeNanosUnsafe(){return oz()}currentTimeNanos=It(()=>this.currentTimeNanosUnsafe());monotonicTimeNanosUnsafe(){return mP()}monotonicTimeNanos=It(()=>this.monotonicTimeNanosUnsafe());sleep(e){return this.sleepMillis(xf(e))}sleepMillis(e){if(e<=0)return Px;else if(!Number.isFinite(e))return Pf;return nn((t)=>{let r=e>lx?this.sleepMillis(e-lx):Et,n=setTimeout(()=>t(r),Math.min(e,lx));return It(()=>clearTimeout(n))})}}var fP=BigInt(1e6),mP=function(){let e=globalThis.process?.hrtime;if(typeof e?.bigint==="function")return()=>e.bigint();if(typeof performance<"u"&&typeof performance.now==="function")return()=>BigInt(Math.round(performance.now()*1e6));let t=BigInt(0);return()=>{let r=BigInt(Date.now())*fP;if(r>t)t=r;return t}}(),oz=function(){let e=BigInt(1e9),t;return()=>{let r=mP(),n=BigInt(Date.now())*fP;if(t===void 0)t=n-r;else{let o=t+r;if((n>o?n-o:o-n)>e)t=n-r}return t+r}}(),zf=(e)=>tt((t)=>e(t.getRef(yi))),hP=(e)=>zf((t)=>t.sleep(Lc(e))),Zx=zf((e)=>e.currentTimeMillis);var Sx="~effect/Cause/AsyncFiberError";class Xx extends ud("AsyncFiberError"){[Sx]=Sx;constructor(e){super({message:"An asynchronous Effect was executed with Effect.runSync",fiber:e})}}var bx="~effect/Cause/UnknownError";class Od extends ud("UnknownError"){[bx]=bx;constructor(e,t){super({message:t,cause:e})}}var eS=pt("effect/Console",{defaultValue:()=>globalThis.console}),iz=(e)=>{switch(e){case"All":return Number.MIN_SAFE_INTEGER;case"Fatal":return 50000;case"Error":return 40000;case"Warn":return 30000;case"Info":return 20000;case"Debug":return 1e4;case"Trace":return 0;case"None":return Number.MAX_SAFE_INTEGER}},sz=cf(oa,iz),yP=ld(sz),gP=pt("effect/Logger/CurrentLoggers",{defaultValue:()=>new Set([fz,mz])}),az=pt("effect/Logger/LogToStderr",{defaultValue:Hp});var cz="~effect/Logger",pz={[cz]:{_Message:Ce,_Output:Ce},pipe(){return nt(this,arguments)}},xP=(e)=>{let t=Object.create(pz);return t.log=e,t},dz=(e)=>e.replace(/[\s="]/g,"_"),uz=(e,t)=>`${dz(e[0])}=${t-e[1]}ms`;var Ix=(e)=>(...t)=>{let r=void 0;for(let n=0,o=t.length;n<o;n++){let i=t[n];if(sd(i)){if(r)t.splice(n,1);else t=t.slice(0,n).concat(t.slice(n+1));r=r?fi(r.reasons.concat(i.reasons)):i,n--}}if(r===void 0)r=kg;return tt((n)=>{let o=e??n.cache.logLevel;if(yP(n.cache.minimumLogLevel,o))return Et;let i=n.getRef(yi),s=n.getRef(gP);if(s.size>0){let c=new Date(i.currentTimeMillisUnsafe());for(let d of s)d.log({cause:r,fiber:n,date:c,logLevel:o,message:t})}return Et})};var la={bold:"1",red:"31",green:"32",yellow:"33",blue:"34",cyan:"36",white:"37",gray:"90",black:"30",bgBrightRed:"101"},are={None:[],All:[],Trace:[la.gray],Debug:[la.blue],Info:[la.green],Warn:[la.yellow],Error:[la.red],Fatal:[la.bgBrightRed,la.black]};var lz=(e)=>`${e.getHours().toString().padStart(2,"0")}:${e.getMinutes().toString().padStart(2,"0")}:${e.getSeconds().toString().padStart(2,"0")}.${e.getMilliseconds().toString().padStart(3,"0")}`;var fz=xP(({cause:e,date:t,fiber:r,logLevel:n,message:o})=>{let i=Array.isArray(o)?o.slice():[o];if(e.reasons.length>0)i.push(Cx(e));let s=t.getTime(),c=r.getRef(ux),d="";for(let I of c)d+=` ${uz(I,s)}`;let x=r.getRef(kf);if(Object.keys(x).length>0)i.push(x);let f=r.getRef(eS);(r.getRef(az)?f.error:f.log)(`[${lz(t)}] ${n.toUpperCase()} (#${r.id})${d}:`,...i)}),mz=xP(({cause:e,fiber:t,logLevel:r,message:n})=>{let o=t.getRef(yi),i=t.getRef(kf),s=t.cache.span;if(s===void 0||s._tag==="ExternalSpan"||s.status._tag==="Ended")return;let c={};for(let[d,x]of Object.entries(i))hr(c,d,x);if(c["effect.fiberId"]=t.id,c["effect.logLevel"]=r.toUpperCase(),e.reasons.length>0)c["effect.cause"]=Cx(e);s.event(sC(Array.isArray(n)&&n.length===1?n[0]:n),o.currentTimeNanosUnsafe(),c)});function hz(){hx.interruptChildren??=Rj}var yz="~effect/Deferred";var gz={[yz]:{_A:Ce,_E:Ce},pipe(){return nt(this,arguments)}},SP=function(){this.resumes=void 0,this.effect=void 0};SP.prototype=gz;var $o=()=>new SP;var on=(e)=>nn((t)=>{if(e.effect)return t(e.effect);return e.resumes??=[],e.resumes.push(t),It(()=>{let r=e.resumes;if(r===void 0)return;let n=r.indexOf(t);if(n>=0)r.splice(n,1)})});var xz=W(2,(e,t)=>It(()=>mo(e,t))),Sz=xz,bP=W(2,(e,t)=>Sz(e,lo(t)));var Qf=(e)=>e.effect!==void 0;var mo=(e,t)=>{if(e.effect)return!1;if(e.effect=t,e.resumes){let r=e.resumes;e.resumes=void 0;for(let n=0;n<r.length;n++)r[n](t)}return!0};var IP=vT;var Rd=Ed;var ns=Kf,os=qO,Hf=kd,_d=BO;var is=NO,pn=Wx;var Iz="~effect/Layer",kP="~effect/Layer/MemoMap",Ez=(e,t)=>{let r={observers:0,deferred:$o(),scope:ns(),finalizer:(n)=>St(()=>{if(--r.observers>0)return Et;return e.map.delete(t),pn(r.scope,n)})};return r},wP=(e,t)=>{if(t.state._tag==="Closed")return!1;return e.observers++,jc(t,{},e.finalizer),!0};var kz={[Iz]:{_ROut:Ce,_E:Ce,_RIn:Ce},pipe(){return nt(this,arguments)}},CP=(e)=>{let t=Object.create(kz);return t.build=e,t},wz=(e)=>CP((t,r)=>{let n=is(r);return ya(e(t,n),(o)=>o._tag==="Failure"?pn(n,o):Et)}),tS=(e)=>{let t=wz((r,n)=>r.getOrElseMemoize(t,n,e));return t};class rS{get[kP](){return kP}parent;constructor(e){this.parent=e}map=new Map;get(e,t){let r=this.map.get(e);if(r)return wP(r,t),r.deferred.effect??on(r.deferred);return this.parent?.get(e,t)}getOrElseMemoize(e,t,r){return St(()=>{let n;return ha(St(()=>{let o=this.get(e,t);if(o)return o;let i=Ez(this,e);if(!wP(i,t))return r(this,t);return n=i.deferred,this.map.set(e,i),r(this,i.scope)}),(o)=>{if(n)mo(n,o)})})}}var nS=()=>new rS,Az=(e)=>new rS(e);class Ud extends Qt()("effect/Layer/CurrentMemoMap"){static forkOrCreate(e){let t=Pc(e,Ud);return t?Az(t):nS()}}var oS=W(3,(e,t,r)=>Wc(qn(St(()=>e.build(t,r)),Bn(Ud,t)),Ud,t));var TP=W(2,(e,t)=>tt((r)=>oS(e,Ud.forkOrCreate(r.context),t))),ss=function(){if(arguments.length===1)return(e)=>AP(aa(arguments[0],e));return AP(aa(arguments[0],arguments[1]))},AP=(e)=>CP(hn(dt(e)));var as=function(){if(arguments.length===1)return(e)=>vP(arguments[0],e);return vP(arguments[0],arguments[1])},vP=(e,t)=>OP(qn(t,(r)=>aa(e,r))),OP=(e)=>tS((t,r)=>os(e,r));var PP=(e,t,r)=>{let n=is(r,"parallel");return hi(e,(o)=>o.build(t,is(n,"sequential")),{concurrency:e.length}).pipe(qn((o)=>WC(...o)))},Vf=(...e)=>tS((t,r)=>PP(e,t,r));var vz=(e,t,r)=>tS((n,o)=>Vt(Array.isArray(t)?PP(t,n,o):t.build(n,o),(i)=>e.build(n,o).pipe(xi(i),qn((s)=>r(s,i)))));var RP=W(2,(e,t)=>vz(e,t,(r,n)=>_c(n,r)));var ga=ft,cs=ar,$n=lo;var ho=jr;var dn=Df,Dd=lO;var iS=sd;var Hc=Ac,_P=pd;var xa=fi;var UP=cd,Jf=wg;var sS=(e)=>new kc(e),aS=(e)=>new wc(e);var ps=Nc;var cS=vx;var Ld=rf;var Md=vc,vr=lC;var DP=Od;var pS=FT;var ds=Zx;var ene=globalThis.Number;var LP=W(2,(e,t)=>{let r=Math.pow(10,t);return Math.round(e*r)/r});var tne=globalThis.String;var FP=(e)=>e.toLowerCase();var NP=(e)=>e.trim();var Tz=/[\uD800-\uDFFF]/u;var BP=(e)=>e.isWellFormed?.()??!Tz.test(e);var go=W(2,(e,t)=>Ff(e,Oz,(r)=>t(r))),Ii=(e)=>e.reasons.some(uS),uS=(e)=>e._tag==="Fail"&&Ld(e.error),Yf=(e)=>{let t,r=!1;for(let n of e.reasons)if(uS(n))t??=n.error;else if(n._tag!=="Interrupt")r=!0;if(t===void 0)return Mt(e);return r?Mt(xa(e.reasons.filter((n)=>!uS(n)))):vt(t)};var Oz=(e)=>{let t=Yf(e);return Ht(t)?t:vt(t.success.value)},lS=(e)=>{let t=Yf(e);return!Ht(t)?ga(t.success.value):cs(t.failure)},qP=W(2,(e,t)=>qo(e,{onSuccess:t.onSuccess,onFailure:(r)=>{let n=Yf(r);return!Ht(n)?t.onDone(n.success.value):t.onFailure(n.failure)}}));var Pz=(e,t,r)=>qf((n)=>Vt(r?.local?oS(t,nS(),n):TP(t,n),(o)=>xi(e,o))),$P=W((e)=>zt(e[0]),(e,t,r)=>Qg(t)?xi(e,t):Pz(e,Array.isArray(t)?Vf(...t):t,r));var us=zt,Ei=Vx;var Wo=hi;var Zf=Cd;var ls=ZT,j=dt,Nd=HT,fS=QT,Ze=St,We=It,et=Et;var un=nn,Bd=Pf;var _=eO,oe=rs,Xf=JT,Wn=Ct,Sa=VT,Qr=qc,gr=YT;var Vc=tt;var Kd=jT;var Ae=Vt;var Gn=ma,fs=_f,WP=Sd;var ba=Id,Me=qn,xr=$c;var mS=Uf;var hS=kO,ki=Gc;var qd=Nx,GP=TO,jP=OO;var Cr=Si;var ms=Nf,em=Fx;var Jt=Bx;var Go=Kx,zP=CO;var yS=UO,gS=DO;var QP=RO;var $d=hP;var jn=sO;var Wd=$x;var tm=qo,HP=qx;var Gd=EO,xS=Mf,SS=$P,hs=xi;var rm=bO;var ys=Wc;var nm=wd,Ia=Gx,VP=qf,zn=jx;var JP=Qx,Jc=zx,jo=WO,wi=jO;var bS=ha,Ea=ya;var YP=zO;var jd=QO;var zd=Hx,om=zc;var zo=wO;var im=YO,Qd=Jx,sm=XO;var am=rP,cm=jf;var ZP=iP;var IS=nP;var ka=aP;var be=_x,nr=tO;var qt=(e,t,r)=>(...n)=>un((o)=>{let i=!0,s;try{e(...n,(c,d)=>{let x=c?t?Ze(()=>oe(t(c,n))):oe(c):j(d);if(i)s??=x;else o(x)})}catch(c){s=r?oe(r(c,n)):Qr(c)}if(i=!1,s)o(s)});var Qo=cO,Hd=pO,ES=dO,Sr=aO,pm=uO,XP=rO;var eR=globalThis.BigInt;var tR=(e)=>{if(e>eR(Number.MAX_SAFE_INTEGER)||e<eR(Number.MIN_SAFE_INTEGER))return xe();return Le(Number(e))};var nR=BigInt(0),_z=BigInt(1),Ho=BigInt(1000),gs=BigInt(1024),oR=[{symbol:"B",factor:_z,names:["B","byte","bytes"]},{symbol:"kB",factor:Ho,names:["kB","kilobyte","kilobytes"]},{symbol:"MB",factor:Ho**BigInt(2),names:["MB","megabyte","megabytes"]},{symbol:"GB",factor:Ho**BigInt(3),names:["GB","gigabyte","gigabytes"]},{symbol:"TB",factor:Ho**BigInt(4),names:["TB","terabyte","terabytes"]},{symbol:"PB",factor:Ho**BigInt(5),names:["PB","petabyte","petabytes"]},{symbol:"EB",factor:Ho**BigInt(6),names:["EB","exabyte","exabytes"]},{symbol:"ZB",factor:Ho**BigInt(7),names:["ZB","zettabyte","zettabytes"]},{symbol:"YB",factor:Ho**BigInt(8),names:["YB","yottabyte","yottabytes"]},{symbol:"RB",factor:Ho**BigInt(9),names:["RB","ronnabyte","ronnabytes"]},{symbol:"QB",factor:Ho**BigInt(10),names:["QB","quettabyte","quettabytes"]}],Uz=[oR[0],{symbol:"KiB",factor:gs,names:["KiB","kibibyte","kibibytes"]},{symbol:"MiB",factor:gs**BigInt(2),names:["MiB","mebibyte","mebibytes"]},{symbol:"GiB",factor:gs**BigInt(3),names:["GiB","gibibyte","gibibytes"]},{symbol:"TiB",factor:gs**BigInt(4),names:["TiB","tebibyte","tebibytes"]},{symbol:"PiB",factor:gs**BigInt(5),names:["PiB","pebibyte","pebibytes"]},{symbol:"EiB",factor:gs**BigInt(6),names:["EiB","exbibyte","exbibytes"]},{symbol:"ZiB",factor:gs**BigInt(7),names:["ZiB","zebibyte","zebibytes"]},{symbol:"YiB",factor:gs**BigInt(8),names:["YiB","yobibyte","yobibytes"]}],Dz=[...oR,...Uz.slice(1)],Lz=new Map(Dz.flatMap((e)=>e.names.map((t)=>[t,e])));var kS=(e)=>e;var Yc=(e)=>{throw Error(`Invalid ByteSize: ${e}`)},iR=(e)=>{if(!Number.isSafeInteger(e)||e<0)return Yc(`expected a non-negative safe integer, received ${e}`);return kS(BigInt(e))},Goe=BigInt(Number.MAX_SAFE_INTEGER),Mz=(e,t)=>{let r=/^(\d+)(?:\.(\d+))?(?:e([+-]\d+))?$/.exec(e);if(r===null)return;let n=r[2]??"",o=BigInt(r[1]+n)*t,i=Number(r[3]??0)-n.length;if(i>=0)return o*BigInt(10)**BigInt(i);let s=BigInt(10)**BigInt(-i);return o%s===nR?o/s:void 0};var Fz=(e)=>{let t=/^\s*(\d+(?:\.\d+)?)\s*([A-Za-z]+)\s*$/.exec(e);if(t===null)return Yc(`unsupported syntax ${JSON.stringify(e)}`);let r=Lz.get(t[2]);if(r===void 0)return Yc(`unsupported unit ${JSON.stringify(t[2])}`);let n=Mz(t[1],r.factor);if(n===void 0)return Yc(`${JSON.stringify(e)} does not represent an integral number of bytes`);return kS(n)};var dm=(e)=>{switch(typeof e){case"bigint":if(e<nR)return Yc(`expected a non-negative bigint, received ${e}`);return kS(e);case"number":return iR(e);case"string":return Fz(e)}return Yc(`unsupported input ${e}`)};var wS=(e)=>typeof e==="bigint"?dm(e):iR(e);var um=wf;var lm=Of;var sR=Tf,aR=tP;var hR=1e4,Nz=4194304,Bz=64,yR=(e,t)=>{let r=[],n=new Set;for(let i of e)for(let s of Yz(i)){let c=r.length;if($z(s,r))n.add(c)}let o=TS(r,n);return{nodes:r,initial:o,dot:t,masks:r.length<=32?Kz(r,o):void 0}},Kz=(e,t)=>{let r=0;for(let s of t)r|=1<<s;let n=0,o=0,i=0;for(let s=0;s<e.length;s++){let c=e[s],d=1<<s;if(c._tag==="Globstar")n|=d;else if(c._tag==="End"){if(o|=d,!c.directoryOnly)i|=d}}return{initial:r,globstar:n,end:o,endFile:i}},qz=(e)=>e.startsWith("//")&&e[2]!==void 0&&e[2]!=="/",$z=(e,t)=>{if(e===""||qz(e))return!1;let r=Wz(e),n=r.indexOf("**");if(n!==-1&&r.some((s,c)=>c>n&&(s==="."||s==="..")))return!1;let{directory:o,segments:i}=zz(r);if(i.length===0)return!1;for(let s of i)if(s!=="**")t.push(Qz(Array.from(s)));else if(t[t.length-1]!==cR)t.push(cR);return t.push({_tag:"End",directoryOnly:o}),!0},cR={_tag:"Globstar"},Wz=(e)=>{let t=[],r=0;for(let n=0;n<e.length;n++)if(e[n]==="\\")n++;else if(e[n]==="/")t.push(e.slice(r,n)),r=n+1;return t.push(e.slice(r)),t},PS=/^[A-Za-z]:/,Gz=(e)=>e.length===2&&PS.test(e),gR=(e)=>e===""||e.length===3&&e[2]==="/"&&PS.test(e),jz=(e)=>e.startsWith("/")||e[2]==="/"&&PS.test(e),zz=(e)=>{let t=[],r=0;if(e.length>1&&(e[0]===""||Gz(e[0])))t.push(e[0]===""?"":`${e[0]}/`),r=1;let n=!1;for(;r<e.length;r++){let o=e[r];if(o===""||o===".")n=r===e.length-1&&t.length>0;else t.push(o),n=!1}if(t.length===0&&e.includes("."))t.push(".");return{segments:t,directory:n}},Qz=(e)=>{let t=[],r="",n=!1,o=!0;for(let s=0;s<e.length;s++){let c=e[s];if(c==="\\"&&s+1<e.length)r+=e[++s],t.push({_tag:"Char",code:e[s].codePointAt(0)});else if(c==="*"){if(n=!0,t[t.length-1]?._tag!=="Star")t.push({_tag:"Star"})}else if(c==="?")n=!0,t.push({_tag:"Any"});else if(c==="["&&o){let d=xR(e,s);if(d===void 0)o=!1,r+=c,t.push({_tag:"Char",code:c.codePointAt(0)});else n=!0,t.push(d.token),s=d.end}else r+=c,t.push({_tag:"Char",code:c.codePointAt(0)})}if(!n)return{_tag:"Literal",value:r};let i=t[0];return{_tag:"Wildcard",tokens:t,leadingDot:i._tag==="Char"&&i.code===46,affixes:Hz(t)}},Hz=(e)=>{let t="",r;for(let n of e)if(n._tag==="Star"&&r===void 0)r="";else if(n._tag==="Char"&&(n.code<55296||n.code>57343)){let o=String.fromCodePoint(n.code);if(r===void 0)t+=o;else r+=o}else return;return r===void 0?void 0:{prefix:t,suffix:r}},Hr=(e,t)=>[e.codePointAt(0),t.codePointAt(0)],Vz={alnum:[...Hr("0","9"),...Hr("A","Z"),...Hr("a","z")],alpha:[...Hr("A","Z"),...Hr("a","z")],blank:[9,9,32,32],cntrl:[0,31,127,127],digit:Hr("0","9"),graph:[33,126],lower:Hr("a","z"),print:[32,126],punct:[33,47,58,64,91,96,123,126],space:[9,13,32,32],upper:Hr("A","Z"),word:[...Hr("0","9"),...Hr("A","Z"),95,95,...Hr("a","z")],xdigit:[...Hr("0","9"),...Hr("A","F"),...Hr("a","f")]},Jz=(e,t)=>{for(let r=t+2;r<e.length&&r<=t+8;r++)if(e[r]===":"&&e[r+1]==="]"){let n=Vz[e.slice(t+2,r).join("")];return n===void 0?void 0:{ranges:n,end:r+1}}return},xR=(e,t)=>{let r=t+1,n=e[r]==="!"||e[r]==="^";if(n)r++;let o=[];for(let i=!0;r<e.length;r++,i=!1){let s=e[r];if(s==="/")return;if(s==="]"&&!i)return{token:{_tag:"Class",ranges:o,negated:n},end:r};if(s==="["&&e[r+1]===":"){let c=Jz(e,r);if(c!==void 0){o.push(...c.ranges),r=c.end;continue}}if(s==="\\"&&r+1<e.length)s=e[++r];if(e[r+1]==="-"&&r+2<e.length&&e[r+2]!=="]"){let c=r+2;if(e[c]==="/")return;if(e[c]==="\\"&&c+1<e.length)c++;o.push(...Hr(s,e[c])),r=c;continue}o.push(...Hr(s,s))}return},Yz=(e)=>{let t=Array.from(e),r=Zz(t);if(r.size===0)return[e];let n=SR(t,0,t.length,r,0);if(n===void 0)return[e];let o=bR(n);return o>hR||o*e.length>Nz?[e]:IR(n)},Zz=(e)=>{let t=new Map,r=[],n=!0;for(let o=0;o<e.length;o++){let i=e[o];if(i==="\\")o++;else if(i==="/")n=!0;else if(i==="["&&n){let s=xR(e,o);if(s===void 0)n=!1;else o=s.end}else if(i==="{")r.push({open:o,commas:[]});else if(i===",")r[r.length-1]?.commas.push(o);else if(i==="}"){let s=r.pop();if(s!==void 0&&s.commas.length>0)t.set(s.open,{commas:s.commas,close:o})}}return t},SR=(e,t,r,n,o)=>{if(o>Bz)return;let i=[],s="";for(let c=t;c<r;c++){let d=n.get(c);if(d===void 0){if(e[c]==="\\"&&c+1<r)s+=e[c++];s+=e[c];continue}let x=[],f=c+1;for(let g of[...d.commas,d.close]){let I=SR(e,f,g,n,o+1);if(I===void 0)return;x.push(I),f=g+1}if(s!=="")i.push(s),s="";i.push(x),c=d.close}if(s!=="")i.push(s);return i},bR=(e)=>{let t=1;for(let r of e)if(typeof r!=="string"){let n=0;for(let o of r)n+=bR(o);if(t*=n,t>hR)return 1/0}return t},IR=(e)=>{let t=[""];for(let r of e)if(typeof r==="string")t=t.map((n)=>n+r);else{let n=r.flatMap(IR);t=t.flatMap((o)=>n.map((i)=>o+i))}return t},Xz=(e,t)=>{switch(e._tag){case"Char":return e.code===t;case"Any":return!0;case"Star":return!1;case"Class":{let r=!1;for(let n=0;n<e.ranges.length&&!r;n+=2)r=t>=e.ranges[n]&&t<=e.ranges[n+1];return r!==e.negated}}},pR=(e)=>e>65535?2:1,eQ=(e,t,r)=>{if(t==="."||t===".."||t.startsWith(".")&&!r&&!e.leadingDot)return!1;if(e.affixes!==void 0){let{prefix:d,suffix:x}=e.affixes;return t.length>=d.length+x.length&&t.startsWith(d)&&t.endsWith(x)}let{tokens:n}=e,o=0,i=0,s=-1,c=0;while(i<t.length){if(n[o]?._tag==="Star"){s=o++,c=i;continue}let d=t.codePointAt(i);if(o<n.length&&Xz(n[o],d))o++,i+=pR(d);else if(s!==-1)o=s+1,c+=pR(t.codePointAt(c)),i=c;else return!1}while(n[o]?._tag==="Star")o++;return o===n.length},TS=(e,t)=>{for(let r of t)if(e[r]._tag==="Globstar")t.add(r+1);return t},dR=(e,t,r)=>{let n=new Set,o=new Set,i=gR(r);for(let s of t){let c=e.nodes[s];switch(c._tag){case"Globstar":{if(!i&&r!=="."&&r!==".."&&(e.dot||!r.startsWith(".")))o.add(s);break}case"Literal":{if(c.value===r)n.add(s+1);break}case"Wildcard":{if(!i&&eQ(c,r,e.dot))n.add(s+1);break}}}return{explicit:TS(e.nodes,n),globstar:TS(e.nodes,o)}},uR=(e)=>{if(e.globstar.size===0)return e.explicit;let t=new Set(e.explicit);for(let r of e.globstar)t.add(r);return t},lR=(e,t,r)=>{for(let n of t){let o=e.nodes[n];if(o._tag==="End"&&(r||!o.directoryOnly))return!0}return!1},fR=(e,t)=>{for(let r of t)if(e.nodes[r]._tag!=="End")return!0;return!1},tQ=(e,t)=>{for(let r of t){let n=e.nodes[r];if(n._tag==="End"&&n.directoryOnly)return!0}return!1};var CS=(e,t)=>{if(e==="")return t===""?"/":t;return e.endsWith("/")?e+t:`${e}/${t}`},OS=(e)=>e.reason._tag==="NotFound"||e.reason._tag==="BadResource",fm=(e)=>OS(e)||e.reason._tag==="PermissionDenied",mR=(e)=>fm(e)||e.reason._tag==="Unknown",rQ=16,nQ=cf(UC,(e)=>e.name),ER=(e)=>(t,r)=>oQ(e,yR([t],r?.dot??!1),r),oQ=be(function*(e,t,r){if(t.initial.size===0)return[];let n=r?.root??"",o=yR(r?.exclude??[],!0),i=o.nodes.some((h)=>h._tag==="End"&&h.directoryOnly),s=(h)=>jz(h)?h:h===""?n===""?".":n:CS(n,h),c=(h)=>h==="."||h===".."||gR(h),d=(h,S,H)=>{let te=s(CS(h,S));return e.stat(te).pipe(Me((E)=>E.type),jP("PlatformError","NotFound",()=>e.readLink(te).pipe(xr("SymbolicLink"),ms(mR,()=>j(void 0)))),ms(H?OS:fm,()=>j(void 0)),Me((E)=>E===void 0?void 0:{name:S,type:E}))},x=(h,S,H)=>{let te=new Set,E=!H;for(let le of S){let z=t.nodes[le];if(z._tag==="Literal")te.add(z.value);else if(z._tag!=="End")E=!0}let ge=E?[...te].filter(c):[...te];return hS(E?ms(e.readDirectoryEntries(s(h)),H?OS:fm,()=>j([])):j([]),Wo(ge,(le)=>d(h,le,H),{concurrency:16}),(le,z)=>({entries:XC([...le,...z.filter(ir)],nQ),named:H&&!E}))},f=({name:h,type:S},H,te,E)=>{let ge=dR(t,te,h),le=uR(ge);if(le.size===0)return;let z=CS(H,h),re=uR(dR(o,E,h)),V=fR(t,le),ne=(de,pe)=>{let he=lR(t,le,de);if(!he&&(!de||!V)||lR(o,re,de))return;return{relative:z,accepted:he,excluded:re,next:!de||!V?void 0:!pe||ge.globstar.size===0?le:fR(t,ge.explicit)?ge.explicit:void 0}};if(!V&&!tQ(t,le)&&!i)return ne(!1,!1);if(S!=="Unknown"&&S!=="SymbolicLink")return ne(S==="Directory",!1);let ie=s(z);return e.stat(ie).pipe(Me((de)=>de.type==="Directory"),ms(fm,()=>j(!1)),Ae((de)=>{let pe=ne(de,S==="SymbolicLink");if(S==="SymbolicLink"||pe?.next===void 0||ge.globstar.size===0)return j(pe);return e.readLink(ie).pipe(xr(ne(de,!0)),ms(mR,()=>j(pe)))}))},g=rQ,I=!1,w=$o(),A=(h)=>h.pipe(wi((S)=>We(()=>{if(!I)mo(w,Wn(S))})),jo(We(()=>{g++})),im),y=be(function*(h,S,H,te){let E=yield*x(h,S,te),ge=[],le=[];for(let ne of E.entries){let ie=f(ne,h,S,H);if(us(ie)){let de=ge.push(void 0)-1;le.push(Me(ie,(pe)=>{ge[de]=pe}))}else ge.push(ie)}if(le.length>0)yield*Ei(le,{concurrency:16,discard:!0});let z=[];for(let ne of ge)if(ne?.next!==void 0){let ie=y(ne.relative,ne.next,ne.excluded,E.named);if(g>0)g--,z.push(um(yield*A(ie)));else z.push(j(yield*ie))}let re=[],V=0;for(let ne of ge){if(ne===void 0)continue;if(ne.accepted)re.push(ne.relative);if(ne.next!==void 0)for(let ie of yield*z[V++])re.push(ie)}return re});return yield*jn(jo(y("",t.initial,o.initial,!0),We(()=>{I=!0})),on(w))});var kR="~effect/PlatformError";class Vd extends Ko("BadArgument"){get message(){return`${this.module}.${this.method}${this.description?`: ${this.description}`:""}`}}class wR extends ST{get message(){return`${this._tag}: ${this.module}.${this.method}${this.pathOrDescriptor!==void 0?` (${this.pathOrDescriptor})`:""}${this.description?`: ${this.description}`:""}`}}class RS extends Ko("PlatformError"){constructor(e){if("cause"in e)super({reason:e,cause:e.cause});else super({reason:e})}[kR]=kR;get message(){return this.reason.message}}var xo=(e)=>new RS(new wR(e)),bn=(e)=>new RS(new Vd(e));var AR=pP;var CR="~effect/MutableRef",sQ={[CR]:CR,...Lr,toJSON(){return{_id:"MutableRef",current:Fo(this.current)}}},TR=(e)=>{let t=Object.create(sQ);return t.current=e,t};var aQ=Symbol.for("effect/MutableList/Empty"),RR=()=>({head:void 0,tail:void 0,length:0}),_S=(e)=>{let t=e.head;if(t.offset>=1024&&t===e.tail&&t.mutable&&(t.array.length-t.offset)*8<=t.offset)e.head=e.tail={array:t.array.slice(t.offset),mutable:!0,offset:0,next:void 0}},PR=()=>({array:[],mutable:!0,offset:0,next:void 0}),Zc=(e,t)=>{if(!e.tail)e.head=e.tail=PR();else if(!e.tail.mutable)e.tail.next=PR(),e.tail=e.tail.next;e.tail.array.push(t),e.length++};var xs=(e)=>{e.head=e.tail=void 0,e.length=0},_R=(e,t)=>{if(t=Uc(t),t<=0||!e.head)return[];if(t=Math.min(t,e.length),t===e.length&&e.head?.offset===0&&!e.head.next){let i=e.head.array;return xs(e),i}let r=Array(t),n=0,o=e.head;while(o){while(o.offset<o.array.length){if(r[n++]=o.array[o.offset],o.mutable)o.array[o.offset]=void 0;if(o.offset++,n===t){if(e.head=o.offset===o.array.length&&o.next?o.next:o,e.length-=t,e.length===0)xs(e);else _S(e);return r}}o=o.next}return xs(e),r},UR=(e,t)=>{if(t=Uc(t),t<=0||!e.head)return;if(t=Math.min(t,e.length),t===e.length&&e.head?.offset===0&&!e.head.next){xs(e);return}let r=0,n=e.head;while(n){let o=n.array.length-n.offset;if(r+o>t){n.offset+=t-r,e.head=n,e.length-=t,_S(e);return}r+=o,n=n.next}xs(e);return};var US=(e)=>{if(!e.head)return aQ;let t=e.head.array[e.head.offset];if(e.head.mutable)e.head.array[e.head.offset]=void 0;if(e.head.offset++,e.length--,e.head.offset===e.head.array.length)if(e.head.next)e.head=e.head.next;else xs(e);else _S(e);return t};var cQ="~effect/Queue",pQ="~effect/Queue/Enqueue",dQ="~effect/Queue/Dequeue";var DS={_A:Ce,_E:Ce},uQ={[cQ]:DS,[pQ]:DS,[dQ]:DS,...Lr,toJSON(){return{_id:"effect/Queue",state:this.state._tag,size:fQ(this)}}},wa=(e)=>tt((t)=>{let r=Object.create(uQ);return r.dispatcher=t.currentDispatcher,r.capacity=e?.capacity??Number.POSITIVE_INFINITY,r.strategy=e?.strategy??"suspend",r.messages=RR(),r.scheduleRunning=!1,r.state={_tag:"Open",takers:new Set,offers:new Set,awaiters:new Set},dt(r)}),LR=(e)=>wa({capacity:e}),MR=(e)=>wa({capacity:e,strategy:"sliding"});var Jd=W(2,(e,t)=>St(()=>Ss(e,t)?hm:e.state._tag==="Open"&&e.strategy==="suspend"?gQ(e,t):qR)),Ss=(e,t)=>{if(e.state._tag!=="Open")return!1;else if(e.messages.length>=e.capacity){if(e.capacity<=0&&e.state.takers.size>(e.strategy==="sliding"?0:e.messages.length)){if(Zc(e.messages,t),e.strategy==="sliding")UR(e.messages,e.messages.length-e.state.takers.size);return $R(e),!0}else if(e.strategy==="sliding"){if(e.capacity>0)US(e.messages),Zc(e.messages,t);return!0}return!1}return Zc(e.messages,t),WR(e),!0};var Xc=W(2,(e,t)=>It(()=>Yd(e,t))),Yd=(e,t)=>{if(e.state._tag!=="Open")return!1;let r=ar(t),n=xO(r,mQ);if(e.state.offers.size===0&&e.messages.length===0)return ym(e,n),!0;return e.state={...e.state,_tag:"Closing",exit:n},WR(e),!0};var Vo=(e)=>Yd(e,cd(vc()));var MS=(e)=>It(()=>lQ(e)),lQ=(e)=>{if(e.state._tag==="Done")return!1;xs(e.messages);let t=e.state.offers;ym(e,e.state._tag==="Open"?hQ:e.state.exit);for(let r of t)jR(r);return!0};var FR=(e)=>NR(e,1,Number.POSITIVE_INFINITY);var NR=W(3,(e,t,r)=>(t=Uc(t),r=Uc(r),FS(()=>yQ(e,t,r)??ma(GR(e,()=>NS(e,t)),NR(e,t,r))))),Ai=(e)=>FS(()=>KR(e)??ma(GR(e,()=>NS(e,1)),Ai(e))),BR=(e)=>FS(()=>{let t=KR(e);if(t===void 0)return dt(xe());if(t._tag==="Success")return dt(Le(t.value));return dt(xe())});var KR=(e)=>{if(e.state._tag==="Done")return e.state.exit;if(e.messages.length>0){let t=US(e.messages);return LS(e),ft(t)}else if(e.capacity<=0&&e.state.offers.size>0){let t=zR(e.state.offers);return LS(e),ft(t)}return};var fQ=(e)=>e.state._tag==="Done"?0:e.messages.length;var qR=ft(!1),hm=ft(!0),mQ=lo(vc()),hQ=Mx(),$R=(e)=>{if(e.state._tag==="Done"||e.state.takers.size===0)return;for(let t of e.state.takers){if(!t.ready())continue;if(e.state.takers.delete(t),t.resume(jr),e.messages.length===0)break}},WR=(e)=>{if(e.scheduleRunning||e.state._tag==="Done"||e.state.takers.size===0)return;e.scheduleRunning=!0,e.dispatcher.scheduleTask(()=>{e.scheduleRunning=!1,$R(e)},0)},yQ=(e,t,r)=>{if(e.state._tag==="Done")return e.state.exit;else if(r<=0||t<=0)return ft([]);else if(!NS(e,t))return;let n=e.messages.length>0?_R(e.messages,r):[zR(e.state.offers)];return LS(e),ft(n)},FS=Fn({op:"QueueTake",[xt](e){let t=this[qe]();return Zl(t)?t[xt](e):t}}),NS=(e,t)=>e.messages.length>=(e.state._tag==="Closing"?1:Math.min(t,e.capacity||1))||e.capacity<=0&&e.state._tag!=="Done"&&e.state.offers.size>0,GR=(e,t)=>nn((r)=>{if(e.state._tag==="Done")return r(e.state.exit);if(t())return r(jr);let n={ready:t,resume:r};return e.state.takers.add(n),It(()=>{if(e.state._tag!=="Done")e.state.takers.delete(n)})}),gQ=(e,t)=>nn((r)=>Ss(e,t)?r(hm):xQ(e,{_tag:"Single",message:t,resume:r})),xQ=(e,t)=>{if(e.state._tag!=="Open")return jR(t);let r=e.state.offers;return r.add(t),It(()=>{if(e.state._tag==="Done")return;if(r.delete(t),e.state._tag==="Closing"&&r.size===0&&e.messages.length===0)ym(e,e.state.exit)})},jR=(e)=>e._tag==="Single"?e.resume(qR):e.resume(ft(e.remaining.slice(e.offset))),zR=(e)=>{let t=e.values().next().value;if(t._tag==="Single")return e.delete(t),t.resume(hm),t.message;let r=t.remaining[t.offset++];if(t.offset===t.remaining.length)e.delete(t),t.resume(ft([]));return r},LS=(e)=>{if(e.state._tag==="Done")return Ii(e.state.exit.cause);else if(e.state.offers.size===0){if(e.state._tag==="Closing"&&e.messages.length===0)return ym(e,e.state.exit,!0),Ii(e.state.exit.cause);return!1}for(let t of e.state.offers){let r=e.capacity-e.messages.length;if(r<=0)break;else if(t._tag==="Single")Zc(e.messages,t.message),e.state.offers.delete(t),t.resume(hm);else{for(;t.offset<t.remaining.length;t.offset++){if(r===0)return!1;Zc(e.messages,t.remaining[t.offset]),r--}e.state.offers.delete(t),t.resume(ft([]))}let n=e.state;if(n._tag==="Done")return Ii(n.exit.cause)}return!1};var ym=(e,t,r=!1)=>{if(e.state._tag==="Done")return;let n=e.state;if(e.state={_tag:"Done",exit:t},n.takers.size===0&&n.awaiters.size===0)return;let o=()=>{for(let i of n.takers)i.resume(t);n.takers.clear();for(let i of n.awaiters)i(t);n.awaiters.clear()};if(r)e.dispatcher.scheduleTask(o,0);else o()};var HR="~effect/Channel",QR=(e)=>Ye(e,HR),kQ={[HR]:{_Env:Ce,_InErr:Ce,_InElem:Ce,_OutErr:Ce,_OutElem:Ce},pipe(){return nt(this,arguments)}},Mr=(e)=>{let t=Object.create(kQ);return t.transform=(r,n)=>Cr(e(r,n),(o)=>j(Wn(o))),t},BS=(e,t)=>Mr((r,n)=>Ae(So(e)(r,n),(o)=>t(o,n))),ep=(e)=>Mr((t,r)=>e),VR=(e)=>Mr(be(function*(t,r){let n=is(r),o=(s)=>pn(n,lS(s)),i=yield*wi(e(t,r,n),o);return wi(i,o)})),So=(e)=>e.transform;var wQ=(e,t,r)=>wa({capacity:r?.bufferSize,strategy:r?.strategy}).pipe(fs((n)=>_d(e,MS(n))),fs((n)=>os(t(n),e).pipe(Cr((o)=>Xc(n,o)),Qd(e,{startImmediately:!0}))));var JR=(e,t)=>Mr((r,n)=>Me(wQ(n,e,t),FR)),YR=(e)=>Mr((t,r)=>Ze(()=>So(e())(t,r)));var ZR=ep(j(vr()));var XR=(e)=>ep(j(oe(e)));var AQ=(e)=>ep(Ae(e,()=>vr()));var KS=W(2,(e,t)=>e0(e,(r)=>j(t(r)))),e0=W(2,(e,t)=>BS(e,(r)=>j(go(r,(n)=>Ae(t(n),vr)))));var t0=W(2,(e,t)=>BS(e,(r)=>j(zP(r,(n)=>Ld(n)?et:mS(t(n))))));var qS=W((e)=>QR(e[0])&&QR(e[1]),(e,t,r)=>VR(be(function*(n,o,i){let s=r?.haltStrategy??"both",c=yield*LR(0);yield*_d(i,MS(c));let d=0;function x(g,I){if(d++,!Ii(I))return Xc(c,I);switch(s){case"both":return d===2?Xc(c,I):et;case"left":case"right":return g===s?Xc(c,I):et;case"either":return Xc(c,I)}}let f=(g,I,w)=>So(I)(n,w).pipe(Ae((A)=>A.pipe(Ae((y)=>Jd(c,y)),zo)),wi((A)=>bS(lS(A),(y)=>pn(w,y)).pipe(tm({onFailure:(y)=>x(g,y),onSuccess:()=>x(g,A)}))),Qd(i,{startImmediately:!0}));return yield*f("left",e,is(i)),yield*f("right",t,is(i)),Ai(c)}))),r0=W(2,(e,t)=>qS(e,AQ(t),{haltStrategy:"left"})),n0=()=>Mr((e,t)=>We(()=>{let r="",n=!1,o=xe();function i(d){let x=[];function f(g){if(r.length===0)x.push(g);else x.push(r+g),r=""}for(let g=0;g<d.length;g++){let I=d[g];if(I.length!==0){let w=0,A=I.indexOf("\r"),y=I.indexOf(`
27
+ `);if(n){if(y===0)w=1,y=I.indexOf(`
28
+ `,w);n=!1}while(A!==-1||y!==-1)if(A===-1||y!==-1&&y<A)f(I.substring(w,y)),w=y+1,y=I.indexOf(`
29
+ `,w);else if(f(I.substring(w,A)),I.length===A+1)n=!0,w=I.length,A=-1;else w=A+(y===A+1?2:1),A=I.indexOf("\r",w),y=I.indexOf(`
30
+ `,w);r=r+I.substring(w)}}return Zi(x)?x:null}let s=Ze(()=>{if(o._tag==="Some")return vr(o.value);return qP(e,{onSuccess:c,onFailure:Wn,onDone:(d)=>{if(o=Le(d),r.length>0){let x=r;return r="",n=!1,j([x])}return vr(d)}})});function c(d){let x=i(d);return x!==null?j(x):s}return s})),o0=(e,t)=>Mr((r,n)=>We(()=>{let o=new TextDecoder(e,t),i={stream:!0},s=r.pipe(Me(gn((c)=>o.decode(c,i))),go((c)=>{s=vr(c);let d=o.decode();return d.length>0?j(Xi(d)):s}));return Ze(()=>s)}));var $S=W(2,(e,t)=>Mr((r,n)=>Ae(So(e)(r,n),(o)=>So(t)(o,n))));var i0=(e)=>e._tag==="Die"&&Ld(e.defect)&&iS(e.defect.value),s0=(e)=>e.reasons.some(i0),a0=(e)=>Cr(e,(t)=>Ii(t)?Wn(t):Qr(Md(t))),vQ=(e)=>s0(e)?xa(e.reasons.flatMap((t)=>i0(t)?t.defect.value.reasons:[t])):e,c0=(e)=>Cr(e,(t)=>Wn(vQ(t))),gm=(e)=>Mr((t,r)=>{let n;return j(Ze(()=>{if(n)return n;return e.pipe(os(r),Ae((o)=>So(o)(t,r)),Ae((o)=>n=o))}))});var p0=(e,t,r)=>Ze(()=>{let n=ns(),o=So(e)(vr(),n);return go(Ae(o,t),r?r:j).pipe(Ea((i)=>pn(n,i)))});var d0=(e)=>p0(e,(t)=>zo(t,{disableYield:!0}));var WS=W(3,(e,t,r)=>Ze(()=>{let n=t();return p0(e,(o)=>Zf({while:_o,body:()=>o,step:(i)=>{n=r(n,i)}}),()=>j(n))}));var GS=(e,t)=>So(e)(vr(),t);var CQ="~effect/Stream",TQ={_R:Ce,_E:Ce,_A:Ce},u0=function(e){this.channel=e};u0.prototype={[CQ]:TQ,pipe(){return nt(this,arguments)}};var l0=(e)=>new u0(e);var f0="~effect/Sink",m0=j([void 0]),PQ={_A:Ce,_In:Ce,_L:Ce,_E:Ce,_R:Ce},RQ={[f0]:PQ,pipe(){return nt(this,arguments)}},eu=(e)=>Ye(e,f0),jS=(e)=>zS((t,r)=>So(e)(t,r).pipe(Ae(zo({disableYield:!0})),go(j)));var zS=(e)=>{let t=Object.create(RQ);return t.transform=e,t},_Q=(e)=>Mr((t,r)=>j(Ae(e.transform(t,r),vr)));var tu=zS((e)=>go(zo(e,{disableYield:!0}),()=>m0));var h0=(e)=>UQ(Wo((t)=>e(t),{discard:!0})),UQ=(e)=>zS((t)=>t.pipe(Ae(e),zo({disableYield:!0}),go(()=>m0)));var y0=(e)=>jS(gm(Me(e,_Q)));var DQ="~effect/RcRef",ru={_tag:"Empty"},LQ={_tag:"Closed"},MQ={_A:Ce,_E:Ce};class x0{[DQ]=MQ;pipe(){return nt(this,arguments)}state=ru;acquire;context;scope;idleTimeToLive;constructor(e,t,r,n){this.acquire=e,this.context=t,this.scope=r,this.idleTimeToLive=n}}var S0=(e)=>Vc((t)=>{let r=t.context,n=rn(r,Rd),o=new x0(e.acquire,r,n,e.idleTimeToLive!==void 0?Lc(e.idleTimeToLive):void 0);return xr(Hf(n,()=>{let i=o.state;if(o.state=LQ,i._tag==="Acquired")return pn(i.scope,ho);if(i._tag==="Acquiring")return lm(i.fiber);return et}),o)}),FQ=(e,t)=>{switch(e.state._tag){case"Closed":return jd;case"Acquired":{let r=e.state;return r.refCount++,r.fiber?xr(lm(r.fiber),r):j(r)}case"Acquiring":{let r=e.state;return r.awaiters++,g0(e,r,t)}case"Empty":{let r={_tag:"Acquiring",fiber:void 0,awaiters:1,acquired:void 0};e.state=r;let n=ns(),o=hs(e.acquire,Bn(e.context,Rd,n)).pipe(Ae((i)=>{if(e.state!==r)return jd;let s={_tag:"Acquired",value:i,scope:n,fiber:void 0,refCount:r.awaiters,invalidated:!1};return e.state=s,r.acquired=s,j(s)}),Ea((i)=>{if(dn(i))return et;if(e.state===r)e.state=ru;return pn(n,i)}));return r.fiber=cm(sR().context)(o),g0(e,r,t)}}},g0=(e,t,r)=>Ea(r(um(t.fiber)),(n)=>{let o=t.acquired;if(o!==void 0)return Dd(n)?I0(e,o):et;if(--t.awaiters>0||e.state!==t)return et;return e.state=ru,lm(t.fiber)}),b0=(e)=>{let t=e;return om((r)=>Ae(nm,(n)=>Ae(FQ(t,r),(o)=>xr(Hf(n,()=>I0(t,o)),o.value))))},I0=(e,t)=>{if(t.refCount--,t.refCount>0)return et;let r=e.idleTimeToLive;if(r===void 0||t.invalidated){if(e.state===t)e.state=ru;return pn(t.scope,ho)}else if(!uT(r))return et;return t.fiber=om((n)=>Ae(n($d(r)),()=>{if(e.state===t&&t.refCount===0)return e.state=ru,gS(pn(t.scope,ho),{log:"Unhandled",message:"Unhandled error in RcRef finalizer"});return et})).pipe(jo(We(()=>{t.fiber=void 0})),cm(e.context),aR(e.scope)),et};var QS=S0,Sm=b0;var BQ="~effect/Stream",Aa=(e)=>Ye(e,BQ);var ln=l0;var k0=(e)=>ln(ep(e)),KQ=(e,t)=>ln(Mr((r,n)=>Ae(GS(e.channel,n),(o)=>t(o,n))));var HS=(e)=>e.channel,w0=(e,t)=>ln(JR(e,t)),tp=ln(ZR);var A0=(e)=>{let t=ln(YR(()=>e().channel));return qQ.set(t,e),t},qQ=new WeakMap,VS=(e)=>ln(XR(e));var Jo=(e)=>ln(gm(Me(e,HS)));var v0=W(2,(e,t)=>$Q(e,JS(t)));var C0=W((e)=>Aa(e[0])&&Aa(e[1]),(e,t,r)=>ln(qS(HS(e),HS(t),r))),$Q=W(2,(e,t)=>e.channel.pipe(r0(t),ln));var T0=W(2,(e,t)=>e.channel.pipe(t0(t),ln));var bm=W(2,(e,t)=>KQ(e,(r,n)=>We(()=>{let o,i,s=Ze(()=>{if(i!==void 0){let d=i;return i=void 0,j(d)}return r}).pipe(ki((d)=>(o=$n(d),vr()))),c=Me(Ze(()=>t.transform(s,n)),([d,x])=>(i=x,Xi(d)));return Ze(()=>o?o:c)})));var O0=W((e)=>Aa(e[0]),(e,t)=>e.channel.pipe($S(o0(t?.encoding)),ln));var P0=(e)=>e.channel.pipe($S(n0()),ln);var R0=W(2,(e,t)=>VP((r)=>GS(e.channel,r).pipe(Ae((n)=>WQ(t,n,r)),Me(([n])=>n)))),WQ=(e,t,r)=>c0(e.transform(a0(t),r)),_0=(e)=>WS(e.channel,()=>[],(t,r)=>{for(let n=0;n<r.length;n++)t.push(r[n]);return t});var JS=(e)=>d0(e.channel);var U0=(e)=>WS(e.channel,()=>"",(t,r)=>t+r.join(""));var D0="~effect/FileSystem",nu=Qt("effect/FileSystem"),L0=(e)=>nu.of({...e,[D0]:D0,glob:ER(e),exists:(t)=>Hi(e.access(t),xr(!0),qd("PlatformError",(r)=>r.reason._tag==="NotFound"?j(!1):oe(r))),readFileString:(t,r)=>Ae(e.readFile(t),(n)=>gr({try:()=>new TextDecoder(r).decode(n),catch:(o)=>bn({module:"FileSystem",method:"readFileString",description:"invalid encoding",cause:o})})),stream:be(function*(t,r){let n=yield*e.open(t,{flag:"r"}),o=r?.offset===void 0?void 0:dm(r.offset);if(o)yield*n.seek(o,"start");let i=r?.bytesToRead===void 0?void 0:dm(r.bytesToRead),s=BigInt(0),c=Number(BigInt(r?.chunkSize??65536)),d=n.readAlloc(c);return k0(j(Ae(Ze(()=>{if(i!==void 0&&i<=s)return vr();return i!==void 0&&i-s<c?n.readAlloc(Number(i-s)):d}),Wr({onNone:()=>vr(),onSome:(x)=>(s+=BigInt(x.length),j(Xi(x)))}))))},Jo),sink:(t,r)=>Hi(e.open(t,{...r,flag:r?.flag??"w"}),Me((n)=>h0((o)=>n.writeAll(o))),y0),writeFileString:(t,r,n)=>Ae(gr({try:()=>new TextEncoder().encode(r),catch:(o)=>bn({module:"FileSystem",method:"writeFileString",description:"could not encode string",cause:o})}),(o)=>e.writeFile(t,o,n))});var Im="~effect/FileSystem/File";class Em extends Qt()("effect/FileSystem/WatchBackend"){}var M0="~effect/Path",Ca=Qt("effect/Path"),km=(e)=>Ca.of({...e,[M0]:M0,resolveWithin(t,r){if(e.parse(r).root!=="")return xe();let n=e.resolve(t),o=e.resolve(n,r),i=e.relative(n,o);return i===".."||i.startsWith(`..${e.sep}`)||e.isAbsolute(i)?xe():Le(o)}});function ZS(e){return e.checks?e.checks[e.checks.length-1].annotations:e.annotations}var ou="~structural";var wm="~sentinels",Am="~constructor";var iu=po((e)=>{let t=ZS(e)?.identifier;if(typeof t==="string")return t;return e.getExpected(iu)});var He=Symbol.for("effect/schema/parser/missing");var Fr=ga,Qn=Fr(He),vi=Object.assign(Fr(He),{[He]:!0}),pr=(e)=>e[He]===!0,su=(e)=>e===He?xe():Le(e),eb=(e)=>e._tag==="None"?Qn:Fr(e.value);var du="~effect/SchemaIssue/Issue";function rb(e){return Ye(e,du)&&e[du]===du}function GQ(e){return Object.hasOwn(e,"input")}class Hn{[du]=du;constructor(e,t){if(t?.reportInput===!0&&e!==He)this.input=e}}var N0=class extends Hn{_tag="Filter";filter;issue;constructor(e,t,r,n){super(r,n);this.filter=e,this.issue=t}},B0=class extends Hn{_tag="Encoding";ast;issue;constructor(e,t,r,n){super(r,n);this.ast=e,this.issue=t}},In=class extends Hn{_tag="Pointer";path;issue;constructor(e,t){super();this.path=e,this.issue=t}},uu=class extends Hn{_tag="MissingKey";annotations;constructor(e){super();this.annotations=e}},nb=class extends Hn{_tag="UnexpectedKey";ast;constructor(e,t,r){super(t,r);this.ast=e}},Nr=class extends Hn{_tag="Composite";ast;issues;constructor(e,t,r,n){super(r,n);this.ast=e,this.issues=t}},Vn=class extends Hn{_tag="InvalidType";ast;constructor(e,t,r){super(t,r);this.ast=e}},Vr=class extends Hn{_tag="InvalidValue";annotations;constructor(e,t,r){super(t,r);this.annotations=e}};var lu=class extends Hn{_tag="Forbidden";annotations;constructor(e,t,r){super(t,r);this.annotations=e}},fu=class extends Hn{_tag="AnyOf";ast;issues;constructor(e,t,r,n){super(r,n);this.ast=e,this.issues=t}},K0=class extends Hn{_tag="OneOf";ast;successes;constructor(e,t,r,n){super(r,n);this.ast=e,this.successes=t}};function tb(e,t,r){if(rb(e))return e;if(typeof e==="string")return new Vr({message:e},t,r);let n=typeof e.issue==="string"?new Vr({message:e.issue},t,r):e.issue;return new In(e.path,n)}function q0(e,t,r){if(e===void 0)return;if(typeof e==="boolean")return e?void 0:new Vr(void 0,t,r);return tb(e,t,r)}function $0(e,t,r,n){if(Array.isArray(t)){if(!Zi(t))return;return t.length===1?tb(t[0],r,n):new Nr(e,gn(t,(o)=>tb(o,r,n)),r,n)}return q0(t,r,n)}var W0=(e)=>{let t=np(e);if(t!==void 0)return t;switch(e._tag){case"InvalidType":return rp(iu(e.ast),e);case"InvalidValue":{let r=j0(e);if(r!==void 0)return rp(r,e);let n=vm(e);return n===void 0?"Expected a valid value":`Invalid data ${n}`}case"MissingKey":return"Missing key";case"UnexpectedKey":{let r=vm(e);return r===void 0?"Expected no excess property":`Unexpected key with value ${r}`}case"Forbidden":return"Forbidden operation";case"OneOf":{let r=vm(e);return r===void 0?"Expected exactly one member to match":`Expected exactly one member to match the input ${r}`}}},G0=(e)=>np(e)??np(e.issue);function jQ(e){return(t)=>({issues:cu(t,[],e?.leafHook??W0,e?.checkHook??G0)})}function vm(e){return GQ(e)?it(e.input):void 0}function j0(e){let t=e.annotations?.expected;return typeof t==="string"?t:void 0}function rp(e,t){let r=vm(t);return r===void 0?`Expected ${e}`:`Expected ${e}, got ${r}`}function z0(e,t){let r=t(e);if(r!==void 0||e.issue._tag!=="InvalidValue")return r;let n=j0(e.issue);return n===void 0?rp(Q0(e.filter),e):rp(n,e.issue)}function cu(e,t,r,n,o){switch(e._tag){case"Filter":return cu(e.issue,t,r,n,o??z0(e,n));case"Encoding":return cu(e.issue,t,r,n,o);case"Pointer":return cu(e.issue,[...t,...e.path],r,n,o);case"Composite":case"AnyOf":{if(e._tag==="Composite"||e.issues.length>0)return e.issues.flatMap((i)=>cu(i,t,r,n,o));return[{path:t,message:o??np(e)??rp(iu(e.ast),e)}]}default:return[{path:t,message:o??r(e)}]}}function Q0(e){let t=e.annotations?.expected;if(typeof t==="string")return t;switch(e._tag){case"Filter":return"<filter>";case"FilterGroup":return e.checks.map((r)=>Q0(r)).join(" & ")}}function zQ(){return(e)=>pu(e,"")}var H0=zQ();function pu(e,t,r){let n;switch(e._tag){case"Filter":return pu(e.issue,t,r??z0(e,G0));case"Encoding":return pu(e.issue,t,r);case"Pointer":return pu(e.issue,t+oC(e.path),r);case"Composite":case"AnyOf":{if(e._tag==="Composite"||e.issues.length>0)return e.issues.map((o)=>pu(o,t,r)).join(`
31
+ `);n=r??np(e)??rp(iu(e.ast),e);break}default:n=r??W0(e);break}return t?`${n}
32
+ at ${t}`:n}function np(e){if(e._tag==="Pointer"||e._tag==="Composite")return;if(e._tag==="Encoding")return np(e.issue);let r=(e._tag==="Filter"?e.filter.annotations:("annotations"in e)?e.annotations:e.ast.annotations)?.[e._tag==="MissingKey"?"messageMissingKey":e._tag==="UnexpectedKey"?"messageUnexpectedKey":"message"];if(typeof r==="string")return r}function mu(e){let t;for(let r of e.reasons){if(!Hc(r)||!rb(r.error))return;t??=r.error}return t}function Ta(e,t){let r=mu(e);if(r===void 0)throw Error(t,{cause:e});return r}var J0=(e,t,r)=>{if(e.length<128)return;let n=Uint8Array;if(typeof n.fromBase64!=="function"){let o=Y0();if(o===void 0)return;let i=r?.alphabet??"base64",s=new Uint8Array(t),c=o.from(s.buffer),d=r!==void 0&&e.endsWith("=")?e.slice(0,e.indexOf("=")):e;return c.write(e,i)===t&&c.toString(i)===d?s:null}try{let o=n.fromBase64(e,r);return o.length===t?o:null}catch{return null}},ob=Object.getPrototypeOf(Uint8Array.prototype),QQ=Object.getOwnPropertyDescriptor(ob,"buffer").get,HQ=Object.getOwnPropertyDescriptor(ob,"byteOffset").get,VQ=Object.getOwnPropertyDescriptor(ob,"byteLength").get,Y0=()=>{let e=globalThis;return typeof e.process?.versions?.node==="string"&&typeof e.Buffer==="function"?e.Buffer:void 0},Z0=(e,t)=>{let r=Y0();if(r===void 0)return;let n=VQ.call(e);if(n<32)return;return r.from(QQ.call(e),HQ.call(e),n).toString(t)},X0=(e)=>e.indexOf(`
33
+ `)===-1&&e.indexOf("\r")===-1?e:e.replace(/[\n\r]/g,"");var Tm=(e)=>YQ(typeof e==="string"?t_.encode(e):e),Om=(e)=>{let t=X0(e),r=t.length;if(r%4!==0)return Mt(new Mc({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 Mt(new Mc({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=J0(t,i,void 0);if(s)return vt(s);if(s===null){let c=tH.exec(t);if(c!==null)return Mt(new Mc({kind:"Decode",module:"Base64",input:t,message:`Invalid character ${c[0]}`}))}try{let c=new Uint8Array(i);for(let d=0,x=0;d<r;d+=4,x+=3){let f=Cm(t.charCodeAt(d))<<18|Cm(t.charCodeAt(d+1))<<12|Cm(t.charCodeAt(d+2))<<6|Cm(t.charCodeAt(d+3));c[x]=f>>16,c[x+1]=f>>8&255,c[x+2]=f&255}return vt(c)}catch(c){return Mt(new Mc({kind:"Decode",module:"Base64",input:t,message:c instanceof Error?c.message:"Invalid input"}))}};var YQ=(e)=>{let t=e.length,r=Uint8Array.prototype.toBase64;if(t>=32){if(typeof r==="function")return r.call(e);let n=Z0(e,"base64");if(n!==void 0)return n}return t<128?ZQ(e):XQ(e)},ZQ=(e)=>{let t=e.length,r="",n;for(n=2;n<t;n+=3)r+=Jn[e[n-2]>>2],r+=Jn[(e[n-2]&3)<<4|e[n-1]>>4],r+=Jn[(e[n-1]&15)<<2|e[n]>>6],r+=Jn[e[n]&63];if(n===t+1)r+=Jn[e[n-2]>>2],r+=Jn[(e[n-2]&3)<<4],r+="==";if(n===t)r+=Jn[e[n-2]>>2],r+=Jn[(e[n-2]&3)<<4|e[n-1]>>4],r+=Jn[(e[n-1]&15)<<2],r+="=";return r},XQ=(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]=Ci[e[n-2]>>2],r[o+1]=Ci[(e[n-2]&3)<<4|e[n-1]>>4],r[o+2]=Ci[(e[n-1]&15)<<2|e[n]>>6],r[o+3]=Ci[e[n]&63];if(n===t+1)r[o]=Ci[e[n-2]>>2],r[o+1]=Ci[(e[n-2]&3)<<4],r[o+2]=ib,r[o+3]=ib;if(n===t)r[o]=Ci[e[n-2]>>2],r[o+1]=Ci[(e[n-2]&3)<<4|e[n-1]>>4],r[o+2]=Ci[(e[n-1]&15)<<2],r[o+3]=ib;return eH.decode(r)},t_=new TextEncoder,eH=new TextDecoder("utf-8",{ignoreBOM:!0}),Jn="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Ci=t_.encode(Jn),ib=61,tH=/[^A-Za-z0-9+/=]/,hu=new Uint8Array(123).fill(255);for(let e=0;e<Jn.length;e++)hu[Jn.charCodeAt(e)]=e;hu[61]=0;var Cm=(e)=>{if(e>=hu.length||hu[e]===255)throw TypeError(`Invalid character ${String.fromCharCode(e)}`);return hu[e]};var yu=(e)=>Object.assign(Object.create(pg),e);function rH(e){return n_((t,r)=>oe(e(t,r)))}function sb(e){return rH((t,r)=>{let n={message:e(t)};return T(t)?new lu(n,t.value,r):new lu(n)})}var nH=yu({_tag:"Passthrough"});function Yn(){return nH}function Tt(e){return yu({_tag:"Transform",transform:e})}function Ti(e){return yu({_tag:"TransformEffect",transform:e})}function ab(e){return yu({_tag:"TransformOptional",transform:e})}function n_(e){return yu({_tag:"TransformOptionalEffect",transform:e})}function o_(){return ab(()=>xe())}function i_(e){return n_((t)=>{let r=Wg(t,ir);return T(r)?j(r):Qo(e,Le)})}function Pm(){return Tt(globalThis.String)}function Rm(){return Tt(globalThis.Number)}function s_(){return Tt(NP)}function a_(){return Tt(FP)}function oH(e){return Ti((t,r)=>typeof t==="string"&&!BP(t)?oe(new Vr({expected:"a well-formed Unicode string"},t,r)):j(e(t)))}function c_(){return oH(Tm)}function p_(){return Ti((e,t)=>Hd(Kd(Om(e)),()=>new Vr({expected:"a valid Base64 string"},e,t)))}var cb=class extends mc{_tag="Middleware";decode;encode;constructor(e,t){super();this.decode=e,this.encode=t}flip(){return new cb(this.encode,this.decode)}},gu="~effect/SchemaTransformation/Transformation",or=class extends mc{[gu]=gu;_tag="Transformation";decode;encode;constructor(e,t){super();this.decode=e,this.encode=t}flip(){return new or(this.encode,this.decode)}};function cH(e){return Ye(e,gu)&&e[gu]===gu}var pb=(e)=>{if(cH(e))return e;return new or(e.decode,e.encode)};function _m(e){return new or(Ti(e.decode),Ti(e.encode))}function Um(e){return new or(Tt(e.decode),Tt(e.encode))}function d_(){return new or(s_(),Yn())}function pH(){return new or(a_(),Yn())}var dH=new or(Yn(),Yn());function Dm(){return dH}var xu=new or(Rm(),Tt((e)=>Object.is(e,-0)?"-0":globalThis.String(e)));var uH=(e)=>Zv(e)&&typeof e.message==="string",lH=(e)=>{let r=Object.hasOwn(e,"cause")?Error(e.message,{cause:u_(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},fH=(e)=>{try{let t=Xs(e);return t===void 0?it(e):JSON.parse(t)}catch{return it(e)}},mH=(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},hH=(e)=>{let t=new WeakSet,r=(n)=>{if(Xv(n)){if(t.has(n))return"[Circular]";t.add(n);let o=mH(n,e,r);return t.delete(n),o}return fH(n)};return r},u_=(e)=>uH(e)?lH(e):e;var l_=(e)=>Um({decode:u_,encode:hH(e)});var f_=_m({decode:(e,t)=>URL.canParse(e)?j(new URL(e)):oe(new Vr({expected:"a valid URL string"},e,t)),encode:(e)=>j(e.href)});var m_=new or(p_(),c_());function Ra(e){return(t)=>t._tag===e}var gb=Ra("Declaration");var gH=Ra("Never");var ap=Ra("Literal"),db=Ra("UniqueSymbol");var A_=Ra("Arrays"),v_=Ra("Objects");var _a=Ra("Suspend"),Jr=class{to;transformation;constructor(e,t){this.to=e,this.transformation=t}},Ua={},xb=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}},h_="~effect/Schema";class Zn{[h_]=h_;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 Bm(e){return e.checks===e.encodingChecks?e:kn(e,{checks:e.encodingChecks,encodingChecks:e.checks,encoding:void 0})}var Eu=class extends Zn{_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===He)return Qn;e??=this.run(this.typeParameters);try{return e(t,this,r)}catch(n){return Qr(n)}}}recur(e){let t=cp(this.typeParameters,e);return t===this.typeParameters?this:kn(this,{typeParameters:t,encoding:void 0})}flip(e){let t=Bm(this.recur(e));return this.run===this.encodingRun?t:kn(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>"}},xH=class extends Zn{_tag="Null";getParser(){return Ub(this,null)}getExpected(){return"null"}},Km=new xH;var SH=class extends Zn{_tag="Undefined";getParser(){return Ub(this,void 0)}toCodecJson(){return Br(this,[bH])}getExpected(){return"undefined"}},bH=new Jr(Km,new or(Tt(()=>{return}),Tt(()=>null))),Sb=new SH;var IH=class extends Zn{_tag="Unknown";getParser(){return vu(this,Yv)}getExpected(){return"unknown"}},Pa=new IH;var Zo=class extends Zn{_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 ${it(e)}`);this.literal=e}getParser(){return Ub(this,this.literal)}matchPart(e,t){return e===globalThis.String(this.literal)?this.literal:void 0}toCodecJson(){return typeof this.literal==="bigint"?y_(this):this}toCodecStringTree(){return typeof this.literal==="string"?this:y_(this)}getExpected(){return typeof this.literal==="string"?JSON.stringify(this.literal):globalThis.String(this.literal)}};function y_(e){let t=globalThis.String(e.literal);return Br(e,[new Jr(new Zo(t),new or(Tt(()=>e.literal),Tt(()=>t)))])}var EH=class extends Zn{_tag="String";getParser(){return vu(this,Lo)}matchPart(e,t){let r=this.checks;return r&&!t.disableChecks&&Es(r,e,void 0,this,t)?void 0:e}getExpected(){return"string"}},bs=new EH,kH=class extends Zn{_tag="Number";getParser(){return vu(this,rd)}matchKey(e,t){return this._match(QH,e,t)}matchPart(e,t){return this._match(yb,e,t)}_match(e,t,r){if(!e.test(t))return;let n=globalThis.Number(t);if(r.disableChecks||!this.checks)return n;return Es(this.checks,n,void 0,this,r)?void 0:n}toCodecJson(){if(this.checks&&(ub(this.checks,"effect/schema/isFinite")||ub(this.checks,"effect/schema/isInt")))return this;return Br(this,[LH])}toCodecStringTree(){if(this.toCodecJson()===this)return Br(this,[HH]);return Br(this,[VH])}getExpected(){return"number"}};function ub(e,t){return e.some((r)=>r.annotations?.representation?.id===t||r._tag==="FilterGroup"&&ub(r.checks,t))}var bb=new kH,wH=class extends Zn{_tag="Boolean";getParser(){return vu(this,Hl)}getExpected(){return"boolean"}},C_=new wH;var qm=class extends Zn{_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 d=!1;for(let x=0;x<t.length;x++)if(Xo(t[x]))d=!0;else if(d)throw Error("A required element cannot follow an optional element. ts(1257)");if(d&&r.length>1)throw Error("A required element cannot follow an optional element. ts(1257)");for(let x=1;x<r.length;x++)if(Xo(r[x]))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(f,g){if(g<i)return n[g];else if(g>=f)return o[g-f+1];return o[0]}let d=(f)=>{let{input:g,len:I,options:w}=f;if(r.rest.length===0&&I>i)for(let A=i;A<I;A++){let y=new nb(r,g[A],w),h=new In([A],y);if(w.errors==="all")if(f.issues)f.issues.push(h);else f.issues=[h];else return oe(new Nr(r,[h],g,w))}if(f.issues)return oe(new Nr(r,f.issues,g,w));return Fr(f.output)},x=(f,g)=>{let I=f.length,w={ast:r,getParser:c,input:f,len:I,tailThreshold:Math.max(i,I-s),output:[],issues:void 0,options:g},A=r.rest.length===0?i:Math.max(I,i+s),y=g.concurrency===void 0?1:Td(g.concurrency),h=y===1?vH(w,f,0,A):CH(w,f,{concurrency:y,end:A});if(!h)return d(w);if(mt(h))return Sr(h,()=>d(w));let S=!0;return Ze(()=>{if(!S)return x(f,g);return S=!1,Ae(h,()=>d(w))})};return(f,g)=>{if(f===He)return Qn;try{if(!Array.isArray(f))return oe(new Vn(r,f,g));if(!n)n=r.elements.map((I)=>({ast:I,parser:t(I)})),o=r.rest.map((I)=>({ast:I,parser:t(I)}));return x(f,g)}catch(I){return Qr(I)}}}recur(e){let t=cp(this.elements,e),r=cp(this.rest,e);return t===this.elements&&r===this.rest?this:new qm(this.isMutable,t,r,this.annotations,this.checks,void 0,this.context,this.encodingChecks)}flip(e){return Bm(this.recur(e))}getExpected(){return"array"}};function AH(e,t,r,n){if(r._tag==="Failure")return Fm(e,e.ast,n,r);let o=pr(r)?t:r[qe];if(o!==He)e.output[n]=o;else{let i=e.getParser(e.tailThreshold,n);if(Xo(i.ast))return;let s=new In([n],new uu(i.ast.context?.annotations));if(e.options.errors==="all")if(e.issues)e.issues.push(s);else e.issues=[s];else return $n(new Nr(e.ast,[s],e.input,e.options))}}var T_={onItem(e,t,r){let n=r<e.len?t:He;return e.getParser(e.tailThreshold,r).parser(n,e.options)},step:AH},vH=$f()(T_),CH=Wf()(T_),Fm=(e,t,r,n)=>{if(n.cause.reasons.length===0)return n;let o=mu(n.cause);if(o===void 0)return cs(ps(n.cause,(s)=>new Nr(t,[new In([r],s)],e.input,e.options)));let i=new In([r],o);if(e.options.errors==="all")if(e.issues)e.issues.push(i);else e.issues=[i];else return $n(new Nr(t,[i],e.input,e.options))},O_="[+-]?(?:\\d+(?:\\.\\d+)?|\\.\\d+)(?:[Ee][+-]?\\d+)?";function bu(e,t,r=Ua){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(Db(bo(t)))}var Ib=class{name;type;constructor(e,t){this.name=e,this.type=t}};function P_(e){switch(e._tag){case"String":case"Number":case"Symbol":case"TemplateLiteral":return!0;case"Union":return e.types.every(P_);default:return!1}}function R_(e){let t=vb(e);switch(t._tag){case"String":case"Number":case"Symbol":case"TemplateLiteral":return!0;case"Union":return t.types.every(R_);default:return!1}}function TH(e){return P_(e)&&R_(e)}var __=class{parameter;type;constructor(e,t){if(!TH(e))throw Error(`Invalid index signature parameter ${e._tag}`);if(this.parameter=e,this.type=t,Xo(t)||t.encoding!==void 0&&Xo(bo(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.")}},Eb=class extends Zn{_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 vu(r,Sg);let i,s,c=()=>{if(!i)i=r.propertySignatures.map((g)=>({parser:t(g.type),name:g.name,type:g.type,ownOnly:M_(g.name)})),s=o?r.indexSignatures.map((g)=>({is:g,parserKey:e(Db(g.parameter)),parserValue:t(g.type)})):void 0;return i},d=()=>{let g=new Set(r.propertySignatures.map((h)=>typeof h.name==="number"?globalThis.String(h.name):h.name)),I=(h,S,H,te,E)=>{if(E._tag==="Failure")return Fm(h,r,S,E)??ho;let ge=pr(E)?te:E[qe];if(H!==He&&ge!==He){if(n&&(g.has(S)||g.has(typeof H==="number"?globalThis.String(H):H)))return ho;hr(h.out,H,ge)}return ho},w=(h,S,H,te)=>{if(!te){let z=H.parserKey(S,h.options);if(!mt(z))return Ae(ba(z),(re)=>w(h,S,H,re));te=z}if(te._tag==="Failure")return Fm(h,r,S,te)??ho;let E=pr(te)?S:te[qe],ge=h.input[S],le=H.parserValue(ge,h.options);return mt(le)?I(h,S,E,ge,le):Ae(ba(le),(z)=>I(h,S,E,ge,z))},A=(h,S,H)=>{let te=h.input[S],E=H.parserValue(te,h.options);return mt(E)?I(h,S,S,te,E):Ae(ba(E),(ge)=>I(h,S,S,te,ge))},y=o?Wf()({onItem:(h,[S,H])=>H.is.parameter===bs?A(h,S,H):w(h,S,H),step:(h,S,H)=>H._tag==="Failure"?H:void 0}):void 0;return XP(function*(h,S){if(h===He)return He;if(!(typeof h==="object"&&h!==null&&!Array.isArray(h)))return yield*oe(new Vn(r,h,S));c();let H=h,te={},E={ast:r,input:H,out:te,issues:void 0,options:S},ge=S.errors==="all",le=S.onExcessProperty==="error",z=S.concurrency===void 0?1:Td(S.concurrency),re=o&&le?r.indexSignatures.map((V)=>bu(H,V.parameter,S)):void 0;if(le){let V=re?new Set(g):g;if(re)for(let ie of re)for(let de of ie)V.add(de);let ne=wr(H);for(let ie=0;ie<ne.length;ie++){let de=ne[ie];if(!V.has(de)){let pe=new nb(r,H[de],S),he=new In([de],pe);if(ge){if(E.issues)E.issues.push(he);else E.issues=[he];continue}else return yield*oe(new Nr(r,[he],h,S))}}}if(n){let V=z===1?g_(E,i):OH(E,i,{concurrency:z});if(V)yield*V}if(o&&z===1)for(let V=0;V<o;V++){let ne=s[V],ie=ne.is.parameter===bs?A:w,de=re?.[V]??(ne.is.parameter===bs?Object.keys(H):bu(H,ne.is.parameter,S));for(let pe=0;pe<de.length;pe++){let he=ie(E,de[pe],ne);if(!mt(he))yield*he;else if(he._tag==="Failure")return yield*he}}else if(y){let V=pa();for(let ie=0;ie<o;ie++){let de=s[ie],pe=re?.[ie]??(de.is.parameter===bs?Object.keys(H):bu(H,de.is.parameter,S));for(let he=0;he<pe.length;he++)V.push([pe[he],de])}let ne=y(E,V,{concurrency:z});if(ne)yield*ne}if(E.issues)return yield*oe(new Nr(r,E.issues,h,S));return te})};if(o)return d();let x,f=(g,I,w)=>{let A=i[I];return Ae(ba(w),(y)=>{let h={...g,out:{...g.out}},S=lb(h,A,y);if(S)return S;let H=()=>Fr(h.out),te=g_(h,i.slice(I+1));return te?Sr(te,H):H()})};return(g,I)=>{if(g===He)return Qn;if(I.errors==="all"||I.onExcessProperty!==void 0||I.concurrency!==void 0&&Td(I.concurrency)!==1)return(x??=d())(g,I);if(!(typeof g==="object"&&g!==null&&!Array.isArray(g)))return oe(new Vn(r,g,I));let w=c(),A=g,y={},h={ast:r,input:A,out:y,issues:void 0,options:I};try{for(let S=0;S<w.length;S++){let H=w[S],te=H.name,E=H.ownOnly?Object.hasOwn(A,te):(te in A),ge=E?A[te]:He,le=H.parser(ge,I);if(!mt(le))return f(h,S,le);if(pr(le)){if(E)hr(y,te,ge);continue}let z=lb(h,H,le);if(z)return z}}catch(S){return Qr(S)}return Fr(y)}}recur(e,t=e){let r=cp(this.propertySignatures,(o)=>{let i=e(o.type);return i===o.type?o:new Ib(o.name,i)}),n=cp(this.indexSignatures,(o)=>{let i=t(o.parameter),s=e(o.type);return i===o.parameter&&s===o.type?o:new __(i,s)});return r===this.propertySignatures&&n===this.indexSignatures?this:kn(this,{propertySignatures:r,indexSignatures:n,encoding:void 0})}flip(e){return Bm(this.recur(e))}getExpected(){if(this.propertySignatures.length===0&&this.indexSignatures.length===0)return"object | array";return"object"}};function lb(e,t,r){if(r._tag==="Failure")return Fm(e,e.ast,t.name,r);if(pr(r))return;let n=r[qe];if(n!==He){hr(e.out,t.name,n);return}if(delete e.out[t.name],!Xo(t.type)){let o=new In([t.name],new uu(t.type.context?.annotations));if(e.options.errors==="all"){if(e.issues)e.issues.push(o);else e.issues=[o];return}else return $n(new Nr(e.ast,[o],e.input,e.options))}}var U_={onItem(e,t){if(!(t.ownOnly?Object.hasOwn(e.input,t.name):(t.name in e.input)))return t.parser(He,e.options);let r=e.input[t.name];return hr(e.out,t.name,r),t.parser(r,e.options)},step:lb},g_=$f()(U_),OH=Wf()(U_);function kb(e,t){if(!e)return t;if(!t)return e;return[...e,...t]}function $m(e,t,r){return new Eb(wr(e).map((n)=>new Ib(n,e[n].ast)),[],r,t)}function Wm(e){return e.ast}function Gm(e,t,r){return new Is(e.map(Wm),t,void 0,r)}function D_(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=kb(o,i.checks)}return new Eb(r,n,void 0,o)}var wb=Vp((e)=>{while(!0){if(_a(e))return Pa;let t=e.encoding;if(!t)return e.recur?.(wb,Ce)??e;if(t.some((r)=>r.transformation._tag==="Middleware"&&r.transformation.decode!==Ce))return Pa;e=t[t.length-1].to}});function L_(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(L_)));default:return["null","undefined","string","number","boolean","symbol","bigint","object","array","function"]}}function Iu(e){switch(e._tag){default:return[];case"Declaration":{let t=e.annotations?.[wm];return Array.isArray(t)?t:[]}case"Objects":return e.propertySignatures.flatMap((t)=>{let r=t.type;if(!Xo(r)){if(ap(r))return[{key:t.name,literal:r.literal}];if(db(r))return[{key:t.name,literal:r.symbol}]}return[]});case"Arrays":return e.elements.flatMap((t,r)=>{if(!Xo(t)){if(ap(t))return[{key:r,literal:t.literal}];if(db(t))return[{key:r,literal:t.symbol}]}return[]});case"Union":{if(e.types.length===0)return[];let t=e.types.map((r)=>Iu(wb(r)));return t[0].filter((r)=>t.every((n)=>n.some((o)=>o.key===r.key&&o.literal===r.literal)))}case"Suspend":return Iu(e.thunk())}}var x_=new WeakMap,Lm=Object.freeze([]),S_=(e)=>e===null?"null":Array.isArray(e)?"array":typeof e,PH=new Set(Reflect.ownKeys(Object.prototype)).add("__proto__"),M_=(e)=>PH.has(typeof e==="number"?globalThis.String(e):e),Mm=(e,t)=>Object.hasOwn(e,t)||(t in e)&&!M_(t);function RH(e){let t=x_.get(e);if(t)return t;let r,n=0,o,i,s=!0,c=[];for(let f=0;f<e.length;f++){let g=e[f],I=wb(g);if(gH(I))continue;if(ap(I)||db(I)){i??=new Map;let A=ap(I)?I.literal:I.symbol;c[f]=A;let y=i.get(A);if(!y)i.set(A,y=[]);y.push(f)}else s=!1;let w=Iu(I);if(w.length){r??=new Map,n++;for(let{key:A,literal:y}of w){let h=r.get(A);if(!h)r.set(A,h=[new Map,new Set]);h[1].add(f);let S=h[0].get(y);if(!S)h[0].set(y,S=new Set);S.add(f)}}else{o??={};let A=L_(I);for(let y of A)(o[y]??=[]).push(f)}}let d={},x=(f)=>d[f]??=Object.freeze(o?.[f]??Lm);if(s&&i)i.forEach(Object.freeze),t=(f)=>i.get(f)??Lm;else if(r?.size===1&&!o){let[f,[g]]=r.entries().next().value,I=new Map;for(let[A,y]of g)I.set(A,Object.freeze(Array.from(y)));let w=Object.freeze(e.map((A,y)=>y));t=(A,y)=>{if(nd(A)){let h=Mm(A,f)?A[f]:void 0;if(h!==void 0)return I.get(h)??Lm;if(y)return w}return Lm}}else if(r){let f;for(let g of r)if((!f||g[1][0].size>f[1][0].size)&&g[1][1].size===n)f=g;t=(g,I)=>{let w=S_(g);if(!nd(g))return x(w);let A=new Set(o?.[w]),y;if(f){let[h,[S]]=f,H=Mm(g,h),te=H?g[h]:void 0;if(H&&(!I||te!==void 0)){let E=S.get(te);if(!E)return x(w);for(let ge of E)A.add(ge);y=h}}if(y===void 0)for(let[h,[S,H]]of r){let te=Mm(g,h),E=te?g[h]:void 0;if(te&&(!I||E!==void 0)){let ge=S.get(E);if(ge)for(let le of ge)A.add(le)}else if(I)for(let ge of H)A.add(ge)}for(let[h,[S,H]]of r){if(h===y)continue;let te=Mm(g,h),E=te?g[h]:void 0;if(te&&(!I||E!==void 0)){let ge=S.get(E);for(let le of A)if(H.has(le)&&!ge?.has(le))A.delete(le)}}return Array.from(A).sort((h,S)=>h-S)}}else t=(f)=>{let g=x(S_(f));return i?g.filter((I)=>c[I]===void 0||c[I]===f):g};return x_.set(e,t),t}var Is=class extends Zn{_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,d)=>{if(c===He)return Qn;let x=(s??=RH(r.types))(c,n);if(x.length===0)return oe(new fu(r,[],c,d));if(x.length===1){let f=i(x[0])(c,d);if(f._tag==="Success")return f;return mt(f)?F_(r,f.cause,c,d):_H(r,f,c,d)}return N_(r,i,x,c,d)}}recur(e){let t=cp(this.types,e);return t===this.types?this:kn(this,{types:t,encoding:void 0})}flip(e){return Bm(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=bo(n);switch(o._tag){case"Arrays":{let i=o.elements.filter(ap);if(i.length>0)return`${I_(o.isMutable)}[ ${i.map((s)=>e(s)+E_(s.context?.isOptional)).join(", ")}, ... ]`;break}case"Objects":{let i=o.propertySignatures.filter((s)=>ap(s.type));if(i.length>0)return`{ ${i.map((s)=>`${I_(s.type.context?.isMutable)}${Sc(s.name)}${E_(s.type.context?.isOptional)}: ${e(s.type)}`).join(", ")}, ... }`;break}}return e(o)});return Array.from(new Set(r)).join(" | ")}};function F_(e,t,r,n){let o=mu(t);if(!o)return cs(t);return $n(new fu(e,[o],r,n))}function _H(e,t,r,n){return Cr(t,(o)=>F_(e,o,r,n))}function N_(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=UH(i,r);if(!s){if(i.out)return i.out;return oe(new fu(e,i.issues??[],n,o))}if(mt(s))return b_(s,i);let c=!0;return Ze(()=>{if(!c)return N_(e,t,r,n,o);return c=!1,b_(s,i)})}function b_(e,t){return Sr(e,(r)=>{if(t.out)return pr(t.out)?j(t.input):t.out;return oe(new fu(t.ast,t.issues??[],t.input,t.options))})}var UH=$f()({onItem(e,t){return e.parser(t)(e.input,e.options)},step(e,t,r){if(r._tag==="Failure"){let n=mu(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]),$n(new K0(e.ast,e.successes,e.input,e.options));if(e.out=r,e.successes)e.successes.push(e.ast.types[t]);else return ho}}}),B_=new Is([new Zo("Infinity"),new Zo("-Infinity"),new Zo("NaN")]);function I_(e){return e?"":"readonly "}function E_(e){return e?"?":""}function DH(e){let t;return()=>t??=e()}var fb=class extends mc{_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 fb(this.run,{...this.annotations,...e},this.aborted)}abort(){return new fb(this.run,this.annotations,!0)}and(e,t){return new Nm([this,e],t)}},Nm=class extends mc{_tag="FilterGroup";checks;annotations;constructor(e,t=void 0){super();this.checks=e,this.annotations=t}annotate(e){return new Nm(this.checks,{...this.annotations,...e})}and(e,t){return new Nm([this,e],t)}};function jm(e,t,r=!1){return new fb((n,o,i)=>$0(o,e(n,o,i),n,i),t,r)}function K_(e){return jm((t)=>globalThis.Number.isFinite(t),{expected:"a finite number",representation:{id:"effect/schema/isFinite",payload:null},toJsonSchema:()=>({type:"number"}),arbitraryConstraint:{number:"finite"},...e})}var q_=Da(bb,[K_()]),LH=new Jr(new Is([q_,B_]),new or(Rm(),Tt((e)=>globalThis.Number.isFinite(e)?e:globalThis.String(e))));function Ab(e,t){let r=new globalThis.RegExp(e),n={source:r.source,flags:r.flags};return jm((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 mb=new WeakMap;function kn(e,t){return Object.assign(Object.create(Object.getPrototypeOf(e)),e,t)}function $_(e,t){let r=kn(e,t);return mb.set(r,ku(e)),r}function ku(e){let t=mb.get(e);if(t!==void 0)return t;if(e.encoding===void 0)return e;let r=kn(e,{encoding:void 0});return mb.set(e,r),r}function Br(e,t){return e.encoding===t?e:$_(e,{encoding:t})}function pp(e,t){if(e.context===t)return e;let r=ku(e);if(r.context===t&&r.encoding===e.encoding)return r;return $_(e,{context:t})}function vb(e){return e.encoding?vb(e.encoding[e.encoding.length-1].to):e}function zm(e,t){if(e.checks)return Cb(e,W_(e.checks,(r)=>r.annotate(t)));return kn(e,{annotations:{...e.annotations,...t}})}function Cb(e,t){if(e._tag==="Suspend"&&t)throw Error("Cannot add checks to Suspend");if(e.checks===t)return e;return kn(e,{checks:t})}function Da(e,t){return Cb(e,kb(e.checks,t))}function Qm(e,t){let r=t(e.to);return r===e.to?e:new Jr(r,e.transformation)}function W_(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 Tb(e,t){return W_(e,(r)=>Qm(r,t))}function G_(e){return(t)=>t.encoding?Br(t,Tb(t.encoding,e)):t}function j_(e,t){return G_((r)=>pp(r,t))(e)}function Ob(e){function t(r){return r.encoding?Br(r,Tb(r.encoding,t)):e(r)}return po(t)}function Hm(e,t){function r(n){if(n.encoding){let o=n.encoding[n.encoding.length-1];return t?.stopAt?.(o)?n:Br(n,Tb(n.encoding,r))}return e(n)}return Vp(r)}function z_(e,t){return Q_(e,t,Oi(e))}function Q_(e,t,r){let n=new Jr(e,t);return Br(r,r.encoding?[...r.encoding,n]:[n])}function cp(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 Pb(e,t=Xo(e),r=NH(e),n=e.context?.constructorDefault,o=e.context?.annotations){return pp(e,new xb(t,r,n,o))}function MH(e){let t=e==="isOptional"?!0:void 0,r=e==="isMutable"?!0:void 0,n=Vp((i)=>o(i.context?.[e]?i:Pb(i,t,r))),o=G_(n);return n}function Vm(e,t){return Pb(e,void 0,void 0,void 0,e.context?{...e.context.annotations,...t}:t)}var Jm=MH("isOptional"),H_=po((e)=>Jm(new Is([e,Sb])));function V_(e,t){return Pb(e,void 0,void 0,t)}function wu(e,t,r){return Q_(e,r,t)}function FH(e){let t=[],r=[];function n(i){if(!t.includes(i))t.push(i)}function o(i){switch(i._tag){case"Literal":if(xg(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 Rb(e,t){let{literals:r,parameters:n}=FH(e);return new Eb(r.map((o)=>new Ib(o,t)),n.map((o)=>new __(o,t)))}function Xo(e){return e.context?.isOptional??!1}function NH(e){return e.context?.isMutable??!1}function _b(e){return e.annotations?.[ou]===!0||e._tag==="FilterGroup"&&e.checks.every(_b)}function BH(e){function t(n){if(_b(n))return[n];return n._tag==="FilterGroup"?n.checks.flatMap(t):[]}let r=e.flatMap(t);return mf(r)?r:void 0}function J_(e,t,r){let n=new Set([e]);for(let i of n){if(r?.has(i))continue;if(!t(i))return!1;if(!_a(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 KH=new WeakSet;function Y_(e,t){let r=A_(e)||v_(e)||gb(e)&&e.typeParameters.length>0;if(r&&t.every(_b)||J_(e,(n)=>!n.encoding&&!_a(n),KH))return t;if(r)return BH(t)}function Z_(e){return gb(e)&&e.encodingRun!==void 0&&e.encodingRun!==e.run}function qH(e,t){function r(n){if(_a(n))return n.thunk===t;return!Z_(n)&&!(("encodingChecks"in n)&&n.checks&&Y_(n,n.checks)!==n.checks)}return J_(e,r)}var Su=new WeakMap,sp=new WeakMap,k_=new WeakSet,w_=new WeakSet,Au=new WeakMap,hb=new WeakMap,Oi=(e)=>Au.has(e)?$H(e):Oa(e),$H=po((e)=>{let t=Au.get(e);if(t&&k_.has(t))return t;let r=Oa(e);if(t)k_.add(r);return r});function Oa(e){let t=Su.get(e);if(t)return t;let r=Au.get(e),n=r&&Su.get(r)===r,o=r&&sp.get(r)||WH(e);if(n)sp.set(r,o);if(Su.set(e,o),o!==e)Su.set(o,o);return o}function X_(e,t){let r=ku(e);if(r!==e){let n=t(r);return n===r&&!e.encoding?e:pp(n,e.context)}}function WH(e){let t=X_(e,Oa);if(t)return t;if(_a(e))return hb.get(e.thunk)?.project(e)??e.recur(Oa);let r="recur"in e?e.recur(Oa):e;if("encodingChecks"in r&&r.encodingChecks)return kn(r,{encodingChecks:void 0,checks:kb(Y_(e,r.encodingChecks),r.checks)});return r===e&&Z_(r)&&Au.has(e)?kn(r,{}):r}var bo=(e)=>Oi(En(e));function GH(e,t){let r=Br(e,void 0),n=t.map((i)=>{let s=new Jr(En(r),i.transformation.flip());return r=i.to,s}).reverse(),o=En(r);return Br(o,o.encoding?[...o.encoding,...n]:n)}var En=po((e)=>{let t=jH(e);if(t!==e)Au.set(t,e);return t});function jH(e){if(e.encoding)return GH(e,e.encoding);let t=X_(e,En);if(t)return t;if(_a(e)){let r=hb.get(e.thunk);if(r)return kn(e,{thunk:r.source.thunk});let n=e.recur(En);return hb.set(n.thunk,{source:e,project(o){let i=DH(()=>zH(e.thunk(),i));return kn(o,{thunk:i})}}),n}return"flip"in e?e.flip(En):e}function zH(e,t){if(Su.get(e)!==e)return Oa(En(e));let r=sp.get(e);if(r)return r;if(qH(e,t))return sp.set(e,e),e;let n=Oa(En(e));if(w_.has(e)&&!sp.has(n))sp.set(n,e);return w_.add(n),n}function Ub(e,t){let r=t===0?vi:Fr(t);return(n,o)=>{if(n===He)return Qn;if(n===t)return r;return oe(new Vn(e,n,o))}}function vu(e,t){return(r,n)=>{if(r===He)return Qn;if(t(r))return vi;return oe(new Vn(e,r,n))}}var Db=Hm((e)=>{switch(e._tag){default:return e;case"Number":return e.toCodecStringTree();case"Union":return e.recur(Db)}}),Lb=Hm((e)=>{switch(e._tag){default:return e;case"Symbol":case"UniqueSymbol":return e.toCodecStringTree();case"Union":return e.recur(Lb)}});var yb=new globalThis.RegExp(`^${O_}$`),QH=new globalThis.RegExp(`^(?:${O_}|Infinity|-Infinity|NaN)$`);function eU(e){return Ab(yb,{expected:"a string representing a finite number",representation:{id:"effect/schema/isStringFinite",payload:null},toJsonSchema:()=>({pattern:yb.source}),...e})}var tU=Da(bs,[eU()]),HH=new Jr(tU,xu),VH=new Jr(new Is([tU,B_]),xu),JH="-?\\d+",Sce=new globalThis.RegExp(`^${JH}$`);var YH="Symbol\\(([\\s\\S]*)\\)",bce=new globalThis.RegExp(`^${YH}$`);function Es(e,t,r,n,o){for(let i=0;i<e.length;i++){let s=e[i];if(s._tag==="FilterGroup"){if(r=Es(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 d=new N0(s,c,t,o);if(r)r.push(d);else r=[d];if(o.errors!=="all"||s.aborted)return r}}}return r}function Ym(e){if(!gb(e))return;let t=e.annotations?.[Am];return Mo(t)?t(e.typeParameters):void 0}function ZH(e){return e===null||typeof e==="string"||typeof e==="boolean"||typeof e==="number"&&globalThis.Number.isFinite(e)}function XH(e){return e===void 0||typeof e==="string"}function rU(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 eV(e){return rU(e,ZH)}var nU=new Eu([],()=>(e,t,r)=>eV(e)?vi:oe(new Vn(t,e,r)),{representation:{id:"effect/schema/Json",payload:null},expected:"JSON value",toCodecJson:()=>{return},toCodecStringTree:()=>Mb});function tV(e){return rU(e,XH)}var rV=new Eu([],()=>(e,t,r)=>tV(e)?vi:oe(new Vn(t,e,r)),{expected:"StringTree",toCodecStringTree:()=>{return}}),Mb=new Jr(rV,Dm());function Fb(){return Object.assign((e)=>e,{option:(e)=>Le(e),result:(e)=>vt(e),is:(e)=>!0})}var sU=Fb(),aU=Fb(),iU="~effect/process/ChildProcessSpawner/ChildProcessHandle",nV={[iU]:iU,...Yi,toJSON(){return{_id:"ChildProcessHandle",pid:this.pid}}},Nb=(e)=>Object.setPrototypeOf({...e},nV),cU=(e)=>{let t=(n,o)=>e(n).pipe(Me((i)=>O0(o?.includeStderr===!0?i.all:v0(i.stdout,i.stderr))),Jo),r=(n,o)=>P0(t(n,o));return dp.of({spawn:e,exitCode:(n)=>Ia(Ae(e(n),(o)=>jn(o.exitCode,Gn(JS(o.all),Bd)))),streamString:t,streamLines:r,lines:(n,o)=>_0(r(n,o)),string:(n,o)=>U0(t(n,o))})};class dp extends Qt()("effect/process/ChildProcessSpawner"){}var Ma=new WeakMap,pU=(e)=>{if(Ma.has(e))return Ma.get(e);else throw Error("Unable to get redacted value"+(e.label?` with label: "${e.label}"`:""))};var dU="~effect/Redacted",wn=(e)=>Ye(e,dU),ei=(e,t)=>{let r=Object.create(iV);if(t?.label)r.label=t.label;return Ma.set(r,e),r},iV={[dU]:{_A:(e)=>e},label:void 0,...Lr,toJSON(){return this.toString()},toString(){return`<redacted${Lo(this.label)?":"+this.label:""}>`},[Ut](){return Je(Ma.get(this))},[Dt](e){return wn(e)&&mr(Ma.get(this),Ma.get(e))}},Xn=pU;var uU=(e)=>bC((t,r)=>e(Xn(t),Xn(r)));class Fa extends Ko("CommandLineError"){}var fU=(e,t)=>{if(e.length===0)return"";let r=t?.format??"posix";return pV(r,e.map((n,o)=>wn(n)?"<redacted>":xV(cV(r,n,o===0))))},mU=(e,...t)=>{let r=e.findIndex((n)=>n===void 0);if(r!==-1)return Mt(new Fa({reason:"InvalidEscape",message:`Template part ${r} contains an invalid escape sequence`}));return AV(e,t)},sV=(e)=>wn(e)?Xn(e):String(e),lU=(e)=>wn(e)?e:String(e);var aV=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"]),cV=(e,t,r)=>{switch(e){case"posix":return r&&aV.has(t)?`'${t}'`:uV(t);case"powershell":return lV(t);case"windows":return r&&!t.includes('"')?hV(t):mV(t)}},pV=(e,t)=>e==="powershell"?`& ${t.join(" ")}`:t.join(" "),dV=/^[A-Za-z0-9_@+:,./-]+$/,uV=(e)=>dV.test(e)?e:`'${e.replace(/['\\]/g,(t)=>`'\\${t}'`)}'`,lV=(e)=>`'${e.replace(/['\u2018\u2019\u201A\u201B]/g,"$&$&")}'`,fV=/[ \t\n\v"]/,mV=(e)=>{if(e.length>0&&!fV.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)+'"'},hV=(e)=>e.length>0&&!/[ \t]/.test(e)?e:`"${e}"`,yV=/[\u0000-\u001f\u007f-\u009f\u2028\u2029]/g,gV={"\n":"\\n","\r":"\\r","\t":"\\t"},xV=(e)=>e.replace(yV,(t)=>gV[t]??`\\u${t.charCodeAt(0).toString(16).padStart(4,"0")}`),SV="|&;<>()",bV="*?[",IV=/[A-Za-z_0-9{(@*#?$!'"-]/,EV=/[A-Za-z_0-9{(@*#?$!-]/,kV=/^[A-Za-z_][A-Za-z0-9_]*\+?$/,Bb=(e)=>e===" "||e==="\t"||e===`
34
+ `,wV=(e,t,r)=>{if(SV.includes(e))return`The operator "${e}" needs a shell`;if(e==="`")return"Command substitution needs a shell";if(e==="$"&&t!==void 0&&IV.test(t))return`The expansion "$${t}" needs a shell`;if(bV.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&&!Bb(t))return'A leading "=" is expanded by zsh';return},AV=(e,t)=>{let r=[],n=[],o=!0,i=0,s=void 0,c=0,d=0,x=(I,w,A=d)=>Mt(new Fa({reason:I,message:`${w} in template part ${A}`})),f=()=>{if(n.length===0)return;let I=n.map(sV).join("");r.push(n.length===1&&wn(n[0])?n[0]:n.some(wn)?ei(I):I),n=[],o=!0,i=0},g=(I)=>{for(let w=0;w<I.length;w++){let A=I[w],y=I[w+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!==`
35
+ `)n.push(y);w++}else if(A==="`")return x("UnsupportedSyntax","Command substitution needs a shell");else if(A==="$"&&y!==void 0&&EV.test(y))return x("UnsupportedSyntax",`The expansion "$${y}" needs a shell`);else n.push(A);else if(Bb(A))f();else if(A==="\\"){if(y===void 0)return x("InvalidEscape","A trailing backslash escapes nothing");if(y!==`
36
+ `)n.push(y),o=!1;w++}else if(A==="'"||A==='"')s=A,c=d,n.push(""),o=!1;else{let h=wV(A,y,n.length===0);if(h!==void 0)return x("UnsupportedSyntax",h);if(A==="{")i++;else if(A==="}"){if(i>0)i--}else if(i>0&&(A===","||A==="."&&y==="."))return x("UnsupportedSyntax","Brace expansion needs a shell");else if(A==="="&&r.length===0&&o&&kV.test(n.join("")))return x("UnsupportedSyntax","A variable assignment needs a shell");n.push(A)}}return};for(;d<e.length;d++){let I=g(e[d]);if(I!==void 0)return I;if(d===t.length)break;let w=t[d];if(Array.isArray(w)){let A=e[d+1][0];if(n.length>0||(A===void 0?d+1<t.length:!Bb(A)))return x("UnsupportedSyntax","An interpolated array must be a separate argument");for(let y of w)r.push(lU(y))}else n.push(lU(w)),o=!1}if(s!==void 0)return x("UnterminatedQuote","The quote is not closed",c);return f(),vt(r)};var yU="~effect/process/ChildProcess",vV={...Bo({label:"Command",evaluate(e){return Rc(e.context,dp).spawn(this)}}),[yU]:yU};var Cu=(e,t,r)=>Object.assign(Object.create(vV),{_tag:"StandardCommand",command:e,args:t,options:r});var Zm=function(...t){if(gU(t[0])){let[i,...s]=t,[c,d]=xU(i,s);return Cu(c,d,{})}if(typeof t[0]==="object"&&!Array.isArray(t[0])&&!gU(t[0])){let i=t[0];return function(s,...c){if(i.shell!==void 0&&i.shell!==!1)return Cu(CV(s,c),[],i);let[d,x]=xU(s,c);return Cu(d,x,i)}}if(typeof t[0]==="string"&&!Array.isArray(t[1])){let[i,s={}]=t;return Cu(i,[],s)}let[r,n=[],o={}]=t;return Cu(r,n,o)};var gU=(e)=>Array.isArray(e)&&("raw"in e)&&Array.isArray(e.raw),Xm=(e)=>{let t=/^fd(\d+)$/.exec(e);if(t===null)return;let r=parseInt(t[1],10);return r>=3?r:void 0},SU=(e)=>`fd${e}`,xU=(e,t)=>{let[r="",...n]=Xg(mU(e,...t));if(typeof r!=="string")throw new Fa({reason:"InvalidArgument",message:"The program name of a command cannot be Redacted"});return[r,n]},CV=(e,t)=>{if(t.length>0)throw new Fa({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 Fa({reason:"InvalidEscape",message:"Template part 0 contains an invalid escape sequence"});return r};import*as nh from"child_process";import{PassThrough as Kb}from"stream";var bU=(e,t,r)=>{let n=e.detached??r!=="win32";return{...t,detached:n,shell:e.shell,windowsHide:e.windowsHide??!n}};var ht=(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 xo({_tag:o,module:e,method:t,pathOrDescriptor:n,syscall:r.syscall,cause:r})};import{finished as IU}from"stream";var eh=(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 up=(e)=>jS(KS(OV(e),(t)=>[t])),OV=(e)=>Mr((t)=>{let r=e.evaluate(),n=RV({...e,writable:r,pull:t});return j(e.endOnDone===!1?n:wi(n,(o)=>Ii(o)?et:PV(r)))}),PV=(e)=>un((t)=>{let r=()=>t(et);if(e.closed){let n=IU(e,{readable:!1},()=>{n(),r()})}else eh(e,pi,r)}),RV=(e)=>Vc((t)=>{let r=t.currentDispatcher,n=$o(),o=$o(),i=(x)=>mo(o,Xf(()=>e.onError(x))),s=!1,c=(x)=>{s=!0,i(x)};e.writable.on("error",c);let d=IU(e.writable,{readable:!1},(x)=>{if(x)i(x);else mo(n,et)});return e.pull.pipe(Ae((x)=>{let f=0;return un((g)=>{let I=!1,w=()=>r.scheduleTask(A,0),A=()=>{e.writable.off("drain",A),e.writable.off("finish",w);for(;f<x.length;){if(I)return;if(!e.writable.write(x[f++],e.encoding,(h)=>{if(!h)return;if(e.writable.closed)i(h);else r.scheduleTask(()=>i(h),0)})){if(!I)e.writable.once("drain",A),e.writable.once("finish",w);return}}if(!I)g(et)};return A(),We(()=>{I=!0,e.writable.off("drain",A),e.writable.off("finish",w)})})}),zo({disableYield:!0}),e.endOnDone!==!1?go((x)=>(e.writable.end(),Gn(on(n),vr(x)))):Ce,jn(on(o)),jo(We(()=>{d();let x=()=>{e.writable.off("error",c),e.writable.off("error",x),e.writable.off("close",x)};if(e.writable.errored&&!e.writable.closed&&!s)e.writable.once("error",x),e.writable.once("close",x);else x()})))});import{finished as UV,Readable as Zce}from"stream";var lp=(e)=>ln(DV(e)),DV=(e)=>Mr((t,r)=>LV({scope:r,readable:e.evaluate(),onError:e.onError??MV,chunkSize:e.chunkSize,readSize:e.readSize,closeOnDone:e.closeOnDone}));var LV=(e)=>{let t=e.readable,r=e.chunkSize??4096,n=e.closeOnDone??!0,o=e.exit??TR(void 0),i=e.latch??AR(!1);function s(){i.openUnsafe()}t.on("readable",s);let c=UV(t,{readable:!0,writable:!1},(x)=>{o.current??=$n(x?e.onError(x):Md()),i.openUnsafe()}),d=Ze(function x(){let f=e.readable.read(e.readSize);if(f===null){if(o.current)return o.current;if(t.readableEnded)return oe(Md());return i.closeUnsafe(),Ae(i.await,x)}let g=Xi(f);while(g.length<r){if(f=e.readable.read(e.readSize),f===null)break;g.push(f)}return j(g)});return xr(_d(e.scope,We(()=>{if(t.off("readable",s),n)eh(t,c);else c()})),d)};var MV=(e)=>new DP(e);var Na=(e)=>e instanceof globalThis.Error?e:new globalThis.Error(String(e)),Io=(e,t,r)=>{let{commands:n}=Wb(r),o=globalThis.process.platform==="win32"?"windows":"posix",i=n.map((s)=>fU([s.command,...s.args],{format:o})).join(" | ");return ht("ChildProcess",e)(t,[i])},rh=(e)=>wn(e)?Xn(e):e,NV=(e)=>{if(e.command.includes("\x00"))return"The command contains a NUL character";let t=e.args.findIndex((r)=>rh(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&&rh(n).includes("\x00"))return`The environment variable ${r} contains a NUL character`;return},EU=1000,BV=10,kU=(e)=>{let t=()=>{};e.on("error",t),e.once("close",()=>e.off("error",t))},qb=(e)=>e.exitCode!==null||e.signalCode!==null,th=(e)=>globalThis.process.platform!=="win32"&&e.options.detached!==!1,AU=(e)=>e?.code==="EPERM",wU=(e,t)=>{if(t.lost===!0)return!1;if(!qb(t))return!0;if(!th(e))return!1;try{return globalThis.process.kill(-t.pid,0),!0}catch(r){return AU(r)}},KV=(e,t=()=>{})=>{if(qb(e)){t(null);return}nh.execFile("taskkill",["/pid",String(e.pid),"/T","/F"],{windowsHide:!0},t)},qV=(e,t,r,n)=>{let o=nh.spawn(e,t,r);for(let i of n){let s=o.stdio[i];if(s&&"allowHalfOpen"in s)s.allowHalfOpen=!0}return o},$V=be(function*(e){let t=yield*nu,r=yield*Ca,n=be(function*(z){if(gc(z.cwd))return;return yield*t.access(z.cwd),r.resolve(z.cwd)}),o=(z)=>{if(z.env===void 0)return;let re=z.extendEnv===!0?{...globalThis.process.env}:{};for(let[V,ne]of Object.entries(z.env))if(ne===void 0)delete re[V];else re[V]=rh(ne);return re},i=(z)=>Aa(z)?"pipe":z,s=(z)=>eu(z)?"pipe":z,c=(z)=>{let re={stream:"pipe",encoding:"utf-8",endOnDone:!0};if(gc(z.stdin))return re;if(typeof z.stdin==="string")return{...re,stream:z.stdin};if(Aa(z.stdin))return{...re,stream:z.stdin};return{stream:z.stdin.stream,encoding:z.stdin.encoding??re.encoding,endOnDone:z.stdin.endOnDone??re.endOnDone}},d=(z,re)=>{let V=z[re];if(gc(V))return{stream:"pipe"};if(typeof V==="string")return{stream:V};if(eu(V))return{stream:V};return{stream:V.stream}},x=(z)=>{if(gc(z.additionalFds))return[];let re=[];for(let[V,ne]of Object.entries(z.additionalFds)){let ie=Xm(V);if(ir(ie))re.push({fd:ie,config:ne})}return re.sort((V,ne)=>V.fd-ne.fd)},f=(z,re,V,ne)=>{let ie=[i(z.stream),s(re.stream),s(V.stream)];if(ne.length===0)return ie;let de=ne.reduce((pe,{fd:he})=>Math.max(pe,he),2);for(let pe=3;pe<=de;pe++)ie[pe]="ignore";for(let{fd:pe}of ne)ie[pe]="pipe";return ie},g=(z,re,V)=>sm(R0(T0(z,(ne)=>bP(V,ne)),re)),I=be(function*(z,re,V,ne){if(V.length===0)return{getInputFd:()=>tu,getOutputFd:()=>tp};let ie=new Map,de=new Map,pe=(ke,Oe,Se)=>Ze(()=>{let Qe=tu;if(Oe&&"write"in Oe)kU(Oe),Qe=up({evaluate:()=>Oe,onError:(Be)=>Io(`fromWritable(fd${ke})`,Na(Be),z)});if(Se)return Me(g(Se,Qe,ne),()=>{ie.set(ke,Qe)});return ie.set(ke,Qe),et}),he=(ke,Oe,Se)=>{let Qe=tp;if(Oe&&"read"in Oe){let Be=new Kb,fr=void 0;Be.on("error",(Zr)=>{fr??=Zr}),Oe.on("error",(Zr)=>Be.destroy(Zr)),Oe.pipe(Be);let kr=(Zr)=>Io(`fromReadable(fd${ke})`,Na(Zr),z);Qe=A0(()=>fr===void 0?lp({evaluate:()=>Be,onError:kr}):VS(kr(fr)))}if(Se)Qe=bm(Qe,Se);de.set(ke,Qe)};for(let{config:ke,fd:Oe}of V){let Se=re.stdio[Oe];switch(ke.type){case"input":{yield*pe(Oe,Se,ke.stream);break}case"output":{he(Oe,Se,ke.sink);break}case"duplex":{he(Oe,Se,ke.sink),yield*pe(Oe,Se,ke.stream);break}}}return{getInputFd:(ke)=>ie.get(ke)??tu,getOutputFd:(ke)=>de.get(ke)??tp}}),w=(z,re,V,ne)=>Ze(()=>{let ie=tu;if(Vl(re.stdin))kU(re.stdin),ie=up({evaluate:()=>re.stdin,onError:(de)=>Io("fromWritable(stdin)",Na(de),z),endOnDone:V.endOnDone,encoding:V.encoding});if(Aa(V.stream))return xr(g(V.stream,ie,ne),ie);return j(ie)}),A=(z,re,V,ne)=>{let ie=re.stdout?(()=>{let he=new Kb;return re.stdout.on("error",(ke)=>he.destroy(ke)),re.stdout.pipe(he),lp({evaluate:()=>he,onError:(ke)=>Io("fromReadable(stdout)",Na(ke),z)})})():tp,de=re.stderr?(()=>{let he=new Kb;return re.stderr.on("error",(ke)=>he.destroy(ke)),re.stderr.pipe(he),lp({evaluate:()=>he,onError:(ke)=>Io("fromReadable(stderr)",Na(ke),z)})})():tp;if(eu(V.stream))ie=bm(ie,V.stream);if(eu(ne.stream))de=bm(de,ne.stream);let pe=C0(ie,de);return{stdout:ie,stderr:de,all:pe}},y=(z,re,V,ne)=>un((ie)=>{let de=$o(),pe=z(re.command,re.args.map(rh),V,ne);return pe.on("error",(he)=>{if(re.args.some(wn))Object.assign(he,{spawnargs:[re.command,...re.args.map((ke)=>wn(ke)?"<redacted>":ke)]});ie(oe(Io("spawn",he,re)))}),pe.on("exit",(...he)=>{mo(de,ga(he))}),pe.on("lost",(he)=>{mo(de,$n(Io("exitCode",he,re)))}),pe.on("spawn",()=>{ie(j([pe,de]))}),We(()=>{pe.kill("SIGTERM")})}),h=(z,re,V)=>{if(globalThis.process.platform==="win32")return un((ne)=>{KV(re,(ie)=>{if(ie)ne(oe(Io("kill",Na(ie),z)));else ne(et)})});return gr({try:()=>{globalThis.process.kill(-re.pid,V)},catch:(ne)=>Io("kill",Na(ne),z)})},S=(z,re)=>{try{globalThis.process.kill(-z.pid,re)}catch{}},H=(z,re,V)=>Ze(()=>{if(!re.kill(V)){let ie=new globalThis.Error("Failed to kill child process");return oe(Io("kill",ie,z))}return et}),te=(z,re,V)=>un((ne)=>{let ie=Date.now()+V,de,pe=()=>{clearTimeout(de),re.removeListener("exit",he),re.removeListener("lost",he)},he=()=>{if(clearTimeout(de),Date.now()>=ie||!wU(z,re)){pe(),ne(et);return}de=setTimeout(he,BV)};return re.on("exit",he),re.on("lost",he),he(),We(pe)}),E=be(function*(z,re,V,ne){let ie=(de)=>globalThis.process.platform==="win32"||th(z)?h(z,re,de).pipe(ki((pe)=>qb(re)&&AU(pe.cause)?et:H(z,re,de))):H(z,re,de);if(yield*ie(ne?.killSignal??"SIGTERM"),gc(ne?.forceKillAfter))yield*on(V),yield*te(z,re,EU);else if(yield*te(z,re,xf(ne.forceKillAfter)),wU(z,re))yield*ie("SIGKILL"),yield*te(z,re,EU);yield*on(V)}),ge=(z,re)=>{let V=re??"stdout";switch(V){case"stdout":return z.stdout;case"stderr":return z.stderr;case"all":return z.all;default:{let ne=Xm(V);if(ir(ne))return z.getOutputFd(ne);return z.stdout}}},le=be(function*(z){switch(z._tag){case"StandardCommand":{if(z.options.shell!==void 0&&z.options.shell!==!1&&z.args.length>0)return yield*oe(bn({module:"ChildProcess",method:"spawn",description:"The shell option cannot be combined with arguments; pass the whole script as the command"}));let re=NV(z);if(re!==void 0)return yield*oe(bn({module:"ChildProcess",method:"spawn",description:re}));let V=c(z.options),ne=d(z.options,"stdout"),ie=d(z.options,"stderr"),de=x(z.options),pe=!0,he=yield*n(z.options),ke=o(z.options),Oe=f(V,ne,ie,de),Se=de.flatMap(({config:Dr,fd:Un})=>Dr.type==="duplex"?[Un]:[]),Qe=be(function*(Dr,Un){if(Dr.lost===!0||!pe)return;if(Qf(Un)){let[si]=yield*Go(on(Un));if((si===0||Vv(si))&&!th(z))return}yield*yS(E(z,Dr,Un,z.options))}),Be=yield*e,fr=ns(),[kr,Zr]=yield*zn(y(Be,z,bU(z.options,{cwd:he,env:ke,stdio:Oe},process.platform),Se),([Dr,Un],si)=>Ei([pn(fr,si),Qe(Dr,Un)],{concurrency:"unbounded",discard:!0})),Gs=aU(kr.pid);if(th(z))kr.on("exit",(Dr)=>{if(pe&&Dr!==0&&Vl(Dr))S(kr,z.options.killSignal??"SIGTERM")});let js=We(()=>{if(!pe)kr.ref(),pe=!0}),zs=We(()=>{if(pe)kr.unref(),pe=!1;return js}),Ro=$o(),Ml=yield*os(fr)(w(z,kr,V,Ro)),{all:Fl,stderr:Nl,stdout:Bl}=A(z,kr,ne,ie),{getInputFd:Kl,getOutputFd:ql}=yield*os(fr)(I(z,kr,de,Ro)),$l=Ze(()=>Qf(Zr)?xr(on(Zr),!1):j(!0)),Wl=Ae(jn(on(Zr),on(Ro)),([Dr,Un])=>{if(Qf(Ro))return on(Ro);if(Vl(Dr))return j(sU(Dr));let si=new globalThis.Error(`Process interrupted due to receipt of signal: '${Un}'`);return oe(Io("exitCode",si,z))});return Nb({pid:Gs,exitCode:Wl,isRunning:$l,kill:(Dr)=>E(z,kr,Zr,Dr),stdin:Ml,stdout:Bl,stderr:Nl,all:Fl,getInputFd:Kl,getOutputFd:ql,unref:zs})}case"PipedCommand":{let{commands:re,pipeOptions:V}=Wb(z),[ne,...ie]=re,de=[yield*le(ne)];for(let Oe=0;Oe<ie.length;Oe++){let Se=ie[Oe],Qe=V[Oe]??{},Be=c(Se.options),fr=Jo(j(ge(de[de.length-1],Qe.from))),kr=Qe.to??"stdin";if(kr==="stdin")de.push(yield*le(Zm(Se.command,Se.args,{...Se.options,stdin:{...Be,stream:fr}})));else{let Zr=Xm(kr);if(ir(Zr)){let Gs=SU(Zr),js=Se.options.additionalFds??{},zs=js[Gs],Ro=zs?.type==="duplex"?{...zs,stream:fr}:{type:"input",stream:fr};de.push(yield*le(Zm(Se.command,Se.args,{...Se.options,additionalFds:{...js,[Gs]:Ro}})))}else de.push(yield*le(Zm(Se.command,Se.args,{...Se.options,stdin:{...Be,stream:fr}})))}}let pe=de[de.length-1],he=(Oe)=>Wo([...de].reverse(),(Se)=>yS(Se.kill(Oe)),{discard:!0}),ke=_(function*(){let Oe=[];for(let Se of de)Oe.push(yield*Se.unref);return Wo([...Oe].reverse(),(Se)=>Se,{discard:!0})});return Nb({pid:pe.pid,exitCode:pe.exitCode,isRunning:pe.isRunning,kill:he,stdin:de[0].stdin,stdout:pe.stdout,stderr:pe.stderr,all:pe.all,getInputFd:pe.getInputFd,getOutputFd:pe.getOutputFd,unref:ke})}}});return cU(le)}),$b=as(dp,$V(j(qV)));var Wb=(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 TU from"crypto";import*as ve from"fs";import*as OU from"os";import*as Pi from"path";var kt=(e)=>(t)=>bn({module:"FileSystem",method:e,description:t.message??String(t)}),PU=(e,t)=>{let r=Number(e);if(!Number.isSafeInteger(r))throw RangeError(`${t} exceeds the safe integer range: ${e}`);return r},vU=(e)=>$g(ia(e),tR),RU=(e)=>BigInt.asUintN(64,e),Gb=(e)=>df(ia(e),RU),GV=(e,t)=>gr({try:()=>PU(e,"position"),catch:kt(t)}),jV=(()=>{let e=qt(ve.access,ht("FileSystem","access"),kt("access"));return(t,r)=>{let n=ve.constants.F_OK;if(r?.readable)n|=ve.constants.R_OK;if(r?.writable)n|=ve.constants.W_OK;return e(t,n)}})(),zV=(()=>{let e=qt(ve.cp,ht("FileSystem","copy"),kt("copy"));return(t,r,n)=>e(t,r,{force:n?.overwrite??!1,preserveTimestamps:n?.preserveTimestamps??!1,recursive:!0})})(),QV=(()=>{let e=qt(ve.copyFile,ht("FileSystem","copyFile"),kt("copyFile"));return(t,r)=>e(t,r)})(),HV=(()=>{let e=qt(ve.chmod,ht("FileSystem","chmod"),kt("chmod"));return(t,r)=>e(t,r)})(),VV=(()=>{let e=qt(ve.chown,ht("FileSystem","chown"),kt("chown"));return(t,r,n)=>e(t,r,n)})(),JV=(()=>{let e=qt(ve.link,ht("FileSystem","link"),kt("link"));return(t,r)=>e(t,r)})(),YV=(()=>{let e=qt(ve.mkdir,ht("FileSystem","makeDirectory"),kt("makeDirectory"));return(t,r)=>e(t,{recursive:r?.recursive??!1,mode:r?.mode})})(),jb=(e)=>{let t=qt(ve.mkdtemp,ht("FileSystem",e),kt(e));return(r)=>Ze(()=>{let n=r?.prefix??"",o=typeof r?.directory==="string"?Pi.join(r.directory,"."):OU.tmpdir();return t(n?Pi.join(o,n):o+"/")})},ZV=jb("makeTempDirectory"),zb=(e)=>{let t=qt(ve.rm,ht("FileSystem",e),kt(e));return(r,n)=>t(r,{recursive:n?.recursive??!1,force:n?.force??!1})},XV=zb("remove"),e4=(()=>{let e=jb("makeTempDirectoryScoped"),t=zb("makeTempDirectoryScoped");return(r)=>zn(e(r),(n)=>Go(t(n,{recursive:!0,force:!0})))})(),t4=(e)=>{let{O_APPEND:t,O_CREAT:r,O_EXCL:n,O_RDONLY:o,O_RDWR:i,O_TRUNC:s,O_WRONLY:c}=ve.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}},r4=(e,t)=>Ze(()=>{let{O_NOFOLLOW:r}=ve.constants;if(process.platform==="win32"||typeof r!=="number"||r===0)return oe(bn({module:"FileSystem",method:e,description:"noFollow is not supported on this platform"}));return j(t4(t)|r)}),n4=(e)=>{let t=qt(ve.open,ht("FileSystem",e),kt(e)),r=qt(ve.close,ht("FileSystem",e),kt(e));return(n,o)=>Hi(zn(o?.noFollow===!0?Ae(r4(e,o.flag??"r"),(i)=>t(n,i,o.mode)):t(n,o?.flag??"r",o?.mode),(i)=>Go(r(i))),Me((i)=>s4(i,o?.flag?.startsWith("a")??!1)))},o4=n4("open"),i4=(e)=>e.reason.cause?.code==="ESPIPE",CU=(e)=>bn({module:"FileSystem",method:e,description:"Cannot read before the start of the file"}),s4=(()=>{let e=(f)=>qt(ve.read,ht("FileSystem",f),kt(f)),t=e("read"),r=e("readAlloc"),n=qt(ve.fstat,ht("FileSystem","stat"),kt("stat")),o=qt(ve.ftruncate,ht("FileSystem","truncate"),kt("truncate")),i=qt(ve.fsync,ht("FileSystem","sync"),kt("sync")),s=(f)=>{let g=qt(ve.write,ht("FileSystem",f),kt(f));return(I,w,A)=>g(I,w,0,w.length,A)},c=s("write"),d=s("writeAll");class x{[Im];fd;append;position=BigInt(0);sequential=!1;constructor(f,g){this[Im]=Im,this.fd=f,this.append=g}get stat(){return Ae(n(this.fd,{bigint:!0}),DU)}get sync(){return i(this.fd)}atCursor(f){return Ze(()=>{if(this.sequential)return f(null);let g=this.position;return ms(Me(f(g),(I)=>(this.position=g+BigInt(I),I)),i4,()=>(this.sequential=!0,f(null)))})}writeOnce(f,g,I){return this.append?Ze(()=>g(this.fd,I,void 0)):this.atCursor((w)=>w===null?g(this.fd,I,void 0):Ae(GV(w,f),(A)=>g(this.fd,I,A)))}seek(f,g){return Ze(()=>{let I=g==="start"?f:this.position+f;if(I<BigInt(0))return oe(bn({module:"FileSystem",method:"seek",description:"Cannot seek before the start of the file"}));return this.position=I,j(I)})}read(f,g){return Ze(()=>{let I=g?.position;if(I===void 0)return this.atCursor((w)=>t(this.fd,{buffer:f,position:w}));return I<BigInt(0)?oe(CU("read")):t(this.fd,{buffer:f,position:I})})}readAlloc(f,g){return Ze(()=>{try{if(!Number.isInteger(f)||f<0)throw RangeError("size must be a non-negative integer");let I=g?.position;if(I!==void 0&&I<BigInt(0))return oe(CU("readAlloc"));let w=Buffer.allocUnsafeSlow(f),A=(y)=>r(this.fd,{buffer:w,position:y});return Me(I===void 0?this.atCursor(A):A(I),(y)=>{if(y===0)return xe();if(y===f)return Le(w);let h=Buffer.allocUnsafeSlow(y);return w.copy(h,0,0,y),Le(h)})}catch(I){return oe(kt("readAlloc")(I))}})}truncate(f){return Me(o(this.fd,f||void 0),()=>{if(!this.append){let g=BigInt(f??0);if(this.position>g)this.position=g}})}write(f){return this.writeOnce("write",c,f)}writeAllChunk(f){return Ae(this.writeOnce("writeAll",d,f),(g)=>{if(g===0)return oe(xo({module:"FileSystem",method:"writeAll",_tag:"WriteZero",pathOrDescriptor:this.fd,description:"write returned 0 bytes written"}));return g<f.length?this.writeAllChunk(f.subarray(g)):et})}writeAll(f){return f.length===0?et:this.writeAllChunk(f)}}return(f,g)=>new x(f,g)})(),_U=(e)=>{let t=jb(e);return be(function*(r){let n=yield*t(r),o=TU.randomBytes(6).toString("hex"),i=Pi.join(n,r?.suffix?`${o}${r.suffix}`:o);return yield*MU(i,new Uint8Array(0)),i})},a4=_U("makeTempFile"),c4=(()=>{let e=_U("makeTempFileScoped"),t=zb("makeTempFileScoped");return(r)=>zn(e(r),(n)=>Go(t(Pi.dirname(n),{recursive:!0,force:!0})))})(),p4=(e,t)=>ls({try:()=>ve.promises.readdir(e,t),catch:(r)=>ht("FileSystem","readDirectory")(r,[e])}),d4=(e)=>ls({try:()=>ve.promises.readdir(e,{withFileTypes:!0}),catch:(t)=>ht("FileSystem","readDirectoryEntries")(t,[e])}).pipe(Me((t)=>t.map((r)=>({name:r.name,type:UU(r)})))),u4=(e)=>un((t,r)=>{try{ve.readFile(e,{signal:r},(n,o)=>{if(n)t(oe(ht("FileSystem","readFile")(n,[e])));else t(j(o))})}catch(n){t(oe(kt("readFile")(n)))}}),l4=(()=>{let e=qt(ve.readlink,ht("FileSystem","readLink"),kt("readLink"));return(t)=>e(t)})(),f4=(()=>{let e=qt(process.platform==="win32"?ve.realpath.native:ve.realpath,ht("FileSystem","realPath"),kt("realPath"));return(t)=>e(t)})(),m4=(()=>{let e=qt(ve.rename,ht("FileSystem","rename"),kt("rename"));return(t,r)=>e(t,r)})(),UU=(e)=>e.isFile()?"File":e.isDirectory()?"Directory":e.isSymbolicLink()?"SymbolicLink":e.isBlockDevice()?"BlockDevice":e.isCharacterDevice()?"CharacterDevice":e.isFIFO()?"FIFO":e.isSocket()?"Socket":"Unknown",DU=(e,t="stat")=>gr({try:()=>({type:UU(e),mtime:ia(e.mtime),atime:ia(e.atime),birthtime:ia(e.birthtime),dev:RU(e.dev),rdev:Gb(e.rdev),ino:Gb(e.ino),mode:PU(e.mode,"mode"),nlink:Gb(e.nlink),uid:vU(e.uid),gid:vU(e.gid),size:wS(e.size),blksize:e.blksize!==void 0?Le(wS(e.blksize)):xe(),blocks:ia(e.blocks)}),catch:kt(t)}),LU=(e,t)=>{let r=qt(t,ht("FileSystem",e),kt(e));return(n)=>Ae(r(n,{bigint:!0}),(o)=>DU(o,e))},Qb=LU("stat",ve.stat),h4=LU("lstat",ve.lstat),y4=(()=>{let e=qt(ve.symlink,ht("FileSystem","symlink"),kt("symlink"));return(t,r)=>e(t,r)})(),g4=(()=>{let e=qt(ve.truncate,ht("FileSystem","truncate"),kt("truncate"));return(t,r)=>e(t,r)})(),x4=(()=>{let e=qt(ve.utimes,ht("FileSystem","utime"),kt("utime"));return(t,r,n)=>e(t,r,n)})(),S4=(e,t,r)=>w0((n)=>zn(We(()=>{let o=t.type==="Directory"?e:Pi.dirname(e),i=ve.watch(e,{recursive:r?.recursive??!1},(s,c)=>{if(!c)return;switch(s){case"rename":{am(HP(Qb(Pi.resolve(o,c)),{onSuccess:(d)=>Jd(n,{_tag:"Create",path:c}),onFailure:(d)=>Jd(n,{_tag:"Remove",path:c})}));return}case"change":{Ss(n,{_tag:"Update",path:c});return}}});return i.on("error",(s)=>{Yd(n,UP(xo({module:"FileSystem",_tag:"Unknown",method:"watch",pathOrDescriptor:e,cause:s})))}),i.on("close",()=>{Vo(n)}),i}),(o)=>We(()=>o.close())).pipe(fs(()=>We(()=>r?.onReady?.())))),b4=(e,t,r)=>Ei([Qb(t),rm(Em)]).pipe(Me(([n,o])=>LC(o,()=>e).pipe($g((i)=>i.register(t,n,r)),yr(()=>S4(t,n,r)))),Jo),MU=(e,t,r)=>un((n,o)=>{try{ve.writeFile(e,t,{signal:o,flag:r?.flag,mode:r?.mode},(i)=>{if(i)n(oe(ht("FileSystem","writeFile")(i,[e])));else n(et)})}catch(i){n(oe(kt("writeFile")(i)))}}),I4=Me(rm(Em),(e)=>L0({access:jV,chmod:HV,chown:VV,copy:zV,copyFile:QV,link:JV,lstat:h4,makeDirectory:YV,makeTempDirectory:ZV,makeTempDirectoryScoped:e4,makeTempFile:a4,makeTempFileScoped:c4,open:o4,readDirectory:p4,readDirectoryEntries:d4,readFile:u4,readLink:l4,realPath:f4,remove:XV,rename:m4,stat:Qb,symlink:y4,truncate:g4,utimes:x4,watch(t,r){return b4(e,t,r)},writeFile:MU})),FU=as(nu)(I4);var NU=FU;import*as Tu from"path";import*as oh from"url";var Hb=(e)=>({fromFileUrl:(t)=>gr({try:()=>oh.fileURLToPath(t,{windows:e}),catch:(r)=>new Vd({module:"Path",method:"fromFileUrl",cause:r})}),toFileUrl:(t)=>gr({try:()=>oh.pathToFileURL(t,{windows:e}),catch:(r)=>new Vd({module:"Path",method:"toFileUrl",cause:r})})}),w4=ss(Ca)(km({...Tu.posix,...Hb(!1)})),A4=ss(Ca)(km({...Tu.win32,...Hb(!0)})),BU=ss(Ca)(km({...Tu,...Hb(void 0)}));var KU=BU;var Vb="~effect/Stdio",qU=Qt(Vb),$U=(e)=>({[Vb]:Vb,stdinIsTerminal:j(!1),stdoutIsTerminal:j(!1),stderrIsTerminal:j(!1),...e});var T4=We(()=>{process.nextTick(()=>{if(process.stdin.readableFlowing===null)process.stdin.pause()})}),GU=ss(qU,$U({args:We(()=>process.argv.slice(2)),stdinIsTerminal:We(()=>process.stdin.isTTY===!0),stdoutIsTerminal:We(()=>process.stdout.isTTY===!0),stderrIsTerminal:We(()=>process.stderr.isTTY===!0),stdout:(e)=>up({evaluate:()=>process.stdout,onError:(t)=>xo({module:"Stdio",method:"stdout",_tag:"Unknown",cause:t}),endOnDone:e?.endOnDone??!1}),stderr:(e)=>up({evaluate:()=>process.stderr,onError:(t)=>xo({module:"Stdio",method:"stderr",_tag:"Unknown",cause:t}),endOnDone:e?.endOnDone??!1}),stdin:Jo(xr(Jc(()=>T4),lp({evaluate:()=>process.stdin,onError:(e)=>xo({module:"Stdio",method:"stdin",_tag:"Unknown",cause:e}),closeOnDone:!1})))}));var jU=GU;var zU="~effect/http/Cookies";var QU="~effect/http/Cookies/Cookie";var R4={[zU]:zU,...Yi,toJSON(){return{_id:"effect/Cookies",cookies:QC(this.cookies,(e)=>e.toJSON())}},pipe(){return nt(this,arguments)}},_4=(e)=>{let t=Object.create(R4);return t.cookies=e,t},U4=(e)=>{let t={};for(let r of e)hr(t,r.name,r);return _4(t)};var HU=U4([]);var xpe={[QU]:QU,...Yi,toJSON(){return{_id:"effect/Cookies/Cookie",name:this.name,value:this.value,options:this.options}}};var JU=Symbol.for("~effect/http/Headers");var ih=Object.defineProperties(Object.create(null),{[JU]:{value:JU},[Zs]:{value(e){return L4(this,rn(e,M4))}},toJSON:{value(){return uo(this)}},[Dt]:{value(e){return D4(this,e)}},[Ut]:{value(){return ed(this)}},toString:{value:Yi.toString},[cn]:{value:Yi[cn]}});var D4=VC(IC()),Ba=Object.create(ih),YU=(e)=>{if(e===void 0)return Ba;else if(Symbol.iterator in e){let r=Object.create(ih);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(ih);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},ZU=(e)=>Object.setPrototypeOf(e,ih);var L4=W(2,(e,t)=>{let r={...e},n=(o)=>{if(typeof o==="string"){let i=o.toLowerCase();if(i in e)r[i]=ei(e[i])}else for(let i in e)if(i.search(o)!==-1)r[i]=ei(e[i])};if(Array.isArray(t))for(let o=0;o<t.length;o++)n(t[o]);else n(t);return r});var M4=pt("effect/Headers/CurrentRedactedNames",{defaultValue:()=>["authorization","cookie","set-cookie","x-api-key"]});var sh=(e,t,r)=>pr(e)?r(t):Sr(e,r);function eD(e){let t=F4(e);return(r,n,o)=>{try{return t(r,n,o)}catch(i){return Qr(i)}}}function F4(e){if(e._tag==="Middleware")return(r,n,o)=>{let i=pr(r)?e.decode(Fr(su(n)),o):e.decode(Qo(r,su),o);return XU(i)};let t=e.decode;switch(t._tag){case"Passthrough":return(r,n)=>pr(r)?Fr(n):r;case"Transform":{let r=(n)=>n===He?Qn:Fr(t.transform(n));return(n,o)=>sh(n,o,r)}case"TransformOptional":{let r=(n)=>eb(t.transform(su(n)));return(n,o)=>sh(n,o,r)}case"TransformEffect":return(r,n,o)=>sh(r,n,(i)=>i===He?Qn:t.transform(i,o));case"TransformOptionalEffect":return(r,n,o)=>sh(r,n,(i)=>XU(t.transform(su(i),o)))}}var XU=(e)=>Sr(e,eb),tD=(e,t,r,n)=>Cr(n,(o)=>Sa(()=>ps(o,(i)=>new B0(e,i,t,r))));function N4(e,t){let r=eD(e.link.transformation),n;return(o,i)=>{if(o===He)return Qn;if(e.isConstructed(o))return vi;let s=(n??=t(e.link.to))(o,i);return r(s,o,i)}}function B4(e,t){let r=e.context.constructorDefault;return(n,o)=>{if(n!==He&&n!==void 0)return t(n,o);let i=r;if(mt(i)&&i._tag==="Success"){let s=t(i[qe],o);return pr(s)?i:s}return Sr(tD(e,n,o,i),(s)=>{let c=t(s,o);return pr(c)?Fr(s):c})}}function Yb(e,t){let r=t(e);return e.context?.constructorDefault===void 0?r:B4(e,r)}function Ou(e,t,r,n,o){if(e._tag==="Declaration")for(let A of e.typeParameters)t(A);let i=r?Ym(e):void 0,s=i?N4(i,t):n??e.getParser(t,r),{checks:c,encoding:d}=e,x=d?.map((A)=>eD(A.transformation)),f=e.encodingChecks;if(!d&&!c&&!f)return s;let g,I=(A,y)=>{let h=s(A,y);try{if(f&&!y.disableChecks)if(mt(h)){if(h._tag==="Success"){let S=pr(h)?A:h[qe];if(A!==He&&S!==He){let H=Es(f,A,void 0,e,y);if(H)h=oe(new Nr(e,H,A,y))}}}else h=Ae(h,(S)=>{if(A!==He&&S!==He){let H=Es(f,A,void 0,e,y);if(H)return oe(new Nr(e,H,A,y))}return j(S)});if(c&&!y.disableChecks)if(mt(h)){if(h._tag==="Success"){let S=pr(h)?A:h[qe];if(S===He)return h;let H=Es(c,S,void 0,e,y);if(H)h=oe(new Nr(e,H,S,y))}}else h=Ae(h,(S)=>{if(S!==He){let H=Es(c,S,void 0,e,y);if(H)return oe(new Nr(e,H,S,y))}return j(S)});return h}catch(S){return Qr(S)}},w=o===void 0?I:o(I);if(!d)return w;return(A,y)=>{let h=g??=d.map((te)=>t(te.to)),S=A,H=h[h.length-1](A,y);for(let te=d.length-1;te>=0;te--)if(H=x[te](H,S,y),te!==0){let E=h[te-1];if(H._tag==="Success")S=H[qe],H=E(S,y);else H=Sr(H,(ge)=>{let le=E(ge,y);return pr(le)?Fr(ge):le})}if(H._tag==="Success"){let te=H[qe],E=w(te,y);return pr(E)?H:E}return H=tD(e,A,y,H),Sr(H,(te)=>{let E=w(te,y);return pr(E)?Fr(te):E})}}var Zb=Symbol(),rD=new WeakMap,nD,Pu=!1;var q4=(e)=>Pu?ah(An,e,"parser"):An(e).parser,oD=(e)=>Pu?ah(An,e,"makeEffect"):An(e).makeEffect,$4=(e)=>Yb(e,oD);class Xb{ast;constructor(e){this.ast=e}get decodeEffect(){return this.cachedDecodeEffect??=Ou(this.ast,q4)}get parser(){return this.decodeEffect}get makeEffect(){return this.cachedMakeEffect??=Ou(this.ast,oD,$4)}}class iD extends Xb{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")??Ou(this.ast,(e)=>ah(this.resolve,e,"parser")))}get parser(){let e=this.decode;return e===void 0?this.decodeEffect:this.save("parser",W4(e,()=>this.decodeEffect))}get makeEffect(){let e=this.compiledMakeEffect;if(e!==void 0)return this.save("makeEffect",e);let t=(r)=>ah(this.resolve,r,"makeEffect");return this.save("makeEffect",Ou(this.ast,t,(r)=>Yb(r,t)))}}function W4(e,t){let r;return(n,o)=>{if(n!==He)try{let i=e(n,o);if(i!==Zb)return i===n?vi:Fr(i)}catch(i){return Qr(i)}return(r??=t())(n,o)}}function ah(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 An(e){let t=rD.get(e);if(t!==void 0)return t;let r=nD===void 0?new Xb(e):new iD(e,nD(e,An),An);return rD.set(e,r),r}function tI(e){let t=e.ast,r;return(n,o)=>yD(r??=An(Oi(t)),n,hD(o))}function ch(e){let t=tI(e);return(r,n)=>V4(ka(t(r,n)))}function aD(e){return Y4(Oi(e.ast))}function cD(e){return z4(e.ast)}function j4(e){if(!Pu){let o=lD(rI(e));return(i)=>{let s=o(i,Ua);if(dn(s))return!0;return Ta(s.cause,"Type guard adapter can only return false for schema issues"),!1}}let t=An(e),r=t.is;if(r!==void 0)return(o)=>{try{return r(o,Ua)}catch(i){return Ta(Jf(i),"Type guard adapter can only return false for schema issues"),!1}};let n=t.parser;return(o)=>{let i=ka(nI(n(o,Ua),o));if(dn(i))return!0;return Ta(i.cause,"Type guard adapter can only return false for schema issues"),!1}}function z4(e){let t=Oi(e),r=(n)=>(r=j4(t),r(n));return(n)=>r(n)}function Ka(e,t){let r=rI(e.ast);return uD(r,t)}function pD(e,t){return H4(Ka(e,t))}function dD(e,t){let r=rI(En(e.ast));return uD(r,t)}function uD(e,t){return t===void 0?e:(r,n)=>e(r,n?{...t,...n}:t)}var sD=(e)=>{if(e===He)return oe(new Vr);return j(e)};function rI(e){return Q4(Z4,e)}function nI(e,t){if(pr(e))return j(t);if(!mt(e))return Sr(e,sD);return e[qe]===He?sD(He):e}function Q4(e,t){let r;return(n,o)=>nI((r??=e(t))(n,o??Ua),n)}function lD(e){return(t,r)=>ka(e(t,r))}function H4(e){let t=lD(e);return(r,n)=>{let o=t(r,n);if(dn(o))return Le(o.value);return Ta(o.cause,"Option adapter can only return none for schema issues"),xe()}}function V4(e){if(dn(e))return Le(e.value);return Ta(e.cause,"Option adapter can only return none for schema issues"),xe()}function J4(e,t){let r=ka(e);if(dn(r))return r.value;let n=Ta(r.cause,t);throw Error("Schema validation failed",{cause:n})}var fD="Constructor adapter can only throw schema issues";function mD(e){throw Error(fD,{cause:Jf(e)})}function Y4(e){let t;return(r,n)=>eI(t??=An(e),r,n)}function hD(e){return e?.disableChecks?{...e.parseOptions,disableChecks:!0}:e?.parseOptions??Ua}function yD(e,t,r){return nI(e.makeEffect(t,r),t)}function eI(e,t,r){let n=hD(r),o=Pu?e.make:void 0;if(o!==void 0&&t!==He){let i;try{i=o(t,n)}catch(s){mD(s)}if(i!==Zb&&i!==He)return i}return J4(yD(e,t,n),fD)}function gD(e,t,r,n){let o=An(e),i=Ym(e);if(i===void 0||o.make!==void 0||o.compiledMakeEffect!==void 0)return eI(o,t,r);if(i.isConstructed(t))return t;let s=eI((o.resolve??An)(i.link.to),t,r);try{return n(s)}catch(c){mD(c)}}var Z4=(e)=>An(e).parser;var dh="~effect/Schema/Schema",xD=Symbol(),X4={[dh]:dh,get make(){let e=aD(this);return Object.defineProperty(this,"make",{value:e,enumerable:!0}),e},get makeEffect(){let e=tI(this);return Object.defineProperty(this,"makeEffect",{value:e,enumerable:!0}),e},get makeOption(){let e=ch(this);return Object.defineProperty(this,"makeOption",{value:e,enumerable:!0}),e},pipe(){return nt(this,arguments)},annotate(e){return this.rebuild(zm(this.ast,e))},annotateKey(e){return this.rebuild(Vm(this.ast,e))},check(...e){return this.rebuild(Da(this.ast,e))},rebuild(e){return fp(e,this[xD])}};function fp(e,t){function r(){}let n=Object.setPrototypeOf(r,X4);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[xD]=t,n.ast=e,n}function rJ(e,t){let r=po((o)=>{let i=pp(o,void 0),s=e(i,n);return s===i?null:s}),n=Hm((o)=>{let i=r(ku(o));if(i===null)return o;let s=pp(i,o.context);return o.context===void 0?s:j_(s,nJ(o.context))},t);return n}function nJ(e){return e.constructorDefault===void 0?e:new xb(e.isOptional,e.isMutable,void 0,e.annotations)}function oJ(e){if(e.propertySignatures.some((t)=>typeof t.name!=="string"))throw new globalThis.Error("Objects property names must be strings",{cause:e})}function iJ(e){return(t)=>{let r=[...t].sort((o,i)=>e(bo(o))-e(bo(i)));if(!r.some((o,i)=>o!==t[i]))return t;return r}}function bD(e){return fp(lJ(e.ast),{schema:e})}var sJ=iJ((e)=>{switch(e._tag){case"Null":case"Boolean":case"Number":case"BigInt":case"Symbol":case"UniqueSymbol":return 0;default:return 1}});function aJ(e,t,r){switch(e._tag){case"Declaration":{let n=e.typeParameters.map((x)=>fp(t(bo(x)))),o=e.annotations?.toCodecStringTree;if(Mo(o)){let x=o(n);if(x===void 0)return e;return Br(e,[Qm(x,t)])}let i=e.annotations?.toCodecJson,s=Mo(i)?i(n):void 0,c=s===void 0?e.annotations?.toCodec:void 0,d=s??(Mo(c)?c(n):void 0);return d===void 0?r(e):Br(e,[Qm(d,t)])}case"Null":return Br(e,[cJ]);case"Boolean":return Br(e,[pJ]);case"Unknown":case"ObjectKeyword":return Br(e,[Mb]);case"Enum":case"Number":case"Literal":case"UniqueSymbol":case"Symbol":case"BigInt":return e.toCodecStringTree();case"Objects":return oJ(e),e.recur(t,Lb);case"Union":{let n=sJ(e.types);if(n!==e.types)return new Is(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 cJ=new Jr(new Zo("null"),new or(Tt(()=>null),Tt(()=>"null"))),pJ=new Jr(new Is([new Zo("true"),new Zo("false")]),new or(Tt((e)=>e==="true"),Pm())),dJ=new or(Tt((e)=>typeof e==="string"?[e]:e),Yn()),uJ=(e)=>e.transformation===dJ,lJ=rJ((e,t)=>aJ(e,t,(r)=>{throw new globalThis.Error("Missing structural codec for StringTree",{cause:r})}),{stopAt:uJ});var qa=(e)=>e;var mp="~effect/Schema/SchemaError";function ED(e){return Ye(e,mp)&&e[mp]===mp}var Ru=dh;function vD(){return(e,t,r)=>wt(new Eu(e.map(Wm),(n)=>t(n.map((o)=>wt(o))),r))}function mJ(e,t){return vD()([],()=>(r,n,o)=>e(r)?j(r):oe(new Vn(n,r,o)),t)}function hJ(e){return(t)=>kD(kD(t).annotate(e))}class Du extends Ko("SchemaError"){[mp]=mp;constructor(e){let t=ui();tn(0);try{super({issue:e})}finally{tn(t)}}get message(){return H0(this.issue)}toJSON(){return{_tag:this._tag,message:this.message}}[cn](){return this.toJSON()}toString(){return`SchemaError(${this.message})`}}function yJ(e){return ED(e)}function CD(e){if(mt(e))return gJ(e);return Cr(e,(t)=>Sa(()=>ps(t,(r)=>new Du(r))))}function gJ(e){return dn(e)?e:cs(ps(e.cause,(t)=>new Du(t)))}function TD(e,t){let r;for(let n of e.reasons){if(!Hc(n)||!yJ(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 xJ(e){return IS(e).then((t)=>{if(dn(t))return t.value;throw TD(t.cause,"Promise adapter can only reject schema errors")})}function SJ(e){let t=ka(e);if(dn(t))return t.value;throw TD(t.cause,"Sync adapter can only throw schema errors")}var iI=cD;function Kr(e,t){let r=Ka(e,t);return(n,o)=>CD(r(n,o))}var ws=pD;function bJ(e,t){let r=Kr(e,t);return(n,o)=>xJ(r(n,o))}function IJ(e,t){let r=Kr(e,t);return(n,o)=>SJ(r(n,o))}function OD(e,t){let r=dD(e,t);return(n,o)=>CD(r(n,o))}var wt=fp;function EJ(e){return Ye(e,Ru)&&e[Ru]===Ru}var u=qa((e)=>wt(Jm(e.ast),{schema:e}));var sI=qa((e)=>{let t=vJ(e);return wt(H_(e.ast),{schema:t})});var kJ=qa((e)=>wt(bo(e.ast),{schema:e})),_u="~effect/Schema/flip";function wJ(e){return Ye(e,_u)&&e[_u]===_u}function kD(e){if(wJ(e))return e.schema.rebuild(En(e.ast));return wt(En(e.ast),{[_u]:_u,schema:e})}function v(e){let t=wt(new Zo(e),{literal:e,transform(r){return t.pipe(Ri(v(r),{decode:Tt(()=>r),encode:Tt(()=>e)}))}});return t}var J=wt(Pa),PD=wt(Km),AJ=wt(Sb),a=wt(bs);var dr=wt(bb),X=wt(C_);function aI(e,t){return wt(e,{fields:t,mapFields(r,n){let o=r(this.fields);return aI($m(o,n?.unsafePreserveChecks?this.ast.checks:void 0),o)}})}function p(e){return aI($m(e,void 0),e)}function Yt(e,t){return wt(Rb(e.ast,t.ast),{key:e,value:t})}function RD(e,t){return wt(D_(e.ast,t.map(Wm)),{schema:e,records:t})}var L=qa((e)=>wt(new qm(!1,[],[e.ast]),{value:e}));function _D(e,t){return wt(e,{members:t,mapMembers(r,n){let o=r(this.members);return _D(Gm(o,this.ast.options,n?.unsafePreserveChecks?this.ast.checks:void 0),o)}})}function st(e,t){return _D(Gm(e,t,void 0),e)}function G(e){let t=e.map(v);return wt(Gm(t,void 0,void 0),{literals:e,members:t,mapMembers(r){return st(r(this.members))},pick(r){return G(r)},transform(r){return st(t.map((n,o)=>n.transform(r[o])))}})}var M=qa((e)=>st([e,PD])),vJ=qa((e)=>st([e,AJ]));function yt(e){return(t)=>wt(t.ast,{schema:t,identifier:e})}function CJ(e){return(t)=>wt(z_(t.ast,new cb(e,Ce)),{schema:t})}function lh(e){return TJ(e)}function TJ(e){return(t)=>CJ(pm(e))(t)}function Ri(e,t){return(r)=>wt(wu(r.ast,e.ast,t?pb(t):Dm()),{from:r,to:e})}var cI=G(["true","yes","on","1","y"]),pI=G(["false","no","off","0","n"]),dI=G([...cI.literals,...pI.literals]).pipe(Ri(X,Um({decode:(e)=>e==="true"||e==="yes"||e==="on"||e==="1"||e==="y",encode:(e)=>e?"true":"false"})));function OJ(e){return(t)=>wt(V_(t.ast,e),{schema:t})}function PJ(e){if(mt(e)&&e._tag==="Success")return e;return Cr(e,(t)=>Sa(()=>ps(t,(r)=>r.issue)))}function UD(e,t){let r=t?.encodingStrategy==="omit"?o_():Yn();return(n)=>u(kJ(n)).pipe(Ri(n,{decode:i_(PJ(e)),encode:r}))}function As(e){return v(e).pipe(OJ(j(e)))}function RJ(e,t){return p({_tag:As(e),...t})}function $a(e,t){return mJ((r)=>r instanceof e,t)}function hp(){return(e,t)=>new Jr(e.ast,pb(t))}var Ft=jm;var wD="^\\S[\\s\\S]*\\S$|^\\S$|^$";function DD(e){let t=new globalThis.RegExp(wD);return Ft((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:wD,flags:""}]},...e})}function Ge(e,t){let{source:r,flags:n}=e,o=/^[dg]*uy?$/.test(n);return Ab(e,{toJsonSchema:()=>o?{pattern:n.endsWith("y")?`^(?:${r})`:r}:[{},!0],...t})}var _J=(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 N(e,t){let r=_J(e);return Ge(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 UJ(e){let r=/^[0-9a-zA-Z+/]*={0,2}$/;return Ft((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 DJ(e){let t=ld(e.order),r=e.formatter??it;return(n,o)=>Ft((i)=>t(i,n),{expected:`a value greater than ${r(n)}`,arbitraryConstraint:{order:e.order,minimum:n,exclusiveMinimum:!0},...e.annotate?.(n),...o})}function LJ(e){let t=qg(e.order),r=e.formatter??it;return(n,o)=>Ft((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 MJ(e){let t=Kg(e.order),r=e.formatter??it;return(n,o)=>Ft((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 FJ(e){let t=qg(e.order),r=ld(e.order),n=Kg(e.order),o=DC(e.order),i=e.formatter??it;return(s,c)=>{let d=s.exclusiveMinimum?r:t,x=s.exclusiveMaximum?o:n;return Ft((f)=>d(f,s.minimum)&&x(f,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 Uu(e){if(!globalThis.Number.isFinite(e))throw new globalThis.RangeError(`Expected a finite number, got ${it(e)}`);return e}var ti=DJ({order:oa,annotate:(e)=>({representation:{id:"effect/schema/isGreaterThan",payload:{exclusiveMinimum:Uu(e)}},toJsonSchema:()=>({exclusiveMinimum:e})})}),Ne=LJ({order:oa,annotate:(e)=>({representation:{id:"effect/schema/isGreaterThanOrEqualTo",payload:{minimum:Uu(e)}},toJsonSchema:()=>({minimum:e})})});var LD=MJ({order:oa,annotate:(e)=>({representation:{id:"effect/schema/isLessThanOrEqualTo",payload:{maximum:Uu(e)}},toJsonSchema:()=>({maximum:e})})}),Tr=FJ({order:oa,annotate:(e)=>{let t=e.exclusiveMinimum?!0:void 0,r=e.exclusiveMaximum?!0:void 0;return{representation:{id:"effect/schema/isBetween",payload:{minimum:Uu(e.minimum),maximum:Uu(e.maximum),...t&&{exclusiveMinimum:t},...r&&{exclusiveMaximum:r}}},toJsonSchema:()=>({[t?"exclusiveMinimum":"minimum"]:e.minimum,[r?"exclusiveMaximum":"maximum"]:e.maximum})}}});function yp(e){return Ft((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 F=dr.check(yp());function we(e,t){return e=uh(e),NJ(e,Math.ceil(e/2),t)}function NJ(e,t,r){return Ft((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],[ou]:!0,arbitraryConstraint:{minLength:e},...r})}function ae(e,t){return e=uh(e),Ft((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],[ou]:!0,arbitraryConstraint:{maxLength:e},...t})}function BJ(e,t,r){return e=uh(e),t=uh(t),Ft((n)=>{let o=KJ(n,t+1);return o>=e&&o<=t},{expected:e===t?`a string with ${e} code points`:`a string with between ${e} and ${t} code points`,representation:{id:"effect/schema/isBetweenCodePoints",payload:{minimum:e,maximum:t}},toJsonSchema:()=>({allOf:[{minLength:e},{maxLength:t}]}),arbitraryConstraint:{minCodePoints:e,maxCodePoints:t},...r})}function KJ(e,t){if(t===0)return 0;let r=0;for(let n of e)if(++r>=t)break;return r}function uh(e){if(!globalThis.Number.isFinite(e))throw new globalThis.RangeError(`Expected a finite number, got ${e}`);return Math.max(0,Math.floor(e))}var qJ=(e)=>(e?.includeStack===!0?1:0)|(e?.excludeCause===!0?2:0),$J=(e)=>{switch(e){case 0:return;case 1:return{includeStack:!0};case 2:return{excludeCause:!0};case 3:return{includeStack:!0,excludeCause:!0}}};var AD=[];function MD(e){let t=qJ(e),r=AD[t];if(r!==void 0)return r;let n=ZJ.pipe(Ri(J,l_($J(t))));return AD[t]=n,n}var Qde=$a(globalThis.RegExp,{representation:{id:"effect/schema/RegExp",payload:null},expected:"RegExp",toCodecJson:()=>hp()(p({source:a,flags:a}),_m({decode:(e,t)=>gr({try:()=>new globalThis.RegExp(e.source,e.flags),catch:()=>new Vr({expected:"valid RegExp source and flags"},e,t)}),encode:(e)=>j({source:e.source,flags:e.flags})}))}),WJ=a.annotate({expected:"a string that will be decoded as a URL"}),GJ=$a(globalThis.URL,{representation:{id:"effect/schema/URL",payload:null},expected:"URL",toCodecJson:()=>hp()(WJ,f_)});var Hde=$a(globalThis.File,{representation:{id:"effect/schema/File",payload:null},expected:"File",toCodecJson:()=>hp()(p({data:a.check(UJ()),type:a,name:a,lastModified:F}),_m({decode:(e,t)=>md(Om(e.data),{onFailure:()=>oe(new Vr({expected:"a valid Base64 string"},e.data,t)),onSuccess:(r)=>{let n=new globalThis.Uint8Array(r);return j(new globalThis.File([n],e.name,{type:e.type,lastModified:e.lastModified}))}}),encode:(e,t)=>ls({try:async()=>{let r=new globalThis.Uint8Array(await e.arrayBuffer());return{data:Tm(r),type:e.type,name:e.name,lastModified:e.lastModified}},catch:()=>new Vr({expected:"a readable File"},e,t)})}))});var Vde=$a(globalThis.URLSearchParams,{representation:{id:"effect/schema/URLSearchParams",payload:null},expected:"URLSearchParams",toCodecJson:()=>hp()(a.annotate({expected:"a query string that will be decoded as URLSearchParams"}),Um({decode:(e)=>new globalThis.URLSearchParams(e),encode:(e)=>e.toString()}))});var fh=a.annotate({expected:"a string that will be decoded as a number"}).pipe(Ri(dr,xu));var jJ=a.check(DD()),Yr=a.annotate({expected:"a string that will be decoded as a trimmed string"}).pipe(Ri(jJ,d_()));var zJ=a.annotate({expected:"a base64 encoded string that will be decoded as Uint8Array",format:"byte",contentEncoding:"base64"}),Jde=$a(globalThis.Uint8Array,{representation:{id:"effect/schema/Uint8Array",payload:null},expected:"Uint8Array",toCodecJson:()=>hp()(zJ,m_)});var QJ=-8640000000000000,HJ=8640000000000000,Yde=QJ+50400000,Zde=HJ-50400000;function FD(e,t){let r=typeof t?.label==="string"?t.label:void 0,n=t?.disallowJsonEncode===!0,o=r!==void 0?n?{label:r,disallowJsonEncode:!0}:{label:r}:n?{disallowJsonEncode:!0}:void 0,i=r!==void 0?Ka(v(r)):void 0,s=vD()([e],([c])=>(d,x,f)=>{if(wn(d)){let g=i!==void 0?Hd(i(d.label,f),(I)=>new In(["label"],I)):et;return Sr(g,()=>ES(Ka(c)(Xn(d),f),{onSuccess:(I)=>ei(I,{label:d.label}),onFailure:()=>new Nr(x,[new In(["value"],new Vr(void 0,d,f))],d,f)}))}return oe(new Vn(x,d,f))},{representation:{id:"effect/schema/Redacted",payload:o??null},expected:"Redacted",toCodecJson:([c])=>hp()(c,{decode:Tt((d)=>ei(d,{label:r})),encode:n?sb((d)=>"Cannot serialize Redacted"+(T(d)&&typeof d.value.label==="string"?` with label: "${d.value.label}"`:"")):Tt(Xn)}),toEquivalence:([c])=>uU(c)});return wt(s.ast,{value:e})}var VJ=globalThis.Symbol.for("immer-draftable"),oI={};function ND(e,t,r,n,o){let i=YJ(r,t,n),s=KD(t),c=class extends e{constructor(...[d,x]){let g=x?.["~payload"],I=g?.token===oI?g.value:r.make(d??{},x);super(I,{...x,disableChecks:!0,"~payload":{token:oI,value:I}})}static[Ru]=Ru;get[s](){return s}static[VJ]=!0;static identifier=t;static fields=r.fields;static get ast(){return i(this).ast}static pipe(){return nt(this,arguments)}static rebuild(d){return i(this).rebuild(d)}static make(d,x){return gD(Oi(i(this).ast),d??{},x,(f)=>BD(this,f))}static makeOption(d,x){return ch(i(this))(d??{},x)}static makeEffect(d,x){return i(this).makeEffect(d??{},x)}static annotate(d){return this.rebuild(zm(this.ast,d))}static annotateKey(d){return this.rebuild(Vm(this.ast,d))}static check(...d){return this.rebuild(Da(this.ast,d))}static extend(d){return(x,f)=>{let g=uI(x)?x:p(x),I={...r.fields,...g.fields},w=$m(I,r.ast.checks,{identifier:d});return ND(this,d,aI(Da(w,g.ast.checks),I),f,o)}}static mapFields(d,x){return r.mapFields(d,x)}};if(o!==void 0)Object.assign(c.prototype,o(t));return c}function BD(e,t){return new e(t,{"~payload":{token:oI,value:t}})}function JJ(e){return new or(Tt((t)=>BD(e,t)),Yn())}function KD(e){return`~effect/Schema/Class/${e}`}function YJ(e,t,r){let n;return(o)=>{if(n!==void 0)return n;let i=KD(t),s=(x)=>x instanceof o||Ye(x,i),c=JJ(o),d=wt(new Eu([e.ast],()=>(x,f,g)=>s(x)?j(x):oe(new Vn(f,x,g)),{identifier:t,[Am]:([x])=>({isConstructed:s,link:new Jr(x,c)}),toCodec:([x])=>new Jr(x.ast,c),toEquivalence:([x])=>x,toFormatter:([x])=>(f)=>`${o.identifier}(${x(f)})`,[wm]:Iu(e.ast),...r}));return n=Ri(d,c)(e)}}function uI(e){return EJ(e)}var Lu=(e)=>(t,r)=>{let n=uI(t)?t:p(t);return ND(dd,e,n,r,(i)=>({name:i}))},Eo=(e)=>(t,r,n)=>{let o=uI(r)?r.mapFields((i)=>({_tag:As(t),...i}),{unsafePreserveChecks:!0}):RJ(t,r);return Lu(e??t)(o,n)};var mh=bD;var ZJ=wt(nU);var qD="~effect/Terminal",lI="~effect/Terminal/QuitError";class Mu extends Lu("QuitError")({_tag:As("QuitError")}){[lI]=lI}var $D=(e)=>Ye(e,lI),ko=Qt("effect/Terminal"),WD=(e)=>ko.of({...e,[qD]:qD});import*as yh from"readline";var GD=be(function*(e=zD){let t=yield*wa(),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*Jc(()=>We(()=>i?.off("end",o)));let c=yield*QS({acquire:zn(We(()=>{let h=s(),S=yh.createInterface({input:h,escapeCodeTimeout:50}),H=(E)=>Ss(t,E),te=()=>{n=!1,Vo(t)};return n=!0,yh.emitKeypressEvents(h,S),S.on("line",H),S.once("close",te),{rl:S,onClose:te,onLine:H}}),({rl:h,onClose:S,onLine:H})=>We(()=>{if(n=!1,h.off("line",H),h.off("close",S),h.close(),r)Vo(t)})),idleTimeToLive:"10 millis"}),d=(h)=>We(()=>{let S=s();if(S.isTTY)S.setRawMode(h)}),x=yield*QS({acquire:zn(d(!0),()=>d(!1)),idleTimeToLive:"10 millis"}),f=We(()=>process.stdout.columns??0),g=We(()=>process.stdout.rows??0),I=_(function*(){let h=process.stdout,S=yield*MR(1),H=()=>Ss(S,{columns:h.columns??0,rows:h.rows??0});return yield*Jc(()=>We(()=>{h.off("resize",H),Vo(S)})),h.on("resize",H),H(),S}),w=_(function*(){let h=s(),S=yield*wa(),H=(ge,le)=>{let z={input:Tc(ge),key:{name:le.name??"",ctrl:!!le.ctrl,meta:!!le.meta,shift:!!le.shift}};if(Ss(S,z),e(z))Vo(S)},te=setInterval(()=>{},2147483647),E=()=>{clearInterval(te),Vo(S)};if(yield*Jc(()=>We(()=>{clearInterval(te),h.off("keypress",H),h.off("end",E)})),h.on("keypress",H),r)E();else yield*Sm(c),yield*Sm(x),h.once("end",E);return S}),A=Ze(()=>BR(t).pipe(Ae(Wr({onNone:()=>Ia(Gn(Sm(c),Ai(t))),onSome:j})),Jt(()=>new Mu({}))));return WD({columns:f,rows:g,size:I,readInput:w,readLine:A,display:(h)=>zd(un((S)=>{process.stdout.write(h,(H)=>Jv(H)?S(et):S(oe(bn({module:"Terminal",method:"display",description:"Failed to write prompt to stdout",cause:H}))))}))})}),jD=as(ko,GD(zD));function zD(e){let t=e.key;return t.name==="escape"||t.ctrl&&(t.name==="c"||t.name==="d")}var QD=jD;var t3=$b.pipe(RP(Vf(NU,KU,jU,QD)));function r3(e){return{_tag:"Value",value:e}}function n3(e,t){return{_tag:"Record",keys:e,value:t}}function o3(e,t){return{_tag:"Array",length:e,value:t}}var gh=pt("effect/ConfigProvider",{defaultValue:()=>ZD()}),i3={...Lr,toJSON(){return{_id:"ConfigProvider"}}},s3=(e)=>e;function a3(e,t){let r=Object.create(i3);return r.load=e,r.mapInput=t,r}function JD(e,t){return a3((r)=>e(t(r)),(r)=>JD(e,(n)=>r(t(n))))}function YD(e){return JD(e,s3)}var c3=(e)=>us(e)?as(gh)(e):ss(gh)(e);function p3(e,t){return e===""&&!t?void 0:e}function VD(e,t){let r=t?.preserveEmptyStrings===!0,n=d3(e);return YD((o)=>j(u3(n,e,o,r)))}function ZD(e){if(e?.env!==void 0)return VD(e.env,e);let t;return YD((r)=>Ze(()=>(t??=VD({...globalThis.process?.env,...import.meta?.env},e)).load(r)))}function d3(e){let t={};for(let[r,n]of Object.entries(e)){if(n===void 0)continue;let o=r.split("_"),i=t;for(let s of o){let c=i.children??=Object.create(null);i=c[s]??={}}}return t}function u3(e,t,r,n){let o=r.map(String).join("_"),i=p3(Object.hasOwn(t,o)?t[o]:void 0,n),s=l3(e,r),c=s?.children?Object.keys(s.children):[];if(c.length===0)return i===void 0?void 0:r3(i);if(c.every(JC)){let x=Math.max(...c.map((f)=>parseInt(f,10)))+1;return o3(x,i)}return n3(new Set(c),i)}function l3(e,t){if(t.length===0)return e;let r=e;for(let n of t)if(r=r?.children?.[String(n)],!r)return;return r}var XD="~effect/Config";class hI{_tag="ConfigError";name="ConfigError";cause;constructor(e){this.cause=e,Object.defineProperty(this,"message",{value:e.toString(),enumerable:!1,configurable:!0})}toString(){return`ConfigError(${this.message})`}}var h3={...Bo({label:"Config",evaluate(e){return this.parse(e.getRef(gh))}}),[XD]:XD,toJSON(){return{_id:"Config"}}};function Sh(e){let t=Object.create(h3);return t.evaluator=e,t.parse=(r)=>Sr(e(r,[]),Kd),t}var xh=(e,t,r)=>e.evaluator(t,r),y3=W(2,(e,t)=>Sh((r,n)=>Me(xh(e,r,n),Zg(t))));function g3(e){let t=globalThis.Array.isArray(e)?e:(Symbol.iterator in e)?[...e]:e;return Sh((r,n)=>globalThis.Array.isArray(t)?Qo(Ei(t.map((o)=>xh(o,r,n))),ex):Qo(Ei(Object.fromEntries(wr(t).map((o)=>[o,xh(t[o],r,n)]))),ex))}var tL=W(2,(e,t)=>Sh((r,n)=>Qo(xh(e,r,n),(o)=>Ht(o)?vt(t):o))),Wa=(e)=>e.pipe(y3(Le),tL(xe()));var x3=(e)=>Ln(e,"SourceError"),S3=()=>"<configuration>",rL=(e)=>(t)=>Cr(t,(r)=>Wn(xa(r.reasons.map(e)))),nL=(e,t)=>e.load(t).pipe(rL((r)=>Hc(r)?aS(r.error).annotate(pS(r)):r),Qo((r)=>({provider:e,path:t,node:r,toString:S3}))),eL=(e,t)=>nL(e.provider,[...e.path,t]),mI=(e,t)=>wu(Pa,e,new or(Ti((r)=>t(r)),Yn())),oL=(e)=>{switch(e._tag){case"Union":return e.types.every(oL);case"Objects":case"Arrays":case"Suspend":return!1;default:return!0}},yI=(e,t)=>{switch(e._tag){case"Objects":return t?._tag==="Record";case"Arrays":return t?._tag==="Array";case"Union":return e.types.some((r)=>yI(r,t));case"Suspend":return yI(e.thunk(),t);default:return t?.value!==void 0}},b3=po((e)=>{let t=new WeakSet,r=Ob((n)=>{switch(t.add(n),n._tag){case"Objects":{let o=be(function*(i){if(i.node?._tag!=="Record")return;let s=i.node,c=new Set;for(let x of n.propertySignatures)if(typeof x.name==="string")c.add(x.name);if(n.indexSignatures.length>0){let x={};for(let f of s.keys)hr(x,f,void 0);for(let f of n.indexSignatures)for(let g of bu(x,f.parameter))if(typeof g==="string")c.add(g)}let d={};for(let x of c){let f=yield*eL(i,x);if(f.node!==void 0)hr(d,x,f)}return d});return mI(n.recur(r,(i)=>i),o)}case"Arrays":{let o=be(function*(i){if(i.node?._tag!=="Array")return;let s=[];for(let c=0;c<i.node.length;c++)s.push(yield*eL(i,c));return s});return mI(n.recur(r),o)}case"Union":for(let o of n.types)r(o);if(!oL(n))return n.recur(r);break;case"Suspend":{let o=n.thunk();if(!t.has(o))r(o);return n.recur(r)}case"Declaration":case"Any":throw new globalThis.Error("Config.schema does not support opaque StringTree encodings",{cause:n})}return mI(n,(o)=>j(o.node?.value))});return r(e)});function iL(e,t){let r=mh(e),n=bo(r.ast),o=Ka(wt(b3(r.ast))),i=typeof t==="string"?[t]:t??[];return Sh((s,c)=>{let d=[...c,...i];return nL(s,d).pipe(Sr((x)=>o(x).pipe(Qo(vt),pm((f)=>{let g=new hI(new Du(d.length>0?new In(d,f):f));return yI(n,x.node)?oe(g):j(Mt(g))}))),rL((x)=>_P(x)&&x3(x.defect)?sS(new hI(x.defect)).annotate(pS(x)):x))})}function Ga(e){return iL(a,e)}function I3(e){return iL(FD(a),e)}var E3=eS,sL=(e)=>tt((t)=>e(t.getRef(E3)));var Ih=(...e)=>sL((t)=>It(()=>{t.error(...e)}));var Or=(...e)=>sL((t)=>It(()=>{t.log(...e)}));var Eh="~effect/ErrorReporter/ignore";var aL="~effect/Runtime/errorExitCode";var Nu="~effect/Runtime/errorReported";var gt=a.check(N()),me=yt("WorkspaceId")(gt),_i=yt("WorkspaceInviteId")(gt),vs=yt("UserId")(gt),SI=yt("AuditEventId")(gt),Nt=yt("PostId")(gt),ur=yt("TargetId")(gt),Zt=yt("AttemptId")(gt),Y=yt("AccountId")(gt),vn=yt("MediaId")(gt),Ot=yt("ProfileId")(gt),ja=yt("ApiKeyId")(gt),Bu=yt("WebhookEndpointId")(gt),Cn=yt("InboxConversationId")(gt),eo=yt("InboxMessageId")(gt),gp=yt("InboxCommentThreadId")(gt),xp=yt("InboxCommentId")(gt),Sp=yt("InboxMentionId")(gt),kh=yt("InboxReviewId")(gt),bI=yt("InboxAttachmentId")(gt),Ui=yt("InboxActionId")(gt),dfe=yt("InboundEventId")(gt),ufe=yt("WebhookDeliveryId")(gt),to=yt("AdCampaignId")(gt),Cs=yt("AdGroupId")(gt),bp=yt("AdCreativeId")(gt),Ts=yt("AdId")(gt),cL=yt("AdInsightId")(gt),ro=yt("AdOperationId")(gt),pL=yt("AdBoostId")(gt),dL=yt("AdRequestId")(gt);var uL=(e)=>e,lL=(e)=>e;var II=Yr.check(we(1),ae(100)),EI=a.check(we(1),ae(100)).annotate({description:"An IANA time zone such as America/New_York."}),za=p({id:me,name:II,defaultTimezone:EI,role:G(["owner","member"])}),fL=p({workspaces:L(za)}),mL=p({name:II,defaultTimezone:u(EI).annotate({description:"Default IANA time zone for new queues. Defaults to UTC; existing queues keep their own time zone."})}),hfe=p({name:u(II),defaultTimezone:u(EI)}).check(Ft(({name:e,defaultTimezone:t})=>e!==void 0||t!==void 0||"Provide a name, a default time zone, or both.")),yfe=p({workspaceId:me}),hL=Yr.check(we(1),ae(100)),kI=p({id:a.check(N()),email:a,displayName:M(hL)}),yL=p({displayName:M(hL)}),gL=p({deactivated:v(!0)}),xL=p({archived:v(!0)});var no=a.check(Ge(/^[A-Z]{3}$/)),At=p({amountMinor:F,currency:no}).annotate({identifier:"Money"});var Ku=p({estimatedCostMicros:F,estimatedCost:At,includedRemaining:F,overagePublishes:F,xPublishes:F,blocked:M(p({code:G(["insufficient_credit","spend_cap_reached","billing_inactive"]),nextAction:a}))}).annotate({identifier:"PostBillingEstimate"});var k3=50,SL=100;var bL=a.check(we(1),ae(2048)).annotate({description:"Opaque cursor from a previous list response. Pass nextCursor verbatim."}),Pt=p({cursor:u(bL),limit:u(fh.check(yp(),Tr({minimum:1,maximum:SL})).annotate({description:`Page size from 1 to ${SL}. Defaults to ${k3}.`}))}).annotate({identifier:"PageQuery"}),Ve={hasMore:X,nextCursor:u(bL)},w3=p({v:v(1),k:a.check(ae(512)),id:a.check(we(1),ae(256))}),wfe=IJ(w3);var A3=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","queue_not_found","queue_unavailable","invalid_field","account_ambiguous","unsupported_placement","schedule_required","selector_required","selector_conflict"]),wo=p({code:A3,path:L(st([a,F])),message:a,candidates:u(L(p({accountId:Y,name:a})))}).annotate({identifier:"PostIssue"}),Tfe=jQ();var Os=["bluesky","facebook","instagram","linkedin","pinterest","reddit","snapchat","tiktok","threads","x","youtube","google_business"],Tn=G(Os),v3=[...Os,"meta_ads","google_ads","reddit_ads","pinterest_ads","tiktok_ads","linkedin_ads","snapchat_ads","amazon_ads","openai_ads"],ze=G(v3);var wh=G(["na","eu","fe"]),br=G(["social_page","social_account","social_board","social_channel","ad_account"]),C3=G(["auth","permission","access_pending","rate_limit","not_found","deleted","conflict","invalid_request","transient","invalid_response","unsupported"]),Rfe=p({provider:ze,operation:a,kind:C3,providerStatus:u(F),providerCode:u(a),requestId:u(a),retryable:X,retryAfterSeconds:u(F),missingScopes:u(L(a)),detail:u(a)}).annotate({identifier:"ProviderError"}),_fe=G(["publish","read_insights","engage","ads"]),T3=p({provider:Tn});var lr=G(Os),Ip=a.check(N()),Ao=F.check(Ne(1)),O3=128,sn=a.check(Ge(new RegExp(`^[A-Za-z0-9._~-]{1,${O3}}$`))),Kfe=p({"idempotency-key":sn}),qfe=p({"idempotency-key":u(sn)}),IL=86400,$t=a.check(Ge(/^\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)$/),Ft((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"})),Pr=G(["feed","reel","story","carousel","video","pin"]),Ah=st([$t,PD]),P3=p({accountId:Y,placement:Pr,scheduledAt:u(Ah),queueId:u(Ip)}).annotate({identifier:"DestinationSelection"}),$fe=p({expectedRevision:Ao,scheduledAt:u($t),accountIds:u(L(Y).check(we(1),ae(50)).annotate({description:"Select every draft placement for these accounts. Use targets for exact selection instead."})),targets:u(L(P3).check(we(1),ae(50)).annotate({description:"Select exact draft destinations and optionally override each schedule. Omit accountIds when using targets."}))}),EL=p({postId:Nt}),wI=p({postId:Nt,targetId:ur}),Wfe=p({expectedAttemptId:Zt}),Gfe=st([p({expectedAttemptId:Zt,action:v("reschedule"),scheduledAt:$t}),p({expectedAttemptId:Zt,action:v("reschedule"),queueId:Ip,pinned:u(p({slotId:Ip,occurrenceDate:a.check(Ge(/^\d{4}-\d{2}-\d{2}$/))}))}),p({expectedAttemptId:Zt,action:G(["publish_now","cancel"])})]).annotate({identifier:"ScheduleChange"}),R3=u(a),kL={queueId:u(Ip),slotId:u(Ip),assignmentId:u(Ip),occurrenceDate:u(a.check(Ge(/^\d{4}-\d{2}-\d{2}$/))),localDate:u(a.check(Ge(/^\d{4}-\d{2}-\d{2}$/))),localTime:u(a.check(Ge(/^(?:[01]\d|2[0-3]):[0-5]\d$/))),timezone:u(a)},wL={targetId:ur,attemptId:Zt,accountId:Y,scheduledAt:R3,...kL},Ep=G(["scheduled","queued","submitting","confirming","published","provider_draft","failed","unresolved","cancelled"]),vh=st([v("draft"),Ep]).annotate({identifier:"PostState"}),qu=p({id:a.check(we(1)),kind:a.check(we(1))}).annotate({identifier:"DeliveryProviderRef"}),AI=p({...wL,status:Ep}),_3=p({targetId:ur,attemptId:Zt,accountId:Y,provider:lr,placement:Pr,status:Ep,scheduledAt:M(a),url:M(a),issue:M(a),canRetry:X,canReconcile:X,...kL}).annotate({identifier:"PublishAcceptedTarget"}),Qa=p({postId:Nt,idempotencyKey:sn,targets:L(_3),warnings:L(wo),billing:u(Ku)}).annotate({identifier:"PublishAccepted"}),$u=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","billing_inactive","spend_cap_reached","insufficient_credit"]),jfe=G(["pending","sending","posted","failed","unresolved"]),zfe=G(["pending","updating","updated","failed","unresolved"]),Qfe=G(["pending","sending","invited","failed","unresolved"]),U3={...wL,revision:Ao,provider:lr,placement:Pr},Ch=p({...U3,status:Ep,providerRef:u(qu),url:u(a),issue:u($u),canRetry:X,canReconcile:X,nextAction:u(a)}).annotate({identifier:"DeliveryStatus"}),vI=p({postId:Nt,status:vh,targets:L(Ch)}),Hfe=p({settled:X,post:vI,retryAfterSeconds:u(F)}).annotate({identifier:"PublishWait"});function AL(e){return e==="draft"||!["scheduled","queued","submitting","confirming"].includes(e)}var D3=p({postId:Nt,isDraft:X,status:vh,textPreview:a,targetCount:F.check(Ne(0)),mediaCount:F.check(Ne(0)),revision:Ao,createdAt:a,updatedAt:a}).annotate({identifier:"PostSummary"}),vL=p({data:L(D3),...Ve}).annotate({identifier:"PostList"}),L3=p({delivery:Ch,createdAt:a,updatedAt:a,replacesAttemptId:u(Zt)}).annotate({identifier:"DeliveryAttemptSummary"}),CL=p({currentAttemptId:Zt,data:L(L3),...Ve}).annotate({identifier:"DeliveryHistory"});var Ps=G(["payg","pro","platform","enterprise"]),Th=G(["month","year"]),Oh=G(["fake","stripe"]),Wu=G(["active","trialing","past_due","canceled","incomplete","unpaid"]),Ph=G(["confirmed_publish","x_passthrough","x_read","managed_ad","inbox_reply","automation_run"]),M3=p({meter:Ph,includedPerPeriod:F,overageUnitPriceMicros:M(F),unitLabel:a}).annotate({identifier:"BillingPlanMeter"}),F3=p({id:Ps,name:a,monthlyPrice:M(At),annualPrice:M(At),meters:L(M3),xReads:X,includedXReadMicros:M(F),seatsLimit:M(F),analyticsRetentionDays:F,whiteLabelOAuth:X,ssoSaml:X,priorityQueue:X,adsInsights:X,adsWrite:X}).annotate({identifier:"BillingPlan"}),TL=p({data:L(F3)}).annotate({identifier:"BillingPlanList"}),N3=p({meter:Ph,includedPerPeriod:F,used:F,billable:F,costMicros:F}).annotate({identifier:"BillingMeterUsage"}),B3=p({monthlySpendCapMicros:M(F),version:F}).annotate({identifier:"BillingSpendControls"}),K3=G(["ok","payment_required","insufficient_credit","spend_cap_reached"]),TI=p({workspaceId:me,plan:Ps,status:Wu,paymentStatus:K3,interval:M(Th),gateway:Oh,periodStart:a,periodEnd:a,cancelAtPeriodEnd:X,creditBalanceMicros:F,creditBalance:At,spendControls:B3,currentPeriod:p({start:a,end:a,meters:L(N3),totalVariableSpendMicros:F,seatsUsed:F,seatsLimit:M(F)})}).annotate({identifier:"WorkspaceBilling"}),Ha=a.check(Ge(/^\d{4}-\d{2}-\d{2}$/)),CI=a.check(Ge(/^https?:\/\/[^\s]+$/)),tme=p({from:u(Ha),to:u(Ha),meter:u(Ph),provider:u(lr)}).annotate({identifier:"BillingUsageQuery"}),q3=p({date:Ha,meter:Ph,provider:M(lr),quantity:F,billableQuantity:F,costMicros:F}).annotate({identifier:"BillingUsageDailyPoint"}),OL=p({from:Ha,to:Ha,totals:p({quantity:F,billableQuantity:F,costMicros:F}),data:L(q3)}).annotate({identifier:"BillingUsage"}),Rh=G(["top_up","auto_top_up","overage_debit","x_passthrough_debit","refund","adjustment"]),rme=p({kind:u(Rh),from:u(Ha),to:u(Ha),...Pt.fields}).annotate({identifier:"BillingLedgerQuery"}),$3=p({id:a.check(N()),kind:Rh,deltaMicros:F,balanceAfterMicros:F,description:a,referenceKind:M(a),referenceId:M(a),createdAt:a}).annotate({identifier:"BillingLedgerEntry"}),PL=p({data:L($3),...Ve}).annotate({identifier:"BillingLedgerList"}),nme=st([p({mode:v("subscription"),plan:G(["pro","platform"]),interval:Th,returnUrl:u(CI)}),p({mode:v("top_up"),amountMinor:F.check(Ne(1000),LD(1e7)),returnUrl:u(CI)})]).annotate({identifier:"CreateBillingCheckout"}),RL=p({url:a,expiresAt:u(a)}).annotate({identifier:"BillingCheckoutSession"}),ome=p({returnUrl:u(CI)}).annotate({identifier:"CreateBillingPortal"}),_L=p({url:a}).annotate({identifier:"BillingPortalSession"}),ime=p({version:F,monthlySpendCapMicros:M(F)}).annotate({identifier:"UpdateBillingSpendControls"});var UL=180,DL=365,FL=["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.deleted","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"],OI=G(FL).annotate({identifier:"AuditAction"}),NL=["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"],_h=G(NL).annotate({identifier:"AuditTargetKind"}),W3=G(["user","api_key"]).annotate({identifier:"AuditActorType"}),G3=st([p({type:v("user"),id:vs,email:M(a),displayName:M(a)}),p({type:v("api_key"),id:ja,name:M(a),prefix:M(a)})]).annotate({identifier:"AuditActor"}),PI=p({id:SI,workspaceId:me,profileId:M(Ot),actor:G3,action:OI,targetKind:_h,targetId:a.check(N()),detail:Yt(a,J),createdAt:a}).annotate({identifier:"AuditEvent"}),BL=p({data:L(PI),...Ve}).annotate({identifier:"AuditEventList"}),lme=p({workspaceId:me,eventId:SI}),LL=st([$t,a.check(Ge(/^\d{4}-\d{2}-\d{2}$/))]),fme=p({action:u(OI),targetKind:u(_h),targetId:u(a.check(N())),actorType:u(W3),actorId:u(a.check(N())),profileId:u(Ot),from:u(LL).annotate({description:"Inclusive start instant (ISO 8601 timestamp or YYYY-MM-DD UTC date)."}),to:u(LL).annotate({description:"Inclusive end instant (ISO 8601 timestamp or YYYY-MM-DD UTC date)."}),...Pt.fields}),j3=p({action:OI,targetKind:_h,description:a,retentionDays:F}).annotate({identifier:"AuditActionCatalogEntry"}),KL=p({actions:L(j3),targetKinds:L(_h),retention:p({standardDays:F,spendDays:F})}).annotate({identifier:"AuditActionCatalog"}),ML={"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.deleted":{targetKind:"integration_connection",description:"Disconnected provider grant permanently deleted with its accounts and their publishing, ads, inbox, and analytics records."},"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."}},mme={actions:FL.map((e)=>({action:e,targetKind:ML[e].targetKind,description:ML[e].description,retentionDays:e.startsWith("billing.")||e.startsWith("ads.")?DL:UL})),targetKinds:[...NL],retention:{standardDays:UL,spendDays:DL}};var RI=p({workspaceId:me,deliveryFailures:X,connectionExpiring:X,webhookFailures:X,billingAlerts:X,weeklyDigest:X,updatedAt:M(a)}).annotate({identifier:"NotificationPreferences"}),xme=p({deliveryFailures:u(X),connectionExpiring:u(X),webhookFailures:u(X),billingAlerts:u(X),weeklyDigest:u(X)}).check(Ft((e)=>Object.values(e).some((t)=>t!==void 0)||"Provide at least one notification preference to update.")).annotate({identifier:"UpdateNotificationPreferences"});var kp=G(["owner","member"]).annotate({identifier:"WorkspaceRole"}),z3=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,Q3=Yr.pipe(Ri(a.check(we(3),ae(320),Ge(z3)),pH())).annotate({identifier:"NormalizedEmail",description:"Email address, trimmed and lowercased."}),Uh=p({workspaceId:me,userId:vs,email:a,displayName:M(a),role:kp,joinedAt:a}).annotate({identifier:"WorkspaceMember"}),qL=p({data:L(Uh),...Ve}).annotate({identifier:"WorkspaceMemberList"}),wme=p({role:u(kp),...Pt.fields}),Ame=p({workspaceId:me,userId:vs}),vme=p({role:kp}).annotate({identifier:"UpdateWorkspaceMemberRole"}),$L=p({removed:v(!0)}).annotate({identifier:"WorkspaceMemberRemoved"}),WL=G(["pending","accepted","revoked","expired"]).annotate({identifier:"WorkspaceInviteStatus"}),_I=p({id:_i,workspaceId:me,email:a,role:kp,status:WL,deliveryState:G(["queued","sending","uncertain","sent"]),remoteRevocationPending:X,invitedByUserId:vs,invitedByEmail:M(a),expiresAt:a,acceptedAt:M(a),revokedAt:M(a),createdAt:a}).annotate({identifier:"WorkspaceInvite"}),GL=p({data:L(_I),...Ve}).annotate({identifier:"WorkspaceInviteList"}),Cme=p({status:u(WL),...Pt.fields}),Tme=p({workspaceId:me,inviteId:_i}),Ome=p({email:Q3,role:u(kp)}).annotate({identifier:"CreateWorkspaceInvite"}),jL=p({invite:_I}).annotate({identifier:"WorkspaceInviteCreated"}),zL=p({invite:_I,resendState:G(["sending","sent","uncertain"])}).annotate({identifier:"WorkspaceInviteResent"}),QL=p({revoked:v(!0),remoteRevocationPending:X}).annotate({identifier:"WorkspaceInviteRevoked"}),H3=p({id:_i,workspaceId:me,workspaceName:a,role:kp,invitedByEmail:M(a),invitedByName:M(a),expiresAt:a,createdAt:a}).annotate({identifier:"PendingUserInvite"}),HL=p({data:L(H3)}).annotate({identifier:"PendingUserInviteList"}),Pme=st([p({token:Yr.check(we(1),ae(256))}),p({inviteId:_i})]).annotate({identifier:"AcceptWorkspaceInvite"}),VL=p({workspace:za,membership:Uh}).annotate({identifier:"WorkspaceInviteAccepted"}),JL=p({declined:v(!0),remoteRevocationPending:X}).annotate({identifier:"WorkspaceInviteDeclined"}),Rme=p({inviteId:_i});var V3="pubnio_sk_",UI=new RegExp(`^${V3}[A-Za-z0-9_-]{43}$`),Gu=G(["read","publish","engage","ads_read","ads_manage"]),DI=L(Gu).check(we(1),ae(Gu.literals.length),Ft((e)=>new Set(e).size===e.length||"Choose each scope once.")),LI=Yr.check(we(1),ae(100)),ju=p({id:ja,workspaceId:me,name:LI,prefix:a,scopes:DI,createdAt:a,updatedAt:a,expiresAt:M(a),revokedAt:M(a)}).annotate({identifier:"ApiKey"}),Fme=p({name:LI,scopes:u(DI).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($t)}),Nme=p({name:u(LI),scopes:u(DI)}).check(Ft(({name:e,scopes:t})=>e!==void 0||t!==void 0||"Provide a name or scopes."));var Bme=Gu.literals;var Kme=p({workspaceId:me,keyId:ja}),YL=p({key:ju,secret:a.check(Ge(UI)).annotate({description:"Copy this secret now. This is the only response that returns it."})}),ZL=p({data:L(ju),...Ve}).annotate({identifier:"ApiKeyList"}),XL=p({revoked:v(!0)});var Dh=26214400,Lh=268435456,Mh=16777216,J3=8388608;var Rs=a.check(ae(2048),Ge(/^https:\/\//i),Ft((e)=>{let t=URL.parse(e);return Boolean(t?.hostname&&t.protocol==="https:"&&!t.username&&!t.password)||"Expected an HTTPS media URL without credentials"})),eM=p({mediaId:vn}),Y3=p({url:Rs}),Z3=st([eM,Y3]).annotate({identifier:"MediaInput"}),MI=35,_s=L(Z3).check(ae(MI)),zu=G(["image","video","document"]),wp=G(["image/jpeg","image/png","image/gif","image/webp","video/mp4","video/quicktime","video/webm","application/pdf"]);function X3(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 tM(e){return wp.literals.find((t)=>X3(e,t))}var Qme=p({workspaceId:me,mimeType:wp}),FI=p({mediaId:vn,type:zu,mimeType:wp,sizeBytes:F.check(Tr({minimum:1,maximum:Lh})),createdAt:a}).annotate({identifier:"MediaAsset"}),rM=p({data:L(FI),...Ve}).annotate({identifier:"MediaList"}),nM=p({deleted:v(!0)}),Hme=p({url:a.check(we(1),ae(8192))}).annotate({identifier:"MediaImport"}),Vme=p({sizeBytes:F.check(Ne(1))}).annotate({identifier:"MediaUploadStart"}),oM=Tr({minimum:1,maximum:Math.ceil(Lh/Mh)}),e6=F.check(oM),Jme=p({...eM.fields,partNumber:fh.check(yp(),oM)}),iM=p({mediaId:vn,partSizeBytes:v(Mh),expiresAt:a}).annotate({identifier:"MediaUploadSession"}),sM=p({partNumber:e6}).annotate({identifier:"MediaPartReceipt"}),aM=p({code:G(["media_source_unavailable","media_storage_unavailable","media_too_large","unsupported_media","upload_expired"]),maxBytes:u(F)}).annotate({identifier:"MediaIntakeIssue"}),t6=G(["awaiting_upload","processing","ready","failed"]),r6=p({receivedPartCount:F.check(Ne(0)),partDigests:L(a.check(Ge(/^[A-Za-z0-9_-]{43}$/))),expiresAt:a}).annotate({identifier:"MediaUploadProgress"}),Va=p({mediaId:vn,status:t6,asset:u(FI),issue:u(aM),upload:u(r6),idempotencyKey:u(sn),retryAfterSeconds:u(F)}).annotate({identifier:"MediaIntake"}),Yme=p({mediaId:vn,status:G(["ready","failed","timeout"]),asset:u(FI),issue:u(aM),retryAfterSeconds:u(F)}).annotate({identifier:"MediaWait"}),Zme=p({data:a.check(we(1),ae(Math.ceil(J3/3)*4+4)).annotate({description:"Base64-encoded file bytes. Maximum 8 MiB after decoding."}),mimeType:wp,filename:u(a.check(we(1),ae(255)))}).annotate({identifier:"MediaInlineUpload"}),cM=G(["part_conflict","part_out_of_order","parts_missing","upload_closed","upload_expired"]);var NI=["live","beta","upcoming"];var n6=["publish","read_insights","manage_comments"],Fh=[...n6,"send_messages"],On={bluesky:{label:"Bluesky",availability:"beta",authFamily:"bluesky",accountKinds:["social_account"],capabilities:{social_account:Fh},approvalRequired:{},limited:{}},facebook:{label:"Facebook",availability:"live",authFamily:"facebook",accountKinds:["social_page"],capabilities:{social_page:Fh},approvalRequired:{},limited:{}},instagram:{label:"Instagram",availability:"live",authFamily:"instagram",accountKinds:["social_account"],capabilities:{social_account:Fh},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:Fh},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 the={bluesky:{...On.bluesky,publishCapable:!0},facebook:{...On.facebook,publishCapable:!0},instagram:{...On.instagram,publishCapable:!0},linkedin:{...On.linkedin,publishCapable:!0},pinterest:{...On.pinterest,publishCapable:!0},reddit:{...On.reddit,publishCapable:!0},snapchat:{...On.snapchat,publishCapable:!0},tiktok:{...On.tiktok,publishCapable:!0},threads:{...On.threads,publishCapable:!0},x:{...On.x,publishCapable:!0},youtube:{...On.youtube,publishCapable:!0},google_business:{...On.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"}},rhe=Os.flatMap((e)=>{let t=On[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 o6=60,i6=3600;var s6={requestsPerMinute:300,publishesPerMinute:30,mediaUploadsPerMinute:10,windowSeconds:60},Li=st([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:L(a)}),p({status:v("permission_required"),reason:v("missing_page_task")})]).annotate({identifier:"AccountReadiness"}),Di=G(["publish","read_insights","manage_comments","send_messages","ads_read","ads_write","ads_spend"]),a6=G(["supported","not_supported","access_pending","permission_missing","unverified","reconnect_required","unavailable"]),dhe=p({scopes:u(L(a)),pageTasks:u(L(a)),roles:u(L(a)),loginMethods:u(L(a))}),Mi=p({capability:Di,state:a6,missingScopes:L(a),missingRoles:L(a),reason:u(a)}).annotate({identifier:"AccountCapability"}),c6=p({accountId:Y,profileId:Ot,provider:ze,accountKind:br,enabled:X,publishingReadiness:Li,capabilities:L(Mi),checkedAt:a}).annotate({identifier:"AccountCapabilities"}),dM=p({capabilities:L(c6)}),uhe=p({workspaceId:me,profileId:u(Ot),accountId:u(Y),capability:u(Di)}),p6=p({provider:ze,availability:G(NI),accountKind:br,capabilities:L(Di),approvalRequired:L(Di),limited:L(Di)}).annotate({identifier:"CapabilityCatalogEntry"}),uM=p({entries:L(p6)}).annotate({identifier:"CapabilityCatalog"}),d6=p({accountId:Y,provider:ze,accountKind:br,name:a,enabled:X,readiness:Li}).annotate({identifier:"AccountSummary"}),lhe=p({accounts:L(d6)}).annotate({identifier:"AccountSummaryList"}),u6=p({requestsPerMinute:F,publishesPerMinute:F,mediaUploadsPerMinute:F,windowSeconds:F}).annotate({identifier:"RateLimits"}),lM=p({uploadMaxBytes:F,assetMaxBytes:F,partMaxBytes:F,types:L(zu)}).annotate({identifier:"MediaLimits"}),BI=p({targetsPerRequest:F,draftTextCharacters:F,idempotencyTtlSeconds:F,wait:p({defaultSeconds:F,maxSeconds:F}),media:lM,rateLimits:u6}).annotate({identifier:"ApiLimits"}),fM={minOptions:2,maxOptions:4},Ap={...fM,optionCharacters:25,minDurationMinutes:5,maxDurationMinutes:10080},Qu={...fM,questionCharacters:140,optionCharacters:30,durations:["ONE_DAY","THREE_DAYS","SEVEN_DAYS","FOURTEEN_DAYS"]},KI=["following","mentionedUsers","subscribers","verified"],mM=10,pM={minOptions:F,maxOptions:F,optionCharacters:F},l6=p({poll:st([p({...pM,minDurationMinutes:F,maxDurationMinutes:F}),p({...pM,questionCharacters:F,durations:L(G(Qu.durations))})]),replySettings:u(L(G(KI))),maxMediaTags:u(F),placeId:u(X),quotePostId:u(X)}),f6=p({settings:u(l6),placement:Pr,default:X,mediaTypes:L(zu),maxMedia:F,captionCharacters:F}).annotate({identifier:"PlacementCapability"}),m6=p({provider:Tn,label:a,availability:G(NI),accountKinds:L(br),placements:L(f6),requiredScopes:L(a)}).annotate({identifier:"ProviderCapability"}),hM=p({providers:L(m6),accountKinds:L(br),media:lM,limits:BI}).annotate({identifier:"PublishCapabilities"}),fhe={targetsPerRequest:50,draftTextCharacters:128000,idempotencyTtlSeconds:IL,wait:{defaultSeconds:o6,maxSeconds:i6},media:{uploadMaxBytes:Dh,assetMaxBytes:Lh,partMaxBytes:Mh,types:[...zu.literals]},rateLimits:s6};var Nh=G(["instagram_login","facebook_login","unified_login"]),yM=u(Nh),h6=st([p({provider:v("bluesky"),kind:v("account"),handle:a,did:a,service:a}),p({provider:v("facebook"),kind:v("page"),tasks:u(L(a))}),p({provider:v("instagram"),kind:v("professional_account"),username:a,loginMethod:yM,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(X)}),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(Ge(/^[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(Ge(/^[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(Ge(/^[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(Ge(/^[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(Ge(/^[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(Ge(/^[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(Ge(/^[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(Ge(/^[A-Z]{3}$/)),timezone:a,status:G(["active","disabled","pending","closed","unknown"]),region:wh,businessId:u(a),managerId:u(a)}),p({provider:v("openai_ads"),kind:v("ad_account"),externalId:a,currency:a.check(Ge(/^[A-Z]{3}$/)),timezone:a,status:G(["active","disabled","pending","closed","unknown"])})]);var vp=p({id:Y,profileId:Ot,connectionId:a.check(N()),provider:ze,accountKind:br,parentAccountId:M(Y),name:a,platformUserId:a,avatarUrl:M(a),enabled:X,available:X,details:h6,readiness:Li,capabilities:L(Mi)}).annotate({identifier:"ProviderAccount"}),qI=p({accounts:L(vp)}),y6=p({id:Y,enabled:X});var Bh=a.check(N()),WI=p({attemptId:Bh}),Hu=p({accountId:Y}),gM=p({connectionId:Bh}),GI=p({attemptId:Bh,url:a,expiresAt:u(a)}),g6=G(["provider_error","invalid_callback","account_mismatch","connection_changed","connection_failed"]),khe=G(["pages_permission_declined","no_pages","granted_pages_not_listed","business_assets_unavailable"]),$I={attemptId:Bh,provider:ze},xM=st([p({...$I,status:G(["pending","denied","expired"])}),p({...$I,status:v("connected"),accountIds:L(Y)}),p({...$I,status:v("failed"),reason:g6})]).annotate({identifier:"ConnectionStatus"}),SM=p({disconnected:v(!0)}),bM=p({deleted:v(!0)}),x6=p({handle:Yr.check(we(1),ae(253)),appPassword:Yr.check(we(1),ae(256)),service:u(a.check(ae(2048),Ge(/^https:\/\//i)))}).annotate({identifier:"BlueskyConnect"}),whe=p({...x6.fields,accountId:u(Y),profileId:u(Ot)}).annotate({identifier:"BlueskySessionConnect"}),IM=p({used:F.check(Ne(0)),limit:F.check(ti(0)),windowSeconds:F.check(ti(0))}).annotate({identifier:"InstagramPublishingLimit"}),Kh=G(["music","original_sound"]),Cp=a.check(Ge(/^\d{1,32}$/)),Ahe=p({...Hu.fields,audioId:Cp}),vhe=p({audioType:Kh,q:u(Yr.check(we(1),ae(200)))}),jI=p({audioId:Cp,audioType:Kh,title:a,durationMs:u(F.check(Ne(0))),artist:u(a),creator:u(a),previewUrl:u(a),coverUrl:u(a),instagramPreviewUrl:u(a)}).annotate({identifier:"InstagramAudio"}),EM=p({audio:L(jI)});var VI=128000;var qh=1250;var S6=3000,Whe=new Intl.Segmenter(void 0,{granularity:"grapheme"});var b6=300;var kM=500,I6=100,E6=1e5,zI=50,k6=100;var Fi=a.check(ae(VI)),OM=F.check(Ne(1)),Ghe=p({workspaceId:me,isDraft:u(X).annotate({description:"Filter to drafts (true) or submitted posts (false)."}),accountId:u(Y).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(Ot).annotate({description:"Filter to posts targeting any account in this workspace profile."}),...Pt.fields}),w6=MI,qr={text:u(Fi),media:u(_s),scheduledAt:u(Ah),queueId:u(a.check(N()).annotate({description:"Assign this destination to its connected account's schedule queue."}))},Ju=a.check(Ge(/^\d+$/)),A6=L(a.check(Ge(/^[A-Z]{2}$/))).check(we(1),ae(25)),PM={firstComment:u(Fi),thread:u(L(a.check(we(1),ae(qh))).check(ae(24))),nativeDraft:u(X),countries:u(A6)},RM=p({...PM,link:u(Rs),textFormatPresetId:u(Ju),albumId:u(Ju)}).annotate({identifier:"FacebookFeedSettings"}),_M=p({...PM,title:u(Fi),isAiGenerated:u(X),collaboratorPageIds:u(L(Ju).check(we(1),ae(10),Ft((e)=>new Set(e).size===e.length||"Choose each collaborator Page once")))}).annotate({identifier:"FacebookReelSettings"}),UM=p({isAiGenerated:u(X)}).annotate({identifier:"FacebookStorySettings"}),JI=a.check(Ge(/^@?[a-zA-Z0-9._]{1,30}$/)),wM=dr.check(Tr({minimum:0,maximum:1})),v6=p({username:JI,x:u(wM),y:u(wM)}),DM={isAiGenerated:u(X)},YI={...DM,firstComment:u(Fi),commentsEnabled:u(X),collaborators:u(L(JI).check(ae(3))),locationId:u(Ju),isPaidPartnership:u(X),brandedContentSponsors:u(L(st([Ju,JI])).check(we(1),ae(2)))},$h=u(L(v6).check(ae(20))),LM=u(a.check(ae(1000))),MM=p({...YI,altText:LM,userTags:$h}).annotate({identifier:"InstagramFeedSettings"}),FM=p({...YI,shareToFeed:u(X),muteAudio:u(X),audioConfiguration:u(p({audioId:Cp,audioVolume:u(F.check(Tr({minimum:1,maximum:100}))),videoVolume:u(F.check(Tr({minimum:0,maximum:100})))})),coverUrl:u(Rs),thumbOffset:u(F.check(Ne(0))),audioName:u(a.check(ae(255))),trial:u(p({graduationStrategy:G(["MANUAL","SS_PERFORMANCE"])})),userTags:$h}).annotate({identifier:"InstagramReelSettings"}),NM=p({...YI,muteAudio:u(X),slides:u(L(p({altText:LM,userTags:$h})).check(ae(20)))}).annotate({identifier:"InstagramCarouselSettings"}),BM=p({...DM,muteAudio:u(X),userTags:$h}).annotate({identifier:"InstagramStorySettings"}),AM=a.check(we(1),ae(S6)),KM=p({firstComment:u(AM),thread:u(L(AM).check(ae(24))),altText:u(a.check(ae(1000)))}).annotate({identifier:"BlueskyFeedSettings"}),qM=Ft((e)=>e.trim().length>0||"Supply a nonblank string.",{toJsonSchema:()=>({pattern:"\\S"})});function $M(e){return a.check(BJ(1,e,{expected:`between 1 and ${e} characters`}),qM)}function WM({minOptions:e,maxOptions:t,optionCharacters:r}){return L($M(r)).check(we(e),ae(t))}var C6=p({question:$M(Qu.questionCharacters),options:WM(Qu),duration:G(Qu.durations)}).annotate({description:"Organic LinkedIn poll. Include post text and omit media, altText, and documentTitle."}),GM=p({poll:u(C6),firstComment:u(Fi),thread:u(L(a.check(we(1),ae(qh))).check(ae(24))),visibility:u(G(["PUBLIC","CONNECTIONS"])),altText:u(a.check(ae(4086))),documentTitle:u(Yr.check(we(1),ae(k6)))}).annotate({identifier:"LinkedInFeedSettings"}),jM=p({title:u(a.check(we(1),ae(100))),description:u(a.check(we(1),ae(800))),link:u(Rs),altText:u(a.check(ae(500)))}).annotate({identifier:"PinterestPinSettings"}),T6=a.check(Ge(/^(?:r\/)?[A-Za-z0-9_]{2,21}$/)),zM=p({subreddit:T6,title:a.check(we(1),ae(b6)),link:u(Rs),flairId:u(a.check(we(1),ae(100))),flairText:u(a.check(we(1),ae(64))),nsfw:u(X),spoiler:u(X),sendReplies:u(X),thumbnailMediaId:u(vn),firstComment:u(Fi)}).annotate({identifier:"RedditFeedSettings"}),QM=p({contentType:u(G(["story","saved_story","spotlight"])),title:u(a.check(we(1),ae(45))),description:u(a.check(we(1),ae(160))),link:u(Rs),locale:u(a.check(Ge(/^[a-z]{2}_[A-Z]{2}$/)))}).annotate({identifier:"SnapchatStorySettings"}),HM=p({title:a.check(we(1),ae(100)),description:u(a.check(ae(5000))),privacyStatus:G(["public","unlisted","private"]),firstComment:u(Fi),tags:u(L(a.check(ae(100))).check(ae(30))),categoryId:u(a.check(Ge(/^\d{1,3}$/))),madeForKids:u(X),containsSyntheticMedia:u(X),thumbnailMediaId:u(vn),notifySubscribers:u(X),license:u(G(["youtube","creativeCommon"])),embeddable:u(X),publicStatsViewable:u(X)}).annotate({identifier:"YouTubeVideoSettings"}),O6=p({title:a.check(we(1),ae(I6)),content:a.check(we(1),ae(E6))}).annotate({identifier:"XArticleDraftSettings"}),P6=p({options:WM(Ap),durationMinutes:dr.check(yp({expected:"an integer number of minutes"}),Tr({minimum:Ap.minDurationMinutes,maximum:Ap.maxDurationMinutes},{expected:`between ${Ap.minDurationMinutes} and ${Ap.maxDurationMinutes} minutes`}))}).annotate({description:"X poll on the root post. Include post text and omit attachments."}),vM=a.check(Ge(/^[0-9]{1,19}$/,{expected:"an X ID string of 1 to 19 digits"})),VM=p({poll:u(P6),replySettings:u(G(KI).annotate({description:"Who may reply to the root X post. Omit for the provider default."})),quotePostId:u(vM.annotate({description:"Native quotes require an X Enterprise app. With PubNio's current app, omit this field and put the X post URL in the text."})),mediaTaggedUserIds:u(L(vM).check(ae(mM)).annotate({description:"X user ID strings to tag on root post photos (JPEG, PNG, or WebP)."})),placeId:u(a.check(DD({expected:"an X Place ID without surrounding whitespace"}),qM).annotate({description:"Opaque X Place ID such as geo.place_id from a post lookup."})),firstComment:u(Fi),thread:u(L(a.check(we(1),ae(qh))).check(ae(24))),article:u(O6)}).annotate({identifier:"XFeedSettings"}),QI="Use a valid location-local date and time in YYYY-MM-DDTHH:MM format.",CM=a.check(Ge(/^[0-9]{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12][0-9]|3[01])T(?:[01][0-9]|2[0-3]):[0-5][0-9]$/,{message:QI}),Ft((e)=>{let t=Number(e.slice(0,4)),r=new Date(`${e}:00Z`);return t>0&&r.getUTCMonth()+1===Number(e.slice(5,7))&&r.getUTCDate()===Number(e.slice(8,10))||QI})).annotate({description:QI}),HI=a.check(Ge(/\S/,{message:"Enter a string with non-whitespace content."})),TM=Rs.annotate({description:"Use an HTTPS URL of at most 2,048 characters without embedded credentials.",message:"Use an HTTPS URL of at most 2,048 characters without embedded credentials."}),JM=p({topicType:u(G(["standard","event","offer"])),title:u(HI),startsAt:u(CM),endsAt:u(CM),couponCode:u(HI),redeemUrl:u(TM),terms:u(HI),callToAction:u(G(["book","order","shop","learn_more","sign_up","call"])),callToActionUrl:u(TM)}).annotate({identifier:"GoogleBusinessFeedSettings"}),YM=p({firstComment:u(a.check(we(1),ae(kM))),thread:u(L(a.check(we(1),ae(kM))).check(ae(24)))}).annotate({identifier:"ThreadsFeedSettings"}),ZM={privacy:G(["PUBLIC_TO_EVERYONE","MUTUAL_FOLLOW_FRIENDS","FOLLOWER_OF_CREATOR","SELF_ONLY"]),commercialDisclosure:u(G(["none","own_brand","paid_partnership"])),isAiGenerated:u(X),disableComment:u(X),nativeDraft:u(X)},R6=p({...ZM,format:u(v("video")),disableDuet:u(X),disableStitch:u(X)}).annotate({identifier:"TikTokVideoSettings"}),_6=p({...ZM,format:v("photo"),title:u(a.check(ae(90))),coverIndex:u(F.check(Tr({minimum:0,maximum:w6-1}))),autoAddMusic:u(X)}).annotate({identifier:"TikTokPhotoSettings"}),XM=st([R6,_6]).annotate({identifier:"TikTokFeedSettings"}),eF=st([p({accountId:Y,provider:v("bluesky"),placement:v("feed"),...qr,settings:u(KM)}),p({accountId:Y,provider:v("facebook"),placement:v("feed"),...qr,settings:u(RM)}),p({accountId:Y,provider:v("facebook"),placement:v("reel"),...qr,settings:u(_M)}),p({accountId:Y,provider:v("facebook"),placement:v("story"),...qr,settings:u(UM)}),p({accountId:Y,provider:v("instagram"),placement:v("feed"),...qr,settings:u(MM)}),p({accountId:Y,provider:v("instagram"),placement:v("reel"),...qr,settings:u(FM)}),p({accountId:Y,provider:v("instagram"),placement:v("carousel"),...qr,settings:u(NM)}),p({accountId:Y,provider:v("instagram"),placement:v("story"),...qr,settings:u(BM)}),p({accountId:Y,provider:v("linkedin"),placement:v("feed"),...qr,settings:u(GM)}),p({accountId:Y,provider:v("threads"),placement:v("feed"),...qr,settings:u(YM)}),p({accountId:Y,provider:v("x"),placement:v("feed"),...qr,settings:u(VM)}),p({accountId:Y,provider:v("youtube"),placement:v("video"),...qr,settings:HM}),p({accountId:Y,provider:v("pinterest"),placement:v("pin"),...qr,settings:u(jM)}),p({accountId:Y,provider:v("reddit"),placement:v("feed"),...qr,settings:zM}),p({accountId:Y,provider:v("snapchat"),placement:v("story"),...qr,settings:u(QM)}),p({accountId:Y,provider:v("tiktok"),placement:v("feed"),...qr,settings:u(XM)}),p({accountId:Y,provider:v("google_business"),placement:v("feed"),...qr,settings:u(JM)})]).annotate({identifier:"PublishTarget"}),jhe=Kr(eF,{onExcessProperty:"error"}),U6=a.check(we(1),ae(qh)),D6=L(U6).check(we(1),ae(24)),L6=st([KM,RM,_M,UM,MM,FM,NM,BM,GM,zM,QM,YM,VM,HM,jM,XM,JM]);function Vu(e,t=0){switch(e._tag){case"Composite":return e.issues.reduce((r,n)=>r+Vu(n,t),0);case"AnyOf":return e.issues.length===0?0:Math.min(...e.issues.map((r)=>Vu(r,t)));case"Pointer":return Vu(e.issue,t+e.path.length);case"UnexpectedKey":return t===1?3:2;case"MissingKey":return t===1?4:1;default:return 0}}var M6=L6.pipe(lh((e)=>{if(e._tag!=="AnyOf")return oe(e);let[t,...r]=e.issues;if(!t)return oe(e);let n=t,o=Vu(t);for(let i of r){if(o===0)break;let s=Vu(i);if(s<o)n=i,o=s}return oe(n)})),F6=p({accountId:Y,provider:u(Tn),placement:u(Pr),text:u(Fi),thread:u(D6),media:u(_s),scheduledAt:u(Ah),queueId:u(a.check(N()).annotate({description:"Assign this destination to its connected account's schedule queue."})),settings:u(M6)}).annotate({identifier:"CreatePostTarget"}),ZI=Yr.check(ae(VI)).pipe(hJ({description:`At most ${VI} characters after trimming.`})),tF=L(eF).check(ae(50)),XI={text:u(ZI),targets:u(tF),media:u(_s)},zhe=p(XI).annotate({identifier:"PostContent"}),Qhe=p({...XI,scheduledAt:u($t)}).annotate({identifier:"PostPreflight"}),rF=p({text:u(ZI),platforms:u(L(Tn).check(we(1),ae(zI))),accounts:u(L(Y).check(we(1),ae(zI))),targets:u(L(F6).check(we(1),ae(zI))),media:u(_s),scheduledAt:u($t),publishNow:u(X),isDraft:u(X).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."}),N6=p({...XI,expectedRevision:u(OM)}).annotate({identifier:"UpdatePost"}),Tp=p({postId:Nt,isDraft:X,revision:OM,text:ZI,media:_s,targets:tF,deliveries:L(Ch),status:vh,createdAt:a,updatedAt:a}).annotate({identifier:"Post"}),Hhe=p({...Tp.fields,idempotencyKey:u(sn)}).annotate({identifier:"PostCreated"}),Vhe=st([Tp,Qa]).annotate({identifier:"PostCreateResult"}),nF=p({archived:v(!0)}),Jhe=Kr(N6,{onExcessProperty:"error"}),B6=p({accountId:Y,provider:Tn,placement:Pr,canPublish:X,caption:p({count:F,limit:F}),errors:L(wo),warnings:L(wo)}),eE=p({canPublish:X,errors:L(wo),warnings:L(wo),targets:L(B6),billing:u(Ku)}).annotate({identifier:"PostValidation"});var vo=a.check(N()),tr=vo,oF=vo,Wh=Yr.check(we(1),ae(100)),Op=a.check(we(1),ae(100)),iF=F.check(Tr({minimum:0,maximum:6})),Gh=a.check(Ge(/^(?:[01]\d|2[0-3]):[0-5]\d$/)),K6=50,Pn=a.check(Ge(/^\d{4}-\d{2}-\d{2}$/)),q6=p({id:u(vo).annotate({description:"Round-trip an existing slot ID. Omit to create a new slot; a removed slot reports no ID."}),dayOfWeek:iF,time:Gh}).annotate({identifier:"QueueSlotInput"}),$6=p({id:vo,dayOfWeek:iF,time:Gh}).annotate({identifier:"QueueSlot"}),sF=L(q6).check(ae(K6)),W6=p({maxPerDay:M(F.check(Ne(1))).annotate({description:"Null uses the provider limit."}),maxPending:F.check(Ne(1)),minGapSeconds:F.check(Ne(1)),horizonDays:F.check(Tr({minimum:1,maximum:90})),providerMaxPerDay:F.check(Ne(1)),providerMinGapSeconds:F.check(Ne(1))}).annotate({identifier:"QueueLimits"}),G6=G(["active","paused","archived"]),Pp=p({id:tr,workspaceId:me,accountId:Y,name:Wh,timezone:Op,status:G6,isDefault:X.annotate({description:"The queue nextSlot assignment uses for this account when none is given."}),limits:W6,slots:L($6),version:F.check(Ne(1)),pausedAt:M(a),archivedAt:M(a),createdAt:a,updatedAt:a}).annotate({identifier:"Queue"}),aF=p({data:L(Pp),...Ve}).annotate({identifier:"QueueList"}),cF=p({archived:v(!0),version:F.check(Ne(1))}).annotate({identifier:"QueueArchived"}),pF={maxPending:u(F.check(Tr({minimum:1,maximum:1000}))),minGapSeconds:u(F.check(Tr({minimum:60,maximum:604800}))),horizonDays:u(F.check(Tr({minimum:1,maximum:90})))},dF=p({accountId:Y,name:Wh,timezone:u(Op).annotate({description:"An IANA time zone such as America/New_York. Defaults to the workspace default time zone."}),slots:sF,isDefault:u(X).annotate({description:"Promote this queue to the account default. The first active queue is always the default."}),maxPerDay:u(F.check(Tr({minimum:1,maximum:1000}))).annotate({description:"Defaults to the provider limit."}),...pF}).annotate({identifier:"CreateQueue"}),uF=p({expectedVersion:F.check(Ne(1)),name:u(Wh),timezone:u(Op),paused:u(X),isDefault:u(X).annotate({description:"Promote or demote the account default. Demoting the current default requires promoting another queue first."}),maxPerDay:u(M(F.check(Tr({minimum:1,maximum:1000})))),...pF}).annotate({identifier:"UpdateQueue"}),lF=p({expectedVersion:F.check(Ne(1)),slots:sF}).annotate({identifier:"ReplaceQueueSlots"}),fF=G(["paused","archived","account_not_ready"]),mF=G(["max_per_day","max_pending"]),j6=G(["occupied","capacity","skipped","blacked_out"]),hF=p({queueId:tr,slotId:M(vo),scheduledFor:a.annotate({description:"The resolved UTC instant."}),occurrenceDate:Pn.annotate({description:"The local date the assignment counts toward."}),localDate:Pn,localTime:Gh,timezone:Op,available:X,unavailableReason:u(j6)}).annotate({identifier:"QueueOccurrence"}),yF=p({queueId:tr,occurrence:M(hF),horizonEndsAt:a}).annotate({identifier:"QueueNextSlot"}),gF=p({queueId:tr,timezone:Op,horizonEndsAt:a,occurrences:L(hF)}).annotate({identifier:"QueueSlotPreview"}),z6=G(["published_now","cancelled","archived","submitted","rescheduled"]),oye=p({id:oF,queueId:tr,slotId:M(vo),postId:Nt,targetId:ur,attemptId:Zt,scheduledFor:a,occurrenceDate:Pn,releasedAt:M(a),releaseReason:M(z6)}).annotate({identifier:"QueueAssignment"}),Yu=vo,jh=vo,xF=p({slotId:vo,occurrenceDate:Pn}).annotate({identifier:"SkipQueueSlot"}),tE=p({id:Yu,queueId:tr,slotId:vo,occurrenceDate:Pn,createdAt:a}).annotate({identifier:"QueueSkip"}),SF=p({data:L(tE),...Ve}).annotate({identifier:"QueueSkipList"}),bF=Yr.check(ae(200)).annotate({description:"Optional note for why these dates are unavailable."}),IF=p({startsOn:Pn,endsOn:Pn,reason:u(bF)}).annotate({identifier:"CreateQueueBlackout"}),rE=p({id:jh,queueId:tr,startsOn:Pn,endsOn:Pn,reason:M(bF),createdAt:a}).annotate({identifier:"QueueBlackout"}),EF=p({data:L(rE),...Ve}).annotate({identifier:"QueueBlackoutList"}),nE=p({deleted:v(!0)}).annotate({identifier:"QueueDeleted"});var Q6=G(["scheduled","queued"]),H6=p({postId:Nt,targetId:ur,attemptId:Zt,accountId:Y,provider:lr,placement:Pr,queueId:u(tr),slotId:u(vo),assignmentId:u(oF),queueName:u(Wh),scheduledFor:a.annotate({description:"The queued attempt's UTC instant."}),occurrenceDate:u(Pn),timezone:u(Op),localDate:u(Pn),localTime:u(Gh),status:Q6.annotate({description:"scheduled when scheduledFor is in the future; queued otherwise."}),textPreview:a.check(ae(160)).annotate({description:"Short single-line preview of the post text."})}).annotate({identifier:"ScheduleEntry"}),kF=p({data:L(H6),...Ve}).annotate({identifier:"ScheduleList"}),iye=p({results:L(p({index:F.check(Ne(0)),accepted:u(Qa),problem:u(a)}))}).annotate({identifier:"BulkPublishResult"}),V6=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"]),wF=p({code:V6,path:L(st([a,F])),message:a}).annotate({identifier:"QueueIssue"}),sye=p({workspaceId:me,accountId:u(Y),...Pt.fields}),aye=p({workspaceId:me}),cye=p({workspaceId:me,expectedVersion:fh.check(yp(),Ne(1))}),pye=p({workspaceId:me,after:u($t)}),dye=p({workspaceId:me,count:fh.check(yp(),Tr({minimum:1,maximum:100})),after:u($t),includeOccupied:u(X)}),uye=p({workspaceId:me,...Pt.fields}),lye=p({workspaceId:me,...Pt.fields}),fye=p({workspaceId:me,from:$t.annotate({description:"Inclusive ISO start instant."}),to:$t.annotate({description:"Inclusive ISO end instant, after from and within 90 days."}),accountId:u(Y),queueId:u(tr),...Pt.fields}),mye=p({queueId:tr,skipId:Yu}),hye=p({queueId:tr,blackoutId:jh});var J6=G(["queued","running","succeeded","partial","failed","cancelled"]),Y6=G(["active","backoff","paused","inaccessible","deleted","complete"]),AF=a.check(N()),vF=a.check(N()),oE=p({id:AF,workspaceId:me,cursorId:vF,domain:a,provider:a,subjectKind:a,subjectId:a.check(N()),scope:a,status:J6,startedAt:a,finishedAt:M(a),requestCount:F,pageCount:F,errorKind:M(a),providerStatus:M(F),retryAfterSeconds:M(F),detail:M(Yt(a,J)),createdAt:a}).annotate({identifier:"SyncRun"}),Sye=p({cursorId:M(vF),state:Y6,lastSuccessAt:M(a),nextDueAt:M(a),syncRunId:M(AF)}).annotate({identifier:"SyncResource"});var Us="/api/v1/inbox",Tye=`${Us}/conversations`,Oye=`${Us}/comments`,Pye=`${Us}/mentions`,Z6=`${Us}/reviews`,Rye=`${Z6}/:reviewId`,_ye=`${Us}/unread-count`,Uye=`${Us}/capabilities`,Dye=`${Us}/sync`,Lye=`${Us}/attachments`,X6=G(["conversation","message","comment_thread","comment","mention"]),CF=G(["inbox","message_request","spam","other"]),sE=G(["active","archived"]),aE=G(["inbound","outbound"]),e8=G(["received","pending","sending","sent","delivered","failed","unresolved","deleted"]),cE=G(["text","media","template","interactive","system","unknown"]),t8=G(["post","comment","story","other"]),r8=G(["image","video","audio","file","unknown"]),n8=G(["pending","succeeded","failed","unresolved"]),o8=G(["list","read","send","reply","edit","delete","hide","unhide","like","unlike"]),i8=G(["webhook","polling","webhook_with_reconciliation"]),Zu=p({externalId:a,name:M(a),handle:M(a)}).annotate({identifier:"InboxParticipant"}),pE=G(["none","24_hours","x_dm_30_days"]),TF=p({open:X,policy:pE,endsAt:M(a)}).annotate({identifier:"InboxReplyWindow"}),s8=G(["fresh","stale","pending","failed"]),dE=p({status:s8,observedAt:M(a),nextDueAt:M(a),syncRunId:M(a)}).annotate({identifier:"InboxFreshness"}),a8=p({id:bI,messageId:eo,kind:r8,mimeType:M(a),sizeBytes:M(F),width:M(F),height:M(F),durationSeconds:M(dr),url:a.annotate({description:"Workspace-scoped PubNio attachment URL. It never contains a provider URL or token."}),createdAt:a}).annotate({identifier:"InboxAttachment"}),uE=p({id:eo,conversationId:Cn,accountId:Y,provider:ze,direction:aE,state:e8,kind:cE,text:M(a),sender:Zu,replyToMessageId:M(eo),attachments:L(a8),actionId:M(Ui),providerCreatedAt:a,providerUpdatedAt:M(a),readAt:M(a),deletedAt:M(a),createdAt:a}).annotate({identifier:"InboxMessage"}),zh=p({id:Cn,workspaceId:me,accountId:Y,provider:ze,participant:Zu,folder:CF,status:sE,unreadCount:F,lastMessageAt:M(a),lastInboundAt:M(a),lastOutboundAt:M(a),lastMessagePreview:M(a),providerUrl:M(a),lastReadAt:M(a),archivedAt:M(a),replyWindow:TF,freshness:dE,createdAt:a}).annotate({identifier:"InboxConversation"}),Qh=p({id:xp,threadId:gp,accountId:Y,provider:ze,parentCommentId:M(xp),author:Zu,text:M(a),likeCount:F,replyCount:F,likedByAccount:X,hidden:X,canReply:X,canHide:X,canLike:X,canDelete:X,permalink:M(a),actionId:M(Ui),providerCreatedAt:a,providerUpdatedAt:M(a),deletedAt:M(a),createdAt:a}).annotate({identifier:"InboxComment"}),OF=p({id:gp,workspaceId:me,accountId:Y,provider:ze,providerPostId:a,postId:M(a.check(N())),permalink:M(a),caption:M(a),commentCount:F,unreadCount:F,lastCommentAt:M(a),lastReadAt:M(a),freshness:dE,createdAt:a}).annotate({identifier:"InboxCommentThread"}),c8=p({id:Sp,workspaceId:me,accountId:Y,provider:ze,kind:t8,author:Zu,text:M(a),permalink:M(a),parentExternalId:M(a),canReply:X,freshness:dE,providerCreatedAt:a,deletedAt:M(a),createdAt:a}).annotate({identifier:"InboxMention"}),p8=G(["positive","negative"]),lE=p({id:kh,workspaceId:me,accountId:Y,provider:ze,locationExternalId:M(a),author:Zu,rating:M(F.check(Tr({minimum:1,maximum:5}))),recommendation:M(p8),text:M(a),permalink:M(a),providerCreatedAt:a,providerUpdatedAt:M(a),repliedAt:M(a),replyText:M(a),canReply:X,deletedAt:M(a),createdAt:a}).annotate({identifier:"InboxReview"}),PF=p({data:L(zh),...Ve}).annotate({identifier:"InboxConversationList"}),RF=p({data:L(uE),...Ve}).annotate({identifier:"InboxMessageList"}),_F=p({data:L(OF),...Ve}).annotate({identifier:"InboxCommentThreadList"}),UF=p({thread:OF,data:L(Qh),...Ve}).annotate({identifier:"InboxCommentThreadDetail"}),DF=p({data:L(c8),...Ve}).annotate({identifier:"InboxMentionList"}),LF=p({data:L(lE),...Ve}).annotate({identifier:"InboxReviewList"}),MF=p({unreadCount:F}).annotate({identifier:"InboxUnreadCount"}),d8=G(["provider_subscription_limit","missing_scopes","webhook_invalid","subscription_pending","plan_required","insufficient_credit","spend_cap_reached"]),fE=p({reason:d8,action:G(["contact_pubnio","reconnect_account","wait_for_repair","upgrade_plan","add_credit","raise_spend_cap"])}),u8=p({from:a,to:a,action:v("review_on_x")}),iE=p({resource:X6,supported:X,operations:L(o8),attachments:X,quickReplies:X,buttons:X,readReceipts:X,moderation:X,syncMode:i8,backfillDays:F,missingScopes:L(a),missingTasks:L(a),unavailable:M(fE)}).annotate({identifier:"InboxChannelCapability"}),l8=p({accountId:Y,profileId:a.check(N()),provider:ze,accountKind:br,enabled:X,publishingReadiness:Li,accountCapabilities:L(Mi),messaging:iE,comments:iE,mentions:iE,replyWindow:TF,lastSyncError:M(a),deliveryGap:M(u8),checkedAt:a}).annotate({identifier:"InboxAccountCapabilities"}),FF=p({accounts:L(l8)}).annotate({identifier:"InboxCapabilities"}),Mye=p({workspaceId:me,accountId:u(Y)}),Fye=p({workspaceId:me,conversationId:Cn}),Nye=p({workspaceId:me,threadId:gp}),Bye=p({workspaceId:me,commentId:xp}),Kye=p({workspaceId:me,mentionId:Sp}),qye=p({workspaceId:me,attachmentId:bI}),$ye=p({workspaceId:me,accountId:u(Y),provider:u(ze),status:u(sE),folder:u(CF),unread:u(X),search:u(a.check(ae(200))),...Pt.fields}),Wye=p({workspaceId:me,order:u(G(["oldest","newest"])),...Pt.fields}),Gye=p({workspaceId:me,accountId:u(Y),postId:u(a.check(N())),providerPostId:u(a),unread:u(X),...Pt.fields}),jye=p({workspaceId:me,...Pt.fields}),zye=p({workspaceId:me,accountId:u(Y),provider:u(ze),...Pt.fields}),Qye=p({workspaceId:me,accountId:u(Y),includeDeleted:u(X),...Pt.fields}),Hye=p({status:u(sE),read:u(X)}).check(Ft(({status:e,read:t})=>e!==void 0||t!==void 0||"Provide status or read.")),mE=Yr.check(we(1),ae(1e4)),Vye=p({text:mE}).annotate({identifier:"SendInboxMessage"}),Jye=p({text:mE}).annotate({identifier:"ReplyInboxComment"}),Yye=p({text:mE}).annotate({identifier:"ReplyInboxReview"}),Zye=p({hidden:u(X),liked:u(X)}).check(Ft(({hidden:e,liked:t})=>e!==void 0!==(t!==void 0)||"Provide exactly one of hidden or liked for one provider call.")),Xye=p({"idempotency-key":sn}),NF=p({deleted:v(!0),actionId:Ui}).annotate({identifier:"InboxDeleted"}),BF=p({mentionId:Sp,actionId:Ui,status:n8,providerResultId:M(a)}).annotate({identifier:"InboxMentionReply"}),ege=p({workspaceId:me,accountId:u(Y)}),KF=p({syncRunId:a.check(N()),status:oE.fields.status}).annotate({identifier:"InboxSyncAccepted"}),qF=p({syncRun:oE,counts:p({conversations:F,messages:F,commentThreads:F,comments:F,mentions:F})}).annotate({identifier:"InboxSyncStatus"}),tge=p({workspaceId:me,syncRunId:a.check(N())});var Xu=G(["post","comment"]);var f8=Yr.check(we(1)),cge=p({accountId:u(Y).annotate({description:"Account that comments; derived when unambiguous."}),provider:u(Tn),target:a.check(we(1),ae(2048)).annotate({description:"Provider ID or permalink."}),targetKind:u(Xu),text:f8.annotate({description:"Max 8000 characters."})}).annotate({identifier:"CreateComment"}),pge=p({actionId:Ui,idempotencyKey:sn,commentId:a.check(we(1)),target:a,targetId:a.check(we(1)),targetKind:Xu,accountId:Y,provider:Tn,status:v("posted"),permalink:u(a),replayed:X}).annotate({identifier:"CommentCreated"});var m8=["meta_ads","google_ads","reddit_ads","pinterest_ads","tiktok_ads","linkedin_ads","snapchat_ads","amazon_ads","openai_ads"],Bt=G(m8);var h8=G(["available","selected"]),hE=G(["active","disabled","pending","closed","unknown"]),y8=p({provider:Bt,kind:v("ad_account"),externalId:a,currency:no,timezone:a,status:hE,businessId:u(a),managerId:u(a),loginCustomerId:u(a),region:u(wh)}).annotate({identifier:"AdAccountDetails"}),g8=p({configured:X,killSwitchActive:X,monthlyCap:M(At),dailyCap:M(At),maxCampaignDailyBudget:M(At),maxCampaignLifetimeBudget:M(At),revision:F.check(Ne(0))}).annotate({identifier:"AdAccountPolicy"}),Co=p({code:a,message:a,field:u(a),providerCode:u(a),missingScopes:u(L(a)),retryable:X,providerMessage:u(a)}).annotate({identifier:"AdIssue"}),Ds=G(["draft","paused","activating","active","pending_review","rejected","completed","archived","unknown"]),Ls=p({amountMinor:F.check(Ne(0)),currency:no,kind:G(["daily","lifetime"])}).annotate({identifier:"AdBudget"}),Vh=p({accountId:Y,currency:no,configured:X,monthlyCap:M(At),dailyCap:M(At),maxCampaignDailyBudget:M(At),maxCampaignLifetimeBudget:M(At),killSwitchActive:X,killSwitchAt:M(a),killSwitchReason:M(a),revision:F.check(Ne(0)),updatedAt:a}).annotate({identifier:"AdSpendPolicy"}),Hh=M(At),Ige=p({expectedRevision:F.check(Ne(0)),monthlyCap:Hh,dailyCap:Hh,maxCampaignDailyBudget:Hh,maxCampaignLifetimeBudget:Hh}).annotate({identifier:"AdSpendPolicyUpdate"}),Ege=p({active:X,reason:u(a.check(ae(500)))}).annotate({identifier:"AdKillSwitchInput"}),$F=p({policy:Vh,changed:X,paused:p({campaigns:F.check(Ne(0)),adGroups:F.check(Ne(0)),ads:F.check(Ne(0))}),nextAction:a}).annotate({identifier:"AdKillSwitchResult"}),Jh=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"]),tl=G(["queued","preflight","creating","recording","reviewing","activating","succeeded","partial","failed","unresolved","cancelled"]),x8=G(["queued","preflight","create","record","review","activate","finish"]),fn=p({id:ro,accountId:Y,kind:Jh,status:tl,step:x8,input:Yt(a,J),result:M(Yt(a,J)),issues:L(Co),attempts:F.check(Ne(0)),canRetry:X,nextAction:a,createdAt:a,updatedAt:a,startedAt:M(a),completedAt:M(a)}).annotate({identifier:"AdOperation"}),kge=p({id:dL,accountId:Y,idempotencyKey:a,intentHash:a,requestedByType:G(["user","api_key"]),requestedByUserId:M(vs),requestedByApiKeyId:M(ja),operationId:M(ro),createdAt:a}).annotate({identifier:"AdRequest"}),wge=p({id:pL,accountId:Y,provider:Bt,postId:Nt,targetId:ur,actorAccountId:Y,creativeId:M(bp),campaignId:M(to),providerPostId:a,permalink:M(a),sourceHash:a,status:Ds,revision:F.check(Ne(1)),operationId:M(ro),createdAt:a,updatedAt:a}).annotate({identifier:"AdBoost"}),Age=p({expectedRevision:F.check(ti(0)),confirmation:v("activate_spend")}).annotate({identifier:"AdCampaignActivationInput"}),vge=p({expectedRevision:F.check(ti(0))}).annotate({identifier:"AdCampaignPauseInput"}),Cge=p({expectedRevision:F.check(ti(0))}).annotate({identifier:"AdCampaignArchiveInput"}),Tge=p({status:G(["active","paused","archived"]),expectedRevision:F.check(ti(0))}).annotate({identifier:"AdEntityStatusUpdate"}),Oge=p({budget:Ls,expectedRevision:F.check(ti(0))}).annotate({identifier:"AdBudgetUpdateInput"}),S8=p({headline:u(a.check(ae(255))),body:u(a.check(ae(2000))),callToAction:u(a.check(ae(64))),destinationUrl:u(a.check(ae(2048))),providerSettings:u(Yt(a,J))}).annotate({identifier:"AdAttachAdCreative"}),Pge=p({name:a.check(we(1),ae(255)),budget:u(Ls),targeting:u(Yt(a,J)),providerSettings:u(Yt(a,J))}).annotate({identifier:"AdAdGroupCreateInput"}),Rge=p({actorAccountId:Y,mediaId:a.check(N()),headline:u(a.check(ae(255))),body:u(a.check(ae(2000))),callToAction:u(a.check(ae(64))),destinationUrl:a.check(ae(2048)),providerSettings:u(Yt(a,J))}).annotate({identifier:"AdCreativeCreateInput"}),_ge=p({name:u(a.check(we(1),ae(255)))}).annotate({identifier:"AdCampaignDuplicateInput"}),Uge=p({name:a.check(we(1),ae(255)),creativeId:u(bp),creative:u(S8),providerSettings:u(Yt(a,J))}).annotate({identifier:"AdAttachAdInput"}),Dge=p({"idempotency-key":sn}),b8=p({id:Y,name:a,provider:Bt,accountKind:v("ad_account"),available:X,selected:X,details:y8,readiness:Li,capabilities:L(Mi),policy:g8,issues:L(Co),createdAt:a,updatedAt:a}).annotate({identifier:"AdAccount"}),WF=p({data:L(b8),...Ve}).annotate({identifier:"AdAccountList"}),Lge=p({workspaceId:me,state:u(h8),...Pt.fields}),Mge=p({workspaceId:me,provider:Bt,accountId:u(Y)}),GF=p({attemptId:a.check(N()),provider:Bt,url:a,status:v("pending")}).annotate({identifier:"AdConnectLaunch"}),Fge=p({workspaceId:me,provider:v("openai_ads"),apiKey:a.check(we(1),ae(2048)),accountId:u(Y),profileId:u(Ot)}).annotate({identifier:"AdApiKeyConnectInput"}),jF=p({provider:v("openai_ads"),accountId:Y,status:v("connected")}).annotate({identifier:"AdApiKeyConnectResult"}),Nge=p({workspaceId:me,accountId:Y}),zF=p({accountId:Y,selected:v(!0),campaignSyncQueued:X,insightSyncQueued:X}).annotate({identifier:"AdAccountSelection"}),QF=p({accountId:Y,disconnected:v(!0),historyRetained:v(!0)}).annotate({identifier:"AdAccountDisconnected"}),HF=G(["awareness","traffic","engagement","leads","sales","app_promotion","video_views","reach","conversions","unknown"]),I8=G(["provider","pubnio"]),VF=a,el=Yt(a,J),rl=p({startAt:M($t),endAt:M($t),timezone:a}).annotate({identifier:"AdSchedule"}),JF=p({valid:X,accountId:Y,provider:Bt,actorAccountId:M(Y),currency:no,budget:M(Ls),schedule:M(rl),killSwitchActive:X,issues:L(Co),nextAction:a}).annotate({identifier:"AdValidation"}),E8=p({postId:Nt,postTargetId:u(ur),actorAccountId:u(Y),budget:Ls,schedule:u(rl),targeting:u(Yt(a,J))}).annotate({identifier:"AdBoostDraft"}),Bge=p({workspaceId:me,accountId:Y,...E8.fields}).annotate({identifier:"AdBoostInput"}),k8=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"]),w8=p({budgetOwner:G(["campaign","ad_group","shared"]),maxAdGroups:u(F.check(Ne(1))),budgetUnit:G(["minor","micros"]),hierarchy:L(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"}),A8=p({accountId:Y,actorAccountId:u(Y),budget:u(Ls),schedule:u(rl),providerSettings:u(Yt(a,J))}).annotate({identifier:"AdCampaignPlanTarget"}),v8=p({headline:u(a.check(ae(255))),body:u(a.check(ae(2000))),callToAction:u(a.check(ae(64))),destinationUrl:u(a.check(ae(2048))),media:u(_s),providerSettings:u(Yt(a,J))}).annotate({identifier:"AdCampaignPlanCreative"}),C8=p({name:a.check(we(1),ae(255)),creative:v8,providerSettings:u(Yt(a,J))}).annotate({identifier:"AdCampaignPlanAd"}),T8=p({name:a.check(we(1),ae(255)),budget:u(Ls),targeting:u(Yt(a,J)),providerSettings:u(Yt(a,J)),ads:L(C8).check(we(1),ae(50))}).annotate({identifier:"AdCampaignPlanAdGroup"}),Kge=p({name:a.check(we(1),ae(255)),objective:HF,budget:u(Ls),schedule:u(rl),targets:L(A8).check(we(1),ae(50)),adGroups:L(T8).check(we(1),ae(50)),providerSettings:u(Yt(a,J))}).annotate({identifier:"AdCampaignPlan"}),O8=p({accountId:Y,provider:u(Bt),name:u(a),currency:u(no),budget:u(M(Ls)),profile:u(w8),capabilities:u(L(k8)),issues:L(Co)}).annotate({identifier:"AdCampaignPlanTargetValidation"}),YF=p({valid:X,issues:L(Co),targets:L(O8)}).annotate({identifier:"AdCampaignPlanValidation"}),yE=G(["queued","creating","partial","succeeded","failed","unresolved"]),ZF=p({accountId:Y,provider:Bt,operationId:ro,status:tl}).annotate({identifier:"AdCampaignPlanTargetAccepted"}),XF=p({planId:a.check(N()),status:yE,targets:L(ZF)}).annotate({identifier:"AdCampaignPlanAccepted"}),P8=p({planId:a.check(N()),status:yE,createdAt:a,targets:L(ZF)}).annotate({identifier:"AdCampaignPlanListRow"}),eN=p({data:L(P8),...Ve}).annotate({identifier:"AdCampaignPlanList"}),R8=p({accountId:Y,provider:Bt,operationId:ro,campaignId:M(to),status:tl,issues:L(Co)}).annotate({identifier:"AdCampaignPlanTargetDetail"}),tN=p({planId:a.check(N()),status:yE,createdAt:a,targets:L(R8),issues:L(Co)}).annotate({identifier:"AdCampaignPlanDetail"}),rN=p({id:to,accountId:Y,provider:Bt,externalId:a,name:a,objective:HF,status:Ds,providerStatus:M(a),managed:I8,revision:F.check(Ne(1)),budget:M(At),bidStrategy:M(VF),schedule:rl,providerSettings:el,syncedAt:a}).annotate({identifier:"AdCampaign"}),nN=p({id:Cs,campaignId:to,accountId:Y,provider:Bt,kind:a,externalId:a,name:a,status:Ds,providerStatus:M(a),revision:F.check(Ne(1)),budget:M(At),bidStrategy:M(VF),targeting:el,providerSettings:el,syncedAt:a}).annotate({identifier:"AdGroup"}),nl=p({id:bp,accountId:Y,provider:Bt,externalId:a,kind:a,actorAccountId:M(Y),mediaId:M(a.check(N())),headline:M(a),body:M(a),callToAction:M(a),destinationUrl:M(a),providerSettings:el,syncedAt:a}).annotate({identifier:"AdCreative"}),gE=G(["campaign","ad_group","ad"]),_8=a,U8=G(["fresh","stale","pending","partial","unavailable"]),Ja=p({status:U8,syncedAt:M(a),nextSyncAt:u(a),retryAfter:u(a)}).annotate({identifier:"AdFreshness"}),qge=p({accountId:u(Y),campaignId:u(to),adGroupId:u(Cs),adId:u(Ts),from:u(a.check(Ge(/^\d{4}-\d{2}-\d{2}$/))),to:u(a.check(Ge(/^\d{4}-\d{2}-\d{2}$/))),level:u(gE),metrics:u(L(_8).check(ae(30))),cursor:Pt.fields.cursor,limit:u(F.check(Ne(1),LD(100)))}).annotate({identifier:"AdInsightQuery"}),D8=p({id:cL,accountId:Y,level:gE,campaignId:M(to),adGroupId:M(Cs),adId:M(Ts),creativeId:M(bp),date:a.check(Ge(/^\d{4}-\d{2}-\d{2}$/)),currency:no,spend:At,impressions:F.check(Ne(0)),clicks:F.check(Ne(0)),conversions:dr.check(Ne(0)),revenue:At,metrics:Yt(a,dr),syncedAt:a}).annotate({identifier:"AdInsightRow"}),L8=p({currency:no,spend:At,impressions:F.check(Ne(0)),clicks:F.check(Ne(0)),conversions:dr.check(Ne(0)),revenue:At,metrics:Yt(a,dr)}).annotate({identifier:"AdInsightTotals"}),xE=p({from:a,to:a,level:gE,totals:L(L8),rowCount:F.check(Ne(0)),freshness:Ja}).annotate({identifier:"AdInsightSummary"}),Yh=p({id:Ts,accountId:Y,campaignId:to,adGroupId:Cs,creativeId:M(bp),provider:Bt,externalId:a,name:a,format:M(a),status:Ds,providerStatus:M(a),revision:F.check(Ne(1)),providerSettings:el,syncedAt:a,creative:u(M(nl)),insights:u(M(xE))}).annotate({identifier:"Ad"}),SE=p({data:L(rN),...Ve,freshness:Ja}).annotate({identifier:"AdCampaignList"}),M8=p({...nN.fields,insights:u(M(xE))}).annotate({identifier:"AdGroupListRow"}),oN=p({data:L(M8),...Ve,freshness:Ja}).annotate({identifier:"AdGroupList"}),iN=p({data:L(Yh),...Ve,freshness:Ja}).annotate({identifier:"AdList"}),sN=p({data:L(nl),...Ve,freshness:Ja}).annotate({identifier:"AdCreativeList"}),bE=p({data:L(D8),summary:xE,...Ve,freshness:Ja}).annotate({identifier:"AdInsightList"}),F8=p({adGroup:nN,ads:L(p({ad:Yh,creative:M(nl)}))}).annotate({identifier:"AdTreeNode"}),N8=p({campaign:rN,adGroups:L(F8)}).annotate({identifier:"AdTreeCampaign"}),aN=p({data:L(N8),...Ve,freshness:Ja}).annotate({identifier:"AdTree"}),cN=p({accountId:Y,queuedScopes:L(G(["campaigns","ads_insights"])),nextDueAt:a,retryAfterSeconds:u(F)}).annotate({identifier:"AdRefreshAccepted"});var IE="2026-12-02",pN=[IE],Zh=G(pN),dN="PubNio-Version";var EE=Yr.check(we(1),ae(100)),kE=a.check(we(1),ae(128)),ol=p({id:Ot,workspaceId:me,name:EE,externalId:M(kE),isDefault:X,archived:X,createdAt:a,updatedAt:a}).annotate({identifier:"WorkspaceProfile"}),uN=p({data:L(ol),...Ve}).annotate({identifier:"ProfileList"}),Hge=p({workspaceId:me,includeArchived:u(X),...Pt.fields}),Vge=p({name:EE,externalId:u(kE)}),Jge=p({name:u(EE),externalId:u(M(kE))}).check(Ft(({name:e,externalId:t})=>e!==void 0||t!==void 0||"Provide a name or external ID.")),Yge=p({profileId:Ot}),lN=p({archived:v(!0)});var nxe=G(["publishing","inbox","analytics","ads","scheduling","accounts","billing"]),Xh=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","billing.subscription.duplicate_refunded"]);var fN=p({id:a.check(N()),type:Xh,version:v(1),timestamp:$t.check(Ge(/Z$/)),workspaceId:me,profileId:u(Ot)}).annotate({identifier:"WorkspaceEventEnvelope"});var wE=a.check(N()),B8=a.check(N()),mN=Xh,gN=G([...Xh.literals,"webhook.test"]),xxe=p({eventTypes:L(gN)}).annotate({identifier:"WebhookEventTypes"}),De=fN.fields,il={postId:Nt,targetId:ur,attemptId:Zt,accountId:Y,provider:lr,placement:Pr,revision:Ao},hN={providerRef:qu,url:u(a)},ey={canRetry:X,canReconcile:X,nextAction:a},K8=G(["published","provider_draft","failed","unresolved","cancelled"]),q8={targetId:ur,accountId:Y,provider:lr,placement:Pr,status:K8,url:u(a),issue:u($u)},$8={targetId:ur,accountId:Y,scheduledAt:M(a)},ty={postId:Nt,revision:Ao,targets:L(p(q8))},AE=G(["live","backfill"]),yN={messageId:eo,conversationId:Cn,accountId:Y,provider:lr,direction:aE,kind:cE,providerCreatedAt:a,freshness:AE},W8={threadId:gp,commentId:xp,accountId:Y,provider:lr,providerCreatedAt:a,freshness:AE},G8={mentionId:Sp,accountId:Y,provider:lr,providerCreatedAt:a,freshness:AE},sl={reviewId:kh,accountId:Y,provider:ze,locationId:u(a)},al={accountId:Y,provider:ze,accountKind:br},Sxe=st([p({...De,type:v("post.delivery.published"),data:p({...il,status:v("published"),...hN})}),p({...De,type:v("post.delivery.provider_draft"),data:p({...il,status:v("provider_draft"),...hN})}),p({...De,type:v("post.delivery.failed"),data:p({...il,status:v("failed"),issue:$u,canRetry:ey.canRetry,nextAction:ey.nextAction,providerRef:u(qu),url:u(a)})}),p({...De,type:v("post.delivery.unresolved"),data:p({...il,status:v("unresolved"),issue:$u,canReconcile:ey.canReconcile,nextAction:ey.nextAction,providerRef:u(qu),url:u(a)})}),p({...De,type:v("post.delivery.cancelled"),data:p({...il,status:v("cancelled")})}),p({...De,type:v("post.scheduled"),data:p({postId:Nt,revision:Ao,targets:L(p($8))})}),p({...De,type:v("schedule.assignment.changed"),data:p({postId:Nt,targetId:ur,accountId:Y,attemptId:Zt,previousScheduledAt:M(a),scheduledAt:M(a),queueId:M(tr)})}),p({...De,type:v("post.published"),data:p(ty)}),p({...De,type:v("post.partial"),data:p(ty)}),p({...De,type:v("post.failed"),data:p(ty)}),p({...De,type:v("post.cancelled"),data:p(ty)}),p({...De,type:v("inbox.message.received"),data:p(yN)}),p({...De,type:v("inbox.message.sent"),data:p(yN)}),p({...De,type:v("inbox.comment.received"),data:p(W8)}),p({...De,type:v("inbox.review.new"),data:p(sl)}),p({...De,type:v("inbox.review.updated"),data:p(sl)}),p({...De,type:v("inbox.review.deleted"),data:p(sl)}),p({...De,type:v("inbox.review.restored"),data:p(sl)}),p({...De,type:v("inbox.review.replied"),data:p(sl)}),p({...De,type:v("inbox.mention.received"),data:p(G8)}),p({...De,type:v("inbox.message.delivered"),data:p({messageIds:L(eo),conversationId:u(Cn),accountId:Y,provider:lr,deliveredAt:a})}),p({...De,type:v("inbox.message.read"),data:p({messageIds:L(eo),conversationId:u(Cn),accountId:Y,provider:lr,readAt:a})}),p({...De,type:v("inbox.message.edited"),data:p({messageId:eo,conversationId:Cn,accountId:Y,provider:lr})}),p({...De,type:v("inbox.message.deleted"),data:p({messageId:eo,conversationId:Cn,accountId:Y,provider:lr})}),p({...De,type:v("inbox.reaction.received"),data:p({messageId:u(eo),conversationId:u(Cn),accountId:Y,provider:lr,reaction:a,action:G(["add","remove"])})}),p({...De,type:v("inbox.referral.received"),data:p({messageId:u(eo),conversationId:u(Cn),accountId:Y,provider:lr,ref:a,source:a,adId:u(a)})}),p({...De,type:v("inbox.conversation.started"),data:p({conversationId:Cn,accountId:Y,provider:lr,participantExternalId:a})}),p({...De,type:v("analytics.post.synced"),data:p({postId:Nt,accountId:Y,provider:ze})}),p({...De,type:v("analytics.account.synced"),data:p({accountId:Y,provider:ze})}),p({...De,type:v("ads.operation.succeeded"),data:p({operationId:ro,accountId:Y,kind:Jh,status:G(["succeeded","partial"]),nextAction:a})}),p({...De,type:v("ads.operation.failed"),data:p({operationId:ro,accountId:Y,kind:Jh,status:G(["failed","unresolved","cancelled"]),issue:Co,canRetry:X,nextAction:a})}),p({...De,type:G(["ads.campaign.activated","ads.campaign.paused"]),data:p({operationId:ro,accountId:Y,campaignId:to})}),p({...De,type:v("ads.budget.changed"),data:st([p({operationId:ro,accountId:Y,level:v("campaign"),campaignId:to}),p({operationId:ro,accountId:Y,level:v("ad_group"),adGroupId:Cs})])}),p({...De,type:v("ads.kill_switch.activated"),data:p({accountId:Y,revision:F.check(Ne(1)),reason:M(a),pausedCampaigns:F.check(Ne(0)),pausedAdGroups:F.check(Ne(0)),pausedAds:F.check(Ne(0))})}),p({...De,type:v("ads.lead.received"),data:p({accountId:Y,leadId:a,pageId:u(a),formId:u(a),adId:u(a),adGroupId:u(a)})}),p({...De,type:v("ads.campaign.status_changed"),data:p({accountId:Y,campaignId:to,provider:Bt,status:Ds})}),p({...De,type:v("ads.ad_group.status_changed"),data:p({accountId:Y,adGroupId:Cs,provider:Bt,status:Ds})}),p({...De,type:v("ads.ad.status_changed"),data:p({accountId:Y,adId:Ts,provider:Bt,status:Ds})}),p({...De,type:v("ads.ad_account.status_changed"),data:p({accountId:Y,provider:Bt,status:hE})}),p({...De,type:v("ads.ad.review.approved"),data:p({accountId:Y,adId:Ts,provider:Bt})}),p({...De,type:v("ads.ad.review.rejected"),data:p({accountId:Y,adId:Ts,provider:Bt})}),p({...De,type:v("ads.sync.failed"),data:p({accountId:Y,provider:Bt})}),p({...De,type:v("ads.sync.recovered"),data:p({accountId:Y,provider:Bt})}),p({...De,type:v("ads.initial_sync.completed"),data:p({accountId:Y,provider:Bt})}),p({...De,type:v("account.connected"),data:p({...al,reconnected:X})}),p({...De,type:v("account.disconnected"),data:p({...al,reason:G(["disconnected","expired","revoked","deauthorized"])})}),p({...De,type:v("account.permissions_changed"),data:p({...al,missingScopes:L(a),missingTasks:L(a)})}),p({...De,type:v("account.restricted"),data:p({...al,reason:v("publish_failures")})}),p({...De,type:v("account.recovered"),data:p(al)}),p({...De,type:v("billing.subscription.updated"),data:p({plan:Ps,status:Wu,interval:M(Th),periodStart:a,periodEnd:a,cancelAtPeriodEnd:X})}),p({...De,type:v("billing.credit.topped_up"),data:p({amountMicros:F,balanceAfterMicros:F,kind:Rh})}),p({...De,type:v("billing.credit.low"),data:p({balanceMicros:F,thresholdMicros:F})}),p({...De,type:v("billing.spend_cap.reached"),data:p({capMicros:F,periodSpendMicros:F,estimatedMicros:F})}),p({...De,type:v("billing.invoice.payment_failed"),data:p({invoiceId:a,amountDueMinor:F,hostedInvoiceUrl:M(a)})}),p({...De,type:v("billing.subscription.duplicate_refunded"),data:p({subscriptionId:a,amountRefundedMinor:F,currency:a})}),p({...De,type:v("webhook.test"),data:p({endpointId:Bu})})]).annotate({identifier:"WebhookEvent"}),vE=G(["publishing","inbox","analytics","ads","scheduling","accounts","billing"]),CE=Yr.check(we(1),ae(100)),xN=a.check(ae(2048)),j8=u(L(Y)).annotate({description:"Only deliver events for these accounts. Empty or omitted means every account. Duplicates are ignored."}),z8=u(L(vE)).annotate({description:"Drop every event in these families. Empty or omitted means no family is dropped. Duplicates are ignored."}),Q8=u(M(L(Y))).annotate({description:"Only deliver events for these accounts. Omit to keep the current filter; null or an empty array clears it to every account."}),H8=u(M(L(vE))).annotate({description:"Drop every event in these families. Omit to keep the current denylist; null or an empty array clears it."}),TE=L(mN).check(we(1),ae(mN.literals.length),Ft((e)=>new Set(e).size===e.length||"Choose each event type only once.")),V8=p({workspaceId:me,endpointId:Bu}),bxe=p({...V8.fields,deliveryId:wE}),Ixe=p({name:CE,url:xN,eventTypes:TE,enabled:u(X),profileId:u(Ot),accountIds:j8,disabledResourceGroups:z8}),Exe=p({name:u(CE),eventTypes:u(TE),enabled:u(X),profileId:u(M(Ot)),accountIds:Q8,disabledResourceGroups:H8}).check(Ft((e)=>Object.keys(e).length>0||"Provide at least one endpoint change.")),ry=p({id:Bu,workspaceId:me,name:CE,eventTypes:TE,enabled:X,profileId:M(Ot),accountIds:L(Y),disabledResourceGroups:L(vE),apiVersion:Zh,destinationOrigin:a,createdAt:a,updatedAt:a,deletedAt:M(a)}).annotate({identifier:"WebhookEndpoint"}),OE=p({...ry.fields,url:M(xN)}),J8=a.check(Ge(/^whsec_[A-Za-z0-9+/]{43}=$/)),SN=p({endpoint:OE,secret:J8}),bN=p({data:L(ry),...Ve}).annotate({identifier:"WebhookEndpointList"}),IN=p({deleted:v(!0)}),EN=p({deliveryId:wE}),PE=G(["pending","sending","delivered","failed","cancelled"]),Y8=G(["timeout","network","http_status","redirect","destination_rejected","configuration_unavailable","expired","attempts_exhausted"]),ny=p({id:wE,workspaceId:me,endpointId:Bu,eventId:B8,eventType:gN,status:PE,attemptCount:F,createdAt:a,nextAttemptAt:M(a),lastAttemptAt:M(a),lastHttpStatus:M(F),lastError:M(Y8),completedAt:M(a)}).annotate({identifier:"WebhookDelivery"}),kN=p({data:L(ny),...Ve}).annotate({identifier:"WebhookDeliveryList"});var RE="~effect/http/HttpBody";class UE{[RE];constructor(){this[RE]=RE}[cn](){return this.toJSON()}toString(){return it(this,{ignoreToString:!0})}}class wN extends UE{_tag="Empty";toJSON(){return{_id:"effect/HttpBody",_tag:"Empty"}}}var AN=new wN;class _E extends UE{_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??=Z8(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 vN=new TextEncoder,oy=globalThis.Buffer,Z8=oy!==void 0?(e)=>oy.from(e,"utf8"):(e)=>vN.encode(e),CN=(e,t)=>{if(typeof e!=="string")e=e===void 0?"":String(e);if(oy!==void 0)return new _E(void 0,t??"text/plain",oy.byteLength(e,"utf8"),e);let r=vN.encode(e);return new _E(r,t??"text/plain",r.length,e)},TN=(e,t)=>CN(JSON.stringify(e),t??"application/json");var X8=Object.getPrototypeOf(Ba),PN=()=>Object.create(X8);var RN="~effect/http/HttpServerResponse";var t5=(e,t)=>{if(e?.contentType)return e.contentType;else if(e?.headers)return t["content-type"]};var _N=(e,t)=>{let r=t?.headers?YU(t.headers):Ba;return n5({status:t?.status??200,statusText:t?.statusText,headers:r,cookies:t?.cookies,body:TN(e,t5(t,r))})};var r5={...Lr,[RN]:RN,[Eh]:!0,toJSON(){return{_id:"HttpServerResponse",status:this.status,statusText:this.statusText,headers:uo(this.headers),cookies:this.cookies.toJSON(),body:this.body.toJSON()}}},n5=(e,t)=>{let r=Object.create(r5);if(r.status=e.status,r.statusText=e.statusText,r.cookies=e.cookies??HU,r.body=e.body??AN,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===Ba?PN():ZU({...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??Ba;return r};var DN="~effect/http/HttpServerRespondable";var iy="application/problem+json",MN="about:blank",Ya=(e)=>u(e).pipe(lh(()=>Nd)),FN=(e,t)=>UD(j(t))(e).pipe(lh(()=>fS(t))),DE=(e)=>FN(As(e),e),o5=RD(p({type:FN(a,MN),status:Ya(dr),title:Ya(a),detail:Ya(a),instance:Ya(a)}),[Yt(a,J)]);var i5={_tag:"Json",contentType:iy},fe=()=>(e,t,r,n)=>{let o=p({detail:Ya(a),instance:Ya(a),...r,type:As(t.type),status:DE(t.status),title:DE(t.title)}),i=OD(o),s=Lu(e)(o,{description:t.title,httpApiStatus:t.status,"~httpApiEncoding":i5,...n});return Object.assign(s.prototype,{_tag:e,[Eh]:t.status<500,[DN](){return Me(i(this),(c)=>_N(c,{status:t.status,contentType:iy}))}}),Object.defineProperty(s.prototype,"message",{get(){return this.detail??t.title},configurable:!0}),s},s5=p({path:L(st([a,dr])),message:a});class a5 extends fe()("UploadTooLarge",{type:"about:blank",status:413,title:"Content Too Large"}){}class BN extends fe()("AuthenticationRequired",{type:"urn:pubnio:problem:authentication-required",status:401,title:"Unauthorized"},{docUrl:u(a)}){}class KN extends fe()("Forbidden",{type:"urn:pubnio:problem:forbidden",status:403,title:"Forbidden"},{requiredScope:u(Gu),docUrl:u(a)}){}class qN extends fe()("HumanActorRequired",{type:"urn:pubnio:problem:human-actor-required",status:403,title:"Human actor required"},{code:v("human_actor_required"),nextAction:a}){}class $N extends fe()("OwnerRequired",{type:"urn:pubnio:problem:owner-required",status:403,title:"Owner permission required"},{code:v("owner_required"),nextAction:a}){}class WN extends fe()("SeatLimitReached",{type:"urn:pubnio:problem:seat-limit-reached",status:402,title:"Seat limit reached"},{code:v("seat_limit_reached"),seatsUsed:F,seatsLimit:F,nextAction:a}){}class GN extends fe()("PlanRequired",{type:"urn:pubnio:problem:plan-required",status:402,title:"Plan upgrade required"},{code:v("plan_required"),entitlement:G(["adsInsights","adsWrite","analyticsHistory"]),currentPlan:Ps,minimumPlan:Ps,fundingUrl:a,canManageBilling:X,nextAction:a,param:u(a),earliestDate:u(a)}){}class jN extends fe()("AlreadyMember",{type:"urn:pubnio:problem:already-member",status:409,title:"Already a workspace member"},{code:v("already_member"),nextAction:a}){}class zN extends fe()("InviteAlreadyPending",{type:"urn:pubnio:problem:invite-already-pending",status:409,title:"Invite already pending"},{code:v("invite_already_pending"),nextAction:a}){}class QN extends fe()("LastOwnerRequired",{type:"urn:pubnio:problem:last-owner-required",status:409,title:"Last owner required"},{code:v("last_owner_required"),nextAction:a}){}class HN extends fe()("InviteExpired",{type:"urn:pubnio:problem:invite-expired",status:410,title:"Invite expired"},{code:v("invite_expired"),nextAction:a}){}class VN extends fe()("InviteEmailMismatch",{type:"urn:pubnio:problem:invite-email-mismatch",status:403,title:"Invite email mismatch"},{code:v("invite_email_mismatch"),nextAction:a}){}class JN extends fe()("NotFound",{type:"urn:pubnio:problem:not-found",status:404,title:"Not Found"}){}class YN extends fe()("Conflict",{type:"urn:pubnio:problem:conflict",status:409,title:"Conflict"}){}class ZN extends fe()("Unavailable",{type:"urn:pubnio:problem:unavailable",status:503,title:"Service Unavailable"}){}class XN extends fe()("UnsupportedApiVersion",{type:"urn:pubnio:problem:unsupported-api-version",status:400,title:"Unsupported API version"},{code:v("unsupported_api_version"),param:a,supportedVersions:L(Zh),nextAction:a}){}class c5 extends fe()("InvalidCursor",{type:"urn:pubnio:problem:invalid-cursor",status:400,title:"Invalid cursor"},{code:u(v("invalid_cursor")),nextAction:u(a)}){}var cl=p({accountId:Y,name:a}).annotate({identifier:"ProblemCandidate"});class eB extends fe()("InvalidPublication",{type:"urn:pubnio:problem:invalid-publication",status:422,title:"Invalid publication"},{issues:L(wo),candidates:u(L(cl)),code:u(v("invalid_publication")),nextAction:u(a)}){}var tB="x-request-id",rB=s5;class nB extends fe()("InternalFailure",{type:"urn:pubnio:problem:internal-error",status:500,title:"Internal Server Error"},{requestId:a.check(N())}){}class oB extends fe()("AttemptChanged",{type:"urn:pubnio:problem:attempt-changed",status:409,title:"Delivery attempt changed"},{currentAttemptId:Zt}){}class iB extends fe()("IdempotencyConflict",{type:"urn:pubnio:problem:idempotency-conflict",status:409,title:"Idempotency key already used"},{code:u(v("idempotency_conflict")),nextAction:u(a)}){}class sB extends fe()("AccountAmbiguous",{type:"urn:pubnio:problem:account-ambiguous",status:422,title:"Account ambiguous"},{code:v("account_ambiguous"),provider:ze,param:a,candidates:L(cl),nextAction:a}){}class aB extends fe()("ProviderMismatch",{type:"urn:pubnio:problem:provider-mismatch",status:422,title:"Provider mismatch"},{code:v("provider_mismatch"),provider:ze,expectedProvider:ze,param:a,nextAction:a}){}class cB extends fe()("PublishAccountNotFound",{type:"urn:pubnio:problem:publish-account-not-found",status:422,title:"Publishing account not found"},{code:v("account_not_found"),provider:u(ze),accountId:u(Y),param:a,candidates:u(L(cl)),nextAction:a}){}class pB extends fe()("MediaUploadConflict",{type:"urn:pubnio:problem:media-upload-conflict",status:409,title:"Media upload conflict"},{reason:cM}){}class dB extends fe()("DestinationAlreadySubmitted",{type:"urn:pubnio:problem:destination-already-submitted",status:409,title:"Destination already submitted"}){}class uB extends fe()("DeliveryNotRetryable",{type:"urn:pubnio:problem:delivery-not-retryable",status:409,title:"Delivery cannot be retried"}){}class lB extends fe()("DeliveryNotReconcilable",{type:"urn:pubnio:problem:delivery-not-reconcilable",status:409,title:"Delivery cannot be reconciled"}){}class fB extends fe()("DeliveryScheduleLocked",{type:"urn:pubnio:problem:delivery-schedule-locked",status:409,title:"Delivery schedule cannot change"}){}class mB extends fe()("PostRevisionConflict",{type:"urn:pubnio:problem:post-revision-conflict",status:409,title:"Post revision changed"},{currentRevision:Ao}){}class hB extends fe()("QueueNotFound",{type:"urn:pubnio:problem:queue-not-found",status:404,title:"Queue not found"}){}class yB extends fe()("QueueAlreadyExists",{type:"urn:pubnio:problem:queue-already-exists",status:409,title:"Queue already exists"}){}class gB extends fe()("QueueDefaultRequired",{type:"urn:pubnio:problem:queue-default-required",status:409,title:"Queue default required"},{code:v("queue_default_required"),accountId:Y,nextAction:a}){}class xB extends fe()("QueueVersionConflict",{type:"urn:pubnio:problem:queue-version-conflict",status:409,title:"Queue version changed"},{currentVersion:F.check(Ne(1))}){}class SB extends fe()("QueueUnavailable",{type:"urn:pubnio:problem:queue-unavailable",status:409,title:"Queue unavailable"},{reason:fF}){}class bB extends fe()("QueueCapacityReached",{type:"urn:pubnio:problem:queue-capacity-reached",status:409,title:"Queue capacity reached"},{reason:mF}){}class IB extends fe()("QueueNoSlotAvailable",{type:"urn:pubnio:problem:queue-no-slot-available",status:409,title:"No queue slot available"},{horizonEndsAt:a}){}class EB extends fe()("QueueSlotConflict",{type:"urn:pubnio:problem:queue-slot-conflict",status:409,title:"Queue slot conflict"},{scheduledAt:a,suggestedSlots:L(a)}){}class kB extends fe()("InvalidTimezone",{type:"urn:pubnio:problem:invalid-timezone",status:422,title:"Invalid time zone"},{code:v("invalid_timezone"),timezone:a,nextAction:a}){}class wB extends fe()("InvalidQueue",{type:"urn:pubnio:problem:invalid-queue",status:422,title:"Invalid queue"},{issues:L(wF)}){}class AB extends fe()("ScheduleRangeTooWide",{type:"urn:pubnio:problem:schedule-range-too-wide",status:422,title:"Schedule range too wide"},{maxDays:F}){}class vB extends fe()("WebhookTestRateLimited",{type:"urn:pubnio:problem:webhook-test-rate-limited",status:429,title:"Webhook test rate limited"}){}class CB extends fe()("WebhookDeliveryNotReplayable",{type:"urn:pubnio:problem:webhook-delivery-not-replayable",status:409,title:"Webhook delivery not replayable"},{code:v("webhook_delivery_not_replayable"),deliveryStatus:PE,nextAction:a}){}class TB extends fe()("ProviderPermissionRequired",{type:"urn:pubnio:problem:provider-permission-required",status:403,title:"Provider permission required"},{provider:ze,missingScopes:L(a),missingRoles:L(a),reason:u(a),reconnectRequired:u(X)}){}class OB extends fe()("ProviderReconnectRequired",{type:"urn:pubnio:problem:provider-reconnect-required",status:409,title:"Provider reconnect required"},{provider:ze,missingScopes:L(a),reason:u(a)}){}class PB extends fe()("ProviderRateLimited",{type:"urn:pubnio:problem:provider-rate-limited",status:429,title:"Provider rate limited"},{provider:ze,retryAfterSeconds:u(F)}){}class RB extends fe()("ProviderUnavailable",{type:"urn:pubnio:problem:provider-unavailable",status:503,title:"Provider unavailable"},{provider:ze,retryAfterSeconds:u(F)}){}class _B extends fe()("CapabilityUnsupported",{type:"urn:pubnio:problem:capability-unsupported",status:422,title:"Capability unsupported"},{capability:Di,provider:ze,accountKind:br}){}class UB extends fe()("AnalyticsRangeInvalid",{type:"urn:pubnio:problem:analytics-range-invalid",status:400,title:"Analytics range invalid"},{reason:G(["invalid_timezone","invalid_range","range_too_wide"])}){}class DB extends fe()("AnalyticsMetricUnsupported",{type:"urn:pubnio:problem:analytics-metric-unsupported",status:400,title:"Analytics metric unsupported"},{metrics:L(a),maxMetrics:u(F)}){}class LB extends fe()("AnalyticsRefreshConflict",{type:"urn:pubnio:problem:analytics-refresh-conflict",status:409,title:"Analytics refresh conflict"},{reason:G(["not_published","deleted","account_analytics_pending"])}){}class MB extends fe()("CapabilityUnverified",{type:"urn:pubnio:problem:capability-unverified",status:409,title:"Capability unverified"},{capability:Di,provider:ze}){}class FB extends fe()("InboxReplyWindowClosed",{type:"urn:pubnio:problem:inbox-reply-window-closed",status:409,title:"Inbox reply window closed"},{provider:ze,policy:pE,endsAt:M(a)}){}class NB extends fe()("InboxTargetChanged",{type:"urn:pubnio:problem:inbox-target-changed",status:409,title:"Inbox target changed"},{targetId:a,state:G(["deleted","changed","unsupported"])}){}class BB extends fe()("InboxSyncInProgress",{type:"urn:pubnio:problem:inbox-sync-in-progress",status:409,title:"Inbox sync already running"},{syncRunId:a.check(N()),retryAfterSeconds:F}){}class KB extends fe()("InboxUnsupportedContent",{type:"urn:pubnio:problem:inbox-unsupported-content",status:422,title:"Inbox content unsupported"},{kind:G(["image","video","audio","file","text","unknown"]),capability:Di}){}class qB extends fe()("InboxUnavailable",{type:"urn:pubnio:problem:inbox-unavailable",status:409,title:"Inbox unavailable"},fE.fields){}var p5=[qB,FB,NB,BB,KB];class $B extends fe()("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(L(a))}){}class WB extends fe()("AdAccountNotSelected",{type:"urn:pubnio:problem:ad-account-not-selected",status:409,title:"Ad account not selected"},{accountId:a}){}class GB extends fe()("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(F)}){}class jB extends fe()("AdRefreshRateLimited",{type:"urn:pubnio:problem:ad-refresh-rate-limited",status:429,title:"Ad refresh rate limited"},{retryAfterSeconds:F.check(Ne(0))}){}class zB extends fe()("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:F.check(Ne(0)),actualRevision:F.check(Ne(0)),nextAction:a}){}class QB extends fe()("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:At,requested:At,committed:At,nextAction:a}){}class HB extends fe()("AdBudgetBelowMinimum",{type:"urn:pubnio:problem:ad-budget-below-minimum",status:422,title:"Ad budget is below the provider minimum"},{minimum:At,requested:At,nextAction:a}){}class VB extends fe()("AdCurrencyMismatch",{type:"urn:pubnio:problem:ad-currency-mismatch",status:422,title:"Ad currency does not match the account"},{expected:no,actual:no,nextAction:a}){}class JB extends fe()("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 YB extends fe()("AdKillSwitchActive",{type:"urn:pubnio:problem:ad-kill-switch-active",status:409,title:"Ad kill switch is active"},{accountId:Y,activatedAt:M(a),reason:M(a),nextAction:a}){}class ZB extends fe()("AdOperationNotRetryable",{type:"urn:pubnio:problem:ad-operation-not-retryable",status:409,title:"Ad operation is not retryable"},{operationStatus:tl,nextAction:a}){}class XB extends fe()("AdProviderRejected",{type:"urn:pubnio:problem:ad-provider-rejected",status:422,title:"Ad provider rejected the request"},{provider:Bt,code:a,retryable:X,providerCode:u(a),providerMessage:u(a),issues:L(Co),nextAction:a}){}class e1 extends fe()("InvalidAdRequest",{type:"urn:pubnio:problem:invalid-ad-request",status:400,title:"Invalid ad request"},{reason:a,field:u(a),nextAction:a}){}var d5=[TB,OB,PB,RB,_B,MB];class u5 extends fe()("CommentTargetInvalid",{type:"urn:pubnio:problem:comment-target-invalid",status:400,title:"Comment target invalid"},{code:v("comment_target_invalid"),reason:a,targetKind:u(Xu),nextAction:a}){}class l5 extends fe()("CommentRejected",{type:"urn:pubnio:problem:comment-rejected",status:422,title:"Comment rejected"},{code:v("comment_rejected"),provider:ze,targetKind:Xu,nextAction:a}){}class f5 extends fe()("CommentUnresolved",{type:"urn:pubnio:problem:comment-unresolved",status:409,title:"Comment outcome unresolved"},{code:v("comment_unresolved"),actionId:Ui,nextAction:a}){}var m5=[eB,oB,iB,dB,uB,lB,fB,mB,sB,aB,cB],h5=[UB,DB,LB],y5=[$B,WB,GB,jB,zB,QB,HB,VB,JB,YB,ZB,XB,e1,GN],g5=[hB,yB,gB,xB,SB,bB,IB,EB,wB,AB],x5=[kB];class t1 extends fe()("InsufficientCredit",{type:"urn:pubnio:problem:insufficient-credit",status:402,title:"Insufficient prepaid credit"},{code:v("insufficient_credit"),balanceMicros:F,requiredMicros:F,fundingUrl:a,canManageBilling:X,nextAction:a}){}class r1 extends fe()("SpendCapReached",{type:"urn:pubnio:problem:spend-cap-reached",status:402,title:"Monthly spend cap reached"},{code:v("spend_cap_reached"),capMicros:F,periodSpendMicros:F,estimatedMicros:F,fundingUrl:a,canManageBilling:X,nextAction:a}){}class n1 extends fe()("BillingInactive",{type:"urn:pubnio:problem:billing-inactive",status:402,title:"Workspace billing is inactive"},{code:v("billing_inactive"),subscriptionStatus:Wu,fundingUrl:a,canManageBilling:X,nextAction:a}){}class o1 extends fe()("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:F,maxMinor:F,nextAction:a}){}class i1 extends fe()("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 s1 extends fe()("BillingRevisionConflict",{type:"urn:pubnio:problem:billing-revision-conflict",status:409,title:"Billing settings changed concurrently"},{code:v("billing_revision_conflict"),expectedVersion:F,actualVersion:F,nextAction:a}){}class a1 extends fe()("SubscriptionAlreadyActive",{type:"urn:pubnio:problem:subscription-already-active",status:409,title:"Subscription is already active"},{code:v("subscription_already_active"),plan:Ps,nextAction:a}){}class c1 extends fe()("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 p1 extends fe()("BillingCustomerMissing",{type:"urn:pubnio:problem:billing-customer-missing",status:409,title:"No billing customer exists yet"},{code:v("billing_customer_missing"),nextAction:a}){}class d1 extends fe()("BillingProviderMismatch",{type:"urn:pubnio:problem:billing-provider-mismatch",status:409,title:"Workspace billing gateway mismatch"},{code:v("billing_provider_mismatch"),workspaceGateway:Oh,requestedGateway:Oh,nextAction:a}){}class u1 extends fe()("BillingNotConfigured",{type:"urn:pubnio:problem:billing-not-configured",status:503,title:"Billing gateway is not configured"},{code:v("billing_not_configured"),nextAction:a}){}class l1 extends fe()("BillingUnavailable",{type:"urn:pubnio:problem:billing-unavailable",status:503,title:"Billing gateway is temporarily unavailable"},{code:v("billing_unavailable"),retryable:X,nextAction:a}){}var S5=[t1,r1,n1],b5=[...S5,o1,i1,s1,a1,c1,p1,d1,u1,l1],I5=[WN,jN,zN,QN,HN,VN],f1=st([BN,KN,qN,$N,JN,YN,ZN,XN,...m5,...b5,...g5,...x5,...I5,...p5,...d5,...h5,...y5,nB,vB,CB,pB]);var Za=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"]),m1=G(["count","milliseconds","ratio"]),h1=G(["sum","unique","latest","weighted","ratio"]),y1=G(["post","account"]),E5=G(["total","day"]),g1=G(["available","pending","unsupported","deprecated","renamed","permission_missing","access_pending","stale","deleted","private","not_applicable"]),k5=Yt(a,dr),sy=p({key:Za,value:M(dr),availability:g1,reason:u(a),replacedBy:u(Za),renamedTo:u(Za),missingScopes:u(L(a)),reconnectRequired:u(X),retryAfter:u(a),observedAt:u(a),total:u(M(dr)),breakdown:u(k5)}).annotate({identifier:"MetricReading"}),w5=p({key:Za,scopes:L(y1),unit:m1,aggregation:h1,definition:a}).annotate({identifier:"MetricDefinition"}),A5=p({key:Za,scope:y1,granularity:E5,unit:m1,aggregation:h1,availability:g1,supported:X,reason:u(a),renamedFrom:u(a),replacedBy:u(Za)}).annotate({identifier:"MetricCapability"}),v5=G(["ready","permission_required","access_pending","reconnect_required","disabled"]),C5=p({provider:ze,accountKinds:L(br),placements:L(Pr),metrics:L(A5),historyDays:F.check(ti(0)),latencySeconds:F.check(Ne(0)),firstAvailableAfterSeconds:F.check(Ne(0)),requiredScopes:L(a),comments:X}).annotate({identifier:"ProviderCapabilities"}),T5=p({accountId:Y,provider:ze,accountKind:br,readiness:v5,capability:Mi,missingScopes:L(a),reconnectRequired:X,accessPending:X}).annotate({identifier:"AnalyticsAccountCapability"}),x1=p({metrics:L(w5),providers:L(C5),accounts:L(T5),checkedAt:a}).annotate({identifier:"AnalyticsCapabilities"}),O5=G(["fresh","stale","pending","partial","unavailable"]),ay=p({status:O5,observedAt:M(a),retryAfter:u(a)}).annotate({identifier:"AnalyticsFreshness"}),S1=p({from:a.check(Ge(/^\d{4}-\d{2}-\d{2}$/)),to:a.check(Ge(/^\d{4}-\d{2}-\d{2}$/)),timezone:v("UTC"),dayBasis:v("provider_utc")}).annotate({identifier:"AnalyticsDateRange"}),LSe=G(["provider_daily","snapshot_delta","provider_lifetime","provider_total"]),b1=p({date:a.check(Ge(/^\d{4}-\d{2}-\d{2}$/)),metrics:L(sy)}).annotate({identifier:"AnalyticsPoint"}),P5=G(["available","pending","unavailable"]),R5=p({targetId:ur,attemptId:M(Zt),accountId:Y,provider:ze,placement:Pr,providerPostId:M(a),publishedAt:M(a),state:P5,metrics:L(sy),series:u(L(b1)),freshness:ay}).annotate({identifier:"PostAnalyticsTarget"}),ME=p({postId:Nt,workspaceId:me,range:S1,targets:L(R5),freshness:ay}).annotate({identifier:"PostAnalytics"}),_5=p({accountId:Y,provider:ze,accountKind:br,profileId:Ot,name:a,metrics:L(sy),freshness:ay}).annotate({identifier:"AnalyticsAccountSummary"}),I1=p({accountId:Y,workspaceId:me,provider:ze,accountKind:br,profileId:Ot,name:a,range:S1,metrics:L(sy),series:u(L(b1)),freshness:ay}).annotate({identifier:"AccountAnalytics"}),E1=p({data:L(_5),...Ve}).annotate({identifier:"AccountAnalyticsList"}),MSe=p({workspaceId:me,postId:u(Nt),targetId:u(ur),metrics:u(L(Za).check(ae(30)))}).check(Ft(({postId:e,targetId:t})=>e!==void 0||t!==void 0||"Send postId or targetId to refresh a published post.")),U5=G(["queued","running","succeeded","failed","paused","deleted","inaccessible"]),FE=p({id:a.check(N()),workspaceId:me,subjectKind:a,subjectId:a.check(N()),status:U5,nextDueAt:M(a),lastSuccessAt:M(a),errorKind:M(a),createdAt:a}).annotate({identifier:"AnalyticsRefresh"});var k1={name:"@pubnio/sdk",version:"0.3.0",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:{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 w1({onRequest:e,onSseError:t,onSseEvent:r,responseTransformer:n,responseValidator:o,sseDefaultRetryDelay:i,sseMaxRetryAttempts:s,sseMaxRetryDelay:c,sseSleepFn:d,url:x,...f}){let g,I=d??((y)=>new Promise((h)=>setTimeout(h,y)));return{stream:async function*(){let y=i??3000,h=0,S=f.signal??new AbortController().signal;while(!0){if(S.aborted)break;h++;let H=f.headers instanceof Headers?f.headers:new Headers(f.headers);if(g!==void 0)H.set("Last-Event-ID",g);try{let te={redirect:"follow",...f,body:f.serializedBody,headers:H,signal:S},E=new Request(x,te);if(e)E=await e(x,te);let le=await(f.fetch??globalThis.fetch)(E);if(!le.ok)throw Error(`SSE failed: ${le.status} ${le.statusText}`);if(!le.body)throw Error("No body in SSE response");let z=le.body.pipeThrough(new TextDecoderStream).getReader(),re="",V=()=>{try{z.cancel()}catch{}};S.addEventListener("abort",V);try{while(!0){let{done:ne,value:ie}=await z.read();if(ne)break;re+=ie,re=re.replace(/\r\n?/g,`
37
+ `);let de=re.split(`
37
38
 
38
- `);ee=ae.pop()??"";for(let se of ae){let le=se.split(`
39
- `),Se=[],ve;for(let _e of le)if(_e.startsWith("data:"))Se.push(_e.replace(/^data:\s*/,""));else if(_e.startsWith("event:"))ve=_e.replace(/^event:\s*/,"");else if(_e.startsWith("id:"))g=_e.replace(/^id:\s*/,"");else if(_e.startsWith("retry:")){let nr=Number.parseInt(_e.replace(/^retry:\s*/,""),10);if(!Number.isNaN(nr))y=nr}let ye,$e=!1;if(Se.length){let _e=Se.join(`
40
- `);try{ye=JSON.parse(_e),$e=!0}catch{ye=_e}}if($e){if(o)await o(ye);if(n)ye=await n(ye)}if(r?.({data:ye,event:ve,id:g,retry:y}),Se.length)yield ye}}}finally{x.removeEventListener("abort",Q),K.releaseLock()}break}catch(X){if(t?.(X),s!==void 0&&h>=s)break;let I=Math.min(y*2**(h-1),c??30000);await w(I)}}}()}}var u6=(e)=>{switch(e){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},l6=(e)=>{switch(e){case"form":return",";case"pipeDelimited":return"|";case"spaceDelimited":return"%20";default:return","}},f6=(e)=>{switch(e){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},Ch=({allowReserved:e,explode:t,name:r,style:n,value:o})=>{if(!t){let c=(e?o:o.map((l)=>encodeURIComponent(l))).join(l6(n));switch(n){case"label":return`.${c}`;case"matrix":return`;${r}=${c}`;case"simple":return c;default:return`${r}=${c}`}}let i=u6(n),s=o.map((c)=>{if(n==="label"||n==="simple")return e?c:encodeURIComponent(c);return sp({allowReserved:e,name:r,value:c})}).join(i);return n==="label"||n==="matrix"?i+s:s},sp=({allowReserved:e,name:t,value:r})=>{if(r===void 0||r===null)return"";if(typeof r==="object")throw Error("Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these.");return`${t}=${e?r:encodeURIComponent(r)}`},Th=({allowReserved:e,explode:t,name:r,style:n,value:o,valueOnly:i})=>{if(o instanceof Date)return i?o.toISOString():`${r}=${o.toISOString()}`;if(n!=="deepObject"&&!t){let l=[];Object.entries(o).forEach(([m,g])=>{l=[...l,m,e?g:encodeURIComponent(g)]});let S=l.join(",");switch(n){case"form":return`${r}=${S}`;case"label":return`.${S}`;case"matrix":return`;${r}=${S}`;default:return S}}let s=f6(n),c=Object.entries(o).map(([l,S])=>sp({allowReserved:e,name:n==="deepObject"?`${r}[${l}]`:l,value:S})).join(s);return n==="label"||n==="matrix"?s+c:c};var m6=/\{[^{}]+\}/g,h6=({path:e,url:t})=>{let r=t,n=t.match(m6);if(n)for(let o of n){let i=!1,s=o.substring(1,o.length-1),c="simple";if(s.endsWith("*"))i=!0,s=s.substring(0,s.length-1);if(s.startsWith("."))s=s.substring(1),c="label";else if(s.startsWith(";"))s=s.substring(1),c="matrix";let l=e[s];if(l===void 0||l===null)continue;if(Array.isArray(l)){r=r.replace(o,Ch({explode:i,name:s,style:c,value:l}));continue}if(typeof l==="object"){r=r.replace(o,Th({explode:i,name:s,style:c,value:l,valueOnly:!0}));continue}if(c==="matrix"){r=r.replace(o,`;${sp({name:s,value:l})}`);continue}let S=encodeURIComponent(c==="label"?`.${l}`:l);r=r.replace(o,S)}return r},FN=({baseUrl:e,path:t,query:r,querySerializer:n,url:o})=>{let i=o.startsWith("/")?o:`/${o}`,s=(e??"")+i;if(t)s=h6({path:t,url:s});let c=r?n(r):"";if(c.startsWith("?"))c=c.substring(1);if(c)s+=`?${c}`;return s};function UI(e){let t=e.body!==void 0;if(t&&e.bodySerializer){if("serializedBody"in e)return e.serializedBody!==void 0&&e.serializedBody!==""?e.serializedBody:null;return e.body!==""?e.body:null}if(t)return e.body;return}var NN=async(e,t)=>{let r=typeof t==="function"?await t(e):t;if(!r)return;if(e.scheme==="bearer")return`Bearer ${r}`;if(e.scheme==="basic")return`Basic ${btoa(r)}`;return r};var BN={bodySerializer:(e)=>JSON.stringify(e,(t,r)=>typeof r==="bigint"?r.toString():r)};var KN=({parameters:e={},...t}={})=>(n)=>{let o=[];if(n&&typeof n==="object")for(let i in n){let s=n[i];if(s===void 0||s===null)continue;let c=e[i]||t;if(Array.isArray(s)){let l=Ch({allowReserved:c.allowReserved,explode:!0,name:i,style:"form",value:s,...c.array});if(l)o.push(l)}else if(typeof s==="object"){let l=Th({allowReserved:c.allowReserved,explode:!0,name:i,style:"deepObject",value:s,...c.object});if(l)o.push(l)}else{let l=sp({allowReserved:c.allowReserved,name:i,value:s});if(l)o.push(l)}}return o.join("&")},qN=(e)=>{if(!e)return"stream";let t=e.split(";")[0]?.trim();if(!t)return;if(t.startsWith("application/json")||t.endsWith("+json"))return"json";if(t==="multipart/form-data")return"formData";if(["application/","audio/","image/","video/"].some((r)=>t.startsWith(r)))return"blob";if(t.startsWith("text/"))return"text";return},y6=(e,t)=>{if(!t)return!1;if(e.headers.has(t)||e.query?.[t]||e.headers.get("Cookie")?.includes(`${t}=`))return!0;return!1};async function $N(e){for(let t of e.security??[]){if(y6(e,t.name))continue;let r=await NN(t,e.auth);if(!r)continue;let n=t.name??"Authorization";switch(t.in){case"query":if(!e.query)e.query={};e.query[n]=r;break;case"cookie":e.headers.append("Cookie",`${n}=${r}`);break;case"header":default:e.headers.set(n,r);break}}}var DI=(e)=>FN({baseUrl:e.baseUrl,path:e.path,query:e.query,querySerializer:typeof e.querySerializer==="function"?e.querySerializer:KN(e.querySerializer),url:e.url}),LI=(e,t)=>{let r={...e,...t};if(r.baseUrl?.endsWith("/"))r.baseUrl=r.baseUrl.substring(0,r.baseUrl.length-1);return r.headers=Ph(e.headers,t.headers),r},g6=(e)=>{let t=[];return e.forEach((r,n)=>{t.push([n,r])}),t},Ph=(...e)=>{let t=new Headers;for(let r of e){if(!r)continue;let n=r instanceof Headers?g6(r):Object.entries(r);for(let[o,i]of n)if(i===null)t.delete(o);else if(Array.isArray(i))for(let s of i)t.append(o,s);else if(i!==void 0)t.set(o,typeof i==="object"?JSON.stringify(i):i)}return t};class Oh{fns=[];clear(){this.fns=[]}eject(e){let t=this.getInterceptorIndex(e);if(this.fns[t])this.fns[t]=null}exists(e){let t=this.getInterceptorIndex(e);return Boolean(this.fns[t])}getInterceptorIndex(e){if(typeof e==="number")return this.fns[e]?e:-1;return this.fns.indexOf(e)}update(e,t){let r=this.getInterceptorIndex(e);if(this.fns[r])return this.fns[r]=t,e;return!1}use(e){return this.fns.push(e),this.fns.length-1}}var WN=()=>({error:new Oh,request:new Oh,response:new Oh}),x6=KN({allowReserved:!1,array:{explode:!0,style:"form"},object:{explode:!0,style:"deepObject"}}),S6={"Content-Type":"application/json"},Du=(e={})=>({...BN,headers:S6,parseAs:"auto",querySerializer:x6,...e});var Lu=(e={})=>{let t=LI(Du(),e),r=()=>({...t}),n=(m)=>(t=LI(t,m),r()),o=WN(),i=async(m)=>{let g={...t,...m,fetch:m.fetch??t.fetch??globalThis.fetch,headers:Ph(t.headers,m.headers),serializedBody:void 0};if(g.security)await $N(g);if(g.requestValidator)await g.requestValidator(g);if(g.body!==void 0&&g.bodySerializer)g.serializedBody=g.bodySerializer(g.body);if(g.body===void 0||g.serializedBody==="")g.headers.delete("Content-Type");let w=g,k=DI(w);return{opts:w,url:k}},s=async(m)=>{let g=m.throwOnError??t.throwOnError,w=m.responseStyle??t.responseStyle,k,A;try{let{opts:y,url:h}=await i(m),x={redirect:"follow",...y,body:UI(y)};k=new Request(h,x);for(let pe of o.request.fns)if(pe)k=await pe(k,y);let z=y.fetch;A=await z(k);for(let pe of o.response.fns)if(pe)A=await pe(A,k,y);let X={request:k,response:A};if(A.ok){let pe=(y.parseAs==="auto"?qN(A.headers.get("Content-Type")):y.parseAs)??"json";if(A.status===204||A.headers.get("Content-Length")==="0"){let ee;switch(pe){case"arrayBuffer":case"blob":case"text":ee=await A[pe]();break;case"formData":ee=new FormData;break;case"stream":ee=A.body;break;case"json":default:ee={};break}return y.responseStyle==="data"?ee:{data:ee,...X}}let K;switch(pe){case"arrayBuffer":case"blob":case"formData":case"text":K=await A[pe]();break;case"json":{let ee=await A.text();K=ee?JSON.parse(ee):{};break}case"stream":return y.responseStyle==="data"?A.body:{data:A.body,...X}}if(pe==="json"){if(y.responseValidator)await y.responseValidator(K);if(y.responseTransformer)K=await y.responseTransformer(K)}return y.responseStyle==="data"?K:{data:K,...X}}let I=await A.text(),me;try{me=JSON.parse(I)}catch{}throw me??I}catch(y){let h=y;for(let x of o.error.fns)if(x)h=await x(h,A,k,m);if(h=h||{},g)throw h;return w==="data"?void 0:{error:h,request:k,response:A}}},c=(m)=>(g)=>s({...g,method:m}),l=(m)=>async(g)=>{let{opts:w,url:k}=await i(g);return MN({...w,body:w.body,method:m,onRequest:async(A,y)=>{let h=new Request(A,y);for(let x of o.request.fns)if(x)h=await x(h,w);return h},serializedBody:UI(w),url:k})};return{buildUrl:(m)=>DI({...t,...m}),connect:c("CONNECT"),delete:c("DELETE"),get:c("GET"),getConfig:r,head:c("HEAD"),interceptors:o,options:c("OPTIONS"),patch:c("PATCH"),post:c("POST"),put:c("PUT"),request:s,setConfig:n,sse:{connect:l("CONNECT"),delete:l("DELETE"),get:l("GET"),head:l("HEAD"),options:l("OPTIONS"),patch:l("PATCH"),post:l("POST"),put:l("PUT"),trace:l("TRACE")},trace:c("TRACE")}};async function*GN(e,t,{signal:r,maxPages:n}={}){if(n!==void 0&&(!Number.isSafeInteger(n)||n<1))throw RangeError("maxPages must be a whole number of at least 1.");let o=t.cursor,i=0,s=new Set;while(!0){if(r?.aborted)return;let c=await e(o===void 0?t:{...t,cursor:o});if(yield c,i++,!c.hasMore)return;if(c.nextCursor===void 0)throw Error("PubNio returned hasMore without a nextCursor for a cursor list.");if(s.has(c.nextCursor)||c.nextCursor===o)throw Error("PubNio returned a repeated pagination cursor.");if(n!==void 0&&i>=n)return;s.add(c.nextCursor),o=c.nextCursor}}async function*nt(e,t,r){for await(let n of GN(e,t,r))yield*n.data}var b6=new Set([408,425,429]);function I6(e){if(e.status!==429&&e.status!==503)return;let t=e.headers.get("retry-after");if(!t)return;let r=Number(t);if(Number.isFinite(r)&&r>=0)return r*1000;let n=Date.parse(t);if(Number.isNaN(n))return;return Math.max(0,n-Date.now())}function zN(e){return 250*2**e}function jN(e,t){return new Promise((r,n)=>{if(t.aborted){n(t.reason??Error("The request was aborted."));return}let o=()=>{clearTimeout(s),t.removeEventListener("abort",i),r()},i=()=>{clearTimeout(s),t.removeEventListener("abort",i),n(t.reason??Error("The request was aborted."))},s=setTimeout(o,e);t.addEventListener("abort",i,{once:!0})})}function QN(e){let t=e.method.toUpperCase();return t==="GET"||t==="HEAD"||e.headers.has("idempotency-key")}function w6(e){return b6.has(e)||e>=500}function HN(e,{retries:t=2}={}){return async(r)=>{let n=r.signal;for(let o=0;;o++){let i;try{i=await e(r.clone())}catch(c){if(!QN(r)||o>=t||n.aborted)throw c;await jN(zN(o),n);continue}if(!QN(r)||!w6(i.status)||o>=t)return i;let s=Math.max(zN(o),I6(i)??0);i.body?.cancel().catch(()=>{return}),await jN(s,n)}}}var B=Lu(Du({baseUrl:"/"}));var VN=(e)=>(e?.client??B).delete({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/me",...e}),MI=(e)=>(e?.client??B).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/me",...e}),JN=(e)=>(e.client??B).patch({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/me",...e,headers:{"Content-Type":"application/json",...e.headers}}),FI=(e)=>(e?.client??B).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/workspaces",...e}),NI=(e)=>(e.client??B).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/workspaces",...e,headers:{"Content-Type":"application/json",...e.headers}}),BI=(e)=>(e.client??B).delete({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/workspaces/{workspaceId}",...e}),KI=(e)=>(e.client??B).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/workspaces/{workspaceId}",...e}),qI=(e)=>(e.client??B).patch({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/workspaces/{workspaceId}",...e,headers:{"Content-Type":"application/json",...e.headers}}),$I=(e)=>(e.client??B).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/workspaces/{workspaceId}/api-keys",...e}),WI=(e)=>(e.client??B).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/workspaces/{workspaceId}/api-keys",...e,headers:{"Content-Type":"application/json",...e.headers}}),GI=(e)=>(e.client??B).delete({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/workspaces/{workspaceId}/api-keys/{keyId}",...e}),zI=(e)=>(e.client??B).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/workspaces/{workspaceId}/api-keys/{keyId}",...e}),jI=(e)=>(e.client??B).patch({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/workspaces/{workspaceId}/api-keys/{keyId}",...e,headers:{"Content-Type":"application/json",...e.headers}}),QI=(e)=>(e.client??B).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/workspaces/{workspaceId}/webhook-endpoints",...e}),HI=(e)=>(e.client??B).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/workspaces/{workspaceId}/webhook-endpoints",...e,headers:{"Content-Type":"application/json",...e.headers}}),VI=(e)=>(e.client??B).delete({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/workspaces/{workspaceId}/webhook-endpoints/{endpointId}",...e}),JI=(e)=>(e.client??B).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/workspaces/{workspaceId}/webhook-endpoints/{endpointId}",...e}),YI=(e)=>(e.client??B).patch({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/workspaces/{workspaceId}/webhook-endpoints/{endpointId}",...e,headers:{"Content-Type":"application/json",...e.headers}}),ZI=(e)=>(e.client??B).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/workspaces/{workspaceId}/webhook-endpoints/{endpointId}/test",...e}),XI=(e)=>(e.client??B).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/workspaces/{workspaceId}/webhook-endpoints/{endpointId}/deliveries",...e}),ew=(e)=>(e.client??B).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/workspaces/{workspaceId}/webhook-endpoints/{endpointId}/deliveries/{deliveryId}",...e}),tw=(e)=>(e.client??B).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/workspaces/{workspaceId}/webhook-endpoints/{endpointId}/deliveries/{deliveryId}/replay",...e}),E6=(e)=>(e?.client??B).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/webhooks/event-types",...e}),YN=(e)=>(e.client??B).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/integrations",...e}),ZN=(e)=>(e.client??B).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/integrations",...e,headers:{"Content-Type":"application/json",...e.headers}}),rw=(e)=>(e.client??B).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/integrations/accounts/{accountId}/profile",...e,headers:{"Content-Type":"application/json",...e.headers}}),XN=(e)=>(e.client??B).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/integrations/{provider}/connect",...e}),k6=(e)=>(e.client??B).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/integrations/bluesky/session",...e,headers:{"Content-Type":"application/json",...e.headers}}),eB=(e)=>(e.client??B).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/integrations/attempts/{attemptId}",...e}),nw=(e)=>(e.client??B).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/integrations/accounts/{accountId}",...e}),tB=(e)=>(e.client??B).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/integrations/accounts/{accountId}/reconnect",...e}),rB=(e)=>(e.client??B).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/integrations/accounts/{accountId}/instagram/publishing-limit",...e}),nB=(e)=>(e.client??B).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/integrations/accounts/{accountId}/instagram/audio",...e}),ow=(e)=>(e.client??B).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/integrations/accounts/{accountId}/instagram/audio/{audioId}",...e}),oB=(e)=>(e.client??B).delete({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/integrations/connections/{connectionId}",...e}),iB=(e)=>(e.client??B).delete({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/integrations/connections/{connectionId}/permanent",...e}),iw=(e)=>(e.client??B).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/profiles",...e}),sw=(e)=>(e.client??B).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/profiles",...e,headers:{"Content-Type":"application/json",...e.headers}}),aw=(e)=>(e.client??B).delete({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/profiles/{profileId}",...e}),cw=(e)=>(e.client??B).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/profiles/{profileId}",...e}),pw=(e)=>(e.client??B).patch({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/profiles/{profileId}",...e,headers:{"Content-Type":"application/json",...e.headers}}),dw=(e)=>(e?.client??B).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/capabilities",...e}),uw=(e)=>(e.client??B).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/integrations/capabilities",...e}),lw=(e)=>(e?.client??B).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/capabilities/catalog",...e}),fw=(e)=>(e?.client??B).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/limits",...e}),mw=(e)=>(e.client??B).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/media",...e}),sB=(e)=>(e.client??B).post({bodySerializer:null,security:[{scheme:"bearer",type:"http"}],url:"/api/v1/media",...e,headers:{"Content-Type":"application/octet-stream",...e.headers}}),hw=(e)=>(e.client??B).delete({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/media/{mediaId}",...e}),yw=(e)=>(e.client??B).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/media/{mediaId}",...e});var aB=(e)=>(e.client??B).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/media/import",...e,headers:{"Content-Type":"application/json",...e.headers}}),Rh=(e)=>(e.client??B).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/media/{mediaId}/status",...e}),cB=(e)=>(e.client??B).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/media/uploads",...e,headers:{"Content-Type":"application/json",...e.headers}}),pB=(e)=>(e.client??B).put({bodySerializer:null,security:[{scheme:"bearer",type:"http"}],url:"/api/v1/media/uploads/{mediaId}/parts/{partNumber}",...e,headers:{"Content-Type":"application/octet-stream",...e.headers}}),dB=(e)=>(e.client??B).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/media/uploads/{mediaId}/complete",...e}),uB=(e)=>(e.client??B).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/media/{mediaId}/content",...e}),lB=(e)=>(e.client??B).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/queues",...e}),fB=(e)=>(e.client??B).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/queues",...e,headers:{"Content-Type":"application/json",...e.headers}}),mB=(e)=>(e.client??B).delete({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/queues/{queueId}",...e}),hB=(e)=>(e.client??B).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/queues/{queueId}",...e}),yB=(e)=>(e.client??B).patch({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/queues/{queueId}",...e,headers:{"Content-Type":"application/json",...e.headers}}),gB=(e)=>(e.client??B).put({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/queues/{queueId}/slots",...e,headers:{"Content-Type":"application/json",...e.headers}}),xB=(e)=>(e.client??B).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/queues/{queueId}/next-slot",...e}),SB=(e)=>(e.client??B).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/queues/{queueId}/slots/preview",...e}),bB=(e)=>(e.client??B).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/queues/{queueId}/skips",...e}),IB=(e)=>(e.client??B).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/queues/{queueId}/skips",...e,headers:{"Content-Type":"application/json",...e.headers}}),wB=(e)=>(e.client??B).delete({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/queues/{queueId}/skips/{skipId}",...e}),EB=(e)=>(e.client??B).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/queues/{queueId}/blackouts",...e}),kB=(e)=>(e.client??B).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/queues/{queueId}/blackouts",...e,headers:{"Content-Type":"application/json",...e.headers}}),AB=(e)=>(e.client??B).delete({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/queues/{queueId}/blackouts/{blackoutId}",...e}),vB=(e)=>(e.client??B).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/schedule",...e}),CB=(e)=>(e.client??B).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/posts/{postId}/targets/{targetId}/schedule",...e,headers:{"Content-Type":"application/json",...e.headers}}),gw=(e)=>(e.client??B).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/analytics/posts/{postId}",...e}),xw=(e)=>(e.client??B).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/analytics/posts/{postId}/series",...e}),Sw=(e)=>(e.client??B).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/workspaces/{workspaceId}/analytics/accounts",...e}),bw=(e)=>(e.client??B).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/workspaces/{workspaceId}/analytics/accounts/{accountId}",...e}),Iw=(e)=>(e.client??B).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/workspaces/{workspaceId}/analytics/capabilities",...e}),ww=(e)=>(e.client??B).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/analytics/refreshes",...e,headers:{"Content-Type":"application/json",...e.headers}}),Ew=(e)=>(e.client??B).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/analytics/refreshes/{refreshId}",...e}),kw=(e)=>(e.client??B).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/inbox/conversations",...e}),Aw=(e)=>(e.client??B).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/inbox/conversations/{conversationId}",...e}),vw=(e)=>(e.client??B).patch({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/inbox/conversations/{conversationId}",...e,headers:{"Content-Type":"application/json",...e.headers}}),Cw=(e)=>(e.client??B).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/inbox/conversations/{conversationId}/messages",...e}),Tw=(e)=>(e.client??B).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/inbox/conversations/{conversationId}/messages",...e,headers:{"Content-Type":"application/json",...e.headers}}),Ow=(e)=>(e.client??B).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/inbox/comments",...e}),Pw=(e)=>(e.client??B).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/inbox/comments/{threadId}",...e}),Rw=(e)=>(e.client??B).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/inbox/comments/{commentId}/replies",...e,headers:{"Content-Type":"application/json",...e.headers}}),_w=(e)=>(e.client??B).delete({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/inbox/comments/{commentId}",...e}),Uw=(e)=>(e.client??B).patch({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/inbox/comments/{commentId}",...e,headers:{"Content-Type":"application/json",...e.headers}}),Dw=(e)=>(e.client??B).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/inbox/mentions",...e}),Lw=(e)=>(e.client??B).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/inbox/mentions/{mentionId}/reply",...e,headers:{"Content-Type":"application/json",...e.headers}}),Mw=(e)=>(e.client??B).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/inbox/reviews",...e}),Fw=(e)=>(e.client??B).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/inbox/reviews/{reviewId}",...e}),A6=(e)=>(e.client??B).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/inbox/reviews/{reviewId}/replies",...e,headers:{"Content-Type":"application/json",...e.headers}}),Nw=(e)=>(e.client??B).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/inbox/unread-count",...e}),Bw=(e)=>(e.client??B).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/inbox/capabilities",...e}),Kw=(e)=>(e.client??B).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/inbox/sync",...e,headers:{"Content-Type":"application/json",...e.headers}}),qw=(e)=>(e.client??B).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/inbox/sync/{syncRunId}",...e}),$w=(e)=>(e.client??B).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/inbox/attachments/{attachmentId}",...e}),v6=(e)=>(e.client??B).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/comments",...e,headers:{"Content-Type":"application/json",...e.headers}}),TB=(e)=>(e.client??B).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/posts",...e}),Ww=(e)=>(e.client??B).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/posts",...e,headers:{"Content-Type":"application/json",...e.headers}}),Gw=(e)=>(e.client??B).delete({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/posts/{postId}",...e}),zw=(e)=>(e.client??B).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/posts/{postId}",...e}),jw=(e)=>(e.client??B).patch({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/posts/{postId}",...e,headers:{"Content-Type":"application/json",...e.headers}}),OB=(e)=>(e.client??B).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/posts/{postId}/validate",...e}),PB=(e)=>(e.client??B).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/posts/{postId}/publish",...e,headers:{"Content-Type":"application/json",...e.headers}}),Qw=(e)=>(e.client??B).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/posts/{postId}/targets/{targetId}/attempts",...e}),Hw=(e)=>(e.client??B).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/posts/{postId}/targets/{targetId}/retry",...e,headers:{"Content-Type":"application/json",...e.headers}}),Vw=(e)=>(e.client??B).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/posts/{postId}/targets/{targetId}/reconcile",...e,headers:{"Content-Type":"application/json",...e.headers}}),Jw=(e)=>(e.client??B).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/ads/accounts",...e}),Yw=(e)=>(e.client??B).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/ads/accounts/connect",...e,headers:{"Content-Type":"application/json",...e.headers}}),Zw=(e)=>(e.client??B).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/ads/accounts/connect/api-key",...e,headers:{"Content-Type":"application/json",...e.headers}}),Xw=(e)=>(e.client??B).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/ads/campaigns/validate",...e,headers:{"Content-Type":"application/json",...e.headers}}),eE=(e)=>(e.client??B).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/ads/campaigns",...e}),tE=(e)=>(e.client??B).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/ads/campaigns",...e,headers:{"Content-Type":"application/json",...e.headers}}),rE=(e)=>(e.client??B).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/ads/plans",...e}),nE=(e)=>(e.client??B).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/ads/plans/{planId}",...e}),oE=(e)=>(e.client??B).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/ads/accounts/{accountId}/select",...e}),iE=(e)=>(e.client??B).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/ads/accounts/{accountId}/disconnect",...e}),sE=(e)=>(e.client??B).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/ads/accounts/{accountId}/campaigns",...e}),aE=(e)=>(e.client??B).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/ads/tree",...e}),cE=(e)=>(e.client??B).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/ads/ads",...e}),pE=(e)=>(e.client??B).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/ads/ad-groups",...e}),dE=(e)=>(e.client??B).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/ads/ads/{adId}",...e}),uE=(e)=>(e.client??B).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/ads/creatives",...e}),lE=(e)=>(e.client??B).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/ads/accounts/{accountId}/creatives",...e,headers:{"Content-Type":"application/json",...e.headers}}),fE=(e)=>(e.client??B).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/ads/creatives/{creativeId}",...e}),mE=(e)=>(e.client??B).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/ads/insights",...e}),hE=(e)=>(e.client??B).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/ads/accounts/{accountId}/insights",...e}),yE=(e)=>(e.client??B).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/ads/accounts/{accountId}/insights/refresh",...e}),gE=(e)=>(e.client??B).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/ads/accounts/{accountId}/spend-policy",...e}),xE=(e)=>(e.client??B).put({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/ads/accounts/{accountId}/spend-policy",...e,headers:{"Content-Type":"application/json",...e.headers}}),SE=(e)=>(e.client??B).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/ads/accounts/{accountId}/kill-switch",...e,headers:{"Content-Type":"application/json",...e.headers}}),bE=(e)=>(e.client??B).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/ads/accounts/{accountId}/operations/{operationId}",...e}),IE=(e)=>(e.client??B).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/ads/accounts/{accountId}/boosts/validate",...e,headers:{"Content-Type":"application/json",...e.headers}}),wE=(e)=>(e.client??B).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/ads/accounts/{accountId}/boosts",...e,headers:{"Content-Type":"application/json",...e.headers}}),EE=(e)=>(e.client??B).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/ads/accounts/{accountId}/campaigns/{campaignId}/activate",...e,headers:{"Content-Type":"application/json",...e.headers}}),kE=(e)=>(e.client??B).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/ads/accounts/{accountId}/campaigns/{campaignId}/pause",...e,headers:{"Content-Type":"application/json",...e.headers}}),AE=(e)=>(e.client??B).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/ads/accounts/{accountId}/campaigns/{campaignId}/archive",...e,headers:{"Content-Type":"application/json",...e.headers}}),vE=(e)=>(e.client??B).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/ads/accounts/{accountId}/campaigns/{campaignId}/duplicate",...e,headers:{"Content-Type":"application/json",...e.headers}}),CE=(e)=>(e.client??B).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/ads/accounts/{accountId}/campaigns/{campaignId}/budget",...e,headers:{"Content-Type":"application/json",...e.headers}}),TE=(e)=>(e.client??B).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/ads/accounts/{accountId}/ad-groups/{adGroupId}/budget",...e,headers:{"Content-Type":"application/json",...e.headers}}),OE=(e)=>(e.client??B).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/ads/accounts/{accountId}/ad-groups/{adGroupId}/status",...e,headers:{"Content-Type":"application/json",...e.headers}}),PE=(e)=>(e.client??B).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/ads/accounts/{accountId}/campaigns/{campaignId}/ad-groups",...e,headers:{"Content-Type":"application/json",...e.headers}}),RE=(e)=>(e.client??B).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/ads/accounts/{accountId}/ad-groups/{adGroupId}/ads",...e,headers:{"Content-Type":"application/json",...e.headers}}),_E=(e)=>(e.client??B).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/ads/accounts/{accountId}/ads/{adId}/status",...e,headers:{"Content-Type":"application/json",...e.headers}}),UE=(e)=>(e.client??B).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/workspaces/{workspaceId}/audit-logs",...e}),DE=(e)=>(e.client??B).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/workspaces/{workspaceId}/audit-logs/{eventId}",...e}),LE=(e)=>(e.client??B).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/workspaces/{workspaceId}/notification-preferences",...e}),ME=(e)=>(e.client??B).patch({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/workspaces/{workspaceId}/notification-preferences",...e,headers:{"Content-Type":"application/json",...e.headers}}),FE=(e)=>(e.client??B).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/workspaces/{workspaceId}/members",...e}),NE=(e)=>(e.client??B).delete({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/workspaces/{workspaceId}/members/{userId}",...e}),BE=(e)=>(e.client??B).patch({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/workspaces/{workspaceId}/members/{userId}",...e,headers:{"Content-Type":"application/json",...e.headers}}),KE=(e)=>(e.client??B).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/workspaces/{workspaceId}/invites",...e}),qE=(e)=>(e.client??B).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/workspaces/{workspaceId}/invites",...e,headers:{"Content-Type":"application/json",...e.headers}}),$E=(e)=>(e.client??B).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/workspaces/{workspaceId}/invites/{inviteId}/resend",...e}),WE=(e)=>(e.client??B).delete({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/workspaces/{workspaceId}/invites/{inviteId}",...e}),RB=(e)=>(e?.client??B).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/me/invites",...e}),_B=(e)=>(e.client??B).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/me/invites/accept",...e,headers:{"Content-Type":"application/json",...e.headers}}),UB=(e)=>(e.client??B).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/me/invites/{inviteId}/decline",...e}),GE=(e)=>(e.client??B).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/workspaces/{workspaceId}/billing",...e}),zE=(e)=>(e.client??B).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/workspaces/{workspaceId}/billing/usage",...e}),jE=(e)=>(e.client??B).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/workspaces/{workspaceId}/billing/ledger",...e}),QE=(e)=>(e.client??B).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/workspaces/{workspaceId}/billing/checkout",...e,headers:{"Content-Type":"application/json",...e.headers}}),HE=(e)=>(e.client??B).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/workspaces/{workspaceId}/billing/portal",...e,headers:{"Content-Type":"application/json",...e.headers}}),VE=(e)=>(e.client??B).patch({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/workspaces/{workspaceId}/billing/spend-controls",...e,headers:{"Content-Type":"application/json",...e.headers}}),JE=(e)=>(e?.client??B).get({url:"/api/v1/billing/plans",...e}),YE=(e)=>(e?.client??B).get({url:"/api/v1/audit-logs/actions",...e});var C6=ns(AN),T6=ns(U(hF)),O6=ns(U(uo)),P6=ns(U(Uu)),R6=ns(U(a)),_6=ns(D3);class $n extends Error{failure;constructor(e){super(e.kind==="http"?e.problem?.detail??`PubNio request failed (HTTP ${e.status}).`:e.kind==="transport"?"Could not reach PubNio.":"PubNio returned a response that does not match its API contract.");this.failure=e;this.name="PubNioError"}get kind(){return this.failure.kind}get status(){return this.failure.kind==="transport"?void 0:this.failure.status}get requestId(){if(this.failure.kind==="transport")return;if(this.failure.requestId)return this.failure.requestId;let e=this.problem;return typeof e?.requestId==="string"?e.requestId:void 0}get problem(){return this.failure.kind==="http"?this.failure.problem:void 0}get knownProblem(){let e=C6(this.problem);return e._tag==="Some"?e.value:void 0}get problemType(){return this.problem?.type}isProblem(e){return e.startsWith("urn:")&&this.problemType===e}get code(){let e=this.problem;if(typeof e?.code==="string")return e.code;let t="urn:pubnio:problem:";return typeof this.problemType==="string"&&this.problemType.startsWith(t)?this.problemType.slice(t.length).replaceAll("-","_"):void 0}get param(){let e=this.problem;return typeof e?.param==="string"?e.param:void 0}get nextAction(){let e=this.problem;return typeof e?.nextAction==="string"?e.nextAction:void 0}get candidates(){let e=this.problem,t=P6(e?.candidates);return t._tag==="Some"?t.value:[]}get supportedVersions(){let e=this.problem,t=R6(e?.supportedVersions);return t._tag==="Some"?t.value:[]}get currentRevision(){let e=this.knownProblem;return e?.type==="urn:pubnio:problem:post-revision-conflict"?e.currentRevision:void 0}get currentAttemptId(){let e=this.knownProblem;return e?.type==="urn:pubnio:problem:attempt-changed"?e.currentAttemptId:void 0}get retryable(){if(this.failure.kind==="transport")return!0;if(this.failure.kind!=="http")return!1;let{status:e}=this.failure;return e===408||e===429||e>=500}get idempotencyKey(){if(this.failure.idempotencyKey!==void 0)return this.failure.idempotencyKey;let e=this.problem;return typeof e?.idempotencyKey==="string"?e.idempotencyKey:void 0}get requestIssues(){let e=T6(this.problem?.errors);return e._tag==="Some"?e.value:[]}get issues(){let e=O6(this.problem?.issues);return e._tag==="Some"?e.value:[]}}var U6="https://pubnio.com",D6=60000,L6=2,DB=300000,M6=2000;function ZE(e,t){if(!Number.isSafeInteger(e)||e<0||e>3600000)throw RangeError(`${t} must be a whole number between 0 and 3600000.`);return e}function F6(e){if(!Number.isSafeInteger(e)||e<0||e>5)throw RangeError("retries must be a whole number between 0 and 5.");return e}function N6(e){return e===0?void 0:AbortSignal.timeout(e)}function LB(e){let t=e.filter((r)=>!!r);if(t.length===0)return;return t.length===1?t[0]:AbortSignal.any(t)}function B6(e,t){return new Promise((r)=>{if(t?.aborted){r();return}let n=()=>{clearTimeout(o),t?.removeEventListener("abort",n),r()},o=setTimeout(n,e);t?.addEventListener("abort",n,{once:!0})})}function K6(e){return{accounts:e.accounts.map(({id:t,provider:r,accountKind:n,name:o,enabled:i,readiness:s})=>({accountId:t,provider:r,accountKind:n,name:o,enabled:i,readiness:s}))}}function Qt(e,t){return t().catch((r)=>{if(r instanceof $n&&r.idempotencyKey===void 0)throw new $n({...r.failure,idempotencyKey:e});throw r})}function MB(e){return e.map((t)=>({...t}))}function q6(e,t){return new $n({kind:"http",status:404,problem:{type:"urn:pubnio:problem:target-not-found",status:404,title:"Delivery target not found",detail:`Target ${t} is not part of post ${e}.`,code:"target_not_found",param:"targetId",nextAction:`Read posts.status("${e}") and retry with a current targetId.`}})}function $6(e,t){return new $n({kind:"http",status:422,problem:{type:"urn:pubnio:problem:schedule-required",status:422,title:"Schedule required",detail:`Target ${t} on post ${e} is not assigned to a schedule queue.`,code:"schedule_required",param:"queueId",nextAction:"Use schedule.change with an explicit scheduledAt to reschedule this target, or pass queueId to assign it to a queue."}})}async function W6(e){let t=new Uint8Array(await crypto.subtle.digest("SHA-256",await e.arrayBuffer()));return btoa(String.fromCharCode(...t)).replaceAll("+","-").replaceAll("/","_").replace(/=+$/,"")}function Aa({baseUrl:e=U6,accessToken:t,apiKey:r,fetch:n,headers:o,timeoutMs:i=D6,signal:s,retries:c=L6,clientName:l="sdk",clientVersion:S=LN.version,onRuntime:m}){let g=ZE(i,"timeoutMs"),w=F6(c),k=r??t,A=new Headers(o);if(!A.has("x-pubnio-client"))A.set("x-pubnio-client",`${l}/${S}`);A.set(kM,yI);let y=Lu({baseUrl:e.toString().replace(/\/+$/,""),headers:A,...k?{auth:k,redirect:"error"}:{},fetch:HN((I)=>n?n(I):fetch(I),{retries:w})});function h(I={},me=g){let pe=LB([s,I.signal,N6(I.timeoutMs===void 0?me:ZE(I.timeoutMs,"timeoutMs"))]);return pe?{signal:pe}:{}}async function x(I,me){let{data:pe,error:K,response:ee}=await me.catch(()=>{throw new $n({kind:"transport"})});if(!ee)throw new $n({kind:"transport"});let{status:Q}=ee,te=ee.headers.get(mF)??void 0;if(!ee.ok){let se=ee.headers.get("content-type")?.split(";",1)[0]?.trim().toLowerCase()===kh?_6(K):void 0;throw new $n({kind:"http",status:Q,...se?._tag==="Some"?{problem:se.value}:{},...te?{requestId:te}:{}})}let re=()=>new $n({kind:"invalid_response",status:Q,...te?{requestId:te}:{}});if(K!==void 0)throw re();return ao(I)(pe).catch(()=>{throw re()})}m?.({client:y,transport:h,decode:x});async function z(I,me,{timeoutMs:pe=60000,signal:K}={}){let ee=ZE(pe,"timeoutMs"),Q=performance.now()+ee,te=new AbortController,re=ee===0?void 0:setTimeout(()=>te.abort(),ee),ae=()=>te.abort();K?.addEventListener("abort",ae,{once:!0});let se=LB([K,te.signal]);try{let le=await I(se);while(!me(le)){let Se=Q-performance.now();if(Se<=0||se.aborted)return{value:le,settled:!1};if(await B6(Math.min(M6,Se),se),performance.now()>=Q||se.aborted)return{value:le,settled:!1};try{le=await I(se)}catch(ve){if(se.aborted)return{value:le,settled:!1};throw ve}}return{value:le,settled:!0}}finally{clearTimeout(re),K?.removeEventListener("abort",ae)}}function X(I){let me=(d,b)=>x(np,zw({client:y,path:{postId:d},query:{workspaceId:I},...h(b)})),pe=async(d,b)=>{let W=await me(d,b);return{postId:W.postId,status:W.status,targets:W.deliveries}},K=(d,b)=>x(Ia,Rh({client:y,path:{mediaId:d},query:{workspaceId:I},...h(b)}));async function ee(d,b){let W=typeof d==="string"?b:d;if(!(W instanceof Blob))throw TypeError("Choose a media file to upload.");let ce=typeof d==="string"?d:b instanceof Blob?void 0:b?.mimeType,Ce=b instanceof Blob?void 0:b,Br=Ce?.timeoutMs??DB,vs=Ce?.signal,$o=Ce?.idempotencyKey??crypto.randomUUID(),Wo={timeoutMs:Br,signal:vs};if(W.size<=eh){let Cs=ce??kD(new Uint8Array(await W.slice(0,64).arrayBuffer()));if(!Cs)throw TypeError("Choose a supported image or video file.");return x(Ia,sB({client:y,query:{workspaceId:I,mimeType:Cs},headers:{"idempotency-key":$o},body:W,...h(Wo)}))}let{mediaId:Ka,partSizeBytes:hl}=await x(TD,cB({client:y,query:{workspaceId:I},headers:{"idempotency-key":$o},body:{sizeBytes:W.size},...h(Wo)})),vi=await x(Ia,Rh({client:y,path:{mediaId:Ka},query:{workspaceId:I},...h(Wo)}));if(vi.status==="ready")return vi;if(vi.status!=="awaiting_upload"||!vi.upload)throw Error(`Media upload could not resume${vi.status==="failed"&&vi.issue?` (${vi.issue.code})`:""}.`);let{receivedPartCount:$1,partDigests:W1}=vi.upload;for(let Cs=0,Ip=1;Cs<W.size;Cs+=hl,Ip++){let ky=W.slice(Cs,Cs+hl);if(Ip<=$1){if(await W6(ky)!==W1[Ip-1])throw Error("The selected file does not match this upload session. Use a new idempotency key for a different file.");continue}await x(OD,pB({client:y,path:{mediaId:Ka,partNumber:String(Ip)},query:{workspaceId:I},headers:{"content-length":String(ky.size),"idempotency-key":`${$o}-part-${Ip}`},body:ky,...h(Wo)}))}let RA=await x(Ia,dB({client:y,path:{mediaId:Ka},query:{workspaceId:I},headers:{"idempotency-key":`${$o}-complete`},...h(Wo)}));if(RA.status!=="ready")throw Error("The upload could not be finalized. Check the media status before retrying.");return RA}async function Q(d){let{idempotencyKey:b=crypto.randomUUID(),...W}=d;return Qt(b,async()=>{let ce=W;if(W.isDraft)return x(np,Ww({client:y,query:{workspaceId:I},headers:{"idempotency-key":b},body:ce,...h()}));return{...await x(xa,Ww({client:y,query:{workspaceId:I},headers:{"idempotency-key":b},body:ce,...h()})),idempotencyKey:b}})}let te=({cursor:d,limit:b,isDraft:W,deliveryStatus:ce,accountId:Ce,profileId:Br}={})=>x(VU,TB({client:y,query:{workspaceId:I,cursor:d,limit:b?.toString(),isDraft:W===void 0?void 0:W?"true":"false",deliveryStatus:ce,accountId:Ce,profileId:Br},...h()})),re=(d,b,{cursor:W,limit:ce}={})=>x(JU,Qw({client:y,path:{postId:d,targetId:b},query:{workspaceId:I,cursor:W,limit:ce?.toString()},...h()})),ae=({cursor:d,limit:b,type:W}={})=>x(AD,mw({client:y,query:{workspaceId:I,cursor:d,limit:b?.toString(),type:W},...h()})),se=({cursor:d,limit:b,includeArchived:W}={})=>x(AM,iw({client:y,query:{workspaceId:I,includeArchived:W?"true":void 0,cursor:d,limit:b===void 0?void 0:String(b)},...h()})),le=({cursor:d,limit:b,action:W,targetKind:ce,targetId:Ce,actorType:Br,actorId:vs,profileId:$o,from:Wo,to:Ka}={})=>x(cD,UE({client:y,path:{workspaceId:I},query:{cursor:d,limit:b?.toString(),action:W,targetKind:ce,targetId:Ce,actorType:Br,actorId:vs,profileId:$o,from:Wo,to:Ka},...h()})),Se=({cursor:d,limit:b}={})=>x(ID,$I({client:y,path:{workspaceId:I},query:{cursor:d,limit:b?.toString()},...h()})),ve=({cursor:d,limit:b}={})=>x(DM,QI({client:y,path:{workspaceId:I},query:{cursor:d,limit:b?.toString()},...h()})),ye=(d,{cursor:b,limit:W}={})=>x(FM,XI({client:y,path:{workspaceId:I,endpointId:d},query:{cursor:b,limit:W?.toString()},...h()})),$e=({accountId:d,cursor:b,limit:W}={})=>x(IL,lB({client:y,query:{workspaceId:I,accountId:d,cursor:b,limit:W===void 0?void 0:String(W)},...h()})),_e=({from:d,to:b,accountId:W,queueId:ce,cursor:Ce,limit:Br})=>x(FL,vB({client:y,query:{workspaceId:I,from:d,to:b,accountId:W,queueId:ce,cursor:Ce,limit:Br===void 0?void 0:String(Br)},...h()})),nr=(d,b)=>x(PL,xB({client:y,path:{queueId:d},query:{workspaceId:I,after:b},...h()})),lr=(d,b,W)=>x(kb,CB({client:y,path:{postId:d,targetId:b},query:{workspaceId:I},body:W,...h()})),Nr=async(d,b,W={})=>{let Ce=(await pe(d)).targets.find((hl)=>hl.targetId===b);if(!Ce)throw q6(d,b);let Br=W.queueId??Ce.queueId;if(!Br)throw $6(d,b);let vs=await nr(Br,Ce.scheduledAt??new Date().toISOString());if(!vs.occurrence)return{skipped:!1,horizonEndsAt:vs.horizonEndsAt};let{slotId:$o,occurrenceDate:Wo}=vs.occurrence;if(!$o)throw new $n({kind:"http",status:409,problem:{type:"urn:pubnio:problem:conflict",status:409,title:"Conflict",detail:"The next queue occurrence is not bound to a slot.",code:"conflict",param:"queueId",nextAction:"Read the queue slots, then retry with a queue that has active slots."}});return{skipped:!0,result:await lr(d,b,{expectedAttemptId:W.expectedAttemptId??Ce.attemptId,action:"reschedule",queueId:Br,pinned:{slotId:$o,occurrenceDate:Wo}})}},Es=(d,{cursor:b,limit:W}={})=>x(UL,bB({client:y,path:{queueId:d},query:{workspaceId:I,cursor:b,limit:W===void 0?void 0:String(W)},...h()})),ks=(d,{cursor:b,limit:W}={})=>x(ML,EB({client:y,path:{queueId:d},query:{workspaceId:I,cursor:b,limit:W===void 0?void 0:String(W)},...h()})),As=(d={})=>{let b={accountId:d.accountIds&&[...d.accountIds],platform:d.provider,from:d.from,to:d.to,timezone:d.timezone,granularity:d.granularity,metrics:d.metrics&&[...d.metrics],cursor:d.cursor,limit:d.limit===void 0?void 0:String(d.limit)};return x(DN,Sw({client:y,path:{workspaceId:I},query:b,...h()}))},xo=(d={})=>x(GL,kw({client:y,query:{workspaceId:I,accountId:d.accountId,provider:d.provider,status:d.status,folder:d.folder,unread:d.unread===void 0?void 0:d.unread?"true":"false",search:d.search,cursor:d.cursor,limit:d.limit===void 0?void 0:String(d.limit)},...h()})),al=(d,b={})=>x(zL,Cw({client:y,path:{conversationId:d},query:{workspaceId:I,order:b.order,cursor:b.cursor,limit:b.limit===void 0?void 0:String(b.limit)},...h()})),cl=(d={})=>x(jL,Ow({client:y,query:{workspaceId:I,accountId:d.accountId,postId:d.postId,providerPostId:d.providerPostId,unread:d.unread===void 0?void 0:d.unread?"true":"false",cursor:d.cursor,limit:d.limit===void 0?void 0:String(d.limit)},...h()})),pl=(d,b={})=>x(QL,Pw({client:y,path:{threadId:d},query:{workspaceId:I,cursor:b.cursor,limit:b.limit===void 0?void 0:String(b.limit)},...h()})),dl=(d={})=>x(HL,Dw({client:y,query:{workspaceId:I,accountId:d.accountId,provider:d.provider,cursor:d.cursor,limit:d.limit===void 0?void 0:String(d.limit)},...h()})),ul=(d={})=>x(VL,Mw({client:y,query:{workspaceId:I,accountId:d.accountId,includeDeleted:d.includeDeleted===void 0?void 0:d.includeDeleted?"true":"false",cursor:d.cursor,limit:d.limit===void 0?void 0:String(d.limit)},...h()})),ll=(d={})=>x(nM,Jw({client:y,query:{workspaceId:I,state:d.state,cursor:d.cursor,limit:d.limit===void 0?void 0:String(d.limit)},...h()})),fl=(d={})=>x(mI,eE({client:y,query:{workspaceId:I,accountId:d.accountId,provider:d.provider,status:d.status,managed:d.managed,cursor:d.cursor,limit:d.limit===void 0?void 0:String(d.limit)},...h()})),ml=(d,b={})=>x(mI,sE({client:y,path:{accountId:d},query:{workspaceId:I,provider:b.provider,status:b.status,managed:b.managed,cursor:b.cursor,limit:b.limit===void 0?void 0:String(b.limit)},...h()})),Ey=(d={})=>x(xM,pE({client:y,query:{workspaceId:I,accountId:d.accountId,campaignId:d.campaignId,provider:d.provider,status:d.status,from:d.from,to:d.to,cursor:d.cursor,limit:d.limit===void 0?void 0:String(d.limit)},...h()})),wr=(d={})=>x(SM,cE({client:y,query:{workspaceId:I,accountId:d.accountId,campaignId:d.campaignId,adGroupId:d.adGroupId,provider:d.provider,status:d.status,from:d.from,to:d.to,cursor:d.cursor,limit:d.limit===void 0?void 0:String(d.limit)},...h()})),An=(d={})=>x(IM,aE({client:y,query:{workspaceId:I,accountId:d.accountId,campaignId:d.campaignId,cursor:d.cursor,limit:d.limit===void 0?void 0:String(d.limit)},...h()})),qo=(d={})=>x(bM,uE({client:y,query:{workspaceId:I,accountId:d.accountId,adId:d.adId,cursor:d.cursor,limit:d.limit===void 0?void 0:String(d.limit)},...h()})),U1=(d,b,W={})=>{let ce=W.idempotencyKey??crypto.randomUUID();return Qt(ce,()=>x(sn,lE({client:y,path:{accountId:d},query:{workspaceId:I},headers:{"idempotency-key":ce},body:b,...h()})))},D1=(d)=>x(Tu,fE({client:y,path:{creativeId:d},query:{workspaceId:I},...h()})),CA=(d={})=>x(hI,mE({client:y,query:{workspaceId:I,accountId:d.accountId,campaignId:d.campaignId,adGroupId:d.adGroupId,adId:d.adId,level:d.level,from:d.from,to:d.to,metrics:d.metrics&&[...d.metrics],cursor:d.cursor,limit:d.limit===void 0?void 0:String(d.limit)},...h()})),TA=(d,b={})=>x(hI,hE({client:y,path:{accountId:d},query:{workspaceId:I,campaignId:b.campaignId,adGroupId:b.adGroupId,adId:b.adId,level:b.level,from:b.from,to:b.to,metrics:b.metrics&&[...b.metrics],cursor:b.cursor,limit:b.limit===void 0?void 0:String(b.limit)},...h()})),L1=(d)=>x(mh,gE({client:y,path:{accountId:d},query:{workspaceId:I},...h()})),M1=(d,b)=>x(mh,xE({client:y,path:{accountId:d},query:{workspaceId:I},body:b,...h()})),F1=(d,b)=>x(rM,SE({client:y,path:{accountId:d},query:{workspaceId:I},body:b,...h()})),N1=(d,b)=>x(sn,bE({client:y,path:{accountId:d,operationId:b},query:{workspaceId:I},...h()})),B1=(d,b)=>x(dM,IE({client:y,path:{accountId:d},query:{workspaceId:I},body:b,...h()})),OA=(d)=>({...d,...d.budget?{budget:{...d.budget}}:{},...d.schedule?{schedule:{...d.schedule}}:{},...d.providerSettings?{providerSettings:{...d.providerSettings}}:{},targets:d.targets.map((b)=>({...b,...b.budget?{budget:{...b.budget}}:{},...b.schedule?{schedule:{...b.schedule}}:{},...b.providerSettings?{providerSettings:{...b.providerSettings}}:{}})),adGroups:d.adGroups.map((b)=>({...b,...b.budget?{budget:{...b.budget}}:{},...b.targeting?{targeting:{...b.targeting}}:{},...b.providerSettings?{providerSettings:{...b.providerSettings}}:{},ads:b.ads.map((W)=>({...W,...W.providerSettings?{providerSettings:{...W.providerSettings}}:{},creative:{...W.creative.headline!==void 0?{headline:W.creative.headline}:{},...W.creative.body!==void 0?{body:W.creative.body}:{},...W.creative.callToAction!==void 0?{callToAction:W.creative.callToAction}:{},...W.creative.destinationUrl!==void 0?{destinationUrl:W.creative.destinationUrl}:{},...W.creative.media?{media:W.creative.media.map((ce)=>({...ce}))}:{},...W.creative.providerSettings?{providerSettings:{...W.creative.providerSettings}}:{}}}))}))}),K1=(d)=>x(uM,Xw({client:y,query:{workspaceId:I},body:OA(d),...h()})),q1=(d,b={})=>{let W=b.idempotencyKey??crypto.randomUUID();return Qt(W,()=>x(fM,tE({client:y,query:{workspaceId:I},headers:{"idempotency-key":W},body:OA(d),...h()})))},PA=(d={})=>x(mM,rE({client:y,query:{workspaceId:I,status:d.status,cursor:d.cursor,limit:d.limit===void 0?void 0:String(d.limit)},...h()}));return{workspaceId:I,posts:{list:te,iterate:(d,b)=>nt(te,d??{},b),create:Q,get:me,update:(d,b)=>x(np,jw({client:y,path:{postId:d},query:{workspaceId:I},body:b,...h()})),validate:(d)=>x(gL,OB({client:y,path:{postId:d},query:{workspaceId:I},...h()})),publish:(d,b)=>{let{idempotencyKey:W=crypto.randomUUID(),...ce}=b;return Qt(W,async()=>({...await x(xa,PB({client:y,path:{postId:d},query:{workspaceId:I},headers:{"idempotency-key":W},body:{expectedRevision:ce.expectedRevision,scheduledAt:ce.scheduledAt,accountIds:ce.accountIds&&[...ce.accountIds],targets:ce.targets&&[...ce.targets]},...h()})),idempotencyKey:W}))},delete:(d)=>x(yL,Gw({client:y,path:{postId:d},query:{workspaceId:I},...h()})),status:pe,attempts:re,iterateAttempts:(d,b,W,ce)=>nt((Ce)=>re(d,b,Ce),W??{},ce),retry:(d,b,W)=>x(kb,Hw({client:y,path:{postId:d,targetId:b},query:{workspaceId:I},body:W,...h()})),reconcile:(d,b,W)=>x(Ab,Vw({client:y,path:{postId:d,targetId:b},query:{workspaceId:I},body:W,...h()})),wait:async(d,b)=>{let{value:W,settled:ce}=await z((Ce)=>pe(d,{signal:Ce}),(Ce)=>HU(Ce.status),b);return{settled:ce,post:W,...ce?{}:{retryAfterSeconds:2}}}},media:{list:ae,iterate:(d,b)=>nt(ae,d??{},b),delete:(d)=>x(vD,hw({client:y,path:{mediaId:d},query:{workspaceId:I},...h()})),importUrl:(d,b={})=>{let{idempotencyKey:W=crypto.randomUUID(),signal:ce,timeoutMs:Ce}=b;return Qt(W,async()=>({...await x(Ia,aB({client:y,query:{workspaceId:I},headers:{"idempotency-key":W},body:{url:d},...h({timeoutMs:Ce,signal:ce})})),idempotencyKey:W}))},status:K,upload:ee,get:(d)=>x(Ia,yw({client:y,path:{mediaId:d},query:{workspaceId:I},...h()})),download:(d)=>x(ha(Blob),uB({client:y,path:{mediaId:d},query:{workspaceId:I},parseAs:"blob",...h()})),wait:async(d,b)=>{let{value:W}=await z((ce)=>K(d,{signal:ce}),(ce)=>ce.status==="ready"||ce.status==="failed",{timeoutMs:b?.timeoutMs??DB,signal:b?.signal});if(W.status==="ready"&&W.asset)return{mediaId:W.mediaId,status:"ready",asset:W.asset};if(W.status==="failed"&&W.issue)return{mediaId:W.mediaId,status:"failed",issue:W.issue};return{mediaId:W.mediaId,status:"timeout",retryAfterSeconds:2}}},accounts:{list:async(d)=>{let b=typeof d==="string"?{profileId:d}:d,W=await x(Bb,YN({client:y,query:{workspaceId:I,profileId:b?.profileId,ready:b?.ready===void 0?void 0:b.ready?"true":"false",includeAdAccounts:b?.includeAdAccounts===void 0?void 0:b.includeAdAccounts?"true":"false"},...h()}));return b?.ready?K6(W):W},get:(d,b)=>x(tp,nw({client:y,path:{accountId:d},query:{workspaceId:I,includeAdAccounts:b?.includeAdAccounts===void 0?void 0:b.includeAdAccounts?"true":"false"},...h()})),move:(d,b)=>x(tp,rw({client:y,path:{accountId:d},query:{workspaceId:I},body:b,...h()})),setEnabled:(d)=>x(tp,ZN({client:y,query:{workspaceId:I},body:d,...h()})),prepareConnection:(d,b,W)=>x($b,XN({client:y,path:{provider:d},query:{workspaceId:I,loginMethod:b,profileId:W},...h()})),connectionStatus:(d)=>x(ND,eB({client:y,path:{attemptId:d},query:{workspaceId:I},...h()})),reconnect:(d,b)=>x($b,tB({client:y,path:{accountId:d},query:{workspaceId:I,loginMethod:b},...h()})),disconnect:(d)=>x(BD,oB({client:y,path:{connectionId:d},query:{workspaceId:I},...h()})),delete:(d)=>x(KD,iB({client:y,path:{connectionId:d},query:{workspaceId:I},...h()})),instagramPublishingLimit:(d)=>x(qD,rB({client:y,path:{accountId:d},query:{workspaceId:I},...h()})),searchInstagramAudio:(d,b)=>x($D,nB({client:y,path:{accountId:d},query:{workspaceId:I,...b},...h()})),getInstagramAudio:(d,b)=>x(Wb,ow({client:y,path:{accountId:d,audioId:b},query:{workspaceId:I},...h()}))},profiles:{list:se,iterate:(d,b)=>nt(se,d??{},b),create:(d)=>x(Ou,sw({client:y,query:{workspaceId:I},body:d,...h()})),get:(d)=>x(Ou,cw({client:y,path:{profileId:d},query:{workspaceId:I},...h()})),update:(d,b)=>x(Ou,pw({client:y,path:{profileId:d},query:{workspaceId:I},body:b,...h()})),archive:(d)=>x(vM,aw({client:y,path:{profileId:d},query:{workspaceId:I},...h()}))},capabilities:{list:(d={})=>x(_D,uw({client:y,query:{workspaceId:I,profileId:d.profileId,accountId:d.accountId,capability:d.capability},...h()})),catalog:()=>x(UD,lw({client:y})),get:()=>x(LD,dw({client:y}))},limits:{get:()=>x(Nb,fw({client:y}))},apiKeys:{create:(d)=>x(bD,WI({client:y,path:{workspaceId:I},body:{...d,scopes:d.scopes&&[...d.scopes]},...h()})),list:Se,iterate:(d,b)=>nt(Se,d??{},b),get:(d)=>x(xu,zI({client:y,path:{workspaceId:I,keyId:d},...h()})),update:(d,b)=>x(xu,jI({client:y,path:{workspaceId:I,keyId:d},body:{...b,scopes:b.scopes&&[...b.scopes]},...h()})),revoke:(d)=>x(wD,GI({client:y,path:{workspaceId:I,keyId:d},...h()}))},webhooks:{create:(d)=>{let{eventTypes:b,accountIds:W,disabledResourceGroups:ce,...Ce}=d;return x(UM,HI({client:y,path:{workspaceId:I},body:{...Ce,eventTypes:[...b],...W?{accountIds:[...W]}:{},...ce?{disabledResourceGroups:[...ce]}:{}},...h()}))},list:ve,iterate:(d,b)=>nt(ve,d??{},b),get:(d)=>x(kI,JI({client:y,path:{workspaceId:I,endpointId:d},...h()})),update:(d,b)=>{let{eventTypes:W,accountIds:ce,disabledResourceGroups:Ce,...Br}=b;return x(Ih,YI({client:y,path:{workspaceId:I,endpointId:d},body:{...Br,eventTypes:W?.slice(),...ce===void 0?{}:{accountIds:ce===null?null:[...ce]},...Ce===void 0?{}:{disabledResourceGroups:Ce===null?null:[...Ce]}},...h()}))},delete:(d)=>x(LM,VI({client:y,path:{workspaceId:I,endpointId:d},...h()})),test:(d)=>x(MM,ZI({client:y,path:{workspaceId:I,endpointId:d},...h()})),listDeliveries:ye,iterateDeliveries:(d,b,W)=>nt((ce)=>ye(d,ce),b??{},W),getDelivery:(d,b)=>x(wh,ew({client:y,path:{workspaceId:I,endpointId:d,deliveryId:b},...h()})),replayDelivery:(d,b)=>x(wh,tw({client:y,path:{workspaceId:I,endpointId:d,deliveryId:b},...h()}))},queues:{list:$e,iterate:(d,b)=>nt($e,d??{},b),create:(d)=>x(ip,fB({client:y,query:{workspaceId:I},body:{...d,slots:MB(d.slots)},...h()})),get:(d)=>x(ip,hB({client:y,path:{queueId:d},query:{workspaceId:I},...h()})),update:(d,b)=>x(ip,yB({client:y,path:{queueId:d},query:{workspaceId:I},body:b,...h()})),archive:(d,b)=>x(wL,mB({client:y,path:{queueId:d},query:{workspaceId:I,expectedVersion:String(b)},...h()})),replaceSlots:(d,b)=>x(ip,gB({client:y,path:{queueId:d},query:{workspaceId:I},body:{expectedVersion:b.expectedVersion,slots:MB(b.slots)},...h()})),nextSlot:nr,previewSlots:(d,{count:b,after:W,includeOccupied:ce})=>x(RL,SB({client:y,path:{queueId:d},query:{workspaceId:I,count:String(b),after:W,includeOccupied:ce===void 0?void 0:ce?"true":"false"},...h()})),skips:Es,iterateSkips:(d,b,W)=>nt((ce)=>Es(d,ce),b??{},W),skip:(d,b,W)=>x(Yb,IB({client:y,path:{queueId:d},query:{workspaceId:I},body:{slotId:b,occurrenceDate:W},...h()})),unskip:(d,b)=>x(Xb,wB({client:y,path:{queueId:d,skipId:b},query:{workspaceId:I},...h()})),blackouts:ks,iterateBlackouts:(d,b,W)=>nt((ce)=>ks(d,ce),b??{},W),blackout:(d,b)=>x(Zb,kB({client:y,path:{queueId:d},query:{workspaceId:I},body:b,...h()})),unblackout:(d,b)=>x(Xb,AB({client:y,path:{queueId:d,blackoutId:b},query:{workspaceId:I},...h()}))},schedule:{list:_e,iterateRange:(d,b)=>nt(_e,d,b),change:lr,skipToNext:Nr},inbox:{conversations:xo,iterateConversations:(d,b)=>nt(xo,d??{},b),conversation:(d)=>x(uh,Aw({client:y,path:{conversationId:d},query:{workspaceId:I},...h()})),updateConversation:(d,b)=>x(uh,vw({client:y,path:{conversationId:d},query:{workspaceId:I},body:b,...h()})),messages:al,iterateMessages:(d,b,W)=>nt((ce)=>al(d,ce),b??{},W),sendMessage:(d,b)=>{let{idempotencyKey:W=crypto.randomUUID(),text:ce}=b;return Qt(W,()=>x(aI,Tw({client:y,path:{conversationId:d},query:{workspaceId:I},headers:{"idempotency-key":W},body:{text:ce},...h()})))},comments:cl,iterateComments:(d,b)=>nt(cl,d??{},b),thread:pl,iterateThread:(d,b,W)=>nt((ce)=>pl(d,ce),b??{},W),replyComment:(d,b)=>{let{idempotencyKey:W=crypto.randomUUID(),text:ce}=b;return Qt(W,()=>x(lh,Rw({client:y,path:{commentId:d},query:{workspaceId:I},headers:{"idempotency-key":W},body:{text:ce},...h()})))},moderateComment:(d,b)=>x(lh,Uw({client:y,path:{commentId:d},query:{workspaceId:I},body:b,...h()})),deleteComment:(d)=>x(ZL,_w({client:y,path:{commentId:d},query:{workspaceId:I},...h()})),mentions:dl,iterateMentions:(d,b)=>nt(dl,d??{},b),replyMention:(d,b)=>{let{idempotencyKey:W=crypto.randomUUID(),text:ce}=b;return Qt(W,()=>x(XL,Lw({client:y,path:{mentionId:d},query:{workspaceId:I},headers:{"idempotency-key":W},body:{text:ce},...h()})))},reviews:ul,iterateReviews:(d,b)=>nt(ul,d??{},b),review:(d)=>x(cI,Fw({client:y,path:{reviewId:d},query:{workspaceId:I},...h()})),capabilities:(d)=>x(YL,Bw({client:y,query:{workspaceId:I,accountId:d},...h()})),unreadCount:()=>x(JL,Nw({client:y,query:{workspaceId:I},...h()})),startSync:(d)=>x(eM,Kw({client:y,body:{workspaceId:I,accountId:d},...h()})),sync:(d)=>x(tM,qw({client:y,path:{syncRunId:d},query:{workspaceId:I},...h()})),attachment:(d)=>x(ha(Blob),$w({client:y,path:{attachmentId:d},query:{workspaceId:I},parseAs:"blob",...h()}))},ads:{accounts:ll,iterateAccounts:(d,b)=>nt(ll,d??{},b),connect:(d)=>x(oM,Yw({client:y,body:{...d,workspaceId:I},...h()})),connectApiKey:(d)=>x(iM,Zw({client:y,body:{...d,workspaceId:I},...h()})),select:(d)=>x(sM,oE({client:y,path:{accountId:d},query:{workspaceId:I},...h()})),disconnect:(d)=>x(aM,iE({client:y,path:{accountId:d},query:{workspaceId:I},...h()})),campaigns:fl,iterateCampaigns:(d,b)=>nt(fl,d??{},b),accountCampaigns:ml,adGroups:Ey,iterateAdGroups:(d,b)=>nt(Ey,d??{},b),ads:wr,iterateAds:(d,b)=>nt(wr,d??{},b),iterateAccountCampaigns:(d,b,W)=>nt((ce)=>ml(d,ce),b??{},W),tree:An,iterateTree:(d,b)=>nt(An,d??{},b),ad:(d)=>x(yh,dE({client:y,path:{adId:d},query:{workspaceId:I},...h()})),creatives:qo,creative:D1,createCreative:U1,iterateCreatives:(d,b)=>nt(qo,d??{},b),insights:CA,iterateInsights:(d,b)=>nt(CA,d??{},b),accountInsights:TA,iterateAccountInsights:(d,b,W)=>nt((ce)=>TA(d,ce),b??{},W),refresh:(d)=>x(wM,yE({client:y,path:{accountId:d},query:{workspaceId:I},...h()})),spendPolicy:L1,updateSpendPolicy:M1,setKillSwitch:F1,operation:N1,validateBoost:B1,validateCampaignPlan:K1,createCampaignPlan:q1,campaignPlan:(d)=>x(hM,nE({client:y,path:{planId:d},query:{workspaceId:I},...h()})),campaignPlans:PA,iterateCampaignPlans:(d,b)=>nt(PA,d??{},b),createBoost:(d,b,W={})=>{let ce=W.idempotencyKey??crypto.randomUUID();return Qt(ce,()=>x(sn,wE({client:y,path:{accountId:d},query:{workspaceId:I},headers:{"idempotency-key":ce},body:b,...h()})))},activateCampaign:(d,b,W,ce={})=>{let Ce=ce.idempotencyKey??crypto.randomUUID();return Qt(Ce,()=>x(sn,EE({client:y,path:{accountId:d,campaignId:b},query:{workspaceId:I},headers:{"idempotency-key":Ce},body:W,...h()})))},pauseCampaign:(d,b,W,ce={})=>{let Ce=ce.idempotencyKey??crypto.randomUUID();return Qt(Ce,()=>x(sn,kE({client:y,path:{accountId:d,campaignId:b},query:{workspaceId:I},headers:{"idempotency-key":Ce},body:W,...h()})))},archiveCampaign:(d,b,W,ce={})=>{let Ce=ce.idempotencyKey??crypto.randomUUID();return Qt(Ce,()=>x(sn,AE({client:y,path:{accountId:d,campaignId:b},query:{workspaceId:I},headers:{"idempotency-key":Ce},body:W,...h()})))},duplicateCampaign:(d,b,W,ce={})=>{let Ce=ce.idempotencyKey??crypto.randomUUID();return Qt(Ce,()=>x(sn,vE({client:y,path:{accountId:d,campaignId:b},query:{workspaceId:I},headers:{"idempotency-key":Ce},body:W,...h()})))},setCampaignBudget:(d,b,W,ce={})=>{let Ce=ce.idempotencyKey??crypto.randomUUID();return Qt(Ce,()=>x(sn,CE({client:y,path:{accountId:d,campaignId:b},query:{workspaceId:I},headers:{"idempotency-key":Ce},body:W,...h()})))},setAdGroupBudget:(d,b,W,ce={})=>{let Ce=ce.idempotencyKey??crypto.randomUUID();return Qt(Ce,()=>x(sn,TE({client:y,path:{accountId:d,adGroupId:b},query:{workspaceId:I},headers:{"idempotency-key":Ce},body:W,...h()})))},setAdGroupStatus:(d,b,W,ce={})=>{let Ce=ce.idempotencyKey??crypto.randomUUID();return Qt(Ce,()=>x(sn,OE({client:y,path:{accountId:d,adGroupId:b},query:{workspaceId:I},headers:{"idempotency-key":Ce},body:W,...h()})))},attachAd:(d,b,W,ce={})=>{let Ce=ce.idempotencyKey??crypto.randomUUID();return Qt(Ce,()=>x(sn,RE({client:y,path:{accountId:d,adGroupId:b},query:{workspaceId:I},headers:{"idempotency-key":Ce},body:W,...h()})))},createAdGroup:(d,b,W,ce={})=>{let Ce=ce.idempotencyKey??crypto.randomUUID();return Qt(Ce,()=>x(sn,PE({client:y,path:{accountId:d,campaignId:b},query:{workspaceId:I},headers:{"idempotency-key":Ce},body:W,...h()})))},setAdStatus:(d,b,W,ce={})=>{let Ce=ce.idempotencyKey??crypto.randomUUID();return Qt(Ce,()=>x(sn,_E({client:y,path:{accountId:d,adId:b},query:{workspaceId:I},headers:{"idempotency-key":Ce},body:W,...h()})))}},analytics:{post:(d,b={})=>x(RI,gw({client:y,path:{postId:d},query:{workspaceId:I,targetId:b.targetId,from:b.from,to:b.to,timezone:b.timezone,granularity:b.granularity,metrics:b.metrics&&[...b.metrics]},...h()})),series:(d,b={})=>x(RI,xw({client:y,path:{postId:d},query:{workspaceId:I,targetId:b.targetId,from:b.from,to:b.to,timezone:b.timezone,granularity:b.granularity,metrics:b.metrics&&[...b.metrics]},...h()})),accounts:As,iterateAccounts:(d,b)=>nt(As,d??{},b),account:(d,b={})=>x(UN,bw({client:y,path:{workspaceId:I,accountId:d},query:{from:b.from,to:b.to,timezone:b.timezone,granularity:b.granularity,metrics:b.metrics&&[...b.metrics]},...h()})),capabilities:()=>x(PN,Iw({client:y,path:{workspaceId:I},...h()})),refresh:(d)=>x(_I,ww({client:y,body:{workspaceId:I,postId:d.postId,targetId:d.targetId,metrics:d.metrics&&[...d.metrics]},...h()})),refreshStatus:(d)=>x(_I,Ew({client:y,path:{refreshId:d},query:{workspaceId:I},...h()}))},members:{list:(d={})=>x(dD,FE({client:y,path:{workspaceId:I},query:{...d,limit:d.limit?.toString()},...h()})),iterate:(d,b)=>nt(X(I).members.list,d??{},b),updateRole:(d,b)=>x(Xm,BE({client:y,path:{workspaceId:I,userId:d},body:b,...h()})),remove:(d)=>x(uD,NE({client:y,path:{workspaceId:I,userId:d},...h()}))},invites:{list:(d={})=>x(fD,KE({client:y,path:{workspaceId:I},query:{...d,limit:d.limit?.toString()},...h()})),iterate:(d,b)=>nt(X(I).invites.list,d??{},b),create:(d,b=crypto.randomUUID())=>Qt(b,async()=>({...await x(mD,qE({client:y,path:{workspaceId:I},body:d,headers:{"idempotency-key":b},...h()})),idempotencyKey:b})),resend:(d,b=crypto.randomUUID())=>Qt(b,async()=>({...await x(hD,$E({client:y,path:{workspaceId:I,inviteId:d},headers:{"idempotency-key":b},...h()})),idempotencyKey:b})),revoke:(d)=>x(yD,WE({client:y,path:{workspaceId:I,inviteId:d},...h()}))},audit:{list:le,iterate:(d,b)=>nt(le,d??{},b),get:(d)=>x(Ob,DE({client:y,path:{workspaceId:I,eventId:d},...h()}))},notifications:{getPreferences:()=>x(Pb,LE({client:y,path:{workspaceId:I},...h()})),updatePreferences:(d)=>x(Pb,ME({client:y,path:{workspaceId:I},body:d,...h()}))},billing:{get:()=>x(Cb,GE({client:y,path:{workspaceId:I},...h()})),usage:(d)=>x(ZU,zE({client:y,path:{workspaceId:I},query:d?{from:d.from,to:d.to,meter:d.meter,provider:d.provider}:void 0,...h()})),ledger:(d)=>x(XU,jE({client:y,path:{workspaceId:I},query:d?{kind:d.kind,from:d.from,to:d.to,cursor:d.cursor,limit:d.limit?.toString()}:void 0,...h()})),checkout:(d,b)=>{let W=b?.idempotencyKey,ce=()=>x(eD,QE({client:y,path:{workspaceId:I},body:d,...W?{headers:{"idempotency-key":W}}:{},...h()}));return W?Qt(W,ce):ce()},portal:(d)=>x(tD,HE({client:y,path:{workspaceId:I},body:d??{},...h()})),updateSpendControls:(d)=>x(Cb,VE({client:y,path:{workspaceId:I},body:d,...h()}))}}}return{me:{get:()=>x(wb,MI({client:y,...h()})),update:(I)=>x(wb,JN({client:y,body:I,...h()})),deactivate:()=>x(KU,VN({client:y,...h()})),invites:()=>x(gD,RB({client:y,...h()})),acceptInvite:(I)=>x(xD,_B({client:y,body:I,...h()})),declineInvite:(I)=>x(SD,UB({client:y,path:{inviteId:I},...h()}))},audit:{actions:()=>x(pD,YE({client:y,...h()}))},billing:{plans:()=>x(YU,JE({client:y,...h()}))},workspaces:{list:()=>x(MU,FI({client:y,...h()})),get:(I)=>x(ga,KI({client:y,path:{workspaceId:I},...h()})),create:(I)=>x(ga,NI({client:y,body:I,...h()})),update:(I,me)=>x(ga,qI({client:y,path:{workspaceId:I},body:me,...h()})),archive:(I)=>x(qU,BI({client:y,path:{workspaceId:I},...h()}))},workspace:(I)=>X(I)}}var st="~effect/cli/CliError",XE=(e)=>He(e,st),_h="~effect/cli/CliError/userMessage",FB=(e)=>(_h in e)&&typeof e[_h]==="string"?e[_h]:void 0;class va extends co(`${st}/UnrecognizedOption`)("UnrecognizedOption",{option:a,command:pb(U(a)),suggestions:U(a)}){[st]=st;get message(){let e=this.suggestions.length>0?`
39
+ `);re=de.pop()??"";for(let pe of de){let he=pe.split(`
40
+ `),ke=[],Oe;for(let Be of he)if(Be.startsWith("data:"))ke.push(Be.replace(/^data:\s*/,""));else if(Be.startsWith("event:"))Oe=Be.replace(/^event:\s*/,"");else if(Be.startsWith("id:"))g=Be.replace(/^id:\s*/,"");else if(Be.startsWith("retry:")){let fr=Number.parseInt(Be.replace(/^retry:\s*/,""),10);if(!Number.isNaN(fr))y=fr}let Se,Qe=!1;if(ke.length){let Be=ke.join(`
41
+ `);try{Se=JSON.parse(Be),Qe=!0}catch{Se=Be}}if(Qe){if(o)await o(Se);if(n)Se=await n(Se)}if(r?.({data:Se,event:Oe,id:g,retry:y}),ke.length)yield Se}}}finally{S.removeEventListener("abort",V),z.releaseLock()}break}catch(te){if(t?.(te),s!==void 0&&h>=s)break;let E=Math.min(y*2**(h-1),c??30000);await I(E)}}}()}}var L5=(e)=>{switch(e){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},M5=(e)=>{switch(e){case"form":return",";case"pipeDelimited":return"|";case"spaceDelimited":return"%20";default:return","}},F5=(e)=>{switch(e){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},cy=({allowReserved:e,explode:t,name:r,style:n,value:o})=>{if(!t){let c=(e?o:o.map((d)=>encodeURIComponent(d))).join(M5(n));switch(n){case"label":return`.${c}`;case"matrix":return`;${r}=${c}`;case"simple":return c;default:return`${r}=${c}`}}let i=L5(n),s=o.map((c)=>{if(n==="label"||n==="simple")return e?c:encodeURIComponent(c);return Rp({allowReserved:e,name:r,value:c})}).join(i);return n==="label"||n==="matrix"?i+s:s},Rp=({allowReserved:e,name:t,value:r})=>{if(r===void 0||r===null)return"";if(typeof r==="object")throw Error("Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these.");return`${t}=${e?r:encodeURIComponent(r)}`},py=({allowReserved:e,explode:t,name:r,style:n,value:o,valueOnly:i})=>{if(o instanceof Date)return i?o.toISOString():`${r}=${o.toISOString()}`;if(n!=="deepObject"&&!t){let d=[];Object.entries(o).forEach(([f,g])=>{d=[...d,f,e?g:encodeURIComponent(g)]});let x=d.join(",");switch(n){case"form":return`${r}=${x}`;case"label":return`.${x}`;case"matrix":return`;${r}=${x}`;default:return x}}let s=F5(n),c=Object.entries(o).map(([d,x])=>Rp({allowReserved:e,name:n==="deepObject"?`${r}[${d}]`:d,value:x})).join(s);return n==="label"||n==="matrix"?s+c:c};var N5=/\{[^{}]+\}/g,B5=({path:e,url:t})=>{let r=t,n=t.match(N5);if(n)for(let o of n){let i=!1,s=o.substring(1,o.length-1),c="simple";if(s.endsWith("*"))i=!0,s=s.substring(0,s.length-1);if(s.startsWith("."))s=s.substring(1),c="label";else if(s.startsWith(";"))s=s.substring(1),c="matrix";let d=e[s];if(d===void 0||d===null)continue;if(Array.isArray(d)){r=r.replace(o,cy({explode:i,name:s,style:c,value:d}));continue}if(typeof d==="object"){r=r.replace(o,py({explode:i,name:s,style:c,value:d,valueOnly:!0}));continue}if(c==="matrix"){r=r.replace(o,`;${Rp({name:s,value:d})}`);continue}let x=encodeURIComponent(c==="label"?`.${d}`:d);r=r.replace(o,x)}return r},A1=({baseUrl:e,path:t,query:r,querySerializer:n,url:o})=>{let i=o.startsWith("/")?o:`/${o}`,s=(e??"")+i;if(t)s=B5({path:t,url:s});let c=r?n(r):"";if(c.startsWith("?"))c=c.substring(1);if(c)s+=`?${c}`;return s};function NE(e){let t=e.body!==void 0;if(t&&e.bodySerializer){if("serializedBody"in e)return e.serializedBody!==void 0&&e.serializedBody!==""?e.serializedBody:null;return e.body!==""?e.body:null}if(t)return e.body;return}var v1=async(e,t)=>{let r=typeof t==="function"?await t(e):t;if(!r)return;if(e.scheme==="bearer")return`Bearer ${r}`;if(e.scheme==="basic")return`Basic ${btoa(r)}`;return r};var C1={bodySerializer:(e)=>JSON.stringify(e,(t,r)=>typeof r==="bigint"?r.toString():r)};var T1=({parameters:e={},...t}={})=>(n)=>{let o=[];if(n&&typeof n==="object")for(let i in n){let s=n[i];if(s===void 0||s===null)continue;let c=e[i]||t;if(Array.isArray(s)){let d=cy({allowReserved:c.allowReserved,explode:!0,name:i,style:"form",value:s,...c.array});if(d)o.push(d)}else if(typeof s==="object"){let d=py({allowReserved:c.allowReserved,explode:!0,name:i,style:"deepObject",value:s,...c.object});if(d)o.push(d)}else{let d=Rp({allowReserved:c.allowReserved,name:i,value:s});if(d)o.push(d)}}return o.join("&")},O1=(e)=>{if(!e)return"stream";let t=e.split(";")[0]?.trim();if(!t)return;if(t.startsWith("application/json")||t.endsWith("+json"))return"json";if(t==="multipart/form-data")return"formData";if(["application/","audio/","image/","video/"].some((r)=>t.startsWith(r)))return"blob";if(t.startsWith("text/"))return"text";return},K5=(e,t)=>{if(!t)return!1;if(e.headers.has(t)||e.query?.[t]||e.headers.get("Cookie")?.includes(`${t}=`))return!0;return!1};async function P1(e){for(let t of e.security??[]){if(K5(e,t.name))continue;let r=await v1(t,e.auth);if(!r)continue;let n=t.name??"Authorization";switch(t.in){case"query":if(!e.query)e.query={};e.query[n]=r;break;case"cookie":e.headers.append("Cookie",`${n}=${r}`);break;case"header":default:e.headers.set(n,r);break}}}var BE=(e)=>A1({baseUrl:e.baseUrl,path:e.path,query:e.query,querySerializer:typeof e.querySerializer==="function"?e.querySerializer:T1(e.querySerializer),url:e.url}),KE=(e,t)=>{let r={...e,...t};if(r.baseUrl?.endsWith("/"))r.baseUrl=r.baseUrl.substring(0,r.baseUrl.length-1);return r.headers=uy(e.headers,t.headers),r},q5=(e)=>{let t=[];return e.forEach((r,n)=>{t.push([n,r])}),t},uy=(...e)=>{let t=new Headers;for(let r of e){if(!r)continue;let n=r instanceof Headers?q5(r):Object.entries(r);for(let[o,i]of n)if(i===null)t.delete(o);else if(Array.isArray(i))for(let s of i)t.append(o,s);else if(i!==void 0)t.set(o,typeof i==="object"?JSON.stringify(i):i)}return t};class dy{fns=[];clear(){this.fns=[]}eject(e){let t=this.getInterceptorIndex(e);if(this.fns[t])this.fns[t]=null}exists(e){let t=this.getInterceptorIndex(e);return Boolean(this.fns[t])}getInterceptorIndex(e){if(typeof e==="number")return this.fns[e]?e:-1;return this.fns.indexOf(e)}update(e,t){let r=this.getInterceptorIndex(e);if(this.fns[r])return this.fns[r]=t,e;return!1}use(e){return this.fns.push(e),this.fns.length-1}}var R1=()=>({error:new dy,request:new dy,response:new dy}),$5=T1({allowReserved:!1,array:{explode:!0,style:"form"},object:{explode:!0,style:"deepObject"}}),W5={"Content-Type":"application/json"},pl=(e={})=>({...C1,headers:W5,parseAs:"auto",querySerializer:$5,...e});var dl=(e={})=>{let t=KE(pl(),e),r=()=>({...t}),n=(f)=>(t=KE(t,f),r()),o=R1(),i=async(f)=>{let g={...t,...f,fetch:f.fetch??t.fetch??globalThis.fetch,headers:uy(t.headers,f.headers),serializedBody:void 0};if(g.security)await P1(g);if(g.requestValidator)await g.requestValidator(g);if(g.body!==void 0&&g.bodySerializer)g.serializedBody=g.bodySerializer(g.body);if(g.body===void 0||g.serializedBody==="")g.headers.delete("Content-Type");let I=g,w=BE(I);return{opts:I,url:w}},s=async(f)=>{let g=f.throwOnError??t.throwOnError,I=f.responseStyle??t.responseStyle,w,A;try{let{opts:y,url:h}=await i(f),S={redirect:"follow",...y,body:NE(y)};w=new Request(h,S);for(let le of o.request.fns)if(le)w=await le(w,y);let H=y.fetch;A=await H(w);for(let le of o.response.fns)if(le)A=await le(A,w,y);let te={request:w,response:A};if(A.ok){let le=(y.parseAs==="auto"?O1(A.headers.get("Content-Type")):y.parseAs)??"json";if(A.status===204||A.headers.get("Content-Length")==="0"){let re;switch(le){case"arrayBuffer":case"blob":case"text":re=await A[le]();break;case"formData":re=new FormData;break;case"stream":re=A.body;break;case"json":default:re={};break}return y.responseStyle==="data"?re:{data:re,...te}}let z;switch(le){case"arrayBuffer":case"blob":case"formData":case"text":z=await A[le]();break;case"json":{let re=await A.text();z=re?JSON.parse(re):{};break}case"stream":return y.responseStyle==="data"?A.body:{data:A.body,...te}}if(le==="json"){if(y.responseValidator)await y.responseValidator(z);if(y.responseTransformer)z=await y.responseTransformer(z)}return y.responseStyle==="data"?z:{data:z,...te}}let E=await A.text(),ge;try{ge=JSON.parse(E)}catch{}throw ge??E}catch(y){let h=y;for(let S of o.error.fns)if(S)h=await S(h,A,w,f);if(h=h||{},g)throw h;return I==="data"?void 0:{error:h,request:w,response:A}}},c=(f)=>(g)=>s({...g,method:f}),d=(f)=>async(g)=>{let{opts:I,url:w}=await i(g);return w1({...I,body:I.body,method:f,onRequest:async(A,y)=>{let h=new Request(A,y);for(let S of o.request.fns)if(S)h=await S(h,I);return h},serializedBody:NE(I),url:w})};return{buildUrl:(f)=>BE({...t,...f}),connect:c("CONNECT"),delete:c("DELETE"),get:c("GET"),getConfig:r,head:c("HEAD"),interceptors:o,options:c("OPTIONS"),patch:c("PATCH"),post:c("POST"),put:c("PUT"),request:s,setConfig:n,sse:{connect:d("CONNECT"),delete:d("DELETE"),get:d("GET"),head:d("HEAD"),options:d("OPTIONS"),patch:d("PATCH"),post:d("POST"),put:d("PUT"),trace:d("TRACE")},trace:c("TRACE")}};async function*_1(e,t,{signal:r,maxPages:n}={}){if(n!==void 0&&(!Number.isSafeInteger(n)||n<1))throw RangeError("maxPages must be a whole number of at least 1.");let o=t.cursor,i=0,s=new Set;while(!0){if(r?.aborted)return;let c=await e(o===void 0?t:{...t,cursor:o});if(yield c,i++,!c.hasMore)return;if(c.nextCursor===void 0)throw Error("PubNio returned hasMore without a nextCursor for a cursor list.");if(s.has(c.nextCursor)||c.nextCursor===o)throw Error("PubNio returned a repeated pagination cursor.");if(n!==void 0&&i>=n)return;s.add(c.nextCursor),o=c.nextCursor}}async function*at(e,t,r){for await(let n of _1(e,t,r))yield*n.data}var G5=new Set([408,425,429]);function j5(e){if(e.status!==429&&e.status!==503)return;let t=e.headers.get("retry-after");if(!t)return;let r=Number(t);if(Number.isFinite(r)&&r>=0)return r*1000;let n=Date.parse(t);if(Number.isNaN(n))return;return Math.max(0,n-Date.now())}function U1(e){return 250*2**e}function D1(e,t){return new Promise((r,n)=>{if(t.aborted){n(t.reason??Error("The request was aborted."));return}let o=()=>{clearTimeout(s),t.removeEventListener("abort",i),r()},i=()=>{clearTimeout(s),t.removeEventListener("abort",i),n(t.reason??Error("The request was aborted."))},s=setTimeout(o,e);t.addEventListener("abort",i,{once:!0})})}function L1(e){let t=e.method.toUpperCase();return t==="GET"||t==="HEAD"||e.headers.has("idempotency-key")}function z5(e){return G5.has(e)||e>=500}function M1(e,{retries:t=2}={}){return async(r)=>{let n=r.signal;for(let o=0;;o++){let i;try{i=await e(r.clone())}catch(c){if(!L1(r)||o>=t||n.aborted)throw c;await D1(U1(o),n);continue}if(!L1(r)||!z5(i.status)||o>=t)return i;let s=Math.max(U1(o),j5(i)??0);i.body?.cancel().catch(()=>{return}),await D1(s,n)}}}var q=dl(pl({baseUrl:"/"}));var F1=(e)=>(e?.client??q).delete({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/me",...e}),qE=(e)=>(e?.client??q).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/me",...e}),N1=(e)=>(e.client??q).patch({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/me",...e,headers:{"Content-Type":"application/json",...e.headers}}),$E=(e)=>(e?.client??q).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/workspaces",...e}),WE=(e)=>(e.client??q).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/workspaces",...e,headers:{"Content-Type":"application/json",...e.headers}}),GE=(e)=>(e.client??q).delete({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/workspaces/{workspaceId}",...e}),jE=(e)=>(e.client??q).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/workspaces/{workspaceId}",...e}),zE=(e)=>(e.client??q).patch({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/workspaces/{workspaceId}",...e,headers:{"Content-Type":"application/json",...e.headers}}),QE=(e)=>(e.client??q).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/workspaces/{workspaceId}/api-keys",...e}),HE=(e)=>(e.client??q).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/workspaces/{workspaceId}/api-keys",...e,headers:{"Content-Type":"application/json",...e.headers}}),VE=(e)=>(e.client??q).delete({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/workspaces/{workspaceId}/api-keys/{keyId}",...e}),JE=(e)=>(e.client??q).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/workspaces/{workspaceId}/api-keys/{keyId}",...e}),YE=(e)=>(e.client??q).patch({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/workspaces/{workspaceId}/api-keys/{keyId}",...e,headers:{"Content-Type":"application/json",...e.headers}}),ZE=(e)=>(e.client??q).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/workspaces/{workspaceId}/webhook-endpoints",...e}),XE=(e)=>(e.client??q).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/workspaces/{workspaceId}/webhook-endpoints",...e,headers:{"Content-Type":"application/json",...e.headers}}),ek=(e)=>(e.client??q).delete({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/workspaces/{workspaceId}/webhook-endpoints/{endpointId}",...e}),tk=(e)=>(e.client??q).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/workspaces/{workspaceId}/webhook-endpoints/{endpointId}",...e}),rk=(e)=>(e.client??q).patch({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/workspaces/{workspaceId}/webhook-endpoints/{endpointId}",...e,headers:{"Content-Type":"application/json",...e.headers}}),nk=(e)=>(e.client??q).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/workspaces/{workspaceId}/webhook-endpoints/{endpointId}/test",...e}),ok=(e)=>(e.client??q).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/workspaces/{workspaceId}/webhook-endpoints/{endpointId}/deliveries",...e}),ik=(e)=>(e.client??q).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/workspaces/{workspaceId}/webhook-endpoints/{endpointId}/deliveries/{deliveryId}",...e}),sk=(e)=>(e.client??q).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/workspaces/{workspaceId}/webhook-endpoints/{endpointId}/deliveries/{deliveryId}/replay",...e}),Q5=(e)=>(e?.client??q).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/webhooks/event-types",...e}),B1=(e)=>(e.client??q).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/integrations",...e}),K1=(e)=>(e.client??q).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/integrations",...e,headers:{"Content-Type":"application/json",...e.headers}}),ak=(e)=>(e.client??q).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/integrations/accounts/{accountId}/profile",...e,headers:{"Content-Type":"application/json",...e.headers}}),q1=(e)=>(e.client??q).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/integrations/{provider}/connect",...e}),H5=(e)=>(e.client??q).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/integrations/bluesky/session",...e,headers:{"Content-Type":"application/json",...e.headers}}),$1=(e)=>(e.client??q).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/integrations/attempts/{attemptId}",...e}),ck=(e)=>(e.client??q).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/integrations/accounts/{accountId}",...e}),W1=(e)=>(e.client??q).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/integrations/accounts/{accountId}/reconnect",...e}),G1=(e)=>(e.client??q).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/integrations/accounts/{accountId}/instagram/publishing-limit",...e}),j1=(e)=>(e.client??q).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/integrations/accounts/{accountId}/instagram/audio",...e}),pk=(e)=>(e.client??q).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/integrations/accounts/{accountId}/instagram/audio/{audioId}",...e}),z1=(e)=>(e.client??q).delete({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/integrations/connections/{connectionId}",...e}),Q1=(e)=>(e.client??q).delete({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/integrations/connections/{connectionId}/permanent",...e}),dk=(e)=>(e.client??q).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/profiles",...e}),uk=(e)=>(e.client??q).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/profiles",...e,headers:{"Content-Type":"application/json",...e.headers}}),lk=(e)=>(e.client??q).delete({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/profiles/{profileId}",...e}),fk=(e)=>(e.client??q).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/profiles/{profileId}",...e}),mk=(e)=>(e.client??q).patch({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/profiles/{profileId}",...e,headers:{"Content-Type":"application/json",...e.headers}}),hk=(e)=>(e?.client??q).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/capabilities",...e}),yk=(e)=>(e.client??q).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/integrations/capabilities",...e}),gk=(e)=>(e?.client??q).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/capabilities/catalog",...e}),xk=(e)=>(e?.client??q).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/limits",...e}),Sk=(e)=>(e.client??q).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/media",...e}),H1=(e)=>(e.client??q).post({bodySerializer:null,security:[{scheme:"bearer",type:"http"}],url:"/api/v1/media",...e,headers:{"Content-Type":"application/octet-stream",...e.headers}}),bk=(e)=>(e.client??q).delete({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/media/{mediaId}",...e}),Ik=(e)=>(e.client??q).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/media/{mediaId}",...e});var V1=(e)=>(e.client??q).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/media/import",...e,headers:{"Content-Type":"application/json",...e.headers}}),ly=(e)=>(e.client??q).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/media/{mediaId}/status",...e}),J1=(e)=>(e.client??q).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/media/uploads",...e,headers:{"Content-Type":"application/json",...e.headers}}),Y1=(e)=>(e.client??q).put({bodySerializer:null,security:[{scheme:"bearer",type:"http"}],url:"/api/v1/media/uploads/{mediaId}/parts/{partNumber}",...e,headers:{"Content-Type":"application/octet-stream",...e.headers}}),Z1=(e)=>(e.client??q).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/media/uploads/{mediaId}/complete",...e}),X1=(e)=>(e.client??q).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/media/{mediaId}/content",...e}),eK=(e)=>(e.client??q).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/queues",...e}),tK=(e)=>(e.client??q).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/queues",...e,headers:{"Content-Type":"application/json",...e.headers}}),rK=(e)=>(e.client??q).delete({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/queues/{queueId}",...e}),nK=(e)=>(e.client??q).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/queues/{queueId}",...e}),oK=(e)=>(e.client??q).patch({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/queues/{queueId}",...e,headers:{"Content-Type":"application/json",...e.headers}}),iK=(e)=>(e.client??q).put({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/queues/{queueId}/slots",...e,headers:{"Content-Type":"application/json",...e.headers}}),sK=(e)=>(e.client??q).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/queues/{queueId}/next-slot",...e}),aK=(e)=>(e.client??q).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/queues/{queueId}/slots/preview",...e}),cK=(e)=>(e.client??q).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/queues/{queueId}/skips",...e}),pK=(e)=>(e.client??q).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/queues/{queueId}/skips",...e,headers:{"Content-Type":"application/json",...e.headers}}),dK=(e)=>(e.client??q).delete({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/queues/{queueId}/skips/{skipId}",...e}),uK=(e)=>(e.client??q).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/queues/{queueId}/blackouts",...e}),lK=(e)=>(e.client??q).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/queues/{queueId}/blackouts",...e,headers:{"Content-Type":"application/json",...e.headers}}),fK=(e)=>(e.client??q).delete({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/queues/{queueId}/blackouts/{blackoutId}",...e}),mK=(e)=>(e.client??q).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/schedule",...e}),hK=(e)=>(e.client??q).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/posts/{postId}/targets/{targetId}/schedule",...e,headers:{"Content-Type":"application/json",...e.headers}}),Ek=(e)=>(e.client??q).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/analytics/posts/{postId}",...e}),kk=(e)=>(e.client??q).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/analytics/posts/{postId}/series",...e}),wk=(e)=>(e.client??q).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/workspaces/{workspaceId}/analytics/accounts",...e}),Ak=(e)=>(e.client??q).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/workspaces/{workspaceId}/analytics/accounts/{accountId}",...e}),vk=(e)=>(e.client??q).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/workspaces/{workspaceId}/analytics/capabilities",...e}),Ck=(e)=>(e.client??q).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/analytics/refreshes",...e,headers:{"Content-Type":"application/json",...e.headers}}),Tk=(e)=>(e.client??q).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/analytics/refreshes/{refreshId}",...e}),Ok=(e)=>(e.client??q).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/inbox/conversations",...e}),Pk=(e)=>(e.client??q).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/inbox/conversations/{conversationId}",...e}),Rk=(e)=>(e.client??q).patch({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/inbox/conversations/{conversationId}",...e,headers:{"Content-Type":"application/json",...e.headers}}),_k=(e)=>(e.client??q).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/inbox/conversations/{conversationId}/messages",...e}),Uk=(e)=>(e.client??q).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/inbox/conversations/{conversationId}/messages",...e,headers:{"Content-Type":"application/json",...e.headers}}),Dk=(e)=>(e.client??q).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/inbox/comments",...e}),Lk=(e)=>(e.client??q).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/inbox/comments/{threadId}",...e}),Mk=(e)=>(e.client??q).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/inbox/comments/{commentId}/replies",...e,headers:{"Content-Type":"application/json",...e.headers}}),Fk=(e)=>(e.client??q).delete({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/inbox/comments/{commentId}",...e}),Nk=(e)=>(e.client??q).patch({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/inbox/comments/{commentId}",...e,headers:{"Content-Type":"application/json",...e.headers}}),Bk=(e)=>(e.client??q).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/inbox/mentions",...e}),Kk=(e)=>(e.client??q).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/inbox/mentions/{mentionId}/reply",...e,headers:{"Content-Type":"application/json",...e.headers}}),qk=(e)=>(e.client??q).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/inbox/reviews",...e}),$k=(e)=>(e.client??q).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/inbox/reviews/{reviewId}",...e}),V5=(e)=>(e.client??q).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/inbox/reviews/{reviewId}/replies",...e,headers:{"Content-Type":"application/json",...e.headers}}),Wk=(e)=>(e.client??q).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/inbox/unread-count",...e}),Gk=(e)=>(e.client??q).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/inbox/capabilities",...e}),jk=(e)=>(e.client??q).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/inbox/sync",...e,headers:{"Content-Type":"application/json",...e.headers}}),zk=(e)=>(e.client??q).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/inbox/sync/{syncRunId}",...e}),Qk=(e)=>(e.client??q).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/inbox/attachments/{attachmentId}",...e}),J5=(e)=>(e.client??q).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/comments",...e,headers:{"Content-Type":"application/json",...e.headers}}),yK=(e)=>(e.client??q).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/posts",...e}),Hk=(e)=>(e.client??q).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/posts",...e,headers:{"Content-Type":"application/json",...e.headers}}),gK=(e)=>(e.client??q).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/posts/validate",...e,headers:{"Content-Type":"application/json",...e.headers}}),Vk=(e)=>(e.client??q).delete({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/posts/{postId}",...e}),Jk=(e)=>(e.client??q).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/posts/{postId}",...e}),Yk=(e)=>(e.client??q).patch({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/posts/{postId}",...e,headers:{"Content-Type":"application/json",...e.headers}}),xK=(e)=>(e.client??q).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/posts/{postId}/validate",...e}),SK=(e)=>(e.client??q).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/posts/{postId}/publish",...e,headers:{"Content-Type":"application/json",...e.headers}}),Zk=(e)=>(e.client??q).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/posts/{postId}/targets/{targetId}/attempts",...e}),Xk=(e)=>(e.client??q).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/posts/{postId}/targets/{targetId}/retry",...e,headers:{"Content-Type":"application/json",...e.headers}}),ew=(e)=>(e.client??q).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/posts/{postId}/targets/{targetId}/reconcile",...e,headers:{"Content-Type":"application/json",...e.headers}}),tw=(e)=>(e.client??q).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/ads/accounts",...e}),rw=(e)=>(e.client??q).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/ads/accounts/connect",...e,headers:{"Content-Type":"application/json",...e.headers}}),nw=(e)=>(e.client??q).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/ads/accounts/connect/api-key",...e,headers:{"Content-Type":"application/json",...e.headers}}),ow=(e)=>(e.client??q).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/ads/campaigns/validate",...e,headers:{"Content-Type":"application/json",...e.headers}}),iw=(e)=>(e.client??q).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/ads/campaigns",...e}),sw=(e)=>(e.client??q).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/ads/campaigns",...e,headers:{"Content-Type":"application/json",...e.headers}}),aw=(e)=>(e.client??q).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/ads/plans",...e}),cw=(e)=>(e.client??q).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/ads/plans/{planId}",...e}),pw=(e)=>(e.client??q).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/ads/accounts/{accountId}/select",...e}),dw=(e)=>(e.client??q).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/ads/accounts/{accountId}/disconnect",...e}),uw=(e)=>(e.client??q).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/ads/accounts/{accountId}/campaigns",...e}),lw=(e)=>(e.client??q).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/ads/tree",...e}),fw=(e)=>(e.client??q).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/ads/ads",...e}),mw=(e)=>(e.client??q).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/ads/ad-groups",...e}),hw=(e)=>(e.client??q).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/ads/ads/{adId}",...e}),yw=(e)=>(e.client??q).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/ads/creatives",...e}),gw=(e)=>(e.client??q).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/ads/accounts/{accountId}/creatives",...e,headers:{"Content-Type":"application/json",...e.headers}}),xw=(e)=>(e.client??q).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/ads/creatives/{creativeId}",...e}),Sw=(e)=>(e.client??q).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/ads/insights",...e}),bw=(e)=>(e.client??q).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/ads/accounts/{accountId}/insights",...e}),Iw=(e)=>(e.client??q).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/ads/accounts/{accountId}/insights/refresh",...e}),Ew=(e)=>(e.client??q).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/ads/accounts/{accountId}/spend-policy",...e}),kw=(e)=>(e.client??q).put({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/ads/accounts/{accountId}/spend-policy",...e,headers:{"Content-Type":"application/json",...e.headers}}),ww=(e)=>(e.client??q).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/ads/accounts/{accountId}/kill-switch",...e,headers:{"Content-Type":"application/json",...e.headers}}),Aw=(e)=>(e.client??q).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/ads/accounts/{accountId}/operations/{operationId}",...e}),vw=(e)=>(e.client??q).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/ads/accounts/{accountId}/boosts/validate",...e,headers:{"Content-Type":"application/json",...e.headers}}),Cw=(e)=>(e.client??q).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/ads/accounts/{accountId}/boosts",...e,headers:{"Content-Type":"application/json",...e.headers}}),Tw=(e)=>(e.client??q).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/ads/accounts/{accountId}/campaigns/{campaignId}/activate",...e,headers:{"Content-Type":"application/json",...e.headers}}),Ow=(e)=>(e.client??q).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/ads/accounts/{accountId}/campaigns/{campaignId}/pause",...e,headers:{"Content-Type":"application/json",...e.headers}}),Pw=(e)=>(e.client??q).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/ads/accounts/{accountId}/campaigns/{campaignId}/archive",...e,headers:{"Content-Type":"application/json",...e.headers}}),Rw=(e)=>(e.client??q).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/ads/accounts/{accountId}/campaigns/{campaignId}/duplicate",...e,headers:{"Content-Type":"application/json",...e.headers}}),_w=(e)=>(e.client??q).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/ads/accounts/{accountId}/campaigns/{campaignId}/budget",...e,headers:{"Content-Type":"application/json",...e.headers}}),Uw=(e)=>(e.client??q).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/ads/accounts/{accountId}/ad-groups/{adGroupId}/budget",...e,headers:{"Content-Type":"application/json",...e.headers}}),Dw=(e)=>(e.client??q).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/ads/accounts/{accountId}/ad-groups/{adGroupId}/status",...e,headers:{"Content-Type":"application/json",...e.headers}}),Lw=(e)=>(e.client??q).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/ads/accounts/{accountId}/campaigns/{campaignId}/ad-groups",...e,headers:{"Content-Type":"application/json",...e.headers}}),Mw=(e)=>(e.client??q).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/ads/accounts/{accountId}/ad-groups/{adGroupId}/ads",...e,headers:{"Content-Type":"application/json",...e.headers}}),Fw=(e)=>(e.client??q).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/ads/accounts/{accountId}/ads/{adId}/status",...e,headers:{"Content-Type":"application/json",...e.headers}}),Nw=(e)=>(e.client??q).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/workspaces/{workspaceId}/audit-logs",...e}),Bw=(e)=>(e.client??q).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/workspaces/{workspaceId}/audit-logs/{eventId}",...e}),Kw=(e)=>(e.client??q).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/workspaces/{workspaceId}/notification-preferences",...e}),qw=(e)=>(e.client??q).patch({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/workspaces/{workspaceId}/notification-preferences",...e,headers:{"Content-Type":"application/json",...e.headers}}),$w=(e)=>(e.client??q).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/workspaces/{workspaceId}/members",...e}),Ww=(e)=>(e.client??q).delete({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/workspaces/{workspaceId}/members/{userId}",...e}),Gw=(e)=>(e.client??q).patch({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/workspaces/{workspaceId}/members/{userId}",...e,headers:{"Content-Type":"application/json",...e.headers}}),jw=(e)=>(e.client??q).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/workspaces/{workspaceId}/invites",...e}),zw=(e)=>(e.client??q).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/workspaces/{workspaceId}/invites",...e,headers:{"Content-Type":"application/json",...e.headers}}),Qw=(e)=>(e.client??q).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/workspaces/{workspaceId}/invites/{inviteId}/resend",...e}),Hw=(e)=>(e.client??q).delete({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/workspaces/{workspaceId}/invites/{inviteId}",...e}),bK=(e)=>(e?.client??q).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/me/invites",...e}),IK=(e)=>(e.client??q).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/me/invites/accept",...e,headers:{"Content-Type":"application/json",...e.headers}}),EK=(e)=>(e.client??q).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/me/invites/{inviteId}/decline",...e}),Vw=(e)=>(e.client??q).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/workspaces/{workspaceId}/billing",...e}),Jw=(e)=>(e.client??q).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/workspaces/{workspaceId}/billing/usage",...e}),Yw=(e)=>(e.client??q).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/workspaces/{workspaceId}/billing/ledger",...e}),Zw=(e)=>(e.client??q).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/workspaces/{workspaceId}/billing/checkout",...e,headers:{"Content-Type":"application/json",...e.headers}}),Xw=(e)=>(e.client??q).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/workspaces/{workspaceId}/billing/portal",...e,headers:{"Content-Type":"application/json",...e.headers}}),eA=(e)=>(e.client??q).patch({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/workspaces/{workspaceId}/billing/spend-controls",...e,headers:{"Content-Type":"application/json",...e.headers}}),tA=(e)=>(e?.client??q).get({url:"/api/v1/billing/plans",...e}),rA=(e)=>(e?.client??q).get({url:"/api/v1/audit-logs/actions",...e});var Y5=ws(f1),Z5=ws(L(rB)),X5=ws(L(wo)),eY=ws(L(cl)),tY=ws(L(a)),rY=ws(o5);class oo extends Error{failure;constructor(e){super(e.kind==="http"?e.problem?.detail??`PubNio request failed (HTTP ${e.status}).`:e.kind==="transport"?"Could not reach PubNio.":"PubNio returned a response that does not match its API contract.");this.failure=e;this.name="PubNioError"}get kind(){return this.failure.kind}get status(){return this.failure.kind==="transport"?void 0:this.failure.status}get requestId(){if(this.failure.kind==="transport")return;if(this.failure.requestId)return this.failure.requestId;let e=this.problem;return typeof e?.requestId==="string"?e.requestId:void 0}get problem(){return this.failure.kind==="http"?this.failure.problem:void 0}get knownProblem(){let e=Y5(this.problem);return e._tag==="Some"?e.value:void 0}get problemType(){return this.problem?.type}isProblem(e){return e.startsWith("urn:")&&this.problemType===e}get code(){let e=this.problem;if(typeof e?.code==="string")return e.code;let t="urn:pubnio:problem:";return typeof this.problemType==="string"&&this.problemType.startsWith(t)?this.problemType.slice(t.length).replaceAll("-","_"):void 0}get param(){let e=this.problem;return typeof e?.param==="string"?e.param:void 0}get nextAction(){let e=this.problem;return typeof e?.nextAction==="string"?e.nextAction:void 0}get candidates(){let e=this.problem,t=eY(e?.candidates);return t._tag==="Some"?t.value:[]}get supportedVersions(){let e=this.problem,t=tY(e?.supportedVersions);return t._tag==="Some"?t.value:[]}get currentRevision(){let e=this.knownProblem;return e?.type==="urn:pubnio:problem:post-revision-conflict"?e.currentRevision:void 0}get currentAttemptId(){let e=this.knownProblem;return e?.type==="urn:pubnio:problem:attempt-changed"?e.currentAttemptId:void 0}get retryable(){if(this.failure.kind==="transport")return!0;if(this.failure.kind!=="http")return!1;let{status:e}=this.failure;return e===408||e===429||e>=500}get idempotencyKey(){if(this.failure.idempotencyKey!==void 0)return this.failure.idempotencyKey;let e=this.problem;return typeof e?.idempotencyKey==="string"?e.idempotencyKey:void 0}get requestIssues(){let e=Z5(this.problem?.errors);return e._tag==="Some"?e.value:[]}get issues(){let e=X5(this.problem?.issues);return e._tag==="Some"?e.value:[]}}var nY="https://pubnio.com",oY=60000,iY=2,kK=300000,sY=2000;function nA(e,t){if(!Number.isSafeInteger(e)||e<0||e>3600000)throw RangeError(`${t} must be a whole number between 0 and 3600000.`);return e}function aY(e){if(!Number.isSafeInteger(e)||e<0||e>5)throw RangeError("retries must be a whole number between 0 and 5.");return e}function cY(e){return e===0?void 0:AbortSignal.timeout(e)}function wK(e){let t=e.filter((r)=>!!r);if(t.length===0)return;return t.length===1?t[0]:AbortSignal.any(t)}function pY(e,t){return new Promise((r)=>{if(t?.aborted){r();return}let n=()=>{clearTimeout(o),t?.removeEventListener("abort",n),r()},o=setTimeout(n,e);t?.addEventListener("abort",n,{once:!0})})}function dY(e){return{accounts:e.accounts.map(({id:t,provider:r,accountKind:n,name:o,enabled:i,readiness:s})=>({accountId:t,provider:r,accountKind:n,name:o,enabled:i,readiness:s}))}}function rr(e,t){return t().catch((r)=>{if(r instanceof oo&&r.idempotencyKey===void 0)throw new oo({...r.failure,idempotencyKey:e});throw r})}function AK(e){return e.map((t)=>({...t}))}function uY(e,t){return new oo({kind:"http",status:404,problem:{type:"urn:pubnio:problem:target-not-found",status:404,title:"Delivery target not found",detail:`Target ${t} is not part of post ${e}.`,code:"target_not_found",param:"targetId",nextAction:`Read posts.status("${e}") and retry with a current targetId.`}})}function lY(e,t){return new oo({kind:"http",status:422,problem:{type:"urn:pubnio:problem:schedule-required",status:422,title:"Schedule required",detail:`Target ${t} on post ${e} is not assigned to a schedule queue.`,code:"schedule_required",param:"queueId",nextAction:"Use schedule.change with an explicit scheduledAt to reschedule this target, or pass queueId to assign it to a queue."}})}async function fY(e){let t=new Uint8Array(await crypto.subtle.digest("SHA-256",await e.arrayBuffer()));return btoa(String.fromCharCode(...t)).replaceAll("+","-").replaceAll("/","_").replace(/=+$/,"")}function Xa({baseUrl:e=nY,accessToken:t,apiKey:r,fetch:n,headers:o,timeoutMs:i=oY,signal:s,retries:c=iY,clientName:d="sdk",clientVersion:x=k1.version,onRuntime:f}){let g=nA(i,"timeoutMs"),I=aY(c),w=r??t,A=new Headers(o);if(!A.has("x-pubnio-client"))A.set("x-pubnio-client",`${d}/${x}`);A.set(dN,IE);let y=dl({baseUrl:e.toString().replace(/\/+$/,""),headers:A,...w?{auth:w,redirect:"error"}:{},fetch:M1((E)=>n?n(E):fetch(E),{retries:I})});function h(E={},ge=g){let le=wK([s,E.signal,cY(E.timeoutMs===void 0?ge:nA(E.timeoutMs,"timeoutMs"))]);return le?{signal:le}:{}}async function S(E,ge){let{data:le,error:z,response:re}=await ge.catch(()=>{throw new oo({kind:"transport"})});if(!re)throw new oo({kind:"transport"});let{status:V}=re,ne=re.headers.get(tB)??void 0;if(!re.ok){let pe=re.headers.get("content-type")?.split(";",1)[0]?.trim().toLowerCase()===iy?rY(z):void 0;throw new oo({kind:"http",status:V,...pe?._tag==="Some"?{problem:pe.value}:{},...ne?{requestId:ne}:{}})}let ie=()=>new oo({kind:"invalid_response",status:V,...ne?{requestId:ne}:{}});if(z!==void 0)throw ie();return bJ(E)(le).catch(()=>{throw ie()})}f?.({client:y,transport:h,decode:S});async function H(E,ge,{timeoutMs:le=60000,signal:z}={}){let re=nA(le,"timeoutMs"),V=performance.now()+re,ne=new AbortController,ie=re===0?void 0:setTimeout(()=>ne.abort(),re),de=()=>ne.abort();z?.addEventListener("abort",de,{once:!0});let pe=wK([z,ne.signal]);try{let he=await E(pe);while(!ge(he)){let ke=V-performance.now();if(ke<=0||pe.aborted)return{value:he,settled:!1};if(await pY(Math.min(sY,ke),pe),performance.now()>=V||pe.aborted)return{value:he,settled:!1};try{he=await E(pe)}catch(Oe){if(pe.aborted)return{value:he,settled:!1};throw Oe}}return{value:he,settled:!0}}finally{clearTimeout(ie),z?.removeEventListener("abort",de)}}function te(E){let ge=(l,b)=>S(Tp,Jk({client:y,path:{postId:l},query:{workspaceId:E},...h(b)})),le=async(l,b)=>{let Q=await ge(l,b);return{postId:Q.postId,status:Q.status,targets:Q.deliveries}},z=(l,b)=>S(Va,ly({client:y,path:{mediaId:l},query:{workspaceId:E},...h(b)}));async function re(l,b){let Q=typeof l==="string"?b:l;if(!(Q instanceof Blob))throw TypeError("Choose a media file to upload.");let ue=typeof l==="string"?l:b instanceof Blob?void 0:b?.mimeType,Re=b instanceof Blob?void 0:b,Xr=Re?.timeoutMs??kK,Qs=Re?.signal,ai=Re?.idempotencyKey??crypto.randomUUID(),ci={timeoutMs:Xr,signal:Qs};if(Q.size<=Dh){let Hs=ue??tM(new Uint8Array(await Q.slice(0,64).arrayBuffer()));if(!Hs)throw TypeError("Choose a supported image or video file.");return S(Va,H1({client:y,query:{workspaceId:E,mimeType:Hs},headers:{"idempotency-key":ai},body:Q,...h(ci)}))}let{mediaId:fc,partSizeBytes:Gl}=await S(iM,J1({client:y,query:{workspaceId:E},headers:{"idempotency-key":ai},body:{sizeBytes:Q.size},...h(ci)})),zi=await S(Va,ly({client:y,path:{mediaId:fc},query:{workspaceId:E},...h(ci)}));if(zi.status==="ready")return zi;if(zi.status!=="awaiting_upload"||!zi.upload)throw Error(`Media upload could not resume${zi.status==="failed"&&zi.issue?` (${zi.issue.code})`:""}.`);let{receivedPartCount:U2,partDigests:D2}=zi.upload;for(let Hs=0,Qp=1;Hs<Q.size;Hs+=Gl,Qp++){let cg=Q.slice(Hs,Hs+Gl);if(Qp<=U2){if(await fY(cg)!==D2[Qp-1])throw Error("The selected file does not match this upload session. Use a new idempotency key for a different file.");continue}await S(sM,Y1({client:y,path:{mediaId:fc,partNumber:String(Qp)},query:{workspaceId:E},headers:{"content-length":String(cg.size),"idempotency-key":`${ai}-part-${Qp}`},body:cg,...h(ci)}))}let Lv=await S(Va,Z1({client:y,path:{mediaId:fc},query:{workspaceId:E},headers:{"idempotency-key":`${ai}-complete`},...h(ci)}));if(Lv.status!=="ready")throw Error("The upload could not be finalized. Check the media status before retrying.");return Lv}async function V(l){let{idempotencyKey:b=crypto.randomUUID(),...Q}=l;return rr(b,async()=>{let ue=Q;if(Q.isDraft)return S(Tp,Hk({client:y,query:{workspaceId:E},headers:{"idempotency-key":b},body:ue,...h()}));return{...await S(Qa,Hk({client:y,query:{workspaceId:E},headers:{"idempotency-key":b},body:ue,...h()})),idempotencyKey:b}})}let ne=({cursor:l,limit:b,isDraft:Q,deliveryStatus:ue,accountId:Re,profileId:Xr}={})=>S(vL,yK({client:y,query:{workspaceId:E,cursor:l,limit:b?.toString(),isDraft:Q===void 0?void 0:Q?"true":"false",deliveryStatus:ue,accountId:Re,profileId:Xr},...h()})),ie=(l,b,{cursor:Q,limit:ue}={})=>S(CL,Zk({client:y,path:{postId:l,targetId:b},query:{workspaceId:E,cursor:Q,limit:ue?.toString()},...h()})),de=({cursor:l,limit:b,type:Q}={})=>S(rM,Sk({client:y,query:{workspaceId:E,cursor:l,limit:b?.toString(),type:Q},...h()})),pe=({cursor:l,limit:b,includeArchived:Q}={})=>S(uN,dk({client:y,query:{workspaceId:E,includeArchived:Q?"true":void 0,cursor:l,limit:b===void 0?void 0:String(b)},...h()})),he=({cursor:l,limit:b,action:Q,targetKind:ue,targetId:Re,actorType:Xr,actorId:Qs,profileId:ai,from:ci,to:fc}={})=>S(BL,Nw({client:y,path:{workspaceId:E},query:{cursor:l,limit:b?.toString(),action:Q,targetKind:ue,targetId:Re,actorType:Xr,actorId:Qs,profileId:ai,from:ci,to:fc},...h()})),ke=({cursor:l,limit:b}={})=>S(ZL,QE({client:y,path:{workspaceId:E},query:{cursor:l,limit:b?.toString()},...h()})),Oe=({cursor:l,limit:b}={})=>S(bN,ZE({client:y,path:{workspaceId:E},query:{cursor:l,limit:b?.toString()},...h()})),Se=(l,{cursor:b,limit:Q}={})=>S(kN,ok({client:y,path:{workspaceId:E,endpointId:l},query:{cursor:b,limit:Q?.toString()},...h()})),Qe=({accountId:l,cursor:b,limit:Q}={})=>S(aF,eK({client:y,query:{workspaceId:E,accountId:l,cursor:b,limit:Q===void 0?void 0:String(Q)},...h()})),Be=({from:l,to:b,accountId:Q,queueId:ue,cursor:Re,limit:Xr})=>S(kF,mK({client:y,query:{workspaceId:E,from:l,to:b,accountId:Q,queueId:ue,cursor:Re,limit:Xr===void 0?void 0:String(Xr)},...h()})),fr=(l,b)=>S(yF,sK({client:y,path:{queueId:l},query:{workspaceId:E,after:b},...h()})),kr=(l,b,Q)=>S(AI,hK({client:y,path:{postId:l,targetId:b},query:{workspaceId:E},body:Q,...h()})),Zr=async(l,b,Q={})=>{let Re=(await le(l)).targets.find((Gl)=>Gl.targetId===b);if(!Re)throw uY(l,b);let Xr=Q.queueId??Re.queueId;if(!Xr)throw lY(l,b);let Qs=await fr(Xr,Re.scheduledAt??new Date().toISOString());if(!Qs.occurrence)return{skipped:!1,horizonEndsAt:Qs.horizonEndsAt};let{slotId:ai,occurrenceDate:ci}=Qs.occurrence;if(!ai)throw new oo({kind:"http",status:409,problem:{type:"urn:pubnio:problem:conflict",status:409,title:"Conflict",detail:"The next queue occurrence is not bound to a slot.",code:"conflict",param:"queueId",nextAction:"Read the queue slots, then retry with a queue that has active slots."}});return{skipped:!0,result:await kr(l,b,{expectedAttemptId:Q.expectedAttemptId??Re.attemptId,action:"reschedule",queueId:Xr,pinned:{slotId:ai,occurrenceDate:ci}})}},Gs=(l,{cursor:b,limit:Q}={})=>S(SF,cK({client:y,path:{queueId:l},query:{workspaceId:E,cursor:b,limit:Q===void 0?void 0:String(Q)},...h()})),js=(l,{cursor:b,limit:Q}={})=>S(EF,uK({client:y,path:{queueId:l},query:{workspaceId:E,cursor:b,limit:Q===void 0?void 0:String(Q)},...h()})),zs=(l={})=>{let b={accountId:l.accountIds&&[...l.accountIds],platform:l.provider,from:l.from,to:l.to,timezone:l.timezone,granularity:l.granularity,metrics:l.metrics&&[...l.metrics],cursor:l.cursor,limit:l.limit===void 0?void 0:String(l.limit)};return S(E1,wk({client:y,path:{workspaceId:E},query:b,...h()}))},Ro=(l={})=>S(PF,Ok({client:y,query:{workspaceId:E,accountId:l.accountId,provider:l.provider,status:l.status,folder:l.folder,unread:l.unread===void 0?void 0:l.unread?"true":"false",search:l.search,cursor:l.cursor,limit:l.limit===void 0?void 0:String(l.limit)},...h()})),Ml=(l,b={})=>S(RF,_k({client:y,path:{conversationId:l},query:{workspaceId:E,order:b.order,cursor:b.cursor,limit:b.limit===void 0?void 0:String(b.limit)},...h()})),Fl=(l={})=>S(_F,Dk({client:y,query:{workspaceId:E,accountId:l.accountId,postId:l.postId,providerPostId:l.providerPostId,unread:l.unread===void 0?void 0:l.unread?"true":"false",cursor:l.cursor,limit:l.limit===void 0?void 0:String(l.limit)},...h()})),Nl=(l,b={})=>S(UF,Lk({client:y,path:{threadId:l},query:{workspaceId:E,cursor:b.cursor,limit:b.limit===void 0?void 0:String(b.limit)},...h()})),Bl=(l={})=>S(DF,Bk({client:y,query:{workspaceId:E,accountId:l.accountId,provider:l.provider,cursor:l.cursor,limit:l.limit===void 0?void 0:String(l.limit)},...h()})),Kl=(l={})=>S(LF,qk({client:y,query:{workspaceId:E,accountId:l.accountId,includeDeleted:l.includeDeleted===void 0?void 0:l.includeDeleted?"true":"false",cursor:l.cursor,limit:l.limit===void 0?void 0:String(l.limit)},...h()})),ql=(l={})=>S(WF,tw({client:y,query:{workspaceId:E,state:l.state,cursor:l.cursor,limit:l.limit===void 0?void 0:String(l.limit)},...h()})),$l=(l={})=>S(SE,iw({client:y,query:{workspaceId:E,accountId:l.accountId,provider:l.provider,status:l.status,managed:l.managed,cursor:l.cursor,limit:l.limit===void 0?void 0:String(l.limit)},...h()})),Wl=(l,b={})=>S(SE,uw({client:y,path:{accountId:l},query:{workspaceId:E,provider:b.provider,status:b.status,managed:b.managed,cursor:b.cursor,limit:b.limit===void 0?void 0:String(b.limit)},...h()})),ag=(l={})=>S(oN,mw({client:y,query:{workspaceId:E,accountId:l.accountId,campaignId:l.campaignId,provider:l.provider,status:l.status,from:l.from,to:l.to,cursor:l.cursor,limit:l.limit===void 0?void 0:String(l.limit)},...h()})),Dr=(l={})=>S(iN,fw({client:y,query:{workspaceId:E,accountId:l.accountId,campaignId:l.campaignId,adGroupId:l.adGroupId,provider:l.provider,status:l.status,from:l.from,to:l.to,cursor:l.cursor,limit:l.limit===void 0?void 0:String(l.limit)},...h()})),Un=(l={})=>S(aN,lw({client:y,query:{workspaceId:E,accountId:l.accountId,campaignId:l.campaignId,cursor:l.cursor,limit:l.limit===void 0?void 0:String(l.limit)},...h()})),si=(l={})=>S(sN,yw({client:y,query:{workspaceId:E,accountId:l.accountId,adId:l.adId,cursor:l.cursor,limit:l.limit===void 0?void 0:String(l.limit)},...h()})),w2=(l,b,Q={})=>{let ue=Q.idempotencyKey??crypto.randomUUID();return rr(ue,()=>S(fn,gw({client:y,path:{accountId:l},query:{workspaceId:E},headers:{"idempotency-key":ue},body:b,...h()})))},A2=(l)=>S(nl,xw({client:y,path:{creativeId:l},query:{workspaceId:E},...h()})),Rv=(l={})=>S(bE,Sw({client:y,query:{workspaceId:E,accountId:l.accountId,campaignId:l.campaignId,adGroupId:l.adGroupId,adId:l.adId,level:l.level,from:l.from,to:l.to,metrics:l.metrics&&[...l.metrics],cursor:l.cursor,limit:l.limit===void 0?void 0:String(l.limit)},...h()})),_v=(l,b={})=>S(bE,bw({client:y,path:{accountId:l},query:{workspaceId:E,campaignId:b.campaignId,adGroupId:b.adGroupId,adId:b.adId,level:b.level,from:b.from,to:b.to,metrics:b.metrics&&[...b.metrics],cursor:b.cursor,limit:b.limit===void 0?void 0:String(b.limit)},...h()})),v2=(l)=>S(Vh,Ew({client:y,path:{accountId:l},query:{workspaceId:E},...h()})),C2=(l,b)=>S(Vh,kw({client:y,path:{accountId:l},query:{workspaceId:E},body:b,...h()})),T2=(l,b)=>S($F,ww({client:y,path:{accountId:l},query:{workspaceId:E},body:b,...h()})),O2=(l,b)=>S(fn,Aw({client:y,path:{accountId:l,operationId:b},query:{workspaceId:E},...h()})),P2=(l,b)=>S(JF,vw({client:y,path:{accountId:l},query:{workspaceId:E},body:b,...h()})),Uv=(l)=>({...l,...l.budget?{budget:{...l.budget}}:{},...l.schedule?{schedule:{...l.schedule}}:{},...l.providerSettings?{providerSettings:{...l.providerSettings}}:{},targets:l.targets.map((b)=>({...b,...b.budget?{budget:{...b.budget}}:{},...b.schedule?{schedule:{...b.schedule}}:{},...b.providerSettings?{providerSettings:{...b.providerSettings}}:{}})),adGroups:l.adGroups.map((b)=>({...b,...b.budget?{budget:{...b.budget}}:{},...b.targeting?{targeting:{...b.targeting}}:{},...b.providerSettings?{providerSettings:{...b.providerSettings}}:{},ads:b.ads.map((Q)=>({...Q,...Q.providerSettings?{providerSettings:{...Q.providerSettings}}:{},creative:{...Q.creative.headline!==void 0?{headline:Q.creative.headline}:{},...Q.creative.body!==void 0?{body:Q.creative.body}:{},...Q.creative.callToAction!==void 0?{callToAction:Q.creative.callToAction}:{},...Q.creative.destinationUrl!==void 0?{destinationUrl:Q.creative.destinationUrl}:{},...Q.creative.media?{media:Q.creative.media.map((ue)=>({...ue}))}:{},...Q.creative.providerSettings?{providerSettings:{...Q.creative.providerSettings}}:{}}}))}))}),R2=(l)=>S(YF,ow({client:y,query:{workspaceId:E},body:Uv(l),...h()})),_2=(l,b={})=>{let Q=b.idempotencyKey??crypto.randomUUID();return rr(Q,()=>S(XF,sw({client:y,query:{workspaceId:E},headers:{"idempotency-key":Q},body:Uv(l),...h()})))},Dv=(l={})=>S(eN,aw({client:y,query:{workspaceId:E,status:l.status,cursor:l.cursor,limit:l.limit===void 0?void 0:String(l.limit)},...h()}));return{workspaceId:E,posts:{list:ne,iterate:(l,b)=>at(ne,l??{},b),create:V,get:ge,update:(l,b)=>S(Tp,Yk({client:y,path:{postId:l},query:{workspaceId:E},body:b,...h()})),validate:(l)=>S(eE,xK({client:y,path:{postId:l},query:{workspaceId:E},...h()})),validateBody:(l)=>S(eE,gK({client:y,query:{workspaceId:E},body:l,...h()})),publish:(l,b)=>{let{idempotencyKey:Q=crypto.randomUUID(),...ue}=b;return rr(Q,async()=>({...await S(Qa,SK({client:y,path:{postId:l},query:{workspaceId:E},headers:{"idempotency-key":Q},body:{expectedRevision:ue.expectedRevision,scheduledAt:ue.scheduledAt,accountIds:ue.accountIds&&[...ue.accountIds],targets:ue.targets&&[...ue.targets]},...h()})),idempotencyKey:Q}))},delete:(l)=>S(nF,Vk({client:y,path:{postId:l},query:{workspaceId:E},...h()})),status:le,attempts:ie,iterateAttempts:(l,b,Q,ue)=>at((Re)=>ie(l,b,Re),Q??{},ue),retry:(l,b,Q)=>S(AI,Xk({client:y,path:{postId:l,targetId:b},query:{workspaceId:E},body:Q,...h()})),reconcile:(l,b,Q)=>S(vI,ew({client:y,path:{postId:l,targetId:b},query:{workspaceId:E},body:Q,...h()})),wait:async(l,b)=>{let{value:Q,settled:ue}=await H((Re)=>le(l,{signal:Re}),(Re)=>AL(Re.status),b);return{settled:ue,post:Q,...ue?{}:{retryAfterSeconds:2}}}},media:{list:de,iterate:(l,b)=>at(de,l??{},b),delete:(l)=>S(nM,bk({client:y,path:{mediaId:l},query:{workspaceId:E},...h()})),importUrl:(l,b={})=>{let{idempotencyKey:Q=crypto.randomUUID(),signal:ue,timeoutMs:Re}=b;return rr(Q,async()=>({...await S(Va,V1({client:y,query:{workspaceId:E},headers:{"idempotency-key":Q},body:{url:l},...h({timeoutMs:Re,signal:ue})})),idempotencyKey:Q}))},status:z,upload:re,get:(l)=>S(Va,Ik({client:y,path:{mediaId:l},query:{workspaceId:E},...h()})),download:(l)=>S($a(Blob),X1({client:y,path:{mediaId:l},query:{workspaceId:E},parseAs:"blob",...h()})),wait:async(l,b)=>{let{value:Q}=await H((ue)=>z(l,{signal:ue}),(ue)=>ue.status==="ready"||ue.status==="failed",{timeoutMs:b?.timeoutMs??kK,signal:b?.signal});if(Q.status==="ready"&&Q.asset)return{mediaId:Q.mediaId,status:"ready",asset:Q.asset};if(Q.status==="failed"&&Q.issue)return{mediaId:Q.mediaId,status:"failed",issue:Q.issue};return{mediaId:Q.mediaId,status:"timeout",retryAfterSeconds:2}}},accounts:{list:async(l)=>{let b=typeof l==="string"?{profileId:l}:l,Q=await S(qI,B1({client:y,query:{workspaceId:E,profileId:b?.profileId,ready:b?.ready===void 0?void 0:b.ready?"true":"false",includeAdAccounts:b?.includeAdAccounts===void 0?void 0:b.includeAdAccounts?"true":"false"},...h()}));return b?.ready?dY(Q):Q},get:(l,b)=>S(vp,ck({client:y,path:{accountId:l},query:{workspaceId:E,includeAdAccounts:b?.includeAdAccounts===void 0?void 0:b.includeAdAccounts?"true":"false"},...h()})),move:(l,b)=>S(vp,ak({client:y,path:{accountId:l},query:{workspaceId:E},body:b,...h()})),setEnabled:(l)=>S(vp,K1({client:y,query:{workspaceId:E},body:l,...h()})),prepareConnection:(l,b,Q)=>S(GI,q1({client:y,path:{provider:l},query:{workspaceId:E,loginMethod:b,profileId:Q},...h()})),connectionStatus:(l)=>S(xM,$1({client:y,path:{attemptId:l},query:{workspaceId:E},...h()})),reconnect:(l,b)=>S(GI,W1({client:y,path:{accountId:l},query:{workspaceId:E,loginMethod:b},...h()})),disconnect:(l)=>S(SM,z1({client:y,path:{connectionId:l},query:{workspaceId:E},...h()})),delete:(l)=>S(bM,Q1({client:y,path:{connectionId:l},query:{workspaceId:E},...h()})),instagramPublishingLimit:(l)=>S(IM,G1({client:y,path:{accountId:l},query:{workspaceId:E},...h()})),searchInstagramAudio:(l,b)=>S(EM,j1({client:y,path:{accountId:l},query:{workspaceId:E,...b},...h()})),getInstagramAudio:(l,b)=>S(jI,pk({client:y,path:{accountId:l,audioId:b},query:{workspaceId:E},...h()}))},profiles:{list:pe,iterate:(l,b)=>at(pe,l??{},b),create:(l)=>S(ol,uk({client:y,query:{workspaceId:E},body:l,...h()})),get:(l)=>S(ol,fk({client:y,path:{profileId:l},query:{workspaceId:E},...h()})),update:(l,b)=>S(ol,mk({client:y,path:{profileId:l},query:{workspaceId:E},body:b,...h()})),archive:(l)=>S(lN,lk({client:y,path:{profileId:l},query:{workspaceId:E},...h()}))},capabilities:{list:(l={})=>S(dM,yk({client:y,query:{workspaceId:E,profileId:l.profileId,accountId:l.accountId,capability:l.capability},...h()})),catalog:()=>S(uM,gk({client:y})),get:()=>S(hM,hk({client:y}))},limits:{get:()=>S(BI,xk({client:y}))},apiKeys:{create:(l)=>S(YL,HE({client:y,path:{workspaceId:E},body:{...l,scopes:l.scopes&&[...l.scopes]},...h()})),list:ke,iterate:(l,b)=>at(ke,l??{},b),get:(l)=>S(ju,JE({client:y,path:{workspaceId:E,keyId:l},...h()})),update:(l,b)=>S(ju,YE({client:y,path:{workspaceId:E,keyId:l},body:{...b,scopes:b.scopes&&[...b.scopes]},...h()})),revoke:(l)=>S(XL,VE({client:y,path:{workspaceId:E,keyId:l},...h()}))},webhooks:{create:(l)=>{let{eventTypes:b,accountIds:Q,disabledResourceGroups:ue,...Re}=l;return S(SN,XE({client:y,path:{workspaceId:E},body:{...Re,eventTypes:[...b],...Q?{accountIds:[...Q]}:{},...ue?{disabledResourceGroups:[...ue]}:{}},...h()}))},list:Oe,iterate:(l,b)=>at(Oe,l??{},b),get:(l)=>S(OE,tk({client:y,path:{workspaceId:E,endpointId:l},...h()})),update:(l,b)=>{let{eventTypes:Q,accountIds:ue,disabledResourceGroups:Re,...Xr}=b;return S(ry,rk({client:y,path:{workspaceId:E,endpointId:l},body:{...Xr,eventTypes:Q?.slice(),...ue===void 0?{}:{accountIds:ue===null?null:[...ue]},...Re===void 0?{}:{disabledResourceGroups:Re===null?null:[...Re]}},...h()}))},delete:(l)=>S(IN,ek({client:y,path:{workspaceId:E,endpointId:l},...h()})),test:(l)=>S(EN,nk({client:y,path:{workspaceId:E,endpointId:l},...h()})),listDeliveries:Se,iterateDeliveries:(l,b,Q)=>at((ue)=>Se(l,ue),b??{},Q),getDelivery:(l,b)=>S(ny,ik({client:y,path:{workspaceId:E,endpointId:l,deliveryId:b},...h()})),replayDelivery:(l,b)=>S(ny,sk({client:y,path:{workspaceId:E,endpointId:l,deliveryId:b},...h()}))},queues:{list:Qe,iterate:(l,b)=>at(Qe,l??{},b),create:(l)=>S(Pp,tK({client:y,query:{workspaceId:E},body:{...l,slots:AK(l.slots)},...h()})),get:(l)=>S(Pp,nK({client:y,path:{queueId:l},query:{workspaceId:E},...h()})),update:(l,b)=>S(Pp,oK({client:y,path:{queueId:l},query:{workspaceId:E},body:b,...h()})),archive:(l,b)=>S(cF,rK({client:y,path:{queueId:l},query:{workspaceId:E,expectedVersion:String(b)},...h()})),replaceSlots:(l,b)=>S(Pp,iK({client:y,path:{queueId:l},query:{workspaceId:E},body:{expectedVersion:b.expectedVersion,slots:AK(b.slots)},...h()})),nextSlot:fr,previewSlots:(l,{count:b,after:Q,includeOccupied:ue})=>S(gF,aK({client:y,path:{queueId:l},query:{workspaceId:E,count:String(b),after:Q,includeOccupied:ue===void 0?void 0:ue?"true":"false"},...h()})),skips:Gs,iterateSkips:(l,b,Q)=>at((ue)=>Gs(l,ue),b??{},Q),skip:(l,b,Q)=>S(tE,pK({client:y,path:{queueId:l},query:{workspaceId:E},body:{slotId:b,occurrenceDate:Q},...h()})),unskip:(l,b)=>S(nE,dK({client:y,path:{queueId:l,skipId:b},query:{workspaceId:E},...h()})),blackouts:js,iterateBlackouts:(l,b,Q)=>at((ue)=>js(l,ue),b??{},Q),blackout:(l,b)=>S(rE,lK({client:y,path:{queueId:l},query:{workspaceId:E},body:b,...h()})),unblackout:(l,b)=>S(nE,fK({client:y,path:{queueId:l,blackoutId:b},query:{workspaceId:E},...h()}))},schedule:{list:Be,iterateRange:(l,b)=>at(Be,l,b),change:kr,skipToNext:Zr},inbox:{conversations:Ro,iterateConversations:(l,b)=>at(Ro,l??{},b),conversation:(l)=>S(zh,Pk({client:y,path:{conversationId:l},query:{workspaceId:E},...h()})),updateConversation:(l,b)=>S(zh,Rk({client:y,path:{conversationId:l},query:{workspaceId:E},body:b,...h()})),messages:Ml,iterateMessages:(l,b,Q)=>at((ue)=>Ml(l,ue),b??{},Q),sendMessage:(l,b)=>{let{idempotencyKey:Q=crypto.randomUUID(),text:ue}=b;return rr(Q,()=>S(uE,Uk({client:y,path:{conversationId:l},query:{workspaceId:E},headers:{"idempotency-key":Q},body:{text:ue},...h()})))},comments:Fl,iterateComments:(l,b)=>at(Fl,l??{},b),thread:Nl,iterateThread:(l,b,Q)=>at((ue)=>Nl(l,ue),b??{},Q),replyComment:(l,b)=>{let{idempotencyKey:Q=crypto.randomUUID(),text:ue}=b;return rr(Q,()=>S(Qh,Mk({client:y,path:{commentId:l},query:{workspaceId:E},headers:{"idempotency-key":Q},body:{text:ue},...h()})))},moderateComment:(l,b)=>S(Qh,Nk({client:y,path:{commentId:l},query:{workspaceId:E},body:b,...h()})),deleteComment:(l)=>S(NF,Fk({client:y,path:{commentId:l},query:{workspaceId:E},...h()})),mentions:Bl,iterateMentions:(l,b)=>at(Bl,l??{},b),replyMention:(l,b)=>{let{idempotencyKey:Q=crypto.randomUUID(),text:ue}=b;return rr(Q,()=>S(BF,Kk({client:y,path:{mentionId:l},query:{workspaceId:E},headers:{"idempotency-key":Q},body:{text:ue},...h()})))},reviews:Kl,iterateReviews:(l,b)=>at(Kl,l??{},b),review:(l)=>S(lE,$k({client:y,path:{reviewId:l},query:{workspaceId:E},...h()})),capabilities:(l)=>S(FF,Gk({client:y,query:{workspaceId:E,accountId:l},...h()})),unreadCount:()=>S(MF,Wk({client:y,query:{workspaceId:E},...h()})),startSync:(l)=>S(KF,jk({client:y,body:{workspaceId:E,accountId:l},...h()})),sync:(l)=>S(qF,zk({client:y,path:{syncRunId:l},query:{workspaceId:E},...h()})),attachment:(l)=>S($a(Blob),Qk({client:y,path:{attachmentId:l},query:{workspaceId:E},parseAs:"blob",...h()}))},ads:{accounts:ql,iterateAccounts:(l,b)=>at(ql,l??{},b),connect:(l)=>S(GF,rw({client:y,body:{...l,workspaceId:E},...h()})),connectApiKey:(l)=>S(jF,nw({client:y,body:{...l,workspaceId:E},...h()})),select:(l)=>S(zF,pw({client:y,path:{accountId:l},query:{workspaceId:E},...h()})),disconnect:(l)=>S(QF,dw({client:y,path:{accountId:l},query:{workspaceId:E},...h()})),campaigns:$l,iterateCampaigns:(l,b)=>at($l,l??{},b),accountCampaigns:Wl,adGroups:ag,iterateAdGroups:(l,b)=>at(ag,l??{},b),ads:Dr,iterateAds:(l,b)=>at(Dr,l??{},b),iterateAccountCampaigns:(l,b,Q)=>at((ue)=>Wl(l,ue),b??{},Q),tree:Un,iterateTree:(l,b)=>at(Un,l??{},b),ad:(l)=>S(Yh,hw({client:y,path:{adId:l},query:{workspaceId:E},...h()})),creatives:si,creative:A2,createCreative:w2,iterateCreatives:(l,b)=>at(si,l??{},b),insights:Rv,iterateInsights:(l,b)=>at(Rv,l??{},b),accountInsights:_v,iterateAccountInsights:(l,b,Q)=>at((ue)=>_v(l,ue),b??{},Q),refresh:(l)=>S(cN,Iw({client:y,path:{accountId:l},query:{workspaceId:E},...h()})),spendPolicy:v2,updateSpendPolicy:C2,setKillSwitch:T2,operation:O2,validateBoost:P2,validateCampaignPlan:R2,createCampaignPlan:_2,campaignPlan:(l)=>S(tN,cw({client:y,path:{planId:l},query:{workspaceId:E},...h()})),campaignPlans:Dv,iterateCampaignPlans:(l,b)=>at(Dv,l??{},b),createBoost:(l,b,Q={})=>{let ue=Q.idempotencyKey??crypto.randomUUID();return rr(ue,()=>S(fn,Cw({client:y,path:{accountId:l},query:{workspaceId:E},headers:{"idempotency-key":ue},body:b,...h()})))},activateCampaign:(l,b,Q,ue={})=>{let Re=ue.idempotencyKey??crypto.randomUUID();return rr(Re,()=>S(fn,Tw({client:y,path:{accountId:l,campaignId:b},query:{workspaceId:E},headers:{"idempotency-key":Re},body:Q,...h()})))},pauseCampaign:(l,b,Q,ue={})=>{let Re=ue.idempotencyKey??crypto.randomUUID();return rr(Re,()=>S(fn,Ow({client:y,path:{accountId:l,campaignId:b},query:{workspaceId:E},headers:{"idempotency-key":Re},body:Q,...h()})))},archiveCampaign:(l,b,Q,ue={})=>{let Re=ue.idempotencyKey??crypto.randomUUID();return rr(Re,()=>S(fn,Pw({client:y,path:{accountId:l,campaignId:b},query:{workspaceId:E},headers:{"idempotency-key":Re},body:Q,...h()})))},duplicateCampaign:(l,b,Q,ue={})=>{let Re=ue.idempotencyKey??crypto.randomUUID();return rr(Re,()=>S(fn,Rw({client:y,path:{accountId:l,campaignId:b},query:{workspaceId:E},headers:{"idempotency-key":Re},body:Q,...h()})))},setCampaignBudget:(l,b,Q,ue={})=>{let Re=ue.idempotencyKey??crypto.randomUUID();return rr(Re,()=>S(fn,_w({client:y,path:{accountId:l,campaignId:b},query:{workspaceId:E},headers:{"idempotency-key":Re},body:Q,...h()})))},setAdGroupBudget:(l,b,Q,ue={})=>{let Re=ue.idempotencyKey??crypto.randomUUID();return rr(Re,()=>S(fn,Uw({client:y,path:{accountId:l,adGroupId:b},query:{workspaceId:E},headers:{"idempotency-key":Re},body:Q,...h()})))},setAdGroupStatus:(l,b,Q,ue={})=>{let Re=ue.idempotencyKey??crypto.randomUUID();return rr(Re,()=>S(fn,Dw({client:y,path:{accountId:l,adGroupId:b},query:{workspaceId:E},headers:{"idempotency-key":Re},body:Q,...h()})))},attachAd:(l,b,Q,ue={})=>{let Re=ue.idempotencyKey??crypto.randomUUID();return rr(Re,()=>S(fn,Mw({client:y,path:{accountId:l,adGroupId:b},query:{workspaceId:E},headers:{"idempotency-key":Re},body:Q,...h()})))},createAdGroup:(l,b,Q,ue={})=>{let Re=ue.idempotencyKey??crypto.randomUUID();return rr(Re,()=>S(fn,Lw({client:y,path:{accountId:l,campaignId:b},query:{workspaceId:E},headers:{"idempotency-key":Re},body:Q,...h()})))},setAdStatus:(l,b,Q,ue={})=>{let Re=ue.idempotencyKey??crypto.randomUUID();return rr(Re,()=>S(fn,Fw({client:y,path:{accountId:l,adId:b},query:{workspaceId:E},headers:{"idempotency-key":Re},body:Q,...h()})))}},analytics:{post:(l,b={})=>S(ME,Ek({client:y,path:{postId:l},query:{workspaceId:E,targetId:b.targetId,from:b.from,to:b.to,timezone:b.timezone,granularity:b.granularity,metrics:b.metrics&&[...b.metrics]},...h()})),series:(l,b={})=>S(ME,kk({client:y,path:{postId:l},query:{workspaceId:E,targetId:b.targetId,from:b.from,to:b.to,timezone:b.timezone,granularity:b.granularity,metrics:b.metrics&&[...b.metrics]},...h()})),accounts:zs,iterateAccounts:(l,b)=>at(zs,l??{},b),account:(l,b={})=>S(I1,Ak({client:y,path:{workspaceId:E,accountId:l},query:{from:b.from,to:b.to,timezone:b.timezone,granularity:b.granularity,metrics:b.metrics&&[...b.metrics]},...h()})),capabilities:()=>S(x1,vk({client:y,path:{workspaceId:E},...h()})),refresh:(l)=>S(FE,Ck({client:y,body:{workspaceId:E,postId:l.postId,targetId:l.targetId,metrics:l.metrics&&[...l.metrics]},...h()})),refreshStatus:(l)=>S(FE,Tk({client:y,path:{refreshId:l},query:{workspaceId:E},...h()}))},members:{list:(l={})=>S(qL,$w({client:y,path:{workspaceId:E},query:{...l,limit:l.limit?.toString()},...h()})),iterate:(l,b)=>at(te(E).members.list,l??{},b),updateRole:(l,b)=>S(Uh,Gw({client:y,path:{workspaceId:E,userId:l},body:b,...h()})),remove:(l)=>S($L,Ww({client:y,path:{workspaceId:E,userId:l},...h()}))},invites:{list:(l={})=>S(GL,jw({client:y,path:{workspaceId:E},query:{...l,limit:l.limit?.toString()},...h()})),iterate:(l,b)=>at(te(E).invites.list,l??{},b),create:(l,b=crypto.randomUUID())=>rr(b,async()=>({...await S(jL,zw({client:y,path:{workspaceId:E},body:l,headers:{"idempotency-key":b},...h()})),idempotencyKey:b})),resend:(l,b=crypto.randomUUID())=>rr(b,async()=>({...await S(zL,Qw({client:y,path:{workspaceId:E,inviteId:l},headers:{"idempotency-key":b},...h()})),idempotencyKey:b})),revoke:(l)=>S(QL,Hw({client:y,path:{workspaceId:E,inviteId:l},...h()}))},audit:{list:he,iterate:(l,b)=>at(he,l??{},b),get:(l)=>S(PI,Bw({client:y,path:{workspaceId:E,eventId:l},...h()}))},notifications:{getPreferences:()=>S(RI,Kw({client:y,path:{workspaceId:E},...h()})),updatePreferences:(l)=>S(RI,qw({client:y,path:{workspaceId:E},body:l,...h()}))},billing:{get:()=>S(TI,Vw({client:y,path:{workspaceId:E},...h()})),usage:(l)=>S(OL,Jw({client:y,path:{workspaceId:E},query:l?{from:l.from,to:l.to,meter:l.meter,provider:l.provider}:void 0,...h()})),ledger:(l)=>S(PL,Yw({client:y,path:{workspaceId:E},query:l?{kind:l.kind,from:l.from,to:l.to,cursor:l.cursor,limit:l.limit?.toString()}:void 0,...h()})),checkout:(l,b)=>{let Q=b?.idempotencyKey,ue=()=>S(RL,Zw({client:y,path:{workspaceId:E},body:l,...Q?{headers:{"idempotency-key":Q}}:{},...h()}));return Q?rr(Q,ue):ue()},portal:(l)=>S(_L,Xw({client:y,path:{workspaceId:E},body:l??{},...h()})),updateSpendControls:(l)=>S(TI,eA({client:y,path:{workspaceId:E},body:l,...h()}))}}}return{me:{get:()=>S(kI,qE({client:y,...h()})),update:(E)=>S(kI,N1({client:y,body:E,...h()})),deactivate:()=>S(gL,F1({client:y,...h()})),invites:()=>S(HL,bK({client:y,...h()})),acceptInvite:(E)=>S(VL,IK({client:y,body:E,...h()})),declineInvite:(E)=>S(JL,EK({client:y,path:{inviteId:E},...h()}))},audit:{actions:()=>S(KL,rA({client:y,...h()}))},billing:{plans:()=>S(TL,tA({client:y,...h()}))},workspaces:{list:()=>S(fL,$E({client:y,...h()})),get:(E)=>S(za,jE({client:y,path:{workspaceId:E},...h()})),create:(E)=>S(za,WE({client:y,body:E,...h()})),update:(E,ge)=>S(za,zE({client:y,path:{workspaceId:E},body:ge,...h()})),archive:(E)=>S(xL,GE({client:y,path:{workspaceId:E},...h()}))},workspace:(E)=>te(E)}}var ut="~effect/cli/CliError",oA=(e)=>Ye(e,ut),fy="~effect/cli/CliError/userMessage",vK=(e)=>(fy in e)&&typeof e[fy]==="string"?e[fy]:void 0;class ec extends Eo(`${ut}/UnrecognizedOption`)("UnrecognizedOption",{option:a,command:sI(L(a)),suggestions:L(a)}){[ut]=ut;get message(){let e=this.suggestions.length>0?`
41
42
 
42
43
  Did you mean this?
43
44
  ${this.suggestions.join(`
44
- `)}`:"";return(this.command?`Unrecognized flag: ${this.option} in command ${this.command.join(" ")}`:`Unrecognized flag: ${this.option}`)+e}}class Uh extends co(`${st}/DuplicateOption`)("DuplicateOption",{option:a,parentCommand:a,childCommand:a}){[st]=st;get message(){return`Duplicate flag name "${this.option}" in parent command "${this.parentCommand}" and subcommand "${this.childCommand}". Parent will always claim this flag (Mode A semantics). Consider renaming one of them to avoid confusion.`}}class Mu extends co(`${st}/MissingOption`)("MissingOption",{option:a}){[st]=st;get message(){return`Missing required flag: --${this.option}`}}class Fu extends co(`${st}/MissingArgument`)("MissingArgument",{argument:a}){[st]=st;get message(){return`Missing required argument: ${this.argument}`}}class Dh extends co(`${st}/UnexpectedArgument`)("UnexpectedArgument",{arguments:U(a)}){[st]=st;get message(){return`Unexpected positional ${this.arguments.length===1?"argument":"arguments"}: ${this.arguments.map((t)=>JSON.stringify(t)).join(", ")}`}}class En extends co(`${st}/InvalidValue`)("InvalidValue",{option:a,value:a,expected:a,kind:pt([v("flag"),v("argument")])}){[st]=st;get message(){let e=this.expected.startsWith("Expected ")||this.expected.startsWith("Expected:")?this.expected:`Expected: ${this.expected}`;if(this.kind==="argument")return`Invalid value for argument <${this.option}>: "${this.value}". ${e}`;if(this.value.length===0)return`Missing value for flag --${this.option}. ${e}`;return`Invalid value for flag --${this.option}: "${this.value}". ${e}`}}class Lh extends co(`${st}/UnknownSubcommand`)("UnknownSubcommand",{subcommand:a,parent:pb(U(a)),suggestions:U(a)}){[st]=st;get message(){let e=this.suggestions.length>0?`
45
+ `)}`:"";return(this.command?`Unrecognized flag: ${this.option} in command ${this.command.join(" ")}`:`Unrecognized flag: ${this.option}`)+e}}class my extends Eo(`${ut}/DuplicateOption`)("DuplicateOption",{option:a,parentCommand:a,childCommand:a}){[ut]=ut;get message(){return`Duplicate flag name "${this.option}" in parent command "${this.parentCommand}" and subcommand "${this.childCommand}". Parent will always claim this flag (Mode A semantics). Consider renaming one of them to avoid confusion.`}}class ul extends Eo(`${ut}/MissingOption`)("MissingOption",{option:a}){[ut]=ut;get message(){return`Missing required flag: --${this.option}`}}class ll extends Eo(`${ut}/MissingArgument`)("MissingArgument",{argument:a}){[ut]=ut;get message(){return`Missing required argument: ${this.argument}`}}class hy extends Eo(`${ut}/UnexpectedArgument`)("UnexpectedArgument",{arguments:L(a)}){[ut]=ut;get message(){return`Unexpected positional ${this.arguments.length===1?"argument":"arguments"}: ${this.arguments.map((t)=>JSON.stringify(t)).join(", ")}`}}class Rn extends Eo(`${ut}/InvalidValue`)("InvalidValue",{option:a,value:a,expected:a,kind:st([v("flag"),v("argument")])}){[ut]=ut;get message(){let e=this.expected.startsWith("Expected ")||this.expected.startsWith("Expected:")?this.expected:`Expected: ${this.expected}`;if(this.kind==="argument")return`Invalid value for argument <${this.option}>: "${this.value}". ${e}`;if(this.value.length===0)return`Missing value for flag --${this.option}. ${e}`;return`Invalid value for flag --${this.option}: "${this.value}". ${e}`}}class yy extends Eo(`${ut}/UnknownSubcommand`)("UnknownSubcommand",{subcommand:a,parent:sI(L(a)),suggestions:L(a)}){[ut]=ut;get message(){let e=this.suggestions.length>0?`
45
46
 
46
47
  Did you mean this?
47
48
  ${this.suggestions.join(`
48
- `)}`:"";return this.parent?`Unknown subcommand "${this.subcommand}" for "${this.parent.join(" ")}"${e}`:`Unknown subcommand "${this.subcommand}"${e}`}}class NB extends co(`${st}/ValidationError`)("ValidationError",{message:a}){[st]=st}class Nu extends co(`${st}/UserError`)("UserError",{cause:yU(),userMessage:u(a)}){[st]=st;[uu]=!0;get message(){if(this.userMessage)return this.userMessage;if(typeof this.cause==="string"&&this.cause)return this.cause;if(this.cause instanceof Error&&this.cause.message)return this.cause.message;return"An error occurred"}get[_h](){return this.message}}var G6=pt([va,Uh,Mu,Fu,Dh,En,Lh,NB,Nu]);class Si extends co(`${st}/ShowHelp`)("ShowHelp",{commandPath:U(a),errors:U(G6)}){[st]=st;[PU]=this.errors.length?1:0;[uu]=!1;get message(){return"Help requested"}}var z6="~effect/cli/Primitive",j6={[z6]:{_A:Ee}},BB=cb(lb),KB=cb(fb),ek=(e)=>e._tag==="Boolean",tk=(e,t)=>Object.assign(Object.create(j6),{_tag:e,parse:t}),qB=(e,t)=>{let r=bU(t),n=rs(r);return tk(e,(o)=>Rr(n(o),(i)=>i.message))},$B=qB("Boolean",lU);var WB=qB("Int",M);var GB=tk("String",(e)=>j(e)),zB=(e)=>{let t=new Map(e),r=e.map(([o])=>rt(o)).join(" | "),n=tk("Choice",(o)=>{if(t.has(o))return j(t.get(o));return he(r)});return Object.assign(n,{choiceKeys:e.map(([o])=>o)})};var Bu=(e)=>{switch(e._tag){case"Boolean":return"boolean";case"String":return"string";case"Int":return"integer";case"Finite":return"number";case"Date":return"date";case"Path":return"path";case"Choice":return"choice";case"Redacted":return"string";case"FileText":return"file";case"FileParse":return"file";case"FileSchema":return"file";case"KeyValuePair":return"key=value";case"Never":return"none";default:return"value"}},bi=(e)=>e._tag==="Choice"?e.choiceKeys:void 0,rk=(e)=>e._tag==="Path"?e.pathType:void 0;var Ii="\x1B[1m",jB="\x1B[3m",Ca="\x1B[4m",QB="\x1B[9m",HB="\x1B[?25h",Ku="\x1B[?25l",Ta="\x1B[G",Mh="\x1B[s",Fh="\x1B[u",hs="\x1B[2K",VB="\x07",Nh="\x1B[31m",Bh="\x1B[32m",JB="\x1B[35m",Oa="\x1B[37m",qu="\x1B[90m",pp="\x1B[96m",wt=(e,t,...r)=>{if(!e)return t;return`${r.flat().join("")}${t}\x1B[0m`},Kh=()=>{let e=globalThis.process;return typeof e==="object"&&e!==null&&typeof e.stdout==="object"&&e.stdout!==null&&e.stdout.isTTY===!0&&!e.env?.NO_COLOR},Fo=(...e)=>e,YB=(e,t)=>{if(t===void 0)return`\x1B[${Math.max(e+1,0)}G`;return`\x1B[${t+1};${Math.max(e+1,0)}H`},ZB=(e=1)=>`\x1B[${e}B`,XB=(e,t=0)=>{let r="";if(t<0)r+=`\x1B[${-t}A`;if(t>0)r+=`\x1B[${t}B`;if(e>0)r+=`\x1B[${e}C`;if(e<0)r+=`\x1B[${-e}D`;return r},eK=(e)=>{let t="";for(let r=0;r<e;r++)t+="\x1B[2K"+(r<e-1?"\x1B[1A":"");if(e>0)t+="\x1B[G";return t};var Q6="~effect/cli/Prompt";var sK={prefix:"?",arrowUp:"\u2191",arrowDown:"\u2193",checkboxOn:"\u2612",checkboxOff:"\u2610",tick:"\u2714",ellipsis:"\u2026",pointerSmall:"\u203A",pointer:"\u276F",descriptionSeparator:"- ",passwordMask:"*",toggleSeparator:"/",primaryColor:pp,mutedColor:qu,successColor:Bh,errorColor:Nh,submittedColor:Oa},H6={...sK,checkboxOn:"[*]",checkboxOff:"[ ]",tick:"\u221A",ellipsis:"...",pointerSmall:"\xBB",pointer:">"},V6=(e)=>({...process.platform==="win32"?H6:sK,...e,colors:e?.colors??Kh()}),$u=Jt("effect/cli/Prompt/Theme",{defaultValue:V6}),Sr=(e)=>De($u,(t)=>({...t,...e.theme}));var sk=(e,t)=>wt(e.colors,t,Fo(jB,e.errorColor)),at=(e,t,...r)=>t.length===0?"":wt(e.colors,t,...r),ys=(e,t)=>e.length===0?t:e+" "+t,J6=(e,t,r)=>{let n=Math.max(e.arrowUp.length,e.arrowDown.length);if(t)return e.arrowUp.padEnd(n);if(r)return e.arrowDown.padEnd(n);return" ".repeat(n)},ak=(e)=>{let t={initial:!1,...e,label:{confirm:"yes",deny:"no",...e.label},placeholder:{defaultConfirm:"(Y/n)",defaultDeny:"(y/N)",...e.placeholder}},r={value:t.initial};return Pa(r,{render:sY(t),process:(n)=>pY(n,t.initial),clear:nY(t)})},Pa=(e,...t)=>{let[r,n]=t.length===1?[void 0,t[0]]:[t[0],t[1]],o=Object.create(dk);return o._tag="Loop",o.initialState=e,o.render=n.render,o.process=n.process,o.clear=n.clear,o.events=r,o},aK=(e)=>{let t={initial:new globalThis.Date,dateMask:"YYYY-MM-DD HH:mm:ss",validate:j,...e,locales:{...bY,...e.locales}},r=kY(t.dateMask,t.initial,t.locales),n=r.findIndex((i)=>!i.isToken()),o={dateParts:r,typed:"",cursor:n,value:t.initial,error:ge()};return Pa(o,{render:IY(t),process:wY(t),clear:dY(t)})};var Y6=q(2,(e,t)=>{let r=Object.create(dk);return r._tag="OnSuccess",r.prompt=e,r.onSuccess=t,r}),cK=(e)=>{let t={default:0,min:globalThis.Number.NEGATIVE_INFINITY,max:globalThis.Number.POSITIVE_INFINITY,incrementBy:1,decrementBy:1,precision:2,validate:(o)=>{if(o<t.min)return he(`${o} must be greater than or equal to ${t.min}`);if(o>t.max)return he(`${o} must be less than or equal to ${t.max}`);return j(o)},...e},r=e.default===void 0?"":`${t.default}`,n={cursor:r.length,value:r,error:ge()};return Pa(n,{render:RY(t),process:_Y(t),clear:IK(t)})};var ck=(e)=>{let t={default:0,min:globalThis.Number.NEGATIVE_INFINITY,max:globalThis.Number.POSITIVE_INFINITY,incrementBy:1,decrementBy:1,validate:(o)=>{if(o<t.min)return he(`${o} must be greater than or equal to ${t.min}`);if(o>t.max)return he(`${o} must be less than or equal to ${t.max}`);return j(o)},...e},r=e.default===void 0?"":`${t.default}`,n={cursor:r.length,value:r,error:ge()};return Pa(n,{render:OY(t),process:PY(t),clear:IK(t)})};var Z6=q(2,(e,t)=>Y6(e,(r)=>eY(t(r)))),pK=(e)=>PK(e,"password").pipe(Z6(da)),an=Ie(function*(e){let t=yield*po,r=yield*PO(t.readInput);return yield*ok(e,t,r)},Rr(()=>new pu({})),Vs),X6=(e)=>{let t=0,r=-1;for(let n=0;n<e.length;n++)if(e[n].selected===!0){if(r!==-1)throw Error("InvalidArgumentException: only a single choice can be selected by default for Prompt.Select");r=n}if(r!==-1)t=r;return t},pk=(e)=>{let t={maxPerPage:10,...e},r=X6(t.choices);return Pa(r,{render:KY(t),process:$Y(t),clear:qY(t)})};var eY=(e)=>{let t=Object.create(dk);return t._tag="Succeed",t.value=e,t},dK=(e)=>PK(e,"text"),uK=(e)=>{let t={initial:!1,active:"on",inactive:"off",...e};return Pa(t.initial,{render:i8(t),process:s8,clear:()=>r8(t)})},dk={...Ui({label:"Prompt",evaluate(){return an(this)}}),[Q6]:{_Output:(e)=>e}};var ok=(e,t,r)=>Ve(()=>{let n=e;switch(n._tag){case"Loop":return Ae(r,(o)=>tY(n,t,o));case"OnSuccess":return Ae(ok(n.prompt,t,r),(o)=>ok(n.onSuccess(o),t,r));case"Succeed":return j(n.value)}}),tY=Ie(function*(e,t,r){let n=wc(e.initialState)?yield*e.initialState:e.initialState,o=xe.NextFrame({state:n}),i="";while(!0){let s=yield*e.render(n,o);if(yield*Co(t.display(i+s)),i="",e.events){let c=si(r).pipe(De((S)=>({_tag:"Input",input:S}))),l=yield*Un(c,si(e.events).pipe(De((S)=>({_tag:"Event",value:S}))));o=yield*e.process(l,n)}else{let c=yield*si(r);o=yield*e.process(c,n)}switch(o._tag){case"Beep":continue;case"NextFrame":{i=yield*e.clear(n,o),n=o.state;continue}case"Submit":{i=yield*e.clear(n,o);let c=yield*e.render(n,o);return yield*Co(t.display(i+c)),o.value}}}},(e,t,r)=>To(e,Co(r.display(HB)))),xe=mC(),dp=(e,t)=>{if(t===0)return hs+YB(0);let r=0,n=e.split(_a);for(let o of n)r+=1+Math.floor(Math.max(o.length-1,0)/t);return eK(r)},rY=(e,t)=>{let r=e.split(_a);return t===0?r.length:Oi(ln(r,(n)=>Math.ceil(n.length/t)),ql(0,(n,o)=>n+o))},uk=(e,t,r)=>{if(r!==void 0&&r.length>0)return ZB(rY(r,t))+dp(`
49
- ${r}`,t)+dp(e,t);return dp(e,t)},Ra=VB,_a=/\r?\n/,nY=(e)=>Ie(function*(t,r){let o=yield*(yield*po).columns,i=yield*Sr(e),s=t.value?e.placeholder.defaultConfirm:e.placeholder.defaultDeny,c=Wn(s,e.message,i.prefix,i.pointerSmall,i,{plain:!0}),l=dp(c,o),S=hs+Ta;return l+S}),oY=Ie(function*(e,t){let r=yield*Sr(t),n=at(r,r.prefix,r.primaryColor),o=at(r,r.pointerSmall,r.mutedColor),i=e.value?t.placeholder.defaultConfirm:t.placeholder.defaultDeny,s=wt(r.colors,i,r.mutedColor),c=Wn(s,t.message,n,o,r);return Ku+c}),iY=Ie(function*(e,t){let r=yield*Sr(t),n=at(r,r.tick,r.successColor),o=at(r,r.ellipsis,r.mutedColor),i=e?t.label.confirm:t.label.deny;return Wn(i,t.message,n,o,r)+`
50
- `}),sY=(e)=>(t,r)=>xe.$match(r,{Beep:()=>j(Ra),NextFrame:({state:n})=>oY(n,e),Submit:({value:n})=>iY(n,e)}),aY=/^y|t$/,cY=/^n|f$/,pY=(e,t)=>{let r=fr(e.input,()=>"");if(e.key.name==="enter"||e.key.name==="return")return j(xe.Submit({value:t}));if(aY.test(r.toLowerCase()))return j(xe.Submit({value:!0}));if(cY.test(r.toLowerCase()))return j(xe.Submit({value:!1}));return j(xe.Beep())},dY=(e)=>Ie(function*(t,r){let o=yield*(yield*po).columns,i=yield*Sr(e),s=hs+Ta,c=ql(t.dateParts,"",(g,w)=>g+w.toString()),l=Wn(c,e.message,i.prefix,i.pointerSmall,i,{plain:!0}),S=O(t.error)?zp(t.error.value.split(_a),{onEmpty:()=>"",onNonEmpty:(g)=>ys(i.pointerSmall,g.join(`
51
- `))}):"";return uk(l,o,S)+s}),uY=(e,t,r)=>{if(O(e.error)){let n=e.error.value.split(_a);if(Di(n)){let o=at(r,t,r.errorColor),i=ln(n,(s)=>sk(r,s));return Mh+`
52
- `+ys(o,i.join(`
53
- `))+Fh}}return""},lK=(e,t,r=!1)=>ql(e.dateParts,"",(n,o,i)=>{let s=o.toString();if(i===e.cursor&&!r){let c=Fo(Ca,t.primaryColor);return n+wt(t.colors,s,c)}return n+s}),lY=Ie(function*(e,t){let r=yield*Sr(t),n=at(r,r.prefix,r.primaryColor),o=at(r,r.pointerSmall,r.mutedColor),i=lK(e,r),s=Wn(i,t.message,n,o,r),c=uY(e,r.pointerSmall,r);return Ku+s+c}),fY=Ie(function*(e,t){let r=yield*Sr(t),n=at(r,r.tick,r.successColor),o=at(r,r.ellipsis,r.mutedColor),i=lK(e,r,!0);return Wn(i,t.message,n,o,r)+`
54
- `}),mY=(e)=>(e.dateParts[e.cursor].increment(),xe.NextFrame({state:{...e,typed:""}})),hY=(e)=>(e.dateParts[e.cursor].decrement(),xe.NextFrame({state:{...e,typed:""}})),yY=(e)=>{let t=e.dateParts[e.cursor].previousPart();if(O(t))return xe.NextFrame({state:{...e,typed:"",cursor:e.dateParts.indexOf(t.value)}});return xe.Beep()},gY=(e)=>{let t=e.dateParts[e.cursor].nextPart();if(O(t))return xe.NextFrame({state:{...e,typed:"",cursor:e.dateParts.indexOf(t.value)}});return xe.Beep()},xY=(e)=>{let t=e.dateParts[e.cursor].nextPart(),r=$r(t,{onNone:()=>e.dateParts.findIndex((n)=>!n.isToken()),onSome:(n)=>e.dateParts.indexOf(n)});return xe.NextFrame({state:{...e,typed:"",cursor:r}})},SY=(e,t)=>{if(/\d/.test(e)){let r=t.typed+e;return t.dateParts[t.cursor].setValue(r),xe.NextFrame({state:{...t,typed:r}})}return xe.Beep()},bY={months:["January","February","March","April","May","June","July","August","September","October","November","December"],monthsShort:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],weekdays:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],weekdaysShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]},IY=(e)=>(t,r)=>xe.$match(r,{Beep:()=>j(Ra),NextFrame:({state:n})=>lY(n,e),Submit:()=>fY(t,e)}),wY=(e)=>(t,r)=>{switch(t.key.name){case"left":return j(yY(r));case"right":return j(gY(r));case"k":case"up":return j(mY(r));case"j":case"down":return j(hY(r));case"tab":return j(xY(r));case"enter":case"return":return gd(e.validate(r.value),{onFailure:(n)=>xe.NextFrame({state:{...r,error:Ue(n)}}),onSuccess:(n)=>xe.Submit({value:n})});default:return j(SY(fr(t.input,()=>""),r))}},EY=/\\(.)|"((?:\\["\\]|[^"])+)"|(D[Do]?|d{3,4}|d)|(M{1,4})|(YY(?:YY)?)|([aA])|([Hh]{1,2})|(m{1,2})|(s{1,2})|(S{1,4})|./g,tK={1:({token:e,...t})=>new lk({token:e.replace(/\\(.)/g,"$1"),...t}),2:(e)=>new gK(e),3:(e)=>new xK(e),4:(e)=>new SK(e),5:(e)=>new bK(e),6:(e)=>new yK(e),7:(e)=>new hK(e),8:(e)=>new mK(e),9:(e)=>new fK(e)},kY=(e,t,r)=>{let n=[],o=null;while(o=EY.exec(e)){let s=o.shift(),c=o.findIndex((l)=>l!==void 0);if(c in tK){let l=o[c]||s;n.push(tK[c]({token:l,date:t,parts:n,locales:r}))}else n.push(new lk({token:o[c]||s,date:t,parts:n,locales:r}))}let i=n.reduce((s,c)=>{let l=s[s.length-1];if(c.isToken()&&l!==void 0&&l.isToken())l.setValue(c.token);else s.push(c);return s},qs());return n.splice(0,n.length,...i),n};class No{token;date;parts;locales;constructor(e){this.token=e.token,this.locales=e.locales,this.date=e.date||new globalThis.Date,this.parts=e.parts||[this]}isToken(){return!1}nextPart(){let e=fr(yg(this.parts,(t)=>t===this),()=>0);return Qv(this.parts.slice(e+1),(t)=>!t.isToken())}previousPart(){let e=yg(this.parts,(t)=>t===this);if(O(e))return Hv(this.parts.slice(0,e.value),(t)=>!t.isToken());return ge()}toString(){return globalThis.String(this.date)}}class lk extends No{increment(){}decrement(){}setValue(e){this.token=this.token+e}isToken(){return!0}toString(){return this.token}}class fK extends No{increment(){this.date.setMilliseconds(this.date.getMilliseconds()+1)}decrement(){this.date.setMilliseconds(this.date.getMilliseconds()-1)}setValue(e){this.date.setMilliseconds(globalThis.Number.parseInt(e.slice(-this.token.length)))}toString(){return`${this.date.getMilliseconds()}`.padStart(4,"0").substring(0,this.token.length)}}class mK extends No{increment(){this.date.setSeconds(this.date.getSeconds()+1)}decrement(){this.date.setSeconds(this.date.getSeconds()-1)}setValue(e){this.date.setSeconds(globalThis.Number.parseInt(e.slice(-2)))}toString(){let e=`${this.date.getSeconds()}`;return this.token.length>1?e.padStart(2,"0"):e}}class hK extends No{increment(){this.date.setMinutes(this.date.getMinutes()+1)}decrement(){this.date.setMinutes(this.date.getMinutes()-1)}setValue(e){this.date.setMinutes(globalThis.Number.parseInt(e.slice(-2)))}toString(){let e=`${this.date.getMinutes()}`;return this.token.length>1?e.padStart(2,"0"):e}}class yK extends No{increment(){this.date.setHours(this.date.getHours()+1)}decrement(){this.date.setHours(this.date.getHours()-1)}setValue(e){this.date.setHours(globalThis.Number.parseInt(e.slice(-2)))}toString(){let e=/h/.test(this.token)?this.date.getHours()%12||12:this.date.getHours();return this.token.length>1?`${e}`.padStart(2,"0"):`${e}`}}class gK extends No{increment(){this.date.setDate(this.date.getDate()+1)}decrement(){this.date.setDate(this.date.getDate()-1)}setValue(e){this.date.setDate(globalThis.Number.parseInt(e.slice(-2)))}toString(){let e=this.date.getDate(),t=this.date.getDay();switch(this.token){case"DD":return`${e}`.padStart(2,"0");case"Do":return`${e}${this.ordinalIndicator(e)}`;case"d":return`${t+1}`;case"ddd":return this.locales.weekdaysShort[t];case"dddd":return this.locales.weekdays[t];default:return`${e}`}}ordinalIndicator(e){if(e>=11&&e<=13)return"th";switch(e%10){case 1:return"st";case 2:return"nd";case 3:return"rd";default:return"th"}}}class xK extends No{increment(){this.date.setMonth(this.date.getMonth()+1)}decrement(){this.date.setMonth(this.date.getMonth()-1)}setValue(e){let t=globalThis.Number.parseInt(e.slice(-2))-1;this.date.setMonth(t<0?0:t)}toString(){let e=this.date.getMonth();switch(this.token.length){case 2:return`${e+1}`.padStart(2,"0");case 3:return this.locales.monthsShort[e];case 4:return this.locales.months[e];default:return`${e+1}`}}}class SK extends No{increment(){this.date.setFullYear(this.date.getFullYear()+1)}decrement(){this.date.setFullYear(this.date.getFullYear()-1)}setValue(e){this.date.setFullYear(globalThis.Number.parseInt(e.slice(-4)))}toString(){let e=`${this.date.getFullYear()}`.padStart(4,"0");return this.token.length===2?e.slice(-2):e}}class bK extends No{increment(){this.date.setHours((this.date.getHours()+12)%24)}decrement(){this.increment()}setValue(e){}toString(){let e=this.date.getHours()>=12?"pm":"am";return/A/.test(this.token)?e.toUpperCase():e}}var Wn=(e,t,r,n,o,i)=>{let s=r.length===0?"":r+" ",c=(l)=>{let S=s+l;if(n.length>0)S+=" "+n;if(e.length>0)S+=" "+e;else if(n.length>0)S+=" ";return S};return zp(t.split(_a),{onEmpty:()=>c(""),onNonEmpty:(l)=>{let S=i?.plain===!0?l:ln(l,(m)=>wt(o.colors,m,Ii));return c(S.join(`
55
- `))}})};var AY=(e,t,r,n)=>{if(!e.disabled&&e.description&&t){let o=r.descriptionSeparator+e.description;return n?.plain===!0?o:wt(r.colors,o,r.mutedColor)}return""};var IK=(e)=>Ie(function*(t,r){let o=yield*(yield*po).columns,i=yield*Sr(e),s=hs+Ta,c=wK(t,i.pointerSmall,i,{plain:!0}),l=fk(t,i.prefix,i.pointerSmall,e,i,{plain:!0});return uk(l,o,c)+s}),vY=(e,t,r,n)=>{let o=e.value===""?"":`${e.value}`;if(t||n?.plain===!0)return o;let i=O(e.error)?r.errorColor:Fo(Ca,r.primaryColor);return wt(r.colors,o,i)},wK=(e,t,r,n)=>{if(O(e.error))return zp(e.error.value.split(_a),{onEmpty:()=>"",onNonEmpty:(o)=>{if(n?.plain===!0)return ys(t,o.join(`
56
- `));let i=at(r,t,r.errorColor),s=ln(o,(c)=>sk(r,c));return Mh+`
57
- `+ys(i,s.join(`
58
- `))+Fh}});return""},fk=(e,t,r,n,o,i,s=!1)=>{let c=vY(e,s,o,i);return Wn(c,n.message,t,r,o,i)},EK=Ie(function*(e,t){let r=yield*Sr(t),n=at(r,r.prefix,r.primaryColor),o=at(r,r.pointerSmall,r.mutedColor),i=wK(e,r.pointerSmall,r);return fk(e,n,o,t,r)+i}),kK=Ie(function*(e,t){let r=yield*Sr(t),n=at(r,r.tick,r.successColor),o=at(r,r.ellipsis,r.mutedColor);return fk(e,n,o,t,r,void 0,!0)+`
59
- `}),AK=(e)=>{if(e.value.length<=0)return j(xe.Beep());let t=e.value.slice(0,e.value.length-1);return j(xe.NextFrame({state:{...e,value:t,error:ge()}}))},vK=(e)=>j(xe.NextFrame({state:{...e,cursor:0,value:"",error:ge()}})),ik=(e)=>Object.is(e,-0)?"-0":`${e}`,CY=(e,t)=>{if(t.value.length===0&&e==="-")return j(xe.NextFrame({state:{...t,value:"-",error:ge()}}));let r=globalThis.Number.parseInt(t.value+e);if(globalThis.Number.isNaN(r))return j(xe.Beep());else return j(xe.NextFrame({state:{...t,value:ik(r),error:ge()}}))},TY=(e,t)=>{if(e==="."&&t.value.includes("."))return j(xe.Beep());if(t.value.length===0&&e==="-")return j(xe.NextFrame({state:{...t,value:"-",error:ge()}}));let r=globalThis.Number.parseFloat(t.value+e);if(globalThis.Number.isNaN(r))return j(xe.Beep());else return j(xe.NextFrame({state:{...t,value:e==="."?`${ik(r)}.`:t.value.includes(".")&&/^\d$/.test(e)?t.value+e:ik(r),error:ge()}}))},OY=(e)=>(t,r)=>xe.$match(r,{Beep:()=>j(Ra),NextFrame:({state:n})=>EK(n,e),Submit:()=>kK(t,e)}),PY=(e)=>(t,r)=>{if(t.key.ctrl&&t.key.name==="u")return vK(r);switch(t.key.name){case"backspace":return AK(r);case"k":case"up":return j(xe.NextFrame({state:{...r,value:r.value===""||r.value==="-"?`${e.incrementBy}`:`${globalThis.Number.parseInt(r.value)+e.incrementBy}`,error:ge()}}));case"j":case"down":return j(xe.NextFrame({state:{...r,value:r.value===""||r.value==="-"?`-${e.decrementBy}`:`${globalThis.Number.parseInt(r.value)-e.decrementBy}`,error:ge()}}));case"enter":case"return":{let n=globalThis.Number.parseInt(r.value);if(globalThis.Number.isNaN(n))return j(xe.NextFrame({state:{...r,error:Ue("Must provide an integer value")}}));else return gd(e.validate(n),{onFailure:(o)=>xe.NextFrame({state:{...r,error:Ue(o)}}),onSuccess:(o)=>xe.Submit({value:o})})}default:return CY(fr(t.input,()=>""),r)}},RY=(e)=>(t,r)=>xe.$match(r,{Beep:()=>j(Ra),NextFrame:({state:n})=>EK(n,e),Submit:()=>kK(t,e)}),_Y=(e)=>(t,r)=>{if(t.key.ctrl&&t.key.name==="u")return vK(r);switch(t.key.name){case"backspace":return AK(r);case"k":case"up":return j(xe.NextFrame({state:{...r,value:r.value===""||r.value==="-"?`${e.incrementBy}`:`${globalThis.Number.parseFloat(r.value)+e.incrementBy}`,error:ge()}}));case"j":case"down":return j(xe.NextFrame({state:{...r,value:r.value===""||r.value==="-"?`-${e.decrementBy}`:`${globalThis.Number.parseFloat(r.value)-e.decrementBy}`,error:ge()}}));case"enter":case"return":{let n=globalThis.Number.parseFloat(r.value);if(globalThis.Number.isNaN(n))return j(xe.NextFrame({state:{...r,error:Ue("Must provide a floating point value")}}));else return Ae(Be(()=>yO(n,e.precision)),(o)=>gd(e.validate(o),{onFailure:(i)=>xe.NextFrame({state:{...r,error:Ue(i)}}),onSuccess:(i)=>xe.Submit({value:i})}))}default:return TY(fr(t.input,()=>""),r)}};var mk=(e,t,r,n,o)=>r.message===void 0?void 0:Wn("",r.message,e,t,n,o),CK=(e,t)=>e===void 0?t:e+`
60
- `+t;var UY=(e,t,r,n,o,i)=>{let s=J6(o,n===r.startIndex&&r.startIndex>0,n===r.endIndex-1&&r.endIndex<t.length);if(i?.plain===!0)return e===n?o.pointer+s:s+" ".repeat(o.pointer.length);if(t[n].disabled){let c=Fo(Ii,o.mutedColor);return e===n?at(o,o.pointer,c)+s:s+" ".repeat(o.pointer.length)}return e===n?at(o,o.pointer,o.primaryColor)+s:s+" ".repeat(o.pointer.length)};var DY=(e,t,r,n)=>{if(n?.plain===!0)return e.title;let o=e.title;if(t)return e.disabled?wt(r.colors,o,Fo(Ca,r.mutedColor)):wt(r.colors,o,Fo(Ca,r.primaryColor));return e.disabled?wt(r.colors,o,Fo(QB,r.mutedColor)):o},TK=(e,t,r,n)=>{let o=t.choices,i=a8(e,o.length,t.maxPerPage),s=[];for(let c=i.startIndex;c<i.endIndex;c++){let l=o[c],S=e===c,m=UY(e,o,i,c,r,n),g=DY(l,S,r,n),w=AY(l,S,r,n);s.push(m+g+" "+w)}return s.join(`
61
- `)};var LY=Ie(function*(e,t){let r=yield*Sr(t),n=TK(e,t,r),o=at(r,r.prefix,r.primaryColor),i=at(r,r.pointerSmall,r.mutedColor),s=mk(o,i,t,r);return Ku+CK(s,n)});var MY=Ie(function*(e,t){let r=yield*Sr(t),n=t.choices[e].title,o=at(r,r.tick,r.successColor),i=at(r,r.ellipsis,r.mutedColor);return(mk(o,i,t,r)??o)+" "+wt(r.colors,n,r.submittedColor)+`
62
- `});var FY=(e,t)=>{if(e===0)return j(xe.NextFrame({state:t.length-1}));return j(xe.NextFrame({state:e-1}))},NY=(e,t)=>{if(e===t.length-1)return j(xe.NextFrame({state:0}));return j(xe.NextFrame({state:e+1}))},BY=(e,t)=>j(xe.NextFrame({state:(e+1)%t.length}));var KY=(e)=>(t,r)=>xe.$match(r,{Beep:()=>j(Ra),NextFrame:({state:n})=>LY(n,e),Submit:()=>MY(t,e)});var qY=(e)=>Ie(function*(t,r){let o=yield*(yield*po).columns,i=yield*Sr(e),s=hs+Ta,c=mk(i.prefix,i.pointerSmall,e,i,{plain:!0}),l=TK(t,e,i,{plain:!0});return dp(CK(c,l),o)+s});var $Y=(e)=>(t,r)=>{switch(t.key.name){case"k":case"up":return FY(r,e.choices);case"j":case"down":return NY(r,e.choices);case"tab":return BY(r,e.choices);case"enter":case"return":{let n=e.choices[r];if(n.disabled)return j(xe.Beep());return j(xe.Submit({value:n.value}))}default:return j(xe.Beep())}};var WY=Ie(function*(e,t){let n=yield*(yield*po).columns,o=yield*Sr(t),i=hs+Ta,s=OK(e,o.pointerSmall,o,{plain:!0});return uk(hk(e,o.prefix,o.pointerSmall,t,o,{plain:!0}),n,s)+i}),GY=(e,t,r,n,o)=>{let i=e.value;if(o?.plain===!0)switch(t.type){case"hidden":return"";case"password":return r.passwordMask.repeat(i.length);case"text":return i}if(i.length===0)return"";let s=O(e.error)?r.errorColor:n?r.submittedColor:Fo(Ca,r.primaryColor);switch(t.type){case"hidden":return"";case"password":return at(r,r.passwordMask.repeat(i.length),s);case"text":return wt(r.colors,i,s)}},OK=(e,t,r,n)=>{if(O(e.error))return zp(e.error.value.split(_a),{onEmpty:()=>"",onNonEmpty:(o)=>{if(n?.plain===!0)return ys(t,o.join(`
63
- `));let i=at(r,t,r.errorColor),s=ln(o,(c)=>sk(r,c));return Mh+`
64
- `+ys(i,s.join(`
65
- `))+Fh}});return""},hk=(e,t,r,n,o,i,s=!1)=>{let c=GY(e,n,o,s,i);return Wn(c,n.message,t,r,o,i)},zY=Ie(function*(e,t){let r=yield*Sr(t),n=at(r,r.prefix,r.primaryColor),o=at(r,r.pointerSmall,r.mutedColor),i=hk(e,n,o,t,r),s=OK(e,r.pointerSmall,r),c=t.type==="password"?r.passwordMask.length:1,l=(e.cursor-e.value.length)*c;return i+s+XB(l)}),jY=Ie(function*(e,t){let r=yield*Sr(t),n=at(r,r.tick,r.successColor),o=at(r,r.ellipsis,r.mutedColor);return hk(e,n,o,t,r,void 0,!0)+`
66
- `}),QY=(e)=>{if(e.cursor<=0)return j(xe.Beep());let t=e.value.slice(0,e.cursor-1),r=e.value.slice(e.cursor),n=e.cursor-1,o=`${t}${r}`;return j(xe.NextFrame({state:{...e,cursor:n,value:o,error:ge()}}))},HY=(e)=>j(xe.NextFrame({state:{...e,cursor:0,value:"",error:ge()}})),VY=(e)=>{if(e.cursor<=0)return j(xe.Beep());let t=e.cursor-1;return j(xe.NextFrame({state:{...e,cursor:t,error:ge()}}))},JY=(e)=>{if(e.cursor>=e.value.length)return j(xe.Beep());let t=Math.min(e.cursor+1,e.value.length);return j(xe.NextFrame({state:{...e,cursor:t,error:ge()}}))},rK=(e)=>j(xe.NextFrame({state:{...e,cursor:0,error:ge()}})),nK=(e)=>j(xe.NextFrame({state:{...e,cursor:e.value.length,error:ge()}})),YY=(e,t)=>{if(e.value===t.default)return j(xe.Beep());let r=e.value.length===0?t.default:e.value;return j(xe.NextFrame({state:{...e,value:r,cursor:r.length,error:ge()}}))},ZY=(e,t)=>{let r=t.value.slice(0,t.cursor),n=t.value.slice(t.cursor),o=`${r}${e}${n}`,i=t.cursor+e.length;return j(xe.NextFrame({state:{...t,cursor:i,value:o,error:ge()}}))},XY=(e)=>(t,r)=>xe.$match(r,{Beep:()=>j(Ra),NextFrame:({state:n})=>zY(n,e),Submit:()=>jY(t,e)}),e8=(e)=>(t,r)=>{if(t.key.ctrl)switch(t.key.name){case"u":return HY(r);case"a":return rK(r);case"e":return nK(r);default:return j(xe.Beep())}switch(t.key.name){case"backspace":return QY(r);case"left":return VY(r);case"right":return JY(r);case"home":return rK(r);case"end":return nK(r);case"enter":case"return":{let n=r.value;return gd(e.validate(n),{onFailure:(o)=>xe.NextFrame({state:{...r,value:n,error:Ue(o)}}),onSuccess:(o)=>xe.Submit({value:o})})}case"tab":return YY(r,e);default:return ZY(fr(t.input,()=>""),r)}},t8=(e)=>(t,r)=>WY(t,e),PK=(e,t)=>{let r={default:"",type:t,validate:j,...e},n={cursor:r.default.length,value:r.default,error:ge()};return Pa(n,{render:XY(r),process:e8(r),clear:t8(r)})},r8=Ie(function*(e){let r=yield*(yield*po).columns,n=yield*Sr(e),o=hs+Ta,i=e.active+" "+ys(n.toggleSeparator,e.inactive),s=Wn(i,e.message,n.prefix,n.pointerSmall,n,{plain:!0});return dp(s,r)+o}),RK=(e,t,r,n=!1)=>{let o=at(r,r.toggleSeparator,r.mutedColor),i=Fo(Ca,n?r.submittedColor:r.primaryColor),s=e?t.inactive:wt(r.colors,t.inactive,i);return(e?wt(r.colors,t.active,i):t.active)+" "+ys(o,s)},n8=Ie(function*(e,t){let r=yield*Sr(t),n=at(r,r.prefix,r.primaryColor),o=at(r,r.pointerSmall,r.mutedColor),i=RK(e,t,r),s=Wn(i,t.message,n,o,r);return Ku+s}),o8=Ie(function*(e,t){let r=yield*Sr(t),n=at(r,r.tick,r.successColor),o=at(r,r.ellipsis,r.mutedColor),i=RK(e,t,r,!0);return Wn(i,t.message,n,o,r)+`
67
- `}),oK=j(xe.NextFrame({state:!0})),iK=j(xe.NextFrame({state:!1})),i8=(e)=>(t,r)=>{switch(r._tag){case"Beep":return j(Ra);case"NextFrame":return n8(t,e);case"Submit":return o8(t,e)}},s8=(e,t)=>{switch(e.key.name){case"0":case"j":case"delete":case"right":case"down":return iK;case"1":case"k":case"left":case"up":return oK;case" ":case"tab":return t?iK:oK;case"enter":case"return":return j(xe.Submit({value:t}));default:return j(xe.Beep())}},a8=(e,t,r)=>{let n=r===void 0?t:r,o=Math.min(t-n,e-Math.floor(n/2));if(o<0)o=0;let i=Math.min(o+n,t);return{startIndex:o,endIndex:i}};var qh=Jt("effect/cli/TerminalCapabilities",{defaultValue:()=>d8()}),_K=(e)=>e!==void 0&&e.length>0,c8=(e)=>_K(e)&&e!=="0"&&e.toLowerCase()!=="false",p8=(e)=>{if(e.term==="dumb")return{canColor:!1,canAnimate:!1,canPrompt:!1};return{canColor:!_K(e.noColor)&&(c8(e.forceColor)||e.stdoutIsTerminal),canAnimate:e.stdoutIsTerminal,canPrompt:e.stdinIsTerminal&&e.stdoutIsTerminal}},d8=()=>{let e=globalThis.process;return p8({noColor:e?.env?.NO_COLOR,forceColor:e?.env?.FORCE_COLOR,term:e?.env?.TERM,stdinIsTerminal:e?.stdin?.isTTY===!0,stdoutIsTerminal:e?.stdout?.isTTY===!0})};var UK="~effect/cli/Param",lp="argument",ho="flag",Gu={[UK]:{_A:Ee},pipe(){return et(this,arguments)}},xk=(e)=>He(e,UK);var zu=(e)=>e.kind==="flag",Ua=(e)=>{let t=(r)=>e.kind===lp?l8(e.name,e.primitiveType,r):f8(e.name,e.primitiveType,r);return Object.setPrototypeOf({_tag:"Single",...e,description:e.description??ge(),aliases:e.aliases??[],hidden:e.hidden??!1,annotations:e.annotations??un(),parse:t},Gu)},Wh=(e,t)=>Ua({name:t,primitiveType:GB,kind:e}),DK=(e,t)=>Ua({name:t,primitiveType:$B,kind:e}),Sk=(e,t)=>Ua({name:t,primitiveType:WB,kind:e});var Gh=(e,t,r)=>Ua({name:t,primitiveType:zB(r),kind:e}),zh=(e,t,r)=>{let n=r.map((o)=>[o,o]);return Gh(e,t,n)};var u8=/^-+/,LK=q(2,(e,t)=>gs(e,(r)=>Ua({...r,aliases:[...r.aliases,t.replace(u8,"")]}))),bk=q(2,(e,t)=>gs(e,(r)=>Ua({...r,description:Ue(t)})));var Ik=q(2,(e,t)=>{let r=(n)=>De(e.parse(n),([o,i])=>[o,t(i)]);return Object.assign(Object.create(Gu),{_tag:"Map",kind:e.kind,param:e,f:t,parse:r})}),$h=(e,t,r=[],n)=>{let o=r.map((i)=>()=>i().parse);return Object.assign(Object.create(Gu),{_tag:"Transform",kind:e.kind,param:e,alternatives:r,f:t,fallback:n,parse:t(e.parse,o)})},wk=q(2,(e,t)=>$h(e,(r)=>(n)=>Ae(r(n),([o,i])=>t(i).pipe(De((s)=>[o,s])))));var up=(e)=>{let t=(r)=>e.parse(r).pipe(De(([n,o])=>[n,Ue(o)]),kO({MissingOption:()=>j([r.arguments,ge()]),MissingArgument:()=>j([r.arguments,ge()])}));return Object.assign(Object.create(Gu),{_tag:"Optional",kind:e.kind,param:e,parse:t})},Ek=q(2,(e,t)=>{if(!wc(t))return $h(up(e),(r)=>(n)=>De(r(n),([o,i])=>[o,fr(i,()=>t)]),[],{_tag:"Default",value:t});return $h(up(e),(r)=>(n)=>Ae(r(n),([o,i])=>$r(i,{onNone:()=>De(t,(s)=>[o,s]),onSome:(s)=>j([o,s])})),[],{_tag:"DefaultEffect"})});var jh=(e,t)=>{let r=Hh(e),n=(o)=>{if(r.kind==="argument")return m8(e,r,o,t);else return h8(e,r,o,t)};return Object.assign(Object.create(Gu),{_tag:"Variadic",kind:e.kind,param:e,min:ec(t?.min),max:ec(t?.max),parse:n})};var kk=q(2,(e,t)=>{if(t<0)throw Error("atMost: max must be non-negative");return jh(e,{max:t})}),Ak=q(2,(e,t)=>{if(t<0)throw Error("atLeast: min must be non-negative");return jh(e,{min:t})});var vk=q(2,(e,t)=>gs(e,(r)=>Ua({...r,typeName:t})));var Qh=q(2,(e,t)=>{let r=rs(t);return wk(e,(n)=>Rr(r(n),(o)=>{let i=Hh(e);return new En({option:i.name,value:globalThis.String(n),expected:`Schema validation failed: ${o.message}`,kind:i.kind})}))});var l8=Ie(function*(e,t,r){if(r.arguments.length===0)return yield*new Fu({argument:e});let n=r.arguments[0],o=yield*Rr(t.parse(n),(i)=>new En({option:e,value:n,expected:i,kind:"argument"}));return[r.arguments.slice(1),o]}),f8=Ie(function*(e,t,r){let n=r.flags[e];if(n===void 0||n.length===0)return yield*new Mu({option:e});if(n.length>1)return yield*new En({option:e,value:`${n.length} occurrences`,expected:"at most 1 value",kind:"flag"});let o=n[0],i=yield*Rr(t.parse(o),(s)=>new En({option:e,value:o,expected:s,kind:"flag"}));return[r.arguments,i]}),m8=Ie(function*(e,t,r,n){let o=[],i=n?.min??0,s=n?.max??Number.POSITIVE_INFINITY,c=0,l=r.arguments;while(l.length>0&&c<s){let[S,m]=yield*e.parse({flags:r.flags,arguments:l});o.push(m),l=S,c++}if(c<i)return yield*c===0?new Fu({argument:t.name}):new En({option:t.name,value:`${c} values`,expected:`at least ${i} value${i===1?"":"s"}`,kind:t.kind});return[l,o]}),h8=Ie(function*(e,t,r,n){let o=[],s=[t.name,...t.aliases].flatMap((l)=>r.flags[l]??[]),c=s.length;if(Yt(n?.min)&&c<n.min)return yield*c===0?new Mu({option:t.name}):new En({option:t.name,value:`${c} occurrences`,expected:`at least ${n.min} value${n.min===1?"":"s"}`,kind:t.kind});if(Yt(n?.max)&&c>n.max)return yield*new En({option:t.name,value:`${c} occurrences`,expected:`at most ${n.max} value${n.max===1?"":"s"}`,kind:t.kind});for(let l of s){let[,S]=yield*e.parse({flags:{[t.name]:[l]},arguments:[]});o.push(S)}return[r.arguments,o]}),Ck=(e,t)=>{let r=e;switch(r._tag){case"Single":return t.Single(r);case"Map":return t.Map(r);case"Transform":return t.Transform(r);case"Optional":return t.Optional(r);case"Variadic":return t.Variadic(r)}},gs=(e,t)=>Ck(e,{Single:(r)=>t(r),Map:(r)=>Ik(gs(r.param,t),r.f),Transform:(r)=>$h(gs(r.param,t),r.f,r.alternatives.map((n)=>()=>gs(n(),t)),r.fallback),Optional:(r)=>up(gs(r.param,t)),Variadic:(r)=>jh(gs(r.param,t),{min:f(r.min),max:f(r.max)})}),qt=(e)=>Ck(e,{Single:(t)=>[t],Map:(t)=>qt(t.param),Transform:(t)=>[...qt(t.param),...t.alternatives.flatMap((r)=>qt(r()))],Optional:(t)=>qt(t.param),Variadic:(t)=>qt(t.param)}),Hh=(e)=>{let t=qt(e);if(t.length===0)throw Error("No Single param found in param structure");if(t.length>1)throw Error(`Multiple Single params found: ${t.map((r)=>r.name).join(", ")}`);return t[0]},Bo=(e)=>{let t=Wu(e);return{...t,isRequired:!t.isOptional&&(!t.isVariadic||$p(t.variadicMin,(r)=>r>0))}},Wu=(e)=>Ck(e,{Single:()=>({isOptional:!1,isVariadic:!1,variadicMin:ge(),variadicMax:ge()}),Map:(t)=>Wu(t.param),Transform:(t)=>Wu(t.param),Optional:(t)=>({...Wu(t.param),isOptional:!0}),Variadic:(t)=>({...Wu(t.param),isVariadic:!0,variadicMin:t.min,variadicMax:t.max})});var ne=(e)=>Wh(lp,e);var L8=(e,t)=>zh(lp,e,t);var ie=q(2,(e,t)=>Qh(e,t));var Ok=Jt("effect/cli/CliOutput",{defaultValue:()=>Yh()}),NK={present:Ie(function*(e){let t=yield*xd(),r=nc(t,Ok)??Yh({colors:dn(t,qh).canColor});switch(e._tag){case"Help":return yield*gr(r.formatHelpDoc(e.helpDoc));case"InvalidInvocation":return yield*gr(r.formatHelpDoc(e.helpDoc)),yield*qm(r.formatErrors(e.errors));case"Version":return yield*gr(r.formatVersion(e.name,e.version))}})},fp=Jt("effect/cli/CliOutput/Presenter",{defaultValue:()=>NK});var Vh=(e)=>e.replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F]/g,(t)=>`\\x${t.charCodeAt(0).toString(16).padStart(2,"0")}`),Yh=(e)=>{let t=e?.colors??Kh(),r={inheritedFlags:e?.inheritedFlags??"full",globalFlags:e?.globalFlags??"full"},n=t?{bold:(c)=>`\x1B[1m${c}\x1B[0m`,dim:(c)=>`\x1B[2m${c}\x1B[0m`,cyan:(c)=>`\x1B[36m${c}\x1B[0m`,green:(c)=>`\x1B[32m${c}\x1B[0m`,blue:(c)=>`\x1B[34m${c}\x1B[0m`,yellow:(c)=>`\x1B[33m${c}\x1B[0m`,magenta:(c)=>`\x1B[35m${c}\x1B[0m`}:{bold:(c)=>c,dim:(c)=>c,cyan:(c)=>c,green:(c)=>c,blue:(c)=>c,yellow:(c)=>c,magenta:(c)=>c},o=t?"\x1B[0m":"",i=t?"\x1B[31m":"",s=t?"\x1B[1m":"";return{formatHelpDoc:(c)=>$8(c,n,r),formatCliError:(c)=>Vh(c.message),formatError:(c)=>`
49
+ `)}`:"";return this.parent?`Unknown subcommand "${this.subcommand}" for "${this.parent.join(" ")}"${e}`:`Unknown subcommand "${this.subcommand}"${e}`}}class CK extends Eo(`${ut}/ValidationError`)("ValidationError",{message:a}){[ut]=ut}class fl extends Eo(`${ut}/UserError`)("UserError",{cause:MD(),userMessage:u(a)}){[ut]=ut;[Nu]=!0;get message(){if(this.userMessage)return this.userMessage;if(typeof this.cause==="string"&&this.cause)return this.cause;if(this.cause instanceof Error&&this.cause.message)return this.cause.message;return"An error occurred"}get[fy](){return this.message}}var mY=st([ec,my,ul,ll,hy,Rn,yy,CK,fl]);class Ni extends Eo(`${ut}/ShowHelp`)("ShowHelp",{commandPath:L(a),errors:L(mY)}){[ut]=ut;[aL]=this.errors.length?1:0;[Nu]=!1;get message(){return"Help requested"}}var hY="~effect/cli/Primitive",yY={[hY]:{_A:Ce}},TK=iI(cI),OK=iI(pI),iA=(e)=>e._tag==="Boolean",sA=(e,t)=>Object.assign(Object.create(yY),{_tag:e,parse:t}),PK=(e,t)=>{let r=mh(t),n=Kr(r);return sA(e,(o)=>Jt(n(o),(i)=>i.message))},RK=PK("Boolean",dI);var _K=PK("Int",F);var UK=sA("String",(e)=>j(e)),DK=(e)=>{let t=new Map(e),r=e.map(([o])=>it(o)).join(" | "),n=sA("Choice",(o)=>{if(t.has(o))return j(t.get(o));return oe(r)});return Object.assign(n,{choiceKeys:e.map(([o])=>o)})};var ml=(e)=>{switch(e._tag){case"Boolean":return"boolean";case"String":return"string";case"Int":return"integer";case"Finite":return"number";case"Date":return"date";case"Path":return"path";case"Choice":return"choice";case"Redacted":return"string";case"FileText":return"file";case"FileParse":return"file";case"FileSchema":return"file";case"KeyValuePair":return"key=value";case"Never":return"none";default:return"value"}},Bi=(e)=>e._tag==="Choice"?e.choiceKeys:void 0,aA=(e)=>e._tag==="Path"?e.pathType:void 0;var Ki="\x1B[1m",LK="\x1B[3m",tc="\x1B[4m",MK="\x1B[9m",FK="\x1B[?25h",hl="\x1B[?25l",rc="\x1B[G",gy="\x1B[s",xy="\x1B[u",Ms="\x1B[2K",NK="\x07",Sy="\x1B[31m",by="\x1B[32m",BK="\x1B[35m",nc="\x1B[37m",yl="\x1B[90m",Dp="\x1B[96m",Rt=(e,t,...r)=>{if(!e)return t;return`${r.flat().join("")}${t}\x1B[0m`},Iy=()=>{let e=globalThis.process;return typeof e==="object"&&e!==null&&typeof e.stdout==="object"&&e.stdout!==null&&e.stdout.isTTY===!0&&!e.env?.NO_COLOR},ri=(...e)=>e,KK=(e,t)=>{if(t===void 0)return`\x1B[${Math.max(e+1,0)}G`;return`\x1B[${t+1};${Math.max(e+1,0)}H`},qK=(e=1)=>`\x1B[${e}B`,$K=(e,t=0)=>{let r="";if(t<0)r+=`\x1B[${-t}A`;if(t>0)r+=`\x1B[${t}B`;if(e>0)r+=`\x1B[${e}C`;if(e<0)r+=`\x1B[${-e}D`;return r},WK=(e)=>{let t="";for(let r=0;r<e;r++)t+="\x1B[2K"+(r<e-1?"\x1B[1A":"");if(e>0)t+="\x1B[G";return t};var gY="~effect/cli/Prompt";var VK={prefix:"?",arrowUp:"\u2191",arrowDown:"\u2193",checkboxOn:"\u2612",checkboxOff:"\u2610",tick:"\u2714",ellipsis:"\u2026",pointerSmall:"\u203A",pointer:"\u276F",descriptionSeparator:"- ",passwordMask:"*",toggleSeparator:"/",primaryColor:Dp,mutedColor:yl,successColor:by,errorColor:Sy,submittedColor:nc},xY={...VK,checkboxOn:"[*]",checkboxOff:"[ ]",tick:"\u221A",ellipsis:"...",pointerSmall:"\xBB",pointer:">"},SY=(e)=>({...process.platform==="win32"?xY:VK,...e,colors:e?.colors??Iy()}),gl=pt("effect/cli/Prompt/Theme",{defaultValue:SY}),Rr=(e)=>Me(gl,(t)=>({...t,...e.theme}));var uA=(e,t)=>Rt(e.colors,t,ri(LK,e.errorColor)),lt=(e,t,...r)=>t.length===0?"":Rt(e.colors,t,...r),Fs=(e,t)=>e.length===0?t:e+" "+t,bY=(e,t,r)=>{let n=Math.max(e.arrowUp.length,e.arrowDown.length);if(t)return e.arrowUp.padEnd(n);if(r)return e.arrowDown.padEnd(n);return" ".repeat(n)},lA=(e)=>{let t={initial:!1,...e,label:{confirm:"yes",deny:"no",...e.label},placeholder:{defaultConfirm:"(Y/n)",defaultDeny:"(y/N)",...e.placeholder}},r={value:t.initial};return oc(r,{render:PY(t),process:(n)=>UY(n,t.initial),clear:CY(t)})},oc=(e,...t)=>{let[r,n]=t.length===1?[void 0,t[0]]:[t[0],t[1]],o=Object.create(hA);return o._tag="Loop",o.initialState=e,o.render=n.render,o.process=n.process,o.clear=n.clear,o.events=r,o},JK=(e)=>{let t={initial:new globalThis.Date,dateMask:"YYYY-MM-DD HH:mm:ss",validate:j,...e,locales:{...GY,...e.locales}},r=HY(t.dateMask,t.initial,t.locales),n=r.findIndex((i)=>!i.isToken()),o={dateParts:r,typed:"",cursor:n,value:t.initial,error:xe()};return oc(o,{render:jY(t),process:zY(t),clear:DY(t)})};var IY=W(2,(e,t)=>{let r=Object.create(hA);return r._tag="OnSuccess",r.prompt=e,r.onSuccess=t,r}),YK=(e)=>{let t={default:0,min:globalThis.Number.NEGATIVE_INFINITY,max:globalThis.Number.POSITIVE_INFINITY,incrementBy:1,decrementBy:1,precision:2,validate:(o)=>{if(o<t.min)return oe(`${o} must be greater than or equal to ${t.min}`);if(o>t.max)return oe(`${o} must be less than or equal to ${t.max}`);return j(o)},...e},r=e.default===void 0?"":`${t.default}`,n={cursor:r.length,value:r,error:xe()};return oc(n,{render:t9(t),process:r9(t),clear:dq(t)})};var fA=(e)=>{let t={default:0,min:globalThis.Number.NEGATIVE_INFINITY,max:globalThis.Number.POSITIVE_INFINITY,incrementBy:1,decrementBy:1,validate:(o)=>{if(o<t.min)return oe(`${o} must be greater than or equal to ${t.min}`);if(o>t.max)return oe(`${o} must be less than or equal to ${t.max}`);return j(o)},...e},r=e.default===void 0?"":`${t.default}`,n={cursor:r.length,value:r,error:xe()};return oc(n,{render:XY(t),process:e9(t),clear:dq(t)})};var EY=W(2,(e,t)=>IY(e,(r)=>wY(t(r)))),ZK=(e)=>Sq(e,"password").pipe(EY(ei)),mn=be(function*(e){let t=yield*ko,r=yield*YP(t.readInput);return yield*pA(e,t,r)},Jt(()=>new Mu({})),Ia),kY=(e)=>{let t=0,r=-1;for(let n=0;n<e.length;n++)if(e[n].selected===!0){if(r!==-1)throw Error("InvalidArgumentException: only a single choice can be selected by default for Prompt.Select");r=n}if(r!==-1)t=r;return t},mA=(e)=>{let t={maxPerPage:10,...e},r=kY(t.choices);return oc(r,{render:d9(t),process:l9(t),clear:u9(t)})};var wY=(e)=>{let t=Object.create(hA);return t._tag="Succeed",t.value=e,t},XK=(e)=>Sq(e,"text"),eq=(e)=>{let t={initial:!1,active:"on",inactive:"off",...e};return oc(t.initial,{render:O9(t),process:P9,clear:()=>v9(t)})},hA={...Bo({label:"Prompt",evaluate(){return mn(this)}}),[gY]:{_Output:(e)=>e}};var pA=(e,t,r)=>Ze(()=>{let n=e;switch(n._tag){case"Loop":return Ae(r,(o)=>AY(n,t,o));case"OnSuccess":return Ae(pA(n.prompt,t,r),(o)=>pA(n.onSuccess(o),t,r));case"Succeed":return j(n.value)}}),AY=be(function*(e,t,r){let n=us(e.initialState)?yield*e.initialState:e.initialState,o=Ee.NextFrame({state:n}),i="";while(!0){let s=yield*e.render(n,o);if(yield*Go(t.display(i+s)),i="",e.events){let c=Ai(r).pipe(Me((x)=>({_tag:"Input",input:x}))),d=yield*jn(c,Ai(e.events).pipe(Me((x)=>({_tag:"Event",value:x}))));o=yield*e.process(d,n)}else{let c=yield*Ai(r);o=yield*e.process(c,n)}switch(o._tag){case"Beep":continue;case"NextFrame":{i=yield*e.clear(n,o),n=o.state;continue}case"Submit":{i=yield*e.clear(n,o);let c=yield*e.render(n,o);return yield*Go(t.display(i+c)),o.value}}}},(e,t,r)=>jo(e,Go(r.display(FK)))),Ee=xT(),Lp=(e,t)=>{if(t===0)return Ms+KK(0);let r=0,n=e.split(sc);for(let o of n)r+=1+Math.floor(Math.max(o.length-1,0)/t);return WK(r)},vY=(e,t)=>{let r=e.split(sc);return t===0?r.length:Hi(gn(r,(n)=>Math.ceil(n.length/t)),hf(0,(n,o)=>n+o))},yA=(e,t,r)=>{if(r!==void 0&&r.length>0)return qK(vY(r,t))+Lp(`
50
+ ${r}`,t)+Lp(e,t);return Lp(e,t)},ic=NK,sc=/\r?\n/,CY=(e)=>be(function*(t,r){let o=yield*(yield*ko).columns,i=yield*Rr(e),s=t.value?e.placeholder.defaultConfirm:e.placeholder.defaultDeny,c=io(s,e.message,i.prefix,i.pointerSmall,i,{plain:!0}),d=Lp(c,o),x=Ms+rc;return d+x}),TY=be(function*(e,t){let r=yield*Rr(t),n=lt(r,r.prefix,r.primaryColor),o=lt(r,r.pointerSmall,r.mutedColor),i=e.value?t.placeholder.defaultConfirm:t.placeholder.defaultDeny,s=Rt(r.colors,i,r.mutedColor),c=io(s,t.message,n,o,r);return hl+c}),OY=be(function*(e,t){let r=yield*Rr(t),n=lt(r,r.tick,r.successColor),o=lt(r,r.ellipsis,r.mutedColor),i=e?t.label.confirm:t.label.deny;return io(i,t.message,n,o,r)+`
51
+ `}),PY=(e)=>(t,r)=>Ee.$match(r,{Beep:()=>j(ic),NextFrame:({state:n})=>TY(n,e),Submit:({value:n})=>OY(n,e)}),RY=/^y|t$/,_Y=/^n|f$/,UY=(e,t)=>{let r=yr(e.input,()=>"");if(e.key.name==="enter"||e.key.name==="return")return j(Ee.Submit({value:t}));if(RY.test(r.toLowerCase()))return j(Ee.Submit({value:!0}));if(_Y.test(r.toLowerCase()))return j(Ee.Submit({value:!1}));return j(Ee.Beep())},DY=(e)=>be(function*(t,r){let o=yield*(yield*ko).columns,i=yield*Rr(e),s=Ms+rc,c=hf(t.dateParts,"",(g,I)=>g+I.toString()),d=io(c,e.message,i.prefix,i.pointerSmall,i,{plain:!0}),x=T(t.error)?yd(t.error.value.split(sc),{onEmpty:()=>"",onNonEmpty:(g)=>Fs(i.pointerSmall,g.join(`
52
+ `))}):"";return yA(d,o,x)+s}),LY=(e,t,r)=>{if(T(e.error)){let n=e.error.value.split(sc);if(Zi(n)){let o=lt(r,t,r.errorColor),i=gn(n,(s)=>uA(r,s));return gy+`
53
+ `+Fs(o,i.join(`
54
+ `))+xy}}return""},tq=(e,t,r=!1)=>hf(e.dateParts,"",(n,o,i)=>{let s=o.toString();if(i===e.cursor&&!r){let c=ri(tc,t.primaryColor);return n+Rt(t.colors,s,c)}return n+s}),MY=be(function*(e,t){let r=yield*Rr(t),n=lt(r,r.prefix,r.primaryColor),o=lt(r,r.pointerSmall,r.mutedColor),i=tq(e,r),s=io(i,t.message,n,o,r),c=LY(e,r.pointerSmall,r);return hl+s+c}),FY=be(function*(e,t){let r=yield*Rr(t),n=lt(r,r.tick,r.successColor),o=lt(r,r.ellipsis,r.mutedColor),i=tq(e,r,!0);return io(i,t.message,n,o,r)+`
55
+ `}),NY=(e)=>(e.dateParts[e.cursor].increment(),Ee.NextFrame({state:{...e,typed:""}})),BY=(e)=>(e.dateParts[e.cursor].decrement(),Ee.NextFrame({state:{...e,typed:""}})),KY=(e)=>{let t=e.dateParts[e.cursor].previousPart();if(T(t))return Ee.NextFrame({state:{...e,typed:"",cursor:e.dateParts.indexOf(t.value)}});return Ee.Beep()},qY=(e)=>{let t=e.dateParts[e.cursor].nextPart();if(T(t))return Ee.NextFrame({state:{...e,typed:"",cursor:e.dateParts.indexOf(t.value)}});return Ee.Beep()},$Y=(e)=>{let t=e.dateParts[e.cursor].nextPart(),r=Wr(t,{onNone:()=>e.dateParts.findIndex((n)=>!n.isToken()),onSome:(n)=>e.dateParts.indexOf(n)});return Ee.NextFrame({state:{...e,typed:"",cursor:r}})},WY=(e,t)=>{if(/\d/.test(e)){let r=t.typed+e;return t.dateParts[t.cursor].setValue(r),Ee.NextFrame({state:{...t,typed:r}})}return Ee.Beep()},GY={months:["January","February","March","April","May","June","July","August","September","October","November","December"],monthsShort:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],weekdays:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],weekdaysShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]},jY=(e)=>(t,r)=>Ee.$match(r,{Beep:()=>j(ic),NextFrame:({state:n})=>MY(n,e),Submit:()=>FY(t,e)}),zY=(e)=>(t,r)=>{switch(t.key.name){case"left":return j(KY(r));case"right":return j(qY(r));case"k":case"up":return j(NY(r));case"j":case"down":return j(BY(r));case"tab":return j($Y(r));case"enter":case"return":return Wd(e.validate(r.value),{onFailure:(n)=>Ee.NextFrame({state:{...r,error:Le(n)}}),onSuccess:(n)=>Ee.Submit({value:n})});default:return j(WY(yr(t.input,()=>""),r))}},QY=/\\(.)|"((?:\\["\\]|[^"])+)"|(D[Do]?|d{3,4}|d)|(M{1,4})|(YY(?:YY)?)|([aA])|([Hh]{1,2})|(m{1,2})|(s{1,2})|(S{1,4})|./g,GK={1:({token:e,...t})=>new gA({token:e.replace(/\\(.)/g,"$1"),...t}),2:(e)=>new sq(e),3:(e)=>new aq(e),4:(e)=>new cq(e),5:(e)=>new pq(e),6:(e)=>new iq(e),7:(e)=>new oq(e),8:(e)=>new nq(e),9:(e)=>new rq(e)},HY=(e,t,r)=>{let n=[],o=null;while(o=QY.exec(e)){let s=o.shift(),c=o.findIndex((d)=>d!==void 0);if(c in GK){let d=o[c]||s;n.push(GK[c]({token:d,date:t,parts:n,locales:r}))}else n.push(new gA({token:o[c]||s,date:t,parts:n,locales:r}))}let i=n.reduce((s,c)=>{let d=s[s.length-1];if(c.isToken()&&d!==void 0&&d.isToken())d.setValue(c.token);else s.push(c);return s},pa());return n.splice(0,n.length,...i),n};class ni{token;date;parts;locales;constructor(e){this.token=e.token,this.locales=e.locales,this.date=e.date||new globalThis.Date,this.parts=e.parts||[this]}isToken(){return!1}nextPart(){let e=yr(rx(this.parts,(t)=>t===this),()=>0);return YC(this.parts.slice(e+1),(t)=>!t.isToken())}previousPart(){let e=rx(this.parts,(t)=>t===this);if(T(e))return ZC(this.parts.slice(0,e.value),(t)=>!t.isToken());return xe()}toString(){return globalThis.String(this.date)}}class gA extends ni{increment(){}decrement(){}setValue(e){this.token=this.token+e}isToken(){return!0}toString(){return this.token}}class rq extends ni{increment(){this.date.setMilliseconds(this.date.getMilliseconds()+1)}decrement(){this.date.setMilliseconds(this.date.getMilliseconds()-1)}setValue(e){this.date.setMilliseconds(globalThis.Number.parseInt(e.slice(-this.token.length)))}toString(){return`${this.date.getMilliseconds()}`.padStart(4,"0").substring(0,this.token.length)}}class nq extends ni{increment(){this.date.setSeconds(this.date.getSeconds()+1)}decrement(){this.date.setSeconds(this.date.getSeconds()-1)}setValue(e){this.date.setSeconds(globalThis.Number.parseInt(e.slice(-2)))}toString(){let e=`${this.date.getSeconds()}`;return this.token.length>1?e.padStart(2,"0"):e}}class oq extends ni{increment(){this.date.setMinutes(this.date.getMinutes()+1)}decrement(){this.date.setMinutes(this.date.getMinutes()-1)}setValue(e){this.date.setMinutes(globalThis.Number.parseInt(e.slice(-2)))}toString(){let e=`${this.date.getMinutes()}`;return this.token.length>1?e.padStart(2,"0"):e}}class iq extends ni{increment(){this.date.setHours(this.date.getHours()+1)}decrement(){this.date.setHours(this.date.getHours()-1)}setValue(e){this.date.setHours(globalThis.Number.parseInt(e.slice(-2)))}toString(){let e=/h/.test(this.token)?this.date.getHours()%12||12:this.date.getHours();return this.token.length>1?`${e}`.padStart(2,"0"):`${e}`}}class sq extends ni{increment(){this.date.setDate(this.date.getDate()+1)}decrement(){this.date.setDate(this.date.getDate()-1)}setValue(e){this.date.setDate(globalThis.Number.parseInt(e.slice(-2)))}toString(){let e=this.date.getDate(),t=this.date.getDay();switch(this.token){case"DD":return`${e}`.padStart(2,"0");case"Do":return`${e}${this.ordinalIndicator(e)}`;case"d":return`${t+1}`;case"ddd":return this.locales.weekdaysShort[t];case"dddd":return this.locales.weekdays[t];default:return`${e}`}}ordinalIndicator(e){if(e>=11&&e<=13)return"th";switch(e%10){case 1:return"st";case 2:return"nd";case 3:return"rd";default:return"th"}}}class aq extends ni{increment(){this.date.setMonth(this.date.getMonth()+1)}decrement(){this.date.setMonth(this.date.getMonth()-1)}setValue(e){let t=globalThis.Number.parseInt(e.slice(-2))-1;this.date.setMonth(t<0?0:t)}toString(){let e=this.date.getMonth();switch(this.token.length){case 2:return`${e+1}`.padStart(2,"0");case 3:return this.locales.monthsShort[e];case 4:return this.locales.months[e];default:return`${e+1}`}}}class cq extends ni{increment(){this.date.setFullYear(this.date.getFullYear()+1)}decrement(){this.date.setFullYear(this.date.getFullYear()-1)}setValue(e){this.date.setFullYear(globalThis.Number.parseInt(e.slice(-4)))}toString(){let e=`${this.date.getFullYear()}`.padStart(4,"0");return this.token.length===2?e.slice(-2):e}}class pq extends ni{increment(){this.date.setHours((this.date.getHours()+12)%24)}decrement(){this.increment()}setValue(e){}toString(){let e=this.date.getHours()>=12?"pm":"am";return/A/.test(this.token)?e.toUpperCase():e}}var io=(e,t,r,n,o,i)=>{let s=r.length===0?"":r+" ",c=(d)=>{let x=s+d;if(n.length>0)x+=" "+n;if(e.length>0)x+=" "+e;else if(n.length>0)x+=" ";return x};return yd(t.split(sc),{onEmpty:()=>c(""),onNonEmpty:(d)=>{let x=i?.plain===!0?d:gn(d,(f)=>Rt(o.colors,f,Ki));return c(x.join(`
56
+ `))}})};var VY=(e,t,r,n)=>{if(!e.disabled&&e.description&&t){let o=r.descriptionSeparator+e.description;return n?.plain===!0?o:Rt(r.colors,o,r.mutedColor)}return""};var dq=(e)=>be(function*(t,r){let o=yield*(yield*ko).columns,i=yield*Rr(e),s=Ms+rc,c=uq(t,i.pointerSmall,i,{plain:!0}),d=xA(t,i.prefix,i.pointerSmall,e,i,{plain:!0});return yA(d,o,c)+s}),JY=(e,t,r,n)=>{let o=e.value===""?"":`${e.value}`;if(t||n?.plain===!0)return o;let i=T(e.error)?r.errorColor:ri(tc,r.primaryColor);return Rt(r.colors,o,i)},uq=(e,t,r,n)=>{if(T(e.error))return yd(e.error.value.split(sc),{onEmpty:()=>"",onNonEmpty:(o)=>{if(n?.plain===!0)return Fs(t,o.join(`
57
+ `));let i=lt(r,t,r.errorColor),s=gn(o,(c)=>uA(r,c));return gy+`
58
+ `+Fs(i,s.join(`
59
+ `))+xy}});return""},xA=(e,t,r,n,o,i,s=!1)=>{let c=JY(e,s,o,i);return io(c,n.message,t,r,o,i)},lq=be(function*(e,t){let r=yield*Rr(t),n=lt(r,r.prefix,r.primaryColor),o=lt(r,r.pointerSmall,r.mutedColor),i=uq(e,r.pointerSmall,r);return xA(e,n,o,t,r)+i}),fq=be(function*(e,t){let r=yield*Rr(t),n=lt(r,r.tick,r.successColor),o=lt(r,r.ellipsis,r.mutedColor);return xA(e,n,o,t,r,void 0,!0)+`
60
+ `}),mq=(e)=>{if(e.value.length<=0)return j(Ee.Beep());let t=e.value.slice(0,e.value.length-1);return j(Ee.NextFrame({state:{...e,value:t,error:xe()}}))},hq=(e)=>j(Ee.NextFrame({state:{...e,cursor:0,value:"",error:xe()}})),dA=(e)=>Object.is(e,-0)?"-0":`${e}`,YY=(e,t)=>{if(t.value.length===0&&e==="-")return j(Ee.NextFrame({state:{...t,value:"-",error:xe()}}));let r=globalThis.Number.parseInt(t.value+e);if(globalThis.Number.isNaN(r))return j(Ee.Beep());else return j(Ee.NextFrame({state:{...t,value:dA(r),error:xe()}}))},ZY=(e,t)=>{if(e==="."&&t.value.includes("."))return j(Ee.Beep());if(t.value.length===0&&e==="-")return j(Ee.NextFrame({state:{...t,value:"-",error:xe()}}));let r=globalThis.Number.parseFloat(t.value+e);if(globalThis.Number.isNaN(r))return j(Ee.Beep());else return j(Ee.NextFrame({state:{...t,value:e==="."?`${dA(r)}.`:t.value.includes(".")&&/^\d$/.test(e)?t.value+e:dA(r),error:xe()}}))},XY=(e)=>(t,r)=>Ee.$match(r,{Beep:()=>j(ic),NextFrame:({state:n})=>lq(n,e),Submit:()=>fq(t,e)}),e9=(e)=>(t,r)=>{if(t.key.ctrl&&t.key.name==="u")return hq(r);switch(t.key.name){case"backspace":return mq(r);case"k":case"up":return j(Ee.NextFrame({state:{...r,value:r.value===""||r.value==="-"?`${e.incrementBy}`:`${globalThis.Number.parseInt(r.value)+e.incrementBy}`,error:xe()}}));case"j":case"down":return j(Ee.NextFrame({state:{...r,value:r.value===""||r.value==="-"?`-${e.decrementBy}`:`${globalThis.Number.parseInt(r.value)-e.decrementBy}`,error:xe()}}));case"enter":case"return":{let n=globalThis.Number.parseInt(r.value);if(globalThis.Number.isNaN(n))return j(Ee.NextFrame({state:{...r,error:Le("Must provide an integer value")}}));else return Wd(e.validate(n),{onFailure:(o)=>Ee.NextFrame({state:{...r,error:Le(o)}}),onSuccess:(o)=>Ee.Submit({value:o})})}default:return YY(yr(t.input,()=>""),r)}},t9=(e)=>(t,r)=>Ee.$match(r,{Beep:()=>j(ic),NextFrame:({state:n})=>lq(n,e),Submit:()=>fq(t,e)}),r9=(e)=>(t,r)=>{if(t.key.ctrl&&t.key.name==="u")return hq(r);switch(t.key.name){case"backspace":return mq(r);case"k":case"up":return j(Ee.NextFrame({state:{...r,value:r.value===""||r.value==="-"?`${e.incrementBy}`:`${globalThis.Number.parseFloat(r.value)+e.incrementBy}`,error:xe()}}));case"j":case"down":return j(Ee.NextFrame({state:{...r,value:r.value===""||r.value==="-"?`-${e.decrementBy}`:`${globalThis.Number.parseFloat(r.value)-e.decrementBy}`,error:xe()}}));case"enter":case"return":{let n=globalThis.Number.parseFloat(r.value);if(globalThis.Number.isNaN(n))return j(Ee.NextFrame({state:{...r,error:Le("Must provide a floating point value")}}));else return Ae(We(()=>LP(n,e.precision)),(o)=>Wd(e.validate(o),{onFailure:(i)=>Ee.NextFrame({state:{...r,error:Le(i)}}),onSuccess:(i)=>Ee.Submit({value:i})}))}default:return ZY(yr(t.input,()=>""),r)}};var SA=(e,t,r,n,o)=>r.message===void 0?void 0:io("",r.message,e,t,n,o),yq=(e,t)=>e===void 0?t:e+`
61
+ `+t;var n9=(e,t,r,n,o,i)=>{let s=bY(o,n===r.startIndex&&r.startIndex>0,n===r.endIndex-1&&r.endIndex<t.length);if(i?.plain===!0)return e===n?o.pointer+s:s+" ".repeat(o.pointer.length);if(t[n].disabled){let c=ri(Ki,o.mutedColor);return e===n?lt(o,o.pointer,c)+s:s+" ".repeat(o.pointer.length)}return e===n?lt(o,o.pointer,o.primaryColor)+s:s+" ".repeat(o.pointer.length)};var o9=(e,t,r,n)=>{if(n?.plain===!0)return e.title;let o=e.title;if(t)return e.disabled?Rt(r.colors,o,ri(tc,r.mutedColor)):Rt(r.colors,o,ri(tc,r.primaryColor));return e.disabled?Rt(r.colors,o,ri(MK,r.mutedColor)):o},gq=(e,t,r,n)=>{let o=t.choices,i=R9(e,o.length,t.maxPerPage),s=[];for(let c=i.startIndex;c<i.endIndex;c++){let d=o[c],x=e===c,f=n9(e,o,i,c,r,n),g=o9(d,x,r,n),I=VY(d,x,r,n);s.push(f+g+" "+I)}return s.join(`
62
+ `)};var i9=be(function*(e,t){let r=yield*Rr(t),n=gq(e,t,r),o=lt(r,r.prefix,r.primaryColor),i=lt(r,r.pointerSmall,r.mutedColor),s=SA(o,i,t,r);return hl+yq(s,n)});var s9=be(function*(e,t){let r=yield*Rr(t),n=t.choices[e].title,o=lt(r,r.tick,r.successColor),i=lt(r,r.ellipsis,r.mutedColor);return(SA(o,i,t,r)??o)+" "+Rt(r.colors,n,r.submittedColor)+`
63
+ `});var a9=(e,t)=>{if(e===0)return j(Ee.NextFrame({state:t.length-1}));return j(Ee.NextFrame({state:e-1}))},c9=(e,t)=>{if(e===t.length-1)return j(Ee.NextFrame({state:0}));return j(Ee.NextFrame({state:e+1}))},p9=(e,t)=>j(Ee.NextFrame({state:(e+1)%t.length}));var d9=(e)=>(t,r)=>Ee.$match(r,{Beep:()=>j(ic),NextFrame:({state:n})=>i9(n,e),Submit:()=>s9(t,e)});var u9=(e)=>be(function*(t,r){let o=yield*(yield*ko).columns,i=yield*Rr(e),s=Ms+rc,c=SA(i.prefix,i.pointerSmall,e,i,{plain:!0}),d=gq(t,e,i,{plain:!0});return Lp(yq(c,d),o)+s});var l9=(e)=>(t,r)=>{switch(t.key.name){case"k":case"up":return a9(r,e.choices);case"j":case"down":return c9(r,e.choices);case"tab":return p9(r,e.choices);case"enter":case"return":{let n=e.choices[r];if(n.disabled)return j(Ee.Beep());return j(Ee.Submit({value:n.value}))}default:return j(Ee.Beep())}};var f9=be(function*(e,t){let n=yield*(yield*ko).columns,o=yield*Rr(t),i=Ms+rc,s=xq(e,o.pointerSmall,o,{plain:!0});return yA(bA(e,o.prefix,o.pointerSmall,t,o,{plain:!0}),n,s)+i}),m9=(e,t,r,n,o)=>{let i=e.value;if(o?.plain===!0)switch(t.type){case"hidden":return"";case"password":return r.passwordMask.repeat(i.length);case"text":return i}if(i.length===0)return"";let s=T(e.error)?r.errorColor:n?r.submittedColor:ri(tc,r.primaryColor);switch(t.type){case"hidden":return"";case"password":return lt(r,r.passwordMask.repeat(i.length),s);case"text":return Rt(r.colors,i,s)}},xq=(e,t,r,n)=>{if(T(e.error))return yd(e.error.value.split(sc),{onEmpty:()=>"",onNonEmpty:(o)=>{if(n?.plain===!0)return Fs(t,o.join(`
64
+ `));let i=lt(r,t,r.errorColor),s=gn(o,(c)=>uA(r,c));return gy+`
65
+ `+Fs(i,s.join(`
66
+ `))+xy}});return""},bA=(e,t,r,n,o,i,s=!1)=>{let c=m9(e,n,o,s,i);return io(c,n.message,t,r,o,i)},h9=be(function*(e,t){let r=yield*Rr(t),n=lt(r,r.prefix,r.primaryColor),o=lt(r,r.pointerSmall,r.mutedColor),i=bA(e,n,o,t,r),s=xq(e,r.pointerSmall,r),c=t.type==="password"?r.passwordMask.length:1,d=(e.cursor-e.value.length)*c;return i+s+$K(d)}),y9=be(function*(e,t){let r=yield*Rr(t),n=lt(r,r.tick,r.successColor),o=lt(r,r.ellipsis,r.mutedColor);return bA(e,n,o,t,r,void 0,!0)+`
67
+ `}),g9=(e)=>{if(e.cursor<=0)return j(Ee.Beep());let t=e.value.slice(0,e.cursor-1),r=e.value.slice(e.cursor),n=e.cursor-1,o=`${t}${r}`;return j(Ee.NextFrame({state:{...e,cursor:n,value:o,error:xe()}}))},x9=(e)=>j(Ee.NextFrame({state:{...e,cursor:0,value:"",error:xe()}})),S9=(e)=>{if(e.cursor<=0)return j(Ee.Beep());let t=e.cursor-1;return j(Ee.NextFrame({state:{...e,cursor:t,error:xe()}}))},b9=(e)=>{if(e.cursor>=e.value.length)return j(Ee.Beep());let t=Math.min(e.cursor+1,e.value.length);return j(Ee.NextFrame({state:{...e,cursor:t,error:xe()}}))},jK=(e)=>j(Ee.NextFrame({state:{...e,cursor:0,error:xe()}})),zK=(e)=>j(Ee.NextFrame({state:{...e,cursor:e.value.length,error:xe()}})),I9=(e,t)=>{if(e.value===t.default)return j(Ee.Beep());let r=e.value.length===0?t.default:e.value;return j(Ee.NextFrame({state:{...e,value:r,cursor:r.length,error:xe()}}))},E9=(e,t)=>{let r=t.value.slice(0,t.cursor),n=t.value.slice(t.cursor),o=`${r}${e}${n}`,i=t.cursor+e.length;return j(Ee.NextFrame({state:{...t,cursor:i,value:o,error:xe()}}))},k9=(e)=>(t,r)=>Ee.$match(r,{Beep:()=>j(ic),NextFrame:({state:n})=>h9(n,e),Submit:()=>y9(t,e)}),w9=(e)=>(t,r)=>{if(t.key.ctrl)switch(t.key.name){case"u":return x9(r);case"a":return jK(r);case"e":return zK(r);default:return j(Ee.Beep())}switch(t.key.name){case"backspace":return g9(r);case"left":return S9(r);case"right":return b9(r);case"home":return jK(r);case"end":return zK(r);case"enter":case"return":{let n=r.value;return Wd(e.validate(n),{onFailure:(o)=>Ee.NextFrame({state:{...r,value:n,error:Le(o)}}),onSuccess:(o)=>Ee.Submit({value:o})})}case"tab":return I9(r,e);default:return E9(yr(t.input,()=>""),r)}},A9=(e)=>(t,r)=>f9(t,e),Sq=(e,t)=>{let r={default:"",type:t,validate:j,...e},n={cursor:r.default.length,value:r.default,error:xe()};return oc(n,{render:k9(r),process:w9(r),clear:A9(r)})},v9=be(function*(e){let r=yield*(yield*ko).columns,n=yield*Rr(e),o=Ms+rc,i=e.active+" "+Fs(n.toggleSeparator,e.inactive),s=io(i,e.message,n.prefix,n.pointerSmall,n,{plain:!0});return Lp(s,r)+o}),bq=(e,t,r,n=!1)=>{let o=lt(r,r.toggleSeparator,r.mutedColor),i=ri(tc,n?r.submittedColor:r.primaryColor),s=e?t.inactive:Rt(r.colors,t.inactive,i);return(e?Rt(r.colors,t.active,i):t.active)+" "+Fs(o,s)},C9=be(function*(e,t){let r=yield*Rr(t),n=lt(r,r.prefix,r.primaryColor),o=lt(r,r.pointerSmall,r.mutedColor),i=bq(e,t,r),s=io(i,t.message,n,o,r);return hl+s}),T9=be(function*(e,t){let r=yield*Rr(t),n=lt(r,r.tick,r.successColor),o=lt(r,r.ellipsis,r.mutedColor),i=bq(e,t,r,!0);return io(i,t.message,n,o,r)+`
68
+ `}),QK=j(Ee.NextFrame({state:!0})),HK=j(Ee.NextFrame({state:!1})),O9=(e)=>(t,r)=>{switch(r._tag){case"Beep":return j(ic);case"NextFrame":return C9(t,e);case"Submit":return T9(t,e)}},P9=(e,t)=>{switch(e.key.name){case"0":case"j":case"delete":case"right":case"down":return HK;case"1":case"k":case"left":case"up":return QK;case" ":case"tab":return t?HK:QK;case"enter":case"return":return j(Ee.Submit({value:t}));default:return j(Ee.Beep())}},R9=(e,t,r)=>{let n=r===void 0?t:r,o=Math.min(t-n,e-Math.floor(n/2));if(o<0)o=0;let i=Math.min(o+n,t);return{startIndex:o,endIndex:i}};var Ey=pt("effect/cli/TerminalCapabilities",{defaultValue:()=>D9()}),Iq=(e)=>e!==void 0&&e.length>0,_9=(e)=>Iq(e)&&e!=="0"&&e.toLowerCase()!=="false",U9=(e)=>{if(e.term==="dumb")return{canColor:!1,canAnimate:!1,canPrompt:!1};return{canColor:!Iq(e.noColor)&&(_9(e.forceColor)||e.stdoutIsTerminal),canAnimate:e.stdoutIsTerminal,canPrompt:e.stdinIsTerminal&&e.stdoutIsTerminal}},D9=()=>{let e=globalThis.process;return U9({noColor:e?.env?.NO_COLOR,forceColor:e?.env?.FORCE_COLOR,term:e?.env?.TERM,stdinIsTerminal:e?.stdin?.isTTY===!0,stdoutIsTerminal:e?.stdout?.isTTY===!0})};var Eq="~effect/cli/Param",Fp="argument",To="flag",Sl={[Eq]:{_A:Ce},pipe(){return nt(this,arguments)}},kA=(e)=>Ye(e,Eq);var bl=(e)=>e.kind==="flag",ac=(e)=>{let t=(r)=>e.kind===Fp?M9(e.name,e.primitiveType,r):F9(e.name,e.primitiveType,r);return Object.setPrototypeOf({_tag:"Single",...e,description:e.description??xe(),aliases:e.aliases??[],hidden:e.hidden??!1,annotations:e.annotations??Gr(),parse:t},Sl)},wy=(e,t)=>ac({name:t,primitiveType:UK,kind:e}),kq=(e,t)=>ac({name:t,primitiveType:RK,kind:e}),wA=(e,t)=>ac({name:t,primitiveType:_K,kind:e});var Ay=(e,t,r)=>ac({name:t,primitiveType:DK(r),kind:e}),vy=(e,t,r)=>{let n=r.map((o)=>[o,o]);return Ay(e,t,n)};var L9=/^-+/,wq=W(2,(e,t)=>Ns(e,(r)=>ac({...r,aliases:[...r.aliases,t.replace(L9,"")]}))),AA=W(2,(e,t)=>Ns(e,(r)=>ac({...r,description:Le(t)})));var vA=W(2,(e,t)=>{let r=(n)=>Me(e.parse(n),([o,i])=>[o,t(i)]);return Object.assign(Object.create(Sl),{_tag:"Map",kind:e.kind,param:e,f:t,parse:r})}),ky=(e,t,r=[],n)=>{let o=r.map((i)=>()=>i().parse);return Object.assign(Object.create(Sl),{_tag:"Transform",kind:e.kind,param:e,alternatives:r,f:t,fallback:n,parse:t(e.parse,o)})},CA=W(2,(e,t)=>ky(e,(r)=>(n)=>Ae(r(n),([o,i])=>t(i).pipe(Me((s)=>[o,s])))));var Mp=(e)=>{let t=(r)=>e.parse(r).pipe(Me(([n,o])=>[n,Le(o)]),GP({MissingOption:()=>j([r.arguments,xe()]),MissingArgument:()=>j([r.arguments,xe()])}));return Object.assign(Object.create(Sl),{_tag:"Optional",kind:e.kind,param:e,parse:t})},TA=W(2,(e,t)=>{if(!us(t))return ky(Mp(e),(r)=>(n)=>Me(r(n),([o,i])=>[o,yr(i,()=>t)]),[],{_tag:"Default",value:t});return ky(Mp(e),(r)=>(n)=>Ae(r(n),([o,i])=>Wr(i,{onNone:()=>Me(t,(s)=>[o,s]),onSome:(s)=>j([o,s])})),[],{_tag:"DefaultEffect"})});var Cy=(e,t)=>{let r=Oy(e),n=(o)=>{if(r.kind==="argument")return N9(e,r,o,t);else return B9(e,r,o,t)};return Object.assign(Object.create(Sl),{_tag:"Variadic",kind:e.kind,param:e,min:Tc(t?.min),max:Tc(t?.max),parse:n})};var OA=W(2,(e,t)=>{if(t<0)throw Error("atMost: max must be non-negative");return Cy(e,{max:t})}),PA=W(2,(e,t)=>{if(t<0)throw Error("atLeast: min must be non-negative");return Cy(e,{min:t})});var RA=W(2,(e,t)=>Ns(e,(r)=>ac({...r,typeName:t})));var Ty=W(2,(e,t)=>{let r=Kr(t);return CA(e,(n)=>Jt(r(n),(o)=>{let i=Oy(e);return new Rn({option:i.name,value:globalThis.String(n),expected:`Schema validation failed: ${o.message}`,kind:i.kind})}))});var M9=be(function*(e,t,r){if(r.arguments.length===0)return yield*new ll({argument:e});let n=r.arguments[0],o=yield*Jt(t.parse(n),(i)=>new Rn({option:e,value:n,expected:i,kind:"argument"}));return[r.arguments.slice(1),o]}),F9=be(function*(e,t,r){let n=r.flags[e];if(n===void 0||n.length===0)return yield*new ul({option:e});if(n.length>1)return yield*new Rn({option:e,value:`${n.length} occurrences`,expected:"at most 1 value",kind:"flag"});let o=n[0],i=yield*Jt(t.parse(o),(s)=>new Rn({option:e,value:o,expected:s,kind:"flag"}));return[r.arguments,i]}),N9=be(function*(e,t,r,n){let o=[],i=n?.min??0,s=n?.max??Number.POSITIVE_INFINITY,c=0,d=r.arguments;while(d.length>0&&c<s){let[x,f]=yield*e.parse({flags:r.flags,arguments:d});o.push(f),d=x,c++}if(c<i)return yield*c===0?new ll({argument:t.name}):new Rn({option:t.name,value:`${c} values`,expected:`at least ${i} value${i===1?"":"s"}`,kind:t.kind});return[d,o]}),B9=be(function*(e,t,r,n){let o=[],s=[t.name,...t.aliases].flatMap((d)=>r.flags[d]??[]),c=s.length;if(ir(n?.min)&&c<n.min)return yield*c===0?new ul({option:t.name}):new Rn({option:t.name,value:`${c} occurrences`,expected:`at least ${n.min} value${n.min===1?"":"s"}`,kind:t.kind});if(ir(n?.max)&&c>n.max)return yield*new Rn({option:t.name,value:`${c} occurrences`,expected:`at most ${n.max} value${n.max===1?"":"s"}`,kind:t.kind});for(let d of s){let[,x]=yield*e.parse({flags:{[t.name]:[d]},arguments:[]});o.push(x)}return[r.arguments,o]}),_A=(e,t)=>{let r=e;switch(r._tag){case"Single":return t.Single(r);case"Map":return t.Map(r);case"Transform":return t.Transform(r);case"Optional":return t.Optional(r);case"Variadic":return t.Variadic(r)}},Ns=(e,t)=>_A(e,{Single:(r)=>t(r),Map:(r)=>vA(Ns(r.param,t),r.f),Transform:(r)=>ky(Ns(r.param,t),r.f,r.alternatives.map((n)=>()=>Ns(n(),t)),r.fallback),Optional:(r)=>Mp(Ns(r.param,t)),Variadic:(r)=>Cy(Ns(r.param,t),{min:m(r.min),max:m(r.max)})}),Xt=(e)=>_A(e,{Single:(t)=>[t],Map:(t)=>Xt(t.param),Transform:(t)=>[...Xt(t.param),...t.alternatives.flatMap((r)=>Xt(r()))],Optional:(t)=>Xt(t.param),Variadic:(t)=>Xt(t.param)}),Oy=(e)=>{let t=Xt(e);if(t.length===0)throw Error("No Single param found in param structure");if(t.length>1)throw Error(`Multiple Single params found: ${t.map((r)=>r.name).join(", ")}`);return t[0]},oi=(e)=>{let t=xl(e);return{...t,isRequired:!t.isOptional&&(!t.isVariadic||fd(t.variadicMin,(r)=>r>0))}},xl=(e)=>_A(e,{Single:()=>({isOptional:!1,isVariadic:!1,variadicMin:xe(),variadicMax:xe()}),Map:(t)=>xl(t.param),Transform:(t)=>xl(t.param),Optional:(t)=>({...xl(t.param),isOptional:!0}),Variadic:(t)=>({...xl(t.param),isVariadic:!0,variadicMin:t.min,variadicMax:t.max})});var se=(e)=>wy(Fp,e);var iZ=(e,t)=>vy(Fp,e,t);var ce=W(2,(e,t)=>Ty(e,t));var DA=pt("effect/cli/CliOutput",{defaultValue:()=>_y()}),Cq={present:be(function*(e){let t=yield*Gd(),r=Pc(t,DA)??_y({colors:rn(t,Ey).canColor});switch(e._tag){case"Help":return yield*Or(r.formatHelpDoc(e.helpDoc));case"InvalidInvocation":return yield*Or(r.formatHelpDoc(e.helpDoc)),yield*Ih(r.formatErrors(e.errors));case"Version":return yield*Or(r.formatVersion(e.name,e.version))}})},Np=pt("effect/cli/CliOutput/Presenter",{defaultValue:()=>Cq});var Py=(e)=>e.replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F]/g,(t)=>`\\x${t.charCodeAt(0).toString(16).padStart(2,"0")}`),_y=(e)=>{let t=e?.colors??Iy(),r={inheritedFlags:e?.inheritedFlags??"full",globalFlags:e?.globalFlags??"full"},n=t?{bold:(c)=>`\x1B[1m${c}\x1B[0m`,dim:(c)=>`\x1B[2m${c}\x1B[0m`,cyan:(c)=>`\x1B[36m${c}\x1B[0m`,green:(c)=>`\x1B[32m${c}\x1B[0m`,blue:(c)=>`\x1B[34m${c}\x1B[0m`,yellow:(c)=>`\x1B[33m${c}\x1B[0m`,magenta:(c)=>`\x1B[35m${c}\x1B[0m`}:{bold:(c)=>c,dim:(c)=>c,cyan:(c)=>c,green:(c)=>c,blue:(c)=>c,yellow:(c)=>c,magenta:(c)=>c},o=t?"\x1B[0m":"",i=t?"\x1B[31m":"",s=t?"\x1B[1m":"";return{formatHelpDoc:(c)=>lZ(c,n,r),formatCliError:(c)=>Py(c.message),formatError:(c)=>`
68
69
  ${s}${i}ERROR${o}
69
- ${Vh(c.message)}${o}`,formatErrors:(c)=>{if(c.length===0)return"";if(c.length===1)return`
70
+ ${Py(c.message)}${o}`,formatErrors:(c)=>{if(c.length===0)return"";if(c.length===1)return`
70
71
  ${s}${i}ERROR${o}
71
- ${Vh(c[0].message)}${o}`;let l=new Map;for(let m of c){let g=m._tag??"Error",w=l.get(g)??[];w.push(m),l.set(g,w)}let S=[];S.push(`
72
- ${s}${i}ERRORS${o}`);for(let[,m]of l)for(let g of m)S.push(` ${Vh(g.message)}${o}`);return S.join(`
73
- `)},formatVersion:(c,l)=>`${n.bold(c)} ${n.dim("v")}${n.bold(l)}`}},M8=(e)=>e.replace(/\u001B\[[0-9;]*m/g,""),MK,F8=/[\p{Mark}\p{Control}\p{Default_Ignorable_Code_Point}]/gu,N8=/\p{Emoji_Presentation}/u,B8=(e)=>{if(e<4352)return!1;return e<=4447||e===9001||e===9002||e>=11904&&e<=12350||e>=12352&&e<=42191||e>=44032&&e<=55203||e>=63744&&e<=64255||e>=65040&&e<=65049||e>=65072&&e<=65135||e>=65280&&e<=65376||e>=65504&&e<=65510||e>=110592&&e<=111359||e>=127488&&e<=127569||e>=131072&&e<=262141},K8=(e)=>{let t=e.replace(F8,"");if(t.length===0)return 0;if(N8.test(e)||e.includes("\uFE0F"))return 2;return B8(t.codePointAt(0))?2:1},Tk=(e)=>{MK??=new Intl.Segmenter(void 0,{granularity:"grapheme"});let t=0;for(let{segment:r}of MK.segment(M8(e)))t+=K8(r);return t},q8=(e,t)=>{let r=Tk(e),n=Math.max(0,t-r);return e+" ".repeat(n)},Jh=(e,t)=>{let r=Math.max(...e.map((o)=>Tk(o.left)))+4,n=t===void 0?r:Math.min(r,t);return e.map(({left:o,right:i})=>` ${q8(o,Math.max(n,Tk(o)+1))}${i}`).join(`
74
- `)},FK=(e,t)=>t?`${e}, ${t}`:e,$8=(e,t,r)=>{let n=[];if(e.description)n.push(t.bold("DESCRIPTION")),n.push(` ${e.description}`),n.push("");if(n.push(t.bold("USAGE")),n.push(` ${t.cyan(e.usage)}`),n.push(""),e.args&&e.args.length>0){n.push(t.bold("ARGUMENTS"));let m=e.args.map((g)=>{let w=g.name;if(g.variadic)w+="...";let k=t.green(w),A=t.dim(g.type),y=`${k} ${A}`,h=g.required?"":t.dim(" (optional)"),x=fr(g.description,()=>"")+h;return{left:y,right:x}});n.push(Jh(m,25)),n.push("")}let o=(m,g)=>{n.push(t.bold(m)),n.push(Jh(g.map((w)=>{let k=[`--${w.name}`,...w.aliases].map(t.green).join(", "),A=w.type!=="boolean"?` ${t.dim(w.type)}`:"";return{left:k+A,right:fr(w.description,()=>"")}}))),n.push("")},i=[],s=(m,g,w,k)=>{if(!g||g.length===0||w==="none")return;if(w==="summary"&&k&&k.length>0)i.push(`Run '${k.join(" ")} --help' for ${m.toLowerCase()}`);else o(m,g)};if(e.flags.length>0)o("FLAGS",e.flags);let c=e.commandPath;s("INHERITED FLAGS",e.inheritedFlags,r.inheritedFlags,c?.slice(0,-1));let l=e.globalFlagsScope??c?.slice(0,1),S=c===void 0||l?.length===c.length;if(s("GLOBAL FLAGS",e.globalFlags,S?"full":r.globalFlags,l),i.length>0)n.push(...i,"");if(e.subcommands&&e.subcommands.length>0){let m=e.subcommands.find((g)=>g.group===void 0);if(m){if(n.push(t.bold("SUBCOMMANDS")),n.push(Jh(m.commands.map((g)=>({left:t.cyan(FK(g.name,g.alias)),right:g.shortDescription??g.description})),20)),e.subcommands.length>1)n.push("")}for(let g of e.subcommands){if(g.group===void 0)continue;n.push(t.bold(`${g.group}:`)),n.push(Jh(g.commands.map((w)=>({left:t.cyan(FK(w.name,w.alias)),right:w.shortDescription??w.description})),20)),n.push("")}}if(e.examples&&e.examples.length>0){n.push(t.bold("EXAMPLES"));let m=!0,g=!1;for(let w of e.examples){if(w.description){if(!m)n.push("");n.push(` ${t.dim(`# ${w.description}`)}`)}else if(g)n.push("");n.push(` ${t.cyan(w.command)}`),m=!1,g=!!w.description}n.push("")}if(n[n.length-1]==="")n.pop();return n.join(`
75
- `)};var BK="~effect/cli/Command/Config/Internal",Pk=(e)=>{let t=[],r=[],n=[];function o(s){let c=Object.create(null);for(let l of Yr(s))c[l]=i(s[l]);return c}function i(s){if(Array.isArray(s))return{_tag:"Array",children:s.map((c)=>i(c))};else if(xk(s)){let c=t.length;if(t.push(s),s.kind==="argument")n.push(s);else r.push(s);return{_tag:"Param",index:c}}else return{_tag:"Nested",tree:o(s)}}return{[BK]:BK,flags:r,arguments:n,orderedParams:t,tree:o(e)}},KK=Pk({});var Rk=(e,t)=>{let r={};for(let o of Yr(e))Zr(r,o,n(e[o]));return r;function n(o){switch(o._tag){case"Param":return t[o.index];case"Array":return o.children.map((i)=>n(i));case"Nested":return Rk(o.tree,t)}}};var Qu="~effect/cli/Command",Dt=(e)=>e,W8={...Ui({label:"Command",evaluate(){return Dt(this).service}})},Hu=(e)=>{let t=e.config,r=e.contextConfig??KK,n=e.service??Vt(`${Qu}/${e.name}`),o=e.annotations??un(),i=e.globalFlags??[],s=e.subcommands??[],c=e.resolveExamples??G8,l=(w,k)=>Yt(e.handle)?e.handle(w,k):he(new Si({commandPath:k,errors:[]})),S=e.parse??_k(t),m=e.parseContext??_k(r,{allowLeftovers:!0}),g=(w)=>{let k=[],A=[];for(let z of t.arguments){let X=qt(z),I=Bo(z);for(let me of X)k.push({name:me.name,type:me.typeName??Bu(me.primitiveType),description:me.description,required:I.isRequired,variadic:I.isVariadic})}let y=w.length>0?w.join(" "):e.name;if(s.some((z)=>z.commands.some((X)=>!X.unlisted)))y+=" <subcommand>";y+=" [flags]";for(let z of k){let X=z.variadic?`<${z.name}...>`:`<${z.name}>`;y+=` ${z.required?X:`[${X}]`}`}for(let z of t.flags){let X=qt(z),I=Bo(z);for(let me of X){if(me.hidden)continue;A.push(Zh(me,I))}}let h=[];for(let z of s){let X=z.commands.filter((I)=>!I.unlisted);if(X.length===0)continue;h.push({group:z.group,commands:ln(X,(I)=>({name:I.name,alias:I.alias,shortDescription:I.shortDescription,description:I.description??""}))})}let x=c(w);return{description:e.description??"",usage:y,flags:A,annotations:o,...k.length>0&&{args:k},...h.length>0&&{subcommands:h},...x.length>0&&{examples:x}}};return Object.assign(Object.create(W8),{[Qu]:Qu,name:e.name,examples:c([e.name]),resolveExamples:c,annotations:o,globalFlags:i,subcommands:s,unlisted:e.unlisted??!1,config:t,contextConfig:r,service:n,parse:S,parseContext:m,handle:l,buildHelpDoc:g,...Yt(e.description)?{description:e.description}:{},...Yt(e.shortDescription)?{shortDescription:e.shortDescription}:{},...Yt(e.alias)?{alias:e.alias}:{}})},G8=()=>[],Zh=(e,t)=>{let r=e.aliases.map((o)=>o.length===1?`-${o}`:`--${o}`),n=e.typeName??Bu(e.primitiveType);return{name:e.name,aliases:r,type:e.optionalValue===void 0?n:`[=${n}]`,description:z8(e.description,bi(e.primitiveType)),required:e.primitiveType._tag!=="Boolean"&&!t.isOptional}},z8=(e,t)=>{if(t===void 0||t.length===0)return e;let r=`(choices: ${t.join(", ")})`;return $r(e,{onNone:()=>Ue(r),onSome:(n)=>Ue(`${n} ${r}`)})},_k=(e,t)=>Ie(function*(r){let n={flags:r.flags,arguments:r.arguments},[o,i]=yield*j8(n,e.orderedParams);if(t?.allowLeftovers!==!0&&o.length>0)return yield*new Dh({arguments:o});return Rk(e.tree,i)}),j8=Ie(function*(e,t){let r=[],n=e.arguments;for(let o of t){let[i,s]=yield*o.parse({flags:e.flags,arguments:n});r.push(s),n=i}return[n,r]}),qK=(e,t,r)=>{let n=Dt(e),o=new Set;((s)=>{for(let c of s){let l=qt(c);for(let S of l)o.add(S.name)}})((r?.contextConfig??n.contextConfig).flags);for(let s of t){let c=Dt(s);for(let l of c.config.flags){let S=qt(l);for(let m of S)if(o.has(m.name))throw new Uh({option:m.name,parentCommand:e.name,childCommand:s.name})}}};var Q8=(e)=>{switch(e.primitiveType._tag){case"Boolean":return{_tag:"Boolean"};case"Int":return{_tag:"Int"};case"Finite":return{_tag:"Finite"};case"Date":return{_tag:"Date"};case"Choice":return{_tag:"Choice",values:bi(e.primitiveType)??[]};case"Path":return{_tag:"Path",pathType:rk(e.primitiveType)??"either"};case"FileText":case"FileParse":case"FileSchema":return{_tag:"Path",pathType:"file"};default:return{_tag:"String"}}},H8=(e)=>{switch(e.primitiveType._tag){case"Int":return{_tag:"Int"};case"Finite":return{_tag:"Finite"};case"Date":return{_tag:"Date"};case"Choice":return{_tag:"Choice",values:bi(e.primitiveType)??[]};case"Path":return{_tag:"Path",pathType:rk(e.primitiveType)??"either"};case"FileText":case"FileParse":case"FileSchema":return{_tag:"Path",pathType:"file"};default:return{_tag:"String"}}},Vu=(e,t)=>{let r=e;switch(r._tag){case"Single":return[[r,t===!0]];case"Map":case"Optional":return Vu(r.param,t);case"Transform":return[...Vu(r.param,t),...r.alternatives.flatMap((n)=>Vu(n(),t))];case"Variadic":return Vu(r.param,t??!$p(r.max,(n)=>n<=1))}},Uk=(e,t=[])=>{let r=Dt(e),n=r.config,o=[],i=new Set;for(let[S,m]of[...n.flags,...t].entries())for(let[g,w]of Vu(m)){if(g.hidden)continue;if(S>=n.flags.length&&i.has(g.name))continue;i.add(g.name),o.push({name:g.name,aliases:g.aliases,description:f(g.description),type:Q8(g),optionalValue:g.optionalValue!==void 0,repeatable:w,negation:g.negation})}let s=[];for(let S of n.arguments){let m=qt(S),g=Bo(S);for(let w of m){if(w.kind!=="argument")continue;s.push({name:w.name,description:f(w.description),required:!g.isOptional&&(!g.isVariadic||$p(g.variadicMin,(k)=>k>0)),variadic:g.isVariadic,type:H8(w)})}}let c=[],l=[...t,...r.contextConfig.flags];for(let S of e.subcommands)for(let m of S.commands){if(m.unlisted)continue;let g=Uk(m,l);if(c.push(g),m.alias&&m.alias!==m.name)c.push({...g,name:m.alias})}return{name:e.name,description:e.shortDescription??e.description,flags:o,arguments:s,subcommands:c}},Da=(e)=>e.type._tag!=="Boolean"&&e.optionalValue!==!0,yo=(e)=>e.type._tag!=="Boolean"||e.negation===!1?void 0:e.negation??`no-${e.name}`;var Ju=(e)=>e.replace(/'/g,"'\\''"),Dk=(e)=>e.replace(/[^a-zA-Z0-9_]/g,"_"),Lk=(e)=>{let t=[`--${e.name}`];for(let n of e.aliases)t.push(n.length===1?`-${n}`:`--${n}`);let r=yo(e);if(r!==void 0)t.push(`--${r}`);return t},J8=(e,t)=>{if(e.length===0)return;let r=e.map(Lk);t.push(` local ${r.map((n,o)=>`_used_${o}=""`).join(" ")}`),t.push(" for ((i = 1; i < cword; i++)); do"),t.push(' case "${words[i]%%=*}" in'),r.forEach((n,o)=>{t.push(` ${n.join("|")}) _used_${o}=1 ;;`)}),t.push(" esac"),t.push(" done"),t.push(' local _filtered_flags=""'),r.forEach((n,o)=>{let i=e[o].repeatable===!0?"":`[[ -n "$_used_${o}" ]] || `;t.push(` ${i}_filtered_flags+=" ${n.join(" ")}"`)}),t.push("")},Xh=(e)=>["\\\\","\\\"","\\'"].map((t)=>`${e}=\${${e}//${t}/}`).join("; "),Y8=(e,t)=>{t.push(`${e}()`),t.push("{"),t.push(' local _cur="$1" _word="$2"; shift 2'),t.push(""),t.push(' local _head="${_cur%"$_word"}"'),t.push(' local _open=""'),t.push(' case "$_head" in'),t.push(` *\\') _open="'" ;;`),t.push(` *\\") _open='"' ;;`),t.push(" esac"),t.push(""),t.push(' local _prefix="$_cur" _committed="$_head"'),t.push(` ${Xh("_prefix")}`),t.push(` ${Xh("_committed")}`),t.push(""),t.push(" COMPREPLY=()"),t.push(" local _choice _rest _match"),t.push(' for _choice in "$@"; do'),t.push(' [[ "$_choice" == "$_prefix"* ]] || continue'),t.push(' _rest="${_choice#"$_committed"}"'),t.push(' case "$_open" in'),t.push(` "'")`),t.push(` if [[ "$_head" == "'" ]]; then`),t.push(" _match=${_rest//\\'/\\'\\\\\\'\\'}"),t.push(" else"),t.push(' [[ "$_rest" == *\\\'* ]] && continue'),t.push(' _match="$_rest"'),t.push(" fi"),t.push(" ;;"),t.push(` '"')`),t.push(' _match="${_rest//\\\\/\\\\\\\\}"'),t.push(' _match="${_match//\\$/\\\\$}"'),t.push(' _match="${_match//\\`/\\\\\\`}"'),t.push(' _match="${_match//\\"/\\\\\\"}"'),t.push(" ;;"),t.push(" *)"),t.push(` printf -v _match '%q' "$_rest"`),t.push(` [[ -z "$_head" && "$_match" == '~'* ]] && _match="\\\\$_match"`),t.push(" ;;"),t.push(" esac"),t.push(' [[ -n "$_open" && "$_match" == *"$_open" ]] && _match+="$_open"'),t.push(' COMPREPLY+=("$_match")'),t.push(" done"),t.push("}"),t.push("")},Z8=(e,t)=>{t.push(`${e.paths}()`),t.push("{"),t.push(' local _kind="$1" _cur="$2" _word="$3"'),t.push(""),t.push(' local _prefix="$_cur" _committed="${_cur%"$_word"}"'),t.push(` ${Xh("_prefix")}`),t.push(` ${Xh("_committed")}`),t.push(""),t.push(' local _typed="" _dir="$_committed" _open="" _i'),t.push(' if [[ "$_word" == */* ]]; then'),t.push(' _typed="${_word%/*}/"'),t.push(' _dir="${_prefix%/*}/"'),t.push(' if [[ "$_cur" == "$_word" ]]; then'),t.push(" for ((_i = 0; _i < ${#_typed}; _i++)); do"),t.push(' case "$_open${_typed:_i:1}" in'),t.push(" \\\\|\\\"\\\\) ((_i += 1)) ;;"),t.push(' \\"|\\\') _open="${_typed:_i:1}" ;;'),t.push(' \\"\\"|\\\'\\\') _open="" ;;'),t.push(" esac"),t.push(" done"),t.push(" fi"),t.push(" fi"),t.push(""),t.push(' local _path _names=() _rest="${_word#"$_typed"}"'),t.push(" while IFS= read -r _path; do"),t.push(' if [[ "$_path" == "$_dir"* ]]; then'),t.push(' _names+=("$_committed${_path#"$_dir"}")'),t.push(' elif [[ -z "$_committed" ]]; then'),t.push(' _names+=("$_path")'),t.push(' _typed="" _rest="" _open=""'),t.push(" fi"),t.push(' done < <(compgen "$_kind" -- "$_prefix")'),t.push(' if [[ -n "$_open" ]]; then'),t.push(' _typed+="$_open"'),t.push(' _rest="${_prefix##*/}"'),t.push(" fi"),t.push(""),t.push(` ${e.choices} "\${_cur%"$_word"}$_rest" "$_rest" "\${_names[@]}"`),t.push(" for ((_i = 0; _i < ${#COMPREPLY[@]}; _i++)); do"),t.push(' COMPREPLY[_i]="$_typed${COMPREPLY[_i]}"'),t.push(" done"),t.push("}"),t.push("")},WK=(e,t)=>`${t.choices} "$cur" "$_comp_word" ${e.map((r)=>`'${Ju(r)}'`).join(" ")}`,$K=(e,t)=>{switch(e._tag){case"Choice":return WK(e.values,t);case"Path":return`${t.paths} ${e.pathType==="directory"?"-d":"-f"} "$cur" "$_comp_word"`;default:return}},GK=(e,t,r,n)=>{let o=[...t,e.name],i=`_${o.map(Dk).join("_")}`;if(r.push(`${i}()`),r.push("{"),r.push(" local cur prev words cword i"),r.push(t.length===0?" local _command_index=0":' local _command_index="$1"'),r.push(' _init_completion -n "$COMP_WORDBREAKS" || return'),t.length===0)r.push(' local _comp_word="$2"');r.push("");let s=e.flags.filter(Da);if(s.length>0){r.push(" # Flag value completions"),r.push(' case "$prev" in');for(let l of s){let S=[`--${l.name}`];for(let g of l.aliases)S.push(g.length===1?`-${g}`:`--${g}`);let m=$K(l.type,n);if(m)r.push(` ${S.join("|")})`),r.push(` ${m}`),r.push(" return"),r.push(" ;;")}r.push(" esac"),r.push("")}if(e.subcommands.length>0){r.push(" # Subcommand dispatch"),r.push(" local cmd _skip_next=0"),r.push(" for ((i = _command_index + 1; i < cword; i++)); do"),r.push(" if (( _skip_next )); then"),r.push(" _skip_next=0"),r.push(" continue"),r.push(" fi"),r.push(' case "${words[i]}" in');for(let l of e.flags){if(!Da(l))continue;let S=Lk(l);r.push(` ${S.join("|")}) _skip_next=1 ;;`),r.push(` ${S.map((m)=>`${m}=*`).join("|")}) ;;`)}for(let l of e.subcommands){let S=`_${[...o,l.name].map(Dk).join("_")}`;r.push(` ${l.name})`),r.push(` ${S} "$i"`),r.push(" return"),r.push(" ;;")}r.push(" esac"),r.push(" done"),r.push("")}if(J8(e.flags,r),e.flags.length>0||e.subcommands.length>0){if(r.push(" # Complete flags (filtered) and subcommands"),r.push(' if [[ "$cur" == -* ]]; then'),e.flags.length>0)r.push(' COMPREPLY=( $(compgen -W "$_filtered_flags" -- "$cur") )');r.push(" return"),r.push(" fi"),r.push("")}let c=e.arguments.flatMap((l,S)=>{let m=$K(l.type,n);return m===void 0?[]:[{argument:l,completion:m,index:S}]});if(c.length>0){r.push(" # Positional argument completions"),r.push(" local _position=0 _skip_next=0 _end_of_options=0"),r.push(" for ((i = _command_index + 1; i < cword; i++)); do"),r.push(" if (( _skip_next )); then"),r.push(" _skip_next=0"),r.push(" continue"),r.push(" fi"),r.push(" if (( _end_of_options )); then"),r.push(" ((_position += 1))"),r.push(" continue"),r.push(" fi"),r.push(' case "${words[i]}" in'),r.push(" --) _end_of_options=1 ;;");for(let S of e.flags){let m=Lk(S);if(!Da(S))r.push(` ${m.join("|")}) ;;`);else r.push(` ${m.join("|")}) _skip_next=1 ;;`),r.push(` ${m.map((g)=>`${g}=*`).join("|")}) ;;`)}r.push(" -*) ;;"),r.push(" *) ((_position += 1)) ;;"),r.push(" esac"),r.push(" done"),r.push(' case "$_position" in');for(let{argument:S,completion:m,index:g}of c){if(S.variadic)continue;r.push(` ${g})`),r.push(` ${m}`),r.push(" return"),r.push(" ;;")}r.push(" esac");let l=c.find(({argument:S})=>S.variadic);if(l!==void 0)r.push(` if (( _position >= ${l.index} )); then`),r.push(` ${l.completion}`),r.push(" return"),r.push(" fi")}else if(e.subcommands.length>0)r.push(` ${WK(e.subcommands.map((l)=>l.name),n)}`);r.push("}"),r.push("");for(let l of e.subcommands)GK(l,o,r,n)},zK=(e,t)=>{let r=[],n=Dk(e),o={choices:`_${n}--choices`,paths:`_${n}--paths`};return r.push(`###-begin-${Ju(e)}-completions-###`),r.push("#"),r.push("# Static completion script for Bash"),r.push("#"),r.push("# Installation:"),r.push(`# ${Ju(e)} --completions bash >> ~/.bashrc`),r.push("#"),r.push(""),r.push("if ! type _init_completion &>/dev/null; then"),r.push(" _init_completion()"),r.push(" {"),r.push(" COMPREPLY=()"),r.push(' local _i _j=0 _piece _line="$COMP_LINE"'),r.push(' words=("${COMP_WORDS[0]}")'),r.push(" cword=0"),r.push(' _line="${_line#*"${COMP_WORDS[0]}"}"'),r.push(" for ((_i = 1; _i < ${#COMP_WORDS[@]}; _i++)); do"),r.push(' _piece="${COMP_WORDS[_i]}"'),r.push(' if [[ "$_line" == [[:blank:]]* ]]; then'),r.push(" ((_j++))"),r.push(' words[_j]="$_piece"'),r.push(" else"),r.push(' words[_j]="${words[_j]}$_piece"'),r.push(" fi"),r.push(" ((_i == COMP_CWORD)) && cword=$_j"),r.push(' _line="${_line#*"$_piece"}"'),r.push(" done"),r.push(' cur="${words[cword]}"'),r.push(' prev=""'),r.push(' ((cword > 0)) && prev="${words[cword-1]}"'),r.push(" return 0"),r.push(" }"),r.push("fi"),r.push(""),Y8(o.choices,r),Z8(o,r),GK(t,[],r,o),r.push(`complete -F _${n} ${Ju(e)}`),r.push(`###-end-${Ju(e)}-completions-###`),r.join(`
76
- `)};var xs=(e)=>e.replace(/\\/g,"\\\\").replace(/'/g,"\\'"),jK=(e)=>xs(e.replace(/[^A-Za-z0-9_.,/@%+-]/gu,"\\$&")),e9=(e,t)=>{if(e.length===0){if(t.length>0)return"__fish_use_subcommand";return""}let r=e.map((n)=>`__fish_seen_subcommand_from ${n}`).join("; and ");if(t.length>0)return`${r}; and not __fish_seen_subcommand_from ${t.join(" ")}`;return r},Mk=(e)=>{let t=[];for(let n of e.aliases)if(n.length===1)t.push(`-s ${n}`);t.push(e.name);for(let n of e.aliases)if(n.length>1)t.push(n);let r=yo(e);if(r!==void 0)t.push(r);return`not __fish_contains_opt ${t.join(" ")}`},t9=(e)=>{let t=[`--${e.name}`];for(let r of e.aliases)t.push(r.length===1?`-${r}`:`--${r}`);return`begin; ${Mk(e)}; or contains -- (commandline -poc)[-1] ${t.join(" ")}; end`},r9=(e)=>{let t=[`-l ${e.name}`];for(let n of e.aliases)if(n.length===1)t.push(`-s ${n}`);else t.push(`-l ${n}`);if(e.description)t.push(`-d '${xs(e.description)}'`);let r=Da(e)?n9(e.type):void 0;if(r)t.push(r);return t},n9=(e)=>{switch(e._tag){case"Boolean":return;case"Choice":return`-r -f -a '${e.values.map(jK).join(" ")}'`;case"Path":if(e.pathType==="directory")return"-r -F";return"-r -F";default:return"-r -f"}},o9=(e)=>{switch(e._tag){case"Choice":return`-r -f -a '${e.values.map(jK).join(" ")}'`;case"Path":return"-r -F";default:return}},QK=(e,t,r,n)=>{let o=t.subcommands.map((l)=>l.name),i=e9(r,o),s=i?`-n '${i}'`:"";if(!t.arguments.some((l)=>l.type._tag==="Path")){let l=[`complete -c ${e}`];if(s)l.push(s);l.push("-f"),n.push(l.join(" "))}for(let l of t.subcommands){let S=[`complete -c ${e}`];if(s)S.push(s);if(S.push(`-f -a '${xs(l.name)}'`),l.description)S.push(`-d '${xs(l.description)}'`);n.push(S.join(" "))}for(let l of t.flags){let S=l.repeatable===!0?"":Da(l)?t9(l):Mk(l),m=[i,S].filter((A)=>A!=="").join("; and "),g=m?`-n '${m}'`:"",w=[`complete -c ${e}`];if(g)w.push(g);w.push(...r9(l)),n.push(w.join(" "));let k=yo(l);if(k!==void 0){let A=[`complete -c ${e}`];if(g)A.push(g);if(A.push(`-l ${k}`),l.description)A.push(`-d '${xs(`Disable ${l.name}`)}'`);n.push(A.join(" "))}}if(t.flags.length>0){let S=i?`${i}; and not string match -q -- "-*" (commandline -ct)`:'not string match -q -- "-*" (commandline -ct)';for(let m of t.flags){let g=m.repeatable===!0?S:`${S}; and ${Mk(m)}`,w=yo(m),k=[`complete -c ${e}`];if(k.push(`-n '${g}'`),k.push(`-f -a '--${m.name}'`),m.description)k.push(`-d '${xs(m.description)}'`);if(n.push(k.join(" ")),w!==void 0){let A=[`complete -c ${e}`];if(A.push(`-n '${g}'`),A.push(`-f -a '--${w}'`),m.description)A.push(`-d '${xs(`Disable ${m.name}`)}'`);n.push(A.join(" "))}}}for(let l of t.arguments){let S=o9(l.type);if(S){let m=[`complete -c ${e}`];if(s)m.push(s);if(m.push(S),l.description)m.push(`-d '${xs(l.description)}'`);n.push(m.join(" "))}}for(let l of t.subcommands)QK(e,l,[...r,l.name],n)},HK=(e,t)=>{let r=[];return r.push(`###-begin-${e}-completions-###`),r.push("#"),r.push("# Static completion script for Fish"),r.push("#"),r.push("# Installation:"),r.push(`# ${e} --completions fish > ~/.config/fish/completions/${e}.fish`),r.push("#"),r.push(""),QK(e,t,[],r),r.push(""),r.push(`###-end-${e}-completions-###`),r.join(`
77
- `)};var wi=(e)=>{let t=[],r="";for(let n=0;n<e.length;n++){let o=e.charCodeAt(n);if(o>=32&&o<128){r+=e[n]==="'"?"''":e[n];continue}if(r!==""||t.length===0)t.push(`'${r}'`);r="",t.push(`[char]0x${o.toString(16).toUpperCase().padStart(4,"0")}`)}if(r!==""||t.length===0)t.push(`'${r}'`);return t.length===1?t[0]:`(${t.join(" + ")})`},VK=(e)=>`@(${e.map(wi).join(", ")})`,Nk=(e)=>e?wi(e):"$null",s9=(e)=>e.replace(/[^a-zA-Z0-9_]/g,"_"),a9=(e)=>[`--${e.name}`,...e.aliases.map((t)=>t.length===1?`-${t}`:`--${t}`)],JK=(e)=>`values = ${VK(e._tag==="Choice"?e.values:[])}; pathType = ${e._tag==="Path"?wi(e.pathType):"$null"}`,c9=(e)=>{let t=yo(e);return`@{ name = ${wi(e.name)}; forms = ${VK(a9(e))}; takesValue = $${e.type._tag!=="Boolean"}; `+(t===void 0?"":`negation = ${wi(`--${t}`)}; `)+(e.optionalValue===!0?"optionalValue = $true; ":"")+(e.repeatable===!0?"repeatable = $true; ":"")+`${JK(e.type)}; description = ${Nk(e.description)} }`},p9=(e)=>`@{ name = ${wi(e.name)}; variadic = $${e.variadic}; ${JK(e.type)}; description = ${Nk(e.description)} }`,Fk=(e,t,r)=>{if(r.length===0){e.push(` ${t} = @()`);return}e.push(` ${t} = @(`);for(let n of r)e.push(` ${n}`);e.push(" )")},YK=(e,t,r,n,o)=>{let i=r.join(" ");if(o.has(i))return;o.add(i),n.push(`${e}[${wi(i)}] = @{`),Fk(n,"subcommands",t.subcommands.map((s)=>`@{ name = ${wi(s.name)}; description = ${Nk(s.description)} }`)),Fk(n,"flags",t.flags.map(c9)),Fk(n,"arguments",t.arguments.map(p9)),n.push("}");for(let s of t.subcommands)YK(e,s,[...r,s.name],n,o)},d9=(e)=>String.raw` param($wordToComplete, $commandAst, $cursorPosition)
72
+ ${Py(c[0].message)}${o}`;let d=new Map;for(let f of c){let g=f._tag??"Error",I=d.get(g)??[];I.push(f),d.set(g,I)}let x=[];x.push(`
73
+ ${s}${i}ERRORS${o}`);for(let[,f]of d)for(let g of f)x.push(` ${Py(g.message)}${o}`);return x.join(`
74
+ `)},formatVersion:(c,d)=>`${n.bold(c)} ${n.dim("v")}${n.bold(d)}`}},sZ=(e)=>e.replace(/\u001B\[[0-9;]*m/g,""),Aq,aZ=/[\p{Mark}\p{Control}\p{Default_Ignorable_Code_Point}]/gu,cZ=/\p{Emoji_Presentation}/u,pZ=(e)=>{if(e<4352)return!1;return e<=4447||e===9001||e===9002||e>=11904&&e<=12350||e>=12352&&e<=42191||e>=44032&&e<=55203||e>=63744&&e<=64255||e>=65040&&e<=65049||e>=65072&&e<=65135||e>=65280&&e<=65376||e>=65504&&e<=65510||e>=110592&&e<=111359||e>=127488&&e<=127569||e>=131072&&e<=262141},dZ=(e)=>{let t=e.replace(aZ,"");if(t.length===0)return 0;if(cZ.test(e)||e.includes("\uFE0F"))return 2;return pZ(t.codePointAt(0))?2:1},UA=(e)=>{Aq??=new Intl.Segmenter(void 0,{granularity:"grapheme"});let t=0;for(let{segment:r}of Aq.segment(sZ(e)))t+=dZ(r);return t},uZ=(e,t)=>{let r=UA(e),n=Math.max(0,t-r);return e+" ".repeat(n)},Ry=(e,t)=>{let r=Math.max(...e.map((o)=>UA(o.left)))+4,n=t===void 0?r:Math.min(r,t);return e.map(({left:o,right:i})=>` ${uZ(o,Math.max(n,UA(o)+1))}${i}`).join(`
75
+ `)},vq=(e,t)=>t?`${e}, ${t}`:e,lZ=(e,t,r)=>{let n=[];if(e.description)n.push(t.bold("DESCRIPTION")),n.push(` ${e.description}`),n.push("");if(n.push(t.bold("USAGE")),n.push(` ${t.cyan(e.usage)}`),n.push(""),e.args&&e.args.length>0){n.push(t.bold("ARGUMENTS"));let f=e.args.map((g)=>{let I=g.name;if(g.variadic)I+="...";let w=t.green(I),A=t.dim(g.type),y=`${w} ${A}`,h=g.required?"":t.dim(" (optional)"),S=yr(g.description,()=>"")+h;return{left:y,right:S}});n.push(Ry(f,25)),n.push("")}let o=(f,g)=>{n.push(t.bold(f)),n.push(Ry(g.map((I)=>{let w=[`--${I.name}`,...I.aliases].map(t.green).join(", "),A=I.type!=="boolean"?` ${t.dim(I.type)}`:"";return{left:w+A,right:yr(I.description,()=>"")}}))),n.push("")},i=[],s=(f,g,I,w)=>{if(!g||g.length===0||I==="none")return;if(I==="summary"&&w&&w.length>0)i.push(`Run '${w.join(" ")} --help' for ${f.toLowerCase()}`);else o(f,g)};if(e.flags.length>0)o("FLAGS",e.flags);let c=e.commandPath;s("INHERITED FLAGS",e.inheritedFlags,r.inheritedFlags,c?.slice(0,-1));let d=e.globalFlagsScope??c?.slice(0,1),x=c===void 0||d?.length===c.length;if(s("GLOBAL FLAGS",e.globalFlags,x?"full":r.globalFlags,d),i.length>0)n.push(...i,"");if(e.subcommands&&e.subcommands.length>0){let f=e.subcommands.find((g)=>g.group===void 0);if(f){if(n.push(t.bold("SUBCOMMANDS")),n.push(Ry(f.commands.map((g)=>({left:t.cyan(vq(g.name,g.alias)),right:g.shortDescription??g.description})),20)),e.subcommands.length>1)n.push("")}for(let g of e.subcommands){if(g.group===void 0)continue;n.push(t.bold(`${g.group}:`)),n.push(Ry(g.commands.map((I)=>({left:t.cyan(vq(I.name,I.alias)),right:I.shortDescription??I.description})),20)),n.push("")}}if(e.examples&&e.examples.length>0){n.push(t.bold("EXAMPLES"));let f=!0,g=!1;for(let I of e.examples){if(I.description){if(!f)n.push("");n.push(` ${t.dim(`# ${I.description}`)}`)}else if(g)n.push("");n.push(` ${t.cyan(I.command)}`),f=!1,g=!!I.description}n.push("")}if(n[n.length-1]==="")n.pop();return n.join(`
76
+ `)};var Tq="~effect/cli/Command/Config/Internal",LA=(e)=>{let t=[],r=[],n=[];function o(s){let c=Object.create(null);for(let d of wr(s))c[d]=i(s[d]);return c}function i(s){if(Array.isArray(s))return{_tag:"Array",children:s.map((c)=>i(c))};else if(kA(s)){let c=t.length;if(t.push(s),s.kind==="argument")n.push(s);else r.push(s);return{_tag:"Param",index:c}}else return{_tag:"Nested",tree:o(s)}}return{[Tq]:Tq,flags:r,arguments:n,orderedParams:t,tree:o(e)}},Oq=LA({});var MA=(e,t)=>{let r={};for(let o of wr(e))hr(r,o,n(e[o]));return r;function n(o){switch(o._tag){case"Param":return t[o.index];case"Array":return o.children.map((i)=>n(i));case"Nested":return MA(o.tree,t)}}};var El="~effect/cli/Command",Wt=(e)=>e,fZ={...Bo({label:"Command",evaluate(){return Wt(this).service}})},kl=(e)=>{let t=e.config,r=e.contextConfig??Oq,n=e.service??Qt(`${El}/${e.name}`),o=e.annotations??Gr(),i=e.globalFlags??[],s=e.subcommands??[],c=e.resolveExamples??mZ,d=(I,w)=>ir(e.handle)?e.handle(I,w):oe(new Ni({commandPath:w,errors:[]})),x=e.parse??FA(t),f=e.parseContext??FA(r,{allowLeftovers:!0}),g=(I)=>{let w=[],A=[];for(let H of t.arguments){let te=Xt(H),E=oi(H);for(let ge of te)w.push({name:ge.name,type:ge.typeName??ml(ge.primitiveType),description:ge.description,required:E.isRequired,variadic:E.isVariadic})}let y=I.length>0?I.join(" "):e.name;if(s.some((H)=>H.commands.some((te)=>!te.unlisted)))y+=" <subcommand>";y+=" [flags]";for(let H of w){let te=H.variadic?`<${H.name}...>`:`<${H.name}>`;y+=` ${H.required?te:`[${te}]`}`}for(let H of t.flags){let te=Xt(H),E=oi(H);for(let ge of te){if(ge.hidden)continue;A.push(Uy(ge,E))}}let h=[];for(let H of s){let te=H.commands.filter((E)=>!E.unlisted);if(te.length===0)continue;h.push({group:H.group,commands:gn(te,(E)=>({name:E.name,alias:E.alias,shortDescription:E.shortDescription,description:E.description??""}))})}let S=c(I);return{description:e.description??"",usage:y,flags:A,annotations:o,...w.length>0&&{args:w},...h.length>0&&{subcommands:h},...S.length>0&&{examples:S}}};return Object.assign(Object.create(fZ),{[El]:El,name:e.name,examples:c([e.name]),resolveExamples:c,annotations:o,globalFlags:i,subcommands:s,unlisted:e.unlisted??!1,config:t,contextConfig:r,service:n,parse:x,parseContext:f,handle:d,buildHelpDoc:g,...ir(e.description)?{description:e.description}:{},...ir(e.shortDescription)?{shortDescription:e.shortDescription}:{},...ir(e.alias)?{alias:e.alias}:{}})},mZ=()=>[],Uy=(e,t)=>{let r=e.aliases.map((o)=>o.length===1?`-${o}`:`--${o}`),n=e.typeName??ml(e.primitiveType);return{name:e.name,aliases:r,type:e.optionalValue===void 0?n:`[=${n}]`,description:hZ(e.description,Bi(e.primitiveType)),required:e.primitiveType._tag!=="Boolean"&&!t.isOptional}},hZ=(e,t)=>{if(t===void 0||t.length===0)return e;let r=`(choices: ${t.join(", ")})`;return Wr(e,{onNone:()=>Le(r),onSome:(n)=>Le(`${n} ${r}`)})},FA=(e,t)=>be(function*(r){let n={flags:r.flags,arguments:r.arguments},[o,i]=yield*yZ(n,e.orderedParams);if(t?.allowLeftovers!==!0&&o.length>0)return yield*new hy({arguments:o});return MA(e.tree,i)}),yZ=be(function*(e,t){let r=[],n=e.arguments;for(let o of t){let[i,s]=yield*o.parse({flags:e.flags,arguments:n});r.push(s),n=i}return[n,r]}),Pq=(e,t,r)=>{let n=Wt(e),o=new Set;((s)=>{for(let c of s){let d=Xt(c);for(let x of d)o.add(x.name)}})((r?.contextConfig??n.contextConfig).flags);for(let s of t){let c=Wt(s);for(let d of c.config.flags){let x=Xt(d);for(let f of x)if(o.has(f.name))throw new my({option:f.name,parentCommand:e.name,childCommand:s.name})}}};var gZ=(e)=>{switch(e.primitiveType._tag){case"Boolean":return{_tag:"Boolean"};case"Int":return{_tag:"Int"};case"Finite":return{_tag:"Finite"};case"Date":return{_tag:"Date"};case"Choice":return{_tag:"Choice",values:Bi(e.primitiveType)??[]};case"Path":return{_tag:"Path",pathType:aA(e.primitiveType)??"either"};case"FileText":case"FileParse":case"FileSchema":return{_tag:"Path",pathType:"file"};default:return{_tag:"String"}}},xZ=(e)=>{switch(e.primitiveType._tag){case"Int":return{_tag:"Int"};case"Finite":return{_tag:"Finite"};case"Date":return{_tag:"Date"};case"Choice":return{_tag:"Choice",values:Bi(e.primitiveType)??[]};case"Path":return{_tag:"Path",pathType:aA(e.primitiveType)??"either"};case"FileText":case"FileParse":case"FileSchema":return{_tag:"Path",pathType:"file"};default:return{_tag:"String"}}},wl=(e,t)=>{let r=e;switch(r._tag){case"Single":return[[r,t===!0]];case"Map":case"Optional":return wl(r.param,t);case"Transform":return[...wl(r.param,t),...r.alternatives.flatMap((n)=>wl(n(),t))];case"Variadic":return wl(r.param,t??!fd(r.max,(n)=>n<=1))}},NA=(e,t=[])=>{let r=Wt(e),n=r.config,o=[],i=new Set;for(let[x,f]of[...n.flags,...t].entries())for(let[g,I]of wl(f)){if(g.hidden)continue;if(x>=n.flags.length&&i.has(g.name))continue;i.add(g.name),o.push({name:g.name,aliases:g.aliases,description:m(g.description),type:gZ(g),optionalValue:g.optionalValue!==void 0,repeatable:I,negation:g.negation})}let s=[];for(let x of n.arguments){let f=Xt(x),g=oi(x);for(let I of f){if(I.kind!=="argument")continue;s.push({name:I.name,description:m(I.description),required:!g.isOptional&&(!g.isVariadic||fd(g.variadicMin,(w)=>w>0)),variadic:g.isVariadic,type:xZ(I)})}}let c=[],d=[...t,...r.contextConfig.flags];for(let x of e.subcommands)for(let f of x.commands){if(f.unlisted)continue;let g=NA(f,d);if(c.push(g),f.alias&&f.alias!==f.name)c.push({...g,name:f.alias})}return{name:e.name,description:e.shortDescription??e.description,flags:o,arguments:s,subcommands:c}},cc=(e)=>e.type._tag!=="Boolean"&&e.optionalValue!==!0,Oo=(e)=>e.type._tag!=="Boolean"||e.negation===!1?void 0:e.negation??`no-${e.name}`;var Al=(e)=>e.replace(/'/g,"'\\''"),BA=(e)=>e.replace(/[^a-zA-Z0-9_]/g,"_"),KA=(e)=>{let t=[`--${e.name}`];for(let n of e.aliases)t.push(n.length===1?`-${n}`:`--${n}`);let r=Oo(e);if(r!==void 0)t.push(`--${r}`);return t},bZ=(e,t)=>{if(e.length===0)return;let r=e.map(KA);t.push(` local ${r.map((n,o)=>`_used_${o}=""`).join(" ")}`),t.push(" for ((i = 1; i < cword; i++)); do"),t.push(' case "${words[i]%%=*}" in'),r.forEach((n,o)=>{t.push(` ${n.join("|")}) _used_${o}=1 ;;`)}),t.push(" esac"),t.push(" done"),t.push(' local _filtered_flags=""'),r.forEach((n,o)=>{let i=e[o].repeatable===!0?"":`[[ -n "$_used_${o}" ]] || `;t.push(` ${i}_filtered_flags+=" ${n.join(" ")}"`)}),t.push("")},Dy=(e)=>["\\\\","\\\"","\\'"].map((t)=>`${e}=\${${e}//${t}/}`).join("; "),IZ=(e,t)=>{t.push(`${e}()`),t.push("{"),t.push(' local _cur="$1" _word="$2"; shift 2'),t.push(""),t.push(' local _head="${_cur%"$_word"}"'),t.push(' local _open=""'),t.push(' case "$_head" in'),t.push(` *\\') _open="'" ;;`),t.push(` *\\") _open='"' ;;`),t.push(" esac"),t.push(""),t.push(' local _prefix="$_cur" _committed="$_head"'),t.push(` ${Dy("_prefix")}`),t.push(` ${Dy("_committed")}`),t.push(""),t.push(" COMPREPLY=()"),t.push(" local _choice _rest _match"),t.push(' for _choice in "$@"; do'),t.push(' [[ "$_choice" == "$_prefix"* ]] || continue'),t.push(' _rest="${_choice#"$_committed"}"'),t.push(' case "$_open" in'),t.push(` "'")`),t.push(` if [[ "$_head" == "'" ]]; then`),t.push(" _match=${_rest//\\'/\\'\\\\\\'\\'}"),t.push(" else"),t.push(' [[ "$_rest" == *\\\'* ]] && continue'),t.push(' _match="$_rest"'),t.push(" fi"),t.push(" ;;"),t.push(` '"')`),t.push(' _match="${_rest//\\\\/\\\\\\\\}"'),t.push(' _match="${_match//\\$/\\\\$}"'),t.push(' _match="${_match//\\`/\\\\\\`}"'),t.push(' _match="${_match//\\"/\\\\\\"}"'),t.push(" ;;"),t.push(" *)"),t.push(` printf -v _match '%q' "$_rest"`),t.push(` [[ -z "$_head" && "$_match" == '~'* ]] && _match="\\\\$_match"`),t.push(" ;;"),t.push(" esac"),t.push(' [[ -n "$_open" && "$_match" == *"$_open" ]] && _match+="$_open"'),t.push(' COMPREPLY+=("$_match")'),t.push(" done"),t.push("}"),t.push("")},EZ=(e,t)=>{t.push(`${e.paths}()`),t.push("{"),t.push(' local _kind="$1" _cur="$2" _word="$3"'),t.push(""),t.push(' local _prefix="$_cur" _committed="${_cur%"$_word"}"'),t.push(` ${Dy("_prefix")}`),t.push(` ${Dy("_committed")}`),t.push(""),t.push(' local _typed="" _dir="$_committed" _open="" _i'),t.push(' if [[ "$_word" == */* ]]; then'),t.push(' _typed="${_word%/*}/"'),t.push(' _dir="${_prefix%/*}/"'),t.push(' if [[ "$_cur" == "$_word" ]]; then'),t.push(" for ((_i = 0; _i < ${#_typed}; _i++)); do"),t.push(' case "$_open${_typed:_i:1}" in'),t.push(" \\\\|\\\"\\\\) ((_i += 1)) ;;"),t.push(' \\"|\\\') _open="${_typed:_i:1}" ;;'),t.push(' \\"\\"|\\\'\\\') _open="" ;;'),t.push(" esac"),t.push(" done"),t.push(" fi"),t.push(" fi"),t.push(""),t.push(' local _path _names=() _rest="${_word#"$_typed"}"'),t.push(" while IFS= read -r _path; do"),t.push(' if [[ "$_path" == "$_dir"* ]]; then'),t.push(' _names+=("$_committed${_path#"$_dir"}")'),t.push(' elif [[ -z "$_committed" ]]; then'),t.push(' _names+=("$_path")'),t.push(' _typed="" _rest="" _open=""'),t.push(" fi"),t.push(' done < <(compgen "$_kind" -- "$_prefix")'),t.push(' if [[ -n "$_open" ]]; then'),t.push(' _typed+="$_open"'),t.push(' _rest="${_prefix##*/}"'),t.push(" fi"),t.push(""),t.push(` ${e.choices} "\${_cur%"$_word"}$_rest" "$_rest" "\${_names[@]}"`),t.push(" for ((_i = 0; _i < ${#COMPREPLY[@]}; _i++)); do"),t.push(' COMPREPLY[_i]="$_typed${COMPREPLY[_i]}"'),t.push(" done"),t.push("}"),t.push("")},_q=(e,t)=>`${t.choices} "$cur" "$_comp_word" ${e.map((r)=>`'${Al(r)}'`).join(" ")}`,Rq=(e,t)=>{switch(e._tag){case"Choice":return _q(e.values,t);case"Path":return`${t.paths} ${e.pathType==="directory"?"-d":"-f"} "$cur" "$_comp_word"`;default:return}},Uq=(e,t,r,n)=>{let o=[...t,e.name],i=`_${o.map(BA).join("_")}`;if(r.push(`${i}()`),r.push("{"),r.push(" local cur prev words cword i"),r.push(t.length===0?" local _command_index=0":' local _command_index="$1"'),r.push(' _init_completion -n "$COMP_WORDBREAKS" || return'),t.length===0)r.push(' local _comp_word="$2"');r.push("");let s=e.flags.filter(cc);if(s.length>0){r.push(" # Flag value completions"),r.push(' case "$prev" in');for(let d of s){let x=[`--${d.name}`];for(let g of d.aliases)x.push(g.length===1?`-${g}`:`--${g}`);let f=Rq(d.type,n);if(f)r.push(` ${x.join("|")})`),r.push(` ${f}`),r.push(" return"),r.push(" ;;")}r.push(" esac"),r.push("")}if(e.subcommands.length>0){r.push(" # Subcommand dispatch"),r.push(" local cmd _skip_next=0"),r.push(" for ((i = _command_index + 1; i < cword; i++)); do"),r.push(" if (( _skip_next )); then"),r.push(" _skip_next=0"),r.push(" continue"),r.push(" fi"),r.push(' case "${words[i]}" in');for(let d of e.flags){if(!cc(d))continue;let x=KA(d);r.push(` ${x.join("|")}) _skip_next=1 ;;`),r.push(` ${x.map((f)=>`${f}=*`).join("|")}) ;;`)}for(let d of e.subcommands){let x=`_${[...o,d.name].map(BA).join("_")}`;r.push(` ${d.name})`),r.push(` ${x} "$i"`),r.push(" return"),r.push(" ;;")}r.push(" esac"),r.push(" done"),r.push("")}if(bZ(e.flags,r),e.flags.length>0||e.subcommands.length>0){if(r.push(" # Complete flags (filtered) and subcommands"),r.push(' if [[ "$cur" == -* ]]; then'),e.flags.length>0)r.push(' COMPREPLY=( $(compgen -W "$_filtered_flags" -- "$cur") )');r.push(" return"),r.push(" fi"),r.push("")}let c=e.arguments.flatMap((d,x)=>{let f=Rq(d.type,n);return f===void 0?[]:[{argument:d,completion:f,index:x}]});if(c.length>0){r.push(" # Positional argument completions"),r.push(" local _position=0 _skip_next=0 _end_of_options=0"),r.push(" for ((i = _command_index + 1; i < cword; i++)); do"),r.push(" if (( _skip_next )); then"),r.push(" _skip_next=0"),r.push(" continue"),r.push(" fi"),r.push(" if (( _end_of_options )); then"),r.push(" ((_position += 1))"),r.push(" continue"),r.push(" fi"),r.push(' case "${words[i]}" in'),r.push(" --) _end_of_options=1 ;;");for(let x of e.flags){let f=KA(x);if(!cc(x))r.push(` ${f.join("|")}) ;;`);else r.push(` ${f.join("|")}) _skip_next=1 ;;`),r.push(` ${f.map((g)=>`${g}=*`).join("|")}) ;;`)}r.push(" -*) ;;"),r.push(" *) ((_position += 1)) ;;"),r.push(" esac"),r.push(" done"),r.push(' case "$_position" in');for(let{argument:x,completion:f,index:g}of c){if(x.variadic)continue;r.push(` ${g})`),r.push(` ${f}`),r.push(" return"),r.push(" ;;")}r.push(" esac");let d=c.find(({argument:x})=>x.variadic);if(d!==void 0)r.push(` if (( _position >= ${d.index} )); then`),r.push(` ${d.completion}`),r.push(" return"),r.push(" fi")}else if(e.subcommands.length>0)r.push(` ${_q(e.subcommands.map((d)=>d.name),n)}`);r.push("}"),r.push("");for(let d of e.subcommands)Uq(d,o,r,n)},Dq=(e,t)=>{let r=[],n=BA(e),o={choices:`_${n}--choices`,paths:`_${n}--paths`};return r.push(`###-begin-${Al(e)}-completions-###`),r.push("#"),r.push("# Static completion script for Bash"),r.push("#"),r.push("# Installation:"),r.push(`# ${Al(e)} --completions bash >> ~/.bashrc`),r.push("#"),r.push(""),r.push("if ! type _init_completion &>/dev/null; then"),r.push(" _init_completion()"),r.push(" {"),r.push(" COMPREPLY=()"),r.push(' local _i _j=0 _piece _line="$COMP_LINE"'),r.push(' words=("${COMP_WORDS[0]}")'),r.push(" cword=0"),r.push(' _line="${_line#*"${COMP_WORDS[0]}"}"'),r.push(" for ((_i = 1; _i < ${#COMP_WORDS[@]}; _i++)); do"),r.push(' _piece="${COMP_WORDS[_i]}"'),r.push(' if [[ "$_line" == [[:blank:]]* ]]; then'),r.push(" ((_j++))"),r.push(' words[_j]="$_piece"'),r.push(" else"),r.push(' words[_j]="${words[_j]}$_piece"'),r.push(" fi"),r.push(" ((_i == COMP_CWORD)) && cword=$_j"),r.push(' _line="${_line#*"$_piece"}"'),r.push(" done"),r.push(' cur="${words[cword]}"'),r.push(' prev=""'),r.push(' ((cword > 0)) && prev="${words[cword-1]}"'),r.push(" return 0"),r.push(" }"),r.push("fi"),r.push(""),IZ(o.choices,r),EZ(o,r),Uq(t,[],r,o),r.push(`complete -F _${n} ${Al(e)}`),r.push(`###-end-${Al(e)}-completions-###`),r.join(`
77
+ `)};var Bs=(e)=>e.replace(/\\/g,"\\\\").replace(/'/g,"\\'"),Lq=(e)=>Bs(e.replace(/[^A-Za-z0-9_.,/@%+-]/gu,"\\$&")),wZ=(e,t)=>{if(e.length===0){if(t.length>0)return"__fish_use_subcommand";return""}let r=e.map((n)=>`__fish_seen_subcommand_from ${n}`).join("; and ");if(t.length>0)return`${r}; and not __fish_seen_subcommand_from ${t.join(" ")}`;return r},qA=(e)=>{let t=[];for(let n of e.aliases)if(n.length===1)t.push(`-s ${n}`);t.push(e.name);for(let n of e.aliases)if(n.length>1)t.push(n);let r=Oo(e);if(r!==void 0)t.push(r);return`not __fish_contains_opt ${t.join(" ")}`},AZ=(e)=>{let t=[`--${e.name}`];for(let r of e.aliases)t.push(r.length===1?`-${r}`:`--${r}`);return`begin; ${qA(e)}; or contains -- (commandline -poc)[-1] ${t.join(" ")}; end`},vZ=(e)=>{let t=[`-l ${e.name}`];for(let n of e.aliases)if(n.length===1)t.push(`-s ${n}`);else t.push(`-l ${n}`);if(e.description)t.push(`-d '${Bs(e.description)}'`);let r=cc(e)?CZ(e.type):void 0;if(r)t.push(r);return t},CZ=(e)=>{switch(e._tag){case"Boolean":return;case"Choice":return`-r -f -a '${e.values.map(Lq).join(" ")}'`;case"Path":if(e.pathType==="directory")return"-r -F";return"-r -F";default:return"-r -f"}},TZ=(e)=>{switch(e._tag){case"Choice":return`-r -f -a '${e.values.map(Lq).join(" ")}'`;case"Path":return"-r -F";default:return}},Mq=(e,t,r,n)=>{let o=t.subcommands.map((d)=>d.name),i=wZ(r,o),s=i?`-n '${i}'`:"";if(!t.arguments.some((d)=>d.type._tag==="Path")){let d=[`complete -c ${e}`];if(s)d.push(s);d.push("-f"),n.push(d.join(" "))}for(let d of t.subcommands){let x=[`complete -c ${e}`];if(s)x.push(s);if(x.push(`-f -a '${Bs(d.name)}'`),d.description)x.push(`-d '${Bs(d.description)}'`);n.push(x.join(" "))}for(let d of t.flags){let x=d.repeatable===!0?"":cc(d)?AZ(d):qA(d),f=[i,x].filter((A)=>A!=="").join("; and "),g=f?`-n '${f}'`:"",I=[`complete -c ${e}`];if(g)I.push(g);I.push(...vZ(d)),n.push(I.join(" "));let w=Oo(d);if(w!==void 0){let A=[`complete -c ${e}`];if(g)A.push(g);if(A.push(`-l ${w}`),d.description)A.push(`-d '${Bs(`Disable ${d.name}`)}'`);n.push(A.join(" "))}}if(t.flags.length>0){let x=i?`${i}; and not string match -q -- "-*" (commandline -ct)`:'not string match -q -- "-*" (commandline -ct)';for(let f of t.flags){let g=f.repeatable===!0?x:`${x}; and ${qA(f)}`,I=Oo(f),w=[`complete -c ${e}`];if(w.push(`-n '${g}'`),w.push(`-f -a '--${f.name}'`),f.description)w.push(`-d '${Bs(f.description)}'`);if(n.push(w.join(" ")),I!==void 0){let A=[`complete -c ${e}`];if(A.push(`-n '${g}'`),A.push(`-f -a '--${I}'`),f.description)A.push(`-d '${Bs(`Disable ${f.name}`)}'`);n.push(A.join(" "))}}}for(let d of t.arguments){let x=TZ(d.type);if(x){let f=[`complete -c ${e}`];if(s)f.push(s);if(f.push(x),d.description)f.push(`-d '${Bs(d.description)}'`);n.push(f.join(" "))}}for(let d of t.subcommands)Mq(e,d,[...r,d.name],n)},Fq=(e,t)=>{let r=[];return r.push(`###-begin-${e}-completions-###`),r.push("#"),r.push("# Static completion script for Fish"),r.push("#"),r.push("# Installation:"),r.push(`# ${e} --completions fish > ~/.config/fish/completions/${e}.fish`),r.push("#"),r.push(""),Mq(e,t,[],r),r.push(""),r.push(`###-end-${e}-completions-###`),r.join(`
78
+ `)};var qi=(e)=>{let t=[],r="";for(let n=0;n<e.length;n++){let o=e.charCodeAt(n);if(o>=32&&o<128){r+=e[n]==="'"?"''":e[n];continue}if(r!==""||t.length===0)t.push(`'${r}'`);r="",t.push(`[char]0x${o.toString(16).toUpperCase().padStart(4,"0")}`)}if(r!==""||t.length===0)t.push(`'${r}'`);return t.length===1?t[0]:`(${t.join(" + ")})`},Nq=(e)=>`@(${e.map(qi).join(", ")})`,WA=(e)=>e?qi(e):"$null",PZ=(e)=>e.replace(/[^a-zA-Z0-9_]/g,"_"),RZ=(e)=>[`--${e.name}`,...e.aliases.map((t)=>t.length===1?`-${t}`:`--${t}`)],Bq=(e)=>`values = ${Nq(e._tag==="Choice"?e.values:[])}; pathType = ${e._tag==="Path"?qi(e.pathType):"$null"}`,_Z=(e)=>{let t=Oo(e);return`@{ name = ${qi(e.name)}; forms = ${Nq(RZ(e))}; takesValue = $${e.type._tag!=="Boolean"}; `+(t===void 0?"":`negation = ${qi(`--${t}`)}; `)+(e.optionalValue===!0?"optionalValue = $true; ":"")+(e.repeatable===!0?"repeatable = $true; ":"")+`${Bq(e.type)}; description = ${WA(e.description)} }`},UZ=(e)=>`@{ name = ${qi(e.name)}; variadic = $${e.variadic}; ${Bq(e.type)}; description = ${WA(e.description)} }`,$A=(e,t,r)=>{if(r.length===0){e.push(` ${t} = @()`);return}e.push(` ${t} = @(`);for(let n of r)e.push(` ${n}`);e.push(" )")},Kq=(e,t,r,n,o)=>{let i=r.join(" ");if(o.has(i))return;o.add(i),n.push(`${e}[${qi(i)}] = @{`),$A(n,"subcommands",t.subcommands.map((s)=>`@{ name = ${qi(s.name)}; description = ${WA(s.description)} }`)),$A(n,"flags",t.flags.map(_Z)),$A(n,"arguments",t.arguments.map(UZ)),n.push("}");for(let s of t.subcommands)Kq(e,s,[...r,s.name],n,o)},DZ=(e)=>String.raw` param($wordToComplete, $commandAst, $cursorPosition)
78
79
 
79
80
  $spec = ${e}
80
81
  $results = [System.Collections.Generic.List[System.Management.Automation.CompletionResult]]::new()
@@ -263,10 +264,10 @@ ${s}${i}ERRORS${o}`);for(let[,m]of l)for(let g of m)S.push(` ${Vh(g.message)}${
263
264
  if (-not $endOfOptions) {
264
265
  & $addFlags $typed
265
266
  }
266
- return $results`,ZK=(e,t)=>{let r=`$global:_${s9(e)}_Completions`,n=[];return n.push(`###-begin-${e}-completions-###`),n.push("#"),n.push("# Static completion script for PowerShell"),n.push("#"),n.push("# Installation:"),n.push(`# ${e} --completions powershell > ${e}-completion.ps1`),n.push("# then add this line to your $PROFILE (use the full path to the file):"),n.push(`# . <PATH>\\${e}-completion.ps1`),n.push("#"),n.push(""),n.push(`${r} = [hashtable]::new([System.StringComparer]::Ordinal)`),YK(r,t,[],n,new Set),n.push(""),n.push(`Register-ArgumentCompleter -Native -CommandName ${wi(e)} -ScriptBlock {`),n.push(d9(r)),n.push("}"),n.push(""),n.push(`###-end-${e}-completions-###`),n.join(`
267
- `)};var ey=(e)=>e.replace(/\\/g,"\\\\").replace(/'/g,"'\\''").replace(/:/g,"\\:"),XK=(e)=>ey(e).replace(/]/g,"\\]"),nq=(e)=>e.replace(/[^A-Za-z0-9_.,/@%+-]/gu,"\\$&").replace(/'/g,"'\\''"),Bk=(e)=>e.replace(/[^a-zA-Z0-9_]/g,"_"),l9=(e)=>{let t=[`--${e.name}`];for(let n of e.aliases)t.push(n.length===1?`-${n}`:`--${n}`);let r=yo(e);if(r!==void 0)t.push(`--${r}`);return t},eq=(e)=>{switch(e._tag){case"Boolean":return"";case"Choice":return`:value:(${e.values.map(nq).join(" ")})`;case"Path":return e.pathType==="directory"?":directory:_directories":":file:_files";case"Int":return":integer:";case"Finite":return":float:";case"Date":return":date:";default:return":value:"}},f9=(e)=>{switch(e._tag){case"Choice":return`(${e.values.map(nq).join(" ")})`;case"Path":return e.pathType==="directory"?"_directories":"_files";default:return""}},tq=(e)=>{let t=[],r=e.description?`[${XK(e.description)}]`:"",n=e.optionalValue===!0&&e.type._tag!=="Boolean",o=n?"=-":"",i=n?`:${eq(e.type)}`:eq(e.type),s=e.repeatable===!0?"*":`(${l9(e).join(" ")})`;t.push(`'${s}--${e.name}${o}${r}${i}'`);for(let l of e.aliases){let S=l.length===1?"-":"--";t.push(`'${s}${S}${l}${o}${r}${i}'`)}let c=yo(e);if(c!==void 0){let l=e.description?`[${XK(`Disable ${e.name}`)}]`:"";t.push(`'${s}--${c}${l}'`)}return t},rq=(e)=>{let t=e.description?ey(e.description):e.name,r=f9(e.type);return`'${e.variadic?"*":""}:${t}:${r}'`},oq=(e,t,r)=>{let n=[...t,e.name],o=`_${n.map(Bk).join("_")}`;if(r.push(`${o}() {`),e.subcommands.length>0){r.push(" local context state state_descr line"),r.push(" typeset -A opt_args"),r.push(""),r.push(" local -a commands"),r.push(" commands=(");for(let i of e.subcommands){let s=i.description?ey(i.description):"";r.push(` '${ey(i.name)}:${s}'`)}r.push(" )"),r.push(""),r.push(" local -a specs"),r.push(" specs=(");for(let i of e.flags)for(let s of tq(i))r.push(` ${s}`);if(e.arguments.length>0){r.push(" -"),r.push(" parent-arguments");for(let i of e.arguments)r.push(` ${rq(i)}`);r.push(" -"),r.push(" subcommands")}r.push(" '1:command:->command'"),r.push(" '*::arg:->args'"),r.push(" )"),r.push(""),r.push(' _arguments -C "${specs[@]}"'),r.push(""),r.push(' case "$state" in'),r.push(" command)"),r.push(" _describe -t commands 'commands' commands"),r.push(" ;;"),r.push(" args)"),r.push(' case "$words[1]" in');for(let i of e.subcommands){let s=`_${[...n,i.name].map(Bk).join("_")}`;r.push(` ${i.name})`),r.push(` ${s}`),r.push(" ;;")}r.push(" esac"),r.push(" ;;"),r.push(" esac")}else{let i=[];for(let s of e.flags)i.push(...tq(s));for(let s of e.arguments)i.push(rq(s));if(i.length>0){r.push(" local -a specs"),r.push(" specs=(");for(let s of i)r.push(` ${s}`);r.push(" )"),r.push(' _arguments "${specs[@]}"')}}r.push("}"),r.push("");for(let i of e.subcommands)oq(i,n,r)},iq=(e,t)=>{let r=[],n=Bk(e);return r.push(`#compdef ${e}`),r.push(`###-begin-${e}-completions-###`),r.push("#"),r.push("# Static completion script for Zsh"),r.push("#"),r.push("# Installation:"),r.push(`# ${e} --completions zsh > ~/.zsh/completions/_${e}`),r.push("# then add ~/.zsh/completions to your fpath"),r.push("#"),r.push(""),oq(t,[],r),r.push("# Handle both direct invocation and autoload"),r.push('if [[ "${zsh_eval_context[-1]}" == "loadautofunc" ]]; then'),r.push(` _${n} "$@"`),r.push("else"),r.push(` compdef _${n} ${e}`),r.push("fi"),r.push(`###-end-${e}-completions-###`),r.join(`
268
- `)};var sq=(e)=>Uk(e),aq=(e,t,r)=>{switch(t){case"bash":return zK(e,r);case"zsh":return iq(e,r);case"fish":return HK(e,r);case"powershell":return ZK(e,r)}};var C=(e)=>Wh(ho,e),ht=(e)=>DK(ho,e),Le=(e)=>Sk(ho,e);var Kk=(e,t)=>Gh(ho,e,t),ke=(e,t)=>zh(ho,e,t);var qk=q(2,(e,t)=>LK(e,t)),Oe=q(2,(e,t)=>bk(e,t));var $k=q(2,(e,t)=>vk(e,t));var E=(e)=>up(e),tt=Ek;var Ir=q(2,(e,t)=>Ak(e,t)),h9=q(2,(e,t)=>kk(e,t));var fe=q(2,(e,t)=>Qh(e,t));var Wk=(e)=>{let t=new Set,r=[];for(let n of e){if(t.has(n))continue;t.add(n),r.push(n)}return r},pq=(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},Gk=(e,t,r)=>{let o=pq(e,t).flatMap((i)=>Dt(i).globalFlags);return Wk([...r,...o])},y9=(e)=>{let t=[],r=(n)=>{let o=Dt(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),Wk(t)},g9=(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=Dt(o);for(let s of i.contextConfig.flags){let c=qt(s),l=Bo(s);for(let S of c){if(r.has(S.name))continue;if(S.hidden)continue;r.add(S.name),n.push(Zh(S,l))}}}return n},dq=(e,t)=>Wk([...t,...y9(e)]),ty=(e,t,r)=>kr(function*(){let n=pq(e,t),o=n.length>0?n[n.length-1]:e,i=Dt(o).buildHelpDoc(t),s=g9(n,i.flags),c=Gk(e,t,r),l=[];for(let m of c){let g=qt(m.flag),w=Bo(m.flag);for(let k of g){if(k.hidden)continue;l.push({...Zh(k,w),required:!1})}}let S=1;for(let m=n.length-1;m>0;m--)if(Dt(n[m]).globalFlags.length>0){S=m+1;break}return{...i,inheritedFlags:s,globalFlags:l,globalFlagsScope:t.slice(0,S),commandPath:t}});var ry=(e)=>({_tag:"Action",flag:e.flag,run:e.run}),S9=(e)=>(t)=>{uq+=1;let r=Vt(`effect/cli/GlobalFlag/${e}/${uq}`);return Object.assign(r,{_tag:"Setting",id:e,flag:t.flag})},uq=0,b9=ry({flag:ht("help").pipe(qk("h"),Oe("Show help information"),tt(!1)),run:Ie(function*(e,{builtIns:t,command:r,commandPath:n}){let o=yield*fp,i=yield*ty(r,n,t);yield*o.present({_tag:"Help",reason:"Requested",commandPath:n,helpDoc:i})})}),I9=ry({flag:ht("version").pipe(qk("v"),Oe("Show version information"),tt(!1)),run:Ie(function*(e,{command:t,version:r}){yield*(yield*fp).present({_tag:"Version",name:t.name,version:r})})}),zk=ry({flag:ht("wizard").pipe(Oe("Start wizard mode for a command"),tt(!1)),run:()=>Je}),w9=ry({flag:Kk("completions",[["bash","bash"],["zsh","zsh"],["fish","fish"],["powershell","powershell"],["sh","bash"],["pwsh","powershell"]]).pipe(E,$k("<bash|zsh|fish|powershell|sh|pwsh>"),Oe("Print shell completion script")),run:Ie(function*(e,{command:t}){if(sr(e))return;let r=sq(t);yield*gr(aq(t.name,e.value,r))})}),mp=S9("log-level")({flag:Kk("log-level",[["all","All"],["trace","Trace"],["debug","Debug"],["info","Info"],["warn","Warn"],["warning","Warn"],["error","Error"],["fatal","Fatal"],["none","None"]]).pipe(E,Oe("Sets the minimum log level"),$k("<all|trace|debug|info|warn|warning|error|fatal|none>"))}),lq=[b9,I9,zk,w9,mp];class ny extends Jt("effect/cli/CliConfig",{defaultValue:()=>E9}){}var E9={builtIns:lq};var mq=Ix((e)=>j(nc(e,Ok)??Yh({colors:dn(e,qh).canColor})));function yq(e){let t=e.indexOf("--");if(t===-1)return{tokens:hq(e),trailingOperands:[]};return{tokens:hq(e.slice(0,t)),trailingOperands:e.slice(t+1)}}var gq=(e)=>{if(e._tag==="Value")return e.value;if(e._tag==="LongOption")return e.raw;let t=xq.test(e.raw)?`--${e.flag}`:e.raw;return e.value===void 0?t:`${t}=${e.value}`},xq=/^-(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?$/,hq=(e)=>{let t=[];for(let r of e)if(!r.startsWith("-")||xq.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 A9=(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]},Qk=(e,t)=>{let r=t.map((o)=>[A9(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 Vk=(e)=>$r(e.subcommand,{onNone:()=>[],onSome:(t)=>[t.name,...Vk(t.parsedInput)]}),Jk=(e,t,r=[])=>kr(function*(){let{tokens:n,trailingOperands:o}=e,i=[...r,t.name],s=Pq(n,Oq(t,i));if(s._tag==="Leaf")return{flags:s.flags,arguments:[...s.arguments,...o],subcommand:ge(),...s.errors.length>0&&{errors:s.errors}};let c={tokens:s.childTokens,trailingOperands:o},l=yield*Jk(c,s.sub,i),S=[...s.errors,...l.errors??[]];return{flags:s.flags,arguments:[],subcommand:Ue({name:s.sub.name,parsedInput:l}),...S.length>0&&{errors:S}}}),Yk=(e,t)=>{let r=Pq(e,Oq(t,[]));return r._tag==="Leaf"?e:Yk(r.childTokens,r.sub)},oy=(e)=>{let t=0;return{peek:()=>e[t],take:()=>e[t++],rest:()=>e.slice(t)}},Iq=(e)=>!ek(e.primitiveType)||e.negation===!1?void 0:e.negation??`no-${e.name}`,yp=(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=Iq(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}},wq=(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},Zk=(e)=>Object.fromEntries(e.map((t)=>[t.name,[]])),v9=(e)=>{let t=Zk(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}},iy=(e)=>e._tag==="LongOption"||e._tag==="ShortOption",Eq=(e)=>e._tag==="LongOption"?e.name:e.flag,hp=(e,t)=>{let r=Eq(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},Sq=(e,t,r)=>new En({option:t.name,value:r,expected:`omit the value and use ${e.raw} by itself to set --${t.name} to false`,kind:"flag"}),C9=(e)=>{let t=bi(e.primitiveType);return new En({option:e.name,value:"",expected:t===void 0?e.typeName??Bu(e.primitiveType):t.join(" | "),kind:"flag"})},bq=(e)=>e?._tag==="Value"&&(BB(e.value)||KB(e.value))?e.value:void 0,kq=(e,t,r,n=!1)=>{let o=Yu(e,t,r,n);switch(o._tag){case"Value":return{_tag:"Value",value:o.value};case"Error":return{_tag:"Error",error:o.error}}},Yu=(e,t,r,n=!1)=>{if(n){if(t.value!==void 0)return{_tag:"Error",error:Sq(t,r,t.value),tokens:[]};let i=r.optionalValue===void 0?bq(e.peek()):void 0;if(i!==void 0){let s=e.take();return{_tag:"Error",error:Sq(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(ek(r.primitiveType)){let i=bq(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:C9(r),tokens:[]}},T9=(e,t)=>{let r=Zk(t.params),n=[],o=[],i=oy(e);for(let s=i.take();s;s=i.take()){if(!iy(s)){n.push(s);continue}let c=hp(s,t);if(!c){n.push(s);continue}let l=kq(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}},Aq=(e)=>Dt(e).config.flags.flatMap(qt).filter(zu),vq=(e)=>Dt(e).contextConfig.flags.flatMap(qt).filter(zu),Cq=(e,t)=>{for(let r of t){let n=hp(e,r);if(n!==void 0)return n}return},Hk=(e,t,r,n)=>{e.push(r);let o=Yu(t,r,n.param,n.negated);e.push(...o.tokens)},O9=(e,t,r,n,o)=>{let i=oy(t);Yu(i,e,r.param,r.negated);for(let s=i.take();s;s=i.take()){if(iy(s)){let c=Cq(s,o);if(c!==void 0)Yu(i,s,c.param,c.negated);continue}if(s._tag==="Value")return n.has(s.value)}return!1},Tq=(e,t,r)=>{let n=Zk(r.params),o=[],i=(s,c,l)=>{let S=yp(Aq(c)),m=yp(vq(c)),g=wq(c.subcommands),w=oy(s),k=[],A=!0;for(let y=w.take();y;y=w.take()){if(iy(y)){let h=Cq(y,l);if(h!==void 0){Hk(k,w,y,h);continue}let x=hp(y,m);if(x!==void 0){Hk(k,w,y,x);continue}let z=hp(y,S),X=hp(y,r);if(z!==void 0){if(X===void 0||!A||!O9(y,w.rest(),z,g,[S,m,r])){Hk(k,w,y,z);continue}}if(X!==void 0){let I=Yu(w,y,X.param,X.negated);if(I._tag==="Error"){o.push(I.error);continue}if(I.value!==void 0)n[X.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}},P9=(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=Iq(s);if(c!==void 0)o.push(c);for(let l of s.aliases)o.push(l)}let i=Qk(Eq(e),o).map((s)=>s.length===1?`-${s}`:`--${s}`);return new va({option:n,suggestions:i,command:r})},R9=(e)=>({flags:v9(e.params),arguments:[],errors:[],mode:{_tag:"AwaitingFirstValue"}}),_9=(e)=>({_tag:"Leaf",flags:e.flags.snapshot(),arguments:e.arguments,errors:e.errors}),U9=(e,t,r,n)=>{let{command:o,commandPath:i,inheritedFlagRegistry:s,localFlagNames:c}=r,l=wq(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 va({option:`--${A}`,suggestions:[],command:g}))}let k=T9(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(!(Dt(o).config.arguments.length>0)&&l.size>0){let g=[];for(let[k,A]of l)if(!A.unlisted)g.push(k);let w=Qk(e,g);n.errors.push(new Lh({subcommand:e,parent:i,suggestions:w}))}return{_tag:"Argument"}},D9=(e,t,r,n)=>{let{commandPath:o,flagRegistry:i}=r,s=hp(e,i);if(!s){n.errors.push(P9(e,i.params,o));return}let c=kq(t,e,s.param,s.negated);if(c._tag==="Error"){n.errors.push(c.error);return}n.flags.add(s.param.name,c.value)},L9=(e,t,r,n)=>{if(n.mode._tag==="AwaitingFirstValue"){let o=U9(e,t,r,n);if(o._tag==="Subcommand")return o.result;n.mode={_tag:"CollectingArguments"}}n.arguments.push(e);return},Oq=(e,t)=>{let r=Aq(e),n=vq(e),o=new Set(n.map((i)=>i.name));return{command:e,commandPath:t,flagRegistry:yp(r),inheritedFlagRegistry:yp(n),localFlagNames:r.filter((i)=>!o.has(i.name)).map((i)=>i.name)}},Pq=(e,t)=>{let r=oy(e),n=R9(t.flagRegistry);for(let o=r.take();o;o=r.take()){if(iy(o)){D9(o,r,t,n);continue}if(o._tag==="Value"){let i=L9(o.value,r,t,n);if(i)return i}}return _9(n)};var Uq=Ie(function*(e,t){let r=t?.commandPath??[e.name],n=F9(e,r),o=(t?.prefix??r).map((s)=>Gn(s)),{colors:i}=yield*$u;return yield*sy(o,i),yield*Dq(n,o,n===e?"ROOT":n.name,i),{args:o.map((s)=>s.value),displayArgs:o.map((s)=>s.displayValue)}}),F9=(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},Dq=Ie(function*(e,t,r,n){let o=Dt(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*gr(_q(r,"FLAGS",n));for(let l of s.flags)t.push(...yield*Rq(l));if(s.arguments.length>0||i.length>0)yield*sy(t,n)}if(s.arguments.length>0){if(yield*gr(_q(r,"ARGUMENTS",n)),i.length===0)t.push(Gn("--"));for(let l of s.arguments)t.push(...yield*Rq(l));if(i.length>0)yield*sy(t,n)}if(i.length===0)return;let c=yield*an(pk({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*gr(),t.push(Gn(c.name)),N9(c))yield*sy(t,n);yield*Dq(c,t,c.name,n)}),N9=(e)=>e.subcommands.some((r)=>r.commands.some((n)=>!n.unlisted))||Dt(e).config.orderedParams.length>0,Rq=Ie(function*(e){let t=Hh(e),r=Bo(e);if(r.isOptional){if(!(yield*an(ak({message:`Set ${Xk(t)}?`,initial:!1}))))return yield*gr(),[]}let n=!r.isVariadic?1:yield*an(ck({message:`${Xk(t)} count`,default:fr(r.variadicMin,()=>0),min:fr(r.variadicMin,()=>0),...O(r.variadicMax)?{max:r.variadicMax.value}:{}})),o=[];for(let s=0;s<n;s++)o.push(yield*B9(t));let i=t.kind===ho?{flags:{[t.name]:o.map((s)=>s.value)},arguments:[]}:{flags:{},arguments:o.map((s)=>s.value)};if(yield*e.parse(i),yield*gr(),t.kind===lp)return o;return o.flatMap((s)=>t.optionalValue!==void 0||s.value.startsWith("-")&&s.value.length>1?[Gn(`--${t.name}=${s.value}`,`--${t.name}=${s.displayValue}`)]:[Gn(`--${t.name}`),s])}),B9=(e)=>{let t=q9(e);switch(e.primitiveType._tag){case"Boolean":return De(an(ak({message:t,label:{confirm:"true",deny:"false"},placeholder:{defaultConfirm:"(T/f)",defaultDeny:"(t/F)"}})),(r)=>Gn(String(r)));case"Choice":{let r=bi(e.primitiveType)??[];return De(an(pk({message:t,choices:r.map((n)=>({title:n,value:n}))})),Gn)}case"Date":return De(an(aK({message:t})),(r)=>Gn(r.toISOString()));case"Finite":return De(an(cK({message:t})),(r)=>Gn(String(r)));case"Int":return De(an(ck({message:t})),(r)=>Gn(String(r)));case"Redacted":return De(an(pK({message:t})),(r)=>Gn(Kc(r),"<redacted>"));default:return De(an(dK({message:t})),Gn)}},Gn=(e,t=e)=>({value:e,displayValue:t}),K9=(e)=>e.kind===ho?`--${e.name}`:e.name,q9=(e)=>Xk(e),Xk=(e)=>{let t=f(e.description)?.trim(),r=e.kind===ho&&t!==void 0&&t.length<=32?t:$9(e.name);return e.kind===ho?`${r} (${K9(e)})`:r},$9=(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(" ")},sy=(e,t)=>gr(Nq("Current command",e.map((r)=>r.displayValue),t,JB)),_q=(e,t,r)=>`${wt(r,e.toUpperCase(),Ii,pp)} ${wt(r,"\xB7",qu)} ${wt(r,t,Ii,Oa)}`,Lq=(e,t,r,n)=>[`${wt(n,e,Ii,pp)} ${wt(n,`v${t}`,Oa)} ${wt(n,"\xB7 Command wizard",Ii,Oa)}`,...r===void 0||r.length===0?[]:[r],wt(n,"Build a command interactively. Press Ctrl+C to cancel.",qu),""].join(`
269
- `),Mq=(e,t)=>Nq("Command ready",e,t,pp,Bh),Fq=(e)=>`
270
- ${wt(e,"Wizard cancelled.",Nh)}`,Nq=(e,t,r,n,o=Oa)=>{let i=W9(t);return[wt(r,e,Ii,o),...i.map((s)=>wt(r,s,n)),""].join(`
271
- `)},W9=(e)=>{let o=e.map(G9),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},G9=(e)=>/^[A-Za-z0-9_./:@%+=,-]+$/.test(e)?e:`'${e.replaceAll("'",`'"'"'`)}'`;var j9=(e)=>He(e,Qu),T=(e,t,r)=>{let n=Pk(t??{});return Hu({name:e,config:n,...Yt(r)?{handle:r}:{}})};var Q9=(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(j9(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}},Ze=q(2,(e,t)=>{let r=Q9(t);qK(e,r.flat);let n=Dt(e),o=new Map(r.flat.map((l)=>[l.name,Dt(l)])),i=Symbol("effect/cli/SubcommandState"),s=Ie(function*(l){if(sr(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=Ie(function*(l,S){let g=l[i];if(g){let w=o.get(g.name);if(!w)return yield*new Si({commandPath:S,errors:[]});return yield*w.handle(g.result,[...S,w.name]).pipe(Vi(n.service,l))}return yield*n.handle(l,S)});return Hu({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=q(2,(e,t)=>Hu({...Dt(e),description:t}));var F=q(3,(e,t,r)=>{let n=Dt(e);return Hu({...n,annotations:ko(n.annotations,t,r)})});var H9=(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=qt(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 va({option:g,suggestions:[],command:n}))}}return i},V9=(e,t,r)=>kr(function*(){let{builtIns:n}=yield*ny,o=yield*fp,{commandPath:i,errors:s}=t,c=yield*ty(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})}),J9=(e,t)=>kr(function*(){let r=yield*mq,n=e instanceof Nu?e:new Nu({cause:e,userMessage:t});yield*qm(r.formatError(n)),Object.assign(e,{[uu]:!1})});var Bq=(e,t)=>{let r=Dt(e);return Ie(function*(n){let{builtIns:o}=yield*ny,{tokens:i,trailingOperands:s}=yq(n),c=dq(e,o),l=c.flatMap((Q)=>qt(Q.flag)),S=yp(l.filter(zu)),{flagMap:m,remainder:g,errors:w}=Tq(i,e,S),k={flags:m,arguments:[]},A=yield*Jk({tokens:g,trailingOperands:s},e),y=[e.name,...Vk(A)],h=(Q)=>Q._tag==="ShowHelp"?Q:new Si({commandPath:y,errors:[Q]}),x=Rr(h),z={builtIns:o,command:e,commandPath:y,version:t.version},X=Gk(e,y,o),I=H9(c,X,m,y);if(I.length>0||w.length>0){let Q=A.errors??[];return yield*new Si({commandPath:y,errors:[...w,...I,...Q]})}for(let Q of X){if(Q._tag!=="Action")continue;if(!qt(Q.flag).some((se)=>{let le=m[se.name];return le!==void 0&&le.length>0}))continue;let[,ae]=yield*Q.flag.parse(k).pipe(x);if(Q===zk){let{colors:se}=yield*$u;return yield*kr(function*(){yield*gr(Lq(e.name,t.version,e.description,se));let le=new Set(Yk(g,e)),Se=[e.name,...i.filter(($e)=>!le.has($e)&&!($e._tag==="LongOption"&&$e.name==="wizard")).map(gq)],ve=yield*Uq(e,{commandPath:y,prefix:Se});if(yield*gr(Mq(ve.displayArgs,se)),yield*an(uK({message:"Run this command?",initial:!0,active:"yes",inactive:"no"})))yield*gr(),yield*Bq(e,{...t,renderErrors:!1})(ve.args.slice(1))}).pipe(yd("QuitError",()=>gr(Fq(se))))}yield*Q.run(ae,z);return}if(A.errors&&A.errors.length>0)return yield*new Si({commandPath:y,errors:A.errors});let me=yield*r.parse(A).pipe(Rr((Q)=>XE(Q)?h(Q):Q)),pe=r.handle(me,[e.name]),K=X.includes(mp)?(yield*mp.flag.parse(k).pipe(x))[1]:ge();pe=Vi(pe,mp,K);for(let Q of X){if(Q._tag!=="Setting"||Q===mp)continue;let[,te]=yield*Q.flag.parse(k).pipe(x);pe=Vi(pe,Q,te)}let ee=$r(K,{onNone:()=>un(),onSome:(Q)=>Ks(nO,Q)});yield*Hi(pe,ee)},Cf((n)=>XE(n)&&n._tag==="ShowHelp"?Xt(n):Nt(n),(n)=>eo(V9(e,n,t.renderErrors!==!1),he(n))),Cf((n)=>{if(t.renderErrors===!1||!Pp(n))return Nt(n);let o=FB(n);return o===void 0?Nt(n):Xt({error:n,userMessage:o})},({error:n,userMessage:o})=>eo(J9(n,o),he(n))),Cf((n)=>wU(n)?Xt(n):Nt(n),(n)=>Sd))};var Zu={name:"@pubnio/cli",version:"0.2.12",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:{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 Kq(e){let t,r=Aa({...e,onRuntime:(n)=>{t=n}});if(!t)throw Error("PubNio client runtime was not captured.");return{client:r,runtime:t}}class _ extends Vt()("@pubnio/cli/CliOperations"){}function qq(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 N=C("workspace").pipe(fe(de),E,Oe("Workspace ID. Defaults to PUBNIO_WORKSPACE_ID or your only workspace.")),$q=ne("id").pipe(ie(de)),vbe=C("name").pipe(fe(FU.fields.name)),Cbe=C("default-timezone").pipe(E,Oe("Default IANA time zone for new queues, e.g. America/New_York.")),Xu=ht("browser").pipe(tt(qq().browser),Oe("Open the browser automatically. Defaults to on only for an interactive terminal; pass --browser or --no-browser to override.")),eA=C("account").pipe(fe(V),E,Oe("Publishing account ID.")),Wq=C("account").pipe(fe(V),Ir(0),Oe("Publish to this exact publishing account ID, or save it as a draft target. Repeat for several accounts.")),Gq=C("account").pipe(fe(bu.fields.accountId),E,Oe("Publish to this existing post target account.")),ot=C("idempotency-key").pipe(fe(Vr),E,Oe("Reuse a key to replay this request safely. Generated when omitted.")),Ss={cursor:C("cursor").pipe(E),limit:Le("limit").pipe(E)};class Fe extends Error{}function Et(e){return(e==="-"?Bun.stdin:Bun.file(e)).json().catch(()=>{throw new Fe("Could not read JSON input.")})}function R(e){return js({try:e,catch:(t)=>t}).pipe(ji((t)=>Be(()=>console.log(JSON.stringify(t,null,2)))))}function ay(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 zq=p({clientId:a});var jq="/api/auth/cli";var Qq=new TextDecoder,Hq=new TextDecoder("utf-8",{fatal:!0});function Vq(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 Jq 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 Ei extends Jq{static code="ERR_JWT_INVALID";code="ERR_JWT_INVALID"}var Z9="The input to be decoded is not correctly encoded.";function Yq(e){try{return Vq(typeof e=="string"?e:Qq.decode(e),!0)}catch(t){throw TypeError(Z9,{cause:t})}}function Zq(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 tA(e){if(typeof e!="string")throw new Ei("JWTs must use Compact JWS serialization, JWT must be a string");let{1:t,length:r}=e.split(".");if(r===5)throw new Ei("Only JWTs using Compact JWS serialization can be decoded");if(r!==3)throw new Ei("Invalid JWT");if(!t)throw new Ei("JWTs must contain a payload");let n;try{n=Yq(t)}catch(i){throw new Ei("Failed to base64url decode the payload",{cause:i})}let o;try{o=JSON.parse(Hq.decode(n))}catch(i){throw new Ei("Failed to parse the decoded payload as JSON",{cause:i})}if(!Zq(o))throw new Ei("Invalid JWT Claims Set");return o}var T$=J1(A$(),1);import{mkdir as F5,rename as v$,rm as Ba,writeFile as C$}from"fs/promises";import{homedir as N5}from"os";import{join as xA}from"path";var B5="https://api.workos.com/user_management",K5=(e)=>{let t=xA(process.env.XDG_CONFIG_HOME||xA(N5(),".config"),"pubnio"),r=new Bun.CryptoHasher("sha256").update(e).digest("hex");return{dir:t,file:xA(t,`${r}.json`)}},SA=p({access_token:a,refresh_token:a}),q5=p({clientId:a,...SA.fields,workspaceId:u(de)}),O$=p({device_code:a,user_code:a,verification_uri:a,verification_uri_complete:a,expires_in:yr.check(Mo(0)),interval:yr.check(Mo(0))});class by extends Error{code;status;constructor(e,t){super(`WorkOS request failed (HTTP ${t}).`);this.code=e;this.status=t}}var $5="Sign in with `pnio auth login`.";async function bA(e,t,r,n){let o=await e(`${B5}/${t}`,{method:"POST",body:new URLSearchParams(r),redirect:"error",signal:AbortSignal.timeout(1e4)}),i=await o.json().catch(()=>null);if(o.ok)return ao(n)(i);let s=i&&typeof i==="object"&&"error"in i&&typeof i.error==="string"?i.error:"unknown";throw new by(s,o.status)}var W5=p({clientId:a,device:O$,expiresAt:yr}),P$=(e)=>`${e}.device.json`;async function G5(e,t){let r=`${e}.${crypto.randomUUID()}.tmp`;try{await C$(r,JSON.stringify(t),{mode:384,flag:"wx"}),await v$(r,e)}finally{await Ba(r,{force:!0})}}async function z5(e,t=fetch){let r=await bA(t,"authorize/device",{client_id:e},O$),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 R$(e){let t=await kA(e,"GET"),{clientId:r}=await ao(zq)(await t.json()),{device:n,url:o,completeUrl:i}=await z5(r),s=Date.now()+n.expires_in*1000;return await il(e,async(c)=>{await G5(P$(c),{clientId:r,device:n,expiresAt:s})}),{url:o,completeUrl:i,userCode:n.user_code,expiresAt:new Date(s).toISOString()}}async function j5(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 bA(n,"authenticate",{client_id:e,grant_type:"urn:ietf:params:oauth:grant-type:device_code",device_code:t.device_code},SA);return{clientId:e,...s}}catch(s){if(s instanceof by){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 IA(e,{timeoutMs:t=600000}={}){return il(e,async(r)=>{let n=P$(r),o=await Q5(n);if(!o)throw Error("No sign-in is pending. Run `pnio auth login`.");if(o.expiresAt<=Date.now())throw await Ba(n,{force:!0}),Error("Sign-in expired. Run `pnio auth login` again.");let i=await j5(o.clientId,o.device,Math.min(t,o.expiresAt-Date.now())).catch(async(s)=>{throw await Ba(n,{force:!0}),s});return await kA(e,"POST",i.access_token),await EA(r,i),await Ba(n,{force:!0}),i.access_token})}async function Q5(e){let t=Bun.file(e);if(!await t.exists())return;return ao(W5)(await t.json())}async function wA(e){let t=Bun.file(e);if(!await t.exists())return;return ao(q5)(await t.json())}async function EA(e,t){let r=`${e}.${crypto.randomUUID()}.tmp`;try{await C$(r,JSON.stringify(t),{mode:384,flag:"wx"}),await v$(r,e)}finally{await Ba(r,{force:!0})}}async function il(e,t){let{dir:r,file:n}=K5(e);await F5(r,{recursive:!0,mode:448});let o=await T$.default.lock(n,{realpath:!1,retries:{retries:20,minTimeout:100,maxTimeout:1000}});try{return await t(n)}finally{await o()}}async function kA(e,t,r){let n=await fetch(`${e}${jq}`,{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 _$(e,t){let{exp:r}=tA(t.access_token);if(r&&r*1000>Date.now()+30000)return t.access_token;try{let n=await bA(fetch,"authenticate",{client_id:t.clientId,grant_type:"refresh_token",refresh_token:t.refresh_token},SA);return await EA(e,{...t,...n}),n.access_token}catch(n){if(!(n instanceof by&&n.code==="invalid_grant"))throw n;await Ba(e,{force:!0});return}}async function U$(e){return il(e,async(t)=>{let r=await wA(t),n=r&&await _$(t,r);if(!n||!r)throw Error($5);return{token:n,workspaceId:r.workspaceId}})}async function D$(e,t,r){await il(e,async(n)=>{let o=await wA(n);if(o?.access_token!==t)throw Error("The CLI session changed. Run the workspace command again.");await EA(n,{...o,workspaceId:r})})}async function L$(e){return il(e,async(t)=>{let r=await wA(t),n=r&&await _$(t,r);if(n)await kA(e,"DELETE",n);await Ba(t,{force:!0})})}function Ai(){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 Fe("PUBNIO_BASE_URL must be an HTTPS origin or a local HTTP origin.");return e.origin}async function M$(e,t){let r=t==="default"?process.env.PUBNIO_API_KEY:void 0;if(r!==void 0&&!_b.test(r))throw new Fe("PUBNIO_API_KEY is not a valid PubNio API key.");let n=r===void 0?await U$(e):void 0;return{apiKey:r,session:n}}async function go(e=Ai(),t="default"){let{apiKey:r,session:n}=await M$(e,t),o=Aa({baseUrl:e,clientName:"cli",clientVersion:Zu.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 D$(e,n.token,s.id);return s}}}async function J(e=Ai(),t="default"){let{apiKey:r,session:n}=await M$(e,t);return{...Kq({baseUrl:e,clientName:"cli",clientVersion:Zu.version,...r!==void 0?{apiKey:r}:{accessToken:n?.token}}),selectedWorkspaceId:n?.workspaceId}}async function Z(e,t,r){let n=t??process.env.PUBNIO_WORKSPACE_ID??e.selectedWorkspaceId??r;if(n!==void 0){let i=ns(de)(n);if(i._tag==="None")throw new Fe("Expected a workspace UUID.");return i.value}let{workspaces:o}=await e.workspaces.list();if(o.length!==1)throw new Fe("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 Ke(e,{origin:t,auth:r}={}){let n=await go(t,r);return n.workspace(await Z(n,e))}var F$=[T("list-accounts",{workspace:N,state:ke("state",["available","selected"]).pipe(E),cursor:C("cursor").pipe(E),limit:Le("limit").pipe(E)},(e)=>R(async()=>{let t=await J();return t.runtime.decode(H,Jw({client:t.runtime.client,query:{workspaceId:await Z(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(F(_,["ads.listAccounts"]),P("List available and selected ad accounts")),T("connect-account",{workspaceId:C("workspace-id").pipe(fe(a.check(L()))),provider:ke("provider",["meta_ads","google_ads","reddit_ads","pinterest_ads","tiktok_ads","linkedin_ads","snapchat_ads","amazon_ads","openai_ads"]),accountId:C("account-id").pipe(fe(a.check(L()))).pipe(E)},(e)=>R(async()=>{let t=await J(void 0,"human");return t.runtime.decode(H,Yw({client:t.runtime.client,body:{workspaceId:e.workspaceId,provider:e.provider,...O(e.accountId)?{accountId:f(e.accountId)}:{}},...t.runtime.transport()}))})).pipe(F(_,["ads.connectAccount"]),P("Start an ad account OAuth connection")),T("connect-api-key-account",{workspaceId:C("workspace-id").pipe(fe(a.check(L()))),provider:ke("provider",["openai_ads"]),apiKey:C("api-key"),accountId:C("account-id").pipe(fe(a.check(L()))).pipe(E),profileId:C("profile-id").pipe(fe(a.check(L()))).pipe(E)},(e)=>R(async()=>{let t=await J(void 0,"human");return t.runtime.decode(H,Zw({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(F(_,["ads.connectApiKeyAccount"]),P("Connect an ad account with an API key")),T("disconnect-account",{workspace:N,accountId:ne("account-id").pipe(ie(a.check(L())))},(e)=>R(async()=>{let t=await J(void 0,"human");return t.runtime.decode(H,iE({client:t.runtime.client,path:{accountId:e.accountId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["ads.disconnectAccount"]),P("Stop syncing an ad account")),T("select-account",{workspace:N,accountId:ne("account-id").pipe(ie(a.check(L())))},(e)=>R(async()=>{let t=await J(void 0,"human");return t.runtime.decode(H,oE({client:t.runtime.client,path:{accountId:e.accountId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["ads.selectAccount"]),P("Select a discovered ad account")),T("list-campaigns",{workspace:N,accountId:ne("account-id").pipe(ie(a.check(L()))),provider:ke("provider",["meta_ads","google_ads","reddit_ads","pinterest_ads","tiktok_ads","linkedin_ads","snapchat_ads","amazon_ads","openai_ads"]).pipe(E),status:ke("status",["draft","paused","activating","active","pending_review","rejected","completed","archived","unknown"]).pipe(E),managed:ke("managed",["provider","pubnio"]).pipe(E),cursor:C("cursor").pipe(E),limit:Le("limit").pipe(E)},(e)=>R(async()=>{let t=await J();return t.runtime.decode(H,sE({client:t.runtime.client,path:{accountId:e.accountId},query:{workspaceId:await Z(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(F(_,["ads.listCampaigns"]),P("List one account's campaigns newest first")),T("list-workspace-campaigns",{workspace:N,accountId:C("account-id").pipe(fe(a.check(L()))).pipe(E),provider:ke("provider",["meta_ads","google_ads","reddit_ads","pinterest_ads","tiktok_ads","linkedin_ads","snapchat_ads","amazon_ads","openai_ads"]).pipe(E),status:ke("status",["draft","paused","activating","active","pending_review","rejected","completed","archived","unknown"]).pipe(E),managed:ke("managed",["provider","pubnio"]).pipe(E),cursor:C("cursor").pipe(E),limit:Le("limit").pipe(E)},(e)=>R(async()=>{let t=await J();return t.runtime.decode(H,eE({client:t.runtime.client,query:{workspaceId:await Z(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(F(_,["ads.listWorkspaceCampaigns"]),P("List campaigns across selected ad accounts")),T("get-tree",{workspace:N,accountId:C("account-id").pipe(fe(a.check(L()))).pipe(E),campaignId:C("campaign-id").pipe(fe(a.check(L()))).pipe(E),cursor:C("cursor").pipe(E),limit:Le("limit").pipe(E)},(e)=>R(async()=>{let t=await J();return t.runtime.decode(H,aE({client:t.runtime.client,query:{workspaceId:await Z(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(F(_,["ads.getTree"]),P("Read a campaign, ad group, ad, and creative tree")),T("list-ads",{workspace:N,accountId:C("account-id").pipe(fe(a.check(L()))).pipe(E),campaignId:C("campaign-id").pipe(fe(a.check(L()))).pipe(E),adGroupId:C("ad-group-id").pipe(fe(a.check(L()))).pipe(E),provider:ke("provider",["meta_ads","google_ads","reddit_ads","pinterest_ads","tiktok_ads","linkedin_ads","snapchat_ads","amazon_ads","openai_ads"]).pipe(E),status:ke("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:Le("limit").pipe(E)},(e)=>R(async()=>{let t=await J();return t.runtime.decode(H,cE({client:t.runtime.client,query:{workspaceId:await Z(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(F(_,["ads.listAds"]),P("List ads with a performance summary")),T("list-ad-groups",{workspace:N,accountId:C("account-id").pipe(fe(a.check(L()))).pipe(E),campaignId:C("campaign-id").pipe(fe(a.check(L()))).pipe(E),provider:ke("provider",["meta_ads","google_ads","reddit_ads","pinterest_ads","tiktok_ads","linkedin_ads","snapchat_ads","amazon_ads","openai_ads"]).pipe(E),status:ke("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:Le("limit").pipe(E)},(e)=>R(async()=>{let t=await J();return t.runtime.decode(H,pE({client:t.runtime.client,query:{workspaceId:await Z(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(F(_,["ads.listAdGroups"]),P("List ad groups with a performance summary")),T("get-ad",{workspace:N,adId:ne("ad-id").pipe(ie(a.check(L())))},(e)=>R(async()=>{let t=await J();return t.runtime.decode(H,dE({client:t.runtime.client,path:{adId:e.adId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["ads.getAd"]),P("Read one ad with its creative and metrics")),T("list-creatives",{workspace:N,accountId:C("account-id").pipe(fe(a.check(L()))).pipe(E),adId:C("ad-id").pipe(fe(a.check(L()))).pipe(E),cursor:C("cursor").pipe(E),limit:Le("limit").pipe(E)},(e)=>R(async()=>{let t=await J();return t.runtime.decode(H,uE({client:t.runtime.client,query:{workspaceId:await Z(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(F(_,["ads.listCreatives"]),P("List ad creatives")),T("get-creative",{workspace:N,creativeId:ne("creative-id").pipe(ie(a.check(L())))},(e)=>R(async()=>{let t=await J();return t.runtime.decode(H,fE({client:t.runtime.client,path:{creativeId:e.creativeId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["ads.getCreative"]),P("Read one ad creative")),T("list-insights",{workspace:N,accountId:ne("account-id").pipe(ie(a.check(L()))),campaignId:C("campaign-id").pipe(fe(a.check(L()))).pipe(E),adGroupId:C("ad-group-id").pipe(fe(a.check(L()))).pipe(E),adId:C("ad-id").pipe(fe(a.check(L()))).pipe(E),from:C("from").pipe(E),to:C("to").pipe(E),level:ke("level",["campaign","ad_group","ad"]).pipe(E),metrics:C("metrics").pipe(Ir(0)),cursor:C("cursor").pipe(E),limit:Le("limit").pipe(E)},(e)=>R(async()=>{let t=await J();return t.runtime.decode(H,hE({client:t.runtime.client,path:{accountId:e.accountId},query:{workspaceId:await Z(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(F(_,["ads.listInsights"]),P("Read one ad account's daily insights")),T("list-workspace-insights",{workspace:N,accountId:C("account-id").pipe(fe(a.check(L()))).pipe(E),campaignId:C("campaign-id").pipe(fe(a.check(L()))).pipe(E),adGroupId:C("ad-group-id").pipe(fe(a.check(L()))).pipe(E),adId:C("ad-id").pipe(fe(a.check(L()))).pipe(E),from:C("from").pipe(E),to:C("to").pipe(E),level:ke("level",["campaign","ad_group","ad"]).pipe(E),metrics:C("metrics").pipe(Ir(0)),cursor:C("cursor").pipe(E),limit:Le("limit").pipe(E)},(e)=>R(async()=>{let t=await J();return t.runtime.decode(H,mE({client:t.runtime.client,query:{workspaceId:await Z(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(F(_,["ads.listWorkspaceInsights"]),P("Read daily insights across selected ad accounts")),T("refresh-insights",{workspace:N,accountId:ne("account-id").pipe(ie(a.check(L())))},(e)=>R(async()=>{let t=await J();return t.runtime.decode(H,yE({client:t.runtime.client,path:{accountId:e.accountId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["ads.refreshInsights"]),P("Queue an ad insight refresh")),T("activate-campaign",{workspace:N,accountId:ne("account-id").pipe(ie(a.check(L()))),campaignId:ne("campaign-id").pipe(ie(a.check(L()))),expectedRevision:Le("expected-revision"),confirmation:ke("confirmation",["activate_spend"]),idempotencyKey:ot},(e)=>R(async()=>{let t=await J(void 0,"human");return t.runtime.decode(H,EE({client:t.runtime.client,path:{accountId:e.accountId,campaignId:e.campaignId},query:{workspaceId:await Z(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(F(_,["ads.activateCampaign"]),P("Activate one paused boost campaign")),T("pause-campaign",{workspace:N,accountId:ne("account-id").pipe(ie(a.check(L()))),campaignId:ne("campaign-id").pipe(ie(a.check(L()))),expectedRevision:Le("expected-revision"),idempotencyKey:ot},(e)=>R(async()=>{let t=await J();return t.runtime.decode(H,kE({client:t.runtime.client,path:{accountId:e.accountId,campaignId:e.campaignId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{expectedRevision:e.expectedRevision},headers:{"idempotency-key":f(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()}))})).pipe(F(_,["ads.pauseCampaign"]),P("Pause one campaign")),T("archive-campaign",{workspace:N,accountId:ne("account-id").pipe(ie(a.check(L()))),campaignId:ne("campaign-id").pipe(ie(a.check(L()))),expectedRevision:Le("expected-revision"),idempotencyKey:ot},(e)=>R(async()=>{let t=await J();return t.runtime.decode(H,AE({client:t.runtime.client,path:{accountId:e.accountId,campaignId:e.campaignId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{expectedRevision:e.expectedRevision},headers:{"idempotency-key":f(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()}))})).pipe(F(_,["ads.archiveCampaign"]),P("Archive one campaign")),T("duplicate-campaign",{workspace:N,accountId:ne("account-id").pipe(ie(a.check(L()))),campaignId:ne("campaign-id").pipe(ie(a.check(L()))),name:C("name").pipe(E),idempotencyKey:ot},(e)=>R(async()=>{let t=await J();return t.runtime.decode(H,vE({client:t.runtime.client,path:{accountId:e.accountId,campaignId:e.campaignId},query:{workspaceId:await Z(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(F(_,["ads.duplicateCampaign"]),P("Duplicate a campaign tree as paused")),T("create-ad-group",{workspace:N,accountId:ne("account-id").pipe(ie(a.check(L()))),campaignId:ne("campaign-id").pipe(ie(a.check(L()))),name:C("name"),idempotencyKey:ot,file:C("file").pipe(E,Oe("Read the body JSON from a file or stdin with -."))},(e)=>R(async()=>{let t=await J(),r=f(e.file),n=r===void 0?{name:e.name}:await Et(r);return t.runtime.decode(H,PE({client:t.runtime.client,path:{accountId:e.accountId,campaignId:e.campaignId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:n,headers:{"idempotency-key":f(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()}))})).pipe(F(_,["ads.createAdGroup"]),P("Create a paused ad group under a campaign")),T("create-creative",{workspace:N,accountId:ne("account-id").pipe(ie(a.check(L()))),actorAccountId:C("actor-account-id").pipe(fe(a.check(L()))),mediaId:C("media-id").pipe(fe(a.check(L()))),headline:C("headline").pipe(E),body:C("body").pipe(E),callToAction:C("call-to-action").pipe(E),destinationUrl:C("destination-url"),idempotencyKey:ot,file:C("file").pipe(E,Oe("Read the body JSON from a file or stdin with -."))},(e)=>R(async()=>{let t=await J(),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 Et(r);return t.runtime.decode(H,lE({client:t.runtime.client,path:{accountId:e.accountId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:n,headers:{"idempotency-key":f(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()}))})).pipe(F(_,["ads.createCreative"]),P("Create a paused provider creative")),T("set-campaign-budget",{workspace:N,accountId:ne("account-id").pipe(ie(a.check(L()))),campaignId:ne("campaign-id").pipe(ie(a.check(L()))),expectedRevision:Le("expected-revision"),idempotencyKey:ot,file:C("file").pipe(E,Oe("Read the body JSON from a file or stdin with -."))},(e)=>R(async()=>{let t=await J(void 0,"human"),r=f(e.file),n=r===void 0?{expectedRevision:e.expectedRevision}:await Et(r);return t.runtime.decode(H,CE({client:t.runtime.client,path:{accountId:e.accountId,campaignId:e.campaignId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:n,headers:{"idempotency-key":f(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()}))})).pipe(F(_,["ads.setCampaignBudget"]),P("Update a campaign budget")),T("set-ad-group-budget",{workspace:N,accountId:ne("account-id").pipe(ie(a.check(L()))),adGroupId:ne("ad-group-id").pipe(ie(a.check(L()))),expectedRevision:Le("expected-revision"),idempotencyKey:ot,file:C("file").pipe(E,Oe("Read the body JSON from a file or stdin with -."))},(e)=>R(async()=>{let t=await J(void 0,"human"),r=f(e.file),n=r===void 0?{expectedRevision:e.expectedRevision}:await Et(r);return t.runtime.decode(H,TE({client:t.runtime.client,path:{accountId:e.accountId,adGroupId:e.adGroupId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:n,headers:{"idempotency-key":f(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()}))})).pipe(F(_,["ads.setAdGroupBudget"]),P("Update an ad group budget")),T("set-ad-group-status",{workspace:N,accountId:ne("account-id").pipe(ie(a.check(L()))),adGroupId:ne("ad-group-id").pipe(ie(a.check(L()))),status:ke("status",["active","paused","archived"]),expectedRevision:Le("expected-revision"),idempotencyKey:ot},(e)=>R(async()=>{let t=await J();return t.runtime.decode(H,OE({client:t.runtime.client,path:{accountId:e.accountId,adGroupId:e.adGroupId},query:{workspaceId:await Z(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(F(_,["ads.setAdGroupStatus"]),P("Pause, resume, or archive an ad group")),T("set-ad-status",{workspace:N,accountId:ne("account-id").pipe(ie(a.check(L()))),adId:ne("ad-id").pipe(ie(a.check(L()))),status:ke("status",["active","paused","archived"]),expectedRevision:Le("expected-revision"),idempotencyKey:ot},(e)=>R(async()=>{let t=await J();return t.runtime.decode(H,_E({client:t.runtime.client,path:{accountId:e.accountId,adId:e.adId},query:{workspaceId:await Z(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(F(_,["ads.setAdStatus"]),P("Pause, resume, or archive an ad")),T("attach-ad",{workspace:N,accountId:ne("account-id").pipe(ie(a.check(L()))),adGroupId:ne("ad-group-id").pipe(ie(a.check(L()))),name:C("name"),creativeId:C("creative-id").pipe(fe(a.check(L()))).pipe(E),idempotencyKey:ot,file:C("file").pipe(E,Oe("Read the body JSON from a file or stdin with -."))},(e)=>R(async()=>{let t=await J(),r=f(e.file),n=r===void 0?{name:e.name,...O(e.creativeId)?{creativeId:f(e.creativeId)}:{}}:await Et(r);return t.runtime.decode(H,RE({client:t.runtime.client,path:{accountId:e.accountId,adGroupId:e.adGroupId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:n,headers:{"idempotency-key":f(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()}))})).pipe(F(_,["ads.attachAd"]),P("Attach a paused ad to an existing ad group")),T("create-boost",{workspace:N,accountId:ne("account-id").pipe(ie(a.check(L()))),postId:C("post-id").pipe(fe(a.check(L()))),postTargetId:C("post-target-id").pipe(fe(a.check(L()))).pipe(E),actorAccountId:C("actor-account-id").pipe(fe(a.check(L()))).pipe(E),idempotencyKey:ot,file:C("file").pipe(E,Oe("Read the body JSON from a file or stdin with -."))},(e)=>R(async()=>{let t=await J(),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 Et(r);return t.runtime.decode(H,wE({client:t.runtime.client,path:{accountId:e.accountId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:n,headers:{"idempotency-key":f(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()}))})).pipe(F(_,["ads.createBoost"]),P("Create a paused Facebook Page post boost")),T("validate-boost",{workspace:N,accountId:ne("account-id").pipe(ie(a.check(L()))),postId:C("post-id").pipe(fe(a.check(L()))),postTargetId:C("post-target-id").pipe(fe(a.check(L()))).pipe(E),actorAccountId:C("actor-account-id").pipe(fe(a.check(L()))).pipe(E),file:C("file").pipe(E,Oe("Read the body JSON from a file or stdin with -."))},(e)=>R(async()=>{let t=await J(),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 Et(r);return t.runtime.decode(H,IE({client:t.runtime.client,path:{accountId:e.accountId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:n,...t.runtime.transport()}))})).pipe(F(_,["ads.validateBoost"]),P("Validate a Facebook Page post boost")),T("validate-campaign-plan",{workspace:N,name:C("name"),objective:ke("objective",["awareness","traffic","engagement","leads","sales","app_promotion","video_views","reach","conversions","unknown"]),file:C("file").pipe(E,Oe("Read the body JSON from a file or stdin with -."))},(e)=>R(async()=>{let t=await J(),r=f(e.file),n=r===void 0?{name:e.name,objective:e.objective}:await Et(r);return t.runtime.decode(H,Xw({client:t.runtime.client,query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:n,...t.runtime.transport()}))})).pipe(F(_,["ads.validateCampaignPlan"]),P("Validate a unified campaign plan")),T("create-campaign-plan",{workspace:N,name:C("name"),objective:ke("objective",["awareness","traffic","engagement","leads","sales","app_promotion","video_views","reach","conversions","unknown"]),idempotencyKey:ot,file:C("file").pipe(E,Oe("Read the body JSON from a file or stdin with -."))},(e)=>R(async()=>{let t=await J(),r=f(e.file),n=r===void 0?{name:e.name,objective:e.objective}:await Et(r);return t.runtime.decode(H,tE({client:t.runtime.client,query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:n,headers:{"idempotency-key":f(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()}))})).pipe(F(_,["ads.createCampaignPlan"]),P("Create a paused campaign plan")),T("get-campaign-plan",{workspace:N,planId:ne("plan-id").pipe(ie(a.check(L())))},(e)=>R(async()=>{let t=await J();return t.runtime.decode(H,nE({client:t.runtime.client,path:{planId:e.planId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["ads.getCampaignPlan"]),P("Read a campaign plan and its target operations")),T("list-campaign-plans",{workspace:N,status:ke("status",["queued","creating","partial","succeeded","failed","unresolved"]).pipe(E),cursor:C("cursor").pipe(E),limit:Le("limit").pipe(E)},(e)=>R(async()=>{let t=await J();return t.runtime.decode(H,rE({client:t.runtime.client,query:{workspaceId:await Z(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(F(_,["ads.listCampaignPlans"]),P("List campaign plans")),T("get-operation",{workspace:N,accountId:ne("account-id").pipe(ie(a.check(L()))),operationId:ne("operation-id").pipe(ie(a.check(L())))},(e)=>R(async()=>{let t=await J();return t.runtime.decode(H,bE({client:t.runtime.client,path:{accountId:e.accountId,operationId:e.operationId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["ads.getOperation"]),P("Read one ad operation")),T("get-spend-policy",{workspace:N,accountId:ne("account-id").pipe(ie(a.check(L())))},(e)=>R(async()=>{let t=await J();return t.runtime.decode(H,gE({client:t.runtime.client,path:{accountId:e.accountId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["ads.getSpendPolicy"]),P("Read an ad account's spend policy")),T("update-spend-policy",{workspace:N,accountId:ne("account-id").pipe(ie(a.check(L()))),expectedRevision:Le("expected-revision"),file:C("file").pipe(E,Oe("Read the body JSON from a file or stdin with -."))},(e)=>R(async()=>{let t=await J(void 0,"human"),r=f(e.file),n=r===void 0?{expectedRevision:e.expectedRevision}:await Et(r);return t.runtime.decode(H,xE({client:t.runtime.client,path:{accountId:e.accountId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:n,...t.runtime.transport()}))})).pipe(F(_,["ads.updateSpendPolicy"]),P("Replace an ad account's spend policy")),T("set-kill-switch",{workspace:N,accountId:ne("account-id").pipe(ie(a.check(L()))),active:ht("active").pipe(tt(!1)),reason:C("reason").pipe(E)},(e)=>R(async()=>{let t=await J();return t.runtime.decode(H,SE({client:t.runtime.client,path:{accountId:e.accountId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{active:e.active,...O(e.reason)?{reason:f(e.reason)}:{}},...t.runtime.transport()}))})).pipe(F(_,["ads.setKillSwitch"]),P("Set or clear an ad account kill switch"))];var N$=T("ads").pipe(P("Read and manage ad accounts, campaigns, and boosts."),Ze(F$));var B$=[T("accounts").pipe(P(""),Ze([T("list",{workspace:N,accountId:C("account-id").pipe(Ir(0)),platform:ke("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:ke("granularity",["day","total"]).pipe(E),metrics:C("metrics").pipe(Ir(0)),cursor:C("cursor").pipe(E),limit:Le("limit").pipe(E)},(e)=>R(async()=>{let t=await J();return t.runtime.decode(H,Sw({client:t.runtime.client,path:{workspaceId:await Z(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(F(_,["analytics.accounts.list"]),P("List account analytics summaries")),T("get",{workspace:N,accountId:ne("account-id").pipe(ie(a.check(L()))),from:C("from").pipe(E),to:C("to").pipe(E),timezone:C("timezone").pipe(E),granularity:ke("granularity",["day","total"]).pipe(E),metrics:C("metrics").pipe(Ir(0))},(e)=>R(async()=>{let t=await J();return t.runtime.decode(H,bw({client:t.runtime.client,path:{accountId:e.accountId,workspaceId:await Z(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(F(_,["analytics.accounts.get"]),P("Read one account's analytics"))])),T("posts").pipe(P(""),Ze([T("get",{workspace:N,postId:ne("post-id").pipe(ie(a.check(L()))),targetId:C("target-id").pipe(fe(a.check(L()))).pipe(E),from:C("from").pipe(E),to:C("to").pipe(E),timezone:C("timezone").pipe(E),granularity:ke("granularity",["day","total"]).pipe(E),metrics:C("metrics").pipe(Ir(0))},(e)=>R(async()=>{let t=await J();return t.runtime.decode(H,gw({client:t.runtime.client,path:{postId:e.postId},query:{workspaceId:await Z(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(F(_,["analytics.posts.get"]),P("Read target-scoped post analytics totals")),T("series",{workspace:N,postId:ne("post-id").pipe(ie(a.check(L()))),targetId:C("target-id").pipe(fe(a.check(L()))).pipe(E),from:C("from").pipe(E),to:C("to").pipe(E),timezone:C("timezone").pipe(E),granularity:ke("granularity",["day","total"]).pipe(E),metrics:C("metrics").pipe(Ir(0))},(e)=>R(async()=>{let t=await J();return t.runtime.decode(H,xw({client:t.runtime.client,path:{postId:e.postId},query:{workspaceId:await Z(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(F(_,["analytics.posts.series"]),P("Read daily post analytics series"))])),T("capabilities").pipe(P(""),Ze([T("get",{workspace:N},(e)=>R(async()=>{let t=await J();return t.runtime.decode(H,Iw({client:t.runtime.client,path:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["analytics.capabilities.get"]),P("Read the analytics metric catalog and provider support"))])),T("refreshes").pipe(P(""),Ze([T("create",{workspaceId:C("workspace-id").pipe(fe(a.check(L()))),postId:C("post-id").pipe(fe(a.check(L()))).pipe(E),targetId:C("target-id").pipe(fe(a.check(L()))).pipe(E),metrics:ke("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(Ir(0))},(e)=>R(async()=>{let t=await J();return t.runtime.decode(H,ww({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(F(_,["analytics.refreshes.create"]),P("Queue a priority analytics refresh")),T("get",{workspace:N,refreshId:ne("refresh-id").pipe(ie(a.check(L())))},(e)=>R(async()=>{let t=await J();return t.runtime.decode(H,Ew({client:t.runtime.client,path:{refreshId:e.refreshId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["analytics.refreshes.get"]),P("Read an analytics refresh status"))]))];var K$=T("analytics").pipe(P("Read post, account, and refresh analytics."),Ze(B$));var q$=[T("list",{workspace:N,cursor:C("cursor").pipe(E),limit:Le("limit").pipe(E)},(e)=>R(async()=>{let t=await J(void 0,"human");return t.runtime.decode(H,$I({client:t.runtime.client,path:{workspaceId:await Z(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(F(_,["apiKeys.list"]),P("List workspace API keys")),T("create",{workspace:N,name:C("name"),scopes:ke("scope",["read","publish","engage","ads_read","ads_manage"]).pipe(Ir(0)),expiresAt:C("expires-at").pipe(E)},(e)=>R(async()=>{let t=await J(void 0,"human");return t.runtime.decode(H,WI({client:t.runtime.client,path:{workspaceId:await Z(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(F(_,["apiKeys.create"]),P("Create a workspace API key")),T("get",{workspace:N,keyId:ne("key-id").pipe(ie(a.check(L())))},(e)=>R(async()=>{let t=await J(void 0,"human");return t.runtime.decode(H,zI({client:t.runtime.client,path:{keyId:e.keyId,workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["apiKeys.get"]),P("Read API key metadata")),T("update",{workspace:N,keyId:ne("key-id").pipe(ie(a.check(L()))),name:C("name").pipe(E),scopes:ke("scope",["read","publish","engage","ads_read","ads_manage"]).pipe(Ir(0))},(e)=>R(async()=>{let t=await J(void 0,"human");return t.runtime.decode(H,jI({client:t.runtime.client,path:{keyId:e.keyId,workspaceId:await Z(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(F(_,["apiKeys.update"]),P("Rename an API key or change its access")),T("revoke",{workspace:N,keyId:ne("key-id").pipe(ie(a.check(L())))},(e)=>R(async()=>{let t=await J(void 0,"human");return t.runtime.decode(H,GI({client:t.runtime.client,path:{keyId:e.keyId,workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["apiKeys.revoke"]),P("Revoke a workspace API key"))];var $$=T("api-keys").pipe(P("Manage workspace API keys as a signed-in owner."),Ze(q$));var W$=[T("list",{workspace:N,action:ke("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.deleted","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:ke("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(fe(a.check(L()))).pipe(E),actorType:ke("actor-type",["user","api_key"]).pipe(E),actorId:C("actor-id").pipe(fe(a.check(L()))).pipe(E),profileId:C("profile-id").pipe(fe(a.check(L()))).pipe(E),from:C("from").pipe(E),to:C("to").pipe(E),cursor:C("cursor").pipe(E),limit:Le("limit").pipe(E)},(e)=>R(async()=>{let t=await J(void 0,"human");return t.runtime.decode(H,UE({client:t.runtime.client,path:{workspaceId:await Z(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(F(_,["audit.list"]),P("List workspace audit events")),T("get",{workspace:N,eventId:ne("event-id").pipe(ie(a.check(L())))},(e)=>R(async()=>{let t=await J(void 0,"human");return t.runtime.decode(H,DE({client:t.runtime.client,path:{eventId:e.eventId,workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["audit.get"]),P("Read one audit event")),T("actions").pipe(P(""),Ze([T("list",{},(e)=>R(async()=>{let t=await J();return t.runtime.decode(H,YE({client:t.runtime.client,...t.runtime.transport()}))})).pipe(F(_,["audit.actions.list"]),P("List documented audit actions"))]))];var G$=T("audit").pipe(P("Read the workspace audit history."),Ze(W$));var z$=Le("timeout").pipe(tt(600),Oe("Maximum seconds to wait for sign-in.")),H5=T("login",{browser:Xu,timeout:z$,noWait:ht("no-wait").pipe(tt(!1),Oe("Print the verification URL and code, then exit. Finish with `pnio auth complete`."))},(e)=>R(async()=>{let t=Ai(),r=await R$(t);if(console.error(`Open ${r.url} and confirm code ${r.userCode}.`),e.browser)ay(r.completeUrl);if(e.noWait)return r;let n=await IA(t,{timeoutMs:e.timeout*1000});return Aa({baseUrl:t,accessToken:n}).me.get()})).pipe(P("Sign in with a WorkOS device code, or hand off with --no-wait.")),V5=T("complete",{timeout:z$},(e)=>R(async()=>{let t=Ai(),r=await IA(t,{timeoutMs:e.timeout*1000});return Aa({baseUrl:t,accessToken:r}).me.get()})).pipe(P("Finish a sign-in started with `pnio auth login --no-wait`.")),J5=T("status",{},()=>R(async()=>(await go(void 0,"human")).me.get())).pipe(P("Show the current PubNio account.")),Y5=T("logout",{},()=>R(async()=>(await L$(Ai()),{signedOut:!0}))).pipe(P("Revoke the CLI session and clear local credentials.")),j$=T("auth").pipe(P("Manage your CLI session."),Ze([H5,V5,J5,Y5]));var Q$=[T("status",{workspace:N},(e)=>R(async()=>{let t=await J();return t.runtime.decode(H,GE({client:t.runtime.client,path:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["billing.get"]),P("Get workspace billing status")),T("usage",{workspace:N,from:C("from").pipe(E),to:C("to").pipe(E),meter:ke("meter",["confirmed_publish","x_passthrough","managed_ad","inbox_reply","automation_run"]).pipe(E),provider:ke("provider",["bluesky","facebook","instagram","linkedin","pinterest","reddit","snapchat","tiktok","threads","x","youtube","google_business"]).pipe(E)},(e)=>R(async()=>{let t=await J();return t.runtime.decode(H,zE({client:t.runtime.client,path:{workspaceId:await Z(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(F(_,["billing.usage.get"]),P("Get workspace daily usage summary")),T("ledger",{workspace:N,kind:ke("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:Le("limit").pipe(E)},(e)=>R(async()=>{let t=await J(void 0,"human");return t.runtime.decode(H,jE({client:t.runtime.client,path:{workspaceId:await Z(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(F(_,["billing.ledger.list"]),P("List workspace prepaid credit ledger")),T("plans",{},(e)=>R(async()=>{let t=await J();return t.runtime.decode(H,JE({client:t.runtime.client,...t.runtime.transport()}))})).pipe(F(_,["billing.plans.list"]),P("List public billing plans")),T("top-up",{workspace:N,idempotencyKey:ot,file:C("file").pipe(E,Oe("Read the body JSON from a file or stdin with -."))},(e)=>R(async()=>{let t=await J(void 0,"human"),r=f(e.file),n=r===void 0?{}:await Et(r);return t.runtime.decode(H,QE({client:t.runtime.client,path:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:n,headers:{"idempotency-key":f(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()}))})).pipe(F(_,["billing.checkout.create"]),P("Create a hosted checkout session for a plan upgrade or credit top-up")),T("portal",{workspace:N,returnUrl:C("return-url").pipe(E)},(e)=>R(async()=>{let t=await J(void 0,"human");return t.runtime.decode(H,HE({client:t.runtime.client,path:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{...O(e.returnUrl)?{returnUrl:f(e.returnUrl)}:{}},...t.runtime.transport()}))})).pipe(F(_,["billing.portal.create"]),P("Create a hosted billing portal session")),T("spend-cap",{workspace:N,version:Le("version"),file:C("file").pipe(E,Oe("Read the body JSON from a file or stdin with -."))},(e)=>R(async()=>{let t=await J(void 0,"human"),r=f(e.file),n=r===void 0?{version:e.version}:await Et(r);return t.runtime.decode(H,VE({client:t.runtime.client,path:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:n,...t.runtime.transport()}))})).pipe(F(_,["billing.spendControls.update"]),P("Update monthly spend cap"))];var H$=T("billing").pipe(P("Manage workspace billing, usage, and checkout."),Ze(Q$));var V$=[T("catalog",{},(e)=>R(async()=>{let t=await J();return t.runtime.decode(H,lw({client:t.runtime.client,...t.runtime.transport()}))})).pipe(F(_,["capabilities.catalog"]),P("Read the static provider capability catalog")),T("get",{},(e)=>R(async()=>{let t=await J();return t.runtime.decode(H,dw({client:t.runtime.client,...t.runtime.transport()}))})).pipe(F(_,["capabilities.get"]),P("Read the publish capability catalog")),T("list",{workspace:N,profileId:C("profile-id").pipe(fe(a.check(L()))).pipe(E),accountId:C("account-id").pipe(fe(a.check(L()))).pipe(E),capability:ke("capability",["publish","read_insights","manage_comments","send_messages","ads_read","ads_write","ads_spend"]).pipe(E)},(e)=>R(async()=>{let t=await J();return t.runtime.decode(H,uw({client:t.runtime.client,query:{workspaceId:await Z(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(F(_,["capabilities.list"]),P("List computed capabilities for connected accounts"))];var J$=T("capabilities").pipe(P("Read publishing capabilities, placements, and limits."),Ze(V$));var Y$=[T("create",{workspace:N,accountId:C("account-id").pipe(fe(a.check(L()))).pipe(E),provider:ke("provider",["bluesky","facebook","instagram","linkedin","pinterest","reddit","snapchat","tiktok","threads","x","youtube","google_business"]).pipe(E),target:C("target"),targetKind:ke("target-kind",["post","comment"]).pipe(E),text:C("text"),idempotencyKey:ot},(e)=>R(async()=>{let t=await J();return t.runtime.decode(H,v6({client:t.runtime.client,query:{workspaceId:await Z(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(F(_,["comments.create"]),P("Comment on or reply to a provider post"))];var Z$=T("comments").pipe(P("Create comments where a destination supports them."),Ze(Y$));var X$=[T("get",{},(e)=>R(async()=>{let t=await J();return t.runtime.decode(H,fw({client:t.runtime.client,...t.runtime.transport()}))})).pipe(F(_,["limits.get"]),P("Read documented API limits"))];var e1=T("limits").pipe(P("Read workspace publishing limits."),Ze(X$));var t1=[T("capabilities",{workspace:N,accountId:C("account-id").pipe(fe(a.check(L()))).pipe(E)},(e)=>R(async()=>{let t=await J();return t.runtime.decode(H,Bw({client:t.runtime.client,query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId),...O(e.accountId)?{accountId:f(e.accountId)}:{}},...t.runtime.transport()}))})).pipe(F(_,["inbox.capabilities.get"]),P("Read per-account inbox channel capabilities")),T("unread-count",{workspace:N},(e)=>R(async()=>{let t=await J();return t.runtime.decode(H,Nw({client:t.runtime.client,query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["inbox.unread.count"]),P("Count conversations with at least one unread inbound message")),T("conversations").pipe(P(""),Ze([T("list",{workspace:N,accountId:C("account-id").pipe(fe(a.check(L()))).pipe(E),provider:ke("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:ke("status",["active","archived"]).pipe(E),folder:ke("folder",["inbox","message_request","spam","other"]).pipe(E),unread:ke("unread",["true","false"]).pipe(E),search:C("search").pipe(E),cursor:C("cursor").pipe(E),limit:Le("limit").pipe(E)},(e)=>R(async()=>{let t=await J();return t.runtime.decode(H,kw({client:t.runtime.client,query:{workspaceId:await Z(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(F(_,["inbox.conversations.list"]),P("List DM conversations newest first")),T("get",{workspace:N,conversationId:ne("conversation-id").pipe(ie(a.check(L())))},(e)=>R(async()=>{let t=await J();return t.runtime.decode(H,Aw({client:t.runtime.client,path:{conversationId:e.conversationId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["inbox.conversations.get"]),P("Read one conversation and reply window")),T("update",{workspace:N,conversationId:ne("conversation-id").pipe(ie(a.check(L()))),status:ke("status",["active","archived"]).pipe(E),read:ht("read").pipe(tt(!1))},(e)=>R(async()=>{let t=await J();if(!(O(e.status)||e.read))throw new Fe("Provide --status or --read.");return t.runtime.decode(H,vw({client:t.runtime.client,path:{conversationId:e.conversationId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{...O(e.status)?{status:f(e.status)}:{},...e.read?{read:!0}:{}},...t.runtime.transport()}))})).pipe(F(_,["inbox.conversations.update"]),P("Mark read or archive a conversation"))])),T("messages").pipe(P(""),Ze([T("list",{workspace:N,conversationId:ne("conversation-id").pipe(ie(a.check(L()))),order:ke("order",["oldest","newest"]).pipe(E),cursor:C("cursor").pipe(E),limit:Le("limit").pipe(E)},(e)=>R(async()=>{let t=await J();return t.runtime.decode(H,Cw({client:t.runtime.client,path:{conversationId:e.conversationId},query:{workspaceId:await Z(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(F(_,["inbox.messages.list"]),P("Page messages oldest or newest first")),T("send",{workspace:N,conversationId:ne("conversation-id").pipe(ie(a.check(L()))),text:C("text"),idempotencyKey:ot},(e)=>R(async()=>{let t=await J();return t.runtime.decode(H,Tw({client:t.runtime.client,path:{conversationId:e.conversationId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{text:e.text},headers:{"idempotency-key":f(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()}))})).pipe(F(_,["inbox.messages.send"]),P("Send a text reply inside the provider window"))])),T("comments").pipe(P(""),Ze([T("list",{workspace:N,accountId:C("account-id").pipe(fe(a.check(L()))).pipe(E),postId:C("post-id").pipe(fe(a.check(L()))).pipe(E),providerPostId:C("provider-post-id").pipe(E),unread:ke("unread",["true","false"]).pipe(E),cursor:C("cursor").pipe(E),limit:Le("limit").pipe(E)},(e)=>R(async()=>{let t=await J();return t.runtime.decode(H,Ow({client:t.runtime.client,query:{workspaceId:await Z(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(F(_,["inbox.comments.list"]),P("List comment threads with counts")),T("get",{workspace:N,threadId:ne("thread-id").pipe(ie(a.check(L()))),cursor:C("cursor").pipe(E),limit:Le("limit").pipe(E)},(e)=>R(async()=>{let t=await J();return t.runtime.decode(H,Pw({client:t.runtime.client,path:{threadId:e.threadId},query:{workspaceId:await Z(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(F(_,["inbox.comments.get"]),P("Read a comment thread and its comments")),T("reply",{workspace:N,commentId:ne("comment-id").pipe(ie(a.check(L()))),text:C("text"),idempotencyKey:ot},(e)=>R(async()=>{let t=await J();return t.runtime.decode(H,Rw({client:t.runtime.client,path:{commentId:e.commentId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{text:e.text},headers:{"idempotency-key":f(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()}))})).pipe(F(_,["inbox.comments.reply"]),P("Reply to a comment")),T("moderate",{workspace:N,commentId:ne("comment-id").pipe(ie(a.check(L()))),hidden:ht("hidden").pipe(tt(!1)),liked:ht("liked").pipe(tt(!1))},(e)=>R(async()=>{let t=await J();return t.runtime.decode(H,Uw({client:t.runtime.client,path:{commentId:e.commentId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{...e.hidden?{hidden:!0}:{},...e.liked?{liked:!0}:{}},...t.runtime.transport()}))})).pipe(F(_,["inbox.comments.moderate"]),P("Hide, unhide, like, or unlike a comment")),T("delete",{workspace:N,commentId:ne("comment-id").pipe(ie(a.check(L())))},(e)=>R(async()=>{let t=await J();return t.runtime.decode(H,_w({client:t.runtime.client,path:{commentId:e.commentId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["inbox.comments.delete"]),P("Delete a comment where the provider supports it"))])),T("mentions").pipe(P(""),Ze([T("list",{workspace:N,accountId:C("account-id").pipe(fe(a.check(L()))).pipe(E),provider:ke("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:Le("limit").pipe(E)},(e)=>R(async()=>{let t=await J();return t.runtime.decode(H,Dw({client:t.runtime.client,query:{workspaceId:await Z(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(F(_,["inbox.mentions.list"]),P("List mentions of a connected account")),T("reply",{workspace:N,mentionId:ne("mention-id").pipe(ie(a.check(L()))),text:C("text"),idempotencyKey:ot},(e)=>R(async()=>{let t=await J();return t.runtime.decode(H,Lw({client:t.runtime.client,path:{mentionId:e.mentionId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{text:e.text},headers:{"idempotency-key":f(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()}))})).pipe(F(_,["inbox.mentions.reply"]),P("Reply to a mention where supported"))])),T("sync").pipe(P(""),Ze([T("start",{workspaceId:C("workspace-id").pipe(fe(a.check(L()))),accountId:C("account-id").pipe(fe(a.check(L()))).pipe(E)},(e)=>R(async()=>{let t=await J();return t.runtime.decode(H,Kw({client:t.runtime.client,body:{workspaceId:e.workspaceId,...O(e.accountId)?{accountId:f(e.accountId)}:{}},...t.runtime.transport()}))})).pipe(F(_,["inbox.sync.start"]),P("Queue a bounded inbox sync")),T("status",{workspace:N,syncRunId:ne("sync-run-id").pipe(ie(a.check(L())))},(e)=>R(async()=>{let t=await J();return t.runtime.decode(H,qw({client:t.runtime.client,path:{syncRunId:e.syncRunId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["inbox.sync.get"]),P("Read a sync run and current inbox counts"))])),T("attachments").pipe(P(""),Ze([T("get",{workspace:N,attachmentId:ne("attachment-id").pipe(ie(a.check(L())))},(e)=>R(async()=>{let t=await J();return t.runtime.decode(H,$w({client:t.runtime.client,path:{attachmentId:e.attachmentId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["inbox.attachments.get"]),P("Stream an inbound attachment"))])),T("reviews").pipe(P(""),Ze([T("list",{workspace:N,accountId:C("account-id").pipe(fe(a.check(L()))).pipe(E),includeDeleted:ke("include-deleted",["true","false"]).pipe(E),cursor:C("cursor").pipe(E),limit:Le("limit").pipe(E)},(e)=>R(async()=>{let t=await J();return t.runtime.decode(H,Mw({client:t.runtime.client,query:{workspaceId:await Z(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(F(_,["inbox.reviews.list"]),P("List stored Google Business Profile reviews newest first")),T("get",{workspace:N,reviewId:ne("review-id").pipe(ie(a.check(L())))},(e)=>R(async()=>{let t=await J();return t.runtime.decode(H,Fw({client:t.runtime.client,path:{reviewId:e.reviewId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["inbox.reviews.get"]),P("Read one stored Google Business Profile review")),T("reply",{workspace:N,reviewId:ne("review-id").pipe(ie(a.check(L()))),text:C("text"),idempotencyKey:ot},(e)=>R(async()=>{let t=await J();return t.runtime.decode(H,A6({client:t.runtime.client,path:{reviewId:e.reviewId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{text:e.text},headers:{"idempotency-key":f(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()}))})).pipe(F(_,["inbox.reviews.reply"]),P("Reply to a Google Business Profile review"))]))];var r1=T("inbox").pipe(P("Read and reply from the unified inbox."),Ze(t1));var n1=[T("get-account",{workspace:N,accountId:ne("account-id").pipe(ie(a.check(L()))),includeAdAccounts:ke("include-ad-accounts",["true","false"]).pipe(E)},(e)=>R(async()=>{let t=await J();return t.runtime.decode(H,nw({client:t.runtime.client,path:{accountId:e.accountId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId),...O(e.includeAdAccounts)?{includeAdAccounts:f(e.includeAdAccounts)}:{}},...t.runtime.transport()}))})).pipe(F(_,["integrations.getAccount"]),P("Check account readiness")),T("bluesky-session",{workspace:N,handle:C("handle"),appPassword:C("app-password"),service:C("service").pipe(E),accountId:C("account-id").pipe(fe(a.check(L()))).pipe(E),profileId:C("profile-id").pipe(fe(a.check(L()))).pipe(E)},(e)=>R(async()=>{let t=await J(void 0,"human");return t.runtime.decode(H,k6({client:t.runtime.client,query:{workspaceId:await Z(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(F(_,["integrations.blueskySession"]),P("Connect Bluesky with an app password")),T("get-instagram-audio",{workspace:N,accountId:ne("account-id").pipe(ie(a.check(L()))),audioId:ne("audio-id")},(e)=>R(async()=>{let t=await J();return t.runtime.decode(H,ow({client:t.runtime.client,path:{accountId:e.accountId,audioId:e.audioId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["integrations.getInstagramAudio"]),P("Read current Instagram audio metadata and refresh its preview URL")),T("move-account",{workspace:N,accountId:ne("account-id").pipe(ie(a.check(L()))),profileId:C("profile-id").pipe(fe(a.check(L())))},(e)=>R(async()=>{let t=await J(void 0,"human");return t.runtime.decode(H,rw({client:t.runtime.client,path:{accountId:e.accountId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{profileId:e.profileId},...t.runtime.transport()}))})).pipe(F(_,["integrations.moveAccount"]),P("Move an account to another profile"))];var bp=ne("account-id").pipe(ie(bu.fields.accountId)),i1=ke("login-method",oh.literals).pipe(E),s1=Le("timeout").pipe(tt(120),Oe("Maximum seconds to wait for consent."));async function a1(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 c1(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)ay(e.url);return e}var Z5=T("list",{workspace:N},({workspace:e})=>R(async()=>(await Ke(f(e))).accounts.list())).pipe(F(_,["integrations.list"]),P("List publishing destinations.")),X5=T("connect",{provider:L8("provider",bn.literals),workspace:N,browser:Xu,loginMethod:i1,wait:ht("wait").pipe(tt(!1),Oe("Wait for consent before returning.")),timeout:s1},(e)=>R(async()=>{let t=Ai(),r=await Ke(f(e.workspace),{origin:t}),n=await r.accounts.prepareConnection(e.provider,f(e.loginMethod)),o=c1(n,t,e.browser);if(!e.wait)return o;let i=await a1(r,n.attemptId,e.timeout);if(i.status!=="connected")process.exitCode=1;return{...o,connection:i}})).pipe(F(_,["integrations.prepareConnection","integrations.connectionStatus"]),P("Connect Facebook, Instagram, or TikTok.")),eZ=T("wait",{attempt:ne("attempt-id").pipe(ie(qb.fields.attemptId)),workspace:N,timeout:s1},(e)=>R(async()=>{let t=await Ke(f(e.workspace)),r=await a1(t,e.attempt,e.timeout);if(r.status!=="connected")process.exitCode=1;return r})).pipe(F(_,["integrations.connectionStatus"]),P("Wait for an account connection to finish.")),tZ=T("status",{attempt:ne("attempt-id").pipe(ie(qb.fields.attemptId)),workspace:N},({attempt:e,workspace:t})=>R(async()=>(await Ke(f(t))).accounts.connectionStatus(e))).pipe(F(_,["integrations.connectionStatus"]),P("Check whether social account OAuth completed.")),rZ=T("health",{account:bp,workspace:N},({account:e,workspace:t})=>R(async()=>(await Ke(f(t))).accounts.get(e))).pipe(F(_,["integrations.getAccount"]),P("Check account readiness using the last recorded grant.")),nZ=T("instagram-quota",{account:bp,workspace:N},({account:e,workspace:t})=>R(async()=>(await Ke(f(t))).accounts.instagramPublishingLimit(e))).pipe(F(_,["integrations.instagramPublishingLimit"]),P("Read the Instagram account\u2019s current publishing quota.")),oZ=T("instagram-audio",{account:bp,workspace:N,type:ke("type",sh.literals).pipe(tt("music")),query:C("query").pipe(E)},({account:e,workspace:t,type:r,query:n})=>R(async()=>(await Ke(f(t))).accounts.searchInstagramAudio(e,{audioType:r,q:f(n)}))).pipe(F(_,["integrations.searchInstagramAudio"]),P("Search Instagram\u2019s catalog or list trending audio.")),iZ=T("instagram-audio-info",{account:bp,workspace:N,audioId:ne("audio-id").pipe(ie(rp))},({account:e,workspace:t,audioId:r})=>R(async()=>(await Ke(f(t))).accounts.getInstagramAudio(e,r))).pipe(F(_,["integrations.getInstagramAudio"]),P("Read current metadata for an Instagram audio track.")),sZ=T("reconnect",{account:bp,workspace:N,browser:Xu,loginMethod:i1},(e)=>R(async()=>{let t=Ai(),r=await Ke(f(e.workspace),{origin:t});return c1(await r.accounts.reconnect(e.account,f(e.loginMethod)),t,e.browser)})).pipe(F(_,["integrations.reconnect"]),P("Reauthorize a connected account while keeping its ID.")),aZ=T("disconnect",{connection:ne("connection-id").pipe(ie(FD.fields.connectionId)),workspace:N,yes:ht("yes").pipe(tt(!1))},({connection:e,workspace:t,yes:r})=>R(async()=>{if(!r)throw new Fe("Pass --yes to disconnect the grant and disable all accounts using it.");return(await Ke(f(t))).accounts.disconnect(e)})).pipe(F(_,["integrations.disconnect"]),P("Remove a grant and disable its accounts."));function o1(e){return T(e,{account:bp,workspace:N},({account:t,workspace:r})=>R(async()=>(await Ke(f(r))).accounts.setEnabled({id:t,enabled:e==="enable"}))).pipe(F(_,["integrations.setEnabled"]),P(`${e==="enable"?"Enable":"Disable"} a publishing destination.`))}var p1=T("integrations").pipe(P("Connect and select publishing destinations."),Ze([Z5,X5,eZ,tZ,rZ,nZ,oZ,iZ,sZ,aZ,o1("enable"),o1("disable"),...n1]));import{writeFile as cZ}from"fs/promises";var d1=[T("status",{workspace:N,mediaId:ne("media-id").pipe(ie(a.check(L())))},(e)=>R(async()=>{let t=await J();return t.runtime.decode(H,Rh({client:t.runtime.client,path:{mediaId:e.mediaId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["media.status"]),P("Get workspace media intake status")),T("get",{workspace:N,mediaId:ne("media-id").pipe(ie(a.check(L())))},(e)=>R(async()=>{let t=await J();return t.runtime.decode(H,yw({client:t.runtime.client,path:{mediaId:e.mediaId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["media.get"]),P("Get workspace media metadata")),T("list",{workspace:N,cursor:C("cursor").pipe(E),limit:Le("limit").pipe(E),type:ke("type",["image","video","document"]).pipe(E)},(e)=>R(async()=>{let t=await J();return t.runtime.decode(H,mw({client:t.runtime.client,query:{workspaceId:await Z(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(F(_,["media.list"]),P("List ready workspace media")),T("delete",{workspace:N,mediaId:ne("media-id").pipe(ie(a.check(L())))},(e)=>R(async()=>{let t=await J(void 0,"human");return t.runtime.decode(H,hw({client:t.runtime.client,path:{mediaId:e.mediaId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["media.delete"]),P("Delete unused workspace media"))];var u1=ne("media-id").pipe(ie(xn)),pZ=T("upload",{file:ne("file"),workspace:N,mime:ke("mime",ep.literals).pipe(E),key:ot},(e)=>R(async()=>{let t=Bun.file(e.file);if(!await t.exists())throw new Fe("Choose an existing media file.");return(await Ke(f(e.workspace))).media.upload(t,{mimeType:f(e.mime),idempotencyKey:f(e.key)})})).pipe(F(_,["media.upload","media.startUpload","media.uploadPart","media.completeUpload"]),P("Upload an image, video, or document for use in posts.")),dZ=T("import",{url:ne("url"),workspace:N,key:ot},(e)=>R(async()=>(await Ke(f(e.workspace))).media.importUrl(e.url,{idempotencyKey:f(e.key)}))).pipe(F(_,["media.import"]),P("Copy a public or signed HTTPS URL into private workspace media.")),uZ=T("wait",{mediaId:u1,workspace:N,timeoutSeconds:Le("timeout").pipe(tt(30),Oe("Maximum seconds to wait for media readiness."))},(e)=>R(async()=>{if(e.timeoutSeconds<0||e.timeoutSeconds>300)throw new Fe("Use a timeout between 0 and 300 seconds.");let t=await(await Ke(f(e.workspace))).media.wait(e.mediaId,{timeoutMs:e.timeoutSeconds*1000});if(t.status!=="ready")process.exitCode=1;return t})).pipe(F(_,["media.status"]),P("Wait for media readiness and return ready, failed, or timeout.")),lZ=T("download",{mediaId:u1,workspace:N,out:C("out")},(e)=>R(async()=>{let t=await(await Ke(f(e.workspace))).media.download(e.mediaId);return await cZ(e.out,new Uint8Array(await t.arrayBuffer()),{flag:"wx"}),{path:e.out,sizeBytes:t.size}})).pipe(F(_,["media.download"]),P("Save private media to a new local file.")),l1=T("media").pipe(P("Manage workspace media files."),Ze([pZ,dZ,...d1,uZ,lZ]));var f1=[T("get",{workspace:N,postId:ne("post-id").pipe(ie(a.check(L())))},(e)=>R(async()=>{let t=await J();return t.runtime.decode(H,zw({client:t.runtime.client,path:{postId:e.postId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["posts.get"]),P("Read a post or draft")),T("attempts",{workspace:N,postId:ne("post-id").pipe(ie(a.check(L()))),targetId:ne("target-id").pipe(ie(a.check(L()))),cursor:C("cursor").pipe(E),limit:Le("limit").pipe(E)},(e)=>R(async()=>{let t=await J();return t.runtime.decode(H,Qw({client:t.runtime.client,path:{postId:e.postId,targetId:e.targetId},query:{workspaceId:await Z(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(F(_,["posts.attempts"]),P("Read a destination's delivery attempt history")),T("retry",{workspace:N,postId:ne("post-id").pipe(ie(a.check(L()))),targetId:ne("target-id").pipe(ie(a.check(L()))),expectedAttemptId:C("expected-attempt-id").pipe(fe(a.check(L())))},(e)=>R(async()=>{let t=await J();return t.runtime.decode(H,Hw({client:t.runtime.client,path:{postId:e.postId,targetId:e.targetId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{expectedAttemptId:e.expectedAttemptId},...t.runtime.transport()}))})).pipe(F(_,["posts.retry"]),P("Retry a failed delivery")),T("reconcile",{workspace:N,postId:ne("post-id").pipe(ie(a.check(L()))),targetId:ne("target-id").pipe(ie(a.check(L()))),expectedAttemptId:C("expected-attempt-id").pipe(fe(a.check(L())))},(e)=>R(async()=>{let t=await J();return t.runtime.decode(H,Vw({client:t.runtime.client,path:{postId:e.postId,targetId:e.targetId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{expectedAttemptId:e.expectedAttemptId},...t.runtime.transport()}))})).pipe(F(_,["posts.reconcile"]),P("Recheck a recorded provider receipt")),T("update",{workspace:N,postId:ne("post-id").pipe(ie(a.check(L()))),text:C("text").pipe(E),expectedRevision:Le("revision").pipe(E),file:C("file").pipe(E,Oe("Read the body JSON from a file or stdin with -."))},(e)=>R(async()=>{let t=await J(),r=f(e.file),n=r===void 0?{...O(e.text)?{text:f(e.text)}:{},...O(e.expectedRevision)?{expectedRevision:f(e.expectedRevision)}:{}}:await Et(r);return t.runtime.decode(H,jw({client:t.runtime.client,path:{postId:e.postId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:n,...t.runtime.transport()}))})).pipe(F(_,["posts.update"]),P("Edit a draft")),T("delete",{workspace:N,postId:ne("post-id").pipe(ie(a.check(L())))},(e)=>R(async()=>{let t=await J();return t.runtime.decode(H,Gw({client:t.runtime.client,path:{postId:e.postId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["posts.delete"]),P("Archive a post or draft"))];var fZ=ao(hL,{onExcessProperty:"error"}),Iy=ne("post-id").pipe(ie(zU.fields.postId)),mZ=Le("revision").pipe(fe(lo),Oe("Expected revision from posts get.")),hZ=T("create",{workspace:N,text:C("text").pipe(E,Oe("Post text for the one-call path.")),platform:ke("platform",ps).pipe(Ir(0),Oe("Publish to the single ready account for this provider. Repeat for several platforms.")),account:Wq,mediaId:C("media-id").pipe(fe(xn),Ir(0),Oe("Attach ready workspace media by ID.")),mediaUrl:C("media-url").pipe(Ir(0),Oe("Attach a public HTTPS media URL.")),schedule:C("schedule").pipe(fe(Ut),E,Oe("Schedule with an ISO time and explicit offset.")),publishNow:ht("publish-now").pipe(tt(!0),Oe("Publish now when --schedule is absent.")),draft:ht("draft").pipe(tt(!1),Oe("Save a draft without submitting it.")),file:C("file").pipe(E,Oe("Advanced: read a full Level 2 post JSON document from a file or stdin with -.")),key:ot,queue:C("queue").pipe(fe(jt),E,Oe("Assign every file-provided destination to this account queue."))},(e)=>R(async()=>{let t=await Ke(f(e.workspace)),r=f(e.key),n=f(e.file),o=f(e.schedule);if(e.draft&&o)throw new Fe("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 Fe("Use --file alone, or provide --text with --platform or --account.");let c=await fZ(await Et(n)).catch(()=>{throw new Fe("Post JSON does not match the PubNio API contract.")}),l=f(e.queue);if(l&&e.draft)throw new Fe("Drafts cannot be assigned a queue.");if(l&&(c.targets??[]).some((S)=>S.scheduledAt!==void 0||S.queueId!==void 0))throw new Fe("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 Fe("Provide --text or --file.");if(e.draft&&e.platform.length)throw new Fe("Drafts select exact --account IDs, not platforms.");if(!e.draft&&O(e.queue))throw new Fe("--queue requires --file.");if(!e.draft&&e.platform.length&&e.account.length)throw new Fe("Use --platform or --account, not both.");if(!e.draft&&!e.platform.length&&!e.account.length)throw new Fe("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(F(_,["posts.create"]),P("Create and submit a post in one call, or save a draft with --draft.")),yZ=T("list",{workspace:N,...Ss,draft:ht("draft").pipe(tt(!1),Oe("List only drafts. Omit to list posts and drafts.")),deliveryStatus:ke("delivery-status",Yc.literals).pipe(E)},(e)=>R(async()=>(await Ke(f(e.workspace))).posts.list({cursor:f(e.cursor),limit:f(e.limit),...e.draft?{isDraft:!0}:{},deliveryStatus:f(e.deliveryStatus)}))).pipe(F(_,["posts.list"]),P("List posts and drafts, and filter their current deliveries.")),gZ=T("validate",{workspace:N,id:Iy},(e)=>R(async()=>{let t=await(await Ke(f(e.workspace))).posts.validate(e.id);if(!t.canPublish)process.exitCode=1;return t})).pipe(F(_,["posts.validate"]),P("Validate a saved draft before publishing.")),xZ=T("publish",{id:Iy,workspace:N,revision:mZ,key:ot,at:C("at").pipe(fe(Ut),E),queue:C("queue").pipe(fe(jt),E),account:Gq,placement:ke("placement",xr.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 Fe("Use --placement with --account.");if(n&&o)throw new Fe("Use --at or --queue, not both.");let s=await Ke(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 Fe("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(F(_,["posts.get","posts.publish"]),P("Publish a saved draft now or at --at.")),SZ=T("status",{workspace:N,id:Iy},(e)=>R(async()=>(await Ke(f(e.workspace))).posts.status(e.id))).pipe(F(_,["posts.get"]),P("Read delivery outcomes for a post.")),bZ=T("wait",{workspace:N,id:Iy,timeoutSeconds:Le("timeout").pipe(tt(60),Oe("Maximum seconds to wait for delivery."))},(e)=>R(async()=>{if(e.timeoutSeconds<0||e.timeoutSeconds>3600)throw new Fe("Use a timeout between 0 and 3600 seconds.");let t=await(await Ke(f(e.workspace))).posts.wait(e.id,{timeoutMs:e.timeoutSeconds*1000});if(!t.settled)process.exitCode=1;return t})).pipe(F(_,["posts.get"]),P("Wait for a post to reach a settled delivery outcome."));function AA(e,t){return R(async()=>(await Ke(f(e.workspace))).schedule.change(DU(e.postId),LU(e.targetId),t))}var vA={postId:ne("post-id").pipe(ie(Eb.fields.postId)),targetId:ne("target-id").pipe(ie(Eb.fields.targetId)),expectedAttemptId:C("attempt").pipe(fe(Kt),Oe("Current attempt ID from posts status.")),workspace:N},IZ=T("reschedule",{...vA,at:C("at").pipe(fe(Ut),E),queue:C("queue").pipe(fe(jt),E),slot:C("slot").pipe(fe(a.check(L())),E),date:C("date").pipe(fe(wn),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 Fe("Use exactly one of --at or --queue.");if(r&&n===void 0!==(o===void 0))throw new Fe("Use --slot and --date together to pin a slot.");return AA(e,r?{action:"reschedule",expectedAttemptId:e.expectedAttemptId,queueId:r,...n&&o?{pinned:{slotId:n,occurrenceDate:o}}:{}}:{action:"reschedule",expectedAttemptId:e.expectedAttemptId,scheduledAt:t})}).pipe(F(_,["schedule.change"]),P("Move a pending delivery to a queue slot or time.")),wZ=T("cancel",vA,(e)=>AA(e,{action:"cancel",expectedAttemptId:e.expectedAttemptId})).pipe(F(_,["schedule.change"]),P("Cancel a delivery before the provider write is reserved.")),EZ=T("publish-now",vA,(e)=>AA(e,{action:"publish_now",expectedAttemptId:e.expectedAttemptId})).pipe(F(_,["schedule.change"]),P("Bring a pending delivery forward.")),m1=T("posts").pipe(P("Create and publish posts, save drafts, and manage delivery status."),Ze([hZ,yZ,...f1,gZ,xZ,SZ,bZ,IZ,wZ,EZ]));var kn=ne("queue-id").pipe(ie(jt)),wy=Le("version").pipe(Oe("Expected version from the last queue read.")),y1={maxPerDay:Le("max-per-day").pipe(E),maxPending:Le("max-pending").pipe(E),minGap:Le("min-gap").pipe(E),horizon:Le("horizon-days").pipe(E)},g1={slot:C("slot").pipe(h9(50),Oe("Weekly slot as DAY:HH:mm where 0 is Sunday."))},kZ=ao(kL,{onExcessProperty:"error"}),AZ=ao(AL,{onExcessProperty:"error"}),vZ=ao(vL,{onExcessProperty:"error"}),CZ=ao(_L,{onExcessProperty:"error"}),TZ=ao(LL,{onExcessProperty:"error"});function x1(e){let t=/^([0-6]):((?:[01]\d|2[0-3]):[0-5]\d)$/.exec(e);if(!t)throw new Fe("Use --slot DAY:HH:mm where DAY is 0-6, 0 Sunday.");return{dayOfWeek:Number(t[1]),time:t[2]}}function S1(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 OZ=T("list",{workspace:N,account:eA,...Ss},(e)=>R(async()=>(await Ke(f(e.workspace))).queues.list({accountId:f(e.account),cursor:f(e.cursor),limit:f(e.limit)}))).pipe(F(_,["queues.list"]),P("List account schedule queues.")),PZ=T("create",{workspace:N,file:C("file").pipe(E,Oe("Read CreateQueue JSON from a file or stdin with -.")),account:eA,name:C("name").pipe(E),timezone:C("timezone").pipe(E,Oe("IANA time zone, e.g. America/New_York. Defaults to the workspace default time zone.")),default:ht("default").pipe(E,Oe("Promote the new queue to the account default. The first active queue is always the default.")),...g1,...y1},(e)=>R(async()=>{let t=await Ke(f(e.workspace)),r=f(e.file),n=await kZ(r?await Et(r):{accountId:f(e.account),name:f(e.name),...sr(e.timezone)?{}:{timezone:e.timezone.value},slots:e.slot.map(x1),...sr(e.default)?{}:{isDefault:e.default.value},...S1(e)}).catch(()=>{throw new Fe("Queue JSON does not match the PubNio API contract.")});return t.queues.create(n)})).pipe(F(_,["queues.create"]),P("Create a weekly queue for an account; the first is the default. Omit --timezone to use the workspace default.")),RZ=T("get",{workspace:N,queueId:kn},(e)=>R(async()=>(await Ke(f(e.workspace))).queues.get(e.queueId))).pipe(F(_,["queues.get"]),P("Read a queue, its slots, and its limits.")),_Z=T("update",{workspace:N,queueId:kn,version:wy,file:C("file").pipe(E,Oe("Read UpdateQueue JSON from a file or stdin with -.")),name:C("name").pipe(E),timezone:C("timezone").pipe(E),pause:ht("pause").pipe(tt(!1)),resume:ht("resume").pipe(tt(!1)),default:ht("default").pipe(E,Oe("Promote or demote the account default. Demote only after promoting another queue.")),...y1},(e)=>R(async()=>{if(e.pause&&e.resume)throw new Fe("Use --pause or --resume, not both.");let t=await Ke(f(e.workspace)),r=f(e.file),n=await AZ(r?await Et(r):{expectedVersion:e.version,...sr(e.name)?{}:{name:e.name.value},...sr(e.timezone)?{}:{timezone:e.timezone.value},...e.pause?{paused:!0}:e.resume?{paused:!1}:{},...sr(e.default)?{}:{isDefault:e.default.value},...S1(e)}).catch(()=>{throw new Fe("Queue update JSON does not match the PubNio API contract.")});return t.queues.update(e.queueId,n)})).pipe(F(_,["queues.update"]),P("Update limits, name, time zone, default, pause, or resume a queue.")),UZ=T("archive",{workspace:N,queueId:kn,version:wy},(e)=>R(async()=>(await Ke(f(e.workspace))).queues.archive(e.queueId,e.version))).pipe(F(_,["queues.archive"]),P("Archive a queue and keep queued work.")),DZ=T("slots",{workspace:N,queueId:kn,version:wy,file:C("file").pipe(E,Oe("Read ReplaceQueueSlots JSON from a file or stdin.")),...g1},(e)=>R(async()=>{let t=await Ke(f(e.workspace)),r=f(e.file),n=await vZ(r?await Et(r):{expectedVersion:e.version,slots:e.slot.map(x1)}).catch(()=>{throw new Fe("Queue slot JSON does not match the PubNio API contract.")});return t.queues.replaceSlots(e.queueId,n)})).pipe(F(_,["queues.slots.replace"]),P("Replace every weekly queue slot.")),LZ=T("next-slot",{workspace:N,queueId:kn,after:C("after").pipe(E)},(e)=>R(async()=>(await Ke(f(e.workspace))).queues.nextSlot(e.queueId,f(e.after)))).pipe(F(_,["queues.slots.next"]),P("Read the next free queue occurrence.")),MZ=T("preview",{workspace:N,queueId:kn,count:Le("count").pipe(tt(10)),after:C("after").pipe(E),includeOccupied:ht("include-occupied").pipe(tt(!1))},(e)=>R(async()=>(await Ke(f(e.workspace))).queues.previewSlots(e.queueId,{count:e.count,after:f(e.after),includeOccupied:e.includeOccupied}))).pipe(F(_,["queues.slots.preview"]),P("Preview upcoming queue occurrences.")),FZ=T("skips",{workspace:N,queueId:kn,...Ss},(e)=>R(async()=>(await Ke(f(e.workspace))).queues.skips(e.queueId,{cursor:f(e.cursor),limit:f(e.limit)}))).pipe(F(_,["queues.skips.list"]),P("List skipped queue occurrences.")),NZ=T("skip",{workspace:N,queueId:kn,slotId:C("slot-id").pipe(fe(wu)),occurrenceDate:C("occurrence-date")},(e)=>R(async()=>{let t=await Ke(f(e.workspace)),r=await CZ({slotId:e.slotId,occurrenceDate:e.occurrenceDate}).catch(()=>{throw new Fe("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(F(_,["queues.skips.create"]),P("Skip one queue occurrence.")),BZ=T("unskip",{workspace:N,queueId:kn,skipId:C("skip-id").pipe(fe(wu))},(e)=>R(async()=>(await Ke(f(e.workspace))).queues.unskip(e.queueId,e.skipId))).pipe(F(_,["queues.skips.delete"]),P("Restore a skipped queue occurrence.")),KZ=T("blackouts",{workspace:N,queueId:kn,...Ss},(e)=>R(async()=>(await Ke(f(e.workspace))).queues.blackouts(e.queueId,{cursor:f(e.cursor),limit:f(e.limit)}))).pipe(F(_,["queues.blackouts.list"]),P("List queue blackout date ranges.")),qZ=T("blackout",{workspace:N,queueId:kn,startsOn:C("starts-on"),endsOn:C("ends-on"),reason:C("reason").pipe(E)},(e)=>R(async()=>{let t=await Ke(f(e.workspace)),r=await TZ({startsOn:e.startsOn,endsOn:e.endsOn,reason:f(e.reason)}).catch(()=>{throw new Fe("Use --starts-on and --ends-on as YYYY-MM-DD; --reason is at most 200 characters.")});return t.queues.blackout(e.queueId,r)})).pipe(F(_,["queues.blackouts.create"]),P("Black out a queue date range.")),$Z=T("unblackout",{workspace:N,queueId:kn,blackoutId:C("blackout-id").pipe(fe(dh))},(e)=>R(async()=>(await Ke(f(e.workspace))).queues.unblackout(e.queueId,e.blackoutId))).pipe(F(_,["queues.blackouts.delete"]),P("Remove a queue blackout.")),h1=(e)=>T(e?"pause":"resume",{workspace:N,queueId:kn,version:wy},(t)=>R(async()=>(await Ke(f(t.workspace))).queues.update(t.queueId,{expectedVersion:t.version,paused:e}))).pipe(F(_,["queues.update"]),P(e?"Pause new assignments while queued attempts still publish.":"Resume new assignments.")),b1=T("queues").pipe(P("Manage weekly account publishing queues."),Ze([OZ,PZ,RZ,_Z,UZ,DZ,LZ,MZ,FZ,NZ,BZ,KZ,qZ,$Z,h1(!0),h1(!1)]));var WZ=T("list",{workspace:N,from:C("from").pipe(Oe("Inclusive ISO start instant, for example 2026-12-01T00:00:00Z.")),to:C("to").pipe(Oe("Inclusive ISO end instant, at most 90 days after --from.")),accountId:C("account-id").pipe(fe(V),E,Oe("Filter by the target publishing account.")),queueId:C("queue-id").pipe(fe(jt),E,Oe("Filter by the open queue assignment.")),...Ss},(e)=>R(async()=>(await Ke(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(F(_,["schedule.list"]),P("List queued attempts in a time range.")),GZ=T("skip-to-next",{workspace:N,postId:C("post-id").pipe(fe(Ot)),targetId:C("target-id").pipe(fe(tr)),queueId:C("queue-id").pipe(fe(jt),E,Oe("Override the target delivery's current queue.")),expectedAttemptId:C("expected-attempt-id").pipe(fe(Kt),E,Oe("Override the target delivery's current attempt."))},(e)=>R(async()=>(await Ke(f(e.workspace))).schedule.skipToNext(e.postId,e.targetId,{queueId:f(e.queueId),expectedAttemptId:f(e.expectedAttemptId)}))).pipe(F(_,["posts.get","queues.slots.next","schedule.change"]),P("Move a queue-assigned target to the next free occurrence.")),I1=T("schedule").pipe(P("Read the publishing calendar and skip ahead."),Ze([WZ,GZ]));var w1=[T("preferences").pipe(P(""),Ze([T("get",{workspace:N},(e)=>R(async()=>{let t=await J(void 0,"human");return t.runtime.decode(H,LE({client:t.runtime.client,path:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["notifications.preferences.get"]),P("Read email notification preferences")),T("update",{workspace:N,deliveryFailures:ht("delivery-failures").pipe(tt(!1)),connectionExpiring:ht("connection-expiring").pipe(tt(!1)),webhookFailures:ht("webhook-failures").pipe(tt(!1)),billingAlerts:ht("billing-alerts").pipe(tt(!1)),weeklyDigest:ht("weekly-digest").pipe(tt(!1))},(e)=>R(async()=>{let t=await J(void 0,"human");return t.runtime.decode(H,ME({client:t.runtime.client,path:{workspaceId:await Z(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(F(_,["notifications.preferences.update"]),P("Update email notification preferences"))]))];var E1=T("notifications").pipe(P("Read and update notification preferences."),Ze(w1));var k1=[T("get",{},(e)=>R(async()=>{let t=await J(void 0,"human");return t.runtime.decode(H,MI({client:t.runtime.client,...t.runtime.transport()}))})).pipe(F(_,["profile.get"]),P("Get your profile"))];var zZ=T("update",{name:C("name").pipe(E),clear:ht("clear-name").pipe(tt(!1))},({name:e,clear:t})=>R(async()=>{if(e._tag==="Some"===t)throw new Fe("Provide exactly one of --name or --clear-name.");let r=ns(BU)({displayName:e._tag==="Some"?e.value:null});if(r._tag==="None")throw new Fe("Display name must be between 1 and 100 characters.");return(await go()).me.update(r.value)})).pipe(F(_,["profile.update"]),P("Change or clear your display name.")),jZ=T("deactivate",{yes:ht("yes").pipe(tt(!1))},({yes:e})=>R(async()=>{if(!e)throw new Fe("Pass --yes to deactivate the current profile.");return(await go()).me.deactivate()})).pipe(F(_,["profile.deactivate"]),P("Deactivate your profile after archiving owned workspaces.")),QZ=T("list",{},()=>R(async()=>(await go(void 0,"human")).me.invites())).pipe(F(_,["me.invites.list"])),HZ=T("accept",{inviteId:ne("invite-id").pipe(ie(mi))},({inviteId:e})=>R(async()=>(await go(void 0,"human")).me.acceptInvite({inviteId:e}))).pipe(F(_,["me.invites.accept"])),VZ=T("decline",{inviteId:ne("invite-id").pipe(ie(mi))},({inviteId:e})=>R(async()=>(await go(void 0,"human")).me.declineInvite(e))).pipe(F(_,["me.invites.decline"])),JZ=T("invites").pipe(P("Manage your workspace invitations."),Ze([QZ,HZ,VZ])),A1=T("profile").pipe(P("Manage your PubNio profile."),Ze([...k1,zZ,jZ,JZ]));var v1=[T("list",{workspace:N,includeArchived:ke("include-archived",["true","false"]).pipe(E),cursor:C("cursor").pipe(E),limit:Le("limit").pipe(E)},(e)=>R(async()=>{let t=await J();return t.runtime.decode(H,iw({client:t.runtime.client,query:{workspaceId:await Z(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(F(_,["profiles.list"]),P("List workspace profiles")),T("create",{workspace:N,name:C("name"),externalId:C("external-id").pipe(E)},(e)=>R(async()=>{let t=await J(void 0,"human");return t.runtime.decode(H,sw({client:t.runtime.client,query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{name:e.name,...O(e.externalId)?{externalId:f(e.externalId)}:{}},...t.runtime.transport()}))})).pipe(F(_,["profiles.create"]),P("Create a workspace profile")),T("get",{workspace:N,profileId:ne("profile-id").pipe(ie(a.check(L())))},(e)=>R(async()=>{let t=await J();return t.runtime.decode(H,cw({client:t.runtime.client,path:{profileId:e.profileId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["profiles.get"]),P("Read a workspace profile")),T("update",{workspace:N,profileId:ne("profile-id").pipe(ie(a.check(L()))),name:C("name").pipe(E),file:C("file").pipe(E,Oe("Read the body JSON from a file or stdin with -."))},(e)=>R(async()=>{let t=await J(void 0,"human"),r=f(e.file),n=r===void 0?{...O(e.name)?{name:f(e.name)}:{}}:await Et(r);return t.runtime.decode(H,pw({client:t.runtime.client,path:{profileId:e.profileId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:n,...t.runtime.transport()}))})).pipe(F(_,["profiles.update"]),P("Rename a profile or change its external ID")),T("archive",{workspace:N,profileId:ne("profile-id").pipe(ie(a.check(L())))},(e)=>R(async()=>{let t=await J(void 0,"human");return t.runtime.decode(H,aw({client:t.runtime.client,path:{profileId:e.profileId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["profiles.archive"]),P("Archive a workspace profile"))];var C1=T("profiles").pipe(P("Manage posting profiles."),Ze(v1));var T1=[T("list",{workspace:N,cursor:C("cursor").pipe(E),limit:Le("limit").pipe(E)},(e)=>R(async()=>{let t=await J(void 0,"human");return t.runtime.decode(H,QI({client:t.runtime.client,path:{workspaceId:await Z(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(F(_,["webhooks.list"]),P("List webhook endpoints")),T("create",{workspace:N,name:C("name"),url:C("url"),eventTypes:ke("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(Ir(0)),enabled:ht("paused").pipe(tt(!1)),profileId:C("profile-id").pipe(fe(a.check(L()))).pipe(E),accountIds:C("account-ids").pipe(Ir(0)),disabledResourceGroups:ke("disabled-resource-groups",["publishing","inbox","analytics","ads","scheduling","accounts","billing"]).pipe(Ir(0))},(e)=>R(async()=>{let t=await J(void 0,"human");return t.runtime.decode(H,HI({client:t.runtime.client,path:{workspaceId:await Z(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(F(_,["webhooks.create"]),P("Register a webhook endpoint")),T("get",{workspace:N,endpointId:ne("endpoint-id").pipe(ie(a.check(L())))},(e)=>R(async()=>{let t=await J(void 0,"human");return t.runtime.decode(H,JI({client:t.runtime.client,path:{endpointId:e.endpointId,workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["webhooks.get"]),P("Inspect a webhook endpoint")),T("update",{workspace:N,endpointId:ne("endpoint-id").pipe(ie(a.check(L()))),name:C("name").pipe(E),eventTypes:ke("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(Ir(0)),enabled:ht("paused").pipe(tt(!1)),file:C("file").pipe(E,Oe("Read the body JSON from a file or stdin with -."))},(e)=>R(async()=>{let t=await J(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 Et(r);return t.runtime.decode(H,YI({client:t.runtime.client,path:{endpointId:e.endpointId,workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:n,...t.runtime.transport()}))})).pipe(F(_,["webhooks.update"]),P("Edit or pause a webhook endpoint")),T("delete",{workspace:N,endpointId:ne("endpoint-id").pipe(ie(a.check(L())))},(e)=>R(async()=>{let t=await J(void 0,"human");return t.runtime.decode(H,VI({client:t.runtime.client,path:{endpointId:e.endpointId,workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["webhooks.delete"]),P("Permanently disable a webhook endpoint")),T("test",{workspace:N,endpointId:ne("endpoint-id").pipe(ie(a.check(L())))},(e)=>R(async()=>{let t=await J(void 0,"human");return t.runtime.decode(H,ZI({client:t.runtime.client,path:{endpointId:e.endpointId,workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["webhooks.test"]),P("Enqueue a webhook test event")),T("list-deliveries",{workspace:N,endpointId:ne("endpoint-id").pipe(ie(a.check(L()))),cursor:C("cursor").pipe(E),limit:Le("limit").pipe(E)},(e)=>R(async()=>{let t=await J(void 0,"human");return t.runtime.decode(H,XI({client:t.runtime.client,path:{endpointId:e.endpointId,workspaceId:await Z(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(F(_,["webhooks.listDeliveries"]),P("List webhook deliveries")),T("get-delivery",{workspace:N,endpointId:ne("endpoint-id").pipe(ie(a.check(L()))),deliveryId:ne("delivery-id").pipe(ie(a.check(L())))},(e)=>R(async()=>{let t=await J(void 0,"human");return t.runtime.decode(H,ew({client:t.runtime.client,path:{endpointId:e.endpointId,deliveryId:e.deliveryId,workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["webhooks.getDelivery"]),P("Inspect a webhook delivery")),T("replay-delivery",{workspace:N,endpointId:ne("endpoint-id").pipe(ie(a.check(L()))),deliveryId:ne("delivery-id").pipe(ie(a.check(L())))},(e)=>R(async()=>{let t=await J(void 0,"human");return t.runtime.decode(H,tw({client:t.runtime.client,path:{endpointId:e.endpointId,deliveryId:e.deliveryId,workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["webhooks.replayDelivery"]),P("Replay a settled webhook delivery")),T("event-types",{},(e)=>R(async()=>{let t=await J();return t.runtime.decode(H,E6({client:t.runtime.client,...t.runtime.transport()}))})).pipe(F(_,["webhooks.eventTypes"]),P("List supported webhook event types"))];var O1=T("webhooks").pipe(P("Manage workspace webhooks as a signed-in owner."),Ze(T1));var P1=[T("list",{},(e)=>R(async()=>{let t=await J();return t.runtime.decode(H,FI({client:t.runtime.client,...t.runtime.transport()}))})).pipe(F(_,["workspaces.list"]),P("List workspaces")),T("create",{name:C("name"),defaultTimezone:C("default-timezone").pipe(E)},(e)=>R(async()=>{let t=await J(void 0,"human");return t.runtime.decode(H,NI({client:t.runtime.client,body:{name:e.name,...O(e.defaultTimezone)?{defaultTimezone:f(e.defaultTimezone)}:{}},...t.runtime.transport()}))})).pipe(F(_,["workspaces.create"]),P("Create a workspace")),T("get",{id:ne("id").pipe(ie(a.check(L())))},(e)=>R(async()=>{let t=await J();return t.runtime.decode(H,KI({client:t.runtime.client,path:{workspaceId:e.id},...t.runtime.transport()}))})).pipe(F(_,["workspaces.get"]),P("Get a workspace")),T("update",{id:ne("id").pipe(ie(a.check(L()))),name:C("name").pipe(E),defaultTimezone:C("default-timezone").pipe(E)},(e)=>R(async()=>{let t=await J(void 0,"human");if(!(O(e.name)||O(e.defaultTimezone)))throw new Fe("Provide --name or --default-timezone.");return t.runtime.decode(H,qI({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(F(_,["workspaces.update"]),P("Update a workspace you own")),T("archive",{id:ne("id").pipe(ie(a.check(L())))},(e)=>R(async()=>{let t=await J(void 0,"human");return t.runtime.decode(H,BI({client:t.runtime.client,path:{workspaceId:e.id},...t.runtime.transport()}))})).pipe(F(_,["workspaces.archive"]),P("Archive a workspace you own")),T("invites").pipe(P(""),Ze([T("list",{workspace:N,status:ke("status",["pending","accepted","revoked","expired"]).pipe(E),cursor:C("cursor").pipe(E),limit:Le("limit").pipe(E)},(e)=>R(async()=>{let t=await J(void 0,"human");return t.runtime.decode(H,KE({client:t.runtime.client,path:{workspaceId:await Z(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(F(_,["workspaces.invites.list"]),P("List workspace invitations")),T("create",{workspace:N,email:C("email"),role:ke("role",["owner","member"]).pipe(E),idempotencyKey:ot},(e)=>R(async()=>{let t=await J(void 0,"human");return t.runtime.decode(H,qE({client:t.runtime.client,path:{workspaceId:await Z(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(F(_,["workspaces.invites.create"]),P("Create a workspace invitation")),T("resend",{workspace:N,inviteId:ne("invite-id").pipe(ie(a.check(L()))),idempotencyKey:ot},(e)=>R(async()=>{let t=await J(void 0,"human");return t.runtime.decode(H,$E({client:t.runtime.client,path:{inviteId:e.inviteId,workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},headers:{"idempotency-key":f(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()}))})).pipe(F(_,["workspaces.invites.resend"]),P("Resend a pending invitation email")),T("revoke",{workspace:N,inviteId:ne("invite-id").pipe(ie(a.check(L())))},(e)=>R(async()=>{let t=await J(void 0,"human");return t.runtime.decode(H,WE({client:t.runtime.client,path:{inviteId:e.inviteId,workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["workspaces.invites.revoke"]),P("Revoke a pending workspace invitation"))])),T("members").pipe(P(""),Ze([T("list",{workspace:N,role:ke("role",["owner","member"]).pipe(E),cursor:C("cursor").pipe(E),limit:Le("limit").pipe(E)},(e)=>R(async()=>{let t=await J(void 0,"human");return t.runtime.decode(H,FE({client:t.runtime.client,path:{workspaceId:await Z(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(F(_,["workspaces.members.list"]),P("List workspace members")),T("remove",{workspace:N,userId:ne("user-id").pipe(ie(a.check(L())))},(e)=>R(async()=>{let t=await J(void 0,"human");return t.runtime.decode(H,NE({client:t.runtime.client,path:{userId:e.userId,workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["workspaces.members.remove"]),P("Remove a workspace member or leave the workspace")),T("update-role",{workspace:N,userId:ne("user-id").pipe(ie(a.check(L()))),role:ke("role",["owner","member"])},(e)=>R(async()=>{let t=await J(void 0,"human");return t.runtime.decode(H,BE({client:t.runtime.client,path:{userId:e.userId,workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{role:e.role},...t.runtime.transport()}))})).pipe(F(_,["workspaces.members.updateRole"]),P("Update a workspace member's role"))]))];var YZ=T("use",{id:$q},({id:e})=>R(async()=>(await go()).useWorkspace(e))).pipe(F(_,["workspaces.get"]),P("Remember the active workspace for this CLI session.")),R1=T("workspaces").pipe(P("Manage PubNio workspaces."),Ze([...P1,YZ]));var _1=T("pnio").pipe(P("Connect accounts and manage PubNio content."),Ze([j$,A1,R1,C1,$$,K$,G$,E1,p1,J$,Z$,e1,N$,m1,b1,I1,l1,O1,r1,H$]));var ZZ=Bq(_1,{version:Zu.version}),sl=process.argv.slice(2);try{await RO(ZZ(sl.length?sl:["--help"]).pipe(TO(o4),Vi(fp,{present:(e)=>e._tag==="InvalidInvocation"?Be(()=>console.error(e.errors.map((t)=>t.message).join(`
272
- `))):NK.present(e)})))}catch(e){if(e instanceof Si){if(e.errors.length)process.exitCode=2}else if(e instanceof $n){let t=e.status===401?process.env.PUBNIO_API_KEY!==void 0&&sl[0]!=="api-keys"&&sl[0]!=="webhooks"&&sl[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 Fe?2:1}
267
+ return $results`,qq=(e,t)=>{let r=`$global:_${PZ(e)}_Completions`,n=[];return n.push(`###-begin-${e}-completions-###`),n.push("#"),n.push("# Static completion script for PowerShell"),n.push("#"),n.push("# Installation:"),n.push(`# ${e} --completions powershell > ${e}-completion.ps1`),n.push("# then add this line to your $PROFILE (use the full path to the file):"),n.push(`# . <PATH>\\${e}-completion.ps1`),n.push("#"),n.push(""),n.push(`${r} = [hashtable]::new([System.StringComparer]::Ordinal)`),Kq(r,t,[],n,new Set),n.push(""),n.push(`Register-ArgumentCompleter -Native -CommandName ${qi(e)} -ScriptBlock {`),n.push(DZ(r)),n.push("}"),n.push(""),n.push(`###-end-${e}-completions-###`),n.join(`
268
+ `)};var Ly=(e)=>e.replace(/\\/g,"\\\\").replace(/'/g,"'\\''").replace(/:/g,"\\:"),$q=(e)=>Ly(e).replace(/]/g,"\\]"),zq=(e)=>e.replace(/[^A-Za-z0-9_.,/@%+-]/gu,"\\$&").replace(/'/g,"'\\''"),GA=(e)=>e.replace(/[^a-zA-Z0-9_]/g,"_"),MZ=(e)=>{let t=[`--${e.name}`];for(let n of e.aliases)t.push(n.length===1?`-${n}`:`--${n}`);let r=Oo(e);if(r!==void 0)t.push(`--${r}`);return t},Wq=(e)=>{switch(e._tag){case"Boolean":return"";case"Choice":return`:value:(${e.values.map(zq).join(" ")})`;case"Path":return e.pathType==="directory"?":directory:_directories":":file:_files";case"Int":return":integer:";case"Finite":return":float:";case"Date":return":date:";default:return":value:"}},FZ=(e)=>{switch(e._tag){case"Choice":return`(${e.values.map(zq).join(" ")})`;case"Path":return e.pathType==="directory"?"_directories":"_files";default:return""}},Gq=(e)=>{let t=[],r=e.description?`[${$q(e.description)}]`:"",n=e.optionalValue===!0&&e.type._tag!=="Boolean",o=n?"=-":"",i=n?`:${Wq(e.type)}`:Wq(e.type),s=e.repeatable===!0?"*":`(${MZ(e).join(" ")})`;t.push(`'${s}--${e.name}${o}${r}${i}'`);for(let d of e.aliases){let x=d.length===1?"-":"--";t.push(`'${s}${x}${d}${o}${r}${i}'`)}let c=Oo(e);if(c!==void 0){let d=e.description?`[${$q(`Disable ${e.name}`)}]`:"";t.push(`'${s}--${c}${d}'`)}return t},jq=(e)=>{let t=e.description?Ly(e.description):e.name,r=FZ(e.type);return`'${e.variadic?"*":""}:${t}:${r}'`},Qq=(e,t,r)=>{let n=[...t,e.name],o=`_${n.map(GA).join("_")}`;if(r.push(`${o}() {`),e.subcommands.length>0){r.push(" local context state state_descr line"),r.push(" typeset -A opt_args"),r.push(""),r.push(" local -a commands"),r.push(" commands=(");for(let i of e.subcommands){let s=i.description?Ly(i.description):"";r.push(` '${Ly(i.name)}:${s}'`)}r.push(" )"),r.push(""),r.push(" local -a specs"),r.push(" specs=(");for(let i of e.flags)for(let s of Gq(i))r.push(` ${s}`);if(e.arguments.length>0){r.push(" -"),r.push(" parent-arguments");for(let i of e.arguments)r.push(` ${jq(i)}`);r.push(" -"),r.push(" subcommands")}r.push(" '1:command:->command'"),r.push(" '*::arg:->args'"),r.push(" )"),r.push(""),r.push(' _arguments -C "${specs[@]}"'),r.push(""),r.push(' case "$state" in'),r.push(" command)"),r.push(" _describe -t commands 'commands' commands"),r.push(" ;;"),r.push(" args)"),r.push(' case "$words[1]" in');for(let i of e.subcommands){let s=`_${[...n,i.name].map(GA).join("_")}`;r.push(` ${i.name})`),r.push(` ${s}`),r.push(" ;;")}r.push(" esac"),r.push(" ;;"),r.push(" esac")}else{let i=[];for(let s of e.flags)i.push(...Gq(s));for(let s of e.arguments)i.push(jq(s));if(i.length>0){r.push(" local -a specs"),r.push(" specs=(");for(let s of i)r.push(` ${s}`);r.push(" )"),r.push(' _arguments "${specs[@]}"')}}r.push("}"),r.push("");for(let i of e.subcommands)Qq(i,n,r)},Hq=(e,t)=>{let r=[],n=GA(e);return r.push(`#compdef ${e}`),r.push(`###-begin-${e}-completions-###`),r.push("#"),r.push("# Static completion script for Zsh"),r.push("#"),r.push("# Installation:"),r.push(`# ${e} --completions zsh > ~/.zsh/completions/_${e}`),r.push("# then add ~/.zsh/completions to your fpath"),r.push("#"),r.push(""),Qq(t,[],r),r.push("# Handle both direct invocation and autoload"),r.push('if [[ "${zsh_eval_context[-1]}" == "loadautofunc" ]]; then'),r.push(` _${n} "$@"`),r.push("else"),r.push(` compdef _${n} ${e}`),r.push("fi"),r.push(`###-end-${e}-completions-###`),r.join(`
269
+ `)};var Vq=(e)=>NA(e),Jq=(e,t,r)=>{switch(t){case"bash":return Dq(e,r);case"zsh":return Hq(e,r);case"fish":return Fq(e,r);case"powershell":return qq(e,r)}};var O=(e)=>wy(To,e),bt=(e)=>kq(To,e),Ke=(e)=>wA(To,e);var jA=(e,t)=>Ay(To,e,t),Te=(e,t)=>vy(To,e,t);var zA=W(2,(e,t)=>wq(e,t)),_e=W(2,(e,t)=>AA(e,t));var QA=W(2,(e,t)=>RA(e,t));var k=(e)=>Mp(e),ot=TA;var Ur=W(2,(e,t)=>PA(e,t)),BZ=W(2,(e,t)=>OA(e,t));var ye=W(2,(e,t)=>Ty(e,t));var HA=(e)=>{let t=new Set,r=[];for(let n of e){if(t.has(n))continue;t.add(n),r.push(n)}return r},Zq=(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((d)=>d.name===i),s)break;if(!s)break;r.push(s),n=s}return r},VA=(e,t,r)=>{let o=Zq(e,t).flatMap((i)=>Wt(i).globalFlags);return HA([...r,...o])},KZ=(e)=>{let t=[],r=(n)=>{let o=Wt(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),HA(t)},qZ=(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=Wt(o);for(let s of i.contextConfig.flags){let c=Xt(s),d=oi(s);for(let x of c){if(r.has(x.name))continue;if(x.hidden)continue;r.add(x.name),n.push(Uy(x,d))}}}return n},Xq=(e,t)=>HA([...t,...KZ(e)]),My=(e,t,r)=>_(function*(){let n=Zq(e,t),o=n.length>0?n[n.length-1]:e,i=Wt(o).buildHelpDoc(t),s=qZ(n,i.flags),c=VA(e,t,r),d=[];for(let f of c){let g=Xt(f.flag),I=oi(f.flag);for(let w of g){if(w.hidden)continue;d.push({...Uy(w,I),required:!1})}}let x=1;for(let f=n.length-1;f>0;f--)if(Wt(n[f]).globalFlags.length>0){x=f+1;break}return{...i,inheritedFlags:s,globalFlags:d,globalFlagsScope:t.slice(0,x),commandPath:t}});var Fy=(e)=>({_tag:"Action",flag:e.flag,run:e.run}),WZ=(e)=>(t)=>{e$+=1;let r=Qt(`effect/cli/GlobalFlag/${e}/${e$}`);return Object.assign(r,{_tag:"Setting",id:e,flag:t.flag})},e$=0,GZ=Fy({flag:bt("help").pipe(zA("h"),_e("Show help information"),ot(!1)),run:be(function*(e,{builtIns:t,command:r,commandPath:n}){let o=yield*Np,i=yield*My(r,n,t);yield*o.present({_tag:"Help",reason:"Requested",commandPath:n,helpDoc:i})})}),jZ=Fy({flag:bt("version").pipe(zA("v"),_e("Show version information"),ot(!1)),run:be(function*(e,{command:t,version:r}){yield*(yield*Np).present({_tag:"Version",name:t.name,version:r})})}),JA=Fy({flag:bt("wizard").pipe(_e("Start wizard mode for a command"),ot(!1)),run:()=>et}),zZ=Fy({flag:jA("completions",[["bash","bash"],["zsh","zsh"],["fish","fish"],["powershell","powershell"],["sh","bash"],["pwsh","powershell"]]).pipe(k,QA("<bash|zsh|fish|powershell|sh|pwsh>"),_e("Print shell completion script")),run:be(function*(e,{command:t}){if(cr(e))return;let r=Vq(t);yield*Or(Jq(t.name,e.value,r))})}),Bp=WZ("log-level")({flag:jA("log-level",[["all","All"],["trace","Trace"],["debug","Debug"],["info","Info"],["warn","Warn"],["warning","Warn"],["error","Error"],["fatal","Fatal"],["none","None"]]).pipe(k,_e("Sets the minimum log level"),QA("<all|trace|debug|info|warn|warning|error|fatal|none>"))}),t$=[GZ,jZ,JA,zZ,Bp];class Ny extends pt("effect/cli/CliConfig",{defaultValue:()=>QZ}){}var QZ={builtIns:t$};var n$=xS((e)=>j(Pc(e,DA)??_y({colors:rn(e,Ey).canColor})));function i$(e){let t=e.indexOf("--");if(t===-1)return{tokens:o$(e),trailingOperands:[]};return{tokens:o$(e.slice(0,t)),trailingOperands:e.slice(t+1)}}var s$=(e)=>{if(e._tag==="Value")return e.value;if(e._tag==="LongOption")return e.raw;let t=a$.test(e.raw)?`--${e.flag}`:e.raw;return e.value===void 0?t:`${t}=${e.value}`},a$=/^-(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?$/,o$=(e)=>{let t=[];for(let r of e)if(!r.startsWith("-")||a$.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 VZ=(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]},ZA=(e,t)=>{let r=t.map((o)=>[VZ(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 ev=(e)=>Wr(e.subcommand,{onNone:()=>[],onSome:(t)=>[t.name,...ev(t.parsedInput)]}),tv=(e,t,r=[])=>_(function*(){let{tokens:n,trailingOperands:o}=e,i=[...r,t.name],s=S$(n,x$(t,i));if(s._tag==="Leaf")return{flags:s.flags,arguments:[...s.arguments,...o],subcommand:xe(),...s.errors.length>0&&{errors:s.errors}};let c={tokens:s.childTokens,trailingOperands:o},d=yield*tv(c,s.sub,i),x=[...s.errors,...d.errors??[]];return{flags:s.flags,arguments:[],subcommand:Le({name:s.sub.name,parsedInput:d}),...x.length>0&&{errors:x}}}),rv=(e,t)=>{let r=S$(e,x$(t,[]));return r._tag==="Leaf"?e:rv(r.childTokens,r.sub)},By=(e)=>{let t=0;return{peek:()=>e[t],take:()=>e[t++],rest:()=>e.slice(t)}},d$=(e)=>!iA(e.primitiveType)||e.negation===!1?void 0:e.negation??`no-${e.name}`,qp=(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=d$(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}},u$=(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},nv=(e)=>Object.fromEntries(e.map((t)=>[t.name,[]])),JZ=(e)=>{let t=nv(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}},Ky=(e)=>e._tag==="LongOption"||e._tag==="ShortOption",l$=(e)=>e._tag==="LongOption"?e.name:e.flag,Kp=(e,t)=>{let r=l$(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},c$=(e,t,r)=>new Rn({option:t.name,value:r,expected:`omit the value and use ${e.raw} by itself to set --${t.name} to false`,kind:"flag"}),YZ=(e)=>{let t=Bi(e.primitiveType);return new Rn({option:e.name,value:"",expected:t===void 0?e.typeName??ml(e.primitiveType):t.join(" | "),kind:"flag"})},p$=(e)=>e?._tag==="Value"&&(TK(e.value)||OK(e.value))?e.value:void 0,f$=(e,t,r,n=!1)=>{let o=vl(e,t,r,n);switch(o._tag){case"Value":return{_tag:"Value",value:o.value};case"Error":return{_tag:"Error",error:o.error}}},vl=(e,t,r,n=!1)=>{if(n){if(t.value!==void 0)return{_tag:"Error",error:c$(t,r,t.value),tokens:[]};let i=r.optionalValue===void 0?p$(e.peek()):void 0;if(i!==void 0){let s=e.take();return{_tag:"Error",error:c$(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(iA(r.primitiveType)){let i=p$(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:YZ(r),tokens:[]}},ZZ=(e,t)=>{let r=nv(t.params),n=[],o=[],i=By(e);for(let s=i.take();s;s=i.take()){if(!Ky(s)){n.push(s);continue}let c=Kp(s,t);if(!c){n.push(s);continue}let d=f$(i,s,c.param,c.negated);if(d._tag==="Error"){o.push(d.error);continue}if(d.value!==void 0)r[c.param.name].push(d.value)}return{flagMap:r,remainder:n,errors:o}},m$=(e)=>Wt(e).config.flags.flatMap(Xt).filter(bl),h$=(e)=>Wt(e).contextConfig.flags.flatMap(Xt).filter(bl),y$=(e,t)=>{for(let r of t){let n=Kp(e,r);if(n!==void 0)return n}return},XA=(e,t,r,n)=>{e.push(r);let o=vl(t,r,n.param,n.negated);e.push(...o.tokens)},XZ=(e,t,r,n,o)=>{let i=By(t);vl(i,e,r.param,r.negated);for(let s=i.take();s;s=i.take()){if(Ky(s)){let c=y$(s,o);if(c!==void 0)vl(i,s,c.param,c.negated);continue}if(s._tag==="Value")return n.has(s.value)}return!1},g$=(e,t,r)=>{let n=nv(r.params),o=[],i=(s,c,d)=>{let x=qp(m$(c)),f=qp(h$(c)),g=u$(c.subcommands),I=By(s),w=[],A=!0;for(let y=I.take();y;y=I.take()){if(Ky(y)){let h=y$(y,d);if(h!==void 0){XA(w,I,y,h);continue}let S=Kp(y,f);if(S!==void 0){XA(w,I,y,S);continue}let H=Kp(y,x),te=Kp(y,r);if(H!==void 0){if(te===void 0||!A||!XZ(y,I.rest(),H,g,[x,f,r])){XA(w,I,y,H);continue}}if(te!==void 0){let E=vl(I,y,te.param,te.negated);if(E._tag==="Error"){o.push(E.error);continue}if(E.value!==void 0)n[te.param.name].push(E.value);continue}w.push(y);continue}if(y._tag==="Value"&&A){let h=g.get(y.value);if(h!==void 0)return w.push(y),w.push(...i(I.rest(),h,[...d,f])),w;A=!1}w.push(y)}return w};return{flagMap:n,remainder:i(e,t,[]),errors:o}},e7=(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=d$(s);if(c!==void 0)o.push(c);for(let d of s.aliases)o.push(d)}let i=ZA(l$(e),o).map((s)=>s.length===1?`-${s}`:`--${s}`);return new ec({option:n,suggestions:i,command:r})},t7=(e)=>({flags:JZ(e.params),arguments:[],errors:[],mode:{_tag:"AwaitingFirstValue"}}),r7=(e)=>({_tag:"Leaf",flags:e.flags.snapshot(),arguments:e.arguments,errors:e.errors}),n7=(e,t,r,n)=>{let{command:o,commandPath:i,inheritedFlagRegistry:s,localFlagNames:c}=r,d=u$(o.subcommands),x=d.get(e);if(x){let g=[...i,x.name],I=n.flags.snapshot();for(let A of c){let y=I[A];if(y!==void 0&&y.length>0)n.errors.push(new ec({option:`--${A}`,suggestions:[],command:g}))}let w=ZZ(t.rest(),s);return n.flags.merge(w.flagMap),n.errors.push(...w.errors),{_tag:"Subcommand",result:{_tag:"Sub",flags:n.flags.snapshot(),sub:x,childTokens:w.remainder,errors:n.errors}}}if(!(Wt(o).config.arguments.length>0)&&d.size>0){let g=[];for(let[w,A]of d)if(!A.unlisted)g.push(w);let I=ZA(e,g);n.errors.push(new yy({subcommand:e,parent:i,suggestions:I}))}return{_tag:"Argument"}},o7=(e,t,r,n)=>{let{commandPath:o,flagRegistry:i}=r,s=Kp(e,i);if(!s){n.errors.push(e7(e,i.params,o));return}let c=f$(t,e,s.param,s.negated);if(c._tag==="Error"){n.errors.push(c.error);return}n.flags.add(s.param.name,c.value)},i7=(e,t,r,n)=>{if(n.mode._tag==="AwaitingFirstValue"){let o=n7(e,t,r,n);if(o._tag==="Subcommand")return o.result;n.mode={_tag:"CollectingArguments"}}n.arguments.push(e);return},x$=(e,t)=>{let r=m$(e),n=h$(e),o=new Set(n.map((i)=>i.name));return{command:e,commandPath:t,flagRegistry:qp(r),inheritedFlagRegistry:qp(n),localFlagNames:r.filter((i)=>!o.has(i.name)).map((i)=>i.name)}},S$=(e,t)=>{let r=By(e),n=t7(t.flagRegistry);for(let o=r.take();o;o=r.take()){if(Ky(o)){o7(o,r,t,n);continue}if(o._tag==="Value"){let i=i7(o.value,r,t,n);if(i)return i}}return r7(n)};var E$=be(function*(e,t){let r=t?.commandPath??[e.name],n=a7(e,r),o=(t?.prefix??r).map((s)=>so(s)),{colors:i}=yield*gl;return yield*qy(o,i),yield*k$(n,o,n===e?"ROOT":n.name,i),{args:o.map((s)=>s.value),displayArgs:o.map((s)=>s.displayValue)}}),a7=(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},k$=be(function*(e,t,r,n){let o=Wt(e),i=e.subcommands.flatMap((d)=>d.commands.filter((x)=>!x.unlisted)),s=i.length===0?o.config:o.contextConfig;if(s.flags.length>0){yield*Or(I$(r,"FLAGS",n));for(let d of s.flags)t.push(...yield*b$(d));if(s.arguments.length>0||i.length>0)yield*qy(t,n)}if(s.arguments.length>0){if(yield*Or(I$(r,"ARGUMENTS",n)),i.length===0)t.push(so("--"));for(let d of s.arguments)t.push(...yield*b$(d));if(i.length>0)yield*qy(t,n)}if(i.length===0)return;let c=yield*mn(mA({message:"Command",choices:i.map((d)=>({title:d.name,value:d,...d.shortDescription!==void 0?{description:d.shortDescription}:d.description!==void 0?{description:d.description}:{}}))}));if(yield*Or(),t.push(so(c.name)),c7(c))yield*qy(t,n);yield*k$(c,t,c.name,n)}),c7=(e)=>e.subcommands.some((r)=>r.commands.some((n)=>!n.unlisted))||Wt(e).config.orderedParams.length>0,b$=be(function*(e){let t=Oy(e),r=oi(e);if(r.isOptional){if(!(yield*mn(lA({message:`Set ${ov(t)}?`,initial:!1}))))return yield*Or(),[]}let n=!r.isVariadic?1:yield*mn(fA({message:`${ov(t)} count`,default:yr(r.variadicMin,()=>0),min:yr(r.variadicMin,()=>0),...T(r.variadicMax)?{max:r.variadicMax.value}:{}})),o=[];for(let s=0;s<n;s++)o.push(yield*p7(t));let i=t.kind===To?{flags:{[t.name]:o.map((s)=>s.value)},arguments:[]}:{flags:{},arguments:o.map((s)=>s.value)};if(yield*e.parse(i),yield*Or(),t.kind===Fp)return o;return o.flatMap((s)=>t.optionalValue!==void 0||s.value.startsWith("-")&&s.value.length>1?[so(`--${t.name}=${s.value}`,`--${t.name}=${s.displayValue}`)]:[so(`--${t.name}`),s])}),p7=(e)=>{let t=u7(e);switch(e.primitiveType._tag){case"Boolean":return Me(mn(lA({message:t,label:{confirm:"true",deny:"false"},placeholder:{defaultConfirm:"(T/f)",defaultDeny:"(t/F)"}})),(r)=>so(String(r)));case"Choice":{let r=Bi(e.primitiveType)??[];return Me(mn(mA({message:t,choices:r.map((n)=>({title:n,value:n}))})),so)}case"Date":return Me(mn(JK({message:t})),(r)=>so(r.toISOString()));case"Finite":return Me(mn(YK({message:t})),(r)=>so(String(r)));case"Int":return Me(mn(fA({message:t})),(r)=>so(String(r)));case"Redacted":return Me(mn(ZK({message:t})),(r)=>so(Xn(r),"<redacted>"));default:return Me(mn(XK({message:t})),so)}},so=(e,t=e)=>({value:e,displayValue:t}),d7=(e)=>e.kind===To?`--${e.name}`:e.name,u7=(e)=>ov(e),ov=(e)=>{let t=m(e.description)?.trim(),r=e.kind===To&&t!==void 0&&t.length<=32?t:l7(e.name);return e.kind===To?`${r} (${d7(e)})`:r},l7=(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(" ")},qy=(e,t)=>Or(C$("Current command",e.map((r)=>r.displayValue),t,BK)),I$=(e,t,r)=>`${Rt(r,e.toUpperCase(),Ki,Dp)} ${Rt(r,"\xB7",yl)} ${Rt(r,t,Ki,nc)}`,w$=(e,t,r,n)=>[`${Rt(n,e,Ki,Dp)} ${Rt(n,`v${t}`,nc)} ${Rt(n,"\xB7 Command wizard",Ki,nc)}`,...r===void 0||r.length===0?[]:[r],Rt(n,"Build a command interactively. Press Ctrl+C to cancel.",yl),""].join(`
270
+ `),A$=(e,t)=>C$("Command ready",e,t,Dp,by),v$=(e)=>`
271
+ ${Rt(e,"Wizard cancelled.",Sy)}`,C$=(e,t,r,n,o=nc)=>{let i=f7(t);return[Rt(r,e,Ki,o),...i.map((s)=>Rt(r,s,n)),""].join(`
272
+ `)},f7=(e)=>{let o=e.map(m7),i=[],s=" $ ";for(let c of o){let d=s===" $ "||s===" "?"":" ";if(s.length+d.length+c.length>88&&s!==" $ ")i.push(`${s} \\`),s=` ${c}`;else s+=`${d}${c}`}if(s!==" $ ")i.push(s);return i},m7=(e)=>/^[A-Za-z0-9_./:@%+=,-]+$/.test(e)?e:`'${e.replaceAll("'",`'"'"'`)}'`;var y7=(e)=>Ye(e,El),P=(e,t,r)=>{let n=LA(t??{});return kl({name:e,config:n,...ir(r)?{handle:r}:{}})};var g7=(e)=>{let t=[],r=new Map,n=(s,c)=>{t.push(c);let d=r.get(s);if(d)d.push(c);else r.set(s,[c])};for(let s of e){if(y7(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}},rt=W(2,(e,t)=>{let r=g7(t);Pq(e,r.flat);let n=Wt(e),o=new Map(r.flat.map((d)=>[d.name,Wt(d)])),i=Symbol("effect/cli/SubcommandState"),s=be(function*(d){if(cr(d.subcommand))return yield*n.parse(d);let x=o.get(d.subcommand.value.name);if(!x)return yield*n.parse(d);let f=yield*n.parseContext(d),g=yield*x.parse(d.subcommand.value.parsedInput);return{...f,[i]:{name:x.name,result:g}}}),c=be(function*(d,x){let g=d[i];if(g){let I=o.get(g.name);if(!I)return yield*new Ni({commandPath:x,errors:[]});return yield*I.handle(g.result,[...x,I.name]).pipe(ys(n.service,d))}return yield*n.handle(d,x)});return kl({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 R=W(2,(e,t)=>kl({...Wt(e),description:t}));var B=W(3,(e,t,r)=>{let n=Wt(e);return kl({...n,annotations:Bn(n.annotations,t,r)})});var x7=(e,t,r,n)=>{let o=new Set(t),i=[],s=new Set;for(let c of e){if(o.has(c))continue;let d=Xt(c.flag);for(let x of d){let f=r[x.name];if(!f||f.length===0)continue;let g=`--${x.name}`;if(s.has(g))continue;s.add(g),i.push(new ec({option:g,suggestions:[],command:n}))}}return i},S7=(e,t,r)=>_(function*(){let{builtIns:n}=yield*Ny,o=yield*Np,{commandPath:i,errors:s}=t,c=yield*My(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})}),b7=(e,t)=>_(function*(){let r=yield*n$,n=e instanceof fl?e:new fl({cause:e,userMessage:t});yield*Ih(r.formatError(n)),Object.assign(e,{[Nu]:!1})});var T$=(e,t)=>{let r=Wt(e);return be(function*(n){let{builtIns:o}=yield*Ny,{tokens:i,trailingOperands:s}=i$(n),c=Xq(e,o),d=c.flatMap((V)=>Xt(V.flag)),x=qp(d.filter(bl)),{flagMap:f,remainder:g,errors:I}=g$(i,e,x),w={flags:f,arguments:[]},A=yield*tv({tokens:g,trailingOperands:s},e),y=[e.name,...ev(A)],h=(V)=>V._tag==="ShowHelp"?V:new Ni({commandPath:y,errors:[V]}),S=Jt(h),H={builtIns:o,command:e,commandPath:y,version:t.version},te=VA(e,y,o),E=x7(c,te,f,y);if(E.length>0||I.length>0){let V=A.errors??[];return yield*new Ni({commandPath:y,errors:[...I,...E,...V]})}for(let V of te){if(V._tag!=="Action")continue;if(!Xt(V.flag).some((pe)=>{let he=f[pe.name];return he!==void 0&&he.length>0}))continue;let[,de]=yield*V.flag.parse(w).pipe(S);if(V===JA){let{colors:pe}=yield*gl;return yield*_(function*(){yield*Or(w$(e.name,t.version,e.description,pe));let he=new Set(rv(g,e)),ke=[e.name,...i.filter((Qe)=>!he.has(Qe)&&!(Qe._tag==="LongOption"&&Qe.name==="wizard")).map(s$)],Oe=yield*E$(e,{commandPath:y,prefix:ke});if(yield*Or(A$(Oe.displayArgs,pe)),yield*mn(eq({message:"Run this command?",initial:!0,active:"yes",inactive:"no"})))yield*Or(),yield*T$(e,{...t,renderErrors:!1})(Oe.args.slice(1))}).pipe(qd("QuitError",()=>Or(v$(pe))))}yield*V.run(de,H);return}if(A.errors&&A.errors.length>0)return yield*new Ni({commandPath:y,errors:A.errors});let ge=yield*r.parse(A).pipe(Jt((V)=>oA(V)?h(V):V)),le=r.handle(ge,[e.name]),z=te.includes(Bp)?(yield*Bp.flag.parse(w).pipe(S))[1]:xe();le=ys(le,Bp,z);for(let V of te){if(V._tag!=="Setting"||V===Bp)continue;let[,ne]=yield*V.flag.parse(w).pipe(S);le=ys(le,V,ne)}let re=Wr(z,{onNone:()=>Gr(),onSome:(V)=>aa(IP,V)});yield*hs(le,re)},em((n)=>oA(n)&&n._tag==="ShowHelp"?vt(n):Mt(n),(n)=>Gn(S7(e,n,t.renderErrors!==!1),oe(n))),em((n)=>{if(t.renderErrors===!1||!nd(n))return Mt(n);let o=vK(n);return o===void 0?Mt(n):vt({error:n,userMessage:o})},({error:n,userMessage:o})=>Gn(b7(n,o),oe(n))),em((n)=>$D(n)?vt(n):Mt(n),(n)=>jd))};var Cl={name:"@pubnio/cli",version:"0.3.0",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:{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 O$(e){let t,r=Xa({...e,onRuntime:(n)=>{t=n}});if(!t)throw Error("PubNio client runtime was not captured.");return{client:r,runtime:t}}class D extends Qt()("@pubnio/cli/CliOperations"){}var P$=c3(ZD({preserveEmptyStrings:!0})),$y=Wa(I3("PUBNIO_API_KEY")),R$=_(function*(){let e=yield*g3({nonInteractive:Wa(Ga("PUBNIO_NON_INTERACTIVE")),ci:Wa(Ga("CI")),opencode:Wa(Ga("OPENCODE_AGENT")),claude:Wa(Ga("CLAUDECODE"))}),t=m(e.ci);return Boolean(process.stdout.isTTY)&&m(e.nonInteractive)!=="1"&&t!=="1"&&t!=="true"&&!m(e.opencode)&&!m(e.claude)}).pipe(QP(()=>!1));var K=O("workspace").pipe(ye(me),k,_e("Workspace ID. Defaults to PUBNIO_WORKSPACE_ID or your only workspace.")),_$=se("id").pipe(ce(me)),JEe=O("name").pipe(ye(mL.fields.name)),YEe=O("default-timezone").pipe(k,_e("Default IANA time zone for new queues, e.g. America/New_York.")),Tl=bt("browser").pipe(ot(R$),_e("Open the browser automatically. Defaults to on only for an interactive terminal; pass --browser or --no-browser to override.")),iv=O("account").pipe(ye(Y),k,_e("Publishing account ID.")),U$=O("account").pipe(ye(Y),Ur(0),_e("Publish to this exact publishing account ID, or save it as a draft target. Repeat for several accounts.")),D$=O("account").pipe(ye(Hu.fields.accountId),k,_e("Publish to this existing post target account.")),ct=O("idempotency-key").pipe(ye(sn),k,_e("Reuse a key to replay this request safely. Generated when omitted.")),Ks={cursor:O("cursor").pipe(k),limit:Ke("limit").pipe(k)};class $e extends Error{}function C(e){return ls({try:e,catch:(t)=>t})}function _t(e){return ls({try:()=>(e==="-"?Bun.stdin:Bun.file(e)).json(),catch:()=>new $e("Could not read JSON input.")})}function U(e){return e.pipe(fs((t)=>We(()=>console.log(JSON.stringify(t,null,2)))))}function Wy(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 L$=p({clientId:a});var M$="/api/auth/cli";var F$=new TextDecoder,N$=new TextDecoder("utf-8",{fatal:!0});function B$(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 K$ 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 $i extends K${static code="ERR_JWT_INVALID";code="ERR_JWT_INVALID"}var E7="The input to be decoded is not correctly encoded.";function q$(e){try{return B$(typeof e=="string"?e:F$.decode(e),!0)}catch(t){throw TypeError(E7,{cause:t})}}function $$(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 sv(e){if(typeof e!="string")throw new $i("JWTs must use Compact JWS serialization, JWT must be a string");let{1:t,length:r}=e.split(".");if(r===5)throw new $i("Only JWTs using Compact JWS serialization can be decoded");if(r!==3)throw new $i("Invalid JWT");if(!t)throw new $i("JWTs must contain a payload");let n;try{n=q$(t)}catch(i){throw new $i("Failed to base64url decode the payload",{cause:i})}let o;try{o=JSON.parse(N$.decode(n))}catch(i){throw new $i("Failed to parse the decoded payload as JSON",{cause:i})}if(!$$(o))throw new $i("Invalid JWT Claims Set");return o}var yW=q2(hW(),1);import{mkdir as aX,rename as cX,rm as pX,writeFile as dX}from"fs/promises";import{homedir as uX}from"os";import{join as kv}from"path";var lX="https://api.workos.com/user_management",fX=nr("Cli.sessionPath")(function*(e){let t=yield*Wa(Ga("XDG_CONFIG_HOME")),r=kv(m(t)||kv(uX(),".config"),"pubnio"),n=new Bun.CryptoHasher("sha256").update(e).digest("hex");return{dir:r,file:kv(r,`${n}.json`)}}),wv=p({access_token:a,refresh_token:a}),Av=p({clientId:a,...wv.fields,workspaceId:u(me)}),gW=p({device_code:a,user_code:a,verification_uri:a,verification_uri_complete:a,expires_in:dr.check(ti(0)),interval:dr.check(ti(0))}),mX=p({clientId:a,device:gW,expiresAt:dr});class rg extends Error{code;status;constructor(e,t){super(`WorkOS request failed (HTTP ${t}).`);this.code=e;this.status=t}}class Gi extends Ko("AuthError"){}var hX="Sign in with `pnio auth login`.",vv=nr("Cli.workosRequest")(function*(e,t,r,n){let o=yield*C((c)=>e(`${lX}/${t}`,{method:"POST",body:new URLSearchParams(r),redirect:"error",signal:AbortSignal.any([c,AbortSignal.timeout(1e4)])})),i=yield*C(()=>o.json()).pipe(QP(()=>null));if(o.ok)return yield*Kr(n)(i);let s=i&&typeof i==="object"&&"error"in i&&typeof i.error==="string"?i.error:"unknown";return yield*oe(new rg(s,o.status))}),xW=(e)=>`${e}.device.json`,jp=(e)=>C(()=>pX(e,{force:!0})),SW=nr("Cli.requestDevice")(function*(e,t=fetch){let r=yield*vv(t,"authorize/device",{client_id:e},gW),{url:n,completeUrl:o}=yield*gr({try:()=>({url:new URL(r.verification_uri),completeUrl:new URL(r.verification_uri_complete)}),catch:(i)=>i});if(n.protocol!=="https:"||o.origin!==n.origin)return yield*new Gi({message:"WorkOS returned an invalid sign-in URL."});return{device:r,url:n.href,completeUrl:o.href}}),bW=nr("Cli.startLogin")(function*(e){let t=yield*Tv(e,"GET"),r=yield*C(()=>t.json()),{clientId:n}=yield*Kr(L$)(r),{device:o,url:i,completeUrl:s}=yield*SW(n),c=(yield*ds)+o.expires_in*1000;return yield*Dl(e,(d)=>og(xW(d),{clientId:n,device:o,expiresAt:c})),{url:i,completeUrl:s,userCode:o.user_code,expiresAt:new Date(c).toISOString()}}),IW=nr("Cli.awaitDevice")(function*(e,t,r,n=fetch){let i=(yield*ds)+Math.min(t.expires_in*1000,r),s=t.interval*1000;while((yield*ds)+s<i){yield*$d(s);let c=yield*WP(vv(n,"authenticate",{client_id:e,grant_type:"urn:ietf:params:oauth:grant-type:device_code",device_code:t.device_code},wv));if(ca(c))return{clientId:e,...c.success};let d=c.failure;if(d instanceof rg){if(d.code==="authorization_pending")continue;if(d.code==="slow_down"||d.status===429||d.status>=500){s+=5000;continue}if(d.code==="expired_token")break;if(d.code==="access_denied")return yield*new Gi({message:"Sign-in was declined.",cause:d})}if(d instanceof Error&&d.name==="TimeoutError"){s*=2;continue}return yield*oe(d)}return yield*new Gi({message:"Sign-in is still pending. Run `pnio auth complete` to keep waiting, or `pnio auth login` to start over."})}),Fke=nr("Cli.deviceLogin")(function*(e,t,r=fetch){let{device:n,url:o,completeUrl:i}=yield*SW(e,r);return t({code:n.user_code,url:o,openUrl:i}),yield*IW(e,n,n.expires_in*1000,r)}),Cv=nr("Cli.completeLogin")(function*(e,{timeoutMs:t=600000}={}){return yield*Dl(e,(r)=>_(function*(){let n=xW(r),o=yield*ng(n,mX);if(!o)return yield*new Gi({message:"No sign-in is pending. Run `pnio auth login`."});if(o.expiresAt<=(yield*ds))return yield*jp(n),yield*new Gi({message:"Sign-in expired. Run `pnio auth login` again."});let i=o.expiresAt-(yield*ds),s=yield*IW(o.clientId,o.device,Math.min(t,i)).pipe(ki((c)=>jp(n).pipe(Gn(oe(c)))));return yield*Tv(e,"POST",s.access_token),yield*og(r,s),yield*jp(n),s.access_token}))}),ng=nr("Cli.readLocalJson")(function*(e,t){let r=Bun.file(e);if(!(yield*C(()=>r.exists())))return;let n=yield*C(()=>r.json());return yield*Kr(t)(n)});function EW(e,t,r){return JP(e,(n)=>ba(t(n)),r).pipe(Ae((n)=>Dd(n)?Wn(n.cause):j(n.value)))}var og=nr("Cli.writeLocalJson")(function*(e,t){yield*EW(We(()=>`${e}.${crypto.randomUUID()}.tmp`),(r)=>_(function*(){yield*C(()=>dX(r,JSON.stringify(t),{mode:384,flag:"wx"})),yield*C(()=>cX(r,e))}).pipe(zd),jp)}),Dl=nr("Cli.withSessionLock")(function*(e,t){let{dir:r,file:n}=yield*fX(e);return yield*C(()=>aX(r,{recursive:!0,mode:448})),yield*EW(C(()=>yW.default.lock(n,{realpath:!1,retries:{retries:20,minTimeout:100,maxTimeout:1000}})),()=>t(n),(o)=>C(()=>o()))}),Tv=nr("Cli.authRequest")(function*(e,t,r){let n=yield*C((o)=>fetch(`${e}${M$}`,{method:t,headers:r?{Authorization:`Bearer ${r}`}:{},redirect:"error",signal:AbortSignal.any([o,AbortSignal.timeout(15000)])}));if(!n.ok)return yield*new Gi({message:`PubNio sign-in request failed (HTTP ${n.status}).`});return n}),kW=nr("Cli.refresh")(function*(e,t){let{exp:r}=yield*gr({try:()=>sv(t.access_token),catch:(o)=>o});if(r&&r*1000>(yield*ds)+30000)return t.access_token;let n=yield*WP(vv(fetch,"authenticate",{client_id:t.clientId,grant_type:"refresh_token",refresh_token:t.refresh_token},wv));if(Ht(n)){let o=n.failure;if(!(o instanceof rg&&o.code==="invalid_grant"))return yield*oe(o);yield*jp(e);return}return yield*og(e,{...t,...n.success}),n.success.access_token}),wW=(e)=>Dl(e,(t)=>_(function*(){let r=yield*ng(t,Av),n=r&&(yield*kW(t,r));if(!n||!r)return yield*new Gi({message:hX});return{token:n,workspaceId:r.workspaceId}})),AW=(e,t,r)=>Dl(e,(n)=>_(function*(){let o=yield*ng(n,Av);if(o?.access_token!==t)return yield*new Gi({message:"The CLI session changed. Run the workspace command again."});yield*og(n,{...o,workspaceId:r})})),vW=(e)=>Dl(e,(t)=>_(function*(){let r=yield*ng(t,Av),n=r&&(yield*kW(t,r));if(n)yield*Tv(e,"DELETE",n);yield*jp(t)}));var ji=_(function*(){let e=yield*Ga("PUBNIO_BASE_URL").pipe(tL("https://pubnio.com")),t=URL.parse(e);if(!t||t.username||t.password||t.pathname!=="/"||t.search||t.hash||t.protocol!=="https:"&&!(t.protocol==="http:"&&["localhost","127.0.0.1","[::1]"].includes(t.hostname)))return yield*oe(new $e("PUBNIO_BASE_URL must be an HTTPS origin or a local HTTP origin."));return t.origin}),CW=nr("Cli.credentials")(function*(e,t){let r=t==="default"?yield*$y:xe();if(T(r)){let n=Xn(r.value);if(!UI.test(n))return yield*oe(new $e("PUBNIO_API_KEY is not a valid PubNio API key."));return{apiKey:n,session:void 0}}return{apiKey:void 0,session:yield*wW(e)}}),Po=nr("Cli.client")(function*(e,t="default"){let r=e??(yield*ji),{apiKey:n,session:o}=yield*CW(r,t),i=Xa({baseUrl:r,clientName:"cli",clientVersion:Cl.version,...n!==void 0?{apiKey:n}:{accessToken:o?.token}});return{...i,selectedWorkspaceId:o?.workspaceId,useWorkspace:nr("Cli.useWorkspace")(function*(s){let c=yield*C(()=>i.workspaces.get(s));if(o)yield*AW(r,o.token,c.id);return c})}}),Z=nr("Cli.rawClient")(function*(e,t="default"){let r=e??(yield*ji),{apiKey:n,session:o}=yield*CW(r,t);return{...O$({baseUrl:r,clientName:"cli",clientVersion:Cl.version,...n!==void 0?{apiKey:n}:{accessToken:o?.token}}),selectedWorkspaceId:o?.workspaceId}}),ee=nr("Cli.workspaceId")(function*(e,t,r){let n=t??m(yield*Wa(Ga("PUBNIO_WORKSPACE_ID")))??e.selectedWorkspaceId??r;if(n!==void 0){let i=ws(me)(n);if(i._tag==="None")return yield*oe(new $e("Expected a workspace UUID."));return i.value}let{workspaces:o}=yield*C(()=>e.workspaces.list());if(o.length!==1)return yield*oe(new $e("Select a workspace with `pnio workspaces use <id>` or pass --workspace. Run `pnio workspaces list` to see your workspaces."));return o[0].id}),je=nr("Cli.workspaceClient")(function*(e,{origin:t,auth:r}={}){let n=yield*Po(t,r);return n.workspace(yield*ee(n,e))});var TW=[P("list-accounts",{workspace:K,state:Te("state",["available","selected"]).pipe(k),cursor:O("cursor").pipe(k),limit:Ke("limit").pipe(k)},(e)=>U(_(function*(){let t=yield*Z(),r=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,tw({client:t.runtime.client,query:{workspaceId:r,...T(e.state)?{state:m(e.state)}:{},...T(e.cursor)?{cursor:m(e.cursor)}:{},...T(e.limit)?{limit:String(m(e.limit))}:{}},...t.runtime.transport()})))}))).pipe(B(D,["ads.listAccounts"]),R("List available and selected ad accounts")),P("connect-account",{workspaceId:O("workspace-id").pipe(ye(a.check(N()))),provider:Te("provider",["meta_ads","google_ads","reddit_ads","pinterest_ads","tiktok_ads","linkedin_ads","snapchat_ads","amazon_ads","openai_ads"]),accountId:O("account-id").pipe(ye(a.check(N()))).pipe(k)},(e)=>U(_(function*(){let t=yield*Z(void 0,"human");return yield*C(()=>t.runtime.decode(J,rw({client:t.runtime.client,body:{workspaceId:e.workspaceId,provider:e.provider,...T(e.accountId)?{accountId:m(e.accountId)}:{}},...t.runtime.transport()})))}))).pipe(B(D,["ads.connectAccount"]),R("Start an ad account OAuth connection")),P("connect-api-key-account",{workspaceId:O("workspace-id").pipe(ye(a.check(N()))),provider:Te("provider",["openai_ads"]),apiKey:O("api-key"),accountId:O("account-id").pipe(ye(a.check(N()))).pipe(k),profileId:O("profile-id").pipe(ye(a.check(N()))).pipe(k)},(e)=>U(_(function*(){let t=yield*Z(void 0,"human");return yield*C(()=>t.runtime.decode(J,nw({client:t.runtime.client,body:{workspaceId:e.workspaceId,provider:e.provider,apiKey:e.apiKey,...T(e.accountId)?{accountId:m(e.accountId)}:{},...T(e.profileId)?{profileId:m(e.profileId)}:{}},...t.runtime.transport()})))}))).pipe(B(D,["ads.connectApiKeyAccount"]),R("Connect an ad account with an API key")),P("disconnect-account",{workspace:K,accountId:se("account-id").pipe(ce(a.check(N())))},(e)=>U(_(function*(){let t=yield*Z(void 0,"human"),r=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,dw({client:t.runtime.client,path:{accountId:e.accountId},query:{workspaceId:r},...t.runtime.transport()})))}))).pipe(B(D,["ads.disconnectAccount"]),R("Stop syncing an ad account")),P("select-account",{workspace:K,accountId:se("account-id").pipe(ce(a.check(N())))},(e)=>U(_(function*(){let t=yield*Z(void 0,"human"),r=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,pw({client:t.runtime.client,path:{accountId:e.accountId},query:{workspaceId:r},...t.runtime.transport()})))}))).pipe(B(D,["ads.selectAccount"]),R("Select a discovered ad account")),P("list-campaigns",{workspace:K,accountId:se("account-id").pipe(ce(a.check(N()))),provider:Te("provider",["meta_ads","google_ads","reddit_ads","pinterest_ads","tiktok_ads","linkedin_ads","snapchat_ads","amazon_ads","openai_ads"]).pipe(k),status:Te("status",["draft","paused","activating","active","pending_review","rejected","completed","archived","unknown"]).pipe(k),managed:Te("managed",["provider","pubnio"]).pipe(k),cursor:O("cursor").pipe(k),limit:Ke("limit").pipe(k)},(e)=>U(_(function*(){let t=yield*Z(),r=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,uw({client:t.runtime.client,path:{accountId:e.accountId},query:{workspaceId:r,...T(e.provider)?{provider:m(e.provider)}:{},...T(e.status)?{status:m(e.status)}:{},...T(e.managed)?{managed:m(e.managed)}:{},...T(e.cursor)?{cursor:m(e.cursor)}:{},...T(e.limit)?{limit:String(m(e.limit))}:{}},...t.runtime.transport()})))}))).pipe(B(D,["ads.listCampaigns"]),R("List one account's campaigns newest first")),P("list-workspace-campaigns",{workspace:K,accountId:O("account-id").pipe(ye(a.check(N()))).pipe(k),provider:Te("provider",["meta_ads","google_ads","reddit_ads","pinterest_ads","tiktok_ads","linkedin_ads","snapchat_ads","amazon_ads","openai_ads"]).pipe(k),status:Te("status",["draft","paused","activating","active","pending_review","rejected","completed","archived","unknown"]).pipe(k),managed:Te("managed",["provider","pubnio"]).pipe(k),cursor:O("cursor").pipe(k),limit:Ke("limit").pipe(k)},(e)=>U(_(function*(){let t=yield*Z(),r=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,iw({client:t.runtime.client,query:{workspaceId:r,...T(e.accountId)?{accountId:m(e.accountId)}:{},...T(e.provider)?{provider:m(e.provider)}:{},...T(e.status)?{status:m(e.status)}:{},...T(e.managed)?{managed:m(e.managed)}:{},...T(e.cursor)?{cursor:m(e.cursor)}:{},...T(e.limit)?{limit:String(m(e.limit))}:{}},...t.runtime.transport()})))}))).pipe(B(D,["ads.listWorkspaceCampaigns"]),R("List campaigns across selected ad accounts")),P("get-tree",{workspace:K,accountId:O("account-id").pipe(ye(a.check(N()))).pipe(k),campaignId:O("campaign-id").pipe(ye(a.check(N()))).pipe(k),cursor:O("cursor").pipe(k),limit:Ke("limit").pipe(k)},(e)=>U(_(function*(){let t=yield*Z(),r=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,lw({client:t.runtime.client,query:{workspaceId:r,...T(e.accountId)?{accountId:m(e.accountId)}:{},...T(e.campaignId)?{campaignId:m(e.campaignId)}:{},...T(e.cursor)?{cursor:m(e.cursor)}:{},...T(e.limit)?{limit:String(m(e.limit))}:{}},...t.runtime.transport()})))}))).pipe(B(D,["ads.getTree"]),R("Read a campaign, ad group, ad, and creative tree")),P("list-ads",{workspace:K,accountId:O("account-id").pipe(ye(a.check(N()))).pipe(k),campaignId:O("campaign-id").pipe(ye(a.check(N()))).pipe(k),adGroupId:O("ad-group-id").pipe(ye(a.check(N()))).pipe(k),provider:Te("provider",["meta_ads","google_ads","reddit_ads","pinterest_ads","tiktok_ads","linkedin_ads","snapchat_ads","amazon_ads","openai_ads"]).pipe(k),status:Te("status",["draft","paused","activating","active","pending_review","rejected","completed","archived","unknown"]).pipe(k),from:O("from").pipe(k),to:O("to").pipe(k),cursor:O("cursor").pipe(k),limit:Ke("limit").pipe(k)},(e)=>U(_(function*(){let t=yield*Z(),r=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,fw({client:t.runtime.client,query:{workspaceId:r,...T(e.accountId)?{accountId:m(e.accountId)}:{},...T(e.campaignId)?{campaignId:m(e.campaignId)}:{},...T(e.adGroupId)?{adGroupId:m(e.adGroupId)}:{},...T(e.provider)?{provider:m(e.provider)}:{},...T(e.status)?{status:m(e.status)}:{},...T(e.from)?{from:m(e.from)}:{},...T(e.to)?{to:m(e.to)}:{},...T(e.cursor)?{cursor:m(e.cursor)}:{},...T(e.limit)?{limit:String(m(e.limit))}:{}},...t.runtime.transport()})))}))).pipe(B(D,["ads.listAds"]),R("List ads with a performance summary")),P("list-ad-groups",{workspace:K,accountId:O("account-id").pipe(ye(a.check(N()))).pipe(k),campaignId:O("campaign-id").pipe(ye(a.check(N()))).pipe(k),provider:Te("provider",["meta_ads","google_ads","reddit_ads","pinterest_ads","tiktok_ads","linkedin_ads","snapchat_ads","amazon_ads","openai_ads"]).pipe(k),status:Te("status",["draft","paused","activating","active","pending_review","rejected","completed","archived","unknown"]).pipe(k),from:O("from").pipe(k),to:O("to").pipe(k),cursor:O("cursor").pipe(k),limit:Ke("limit").pipe(k)},(e)=>U(_(function*(){let t=yield*Z(),r=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,mw({client:t.runtime.client,query:{workspaceId:r,...T(e.accountId)?{accountId:m(e.accountId)}:{},...T(e.campaignId)?{campaignId:m(e.campaignId)}:{},...T(e.provider)?{provider:m(e.provider)}:{},...T(e.status)?{status:m(e.status)}:{},...T(e.from)?{from:m(e.from)}:{},...T(e.to)?{to:m(e.to)}:{},...T(e.cursor)?{cursor:m(e.cursor)}:{},...T(e.limit)?{limit:String(m(e.limit))}:{}},...t.runtime.transport()})))}))).pipe(B(D,["ads.listAdGroups"]),R("List ad groups with a performance summary")),P("get-ad",{workspace:K,adId:se("ad-id").pipe(ce(a.check(N())))},(e)=>U(_(function*(){let t=yield*Z(),r=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,hw({client:t.runtime.client,path:{adId:e.adId},query:{workspaceId:r},...t.runtime.transport()})))}))).pipe(B(D,["ads.getAd"]),R("Read one ad with its creative and metrics")),P("list-creatives",{workspace:K,accountId:O("account-id").pipe(ye(a.check(N()))).pipe(k),adId:O("ad-id").pipe(ye(a.check(N()))).pipe(k),cursor:O("cursor").pipe(k),limit:Ke("limit").pipe(k)},(e)=>U(_(function*(){let t=yield*Z(),r=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,yw({client:t.runtime.client,query:{workspaceId:r,...T(e.accountId)?{accountId:m(e.accountId)}:{},...T(e.adId)?{adId:m(e.adId)}:{},...T(e.cursor)?{cursor:m(e.cursor)}:{},...T(e.limit)?{limit:String(m(e.limit))}:{}},...t.runtime.transport()})))}))).pipe(B(D,["ads.listCreatives"]),R("List ad creatives")),P("get-creative",{workspace:K,creativeId:se("creative-id").pipe(ce(a.check(N())))},(e)=>U(_(function*(){let t=yield*Z(),r=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,xw({client:t.runtime.client,path:{creativeId:e.creativeId},query:{workspaceId:r},...t.runtime.transport()})))}))).pipe(B(D,["ads.getCreative"]),R("Read one ad creative")),P("list-insights",{workspace:K,accountId:se("account-id").pipe(ce(a.check(N()))),campaignId:O("campaign-id").pipe(ye(a.check(N()))).pipe(k),adGroupId:O("ad-group-id").pipe(ye(a.check(N()))).pipe(k),adId:O("ad-id").pipe(ye(a.check(N()))).pipe(k),from:O("from").pipe(k),to:O("to").pipe(k),level:Te("level",["campaign","ad_group","ad"]).pipe(k),metrics:O("metrics").pipe(Ur(0)),cursor:O("cursor").pipe(k),limit:Ke("limit").pipe(k)},(e)=>U(_(function*(){let t=yield*Z(),r=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,bw({client:t.runtime.client,path:{accountId:e.accountId},query:{workspaceId:r,...T(e.campaignId)?{campaignId:m(e.campaignId)}:{},...T(e.adGroupId)?{adGroupId:m(e.adGroupId)}:{},...T(e.adId)?{adId:m(e.adId)}:{},...T(e.from)?{from:m(e.from)}:{},...T(e.to)?{to:m(e.to)}:{},...T(e.level)?{level:m(e.level)}:{},...e.metrics.length?{metrics:[...e.metrics]}:{},...T(e.cursor)?{cursor:m(e.cursor)}:{},...T(e.limit)?{limit:String(m(e.limit))}:{}},...t.runtime.transport()})))}))).pipe(B(D,["ads.listInsights"]),R("Read one ad account's daily insights")),P("list-workspace-insights",{workspace:K,accountId:O("account-id").pipe(ye(a.check(N()))).pipe(k),campaignId:O("campaign-id").pipe(ye(a.check(N()))).pipe(k),adGroupId:O("ad-group-id").pipe(ye(a.check(N()))).pipe(k),adId:O("ad-id").pipe(ye(a.check(N()))).pipe(k),from:O("from").pipe(k),to:O("to").pipe(k),level:Te("level",["campaign","ad_group","ad"]).pipe(k),metrics:O("metrics").pipe(Ur(0)),cursor:O("cursor").pipe(k),limit:Ke("limit").pipe(k)},(e)=>U(_(function*(){let t=yield*Z(),r=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,Sw({client:t.runtime.client,query:{workspaceId:r,...T(e.accountId)?{accountId:m(e.accountId)}:{},...T(e.campaignId)?{campaignId:m(e.campaignId)}:{},...T(e.adGroupId)?{adGroupId:m(e.adGroupId)}:{},...T(e.adId)?{adId:m(e.adId)}:{},...T(e.from)?{from:m(e.from)}:{},...T(e.to)?{to:m(e.to)}:{},...T(e.level)?{level:m(e.level)}:{},...e.metrics.length?{metrics:[...e.metrics]}:{},...T(e.cursor)?{cursor:m(e.cursor)}:{},...T(e.limit)?{limit:String(m(e.limit))}:{}},...t.runtime.transport()})))}))).pipe(B(D,["ads.listWorkspaceInsights"]),R("Read daily insights across selected ad accounts")),P("refresh-insights",{workspace:K,accountId:se("account-id").pipe(ce(a.check(N())))},(e)=>U(_(function*(){let t=yield*Z(),r=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,Iw({client:t.runtime.client,path:{accountId:e.accountId},query:{workspaceId:r},...t.runtime.transport()})))}))).pipe(B(D,["ads.refreshInsights"]),R("Queue an ad insight refresh")),P("activate-campaign",{workspace:K,accountId:se("account-id").pipe(ce(a.check(N()))),campaignId:se("campaign-id").pipe(ce(a.check(N()))),expectedRevision:Ke("expected-revision"),confirmation:Te("confirmation",["activate_spend"]),idempotencyKey:ct},(e)=>U(_(function*(){let t=yield*Z(void 0,"human"),r=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,Tw({client:t.runtime.client,path:{accountId:e.accountId,campaignId:e.campaignId},query:{workspaceId:r},body:{expectedRevision:e.expectedRevision,confirmation:e.confirmation},headers:{"idempotency-key":m(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()})))}))).pipe(B(D,["ads.activateCampaign"]),R("Activate one paused boost campaign")),P("pause-campaign",{workspace:K,accountId:se("account-id").pipe(ce(a.check(N()))),campaignId:se("campaign-id").pipe(ce(a.check(N()))),expectedRevision:Ke("expected-revision"),idempotencyKey:ct},(e)=>U(_(function*(){let t=yield*Z(),r=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,Ow({client:t.runtime.client,path:{accountId:e.accountId,campaignId:e.campaignId},query:{workspaceId:r},body:{expectedRevision:e.expectedRevision},headers:{"idempotency-key":m(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()})))}))).pipe(B(D,["ads.pauseCampaign"]),R("Pause one campaign")),P("archive-campaign",{workspace:K,accountId:se("account-id").pipe(ce(a.check(N()))),campaignId:se("campaign-id").pipe(ce(a.check(N()))),expectedRevision:Ke("expected-revision"),idempotencyKey:ct},(e)=>U(_(function*(){let t=yield*Z(),r=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,Pw({client:t.runtime.client,path:{accountId:e.accountId,campaignId:e.campaignId},query:{workspaceId:r},body:{expectedRevision:e.expectedRevision},headers:{"idempotency-key":m(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()})))}))).pipe(B(D,["ads.archiveCampaign"]),R("Archive one campaign")),P("duplicate-campaign",{workspace:K,accountId:se("account-id").pipe(ce(a.check(N()))),campaignId:se("campaign-id").pipe(ce(a.check(N()))),name:O("name").pipe(k),idempotencyKey:ct},(e)=>U(_(function*(){let t=yield*Z(),r=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,Rw({client:t.runtime.client,path:{accountId:e.accountId,campaignId:e.campaignId},query:{workspaceId:r},body:{...T(e.name)?{name:m(e.name)}:{}},headers:{"idempotency-key":m(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()})))}))).pipe(B(D,["ads.duplicateCampaign"]),R("Duplicate a campaign tree as paused")),P("create-ad-group",{workspace:K,accountId:se("account-id").pipe(ce(a.check(N()))),campaignId:se("campaign-id").pipe(ce(a.check(N()))),name:O("name"),idempotencyKey:ct,file:O("file").pipe(k,_e("Read the body JSON from a file or stdin with -."))},(e)=>U(_(function*(){let t=yield*Z(),r=m(e.file),n=r===void 0?{name:e.name}:yield*_t(r),o=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,Lw({client:t.runtime.client,path:{accountId:e.accountId,campaignId:e.campaignId},query:{workspaceId:o},body:n,headers:{"idempotency-key":m(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()})))}))).pipe(B(D,["ads.createAdGroup"]),R("Create a paused ad group under a campaign")),P("create-creative",{workspace:K,accountId:se("account-id").pipe(ce(a.check(N()))),actorAccountId:O("actor-account-id").pipe(ye(a.check(N()))),mediaId:O("media-id").pipe(ye(a.check(N()))),headline:O("headline").pipe(k),body:O("body").pipe(k),callToAction:O("call-to-action").pipe(k),destinationUrl:O("destination-url"),idempotencyKey:ct,file:O("file").pipe(k,_e("Read the body JSON from a file or stdin with -."))},(e)=>U(_(function*(){let t=yield*Z(),r=m(e.file),n=r===void 0?{actorAccountId:e.actorAccountId,mediaId:e.mediaId,...T(e.headline)?{headline:m(e.headline)}:{},...T(e.body)?{body:m(e.body)}:{},...T(e.callToAction)?{callToAction:m(e.callToAction)}:{},destinationUrl:e.destinationUrl}:yield*_t(r),o=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,gw({client:t.runtime.client,path:{accountId:e.accountId},query:{workspaceId:o},body:n,headers:{"idempotency-key":m(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()})))}))).pipe(B(D,["ads.createCreative"]),R("Create a paused provider creative")),P("set-campaign-budget",{workspace:K,accountId:se("account-id").pipe(ce(a.check(N()))),campaignId:se("campaign-id").pipe(ce(a.check(N()))),expectedRevision:Ke("expected-revision"),idempotencyKey:ct,file:O("file").pipe(k,_e("Read the body JSON from a file or stdin with -."))},(e)=>U(_(function*(){let t=yield*Z(void 0,"human"),r=m(e.file),n=r===void 0?{expectedRevision:e.expectedRevision}:yield*_t(r),o=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,_w({client:t.runtime.client,path:{accountId:e.accountId,campaignId:e.campaignId},query:{workspaceId:o},body:n,headers:{"idempotency-key":m(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()})))}))).pipe(B(D,["ads.setCampaignBudget"]),R("Update a campaign budget")),P("set-ad-group-budget",{workspace:K,accountId:se("account-id").pipe(ce(a.check(N()))),adGroupId:se("ad-group-id").pipe(ce(a.check(N()))),expectedRevision:Ke("expected-revision"),idempotencyKey:ct,file:O("file").pipe(k,_e("Read the body JSON from a file or stdin with -."))},(e)=>U(_(function*(){let t=yield*Z(void 0,"human"),r=m(e.file),n=r===void 0?{expectedRevision:e.expectedRevision}:yield*_t(r),o=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,Uw({client:t.runtime.client,path:{accountId:e.accountId,adGroupId:e.adGroupId},query:{workspaceId:o},body:n,headers:{"idempotency-key":m(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()})))}))).pipe(B(D,["ads.setAdGroupBudget"]),R("Update an ad group budget")),P("set-ad-group-status",{workspace:K,accountId:se("account-id").pipe(ce(a.check(N()))),adGroupId:se("ad-group-id").pipe(ce(a.check(N()))),status:Te("status",["active","paused","archived"]),expectedRevision:Ke("expected-revision"),idempotencyKey:ct},(e)=>U(_(function*(){let t=yield*Z(),r=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,Dw({client:t.runtime.client,path:{accountId:e.accountId,adGroupId:e.adGroupId},query:{workspaceId:r},body:{status:e.status,expectedRevision:e.expectedRevision},headers:{"idempotency-key":m(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()})))}))).pipe(B(D,["ads.setAdGroupStatus"]),R("Pause, resume, or archive an ad group")),P("set-ad-status",{workspace:K,accountId:se("account-id").pipe(ce(a.check(N()))),adId:se("ad-id").pipe(ce(a.check(N()))),status:Te("status",["active","paused","archived"]),expectedRevision:Ke("expected-revision"),idempotencyKey:ct},(e)=>U(_(function*(){let t=yield*Z(),r=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,Fw({client:t.runtime.client,path:{accountId:e.accountId,adId:e.adId},query:{workspaceId:r},body:{status:e.status,expectedRevision:e.expectedRevision},headers:{"idempotency-key":m(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()})))}))).pipe(B(D,["ads.setAdStatus"]),R("Pause, resume, or archive an ad")),P("attach-ad",{workspace:K,accountId:se("account-id").pipe(ce(a.check(N()))),adGroupId:se("ad-group-id").pipe(ce(a.check(N()))),name:O("name"),creativeId:O("creative-id").pipe(ye(a.check(N()))).pipe(k),idempotencyKey:ct,file:O("file").pipe(k,_e("Read the body JSON from a file or stdin with -."))},(e)=>U(_(function*(){let t=yield*Z(),r=m(e.file),n=r===void 0?{name:e.name,...T(e.creativeId)?{creativeId:m(e.creativeId)}:{}}:yield*_t(r),o=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,Mw({client:t.runtime.client,path:{accountId:e.accountId,adGroupId:e.adGroupId},query:{workspaceId:o},body:n,headers:{"idempotency-key":m(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()})))}))).pipe(B(D,["ads.attachAd"]),R("Attach a paused ad to an existing ad group")),P("create-boost",{workspace:K,accountId:se("account-id").pipe(ce(a.check(N()))),postId:O("post-id").pipe(ye(a.check(N()))),postTargetId:O("post-target-id").pipe(ye(a.check(N()))).pipe(k),actorAccountId:O("actor-account-id").pipe(ye(a.check(N()))).pipe(k),idempotencyKey:ct,file:O("file").pipe(k,_e("Read the body JSON from a file or stdin with -."))},(e)=>U(_(function*(){let t=yield*Z(),r=m(e.file),n=r===void 0?{postId:e.postId,...T(e.postTargetId)?{postTargetId:m(e.postTargetId)}:{},...T(e.actorAccountId)?{actorAccountId:m(e.actorAccountId)}:{}}:yield*_t(r),o=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,Cw({client:t.runtime.client,path:{accountId:e.accountId},query:{workspaceId:o},body:n,headers:{"idempotency-key":m(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()})))}))).pipe(B(D,["ads.createBoost"]),R("Create a paused Facebook Page post boost")),P("validate-boost",{workspace:K,accountId:se("account-id").pipe(ce(a.check(N()))),postId:O("post-id").pipe(ye(a.check(N()))),postTargetId:O("post-target-id").pipe(ye(a.check(N()))).pipe(k),actorAccountId:O("actor-account-id").pipe(ye(a.check(N()))).pipe(k),file:O("file").pipe(k,_e("Read the body JSON from a file or stdin with -."))},(e)=>U(_(function*(){let t=yield*Z(),r=m(e.file),n=r===void 0?{postId:e.postId,...T(e.postTargetId)?{postTargetId:m(e.postTargetId)}:{},...T(e.actorAccountId)?{actorAccountId:m(e.actorAccountId)}:{}}:yield*_t(r),o=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,vw({client:t.runtime.client,path:{accountId:e.accountId},query:{workspaceId:o},body:n,...t.runtime.transport()})))}))).pipe(B(D,["ads.validateBoost"]),R("Validate a Facebook Page post boost")),P("validate-campaign-plan",{workspace:K,name:O("name"),objective:Te("objective",["awareness","traffic","engagement","leads","sales","app_promotion","video_views","reach","conversions","unknown"]),file:O("file").pipe(k,_e("Read the body JSON from a file or stdin with -."))},(e)=>U(_(function*(){let t=yield*Z(),r=m(e.file),n=r===void 0?{name:e.name,objective:e.objective}:yield*_t(r),o=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,ow({client:t.runtime.client,query:{workspaceId:o},body:n,...t.runtime.transport()})))}))).pipe(B(D,["ads.validateCampaignPlan"]),R("Validate a unified campaign plan")),P("create-campaign-plan",{workspace:K,name:O("name"),objective:Te("objective",["awareness","traffic","engagement","leads","sales","app_promotion","video_views","reach","conversions","unknown"]),idempotencyKey:ct,file:O("file").pipe(k,_e("Read the body JSON from a file or stdin with -."))},(e)=>U(_(function*(){let t=yield*Z(),r=m(e.file),n=r===void 0?{name:e.name,objective:e.objective}:yield*_t(r),o=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,sw({client:t.runtime.client,query:{workspaceId:o},body:n,headers:{"idempotency-key":m(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()})))}))).pipe(B(D,["ads.createCampaignPlan"]),R("Create a paused campaign plan")),P("get-campaign-plan",{workspace:K,planId:se("plan-id").pipe(ce(a.check(N())))},(e)=>U(_(function*(){let t=yield*Z(),r=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,cw({client:t.runtime.client,path:{planId:e.planId},query:{workspaceId:r},...t.runtime.transport()})))}))).pipe(B(D,["ads.getCampaignPlan"]),R("Read a campaign plan and its target operations")),P("list-campaign-plans",{workspace:K,status:Te("status",["queued","creating","partial","succeeded","failed","unresolved"]).pipe(k),cursor:O("cursor").pipe(k),limit:Ke("limit").pipe(k)},(e)=>U(_(function*(){let t=yield*Z(),r=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,aw({client:t.runtime.client,query:{workspaceId:r,...T(e.status)?{status:m(e.status)}:{},...T(e.cursor)?{cursor:m(e.cursor)}:{},...T(e.limit)?{limit:String(m(e.limit))}:{}},...t.runtime.transport()})))}))).pipe(B(D,["ads.listCampaignPlans"]),R("List campaign plans")),P("get-operation",{workspace:K,accountId:se("account-id").pipe(ce(a.check(N()))),operationId:se("operation-id").pipe(ce(a.check(N())))},(e)=>U(_(function*(){let t=yield*Z(),r=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,Aw({client:t.runtime.client,path:{accountId:e.accountId,operationId:e.operationId},query:{workspaceId:r},...t.runtime.transport()})))}))).pipe(B(D,["ads.getOperation"]),R("Read one ad operation")),P("get-spend-policy",{workspace:K,accountId:se("account-id").pipe(ce(a.check(N())))},(e)=>U(_(function*(){let t=yield*Z(),r=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,Ew({client:t.runtime.client,path:{accountId:e.accountId},query:{workspaceId:r},...t.runtime.transport()})))}))).pipe(B(D,["ads.getSpendPolicy"]),R("Read an ad account's spend policy")),P("update-spend-policy",{workspace:K,accountId:se("account-id").pipe(ce(a.check(N()))),expectedRevision:Ke("expected-revision"),file:O("file").pipe(k,_e("Read the body JSON from a file or stdin with -."))},(e)=>U(_(function*(){let t=yield*Z(void 0,"human"),r=m(e.file),n=r===void 0?{expectedRevision:e.expectedRevision}:yield*_t(r),o=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,kw({client:t.runtime.client,path:{accountId:e.accountId},query:{workspaceId:o},body:n,...t.runtime.transport()})))}))).pipe(B(D,["ads.updateSpendPolicy"]),R("Replace an ad account's spend policy")),P("set-kill-switch",{workspace:K,accountId:se("account-id").pipe(ce(a.check(N()))),active:bt("active").pipe(ot(!1)),reason:O("reason").pipe(k)},(e)=>U(_(function*(){let t=yield*Z(),r=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,ww({client:t.runtime.client,path:{accountId:e.accountId},query:{workspaceId:r},body:{active:e.active,...T(e.reason)?{reason:m(e.reason)}:{}},...t.runtime.transport()})))}))).pipe(B(D,["ads.setKillSwitch"]),R("Set or clear an ad account kill switch"))];var OW=P("ads").pipe(R("Read and manage ad accounts, campaigns, and boosts."),rt(TW));var PW=[P("accounts").pipe(R(""),rt([P("list",{workspace:K,accountId:O("account-id").pipe(Ur(0)),platform:Te("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(k),from:O("from").pipe(k),to:O("to").pipe(k),timezone:O("timezone").pipe(k),granularity:Te("granularity",["day","total"]).pipe(k),metrics:O("metrics").pipe(Ur(0)),cursor:O("cursor").pipe(k),limit:Ke("limit").pipe(k)},(e)=>U(_(function*(){let t=yield*Z(),r=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,wk({client:t.runtime.client,path:{workspaceId:r},query:{...e.accountId.length?{accountId:[...e.accountId]}:{},...T(e.platform)?{platform:m(e.platform)}:{},...T(e.from)?{from:m(e.from)}:{},...T(e.to)?{to:m(e.to)}:{},...T(e.timezone)?{timezone:m(e.timezone)}:{},...T(e.granularity)?{granularity:m(e.granularity)}:{},...e.metrics.length?{metrics:[...e.metrics]}:{},...T(e.cursor)?{cursor:m(e.cursor)}:{},...T(e.limit)?{limit:String(m(e.limit))}:{}},...t.runtime.transport()})))}))).pipe(B(D,["analytics.accounts.list"]),R("List account analytics summaries")),P("get",{workspace:K,accountId:se("account-id").pipe(ce(a.check(N()))),from:O("from").pipe(k),to:O("to").pipe(k),timezone:O("timezone").pipe(k),granularity:Te("granularity",["day","total"]).pipe(k),metrics:O("metrics").pipe(Ur(0))},(e)=>U(_(function*(){let t=yield*Z(),r=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,Ak({client:t.runtime.client,path:{accountId:e.accountId,workspaceId:r},query:{...T(e.from)?{from:m(e.from)}:{},...T(e.to)?{to:m(e.to)}:{},...T(e.timezone)?{timezone:m(e.timezone)}:{},...T(e.granularity)?{granularity:m(e.granularity)}:{},...e.metrics.length?{metrics:[...e.metrics]}:{}},...t.runtime.transport()})))}))).pipe(B(D,["analytics.accounts.get"]),R("Read one account's analytics"))])),P("posts").pipe(R(""),rt([P("get",{workspace:K,postId:se("post-id").pipe(ce(a.check(N()))),targetId:O("target-id").pipe(ye(a.check(N()))).pipe(k),from:O("from").pipe(k),to:O("to").pipe(k),timezone:O("timezone").pipe(k),granularity:Te("granularity",["day","total"]).pipe(k),metrics:O("metrics").pipe(Ur(0))},(e)=>U(_(function*(){let t=yield*Z(),r=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,Ek({client:t.runtime.client,path:{postId:e.postId},query:{workspaceId:r,...T(e.targetId)?{targetId:m(e.targetId)}:{},...T(e.from)?{from:m(e.from)}:{},...T(e.to)?{to:m(e.to)}:{},...T(e.timezone)?{timezone:m(e.timezone)}:{},...T(e.granularity)?{granularity:m(e.granularity)}:{},...e.metrics.length?{metrics:[...e.metrics]}:{}},...t.runtime.transport()})))}))).pipe(B(D,["analytics.posts.get"]),R("Read target-scoped post analytics totals")),P("series",{workspace:K,postId:se("post-id").pipe(ce(a.check(N()))),targetId:O("target-id").pipe(ye(a.check(N()))).pipe(k),from:O("from").pipe(k),to:O("to").pipe(k),timezone:O("timezone").pipe(k),granularity:Te("granularity",["day","total"]).pipe(k),metrics:O("metrics").pipe(Ur(0))},(e)=>U(_(function*(){let t=yield*Z(),r=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,kk({client:t.runtime.client,path:{postId:e.postId},query:{workspaceId:r,...T(e.targetId)?{targetId:m(e.targetId)}:{},...T(e.from)?{from:m(e.from)}:{},...T(e.to)?{to:m(e.to)}:{},...T(e.timezone)?{timezone:m(e.timezone)}:{},...T(e.granularity)?{granularity:m(e.granularity)}:{},...e.metrics.length?{metrics:[...e.metrics]}:{}},...t.runtime.transport()})))}))).pipe(B(D,["analytics.posts.series"]),R("Read daily post analytics series"))])),P("capabilities").pipe(R(""),rt([P("get",{workspace:K},(e)=>U(_(function*(){let t=yield*Z(),r=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,vk({client:t.runtime.client,path:{workspaceId:r},...t.runtime.transport()})))}))).pipe(B(D,["analytics.capabilities.get"]),R("Read the analytics metric catalog and provider support"))])),P("refreshes").pipe(R(""),rt([P("create",{workspaceId:O("workspace-id").pipe(ye(a.check(N()))),postId:O("post-id").pipe(ye(a.check(N()))).pipe(k),targetId:O("target-id").pipe(ye(a.check(N()))).pipe(k),metrics:Te("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(Ur(0))},(e)=>U(_(function*(){let t=yield*Z();return yield*C(()=>t.runtime.decode(J,Ck({client:t.runtime.client,body:{workspaceId:e.workspaceId,...T(e.postId)?{postId:m(e.postId)}:{},...T(e.targetId)?{targetId:m(e.targetId)}:{},...e.metrics.length?{metrics:[...e.metrics]}:{}},...t.runtime.transport()})))}))).pipe(B(D,["analytics.refreshes.create"]),R("Queue a priority analytics refresh")),P("get",{workspace:K,refreshId:se("refresh-id").pipe(ce(a.check(N())))},(e)=>U(_(function*(){let t=yield*Z(),r=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,Tk({client:t.runtime.client,path:{refreshId:e.refreshId},query:{workspaceId:r},...t.runtime.transport()})))}))).pipe(B(D,["analytics.refreshes.get"]),R("Read an analytics refresh status"))]))];var RW=P("analytics").pipe(R("Read post, account, and refresh analytics."),rt(PW));var _W=[P("list",{workspace:K,cursor:O("cursor").pipe(k),limit:Ke("limit").pipe(k)},(e)=>U(_(function*(){let t=yield*Z(void 0,"human"),r=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,QE({client:t.runtime.client,path:{workspaceId:r},query:{...T(e.cursor)?{cursor:m(e.cursor)}:{},...T(e.limit)?{limit:String(m(e.limit))}:{}},...t.runtime.transport()})))}))).pipe(B(D,["apiKeys.list"]),R("List workspace API keys")),P("create",{workspace:K,name:O("name"),scopes:Te("scope",["read","publish","engage","ads_read","ads_manage"]).pipe(Ur(0)),expiresAt:O("expires-at").pipe(k)},(e)=>U(_(function*(){let t=yield*Z(void 0,"human"),r=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,HE({client:t.runtime.client,path:{workspaceId:r},body:{name:e.name,...e.scopes.length?{scopes:[...e.scopes]}:{},...T(e.expiresAt)?{expiresAt:m(e.expiresAt)}:{}},...t.runtime.transport()})))}))).pipe(B(D,["apiKeys.create"]),R("Create a workspace API key")),P("get",{workspace:K,keyId:se("key-id").pipe(ce(a.check(N())))},(e)=>U(_(function*(){let t=yield*Z(void 0,"human"),r=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,JE({client:t.runtime.client,path:{keyId:e.keyId,workspaceId:r},...t.runtime.transport()})))}))).pipe(B(D,["apiKeys.get"]),R("Read API key metadata")),P("update",{workspace:K,keyId:se("key-id").pipe(ce(a.check(N()))),name:O("name").pipe(k),scopes:Te("scope",["read","publish","engage","ads_read","ads_manage"]).pipe(Ur(0))},(e)=>U(_(function*(){let t=yield*Z(void 0,"human"),r=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,YE({client:t.runtime.client,path:{keyId:e.keyId,workspaceId:r},body:{...T(e.name)?{name:m(e.name)}:{},...e.scopes.length?{scopes:[...e.scopes]}:{}},...t.runtime.transport()})))}))).pipe(B(D,["apiKeys.update"]),R("Rename an API key or change its access")),P("revoke",{workspace:K,keyId:se("key-id").pipe(ce(a.check(N())))},(e)=>U(_(function*(){let t=yield*Z(void 0,"human"),r=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,VE({client:t.runtime.client,path:{keyId:e.keyId,workspaceId:r},...t.runtime.transport()})))}))).pipe(B(D,["apiKeys.revoke"]),R("Revoke a workspace API key"))];var UW=P("api-keys").pipe(R("Manage workspace API keys as a signed-in owner."),rt(_W));var DW=[P("list",{workspace:K,action:Te("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.deleted","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(k),targetKind:Te("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(k),targetId:O("target-id").pipe(ye(a.check(N()))).pipe(k),actorType:Te("actor-type",["user","api_key"]).pipe(k),actorId:O("actor-id").pipe(ye(a.check(N()))).pipe(k),profileId:O("profile-id").pipe(ye(a.check(N()))).pipe(k),from:O("from").pipe(k),to:O("to").pipe(k),cursor:O("cursor").pipe(k),limit:Ke("limit").pipe(k)},(e)=>U(_(function*(){let t=yield*Z(void 0,"human"),r=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,Nw({client:t.runtime.client,path:{workspaceId:r},query:{...T(e.action)?{action:m(e.action)}:{},...T(e.targetKind)?{targetKind:m(e.targetKind)}:{},...T(e.targetId)?{targetId:m(e.targetId)}:{},...T(e.actorType)?{actorType:m(e.actorType)}:{},...T(e.actorId)?{actorId:m(e.actorId)}:{},...T(e.profileId)?{profileId:m(e.profileId)}:{},...T(e.from)?{from:m(e.from)}:{},...T(e.to)?{to:m(e.to)}:{},...T(e.cursor)?{cursor:m(e.cursor)}:{},...T(e.limit)?{limit:String(m(e.limit))}:{}},...t.runtime.transport()})))}))).pipe(B(D,["audit.list"]),R("List workspace audit events")),P("get",{workspace:K,eventId:se("event-id").pipe(ce(a.check(N())))},(e)=>U(_(function*(){let t=yield*Z(void 0,"human"),r=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,Bw({client:t.runtime.client,path:{eventId:e.eventId,workspaceId:r},...t.runtime.transport()})))}))).pipe(B(D,["audit.get"]),R("Read one audit event")),P("actions").pipe(R(""),rt([P("list",{},(e)=>U(_(function*(){let t=yield*Z();return yield*C(()=>t.runtime.decode(J,rA({client:t.runtime.client,...t.runtime.transport()})))}))).pipe(B(D,["audit.actions.list"]),R("List documented audit actions"))]))];var LW=P("audit").pipe(R("Read the workspace audit history."),rt(DW));var MW=Ke("timeout").pipe(ot(600),_e("Maximum seconds to wait for sign-in.")),yX=P("login",{browser:Tl,timeout:MW,noWait:bt("no-wait").pipe(ot(!1),_e("Print the verification URL and code, then exit. Finish with `pnio auth complete`."))},(e)=>U(_(function*(){let t=yield*ji,r=yield*bW(t);if(console.error(`Open ${r.url} and confirm code ${r.userCode}.`),e.browser)Wy(r.completeUrl);if(e.noWait)return r;let n=yield*Cv(t,{timeoutMs:e.timeout*1000});return yield*C(()=>Xa({baseUrl:t,accessToken:n}).me.get())}))).pipe(R("Sign in with a WorkOS device code, or hand off with --no-wait.")),gX=P("complete",{timeout:MW},(e)=>U(_(function*(){let t=yield*ji,r=yield*Cv(t,{timeoutMs:e.timeout*1000});return yield*C(()=>Xa({baseUrl:t,accessToken:r}).me.get())}))).pipe(R("Finish a sign-in started with `pnio auth login --no-wait`.")),xX=P("status",{},()=>U(_(function*(){let e=yield*Po(void 0,"human");return yield*C(()=>e.me.get())}))).pipe(R("Show the current PubNio account.")),SX=P("logout",{},()=>U(_(function*(){return yield*vW(yield*ji),{signedOut:!0}}))).pipe(R("Revoke the CLI session and clear local credentials.")),FW=P("auth").pipe(R("Manage your CLI session."),rt([yX,gX,xX,SX]));var NW=[P("status",{workspace:K},(e)=>U(_(function*(){let t=yield*Z(),r=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,Vw({client:t.runtime.client,path:{workspaceId:r},...t.runtime.transport()})))}))).pipe(B(D,["billing.get"]),R("Get workspace billing status")),P("usage",{workspace:K,from:O("from").pipe(k),to:O("to").pipe(k),meter:Te("meter",["confirmed_publish","x_passthrough","x_read","managed_ad","inbox_reply","automation_run"]).pipe(k),provider:Te("provider",["bluesky","facebook","instagram","linkedin","pinterest","reddit","snapchat","tiktok","threads","x","youtube","google_business"]).pipe(k)},(e)=>U(_(function*(){let t=yield*Z(),r=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,Jw({client:t.runtime.client,path:{workspaceId:r},query:{...T(e.from)?{from:m(e.from)}:{},...T(e.to)?{to:m(e.to)}:{},...T(e.meter)?{meter:m(e.meter)}:{},...T(e.provider)?{provider:m(e.provider)}:{}},...t.runtime.transport()})))}))).pipe(B(D,["billing.usage.get"]),R("Get workspace daily usage summary")),P("ledger",{workspace:K,kind:Te("kind",["top_up","auto_top_up","overage_debit","x_passthrough_debit","refund","adjustment"]).pipe(k),from:O("from").pipe(k),to:O("to").pipe(k),cursor:O("cursor").pipe(k),limit:Ke("limit").pipe(k)},(e)=>U(_(function*(){let t=yield*Z(void 0,"human"),r=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,Yw({client:t.runtime.client,path:{workspaceId:r},query:{...T(e.kind)?{kind:m(e.kind)}:{},...T(e.from)?{from:m(e.from)}:{},...T(e.to)?{to:m(e.to)}:{},...T(e.cursor)?{cursor:m(e.cursor)}:{},...T(e.limit)?{limit:String(m(e.limit))}:{}},...t.runtime.transport()})))}))).pipe(B(D,["billing.ledger.list"]),R("List workspace prepaid credit ledger")),P("plans",{},(e)=>U(_(function*(){let t=yield*Z();return yield*C(()=>t.runtime.decode(J,tA({client:t.runtime.client,...t.runtime.transport()})))}))).pipe(B(D,["billing.plans.list"]),R("List public billing plans")),P("top-up",{workspace:K,idempotencyKey:ct,file:O("file").pipe(k,_e("Read the body JSON from a file or stdin with -."))},(e)=>U(_(function*(){let t=yield*Z(void 0,"human"),r=m(e.file),n=r===void 0?{}:yield*_t(r),o=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,Zw({client:t.runtime.client,path:{workspaceId:o},body:n,headers:{"idempotency-key":m(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()})))}))).pipe(B(D,["billing.checkout.create"]),R("Create a hosted checkout session for a plan upgrade or credit top-up")),P("portal",{workspace:K,returnUrl:O("return-url").pipe(k)},(e)=>U(_(function*(){let t=yield*Z(void 0,"human"),r=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,Xw({client:t.runtime.client,path:{workspaceId:r},body:{...T(e.returnUrl)?{returnUrl:m(e.returnUrl)}:{}},...t.runtime.transport()})))}))).pipe(B(D,["billing.portal.create"]),R("Create a hosted billing portal session")),P("spend-cap",{workspace:K,version:Ke("version"),file:O("file").pipe(k,_e("Read the body JSON from a file or stdin with -."))},(e)=>U(_(function*(){let t=yield*Z(void 0,"human"),r=m(e.file),n=r===void 0?{version:e.version}:yield*_t(r),o=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,eA({client:t.runtime.client,path:{workspaceId:o},body:n,...t.runtime.transport()})))}))).pipe(B(D,["billing.spendControls.update"]),R("Update monthly spend cap"))];var BW=P("billing").pipe(R("Manage workspace billing, usage, and checkout."),rt(NW));var KW=[P("catalog",{},(e)=>U(_(function*(){let t=yield*Z();return yield*C(()=>t.runtime.decode(J,gk({client:t.runtime.client,...t.runtime.transport()})))}))).pipe(B(D,["capabilities.catalog"]),R("Read the static provider capability catalog")),P("get",{},(e)=>U(_(function*(){let t=yield*Z();return yield*C(()=>t.runtime.decode(J,hk({client:t.runtime.client,...t.runtime.transport()})))}))).pipe(B(D,["capabilities.get"]),R("Read the publish capability catalog")),P("list",{workspace:K,profileId:O("profile-id").pipe(ye(a.check(N()))).pipe(k),accountId:O("account-id").pipe(ye(a.check(N()))).pipe(k),capability:Te("capability",["publish","read_insights","manage_comments","send_messages","ads_read","ads_write","ads_spend"]).pipe(k)},(e)=>U(_(function*(){let t=yield*Z(),r=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,yk({client:t.runtime.client,query:{workspaceId:r,...T(e.profileId)?{profileId:m(e.profileId)}:{},...T(e.accountId)?{accountId:m(e.accountId)}:{},...T(e.capability)?{capability:m(e.capability)}:{}},...t.runtime.transport()})))}))).pipe(B(D,["capabilities.list"]),R("List computed capabilities for connected accounts"))];var qW=P("capabilities").pipe(R("Read publishing capabilities, placements, and limits."),rt(KW));var $W=[P("create",{workspace:K,accountId:O("account-id").pipe(ye(a.check(N()))).pipe(k),provider:Te("provider",["bluesky","facebook","instagram","linkedin","pinterest","reddit","snapchat","tiktok","threads","x","youtube","google_business"]).pipe(k),target:O("target"),targetKind:Te("target-kind",["post","comment"]).pipe(k),text:O("text"),idempotencyKey:ct},(e)=>U(_(function*(){let t=yield*Z(),r=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,J5({client:t.runtime.client,query:{workspaceId:r},body:{...T(e.accountId)?{accountId:m(e.accountId)}:{},...T(e.provider)?{provider:m(e.provider)}:{},target:e.target,...T(e.targetKind)?{targetKind:m(e.targetKind)}:{},text:e.text},headers:{"idempotency-key":m(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()})))}))).pipe(B(D,["comments.create"]),R("Comment on or reply to a provider post"))];var WW=P("comments").pipe(R("Create comments where a destination supports them."),rt($W));var GW=[P("get",{},(e)=>U(_(function*(){let t=yield*Z();return yield*C(()=>t.runtime.decode(J,xk({client:t.runtime.client,...t.runtime.transport()})))}))).pipe(B(D,["limits.get"]),R("Read documented API limits"))];var jW=P("limits").pipe(R("Read workspace publishing limits."),rt(GW));var zW=[P("capabilities",{workspace:K,accountId:O("account-id").pipe(ye(a.check(N()))).pipe(k)},(e)=>U(_(function*(){let t=yield*Z(),r=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,Gk({client:t.runtime.client,query:{workspaceId:r,...T(e.accountId)?{accountId:m(e.accountId)}:{}},...t.runtime.transport()})))}))).pipe(B(D,["inbox.capabilities.get"]),R("Read per-account inbox channel capabilities")),P("unread-count",{workspace:K},(e)=>U(_(function*(){let t=yield*Z(),r=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,Wk({client:t.runtime.client,query:{workspaceId:r},...t.runtime.transport()})))}))).pipe(B(D,["inbox.unread.count"]),R("Count conversations with at least one unread inbound message")),P("conversations").pipe(R(""),rt([P("list",{workspace:K,accountId:O("account-id").pipe(ye(a.check(N()))).pipe(k),provider:Te("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(k),status:Te("status",["active","archived"]).pipe(k),folder:Te("folder",["inbox","message_request","spam","other"]).pipe(k),unread:Te("unread",["true","false"]).pipe(k),search:O("search").pipe(k),cursor:O("cursor").pipe(k),limit:Ke("limit").pipe(k)},(e)=>U(_(function*(){let t=yield*Z(),r=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,Ok({client:t.runtime.client,query:{workspaceId:r,...T(e.accountId)?{accountId:m(e.accountId)}:{},...T(e.provider)?{provider:m(e.provider)}:{},...T(e.status)?{status:m(e.status)}:{},...T(e.folder)?{folder:m(e.folder)}:{},...T(e.unread)?{unread:m(e.unread)}:{},...T(e.search)?{search:m(e.search)}:{},...T(e.cursor)?{cursor:m(e.cursor)}:{},...T(e.limit)?{limit:String(m(e.limit))}:{}},...t.runtime.transport()})))}))).pipe(B(D,["inbox.conversations.list"]),R("List DM conversations newest first")),P("get",{workspace:K,conversationId:se("conversation-id").pipe(ce(a.check(N())))},(e)=>U(_(function*(){let t=yield*Z(),r=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,Pk({client:t.runtime.client,path:{conversationId:e.conversationId},query:{workspaceId:r},...t.runtime.transport()})))}))).pipe(B(D,["inbox.conversations.get"]),R("Read one conversation and reply window")),P("update",{workspace:K,conversationId:se("conversation-id").pipe(ce(a.check(N()))),status:Te("status",["active","archived"]).pipe(k),read:bt("read").pipe(ot(!1))},(e)=>U(_(function*(){let t=yield*Z();if(!(T(e.status)||e.read))return yield*oe(new $e("Provide --status or --read."));let r=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,Rk({client:t.runtime.client,path:{conversationId:e.conversationId},query:{workspaceId:r},body:{...T(e.status)?{status:m(e.status)}:{},...e.read?{read:!0}:{}},...t.runtime.transport()})))}))).pipe(B(D,["inbox.conversations.update"]),R("Mark read or archive a conversation"))])),P("messages").pipe(R(""),rt([P("list",{workspace:K,conversationId:se("conversation-id").pipe(ce(a.check(N()))),order:Te("order",["oldest","newest"]).pipe(k),cursor:O("cursor").pipe(k),limit:Ke("limit").pipe(k)},(e)=>U(_(function*(){let t=yield*Z(),r=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,_k({client:t.runtime.client,path:{conversationId:e.conversationId},query:{workspaceId:r,...T(e.order)?{order:m(e.order)}:{},...T(e.cursor)?{cursor:m(e.cursor)}:{},...T(e.limit)?{limit:String(m(e.limit))}:{}},...t.runtime.transport()})))}))).pipe(B(D,["inbox.messages.list"]),R("Page messages oldest or newest first")),P("send",{workspace:K,conversationId:se("conversation-id").pipe(ce(a.check(N()))),text:O("text"),idempotencyKey:ct},(e)=>U(_(function*(){let t=yield*Z(),r=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,Uk({client:t.runtime.client,path:{conversationId:e.conversationId},query:{workspaceId:r},body:{text:e.text},headers:{"idempotency-key":m(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()})))}))).pipe(B(D,["inbox.messages.send"]),R("Send a text reply inside the provider window"))])),P("comments").pipe(R(""),rt([P("list",{workspace:K,accountId:O("account-id").pipe(ye(a.check(N()))).pipe(k),postId:O("post-id").pipe(ye(a.check(N()))).pipe(k),providerPostId:O("provider-post-id").pipe(k),unread:Te("unread",["true","false"]).pipe(k),cursor:O("cursor").pipe(k),limit:Ke("limit").pipe(k)},(e)=>U(_(function*(){let t=yield*Z(),r=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,Dk({client:t.runtime.client,query:{workspaceId:r,...T(e.accountId)?{accountId:m(e.accountId)}:{},...T(e.postId)?{postId:m(e.postId)}:{},...T(e.providerPostId)?{providerPostId:m(e.providerPostId)}:{},...T(e.unread)?{unread:m(e.unread)}:{},...T(e.cursor)?{cursor:m(e.cursor)}:{},...T(e.limit)?{limit:String(m(e.limit))}:{}},...t.runtime.transport()})))}))).pipe(B(D,["inbox.comments.list"]),R("List comment threads with counts")),P("get",{workspace:K,threadId:se("thread-id").pipe(ce(a.check(N()))),cursor:O("cursor").pipe(k),limit:Ke("limit").pipe(k)},(e)=>U(_(function*(){let t=yield*Z(),r=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,Lk({client:t.runtime.client,path:{threadId:e.threadId},query:{workspaceId:r,...T(e.cursor)?{cursor:m(e.cursor)}:{},...T(e.limit)?{limit:String(m(e.limit))}:{}},...t.runtime.transport()})))}))).pipe(B(D,["inbox.comments.get"]),R("Read a comment thread and its comments")),P("reply",{workspace:K,commentId:se("comment-id").pipe(ce(a.check(N()))),text:O("text"),idempotencyKey:ct},(e)=>U(_(function*(){let t=yield*Z(),r=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,Mk({client:t.runtime.client,path:{commentId:e.commentId},query:{workspaceId:r},body:{text:e.text},headers:{"idempotency-key":m(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()})))}))).pipe(B(D,["inbox.comments.reply"]),R("Reply to a comment")),P("moderate",{workspace:K,commentId:se("comment-id").pipe(ce(a.check(N()))),hidden:bt("hidden").pipe(ot(!1)),liked:bt("liked").pipe(ot(!1))},(e)=>U(_(function*(){let t=yield*Z(),r=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,Nk({client:t.runtime.client,path:{commentId:e.commentId},query:{workspaceId:r},body:{...e.hidden?{hidden:!0}:{},...e.liked?{liked:!0}:{}},...t.runtime.transport()})))}))).pipe(B(D,["inbox.comments.moderate"]),R("Hide, unhide, like, or unlike a comment")),P("delete",{workspace:K,commentId:se("comment-id").pipe(ce(a.check(N())))},(e)=>U(_(function*(){let t=yield*Z(),r=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,Fk({client:t.runtime.client,path:{commentId:e.commentId},query:{workspaceId:r},...t.runtime.transport()})))}))).pipe(B(D,["inbox.comments.delete"]),R("Delete a comment where the provider supports it"))])),P("mentions").pipe(R(""),rt([P("list",{workspace:K,accountId:O("account-id").pipe(ye(a.check(N()))).pipe(k),provider:Te("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(k),cursor:O("cursor").pipe(k),limit:Ke("limit").pipe(k)},(e)=>U(_(function*(){let t=yield*Z(),r=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,Bk({client:t.runtime.client,query:{workspaceId:r,...T(e.accountId)?{accountId:m(e.accountId)}:{},...T(e.provider)?{provider:m(e.provider)}:{},...T(e.cursor)?{cursor:m(e.cursor)}:{},...T(e.limit)?{limit:String(m(e.limit))}:{}},...t.runtime.transport()})))}))).pipe(B(D,["inbox.mentions.list"]),R("List mentions of a connected account")),P("reply",{workspace:K,mentionId:se("mention-id").pipe(ce(a.check(N()))),text:O("text"),idempotencyKey:ct},(e)=>U(_(function*(){let t=yield*Z(),r=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,Kk({client:t.runtime.client,path:{mentionId:e.mentionId},query:{workspaceId:r},body:{text:e.text},headers:{"idempotency-key":m(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()})))}))).pipe(B(D,["inbox.mentions.reply"]),R("Reply to a mention where supported"))])),P("sync").pipe(R(""),rt([P("start",{workspaceId:O("workspace-id").pipe(ye(a.check(N()))),accountId:O("account-id").pipe(ye(a.check(N()))).pipe(k)},(e)=>U(_(function*(){let t=yield*Z();return yield*C(()=>t.runtime.decode(J,jk({client:t.runtime.client,body:{workspaceId:e.workspaceId,...T(e.accountId)?{accountId:m(e.accountId)}:{}},...t.runtime.transport()})))}))).pipe(B(D,["inbox.sync.start"]),R("Queue a bounded inbox sync")),P("status",{workspace:K,syncRunId:se("sync-run-id").pipe(ce(a.check(N())))},(e)=>U(_(function*(){let t=yield*Z(),r=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,zk({client:t.runtime.client,path:{syncRunId:e.syncRunId},query:{workspaceId:r},...t.runtime.transport()})))}))).pipe(B(D,["inbox.sync.get"]),R("Read a sync run and current inbox counts"))])),P("attachments").pipe(R(""),rt([P("get",{workspace:K,attachmentId:se("attachment-id").pipe(ce(a.check(N())))},(e)=>U(_(function*(){let t=yield*Z(),r=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,Qk({client:t.runtime.client,path:{attachmentId:e.attachmentId},query:{workspaceId:r},...t.runtime.transport()})))}))).pipe(B(D,["inbox.attachments.get"]),R("Stream an inbound attachment"))])),P("reviews").pipe(R(""),rt([P("list",{workspace:K,accountId:O("account-id").pipe(ye(a.check(N()))).pipe(k),includeDeleted:Te("include-deleted",["true","false"]).pipe(k),cursor:O("cursor").pipe(k),limit:Ke("limit").pipe(k)},(e)=>U(_(function*(){let t=yield*Z(),r=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,qk({client:t.runtime.client,query:{workspaceId:r,...T(e.accountId)?{accountId:m(e.accountId)}:{},...T(e.includeDeleted)?{includeDeleted:m(e.includeDeleted)}:{},...T(e.cursor)?{cursor:m(e.cursor)}:{},...T(e.limit)?{limit:String(m(e.limit))}:{}},...t.runtime.transport()})))}))).pipe(B(D,["inbox.reviews.list"]),R("List stored Google Business Profile reviews newest first")),P("get",{workspace:K,reviewId:se("review-id").pipe(ce(a.check(N())))},(e)=>U(_(function*(){let t=yield*Z(),r=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,$k({client:t.runtime.client,path:{reviewId:e.reviewId},query:{workspaceId:r},...t.runtime.transport()})))}))).pipe(B(D,["inbox.reviews.get"]),R("Read one stored Google Business Profile review")),P("reply",{workspace:K,reviewId:se("review-id").pipe(ce(a.check(N()))),text:O("text"),idempotencyKey:ct},(e)=>U(_(function*(){let t=yield*Z(),r=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,V5({client:t.runtime.client,path:{reviewId:e.reviewId},query:{workspaceId:r},body:{text:e.text},headers:{"idempotency-key":m(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()})))}))).pipe(B(D,["inbox.reviews.reply"]),R("Reply to a Google Business Profile review"))]))];var QW=P("inbox").pipe(R("Read and reply from the unified inbox."),rt(zW));var HW=[P("get-account",{workspace:K,accountId:se("account-id").pipe(ce(a.check(N()))),includeAdAccounts:Te("include-ad-accounts",["true","false"]).pipe(k)},(e)=>U(_(function*(){let t=yield*Z(),r=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,ck({client:t.runtime.client,path:{accountId:e.accountId},query:{workspaceId:r,...T(e.includeAdAccounts)?{includeAdAccounts:m(e.includeAdAccounts)}:{}},...t.runtime.transport()})))}))).pipe(B(D,["integrations.getAccount"]),R("Check account readiness")),P("bluesky-session",{workspace:K,handle:O("handle"),appPassword:O("app-password"),service:O("service").pipe(k),accountId:O("account-id").pipe(ye(a.check(N()))).pipe(k),profileId:O("profile-id").pipe(ye(a.check(N()))).pipe(k)},(e)=>U(_(function*(){let t=yield*Z(void 0,"human"),r=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,H5({client:t.runtime.client,query:{workspaceId:r},body:{handle:e.handle,appPassword:e.appPassword,...T(e.service)?{service:m(e.service)}:{},...T(e.accountId)?{accountId:m(e.accountId)}:{},...T(e.profileId)?{profileId:m(e.profileId)}:{}},...t.runtime.transport()})))}))).pipe(B(D,["integrations.blueskySession"]),R("Connect Bluesky with an app password")),P("get-instagram-audio",{workspace:K,accountId:se("account-id").pipe(ce(a.check(N()))),audioId:se("audio-id")},(e)=>U(_(function*(){let t=yield*Z(),r=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,pk({client:t.runtime.client,path:{accountId:e.accountId,audioId:e.audioId},query:{workspaceId:r},...t.runtime.transport()})))}))).pipe(B(D,["integrations.getInstagramAudio"]),R("Read current Instagram audio metadata and refresh its preview URL")),P("move-account",{workspace:K,accountId:se("account-id").pipe(ce(a.check(N()))),profileId:O("profile-id").pipe(ye(a.check(N())))},(e)=>U(_(function*(){let t=yield*Z(void 0,"human"),r=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,ak({client:t.runtime.client,path:{accountId:e.accountId},query:{workspaceId:r},body:{profileId:e.profileId},...t.runtime.transport()})))}))).pipe(B(D,["integrations.moveAccount"]),R("Move an account to another profile"))];var zp=se("account-id").pipe(ce(Hu.fields.accountId)),JW=Te("login-method",Nh.literals).pipe(k),YW=Ke("timeout").pipe(ot(120),_e("Maximum seconds to wait for consent.")),ZW=nr("Cli.waitForConnection")(function*(e,t,r){let n=(yield*ds)+Math.max(0,r)*1000;for(;;){let o=yield*C(()=>e.accounts.connectionStatus(t));if(o.status!=="pending")return o;if((yield*ds)>=n)return{...o,timedOut:!0};yield*$d("1 second")}}),XW=nr("Cli.oauthHandoff")(function*(e,t,r){if((yield*gr({try:()=>new URL(e.url),catch:(o)=>o})).origin!==t)return yield*oe(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)Wy(e.url);return e}),bX=P("list",{workspace:K},({workspace:e})=>U(_(function*(){let t=yield*je(m(e));return yield*C(()=>t.accounts.list())}))).pipe(B(D,["integrations.list"]),R("List publishing destinations.")),IX=P("connect",{provider:iZ("provider",Tn.literals),workspace:K,browser:Tl,loginMethod:JW,wait:bt("wait").pipe(ot(!1),_e("Wait for consent before returning.")),timeout:YW},(e)=>U(_(function*(){let t=yield*ji,r=yield*je(m(e.workspace),{origin:t}),n=yield*C(()=>r.accounts.prepareConnection(e.provider,m(e.loginMethod))),o=yield*XW(n,t,e.browser);if(!e.wait)return o;let i=yield*ZW(r,n.attemptId,e.timeout);if(i.status!=="connected")process.exitCode=1;return{...o,connection:i}}))).pipe(B(D,["integrations.prepareConnection","integrations.connectionStatus"]),R("Connect Facebook, Instagram, or TikTok.")),EX=P("wait",{attempt:se("attempt-id").pipe(ce(WI.fields.attemptId)),workspace:K,timeout:YW},(e)=>U(_(function*(){let t=yield*je(m(e.workspace)),r=yield*ZW(t,e.attempt,e.timeout);if(r.status!=="connected")process.exitCode=1;return r}))).pipe(B(D,["integrations.connectionStatus"]),R("Wait for an account connection to finish.")),kX=P("status",{attempt:se("attempt-id").pipe(ce(WI.fields.attemptId)),workspace:K},({attempt:e,workspace:t})=>U(_(function*(){let r=yield*je(m(t));return yield*C(()=>r.accounts.connectionStatus(e))}))).pipe(B(D,["integrations.connectionStatus"]),R("Check whether social account OAuth completed.")),wX=P("health",{account:zp,workspace:K},({account:e,workspace:t})=>U(_(function*(){let r=yield*je(m(t));return yield*C(()=>r.accounts.get(e))}))).pipe(B(D,["integrations.getAccount"]),R("Check account readiness using the last recorded grant.")),AX=P("instagram-quota",{account:zp,workspace:K},({account:e,workspace:t})=>U(_(function*(){let r=yield*je(m(t));return yield*C(()=>r.accounts.instagramPublishingLimit(e))}))).pipe(B(D,["integrations.instagramPublishingLimit"]),R("Read the Instagram account\u2019s current publishing quota.")),vX=P("instagram-audio",{account:zp,workspace:K,type:Te("type",Kh.literals).pipe(ot("music")),query:O("query").pipe(k)},({account:e,workspace:t,type:r,query:n})=>U(_(function*(){let o=yield*je(m(t));return yield*C(()=>o.accounts.searchInstagramAudio(e,{audioType:r,q:m(n)}))}))).pipe(B(D,["integrations.searchInstagramAudio"]),R("Search Instagram\u2019s catalog or list trending audio.")),CX=P("instagram-audio-info",{account:zp,workspace:K,audioId:se("audio-id").pipe(ce(Cp))},({account:e,workspace:t,audioId:r})=>U(_(function*(){let n=yield*je(m(t));return yield*C(()=>n.accounts.getInstagramAudio(e,r))}))).pipe(B(D,["integrations.getInstagramAudio"]),R("Read current metadata for an Instagram audio track.")),TX=P("reconnect",{account:zp,workspace:K,browser:Tl,loginMethod:JW},(e)=>U(_(function*(){let t=yield*ji,r=yield*je(m(e.workspace),{origin:t});return yield*XW(yield*C(()=>r.accounts.reconnect(e.account,m(e.loginMethod))),t,e.browser)}))).pipe(B(D,["integrations.reconnect"]),R("Reauthorize a connected account while keeping its ID.")),OX=P("disconnect",{connection:se("connection-id").pipe(ce(gM.fields.connectionId)),workspace:K,yes:bt("yes").pipe(ot(!1))},({connection:e,workspace:t,yes:r})=>U(_(function*(){if(!r)return yield*oe(new $e("Pass --yes to disconnect the grant and disable all accounts using it."));let n=yield*je(m(t));return yield*C(()=>n.accounts.disconnect(e))}))).pipe(B(D,["integrations.disconnect"]),R("Remove a grant and disable its accounts."));function VW(e){return P(e,{account:zp,workspace:K},({account:t,workspace:r})=>U(_(function*(){let n=yield*je(m(r));return yield*C(()=>n.accounts.setEnabled({id:t,enabled:e==="enable"}))}))).pipe(B(D,["integrations.setEnabled"]),R(`${e==="enable"?"Enable":"Disable"} a publishing destination.`))}var e2=P("integrations").pipe(R("Connect and select publishing destinations."),rt([bX,IX,EX,kX,wX,AX,vX,CX,TX,OX,VW("enable"),VW("disable"),...HW]));import{writeFile as PX}from"fs/promises";var t2=[P("status",{workspace:K,mediaId:se("media-id").pipe(ce(a.check(N())))},(e)=>U(_(function*(){let t=yield*Z(),r=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,ly({client:t.runtime.client,path:{mediaId:e.mediaId},query:{workspaceId:r},...t.runtime.transport()})))}))).pipe(B(D,["media.status"]),R("Get workspace media intake status")),P("get",{workspace:K,mediaId:se("media-id").pipe(ce(a.check(N())))},(e)=>U(_(function*(){let t=yield*Z(),r=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,Ik({client:t.runtime.client,path:{mediaId:e.mediaId},query:{workspaceId:r},...t.runtime.transport()})))}))).pipe(B(D,["media.get"]),R("Get workspace media metadata")),P("list",{workspace:K,cursor:O("cursor").pipe(k),limit:Ke("limit").pipe(k),type:Te("type",["image","video","document"]).pipe(k)},(e)=>U(_(function*(){let t=yield*Z(),r=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,Sk({client:t.runtime.client,query:{workspaceId:r,...T(e.cursor)?{cursor:m(e.cursor)}:{},...T(e.limit)?{limit:String(m(e.limit))}:{},...T(e.type)?{type:m(e.type)}:{}},...t.runtime.transport()})))}))).pipe(B(D,["media.list"]),R("List ready workspace media")),P("delete",{workspace:K,mediaId:se("media-id").pipe(ce(a.check(N())))},(e)=>U(_(function*(){let t=yield*Z(void 0,"human"),r=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,bk({client:t.runtime.client,path:{mediaId:e.mediaId},query:{workspaceId:r},...t.runtime.transport()})))}))).pipe(B(D,["media.delete"]),R("Delete unused workspace media"))];var r2=se("media-id").pipe(ce(vn)),RX=P("upload",{file:se("file"),workspace:K,mime:Te("mime",wp.literals).pipe(k),key:ct},(e)=>U(_(function*(){let t=Bun.file(e.file);if(!(yield*C(()=>t.exists())))return yield*oe(new $e("Choose an existing media file."));let r=yield*je(m(e.workspace));return yield*C(()=>r.media.upload(t,{mimeType:m(e.mime),idempotencyKey:m(e.key)}))}))).pipe(B(D,["media.upload","media.startUpload","media.uploadPart","media.completeUpload"]),R("Upload an image, video, or document for use in posts.")),_X=P("import",{url:se("url"),workspace:K,key:ct},(e)=>U(_(function*(){let t=yield*je(m(e.workspace));return yield*C(()=>t.media.importUrl(e.url,{idempotencyKey:m(e.key)}))}))).pipe(B(D,["media.import"]),R("Copy a public or signed HTTPS URL into private workspace media.")),UX=P("wait",{mediaId:r2,workspace:K,timeoutSeconds:Ke("timeout").pipe(ot(30),_e("Maximum seconds to wait for media readiness."))},(e)=>U(_(function*(){if(e.timeoutSeconds<0||e.timeoutSeconds>300)return yield*oe(new $e("Use a timeout between 0 and 300 seconds."));let t=yield*je(m(e.workspace)),r=yield*C(()=>t.media.wait(e.mediaId,{timeoutMs:e.timeoutSeconds*1000}));if(r.status!=="ready")process.exitCode=1;return r}))).pipe(B(D,["media.status"]),R("Wait for media readiness and return ready, failed, or timeout.")),DX=P("download",{mediaId:r2,workspace:K,out:O("out")},(e)=>U(_(function*(){let t=yield*je(m(e.workspace)),r=yield*C(()=>t.media.download(e.mediaId)),n=yield*C(()=>r.arrayBuffer());return yield*C(()=>PX(e.out,new Uint8Array(n),{flag:"wx"})),{path:e.out,sizeBytes:r.size}}))).pipe(B(D,["media.download"]),R("Save private media to a new local file.")),n2=P("media").pipe(R("Manage workspace media files."),rt([RX,_X,...t2,UX,DX]));var o2=[P("get",{workspace:K,postId:se("post-id").pipe(ce(a.check(N())))},(e)=>U(_(function*(){let t=yield*Z(),r=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,Jk({client:t.runtime.client,path:{postId:e.postId},query:{workspaceId:r},...t.runtime.transport()})))}))).pipe(B(D,["posts.get"]),R("Read a post or draft")),P("attempts",{workspace:K,postId:se("post-id").pipe(ce(a.check(N()))),targetId:se("target-id").pipe(ce(a.check(N()))),cursor:O("cursor").pipe(k),limit:Ke("limit").pipe(k)},(e)=>U(_(function*(){let t=yield*Z(),r=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,Zk({client:t.runtime.client,path:{postId:e.postId,targetId:e.targetId},query:{workspaceId:r,...T(e.cursor)?{cursor:m(e.cursor)}:{},...T(e.limit)?{limit:String(m(e.limit))}:{}},...t.runtime.transport()})))}))).pipe(B(D,["posts.attempts"]),R("Read a destination's delivery attempt history")),P("retry",{workspace:K,postId:se("post-id").pipe(ce(a.check(N()))),targetId:se("target-id").pipe(ce(a.check(N()))),expectedAttemptId:O("expected-attempt-id").pipe(ye(a.check(N())))},(e)=>U(_(function*(){let t=yield*Z(),r=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,Xk({client:t.runtime.client,path:{postId:e.postId,targetId:e.targetId},query:{workspaceId:r},body:{expectedAttemptId:e.expectedAttemptId},...t.runtime.transport()})))}))).pipe(B(D,["posts.retry"]),R("Retry a failed delivery")),P("reconcile",{workspace:K,postId:se("post-id").pipe(ce(a.check(N()))),targetId:se("target-id").pipe(ce(a.check(N()))),expectedAttemptId:O("expected-attempt-id").pipe(ye(a.check(N())))},(e)=>U(_(function*(){let t=yield*Z(),r=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,ew({client:t.runtime.client,path:{postId:e.postId,targetId:e.targetId},query:{workspaceId:r},body:{expectedAttemptId:e.expectedAttemptId},...t.runtime.transport()})))}))).pipe(B(D,["posts.reconcile"]),R("Recheck a recorded provider receipt")),P("update",{workspace:K,postId:se("post-id").pipe(ce(a.check(N()))),text:O("text").pipe(k),expectedRevision:Ke("revision").pipe(k),file:O("file").pipe(k,_e("Read the body JSON from a file or stdin with -."))},(e)=>U(_(function*(){let t=yield*Z(),r=m(e.file),n=r===void 0?{...T(e.text)?{text:m(e.text)}:{},...T(e.expectedRevision)?{expectedRevision:m(e.expectedRevision)}:{}}:yield*_t(r),o=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,Yk({client:t.runtime.client,path:{postId:e.postId},query:{workspaceId:o},body:n,...t.runtime.transport()})))}))).pipe(B(D,["posts.update"]),R("Edit a draft")),P("delete",{workspace:K,postId:se("post-id").pipe(ce(a.check(N())))},(e)=>U(_(function*(){let t=yield*Z(),r=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,Vk({client:t.runtime.client,path:{postId:e.postId},query:{workspaceId:r},...t.runtime.transport()})))}))).pipe(B(D,["posts.delete"]),R("Archive a post or draft"))];var LX=Kr(rF,{onExcessProperty:"error"}),ig=se("post-id").pipe(ce(EL.fields.postId)),MX=Ke("revision").pipe(ye(Ao),_e("Expected revision from posts get.")),FX=P("create",{workspace:K,text:O("text").pipe(k,_e("Post text for the one-call path.")),platform:Te("platform",Os).pipe(Ur(0),_e("Publish to the single ready account for this provider. Repeat for several platforms.")),account:U$,mediaId:O("media-id").pipe(ye(vn),Ur(0),_e("Attach ready workspace media by ID.")),mediaUrl:O("media-url").pipe(Ur(0),_e("Attach a public HTTPS media URL.")),schedule:O("schedule").pipe(ye($t),k,_e("Schedule with an ISO time and explicit offset.")),publishNow:bt("publish-now").pipe(ot(!0),_e("Publish now when --schedule is absent.")),draft:bt("draft").pipe(ot(!1),_e("Save a draft without submitting it.")),file:O("file").pipe(k,_e("Advanced: read a full Level 2 post JSON document from a file or stdin with -.")),key:ct,queue:O("queue").pipe(ye(tr),k,_e("Assign every file-provided destination to this account queue."))},(e)=>U(_(function*(){let t=yield*je(m(e.workspace)),r=m(e.key),n=m(e.file),o=m(e.schedule);if(e.draft&&o)return yield*oe(new $e("Drafts cannot set --schedule until published."));if(n){if(T(e.text)||e.platform.length||e.account.length||e.mediaId.length||e.mediaUrl.length||o&&!e.draft||!e.publishNow&&!e.draft)return yield*oe(new $e("Use --file alone, or provide --text with --platform or --account."));let c=yield*LX(yield*_t(n)).pipe(Jt(()=>new $e("Post JSON does not match the PubNio API contract."))),d=m(e.queue);if(d&&e.draft)return yield*oe(new $e("Drafts cannot be assigned a queue."));if(d&&(c.targets??[]).some((x)=>x.scheduledAt!==void 0||x.queueId!==void 0))return yield*oe(new $e("Remove per-target schedules or queues when using --queue."));return yield*C(()=>t.posts.create({...d?{...c,targets:(c.targets??[]).map((x)=>({...x,queueId:d}))}:c,...e.draft?{isDraft:!0}:{},...r?{idempotencyKey:r}:{}}))}let i=m(e.text);if(i===void 0)return yield*oe(new $e("Provide --text or --file."));if(e.draft&&e.platform.length)return yield*oe(new $e("Drafts select exact --account IDs, not platforms."));if(!e.draft&&T(e.queue))return yield*oe(new $e("--queue requires --file."));if(!e.draft&&e.platform.length&&e.account.length)return yield*oe(new $e("Use --platform or --account, not both."));if(!e.draft&&!e.platform.length&&!e.account.length)return yield*oe(new $e("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 yield*C(()=>t.posts.create({text:i,isDraft:!0,...e.account.length?{targets:e.account.map((c)=>({accountId:c}))}:{},...s.length?{media:s}:{}}));return yield*C(()=>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(B(D,["posts.create"]),R("Create and submit a post in one call, or save a draft with --draft.")),NX=P("list",{workspace:K,...Ks,draft:bt("draft").pipe(ot(!1),_e("List only drafts. Omit to list posts and drafts.")),deliveryStatus:Te("delivery-status",Ep.literals).pipe(k)},(e)=>U(_(function*(){let t=yield*je(m(e.workspace));return yield*C(()=>t.posts.list({cursor:m(e.cursor),limit:m(e.limit),...e.draft?{isDraft:!0}:{},deliveryStatus:m(e.deliveryStatus)}))}))).pipe(B(D,["posts.list"]),R("List posts and drafts, and filter their current deliveries.")),BX=P("validate",{workspace:K,id:ig},(e)=>U(_(function*(){let t=yield*je(m(e.workspace)),r=yield*C(()=>t.posts.validate(e.id));if(!r.canPublish)process.exitCode=1;return r}))).pipe(B(D,["posts.validate"]),R("Validate a saved draft before publishing.")),KX=P("publish",{id:ig,workspace:K,revision:MX,key:ct,at:O("at").pipe(ye($t),k),queue:O("queue").pipe(ye(tr),k),account:D$,placement:Te("placement",Pr.literals).pipe(k)},(e)=>U(_(function*(){let t=m(e.placement),r=m(e.account),n=m(e.at),o=m(e.queue),i=m(e.key);if(t&&!r)return yield*oe(new $e("Use --placement with --account."));if(n&&o)return yield*oe(new $e("Use --at or --queue, not both."));let s=yield*je(m(e.workspace));if(o){let d=(yield*C(()=>s.posts.get(e.id))).targets.filter((x)=>!r||x.accountId.toLowerCase()===r.toLowerCase());if(!d.length||t&&d.some((x)=>x.placement!==t))return yield*oe(new $e("No matching destination exists in this post for --queue."));return yield*C(()=>s.posts.publish(e.id,{expectedRevision:e.revision,idempotencyKey:i,targets:d.map((x)=>({accountId:x.accountId,placement:x.placement,queueId:o}))}))}return yield*C(()=>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(B(D,["posts.get","posts.publish"]),R("Publish a saved draft now or at --at.")),qX=P("status",{workspace:K,id:ig},(e)=>U(_(function*(){let t=yield*je(m(e.workspace));return yield*C(()=>t.posts.status(e.id))}))).pipe(B(D,["posts.get"]),R("Read delivery outcomes for a post.")),$X=P("wait",{workspace:K,id:ig,timeoutSeconds:Ke("timeout").pipe(ot(60),_e("Maximum seconds to wait for delivery."))},(e)=>U(_(function*(){if(e.timeoutSeconds<0||e.timeoutSeconds>3600)return yield*oe(new $e("Use a timeout between 0 and 3600 seconds."));let t=yield*je(m(e.workspace)),r=yield*C(()=>t.posts.wait(e.id,{timeoutMs:e.timeoutSeconds*1000}));if(!r.settled)process.exitCode=1;return r}))).pipe(B(D,["posts.get"]),R("Wait for a post to reach a settled delivery outcome."));function Ov(e,t){return U(_(function*(){let r=yield*je(m(e.workspace));return yield*C(()=>r.schedule.change(uL(e.postId),lL(e.targetId),t))}))}var Pv={postId:se("post-id").pipe(ce(wI.fields.postId)),targetId:se("target-id").pipe(ce(wI.fields.targetId)),expectedAttemptId:O("attempt").pipe(ye(Zt),_e("Current attempt ID from posts status.")),workspace:K},WX=P("reschedule",{...Pv,at:O("at").pipe(ye($t),k),queue:O("queue").pipe(ye(tr),k),slot:O("slot").pipe(ye(a.check(N())),k),date:O("date").pipe(ye(Pn),k)},(e)=>{let t=m(e.at),r=m(e.queue),n=m(e.slot),o=m(e.date);if(t===void 0===(r===void 0))return oe(new $e("Use exactly one of --at or --queue."));if(r&&n===void 0!==(o===void 0))return oe(new $e("Use --slot and --date together to pin a slot."));return Ov(e,r?{action:"reschedule",expectedAttemptId:e.expectedAttemptId,queueId:r,...n&&o?{pinned:{slotId:n,occurrenceDate:o}}:{}}:{action:"reschedule",expectedAttemptId:e.expectedAttemptId,scheduledAt:t})}).pipe(B(D,["schedule.change"]),R("Move a pending delivery to a queue slot or time.")),GX=P("cancel",Pv,(e)=>Ov(e,{action:"cancel",expectedAttemptId:e.expectedAttemptId})).pipe(B(D,["schedule.change"]),R("Cancel a delivery before the provider write is reserved.")),jX=P("publish-now",Pv,(e)=>Ov(e,{action:"publish_now",expectedAttemptId:e.expectedAttemptId})).pipe(B(D,["schedule.change"]),R("Bring a pending delivery forward.")),i2=P("posts").pipe(R("Create and publish posts, save drafts, and manage delivery status."),rt([FX,NX,...o2,BX,KX,qX,$X,WX,GX,jX]));var _n=se("queue-id").pipe(ce(tr)),sg=Ke("version").pipe(_e("Expected version from the last queue read.")),a2={maxPerDay:Ke("max-per-day").pipe(k),maxPending:Ke("max-pending").pipe(k),minGap:Ke("min-gap").pipe(k),horizon:Ke("horizon-days").pipe(k)},c2={slot:O("slot").pipe(BZ(50),_e("Weekly slot as DAY:HH:mm where 0 is Sunday."))},zX=Kr(dF,{onExcessProperty:"error"}),QX=Kr(uF,{onExcessProperty:"error"}),HX=Kr(lF,{onExcessProperty:"error"}),VX=Kr(xF,{onExcessProperty:"error"}),JX=Kr(IF,{onExcessProperty:"error"});function p2(e){let t=/^([0-6]):((?:[01]\d|2[0-3]):[0-5]\d)$/.exec(e);if(!t)return oe(new $e("Use --slot DAY:HH:mm where DAY is 0-6, 0 Sunday."));return j({dayOfWeek:Number(t[1]),time:t[2]})}function d2(e){let t=m(e.maxPerDay),r=m(e.maxPending),n=m(e.minGap),o=m(e.horizon);return{...t===void 0?{}:{maxPerDay:t},...r===void 0?{}:{maxPending:r},...n===void 0?{}:{minGapSeconds:n},...o===void 0?{}:{horizonDays:o}}}var YX=P("list",{workspace:K,account:iv,...Ks},(e)=>U(_(function*(){let t=yield*je(m(e.workspace));return yield*C(()=>t.queues.list({accountId:m(e.account),cursor:m(e.cursor),limit:m(e.limit)}))}))).pipe(B(D,["queues.list"]),R("List account schedule queues.")),ZX=P("create",{workspace:K,file:O("file").pipe(k,_e("Read CreateQueue JSON from a file or stdin with -.")),account:iv,name:O("name").pipe(k),timezone:O("timezone").pipe(k,_e("IANA time zone, e.g. America/New_York. Defaults to the workspace default time zone.")),default:bt("default").pipe(k,_e("Promote the new queue to the account default. The first active queue is always the default.")),...c2,...a2},(e)=>U(_(function*(){let t=yield*je(m(e.workspace)),r=m(e.file),n=yield*zX(r?yield*_t(r):{accountId:m(e.account),name:m(e.name),...cr(e.timezone)?{}:{timezone:e.timezone.value},slots:yield*Wo(e.slot,p2),...cr(e.default)?{}:{isDefault:e.default.value},...d2(e)}).pipe(Jt(()=>new $e("Queue JSON does not match the PubNio API contract.")));return yield*C(()=>t.queues.create(n))}))).pipe(B(D,["queues.create"]),R("Create a weekly queue for an account; the first is the default. Omit --timezone to use the workspace default.")),XX=P("get",{workspace:K,queueId:_n},(e)=>U(_(function*(){let t=yield*je(m(e.workspace));return yield*C(()=>t.queues.get(e.queueId))}))).pipe(B(D,["queues.get"]),R("Read a queue, its slots, and its limits.")),eee=P("update",{workspace:K,queueId:_n,version:sg,file:O("file").pipe(k,_e("Read UpdateQueue JSON from a file or stdin with -.")),name:O("name").pipe(k),timezone:O("timezone").pipe(k),pause:bt("pause").pipe(ot(!1)),resume:bt("resume").pipe(ot(!1)),default:bt("default").pipe(k,_e("Promote or demote the account default. Demote only after promoting another queue.")),...a2},(e)=>U(_(function*(){if(e.pause&&e.resume)return yield*oe(new $e("Use --pause or --resume, not both."));let t=yield*je(m(e.workspace)),r=m(e.file),n=yield*QX(r?yield*_t(r):{expectedVersion:e.version,...cr(e.name)?{}:{name:e.name.value},...cr(e.timezone)?{}:{timezone:e.timezone.value},...e.pause?{paused:!0}:e.resume?{paused:!1}:{},...cr(e.default)?{}:{isDefault:e.default.value},...d2(e)}).pipe(Jt(()=>new $e("Queue update JSON does not match the PubNio API contract.")));return yield*C(()=>t.queues.update(e.queueId,n))}))).pipe(B(D,["queues.update"]),R("Update limits, name, time zone, default, pause, or resume a queue.")),tee=P("archive",{workspace:K,queueId:_n,version:sg},(e)=>U(_(function*(){let t=yield*je(m(e.workspace));return yield*C(()=>t.queues.archive(e.queueId,e.version))}))).pipe(B(D,["queues.archive"]),R("Archive a queue and keep queued work.")),ree=P("slots",{workspace:K,queueId:_n,version:sg,file:O("file").pipe(k,_e("Read ReplaceQueueSlots JSON from a file or stdin.")),...c2},(e)=>U(_(function*(){let t=yield*je(m(e.workspace)),r=m(e.file),n=yield*HX(r?yield*_t(r):{expectedVersion:e.version,slots:yield*Wo(e.slot,p2)}).pipe(Jt(()=>new $e("Queue slot JSON does not match the PubNio API contract.")));return yield*C(()=>t.queues.replaceSlots(e.queueId,n))}))).pipe(B(D,["queues.slots.replace"]),R("Replace every weekly queue slot.")),nee=P("next-slot",{workspace:K,queueId:_n,after:O("after").pipe(k)},(e)=>U(_(function*(){let t=yield*je(m(e.workspace));return yield*C(()=>t.queues.nextSlot(e.queueId,m(e.after)))}))).pipe(B(D,["queues.slots.next"]),R("Read the next free queue occurrence.")),oee=P("preview",{workspace:K,queueId:_n,count:Ke("count").pipe(ot(10)),after:O("after").pipe(k),includeOccupied:bt("include-occupied").pipe(ot(!1))},(e)=>U(_(function*(){let t=yield*je(m(e.workspace));return yield*C(()=>t.queues.previewSlots(e.queueId,{count:e.count,after:m(e.after),includeOccupied:e.includeOccupied}))}))).pipe(B(D,["queues.slots.preview"]),R("Preview upcoming queue occurrences.")),iee=P("skips",{workspace:K,queueId:_n,...Ks},(e)=>U(_(function*(){let t=yield*je(m(e.workspace));return yield*C(()=>t.queues.skips(e.queueId,{cursor:m(e.cursor),limit:m(e.limit)}))}))).pipe(B(D,["queues.skips.list"]),R("List skipped queue occurrences.")),see=P("skip",{workspace:K,queueId:_n,slotId:O("slot-id").pipe(ye(Yu)),occurrenceDate:O("occurrence-date")},(e)=>U(_(function*(){let t=yield*je(m(e.workspace)),r=yield*VX({slotId:e.slotId,occurrenceDate:e.occurrenceDate}).pipe(Jt(()=>new $e("Use --slot-id with a queue slot UUID and --occurrence-date YYYY-MM-DD.")));return yield*C(()=>t.queues.skip(e.queueId,r.slotId,r.occurrenceDate))}))).pipe(B(D,["queues.skips.create"]),R("Skip one queue occurrence.")),aee=P("unskip",{workspace:K,queueId:_n,skipId:O("skip-id").pipe(ye(Yu))},(e)=>U(_(function*(){let t=yield*je(m(e.workspace));return yield*C(()=>t.queues.unskip(e.queueId,e.skipId))}))).pipe(B(D,["queues.skips.delete"]),R("Restore a skipped queue occurrence.")),cee=P("blackouts",{workspace:K,queueId:_n,...Ks},(e)=>U(_(function*(){let t=yield*je(m(e.workspace));return yield*C(()=>t.queues.blackouts(e.queueId,{cursor:m(e.cursor),limit:m(e.limit)}))}))).pipe(B(D,["queues.blackouts.list"]),R("List queue blackout date ranges.")),pee=P("blackout",{workspace:K,queueId:_n,startsOn:O("starts-on"),endsOn:O("ends-on"),reason:O("reason").pipe(k)},(e)=>U(_(function*(){let t=yield*je(m(e.workspace)),r=yield*JX({startsOn:e.startsOn,endsOn:e.endsOn,reason:m(e.reason)}).pipe(Jt(()=>new $e("Use --starts-on and --ends-on as YYYY-MM-DD; --reason is at most 200 characters.")));return yield*C(()=>t.queues.blackout(e.queueId,r))}))).pipe(B(D,["queues.blackouts.create"]),R("Black out a queue date range.")),dee=P("unblackout",{workspace:K,queueId:_n,blackoutId:O("blackout-id").pipe(ye(jh))},(e)=>U(_(function*(){let t=yield*je(m(e.workspace));return yield*C(()=>t.queues.unblackout(e.queueId,e.blackoutId))}))).pipe(B(D,["queues.blackouts.delete"]),R("Remove a queue blackout.")),s2=(e)=>P(e?"pause":"resume",{workspace:K,queueId:_n,version:sg},(t)=>U(_(function*(){let r=yield*je(m(t.workspace));return yield*C(()=>r.queues.update(t.queueId,{expectedVersion:t.version,paused:e}))}))).pipe(B(D,["queues.update"]),R(e?"Pause new assignments while queued attempts still publish.":"Resume new assignments.")),u2=P("queues").pipe(R("Manage weekly account publishing queues."),rt([YX,ZX,XX,eee,tee,ree,nee,oee,iee,see,aee,cee,pee,dee,s2(!0),s2(!1)]));var uee=P("list",{workspace:K,from:O("from").pipe(_e("Inclusive ISO start instant, for example 2026-12-01T00:00:00Z.")),to:O("to").pipe(_e("Inclusive ISO end instant, at most 90 days after --from.")),accountId:O("account-id").pipe(ye(Y),k,_e("Filter by the target publishing account.")),queueId:O("queue-id").pipe(ye(tr),k,_e("Filter by the open queue assignment.")),...Ks},(e)=>U(_(function*(){let t=yield*je(m(e.workspace));return yield*C(()=>t.schedule.list({from:e.from,to:e.to,accountId:m(e.accountId),queueId:m(e.queueId),cursor:m(e.cursor),limit:m(e.limit)}))}))).pipe(B(D,["schedule.list"]),R("List queued attempts in a time range.")),lee=P("skip-to-next",{workspace:K,postId:O("post-id").pipe(ye(Nt)),targetId:O("target-id").pipe(ye(ur)),queueId:O("queue-id").pipe(ye(tr),k,_e("Override the target delivery's current queue.")),expectedAttemptId:O("expected-attempt-id").pipe(ye(Zt),k,_e("Override the target delivery's current attempt."))},(e)=>U(_(function*(){let t=yield*je(m(e.workspace));return yield*C(()=>t.schedule.skipToNext(e.postId,e.targetId,{queueId:m(e.queueId),expectedAttemptId:m(e.expectedAttemptId)}))}))).pipe(B(D,["posts.get","queues.slots.next","schedule.change"]),R("Move a queue-assigned target to the next free occurrence.")),l2=P("schedule").pipe(R("Read the publishing calendar and skip ahead."),rt([uee,lee]));var f2=[P("preferences").pipe(R(""),rt([P("get",{workspace:K},(e)=>U(_(function*(){let t=yield*Z(void 0,"human"),r=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,Kw({client:t.runtime.client,path:{workspaceId:r},...t.runtime.transport()})))}))).pipe(B(D,["notifications.preferences.get"]),R("Read email notification preferences")),P("update",{workspace:K,deliveryFailures:bt("delivery-failures").pipe(ot(!1)),connectionExpiring:bt("connection-expiring").pipe(ot(!1)),webhookFailures:bt("webhook-failures").pipe(ot(!1)),billingAlerts:bt("billing-alerts").pipe(ot(!1)),weeklyDigest:bt("weekly-digest").pipe(ot(!1))},(e)=>U(_(function*(){let t=yield*Z(void 0,"human"),r=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,qw({client:t.runtime.client,path:{workspaceId:r},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(B(D,["notifications.preferences.update"]),R("Update email notification preferences"))]))];var m2=P("notifications").pipe(R("Read and update notification preferences."),rt(f2));var h2=[P("get",{},(e)=>U(_(function*(){let t=yield*Z(void 0,"human");return yield*C(()=>t.runtime.decode(J,qE({client:t.runtime.client,...t.runtime.transport()})))}))).pipe(B(D,["profile.get"]),R("Get your profile"))];var fee=P("update",{name:O("name").pipe(k),clear:bt("clear-name").pipe(ot(!1))},({name:e,clear:t})=>U(_(function*(){if(e._tag==="Some"===t)return yield*oe(new $e("Provide exactly one of --name or --clear-name."));let r=ws(yL)({displayName:e._tag==="Some"?e.value:null});if(r._tag==="None")return yield*oe(new $e("Display name must be between 1 and 100 characters."));let n=yield*Po();return yield*C(()=>n.me.update(r.value))}))).pipe(B(D,["profile.update"]),R("Change or clear your display name.")),mee=P("deactivate",{yes:bt("yes").pipe(ot(!1))},({yes:e})=>U(_(function*(){if(!e)return yield*oe(new $e("Pass --yes to deactivate the current profile."));let t=yield*Po();return yield*C(()=>t.me.deactivate())}))).pipe(B(D,["profile.deactivate"]),R("Deactivate your profile after archiving owned workspaces.")),hee=P("list",{},()=>U(_(function*(){let e=yield*Po(void 0,"human");return yield*C(()=>e.me.invites())}))).pipe(B(D,["me.invites.list"])),yee=P("accept",{inviteId:se("invite-id").pipe(ce(_i))},({inviteId:e})=>U(_(function*(){let t=yield*Po(void 0,"human");return yield*C(()=>t.me.acceptInvite({inviteId:e}))}))).pipe(B(D,["me.invites.accept"])),gee=P("decline",{inviteId:se("invite-id").pipe(ce(_i))},({inviteId:e})=>U(_(function*(){let t=yield*Po(void 0,"human");return yield*C(()=>t.me.declineInvite(e))}))).pipe(B(D,["me.invites.decline"])),xee=P("invites").pipe(R("Manage your workspace invitations."),rt([hee,yee,gee])),y2=P("profile").pipe(R("Manage your PubNio profile."),rt([...h2,fee,mee,xee]));var g2=[P("list",{workspace:K,includeArchived:Te("include-archived",["true","false"]).pipe(k),cursor:O("cursor").pipe(k),limit:Ke("limit").pipe(k)},(e)=>U(_(function*(){let t=yield*Z(),r=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,dk({client:t.runtime.client,query:{workspaceId:r,...T(e.includeArchived)?{includeArchived:m(e.includeArchived)}:{},...T(e.cursor)?{cursor:m(e.cursor)}:{},...T(e.limit)?{limit:String(m(e.limit))}:{}},...t.runtime.transport()})))}))).pipe(B(D,["profiles.list"]),R("List workspace profiles")),P("create",{workspace:K,name:O("name"),externalId:O("external-id").pipe(k)},(e)=>U(_(function*(){let t=yield*Z(void 0,"human"),r=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,uk({client:t.runtime.client,query:{workspaceId:r},body:{name:e.name,...T(e.externalId)?{externalId:m(e.externalId)}:{}},...t.runtime.transport()})))}))).pipe(B(D,["profiles.create"]),R("Create a workspace profile")),P("get",{workspace:K,profileId:se("profile-id").pipe(ce(a.check(N())))},(e)=>U(_(function*(){let t=yield*Z(),r=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,fk({client:t.runtime.client,path:{profileId:e.profileId},query:{workspaceId:r},...t.runtime.transport()})))}))).pipe(B(D,["profiles.get"]),R("Read a workspace profile")),P("update",{workspace:K,profileId:se("profile-id").pipe(ce(a.check(N()))),name:O("name").pipe(k),file:O("file").pipe(k,_e("Read the body JSON from a file or stdin with -."))},(e)=>U(_(function*(){let t=yield*Z(void 0,"human"),r=m(e.file),n=r===void 0?{...T(e.name)?{name:m(e.name)}:{}}:yield*_t(r),o=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,mk({client:t.runtime.client,path:{profileId:e.profileId},query:{workspaceId:o},body:n,...t.runtime.transport()})))}))).pipe(B(D,["profiles.update"]),R("Rename a profile or change its external ID")),P("archive",{workspace:K,profileId:se("profile-id").pipe(ce(a.check(N())))},(e)=>U(_(function*(){let t=yield*Z(void 0,"human"),r=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,lk({client:t.runtime.client,path:{profileId:e.profileId},query:{workspaceId:r},...t.runtime.transport()})))}))).pipe(B(D,["profiles.archive"]),R("Archive a workspace profile"))];var x2=P("profiles").pipe(R("Manage posting profiles."),rt(g2));var S2=[P("list",{workspace:K,cursor:O("cursor").pipe(k),limit:Ke("limit").pipe(k)},(e)=>U(_(function*(){let t=yield*Z(void 0,"human"),r=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,ZE({client:t.runtime.client,path:{workspaceId:r},query:{...T(e.cursor)?{cursor:m(e.cursor)}:{},...T(e.limit)?{limit:String(m(e.limit))}:{}},...t.runtime.transport()})))}))).pipe(B(D,["webhooks.list"]),R("List webhook endpoints")),P("create",{workspace:K,name:O("name"),url:O("url"),eventTypes:Te("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","billing.subscription.duplicate_refunded"]).pipe(Ur(0)),enabled:bt("paused").pipe(ot(!1)),profileId:O("profile-id").pipe(ye(a.check(N()))).pipe(k),accountIds:O("account-ids").pipe(Ur(0)),disabledResourceGroups:Te("disabled-resource-groups",["publishing","inbox","analytics","ads","scheduling","accounts","billing"]).pipe(Ur(0))},(e)=>U(_(function*(){let t=yield*Z(void 0,"human"),r=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,XE({client:t.runtime.client,path:{workspaceId:r},body:{name:e.name,url:e.url,eventTypes:[...e.eventTypes],...e.enabled?{enabled:!1}:{},...T(e.profileId)?{profileId:m(e.profileId)}:{},...e.accountIds.length?{accountIds:[...e.accountIds]}:{},...e.disabledResourceGroups.length?{disabledResourceGroups:[...e.disabledResourceGroups]}:{}},...t.runtime.transport()})))}))).pipe(B(D,["webhooks.create"]),R("Register a webhook endpoint")),P("get",{workspace:K,endpointId:se("endpoint-id").pipe(ce(a.check(N())))},(e)=>U(_(function*(){let t=yield*Z(void 0,"human"),r=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,tk({client:t.runtime.client,path:{endpointId:e.endpointId,workspaceId:r},...t.runtime.transport()})))}))).pipe(B(D,["webhooks.get"]),R("Inspect a webhook endpoint")),P("update",{workspace:K,endpointId:se("endpoint-id").pipe(ce(a.check(N()))),name:O("name").pipe(k),eventTypes:Te("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","billing.subscription.duplicate_refunded"]).pipe(Ur(0)),enabled:bt("paused").pipe(ot(!1)),file:O("file").pipe(k,_e("Read the body JSON from a file or stdin with -."))},(e)=>U(_(function*(){let t=yield*Z(void 0,"human"),r=m(e.file),n=r===void 0?{...T(e.name)?{name:m(e.name)}:{},...e.eventTypes.length?{eventTypes:[...e.eventTypes]}:{},...e.enabled?{enabled:!1}:{}}:yield*_t(r),o=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,rk({client:t.runtime.client,path:{endpointId:e.endpointId,workspaceId:o},body:n,...t.runtime.transport()})))}))).pipe(B(D,["webhooks.update"]),R("Edit or pause a webhook endpoint")),P("delete",{workspace:K,endpointId:se("endpoint-id").pipe(ce(a.check(N())))},(e)=>U(_(function*(){let t=yield*Z(void 0,"human"),r=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,ek({client:t.runtime.client,path:{endpointId:e.endpointId,workspaceId:r},...t.runtime.transport()})))}))).pipe(B(D,["webhooks.delete"]),R("Permanently disable a webhook endpoint")),P("test",{workspace:K,endpointId:se("endpoint-id").pipe(ce(a.check(N())))},(e)=>U(_(function*(){let t=yield*Z(void 0,"human"),r=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,nk({client:t.runtime.client,path:{endpointId:e.endpointId,workspaceId:r},...t.runtime.transport()})))}))).pipe(B(D,["webhooks.test"]),R("Enqueue a webhook test event")),P("list-deliveries",{workspace:K,endpointId:se("endpoint-id").pipe(ce(a.check(N()))),cursor:O("cursor").pipe(k),limit:Ke("limit").pipe(k)},(e)=>U(_(function*(){let t=yield*Z(void 0,"human"),r=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,ok({client:t.runtime.client,path:{endpointId:e.endpointId,workspaceId:r},query:{...T(e.cursor)?{cursor:m(e.cursor)}:{},...T(e.limit)?{limit:String(m(e.limit))}:{}},...t.runtime.transport()})))}))).pipe(B(D,["webhooks.listDeliveries"]),R("List webhook deliveries")),P("get-delivery",{workspace:K,endpointId:se("endpoint-id").pipe(ce(a.check(N()))),deliveryId:se("delivery-id").pipe(ce(a.check(N())))},(e)=>U(_(function*(){let t=yield*Z(void 0,"human"),r=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,ik({client:t.runtime.client,path:{endpointId:e.endpointId,deliveryId:e.deliveryId,workspaceId:r},...t.runtime.transport()})))}))).pipe(B(D,["webhooks.getDelivery"]),R("Inspect a webhook delivery")),P("replay-delivery",{workspace:K,endpointId:se("endpoint-id").pipe(ce(a.check(N()))),deliveryId:se("delivery-id").pipe(ce(a.check(N())))},(e)=>U(_(function*(){let t=yield*Z(void 0,"human"),r=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,sk({client:t.runtime.client,path:{endpointId:e.endpointId,deliveryId:e.deliveryId,workspaceId:r},...t.runtime.transport()})))}))).pipe(B(D,["webhooks.replayDelivery"]),R("Replay a settled webhook delivery")),P("event-types",{},(e)=>U(_(function*(){let t=yield*Z();return yield*C(()=>t.runtime.decode(J,Q5({client:t.runtime.client,...t.runtime.transport()})))}))).pipe(B(D,["webhooks.eventTypes"]),R("List supported webhook event types"))];var b2=P("webhooks").pipe(R("Manage workspace webhooks as a signed-in owner."),rt(S2));var I2=[P("list",{},(e)=>U(_(function*(){let t=yield*Z();return yield*C(()=>t.runtime.decode(J,$E({client:t.runtime.client,...t.runtime.transport()})))}))).pipe(B(D,["workspaces.list"]),R("List workspaces")),P("create",{name:O("name"),defaultTimezone:O("default-timezone").pipe(k)},(e)=>U(_(function*(){let t=yield*Z(void 0,"human");return yield*C(()=>t.runtime.decode(J,WE({client:t.runtime.client,body:{name:e.name,...T(e.defaultTimezone)?{defaultTimezone:m(e.defaultTimezone)}:{}},...t.runtime.transport()})))}))).pipe(B(D,["workspaces.create"]),R("Create a workspace")),P("get",{id:se("id").pipe(ce(a.check(N())))},(e)=>U(_(function*(){let t=yield*Z();return yield*C(()=>t.runtime.decode(J,jE({client:t.runtime.client,path:{workspaceId:e.id},...t.runtime.transport()})))}))).pipe(B(D,["workspaces.get"]),R("Get a workspace")),P("update",{id:se("id").pipe(ce(a.check(N()))),name:O("name").pipe(k),defaultTimezone:O("default-timezone").pipe(k)},(e)=>U(_(function*(){let t=yield*Z(void 0,"human");if(!(T(e.name)||T(e.defaultTimezone)))return yield*oe(new $e("Provide --name or --default-timezone."));return yield*C(()=>t.runtime.decode(J,zE({client:t.runtime.client,path:{workspaceId:e.id},body:{...T(e.name)?{name:m(e.name)}:{},...T(e.defaultTimezone)?{defaultTimezone:m(e.defaultTimezone)}:{}},...t.runtime.transport()})))}))).pipe(B(D,["workspaces.update"]),R("Update a workspace you own")),P("archive",{id:se("id").pipe(ce(a.check(N())))},(e)=>U(_(function*(){let t=yield*Z(void 0,"human");return yield*C(()=>t.runtime.decode(J,GE({client:t.runtime.client,path:{workspaceId:e.id},...t.runtime.transport()})))}))).pipe(B(D,["workspaces.archive"]),R("Archive a workspace you own")),P("invites").pipe(R(""),rt([P("list",{workspace:K,status:Te("status",["pending","accepted","revoked","expired"]).pipe(k),cursor:O("cursor").pipe(k),limit:Ke("limit").pipe(k)},(e)=>U(_(function*(){let t=yield*Z(void 0,"human"),r=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,jw({client:t.runtime.client,path:{workspaceId:r},query:{...T(e.status)?{status:m(e.status)}:{},...T(e.cursor)?{cursor:m(e.cursor)}:{},...T(e.limit)?{limit:String(m(e.limit))}:{}},...t.runtime.transport()})))}))).pipe(B(D,["workspaces.invites.list"]),R("List workspace invitations")),P("create",{workspace:K,email:O("email"),role:Te("role",["owner","member"]).pipe(k),idempotencyKey:ct},(e)=>U(_(function*(){let t=yield*Z(void 0,"human"),r=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,zw({client:t.runtime.client,path:{workspaceId:r},body:{email:e.email,...T(e.role)?{role:m(e.role)}:{}},headers:{"idempotency-key":m(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()})))}))).pipe(B(D,["workspaces.invites.create"]),R("Create a workspace invitation")),P("resend",{workspace:K,inviteId:se("invite-id").pipe(ce(a.check(N()))),idempotencyKey:ct},(e)=>U(_(function*(){let t=yield*Z(void 0,"human"),r=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,Qw({client:t.runtime.client,path:{inviteId:e.inviteId,workspaceId:r},headers:{"idempotency-key":m(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()})))}))).pipe(B(D,["workspaces.invites.resend"]),R("Resend a pending invitation email")),P("revoke",{workspace:K,inviteId:se("invite-id").pipe(ce(a.check(N())))},(e)=>U(_(function*(){let t=yield*Z(void 0,"human"),r=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,Hw({client:t.runtime.client,path:{inviteId:e.inviteId,workspaceId:r},...t.runtime.transport()})))}))).pipe(B(D,["workspaces.invites.revoke"]),R("Revoke a pending workspace invitation"))])),P("members").pipe(R(""),rt([P("list",{workspace:K,role:Te("role",["owner","member"]).pipe(k),cursor:O("cursor").pipe(k),limit:Ke("limit").pipe(k)},(e)=>U(_(function*(){let t=yield*Z(void 0,"human"),r=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,$w({client:t.runtime.client,path:{workspaceId:r},query:{...T(e.role)?{role:m(e.role)}:{},...T(e.cursor)?{cursor:m(e.cursor)}:{},...T(e.limit)?{limit:String(m(e.limit))}:{}},...t.runtime.transport()})))}))).pipe(B(D,["workspaces.members.list"]),R("List workspace members")),P("remove",{workspace:K,userId:se("user-id").pipe(ce(a.check(N())))},(e)=>U(_(function*(){let t=yield*Z(void 0,"human"),r=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,Ww({client:t.runtime.client,path:{userId:e.userId,workspaceId:r},...t.runtime.transport()})))}))).pipe(B(D,["workspaces.members.remove"]),R("Remove a workspace member or leave the workspace")),P("update-role",{workspace:K,userId:se("user-id").pipe(ce(a.check(N()))),role:Te("role",["owner","member"])},(e)=>U(_(function*(){let t=yield*Z(void 0,"human"),r=yield*ee(t.client,m(e.workspace),t.selectedWorkspaceId);return yield*C(()=>t.runtime.decode(J,Gw({client:t.runtime.client,path:{userId:e.userId,workspaceId:r},body:{role:e.role},...t.runtime.transport()})))}))).pipe(B(D,["workspaces.members.updateRole"]),R("Update a workspace member's role"))]))];var See=P("use",{id:_$},({id:e})=>U(_(function*(){return yield*(yield*Po()).useWorkspace(e)}))).pipe(B(D,["workspaces.get"]),R("Remember the active workspace for this CLI session.")),E2=P("workspaces").pipe(R("Manage PubNio workspaces."),rt([...I2,See]));var k2=P("pnio").pipe(R("Connect accounts and manage PubNio content."),rt([FW,y2,E2,x2,UW,RW,LW,m2,e2,qW,WW,jW,OW,i2,u2,l2,n2,b2,QW,BW]));var bee=T$(k2,{version:Cl.version}),Ll=process.argv.slice(2),Iee=nr("Cli.presentError")(function*(e){if(e instanceof Ni){if(e.errors.length)process.exitCode=2}else if(e instanceof oo){let t=e.status===401?T(yield*$y)&&Ll[0]!=="api-keys"&&Ll[0]!=="webhooks"&&Ll[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 $e?2:1});await ZP(bee(Ll.length?Ll:["--help"]).pipe(Cr((e)=>Iee(cS(e))),SS(t3),SS(P$),ys(Np,{present:(e)=>e._tag==="InvalidInvocation"?We(()=>console.error(e.errors.map((t)=>t.message).join(`
273
+ `))):Cq.present(e)})));