@linzumi/cli 1.0.342 → 1.0.344

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.
@@ -1,17 +1,17 @@
1
1
  import { createRequire as __linzumiBundleCreateRequire } from 'node:module';
2
2
  const require = __linzumiBundleCreateRequire(import.meta.url);
3
- var Cl=Object.create;var Qn=Object.defineProperty;var Fl=Object.getOwnPropertyDescriptor;var Nl=Object.getOwnPropertyNames;var $l=Object.getPrototypeOf,Il=Object.prototype.hasOwnProperty;var Xe=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof require<"u"?require:t)[r]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var Se=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Pl=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Nl(t))!Il.call(e,i)&&i!==r&&Qn(e,i,{get:()=>t[i],enumerable:!(n=Fl(t,i))||n.enumerable});return e};var Rl=(e,t,r)=>(r=e!=null?Cl($l(e)):{},Pl(t||!e||!e.__esModule?Qn(r,"default",{value:e,enumerable:!0}):r,e));var oi=Se((Rs,ii)=>{var Ye=Xe("constants"),jl=process.cwd,hr=null,Ul=process.env.GRACEFUL_FS_PLATFORM||process.platform;process.cwd=function(){return hr||(hr=jl.call(process)),hr};try{process.cwd()}catch{}typeof process.chdir=="function"&&(Zr=process.chdir,process.chdir=function(e){hr=null,Zr.call(process,e)},Object.setPrototypeOf&&Object.setPrototypeOf(process.chdir,Zr));var Zr;ii.exports=Ll;function Ll(e){Ye.hasOwnProperty("O_SYMLINK")&&process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)&&t(e),e.lutimes||r(e),e.chown=o(e.chown),e.fchown=o(e.fchown),e.lchown=o(e.lchown),e.chmod=n(e.chmod),e.fchmod=n(e.fchmod),e.lchmod=n(e.lchmod),e.chownSync=l(e.chownSync),e.fchownSync=l(e.fchownSync),e.lchownSync=l(e.lchownSync),e.chmodSync=i(e.chmodSync),e.fchmodSync=i(e.fchmodSync),e.lchmodSync=i(e.lchmodSync),e.stat=a(e.stat),e.fstat=a(e.fstat),e.lstat=a(e.lstat),e.statSync=s(e.statSync),e.fstatSync=s(e.fstatSync),e.lstatSync=s(e.lstatSync),e.chmod&&!e.lchmod&&(e.lchmod=function(u,m,c){c&&process.nextTick(c)},e.lchmodSync=function(){}),e.chown&&!e.lchown&&(e.lchown=function(u,m,c,d){d&&process.nextTick(d)},e.lchownSync=function(){}),Ul==="win32"&&(e.rename=typeof e.rename!="function"?e.rename:(function(u){function m(c,d,p){var h=Date.now(),_=0;u(c,d,function y(g){if(g&&(g.code==="EACCES"||g.code==="EPERM"||g.code==="EBUSY")&&Date.now()-h<6e4){setTimeout(function(){e.stat(d,function(S,T){S&&S.code==="ENOENT"?u(c,d,y):p(g)})},_),_<100&&(_+=10);return}p&&p(g)})}return Object.setPrototypeOf&&Object.setPrototypeOf(m,u),m})(e.rename)),e.read=typeof e.read!="function"?e.read:(function(u){function m(c,d,p,h,_,y){var g;if(y&&typeof y=="function"){var S=0;g=function(T,C,N){if(T&&T.code==="EAGAIN"&&S<10)return S++,u.call(e,c,d,p,h,_,g);y.apply(this,arguments)}}return u.call(e,c,d,p,h,_,g)}return Object.setPrototypeOf&&Object.setPrototypeOf(m,u),m})(e.read),e.readSync=typeof e.readSync!="function"?e.readSync:(function(u){return function(m,c,d,p,h){for(var _=0;;)try{return u.call(e,m,c,d,p,h)}catch(y){if(y.code==="EAGAIN"&&_<10){_++;continue}throw y}}})(e.readSync);function t(u){u.lchmod=function(m,c,d){u.open(m,Ye.O_WRONLY|Ye.O_SYMLINK,c,function(p,h){if(p){d&&d(p);return}u.fchmod(h,c,function(_){u.close(h,function(y){d&&d(_||y)})})})},u.lchmodSync=function(m,c){var d=u.openSync(m,Ye.O_WRONLY|Ye.O_SYMLINK,c),p=!0,h;try{h=u.fchmodSync(d,c),p=!1}finally{if(p)try{u.closeSync(d)}catch{}else u.closeSync(d)}return h}}function r(u){Ye.hasOwnProperty("O_SYMLINK")&&u.futimes?(u.lutimes=function(m,c,d,p){u.open(m,Ye.O_SYMLINK,function(h,_){if(h){p&&p(h);return}u.futimes(_,c,d,function(y){u.close(_,function(g){p&&p(y||g)})})})},u.lutimesSync=function(m,c,d){var p=u.openSync(m,Ye.O_SYMLINK),h,_=!0;try{h=u.futimesSync(p,c,d),_=!1}finally{if(_)try{u.closeSync(p)}catch{}else u.closeSync(p)}return h}):u.futimes&&(u.lutimes=function(m,c,d,p){p&&process.nextTick(p)},u.lutimesSync=function(){})}function n(u){return u&&function(m,c,d){return u.call(e,m,c,function(p){f(p)&&(p=null),d&&d.apply(this,arguments)})}}function i(u){return u&&function(m,c){try{return u.call(e,m,c)}catch(d){if(!f(d))throw d}}}function o(u){return u&&function(m,c,d,p){return u.call(e,m,c,d,function(h){f(h)&&(h=null),p&&p.apply(this,arguments)})}}function l(u){return u&&function(m,c,d){try{return u.call(e,m,c,d)}catch(p){if(!f(p))throw p}}}function a(u){return u&&function(m,c,d){typeof c=="function"&&(d=c,c=null);function p(h,_){_&&(_.uid<0&&(_.uid+=4294967296),_.gid<0&&(_.gid+=4294967296)),d&&d.apply(this,arguments)}return c?u.call(e,m,c,p):u.call(e,m,p)}}function s(u){return u&&function(m,c){var d=c?u.call(e,m,c):u.call(e,m);return d&&(d.uid<0&&(d.uid+=4294967296),d.gid<0&&(d.gid+=4294967296)),d}}function f(u){if(!u||u.code==="ENOSYS")return!0;var m=!process.getuid||process.getuid()!==0;return!!(m&&(u.code==="EINVAL"||u.code==="EPERM"))}}});var ai=Se((Ms,ui)=>{var li=Xe("stream").Stream;ui.exports=zl;function zl(e){return{ReadStream:t,WriteStream:r};function t(n,i){if(!(this instanceof t))return new t(n,i);li.call(this);var o=this;this.path=n,this.fd=null,this.readable=!0,this.paused=!1,this.flags="r",this.mode=438,this.bufferSize=64*1024,i=i||{};for(var l=Object.keys(i),a=0,s=l.length;a<s;a++){var f=l[a];this[f]=i[f]}if(this.encoding&&this.setEncoding(this.encoding),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 new Error("start must be <= end");this.pos=this.start}if(this.fd!==null){process.nextTick(function(){o._read()});return}e.open(this.path,this.flags,this.mode,function(u,m){if(u){o.emit("error",u),o.readable=!1;return}o.fd=m,o.emit("open",m),o._read()})}function r(n,i){if(!(this instanceof r))return new r(n,i);li.call(this),this.path=n,this.fd=null,this.writable=!0,this.flags="w",this.encoding="binary",this.mode=438,this.bytesWritten=0,i=i||{};for(var o=Object.keys(i),l=0,a=o.length;l<a;l++){var s=o[l];this[s]=i[s]}if(this.start!==void 0){if(typeof this.start!="number")throw TypeError("start must be a Number");if(this.start<0)throw new Error("start must be >= zero");this.pos=this.start}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 di=Se((Ds,si)=>{"use strict";si.exports=Jl;var ql=Object.getPrototypeOf||function(e){return e.__proto__};function Jl(e){if(e===null||typeof e!="object")return e;if(e instanceof Object)var t={__proto__:ql(e)};else var t=Object.create(null);return Object.getOwnPropertyNames(e).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))}),t}});var tn=Se((js,en)=>{var V=Xe("fs"),Wl=oi(),Bl=ai(),Vl=di(),_r=Xe("util"),le,gr;typeof Symbol=="function"&&typeof Symbol.for=="function"?(le=Symbol.for("graceful-fs.queue"),gr=Symbol.for("graceful-fs.previous")):(le="___graceful-fs.queue",gr="___graceful-fs.previous");function Hl(){}function mi(e,t){Object.defineProperty(e,le,{get:function(){return t}})}var ct=Hl;_r.debuglog?ct=_r.debuglog("gfs4"):/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&(ct=function(){var e=_r.format.apply(_r,arguments);e="GFS4: "+e.split(/\n/).join(`
4
- GFS4: `),console.error(e)});V[le]||(fi=global[le]||[],mi(V,fi),V.close=(function(e){function t(r,n){return e.call(V,r,function(i){i||ci(),typeof n=="function"&&n.apply(this,arguments)})}return Object.defineProperty(t,gr,{value:e}),t})(V.close),V.closeSync=(function(e){function t(r){e.apply(V,arguments),ci()}return Object.defineProperty(t,gr,{value:e}),t})(V.closeSync),/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&process.on("exit",function(){ct(V[le]),Xe("assert").equal(V[le].length,0)}));var fi;global[le]||mi(global,V[le]);en.exports=Yr(Vl(V));process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH&&!V.__patched&&(en.exports=Yr(V),V.__patched=!0);function Yr(e){Wl(e),e.gracefulify=Yr,e.createReadStream=C,e.createWriteStream=N;var t=e.readFile;e.readFile=r;function r(x,b,F){return typeof b=="function"&&(F=b,b=null),J(x,b,F);function J(L,E,v,G){return t(L,E,function(O){O&&(O.code==="EMFILE"||O.code==="ENFILE")?Et([J,[L,E,v],O,G||Date.now(),Date.now()]):typeof v=="function"&&v.apply(this,arguments)})}}var n=e.writeFile;e.writeFile=i;function i(x,b,F,J){return typeof F=="function"&&(J=F,F=null),L(x,b,F,J);function L(E,v,G,O,w){return n(E,v,G,function(k){k&&(k.code==="EMFILE"||k.code==="ENFILE")?Et([L,[E,v,G,O],k,w||Date.now(),Date.now()]):typeof O=="function"&&O.apply(this,arguments)})}}var o=e.appendFile;o&&(e.appendFile=l);function l(x,b,F,J){return typeof F=="function"&&(J=F,F=null),L(x,b,F,J);function L(E,v,G,O,w){return o(E,v,G,function(k){k&&(k.code==="EMFILE"||k.code==="ENFILE")?Et([L,[E,v,G,O],k,w||Date.now(),Date.now()]):typeof O=="function"&&O.apply(this,arguments)})}}var a=e.copyFile;a&&(e.copyFile=s);function s(x,b,F,J){return typeof F=="function"&&(J=F,F=0),L(x,b,F,J);function L(E,v,G,O,w){return a(E,v,G,function(k){k&&(k.code==="EMFILE"||k.code==="ENFILE")?Et([L,[E,v,G,O],k,w||Date.now(),Date.now()]):typeof O=="function"&&O.apply(this,arguments)})}}var f=e.readdir;e.readdir=m;var u=/^v[0-5]\./;function m(x,b,F){typeof b=="function"&&(F=b,b=null);var J=u.test(process.version)?function(v,G,O,w){return f(v,L(v,G,O,w))}:function(v,G,O,w){return f(v,G,L(v,G,O,w))};return J(x,b,F);function L(E,v,G,O){return function(w,k){w&&(w.code==="EMFILE"||w.code==="ENFILE")?Et([J,[E,v,G],w,O||Date.now(),Date.now()]):(k&&k.sort&&k.sort(),typeof G=="function"&&G.call(this,w,k))}}}if(process.version.substr(0,4)==="v0.8"){var c=Bl(e);y=c.ReadStream,S=c.WriteStream}var d=e.ReadStream;d&&(y.prototype=Object.create(d.prototype),y.prototype.open=g);var p=e.WriteStream;p&&(S.prototype=Object.create(p.prototype),S.prototype.open=T),Object.defineProperty(e,"ReadStream",{get:function(){return y},set:function(x){y=x},enumerable:!0,configurable:!0}),Object.defineProperty(e,"WriteStream",{get:function(){return S},set:function(x){S=x},enumerable:!0,configurable:!0});var h=y;Object.defineProperty(e,"FileReadStream",{get:function(){return h},set:function(x){h=x},enumerable:!0,configurable:!0});var _=S;Object.defineProperty(e,"FileWriteStream",{get:function(){return _},set:function(x){_=x},enumerable:!0,configurable:!0});function y(x,b){return this instanceof y?(d.apply(this,arguments),this):y.apply(Object.create(y.prototype),arguments)}function g(){var x=this;K(x.path,x.flags,x.mode,function(b,F){b?(x.autoClose&&x.destroy(),x.emit("error",b)):(x.fd=F,x.emit("open",F),x.read())})}function S(x,b){return this instanceof S?(p.apply(this,arguments),this):S.apply(Object.create(S.prototype),arguments)}function T(){var x=this;K(x.path,x.flags,x.mode,function(b,F){b?(x.destroy(),x.emit("error",b)):(x.fd=F,x.emit("open",F))})}function C(x,b){return new e.ReadStream(x,b)}function N(x,b){return new e.WriteStream(x,b)}var H=e.open;e.open=K;function K(x,b,F,J){return typeof F=="function"&&(J=F,F=null),L(x,b,F,J);function L(E,v,G,O,w){return H(E,v,G,function(k,R){k&&(k.code==="EMFILE"||k.code==="ENFILE")?Et([L,[E,v,G,O],k,w||Date.now(),Date.now()]):typeof O=="function"&&O.apply(this,arguments)})}}return e}function Et(e){ct("ENQUEUE",e[0].name,e[1]),V[le].push(e),Qr()}var yr;function ci(){for(var e=Date.now(),t=0;t<V[le].length;++t)V[le][t].length>2&&(V[le][t][3]=e,V[le][t][4]=e);Qr()}function Qr(){if(clearTimeout(yr),yr=void 0,V[le].length!==0){var e=V[le].shift(),t=e[0],r=e[1],n=e[2],i=e[3],o=e[4];if(i===void 0)ct("RETRY",t.name,r),t.apply(null,r);else if(Date.now()-i>=6e4){ct("TIMEOUT",t.name,r);var l=r.pop();typeof l=="function"&&l.call(null,n)}else{var a=Date.now()-o,s=Math.max(o-i,1),f=Math.min(s*1.2,100);a>=f?(ct("RETRY",t.name,r),t.apply(null,r.concat([i]))):V[le].push(e)}yr===void 0&&(yr=setTimeout(Qr,0))}}});var hi=Se((Us,pi)=>{function we(e,t){typeof t=="boolean"&&(t={forever:t}),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))}pi.exports=we;we.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts};we.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timeouts=[],this._cachedTimeouts=null};we.prototype.retry=function(e){if(this._timeout&&clearTimeout(this._timeout),!e)return!1;var t=new Date().getTime();if(e&&t-this._operationStart>=this._maxRetryTime)return this._errors.unshift(new 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,i=setTimeout(function(){n._attempts++,n._operationTimeoutCb&&(n._timeout=setTimeout(function(){n._operationTimeoutCb(n._attempts)},n._operationTimeout),n._options.unref&&n._timeout.unref()),n._fn(n._attempts)},r);return this._options.unref&&i.unref(),!0};we.prototype.attempt=function(e,t){this._fn=e,t&&(t.timeout&&(this._operationTimeout=t.timeout),t.cb&&(this._operationTimeoutCb=t.cb));var r=this;this._operationTimeoutCb&&(this._timeout=setTimeout(function(){r._operationTimeoutCb()},r._operationTimeout)),this._operationStart=new Date().getTime(),this._fn(this._attempts)};we.prototype.try=function(e){console.log("Using RetryOperation.try() is deprecated"),this.attempt(e)};we.prototype.start=function(e){console.log("Using RetryOperation.start() is deprecated"),this.attempt(e)};we.prototype.start=we.prototype.try;we.prototype.errors=function(){return this._errors};we.prototype.attempts=function(){return this._attempts};we.prototype.mainError=function(){if(this._errors.length===0)return null;for(var e={},t=null,r=0,n=0;n<this._errors.length;n++){var i=this._errors[n],o=i.message,l=(e[o]||0)+1;e[o]=l,l>=r&&(t=i,r=l)}return t}});var _i=Se(mt=>{var Kl=hi();mt.operation=function(e){var t=mt.timeouts(e);return new Kl(t,{forever:e&&e.forever,unref:e&&e.unref,maxRetryTime:e&&e.maxRetryTime})};mt.timeouts=function(e){if(e instanceof Array)return[].concat(e);var t={retries:10,factor:2,minTimeout:1*1e3,maxTimeout:1/0,randomize:!1};for(var r in e)t[r]=e[r];if(t.minTimeout>t.maxTimeout)throw new Error("minTimeout is greater than maxTimeout");for(var n=[],i=0;i<t.retries;i++)n.push(this.createTimeout(i,t));return e&&e.forever&&!n.length&&n.push(this.createTimeout(i,t)),n.sort(function(o,l){return o-l}),n};mt.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};mt.wrap=function(e,t,r){if(t instanceof Array&&(r=t,t=null),!r){r=[];for(var n in e)typeof e[n]=="function"&&r.push(n)}for(var i=0;i<r.length;i++){var o=r[i],l=e[o];e[o]=function(s){var f=mt.operation(t),u=Array.prototype.slice.call(arguments,1),m=u.pop();u.push(function(c){f.retry(c)||(c&&(arguments[0]=f.mainError()),m.apply(this,arguments))}),f.attempt(function(){s.apply(e,u)})}.bind(e,l),e[o].options=t}}});var gi=Se((zs,yi)=>{yi.exports=_i()});var Si=Se((qs,Sr)=>{Sr.exports=["SIGABRT","SIGALRM","SIGHUP","SIGINT","SIGTERM"];process.platform!=="win32"&&Sr.exports.push("SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Sr.exports.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT","SIGUNUSED")});var Oi=Se((Js,Gt)=>{var W=global.process,pt=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"};pt(W)?(Ti=Xe("assert"),kt=Si(),Ai=/^win/i.test(W.platform),Bt=Xe("events"),typeof Bt!="function"&&(Bt=Bt.EventEmitter),W.__signal_exit_emitter__?re=W.__signal_exit_emitter__:(re=W.__signal_exit_emitter__=new Bt,re.count=0,re.emitted={}),re.infinite||(re.setMaxListeners(1/0),re.infinite=!0),Gt.exports=function(e,t){if(!pt(global.process))return function(){};Ti.equal(typeof e,"function","a callback must be provided for exit handler"),bt===!1&&rn();var r="exit";t&&t.alwaysLast&&(r="afterexit");var n=function(){re.removeListener(r,e),re.listeners("exit").length===0&&re.listeners("afterexit").length===0&&Tr()};return re.on(r,e),n},Tr=function(){!bt||!pt(global.process)||(bt=!1,kt.forEach(function(t){try{W.removeListener(t,Ar[t])}catch{}}),W.emit=vr,W.reallyExit=nn,re.count-=1)},Gt.exports.unload=Tr,ht=function(t,r,n){re.emitted[t]||(re.emitted[t]=!0,re.emit(t,r,n))},Ar={},kt.forEach(function(e){Ar[e]=function(){if(pt(global.process)){var r=W.listeners(e);r.length===re.count&&(Tr(),ht("exit",null,e),ht("afterexit",null,e),Ai&&e==="SIGHUP"&&(e="SIGINT"),W.kill(W.pid,e))}}}),Gt.exports.signals=function(){return kt},bt=!1,rn=function(){bt||!pt(global.process)||(bt=!0,re.count+=1,kt=kt.filter(function(t){try{return W.on(t,Ar[t]),!0}catch{return!1}}),W.emit=wi,W.reallyExit=vi)},Gt.exports.load=rn,nn=W.reallyExit,vi=function(t){pt(global.process)&&(W.exitCode=t||0,ht("exit",W.exitCode,null),ht("afterexit",W.exitCode,null),nn.call(W,W.exitCode))},vr=W.emit,wi=function(t,r){if(t==="exit"&&pt(global.process)){r!==void 0&&(W.exitCode=r);var n=vr.apply(this,arguments);return ht("exit",W.exitCode,null),ht("afterexit",W.exitCode,null),n}else return vr.apply(this,arguments)}):Gt.exports=function(){return function(){}};var Ti,kt,Ai,Bt,re,Tr,ht,Ar,bt,rn,nn,vi,vr,wi});var Gi=Se((Ws,Vt)=>{"use strict";var Xl=Xe("path"),un=tn(),Zl=gi(),Yl=Oi(),Ue={};function Ct(e,t){return t.lockfilePath||`${e}.lock`}function an(e,t,r){if(!t.realpath)return r(null,Xl.resolve(e));t.fs.realpath(e,r)}function on(e,t,r){t.fs.mkdir(Ct(e,t),n=>{if(!n)return r();if(n.code!=="EEXIST")return r(n);if(t.stale<=0)return r(Object.assign(new Error("Lock file is already being hold"),{code:"ELOCKED",file:e}));t.fs.stat(Ct(e,t),(i,o)=>{if(i)return i.code==="ENOENT"?on(e,{...t,stale:0},r):r(i);if(!Ei(o,t))return r(Object.assign(new Error("Lock file is already being hold"),{code:"ELOCKED",file:e}));ki(e,t,l=>{if(l)return r(l);on(e,{...t,stale:0},r)})})})}function Ei(e,t){return e.mtime.getTime()<Date.now()-t.stale}function ki(e,t,r){t.fs.rmdir(Ct(e,t),n=>{if(n&&n.code!=="ENOENT")return r(n);r()})}function ln(e,t){let r=Ue[e];r.updateTimeout||(r.updateDelay=r.updateDelay||t.update,r.updateTimeout=setTimeout(()=>{let n=Date.now()/1e3;r.updateTimeout=null,t.fs.utimes(Ct(e,t),n,n,i=>{if(!r.released){if(r.lastUpdate<=Date.now()-t.stale&&r.lastUpdate>Date.now()-t.stale*2){let o=Object.assign(new Error(r.updateError||"Unable to update lock within the stale threshold"),{code:"ECOMPROMISED"});return xi(e,r,o)}if(i)return i.code==="ENOENT"?xi(e,r,Object.assign(i,{code:"ECOMPROMISED"})):(r.updateError=i,r.updateDelay=1e3,ln(e,t));r.lastUpdate=Date.now(),r.updateError=null,r.updateDelay=null,ln(e,t)}})},r.updateDelay),r.updateTimeout.unref&&r.updateTimeout.unref())}function xi(e,t,r){t.released=!0,t.updateTimeout&&clearTimeout(t.updateTimeout),Ue[e]===t&&delete Ue[e],t.options.onCompromised(r)}function Ql(e,t,r){t={stale:1e4,update:null,realpath:!0,retries:0,fs:un,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,2e3),t.update=t.update==null?t.stale/2:t.update||0,t.update=Math.max(Math.min(t.update,t.stale/2),1e3),an(e,t,(n,i)=>{if(n)return r(n);let o=Zl.operation(t.retries);o.attempt(()=>{on(i,t,l=>{if(o.retry(l))return;if(l)return r(o.mainError());let a=Ue[i]={options:t,lastUpdate:Date.now()};ln(i,t),r(null,s=>{if(a.released)return s&&s(Object.assign(new Error("Lock is already released"),{code:"ERELEASED"}));bi(i,{...t,realpath:!1},s)})})})})}function bi(e,t,r){t={fs:un,realpath:!0,...t},an(e,t,(n,i)=>{if(n)return r(n);let o=Ue[i];if(!o)return r(Object.assign(new Error("Lock is not acquired/owned by you"),{code:"ENOTACQUIRED"}));o.updateTimeout&&clearTimeout(o.updateTimeout),o.released=!0,delete Ue[i],ki(i,t,r)})}function eu(e,t,r){t={stale:1e4,realpath:!0,fs:un,...t},t.stale=Math.max(t.stale||0,2e3),an(e,t,(n,i)=>{if(n)return r(n);t.fs.stat(Ct(i,t),(o,l)=>o?o.code==="ENOENT"?r(null,!1):r(o):r(null,!Ei(l,t)))})}function tu(){return Ue}Yl(()=>{for(let e in Ue){let t=Ue[e].options;try{t.fs.rmdirSync(Ct(e,t))}catch{}}});Vt.exports.lock=Ql;Vt.exports.unlock=bi;Vt.exports.check=eu;Vt.exports.getLocks=tu});var Fi=Se((Bs,Ci)=>{"use strict";var ru=tn();function nu(e){let t=["mkdir","realpath","stat","rmdir","utimes"],r={...e};return t.forEach(n=>{r[n]=(...i)=>{let o=i.pop(),l;try{l=e[`${n}Sync`](...i)}catch(a){return o(a)}o(null,l)}}),r}function iu(e){return(...t)=>new Promise((r,n)=>{t.push((i,o)=>{i?n(i):r(o)}),e(...t)})}function ou(e){return(...t)=>{let r,n;if(t.push((i,o)=>{r=i,n=o}),e(...t),r)throw r;return n}}function lu(e){if(e={...e},e.fs=nu(e.fs||ru),typeof e.retries=="number"&&e.retries>0||e.retries&&typeof e.retries.retries=="number"&&e.retries.retries>0)throw Object.assign(new Error("Cannot use retries with the sync api"),{code:"ESYNC"});return e}Ci.exports={toPromise:iu,toSync:ou,toSyncOptions:lu}});var $i=Se((Vs,Qe)=>{"use strict";var Ft=Gi(),{toPromise:wr,toSync:Or,toSyncOptions:sn}=Fi();async function Ni(e,t){let r=await wr(Ft.lock)(e,t);return wr(r)}function uu(e,t){let r=Or(Ft.lock)(e,sn(t));return Or(r)}function au(e,t){return wr(Ft.unlock)(e,t)}function su(e,t){return Or(Ft.unlock)(e,sn(t))}function du(e,t){return wr(Ft.check)(e,t)}function fu(e,t){return Or(Ft.check)(e,sn(t))}Qe.exports=Ni;Qe.exports.lock=Ni;Qe.exports.unlock=au;Qe.exports.lockSync=uu;Qe.exports.unlockSync=su;Qe.exports.check=du;Qe.exports.checkSync=fu});import*as vl from"node:crypto";function Te(e){return e===void 0?{BS_PRIVATE_NESTED_SOME_NONE:0}:e!==null&&e.BS_PRIVATE_NESTED_SOME_NONE!==void 0?{BS_PRIVATE_NESTED_SOME_NONE:e.BS_PRIVATE_NESTED_SOME_NONE+1|0}:e}function Ze(e){if(e!=null)return Te(e)}function D(e){if(e===null||e.BS_PRIVATE_NESTED_SOME_NONE===void 0)return e;let t=e.BS_PRIVATE_NESTED_SOME_NONE;if(t!==0)return{BS_PRIVATE_NESTED_SOME_NONE:t-1|0}}function Hr(e,t,r){return e.reduce(r,t)}function De(e,t){let r=e.length,n=new Array(r),i=0;for(let o=0;o<r;++o){let l=e[o],a=t(l);a!==void 0&&(n[i]=D(a),i=i+1|0)}return n.length=i,n}function Ce(e){if(e.RE_EXN_ID==="JsExn")return Te(e._1)}var pr=(e=>t=>t&&typeof t[e]=="string"?t[e]:void 0),$s=pr("stack"),Ae=pr("message"),Is=pr("name"),Ps=pr("fileName");import*as I from"node:fs";import*as xr from"node:crypto";function ve(e,t){if(e!==void 0)return Te(t(D(e)))}function q(e,t){if(e!==void 0)return t(D(e))}function $(e,t){return e!==void 0?D(e):t}function Kr(e,t){return e!==void 0?e:t}function ri(e){return e===void 0}function Xr(e,t){let r=e.indexOf(t);if(r!==-1)return r}var hu=Rl($i(),1);var Ii=(function(e,t){for(var r in e)t(r)});function Nt(e,t){if(e===t)return!0;let r=typeof e;if(r==="string"||r==="number"||r==="bigint"||r==="boolean"||r==="undefined"||e===null)return!1;let n=typeof t;if(r==="function"||n==="function")throw{RE_EXN_ID:"Invalid_argument",_1:"equal: functional value",Error:new Error};if(n==="number"||n==="bigint"||n==="undefined"||t===null)return!1;let i=e.TAG,o=t.TAG;if(i!==o)return!1;let l=e.length|0,a=t.length|0;if(l===a)if(Array.isArray(e)){let s=0;for(;;){let f=s;if(f===l)return!0;if(!Nt(e[f],t[f]))return!1;s=f+1|0}}else{if(e instanceof Date&&t instanceof Date)return!(e>t||e<t);{let s={contents:!0},f=m=>{if(!Object.prototype.hasOwnProperty.call(t,m)){s.contents=!1;return}},u=m=>{if(!Object.prototype.hasOwnProperty.call(e,m)||!Nt(t[m],e[m])){s.contents=!1;return}};return Ii(e,f),s.contents&&Ii(t,u),s.contents}}else return!1}import*as Di from"node:child_process";function pu(e){return e==null?!1:typeof e.RE_EXN_ID=="string"}function j(e){return pu(e)?e:{RE_EXN_ID:"JsExn",_1:e}}var fn={};function Mi(e){let t=fn[e];if(t!==void 0){let r=t+1|0;return fn[e]=r,e+("/"+r)}return fn[e]=1,e}function ze(e){let t=Ce(e);if(t===void 0)return{code:void 0,message:"unknown error"};let r=D(t);return{code:Ze(r.code),message:$(Ae(r),"unknown error")}}function ji(e,t){return Nt(e.code,t)}function et(e){try{return{TAG:"Ok",_0:I.readFileSync(e,"utf8")}}catch(t){let r=j(t);return{TAG:"Error",_0:ze(r)}}}function Ht(e,t,r){try{return{TAG:"Ok",_0:(I.writeFileSync(e,t,r),void 0)}}catch(n){let i=j(n);return{TAG:"Error",_0:ze(i)}}}function Kt(e){try{return{TAG:"Ok",_0:(I.mkdirSync(e,{recursive:!0}),void 0)}}catch(t){let r=j(t);return{TAG:"Error",_0:ze(r)}}}function cn(e,t){try{return{TAG:"Ok",_0:(I.chmodSync(e,t),void 0)}}catch(r){let n=j(r);return{TAG:"Error",_0:ze(n)}}}function Ui(e,t){try{return{TAG:"Ok",_0:(I.linkSync(e,t),void 0)}}catch(r){let n=j(r);return{TAG:"Error",_0:ze(n)}}}function Li(e){try{return{TAG:"Ok",_0:(I.unlinkSync(e),void 0)}}catch(t){let r=j(t);return{TAG:"Error",_0:ze(r)}}}function zi(e,t){try{return{TAG:"Ok",_0:(I.renameSync(e,t),void 0)}}catch(r){let n=j(r);return{TAG:"Error",_0:ze(n)}}}function qi(e){try{return{TAG:"Ok",_0:(I.rmSync(e,{force:!0}),void 0)}}catch(t){let r=j(t);return{TAG:"Error",_0:ze(r)}}}function Ji(e){return xr.createHash("sha256").update(e).digest("hex")}function Wi(e){try{return xr.randomBytes(e).toString("hex")}catch{return""}}function Bi(e,t,r,n){try{return{TAG:"Ok",_0:Di.execFileSync(e,t,{encoding:"utf8",timeout:r,maxBuffer:n})}}catch(i){let o=j(i);return{TAG:"Error",_0:ze(o)}}}function tt(e){try{return process.stderr.write(e)}catch{return!1}}function Xt(e,t){return e[t]}function $t(e){try{return Te(new URL(e))}catch{return}}function Vi(e){return e.keys().toArray()}function qe(e,t){try{return{TAG:"Ok",_0:new URL(e,t)}}catch(r){let n=j(r),i=Ce(n);return{TAG:"Error",_0:i!==void 0?$(Ae(D(i)),"unknown error"):"unknown error"}}}function X(e,t){return e.TAG==="Ok"?{TAG:"Ok",_0:t(e._0)}:e}function P(e,t){return e.TAG==="Ok"?t(e._0):e}function U(e,t){return e.TAG==="Ok"?e:{TAG:"Error",_0:t(e._0)}}var _u="--api-url must be ws://, wss://, http://, or https://";function ce(e){let t=$t(e);if(t===void 0)return{TAG:"Error",_0:"invalid URL: "+e};let r=D(t),n=r.protocol,i;switch(n){case"http:":case"https:":i={TAG:"Ok",_0:void 0};break;case"ws:":r.protocol="http:",i={TAG:"Ok",_0:void 0};break;case"wss:":r.protocol="https:",i={TAG:"Ok",_0:void 0};break;default:i={TAG:"Error",_0:_u}}return X(i,()=>{r.pathname="",r.search="",r.hash="";let o=r.toString();return o.endsWith("/")?o.slice(0,o.length-1|0):o})}var Zt="wss://serve.linzumi.com";import*as pl from"node:os";var Zi={},Mr=[],Su=(e=>({...e}));function Ut(e){let t=0;for(;;){let r=t,n=e[r];if(n===void 0)return'"'+e+'"';switch(n){case'"':case`
5
- `:return JSON.stringify(e);default:t=r+1|0;continue}}}function Tu(e){return e===""?[]:JSON.parse(e.split('"]["').join('","'))}function Au(e){return"["+Ut(e)+"]"}function vu(e){let t=e.length;return t!==1?t!==0?e.map(Au).join(""):"":"["+Ut(e[0])+"]"}var Sn="sury",Tn=Symbol(Sn),An=Symbol(Sn+":item"),Rt="string",ot="number",wu="bigint",Ou="boolean",xu="symbol",Mt="null",$e="undefined",_n="nan";var vn="instance",yt="array",ie="object",lt="union",yn="never",or="unknown",Eu="ref",wn=Mi("Sury.Exn"),Ie="const";function ku(e){return e.type===$e?!0:e.type===lt?$e in e.has:!1}function bu(e,t){return(e&t)!==0}var Y={[or]:1,[Rt]:2,[ot]:4,[Ou]:8,[$e]:16,[Mt]:32,[ie]:64,[yt]:128,[lt]:256,[Eu]:512,[wu]:1024,[_n]:2048,function:4096,[vn]:8192,[yn]:32768,[xu]:16384};function br(e){let t=Y[typeof e];if(t&16)return $e;if(!(t&64))return t&2?'"'+e+'"':t&1024?e+"n":t&4096?"Function":e.toString();if(e===null)return Mt;if(Array.isArray(e)){let i="[";for(let o=0,l=e.length;o<l;++o)o!==0&&(i=i+", "),i=i+br(e[o]);return i+"]"}if(e.constructor!==Object)return Object.prototype.toString.call(e);let r=Object.keys(e),n="{ ";for(let i=0,o=r.length;i<o;++i){let l=r[i],a=e[l];n=n+l+": "+br(a)+"; "}return n+"}"}function Z(e){let t=e.type,r=e.to,n=e.const,i=e.name;if(i!==void 0)return i;if(n!==void 0)return br(n);let o=e.format,l=e.anyOf;if(l!==void 0)return l.map(Z).join(" | ");if(o!==void 0){if(o!=="compactColumns")return o;let a=e.additionalItems;if(r===void 0)return a!==void 0&&a!=="strip"&&a!=="strict"?Z(a)+"[]":"unknown[][]";let s=r.properties;return s===void 0?"unknown[][]":"["+Object.keys(s).map(u=>{let m=s[u];return Z(m)+"[]"}).join(", ")+"]"}switch(t){case"nan":return"NaN";case"object":let a=e.additionalItems,s=e.properties,f=Object.keys(s);return f.length===0?typeof a===ie?"{ [key: string]: "+Z(a)+"; }":"{}":"{ "+f.map(u=>u+": "+Z(s[u])+";").join(" ")+" }";default:if(e.b)return t;switch(t){case"instance":return e.class.name;case"array":let u=e.additionalItems,m=e.items;if(typeof u!==ie)return"["+m.map(Z).join(", ")+"]";let c=Z(u);return(u.type===lt?"("+c+")":c)+"[]";default:return t}}}var gt=class extends Error{constructor(t){super();for(let r in t)this[r]=t[r]}},ke=Object.defineProperty,lr=gt.prototype;ke(lr,"message",{get(){return Qi(this)}});ke(lr,"name",{value:"SuryError"});ke(lr,"s",{value:Tn});ke(lr,"_1",{get(){return this}});ke(lr,"RE_EXN_ID",{value:wn});var Yi=1,On=function(){},xn=Object.create(null);ke(xn,"with",{get(){return(e,...t)=>e(this,...t)}});On.prototype=xn;function Dr(e){if(e&&e.s===Tn)return e;throw e}function Qi(e){let t=e.path;return(t===""?"":"Failed at "+t+": ")+e.reason}var Yt={m:Qi,d:void 0,a:"strip",f:0},nt={};var Gr="value",It="r";function me(e,t){let r=new On;return r.type=e,r.seq=Yi++,t&&(nt[Gr]=r,ke(r,It,nt)),r}function eo(e){return e}var mn={};function Lt(e,t,r){if(mn[e])return mn[e];let n=me(t,!0);return r(n),mn[e]=n,n}var ne=me(or,!0);ne.decoder=eo;var Dt=(e=>{let t=new On;for(let r in e)t[r]=e[r];return t.seq=Yi++,t});function ut(e,t){let r=Dt(e),n=r;for(;n.to;){let i=Dt(n.to);n.to=i,n=i}return t(n),r}function St(e,t){let r=e.g.e,n=r.length;return r[n]=t,"e["+n+"]"}function ur(e,t){let r=Y[t.type],n=t.const;return r&16?"void 0":r&2?Ut(n):r&1024?n+"n":r&28672?St(e,t.const):n}function Tt(e,t){let r='"'+t+'"',n=e[r];if(n!==void 0)return n;let i=Ut(t);return e[r]=i,i}function pe(){return this.i}function Gu(){return this.b.v()}function Cu(){return this.prev.v()}function Oe(e){let t=e.v+1;return e.v=t,"v"+t}function Cr(e,t){e.hd=e.hd===""?t:e.hd+","+t}function Fu(){let e=this,t=Oe(e.g);return e.cp="let "+t+"="+e.i+";",e.i=t,e.v=pe,t}function gn(){let e=this,t=e.p;if(t.fz)return e.v=pe,e.i;let r=Oe(e.g);return Cr(t,r+"="+e.i),e.v=pe,e.i=r,r}function Fr(){let e=this;if(e.fz)return e.v=pe,e.i="("+e.i+")",e.i;let t=Oe(e.g);if(e.prev!==void 0){let n=e.i;n===""?e.cp="let "+t+";"+e.cp:e.cp=e.cp+("let "+t+"="+n+";")}else{let n=e.i;n===""?Cr(e,t):Cr(e,t+"="+n)}return e.v=pe,e.i=t,t}function Nu(e,t,r,n){return{v:pe,i:"i",s:e,e:t,f:0,cp:"",hd:"",path:"",g:{v:-1,o:r,e:[],d:n}}}function ar(e,t,r){let n=e.path,i="Can't decode "+Z(t)+" to "+Z(r)+". Use S.to to define a custom decoder",o={code:"unsupported_decode",path:n,reason:i,from:t,to:r};throw new gt(o)}function Qt(e,t,r){return St(e,n=>{let i=t(n);throw new gt(i)})+"("+r+")"}function to(e,t,r,n,i,o,l){let a=l!==void 0?l:"Expected "+Z(e)+", received "+(i?br(n):Z(t));if(o!==void 0){let f={};for(let u=0,m=o.length;u<m;++u){let c=o[u],d=c.reason.split(`
3
+ var Nl=Object.create;var ei=Object.defineProperty;var $l=Object.getOwnPropertyDescriptor;var Il=Object.getOwnPropertyNames;var Pl=Object.getPrototypeOf,Rl=Object.prototype.hasOwnProperty;var Ze=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof require<"u"?require:t)[r]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var Se=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Ml=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Il(t))!Rl.call(e,i)&&i!==r&&ei(e,i,{get:()=>t[i],enumerable:!(n=$l(t,i))||n.enumerable});return e};var Dl=(e,t,r)=>(r=e!=null?Nl(Pl(e)):{},Ml(t||!e||!e.__esModule?ei(r,"default",{value:e,enumerable:!0}):r,e));var li=Se((Ds,oi)=>{var Qe=Ze("constants"),Ll=process.cwd,_r=null,zl=process.env.GRACEFUL_FS_PLATFORM||process.platform;process.cwd=function(){return _r||(_r=Ll.call(process)),_r};try{process.cwd()}catch{}typeof process.chdir=="function"&&(Yr=process.chdir,process.chdir=function(e){_r=null,Yr.call(process,e)},Object.setPrototypeOf&&Object.setPrototypeOf(process.chdir,Yr));var Yr;oi.exports=ql;function ql(e){Qe.hasOwnProperty("O_SYMLINK")&&process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)&&t(e),e.lutimes||r(e),e.chown=o(e.chown),e.fchown=o(e.fchown),e.lchown=o(e.lchown),e.chmod=n(e.chmod),e.fchmod=n(e.fchmod),e.lchmod=n(e.lchmod),e.chownSync=l(e.chownSync),e.fchownSync=l(e.fchownSync),e.lchownSync=l(e.lchownSync),e.chmodSync=i(e.chmodSync),e.fchmodSync=i(e.fchmodSync),e.lchmodSync=i(e.lchmodSync),e.stat=a(e.stat),e.fstat=a(e.fstat),e.lstat=a(e.lstat),e.statSync=s(e.statSync),e.fstatSync=s(e.fstatSync),e.lstatSync=s(e.lstatSync),e.chmod&&!e.lchmod&&(e.lchmod=function(u,m,c){c&&process.nextTick(c)},e.lchmodSync=function(){}),e.chown&&!e.lchown&&(e.lchown=function(u,m,c,d){d&&process.nextTick(d)},e.lchownSync=function(){}),zl==="win32"&&(e.rename=typeof e.rename!="function"?e.rename:(function(u){function m(c,d,p){var h=Date.now(),_=0;u(c,d,function y(g){if(g&&(g.code==="EACCES"||g.code==="EPERM"||g.code==="EBUSY")&&Date.now()-h<6e4){setTimeout(function(){e.stat(d,function(S,T){S&&S.code==="ENOENT"?u(c,d,y):p(g)})},_),_<100&&(_+=10);return}p&&p(g)})}return Object.setPrototypeOf&&Object.setPrototypeOf(m,u),m})(e.rename)),e.read=typeof e.read!="function"?e.read:(function(u){function m(c,d,p,h,_,y){var g;if(y&&typeof y=="function"){var S=0;g=function(T,C,N){if(T&&T.code==="EAGAIN"&&S<10)return S++,u.call(e,c,d,p,h,_,g);y.apply(this,arguments)}}return u.call(e,c,d,p,h,_,g)}return Object.setPrototypeOf&&Object.setPrototypeOf(m,u),m})(e.read),e.readSync=typeof e.readSync!="function"?e.readSync:(function(u){return function(m,c,d,p,h){for(var _=0;;)try{return u.call(e,m,c,d,p,h)}catch(y){if(y.code==="EAGAIN"&&_<10){_++;continue}throw y}}})(e.readSync);function t(u){u.lchmod=function(m,c,d){u.open(m,Qe.O_WRONLY|Qe.O_SYMLINK,c,function(p,h){if(p){d&&d(p);return}u.fchmod(h,c,function(_){u.close(h,function(y){d&&d(_||y)})})})},u.lchmodSync=function(m,c){var d=u.openSync(m,Qe.O_WRONLY|Qe.O_SYMLINK,c),p=!0,h;try{h=u.fchmodSync(d,c),p=!1}finally{if(p)try{u.closeSync(d)}catch{}else u.closeSync(d)}return h}}function r(u){Qe.hasOwnProperty("O_SYMLINK")&&u.futimes?(u.lutimes=function(m,c,d,p){u.open(m,Qe.O_SYMLINK,function(h,_){if(h){p&&p(h);return}u.futimes(_,c,d,function(y){u.close(_,function(g){p&&p(y||g)})})})},u.lutimesSync=function(m,c,d){var p=u.openSync(m,Qe.O_SYMLINK),h,_=!0;try{h=u.futimesSync(p,c,d),_=!1}finally{if(_)try{u.closeSync(p)}catch{}else u.closeSync(p)}return h}):u.futimes&&(u.lutimes=function(m,c,d,p){p&&process.nextTick(p)},u.lutimesSync=function(){})}function n(u){return u&&function(m,c,d){return u.call(e,m,c,function(p){f(p)&&(p=null),d&&d.apply(this,arguments)})}}function i(u){return u&&function(m,c){try{return u.call(e,m,c)}catch(d){if(!f(d))throw d}}}function o(u){return u&&function(m,c,d,p){return u.call(e,m,c,d,function(h){f(h)&&(h=null),p&&p.apply(this,arguments)})}}function l(u){return u&&function(m,c,d){try{return u.call(e,m,c,d)}catch(p){if(!f(p))throw p}}}function a(u){return u&&function(m,c,d){typeof c=="function"&&(d=c,c=null);function p(h,_){_&&(_.uid<0&&(_.uid+=4294967296),_.gid<0&&(_.gid+=4294967296)),d&&d.apply(this,arguments)}return c?u.call(e,m,c,p):u.call(e,m,p)}}function s(u){return u&&function(m,c){var d=c?u.call(e,m,c):u.call(e,m);return d&&(d.uid<0&&(d.uid+=4294967296),d.gid<0&&(d.gid+=4294967296)),d}}function f(u){if(!u||u.code==="ENOSYS")return!0;var m=!process.getuid||process.getuid()!==0;return!!(m&&(u.code==="EINVAL"||u.code==="EPERM"))}}});var si=Se((js,ai)=>{var ui=Ze("stream").Stream;ai.exports=Jl;function Jl(e){return{ReadStream:t,WriteStream:r};function t(n,i){if(!(this instanceof t))return new t(n,i);ui.call(this);var o=this;this.path=n,this.fd=null,this.readable=!0,this.paused=!1,this.flags="r",this.mode=438,this.bufferSize=64*1024,i=i||{};for(var l=Object.keys(i),a=0,s=l.length;a<s;a++){var f=l[a];this[f]=i[f]}if(this.encoding&&this.setEncoding(this.encoding),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 new Error("start must be <= end");this.pos=this.start}if(this.fd!==null){process.nextTick(function(){o._read()});return}e.open(this.path,this.flags,this.mode,function(u,m){if(u){o.emit("error",u),o.readable=!1;return}o.fd=m,o.emit("open",m),o._read()})}function r(n,i){if(!(this instanceof r))return new r(n,i);ui.call(this),this.path=n,this.fd=null,this.writable=!0,this.flags="w",this.encoding="binary",this.mode=438,this.bytesWritten=0,i=i||{};for(var o=Object.keys(i),l=0,a=o.length;l<a;l++){var s=o[l];this[s]=i[s]}if(this.start!==void 0){if(typeof this.start!="number")throw TypeError("start must be a Number");if(this.start<0)throw new Error("start must be >= zero");this.pos=this.start}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 fi=Se((Us,di)=>{"use strict";di.exports=Bl;var Wl=Object.getPrototypeOf||function(e){return e.__proto__};function Bl(e){if(e===null||typeof e!="object")return e;if(e instanceof Object)var t={__proto__:Wl(e)};else var t=Object.create(null);return Object.getOwnPropertyNames(e).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))}),t}});var rn=Se((Ls,tn)=>{var V=Ze("fs"),Vl=li(),Hl=si(),Kl=fi(),yr=Ze("util"),le,Sr;typeof Symbol=="function"&&typeof Symbol.for=="function"?(le=Symbol.for("graceful-fs.queue"),Sr=Symbol.for("graceful-fs.previous")):(le="___graceful-fs.queue",Sr="___graceful-fs.previous");function Xl(){}function pi(e,t){Object.defineProperty(e,le,{get:function(){return t}})}var mt=Xl;yr.debuglog?mt=yr.debuglog("gfs4"):/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&(mt=function(){var e=yr.format.apply(yr,arguments);e="GFS4: "+e.split(/\n/).join(`
4
+ GFS4: `),console.error(e)});V[le]||(ci=global[le]||[],pi(V,ci),V.close=(function(e){function t(r,n){return e.call(V,r,function(i){i||mi(),typeof n=="function"&&n.apply(this,arguments)})}return Object.defineProperty(t,Sr,{value:e}),t})(V.close),V.closeSync=(function(e){function t(r){e.apply(V,arguments),mi()}return Object.defineProperty(t,Sr,{value:e}),t})(V.closeSync),/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&process.on("exit",function(){mt(V[le]),Ze("assert").equal(V[le].length,0)}));var ci;global[le]||pi(global,V[le]);tn.exports=Qr(Kl(V));process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH&&!V.__patched&&(tn.exports=Qr(V),V.__patched=!0);function Qr(e){Vl(e),e.gracefulify=Qr,e.createReadStream=C,e.createWriteStream=N;var t=e.readFile;e.readFile=r;function r(w,b,F){return typeof b=="function"&&(F=b,b=null),J(w,b,F);function J(L,E,v,G){return t(L,E,function(O){O&&(O.code==="EMFILE"||O.code==="ENFILE")?kt([J,[L,E,v],O,G||Date.now(),Date.now()]):typeof v=="function"&&v.apply(this,arguments)})}}var n=e.writeFile;e.writeFile=i;function i(w,b,F,J){return typeof F=="function"&&(J=F,F=null),L(w,b,F,J);function L(E,v,G,O,x){return n(E,v,G,function(k){k&&(k.code==="EMFILE"||k.code==="ENFILE")?kt([L,[E,v,G,O],k,x||Date.now(),Date.now()]):typeof O=="function"&&O.apply(this,arguments)})}}var o=e.appendFile;o&&(e.appendFile=l);function l(w,b,F,J){return typeof F=="function"&&(J=F,F=null),L(w,b,F,J);function L(E,v,G,O,x){return o(E,v,G,function(k){k&&(k.code==="EMFILE"||k.code==="ENFILE")?kt([L,[E,v,G,O],k,x||Date.now(),Date.now()]):typeof O=="function"&&O.apply(this,arguments)})}}var a=e.copyFile;a&&(e.copyFile=s);function s(w,b,F,J){return typeof F=="function"&&(J=F,F=0),L(w,b,F,J);function L(E,v,G,O,x){return a(E,v,G,function(k){k&&(k.code==="EMFILE"||k.code==="ENFILE")?kt([L,[E,v,G,O],k,x||Date.now(),Date.now()]):typeof O=="function"&&O.apply(this,arguments)})}}var f=e.readdir;e.readdir=m;var u=/^v[0-5]\./;function m(w,b,F){typeof b=="function"&&(F=b,b=null);var J=u.test(process.version)?function(v,G,O,x){return f(v,L(v,G,O,x))}:function(v,G,O,x){return f(v,G,L(v,G,O,x))};return J(w,b,F);function L(E,v,G,O){return function(x,k){x&&(x.code==="EMFILE"||x.code==="ENFILE")?kt([J,[E,v,G],x,O||Date.now(),Date.now()]):(k&&k.sort&&k.sort(),typeof G=="function"&&G.call(this,x,k))}}}if(process.version.substr(0,4)==="v0.8"){var c=Hl(e);y=c.ReadStream,S=c.WriteStream}var d=e.ReadStream;d&&(y.prototype=Object.create(d.prototype),y.prototype.open=g);var p=e.WriteStream;p&&(S.prototype=Object.create(p.prototype),S.prototype.open=T),Object.defineProperty(e,"ReadStream",{get:function(){return y},set:function(w){y=w},enumerable:!0,configurable:!0}),Object.defineProperty(e,"WriteStream",{get:function(){return S},set:function(w){S=w},enumerable:!0,configurable:!0});var h=y;Object.defineProperty(e,"FileReadStream",{get:function(){return h},set:function(w){h=w},enumerable:!0,configurable:!0});var _=S;Object.defineProperty(e,"FileWriteStream",{get:function(){return _},set:function(w){_=w},enumerable:!0,configurable:!0});function y(w,b){return this instanceof y?(d.apply(this,arguments),this):y.apply(Object.create(y.prototype),arguments)}function g(){var w=this;X(w.path,w.flags,w.mode,function(b,F){b?(w.autoClose&&w.destroy(),w.emit("error",b)):(w.fd=F,w.emit("open",F),w.read())})}function S(w,b){return this instanceof S?(p.apply(this,arguments),this):S.apply(Object.create(S.prototype),arguments)}function T(){var w=this;X(w.path,w.flags,w.mode,function(b,F){b?(w.destroy(),w.emit("error",b)):(w.fd=F,w.emit("open",F))})}function C(w,b){return new e.ReadStream(w,b)}function N(w,b){return new e.WriteStream(w,b)}var H=e.open;e.open=X;function X(w,b,F,J){return typeof F=="function"&&(J=F,F=null),L(w,b,F,J);function L(E,v,G,O,x){return H(E,v,G,function(k,R){k&&(k.code==="EMFILE"||k.code==="ENFILE")?kt([L,[E,v,G,O],k,x||Date.now(),Date.now()]):typeof O=="function"&&O.apply(this,arguments)})}}return e}function kt(e){mt("ENQUEUE",e[0].name,e[1]),V[le].push(e),en()}var gr;function mi(){for(var e=Date.now(),t=0;t<V[le].length;++t)V[le][t].length>2&&(V[le][t][3]=e,V[le][t][4]=e);en()}function en(){if(clearTimeout(gr),gr=void 0,V[le].length!==0){var e=V[le].shift(),t=e[0],r=e[1],n=e[2],i=e[3],o=e[4];if(i===void 0)mt("RETRY",t.name,r),t.apply(null,r);else if(Date.now()-i>=6e4){mt("TIMEOUT",t.name,r);var l=r.pop();typeof l=="function"&&l.call(null,n)}else{var a=Date.now()-o,s=Math.max(o-i,1),f=Math.min(s*1.2,100);a>=f?(mt("RETRY",t.name,r),t.apply(null,r.concat([i]))):V[le].push(e)}gr===void 0&&(gr=setTimeout(en,0))}}});var _i=Se((zs,hi)=>{function xe(e,t){typeof t=="boolean"&&(t={forever:t}),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))}hi.exports=xe;xe.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts};xe.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timeouts=[],this._cachedTimeouts=null};xe.prototype.retry=function(e){if(this._timeout&&clearTimeout(this._timeout),!e)return!1;var t=new Date().getTime();if(e&&t-this._operationStart>=this._maxRetryTime)return this._errors.unshift(new 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,i=setTimeout(function(){n._attempts++,n._operationTimeoutCb&&(n._timeout=setTimeout(function(){n._operationTimeoutCb(n._attempts)},n._operationTimeout),n._options.unref&&n._timeout.unref()),n._fn(n._attempts)},r);return this._options.unref&&i.unref(),!0};xe.prototype.attempt=function(e,t){this._fn=e,t&&(t.timeout&&(this._operationTimeout=t.timeout),t.cb&&(this._operationTimeoutCb=t.cb));var r=this;this._operationTimeoutCb&&(this._timeout=setTimeout(function(){r._operationTimeoutCb()},r._operationTimeout)),this._operationStart=new Date().getTime(),this._fn(this._attempts)};xe.prototype.try=function(e){console.log("Using RetryOperation.try() is deprecated"),this.attempt(e)};xe.prototype.start=function(e){console.log("Using RetryOperation.start() is deprecated"),this.attempt(e)};xe.prototype.start=xe.prototype.try;xe.prototype.errors=function(){return this._errors};xe.prototype.attempts=function(){return this._attempts};xe.prototype.mainError=function(){if(this._errors.length===0)return null;for(var e={},t=null,r=0,n=0;n<this._errors.length;n++){var i=this._errors[n],o=i.message,l=(e[o]||0)+1;e[o]=l,l>=r&&(t=i,r=l)}return t}});var yi=Se(pt=>{var Zl=_i();pt.operation=function(e){var t=pt.timeouts(e);return new Zl(t,{forever:e&&e.forever,unref:e&&e.unref,maxRetryTime:e&&e.maxRetryTime})};pt.timeouts=function(e){if(e instanceof Array)return[].concat(e);var t={retries:10,factor:2,minTimeout:1*1e3,maxTimeout:1/0,randomize:!1};for(var r in e)t[r]=e[r];if(t.minTimeout>t.maxTimeout)throw new Error("minTimeout is greater than maxTimeout");for(var n=[],i=0;i<t.retries;i++)n.push(this.createTimeout(i,t));return e&&e.forever&&!n.length&&n.push(this.createTimeout(i,t)),n.sort(function(o,l){return o-l}),n};pt.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};pt.wrap=function(e,t,r){if(t instanceof Array&&(r=t,t=null),!r){r=[];for(var n in e)typeof e[n]=="function"&&r.push(n)}for(var i=0;i<r.length;i++){var o=r[i],l=e[o];e[o]=function(s){var f=pt.operation(t),u=Array.prototype.slice.call(arguments,1),m=u.pop();u.push(function(c){f.retry(c)||(c&&(arguments[0]=f.mainError()),m.apply(this,arguments))}),f.attempt(function(){s.apply(e,u)})}.bind(e,l),e[o].options=t}}});var Si=Se((Js,gi)=>{gi.exports=yi()});var Ti=Se((Ws,Tr)=>{Tr.exports=["SIGABRT","SIGALRM","SIGHUP","SIGINT","SIGTERM"];process.platform!=="win32"&&Tr.exports.push("SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Tr.exports.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT","SIGUNUSED")});var wi=Se((Bs,Ct)=>{var W=global.process,ht=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"};ht(W)?(Ai=Ze("assert"),bt=Ti(),vi=/^win/i.test(W.platform),Vt=Ze("events"),typeof Vt!="function"&&(Vt=Vt.EventEmitter),W.__signal_exit_emitter__?re=W.__signal_exit_emitter__:(re=W.__signal_exit_emitter__=new Vt,re.count=0,re.emitted={}),re.infinite||(re.setMaxListeners(1/0),re.infinite=!0),Ct.exports=function(e,t){if(!ht(global.process))return function(){};Ai.equal(typeof e,"function","a callback must be provided for exit handler"),Gt===!1&&nn();var r="exit";t&&t.alwaysLast&&(r="afterexit");var n=function(){re.removeListener(r,e),re.listeners("exit").length===0&&re.listeners("afterexit").length===0&&Ar()};return re.on(r,e),n},Ar=function(){!Gt||!ht(global.process)||(Gt=!1,bt.forEach(function(t){try{W.removeListener(t,vr[t])}catch{}}),W.emit=xr,W.reallyExit=on,re.count-=1)},Ct.exports.unload=Ar,_t=function(t,r,n){re.emitted[t]||(re.emitted[t]=!0,re.emit(t,r,n))},vr={},bt.forEach(function(e){vr[e]=function(){if(ht(global.process)){var r=W.listeners(e);r.length===re.count&&(Ar(),_t("exit",null,e),_t("afterexit",null,e),vi&&e==="SIGHUP"&&(e="SIGINT"),W.kill(W.pid,e))}}}),Ct.exports.signals=function(){return bt},Gt=!1,nn=function(){Gt||!ht(global.process)||(Gt=!0,re.count+=1,bt=bt.filter(function(t){try{return W.on(t,vr[t]),!0}catch{return!1}}),W.emit=Oi,W.reallyExit=xi)},Ct.exports.load=nn,on=W.reallyExit,xi=function(t){ht(global.process)&&(W.exitCode=t||0,_t("exit",W.exitCode,null),_t("afterexit",W.exitCode,null),on.call(W,W.exitCode))},xr=W.emit,Oi=function(t,r){if(t==="exit"&&ht(global.process)){r!==void 0&&(W.exitCode=r);var n=xr.apply(this,arguments);return _t("exit",W.exitCode,null),_t("afterexit",W.exitCode,null),n}else return xr.apply(this,arguments)}):Ct.exports=function(){return function(){}};var Ai,bt,vi,Vt,re,Ar,_t,vr,Gt,nn,on,xi,xr,Oi});var Ci=Se((Vs,Ht)=>{"use strict";var Yl=Ze("path"),an=rn(),Ql=Si(),eu=wi(),Ue={};function Ft(e,t){return t.lockfilePath||`${e}.lock`}function sn(e,t,r){if(!t.realpath)return r(null,Yl.resolve(e));t.fs.realpath(e,r)}function ln(e,t,r){t.fs.mkdir(Ft(e,t),n=>{if(!n)return r();if(n.code!=="EEXIST")return r(n);if(t.stale<=0)return r(Object.assign(new Error("Lock file is already being hold"),{code:"ELOCKED",file:e}));t.fs.stat(Ft(e,t),(i,o)=>{if(i)return i.code==="ENOENT"?ln(e,{...t,stale:0},r):r(i);if(!ki(o,t))return r(Object.assign(new Error("Lock file is already being hold"),{code:"ELOCKED",file:e}));bi(e,t,l=>{if(l)return r(l);ln(e,{...t,stale:0},r)})})})}function ki(e,t){return e.mtime.getTime()<Date.now()-t.stale}function bi(e,t,r){t.fs.rmdir(Ft(e,t),n=>{if(n&&n.code!=="ENOENT")return r(n);r()})}function un(e,t){let r=Ue[e];r.updateTimeout||(r.updateDelay=r.updateDelay||t.update,r.updateTimeout=setTimeout(()=>{let n=Date.now()/1e3;r.updateTimeout=null,t.fs.utimes(Ft(e,t),n,n,i=>{if(!r.released){if(r.lastUpdate<=Date.now()-t.stale&&r.lastUpdate>Date.now()-t.stale*2){let o=Object.assign(new Error(r.updateError||"Unable to update lock within the stale threshold"),{code:"ECOMPROMISED"});return Ei(e,r,o)}if(i)return i.code==="ENOENT"?Ei(e,r,Object.assign(i,{code:"ECOMPROMISED"})):(r.updateError=i,r.updateDelay=1e3,un(e,t));r.lastUpdate=Date.now(),r.updateError=null,r.updateDelay=null,un(e,t)}})},r.updateDelay),r.updateTimeout.unref&&r.updateTimeout.unref())}function Ei(e,t,r){t.released=!0,t.updateTimeout&&clearTimeout(t.updateTimeout),Ue[e]===t&&delete Ue[e],t.options.onCompromised(r)}function tu(e,t,r){t={stale:1e4,update:null,realpath:!0,retries:0,fs:an,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,2e3),t.update=t.update==null?t.stale/2:t.update||0,t.update=Math.max(Math.min(t.update,t.stale/2),1e3),sn(e,t,(n,i)=>{if(n)return r(n);let o=Ql.operation(t.retries);o.attempt(()=>{ln(i,t,l=>{if(o.retry(l))return;if(l)return r(o.mainError());let a=Ue[i]={options:t,lastUpdate:Date.now()};un(i,t),r(null,s=>{if(a.released)return s&&s(Object.assign(new Error("Lock is already released"),{code:"ERELEASED"}));Gi(i,{...t,realpath:!1},s)})})})})}function Gi(e,t,r){t={fs:an,realpath:!0,...t},sn(e,t,(n,i)=>{if(n)return r(n);let o=Ue[i];if(!o)return r(Object.assign(new Error("Lock is not acquired/owned by you"),{code:"ENOTACQUIRED"}));o.updateTimeout&&clearTimeout(o.updateTimeout),o.released=!0,delete Ue[i],bi(i,t,r)})}function ru(e,t,r){t={stale:1e4,realpath:!0,fs:an,...t},t.stale=Math.max(t.stale||0,2e3),sn(e,t,(n,i)=>{if(n)return r(n);t.fs.stat(Ft(i,t),(o,l)=>o?o.code==="ENOENT"?r(null,!1):r(o):r(null,!ki(l,t)))})}function nu(){return Ue}eu(()=>{for(let e in Ue){let t=Ue[e].options;try{t.fs.rmdirSync(Ft(e,t))}catch{}}});Ht.exports.lock=tu;Ht.exports.unlock=Gi;Ht.exports.check=ru;Ht.exports.getLocks=nu});var Ni=Se((Hs,Fi)=>{"use strict";var iu=rn();function ou(e){let t=["mkdir","realpath","stat","rmdir","utimes"],r={...e};return t.forEach(n=>{r[n]=(...i)=>{let o=i.pop(),l;try{l=e[`${n}Sync`](...i)}catch(a){return o(a)}o(null,l)}}),r}function lu(e){return(...t)=>new Promise((r,n)=>{t.push((i,o)=>{i?n(i):r(o)}),e(...t)})}function uu(e){return(...t)=>{let r,n;if(t.push((i,o)=>{r=i,n=o}),e(...t),r)throw r;return n}}function au(e){if(e={...e},e.fs=ou(e.fs||iu),typeof e.retries=="number"&&e.retries>0||e.retries&&typeof e.retries.retries=="number"&&e.retries.retries>0)throw Object.assign(new Error("Cannot use retries with the sync api"),{code:"ESYNC"});return e}Fi.exports={toPromise:lu,toSync:uu,toSyncOptions:au}});var Ii=Se((Ks,et)=>{"use strict";var Nt=Ci(),{toPromise:Or,toSync:wr,toSyncOptions:dn}=Ni();async function $i(e,t){let r=await Or(Nt.lock)(e,t);return Or(r)}function su(e,t){let r=wr(Nt.lock)(e,dn(t));return wr(r)}function du(e,t){return Or(Nt.unlock)(e,t)}function fu(e,t){return wr(Nt.unlock)(e,dn(t))}function cu(e,t){return Or(Nt.check)(e,t)}function mu(e,t){return wr(Nt.check)(e,dn(t))}et.exports=$i;et.exports.lock=$i;et.exports.unlock=du;et.exports.lockSync=su;et.exports.unlockSync=fu;et.exports.check=cu;et.exports.checkSync=mu});import*as Ol from"node:crypto";function Te(e){return e===void 0?{BS_PRIVATE_NESTED_SOME_NONE:0}:e!==null&&e.BS_PRIVATE_NESTED_SOME_NONE!==void 0?{BS_PRIVATE_NESTED_SOME_NONE:e.BS_PRIVATE_NESTED_SOME_NONE+1|0}:e}function Ye(e){if(e!=null)return Te(e)}function D(e){if(e===null||e.BS_PRIVATE_NESTED_SOME_NONE===void 0)return e;let t=e.BS_PRIVATE_NESTED_SOME_NONE;if(t!==0)return{BS_PRIVATE_NESTED_SOME_NONE:t-1|0}}function Kr(e,t,r){return e.reduce(r,t)}function De(e,t){let r=e.length,n=new Array(r),i=0;for(let o=0;o<r;++o){let l=e[o],a=t(l);a!==void 0&&(n[i]=D(a),i=i+1|0)}return n.length=i,n}function Ce(e){if(e.RE_EXN_ID==="JsExn")return Te(e._1)}var hr=(e=>t=>t&&typeof t[e]=="string"?t[e]:void 0),Ps=hr("stack"),Ae=hr("message"),Rs=hr("name"),Ms=hr("fileName");import*as I from"node:fs";import*as Er from"node:crypto";function ve(e,t){if(e!==void 0)return Te(t(D(e)))}function q(e,t){if(e!==void 0)return t(D(e))}function $(e,t){return e!==void 0?D(e):t}function Xr(e,t){return e!==void 0?e:t}function ni(e){return e===void 0}function Zr(e,t){let r=e.indexOf(t);if(r!==-1)return r}var yu=Dl(Ii(),1);var Pi=(function(e,t){for(var r in e)t(r)});function $t(e,t){if(e===t)return!0;let r=typeof e;if(r==="string"||r==="number"||r==="bigint"||r==="boolean"||r==="undefined"||e===null)return!1;let n=typeof t;if(r==="function"||n==="function")throw{RE_EXN_ID:"Invalid_argument",_1:"equal: functional value",Error:new Error};if(n==="number"||n==="bigint"||n==="undefined"||t===null)return!1;let i=e.TAG,o=t.TAG;if(i!==o)return!1;let l=e.length|0,a=t.length|0;if(l===a)if(Array.isArray(e)){let s=0;for(;;){let f=s;if(f===l)return!0;if(!$t(e[f],t[f]))return!1;s=f+1|0}}else{if(e instanceof Date&&t instanceof Date)return!(e>t||e<t);{let s={contents:!0},f=m=>{if(!Object.prototype.hasOwnProperty.call(t,m)){s.contents=!1;return}},u=m=>{if(!Object.prototype.hasOwnProperty.call(e,m)||!$t(t[m],e[m])){s.contents=!1;return}};return Pi(e,f),s.contents&&Pi(t,u),s.contents}}else return!1}import*as ji from"node:child_process";function _u(e){return e==null?!1:typeof e.RE_EXN_ID=="string"}function j(e){return _u(e)?e:{RE_EXN_ID:"JsExn",_1:e}}var cn={};function Di(e){let t=cn[e];if(t!==void 0){let r=t+1|0;return cn[e]=r,e+("/"+r)}return cn[e]=1,e}function ze(e){let t=Ce(e);if(t===void 0)return{code:void 0,message:"unknown error"};let r=D(t);return{code:Ye(r.code),message:$(Ae(r),"unknown error")}}function Ui(e,t){return $t(e.code,t)}function tt(e){try{return{TAG:"Ok",_0:I.readFileSync(e,"utf8")}}catch(t){let r=j(t);return{TAG:"Error",_0:ze(r)}}}function Kt(e,t,r){try{return{TAG:"Ok",_0:(I.writeFileSync(e,t,r),void 0)}}catch(n){let i=j(n);return{TAG:"Error",_0:ze(i)}}}function Xt(e){try{return{TAG:"Ok",_0:(I.mkdirSync(e,{recursive:!0}),void 0)}}catch(t){let r=j(t);return{TAG:"Error",_0:ze(r)}}}function mn(e,t){try{return{TAG:"Ok",_0:(I.chmodSync(e,t),void 0)}}catch(r){let n=j(r);return{TAG:"Error",_0:ze(n)}}}function Li(e,t){try{return{TAG:"Ok",_0:(I.linkSync(e,t),void 0)}}catch(r){let n=j(r);return{TAG:"Error",_0:ze(n)}}}function zi(e){try{return{TAG:"Ok",_0:(I.unlinkSync(e),void 0)}}catch(t){let r=j(t);return{TAG:"Error",_0:ze(r)}}}function qi(e,t){try{return{TAG:"Ok",_0:(I.renameSync(e,t),void 0)}}catch(r){let n=j(r);return{TAG:"Error",_0:ze(n)}}}function Ji(e){try{return{TAG:"Ok",_0:(I.rmSync(e,{force:!0}),void 0)}}catch(t){let r=j(t);return{TAG:"Error",_0:ze(r)}}}function Wi(e){return Er.createHash("sha256").update(e).digest("hex")}function Bi(e){try{return Er.randomBytes(e).toString("hex")}catch{return""}}function Vi(e,t,r,n){try{return{TAG:"Ok",_0:ji.execFileSync(e,t,{encoding:"utf8",timeout:r,maxBuffer:n})}}catch(i){let o=j(i);return{TAG:"Error",_0:ze(o)}}}function rt(e){try{return process.stderr.write(e)}catch{return!1}}function Zt(e,t){return e[t]}function It(e){try{return Te(new URL(e))}catch{return}}function Hi(e){return e.keys().toArray()}function qe(e,t){try{return{TAG:"Ok",_0:new URL(e,t)}}catch(r){let n=j(r),i=Ce(n);return{TAG:"Error",_0:i!==void 0?$(Ae(D(i)),"unknown error"):"unknown error"}}}function Z(e,t){return e.TAG==="Ok"?{TAG:"Ok",_0:t(e._0)}:e}function P(e,t){return e.TAG==="Ok"?t(e._0):e}function U(e,t){return e.TAG==="Ok"?e:{TAG:"Error",_0:t(e._0)}}var gu="--api-url must be ws://, wss://, http://, or https://";function ce(e){let t=It(e);if(t===void 0)return{TAG:"Error",_0:"invalid URL: "+e};let r=D(t),n=r.protocol,i;switch(n){case"http:":case"https:":i={TAG:"Ok",_0:void 0};break;case"ws:":r.protocol="http:",i={TAG:"Ok",_0:void 0};break;case"wss:":r.protocol="https:",i={TAG:"Ok",_0:void 0};break;default:i={TAG:"Error",_0:gu}}return Z(i,()=>{r.pathname="",r.search="",r.hash="";let o=r.toString();return o.endsWith("/")?o.slice(0,o.length-1|0):o})}var Yt="wss://serve.linzumi.com";import*as _l from"node:os";var Yi={},Dr=[],Au=(e=>({...e}));function Lt(e){let t=0;for(;;){let r=t,n=e[r];if(n===void 0)return'"'+e+'"';switch(n){case'"':case`
5
+ `:return JSON.stringify(e);default:t=r+1|0;continue}}}function vu(e){return e===""?[]:JSON.parse(e.split('"]["').join('","'))}function xu(e){return"["+Lt(e)+"]"}function Ou(e){let t=e.length;return t!==1?t!==0?e.map(xu).join(""):"":"["+Lt(e[0])+"]"}var Tn="sury",An=Symbol(Tn),vn=Symbol(Tn+":item"),Mt="string",lt="number",wu="bigint",Eu="boolean",ku="symbol",Dt="null",$e="undefined",yn="nan";var xn="instance",gt="array",ie="object",ut="union",gn="never",lr="unknown",bu="ref",On=Di("Sury.Exn"),Ie="const";function Gu(e){return e.type===$e?!0:e.type===ut?$e in e.has:!1}function Cu(e,t){return(e&t)!==0}var Y={[lr]:1,[Mt]:2,[lt]:4,[Eu]:8,[$e]:16,[Dt]:32,[ie]:64,[gt]:128,[ut]:256,[bu]:512,[wu]:1024,[yn]:2048,function:4096,[xn]:8192,[gn]:32768,[ku]:16384};function Gr(e){let t=Y[typeof e];if(t&16)return $e;if(!(t&64))return t&2?'"'+e+'"':t&1024?e+"n":t&4096?"Function":e.toString();if(e===null)return Dt;if(Array.isArray(e)){let i="[";for(let o=0,l=e.length;o<l;++o)o!==0&&(i=i+", "),i=i+Gr(e[o]);return i+"]"}if(e.constructor!==Object)return Object.prototype.toString.call(e);let r=Object.keys(e),n="{ ";for(let i=0,o=r.length;i<o;++i){let l=r[i],a=e[l];n=n+l+": "+Gr(a)+"; "}return n+"}"}function K(e){let t=e.type,r=e.to,n=e.const,i=e.name;if(i!==void 0)return i;if(n!==void 0)return Gr(n);let o=e.format,l=e.anyOf;if(l!==void 0)return l.map(K).join(" | ");if(o!==void 0){if(o!=="compactColumns")return o;let a=e.additionalItems;if(r===void 0)return a!==void 0&&a!=="strip"&&a!=="strict"?K(a)+"[]":"unknown[][]";let s=r.properties;return s===void 0?"unknown[][]":"["+Object.keys(s).map(u=>{let m=s[u];return K(m)+"[]"}).join(", ")+"]"}switch(t){case"nan":return"NaN";case"object":let a=e.additionalItems,s=e.properties,f=Object.keys(s);return f.length===0?typeof a===ie?"{ [key: string]: "+K(a)+"; }":"{}":"{ "+f.map(u=>u+": "+K(s[u])+";").join(" ")+" }";default:if(e.b)return t;switch(t){case"instance":return e.class.name;case"array":let u=e.additionalItems,m=e.items;if(typeof u!==ie)return"["+m.map(K).join(", ")+"]";let c=K(u);return(u.type===ut?"("+c+")":c)+"[]";default:return t}}}var St=class extends Error{constructor(t){super();for(let r in t)this[r]=t[r]}},ke=Object.defineProperty,ur=St.prototype;ke(ur,"message",{get(){return eo(this)}});ke(ur,"name",{value:"SuryError"});ke(ur,"s",{value:An});ke(ur,"_1",{get(){return this}});ke(ur,"RE_EXN_ID",{value:On});var Qi=1,wn=function(){},En=Object.create(null);ke(En,"with",{get(){return(e,...t)=>e(this,...t)}});wn.prototype=En;function jr(e){if(e&&e.s===An)return e;throw e}function eo(e){let t=e.path;return(t===""?"":"Failed at "+t+": ")+e.reason}var Qt={m:eo,d:void 0,a:"strip",f:0},it={};var Cr="value",Pt="r";function me(e,t){let r=new wn;return r.type=e,r.seq=Qi++,t&&(it[Cr]=r,ke(r,Pt,it)),r}function to(e){return e}var pn={};function zt(e,t,r){if(pn[e])return pn[e];let n=me(t,!0);return r(n),pn[e]=n,n}var ne=me(lr,!0);ne.decoder=to;var jt=(e=>{let t=new wn;for(let r in e)t[r]=e[r];return t.seq=Qi++,t});function at(e,t){let r=jt(e),n=r;for(;n.to;){let i=jt(n.to);n.to=i,n=i}return t(n),r}function Tt(e,t){let r=e.g.e,n=r.length;return r[n]=t,"e["+n+"]"}function ar(e,t){let r=Y[t.type],n=t.const;return r&16?"void 0":r&2?Lt(n):r&1024?n+"n":r&28672?Tt(e,t.const):n}function At(e,t){let r='"'+t+'"',n=e[r];if(n!==void 0)return n;let i=Lt(t);return e[r]=i,i}function pe(){return this.i}function Fu(){return this.b.v()}function Nu(){return this.prev.v()}function Oe(e){let t=e.v+1;return e.v=t,"v"+t}function Fr(e,t){e.hd=e.hd===""?t:e.hd+","+t}function $u(){let e=this,t=Oe(e.g);return e.cp="let "+t+"="+e.i+";",e.i=t,e.v=pe,t}function Sn(){let e=this,t=e.p;if(t.fz)return e.v=pe,e.i;let r=Oe(e.g);return Fr(t,r+"="+e.i),e.v=pe,e.i=r,r}function Nr(){let e=this;if(e.fz)return e.v=pe,e.i="("+e.i+")",e.i;let t=Oe(e.g);if(e.prev!==void 0){let n=e.i;n===""?e.cp="let "+t+";"+e.cp:e.cp=e.cp+("let "+t+"="+n+";")}else{let n=e.i;n===""?Fr(e,t):Fr(e,t+"="+n)}return e.v=pe,e.i=t,t}function Iu(e,t,r,n){return{v:pe,i:"i",s:e,e:t,f:0,cp:"",hd:"",path:"",g:{v:-1,o:r,e:[],d:n}}}function sr(e,t,r){let n=e.path,i="Can't decode "+K(t)+" to "+K(r)+". Use S.to to define a custom decoder",o={code:"unsupported_decode",path:n,reason:i,from:t,to:r};throw new St(o)}function er(e,t,r){return Tt(e,n=>{let i=t(n);throw new St(i)})+"("+r+")"}function ro(e,t,r,n,i,o,l){let a=l!==void 0?l:"Expected "+K(e)+", received "+(i?Gr(n):K(t));if(o!==void 0){let f={};for(let u=0,m=o.length;u<m;++u){let c=o[u],d=c.reason.split(`
6
6
  `).join(`
7
7
  `),p=c.path,_=`
8
- - `+(p===""?"":"At "+p+": ")+d;f[_]||(f[_]=1,a=a+_)}}let s={code:"invalid_input",path:r,reason:a,expected:e,received:t,unionErrors:o};return i&&(s.input=n),s}function En(e,t,r,n){return i=>{let o=t!==void 0?t:"",l=n!==void 0?n:!0,a=e!==void 0?e:i.e,s=i.prev,f=s!==void 0?s.s:i.s,u=o===""?i.path:i.path+o;return m=>to(a,f,u,m,l,void 0,r)}}function ue(e){let t=e.e.errorMessage,r;if(t!==void 0){let n=t.type;r=n!==void 0?n:t._}else r=void 0;return En(void 0,void 0,r,void 0)(e)}function $u(e,t){let r=t!==void 0?t:e.e;return Qt(e,En(r,void 0,void 0,void 0)(e),e.v())}function Iu(e,t){let r=e.vc,n=r.length;if(n===1){let l=r[0];return l.c(t)+"||"+Qt(e,l.f(e),t)+";"}let i="",o=0;for(;o<n;){let l=r[o],a=l.f,s=l.c(t);for(o=o+1|0;o<n&&r[o].f===a;)s=s+"&&"+r[o].c(t),o=o+1|0;i=i+(s+"||"+Qt(e,a(e),t)+";")}return i}function ro(e){return e.t===!0?e.prev.t!==!0?e.cp==="":!1:!0}function Ne(e,t){let r=e,n="";for(;r!==void 0;){let i=r;r=i.prev;let o="";if(i.vc)if(t!==void 0&&ro(i)){let a=r.v(),s=i.vc,f="";for(let u=0,m=s.length;u<m;++u){let c=s[u],d=c.c(a);c.f===ue?f=f?f+"&&"+d:d:i.e.noValidation!==!0&&(o=o+(d+"||"+Qt(i,c.f(i),a)+";"))}f&&(t.contents?t.contents=f+"&&"+t.contents:t.contents=f)}else i.e.noValidation!==!0&&(o=Iu(i,r.v()));i.hd!==""&&(o=o+("let "+i.hd+";")),i.fz=!0,o=i.cp+o,n=o+n}return n}function Pe(e,t,r,n){let i=n!==void 0?n:e.e;return{v:Fr,i:t,s:r,e:i,prev:e,f:0,d:e.d,cp:"",hd:"",t:!0,path:e.path,g:e.g}}function B(e,t,r,n){let i=t!==void 0?t:e.s,o=n!==void 0?n:e.e,l=e.v!==pe,a={v:l?Cu:pe,i:e.i,s:i,e:o,prev:e,f:e.f,d:e.d,cp:"",hd:"",vc:r,t:e.t,path:e.path,g:e.g};if(l){let s=e.v.bind(e);e.v=()=>{let f=s();return a.i=f,a.v=pe,f}}return a}function kn(e,t){let r=e.vc;r!==void 0?r.push(t):e.vc=[t]}function er(e,t){let r=t.e.inputRefiner,n;if(r!==void 0){let a=r(t);if(a.length!==0)if(t.prev!==void 0){for(let f=0,u=a.length;f<u;++f)kn(t,a[f]);n=void 0}else n=a;else n=void 0}else n=void 0;let i=e.e.refiner,o;if(i!==void 0){let a=i(e);o=a.length!==0?a:void 0}else o=void 0;let l=n!==void 0?o!==void 0?B(e,void 0,n.concat(o),void 0):B(e,void 0,n,void 0):o!==void 0?B(e,void 0,o,void 0):e;return l.io=!0,l}function no(e,t,r){if(!t.vc)return;let i="["+Tt(e.g,r)+"]";t.vc.forEach(o=>kn(e,{c:l=>o.c(l+i),f:o.f})),t.vc=void 0}function io(e,t){let r=e.s.additionalItems,n;n=r!==void 0&&r!=="strip"&&r!=="strict"?r:ne;let i=e.e.additionalItems,o;return o=i!==void 0&&i!=="strip"&&i!=="strict"?i:ne,{p:e,v:Fu,i:e.v()+"["+t+"]",s:n,e:o,f:e.f,cp:"",hd:"",path:"",g:e.g}}function _t(e,t,r){return Pe(e,ur(e,t),t,r)}function oo(e,t){let r=Pe(e,t,e.s,void 0);return r.f=1,r}function it(e,t,r){e.s.type===yt?e.s.items.push(r.s):(r.o||e.s.required.push(t),e.s.properties[t]=r.s),r.f&1&&r.v(),e.cp=e.cp+Ne(r,void 0),e.d[t]=r}function lo(e,t,r){return e.v()+"["+t+"]="+r.i}function We(e){let t=e.v!==pe,r={b:e,v:t?Gu:pe,i:e.i,s:e.s,io:e.io,e:e.e,f:0,d:e.d,cp:"",hd:"",u:!1,t:!1,path:e.path,g:e.g};if(t){let n=e.v.bind(e);e.v=()=>{let i=n();return r.i=i,r.v=pe,i}}return r}function Pu(e,t){throw new gt({code:"invalid_operation",path:e.path,reason:t})}function uo(e,t,r,n){if(e.path===""&&r===void 0)return Ne(e,void 0);{let i=s=>{let f=t.path,u=f===""?"":Ut(f)+"+";return s+".path="+u+(r!==void 0?`'["'+`+r+`+'"]'+`:"")+s+".path"},o=Ne(e,void 0);if(o===""&&!(e.f&1))return o+(n!==void 0?n():"");let l=Oe(e.g),a=i(l)+";throw "+l;return e.f&1&&(e.i=e.i+".catch("+l+"=>{"+a+"})"),"try{"+o+(n!==void 0?n():"")+"}catch("+l+"){"+a+"}"}}function ao(e){return e}ao.embedded=Mr;function pn(e){return e+"<=2147483647&&"+e+">=-2147483648&&"+e+"%1===0"}function tr(e){return t=>"typeof "+t+'==="'+e+'"'}function Pt(e){return"Number.isNaN("+e+")"}function Nr(e){return"Array.isArray("+e+")"}function so(e){return tr(ie)(e)+"&&"+e}function Ru(e,t){return r=>r+" instanceof "+St(e,t)}function Mu(e){let t=Y[e.s.type];if(t&1){let i=[{c:tr(ot),f:ue}],o=e.e.format,l=0;return o==="int32"?i.push({c:pn,f:ue}):l=1,l===1&&(e.g.o&2||i.push({c:a=>"!"+Pt(a),f:ue})),B(e,e.e,i,void 0)}if(!(t&2))return t&4?e.s.format!==e.e.format&&e.e.format==="int32"?B(e,e.e,[{c:pn,f:ue}],void 0):e:ar(e,e.s,e.e);let r=Oe(e.g),n=Pe(e,r,e.e,void 0);return n.v=pe,n.cp="let "+r+"=+"+e.v()+";",n.vc=[{c:i=>{let o=e.e.format;return o!==void 0&&o==="int32"?pn(r):"!"+Pt(r)},f:ue}],n}function fo(){return Lt(ot,ot,e=>{e.decoder=Mu})}function Du(e){return Pe(e,'""+'+e.i,bn(),void 0)}function ju(e){let t=Y[e.s.type];if(t&1)return B(e,e.e,[{c:tr(Rt),f:ue}],void 0);if(!(t&3132&&Ie in e.s))return t&1036?Du(e):t&2?e:ar(e,e.s,e.e);let r=""+e.s.const,n=me(Rt,!1);return n.const=r,Pe(e,'"'+r+'"',n,void 0)}function bn(){return Lt(Rt,Rt,e=>{e.decoder=ju})}function co(e,t){e[Y[t]&768?or:t]=!0}var Uu="JSON";function jt(e){let t=e.e;if(t.noValidation&&!e.u)return _t(e,t,void 0);if(Ie in e.s)return e.s.const===t.const?e:_t(e,t,void 0);let r=Y[t.type];if(!(Y[e.s.type]&2&&r&3132))return r&2048?B(e,t,[{c:Pt,f:ue}],void 0):B(e,t,[{c:o=>o+"==="+ur(e,t),f:ue}],void 0);let n=me(Rt,!1);n.const=""+t.const;let i=_t(e,n,n);return i.vc=[{c:o=>o+'==="'+n.const+'"',f:ue}],_t(i,t,t)}function jr(){return Lt($e,$e,e=>{e.const=void 0,e.decoder=jt})}function Lu(){return Lt(Mt,Mt,e=>{e.const=null,e.decoder=jt})}function mo(){return Lt(_n,_n,e=>{e.const=NaN,e.decoder=jt})}function Gn(e){if(e===null)return Lu();let t=typeof e;if(t===$e)return jr();if(t===ot&&Number.isNaN(e))return mo();if(t===ie){let n=me(vn,!0);return n.class=e.constructor,n.const=e,n.decoder=jt,n}let r=me(t,!0);return r.const=e,r.decoder=jt,r}function xe(e){let t=e,r,n=0;for(;!t.io||t.e.to;){let i=r;r=void 0;let o=t;if(n=n+1|0,n>50)throw new Error("Loop count exceeded 100");if(o.e.$defs&&(o.g.d?Object.assign(o.g.d,o.e.$defs):o.g.d=o.e.$defs),o.f&1){let l=o.v(),a=We(o),s=xe(a),f=Ne(s,void 0);t=a.i!==s.i||f!==""?Pe(o,l+".then("+l+"=>{"+f+"return "+s.i+"})",s.s,s.e):B(o,s.s,void 0,s.e),t.f=t.f|1,t.io=!0}else if(o.io){let l=o.e.to,s=o.e.parser;t=s!==void 0?s(o):B(t,void 0,void 0,l)}else{let l=o.s.encoder;l&&l!==i&&o.s!==o.e&&o.e.type!==or&&(t=l(o,o.e)),o!==t?r=l:(t=o.e.decoder(o),t.io||(t=er(t,t)))}}return t}function at(e){for(;;){let t=e,r=t.to;if(r===void 0)return t;e=r}}function Je(e){if(It in e)return e[It];let t,r=e;for(;r;){let i=Dt(r),o=i.to,l=t;l!==void 0?i.to=l:delete i.to;let a=i.parser,s=i.serializer;s!==void 0?i.parser=s:delete i.parser,a!==void 0?i.serializer=a:delete i.serializer;let f=i.refiner,u=i.inputRefiner;u!==void 0?i.refiner=u:delete i.refiner,f!==void 0?i.inputRefiner=f:delete i.inputRefiner;let m=i.fromDefault,c=i.default;c!==void 0?i.fromDefault=c:delete i.fromDefault,m!==void 0?i.default=m:delete i.default;let d=i.items;d!==void 0&&(i.items=d.map(Je));let p=i.properties;if(p!==void 0){let y={},g=Object.keys(p);for(let S=0,T=g.length;S<T;++S){let C=g[S];y[C]=Je(p[C])}i.properties=y}typeof i.additionalItems===ie&&(i.additionalItems=Je(i.additionalItems));let h=i.anyOf;if(h!==void 0){let y={},g=[];for(let S=0,T=h.length;S<T;++S){let C=h[S],N=Je(C);g.push(N),co(y,N.type)}i.has=y,i.anyOf=g}let _=i.$defs;if(_!==void 0){let y={};for(let g=0,S=Object.keys(_).length;g<S;++g){let T=Object.keys(_)[g];y[T]=Je(_[T])}i.$defs=y}t=i,r=o}let n=t;return nt[Gr]=n,ke(e,It,nt),nt[Gr]=e,ke(n,It,nt),n}function po(e){try{return xe(e)}catch(t){let r=Dr(t),n=e.p;throw r.path=(n!==void 0?n.path:"")+(e.path+"[]"+r.path),r}}function zu(e,t,r,n){let i=Nu(Ie in e?ne:e,t,r,n),o=xe(i),l=Ne(o,void 0),a=bu(o.f,1);t.isAsync=a;let s=o.t===!0;if(t.hasTransform=s,l===""&&(o===i||o.i===i.i)&&!(r&1))return ao;let f=o.i;r&1&&!a&&!n&&(f="Promise.resolve("+f+")");let u="i=>{"+l+"return "+f+"}",m=i.g.e,c=new Function("e","s","return "+u)(m,Tn);return c.embedded=i.g.e,c}function $r(e,t){let r=arguments,n=0,i,o="",l=0,a;for(;i===void 0;){let f=r[n];if(f)if(typeof f===ot){let u=f|Yt.f;i=u,o=o+"-"+u}else{let u=f.seq;u>l&&(l=u,a=f),o=o+u+"-",n=n+1|0}else{let u=Yt.f;i=u,o=o+"-"+u}}let s=a;if(s!==void 0){let f=o;if(f in s)return s[f];let u=r[n-1|0];for(let c=n-2|0;c>=0;--c){let d=u;u=ut(r[c],p=>{p.to=d})}let m=zu(u,u,i,0);return nt[Gr]=m,ke(s,f,nt),m}throw new Error("[Sury] No schema provided for decoder.")}var At="BS_PRIVATE_NESTED_SOME_NONE";function qu(e){let t=B(e,void 0,void 0,Cn());return t.cp=$u(e,void 0)+";",t}function Cn(){return Lt(yn,yn,e=>{e.decoder=qu})}function Ju(e){let t=e.e.to;return Pe(e,"{"+At+":"+at(e.e).properties[At].const+"}",t,t)}function rr(e,t){return{v:Fr,i:"",s:t.type===yt?{type:yt,decoder:Nn,additionalItems:"strict",items:[]}:{type:ie,decoder:sr,additionalItems:"strict",required:[],properties:{}},e:e.e,prev:e,f:0,d:{},cp:"",hd:"",t:!0,path:e.path,g:e.g}}function Fn(e){return In(e,jr())}function sr(e){let t=e.u,r=e.e,n=Y[e.s.type],i;if(n&65){let u=n&64,m;if(u)m=e.s;else{let d=me(ie,!1);d.properties=Zi,d.additionalItems=ne,m=d}let c=[];u||(c.push({c:so,f:ue}),r.additionalItems!=="strip"&&c.push({c:d=>"!"+Nr(d),f:ue})),i=c.length!==0?B(e,m,c,void 0):B(e,m,void 0,void 0)}else i=ar(e,e.s,r);let o=r.additionalItems,l;l=o==="strip"||o==="strict"?void 0:o;let a=i.s.additionalItems,s;s=a!=="strip"&&a!=="strict";let f;if(l!==void 0)if(l===ne)f=i;else if(s){let u=i.v(),m=Oe(i.g),c=io(i,m),d=po(c),p=d.t,h=p?Pe(i,"{}",r,void 0):B(i,r,void 0,void 0),_=uo(d,i,m,p?()=>lo(h,m,d):void 0);if((p||_!=="")&&(h.cp=h.cp+("for(let "+m+" in "+u+"){"+_+"}")),d.f&1){let y=Oe(h.g),g=Oe(h.g),S=Oe(h.g),T=Oe(h.g),C=h.v();f=oo(h,"new Promise(("+y+","+g+")=>{let "+T+"=Object.keys("+C+").length;for(let "+m+" in "+C+"){"+C+"["+m+"].then("+S+"=>{"+C+"["+m+"]="+S+";if("+T+"--===1){"+y+"("+C+")}},"+g+")}})")}else f=h}else{let u=rr(i,r),m=Object.keys(i.s.properties);for(let c=0,d=m.length;c<d;++c){let p=m[c],h=Ir(i,p);h.e=l,h.io=!1,h.u=t,it(u,p,xe(h))}f=nr(u)}else{let u=r.properties,m=Object.keys(u),c=m.length,d=rr(i,r),p=r.additionalItems,h;h=p==="strip"||p==="strict"?p==="strip"?s||Object.keys(i.s.properties).length!==c:!1:!0;let _=i.s.additionalItems,y;y=_==="strip"||_==="strict"?!1:_.name===Uu;for(let S=0;S<c;++S){let T=m[S],C=u[T],N=Ir(i,T);N.e=C,N.io=!1,N.u=t,y&&C.type===lt&&C.has[$e]&&(N.i="("+N.i+"??null)");let H=xe(N);t&&Ie in C&&no(i,H,T),it(d,T,H),h||(h=H.t)}let g=!1;if(r.additionalItems==="strict"){let S=i.s.additionalItems,T;T=S!=="strip"&&S!=="strict",g=T}if(g){let S=Oe(d.g);if(Cr(i,S),d.cp=d.cp+("for("+S+" in "+i.v()+"){if("),m.length!==0)for(let T=0,C=m.length;T<C;++T){let N=m[T];T!==0&&(d.cp=d.cp+"&&"),d.cp=d.cp+(S+"!=="+Tt(i.g,N))}else d.cp=d.cp+"true";d.cp=d.cp+("){"+Qt(i,T=>({code:"unrecognized_keys",path:d.path,reason:'Unrecognized key "'+T+'"',keys:[T]}),S)+"}}")}if(h)f=nr(d);else{let S=B(i,void 0,void 0,void 0);S.cp=d.cp,S.d=d.d,f=S}}return er(f,i)}function Wu(){let e=Gn(0),t={};return t[At]=e,{type:ie,serializer:r=>{let n=r.e.to;return _t(r,n,n)},decoder:sr,additionalItems:"strip",required:[At],properties:t}}function Nn(e){let t=e.u,r=e.e,n=Y[e.s.type],i=r.items,o=i.length,l;if(n&129){let u=n&128,m=u?e.s:$n(ne),c=[];u||c.push({c:Nr,f:ue});let d=m.additionalItems,p;if(p=d==="strip"||d==="strict"?m.items.length===o:!1,!p){let h=r.additionalItems;(h==="strip"||h==="strict")&&(h==="strip"?c.push({c:_=>_+".length>="+o,f:ue}):c.push({c:_=>_+".length==="+o,f:ue}))}l=c.length!==0?B(e,m,c,void 0):B(e,m,void 0,void 0)}else l=ar(e,e.s,r);let a=r.additionalItems,s,f=0;if(a==="strip"||a==="strict")f=1;else if(a===ne)s=l;else{let u=l.v(),m=Oe(l.g),c=io(l,m),d=po(c),p=d.t,h=p?Pe(l,"new Array("+u+".length)",r,void 0):B(l,r,void 0,void 0),_=uo(d,l,m,p?()=>lo(h,m,d):void 0);(p||_!=="")&&(h.cp=h.cp+("for(let "+m+"="+o+";"+m+"<"+u+".length;++"+m+"){"+_+"}")),s=d.f&1?oo(h,"Promise.all("+h.i+")"):h}if(f===1){let u=rr(l,r),m=r.additionalItems,c;if(m==="strip"||m==="strict")if(m==="strip"){let d=l.s.additionalItems;c=d==="strip"||d==="strict"?l.s.items.length!==o:!0}else c=!1;else c=!0;for(let d=0;d<o;++d){let p=i[d],h=d.toString(),_=Ir(l,h);_.e=p,_.io=!1,_.u=t;let y=xe(_);t&&Ie in p&&no(l,y,h),it(u,h,y),c||(c=y.t)}if(c)s=nr(u);else{let d=B(l,void 0,void 0,void 0);d.cp=u.cp,d.d=u.d,s=d}}return er(s,l)}function Bu(e,t){let r=e.s.anyOf;return t.type===lt&&_o(t)===void 0&&ho(t.anyOf,r)||!Ku(r,t)?e:Hu(e,t)}function Vu(e){let t=e.e,r=t.anyOf,n=Y[e.s.type],i=_o(t);if(e.s===t&&i===void 0&&r.every(Er)||n&256&&ho(r,e.s.anyOf)&&i===void 0||e.io&&e.e===e.s)return e;(n&256||e.s.encoder===void 0&&n&512)&&(e.s=ne);let o="";if(!(n&769)){let E=hn(e.s),v=!1,G=!1,O=r.length,w=0;for(;o===""&&w<O;){let k=r[w];hn(k)===E?o=E:k.type===Mt?v=!0:k.type===$e&&(G=!0),w=w+1|0}o===""&&(n&16&&v?o=Mt:n&32&&G&&(o=$e))}let l=o,a=e.i,s=E=>St(e,function(){let v=arguments,G=to(t,ne,e.path,v[0],!0,v.length>1?Array.from(v).slice(1):void 0,void 0);throw new gt(G)})+"("+e.v()+E+")",f=B(e,void 0,void 0,void 0),u=[],m={contents:""},c=(E,v)=>{let G=E[0],O=E[1],w="",k="",R=!1,Q={contents:""},oe="",ge={},fe=2,M=E.length-1|0;for(;fe<=M;){let ee=We(O);ee.u=!0,ee.t=O.t,ee.io=!1,ee.e=E[fe];let te=fe===M,he=fe===2,dt=he&&te,Ot=!dt,be=!1,Me="",He={contents:""};try{let z=xe(ee);if(u.push(z.s),Me=Ne(z,He),z.t){f.t=!0,z.f&1&&(f.f=f.f|1);let Ge=G.v();z.i!==Ge&&(Me=Me+(Ge+"="+z.i))}}catch(z){let Ge=St(ee,Dr(z));oe=oe+","+Ge,v&&dt?(m.contents=Ge,be=!0):te?(Ot=!1,Me=v?"throw "+Ge:s(oe)):be=!0}let Ke=He.contents,ft=Me;if(!be&&Ke)if(ft){let z=ge[Ke];z!==void 0?typeof z=="string"?ge[Ke]=[z,ft]:z.push(ft):ge[Ke]=ft}else Q.contents=Q.contents?Q.contents+"||"+Ke:Ke;if(!be&&(!Ke||te)){let z=Object.keys(ge);for(let Ge=0,kl=z.length;Ge<kl;++Ge){let Zn=z[Ge];w=w+(R?"else if":"if")+("("+Zn+"){");let Wt=ge[Zn];if(typeof Wt=="string")w=w+Wt+"}";else{let Vr="";for(let mr=0,bl=Wt.length;mr<bl;++mr){let Gl=Wt[mr],Yn="e"+mr;w=w+("try{"+Gl+"}catch("+Yn+"){"),Vr=Vr+","+Yn}w=w+s(Vr)+"}".repeat(Wt.length)+"}"}R=!0}ge={}}if(!be&&!Ke)if(ft)if(Q.contents&&(w=w+(R?"else if":"if")+("(!("+Q.contents+")){"),k="}"+k,Q.contents="",R=!1),te&&(v||!Ot||he))w=w+((R?"else{":"")+ft),k=(R?"}":"")+k;else{let z="e"+(fe-2|0);w=w+((R?"else{":"")+"try{"+ft+"}catch("+z+"){"),k=(R?"}":"")+"}"+k,oe=oe+","+z,R=!1}else Q.contents="",fe=M,Ot=!1;if(te){if(Q.contents)w||oe?w=w+(R?"else if":"if")+("(!("+Q.contents+")){"+s(oe)+"}"):kn(O,{c:z=>"("+Q.contents+")",f:ue});else if(Ot){let z=s(oe);w=w+(R?"else{"+z+"}":z)}}fe=fe+1}return w+k},d="",p="",h="",_=!1,y=r.length-1|0,g={},S=[],T=t.refiner,C=t.inputRefiner,N={contents:void 0},H={contents:void 0},K=(E,v,G)=>{if(v===void 0)return E;let O=w=>{let k=G.contents;if(k!==void 0)return k;let R=v(w);return G.contents=R,R};return E!==void 0?w=>{let k=E(w),R=O(w);for(let Q=0,oe=R.length;Q<oe;++Q)k.push(R[Q]);return k}:O},x=E=>{let v=K(E.refiner,T,N);v!==void 0&&(E.refiner=v);let G=K(E.inputRefiner,C,H);if(G!==void 0){E.inputRefiner=G;return}},b;if(Ie in e.s){let E=[],v=[];for(let G=0;G<=y;++G){let O=r[G];Ie in O&&O.const===e.s.const?E.push(O):v.push(O)}b=E.concat(v)}else b=r;for(let E=0;E<=y;++E){let v=i!==void 0?ut(b[E],k=>{x(k),k.to=i}):b[E],G=v.type,O=Y[G],w=hn(v);if((l===""||l===w)&&!(O&16&&"fromDefault"in t)){let k=g[w];if(k!==void 0)O&64&&At in v.properties?k.splice(k.length-1|0,0,v):O&2096||k.push(v);else{let R=We(e),Q;if(O&37633)Q=ne;else{let M=me(v.type,!1);M.encoder=v.encoder,O&8192?M.class=v.class:O&64?(M.properties=Zi,M.additionalItems=ne):O&128?(M.additionalItems=ne,M.items=Mr):O&2096&&(M.const=v.const),M.decoder=ee=>Y[ee.s.type]&1?B(ee,ee.e,[{c:te=>{let he=Y[v.type];if(he&64)return so(te)+"&&!"+Nr(te);if(he&128)return Nr(te);if(he&8192)return Ru(ee,v.class)(te);if(!(he&4))return he&2048?Pt(te):he&48?te+"==="+ur(ee,v):he&17418?tr(v.type)(te):"";let dt=tr(ot)(te);return ee.g.o&2?dt:dt+"&&!"+Pt(te)},f:ue}],void 0):v.decoder(ee),Q=M}R.e=Q;let oe;try{oe=xe(R)}catch{R.vc=void 0,oe=R}Hi(O,g)?S.unshift(w):S.push(w),g[w]=[R,oe,v];let ge=!0,fe=oe;for(;fe!==void 0&&ge;){let M=fe;fe=M.prev,ge=!(M.vc&&ro(M))}if(ge){for(let M=0,ee=S.length;M<ee;++M){let te=S[M];if(!_){let he=g[te],dt=he[1],Ot=c(he,!0),be=Ne(dt,void 0)+Ot,Me=m.contents;if(Me)if(m.contents="",be){let He="e"+(E+M|0);d=d+("try{"+be+"throw "+Me+"}catch("+He+"){"),p="}"+p,h=h+","+He}else h=h+","+Me;else if(be){let He="e"+(E+M|0);d=d+("try{"+be+"}catch("+He+"){"),p="}"+p,h=h+","+He}else _=!0}}g={},S=[]}}}}let F=g,J=S;if(!_){let E=!1,v="";for(let w=0,k=J.length;w<k;++w){let R=F[J[w]],Q=R[1],oe=R[2],ge=c(R,!1),fe={contents:""},M=Ne(Q,fe)+ge,ee=fe.contents;M||Hi(Y[oe.type],F)?(d=d+(E?"else if":"if")+("("+ee+"){"+M+"}"),E=!0):v=v?v+"||"+ee:ee}let G=s(h),O;v?O=(E?"else if":"if")+("(!("+v+")){"+G+"}"):O=E?"else{"+G+"}":p===""?G+";":G,d=d+O}f.cp=f.cp+d+p,e.i!==f.i&&(f.i=e.i);let L=f.f&1?(f.i="Promise.resolve("+f.i+")",f.v=Fr,f):f.v===pe&&e.cp===""&&f.cp===""&&a==="i"?(e.hd="",e.v=Fr,e.i=a,e):f;return L.s=u.length?ir(u):Cn(),L.e=i!==void 0?(L.io=!0,at(i)):t,L}function ho(e,t){return t.every((r,n)=>{let i=e[n];return i!==void 0&&!(Y[r.type]&9152)&&r.type===i.type&&r.const===i.const?r.to===void 0:!1})}function Hu(e,t){return B(e,ne,void 0,ut(e.s,r=>{r.to=t}))}function Ku(e,t){return!(Y[at(t).type]&512)&&!(t.type===lt&&t.anyOf.some(r=>Y[r.type]&512))?!e.some(r=>r.to!==void 0||r.parser!==void 0?!0:Y[r.type]&512):!1}function _o(e){if(e.parser!==void 0)return;let r=e.to;if(r!==void 0)return r}function Ir(e,t){let r=e.d,n;if(r!==void 0)n=r;else{let u={};e.d=u,n=u}let i=n[t];if(i!==void 0)return We(i);let o=e.s.type===ie?e.s.properties[t]:e.s.items[t],l;if(o!==void 0)l=o;else{let u=e.s.additionalItems;l=u==="strip"||u==="strict"?ar(e,e.s,e.e):e.s.type===ie&&u.type!==or&&!(Y[u.type]&512)&&!ku(u)?Fn(u):u}let s="["+Tt(e.g,t)+"]",f={p:e,v:gn,i:Ie in l?ur(e,l):e.v()+s,s:l,e:l,f:0,cp:"",hd:"",path:e.path+s,g:e.g};return n[t]=f,f}function nr(e){let t=e.s.type===yt,r="",n="",i,o=Object.keys(e.d);for(let f=0,u=o.length;f<u;++f){let m=o[f],c=e.d[m];if(c.f&1&&(n=n+c.i+","),c.o){let d=i;i=p=>(d!==void 0?d(p):"")+("if("+c.v()+"!==void 0){"+p+"["+Tt(e.g,m)+"]="+c.i+"}")}else r=r+(t?c.i:Tt(e.g,m)+":"+c.i)+","}if(e.i=t?"["+r+"]":"{"+r+"}",n){let f=We(e);f.io=!0;let u=xe(f),m=Ne(u,void 0);return m===""&&n===u.i+","?e.i=u.i:e.i="Promise.all(["+n+"]).then((["+n+"])=>{"+m+"return "+u.i+"})",e.f=e.f|1,e.s=u.s,e.e=u.e,e.io=!0,e}let l=i;if(l===void 0)return e;let a=l(e.v()),s=B(e,void 0,void 0,void 0);return s.cp=s.cp+a,s}function ir(e){let t=e.length;if(t===1)return e[0];if(t!==0){let r={},n=new Set;for(let o=0,l=e.length;o<l;++o){let a=e[o];a.type===lt&&a.to===void 0?(a.anyOf.forEach(s=>{n.add(s)}),Object.assign(r,a.has)):(n.add(a),co(r,a.type))}let i=me(lt,!1);return i.anyOf=Array.from(n),i.decoder=Vu,i.encoder=Bu,i.has=r,i}throw new Error("[Sury] S.union requires at least one item")}function Hi(e,t){return e&8320&&ie in t?!0:e&2048?ot in t:!1}function hn(e){return Y[e.type]&8192?e.class.name:e.type}function Er(e){for(;;){let t=e,r=!1,n=!1,i=!1;if(t.to===void 0&&t.parser===void 0&&!(Y[t.type]&512)){let l=t.anyOf;i=l!==void 0?l.every(Er):!0}if(i){let l=t.items;n=l!==void 0?l.every(Er):!0}if(n){let l=t.properties;r=l!==void 0?Object.values(l).every(Er):!0}if(!r)return!1;let o=t.additionalItems;if(o===void 0||o==="strip"||o==="strict")return!0;e=o}}function $n(e){let t=me(yt,e[It]===e);return t.additionalItems=e,t.items=Mr,t.decoder=Nn,t}function In(e,t){let r=t!==void 0?t:jr(),n=at(e);switch(n.type){case"undefined":return ir([r,Ki(e)]);case"union":let o=n.has,l=n.anyOf;return ut(e,a=>{let s=Su(o),f=[];for(let u=0,m=l.length;u<m;++u){let c=l[u],d=at(c),p=d.type,h;if(p==="undefined")s[r.type]=!0,f.push(r),h=Ki(c);else{let _=d.properties;if(_!==void 0){let y=_[At];h=y!==void 0?ut(c,g=>{let S={},T={...y};T.const=y.const+1,S[At]=T,g.properties=S}):c}else h=c}f.push(h)}f.length===l.length&&(s[r.type]=!0,f.push(r)),a.anyOf=f,a.has=s});default:return ir([e,r])}}function Ki(e){return ut(e,t=>{t.to=Wu(),t.parser=Ju})}ke(xn,"~standard",{get:function(){let e=this;return{version:1,vendor:Sn,validate:t=>{try{return{value:$r(ne,e)(t)}}catch(r){let n=Dr(r);return{issues:[{message:n.reason,path:n.path===""?void 0:Tu(n.path)}]}}}}}});function yo(e,t){return $r(ne,t)(e)}function Xu(e,t){return ut(e,r=>{let n=t(r),i=r.refiner;i!==void 0?r.refiner=o=>{let l=i(o),a=n(o);for(let s=0,f=a.length;s<f;++s)l.push(a[s]);return l}:r.refiner=n})}function go(e,t,r,n){let i=r!==void 0?r:"Refinement failed",o=n!==void 0?vu(n):"";return Xu(e,l=>(a=>{let s=St(a,t);return[{c:f=>s+"("+f+")",f:En(void 0,o,i,void 0)}]}))}function So(e,t){return ut(e,r=>{let n=r.anyOf;if(n!==void 0){let o=[],l=[];for(let c=0,d=n.length;c<d;++c){let p=n[c],h=at(p);h.type!=="undefined"&&(o.push(h),l.push(p))}let a=o.length,s;if(a!==1)if(a!==0)s=ir(o);else{let c="Can't set default for "+Z(r);throw new Error("[Sury] "+c)}else s=o[0];let f=l.length!==1?ir(l):l[0];if(t.TAG==="Value"){let c=t._0;try{$r(ne,s)(c)}catch(d){let p=Dr(d),h="Invalid default for "+Z(r)+": "+p.message;throw new Error("[Sury] "+h)}try{r.default=$r(Je(f),void 0)(c)}catch{}}r.parser=c=>{let d=c.e.to,p=c.v(),h;return h=t.TAG==="Value"?ur(c,Gn(t._0)):St(c,t._0)+"()",Pe(c,p+"===void 0?"+h+":"+p,d,d)};let u=Dt(s),m=u.decoder;u.serializer=c=>{let d=Je(f);return B(m(c),d,void 0,d)},u.decoder=eo,r.to=u;return}let i="Can't set default for "+Z(r);throw new Error("[Sury] "+i)})}function Zu(e){return e[An]}function Pr(e,t,r){let n=Dt(at(e));return n.from=t,r!==void 0&&(n.fromFlattened=r),new Proxy(n,{get:(i,o)=>{if(o===An)return i;let l=i.items,a=i.properties,s=a!==void 0?a[o]:l!==void 0?l[o]:void 0;if(s===void 0){let f='Cannot read property "'+o+'" of '+Z(i);throw new Error("[Sury] "+f)}return Pr(s,i.from.concat(o),i.fromFlattened)}})}function To(e,t,r){let n=rr(e,t);n.io=!0;let i=t.items;if(i!==void 0)for(let o=0,l=i.length;o<l;++o){let a=o.toString();it(n,a,r(a,i[o]))}else{let o=t.properties;if(o!==void 0){let l=Object.keys(o);for(let a=0,s=l.length;a<s;++a){let f=l[a];it(n,f,r(f,o[f]))}}else{let l="Don't know where the value is coming from: "+Z(t);throw new Error("[Sury] "+l)}}return nr(n)}function Ao(e,t){let r=t.from,n=t.fromFlattened,i=n!==void 0?We(Xi(e.fv[n],t.from,0)):r!==void 0?We(Xi(e,r,0)):Ie in t?_t(e,t,void 0):To(e,t,(o,l)=>Ao(e,l));return i.prev=void 0,i.e=t,i}function vo(e,t){let r=t.e,n=r.from;if(n!==void 0){let l=r.fromFlattened,a;if(l!==void 0){e.flattened===void 0&&(e.flattened=[]);let s=e.flattened[l];if(s!==void 0)a=s;else{let f={};e.flattened[l]=f,a=f}}else a=e;for(let s=0,f=n.length;s<f;++s){let u=n[s],m=a.properties,c;if(m!==void 0)c=m;else{let h={};a.properties=h,c=h}let d=c[u],p;if(d!==void 0)p=d;else{let h={};c[u]=h,p=h}a=p}a.val=t;return}let i=t.d;if(i===void 0)return;let o=Object.keys(i);for(let l=0,a=o.length;l<a;++l)vo(e,i[o[l]])}function kr(e,t,r,n){let i=0;if(t!==void 0){let o=t.val;if(o!==void 0){let l=We(o);return l.t=!0,l.s=r,l.e=r,xe(l)}i=1}else i=1;if(i===1){if(Ie in r){let m=_t(e,r,r);return m.prev=void 0,m.p=e,m.v=gn,m.io=!0,xe(m)}let o=t===void 0?at(r):r,l=rr(e,o);l.e=o,l.io=!0,l.prev=void 0,l.p=e,l.v=gn;let a=o.flattened,s=o.items,f=0,u=0;if(s!==void 0&&(t!==void 0||typeof o.additionalItems!==ie))for(let m=0,c=s.length;m<c;++m){let d=m.toString(),p;if(t!==void 0){let _=t.properties;p=_!==void 0?_[d]:void 0}else p=void 0;let h=Tt(e.g,d);it(l,d,kr(e,p,s[m],n+("["+h+"]")))}else u=3;if(u===3){let m=o.properties;if(m!==void 0&&(t!==void 0||typeof o.additionalItems!==ie)){if(a!==void 0&&t!==void 0){let d=t.flattened;d!==void 0&&d.forEach((p,h)=>{let y=kr(e,p,Je(a[h]),n).d,g=Object.keys(y);for(let S=0,T=g.length;S<T;++S){let C=g[S];it(l,C,y[C])}})}let c=Object.keys(m);for(let d=0,p=c.length;d<p;++d){let h=c[d];if(!(h in l.d)){let _;if(t!==void 0){let g=t.properties;_=g!==void 0?g[h]:void 0}else _=void 0;let y=Tt(e.g,h);it(l,h,kr(e,_,m[h],n+("["+y+"]")))}}}else f=2}if(f===2){let m=r.from,c=m!==void 0?n+m.map(p=>'["'+p+'"]').join(""):n,d=c===""?"":" at "+c;Pu(e,"Missing input for "+Z(r)+d)}return nr(l)}}function Xi(e,t,r){for(;;){let n=r,i=e,o=t[n];if(o===void 0)return i;r=n+1|0,e=i.d[o]}}function Rr(e,t){if(typeof e!==ie||e===null)return Gn(e);let r=t(e);if(r!==void 0)return r;if(Array.isArray(e)){for(let s=0,f=e.length;s<f;++s){let u=Rr(e[s],t);e[s]=u}let a=me(yt,!1);return a.items=e,a.additionalItems="strict",a.decoder=Nn,a}let n=e.constructor;if(n&&n!==Object){let a=me(vn,!0);return a.class=n,a.const=e,a.decoder=jt,a}let i=Object.keys(e),o=i.length;for(let a=0;a<o;++a){let s=i[a],f=Rr(e[s],t);e[s]=f}let l=me(ie,!1);return l.required=i,l.properties=e,l.additionalItems=Yt.a,l.decoder=sr,l}function Yu(e){let t={};vo(t,e);let r=e.e.to,n=kr(e,t,r,"");return n.t=!0,n.prev=e,n}function wo(e){return Rr(e,t=>{if(t["~standard"])return t})}function Oo(e){let t=this,r="~"+e,n=t[r];if(n!==void 0)return D(n);let i={},o=[],l=me(ie,!1);l.required=o,l.properties=i,l.additionalItems=Yt.a,l.decoder=sr;let a=t.f(e,l)[An],s=(d,p)=>{let h=Ut(d);if(d in i)throw new Error("[Sury] "+("The field "+h+" defined twice"));return o.push(d),i[d]=p,Pr(p,a.from.concat(d),a.fromFlattened)},c={field:s,f:s,fieldOr:(d,p,h)=>{let _=In(p,void 0);return s(d,So(_,{TAG:"Value",_0:h}))},tag:(d,p)=>{s(d,wo(p))},nested:Oo,flatten:d=>{if(d.type==="object"){let _=d.to,y=d.properties;if(_){let T="Unsupported nested flatten for transformed object schema "+Z(d);throw new Error("[Sury] "+T)}let g=Object.keys(y),S={};for(let T=0,C=g.length;T<C;++T){let N=g[T];S[N]=s(N,y[N])}return S}let h="Can't flatten "+Z(d)+" schema";throw new Error("[Sury] "+h)}};return t[r]=c,c}function Qu(e){let t=Dt(Rr(e,Zu));return t.serializer=Yu,t}function ea(e){let t=e.e.flattened;if(t!==void 0){let i=[];for(let o=0,l=t.length;o<l;++o){let a=t[o],s=a.to,f;if(s!==void 0){let u=We(e);u.e=a,u.io=!0,f=xe(u)}else{let u=To(e,a,(m,c)=>Ir(e,m));u.e=a,u.prev=void 0,f=er(u,u)}i.push(f),e.cp=e.cp+Ne(f,void 0)}e.fv=i}let r=e.e.to,n=Ao(e,r);return n.t=!0,n.prev=e,er(n,e)}function xo(e){let t,r={},n=u=>{if(u.type==="object"){let d=u.properties,p=Object.keys(d);for(let _=0,y=p.length;_<y;++_){let g=p[_],S=d[g],T=r[g];if(T!==void 0){if(T!==S)throw new Error("[Sury] "+('The field "'+g+'" defined twice with incompatible schemas'))}else r[g]=S}let h=t||(t=[]);return Pr(u,Mr,h.push(u)-1|0)}let c="The '"+Z(u)+"' schema can't be flattened";throw new Error("[Sury] "+c)},i=(u,m)=>{if(u in r)throw new Error("[Sury] "+('The field "'+u+'" defined twice with incompatible schemas'));return r[u]=m,Pr(m,[u],void 0)},s=e({field:i,f:i,fieldOr:(u,m,c)=>{let d=In(m,void 0);return i(u,So(d,{TAG:"Value",_0:c}))},tag:(u,m)=>{i(u,wo(m))},nested:Oo,flatten:n}),f=me(ie,!1);return f.required=Object.keys(r),f.properties=r,f.additionalItems=Yt.a,f.decoder=sr,f.parser=ea,f.to=Qu(s),t!==void 0&&(f.flattened=t),f}var st=bn();var Eo=fo();var ko=wn;var bo=$n;var dr=Fn;var Be=go;var Go=yo;var Ur=xo;function ra(e){return{path:e.path,summary:e.message}}function A(e){return{path:"",summary:e}}function Pn(e,t){try{return{TAG:"Ok",_0:Go(e,t)}}catch(r){let n=j(r);if(n.RE_EXN_ID===ko)return{TAG:"Error",_0:ra(n._1)};throw n}}import*as Lr from"node:fs";import*as Io from"node:os";import*as zr from"node:path";function Po(){return zr.join(Io.homedir(),".linzumi","auth.json")}var Fo="Kandan auth cache must contain a JSON object",na="Kandan auth cache local_codex_runner must be an object",ia="Kandan auth cache personal_agent_delegation must be an object";function No(e){if(typeof e!="object"||e===null||Array.isArray(e))return;let t=e.access_token,r=e.issued_at;if(t===void 0||typeof t!="string"||r===void 0||typeof r!="string")return;let n=e.expires_at,i;return i=typeof n=="string"?n:void 0,{accessToken:t,issuedAt:r,expiresAt:i}}function Ro(e){let t;try{t=JSON.parse(e)}catch{t=void 0}if(t===void 0)return{TAG:"Error",_0:A(Fo)};if(typeof t!="object"||t===null||Array.isArray(t))return{TAG:"Error",_0:A(Fo)};let r=t.local_codex_runner,n=t.personal_agent_delegation,i=r!==void 0?typeof r=="object"&&r!==null&&!Array.isArray(r):!0,o=n!==void 0?typeof n=="object"&&n!==null&&!Array.isArray(n):!0;if(!i)return{TAG:"Error",_0:A(na)};if(!o)return{TAG:"Error",_0:A(ia)};let l;return l=typeof r=="object"&&r!==null&&!Array.isArray(r)?Object.fromEntries(De(Object.entries(r),a=>{let s=a[0];return ve(No(a[1]),f=>[s,f])})):void 0,{TAG:"Ok",_0:{serverTokens:l,personalAgentDelegation:q(n,No)}}}function oa(e){return Lr.existsSync(e)?P(U(et(e),t=>A(t.message)),t=>X(Ro(t),r=>r)):{TAG:"Ok",_0:void 0}}function la(e,t){return e!==void 0?new Date(e).getTime()<=t:!1}function Mo(e,t,r){return Lr.existsSync(t)?P(oa(t),n=>X(U(ce(e),A),i=>q(q(q(n,o=>o.serverTokens),o=>o[i]),o=>{if(!(o.accessToken.trim()===""||la(o.expiresAt,r)))return{accessToken:o.accessToken,expiresAt:o.expiresAt}}))):{TAG:"Ok",_0:void 0}}function $o(e){let t={};t.access_token=e.accessToken,t.issued_at=e.issuedAt;let r=e.expiresAt;return r!==void 0&&(t.expires_at=r),t}function ua(e){let t={};t.version=1;let r=e.serverTokens;r!==void 0&&(t.local_codex_runner=Object.fromEntries(Object.entries(r).map(i=>[i[0],$o(i[1])])));let n=e.personalAgentDelegation;return n!==void 0&&(t.personal_agent_delegation=$o(n)),t}function Do(e,t,r,n,i){return P(U(ce(e),A),o=>{let l=Lr.existsSync(n)?P(U(et(n),a=>A(a.message)),Ro):{TAG:"Ok",_0:{serverTokens:void 0,personalAgentDelegation:void 0}};return P(l,a=>{let s=i.toISOString(),f=ve(r,y=>new Date(i.getTime()+y*1e3).toISOString()),u={accessToken:t,issuedAt:s,expiresAt:f},m=a.serverTokens,c=m!==void 0?Object.fromEntries(Object.entries(m)):{};c[o]=u;let d=ua({serverTokens:c,personalAgentDelegation:a.personalAgentDelegation}),p=JSON.stringify(d,void 0,2)+`
9
- `,h=n+".tmp."+process.pid.toString()+"."+Wi(6),_=y=>A(y.message);return P(U(Kt(zr.dirname(n)),_),()=>{let y=P(Ht(h,p,{encoding:"utf8",mode:384}),()=>zi(h,n));return y.TAG==="Ok"?{TAG:"Ok",_0:{accessToken:t,expiresAt:f}}:(qi(h),{TAG:"Error",_0:A(y._0.message)})})})})}function Uo(e){return e._0}var wf=new RegExp("^[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?(?:\\.[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?)*$"),Of=new RegExp("^[0-9.]+$");function Rn(e){if(typeof e!="string")return;let t=e.trim();if(t!=="")return t}function Mn(e){return isFinite(e)?Math.trunc(e)===e:!1}function fa(e){if(typeof e=="number"&&e%1===0)return e}function ca(e){let t=e.replaceAll("-","+").replaceAll("_","/");switch(t.length&3){case 2:return t+"==";case 3:return t+"=";default:return t}}function ma(e){let t=e.split(".")[1];if(t===void 0)return;let r=Buffer.from(ca(t),"base64").toString("utf8"),n;try{n=JSON.parse(r)}catch{n=void 0}if(typeof n=="object"&&n!==null&&!Array.isArray(n))return n}function jn(e){let t=q(ma(e),r=>fa(r.exp));if(t===void 0)return{TAG:"Ok",_0:void 0};if(t<=0)return{TAG:"Ok",_0:void 0};try{return{TAG:"Ok",_0:new Date(t*1e3).toISOString()}}catch(r){let n=j(r),i=Ce(n);return{TAG:"Error",_0:A(i!==void 0?$(Ae(D(i)),"unknown error"):"unknown error")}}}import*as Wo from"node:http";import*as Bo from"node:crypto";function zt(e){let t=Ce(e);return t!==void 0?$(Ae(D(t)),"unknown error"):"unknown error"}async function vt(e,t){try{return{TAG:"Ok",_0:await fetch(e,t)}}catch(r){let n=j(r);return{TAG:"Error",_0:{message:zt(n)}}}}async function ha(e){try{return{TAG:"Ok",_0:await e.text()}}catch(t){let r=j(t);return{TAG:"Error",_0:{message:zt(r)}}}}async function wt(e){let t=await ha(e);if(t.TAG!=="Ok")return{TAG:"Error",_0:t._0};try{return{TAG:"Ok",_0:JSON.parse(t._0)}}catch(r){let n=j(r);return{TAG:"Error",_0:{message:zt(n)}}}}import*as Vo from"node:child_process";function qr(e){if(typeof e!="object"||e===null||Array.isArray(e))return;let t=e.error;if(typeof t=="string")return t}function Lo(e,t){if(e===void 0)return t!==void 0?"local runner device authorization failed (HTTP "+t.toString()+", no reason returned by the server)":"local runner device authorization failed (no reason returned by the server)";switch(e){case"access_denied":return"local runner device authorization was denied";case"approving_user_not_found":return"local runner device authorization failed: the approving Linzumi account could not be found";case"device_session_consumed":return"local runner device authorization was already used";case"device_session_expired":return"local runner device authorization expired";case"device_session_not_pending":return"local runner device authorization was already decided (approved or denied) on the server";case"invalid_device_code":return"local runner device authorization code was rejected";case"invalid_user_code":return"local runner device authorization code was not recognized by the server";case"rate_limited":return"local runner device authorization was rate limited by the server; wait a minute and retry";default:return"local runner device authorization failed (server said: "+e+")"}}function qt(e,t){let r=e[t];if(r!==void 0&&typeof r=="string"&&r.trim()!=="")return r}async function zo(e,t,r,n,i){let o=qe("/api/v2/local-codex-runner/device/start",e);if(o.TAG!=="Ok")return{TAG:"Error",_0:A(o._0)};let l={},a=(_,y)=>{if(y!==void 0){l[_]=y;return}};a("workspace",t),a("channel",r),a("onboarding",n),i!==void 0&&(a("runner_id",i.commanderId),a("machine_fingerprint",i.machineFingerprint),a("hostname",i.hostname));let s={};s["content-type"]="application/json";let f=await vt(o._0.toString(),{method:"POST",headers:s,body:JSON.stringify(l)});if(f.TAG!=="Ok")return{TAG:"Error",_0:A(f._0.message)};let u=f._0,m=u.status,c=await wt(u);if(c.TAG!=="Ok")return{TAG:"Error",_0:A(c._0.message)};let d=c._0;if(m>=200&&m<300){if(Array.isArray(d))return{TAG:"Error",_0:A("local runner device authorization response was incomplete")};if(d!==null)switch(typeof d){case"object":let _=qt(d,"device_code"),y=qt(d,"user_code"),g=qt(d,"verification_uri");if(_===void 0)return{TAG:"Error",_0:A("local runner device authorization response was incomplete")};if(y===void 0)return{TAG:"Error",_0:A("local runner device authorization response was incomplete")};if(g===void 0)return{TAG:"Error",_0:A("local runner device authorization response was incomplete")};let S=d.expires_in,T;return T=typeof S=="number"?S:void 0,{TAG:"Ok",_0:{deviceCode:_,userCode:y,verificationUri:g,expiresInSeconds:T}}}}let h=qr(d);return{TAG:"Error",_0:A(h!==void 0?"local runner device authorization failed to start (server said: "+h+")":"local runner device authorization failed to start (HTTP "+m.toString()+")")}}async function _a(e,t,r){let n=new AbortController,i=setTimeout(()=>{n.abort()},r+1e4|0),o={};o.device_code=t,o.wait_ms=r;let l={};l["content-type"]="application/json";let a=qe("/api/v2/local-codex-runner/device/token",e),s;if(s=a.TAG==="Ok"?await vt(a._0.toString(),{method:"POST",headers:l,body:JSON.stringify(o),signal:Te(n.signal)}):{TAG:"Error",_0:{message:a._0}},s.TAG==="Ok"){let f=s._0,u=f.status,m=await wt(f);if(clearTimeout(i),m.TAG!=="Ok")return n.signal.aborted?"Continue":{TAG:"Done",_0:{TAG:"Transient",reason:"non-JSON device/token response ("+m._0.message+")",httpStatus:u}};let c=m._0,d=u>=200&&u<300,p=qr(c),h=0;if(u!==202||p===void 0)h=1;else{if(p==="authorization_pending")return"Continue";h=1}if(h===1){let _=0;if(d){if(Array.isArray(c))return{TAG:"Done",_0:{TAG:"Rejected",reason:"device token response did not include access_token",httpStatus:u}};if(c===null)_=2;else switch(typeof c){case"object":let y=qt(c,"access_token");if(y===void 0)return{TAG:"Done",_0:{TAG:"Rejected",reason:"device token response did not include access_token",httpStatus:u}};let g=c.expires_in,S;return S=typeof g=="number"?g:void 0,{TAG:"Done",_0:{TAG:"Token",_0:{accessToken:y,expiresInSeconds:S}}};default:_=2}}else _=2;if(_===2){let y=0;if(p!==void 0)switch(p){case"access_denied":return{TAG:"Done",_0:"Denied"};case"device_session_consumed":return{TAG:"Done",_0:"Consumed"};case"device_session_expired":return{TAG:"Done",_0:"CodeExpired"};default:y=3}else y=3;if(y===3)return u>=500||u===429?{TAG:"Done",_0:{TAG:"Transient",reason:p!==void 0?p:"HTTP "+u.toString(),httpStatus:u}}:{TAG:"Done",_0:{TAG:"Rejected",reason:p,httpStatus:u}}}}}else return clearTimeout(i),n.signal.aborted?"Continue":{TAG:"Done",_0:{TAG:"Transient",reason:s._0.message,httpStatus:void 0}}}async function qo(e,t,r){let n=r!==void 0&&r>=0?r:600,i=Date.now()+n*1e3,o=async()=>{if(Date.now()>=i)return"CodeExpired";let l=Math.max(0,Math.min(3e4,i-Date.now())),a=await _a(e,t,l);return typeof a!="object"?await o():a._0};return await o()}function Ho(e,t){if(e!==void 0&&isFinite(e)&&e>0)return e;let r=ve(Xt(t,"LINZUMI_OAUTH_CALLBACK_TIMEOUT_MS"),i=>i.trim());if(r===void 0||r==="")return 3e5;let n=Number.parseInt(r,10);return isFinite(n)&&n>0?n:3e5}function ya(e){let t=e.split(".").map(o=>Number.parseInt(o,10));if(t.length!==4||t.some(o=>!Number.isInteger(o)||o<0?!0:o>255))return e==="localhost";let n=t[0],i=t[1];return n!==void 0&&i!==void 0?n===10||n===127||n===172&&i>=16&&i<=31||n===192&&i===168||n===169&&i===254?!0:n===100&&i>=64?i<=127:!1:!1}function ga(e){try{return{TAG:"Ok",_0:new URL(e)}}catch(t){let r=j(t);return{TAG:"Error",_0:zt(r)}}}function Sa(e,t){let r=ve(t,o=>o.trim());if(r!==void 0&&r!=="")return{TAG:"Ok",_0:r};let n=ga(e);if(n.TAG!=="Ok")return{TAG:"Error",_0:n._0};let i=n._0.hostname.trim();return ya(i)&&i!=="localhost"?{TAG:"Ok",_0:i}:{TAG:"Ok",_0:"127.0.0.1"}}function Ta(e,t,r,n,i,o,l){return X(qe("/api/v2/local-codex-runner/oauth/authorize",e),a=>{let s=a.searchParams;return s.set("redirect_uri",t),s.set("state",r),n!==void 0&&s.set("workspace",n),i!==void 0&&s.set("channel",i),o!==void 0&&s.set("onboarding",o),l!==void 0&&s.set("purpose","persisted_documents_publish"),a.toString()})}async function Aa(e,t,r){let n=qe("/api/v2/local-codex-runner/oauth/token",e);if(n.TAG!=="Ok")return{TAG:"Error",_0:A(n._0)};let i={};i.code=t,i.redirect_uri=r;let o={};o["content-type"]="application/json";let l=await vt(n._0.toString(),{method:"POST",headers:o,body:JSON.stringify(i)});if(l.TAG!=="Ok")return{TAG:"Error",_0:A(l._0.message)};let a=l._0,s=a.status,f=await wt(a);if(f.TAG!=="Ok")return{TAG:"Error",_0:A(f._0.message)};let u=f._0;if(s>=200&&s<300){if(Array.isArray(u))return{TAG:"Error",_0:A("local runner OAuth token response did not include access_token")};if(u!==null)switch(typeof u){case"object":let d=qt(u,"access_token");if(d===void 0)return{TAG:"Error",_0:A("local runner OAuth token response did not include access_token")};let p=u.expires_in,h;return h=typeof p=="number"?p:void 0,{TAG:"Ok",_0:{accessToken:d,expiresInSeconds:h}}}}let c=qr(u);return c!==void 0?c==="admin_role_required"?{TAG:"Error",_0:A("This token requires a Linzumi admin account. Approve the request while signed in as an admin.")}:{TAG:"Error",_0:A("local runner OAuth token exchange failed: "+c)}:{TAG:"Error",_0:A("local runner OAuth token exchange failed")}}function Ln(e){return e.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;")}var va='<svg viewBox="0 0 512 512" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"><path fill="currentColor" d="M206.7,82.37l2.55-6.45,2.01-3.63c.67-1.21,1.07-1.88,2.55-3.63,1.34-1.61,3.36-4.43,5.64-6.58,2.42-2.24,5.06-4.3,7.93-6.18,3.92-2.53,8.17-4.52,12.63-5.91,1.79-.63,4.03-1.16,6.72-1.61,6.1-.88,12.29-.92,18.4-.13,2.69.45,5.06,1.03,7.12,1.75,2.15.67,3.49,1.07,5.64,2.15,4.55,2.16,8.87,4.77,12.9,7.79,1.61,1.34,2.42,2.15,4.16,4.16l5.91,7.66c1.34,2.01,1.34,2.28,2.15,4.03l2.55,6.58c.67,1.34-.13,1.34,1.07.94,1.21-.27,4.3-2.01,6.45-2.82,4.7-1.83,9.62-3,14.64-3.49,2.42-.27,3.76-.54,7.12-.27s9.27,1.21,12.76,2.15c3.63.94,6.58,2.55,8.73,3.49,2.15,1.07,2.55,1.48,4.16,2.55,3.49,2.51,6.77,5.29,9.81,8.33,1.52,1.7,3.04,3.58,4.57,5.64,2.74,4.49,4.86,9.32,6.31,14.37.67,2.28,1.07,3.49,1.34,6.72.27,3.22,0,10.48.4,12.76.27,2.28.27.67,1.61.94,1.48.27,4.3,0,6.72.4,2.42.27,4.97.85,7.66,1.75,6.76,2.32,13.01,5.92,18.4,10.61,2.28,1.75,2.96,2.69,4.3,4.3,3.51,3.93,6.32,8.43,8.33,13.3,1.07,2.15,1.21,2.28,1.88,5.1.54,2.96,1.61,8.19,1.61,12.36s-.81,9.67-1.34,12.76c-.67,3.22-1.07,4.03-2.15,6.18-2.16,4.54-4.81,8.82-7.93,12.76-1.25,1.61-2.6,3-4.03,4.16-1.48,1.34-2.69,2.42-4.7,3.76-3.79,2.34-7.74,4.4-11.82,6.18l-6.58,2.15c-2.06.45-4.12.72-6.18.81l-7.25.13c-2.28,0-2.82.27-6.58-.4-3.76-.81-11.69-2.82-15.99-4.3-4.16-1.34-6.31-2.69-9.67-4.43-3.49-1.75-10.48-6.18-12.9-7.39-8.26-4.54-16.78-8.58-25.52-12.09-4.3-1.75-9.27-3.22-11.82-4.03-2.55-.81-5.24-1.61-7.66-2.15-8.39-2.25-16.99-3.6-25.66-4.03-3.9-.27-4.84-.27-8.19-.13-3.67-.09-7.79.04-12.36.4-7.9.79-15.75,2.04-23.51,3.76-8.37,2.26-16.62,4.95-24.72,8.06-3.22,1.34-2.82.81-9.13,4.16-6.31,3.36-22.03,12.22-28.75,15.58-6.72,3.36-8.73,3.49-11.82,4.43-3.09,1.07-4.3,1.21-6.58,1.61-7.3,1.09-14.71,1.18-22.03.27-2.55-.54-5.78-1.61-7.79-2.28-2.01-.54-2.15-.67-4.03-1.75-2.02-1.07-5.64-3.22-7.79-4.7-3.24-2.15-6.14-4.77-8.6-7.79-1.34-1.52-2.69-3.36-4.03-5.51-1.52-2.51-2.96-5.24-4.3-8.19-2.03-5.46-3.03-11.24-2.96-17.06,0-2.96.13-6.72.67-9.67.54-2.87,1.34-5.6,2.42-8.19,4.24-10.52,12.04-19.22,22.03-24.58,5.19-2.98,10.88-4.98,16.79-5.91,2.55-.4,5.37-.13,6.72-.4,1.34-.27,1.34,1.34,1.61-.94.4-2.28,0-9.4.4-12.76.27-3.36.81-4.97,1.48-7.25,1.87-6.19,4.88-11.97,8.87-17.06,3.47-3.98,7.39-7.54,11.69-10.61,4.43-2.61,9.11-4.77,13.97-6.45,2.55-.67,6.99-1.34,9.13-1.75,2.15-.27,1.88-.13,3.63-.13,1.79-.09,4.03,0,6.72.27,2.69.18,5.73.72,9.13,1.61,3.49,1.07,9.27,4.03,11.28,4.7s.4.27,1.07-.94ZM512.27,255.7c0,141.39-114.62,256-256,256S.27,397.09.27,255.7,114.89-.3,256.27-.3s256,114.62,256,256ZM449.33,352.66c14.67-29.16,22.94-62.09,22.94-96.95,0-119.29-96.71-216-216-216S40.27,136.41,40.27,255.7c0,41.89,11.94,80.98,32.57,114.09,1.7,1.79,2.94.65,3.05-.57.27-1.61,2.75-20.85,4.43-27.27,1.87-7.6,4.52-14.98,7.93-22.03,1.75-3.49,3.76-7.93,6.18-11.82,8.77-13.95,19.75-26.38,32.51-36.81,7.24-5.32,14.87-10.08,22.84-14.24,9.74-4.78,20.09-8.22,30.76-10.21,4.03-.99,7.61-1.66,10.75-2.02,3.36-.54,5.78-.54,9.27-.94,3.49-.54,9.32-1.16,11.82-2.01,6.65-2.27,5.64-6.72,3.09-7.52-2.55-.81-9.67-1.88-13.84-2.96-4.16-1.21-8.73-2.82-11.28-3.76-2.55-.94-2.28-.94-3.9-2.02l-5.91-4.03c-.94-.94-1.34-.94.54-2.02l10.21-5.51c2.01-1.07,1.75-.67,3.09-.13,1.34.67,4.3,2.42,6.72,3.36,7.2,2.69,14.96,3.52,22.57,2.42,1.34-.27,1.34-.54,1.61-1.21.27-.67.81-.94-.13-2.69-.94-1.88-4.43-6.58-5.64-8.46l-1.21-2.28c-.27-.45-1.07-1.07,1.21-1.75,2.42-.54,10.48-2.58,12.9-2.82.86-.09.67,0,1.75,1.07,1.07,1.07,3.09,3.63,4.84,5.24,1.88,1.61,4.43,3.22,6.18,4.3,2.8,1.71,5.99,2.68,9.27,2.82,1.88,0,4.97-.13,7.12-.67,2.15-.4,3.63-.94,5.64-2.02,2.01-1.07,4.7-2.69,6.72-4.43,2.01-1.75,3.49-5.1,5.64-6.04,2.15-.81,4.97.54,7.12.94,2.28.4,4.97,1.21,6.18,1.61,1.21.4,2.01.4.67,2.28l-8.06,10.34c-1.34,1.88.13,5.51,1.21,5.64l5.64.27c2.28-.13,4.43.13,7.66-.67,3.36-.81,9.27-2.96,11.82-3.9,2.69-.94,3.22-1.34,4.16-2.01.81-.54,1.39-1.03,1.75-1.48.45-.27.67-1.07,2.82,0s9.4,4.97,11.28,6.18c2.01,1.21,1.07.94,0,1.75l-5.51,3.9c-1.48.94-1.07.94-3.22,1.88-2.15,1.07-6.58,2.96-9.67,4.03s-4.03,1.75-8.73,2.69c-4.7.81-14.51,1.75-19.48,2.55-4.97.81-7.93,1.34-10.34,2.01-2.28.67-2.15.94-3.49,1.88-1.48,1.07-2.69,1.61-4.97,3.9-2.28,2.28-5.91,6.85-8.73,9.81-2.82,2.96-6.45,6.04-8.33,7.79-2.02,1.61-1.61,1.34-3.36,2.42l-6.99,4.03-4.03,2.02-6.72,2.15c-2.42.67-3.9,1.21-7.66,2.01l-14.91,2.82c-3.63.81-4.3,1.07-7.12,2.01-2.96,1.07-6.22,2.46-9.81,4.16-3.22,1.43-6.81,3.45-10.75,6.04-13.6,9.14-24.61,21.63-31.97,36.27-2.01,3.76-2.96,6.58-3.9,9.27-1.07,2.69-1.61,4.03-2.28,6.58-.67,2.69-1.48,5.24-2.15,9.27-.54,4.16-1.48,11.15-1.75,15.45-.27,4.16-.27,6.04,0,10.21l1.88,14.91c.67,3.76,1.48,5.91,2.15,8.19l1.88,5.64c.99,2.6,2.42,5.78,4.3,9.54,2.15,3.76,5.37,9.13,8.06,13.03,10.08,14.51,23.81,26.36,40.17,33.05,22.55,9.22,43.32,10.46,61.89,10.46,3.25,0,6.49-.09,9.71-.23,3.07-.42,2.74-6.09,10.48-9.42,5.26-2.26,13.7-2.42,14.91-2.55,1.07-.13-5.24-4.57-7.79-6.45-2.55-1.88-4.97-4.3-6.72-5.91-1.75-1.75-2.42-2.28-3.9-4.16-1.61-1.88-3.9-5.51-5.24-7.12-1.34-1.61-1.48-2.28-2.55-2.55-.98-.27-2.37-.09-4.16.54-1.88.4-5.37,1.21-7.12,1.88-1.75.67-2.02.81-3.09,2.01-1.07,1.07-2.69,3.76-3.63,4.7-.81.94-.67.67-1.48.94-.81.27-2.42.67-3.63.54-1.34-.18-2.55-.58-3.63-1.21-.81-.81-1.48-2.42-1.88-3.22-.4-.94-.54-1.21-.54-2.15l.4-3.49c.18-1.52.72-3.27,1.61-5.24.94-1.75,1.88-3.49,4.16-5.64,2.15-2.02,7.52-5.51,9.13-6.85,1.61-1.34,1.21-2.15.54-3.63-2.69-5.16-6.33-9.77-10.75-13.57-2.42-1.88-5.51-3.22-7.79-4.3-2.15-1.21-2.01-1.21-5.78-2.42-3.76-1.07-13.16-3.63-16.79-4.84-3.63-1.07-2.82-.94-5.1-2.01l-8.19-4.3c-1.75-.94-1.34-.54-2.69-1.61l-5.51-4.57c-2.18-1.93-3.77-4.45-4.57-7.25-.45-1.52-.45-2.87,0-4.03.4-1.34,0-1.21,2.01-3.63,2.15-2.42,7.25-7.93,10.21-10.75,3.09-2.82,4.97-4.03,7.79-6.04,5.43-3.82,11.09-7.32,16.93-10.48,2.42-1.21,5.37-2.02,7.12-2.69,1.61-.81,2.64-1.43,3.09-1.88.54-.4.67.54.4-.94-.4-1.48-1.88-4.97-2.28-7.66-.4-2.82-.4-6.18,0-8.73.36-2.42,1.03-4.66,2.01-6.72,1.16-2.24,2.46-4.3,3.9-6.18,1.34-1.7,2.91-3.04,4.7-4.03,1.75-1.07,4.3-2.01,6.18-2.42,1.61-.45,3.13-.58,4.57-.4l4.57.27c1.34.18,2.55.49,3.63.94,1.07.54,2.55,1.48,3.09,2.01.4.67.67.13-.27,1.61-1.07,1.48-4.16,4.57-5.78,7.12-1.61,2.69-2.96,5.6-4.03,8.73-.94,3.22-1.88,8.73-2.01,10.75-.27,2.15,4.7,1.75,5.1.54.54-1.07.27-2.55,1.07-5.1.81-2.42,2.42-7.25,3.9-9.81,1.34-2.55,2.82-3.76,4.57-5.51,1.79-1.88,3.67-3.45,5.64-4.7,1.88-1.21,3.22-1.75,5.64-2.28,2.42-.4,6.18-.67,8.73-.67,2.42,0,3.9.13,6.18.94,2.15.81,5.24,2.69,7.12,4.03,1.79,1.52,3.22,3.09,4.3,4.7,1.21,1.61,1.88,2.96,2.55,5.1.67,2.15,1.34,5.1,1.34,7.66,0,2.69-.54,6.04-1.21,8.19-.63,2.24-1.43,4.03-2.42,5.37-.67,1.34-.94,1.61-2.15,2.82-1.21,1.34-3.22,3.22-4.97,4.57-1.75,1.21-4.43,2.28-5.51,3.22-.94.81-.4,2.51.4,2.42.94.13,1.75.4,4.57-.13,2.82-.4,8.33-2.15,12.22-2.82,11.99-2.63,24.41-2.63,36.4,0,3.22.54,4.16,1.07,6.31,1.75l6.04,2.28c2.42,1.07,5.51,2.42,8.19,4.16,8.15,5.36,15.14,12.3,20.55,20.42,1.61,2.42,2.87,4.66,3.76,6.72,1.85,4.51,3.42,9.13,4.7,13.84.67,2.82,1.21,4.43,1.61,8.19.4,3.76.4,11.82.54,14.37.27,2.55-.13,2.28,1.75,1.34,1.75-.94,20.09-7.74,30.63-31.57,9.16-20.71,1.9-47.26-2.28-55.34-1.75-3.22-4.16-6.99-6.31-9.81-4.44-5.14-9.6-9.62-15.31-13.3-2.96-1.7-5.55-3.09-7.79-4.16-4.33-1.6-8.77-2.86-13.3-3.76l-6.18-.4h-14.37c-2.69-.27-3.1-3.18-.54-4.3,3.64-1.58,9.88-2.63,18.54-2.42,8.78.21,14.91,1.88,17.33,2.55,13.98,3.94,30.19,16.65,38.55,30.76,6.61,11.16,9.81,29.96,9.81,29.96.37,1.75,2.18,1.66,3.08.35ZM232.78,345.3c-3.91,0-7.08,3.17-7.08,7.08s3.17,7.08,7.08,7.08,7.08-3.17,7.08-7.08-3.17-7.08-7.08-7.08Z"/></svg>';function wa(e){let t=e.status>=200&&e.status<300,r=t?"badge badge--success":"badge badge--notice",n=t?'<svg viewBox="0 0 24 24" aria-hidden="true" focusable="false" class="mark"><path fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round" d="M5 12.5l4.2 4.2L19 7"/></svg>':'<svg viewBox="0 0 24 24" aria-hidden="true" focusable="false" class="mark"><path fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round" d="M12 7v6M12 17h.01"/></svg>',i=t?"--success-soft":"--notice-soft";return`<!doctype html>
8
+ - `+(p===""?"":"At "+p+": ")+d;f[_]||(f[_]=1,a=a+_)}}let s={code:"invalid_input",path:r,reason:a,expected:e,received:t,unionErrors:o};return i&&(s.input=n),s}function kn(e,t,r,n){return i=>{let o=t!==void 0?t:"",l=n!==void 0?n:!0,a=e!==void 0?e:i.e,s=i.prev,f=s!==void 0?s.s:i.s,u=o===""?i.path:i.path+o;return m=>ro(a,f,u,m,l,void 0,r)}}function ue(e){let t=e.e.errorMessage,r;if(t!==void 0){let n=t.type;r=n!==void 0?n:t._}else r=void 0;return kn(void 0,void 0,r,void 0)(e)}function Pu(e,t){let r=t!==void 0?t:e.e;return er(e,kn(r,void 0,void 0,void 0)(e),e.v())}function Ru(e,t){let r=e.vc,n=r.length;if(n===1){let l=r[0];return l.c(t)+"||"+er(e,l.f(e),t)+";"}let i="",o=0;for(;o<n;){let l=r[o],a=l.f,s=l.c(t);for(o=o+1|0;o<n&&r[o].f===a;)s=s+"&&"+r[o].c(t),o=o+1|0;i=i+(s+"||"+er(e,a(e),t)+";")}return i}function no(e){return e.t===!0?e.prev.t!==!0?e.cp==="":!1:!0}function Ne(e,t){let r=e,n="";for(;r!==void 0;){let i=r;r=i.prev;let o="";if(i.vc)if(t!==void 0&&no(i)){let a=r.v(),s=i.vc,f="";for(let u=0,m=s.length;u<m;++u){let c=s[u],d=c.c(a);c.f===ue?f=f?f+"&&"+d:d:i.e.noValidation!==!0&&(o=o+(d+"||"+er(i,c.f(i),a)+";"))}f&&(t.contents?t.contents=f+"&&"+t.contents:t.contents=f)}else i.e.noValidation!==!0&&(o=Ru(i,r.v()));i.hd!==""&&(o=o+("let "+i.hd+";")),i.fz=!0,o=i.cp+o,n=o+n}return n}function Pe(e,t,r,n){let i=n!==void 0?n:e.e;return{v:Nr,i:t,s:r,e:i,prev:e,f:0,d:e.d,cp:"",hd:"",t:!0,path:e.path,g:e.g}}function B(e,t,r,n){let i=t!==void 0?t:e.s,o=n!==void 0?n:e.e,l=e.v!==pe,a={v:l?Nu:pe,i:e.i,s:i,e:o,prev:e,f:e.f,d:e.d,cp:"",hd:"",vc:r,t:e.t,path:e.path,g:e.g};if(l){let s=e.v.bind(e);e.v=()=>{let f=s();return a.i=f,a.v=pe,f}}return a}function bn(e,t){let r=e.vc;r!==void 0?r.push(t):e.vc=[t]}function tr(e,t){let r=t.e.inputRefiner,n;if(r!==void 0){let a=r(t);if(a.length!==0)if(t.prev!==void 0){for(let f=0,u=a.length;f<u;++f)bn(t,a[f]);n=void 0}else n=a;else n=void 0}else n=void 0;let i=e.e.refiner,o;if(i!==void 0){let a=i(e);o=a.length!==0?a:void 0}else o=void 0;let l=n!==void 0?o!==void 0?B(e,void 0,n.concat(o),void 0):B(e,void 0,n,void 0):o!==void 0?B(e,void 0,o,void 0):e;return l.io=!0,l}function io(e,t,r){if(!t.vc)return;let i="["+At(e.g,r)+"]";t.vc.forEach(o=>bn(e,{c:l=>o.c(l+i),f:o.f})),t.vc=void 0}function oo(e,t){let r=e.s.additionalItems,n;n=r!==void 0&&r!=="strip"&&r!=="strict"?r:ne;let i=e.e.additionalItems,o;return o=i!==void 0&&i!=="strip"&&i!=="strict"?i:ne,{p:e,v:$u,i:e.v()+"["+t+"]",s:n,e:o,f:e.f,cp:"",hd:"",path:"",g:e.g}}function yt(e,t,r){return Pe(e,ar(e,t),t,r)}function lo(e,t){let r=Pe(e,t,e.s,void 0);return r.f=1,r}function ot(e,t,r){e.s.type===gt?e.s.items.push(r.s):(r.o||e.s.required.push(t),e.s.properties[t]=r.s),r.f&1&&r.v(),e.cp=e.cp+Ne(r,void 0),e.d[t]=r}function uo(e,t,r){return e.v()+"["+t+"]="+r.i}function We(e){let t=e.v!==pe,r={b:e,v:t?Fu:pe,i:e.i,s:e.s,io:e.io,e:e.e,f:0,d:e.d,cp:"",hd:"",u:!1,t:!1,path:e.path,g:e.g};if(t){let n=e.v.bind(e);e.v=()=>{let i=n();return r.i=i,r.v=pe,i}}return r}function Mu(e,t){throw new St({code:"invalid_operation",path:e.path,reason:t})}function ao(e,t,r,n){if(e.path===""&&r===void 0)return Ne(e,void 0);{let i=s=>{let f=t.path,u=f===""?"":Lt(f)+"+";return s+".path="+u+(r!==void 0?`'["'+`+r+`+'"]'+`:"")+s+".path"},o=Ne(e,void 0);if(o===""&&!(e.f&1))return o+(n!==void 0?n():"");let l=Oe(e.g),a=i(l)+";throw "+l;return e.f&1&&(e.i=e.i+".catch("+l+"=>{"+a+"})"),"try{"+o+(n!==void 0?n():"")+"}catch("+l+"){"+a+"}"}}function so(e){return e}so.embedded=Dr;function hn(e){return e+"<=2147483647&&"+e+">=-2147483648&&"+e+"%1===0"}function rr(e){return t=>"typeof "+t+'==="'+e+'"'}function Rt(e){return"Number.isNaN("+e+")"}function $r(e){return"Array.isArray("+e+")"}function fo(e){return rr(ie)(e)+"&&"+e}function Du(e,t){return r=>r+" instanceof "+Tt(e,t)}function ju(e){let t=Y[e.s.type];if(t&1){let i=[{c:rr(lt),f:ue}],o=e.e.format,l=0;return o==="int32"?i.push({c:hn,f:ue}):l=1,l===1&&(e.g.o&2||i.push({c:a=>"!"+Rt(a),f:ue})),B(e,e.e,i,void 0)}if(!(t&2))return t&4?e.s.format!==e.e.format&&e.e.format==="int32"?B(e,e.e,[{c:hn,f:ue}],void 0):e:sr(e,e.s,e.e);let r=Oe(e.g),n=Pe(e,r,e.e,void 0);return n.v=pe,n.cp="let "+r+"=+"+e.v()+";",n.vc=[{c:i=>{let o=e.e.format;return o!==void 0&&o==="int32"?hn(r):"!"+Rt(r)},f:ue}],n}function co(){return zt(lt,lt,e=>{e.decoder=ju})}function Uu(e){return Pe(e,'""+'+e.i,Gn(),void 0)}function Lu(e){let t=Y[e.s.type];if(t&1)return B(e,e.e,[{c:rr(Mt),f:ue}],void 0);if(!(t&3132&&Ie in e.s))return t&1036?Uu(e):t&2?e:sr(e,e.s,e.e);let r=""+e.s.const,n=me(Mt,!1);return n.const=r,Pe(e,'"'+r+'"',n,void 0)}function Gn(){return zt(Mt,Mt,e=>{e.decoder=Lu})}function mo(e,t){e[Y[t]&768?lr:t]=!0}var zu="JSON";function Ut(e){let t=e.e;if(t.noValidation&&!e.u)return yt(e,t,void 0);if(Ie in e.s)return e.s.const===t.const?e:yt(e,t,void 0);let r=Y[t.type];if(!(Y[e.s.type]&2&&r&3132))return r&2048?B(e,t,[{c:Rt,f:ue}],void 0):B(e,t,[{c:o=>o+"==="+ar(e,t),f:ue}],void 0);let n=me(Mt,!1);n.const=""+t.const;let i=yt(e,n,n);return i.vc=[{c:o=>o+'==="'+n.const+'"',f:ue}],yt(i,t,t)}function Ur(){return zt($e,$e,e=>{e.const=void 0,e.decoder=Ut})}function qu(){return zt(Dt,Dt,e=>{e.const=null,e.decoder=Ut})}function po(){return zt(yn,yn,e=>{e.const=NaN,e.decoder=Ut})}function Cn(e){if(e===null)return qu();let t=typeof e;if(t===$e)return Ur();if(t===lt&&Number.isNaN(e))return po();if(t===ie){let n=me(xn,!0);return n.class=e.constructor,n.const=e,n.decoder=Ut,n}let r=me(t,!0);return r.const=e,r.decoder=Ut,r}function we(e){let t=e,r,n=0;for(;!t.io||t.e.to;){let i=r;r=void 0;let o=t;if(n=n+1|0,n>50)throw new Error("Loop count exceeded 100");if(o.e.$defs&&(o.g.d?Object.assign(o.g.d,o.e.$defs):o.g.d=o.e.$defs),o.f&1){let l=o.v(),a=We(o),s=we(a),f=Ne(s,void 0);t=a.i!==s.i||f!==""?Pe(o,l+".then("+l+"=>{"+f+"return "+s.i+"})",s.s,s.e):B(o,s.s,void 0,s.e),t.f=t.f|1,t.io=!0}else if(o.io){let l=o.e.to,s=o.e.parser;t=s!==void 0?s(o):B(t,void 0,void 0,l)}else{let l=o.s.encoder;l&&l!==i&&o.s!==o.e&&o.e.type!==lr&&(t=l(o,o.e)),o!==t?r=l:(t=o.e.decoder(o),t.io||(t=tr(t,t)))}}return t}function st(e){for(;;){let t=e,r=t.to;if(r===void 0)return t;e=r}}function Je(e){if(Pt in e)return e[Pt];let t,r=e;for(;r;){let i=jt(r),o=i.to,l=t;l!==void 0?i.to=l:delete i.to;let a=i.parser,s=i.serializer;s!==void 0?i.parser=s:delete i.parser,a!==void 0?i.serializer=a:delete i.serializer;let f=i.refiner,u=i.inputRefiner;u!==void 0?i.refiner=u:delete i.refiner,f!==void 0?i.inputRefiner=f:delete i.inputRefiner;let m=i.fromDefault,c=i.default;c!==void 0?i.fromDefault=c:delete i.fromDefault,m!==void 0?i.default=m:delete i.default;let d=i.items;d!==void 0&&(i.items=d.map(Je));let p=i.properties;if(p!==void 0){let y={},g=Object.keys(p);for(let S=0,T=g.length;S<T;++S){let C=g[S];y[C]=Je(p[C])}i.properties=y}typeof i.additionalItems===ie&&(i.additionalItems=Je(i.additionalItems));let h=i.anyOf;if(h!==void 0){let y={},g=[];for(let S=0,T=h.length;S<T;++S){let C=h[S],N=Je(C);g.push(N),mo(y,N.type)}i.has=y,i.anyOf=g}let _=i.$defs;if(_!==void 0){let y={};for(let g=0,S=Object.keys(_).length;g<S;++g){let T=Object.keys(_)[g];y[T]=Je(_[T])}i.$defs=y}t=i,r=o}let n=t;return it[Cr]=n,ke(e,Pt,it),it[Cr]=e,ke(n,Pt,it),n}function ho(e){try{return we(e)}catch(t){let r=jr(t),n=e.p;throw r.path=(n!==void 0?n.path:"")+(e.path+"[]"+r.path),r}}function Ju(e,t,r,n){let i=Iu(Ie in e?ne:e,t,r,n),o=we(i),l=Ne(o,void 0),a=Cu(o.f,1);t.isAsync=a;let s=o.t===!0;if(t.hasTransform=s,l===""&&(o===i||o.i===i.i)&&!(r&1))return so;let f=o.i;r&1&&!a&&!n&&(f="Promise.resolve("+f+")");let u="i=>{"+l+"return "+f+"}",m=i.g.e,c=new Function("e","s","return "+u)(m,An);return c.embedded=i.g.e,c}function Ir(e,t){let r=arguments,n=0,i,o="",l=0,a;for(;i===void 0;){let f=r[n];if(f)if(typeof f===lt){let u=f|Qt.f;i=u,o=o+"-"+u}else{let u=f.seq;u>l&&(l=u,a=f),o=o+u+"-",n=n+1|0}else{let u=Qt.f;i=u,o=o+"-"+u}}let s=a;if(s!==void 0){let f=o;if(f in s)return s[f];let u=r[n-1|0];for(let c=n-2|0;c>=0;--c){let d=u;u=at(r[c],p=>{p.to=d})}let m=Ju(u,u,i,0);return it[Cr]=m,ke(s,f,it),m}throw new Error("[Sury] No schema provided for decoder.")}var vt="BS_PRIVATE_NESTED_SOME_NONE";function Wu(e){let t=B(e,void 0,void 0,Fn());return t.cp=Pu(e,void 0)+";",t}function Fn(){return zt(gn,gn,e=>{e.decoder=Wu})}function Bu(e){let t=e.e.to;return Pe(e,"{"+vt+":"+st(e.e).properties[vt].const+"}",t,t)}function nr(e,t){return{v:Nr,i:"",s:t.type===gt?{type:gt,decoder:$n,additionalItems:"strict",items:[]}:{type:ie,decoder:dr,additionalItems:"strict",required:[],properties:{}},e:e.e,prev:e,f:0,d:{},cp:"",hd:"",t:!0,path:e.path,g:e.g}}function Nn(e){return Pn(e,Ur())}function dr(e){let t=e.u,r=e.e,n=Y[e.s.type],i;if(n&65){let u=n&64,m;if(u)m=e.s;else{let d=me(ie,!1);d.properties=Yi,d.additionalItems=ne,m=d}let c=[];u||(c.push({c:fo,f:ue}),r.additionalItems!=="strip"&&c.push({c:d=>"!"+$r(d),f:ue})),i=c.length!==0?B(e,m,c,void 0):B(e,m,void 0,void 0)}else i=sr(e,e.s,r);let o=r.additionalItems,l;l=o==="strip"||o==="strict"?void 0:o;let a=i.s.additionalItems,s;s=a!=="strip"&&a!=="strict";let f;if(l!==void 0)if(l===ne)f=i;else if(s){let u=i.v(),m=Oe(i.g),c=oo(i,m),d=ho(c),p=d.t,h=p?Pe(i,"{}",r,void 0):B(i,r,void 0,void 0),_=ao(d,i,m,p?()=>uo(h,m,d):void 0);if((p||_!=="")&&(h.cp=h.cp+("for(let "+m+" in "+u+"){"+_+"}")),d.f&1){let y=Oe(h.g),g=Oe(h.g),S=Oe(h.g),T=Oe(h.g),C=h.v();f=lo(h,"new Promise(("+y+","+g+")=>{let "+T+"=Object.keys("+C+").length;for(let "+m+" in "+C+"){"+C+"["+m+"].then("+S+"=>{"+C+"["+m+"]="+S+";if("+T+"--===1){"+y+"("+C+")}},"+g+")}})")}else f=h}else{let u=nr(i,r),m=Object.keys(i.s.properties);for(let c=0,d=m.length;c<d;++c){let p=m[c],h=Pr(i,p);h.e=l,h.io=!1,h.u=t,ot(u,p,we(h))}f=ir(u)}else{let u=r.properties,m=Object.keys(u),c=m.length,d=nr(i,r),p=r.additionalItems,h;h=p==="strip"||p==="strict"?p==="strip"?s||Object.keys(i.s.properties).length!==c:!1:!0;let _=i.s.additionalItems,y;y=_==="strip"||_==="strict"?!1:_.name===zu;for(let S=0;S<c;++S){let T=m[S],C=u[T],N=Pr(i,T);N.e=C,N.io=!1,N.u=t,y&&C.type===ut&&C.has[$e]&&(N.i="("+N.i+"??null)");let H=we(N);t&&Ie in C&&io(i,H,T),ot(d,T,H),h||(h=H.t)}let g=!1;if(r.additionalItems==="strict"){let S=i.s.additionalItems,T;T=S!=="strip"&&S!=="strict",g=T}if(g){let S=Oe(d.g);if(Fr(i,S),d.cp=d.cp+("for("+S+" in "+i.v()+"){if("),m.length!==0)for(let T=0,C=m.length;T<C;++T){let N=m[T];T!==0&&(d.cp=d.cp+"&&"),d.cp=d.cp+(S+"!=="+At(i.g,N))}else d.cp=d.cp+"true";d.cp=d.cp+("){"+er(i,T=>({code:"unrecognized_keys",path:d.path,reason:'Unrecognized key "'+T+'"',keys:[T]}),S)+"}}")}if(h)f=ir(d);else{let S=B(i,void 0,void 0,void 0);S.cp=d.cp,S.d=d.d,f=S}}return tr(f,i)}function Vu(){let e=Cn(0),t={};return t[vt]=e,{type:ie,serializer:r=>{let n=r.e.to;return yt(r,n,n)},decoder:dr,additionalItems:"strip",required:[vt],properties:t}}function $n(e){let t=e.u,r=e.e,n=Y[e.s.type],i=r.items,o=i.length,l;if(n&129){let u=n&128,m=u?e.s:In(ne),c=[];u||c.push({c:$r,f:ue});let d=m.additionalItems,p;if(p=d==="strip"||d==="strict"?m.items.length===o:!1,!p){let h=r.additionalItems;(h==="strip"||h==="strict")&&(h==="strip"?c.push({c:_=>_+".length>="+o,f:ue}):c.push({c:_=>_+".length==="+o,f:ue}))}l=c.length!==0?B(e,m,c,void 0):B(e,m,void 0,void 0)}else l=sr(e,e.s,r);let a=r.additionalItems,s,f=0;if(a==="strip"||a==="strict")f=1;else if(a===ne)s=l;else{let u=l.v(),m=Oe(l.g),c=oo(l,m),d=ho(c),p=d.t,h=p?Pe(l,"new Array("+u+".length)",r,void 0):B(l,r,void 0,void 0),_=ao(d,l,m,p?()=>uo(h,m,d):void 0);(p||_!=="")&&(h.cp=h.cp+("for(let "+m+"="+o+";"+m+"<"+u+".length;++"+m+"){"+_+"}")),s=d.f&1?lo(h,"Promise.all("+h.i+")"):h}if(f===1){let u=nr(l,r),m=r.additionalItems,c;if(m==="strip"||m==="strict")if(m==="strip"){let d=l.s.additionalItems;c=d==="strip"||d==="strict"?l.s.items.length!==o:!0}else c=!1;else c=!0;for(let d=0;d<o;++d){let p=i[d],h=d.toString(),_=Pr(l,h);_.e=p,_.io=!1,_.u=t;let y=we(_);t&&Ie in p&&io(l,y,h),ot(u,h,y),c||(c=y.t)}if(c)s=ir(u);else{let d=B(l,void 0,void 0,void 0);d.cp=u.cp,d.d=u.d,s=d}}return tr(s,l)}function Hu(e,t){let r=e.s.anyOf;return t.type===ut&&yo(t)===void 0&&_o(t.anyOf,r)||!Zu(r,t)?e:Xu(e,t)}function Ku(e){let t=e.e,r=t.anyOf,n=Y[e.s.type],i=yo(t);if(e.s===t&&i===void 0&&r.every(kr)||n&256&&_o(r,e.s.anyOf)&&i===void 0||e.io&&e.e===e.s)return e;(n&256||e.s.encoder===void 0&&n&512)&&(e.s=ne);let o="";if(!(n&769)){let E=_n(e.s),v=!1,G=!1,O=r.length,x=0;for(;o===""&&x<O;){let k=r[x];_n(k)===E?o=E:k.type===Dt?v=!0:k.type===$e&&(G=!0),x=x+1|0}o===""&&(n&16&&v?o=Dt:n&32&&G&&(o=$e))}let l=o,a=e.i,s=E=>Tt(e,function(){let v=arguments,G=ro(t,ne,e.path,v[0],!0,v.length>1?Array.from(v).slice(1):void 0,void 0);throw new St(G)})+"("+e.v()+E+")",f=B(e,void 0,void 0,void 0),u=[],m={contents:""},c=(E,v)=>{let G=E[0],O=E[1],x="",k="",R=!1,Q={contents:""},oe="",ge={},fe=2,M=E.length-1|0;for(;fe<=M;){let ee=We(O);ee.u=!0,ee.t=O.t,ee.io=!1,ee.e=E[fe];let te=fe===M,he=fe===2,ft=he&&te,wt=!ft,be=!1,Me="",Ke={contents:""};try{let z=we(ee);if(u.push(z.s),Me=Ne(z,Ke),z.t){f.t=!0,z.f&1&&(f.f=f.f|1);let Ge=G.v();z.i!==Ge&&(Me=Me+(Ge+"="+z.i))}}catch(z){let Ge=Tt(ee,jr(z));oe=oe+","+Ge,v&&ft?(m.contents=Ge,be=!0):te?(wt=!1,Me=v?"throw "+Ge:s(oe)):be=!0}let Xe=Ke.contents,ct=Me;if(!be&&Xe)if(ct){let z=ge[Xe];z!==void 0?typeof z=="string"?ge[Xe]=[z,ct]:z.push(ct):ge[Xe]=ct}else Q.contents=Q.contents?Q.contents+"||"+Xe:Xe;if(!be&&(!Xe||te)){let z=Object.keys(ge);for(let Ge=0,Gl=z.length;Ge<Gl;++Ge){let Yn=z[Ge];x=x+(R?"else if":"if")+("("+Yn+"){");let Bt=ge[Yn];if(typeof Bt=="string")x=x+Bt+"}";else{let Hr="";for(let pr=0,Cl=Bt.length;pr<Cl;++pr){let Fl=Bt[pr],Qn="e"+pr;x=x+("try{"+Fl+"}catch("+Qn+"){"),Hr=Hr+","+Qn}x=x+s(Hr)+"}".repeat(Bt.length)+"}"}R=!0}ge={}}if(!be&&!Xe)if(ct)if(Q.contents&&(x=x+(R?"else if":"if")+("(!("+Q.contents+")){"),k="}"+k,Q.contents="",R=!1),te&&(v||!wt||he))x=x+((R?"else{":"")+ct),k=(R?"}":"")+k;else{let z="e"+(fe-2|0);x=x+((R?"else{":"")+"try{"+ct+"}catch("+z+"){"),k=(R?"}":"")+"}"+k,oe=oe+","+z,R=!1}else Q.contents="",fe=M,wt=!1;if(te){if(Q.contents)x||oe?x=x+(R?"else if":"if")+("(!("+Q.contents+")){"+s(oe)+"}"):bn(O,{c:z=>"("+Q.contents+")",f:ue});else if(wt){let z=s(oe);x=x+(R?"else{"+z+"}":z)}}fe=fe+1}return x+k},d="",p="",h="",_=!1,y=r.length-1|0,g={},S=[],T=t.refiner,C=t.inputRefiner,N={contents:void 0},H={contents:void 0},X=(E,v,G)=>{if(v===void 0)return E;let O=x=>{let k=G.contents;if(k!==void 0)return k;let R=v(x);return G.contents=R,R};return E!==void 0?x=>{let k=E(x),R=O(x);for(let Q=0,oe=R.length;Q<oe;++Q)k.push(R[Q]);return k}:O},w=E=>{let v=X(E.refiner,T,N);v!==void 0&&(E.refiner=v);let G=X(E.inputRefiner,C,H);if(G!==void 0){E.inputRefiner=G;return}},b;if(Ie in e.s){let E=[],v=[];for(let G=0;G<=y;++G){let O=r[G];Ie in O&&O.const===e.s.const?E.push(O):v.push(O)}b=E.concat(v)}else b=r;for(let E=0;E<=y;++E){let v=i!==void 0?at(b[E],k=>{w(k),k.to=i}):b[E],G=v.type,O=Y[G],x=_n(v);if((l===""||l===x)&&!(O&16&&"fromDefault"in t)){let k=g[x];if(k!==void 0)O&64&&vt in v.properties?k.splice(k.length-1|0,0,v):O&2096||k.push(v);else{let R=We(e),Q;if(O&37633)Q=ne;else{let M=me(v.type,!1);M.encoder=v.encoder,O&8192?M.class=v.class:O&64?(M.properties=Yi,M.additionalItems=ne):O&128?(M.additionalItems=ne,M.items=Dr):O&2096&&(M.const=v.const),M.decoder=ee=>Y[ee.s.type]&1?B(ee,ee.e,[{c:te=>{let he=Y[v.type];if(he&64)return fo(te)+"&&!"+$r(te);if(he&128)return $r(te);if(he&8192)return Du(ee,v.class)(te);if(!(he&4))return he&2048?Rt(te):he&48?te+"==="+ar(ee,v):he&17418?rr(v.type)(te):"";let ft=rr(lt)(te);return ee.g.o&2?ft:ft+"&&!"+Rt(te)},f:ue}],void 0):v.decoder(ee),Q=M}R.e=Q;let oe;try{oe=we(R)}catch{R.vc=void 0,oe=R}Ki(O,g)?S.unshift(x):S.push(x),g[x]=[R,oe,v];let ge=!0,fe=oe;for(;fe!==void 0&&ge;){let M=fe;fe=M.prev,ge=!(M.vc&&no(M))}if(ge){for(let M=0,ee=S.length;M<ee;++M){let te=S[M];if(!_){let he=g[te],ft=he[1],wt=c(he,!0),be=Ne(ft,void 0)+wt,Me=m.contents;if(Me)if(m.contents="",be){let Ke="e"+(E+M|0);d=d+("try{"+be+"throw "+Me+"}catch("+Ke+"){"),p="}"+p,h=h+","+Ke}else h=h+","+Me;else if(be){let Ke="e"+(E+M|0);d=d+("try{"+be+"}catch("+Ke+"){"),p="}"+p,h=h+","+Ke}else _=!0}}g={},S=[]}}}}let F=g,J=S;if(!_){let E=!1,v="";for(let x=0,k=J.length;x<k;++x){let R=F[J[x]],Q=R[1],oe=R[2],ge=c(R,!1),fe={contents:""},M=Ne(Q,fe)+ge,ee=fe.contents;M||Ki(Y[oe.type],F)?(d=d+(E?"else if":"if")+("("+ee+"){"+M+"}"),E=!0):v=v?v+"||"+ee:ee}let G=s(h),O;v?O=(E?"else if":"if")+("(!("+v+")){"+G+"}"):O=E?"else{"+G+"}":p===""?G+";":G,d=d+O}f.cp=f.cp+d+p,e.i!==f.i&&(f.i=e.i);let L=f.f&1?(f.i="Promise.resolve("+f.i+")",f.v=Nr,f):f.v===pe&&e.cp===""&&f.cp===""&&a==="i"?(e.hd="",e.v=Nr,e.i=a,e):f;return L.s=u.length?or(u):Fn(),L.e=i!==void 0?(L.io=!0,st(i)):t,L}function _o(e,t){return t.every((r,n)=>{let i=e[n];return i!==void 0&&!(Y[r.type]&9152)&&r.type===i.type&&r.const===i.const?r.to===void 0:!1})}function Xu(e,t){return B(e,ne,void 0,at(e.s,r=>{r.to=t}))}function Zu(e,t){return!(Y[st(t).type]&512)&&!(t.type===ut&&t.anyOf.some(r=>Y[r.type]&512))?!e.some(r=>r.to!==void 0||r.parser!==void 0?!0:Y[r.type]&512):!1}function yo(e){if(e.parser!==void 0)return;let r=e.to;if(r!==void 0)return r}function Pr(e,t){let r=e.d,n;if(r!==void 0)n=r;else{let u={};e.d=u,n=u}let i=n[t];if(i!==void 0)return We(i);let o=e.s.type===ie?e.s.properties[t]:e.s.items[t],l;if(o!==void 0)l=o;else{let u=e.s.additionalItems;l=u==="strip"||u==="strict"?sr(e,e.s,e.e):e.s.type===ie&&u.type!==lr&&!(Y[u.type]&512)&&!Gu(u)?Nn(u):u}let s="["+At(e.g,t)+"]",f={p:e,v:Sn,i:Ie in l?ar(e,l):e.v()+s,s:l,e:l,f:0,cp:"",hd:"",path:e.path+s,g:e.g};return n[t]=f,f}function ir(e){let t=e.s.type===gt,r="",n="",i,o=Object.keys(e.d);for(let f=0,u=o.length;f<u;++f){let m=o[f],c=e.d[m];if(c.f&1&&(n=n+c.i+","),c.o){let d=i;i=p=>(d!==void 0?d(p):"")+("if("+c.v()+"!==void 0){"+p+"["+At(e.g,m)+"]="+c.i+"}")}else r=r+(t?c.i:At(e.g,m)+":"+c.i)+","}if(e.i=t?"["+r+"]":"{"+r+"}",n){let f=We(e);f.io=!0;let u=we(f),m=Ne(u,void 0);return m===""&&n===u.i+","?e.i=u.i:e.i="Promise.all(["+n+"]).then((["+n+"])=>{"+m+"return "+u.i+"})",e.f=e.f|1,e.s=u.s,e.e=u.e,e.io=!0,e}let l=i;if(l===void 0)return e;let a=l(e.v()),s=B(e,void 0,void 0,void 0);return s.cp=s.cp+a,s}function or(e){let t=e.length;if(t===1)return e[0];if(t!==0){let r={},n=new Set;for(let o=0,l=e.length;o<l;++o){let a=e[o];a.type===ut&&a.to===void 0?(a.anyOf.forEach(s=>{n.add(s)}),Object.assign(r,a.has)):(n.add(a),mo(r,a.type))}let i=me(ut,!1);return i.anyOf=Array.from(n),i.decoder=Ku,i.encoder=Hu,i.has=r,i}throw new Error("[Sury] S.union requires at least one item")}function Ki(e,t){return e&8320&&ie in t?!0:e&2048?lt in t:!1}function _n(e){return Y[e.type]&8192?e.class.name:e.type}function kr(e){for(;;){let t=e,r=!1,n=!1,i=!1;if(t.to===void 0&&t.parser===void 0&&!(Y[t.type]&512)){let l=t.anyOf;i=l!==void 0?l.every(kr):!0}if(i){let l=t.items;n=l!==void 0?l.every(kr):!0}if(n){let l=t.properties;r=l!==void 0?Object.values(l).every(kr):!0}if(!r)return!1;let o=t.additionalItems;if(o===void 0||o==="strip"||o==="strict")return!0;e=o}}function In(e){let t=me(gt,e[Pt]===e);return t.additionalItems=e,t.items=Dr,t.decoder=$n,t}function Pn(e,t){let r=t!==void 0?t:Ur(),n=st(e);switch(n.type){case"undefined":return or([r,Xi(e)]);case"union":let o=n.has,l=n.anyOf;return at(e,a=>{let s=Au(o),f=[];for(let u=0,m=l.length;u<m;++u){let c=l[u],d=st(c),p=d.type,h;if(p==="undefined")s[r.type]=!0,f.push(r),h=Xi(c);else{let _=d.properties;if(_!==void 0){let y=_[vt];h=y!==void 0?at(c,g=>{let S={},T={...y};T.const=y.const+1,S[vt]=T,g.properties=S}):c}else h=c}f.push(h)}f.length===l.length&&(s[r.type]=!0,f.push(r)),a.anyOf=f,a.has=s});default:return or([e,r])}}function Xi(e){return at(e,t=>{t.to=Vu(),t.parser=Bu})}ke(En,"~standard",{get:function(){let e=this;return{version:1,vendor:Tn,validate:t=>{try{return{value:Ir(ne,e)(t)}}catch(r){let n=jr(r);return{issues:[{message:n.reason,path:n.path===""?void 0:vu(n.path)}]}}}}}});function go(e,t){return Ir(ne,t)(e)}function Yu(e,t){return at(e,r=>{let n=t(r),i=r.refiner;i!==void 0?r.refiner=o=>{let l=i(o),a=n(o);for(let s=0,f=a.length;s<f;++s)l.push(a[s]);return l}:r.refiner=n})}function So(e,t,r,n){let i=r!==void 0?r:"Refinement failed",o=n!==void 0?Ou(n):"";return Yu(e,l=>(a=>{let s=Tt(a,t);return[{c:f=>s+"("+f+")",f:kn(void 0,o,i,void 0)}]}))}function To(e,t){return at(e,r=>{let n=r.anyOf;if(n!==void 0){let o=[],l=[];for(let c=0,d=n.length;c<d;++c){let p=n[c],h=st(p);h.type!=="undefined"&&(o.push(h),l.push(p))}let a=o.length,s;if(a!==1)if(a!==0)s=or(o);else{let c="Can't set default for "+K(r);throw new Error("[Sury] "+c)}else s=o[0];let f=l.length!==1?or(l):l[0];if(t.TAG==="Value"){let c=t._0;try{Ir(ne,s)(c)}catch(d){let p=jr(d),h="Invalid default for "+K(r)+": "+p.message;throw new Error("[Sury] "+h)}try{r.default=Ir(Je(f),void 0)(c)}catch{}}r.parser=c=>{let d=c.e.to,p=c.v(),h;return h=t.TAG==="Value"?ar(c,Cn(t._0)):Tt(c,t._0)+"()",Pe(c,p+"===void 0?"+h+":"+p,d,d)};let u=jt(s),m=u.decoder;u.serializer=c=>{let d=Je(f);return B(m(c),d,void 0,d)},u.decoder=to,r.to=u;return}let i="Can't set default for "+K(r);throw new Error("[Sury] "+i)})}function Qu(e){return e[vn]}function Rr(e,t,r){let n=jt(st(e));return n.from=t,r!==void 0&&(n.fromFlattened=r),new Proxy(n,{get:(i,o)=>{if(o===vn)return i;let l=i.items,a=i.properties,s=a!==void 0?a[o]:l!==void 0?l[o]:void 0;if(s===void 0){let f='Cannot read property "'+o+'" of '+K(i);throw new Error("[Sury] "+f)}return Rr(s,i.from.concat(o),i.fromFlattened)}})}function Ao(e,t,r){let n=nr(e,t);n.io=!0;let i=t.items;if(i!==void 0)for(let o=0,l=i.length;o<l;++o){let a=o.toString();ot(n,a,r(a,i[o]))}else{let o=t.properties;if(o!==void 0){let l=Object.keys(o);for(let a=0,s=l.length;a<s;++a){let f=l[a];ot(n,f,r(f,o[f]))}}else{let l="Don't know where the value is coming from: "+K(t);throw new Error("[Sury] "+l)}}return ir(n)}function vo(e,t){let r=t.from,n=t.fromFlattened,i=n!==void 0?We(Zi(e.fv[n],t.from,0)):r!==void 0?We(Zi(e,r,0)):Ie in t?yt(e,t,void 0):Ao(e,t,(o,l)=>vo(e,l));return i.prev=void 0,i.e=t,i}function xo(e,t){let r=t.e,n=r.from;if(n!==void 0){let l=r.fromFlattened,a;if(l!==void 0){e.flattened===void 0&&(e.flattened=[]);let s=e.flattened[l];if(s!==void 0)a=s;else{let f={};e.flattened[l]=f,a=f}}else a=e;for(let s=0,f=n.length;s<f;++s){let u=n[s],m=a.properties,c;if(m!==void 0)c=m;else{let h={};a.properties=h,c=h}let d=c[u],p;if(d!==void 0)p=d;else{let h={};c[u]=h,p=h}a=p}a.val=t;return}let i=t.d;if(i===void 0)return;let o=Object.keys(i);for(let l=0,a=o.length;l<a;++l)xo(e,i[o[l]])}function br(e,t,r,n){let i=0;if(t!==void 0){let o=t.val;if(o!==void 0){let l=We(o);return l.t=!0,l.s=r,l.e=r,we(l)}i=1}else i=1;if(i===1){if(Ie in r){let m=yt(e,r,r);return m.prev=void 0,m.p=e,m.v=Sn,m.io=!0,we(m)}let o=t===void 0?st(r):r,l=nr(e,o);l.e=o,l.io=!0,l.prev=void 0,l.p=e,l.v=Sn;let a=o.flattened,s=o.items,f=0,u=0;if(s!==void 0&&(t!==void 0||typeof o.additionalItems!==ie))for(let m=0,c=s.length;m<c;++m){let d=m.toString(),p;if(t!==void 0){let _=t.properties;p=_!==void 0?_[d]:void 0}else p=void 0;let h=At(e.g,d);ot(l,d,br(e,p,s[m],n+("["+h+"]")))}else u=3;if(u===3){let m=o.properties;if(m!==void 0&&(t!==void 0||typeof o.additionalItems!==ie)){if(a!==void 0&&t!==void 0){let d=t.flattened;d!==void 0&&d.forEach((p,h)=>{let y=br(e,p,Je(a[h]),n).d,g=Object.keys(y);for(let S=0,T=g.length;S<T;++S){let C=g[S];ot(l,C,y[C])}})}let c=Object.keys(m);for(let d=0,p=c.length;d<p;++d){let h=c[d];if(!(h in l.d)){let _;if(t!==void 0){let g=t.properties;_=g!==void 0?g[h]:void 0}else _=void 0;let y=At(e.g,h);ot(l,h,br(e,_,m[h],n+("["+y+"]")))}}}else f=2}if(f===2){let m=r.from,c=m!==void 0?n+m.map(p=>'["'+p+'"]').join(""):n,d=c===""?"":" at "+c;Mu(e,"Missing input for "+K(r)+d)}return ir(l)}}function Zi(e,t,r){for(;;){let n=r,i=e,o=t[n];if(o===void 0)return i;r=n+1|0,e=i.d[o]}}function Mr(e,t){if(typeof e!==ie||e===null)return Cn(e);let r=t(e);if(r!==void 0)return r;if(Array.isArray(e)){for(let s=0,f=e.length;s<f;++s){let u=Mr(e[s],t);e[s]=u}let a=me(gt,!1);return a.items=e,a.additionalItems="strict",a.decoder=$n,a}let n=e.constructor;if(n&&n!==Object){let a=me(xn,!0);return a.class=n,a.const=e,a.decoder=Ut,a}let i=Object.keys(e),o=i.length;for(let a=0;a<o;++a){let s=i[a],f=Mr(e[s],t);e[s]=f}let l=me(ie,!1);return l.required=i,l.properties=e,l.additionalItems=Qt.a,l.decoder=dr,l}function ea(e){let t={};xo(t,e);let r=e.e.to,n=br(e,t,r,"");return n.t=!0,n.prev=e,n}function Oo(e){return Mr(e,t=>{if(t["~standard"])return t})}function wo(e){let t=this,r="~"+e,n=t[r];if(n!==void 0)return D(n);let i={},o=[],l=me(ie,!1);l.required=o,l.properties=i,l.additionalItems=Qt.a,l.decoder=dr;let a=t.f(e,l)[vn],s=(d,p)=>{let h=Lt(d);if(d in i)throw new Error("[Sury] "+("The field "+h+" defined twice"));return o.push(d),i[d]=p,Rr(p,a.from.concat(d),a.fromFlattened)},c={field:s,f:s,fieldOr:(d,p,h)=>{let _=Pn(p,void 0);return s(d,To(_,{TAG:"Value",_0:h}))},tag:(d,p)=>{s(d,Oo(p))},nested:wo,flatten:d=>{if(d.type==="object"){let _=d.to,y=d.properties;if(_){let T="Unsupported nested flatten for transformed object schema "+K(d);throw new Error("[Sury] "+T)}let g=Object.keys(y),S={};for(let T=0,C=g.length;T<C;++T){let N=g[T];S[N]=s(N,y[N])}return S}let h="Can't flatten "+K(d)+" schema";throw new Error("[Sury] "+h)}};return t[r]=c,c}function ta(e){let t=jt(Mr(e,Qu));return t.serializer=ea,t}function ra(e){let t=e.e.flattened;if(t!==void 0){let i=[];for(let o=0,l=t.length;o<l;++o){let a=t[o],s=a.to,f;if(s!==void 0){let u=We(e);u.e=a,u.io=!0,f=we(u)}else{let u=Ao(e,a,(m,c)=>Pr(e,m));u.e=a,u.prev=void 0,f=tr(u,u)}i.push(f),e.cp=e.cp+Ne(f,void 0)}e.fv=i}let r=e.e.to,n=vo(e,r);return n.t=!0,n.prev=e,tr(n,e)}function Eo(e){let t,r={},n=u=>{if(u.type==="object"){let d=u.properties,p=Object.keys(d);for(let _=0,y=p.length;_<y;++_){let g=p[_],S=d[g],T=r[g];if(T!==void 0){if(T!==S)throw new Error("[Sury] "+('The field "'+g+'" defined twice with incompatible schemas'))}else r[g]=S}let h=t||(t=[]);return Rr(u,Dr,h.push(u)-1|0)}let c="The '"+K(u)+"' schema can't be flattened";throw new Error("[Sury] "+c)},i=(u,m)=>{if(u in r)throw new Error("[Sury] "+('The field "'+u+'" defined twice with incompatible schemas'));return r[u]=m,Rr(m,[u],void 0)},s=e({field:i,f:i,fieldOr:(u,m,c)=>{let d=Pn(m,void 0);return i(u,To(d,{TAG:"Value",_0:c}))},tag:(u,m)=>{i(u,Oo(m))},nested:wo,flatten:n}),f=me(ie,!1);return f.required=Object.keys(r),f.properties=r,f.additionalItems=Qt.a,f.decoder=dr,f.parser=ra,f.to=ta(s),t!==void 0&&(f.flattened=t),f}var dt=Gn();var ko=co();var bo=On;var Go=In;var fr=Nn;var Be=So;var Co=go;var Ve=K;var Lr=Eo;function No(e){switch(e.code){case"invalid_input":let t=e.expected,r=e.reason;if(!r.startsWith("Expected "+Ve(t)+", received "))return r;let n=Ve(e.received);return n==="unknown"?"Expected "+Ve(t):"Expected "+Ve(t)+", received "+n;case"invalid_operation":return"invalid operation";case"unsupported_decode":return"unsupported decode from "+Ve(e.from)+" to "+Ve(e.to);case"invalid_conversion":return"invalid conversion from "+Ve(e.from)+" to "+Ve(e.to);case"unrecognized_keys":return e.keys.length.toString()+" unrecognized key(s)"}}function ia(e){let t=e.path,r=t===""?"Failed: "+No(e):"Failed at "+t+": "+No(e);return{path:t,summary:r}}function A(e){return{path:"",summary:e}}function Rn(e,t){try{return{TAG:"Ok",_0:Co(e,t)}}catch(r){let n=j(r);if(n.RE_EXN_ID===bo)return{TAG:"Error",_0:ia(n._1)};throw n}}import*as zr from"node:fs";import*as Ro from"node:os";import*as qr from"node:path";function Mo(){return qr.join(Ro.homedir(),".linzumi","auth.json")}var $o="Kandan auth cache must contain a JSON object",oa="Kandan auth cache local_codex_runner must be an object",la="Kandan auth cache personal_agent_delegation must be an object";function Io(e){if(typeof e!="object"||e===null||Array.isArray(e))return;let t=e.access_token,r=e.issued_at;if(t===void 0||typeof t!="string"||r===void 0||typeof r!="string")return;let n=e.expires_at,i;return i=typeof n=="string"?n:void 0,{accessToken:t,issuedAt:r,expiresAt:i}}function Do(e){let t;try{t=JSON.parse(e)}catch{t=void 0}if(t===void 0)return{TAG:"Error",_0:A($o)};if(typeof t!="object"||t===null||Array.isArray(t))return{TAG:"Error",_0:A($o)};let r=t.local_codex_runner,n=t.personal_agent_delegation,i=r!==void 0?typeof r=="object"&&r!==null&&!Array.isArray(r):!0,o=n!==void 0?typeof n=="object"&&n!==null&&!Array.isArray(n):!0;if(!i)return{TAG:"Error",_0:A(oa)};if(!o)return{TAG:"Error",_0:A(la)};let l;return l=typeof r=="object"&&r!==null&&!Array.isArray(r)?Object.fromEntries(De(Object.entries(r),a=>{let s=a[0];return ve(Io(a[1]),f=>[s,f])})):void 0,{TAG:"Ok",_0:{serverTokens:l,personalAgentDelegation:q(n,Io)}}}function ua(e){return zr.existsSync(e)?P(U(tt(e),t=>A(t.message)),t=>Z(Do(t),r=>r)):{TAG:"Ok",_0:void 0}}function aa(e,t){return e!==void 0?new Date(e).getTime()<=t:!1}function jo(e,t,r){return zr.existsSync(t)?P(ua(t),n=>Z(U(ce(e),A),i=>q(q(q(n,o=>o.serverTokens),o=>o[i]),o=>{if(!(o.accessToken.trim()===""||aa(o.expiresAt,r)))return{accessToken:o.accessToken,expiresAt:o.expiresAt}}))):{TAG:"Ok",_0:void 0}}function Po(e){let t={};t.access_token=e.accessToken,t.issued_at=e.issuedAt;let r=e.expiresAt;return r!==void 0&&(t.expires_at=r),t}function sa(e){let t={};t.version=1;let r=e.serverTokens;r!==void 0&&(t.local_codex_runner=Object.fromEntries(Object.entries(r).map(i=>[i[0],Po(i[1])])));let n=e.personalAgentDelegation;return n!==void 0&&(t.personal_agent_delegation=Po(n)),t}function Uo(e,t,r,n,i){return P(U(ce(e),A),o=>{let l=zr.existsSync(n)?P(U(tt(n),a=>A(a.message)),Do):{TAG:"Ok",_0:{serverTokens:void 0,personalAgentDelegation:void 0}};return P(l,a=>{let s=i.toISOString(),f=ve(r,y=>new Date(i.getTime()+y*1e3).toISOString()),u={accessToken:t,issuedAt:s,expiresAt:f},m=a.serverTokens,c=m!==void 0?Object.fromEntries(Object.entries(m)):{};c[o]=u;let d=sa({serverTokens:c,personalAgentDelegation:a.personalAgentDelegation}),p=JSON.stringify(d,void 0,2)+`
9
+ `,h=n+".tmp."+process.pid.toString()+"."+Bi(6),_=y=>A(y.message);return P(U(Xt(qr.dirname(n)),_),()=>{let y=P(Kt(h,p,{encoding:"utf8",mode:384}),()=>qi(h,n));return y.TAG==="Ok"?{TAG:"Ok",_0:{accessToken:t,expiresAt:f}}:(Ji(h),{TAG:"Error",_0:A(y._0.message)})})})})}function zo(e){return e._0}var wf=new RegExp("^[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?(?:\\.[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?)*$"),Ef=new RegExp("^[0-9.]+$");function Mn(e){if(typeof e!="string")return;let t=e.trim();if(t!=="")return t}function Dn(e){return isFinite(e)?Math.trunc(e)===e:!1}function ma(e){if(typeof e=="number"&&e%1===0)return e}function pa(e){let t=e.replaceAll("-","+").replaceAll("_","/");switch(t.length&3){case 2:return t+"==";case 3:return t+"=";default:return t}}function ha(e){let t=e.split(".")[1];if(t===void 0)return;let r=Buffer.from(pa(t),"base64").toString("utf8"),n;try{n=JSON.parse(r)}catch{n=void 0}if(typeof n=="object"&&n!==null&&!Array.isArray(n))return n}function Un(e){let t=q(ha(e),r=>ma(r.exp));if(t===void 0)return{TAG:"Ok",_0:void 0};if(t<=0)return{TAG:"Ok",_0:void 0};try{return{TAG:"Ok",_0:new Date(t*1e3).toISOString()}}catch(r){let n=j(r),i=Ce(n);return{TAG:"Error",_0:A(i!==void 0?$(Ae(D(i)),"unknown error"):"unknown error")}}}import*as Vo from"node:http";import*as Ho from"node:crypto";function qt(e){let t=Ce(e);return t!==void 0?$(Ae(D(t)),"unknown error"):"unknown error"}async function xt(e,t){try{return{TAG:"Ok",_0:await fetch(e,t)}}catch(r){let n=j(r);return{TAG:"Error",_0:{message:qt(n)}}}}async function ya(e){try{return{TAG:"Ok",_0:await e.text()}}catch(t){let r=j(t);return{TAG:"Error",_0:{message:qt(r)}}}}async function Ot(e){let t=await ya(e);if(t.TAG!=="Ok")return{TAG:"Error",_0:t._0};try{return{TAG:"Ok",_0:JSON.parse(t._0)}}catch(r){let n=j(r);return{TAG:"Error",_0:{message:qt(n)}}}}import*as Ko from"node:child_process";function Jr(e){if(typeof e!="object"||e===null||Array.isArray(e))return;let t=e.error;if(typeof t=="string")return t}function qo(e,t){if(e===void 0)return t!==void 0?"local runner device authorization failed (HTTP "+t.toString()+", no reason returned by the server)":"local runner device authorization failed (no reason returned by the server)";switch(e){case"access_denied":return"local runner device authorization was denied";case"approving_user_not_found":return"local runner device authorization failed: the approving Linzumi account could not be found";case"device_session_consumed":return"local runner device authorization was already used";case"device_session_expired":return"local runner device authorization expired";case"device_session_not_pending":return"local runner device authorization was already decided (approved or denied) on the server";case"invalid_device_code":return"local runner device authorization code was rejected";case"invalid_user_code":return"local runner device authorization code was not recognized by the server";case"rate_limited":return"local runner device authorization was rate limited by the server; wait a minute and retry";default:return"local runner device authorization failed (server said: "+e+")"}}function Jt(e,t){let r=e[t];if(r!==void 0&&typeof r=="string"&&r.trim()!=="")return r}async function Jo(e,t,r,n,i){let o=qe("/api/v2/local-codex-runner/device/start",e);if(o.TAG!=="Ok")return{TAG:"Error",_0:A(o._0)};let l={},a=(_,y)=>{if(y!==void 0){l[_]=y;return}};a("workspace",t),a("channel",r),a("onboarding",n),i!==void 0&&(a("runner_id",i.commanderId),a("machine_fingerprint",i.machineFingerprint),a("hostname",i.hostname));let s={};s["content-type"]="application/json";let f=await xt(o._0.toString(),{method:"POST",headers:s,body:JSON.stringify(l)});if(f.TAG!=="Ok")return{TAG:"Error",_0:A(f._0.message)};let u=f._0,m=u.status,c=await Ot(u);if(c.TAG!=="Ok")return{TAG:"Error",_0:A(c._0.message)};let d=c._0;if(m>=200&&m<300){if(Array.isArray(d))return{TAG:"Error",_0:A("local runner device authorization response was incomplete")};if(d!==null)switch(typeof d){case"object":let _=Jt(d,"device_code"),y=Jt(d,"user_code"),g=Jt(d,"verification_uri");if(_===void 0)return{TAG:"Error",_0:A("local runner device authorization response was incomplete")};if(y===void 0)return{TAG:"Error",_0:A("local runner device authorization response was incomplete")};if(g===void 0)return{TAG:"Error",_0:A("local runner device authorization response was incomplete")};let S=d.expires_in,T;return T=typeof S=="number"?S:void 0,{TAG:"Ok",_0:{deviceCode:_,userCode:y,verificationUri:g,expiresInSeconds:T}}}}let h=Jr(d);return{TAG:"Error",_0:A(h!==void 0?"local runner device authorization failed to start (server said: "+h+")":"local runner device authorization failed to start (HTTP "+m.toString()+")")}}async function ga(e,t,r){let n=new AbortController,i=setTimeout(()=>{n.abort()},r+1e4|0),o={};o.device_code=t,o.wait_ms=r;let l={};l["content-type"]="application/json";let a=qe("/api/v2/local-codex-runner/device/token",e),s;if(s=a.TAG==="Ok"?await xt(a._0.toString(),{method:"POST",headers:l,body:JSON.stringify(o),signal:Te(n.signal)}):{TAG:"Error",_0:{message:a._0}},s.TAG==="Ok"){let f=s._0,u=f.status,m=await Ot(f);if(clearTimeout(i),m.TAG!=="Ok")return n.signal.aborted?"Continue":{TAG:"Done",_0:{TAG:"Transient",reason:"non-JSON device/token response ("+m._0.message+")",httpStatus:u}};let c=m._0,d=u>=200&&u<300,p=Jr(c),h=0;if(u!==202||p===void 0)h=1;else{if(p==="authorization_pending")return"Continue";h=1}if(h===1){let _=0;if(d){if(Array.isArray(c))return{TAG:"Done",_0:{TAG:"Rejected",reason:"device token response did not include access_token",httpStatus:u}};if(c===null)_=2;else switch(typeof c){case"object":let y=Jt(c,"access_token");if(y===void 0)return{TAG:"Done",_0:{TAG:"Rejected",reason:"device token response did not include access_token",httpStatus:u}};let g=c.expires_in,S;return S=typeof g=="number"?g:void 0,{TAG:"Done",_0:{TAG:"Token",_0:{accessToken:y,expiresInSeconds:S}}};default:_=2}}else _=2;if(_===2){let y=0;if(p!==void 0)switch(p){case"access_denied":return{TAG:"Done",_0:"Denied"};case"device_session_consumed":return{TAG:"Done",_0:"Consumed"};case"device_session_expired":return{TAG:"Done",_0:"CodeExpired"};default:y=3}else y=3;if(y===3)return u>=500||u===429?{TAG:"Done",_0:{TAG:"Transient",reason:p!==void 0?p:"HTTP "+u.toString(),httpStatus:u}}:{TAG:"Done",_0:{TAG:"Rejected",reason:p,httpStatus:u}}}}}else return clearTimeout(i),n.signal.aborted?"Continue":{TAG:"Done",_0:{TAG:"Transient",reason:s._0.message,httpStatus:void 0}}}async function Wo(e,t,r){let n=r!==void 0&&r>=0?r:600,i=Date.now()+n*1e3,o=async()=>{if(Date.now()>=i)return"CodeExpired";let l=Math.max(0,Math.min(3e4,i-Date.now())),a=await ga(e,t,l);return typeof a!="object"?await o():a._0};return await o()}function Xo(e,t){if(e!==void 0&&isFinite(e)&&e>0)return e;let r=ve(Zt(t,"LINZUMI_OAUTH_CALLBACK_TIMEOUT_MS"),i=>i.trim());if(r===void 0||r==="")return 3e5;let n=Number.parseInt(r,10);return isFinite(n)&&n>0?n:3e5}function Sa(e){let t=e.split(".").map(o=>Number.parseInt(o,10));if(t.length!==4||t.some(o=>!Number.isInteger(o)||o<0?!0:o>255))return e==="localhost";let n=t[0],i=t[1];return n!==void 0&&i!==void 0?n===10||n===127||n===172&&i>=16&&i<=31||n===192&&i===168||n===169&&i===254?!0:n===100&&i>=64?i<=127:!1:!1}function Ta(e){try{return{TAG:"Ok",_0:new URL(e)}}catch(t){let r=j(t);return{TAG:"Error",_0:qt(r)}}}function Aa(e,t){let r=ve(t,o=>o.trim());if(r!==void 0&&r!=="")return{TAG:"Ok",_0:r};let n=Ta(e);if(n.TAG!=="Ok")return{TAG:"Error",_0:n._0};let i=n._0.hostname.trim();return Sa(i)&&i!=="localhost"?{TAG:"Ok",_0:i}:{TAG:"Ok",_0:"127.0.0.1"}}function va(e,t,r,n,i,o,l){return Z(qe("/api/v2/local-codex-runner/oauth/authorize",e),a=>{let s=a.searchParams;return s.set("redirect_uri",t),s.set("state",r),n!==void 0&&s.set("workspace",n),i!==void 0&&s.set("channel",i),o!==void 0&&s.set("onboarding",o),l!==void 0&&s.set("purpose","persisted_documents_publish"),a.toString()})}async function xa(e,t,r){let n=qe("/api/v2/local-codex-runner/oauth/token",e);if(n.TAG!=="Ok")return{TAG:"Error",_0:A(n._0)};let i={};i.code=t,i.redirect_uri=r;let o={};o["content-type"]="application/json";let l=await xt(n._0.toString(),{method:"POST",headers:o,body:JSON.stringify(i)});if(l.TAG!=="Ok")return{TAG:"Error",_0:A(l._0.message)};let a=l._0,s=a.status,f=await Ot(a);if(f.TAG!=="Ok")return{TAG:"Error",_0:A(f._0.message)};let u=f._0;if(s>=200&&s<300){if(Array.isArray(u))return{TAG:"Error",_0:A("local runner OAuth token response did not include access_token")};if(u!==null)switch(typeof u){case"object":let d=Jt(u,"access_token");if(d===void 0)return{TAG:"Error",_0:A("local runner OAuth token response did not include access_token")};let p=u.expires_in,h;return h=typeof p=="number"?p:void 0,{TAG:"Ok",_0:{accessToken:d,expiresInSeconds:h}}}}let c=Jr(u);return c!==void 0?c==="admin_role_required"?{TAG:"Error",_0:A("This token requires a Linzumi admin account. Approve the request while signed in as an admin.")}:{TAG:"Error",_0:A("local runner OAuth token exchange failed: "+c)}:{TAG:"Error",_0:A("local runner OAuth token exchange failed")}}function zn(e){return e.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;")}var Oa='<svg viewBox="0 0 512 512" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"><path fill="currentColor" d="M206.7,82.37l2.55-6.45,2.01-3.63c.67-1.21,1.07-1.88,2.55-3.63,1.34-1.61,3.36-4.43,5.64-6.58,2.42-2.24,5.06-4.3,7.93-6.18,3.92-2.53,8.17-4.52,12.63-5.91,1.79-.63,4.03-1.16,6.72-1.61,6.1-.88,12.29-.92,18.4-.13,2.69.45,5.06,1.03,7.12,1.75,2.15.67,3.49,1.07,5.64,2.15,4.55,2.16,8.87,4.77,12.9,7.79,1.61,1.34,2.42,2.15,4.16,4.16l5.91,7.66c1.34,2.01,1.34,2.28,2.15,4.03l2.55,6.58c.67,1.34-.13,1.34,1.07.94,1.21-.27,4.3-2.01,6.45-2.82,4.7-1.83,9.62-3,14.64-3.49,2.42-.27,3.76-.54,7.12-.27s9.27,1.21,12.76,2.15c3.63.94,6.58,2.55,8.73,3.49,2.15,1.07,2.55,1.48,4.16,2.55,3.49,2.51,6.77,5.29,9.81,8.33,1.52,1.7,3.04,3.58,4.57,5.64,2.74,4.49,4.86,9.32,6.31,14.37.67,2.28,1.07,3.49,1.34,6.72.27,3.22,0,10.48.4,12.76.27,2.28.27.67,1.61.94,1.48.27,4.3,0,6.72.4,2.42.27,4.97.85,7.66,1.75,6.76,2.32,13.01,5.92,18.4,10.61,2.28,1.75,2.96,2.69,4.3,4.3,3.51,3.93,6.32,8.43,8.33,13.3,1.07,2.15,1.21,2.28,1.88,5.1.54,2.96,1.61,8.19,1.61,12.36s-.81,9.67-1.34,12.76c-.67,3.22-1.07,4.03-2.15,6.18-2.16,4.54-4.81,8.82-7.93,12.76-1.25,1.61-2.6,3-4.03,4.16-1.48,1.34-2.69,2.42-4.7,3.76-3.79,2.34-7.74,4.4-11.82,6.18l-6.58,2.15c-2.06.45-4.12.72-6.18.81l-7.25.13c-2.28,0-2.82.27-6.58-.4-3.76-.81-11.69-2.82-15.99-4.3-4.16-1.34-6.31-2.69-9.67-4.43-3.49-1.75-10.48-6.18-12.9-7.39-8.26-4.54-16.78-8.58-25.52-12.09-4.3-1.75-9.27-3.22-11.82-4.03-2.55-.81-5.24-1.61-7.66-2.15-8.39-2.25-16.99-3.6-25.66-4.03-3.9-.27-4.84-.27-8.19-.13-3.67-.09-7.79.04-12.36.4-7.9.79-15.75,2.04-23.51,3.76-8.37,2.26-16.62,4.95-24.72,8.06-3.22,1.34-2.82.81-9.13,4.16-6.31,3.36-22.03,12.22-28.75,15.58-6.72,3.36-8.73,3.49-11.82,4.43-3.09,1.07-4.3,1.21-6.58,1.61-7.3,1.09-14.71,1.18-22.03.27-2.55-.54-5.78-1.61-7.79-2.28-2.01-.54-2.15-.67-4.03-1.75-2.02-1.07-5.64-3.22-7.79-4.7-3.24-2.15-6.14-4.77-8.6-7.79-1.34-1.52-2.69-3.36-4.03-5.51-1.52-2.51-2.96-5.24-4.3-8.19-2.03-5.46-3.03-11.24-2.96-17.06,0-2.96.13-6.72.67-9.67.54-2.87,1.34-5.6,2.42-8.19,4.24-10.52,12.04-19.22,22.03-24.58,5.19-2.98,10.88-4.98,16.79-5.91,2.55-.4,5.37-.13,6.72-.4,1.34-.27,1.34,1.34,1.61-.94.4-2.28,0-9.4.4-12.76.27-3.36.81-4.97,1.48-7.25,1.87-6.19,4.88-11.97,8.87-17.06,3.47-3.98,7.39-7.54,11.69-10.61,4.43-2.61,9.11-4.77,13.97-6.45,2.55-.67,6.99-1.34,9.13-1.75,2.15-.27,1.88-.13,3.63-.13,1.79-.09,4.03,0,6.72.27,2.69.18,5.73.72,9.13,1.61,3.49,1.07,9.27,4.03,11.28,4.7s.4.27,1.07-.94ZM512.27,255.7c0,141.39-114.62,256-256,256S.27,397.09.27,255.7,114.89-.3,256.27-.3s256,114.62,256,256ZM449.33,352.66c14.67-29.16,22.94-62.09,22.94-96.95,0-119.29-96.71-216-216-216S40.27,136.41,40.27,255.7c0,41.89,11.94,80.98,32.57,114.09,1.7,1.79,2.94.65,3.05-.57.27-1.61,2.75-20.85,4.43-27.27,1.87-7.6,4.52-14.98,7.93-22.03,1.75-3.49,3.76-7.93,6.18-11.82,8.77-13.95,19.75-26.38,32.51-36.81,7.24-5.32,14.87-10.08,22.84-14.24,9.74-4.78,20.09-8.22,30.76-10.21,4.03-.99,7.61-1.66,10.75-2.02,3.36-.54,5.78-.54,9.27-.94,3.49-.54,9.32-1.16,11.82-2.01,6.65-2.27,5.64-6.72,3.09-7.52-2.55-.81-9.67-1.88-13.84-2.96-4.16-1.21-8.73-2.82-11.28-3.76-2.55-.94-2.28-.94-3.9-2.02l-5.91-4.03c-.94-.94-1.34-.94.54-2.02l10.21-5.51c2.01-1.07,1.75-.67,3.09-.13,1.34.67,4.3,2.42,6.72,3.36,7.2,2.69,14.96,3.52,22.57,2.42,1.34-.27,1.34-.54,1.61-1.21.27-.67.81-.94-.13-2.69-.94-1.88-4.43-6.58-5.64-8.46l-1.21-2.28c-.27-.45-1.07-1.07,1.21-1.75,2.42-.54,10.48-2.58,12.9-2.82.86-.09.67,0,1.75,1.07,1.07,1.07,3.09,3.63,4.84,5.24,1.88,1.61,4.43,3.22,6.18,4.3,2.8,1.71,5.99,2.68,9.27,2.82,1.88,0,4.97-.13,7.12-.67,2.15-.4,3.63-.94,5.64-2.02,2.01-1.07,4.7-2.69,6.72-4.43,2.01-1.75,3.49-5.1,5.64-6.04,2.15-.81,4.97.54,7.12.94,2.28.4,4.97,1.21,6.18,1.61,1.21.4,2.01.4.67,2.28l-8.06,10.34c-1.34,1.88.13,5.51,1.21,5.64l5.64.27c2.28-.13,4.43.13,7.66-.67,3.36-.81,9.27-2.96,11.82-3.9,2.69-.94,3.22-1.34,4.16-2.01.81-.54,1.39-1.03,1.75-1.48.45-.27.67-1.07,2.82,0s9.4,4.97,11.28,6.18c2.01,1.21,1.07.94,0,1.75l-5.51,3.9c-1.48.94-1.07.94-3.22,1.88-2.15,1.07-6.58,2.96-9.67,4.03s-4.03,1.75-8.73,2.69c-4.7.81-14.51,1.75-19.48,2.55-4.97.81-7.93,1.34-10.34,2.01-2.28.67-2.15.94-3.49,1.88-1.48,1.07-2.69,1.61-4.97,3.9-2.28,2.28-5.91,6.85-8.73,9.81-2.82,2.96-6.45,6.04-8.33,7.79-2.02,1.61-1.61,1.34-3.36,2.42l-6.99,4.03-4.03,2.02-6.72,2.15c-2.42.67-3.9,1.21-7.66,2.01l-14.91,2.82c-3.63.81-4.3,1.07-7.12,2.01-2.96,1.07-6.22,2.46-9.81,4.16-3.22,1.43-6.81,3.45-10.75,6.04-13.6,9.14-24.61,21.63-31.97,36.27-2.01,3.76-2.96,6.58-3.9,9.27-1.07,2.69-1.61,4.03-2.28,6.58-.67,2.69-1.48,5.24-2.15,9.27-.54,4.16-1.48,11.15-1.75,15.45-.27,4.16-.27,6.04,0,10.21l1.88,14.91c.67,3.76,1.48,5.91,2.15,8.19l1.88,5.64c.99,2.6,2.42,5.78,4.3,9.54,2.15,3.76,5.37,9.13,8.06,13.03,10.08,14.51,23.81,26.36,40.17,33.05,22.55,9.22,43.32,10.46,61.89,10.46,3.25,0,6.49-.09,9.71-.23,3.07-.42,2.74-6.09,10.48-9.42,5.26-2.26,13.7-2.42,14.91-2.55,1.07-.13-5.24-4.57-7.79-6.45-2.55-1.88-4.97-4.3-6.72-5.91-1.75-1.75-2.42-2.28-3.9-4.16-1.61-1.88-3.9-5.51-5.24-7.12-1.34-1.61-1.48-2.28-2.55-2.55-.98-.27-2.37-.09-4.16.54-1.88.4-5.37,1.21-7.12,1.88-1.75.67-2.02.81-3.09,2.01-1.07,1.07-2.69,3.76-3.63,4.7-.81.94-.67.67-1.48.94-.81.27-2.42.67-3.63.54-1.34-.18-2.55-.58-3.63-1.21-.81-.81-1.48-2.42-1.88-3.22-.4-.94-.54-1.21-.54-2.15l.4-3.49c.18-1.52.72-3.27,1.61-5.24.94-1.75,1.88-3.49,4.16-5.64,2.15-2.02,7.52-5.51,9.13-6.85,1.61-1.34,1.21-2.15.54-3.63-2.69-5.16-6.33-9.77-10.75-13.57-2.42-1.88-5.51-3.22-7.79-4.3-2.15-1.21-2.01-1.21-5.78-2.42-3.76-1.07-13.16-3.63-16.79-4.84-3.63-1.07-2.82-.94-5.1-2.01l-8.19-4.3c-1.75-.94-1.34-.54-2.69-1.61l-5.51-4.57c-2.18-1.93-3.77-4.45-4.57-7.25-.45-1.52-.45-2.87,0-4.03.4-1.34,0-1.21,2.01-3.63,2.15-2.42,7.25-7.93,10.21-10.75,3.09-2.82,4.97-4.03,7.79-6.04,5.43-3.82,11.09-7.32,16.93-10.48,2.42-1.21,5.37-2.02,7.12-2.69,1.61-.81,2.64-1.43,3.09-1.88.54-.4.67.54.4-.94-.4-1.48-1.88-4.97-2.28-7.66-.4-2.82-.4-6.18,0-8.73.36-2.42,1.03-4.66,2.01-6.72,1.16-2.24,2.46-4.3,3.9-6.18,1.34-1.7,2.91-3.04,4.7-4.03,1.75-1.07,4.3-2.01,6.18-2.42,1.61-.45,3.13-.58,4.57-.4l4.57.27c1.34.18,2.55.49,3.63.94,1.07.54,2.55,1.48,3.09,2.01.4.67.67.13-.27,1.61-1.07,1.48-4.16,4.57-5.78,7.12-1.61,2.69-2.96,5.6-4.03,8.73-.94,3.22-1.88,8.73-2.01,10.75-.27,2.15,4.7,1.75,5.1.54.54-1.07.27-2.55,1.07-5.1.81-2.42,2.42-7.25,3.9-9.81,1.34-2.55,2.82-3.76,4.57-5.51,1.79-1.88,3.67-3.45,5.64-4.7,1.88-1.21,3.22-1.75,5.64-2.28,2.42-.4,6.18-.67,8.73-.67,2.42,0,3.9.13,6.18.94,2.15.81,5.24,2.69,7.12,4.03,1.79,1.52,3.22,3.09,4.3,4.7,1.21,1.61,1.88,2.96,2.55,5.1.67,2.15,1.34,5.1,1.34,7.66,0,2.69-.54,6.04-1.21,8.19-.63,2.24-1.43,4.03-2.42,5.37-.67,1.34-.94,1.61-2.15,2.82-1.21,1.34-3.22,3.22-4.97,4.57-1.75,1.21-4.43,2.28-5.51,3.22-.94.81-.4,2.51.4,2.42.94.13,1.75.4,4.57-.13,2.82-.4,8.33-2.15,12.22-2.82,11.99-2.63,24.41-2.63,36.4,0,3.22.54,4.16,1.07,6.31,1.75l6.04,2.28c2.42,1.07,5.51,2.42,8.19,4.16,8.15,5.36,15.14,12.3,20.55,20.42,1.61,2.42,2.87,4.66,3.76,6.72,1.85,4.51,3.42,9.13,4.7,13.84.67,2.82,1.21,4.43,1.61,8.19.4,3.76.4,11.82.54,14.37.27,2.55-.13,2.28,1.75,1.34,1.75-.94,20.09-7.74,30.63-31.57,9.16-20.71,1.9-47.26-2.28-55.34-1.75-3.22-4.16-6.99-6.31-9.81-4.44-5.14-9.6-9.62-15.31-13.3-2.96-1.7-5.55-3.09-7.79-4.16-4.33-1.6-8.77-2.86-13.3-3.76l-6.18-.4h-14.37c-2.69-.27-3.1-3.18-.54-4.3,3.64-1.58,9.88-2.63,18.54-2.42,8.78.21,14.91,1.88,17.33,2.55,13.98,3.94,30.19,16.65,38.55,30.76,6.61,11.16,9.81,29.96,9.81,29.96.37,1.75,2.18,1.66,3.08.35ZM232.78,345.3c-3.91,0-7.08,3.17-7.08,7.08s3.17,7.08,7.08,7.08,7.08-3.17,7.08-7.08-3.17-7.08-7.08-7.08Z"/></svg>';function wa(e){let t=e.status>=200&&e.status<300,r=t?"badge badge--success":"badge badge--notice",n=t?'<svg viewBox="0 0 24 24" aria-hidden="true" focusable="false" class="mark"><path fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round" d="M5 12.5l4.2 4.2L19 7"/></svg>':'<svg viewBox="0 0 24 24" aria-hidden="true" focusable="false" class="mark"><path fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round" d="M12 7v6M12 17h.01"/></svg>',i=t?"--success-soft":"--notice-soft";return`<!doctype html>
10
10
  <html lang="en">
11
11
  <head>
12
12
  <meta charset="utf-8" />
13
13
  <meta name="viewport" content="width=device-width, initial-scale=1" />
14
- <title>`+Ln(e.title)+`</title>
14
+ <title>`+zn(e.title)+`</title>
15
15
  <style>
16
16
  :root {
17
17
  color-scheme: light dark;
@@ -102,34 +102,34 @@ GFS4: `),console.error(e)});V[le]||(fi=global[le]||[],mi(V,fi),V.close=(function
102
102
  <body>
103
103
  <main>
104
104
  <div class="`+r+'">'+n+`</div>
105
- <h1>`+Ln(e.title)+`</h1>
106
- <p>`+Ln(e.body)+`</p>
107
- <div class="logo">`+va+`</div>
105
+ <h1>`+zn(e.title)+`</h1>
106
+ <p>`+zn(e.body)+`</p>
107
+ <div class="logo">`+Oa+`</div>
108
108
  </main>
109
109
  </body>
110
- </html>`}function fr(e,t){let r={};r["content-type"]="text/html; charset=utf-8",e.writeHead(t.status,r),e.end(wa(t))}var Oa=new RegExp('[&^|<>()%"]',"g");function xa(e){let t=$t(e);if(t===void 0)return e;let r=D(t),n=r.searchParams;return Vi(n).includes("state")?(n.set("state","<SENSITIVE_DATA>"),r.toString()):e}function Ea(e,t){switch(e){case"darwin":return["open",[t]];case"win32":return["cmd",["/c","start","",t.replace(Oa,"^$&")]];default:return["xdg-open",[t]]}}function Ko(e,t,r){let n=Ea(t,r),i=n[1],o=n[0];return new Promise((l,a)=>{let s=(u,m)=>{let c={};return c.command=o,c.args=i.map(d=>xa(d)),u!==void 0&&(c.pid=u),m!==void 0&&(c.message=m),c.purpose="oauth.open_browser",c};e("process.spawn",s(void 0,void 0));let f=Vo.spawn(o,i,{stdio:["ignore","ignore","ignore"],detached:!0});e("process.spawned",s(Ze(f.pid),void 0)),f.on("error",u=>{e("process.spawn_failed",s(Ze(f.pid),u.message)),l()}),f.on("spawn",()=>{f.unref(),l()})})}function ka(e,t,r){return new Promise((n,i)=>{let o={contents:void 0},l=new Promise((c,d)=>{o.contents=c}),a={contents:!1},s=c=>{if(a.contents)return!1;a.contents=!0;let d=o.contents;return d!==void 0&&d(c),!0},f={contents:"http://"+e+"/callback"},u=async(c,d)=>{let p=$(Ze(c.url),"/"),h=qe(p,"http://"+e);if(h.TAG==="Ok"){let _=h._0.searchParams,y=_.get("code"),g=_.get("state"),S=_.get("error"),T=0;if(S==null)T=1;else{if(S.trim()!=="")return s({TAG:"Error",_0:A("local runner OAuth failed: "+S)}),fr(d,{title:"Not authorized",body:"You denied the request. Close this tab and rerun the bootstrap command when you're ready.",status:403});T=1}if(T===1){let C=0;if(y==null||g==null)C=2;else{if(y.trim()!==""&&g.trim()!==""){let N=await r({code:y,state:g,redirectUri:f.contents});if(N.TAG==="Ok"){let H=s({TAG:"Ok",_0:N._0});return fr(d,{title:H?"Computer authorized":"Already authorized",body:"This computer has been authorized for agentic use in Linzumi. Feel free to close this tab and let the terminal finish setup.",status:200})}return s({TAG:"Error",_0:N._0}),fr(d,{title:"Authorization could not be completed",body:"We received the authorization but could not finish setup. Return to your terminal for details and rerun the bootstrap command.",status:400})}C=2}if(C===2)return fr(d,{title:"Authorization callback was incomplete",body:"We didn't receive the authorization code. Return to your terminal and try again.",status:400})}}else return s({TAG:"Error",_0:A(h._0)}),fr(d,{title:"Authorization callback failed",body:"Return to your terminal and rerun the bootstrap command.",status:500})},m=Wo.createServer((c,d)=>{u(c,d)});m.once("error",c=>n({TAG:"Error",_0:A(c.message)})),m.listen(0,e,()=>{let c=m.address(),d;if(c==null||typeof c!="object"||c===null||Array.isArray(c))d=void 0;else{let h=c.port;d=typeof h=="number"?h:void 0}if(d===void 0)return n({TAG:"Error",_0:A("local runner OAuth callback server did not bind to a TCP port")});f.contents="http://"+e+":"+d.toString()+"/callback";let p;if(c==null||typeof c!="object"||c===null||Array.isArray(c))p="";else{let h=c.address;p=typeof h=="string"?h:""}n({TAG:"Ok",_0:{redirectUri:f.contents,boundAddress:p,waitForToken:h=>{let _=Ho(h,t),y=setTimeout(()=>{s({TAG:"Error",_0:A("Authorization timed out before the browser callback completed. Rerun the connect command and finish authorizing in the browser.")}),m.close()},_);return y.unref(),l.then(g=>{clearTimeout(y)}),l},close:()=>{m.close()}}})})})}async function Xo(e,t,r,n,i,o,l,a,s,f){let u=U(ce(e),A);if(u.TAG!=="Ok")return{TAG:"Error",_0:u._0};let m=u._0,c=U(Sa(e,o),A);if(c.TAG!=="Ok")return{TAG:"Error",_0:c._0};let d=Bo.randomBytes(18).toString("base64url"),p=await ka(c._0,l,y=>y.state===d?Aa(m,y.code,y.redirectUri):Promise.resolve({TAG:"Error",_0:A("local runner OAuth state mismatch")}));if(p.TAG!=="Ok")return{TAG:"Error",_0:p._0};let h=p._0,_=U(Ta(m,h.redirectUri,d,t,r,n,i),A);if(_.TAG==="Ok"){let y=_._0;a(`Authorize the local Codex runner:
110
+ </html>`}function cr(e,t){let r={};r["content-type"]="text/html; charset=utf-8",e.writeHead(t.status,r),e.end(wa(t))}var Ea=new RegExp('[&^|<>()%"]',"g");function ka(e){let t=It(e);if(t===void 0)return e;let r=D(t),n=r.searchParams;return Hi(n).includes("state")?(n.set("state","<SENSITIVE_DATA>"),r.toString()):e}function ba(e,t){switch(e){case"darwin":return["open",[t]];case"win32":return["cmd",["/c","start","",t.replace(Ea,"^$&")]];default:return["xdg-open",[t]]}}function Zo(e,t,r){let n=ba(t,r),i=n[1],o=n[0];return new Promise((l,a)=>{let s=(u,m)=>{let c={};return c.command=o,c.args=i.map(d=>ka(d)),u!==void 0&&(c.pid=u),m!==void 0&&(c.message=m),c.purpose="oauth.open_browser",c};e("process.spawn",s(void 0,void 0));let f=Ko.spawn(o,i,{stdio:["ignore","ignore","ignore"],detached:!0});e("process.spawned",s(Ye(f.pid),void 0)),f.on("error",u=>{e("process.spawn_failed",s(Ye(f.pid),u.message)),l()}),f.on("spawn",()=>{f.unref(),l()})})}function Ga(e,t,r){return new Promise((n,i)=>{let o={contents:void 0},l=new Promise((c,d)=>{o.contents=c}),a={contents:!1},s=c=>{if(a.contents)return!1;a.contents=!0;let d=o.contents;return d!==void 0&&d(c),!0},f={contents:"http://"+e+"/callback"},u=async(c,d)=>{let p=$(Ye(c.url),"/"),h=qe(p,"http://"+e);if(h.TAG==="Ok"){let _=h._0.searchParams,y=_.get("code"),g=_.get("state"),S=_.get("error"),T=0;if(S==null)T=1;else{if(S.trim()!=="")return s({TAG:"Error",_0:A("local runner OAuth failed: "+S)}),cr(d,{title:"Not authorized",body:"You denied the request. Close this tab and rerun the bootstrap command when you're ready.",status:403});T=1}if(T===1){let C=0;if(y==null||g==null)C=2;else{if(y.trim()!==""&&g.trim()!==""){let N=await r({code:y,state:g,redirectUri:f.contents});if(N.TAG==="Ok"){let H=s({TAG:"Ok",_0:N._0});return cr(d,{title:H?"Computer authorized":"Already authorized",body:"This computer has been authorized for agentic use in Linzumi. Feel free to close this tab and let the terminal finish setup.",status:200})}return s({TAG:"Error",_0:N._0}),cr(d,{title:"Authorization could not be completed",body:"We received the authorization but could not finish setup. Return to your terminal for details and rerun the bootstrap command.",status:400})}C=2}if(C===2)return cr(d,{title:"Authorization callback was incomplete",body:"We didn't receive the authorization code. Return to your terminal and try again.",status:400})}}else return s({TAG:"Error",_0:A(h._0)}),cr(d,{title:"Authorization callback failed",body:"Return to your terminal and rerun the bootstrap command.",status:500})},m=Vo.createServer((c,d)=>{u(c,d)});m.once("error",c=>n({TAG:"Error",_0:A(c.message)})),m.listen(0,e,()=>{let c=m.address(),d;if(c==null||typeof c!="object"||c===null||Array.isArray(c))d=void 0;else{let h=c.port;d=typeof h=="number"?h:void 0}if(d===void 0)return n({TAG:"Error",_0:A("local runner OAuth callback server did not bind to a TCP port")});f.contents="http://"+e+":"+d.toString()+"/callback";let p;if(c==null||typeof c!="object"||c===null||Array.isArray(c))p="";else{let h=c.address;p=typeof h=="string"?h:""}n({TAG:"Ok",_0:{redirectUri:f.contents,boundAddress:p,waitForToken:h=>{let _=Xo(h,t),y=setTimeout(()=>{s({TAG:"Error",_0:A("Authorization timed out before the browser callback completed. Rerun the connect command and finish authorizing in the browser.")}),m.close()},_);return y.unref(),l.then(g=>{clearTimeout(y)}),l},close:()=>{m.close()}}})})})}async function Yo(e,t,r,n,i,o,l,a,s,f){let u=U(ce(e),A);if(u.TAG!=="Ok")return{TAG:"Error",_0:u._0};let m=u._0,c=U(Aa(e,o),A);if(c.TAG!=="Ok")return{TAG:"Error",_0:c._0};let d=Ho.randomBytes(18).toString("base64url"),p=await Ga(c._0,l,y=>y.state===d?xa(m,y.code,y.redirectUri):Promise.resolve({TAG:"Error",_0:A("local runner OAuth state mismatch")}));if(p.TAG!=="Ok")return{TAG:"Error",_0:p._0};let h=p._0,_=U(va(m,h.redirectUri,d,t,r,n,i),A);if(_.TAG==="Ok"){let y=_._0;a(`Authorize the local Codex runner:
111
111
  `+y+`
112
- `);let g;try{await s(y),g=await h.waitForToken(Ho(f,l))}catch(S){let T=j(S);g={TAG:"Error",_0:A(zt(T))}}return h.close(),g}return h.close(),{TAG:"Error",_0:_._0}}import*as Br from"node:fs";import*as Wn from"node:os";import*as de from"node:path";import*as Bn from"node:crypto";var Ga=new RegExp("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$","i"),Ca=new RegExp("^[a-zA-Z0-9_.-]+$");function zn(e){return Ga.test(e)}function Wr(e){return Ca.test(e)}var Fa=Be(st,e=>e.trim()!=="","allowedCwds entries must be non-empty strings",void 0);function Qo(e){return{version:1,machineId:e.f("machineId",dr(Be(st,zn,"invalid machine id",void 0))),runnerId:e.f("runnerId",dr(Be(st,Wr,"invalid runner id",void 0))),allowedCwds:e.f("allowedCwds",bo(Fa))}}var Na=Ur(Qo),$a=Ur(e=>(e.tag("version",1),Qo(e)));function qn(e){let t=new Set;return De(e,r=>{let n=r.trim();if(!(n===""||t.has(n)))return t.add(n),n})}function el(e){return{version:e.version,machineId:e.machineId,runnerId:e.runnerId,allowedCwds:qn(e.allowedCwds)}}function Jn(e){return X(Pn(e,$a),el)}function tl(e){return X(Pn(e,Na),el)}var Jr=dr(Be(st,e=>e.trim()!=="","must be a non-empty string",void 0)),Zo=dr(Be(Eo,e=>Mn(e)?e>0:!1,"must be a positive integer",void 0));function Ia(e){return!Number.isNaN(new Date(e).getTime())}var Yo=Be(st,Ia,"must be a parseable date",void 0),xf=Ur(e=>({email:e.f("email",Be(st,t=>t.trim()!=="","must be a non-empty string",void 0)),serviceUrl:e.f("service_url",Be(st,t=>t.trim()!=="","must be a non-empty string",void 0)),accessToken:e.f("access_token",Jr),refreshToken:e.f("refresh_token",Jr),expiresInSeconds:e.f("expires_in_seconds",Zo),userId:e.f("user_id",Zo),workspaceSlug:e.f("workspace_slug",Jr),launchUrl:e.f("launch_url",Jr),createdAt:e.f("created_at",Yo),updatedAt:e.f("updated_at",Yo)}));var Re="prod";function rl(e){let t=e!==void 0?e:process.env,r=Xt(t,"HOME");return r!==void 0&&r.trim()!==""?r:Wn.homedir()}function Ra(e,t){let r=e!==void 0?e:process.env;return t==="~"?rl(r):t.startsWith("~/")?de.resolve(rl(r),t.slice(2)):t}function ol(e){let t=Xt(e,"LINZUMI_CONFIG_FILE");return t!==void 0&&t.trim()!==""?de.resolve(Ra(e,t)):de.resolve(Wn.homedir(),".linzumi","config.json")}function cr(e){let t=ce(e),r=ce(Zt);if(t.TAG!=="Ok")return{TAG:"Error",_0:A(t._0)};let n=t._0;return r.TAG==="Ok"?{TAG:"Ok",_0:n===r._0?Re:n}:{TAG:"Error",_0:A(r._0)}}function Ma(e){return X(cr(e),t=>t===Re?Re:Buffer.from(t).toString("base64url"))}function Da(e,t,r){let n=de.dirname(e),i=de.basename(e);return t!==void 0?P(cr(t),o=>o===Re?{TAG:"Ok",_0:de.join(n,i+"."+r)}:X(Ma(t),l=>de.join(n,i+"."+l+"."+r))):{TAG:"Ok",_0:de.join(n,i+"."+r)}}function ll(e){if(Br.existsSync(e))return P(U(et(e),r=>A(r.message)),r=>{let n;try{n=JSON.parse(r)}catch{n=void 0}return typeof n=="object"&&n!==null&&!Array.isArray(n)?Jn(n).TAG==="Ok"?{TAG:"Ok",_0:n}:{TAG:"Error",_0:A("invalid Linzumi config: "+e)}:{TAG:"Error",_0:A("invalid Linzumi config: "+e)}});let t={};return t.version=1,t.allowedCwds=[],{TAG:"Ok",_0:t}}function ja(){let e={};return e.allowedCwds=[],e}function nl(e,t){return P(ll(e),r=>{let n=t!==void 0?cr(t):{TAG:"Ok",_0:Re};return P(n,i=>{let o=i===Re?r:$(r[i],ja()),l=i===Re?Jn(o):tl(o);return U(l,a=>A("invalid Linzumi config section "+i+": "+e))})})}function Ua(e,t){let r=i=>A(i.message),n=Br.existsSync(e)?U(cn(e,384),r):{TAG:"Ok",_0:void 0};return P(P(n,()=>U(Ht(e,JSON.stringify(t,void 0,2)+`
113
- `,{encoding:"utf8",mode:384}),r)),()=>U(cn(e,384),r))}function La(e){let t={},r=e.machineId;r!==void 0&&(t.machineId=r);let n=e.runnerId;return n!==void 0&&(t.runnerId=n),t.allowedCwds=qn(e.allowedCwds).map(i=>i),t}function za(e){let t=e.version===1,r=e.machineId,n=r!==void 0?zn(r):!0,i=e.runnerId,o=i!==void 0?Wr(i):!0,l=e.allowedCwds.every(a=>a.trim()!=="");return t&&n&&o&&l?{TAG:"Ok",_0:void 0}:{TAG:"Error",_0:A("invalid Linzumi config")}}function qa(e,t,r){return P(za(e),()=>{let n=r!==void 0?cr(r):{TAG:"Ok",_0:Re};return P(n,i=>P(ll(t),o=>{let l=Object.fromEntries(Object.entries(o)),a=La(e);return i===Re?(Object.entries(a).forEach(s=>{l[s[0]]=s[1]}),l.version=1):(l.version=1,l[i]=a),P(U(Kt(de.dirname(t)),s=>A(s.message)),()=>Ua(t,l))}))})}function il(e,t,r){return P(U(et(e),n=>A(n.message)),n=>{let i=n.trim();return t(i)?{TAG:"Ok",_0:i}:{TAG:"Error",_0:A("invalid Linzumi "+r+" seed: "+e)}})}function Ja(e,t,r,n){if(Br.existsSync(e))return il(e,r,n);let i=t();if(!r(i))return{TAG:"Error",_0:A("invalid generated Linzumi "+n+": "+i)};let o=de.dirname(e),l=de.basename(e),a=de.join(o,"."+l+"."+process.pid.toString()+"."+Bn.randomUUID()+".tmp"),s=f=>A(f.message);return P(P(U(Kt(o),s),()=>U(Ht(a,i+`
114
- `,{encoding:"utf8",flag:"wx"}),s)),()=>{let f=Ui(a,e),u;if(f.TAG==="Ok")u={TAG:"Ok",_0:i};else{let m=f._0;u=ji(m,"EEXIST")?il(e,r,n):{TAG:"Error",_0:A(m.message)}}return Li(a),u})}function Wa(){return"runner-"+Bn.randomUUID()}function Ba(e,t,r,n,i,o,l,a){let s=t!==void 0?X(cr(t),f=>{if(f!==Re)return t}):{TAG:"Ok",_0:void 0};return P(s,f=>P(nl(e,f),u=>{let m=l(u);return m!==void 0?{TAG:"Ok",_0:m}:P(Da(e,f,r),c=>P(Ja(c,n,i,o),d=>P(nl(e,f),p=>{let h=l(p);return h!==void 0?{TAG:"Ok",_0:h}:X(qa(a(p,d),e,f),()=>d)})))}))}function ul(e,t,r){return Ba(e,t,"runner-id",r!==void 0?r:Wa,Wr,"runner id",i=>i.runnerId,(i,o)=>({version:i.version,machineId:i.machineId,runnerId:o,allowedCwds:i.allowedCwds}))}function Ha(e){if(typeof e=="object"&&e!==null&&!Array.isArray(e))return e}async function al(e,t,r,n,i){let o=i!==void 0?i:[],l=U(ce(e),A);if(l.TAG!=="Ok")return{TAG:"Error",_0:l._0};let a=qe("/api/v2/local-codex-runner/oauth/validate",l._0);if(a.TAG!=="Ok")return{TAG:"Error",_0:A(a._0)};let s=a._0,f=s.searchParams;r!==void 0&&f.set("workspace",r),n!==void 0&&f.set("channel",n),o.forEach(p=>{f.append("required_scope",p)});let u={};u.authorization="Bearer "+t;let m=await vt(s.toString(),{method:"GET",headers:u});if(m.TAG!=="Ok")return{TAG:"Error",_0:A(m._0.message)};let c=m._0,d=c.status;if(d>404||d<401){if(d===200){let p=await wt(c);return p.TAG!=="Ok"?{TAG:"Error",_0:A(p._0.message)}:q(Ha(p._0),_=>_.ok)===!0?{TAG:"Ok",_0:"Usable"}:{TAG:"Ok",_0:"Rejected"}}}else{if(d<402)return{TAG:"Ok",_0:"Rejected"};switch(d){case 402:break;case 403:return{TAG:"Ok",_0:"Rejected"};case 404:return{TAG:"Ok",_0:"NotFound"}}}return{TAG:"Error",_0:A("local runner auth validation failed with HTTP "+d.toString())}}var Xa=3600*1e3;function Za(e,t,r,n){return e<=3?"DecidePrompt":r!==void 0&&t-r<Xa?n?"DecideRefreshLine":"DecideSilent":"DecideSummary"}function sl(e){let t=Math.floor(e/6e4),r=Math.floor(t/60),n=t-r*60;return r>0?r.toString()+"h "+n.toString()+"m":n.toString()+"m"}function Ya(e){switch(e.TAG){case"Prompt":return(e.cycle===1?"":`The previous code expired; here is a fresh one (no restart needed - this prompt stays alive).
112
+ `);let g;try{await s(y),g=await h.waitForToken(Xo(f,l))}catch(S){let T=j(S);g={TAG:"Error",_0:A(qt(T))}}return h.close(),g}return h.close(),{TAG:"Error",_0:_._0}}import*as Vr from"node:fs";import*as Bn from"node:os";import*as de from"node:path";import*as Vn from"node:crypto";var Fa=new RegExp("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$","i"),Na=new RegExp("^[a-zA-Z0-9_.-]+$");function qn(e){return Fa.test(e)}function Br(e){return Na.test(e)}var $a=Be(dt,e=>e.trim()!=="","allowedCwds entries must be non-empty strings",void 0);function tl(e){return{version:1,machineId:e.f("machineId",fr(Be(dt,qn,"invalid machine id",void 0))),runnerId:e.f("runnerId",fr(Be(dt,Br,"invalid runner id",void 0))),allowedCwds:e.f("allowedCwds",Go($a))}}var Ia=Lr(tl),Pa=Lr(e=>(e.tag("version",1),tl(e)));function Jn(e){let t=new Set;return De(e,r=>{let n=r.trim();if(!(n===""||t.has(n)))return t.add(n),n})}function rl(e){return{version:e.version,machineId:e.machineId,runnerId:e.runnerId,allowedCwds:Jn(e.allowedCwds)}}function Wn(e){return Z(Rn(e,Pa),rl)}function nl(e){return Z(Rn(e,Ia),rl)}var Wr=fr(Be(dt,e=>e.trim()!=="","must be a non-empty string",void 0)),Qo=fr(Be(ko,e=>Dn(e)?e>0:!1,"must be a positive integer",void 0));function Ra(e){return!Number.isNaN(new Date(e).getTime())}var el=Be(dt,Ra,"must be a parseable date",void 0),kf=Lr(e=>({email:e.f("email",Be(dt,t=>t.trim()!=="","must be a non-empty string",void 0)),serviceUrl:e.f("service_url",Be(dt,t=>t.trim()!=="","must be a non-empty string",void 0)),accessToken:e.f("access_token",Wr),refreshToken:e.f("refresh_token",Wr),expiresInSeconds:e.f("expires_in_seconds",Qo),userId:e.f("user_id",Qo),workspaceSlug:e.f("workspace_slug",Wr),launchUrl:e.f("launch_url",Wr),createdAt:e.f("created_at",el),updatedAt:e.f("updated_at",el)}));var Re="prod";function il(e){let t=e!==void 0?e:process.env,r=Zt(t,"HOME");return r!==void 0&&r.trim()!==""?r:Bn.homedir()}function Da(e,t){let r=e!==void 0?e:process.env;return t==="~"?il(r):t.startsWith("~/")?de.resolve(il(r),t.slice(2)):t}function ul(e){let t=Zt(e,"LINZUMI_CONFIG_FILE");return t!==void 0&&t.trim()!==""?de.resolve(Da(e,t)):de.resolve(Bn.homedir(),".linzumi","config.json")}function mr(e){let t=ce(e),r=ce(Yt);if(t.TAG!=="Ok")return{TAG:"Error",_0:A(t._0)};let n=t._0;return r.TAG==="Ok"?{TAG:"Ok",_0:n===r._0?Re:n}:{TAG:"Error",_0:A(r._0)}}function ja(e){return Z(mr(e),t=>t===Re?Re:Buffer.from(t).toString("base64url"))}function Ua(e,t,r){let n=de.dirname(e),i=de.basename(e);return t!==void 0?P(mr(t),o=>o===Re?{TAG:"Ok",_0:de.join(n,i+"."+r)}:Z(ja(t),l=>de.join(n,i+"."+l+"."+r))):{TAG:"Ok",_0:de.join(n,i+"."+r)}}function al(e){if(Vr.existsSync(e))return P(U(tt(e),r=>A(r.message)),r=>{let n;try{n=JSON.parse(r)}catch{n=void 0}return typeof n=="object"&&n!==null&&!Array.isArray(n)?Wn(n).TAG==="Ok"?{TAG:"Ok",_0:n}:{TAG:"Error",_0:A("invalid Linzumi config: "+e)}:{TAG:"Error",_0:A("invalid Linzumi config: "+e)}});let t={};return t.version=1,t.allowedCwds=[],{TAG:"Ok",_0:t}}function La(){let e={};return e.allowedCwds=[],e}function ol(e,t){return P(al(e),r=>{let n=t!==void 0?mr(t):{TAG:"Ok",_0:Re};return P(n,i=>{let o=i===Re?r:$(r[i],La()),l=i===Re?Wn(o):nl(o);return U(l,a=>A("invalid Linzumi config section "+i+": "+e))})})}function za(e,t){let r=i=>A(i.message),n=Vr.existsSync(e)?U(mn(e,384),r):{TAG:"Ok",_0:void 0};return P(P(n,()=>U(Kt(e,JSON.stringify(t,void 0,2)+`
113
+ `,{encoding:"utf8",mode:384}),r)),()=>U(mn(e,384),r))}function qa(e){let t={},r=e.machineId;r!==void 0&&(t.machineId=r);let n=e.runnerId;return n!==void 0&&(t.runnerId=n),t.allowedCwds=Jn(e.allowedCwds).map(i=>i),t}function Ja(e){let t=e.version===1,r=e.machineId,n=r!==void 0?qn(r):!0,i=e.runnerId,o=i!==void 0?Br(i):!0,l=e.allowedCwds.every(a=>a.trim()!=="");return t&&n&&o&&l?{TAG:"Ok",_0:void 0}:{TAG:"Error",_0:A("invalid Linzumi config")}}function Wa(e,t,r){return P(Ja(e),()=>{let n=r!==void 0?mr(r):{TAG:"Ok",_0:Re};return P(n,i=>P(al(t),o=>{let l=Object.fromEntries(Object.entries(o)),a=qa(e);return i===Re?(Object.entries(a).forEach(s=>{l[s[0]]=s[1]}),l.version=1):(l.version=1,l[i]=a),P(U(Xt(de.dirname(t)),s=>A(s.message)),()=>za(t,l))}))})}function ll(e,t,r){return P(U(tt(e),n=>A(n.message)),n=>{let i=n.trim();return t(i)?{TAG:"Ok",_0:i}:{TAG:"Error",_0:A("invalid Linzumi "+r+" seed: "+e)}})}function Ba(e,t,r,n){if(Vr.existsSync(e))return ll(e,r,n);let i=t();if(!r(i))return{TAG:"Error",_0:A("invalid generated Linzumi "+n+": "+i)};let o=de.dirname(e),l=de.basename(e),a=de.join(o,"."+l+"."+process.pid.toString()+"."+Vn.randomUUID()+".tmp"),s=f=>A(f.message);return P(P(U(Xt(o),s),()=>U(Kt(a,i+`
114
+ `,{encoding:"utf8",flag:"wx"}),s)),()=>{let f=Li(a,e),u;if(f.TAG==="Ok")u={TAG:"Ok",_0:i};else{let m=f._0;u=Ui(m,"EEXIST")?ll(e,r,n):{TAG:"Error",_0:A(m.message)}}return zi(a),u})}function Va(){return"runner-"+Vn.randomUUID()}function Ha(e,t,r,n,i,o,l,a){let s=t!==void 0?Z(mr(t),f=>{if(f!==Re)return t}):{TAG:"Ok",_0:void 0};return P(s,f=>P(ol(e,f),u=>{let m=l(u);return m!==void 0?{TAG:"Ok",_0:m}:P(Ua(e,f,r),c=>P(Ba(c,n,i,o),d=>P(ol(e,f),p=>{let h=l(p);return h!==void 0?{TAG:"Ok",_0:h}:Z(Wa(a(p,d),e,f),()=>d)})))}))}function sl(e,t,r){return Ha(e,t,"runner-id",r!==void 0?r:Va,Br,"runner id",i=>i.runnerId,(i,o)=>({version:i.version,machineId:i.machineId,runnerId:o,allowedCwds:i.allowedCwds}))}function Xa(e){if(typeof e=="object"&&e!==null&&!Array.isArray(e))return e}async function dl(e,t,r,n,i){let o=i!==void 0?i:[],l=U(ce(e),A);if(l.TAG!=="Ok")return{TAG:"Error",_0:l._0};let a=qe("/api/v2/local-codex-runner/oauth/validate",l._0);if(a.TAG!=="Ok")return{TAG:"Error",_0:A(a._0)};let s=a._0,f=s.searchParams;r!==void 0&&f.set("workspace",r),n!==void 0&&f.set("channel",n),o.forEach(p=>{f.append("required_scope",p)});let u={};u.authorization="Bearer "+t;let m=await xt(s.toString(),{method:"GET",headers:u});if(m.TAG!=="Ok")return{TAG:"Error",_0:A(m._0.message)};let c=m._0,d=c.status;if(d>404||d<401){if(d===200){let p=await Ot(c);return p.TAG!=="Ok"?{TAG:"Error",_0:A(p._0.message)}:q(Xa(p._0),_=>_.ok)===!0?{TAG:"Ok",_0:"Usable"}:{TAG:"Ok",_0:"Rejected"}}}else{if(d<402)return{TAG:"Ok",_0:"Rejected"};switch(d){case 402:break;case 403:return{TAG:"Ok",_0:"Rejected"};case 404:return{TAG:"Ok",_0:"NotFound"}}}return{TAG:"Error",_0:A("local runner auth validation failed with HTTP "+d.toString())}}var Ya=3600*1e3;function Qa(e,t,r,n){return e<=3?"DecidePrompt":r!==void 0&&t-r<Ya?n?"DecideRefreshLine":"DecideSilent":"DecideSummary"}function fl(e){let t=Math.floor(e/6e4),r=Math.floor(t/60),n=t-r*60;return r>0?r.toString()+"h "+n.toString()+"m":n.toString()+"m"}function es(e){switch(e.TAG){case"Prompt":return(e.cycle===1?"":`The previous code expired; here is a fresh one (no restart needed - this prompt stays alive).
115
115
  `)+`Authorize this computer:
116
116
  Code: `+e.userCode+`
117
117
  Open: `+e.verificationUri+`
118
- `;case"Summary":return"Still waiting for authorization after "+sl(e.waitedMs)+" "+("("+e.cycle.toString()+` codes issued so far).
118
+ `;case"Summary":return"Still waiting for authorization after "+fl(e.waitedMs)+" "+("("+e.cycle.toString()+` codes issued so far).
119
119
  `)+(`Authorize this computer:
120
120
  Code: `+e.userCode+`
121
121
  Open: `+e.verificationUri+`
122
- `);case"RefreshLine":return"\r\x1B[2KCode: "+e.userCode+" (waiting "+sl(e.waitedMs)+") - open "+e.verificationUri;case"TransientFailure":return"Device authorization poll hit a transient failure ("+e._0+`); retrying with the same code.
122
+ `);case"RefreshLine":return"\r\x1B[2KCode: "+e.userCode+" (waiting "+fl(e.waitedMs)+") - open "+e.verificationUri;case"TransientFailure":return"Device authorization poll hit a transient failure ("+e._0+`); retrying with the same code.
123
123
  `;case"StartFailed":return"Could not mint a device authorization code ("+e.reason+"); retrying in "+Math.round(e.retryInMs/1e3).toString()+`s.
124
- `}}function Qa(e){return new Promise((t,r)=>{setTimeout(()=>t(),e|0)})}function es(e){return{startDeviceAuthorization:t=>zo(t.httpBaseUrl,t.workspaceSlug,t.channelSlug,t.onboarding,t.identity),pollDeviceCodeForToken:t=>qo(t.httpBaseUrl,t.deviceCode,t.expiresInSeconds),now:()=>Date.now(),sleep:Qa,report:e,log:(t,r)=>{}}}var ts="local runner device authorization was denied - a signed-in user rejected this computer";async function dl(e,t,r,n,i,o,l,a){let s=o!==void 0?o:y=>{tt(y)},f=a!==void 0?a:es(y=>s(Ya(y))),u=l!==void 0?l:Nt(Ze(process.stderr.isTTY),!0),m=U(ce(e),A);if(m.TAG!=="Ok")return{TAG:"Error",_0:m._0};let c=m._0,d=f.now(),p={cycle:0,lastLoudPromptAtMs:void 0,startFailures:0},h=async y=>{let g=await f.pollDeviceCodeForToken({httpBaseUrl:c,deviceCode:y.deviceCode,expiresInSeconds:y.expiresInSeconds});if(typeof g!="object"||g.TAG!=="Transient")return g;let S=g.httpStatus,T=g.reason;f.report({TAG:"TransientFailure",_0:T});let C={};return C.cycle=p.cycle,C.reason=T,C.httpStatus=S!==void 0?S:null,f.log("device_wait.transient_poll_failure",C),await f.sleep(5e3),await h(y)},_=async()=>{let y=await f.startDeviceAuthorization({httpBaseUrl:c,workspaceSlug:t,channelSlug:r,onboarding:n,identity:i});if(y.TAG==="Ok"){let g=y._0;p.startFailures=0,p.cycle=p.cycle+1|0;let S=Za(p.cycle,f.now(),p.lastLoudPromptAtMs,u),T=0;switch(S){case"DecidePrompt":case"DecideSummary":T=1;break;case"DecideRefreshLine":f.report({TAG:"RefreshLine",userCode:g.userCode,verificationUri:g.verificationUri,waitedMs:f.now()-d});break;case"DecideSilent":break}if(T===1){p.lastLoudPromptAtMs=f.now();let H=f.now()-d,K;K=S==="DecidePrompt"?{TAG:"Prompt",cycle:p.cycle,userCode:g.userCode,verificationUri:g.verificationUri}:{TAG:"Summary",cycle:p.cycle,userCode:g.userCode,verificationUri:g.verificationUri,waitedMs:H},f.report(K)}let C={};C.cycle=p.cycle,C.verificationUri=g.verificationUri,f.log("device_wait.code_issued",C);let N=await h(g);if(typeof N!="object")switch(N){case"CodeExpired":let H={};return H.cycle=p.cycle,H.outcome="code_expired",f.log("device_wait.code_retired",H),await _();case"Denied":return{TAG:"Error",_0:A(ts)};case"Consumed":let K={};return K.cycle=p.cycle,K.outcome="consumed",f.log("device_wait.code_retired",K),await _()}else switch(N.TAG){case"Token":let H={};return H.cycle=p.cycle,H.waitedMs=f.now()-d,f.log("device_wait.authorized",H),{TAG:"Ok",_0:N._0};case"Rejected":let K=N.httpStatus,x=N.reason;f.report({TAG:"TransientFailure",_0:Lo(x,K)});let b={};return b.cycle=p.cycle,b.reason=x!==void 0?x:null,b.httpStatus=K,f.log("device_wait.code_rejected",b),await _();case"Transient":return await _()}}else{let g=y._0;p.startFailures=p.startFailures+1|0;let S=Math.min(6e4,5e3*Math.pow(2,p.startFailures-1|0));f.report({TAG:"StartFailed",reason:g.summary,retryInMs:S});let T={};return T.reason=g.summary,T.retryInMs=S,T.attempt=p.startFailures,f.log("device_wait.start_failed",T),await f.sleep(S),await _()}};return await _()}var ns="linzumi-machine-fingerprint:v1:";var fl={platform:void 0,execFile:void 0,readFile:void 0,username:void 0};function is(e,t){return Bi(e,t,5e3,1024*1024)}var os=new RegExp('"IOPlatformUUID"\\s*=\\s*"([0-9A-Fa-f-]{36})"'),ls=new RegExp("^[0-9a-f]{32}$"),us=["/etc/machine-id","/var/lib/dbus/machine-id"];function as(e){let t=e!==void 0?e:fl,r=$(t.platform,process.platform),n=$(t.execFile,is),i=$(t.readFile,et);switch(r){case"darwin":let o=n("ioreg",["-rd1","-c","IOPlatformExpertDevice"]);if(o.TAG!=="Ok")return;let l=os.exec(o._0);if(l==null)return;let a=l.slice(1)[0];if(a===void 0)return;let s=D(a);return s!==void 0?s.toLowerCase():void 0;case"linux":return Hr(us,void 0,(f,u)=>{if(f!==void 0)return f;let m=i(u);if(m.TAG!=="Ok")return;let c=m._0.trim().toLowerCase();if(ls.test(c))return c});default:return}}function cl(){return ve(as(fl),e=>"mfp-"+Ji(ns+e).slice(0,32))}function ds(e,t){return P(U(ce(e),A),r=>{let n=$t(r);return n===void 0?{TAG:"Error",_0:A("invalid URL: "+r)}:{TAG:"Ok",_0:"Workspace '"+(t!==void 0?t:"undefined")+"' was not found on "+D(n).host+". Sign in to the web app to create it, then re-run connect."}})}function hl(e){let t=e.authFilePath;return t!==void 0?t:Po()}function _l(e,t){let r=hl(e);return X(Do(e.serviceUrl,t.accessToken,t.expiresInSeconds,r,new Date),n=>({accessToken:n.accessToken,expiresAt:n.expiresAt,authFilePath:r}))}function ml(e,t){if(t===void 0)return jn(e);let r=new Date(t).getTime();if(isFinite(r))return{TAG:"Ok",_0:t};let n=jn(e);if(n.TAG!=="Ok")return{TAG:"Error",_0:n._0};let i=n._0;return i!==void 0?{TAG:"Ok",_0:i}:{TAG:"Error",_0:A("invalid managed token expiry metadata and access token has no usable expiry")}}async function fs(e){let t=ol(process.env),r=ul(t,e.serviceUrl,void 0);if(r.TAG!=="Ok")return{TAG:"Error",_0:r._0};let n=r._0,i=cl(),o=pl.hostname(),l={commanderId:n,machineFingerprint:i,hostname:o},a=await dl(e.serviceUrl,e.workspaceSlug,e.channelSlug,e.onboarding,l,void 0,void 0,void 0);return a.TAG==="Ok"?_l(e,a._0):{TAG:"Error",_0:a._0}}async function cs(e){let t=e.authMode;if(typeof t!="object")return await fs(e);let r=ve(t.callbackHost,Uo),n=await Xo(e.serviceUrl,e.workspaceSlug,e.channelSlug,e.onboarding,void 0,r,process.env,i=>{tt(i)},i=>Ko((o,l)=>{if(o!=="process.spawn_failed"||typeof l!="object"||l===null||Array.isArray(l))return;let a=q(l.command,Rn),s=q(l.message,Rn);if(a!==void 0&&s!==void 0){tt("linzumi (rescript commander): could not open the authorization URL with "+a+" ("+s+`); open the URL above manually
125
- `);return}},process.platform,i),void 0);return n.TAG==="Ok"?_l(e,n._0):{TAG:"Error",_0:n._0}}function ms(){return{readCachedToken:(e,t)=>Mo(e,t,Date.now()),validateToken:(e,t,r,n,i)=>al(e,t,r,n,i),acquireAndCacheAuth:cs}}async function ps(e,t,r){let n=await t.validateToken(e.serviceUrl,r,e.workspaceSlug,e.channelSlug,e.requiredScopes);if(n.TAG!=="Ok")return{TAG:"Ok",_0:void 0};switch(n._0){case"Usable":case"Rejected":return{TAG:"Ok",_0:void 0};case"NotFound":return P(ds(e.serviceUrl,e.workspaceSlug),i=>({TAG:"Error",_0:A(i)}))}}async function hs(e,t){let r=t!==void 0?t:ms(),n=ve(e.explicitToken,_=>_.trim()),i=n!==void 0&&n!==""?n:void 0;if(i!==void 0)return{TAG:"Ok",_0:{TAG:"ExplicitAuth",accessToken:i}};let o=hl(e),l=r.readCachedToken(e.serviceUrl,o);if(l.TAG!=="Ok")return{TAG:"Error",_0:l._0};let a=l._0,s;if(a!==void 0){let _=await r.validateToken(e.serviceUrl,a.accessToken,e.workspaceSlug,e.channelSlug,e.requiredScopes);if(_.TAG==="Ok")switch(_._0){case"Usable":s={TAG:"Ok",_0:a};break;case"Rejected":let y=e.reportRejectedCachedToken;y!==void 0&&y("UnusableRejected"),s={TAG:"Ok",_0:void 0};break;case"NotFound":let g=e.reportRejectedCachedToken;g!==void 0&&g("UnusableNotFound"),s={TAG:"Ok",_0:void 0};break}else s={TAG:"Error",_0:_._0}}else s={TAG:"Ok",_0:void 0};if(s.TAG!=="Ok")return{TAG:"Error",_0:s._0};let f=s._0;if(f!==void 0)return X(ml(f.accessToken,f.expiresAt),_=>({TAG:"CachedAuth",_0:{accessToken:f.accessToken,expiresAt:_,authFilePath:o}}));let u=await r.acquireAndCacheAuth(e);if(u.TAG!=="Ok")return{TAG:"Error",_0:u._0};let m=u._0,c=ml(m.accessToken,m.expiresAt);if(c.TAG!=="Ok")return{TAG:"Error",_0:c._0};let d=c._0;if(e.workspaceSlug===void 0)return{TAG:"Ok",_0:{TAG:"AcquiredAuth",accessToken:m.accessToken,expiresAt:d,authFilePath:m.authFilePath,mode:e.authMode}};let h=await ps(e,r,m.accessToken);return h.TAG==="Ok"?{TAG:"Ok",_0:{TAG:"AcquiredAuth",accessToken:m.accessToken,expiresAt:d,authFilePath:m.authFilePath,mode:e.authMode}}:{TAG:"Error",_0:h._0}}function _s(e){switch(e.TAG){case"CachedAuth":return e._0.accessToken;case"ExplicitAuth":case"AcquiredAuth":return e.accessToken}}async function yl(e,t){return X(await hs(e,t),_s)}function Ss(e){let t=Ce(e);return t!==void 0?$(Ae(D(t)),"unknown error"):"unknown error"}function gl(e){let t;try{t={TAG:"Ok",_0:new URL(e)}}catch(o){let l=j(o);t={TAG:"Error",_0:Ss(l)}}if(t.TAG!=="Ok")return{TAG:"Error",_0:t._0};let r=t._0,n=r.protocol,i;switch(n){case"https:":case"wss:":i="https:";break;default:i="http:"}return r.protocol=i,r.pathname="/api/v2/graphql",r.search="",r.hash="",{TAG:"Ok",_0:r.toString()}}function As(e){return vl.createHash("sha256").update(e,"utf8").digest().subarray(0,8).toString("base64url")}function Xn(e,t){return{operationName:e,documentId:As(t),text:t}}var wl=Xn("TopicsCliTopicLookup",`query TopicsCliTopicLookup($workspaceSlug: String!, $slug: String!) {
124
+ `}}function ts(e){return new Promise((t,r)=>{setTimeout(()=>t(),e|0)})}function rs(e){return{startDeviceAuthorization:t=>Jo(t.httpBaseUrl,t.workspaceSlug,t.channelSlug,t.onboarding,t.identity),pollDeviceCodeForToken:t=>Wo(t.httpBaseUrl,t.deviceCode,t.expiresInSeconds),now:()=>Date.now(),sleep:ts,report:e,log:(t,r)=>{}}}var ns="local runner device authorization was denied - a signed-in user rejected this computer";async function cl(e,t,r,n,i,o,l,a){let s=o!==void 0?o:y=>{rt(y)},f=a!==void 0?a:rs(y=>s(es(y))),u=l!==void 0?l:$t(Ye(process.stderr.isTTY),!0),m=U(ce(e),A);if(m.TAG!=="Ok")return{TAG:"Error",_0:m._0};let c=m._0,d=f.now(),p={cycle:0,lastLoudPromptAtMs:void 0,startFailures:0},h=async y=>{let g=await f.pollDeviceCodeForToken({httpBaseUrl:c,deviceCode:y.deviceCode,expiresInSeconds:y.expiresInSeconds});if(typeof g!="object"||g.TAG!=="Transient")return g;let S=g.httpStatus,T=g.reason;f.report({TAG:"TransientFailure",_0:T});let C={};return C.cycle=p.cycle,C.reason=T,C.httpStatus=S!==void 0?S:null,f.log("device_wait.transient_poll_failure",C),await f.sleep(5e3),await h(y)},_=async()=>{let y=await f.startDeviceAuthorization({httpBaseUrl:c,workspaceSlug:t,channelSlug:r,onboarding:n,identity:i});if(y.TAG==="Ok"){let g=y._0;p.startFailures=0,p.cycle=p.cycle+1|0;let S=Qa(p.cycle,f.now(),p.lastLoudPromptAtMs,u),T=0;switch(S){case"DecidePrompt":case"DecideSummary":T=1;break;case"DecideRefreshLine":f.report({TAG:"RefreshLine",userCode:g.userCode,verificationUri:g.verificationUri,waitedMs:f.now()-d});break;case"DecideSilent":break}if(T===1){p.lastLoudPromptAtMs=f.now();let H=f.now()-d,X;X=S==="DecidePrompt"?{TAG:"Prompt",cycle:p.cycle,userCode:g.userCode,verificationUri:g.verificationUri}:{TAG:"Summary",cycle:p.cycle,userCode:g.userCode,verificationUri:g.verificationUri,waitedMs:H},f.report(X)}let C={};C.cycle=p.cycle,C.verificationUri=g.verificationUri,f.log("device_wait.code_issued",C);let N=await h(g);if(typeof N!="object")switch(N){case"CodeExpired":let H={};return H.cycle=p.cycle,H.outcome="code_expired",f.log("device_wait.code_retired",H),await _();case"Denied":return{TAG:"Error",_0:A(ns)};case"Consumed":let X={};return X.cycle=p.cycle,X.outcome="consumed",f.log("device_wait.code_retired",X),await _()}else switch(N.TAG){case"Token":let H={};return H.cycle=p.cycle,H.waitedMs=f.now()-d,f.log("device_wait.authorized",H),{TAG:"Ok",_0:N._0};case"Rejected":let X=N.httpStatus,w=N.reason;f.report({TAG:"TransientFailure",_0:qo(w,X)});let b={};return b.cycle=p.cycle,b.reason=w!==void 0?w:null,b.httpStatus=X,f.log("device_wait.code_rejected",b),await _();case"Transient":return await _()}}else{let g=y._0;p.startFailures=p.startFailures+1|0;let S=Math.min(6e4,5e3*Math.pow(2,p.startFailures-1|0));f.report({TAG:"StartFailed",reason:g.summary,retryInMs:S});let T={};return T.reason=g.summary,T.retryInMs=S,T.attempt=p.startFailures,f.log("device_wait.start_failed",T),await f.sleep(S),await _()}};return await _()}var os="linzumi-machine-fingerprint:v1:";var ml={platform:void 0,execFile:void 0,readFile:void 0,username:void 0};function ls(e,t){return Vi(e,t,5e3,1024*1024)}var us=new RegExp('"IOPlatformUUID"\\s*=\\s*"([0-9A-Fa-f-]{36})"'),as=new RegExp("^[0-9a-f]{32}$"),ss=["/etc/machine-id","/var/lib/dbus/machine-id"];function ds(e){let t=e!==void 0?e:ml,r=$(t.platform,process.platform),n=$(t.execFile,ls),i=$(t.readFile,tt);switch(r){case"darwin":let o=n("ioreg",["-rd1","-c","IOPlatformExpertDevice"]);if(o.TAG!=="Ok")return;let l=us.exec(o._0);if(l==null)return;let a=l.slice(1)[0];if(a===void 0)return;let s=D(a);return s!==void 0?s.toLowerCase():void 0;case"linux":return Kr(ss,void 0,(f,u)=>{if(f!==void 0)return f;let m=i(u);if(m.TAG!=="Ok")return;let c=m._0.trim().toLowerCase();if(as.test(c))return c});default:return}}function pl(){return ve(ds(ml),e=>"mfp-"+Wi(os+e).slice(0,32))}function cs(e,t){return P(U(ce(e),A),r=>{let n=It(r);return n===void 0?{TAG:"Error",_0:A("invalid URL: "+r)}:{TAG:"Ok",_0:"Workspace '"+(t!==void 0?t:"undefined")+"' was not found on "+D(n).host+". Sign in to the web app to create it, then re-run connect."}})}function yl(e){let t=e.authFilePath;return t!==void 0?t:Mo()}function gl(e,t){let r=yl(e);return Z(Uo(e.serviceUrl,t.accessToken,t.expiresInSeconds,r,new Date),n=>({accessToken:n.accessToken,expiresAt:n.expiresAt,authFilePath:r}))}function hl(e,t){if(t===void 0)return Un(e);let r=new Date(t).getTime();if(isFinite(r))return{TAG:"Ok",_0:t};let n=Un(e);if(n.TAG!=="Ok")return{TAG:"Error",_0:n._0};let i=n._0;return i!==void 0?{TAG:"Ok",_0:i}:{TAG:"Error",_0:A("invalid managed token expiry metadata and access token has no usable expiry")}}async function ms(e){let t=ul(process.env),r=sl(t,e.serviceUrl,void 0);if(r.TAG!=="Ok")return{TAG:"Error",_0:r._0};let n=r._0,i=pl(),o=_l.hostname(),l={commanderId:n,machineFingerprint:i,hostname:o},a=await cl(e.serviceUrl,e.workspaceSlug,e.channelSlug,e.onboarding,l,void 0,void 0,void 0);return a.TAG==="Ok"?gl(e,a._0):{TAG:"Error",_0:a._0}}async function ps(e){let t=e.authMode;if(typeof t!="object")return await ms(e);let r=ve(t.callbackHost,zo),n=await Yo(e.serviceUrl,e.workspaceSlug,e.channelSlug,e.onboarding,void 0,r,process.env,i=>{rt(i)},i=>Zo((o,l)=>{if(o!=="process.spawn_failed"||typeof l!="object"||l===null||Array.isArray(l))return;let a=q(l.command,Mn),s=q(l.message,Mn);if(a!==void 0&&s!==void 0){rt("linzumi (rescript commander): could not open the authorization URL with "+a+" ("+s+`); open the URL above manually
125
+ `);return}},process.platform,i),void 0);return n.TAG==="Ok"?gl(e,n._0):{TAG:"Error",_0:n._0}}function hs(){return{readCachedToken:(e,t)=>jo(e,t,Date.now()),validateToken:(e,t,r,n,i)=>dl(e,t,r,n,i),acquireAndCacheAuth:ps}}async function _s(e,t,r){let n=await t.validateToken(e.serviceUrl,r,e.workspaceSlug,e.channelSlug,e.requiredScopes);if(n.TAG!=="Ok")return{TAG:"Ok",_0:void 0};switch(n._0){case"Usable":case"Rejected":return{TAG:"Ok",_0:void 0};case"NotFound":return P(cs(e.serviceUrl,e.workspaceSlug),i=>({TAG:"Error",_0:A(i)}))}}async function ys(e,t){let r=t!==void 0?t:hs(),n=ve(e.explicitToken,_=>_.trim()),i=n!==void 0&&n!==""?n:void 0;if(i!==void 0)return{TAG:"Ok",_0:{TAG:"ExplicitAuth",accessToken:i}};let o=yl(e),l=r.readCachedToken(e.serviceUrl,o);if(l.TAG!=="Ok")return{TAG:"Error",_0:l._0};let a=l._0,s;if(a!==void 0){let _=await r.validateToken(e.serviceUrl,a.accessToken,e.workspaceSlug,e.channelSlug,e.requiredScopes);if(_.TAG==="Ok")switch(_._0){case"Usable":s={TAG:"Ok",_0:a};break;case"Rejected":let y=e.reportRejectedCachedToken;y!==void 0&&y("UnusableRejected"),s={TAG:"Ok",_0:void 0};break;case"NotFound":let g=e.reportRejectedCachedToken;g!==void 0&&g("UnusableNotFound"),s={TAG:"Ok",_0:void 0};break}else s={TAG:"Error",_0:_._0}}else s={TAG:"Ok",_0:void 0};if(s.TAG!=="Ok")return{TAG:"Error",_0:s._0};let f=s._0;if(f!==void 0)return Z(hl(f.accessToken,f.expiresAt),_=>({TAG:"CachedAuth",_0:{accessToken:f.accessToken,expiresAt:_,authFilePath:o}}));let u=await r.acquireAndCacheAuth(e);if(u.TAG!=="Ok")return{TAG:"Error",_0:u._0};let m=u._0,c=hl(m.accessToken,m.expiresAt);if(c.TAG!=="Ok")return{TAG:"Error",_0:c._0};let d=c._0;if(e.workspaceSlug===void 0)return{TAG:"Ok",_0:{TAG:"AcquiredAuth",accessToken:m.accessToken,expiresAt:d,authFilePath:m.authFilePath,mode:e.authMode}};let h=await _s(e,r,m.accessToken);return h.TAG==="Ok"?{TAG:"Ok",_0:{TAG:"AcquiredAuth",accessToken:m.accessToken,expiresAt:d,authFilePath:m.authFilePath,mode:e.authMode}}:{TAG:"Error",_0:h._0}}function gs(e){switch(e.TAG){case"CachedAuth":return e._0.accessToken;case"ExplicitAuth":case"AcquiredAuth":return e.accessToken}}async function Sl(e,t){return Z(await ys(e,t),gs)}function As(e){let t=Ce(e);return t!==void 0?$(Ae(D(t)),"unknown error"):"unknown error"}function Tl(e){let t;try{t={TAG:"Ok",_0:new URL(e)}}catch(o){let l=j(o);t={TAG:"Error",_0:As(l)}}if(t.TAG!=="Ok")return{TAG:"Error",_0:t._0};let r=t._0,n=r.protocol,i;switch(n){case"https:":case"wss:":i="https:";break;default:i="http:"}return r.protocol=i,r.pathname="/api/v2/graphql",r.search="",r.hash="",{TAG:"Ok",_0:r.toString()}}function xs(e){return Ol.createHash("sha256").update(e,"utf8").digest().subarray(0,8).toString("base64url")}function Zn(e,t){return{operationName:e,documentId:xs(t),text:t}}var wl=Zn("TopicsCliTopicLookup",`query TopicsCliTopicLookup($workspaceSlug: String!, $slug: String!) {
126
126
  topic(workspaceSlug: $workspaceSlug, slug: $slug) {
127
127
  id
128
128
  slug
129
129
  title
130
130
  status
131
131
  }
132
- }`),Ol=Xn("TopicsCliCreateTopic",`mutation TopicsCliCreateTopic($input: CreateTopicInput!) {
132
+ }`),El=Zn("TopicsCliCreateTopic",`mutation TopicsCliCreateTopic($input: CreateTopicInput!) {
133
133
  createTopic(input: $input) {
134
134
  ok
135
135
  error
@@ -138,7 +138,7 @@ Open: `+e.verificationUri+`
138
138
  slug
139
139
  }
140
140
  }
141
- }`),xl=Xn("TopicsCliPostEntry",`mutation TopicsCliPostEntry($input: PostTopicEntryInput!) {
141
+ }`),kl=Zn("TopicsCliPostEntry",`mutation TopicsCliPostEntry($input: PostTopicEntryInput!) {
142
142
  postTopicEntry(input: $input) {
143
143
  ok
144
144
  error
@@ -146,7 +146,7 @@ Open: `+e.verificationUri+`
146
146
  entrySeq
147
147
  }
148
148
  }
149
- }`),Ff=[wl,Ol,xl],Kn=["plan","reasoning","command_execution","terminal_input","file_change","tool_call","approval_request","web_search","status","artifact","assistant_output"];function Vn(){return`Usage: linzumi topics post [options]
149
+ }`),$f=[wl,El,kl],Xn=["plan","reasoning","command_execution","terminal_input","file_change","tool_call","approval_request","web_search","status","artifact","assistant_output"];function Hn(){return`Usage: linzumi topics post [options]
150
150
 
151
151
  Post one entry into a long-lived topic (spec/topics-rules.md). The topic
152
152
  auto-creates on first post, so producers never lose an entry to a missing
@@ -158,7 +158,7 @@ Required:
158
158
 
159
159
  Options:
160
160
  --kind <kind> Entry kind (default: status). One of:
161
- `+Kn.join(", ")+`.
161
+ `+Xn.join(", ")+`.
162
162
  --preview <text> Short preview line for collapsed rendering.
163
163
  --body <text> Full entry body text.
164
164
  --payload-json <json> JSON object payload (e.g. '{"severity":"error"}').
@@ -170,13 +170,13 @@ Options:
170
170
  --linzumi-url <url> Server URL (defaults to the production server).
171
171
  --token <token> Explicit access token (defaults to cached login).
172
172
  -h, --help Show this help.
173
- `}var vs=["workspace","topic","kind","preview","body","payload-json","dedupe-key","title","linzumi-url","api-url","token"],ws=["json","help","no-create"];function El(e){let t=[],r={},n,i=0;for(;ri(n)&&i<e.length;){let l=e[i];if(l==="-h"||l==="--help")r.help="FlagOn";else if(l.startsWith("--")){let a=Xr(l,"="),s=a!==void 0?l.slice(2,a):l.slice(2,l.length);if(ws.includes(s))a!==void 0?n="--"+s+" does not take a value":r[s]="FlagOn";else if(vs.includes(s))if(a!==void 0)r[s]={TAG:"FlagString",_0:l.slice(a+1|0,l.length)};else{let f=e[i+1|0],u=0;f!==void 0&&!f.startsWith("--")?(r[s]={TAG:"FlagString",_0:f},i=i+1|0):u=1,u===1&&(n="--"+s+" requires a value")}else n="unknown flag --"+s+" (see: linzumi topics --help)"}else t.push(l);i=i+1|0}let o=n;return o!==void 0?{TAG:"Error",_0:o}:{TAG:"Ok",_0:{subcommand:t[0],flags:r}}}function ye(e,t){let r=e[t];if(typeof r=="object")return r._0}function Hn(e,t){let r=e[t];return r!==void 0?typeof r!="object":!1}function Os(e){let t;try{t=JSON.parse(e)}catch{return{TAG:"Error",_0:"--payload-json must be valid JSON"}}return typeof t=="object"&&t!==null&&!Array.isArray(t)?{TAG:"Ok",_0:void 0}:{TAG:"Error",_0:"--payload-json must be a JSON object"}}function ae(e,t){if(typeof e=="object"&&e!==null&&!Array.isArray(e))return e[t]}function Jt(e){if(typeof e=="string")return e}function Sl(e){if(typeof e=="boolean")return e}function xs(e){if(typeof e=="number")return e}function Es(e,t,r,n){let i=ae(n,"errors"),o=i!==void 0?Array.isArray(i)?i:[]:[];if(o.length!==0){let a=De(o,s=>q(ae(s,"extensions"),f=>Jt(ae(f,"code"))));return a.includes("PERSISTED_DOCUMENT_NOT_FOUND")?"DocumentNotFound":{TAG:"GraphqlErrors",_0:{messages:o.map(s=>$(Jt(ae(s,"message")),"unknown error")),codes:a}}}if(!e)return{TAG:"HttpFailure",_0:"HTTP "+t.toString()+" "+r};let l=ae(n,"data");return l!==void 0?{TAG:"Data",_0:l}:{TAG:"HttpFailure",_0:"empty response body"}}function Tl(e){if(typeof e!="object")return"topics request failed";switch(e.TAG){case"Data":return"topics request failed";case"GraphqlErrors":let t=e._0;if(t.codes.includes("FREE_FORM_GRAPHQL_FORBIDDEN"))return"this Linzumi server does not know this CLI version's topics documents yet (its persisted-document manifest predates them); nothing was changed - retry after the next server deploy";let r=t.messages;return r.some(i=>{let o=i.toLowerCase();return o.includes("cannot query field")||o.includes("unknown argument")||o.includes("unknown type")||o.includes("unknown field")?!0:o.includes("has invalid value $input")})?"this Linzumi server does not support topics yet (the topics server rollout has not reached it); nothing was changed":"topics request returned errors: "+r.join("; ");case"HttpFailure":return"topics request failed: "+e._0}}function ks(e,t,r){let n=async i=>{let o=Object.fromEntries([["content-type","application/json"],["authorization","Bearer "+t]]),l=await r(e,{method:"POST",headers:o,body:JSON.stringify(i)}),a;try{a=await l.json()}catch{a=null}return Es(l.ok,l.status,l.statusText,a)};return async(i,o)=>{let l=await n(Object.fromEntries([["documentId",i.documentId],["operationName",i.operationName],["variables",o]]));if(typeof l!="object"){let a=await n(Object.fromEntries([["query",i.text],["operationName",i.operationName],["variables",o]]));return typeof a!="object"||a.TAG!=="Data"?{TAG:"Error",_0:Tl(a)}:{TAG:"Ok",_0:a._0}}switch(l.TAG){case"Data":return{TAG:"Ok",_0:l._0};case"GraphqlErrors":case"HttpFailure":return{TAG:"Error",_0:Tl(l)}}}}function bs(e){return Object.fromEntries([["workspaceSlug",e.workspaceSlug],["slug",e.topicSlug]])}async function Al(e,t){let r=await e(wl,bs(t));return r.TAG==="Ok"?{TAG:"Ok",_0:Jt(q(ae(r._0,"topic"),n=>ae(n,"id")))}:{TAG:"Error",_0:r._0}}async function Gs(e,t){if(!Kn.includes(t.kind))return{TAG:"Error",_0:'unknown entry kind "'+t.kind+'" (one of: '+Kn.join(", ")+")"};let r=t.payloadJson,n=r!==void 0?Os(r):{TAG:"Ok",_0:void 0};if(n.TAG!=="Ok")return{TAG:"Error",_0:n._0};let i=await Al(e,t);if(i.TAG!=="Ok")return{TAG:"Error",_0:i._0};let o=i._0,l;if(o!==void 0)l={TAG:"Ok",_0:[o,!1]};else if(t.createMissing){let g=Object.fromEntries([["workspaceSlug",t.workspaceSlug],["slug",t.topicSlug]]),S=t.title;S!==void 0&&(g.title=S);let T=await e(Ol,Object.fromEntries([["input",g]]));if(T.TAG==="Ok"){let C=ae(T._0,"createTopic"),N=$(Sl(q(C,b=>ae(b,"ok"))),!1),H=Jt(q(q(C,b=>ae(b,"topic")),b=>ae(b,"id"))),K=Jt(q(C,b=>ae(b,"error"))),x=0;if(N&&H!==void 0?l={TAG:"Ok",_0:[H,!0]}:x=1,x===1){let b;if(K!==void 0){let F=K.toLowerCase();b=F.includes("taken")||F.includes("slug")}else b=!1;if(b){let F=await Al(e,t),J=0;if(F.TAG==="Ok"){let L=F._0;L!==void 0?l={TAG:"Ok",_0:[L,!1]}:J=2}else J=2;J===2&&(l={TAG:"Error",_0:'could not create topic "'+t.topicSlug+'": '+$(K,"unknown error")})}else l={TAG:"Error",_0:'could not create topic "'+t.topicSlug+'": '+$(K,"unknown error")}}}else l={TAG:"Error",_0:T._0}}else l={TAG:"Error",_0:'topic "'+t.topicSlug+'" does not exist in workspace "'+t.workspaceSlug+'" (drop --no-create to auto-create it)'};if(l.TAG!=="Ok")return{TAG:"Error",_0:l._0};let a=l._0,s=Object.fromEntries([["topicId",a[0]],["kind",t.kind.toUpperCase()]]),f=t.preview;f!==void 0&&(s.previewText=f);let u=t.body;u!==void 0&&(s.body=u);let m=t.payloadJson;m!==void 0&&(s.payloadJson=m);let c=t.dedupeKey;c!==void 0&&(s.dedupeKey=c);let d=await e(xl,Object.fromEntries([["input",s]]));if(d.TAG!=="Ok")return{TAG:"Error",_0:d._0};let p=ae(d._0,"postTopicEntry"),h=$(Sl(q(p,g=>ae(g,"ok"))),!1),_=xs(q(q(p,g=>ae(g,"entry")),g=>ae(g,"entrySeq")));if(h&&_!==void 0)return{TAG:"Ok",_0:{topicSlug:t.topicSlug,entrySeq:_|0,created:a[1]}};let y=Jt(q(p,g=>ae(g,"error")));return{TAG:"Error",_0:'could not post to topic "'+t.topicSlug+'": '+$(y,"unknown error")}}async function Cs(e,t){let r=t.stdout,n=r!==void 0?r:a=>{process.stdout.write(a)},i=t.stderr,o=i!==void 0?i:a=>{process.stderr.write(a)},l=El(e);if(l.TAG==="Ok"){let a=l._0,s=a.flags,f=a.subcommand;if(Hn(s,"help"))return n(Vn()),0;if(f!==void 0){if(f==="post"){let u=ye(s,"workspace"),m=ye(s,"topic");if(u!==void 0){if(m!==void 0){let c=$(Kr(ye(s,"linzumi-url"),ye(s,"api-url")),t.defaultUrl),d,p=0,h;try{let _=ye(s,"token");h=await(_!==void 0?t.resolveToken({kandanUrl:c,explicitToken:_}):t.resolveToken({kandanUrl:c})),p=1}catch(_){let y=j(_);if(y.RE_EXN_ID==="JsExn")d={TAG:"Error",_0:$(Ae(y._1),"token resolution failed")};else throw y}if(p===1){let _=ks(t.graphqlEndpoint(c),h,$(t.fetchImpl,fetch));d=await Gs(_,{workspaceSlug:u,topicSlug:m,kind:$(ye(s,"kind"),"status"),preview:ye(s,"preview"),body:ye(s,"body"),payloadJson:ye(s,"payload-json"),dedupeKey:ye(s,"dedupe-key"),title:ye(s,"title"),createMissing:!Hn(s,"no-create")})}if(d.TAG==="Ok"){let _=d._0;if(Hn(s,"json")){let y=Object.fromEntries([["topicSlug",_.topicSlug],["entrySeq",_.entrySeq],["created",_.created]]);n(JSON.stringify(y)+`
173
+ `}var Os=["workspace","topic","kind","preview","body","payload-json","dedupe-key","title","linzumi-url","api-url","token"],ws=["json","help","no-create"];function bl(e){let t=[],r={},n,i=0;for(;ni(n)&&i<e.length;){let l=e[i];if(l==="-h"||l==="--help")r.help="FlagOn";else if(l.startsWith("--")){let a=Zr(l,"="),s=a!==void 0?l.slice(2,a):l.slice(2,l.length);if(ws.includes(s))a!==void 0?n="--"+s+" does not take a value":r[s]="FlagOn";else if(Os.includes(s))if(a!==void 0)r[s]={TAG:"FlagString",_0:l.slice(a+1|0,l.length)};else{let f=e[i+1|0],u=0;f!==void 0&&!f.startsWith("--")?(r[s]={TAG:"FlagString",_0:f},i=i+1|0):u=1,u===1&&(n="--"+s+" requires a value")}else n="unknown flag --"+s+" (see: linzumi topics --help)"}else t.push(l);i=i+1|0}let o=n;return o!==void 0?{TAG:"Error",_0:o}:{TAG:"Ok",_0:{subcommand:t[0],flags:r}}}function ye(e,t){let r=e[t];if(typeof r=="object")return r._0}function Kn(e,t){let r=e[t];return r!==void 0?typeof r!="object":!1}function Es(e){let t;try{t=JSON.parse(e)}catch{return{TAG:"Error",_0:"--payload-json must be valid JSON"}}return typeof t=="object"&&t!==null&&!Array.isArray(t)?{TAG:"Ok",_0:void 0}:{TAG:"Error",_0:"--payload-json must be a JSON object"}}function ae(e,t){if(typeof e=="object"&&e!==null&&!Array.isArray(e))return e[t]}function Wt(e){if(typeof e=="string")return e}function Al(e){if(typeof e=="boolean")return e}function ks(e){if(typeof e=="number")return e}function bs(e,t,r,n){let i=ae(n,"errors"),o=i!==void 0?Array.isArray(i)?i:[]:[];if(o.length!==0){let a=De(o,s=>q(ae(s,"extensions"),f=>Wt(ae(f,"code"))));return a.includes("PERSISTED_DOCUMENT_NOT_FOUND")?"DocumentNotFound":{TAG:"GraphqlErrors",_0:{messages:o.map(s=>$(Wt(ae(s,"message")),"unknown error")),codes:a}}}if(!e)return{TAG:"HttpFailure",_0:"HTTP "+t.toString()+" "+r};let l=ae(n,"data");return l!==void 0?{TAG:"Data",_0:l}:{TAG:"HttpFailure",_0:"empty response body"}}function vl(e){if(typeof e!="object")return"topics request failed";switch(e.TAG){case"Data":return"topics request failed";case"GraphqlErrors":let t=e._0;if(t.codes.includes("FREE_FORM_GRAPHQL_FORBIDDEN"))return"this Linzumi server does not know this CLI version's topics documents yet (its persisted-document manifest predates them); nothing was changed - retry after the next server deploy";let r=t.messages;return r.some(i=>{let o=i.toLowerCase();return o.includes("cannot query field")||o.includes("unknown argument")||o.includes("unknown type")||o.includes("unknown field")?!0:o.includes("has invalid value $input")})?"this Linzumi server does not support topics yet (the topics server rollout has not reached it); nothing was changed":"topics request returned errors: "+r.join("; ");case"HttpFailure":return"topics request failed: "+e._0}}function Gs(e,t,r){let n=async i=>{let o=Object.fromEntries([["content-type","application/json"],["authorization","Bearer "+t]]),l=await r(e,{method:"POST",headers:o,body:JSON.stringify(i)}),a;try{a=await l.json()}catch{a=null}return bs(l.ok,l.status,l.statusText,a)};return async(i,o)=>{let l=await n(Object.fromEntries([["documentId",i.documentId],["operationName",i.operationName],["variables",o]]));if(typeof l!="object"){let a=await n(Object.fromEntries([["query",i.text],["operationName",i.operationName],["variables",o]]));return typeof a!="object"||a.TAG!=="Data"?{TAG:"Error",_0:vl(a)}:{TAG:"Ok",_0:a._0}}switch(l.TAG){case"Data":return{TAG:"Ok",_0:l._0};case"GraphqlErrors":case"HttpFailure":return{TAG:"Error",_0:vl(l)}}}}function Cs(e){return Object.fromEntries([["workspaceSlug",e.workspaceSlug],["slug",e.topicSlug]])}async function xl(e,t){let r=await e(wl,Cs(t));return r.TAG==="Ok"?{TAG:"Ok",_0:Wt(q(ae(r._0,"topic"),n=>ae(n,"id")))}:{TAG:"Error",_0:r._0}}async function Fs(e,t){if(!Xn.includes(t.kind))return{TAG:"Error",_0:'unknown entry kind "'+t.kind+'" (one of: '+Xn.join(", ")+")"};let r=t.payloadJson,n=r!==void 0?Es(r):{TAG:"Ok",_0:void 0};if(n.TAG!=="Ok")return{TAG:"Error",_0:n._0};let i=await xl(e,t);if(i.TAG!=="Ok")return{TAG:"Error",_0:i._0};let o=i._0,l;if(o!==void 0)l={TAG:"Ok",_0:[o,!1]};else if(t.createMissing){let g=Object.fromEntries([["workspaceSlug",t.workspaceSlug],["slug",t.topicSlug]]),S=t.title;S!==void 0&&(g.title=S);let T=await e(El,Object.fromEntries([["input",g]]));if(T.TAG==="Ok"){let C=ae(T._0,"createTopic"),N=$(Al(q(C,b=>ae(b,"ok"))),!1),H=Wt(q(q(C,b=>ae(b,"topic")),b=>ae(b,"id"))),X=Wt(q(C,b=>ae(b,"error"))),w=0;if(N&&H!==void 0?l={TAG:"Ok",_0:[H,!0]}:w=1,w===1){let b;if(X!==void 0){let F=X.toLowerCase();b=F.includes("taken")||F.includes("slug")}else b=!1;if(b){let F=await xl(e,t),J=0;if(F.TAG==="Ok"){let L=F._0;L!==void 0?l={TAG:"Ok",_0:[L,!1]}:J=2}else J=2;J===2&&(l={TAG:"Error",_0:'could not create topic "'+t.topicSlug+'": '+$(X,"unknown error")})}else l={TAG:"Error",_0:'could not create topic "'+t.topicSlug+'": '+$(X,"unknown error")}}}else l={TAG:"Error",_0:T._0}}else l={TAG:"Error",_0:'topic "'+t.topicSlug+'" does not exist in workspace "'+t.workspaceSlug+'" (drop --no-create to auto-create it)'};if(l.TAG!=="Ok")return{TAG:"Error",_0:l._0};let a=l._0,s=Object.fromEntries([["topicId",a[0]],["kind",t.kind.toUpperCase()]]),f=t.preview;f!==void 0&&(s.previewText=f);let u=t.body;u!==void 0&&(s.body=u);let m=t.payloadJson;m!==void 0&&(s.payloadJson=m);let c=t.dedupeKey;c!==void 0&&(s.dedupeKey=c);let d=await e(kl,Object.fromEntries([["input",s]]));if(d.TAG!=="Ok")return{TAG:"Error",_0:d._0};let p=ae(d._0,"postTopicEntry"),h=$(Al(q(p,g=>ae(g,"ok"))),!1),_=ks(q(q(p,g=>ae(g,"entry")),g=>ae(g,"entrySeq")));if(h&&_!==void 0)return{TAG:"Ok",_0:{topicSlug:t.topicSlug,entrySeq:_|0,created:a[1]}};let y=Wt(q(p,g=>ae(g,"error")));return{TAG:"Error",_0:'could not post to topic "'+t.topicSlug+'": '+$(y,"unknown error")}}async function Ns(e,t){let r=t.stdout,n=r!==void 0?r:a=>{process.stdout.write(a)},i=t.stderr,o=i!==void 0?i:a=>{process.stderr.write(a)},l=bl(e);if(l.TAG==="Ok"){let a=l._0,s=a.flags,f=a.subcommand;if(Kn(s,"help"))return n(Hn()),0;if(f!==void 0){if(f==="post"){let u=ye(s,"workspace"),m=ye(s,"topic");if(u!==void 0){if(m!==void 0){let c=$(Xr(ye(s,"linzumi-url"),ye(s,"api-url")),t.defaultUrl),d,p=0,h;try{let _=ye(s,"token");h=await(_!==void 0?t.resolveToken({kandanUrl:c,explicitToken:_}):t.resolveToken({kandanUrl:c})),p=1}catch(_){let y=j(_);if(y.RE_EXN_ID==="JsExn")d={TAG:"Error",_0:$(Ae(y._1),"token resolution failed")};else throw y}if(p===1){let _=Gs(t.graphqlEndpoint(c),h,$(t.fetchImpl,fetch));d=await Fs(_,{workspaceSlug:u,topicSlug:m,kind:$(ye(s,"kind"),"status"),preview:ye(s,"preview"),body:ye(s,"body"),payloadJson:ye(s,"payload-json"),dedupeKey:ye(s,"dedupe-key"),title:ye(s,"title"),createMissing:!Kn(s,"no-create")})}if(d.TAG==="Ok"){let _=d._0;if(Kn(s,"json")){let y=Object.fromEntries([["topicSlug",_.topicSlug],["entrySeq",_.entrySeq],["created",_.created]]);n(JSON.stringify(y)+`
174
174
  `)}else{let y=_.created?" (topic auto-created)":"";n("posted entry #"+_.entrySeq.toString()+" to "+u+"/"+_.topicSlug+y+`
175
175
  `)}return 0}return o(d._0+`
176
176
  `),1}return o(`--workspace and --topic are required (see: linzumi topics --help)
177
177
  `),1}return o(`--workspace and --topic are required (see: linzumi topics --help)
178
178
  `),1}return o('unknown topics subcommand "'+f+`"
179
- `),n(Vn()),1}return n(Vn()),1}return o(l._0+`
180
- `),1}async function Nf(e){let t=El(e);if(t.TAG==="Ok"){let r=t._0.flags,n=$(Kr(ye(r,"linzumi-url"),ye(r,"api-url")),Zt),i=gl(n);if(i.TAG==="Ok"){let o=i._0;return await Cs(e,{resolveToken:async l=>{let a=await yl({serviceUrl:l.kandanUrl,explicitToken:l.explicitToken,workspaceSlug:void 0,channelSlug:void 0,requiredScopes:[],onboarding:void 0,authFilePath:void 0,authMode:{TAG:"BrowserMode",callbackHost:void 0},reportRejectedCachedToken:void 0},void 0);return a.TAG==="Ok"?a._0:await Promise.reject({RE_EXN_ID:"Failure",_1:a._0.summary})},defaultUrl:Zt,graphqlEndpoint:l=>o})}return tt(i._0+`
181
- `),1}return tt(t._0+`
182
- `),1}export{ws as booleanFlags,Ol as createDocument,ks as createTransport,Xn as documentOf,Ff as documents,Tl as errorFromOutcome,Hn as flagOn,ye as flagString,Vn as helpText,Es as interpretGraphqlResponse,Sl as jsonBool,ae as jsonField,xs as jsonNumber,Jt as jsonString,wl as lookupDocument,Al as lookupTopicId,bs as lookupVariables,El as parseTopicsArgs,As as persistedDocumentId,xl as postDocument,Gs as postTopicEntry,Nf as run,Cs as runTopicsCommand,Kn as topicEntryKinds,Os as validatePayloadJson,vs as valueFlags};
179
+ `),n(Hn()),1}return n(Hn()),1}return o(l._0+`
180
+ `),1}async function If(e){let t=bl(e);if(t.TAG==="Ok"){let r=t._0.flags,n=$(Xr(ye(r,"linzumi-url"),ye(r,"api-url")),Yt),i=Tl(n);if(i.TAG==="Ok"){let o=i._0;return await Ns(e,{resolveToken:async l=>{let a=await Sl({serviceUrl:l.kandanUrl,explicitToken:l.explicitToken,workspaceSlug:void 0,channelSlug:void 0,requiredScopes:[],onboarding:void 0,authFilePath:void 0,authMode:{TAG:"BrowserMode",callbackHost:void 0},reportRejectedCachedToken:void 0},void 0);return a.TAG==="Ok"?a._0:await Promise.reject({RE_EXN_ID:"Failure",_1:a._0.summary})},defaultUrl:Yt,graphqlEndpoint:l=>o})}return rt(i._0+`
181
+ `),1}return rt(t._0+`
182
+ `),1}export{ws as booleanFlags,El as createDocument,Gs as createTransport,Zn as documentOf,$f as documents,vl as errorFromOutcome,Kn as flagOn,ye as flagString,Hn as helpText,bs as interpretGraphqlResponse,Al as jsonBool,ae as jsonField,ks as jsonNumber,Wt as jsonString,wl as lookupDocument,xl as lookupTopicId,Cs as lookupVariables,bl as parseTopicsArgs,xs as persistedDocumentId,kl as postDocument,Fs as postTopicEntry,If as run,Ns as runTopicsCommand,Xn as topicEntryKinds,Es as validatePayloadJson,Os as valueFlags};