@linzumi/cli 1.0.272 → 1.0.274

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/README.md +1 -1
  2. package/dist/impl-res/cloud-supervisor.mjs +69 -69
  3. package/dist/impl-res/index.js +355 -314
  4. package/dist/impl-res/mcp-server.mjs +34 -34
  5. package/dist/impl-ts/cloud-supervisor.mjs +69 -69
  6. package/dist/impl-ts/index.js +495 -495
  7. package/dist/impl-ts/mcp-server.mjs +1 -1
  8. package/dist/mcp-server.mjs +1 -1
  9. package/package.json +3 -2
  10. package/scripts/check-package-size-budget.mjs +9 -0
  11. package/scripts/build-auth-parity-oracle.mjs +0 -709
  12. package/scripts/build-canonical-codex-transpiler-oracle.mjs +0 -93
  13. package/scripts/build-config-identity-parity-oracle.mjs +0 -526
  14. package/scripts/build-core-commander-seams-parity-oracle.mjs +0 -799
  15. package/scripts/build-core-daemon-parity-oracle.mjs +0 -573
  16. package/scripts/build-core-dispatch-input-queue-parity-oracle.mjs +0 -225
  17. package/scripts/build-core-fate-ladder-parity-oracle.mjs +0 -350
  18. package/scripts/build-core-generation-overlap-parity-oracle.mjs +0 -292
  19. package/scripts/build-core-integration-parity-oracle.mjs +0 -453
  20. package/scripts/build-core-lifecycle-guards-parity-oracle.mjs +0 -443
  21. package/scripts/build-core-lock-parity-oracle.mjs +0 -462
  22. package/scripts/build-core-reconnect-resume-parity-oracle.mjs +0 -365
  23. package/scripts/build-core-startup-resume-scan-parity-oracle.mjs +0 -296
  24. package/scripts/build-core-supervisor-parity-oracle.mjs +0 -781
  25. package/scripts/build-cross-harness-failover-oracle.mjs +0 -349
  26. package/scripts/build-editor-parity-oracle.mjs +0 -1525
  27. package/scripts/build-forwarding-parity-oracle.mjs +0 -1390
  28. package/scripts/build-harness-claude-parity-oracle.mjs +0 -407
  29. package/scripts/build-harness-codex-parity-oracle.mjs +0 -479
  30. package/scripts/build-mcp-parity-oracle.mjs +0 -412
  31. package/scripts/build-mcp-selector-parity-oracle.mjs +0 -65
  32. package/scripts/build-onboarding-discovery-parity-oracle.mjs +0 -388
  33. package/scripts/build-onboarding-flow-parity-oracle.mjs +0 -562
  34. package/scripts/build-onboarding-gateway-parity-oracle.mjs +0 -313
  35. package/scripts/build-onboarding-support-parity-oracle.mjs +0 -519
  36. package/scripts/build-pipeline-parity-oracle.mjs +0 -614
  37. package/scripts/build-protocol-parity-oracle.mjs +0 -398
  38. package/scripts/build-queue-parity-oracle.mjs +0 -1012
  39. package/scripts/build-session-registry-parity-oracle.mjs +0 -582
  40. package/scripts/build-transport-parity-oracle.mjs +0 -694
  41. package/scripts/build-tui-parity-oracle.mjs +0 -577
  42. package/scripts/build-vm-sandbox-parity-oracle.mjs +0 -1281
  43. package/scripts/build-worker-entry-parity-oracle.mjs +0 -424
  44. package/scripts/build-worker-spawn-parity-oracle.mjs +0 -823
@@ -1,14 +1,14 @@
1
1
  import { createRequire as __linzumiBundleCreateRequire } from 'node:module';
2
2
  const require = __linzumiBundleCreateRequire(import.meta.url);
3
- var PS=Object.create;var fu=Object.defineProperty;var CS=Object.getOwnPropertyDescriptor;var RS=Object.getOwnPropertyNames;var IS=Object.getPrototypeOf,jS=Object.prototype.hasOwnProperty;var xn=(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 z=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),mu=(e,t)=>{for(var r in t)fu(e,r,{get:t[r],enumerable:!0})},NS=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of RS(t))!jS.call(e,i)&&i!==r&&fu(e,i,{get:()=>t[i],enumerable:!(n=CS(t,i))||n.enumerable});return e};var Ra=(e,t,r)=>(r=e!=null?PS(IS(e)):{},NS(t||!e||!e.__esModule?fu(r,"default",{value:e,enumerable:!0}):r,e));var xg=z((TM,kg)=>{var Sn=xn("constants"),GS=process.cwd,ja=null,ZS=process.env.GRACEFUL_FS_PLATFORM||process.platform;process.cwd=function(){return ja||(ja=GS.call(process)),ja};try{process.cwd()}catch{}typeof process.chdir=="function"&&(pu=process.chdir,process.chdir=function(e){ja=null,pu.call(process,e)},Object.setPrototypeOf&&Object.setPrototypeOf(process.chdir,pu));var pu;kg.exports=FS;function FS(e){Sn.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=s(e.chownSync),e.fchownSync=s(e.fchownSync),e.lchownSync=s(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=u(e.statSync),e.fstatSync=u(e.fstatSync),e.lstatSync=u(e.lstatSync),e.chmod&&!e.lchmod&&(e.lchmod=function(l,d,p){p&&process.nextTick(p)},e.lchmodSync=function(){}),e.chown&&!e.lchown&&(e.lchown=function(l,d,p,f){f&&process.nextTick(f)},e.lchownSync=function(){}),ZS==="win32"&&(e.rename=typeof e.rename!="function"?e.rename:(function(l){function d(p,f,h){var m=Date.now(),g=0;l(p,f,function y(v){if(v&&(v.code==="EACCES"||v.code==="EPERM"||v.code==="EBUSY")&&Date.now()-m<6e4){setTimeout(function(){e.stat(f,function(b,w){b&&b.code==="ENOENT"?l(p,f,y):h(v)})},g),g<100&&(g+=10);return}h&&h(v)})}return Object.setPrototypeOf&&Object.setPrototypeOf(d,l),d})(e.rename)),e.read=typeof e.read!="function"?e.read:(function(l){function d(p,f,h,m,g,y){var v;if(y&&typeof y=="function"){var b=0;v=function(w,S,R){if(w&&w.code==="EAGAIN"&&b<10)return b++,l.call(e,p,f,h,m,g,v);y.apply(this,arguments)}}return l.call(e,p,f,h,m,g,v)}return Object.setPrototypeOf&&Object.setPrototypeOf(d,l),d})(e.read),e.readSync=typeof e.readSync!="function"?e.readSync:(function(l){return function(d,p,f,h,m){for(var g=0;;)try{return l.call(e,d,p,f,h,m)}catch(y){if(y.code==="EAGAIN"&&g<10){g++;continue}throw y}}})(e.readSync);function t(l){l.lchmod=function(d,p,f){l.open(d,Sn.O_WRONLY|Sn.O_SYMLINK,p,function(h,m){if(h){f&&f(h);return}l.fchmod(m,p,function(g){l.close(m,function(y){f&&f(g||y)})})})},l.lchmodSync=function(d,p){var f=l.openSync(d,Sn.O_WRONLY|Sn.O_SYMLINK,p),h=!0,m;try{m=l.fchmodSync(f,p),h=!1}finally{if(h)try{l.closeSync(f)}catch{}else l.closeSync(f)}return m}}function r(l){Sn.hasOwnProperty("O_SYMLINK")&&l.futimes?(l.lutimes=function(d,p,f,h){l.open(d,Sn.O_SYMLINK,function(m,g){if(m){h&&h(m);return}l.futimes(g,p,f,function(y){l.close(g,function(v){h&&h(y||v)})})})},l.lutimesSync=function(d,p,f){var h=l.openSync(d,Sn.O_SYMLINK),m,g=!0;try{m=l.futimesSync(h,p,f),g=!1}finally{if(g)try{l.closeSync(h)}catch{}else l.closeSync(h)}return m}):l.futimes&&(l.lutimes=function(d,p,f,h){h&&process.nextTick(h)},l.lutimesSync=function(){})}function n(l){return l&&function(d,p,f){return l.call(e,d,p,function(h){c(h)&&(h=null),f&&f.apply(this,arguments)})}}function i(l){return l&&function(d,p){try{return l.call(e,d,p)}catch(f){if(!c(f))throw f}}}function o(l){return l&&function(d,p,f,h){return l.call(e,d,p,f,function(m){c(m)&&(m=null),h&&h.apply(this,arguments)})}}function s(l){return l&&function(d,p,f){try{return l.call(e,d,p,f)}catch(h){if(!c(h))throw h}}}function a(l){return l&&function(d,p,f){typeof p=="function"&&(f=p,p=null);function h(m,g){g&&(g.uid<0&&(g.uid+=4294967296),g.gid<0&&(g.gid+=4294967296)),f&&f.apply(this,arguments)}return p?l.call(e,d,p,h):l.call(e,d,h)}}function u(l){return l&&function(d,p){var f=p?l.call(e,d,p):l.call(e,d);return f&&(f.uid<0&&(f.uid+=4294967296),f.gid<0&&(f.gid+=4294967296)),f}}function c(l){if(!l||l.code==="ENOSYS")return!0;var d=!process.getuid||process.getuid()!==0;return!!(d&&(l.code==="EINVAL"||l.code==="EPERM"))}}});var $g=z(($M,Tg)=>{var Sg=xn("stream").Stream;Tg.exports=qS;function qS(e){return{ReadStream:t,WriteStream:r};function t(n,i){if(!(this instanceof t))return new t(n,i);Sg.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 s=Object.keys(i),a=0,u=s.length;a<u;a++){var c=s[a];this[c]=i[c]}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(l,d){if(l){o.emit("error",l),o.readable=!1;return}o.fd=d,o.emit("open",d),o._read()})}function r(n,i){if(!(this instanceof r))return new r(n,i);Sg.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),s=0,a=o.length;s<a;s++){var u=o[s];this[u]=i[u]}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 zg=z((EM,Eg)=>{"use strict";Eg.exports=US;var LS=Object.getPrototypeOf||function(e){return e.__proto__};function US(e){if(e===null||typeof e!="object")return e;if(e instanceof Object)var t={__proto__:LS(e)};else var t=Object.create(null);return Object.getOwnPropertyNames(e).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))}),t}});var yu=z((zM,_u)=>{var Be=xn("fs"),VS=xg(),BS=$g(),WS=zg(),Na=xn("util"),ft,Da;typeof Symbol=="function"&&typeof Symbol.for=="function"?(ft=Symbol.for("graceful-fs.queue"),Da=Symbol.for("graceful-fs.previous")):(ft="___graceful-fs.queue",Da="___graceful-fs.previous");function JS(){}function Pg(e,t){Object.defineProperty(e,ft,{get:function(){return t}})}var ti=JS;Na.debuglog?ti=Na.debuglog("gfs4"):/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&(ti=function(){var e=Na.format.apply(Na,arguments);e="GFS4: "+e.split(/\n/).join(`
4
- GFS4: `),console.error(e)});Be[ft]||(Ag=global[ft]||[],Pg(Be,Ag),Be.close=(function(e){function t(r,n){return e.call(Be,r,function(i){i||Og(),typeof n=="function"&&n.apply(this,arguments)})}return Object.defineProperty(t,Da,{value:e}),t})(Be.close),Be.closeSync=(function(e){function t(r){e.apply(Be,arguments),Og()}return Object.defineProperty(t,Da,{value:e}),t})(Be.closeSync),/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&process.on("exit",function(){ti(Be[ft]),xn("assert").equal(Be[ft].length,0)}));var Ag;global[ft]||Pg(global,Be[ft]);_u.exports=hu(WS(Be));process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH&&!Be.__patched&&(_u.exports=hu(Be),Be.__patched=!0);function hu(e){VS(e),e.gracefulify=hu,e.createReadStream=S,e.createWriteStream=R;var t=e.readFile;e.readFile=r;function r(D,I,B){return typeof I=="function"&&(B=I,I=null),re(D,I,B);function re(le,j,$,N){return t(le,j,function(G){G&&(G.code==="EMFILE"||G.code==="ENFILE")?Yi([re,[le,j,$],G,N||Date.now(),Date.now()]):typeof $=="function"&&$.apply(this,arguments)})}}var n=e.writeFile;e.writeFile=i;function i(D,I,B,re){return typeof B=="function"&&(re=B,B=null),le(D,I,B,re);function le(j,$,N,G,M){return n(j,$,N,function(V){V&&(V.code==="EMFILE"||V.code==="ENFILE")?Yi([le,[j,$,N,G],V,M||Date.now(),Date.now()]):typeof G=="function"&&G.apply(this,arguments)})}}var o=e.appendFile;o&&(e.appendFile=s);function s(D,I,B,re){return typeof B=="function"&&(re=B,B=null),le(D,I,B,re);function le(j,$,N,G,M){return o(j,$,N,function(V){V&&(V.code==="EMFILE"||V.code==="ENFILE")?Yi([le,[j,$,N,G],V,M||Date.now(),Date.now()]):typeof G=="function"&&G.apply(this,arguments)})}}var a=e.copyFile;a&&(e.copyFile=u);function u(D,I,B,re){return typeof B=="function"&&(re=B,B=0),le(D,I,B,re);function le(j,$,N,G,M){return a(j,$,N,function(V){V&&(V.code==="EMFILE"||V.code==="ENFILE")?Yi([le,[j,$,N,G],V,M||Date.now(),Date.now()]):typeof G=="function"&&G.apply(this,arguments)})}}var c=e.readdir;e.readdir=d;var l=/^v[0-5]\./;function d(D,I,B){typeof I=="function"&&(B=I,I=null);var re=l.test(process.version)?function($,N,G,M){return c($,le($,N,G,M))}:function($,N,G,M){return c($,N,le($,N,G,M))};return re(D,I,B);function le(j,$,N,G){return function(M,V){M&&(M.code==="EMFILE"||M.code==="ENFILE")?Yi([re,[j,$,N],M,G||Date.now(),Date.now()]):(V&&V.sort&&V.sort(),typeof N=="function"&&N.call(this,M,V))}}}if(process.version.substr(0,4)==="v0.8"){var p=BS(e);y=p.ReadStream,b=p.WriteStream}var f=e.ReadStream;f&&(y.prototype=Object.create(f.prototype),y.prototype.open=v);var h=e.WriteStream;h&&(b.prototype=Object.create(h.prototype),b.prototype.open=w),Object.defineProperty(e,"ReadStream",{get:function(){return y},set:function(D){y=D},enumerable:!0,configurable:!0}),Object.defineProperty(e,"WriteStream",{get:function(){return b},set:function(D){b=D},enumerable:!0,configurable:!0});var m=y;Object.defineProperty(e,"FileReadStream",{get:function(){return m},set:function(D){m=D},enumerable:!0,configurable:!0});var g=b;Object.defineProperty(e,"FileWriteStream",{get:function(){return g},set:function(D){g=D},enumerable:!0,configurable:!0});function y(D,I){return this instanceof y?(f.apply(this,arguments),this):y.apply(Object.create(y.prototype),arguments)}function v(){var D=this;be(D.path,D.flags,D.mode,function(I,B){I?(D.autoClose&&D.destroy(),D.emit("error",I)):(D.fd=B,D.emit("open",B),D.read())})}function b(D,I){return this instanceof b?(h.apply(this,arguments),this):b.apply(Object.create(b.prototype),arguments)}function w(){var D=this;be(D.path,D.flags,D.mode,function(I,B){I?(D.destroy(),D.emit("error",I)):(D.fd=B,D.emit("open",B))})}function S(D,I){return new e.ReadStream(D,I)}function R(D,I){return new e.WriteStream(D,I)}var X=e.open;e.open=be;function be(D,I,B,re){return typeof B=="function"&&(re=B,B=null),le(D,I,B,re);function le(j,$,N,G,M){return X(j,$,N,function(V,we){V&&(V.code==="EMFILE"||V.code==="ENFILE")?Yi([le,[j,$,N,G],V,M||Date.now(),Date.now()]):typeof G=="function"&&G.apply(this,arguments)})}}return e}function Yi(e){ti("ENQUEUE",e[0].name,e[1]),Be[ft].push(e),gu()}var Ma;function Og(){for(var e=Date.now(),t=0;t<Be[ft].length;++t)Be[ft][t].length>2&&(Be[ft][t][3]=e,Be[ft][t][4]=e);gu()}function gu(){if(clearTimeout(Ma),Ma=void 0,Be[ft].length!==0){var e=Be[ft].shift(),t=e[0],r=e[1],n=e[2],i=e[3],o=e[4];if(i===void 0)ti("RETRY",t.name,r),t.apply(null,r);else if(Date.now()-i>=6e4){ti("TIMEOUT",t.name,r);var s=r.pop();typeof s=="function"&&s.call(null,n)}else{var a=Date.now()-o,u=Math.max(o-i,1),c=Math.min(u*1.2,100);a>=c?(ti("RETRY",t.name,r),t.apply(null,r.concat([i]))):Be[ft].push(e)}Ma===void 0&&(Ma=setTimeout(gu,0))}}});var Rg=z((AM,Cg)=>{function ir(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))}Cg.exports=ir;ir.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts};ir.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timeouts=[],this._cachedTimeouts=null};ir.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};ir.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)};ir.prototype.try=function(e){console.log("Using RetryOperation.try() is deprecated"),this.attempt(e)};ir.prototype.start=function(e){console.log("Using RetryOperation.start() is deprecated"),this.attempt(e)};ir.prototype.start=ir.prototype.try;ir.prototype.errors=function(){return this._errors};ir.prototype.attempts=function(){return this._attempts};ir.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,s=(e[o]||0)+1;e[o]=s,s>=r&&(t=i,r=s)}return t}});var Ig=z(ri=>{var HS=Rg();ri.operation=function(e){var t=ri.timeouts(e);return new HS(t,{forever:e&&e.forever,unref:e&&e.unref,maxRetryTime:e&&e.maxRetryTime})};ri.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,s){return o-s}),n};ri.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};ri.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],s=e[o];e[o]=function(u){var c=ri.operation(t),l=Array.prototype.slice.call(arguments,1),d=l.pop();l.push(function(p){c.retry(p)||(p&&(arguments[0]=c.mainError()),d.apply(this,arguments))}),c.attempt(function(){u.apply(e,l)})}.bind(e,s),e[o].options=t}}});var Ng=z((PM,jg)=>{jg.exports=Ig()});var Mg=z((CM,Ga)=>{Ga.exports=["SIGABRT","SIGALRM","SIGHUP","SIGINT","SIGTERM"];process.platform!=="win32"&&Ga.exports.push("SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Ga.exports.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT","SIGUNUSED")});var qg=z((RM,ro)=>{var Ne=global.process,ni=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"};ni(Ne)?(Dg=xn("assert"),eo=Mg(),Gg=/^win/i.test(Ne.platform),is=xn("events"),typeof is!="function"&&(is=is.EventEmitter),Ne.__signal_exit_emitter__?ct=Ne.__signal_exit_emitter__:(ct=Ne.__signal_exit_emitter__=new is,ct.count=0,ct.emitted={}),ct.infinite||(ct.setMaxListeners(1/0),ct.infinite=!0),ro.exports=function(e,t){if(!ni(global.process))return function(){};Dg.equal(typeof e,"function","a callback must be provided for exit handler"),to===!1&&vu();var r="exit";t&&t.alwaysLast&&(r="afterexit");var n=function(){ct.removeListener(r,e),ct.listeners("exit").length===0&&ct.listeners("afterexit").length===0&&Za()};return ct.on(r,e),n},Za=function(){!to||!ni(global.process)||(to=!1,eo.forEach(function(t){try{Ne.removeListener(t,Fa[t])}catch{}}),Ne.emit=qa,Ne.reallyExit=bu,ct.count-=1)},ro.exports.unload=Za,ii=function(t,r,n){ct.emitted[t]||(ct.emitted[t]=!0,ct.emit(t,r,n))},Fa={},eo.forEach(function(e){Fa[e]=function(){if(ni(global.process)){var r=Ne.listeners(e);r.length===ct.count&&(Za(),ii("exit",null,e),ii("afterexit",null,e),Gg&&e==="SIGHUP"&&(e="SIGINT"),Ne.kill(Ne.pid,e))}}}),ro.exports.signals=function(){return eo},to=!1,vu=function(){to||!ni(global.process)||(to=!0,ct.count+=1,eo=eo.filter(function(t){try{return Ne.on(t,Fa[t]),!0}catch{return!1}}),Ne.emit=Fg,Ne.reallyExit=Zg)},ro.exports.load=vu,bu=Ne.reallyExit,Zg=function(t){ni(global.process)&&(Ne.exitCode=t||0,ii("exit",Ne.exitCode,null),ii("afterexit",Ne.exitCode,null),bu.call(Ne,Ne.exitCode))},qa=Ne.emit,Fg=function(t,r){if(t==="exit"&&ni(global.process)){r!==void 0&&(Ne.exitCode=r);var n=qa.apply(this,arguments);return ii("exit",Ne.exitCode,null),ii("afterexit",Ne.exitCode,null),n}else return qa.apply(this,arguments)}):ro.exports=function(){return function(){}};var Dg,eo,Gg,is,ct,Za,ii,Fa,to,vu,bu,Zg,qa,Fg});var Wg=z((IM,os)=>{"use strict";var KS=xn("path"),xu=yu(),QS=Ng(),XS=qg(),nn={};function no(e,t){return t.lockfilePath||`${e}.lock`}function Su(e,t,r){if(!t.realpath)return r(null,KS.resolve(e));t.fs.realpath(e,r)}function wu(e,t,r){t.fs.mkdir(no(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(no(e,t),(i,o)=>{if(i)return i.code==="ENOENT"?wu(e,{...t,stale:0},r):r(i);if(!Ug(o,t))return r(Object.assign(new Error("Lock file is already being hold"),{code:"ELOCKED",file:e}));Vg(e,t,s=>{if(s)return r(s);wu(e,{...t,stale:0},r)})})})}function Ug(e,t){return e.mtime.getTime()<Date.now()-t.stale}function Vg(e,t,r){t.fs.rmdir(no(e,t),n=>{if(n&&n.code!=="ENOENT")return r(n);r()})}function ku(e,t){let r=nn[e];r.updateTimeout||(r.updateDelay=r.updateDelay||t.update,r.updateTimeout=setTimeout(()=>{let n=Date.now()/1e3;r.updateTimeout=null,t.fs.utimes(no(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 Lg(e,r,o)}if(i)return i.code==="ENOENT"?Lg(e,r,Object.assign(i,{code:"ECOMPROMISED"})):(r.updateError=i,r.updateDelay=1e3,ku(e,t));r.lastUpdate=Date.now(),r.updateError=null,r.updateDelay=null,ku(e,t)}})},r.updateDelay),r.updateTimeout.unref&&r.updateTimeout.unref())}function Lg(e,t,r){t.released=!0,t.updateTimeout&&clearTimeout(t.updateTimeout),nn[e]===t&&delete nn[e],t.options.onCompromised(r)}function YS(e,t,r){t={stale:1e4,update:null,realpath:!0,retries:0,fs:xu,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),Su(e,t,(n,i)=>{if(n)return r(n);let o=QS.operation(t.retries);o.attempt(()=>{wu(i,t,s=>{if(o.retry(s))return;if(s)return r(o.mainError());let a=nn[i]={options:t,lastUpdate:Date.now()};ku(i,t),r(null,u=>{if(a.released)return u&&u(Object.assign(new Error("Lock is already released"),{code:"ERELEASED"}));Bg(i,{...t,realpath:!1},u)})})})})}function Bg(e,t,r){t={fs:xu,realpath:!0,...t},Su(e,t,(n,i)=>{if(n)return r(n);let o=nn[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 nn[i],Vg(i,t,r)})}function eT(e,t,r){t={stale:1e4,realpath:!0,fs:xu,...t},t.stale=Math.max(t.stale||0,2e3),Su(e,t,(n,i)=>{if(n)return r(n);t.fs.stat(no(i,t),(o,s)=>o?o.code==="ENOENT"?r(null,!1):r(o):r(null,!Ug(s,t)))})}function tT(){return nn}XS(()=>{for(let e in nn){let t=nn[e].options;try{t.fs.rmdirSync(no(e,t))}catch{}}});os.exports.lock=YS;os.exports.unlock=Bg;os.exports.check=eT;os.exports.getLocks=tT});var Hg=z((jM,Jg)=>{"use strict";var rT=yu();function nT(e){let t=["mkdir","realpath","stat","rmdir","utimes"],r={...e};return t.forEach(n=>{r[n]=(...i)=>{let o=i.pop(),s;try{s=e[`${n}Sync`](...i)}catch(a){return o(a)}o(null,s)}}),r}function iT(e){return(...t)=>new Promise((r,n)=>{t.push((i,o)=>{i?n(i):r(o)}),e(...t)})}function oT(e){return(...t)=>{let r,n;if(t.push((i,o)=>{r=i,n=o}),e(...t),r)throw r;return n}}function sT(e){if(e={...e},e.fs=nT(e.fs||rT),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}Jg.exports={toPromise:iT,toSync:oT,toSyncOptions:sT}});var $u=z((NM,Tn)=>{"use strict";var io=Wg(),{toPromise:La,toSync:Ua,toSyncOptions:Tu}=Hg();async function Kg(e,t){let r=await La(io.lock)(e,t);return La(r)}function aT(e,t){let r=Ua(io.lock)(e,Tu(t));return Ua(r)}function cT(e,t){return La(io.unlock)(e,t)}function lT(e,t){return Ua(io.unlock)(e,Tu(t))}function uT(e,t){return La(io.check)(e,t)}function dT(e,t){return Ua(io.check)(e,Tu(t))}Tn.exports=Kg;Tn.exports.lock=Kg;Tn.exports.unlock=cT;Tn.exports.lockSync=aT;Tn.exports.unlockSync=lT;Tn.exports.check=uT;Tn.exports.checkSync=dT});var ia=z(he=>{"use strict";Object.defineProperty(he,"__esModule",{value:!0});he.regexpCode=he.getEsmExportName=he.getProperty=he.safeStringify=he.stringify=he.strConcat=he.addCodeArg=he.str=he._=he.nil=he._Code=he.Name=he.IDENTIFIER=he._CodeOrName=void 0;var ra=class{};he._CodeOrName=ra;he.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var qi=class extends ra{constructor(t){if(super(),!he.IDENTIFIER.test(t))throw new Error("CodeGen: name must be a valid identifier");this.str=t}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};he.Name=qi;var hr=class extends ra{constructor(t){super(),this._items=typeof t=="string"?[t]:t}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let t=this._items[0];return t===""||t==='""'}get str(){var t;return(t=this._str)!==null&&t!==void 0?t:this._str=this._items.reduce((r,n)=>`${r}${n}`,"")}get names(){var t;return(t=this._names)!==null&&t!==void 0?t:this._names=this._items.reduce((r,n)=>(n instanceof qi&&(r[n.str]=(r[n.str]||0)+1),r),{})}};he._Code=hr;he.nil=new hr("");function Ew(e,...t){let r=[e[0]],n=0;for(;n<t.length;)xp(r,t[n]),r.push(e[++n]);return new hr(r)}he._=Ew;var kp=new hr("+");function zw(e,...t){let r=[na(e[0])],n=0;for(;n<t.length;)r.push(kp),xp(r,t[n]),r.push(kp,na(e[++n]));return mC(r),new hr(r)}he.str=zw;function xp(e,t){t instanceof hr?e.push(...t._items):t instanceof qi?e.push(t):e.push(gC(t))}he.addCodeArg=xp;function mC(e){let t=1;for(;t<e.length-1;){if(e[t]===kp){let r=pC(e[t-1],e[t+1]);if(r!==void 0){e.splice(t-1,3,r);continue}e[t++]="+"}t++}}function pC(e,t){if(t==='""')return e;if(e==='""')return t;if(typeof e=="string")return t instanceof qi||e[e.length-1]!=='"'?void 0:typeof t!="string"?`${e.slice(0,-1)}${t}"`:t[0]==='"'?e.slice(0,-1)+t.slice(1):void 0;if(typeof t=="string"&&t[0]==='"'&&!(e instanceof qi))return`"${e}${t.slice(1)}`}function hC(e,t){return t.emptyStr()?e:e.emptyStr()?t:zw`${e}${t}`}he.strConcat=hC;function gC(e){return typeof e=="number"||typeof e=="boolean"||e===null?e:na(Array.isArray(e)?e.join(","):e)}function _C(e){return new hr(na(e))}he.stringify=_C;function na(e){return JSON.stringify(e).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}he.safeStringify=na;function yC(e){return typeof e=="string"&&he.IDENTIFIER.test(e)?new hr(`.${e}`):Ew`[${e}]`}he.getProperty=yC;function vC(e){if(typeof e=="string"&&he.IDENTIFIER.test(e))return new hr(`${e}`);throw new Error(`CodeGen: invalid export name: ${e}, use explicit $id name mapping`)}he.getEsmExportName=vC;function bC(e){return new hr(e.toString())}he.regexpCode=bC});var $p=z(Wt=>{"use strict";Object.defineProperty(Wt,"__esModule",{value:!0});Wt.ValueScope=Wt.ValueScopeName=Wt.Scope=Wt.varKinds=Wt.UsedValueState=void 0;var Bt=ia(),Sp=class extends Error{constructor(t){super(`CodeGen: "code" for ${t} not defined`),this.value=t.value}},kl;(function(e){e[e.Started=0]="Started",e[e.Completed=1]="Completed"})(kl||(Wt.UsedValueState=kl={}));Wt.varKinds={const:new Bt.Name("const"),let:new Bt.Name("let"),var:new Bt.Name("var")};var xl=class{constructor({prefixes:t,parent:r}={}){this._names={},this._prefixes=t,this._parent=r}toName(t){return t instanceof Bt.Name?t:this.name(t)}name(t){return new Bt.Name(this._newName(t))}_newName(t){let r=this._names[t]||this._nameGroup(t);return`${t}${r.index++}`}_nameGroup(t){var r,n;if(!((n=(r=this._parent)===null||r===void 0?void 0:r._prefixes)===null||n===void 0)&&n.has(t)||this._prefixes&&!this._prefixes.has(t))throw new Error(`CodeGen: prefix "${t}" is not allowed in this scope`);return this._names[t]={prefix:t,index:0}}};Wt.Scope=xl;var Sl=class extends Bt.Name{constructor(t,r){super(r),this.prefix=t}setValue(t,{property:r,itemIndex:n}){this.value=t,this.scopePath=(0,Bt._)`.${new Bt.Name(r)}[${n}]`}};Wt.ValueScopeName=Sl;var wC=(0,Bt._)`\n`,Tp=class extends xl{constructor(t){super(t),this._values={},this._scope=t.scope,this.opts={...t,_n:t.lines?wC:Bt.nil}}get(){return this._scope}name(t){return new Sl(t,this._newName(t))}value(t,r){var n;if(r.ref===void 0)throw new Error("CodeGen: ref must be passed in value");let i=this.toName(t),{prefix:o}=i,s=(n=r.key)!==null&&n!==void 0?n:r.ref,a=this._values[o];if(a){let l=a.get(s);if(l)return l}else a=this._values[o]=new Map;a.set(s,i);let u=this._scope[o]||(this._scope[o]=[]),c=u.length;return u[c]=r.ref,i.setValue(r,{property:o,itemIndex:c}),i}getValue(t,r){let n=this._values[t];if(n)return n.get(r)}scopeRefs(t,r=this._values){return this._reduceValues(r,n=>{if(n.scopePath===void 0)throw new Error(`CodeGen: name "${n}" has no value`);return(0,Bt._)`${t}${n.scopePath}`})}scopeCode(t=this._values,r,n){return this._reduceValues(t,i=>{if(i.value===void 0)throw new Error(`CodeGen: name "${i}" has no value`);return i.value.code},r,n)}_reduceValues(t,r,n={},i){let o=Bt.nil;for(let s in t){let a=t[s];if(!a)continue;let u=n[s]=n[s]||new Map;a.forEach(c=>{if(u.has(c))return;u.set(c,kl.Started);let l=r(c);if(l){let d=this.opts.es5?Wt.varKinds.var:Wt.varKinds.const;o=(0,Bt._)`${o}${d} ${c} = ${l};${this.opts._n}`}else if(l=i?.(c))o=(0,Bt._)`${o}${l}${this.opts._n}`;else throw new Sp(c);u.set(c,kl.Completed)})}return o}};Wt.ValueScope=Tp});var ie=z(oe=>{"use strict";Object.defineProperty(oe,"__esModule",{value:!0});oe.or=oe.and=oe.not=oe.CodeGen=oe.operators=oe.varKinds=oe.ValueScopeName=oe.ValueScope=oe.Scope=oe.Name=oe.regexpCode=oe.stringify=oe.getProperty=oe.nil=oe.strConcat=oe.str=oe._=void 0;var fe=ia(),Ar=$p(),Vn=ia();Object.defineProperty(oe,"_",{enumerable:!0,get:function(){return Vn._}});Object.defineProperty(oe,"str",{enumerable:!0,get:function(){return Vn.str}});Object.defineProperty(oe,"strConcat",{enumerable:!0,get:function(){return Vn.strConcat}});Object.defineProperty(oe,"nil",{enumerable:!0,get:function(){return Vn.nil}});Object.defineProperty(oe,"getProperty",{enumerable:!0,get:function(){return Vn.getProperty}});Object.defineProperty(oe,"stringify",{enumerable:!0,get:function(){return Vn.stringify}});Object.defineProperty(oe,"regexpCode",{enumerable:!0,get:function(){return Vn.regexpCode}});Object.defineProperty(oe,"Name",{enumerable:!0,get:function(){return Vn.Name}});var zl=$p();Object.defineProperty(oe,"Scope",{enumerable:!0,get:function(){return zl.Scope}});Object.defineProperty(oe,"ValueScope",{enumerable:!0,get:function(){return zl.ValueScope}});Object.defineProperty(oe,"ValueScopeName",{enumerable:!0,get:function(){return zl.ValueScopeName}});Object.defineProperty(oe,"varKinds",{enumerable:!0,get:function(){return zl.varKinds}});oe.operators={GT:new fe._Code(">"),GTE:new fe._Code(">="),LT:new fe._Code("<"),LTE:new fe._Code("<="),EQ:new fe._Code("==="),NEQ:new fe._Code("!=="),NOT:new fe._Code("!"),OR:new fe._Code("||"),AND:new fe._Code("&&"),ADD:new fe._Code("+")};var gn=class{optimizeNodes(){return this}optimizeNames(t,r){return this}},Ep=class extends gn{constructor(t,r,n){super(),this.varKind=t,this.name=r,this.rhs=n}render({es5:t,_n:r}){let n=t?Ar.varKinds.var:this.varKind,i=this.rhs===void 0?"":` = ${this.rhs}`;return`${n} ${this.name}${i};`+r}optimizeNames(t,r){if(t[this.name.str])return this.rhs&&(this.rhs=Fo(this.rhs,t,r)),this}get names(){return this.rhs instanceof fe._CodeOrName?this.rhs.names:{}}},Tl=class extends gn{constructor(t,r,n){super(),this.lhs=t,this.rhs=r,this.sideEffects=n}render({_n:t}){return`${this.lhs} = ${this.rhs};`+t}optimizeNames(t,r){if(!(this.lhs instanceof fe.Name&&!t[this.lhs.str]&&!this.sideEffects))return this.rhs=Fo(this.rhs,t,r),this}get names(){let t=this.lhs instanceof fe.Name?{}:{...this.lhs.names};return El(t,this.rhs)}},zp=class extends Tl{constructor(t,r,n,i){super(t,n,i),this.op=r}render({_n:t}){return`${this.lhs} ${this.op}= ${this.rhs};`+t}},Ap=class extends gn{constructor(t){super(),this.label=t,this.names={}}render({_n:t}){return`${this.label}:`+t}},Op=class extends gn{constructor(t){super(),this.label=t,this.names={}}render({_n:t}){return`break${this.label?` ${this.label}`:""};`+t}},Pp=class extends gn{constructor(t){super(),this.error=t}render({_n:t}){return`throw ${this.error};`+t}get names(){return this.error.names}},Cp=class extends gn{constructor(t){super(),this.code=t}render({_n:t}){return`${this.code};`+t}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(t,r){return this.code=Fo(this.code,t,r),this}get names(){return this.code instanceof fe._CodeOrName?this.code.names:{}}},oa=class extends gn{constructor(t=[]){super(),this.nodes=t}render(t){return this.nodes.reduce((r,n)=>r+n.render(t),"")}optimizeNodes(){let{nodes:t}=this,r=t.length;for(;r--;){let n=t[r].optimizeNodes();Array.isArray(n)?t.splice(r,1,...n):n?t[r]=n:t.splice(r,1)}return t.length>0?this:void 0}optimizeNames(t,r){let{nodes:n}=this,i=n.length;for(;i--;){let o=n[i];o.optimizeNames(t,r)||(kC(t,o.names),n.splice(i,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((t,r)=>Vi(t,r.names),{})}},_n=class extends oa{render(t){return"{"+t._n+super.render(t)+"}"+t._n}},Rp=class extends oa{},Zo=class extends _n{};Zo.kind="else";var Li=class e extends _n{constructor(t,r){super(r),this.condition=t}render(t){let r=`if(${this.condition})`+super.render(t);return this.else&&(r+="else "+this.else.render(t)),r}optimizeNodes(){super.optimizeNodes();let t=this.condition;if(t===!0)return this.nodes;let r=this.else;if(r){let n=r.optimizeNodes();r=this.else=Array.isArray(n)?new Zo(n):n}if(r)return t===!1?r instanceof e?r:r.nodes:this.nodes.length?this:new e(Aw(t),r instanceof e?[r]:r.nodes);if(!(t===!1||!this.nodes.length))return this}optimizeNames(t,r){var n;if(this.else=(n=this.else)===null||n===void 0?void 0:n.optimizeNames(t,r),!!(super.optimizeNames(t,r)||this.else))return this.condition=Fo(this.condition,t,r),this}get names(){let t=super.names;return El(t,this.condition),this.else&&Vi(t,this.else.names),t}};Li.kind="if";var Ui=class extends _n{};Ui.kind="for";var Ip=class extends Ui{constructor(t){super(),this.iteration=t}render(t){return`for(${this.iteration})`+super.render(t)}optimizeNames(t,r){if(super.optimizeNames(t,r))return this.iteration=Fo(this.iteration,t,r),this}get names(){return Vi(super.names,this.iteration.names)}},jp=class extends Ui{constructor(t,r,n,i){super(),this.varKind=t,this.name=r,this.from=n,this.to=i}render(t){let r=t.es5?Ar.varKinds.var:this.varKind,{name:n,from:i,to:o}=this;return`for(${r} ${n}=${i}; ${n}<${o}; ${n}++)`+super.render(t)}get names(){let t=El(super.names,this.from);return El(t,this.to)}},$l=class extends Ui{constructor(t,r,n,i){super(),this.loop=t,this.varKind=r,this.name=n,this.iterable=i}render(t){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(t)}optimizeNames(t,r){if(super.optimizeNames(t,r))return this.iterable=Fo(this.iterable,t,r),this}get names(){return Vi(super.names,this.iterable.names)}},sa=class extends _n{constructor(t,r,n){super(),this.name=t,this.args=r,this.async=n}render(t){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(t)}};sa.kind="func";var aa=class extends oa{render(t){return"return "+super.render(t)}};aa.kind="return";var Np=class extends _n{render(t){let r="try"+super.render(t);return this.catch&&(r+=this.catch.render(t)),this.finally&&(r+=this.finally.render(t)),r}optimizeNodes(){var t,r;return super.optimizeNodes(),(t=this.catch)===null||t===void 0||t.optimizeNodes(),(r=this.finally)===null||r===void 0||r.optimizeNodes(),this}optimizeNames(t,r){var n,i;return super.optimizeNames(t,r),(n=this.catch)===null||n===void 0||n.optimizeNames(t,r),(i=this.finally)===null||i===void 0||i.optimizeNames(t,r),this}get names(){let t=super.names;return this.catch&&Vi(t,this.catch.names),this.finally&&Vi(t,this.finally.names),t}},ca=class extends _n{constructor(t){super(),this.error=t}render(t){return`catch(${this.error})`+super.render(t)}};ca.kind="catch";var la=class extends _n{render(t){return"finally"+super.render(t)}};la.kind="finally";var Mp=class{constructor(t,r={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...r,_n:r.lines?`
5
- `:""},this._extScope=t,this._scope=new Ar.Scope({parent:t}),this._nodes=[new Rp]}toString(){return this._root.render(this.opts)}name(t){return this._scope.name(t)}scopeName(t){return this._extScope.name(t)}scopeValue(t,r){let n=this._extScope.value(t,r);return(this._values[n.prefix]||(this._values[n.prefix]=new Set)).add(n),n}getScopeValue(t,r){return this._extScope.getValue(t,r)}scopeRefs(t){return this._extScope.scopeRefs(t,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(t,r,n,i){let o=this._scope.toName(r);return n!==void 0&&i&&(this._constants[o.str]=n),this._leafNode(new Ep(t,o,n)),o}const(t,r,n){return this._def(Ar.varKinds.const,t,r,n)}let(t,r,n){return this._def(Ar.varKinds.let,t,r,n)}var(t,r,n){return this._def(Ar.varKinds.var,t,r,n)}assign(t,r,n){return this._leafNode(new Tl(t,r,n))}add(t,r){return this._leafNode(new zp(t,oe.operators.ADD,r))}code(t){return typeof t=="function"?t():t!==fe.nil&&this._leafNode(new Cp(t)),this}object(...t){let r=["{"];for(let[n,i]of t)r.length>1&&r.push(","),r.push(n),(n!==i||this.opts.es5)&&(r.push(":"),(0,fe.addCodeArg)(r,i));return r.push("}"),new fe._Code(r)}if(t,r,n){if(this._blockNode(new Li(t)),r&&n)this.code(r).else().code(n).endIf();else if(r)this.code(r).endIf();else if(n)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(t){return this._elseNode(new Li(t))}else(){return this._elseNode(new Zo)}endIf(){return this._endBlockNode(Li,Zo)}_for(t,r){return this._blockNode(t),r&&this.code(r).endFor(),this}for(t,r){return this._for(new Ip(t),r)}forRange(t,r,n,i,o=this.opts.es5?Ar.varKinds.var:Ar.varKinds.let){let s=this._scope.toName(t);return this._for(new jp(o,s,r,n),()=>i(s))}forOf(t,r,n,i=Ar.varKinds.const){let o=this._scope.toName(t);if(this.opts.es5){let s=r instanceof fe.Name?r:this.var("_arr",r);return this.forRange("_i",0,(0,fe._)`${s}.length`,a=>{this.var(o,(0,fe._)`${s}[${a}]`),n(o)})}return this._for(new $l("of",i,o,r),()=>n(o))}forIn(t,r,n,i=this.opts.es5?Ar.varKinds.var:Ar.varKinds.const){if(this.opts.ownProperties)return this.forOf(t,(0,fe._)`Object.keys(${r})`,n);let o=this._scope.toName(t);return this._for(new $l("in",i,o,r),()=>n(o))}endFor(){return this._endBlockNode(Ui)}label(t){return this._leafNode(new Ap(t))}break(t){return this._leafNode(new Op(t))}return(t){let r=new aa;if(this._blockNode(r),this.code(t),r.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(aa)}try(t,r,n){if(!r&&!n)throw new Error('CodeGen: "try" without "catch" and "finally"');let i=new Np;if(this._blockNode(i),this.code(t),r){let o=this.name("e");this._currNode=i.catch=new ca(o),r(o)}return n&&(this._currNode=i.finally=new la,this.code(n)),this._endBlockNode(ca,la)}throw(t){return this._leafNode(new Pp(t))}block(t,r){return this._blockStarts.push(this._nodes.length),t&&this.code(t).endBlock(r),this}endBlock(t){let r=this._blockStarts.pop();if(r===void 0)throw new Error("CodeGen: not in self-balancing block");let n=this._nodes.length-r;if(n<0||t!==void 0&&n!==t)throw new Error(`CodeGen: wrong number of nodes: ${n} vs ${t} expected`);return this._nodes.length=r,this}func(t,r=fe.nil,n,i){return this._blockNode(new sa(t,r,n)),i&&this.code(i).endFunc(),this}endFunc(){return this._endBlockNode(sa)}optimize(t=1){for(;t-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(t){return this._currNode.nodes.push(t),this}_blockNode(t){this._currNode.nodes.push(t),this._nodes.push(t)}_endBlockNode(t,r){let n=this._currNode;if(n instanceof t||r&&n instanceof r)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${r?`${t.kind}/${r.kind}`:t.kind}"`)}_elseNode(t){let r=this._currNode;if(!(r instanceof Li))throw new Error('CodeGen: "else" without "if"');return this._currNode=r.else=t,this}get _root(){return this._nodes[0]}get _currNode(){let t=this._nodes;return t[t.length-1]}set _currNode(t){let r=this._nodes;r[r.length-1]=t}};oe.CodeGen=Mp;function Vi(e,t){for(let r in t)e[r]=(e[r]||0)+(t[r]||0);return e}function El(e,t){return t instanceof fe._CodeOrName?Vi(e,t.names):e}function Fo(e,t,r){if(e instanceof fe.Name)return n(e);if(!i(e))return e;return new fe._Code(e._items.reduce((o,s)=>(s instanceof fe.Name&&(s=n(s)),s instanceof fe._Code?o.push(...s._items):o.push(s),o),[]));function n(o){let s=r[o.str];return s===void 0||t[o.str]!==1?o:(delete t[o.str],s)}function i(o){return o instanceof fe._Code&&o._items.some(s=>s instanceof fe.Name&&t[s.str]===1&&r[s.str]!==void 0)}}function kC(e,t){for(let r in t)e[r]=(e[r]||0)-(t[r]||0)}function Aw(e){return typeof e=="boolean"||typeof e=="number"||e===null?!e:(0,fe._)`!${Dp(e)}`}oe.not=Aw;var xC=Ow(oe.operators.AND);function SC(...e){return e.reduce(xC)}oe.and=SC;var TC=Ow(oe.operators.OR);function $C(...e){return e.reduce(TC)}oe.or=$C;function Ow(e){return(t,r)=>t===fe.nil?r:r===fe.nil?t:(0,fe._)`${Dp(t)} ${e} ${Dp(r)}`}function Dp(e){return e instanceof fe.Name?e:(0,fe._)`(${e})`}});var ge=z(se=>{"use strict";Object.defineProperty(se,"__esModule",{value:!0});se.checkStrictMode=se.getErrorPath=se.Type=se.useFunc=se.setEvaluated=se.evaluatedPropsToName=se.mergeEvaluated=se.eachItem=se.unescapeJsonPointer=se.escapeJsonPointer=se.escapeFragment=se.unescapeFragment=se.schemaRefOrVal=se.schemaHasRulesButRef=se.schemaHasRules=se.checkUnknownRules=se.alwaysValidSchema=se.toHash=void 0;var $e=ie(),EC=ia();function zC(e){let t={};for(let r of e)t[r]=!0;return t}se.toHash=zC;function AC(e,t){return typeof t=="boolean"?t:Object.keys(t).length===0?!0:(Rw(e,t),!Iw(t,e.self.RULES.all))}se.alwaysValidSchema=AC;function Rw(e,t=e.schema){let{opts:r,self:n}=e;if(!r.strictSchema||typeof t=="boolean")return;let i=n.RULES.keywords;for(let o in t)i[o]||Mw(e,`unknown keyword: "${o}"`)}se.checkUnknownRules=Rw;function Iw(e,t){if(typeof e=="boolean")return!e;for(let r in e)if(t[r])return!0;return!1}se.schemaHasRules=Iw;function OC(e,t){if(typeof e=="boolean")return!e;for(let r in e)if(r!=="$ref"&&t.all[r])return!0;return!1}se.schemaHasRulesButRef=OC;function PC({topSchemaRef:e,schemaPath:t},r,n,i){if(!i){if(typeof r=="number"||typeof r=="boolean")return r;if(typeof r=="string")return(0,$e._)`${r}`}return(0,$e._)`${e}${t}${(0,$e.getProperty)(n)}`}se.schemaRefOrVal=PC;function CC(e){return jw(decodeURIComponent(e))}se.unescapeFragment=CC;function RC(e){return encodeURIComponent(Zp(e))}se.escapeFragment=RC;function Zp(e){return typeof e=="number"?`${e}`:e.replace(/~/g,"~0").replace(/\//g,"~1")}se.escapeJsonPointer=Zp;function jw(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}se.unescapeJsonPointer=jw;function IC(e,t){if(Array.isArray(e))for(let r of e)t(r);else t(e)}se.eachItem=IC;function Pw({mergeNames:e,mergeToName:t,mergeValues:r,resultToName:n}){return(i,o,s,a)=>{let u=s===void 0?o:s instanceof $e.Name?(o instanceof $e.Name?e(i,o,s):t(i,o,s),s):o instanceof $e.Name?(t(i,s,o),o):r(o,s);return a===$e.Name&&!(u instanceof $e.Name)?n(i,u):u}}se.mergeEvaluated={props:Pw({mergeNames:(e,t,r)=>e.if((0,$e._)`${r} !== true && ${t} !== undefined`,()=>{e.if((0,$e._)`${t} === true`,()=>e.assign(r,!0),()=>e.assign(r,(0,$e._)`${r} || {}`).code((0,$e._)`Object.assign(${r}, ${t})`))}),mergeToName:(e,t,r)=>e.if((0,$e._)`${r} !== true`,()=>{t===!0?e.assign(r,!0):(e.assign(r,(0,$e._)`${r} || {}`),Fp(e,r,t))}),mergeValues:(e,t)=>e===!0?!0:{...e,...t},resultToName:Nw}),items:Pw({mergeNames:(e,t,r)=>e.if((0,$e._)`${r} !== true && ${t} !== undefined`,()=>e.assign(r,(0,$e._)`${t} === true ? true : ${r} > ${t} ? ${r} : ${t}`)),mergeToName:(e,t,r)=>e.if((0,$e._)`${r} !== true`,()=>e.assign(r,t===!0?!0:(0,$e._)`${r} > ${t} ? ${r} : ${t}`)),mergeValues:(e,t)=>e===!0?!0:Math.max(e,t),resultToName:(e,t)=>e.var("items",t)})};function Nw(e,t){if(t===!0)return e.var("props",!0);let r=e.var("props",(0,$e._)`{}`);return t!==void 0&&Fp(e,r,t),r}se.evaluatedPropsToName=Nw;function Fp(e,t,r){Object.keys(r).forEach(n=>e.assign((0,$e._)`${t}${(0,$e.getProperty)(n)}`,!0))}se.setEvaluated=Fp;var Cw={};function jC(e,t){return e.scopeValue("func",{ref:t,code:Cw[t.code]||(Cw[t.code]=new EC._Code(t.code))})}se.useFunc=jC;var Gp;(function(e){e[e.Num=0]="Num",e[e.Str=1]="Str"})(Gp||(se.Type=Gp={}));function NC(e,t,r){if(e instanceof $e.Name){let n=t===Gp.Num;return r?n?(0,$e._)`"[" + ${e} + "]"`:(0,$e._)`"['" + ${e} + "']"`:n?(0,$e._)`"/" + ${e}`:(0,$e._)`"/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,$e.getProperty)(e).toString():"/"+Zp(e)}se.getErrorPath=NC;function Mw(e,t,r=e.opts.strictSchema){if(r){if(t=`strict mode: ${t}`,r===!0)throw new Error(t);e.self.logger.warn(t)}}se.checkStrictMode=Mw});var yn=z(qp=>{"use strict";Object.defineProperty(qp,"__esModule",{value:!0});var $t=ie(),MC={data:new $t.Name("data"),valCxt:new $t.Name("valCxt"),instancePath:new $t.Name("instancePath"),parentData:new $t.Name("parentData"),parentDataProperty:new $t.Name("parentDataProperty"),rootData:new $t.Name("rootData"),dynamicAnchors:new $t.Name("dynamicAnchors"),vErrors:new $t.Name("vErrors"),errors:new $t.Name("errors"),this:new $t.Name("this"),self:new $t.Name("self"),scope:new $t.Name("scope"),json:new $t.Name("json"),jsonPos:new $t.Name("jsonPos"),jsonLen:new $t.Name("jsonLen"),jsonPart:new $t.Name("jsonPart")};qp.default=MC});var ua=z(Et=>{"use strict";Object.defineProperty(Et,"__esModule",{value:!0});Et.extendErrors=Et.resetErrorsCount=Et.reportExtraError=Et.reportError=Et.keyword$DataError=Et.keywordError=void 0;var pe=ie(),Al=ge(),Nt=yn();Et.keywordError={message:({keyword:e})=>(0,pe.str)`must pass "${e}" keyword validation`};Et.keyword$DataError={message:({keyword:e,schemaType:t})=>t?(0,pe.str)`"${e}" keyword must be ${t} ($data)`:(0,pe.str)`"${e}" keyword is invalid ($data)`};function DC(e,t=Et.keywordError,r,n){let{it:i}=e,{gen:o,compositeRule:s,allErrors:a}=i,u=Zw(e,t,r);n??(s||a)?Dw(o,u):Gw(i,(0,pe._)`[${u}]`)}Et.reportError=DC;function GC(e,t=Et.keywordError,r){let{it:n}=e,{gen:i,compositeRule:o,allErrors:s}=n,a=Zw(e,t,r);Dw(i,a),o||s||Gw(n,Nt.default.vErrors)}Et.reportExtraError=GC;function ZC(e,t){e.assign(Nt.default.errors,t),e.if((0,pe._)`${Nt.default.vErrors} !== null`,()=>e.if(t,()=>e.assign((0,pe._)`${Nt.default.vErrors}.length`,t),()=>e.assign(Nt.default.vErrors,null)))}Et.resetErrorsCount=ZC;function FC({gen:e,keyword:t,schemaValue:r,data:n,errsCount:i,it:o}){if(i===void 0)throw new Error("ajv implementation error");let s=e.name("err");e.forRange("i",i,Nt.default.errors,a=>{e.const(s,(0,pe._)`${Nt.default.vErrors}[${a}]`),e.if((0,pe._)`${s}.instancePath === undefined`,()=>e.assign((0,pe._)`${s}.instancePath`,(0,pe.strConcat)(Nt.default.instancePath,o.errorPath))),e.assign((0,pe._)`${s}.schemaPath`,(0,pe.str)`${o.errSchemaPath}/${t}`),o.opts.verbose&&(e.assign((0,pe._)`${s}.schema`,r),e.assign((0,pe._)`${s}.data`,n))})}Et.extendErrors=FC;function Dw(e,t){let r=e.const("err",t);e.if((0,pe._)`${Nt.default.vErrors} === null`,()=>e.assign(Nt.default.vErrors,(0,pe._)`[${r}]`),(0,pe._)`${Nt.default.vErrors}.push(${r})`),e.code((0,pe._)`${Nt.default.errors}++`)}function Gw(e,t){let{gen:r,validateName:n,schemaEnv:i}=e;i.$async?r.throw((0,pe._)`new ${e.ValidationError}(${t})`):(r.assign((0,pe._)`${n}.errors`,t),r.return(!1))}var Bi={keyword:new pe.Name("keyword"),schemaPath:new pe.Name("schemaPath"),params:new pe.Name("params"),propertyName:new pe.Name("propertyName"),message:new pe.Name("message"),schema:new pe.Name("schema"),parentSchema:new pe.Name("parentSchema")};function Zw(e,t,r){let{createErrors:n}=e.it;return n===!1?(0,pe._)`{}`:qC(e,t,r)}function qC(e,t,r={}){let{gen:n,it:i}=e,o=[LC(i,r),UC(e,r)];return VC(e,t,o),n.object(...o)}function LC({errorPath:e},{instancePath:t}){let r=t?(0,pe.str)`${e}${(0,Al.getErrorPath)(t,Al.Type.Str)}`:e;return[Nt.default.instancePath,(0,pe.strConcat)(Nt.default.instancePath,r)]}function UC({keyword:e,it:{errSchemaPath:t}},{schemaPath:r,parentSchema:n}){let i=n?t:(0,pe.str)`${t}/${e}`;return r&&(i=(0,pe.str)`${i}${(0,Al.getErrorPath)(r,Al.Type.Str)}`),[Bi.schemaPath,i]}function VC(e,{params:t,message:r},n){let{keyword:i,data:o,schemaValue:s,it:a}=e,{opts:u,propertyName:c,topSchemaRef:l,schemaPath:d}=a;n.push([Bi.keyword,i],[Bi.params,typeof t=="function"?t(e):t||(0,pe._)`{}`]),u.messages&&n.push([Bi.message,typeof r=="function"?r(e):r]),u.verbose&&n.push([Bi.schema,s],[Bi.parentSchema,(0,pe._)`${l}${d}`],[Nt.default.data,o]),c&&n.push([Bi.propertyName,c])}});var qw=z(qo=>{"use strict";Object.defineProperty(qo,"__esModule",{value:!0});qo.boolOrEmptySchema=qo.topBoolOrEmptySchema=void 0;var BC=ua(),WC=ie(),JC=yn(),HC={message:"boolean schema is false"};function KC(e){let{gen:t,schema:r,validateName:n}=e;r===!1?Fw(e,!1):typeof r=="object"&&r.$async===!0?t.return(JC.default.data):(t.assign((0,WC._)`${n}.errors`,null),t.return(!0))}qo.topBoolOrEmptySchema=KC;function QC(e,t){let{gen:r,schema:n}=e;n===!1?(r.var(t,!1),Fw(e)):r.var(t,!0)}qo.boolOrEmptySchema=QC;function Fw(e,t){let{gen:r,data:n}=e,i={gen:r,keyword:"false schema",data:n,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:e};(0,BC.reportError)(i,HC,void 0,t)}});var Lp=z(Lo=>{"use strict";Object.defineProperty(Lo,"__esModule",{value:!0});Lo.getRules=Lo.isJSONType=void 0;var XC=["string","number","integer","boolean","null","object","array"],YC=new Set(XC);function eR(e){return typeof e=="string"&&YC.has(e)}Lo.isJSONType=eR;function tR(){let e={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...e,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},e.number,e.string,e.array,e.object],post:{rules:[]},all:{},keywords:{}}}Lo.getRules=tR});var Up=z(Bn=>{"use strict";Object.defineProperty(Bn,"__esModule",{value:!0});Bn.shouldUseRule=Bn.shouldUseGroup=Bn.schemaHasRulesForType=void 0;function rR({schema:e,self:t},r){let n=t.RULES.types[r];return n&&n!==!0&&Lw(e,n)}Bn.schemaHasRulesForType=rR;function Lw(e,t){return t.rules.some(r=>Uw(e,r))}Bn.shouldUseGroup=Lw;function Uw(e,t){var r;return e[t.keyword]!==void 0||((r=t.definition.implements)===null||r===void 0?void 0:r.some(n=>e[n]!==void 0))}Bn.shouldUseRule=Uw});var da=z(zt=>{"use strict";Object.defineProperty(zt,"__esModule",{value:!0});zt.reportTypeError=zt.checkDataTypes=zt.checkDataType=zt.coerceAndCheckDataType=zt.getJSONTypes=zt.getSchemaTypes=zt.DataType=void 0;var nR=Lp(),iR=Up(),oR=ua(),te=ie(),Vw=ge(),Uo;(function(e){e[e.Correct=0]="Correct",e[e.Wrong=1]="Wrong"})(Uo||(zt.DataType=Uo={}));function sR(e){let t=Bw(e.type);if(t.includes("null")){if(e.nullable===!1)throw new Error("type: null contradicts nullable: false")}else{if(!t.length&&e.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');e.nullable===!0&&t.push("null")}return t}zt.getSchemaTypes=sR;function Bw(e){let t=Array.isArray(e)?e:e?[e]:[];if(t.every(nR.isJSONType))return t;throw new Error("type must be JSONType or JSONType[]: "+t.join(","))}zt.getJSONTypes=Bw;function aR(e,t){let{gen:r,data:n,opts:i}=e,o=cR(t,i.coerceTypes),s=t.length>0&&!(o.length===0&&t.length===1&&(0,iR.schemaHasRulesForType)(e,t[0]));if(s){let a=Bp(t,n,i.strictNumbers,Uo.Wrong);r.if(a,()=>{o.length?lR(e,t,o):Wp(e)})}return s}zt.coerceAndCheckDataType=aR;var Ww=new Set(["string","number","integer","boolean","null"]);function cR(e,t){return t?e.filter(r=>Ww.has(r)||t==="array"&&r==="array"):[]}function lR(e,t,r){let{gen:n,data:i,opts:o}=e,s=n.let("dataType",(0,te._)`typeof ${i}`),a=n.let("coerced",(0,te._)`undefined`);o.coerceTypes==="array"&&n.if((0,te._)`${s} == 'object' && Array.isArray(${i}) && ${i}.length == 1`,()=>n.assign(i,(0,te._)`${i}[0]`).assign(s,(0,te._)`typeof ${i}`).if(Bp(t,i,o.strictNumbers),()=>n.assign(a,i))),n.if((0,te._)`${a} !== undefined`);for(let c of r)(Ww.has(c)||c==="array"&&o.coerceTypes==="array")&&u(c);n.else(),Wp(e),n.endIf(),n.if((0,te._)`${a} !== undefined`,()=>{n.assign(i,a),uR(e,a)});function u(c){switch(c){case"string":n.elseIf((0,te._)`${s} == "number" || ${s} == "boolean"`).assign(a,(0,te._)`"" + ${i}`).elseIf((0,te._)`${i} === null`).assign(a,(0,te._)`""`);return;case"number":n.elseIf((0,te._)`${s} == "boolean" || ${i} === null
3
+ var CS=Object.create;var fu=Object.defineProperty;var RS=Object.getOwnPropertyDescriptor;var IS=Object.getOwnPropertyNames;var jS=Object.getPrototypeOf,NS=Object.prototype.hasOwnProperty;var xn=(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 z=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),mu=(e,t)=>{for(var r in t)fu(e,r,{get:t[r],enumerable:!0})},MS=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of IS(t))!NS.call(e,i)&&i!==r&&fu(e,i,{get:()=>t[i],enumerable:!(n=RS(t,i))||n.enumerable});return e};var Ra=(e,t,r)=>(r=e!=null?CS(jS(e)):{},MS(t||!e||!e.__esModule?fu(r,"default",{value:e,enumerable:!0}):r,e));var xg=z((EM,kg)=>{var Sn=xn("constants"),ZS=process.cwd,ja=null,FS=process.env.GRACEFUL_FS_PLATFORM||process.platform;process.cwd=function(){return ja||(ja=ZS.call(process)),ja};try{process.cwd()}catch{}typeof process.chdir=="function"&&(pu=process.chdir,process.chdir=function(e){ja=null,pu.call(process,e)},Object.setPrototypeOf&&Object.setPrototypeOf(process.chdir,pu));var pu;kg.exports=qS;function qS(e){Sn.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=s(e.chownSync),e.fchownSync=s(e.fchownSync),e.lchownSync=s(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=u(e.statSync),e.fstatSync=u(e.fstatSync),e.lstatSync=u(e.lstatSync),e.chmod&&!e.lchmod&&(e.lchmod=function(l,d,p){p&&process.nextTick(p)},e.lchmodSync=function(){}),e.chown&&!e.lchown&&(e.lchown=function(l,d,p,f){f&&process.nextTick(f)},e.lchownSync=function(){}),FS==="win32"&&(e.rename=typeof e.rename!="function"?e.rename:(function(l){function d(p,f,h){var m=Date.now(),g=0;l(p,f,function y(v){if(v&&(v.code==="EACCES"||v.code==="EPERM"||v.code==="EBUSY")&&Date.now()-m<6e4){setTimeout(function(){e.stat(f,function(b,w){b&&b.code==="ENOENT"?l(p,f,y):h(v)})},g),g<100&&(g+=10);return}h&&h(v)})}return Object.setPrototypeOf&&Object.setPrototypeOf(d,l),d})(e.rename)),e.read=typeof e.read!="function"?e.read:(function(l){function d(p,f,h,m,g,y){var v;if(y&&typeof y=="function"){var b=0;v=function(w,S,R){if(w&&w.code==="EAGAIN"&&b<10)return b++,l.call(e,p,f,h,m,g,v);y.apply(this,arguments)}}return l.call(e,p,f,h,m,g,v)}return Object.setPrototypeOf&&Object.setPrototypeOf(d,l),d})(e.read),e.readSync=typeof e.readSync!="function"?e.readSync:(function(l){return function(d,p,f,h,m){for(var g=0;;)try{return l.call(e,d,p,f,h,m)}catch(y){if(y.code==="EAGAIN"&&g<10){g++;continue}throw y}}})(e.readSync);function t(l){l.lchmod=function(d,p,f){l.open(d,Sn.O_WRONLY|Sn.O_SYMLINK,p,function(h,m){if(h){f&&f(h);return}l.fchmod(m,p,function(g){l.close(m,function(y){f&&f(g||y)})})})},l.lchmodSync=function(d,p){var f=l.openSync(d,Sn.O_WRONLY|Sn.O_SYMLINK,p),h=!0,m;try{m=l.fchmodSync(f,p),h=!1}finally{if(h)try{l.closeSync(f)}catch{}else l.closeSync(f)}return m}}function r(l){Sn.hasOwnProperty("O_SYMLINK")&&l.futimes?(l.lutimes=function(d,p,f,h){l.open(d,Sn.O_SYMLINK,function(m,g){if(m){h&&h(m);return}l.futimes(g,p,f,function(y){l.close(g,function(v){h&&h(y||v)})})})},l.lutimesSync=function(d,p,f){var h=l.openSync(d,Sn.O_SYMLINK),m,g=!0;try{m=l.futimesSync(h,p,f),g=!1}finally{if(g)try{l.closeSync(h)}catch{}else l.closeSync(h)}return m}):l.futimes&&(l.lutimes=function(d,p,f,h){h&&process.nextTick(h)},l.lutimesSync=function(){})}function n(l){return l&&function(d,p,f){return l.call(e,d,p,function(h){c(h)&&(h=null),f&&f.apply(this,arguments)})}}function i(l){return l&&function(d,p){try{return l.call(e,d,p)}catch(f){if(!c(f))throw f}}}function o(l){return l&&function(d,p,f,h){return l.call(e,d,p,f,function(m){c(m)&&(m=null),h&&h.apply(this,arguments)})}}function s(l){return l&&function(d,p,f){try{return l.call(e,d,p,f)}catch(h){if(!c(h))throw h}}}function a(l){return l&&function(d,p,f){typeof p=="function"&&(f=p,p=null);function h(m,g){g&&(g.uid<0&&(g.uid+=4294967296),g.gid<0&&(g.gid+=4294967296)),f&&f.apply(this,arguments)}return p?l.call(e,d,p,h):l.call(e,d,h)}}function u(l){return l&&function(d,p){var f=p?l.call(e,d,p):l.call(e,d);return f&&(f.uid<0&&(f.uid+=4294967296),f.gid<0&&(f.gid+=4294967296)),f}}function c(l){if(!l||l.code==="ENOSYS")return!0;var d=!process.getuid||process.getuid()!==0;return!!(d&&(l.code==="EINVAL"||l.code==="EPERM"))}}});var $g=z((zM,Tg)=>{var Sg=xn("stream").Stream;Tg.exports=LS;function LS(e){return{ReadStream:t,WriteStream:r};function t(n,i){if(!(this instanceof t))return new t(n,i);Sg.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 s=Object.keys(i),a=0,u=s.length;a<u;a++){var c=s[a];this[c]=i[c]}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(l,d){if(l){o.emit("error",l),o.readable=!1;return}o.fd=d,o.emit("open",d),o._read()})}function r(n,i){if(!(this instanceof r))return new r(n,i);Sg.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),s=0,a=o.length;s<a;s++){var u=o[s];this[u]=i[u]}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 zg=z((AM,Eg)=>{"use strict";Eg.exports=VS;var US=Object.getPrototypeOf||function(e){return e.__proto__};function VS(e){if(e===null||typeof e!="object")return e;if(e instanceof Object)var t={__proto__:US(e)};else var t=Object.create(null);return Object.getOwnPropertyNames(e).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))}),t}});var yu=z((OM,_u)=>{var Be=xn("fs"),BS=xg(),WS=$g(),JS=zg(),Na=xn("util"),ft,Da;typeof Symbol=="function"&&typeof Symbol.for=="function"?(ft=Symbol.for("graceful-fs.queue"),Da=Symbol.for("graceful-fs.previous")):(ft="___graceful-fs.queue",Da="___graceful-fs.previous");function HS(){}function Pg(e,t){Object.defineProperty(e,ft,{get:function(){return t}})}var ri=HS;Na.debuglog?ri=Na.debuglog("gfs4"):/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&(ri=function(){var e=Na.format.apply(Na,arguments);e="GFS4: "+e.split(/\n/).join(`
4
+ GFS4: `),console.error(e)});Be[ft]||(Ag=global[ft]||[],Pg(Be,Ag),Be.close=(function(e){function t(r,n){return e.call(Be,r,function(i){i||Og(),typeof n=="function"&&n.apply(this,arguments)})}return Object.defineProperty(t,Da,{value:e}),t})(Be.close),Be.closeSync=(function(e){function t(r){e.apply(Be,arguments),Og()}return Object.defineProperty(t,Da,{value:e}),t})(Be.closeSync),/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&process.on("exit",function(){ri(Be[ft]),xn("assert").equal(Be[ft].length,0)}));var Ag;global[ft]||Pg(global,Be[ft]);_u.exports=hu(JS(Be));process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH&&!Be.__patched&&(_u.exports=hu(Be),Be.__patched=!0);function hu(e){BS(e),e.gracefulify=hu,e.createReadStream=S,e.createWriteStream=R;var t=e.readFile;e.readFile=r;function r(D,I,B){return typeof I=="function"&&(B=I,I=null),re(D,I,B);function re(le,j,$,N){return t(le,j,function(G){G&&(G.code==="EMFILE"||G.code==="ENFILE")?eo([re,[le,j,$],G,N||Date.now(),Date.now()]):typeof $=="function"&&$.apply(this,arguments)})}}var n=e.writeFile;e.writeFile=i;function i(D,I,B,re){return typeof B=="function"&&(re=B,B=null),le(D,I,B,re);function le(j,$,N,G,M){return n(j,$,N,function(V){V&&(V.code==="EMFILE"||V.code==="ENFILE")?eo([le,[j,$,N,G],V,M||Date.now(),Date.now()]):typeof G=="function"&&G.apply(this,arguments)})}}var o=e.appendFile;o&&(e.appendFile=s);function s(D,I,B,re){return typeof B=="function"&&(re=B,B=null),le(D,I,B,re);function le(j,$,N,G,M){return o(j,$,N,function(V){V&&(V.code==="EMFILE"||V.code==="ENFILE")?eo([le,[j,$,N,G],V,M||Date.now(),Date.now()]):typeof G=="function"&&G.apply(this,arguments)})}}var a=e.copyFile;a&&(e.copyFile=u);function u(D,I,B,re){return typeof B=="function"&&(re=B,B=0),le(D,I,B,re);function le(j,$,N,G,M){return a(j,$,N,function(V){V&&(V.code==="EMFILE"||V.code==="ENFILE")?eo([le,[j,$,N,G],V,M||Date.now(),Date.now()]):typeof G=="function"&&G.apply(this,arguments)})}}var c=e.readdir;e.readdir=d;var l=/^v[0-5]\./;function d(D,I,B){typeof I=="function"&&(B=I,I=null);var re=l.test(process.version)?function($,N,G,M){return c($,le($,N,G,M))}:function($,N,G,M){return c($,N,le($,N,G,M))};return re(D,I,B);function le(j,$,N,G){return function(M,V){M&&(M.code==="EMFILE"||M.code==="ENFILE")?eo([re,[j,$,N],M,G||Date.now(),Date.now()]):(V&&V.sort&&V.sort(),typeof N=="function"&&N.call(this,M,V))}}}if(process.version.substr(0,4)==="v0.8"){var p=WS(e);y=p.ReadStream,b=p.WriteStream}var f=e.ReadStream;f&&(y.prototype=Object.create(f.prototype),y.prototype.open=v);var h=e.WriteStream;h&&(b.prototype=Object.create(h.prototype),b.prototype.open=w),Object.defineProperty(e,"ReadStream",{get:function(){return y},set:function(D){y=D},enumerable:!0,configurable:!0}),Object.defineProperty(e,"WriteStream",{get:function(){return b},set:function(D){b=D},enumerable:!0,configurable:!0});var m=y;Object.defineProperty(e,"FileReadStream",{get:function(){return m},set:function(D){m=D},enumerable:!0,configurable:!0});var g=b;Object.defineProperty(e,"FileWriteStream",{get:function(){return g},set:function(D){g=D},enumerable:!0,configurable:!0});function y(D,I){return this instanceof y?(f.apply(this,arguments),this):y.apply(Object.create(y.prototype),arguments)}function v(){var D=this;be(D.path,D.flags,D.mode,function(I,B){I?(D.autoClose&&D.destroy(),D.emit("error",I)):(D.fd=B,D.emit("open",B),D.read())})}function b(D,I){return this instanceof b?(h.apply(this,arguments),this):b.apply(Object.create(b.prototype),arguments)}function w(){var D=this;be(D.path,D.flags,D.mode,function(I,B){I?(D.destroy(),D.emit("error",I)):(D.fd=B,D.emit("open",B))})}function S(D,I){return new e.ReadStream(D,I)}function R(D,I){return new e.WriteStream(D,I)}var X=e.open;e.open=be;function be(D,I,B,re){return typeof B=="function"&&(re=B,B=null),le(D,I,B,re);function le(j,$,N,G,M){return X(j,$,N,function(V,we){V&&(V.code==="EMFILE"||V.code==="ENFILE")?eo([le,[j,$,N,G],V,M||Date.now(),Date.now()]):typeof G=="function"&&G.apply(this,arguments)})}}return e}function eo(e){ri("ENQUEUE",e[0].name,e[1]),Be[ft].push(e),gu()}var Ma;function Og(){for(var e=Date.now(),t=0;t<Be[ft].length;++t)Be[ft][t].length>2&&(Be[ft][t][3]=e,Be[ft][t][4]=e);gu()}function gu(){if(clearTimeout(Ma),Ma=void 0,Be[ft].length!==0){var e=Be[ft].shift(),t=e[0],r=e[1],n=e[2],i=e[3],o=e[4];if(i===void 0)ri("RETRY",t.name,r),t.apply(null,r);else if(Date.now()-i>=6e4){ri("TIMEOUT",t.name,r);var s=r.pop();typeof s=="function"&&s.call(null,n)}else{var a=Date.now()-o,u=Math.max(o-i,1),c=Math.min(u*1.2,100);a>=c?(ri("RETRY",t.name,r),t.apply(null,r.concat([i]))):Be[ft].push(e)}Ma===void 0&&(Ma=setTimeout(gu,0))}}});var Rg=z((PM,Cg)=>{function nr(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))}Cg.exports=nr;nr.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts};nr.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timeouts=[],this._cachedTimeouts=null};nr.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};nr.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)};nr.prototype.try=function(e){console.log("Using RetryOperation.try() is deprecated"),this.attempt(e)};nr.prototype.start=function(e){console.log("Using RetryOperation.start() is deprecated"),this.attempt(e)};nr.prototype.start=nr.prototype.try;nr.prototype.errors=function(){return this._errors};nr.prototype.attempts=function(){return this._attempts};nr.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,s=(e[o]||0)+1;e[o]=s,s>=r&&(t=i,r=s)}return t}});var Ig=z(ni=>{var KS=Rg();ni.operation=function(e){var t=ni.timeouts(e);return new KS(t,{forever:e&&e.forever,unref:e&&e.unref,maxRetryTime:e&&e.maxRetryTime})};ni.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,s){return o-s}),n};ni.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};ni.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],s=e[o];e[o]=function(u){var c=ni.operation(t),l=Array.prototype.slice.call(arguments,1),d=l.pop();l.push(function(p){c.retry(p)||(p&&(arguments[0]=c.mainError()),d.apply(this,arguments))}),c.attempt(function(){u.apply(e,l)})}.bind(e,s),e[o].options=t}}});var Ng=z((RM,jg)=>{jg.exports=Ig()});var Mg=z((IM,Ga)=>{Ga.exports=["SIGABRT","SIGALRM","SIGHUP","SIGINT","SIGTERM"];process.platform!=="win32"&&Ga.exports.push("SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Ga.exports.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT","SIGUNUSED")});var qg=z((jM,no)=>{var Ne=global.process,ii=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"};ii(Ne)?(Dg=xn("assert"),to=Mg(),Gg=/^win/i.test(Ne.platform),is=xn("events"),typeof is!="function"&&(is=is.EventEmitter),Ne.__signal_exit_emitter__?ct=Ne.__signal_exit_emitter__:(ct=Ne.__signal_exit_emitter__=new is,ct.count=0,ct.emitted={}),ct.infinite||(ct.setMaxListeners(1/0),ct.infinite=!0),no.exports=function(e,t){if(!ii(global.process))return function(){};Dg.equal(typeof e,"function","a callback must be provided for exit handler"),ro===!1&&vu();var r="exit";t&&t.alwaysLast&&(r="afterexit");var n=function(){ct.removeListener(r,e),ct.listeners("exit").length===0&&ct.listeners("afterexit").length===0&&Za()};return ct.on(r,e),n},Za=function(){!ro||!ii(global.process)||(ro=!1,to.forEach(function(t){try{Ne.removeListener(t,Fa[t])}catch{}}),Ne.emit=qa,Ne.reallyExit=bu,ct.count-=1)},no.exports.unload=Za,oi=function(t,r,n){ct.emitted[t]||(ct.emitted[t]=!0,ct.emit(t,r,n))},Fa={},to.forEach(function(e){Fa[e]=function(){if(ii(global.process)){var r=Ne.listeners(e);r.length===ct.count&&(Za(),oi("exit",null,e),oi("afterexit",null,e),Gg&&e==="SIGHUP"&&(e="SIGINT"),Ne.kill(Ne.pid,e))}}}),no.exports.signals=function(){return to},ro=!1,vu=function(){ro||!ii(global.process)||(ro=!0,ct.count+=1,to=to.filter(function(t){try{return Ne.on(t,Fa[t]),!0}catch{return!1}}),Ne.emit=Fg,Ne.reallyExit=Zg)},no.exports.load=vu,bu=Ne.reallyExit,Zg=function(t){ii(global.process)&&(Ne.exitCode=t||0,oi("exit",Ne.exitCode,null),oi("afterexit",Ne.exitCode,null),bu.call(Ne,Ne.exitCode))},qa=Ne.emit,Fg=function(t,r){if(t==="exit"&&ii(global.process)){r!==void 0&&(Ne.exitCode=r);var n=qa.apply(this,arguments);return oi("exit",Ne.exitCode,null),oi("afterexit",Ne.exitCode,null),n}else return qa.apply(this,arguments)}):no.exports=function(){return function(){}};var Dg,to,Gg,is,ct,Za,oi,Fa,ro,vu,bu,Zg,qa,Fg});var Wg=z((NM,os)=>{"use strict";var QS=xn("path"),xu=yu(),XS=Ng(),YS=qg(),nn={};function io(e,t){return t.lockfilePath||`${e}.lock`}function Su(e,t,r){if(!t.realpath)return r(null,QS.resolve(e));t.fs.realpath(e,r)}function wu(e,t,r){t.fs.mkdir(io(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(io(e,t),(i,o)=>{if(i)return i.code==="ENOENT"?wu(e,{...t,stale:0},r):r(i);if(!Ug(o,t))return r(Object.assign(new Error("Lock file is already being hold"),{code:"ELOCKED",file:e}));Vg(e,t,s=>{if(s)return r(s);wu(e,{...t,stale:0},r)})})})}function Ug(e,t){return e.mtime.getTime()<Date.now()-t.stale}function Vg(e,t,r){t.fs.rmdir(io(e,t),n=>{if(n&&n.code!=="ENOENT")return r(n);r()})}function ku(e,t){let r=nn[e];r.updateTimeout||(r.updateDelay=r.updateDelay||t.update,r.updateTimeout=setTimeout(()=>{let n=Date.now()/1e3;r.updateTimeout=null,t.fs.utimes(io(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 Lg(e,r,o)}if(i)return i.code==="ENOENT"?Lg(e,r,Object.assign(i,{code:"ECOMPROMISED"})):(r.updateError=i,r.updateDelay=1e3,ku(e,t));r.lastUpdate=Date.now(),r.updateError=null,r.updateDelay=null,ku(e,t)}})},r.updateDelay),r.updateTimeout.unref&&r.updateTimeout.unref())}function Lg(e,t,r){t.released=!0,t.updateTimeout&&clearTimeout(t.updateTimeout),nn[e]===t&&delete nn[e],t.options.onCompromised(r)}function eT(e,t,r){t={stale:1e4,update:null,realpath:!0,retries:0,fs:xu,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),Su(e,t,(n,i)=>{if(n)return r(n);let o=XS.operation(t.retries);o.attempt(()=>{wu(i,t,s=>{if(o.retry(s))return;if(s)return r(o.mainError());let a=nn[i]={options:t,lastUpdate:Date.now()};ku(i,t),r(null,u=>{if(a.released)return u&&u(Object.assign(new Error("Lock is already released"),{code:"ERELEASED"}));Bg(i,{...t,realpath:!1},u)})})})})}function Bg(e,t,r){t={fs:xu,realpath:!0,...t},Su(e,t,(n,i)=>{if(n)return r(n);let o=nn[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 nn[i],Vg(i,t,r)})}function tT(e,t,r){t={stale:1e4,realpath:!0,fs:xu,...t},t.stale=Math.max(t.stale||0,2e3),Su(e,t,(n,i)=>{if(n)return r(n);t.fs.stat(io(i,t),(o,s)=>o?o.code==="ENOENT"?r(null,!1):r(o):r(null,!Ug(s,t)))})}function rT(){return nn}YS(()=>{for(let e in nn){let t=nn[e].options;try{t.fs.rmdirSync(io(e,t))}catch{}}});os.exports.lock=eT;os.exports.unlock=Bg;os.exports.check=tT;os.exports.getLocks=rT});var Hg=z((MM,Jg)=>{"use strict";var nT=yu();function iT(e){let t=["mkdir","realpath","stat","rmdir","utimes"],r={...e};return t.forEach(n=>{r[n]=(...i)=>{let o=i.pop(),s;try{s=e[`${n}Sync`](...i)}catch(a){return o(a)}o(null,s)}}),r}function oT(e){return(...t)=>new Promise((r,n)=>{t.push((i,o)=>{i?n(i):r(o)}),e(...t)})}function sT(e){return(...t)=>{let r,n;if(t.push((i,o)=>{r=i,n=o}),e(...t),r)throw r;return n}}function aT(e){if(e={...e},e.fs=iT(e.fs||nT),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}Jg.exports={toPromise:oT,toSync:sT,toSyncOptions:aT}});var $u=z((DM,Tn)=>{"use strict";var oo=Wg(),{toPromise:La,toSync:Ua,toSyncOptions:Tu}=Hg();async function Kg(e,t){let r=await La(oo.lock)(e,t);return La(r)}function cT(e,t){let r=Ua(oo.lock)(e,Tu(t));return Ua(r)}function lT(e,t){return La(oo.unlock)(e,t)}function uT(e,t){return Ua(oo.unlock)(e,Tu(t))}function dT(e,t){return La(oo.check)(e,t)}function fT(e,t){return Ua(oo.check)(e,Tu(t))}Tn.exports=Kg;Tn.exports.lock=Kg;Tn.exports.unlock=lT;Tn.exports.lockSync=cT;Tn.exports.unlockSync=uT;Tn.exports.check=dT;Tn.exports.checkSync=fT});var ia=z(ge=>{"use strict";Object.defineProperty(ge,"__esModule",{value:!0});ge.regexpCode=ge.getEsmExportName=ge.getProperty=ge.safeStringify=ge.stringify=ge.strConcat=ge.addCodeArg=ge.str=ge._=ge.nil=ge._Code=ge.Name=ge.IDENTIFIER=ge._CodeOrName=void 0;var ra=class{};ge._CodeOrName=ra;ge.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var Li=class extends ra{constructor(t){if(super(),!ge.IDENTIFIER.test(t))throw new Error("CodeGen: name must be a valid identifier");this.str=t}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};ge.Name=Li;var hr=class extends ra{constructor(t){super(),this._items=typeof t=="string"?[t]:t}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let t=this._items[0];return t===""||t==='""'}get str(){var t;return(t=this._str)!==null&&t!==void 0?t:this._str=this._items.reduce((r,n)=>`${r}${n}`,"")}get names(){var t;return(t=this._names)!==null&&t!==void 0?t:this._names=this._items.reduce((r,n)=>(n instanceof Li&&(r[n.str]=(r[n.str]||0)+1),r),{})}};ge._Code=hr;ge.nil=new hr("");function zw(e,...t){let r=[e[0]],n=0;for(;n<t.length;)xp(r,t[n]),r.push(e[++n]);return new hr(r)}ge._=zw;var kp=new hr("+");function Aw(e,...t){let r=[na(e[0])],n=0;for(;n<t.length;)r.push(kp),xp(r,t[n]),r.push(kp,na(e[++n]));return hC(r),new hr(r)}ge.str=Aw;function xp(e,t){t instanceof hr?e.push(...t._items):t instanceof Li?e.push(t):e.push(yC(t))}ge.addCodeArg=xp;function hC(e){let t=1;for(;t<e.length-1;){if(e[t]===kp){let r=gC(e[t-1],e[t+1]);if(r!==void 0){e.splice(t-1,3,r);continue}e[t++]="+"}t++}}function gC(e,t){if(t==='""')return e;if(e==='""')return t;if(typeof e=="string")return t instanceof Li||e[e.length-1]!=='"'?void 0:typeof t!="string"?`${e.slice(0,-1)}${t}"`:t[0]==='"'?e.slice(0,-1)+t.slice(1):void 0;if(typeof t=="string"&&t[0]==='"'&&!(e instanceof Li))return`"${e}${t.slice(1)}`}function _C(e,t){return t.emptyStr()?e:e.emptyStr()?t:Aw`${e}${t}`}ge.strConcat=_C;function yC(e){return typeof e=="number"||typeof e=="boolean"||e===null?e:na(Array.isArray(e)?e.join(","):e)}function vC(e){return new hr(na(e))}ge.stringify=vC;function na(e){return JSON.stringify(e).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}ge.safeStringify=na;function bC(e){return typeof e=="string"&&ge.IDENTIFIER.test(e)?new hr(`.${e}`):zw`[${e}]`}ge.getProperty=bC;function wC(e){if(typeof e=="string"&&ge.IDENTIFIER.test(e))return new hr(`${e}`);throw new Error(`CodeGen: invalid export name: ${e}, use explicit $id name mapping`)}ge.getEsmExportName=wC;function kC(e){return new hr(e.toString())}ge.regexpCode=kC});var $p=z(Wt=>{"use strict";Object.defineProperty(Wt,"__esModule",{value:!0});Wt.ValueScope=Wt.ValueScopeName=Wt.Scope=Wt.varKinds=Wt.UsedValueState=void 0;var Bt=ia(),Sp=class extends Error{constructor(t){super(`CodeGen: "code" for ${t} not defined`),this.value=t.value}},kl;(function(e){e[e.Started=0]="Started",e[e.Completed=1]="Completed"})(kl||(Wt.UsedValueState=kl={}));Wt.varKinds={const:new Bt.Name("const"),let:new Bt.Name("let"),var:new Bt.Name("var")};var xl=class{constructor({prefixes:t,parent:r}={}){this._names={},this._prefixes=t,this._parent=r}toName(t){return t instanceof Bt.Name?t:this.name(t)}name(t){return new Bt.Name(this._newName(t))}_newName(t){let r=this._names[t]||this._nameGroup(t);return`${t}${r.index++}`}_nameGroup(t){var r,n;if(!((n=(r=this._parent)===null||r===void 0?void 0:r._prefixes)===null||n===void 0)&&n.has(t)||this._prefixes&&!this._prefixes.has(t))throw new Error(`CodeGen: prefix "${t}" is not allowed in this scope`);return this._names[t]={prefix:t,index:0}}};Wt.Scope=xl;var Sl=class extends Bt.Name{constructor(t,r){super(r),this.prefix=t}setValue(t,{property:r,itemIndex:n}){this.value=t,this.scopePath=(0,Bt._)`.${new Bt.Name(r)}[${n}]`}};Wt.ValueScopeName=Sl;var xC=(0,Bt._)`\n`,Tp=class extends xl{constructor(t){super(t),this._values={},this._scope=t.scope,this.opts={...t,_n:t.lines?xC:Bt.nil}}get(){return this._scope}name(t){return new Sl(t,this._newName(t))}value(t,r){var n;if(r.ref===void 0)throw new Error("CodeGen: ref must be passed in value");let i=this.toName(t),{prefix:o}=i,s=(n=r.key)!==null&&n!==void 0?n:r.ref,a=this._values[o];if(a){let l=a.get(s);if(l)return l}else a=this._values[o]=new Map;a.set(s,i);let u=this._scope[o]||(this._scope[o]=[]),c=u.length;return u[c]=r.ref,i.setValue(r,{property:o,itemIndex:c}),i}getValue(t,r){let n=this._values[t];if(n)return n.get(r)}scopeRefs(t,r=this._values){return this._reduceValues(r,n=>{if(n.scopePath===void 0)throw new Error(`CodeGen: name "${n}" has no value`);return(0,Bt._)`${t}${n.scopePath}`})}scopeCode(t=this._values,r,n){return this._reduceValues(t,i=>{if(i.value===void 0)throw new Error(`CodeGen: name "${i}" has no value`);return i.value.code},r,n)}_reduceValues(t,r,n={},i){let o=Bt.nil;for(let s in t){let a=t[s];if(!a)continue;let u=n[s]=n[s]||new Map;a.forEach(c=>{if(u.has(c))return;u.set(c,kl.Started);let l=r(c);if(l){let d=this.opts.es5?Wt.varKinds.var:Wt.varKinds.const;o=(0,Bt._)`${o}${d} ${c} = ${l};${this.opts._n}`}else if(l=i?.(c))o=(0,Bt._)`${o}${l}${this.opts._n}`;else throw new Sp(c);u.set(c,kl.Completed)})}return o}};Wt.ValueScope=Tp});var ie=z(oe=>{"use strict";Object.defineProperty(oe,"__esModule",{value:!0});oe.or=oe.and=oe.not=oe.CodeGen=oe.operators=oe.varKinds=oe.ValueScopeName=oe.ValueScope=oe.Scope=oe.Name=oe.regexpCode=oe.stringify=oe.getProperty=oe.nil=oe.strConcat=oe.str=oe._=void 0;var fe=ia(),Ar=$p(),Bn=ia();Object.defineProperty(oe,"_",{enumerable:!0,get:function(){return Bn._}});Object.defineProperty(oe,"str",{enumerable:!0,get:function(){return Bn.str}});Object.defineProperty(oe,"strConcat",{enumerable:!0,get:function(){return Bn.strConcat}});Object.defineProperty(oe,"nil",{enumerable:!0,get:function(){return Bn.nil}});Object.defineProperty(oe,"getProperty",{enumerable:!0,get:function(){return Bn.getProperty}});Object.defineProperty(oe,"stringify",{enumerable:!0,get:function(){return Bn.stringify}});Object.defineProperty(oe,"regexpCode",{enumerable:!0,get:function(){return Bn.regexpCode}});Object.defineProperty(oe,"Name",{enumerable:!0,get:function(){return Bn.Name}});var zl=$p();Object.defineProperty(oe,"Scope",{enumerable:!0,get:function(){return zl.Scope}});Object.defineProperty(oe,"ValueScope",{enumerable:!0,get:function(){return zl.ValueScope}});Object.defineProperty(oe,"ValueScopeName",{enumerable:!0,get:function(){return zl.ValueScopeName}});Object.defineProperty(oe,"varKinds",{enumerable:!0,get:function(){return zl.varKinds}});oe.operators={GT:new fe._Code(">"),GTE:new fe._Code(">="),LT:new fe._Code("<"),LTE:new fe._Code("<="),EQ:new fe._Code("==="),NEQ:new fe._Code("!=="),NOT:new fe._Code("!"),OR:new fe._Code("||"),AND:new fe._Code("&&"),ADD:new fe._Code("+")};var gn=class{optimizeNodes(){return this}optimizeNames(t,r){return this}},Ep=class extends gn{constructor(t,r,n){super(),this.varKind=t,this.name=r,this.rhs=n}render({es5:t,_n:r}){let n=t?Ar.varKinds.var:this.varKind,i=this.rhs===void 0?"":` = ${this.rhs}`;return`${n} ${this.name}${i};`+r}optimizeNames(t,r){if(t[this.name.str])return this.rhs&&(this.rhs=Fo(this.rhs,t,r)),this}get names(){return this.rhs instanceof fe._CodeOrName?this.rhs.names:{}}},Tl=class extends gn{constructor(t,r,n){super(),this.lhs=t,this.rhs=r,this.sideEffects=n}render({_n:t}){return`${this.lhs} = ${this.rhs};`+t}optimizeNames(t,r){if(!(this.lhs instanceof fe.Name&&!t[this.lhs.str]&&!this.sideEffects))return this.rhs=Fo(this.rhs,t,r),this}get names(){let t=this.lhs instanceof fe.Name?{}:{...this.lhs.names};return El(t,this.rhs)}},zp=class extends Tl{constructor(t,r,n,i){super(t,n,i),this.op=r}render({_n:t}){return`${this.lhs} ${this.op}= ${this.rhs};`+t}},Ap=class extends gn{constructor(t){super(),this.label=t,this.names={}}render({_n:t}){return`${this.label}:`+t}},Op=class extends gn{constructor(t){super(),this.label=t,this.names={}}render({_n:t}){return`break${this.label?` ${this.label}`:""};`+t}},Pp=class extends gn{constructor(t){super(),this.error=t}render({_n:t}){return`throw ${this.error};`+t}get names(){return this.error.names}},Cp=class extends gn{constructor(t){super(),this.code=t}render({_n:t}){return`${this.code};`+t}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(t,r){return this.code=Fo(this.code,t,r),this}get names(){return this.code instanceof fe._CodeOrName?this.code.names:{}}},oa=class extends gn{constructor(t=[]){super(),this.nodes=t}render(t){return this.nodes.reduce((r,n)=>r+n.render(t),"")}optimizeNodes(){let{nodes:t}=this,r=t.length;for(;r--;){let n=t[r].optimizeNodes();Array.isArray(n)?t.splice(r,1,...n):n?t[r]=n:t.splice(r,1)}return t.length>0?this:void 0}optimizeNames(t,r){let{nodes:n}=this,i=n.length;for(;i--;){let o=n[i];o.optimizeNames(t,r)||(SC(t,o.names),n.splice(i,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((t,r)=>Bi(t,r.names),{})}},_n=class extends oa{render(t){return"{"+t._n+super.render(t)+"}"+t._n}},Rp=class extends oa{},Zo=class extends _n{};Zo.kind="else";var Ui=class e extends _n{constructor(t,r){super(r),this.condition=t}render(t){let r=`if(${this.condition})`+super.render(t);return this.else&&(r+="else "+this.else.render(t)),r}optimizeNodes(){super.optimizeNodes();let t=this.condition;if(t===!0)return this.nodes;let r=this.else;if(r){let n=r.optimizeNodes();r=this.else=Array.isArray(n)?new Zo(n):n}if(r)return t===!1?r instanceof e?r:r.nodes:this.nodes.length?this:new e(Ow(t),r instanceof e?[r]:r.nodes);if(!(t===!1||!this.nodes.length))return this}optimizeNames(t,r){var n;if(this.else=(n=this.else)===null||n===void 0?void 0:n.optimizeNames(t,r),!!(super.optimizeNames(t,r)||this.else))return this.condition=Fo(this.condition,t,r),this}get names(){let t=super.names;return El(t,this.condition),this.else&&Bi(t,this.else.names),t}};Ui.kind="if";var Vi=class extends _n{};Vi.kind="for";var Ip=class extends Vi{constructor(t){super(),this.iteration=t}render(t){return`for(${this.iteration})`+super.render(t)}optimizeNames(t,r){if(super.optimizeNames(t,r))return this.iteration=Fo(this.iteration,t,r),this}get names(){return Bi(super.names,this.iteration.names)}},jp=class extends Vi{constructor(t,r,n,i){super(),this.varKind=t,this.name=r,this.from=n,this.to=i}render(t){let r=t.es5?Ar.varKinds.var:this.varKind,{name:n,from:i,to:o}=this;return`for(${r} ${n}=${i}; ${n}<${o}; ${n}++)`+super.render(t)}get names(){let t=El(super.names,this.from);return El(t,this.to)}},$l=class extends Vi{constructor(t,r,n,i){super(),this.loop=t,this.varKind=r,this.name=n,this.iterable=i}render(t){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(t)}optimizeNames(t,r){if(super.optimizeNames(t,r))return this.iterable=Fo(this.iterable,t,r),this}get names(){return Bi(super.names,this.iterable.names)}},sa=class extends _n{constructor(t,r,n){super(),this.name=t,this.args=r,this.async=n}render(t){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(t)}};sa.kind="func";var aa=class extends oa{render(t){return"return "+super.render(t)}};aa.kind="return";var Np=class extends _n{render(t){let r="try"+super.render(t);return this.catch&&(r+=this.catch.render(t)),this.finally&&(r+=this.finally.render(t)),r}optimizeNodes(){var t,r;return super.optimizeNodes(),(t=this.catch)===null||t===void 0||t.optimizeNodes(),(r=this.finally)===null||r===void 0||r.optimizeNodes(),this}optimizeNames(t,r){var n,i;return super.optimizeNames(t,r),(n=this.catch)===null||n===void 0||n.optimizeNames(t,r),(i=this.finally)===null||i===void 0||i.optimizeNames(t,r),this}get names(){let t=super.names;return this.catch&&Bi(t,this.catch.names),this.finally&&Bi(t,this.finally.names),t}},ca=class extends _n{constructor(t){super(),this.error=t}render(t){return`catch(${this.error})`+super.render(t)}};ca.kind="catch";var la=class extends _n{render(t){return"finally"+super.render(t)}};la.kind="finally";var Mp=class{constructor(t,r={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...r,_n:r.lines?`
5
+ `:""},this._extScope=t,this._scope=new Ar.Scope({parent:t}),this._nodes=[new Rp]}toString(){return this._root.render(this.opts)}name(t){return this._scope.name(t)}scopeName(t){return this._extScope.name(t)}scopeValue(t,r){let n=this._extScope.value(t,r);return(this._values[n.prefix]||(this._values[n.prefix]=new Set)).add(n),n}getScopeValue(t,r){return this._extScope.getValue(t,r)}scopeRefs(t){return this._extScope.scopeRefs(t,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(t,r,n,i){let o=this._scope.toName(r);return n!==void 0&&i&&(this._constants[o.str]=n),this._leafNode(new Ep(t,o,n)),o}const(t,r,n){return this._def(Ar.varKinds.const,t,r,n)}let(t,r,n){return this._def(Ar.varKinds.let,t,r,n)}var(t,r,n){return this._def(Ar.varKinds.var,t,r,n)}assign(t,r,n){return this._leafNode(new Tl(t,r,n))}add(t,r){return this._leafNode(new zp(t,oe.operators.ADD,r))}code(t){return typeof t=="function"?t():t!==fe.nil&&this._leafNode(new Cp(t)),this}object(...t){let r=["{"];for(let[n,i]of t)r.length>1&&r.push(","),r.push(n),(n!==i||this.opts.es5)&&(r.push(":"),(0,fe.addCodeArg)(r,i));return r.push("}"),new fe._Code(r)}if(t,r,n){if(this._blockNode(new Ui(t)),r&&n)this.code(r).else().code(n).endIf();else if(r)this.code(r).endIf();else if(n)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(t){return this._elseNode(new Ui(t))}else(){return this._elseNode(new Zo)}endIf(){return this._endBlockNode(Ui,Zo)}_for(t,r){return this._blockNode(t),r&&this.code(r).endFor(),this}for(t,r){return this._for(new Ip(t),r)}forRange(t,r,n,i,o=this.opts.es5?Ar.varKinds.var:Ar.varKinds.let){let s=this._scope.toName(t);return this._for(new jp(o,s,r,n),()=>i(s))}forOf(t,r,n,i=Ar.varKinds.const){let o=this._scope.toName(t);if(this.opts.es5){let s=r instanceof fe.Name?r:this.var("_arr",r);return this.forRange("_i",0,(0,fe._)`${s}.length`,a=>{this.var(o,(0,fe._)`${s}[${a}]`),n(o)})}return this._for(new $l("of",i,o,r),()=>n(o))}forIn(t,r,n,i=this.opts.es5?Ar.varKinds.var:Ar.varKinds.const){if(this.opts.ownProperties)return this.forOf(t,(0,fe._)`Object.keys(${r})`,n);let o=this._scope.toName(t);return this._for(new $l("in",i,o,r),()=>n(o))}endFor(){return this._endBlockNode(Vi)}label(t){return this._leafNode(new Ap(t))}break(t){return this._leafNode(new Op(t))}return(t){let r=new aa;if(this._blockNode(r),this.code(t),r.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(aa)}try(t,r,n){if(!r&&!n)throw new Error('CodeGen: "try" without "catch" and "finally"');let i=new Np;if(this._blockNode(i),this.code(t),r){let o=this.name("e");this._currNode=i.catch=new ca(o),r(o)}return n&&(this._currNode=i.finally=new la,this.code(n)),this._endBlockNode(ca,la)}throw(t){return this._leafNode(new Pp(t))}block(t,r){return this._blockStarts.push(this._nodes.length),t&&this.code(t).endBlock(r),this}endBlock(t){let r=this._blockStarts.pop();if(r===void 0)throw new Error("CodeGen: not in self-balancing block");let n=this._nodes.length-r;if(n<0||t!==void 0&&n!==t)throw new Error(`CodeGen: wrong number of nodes: ${n} vs ${t} expected`);return this._nodes.length=r,this}func(t,r=fe.nil,n,i){return this._blockNode(new sa(t,r,n)),i&&this.code(i).endFunc(),this}endFunc(){return this._endBlockNode(sa)}optimize(t=1){for(;t-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(t){return this._currNode.nodes.push(t),this}_blockNode(t){this._currNode.nodes.push(t),this._nodes.push(t)}_endBlockNode(t,r){let n=this._currNode;if(n instanceof t||r&&n instanceof r)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${r?`${t.kind}/${r.kind}`:t.kind}"`)}_elseNode(t){let r=this._currNode;if(!(r instanceof Ui))throw new Error('CodeGen: "else" without "if"');return this._currNode=r.else=t,this}get _root(){return this._nodes[0]}get _currNode(){let t=this._nodes;return t[t.length-1]}set _currNode(t){let r=this._nodes;r[r.length-1]=t}};oe.CodeGen=Mp;function Bi(e,t){for(let r in t)e[r]=(e[r]||0)+(t[r]||0);return e}function El(e,t){return t instanceof fe._CodeOrName?Bi(e,t.names):e}function Fo(e,t,r){if(e instanceof fe.Name)return n(e);if(!i(e))return e;return new fe._Code(e._items.reduce((o,s)=>(s instanceof fe.Name&&(s=n(s)),s instanceof fe._Code?o.push(...s._items):o.push(s),o),[]));function n(o){let s=r[o.str];return s===void 0||t[o.str]!==1?o:(delete t[o.str],s)}function i(o){return o instanceof fe._Code&&o._items.some(s=>s instanceof fe.Name&&t[s.str]===1&&r[s.str]!==void 0)}}function SC(e,t){for(let r in t)e[r]=(e[r]||0)-(t[r]||0)}function Ow(e){return typeof e=="boolean"||typeof e=="number"||e===null?!e:(0,fe._)`!${Dp(e)}`}oe.not=Ow;var TC=Pw(oe.operators.AND);function $C(...e){return e.reduce(TC)}oe.and=$C;var EC=Pw(oe.operators.OR);function zC(...e){return e.reduce(EC)}oe.or=zC;function Pw(e){return(t,r)=>t===fe.nil?r:r===fe.nil?t:(0,fe._)`${Dp(t)} ${e} ${Dp(r)}`}function Dp(e){return e instanceof fe.Name?e:(0,fe._)`(${e})`}});var _e=z(se=>{"use strict";Object.defineProperty(se,"__esModule",{value:!0});se.checkStrictMode=se.getErrorPath=se.Type=se.useFunc=se.setEvaluated=se.evaluatedPropsToName=se.mergeEvaluated=se.eachItem=se.unescapeJsonPointer=se.escapeJsonPointer=se.escapeFragment=se.unescapeFragment=se.schemaRefOrVal=se.schemaHasRulesButRef=se.schemaHasRules=se.checkUnknownRules=se.alwaysValidSchema=se.toHash=void 0;var $e=ie(),AC=ia();function OC(e){let t={};for(let r of e)t[r]=!0;return t}se.toHash=OC;function PC(e,t){return typeof t=="boolean"?t:Object.keys(t).length===0?!0:(Iw(e,t),!jw(t,e.self.RULES.all))}se.alwaysValidSchema=PC;function Iw(e,t=e.schema){let{opts:r,self:n}=e;if(!r.strictSchema||typeof t=="boolean")return;let i=n.RULES.keywords;for(let o in t)i[o]||Dw(e,`unknown keyword: "${o}"`)}se.checkUnknownRules=Iw;function jw(e,t){if(typeof e=="boolean")return!e;for(let r in e)if(t[r])return!0;return!1}se.schemaHasRules=jw;function CC(e,t){if(typeof e=="boolean")return!e;for(let r in e)if(r!=="$ref"&&t.all[r])return!0;return!1}se.schemaHasRulesButRef=CC;function RC({topSchemaRef:e,schemaPath:t},r,n,i){if(!i){if(typeof r=="number"||typeof r=="boolean")return r;if(typeof r=="string")return(0,$e._)`${r}`}return(0,$e._)`${e}${t}${(0,$e.getProperty)(n)}`}se.schemaRefOrVal=RC;function IC(e){return Nw(decodeURIComponent(e))}se.unescapeFragment=IC;function jC(e){return encodeURIComponent(Zp(e))}se.escapeFragment=jC;function Zp(e){return typeof e=="number"?`${e}`:e.replace(/~/g,"~0").replace(/\//g,"~1")}se.escapeJsonPointer=Zp;function Nw(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}se.unescapeJsonPointer=Nw;function NC(e,t){if(Array.isArray(e))for(let r of e)t(r);else t(e)}se.eachItem=NC;function Cw({mergeNames:e,mergeToName:t,mergeValues:r,resultToName:n}){return(i,o,s,a)=>{let u=s===void 0?o:s instanceof $e.Name?(o instanceof $e.Name?e(i,o,s):t(i,o,s),s):o instanceof $e.Name?(t(i,s,o),o):r(o,s);return a===$e.Name&&!(u instanceof $e.Name)?n(i,u):u}}se.mergeEvaluated={props:Cw({mergeNames:(e,t,r)=>e.if((0,$e._)`${r} !== true && ${t} !== undefined`,()=>{e.if((0,$e._)`${t} === true`,()=>e.assign(r,!0),()=>e.assign(r,(0,$e._)`${r} || {}`).code((0,$e._)`Object.assign(${r}, ${t})`))}),mergeToName:(e,t,r)=>e.if((0,$e._)`${r} !== true`,()=>{t===!0?e.assign(r,!0):(e.assign(r,(0,$e._)`${r} || {}`),Fp(e,r,t))}),mergeValues:(e,t)=>e===!0?!0:{...e,...t},resultToName:Mw}),items:Cw({mergeNames:(e,t,r)=>e.if((0,$e._)`${r} !== true && ${t} !== undefined`,()=>e.assign(r,(0,$e._)`${t} === true ? true : ${r} > ${t} ? ${r} : ${t}`)),mergeToName:(e,t,r)=>e.if((0,$e._)`${r} !== true`,()=>e.assign(r,t===!0?!0:(0,$e._)`${r} > ${t} ? ${r} : ${t}`)),mergeValues:(e,t)=>e===!0?!0:Math.max(e,t),resultToName:(e,t)=>e.var("items",t)})};function Mw(e,t){if(t===!0)return e.var("props",!0);let r=e.var("props",(0,$e._)`{}`);return t!==void 0&&Fp(e,r,t),r}se.evaluatedPropsToName=Mw;function Fp(e,t,r){Object.keys(r).forEach(n=>e.assign((0,$e._)`${t}${(0,$e.getProperty)(n)}`,!0))}se.setEvaluated=Fp;var Rw={};function MC(e,t){return e.scopeValue("func",{ref:t,code:Rw[t.code]||(Rw[t.code]=new AC._Code(t.code))})}se.useFunc=MC;var Gp;(function(e){e[e.Num=0]="Num",e[e.Str=1]="Str"})(Gp||(se.Type=Gp={}));function DC(e,t,r){if(e instanceof $e.Name){let n=t===Gp.Num;return r?n?(0,$e._)`"[" + ${e} + "]"`:(0,$e._)`"['" + ${e} + "']"`:n?(0,$e._)`"/" + ${e}`:(0,$e._)`"/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,$e.getProperty)(e).toString():"/"+Zp(e)}se.getErrorPath=DC;function Dw(e,t,r=e.opts.strictSchema){if(r){if(t=`strict mode: ${t}`,r===!0)throw new Error(t);e.self.logger.warn(t)}}se.checkStrictMode=Dw});var yn=z(qp=>{"use strict";Object.defineProperty(qp,"__esModule",{value:!0});var $t=ie(),GC={data:new $t.Name("data"),valCxt:new $t.Name("valCxt"),instancePath:new $t.Name("instancePath"),parentData:new $t.Name("parentData"),parentDataProperty:new $t.Name("parentDataProperty"),rootData:new $t.Name("rootData"),dynamicAnchors:new $t.Name("dynamicAnchors"),vErrors:new $t.Name("vErrors"),errors:new $t.Name("errors"),this:new $t.Name("this"),self:new $t.Name("self"),scope:new $t.Name("scope"),json:new $t.Name("json"),jsonPos:new $t.Name("jsonPos"),jsonLen:new $t.Name("jsonLen"),jsonPart:new $t.Name("jsonPart")};qp.default=GC});var ua=z(Et=>{"use strict";Object.defineProperty(Et,"__esModule",{value:!0});Et.extendErrors=Et.resetErrorsCount=Et.reportExtraError=Et.reportError=Et.keyword$DataError=Et.keywordError=void 0;var pe=ie(),Al=_e(),Nt=yn();Et.keywordError={message:({keyword:e})=>(0,pe.str)`must pass "${e}" keyword validation`};Et.keyword$DataError={message:({keyword:e,schemaType:t})=>t?(0,pe.str)`"${e}" keyword must be ${t} ($data)`:(0,pe.str)`"${e}" keyword is invalid ($data)`};function ZC(e,t=Et.keywordError,r,n){let{it:i}=e,{gen:o,compositeRule:s,allErrors:a}=i,u=Fw(e,t,r);n??(s||a)?Gw(o,u):Zw(i,(0,pe._)`[${u}]`)}Et.reportError=ZC;function FC(e,t=Et.keywordError,r){let{it:n}=e,{gen:i,compositeRule:o,allErrors:s}=n,a=Fw(e,t,r);Gw(i,a),o||s||Zw(n,Nt.default.vErrors)}Et.reportExtraError=FC;function qC(e,t){e.assign(Nt.default.errors,t),e.if((0,pe._)`${Nt.default.vErrors} !== null`,()=>e.if(t,()=>e.assign((0,pe._)`${Nt.default.vErrors}.length`,t),()=>e.assign(Nt.default.vErrors,null)))}Et.resetErrorsCount=qC;function LC({gen:e,keyword:t,schemaValue:r,data:n,errsCount:i,it:o}){if(i===void 0)throw new Error("ajv implementation error");let s=e.name("err");e.forRange("i",i,Nt.default.errors,a=>{e.const(s,(0,pe._)`${Nt.default.vErrors}[${a}]`),e.if((0,pe._)`${s}.instancePath === undefined`,()=>e.assign((0,pe._)`${s}.instancePath`,(0,pe.strConcat)(Nt.default.instancePath,o.errorPath))),e.assign((0,pe._)`${s}.schemaPath`,(0,pe.str)`${o.errSchemaPath}/${t}`),o.opts.verbose&&(e.assign((0,pe._)`${s}.schema`,r),e.assign((0,pe._)`${s}.data`,n))})}Et.extendErrors=LC;function Gw(e,t){let r=e.const("err",t);e.if((0,pe._)`${Nt.default.vErrors} === null`,()=>e.assign(Nt.default.vErrors,(0,pe._)`[${r}]`),(0,pe._)`${Nt.default.vErrors}.push(${r})`),e.code((0,pe._)`${Nt.default.errors}++`)}function Zw(e,t){let{gen:r,validateName:n,schemaEnv:i}=e;i.$async?r.throw((0,pe._)`new ${e.ValidationError}(${t})`):(r.assign((0,pe._)`${n}.errors`,t),r.return(!1))}var Wi={keyword:new pe.Name("keyword"),schemaPath:new pe.Name("schemaPath"),params:new pe.Name("params"),propertyName:new pe.Name("propertyName"),message:new pe.Name("message"),schema:new pe.Name("schema"),parentSchema:new pe.Name("parentSchema")};function Fw(e,t,r){let{createErrors:n}=e.it;return n===!1?(0,pe._)`{}`:UC(e,t,r)}function UC(e,t,r={}){let{gen:n,it:i}=e,o=[VC(i,r),BC(e,r)];return WC(e,t,o),n.object(...o)}function VC({errorPath:e},{instancePath:t}){let r=t?(0,pe.str)`${e}${(0,Al.getErrorPath)(t,Al.Type.Str)}`:e;return[Nt.default.instancePath,(0,pe.strConcat)(Nt.default.instancePath,r)]}function BC({keyword:e,it:{errSchemaPath:t}},{schemaPath:r,parentSchema:n}){let i=n?t:(0,pe.str)`${t}/${e}`;return r&&(i=(0,pe.str)`${i}${(0,Al.getErrorPath)(r,Al.Type.Str)}`),[Wi.schemaPath,i]}function WC(e,{params:t,message:r},n){let{keyword:i,data:o,schemaValue:s,it:a}=e,{opts:u,propertyName:c,topSchemaRef:l,schemaPath:d}=a;n.push([Wi.keyword,i],[Wi.params,typeof t=="function"?t(e):t||(0,pe._)`{}`]),u.messages&&n.push([Wi.message,typeof r=="function"?r(e):r]),u.verbose&&n.push([Wi.schema,s],[Wi.parentSchema,(0,pe._)`${l}${d}`],[Nt.default.data,o]),c&&n.push([Wi.propertyName,c])}});var Lw=z(qo=>{"use strict";Object.defineProperty(qo,"__esModule",{value:!0});qo.boolOrEmptySchema=qo.topBoolOrEmptySchema=void 0;var JC=ua(),HC=ie(),KC=yn(),QC={message:"boolean schema is false"};function XC(e){let{gen:t,schema:r,validateName:n}=e;r===!1?qw(e,!1):typeof r=="object"&&r.$async===!0?t.return(KC.default.data):(t.assign((0,HC._)`${n}.errors`,null),t.return(!0))}qo.topBoolOrEmptySchema=XC;function YC(e,t){let{gen:r,schema:n}=e;n===!1?(r.var(t,!1),qw(e)):r.var(t,!0)}qo.boolOrEmptySchema=YC;function qw(e,t){let{gen:r,data:n}=e,i={gen:r,keyword:"false schema",data:n,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:e};(0,JC.reportError)(i,QC,void 0,t)}});var Lp=z(Lo=>{"use strict";Object.defineProperty(Lo,"__esModule",{value:!0});Lo.getRules=Lo.isJSONType=void 0;var eR=["string","number","integer","boolean","null","object","array"],tR=new Set(eR);function rR(e){return typeof e=="string"&&tR.has(e)}Lo.isJSONType=rR;function nR(){let e={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...e,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},e.number,e.string,e.array,e.object],post:{rules:[]},all:{},keywords:{}}}Lo.getRules=nR});var Up=z(Wn=>{"use strict";Object.defineProperty(Wn,"__esModule",{value:!0});Wn.shouldUseRule=Wn.shouldUseGroup=Wn.schemaHasRulesForType=void 0;function iR({schema:e,self:t},r){let n=t.RULES.types[r];return n&&n!==!0&&Uw(e,n)}Wn.schemaHasRulesForType=iR;function Uw(e,t){return t.rules.some(r=>Vw(e,r))}Wn.shouldUseGroup=Uw;function Vw(e,t){var r;return e[t.keyword]!==void 0||((r=t.definition.implements)===null||r===void 0?void 0:r.some(n=>e[n]!==void 0))}Wn.shouldUseRule=Vw});var da=z(zt=>{"use strict";Object.defineProperty(zt,"__esModule",{value:!0});zt.reportTypeError=zt.checkDataTypes=zt.checkDataType=zt.coerceAndCheckDataType=zt.getJSONTypes=zt.getSchemaTypes=zt.DataType=void 0;var oR=Lp(),sR=Up(),aR=ua(),te=ie(),Bw=_e(),Uo;(function(e){e[e.Correct=0]="Correct",e[e.Wrong=1]="Wrong"})(Uo||(zt.DataType=Uo={}));function cR(e){let t=Ww(e.type);if(t.includes("null")){if(e.nullable===!1)throw new Error("type: null contradicts nullable: false")}else{if(!t.length&&e.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');e.nullable===!0&&t.push("null")}return t}zt.getSchemaTypes=cR;function Ww(e){let t=Array.isArray(e)?e:e?[e]:[];if(t.every(oR.isJSONType))return t;throw new Error("type must be JSONType or JSONType[]: "+t.join(","))}zt.getJSONTypes=Ww;function lR(e,t){let{gen:r,data:n,opts:i}=e,o=uR(t,i.coerceTypes),s=t.length>0&&!(o.length===0&&t.length===1&&(0,sR.schemaHasRulesForType)(e,t[0]));if(s){let a=Bp(t,n,i.strictNumbers,Uo.Wrong);r.if(a,()=>{o.length?dR(e,t,o):Wp(e)})}return s}zt.coerceAndCheckDataType=lR;var Jw=new Set(["string","number","integer","boolean","null"]);function uR(e,t){return t?e.filter(r=>Jw.has(r)||t==="array"&&r==="array"):[]}function dR(e,t,r){let{gen:n,data:i,opts:o}=e,s=n.let("dataType",(0,te._)`typeof ${i}`),a=n.let("coerced",(0,te._)`undefined`);o.coerceTypes==="array"&&n.if((0,te._)`${s} == 'object' && Array.isArray(${i}) && ${i}.length == 1`,()=>n.assign(i,(0,te._)`${i}[0]`).assign(s,(0,te._)`typeof ${i}`).if(Bp(t,i,o.strictNumbers),()=>n.assign(a,i))),n.if((0,te._)`${a} !== undefined`);for(let c of r)(Jw.has(c)||c==="array"&&o.coerceTypes==="array")&&u(c);n.else(),Wp(e),n.endIf(),n.if((0,te._)`${a} !== undefined`,()=>{n.assign(i,a),fR(e,a)});function u(c){switch(c){case"string":n.elseIf((0,te._)`${s} == "number" || ${s} == "boolean"`).assign(a,(0,te._)`"" + ${i}`).elseIf((0,te._)`${i} === null`).assign(a,(0,te._)`""`);return;case"number":n.elseIf((0,te._)`${s} == "boolean" || ${i} === null
6
6
  || (${s} == "string" && ${i} && ${i} == +${i})`).assign(a,(0,te._)`+${i}`);return;case"integer":n.elseIf((0,te._)`${s} === "boolean" || ${i} === null
7
7
  || (${s} === "string" && ${i} && ${i} == +${i} && !(${i} % 1))`).assign(a,(0,te._)`+${i}`);return;case"boolean":n.elseIf((0,te._)`${i} === "false" || ${i} === 0 || ${i} === null`).assign(a,!1).elseIf((0,te._)`${i} === "true" || ${i} === 1`).assign(a,!0);return;case"null":n.elseIf((0,te._)`${i} === "" || ${i} === 0 || ${i} === false`),n.assign(a,null);return;case"array":n.elseIf((0,te._)`${s} === "string" || ${s} === "number"
8
- || ${s} === "boolean" || ${i} === null`).assign(a,(0,te._)`[${i}]`)}}}function uR({gen:e,parentData:t,parentDataProperty:r},n){e.if((0,te._)`${t} !== undefined`,()=>e.assign((0,te._)`${t}[${r}]`,n))}function Vp(e,t,r,n=Uo.Correct){let i=n===Uo.Correct?te.operators.EQ:te.operators.NEQ,o;switch(e){case"null":return(0,te._)`${t} ${i} null`;case"array":o=(0,te._)`Array.isArray(${t})`;break;case"object":o=(0,te._)`${t} && typeof ${t} == "object" && !Array.isArray(${t})`;break;case"integer":o=s((0,te._)`!(${t} % 1) && !isNaN(${t})`);break;case"number":o=s();break;default:return(0,te._)`typeof ${t} ${i} ${e}`}return n===Uo.Correct?o:(0,te.not)(o);function s(a=te.nil){return(0,te.and)((0,te._)`typeof ${t} == "number"`,a,r?(0,te._)`isFinite(${t})`:te.nil)}}zt.checkDataType=Vp;function Bp(e,t,r,n){if(e.length===1)return Vp(e[0],t,r,n);let i,o=(0,Vw.toHash)(e);if(o.array&&o.object){let s=(0,te._)`typeof ${t} != "object"`;i=o.null?s:(0,te._)`!${t} || ${s}`,delete o.null,delete o.array,delete o.object}else i=te.nil;o.number&&delete o.integer;for(let s in o)i=(0,te.and)(i,Vp(s,t,r,n));return i}zt.checkDataTypes=Bp;var dR={message:({schema:e})=>`must be ${e}`,params:({schema:e,schemaValue:t})=>typeof e=="string"?(0,te._)`{type: ${e}}`:(0,te._)`{type: ${t}}`};function Wp(e){let t=fR(e);(0,oR.reportError)(t,dR)}zt.reportTypeError=Wp;function fR(e){let{gen:t,data:r,schema:n}=e,i=(0,Vw.schemaRefOrVal)(e,n,"type");return{gen:t,keyword:"type",data:r,schema:n.type,schemaCode:i,schemaValue:i,parentSchema:n,params:{},it:e}}});var Hw=z(Ol=>{"use strict";Object.defineProperty(Ol,"__esModule",{value:!0});Ol.assignDefaults=void 0;var Vo=ie(),mR=ge();function pR(e,t){let{properties:r,items:n}=e.schema;if(t==="object"&&r)for(let i in r)Jw(e,i,r[i].default);else t==="array"&&Array.isArray(n)&&n.forEach((i,o)=>Jw(e,o,i.default))}Ol.assignDefaults=pR;function Jw(e,t,r){let{gen:n,compositeRule:i,data:o,opts:s}=e;if(r===void 0)return;let a=(0,Vo._)`${o}${(0,Vo.getProperty)(t)}`;if(i){(0,mR.checkStrictMode)(e,`default is ignored for: ${a}`);return}let u=(0,Vo._)`${a} === undefined`;s.useDefaults==="empty"&&(u=(0,Vo._)`${u} || ${a} === null || ${a} === ""`),n.if(u,(0,Vo._)`${a} = ${(0,Vo.stringify)(r)}`)}});var gr=z(Te=>{"use strict";Object.defineProperty(Te,"__esModule",{value:!0});Te.validateUnion=Te.validateArray=Te.usePattern=Te.callValidateCode=Te.schemaProperties=Te.allSchemaProperties=Te.noPropertyInData=Te.propertyInData=Te.isOwnProperty=Te.hasPropFunc=Te.reportMissingProp=Te.checkMissingProp=Te.checkReportMissingProp=void 0;var Ie=ie(),Jp=ge(),Wn=yn(),hR=ge();function gR(e,t){let{gen:r,data:n,it:i}=e;r.if(Kp(r,n,t,i.opts.ownProperties),()=>{e.setParams({missingProperty:(0,Ie._)`${t}`},!0),e.error()})}Te.checkReportMissingProp=gR;function _R({gen:e,data:t,it:{opts:r}},n,i){return(0,Ie.or)(...n.map(o=>(0,Ie.and)(Kp(e,t,o,r.ownProperties),(0,Ie._)`${i} = ${o}`)))}Te.checkMissingProp=_R;function yR(e,t){e.setParams({missingProperty:t},!0),e.error()}Te.reportMissingProp=yR;function Kw(e){return e.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,Ie._)`Object.prototype.hasOwnProperty`})}Te.hasPropFunc=Kw;function Hp(e,t,r){return(0,Ie._)`${Kw(e)}.call(${t}, ${r})`}Te.isOwnProperty=Hp;function vR(e,t,r,n){let i=(0,Ie._)`${t}${(0,Ie.getProperty)(r)} !== undefined`;return n?(0,Ie._)`${i} && ${Hp(e,t,r)}`:i}Te.propertyInData=vR;function Kp(e,t,r,n){let i=(0,Ie._)`${t}${(0,Ie.getProperty)(r)} === undefined`;return n?(0,Ie.or)(i,(0,Ie.not)(Hp(e,t,r))):i}Te.noPropertyInData=Kp;function Qw(e){return e?Object.keys(e).filter(t=>t!=="__proto__"):[]}Te.allSchemaProperties=Qw;function bR(e,t){return Qw(t).filter(r=>!(0,Jp.alwaysValidSchema)(e,t[r]))}Te.schemaProperties=bR;function wR({schemaCode:e,data:t,it:{gen:r,topSchemaRef:n,schemaPath:i,errorPath:o},it:s},a,u,c){let l=c?(0,Ie._)`${e}, ${t}, ${n}${i}`:t,d=[[Wn.default.instancePath,(0,Ie.strConcat)(Wn.default.instancePath,o)],[Wn.default.parentData,s.parentData],[Wn.default.parentDataProperty,s.parentDataProperty],[Wn.default.rootData,Wn.default.rootData]];s.opts.dynamicRef&&d.push([Wn.default.dynamicAnchors,Wn.default.dynamicAnchors]);let p=(0,Ie._)`${l}, ${r.object(...d)}`;return u!==Ie.nil?(0,Ie._)`${a}.call(${u}, ${p})`:(0,Ie._)`${a}(${p})`}Te.callValidateCode=wR;var kR=(0,Ie._)`new RegExp`;function xR({gen:e,it:{opts:t}},r){let n=t.unicodeRegExp?"u":"",{regExp:i}=t.code,o=i(r,n);return e.scopeValue("pattern",{key:o.toString(),ref:o,code:(0,Ie._)`${i.code==="new RegExp"?kR:(0,hR.useFunc)(e,i)}(${r}, ${n})`})}Te.usePattern=xR;function SR(e){let{gen:t,data:r,keyword:n,it:i}=e,o=t.name("valid");if(i.allErrors){let a=t.let("valid",!0);return s(()=>t.assign(a,!1)),a}return t.var(o,!0),s(()=>t.break()),o;function s(a){let u=t.const("len",(0,Ie._)`${r}.length`);t.forRange("i",0,u,c=>{e.subschema({keyword:n,dataProp:c,dataPropType:Jp.Type.Num},o),t.if((0,Ie.not)(o),a)})}}Te.validateArray=SR;function TR(e){let{gen:t,schema:r,keyword:n,it:i}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");if(r.some(u=>(0,Jp.alwaysValidSchema)(i,u))&&!i.opts.unevaluated)return;let s=t.let("valid",!1),a=t.name("_valid");t.block(()=>r.forEach((u,c)=>{let l=e.subschema({keyword:n,schemaProp:c,compositeRule:!0},a);t.assign(s,(0,Ie._)`${s} || ${a}`),e.mergeValidEvaluated(l,a)||t.if((0,Ie.not)(s))})),e.result(s,()=>e.reset(),()=>e.error(!0))}Te.validateUnion=TR});var ek=z(Kr=>{"use strict";Object.defineProperty(Kr,"__esModule",{value:!0});Kr.validateKeywordUsage=Kr.validSchemaType=Kr.funcKeywordCode=Kr.macroKeywordCode=void 0;var Mt=ie(),Wi=yn(),$R=gr(),ER=ua();function zR(e,t){let{gen:r,keyword:n,schema:i,parentSchema:o,it:s}=e,a=t.macro.call(s.self,i,o,s),u=Yw(r,n,a);s.opts.validateSchema!==!1&&s.self.validateSchema(a,!0);let c=r.name("valid");e.subschema({schema:a,schemaPath:Mt.nil,errSchemaPath:`${s.errSchemaPath}/${n}`,topSchemaRef:u,compositeRule:!0},c),e.pass(c,()=>e.error(!0))}Kr.macroKeywordCode=zR;function AR(e,t){var r;let{gen:n,keyword:i,schema:o,parentSchema:s,$data:a,it:u}=e;PR(u,t);let c=!a&&t.compile?t.compile.call(u.self,o,s,u):t.validate,l=Yw(n,i,c),d=n.let("valid");e.block$data(d,p),e.ok((r=t.valid)!==null&&r!==void 0?r:d);function p(){if(t.errors===!1)m(),t.modifying&&Xw(e),g(()=>e.error());else{let y=t.async?f():h();t.modifying&&Xw(e),g(()=>OR(e,y))}}function f(){let y=n.let("ruleErrs",null);return n.try(()=>m((0,Mt._)`await `),v=>n.assign(d,!1).if((0,Mt._)`${v} instanceof ${u.ValidationError}`,()=>n.assign(y,(0,Mt._)`${v}.errors`),()=>n.throw(v))),y}function h(){let y=(0,Mt._)`${l}.errors`;return n.assign(y,null),m(Mt.nil),y}function m(y=t.async?(0,Mt._)`await `:Mt.nil){let v=u.opts.passContext?Wi.default.this:Wi.default.self,b=!("compile"in t&&!a||t.schema===!1);n.assign(d,(0,Mt._)`${y}${(0,$R.callValidateCode)(e,l,v,b)}`,t.modifying)}function g(y){var v;n.if((0,Mt.not)((v=t.valid)!==null&&v!==void 0?v:d),y)}}Kr.funcKeywordCode=AR;function Xw(e){let{gen:t,data:r,it:n}=e;t.if(n.parentData,()=>t.assign(r,(0,Mt._)`${n.parentData}[${n.parentDataProperty}]`))}function OR(e,t){let{gen:r}=e;r.if((0,Mt._)`Array.isArray(${t})`,()=>{r.assign(Wi.default.vErrors,(0,Mt._)`${Wi.default.vErrors} === null ? ${t} : ${Wi.default.vErrors}.concat(${t})`).assign(Wi.default.errors,(0,Mt._)`${Wi.default.vErrors}.length`),(0,ER.extendErrors)(e)},()=>e.error())}function PR({schemaEnv:e},t){if(t.async&&!e.$async)throw new Error("async keyword in sync schema")}function Yw(e,t,r){if(r===void 0)throw new Error(`keyword "${t}" failed to compile`);return e.scopeValue("keyword",typeof r=="function"?{ref:r}:{ref:r,code:(0,Mt.stringify)(r)})}function CR(e,t,r=!1){return!t.length||t.some(n=>n==="array"?Array.isArray(e):n==="object"?e&&typeof e=="object"&&!Array.isArray(e):typeof e==n||r&&typeof e>"u")}Kr.validSchemaType=CR;function RR({schema:e,opts:t,self:r,errSchemaPath:n},i,o){if(Array.isArray(i.keyword)?!i.keyword.includes(o):i.keyword!==o)throw new Error("ajv implementation error");let s=i.dependencies;if(s?.some(a=>!Object.prototype.hasOwnProperty.call(e,a)))throw new Error(`parent schema must have dependencies of ${o}: ${s.join(",")}`);if(i.validateSchema&&!i.validateSchema(e[o])){let u=`keyword "${o}" value is invalid at path "${n}": `+r.errorsText(i.validateSchema.errors);if(t.validateSchema==="log")r.logger.error(u);else throw new Error(u)}}Kr.validateKeywordUsage=RR});var rk=z(Jn=>{"use strict";Object.defineProperty(Jn,"__esModule",{value:!0});Jn.extendSubschemaMode=Jn.extendSubschemaData=Jn.getSubschema=void 0;var Qr=ie(),tk=ge();function IR(e,{keyword:t,schemaProp:r,schema:n,schemaPath:i,errSchemaPath:o,topSchemaRef:s}){if(t!==void 0&&n!==void 0)throw new Error('both "keyword" and "schema" passed, only one allowed');if(t!==void 0){let a=e.schema[t];return r===void 0?{schema:a,schemaPath:(0,Qr._)`${e.schemaPath}${(0,Qr.getProperty)(t)}`,errSchemaPath:`${e.errSchemaPath}/${t}`}:{schema:a[r],schemaPath:(0,Qr._)`${e.schemaPath}${(0,Qr.getProperty)(t)}${(0,Qr.getProperty)(r)}`,errSchemaPath:`${e.errSchemaPath}/${t}/${(0,tk.escapeFragment)(r)}`}}if(n!==void 0){if(i===void 0||o===void 0||s===void 0)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:n,schemaPath:i,topSchemaRef:s,errSchemaPath:o}}throw new Error('either "keyword" or "schema" must be passed')}Jn.getSubschema=IR;function jR(e,t,{dataProp:r,dataPropType:n,data:i,dataTypes:o,propertyName:s}){if(i!==void 0&&r!==void 0)throw new Error('both "data" and "dataProp" passed, only one allowed');let{gen:a}=t;if(r!==void 0){let{errorPath:c,dataPathArr:l,opts:d}=t,p=a.let("data",(0,Qr._)`${t.data}${(0,Qr.getProperty)(r)}`,!0);u(p),e.errorPath=(0,Qr.str)`${c}${(0,tk.getErrorPath)(r,n,d.jsPropertySyntax)}`,e.parentDataProperty=(0,Qr._)`${r}`,e.dataPathArr=[...l,e.parentDataProperty]}if(i!==void 0){let c=i instanceof Qr.Name?i:a.let("data",i,!0);u(c),s!==void 0&&(e.propertyName=s)}o&&(e.dataTypes=o);function u(c){e.data=c,e.dataLevel=t.dataLevel+1,e.dataTypes=[],t.definedProperties=new Set,e.parentData=t.data,e.dataNames=[...t.dataNames,c]}}Jn.extendSubschemaData=jR;function NR(e,{jtdDiscriminator:t,jtdMetadata:r,compositeRule:n,createErrors:i,allErrors:o}){n!==void 0&&(e.compositeRule=n),i!==void 0&&(e.createErrors=i),o!==void 0&&(e.allErrors=o),e.jtdDiscriminator=t,e.jtdMetadata=r}Jn.extendSubschemaMode=NR});var Qp=z((DF,nk)=>{"use strict";nk.exports=function e(t,r){if(t===r)return!0;if(t&&r&&typeof t=="object"&&typeof r=="object"){if(t.constructor!==r.constructor)return!1;var n,i,o;if(Array.isArray(t)){if(n=t.length,n!=r.length)return!1;for(i=n;i--!==0;)if(!e(t[i],r[i]))return!1;return!0}if(t.constructor===RegExp)return t.source===r.source&&t.flags===r.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===r.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===r.toString();if(o=Object.keys(t),n=o.length,n!==Object.keys(r).length)return!1;for(i=n;i--!==0;)if(!Object.prototype.hasOwnProperty.call(r,o[i]))return!1;for(i=n;i--!==0;){var s=o[i];if(!e(t[s],r[s]))return!1}return!0}return t!==t&&r!==r}});var ok=z((GF,ik)=>{"use strict";var Hn=ik.exports=function(e,t,r){typeof t=="function"&&(r=t,t={}),r=t.cb||r;var n=typeof r=="function"?r:r.pre||function(){},i=r.post||function(){};Pl(t,n,i,e,"",e)};Hn.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};Hn.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};Hn.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};Hn.skipKeywords={default:!0,enum:!0,const:!0,required:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0};function Pl(e,t,r,n,i,o,s,a,u,c){if(n&&typeof n=="object"&&!Array.isArray(n)){t(n,i,o,s,a,u,c);for(var l in n){var d=n[l];if(Array.isArray(d)){if(l in Hn.arrayKeywords)for(var p=0;p<d.length;p++)Pl(e,t,r,d[p],i+"/"+l+"/"+p,o,i,l,n,p)}else if(l in Hn.propsKeywords){if(d&&typeof d=="object")for(var f in d)Pl(e,t,r,d[f],i+"/"+l+"/"+MR(f),o,i,l,n,f)}else(l in Hn.keywords||e.allKeys&&!(l in Hn.skipKeywords))&&Pl(e,t,r,d,i+"/"+l,o,i,l,n)}r(n,i,o,s,a,u,c)}}function MR(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}});var fa=z(Jt=>{"use strict";Object.defineProperty(Jt,"__esModule",{value:!0});Jt.getSchemaRefs=Jt.resolveUrl=Jt.normalizeId=Jt._getFullPath=Jt.getFullPath=Jt.inlineRef=void 0;var DR=ge(),GR=Qp(),ZR=ok(),FR=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function qR(e,t=!0){return typeof e=="boolean"?!0:t===!0?!Xp(e):t?sk(e)<=t:!1}Jt.inlineRef=qR;var LR=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function Xp(e){for(let t in e){if(LR.has(t))return!0;let r=e[t];if(Array.isArray(r)&&r.some(Xp)||typeof r=="object"&&Xp(r))return!0}return!1}function sk(e){let t=0;for(let r in e){if(r==="$ref")return 1/0;if(t++,!FR.has(r)&&(typeof e[r]=="object"&&(0,DR.eachItem)(e[r],n=>t+=sk(n)),t===1/0))return 1/0}return t}function ak(e,t="",r){r!==!1&&(t=Bo(t));let n=e.parse(t);return ck(e,n)}Jt.getFullPath=ak;function ck(e,t){return e.serialize(t).split("#")[0]+"#"}Jt._getFullPath=ck;var UR=/#\/?$/;function Bo(e){return e?e.replace(UR,""):""}Jt.normalizeId=Bo;function VR(e,t,r){return r=Bo(r),e.resolve(t,r)}Jt.resolveUrl=VR;var BR=/^[a-z_][-a-z0-9._]*$/i;function WR(e,t){if(typeof e=="boolean")return{};let{schemaId:r,uriResolver:n}=this.opts,i=Bo(e[r]||t),o={"":i},s=ak(n,i,!1),a={},u=new Set;return ZR(e,{allKeys:!0},(d,p,f,h)=>{if(h===void 0)return;let m=s+p,g=o[h];typeof d[r]=="string"&&(g=y.call(this,d[r])),v.call(this,d.$anchor),v.call(this,d.$dynamicAnchor),o[p]=g;function y(b){let w=this.opts.uriResolver.resolve;if(b=Bo(g?w(g,b):b),u.has(b))throw l(b);u.add(b);let S=this.refs[b];return typeof S=="string"&&(S=this.refs[S]),typeof S=="object"?c(d,S.schema,b):b!==Bo(m)&&(b[0]==="#"?(c(d,a[b],b),a[b]=d):this.refs[b]=m),b}function v(b){if(typeof b=="string"){if(!BR.test(b))throw new Error(`invalid anchor "${b}"`);y.call(this,`#${b}`)}}}),a;function c(d,p,f){if(p!==void 0&&!GR(d,p))throw l(f)}function l(d){return new Error(`reference "${d}" resolves to more than one schema`)}}Jt.getSchemaRefs=WR});var ha=z(Kn=>{"use strict";Object.defineProperty(Kn,"__esModule",{value:!0});Kn.getData=Kn.KeywordCxt=Kn.validateFunctionCode=void 0;var mk=qw(),lk=da(),eh=Up(),Cl=da(),JR=Hw(),pa=ek(),Yp=rk(),L=ie(),Q=yn(),HR=fa(),vn=ge(),ma=ua();function KR(e){if(gk(e)&&(_k(e),hk(e))){YR(e);return}pk(e,()=>(0,mk.topBoolOrEmptySchema)(e))}Kn.validateFunctionCode=KR;function pk({gen:e,validateName:t,schema:r,schemaEnv:n,opts:i},o){i.code.es5?e.func(t,(0,L._)`${Q.default.data}, ${Q.default.valCxt}`,n.$async,()=>{e.code((0,L._)`"use strict"; ${uk(r,i)}`),XR(e,i),e.code(o)}):e.func(t,(0,L._)`${Q.default.data}, ${QR(i)}`,n.$async,()=>e.code(uk(r,i)).code(o))}function QR(e){return(0,L._)`{${Q.default.instancePath}="", ${Q.default.parentData}, ${Q.default.parentDataProperty}, ${Q.default.rootData}=${Q.default.data}${e.dynamicRef?(0,L._)`, ${Q.default.dynamicAnchors}={}`:L.nil}}={}`}function XR(e,t){e.if(Q.default.valCxt,()=>{e.var(Q.default.instancePath,(0,L._)`${Q.default.valCxt}.${Q.default.instancePath}`),e.var(Q.default.parentData,(0,L._)`${Q.default.valCxt}.${Q.default.parentData}`),e.var(Q.default.parentDataProperty,(0,L._)`${Q.default.valCxt}.${Q.default.parentDataProperty}`),e.var(Q.default.rootData,(0,L._)`${Q.default.valCxt}.${Q.default.rootData}`),t.dynamicRef&&e.var(Q.default.dynamicAnchors,(0,L._)`${Q.default.valCxt}.${Q.default.dynamicAnchors}`)},()=>{e.var(Q.default.instancePath,(0,L._)`""`),e.var(Q.default.parentData,(0,L._)`undefined`),e.var(Q.default.parentDataProperty,(0,L._)`undefined`),e.var(Q.default.rootData,Q.default.data),t.dynamicRef&&e.var(Q.default.dynamicAnchors,(0,L._)`{}`)})}function YR(e){let{schema:t,opts:r,gen:n}=e;pk(e,()=>{r.$comment&&t.$comment&&vk(e),iI(e),n.let(Q.default.vErrors,null),n.let(Q.default.errors,0),r.unevaluated&&eI(e),yk(e),aI(e)})}function eI(e){let{gen:t,validateName:r}=e;e.evaluated=t.const("evaluated",(0,L._)`${r}.evaluated`),t.if((0,L._)`${e.evaluated}.dynamicProps`,()=>t.assign((0,L._)`${e.evaluated}.props`,(0,L._)`undefined`)),t.if((0,L._)`${e.evaluated}.dynamicItems`,()=>t.assign((0,L._)`${e.evaluated}.items`,(0,L._)`undefined`))}function uk(e,t){let r=typeof e=="object"&&e[t.schemaId];return r&&(t.code.source||t.code.process)?(0,L._)`/*# sourceURL=${r} */`:L.nil}function tI(e,t){if(gk(e)&&(_k(e),hk(e))){rI(e,t);return}(0,mk.boolOrEmptySchema)(e,t)}function hk({schema:e,self:t}){if(typeof e=="boolean")return!e;for(let r in e)if(t.RULES.all[r])return!0;return!1}function gk(e){return typeof e.schema!="boolean"}function rI(e,t){let{schema:r,gen:n,opts:i}=e;i.$comment&&r.$comment&&vk(e),oI(e),sI(e);let o=n.const("_errs",Q.default.errors);yk(e,o),n.var(t,(0,L._)`${o} === ${Q.default.errors}`)}function _k(e){(0,vn.checkUnknownRules)(e),nI(e)}function yk(e,t){if(e.opts.jtd)return dk(e,[],!1,t);let r=(0,lk.getSchemaTypes)(e.schema),n=(0,lk.coerceAndCheckDataType)(e,r);dk(e,r,!n,t)}function nI(e){let{schema:t,errSchemaPath:r,opts:n,self:i}=e;t.$ref&&n.ignoreKeywordsWithRef&&(0,vn.schemaHasRulesButRef)(t,i.RULES)&&i.logger.warn(`$ref: keywords ignored in schema at path "${r}"`)}function iI(e){let{schema:t,opts:r}=e;t.default!==void 0&&r.useDefaults&&r.strictSchema&&(0,vn.checkStrictMode)(e,"default is ignored in the schema root")}function oI(e){let t=e.schema[e.opts.schemaId];t&&(e.baseId=(0,HR.resolveUrl)(e.opts.uriResolver,e.baseId,t))}function sI(e){if(e.schema.$async&&!e.schemaEnv.$async)throw new Error("async schema in sync schema")}function vk({gen:e,schemaEnv:t,schema:r,errSchemaPath:n,opts:i}){let o=r.$comment;if(i.$comment===!0)e.code((0,L._)`${Q.default.self}.logger.log(${o})`);else if(typeof i.$comment=="function"){let s=(0,L.str)`${n}/$comment`,a=e.scopeValue("root",{ref:t.root});e.code((0,L._)`${Q.default.self}.opts.$comment(${o}, ${s}, ${a}.schema)`)}}function aI(e){let{gen:t,schemaEnv:r,validateName:n,ValidationError:i,opts:o}=e;r.$async?t.if((0,L._)`${Q.default.errors} === 0`,()=>t.return(Q.default.data),()=>t.throw((0,L._)`new ${i}(${Q.default.vErrors})`)):(t.assign((0,L._)`${n}.errors`,Q.default.vErrors),o.unevaluated&&cI(e),t.return((0,L._)`${Q.default.errors} === 0`))}function cI({gen:e,evaluated:t,props:r,items:n}){r instanceof L.Name&&e.assign((0,L._)`${t}.props`,r),n instanceof L.Name&&e.assign((0,L._)`${t}.items`,n)}function dk(e,t,r,n){let{gen:i,schema:o,data:s,allErrors:a,opts:u,self:c}=e,{RULES:l}=c;if(o.$ref&&(u.ignoreKeywordsWithRef||!(0,vn.schemaHasRulesButRef)(o,l))){i.block(()=>wk(e,"$ref",l.all.$ref.definition));return}u.jtd||lI(e,t),i.block(()=>{for(let p of l.rules)d(p);d(l.post)});function d(p){(0,eh.shouldUseGroup)(o,p)&&(p.type?(i.if((0,Cl.checkDataType)(p.type,s,u.strictNumbers)),fk(e,p),t.length===1&&t[0]===p.type&&r&&(i.else(),(0,Cl.reportTypeError)(e)),i.endIf()):fk(e,p),a||i.if((0,L._)`${Q.default.errors} === ${n||0}`))}}function fk(e,t){let{gen:r,schema:n,opts:{useDefaults:i}}=e;i&&(0,JR.assignDefaults)(e,t.type),r.block(()=>{for(let o of t.rules)(0,eh.shouldUseRule)(n,o)&&wk(e,o.keyword,o.definition,t.type)})}function lI(e,t){e.schemaEnv.meta||!e.opts.strictTypes||(uI(e,t),e.opts.allowUnionTypes||dI(e,t),fI(e,e.dataTypes))}function uI(e,t){if(t.length){if(!e.dataTypes.length){e.dataTypes=t;return}t.forEach(r=>{bk(e.dataTypes,r)||th(e,`type "${r}" not allowed by context "${e.dataTypes.join(",")}"`)}),pI(e,t)}}function dI(e,t){t.length>1&&!(t.length===2&&t.includes("null"))&&th(e,"use allowUnionTypes to allow union type keyword")}function fI(e,t){let r=e.self.RULES.all;for(let n in r){let i=r[n];if(typeof i=="object"&&(0,eh.shouldUseRule)(e.schema,i)){let{type:o}=i.definition;o.length&&!o.some(s=>mI(t,s))&&th(e,`missing type "${o.join(",")}" for keyword "${n}"`)}}}function mI(e,t){return e.includes(t)||t==="number"&&e.includes("integer")}function bk(e,t){return e.includes(t)||t==="integer"&&e.includes("number")}function pI(e,t){let r=[];for(let n of e.dataTypes)bk(t,n)?r.push(n):t.includes("integer")&&n==="number"&&r.push("integer");e.dataTypes=r}function th(e,t){let r=e.schemaEnv.baseId+e.errSchemaPath;t+=` at "${r}" (strictTypes)`,(0,vn.checkStrictMode)(e,t,e.opts.strictTypes)}var Rl=class{constructor(t,r,n){if((0,pa.validateKeywordUsage)(t,r,n),this.gen=t.gen,this.allErrors=t.allErrors,this.keyword=n,this.data=t.data,this.schema=t.schema[n],this.$data=r.$data&&t.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,vn.schemaRefOrVal)(t,this.schema,n,this.$data),this.schemaType=r.schemaType,this.parentSchema=t.schema,this.params={},this.it=t,this.def=r,this.$data)this.schemaCode=t.gen.const("vSchema",kk(this.$data,t));else if(this.schemaCode=this.schemaValue,!(0,pa.validSchemaType)(this.schema,r.schemaType,r.allowUndefined))throw new Error(`${n} value must be ${JSON.stringify(r.schemaType)}`);("code"in r?r.trackErrors:r.errors!==!1)&&(this.errsCount=t.gen.const("_errs",Q.default.errors))}result(t,r,n){this.failResult((0,L.not)(t),r,n)}failResult(t,r,n){this.gen.if(t),n?n():this.error(),r?(this.gen.else(),r(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(t,r){this.failResult((0,L.not)(t),void 0,r)}fail(t){if(t===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(t),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(t){if(!this.$data)return this.fail(t);let{schemaCode:r}=this;this.fail((0,L._)`${r} !== undefined && (${(0,L.or)(this.invalid$data(),t)})`)}error(t,r,n){if(r){this.setParams(r),this._error(t,n),this.setParams({});return}this._error(t,n)}_error(t,r){(t?ma.reportExtraError:ma.reportError)(this,this.def.error,r)}$dataError(){(0,ma.reportError)(this,this.def.$dataError||ma.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,ma.resetErrorsCount)(this.gen,this.errsCount)}ok(t){this.allErrors||this.gen.if(t)}setParams(t,r){r?Object.assign(this.params,t):this.params=t}block$data(t,r,n=L.nil){this.gen.block(()=>{this.check$data(t,n),r()})}check$data(t=L.nil,r=L.nil){if(!this.$data)return;let{gen:n,schemaCode:i,schemaType:o,def:s}=this;n.if((0,L.or)((0,L._)`${i} === undefined`,r)),t!==L.nil&&n.assign(t,!0),(o.length||s.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),t!==L.nil&&n.assign(t,!1)),n.else()}invalid$data(){let{gen:t,schemaCode:r,schemaType:n,def:i,it:o}=this;return(0,L.or)(s(),a());function s(){if(n.length){if(!(r instanceof L.Name))throw new Error("ajv implementation error");let u=Array.isArray(n)?n:[n];return(0,L._)`${(0,Cl.checkDataTypes)(u,r,o.opts.strictNumbers,Cl.DataType.Wrong)}`}return L.nil}function a(){if(i.validateSchema){let u=t.scopeValue("validate$data",{ref:i.validateSchema});return(0,L._)`!${u}(${r})`}return L.nil}}subschema(t,r){let n=(0,Yp.getSubschema)(this.it,t);(0,Yp.extendSubschemaData)(n,this.it,t),(0,Yp.extendSubschemaMode)(n,t);let i={...this.it,...n,items:void 0,props:void 0};return tI(i,r),i}mergeEvaluated(t,r){let{it:n,gen:i}=this;n.opts.unevaluated&&(n.props!==!0&&t.props!==void 0&&(n.props=vn.mergeEvaluated.props(i,t.props,n.props,r)),n.items!==!0&&t.items!==void 0&&(n.items=vn.mergeEvaluated.items(i,t.items,n.items,r)))}mergeValidEvaluated(t,r){let{it:n,gen:i}=this;if(n.opts.unevaluated&&(n.props!==!0||n.items!==!0))return i.if(r,()=>this.mergeEvaluated(t,L.Name)),!0}};Kn.KeywordCxt=Rl;function wk(e,t,r,n){let i=new Rl(e,r,t);"code"in r?r.code(i,n):i.$data&&r.validate?(0,pa.funcKeywordCode)(i,r):"macro"in r?(0,pa.macroKeywordCode)(i,r):(r.compile||r.validate)&&(0,pa.funcKeywordCode)(i,r)}var hI=/^\/(?:[^~]|~0|~1)*$/,gI=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function kk(e,{dataLevel:t,dataNames:r,dataPathArr:n}){let i,o;if(e==="")return Q.default.rootData;if(e[0]==="/"){if(!hI.test(e))throw new Error(`Invalid JSON-pointer: ${e}`);i=e,o=Q.default.rootData}else{let c=gI.exec(e);if(!c)throw new Error(`Invalid JSON-pointer: ${e}`);let l=+c[1];if(i=c[2],i==="#"){if(l>=t)throw new Error(u("property/index",l));return n[t-l]}if(l>t)throw new Error(u("data",l));if(o=r[t-l],!i)return o}let s=o,a=i.split("/");for(let c of a)c&&(o=(0,L._)`${o}${(0,L.getProperty)((0,vn.unescapeJsonPointer)(c))}`,s=(0,L._)`${s} && ${o}`);return s;function u(c,l){return`Cannot access ${c} ${l} levels up, current level is ${t}`}}Kn.getData=kk});var Il=z(nh=>{"use strict";Object.defineProperty(nh,"__esModule",{value:!0});var rh=class extends Error{constructor(t){super("validation failed"),this.errors=t,this.ajv=this.validation=!0}};nh.default=rh});var ga=z(sh=>{"use strict";Object.defineProperty(sh,"__esModule",{value:!0});var ih=fa(),oh=class extends Error{constructor(t,r,n,i){super(i||`can't resolve reference ${n} from id ${r}`),this.missingRef=(0,ih.resolveUrl)(t,r,n),this.missingSchema=(0,ih.normalizeId)((0,ih.getFullPath)(t,this.missingRef))}};sh.default=oh});var Nl=z(_r=>{"use strict";Object.defineProperty(_r,"__esModule",{value:!0});_r.resolveSchema=_r.getCompilingSchema=_r.resolveRef=_r.compileSchema=_r.SchemaEnv=void 0;var Or=ie(),_I=Il(),Ji=yn(),Pr=fa(),xk=ge(),yI=ha(),Wo=class{constructor(t){var r;this.refs={},this.dynamicAnchors={};let n;typeof t.schema=="object"&&(n=t.schema),this.schema=t.schema,this.schemaId=t.schemaId,this.root=t.root||this,this.baseId=(r=t.baseId)!==null&&r!==void 0?r:(0,Pr.normalizeId)(n?.[t.schemaId||"$id"]),this.schemaPath=t.schemaPath,this.localRefs=t.localRefs,this.meta=t.meta,this.$async=n?.$async,this.refs={}}};_r.SchemaEnv=Wo;function ch(e){let t=Sk.call(this,e);if(t)return t;let r=(0,Pr.getFullPath)(this.opts.uriResolver,e.root.baseId),{es5:n,lines:i}=this.opts.code,{ownProperties:o}=this.opts,s=new Or.CodeGen(this.scope,{es5:n,lines:i,ownProperties:o}),a;e.$async&&(a=s.scopeValue("Error",{ref:_I.default,code:(0,Or._)`require("ajv/dist/runtime/validation_error").default`}));let u=s.scopeName("validate");e.validateName=u;let c={gen:s,allErrors:this.opts.allErrors,data:Ji.default.data,parentData:Ji.default.parentData,parentDataProperty:Ji.default.parentDataProperty,dataNames:[Ji.default.data],dataPathArr:[Or.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:s.scopeValue("schema",this.opts.code.source===!0?{ref:e.schema,code:(0,Or.stringify)(e.schema)}:{ref:e.schema}),validateName:u,ValidationError:a,schema:e.schema,schemaEnv:e,rootId:r,baseId:e.baseId||r,schemaPath:Or.nil,errSchemaPath:e.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,Or._)`""`,opts:this.opts,self:this},l;try{this._compilations.add(e),(0,yI.validateFunctionCode)(c),s.optimize(this.opts.code.optimize);let d=s.toString();l=`${s.scopeRefs(Ji.default.scope)}return ${d}`,this.opts.code.process&&(l=this.opts.code.process(l,e));let f=new Function(`${Ji.default.self}`,`${Ji.default.scope}`,l)(this,this.scope.get());if(this.scope.value(u,{ref:f}),f.errors=null,f.schema=e.schema,f.schemaEnv=e,e.$async&&(f.$async=!0),this.opts.code.source===!0&&(f.source={validateName:u,validateCode:d,scopeValues:s._values}),this.opts.unevaluated){let{props:h,items:m}=c;f.evaluated={props:h instanceof Or.Name?void 0:h,items:m instanceof Or.Name?void 0:m,dynamicProps:h instanceof Or.Name,dynamicItems:m instanceof Or.Name},f.source&&(f.source.evaluated=(0,Or.stringify)(f.evaluated))}return e.validate=f,e}catch(d){throw delete e.validate,delete e.validateName,l&&this.logger.error("Error compiling schema, function code:",l),d}finally{this._compilations.delete(e)}}_r.compileSchema=ch;function vI(e,t,r){var n;r=(0,Pr.resolveUrl)(this.opts.uriResolver,t,r);let i=e.refs[r];if(i)return i;let o=kI.call(this,e,r);if(o===void 0){let s=(n=e.localRefs)===null||n===void 0?void 0:n[r],{schemaId:a}=this.opts;s&&(o=new Wo({schema:s,schemaId:a,root:e,baseId:t}))}if(o!==void 0)return e.refs[r]=bI.call(this,o)}_r.resolveRef=vI;function bI(e){return(0,Pr.inlineRef)(e.schema,this.opts.inlineRefs)?e.schema:e.validate?e:ch.call(this,e)}function Sk(e){for(let t of this._compilations)if(wI(t,e))return t}_r.getCompilingSchema=Sk;function wI(e,t){return e.schema===t.schema&&e.root===t.root&&e.baseId===t.baseId}function kI(e,t){let r;for(;typeof(r=this.refs[t])=="string";)t=r;return r||this.schemas[t]||jl.call(this,e,t)}function jl(e,t){let r=this.opts.uriResolver.parse(t),n=(0,Pr._getFullPath)(this.opts.uriResolver,r),i=(0,Pr.getFullPath)(this.opts.uriResolver,e.baseId,void 0);if(Object.keys(e.schema).length>0&&n===i)return ah.call(this,r,e);let o=(0,Pr.normalizeId)(n),s=this.refs[o]||this.schemas[o];if(typeof s=="string"){let a=jl.call(this,e,s);return typeof a?.schema!="object"?void 0:ah.call(this,r,a)}if(typeof s?.schema=="object"){if(s.validate||ch.call(this,s),o===(0,Pr.normalizeId)(t)){let{schema:a}=s,{schemaId:u}=this.opts,c=a[u];return c&&(i=(0,Pr.resolveUrl)(this.opts.uriResolver,i,c)),new Wo({schema:a,schemaId:u,root:e,baseId:i})}return ah.call(this,r,s)}}_r.resolveSchema=jl;var xI=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function ah(e,{baseId:t,schema:r,root:n}){var i;if(((i=e.fragment)===null||i===void 0?void 0:i[0])!=="/")return;for(let a of e.fragment.slice(1).split("/")){if(typeof r=="boolean")return;let u=r[(0,xk.unescapeFragment)(a)];if(u===void 0)return;r=u;let c=typeof r=="object"&&r[this.opts.schemaId];!xI.has(a)&&c&&(t=(0,Pr.resolveUrl)(this.opts.uriResolver,t,c))}let o;if(typeof r!="boolean"&&r.$ref&&!(0,xk.schemaHasRulesButRef)(r,this.RULES)){let a=(0,Pr.resolveUrl)(this.opts.uriResolver,t,r.$ref);o=jl.call(this,n,a)}let{schemaId:s}=this.opts;if(o=o||new Wo({schema:r,schemaId:s,root:n,baseId:t}),o.schema!==o.root.schema)return o}});var Tk=z((VF,SI)=>{SI.exports={$id:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",description:"Meta-schema for $data reference (JSON AnySchema extension proposal)",type:"object",required:["$data"],properties:{$data:{type:"string",anyOf:[{format:"relative-json-pointer"},{format:"json-pointer"}]}},additionalProperties:!1}});var uh=z((BF,Ak)=>{"use strict";var TI=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),Ek=RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u);function lh(e){let t="",r=0,n=0;for(n=0;n<e.length;n++)if(r=e[n].charCodeAt(0),r!==48){if(!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";t+=e[n];break}for(n+=1;n<e.length;n++){if(r=e[n].charCodeAt(0),!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";t+=e[n]}return t}var $I=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function $k(e){return e.length=0,!0}function EI(e,t,r){if(e.length){let n=lh(e);if(n!=="")t.push(n);else return r.error=!0,!1;e.length=0}return!0}function zI(e){let t=0,r={error:!1,address:"",zone:""},n=[],i=[],o=!1,s=!1,a=EI;for(let u=0;u<e.length;u++){let c=e[u];if(!(c==="["||c==="]"))if(c===":"){if(o===!0&&(s=!0),!a(i,n,r))break;if(++t>7){r.error=!0;break}u>0&&e[u-1]===":"&&(o=!0),n.push(":");continue}else if(c==="%"){if(!a(i,n,r))break;a=$k}else{i.push(c);continue}}return i.length&&(a===$k?r.zone=i.join(""):s?n.push(i.join("")):n.push(lh(i))),r.address=n.join(""),r}function zk(e){if(AI(e,":")<2)return{host:e,isIPV6:!1};let t=zI(e);if(t.error)return{host:e,isIPV6:!1};{let r=t.address,n=t.address;return t.zone&&(r+="%"+t.zone,n+="%25"+t.zone),{host:r,isIPV6:!0,escapedHost:n}}}function AI(e,t){let r=0;for(let n=0;n<e.length;n++)e[n]===t&&r++;return r}function OI(e){let t=e,r=[],n=-1,i=0;for(;i=t.length;){if(i===1){if(t===".")break;if(t==="/"){r.push("/");break}else{r.push(t);break}}else if(i===2){if(t[0]==="."){if(t[1]===".")break;if(t[1]==="/"){t=t.slice(2);continue}}else if(t[0]==="/"&&(t[1]==="."||t[1]==="/")){r.push("/");break}}else if(i===3&&t==="/.."){r.length!==0&&r.pop(),r.push("/");break}if(t[0]==="."){if(t[1]==="."){if(t[2]==="/"){t=t.slice(3);continue}}else if(t[1]==="/"){t=t.slice(2);continue}}else if(t[0]==="/"&&t[1]==="."){if(t[2]==="/"){t=t.slice(2);continue}else if(t[2]==="."&&t[3]==="/"){t=t.slice(3),r.length!==0&&r.pop();continue}}if((n=t.indexOf("/",1))===-1){r.push(t);break}else r.push(t.slice(0,n)),t=t.slice(n)}return r.join("")}function PI(e,t){let r=t!==!0?escape:unescape;return e.scheme!==void 0&&(e.scheme=r(e.scheme)),e.userinfo!==void 0&&(e.userinfo=r(e.userinfo)),e.host!==void 0&&(e.host=r(e.host)),e.path!==void 0&&(e.path=r(e.path)),e.query!==void 0&&(e.query=r(e.query)),e.fragment!==void 0&&(e.fragment=r(e.fragment)),e}function CI(e){let t=[];if(e.userinfo!==void 0&&(t.push(e.userinfo),t.push("@")),e.host!==void 0){let r=unescape(e.host);if(!Ek(r)){let n=zk(r);n.isIPV6===!0?r=`[${n.escapedHost}]`:r=e.host}t.push(r)}return(typeof e.port=="number"||typeof e.port=="string")&&(t.push(":"),t.push(String(e.port))),t.length?t.join(""):void 0}Ak.exports={nonSimpleDomain:$I,recomposeAuthority:CI,normalizeComponentEncoding:PI,removeDotSegments:OI,isIPv4:Ek,isUUID:TI,normalizeIPv6:zk,stringArrayToHexStripped:lh}});var Ik=z((WF,Rk)=>{"use strict";var{isUUID:RI}=uh(),II=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu,jI=["http","https","ws","wss","urn","urn:uuid"];function NI(e){return jI.indexOf(e)!==-1}function dh(e){return e.secure===!0?!0:e.secure===!1?!1:e.scheme?e.scheme.length===3&&(e.scheme[0]==="w"||e.scheme[0]==="W")&&(e.scheme[1]==="s"||e.scheme[1]==="S")&&(e.scheme[2]==="s"||e.scheme[2]==="S"):!1}function Ok(e){return e.host||(e.error=e.error||"HTTP URIs must have a host."),e}function Pk(e){let t=String(e.scheme).toLowerCase()==="https";return(e.port===(t?443:80)||e.port==="")&&(e.port=void 0),e.path||(e.path="/"),e}function MI(e){return e.secure=dh(e),e.resourceName=(e.path||"/")+(e.query?"?"+e.query:""),e.path=void 0,e.query=void 0,e}function DI(e){if((e.port===(dh(e)?443:80)||e.port==="")&&(e.port=void 0),typeof e.secure=="boolean"&&(e.scheme=e.secure?"wss":"ws",e.secure=void 0),e.resourceName){let[t,r]=e.resourceName.split("?");e.path=t&&t!=="/"?t:void 0,e.query=r,e.resourceName=void 0}return e.fragment=void 0,e}function GI(e,t){if(!e.path)return e.error="URN can not be parsed",e;let r=e.path.match(II);if(r){let n=t.scheme||e.scheme||"urn";e.nid=r[1].toLowerCase(),e.nss=r[2];let i=`${n}:${t.nid||e.nid}`,o=fh(i);e.path=void 0,o&&(e=o.parse(e,t))}else e.error=e.error||"URN can not be parsed.";return e}function ZI(e,t){if(e.nid===void 0)throw new Error("URN without nid cannot be serialized");let r=t.scheme||e.scheme||"urn",n=e.nid.toLowerCase(),i=`${r}:${t.nid||n}`,o=fh(i);o&&(e=o.serialize(e,t));let s=e,a=e.nss;return s.path=`${n||t.nid}:${a}`,t.skipEscape=!0,s}function FI(e,t){let r=e;return r.uuid=r.nss,r.nss=void 0,!t.tolerant&&(!r.uuid||!RI(r.uuid))&&(r.error=r.error||"UUID is not valid."),r}function qI(e){let t=e;return t.nss=(e.uuid||"").toLowerCase(),t}var Ck={scheme:"http",domainHost:!0,parse:Ok,serialize:Pk},LI={scheme:"https",domainHost:Ck.domainHost,parse:Ok,serialize:Pk},Ml={scheme:"ws",domainHost:!0,parse:MI,serialize:DI},UI={scheme:"wss",domainHost:Ml.domainHost,parse:Ml.parse,serialize:Ml.serialize},VI={scheme:"urn",parse:GI,serialize:ZI,skipNormalize:!0},BI={scheme:"urn:uuid",parse:FI,serialize:qI,skipNormalize:!0},Dl={http:Ck,https:LI,ws:Ml,wss:UI,urn:VI,"urn:uuid":BI};Object.setPrototypeOf(Dl,null);function fh(e){return e&&(Dl[e]||Dl[e.toLowerCase()])||void 0}Rk.exports={wsIsSecure:dh,SCHEMES:Dl,isValidSchemeName:NI,getSchemeHandler:fh}});var Mk=z((JF,Zl)=>{"use strict";var{normalizeIPv6:WI,removeDotSegments:_a,recomposeAuthority:JI,normalizeComponentEncoding:Gl,isIPv4:HI,nonSimpleDomain:KI}=uh(),{SCHEMES:QI,getSchemeHandler:jk}=Ik();function XI(e,t){return typeof e=="string"?e=Xr(bn(e,t),t):typeof e=="object"&&(e=bn(Xr(e,t),t)),e}function YI(e,t,r){let n=r?Object.assign({scheme:"null"},r):{scheme:"null"},i=Nk(bn(e,n),bn(t,n),n,!0);return n.skipEscape=!0,Xr(i,n)}function Nk(e,t,r,n){let i={};return n||(e=bn(Xr(e,r),r),t=bn(Xr(t,r),r)),r=r||{},!r.tolerant&&t.scheme?(i.scheme=t.scheme,i.userinfo=t.userinfo,i.host=t.host,i.port=t.port,i.path=_a(t.path||""),i.query=t.query):(t.userinfo!==void 0||t.host!==void 0||t.port!==void 0?(i.userinfo=t.userinfo,i.host=t.host,i.port=t.port,i.path=_a(t.path||""),i.query=t.query):(t.path?(t.path[0]==="/"?i.path=_a(t.path):((e.userinfo!==void 0||e.host!==void 0||e.port!==void 0)&&!e.path?i.path="/"+t.path:e.path?i.path=e.path.slice(0,e.path.lastIndexOf("/")+1)+t.path:i.path=t.path,i.path=_a(i.path)),i.query=t.query):(i.path=e.path,t.query!==void 0?i.query=t.query:i.query=e.query),i.userinfo=e.userinfo,i.host=e.host,i.port=e.port),i.scheme=e.scheme),i.fragment=t.fragment,i}function ej(e,t,r){return typeof e=="string"?(e=unescape(e),e=Xr(Gl(bn(e,r),!0),{...r,skipEscape:!0})):typeof e=="object"&&(e=Xr(Gl(e,!0),{...r,skipEscape:!0})),typeof t=="string"?(t=unescape(t),t=Xr(Gl(bn(t,r),!0),{...r,skipEscape:!0})):typeof t=="object"&&(t=Xr(Gl(t,!0),{...r,skipEscape:!0})),e.toLowerCase()===t.toLowerCase()}function Xr(e,t){let r={host:e.host,scheme:e.scheme,userinfo:e.userinfo,port:e.port,path:e.path,query:e.query,nid:e.nid,nss:e.nss,uuid:e.uuid,fragment:e.fragment,reference:e.reference,resourceName:e.resourceName,secure:e.secure,error:""},n=Object.assign({},t),i=[],o=jk(n.scheme||r.scheme);o&&o.serialize&&o.serialize(r,n),r.path!==void 0&&(n.skipEscape?r.path=unescape(r.path):(r.path=escape(r.path),r.scheme!==void 0&&(r.path=r.path.split("%3A").join(":")))),n.reference!=="suffix"&&r.scheme&&i.push(r.scheme,":");let s=JI(r);if(s!==void 0&&(n.reference!=="suffix"&&i.push("//"),i.push(s),r.path&&r.path[0]!=="/"&&i.push("/")),r.path!==void 0){let a=r.path;!n.absolutePath&&(!o||!o.absolutePath)&&(a=_a(a)),s===void 0&&a[0]==="/"&&a[1]==="/"&&(a="/%2F"+a.slice(2)),i.push(a)}return r.query!==void 0&&i.push("?",r.query),r.fragment!==void 0&&i.push("#",r.fragment),i.join("")}var tj=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;function bn(e,t){let r=Object.assign({},t),n={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0},i=!1;r.reference==="suffix"&&(r.scheme?e=r.scheme+":"+e:e="//"+e);let o=e.match(tj);if(o){if(n.scheme=o[1],n.userinfo=o[3],n.host=o[4],n.port=parseInt(o[5],10),n.path=o[6]||"",n.query=o[7],n.fragment=o[8],isNaN(n.port)&&(n.port=o[5]),n.host)if(HI(n.host)===!1){let u=WI(n.host);n.host=u.host.toLowerCase(),i=u.isIPV6}else i=!0;n.scheme===void 0&&n.userinfo===void 0&&n.host===void 0&&n.port===void 0&&n.query===void 0&&!n.path?n.reference="same-document":n.scheme===void 0?n.reference="relative":n.fragment===void 0?n.reference="absolute":n.reference="uri",r.reference&&r.reference!=="suffix"&&r.reference!==n.reference&&(n.error=n.error||"URI is not a "+r.reference+" reference.");let s=jk(r.scheme||n.scheme);if(!r.unicodeSupport&&(!s||!s.unicodeSupport)&&n.host&&(r.domainHost||s&&s.domainHost)&&i===!1&&KI(n.host))try{n.host=URL.domainToASCII(n.host.toLowerCase())}catch(a){n.error=n.error||"Host's domain name can not be converted to ASCII: "+a}(!s||s&&!s.skipNormalize)&&(e.indexOf("%")!==-1&&(n.scheme!==void 0&&(n.scheme=unescape(n.scheme)),n.host!==void 0&&(n.host=unescape(n.host))),n.path&&(n.path=escape(unescape(n.path))),n.fragment&&(n.fragment=encodeURI(decodeURIComponent(n.fragment)))),s&&s.parse&&s.parse(n,r)}else n.error=n.error||"URI can not be parsed.";return n}var mh={SCHEMES:QI,normalize:XI,resolve:YI,resolveComponent:Nk,equal:ej,serialize:Xr,parse:bn};Zl.exports=mh;Zl.exports.default=mh;Zl.exports.fastUri=mh});var Gk=z(ph=>{"use strict";Object.defineProperty(ph,"__esModule",{value:!0});var Dk=Mk();Dk.code='require("ajv/dist/runtime/uri").default';ph.default=Dk});var Wk=z(wt=>{"use strict";Object.defineProperty(wt,"__esModule",{value:!0});wt.CodeGen=wt.Name=wt.nil=wt.stringify=wt.str=wt._=wt.KeywordCxt=void 0;var rj=ha();Object.defineProperty(wt,"KeywordCxt",{enumerable:!0,get:function(){return rj.KeywordCxt}});var Jo=ie();Object.defineProperty(wt,"_",{enumerable:!0,get:function(){return Jo._}});Object.defineProperty(wt,"str",{enumerable:!0,get:function(){return Jo.str}});Object.defineProperty(wt,"stringify",{enumerable:!0,get:function(){return Jo.stringify}});Object.defineProperty(wt,"nil",{enumerable:!0,get:function(){return Jo.nil}});Object.defineProperty(wt,"Name",{enumerable:!0,get:function(){return Jo.Name}});Object.defineProperty(wt,"CodeGen",{enumerable:!0,get:function(){return Jo.CodeGen}});var nj=Il(),Uk=ga(),ij=Lp(),ya=Nl(),oj=ie(),va=fa(),Fl=da(),gh=ge(),Zk=Tk(),sj=Gk(),Vk=(e,t)=>new RegExp(e,t);Vk.code="new RegExp";var aj=["removeAdditional","useDefaults","coerceTypes"],cj=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),lj={errorDataPath:"",format:"`validateFormats: false` can be used instead.",nullable:'"nullable" keyword is supported by default.',jsonPointers:"Deprecated jsPropertySyntax can be used instead.",extendRefs:"Deprecated ignoreKeywordsWithRef can be used instead.",missingRefs:"Pass empty schema with $id that should be ignored to ajv.addSchema.",processCode:"Use option `code: {process: (code, schemaEnv: object) => string}`",sourceCode:"Use option `code: {source: true}`",strictDefaults:"It is default now, see option `strict`.",strictKeywords:"It is default now, see option `strict`.",uniqueItems:'"uniqueItems" keyword is always validated.',unknownFormats:"Disable strict mode or pass `true` to `ajv.addFormat` (or `formats` option).",cache:"Map is used as cache, schema object as key.",serialize:"Map is used as cache, schema object as key.",ajvErrors:"It is default now."},uj={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},Fk=200;function dj(e){var t,r,n,i,o,s,a,u,c,l,d,p,f,h,m,g,y,v,b,w,S,R,X,be,D;let I=e.strict,B=(t=e.code)===null||t===void 0?void 0:t.optimize,re=B===!0||B===void 0?1:B||0,le=(n=(r=e.code)===null||r===void 0?void 0:r.regExp)!==null&&n!==void 0?n:Vk,j=(i=e.uriResolver)!==null&&i!==void 0?i:sj.default;return{strictSchema:(s=(o=e.strictSchema)!==null&&o!==void 0?o:I)!==null&&s!==void 0?s:!0,strictNumbers:(u=(a=e.strictNumbers)!==null&&a!==void 0?a:I)!==null&&u!==void 0?u:!0,strictTypes:(l=(c=e.strictTypes)!==null&&c!==void 0?c:I)!==null&&l!==void 0?l:"log",strictTuples:(p=(d=e.strictTuples)!==null&&d!==void 0?d:I)!==null&&p!==void 0?p:"log",strictRequired:(h=(f=e.strictRequired)!==null&&f!==void 0?f:I)!==null&&h!==void 0?h:!1,code:e.code?{...e.code,optimize:re,regExp:le}:{optimize:re,regExp:le},loopRequired:(m=e.loopRequired)!==null&&m!==void 0?m:Fk,loopEnum:(g=e.loopEnum)!==null&&g!==void 0?g:Fk,meta:(y=e.meta)!==null&&y!==void 0?y:!0,messages:(v=e.messages)!==null&&v!==void 0?v:!0,inlineRefs:(b=e.inlineRefs)!==null&&b!==void 0?b:!0,schemaId:(w=e.schemaId)!==null&&w!==void 0?w:"$id",addUsedSchema:(S=e.addUsedSchema)!==null&&S!==void 0?S:!0,validateSchema:(R=e.validateSchema)!==null&&R!==void 0?R:!0,validateFormats:(X=e.validateFormats)!==null&&X!==void 0?X:!0,unicodeRegExp:(be=e.unicodeRegExp)!==null&&be!==void 0?be:!0,int32range:(D=e.int32range)!==null&&D!==void 0?D:!0,uriResolver:j}}var ba=class{constructor(t={}){this.schemas={},this.refs={},this.formats={},this._compilations=new Set,this._loading={},this._cache=new Map,t=this.opts={...t,...dj(t)};let{es5:r,lines:n}=this.opts.code;this.scope=new oj.ValueScope({scope:{},prefixes:cj,es5:r,lines:n}),this.logger=_j(t.logger);let i=t.validateFormats;t.validateFormats=!1,this.RULES=(0,ij.getRules)(),qk.call(this,lj,t,"NOT SUPPORTED"),qk.call(this,uj,t,"DEPRECATED","warn"),this._metaOpts=hj.call(this),t.formats&&mj.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),t.keywords&&pj.call(this,t.keywords),typeof t.meta=="object"&&this.addMetaSchema(t.meta),fj.call(this),t.validateFormats=i}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){let{$data:t,meta:r,schemaId:n}=this.opts,i=Zk;n==="id"&&(i={...Zk},i.id=i.$id,delete i.$id),r&&t&&this.addMetaSchema(i,i[n],!1)}defaultMeta(){let{meta:t,schemaId:r}=this.opts;return this.opts.defaultMeta=typeof t=="object"?t[r]||t:void 0}validate(t,r){let n;if(typeof t=="string"){if(n=this.getSchema(t),!n)throw new Error(`no schema with key or ref "${t}"`)}else n=this.compile(t);let i=n(r);return"$async"in n||(this.errors=n.errors),i}compile(t,r){let n=this._addSchema(t,r);return n.validate||this._compileSchemaEnv(n)}compileAsync(t,r){if(typeof this.opts.loadSchema!="function")throw new Error("options.loadSchema should be a function");let{loadSchema:n}=this.opts;return i.call(this,t,r);async function i(l,d){await o.call(this,l.$schema);let p=this._addSchema(l,d);return p.validate||s.call(this,p)}async function o(l){l&&!this.getSchema(l)&&await i.call(this,{$ref:l},!0)}async function s(l){try{return this._compileSchemaEnv(l)}catch(d){if(!(d instanceof Uk.default))throw d;return a.call(this,d),await u.call(this,d.missingSchema),s.call(this,l)}}function a({missingSchema:l,missingRef:d}){if(this.refs[l])throw new Error(`AnySchema ${l} is loaded but ${d} cannot be resolved`)}async function u(l){let d=await c.call(this,l);this.refs[l]||await o.call(this,d.$schema),this.refs[l]||this.addSchema(d,l,r)}async function c(l){let d=this._loading[l];if(d)return d;try{return await(this._loading[l]=n(l))}finally{delete this._loading[l]}}}addSchema(t,r,n,i=this.opts.validateSchema){if(Array.isArray(t)){for(let s of t)this.addSchema(s,void 0,n,i);return this}let o;if(typeof t=="object"){let{schemaId:s}=this.opts;if(o=t[s],o!==void 0&&typeof o!="string")throw new Error(`schema ${s} must be string`)}return r=(0,va.normalizeId)(r||o),this._checkUnique(r),this.schemas[r]=this._addSchema(t,n,r,i,!0),this}addMetaSchema(t,r,n=this.opts.validateSchema){return this.addSchema(t,r,!0,n),this}validateSchema(t,r){if(typeof t=="boolean")return!0;let n;if(n=t.$schema,n!==void 0&&typeof n!="string")throw new Error("$schema must be a string");if(n=n||this.opts.defaultMeta||this.defaultMeta(),!n)return this.logger.warn("meta-schema not available"),this.errors=null,!0;let i=this.validate(n,t);if(!i&&r){let o="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(o);else throw new Error(o)}return i}getSchema(t){let r;for(;typeof(r=Lk.call(this,t))=="string";)t=r;if(r===void 0){let{schemaId:n}=this.opts,i=new ya.SchemaEnv({schema:{},schemaId:n});if(r=ya.resolveSchema.call(this,i,t),!r)return;this.refs[t]=r}return r.validate||this._compileSchemaEnv(r)}removeSchema(t){if(t instanceof RegExp)return this._removeAllSchemas(this.schemas,t),this._removeAllSchemas(this.refs,t),this;switch(typeof t){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{let r=Lk.call(this,t);return typeof r=="object"&&this._cache.delete(r.schema),delete this.schemas[t],delete this.refs[t],this}case"object":{let r=t;this._cache.delete(r);let n=t[this.opts.schemaId];return n&&(n=(0,va.normalizeId)(n),delete this.schemas[n],delete this.refs[n]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(t){for(let r of t)this.addKeyword(r);return this}addKeyword(t,r){let n;if(typeof t=="string")n=t,typeof r=="object"&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),r.keyword=n);else if(typeof t=="object"&&r===void 0){if(r=t,n=r.keyword,Array.isArray(n)&&!n.length)throw new Error("addKeywords: keyword must be string or non-empty array")}else throw new Error("invalid addKeywords parameters");if(vj.call(this,n,r),!r)return(0,gh.eachItem)(n,o=>hh.call(this,o)),this;wj.call(this,r);let i={...r,type:(0,Fl.getJSONTypes)(r.type),schemaType:(0,Fl.getJSONTypes)(r.schemaType)};return(0,gh.eachItem)(n,i.type.length===0?o=>hh.call(this,o,i):o=>i.type.forEach(s=>hh.call(this,o,i,s))),this}getKeyword(t){let r=this.RULES.all[t];return typeof r=="object"?r.definition:!!r}removeKeyword(t){let{RULES:r}=this;delete r.keywords[t],delete r.all[t];for(let n of r.rules){let i=n.rules.findIndex(o=>o.keyword===t);i>=0&&n.rules.splice(i,1)}return this}addFormat(t,r){return typeof r=="string"&&(r=new RegExp(r)),this.formats[t]=r,this}errorsText(t=this.errors,{separator:r=", ",dataVar:n="data"}={}){return!t||t.length===0?"No errors":t.map(i=>`${n}${i.instancePath} ${i.message}`).reduce((i,o)=>i+r+o)}$dataMetaSchema(t,r){let n=this.RULES.all;t=JSON.parse(JSON.stringify(t));for(let i of r){let o=i.split("/").slice(1),s=t;for(let a of o)s=s[a];for(let a in n){let u=n[a];if(typeof u!="object")continue;let{$data:c}=u.definition,l=s[a];c&&l&&(s[a]=Bk(l))}}return t}_removeAllSchemas(t,r){for(let n in t){let i=t[n];(!r||r.test(n))&&(typeof i=="string"?delete t[n]:i&&!i.meta&&(this._cache.delete(i.schema),delete t[n]))}}_addSchema(t,r,n,i=this.opts.validateSchema,o=this.opts.addUsedSchema){let s,{schemaId:a}=this.opts;if(typeof t=="object")s=t[a];else{if(this.opts.jtd)throw new Error("schema must be object");if(typeof t!="boolean")throw new Error("schema must be object or boolean")}let u=this._cache.get(t);if(u!==void 0)return u;n=(0,va.normalizeId)(s||n);let c=va.getSchemaRefs.call(this,t,n);return u=new ya.SchemaEnv({schema:t,schemaId:a,meta:r,baseId:n,localRefs:c}),this._cache.set(u.schema,u),o&&!n.startsWith("#")&&(n&&this._checkUnique(n),this.refs[n]=u),i&&this.validateSchema(t,!0),u}_checkUnique(t){if(this.schemas[t]||this.refs[t])throw new Error(`schema with key or id "${t}" already exists`)}_compileSchemaEnv(t){if(t.meta?this._compileMetaSchema(t):ya.compileSchema.call(this,t),!t.validate)throw new Error("ajv implementation error");return t.validate}_compileMetaSchema(t){let r=this.opts;this.opts=this._metaOpts;try{ya.compileSchema.call(this,t)}finally{this.opts=r}}};ba.ValidationError=nj.default;ba.MissingRefError=Uk.default;wt.default=ba;function qk(e,t,r,n="error"){for(let i in e){let o=i;o in t&&this.logger[n](`${r}: option ${i}. ${e[o]}`)}}function Lk(e){return e=(0,va.normalizeId)(e),this.schemas[e]||this.refs[e]}function fj(){let e=this.opts.schemas;if(e)if(Array.isArray(e))this.addSchema(e);else for(let t in e)this.addSchema(e[t],t)}function mj(){for(let e in this.opts.formats){let t=this.opts.formats[e];t&&this.addFormat(e,t)}}function pj(e){if(Array.isArray(e)){this.addVocabulary(e);return}this.logger.warn("keywords option as map is deprecated, pass array");for(let t in e){let r=e[t];r.keyword||(r.keyword=t),this.addKeyword(r)}}function hj(){let e={...this.opts};for(let t of aj)delete e[t];return e}var gj={log(){},warn(){},error(){}};function _j(e){if(e===!1)return gj;if(e===void 0)return console;if(e.log&&e.warn&&e.error)return e;throw new Error("logger must implement log, warn and error methods")}var yj=/^[a-z_$][a-z0-9_$:-]*$/i;function vj(e,t){let{RULES:r}=this;if((0,gh.eachItem)(e,n=>{if(r.keywords[n])throw new Error(`Keyword ${n} is already defined`);if(!yj.test(n))throw new Error(`Keyword ${n} has invalid name`)}),!!t&&t.$data&&!("code"in t||"validate"in t))throw new Error('$data keyword must have "code" or "validate" function')}function hh(e,t,r){var n;let i=t?.post;if(r&&i)throw new Error('keyword with "post" flag cannot have "type"');let{RULES:o}=this,s=i?o.post:o.rules.find(({type:u})=>u===r);if(s||(s={type:r,rules:[]},o.rules.push(s)),o.keywords[e]=!0,!t)return;let a={keyword:e,definition:{...t,type:(0,Fl.getJSONTypes)(t.type),schemaType:(0,Fl.getJSONTypes)(t.schemaType)}};t.before?bj.call(this,s,a,t.before):s.rules.push(a),o.all[e]=a,(n=t.implements)===null||n===void 0||n.forEach(u=>this.addKeyword(u))}function bj(e,t,r){let n=e.rules.findIndex(i=>i.keyword===r);n>=0?e.rules.splice(n,0,t):(e.rules.push(t),this.logger.warn(`rule ${r} is not defined`))}function wj(e){let{metaSchema:t}=e;t!==void 0&&(e.$data&&this.opts.$data&&(t=Bk(t)),e.validateSchema=this.compile(t,!0))}var kj={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function Bk(e){return{anyOf:[e,kj]}}});var Jk=z(_h=>{"use strict";Object.defineProperty(_h,"__esModule",{value:!0});var xj={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};_h.default=xj});var Xk=z(Hi=>{"use strict";Object.defineProperty(Hi,"__esModule",{value:!0});Hi.callRef=Hi.getValidate=void 0;var Sj=ga(),Hk=gr(),Ht=ie(),Ho=yn(),Kk=Nl(),ql=ge(),Tj={keyword:"$ref",schemaType:"string",code(e){let{gen:t,schema:r,it:n}=e,{baseId:i,schemaEnv:o,validateName:s,opts:a,self:u}=n,{root:c}=o;if((r==="#"||r==="#/")&&i===c.baseId)return d();let l=Kk.resolveRef.call(u,c,i,r);if(l===void 0)throw new Sj.default(n.opts.uriResolver,i,r);if(l instanceof Kk.SchemaEnv)return p(l);return f(l);function d(){if(o===c)return Ll(e,s,o,o.$async);let h=t.scopeValue("root",{ref:c});return Ll(e,(0,Ht._)`${h}.validate`,c,c.$async)}function p(h){let m=Qk(e,h);Ll(e,m,h,h.$async)}function f(h){let m=t.scopeValue("schema",a.code.source===!0?{ref:h,code:(0,Ht.stringify)(h)}:{ref:h}),g=t.name("valid"),y=e.subschema({schema:h,dataTypes:[],schemaPath:Ht.nil,topSchemaRef:m,errSchemaPath:r},g);e.mergeEvaluated(y),e.ok(g)}}};function Qk(e,t){let{gen:r}=e;return t.validate?r.scopeValue("validate",{ref:t.validate}):(0,Ht._)`${r.scopeValue("wrapper",{ref:t})}.validate`}Hi.getValidate=Qk;function Ll(e,t,r,n){let{gen:i,it:o}=e,{allErrors:s,schemaEnv:a,opts:u}=o,c=u.passContext?Ho.default.this:Ht.nil;n?l():d();function l(){if(!a.$async)throw new Error("async schema referenced by sync schema");let h=i.let("valid");i.try(()=>{i.code((0,Ht._)`await ${(0,Hk.callValidateCode)(e,t,c)}`),f(t),s||i.assign(h,!0)},m=>{i.if((0,Ht._)`!(${m} instanceof ${o.ValidationError})`,()=>i.throw(m)),p(m),s||i.assign(h,!1)}),e.ok(h)}function d(){e.result((0,Hk.callValidateCode)(e,t,c),()=>f(t),()=>p(t))}function p(h){let m=(0,Ht._)`${h}.errors`;i.assign(Ho.default.vErrors,(0,Ht._)`${Ho.default.vErrors} === null ? ${m} : ${Ho.default.vErrors}.concat(${m})`),i.assign(Ho.default.errors,(0,Ht._)`${Ho.default.vErrors}.length`)}function f(h){var m;if(!o.opts.unevaluated)return;let g=(m=r?.validate)===null||m===void 0?void 0:m.evaluated;if(o.props!==!0)if(g&&!g.dynamicProps)g.props!==void 0&&(o.props=ql.mergeEvaluated.props(i,g.props,o.props));else{let y=i.var("props",(0,Ht._)`${h}.evaluated.props`);o.props=ql.mergeEvaluated.props(i,y,o.props,Ht.Name)}if(o.items!==!0)if(g&&!g.dynamicItems)g.items!==void 0&&(o.items=ql.mergeEvaluated.items(i,g.items,o.items));else{let y=i.var("items",(0,Ht._)`${h}.evaluated.items`);o.items=ql.mergeEvaluated.items(i,y,o.items,Ht.Name)}}}Hi.callRef=Ll;Hi.default=Tj});var Yk=z(yh=>{"use strict";Object.defineProperty(yh,"__esModule",{value:!0});var $j=Jk(),Ej=Xk(),zj=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",$j.default,Ej.default];yh.default=zj});var ex=z(vh=>{"use strict";Object.defineProperty(vh,"__esModule",{value:!0});var Ul=ie(),Qn=Ul.operators,Vl={maximum:{okStr:"<=",ok:Qn.LTE,fail:Qn.GT},minimum:{okStr:">=",ok:Qn.GTE,fail:Qn.LT},exclusiveMaximum:{okStr:"<",ok:Qn.LT,fail:Qn.GTE},exclusiveMinimum:{okStr:">",ok:Qn.GT,fail:Qn.LTE}},Aj={message:({keyword:e,schemaCode:t})=>(0,Ul.str)`must be ${Vl[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0,Ul._)`{comparison: ${Vl[e].okStr}, limit: ${t}}`},Oj={keyword:Object.keys(Vl),type:"number",schemaType:"number",$data:!0,error:Aj,code(e){let{keyword:t,data:r,schemaCode:n}=e;e.fail$data((0,Ul._)`${r} ${Vl[t].fail} ${n} || isNaN(${r})`)}};vh.default=Oj});var tx=z(bh=>{"use strict";Object.defineProperty(bh,"__esModule",{value:!0});var wa=ie(),Pj={message:({schemaCode:e})=>(0,wa.str)`must be multiple of ${e}`,params:({schemaCode:e})=>(0,wa._)`{multipleOf: ${e}}`},Cj={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:Pj,code(e){let{gen:t,data:r,schemaCode:n,it:i}=e,o=i.opts.multipleOfPrecision,s=t.let("res"),a=o?(0,wa._)`Math.abs(Math.round(${s}) - ${s}) > 1e-${o}`:(0,wa._)`${s} !== parseInt(${s})`;e.fail$data((0,wa._)`(${n} === 0 || (${s} = ${r}/${n}, ${a}))`)}};bh.default=Cj});var nx=z(wh=>{"use strict";Object.defineProperty(wh,"__esModule",{value:!0});function rx(e){let t=e.length,r=0,n=0,i;for(;n<t;)r++,i=e.charCodeAt(n++),i>=55296&&i<=56319&&n<t&&(i=e.charCodeAt(n),(i&64512)===56320&&n++);return r}wh.default=rx;rx.code='require("ajv/dist/runtime/ucs2length").default'});var ix=z(kh=>{"use strict";Object.defineProperty(kh,"__esModule",{value:!0});var Ki=ie(),Rj=ge(),Ij=nx(),jj={message({keyword:e,schemaCode:t}){let r=e==="maxLength"?"more":"fewer";return(0,Ki.str)`must NOT have ${r} than ${t} characters`},params:({schemaCode:e})=>(0,Ki._)`{limit: ${e}}`},Nj={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:jj,code(e){let{keyword:t,data:r,schemaCode:n,it:i}=e,o=t==="maxLength"?Ki.operators.GT:Ki.operators.LT,s=i.opts.unicode===!1?(0,Ki._)`${r}.length`:(0,Ki._)`${(0,Rj.useFunc)(e.gen,Ij.default)}(${r})`;e.fail$data((0,Ki._)`${s} ${o} ${n}`)}};kh.default=Nj});var ox=z(xh=>{"use strict";Object.defineProperty(xh,"__esModule",{value:!0});var Mj=gr(),Bl=ie(),Dj={message:({schemaCode:e})=>(0,Bl.str)`must match pattern "${e}"`,params:({schemaCode:e})=>(0,Bl._)`{pattern: ${e}}`},Gj={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:Dj,code(e){let{data:t,$data:r,schema:n,schemaCode:i,it:o}=e,s=o.opts.unicodeRegExp?"u":"",a=r?(0,Bl._)`(new RegExp(${i}, ${s}))`:(0,Mj.usePattern)(e,n);e.fail$data((0,Bl._)`!${a}.test(${t})`)}};xh.default=Gj});var sx=z(Sh=>{"use strict";Object.defineProperty(Sh,"__esModule",{value:!0});var ka=ie(),Zj={message({keyword:e,schemaCode:t}){let r=e==="maxProperties"?"more":"fewer";return(0,ka.str)`must NOT have ${r} than ${t} properties`},params:({schemaCode:e})=>(0,ka._)`{limit: ${e}}`},Fj={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:Zj,code(e){let{keyword:t,data:r,schemaCode:n}=e,i=t==="maxProperties"?ka.operators.GT:ka.operators.LT;e.fail$data((0,ka._)`Object.keys(${r}).length ${i} ${n}`)}};Sh.default=Fj});var ax=z(Th=>{"use strict";Object.defineProperty(Th,"__esModule",{value:!0});var xa=gr(),Sa=ie(),qj=ge(),Lj={message:({params:{missingProperty:e}})=>(0,Sa.str)`must have required property '${e}'`,params:({params:{missingProperty:e}})=>(0,Sa._)`{missingProperty: ${e}}`},Uj={keyword:"required",type:"object",schemaType:"array",$data:!0,error:Lj,code(e){let{gen:t,schema:r,schemaCode:n,data:i,$data:o,it:s}=e,{opts:a}=s;if(!o&&r.length===0)return;let u=r.length>=a.loopRequired;if(s.allErrors?c():l(),a.strictRequired){let f=e.parentSchema.properties,{definedProperties:h}=e.it;for(let m of r)if(f?.[m]===void 0&&!h.has(m)){let g=s.schemaEnv.baseId+s.errSchemaPath,y=`required property "${m}" is not defined at "${g}" (strictRequired)`;(0,qj.checkStrictMode)(s,y,s.opts.strictRequired)}}function c(){if(u||o)e.block$data(Sa.nil,d);else for(let f of r)(0,xa.checkReportMissingProp)(e,f)}function l(){let f=t.let("missing");if(u||o){let h=t.let("valid",!0);e.block$data(h,()=>p(f,h)),e.ok(h)}else t.if((0,xa.checkMissingProp)(e,r,f)),(0,xa.reportMissingProp)(e,f),t.else()}function d(){t.forOf("prop",n,f=>{e.setParams({missingProperty:f}),t.if((0,xa.noPropertyInData)(t,i,f,a.ownProperties),()=>e.error())})}function p(f,h){e.setParams({missingProperty:f}),t.forOf(f,n,()=>{t.assign(h,(0,xa.propertyInData)(t,i,f,a.ownProperties)),t.if((0,Sa.not)(h),()=>{e.error(),t.break()})},Sa.nil)}}};Th.default=Uj});var cx=z($h=>{"use strict";Object.defineProperty($h,"__esModule",{value:!0});var Ta=ie(),Vj={message({keyword:e,schemaCode:t}){let r=e==="maxItems"?"more":"fewer";return(0,Ta.str)`must NOT have ${r} than ${t} items`},params:({schemaCode:e})=>(0,Ta._)`{limit: ${e}}`},Bj={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:Vj,code(e){let{keyword:t,data:r,schemaCode:n}=e,i=t==="maxItems"?Ta.operators.GT:Ta.operators.LT;e.fail$data((0,Ta._)`${r}.length ${i} ${n}`)}};$h.default=Bj});var Wl=z(Eh=>{"use strict";Object.defineProperty(Eh,"__esModule",{value:!0});var lx=Qp();lx.code='require("ajv/dist/runtime/equal").default';Eh.default=lx});var ux=z(Ah=>{"use strict";Object.defineProperty(Ah,"__esModule",{value:!0});var zh=da(),kt=ie(),Wj=ge(),Jj=Wl(),Hj={message:({params:{i:e,j:t}})=>(0,kt.str)`must NOT have duplicate items (items ## ${t} and ${e} are identical)`,params:({params:{i:e,j:t}})=>(0,kt._)`{i: ${e}, j: ${t}}`},Kj={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:Hj,code(e){let{gen:t,data:r,$data:n,schema:i,parentSchema:o,schemaCode:s,it:a}=e;if(!n&&!i)return;let u=t.let("valid"),c=o.items?(0,zh.getSchemaTypes)(o.items):[];e.block$data(u,l,(0,kt._)`${s} === false`),e.ok(u);function l(){let h=t.let("i",(0,kt._)`${r}.length`),m=t.let("j");e.setParams({i:h,j:m}),t.assign(u,!0),t.if((0,kt._)`${h} > 1`,()=>(d()?p:f)(h,m))}function d(){return c.length>0&&!c.some(h=>h==="object"||h==="array")}function p(h,m){let g=t.name("item"),y=(0,zh.checkDataTypes)(c,g,a.opts.strictNumbers,zh.DataType.Wrong),v=t.const("indices",(0,kt._)`{}`);t.for((0,kt._)`;${h}--;`,()=>{t.let(g,(0,kt._)`${r}[${h}]`),t.if(y,(0,kt._)`continue`),c.length>1&&t.if((0,kt._)`typeof ${g} == "string"`,(0,kt._)`${g} += "_"`),t.if((0,kt._)`typeof ${v}[${g}] == "number"`,()=>{t.assign(m,(0,kt._)`${v}[${g}]`),e.error(),t.assign(u,!1).break()}).code((0,kt._)`${v}[${g}] = ${h}`)})}function f(h,m){let g=(0,Wj.useFunc)(t,Jj.default),y=t.name("outer");t.label(y).for((0,kt._)`;${h}--;`,()=>t.for((0,kt._)`${m} = ${h}; ${m}--;`,()=>t.if((0,kt._)`${g}(${r}[${h}], ${r}[${m}])`,()=>{e.error(),t.assign(u,!1).break(y)})))}}};Ah.default=Kj});var dx=z(Ph=>{"use strict";Object.defineProperty(Ph,"__esModule",{value:!0});var Oh=ie(),Qj=ge(),Xj=Wl(),Yj={message:"must be equal to constant",params:({schemaCode:e})=>(0,Oh._)`{allowedValue: ${e}}`},e2={keyword:"const",$data:!0,error:Yj,code(e){let{gen:t,data:r,$data:n,schemaCode:i,schema:o}=e;n||o&&typeof o=="object"?e.fail$data((0,Oh._)`!${(0,Qj.useFunc)(t,Xj.default)}(${r}, ${i})`):e.fail((0,Oh._)`${o} !== ${r}`)}};Ph.default=e2});var fx=z(Ch=>{"use strict";Object.defineProperty(Ch,"__esModule",{value:!0});var $a=ie(),t2=ge(),r2=Wl(),n2={message:"must be equal to one of the allowed values",params:({schemaCode:e})=>(0,$a._)`{allowedValues: ${e}}`},i2={keyword:"enum",schemaType:"array",$data:!0,error:n2,code(e){let{gen:t,data:r,$data:n,schema:i,schemaCode:o,it:s}=e;if(!n&&i.length===0)throw new Error("enum must have non-empty array");let a=i.length>=s.opts.loopEnum,u,c=()=>u??(u=(0,t2.useFunc)(t,r2.default)),l;if(a||n)l=t.let("valid"),e.block$data(l,d);else{if(!Array.isArray(i))throw new Error("ajv implementation error");let f=t.const("vSchema",o);l=(0,$a.or)(...i.map((h,m)=>p(f,m)))}e.pass(l);function d(){t.assign(l,!1),t.forOf("v",o,f=>t.if((0,$a._)`${c()}(${r}, ${f})`,()=>t.assign(l,!0).break()))}function p(f,h){let m=i[h];return typeof m=="object"&&m!==null?(0,$a._)`${c()}(${r}, ${f}[${h}])`:(0,$a._)`${r} === ${m}`}}};Ch.default=i2});var mx=z(Rh=>{"use strict";Object.defineProperty(Rh,"__esModule",{value:!0});var o2=ex(),s2=tx(),a2=ix(),c2=ox(),l2=sx(),u2=ax(),d2=cx(),f2=ux(),m2=dx(),p2=fx(),h2=[o2.default,s2.default,a2.default,c2.default,l2.default,u2.default,d2.default,f2.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},m2.default,p2.default];Rh.default=h2});var jh=z(Ea=>{"use strict";Object.defineProperty(Ea,"__esModule",{value:!0});Ea.validateAdditionalItems=void 0;var Qi=ie(),Ih=ge(),g2={message:({params:{len:e}})=>(0,Qi.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,Qi._)`{limit: ${e}}`},_2={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:g2,code(e){let{parentSchema:t,it:r}=e,{items:n}=t;if(!Array.isArray(n)){(0,Ih.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas');return}px(e,n)}};function px(e,t){let{gen:r,schema:n,data:i,keyword:o,it:s}=e;s.items=!0;let a=r.const("len",(0,Qi._)`${i}.length`);if(n===!1)e.setParams({len:t.length}),e.pass((0,Qi._)`${a} <= ${t.length}`);else if(typeof n=="object"&&!(0,Ih.alwaysValidSchema)(s,n)){let c=r.var("valid",(0,Qi._)`${a} <= ${t.length}`);r.if((0,Qi.not)(c),()=>u(c)),e.ok(c)}function u(c){r.forRange("i",t.length,a,l=>{e.subschema({keyword:o,dataProp:l,dataPropType:Ih.Type.Num},c),s.allErrors||r.if((0,Qi.not)(c),()=>r.break())})}}Ea.validateAdditionalItems=px;Ea.default=_2});var Nh=z(za=>{"use strict";Object.defineProperty(za,"__esModule",{value:!0});za.validateTuple=void 0;var hx=ie(),Jl=ge(),y2=gr(),v2={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(e){let{schema:t,it:r}=e;if(Array.isArray(t))return gx(e,"additionalItems",t);r.items=!0,!(0,Jl.alwaysValidSchema)(r,t)&&e.ok((0,y2.validateArray)(e))}};function gx(e,t,r=e.schema){let{gen:n,parentSchema:i,data:o,keyword:s,it:a}=e;l(i),a.opts.unevaluated&&r.length&&a.items!==!0&&(a.items=Jl.mergeEvaluated.items(n,r.length,a.items));let u=n.name("valid"),c=n.const("len",(0,hx._)`${o}.length`);r.forEach((d,p)=>{(0,Jl.alwaysValidSchema)(a,d)||(n.if((0,hx._)`${c} > ${p}`,()=>e.subschema({keyword:s,schemaProp:p,dataProp:p},u)),e.ok(u))});function l(d){let{opts:p,errSchemaPath:f}=a,h=r.length,m=h===d.minItems&&(h===d.maxItems||d[t]===!1);if(p.strictTuples&&!m){let g=`"${s}" is ${h}-tuple, but minItems or maxItems/${t} are not specified or different at path "${f}"`;(0,Jl.checkStrictMode)(a,g,p.strictTuples)}}}za.validateTuple=gx;za.default=v2});var _x=z(Mh=>{"use strict";Object.defineProperty(Mh,"__esModule",{value:!0});var b2=Nh(),w2={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:e=>(0,b2.validateTuple)(e,"items")};Mh.default=w2});var vx=z(Dh=>{"use strict";Object.defineProperty(Dh,"__esModule",{value:!0});var yx=ie(),k2=ge(),x2=gr(),S2=jh(),T2={message:({params:{len:e}})=>(0,yx.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,yx._)`{limit: ${e}}`},$2={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:T2,code(e){let{schema:t,parentSchema:r,it:n}=e,{prefixItems:i}=r;n.items=!0,!(0,k2.alwaysValidSchema)(n,t)&&(i?(0,S2.validateAdditionalItems)(e,i):e.ok((0,x2.validateArray)(e)))}};Dh.default=$2});var bx=z(Gh=>{"use strict";Object.defineProperty(Gh,"__esModule",{value:!0});var yr=ie(),Hl=ge(),E2={message:({params:{min:e,max:t}})=>t===void 0?(0,yr.str)`must contain at least ${e} valid item(s)`:(0,yr.str)`must contain at least ${e} and no more than ${t} valid item(s)`,params:({params:{min:e,max:t}})=>t===void 0?(0,yr._)`{minContains: ${e}}`:(0,yr._)`{minContains: ${e}, maxContains: ${t}}`},z2={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:E2,code(e){let{gen:t,schema:r,parentSchema:n,data:i,it:o}=e,s,a,{minContains:u,maxContains:c}=n;o.opts.next?(s=u===void 0?1:u,a=c):s=1;let l=t.const("len",(0,yr._)`${i}.length`);if(e.setParams({min:s,max:a}),a===void 0&&s===0){(0,Hl.checkStrictMode)(o,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(a!==void 0&&s>a){(0,Hl.checkStrictMode)(o,'"minContains" > "maxContains" is always invalid'),e.fail();return}if((0,Hl.alwaysValidSchema)(o,r)){let m=(0,yr._)`${l} >= ${s}`;a!==void 0&&(m=(0,yr._)`${m} && ${l} <= ${a}`),e.pass(m);return}o.items=!0;let d=t.name("valid");a===void 0&&s===1?f(d,()=>t.if(d,()=>t.break())):s===0?(t.let(d,!0),a!==void 0&&t.if((0,yr._)`${i}.length > 0`,p)):(t.let(d,!1),p()),e.result(d,()=>e.reset());function p(){let m=t.name("_valid"),g=t.let("count",0);f(m,()=>t.if(m,()=>h(g)))}function f(m,g){t.forRange("i",0,l,y=>{e.subschema({keyword:"contains",dataProp:y,dataPropType:Hl.Type.Num,compositeRule:!0},m),g()})}function h(m){t.code((0,yr._)`${m}++`),a===void 0?t.if((0,yr._)`${m} >= ${s}`,()=>t.assign(d,!0).break()):(t.if((0,yr._)`${m} > ${a}`,()=>t.assign(d,!1).break()),s===1?t.assign(d,!0):t.if((0,yr._)`${m} >= ${s}`,()=>t.assign(d,!0)))}}};Gh.default=z2});var xx=z(Yr=>{"use strict";Object.defineProperty(Yr,"__esModule",{value:!0});Yr.validateSchemaDeps=Yr.validatePropertyDeps=Yr.error=void 0;var Zh=ie(),A2=ge(),Aa=gr();Yr.error={message:({params:{property:e,depsCount:t,deps:r}})=>{let n=t===1?"property":"properties";return(0,Zh.str)`must have ${n} ${r} when property ${e} is present`},params:({params:{property:e,depsCount:t,deps:r,missingProperty:n}})=>(0,Zh._)`{property: ${e},
8
+ || ${s} === "boolean" || ${i} === null`).assign(a,(0,te._)`[${i}]`)}}}function fR({gen:e,parentData:t,parentDataProperty:r},n){e.if((0,te._)`${t} !== undefined`,()=>e.assign((0,te._)`${t}[${r}]`,n))}function Vp(e,t,r,n=Uo.Correct){let i=n===Uo.Correct?te.operators.EQ:te.operators.NEQ,o;switch(e){case"null":return(0,te._)`${t} ${i} null`;case"array":o=(0,te._)`Array.isArray(${t})`;break;case"object":o=(0,te._)`${t} && typeof ${t} == "object" && !Array.isArray(${t})`;break;case"integer":o=s((0,te._)`!(${t} % 1) && !isNaN(${t})`);break;case"number":o=s();break;default:return(0,te._)`typeof ${t} ${i} ${e}`}return n===Uo.Correct?o:(0,te.not)(o);function s(a=te.nil){return(0,te.and)((0,te._)`typeof ${t} == "number"`,a,r?(0,te._)`isFinite(${t})`:te.nil)}}zt.checkDataType=Vp;function Bp(e,t,r,n){if(e.length===1)return Vp(e[0],t,r,n);let i,o=(0,Bw.toHash)(e);if(o.array&&o.object){let s=(0,te._)`typeof ${t} != "object"`;i=o.null?s:(0,te._)`!${t} || ${s}`,delete o.null,delete o.array,delete o.object}else i=te.nil;o.number&&delete o.integer;for(let s in o)i=(0,te.and)(i,Vp(s,t,r,n));return i}zt.checkDataTypes=Bp;var mR={message:({schema:e})=>`must be ${e}`,params:({schema:e,schemaValue:t})=>typeof e=="string"?(0,te._)`{type: ${e}}`:(0,te._)`{type: ${t}}`};function Wp(e){let t=pR(e);(0,aR.reportError)(t,mR)}zt.reportTypeError=Wp;function pR(e){let{gen:t,data:r,schema:n}=e,i=(0,Bw.schemaRefOrVal)(e,n,"type");return{gen:t,keyword:"type",data:r,schema:n.type,schemaCode:i,schemaValue:i,parentSchema:n,params:{},it:e}}});var Kw=z(Ol=>{"use strict";Object.defineProperty(Ol,"__esModule",{value:!0});Ol.assignDefaults=void 0;var Vo=ie(),hR=_e();function gR(e,t){let{properties:r,items:n}=e.schema;if(t==="object"&&r)for(let i in r)Hw(e,i,r[i].default);else t==="array"&&Array.isArray(n)&&n.forEach((i,o)=>Hw(e,o,i.default))}Ol.assignDefaults=gR;function Hw(e,t,r){let{gen:n,compositeRule:i,data:o,opts:s}=e;if(r===void 0)return;let a=(0,Vo._)`${o}${(0,Vo.getProperty)(t)}`;if(i){(0,hR.checkStrictMode)(e,`default is ignored for: ${a}`);return}let u=(0,Vo._)`${a} === undefined`;s.useDefaults==="empty"&&(u=(0,Vo._)`${u} || ${a} === null || ${a} === ""`),n.if(u,(0,Vo._)`${a} = ${(0,Vo.stringify)(r)}`)}});var gr=z(Te=>{"use strict";Object.defineProperty(Te,"__esModule",{value:!0});Te.validateUnion=Te.validateArray=Te.usePattern=Te.callValidateCode=Te.schemaProperties=Te.allSchemaProperties=Te.noPropertyInData=Te.propertyInData=Te.isOwnProperty=Te.hasPropFunc=Te.reportMissingProp=Te.checkMissingProp=Te.checkReportMissingProp=void 0;var Ie=ie(),Jp=_e(),Jn=yn(),_R=_e();function yR(e,t){let{gen:r,data:n,it:i}=e;r.if(Kp(r,n,t,i.opts.ownProperties),()=>{e.setParams({missingProperty:(0,Ie._)`${t}`},!0),e.error()})}Te.checkReportMissingProp=yR;function vR({gen:e,data:t,it:{opts:r}},n,i){return(0,Ie.or)(...n.map(o=>(0,Ie.and)(Kp(e,t,o,r.ownProperties),(0,Ie._)`${i} = ${o}`)))}Te.checkMissingProp=vR;function bR(e,t){e.setParams({missingProperty:t},!0),e.error()}Te.reportMissingProp=bR;function Qw(e){return e.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,Ie._)`Object.prototype.hasOwnProperty`})}Te.hasPropFunc=Qw;function Hp(e,t,r){return(0,Ie._)`${Qw(e)}.call(${t}, ${r})`}Te.isOwnProperty=Hp;function wR(e,t,r,n){let i=(0,Ie._)`${t}${(0,Ie.getProperty)(r)} !== undefined`;return n?(0,Ie._)`${i} && ${Hp(e,t,r)}`:i}Te.propertyInData=wR;function Kp(e,t,r,n){let i=(0,Ie._)`${t}${(0,Ie.getProperty)(r)} === undefined`;return n?(0,Ie.or)(i,(0,Ie.not)(Hp(e,t,r))):i}Te.noPropertyInData=Kp;function Xw(e){return e?Object.keys(e).filter(t=>t!=="__proto__"):[]}Te.allSchemaProperties=Xw;function kR(e,t){return Xw(t).filter(r=>!(0,Jp.alwaysValidSchema)(e,t[r]))}Te.schemaProperties=kR;function xR({schemaCode:e,data:t,it:{gen:r,topSchemaRef:n,schemaPath:i,errorPath:o},it:s},a,u,c){let l=c?(0,Ie._)`${e}, ${t}, ${n}${i}`:t,d=[[Jn.default.instancePath,(0,Ie.strConcat)(Jn.default.instancePath,o)],[Jn.default.parentData,s.parentData],[Jn.default.parentDataProperty,s.parentDataProperty],[Jn.default.rootData,Jn.default.rootData]];s.opts.dynamicRef&&d.push([Jn.default.dynamicAnchors,Jn.default.dynamicAnchors]);let p=(0,Ie._)`${l}, ${r.object(...d)}`;return u!==Ie.nil?(0,Ie._)`${a}.call(${u}, ${p})`:(0,Ie._)`${a}(${p})`}Te.callValidateCode=xR;var SR=(0,Ie._)`new RegExp`;function TR({gen:e,it:{opts:t}},r){let n=t.unicodeRegExp?"u":"",{regExp:i}=t.code,o=i(r,n);return e.scopeValue("pattern",{key:o.toString(),ref:o,code:(0,Ie._)`${i.code==="new RegExp"?SR:(0,_R.useFunc)(e,i)}(${r}, ${n})`})}Te.usePattern=TR;function $R(e){let{gen:t,data:r,keyword:n,it:i}=e,o=t.name("valid");if(i.allErrors){let a=t.let("valid",!0);return s(()=>t.assign(a,!1)),a}return t.var(o,!0),s(()=>t.break()),o;function s(a){let u=t.const("len",(0,Ie._)`${r}.length`);t.forRange("i",0,u,c=>{e.subschema({keyword:n,dataProp:c,dataPropType:Jp.Type.Num},o),t.if((0,Ie.not)(o),a)})}}Te.validateArray=$R;function ER(e){let{gen:t,schema:r,keyword:n,it:i}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");if(r.some(u=>(0,Jp.alwaysValidSchema)(i,u))&&!i.opts.unevaluated)return;let s=t.let("valid",!1),a=t.name("_valid");t.block(()=>r.forEach((u,c)=>{let l=e.subschema({keyword:n,schemaProp:c,compositeRule:!0},a);t.assign(s,(0,Ie._)`${s} || ${a}`),e.mergeValidEvaluated(l,a)||t.if((0,Ie.not)(s))})),e.result(s,()=>e.reset(),()=>e.error(!0))}Te.validateUnion=ER});var tk=z(Kr=>{"use strict";Object.defineProperty(Kr,"__esModule",{value:!0});Kr.validateKeywordUsage=Kr.validSchemaType=Kr.funcKeywordCode=Kr.macroKeywordCode=void 0;var Mt=ie(),Ji=yn(),zR=gr(),AR=ua();function OR(e,t){let{gen:r,keyword:n,schema:i,parentSchema:o,it:s}=e,a=t.macro.call(s.self,i,o,s),u=ek(r,n,a);s.opts.validateSchema!==!1&&s.self.validateSchema(a,!0);let c=r.name("valid");e.subschema({schema:a,schemaPath:Mt.nil,errSchemaPath:`${s.errSchemaPath}/${n}`,topSchemaRef:u,compositeRule:!0},c),e.pass(c,()=>e.error(!0))}Kr.macroKeywordCode=OR;function PR(e,t){var r;let{gen:n,keyword:i,schema:o,parentSchema:s,$data:a,it:u}=e;RR(u,t);let c=!a&&t.compile?t.compile.call(u.self,o,s,u):t.validate,l=ek(n,i,c),d=n.let("valid");e.block$data(d,p),e.ok((r=t.valid)!==null&&r!==void 0?r:d);function p(){if(t.errors===!1)m(),t.modifying&&Yw(e),g(()=>e.error());else{let y=t.async?f():h();t.modifying&&Yw(e),g(()=>CR(e,y))}}function f(){let y=n.let("ruleErrs",null);return n.try(()=>m((0,Mt._)`await `),v=>n.assign(d,!1).if((0,Mt._)`${v} instanceof ${u.ValidationError}`,()=>n.assign(y,(0,Mt._)`${v}.errors`),()=>n.throw(v))),y}function h(){let y=(0,Mt._)`${l}.errors`;return n.assign(y,null),m(Mt.nil),y}function m(y=t.async?(0,Mt._)`await `:Mt.nil){let v=u.opts.passContext?Ji.default.this:Ji.default.self,b=!("compile"in t&&!a||t.schema===!1);n.assign(d,(0,Mt._)`${y}${(0,zR.callValidateCode)(e,l,v,b)}`,t.modifying)}function g(y){var v;n.if((0,Mt.not)((v=t.valid)!==null&&v!==void 0?v:d),y)}}Kr.funcKeywordCode=PR;function Yw(e){let{gen:t,data:r,it:n}=e;t.if(n.parentData,()=>t.assign(r,(0,Mt._)`${n.parentData}[${n.parentDataProperty}]`))}function CR(e,t){let{gen:r}=e;r.if((0,Mt._)`Array.isArray(${t})`,()=>{r.assign(Ji.default.vErrors,(0,Mt._)`${Ji.default.vErrors} === null ? ${t} : ${Ji.default.vErrors}.concat(${t})`).assign(Ji.default.errors,(0,Mt._)`${Ji.default.vErrors}.length`),(0,AR.extendErrors)(e)},()=>e.error())}function RR({schemaEnv:e},t){if(t.async&&!e.$async)throw new Error("async keyword in sync schema")}function ek(e,t,r){if(r===void 0)throw new Error(`keyword "${t}" failed to compile`);return e.scopeValue("keyword",typeof r=="function"?{ref:r}:{ref:r,code:(0,Mt.stringify)(r)})}function IR(e,t,r=!1){return!t.length||t.some(n=>n==="array"?Array.isArray(e):n==="object"?e&&typeof e=="object"&&!Array.isArray(e):typeof e==n||r&&typeof e>"u")}Kr.validSchemaType=IR;function jR({schema:e,opts:t,self:r,errSchemaPath:n},i,o){if(Array.isArray(i.keyword)?!i.keyword.includes(o):i.keyword!==o)throw new Error("ajv implementation error");let s=i.dependencies;if(s?.some(a=>!Object.prototype.hasOwnProperty.call(e,a)))throw new Error(`parent schema must have dependencies of ${o}: ${s.join(",")}`);if(i.validateSchema&&!i.validateSchema(e[o])){let u=`keyword "${o}" value is invalid at path "${n}": `+r.errorsText(i.validateSchema.errors);if(t.validateSchema==="log")r.logger.error(u);else throw new Error(u)}}Kr.validateKeywordUsage=jR});var nk=z(Hn=>{"use strict";Object.defineProperty(Hn,"__esModule",{value:!0});Hn.extendSubschemaMode=Hn.extendSubschemaData=Hn.getSubschema=void 0;var Qr=ie(),rk=_e();function NR(e,{keyword:t,schemaProp:r,schema:n,schemaPath:i,errSchemaPath:o,topSchemaRef:s}){if(t!==void 0&&n!==void 0)throw new Error('both "keyword" and "schema" passed, only one allowed');if(t!==void 0){let a=e.schema[t];return r===void 0?{schema:a,schemaPath:(0,Qr._)`${e.schemaPath}${(0,Qr.getProperty)(t)}`,errSchemaPath:`${e.errSchemaPath}/${t}`}:{schema:a[r],schemaPath:(0,Qr._)`${e.schemaPath}${(0,Qr.getProperty)(t)}${(0,Qr.getProperty)(r)}`,errSchemaPath:`${e.errSchemaPath}/${t}/${(0,rk.escapeFragment)(r)}`}}if(n!==void 0){if(i===void 0||o===void 0||s===void 0)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:n,schemaPath:i,topSchemaRef:s,errSchemaPath:o}}throw new Error('either "keyword" or "schema" must be passed')}Hn.getSubschema=NR;function MR(e,t,{dataProp:r,dataPropType:n,data:i,dataTypes:o,propertyName:s}){if(i!==void 0&&r!==void 0)throw new Error('both "data" and "dataProp" passed, only one allowed');let{gen:a}=t;if(r!==void 0){let{errorPath:c,dataPathArr:l,opts:d}=t,p=a.let("data",(0,Qr._)`${t.data}${(0,Qr.getProperty)(r)}`,!0);u(p),e.errorPath=(0,Qr.str)`${c}${(0,rk.getErrorPath)(r,n,d.jsPropertySyntax)}`,e.parentDataProperty=(0,Qr._)`${r}`,e.dataPathArr=[...l,e.parentDataProperty]}if(i!==void 0){let c=i instanceof Qr.Name?i:a.let("data",i,!0);u(c),s!==void 0&&(e.propertyName=s)}o&&(e.dataTypes=o);function u(c){e.data=c,e.dataLevel=t.dataLevel+1,e.dataTypes=[],t.definedProperties=new Set,e.parentData=t.data,e.dataNames=[...t.dataNames,c]}}Hn.extendSubschemaData=MR;function DR(e,{jtdDiscriminator:t,jtdMetadata:r,compositeRule:n,createErrors:i,allErrors:o}){n!==void 0&&(e.compositeRule=n),i!==void 0&&(e.createErrors=i),o!==void 0&&(e.allErrors=o),e.jtdDiscriminator=t,e.jtdMetadata=r}Hn.extendSubschemaMode=DR});var Qp=z((ZF,ik)=>{"use strict";ik.exports=function e(t,r){if(t===r)return!0;if(t&&r&&typeof t=="object"&&typeof r=="object"){if(t.constructor!==r.constructor)return!1;var n,i,o;if(Array.isArray(t)){if(n=t.length,n!=r.length)return!1;for(i=n;i--!==0;)if(!e(t[i],r[i]))return!1;return!0}if(t.constructor===RegExp)return t.source===r.source&&t.flags===r.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===r.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===r.toString();if(o=Object.keys(t),n=o.length,n!==Object.keys(r).length)return!1;for(i=n;i--!==0;)if(!Object.prototype.hasOwnProperty.call(r,o[i]))return!1;for(i=n;i--!==0;){var s=o[i];if(!e(t[s],r[s]))return!1}return!0}return t!==t&&r!==r}});var sk=z((FF,ok)=>{"use strict";var Kn=ok.exports=function(e,t,r){typeof t=="function"&&(r=t,t={}),r=t.cb||r;var n=typeof r=="function"?r:r.pre||function(){},i=r.post||function(){};Pl(t,n,i,e,"",e)};Kn.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};Kn.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};Kn.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};Kn.skipKeywords={default:!0,enum:!0,const:!0,required:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0};function Pl(e,t,r,n,i,o,s,a,u,c){if(n&&typeof n=="object"&&!Array.isArray(n)){t(n,i,o,s,a,u,c);for(var l in n){var d=n[l];if(Array.isArray(d)){if(l in Kn.arrayKeywords)for(var p=0;p<d.length;p++)Pl(e,t,r,d[p],i+"/"+l+"/"+p,o,i,l,n,p)}else if(l in Kn.propsKeywords){if(d&&typeof d=="object")for(var f in d)Pl(e,t,r,d[f],i+"/"+l+"/"+GR(f),o,i,l,n,f)}else(l in Kn.keywords||e.allKeys&&!(l in Kn.skipKeywords))&&Pl(e,t,r,d,i+"/"+l,o,i,l,n)}r(n,i,o,s,a,u,c)}}function GR(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}});var fa=z(Jt=>{"use strict";Object.defineProperty(Jt,"__esModule",{value:!0});Jt.getSchemaRefs=Jt.resolveUrl=Jt.normalizeId=Jt._getFullPath=Jt.getFullPath=Jt.inlineRef=void 0;var ZR=_e(),FR=Qp(),qR=sk(),LR=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function UR(e,t=!0){return typeof e=="boolean"?!0:t===!0?!Xp(e):t?ak(e)<=t:!1}Jt.inlineRef=UR;var VR=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function Xp(e){for(let t in e){if(VR.has(t))return!0;let r=e[t];if(Array.isArray(r)&&r.some(Xp)||typeof r=="object"&&Xp(r))return!0}return!1}function ak(e){let t=0;for(let r in e){if(r==="$ref")return 1/0;if(t++,!LR.has(r)&&(typeof e[r]=="object"&&(0,ZR.eachItem)(e[r],n=>t+=ak(n)),t===1/0))return 1/0}return t}function ck(e,t="",r){r!==!1&&(t=Bo(t));let n=e.parse(t);return lk(e,n)}Jt.getFullPath=ck;function lk(e,t){return e.serialize(t).split("#")[0]+"#"}Jt._getFullPath=lk;var BR=/#\/?$/;function Bo(e){return e?e.replace(BR,""):""}Jt.normalizeId=Bo;function WR(e,t,r){return r=Bo(r),e.resolve(t,r)}Jt.resolveUrl=WR;var JR=/^[a-z_][-a-z0-9._]*$/i;function HR(e,t){if(typeof e=="boolean")return{};let{schemaId:r,uriResolver:n}=this.opts,i=Bo(e[r]||t),o={"":i},s=ck(n,i,!1),a={},u=new Set;return qR(e,{allKeys:!0},(d,p,f,h)=>{if(h===void 0)return;let m=s+p,g=o[h];typeof d[r]=="string"&&(g=y.call(this,d[r])),v.call(this,d.$anchor),v.call(this,d.$dynamicAnchor),o[p]=g;function y(b){let w=this.opts.uriResolver.resolve;if(b=Bo(g?w(g,b):b),u.has(b))throw l(b);u.add(b);let S=this.refs[b];return typeof S=="string"&&(S=this.refs[S]),typeof S=="object"?c(d,S.schema,b):b!==Bo(m)&&(b[0]==="#"?(c(d,a[b],b),a[b]=d):this.refs[b]=m),b}function v(b){if(typeof b=="string"){if(!JR.test(b))throw new Error(`invalid anchor "${b}"`);y.call(this,`#${b}`)}}}),a;function c(d,p,f){if(p!==void 0&&!FR(d,p))throw l(f)}function l(d){return new Error(`reference "${d}" resolves to more than one schema`)}}Jt.getSchemaRefs=HR});var ha=z(Qn=>{"use strict";Object.defineProperty(Qn,"__esModule",{value:!0});Qn.getData=Qn.KeywordCxt=Qn.validateFunctionCode=void 0;var pk=Lw(),uk=da(),eh=Up(),Cl=da(),KR=Kw(),pa=tk(),Yp=nk(),L=ie(),Q=yn(),QR=fa(),vn=_e(),ma=ua();function XR(e){if(_k(e)&&(yk(e),gk(e))){tI(e);return}hk(e,()=>(0,pk.topBoolOrEmptySchema)(e))}Qn.validateFunctionCode=XR;function hk({gen:e,validateName:t,schema:r,schemaEnv:n,opts:i},o){i.code.es5?e.func(t,(0,L._)`${Q.default.data}, ${Q.default.valCxt}`,n.$async,()=>{e.code((0,L._)`"use strict"; ${dk(r,i)}`),eI(e,i),e.code(o)}):e.func(t,(0,L._)`${Q.default.data}, ${YR(i)}`,n.$async,()=>e.code(dk(r,i)).code(o))}function YR(e){return(0,L._)`{${Q.default.instancePath}="", ${Q.default.parentData}, ${Q.default.parentDataProperty}, ${Q.default.rootData}=${Q.default.data}${e.dynamicRef?(0,L._)`, ${Q.default.dynamicAnchors}={}`:L.nil}}={}`}function eI(e,t){e.if(Q.default.valCxt,()=>{e.var(Q.default.instancePath,(0,L._)`${Q.default.valCxt}.${Q.default.instancePath}`),e.var(Q.default.parentData,(0,L._)`${Q.default.valCxt}.${Q.default.parentData}`),e.var(Q.default.parentDataProperty,(0,L._)`${Q.default.valCxt}.${Q.default.parentDataProperty}`),e.var(Q.default.rootData,(0,L._)`${Q.default.valCxt}.${Q.default.rootData}`),t.dynamicRef&&e.var(Q.default.dynamicAnchors,(0,L._)`${Q.default.valCxt}.${Q.default.dynamicAnchors}`)},()=>{e.var(Q.default.instancePath,(0,L._)`""`),e.var(Q.default.parentData,(0,L._)`undefined`),e.var(Q.default.parentDataProperty,(0,L._)`undefined`),e.var(Q.default.rootData,Q.default.data),t.dynamicRef&&e.var(Q.default.dynamicAnchors,(0,L._)`{}`)})}function tI(e){let{schema:t,opts:r,gen:n}=e;hk(e,()=>{r.$comment&&t.$comment&&bk(e),sI(e),n.let(Q.default.vErrors,null),n.let(Q.default.errors,0),r.unevaluated&&rI(e),vk(e),lI(e)})}function rI(e){let{gen:t,validateName:r}=e;e.evaluated=t.const("evaluated",(0,L._)`${r}.evaluated`),t.if((0,L._)`${e.evaluated}.dynamicProps`,()=>t.assign((0,L._)`${e.evaluated}.props`,(0,L._)`undefined`)),t.if((0,L._)`${e.evaluated}.dynamicItems`,()=>t.assign((0,L._)`${e.evaluated}.items`,(0,L._)`undefined`))}function dk(e,t){let r=typeof e=="object"&&e[t.schemaId];return r&&(t.code.source||t.code.process)?(0,L._)`/*# sourceURL=${r} */`:L.nil}function nI(e,t){if(_k(e)&&(yk(e),gk(e))){iI(e,t);return}(0,pk.boolOrEmptySchema)(e,t)}function gk({schema:e,self:t}){if(typeof e=="boolean")return!e;for(let r in e)if(t.RULES.all[r])return!0;return!1}function _k(e){return typeof e.schema!="boolean"}function iI(e,t){let{schema:r,gen:n,opts:i}=e;i.$comment&&r.$comment&&bk(e),aI(e),cI(e);let o=n.const("_errs",Q.default.errors);vk(e,o),n.var(t,(0,L._)`${o} === ${Q.default.errors}`)}function yk(e){(0,vn.checkUnknownRules)(e),oI(e)}function vk(e,t){if(e.opts.jtd)return fk(e,[],!1,t);let r=(0,uk.getSchemaTypes)(e.schema),n=(0,uk.coerceAndCheckDataType)(e,r);fk(e,r,!n,t)}function oI(e){let{schema:t,errSchemaPath:r,opts:n,self:i}=e;t.$ref&&n.ignoreKeywordsWithRef&&(0,vn.schemaHasRulesButRef)(t,i.RULES)&&i.logger.warn(`$ref: keywords ignored in schema at path "${r}"`)}function sI(e){let{schema:t,opts:r}=e;t.default!==void 0&&r.useDefaults&&r.strictSchema&&(0,vn.checkStrictMode)(e,"default is ignored in the schema root")}function aI(e){let t=e.schema[e.opts.schemaId];t&&(e.baseId=(0,QR.resolveUrl)(e.opts.uriResolver,e.baseId,t))}function cI(e){if(e.schema.$async&&!e.schemaEnv.$async)throw new Error("async schema in sync schema")}function bk({gen:e,schemaEnv:t,schema:r,errSchemaPath:n,opts:i}){let o=r.$comment;if(i.$comment===!0)e.code((0,L._)`${Q.default.self}.logger.log(${o})`);else if(typeof i.$comment=="function"){let s=(0,L.str)`${n}/$comment`,a=e.scopeValue("root",{ref:t.root});e.code((0,L._)`${Q.default.self}.opts.$comment(${o}, ${s}, ${a}.schema)`)}}function lI(e){let{gen:t,schemaEnv:r,validateName:n,ValidationError:i,opts:o}=e;r.$async?t.if((0,L._)`${Q.default.errors} === 0`,()=>t.return(Q.default.data),()=>t.throw((0,L._)`new ${i}(${Q.default.vErrors})`)):(t.assign((0,L._)`${n}.errors`,Q.default.vErrors),o.unevaluated&&uI(e),t.return((0,L._)`${Q.default.errors} === 0`))}function uI({gen:e,evaluated:t,props:r,items:n}){r instanceof L.Name&&e.assign((0,L._)`${t}.props`,r),n instanceof L.Name&&e.assign((0,L._)`${t}.items`,n)}function fk(e,t,r,n){let{gen:i,schema:o,data:s,allErrors:a,opts:u,self:c}=e,{RULES:l}=c;if(o.$ref&&(u.ignoreKeywordsWithRef||!(0,vn.schemaHasRulesButRef)(o,l))){i.block(()=>kk(e,"$ref",l.all.$ref.definition));return}u.jtd||dI(e,t),i.block(()=>{for(let p of l.rules)d(p);d(l.post)});function d(p){(0,eh.shouldUseGroup)(o,p)&&(p.type?(i.if((0,Cl.checkDataType)(p.type,s,u.strictNumbers)),mk(e,p),t.length===1&&t[0]===p.type&&r&&(i.else(),(0,Cl.reportTypeError)(e)),i.endIf()):mk(e,p),a||i.if((0,L._)`${Q.default.errors} === ${n||0}`))}}function mk(e,t){let{gen:r,schema:n,opts:{useDefaults:i}}=e;i&&(0,KR.assignDefaults)(e,t.type),r.block(()=>{for(let o of t.rules)(0,eh.shouldUseRule)(n,o)&&kk(e,o.keyword,o.definition,t.type)})}function dI(e,t){e.schemaEnv.meta||!e.opts.strictTypes||(fI(e,t),e.opts.allowUnionTypes||mI(e,t),pI(e,e.dataTypes))}function fI(e,t){if(t.length){if(!e.dataTypes.length){e.dataTypes=t;return}t.forEach(r=>{wk(e.dataTypes,r)||th(e,`type "${r}" not allowed by context "${e.dataTypes.join(",")}"`)}),gI(e,t)}}function mI(e,t){t.length>1&&!(t.length===2&&t.includes("null"))&&th(e,"use allowUnionTypes to allow union type keyword")}function pI(e,t){let r=e.self.RULES.all;for(let n in r){let i=r[n];if(typeof i=="object"&&(0,eh.shouldUseRule)(e.schema,i)){let{type:o}=i.definition;o.length&&!o.some(s=>hI(t,s))&&th(e,`missing type "${o.join(",")}" for keyword "${n}"`)}}}function hI(e,t){return e.includes(t)||t==="number"&&e.includes("integer")}function wk(e,t){return e.includes(t)||t==="integer"&&e.includes("number")}function gI(e,t){let r=[];for(let n of e.dataTypes)wk(t,n)?r.push(n):t.includes("integer")&&n==="number"&&r.push("integer");e.dataTypes=r}function th(e,t){let r=e.schemaEnv.baseId+e.errSchemaPath;t+=` at "${r}" (strictTypes)`,(0,vn.checkStrictMode)(e,t,e.opts.strictTypes)}var Rl=class{constructor(t,r,n){if((0,pa.validateKeywordUsage)(t,r,n),this.gen=t.gen,this.allErrors=t.allErrors,this.keyword=n,this.data=t.data,this.schema=t.schema[n],this.$data=r.$data&&t.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,vn.schemaRefOrVal)(t,this.schema,n,this.$data),this.schemaType=r.schemaType,this.parentSchema=t.schema,this.params={},this.it=t,this.def=r,this.$data)this.schemaCode=t.gen.const("vSchema",xk(this.$data,t));else if(this.schemaCode=this.schemaValue,!(0,pa.validSchemaType)(this.schema,r.schemaType,r.allowUndefined))throw new Error(`${n} value must be ${JSON.stringify(r.schemaType)}`);("code"in r?r.trackErrors:r.errors!==!1)&&(this.errsCount=t.gen.const("_errs",Q.default.errors))}result(t,r,n){this.failResult((0,L.not)(t),r,n)}failResult(t,r,n){this.gen.if(t),n?n():this.error(),r?(this.gen.else(),r(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(t,r){this.failResult((0,L.not)(t),void 0,r)}fail(t){if(t===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(t),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(t){if(!this.$data)return this.fail(t);let{schemaCode:r}=this;this.fail((0,L._)`${r} !== undefined && (${(0,L.or)(this.invalid$data(),t)})`)}error(t,r,n){if(r){this.setParams(r),this._error(t,n),this.setParams({});return}this._error(t,n)}_error(t,r){(t?ma.reportExtraError:ma.reportError)(this,this.def.error,r)}$dataError(){(0,ma.reportError)(this,this.def.$dataError||ma.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,ma.resetErrorsCount)(this.gen,this.errsCount)}ok(t){this.allErrors||this.gen.if(t)}setParams(t,r){r?Object.assign(this.params,t):this.params=t}block$data(t,r,n=L.nil){this.gen.block(()=>{this.check$data(t,n),r()})}check$data(t=L.nil,r=L.nil){if(!this.$data)return;let{gen:n,schemaCode:i,schemaType:o,def:s}=this;n.if((0,L.or)((0,L._)`${i} === undefined`,r)),t!==L.nil&&n.assign(t,!0),(o.length||s.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),t!==L.nil&&n.assign(t,!1)),n.else()}invalid$data(){let{gen:t,schemaCode:r,schemaType:n,def:i,it:o}=this;return(0,L.or)(s(),a());function s(){if(n.length){if(!(r instanceof L.Name))throw new Error("ajv implementation error");let u=Array.isArray(n)?n:[n];return(0,L._)`${(0,Cl.checkDataTypes)(u,r,o.opts.strictNumbers,Cl.DataType.Wrong)}`}return L.nil}function a(){if(i.validateSchema){let u=t.scopeValue("validate$data",{ref:i.validateSchema});return(0,L._)`!${u}(${r})`}return L.nil}}subschema(t,r){let n=(0,Yp.getSubschema)(this.it,t);(0,Yp.extendSubschemaData)(n,this.it,t),(0,Yp.extendSubschemaMode)(n,t);let i={...this.it,...n,items:void 0,props:void 0};return nI(i,r),i}mergeEvaluated(t,r){let{it:n,gen:i}=this;n.opts.unevaluated&&(n.props!==!0&&t.props!==void 0&&(n.props=vn.mergeEvaluated.props(i,t.props,n.props,r)),n.items!==!0&&t.items!==void 0&&(n.items=vn.mergeEvaluated.items(i,t.items,n.items,r)))}mergeValidEvaluated(t,r){let{it:n,gen:i}=this;if(n.opts.unevaluated&&(n.props!==!0||n.items!==!0))return i.if(r,()=>this.mergeEvaluated(t,L.Name)),!0}};Qn.KeywordCxt=Rl;function kk(e,t,r,n){let i=new Rl(e,r,t);"code"in r?r.code(i,n):i.$data&&r.validate?(0,pa.funcKeywordCode)(i,r):"macro"in r?(0,pa.macroKeywordCode)(i,r):(r.compile||r.validate)&&(0,pa.funcKeywordCode)(i,r)}var _I=/^\/(?:[^~]|~0|~1)*$/,yI=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function xk(e,{dataLevel:t,dataNames:r,dataPathArr:n}){let i,o;if(e==="")return Q.default.rootData;if(e[0]==="/"){if(!_I.test(e))throw new Error(`Invalid JSON-pointer: ${e}`);i=e,o=Q.default.rootData}else{let c=yI.exec(e);if(!c)throw new Error(`Invalid JSON-pointer: ${e}`);let l=+c[1];if(i=c[2],i==="#"){if(l>=t)throw new Error(u("property/index",l));return n[t-l]}if(l>t)throw new Error(u("data",l));if(o=r[t-l],!i)return o}let s=o,a=i.split("/");for(let c of a)c&&(o=(0,L._)`${o}${(0,L.getProperty)((0,vn.unescapeJsonPointer)(c))}`,s=(0,L._)`${s} && ${o}`);return s;function u(c,l){return`Cannot access ${c} ${l} levels up, current level is ${t}`}}Qn.getData=xk});var Il=z(nh=>{"use strict";Object.defineProperty(nh,"__esModule",{value:!0});var rh=class extends Error{constructor(t){super("validation failed"),this.errors=t,this.ajv=this.validation=!0}};nh.default=rh});var ga=z(sh=>{"use strict";Object.defineProperty(sh,"__esModule",{value:!0});var ih=fa(),oh=class extends Error{constructor(t,r,n,i){super(i||`can't resolve reference ${n} from id ${r}`),this.missingRef=(0,ih.resolveUrl)(t,r,n),this.missingSchema=(0,ih.normalizeId)((0,ih.getFullPath)(t,this.missingRef))}};sh.default=oh});var Nl=z(_r=>{"use strict";Object.defineProperty(_r,"__esModule",{value:!0});_r.resolveSchema=_r.getCompilingSchema=_r.resolveRef=_r.compileSchema=_r.SchemaEnv=void 0;var Or=ie(),vI=Il(),Hi=yn(),Pr=fa(),Sk=_e(),bI=ha(),Wo=class{constructor(t){var r;this.refs={},this.dynamicAnchors={};let n;typeof t.schema=="object"&&(n=t.schema),this.schema=t.schema,this.schemaId=t.schemaId,this.root=t.root||this,this.baseId=(r=t.baseId)!==null&&r!==void 0?r:(0,Pr.normalizeId)(n?.[t.schemaId||"$id"]),this.schemaPath=t.schemaPath,this.localRefs=t.localRefs,this.meta=t.meta,this.$async=n?.$async,this.refs={}}};_r.SchemaEnv=Wo;function ch(e){let t=Tk.call(this,e);if(t)return t;let r=(0,Pr.getFullPath)(this.opts.uriResolver,e.root.baseId),{es5:n,lines:i}=this.opts.code,{ownProperties:o}=this.opts,s=new Or.CodeGen(this.scope,{es5:n,lines:i,ownProperties:o}),a;e.$async&&(a=s.scopeValue("Error",{ref:vI.default,code:(0,Or._)`require("ajv/dist/runtime/validation_error").default`}));let u=s.scopeName("validate");e.validateName=u;let c={gen:s,allErrors:this.opts.allErrors,data:Hi.default.data,parentData:Hi.default.parentData,parentDataProperty:Hi.default.parentDataProperty,dataNames:[Hi.default.data],dataPathArr:[Or.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:s.scopeValue("schema",this.opts.code.source===!0?{ref:e.schema,code:(0,Or.stringify)(e.schema)}:{ref:e.schema}),validateName:u,ValidationError:a,schema:e.schema,schemaEnv:e,rootId:r,baseId:e.baseId||r,schemaPath:Or.nil,errSchemaPath:e.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,Or._)`""`,opts:this.opts,self:this},l;try{this._compilations.add(e),(0,bI.validateFunctionCode)(c),s.optimize(this.opts.code.optimize);let d=s.toString();l=`${s.scopeRefs(Hi.default.scope)}return ${d}`,this.opts.code.process&&(l=this.opts.code.process(l,e));let f=new Function(`${Hi.default.self}`,`${Hi.default.scope}`,l)(this,this.scope.get());if(this.scope.value(u,{ref:f}),f.errors=null,f.schema=e.schema,f.schemaEnv=e,e.$async&&(f.$async=!0),this.opts.code.source===!0&&(f.source={validateName:u,validateCode:d,scopeValues:s._values}),this.opts.unevaluated){let{props:h,items:m}=c;f.evaluated={props:h instanceof Or.Name?void 0:h,items:m instanceof Or.Name?void 0:m,dynamicProps:h instanceof Or.Name,dynamicItems:m instanceof Or.Name},f.source&&(f.source.evaluated=(0,Or.stringify)(f.evaluated))}return e.validate=f,e}catch(d){throw delete e.validate,delete e.validateName,l&&this.logger.error("Error compiling schema, function code:",l),d}finally{this._compilations.delete(e)}}_r.compileSchema=ch;function wI(e,t,r){var n;r=(0,Pr.resolveUrl)(this.opts.uriResolver,t,r);let i=e.refs[r];if(i)return i;let o=SI.call(this,e,r);if(o===void 0){let s=(n=e.localRefs)===null||n===void 0?void 0:n[r],{schemaId:a}=this.opts;s&&(o=new Wo({schema:s,schemaId:a,root:e,baseId:t}))}if(o!==void 0)return e.refs[r]=kI.call(this,o)}_r.resolveRef=wI;function kI(e){return(0,Pr.inlineRef)(e.schema,this.opts.inlineRefs)?e.schema:e.validate?e:ch.call(this,e)}function Tk(e){for(let t of this._compilations)if(xI(t,e))return t}_r.getCompilingSchema=Tk;function xI(e,t){return e.schema===t.schema&&e.root===t.root&&e.baseId===t.baseId}function SI(e,t){let r;for(;typeof(r=this.refs[t])=="string";)t=r;return r||this.schemas[t]||jl.call(this,e,t)}function jl(e,t){let r=this.opts.uriResolver.parse(t),n=(0,Pr._getFullPath)(this.opts.uriResolver,r),i=(0,Pr.getFullPath)(this.opts.uriResolver,e.baseId,void 0);if(Object.keys(e.schema).length>0&&n===i)return ah.call(this,r,e);let o=(0,Pr.normalizeId)(n),s=this.refs[o]||this.schemas[o];if(typeof s=="string"){let a=jl.call(this,e,s);return typeof a?.schema!="object"?void 0:ah.call(this,r,a)}if(typeof s?.schema=="object"){if(s.validate||ch.call(this,s),o===(0,Pr.normalizeId)(t)){let{schema:a}=s,{schemaId:u}=this.opts,c=a[u];return c&&(i=(0,Pr.resolveUrl)(this.opts.uriResolver,i,c)),new Wo({schema:a,schemaId:u,root:e,baseId:i})}return ah.call(this,r,s)}}_r.resolveSchema=jl;var TI=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function ah(e,{baseId:t,schema:r,root:n}){var i;if(((i=e.fragment)===null||i===void 0?void 0:i[0])!=="/")return;for(let a of e.fragment.slice(1).split("/")){if(typeof r=="boolean")return;let u=r[(0,Sk.unescapeFragment)(a)];if(u===void 0)return;r=u;let c=typeof r=="object"&&r[this.opts.schemaId];!TI.has(a)&&c&&(t=(0,Pr.resolveUrl)(this.opts.uriResolver,t,c))}let o;if(typeof r!="boolean"&&r.$ref&&!(0,Sk.schemaHasRulesButRef)(r,this.RULES)){let a=(0,Pr.resolveUrl)(this.opts.uriResolver,t,r.$ref);o=jl.call(this,n,a)}let{schemaId:s}=this.opts;if(o=o||new Wo({schema:r,schemaId:s,root:n,baseId:t}),o.schema!==o.root.schema)return o}});var $k=z((WF,$I)=>{$I.exports={$id:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",description:"Meta-schema for $data reference (JSON AnySchema extension proposal)",type:"object",required:["$data"],properties:{$data:{type:"string",anyOf:[{format:"relative-json-pointer"},{format:"json-pointer"}]}},additionalProperties:!1}});var uh=z((JF,Ok)=>{"use strict";var EI=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),zk=RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u);function lh(e){let t="",r=0,n=0;for(n=0;n<e.length;n++)if(r=e[n].charCodeAt(0),r!==48){if(!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";t+=e[n];break}for(n+=1;n<e.length;n++){if(r=e[n].charCodeAt(0),!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";t+=e[n]}return t}var zI=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function Ek(e){return e.length=0,!0}function AI(e,t,r){if(e.length){let n=lh(e);if(n!=="")t.push(n);else return r.error=!0,!1;e.length=0}return!0}function OI(e){let t=0,r={error:!1,address:"",zone:""},n=[],i=[],o=!1,s=!1,a=AI;for(let u=0;u<e.length;u++){let c=e[u];if(!(c==="["||c==="]"))if(c===":"){if(o===!0&&(s=!0),!a(i,n,r))break;if(++t>7){r.error=!0;break}u>0&&e[u-1]===":"&&(o=!0),n.push(":");continue}else if(c==="%"){if(!a(i,n,r))break;a=Ek}else{i.push(c);continue}}return i.length&&(a===Ek?r.zone=i.join(""):s?n.push(i.join("")):n.push(lh(i))),r.address=n.join(""),r}function Ak(e){if(PI(e,":")<2)return{host:e,isIPV6:!1};let t=OI(e);if(t.error)return{host:e,isIPV6:!1};{let r=t.address,n=t.address;return t.zone&&(r+="%"+t.zone,n+="%25"+t.zone),{host:r,isIPV6:!0,escapedHost:n}}}function PI(e,t){let r=0;for(let n=0;n<e.length;n++)e[n]===t&&r++;return r}function CI(e){let t=e,r=[],n=-1,i=0;for(;i=t.length;){if(i===1){if(t===".")break;if(t==="/"){r.push("/");break}else{r.push(t);break}}else if(i===2){if(t[0]==="."){if(t[1]===".")break;if(t[1]==="/"){t=t.slice(2);continue}}else if(t[0]==="/"&&(t[1]==="."||t[1]==="/")){r.push("/");break}}else if(i===3&&t==="/.."){r.length!==0&&r.pop(),r.push("/");break}if(t[0]==="."){if(t[1]==="."){if(t[2]==="/"){t=t.slice(3);continue}}else if(t[1]==="/"){t=t.slice(2);continue}}else if(t[0]==="/"&&t[1]==="."){if(t[2]==="/"){t=t.slice(2);continue}else if(t[2]==="."&&t[3]==="/"){t=t.slice(3),r.length!==0&&r.pop();continue}}if((n=t.indexOf("/",1))===-1){r.push(t);break}else r.push(t.slice(0,n)),t=t.slice(n)}return r.join("")}function RI(e,t){let r=t!==!0?escape:unescape;return e.scheme!==void 0&&(e.scheme=r(e.scheme)),e.userinfo!==void 0&&(e.userinfo=r(e.userinfo)),e.host!==void 0&&(e.host=r(e.host)),e.path!==void 0&&(e.path=r(e.path)),e.query!==void 0&&(e.query=r(e.query)),e.fragment!==void 0&&(e.fragment=r(e.fragment)),e}function II(e){let t=[];if(e.userinfo!==void 0&&(t.push(e.userinfo),t.push("@")),e.host!==void 0){let r=unescape(e.host);if(!zk(r)){let n=Ak(r);n.isIPV6===!0?r=`[${n.escapedHost}]`:r=e.host}t.push(r)}return(typeof e.port=="number"||typeof e.port=="string")&&(t.push(":"),t.push(String(e.port))),t.length?t.join(""):void 0}Ok.exports={nonSimpleDomain:zI,recomposeAuthority:II,normalizeComponentEncoding:RI,removeDotSegments:CI,isIPv4:zk,isUUID:EI,normalizeIPv6:Ak,stringArrayToHexStripped:lh}});var jk=z((HF,Ik)=>{"use strict";var{isUUID:jI}=uh(),NI=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu,MI=["http","https","ws","wss","urn","urn:uuid"];function DI(e){return MI.indexOf(e)!==-1}function dh(e){return e.secure===!0?!0:e.secure===!1?!1:e.scheme?e.scheme.length===3&&(e.scheme[0]==="w"||e.scheme[0]==="W")&&(e.scheme[1]==="s"||e.scheme[1]==="S")&&(e.scheme[2]==="s"||e.scheme[2]==="S"):!1}function Pk(e){return e.host||(e.error=e.error||"HTTP URIs must have a host."),e}function Ck(e){let t=String(e.scheme).toLowerCase()==="https";return(e.port===(t?443:80)||e.port==="")&&(e.port=void 0),e.path||(e.path="/"),e}function GI(e){return e.secure=dh(e),e.resourceName=(e.path||"/")+(e.query?"?"+e.query:""),e.path=void 0,e.query=void 0,e}function ZI(e){if((e.port===(dh(e)?443:80)||e.port==="")&&(e.port=void 0),typeof e.secure=="boolean"&&(e.scheme=e.secure?"wss":"ws",e.secure=void 0),e.resourceName){let[t,r]=e.resourceName.split("?");e.path=t&&t!=="/"?t:void 0,e.query=r,e.resourceName=void 0}return e.fragment=void 0,e}function FI(e,t){if(!e.path)return e.error="URN can not be parsed",e;let r=e.path.match(NI);if(r){let n=t.scheme||e.scheme||"urn";e.nid=r[1].toLowerCase(),e.nss=r[2];let i=`${n}:${t.nid||e.nid}`,o=fh(i);e.path=void 0,o&&(e=o.parse(e,t))}else e.error=e.error||"URN can not be parsed.";return e}function qI(e,t){if(e.nid===void 0)throw new Error("URN without nid cannot be serialized");let r=t.scheme||e.scheme||"urn",n=e.nid.toLowerCase(),i=`${r}:${t.nid||n}`,o=fh(i);o&&(e=o.serialize(e,t));let s=e,a=e.nss;return s.path=`${n||t.nid}:${a}`,t.skipEscape=!0,s}function LI(e,t){let r=e;return r.uuid=r.nss,r.nss=void 0,!t.tolerant&&(!r.uuid||!jI(r.uuid))&&(r.error=r.error||"UUID is not valid."),r}function UI(e){let t=e;return t.nss=(e.uuid||"").toLowerCase(),t}var Rk={scheme:"http",domainHost:!0,parse:Pk,serialize:Ck},VI={scheme:"https",domainHost:Rk.domainHost,parse:Pk,serialize:Ck},Ml={scheme:"ws",domainHost:!0,parse:GI,serialize:ZI},BI={scheme:"wss",domainHost:Ml.domainHost,parse:Ml.parse,serialize:Ml.serialize},WI={scheme:"urn",parse:FI,serialize:qI,skipNormalize:!0},JI={scheme:"urn:uuid",parse:LI,serialize:UI,skipNormalize:!0},Dl={http:Rk,https:VI,ws:Ml,wss:BI,urn:WI,"urn:uuid":JI};Object.setPrototypeOf(Dl,null);function fh(e){return e&&(Dl[e]||Dl[e.toLowerCase()])||void 0}Ik.exports={wsIsSecure:dh,SCHEMES:Dl,isValidSchemeName:DI,getSchemeHandler:fh}});var Dk=z((KF,Zl)=>{"use strict";var{normalizeIPv6:HI,removeDotSegments:_a,recomposeAuthority:KI,normalizeComponentEncoding:Gl,isIPv4:QI,nonSimpleDomain:XI}=uh(),{SCHEMES:YI,getSchemeHandler:Nk}=jk();function ej(e,t){return typeof e=="string"?e=Xr(bn(e,t),t):typeof e=="object"&&(e=bn(Xr(e,t),t)),e}function tj(e,t,r){let n=r?Object.assign({scheme:"null"},r):{scheme:"null"},i=Mk(bn(e,n),bn(t,n),n,!0);return n.skipEscape=!0,Xr(i,n)}function Mk(e,t,r,n){let i={};return n||(e=bn(Xr(e,r),r),t=bn(Xr(t,r),r)),r=r||{},!r.tolerant&&t.scheme?(i.scheme=t.scheme,i.userinfo=t.userinfo,i.host=t.host,i.port=t.port,i.path=_a(t.path||""),i.query=t.query):(t.userinfo!==void 0||t.host!==void 0||t.port!==void 0?(i.userinfo=t.userinfo,i.host=t.host,i.port=t.port,i.path=_a(t.path||""),i.query=t.query):(t.path?(t.path[0]==="/"?i.path=_a(t.path):((e.userinfo!==void 0||e.host!==void 0||e.port!==void 0)&&!e.path?i.path="/"+t.path:e.path?i.path=e.path.slice(0,e.path.lastIndexOf("/")+1)+t.path:i.path=t.path,i.path=_a(i.path)),i.query=t.query):(i.path=e.path,t.query!==void 0?i.query=t.query:i.query=e.query),i.userinfo=e.userinfo,i.host=e.host,i.port=e.port),i.scheme=e.scheme),i.fragment=t.fragment,i}function rj(e,t,r){return typeof e=="string"?(e=unescape(e),e=Xr(Gl(bn(e,r),!0),{...r,skipEscape:!0})):typeof e=="object"&&(e=Xr(Gl(e,!0),{...r,skipEscape:!0})),typeof t=="string"?(t=unescape(t),t=Xr(Gl(bn(t,r),!0),{...r,skipEscape:!0})):typeof t=="object"&&(t=Xr(Gl(t,!0),{...r,skipEscape:!0})),e.toLowerCase()===t.toLowerCase()}function Xr(e,t){let r={host:e.host,scheme:e.scheme,userinfo:e.userinfo,port:e.port,path:e.path,query:e.query,nid:e.nid,nss:e.nss,uuid:e.uuid,fragment:e.fragment,reference:e.reference,resourceName:e.resourceName,secure:e.secure,error:""},n=Object.assign({},t),i=[],o=Nk(n.scheme||r.scheme);o&&o.serialize&&o.serialize(r,n),r.path!==void 0&&(n.skipEscape?r.path=unescape(r.path):(r.path=escape(r.path),r.scheme!==void 0&&(r.path=r.path.split("%3A").join(":")))),n.reference!=="suffix"&&r.scheme&&i.push(r.scheme,":");let s=KI(r);if(s!==void 0&&(n.reference!=="suffix"&&i.push("//"),i.push(s),r.path&&r.path[0]!=="/"&&i.push("/")),r.path!==void 0){let a=r.path;!n.absolutePath&&(!o||!o.absolutePath)&&(a=_a(a)),s===void 0&&a[0]==="/"&&a[1]==="/"&&(a="/%2F"+a.slice(2)),i.push(a)}return r.query!==void 0&&i.push("?",r.query),r.fragment!==void 0&&i.push("#",r.fragment),i.join("")}var nj=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;function bn(e,t){let r=Object.assign({},t),n={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0},i=!1;r.reference==="suffix"&&(r.scheme?e=r.scheme+":"+e:e="//"+e);let o=e.match(nj);if(o){if(n.scheme=o[1],n.userinfo=o[3],n.host=o[4],n.port=parseInt(o[5],10),n.path=o[6]||"",n.query=o[7],n.fragment=o[8],isNaN(n.port)&&(n.port=o[5]),n.host)if(QI(n.host)===!1){let u=HI(n.host);n.host=u.host.toLowerCase(),i=u.isIPV6}else i=!0;n.scheme===void 0&&n.userinfo===void 0&&n.host===void 0&&n.port===void 0&&n.query===void 0&&!n.path?n.reference="same-document":n.scheme===void 0?n.reference="relative":n.fragment===void 0?n.reference="absolute":n.reference="uri",r.reference&&r.reference!=="suffix"&&r.reference!==n.reference&&(n.error=n.error||"URI is not a "+r.reference+" reference.");let s=Nk(r.scheme||n.scheme);if(!r.unicodeSupport&&(!s||!s.unicodeSupport)&&n.host&&(r.domainHost||s&&s.domainHost)&&i===!1&&XI(n.host))try{n.host=URL.domainToASCII(n.host.toLowerCase())}catch(a){n.error=n.error||"Host's domain name can not be converted to ASCII: "+a}(!s||s&&!s.skipNormalize)&&(e.indexOf("%")!==-1&&(n.scheme!==void 0&&(n.scheme=unescape(n.scheme)),n.host!==void 0&&(n.host=unescape(n.host))),n.path&&(n.path=escape(unescape(n.path))),n.fragment&&(n.fragment=encodeURI(decodeURIComponent(n.fragment)))),s&&s.parse&&s.parse(n,r)}else n.error=n.error||"URI can not be parsed.";return n}var mh={SCHEMES:YI,normalize:ej,resolve:tj,resolveComponent:Mk,equal:rj,serialize:Xr,parse:bn};Zl.exports=mh;Zl.exports.default=mh;Zl.exports.fastUri=mh});var Zk=z(ph=>{"use strict";Object.defineProperty(ph,"__esModule",{value:!0});var Gk=Dk();Gk.code='require("ajv/dist/runtime/uri").default';ph.default=Gk});var Jk=z(wt=>{"use strict";Object.defineProperty(wt,"__esModule",{value:!0});wt.CodeGen=wt.Name=wt.nil=wt.stringify=wt.str=wt._=wt.KeywordCxt=void 0;var ij=ha();Object.defineProperty(wt,"KeywordCxt",{enumerable:!0,get:function(){return ij.KeywordCxt}});var Jo=ie();Object.defineProperty(wt,"_",{enumerable:!0,get:function(){return Jo._}});Object.defineProperty(wt,"str",{enumerable:!0,get:function(){return Jo.str}});Object.defineProperty(wt,"stringify",{enumerable:!0,get:function(){return Jo.stringify}});Object.defineProperty(wt,"nil",{enumerable:!0,get:function(){return Jo.nil}});Object.defineProperty(wt,"Name",{enumerable:!0,get:function(){return Jo.Name}});Object.defineProperty(wt,"CodeGen",{enumerable:!0,get:function(){return Jo.CodeGen}});var oj=Il(),Vk=ga(),sj=Lp(),ya=Nl(),aj=ie(),va=fa(),Fl=da(),gh=_e(),Fk=$k(),cj=Zk(),Bk=(e,t)=>new RegExp(e,t);Bk.code="new RegExp";var lj=["removeAdditional","useDefaults","coerceTypes"],uj=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),dj={errorDataPath:"",format:"`validateFormats: false` can be used instead.",nullable:'"nullable" keyword is supported by default.',jsonPointers:"Deprecated jsPropertySyntax can be used instead.",extendRefs:"Deprecated ignoreKeywordsWithRef can be used instead.",missingRefs:"Pass empty schema with $id that should be ignored to ajv.addSchema.",processCode:"Use option `code: {process: (code, schemaEnv: object) => string}`",sourceCode:"Use option `code: {source: true}`",strictDefaults:"It is default now, see option `strict`.",strictKeywords:"It is default now, see option `strict`.",uniqueItems:'"uniqueItems" keyword is always validated.',unknownFormats:"Disable strict mode or pass `true` to `ajv.addFormat` (or `formats` option).",cache:"Map is used as cache, schema object as key.",serialize:"Map is used as cache, schema object as key.",ajvErrors:"It is default now."},fj={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},qk=200;function mj(e){var t,r,n,i,o,s,a,u,c,l,d,p,f,h,m,g,y,v,b,w,S,R,X,be,D;let I=e.strict,B=(t=e.code)===null||t===void 0?void 0:t.optimize,re=B===!0||B===void 0?1:B||0,le=(n=(r=e.code)===null||r===void 0?void 0:r.regExp)!==null&&n!==void 0?n:Bk,j=(i=e.uriResolver)!==null&&i!==void 0?i:cj.default;return{strictSchema:(s=(o=e.strictSchema)!==null&&o!==void 0?o:I)!==null&&s!==void 0?s:!0,strictNumbers:(u=(a=e.strictNumbers)!==null&&a!==void 0?a:I)!==null&&u!==void 0?u:!0,strictTypes:(l=(c=e.strictTypes)!==null&&c!==void 0?c:I)!==null&&l!==void 0?l:"log",strictTuples:(p=(d=e.strictTuples)!==null&&d!==void 0?d:I)!==null&&p!==void 0?p:"log",strictRequired:(h=(f=e.strictRequired)!==null&&f!==void 0?f:I)!==null&&h!==void 0?h:!1,code:e.code?{...e.code,optimize:re,regExp:le}:{optimize:re,regExp:le},loopRequired:(m=e.loopRequired)!==null&&m!==void 0?m:qk,loopEnum:(g=e.loopEnum)!==null&&g!==void 0?g:qk,meta:(y=e.meta)!==null&&y!==void 0?y:!0,messages:(v=e.messages)!==null&&v!==void 0?v:!0,inlineRefs:(b=e.inlineRefs)!==null&&b!==void 0?b:!0,schemaId:(w=e.schemaId)!==null&&w!==void 0?w:"$id",addUsedSchema:(S=e.addUsedSchema)!==null&&S!==void 0?S:!0,validateSchema:(R=e.validateSchema)!==null&&R!==void 0?R:!0,validateFormats:(X=e.validateFormats)!==null&&X!==void 0?X:!0,unicodeRegExp:(be=e.unicodeRegExp)!==null&&be!==void 0?be:!0,int32range:(D=e.int32range)!==null&&D!==void 0?D:!0,uriResolver:j}}var ba=class{constructor(t={}){this.schemas={},this.refs={},this.formats={},this._compilations=new Set,this._loading={},this._cache=new Map,t=this.opts={...t,...mj(t)};let{es5:r,lines:n}=this.opts.code;this.scope=new aj.ValueScope({scope:{},prefixes:uj,es5:r,lines:n}),this.logger=vj(t.logger);let i=t.validateFormats;t.validateFormats=!1,this.RULES=(0,sj.getRules)(),Lk.call(this,dj,t,"NOT SUPPORTED"),Lk.call(this,fj,t,"DEPRECATED","warn"),this._metaOpts=_j.call(this),t.formats&&hj.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),t.keywords&&gj.call(this,t.keywords),typeof t.meta=="object"&&this.addMetaSchema(t.meta),pj.call(this),t.validateFormats=i}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){let{$data:t,meta:r,schemaId:n}=this.opts,i=Fk;n==="id"&&(i={...Fk},i.id=i.$id,delete i.$id),r&&t&&this.addMetaSchema(i,i[n],!1)}defaultMeta(){let{meta:t,schemaId:r}=this.opts;return this.opts.defaultMeta=typeof t=="object"?t[r]||t:void 0}validate(t,r){let n;if(typeof t=="string"){if(n=this.getSchema(t),!n)throw new Error(`no schema with key or ref "${t}"`)}else n=this.compile(t);let i=n(r);return"$async"in n||(this.errors=n.errors),i}compile(t,r){let n=this._addSchema(t,r);return n.validate||this._compileSchemaEnv(n)}compileAsync(t,r){if(typeof this.opts.loadSchema!="function")throw new Error("options.loadSchema should be a function");let{loadSchema:n}=this.opts;return i.call(this,t,r);async function i(l,d){await o.call(this,l.$schema);let p=this._addSchema(l,d);return p.validate||s.call(this,p)}async function o(l){l&&!this.getSchema(l)&&await i.call(this,{$ref:l},!0)}async function s(l){try{return this._compileSchemaEnv(l)}catch(d){if(!(d instanceof Vk.default))throw d;return a.call(this,d),await u.call(this,d.missingSchema),s.call(this,l)}}function a({missingSchema:l,missingRef:d}){if(this.refs[l])throw new Error(`AnySchema ${l} is loaded but ${d} cannot be resolved`)}async function u(l){let d=await c.call(this,l);this.refs[l]||await o.call(this,d.$schema),this.refs[l]||this.addSchema(d,l,r)}async function c(l){let d=this._loading[l];if(d)return d;try{return await(this._loading[l]=n(l))}finally{delete this._loading[l]}}}addSchema(t,r,n,i=this.opts.validateSchema){if(Array.isArray(t)){for(let s of t)this.addSchema(s,void 0,n,i);return this}let o;if(typeof t=="object"){let{schemaId:s}=this.opts;if(o=t[s],o!==void 0&&typeof o!="string")throw new Error(`schema ${s} must be string`)}return r=(0,va.normalizeId)(r||o),this._checkUnique(r),this.schemas[r]=this._addSchema(t,n,r,i,!0),this}addMetaSchema(t,r,n=this.opts.validateSchema){return this.addSchema(t,r,!0,n),this}validateSchema(t,r){if(typeof t=="boolean")return!0;let n;if(n=t.$schema,n!==void 0&&typeof n!="string")throw new Error("$schema must be a string");if(n=n||this.opts.defaultMeta||this.defaultMeta(),!n)return this.logger.warn("meta-schema not available"),this.errors=null,!0;let i=this.validate(n,t);if(!i&&r){let o="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(o);else throw new Error(o)}return i}getSchema(t){let r;for(;typeof(r=Uk.call(this,t))=="string";)t=r;if(r===void 0){let{schemaId:n}=this.opts,i=new ya.SchemaEnv({schema:{},schemaId:n});if(r=ya.resolveSchema.call(this,i,t),!r)return;this.refs[t]=r}return r.validate||this._compileSchemaEnv(r)}removeSchema(t){if(t instanceof RegExp)return this._removeAllSchemas(this.schemas,t),this._removeAllSchemas(this.refs,t),this;switch(typeof t){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{let r=Uk.call(this,t);return typeof r=="object"&&this._cache.delete(r.schema),delete this.schemas[t],delete this.refs[t],this}case"object":{let r=t;this._cache.delete(r);let n=t[this.opts.schemaId];return n&&(n=(0,va.normalizeId)(n),delete this.schemas[n],delete this.refs[n]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(t){for(let r of t)this.addKeyword(r);return this}addKeyword(t,r){let n;if(typeof t=="string")n=t,typeof r=="object"&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),r.keyword=n);else if(typeof t=="object"&&r===void 0){if(r=t,n=r.keyword,Array.isArray(n)&&!n.length)throw new Error("addKeywords: keyword must be string or non-empty array")}else throw new Error("invalid addKeywords parameters");if(wj.call(this,n,r),!r)return(0,gh.eachItem)(n,o=>hh.call(this,o)),this;xj.call(this,r);let i={...r,type:(0,Fl.getJSONTypes)(r.type),schemaType:(0,Fl.getJSONTypes)(r.schemaType)};return(0,gh.eachItem)(n,i.type.length===0?o=>hh.call(this,o,i):o=>i.type.forEach(s=>hh.call(this,o,i,s))),this}getKeyword(t){let r=this.RULES.all[t];return typeof r=="object"?r.definition:!!r}removeKeyword(t){let{RULES:r}=this;delete r.keywords[t],delete r.all[t];for(let n of r.rules){let i=n.rules.findIndex(o=>o.keyword===t);i>=0&&n.rules.splice(i,1)}return this}addFormat(t,r){return typeof r=="string"&&(r=new RegExp(r)),this.formats[t]=r,this}errorsText(t=this.errors,{separator:r=", ",dataVar:n="data"}={}){return!t||t.length===0?"No errors":t.map(i=>`${n}${i.instancePath} ${i.message}`).reduce((i,o)=>i+r+o)}$dataMetaSchema(t,r){let n=this.RULES.all;t=JSON.parse(JSON.stringify(t));for(let i of r){let o=i.split("/").slice(1),s=t;for(let a of o)s=s[a];for(let a in n){let u=n[a];if(typeof u!="object")continue;let{$data:c}=u.definition,l=s[a];c&&l&&(s[a]=Wk(l))}}return t}_removeAllSchemas(t,r){for(let n in t){let i=t[n];(!r||r.test(n))&&(typeof i=="string"?delete t[n]:i&&!i.meta&&(this._cache.delete(i.schema),delete t[n]))}}_addSchema(t,r,n,i=this.opts.validateSchema,o=this.opts.addUsedSchema){let s,{schemaId:a}=this.opts;if(typeof t=="object")s=t[a];else{if(this.opts.jtd)throw new Error("schema must be object");if(typeof t!="boolean")throw new Error("schema must be object or boolean")}let u=this._cache.get(t);if(u!==void 0)return u;n=(0,va.normalizeId)(s||n);let c=va.getSchemaRefs.call(this,t,n);return u=new ya.SchemaEnv({schema:t,schemaId:a,meta:r,baseId:n,localRefs:c}),this._cache.set(u.schema,u),o&&!n.startsWith("#")&&(n&&this._checkUnique(n),this.refs[n]=u),i&&this.validateSchema(t,!0),u}_checkUnique(t){if(this.schemas[t]||this.refs[t])throw new Error(`schema with key or id "${t}" already exists`)}_compileSchemaEnv(t){if(t.meta?this._compileMetaSchema(t):ya.compileSchema.call(this,t),!t.validate)throw new Error("ajv implementation error");return t.validate}_compileMetaSchema(t){let r=this.opts;this.opts=this._metaOpts;try{ya.compileSchema.call(this,t)}finally{this.opts=r}}};ba.ValidationError=oj.default;ba.MissingRefError=Vk.default;wt.default=ba;function Lk(e,t,r,n="error"){for(let i in e){let o=i;o in t&&this.logger[n](`${r}: option ${i}. ${e[o]}`)}}function Uk(e){return e=(0,va.normalizeId)(e),this.schemas[e]||this.refs[e]}function pj(){let e=this.opts.schemas;if(e)if(Array.isArray(e))this.addSchema(e);else for(let t in e)this.addSchema(e[t],t)}function hj(){for(let e in this.opts.formats){let t=this.opts.formats[e];t&&this.addFormat(e,t)}}function gj(e){if(Array.isArray(e)){this.addVocabulary(e);return}this.logger.warn("keywords option as map is deprecated, pass array");for(let t in e){let r=e[t];r.keyword||(r.keyword=t),this.addKeyword(r)}}function _j(){let e={...this.opts};for(let t of lj)delete e[t];return e}var yj={log(){},warn(){},error(){}};function vj(e){if(e===!1)return yj;if(e===void 0)return console;if(e.log&&e.warn&&e.error)return e;throw new Error("logger must implement log, warn and error methods")}var bj=/^[a-z_$][a-z0-9_$:-]*$/i;function wj(e,t){let{RULES:r}=this;if((0,gh.eachItem)(e,n=>{if(r.keywords[n])throw new Error(`Keyword ${n} is already defined`);if(!bj.test(n))throw new Error(`Keyword ${n} has invalid name`)}),!!t&&t.$data&&!("code"in t||"validate"in t))throw new Error('$data keyword must have "code" or "validate" function')}function hh(e,t,r){var n;let i=t?.post;if(r&&i)throw new Error('keyword with "post" flag cannot have "type"');let{RULES:o}=this,s=i?o.post:o.rules.find(({type:u})=>u===r);if(s||(s={type:r,rules:[]},o.rules.push(s)),o.keywords[e]=!0,!t)return;let a={keyword:e,definition:{...t,type:(0,Fl.getJSONTypes)(t.type),schemaType:(0,Fl.getJSONTypes)(t.schemaType)}};t.before?kj.call(this,s,a,t.before):s.rules.push(a),o.all[e]=a,(n=t.implements)===null||n===void 0||n.forEach(u=>this.addKeyword(u))}function kj(e,t,r){let n=e.rules.findIndex(i=>i.keyword===r);n>=0?e.rules.splice(n,0,t):(e.rules.push(t),this.logger.warn(`rule ${r} is not defined`))}function xj(e){let{metaSchema:t}=e;t!==void 0&&(e.$data&&this.opts.$data&&(t=Wk(t)),e.validateSchema=this.compile(t,!0))}var Sj={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function Wk(e){return{anyOf:[e,Sj]}}});var Hk=z(_h=>{"use strict";Object.defineProperty(_h,"__esModule",{value:!0});var Tj={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};_h.default=Tj});var Yk=z(Ki=>{"use strict";Object.defineProperty(Ki,"__esModule",{value:!0});Ki.callRef=Ki.getValidate=void 0;var $j=ga(),Kk=gr(),Ht=ie(),Ho=yn(),Qk=Nl(),ql=_e(),Ej={keyword:"$ref",schemaType:"string",code(e){let{gen:t,schema:r,it:n}=e,{baseId:i,schemaEnv:o,validateName:s,opts:a,self:u}=n,{root:c}=o;if((r==="#"||r==="#/")&&i===c.baseId)return d();let l=Qk.resolveRef.call(u,c,i,r);if(l===void 0)throw new $j.default(n.opts.uriResolver,i,r);if(l instanceof Qk.SchemaEnv)return p(l);return f(l);function d(){if(o===c)return Ll(e,s,o,o.$async);let h=t.scopeValue("root",{ref:c});return Ll(e,(0,Ht._)`${h}.validate`,c,c.$async)}function p(h){let m=Xk(e,h);Ll(e,m,h,h.$async)}function f(h){let m=t.scopeValue("schema",a.code.source===!0?{ref:h,code:(0,Ht.stringify)(h)}:{ref:h}),g=t.name("valid"),y=e.subschema({schema:h,dataTypes:[],schemaPath:Ht.nil,topSchemaRef:m,errSchemaPath:r},g);e.mergeEvaluated(y),e.ok(g)}}};function Xk(e,t){let{gen:r}=e;return t.validate?r.scopeValue("validate",{ref:t.validate}):(0,Ht._)`${r.scopeValue("wrapper",{ref:t})}.validate`}Ki.getValidate=Xk;function Ll(e,t,r,n){let{gen:i,it:o}=e,{allErrors:s,schemaEnv:a,opts:u}=o,c=u.passContext?Ho.default.this:Ht.nil;n?l():d();function l(){if(!a.$async)throw new Error("async schema referenced by sync schema");let h=i.let("valid");i.try(()=>{i.code((0,Ht._)`await ${(0,Kk.callValidateCode)(e,t,c)}`),f(t),s||i.assign(h,!0)},m=>{i.if((0,Ht._)`!(${m} instanceof ${o.ValidationError})`,()=>i.throw(m)),p(m),s||i.assign(h,!1)}),e.ok(h)}function d(){e.result((0,Kk.callValidateCode)(e,t,c),()=>f(t),()=>p(t))}function p(h){let m=(0,Ht._)`${h}.errors`;i.assign(Ho.default.vErrors,(0,Ht._)`${Ho.default.vErrors} === null ? ${m} : ${Ho.default.vErrors}.concat(${m})`),i.assign(Ho.default.errors,(0,Ht._)`${Ho.default.vErrors}.length`)}function f(h){var m;if(!o.opts.unevaluated)return;let g=(m=r?.validate)===null||m===void 0?void 0:m.evaluated;if(o.props!==!0)if(g&&!g.dynamicProps)g.props!==void 0&&(o.props=ql.mergeEvaluated.props(i,g.props,o.props));else{let y=i.var("props",(0,Ht._)`${h}.evaluated.props`);o.props=ql.mergeEvaluated.props(i,y,o.props,Ht.Name)}if(o.items!==!0)if(g&&!g.dynamicItems)g.items!==void 0&&(o.items=ql.mergeEvaluated.items(i,g.items,o.items));else{let y=i.var("items",(0,Ht._)`${h}.evaluated.items`);o.items=ql.mergeEvaluated.items(i,y,o.items,Ht.Name)}}}Ki.callRef=Ll;Ki.default=Ej});var ex=z(yh=>{"use strict";Object.defineProperty(yh,"__esModule",{value:!0});var zj=Hk(),Aj=Yk(),Oj=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",zj.default,Aj.default];yh.default=Oj});var tx=z(vh=>{"use strict";Object.defineProperty(vh,"__esModule",{value:!0});var Ul=ie(),Xn=Ul.operators,Vl={maximum:{okStr:"<=",ok:Xn.LTE,fail:Xn.GT},minimum:{okStr:">=",ok:Xn.GTE,fail:Xn.LT},exclusiveMaximum:{okStr:"<",ok:Xn.LT,fail:Xn.GTE},exclusiveMinimum:{okStr:">",ok:Xn.GT,fail:Xn.LTE}},Pj={message:({keyword:e,schemaCode:t})=>(0,Ul.str)`must be ${Vl[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0,Ul._)`{comparison: ${Vl[e].okStr}, limit: ${t}}`},Cj={keyword:Object.keys(Vl),type:"number",schemaType:"number",$data:!0,error:Pj,code(e){let{keyword:t,data:r,schemaCode:n}=e;e.fail$data((0,Ul._)`${r} ${Vl[t].fail} ${n} || isNaN(${r})`)}};vh.default=Cj});var rx=z(bh=>{"use strict";Object.defineProperty(bh,"__esModule",{value:!0});var wa=ie(),Rj={message:({schemaCode:e})=>(0,wa.str)`must be multiple of ${e}`,params:({schemaCode:e})=>(0,wa._)`{multipleOf: ${e}}`},Ij={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:Rj,code(e){let{gen:t,data:r,schemaCode:n,it:i}=e,o=i.opts.multipleOfPrecision,s=t.let("res"),a=o?(0,wa._)`Math.abs(Math.round(${s}) - ${s}) > 1e-${o}`:(0,wa._)`${s} !== parseInt(${s})`;e.fail$data((0,wa._)`(${n} === 0 || (${s} = ${r}/${n}, ${a}))`)}};bh.default=Ij});var ix=z(wh=>{"use strict";Object.defineProperty(wh,"__esModule",{value:!0});function nx(e){let t=e.length,r=0,n=0,i;for(;n<t;)r++,i=e.charCodeAt(n++),i>=55296&&i<=56319&&n<t&&(i=e.charCodeAt(n),(i&64512)===56320&&n++);return r}wh.default=nx;nx.code='require("ajv/dist/runtime/ucs2length").default'});var ox=z(kh=>{"use strict";Object.defineProperty(kh,"__esModule",{value:!0});var Qi=ie(),jj=_e(),Nj=ix(),Mj={message({keyword:e,schemaCode:t}){let r=e==="maxLength"?"more":"fewer";return(0,Qi.str)`must NOT have ${r} than ${t} characters`},params:({schemaCode:e})=>(0,Qi._)`{limit: ${e}}`},Dj={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:Mj,code(e){let{keyword:t,data:r,schemaCode:n,it:i}=e,o=t==="maxLength"?Qi.operators.GT:Qi.operators.LT,s=i.opts.unicode===!1?(0,Qi._)`${r}.length`:(0,Qi._)`${(0,jj.useFunc)(e.gen,Nj.default)}(${r})`;e.fail$data((0,Qi._)`${s} ${o} ${n}`)}};kh.default=Dj});var sx=z(xh=>{"use strict";Object.defineProperty(xh,"__esModule",{value:!0});var Gj=gr(),Bl=ie(),Zj={message:({schemaCode:e})=>(0,Bl.str)`must match pattern "${e}"`,params:({schemaCode:e})=>(0,Bl._)`{pattern: ${e}}`},Fj={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:Zj,code(e){let{data:t,$data:r,schema:n,schemaCode:i,it:o}=e,s=o.opts.unicodeRegExp?"u":"",a=r?(0,Bl._)`(new RegExp(${i}, ${s}))`:(0,Gj.usePattern)(e,n);e.fail$data((0,Bl._)`!${a}.test(${t})`)}};xh.default=Fj});var ax=z(Sh=>{"use strict";Object.defineProperty(Sh,"__esModule",{value:!0});var ka=ie(),qj={message({keyword:e,schemaCode:t}){let r=e==="maxProperties"?"more":"fewer";return(0,ka.str)`must NOT have ${r} than ${t} properties`},params:({schemaCode:e})=>(0,ka._)`{limit: ${e}}`},Lj={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:qj,code(e){let{keyword:t,data:r,schemaCode:n}=e,i=t==="maxProperties"?ka.operators.GT:ka.operators.LT;e.fail$data((0,ka._)`Object.keys(${r}).length ${i} ${n}`)}};Sh.default=Lj});var cx=z(Th=>{"use strict";Object.defineProperty(Th,"__esModule",{value:!0});var xa=gr(),Sa=ie(),Uj=_e(),Vj={message:({params:{missingProperty:e}})=>(0,Sa.str)`must have required property '${e}'`,params:({params:{missingProperty:e}})=>(0,Sa._)`{missingProperty: ${e}}`},Bj={keyword:"required",type:"object",schemaType:"array",$data:!0,error:Vj,code(e){let{gen:t,schema:r,schemaCode:n,data:i,$data:o,it:s}=e,{opts:a}=s;if(!o&&r.length===0)return;let u=r.length>=a.loopRequired;if(s.allErrors?c():l(),a.strictRequired){let f=e.parentSchema.properties,{definedProperties:h}=e.it;for(let m of r)if(f?.[m]===void 0&&!h.has(m)){let g=s.schemaEnv.baseId+s.errSchemaPath,y=`required property "${m}" is not defined at "${g}" (strictRequired)`;(0,Uj.checkStrictMode)(s,y,s.opts.strictRequired)}}function c(){if(u||o)e.block$data(Sa.nil,d);else for(let f of r)(0,xa.checkReportMissingProp)(e,f)}function l(){let f=t.let("missing");if(u||o){let h=t.let("valid",!0);e.block$data(h,()=>p(f,h)),e.ok(h)}else t.if((0,xa.checkMissingProp)(e,r,f)),(0,xa.reportMissingProp)(e,f),t.else()}function d(){t.forOf("prop",n,f=>{e.setParams({missingProperty:f}),t.if((0,xa.noPropertyInData)(t,i,f,a.ownProperties),()=>e.error())})}function p(f,h){e.setParams({missingProperty:f}),t.forOf(f,n,()=>{t.assign(h,(0,xa.propertyInData)(t,i,f,a.ownProperties)),t.if((0,Sa.not)(h),()=>{e.error(),t.break()})},Sa.nil)}}};Th.default=Bj});var lx=z($h=>{"use strict";Object.defineProperty($h,"__esModule",{value:!0});var Ta=ie(),Wj={message({keyword:e,schemaCode:t}){let r=e==="maxItems"?"more":"fewer";return(0,Ta.str)`must NOT have ${r} than ${t} items`},params:({schemaCode:e})=>(0,Ta._)`{limit: ${e}}`},Jj={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:Wj,code(e){let{keyword:t,data:r,schemaCode:n}=e,i=t==="maxItems"?Ta.operators.GT:Ta.operators.LT;e.fail$data((0,Ta._)`${r}.length ${i} ${n}`)}};$h.default=Jj});var Wl=z(Eh=>{"use strict";Object.defineProperty(Eh,"__esModule",{value:!0});var ux=Qp();ux.code='require("ajv/dist/runtime/equal").default';Eh.default=ux});var dx=z(Ah=>{"use strict";Object.defineProperty(Ah,"__esModule",{value:!0});var zh=da(),kt=ie(),Hj=_e(),Kj=Wl(),Qj={message:({params:{i:e,j:t}})=>(0,kt.str)`must NOT have duplicate items (items ## ${t} and ${e} are identical)`,params:({params:{i:e,j:t}})=>(0,kt._)`{i: ${e}, j: ${t}}`},Xj={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:Qj,code(e){let{gen:t,data:r,$data:n,schema:i,parentSchema:o,schemaCode:s,it:a}=e;if(!n&&!i)return;let u=t.let("valid"),c=o.items?(0,zh.getSchemaTypes)(o.items):[];e.block$data(u,l,(0,kt._)`${s} === false`),e.ok(u);function l(){let h=t.let("i",(0,kt._)`${r}.length`),m=t.let("j");e.setParams({i:h,j:m}),t.assign(u,!0),t.if((0,kt._)`${h} > 1`,()=>(d()?p:f)(h,m))}function d(){return c.length>0&&!c.some(h=>h==="object"||h==="array")}function p(h,m){let g=t.name("item"),y=(0,zh.checkDataTypes)(c,g,a.opts.strictNumbers,zh.DataType.Wrong),v=t.const("indices",(0,kt._)`{}`);t.for((0,kt._)`;${h}--;`,()=>{t.let(g,(0,kt._)`${r}[${h}]`),t.if(y,(0,kt._)`continue`),c.length>1&&t.if((0,kt._)`typeof ${g} == "string"`,(0,kt._)`${g} += "_"`),t.if((0,kt._)`typeof ${v}[${g}] == "number"`,()=>{t.assign(m,(0,kt._)`${v}[${g}]`),e.error(),t.assign(u,!1).break()}).code((0,kt._)`${v}[${g}] = ${h}`)})}function f(h,m){let g=(0,Hj.useFunc)(t,Kj.default),y=t.name("outer");t.label(y).for((0,kt._)`;${h}--;`,()=>t.for((0,kt._)`${m} = ${h}; ${m}--;`,()=>t.if((0,kt._)`${g}(${r}[${h}], ${r}[${m}])`,()=>{e.error(),t.assign(u,!1).break(y)})))}}};Ah.default=Xj});var fx=z(Ph=>{"use strict";Object.defineProperty(Ph,"__esModule",{value:!0});var Oh=ie(),Yj=_e(),e2=Wl(),t2={message:"must be equal to constant",params:({schemaCode:e})=>(0,Oh._)`{allowedValue: ${e}}`},r2={keyword:"const",$data:!0,error:t2,code(e){let{gen:t,data:r,$data:n,schemaCode:i,schema:o}=e;n||o&&typeof o=="object"?e.fail$data((0,Oh._)`!${(0,Yj.useFunc)(t,e2.default)}(${r}, ${i})`):e.fail((0,Oh._)`${o} !== ${r}`)}};Ph.default=r2});var mx=z(Ch=>{"use strict";Object.defineProperty(Ch,"__esModule",{value:!0});var $a=ie(),n2=_e(),i2=Wl(),o2={message:"must be equal to one of the allowed values",params:({schemaCode:e})=>(0,$a._)`{allowedValues: ${e}}`},s2={keyword:"enum",schemaType:"array",$data:!0,error:o2,code(e){let{gen:t,data:r,$data:n,schema:i,schemaCode:o,it:s}=e;if(!n&&i.length===0)throw new Error("enum must have non-empty array");let a=i.length>=s.opts.loopEnum,u,c=()=>u??(u=(0,n2.useFunc)(t,i2.default)),l;if(a||n)l=t.let("valid"),e.block$data(l,d);else{if(!Array.isArray(i))throw new Error("ajv implementation error");let f=t.const("vSchema",o);l=(0,$a.or)(...i.map((h,m)=>p(f,m)))}e.pass(l);function d(){t.assign(l,!1),t.forOf("v",o,f=>t.if((0,$a._)`${c()}(${r}, ${f})`,()=>t.assign(l,!0).break()))}function p(f,h){let m=i[h];return typeof m=="object"&&m!==null?(0,$a._)`${c()}(${r}, ${f}[${h}])`:(0,$a._)`${r} === ${m}`}}};Ch.default=s2});var px=z(Rh=>{"use strict";Object.defineProperty(Rh,"__esModule",{value:!0});var a2=tx(),c2=rx(),l2=ox(),u2=sx(),d2=ax(),f2=cx(),m2=lx(),p2=dx(),h2=fx(),g2=mx(),_2=[a2.default,c2.default,l2.default,u2.default,d2.default,f2.default,m2.default,p2.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},h2.default,g2.default];Rh.default=_2});var jh=z(Ea=>{"use strict";Object.defineProperty(Ea,"__esModule",{value:!0});Ea.validateAdditionalItems=void 0;var Xi=ie(),Ih=_e(),y2={message:({params:{len:e}})=>(0,Xi.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,Xi._)`{limit: ${e}}`},v2={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:y2,code(e){let{parentSchema:t,it:r}=e,{items:n}=t;if(!Array.isArray(n)){(0,Ih.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas');return}hx(e,n)}};function hx(e,t){let{gen:r,schema:n,data:i,keyword:o,it:s}=e;s.items=!0;let a=r.const("len",(0,Xi._)`${i}.length`);if(n===!1)e.setParams({len:t.length}),e.pass((0,Xi._)`${a} <= ${t.length}`);else if(typeof n=="object"&&!(0,Ih.alwaysValidSchema)(s,n)){let c=r.var("valid",(0,Xi._)`${a} <= ${t.length}`);r.if((0,Xi.not)(c),()=>u(c)),e.ok(c)}function u(c){r.forRange("i",t.length,a,l=>{e.subschema({keyword:o,dataProp:l,dataPropType:Ih.Type.Num},c),s.allErrors||r.if((0,Xi.not)(c),()=>r.break())})}}Ea.validateAdditionalItems=hx;Ea.default=v2});var Nh=z(za=>{"use strict";Object.defineProperty(za,"__esModule",{value:!0});za.validateTuple=void 0;var gx=ie(),Jl=_e(),b2=gr(),w2={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(e){let{schema:t,it:r}=e;if(Array.isArray(t))return _x(e,"additionalItems",t);r.items=!0,!(0,Jl.alwaysValidSchema)(r,t)&&e.ok((0,b2.validateArray)(e))}};function _x(e,t,r=e.schema){let{gen:n,parentSchema:i,data:o,keyword:s,it:a}=e;l(i),a.opts.unevaluated&&r.length&&a.items!==!0&&(a.items=Jl.mergeEvaluated.items(n,r.length,a.items));let u=n.name("valid"),c=n.const("len",(0,gx._)`${o}.length`);r.forEach((d,p)=>{(0,Jl.alwaysValidSchema)(a,d)||(n.if((0,gx._)`${c} > ${p}`,()=>e.subschema({keyword:s,schemaProp:p,dataProp:p},u)),e.ok(u))});function l(d){let{opts:p,errSchemaPath:f}=a,h=r.length,m=h===d.minItems&&(h===d.maxItems||d[t]===!1);if(p.strictTuples&&!m){let g=`"${s}" is ${h}-tuple, but minItems or maxItems/${t} are not specified or different at path "${f}"`;(0,Jl.checkStrictMode)(a,g,p.strictTuples)}}}za.validateTuple=_x;za.default=w2});var yx=z(Mh=>{"use strict";Object.defineProperty(Mh,"__esModule",{value:!0});var k2=Nh(),x2={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:e=>(0,k2.validateTuple)(e,"items")};Mh.default=x2});var bx=z(Dh=>{"use strict";Object.defineProperty(Dh,"__esModule",{value:!0});var vx=ie(),S2=_e(),T2=gr(),$2=jh(),E2={message:({params:{len:e}})=>(0,vx.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,vx._)`{limit: ${e}}`},z2={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:E2,code(e){let{schema:t,parentSchema:r,it:n}=e,{prefixItems:i}=r;n.items=!0,!(0,S2.alwaysValidSchema)(n,t)&&(i?(0,$2.validateAdditionalItems)(e,i):e.ok((0,T2.validateArray)(e)))}};Dh.default=z2});var wx=z(Gh=>{"use strict";Object.defineProperty(Gh,"__esModule",{value:!0});var yr=ie(),Hl=_e(),A2={message:({params:{min:e,max:t}})=>t===void 0?(0,yr.str)`must contain at least ${e} valid item(s)`:(0,yr.str)`must contain at least ${e} and no more than ${t} valid item(s)`,params:({params:{min:e,max:t}})=>t===void 0?(0,yr._)`{minContains: ${e}}`:(0,yr._)`{minContains: ${e}, maxContains: ${t}}`},O2={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:A2,code(e){let{gen:t,schema:r,parentSchema:n,data:i,it:o}=e,s,a,{minContains:u,maxContains:c}=n;o.opts.next?(s=u===void 0?1:u,a=c):s=1;let l=t.const("len",(0,yr._)`${i}.length`);if(e.setParams({min:s,max:a}),a===void 0&&s===0){(0,Hl.checkStrictMode)(o,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(a!==void 0&&s>a){(0,Hl.checkStrictMode)(o,'"minContains" > "maxContains" is always invalid'),e.fail();return}if((0,Hl.alwaysValidSchema)(o,r)){let m=(0,yr._)`${l} >= ${s}`;a!==void 0&&(m=(0,yr._)`${m} && ${l} <= ${a}`),e.pass(m);return}o.items=!0;let d=t.name("valid");a===void 0&&s===1?f(d,()=>t.if(d,()=>t.break())):s===0?(t.let(d,!0),a!==void 0&&t.if((0,yr._)`${i}.length > 0`,p)):(t.let(d,!1),p()),e.result(d,()=>e.reset());function p(){let m=t.name("_valid"),g=t.let("count",0);f(m,()=>t.if(m,()=>h(g)))}function f(m,g){t.forRange("i",0,l,y=>{e.subschema({keyword:"contains",dataProp:y,dataPropType:Hl.Type.Num,compositeRule:!0},m),g()})}function h(m){t.code((0,yr._)`${m}++`),a===void 0?t.if((0,yr._)`${m} >= ${s}`,()=>t.assign(d,!0).break()):(t.if((0,yr._)`${m} > ${a}`,()=>t.assign(d,!1).break()),s===1?t.assign(d,!0):t.if((0,yr._)`${m} >= ${s}`,()=>t.assign(d,!0)))}}};Gh.default=O2});var Sx=z(Yr=>{"use strict";Object.defineProperty(Yr,"__esModule",{value:!0});Yr.validateSchemaDeps=Yr.validatePropertyDeps=Yr.error=void 0;var Zh=ie(),P2=_e(),Aa=gr();Yr.error={message:({params:{property:e,depsCount:t,deps:r}})=>{let n=t===1?"property":"properties";return(0,Zh.str)`must have ${n} ${r} when property ${e} is present`},params:({params:{property:e,depsCount:t,deps:r,missingProperty:n}})=>(0,Zh._)`{property: ${e},
9
9
  missingProperty: ${n},
10
10
  depsCount: ${t},
11
- deps: ${r}}`};var O2={keyword:"dependencies",type:"object",schemaType:"object",error:Yr.error,code(e){let[t,r]=P2(e);wx(e,t),kx(e,r)}};function P2({schema:e}){let t={},r={};for(let n in e){if(n==="__proto__")continue;let i=Array.isArray(e[n])?t:r;i[n]=e[n]}return[t,r]}function wx(e,t=e.schema){let{gen:r,data:n,it:i}=e;if(Object.keys(t).length===0)return;let o=r.let("missing");for(let s in t){let a=t[s];if(a.length===0)continue;let u=(0,Aa.propertyInData)(r,n,s,i.opts.ownProperties);e.setParams({property:s,depsCount:a.length,deps:a.join(", ")}),i.allErrors?r.if(u,()=>{for(let c of a)(0,Aa.checkReportMissingProp)(e,c)}):(r.if((0,Zh._)`${u} && (${(0,Aa.checkMissingProp)(e,a,o)})`),(0,Aa.reportMissingProp)(e,o),r.else())}}Yr.validatePropertyDeps=wx;function kx(e,t=e.schema){let{gen:r,data:n,keyword:i,it:o}=e,s=r.name("valid");for(let a in t)(0,A2.alwaysValidSchema)(o,t[a])||(r.if((0,Aa.propertyInData)(r,n,a,o.opts.ownProperties),()=>{let u=e.subschema({keyword:i,schemaProp:a},s);e.mergeValidEvaluated(u,s)},()=>r.var(s,!0)),e.ok(s))}Yr.validateSchemaDeps=kx;Yr.default=O2});var Tx=z(Fh=>{"use strict";Object.defineProperty(Fh,"__esModule",{value:!0});var Sx=ie(),C2=ge(),R2={message:"property name must be valid",params:({params:e})=>(0,Sx._)`{propertyName: ${e.propertyName}}`},I2={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:R2,code(e){let{gen:t,schema:r,data:n,it:i}=e;if((0,C2.alwaysValidSchema)(i,r))return;let o=t.name("valid");t.forIn("key",n,s=>{e.setParams({propertyName:s}),e.subschema({keyword:"propertyNames",data:s,dataTypes:["string"],propertyName:s,compositeRule:!0},o),t.if((0,Sx.not)(o),()=>{e.error(!0),i.allErrors||t.break()})}),e.ok(o)}};Fh.default=I2});var Lh=z(qh=>{"use strict";Object.defineProperty(qh,"__esModule",{value:!0});var Kl=gr(),Cr=ie(),j2=yn(),Ql=ge(),N2={message:"must NOT have additional properties",params:({params:e})=>(0,Cr._)`{additionalProperty: ${e.additionalProperty}}`},M2={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:N2,code(e){let{gen:t,schema:r,parentSchema:n,data:i,errsCount:o,it:s}=e;if(!o)throw new Error("ajv implementation error");let{allErrors:a,opts:u}=s;if(s.props=!0,u.removeAdditional!=="all"&&(0,Ql.alwaysValidSchema)(s,r))return;let c=(0,Kl.allSchemaProperties)(n.properties),l=(0,Kl.allSchemaProperties)(n.patternProperties);d(),e.ok((0,Cr._)`${o} === ${j2.default.errors}`);function d(){t.forIn("key",i,g=>{!c.length&&!l.length?h(g):t.if(p(g),()=>h(g))})}function p(g){let y;if(c.length>8){let v=(0,Ql.schemaRefOrVal)(s,n.properties,"properties");y=(0,Kl.isOwnProperty)(t,v,g)}else c.length?y=(0,Cr.or)(...c.map(v=>(0,Cr._)`${g} === ${v}`)):y=Cr.nil;return l.length&&(y=(0,Cr.or)(y,...l.map(v=>(0,Cr._)`${(0,Kl.usePattern)(e,v)}.test(${g})`))),(0,Cr.not)(y)}function f(g){t.code((0,Cr._)`delete ${i}[${g}]`)}function h(g){if(u.removeAdditional==="all"||u.removeAdditional&&r===!1){f(g);return}if(r===!1){e.setParams({additionalProperty:g}),e.error(),a||t.break();return}if(typeof r=="object"&&!(0,Ql.alwaysValidSchema)(s,r)){let y=t.name("valid");u.removeAdditional==="failing"?(m(g,y,!1),t.if((0,Cr.not)(y),()=>{e.reset(),f(g)})):(m(g,y),a||t.if((0,Cr.not)(y),()=>t.break()))}}function m(g,y,v){let b={keyword:"additionalProperties",dataProp:g,dataPropType:Ql.Type.Str};v===!1&&Object.assign(b,{compositeRule:!0,createErrors:!1,allErrors:!1}),e.subschema(b,y)}}};qh.default=M2});var zx=z(Vh=>{"use strict";Object.defineProperty(Vh,"__esModule",{value:!0});var D2=ha(),$x=gr(),Uh=ge(),Ex=Lh(),G2={keyword:"properties",type:"object",schemaType:"object",code(e){let{gen:t,schema:r,parentSchema:n,data:i,it:o}=e;o.opts.removeAdditional==="all"&&n.additionalProperties===void 0&&Ex.default.code(new D2.KeywordCxt(o,Ex.default,"additionalProperties"));let s=(0,$x.allSchemaProperties)(r);for(let d of s)o.definedProperties.add(d);o.opts.unevaluated&&s.length&&o.props!==!0&&(o.props=Uh.mergeEvaluated.props(t,(0,Uh.toHash)(s),o.props));let a=s.filter(d=>!(0,Uh.alwaysValidSchema)(o,r[d]));if(a.length===0)return;let u=t.name("valid");for(let d of a)c(d)?l(d):(t.if((0,$x.propertyInData)(t,i,d,o.opts.ownProperties)),l(d),o.allErrors||t.else().var(u,!0),t.endIf()),e.it.definedProperties.add(d),e.ok(u);function c(d){return o.opts.useDefaults&&!o.compositeRule&&r[d].default!==void 0}function l(d){e.subschema({keyword:"properties",schemaProp:d,dataProp:d},u)}}};Vh.default=G2});var Cx=z(Bh=>{"use strict";Object.defineProperty(Bh,"__esModule",{value:!0});var Ax=gr(),Xl=ie(),Ox=ge(),Px=ge(),Z2={keyword:"patternProperties",type:"object",schemaType:"object",code(e){let{gen:t,schema:r,data:n,parentSchema:i,it:o}=e,{opts:s}=o,a=(0,Ax.allSchemaProperties)(r),u=a.filter(m=>(0,Ox.alwaysValidSchema)(o,r[m]));if(a.length===0||u.length===a.length&&(!o.opts.unevaluated||o.props===!0))return;let c=s.strictSchema&&!s.allowMatchingProperties&&i.properties,l=t.name("valid");o.props!==!0&&!(o.props instanceof Xl.Name)&&(o.props=(0,Px.evaluatedPropsToName)(t,o.props));let{props:d}=o;p();function p(){for(let m of a)c&&f(m),o.allErrors?h(m):(t.var(l,!0),h(m),t.if(l))}function f(m){for(let g in c)new RegExp(m).test(g)&&(0,Ox.checkStrictMode)(o,`property ${g} matches pattern ${m} (use allowMatchingProperties)`)}function h(m){t.forIn("key",n,g=>{t.if((0,Xl._)`${(0,Ax.usePattern)(e,m)}.test(${g})`,()=>{let y=u.includes(m);y||e.subschema({keyword:"patternProperties",schemaProp:m,dataProp:g,dataPropType:Px.Type.Str},l),o.opts.unevaluated&&d!==!0?t.assign((0,Xl._)`${d}[${g}]`,!0):!y&&!o.allErrors&&t.if((0,Xl.not)(l),()=>t.break())})})}}};Bh.default=Z2});var Rx=z(Wh=>{"use strict";Object.defineProperty(Wh,"__esModule",{value:!0});var F2=ge(),q2={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(e){let{gen:t,schema:r,it:n}=e;if((0,F2.alwaysValidSchema)(n,r)){e.fail();return}let i=t.name("valid");e.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},i),e.failResult(i,()=>e.reset(),()=>e.error())},error:{message:"must NOT be valid"}};Wh.default=q2});var Ix=z(Jh=>{"use strict";Object.defineProperty(Jh,"__esModule",{value:!0});var L2=gr(),U2={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:L2.validateUnion,error:{message:"must match a schema in anyOf"}};Jh.default=U2});var jx=z(Hh=>{"use strict";Object.defineProperty(Hh,"__esModule",{value:!0});var Yl=ie(),V2=ge(),B2={message:"must match exactly one schema in oneOf",params:({params:e})=>(0,Yl._)`{passingSchemas: ${e.passing}}`},W2={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:B2,code(e){let{gen:t,schema:r,parentSchema:n,it:i}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");if(i.opts.discriminator&&n.discriminator)return;let o=r,s=t.let("valid",!1),a=t.let("passing",null),u=t.name("_valid");e.setParams({passing:a}),t.block(c),e.result(s,()=>e.reset(),()=>e.error(!0));function c(){o.forEach((l,d)=>{let p;(0,V2.alwaysValidSchema)(i,l)?t.var(u,!0):p=e.subschema({keyword:"oneOf",schemaProp:d,compositeRule:!0},u),d>0&&t.if((0,Yl._)`${u} && ${s}`).assign(s,!1).assign(a,(0,Yl._)`[${a}, ${d}]`).else(),t.if(u,()=>{t.assign(s,!0),t.assign(a,d),p&&e.mergeEvaluated(p,Yl.Name)})})}}};Hh.default=W2});var Nx=z(Kh=>{"use strict";Object.defineProperty(Kh,"__esModule",{value:!0});var J2=ge(),H2={keyword:"allOf",schemaType:"array",code(e){let{gen:t,schema:r,it:n}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");let i=t.name("valid");r.forEach((o,s)=>{if((0,J2.alwaysValidSchema)(n,o))return;let a=e.subschema({keyword:"allOf",schemaProp:s},i);e.ok(i),e.mergeEvaluated(a)})}};Kh.default=H2});var Gx=z(Qh=>{"use strict";Object.defineProperty(Qh,"__esModule",{value:!0});var eu=ie(),Dx=ge(),K2={message:({params:e})=>(0,eu.str)`must match "${e.ifClause}" schema`,params:({params:e})=>(0,eu._)`{failingKeyword: ${e.ifClause}}`},Q2={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:K2,code(e){let{gen:t,parentSchema:r,it:n}=e;r.then===void 0&&r.else===void 0&&(0,Dx.checkStrictMode)(n,'"if" without "then" and "else" is ignored');let i=Mx(n,"then"),o=Mx(n,"else");if(!i&&!o)return;let s=t.let("valid",!0),a=t.name("_valid");if(u(),e.reset(),i&&o){let l=t.let("ifClause");e.setParams({ifClause:l}),t.if(a,c("then",l),c("else",l))}else i?t.if(a,c("then")):t.if((0,eu.not)(a),c("else"));e.pass(s,()=>e.error(!0));function u(){let l=e.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},a);e.mergeEvaluated(l)}function c(l,d){return()=>{let p=e.subschema({keyword:l},a);t.assign(s,a),e.mergeValidEvaluated(p,s),d?t.assign(d,(0,eu._)`${l}`):e.setParams({ifClause:l})}}}};function Mx(e,t){let r=e.schema[t];return r!==void 0&&!(0,Dx.alwaysValidSchema)(e,r)}Qh.default=Q2});var Zx=z(Xh=>{"use strict";Object.defineProperty(Xh,"__esModule",{value:!0});var X2=ge(),Y2={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:e,parentSchema:t,it:r}){t.if===void 0&&(0,X2.checkStrictMode)(r,`"${e}" without "if" is ignored`)}};Xh.default=Y2});var Fx=z(Yh=>{"use strict";Object.defineProperty(Yh,"__esModule",{value:!0});var eN=jh(),tN=_x(),rN=Nh(),nN=vx(),iN=bx(),oN=xx(),sN=Tx(),aN=Lh(),cN=zx(),lN=Cx(),uN=Rx(),dN=Ix(),fN=jx(),mN=Nx(),pN=Gx(),hN=Zx();function gN(e=!1){let t=[uN.default,dN.default,fN.default,mN.default,pN.default,hN.default,sN.default,aN.default,oN.default,cN.default,lN.default];return e?t.push(tN.default,nN.default):t.push(eN.default,rN.default),t.push(iN.default),t}Yh.default=gN});var qx=z(eg=>{"use strict";Object.defineProperty(eg,"__esModule",{value:!0});var tt=ie(),_N={message:({schemaCode:e})=>(0,tt.str)`must match format "${e}"`,params:({schemaCode:e})=>(0,tt._)`{format: ${e}}`},yN={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:_N,code(e,t){let{gen:r,data:n,$data:i,schema:o,schemaCode:s,it:a}=e,{opts:u,errSchemaPath:c,schemaEnv:l,self:d}=a;if(!u.validateFormats)return;i?p():f();function p(){let h=r.scopeValue("formats",{ref:d.formats,code:u.code.formats}),m=r.const("fDef",(0,tt._)`${h}[${s}]`),g=r.let("fType"),y=r.let("format");r.if((0,tt._)`typeof ${m} == "object" && !(${m} instanceof RegExp)`,()=>r.assign(g,(0,tt._)`${m}.type || "string"`).assign(y,(0,tt._)`${m}.validate`),()=>r.assign(g,(0,tt._)`"string"`).assign(y,m)),e.fail$data((0,tt.or)(v(),b()));function v(){return u.strictSchema===!1?tt.nil:(0,tt._)`${s} && !${y}`}function b(){let w=l.$async?(0,tt._)`(${m}.async ? await ${y}(${n}) : ${y}(${n}))`:(0,tt._)`${y}(${n})`,S=(0,tt._)`(typeof ${y} == "function" ? ${w} : ${y}.test(${n}))`;return(0,tt._)`${y} && ${y} !== true && ${g} === ${t} && !${S}`}}function f(){let h=d.formats[o];if(!h){v();return}if(h===!0)return;let[m,g,y]=b(h);m===t&&e.pass(w());function v(){if(u.strictSchema===!1){d.logger.warn(S());return}throw new Error(S());function S(){return`unknown format "${o}" ignored in schema at path "${c}"`}}function b(S){let R=S instanceof RegExp?(0,tt.regexpCode)(S):u.code.formats?(0,tt._)`${u.code.formats}${(0,tt.getProperty)(o)}`:void 0,X=r.scopeValue("formats",{key:o,ref:S,code:R});return typeof S=="object"&&!(S instanceof RegExp)?[S.type||"string",S.validate,(0,tt._)`${X}.validate`]:["string",S,X]}function w(){if(typeof h=="object"&&!(h instanceof RegExp)&&h.async){if(!l.$async)throw new Error("async format in sync schema");return(0,tt._)`await ${y}(${n})`}return typeof g=="function"?(0,tt._)`${y}(${n})`:(0,tt._)`${y}.test(${n})`}}}};eg.default=yN});var Lx=z(tg=>{"use strict";Object.defineProperty(tg,"__esModule",{value:!0});var vN=qx(),bN=[vN.default];tg.default=bN});var Ux=z(Ko=>{"use strict";Object.defineProperty(Ko,"__esModule",{value:!0});Ko.contentVocabulary=Ko.metadataVocabulary=void 0;Ko.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];Ko.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]});var Bx=z(rg=>{"use strict";Object.defineProperty(rg,"__esModule",{value:!0});var wN=Yk(),kN=mx(),xN=Fx(),SN=Lx(),Vx=Ux(),TN=[wN.default,kN.default,(0,xN.default)(),SN.default,Vx.metadataVocabulary,Vx.contentVocabulary];rg.default=TN});var Jx=z(tu=>{"use strict";Object.defineProperty(tu,"__esModule",{value:!0});tu.DiscrError=void 0;var Wx;(function(e){e.Tag="tag",e.Mapping="mapping"})(Wx||(tu.DiscrError=Wx={}))});var Kx=z(ig=>{"use strict";Object.defineProperty(ig,"__esModule",{value:!0});var Qo=ie(),ng=Jx(),Hx=Nl(),$N=ga(),EN=ge(),zN={message:({params:{discrError:e,tagName:t}})=>e===ng.DiscrError.Tag?`tag "${t}" must be string`:`value of tag "${t}" must be in oneOf`,params:({params:{discrError:e,tag:t,tagName:r}})=>(0,Qo._)`{error: ${e}, tag: ${r}, tagValue: ${t}}`},AN={keyword:"discriminator",type:"object",schemaType:"object",error:zN,code(e){let{gen:t,data:r,schema:n,parentSchema:i,it:o}=e,{oneOf:s}=i;if(!o.opts.discriminator)throw new Error("discriminator: requires discriminator option");let a=n.propertyName;if(typeof a!="string")throw new Error("discriminator: requires propertyName");if(n.mapping)throw new Error("discriminator: mapping is not supported");if(!s)throw new Error("discriminator: requires oneOf keyword");let u=t.let("valid",!1),c=t.const("tag",(0,Qo._)`${r}${(0,Qo.getProperty)(a)}`);t.if((0,Qo._)`typeof ${c} == "string"`,()=>l(),()=>e.error(!1,{discrError:ng.DiscrError.Tag,tag:c,tagName:a})),e.ok(u);function l(){let f=p();t.if(!1);for(let h in f)t.elseIf((0,Qo._)`${c} === ${h}`),t.assign(u,d(f[h]));t.else(),e.error(!1,{discrError:ng.DiscrError.Mapping,tag:c,tagName:a}),t.endIf()}function d(f){let h=t.name("valid"),m=e.subschema({keyword:"oneOf",schemaProp:f},h);return e.mergeEvaluated(m,Qo.Name),h}function p(){var f;let h={},m=y(i),g=!0;for(let w=0;w<s.length;w++){let S=s[w];if(S?.$ref&&!(0,EN.schemaHasRulesButRef)(S,o.self.RULES)){let X=S.$ref;if(S=Hx.resolveRef.call(o.self,o.schemaEnv.root,o.baseId,X),S instanceof Hx.SchemaEnv&&(S=S.schema),S===void 0)throw new $N.default(o.opts.uriResolver,o.baseId,X)}let R=(f=S?.properties)===null||f===void 0?void 0:f[a];if(typeof R!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${a}"`);g=g&&(m||y(S)),v(R,w)}if(!g)throw new Error(`discriminator: "${a}" must be required`);return h;function y({required:w}){return Array.isArray(w)&&w.includes(a)}function v(w,S){if(w.const)b(w.const,S);else if(w.enum)for(let R of w.enum)b(R,S);else throw new Error(`discriminator: "properties/${a}" must have "const" or "enum"`)}function b(w,S){if(typeof w!="string"||w in h)throw new Error(`discriminator: "${a}" values must be unique strings`);h[w]=S}}}};ig.default=AN});var Qx=z((Nq,ON)=>{ON.exports={$schema:"http://json-schema.org/draft-07/schema#",$id:"http://json-schema.org/draft-07/schema#",title:"Core schema meta-schema",definitions:{schemaArray:{type:"array",minItems:1,items:{$ref:"#"}},nonNegativeInteger:{type:"integer",minimum:0},nonNegativeIntegerDefault0:{allOf:[{$ref:"#/definitions/nonNegativeInteger"},{default:0}]},simpleTypes:{enum:["array","boolean","integer","null","number","object","string"]},stringArray:{type:"array",items:{type:"string"},uniqueItems:!0,default:[]}},type:["object","boolean"],properties:{$id:{type:"string",format:"uri-reference"},$schema:{type:"string",format:"uri"},$ref:{type:"string",format:"uri-reference"},$comment:{type:"string"},title:{type:"string"},description:{type:"string"},default:!0,readOnly:{type:"boolean",default:!1},examples:{type:"array",items:!0},multipleOf:{type:"number",exclusiveMinimum:0},maximum:{type:"number"},exclusiveMaximum:{type:"number"},minimum:{type:"number"},exclusiveMinimum:{type:"number"},maxLength:{$ref:"#/definitions/nonNegativeInteger"},minLength:{$ref:"#/definitions/nonNegativeIntegerDefault0"},pattern:{type:"string",format:"regex"},additionalItems:{$ref:"#"},items:{anyOf:[{$ref:"#"},{$ref:"#/definitions/schemaArray"}],default:!0},maxItems:{$ref:"#/definitions/nonNegativeInteger"},minItems:{$ref:"#/definitions/nonNegativeIntegerDefault0"},uniqueItems:{type:"boolean",default:!1},contains:{$ref:"#"},maxProperties:{$ref:"#/definitions/nonNegativeInteger"},minProperties:{$ref:"#/definitions/nonNegativeIntegerDefault0"},required:{$ref:"#/definitions/stringArray"},additionalProperties:{$ref:"#"},definitions:{type:"object",additionalProperties:{$ref:"#"},default:{}},properties:{type:"object",additionalProperties:{$ref:"#"},default:{}},patternProperties:{type:"object",additionalProperties:{$ref:"#"},propertyNames:{format:"regex"},default:{}},dependencies:{type:"object",additionalProperties:{anyOf:[{$ref:"#"},{$ref:"#/definitions/stringArray"}]}},propertyNames:{$ref:"#"},const:!0,enum:{type:"array",items:!0,minItems:1,uniqueItems:!0},type:{anyOf:[{$ref:"#/definitions/simpleTypes"},{type:"array",items:{$ref:"#/definitions/simpleTypes"},minItems:1,uniqueItems:!0}]},format:{type:"string"},contentMediaType:{type:"string"},contentEncoding:{type:"string"},if:{$ref:"#"},then:{$ref:"#"},else:{$ref:"#"},allOf:{$ref:"#/definitions/schemaArray"},anyOf:{$ref:"#/definitions/schemaArray"},oneOf:{$ref:"#/definitions/schemaArray"},not:{$ref:"#"}},default:!0}});var sg=z((je,og)=>{"use strict";Object.defineProperty(je,"__esModule",{value:!0});je.MissingRefError=je.ValidationError=je.CodeGen=je.Name=je.nil=je.stringify=je.str=je._=je.KeywordCxt=je.Ajv=void 0;var PN=Wk(),CN=Bx(),RN=Kx(),Xx=Qx(),IN=["/properties"],ru="http://json-schema.org/draft-07/schema",Xo=class extends PN.default{_addVocabularies(){super._addVocabularies(),CN.default.forEach(t=>this.addVocabulary(t)),this.opts.discriminator&&this.addKeyword(RN.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let t=this.opts.$data?this.$dataMetaSchema(Xx,IN):Xx;this.addMetaSchema(t,ru,!1),this.refs["http://json-schema.org/schema"]=ru}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(ru)?ru:void 0)}};je.Ajv=Xo;og.exports=je=Xo;og.exports.Ajv=Xo;Object.defineProperty(je,"__esModule",{value:!0});je.default=Xo;var jN=ha();Object.defineProperty(je,"KeywordCxt",{enumerable:!0,get:function(){return jN.KeywordCxt}});var Yo=ie();Object.defineProperty(je,"_",{enumerable:!0,get:function(){return Yo._}});Object.defineProperty(je,"str",{enumerable:!0,get:function(){return Yo.str}});Object.defineProperty(je,"stringify",{enumerable:!0,get:function(){return Yo.stringify}});Object.defineProperty(je,"nil",{enumerable:!0,get:function(){return Yo.nil}});Object.defineProperty(je,"Name",{enumerable:!0,get:function(){return Yo.Name}});Object.defineProperty(je,"CodeGen",{enumerable:!0,get:function(){return Yo.CodeGen}});var NN=Il();Object.defineProperty(je,"ValidationError",{enumerable:!0,get:function(){return NN.default}});var MN=ga();Object.defineProperty(je,"MissingRefError",{enumerable:!0,get:function(){return MN.default}})});var sS=z(tn=>{"use strict";Object.defineProperty(tn,"__esModule",{value:!0});tn.formatNames=tn.fastFormats=tn.fullFormats=void 0;function en(e,t){return{validate:e,compare:t}}tn.fullFormats={date:en(rS,ug),time:en(cg(!0),dg),"date-time":en(Yx(!0),iS),"iso-time":en(cg(),nS),"iso-date-time":en(Yx(),oS),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:LN,"uri-reference":/^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,"uri-template":/^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,url:/^(?:https?|ftp):\/\/(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)(?:\.(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu,email:/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,hostname:/^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i,ipv4:/^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$/,ipv6:/^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i,regex:KN,uuid:/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,"json-pointer":/^(?:\/(?:[^~/]|~0|~1)*)*$/,"json-pointer-uri-fragment":/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,"relative-json-pointer":/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,byte:UN,int32:{type:"number",validate:WN},int64:{type:"number",validate:JN},float:{type:"number",validate:tS},double:{type:"number",validate:tS},password:!0,binary:!0};tn.fastFormats={...tn.fullFormats,date:en(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,ug),time:en(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,dg),"date-time":en(/^\d\d\d\d-[0-1]\d-[0-3]\dt(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,iS),"iso-time":en(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,nS),"iso-date-time":en(/^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,oS),uri:/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/)?[^\s]*$/i,"uri-reference":/^(?:(?:[a-z][a-z0-9+\-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i,email:/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i};tn.formatNames=Object.keys(tn.fullFormats);function DN(e){return e%4===0&&(e%100!==0||e%400===0)}var GN=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,ZN=[0,31,28,31,30,31,30,31,31,30,31,30,31];function rS(e){let t=GN.exec(e);if(!t)return!1;let r=+t[1],n=+t[2],i=+t[3];return n>=1&&n<=12&&i>=1&&i<=(n===2&&DN(r)?29:ZN[n])}function ug(e,t){if(e&&t)return e>t?1:e<t?-1:0}var ag=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function cg(e){return function(r){let n=ag.exec(r);if(!n)return!1;let i=+n[1],o=+n[2],s=+n[3],a=n[4],u=n[5]==="-"?-1:1,c=+(n[6]||0),l=+(n[7]||0);if(c>23||l>59||e&&!a)return!1;if(i<=23&&o<=59&&s<60)return!0;let d=o-l*u,p=i-c*u-(d<0?1:0);return(p===23||p===-1)&&(d===59||d===-1)&&s<61}}function dg(e,t){if(!(e&&t))return;let r=new Date("2020-01-01T"+e).valueOf(),n=new Date("2020-01-01T"+t).valueOf();if(r&&n)return r-n}function nS(e,t){if(!(e&&t))return;let r=ag.exec(e),n=ag.exec(t);if(r&&n)return e=r[1]+r[2]+r[3],t=n[1]+n[2]+n[3],e>t?1:e<t?-1:0}var lg=/t|\s/i;function Yx(e){let t=cg(e);return function(n){let i=n.split(lg);return i.length===2&&rS(i[0])&&t(i[1])}}function iS(e,t){if(!(e&&t))return;let r=new Date(e).valueOf(),n=new Date(t).valueOf();if(r&&n)return r-n}function oS(e,t){if(!(e&&t))return;let[r,n]=e.split(lg),[i,o]=t.split(lg),s=ug(r,i);if(s!==void 0)return s||dg(n,o)}var FN=/\/|:/,qN=/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;function LN(e){return FN.test(e)&&qN.test(e)}var eS=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function UN(e){return eS.lastIndex=0,eS.test(e)}var VN=-(2**31),BN=2**31-1;function WN(e){return Number.isInteger(e)&&e<=BN&&e>=VN}function JN(e){return Number.isInteger(e)}function tS(){return!0}var HN=/[^\\]\\Z/;function KN(e){if(HN.test(e))return!1;try{return new RegExp(e),!0}catch{return!1}}});var aS=z(es=>{"use strict";Object.defineProperty(es,"__esModule",{value:!0});es.formatLimitDefinition=void 0;var QN=sg(),Rr=ie(),Xn=Rr.operators,nu={formatMaximum:{okStr:"<=",ok:Xn.LTE,fail:Xn.GT},formatMinimum:{okStr:">=",ok:Xn.GTE,fail:Xn.LT},formatExclusiveMaximum:{okStr:"<",ok:Xn.LT,fail:Xn.GTE},formatExclusiveMinimum:{okStr:">",ok:Xn.GT,fail:Xn.LTE}},XN={message:({keyword:e,schemaCode:t})=>(0,Rr.str)`should be ${nu[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0,Rr._)`{comparison: ${nu[e].okStr}, limit: ${t}}`};es.formatLimitDefinition={keyword:Object.keys(nu),type:"string",schemaType:"string",$data:!0,error:XN,code(e){let{gen:t,data:r,schemaCode:n,keyword:i,it:o}=e,{opts:s,self:a}=o;if(!s.validateFormats)return;let u=new QN.KeywordCxt(o,a.RULES.all.format.definition,"format");u.$data?c():l();function c(){let p=t.scopeValue("formats",{ref:a.formats,code:s.code.formats}),f=t.const("fmt",(0,Rr._)`${p}[${u.schemaCode}]`);e.fail$data((0,Rr.or)((0,Rr._)`typeof ${f} != "object"`,(0,Rr._)`${f} instanceof RegExp`,(0,Rr._)`typeof ${f}.compare != "function"`,d(f)))}function l(){let p=u.schema,f=a.formats[p];if(!f||f===!0)return;if(typeof f!="object"||f instanceof RegExp||typeof f.compare!="function")throw new Error(`"${i}": format "${p}" does not define "compare" function`);let h=t.scopeValue("formats",{key:p,ref:f,code:s.code.formats?(0,Rr._)`${s.code.formats}${(0,Rr.getProperty)(p)}`:void 0});e.fail$data(d(h))}function d(p){return(0,Rr._)`${p}.compare(${r}, ${n}) ${nu[i].fail} 0`}},dependencies:["format"]};var YN=e=>(e.addKeyword(es.formatLimitDefinition),e);es.default=YN});var dS=z((Oa,uS)=>{"use strict";Object.defineProperty(Oa,"__esModule",{value:!0});var ts=sS(),eM=aS(),fg=ie(),cS=new fg.Name("fullFormats"),tM=new fg.Name("fastFormats"),mg=(e,t={keywords:!0})=>{if(Array.isArray(t))return lS(e,t,ts.fullFormats,cS),e;let[r,n]=t.mode==="fast"?[ts.fastFormats,tM]:[ts.fullFormats,cS],i=t.formats||ts.formatNames;return lS(e,i,r,n),t.keywords&&(0,eM.default)(e),e};mg.get=(e,t="full")=>{let n=(t==="fast"?ts.fastFormats:ts.fullFormats)[e];if(!n)throw new Error(`Unknown format "${e}"`);return n};function lS(e,t,r,n){var i,o;(i=(o=e.opts.code).formats)!==null&&i!==void 0||(o.formats=(0,fg._)`require("ajv-formats/dist/formats").${n}`);for(let s of t)e.addFormat(s,r[s])}uS.exports=Oa=mg;Object.defineProperty(Oa,"__esModule",{value:!0});Oa.default=mg});import*as ES from"node:url";import*as me from"node:fs";import*as Va from"node:crypto";function Dt(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 Nr(e){if(e!=null)return Dt(e)}function ve(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 br(e){if(e.RE_EXN_ID==="JsExn")return Dt(e._1)}var Ia=(e=>t=>t&&typeof t[e]=="string"?t[e]:void 0),kM=Ia("stack"),wr=Ia("message"),xM=Ia("name"),SM=Ia("fileName");function He(e,t){if(e!==void 0)return Dt(t(ve(e)))}function Ke(e,t){if(e!==void 0)return t(ve(e))}function rt(e,t){return e!==void 0?ve(e):t}var gT=Ra($u(),1);var Qg=(function(e,t){for(var r in e)t(r)});function Pt(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 s=e.length|0,a=t.length|0;if(s===a)if(Array.isArray(e)){let u=0;for(;;){let c=u;if(c===s)return!0;if(!Pt(e[c],t[c]))return!1;u=c+1|0}}else{if(e instanceof Date&&t instanceof Date)return!(e>t||e<t);{let u={contents:!0},c=d=>{if(!Object.prototype.hasOwnProperty.call(t,d)){u.contents=!1;return}},l=d=>{if(!Object.prototype.hasOwnProperty.call(e,d)||!Pt(t[d],e[d])){u.contents=!1;return}};return Qg(e,c),u.contents&&Qg(t,l),u.contents}}else return!1}import*as Yg from"node:child_process";function hT(e){return e==null?!1:typeof e.RE_EXN_ID=="string"}function K(e){return hT(e)?e:{RE_EXN_ID:"JsExn",_1:e}}var Eu={};function Xg(e){let t=Eu[e];if(t!==void 0){let r=t+1|0;return Eu[e]=r,e+("/"+r)}return Eu[e]=1,e}function We(e){let t=br(e);if(t===void 0)return{code:void 0,message:"unknown error"};let r=ve(t);return{code:Nr(r.code),message:rt(wr(r),"unknown error")}}function e_(e,t){return Pt(e.code,t)}function kr(e){try{return{TAG:"Ok",_0:me.readFileSync(e,"utf8")}}catch(t){let r=K(t);return{TAG:"Error",_0:We(r)}}}function t_(e,t){try{return{TAG:"Ok",_0:(me.writeFileSync(e,t,"utf8"),void 0)}}catch(r){let n=K(r);return{TAG:"Error",_0:We(n)}}}function as(e,t,r){try{return{TAG:"Ok",_0:(me.writeFileSync(e,t,r),void 0)}}catch(n){let i=K(n);return{TAG:"Error",_0:We(i)}}}function xr(e){try{return{TAG:"Ok",_0:(me.mkdirSync(e,{recursive:!0}),void 0)}}catch(t){let r=K(t);return{TAG:"Error",_0:We(r)}}}function Ba(e,t){try{return{TAG:"Ok",_0:(me.chmodSync(e,t),void 0)}}catch(r){let n=K(r);return{TAG:"Error",_0:We(n)}}}function r_(e,t){try{return{TAG:"Ok",_0:(me.linkSync(e,t),void 0)}}catch(r){let n=K(r);return{TAG:"Error",_0:We(n)}}}function n_(e){try{return{TAG:"Ok",_0:(me.unlinkSync(e),void 0)}}catch(t){let r=K(t);return{TAG:"Error",_0:We(r)}}}function Wa(e,t){try{return{TAG:"Ok",_0:(me.renameSync(e,t),void 0)}}catch(r){let n=K(r);return{TAG:"Error",_0:We(n)}}}function oi(e){try{return{TAG:"Ok",_0:(me.rmSync(e,{force:!0}),void 0)}}catch(t){let r=K(t);return{TAG:"Error",_0:We(r)}}}function Ja(e){return Va.createHash("sha256").update(e).digest("hex")}function i_(e){try{return Va.randomBytes(e).toString("hex")}catch{return""}}function o_(e){try{return{TAG:"Ok",_0:me.readdirSync(e)}}catch(t){let r=K(t);return{TAG:"Error",_0:We(r)}}}function s_(e,t,r,n){try{return{TAG:"Ok",_0:Yg.execFileSync(e,t,{encoding:"utf8",timeout:r,maxBuffer:n})}}catch(i){let o=K(i);return{TAG:"Error",_0:We(o)}}}function $n(e){try{return process.stderr.write(e)}catch{return!1}}function cs(e,t){return e[t]}function zu(e,t){try{return process.kill(e,t),{TAG:"Ok",_0:void 0}}catch(r){let n=K(r);return{TAG:"Error",_0:We(n)}}}function oo(e){try{return Dt(new URL(e))}catch{return}}function Kt(e,t){try{return{TAG:"Ok",_0:new URL(e,t)}}catch(r){let n=K(r),i=br(n);return{TAG:"Error",_0:i!==void 0?rt(wr(ve(i)),"unknown error"):"unknown error"}}}var it={};it["api-url"]="ValueKind";it.token="ValueKind";it["auth-file"]="ValueKind";it["delegation-auth-file"]="ValueKind";it.workspace="ValueKind";it.channel="ValueKind";it["owner-username"]="ValueKind";it.mode="ValueKind";it.cwd="ValueKind";it["thread-id"]="ValueKind";it.format="ValueKind";it.command="ValueKind";it["tool-scope"]="ValueKind";it["agent-session"]="BooleanKind";it["ask-user-question-tool"]="BooleanKind";it["multi-agent-jobs"]="BooleanKind";it["include-token"]="BooleanKind";it.help="BooleanKind";function Ha(e){let t={},r,n=0;for(;r===void 0&&n<e.length;){let o=e[n];if(o!==void 0)if(o.startsWith("--")){let s=o.slice(2),a=it[s];if(a!==void 0)if(a==="ValueKind"){let u=e[n+1|0];u!==void 0?u.startsWith("--")?r="--"+s+" requires a value":(t[s]={TAG:"ValueFlag",_0:u},n=n+2|0):r="--"+s+" requires a value"}else t[s]="BoolFlag",n=n+1|0;else r="unsupported option --"+s}else r="unexpected argument "+o;else n=n+1|0}let i=r;return i!==void 0?{TAG:"Error",_0:i}:{TAG:"Ok",_0:t}}function Qe(e,t){let r=e[t];if(r===void 0||typeof r!="object")return;let n=r._0;if(n.trim()!=="")return n}function so(e,t){let r=e[t];return r!==void 0?typeof r!="object":!1}function Ka(e,t){let r=Qe(e,t);return r!==void 0?{TAG:"Ok",_0:r}:{TAG:"Error",_0:"--"+t+" is required"}}function Qa(e){if(e===void 0)return{TAG:"Ok",_0:"Text"};switch(e){case"text":return{TAG:"Ok",_0:"Text"};case"voice":return{TAG:"Ok",_0:"Voice"};default:return{TAG:"Error",_0:"--mode must be voice or text"}}}function Au(e){if(e===void 0)return{TAG:"Ok",_0:"All"};switch(e){case"all":return{TAG:"Ok",_0:"All"};case"coding":return{TAG:"Ok",_0:"Coding"};case"onboarding-discovery":return{TAG:"Ok",_0:"OnboardingDiscovery"};default:return{TAG:"Error",_0:"--tool-scope must be all, coding, or onboarding-discovery"}}}function a_(e){return e[0]==="mcp"?e.slice(1):e}function Xa(){return`Linzumi MCP
11
+ deps: ${r}}`};var C2={keyword:"dependencies",type:"object",schemaType:"object",error:Yr.error,code(e){let[t,r]=R2(e);kx(e,t),xx(e,r)}};function R2({schema:e}){let t={},r={};for(let n in e){if(n==="__proto__")continue;let i=Array.isArray(e[n])?t:r;i[n]=e[n]}return[t,r]}function kx(e,t=e.schema){let{gen:r,data:n,it:i}=e;if(Object.keys(t).length===0)return;let o=r.let("missing");for(let s in t){let a=t[s];if(a.length===0)continue;let u=(0,Aa.propertyInData)(r,n,s,i.opts.ownProperties);e.setParams({property:s,depsCount:a.length,deps:a.join(", ")}),i.allErrors?r.if(u,()=>{for(let c of a)(0,Aa.checkReportMissingProp)(e,c)}):(r.if((0,Zh._)`${u} && (${(0,Aa.checkMissingProp)(e,a,o)})`),(0,Aa.reportMissingProp)(e,o),r.else())}}Yr.validatePropertyDeps=kx;function xx(e,t=e.schema){let{gen:r,data:n,keyword:i,it:o}=e,s=r.name("valid");for(let a in t)(0,P2.alwaysValidSchema)(o,t[a])||(r.if((0,Aa.propertyInData)(r,n,a,o.opts.ownProperties),()=>{let u=e.subschema({keyword:i,schemaProp:a},s);e.mergeValidEvaluated(u,s)},()=>r.var(s,!0)),e.ok(s))}Yr.validateSchemaDeps=xx;Yr.default=C2});var $x=z(Fh=>{"use strict";Object.defineProperty(Fh,"__esModule",{value:!0});var Tx=ie(),I2=_e(),j2={message:"property name must be valid",params:({params:e})=>(0,Tx._)`{propertyName: ${e.propertyName}}`},N2={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:j2,code(e){let{gen:t,schema:r,data:n,it:i}=e;if((0,I2.alwaysValidSchema)(i,r))return;let o=t.name("valid");t.forIn("key",n,s=>{e.setParams({propertyName:s}),e.subschema({keyword:"propertyNames",data:s,dataTypes:["string"],propertyName:s,compositeRule:!0},o),t.if((0,Tx.not)(o),()=>{e.error(!0),i.allErrors||t.break()})}),e.ok(o)}};Fh.default=N2});var Lh=z(qh=>{"use strict";Object.defineProperty(qh,"__esModule",{value:!0});var Kl=gr(),Cr=ie(),M2=yn(),Ql=_e(),D2={message:"must NOT have additional properties",params:({params:e})=>(0,Cr._)`{additionalProperty: ${e.additionalProperty}}`},G2={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:D2,code(e){let{gen:t,schema:r,parentSchema:n,data:i,errsCount:o,it:s}=e;if(!o)throw new Error("ajv implementation error");let{allErrors:a,opts:u}=s;if(s.props=!0,u.removeAdditional!=="all"&&(0,Ql.alwaysValidSchema)(s,r))return;let c=(0,Kl.allSchemaProperties)(n.properties),l=(0,Kl.allSchemaProperties)(n.patternProperties);d(),e.ok((0,Cr._)`${o} === ${M2.default.errors}`);function d(){t.forIn("key",i,g=>{!c.length&&!l.length?h(g):t.if(p(g),()=>h(g))})}function p(g){let y;if(c.length>8){let v=(0,Ql.schemaRefOrVal)(s,n.properties,"properties");y=(0,Kl.isOwnProperty)(t,v,g)}else c.length?y=(0,Cr.or)(...c.map(v=>(0,Cr._)`${g} === ${v}`)):y=Cr.nil;return l.length&&(y=(0,Cr.or)(y,...l.map(v=>(0,Cr._)`${(0,Kl.usePattern)(e,v)}.test(${g})`))),(0,Cr.not)(y)}function f(g){t.code((0,Cr._)`delete ${i}[${g}]`)}function h(g){if(u.removeAdditional==="all"||u.removeAdditional&&r===!1){f(g);return}if(r===!1){e.setParams({additionalProperty:g}),e.error(),a||t.break();return}if(typeof r=="object"&&!(0,Ql.alwaysValidSchema)(s,r)){let y=t.name("valid");u.removeAdditional==="failing"?(m(g,y,!1),t.if((0,Cr.not)(y),()=>{e.reset(),f(g)})):(m(g,y),a||t.if((0,Cr.not)(y),()=>t.break()))}}function m(g,y,v){let b={keyword:"additionalProperties",dataProp:g,dataPropType:Ql.Type.Str};v===!1&&Object.assign(b,{compositeRule:!0,createErrors:!1,allErrors:!1}),e.subschema(b,y)}}};qh.default=G2});var Ax=z(Vh=>{"use strict";Object.defineProperty(Vh,"__esModule",{value:!0});var Z2=ha(),Ex=gr(),Uh=_e(),zx=Lh(),F2={keyword:"properties",type:"object",schemaType:"object",code(e){let{gen:t,schema:r,parentSchema:n,data:i,it:o}=e;o.opts.removeAdditional==="all"&&n.additionalProperties===void 0&&zx.default.code(new Z2.KeywordCxt(o,zx.default,"additionalProperties"));let s=(0,Ex.allSchemaProperties)(r);for(let d of s)o.definedProperties.add(d);o.opts.unevaluated&&s.length&&o.props!==!0&&(o.props=Uh.mergeEvaluated.props(t,(0,Uh.toHash)(s),o.props));let a=s.filter(d=>!(0,Uh.alwaysValidSchema)(o,r[d]));if(a.length===0)return;let u=t.name("valid");for(let d of a)c(d)?l(d):(t.if((0,Ex.propertyInData)(t,i,d,o.opts.ownProperties)),l(d),o.allErrors||t.else().var(u,!0),t.endIf()),e.it.definedProperties.add(d),e.ok(u);function c(d){return o.opts.useDefaults&&!o.compositeRule&&r[d].default!==void 0}function l(d){e.subschema({keyword:"properties",schemaProp:d,dataProp:d},u)}}};Vh.default=F2});var Rx=z(Bh=>{"use strict";Object.defineProperty(Bh,"__esModule",{value:!0});var Ox=gr(),Xl=ie(),Px=_e(),Cx=_e(),q2={keyword:"patternProperties",type:"object",schemaType:"object",code(e){let{gen:t,schema:r,data:n,parentSchema:i,it:o}=e,{opts:s}=o,a=(0,Ox.allSchemaProperties)(r),u=a.filter(m=>(0,Px.alwaysValidSchema)(o,r[m]));if(a.length===0||u.length===a.length&&(!o.opts.unevaluated||o.props===!0))return;let c=s.strictSchema&&!s.allowMatchingProperties&&i.properties,l=t.name("valid");o.props!==!0&&!(o.props instanceof Xl.Name)&&(o.props=(0,Cx.evaluatedPropsToName)(t,o.props));let{props:d}=o;p();function p(){for(let m of a)c&&f(m),o.allErrors?h(m):(t.var(l,!0),h(m),t.if(l))}function f(m){for(let g in c)new RegExp(m).test(g)&&(0,Px.checkStrictMode)(o,`property ${g} matches pattern ${m} (use allowMatchingProperties)`)}function h(m){t.forIn("key",n,g=>{t.if((0,Xl._)`${(0,Ox.usePattern)(e,m)}.test(${g})`,()=>{let y=u.includes(m);y||e.subschema({keyword:"patternProperties",schemaProp:m,dataProp:g,dataPropType:Cx.Type.Str},l),o.opts.unevaluated&&d!==!0?t.assign((0,Xl._)`${d}[${g}]`,!0):!y&&!o.allErrors&&t.if((0,Xl.not)(l),()=>t.break())})})}}};Bh.default=q2});var Ix=z(Wh=>{"use strict";Object.defineProperty(Wh,"__esModule",{value:!0});var L2=_e(),U2={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(e){let{gen:t,schema:r,it:n}=e;if((0,L2.alwaysValidSchema)(n,r)){e.fail();return}let i=t.name("valid");e.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},i),e.failResult(i,()=>e.reset(),()=>e.error())},error:{message:"must NOT be valid"}};Wh.default=U2});var jx=z(Jh=>{"use strict";Object.defineProperty(Jh,"__esModule",{value:!0});var V2=gr(),B2={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:V2.validateUnion,error:{message:"must match a schema in anyOf"}};Jh.default=B2});var Nx=z(Hh=>{"use strict";Object.defineProperty(Hh,"__esModule",{value:!0});var Yl=ie(),W2=_e(),J2={message:"must match exactly one schema in oneOf",params:({params:e})=>(0,Yl._)`{passingSchemas: ${e.passing}}`},H2={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:J2,code(e){let{gen:t,schema:r,parentSchema:n,it:i}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");if(i.opts.discriminator&&n.discriminator)return;let o=r,s=t.let("valid",!1),a=t.let("passing",null),u=t.name("_valid");e.setParams({passing:a}),t.block(c),e.result(s,()=>e.reset(),()=>e.error(!0));function c(){o.forEach((l,d)=>{let p;(0,W2.alwaysValidSchema)(i,l)?t.var(u,!0):p=e.subschema({keyword:"oneOf",schemaProp:d,compositeRule:!0},u),d>0&&t.if((0,Yl._)`${u} && ${s}`).assign(s,!1).assign(a,(0,Yl._)`[${a}, ${d}]`).else(),t.if(u,()=>{t.assign(s,!0),t.assign(a,d),p&&e.mergeEvaluated(p,Yl.Name)})})}}};Hh.default=H2});var Mx=z(Kh=>{"use strict";Object.defineProperty(Kh,"__esModule",{value:!0});var K2=_e(),Q2={keyword:"allOf",schemaType:"array",code(e){let{gen:t,schema:r,it:n}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");let i=t.name("valid");r.forEach((o,s)=>{if((0,K2.alwaysValidSchema)(n,o))return;let a=e.subschema({keyword:"allOf",schemaProp:s},i);e.ok(i),e.mergeEvaluated(a)})}};Kh.default=Q2});var Zx=z(Qh=>{"use strict";Object.defineProperty(Qh,"__esModule",{value:!0});var eu=ie(),Gx=_e(),X2={message:({params:e})=>(0,eu.str)`must match "${e.ifClause}" schema`,params:({params:e})=>(0,eu._)`{failingKeyword: ${e.ifClause}}`},Y2={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:X2,code(e){let{gen:t,parentSchema:r,it:n}=e;r.then===void 0&&r.else===void 0&&(0,Gx.checkStrictMode)(n,'"if" without "then" and "else" is ignored');let i=Dx(n,"then"),o=Dx(n,"else");if(!i&&!o)return;let s=t.let("valid",!0),a=t.name("_valid");if(u(),e.reset(),i&&o){let l=t.let("ifClause");e.setParams({ifClause:l}),t.if(a,c("then",l),c("else",l))}else i?t.if(a,c("then")):t.if((0,eu.not)(a),c("else"));e.pass(s,()=>e.error(!0));function u(){let l=e.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},a);e.mergeEvaluated(l)}function c(l,d){return()=>{let p=e.subschema({keyword:l},a);t.assign(s,a),e.mergeValidEvaluated(p,s),d?t.assign(d,(0,eu._)`${l}`):e.setParams({ifClause:l})}}}};function Dx(e,t){let r=e.schema[t];return r!==void 0&&!(0,Gx.alwaysValidSchema)(e,r)}Qh.default=Y2});var Fx=z(Xh=>{"use strict";Object.defineProperty(Xh,"__esModule",{value:!0});var eN=_e(),tN={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:e,parentSchema:t,it:r}){t.if===void 0&&(0,eN.checkStrictMode)(r,`"${e}" without "if" is ignored`)}};Xh.default=tN});var qx=z(Yh=>{"use strict";Object.defineProperty(Yh,"__esModule",{value:!0});var rN=jh(),nN=yx(),iN=Nh(),oN=bx(),sN=wx(),aN=Sx(),cN=$x(),lN=Lh(),uN=Ax(),dN=Rx(),fN=Ix(),mN=jx(),pN=Nx(),hN=Mx(),gN=Zx(),_N=Fx();function yN(e=!1){let t=[fN.default,mN.default,pN.default,hN.default,gN.default,_N.default,cN.default,lN.default,aN.default,uN.default,dN.default];return e?t.push(nN.default,oN.default):t.push(rN.default,iN.default),t.push(sN.default),t}Yh.default=yN});var Lx=z(eg=>{"use strict";Object.defineProperty(eg,"__esModule",{value:!0});var tt=ie(),vN={message:({schemaCode:e})=>(0,tt.str)`must match format "${e}"`,params:({schemaCode:e})=>(0,tt._)`{format: ${e}}`},bN={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:vN,code(e,t){let{gen:r,data:n,$data:i,schema:o,schemaCode:s,it:a}=e,{opts:u,errSchemaPath:c,schemaEnv:l,self:d}=a;if(!u.validateFormats)return;i?p():f();function p(){let h=r.scopeValue("formats",{ref:d.formats,code:u.code.formats}),m=r.const("fDef",(0,tt._)`${h}[${s}]`),g=r.let("fType"),y=r.let("format");r.if((0,tt._)`typeof ${m} == "object" && !(${m} instanceof RegExp)`,()=>r.assign(g,(0,tt._)`${m}.type || "string"`).assign(y,(0,tt._)`${m}.validate`),()=>r.assign(g,(0,tt._)`"string"`).assign(y,m)),e.fail$data((0,tt.or)(v(),b()));function v(){return u.strictSchema===!1?tt.nil:(0,tt._)`${s} && !${y}`}function b(){let w=l.$async?(0,tt._)`(${m}.async ? await ${y}(${n}) : ${y}(${n}))`:(0,tt._)`${y}(${n})`,S=(0,tt._)`(typeof ${y} == "function" ? ${w} : ${y}.test(${n}))`;return(0,tt._)`${y} && ${y} !== true && ${g} === ${t} && !${S}`}}function f(){let h=d.formats[o];if(!h){v();return}if(h===!0)return;let[m,g,y]=b(h);m===t&&e.pass(w());function v(){if(u.strictSchema===!1){d.logger.warn(S());return}throw new Error(S());function S(){return`unknown format "${o}" ignored in schema at path "${c}"`}}function b(S){let R=S instanceof RegExp?(0,tt.regexpCode)(S):u.code.formats?(0,tt._)`${u.code.formats}${(0,tt.getProperty)(o)}`:void 0,X=r.scopeValue("formats",{key:o,ref:S,code:R});return typeof S=="object"&&!(S instanceof RegExp)?[S.type||"string",S.validate,(0,tt._)`${X}.validate`]:["string",S,X]}function w(){if(typeof h=="object"&&!(h instanceof RegExp)&&h.async){if(!l.$async)throw new Error("async format in sync schema");return(0,tt._)`await ${y}(${n})`}return typeof g=="function"?(0,tt._)`${y}(${n})`:(0,tt._)`${y}.test(${n})`}}}};eg.default=bN});var Ux=z(tg=>{"use strict";Object.defineProperty(tg,"__esModule",{value:!0});var wN=Lx(),kN=[wN.default];tg.default=kN});var Vx=z(Ko=>{"use strict";Object.defineProperty(Ko,"__esModule",{value:!0});Ko.contentVocabulary=Ko.metadataVocabulary=void 0;Ko.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];Ko.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]});var Wx=z(rg=>{"use strict";Object.defineProperty(rg,"__esModule",{value:!0});var xN=ex(),SN=px(),TN=qx(),$N=Ux(),Bx=Vx(),EN=[xN.default,SN.default,(0,TN.default)(),$N.default,Bx.metadataVocabulary,Bx.contentVocabulary];rg.default=EN});var Hx=z(tu=>{"use strict";Object.defineProperty(tu,"__esModule",{value:!0});tu.DiscrError=void 0;var Jx;(function(e){e.Tag="tag",e.Mapping="mapping"})(Jx||(tu.DiscrError=Jx={}))});var Qx=z(ig=>{"use strict";Object.defineProperty(ig,"__esModule",{value:!0});var Qo=ie(),ng=Hx(),Kx=Nl(),zN=ga(),AN=_e(),ON={message:({params:{discrError:e,tagName:t}})=>e===ng.DiscrError.Tag?`tag "${t}" must be string`:`value of tag "${t}" must be in oneOf`,params:({params:{discrError:e,tag:t,tagName:r}})=>(0,Qo._)`{error: ${e}, tag: ${r}, tagValue: ${t}}`},PN={keyword:"discriminator",type:"object",schemaType:"object",error:ON,code(e){let{gen:t,data:r,schema:n,parentSchema:i,it:o}=e,{oneOf:s}=i;if(!o.opts.discriminator)throw new Error("discriminator: requires discriminator option");let a=n.propertyName;if(typeof a!="string")throw new Error("discriminator: requires propertyName");if(n.mapping)throw new Error("discriminator: mapping is not supported");if(!s)throw new Error("discriminator: requires oneOf keyword");let u=t.let("valid",!1),c=t.const("tag",(0,Qo._)`${r}${(0,Qo.getProperty)(a)}`);t.if((0,Qo._)`typeof ${c} == "string"`,()=>l(),()=>e.error(!1,{discrError:ng.DiscrError.Tag,tag:c,tagName:a})),e.ok(u);function l(){let f=p();t.if(!1);for(let h in f)t.elseIf((0,Qo._)`${c} === ${h}`),t.assign(u,d(f[h]));t.else(),e.error(!1,{discrError:ng.DiscrError.Mapping,tag:c,tagName:a}),t.endIf()}function d(f){let h=t.name("valid"),m=e.subschema({keyword:"oneOf",schemaProp:f},h);return e.mergeEvaluated(m,Qo.Name),h}function p(){var f;let h={},m=y(i),g=!0;for(let w=0;w<s.length;w++){let S=s[w];if(S?.$ref&&!(0,AN.schemaHasRulesButRef)(S,o.self.RULES)){let X=S.$ref;if(S=Kx.resolveRef.call(o.self,o.schemaEnv.root,o.baseId,X),S instanceof Kx.SchemaEnv&&(S=S.schema),S===void 0)throw new zN.default(o.opts.uriResolver,o.baseId,X)}let R=(f=S?.properties)===null||f===void 0?void 0:f[a];if(typeof R!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${a}"`);g=g&&(m||y(S)),v(R,w)}if(!g)throw new Error(`discriminator: "${a}" must be required`);return h;function y({required:w}){return Array.isArray(w)&&w.includes(a)}function v(w,S){if(w.const)b(w.const,S);else if(w.enum)for(let R of w.enum)b(R,S);else throw new Error(`discriminator: "properties/${a}" must have "const" or "enum"`)}function b(w,S){if(typeof w!="string"||w in h)throw new Error(`discriminator: "${a}" values must be unique strings`);h[w]=S}}}};ig.default=PN});var Xx=z((Dq,CN)=>{CN.exports={$schema:"http://json-schema.org/draft-07/schema#",$id:"http://json-schema.org/draft-07/schema#",title:"Core schema meta-schema",definitions:{schemaArray:{type:"array",minItems:1,items:{$ref:"#"}},nonNegativeInteger:{type:"integer",minimum:0},nonNegativeIntegerDefault0:{allOf:[{$ref:"#/definitions/nonNegativeInteger"},{default:0}]},simpleTypes:{enum:["array","boolean","integer","null","number","object","string"]},stringArray:{type:"array",items:{type:"string"},uniqueItems:!0,default:[]}},type:["object","boolean"],properties:{$id:{type:"string",format:"uri-reference"},$schema:{type:"string",format:"uri"},$ref:{type:"string",format:"uri-reference"},$comment:{type:"string"},title:{type:"string"},description:{type:"string"},default:!0,readOnly:{type:"boolean",default:!1},examples:{type:"array",items:!0},multipleOf:{type:"number",exclusiveMinimum:0},maximum:{type:"number"},exclusiveMaximum:{type:"number"},minimum:{type:"number"},exclusiveMinimum:{type:"number"},maxLength:{$ref:"#/definitions/nonNegativeInteger"},minLength:{$ref:"#/definitions/nonNegativeIntegerDefault0"},pattern:{type:"string",format:"regex"},additionalItems:{$ref:"#"},items:{anyOf:[{$ref:"#"},{$ref:"#/definitions/schemaArray"}],default:!0},maxItems:{$ref:"#/definitions/nonNegativeInteger"},minItems:{$ref:"#/definitions/nonNegativeIntegerDefault0"},uniqueItems:{type:"boolean",default:!1},contains:{$ref:"#"},maxProperties:{$ref:"#/definitions/nonNegativeInteger"},minProperties:{$ref:"#/definitions/nonNegativeIntegerDefault0"},required:{$ref:"#/definitions/stringArray"},additionalProperties:{$ref:"#"},definitions:{type:"object",additionalProperties:{$ref:"#"},default:{}},properties:{type:"object",additionalProperties:{$ref:"#"},default:{}},patternProperties:{type:"object",additionalProperties:{$ref:"#"},propertyNames:{format:"regex"},default:{}},dependencies:{type:"object",additionalProperties:{anyOf:[{$ref:"#"},{$ref:"#/definitions/stringArray"}]}},propertyNames:{$ref:"#"},const:!0,enum:{type:"array",items:!0,minItems:1,uniqueItems:!0},type:{anyOf:[{$ref:"#/definitions/simpleTypes"},{type:"array",items:{$ref:"#/definitions/simpleTypes"},minItems:1,uniqueItems:!0}]},format:{type:"string"},contentMediaType:{type:"string"},contentEncoding:{type:"string"},if:{$ref:"#"},then:{$ref:"#"},else:{$ref:"#"},allOf:{$ref:"#/definitions/schemaArray"},anyOf:{$ref:"#/definitions/schemaArray"},oneOf:{$ref:"#/definitions/schemaArray"},not:{$ref:"#"}},default:!0}});var sg=z((je,og)=>{"use strict";Object.defineProperty(je,"__esModule",{value:!0});je.MissingRefError=je.ValidationError=je.CodeGen=je.Name=je.nil=je.stringify=je.str=je._=je.KeywordCxt=je.Ajv=void 0;var RN=Jk(),IN=Wx(),jN=Qx(),Yx=Xx(),NN=["/properties"],ru="http://json-schema.org/draft-07/schema",Xo=class extends RN.default{_addVocabularies(){super._addVocabularies(),IN.default.forEach(t=>this.addVocabulary(t)),this.opts.discriminator&&this.addKeyword(jN.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let t=this.opts.$data?this.$dataMetaSchema(Yx,NN):Yx;this.addMetaSchema(t,ru,!1),this.refs["http://json-schema.org/schema"]=ru}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(ru)?ru:void 0)}};je.Ajv=Xo;og.exports=je=Xo;og.exports.Ajv=Xo;Object.defineProperty(je,"__esModule",{value:!0});je.default=Xo;var MN=ha();Object.defineProperty(je,"KeywordCxt",{enumerable:!0,get:function(){return MN.KeywordCxt}});var Yo=ie();Object.defineProperty(je,"_",{enumerable:!0,get:function(){return Yo._}});Object.defineProperty(je,"str",{enumerable:!0,get:function(){return Yo.str}});Object.defineProperty(je,"stringify",{enumerable:!0,get:function(){return Yo.stringify}});Object.defineProperty(je,"nil",{enumerable:!0,get:function(){return Yo.nil}});Object.defineProperty(je,"Name",{enumerable:!0,get:function(){return Yo.Name}});Object.defineProperty(je,"CodeGen",{enumerable:!0,get:function(){return Yo.CodeGen}});var DN=Il();Object.defineProperty(je,"ValidationError",{enumerable:!0,get:function(){return DN.default}});var GN=ga();Object.defineProperty(je,"MissingRefError",{enumerable:!0,get:function(){return GN.default}})});var aS=z(tn=>{"use strict";Object.defineProperty(tn,"__esModule",{value:!0});tn.formatNames=tn.fastFormats=tn.fullFormats=void 0;function en(e,t){return{validate:e,compare:t}}tn.fullFormats={date:en(nS,ug),time:en(cg(!0),dg),"date-time":en(eS(!0),oS),"iso-time":en(cg(),iS),"iso-date-time":en(eS(),sS),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:VN,"uri-reference":/^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,"uri-template":/^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,url:/^(?:https?|ftp):\/\/(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)(?:\.(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu,email:/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,hostname:/^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i,ipv4:/^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$/,ipv6:/^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i,regex:XN,uuid:/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,"json-pointer":/^(?:\/(?:[^~/]|~0|~1)*)*$/,"json-pointer-uri-fragment":/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,"relative-json-pointer":/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,byte:BN,int32:{type:"number",validate:HN},int64:{type:"number",validate:KN},float:{type:"number",validate:rS},double:{type:"number",validate:rS},password:!0,binary:!0};tn.fastFormats={...tn.fullFormats,date:en(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,ug),time:en(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,dg),"date-time":en(/^\d\d\d\d-[0-1]\d-[0-3]\dt(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,oS),"iso-time":en(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,iS),"iso-date-time":en(/^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,sS),uri:/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/)?[^\s]*$/i,"uri-reference":/^(?:(?:[a-z][a-z0-9+\-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i,email:/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i};tn.formatNames=Object.keys(tn.fullFormats);function ZN(e){return e%4===0&&(e%100!==0||e%400===0)}var FN=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,qN=[0,31,28,31,30,31,30,31,31,30,31,30,31];function nS(e){let t=FN.exec(e);if(!t)return!1;let r=+t[1],n=+t[2],i=+t[3];return n>=1&&n<=12&&i>=1&&i<=(n===2&&ZN(r)?29:qN[n])}function ug(e,t){if(e&&t)return e>t?1:e<t?-1:0}var ag=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function cg(e){return function(r){let n=ag.exec(r);if(!n)return!1;let i=+n[1],o=+n[2],s=+n[3],a=n[4],u=n[5]==="-"?-1:1,c=+(n[6]||0),l=+(n[7]||0);if(c>23||l>59||e&&!a)return!1;if(i<=23&&o<=59&&s<60)return!0;let d=o-l*u,p=i-c*u-(d<0?1:0);return(p===23||p===-1)&&(d===59||d===-1)&&s<61}}function dg(e,t){if(!(e&&t))return;let r=new Date("2020-01-01T"+e).valueOf(),n=new Date("2020-01-01T"+t).valueOf();if(r&&n)return r-n}function iS(e,t){if(!(e&&t))return;let r=ag.exec(e),n=ag.exec(t);if(r&&n)return e=r[1]+r[2]+r[3],t=n[1]+n[2]+n[3],e>t?1:e<t?-1:0}var lg=/t|\s/i;function eS(e){let t=cg(e);return function(n){let i=n.split(lg);return i.length===2&&nS(i[0])&&t(i[1])}}function oS(e,t){if(!(e&&t))return;let r=new Date(e).valueOf(),n=new Date(t).valueOf();if(r&&n)return r-n}function sS(e,t){if(!(e&&t))return;let[r,n]=e.split(lg),[i,o]=t.split(lg),s=ug(r,i);if(s!==void 0)return s||dg(n,o)}var LN=/\/|:/,UN=/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;function VN(e){return LN.test(e)&&UN.test(e)}var tS=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function BN(e){return tS.lastIndex=0,tS.test(e)}var WN=-(2**31),JN=2**31-1;function HN(e){return Number.isInteger(e)&&e<=JN&&e>=WN}function KN(e){return Number.isInteger(e)}function rS(){return!0}var QN=/[^\\]\\Z/;function XN(e){if(QN.test(e))return!1;try{return new RegExp(e),!0}catch{return!1}}});var cS=z(es=>{"use strict";Object.defineProperty(es,"__esModule",{value:!0});es.formatLimitDefinition=void 0;var YN=sg(),Rr=ie(),Yn=Rr.operators,nu={formatMaximum:{okStr:"<=",ok:Yn.LTE,fail:Yn.GT},formatMinimum:{okStr:">=",ok:Yn.GTE,fail:Yn.LT},formatExclusiveMaximum:{okStr:"<",ok:Yn.LT,fail:Yn.GTE},formatExclusiveMinimum:{okStr:">",ok:Yn.GT,fail:Yn.LTE}},eM={message:({keyword:e,schemaCode:t})=>(0,Rr.str)`should be ${nu[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0,Rr._)`{comparison: ${nu[e].okStr}, limit: ${t}}`};es.formatLimitDefinition={keyword:Object.keys(nu),type:"string",schemaType:"string",$data:!0,error:eM,code(e){let{gen:t,data:r,schemaCode:n,keyword:i,it:o}=e,{opts:s,self:a}=o;if(!s.validateFormats)return;let u=new YN.KeywordCxt(o,a.RULES.all.format.definition,"format");u.$data?c():l();function c(){let p=t.scopeValue("formats",{ref:a.formats,code:s.code.formats}),f=t.const("fmt",(0,Rr._)`${p}[${u.schemaCode}]`);e.fail$data((0,Rr.or)((0,Rr._)`typeof ${f} != "object"`,(0,Rr._)`${f} instanceof RegExp`,(0,Rr._)`typeof ${f}.compare != "function"`,d(f)))}function l(){let p=u.schema,f=a.formats[p];if(!f||f===!0)return;if(typeof f!="object"||f instanceof RegExp||typeof f.compare!="function")throw new Error(`"${i}": format "${p}" does not define "compare" function`);let h=t.scopeValue("formats",{key:p,ref:f,code:s.code.formats?(0,Rr._)`${s.code.formats}${(0,Rr.getProperty)(p)}`:void 0});e.fail$data(d(h))}function d(p){return(0,Rr._)`${p}.compare(${r}, ${n}) ${nu[i].fail} 0`}},dependencies:["format"]};var tM=e=>(e.addKeyword(es.formatLimitDefinition),e);es.default=tM});var fS=z((Oa,dS)=>{"use strict";Object.defineProperty(Oa,"__esModule",{value:!0});var ts=aS(),rM=cS(),fg=ie(),lS=new fg.Name("fullFormats"),nM=new fg.Name("fastFormats"),mg=(e,t={keywords:!0})=>{if(Array.isArray(t))return uS(e,t,ts.fullFormats,lS),e;let[r,n]=t.mode==="fast"?[ts.fastFormats,nM]:[ts.fullFormats,lS],i=t.formats||ts.formatNames;return uS(e,i,r,n),t.keywords&&(0,rM.default)(e),e};mg.get=(e,t="full")=>{let n=(t==="fast"?ts.fastFormats:ts.fullFormats)[e];if(!n)throw new Error(`Unknown format "${e}"`);return n};function uS(e,t,r,n){var i,o;(i=(o=e.opts.code).formats)!==null&&i!==void 0||(o.formats=(0,fg._)`require("ajv-formats/dist/formats").${n}`);for(let s of t)e.addFormat(s,r[s])}dS.exports=Oa=mg;Object.defineProperty(Oa,"__esModule",{value:!0});Oa.default=mg});import*as zS from"node:url";import*as me from"node:fs";import*as Va from"node:crypto";function Dt(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 Nr(e){if(e!=null)return Dt(e)}function he(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 br(e){if(e.RE_EXN_ID==="JsExn")return Dt(e._1)}var Ia=(e=>t=>t&&typeof t[e]=="string"?t[e]:void 0),SM=Ia("stack"),wr=Ia("message"),TM=Ia("name"),$M=Ia("fileName");function He(e,t){if(e!==void 0)return Dt(t(he(e)))}function Ke(e,t){if(e!==void 0)return t(he(e))}function rt(e,t){return e!==void 0?he(e):t}var _T=Ra($u(),1);var Qg=(function(e,t){for(var r in e)t(r)});function Pt(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 s=e.length|0,a=t.length|0;if(s===a)if(Array.isArray(e)){let u=0;for(;;){let c=u;if(c===s)return!0;if(!Pt(e[c],t[c]))return!1;u=c+1|0}}else{if(e instanceof Date&&t instanceof Date)return!(e>t||e<t);{let u={contents:!0},c=d=>{if(!Object.prototype.hasOwnProperty.call(t,d)){u.contents=!1;return}},l=d=>{if(!Object.prototype.hasOwnProperty.call(e,d)||!Pt(t[d],e[d])){u.contents=!1;return}};return Qg(e,c),u.contents&&Qg(t,l),u.contents}}else return!1}import*as Yg from"node:child_process";function gT(e){return e==null?!1:typeof e.RE_EXN_ID=="string"}function K(e){return gT(e)?e:{RE_EXN_ID:"JsExn",_1:e}}var Eu={};function Xg(e){let t=Eu[e];if(t!==void 0){let r=t+1|0;return Eu[e]=r,e+("/"+r)}return Eu[e]=1,e}function We(e){let t=br(e);if(t===void 0)return{code:void 0,message:"unknown error"};let r=he(t);return{code:Nr(r.code),message:rt(wr(r),"unknown error")}}function e_(e,t){return Pt(e.code,t)}function kr(e){try{return{TAG:"Ok",_0:me.readFileSync(e,"utf8")}}catch(t){let r=K(t);return{TAG:"Error",_0:We(r)}}}function t_(e,t){try{return{TAG:"Ok",_0:(me.writeFileSync(e,t,"utf8"),void 0)}}catch(r){let n=K(r);return{TAG:"Error",_0:We(n)}}}function as(e,t,r){try{return{TAG:"Ok",_0:(me.writeFileSync(e,t,r),void 0)}}catch(n){let i=K(n);return{TAG:"Error",_0:We(i)}}}function xr(e){try{return{TAG:"Ok",_0:(me.mkdirSync(e,{recursive:!0}),void 0)}}catch(t){let r=K(t);return{TAG:"Error",_0:We(r)}}}function Ba(e,t){try{return{TAG:"Ok",_0:(me.chmodSync(e,t),void 0)}}catch(r){let n=K(r);return{TAG:"Error",_0:We(n)}}}function r_(e,t){try{return{TAG:"Ok",_0:(me.linkSync(e,t),void 0)}}catch(r){let n=K(r);return{TAG:"Error",_0:We(n)}}}function n_(e){try{return{TAG:"Ok",_0:(me.unlinkSync(e),void 0)}}catch(t){let r=K(t);return{TAG:"Error",_0:We(r)}}}function Wa(e,t){try{return{TAG:"Ok",_0:(me.renameSync(e,t),void 0)}}catch(r){let n=K(r);return{TAG:"Error",_0:We(n)}}}function si(e){try{return{TAG:"Ok",_0:(me.rmSync(e,{force:!0}),void 0)}}catch(t){let r=K(t);return{TAG:"Error",_0:We(r)}}}function Ja(e){return Va.createHash("sha256").update(e).digest("hex")}function i_(e){try{return Va.randomBytes(e).toString("hex")}catch{return""}}function o_(e){try{return{TAG:"Ok",_0:me.readdirSync(e)}}catch(t){let r=K(t);return{TAG:"Error",_0:We(r)}}}function s_(e,t,r,n){try{return{TAG:"Ok",_0:Yg.execFileSync(e,t,{encoding:"utf8",timeout:r,maxBuffer:n})}}catch(i){let o=K(i);return{TAG:"Error",_0:We(o)}}}function $n(e){try{return process.stderr.write(e)}catch{return!1}}function cs(e,t){return e[t]}function zu(e,t){try{return process.kill(e,t),{TAG:"Ok",_0:void 0}}catch(r){let n=K(r);return{TAG:"Error",_0:We(n)}}}function En(e){try{return Dt(new URL(e))}catch{return}}function a_(e){return e.keys().toArray()}function Kt(e,t){try{return{TAG:"Ok",_0:new URL(e,t)}}catch(r){let n=K(r),i=br(n);return{TAG:"Error",_0:i!==void 0?rt(wr(he(i)),"unknown error"):"unknown error"}}}var it={};it["api-url"]="ValueKind";it.token="ValueKind";it["auth-file"]="ValueKind";it["delegation-auth-file"]="ValueKind";it.workspace="ValueKind";it.channel="ValueKind";it["owner-username"]="ValueKind";it.mode="ValueKind";it.cwd="ValueKind";it["thread-id"]="ValueKind";it.format="ValueKind";it.command="ValueKind";it["tool-scope"]="ValueKind";it["agent-session"]="BooleanKind";it["ask-user-question-tool"]="BooleanKind";it["multi-agent-jobs"]="BooleanKind";it["include-token"]="BooleanKind";it.help="BooleanKind";function Ha(e){let t={},r,n=0;for(;r===void 0&&n<e.length;){let o=e[n];if(o!==void 0)if(o.startsWith("--")){let s=o.slice(2),a=it[s];if(a!==void 0)if(a==="ValueKind"){let u=e[n+1|0];u!==void 0?u.startsWith("--")?r="--"+s+" requires a value":(t[s]={TAG:"ValueFlag",_0:u},n=n+2|0):r="--"+s+" requires a value"}else t[s]="BoolFlag",n=n+1|0;else r="unsupported option --"+s}else r="unexpected argument "+o;else n=n+1|0}let i=r;return i!==void 0?{TAG:"Error",_0:i}:{TAG:"Ok",_0:t}}function Qe(e,t){let r=e[t];if(r===void 0||typeof r!="object")return;let n=r._0;if(n.trim()!=="")return n}function so(e,t){let r=e[t];return r!==void 0?typeof r!="object":!1}function Ka(e,t){let r=Qe(e,t);return r!==void 0?{TAG:"Ok",_0:r}:{TAG:"Error",_0:"--"+t+" is required"}}function Qa(e){if(e===void 0)return{TAG:"Ok",_0:"Text"};switch(e){case"text":return{TAG:"Ok",_0:"Text"};case"voice":return{TAG:"Ok",_0:"Voice"};default:return{TAG:"Error",_0:"--mode must be voice or text"}}}function Au(e){if(e===void 0)return{TAG:"Ok",_0:"All"};switch(e){case"all":return{TAG:"Ok",_0:"All"};case"coding":return{TAG:"Ok",_0:"Coding"};case"onboarding-discovery":return{TAG:"Ok",_0:"OnboardingDiscovery"};default:return{TAG:"Error",_0:"--tool-scope must be all, coding, or onboarding-discovery"}}}function c_(e){return e[0]==="mcp"?e.slice(1):e}function Xa(){return`Linzumi MCP
12
12
 
13
13
  Usage:
14
14
  linzumi mcp server --api-url <url> [--mode voice|text] [--workspace <slug> --channel <slug>]
@@ -103,12 +103,12 @@ Tools:
103
103
  Auth:
104
104
  Uses --token, LINZUMI_MCP_ACCESS_TOKEN, or cached local runner OAuth from linzumi auth.
105
105
  Hosted personal agents use --delegation-auth-file with a signed delegation grant.
106
- `}function l_(e){throw e}function u_(e){throw e}function Ou(e){throw e}function Ce(e){throw new Error(e)}function on(e){let t=br(e);if(t===void 0)return"unknown error";let r=ve(t);return rt(wr(r),String(r))}function _T(e,t){return fetch(e,t)}function yT(e,t){return fetch(e,t)}var Ya={json:_T,binary:yT};function d_(e){return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength|0)}function ec(e){return new Promise((t,r)=>{setTimeout(()=>t(),e)})}function Pu(e){process.exitCode=e}function si(e){process.stdout.write(e)}function Me(e,t){return e.TAG==="Ok"?{TAG:"Ok",_0:t(e._0)}:e}function Y(e,t){return e.TAG==="Ok"?t(e._0):e}function ye(e,t){return e.TAG==="Ok"?e:{TAG:"Error",_0:t(e._0)}}function m_(e,t,r){return e.reduce(r,t)}function Qt(e,t){let r=e.length,n=new Array(r),i=0;for(let o=0;o<r;++o){let s=e[o],a=t(s);a!==void 0&&(n[i]=ve(a),i=i+1|0)}return n.length=i,n}var __={},fc=[],kT=(e=>({...e}));function po(e){let t=0;for(;;){let r=t,n=e[r];if(n===void 0)return'"'+e+'"';switch(n){case'"':case`
107
- `:return JSON.stringify(e);default:t=r+1|0;continue}}}function xT(e){return e===""?[]:JSON.parse(e.split('"]["').join('","'))}function ST(e){return"["+po(e)+"]"}function TT(e){let t=e.length;return t!==1?t!==0?e.map(ST).join(""):"":"["+po(e[0])+"]"}var Du="sury",Gu=Symbol(Du),Zu=Symbol(Du+":item"),lo="string",An="number",$T="bigint",ET="boolean",zT="symbol",uo="null",Gr="undefined",ju="nan";var Fu="instance",li="array",ut="object",On="union",Nu="never",gs="unknown",AT="ref",qu=Xg("Sury.Exn"),Zr="const";function OT(e){return e.type===Gr?!0:e.type===On?Gr in e.has:!1}function PT(e,t){return(e&t)!==0}var Ye={[gs]:1,[lo]:2,[An]:4,[ET]:8,[Gr]:16,[uo]:32,[ut]:64,[li]:128,[On]:256,[AT]:512,[$T]:1024,[ju]:2048,function:4096,[Fu]:8192,[Nu]:32768,[zT]:16384};function nc(e){let t=Ye[typeof e];if(t&16)return Gr;if(!(t&64))return t&2?'"'+e+'"':t&1024?e+"n":t&4096?"Function":e.toString();if(e===null)return uo;if(Array.isArray(e)){let i="[";for(let o=0,s=e.length;o<s;++o)o!==0&&(i=i+", "),i=i+nc(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 s=r[i],a=e[s];n=n+s+": "+nc(a)+"; "}return n+"}"}function Xe(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 nc(n);let o=e.format,s=e.anyOf;if(s!==void 0)return s.map(Xe).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"?Xe(a)+"[]":"unknown[][]";let u=r.properties;return u===void 0?"unknown[][]":"["+Object.keys(u).map(l=>{let d=u[l];return Xe(d)+"[]"}).join(", ")+"]"}switch(t){case"nan":return"NaN";case"object":let a=e.additionalItems,u=e.properties,c=Object.keys(u);return c.length===0?typeof a===ut?"{ [key: string]: "+Xe(a)+"; }":"{}":"{ "+c.map(l=>l+": "+Xe(u[l])+";").join(" ")+" }";default:if(e.b)return t;switch(t){case"instance":return e.class.name;case"array":let l=e.additionalItems,d=e.items;if(typeof l!==ut)return"["+d.map(Xe).join(", ")+"]";let p=Xe(l);return(l.type===On?"("+p+")":p)+"[]";default:return t}}}var ui=class extends Error{constructor(t){super();for(let r in t)this[r]=t[r]}},Sr=Object.defineProperty,_s=ui.prototype;Sr(_s,"message",{get(){return v_(this)}});Sr(_s,"name",{value:"SuryError"});Sr(_s,"s",{value:Gu});Sr(_s,"_1",{get(){return this}});Sr(_s,"RE_EXN_ID",{value:qu});var y_=1,Lu=function(){},Uu=Object.create(null);Sr(Uu,"with",{get(){return(e,...t)=>e(this,...t)}});Lu.prototype=Uu;function mc(e){if(e&&e.s===Gu)return e;throw e}function v_(e){let t=e.path;return(t===""?"":"Failed at "+t+": ")+e.reason}var ls={m:v_,d:void 0,a:"strip",f:0},En={};var ic="value",ao="r";function Ct(e,t){let r=new Lu;return r.type=e,r.seq=y_++,t&&(En[ic]=r,Sr(r,ao,En)),r}function b_(e){return e}var Cu={};function ho(e,t,r){if(Cu[e])return Cu[e];let n=Ct(t,!0);return r(n),Cu[e]=n,n}var lt=Ct(gs,!0);lt.decoder=b_;var fo=(e=>{let t=new Lu;for(let r in e)t[r]=e[r];return t.seq=y_++,t});function Pn(e,t){let r=fo(e),n=r;for(;n.to;){let i=fo(n.to);n.to=i,n=i}return t(n),r}function di(e,t){let r=e.g.e,n=r.length;return r[n]=t,"e["+n+"]"}function ys(e,t){let r=Ye[t.type],n=t.const;return r&16?"void 0":r&2?po(n):r&1024?n+"n":r&28672?di(e,t.const):n}function fi(e,t){let r='"'+t+'"',n=e[r];if(n!==void 0)return n;let i=po(t);return e[r]=i,i}function Zt(){return this.i}function CT(){return this.b.v()}function RT(){return this.prev.v()}function ar(e){let t=e.v+1;return e.v=t,"v"+t}function oc(e,t){e.hd=e.hd===""?t:e.hd+","+t}function IT(){let e=this,t=ar(e.g);return e.cp="let "+t+"="+e.i+";",e.i=t,e.v=Zt,t}function Mu(){let e=this,t=e.p;if(t.fz)return e.v=Zt,e.i;let r=ar(e.g);return oc(t,r+"="+e.i),e.v=Zt,e.i=r,r}function sc(){let e=this;if(e.fz)return e.v=Zt,e.i="("+e.i+")",e.i;let t=ar(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===""?oc(e,t):oc(e,t+"="+n)}return e.v=Zt,e.i=t,t}function jT(e,t,r,n){return{v:Zt,i:"i",s:e,e:t,f:0,cp:"",hd:"",path:"",g:{v:-1,o:r,e:[],d:n}}}function vs(e,t,r){let n=e.path,i="Can't decode "+Xe(t)+" to "+Xe(r)+". Use S.to to define a custom decoder",o={code:"unsupported_decode",path:n,reason:i,from:t,to:r};throw new ui(o)}function us(e,t,r){return di(e,n=>{let i=t(n);throw new ui(i)})+"("+r+")"}function w_(e,t,r,n,i,o,s){let a=s!==void 0?s:"Expected "+Xe(e)+", received "+(i?nc(n):Xe(t));if(o!==void 0){let c={};for(let l=0,d=o.length;l<d;++l){let p=o[l],f=p.reason.split(`
106
+ `}function u_(e){throw e}function d_(e){throw e}function Ou(e){throw e}function Pe(e){throw new Error(e)}function on(e){let t=br(e);if(t===void 0)return"unknown error";let r=he(t);return rt(wr(r),String(r))}function yT(e,t){return fetch(e,t)}function vT(e,t){return fetch(e,t)}var Ya={json:yT,binary:vT};function f_(e){return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength|0)}function ec(e){return new Promise((t,r)=>{setTimeout(()=>t(),e)})}function Pu(e){process.exitCode=e}function ai(e){process.stdout.write(e)}function Me(e,t){return e.TAG==="Ok"?{TAG:"Ok",_0:t(e._0)}:e}function Y(e,t){return e.TAG==="Ok"?t(e._0):e}function ve(e,t){return e.TAG==="Ok"?e:{TAG:"Error",_0:t(e._0)}}function p_(e,t,r){return e.reduce(r,t)}function Qt(e,t){let r=e.length,n=new Array(r),i=0;for(let o=0;o<r;++o){let s=e[o],a=t(s);a!==void 0&&(n[i]=he(a),i=i+1|0)}return n.length=i,n}var y_={},fc=[],xT=(e=>({...e}));function po(e){let t=0;for(;;){let r=t,n=e[r];if(n===void 0)return'"'+e+'"';switch(n){case'"':case`
107
+ `:return JSON.stringify(e);default:t=r+1|0;continue}}}function ST(e){return e===""?[]:JSON.parse(e.split('"]["').join('","'))}function TT(e){return"["+po(e)+"]"}function $T(e){let t=e.length;return t!==1?t!==0?e.map(TT).join(""):"":"["+po(e[0])+"]"}var Du="sury",Gu=Symbol(Du),Zu=Symbol(Du+":item"),lo="string",On="number",ET="bigint",zT="boolean",AT="symbol",uo="null",Gr="undefined",ju="nan";var Fu="instance",ui="array",ut="object",Pn="union",Nu="never",gs="unknown",OT="ref",qu=Xg("Sury.Exn"),Zr="const";function PT(e){return e.type===Gr?!0:e.type===Pn?Gr in e.has:!1}function CT(e,t){return(e&t)!==0}var Ye={[gs]:1,[lo]:2,[On]:4,[zT]:8,[Gr]:16,[uo]:32,[ut]:64,[ui]:128,[Pn]:256,[OT]:512,[ET]:1024,[ju]:2048,function:4096,[Fu]:8192,[Nu]:32768,[AT]:16384};function nc(e){let t=Ye[typeof e];if(t&16)return Gr;if(!(t&64))return t&2?'"'+e+'"':t&1024?e+"n":t&4096?"Function":e.toString();if(e===null)return uo;if(Array.isArray(e)){let i="[";for(let o=0,s=e.length;o<s;++o)o!==0&&(i=i+", "),i=i+nc(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 s=r[i],a=e[s];n=n+s+": "+nc(a)+"; "}return n+"}"}function Xe(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 nc(n);let o=e.format,s=e.anyOf;if(s!==void 0)return s.map(Xe).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"?Xe(a)+"[]":"unknown[][]";let u=r.properties;return u===void 0?"unknown[][]":"["+Object.keys(u).map(l=>{let d=u[l];return Xe(d)+"[]"}).join(", ")+"]"}switch(t){case"nan":return"NaN";case"object":let a=e.additionalItems,u=e.properties,c=Object.keys(u);return c.length===0?typeof a===ut?"{ [key: string]: "+Xe(a)+"; }":"{}":"{ "+c.map(l=>l+": "+Xe(u[l])+";").join(" ")+" }";default:if(e.b)return t;switch(t){case"instance":return e.class.name;case"array":let l=e.additionalItems,d=e.items;if(typeof l!==ut)return"["+d.map(Xe).join(", ")+"]";let p=Xe(l);return(l.type===Pn?"("+p+")":p)+"[]";default:return t}}}var di=class extends Error{constructor(t){super();for(let r in t)this[r]=t[r]}},Sr=Object.defineProperty,_s=di.prototype;Sr(_s,"message",{get(){return b_(this)}});Sr(_s,"name",{value:"SuryError"});Sr(_s,"s",{value:Gu});Sr(_s,"_1",{get(){return this}});Sr(_s,"RE_EXN_ID",{value:qu});var v_=1,Lu=function(){},Uu=Object.create(null);Sr(Uu,"with",{get(){return(e,...t)=>e(this,...t)}});Lu.prototype=Uu;function mc(e){if(e&&e.s===Gu)return e;throw e}function b_(e){let t=e.path;return(t===""?"":"Failed at "+t+": ")+e.reason}var ls={m:b_,d:void 0,a:"strip",f:0},zn={};var ic="value",ao="r";function Ct(e,t){let r=new Lu;return r.type=e,r.seq=v_++,t&&(zn[ic]=r,Sr(r,ao,zn)),r}function w_(e){return e}var Cu={};function ho(e,t,r){if(Cu[e])return Cu[e];let n=Ct(t,!0);return r(n),Cu[e]=n,n}var lt=Ct(gs,!0);lt.decoder=w_;var fo=(e=>{let t=new Lu;for(let r in e)t[r]=e[r];return t.seq=v_++,t});function Cn(e,t){let r=fo(e),n=r;for(;n.to;){let i=fo(n.to);n.to=i,n=i}return t(n),r}function fi(e,t){let r=e.g.e,n=r.length;return r[n]=t,"e["+n+"]"}function ys(e,t){let r=Ye[t.type],n=t.const;return r&16?"void 0":r&2?po(n):r&1024?n+"n":r&28672?fi(e,t.const):n}function mi(e,t){let r='"'+t+'"',n=e[r];if(n!==void 0)return n;let i=po(t);return e[r]=i,i}function Zt(){return this.i}function RT(){return this.b.v()}function IT(){return this.prev.v()}function sr(e){let t=e.v+1;return e.v=t,"v"+t}function oc(e,t){e.hd=e.hd===""?t:e.hd+","+t}function jT(){let e=this,t=sr(e.g);return e.cp="let "+t+"="+e.i+";",e.i=t,e.v=Zt,t}function Mu(){let e=this,t=e.p;if(t.fz)return e.v=Zt,e.i;let r=sr(e.g);return oc(t,r+"="+e.i),e.v=Zt,e.i=r,r}function sc(){let e=this;if(e.fz)return e.v=Zt,e.i="("+e.i+")",e.i;let t=sr(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===""?oc(e,t):oc(e,t+"="+n)}return e.v=Zt,e.i=t,t}function NT(e,t,r,n){return{v:Zt,i:"i",s:e,e:t,f:0,cp:"",hd:"",path:"",g:{v:-1,o:r,e:[],d:n}}}function vs(e,t,r){let n=e.path,i="Can't decode "+Xe(t)+" to "+Xe(r)+". Use S.to to define a custom decoder",o={code:"unsupported_decode",path:n,reason:i,from:t,to:r};throw new di(o)}function us(e,t,r){return fi(e,n=>{let i=t(n);throw new di(i)})+"("+r+")"}function k_(e,t,r,n,i,o,s){let a=s!==void 0?s:"Expected "+Xe(e)+", received "+(i?nc(n):Xe(t));if(o!==void 0){let c={};for(let l=0,d=o.length;l<d;++l){let p=o[l],f=p.reason.split(`
108
108
  `).join(`
109
109
  `),h=p.path,g=`
110
- - `+(h===""?"":"At "+h+": ")+f;c[g]||(c[g]=1,a=a+g)}}let u={code:"invalid_input",path:r,reason:a,expected:e,received:t,unionErrors:o};return i&&(u.input=n),u}function Vu(e,t,r,n){return i=>{let o=t!==void 0?t:"",s=n!==void 0?n:!0,a=e!==void 0?e:i.e,u=i.prev,c=u!==void 0?u.s:i.s,l=o===""?i.path:i.path+o;return d=>w_(a,c,l,d,s,void 0,r)}}function mt(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 Vu(void 0,void 0,r,void 0)(e)}function NT(e,t){let r=t!==void 0?t:e.e;return us(e,Vu(r,void 0,void 0,void 0)(e),e.v())}function MT(e,t){let r=e.vc,n=r.length;if(n===1){let s=r[0];return s.c(t)+"||"+us(e,s.f(e),t)+";"}let i="",o=0;for(;o<n;){let s=r[o],a=s.f,u=s.c(t);for(o=o+1|0;o<n&&r[o].f===a;)u=u+"&&"+r[o].c(t),o=o+1|0;i=i+(u+"||"+us(e,a(e),t)+";")}return i}function k_(e){return e.t===!0?e.prev.t!==!0?e.cp==="":!1:!0}function Dr(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&&k_(i)){let a=r.v(),u=i.vc,c="";for(let l=0,d=u.length;l<d;++l){let p=u[l],f=p.c(a);p.f===mt?c=c?c+"&&"+f:f:i.e.noValidation!==!0&&(o=o+(f+"||"+us(i,p.f(i),a)+";"))}c&&(t.contents?t.contents=c+"&&"+t.contents:t.contents=c)}else i.e.noValidation!==!0&&(o=MT(i,r.v()));i.hd!==""&&(o=o+("let "+i.hd+";")),i.fz=!0,o=i.cp+o,n=o+n}return n}function Fr(e,t,r,n){let i=n!==void 0?n:e.e;return{v:sc,i:t,s:r,e:i,prev:e,f:0,d:e.d,cp:"",hd:"",t:!0,path:e.path,g:e.g}}function De(e,t,r,n){let i=t!==void 0?t:e.s,o=n!==void 0?n:e.e,s=e.v!==Zt,a={v:s?RT:Zt,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(s){let u=e.v.bind(e);e.v=()=>{let c=u();return a.i=c,a.v=Zt,c}}return a}function Bu(e,t){let r=e.vc;r!==void 0?r.push(t):e.vc=[t]}function ds(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 c=0,l=a.length;c<l;++c)Bu(t,a[c]);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 s=n!==void 0?o!==void 0?De(e,void 0,n.concat(o),void 0):De(e,void 0,n,void 0):o!==void 0?De(e,void 0,o,void 0):e;return s.io=!0,s}function x_(e,t,r){if(!t.vc)return;let i="["+fi(e.g,r)+"]";t.vc.forEach(o=>Bu(e,{c:s=>o.c(s+i),f:o.f})),t.vc=void 0}function S_(e,t){let r=e.s.additionalItems,n;n=r!==void 0&&r!=="strip"&&r!=="strict"?r:lt;let i=e.e.additionalItems,o;return o=i!==void 0&&i!=="strip"&&i!=="strict"?i:lt,{p:e,v:IT,i:e.v()+"["+t+"]",s:n,e:o,f:e.f,cp:"",hd:"",path:"",g:e.g}}function ci(e,t,r){return Fr(e,ys(e,t),t,r)}function T_(e,t){let r=Fr(e,t,e.s,void 0);return r.f=1,r}function zn(e,t,r){e.s.type===li?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+Dr(r,void 0),e.d[t]=r}function $_(e,t,r){return e.v()+"["+t+"]="+r.i}function an(e){let t=e.v!==Zt,r={b:e,v:t?CT:Zt,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=Zt,i}}return r}function DT(e,t){throw new ui({code:"invalid_operation",path:e.path,reason:t})}function E_(e,t,r,n){if(e.path===""&&r===void 0)return Dr(e,void 0);{let i=u=>{let c=t.path,l=c===""?"":po(c)+"+";return u+".path="+l+(r!==void 0?`'["'+`+r+`+'"]'+`:"")+u+".path"},o=Dr(e,void 0);if(o===""&&!(e.f&1))return o+(n!==void 0?n():"");let s=ar(e.g),a=i(s)+";throw "+s;return e.f&1&&(e.i=e.i+".catch("+s+"=>{"+a+"})"),"try{"+o+(n!==void 0?n():"")+"}catch("+s+"){"+a+"}"}}function z_(e){return e}z_.embedded=fc;function Ru(e){return e+"<=2147483647&&"+e+">=-2147483648&&"+e+"%1===0"}function fs(e){return t=>"typeof "+t+'==="'+e+'"'}function co(e){return"Number.isNaN("+e+")"}function ac(e){return"Array.isArray("+e+")"}function A_(e){return fs(ut)(e)+"&&"+e}function GT(e,t){return r=>r+" instanceof "+di(e,t)}function ZT(e){let t=Ye[e.s.type];if(t&1){let i=[{c:fs(An),f:mt}],o=e.e.format,s=0;return o==="int32"?i.push({c:Ru,f:mt}):s=1,s===1&&(e.g.o&2||i.push({c:a=>"!"+co(a),f:mt})),De(e,e.e,i,void 0)}if(!(t&2))return t&4?e.s.format!==e.e.format&&e.e.format==="int32"?De(e,e.e,[{c:Ru,f:mt}],void 0):e:vs(e,e.s,e.e);let r=ar(e.g),n=Fr(e,r,e.e,void 0);return n.v=Zt,n.cp="let "+r+"=+"+e.v()+";",n.vc=[{c:i=>{let o=e.e.format;return o!==void 0&&o==="int32"?Ru(r):"!"+co(r)},f:mt}],n}function O_(){return ho(An,An,e=>{e.decoder=ZT})}function FT(e){return Fr(e,'""+'+e.i,Wu(),void 0)}function qT(e){let t=Ye[e.s.type];if(t&1)return De(e,e.e,[{c:fs(lo),f:mt}],void 0);if(!(t&3132&&Zr in e.s))return t&1036?FT(e):t&2?e:vs(e,e.s,e.e);let r=""+e.s.const,n=Ct(lo,!1);return n.const=r,Fr(e,'"'+r+'"',n,void 0)}function Wu(){return ho(lo,lo,e=>{e.decoder=qT})}function P_(e,t){e[Ye[t]&768?gs:t]=!0}var LT="JSON";function mo(e){let t=e.e;if(t.noValidation&&!e.u)return ci(e,t,void 0);if(Zr in e.s)return e.s.const===t.const?e:ci(e,t,void 0);let r=Ye[t.type];if(!(Ye[e.s.type]&2&&r&3132))return r&2048?De(e,t,[{c:co,f:mt}],void 0):De(e,t,[{c:o=>o+"==="+ys(e,t),f:mt}],void 0);let n=Ct(lo,!1);n.const=""+t.const;let i=ci(e,n,n);return i.vc=[{c:o=>o+'==="'+n.const+'"',f:mt}],ci(i,t,t)}function pc(){return ho(Gr,Gr,e=>{e.const=void 0,e.decoder=mo})}function UT(){return ho(uo,uo,e=>{e.const=null,e.decoder=mo})}function C_(){return ho(ju,ju,e=>{e.const=NaN,e.decoder=mo})}function Ju(e){if(e===null)return UT();let t=typeof e;if(t===Gr)return pc();if(t===An&&Number.isNaN(e))return C_();if(t===ut){let n=Ct(Fu,!0);return n.class=e.constructor,n.const=e,n.decoder=mo,n}let r=Ct(t,!0);return r.const=e,r.decoder=mo,r}function cr(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 s=o.v(),a=an(o),u=cr(a),c=Dr(u,void 0);t=a.i!==u.i||c!==""?Fr(o,s+".then("+s+"=>{"+c+"return "+u.i+"})",u.s,u.e):De(o,u.s,void 0,u.e),t.f=t.f|1,t.io=!0}else if(o.io){let s=o.e.to,u=o.e.parser;t=u!==void 0?u(o):De(t,void 0,void 0,s)}else{let s=o.s.encoder;s&&s!==i&&o.s!==o.e&&o.e.type!==gs&&(t=s(o,o.e)),o!==t?r=s:(t=o.e.decoder(o),t.io||(t=ds(t,t)))}}return t}function Cn(e){for(;;){let t=e,r=t.to;if(r===void 0)return t;e=r}}function sn(e){if(ao in e)return e[ao];let t,r=e;for(;r;){let i=fo(r),o=i.to,s=t;s!==void 0?i.to=s:delete i.to;let a=i.parser,u=i.serializer;u!==void 0?i.parser=u:delete i.parser,a!==void 0?i.serializer=a:delete i.serializer;let c=i.refiner,l=i.inputRefiner;l!==void 0?i.refiner=l:delete i.refiner,c!==void 0?i.inputRefiner=c:delete i.inputRefiner;let d=i.fromDefault,p=i.default;p!==void 0?i.fromDefault=p:delete i.fromDefault,d!==void 0?i.default=d:delete i.default;let f=i.items;f!==void 0&&(i.items=f.map(sn));let h=i.properties;if(h!==void 0){let y={},v=Object.keys(h);for(let b=0,w=v.length;b<w;++b){let S=v[b];y[S]=sn(h[S])}i.properties=y}typeof i.additionalItems===ut&&(i.additionalItems=sn(i.additionalItems));let m=i.anyOf;if(m!==void 0){let y={},v=[];for(let b=0,w=m.length;b<w;++b){let S=m[b],R=sn(S);v.push(R),P_(y,R.type)}i.has=y,i.anyOf=v}let g=i.$defs;if(g!==void 0){let y={};for(let v=0,b=Object.keys(g).length;v<b;++v){let w=Object.keys(g)[v];y[w]=sn(g[w])}i.$defs=y}t=i,r=o}let n=t;return En[ic]=n,Sr(e,ao,En),En[ic]=e,Sr(n,ao,En),n}function R_(e){try{return cr(e)}catch(t){let r=mc(t),n=e.p;throw r.path=(n!==void 0?n.path:"")+(e.path+"[]"+r.path),r}}function VT(e,t,r,n){let i=jT(Zr in e?lt:e,t,r,n),o=cr(i),s=Dr(o,void 0),a=PT(o.f,1);t.isAsync=a;let u=o.t===!0;if(t.hasTransform=u,s===""&&(o===i||o.i===i.i)&&!(r&1))return z_;let c=o.i;r&1&&!a&&!n&&(c="Promise.resolve("+c+")");let l="i=>{"+s+"return "+c+"}",d=i.g.e,p=new Function("e","s","return "+l)(d,Gu);return p.embedded=i.g.e,p}function cc(e,t){let r=arguments,n=0,i,o="",s=0,a;for(;i===void 0;){let c=r[n];if(c)if(typeof c===An){let l=c|ls.f;i=l,o=o+"-"+l}else{let l=c.seq;l>s&&(s=l,a=c),o=o+l+"-",n=n+1|0}else{let l=ls.f;i=l,o=o+"-"+l}}let u=a;if(u!==void 0){let c=o;if(c in u)return u[c];let l=r[n-1|0];for(let p=n-2|0;p>=0;--p){let f=l;l=Pn(r[p],h=>{h.to=f})}let d=VT(l,l,i,0);return En[ic]=d,Sr(u,c,En),d}throw new Error("[Sury] No schema provided for decoder.")}var mi="BS_PRIVATE_NESTED_SOME_NONE";function BT(e){let t=De(e,void 0,void 0,Hu());return t.cp=NT(e,void 0)+";",t}function Hu(){return ho(Nu,Nu,e=>{e.decoder=BT})}function WT(e){let t=e.e.to;return Fr(e,"{"+mi+":"+Cn(e.e).properties[mi].const+"}",t,t)}function ms(e,t){return{v:sc,i:"",s:t.type===li?{type:li,decoder:Qu,additionalItems:"strict",items:[]}:{type:ut,decoder:bs,additionalItems:"strict",required:[],properties:{}},e:e.e,prev:e,f:0,d:{},cp:"",hd:"",t:!0,path:e.path,g:e.g}}function Ku(e){return Yu(e,pc())}function bs(e){let t=e.u,r=e.e,n=Ye[e.s.type],i;if(n&65){let l=n&64,d;if(l)d=e.s;else{let f=Ct(ut,!1);f.properties=__,f.additionalItems=lt,d=f}let p=[];l||(p.push({c:A_,f:mt}),r.additionalItems!=="strip"&&p.push({c:f=>"!"+ac(f),f:mt})),i=p.length!==0?De(e,d,p,void 0):De(e,d,void 0,void 0)}else i=vs(e,e.s,r);let o=r.additionalItems,s;s=o==="strip"||o==="strict"?void 0:o;let a=i.s.additionalItems,u;u=a!=="strip"&&a!=="strict";let c;if(s!==void 0)if(s===lt)c=i;else if(u){let l=i.v(),d=ar(i.g),p=S_(i,d),f=R_(p),h=f.t,m=h?Fr(i,"{}",r,void 0):De(i,r,void 0,void 0),g=E_(f,i,d,h?()=>$_(m,d,f):void 0);if((h||g!=="")&&(m.cp=m.cp+("for(let "+d+" in "+l+"){"+g+"}")),f.f&1){let y=ar(m.g),v=ar(m.g),b=ar(m.g),w=ar(m.g),S=m.v();c=T_(m,"new Promise(("+y+","+v+")=>{let "+w+"=Object.keys("+S+").length;for(let "+d+" in "+S+"){"+S+"["+d+"].then("+b+"=>{"+S+"["+d+"]="+b+";if("+w+"--===1){"+y+"("+S+")}},"+v+")}})")}else c=m}else{let l=ms(i,r),d=Object.keys(i.s.properties);for(let p=0,f=d.length;p<f;++p){let h=d[p],m=lc(i,h);m.e=s,m.io=!1,m.u=t,zn(l,h,cr(m))}c=ps(l)}else{let l=r.properties,d=Object.keys(l),p=d.length,f=ms(i,r),h=r.additionalItems,m;m=h==="strip"||h==="strict"?h==="strip"?u||Object.keys(i.s.properties).length!==p:!1:!0;let g=i.s.additionalItems,y;y=g==="strip"||g==="strict"?!1:g.name===LT;for(let b=0;b<p;++b){let w=d[b],S=l[w],R=lc(i,w);R.e=S,R.io=!1,R.u=t,y&&S.type===On&&S.has[Gr]&&(R.i="("+R.i+"??null)");let X=cr(R);t&&Zr in S&&x_(i,X,w),zn(f,w,X),m||(m=X.t)}let v=!1;if(r.additionalItems==="strict"){let b=i.s.additionalItems,w;w=b!=="strip"&&b!=="strict",v=w}if(v){let b=ar(f.g);if(oc(i,b),f.cp=f.cp+("for("+b+" in "+i.v()+"){if("),d.length!==0)for(let w=0,S=d.length;w<S;++w){let R=d[w];w!==0&&(f.cp=f.cp+"&&"),f.cp=f.cp+(b+"!=="+fi(i.g,R))}else f.cp=f.cp+"true";f.cp=f.cp+("){"+us(i,w=>({code:"unrecognized_keys",path:f.path,reason:'Unrecognized key "'+w+'"',keys:[w]}),b)+"}}")}if(m)c=ps(f);else{let b=De(i,void 0,void 0,void 0);b.cp=f.cp,b.d=f.d,c=b}}return ds(c,i)}function JT(){let e=Ju(0),t={};return t[mi]=e,{type:ut,serializer:r=>{let n=r.e.to;return ci(r,n,n)},decoder:bs,additionalItems:"strip",required:[mi],properties:t}}function Qu(e){let t=e.u,r=e.e,n=Ye[e.s.type],i=r.items,o=i.length,s;if(n&129){let l=n&128,d=l?e.s:Xu(lt),p=[];l||p.push({c:ac,f:mt});let f=d.additionalItems,h;if(h=f==="strip"||f==="strict"?d.items.length===o:!1,!h){let m=r.additionalItems;(m==="strip"||m==="strict")&&(m==="strip"?p.push({c:g=>g+".length>="+o,f:mt}):p.push({c:g=>g+".length==="+o,f:mt}))}s=p.length!==0?De(e,d,p,void 0):De(e,d,void 0,void 0)}else s=vs(e,e.s,r);let a=r.additionalItems,u,c=0;if(a==="strip"||a==="strict")c=1;else if(a===lt)u=s;else{let l=s.v(),d=ar(s.g),p=S_(s,d),f=R_(p),h=f.t,m=h?Fr(s,"new Array("+l+".length)",r,void 0):De(s,r,void 0,void 0),g=E_(f,s,d,h?()=>$_(m,d,f):void 0);(h||g!=="")&&(m.cp=m.cp+("for(let "+d+"="+o+";"+d+"<"+l+".length;++"+d+"){"+g+"}")),u=f.f&1?T_(m,"Promise.all("+m.i+")"):m}if(c===1){let l=ms(s,r),d=r.additionalItems,p;if(d==="strip"||d==="strict")if(d==="strip"){let f=s.s.additionalItems;p=f==="strip"||f==="strict"?s.s.items.length!==o:!0}else p=!1;else p=!0;for(let f=0;f<o;++f){let h=i[f],m=f.toString(),g=lc(s,m);g.e=h,g.io=!1,g.u=t;let y=cr(g);t&&Zr in h&&x_(s,y,m),zn(l,m,y),p||(p=y.t)}if(p)u=ps(l);else{let f=De(s,void 0,void 0,void 0);f.cp=l.cp,f.d=l.d,u=f}}return ds(u,s)}function HT(e,t){let r=e.s.anyOf;return t.type===On&&j_(t)===void 0&&I_(t.anyOf,r)||!XT(r,t)?e:QT(e,t)}function KT(e){let t=e.e,r=t.anyOf,n=Ye[e.s.type],i=j_(t);if(e.s===t&&i===void 0&&r.every(tc)||n&256&&I_(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=lt);let o="";if(!(n&769)){let j=Iu(e.s),$=!1,N=!1,G=r.length,M=0;for(;o===""&&M<G;){let V=r[M];Iu(V)===j?o=j:V.type===uo?$=!0:V.type===Gr&&(N=!0),M=M+1|0}o===""&&(n&16&&$?o=uo:n&32&&N&&(o=Gr))}let s=o,a=e.i,u=j=>di(e,function(){let $=arguments,N=w_(t,lt,e.path,$[0],!0,$.length>1?Array.from($).slice(1):void 0,void 0);throw new ui(N)})+"("+e.v()+j+")",c=De(e,void 0,void 0,void 0),l=[],d={contents:""},p=(j,$)=>{let N=j[0],G=j[1],M="",V="",we=!1,Le={contents:""},nt="",At={},xt=2,xe=j.length-1|0;for(;xt<=xe;){let Ue=an(G);Ue.u=!0,Ue.t=G.t,Ue.io=!1,Ue.e=j[xt];let Ve=xt===xe,_e=xt===2,vr=_e&&Ve,Xi=!vr,Ir=!1,rn="",wn={contents:""};try{let Pe=cr(Ue);if(l.push(Pe.s),rn=Dr(Pe,wn),Pe.t){c.t=!0,Pe.f&1&&(c.f=c.f|1);let jr=N.v();Pe.i!==jr&&(rn=rn+(jr+"="+Pe.i))}}catch(Pe){let jr=di(Ue,mc(Pe));nt=nt+","+jr,$&&vr?(d.contents=jr,Ir=!0):Ve?(Xi=!1,rn=$?"throw "+jr:u(nt)):Ir=!0}let kn=wn.contents,ei=rn;if(!Ir&&kn)if(ei){let Pe=At[kn];Pe!==void 0?typeof Pe=="string"?At[kn]=[Pe,ei]:Pe.push(ei):At[kn]=ei}else Le.contents=Le.contents?Le.contents+"||"+kn:kn;if(!Ir&&(!kn||Ve)){let Pe=Object.keys(At);for(let jr=0,zS=Pe.length;jr<zS;++jr){let vg=Pe[jr];M=M+(we?"else if":"if")+("("+vg+"){");let rs=At[vg];if(typeof rs=="string")M=M+rs+"}";else{let du="";for(let Ca=0,AS=rs.length;Ca<AS;++Ca){let OS=rs[Ca],bg="e"+Ca;M=M+("try{"+OS+"}catch("+bg+"){"),du=du+","+bg}M=M+u(du)+"}".repeat(rs.length)+"}"}we=!0}At={}}if(!Ir&&!kn)if(ei)if(Le.contents&&(M=M+(we?"else if":"if")+("(!("+Le.contents+")){"),V="}"+V,Le.contents="",we=!1),Ve&&($||!Xi||_e))M=M+((we?"else{":"")+ei),V=(we?"}":"")+V;else{let Pe="e"+(xt-2|0);M=M+((we?"else{":"")+"try{"+ei+"}catch("+Pe+"){"),V=(we?"}":"")+"}"+V,nt=nt+","+Pe,we=!1}else Le.contents="",xt=xe,Xi=!1;if(Ve){if(Le.contents)M||nt?M=M+(we?"else if":"if")+("(!("+Le.contents+")){"+u(nt)+"}"):Bu(G,{c:Pe=>"("+Le.contents+")",f:mt});else if(Xi){let Pe=u(nt);M=M+(we?"else{"+Pe+"}":Pe)}}xt=xt+1}return M+V},f="",h="",m="",g=!1,y=r.length-1|0,v={},b=[],w=t.refiner,S=t.inputRefiner,R={contents:void 0},X={contents:void 0},be=(j,$,N)=>{if($===void 0)return j;let G=M=>{let V=N.contents;if(V!==void 0)return V;let we=$(M);return N.contents=we,we};return j!==void 0?M=>{let V=j(M),we=G(M);for(let Le=0,nt=we.length;Le<nt;++Le)V.push(we[Le]);return V}:G},D=j=>{let $=be(j.refiner,w,R);$!==void 0&&(j.refiner=$);let N=be(j.inputRefiner,S,X);if(N!==void 0){j.inputRefiner=N;return}},I;if(Zr in e.s){let j=[],$=[];for(let N=0;N<=y;++N){let G=r[N];Zr in G&&G.const===e.s.const?j.push(G):$.push(G)}I=j.concat($)}else I=r;for(let j=0;j<=y;++j){let $=i!==void 0?Pn(I[j],V=>{D(V),V.to=i}):I[j],N=$.type,G=Ye[N],M=Iu($);if((s===""||s===M)&&!(G&16&&"fromDefault"in t)){let V=v[M];if(V!==void 0)G&64&&mi in $.properties?V.splice(V.length-1|0,0,$):G&2096||V.push($);else{let we=an(e),Le;if(G&37633)Le=lt;else{let xe=Ct($.type,!1);xe.encoder=$.encoder,G&8192?xe.class=$.class:G&64?(xe.properties=__,xe.additionalItems=lt):G&128?(xe.additionalItems=lt,xe.items=fc):G&2096&&(xe.const=$.const),xe.decoder=Ue=>Ye[Ue.s.type]&1?De(Ue,Ue.e,[{c:Ve=>{let _e=Ye[$.type];if(_e&64)return A_(Ve)+"&&!"+ac(Ve);if(_e&128)return ac(Ve);if(_e&8192)return GT(Ue,$.class)(Ve);if(!(_e&4))return _e&2048?co(Ve):_e&48?Ve+"==="+ys(Ue,$):_e&17418?fs($.type)(Ve):"";let vr=fs(An)(Ve);return Ue.g.o&2?vr:vr+"&&!"+co(Ve)},f:mt}],void 0):$.decoder(Ue),Le=xe}we.e=Le;let nt;try{nt=cr(we)}catch{we.vc=void 0,nt=we}p_(G,v)?b.unshift(M):b.push(M),v[M]=[we,nt,$];let At=!0,xt=nt;for(;xt!==void 0&&At;){let xe=xt;xt=xe.prev,At=!(xe.vc&&k_(xe))}if(At){for(let xe=0,Ue=b.length;xe<Ue;++xe){let Ve=b[xe];if(!g){let _e=v[Ve],vr=_e[1],Xi=p(_e,!0),Ir=Dr(vr,void 0)+Xi,rn=d.contents;if(rn)if(d.contents="",Ir){let wn="e"+(j+xe|0);f=f+("try{"+Ir+"throw "+rn+"}catch("+wn+"){"),h="}"+h,m=m+","+wn}else m=m+","+rn;else if(Ir){let wn="e"+(j+xe|0);f=f+("try{"+Ir+"}catch("+wn+"){"),h="}"+h,m=m+","+wn}else g=!0}}v={},b=[]}}}}let B=v,re=b;if(!g){let j=!1,$="";for(let M=0,V=re.length;M<V;++M){let we=B[re[M]],Le=we[1],nt=we[2],At=p(we,!1),xt={contents:""},xe=Dr(Le,xt)+At,Ue=xt.contents;xe||p_(Ye[nt.type],B)?(f=f+(j?"else if":"if")+("("+Ue+"){"+xe+"}"),j=!0):$=$?$+"||"+Ue:Ue}let N=u(m),G;$?G=(j?"else if":"if")+("(!("+$+")){"+N+"}"):G=j?"else{"+N+"}":h===""?N+";":N,f=f+G}c.cp=c.cp+f+h,e.i!==c.i&&(c.i=e.i);let le=c.f&1?(c.i="Promise.resolve("+c.i+")",c.v=sc,c):c.v===Zt&&e.cp===""&&c.cp===""&&a==="i"?(e.hd="",e.v=sc,e.i=a,e):c;return le.s=l.length?hs(l):Hu(),le.e=i!==void 0?(le.io=!0,Cn(i)):t,le}function I_(e,t){return t.every((r,n)=>{let i=e[n];return i!==void 0&&!(Ye[r.type]&9152)&&r.type===i.type&&r.const===i.const?r.to===void 0:!1})}function QT(e,t){return De(e,lt,void 0,Pn(e.s,r=>{r.to=t}))}function XT(e,t){return!(Ye[Cn(t).type]&512)&&!(t.type===On&&t.anyOf.some(r=>Ye[r.type]&512))?!e.some(r=>r.to!==void 0||r.parser!==void 0?!0:Ye[r.type]&512):!1}function j_(e){if(e.parser!==void 0)return;let r=e.to;if(r!==void 0)return r}function lc(e,t){let r=e.d,n;if(r!==void 0)n=r;else{let l={};e.d=l,n=l}let i=n[t];if(i!==void 0)return an(i);let o=e.s.type===ut?e.s.properties[t]:e.s.items[t],s;if(o!==void 0)s=o;else{let l=e.s.additionalItems;s=l==="strip"||l==="strict"?vs(e,e.s,e.e):e.s.type===ut&&l.type!==gs&&!(Ye[l.type]&512)&&!OT(l)?Ku(l):l}let u="["+fi(e.g,t)+"]",c={p:e,v:Mu,i:Zr in s?ys(e,s):e.v()+u,s,e:s,f:0,cp:"",hd:"",path:e.path+u,g:e.g};return n[t]=c,c}function ps(e){let t=e.s.type===li,r="",n="",i,o=Object.keys(e.d);for(let c=0,l=o.length;c<l;++c){let d=o[c],p=e.d[d];if(p.f&1&&(n=n+p.i+","),p.o){let f=i;i=h=>(f!==void 0?f(h):"")+("if("+p.v()+"!==void 0){"+h+"["+fi(e.g,d)+"]="+p.i+"}")}else r=r+(t?p.i:fi(e.g,d)+":"+p.i)+","}if(e.i=t?"["+r+"]":"{"+r+"}",n){let c=an(e);c.io=!0;let l=cr(c),d=Dr(l,void 0);return d===""&&n===l.i+","?e.i=l.i:e.i="Promise.all(["+n+"]).then((["+n+"])=>{"+d+"return "+l.i+"})",e.f=e.f|1,e.s=l.s,e.e=l.e,e.io=!0,e}let s=i;if(s===void 0)return e;let a=s(e.v()),u=De(e,void 0,void 0,void 0);return u.cp=u.cp+a,u}function hs(e){let t=e.length;if(t===1)return e[0];if(t!==0){let r={},n=new Set;for(let o=0,s=e.length;o<s;++o){let a=e[o];a.type===On&&a.to===void 0?(a.anyOf.forEach(u=>{n.add(u)}),Object.assign(r,a.has)):(n.add(a),P_(r,a.type))}let i=Ct(On,!1);return i.anyOf=Array.from(n),i.decoder=KT,i.encoder=HT,i.has=r,i}throw new Error("[Sury] S.union requires at least one item")}function p_(e,t){return e&8320&&ut in t?!0:e&2048?An in t:!1}function Iu(e){return Ye[e.type]&8192?e.class.name:e.type}function tc(e){for(;;){let t=e,r=!1,n=!1,i=!1;if(t.to===void 0&&t.parser===void 0&&!(Ye[t.type]&512)){let s=t.anyOf;i=s!==void 0?s.every(tc):!0}if(i){let s=t.items;n=s!==void 0?s.every(tc):!0}if(n){let s=t.properties;r=s!==void 0?Object.values(s).every(tc):!0}if(!r)return!1;let o=t.additionalItems;if(o===void 0||o==="strip"||o==="strict")return!0;e=o}}function Xu(e){let t=Ct(li,e[ao]===e);return t.additionalItems=e,t.items=fc,t.decoder=Qu,t}function Yu(e,t){let r=t!==void 0?t:pc(),n=Cn(e);switch(n.type){case"undefined":return hs([r,h_(e)]);case"union":let o=n.has,s=n.anyOf;return Pn(e,a=>{let u=kT(o),c=[];for(let l=0,d=s.length;l<d;++l){let p=s[l],f=Cn(p),h=f.type,m;if(h==="undefined")u[r.type]=!0,c.push(r),m=h_(p);else{let g=f.properties;if(g!==void 0){let y=g[mi];m=y!==void 0?Pn(p,v=>{let b={},w={...y};w.const=y.const+1,b[mi]=w,v.properties=b}):p}else m=p}c.push(m)}c.length===s.length&&(u[r.type]=!0,c.push(r)),a.anyOf=c,a.has=u});default:return hs([e,r])}}function h_(e){return Pn(e,t=>{t.to=JT(),t.parser=WT})}Sr(Uu,"~standard",{get:function(){let e=this;return{version:1,vendor:Du,validate:t=>{try{return{value:cc(lt,e)(t)}}catch(r){let n=mc(r);return{issues:[{message:n.reason,path:n.path===""?void 0:xT(n.path)}]}}}}}});function N_(e,t){return cc(lt,t)(e)}function YT(e,t){return Pn(e,r=>{let n=t(r),i=r.refiner;i!==void 0?r.refiner=o=>{let s=i(o),a=n(o);for(let u=0,c=a.length;u<c;++u)s.push(a[u]);return s}:r.refiner=n})}function M_(e,t,r,n){let i=r!==void 0?r:"Refinement failed",o=n!==void 0?TT(n):"";return YT(e,s=>(a=>{let u=di(a,t);return[{c:c=>u+"("+c+")",f:Vu(void 0,o,i,void 0)}]}))}function D_(e,t){return Pn(e,r=>{let n=r.anyOf;if(n!==void 0){let o=[],s=[];for(let p=0,f=n.length;p<f;++p){let h=n[p],m=Cn(h);m.type!=="undefined"&&(o.push(m),s.push(h))}let a=o.length,u;if(a!==1)if(a!==0)u=hs(o);else{let p="Can't set default for "+Xe(r);throw new Error("[Sury] "+p)}else u=o[0];let c=s.length!==1?hs(s):s[0];if(t.TAG==="Value"){let p=t._0;try{cc(lt,u)(p)}catch(f){let h=mc(f),m="Invalid default for "+Xe(r)+": "+h.message;throw new Error("[Sury] "+m)}try{r.default=cc(sn(c),void 0)(p)}catch{}}r.parser=p=>{let f=p.e.to,h=p.v(),m;return m=t.TAG==="Value"?ys(p,Ju(t._0)):di(p,t._0)+"()",Fr(p,h+"===void 0?"+m+":"+h,f,f)};let l=fo(u),d=l.decoder;l.serializer=p=>{let f=sn(c);return De(d(p),f,void 0,f)},l.decoder=b_,r.to=l;return}let i="Can't set default for "+Xe(r);throw new Error("[Sury] "+i)})}function e1(e){return e[Zu]}function uc(e,t,r){let n=fo(Cn(e));return n.from=t,r!==void 0&&(n.fromFlattened=r),new Proxy(n,{get:(i,o)=>{if(o===Zu)return i;let s=i.items,a=i.properties,u=a!==void 0?a[o]:s!==void 0?s[o]:void 0;if(u===void 0){let c='Cannot read property "'+o+'" of '+Xe(i);throw new Error("[Sury] "+c)}return uc(u,i.from.concat(o),i.fromFlattened)}})}function G_(e,t,r){let n=ms(e,t);n.io=!0;let i=t.items;if(i!==void 0)for(let o=0,s=i.length;o<s;++o){let a=o.toString();zn(n,a,r(a,i[o]))}else{let o=t.properties;if(o!==void 0){let s=Object.keys(o);for(let a=0,u=s.length;a<u;++a){let c=s[a];zn(n,c,r(c,o[c]))}}else{let s="Don't know where the value is coming from: "+Xe(t);throw new Error("[Sury] "+s)}}return ps(n)}function Z_(e,t){let r=t.from,n=t.fromFlattened,i=n!==void 0?an(g_(e.fv[n],t.from,0)):r!==void 0?an(g_(e,r,0)):Zr in t?ci(e,t,void 0):G_(e,t,(o,s)=>Z_(e,s));return i.prev=void 0,i.e=t,i}function F_(e,t){let r=t.e,n=r.from;if(n!==void 0){let s=r.fromFlattened,a;if(s!==void 0){e.flattened===void 0&&(e.flattened=[]);let u=e.flattened[s];if(u!==void 0)a=u;else{let c={};e.flattened[s]=c,a=c}}else a=e;for(let u=0,c=n.length;u<c;++u){let l=n[u],d=a.properties,p;if(d!==void 0)p=d;else{let m={};a.properties=m,p=m}let f=p[l],h;if(f!==void 0)h=f;else{let m={};p[l]=m,h=m}a=h}a.val=t;return}let i=t.d;if(i===void 0)return;let o=Object.keys(i);for(let s=0,a=o.length;s<a;++s)F_(e,i[o[s]])}function rc(e,t,r,n){let i=0;if(t!==void 0){let o=t.val;if(o!==void 0){let s=an(o);return s.t=!0,s.s=r,s.e=r,cr(s)}i=1}else i=1;if(i===1){if(Zr in r){let d=ci(e,r,r);return d.prev=void 0,d.p=e,d.v=Mu,d.io=!0,cr(d)}let o=t===void 0?Cn(r):r,s=ms(e,o);s.e=o,s.io=!0,s.prev=void 0,s.p=e,s.v=Mu;let a=o.flattened,u=o.items,c=0,l=0;if(u!==void 0&&(t!==void 0||typeof o.additionalItems!==ut))for(let d=0,p=u.length;d<p;++d){let f=d.toString(),h;if(t!==void 0){let g=t.properties;h=g!==void 0?g[f]:void 0}else h=void 0;let m=fi(e.g,f);zn(s,f,rc(e,h,u[d],n+("["+m+"]")))}else l=3;if(l===3){let d=o.properties;if(d!==void 0&&(t!==void 0||typeof o.additionalItems!==ut)){if(a!==void 0&&t!==void 0){let f=t.flattened;f!==void 0&&f.forEach((h,m)=>{let y=rc(e,h,sn(a[m]),n).d,v=Object.keys(y);for(let b=0,w=v.length;b<w;++b){let S=v[b];zn(s,S,y[S])}})}let p=Object.keys(d);for(let f=0,h=p.length;f<h;++f){let m=p[f];if(!(m in s.d)){let g;if(t!==void 0){let v=t.properties;g=v!==void 0?v[m]:void 0}else g=void 0;let y=fi(e.g,m);zn(s,m,rc(e,g,d[m],n+("["+y+"]")))}}}else c=2}if(c===2){let d=r.from,p=d!==void 0?n+d.map(h=>'["'+h+'"]').join(""):n,f=p===""?"":" at "+p;DT(e,"Missing input for "+Xe(r)+f)}return ps(s)}}function g_(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 dc(e,t){if(typeof e!==ut||e===null)return Ju(e);let r=t(e);if(r!==void 0)return r;if(Array.isArray(e)){for(let u=0,c=e.length;u<c;++u){let l=dc(e[u],t);e[u]=l}let a=Ct(li,!1);return a.items=e,a.additionalItems="strict",a.decoder=Qu,a}let n=e.constructor;if(n&&n!==Object){let a=Ct(Fu,!0);return a.class=n,a.const=e,a.decoder=mo,a}let i=Object.keys(e),o=i.length;for(let a=0;a<o;++a){let u=i[a],c=dc(e[u],t);e[u]=c}let s=Ct(ut,!1);return s.required=i,s.properties=e,s.additionalItems=ls.a,s.decoder=bs,s}function t1(e){let t={};F_(t,e);let r=e.e.to,n=rc(e,t,r,"");return n.t=!0,n.prev=e,n}function q_(e){return dc(e,t=>{if(t["~standard"])return t})}function L_(e){let t=this,r="~"+e,n=t[r];if(n!==void 0)return ve(n);let i={},o=[],s=Ct(ut,!1);s.required=o,s.properties=i,s.additionalItems=ls.a,s.decoder=bs;let a=t.f(e,s)[Zu],u=(f,h)=>{let m=po(f);if(f in i)throw new Error("[Sury] "+("The field "+m+" defined twice"));return o.push(f),i[f]=h,uc(h,a.from.concat(f),a.fromFlattened)},p={field:u,f:u,fieldOr:(f,h,m)=>{let g=Yu(h,void 0);return u(f,D_(g,{TAG:"Value",_0:m}))},tag:(f,h)=>{u(f,q_(h))},nested:L_,flatten:f=>{if(f.type==="object"){let g=f.to,y=f.properties;if(g){let w="Unsupported nested flatten for transformed object schema "+Xe(f);throw new Error("[Sury] "+w)}let v=Object.keys(y),b={};for(let w=0,S=v.length;w<S;++w){let R=v[w];b[R]=u(R,y[R])}return b}let m="Can't flatten "+Xe(f)+" schema";throw new Error("[Sury] "+m)}};return t[r]=p,p}function r1(e){let t=fo(dc(e,e1));return t.serializer=t1,t}function n1(e){let t=e.e.flattened;if(t!==void 0){let i=[];for(let o=0,s=t.length;o<s;++o){let a=t[o],u=a.to,c;if(u!==void 0){let l=an(e);l.e=a,l.io=!0,c=cr(l)}else{let l=G_(e,a,(d,p)=>lc(e,d));l.e=a,l.prev=void 0,c=ds(l,l)}i.push(c),e.cp=e.cp+Dr(c,void 0)}e.fv=i}let r=e.e.to,n=Z_(e,r);return n.t=!0,n.prev=e,ds(n,e)}function U_(e){let t,r={},n=l=>{if(l.type==="object"){let f=l.properties,h=Object.keys(f);for(let g=0,y=h.length;g<y;++g){let v=h[g],b=f[v],w=r[v];if(w!==void 0){if(w!==b)throw new Error("[Sury] "+('The field "'+v+'" defined twice with incompatible schemas'))}else r[v]=b}let m=t||(t=[]);return uc(l,fc,m.push(l)-1|0)}let p="The '"+Xe(l)+"' schema can't be flattened";throw new Error("[Sury] "+p)},i=(l,d)=>{if(l in r)throw new Error("[Sury] "+('The field "'+l+'" defined twice with incompatible schemas'));return r[l]=d,uc(d,[l],void 0)},u=e({field:i,f:i,fieldOr:(l,d,p)=>{let f=Yu(d,void 0);return i(l,D_(f,{TAG:"Value",_0:p}))},tag:(l,d)=>{i(l,q_(d))},nested:L_,flatten:n}),c=Ct(ut,!1);return c.required=Object.keys(r),c.properties=r,c.additionalItems=ls.a,c.decoder=bs,c.parser=n1,c.to=r1(u),t!==void 0&&(c.flattened=t),c}var Rn=Wu();var V_=O_();var B_=qu;var W_=Xu;var ws=Ku;var cn=M_;var J_=N_;var hc=U_;function o1(e){return{path:e.path,summary:e.message}}function A(e){return{path:"",summary:e}}function ed(e,t){try{return{TAG:"Ok",_0:J_(e,t)}}catch(r){let n=K(r);if(n.RE_EXN_ID===B_)return{TAG:"Error",_0:o1(n._1)};throw n}}import*as ks from"node:fs";import*as ey from"node:os";import*as gc from"node:path";var s1="--api-url must be ws://, wss://, http://, or https://";function pt(e){let t=oo(e);if(t===void 0)return{TAG:"Error",_0:"invalid URL: "+e};let r=ve(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:s1}}return Me(i,()=>{r.pathname="",r.search="",r.hash="";let o=r.toString();return o.endsWith("/")?o.slice(0,o.length-1|0):o})}var K_="wss://serve.linzumi.com";function go(){return gc.join(ey.homedir(),".linzumi","auth.json")}var Q_="Kandan auth cache must contain a JSON object",a1="Kandan auth cache local_codex_runner must be an object",c1="Kandan auth cache personal_agent_delegation must be an object";function X_(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 ty(e){let t;try{t=JSON.parse(e)}catch{t=void 0}if(t===void 0)return{TAG:"Error",_0:A(Q_)};if(typeof t!="object"||t===null||Array.isArray(t))return{TAG:"Error",_0:A(Q_)};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(a1)};if(!o)return{TAG:"Error",_0:A(c1)};let s;return s=typeof r=="object"&&r!==null&&!Array.isArray(r)?Object.fromEntries(Qt(Object.entries(r),a=>{let u=a[0];return He(X_(a[1]),c=>[u,c])})):void 0,{TAG:"Ok",_0:{serverTokens:s,personalAgentDelegation:Ke(n,X_)}}}function ry(e){return ks.existsSync(e)?Y(ye(kr(e),t=>A(t.message)),t=>Me(ty(t),r=>r)):{TAG:"Ok",_0:void 0}}function ny(e,t){return e!==void 0?new Date(e).getTime()<=t:!1}function _o(e,t,r){return ks.existsSync(t)?Y(ry(t),n=>Me(ye(pt(e),A),i=>Ke(Ke(Ke(n,o=>o.serverTokens),o=>o[i]),o=>{if(!(o.accessToken.trim()===""||ny(o.expiresAt,r)))return{accessToken:o.accessToken,serverBaseUrl:i,issuedAt:o.issuedAt,expiresAt:o.expiresAt}}))):{TAG:"Ok",_0:void 0}}function l1(e){return"missing personal-agent delegation auth file: "+e}var u1="personal-agent delegation auth file is missing access_token",d1="personal-agent delegation auth file token is expired";function iy(e,t){return ks.existsSync(e)?Y(ry(e),r=>{let n=Ke(r,i=>i.personalAgentDelegation);return n!==void 0&&n.accessToken.trim()!==""?ny(n.expiresAt,t)?{TAG:"Error",_0:A(d1)}:{TAG:"Ok",_0:n}:{TAG:"Error",_0:A(u1)}}):{TAG:"Error",_0:A(l1(e))}}function Y_(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 f1(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],Y_(i[1])])));let n=e.personalAgentDelegation;return n!==void 0&&(t.personal_agent_delegation=Y_(n)),t}function td(e,t,r,n,i){return Y(ye(pt(e),A),o=>{let s=ks.existsSync(n)?Y(ye(kr(n),a=>A(a.message)),ty):{TAG:"Ok",_0:{serverTokens:void 0,personalAgentDelegation:void 0}};return Y(s,a=>{let u=i.toISOString(),c=He(r,y=>new Date(i.getTime()+y*1e3).toISOString()),l={accessToken:t,issuedAt:u,expiresAt:c},d=a.serverTokens,p=d!==void 0?Object.fromEntries(Object.entries(d)):{};p[o]=l;let f=f1({serverTokens:p,personalAgentDelegation:a.personalAgentDelegation}),h=JSON.stringify(f,void 0,2)+`
111
- `,m=n+".tmp."+process.pid.toString()+"."+i_(6),g=y=>A(y.message);return Y(ye(xr(gc.dirname(n)),g),()=>{let y=Y(as(m,h,{encoding:"utf8",mode:384}),()=>Wa(m,n));return y.TAG==="Ok"?{TAG:"Ok",_0:{accessToken:t,serverBaseUrl:o,issuedAt:u,expiresAt:c}}:(oi(m),{TAG:"Error",_0:A(y._0.message)})})})})}function yo(e){let t=br(e);return t!==void 0?rt(wr(ve(t)),"unknown error"):"unknown error"}async function pi(e,t){try{return{TAG:"Ok",_0:await fetch(e,t)}}catch(r){let n=K(r);return{TAG:"Error",_0:{message:yo(n)}}}}async function m1(e){try{return{TAG:"Ok",_0:await e.text()}}catch(t){let r=K(t);return{TAG:"Error",_0:{message:yo(r)}}}}async function hi(e){let t=await m1(e);if(t.TAG!=="Ok")return{TAG:"Error",_0:t._0};try{return{TAG:"Ok",_0:JSON.parse(t._0)}}catch(r){let n=K(r);return{TAG:"Error",_0:{message:yo(n)}}}}function p1(e){if(typeof e=="object"&&e!==null&&!Array.isArray(e))return e}async function vo(e,t,r,n,i){let o=i!==void 0?i:[],s=ye(pt(e),A);if(s.TAG!=="Ok")return{TAG:"Error",_0:s._0};let a=Kt("/api/v2/local-codex-runner/oauth/validate",s._0);if(a.TAG!=="Ok")return{TAG:"Error",_0:A(a._0)};let u=a._0,c=u.searchParams;r!==void 0&&c.set("workspace",r),n!==void 0&&c.set("channel",n),o.forEach(h=>{c.append("required_scope",h)});let l={};l.authorization="Bearer "+t;let d=await pi(u.toString(),{method:"GET",headers:l});if(d.TAG!=="Ok")return{TAG:"Error",_0:A(d._0.message)};let p=d._0,f=p.status;if(f>404||f<401){if(f===200){let h=await hi(p);return h.TAG!=="Ok"?{TAG:"Error",_0:A(h._0.message)}:Ke(p1(h._0),g=>g.ok)===!0?{TAG:"Ok",_0:"Usable"}:{TAG:"Ok",_0:"Rejected"}}}else{if(f<402)return{TAG:"Ok",_0:"Rejected"};switch(f){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 "+f.toString())}}import*as Ny from"node:os";function sy(e){return e._0}var m3=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])?)*$"),p3=new RegExp("^[0-9.]+$");function od(e){if(typeof e!="string")return;let t=e.trim();if(t!=="")return t}function sd(e){return isFinite(e)?Math.trunc(e)===e:!1}function _1(e){if(typeof e=="number"&&e%1===0)return e}function y1(e){let t=e.replaceAll("-","+").replaceAll("_","/");switch(t.length&3){case 2:return t+"==";case 3:return t+"=";default:return t}}function ay(e){let t=e.split(".")[1];if(t===void 0)return;let r=Buffer.from(y1(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}var cd=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;function cy(e){let t=ay(e);if(t===void 0)return!1;let n=t.document_surfaces===!0,i=t.linzumi_agent_session,o=typeof i=="string"?cd.test(i):!1,s=t.coding_job_id,a=t.coding_job_thread_id,u=typeof s=="string"&&typeof a=="string"?cd.test(s)&&cd.test(a):!1;return n?o?!0:u:!1}function ld(e){let t=Ke(ay(e),r=>_1(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=K(r),i=br(n);return{TAG:"Error",_0:A(i!==void 0?rt(wr(ve(i)),"unknown error"):"unknown error")}}}import*as py from"node:http";import*as hy from"node:crypto";import*as gy from"node:child_process";function _c(e){if(typeof e!="object"||e===null||Array.isArray(e))return;let t=e.error;if(typeof t=="string")return t}function uy(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 Lr(e,t){let r=e[t];if(r!==void 0&&typeof r=="string"&&r.trim()!=="")return r}async function dy(e,t,r,n,i){let o=Kt("/api/v2/local-codex-runner/device/start",e);if(o.TAG!=="Ok")return{TAG:"Error",_0:A(o._0)};let s={},a=(g,y)=>{if(y!==void 0){s[g]=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 u={};u["content-type"]="application/json";let c=await pi(o._0.toString(),{method:"POST",headers:u,body:JSON.stringify(s)});if(c.TAG!=="Ok")return{TAG:"Error",_0:A(c._0.message)};let l=c._0,d=l.status,p=await hi(l);if(p.TAG!=="Ok")return{TAG:"Error",_0:A(p._0.message)};let f=p._0;if(d>=200&&d<300){if(Array.isArray(f))return{TAG:"Error",_0:A("local runner device authorization response was incomplete")};if(f!==null)switch(typeof f){case"object":let g=Lr(f,"device_code"),y=Lr(f,"user_code"),v=Lr(f,"verification_uri");if(g===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(v===void 0)return{TAG:"Error",_0:A("local runner device authorization response was incomplete")};let b=f.expires_in,w;return w=typeof b=="number"?b:void 0,{TAG:"Ok",_0:{deviceCode:g,userCode:y,verificationUri:v,expiresInSeconds:w}}}}let m=_c(f);return{TAG:"Error",_0:A(m!==void 0?"local runner device authorization failed to start (server said: "+m+")":"local runner device authorization failed to start (HTTP "+d.toString()+")")}}async function v1(e,t,r){let n=new AbortController,i=setTimeout(()=>{n.abort()},r+1e4|0),o={};o.device_code=t,o.wait_ms=r;let s={};s["content-type"]="application/json";let a=Kt("/api/v2/local-codex-runner/device/token",e),u;if(u=a.TAG==="Ok"?await pi(a._0.toString(),{method:"POST",headers:s,body:JSON.stringify(o),signal:Dt(n.signal)}):{TAG:"Error",_0:{message:a._0}},u.TAG==="Ok"){let c=u._0,l=c.status,d=await hi(c);if(clearTimeout(i),d.TAG!=="Ok")return n.signal.aborted?"Continue":{TAG:"Done",_0:{TAG:"Transient",reason:"non-JSON device/token response ("+d._0.message+")",httpStatus:l}};let p=d._0,f=l>=200&&l<300,h=_c(p),m=0;if(l!==202||h===void 0)m=1;else{if(h==="authorization_pending")return"Continue";m=1}if(m===1){let g=0;if(f){if(Array.isArray(p))return{TAG:"Done",_0:{TAG:"Rejected",reason:"device token response did not include access_token",httpStatus:l}};if(p===null)g=2;else switch(typeof p){case"object":let y=Lr(p,"access_token");if(y===void 0)return{TAG:"Done",_0:{TAG:"Rejected",reason:"device token response did not include access_token",httpStatus:l}};let v=p.expires_in,b;return b=typeof v=="number"?v:void 0,{TAG:"Done",_0:{TAG:"Token",_0:{accessToken:y,expiresInSeconds:b,workspaceSlug:Lr(p,"workspace"),channelSlug:Lr(p,"channel")}}};default:g=2}}else g=2;if(g===2){let y=0;if(h!==void 0)switch(h){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 l>=500||l===429?{TAG:"Done",_0:{TAG:"Transient",reason:h!==void 0?h:"HTTP "+l.toString(),httpStatus:l}}:{TAG:"Done",_0:{TAG:"Rejected",reason:h,httpStatus:l}}}}}else return clearTimeout(i),n.signal.aborted?"Continue":{TAG:"Done",_0:{TAG:"Transient",reason:u._0.message,httpStatus:void 0}}}async function fy(e,t,r,n){let i=n!==void 0?n:()=>Date.now(),o=r!==void 0&&r>=0?r:600,s=i()+o*1e3,a=async()=>{if(i()>=s)return"CodeExpired";let u=Math.max(0,Math.min(3e4,s-i())),c=await v1(e,t,u);return typeof c!="object"?await a():c._0};return await a()}function _y(e,t){if(e!==void 0&&isFinite(e)&&e>0)return e;let r=He(cs(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 b1(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 w1(e){try{return{TAG:"Ok",_0:new URL(e)}}catch(t){let r=K(t);return{TAG:"Error",_0:yo(r)}}}function k1(e,t){let r=He(t,o=>o.trim());if(r!==void 0&&r!=="")return{TAG:"Ok",_0:r};let n=w1(e);if(n.TAG!=="Ok")return{TAG:"Error",_0:n._0};let i=n._0.hostname.trim();return b1(i)&&i!=="localhost"?{TAG:"Ok",_0:i}:{TAG:"Ok",_0:"127.0.0.1"}}function x1(e,t,r,n,i,o,s){return Me(Kt("/api/v2/local-codex-runner/oauth/authorize",e),a=>{let u=a.searchParams;return u.set("redirect_uri",t),u.set("state",r),n!==void 0&&u.set("workspace",n),i!==void 0&&u.set("channel",i),o!==void 0&&u.set("onboarding",o),s!==void 0&&u.set("purpose","persisted_documents_publish"),a.toString()})}async function S1(e,t,r){let n=Kt("/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 s=await pi(n._0.toString(),{method:"POST",headers:o,body:JSON.stringify(i)});if(s.TAG!=="Ok")return{TAG:"Error",_0:A(s._0.message)};let a=s._0,u=a.status,c=await hi(a);if(c.TAG!=="Ok")return{TAG:"Error",_0:A(c._0.message)};let l=c._0;if(u>=200&&u<300){if(Array.isArray(l))return{TAG:"Error",_0:A("local runner OAuth token response did not include access_token")};if(l!==null)switch(typeof l){case"object":let f=Lr(l,"access_token");if(f===void 0)return{TAG:"Error",_0:A("local runner OAuth token response did not include access_token")};let h=l.expires_in,m;m=typeof h=="number"?h:void 0;let g=Lr(l,"workspace"),y=Lr(l,"channel");return{TAG:"Ok",_0:{accessToken:f,expiresInSeconds:m,workspaceSlug:g,channelSlug:y}}}}let p=_c(l);return p!==void 0?p==="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: "+p)}:{TAG:"Error",_0:A("local runner OAuth token exchange failed")}}function ud(e){return e.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;")}var T1='<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 $1(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>
110
+ - `+(h===""?"":"At "+h+": ")+f;c[g]||(c[g]=1,a=a+g)}}let u={code:"invalid_input",path:r,reason:a,expected:e,received:t,unionErrors:o};return i&&(u.input=n),u}function Vu(e,t,r,n){return i=>{let o=t!==void 0?t:"",s=n!==void 0?n:!0,a=e!==void 0?e:i.e,u=i.prev,c=u!==void 0?u.s:i.s,l=o===""?i.path:i.path+o;return d=>k_(a,c,l,d,s,void 0,r)}}function mt(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 Vu(void 0,void 0,r,void 0)(e)}function MT(e,t){let r=t!==void 0?t:e.e;return us(e,Vu(r,void 0,void 0,void 0)(e),e.v())}function DT(e,t){let r=e.vc,n=r.length;if(n===1){let s=r[0];return s.c(t)+"||"+us(e,s.f(e),t)+";"}let i="",o=0;for(;o<n;){let s=r[o],a=s.f,u=s.c(t);for(o=o+1|0;o<n&&r[o].f===a;)u=u+"&&"+r[o].c(t),o=o+1|0;i=i+(u+"||"+us(e,a(e),t)+";")}return i}function x_(e){return e.t===!0?e.prev.t!==!0?e.cp==="":!1:!0}function Dr(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&&x_(i)){let a=r.v(),u=i.vc,c="";for(let l=0,d=u.length;l<d;++l){let p=u[l],f=p.c(a);p.f===mt?c=c?c+"&&"+f:f:i.e.noValidation!==!0&&(o=o+(f+"||"+us(i,p.f(i),a)+";"))}c&&(t.contents?t.contents=c+"&&"+t.contents:t.contents=c)}else i.e.noValidation!==!0&&(o=DT(i,r.v()));i.hd!==""&&(o=o+("let "+i.hd+";")),i.fz=!0,o=i.cp+o,n=o+n}return n}function Fr(e,t,r,n){let i=n!==void 0?n:e.e;return{v:sc,i:t,s:r,e:i,prev:e,f:0,d:e.d,cp:"",hd:"",t:!0,path:e.path,g:e.g}}function De(e,t,r,n){let i=t!==void 0?t:e.s,o=n!==void 0?n:e.e,s=e.v!==Zt,a={v:s?IT:Zt,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(s){let u=e.v.bind(e);e.v=()=>{let c=u();return a.i=c,a.v=Zt,c}}return a}function Bu(e,t){let r=e.vc;r!==void 0?r.push(t):e.vc=[t]}function ds(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 c=0,l=a.length;c<l;++c)Bu(t,a[c]);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 s=n!==void 0?o!==void 0?De(e,void 0,n.concat(o),void 0):De(e,void 0,n,void 0):o!==void 0?De(e,void 0,o,void 0):e;return s.io=!0,s}function S_(e,t,r){if(!t.vc)return;let i="["+mi(e.g,r)+"]";t.vc.forEach(o=>Bu(e,{c:s=>o.c(s+i),f:o.f})),t.vc=void 0}function T_(e,t){let r=e.s.additionalItems,n;n=r!==void 0&&r!=="strip"&&r!=="strict"?r:lt;let i=e.e.additionalItems,o;return o=i!==void 0&&i!=="strip"&&i!=="strict"?i:lt,{p:e,v:jT,i:e.v()+"["+t+"]",s:n,e:o,f:e.f,cp:"",hd:"",path:"",g:e.g}}function li(e,t,r){return Fr(e,ys(e,t),t,r)}function $_(e,t){let r=Fr(e,t,e.s,void 0);return r.f=1,r}function An(e,t,r){e.s.type===ui?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+Dr(r,void 0),e.d[t]=r}function E_(e,t,r){return e.v()+"["+t+"]="+r.i}function an(e){let t=e.v!==Zt,r={b:e,v:t?RT:Zt,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=Zt,i}}return r}function GT(e,t){throw new di({code:"invalid_operation",path:e.path,reason:t})}function z_(e,t,r,n){if(e.path===""&&r===void 0)return Dr(e,void 0);{let i=u=>{let c=t.path,l=c===""?"":po(c)+"+";return u+".path="+l+(r!==void 0?`'["'+`+r+`+'"]'+`:"")+u+".path"},o=Dr(e,void 0);if(o===""&&!(e.f&1))return o+(n!==void 0?n():"");let s=sr(e.g),a=i(s)+";throw "+s;return e.f&1&&(e.i=e.i+".catch("+s+"=>{"+a+"})"),"try{"+o+(n!==void 0?n():"")+"}catch("+s+"){"+a+"}"}}function A_(e){return e}A_.embedded=fc;function Ru(e){return e+"<=2147483647&&"+e+">=-2147483648&&"+e+"%1===0"}function fs(e){return t=>"typeof "+t+'==="'+e+'"'}function co(e){return"Number.isNaN("+e+")"}function ac(e){return"Array.isArray("+e+")"}function O_(e){return fs(ut)(e)+"&&"+e}function ZT(e,t){return r=>r+" instanceof "+fi(e,t)}function FT(e){let t=Ye[e.s.type];if(t&1){let i=[{c:fs(On),f:mt}],o=e.e.format,s=0;return o==="int32"?i.push({c:Ru,f:mt}):s=1,s===1&&(e.g.o&2||i.push({c:a=>"!"+co(a),f:mt})),De(e,e.e,i,void 0)}if(!(t&2))return t&4?e.s.format!==e.e.format&&e.e.format==="int32"?De(e,e.e,[{c:Ru,f:mt}],void 0):e:vs(e,e.s,e.e);let r=sr(e.g),n=Fr(e,r,e.e,void 0);return n.v=Zt,n.cp="let "+r+"=+"+e.v()+";",n.vc=[{c:i=>{let o=e.e.format;return o!==void 0&&o==="int32"?Ru(r):"!"+co(r)},f:mt}],n}function P_(){return ho(On,On,e=>{e.decoder=FT})}function qT(e){return Fr(e,'""+'+e.i,Wu(),void 0)}function LT(e){let t=Ye[e.s.type];if(t&1)return De(e,e.e,[{c:fs(lo),f:mt}],void 0);if(!(t&3132&&Zr in e.s))return t&1036?qT(e):t&2?e:vs(e,e.s,e.e);let r=""+e.s.const,n=Ct(lo,!1);return n.const=r,Fr(e,'"'+r+'"',n,void 0)}function Wu(){return ho(lo,lo,e=>{e.decoder=LT})}function C_(e,t){e[Ye[t]&768?gs:t]=!0}var UT="JSON";function mo(e){let t=e.e;if(t.noValidation&&!e.u)return li(e,t,void 0);if(Zr in e.s)return e.s.const===t.const?e:li(e,t,void 0);let r=Ye[t.type];if(!(Ye[e.s.type]&2&&r&3132))return r&2048?De(e,t,[{c:co,f:mt}],void 0):De(e,t,[{c:o=>o+"==="+ys(e,t),f:mt}],void 0);let n=Ct(lo,!1);n.const=""+t.const;let i=li(e,n,n);return i.vc=[{c:o=>o+'==="'+n.const+'"',f:mt}],li(i,t,t)}function pc(){return ho(Gr,Gr,e=>{e.const=void 0,e.decoder=mo})}function VT(){return ho(uo,uo,e=>{e.const=null,e.decoder=mo})}function R_(){return ho(ju,ju,e=>{e.const=NaN,e.decoder=mo})}function Ju(e){if(e===null)return VT();let t=typeof e;if(t===Gr)return pc();if(t===On&&Number.isNaN(e))return R_();if(t===ut){let n=Ct(Fu,!0);return n.class=e.constructor,n.const=e,n.decoder=mo,n}let r=Ct(t,!0);return r.const=e,r.decoder=mo,r}function ar(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 s=o.v(),a=an(o),u=ar(a),c=Dr(u,void 0);t=a.i!==u.i||c!==""?Fr(o,s+".then("+s+"=>{"+c+"return "+u.i+"})",u.s,u.e):De(o,u.s,void 0,u.e),t.f=t.f|1,t.io=!0}else if(o.io){let s=o.e.to,u=o.e.parser;t=u!==void 0?u(o):De(t,void 0,void 0,s)}else{let s=o.s.encoder;s&&s!==i&&o.s!==o.e&&o.e.type!==gs&&(t=s(o,o.e)),o!==t?r=s:(t=o.e.decoder(o),t.io||(t=ds(t,t)))}}return t}function Rn(e){for(;;){let t=e,r=t.to;if(r===void 0)return t;e=r}}function sn(e){if(ao in e)return e[ao];let t,r=e;for(;r;){let i=fo(r),o=i.to,s=t;s!==void 0?i.to=s:delete i.to;let a=i.parser,u=i.serializer;u!==void 0?i.parser=u:delete i.parser,a!==void 0?i.serializer=a:delete i.serializer;let c=i.refiner,l=i.inputRefiner;l!==void 0?i.refiner=l:delete i.refiner,c!==void 0?i.inputRefiner=c:delete i.inputRefiner;let d=i.fromDefault,p=i.default;p!==void 0?i.fromDefault=p:delete i.fromDefault,d!==void 0?i.default=d:delete i.default;let f=i.items;f!==void 0&&(i.items=f.map(sn));let h=i.properties;if(h!==void 0){let y={},v=Object.keys(h);for(let b=0,w=v.length;b<w;++b){let S=v[b];y[S]=sn(h[S])}i.properties=y}typeof i.additionalItems===ut&&(i.additionalItems=sn(i.additionalItems));let m=i.anyOf;if(m!==void 0){let y={},v=[];for(let b=0,w=m.length;b<w;++b){let S=m[b],R=sn(S);v.push(R),C_(y,R.type)}i.has=y,i.anyOf=v}let g=i.$defs;if(g!==void 0){let y={};for(let v=0,b=Object.keys(g).length;v<b;++v){let w=Object.keys(g)[v];y[w]=sn(g[w])}i.$defs=y}t=i,r=o}let n=t;return zn[ic]=n,Sr(e,ao,zn),zn[ic]=e,Sr(n,ao,zn),n}function I_(e){try{return ar(e)}catch(t){let r=mc(t),n=e.p;throw r.path=(n!==void 0?n.path:"")+(e.path+"[]"+r.path),r}}function BT(e,t,r,n){let i=NT(Zr in e?lt:e,t,r,n),o=ar(i),s=Dr(o,void 0),a=CT(o.f,1);t.isAsync=a;let u=o.t===!0;if(t.hasTransform=u,s===""&&(o===i||o.i===i.i)&&!(r&1))return A_;let c=o.i;r&1&&!a&&!n&&(c="Promise.resolve("+c+")");let l="i=>{"+s+"return "+c+"}",d=i.g.e,p=new Function("e","s","return "+l)(d,Gu);return p.embedded=i.g.e,p}function cc(e,t){let r=arguments,n=0,i,o="",s=0,a;for(;i===void 0;){let c=r[n];if(c)if(typeof c===On){let l=c|ls.f;i=l,o=o+"-"+l}else{let l=c.seq;l>s&&(s=l,a=c),o=o+l+"-",n=n+1|0}else{let l=ls.f;i=l,o=o+"-"+l}}let u=a;if(u!==void 0){let c=o;if(c in u)return u[c];let l=r[n-1|0];for(let p=n-2|0;p>=0;--p){let f=l;l=Cn(r[p],h=>{h.to=f})}let d=BT(l,l,i,0);return zn[ic]=d,Sr(u,c,zn),d}throw new Error("[Sury] No schema provided for decoder.")}var pi="BS_PRIVATE_NESTED_SOME_NONE";function WT(e){let t=De(e,void 0,void 0,Hu());return t.cp=MT(e,void 0)+";",t}function Hu(){return ho(Nu,Nu,e=>{e.decoder=WT})}function JT(e){let t=e.e.to;return Fr(e,"{"+pi+":"+Rn(e.e).properties[pi].const+"}",t,t)}function ms(e,t){return{v:sc,i:"",s:t.type===ui?{type:ui,decoder:Qu,additionalItems:"strict",items:[]}:{type:ut,decoder:bs,additionalItems:"strict",required:[],properties:{}},e:e.e,prev:e,f:0,d:{},cp:"",hd:"",t:!0,path:e.path,g:e.g}}function Ku(e){return Yu(e,pc())}function bs(e){let t=e.u,r=e.e,n=Ye[e.s.type],i;if(n&65){let l=n&64,d;if(l)d=e.s;else{let f=Ct(ut,!1);f.properties=y_,f.additionalItems=lt,d=f}let p=[];l||(p.push({c:O_,f:mt}),r.additionalItems!=="strip"&&p.push({c:f=>"!"+ac(f),f:mt})),i=p.length!==0?De(e,d,p,void 0):De(e,d,void 0,void 0)}else i=vs(e,e.s,r);let o=r.additionalItems,s;s=o==="strip"||o==="strict"?void 0:o;let a=i.s.additionalItems,u;u=a!=="strip"&&a!=="strict";let c;if(s!==void 0)if(s===lt)c=i;else if(u){let l=i.v(),d=sr(i.g),p=T_(i,d),f=I_(p),h=f.t,m=h?Fr(i,"{}",r,void 0):De(i,r,void 0,void 0),g=z_(f,i,d,h?()=>E_(m,d,f):void 0);if((h||g!=="")&&(m.cp=m.cp+("for(let "+d+" in "+l+"){"+g+"}")),f.f&1){let y=sr(m.g),v=sr(m.g),b=sr(m.g),w=sr(m.g),S=m.v();c=$_(m,"new Promise(("+y+","+v+")=>{let "+w+"=Object.keys("+S+").length;for(let "+d+" in "+S+"){"+S+"["+d+"].then("+b+"=>{"+S+"["+d+"]="+b+";if("+w+"--===1){"+y+"("+S+")}},"+v+")}})")}else c=m}else{let l=ms(i,r),d=Object.keys(i.s.properties);for(let p=0,f=d.length;p<f;++p){let h=d[p],m=lc(i,h);m.e=s,m.io=!1,m.u=t,An(l,h,ar(m))}c=ps(l)}else{let l=r.properties,d=Object.keys(l),p=d.length,f=ms(i,r),h=r.additionalItems,m;m=h==="strip"||h==="strict"?h==="strip"?u||Object.keys(i.s.properties).length!==p:!1:!0;let g=i.s.additionalItems,y;y=g==="strip"||g==="strict"?!1:g.name===UT;for(let b=0;b<p;++b){let w=d[b],S=l[w],R=lc(i,w);R.e=S,R.io=!1,R.u=t,y&&S.type===Pn&&S.has[Gr]&&(R.i="("+R.i+"??null)");let X=ar(R);t&&Zr in S&&S_(i,X,w),An(f,w,X),m||(m=X.t)}let v=!1;if(r.additionalItems==="strict"){let b=i.s.additionalItems,w;w=b!=="strip"&&b!=="strict",v=w}if(v){let b=sr(f.g);if(oc(i,b),f.cp=f.cp+("for("+b+" in "+i.v()+"){if("),d.length!==0)for(let w=0,S=d.length;w<S;++w){let R=d[w];w!==0&&(f.cp=f.cp+"&&"),f.cp=f.cp+(b+"!=="+mi(i.g,R))}else f.cp=f.cp+"true";f.cp=f.cp+("){"+us(i,w=>({code:"unrecognized_keys",path:f.path,reason:'Unrecognized key "'+w+'"',keys:[w]}),b)+"}}")}if(m)c=ps(f);else{let b=De(i,void 0,void 0,void 0);b.cp=f.cp,b.d=f.d,c=b}}return ds(c,i)}function HT(){let e=Ju(0),t={};return t[pi]=e,{type:ut,serializer:r=>{let n=r.e.to;return li(r,n,n)},decoder:bs,additionalItems:"strip",required:[pi],properties:t}}function Qu(e){let t=e.u,r=e.e,n=Ye[e.s.type],i=r.items,o=i.length,s;if(n&129){let l=n&128,d=l?e.s:Xu(lt),p=[];l||p.push({c:ac,f:mt});let f=d.additionalItems,h;if(h=f==="strip"||f==="strict"?d.items.length===o:!1,!h){let m=r.additionalItems;(m==="strip"||m==="strict")&&(m==="strip"?p.push({c:g=>g+".length>="+o,f:mt}):p.push({c:g=>g+".length==="+o,f:mt}))}s=p.length!==0?De(e,d,p,void 0):De(e,d,void 0,void 0)}else s=vs(e,e.s,r);let a=r.additionalItems,u,c=0;if(a==="strip"||a==="strict")c=1;else if(a===lt)u=s;else{let l=s.v(),d=sr(s.g),p=T_(s,d),f=I_(p),h=f.t,m=h?Fr(s,"new Array("+l+".length)",r,void 0):De(s,r,void 0,void 0),g=z_(f,s,d,h?()=>E_(m,d,f):void 0);(h||g!=="")&&(m.cp=m.cp+("for(let "+d+"="+o+";"+d+"<"+l+".length;++"+d+"){"+g+"}")),u=f.f&1?$_(m,"Promise.all("+m.i+")"):m}if(c===1){let l=ms(s,r),d=r.additionalItems,p;if(d==="strip"||d==="strict")if(d==="strip"){let f=s.s.additionalItems;p=f==="strip"||f==="strict"?s.s.items.length!==o:!0}else p=!1;else p=!0;for(let f=0;f<o;++f){let h=i[f],m=f.toString(),g=lc(s,m);g.e=h,g.io=!1,g.u=t;let y=ar(g);t&&Zr in h&&S_(s,y,m),An(l,m,y),p||(p=y.t)}if(p)u=ps(l);else{let f=De(s,void 0,void 0,void 0);f.cp=l.cp,f.d=l.d,u=f}}return ds(u,s)}function KT(e,t){let r=e.s.anyOf;return t.type===Pn&&N_(t)===void 0&&j_(t.anyOf,r)||!YT(r,t)?e:XT(e,t)}function QT(e){let t=e.e,r=t.anyOf,n=Ye[e.s.type],i=N_(t);if(e.s===t&&i===void 0&&r.every(tc)||n&256&&j_(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=lt);let o="";if(!(n&769)){let j=Iu(e.s),$=!1,N=!1,G=r.length,M=0;for(;o===""&&M<G;){let V=r[M];Iu(V)===j?o=j:V.type===uo?$=!0:V.type===Gr&&(N=!0),M=M+1|0}o===""&&(n&16&&$?o=uo:n&32&&N&&(o=Gr))}let s=o,a=e.i,u=j=>fi(e,function(){let $=arguments,N=k_(t,lt,e.path,$[0],!0,$.length>1?Array.from($).slice(1):void 0,void 0);throw new di(N)})+"("+e.v()+j+")",c=De(e,void 0,void 0,void 0),l=[],d={contents:""},p=(j,$)=>{let N=j[0],G=j[1],M="",V="",we=!1,Le={contents:""},nt="",At={},xt=2,xe=j.length-1|0;for(;xt<=xe;){let Ue=an(G);Ue.u=!0,Ue.t=G.t,Ue.io=!1,Ue.e=j[xt];let Ve=xt===xe,ye=xt===2,vr=ye&&Ve,Yi=!vr,Ir=!1,rn="",wn={contents:""};try{let Oe=ar(Ue);if(l.push(Oe.s),rn=Dr(Oe,wn),Oe.t){c.t=!0,Oe.f&1&&(c.f=c.f|1);let jr=N.v();Oe.i!==jr&&(rn=rn+(jr+"="+Oe.i))}}catch(Oe){let jr=fi(Ue,mc(Oe));nt=nt+","+jr,$&&vr?(d.contents=jr,Ir=!0):Ve?(Yi=!1,rn=$?"throw "+jr:u(nt)):Ir=!0}let kn=wn.contents,ti=rn;if(!Ir&&kn)if(ti){let Oe=At[kn];Oe!==void 0?typeof Oe=="string"?At[kn]=[Oe,ti]:Oe.push(ti):At[kn]=ti}else Le.contents=Le.contents?Le.contents+"||"+kn:kn;if(!Ir&&(!kn||Ve)){let Oe=Object.keys(At);for(let jr=0,AS=Oe.length;jr<AS;++jr){let vg=Oe[jr];M=M+(we?"else if":"if")+("("+vg+"){");let rs=At[vg];if(typeof rs=="string")M=M+rs+"}";else{let du="";for(let Ca=0,OS=rs.length;Ca<OS;++Ca){let PS=rs[Ca],bg="e"+Ca;M=M+("try{"+PS+"}catch("+bg+"){"),du=du+","+bg}M=M+u(du)+"}".repeat(rs.length)+"}"}we=!0}At={}}if(!Ir&&!kn)if(ti)if(Le.contents&&(M=M+(we?"else if":"if")+("(!("+Le.contents+")){"),V="}"+V,Le.contents="",we=!1),Ve&&($||!Yi||ye))M=M+((we?"else{":"")+ti),V=(we?"}":"")+V;else{let Oe="e"+(xt-2|0);M=M+((we?"else{":"")+"try{"+ti+"}catch("+Oe+"){"),V=(we?"}":"")+"}"+V,nt=nt+","+Oe,we=!1}else Le.contents="",xt=xe,Yi=!1;if(Ve){if(Le.contents)M||nt?M=M+(we?"else if":"if")+("(!("+Le.contents+")){"+u(nt)+"}"):Bu(G,{c:Oe=>"("+Le.contents+")",f:mt});else if(Yi){let Oe=u(nt);M=M+(we?"else{"+Oe+"}":Oe)}}xt=xt+1}return M+V},f="",h="",m="",g=!1,y=r.length-1|0,v={},b=[],w=t.refiner,S=t.inputRefiner,R={contents:void 0},X={contents:void 0},be=(j,$,N)=>{if($===void 0)return j;let G=M=>{let V=N.contents;if(V!==void 0)return V;let we=$(M);return N.contents=we,we};return j!==void 0?M=>{let V=j(M),we=G(M);for(let Le=0,nt=we.length;Le<nt;++Le)V.push(we[Le]);return V}:G},D=j=>{let $=be(j.refiner,w,R);$!==void 0&&(j.refiner=$);let N=be(j.inputRefiner,S,X);if(N!==void 0){j.inputRefiner=N;return}},I;if(Zr in e.s){let j=[],$=[];for(let N=0;N<=y;++N){let G=r[N];Zr in G&&G.const===e.s.const?j.push(G):$.push(G)}I=j.concat($)}else I=r;for(let j=0;j<=y;++j){let $=i!==void 0?Cn(I[j],V=>{D(V),V.to=i}):I[j],N=$.type,G=Ye[N],M=Iu($);if((s===""||s===M)&&!(G&16&&"fromDefault"in t)){let V=v[M];if(V!==void 0)G&64&&pi in $.properties?V.splice(V.length-1|0,0,$):G&2096||V.push($);else{let we=an(e),Le;if(G&37633)Le=lt;else{let xe=Ct($.type,!1);xe.encoder=$.encoder,G&8192?xe.class=$.class:G&64?(xe.properties=y_,xe.additionalItems=lt):G&128?(xe.additionalItems=lt,xe.items=fc):G&2096&&(xe.const=$.const),xe.decoder=Ue=>Ye[Ue.s.type]&1?De(Ue,Ue.e,[{c:Ve=>{let ye=Ye[$.type];if(ye&64)return O_(Ve)+"&&!"+ac(Ve);if(ye&128)return ac(Ve);if(ye&8192)return ZT(Ue,$.class)(Ve);if(!(ye&4))return ye&2048?co(Ve):ye&48?Ve+"==="+ys(Ue,$):ye&17418?fs($.type)(Ve):"";let vr=fs(On)(Ve);return Ue.g.o&2?vr:vr+"&&!"+co(Ve)},f:mt}],void 0):$.decoder(Ue),Le=xe}we.e=Le;let nt;try{nt=ar(we)}catch{we.vc=void 0,nt=we}h_(G,v)?b.unshift(M):b.push(M),v[M]=[we,nt,$];let At=!0,xt=nt;for(;xt!==void 0&&At;){let xe=xt;xt=xe.prev,At=!(xe.vc&&x_(xe))}if(At){for(let xe=0,Ue=b.length;xe<Ue;++xe){let Ve=b[xe];if(!g){let ye=v[Ve],vr=ye[1],Yi=p(ye,!0),Ir=Dr(vr,void 0)+Yi,rn=d.contents;if(rn)if(d.contents="",Ir){let wn="e"+(j+xe|0);f=f+("try{"+Ir+"throw "+rn+"}catch("+wn+"){"),h="}"+h,m=m+","+wn}else m=m+","+rn;else if(Ir){let wn="e"+(j+xe|0);f=f+("try{"+Ir+"}catch("+wn+"){"),h="}"+h,m=m+","+wn}else g=!0}}v={},b=[]}}}}let B=v,re=b;if(!g){let j=!1,$="";for(let M=0,V=re.length;M<V;++M){let we=B[re[M]],Le=we[1],nt=we[2],At=p(we,!1),xt={contents:""},xe=Dr(Le,xt)+At,Ue=xt.contents;xe||h_(Ye[nt.type],B)?(f=f+(j?"else if":"if")+("("+Ue+"){"+xe+"}"),j=!0):$=$?$+"||"+Ue:Ue}let N=u(m),G;$?G=(j?"else if":"if")+("(!("+$+")){"+N+"}"):G=j?"else{"+N+"}":h===""?N+";":N,f=f+G}c.cp=c.cp+f+h,e.i!==c.i&&(c.i=e.i);let le=c.f&1?(c.i="Promise.resolve("+c.i+")",c.v=sc,c):c.v===Zt&&e.cp===""&&c.cp===""&&a==="i"?(e.hd="",e.v=sc,e.i=a,e):c;return le.s=l.length?hs(l):Hu(),le.e=i!==void 0?(le.io=!0,Rn(i)):t,le}function j_(e,t){return t.every((r,n)=>{let i=e[n];return i!==void 0&&!(Ye[r.type]&9152)&&r.type===i.type&&r.const===i.const?r.to===void 0:!1})}function XT(e,t){return De(e,lt,void 0,Cn(e.s,r=>{r.to=t}))}function YT(e,t){return!(Ye[Rn(t).type]&512)&&!(t.type===Pn&&t.anyOf.some(r=>Ye[r.type]&512))?!e.some(r=>r.to!==void 0||r.parser!==void 0?!0:Ye[r.type]&512):!1}function N_(e){if(e.parser!==void 0)return;let r=e.to;if(r!==void 0)return r}function lc(e,t){let r=e.d,n;if(r!==void 0)n=r;else{let l={};e.d=l,n=l}let i=n[t];if(i!==void 0)return an(i);let o=e.s.type===ut?e.s.properties[t]:e.s.items[t],s;if(o!==void 0)s=o;else{let l=e.s.additionalItems;s=l==="strip"||l==="strict"?vs(e,e.s,e.e):e.s.type===ut&&l.type!==gs&&!(Ye[l.type]&512)&&!PT(l)?Ku(l):l}let u="["+mi(e.g,t)+"]",c={p:e,v:Mu,i:Zr in s?ys(e,s):e.v()+u,s,e:s,f:0,cp:"",hd:"",path:e.path+u,g:e.g};return n[t]=c,c}function ps(e){let t=e.s.type===ui,r="",n="",i,o=Object.keys(e.d);for(let c=0,l=o.length;c<l;++c){let d=o[c],p=e.d[d];if(p.f&1&&(n=n+p.i+","),p.o){let f=i;i=h=>(f!==void 0?f(h):"")+("if("+p.v()+"!==void 0){"+h+"["+mi(e.g,d)+"]="+p.i+"}")}else r=r+(t?p.i:mi(e.g,d)+":"+p.i)+","}if(e.i=t?"["+r+"]":"{"+r+"}",n){let c=an(e);c.io=!0;let l=ar(c),d=Dr(l,void 0);return d===""&&n===l.i+","?e.i=l.i:e.i="Promise.all(["+n+"]).then((["+n+"])=>{"+d+"return "+l.i+"})",e.f=e.f|1,e.s=l.s,e.e=l.e,e.io=!0,e}let s=i;if(s===void 0)return e;let a=s(e.v()),u=De(e,void 0,void 0,void 0);return u.cp=u.cp+a,u}function hs(e){let t=e.length;if(t===1)return e[0];if(t!==0){let r={},n=new Set;for(let o=0,s=e.length;o<s;++o){let a=e[o];a.type===Pn&&a.to===void 0?(a.anyOf.forEach(u=>{n.add(u)}),Object.assign(r,a.has)):(n.add(a),C_(r,a.type))}let i=Ct(Pn,!1);return i.anyOf=Array.from(n),i.decoder=QT,i.encoder=KT,i.has=r,i}throw new Error("[Sury] S.union requires at least one item")}function h_(e,t){return e&8320&&ut in t?!0:e&2048?On in t:!1}function Iu(e){return Ye[e.type]&8192?e.class.name:e.type}function tc(e){for(;;){let t=e,r=!1,n=!1,i=!1;if(t.to===void 0&&t.parser===void 0&&!(Ye[t.type]&512)){let s=t.anyOf;i=s!==void 0?s.every(tc):!0}if(i){let s=t.items;n=s!==void 0?s.every(tc):!0}if(n){let s=t.properties;r=s!==void 0?Object.values(s).every(tc):!0}if(!r)return!1;let o=t.additionalItems;if(o===void 0||o==="strip"||o==="strict")return!0;e=o}}function Xu(e){let t=Ct(ui,e[ao]===e);return t.additionalItems=e,t.items=fc,t.decoder=Qu,t}function Yu(e,t){let r=t!==void 0?t:pc(),n=Rn(e);switch(n.type){case"undefined":return hs([r,g_(e)]);case"union":let o=n.has,s=n.anyOf;return Cn(e,a=>{let u=xT(o),c=[];for(let l=0,d=s.length;l<d;++l){let p=s[l],f=Rn(p),h=f.type,m;if(h==="undefined")u[r.type]=!0,c.push(r),m=g_(p);else{let g=f.properties;if(g!==void 0){let y=g[pi];m=y!==void 0?Cn(p,v=>{let b={},w={...y};w.const=y.const+1,b[pi]=w,v.properties=b}):p}else m=p}c.push(m)}c.length===s.length&&(u[r.type]=!0,c.push(r)),a.anyOf=c,a.has=u});default:return hs([e,r])}}function g_(e){return Cn(e,t=>{t.to=HT(),t.parser=JT})}Sr(Uu,"~standard",{get:function(){let e=this;return{version:1,vendor:Du,validate:t=>{try{return{value:cc(lt,e)(t)}}catch(r){let n=mc(r);return{issues:[{message:n.reason,path:n.path===""?void 0:ST(n.path)}]}}}}}});function M_(e,t){return cc(lt,t)(e)}function e1(e,t){return Cn(e,r=>{let n=t(r),i=r.refiner;i!==void 0?r.refiner=o=>{let s=i(o),a=n(o);for(let u=0,c=a.length;u<c;++u)s.push(a[u]);return s}:r.refiner=n})}function D_(e,t,r,n){let i=r!==void 0?r:"Refinement failed",o=n!==void 0?$T(n):"";return e1(e,s=>(a=>{let u=fi(a,t);return[{c:c=>u+"("+c+")",f:Vu(void 0,o,i,void 0)}]}))}function G_(e,t){return Cn(e,r=>{let n=r.anyOf;if(n!==void 0){let o=[],s=[];for(let p=0,f=n.length;p<f;++p){let h=n[p],m=Rn(h);m.type!=="undefined"&&(o.push(m),s.push(h))}let a=o.length,u;if(a!==1)if(a!==0)u=hs(o);else{let p="Can't set default for "+Xe(r);throw new Error("[Sury] "+p)}else u=o[0];let c=s.length!==1?hs(s):s[0];if(t.TAG==="Value"){let p=t._0;try{cc(lt,u)(p)}catch(f){let h=mc(f),m="Invalid default for "+Xe(r)+": "+h.message;throw new Error("[Sury] "+m)}try{r.default=cc(sn(c),void 0)(p)}catch{}}r.parser=p=>{let f=p.e.to,h=p.v(),m;return m=t.TAG==="Value"?ys(p,Ju(t._0)):fi(p,t._0)+"()",Fr(p,h+"===void 0?"+m+":"+h,f,f)};let l=fo(u),d=l.decoder;l.serializer=p=>{let f=sn(c);return De(d(p),f,void 0,f)},l.decoder=w_,r.to=l;return}let i="Can't set default for "+Xe(r);throw new Error("[Sury] "+i)})}function t1(e){return e[Zu]}function uc(e,t,r){let n=fo(Rn(e));return n.from=t,r!==void 0&&(n.fromFlattened=r),new Proxy(n,{get:(i,o)=>{if(o===Zu)return i;let s=i.items,a=i.properties,u=a!==void 0?a[o]:s!==void 0?s[o]:void 0;if(u===void 0){let c='Cannot read property "'+o+'" of '+Xe(i);throw new Error("[Sury] "+c)}return uc(u,i.from.concat(o),i.fromFlattened)}})}function Z_(e,t,r){let n=ms(e,t);n.io=!0;let i=t.items;if(i!==void 0)for(let o=0,s=i.length;o<s;++o){let a=o.toString();An(n,a,r(a,i[o]))}else{let o=t.properties;if(o!==void 0){let s=Object.keys(o);for(let a=0,u=s.length;a<u;++a){let c=s[a];An(n,c,r(c,o[c]))}}else{let s="Don't know where the value is coming from: "+Xe(t);throw new Error("[Sury] "+s)}}return ps(n)}function F_(e,t){let r=t.from,n=t.fromFlattened,i=n!==void 0?an(__(e.fv[n],t.from,0)):r!==void 0?an(__(e,r,0)):Zr in t?li(e,t,void 0):Z_(e,t,(o,s)=>F_(e,s));return i.prev=void 0,i.e=t,i}function q_(e,t){let r=t.e,n=r.from;if(n!==void 0){let s=r.fromFlattened,a;if(s!==void 0){e.flattened===void 0&&(e.flattened=[]);let u=e.flattened[s];if(u!==void 0)a=u;else{let c={};e.flattened[s]=c,a=c}}else a=e;for(let u=0,c=n.length;u<c;++u){let l=n[u],d=a.properties,p;if(d!==void 0)p=d;else{let m={};a.properties=m,p=m}let f=p[l],h;if(f!==void 0)h=f;else{let m={};p[l]=m,h=m}a=h}a.val=t;return}let i=t.d;if(i===void 0)return;let o=Object.keys(i);for(let s=0,a=o.length;s<a;++s)q_(e,i[o[s]])}function rc(e,t,r,n){let i=0;if(t!==void 0){let o=t.val;if(o!==void 0){let s=an(o);return s.t=!0,s.s=r,s.e=r,ar(s)}i=1}else i=1;if(i===1){if(Zr in r){let d=li(e,r,r);return d.prev=void 0,d.p=e,d.v=Mu,d.io=!0,ar(d)}let o=t===void 0?Rn(r):r,s=ms(e,o);s.e=o,s.io=!0,s.prev=void 0,s.p=e,s.v=Mu;let a=o.flattened,u=o.items,c=0,l=0;if(u!==void 0&&(t!==void 0||typeof o.additionalItems!==ut))for(let d=0,p=u.length;d<p;++d){let f=d.toString(),h;if(t!==void 0){let g=t.properties;h=g!==void 0?g[f]:void 0}else h=void 0;let m=mi(e.g,f);An(s,f,rc(e,h,u[d],n+("["+m+"]")))}else l=3;if(l===3){let d=o.properties;if(d!==void 0&&(t!==void 0||typeof o.additionalItems!==ut)){if(a!==void 0&&t!==void 0){let f=t.flattened;f!==void 0&&f.forEach((h,m)=>{let y=rc(e,h,sn(a[m]),n).d,v=Object.keys(y);for(let b=0,w=v.length;b<w;++b){let S=v[b];An(s,S,y[S])}})}let p=Object.keys(d);for(let f=0,h=p.length;f<h;++f){let m=p[f];if(!(m in s.d)){let g;if(t!==void 0){let v=t.properties;g=v!==void 0?v[m]:void 0}else g=void 0;let y=mi(e.g,m);An(s,m,rc(e,g,d[m],n+("["+y+"]")))}}}else c=2}if(c===2){let d=r.from,p=d!==void 0?n+d.map(h=>'["'+h+'"]').join(""):n,f=p===""?"":" at "+p;GT(e,"Missing input for "+Xe(r)+f)}return ps(s)}}function __(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 dc(e,t){if(typeof e!==ut||e===null)return Ju(e);let r=t(e);if(r!==void 0)return r;if(Array.isArray(e)){for(let u=0,c=e.length;u<c;++u){let l=dc(e[u],t);e[u]=l}let a=Ct(ui,!1);return a.items=e,a.additionalItems="strict",a.decoder=Qu,a}let n=e.constructor;if(n&&n!==Object){let a=Ct(Fu,!0);return a.class=n,a.const=e,a.decoder=mo,a}let i=Object.keys(e),o=i.length;for(let a=0;a<o;++a){let u=i[a],c=dc(e[u],t);e[u]=c}let s=Ct(ut,!1);return s.required=i,s.properties=e,s.additionalItems=ls.a,s.decoder=bs,s}function r1(e){let t={};q_(t,e);let r=e.e.to,n=rc(e,t,r,"");return n.t=!0,n.prev=e,n}function L_(e){return dc(e,t=>{if(t["~standard"])return t})}function U_(e){let t=this,r="~"+e,n=t[r];if(n!==void 0)return he(n);let i={},o=[],s=Ct(ut,!1);s.required=o,s.properties=i,s.additionalItems=ls.a,s.decoder=bs;let a=t.f(e,s)[Zu],u=(f,h)=>{let m=po(f);if(f in i)throw new Error("[Sury] "+("The field "+m+" defined twice"));return o.push(f),i[f]=h,uc(h,a.from.concat(f),a.fromFlattened)},p={field:u,f:u,fieldOr:(f,h,m)=>{let g=Yu(h,void 0);return u(f,G_(g,{TAG:"Value",_0:m}))},tag:(f,h)=>{u(f,L_(h))},nested:U_,flatten:f=>{if(f.type==="object"){let g=f.to,y=f.properties;if(g){let w="Unsupported nested flatten for transformed object schema "+Xe(f);throw new Error("[Sury] "+w)}let v=Object.keys(y),b={};for(let w=0,S=v.length;w<S;++w){let R=v[w];b[R]=u(R,y[R])}return b}let m="Can't flatten "+Xe(f)+" schema";throw new Error("[Sury] "+m)}};return t[r]=p,p}function n1(e){let t=fo(dc(e,t1));return t.serializer=r1,t}function i1(e){let t=e.e.flattened;if(t!==void 0){let i=[];for(let o=0,s=t.length;o<s;++o){let a=t[o],u=a.to,c;if(u!==void 0){let l=an(e);l.e=a,l.io=!0,c=ar(l)}else{let l=Z_(e,a,(d,p)=>lc(e,d));l.e=a,l.prev=void 0,c=ds(l,l)}i.push(c),e.cp=e.cp+Dr(c,void 0)}e.fv=i}let r=e.e.to,n=F_(e,r);return n.t=!0,n.prev=e,ds(n,e)}function V_(e){let t,r={},n=l=>{if(l.type==="object"){let f=l.properties,h=Object.keys(f);for(let g=0,y=h.length;g<y;++g){let v=h[g],b=f[v],w=r[v];if(w!==void 0){if(w!==b)throw new Error("[Sury] "+('The field "'+v+'" defined twice with incompatible schemas'))}else r[v]=b}let m=t||(t=[]);return uc(l,fc,m.push(l)-1|0)}let p="The '"+Xe(l)+"' schema can't be flattened";throw new Error("[Sury] "+p)},i=(l,d)=>{if(l in r)throw new Error("[Sury] "+('The field "'+l+'" defined twice with incompatible schemas'));return r[l]=d,uc(d,[l],void 0)},u=e({field:i,f:i,fieldOr:(l,d,p)=>{let f=Yu(d,void 0);return i(l,G_(f,{TAG:"Value",_0:p}))},tag:(l,d)=>{i(l,L_(d))},nested:U_,flatten:n}),c=Ct(ut,!1);return c.required=Object.keys(r),c.properties=r,c.additionalItems=ls.a,c.decoder=bs,c.parser=i1,c.to=n1(u),t!==void 0&&(c.flattened=t),c}var In=Wu();var B_=P_();var W_=qu;var J_=Xu;var ws=Ku;var cn=D_;var H_=M_;var hc=V_;function s1(e){return{path:e.path,summary:e.message}}function A(e){return{path:"",summary:e}}function ed(e,t){try{return{TAG:"Ok",_0:H_(e,t)}}catch(r){let n=K(r);if(n.RE_EXN_ID===W_)return{TAG:"Error",_0:s1(n._1)};throw n}}import*as ks from"node:fs";import*as ty from"node:os";import*as gc from"node:path";var a1="--api-url must be ws://, wss://, http://, or https://";function pt(e){let t=En(e);if(t===void 0)return{TAG:"Error",_0:"invalid URL: "+e};let r=he(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:a1}}return Me(i,()=>{r.pathname="",r.search="",r.hash="";let o=r.toString();return o.endsWith("/")?o.slice(0,o.length-1|0):o})}var Q_="wss://serve.linzumi.com";function go(){return gc.join(ty.homedir(),".linzumi","auth.json")}var X_="Kandan auth cache must contain a JSON object",c1="Kandan auth cache local_codex_runner must be an object",l1="Kandan auth cache personal_agent_delegation must be an object";function Y_(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 ry(e){let t;try{t=JSON.parse(e)}catch{t=void 0}if(t===void 0)return{TAG:"Error",_0:A(X_)};if(typeof t!="object"||t===null||Array.isArray(t))return{TAG:"Error",_0:A(X_)};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(c1)};if(!o)return{TAG:"Error",_0:A(l1)};let s;return s=typeof r=="object"&&r!==null&&!Array.isArray(r)?Object.fromEntries(Qt(Object.entries(r),a=>{let u=a[0];return He(Y_(a[1]),c=>[u,c])})):void 0,{TAG:"Ok",_0:{serverTokens:s,personalAgentDelegation:Ke(n,Y_)}}}function ny(e){return ks.existsSync(e)?Y(ve(kr(e),t=>A(t.message)),t=>Me(ry(t),r=>r)):{TAG:"Ok",_0:void 0}}function iy(e,t){return e!==void 0?new Date(e).getTime()<=t:!1}function _o(e,t,r){return ks.existsSync(t)?Y(ny(t),n=>Me(ve(pt(e),A),i=>Ke(Ke(Ke(n,o=>o.serverTokens),o=>o[i]),o=>{if(!(o.accessToken.trim()===""||iy(o.expiresAt,r)))return{accessToken:o.accessToken,serverBaseUrl:i,issuedAt:o.issuedAt,expiresAt:o.expiresAt}}))):{TAG:"Ok",_0:void 0}}function u1(e){return"missing personal-agent delegation auth file: "+e}var d1="personal-agent delegation auth file is missing access_token",f1="personal-agent delegation auth file token is expired";function oy(e,t){return ks.existsSync(e)?Y(ny(e),r=>{let n=Ke(r,i=>i.personalAgentDelegation);return n!==void 0&&n.accessToken.trim()!==""?iy(n.expiresAt,t)?{TAG:"Error",_0:A(f1)}:{TAG:"Ok",_0:n}:{TAG:"Error",_0:A(d1)}}):{TAG:"Error",_0:A(u1(e))}}function ey(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 m1(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],ey(i[1])])));let n=e.personalAgentDelegation;return n!==void 0&&(t.personal_agent_delegation=ey(n)),t}function td(e,t,r,n,i){return Y(ve(pt(e),A),o=>{let s=ks.existsSync(n)?Y(ve(kr(n),a=>A(a.message)),ry):{TAG:"Ok",_0:{serverTokens:void 0,personalAgentDelegation:void 0}};return Y(s,a=>{let u=i.toISOString(),c=He(r,y=>new Date(i.getTime()+y*1e3).toISOString()),l={accessToken:t,issuedAt:u,expiresAt:c},d=a.serverTokens,p=d!==void 0?Object.fromEntries(Object.entries(d)):{};p[o]=l;let f=m1({serverTokens:p,personalAgentDelegation:a.personalAgentDelegation}),h=JSON.stringify(f,void 0,2)+`
111
+ `,m=n+".tmp."+process.pid.toString()+"."+i_(6),g=y=>A(y.message);return Y(ve(xr(gc.dirname(n)),g),()=>{let y=Y(as(m,h,{encoding:"utf8",mode:384}),()=>Wa(m,n));return y.TAG==="Ok"?{TAG:"Ok",_0:{accessToken:t,serverBaseUrl:o,issuedAt:u,expiresAt:c}}:(si(m),{TAG:"Error",_0:A(y._0.message)})})})})}function yo(e){let t=br(e);return t!==void 0?rt(wr(he(t)),"unknown error"):"unknown error"}async function hi(e,t){try{return{TAG:"Ok",_0:await fetch(e,t)}}catch(r){let n=K(r);return{TAG:"Error",_0:{message:yo(n)}}}}async function p1(e){try{return{TAG:"Ok",_0:await e.text()}}catch(t){let r=K(t);return{TAG:"Error",_0:{message:yo(r)}}}}async function gi(e){let t=await p1(e);if(t.TAG!=="Ok")return{TAG:"Error",_0:t._0};try{return{TAG:"Ok",_0:JSON.parse(t._0)}}catch(r){let n=K(r);return{TAG:"Error",_0:{message:yo(n)}}}}function h1(e){if(typeof e=="object"&&e!==null&&!Array.isArray(e))return e}async function vo(e,t,r,n,i){let o=i!==void 0?i:[],s=ve(pt(e),A);if(s.TAG!=="Ok")return{TAG:"Error",_0:s._0};let a=Kt("/api/v2/local-codex-runner/oauth/validate",s._0);if(a.TAG!=="Ok")return{TAG:"Error",_0:A(a._0)};let u=a._0,c=u.searchParams;r!==void 0&&c.set("workspace",r),n!==void 0&&c.set("channel",n),o.forEach(h=>{c.append("required_scope",h)});let l={};l.authorization="Bearer "+t;let d=await hi(u.toString(),{method:"GET",headers:l});if(d.TAG!=="Ok")return{TAG:"Error",_0:A(d._0.message)};let p=d._0,f=p.status;if(f>404||f<401){if(f===200){let h=await gi(p);return h.TAG!=="Ok"?{TAG:"Error",_0:A(h._0.message)}:Ke(h1(h._0),g=>g.ok)===!0?{TAG:"Ok",_0:"Usable"}:{TAG:"Ok",_0:"Rejected"}}}else{if(f<402)return{TAG:"Ok",_0:"Rejected"};switch(f){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 "+f.toString())}}import*as My from"node:os";function ay(e){return e._0}var h3=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])?)*$"),g3=new RegExp("^[0-9.]+$");function od(e){if(typeof e!="string")return;let t=e.trim();if(t!=="")return t}function sd(e){return isFinite(e)?Math.trunc(e)===e:!1}function y1(e){if(typeof e=="number"&&e%1===0)return e}function v1(e){let t=e.replaceAll("-","+").replaceAll("_","/");switch(t.length&3){case 2:return t+"==";case 3:return t+"=";default:return t}}function cy(e){let t=e.split(".")[1];if(t===void 0)return;let r=Buffer.from(v1(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}var cd=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;function ly(e){let t=cy(e);if(t===void 0)return!1;let n=t.document_surfaces===!0,i=t.linzumi_agent_session,o=typeof i=="string"?cd.test(i):!1,s=t.coding_job_id,a=t.coding_job_thread_id,u=typeof s=="string"&&typeof a=="string"?cd.test(s)&&cd.test(a):!1;return n?o?!0:u:!1}function ld(e){let t=Ke(cy(e),r=>y1(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=K(r),i=br(n);return{TAG:"Error",_0:A(i!==void 0?rt(wr(he(i)),"unknown error"):"unknown error")}}}import*as hy from"node:http";import*as gy from"node:crypto";import*as _y from"node:child_process";function _c(e){if(typeof e!="object"||e===null||Array.isArray(e))return;let t=e.error;if(typeof t=="string")return t}function dy(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 Lr(e,t){let r=e[t];if(r!==void 0&&typeof r=="string"&&r.trim()!=="")return r}async function fy(e,t,r,n,i){let o=Kt("/api/v2/local-codex-runner/device/start",e);if(o.TAG!=="Ok")return{TAG:"Error",_0:A(o._0)};let s={},a=(g,y)=>{if(y!==void 0){s[g]=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 u={};u["content-type"]="application/json";let c=await hi(o._0.toString(),{method:"POST",headers:u,body:JSON.stringify(s)});if(c.TAG!=="Ok")return{TAG:"Error",_0:A(c._0.message)};let l=c._0,d=l.status,p=await gi(l);if(p.TAG!=="Ok")return{TAG:"Error",_0:A(p._0.message)};let f=p._0;if(d>=200&&d<300){if(Array.isArray(f))return{TAG:"Error",_0:A("local runner device authorization response was incomplete")};if(f!==null)switch(typeof f){case"object":let g=Lr(f,"device_code"),y=Lr(f,"user_code"),v=Lr(f,"verification_uri");if(g===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(v===void 0)return{TAG:"Error",_0:A("local runner device authorization response was incomplete")};let b=f.expires_in,w;return w=typeof b=="number"?b:void 0,{TAG:"Ok",_0:{deviceCode:g,userCode:y,verificationUri:v,expiresInSeconds:w}}}}let m=_c(f);return{TAG:"Error",_0:A(m!==void 0?"local runner device authorization failed to start (server said: "+m+")":"local runner device authorization failed to start (HTTP "+d.toString()+")")}}async function b1(e,t,r){let n=new AbortController,i=setTimeout(()=>{n.abort()},r+1e4|0),o={};o.device_code=t,o.wait_ms=r;let s={};s["content-type"]="application/json";let a=Kt("/api/v2/local-codex-runner/device/token",e),u;if(u=a.TAG==="Ok"?await hi(a._0.toString(),{method:"POST",headers:s,body:JSON.stringify(o),signal:Dt(n.signal)}):{TAG:"Error",_0:{message:a._0}},u.TAG==="Ok"){let c=u._0,l=c.status,d=await gi(c);if(clearTimeout(i),d.TAG!=="Ok")return n.signal.aborted?"Continue":{TAG:"Done",_0:{TAG:"Transient",reason:"non-JSON device/token response ("+d._0.message+")",httpStatus:l}};let p=d._0,f=l>=200&&l<300,h=_c(p),m=0;if(l!==202||h===void 0)m=1;else{if(h==="authorization_pending")return"Continue";m=1}if(m===1){let g=0;if(f){if(Array.isArray(p))return{TAG:"Done",_0:{TAG:"Rejected",reason:"device token response did not include access_token",httpStatus:l}};if(p===null)g=2;else switch(typeof p){case"object":let y=Lr(p,"access_token");if(y===void 0)return{TAG:"Done",_0:{TAG:"Rejected",reason:"device token response did not include access_token",httpStatus:l}};let v=p.expires_in,b;return b=typeof v=="number"?v:void 0,{TAG:"Done",_0:{TAG:"Token",_0:{accessToken:y,expiresInSeconds:b,workspaceSlug:Lr(p,"workspace"),channelSlug:Lr(p,"channel")}}};default:g=2}}else g=2;if(g===2){let y=0;if(h!==void 0)switch(h){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 l>=500||l===429?{TAG:"Done",_0:{TAG:"Transient",reason:h!==void 0?h:"HTTP "+l.toString(),httpStatus:l}}:{TAG:"Done",_0:{TAG:"Rejected",reason:h,httpStatus:l}}}}}else return clearTimeout(i),n.signal.aborted?"Continue":{TAG:"Done",_0:{TAG:"Transient",reason:u._0.message,httpStatus:void 0}}}async function my(e,t,r,n){let i=n!==void 0?n:()=>Date.now(),o=r!==void 0&&r>=0?r:600,s=i()+o*1e3,a=async()=>{if(i()>=s)return"CodeExpired";let u=Math.max(0,Math.min(3e4,s-i())),c=await b1(e,t,u);return typeof c!="object"?await a():c._0};return await a()}function yy(e,t){if(e!==void 0&&isFinite(e)&&e>0)return e;let r=He(cs(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 w1(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 k1(e){try{return{TAG:"Ok",_0:new URL(e)}}catch(t){let r=K(t);return{TAG:"Error",_0:yo(r)}}}function x1(e,t){let r=He(t,o=>o.trim());if(r!==void 0&&r!=="")return{TAG:"Ok",_0:r};let n=k1(e);if(n.TAG!=="Ok")return{TAG:"Error",_0:n._0};let i=n._0.hostname.trim();return w1(i)&&i!=="localhost"?{TAG:"Ok",_0:i}:{TAG:"Ok",_0:"127.0.0.1"}}function S1(e,t,r,n,i,o,s){return Me(Kt("/api/v2/local-codex-runner/oauth/authorize",e),a=>{let u=a.searchParams;return u.set("redirect_uri",t),u.set("state",r),n!==void 0&&u.set("workspace",n),i!==void 0&&u.set("channel",i),o!==void 0&&u.set("onboarding",o),s!==void 0&&u.set("purpose","persisted_documents_publish"),a.toString()})}async function T1(e,t,r){let n=Kt("/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 s=await hi(n._0.toString(),{method:"POST",headers:o,body:JSON.stringify(i)});if(s.TAG!=="Ok")return{TAG:"Error",_0:A(s._0.message)};let a=s._0,u=a.status,c=await gi(a);if(c.TAG!=="Ok")return{TAG:"Error",_0:A(c._0.message)};let l=c._0;if(u>=200&&u<300){if(Array.isArray(l))return{TAG:"Error",_0:A("local runner OAuth token response did not include access_token")};if(l!==null)switch(typeof l){case"object":let f=Lr(l,"access_token");if(f===void 0)return{TAG:"Error",_0:A("local runner OAuth token response did not include access_token")};let h=l.expires_in,m;m=typeof h=="number"?h:void 0;let g=Lr(l,"workspace"),y=Lr(l,"channel");return{TAG:"Ok",_0:{accessToken:f,expiresInSeconds:m,workspaceSlug:g,channelSlug:y}}}}let p=_c(l);return p!==void 0?p==="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: "+p)}:{TAG:"Error",_0:A("local runner OAuth token exchange failed")}}function ud(e){return e.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;")}var $1='<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 E1(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>
112
112
  <html lang="en">
113
113
  <head>
114
114
  <meta charset="utf-8" />
@@ -206,26 +206,26 @@ Auth:
206
206
  <div class="`+r+'">'+n+`</div>
207
207
  <h1>`+ud(e.title)+`</h1>
208
208
  <p>`+ud(e.body)+`</p>
209
- <div class="logo">`+T1+`</div>
209
+ <div class="logo">`+$1+`</div>
210
210
  </main>
211
211
  </body>
212
- </html>`}function xs(e,t){let r={};r["content-type"]="text/html; charset=utf-8",e.writeHead(t.status,r),e.end($1(t))}var E1=new RegExp('[&^|<>()%"]',"g");function z1(e,t){switch(e){case"darwin":return["open",[t]];case"win32":return["cmd",["/c","start","",t.replace(E1,"^$&")]];default:return["xdg-open",[t]]}}function yy(e,t,r){let n=z1(t,r),i=n[1],o=n[0];return new Promise((s,a)=>{let u=(l,d)=>{let p={};return p.command=o,p.args=i.map(f=>f),l!==void 0&&(p.pid=l),d!==void 0&&(p.message=d),p.purpose="oauth.open_browser",p};e("process.spawn",u(void 0,void 0));let c=gy.spawn(o,i,{stdio:["ignore","ignore","ignore"],detached:!0});e("process.spawned",u(Nr(c.pid),void 0)),c.on("error",l=>{e("process.spawn_failed",u(Nr(c.pid),l.message)),s()}),c.on("spawn",()=>{c.unref(),s()})})}function A1(e,t,r){return new Promise((n,i)=>{let o={contents:void 0},s=new Promise((p,f)=>{o.contents=p}),a={contents:!1},u=p=>{if(a.contents)return!1;a.contents=!0;let f=o.contents;return f!==void 0&&f(p),!0},c={contents:"http://"+e+"/callback"},l=async(p,f)=>{let h=rt(Nr(p.url),"/"),m=Kt(h,"http://"+e);if(m.TAG==="Ok"){let g=m._0.searchParams,y=g.get("code"),v=g.get("state"),b=g.get("error"),w=0;if(b==null)w=1;else{if(b.trim()!=="")return u({TAG:"Error",_0:A("local runner OAuth failed: "+b)}),xs(f,{title:"Not authorized",body:"You denied the request. Close this tab and rerun the bootstrap command when you're ready.",status:403});w=1}if(w===1){let S=0;if(y==null||v==null)S=2;else{if(y.trim()!==""&&v.trim()!==""){let R=await r({code:y,state:v,redirectUri:c.contents});if(R.TAG==="Ok"){let X=u({TAG:"Ok",_0:R._0});return xs(f,{title:X?"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 u({TAG:"Error",_0:R._0}),xs(f,{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})}S=2}if(S===2)return xs(f,{title:"Authorization callback was incomplete",body:"We didn't receive the authorization code. Return to your terminal and try again.",status:400})}}else return u({TAG:"Error",_0:A(m._0)}),xs(f,{title:"Authorization callback failed",body:"Return to your terminal and rerun the bootstrap command.",status:500})},d=py.createServer((p,f)=>{l(p,f)});d.once("error",p=>n({TAG:"Error",_0:A(p.message)})),d.listen(0,e,()=>{let p=d.address(),f;if(p==null||typeof p!="object"||p===null||Array.isArray(p))f=void 0;else{let m=p.port;f=typeof m=="number"?m:void 0}if(f===void 0)return n({TAG:"Error",_0:A("local runner OAuth callback server did not bind to a TCP port")});c.contents="http://"+e+":"+f.toString()+"/callback";let h;if(p==null||typeof p!="object"||p===null||Array.isArray(p))h="";else{let m=p.address;h=typeof m=="string"?m:""}n({TAG:"Ok",_0:{redirectUri:c.contents,boundAddress:h,waitForToken:m=>{let g=_y(m,t),y=setTimeout(()=>{u({TAG:"Error",_0:A("Authorization timed out before the browser callback completed. Rerun the connect command and finish authorizing in the browser.")}),d.close()},g);return y.unref(),s.then(v=>{clearTimeout(y)}),s},close:()=>{d.close()}}})})})}async function vy(e,t,r,n,i,o,s,a,u,c){let l=ye(pt(e),A);if(l.TAG!=="Ok")return{TAG:"Error",_0:l._0};let d=l._0,p=ye(k1(e,o),A);if(p.TAG!=="Ok")return{TAG:"Error",_0:p._0};let f=hy.randomBytes(18).toString("base64url"),h=await A1(p._0,s,y=>y.state===f?S1(d,y.code,y.redirectUri):Promise.resolve({TAG:"Error",_0:A("local runner OAuth state mismatch")}));if(h.TAG!=="Ok")return{TAG:"Error",_0:h._0};let m=h._0,g=ye(x1(d,m.redirectUri,f,t,r,n,i),A);if(g.TAG==="Ok"){let y=g._0;a(`Authorize the local Codex runner:
212
+ </html>`}function xs(e,t){let r={};r["content-type"]="text/html; charset=utf-8",e.writeHead(t.status,r),e.end(E1(t))}var z1=new RegExp('[&^|<>()%"]',"g");function A1(e){let t=En(e);if(t===void 0)return e;let r=he(t),n=r.searchParams;return a_(n).includes("state")?(n.set("state","<SENSITIVE_DATA>"),r.toString()):e}function O1(e,t){switch(e){case"darwin":return["open",[t]];case"win32":return["cmd",["/c","start","",t.replace(z1,"^$&")]];default:return["xdg-open",[t]]}}function vy(e,t,r){let n=O1(t,r),i=n[1],o=n[0];return new Promise((s,a)=>{let u=(l,d)=>{let p={};return p.command=o,p.args=i.map(f=>A1(f)),l!==void 0&&(p.pid=l),d!==void 0&&(p.message=d),p.purpose="oauth.open_browser",p};e("process.spawn",u(void 0,void 0));let c=_y.spawn(o,i,{stdio:["ignore","ignore","ignore"],detached:!0});e("process.spawned",u(Nr(c.pid),void 0)),c.on("error",l=>{e("process.spawn_failed",u(Nr(c.pid),l.message)),s()}),c.on("spawn",()=>{c.unref(),s()})})}function P1(e,t,r){return new Promise((n,i)=>{let o={contents:void 0},s=new Promise((p,f)=>{o.contents=p}),a={contents:!1},u=p=>{if(a.contents)return!1;a.contents=!0;let f=o.contents;return f!==void 0&&f(p),!0},c={contents:"http://"+e+"/callback"},l=async(p,f)=>{let h=rt(Nr(p.url),"/"),m=Kt(h,"http://"+e);if(m.TAG==="Ok"){let g=m._0.searchParams,y=g.get("code"),v=g.get("state"),b=g.get("error"),w=0;if(b==null)w=1;else{if(b.trim()!=="")return u({TAG:"Error",_0:A("local runner OAuth failed: "+b)}),xs(f,{title:"Not authorized",body:"You denied the request. Close this tab and rerun the bootstrap command when you're ready.",status:403});w=1}if(w===1){let S=0;if(y==null||v==null)S=2;else{if(y.trim()!==""&&v.trim()!==""){let R=await r({code:y,state:v,redirectUri:c.contents});if(R.TAG==="Ok"){let X=u({TAG:"Ok",_0:R._0});return xs(f,{title:X?"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 u({TAG:"Error",_0:R._0}),xs(f,{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})}S=2}if(S===2)return xs(f,{title:"Authorization callback was incomplete",body:"We didn't receive the authorization code. Return to your terminal and try again.",status:400})}}else return u({TAG:"Error",_0:A(m._0)}),xs(f,{title:"Authorization callback failed",body:"Return to your terminal and rerun the bootstrap command.",status:500})},d=hy.createServer((p,f)=>{l(p,f)});d.once("error",p=>n({TAG:"Error",_0:A(p.message)})),d.listen(0,e,()=>{let p=d.address(),f;if(p==null||typeof p!="object"||p===null||Array.isArray(p))f=void 0;else{let m=p.port;f=typeof m=="number"?m:void 0}if(f===void 0)return n({TAG:"Error",_0:A("local runner OAuth callback server did not bind to a TCP port")});c.contents="http://"+e+":"+f.toString()+"/callback";let h;if(p==null||typeof p!="object"||p===null||Array.isArray(p))h="";else{let m=p.address;h=typeof m=="string"?m:""}n({TAG:"Ok",_0:{redirectUri:c.contents,boundAddress:h,waitForToken:m=>{let g=yy(m,t),y=setTimeout(()=>{u({TAG:"Error",_0:A("Authorization timed out before the browser callback completed. Rerun the connect command and finish authorizing in the browser.")}),d.close()},g);return y.unref(),s.then(v=>{clearTimeout(y)}),s},close:()=>{d.close()}}})})})}async function by(e,t,r,n,i,o,s,a,u,c){let l=ve(pt(e),A);if(l.TAG!=="Ok")return{TAG:"Error",_0:l._0};let d=l._0,p=ve(x1(e,o),A);if(p.TAG!=="Ok")return{TAG:"Error",_0:p._0};let f=gy.randomBytes(18).toString("base64url"),h=await P1(p._0,s,y=>y.state===f?T1(d,y.code,y.redirectUri):Promise.resolve({TAG:"Error",_0:A("local runner OAuth state mismatch")}));if(h.TAG!=="Ok")return{TAG:"Error",_0:h._0};let m=h._0,g=ve(S1(d,m.redirectUri,f,t,r,n,i),A);if(g.TAG==="Ok"){let y=g._0;a(`Authorize the local Codex runner:
213
213
  `+y+`
214
- `);let v;try{await u(y),v=await m.waitForToken(_y(c,s))}catch(b){let w=K(b);v={TAG:"Error",_0:A(yo(w))}}return m.close(),v}return m.close(),{TAG:"Error",_0:g._0}}import*as bc from"node:fs";import*as pd from"node:os";import*as St from"node:path";import*as hd from"node:crypto";var P1=new RegExp("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$","i"),C1=new RegExp("^[a-zA-Z0-9_.-]+$");function dd(e){return P1.test(e)}function vc(e){return C1.test(e)}var R1=cn(Rn,e=>e.trim()!=="","allowedCwds entries must be non-empty strings",void 0);function ky(e){return{version:1,machineId:e.f("machineId",ws(cn(Rn,dd,"invalid machine id",void 0))),runnerId:e.f("runnerId",ws(cn(Rn,vc,"invalid runner id",void 0))),allowedCwds:e.f("allowedCwds",W_(R1))}}var I1=hc(ky),j1=hc(e=>(e.tag("version",1),ky(e)));function fd(e){let t=new Set;return Qt(e,r=>{let n=r.trim();if(!(n===""||t.has(n)))return t.add(n),n})}function xy(e){return{version:e.version,machineId:e.machineId,runnerId:e.runnerId,allowedCwds:fd(e.allowedCwds)}}function md(e){return Me(ed(e,j1),xy)}function Sy(e){return Me(ed(e,I1),xy)}var yc=ws(cn(Rn,e=>e.trim()!=="","must be a non-empty string",void 0)),by=ws(cn(V_,e=>sd(e)?e>0:!1,"must be a positive integer",void 0));function N1(e){return!Number.isNaN(new Date(e).getTime())}var wy=cn(Rn,N1,"must be a parseable date",void 0),h3=hc(e=>({email:e.f("email",cn(Rn,t=>t.trim()!=="","must be a non-empty string",void 0)),serviceUrl:e.f("service_url",cn(Rn,t=>t.trim()!=="","must be a non-empty string",void 0)),accessToken:e.f("access_token",yc),refreshToken:e.f("refresh_token",yc),expiresInSeconds:e.f("expires_in_seconds",by),userId:e.f("user_id",by),workspaceSlug:e.f("workspace_slug",yc),launchUrl:e.f("launch_url",yc),createdAt:e.f("created_at",wy),updatedAt:e.f("updated_at",wy)}));var Ur="prod";function Ty(e){let t=e!==void 0?e:process.env,r=cs(t,"HOME");return r!==void 0&&r.trim()!==""?r:pd.homedir()}function D1(e,t){let r=e!==void 0?e:process.env;return t==="~"?Ty(r):t.startsWith("~/")?St.resolve(Ty(r),t.slice(2)):t}function zy(e){let t=cs(e,"LINZUMI_CONFIG_FILE");return t!==void 0&&t.trim()!==""?St.resolve(D1(e,t)):St.resolve(pd.homedir(),".linzumi","config.json")}function Ss(e){let t=pt(e),r=pt(K_);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?Ur:n}:{TAG:"Error",_0:A(r._0)}}function G1(e){return Me(Ss(e),t=>t===Ur?Ur:Buffer.from(t).toString("base64url"))}function Z1(e,t,r){let n=St.dirname(e),i=St.basename(e);return t!==void 0?Y(Ss(t),o=>o===Ur?{TAG:"Ok",_0:St.join(n,i+"."+r)}:Me(G1(t),s=>St.join(n,i+"."+s+"."+r))):{TAG:"Ok",_0:St.join(n,i+"."+r)}}function Ay(e){if(bc.existsSync(e))return Y(ye(kr(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)?md(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 F1(){let e={};return e.allowedCwds=[],e}function $y(e,t){return Y(Ay(e),r=>{let n=t!==void 0?Ss(t):{TAG:"Ok",_0:Ur};return Y(n,i=>{let o=i===Ur?r:rt(r[i],F1()),s=i===Ur?md(o):Sy(o);return ye(s,a=>A("invalid Linzumi config section "+i+": "+e))})})}function q1(e,t){let r=i=>A(i.message),n=bc.existsSync(e)?ye(Ba(e,384),r):{TAG:"Ok",_0:void 0};return Y(Y(n,()=>ye(as(e,JSON.stringify(t,void 0,2)+`
215
- `,{encoding:"utf8",mode:384}),r)),()=>ye(Ba(e,384),r))}function L1(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=fd(e.allowedCwds).map(i=>i),t}function U1(e){let t=e.version===1,r=e.machineId,n=r!==void 0?dd(r):!0,i=e.runnerId,o=i!==void 0?vc(i):!0,s=e.allowedCwds.every(a=>a.trim()!=="");return t&&n&&o&&s?{TAG:"Ok",_0:void 0}:{TAG:"Error",_0:A("invalid Linzumi config")}}function V1(e,t,r){return Y(U1(e),()=>{let n=r!==void 0?Ss(r):{TAG:"Ok",_0:Ur};return Y(n,i=>Y(Ay(t),o=>{let s=Object.fromEntries(Object.entries(o)),a=L1(e);return i===Ur?(Object.entries(a).forEach(u=>{s[u[0]]=u[1]}),s.version=1):(s.version=1,s[i]=a),Y(ye(xr(St.dirname(t)),u=>A(u.message)),()=>q1(t,s))}))})}function Ey(e,t,r){return Y(ye(kr(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 B1(e,t,r,n){if(bc.existsSync(e))return Ey(e,r,n);let i=t();if(!r(i))return{TAG:"Error",_0:A("invalid generated Linzumi "+n+": "+i)};let o=St.dirname(e),s=St.basename(e),a=St.join(o,"."+s+"."+process.pid.toString()+"."+hd.randomUUID()+".tmp"),u=c=>A(c.message);return Y(Y(ye(xr(o),u),()=>ye(as(a,i+`
216
- `,{encoding:"utf8",flag:"wx"}),u)),()=>{let c=r_(a,e),l;if(c.TAG==="Ok")l={TAG:"Ok",_0:i};else{let d=c._0;l=e_(d,"EEXIST")?Ey(e,r,n):{TAG:"Error",_0:A(d.message)}}return n_(a),l})}function W1(){return"runner-"+hd.randomUUID()}function J1(e,t,r,n,i,o,s,a){let u=t!==void 0?Me(Ss(t),c=>{if(c!==Ur)return t}):{TAG:"Ok",_0:void 0};return Y(u,c=>Y($y(e,c),l=>{let d=s(l);return d!==void 0?{TAG:"Ok",_0:d}:Y(Z1(e,c,r),p=>Y(B1(p,n,i,o),f=>Y($y(e,c),h=>{let m=s(h);return m!==void 0?{TAG:"Ok",_0:m}:Me(V1(a(h,f),e,c),()=>f)})))}))}function Oy(e,t,r){return J1(e,t,"runner-id",r!==void 0?r:W1,vc,"runner id",i=>i.runnerId,(i,o)=>({version:i.version,machineId:i.machineId,runnerId:o,allowedCwds:i.allowedCwds}))}var K1=3600*1e3;function Q1(e,t,r,n){return e<=3?"DecidePrompt":r!==void 0&&t-r<K1?n?"DecideRefreshLine":"DecideSilent":"DecideSummary"}function Py(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 X1(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).
214
+ `);let v;try{await u(y),v=await m.waitForToken(yy(c,s))}catch(b){let w=K(b);v={TAG:"Error",_0:A(yo(w))}}return m.close(),v}return m.close(),{TAG:"Error",_0:g._0}}import*as bc from"node:fs";import*as pd from"node:os";import*as St from"node:path";import*as hd from"node:crypto";var R1=new RegExp("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$","i"),I1=new RegExp("^[a-zA-Z0-9_.-]+$");function dd(e){return R1.test(e)}function vc(e){return I1.test(e)}var j1=cn(In,e=>e.trim()!=="","allowedCwds entries must be non-empty strings",void 0);function xy(e){return{version:1,machineId:e.f("machineId",ws(cn(In,dd,"invalid machine id",void 0))),runnerId:e.f("runnerId",ws(cn(In,vc,"invalid runner id",void 0))),allowedCwds:e.f("allowedCwds",J_(j1))}}var N1=hc(xy),M1=hc(e=>(e.tag("version",1),xy(e)));function fd(e){let t=new Set;return Qt(e,r=>{let n=r.trim();if(!(n===""||t.has(n)))return t.add(n),n})}function Sy(e){return{version:e.version,machineId:e.machineId,runnerId:e.runnerId,allowedCwds:fd(e.allowedCwds)}}function md(e){return Me(ed(e,M1),Sy)}function Ty(e){return Me(ed(e,N1),Sy)}var yc=ws(cn(In,e=>e.trim()!=="","must be a non-empty string",void 0)),wy=ws(cn(B_,e=>sd(e)?e>0:!1,"must be a positive integer",void 0));function D1(e){return!Number.isNaN(new Date(e).getTime())}var ky=cn(In,D1,"must be a parseable date",void 0),_3=hc(e=>({email:e.f("email",cn(In,t=>t.trim()!=="","must be a non-empty string",void 0)),serviceUrl:e.f("service_url",cn(In,t=>t.trim()!=="","must be a non-empty string",void 0)),accessToken:e.f("access_token",yc),refreshToken:e.f("refresh_token",yc),expiresInSeconds:e.f("expires_in_seconds",wy),userId:e.f("user_id",wy),workspaceSlug:e.f("workspace_slug",yc),launchUrl:e.f("launch_url",yc),createdAt:e.f("created_at",ky),updatedAt:e.f("updated_at",ky)}));var Ur="prod";function $y(e){let t=e!==void 0?e:process.env,r=cs(t,"HOME");return r!==void 0&&r.trim()!==""?r:pd.homedir()}function Z1(e,t){let r=e!==void 0?e:process.env;return t==="~"?$y(r):t.startsWith("~/")?St.resolve($y(r),t.slice(2)):t}function Ay(e){let t=cs(e,"LINZUMI_CONFIG_FILE");return t!==void 0&&t.trim()!==""?St.resolve(Z1(e,t)):St.resolve(pd.homedir(),".linzumi","config.json")}function Ss(e){let t=pt(e),r=pt(Q_);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?Ur:n}:{TAG:"Error",_0:A(r._0)}}function F1(e){return Me(Ss(e),t=>t===Ur?Ur:Buffer.from(t).toString("base64url"))}function q1(e,t,r){let n=St.dirname(e),i=St.basename(e);return t!==void 0?Y(Ss(t),o=>o===Ur?{TAG:"Ok",_0:St.join(n,i+"."+r)}:Me(F1(t),s=>St.join(n,i+"."+s+"."+r))):{TAG:"Ok",_0:St.join(n,i+"."+r)}}function Oy(e){if(bc.existsSync(e))return Y(ve(kr(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)?md(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 L1(){let e={};return e.allowedCwds=[],e}function Ey(e,t){return Y(Oy(e),r=>{let n=t!==void 0?Ss(t):{TAG:"Ok",_0:Ur};return Y(n,i=>{let o=i===Ur?r:rt(r[i],L1()),s=i===Ur?md(o):Ty(o);return ve(s,a=>A("invalid Linzumi config section "+i+": "+e))})})}function U1(e,t){let r=i=>A(i.message),n=bc.existsSync(e)?ve(Ba(e,384),r):{TAG:"Ok",_0:void 0};return Y(Y(n,()=>ve(as(e,JSON.stringify(t,void 0,2)+`
215
+ `,{encoding:"utf8",mode:384}),r)),()=>ve(Ba(e,384),r))}function V1(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=fd(e.allowedCwds).map(i=>i),t}function B1(e){let t=e.version===1,r=e.machineId,n=r!==void 0?dd(r):!0,i=e.runnerId,o=i!==void 0?vc(i):!0,s=e.allowedCwds.every(a=>a.trim()!=="");return t&&n&&o&&s?{TAG:"Ok",_0:void 0}:{TAG:"Error",_0:A("invalid Linzumi config")}}function W1(e,t,r){return Y(B1(e),()=>{let n=r!==void 0?Ss(r):{TAG:"Ok",_0:Ur};return Y(n,i=>Y(Oy(t),o=>{let s=Object.fromEntries(Object.entries(o)),a=V1(e);return i===Ur?(Object.entries(a).forEach(u=>{s[u[0]]=u[1]}),s.version=1):(s.version=1,s[i]=a),Y(ve(xr(St.dirname(t)),u=>A(u.message)),()=>U1(t,s))}))})}function zy(e,t,r){return Y(ve(kr(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 J1(e,t,r,n){if(bc.existsSync(e))return zy(e,r,n);let i=t();if(!r(i))return{TAG:"Error",_0:A("invalid generated Linzumi "+n+": "+i)};let o=St.dirname(e),s=St.basename(e),a=St.join(o,"."+s+"."+process.pid.toString()+"."+hd.randomUUID()+".tmp"),u=c=>A(c.message);return Y(Y(ve(xr(o),u),()=>ve(as(a,i+`
216
+ `,{encoding:"utf8",flag:"wx"}),u)),()=>{let c=r_(a,e),l;if(c.TAG==="Ok")l={TAG:"Ok",_0:i};else{let d=c._0;l=e_(d,"EEXIST")?zy(e,r,n):{TAG:"Error",_0:A(d.message)}}return n_(a),l})}function H1(){return"runner-"+hd.randomUUID()}function K1(e,t,r,n,i,o,s,a){let u=t!==void 0?Me(Ss(t),c=>{if(c!==Ur)return t}):{TAG:"Ok",_0:void 0};return Y(u,c=>Y(Ey(e,c),l=>{let d=s(l);return d!==void 0?{TAG:"Ok",_0:d}:Y(q1(e,c,r),p=>Y(J1(p,n,i,o),f=>Y(Ey(e,c),h=>{let m=s(h);return m!==void 0?{TAG:"Ok",_0:m}:Me(W1(a(h,f),e,c),()=>f)})))}))}function Py(e,t,r){return K1(e,t,"runner-id",r!==void 0?r:H1,vc,"runner id",i=>i.runnerId,(i,o)=>({version:i.version,machineId:i.machineId,runnerId:o,allowedCwds:i.allowedCwds}))}var X1=3600*1e3;function Y1(e,t,r,n){return e<=3?"DecidePrompt":r!==void 0&&t-r<X1?n?"DecideRefreshLine":"DecideSilent":"DecideSummary"}function Cy(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 e$(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).
217
217
  `)+`Authorize this computer:
218
218
  Code: `+e.userCode+`
219
219
  Open: `+e.verificationUri+`
220
- `;case"Summary":return"Still waiting for authorization after "+Py(e.waitedMs)+" "+("("+e.cycle.toString()+` codes issued so far).
220
+ `;case"Summary":return"Still waiting for authorization after "+Cy(e.waitedMs)+" "+("("+e.cycle.toString()+` codes issued so far).
221
221
  `)+(`Authorize this computer:
222
222
  Code: `+e.userCode+`
223
223
  Open: `+e.verificationUri+`
224
- `);case"RefreshLine":return"\r\x1B[2KCode: "+e.userCode+" (waiting "+Py(e.waitedMs)+") - open "+e.verificationUri;case"TransientFailure":return"Device authorization poll hit a transient failure ("+e.reason+`); retrying with the same code.
224
+ `);case"RefreshLine":return"\r\x1B[2KCode: "+e.userCode+" (waiting "+Cy(e.waitedMs)+") - open "+e.verificationUri;case"TransientFailure":return"Device authorization poll hit a transient failure ("+e.reason+`); retrying with the same code.
225
225
  `;case"StartFailed":return"Could not mint a device authorization code ("+e.reason+"); retrying in "+Math.round(e.retryInMs/1e3).toString()+`s.
226
- `}}function Y1(e){return new Promise((t,r)=>{setTimeout(()=>t(),e|0)})}function e$(e){return{startDeviceAuthorization:t=>dy(t.httpBaseUrl,t.workspaceSlug,t.channelSlug,t.onboarding,t.identity),pollDeviceCodeForToken:t=>fy(t.httpBaseUrl,t.deviceCode,t.expiresInSeconds,void 0),now:()=>Date.now(),sleep:Y1,report:e,log:(t,r)=>{}}}var t$="local runner device authorization was denied - a signed-in user rejected this computer";async function Cy(e,t,r,n,i,o,s,a){let u=o!==void 0?o:y=>{$n(y)},c=a!==void 0?a:e$(y=>u(X1(y))),l=s!==void 0?s:Pt(Nr(process.stderr.isTTY),!0),d=ye(pt(e),A);if(d.TAG!=="Ok")return{TAG:"Error",_0:d._0};let p=d._0,f=c.now(),h={cycle:0,lastLoudPromptAtMs:void 0,startFailures:0},m=async y=>{let v=await c.pollDeviceCodeForToken({httpBaseUrl:p,deviceCode:y.deviceCode,expiresInSeconds:y.expiresInSeconds});if(typeof v!="object"||v.TAG!=="Transient")return v;let b=v.httpStatus,w=v.reason;c.report({TAG:"TransientFailure",reason:w,waitedMs:c.now()-f});let S={};return S.cycle=h.cycle,S.reason=w,S.httpStatus=b!==void 0?b:null,c.log("device_wait.transient_poll_failure",S),await c.sleep(5e3),await m(y)},g=async()=>{let y=await c.startDeviceAuthorization({httpBaseUrl:p,workspaceSlug:t,channelSlug:r,onboarding:n,identity:i});if(y.TAG==="Ok"){let v=y._0;h.startFailures=0,h.cycle=h.cycle+1|0;let b=Q1(h.cycle,c.now(),h.lastLoudPromptAtMs,l),w=0;switch(b){case"DecidePrompt":case"DecideSummary":w=1;break;case"DecideRefreshLine":c.report({TAG:"RefreshLine",cycle:h.cycle,userCode:v.userCode,verificationUri:v.verificationUri,waitedMs:c.now()-f});break;case"DecideSilent":break}if(w===1){h.lastLoudPromptAtMs=c.now();let X=c.now()-f,be;be=b==="DecidePrompt"?{TAG:"Prompt",cycle:h.cycle,userCode:v.userCode,verificationUri:v.verificationUri,waitedMs:X}:{TAG:"Summary",cycle:h.cycle,userCode:v.userCode,verificationUri:v.verificationUri,waitedMs:X},c.report(be)}let S={};S.cycle=h.cycle,S.verificationUri=v.verificationUri,c.log("device_wait.code_issued",S);let R=await m(v);if(typeof R!="object")switch(R){case"CodeExpired":let X={};return X.cycle=h.cycle,X.outcome="code_expired",c.log("device_wait.code_retired",X),await g();case"Denied":return{TAG:"Error",_0:A(t$)};case"Consumed":let be={};return be.cycle=h.cycle,be.outcome="consumed",c.log("device_wait.code_retired",be),await g()}else switch(R.TAG){case"Token":let X={};return X.cycle=h.cycle,X.waitedMs=c.now()-f,c.log("device_wait.authorized",X),{TAG:"Ok",_0:R._0};case"Rejected":let be=R.httpStatus,D=R.reason;c.report({TAG:"TransientFailure",reason:uy(D,be),waitedMs:c.now()-f});let I={};return I.cycle=h.cycle,I.reason=D!==void 0?D:null,I.httpStatus=be,c.log("device_wait.code_rejected",I),await g();case"Transient":return await g()}}else{let v=y._0;h.startFailures=h.startFailures+1|0;let b=Math.min(6e4,5e3*Math.pow(2,h.startFailures-1|0));c.report({TAG:"StartFailed",reason:v.summary,retryInMs:b});let w={};return w.reason=v.summary,w.retryInMs=b,w.attempt=h.startFailures,c.log("device_wait.start_failed",w),await c.sleep(b),await g()}};return await g()}var n$="linzumi-machine-fingerprint:v1:";var Ry={platform:void 0,execFile:void 0,readFile:void 0,username:void 0};function i$(e,t){return s_(e,t,5e3,1024*1024)}var o$=new RegExp('"IOPlatformUUID"\\s*=\\s*"([0-9A-Fa-f-]{36})"'),s$=new RegExp("^[0-9a-f]{32}$"),a$=["/etc/machine-id","/var/lib/dbus/machine-id"];function c$(e){let t=e!==void 0?e:Ry,r=rt(t.platform,process.platform),n=rt(t.execFile,i$),i=rt(t.readFile,kr);switch(r){case"darwin":let o=n("ioreg",["-rd1","-c","IOPlatformExpertDevice"]);if(o.TAG!=="Ok")return;let s=o$.exec(o._0);if(s==null)return;let a=s.slice(1)[0];if(a===void 0)return;let u=ve(a);return u!==void 0?u.toLowerCase():void 0;case"linux":return m_(a$,void 0,(c,l)=>{if(c!==void 0)return c;let d=i(l);if(d.TAG!=="Ok")return;let p=d._0.trim().toLowerCase();if(s$.test(p))return p});default:return}}function Iy(e){return He(c$(e!==void 0?e:Ry),r=>"mfp-"+Ja(n$+r).slice(0,32))}function u$(e,t){return Y(ye(pt(e),A),r=>{let n=oo(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 "+ve(n).host+". Sign in to the web app to create it, then re-run connect."}})}function My(e){let t=e.authFilePath;return t!==void 0?t:go()}function Dy(e,t){let r=My(e);return Me(td(e.serviceUrl,t.accessToken,t.expiresInSeconds,r,new Date),n=>({accessToken:n.accessToken,expiresAt:n.expiresAt,authFilePath:r}))}function jy(e,t){if(t===void 0)return ld(e);let r=new Date(t).getTime();if(isFinite(r))return{TAG:"Ok",_0:t};let n=ld(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 d$(e){let t=zy(process.env),r=Oy(t,e.serviceUrl,void 0);if(r.TAG!=="Ok")return{TAG:"Error",_0:r._0};let n=r._0,i=Iy(void 0),o=Ny.hostname(),s={commanderId:n,machineFingerprint:i,hostname:o},a=await Cy(e.serviceUrl,e.workspaceSlug,e.channelSlug,e.onboarding,s,void 0,void 0,void 0);return a.TAG==="Ok"?Dy(e,a._0):{TAG:"Error",_0:a._0}}async function f$(e){let t=e.authMode;if(typeof t!="object")return await d$(e);let r=He(t.callbackHost,sy),n=await vy(e.serviceUrl,e.workspaceSlug,e.channelSlug,e.onboarding,void 0,r,process.env,i=>{$n(i)},i=>yy((o,s)=>{if(o!=="process.spawn_failed"||typeof s!="object"||s===null||Array.isArray(s))return;let a=Ke(s.command,od),u=Ke(s.message,od);if(a!==void 0&&u!==void 0){$n("linzumi (rescript commander): could not open the authorization URL with "+a+" ("+u+`); open the URL above manually
227
- `);return}},process.platform,i),void 0);return n.TAG==="Ok"?Dy(e,n._0):{TAG:"Error",_0:n._0}}function m$(){return{readCachedToken:(e,t)=>_o(e,t,Date.now()),validateToken:(e,t,r,n,i)=>vo(e,t,r,n,i),acquireAndCacheAuth:f$}}async function p$(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 Y(u$(e.serviceUrl,e.workspaceSlug),i=>({TAG:"Error",_0:A(i)}))}}async function h$(e,t){let r=t!==void 0?t:m$(),n=He(e.explicitToken,g=>g.trim()),i=n!==void 0&&n!==""?n:void 0;if(i!==void 0)return{TAG:"Ok",_0:{TAG:"ExplicitAuth",accessToken:i}};let o=My(e),s=r.readCachedToken(e.serviceUrl,o);if(s.TAG!=="Ok")return{TAG:"Error",_0:s._0};let a=s._0,u;if(a!==void 0){let g=await r.validateToken(e.serviceUrl,a.accessToken,e.workspaceSlug,e.channelSlug,e.requiredScopes);if(g.TAG==="Ok")switch(g._0){case"Usable":u={TAG:"Ok",_0:a};break;case"Rejected":let y=e.reportRejectedCachedToken;y!==void 0&&y("UnusableRejected"),u={TAG:"Ok",_0:void 0};break;case"NotFound":let v=e.reportRejectedCachedToken;v!==void 0&&v("UnusableNotFound"),u={TAG:"Ok",_0:void 0};break}else u={TAG:"Error",_0:g._0}}else u={TAG:"Ok",_0:void 0};if(u.TAG!=="Ok")return{TAG:"Error",_0:u._0};let c=u._0;if(c!==void 0)return Me(jy(c.accessToken,c.expiresAt),g=>({TAG:"CachedAuth",_0:{accessToken:c.accessToken,expiresAt:g,authFilePath:o}}));let l=await r.acquireAndCacheAuth(e);if(l.TAG!=="Ok")return{TAG:"Error",_0:l._0};let d=l._0,p=jy(d.accessToken,d.expiresAt);if(p.TAG!=="Ok")return{TAG:"Error",_0:p._0};let f=p._0;if(e.workspaceSlug===void 0)return{TAG:"Ok",_0:{TAG:"AcquiredAuth",accessToken:d.accessToken,expiresAt:f,authFilePath:d.authFilePath,mode:e.authMode}};let m=await p$(e,r,d.accessToken);return m.TAG==="Ok"?{TAG:"Ok",_0:{TAG:"AcquiredAuth",accessToken:d.accessToken,expiresAt:f,authFilePath:d.authFilePath,mode:e.authMode}}:{TAG:"Error",_0:m._0}}function g$(e){switch(e.TAG){case"CachedAuth":return e._0.accessToken;case"ExplicitAuth":case"AcquiredAuth":return e.accessToken}}async function Gy(e,t){return Me(await h$(e,t),g$)}function y$(){return{readCachedToken:(e,t)=>_o(e,t,Date.now()),validateTokenOutcome:(e,t,r,n)=>vo(e,t,r,n,void 0),resolveToken:e=>Gy(e,void 0)}}var gd="missing Linzumi MCP token; run linzumi auth or pass --token";function v$(e){return"Linzumi MCP token was rejected by the server and re-mint failed: "+e}async function Zy(e,t,r,n,i,o){let s=o!==void 0?o:y$(),a=r!==void 0?r:go(),u=t!==void 0?{TAG:"Ok",_0:t}:Me(s.readCachedToken(e,a),p=>He(p,f=>f.accessToken));if(u.TAG!=="Ok")return{TAG:"Error",_0:u._0};let c=u._0;if(c===void 0)return{TAG:"Error",_0:A(gd)};let l=await s.validateTokenOutcome(e,c,n,i);if(l.TAG!=="Ok")return{TAG:"Error",_0:l._0};switch(l._0){case"Usable":return{TAG:"Ok",_0:c};case"Rejected":case"NotFound":break}let d=await s.resolveToken({serviceUrl:e,explicitToken:void 0,workspaceSlug:n,channelSlug:i,requiredScopes:[],onboarding:void 0,authFilePath:r,authMode:{TAG:"BrowserMode",callbackHost:void 0},reportRejectedCachedToken:void 0});return d.TAG==="Ok"?{TAG:"Ok",_0:d._0}:{TAG:"Error",_0:A(v$(d._0.summary))}}var _={};mu(_,{BRAND:()=>B$,DIRTY:()=>gi,EMPTY_PATH:()=>S$,INVALID:()=>W,NEVER:()=>AE,OK:()=>Tt,ParseStatus:()=>ht,Schema:()=>ne,ZodAny:()=>Mn,ZodArray:()=>fn,ZodBigInt:()=>yi,ZodBoolean:()=>vi,ZodBranded:()=>$s,ZodCatch:()=>Oi,ZodDate:()=>bi,ZodDefault:()=>Ai,ZodDiscriminatedUnion:()=>xc,ZodEffects:()=>ur,ZodEnum:()=>Ei,ZodError:()=>Ft,ZodFirstPartyTypeKind:()=>E,ZodFunction:()=>Tc,ZodIntersection:()=>Si,ZodIssueCode:()=>T,ZodLazy:()=>Ti,ZodLiteral:()=>$i,ZodMap:()=>To,ZodNaN:()=>Eo,ZodNativeEnum:()=>zi,ZodNever:()=>Tr,ZodNull:()=>ki,ZodNullable:()=>Wr,ZodNumber:()=>_i,ZodObject:()=>Lt,ZodOptional:()=>qt,ZodParsedType:()=>P,ZodPipeline:()=>Es,ZodPromise:()=>Dn,ZodReadonly:()=>Pi,ZodRecord:()=>Sc,ZodSchema:()=>ne,ZodSet:()=>$o,ZodString:()=>Nn,ZodSymbol:()=>xo,ZodTransformer:()=>ur,ZodTuple:()=>Br,ZodType:()=>ne,ZodUndefined:()=>wi,ZodUnion:()=>xi,ZodUnknown:()=>dn,ZodVoid:()=>So,addIssueToContext:()=>O,any:()=>tE,array:()=>oE,bigint:()=>K$,boolean:()=>Qy,coerce:()=>zE,custom:()=>Jy,date:()=>Q$,datetimeRegex:()=>By,defaultErrorMap:()=>ln,discriminatedUnion:()=>cE,effect:()=>bE,enum:()=>_E,function:()=>pE,getErrorMap:()=>bo,getParsedType:()=>Vr,instanceof:()=>J$,intersection:()=>lE,isAborted:()=>wc,isAsync:()=>wo,isDirty:()=>kc,isValid:()=>jn,late:()=>W$,lazy:()=>hE,literal:()=>gE,makeIssue:()=>Ts,map:()=>fE,nan:()=>H$,nativeEnum:()=>yE,never:()=>nE,null:()=>eE,nullable:()=>kE,number:()=>Ky,object:()=>bd,objectUtil:()=>_d,oboolean:()=>EE,onumber:()=>$E,optional:()=>wE,ostring:()=>TE,pipeline:()=>SE,preprocess:()=>xE,promise:()=>vE,quotelessJson:()=>w$,record:()=>dE,set:()=>mE,setErrorMap:()=>x$,strictObject:()=>sE,string:()=>Hy,symbol:()=>X$,transformer:()=>bE,tuple:()=>uE,undefined:()=>Y$,union:()=>aE,unknown:()=>rE,util:()=>ae,void:()=>iE});var ae;(function(e){e.assertEqual=i=>{};function t(i){}e.assertIs=t;function r(i){throw new Error}e.assertNever=r,e.arrayToEnum=i=>{let o={};for(let s of i)o[s]=s;return o},e.getValidEnumValues=i=>{let o=e.objectKeys(i).filter(a=>typeof i[i[a]]!="number"),s={};for(let a of o)s[a]=i[a];return e.objectValues(s)},e.objectValues=i=>e.objectKeys(i).map(function(o){return i[o]}),e.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{let o=[];for(let s in i)Object.prototype.hasOwnProperty.call(i,s)&&o.push(s);return o},e.find=(i,o)=>{for(let s of i)if(o(s))return s},e.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&Number.isFinite(i)&&Math.floor(i)===i;function n(i,o=" | "){return i.map(s=>typeof s=="string"?`'${s}'`:s).join(o)}e.joinValues=n,e.jsonStringifyReplacer=(i,o)=>typeof o=="bigint"?o.toString():o})(ae||(ae={}));var _d;(function(e){e.mergeShapes=(t,r)=>({...t,...r})})(_d||(_d={}));var P=ae.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Vr=e=>{switch(typeof e){case"undefined":return P.undefined;case"string":return P.string;case"number":return Number.isNaN(e)?P.nan:P.number;case"boolean":return P.boolean;case"function":return P.function;case"bigint":return P.bigint;case"symbol":return P.symbol;case"object":return Array.isArray(e)?P.array:e===null?P.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?P.promise:typeof Map<"u"&&e instanceof Map?P.map:typeof Set<"u"&&e instanceof Set?P.set:typeof Date<"u"&&e instanceof Date?P.date:P.object;default:return P.unknown}};var T=ae.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),w$=e=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:"),Ft=class e extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};let r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=t}format(t){let r=t||function(o){return o.message},n={_errors:[]},i=o=>{for(let s of o.issues)if(s.code==="invalid_union")s.unionErrors.map(i);else if(s.code==="invalid_return_type")i(s.returnTypeError);else if(s.code==="invalid_arguments")i(s.argumentsError);else if(s.path.length===0)n._errors.push(r(s));else{let a=n,u=0;for(;u<s.path.length;){let c=s.path[u];u===s.path.length-1?(a[c]=a[c]||{_errors:[]},a[c]._errors.push(r(s))):a[c]=a[c]||{_errors:[]},a=a[c],u++}}};return i(this),n}static assert(t){if(!(t instanceof e))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,ae.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=r=>r.message){let r={},n=[];for(let i of this.issues)if(i.path.length>0){let o=i.path[0];r[o]=r[o]||[],r[o].push(t(i))}else n.push(t(i));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}};Ft.create=e=>new Ft(e);var k$=(e,t)=>{let r;switch(e.code){case T.invalid_type:e.received===P.undefined?r="Required":r=`Expected ${e.expected}, received ${e.received}`;break;case T.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(e.expected,ae.jsonStringifyReplacer)}`;break;case T.unrecognized_keys:r=`Unrecognized key(s) in object: ${ae.joinValues(e.keys,", ")}`;break;case T.invalid_union:r="Invalid input";break;case T.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${ae.joinValues(e.options)}`;break;case T.invalid_enum_value:r=`Invalid enum value. Expected ${ae.joinValues(e.options)}, received '${e.received}'`;break;case T.invalid_arguments:r="Invalid function arguments";break;case T.invalid_return_type:r="Invalid function return type";break;case T.invalid_date:r="Invalid date";break;case T.invalid_string:typeof e.validation=="object"?"includes"in e.validation?(r=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?r=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?r=`Invalid input: must end with "${e.validation.endsWith}"`:ae.assertNever(e.validation):e.validation!=="regex"?r=`Invalid ${e.validation}`:r="Invalid";break;case T.too_small:e.type==="array"?r=`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:e.type==="string"?r=`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:e.type==="number"?r=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="bigint"?r=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="date"?r=`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:r="Invalid input";break;case T.too_big:e.type==="array"?r=`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:e.type==="string"?r=`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:e.type==="number"?r=`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="bigint"?r=`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="date"?r=`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:r="Invalid input";break;case T.custom:r="Invalid input";break;case T.invalid_intersection_types:r="Intersection results could not be merged";break;case T.not_multiple_of:r=`Number must be a multiple of ${e.multipleOf}`;break;case T.not_finite:r="Number must be finite";break;default:r=t.defaultError,ae.assertNever(e)}return{message:r}},ln=k$;var Fy=ln;function x$(e){Fy=e}function bo(){return Fy}var Ts=e=>{let{data:t,path:r,errorMaps:n,issueData:i}=e,o=[...r,...i.path||[]],s={...i,path:o};if(i.message!==void 0)return{...i,path:o,message:i.message};let a="",u=n.filter(c=>!!c).slice().reverse();for(let c of u)a=c(s,{data:t,defaultError:a}).message;return{...i,path:o,message:a}},S$=[];function O(e,t){let r=bo(),n=Ts({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,r,r===ln?void 0:ln].filter(i=>!!i)});e.common.issues.push(n)}var ht=class e{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,r){let n=[];for(let i of r){if(i.status==="aborted")return W;i.status==="dirty"&&t.dirty(),n.push(i.value)}return{status:t.value,value:n}}static async mergeObjectAsync(t,r){let n=[];for(let i of r){let o=await i.key,s=await i.value;n.push({key:o,value:s})}return e.mergeObjectSync(t,n)}static mergeObjectSync(t,r){let n={};for(let i of r){let{key:o,value:s}=i;if(o.status==="aborted"||s.status==="aborted")return W;o.status==="dirty"&&t.dirty(),s.status==="dirty"&&t.dirty(),o.value!=="__proto__"&&(typeof s.value<"u"||i.alwaysSet)&&(n[o.value]=s.value)}return{status:t.value,value:n}}},W=Object.freeze({status:"aborted"}),gi=e=>({status:"dirty",value:e}),Tt=e=>({status:"valid",value:e}),wc=e=>e.status==="aborted",kc=e=>e.status==="dirty",jn=e=>e.status==="valid",wo=e=>typeof Promise<"u"&&e instanceof Promise;var Z;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t?.message})(Z||(Z={}));var lr=class{constructor(t,r,n,i){this._cachedPath=[],this.parent=t,this.data=r,this._path=n,this._key=i}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},qy=(e,t)=>{if(jn(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let r=new Ft(e.common.issues);return this._error=r,this._error}}};function ee(e){if(!e)return{};let{errorMap:t,invalid_type_error:r,required_error:n,description:i}=e;if(t&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:i}:{errorMap:(s,a)=>{let{message:u}=e;return s.code==="invalid_enum_value"?{message:u??a.defaultError}:typeof a.data>"u"?{message:u??n??a.defaultError}:s.code!=="invalid_type"?{message:a.defaultError}:{message:u??r??a.defaultError}},description:i}}var ne=class{get description(){return this._def.description}_getType(t){return Vr(t.data)}_getOrReturnCtx(t,r){return r||{common:t.parent.common,data:t.data,parsedType:Vr(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new ht,ctx:{common:t.parent.common,data:t.data,parsedType:Vr(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){let r=this._parse(t);if(wo(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(t){let r=this._parse(t);return Promise.resolve(r)}parse(t,r){let n=this.safeParse(t,r);if(n.success)return n.data;throw n.error}safeParse(t,r){let n={common:{issues:[],async:r?.async??!1,contextualErrorMap:r?.errorMap},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Vr(t)},i=this._parseSync({data:t,path:n.path,parent:n});return qy(n,i)}"~validate"(t){let r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Vr(t)};if(!this["~standard"].async)try{let n=this._parseSync({data:t,path:[],parent:r});return jn(n)?{value:n.value}:{issues:r.common.issues}}catch(n){n?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),r.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:r}).then(n=>jn(n)?{value:n.value}:{issues:r.common.issues})}async parseAsync(t,r){let n=await this.safeParseAsync(t,r);if(n.success)return n.data;throw n.error}async safeParseAsync(t,r){let n={common:{issues:[],contextualErrorMap:r?.errorMap,async:!0},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Vr(t)},i=this._parse({data:t,path:n.path,parent:n}),o=await(wo(i)?i:Promise.resolve(i));return qy(n,o)}refine(t,r){let n=i=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(i):r;return this._refinement((i,o)=>{let s=t(i),a=()=>o.addIssue({code:T.custom,...n(i)});return typeof Promise<"u"&&s instanceof Promise?s.then(u=>u?!0:(a(),!1)):s?!0:(a(),!1)})}refinement(t,r){return this._refinement((n,i)=>t(n)?!0:(i.addIssue(typeof r=="function"?r(n,i):r),!1))}_refinement(t){return new ur({schema:this,typeName:E.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}constructor(t){this.spa=this.safeParseAsync,this._def=t,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:r=>this["~validate"](r)}}optional(){return qt.create(this,this._def)}nullable(){return Wr.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return fn.create(this)}promise(){return Dn.create(this,this._def)}or(t){return xi.create([this,t],this._def)}and(t){return Si.create(this,t,this._def)}transform(t){return new ur({...ee(this._def),schema:this,typeName:E.ZodEffects,effect:{type:"transform",transform:t}})}default(t){let r=typeof t=="function"?t:()=>t;return new Ai({...ee(this._def),innerType:this,defaultValue:r,typeName:E.ZodDefault})}brand(){return new $s({typeName:E.ZodBranded,type:this,...ee(this._def)})}catch(t){let r=typeof t=="function"?t:()=>t;return new Oi({...ee(this._def),innerType:this,catchValue:r,typeName:E.ZodCatch})}describe(t){let r=this.constructor;return new r({...this._def,description:t})}pipe(t){return Es.create(this,t)}readonly(){return Pi.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},T$=/^c[^\s-]{8,}$/i,$$=/^[0-9a-z]+$/,E$=/^[0-9A-HJKMNP-TV-Z]{26}$/i,z$=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,A$=/^[a-z0-9_-]{21}$/i,O$=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,P$=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,C$=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,R$="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",yd,I$=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,j$=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,N$=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,M$=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,D$=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,G$=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Uy="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",Z$=new RegExp(`^${Uy}$`);function Vy(e){let t="[0-5]\\d";e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision==null&&(t=`${t}(\\.\\d+)?`);let r=e.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${r}`}function F$(e){return new RegExp(`^${Vy(e)}$`)}function By(e){let t=`${Uy}T${Vy(e)}`,r=[];return r.push(e.local?"Z?":"Z"),e.offset&&r.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${r.join("|")})`,new RegExp(`^${t}$`)}function q$(e,t){return!!((t==="v4"||!t)&&I$.test(e)||(t==="v6"||!t)&&N$.test(e))}function L$(e,t){if(!O$.test(e))return!1;try{let[r]=e.split(".");if(!r)return!1;let n=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),i=JSON.parse(atob(n));return!(typeof i!="object"||i===null||"typ"in i&&i?.typ!=="JWT"||!i.alg||t&&i.alg!==t)}catch{return!1}}function U$(e,t){return!!((t==="v4"||!t)&&j$.test(e)||(t==="v6"||!t)&&M$.test(e))}var Nn=class e extends ne{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==P.string){let o=this._getOrReturnCtx(t);return O(o,{code:T.invalid_type,expected:P.string,received:o.parsedType}),W}let n=new ht,i;for(let o of this._def.checks)if(o.kind==="min")t.data.length<o.value&&(i=this._getOrReturnCtx(t,i),O(i,{code:T.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),n.dirty());else if(o.kind==="max")t.data.length>o.value&&(i=this._getOrReturnCtx(t,i),O(i,{code:T.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),n.dirty());else if(o.kind==="length"){let s=t.data.length>o.value,a=t.data.length<o.value;(s||a)&&(i=this._getOrReturnCtx(t,i),s?O(i,{code:T.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}):a&&O(i,{code:T.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}),n.dirty())}else if(o.kind==="email")C$.test(t.data)||(i=this._getOrReturnCtx(t,i),O(i,{validation:"email",code:T.invalid_string,message:o.message}),n.dirty());else if(o.kind==="emoji")yd||(yd=new RegExp(R$,"u")),yd.test(t.data)||(i=this._getOrReturnCtx(t,i),O(i,{validation:"emoji",code:T.invalid_string,message:o.message}),n.dirty());else if(o.kind==="uuid")z$.test(t.data)||(i=this._getOrReturnCtx(t,i),O(i,{validation:"uuid",code:T.invalid_string,message:o.message}),n.dirty());else if(o.kind==="nanoid")A$.test(t.data)||(i=this._getOrReturnCtx(t,i),O(i,{validation:"nanoid",code:T.invalid_string,message:o.message}),n.dirty());else if(o.kind==="cuid")T$.test(t.data)||(i=this._getOrReturnCtx(t,i),O(i,{validation:"cuid",code:T.invalid_string,message:o.message}),n.dirty());else if(o.kind==="cuid2")$$.test(t.data)||(i=this._getOrReturnCtx(t,i),O(i,{validation:"cuid2",code:T.invalid_string,message:o.message}),n.dirty());else if(o.kind==="ulid")E$.test(t.data)||(i=this._getOrReturnCtx(t,i),O(i,{validation:"ulid",code:T.invalid_string,message:o.message}),n.dirty());else if(o.kind==="url")try{new URL(t.data)}catch{i=this._getOrReturnCtx(t,i),O(i,{validation:"url",code:T.invalid_string,message:o.message}),n.dirty()}else o.kind==="regex"?(o.regex.lastIndex=0,o.regex.test(t.data)||(i=this._getOrReturnCtx(t,i),O(i,{validation:"regex",code:T.invalid_string,message:o.message}),n.dirty())):o.kind==="trim"?t.data=t.data.trim():o.kind==="includes"?t.data.includes(o.value,o.position)||(i=this._getOrReturnCtx(t,i),O(i,{code:T.invalid_string,validation:{includes:o.value,position:o.position},message:o.message}),n.dirty()):o.kind==="toLowerCase"?t.data=t.data.toLowerCase():o.kind==="toUpperCase"?t.data=t.data.toUpperCase():o.kind==="startsWith"?t.data.startsWith(o.value)||(i=this._getOrReturnCtx(t,i),O(i,{code:T.invalid_string,validation:{startsWith:o.value},message:o.message}),n.dirty()):o.kind==="endsWith"?t.data.endsWith(o.value)||(i=this._getOrReturnCtx(t,i),O(i,{code:T.invalid_string,validation:{endsWith:o.value},message:o.message}),n.dirty()):o.kind==="datetime"?By(o).test(t.data)||(i=this._getOrReturnCtx(t,i),O(i,{code:T.invalid_string,validation:"datetime",message:o.message}),n.dirty()):o.kind==="date"?Z$.test(t.data)||(i=this._getOrReturnCtx(t,i),O(i,{code:T.invalid_string,validation:"date",message:o.message}),n.dirty()):o.kind==="time"?F$(o).test(t.data)||(i=this._getOrReturnCtx(t,i),O(i,{code:T.invalid_string,validation:"time",message:o.message}),n.dirty()):o.kind==="duration"?P$.test(t.data)||(i=this._getOrReturnCtx(t,i),O(i,{validation:"duration",code:T.invalid_string,message:o.message}),n.dirty()):o.kind==="ip"?q$(t.data,o.version)||(i=this._getOrReturnCtx(t,i),O(i,{validation:"ip",code:T.invalid_string,message:o.message}),n.dirty()):o.kind==="jwt"?L$(t.data,o.alg)||(i=this._getOrReturnCtx(t,i),O(i,{validation:"jwt",code:T.invalid_string,message:o.message}),n.dirty()):o.kind==="cidr"?U$(t.data,o.version)||(i=this._getOrReturnCtx(t,i),O(i,{validation:"cidr",code:T.invalid_string,message:o.message}),n.dirty()):o.kind==="base64"?D$.test(t.data)||(i=this._getOrReturnCtx(t,i),O(i,{validation:"base64",code:T.invalid_string,message:o.message}),n.dirty()):o.kind==="base64url"?G$.test(t.data)||(i=this._getOrReturnCtx(t,i),O(i,{validation:"base64url",code:T.invalid_string,message:o.message}),n.dirty()):ae.assertNever(o);return{status:n.value,value:t.data}}_regex(t,r,n){return this.refinement(i=>t.test(i),{validation:r,code:T.invalid_string,...Z.errToObj(n)})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...Z.errToObj(t)})}url(t){return this._addCheck({kind:"url",...Z.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...Z.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...Z.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...Z.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...Z.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...Z.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...Z.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...Z.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...Z.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...Z.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...Z.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...Z.errToObj(t)})}datetime(t){return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:t}):this._addCheck({kind:"datetime",precision:typeof t?.precision>"u"?null:t?.precision,offset:t?.offset??!1,local:t?.local??!1,...Z.errToObj(t?.message)})}date(t){return this._addCheck({kind:"date",message:t})}time(t){return typeof t=="string"?this._addCheck({kind:"time",precision:null,message:t}):this._addCheck({kind:"time",precision:typeof t?.precision>"u"?null:t?.precision,...Z.errToObj(t?.message)})}duration(t){return this._addCheck({kind:"duration",...Z.errToObj(t)})}regex(t,r){return this._addCheck({kind:"regex",regex:t,...Z.errToObj(r)})}includes(t,r){return this._addCheck({kind:"includes",value:t,position:r?.position,...Z.errToObj(r?.message)})}startsWith(t,r){return this._addCheck({kind:"startsWith",value:t,...Z.errToObj(r)})}endsWith(t,r){return this._addCheck({kind:"endsWith",value:t,...Z.errToObj(r)})}min(t,r){return this._addCheck({kind:"min",value:t,...Z.errToObj(r)})}max(t,r){return this._addCheck({kind:"max",value:t,...Z.errToObj(r)})}length(t,r){return this._addCheck({kind:"length",value:t,...Z.errToObj(r)})}nonempty(t){return this.min(1,Z.errToObj(t))}trim(){return new e({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new e({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new e({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(t=>t.kind==="datetime")}get isDate(){return!!this._def.checks.find(t=>t.kind==="date")}get isTime(){return!!this._def.checks.find(t=>t.kind==="time")}get isDuration(){return!!this._def.checks.find(t=>t.kind==="duration")}get isEmail(){return!!this._def.checks.find(t=>t.kind==="email")}get isURL(){return!!this._def.checks.find(t=>t.kind==="url")}get isEmoji(){return!!this._def.checks.find(t=>t.kind==="emoji")}get isUUID(){return!!this._def.checks.find(t=>t.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(t=>t.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(t=>t.kind==="cuid2")}get isULID(){return!!this._def.checks.find(t=>t.kind==="ulid")}get isIP(){return!!this._def.checks.find(t=>t.kind==="ip")}get isCIDR(){return!!this._def.checks.find(t=>t.kind==="cidr")}get isBase64(){return!!this._def.checks.find(t=>t.kind==="base64")}get isBase64url(){return!!this._def.checks.find(t=>t.kind==="base64url")}get minLength(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxLength(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}};Nn.create=e=>new Nn({checks:[],typeName:E.ZodString,coerce:e?.coerce??!1,...ee(e)});function V$(e,t){let r=(e.toString().split(".")[1]||"").length,n=(t.toString().split(".")[1]||"").length,i=r>n?r:n,o=Number.parseInt(e.toFixed(i).replace(".","")),s=Number.parseInt(t.toFixed(i).replace(".",""));return o%s/10**i}var _i=class e extends ne{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==P.number){let o=this._getOrReturnCtx(t);return O(o,{code:T.invalid_type,expected:P.number,received:o.parsedType}),W}let n,i=new ht;for(let o of this._def.checks)o.kind==="int"?ae.isInteger(t.data)||(n=this._getOrReturnCtx(t,n),O(n,{code:T.invalid_type,expected:"integer",received:"float",message:o.message}),i.dirty()):o.kind==="min"?(o.inclusive?t.data<o.value:t.data<=o.value)&&(n=this._getOrReturnCtx(t,n),O(n,{code:T.too_small,minimum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),i.dirty()):o.kind==="max"?(o.inclusive?t.data>o.value:t.data>=o.value)&&(n=this._getOrReturnCtx(t,n),O(n,{code:T.too_big,maximum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),i.dirty()):o.kind==="multipleOf"?V$(t.data,o.value)!==0&&(n=this._getOrReturnCtx(t,n),O(n,{code:T.not_multiple_of,multipleOf:o.value,message:o.message}),i.dirty()):o.kind==="finite"?Number.isFinite(t.data)||(n=this._getOrReturnCtx(t,n),O(n,{code:T.not_finite,message:o.message}),i.dirty()):ae.assertNever(o);return{status:i.value,value:t.data}}gte(t,r){return this.setLimit("min",t,!0,Z.toString(r))}gt(t,r){return this.setLimit("min",t,!1,Z.toString(r))}lte(t,r){return this.setLimit("max",t,!0,Z.toString(r))}lt(t,r){return this.setLimit("max",t,!1,Z.toString(r))}setLimit(t,r,n,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:n,message:Z.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:Z.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Z.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Z.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Z.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Z.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:Z.toString(r)})}finite(t){return this._addCheck({kind:"finite",message:Z.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Z.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Z.toString(t)})}get minValue(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxValue(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&ae.isInteger(t.value))}get isFinite(){let t=null,r=null;for(let n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(r===null||n.value>r)&&(r=n.value):n.kind==="max"&&(t===null||n.value<t)&&(t=n.value)}return Number.isFinite(r)&&Number.isFinite(t)}};_i.create=e=>new _i({checks:[],typeName:E.ZodNumber,coerce:e?.coerce||!1,...ee(e)});var yi=class e extends ne{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce)try{t.data=BigInt(t.data)}catch{return this._getInvalidInput(t)}if(this._getType(t)!==P.bigint)return this._getInvalidInput(t);let n,i=new ht;for(let o of this._def.checks)o.kind==="min"?(o.inclusive?t.data<o.value:t.data<=o.value)&&(n=this._getOrReturnCtx(t,n),O(n,{code:T.too_small,type:"bigint",minimum:o.value,inclusive:o.inclusive,message:o.message}),i.dirty()):o.kind==="max"?(o.inclusive?t.data>o.value:t.data>=o.value)&&(n=this._getOrReturnCtx(t,n),O(n,{code:T.too_big,type:"bigint",maximum:o.value,inclusive:o.inclusive,message:o.message}),i.dirty()):o.kind==="multipleOf"?t.data%o.value!==BigInt(0)&&(n=this._getOrReturnCtx(t,n),O(n,{code:T.not_multiple_of,multipleOf:o.value,message:o.message}),i.dirty()):ae.assertNever(o);return{status:i.value,value:t.data}}_getInvalidInput(t){let r=this._getOrReturnCtx(t);return O(r,{code:T.invalid_type,expected:P.bigint,received:r.parsedType}),W}gte(t,r){return this.setLimit("min",t,!0,Z.toString(r))}gt(t,r){return this.setLimit("min",t,!1,Z.toString(r))}lte(t,r){return this.setLimit("max",t,!0,Z.toString(r))}lt(t,r){return this.setLimit("max",t,!1,Z.toString(r))}setLimit(t,r,n,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:n,message:Z.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Z.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Z.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Z.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Z.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:Z.toString(r)})}get minValue(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxValue(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}};yi.create=e=>new yi({checks:[],typeName:E.ZodBigInt,coerce:e?.coerce??!1,...ee(e)});var vi=class extends ne{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==P.boolean){let n=this._getOrReturnCtx(t);return O(n,{code:T.invalid_type,expected:P.boolean,received:n.parsedType}),W}return Tt(t.data)}};vi.create=e=>new vi({typeName:E.ZodBoolean,coerce:e?.coerce||!1,...ee(e)});var bi=class e extends ne{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==P.date){let o=this._getOrReturnCtx(t);return O(o,{code:T.invalid_type,expected:P.date,received:o.parsedType}),W}if(Number.isNaN(t.data.getTime())){let o=this._getOrReturnCtx(t);return O(o,{code:T.invalid_date}),W}let n=new ht,i;for(let o of this._def.checks)o.kind==="min"?t.data.getTime()<o.value&&(i=this._getOrReturnCtx(t,i),O(i,{code:T.too_small,message:o.message,inclusive:!0,exact:!1,minimum:o.value,type:"date"}),n.dirty()):o.kind==="max"?t.data.getTime()>o.value&&(i=this._getOrReturnCtx(t,i),O(i,{code:T.too_big,message:o.message,inclusive:!0,exact:!1,maximum:o.value,type:"date"}),n.dirty()):ae.assertNever(o);return{status:n.value,value:new Date(t.data.getTime())}}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}min(t,r){return this._addCheck({kind:"min",value:t.getTime(),message:Z.toString(r)})}max(t,r){return this._addCheck({kind:"max",value:t.getTime(),message:Z.toString(r)})}get minDate(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t!=null?new Date(t):null}};bi.create=e=>new bi({checks:[],coerce:e?.coerce||!1,typeName:E.ZodDate,...ee(e)});var xo=class extends ne{_parse(t){if(this._getType(t)!==P.symbol){let n=this._getOrReturnCtx(t);return O(n,{code:T.invalid_type,expected:P.symbol,received:n.parsedType}),W}return Tt(t.data)}};xo.create=e=>new xo({typeName:E.ZodSymbol,...ee(e)});var wi=class extends ne{_parse(t){if(this._getType(t)!==P.undefined){let n=this._getOrReturnCtx(t);return O(n,{code:T.invalid_type,expected:P.undefined,received:n.parsedType}),W}return Tt(t.data)}};wi.create=e=>new wi({typeName:E.ZodUndefined,...ee(e)});var ki=class extends ne{_parse(t){if(this._getType(t)!==P.null){let n=this._getOrReturnCtx(t);return O(n,{code:T.invalid_type,expected:P.null,received:n.parsedType}),W}return Tt(t.data)}};ki.create=e=>new ki({typeName:E.ZodNull,...ee(e)});var Mn=class extends ne{constructor(){super(...arguments),this._any=!0}_parse(t){return Tt(t.data)}};Mn.create=e=>new Mn({typeName:E.ZodAny,...ee(e)});var dn=class extends ne{constructor(){super(...arguments),this._unknown=!0}_parse(t){return Tt(t.data)}};dn.create=e=>new dn({typeName:E.ZodUnknown,...ee(e)});var Tr=class extends ne{_parse(t){let r=this._getOrReturnCtx(t);return O(r,{code:T.invalid_type,expected:P.never,received:r.parsedType}),W}};Tr.create=e=>new Tr({typeName:E.ZodNever,...ee(e)});var So=class extends ne{_parse(t){if(this._getType(t)!==P.undefined){let n=this._getOrReturnCtx(t);return O(n,{code:T.invalid_type,expected:P.void,received:n.parsedType}),W}return Tt(t.data)}};So.create=e=>new So({typeName:E.ZodVoid,...ee(e)});var fn=class e extends ne{_parse(t){let{ctx:r,status:n}=this._processInputParams(t),i=this._def;if(r.parsedType!==P.array)return O(r,{code:T.invalid_type,expected:P.array,received:r.parsedType}),W;if(i.exactLength!==null){let s=r.data.length>i.exactLength.value,a=r.data.length<i.exactLength.value;(s||a)&&(O(r,{code:s?T.too_big:T.too_small,minimum:a?i.exactLength.value:void 0,maximum:s?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),n.dirty())}if(i.minLength!==null&&r.data.length<i.minLength.value&&(O(r,{code:T.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),n.dirty()),i.maxLength!==null&&r.data.length>i.maxLength.value&&(O(r,{code:T.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((s,a)=>i.type._parseAsync(new lr(r,s,r.path,a)))).then(s=>ht.mergeArray(n,s));let o=[...r.data].map((s,a)=>i.type._parseSync(new lr(r,s,r.path,a)));return ht.mergeArray(n,o)}get element(){return this._def.type}min(t,r){return new e({...this._def,minLength:{value:t,message:Z.toString(r)}})}max(t,r){return new e({...this._def,maxLength:{value:t,message:Z.toString(r)}})}length(t,r){return new e({...this._def,exactLength:{value:t,message:Z.toString(r)}})}nonempty(t){return this.min(1,t)}};fn.create=(e,t)=>new fn({type:e,minLength:null,maxLength:null,exactLength:null,typeName:E.ZodArray,...ee(t)});function ko(e){if(e instanceof Lt){let t={};for(let r in e.shape){let n=e.shape[r];t[r]=qt.create(ko(n))}return new Lt({...e._def,shape:()=>t})}else return e instanceof fn?new fn({...e._def,type:ko(e.element)}):e instanceof qt?qt.create(ko(e.unwrap())):e instanceof Wr?Wr.create(ko(e.unwrap())):e instanceof Br?Br.create(e.items.map(t=>ko(t))):e}var Lt=class e extends ne{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let t=this._def.shape(),r=ae.objectKeys(t);return this._cached={shape:t,keys:r},this._cached}_parse(t){if(this._getType(t)!==P.object){let c=this._getOrReturnCtx(t);return O(c,{code:T.invalid_type,expected:P.object,received:c.parsedType}),W}let{status:n,ctx:i}=this._processInputParams(t),{shape:o,keys:s}=this._getCached(),a=[];if(!(this._def.catchall instanceof Tr&&this._def.unknownKeys==="strip"))for(let c in i.data)s.includes(c)||a.push(c);let u=[];for(let c of s){let l=o[c],d=i.data[c];u.push({key:{status:"valid",value:c},value:l._parse(new lr(i,d,i.path,c)),alwaysSet:c in i.data})}if(this._def.catchall instanceof Tr){let c=this._def.unknownKeys;if(c==="passthrough")for(let l of a)u.push({key:{status:"valid",value:l},value:{status:"valid",value:i.data[l]}});else if(c==="strict")a.length>0&&(O(i,{code:T.unrecognized_keys,keys:a}),n.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let c=this._def.catchall;for(let l of a){let d=i.data[l];u.push({key:{status:"valid",value:l},value:c._parse(new lr(i,d,i.path,l)),alwaysSet:l in i.data})}}return i.common.async?Promise.resolve().then(async()=>{let c=[];for(let l of u){let d=await l.key,p=await l.value;c.push({key:d,value:p,alwaysSet:l.alwaysSet})}return c}).then(c=>ht.mergeObjectSync(n,c)):ht.mergeObjectSync(n,u)}get shape(){return this._def.shape()}strict(t){return Z.errToObj,new e({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(r,n)=>{let i=this._def.errorMap?.(r,n).message??n.defaultError;return r.code==="unrecognized_keys"?{message:Z.errToObj(t).message??i}:{message:i}}}:{}})}strip(){return new e({...this._def,unknownKeys:"strip"})}passthrough(){return new e({...this._def,unknownKeys:"passthrough"})}extend(t){return new e({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new e({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:E.ZodObject})}setKey(t,r){return this.augment({[t]:r})}catchall(t){return new e({...this._def,catchall:t})}pick(t){let r={};for(let n of ae.objectKeys(t))t[n]&&this.shape[n]&&(r[n]=this.shape[n]);return new e({...this._def,shape:()=>r})}omit(t){let r={};for(let n of ae.objectKeys(this.shape))t[n]||(r[n]=this.shape[n]);return new e({...this._def,shape:()=>r})}deepPartial(){return ko(this)}partial(t){let r={};for(let n of ae.objectKeys(this.shape)){let i=this.shape[n];t&&!t[n]?r[n]=i:r[n]=i.optional()}return new e({...this._def,shape:()=>r})}required(t){let r={};for(let n of ae.objectKeys(this.shape))if(t&&!t[n])r[n]=this.shape[n];else{let o=this.shape[n];for(;o instanceof qt;)o=o._def.innerType;r[n]=o}return new e({...this._def,shape:()=>r})}keyof(){return Wy(ae.objectKeys(this.shape))}};Lt.create=(e,t)=>new Lt({shape:()=>e,unknownKeys:"strip",catchall:Tr.create(),typeName:E.ZodObject,...ee(t)});Lt.strictCreate=(e,t)=>new Lt({shape:()=>e,unknownKeys:"strict",catchall:Tr.create(),typeName:E.ZodObject,...ee(t)});Lt.lazycreate=(e,t)=>new Lt({shape:e,unknownKeys:"strip",catchall:Tr.create(),typeName:E.ZodObject,...ee(t)});var xi=class extends ne{_parse(t){let{ctx:r}=this._processInputParams(t),n=this._def.options;function i(o){for(let a of o)if(a.result.status==="valid")return a.result;for(let a of o)if(a.result.status==="dirty")return r.common.issues.push(...a.ctx.common.issues),a.result;let s=o.map(a=>new Ft(a.ctx.common.issues));return O(r,{code:T.invalid_union,unionErrors:s}),W}if(r.common.async)return Promise.all(n.map(async o=>{let s={...r,common:{...r.common,issues:[]},parent:null};return{result:await o._parseAsync({data:r.data,path:r.path,parent:s}),ctx:s}})).then(i);{let o,s=[];for(let u of n){let c={...r,common:{...r.common,issues:[]},parent:null},l=u._parseSync({data:r.data,path:r.path,parent:c});if(l.status==="valid")return l;l.status==="dirty"&&!o&&(o={result:l,ctx:c}),c.common.issues.length&&s.push(c.common.issues)}if(o)return r.common.issues.push(...o.ctx.common.issues),o.result;let a=s.map(u=>new Ft(u));return O(r,{code:T.invalid_union,unionErrors:a}),W}}get options(){return this._def.options}};xi.create=(e,t)=>new xi({options:e,typeName:E.ZodUnion,...ee(t)});var un=e=>e instanceof Ti?un(e.schema):e instanceof ur?un(e.innerType()):e instanceof $i?[e.value]:e instanceof Ei?e.options:e instanceof zi?ae.objectValues(e.enum):e instanceof Ai?un(e._def.innerType):e instanceof wi?[void 0]:e instanceof ki?[null]:e instanceof qt?[void 0,...un(e.unwrap())]:e instanceof Wr?[null,...un(e.unwrap())]:e instanceof $s||e instanceof Pi?un(e.unwrap()):e instanceof Oi?un(e._def.innerType):[],xc=class e extends ne{_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==P.object)return O(r,{code:T.invalid_type,expected:P.object,received:r.parsedType}),W;let n=this.discriminator,i=r.data[n],o=this.optionsMap.get(i);return o?r.common.async?o._parseAsync({data:r.data,path:r.path,parent:r}):o._parseSync({data:r.data,path:r.path,parent:r}):(O(r,{code:T.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),W)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,r,n){let i=new Map;for(let o of r){let s=un(o.shape[t]);if(!s.length)throw new Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(let a of s){if(i.has(a))throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(a)}`);i.set(a,o)}}return new e({typeName:E.ZodDiscriminatedUnion,discriminator:t,options:r,optionsMap:i,...ee(n)})}};function vd(e,t){let r=Vr(e),n=Vr(t);if(e===t)return{valid:!0,data:e};if(r===P.object&&n===P.object){let i=ae.objectKeys(t),o=ae.objectKeys(e).filter(a=>i.indexOf(a)!==-1),s={...e,...t};for(let a of o){let u=vd(e[a],t[a]);if(!u.valid)return{valid:!1};s[a]=u.data}return{valid:!0,data:s}}else if(r===P.array&&n===P.array){if(e.length!==t.length)return{valid:!1};let i=[];for(let o=0;o<e.length;o++){let s=e[o],a=t[o],u=vd(s,a);if(!u.valid)return{valid:!1};i.push(u.data)}return{valid:!0,data:i}}else return r===P.date&&n===P.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}var Si=class extends ne{_parse(t){let{status:r,ctx:n}=this._processInputParams(t),i=(o,s)=>{if(wc(o)||wc(s))return W;let a=vd(o.value,s.value);return a.valid?((kc(o)||kc(s))&&r.dirty(),{status:r.value,value:a.data}):(O(n,{code:T.invalid_intersection_types}),W)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([o,s])=>i(o,s)):i(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};Si.create=(e,t,r)=>new Si({left:e,right:t,typeName:E.ZodIntersection,...ee(r)});var Br=class e extends ne{_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==P.array)return O(n,{code:T.invalid_type,expected:P.array,received:n.parsedType}),W;if(n.data.length<this._def.items.length)return O(n,{code:T.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),W;!this._def.rest&&n.data.length>this._def.items.length&&(O(n,{code:T.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let o=[...n.data].map((s,a)=>{let u=this._def.items[a]||this._def.rest;return u?u._parse(new lr(n,s,n.path,a)):null}).filter(s=>!!s);return n.common.async?Promise.all(o).then(s=>ht.mergeArray(r,s)):ht.mergeArray(r,o)}get items(){return this._def.items}rest(t){return new e({...this._def,rest:t})}};Br.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Br({items:e,typeName:E.ZodTuple,rest:null,...ee(t)})};var Sc=class e extends ne{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==P.object)return O(n,{code:T.invalid_type,expected:P.object,received:n.parsedType}),W;let i=[],o=this._def.keyType,s=this._def.valueType;for(let a in n.data)i.push({key:o._parse(new lr(n,a,n.path,a)),value:s._parse(new lr(n,n.data[a],n.path,a)),alwaysSet:a in n.data});return n.common.async?ht.mergeObjectAsync(r,i):ht.mergeObjectSync(r,i)}get element(){return this._def.valueType}static create(t,r,n){return r instanceof ne?new e({keyType:t,valueType:r,typeName:E.ZodRecord,...ee(n)}):new e({keyType:Nn.create(),valueType:t,typeName:E.ZodRecord,...ee(r)})}},To=class extends ne{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==P.map)return O(n,{code:T.invalid_type,expected:P.map,received:n.parsedType}),W;let i=this._def.keyType,o=this._def.valueType,s=[...n.data.entries()].map(([a,u],c)=>({key:i._parse(new lr(n,a,n.path,[c,"key"])),value:o._parse(new lr(n,u,n.path,[c,"value"]))}));if(n.common.async){let a=new Map;return Promise.resolve().then(async()=>{for(let u of s){let c=await u.key,l=await u.value;if(c.status==="aborted"||l.status==="aborted")return W;(c.status==="dirty"||l.status==="dirty")&&r.dirty(),a.set(c.value,l.value)}return{status:r.value,value:a}})}else{let a=new Map;for(let u of s){let c=u.key,l=u.value;if(c.status==="aborted"||l.status==="aborted")return W;(c.status==="dirty"||l.status==="dirty")&&r.dirty(),a.set(c.value,l.value)}return{status:r.value,value:a}}}};To.create=(e,t,r)=>new To({valueType:t,keyType:e,typeName:E.ZodMap,...ee(r)});var $o=class e extends ne{_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==P.set)return O(n,{code:T.invalid_type,expected:P.set,received:n.parsedType}),W;let i=this._def;i.minSize!==null&&n.data.size<i.minSize.value&&(O(n,{code:T.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),r.dirty()),i.maxSize!==null&&n.data.size>i.maxSize.value&&(O(n,{code:T.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),r.dirty());let o=this._def.valueType;function s(u){let c=new Set;for(let l of u){if(l.status==="aborted")return W;l.status==="dirty"&&r.dirty(),c.add(l.value)}return{status:r.value,value:c}}let a=[...n.data.values()].map((u,c)=>o._parse(new lr(n,u,n.path,c)));return n.common.async?Promise.all(a).then(u=>s(u)):s(a)}min(t,r){return new e({...this._def,minSize:{value:t,message:Z.toString(r)}})}max(t,r){return new e({...this._def,maxSize:{value:t,message:Z.toString(r)}})}size(t,r){return this.min(t,r).max(t,r)}nonempty(t){return this.min(1,t)}};$o.create=(e,t)=>new $o({valueType:e,minSize:null,maxSize:null,typeName:E.ZodSet,...ee(t)});var Tc=class e extends ne{constructor(){super(...arguments),this.validate=this.implement}_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==P.function)return O(r,{code:T.invalid_type,expected:P.function,received:r.parsedType}),W;function n(a,u){return Ts({data:a,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,bo(),ln].filter(c=>!!c),issueData:{code:T.invalid_arguments,argumentsError:u}})}function i(a,u){return Ts({data:a,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,bo(),ln].filter(c=>!!c),issueData:{code:T.invalid_return_type,returnTypeError:u}})}let o={errorMap:r.common.contextualErrorMap},s=r.data;if(this._def.returns instanceof Dn){let a=this;return Tt(async function(...u){let c=new Ft([]),l=await a._def.args.parseAsync(u,o).catch(f=>{throw c.addIssue(n(u,f)),c}),d=await Reflect.apply(s,this,l);return await a._def.returns._def.type.parseAsync(d,o).catch(f=>{throw c.addIssue(i(d,f)),c})})}else{let a=this;return Tt(function(...u){let c=a._def.args.safeParse(u,o);if(!c.success)throw new Ft([n(u,c.error)]);let l=Reflect.apply(s,this,c.data),d=a._def.returns.safeParse(l,o);if(!d.success)throw new Ft([i(l,d.error)]);return d.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new e({...this._def,args:Br.create(t).rest(dn.create())})}returns(t){return new e({...this._def,returns:t})}implement(t){return this.parse(t)}strictImplement(t){return this.parse(t)}static create(t,r,n){return new e({args:t||Br.create([]).rest(dn.create()),returns:r||dn.create(),typeName:E.ZodFunction,...ee(n)})}},Ti=class extends ne{get schema(){return this._def.getter()}_parse(t){let{ctx:r}=this._processInputParams(t);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}};Ti.create=(e,t)=>new Ti({getter:e,typeName:E.ZodLazy,...ee(t)});var $i=class extends ne{_parse(t){if(t.data!==this._def.value){let r=this._getOrReturnCtx(t);return O(r,{received:r.data,code:T.invalid_literal,expected:this._def.value}),W}return{status:"valid",value:t.data}}get value(){return this._def.value}};$i.create=(e,t)=>new $i({value:e,typeName:E.ZodLiteral,...ee(t)});function Wy(e,t){return new Ei({values:e,typeName:E.ZodEnum,...ee(t)})}var Ei=class e extends ne{_parse(t){if(typeof t.data!="string"){let r=this._getOrReturnCtx(t),n=this._def.values;return O(r,{expected:ae.joinValues(n),received:r.parsedType,code:T.invalid_type}),W}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(t.data)){let r=this._getOrReturnCtx(t),n=this._def.values;return O(r,{received:r.data,code:T.invalid_enum_value,options:n}),W}return Tt(t.data)}get options(){return this._def.values}get enum(){let t={};for(let r of this._def.values)t[r]=r;return t}get Values(){let t={};for(let r of this._def.values)t[r]=r;return t}get Enum(){let t={};for(let r of this._def.values)t[r]=r;return t}extract(t,r=this._def){return e.create(t,{...this._def,...r})}exclude(t,r=this._def){return e.create(this.options.filter(n=>!t.includes(n)),{...this._def,...r})}};Ei.create=Wy;var zi=class extends ne{_parse(t){let r=ae.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(t);if(n.parsedType!==P.string&&n.parsedType!==P.number){let i=ae.objectValues(r);return O(n,{expected:ae.joinValues(i),received:n.parsedType,code:T.invalid_type}),W}if(this._cache||(this._cache=new Set(ae.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){let i=ae.objectValues(r);return O(n,{received:n.data,code:T.invalid_enum_value,options:i}),W}return Tt(t.data)}get enum(){return this._def.values}};zi.create=(e,t)=>new zi({values:e,typeName:E.ZodNativeEnum,...ee(t)});var Dn=class extends ne{unwrap(){return this._def.type}_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==P.promise&&r.common.async===!1)return O(r,{code:T.invalid_type,expected:P.promise,received:r.parsedType}),W;let n=r.parsedType===P.promise?r.data:Promise.resolve(r.data);return Tt(n.then(i=>this._def.type.parseAsync(i,{path:r.path,errorMap:r.common.contextualErrorMap})))}};Dn.create=(e,t)=>new Dn({type:e,typeName:E.ZodPromise,...ee(t)});var ur=class extends ne{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===E.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){let{status:r,ctx:n}=this._processInputParams(t),i=this._def.effect||null,o={addIssue:s=>{O(n,s),s.fatal?r.abort():r.dirty()},get path(){return n.path}};if(o.addIssue=o.addIssue.bind(o),i.type==="preprocess"){let s=i.transform(n.data,o);if(n.common.async)return Promise.resolve(s).then(async a=>{if(r.value==="aborted")return W;let u=await this._def.schema._parseAsync({data:a,path:n.path,parent:n});return u.status==="aborted"?W:u.status==="dirty"?gi(u.value):r.value==="dirty"?gi(u.value):u});{if(r.value==="aborted")return W;let a=this._def.schema._parseSync({data:s,path:n.path,parent:n});return a.status==="aborted"?W:a.status==="dirty"?gi(a.value):r.value==="dirty"?gi(a.value):a}}if(i.type==="refinement"){let s=a=>{let u=i.refinement(a,o);if(n.common.async)return Promise.resolve(u);if(u instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a};if(n.common.async===!1){let a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?W:(a.status==="dirty"&&r.dirty(),s(a.value),{status:r.value,value:a.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(a=>a.status==="aborted"?W:(a.status==="dirty"&&r.dirty(),s(a.value).then(()=>({status:r.value,value:a.value}))))}if(i.type==="transform")if(n.common.async===!1){let s=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!jn(s))return W;let a=i.transform(s.value,o);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:a}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(s=>jn(s)?Promise.resolve(i.transform(s.value,o)).then(a=>({status:r.value,value:a})):W);ae.assertNever(i)}};ur.create=(e,t,r)=>new ur({schema:e,typeName:E.ZodEffects,effect:t,...ee(r)});ur.createWithPreprocess=(e,t,r)=>new ur({schema:t,effect:{type:"preprocess",transform:e},typeName:E.ZodEffects,...ee(r)});var qt=class extends ne{_parse(t){return this._getType(t)===P.undefined?Tt(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};qt.create=(e,t)=>new qt({innerType:e,typeName:E.ZodOptional,...ee(t)});var Wr=class extends ne{_parse(t){return this._getType(t)===P.null?Tt(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};Wr.create=(e,t)=>new Wr({innerType:e,typeName:E.ZodNullable,...ee(t)});var Ai=class extends ne{_parse(t){let{ctx:r}=this._processInputParams(t),n=r.data;return r.parsedType===P.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}};Ai.create=(e,t)=>new Ai({innerType:e,typeName:E.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...ee(t)});var Oi=class extends ne{_parse(t){let{ctx:r}=this._processInputParams(t),n={...r,common:{...r.common,issues:[]}},i=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return wo(i)?i.then(o=>({status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new Ft(n.common.issues)},input:n.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Ft(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};Oi.create=(e,t)=>new Oi({innerType:e,typeName:E.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...ee(t)});var Eo=class extends ne{_parse(t){if(this._getType(t)!==P.nan){let n=this._getOrReturnCtx(t);return O(n,{code:T.invalid_type,expected:P.nan,received:n.parsedType}),W}return{status:"valid",value:t.data}}};Eo.create=e=>new Eo({typeName:E.ZodNaN,...ee(e)});var B$=Symbol("zod_brand"),$s=class extends ne{_parse(t){let{ctx:r}=this._processInputParams(t),n=r.data;return this._def.type._parse({data:n,path:r.path,parent:r})}unwrap(){return this._def.type}},Es=class e extends ne{_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.common.async)return(async()=>{let o=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?W:o.status==="dirty"?(r.dirty(),gi(o.value)):this._def.out._parseAsync({data:o.value,path:n.path,parent:n})})();{let i=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?W:i.status==="dirty"?(r.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:n.path,parent:n})}}static create(t,r){return new e({in:t,out:r,typeName:E.ZodPipeline})}},Pi=class extends ne{_parse(t){let r=this._def.innerType._parse(t),n=i=>(jn(i)&&(i.value=Object.freeze(i.value)),i);return wo(r)?r.then(i=>n(i)):n(r)}unwrap(){return this._def.innerType}};Pi.create=(e,t)=>new Pi({innerType:e,typeName:E.ZodReadonly,...ee(t)});function Ly(e,t){let r=typeof e=="function"?e(t):typeof e=="string"?{message:e}:e;return typeof r=="string"?{message:r}:r}function Jy(e,t={},r){return e?Mn.create().superRefine((n,i)=>{let o=e(n);if(o instanceof Promise)return o.then(s=>{if(!s){let a=Ly(t,n),u=a.fatal??r??!0;i.addIssue({code:"custom",...a,fatal:u})}});if(!o){let s=Ly(t,n),a=s.fatal??r??!0;i.addIssue({code:"custom",...s,fatal:a})}}):Mn.create()}var W$={object:Lt.lazycreate},E;(function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"})(E||(E={}));var J$=(e,t={message:`Input not instance of ${e.name}`})=>Jy(r=>r instanceof e,t),Hy=Nn.create,Ky=_i.create,H$=Eo.create,K$=yi.create,Qy=vi.create,Q$=bi.create,X$=xo.create,Y$=wi.create,eE=ki.create,tE=Mn.create,rE=dn.create,nE=Tr.create,iE=So.create,oE=fn.create,bd=Lt.create,sE=Lt.strictCreate,aE=xi.create,cE=xc.create,lE=Si.create,uE=Br.create,dE=Sc.create,fE=To.create,mE=$o.create,pE=Tc.create,hE=Ti.create,gE=$i.create,_E=Ei.create,yE=zi.create,vE=Dn.create,bE=ur.create,wE=qt.create,kE=Wr.create,xE=ur.createWithPreprocess,SE=Es.create,TE=()=>Hy().optional(),$E=()=>Ky().optional(),EE=()=>Qy().optional(),zE={string:(e=>Nn.create({...e,coerce:!0})),number:(e=>_i.create({...e,coerce:!0})),boolean:(e=>vi.create({...e,coerce:!0})),bigint:(e=>yi.create({...e,coerce:!0})),date:(e=>bi.create({...e,coerce:!0}))};var AE=W;var OE=new Intl.Segmenter("en",{granularity:"grapheme"});function Yy(e){return Array.from(OE.segment(e)).length}import*as kd from"node:fs";import*as sv from"node:os";import*as Ut from"node:path";import*as zo from"node:fs/promises";function ev(e,t){return"Kandan attachment path must resolve inside an allowed upload root ("+e+"): "+t}function tv(e){return"Kandan attachment upload path must not include hidden path segments: "+e}function wd(e){return"Kandan attachment upload requires a known media/document type or text content (binary content is not allowed): "+e}var rv="LINZUMI_THREAD_RUNNER_KANDAN_THREAD_ID";var nv="Kandan attachment path must not be empty";function _t(e){if(typeof e=="object"&&e!==null&&!Array.isArray(e))return e}function zs(e){if(Array.isArray(e))return e}function et(e){if(e!==void 0&&typeof e=="string"&&e.trim()!=="")return e.trim()}function CE(e){if(e!==void 0&&typeof e=="number"&&Number.isInteger(e))return e}function xd(e){if(e!==void 0)return e}function gt(e){let t={};t.type="text",t.text=JSON.stringify(e,void 0,2);let r={};return r.content=[t],r.structuredContent=e,r}var RE="failed: ([a-z0-9_]+)(?: detail=(.+))?$";async function Sd(e){let t;try{t=await e}catch(r){let n=K(r),i=on(n),o=new RegExp(RE).exec(i);if(o==null){let d={};return d.error=i,gt(d)}let s=o.slice(1),a=s[0],u;if(a!==void 0){let d=ve(a);u=d!==void 0?d:i}else u=i;let c={};c.error=u;let l=s[1];if(l!==void 0){let d=ve(l);d!==void 0&&(c.detail=d)}return gt(c)}return gt(t)}function av(e){let t=br(e);if(t===void 0)return Ou(e);let r=ve(t),n=wr(r);return n!==void 0&&n.includes("channel_required")?l_(new Error(n+". Remediation: pass the channel slug in the `channel` parameter, or set target.thread_id to a Linzumi thread you can access (the server resolves the thread's channel). The files were NOT attached; retry with a channel or thread instead of leaving them on disk.",{cause:r})):u_(r)}function mn(e){let t={};return Object.entries(e).forEach(r=>{t[r[0]]=r[1]}),t}function Td(e,t){if(et(e.thread_id)!==void 0||t===void 0)return e;let n=()=>{let s=mn(e);return s.thread_id=t,s},i=e.message_seq;if(i!==void 0&&typeof i<"u")return n();let o=et(e.kind);if(o===void 0)return e;switch(o){case"latest_assistant_message":case"message_seq":case"new_message":return n();default:return e}}function dr(e,t){if(et(e.thread_id)!==void 0||t===void 0)return e;let n=mn(e);return n.thread_id=t,n}function $c(e,t){let r=oo(t);if(r!==void 0)return ve(r).toString();let n=e.replace(new RegExp("^wss://"),"https://").replace(new RegExp("^ws://"),"http://"),i=Kt(t,n);return i.TAG==="Ok"?i._0.toString():Ce(i._0)}function IE(e,t){let r=et(t.inline_url),n=et(t.carousel_url),i=mn(t);return r!==void 0&&(i.inline_url=$c(e,r)),n!==void 0&&(i.carousel_url=$c(e,n)),i}function jE(e,t){if(typeof t!="object"||t===null||Array.isArray(t))return t;let r=et(t.url),n=_t(t.image_variants),i=mn(t);return r!==void 0&&(i.url=$c(e,r)),n!==void 0&&(i.image_variants=IE(e,n)),i}function ov(e,t){let r=zs(t.attachments);if(r===void 0)return t;let n=mn(t);return n.attachments=r.map(i=>jE(e,i)),n}function $d(e,t){let r=_t(t.message),n=_t(t.target_message);if(r===void 0&&n===void 0)return t;let i=mn(t);return r!==void 0&&(i.message=ov(e,r)),n!==void 0&&(i.target_message=ov(e,n)),i}var NE=[".csv",".diff",".gif",".htm",".html",".jpeg",".jpg",".json",".jsonl",".log",".md",".mp4",".patch",".pdf",".png",".svg",".txt",".webm",".webp",".xml",".zip"];async function ME(e){let t=[{path:e,label:"runner cwd"}],r=He(process.env.HOME,o=>o.trim()),n=Ut.resolve(r!==void 0&&r!==""?r:sv.homedir(),"Downloads"),i;try{i=await zo.realpath(n)}catch{return t}return t.some(o=>o.path===i)||t.push({path:i,label:"~/Downloads"}),t}function DE(e,t){let r=Ut.relative(e,t);return r===""?!0:r.startsWith("..")?!1:!Ut.isAbsolute(r)}async function GE(e,t){if(t==="")return Ce(nv);let r=Ut.isAbsolute(t)?Ut.resolve(t):Ut.resolve(e,t);return await zo.realpath(r)}async function ZE(e,t){if(!(await e.stat()).isFile())return Ce("Kandan attachment path is not a file: "+t);let n=Ut.extname(t).toLowerCase();if(NE.includes(n))return{classification:"KnownType",bytes:await e.readFile()};let i=Buffer.alloc(8192),s=(await e.read(i,0,8192,0)).bytesRead;if(i.subarray(0,s).includes(0))return Ce(wd(t));let a=await e.readFile();return a.subarray(0,8192).includes(0)?Ce(wd(t)):{classification:"TextContent",bytes:a}}async function FE(e,t){let r=e.find(i=>DE(i.path,t));if(r!==void 0){if(Ut.relative(r.path,t).split(new RegExp("[\\\\/]+","g")).find(l=>l!==void 0?l.startsWith("."):!1)!==void 0)return Ce(tv(t));let s=await zo.open(t,kd.constants.O_RDONLY|kd.constants.O_NONBLOCK),a,u=0,c;try{c=await ZE(s,t),u=1}catch(l){a={TAG:"Error",_0:K(l)}}return u===1&&(a={TAG:"Ok",_0:c}),await s.close(),a.TAG==="Ok"?a._0:Ou(a._0)}let n=e.map(i=>i.label).join(", ");return Ce(ev(n,t))}function qE(e){let t=e.toLowerCase();return t.endsWith(".png")?"image/png":t.endsWith(".jpg")||t.endsWith(".jpeg")?"image/jpeg":t.endsWith(".gif")?"image/gif":t.endsWith(".webp")?"image/webp":t.endsWith(".csv")?"text/csv":t.endsWith(".json")?"application/json":t.endsWith(".md")||t.endsWith(".txt")||t.endsWith(".log")?"text/plain":"application/octet-stream"}function LE(e,t){if(e.toLowerCase().endsWith(".py"))return"text/x-python";let n=qE(e);return t==="KnownType"||n!=="application/octet-stream"?n:"text/plain"}async function cv(e,t){let r=await zo.realpath(e),n=await ME(r),i=await GE(r,t),o=await FE(n,i);return{fileName:Ut.basename(i),contentType:LE(i,o.classification),sizeBytes:o.bytes.byteLength,bytes:o.bytes}}async function lv(e,t,r,n,i){let o={};return o["content-type"]=n,await Ya.binary($c(e,t),{method:r,headers:o,body:d_(i)})}async function uv(e){let t=await Promise.all(e.files.map(h=>cv(e.cwd,h))),r=et(e.target.thread_id),n={},i=e.workspace;i!==void 0&&(n.workspace=i);let o=e.channel;o!==void 0&&(n.channel=o),r!==void 0&&(n.thread_id=r),n.files=t.map(h=>{let m={};return m.file_name=h.fileName,m.content_type=h.contentType,m.size_bytes=h.sizeBytes,m});let s=await e.client.prepareMessageUploads(n),a=zs(s.uploads),u=a!==void 0?a:[];u.length===t.length||Ce("Linzumi upload prepare response count mismatch"),await Promise.all(t.map(async(h,m)=>{let g=_t(u[m]),y=et(Ke(g,S=>S.upload_url)),v=et(Ke(g,S=>S.upload_method)),b=v!==void 0?v:"PUT";if(y===void 0)return Ce("Linzumi upload prepare response missing upload_url");let w=await lv(e.serviceUrl,y,b,h.contentType,h.bytes);if(!w.ok)return Ce("Linzumi upload failed for "+h.fileName+": "+w.status.toString()+" "+w.statusText)}));let c=u.map(h=>{let m=et(Ke(_t(h),g=>g.file_id));return m!==void 0?m:Ce("Linzumi upload prepare response missing file_id")}),l={},d=e.workspace;d!==void 0&&(l.workspace=d);let p=e.channel;p!==void 0&&(l.channel=p),r!==void 0&&(l.thread_id=r),l.target=e.target;let f=e.body;return f!==void 0&&(l.body=f),l.uploaded_file_ids=c,await e.client.attachMessageFiles(l)}async function dv(e){let t=await cv(e.cwd,e.file),r={},n=e.workspace;n!==void 0&&(r.workspace=n),r.name=e.name,r.file_name=t.fileName,r.content_type=t.contentType,r.size_bytes=t.sizeBytes;let i=await e.client.prepareCustomEmoji(r),o=_t(i.upload),s=et(Ke(o,h=>h.upload_url)),a=et(Ke(o,h=>h.upload_method)),u=a!==void 0?a:"PUT";if(s===void 0)return Ce("Linzumi custom emoji prepare response missing upload_url");let c=await lv(e.serviceUrl,s,u,t.contentType,t.bytes);if(c.ok){let h=await c.json();if(typeof h!="object"||h===null||Array.isArray(h))return Ce("Linzumi custom emoji upload returned non-object JSON");let m=_t(h.custom_emoji);if(m===void 0)return Ce("Linzumi custom emoji upload response missing custom_emoji");let g={};g.ok=!0;let y=i.workspace;g.workspace=y!==void 0?y:void 0,g.emoji=m;let v=et(h.asset_id);g.asset_id=v!==void 0?v:void 0;let b=CE(m.id);g.id=b!==void 0?b:void 0;let w=et(m.name);g.name=w!==void 0?w:void 0;let S=et(m.shortcode);g.shortcode=S!==void 0?S:void 0;let R=et(m.image_url);return g.image_url=R!==void 0?R:void 0,g}let l=c.status.toString()+" "+c.statusText,p=(await c.text()).trim(),f;if(p==="")f=l;else{let h=0,m;try{m=JSON.parse(p),h=1}catch{f=p}if(h===1)if(typeof m=="object"&&m!==null&&!Array.isArray(m)){let g=m.error;f=typeof g=="string"?g:p}else f=p}return Ce("Linzumi custom emoji upload failed: "+f)}import*as Rt from"node:fs";import*as mv from"node:os";import*as pv from"node:net";import*as Xt from"node:path";var hv=Ra($u(),1);import*as gv from"node:child_process";function Ec(e,t){}function Od(e){return e==="DesiredRunning"?"running":"stopped"}function _v(e){switch(e){case"Running":return"running";case"Unhealthy":return"unhealthy";case"Exited":return"exited";case"Failed":return"failed";case"Stopped":return"stopped"}}function UE(){let e=He(process.env.LINZUMI_DEV_SERVICES_DIR,t=>t.trim());return e!==void 0&&e!==""?e:Xt.join(mv.homedir(),".linzumi","dev-services")}function VE(e){let t=e.replace(new RegExp("[^A-Za-z0-9._-]+","g"),"-").replace(new RegExp("^[-.]+|[-.]+$","g"),"").slice(0,80),r=Ja(e).slice(0,8),n=t===""?"runner":t;return Xt.join(UE(),n+"."+r)}function zc(e){let t=e.trim().toLowerCase();if(new RegExp("^[a-z0-9][a-z0-9._-]{0,63}$").test(t)&&!t.includes(".."))return t}function As(e,t){return Xt.join(e,"services",t+".json")}function Pd(e,t){return Xt.join(e,"exits",t+".json")}function yv(e,t){return Xt.join(e,"logs",t+".log")}function Ri(e){if(typeof e=="string"&&e!=="")return e}function pn(e){if(e!==void 0&&typeof e=="number"&&isFinite(e))return e}function BE(e){return e!==void 0?Array.isArray(e)?Qt(e,t=>{if(typeof t=="number"&&Number.isInteger(t)&&t>0&&t<=65535)return t}):[]:[]}function WE(e,t,r){if(r!==void 0&&r!==null){if(typeof r=="object"&&!Array.isArray(r)){let n=Ri(r.reason),i=pn(r.atMs);if(n!==void 0&&i!==void 0)return{reason:n,atMs:i};let o=[];n!==void 0||o.push("reason"),i!==void 0||o.push("atMs");let s=o.join(", ");return console.warn("[dev_services.failure_record_malformed] name="+e+" invalid_fields="+o.join(",")),{reason:'dev-service "'+e+'" has a malformed persisted failure record: invalid '+s,atMs:t}}return console.warn("[dev_services.failure_record_malformed] name="+e+" invalid_fields=reason,atMs"),{reason:'dev-service "'+e+'" has a malformed persisted failure record: invalid reason, atMs',atMs:t}}}function JE(e){if(typeof e!="object"||e===null||Array.isArray(e)||!Pt(e.version,1))return;let t=Ri(e.name),r=Ke(t,zc),n=Ri(e.command),i=Ri(e.cwd),o=e.desiredState,s;if(typeof o=="string")switch(o){case"running":s="DesiredRunning";break;case"stopped":s="DesiredStopped";break;default:s=void 0}else s=void 0;let a=pn(e.updatedAtMs),u=Ri(e.logPath),c=Pt(r,t);if(r!==void 0&&c&&n!==void 0&&i!==void 0&&s!==void 0&&a!==void 0&&u!==void 0)return{watchdogVersion:pn(e.watchdogVersion),name:r,command:n,cwd:i,ports:BE(e.ports),restartOnBranchChange:Pt(e.restartOnBranchChange,!0),desiredState:s,pid:pn(e.pid),ownerPid:pn(e.ownerPid),startedAtMs:pn(e.startedAtMs),updatedAtMs:a,lastBranch:Ri(e.lastBranch),logPath:u,automaticRestartAttempts:rt(pn(e.automaticRestartAttempts),0),automaticRestartWindowStartedAtMs:pn(e.automaticRestartWindowStartedAtMs),automaticRestartCause:Ri(e.automaticRestartCause),failure:WE(r,a,e.failure)}}function Ci(e){return e!==void 0?ve(e):null}function HE(e){let t=e.failure,r=t!==void 0?{reason:t.reason,atMs:t.atMs}:null,n={version:1,watchdogVersion:Ci(e.watchdogVersion),name:e.name,command:e.command,cwd:e.cwd,ports:e.ports,restartOnBranchChange:e.restartOnBranchChange,desiredState:Od(e.desiredState),pid:Ci(e.pid),ownerPid:Ci(e.ownerPid),startedAtMs:Ci(e.startedAtMs),updatedAtMs:e.updatedAtMs,lastBranch:Ci(e.lastBranch),logPath:e.logPath,automaticRestartAttempts:e.automaticRestartAttempts,automaticRestartWindowStartedAtMs:Ci(e.automaticRestartWindowStartedAtMs),automaticRestartCause:Ci(e.automaticRestartCause),failure:r},i=JSON.stringify(n);if(i!==void 0)return i+`
228
- `;throw{RE_EXN_ID:"Failure",_1:"dev-service record could not be encoded",Error:new Error}}function KE(e,t,r){let n=As(e,t.name),i=Y(Y(ye(xr(Xt.dirname(n)),a=>a.message),()=>{try{return{TAG:"Ok",_0:HE(t)}}catch(a){let u=K(a);return{TAG:"Error",_0:"record encoding failed: "+We(u).message}}}),a=>{let u=n+".tmp";return Y(ye(t_(u,a),c=>c.message),()=>ye(Wa(u,n),c=>c.message))});if(i.TAG==="Ok")return{TAG:"Ok",_0:void 0};let o=i._0,s={};return s.path=n,s.message=o,r("dev_services.record_write_failed",s),{TAG:"Error",_0:"could not persist dev-service state at "+n+": "+o}}function Ed(e,t,r){let n=As(e,t.name),i=n+".lock",o=Y(xr(Xt.dirname(n)),()=>{let u;try{let c=Rt.statSync(i),l=c.isFile(),d=c.isDirectory(),p=Date.now()-c.mtimeMs>=5e3;u=l?p?Me(oi(i),()=>{let f={};f.name=t.name,f.path=i,r("dev_services.legacy_record_lock_recovered",f)}):{TAG:"Ok",_0:void 0}:d&&p?{TAG:"Ok",_0:Date.now()-c.mtimeMs}:{TAG:"Ok",_0:void 0}}catch(c){let l=K(c),d=We(l);u=d.code==="ENOENT"?{TAG:"Ok",_0:void 0}:{TAG:"Error",_0:d}}return Y(u,c=>{try{let l=hv.lockSync(n,{lockfilePath:i,realpath:!1,retries:0,stale:5e3,update:1e3,onCompromised:d=>{let p=We(d),f={};throw f.name=t.name,f.path=i,f.message=p.message,r("dev_services.record_lock_compromised",f),d}});if(c!==void 0){let d={};d.name=t.name,d.path=i,d.age_ms=c,r("dev_services.record_lease_recovered",d)}return{TAG:"Ok",_0:l}}catch(l){let d=K(l);return{TAG:"Error",_0:We(d)}}})});if(o.TAG==="Ok"){let u=KE(e,t,r),c;try{o._0(),c={TAG:"Ok",_0:void 0}}catch(p){let f=K(p);c={TAG:"Error",_0:We(f)}}if(u.TAG!=="Ok")return{TAG:"PersistUnwritten",_0:u._0};if(c.TAG==="Ok")return"PersistOk";let l=c._0,d={};return d.name=t.name,d.path=i,d.message=l.message,r("dev_services.record_unlock_failed",d),{TAG:"PersistCommittedUnlockFailed",_0:"could not unlock dev-service state at "+i+": "+l.message}}let s=o._0,a={};return a.name=t.name,a.path=i,a.message=s.message,r("dev_services.record_lock_failed",a),{TAG:"PersistUnwritten",_0:"could not lock dev-service state at "+i+": "+s.message}}function Cd(e,t){let r=zc(t);if(r===void 0)return;let n=kr(As(e,r));if(n.TAG!=="Ok")return;let i;try{i=JSON.parse(n._0)}catch{return}return JE(i)}function QE(e){let t=o_(Xt.join(e,"services"));return t.TAG==="Ok"?Qt(t._0,r=>{if(r.endsWith(".json"))return Cd(e,r.slice(0,r.length-5|0))}).toSorted((r,n)=>r.name.localeCompare(n.name)):[]}function vv(e,t){let r=kr(Pd(e,t));if(r.TAG!=="Ok")return;let n;try{n=JSON.parse(r._0)}catch{return}if(typeof n!="object"||n===null||Array.isArray(n))return;let i=pn(n.atMs);if(i===void 0)return;let o=n.code,s;s=typeof o=="number"?o:void 0;let a=n.signal,u;return u=typeof a=="string"?a:void 0,{code:s,signal:u,atMs:i}}function XE(e){let t={};return t.command=e.command,t.args=e.args.map(r=>r),t.cwd=e.cwd,t.pollIntervalMs=e.pollIntervalMs,t.recordPath=e.recordPath,t.exitStatusPath=e.exitStatusPath,JSON.stringify(t)}function YE(e,t){return{command:e,args:["-e",`
226
+ `}}function t$(e){return new Promise((t,r)=>{setTimeout(()=>t(),e|0)})}function r$(e){return{startDeviceAuthorization:t=>fy(t.httpBaseUrl,t.workspaceSlug,t.channelSlug,t.onboarding,t.identity),pollDeviceCodeForToken:t=>my(t.httpBaseUrl,t.deviceCode,t.expiresInSeconds,void 0),now:()=>Date.now(),sleep:t$,report:e,log:(t,r)=>{}}}var n$="local runner device authorization was denied - a signed-in user rejected this computer";async function Ry(e,t,r,n,i,o,s,a){let u=o!==void 0?o:y=>{$n(y)},c=a!==void 0?a:r$(y=>u(e$(y))),l=s!==void 0?s:Pt(Nr(process.stderr.isTTY),!0),d=ve(pt(e),A);if(d.TAG!=="Ok")return{TAG:"Error",_0:d._0};let p=d._0,f=c.now(),h={cycle:0,lastLoudPromptAtMs:void 0,startFailures:0},m=async y=>{let v=await c.pollDeviceCodeForToken({httpBaseUrl:p,deviceCode:y.deviceCode,expiresInSeconds:y.expiresInSeconds});if(typeof v!="object"||v.TAG!=="Transient")return v;let b=v.httpStatus,w=v.reason;c.report({TAG:"TransientFailure",reason:w,waitedMs:c.now()-f});let S={};return S.cycle=h.cycle,S.reason=w,S.httpStatus=b!==void 0?b:null,c.log("device_wait.transient_poll_failure",S),await c.sleep(5e3),await m(y)},g=async()=>{let y=await c.startDeviceAuthorization({httpBaseUrl:p,workspaceSlug:t,channelSlug:r,onboarding:n,identity:i});if(y.TAG==="Ok"){let v=y._0;h.startFailures=0,h.cycle=h.cycle+1|0;let b=Y1(h.cycle,c.now(),h.lastLoudPromptAtMs,l),w=0;switch(b){case"DecidePrompt":case"DecideSummary":w=1;break;case"DecideRefreshLine":c.report({TAG:"RefreshLine",cycle:h.cycle,userCode:v.userCode,verificationUri:v.verificationUri,waitedMs:c.now()-f});break;case"DecideSilent":break}if(w===1){h.lastLoudPromptAtMs=c.now();let X=c.now()-f,be;be=b==="DecidePrompt"?{TAG:"Prompt",cycle:h.cycle,userCode:v.userCode,verificationUri:v.verificationUri,waitedMs:X}:{TAG:"Summary",cycle:h.cycle,userCode:v.userCode,verificationUri:v.verificationUri,waitedMs:X},c.report(be)}let S={};S.cycle=h.cycle,S.verificationUri=v.verificationUri,c.log("device_wait.code_issued",S);let R=await m(v);if(typeof R!="object")switch(R){case"CodeExpired":let X={};return X.cycle=h.cycle,X.outcome="code_expired",c.log("device_wait.code_retired",X),await g();case"Denied":return{TAG:"Error",_0:A(n$)};case"Consumed":let be={};return be.cycle=h.cycle,be.outcome="consumed",c.log("device_wait.code_retired",be),await g()}else switch(R.TAG){case"Token":let X={};return X.cycle=h.cycle,X.waitedMs=c.now()-f,c.log("device_wait.authorized",X),{TAG:"Ok",_0:R._0};case"Rejected":let be=R.httpStatus,D=R.reason;c.report({TAG:"TransientFailure",reason:dy(D,be),waitedMs:c.now()-f});let I={};return I.cycle=h.cycle,I.reason=D!==void 0?D:null,I.httpStatus=be,c.log("device_wait.code_rejected",I),await g();case"Transient":return await g()}}else{let v=y._0;h.startFailures=h.startFailures+1|0;let b=Math.min(6e4,5e3*Math.pow(2,h.startFailures-1|0));c.report({TAG:"StartFailed",reason:v.summary,retryInMs:b});let w={};return w.reason=v.summary,w.retryInMs=b,w.attempt=h.startFailures,c.log("device_wait.start_failed",w),await c.sleep(b),await g()}};return await g()}var o$="linzumi-machine-fingerprint:v1:";var Iy={platform:void 0,execFile:void 0,readFile:void 0,username:void 0};function s$(e,t){return s_(e,t,5e3,1024*1024)}var a$=new RegExp('"IOPlatformUUID"\\s*=\\s*"([0-9A-Fa-f-]{36})"'),c$=new RegExp("^[0-9a-f]{32}$"),l$=["/etc/machine-id","/var/lib/dbus/machine-id"];function u$(e){let t=e!==void 0?e:Iy,r=rt(t.platform,process.platform),n=rt(t.execFile,s$),i=rt(t.readFile,kr);switch(r){case"darwin":let o=n("ioreg",["-rd1","-c","IOPlatformExpertDevice"]);if(o.TAG!=="Ok")return;let s=a$.exec(o._0);if(s==null)return;let a=s.slice(1)[0];if(a===void 0)return;let u=he(a);return u!==void 0?u.toLowerCase():void 0;case"linux":return p_(l$,void 0,(c,l)=>{if(c!==void 0)return c;let d=i(l);if(d.TAG!=="Ok")return;let p=d._0.trim().toLowerCase();if(c$.test(p))return p});default:return}}function jy(e){return He(u$(e!==void 0?e:Iy),r=>"mfp-"+Ja(o$+r).slice(0,32))}function f$(e,t){return Y(ve(pt(e),A),r=>{let n=En(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 "+he(n).host+". Sign in to the web app to create it, then re-run connect."}})}function Dy(e){let t=e.authFilePath;return t!==void 0?t:go()}function Gy(e,t){let r=Dy(e);return Me(td(e.serviceUrl,t.accessToken,t.expiresInSeconds,r,new Date),n=>({accessToken:n.accessToken,expiresAt:n.expiresAt,authFilePath:r}))}function Ny(e,t){if(t===void 0)return ld(e);let r=new Date(t).getTime();if(isFinite(r))return{TAG:"Ok",_0:t};let n=ld(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 m$(e){let t=Ay(process.env),r=Py(t,e.serviceUrl,void 0);if(r.TAG!=="Ok")return{TAG:"Error",_0:r._0};let n=r._0,i=jy(void 0),o=My.hostname(),s={commanderId:n,machineFingerprint:i,hostname:o},a=await Ry(e.serviceUrl,e.workspaceSlug,e.channelSlug,e.onboarding,s,void 0,void 0,void 0);return a.TAG==="Ok"?Gy(e,a._0):{TAG:"Error",_0:a._0}}async function p$(e){let t=e.authMode;if(typeof t!="object")return await m$(e);let r=He(t.callbackHost,ay),n=await by(e.serviceUrl,e.workspaceSlug,e.channelSlug,e.onboarding,void 0,r,process.env,i=>{$n(i)},i=>vy((o,s)=>{if(o!=="process.spawn_failed"||typeof s!="object"||s===null||Array.isArray(s))return;let a=Ke(s.command,od),u=Ke(s.message,od);if(a!==void 0&&u!==void 0){$n("linzumi (rescript commander): could not open the authorization URL with "+a+" ("+u+`); open the URL above manually
227
+ `);return}},process.platform,i),void 0);return n.TAG==="Ok"?Gy(e,n._0):{TAG:"Error",_0:n._0}}function h$(){return{readCachedToken:(e,t)=>_o(e,t,Date.now()),validateToken:(e,t,r,n,i)=>vo(e,t,r,n,i),acquireAndCacheAuth:p$}}async function g$(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 Y(f$(e.serviceUrl,e.workspaceSlug),i=>({TAG:"Error",_0:A(i)}))}}async function _$(e,t){let r=t!==void 0?t:h$(),n=He(e.explicitToken,g=>g.trim()),i=n!==void 0&&n!==""?n:void 0;if(i!==void 0)return{TAG:"Ok",_0:{TAG:"ExplicitAuth",accessToken:i}};let o=Dy(e),s=r.readCachedToken(e.serviceUrl,o);if(s.TAG!=="Ok")return{TAG:"Error",_0:s._0};let a=s._0,u;if(a!==void 0){let g=await r.validateToken(e.serviceUrl,a.accessToken,e.workspaceSlug,e.channelSlug,e.requiredScopes);if(g.TAG==="Ok")switch(g._0){case"Usable":u={TAG:"Ok",_0:a};break;case"Rejected":let y=e.reportRejectedCachedToken;y!==void 0&&y("UnusableRejected"),u={TAG:"Ok",_0:void 0};break;case"NotFound":let v=e.reportRejectedCachedToken;v!==void 0&&v("UnusableNotFound"),u={TAG:"Ok",_0:void 0};break}else u={TAG:"Error",_0:g._0}}else u={TAG:"Ok",_0:void 0};if(u.TAG!=="Ok")return{TAG:"Error",_0:u._0};let c=u._0;if(c!==void 0)return Me(Ny(c.accessToken,c.expiresAt),g=>({TAG:"CachedAuth",_0:{accessToken:c.accessToken,expiresAt:g,authFilePath:o}}));let l=await r.acquireAndCacheAuth(e);if(l.TAG!=="Ok")return{TAG:"Error",_0:l._0};let d=l._0,p=Ny(d.accessToken,d.expiresAt);if(p.TAG!=="Ok")return{TAG:"Error",_0:p._0};let f=p._0;if(e.workspaceSlug===void 0)return{TAG:"Ok",_0:{TAG:"AcquiredAuth",accessToken:d.accessToken,expiresAt:f,authFilePath:d.authFilePath,mode:e.authMode}};let m=await g$(e,r,d.accessToken);return m.TAG==="Ok"?{TAG:"Ok",_0:{TAG:"AcquiredAuth",accessToken:d.accessToken,expiresAt:f,authFilePath:d.authFilePath,mode:e.authMode}}:{TAG:"Error",_0:m._0}}function y$(e){switch(e.TAG){case"CachedAuth":return e._0.accessToken;case"ExplicitAuth":case"AcquiredAuth":return e.accessToken}}async function Zy(e,t){return Me(await _$(e,t),y$)}function b$(){return{readCachedToken:(e,t)=>_o(e,t,Date.now()),validateTokenOutcome:(e,t,r,n)=>vo(e,t,r,n,void 0),resolveToken:e=>Zy(e,void 0)}}var gd="missing Linzumi MCP token; run linzumi auth or pass --token";function w$(e){return"Linzumi MCP token was rejected by the server and re-mint failed: "+e}async function Fy(e,t,r,n,i,o){let s=o!==void 0?o:b$(),a=r!==void 0?r:go(),u=t!==void 0?{TAG:"Ok",_0:t}:Me(s.readCachedToken(e,a),p=>He(p,f=>f.accessToken));if(u.TAG!=="Ok")return{TAG:"Error",_0:u._0};let c=u._0;if(c===void 0)return{TAG:"Error",_0:A(gd)};let l=await s.validateTokenOutcome(e,c,n,i);if(l.TAG!=="Ok")return{TAG:"Error",_0:l._0};switch(l._0){case"Usable":return{TAG:"Ok",_0:c};case"Rejected":case"NotFound":break}let d=await s.resolveToken({serviceUrl:e,explicitToken:void 0,workspaceSlug:n,channelSlug:i,requiredScopes:[],onboarding:void 0,authFilePath:r,authMode:{TAG:"BrowserMode",callbackHost:void 0},reportRejectedCachedToken:void 0});return d.TAG==="Ok"?{TAG:"Ok",_0:d._0}:{TAG:"Error",_0:A(w$(d._0.summary))}}var _={};mu(_,{BRAND:()=>J$,DIRTY:()=>_i,EMPTY_PATH:()=>$$,INVALID:()=>W,NEVER:()=>PE,OK:()=>Tt,ParseStatus:()=>ht,Schema:()=>ne,ZodAny:()=>Dn,ZodArray:()=>fn,ZodBigInt:()=>vi,ZodBoolean:()=>bi,ZodBranded:()=>$s,ZodCatch:()=>Pi,ZodDate:()=>wi,ZodDefault:()=>Oi,ZodDiscriminatedUnion:()=>xc,ZodEffects:()=>lr,ZodEnum:()=>zi,ZodError:()=>Ft,ZodFirstPartyTypeKind:()=>E,ZodFunction:()=>Tc,ZodIntersection:()=>Ti,ZodIssueCode:()=>T,ZodLazy:()=>$i,ZodLiteral:()=>Ei,ZodMap:()=>To,ZodNaN:()=>Eo,ZodNativeEnum:()=>Ai,ZodNever:()=>Tr,ZodNull:()=>xi,ZodNullable:()=>Wr,ZodNumber:()=>yi,ZodObject:()=>Lt,ZodOptional:()=>qt,ZodParsedType:()=>P,ZodPipeline:()=>Es,ZodPromise:()=>Gn,ZodReadonly:()=>Ci,ZodRecord:()=>Sc,ZodSchema:()=>ne,ZodSet:()=>$o,ZodString:()=>Mn,ZodSymbol:()=>xo,ZodTransformer:()=>lr,ZodTuple:()=>Br,ZodType:()=>ne,ZodUndefined:()=>ki,ZodUnion:()=>Si,ZodUnknown:()=>dn,ZodVoid:()=>So,addIssueToContext:()=>O,any:()=>nE,array:()=>aE,bigint:()=>X$,boolean:()=>Xy,coerce:()=>OE,custom:()=>Hy,date:()=>Y$,datetimeRegex:()=>Wy,defaultErrorMap:()=>ln,discriminatedUnion:()=>uE,effect:()=>kE,enum:()=>vE,function:()=>gE,getErrorMap:()=>bo,getParsedType:()=>Vr,instanceof:()=>K$,intersection:()=>dE,isAborted:()=>wc,isAsync:()=>wo,isDirty:()=>kc,isValid:()=>Nn,late:()=>H$,lazy:()=>_E,literal:()=>yE,makeIssue:()=>Ts,map:()=>pE,nan:()=>Q$,nativeEnum:()=>bE,never:()=>oE,null:()=>rE,nullable:()=>SE,number:()=>Qy,object:()=>bd,objectUtil:()=>_d,oboolean:()=>AE,onumber:()=>zE,optional:()=>xE,ostring:()=>EE,pipeline:()=>$E,preprocess:()=>TE,promise:()=>wE,quotelessJson:()=>x$,record:()=>mE,set:()=>hE,setErrorMap:()=>T$,strictObject:()=>cE,string:()=>Ky,symbol:()=>eE,transformer:()=>kE,tuple:()=>fE,undefined:()=>tE,union:()=>lE,unknown:()=>iE,util:()=>ae,void:()=>sE});var ae;(function(e){e.assertEqual=i=>{};function t(i){}e.assertIs=t;function r(i){throw new Error}e.assertNever=r,e.arrayToEnum=i=>{let o={};for(let s of i)o[s]=s;return o},e.getValidEnumValues=i=>{let o=e.objectKeys(i).filter(a=>typeof i[i[a]]!="number"),s={};for(let a of o)s[a]=i[a];return e.objectValues(s)},e.objectValues=i=>e.objectKeys(i).map(function(o){return i[o]}),e.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{let o=[];for(let s in i)Object.prototype.hasOwnProperty.call(i,s)&&o.push(s);return o},e.find=(i,o)=>{for(let s of i)if(o(s))return s},e.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&Number.isFinite(i)&&Math.floor(i)===i;function n(i,o=" | "){return i.map(s=>typeof s=="string"?`'${s}'`:s).join(o)}e.joinValues=n,e.jsonStringifyReplacer=(i,o)=>typeof o=="bigint"?o.toString():o})(ae||(ae={}));var _d;(function(e){e.mergeShapes=(t,r)=>({...t,...r})})(_d||(_d={}));var P=ae.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Vr=e=>{switch(typeof e){case"undefined":return P.undefined;case"string":return P.string;case"number":return Number.isNaN(e)?P.nan:P.number;case"boolean":return P.boolean;case"function":return P.function;case"bigint":return P.bigint;case"symbol":return P.symbol;case"object":return Array.isArray(e)?P.array:e===null?P.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?P.promise:typeof Map<"u"&&e instanceof Map?P.map:typeof Set<"u"&&e instanceof Set?P.set:typeof Date<"u"&&e instanceof Date?P.date:P.object;default:return P.unknown}};var T=ae.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),x$=e=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:"),Ft=class e extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};let r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=t}format(t){let r=t||function(o){return o.message},n={_errors:[]},i=o=>{for(let s of o.issues)if(s.code==="invalid_union")s.unionErrors.map(i);else if(s.code==="invalid_return_type")i(s.returnTypeError);else if(s.code==="invalid_arguments")i(s.argumentsError);else if(s.path.length===0)n._errors.push(r(s));else{let a=n,u=0;for(;u<s.path.length;){let c=s.path[u];u===s.path.length-1?(a[c]=a[c]||{_errors:[]},a[c]._errors.push(r(s))):a[c]=a[c]||{_errors:[]},a=a[c],u++}}};return i(this),n}static assert(t){if(!(t instanceof e))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,ae.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=r=>r.message){let r={},n=[];for(let i of this.issues)if(i.path.length>0){let o=i.path[0];r[o]=r[o]||[],r[o].push(t(i))}else n.push(t(i));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}};Ft.create=e=>new Ft(e);var S$=(e,t)=>{let r;switch(e.code){case T.invalid_type:e.received===P.undefined?r="Required":r=`Expected ${e.expected}, received ${e.received}`;break;case T.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(e.expected,ae.jsonStringifyReplacer)}`;break;case T.unrecognized_keys:r=`Unrecognized key(s) in object: ${ae.joinValues(e.keys,", ")}`;break;case T.invalid_union:r="Invalid input";break;case T.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${ae.joinValues(e.options)}`;break;case T.invalid_enum_value:r=`Invalid enum value. Expected ${ae.joinValues(e.options)}, received '${e.received}'`;break;case T.invalid_arguments:r="Invalid function arguments";break;case T.invalid_return_type:r="Invalid function return type";break;case T.invalid_date:r="Invalid date";break;case T.invalid_string:typeof e.validation=="object"?"includes"in e.validation?(r=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?r=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?r=`Invalid input: must end with "${e.validation.endsWith}"`:ae.assertNever(e.validation):e.validation!=="regex"?r=`Invalid ${e.validation}`:r="Invalid";break;case T.too_small:e.type==="array"?r=`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:e.type==="string"?r=`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:e.type==="number"?r=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="bigint"?r=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="date"?r=`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:r="Invalid input";break;case T.too_big:e.type==="array"?r=`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:e.type==="string"?r=`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:e.type==="number"?r=`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="bigint"?r=`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="date"?r=`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:r="Invalid input";break;case T.custom:r="Invalid input";break;case T.invalid_intersection_types:r="Intersection results could not be merged";break;case T.not_multiple_of:r=`Number must be a multiple of ${e.multipleOf}`;break;case T.not_finite:r="Number must be finite";break;default:r=t.defaultError,ae.assertNever(e)}return{message:r}},ln=S$;var qy=ln;function T$(e){qy=e}function bo(){return qy}var Ts=e=>{let{data:t,path:r,errorMaps:n,issueData:i}=e,o=[...r,...i.path||[]],s={...i,path:o};if(i.message!==void 0)return{...i,path:o,message:i.message};let a="",u=n.filter(c=>!!c).slice().reverse();for(let c of u)a=c(s,{data:t,defaultError:a}).message;return{...i,path:o,message:a}},$$=[];function O(e,t){let r=bo(),n=Ts({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,r,r===ln?void 0:ln].filter(i=>!!i)});e.common.issues.push(n)}var ht=class e{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,r){let n=[];for(let i of r){if(i.status==="aborted")return W;i.status==="dirty"&&t.dirty(),n.push(i.value)}return{status:t.value,value:n}}static async mergeObjectAsync(t,r){let n=[];for(let i of r){let o=await i.key,s=await i.value;n.push({key:o,value:s})}return e.mergeObjectSync(t,n)}static mergeObjectSync(t,r){let n={};for(let i of r){let{key:o,value:s}=i;if(o.status==="aborted"||s.status==="aborted")return W;o.status==="dirty"&&t.dirty(),s.status==="dirty"&&t.dirty(),o.value!=="__proto__"&&(typeof s.value<"u"||i.alwaysSet)&&(n[o.value]=s.value)}return{status:t.value,value:n}}},W=Object.freeze({status:"aborted"}),_i=e=>({status:"dirty",value:e}),Tt=e=>({status:"valid",value:e}),wc=e=>e.status==="aborted",kc=e=>e.status==="dirty",Nn=e=>e.status==="valid",wo=e=>typeof Promise<"u"&&e instanceof Promise;var Z;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t?.message})(Z||(Z={}));var cr=class{constructor(t,r,n,i){this._cachedPath=[],this.parent=t,this.data=r,this._path=n,this._key=i}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},Ly=(e,t)=>{if(Nn(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let r=new Ft(e.common.issues);return this._error=r,this._error}}};function ee(e){if(!e)return{};let{errorMap:t,invalid_type_error:r,required_error:n,description:i}=e;if(t&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:i}:{errorMap:(s,a)=>{let{message:u}=e;return s.code==="invalid_enum_value"?{message:u??a.defaultError}:typeof a.data>"u"?{message:u??n??a.defaultError}:s.code!=="invalid_type"?{message:a.defaultError}:{message:u??r??a.defaultError}},description:i}}var ne=class{get description(){return this._def.description}_getType(t){return Vr(t.data)}_getOrReturnCtx(t,r){return r||{common:t.parent.common,data:t.data,parsedType:Vr(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new ht,ctx:{common:t.parent.common,data:t.data,parsedType:Vr(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){let r=this._parse(t);if(wo(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(t){let r=this._parse(t);return Promise.resolve(r)}parse(t,r){let n=this.safeParse(t,r);if(n.success)return n.data;throw n.error}safeParse(t,r){let n={common:{issues:[],async:r?.async??!1,contextualErrorMap:r?.errorMap},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Vr(t)},i=this._parseSync({data:t,path:n.path,parent:n});return Ly(n,i)}"~validate"(t){let r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Vr(t)};if(!this["~standard"].async)try{let n=this._parseSync({data:t,path:[],parent:r});return Nn(n)?{value:n.value}:{issues:r.common.issues}}catch(n){n?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),r.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:r}).then(n=>Nn(n)?{value:n.value}:{issues:r.common.issues})}async parseAsync(t,r){let n=await this.safeParseAsync(t,r);if(n.success)return n.data;throw n.error}async safeParseAsync(t,r){let n={common:{issues:[],contextualErrorMap:r?.errorMap,async:!0},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Vr(t)},i=this._parse({data:t,path:n.path,parent:n}),o=await(wo(i)?i:Promise.resolve(i));return Ly(n,o)}refine(t,r){let n=i=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(i):r;return this._refinement((i,o)=>{let s=t(i),a=()=>o.addIssue({code:T.custom,...n(i)});return typeof Promise<"u"&&s instanceof Promise?s.then(u=>u?!0:(a(),!1)):s?!0:(a(),!1)})}refinement(t,r){return this._refinement((n,i)=>t(n)?!0:(i.addIssue(typeof r=="function"?r(n,i):r),!1))}_refinement(t){return new lr({schema:this,typeName:E.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}constructor(t){this.spa=this.safeParseAsync,this._def=t,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:r=>this["~validate"](r)}}optional(){return qt.create(this,this._def)}nullable(){return Wr.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return fn.create(this)}promise(){return Gn.create(this,this._def)}or(t){return Si.create([this,t],this._def)}and(t){return Ti.create(this,t,this._def)}transform(t){return new lr({...ee(this._def),schema:this,typeName:E.ZodEffects,effect:{type:"transform",transform:t}})}default(t){let r=typeof t=="function"?t:()=>t;return new Oi({...ee(this._def),innerType:this,defaultValue:r,typeName:E.ZodDefault})}brand(){return new $s({typeName:E.ZodBranded,type:this,...ee(this._def)})}catch(t){let r=typeof t=="function"?t:()=>t;return new Pi({...ee(this._def),innerType:this,catchValue:r,typeName:E.ZodCatch})}describe(t){let r=this.constructor;return new r({...this._def,description:t})}pipe(t){return Es.create(this,t)}readonly(){return Ci.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},E$=/^c[^\s-]{8,}$/i,z$=/^[0-9a-z]+$/,A$=/^[0-9A-HJKMNP-TV-Z]{26}$/i,O$=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,P$=/^[a-z0-9_-]{21}$/i,C$=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,R$=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,I$=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,j$="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",yd,N$=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,M$=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,D$=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,G$=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Z$=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,F$=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Vy="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",q$=new RegExp(`^${Vy}$`);function By(e){let t="[0-5]\\d";e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision==null&&(t=`${t}(\\.\\d+)?`);let r=e.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${r}`}function L$(e){return new RegExp(`^${By(e)}$`)}function Wy(e){let t=`${Vy}T${By(e)}`,r=[];return r.push(e.local?"Z?":"Z"),e.offset&&r.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${r.join("|")})`,new RegExp(`^${t}$`)}function U$(e,t){return!!((t==="v4"||!t)&&N$.test(e)||(t==="v6"||!t)&&D$.test(e))}function V$(e,t){if(!C$.test(e))return!1;try{let[r]=e.split(".");if(!r)return!1;let n=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),i=JSON.parse(atob(n));return!(typeof i!="object"||i===null||"typ"in i&&i?.typ!=="JWT"||!i.alg||t&&i.alg!==t)}catch{return!1}}function B$(e,t){return!!((t==="v4"||!t)&&M$.test(e)||(t==="v6"||!t)&&G$.test(e))}var Mn=class e extends ne{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==P.string){let o=this._getOrReturnCtx(t);return O(o,{code:T.invalid_type,expected:P.string,received:o.parsedType}),W}let n=new ht,i;for(let o of this._def.checks)if(o.kind==="min")t.data.length<o.value&&(i=this._getOrReturnCtx(t,i),O(i,{code:T.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),n.dirty());else if(o.kind==="max")t.data.length>o.value&&(i=this._getOrReturnCtx(t,i),O(i,{code:T.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),n.dirty());else if(o.kind==="length"){let s=t.data.length>o.value,a=t.data.length<o.value;(s||a)&&(i=this._getOrReturnCtx(t,i),s?O(i,{code:T.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}):a&&O(i,{code:T.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}),n.dirty())}else if(o.kind==="email")I$.test(t.data)||(i=this._getOrReturnCtx(t,i),O(i,{validation:"email",code:T.invalid_string,message:o.message}),n.dirty());else if(o.kind==="emoji")yd||(yd=new RegExp(j$,"u")),yd.test(t.data)||(i=this._getOrReturnCtx(t,i),O(i,{validation:"emoji",code:T.invalid_string,message:o.message}),n.dirty());else if(o.kind==="uuid")O$.test(t.data)||(i=this._getOrReturnCtx(t,i),O(i,{validation:"uuid",code:T.invalid_string,message:o.message}),n.dirty());else if(o.kind==="nanoid")P$.test(t.data)||(i=this._getOrReturnCtx(t,i),O(i,{validation:"nanoid",code:T.invalid_string,message:o.message}),n.dirty());else if(o.kind==="cuid")E$.test(t.data)||(i=this._getOrReturnCtx(t,i),O(i,{validation:"cuid",code:T.invalid_string,message:o.message}),n.dirty());else if(o.kind==="cuid2")z$.test(t.data)||(i=this._getOrReturnCtx(t,i),O(i,{validation:"cuid2",code:T.invalid_string,message:o.message}),n.dirty());else if(o.kind==="ulid")A$.test(t.data)||(i=this._getOrReturnCtx(t,i),O(i,{validation:"ulid",code:T.invalid_string,message:o.message}),n.dirty());else if(o.kind==="url")try{new URL(t.data)}catch{i=this._getOrReturnCtx(t,i),O(i,{validation:"url",code:T.invalid_string,message:o.message}),n.dirty()}else o.kind==="regex"?(o.regex.lastIndex=0,o.regex.test(t.data)||(i=this._getOrReturnCtx(t,i),O(i,{validation:"regex",code:T.invalid_string,message:o.message}),n.dirty())):o.kind==="trim"?t.data=t.data.trim():o.kind==="includes"?t.data.includes(o.value,o.position)||(i=this._getOrReturnCtx(t,i),O(i,{code:T.invalid_string,validation:{includes:o.value,position:o.position},message:o.message}),n.dirty()):o.kind==="toLowerCase"?t.data=t.data.toLowerCase():o.kind==="toUpperCase"?t.data=t.data.toUpperCase():o.kind==="startsWith"?t.data.startsWith(o.value)||(i=this._getOrReturnCtx(t,i),O(i,{code:T.invalid_string,validation:{startsWith:o.value},message:o.message}),n.dirty()):o.kind==="endsWith"?t.data.endsWith(o.value)||(i=this._getOrReturnCtx(t,i),O(i,{code:T.invalid_string,validation:{endsWith:o.value},message:o.message}),n.dirty()):o.kind==="datetime"?Wy(o).test(t.data)||(i=this._getOrReturnCtx(t,i),O(i,{code:T.invalid_string,validation:"datetime",message:o.message}),n.dirty()):o.kind==="date"?q$.test(t.data)||(i=this._getOrReturnCtx(t,i),O(i,{code:T.invalid_string,validation:"date",message:o.message}),n.dirty()):o.kind==="time"?L$(o).test(t.data)||(i=this._getOrReturnCtx(t,i),O(i,{code:T.invalid_string,validation:"time",message:o.message}),n.dirty()):o.kind==="duration"?R$.test(t.data)||(i=this._getOrReturnCtx(t,i),O(i,{validation:"duration",code:T.invalid_string,message:o.message}),n.dirty()):o.kind==="ip"?U$(t.data,o.version)||(i=this._getOrReturnCtx(t,i),O(i,{validation:"ip",code:T.invalid_string,message:o.message}),n.dirty()):o.kind==="jwt"?V$(t.data,o.alg)||(i=this._getOrReturnCtx(t,i),O(i,{validation:"jwt",code:T.invalid_string,message:o.message}),n.dirty()):o.kind==="cidr"?B$(t.data,o.version)||(i=this._getOrReturnCtx(t,i),O(i,{validation:"cidr",code:T.invalid_string,message:o.message}),n.dirty()):o.kind==="base64"?Z$.test(t.data)||(i=this._getOrReturnCtx(t,i),O(i,{validation:"base64",code:T.invalid_string,message:o.message}),n.dirty()):o.kind==="base64url"?F$.test(t.data)||(i=this._getOrReturnCtx(t,i),O(i,{validation:"base64url",code:T.invalid_string,message:o.message}),n.dirty()):ae.assertNever(o);return{status:n.value,value:t.data}}_regex(t,r,n){return this.refinement(i=>t.test(i),{validation:r,code:T.invalid_string,...Z.errToObj(n)})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...Z.errToObj(t)})}url(t){return this._addCheck({kind:"url",...Z.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...Z.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...Z.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...Z.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...Z.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...Z.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...Z.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...Z.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...Z.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...Z.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...Z.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...Z.errToObj(t)})}datetime(t){return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:t}):this._addCheck({kind:"datetime",precision:typeof t?.precision>"u"?null:t?.precision,offset:t?.offset??!1,local:t?.local??!1,...Z.errToObj(t?.message)})}date(t){return this._addCheck({kind:"date",message:t})}time(t){return typeof t=="string"?this._addCheck({kind:"time",precision:null,message:t}):this._addCheck({kind:"time",precision:typeof t?.precision>"u"?null:t?.precision,...Z.errToObj(t?.message)})}duration(t){return this._addCheck({kind:"duration",...Z.errToObj(t)})}regex(t,r){return this._addCheck({kind:"regex",regex:t,...Z.errToObj(r)})}includes(t,r){return this._addCheck({kind:"includes",value:t,position:r?.position,...Z.errToObj(r?.message)})}startsWith(t,r){return this._addCheck({kind:"startsWith",value:t,...Z.errToObj(r)})}endsWith(t,r){return this._addCheck({kind:"endsWith",value:t,...Z.errToObj(r)})}min(t,r){return this._addCheck({kind:"min",value:t,...Z.errToObj(r)})}max(t,r){return this._addCheck({kind:"max",value:t,...Z.errToObj(r)})}length(t,r){return this._addCheck({kind:"length",value:t,...Z.errToObj(r)})}nonempty(t){return this.min(1,Z.errToObj(t))}trim(){return new e({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new e({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new e({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(t=>t.kind==="datetime")}get isDate(){return!!this._def.checks.find(t=>t.kind==="date")}get isTime(){return!!this._def.checks.find(t=>t.kind==="time")}get isDuration(){return!!this._def.checks.find(t=>t.kind==="duration")}get isEmail(){return!!this._def.checks.find(t=>t.kind==="email")}get isURL(){return!!this._def.checks.find(t=>t.kind==="url")}get isEmoji(){return!!this._def.checks.find(t=>t.kind==="emoji")}get isUUID(){return!!this._def.checks.find(t=>t.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(t=>t.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(t=>t.kind==="cuid2")}get isULID(){return!!this._def.checks.find(t=>t.kind==="ulid")}get isIP(){return!!this._def.checks.find(t=>t.kind==="ip")}get isCIDR(){return!!this._def.checks.find(t=>t.kind==="cidr")}get isBase64(){return!!this._def.checks.find(t=>t.kind==="base64")}get isBase64url(){return!!this._def.checks.find(t=>t.kind==="base64url")}get minLength(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxLength(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}};Mn.create=e=>new Mn({checks:[],typeName:E.ZodString,coerce:e?.coerce??!1,...ee(e)});function W$(e,t){let r=(e.toString().split(".")[1]||"").length,n=(t.toString().split(".")[1]||"").length,i=r>n?r:n,o=Number.parseInt(e.toFixed(i).replace(".","")),s=Number.parseInt(t.toFixed(i).replace(".",""));return o%s/10**i}var yi=class e extends ne{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==P.number){let o=this._getOrReturnCtx(t);return O(o,{code:T.invalid_type,expected:P.number,received:o.parsedType}),W}let n,i=new ht;for(let o of this._def.checks)o.kind==="int"?ae.isInteger(t.data)||(n=this._getOrReturnCtx(t,n),O(n,{code:T.invalid_type,expected:"integer",received:"float",message:o.message}),i.dirty()):o.kind==="min"?(o.inclusive?t.data<o.value:t.data<=o.value)&&(n=this._getOrReturnCtx(t,n),O(n,{code:T.too_small,minimum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),i.dirty()):o.kind==="max"?(o.inclusive?t.data>o.value:t.data>=o.value)&&(n=this._getOrReturnCtx(t,n),O(n,{code:T.too_big,maximum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),i.dirty()):o.kind==="multipleOf"?W$(t.data,o.value)!==0&&(n=this._getOrReturnCtx(t,n),O(n,{code:T.not_multiple_of,multipleOf:o.value,message:o.message}),i.dirty()):o.kind==="finite"?Number.isFinite(t.data)||(n=this._getOrReturnCtx(t,n),O(n,{code:T.not_finite,message:o.message}),i.dirty()):ae.assertNever(o);return{status:i.value,value:t.data}}gte(t,r){return this.setLimit("min",t,!0,Z.toString(r))}gt(t,r){return this.setLimit("min",t,!1,Z.toString(r))}lte(t,r){return this.setLimit("max",t,!0,Z.toString(r))}lt(t,r){return this.setLimit("max",t,!1,Z.toString(r))}setLimit(t,r,n,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:n,message:Z.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:Z.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Z.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Z.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Z.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Z.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:Z.toString(r)})}finite(t){return this._addCheck({kind:"finite",message:Z.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Z.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Z.toString(t)})}get minValue(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxValue(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&ae.isInteger(t.value))}get isFinite(){let t=null,r=null;for(let n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(r===null||n.value>r)&&(r=n.value):n.kind==="max"&&(t===null||n.value<t)&&(t=n.value)}return Number.isFinite(r)&&Number.isFinite(t)}};yi.create=e=>new yi({checks:[],typeName:E.ZodNumber,coerce:e?.coerce||!1,...ee(e)});var vi=class e extends ne{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce)try{t.data=BigInt(t.data)}catch{return this._getInvalidInput(t)}if(this._getType(t)!==P.bigint)return this._getInvalidInput(t);let n,i=new ht;for(let o of this._def.checks)o.kind==="min"?(o.inclusive?t.data<o.value:t.data<=o.value)&&(n=this._getOrReturnCtx(t,n),O(n,{code:T.too_small,type:"bigint",minimum:o.value,inclusive:o.inclusive,message:o.message}),i.dirty()):o.kind==="max"?(o.inclusive?t.data>o.value:t.data>=o.value)&&(n=this._getOrReturnCtx(t,n),O(n,{code:T.too_big,type:"bigint",maximum:o.value,inclusive:o.inclusive,message:o.message}),i.dirty()):o.kind==="multipleOf"?t.data%o.value!==BigInt(0)&&(n=this._getOrReturnCtx(t,n),O(n,{code:T.not_multiple_of,multipleOf:o.value,message:o.message}),i.dirty()):ae.assertNever(o);return{status:i.value,value:t.data}}_getInvalidInput(t){let r=this._getOrReturnCtx(t);return O(r,{code:T.invalid_type,expected:P.bigint,received:r.parsedType}),W}gte(t,r){return this.setLimit("min",t,!0,Z.toString(r))}gt(t,r){return this.setLimit("min",t,!1,Z.toString(r))}lte(t,r){return this.setLimit("max",t,!0,Z.toString(r))}lt(t,r){return this.setLimit("max",t,!1,Z.toString(r))}setLimit(t,r,n,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:n,message:Z.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Z.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Z.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Z.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Z.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:Z.toString(r)})}get minValue(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxValue(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}};vi.create=e=>new vi({checks:[],typeName:E.ZodBigInt,coerce:e?.coerce??!1,...ee(e)});var bi=class extends ne{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==P.boolean){let n=this._getOrReturnCtx(t);return O(n,{code:T.invalid_type,expected:P.boolean,received:n.parsedType}),W}return Tt(t.data)}};bi.create=e=>new bi({typeName:E.ZodBoolean,coerce:e?.coerce||!1,...ee(e)});var wi=class e extends ne{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==P.date){let o=this._getOrReturnCtx(t);return O(o,{code:T.invalid_type,expected:P.date,received:o.parsedType}),W}if(Number.isNaN(t.data.getTime())){let o=this._getOrReturnCtx(t);return O(o,{code:T.invalid_date}),W}let n=new ht,i;for(let o of this._def.checks)o.kind==="min"?t.data.getTime()<o.value&&(i=this._getOrReturnCtx(t,i),O(i,{code:T.too_small,message:o.message,inclusive:!0,exact:!1,minimum:o.value,type:"date"}),n.dirty()):o.kind==="max"?t.data.getTime()>o.value&&(i=this._getOrReturnCtx(t,i),O(i,{code:T.too_big,message:o.message,inclusive:!0,exact:!1,maximum:o.value,type:"date"}),n.dirty()):ae.assertNever(o);return{status:n.value,value:new Date(t.data.getTime())}}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}min(t,r){return this._addCheck({kind:"min",value:t.getTime(),message:Z.toString(r)})}max(t,r){return this._addCheck({kind:"max",value:t.getTime(),message:Z.toString(r)})}get minDate(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t!=null?new Date(t):null}};wi.create=e=>new wi({checks:[],coerce:e?.coerce||!1,typeName:E.ZodDate,...ee(e)});var xo=class extends ne{_parse(t){if(this._getType(t)!==P.symbol){let n=this._getOrReturnCtx(t);return O(n,{code:T.invalid_type,expected:P.symbol,received:n.parsedType}),W}return Tt(t.data)}};xo.create=e=>new xo({typeName:E.ZodSymbol,...ee(e)});var ki=class extends ne{_parse(t){if(this._getType(t)!==P.undefined){let n=this._getOrReturnCtx(t);return O(n,{code:T.invalid_type,expected:P.undefined,received:n.parsedType}),W}return Tt(t.data)}};ki.create=e=>new ki({typeName:E.ZodUndefined,...ee(e)});var xi=class extends ne{_parse(t){if(this._getType(t)!==P.null){let n=this._getOrReturnCtx(t);return O(n,{code:T.invalid_type,expected:P.null,received:n.parsedType}),W}return Tt(t.data)}};xi.create=e=>new xi({typeName:E.ZodNull,...ee(e)});var Dn=class extends ne{constructor(){super(...arguments),this._any=!0}_parse(t){return Tt(t.data)}};Dn.create=e=>new Dn({typeName:E.ZodAny,...ee(e)});var dn=class extends ne{constructor(){super(...arguments),this._unknown=!0}_parse(t){return Tt(t.data)}};dn.create=e=>new dn({typeName:E.ZodUnknown,...ee(e)});var Tr=class extends ne{_parse(t){let r=this._getOrReturnCtx(t);return O(r,{code:T.invalid_type,expected:P.never,received:r.parsedType}),W}};Tr.create=e=>new Tr({typeName:E.ZodNever,...ee(e)});var So=class extends ne{_parse(t){if(this._getType(t)!==P.undefined){let n=this._getOrReturnCtx(t);return O(n,{code:T.invalid_type,expected:P.void,received:n.parsedType}),W}return Tt(t.data)}};So.create=e=>new So({typeName:E.ZodVoid,...ee(e)});var fn=class e extends ne{_parse(t){let{ctx:r,status:n}=this._processInputParams(t),i=this._def;if(r.parsedType!==P.array)return O(r,{code:T.invalid_type,expected:P.array,received:r.parsedType}),W;if(i.exactLength!==null){let s=r.data.length>i.exactLength.value,a=r.data.length<i.exactLength.value;(s||a)&&(O(r,{code:s?T.too_big:T.too_small,minimum:a?i.exactLength.value:void 0,maximum:s?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),n.dirty())}if(i.minLength!==null&&r.data.length<i.minLength.value&&(O(r,{code:T.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),n.dirty()),i.maxLength!==null&&r.data.length>i.maxLength.value&&(O(r,{code:T.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((s,a)=>i.type._parseAsync(new cr(r,s,r.path,a)))).then(s=>ht.mergeArray(n,s));let o=[...r.data].map((s,a)=>i.type._parseSync(new cr(r,s,r.path,a)));return ht.mergeArray(n,o)}get element(){return this._def.type}min(t,r){return new e({...this._def,minLength:{value:t,message:Z.toString(r)}})}max(t,r){return new e({...this._def,maxLength:{value:t,message:Z.toString(r)}})}length(t,r){return new e({...this._def,exactLength:{value:t,message:Z.toString(r)}})}nonempty(t){return this.min(1,t)}};fn.create=(e,t)=>new fn({type:e,minLength:null,maxLength:null,exactLength:null,typeName:E.ZodArray,...ee(t)});function ko(e){if(e instanceof Lt){let t={};for(let r in e.shape){let n=e.shape[r];t[r]=qt.create(ko(n))}return new Lt({...e._def,shape:()=>t})}else return e instanceof fn?new fn({...e._def,type:ko(e.element)}):e instanceof qt?qt.create(ko(e.unwrap())):e instanceof Wr?Wr.create(ko(e.unwrap())):e instanceof Br?Br.create(e.items.map(t=>ko(t))):e}var Lt=class e extends ne{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let t=this._def.shape(),r=ae.objectKeys(t);return this._cached={shape:t,keys:r},this._cached}_parse(t){if(this._getType(t)!==P.object){let c=this._getOrReturnCtx(t);return O(c,{code:T.invalid_type,expected:P.object,received:c.parsedType}),W}let{status:n,ctx:i}=this._processInputParams(t),{shape:o,keys:s}=this._getCached(),a=[];if(!(this._def.catchall instanceof Tr&&this._def.unknownKeys==="strip"))for(let c in i.data)s.includes(c)||a.push(c);let u=[];for(let c of s){let l=o[c],d=i.data[c];u.push({key:{status:"valid",value:c},value:l._parse(new cr(i,d,i.path,c)),alwaysSet:c in i.data})}if(this._def.catchall instanceof Tr){let c=this._def.unknownKeys;if(c==="passthrough")for(let l of a)u.push({key:{status:"valid",value:l},value:{status:"valid",value:i.data[l]}});else if(c==="strict")a.length>0&&(O(i,{code:T.unrecognized_keys,keys:a}),n.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let c=this._def.catchall;for(let l of a){let d=i.data[l];u.push({key:{status:"valid",value:l},value:c._parse(new cr(i,d,i.path,l)),alwaysSet:l in i.data})}}return i.common.async?Promise.resolve().then(async()=>{let c=[];for(let l of u){let d=await l.key,p=await l.value;c.push({key:d,value:p,alwaysSet:l.alwaysSet})}return c}).then(c=>ht.mergeObjectSync(n,c)):ht.mergeObjectSync(n,u)}get shape(){return this._def.shape()}strict(t){return Z.errToObj,new e({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(r,n)=>{let i=this._def.errorMap?.(r,n).message??n.defaultError;return r.code==="unrecognized_keys"?{message:Z.errToObj(t).message??i}:{message:i}}}:{}})}strip(){return new e({...this._def,unknownKeys:"strip"})}passthrough(){return new e({...this._def,unknownKeys:"passthrough"})}extend(t){return new e({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new e({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:E.ZodObject})}setKey(t,r){return this.augment({[t]:r})}catchall(t){return new e({...this._def,catchall:t})}pick(t){let r={};for(let n of ae.objectKeys(t))t[n]&&this.shape[n]&&(r[n]=this.shape[n]);return new e({...this._def,shape:()=>r})}omit(t){let r={};for(let n of ae.objectKeys(this.shape))t[n]||(r[n]=this.shape[n]);return new e({...this._def,shape:()=>r})}deepPartial(){return ko(this)}partial(t){let r={};for(let n of ae.objectKeys(this.shape)){let i=this.shape[n];t&&!t[n]?r[n]=i:r[n]=i.optional()}return new e({...this._def,shape:()=>r})}required(t){let r={};for(let n of ae.objectKeys(this.shape))if(t&&!t[n])r[n]=this.shape[n];else{let o=this.shape[n];for(;o instanceof qt;)o=o._def.innerType;r[n]=o}return new e({...this._def,shape:()=>r})}keyof(){return Jy(ae.objectKeys(this.shape))}};Lt.create=(e,t)=>new Lt({shape:()=>e,unknownKeys:"strip",catchall:Tr.create(),typeName:E.ZodObject,...ee(t)});Lt.strictCreate=(e,t)=>new Lt({shape:()=>e,unknownKeys:"strict",catchall:Tr.create(),typeName:E.ZodObject,...ee(t)});Lt.lazycreate=(e,t)=>new Lt({shape:e,unknownKeys:"strip",catchall:Tr.create(),typeName:E.ZodObject,...ee(t)});var Si=class extends ne{_parse(t){let{ctx:r}=this._processInputParams(t),n=this._def.options;function i(o){for(let a of o)if(a.result.status==="valid")return a.result;for(let a of o)if(a.result.status==="dirty")return r.common.issues.push(...a.ctx.common.issues),a.result;let s=o.map(a=>new Ft(a.ctx.common.issues));return O(r,{code:T.invalid_union,unionErrors:s}),W}if(r.common.async)return Promise.all(n.map(async o=>{let s={...r,common:{...r.common,issues:[]},parent:null};return{result:await o._parseAsync({data:r.data,path:r.path,parent:s}),ctx:s}})).then(i);{let o,s=[];for(let u of n){let c={...r,common:{...r.common,issues:[]},parent:null},l=u._parseSync({data:r.data,path:r.path,parent:c});if(l.status==="valid")return l;l.status==="dirty"&&!o&&(o={result:l,ctx:c}),c.common.issues.length&&s.push(c.common.issues)}if(o)return r.common.issues.push(...o.ctx.common.issues),o.result;let a=s.map(u=>new Ft(u));return O(r,{code:T.invalid_union,unionErrors:a}),W}}get options(){return this._def.options}};Si.create=(e,t)=>new Si({options:e,typeName:E.ZodUnion,...ee(t)});var un=e=>e instanceof $i?un(e.schema):e instanceof lr?un(e.innerType()):e instanceof Ei?[e.value]:e instanceof zi?e.options:e instanceof Ai?ae.objectValues(e.enum):e instanceof Oi?un(e._def.innerType):e instanceof ki?[void 0]:e instanceof xi?[null]:e instanceof qt?[void 0,...un(e.unwrap())]:e instanceof Wr?[null,...un(e.unwrap())]:e instanceof $s||e instanceof Ci?un(e.unwrap()):e instanceof Pi?un(e._def.innerType):[],xc=class e extends ne{_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==P.object)return O(r,{code:T.invalid_type,expected:P.object,received:r.parsedType}),W;let n=this.discriminator,i=r.data[n],o=this.optionsMap.get(i);return o?r.common.async?o._parseAsync({data:r.data,path:r.path,parent:r}):o._parseSync({data:r.data,path:r.path,parent:r}):(O(r,{code:T.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),W)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,r,n){let i=new Map;for(let o of r){let s=un(o.shape[t]);if(!s.length)throw new Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(let a of s){if(i.has(a))throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(a)}`);i.set(a,o)}}return new e({typeName:E.ZodDiscriminatedUnion,discriminator:t,options:r,optionsMap:i,...ee(n)})}};function vd(e,t){let r=Vr(e),n=Vr(t);if(e===t)return{valid:!0,data:e};if(r===P.object&&n===P.object){let i=ae.objectKeys(t),o=ae.objectKeys(e).filter(a=>i.indexOf(a)!==-1),s={...e,...t};for(let a of o){let u=vd(e[a],t[a]);if(!u.valid)return{valid:!1};s[a]=u.data}return{valid:!0,data:s}}else if(r===P.array&&n===P.array){if(e.length!==t.length)return{valid:!1};let i=[];for(let o=0;o<e.length;o++){let s=e[o],a=t[o],u=vd(s,a);if(!u.valid)return{valid:!1};i.push(u.data)}return{valid:!0,data:i}}else return r===P.date&&n===P.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}var Ti=class extends ne{_parse(t){let{status:r,ctx:n}=this._processInputParams(t),i=(o,s)=>{if(wc(o)||wc(s))return W;let a=vd(o.value,s.value);return a.valid?((kc(o)||kc(s))&&r.dirty(),{status:r.value,value:a.data}):(O(n,{code:T.invalid_intersection_types}),W)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([o,s])=>i(o,s)):i(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};Ti.create=(e,t,r)=>new Ti({left:e,right:t,typeName:E.ZodIntersection,...ee(r)});var Br=class e extends ne{_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==P.array)return O(n,{code:T.invalid_type,expected:P.array,received:n.parsedType}),W;if(n.data.length<this._def.items.length)return O(n,{code:T.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),W;!this._def.rest&&n.data.length>this._def.items.length&&(O(n,{code:T.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let o=[...n.data].map((s,a)=>{let u=this._def.items[a]||this._def.rest;return u?u._parse(new cr(n,s,n.path,a)):null}).filter(s=>!!s);return n.common.async?Promise.all(o).then(s=>ht.mergeArray(r,s)):ht.mergeArray(r,o)}get items(){return this._def.items}rest(t){return new e({...this._def,rest:t})}};Br.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Br({items:e,typeName:E.ZodTuple,rest:null,...ee(t)})};var Sc=class e extends ne{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==P.object)return O(n,{code:T.invalid_type,expected:P.object,received:n.parsedType}),W;let i=[],o=this._def.keyType,s=this._def.valueType;for(let a in n.data)i.push({key:o._parse(new cr(n,a,n.path,a)),value:s._parse(new cr(n,n.data[a],n.path,a)),alwaysSet:a in n.data});return n.common.async?ht.mergeObjectAsync(r,i):ht.mergeObjectSync(r,i)}get element(){return this._def.valueType}static create(t,r,n){return r instanceof ne?new e({keyType:t,valueType:r,typeName:E.ZodRecord,...ee(n)}):new e({keyType:Mn.create(),valueType:t,typeName:E.ZodRecord,...ee(r)})}},To=class extends ne{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==P.map)return O(n,{code:T.invalid_type,expected:P.map,received:n.parsedType}),W;let i=this._def.keyType,o=this._def.valueType,s=[...n.data.entries()].map(([a,u],c)=>({key:i._parse(new cr(n,a,n.path,[c,"key"])),value:o._parse(new cr(n,u,n.path,[c,"value"]))}));if(n.common.async){let a=new Map;return Promise.resolve().then(async()=>{for(let u of s){let c=await u.key,l=await u.value;if(c.status==="aborted"||l.status==="aborted")return W;(c.status==="dirty"||l.status==="dirty")&&r.dirty(),a.set(c.value,l.value)}return{status:r.value,value:a}})}else{let a=new Map;for(let u of s){let c=u.key,l=u.value;if(c.status==="aborted"||l.status==="aborted")return W;(c.status==="dirty"||l.status==="dirty")&&r.dirty(),a.set(c.value,l.value)}return{status:r.value,value:a}}}};To.create=(e,t,r)=>new To({valueType:t,keyType:e,typeName:E.ZodMap,...ee(r)});var $o=class e extends ne{_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==P.set)return O(n,{code:T.invalid_type,expected:P.set,received:n.parsedType}),W;let i=this._def;i.minSize!==null&&n.data.size<i.minSize.value&&(O(n,{code:T.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),r.dirty()),i.maxSize!==null&&n.data.size>i.maxSize.value&&(O(n,{code:T.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),r.dirty());let o=this._def.valueType;function s(u){let c=new Set;for(let l of u){if(l.status==="aborted")return W;l.status==="dirty"&&r.dirty(),c.add(l.value)}return{status:r.value,value:c}}let a=[...n.data.values()].map((u,c)=>o._parse(new cr(n,u,n.path,c)));return n.common.async?Promise.all(a).then(u=>s(u)):s(a)}min(t,r){return new e({...this._def,minSize:{value:t,message:Z.toString(r)}})}max(t,r){return new e({...this._def,maxSize:{value:t,message:Z.toString(r)}})}size(t,r){return this.min(t,r).max(t,r)}nonempty(t){return this.min(1,t)}};$o.create=(e,t)=>new $o({valueType:e,minSize:null,maxSize:null,typeName:E.ZodSet,...ee(t)});var Tc=class e extends ne{constructor(){super(...arguments),this.validate=this.implement}_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==P.function)return O(r,{code:T.invalid_type,expected:P.function,received:r.parsedType}),W;function n(a,u){return Ts({data:a,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,bo(),ln].filter(c=>!!c),issueData:{code:T.invalid_arguments,argumentsError:u}})}function i(a,u){return Ts({data:a,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,bo(),ln].filter(c=>!!c),issueData:{code:T.invalid_return_type,returnTypeError:u}})}let o={errorMap:r.common.contextualErrorMap},s=r.data;if(this._def.returns instanceof Gn){let a=this;return Tt(async function(...u){let c=new Ft([]),l=await a._def.args.parseAsync(u,o).catch(f=>{throw c.addIssue(n(u,f)),c}),d=await Reflect.apply(s,this,l);return await a._def.returns._def.type.parseAsync(d,o).catch(f=>{throw c.addIssue(i(d,f)),c})})}else{let a=this;return Tt(function(...u){let c=a._def.args.safeParse(u,o);if(!c.success)throw new Ft([n(u,c.error)]);let l=Reflect.apply(s,this,c.data),d=a._def.returns.safeParse(l,o);if(!d.success)throw new Ft([i(l,d.error)]);return d.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new e({...this._def,args:Br.create(t).rest(dn.create())})}returns(t){return new e({...this._def,returns:t})}implement(t){return this.parse(t)}strictImplement(t){return this.parse(t)}static create(t,r,n){return new e({args:t||Br.create([]).rest(dn.create()),returns:r||dn.create(),typeName:E.ZodFunction,...ee(n)})}},$i=class extends ne{get schema(){return this._def.getter()}_parse(t){let{ctx:r}=this._processInputParams(t);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}};$i.create=(e,t)=>new $i({getter:e,typeName:E.ZodLazy,...ee(t)});var Ei=class extends ne{_parse(t){if(t.data!==this._def.value){let r=this._getOrReturnCtx(t);return O(r,{received:r.data,code:T.invalid_literal,expected:this._def.value}),W}return{status:"valid",value:t.data}}get value(){return this._def.value}};Ei.create=(e,t)=>new Ei({value:e,typeName:E.ZodLiteral,...ee(t)});function Jy(e,t){return new zi({values:e,typeName:E.ZodEnum,...ee(t)})}var zi=class e extends ne{_parse(t){if(typeof t.data!="string"){let r=this._getOrReturnCtx(t),n=this._def.values;return O(r,{expected:ae.joinValues(n),received:r.parsedType,code:T.invalid_type}),W}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(t.data)){let r=this._getOrReturnCtx(t),n=this._def.values;return O(r,{received:r.data,code:T.invalid_enum_value,options:n}),W}return Tt(t.data)}get options(){return this._def.values}get enum(){let t={};for(let r of this._def.values)t[r]=r;return t}get Values(){let t={};for(let r of this._def.values)t[r]=r;return t}get Enum(){let t={};for(let r of this._def.values)t[r]=r;return t}extract(t,r=this._def){return e.create(t,{...this._def,...r})}exclude(t,r=this._def){return e.create(this.options.filter(n=>!t.includes(n)),{...this._def,...r})}};zi.create=Jy;var Ai=class extends ne{_parse(t){let r=ae.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(t);if(n.parsedType!==P.string&&n.parsedType!==P.number){let i=ae.objectValues(r);return O(n,{expected:ae.joinValues(i),received:n.parsedType,code:T.invalid_type}),W}if(this._cache||(this._cache=new Set(ae.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){let i=ae.objectValues(r);return O(n,{received:n.data,code:T.invalid_enum_value,options:i}),W}return Tt(t.data)}get enum(){return this._def.values}};Ai.create=(e,t)=>new Ai({values:e,typeName:E.ZodNativeEnum,...ee(t)});var Gn=class extends ne{unwrap(){return this._def.type}_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==P.promise&&r.common.async===!1)return O(r,{code:T.invalid_type,expected:P.promise,received:r.parsedType}),W;let n=r.parsedType===P.promise?r.data:Promise.resolve(r.data);return Tt(n.then(i=>this._def.type.parseAsync(i,{path:r.path,errorMap:r.common.contextualErrorMap})))}};Gn.create=(e,t)=>new Gn({type:e,typeName:E.ZodPromise,...ee(t)});var lr=class extends ne{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===E.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){let{status:r,ctx:n}=this._processInputParams(t),i=this._def.effect||null,o={addIssue:s=>{O(n,s),s.fatal?r.abort():r.dirty()},get path(){return n.path}};if(o.addIssue=o.addIssue.bind(o),i.type==="preprocess"){let s=i.transform(n.data,o);if(n.common.async)return Promise.resolve(s).then(async a=>{if(r.value==="aborted")return W;let u=await this._def.schema._parseAsync({data:a,path:n.path,parent:n});return u.status==="aborted"?W:u.status==="dirty"?_i(u.value):r.value==="dirty"?_i(u.value):u});{if(r.value==="aborted")return W;let a=this._def.schema._parseSync({data:s,path:n.path,parent:n});return a.status==="aborted"?W:a.status==="dirty"?_i(a.value):r.value==="dirty"?_i(a.value):a}}if(i.type==="refinement"){let s=a=>{let u=i.refinement(a,o);if(n.common.async)return Promise.resolve(u);if(u instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a};if(n.common.async===!1){let a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?W:(a.status==="dirty"&&r.dirty(),s(a.value),{status:r.value,value:a.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(a=>a.status==="aborted"?W:(a.status==="dirty"&&r.dirty(),s(a.value).then(()=>({status:r.value,value:a.value}))))}if(i.type==="transform")if(n.common.async===!1){let s=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!Nn(s))return W;let a=i.transform(s.value,o);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:a}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(s=>Nn(s)?Promise.resolve(i.transform(s.value,o)).then(a=>({status:r.value,value:a})):W);ae.assertNever(i)}};lr.create=(e,t,r)=>new lr({schema:e,typeName:E.ZodEffects,effect:t,...ee(r)});lr.createWithPreprocess=(e,t,r)=>new lr({schema:t,effect:{type:"preprocess",transform:e},typeName:E.ZodEffects,...ee(r)});var qt=class extends ne{_parse(t){return this._getType(t)===P.undefined?Tt(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};qt.create=(e,t)=>new qt({innerType:e,typeName:E.ZodOptional,...ee(t)});var Wr=class extends ne{_parse(t){return this._getType(t)===P.null?Tt(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};Wr.create=(e,t)=>new Wr({innerType:e,typeName:E.ZodNullable,...ee(t)});var Oi=class extends ne{_parse(t){let{ctx:r}=this._processInputParams(t),n=r.data;return r.parsedType===P.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}};Oi.create=(e,t)=>new Oi({innerType:e,typeName:E.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...ee(t)});var Pi=class extends ne{_parse(t){let{ctx:r}=this._processInputParams(t),n={...r,common:{...r.common,issues:[]}},i=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return wo(i)?i.then(o=>({status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new Ft(n.common.issues)},input:n.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Ft(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};Pi.create=(e,t)=>new Pi({innerType:e,typeName:E.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...ee(t)});var Eo=class extends ne{_parse(t){if(this._getType(t)!==P.nan){let n=this._getOrReturnCtx(t);return O(n,{code:T.invalid_type,expected:P.nan,received:n.parsedType}),W}return{status:"valid",value:t.data}}};Eo.create=e=>new Eo({typeName:E.ZodNaN,...ee(e)});var J$=Symbol("zod_brand"),$s=class extends ne{_parse(t){let{ctx:r}=this._processInputParams(t),n=r.data;return this._def.type._parse({data:n,path:r.path,parent:r})}unwrap(){return this._def.type}},Es=class e extends ne{_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.common.async)return(async()=>{let o=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?W:o.status==="dirty"?(r.dirty(),_i(o.value)):this._def.out._parseAsync({data:o.value,path:n.path,parent:n})})();{let i=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?W:i.status==="dirty"?(r.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:n.path,parent:n})}}static create(t,r){return new e({in:t,out:r,typeName:E.ZodPipeline})}},Ci=class extends ne{_parse(t){let r=this._def.innerType._parse(t),n=i=>(Nn(i)&&(i.value=Object.freeze(i.value)),i);return wo(r)?r.then(i=>n(i)):n(r)}unwrap(){return this._def.innerType}};Ci.create=(e,t)=>new Ci({innerType:e,typeName:E.ZodReadonly,...ee(t)});function Uy(e,t){let r=typeof e=="function"?e(t):typeof e=="string"?{message:e}:e;return typeof r=="string"?{message:r}:r}function Hy(e,t={},r){return e?Dn.create().superRefine((n,i)=>{let o=e(n);if(o instanceof Promise)return o.then(s=>{if(!s){let a=Uy(t,n),u=a.fatal??r??!0;i.addIssue({code:"custom",...a,fatal:u})}});if(!o){let s=Uy(t,n),a=s.fatal??r??!0;i.addIssue({code:"custom",...s,fatal:a})}}):Dn.create()}var H$={object:Lt.lazycreate},E;(function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"})(E||(E={}));var K$=(e,t={message:`Input not instance of ${e.name}`})=>Hy(r=>r instanceof e,t),Ky=Mn.create,Qy=yi.create,Q$=Eo.create,X$=vi.create,Xy=bi.create,Y$=wi.create,eE=xo.create,tE=ki.create,rE=xi.create,nE=Dn.create,iE=dn.create,oE=Tr.create,sE=So.create,aE=fn.create,bd=Lt.create,cE=Lt.strictCreate,lE=Si.create,uE=xc.create,dE=Ti.create,fE=Br.create,mE=Sc.create,pE=To.create,hE=$o.create,gE=Tc.create,_E=$i.create,yE=Ei.create,vE=zi.create,bE=Ai.create,wE=Gn.create,kE=lr.create,xE=qt.create,SE=Wr.create,TE=lr.createWithPreprocess,$E=Es.create,EE=()=>Ky().optional(),zE=()=>Qy().optional(),AE=()=>Xy().optional(),OE={string:(e=>Mn.create({...e,coerce:!0})),number:(e=>yi.create({...e,coerce:!0})),boolean:(e=>bi.create({...e,coerce:!0})),bigint:(e=>vi.create({...e,coerce:!0})),date:(e=>wi.create({...e,coerce:!0}))};var PE=W;var CE=new Intl.Segmenter("en",{granularity:"grapheme"});function ev(e){return Array.from(CE.segment(e)).length}import*as kd from"node:fs";import*as av from"node:os";import*as Ut from"node:path";import*as zo from"node:fs/promises";function tv(e,t){return"Kandan attachment path must resolve inside an allowed upload root ("+e+"): "+t}function rv(e){return"Kandan attachment upload path must not include hidden path segments: "+e}function wd(e){return"Kandan attachment upload requires a known media/document type or text content (binary content is not allowed): "+e}var nv="LINZUMI_THREAD_RUNNER_KANDAN_THREAD_ID";var iv="Kandan attachment path must not be empty";function _t(e){if(typeof e=="object"&&e!==null&&!Array.isArray(e))return e}function zs(e){if(Array.isArray(e))return e}function et(e){if(e!==void 0&&typeof e=="string"&&e.trim()!=="")return e.trim()}function IE(e){if(e!==void 0&&typeof e=="number"&&Number.isInteger(e))return e}function xd(e){if(e!==void 0)return e}function gt(e){let t={};t.type="text",t.text=JSON.stringify(e,void 0,2);let r={};return r.content=[t],r.structuredContent=e,r}var jE="failed: ([a-z0-9_]+)(?: detail=(.+))?$";async function Sd(e){let t;try{t=await e}catch(r){let n=K(r),i=on(n),o=new RegExp(jE).exec(i);if(o==null){let d={};return d.error=i,gt(d)}let s=o.slice(1),a=s[0],u;if(a!==void 0){let d=he(a);u=d!==void 0?d:i}else u=i;let c={};c.error=u;let l=s[1];if(l!==void 0){let d=he(l);d!==void 0&&(c.detail=d)}return gt(c)}return gt(t)}function cv(e){let t=br(e);if(t===void 0)return Ou(e);let r=he(t),n=wr(r);return n!==void 0&&n.includes("channel_required")?u_(new Error(n+". Remediation: pass the channel slug in the `channel` parameter, or set target.thread_id to a Linzumi thread you can access (the server resolves the thread's channel). The files were NOT attached; retry with a channel or thread instead of leaving them on disk.",{cause:r})):d_(r)}function mn(e){let t={};return Object.entries(e).forEach(r=>{t[r[0]]=r[1]}),t}function Td(e,t){if(et(e.thread_id)!==void 0||t===void 0)return e;let n=()=>{let s=mn(e);return s.thread_id=t,s},i=e.message_seq;if(i!==void 0&&typeof i<"u")return n();let o=et(e.kind);if(o===void 0)return e;switch(o){case"latest_assistant_message":case"message_seq":case"new_message":return n();default:return e}}function ur(e,t){if(et(e.thread_id)!==void 0||t===void 0)return e;let n=mn(e);return n.thread_id=t,n}function $c(e,t){let r=En(t);if(r!==void 0)return he(r).toString();let n=e.replace(new RegExp("^wss://"),"https://").replace(new RegExp("^ws://"),"http://"),i=Kt(t,n);return i.TAG==="Ok"?i._0.toString():Pe(i._0)}function NE(e,t){let r=et(t.inline_url),n=et(t.carousel_url),i=mn(t);return r!==void 0&&(i.inline_url=$c(e,r)),n!==void 0&&(i.carousel_url=$c(e,n)),i}function ME(e,t){if(typeof t!="object"||t===null||Array.isArray(t))return t;let r=et(t.url),n=_t(t.image_variants),i=mn(t);return r!==void 0&&(i.url=$c(e,r)),n!==void 0&&(i.image_variants=NE(e,n)),i}function sv(e,t){let r=zs(t.attachments);if(r===void 0)return t;let n=mn(t);return n.attachments=r.map(i=>ME(e,i)),n}function $d(e,t){let r=_t(t.message),n=_t(t.target_message);if(r===void 0&&n===void 0)return t;let i=mn(t);return r!==void 0&&(i.message=sv(e,r)),n!==void 0&&(i.target_message=sv(e,n)),i}var DE=[".csv",".diff",".gif",".htm",".html",".jpeg",".jpg",".json",".jsonl",".log",".md",".mp4",".patch",".pdf",".png",".svg",".txt",".webm",".webp",".xml",".zip"];async function GE(e){let t=[{path:e,label:"runner cwd"}],r=He(process.env.HOME,o=>o.trim()),n=Ut.resolve(r!==void 0&&r!==""?r:av.homedir(),"Downloads"),i;try{i=await zo.realpath(n)}catch{return t}return t.some(o=>o.path===i)||t.push({path:i,label:"~/Downloads"}),t}function ZE(e,t){let r=Ut.relative(e,t);return r===""?!0:r.startsWith("..")?!1:!Ut.isAbsolute(r)}async function FE(e,t){if(t==="")return Pe(iv);let r=Ut.isAbsolute(t)?Ut.resolve(t):Ut.resolve(e,t);return await zo.realpath(r)}async function qE(e,t){if(!(await e.stat()).isFile())return Pe("Kandan attachment path is not a file: "+t);let n=Ut.extname(t).toLowerCase();if(DE.includes(n))return{classification:"KnownType",bytes:await e.readFile()};let i=Buffer.alloc(8192),s=(await e.read(i,0,8192,0)).bytesRead;if(i.subarray(0,s).includes(0))return Pe(wd(t));let a=await e.readFile();return a.subarray(0,8192).includes(0)?Pe(wd(t)):{classification:"TextContent",bytes:a}}async function LE(e,t){let r=e.find(i=>ZE(i.path,t));if(r!==void 0){if(Ut.relative(r.path,t).split(new RegExp("[\\\\/]+","g")).find(l=>l!==void 0?l.startsWith("."):!1)!==void 0)return Pe(rv(t));let s=await zo.open(t,kd.constants.O_RDONLY|kd.constants.O_NONBLOCK),a,u=0,c;try{c=await qE(s,t),u=1}catch(l){a={TAG:"Error",_0:K(l)}}return u===1&&(a={TAG:"Ok",_0:c}),await s.close(),a.TAG==="Ok"?a._0:Ou(a._0)}let n=e.map(i=>i.label).join(", ");return Pe(tv(n,t))}function UE(e){let t=e.toLowerCase();return t.endsWith(".png")?"image/png":t.endsWith(".jpg")||t.endsWith(".jpeg")?"image/jpeg":t.endsWith(".gif")?"image/gif":t.endsWith(".webp")?"image/webp":t.endsWith(".csv")?"text/csv":t.endsWith(".json")?"application/json":t.endsWith(".md")||t.endsWith(".txt")||t.endsWith(".log")?"text/plain":"application/octet-stream"}function VE(e,t){if(e.toLowerCase().endsWith(".py"))return"text/x-python";let n=UE(e);return t==="KnownType"||n!=="application/octet-stream"?n:"text/plain"}async function lv(e,t){let r=await zo.realpath(e),n=await GE(r),i=await FE(r,t),o=await LE(n,i);return{fileName:Ut.basename(i),contentType:VE(i,o.classification),sizeBytes:o.bytes.byteLength,bytes:o.bytes}}async function uv(e,t,r,n,i){let o={};return o["content-type"]=n,await Ya.binary($c(e,t),{method:r,headers:o,body:f_(i)})}async function dv(e){let t=await Promise.all(e.files.map(h=>lv(e.cwd,h))),r=et(e.target.thread_id),n={},i=e.workspace;i!==void 0&&(n.workspace=i);let o=e.channel;o!==void 0&&(n.channel=o),r!==void 0&&(n.thread_id=r),n.files=t.map(h=>{let m={};return m.file_name=h.fileName,m.content_type=h.contentType,m.size_bytes=h.sizeBytes,m});let s=await e.client.prepareMessageUploads(n),a=zs(s.uploads),u=a!==void 0?a:[];u.length===t.length||Pe("Linzumi upload prepare response count mismatch"),await Promise.all(t.map(async(h,m)=>{let g=_t(u[m]),y=et(Ke(g,S=>S.upload_url)),v=et(Ke(g,S=>S.upload_method)),b=v!==void 0?v:"PUT";if(y===void 0)return Pe("Linzumi upload prepare response missing upload_url");let w=await uv(e.serviceUrl,y,b,h.contentType,h.bytes);if(!w.ok)return Pe("Linzumi upload failed for "+h.fileName+": "+w.status.toString()+" "+w.statusText)}));let c=u.map(h=>{let m=et(Ke(_t(h),g=>g.file_id));return m!==void 0?m:Pe("Linzumi upload prepare response missing file_id")}),l={},d=e.workspace;d!==void 0&&(l.workspace=d);let p=e.channel;p!==void 0&&(l.channel=p),r!==void 0&&(l.thread_id=r),l.target=e.target;let f=e.body;return f!==void 0&&(l.body=f),l.uploaded_file_ids=c,await e.client.attachMessageFiles(l)}async function fv(e){let t=await lv(e.cwd,e.file),r={},n=e.workspace;n!==void 0&&(r.workspace=n),r.name=e.name,r.file_name=t.fileName,r.content_type=t.contentType,r.size_bytes=t.sizeBytes;let i=await e.client.prepareCustomEmoji(r),o=_t(i.upload),s=et(Ke(o,h=>h.upload_url)),a=et(Ke(o,h=>h.upload_method)),u=a!==void 0?a:"PUT";if(s===void 0)return Pe("Linzumi custom emoji prepare response missing upload_url");let c=await uv(e.serviceUrl,s,u,t.contentType,t.bytes);if(c.ok){let h=await c.json();if(typeof h!="object"||h===null||Array.isArray(h))return Pe("Linzumi custom emoji upload returned non-object JSON");let m=_t(h.custom_emoji);if(m===void 0)return Pe("Linzumi custom emoji upload response missing custom_emoji");let g={};g.ok=!0;let y=i.workspace;g.workspace=y!==void 0?y:void 0,g.emoji=m;let v=et(h.asset_id);g.asset_id=v!==void 0?v:void 0;let b=IE(m.id);g.id=b!==void 0?b:void 0;let w=et(m.name);g.name=w!==void 0?w:void 0;let S=et(m.shortcode);g.shortcode=S!==void 0?S:void 0;let R=et(m.image_url);return g.image_url=R!==void 0?R:void 0,g}let l=c.status.toString()+" "+c.statusText,p=(await c.text()).trim(),f;if(p==="")f=l;else{let h=0,m;try{m=JSON.parse(p),h=1}catch{f=p}if(h===1)if(typeof m=="object"&&m!==null&&!Array.isArray(m)){let g=m.error;f=typeof g=="string"?g:p}else f=p}return Pe("Linzumi custom emoji upload failed: "+f)}import*as Rt from"node:fs";import*as pv from"node:os";import*as hv from"node:net";import*as Xt from"node:path";var gv=Ra($u(),1);import*as _v from"node:child_process";function Ec(e,t){}function Od(e){return e==="DesiredRunning"?"running":"stopped"}function yv(e){switch(e){case"Running":return"running";case"Unhealthy":return"unhealthy";case"Exited":return"exited";case"Failed":return"failed";case"Stopped":return"stopped"}}function BE(){let e=He(process.env.LINZUMI_DEV_SERVICES_DIR,t=>t.trim());return e!==void 0&&e!==""?e:Xt.join(pv.homedir(),".linzumi","dev-services")}function WE(e){let t=e.replace(new RegExp("[^A-Za-z0-9._-]+","g"),"-").replace(new RegExp("^[-.]+|[-.]+$","g"),"").slice(0,80),r=Ja(e).slice(0,8),n=t===""?"runner":t;return Xt.join(BE(),n+"."+r)}function zc(e){let t=e.trim().toLowerCase();if(new RegExp("^[a-z0-9][a-z0-9._-]{0,63}$").test(t)&&!t.includes(".."))return t}function As(e,t){return Xt.join(e,"services",t+".json")}function Pd(e,t){return Xt.join(e,"exits",t+".json")}function vv(e,t){return Xt.join(e,"logs",t+".log")}function Ii(e){if(typeof e=="string"&&e!=="")return e}function pn(e){if(e!==void 0&&typeof e=="number"&&isFinite(e))return e}function JE(e){return e!==void 0?Array.isArray(e)?Qt(e,t=>{if(typeof t=="number"&&Number.isInteger(t)&&t>0&&t<=65535)return t}):[]:[]}function HE(e,t,r){if(r!==void 0&&r!==null){if(typeof r=="object"&&!Array.isArray(r)){let n=Ii(r.reason),i=pn(r.atMs);if(n!==void 0&&i!==void 0)return{reason:n,atMs:i};let o=[];n!==void 0||o.push("reason"),i!==void 0||o.push("atMs");let s=o.join(", ");return console.warn("[dev_services.failure_record_malformed] name="+e+" invalid_fields="+o.join(",")),{reason:'dev-service "'+e+'" has a malformed persisted failure record: invalid '+s,atMs:t}}return console.warn("[dev_services.failure_record_malformed] name="+e+" invalid_fields=reason,atMs"),{reason:'dev-service "'+e+'" has a malformed persisted failure record: invalid reason, atMs',atMs:t}}}function KE(e){if(typeof e!="object"||e===null||Array.isArray(e)||!Pt(e.version,1))return;let t=Ii(e.name),r=Ke(t,zc),n=Ii(e.command),i=Ii(e.cwd),o=e.desiredState,s;if(typeof o=="string")switch(o){case"running":s="DesiredRunning";break;case"stopped":s="DesiredStopped";break;default:s=void 0}else s=void 0;let a=pn(e.updatedAtMs),u=Ii(e.logPath),c=Pt(r,t);if(r!==void 0&&c&&n!==void 0&&i!==void 0&&s!==void 0&&a!==void 0&&u!==void 0)return{watchdogVersion:pn(e.watchdogVersion),name:r,command:n,cwd:i,ports:JE(e.ports),restartOnBranchChange:Pt(e.restartOnBranchChange,!0),desiredState:s,pid:pn(e.pid),ownerPid:pn(e.ownerPid),startedAtMs:pn(e.startedAtMs),updatedAtMs:a,lastBranch:Ii(e.lastBranch),logPath:u,automaticRestartAttempts:rt(pn(e.automaticRestartAttempts),0),automaticRestartWindowStartedAtMs:pn(e.automaticRestartWindowStartedAtMs),automaticRestartCause:Ii(e.automaticRestartCause),failure:HE(r,a,e.failure)}}function Ri(e){return e!==void 0?he(e):null}function QE(e){let t=e.failure,r=t!==void 0?{reason:t.reason,atMs:t.atMs}:null,n={version:1,watchdogVersion:Ri(e.watchdogVersion),name:e.name,command:e.command,cwd:e.cwd,ports:e.ports,restartOnBranchChange:e.restartOnBranchChange,desiredState:Od(e.desiredState),pid:Ri(e.pid),ownerPid:Ri(e.ownerPid),startedAtMs:Ri(e.startedAtMs),updatedAtMs:e.updatedAtMs,lastBranch:Ri(e.lastBranch),logPath:e.logPath,automaticRestartAttempts:e.automaticRestartAttempts,automaticRestartWindowStartedAtMs:Ri(e.automaticRestartWindowStartedAtMs),automaticRestartCause:Ri(e.automaticRestartCause),failure:r},i=JSON.stringify(n);if(i!==void 0)return i+`
228
+ `;throw{RE_EXN_ID:"Failure",_1:"dev-service record could not be encoded",Error:new Error}}function XE(e,t,r){let n=As(e,t.name),i=Y(Y(ve(xr(Xt.dirname(n)),a=>a.message),()=>{try{return{TAG:"Ok",_0:QE(t)}}catch(a){let u=K(a);return{TAG:"Error",_0:"record encoding failed: "+We(u).message}}}),a=>{let u=n+".tmp";return Y(ve(t_(u,a),c=>c.message),()=>ve(Wa(u,n),c=>c.message))});if(i.TAG==="Ok")return{TAG:"Ok",_0:void 0};let o=i._0,s={};return s.path=n,s.message=o,r("dev_services.record_write_failed",s),{TAG:"Error",_0:"could not persist dev-service state at "+n+": "+o}}function Ed(e,t,r){let n=As(e,t.name),i=n+".lock",o=Y(xr(Xt.dirname(n)),()=>{let u;try{let c=Rt.statSync(i),l=c.isFile(),d=c.isDirectory(),p=Date.now()-c.mtimeMs>=5e3;u=l?p?Me(si(i),()=>{let f={};f.name=t.name,f.path=i,r("dev_services.legacy_record_lock_recovered",f)}):{TAG:"Ok",_0:void 0}:d&&p?{TAG:"Ok",_0:Date.now()-c.mtimeMs}:{TAG:"Ok",_0:void 0}}catch(c){let l=K(c),d=We(l);u=d.code==="ENOENT"?{TAG:"Ok",_0:void 0}:{TAG:"Error",_0:d}}return Y(u,c=>{try{let l=gv.lockSync(n,{lockfilePath:i,realpath:!1,retries:0,stale:5e3,update:1e3,onCompromised:d=>{let p=We(d),f={};throw f.name=t.name,f.path=i,f.message=p.message,r("dev_services.record_lock_compromised",f),d}});if(c!==void 0){let d={};d.name=t.name,d.path=i,d.age_ms=c,r("dev_services.record_lease_recovered",d)}return{TAG:"Ok",_0:l}}catch(l){let d=K(l);return{TAG:"Error",_0:We(d)}}})});if(o.TAG==="Ok"){let u=XE(e,t,r),c;try{o._0(),c={TAG:"Ok",_0:void 0}}catch(p){let f=K(p);c={TAG:"Error",_0:We(f)}}if(u.TAG!=="Ok")return{TAG:"PersistUnwritten",_0:u._0};if(c.TAG==="Ok")return"PersistOk";let l=c._0,d={};return d.name=t.name,d.path=i,d.message=l.message,r("dev_services.record_unlock_failed",d),{TAG:"PersistCommittedUnlockFailed",_0:"could not unlock dev-service state at "+i+": "+l.message}}let s=o._0,a={};return a.name=t.name,a.path=i,a.message=s.message,r("dev_services.record_lock_failed",a),{TAG:"PersistUnwritten",_0:"could not lock dev-service state at "+i+": "+s.message}}function Cd(e,t){let r=zc(t);if(r===void 0)return;let n=kr(As(e,r));if(n.TAG!=="Ok")return;let i;try{i=JSON.parse(n._0)}catch{return}return KE(i)}function YE(e){let t=o_(Xt.join(e,"services"));return t.TAG==="Ok"?Qt(t._0,r=>{if(r.endsWith(".json"))return Cd(e,r.slice(0,r.length-5|0))}).toSorted((r,n)=>r.name.localeCompare(n.name)):[]}function bv(e,t){let r=kr(Pd(e,t));if(r.TAG!=="Ok")return;let n;try{n=JSON.parse(r._0)}catch{return}if(typeof n!="object"||n===null||Array.isArray(n))return;let i=pn(n.atMs);if(i===void 0)return;let o=n.code,s;s=typeof o=="number"?o:void 0;let a=n.signal,u;return u=typeof a=="string"?a:void 0,{code:s,signal:u,atMs:i}}function ez(e){let t={};return t.command=e.command,t.args=e.args.map(r=>r),t.cwd=e.cwd,t.pollIntervalMs=e.pollIntervalMs,t.recordPath=e.recordPath,t.exitStatusPath=e.exitStatusPath,JSON.stringify(t)}function tz(e,t){return{command:e,args:["-e",`
229
229
  const { spawn } = require('node:child_process');
230
230
  const fs = require('node:fs');
231
231
  const config = JSON.parse(process.argv[process.argv.length - 1]);
@@ -311,10 +311,10 @@ const watchdog = setInterval(() => {
311
311
  }
312
312
  }
313
313
  }, config.pollIntervalMs);
314
- `.trim(),XE(t)]}}function zd(e){if(e===void 0||e<=1)return!1;try{return process.kill(-e,0),!0}catch(t){let r=K(t);return Pt(We(r).code,"EPERM")}}function Rd(e,t){let r=t.pid;if(r===void 0||r<=1)return!1;let n=vv(e,t.name),i=t.startedAtMs;return n!==void 0&&i!==void 0&&n.atMs>=i?!1:zd(t.pid)}function Id(e){return new Promise((t,r)=>{let n=pv.createConnection({port:e,host:"127.0.0.1"}),i=o=>{n.removeAllListeners(),n.destroy(),t(o)};n.setTimeout(750),n.once("connect",()=>i(!0)),n.once("timeout",()=>i(!1)),n.once("error",()=>i(!1))})}async function ez(e,t){let r=Rd(e,t),n=[];for(let s=0,a=t.ports.length;s<a;++s){let u=t.ports[s];if(u!==void 0){let c=r?await Id(u|0):!1;n.push({port:u,listening:c})}}let i=t.desiredState,o;if(i==="DesiredRunning"){let s=t.failure;o=r?n.every(a=>a.listening)?"Running":"Unhealthy":s!==void 0?"Failed":"Exited"}else o="Stopped";return{record:t,liveness:o,portProbes:n,lastExit:vv(e,t.name),failure:t.failure}}async function jd(e){let t=[],r=QE(e);for(let n=0,i=r.length;n<i;++n){let o=r[n];o!==void 0&&t.push(await ez(e,o))}return t}function tz(e){let t=He(e.SHELL,r=>r.trim());return t!==void 0&&t!==""?t:"/bin/sh"}async function Ad(e,t,r,n){let i=n!==void 0?n:3e3;if(e===void 0||e<=1||zu(-e|0,"SIGTERM").TAG!=="Ok")return;let s=Date.now()+i,a=zd(e);for(;a&&Date.now()<s;)await ec(100),a=zd(e);if(!a||zu(-e|0,"SIGKILL").TAG!=="Ok")return;let c={};return c.name=r,c.pgid=e,t("dev_services.stop_escalated",c)}async function bv(e){let t=e.log,r=t!==void 0?t:Ec,n=zc(e.definition.name);if(n===void 0)return{TAG:"Error",_0:"invalid service name: use 1-64 lowercase letters, digits, ., _ or -"};let i=e.definition.command.trim();if(i==="")return{TAG:"Error",_0:"service command must not be empty"};let o;try{o={TAG:"Ok",_0:Rt.statSync(e.definition.cwd).isDirectory()}}catch{o={TAG:"Error",_0:"cwd does not exist: "+e.definition.cwd}}if(o.TAG!=="Ok")return{TAG:"Error",_0:o._0};if(!o._0)return{TAG:"Error",_0:"cwd is not a directory: "+e.definition.cwd};let s=Cd(e.scopeDir,n);s!==void 0&&Rd(e.scopeDir,s)&&await Ad(s.pid,r,n,void 0);let a=e.nowMs,u=a!==void 0?a:Date.now(),c=yv(e.scopeDir,n),l=Pd(e.scopeDir,n),d=Y(Y(Y(xr(Xt.dirname(c)),()=>xr(Xt.join(e.scopeDir,"services"))),()=>xr(Xt.dirname(l))),()=>{try{return{TAG:"Ok",_0:Rt.openSync(c,"a")}}catch($){let N=K($);return{TAG:"Error",_0:We(N)}}});if(d.TAG!=="Ok")return{TAG:"Error",_0:"cannot open service log: "+d._0.message};let p=d._0,f=oi(l);if(f.TAG!=="Ok"){let $={};$.name=n,$.path=l,$.message=f._0.message,r("dev_services.exit_marker_remove_failed",$)}let h=e.shellPathOverride,m=h!==void 0?h:tz(process.env),g=e.nodeExecPath,y=e.watchdogPollIntervalMs,v=YE(g!==void 0?g:process.execPath,{command:m,args:["-lc",i],cwd:e.definition.cwd,pollIntervalMs:y!==void 0?y:500,recordPath:As(e.scopeDir,n),exitStatusPath:l});try{Rt.writeFileSync(p,`
314
+ `.trim(),ez(t)]}}function zd(e){if(e===void 0||e<=1)return!1;try{return process.kill(-e,0),!0}catch(t){let r=K(t);return Pt(We(r).code,"EPERM")}}function Rd(e,t){let r=t.pid;if(r===void 0||r<=1)return!1;let n=bv(e,t.name),i=t.startedAtMs;return n!==void 0&&i!==void 0&&n.atMs>=i?!1:zd(t.pid)}function Id(e){return new Promise((t,r)=>{let n=hv.createConnection({port:e,host:"127.0.0.1"}),i=o=>{n.removeAllListeners(),n.destroy(),t(o)};n.setTimeout(750),n.once("connect",()=>i(!0)),n.once("timeout",()=>i(!1)),n.once("error",()=>i(!1))})}async function rz(e,t){let r=Rd(e,t),n=[];for(let s=0,a=t.ports.length;s<a;++s){let u=t.ports[s];if(u!==void 0){let c=r?await Id(u|0):!1;n.push({port:u,listening:c})}}let i=t.desiredState,o;if(i==="DesiredRunning"){let s=t.failure;o=r?n.every(a=>a.listening)?"Running":"Unhealthy":s!==void 0?"Failed":"Exited"}else o="Stopped";return{record:t,liveness:o,portProbes:n,lastExit:bv(e,t.name),failure:t.failure}}async function jd(e){let t=[],r=YE(e);for(let n=0,i=r.length;n<i;++n){let o=r[n];o!==void 0&&t.push(await rz(e,o))}return t}function nz(e){let t=He(e.SHELL,r=>r.trim());return t!==void 0&&t!==""?t:"/bin/sh"}async function Ad(e,t,r,n){let i=n!==void 0?n:3e3;if(e===void 0||e<=1||zu(-e|0,"SIGTERM").TAG!=="Ok")return;let s=Date.now()+i,a=zd(e);for(;a&&Date.now()<s;)await ec(100),a=zd(e);if(!a||zu(-e|0,"SIGKILL").TAG!=="Ok")return;let c={};return c.name=r,c.pgid=e,t("dev_services.stop_escalated",c)}async function wv(e){let t=e.log,r=t!==void 0?t:Ec,n=zc(e.definition.name);if(n===void 0)return{TAG:"Error",_0:"invalid service name: use 1-64 lowercase letters, digits, ., _ or -"};let i=e.definition.command.trim();if(i==="")return{TAG:"Error",_0:"service command must not be empty"};let o;try{o={TAG:"Ok",_0:Rt.statSync(e.definition.cwd).isDirectory()}}catch{o={TAG:"Error",_0:"cwd does not exist: "+e.definition.cwd}}if(o.TAG!=="Ok")return{TAG:"Error",_0:o._0};if(!o._0)return{TAG:"Error",_0:"cwd is not a directory: "+e.definition.cwd};let s=Cd(e.scopeDir,n);s!==void 0&&Rd(e.scopeDir,s)&&await Ad(s.pid,r,n,void 0);let a=e.nowMs,u=a!==void 0?a:Date.now(),c=vv(e.scopeDir,n),l=Pd(e.scopeDir,n),d=Y(Y(Y(xr(Xt.dirname(c)),()=>xr(Xt.join(e.scopeDir,"services"))),()=>xr(Xt.dirname(l))),()=>{try{return{TAG:"Ok",_0:Rt.openSync(c,"a")}}catch($){let N=K($);return{TAG:"Error",_0:We(N)}}});if(d.TAG!=="Ok")return{TAG:"Error",_0:"cannot open service log: "+d._0.message};let p=d._0,f=si(l);if(f.TAG!=="Ok"){let $={};$.name=n,$.path=l,$.message=f._0.message,r("dev_services.exit_marker_remove_failed",$)}let h=e.shellPathOverride,m=h!==void 0?h:nz(process.env),g=e.nodeExecPath,y=e.watchdogPollIntervalMs,v=tz(g!==void 0?g:process.execPath,{command:m,args:["-lc",i],cwd:e.definition.cwd,pollIntervalMs:y!==void 0?y:500,recordPath:As(e.scopeDir,n),exitStatusPath:l});try{Rt.writeFileSync(p,`
315
315
  --- linzumi dev-service "`+n+'" starting at '+new Date(u).toISOString()+" (owner pid "+e.ownerPid.toString()+`) ---
316
316
  $ `+i+`
317
- `)}catch($){let N=K($),G={};G.name=n,G.message=We(N).message,r("dev_services.start_banner_write_failed",G)}let b=[];e.definition.ports.forEach($=>{if(!b.includes($)){b.push($);return}});let w=1,S=e.definition.cwd,R=b.toSorted(($,N)=>$-N),X=e.definition.restartOnBranchChange,be=e.ownerPid,D=u,I={reason:'dev service "'+n+'" start did not complete',atMs:u},B={watchdogVersion:w,name:n,command:i,cwd:S,ports:R,restartOnBranchChange:X,desiredState:"DesiredStopped",pid:void 0,ownerPid:be,startedAtMs:D,updatedAtMs:u,lastBranch:void 0,logPath:c,automaticRestartAttempts:0,automaticRestartWindowStartedAtMs:void 0,automaticRestartCause:void 0,failure:I},re=()=>{try{return Rt.closeSync(p),{TAG:"Ok",_0:void 0}}catch($){let N=K($);return{TAG:"Error",_0:We(N).message}}},le=Ed(e.scopeDir,B,r);if(typeof le!="object"){let $={};Object.entries(process.env).forEach(_e=>{$[_e[0]]=_e[1]}),$.ELECTRON_RUN_AS_NODE="1";let N;try{let _e=gv.spawn(v.command,v.args,{cwd:e.definition.cwd,detached:!0,stdio:["ignore",Number(p),Number(p)],env:$});_e.unref(),N={TAG:"Ok",_0:Nr(_e.pid)}}catch(_e){let vr=K(_e);N={TAG:"Error",_0:"spawn failed: "+We(vr).message}}let G=re();if(G.TAG!=="Ok"){let _e={};_e.name=n,_e.message=G._0,r("dev_services.log_close_failed",_e)}if(N.TAG!=="Ok")return{TAG:"Error",_0:N._0};let M=N._0;if(M===void 0)return{TAG:"Error",_0:"spawn failed: no pid"};let V=w,we=S,Le=R,nt=X,At=M,Ue={watchdogVersion:V,name:n,command:i,cwd:we,ports:Le,restartOnBranchChange:nt,desiredState:"DesiredRunning",pid:At,ownerPid:be,startedAtMs:D,updatedAtMs:u,lastBranch:void 0,logPath:c,automaticRestartAttempts:0,automaticRestartWindowStartedAtMs:void 0,automaticRestartCause:void 0,failure:void 0},Ve=Ed(e.scopeDir,Ue,r);if(typeof Ve!="object"){let _e={};return _e.name=n,_e.pid=M,_e.owner_pid=e.ownerPid,_e.cwd=e.definition.cwd,_e.ports=Le.map(vr=>vr),r("dev_services.started",_e),{TAG:"Ok",_0:Ue}}return Ve.TAG!=="PersistUnwritten"?{TAG:"Error",_0:Ve._0}:(await Ad(At,r,n,0),{TAG:"Error",_0:Ve._0})}else le.TAG;let j=re();if(j.TAG!=="Ok"){let $={};$.name=n,$.message=j._0,r("dev_services.log_close_failed",$)}return{TAG:"Error",_0:le._0}}async function Nd(e,t,r){let n=r!==void 0?r:Ec,i=Cd(e,t);if(i===void 0)return{TAG:"Error",_0:"unknown service: "+t};Rd(e,i)&&await Ad(i.pid,n,i.name,void 0);let o=i.watchdogVersion,s=i.name,a=i.command,u=i.cwd,c=i.ports,l=i.restartOnBranchChange,d=i.startedAtMs,p=Date.now(),f=i.lastBranch,h=i.logPath,m=i.automaticRestartAttempts,g=i.automaticRestartWindowStartedAtMs,y=i.automaticRestartCause,v={watchdogVersion:o,name:s,command:a,cwd:u,ports:c,restartOnBranchChange:l,desiredState:"DesiredStopped",pid:void 0,ownerPid:void 0,startedAtMs:d,updatedAtMs:p,lastBranch:f,logPath:h,automaticRestartAttempts:m,automaticRestartWindowStartedAtMs:g,automaticRestartCause:y,failure:void 0},b=Ed(e,v,n);if(typeof b=="object")return{TAG:"Error",_0:b._0};let w={};return w.name=i.name,n("dev_services.stopped",w),{TAG:"Ok",_0:v}}async function wv(e,t,r){let n=await Nd(e,t,r);if(n.TAG!=="Ok")return{TAG:"Error",_0:n._0};let i=n._0,o=Y(oi(As(e,i.name)),()=>oi(Pd(e,i.name)));if(o.TAG==="Ok")return{TAG:"Ok",_0:i};let s=o._0,a={};return a.name=i.name,a.message=s.message,r("dev_services.remove_failed",a),{TAG:"Error",_0:'could not remove dev service "'+i.name+'": '+s.message}}function kv(e,t,r){let n=zc(t);if(n===void 0)return;let i=yv(e,n),o;try{o=Rt.openSync(i,"r")}catch{return}let s;try{let a=Rt.fstatSync(o).size,u=Math.min(a,r),c=Buffer.alloc(u|0);Rt.readSync(o,c,0,u|0,a-u),s=c.toString("utf8")}catch{s=void 0}try{Rt.closeSync(o)}catch{}return s}function xv(e){let t=He(e.LINZUMI_DEV_SERVICES_SCOPE,i=>i.trim()),r=e.LINZUMI_DEV_SERVICES_OWNER_PID,n=Number.parseInt(r!==void 0?r:"",10);if(t!==void 0&&t!==""&&Number.isInteger(n)&&n>0)return{scopeDir:VE(t),ownerPid:n}}function Tv(e){return e.trim()!==""?Buffer.byteLength(e,"utf8")<=2e3:!1}function $v(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let t=e.ok;return typeof t!="boolean"||!t?!1:e.completed_without_action===!0}var Ev=`<linzumi_markdown_media_guidance>
317
+ `)}catch($){let N=K($),G={};G.name=n,G.message=We(N).message,r("dev_services.start_banner_write_failed",G)}let b=[];e.definition.ports.forEach($=>{if(!b.includes($)){b.push($);return}});let w=1,S=e.definition.cwd,R=b.toSorted(($,N)=>$-N),X=e.definition.restartOnBranchChange,be=e.ownerPid,D=u,I={reason:'dev service "'+n+'" start did not complete',atMs:u},B={watchdogVersion:w,name:n,command:i,cwd:S,ports:R,restartOnBranchChange:X,desiredState:"DesiredStopped",pid:void 0,ownerPid:be,startedAtMs:D,updatedAtMs:u,lastBranch:void 0,logPath:c,automaticRestartAttempts:0,automaticRestartWindowStartedAtMs:void 0,automaticRestartCause:void 0,failure:I},re=()=>{try{return Rt.closeSync(p),{TAG:"Ok",_0:void 0}}catch($){let N=K($);return{TAG:"Error",_0:We(N).message}}},le=Ed(e.scopeDir,B,r);if(typeof le!="object"){let $={};Object.entries(process.env).forEach(ye=>{$[ye[0]]=ye[1]}),$.ELECTRON_RUN_AS_NODE="1";let N;try{let ye=_v.spawn(v.command,v.args,{cwd:e.definition.cwd,detached:!0,stdio:["ignore",Number(p),Number(p)],env:$});ye.unref(),N={TAG:"Ok",_0:Nr(ye.pid)}}catch(ye){let vr=K(ye);N={TAG:"Error",_0:"spawn failed: "+We(vr).message}}let G=re();if(G.TAG!=="Ok"){let ye={};ye.name=n,ye.message=G._0,r("dev_services.log_close_failed",ye)}if(N.TAG!=="Ok")return{TAG:"Error",_0:N._0};let M=N._0;if(M===void 0)return{TAG:"Error",_0:"spawn failed: no pid"};let V=w,we=S,Le=R,nt=X,At=M,Ue={watchdogVersion:V,name:n,command:i,cwd:we,ports:Le,restartOnBranchChange:nt,desiredState:"DesiredRunning",pid:At,ownerPid:be,startedAtMs:D,updatedAtMs:u,lastBranch:void 0,logPath:c,automaticRestartAttempts:0,automaticRestartWindowStartedAtMs:void 0,automaticRestartCause:void 0,failure:void 0},Ve=Ed(e.scopeDir,Ue,r);if(typeof Ve!="object"){let ye={};return ye.name=n,ye.pid=M,ye.owner_pid=e.ownerPid,ye.cwd=e.definition.cwd,ye.ports=Le.map(vr=>vr),r("dev_services.started",ye),{TAG:"Ok",_0:Ue}}return Ve.TAG!=="PersistUnwritten"?{TAG:"Error",_0:Ve._0}:(await Ad(At,r,n,0),{TAG:"Error",_0:Ve._0})}else le.TAG;let j=re();if(j.TAG!=="Ok"){let $={};$.name=n,$.message=j._0,r("dev_services.log_close_failed",$)}return{TAG:"Error",_0:le._0}}async function Nd(e,t,r){let n=r!==void 0?r:Ec,i=Cd(e,t);if(i===void 0)return{TAG:"Error",_0:"unknown service: "+t};Rd(e,i)&&await Ad(i.pid,n,i.name,void 0);let o=i.watchdogVersion,s=i.name,a=i.command,u=i.cwd,c=i.ports,l=i.restartOnBranchChange,d=i.startedAtMs,p=Date.now(),f=i.lastBranch,h=i.logPath,m=i.automaticRestartAttempts,g=i.automaticRestartWindowStartedAtMs,y=i.automaticRestartCause,v={watchdogVersion:o,name:s,command:a,cwd:u,ports:c,restartOnBranchChange:l,desiredState:"DesiredStopped",pid:void 0,ownerPid:void 0,startedAtMs:d,updatedAtMs:p,lastBranch:f,logPath:h,automaticRestartAttempts:m,automaticRestartWindowStartedAtMs:g,automaticRestartCause:y,failure:void 0},b=Ed(e,v,n);if(typeof b=="object")return{TAG:"Error",_0:b._0};let w={};return w.name=i.name,n("dev_services.stopped",w),{TAG:"Ok",_0:v}}async function kv(e,t,r){let n=await Nd(e,t,r);if(n.TAG!=="Ok")return{TAG:"Error",_0:n._0};let i=n._0,o=Y(si(As(e,i.name)),()=>si(Pd(e,i.name)));if(o.TAG==="Ok")return{TAG:"Ok",_0:i};let s=o._0,a={};return a.name=i.name,a.message=s.message,r("dev_services.remove_failed",a),{TAG:"Error",_0:'could not remove dev service "'+i.name+'": '+s.message}}function xv(e,t,r){let n=zc(t);if(n===void 0)return;let i=vv(e,n),o;try{o=Rt.openSync(i,"r")}catch{return}let s;try{let a=Rt.fstatSync(o).size,u=Math.min(a,r),c=Buffer.alloc(u|0);Rt.readSync(o,c,0,u|0,a-u),s=c.toString("utf8")}catch{s=void 0}try{Rt.closeSync(o)}catch{}return s}function Sv(e){let t=He(e.LINZUMI_DEV_SERVICES_SCOPE,i=>i.trim()),r=e.LINZUMI_DEV_SERVICES_OWNER_PID,n=Number.parseInt(r!==void 0?r:"",10);if(t!==void 0&&t!==""&&Number.isInteger(n)&&n>0)return{scopeDir:WE(t),ownerPid:n}}function $v(e){return e.trim()!==""?Buffer.byteLength(e,"utf8")<=2e3:!1}function Ev(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let t=e.ok;return typeof t!="boolean"||!t?!1:e.completed_without_action===!0}var zv=`<linzumi_markdown_media_guidance>
318
318
  Some Linzumi users have opted into rich Markdown media rendering. When you are
319
319
  writing a visible Linzumi message, channel message, or thread reply, you may use
320
320
  these Markdown-compatible media directives:
@@ -417,14 +417,14 @@ Why bad: External image hosts are intentionally not auto-rendered; attach the im
417
417
  Use media directives only after upload/attach returns a Linzumi download URL.
418
418
  Keep "src" required, all other fields optional, and never exceed 10 embeds in one message.
419
419
  </media_reminder>
420
- </linzumi_markdown_media_guidance>`;function Md(e){return e==="Voice"?"voice":"text"}function iz(e){switch(e){case"All":return"all";case"Coding":return"coding";case"OnboardingDiscovery":return"onboarding-discovery"}}function Dd(e){return JSON.stringify(e)}function zv(e){let t=[],r=e.argsPrefix;r!==void 0&&r.forEach(y=>{t.push(y)}),t.push("mcp"),t.push("server"),t.push("--api-url"),t.push(e.serviceUrl);let n=e.authFilePath;n!==void 0&&(t.push("--auth-file"),t.push(n));let i=e.delegationAuthFilePath;i!==void 0&&(t.push("--delegation-auth-file"),t.push(i));let o=e.ownerUsername;o!==void 0&&(t.push("--owner-username"),t.push(o));let s=e.cwd;s!==void 0&&(t.push("--cwd"),t.push(s));let a=e.threadId;a!==void 0&&(t.push("--thread-id"),t.push(a)),t.push("--mode");let u=e.operatingMode;t.push(u!==void 0?Md(u):"text");let c=e.toolScope;if(c!==void 0){let y=0;switch(c){case"All":break;case"Coding":case"OnboardingDiscovery":y=1;break}y===1&&(t.push("--tool-scope"),t.push(iz(c)))}let l=e.agentSession;l!==void 0&&l&&t.push("--agent-session");let d=e.askUserQuestionTool;d!==void 0&&d&&t.push("--ask-user-question-tool");let p=e.multiAgentJobs;p!==void 0&&p&&t.push("--multi-agent-jobs");let f={},h=e.accessToken;h!==void 0&&(f.LINZUMI_MCP_ACCESS_TOKEN=h);let m=e.devServices;m!==void 0&&(f.LINZUMI_DEV_SERVICES_SCOPE=m.scope,f.LINZUMI_DEV_SERVICES_OWNER_PID=m.ownerPid.toString()),f.ELECTRON_RUN_AS_NODE="1";let g=e.command;return{name:"linzumi",command:g!==void 0?g:"linzumi",args:t,env:f}}function oz(e){return"["+e.map(Dd).join(", ")+"]"}function sz(e){return"{ "+Object.entries(e).map(r=>r[0]+" = "+Dd(r[1])).join(", ")+" }"}function Av(e){let t={};t.command=e.command,t.args=e.args.map(o=>o);let r={};t.env=(Object.entries(e.env).forEach(o=>{r[o[0]]=o[1]}),r);let n={};n[e.name]=t;let i={};return i.mcpServers=n,JSON.stringify(i,void 0,2)+`
421
- `}function Ov(e){let t=Object.entries(e.env).length===0?"":"env = "+sz(e.env)+`
420
+ </linzumi_markdown_media_guidance>`;function Md(e){return e==="Voice"?"voice":"text"}function sz(e){switch(e){case"All":return"all";case"Coding":return"coding";case"OnboardingDiscovery":return"onboarding-discovery"}}function Dd(e){return JSON.stringify(e)}function Av(e){let t=[],r=e.argsPrefix;r!==void 0&&r.forEach(y=>{t.push(y)}),t.push("mcp"),t.push("server"),t.push("--api-url"),t.push(e.serviceUrl);let n=e.authFilePath;n!==void 0&&(t.push("--auth-file"),t.push(n));let i=e.delegationAuthFilePath;i!==void 0&&(t.push("--delegation-auth-file"),t.push(i));let o=e.ownerUsername;o!==void 0&&(t.push("--owner-username"),t.push(o));let s=e.cwd;s!==void 0&&(t.push("--cwd"),t.push(s));let a=e.threadId;a!==void 0&&(t.push("--thread-id"),t.push(a)),t.push("--mode");let u=e.operatingMode;t.push(u!==void 0?Md(u):"text");let c=e.toolScope;if(c!==void 0){let y=0;switch(c){case"All":break;case"Coding":case"OnboardingDiscovery":y=1;break}y===1&&(t.push("--tool-scope"),t.push(sz(c)))}let l=e.agentSession;l!==void 0&&l&&t.push("--agent-session");let d=e.askUserQuestionTool;d!==void 0&&d&&t.push("--ask-user-question-tool");let p=e.multiAgentJobs;p!==void 0&&p&&t.push("--multi-agent-jobs");let f={},h=e.accessToken;h!==void 0&&(f.LINZUMI_MCP_ACCESS_TOKEN=h);let m=e.devServices;m!==void 0&&(f.LINZUMI_DEV_SERVICES_SCOPE=m.scope,f.LINZUMI_DEV_SERVICES_OWNER_PID=m.ownerPid.toString()),f.ELECTRON_RUN_AS_NODE="1";let g=e.command;return{name:"linzumi",command:g!==void 0?g:"linzumi",args:t,env:f}}function az(e){return"["+e.map(Dd).join(", ")+"]"}function cz(e){return"{ "+Object.entries(e).map(r=>r[0]+" = "+Dd(r[1])).join(", ")+" }"}function Ov(e){let t={};t.command=e.command,t.args=e.args.map(o=>o);let r={};t.env=(Object.entries(e.env).forEach(o=>{r[o[0]]=o[1]}),r);let n={};n[e.name]=t;let i={};return i.mcpServers=n,JSON.stringify(i,void 0,2)+`
421
+ `}function Pv(e){let t=Object.entries(e.env).length===0?"":"env = "+cz(e.env)+`
422
422
  `;return"[mcp_servers."+e.name+`]
423
423
  command = `+Dd(e.command)+`
424
- args = `+oz(e.args)+`
425
- `+t}var Cv="Other",Rv="linzumi_ask_user_question",az="plan_mode_native_interview_tool",cz="no_active_turn",Pv="publish_failed: ";function Os(e){return JSON.stringify(e)}function lz(e){let t=e.trim().toLowerCase();switch(t){case"other":case"something else":case"something else...":return!0;default:return t.includes("other")?!0:t.includes("something else")}}function uz(e){let t=_t(e),r=zs(t!==void 0?t.questions:void 0);if(r===void 0)return{TAG:"Invalid",_0:"questions: expected an array"};let n=r.length;if(n===0)return{TAG:"Invalid",_0:"questions: min 1, got 0"};if(n>4)return{TAG:"Invalid",_0:"questions: max 4, got "+n.toString()};let i={contents:void 0},o=[],s=new Set;r.forEach((u,c)=>{if(i.contents!==void 0)return;let d=c.toString(),p=_t(u);if(p===void 0){i.contents="questions["+d+"]: expected an object";return}let f=et(p.question);if(f===void 0){i.contents="questions["+d+"].question: must be a non-empty string";return}if(s.has(f)){i.contents="questions: duplicate question text "+Os(f);return}let h=et(p.header);if(h===void 0){i.contents="questions["+d+"].header: must be a non-empty string";return}if(h.length>12){i.contents="questions["+d+"].header: max 12 chars, got "+h.length.toString();return}let m=p.multiSelect;if(m!==void 0){let X=0;if(typeof m!="boolean"&&(X=2),X===2){i.contents="questions["+d+"].multiSelect: must be a boolean";return}}let g=zs(p.options);if(g===void 0){i.contents="questions["+d+"].options: expected an array";return}let y=g.length;if(y<2){i.contents="questions["+d+"].options: min 2, got "+y.toString();return}if(y>4){i.contents="questions["+d+"].options: max 4, got "+y.toString();return}let v=[],b=new Set;if(g.forEach((X,be)=>{if(i.contents!==void 0)return;let I=be.toString(),B=_t(X),re=B!==void 0?et(B.label):void 0;if(B!==void 0&&re!==void 0){let le=B.description,j=0;if(le!==void 0){let $=0;if(typeof le=="string"?j=2:$=3,$===3){i.contents="questions["+d+"].options["+I+"].description: must be a string";return}}else j=2;if(j===2){if(lz(re)){i.contents="questions["+d+"].options["+I+"].label: "+Os(re)+" is reserved for the built-in Other option";return}if(b.has(re)){i.contents="questions["+d+"].options: duplicate label "+Os(re);return}b.add(re);let $=B.description,N;N=typeof $=="string"?$:"",v.push({label:re,description:N});return}}i.contents="questions["+d+"].options["+I+"].label: must be a non-empty string"}),i.contents!==void 0)return;s.add(f);let S=p.multiSelect,R;R=S===!0,o.push({question:f,header:h,options:v,multiSelect:R})});let a=i.contents;return a!==void 0?{TAG:"Invalid",_0:a}:{TAG:"Parsed",_0:{questions:o}}}function dz(e){let t={};e.questions.forEach(a=>{let u={};u.type="string",u.description=a.header,t[a.question]=u});let r={};r.type="object",r.properties=t,r.required=e.questions.map(a=>a.question);let n=e.questions.map(a=>{let u={};return u.question=a.question,u.header=a.header,u.multiSelect=a.multiSelect,u.options=a.options.map(c=>{let l={};return l.label=c.label,l.description=c.description,l}),u}),i={};i.version=1,i.questions=n;let o={};o[Rv]=i;let s={};return s.message="Linzumi interview: the user is being asked in the Linzumi thread.",s.requestedSchema=r,s._meta=o,s}function fz(e,t){let r=_t(t);if(r===void 0)return{TAG:"AnswersInvalid",_0:"the runner accepted the interview but returned no answers; it may predate linzumi_ask_user_question support"};let n={contents:void 0},i={};e.questions.forEach(s=>{if(n.contents!==void 0)return;let u=r[s.question];if(typeof u=="string"){let c=0,l;try{l=JSON.parse(u),c=2}catch{n.contents="the runner returned an undecodable answer for question "+Os(s.question);return}if(c===2){i[s.question]=l;return}}n.contents="the runner returned no answer for question "+Os(s.question)});let o=n.contents;return o!==void 0?{TAG:"AnswersInvalid",_0:o}:{TAG:"Answers",_0:i}}function mz(e){let t=_t(e);if(t===void 0)return;let r=_t(t[Rv]);return et(r!==void 0?r.reason:void 0)}function Jr(e){let t={};t.type="text",t.text=e;let r={};return r.content=[t],r.isError=!0,r}function pz(e){if(e===void 0)return"undefined";if(e===null)return"null";switch(typeof e){case"string":return e;case"number":return e.toString();default:return JSON.stringify(e)}}async function Iv(e,t){let r=uz(t);if(r.TAG!=="Parsed")return Jr(r._0);let n=r._0,i=0,o;try{o=await e(dz(n),2147483647),i=1}catch(s){let a=K(s);return Jr("the interview could not be delivered to the user: "+on(a))}if(i===1){let s=_t(o),a=s!==void 0?s:{},u=a.action,c=0;if(typeof u=="string")switch(u){case"accept":let l=fz(n,a.content);if(l.TAG!=="Answers")return Jr(l._0);let d={};return d.answers=l._0,gt(d);case"cancel":return Jr("the user dismissed the question without answering");case"decline":let p=mz(a._meta);return p!==void 0?p===az?Jr("linzumi_ask_user_question is unavailable during a Plan-mode turn: use the native request_user_input interview tool instead"):p===cz?Jr("the interview was declined: no active turn is bound to this session"):p.startsWith(Pv)?Jr("the interview could not be published to the user: "+p.slice(Pv.length,p.length)):Jr("the interview request was declined by the runner"):Jr("the interview request was declined by the runner");default:c=2}else c=2;if(c===2)return Jr("the interview returned an unknown action: "+pz(u))}}var jv="linzumi_ask_user_question",Zd=4,Fd=12,qd=2,Ld=4;var Nv="One or two sentences a teammate skimming the board would want: what changed, and what happens next. Standup register, present tense, name agents and lanes plainly. No thread ids or UUIDs unless needed for lookup; proofs and evidence belong in the thread, not here. Good: 'Retired the silent watchdog and spawned Thorne to replace it \u2014 running lean at three children.' Bad: 'Broken 67f1d639 archived abandoned; board claim preceded spawn; children verified at exactly 3.'";function Mv(){return _.string().min(1).refine(e=>Yy(e)<=240,{message:"status_note over 240 chars \u2014 trim to what a reader needs; put evidence in the thread."})}function gz(e){switch(e){case"All":return!0;case"Coding":case"OnboardingDiscovery":return!1}}function _z(e){return e==="Voice"}function yz(e){return e.trim().replace(new RegExp("^:+"),"").replace(new RegExp(":+$"),"").toLowerCase()}function Dv(){return _.string().min(1).refine(e=>yz(e).length<=64,{message:"Custom emoji shortcode name must be at most 64 characters after trimming surrounding colons."})}function Ii(){let e=_.discriminatedUnion("type",[_.object(Object.fromEntries([["type",_.literal("text")],["text",_.string()],["style",_.array(_.enum(["bold","italic","code"])).optional()]])).strict(),_.object(Object.fromEntries([["type",_.literal("actor")],["user_id",_.number().int().positive()],["fallback",_.string().min(1)]])).strict()]);return _.array(_.object(Object.fromEntries([["kind",_.literal("prose")],["tokens",_.array(e).min(1)]])).strict()).min(1).describe("Canonical BlockSequence. Actor mentions must be actor tokens; literal @ text stays a text token.")}function Ee(){return _.string().optional().describe("Workspace slug. Omit to use the authenticated token scope.")}function Yt(){return _.string().optional().describe("Channel slug. Omit to use the authenticated token scope.")}function er(e){if(typeof e=="string")return e}function Gv(e,t,r){let n=_t(e[t]);return n!==void 0?n:Ce(r+" "+t+" must be an object")}function vz(e){return e!==void 0?Array.isArray(e)?Qt(e,t=>{if(typeof t=="string")return t}):[]:[]}function bz(e){return e!==void 0?Array.isArray(e)?Qt(e,t=>{if(typeof t=="number")return t}):[]:[]}function Zv(e){if(typeof e=="number")return e}function Fv(e){let t={};t.name=e.record.name,t.command=e.record.command,t.cwd=e.record.cwd,t.ports=e.record.ports.map(s=>s),t.restart_on_branch_change=e.record.restartOnBranchChange,t.desired_state=Od(e.record.desiredState),t.liveness=_v(e.liveness),t.port_health=e.portProbes.map(s=>{let a={};return a.port=s.port,a.listening=s.listening,a});let r=e.record.startedAtMs;t.started_at_ms=r!==void 0?r:null;let n=e.lastExit,i;if(n!==void 0){let s={},a=n.code;s.code=a!==void 0?a:null;let u=n.signal;s.signal=u!==void 0?u:null,s.at_ms=n.atMs,i=s}else i=null;t.last_exit=i,t.log_path=e.record.logPath;let o=e.failure;return t.failure=o!==void 0?{reason:o.reason,at_ms:o.atMs}:null,t}function wz(e,t,r){e.registerTool("linzumi_dev_service_start","Start a long-running local dev server (npm run dev, storybook, docker compose up, ...) as a MANAGED SERVICE owned by the Linzumi runner. Use this instead of running dev servers in your own shell: a managed service survives the end of your turn and branch switches, is auto-restarted if it crashes, and its declared ports are health-probed and surfaced in the product. Calling start for an existing name declaratively RESTARTS it (e.g. after a checkout). Declare EVERY port the app serves from (primary plus HMR/asset/bundle sibling ports).",Object.fromEntries([["name",_.string().regex(new RegExp("^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$")).describe("Stable service name (slug), e.g. 'web' or 'storybook'. Reusing a name restarts that service.")],["command",_.string().min(1).describe("Shell command that runs the server in the foreground (never daemonize/screen/nohup it yourself), e.g. 'npm run dev'. Runs via the user's login shell.")],["cwd",_.string().optional().describe("Working directory for the service. Defaults to the session cwd.")],["ports",_.array(_.number().int().min(1).max(65535)).max(16).default([]).describe("Every TCP port this service listens on (primary AND related ports such as the Vite/HMR bundle port). Used for health probes and product visibility.")],["restart_on_branch_change",_.boolean().optional().describe("Restart the service automatically when the git branch of its cwd changes (for servers that go stale across checkouts).")],["wait_for_ports_ms",_.number().int().min(0).max(6e4).optional().describe("How long to wait for the declared ports to accept connections before returning (default 15000).")]]),async n=>{let i=er(n.name),o=i!==void 0?i:"",s=er(n.command),a=s!==void 0?s:"",u=er(n.cwd),c=await bv({scopeDir:r.scopeDir,definition:{name:o,command:a,cwd:u!==void 0?u:t,ports:bz(n.ports),restartOnBranchChange:Pt(n.restart_on_branch_change,!0)},ownerPid:r.ownerPid});if(c.TAG==="Ok"){let d=c._0,p=Zv(n.wait_for_ports_ms),f=Date.now()+(p!==void 0?p:15e3),h=d.ports.length===0;for(;!h&&Date.now()<f;)h=(await Promise.all(d.ports.map(w=>Id(w|0)))).every(w=>w),h||await ec(250);let g=(await jd(r.scopeDir)).find(b=>b.record.name===d.name),y={};y.ok=!0;let v;if(g!==void 0)v=Fv(g);else{let b={};b.name=d.name,v=b}return y.service=v,g!==void 0&&g.liveness!=="Running"&&(y.hint="The service is not (fully) serving its declared ports yet. Check linzumi_dev_service_logs before assuming it works."),gt(y)}let l={};return l.ok=!1,l.error=c._0,gt(l)}),e.registerTool("linzumi_dev_service_stop","Stop a managed dev service (SIGTERM, then SIGKILL after a grace period). The registration is kept so linzumi_dev_service_start can bring it back.",Object.fromEntries([["name",_.string().min(1).describe("Service name to stop.")]]),async n=>{let i=er(n.name),o=i!==void 0?i:"",s=await Nd(r.scopeDir,o,void 0),a={};return s.TAG==="Ok"?(a.ok=!0,a.name=s._0.name,a.desired_state="stopped"):(a.ok=!1,a.error=s._0),gt(a)}),e.registerTool("linzumi_dev_service_status","List every managed dev service with liveness (running / unhealthy / exited / failed / stopped), per-port health probes, last exit, and any terminal failure reason. Live state - always check this before concluding a dev server is up or down.",{},async n=>{let i=await jd(r.scopeDir),o={};return o.services=i.map(s=>Fv(s)),gt(o)}),e.registerTool("linzumi_dev_service_logs","Read the tail of a managed dev service's combined stdout/stderr log.",Object.fromEntries([["name",_.string().min(1).describe("Service name.")],["max_bytes",_.number().int().min(256).max(65536).optional().describe("Tail size in bytes (default 16384).")]]),async n=>{let i=er(n.name),o=i!==void 0?i:"",s=Zv(n.max_bytes),a=kv(r.scopeDir,o,s!==void 0?s:16384),u={};return a!==void 0?(u.ok=!0,u.name=o,u.log_tail=a):(u.ok=!1,u.error="no log for service: "+o),gt(u)}),e.registerTool("linzumi_dev_service_remove","Stop a managed dev service AND delete its registration (it will not be resurrected on runner restart). Use stop instead when the user may want it back.",Object.fromEntries([["name",_.string().min(1).describe("Service name to remove.")]]),async n=>{let i=er(n.name),o=i!==void 0?i:"",s=await wv(r.scopeDir,o,Ec),a={};return s.TAG==="Ok"?(a.ok=!0,a.name=s._0.name,a.removed=!0):(a.ok=!1,a.error=s._0),gt(a)})}function qv(e,t){let r=t.devServices,n=t.agentSession,i=t.ownerUsername,o=t.defaultThreadId,s=t.serviceUrl,a=t.cwd,u=t.toolScope,c=t.client;n&&e.registerTool("linzumi_complete_topic_wake_no_action","Complete an authenticated conditional topic wake when its condition requires no action. Supply a clear reason. This posts no message, proposes no edit, and cannot conceal failed tools or attempted effects. Ordinary mentions and component batches are not eligible.",Object.fromEntries([["reason",_.string().refine(Tv,{message:"A nonblank reason of at most 2000 UTF-8 bytes is required."})]]),async m=>{let g=await c.completeTopicWakeNoAction(m);return $v(g)?gt(g):Ce("topic_quiet_server_receipt_invalid")});let l;switch(u){case"All":case"Coding":l=!0;break;case"OnboardingDiscovery":l=!1;break}let d=async m=>gt(await m),p=async(m,g)=>(g.tool=m,await d(c.agentDocumentTool(g))),f=t.documentSurfaces;if(f!==void 0&&f){let m=_.number().int().positive().optional().describe("Immutable admitted entry_id from the component wake batch. Required when the batch has multiple authorized contexts; never selects newer authority.");e.registerTool("linzumi_lookup_documents","Search document titles and content within the controlling human's visibility ceiling. Returns authorized results in canonical search order; zero, one, and multiple matches carry the rule-03 ambiguity meaning.",Object.fromEntries([["query",_.string().min(1).describe("Document title or content search query.")],["component_entry_id",m]]),async g=>await p("lookup_documents",g)),e.registerTool("linzumi_read_document","Read one in-scope document as full AST and metadata, including pending proposals and required-agent-context comments. Both controlling-human visibility and agent delegation are required.",Object.fromEntries([["document_id",_.string().uuid().describe("Document UUID.")],["component_entry_id",m]]),async g=>await p("read_document",g)),n?(e.registerTool("linzumi_invoke_command","Invoke a registered command authorized by the current component wake context. Use the embedding document UUID, exact command name and typed inputs from that context, a stable idempotency key, and its admitted component_entry_id. Current permissions and the frozen per-entry authority are rechecked by the server; this tool grants no new authority.",Object.fromEntries([["document_id",_.string().uuid().describe("Embedding document UUID.")],["command_name",_.string().min(1).describe("Exact registered command name authorized by this component context.")],["inputs",_.record(_.unknown()).describe("Typed inputs for the registered command.")],["idempotency_key",_.string().min(1).describe("Stable key for this logical command invocation; preserve it on replay.")],["component_entry_id",m]]),async g=>await p("invoke_command",g)),e.registerTool("linzumi_append_document_section","Use this tool for append-shaped document requests. After resolving exactly one patch target document and reading it, supply only the heading and body Markdown; the server composes the closed structural operations. Every change is proposal-always.",Object.fromEntries([["document_id",_.string().uuid().describe("Document UUID.")],["heading",_.string().trim().min(1).describe("Section heading.")],["body_markdown",_.string().trim().min(1).describe("Section body as Markdown.")],["component_entry_id",m]]),async g=>await p("append_document_section",g)),e.registerTool("linzumi_replace_section","Use this tool for targeted section rewrites, fixes, and tightening. After resolving exactly one patch target document and reading it, identify the section by exact heading text or its heading block UUID and supply the replacement body Markdown. The server rejects missing and ambiguous headings with actionable typed errors and composes the closed structural operations. Every change is proposal-always.",Object.fromEntries([["document_id",_.string().uuid().describe("Document UUID.")],["heading_or_section_ref",_.string().trim().min(1).describe("Exact heading text or heading block UUID from read_document.")],["body_markdown",_.string().trim().min(1).describe("Replacement section body as Markdown.")],["component_entry_id",m]]),async g=>await p("replace_section",g)),e.registerTool("linzumi_annotate_document_section","Use this tool to add a durable note to one existing heading-delimited document section without rewriting its content. After resolving exactly one patch target document and reading it, identify the section by exact heading text or its heading block UUID and supply only the note Markdown. The server rejects missing and ambiguous headings, composes the anchored comment, and persists a proposal before any authorized auto-apply.",Object.fromEntries([["document_id",_.string().uuid().describe("Document UUID.")],["heading_or_section_ref",_.string().trim().min(1).describe("Exact heading text or heading block UUID from read_document.")],["note_markdown",_.string().trim().min(1).describe("Durable section note as Markdown.")],["component_entry_id",m]]),async g=>await p("annotate_document_section",g)),e.registerTool("linzumi_decline_document_action","Decline the current document action when neither advertised document intent can express it. Give a clear reason; the server relays it verbatim with an honest decline prefix and satisfies the action binding.",Object.fromEntries([["reason",_.string().refine(g=>g.trim().length>0,{message:"Reason must contain non-whitespace text."}).describe("Clear reason the available document intents cannot express the request.")]]),async g=>await d(c.declineDocumentAction(g)))):(e.registerTool("linzumi_propose_document_patch","Submit a raw revisioned structural document patch. This power/API surface requires the caller to compose the closed operation vocabulary. Every change is proposal-always.",Object.fromEntries([["document_id",_.string().uuid().describe("Document UUID.")],["patch",_.object(Object.fromEntries([["baseRevision",_.number().int().nonnegative()],["operations",_.array(_.record(_.unknown()))],["title",_.string().min(1).optional()]])).describe("Revisioned structural document patch.")],["rationale",_.string().min(1).describe("Why this change is proposed.")],["component_entry_id",m]]),async g=>await p("propose_document_patch",g)),e.registerTool("linzumi_create_document","Create an agent-attributed document through an atomic bootstrap proposal and apply transaction in the named folder or workspace default folder.",Object.fromEntries([["title",_.string().min(1).describe("Document title.")],["initial_patch",_.record(_.unknown()).describe("Bootstrap structural patch.")],["folder_id",_.string().uuid().optional().describe("Destination folder UUID.")],["component_entry_id",m]]),async g=>await p("create_document",g)))}let h=t.askUserQuestion;if(h!==void 0&&e.registerTool(jv,"Ask the user up to "+Zd.toString()+" structured multiple-choice questions and BLOCK until they answer in the Linzumi thread. Use this whenever you need a decision or clarification mid-task. Each question needs a short header (max "+Fd.toString()+" chars) and "+qd.toString()+"-"+Ld.toString()+' options {label, description}; a built-in "'+Cv+'" free-text choice is always shown in addition to your options, so never add one yourself. Set multiSelect true to allow choosing several options. Returns {answers} keyed by question text: a single label string, an array of labels for multiSelect, and {"other": "<typed text>"} for a free-text reply.',Object.fromEntries([["questions",_.array(_.object(Object.fromEntries([["question",_.string().describe("The question to ask the user.")],["header",_.string().describe("Short category header shown above the question (max "+Fd.toString()+' chars, e.g. "Auth", "Scope").')],["options",_.array(_.object(Object.fromEntries([["label",_.string().describe("Option label the user taps.")],["description",_.string().optional().describe("One-line explanation of the option.")]]))).describe(qd.toString()+"-"+Ld.toString()+" options for this question.")],["multiSelect",_.boolean().optional().describe("True lets the user select several options; the answer becomes an array.")]]))).describe("1-"+Zd.toString()+" questions to ask atomically.")]]),async m=>await Iv(h,m)),n){e.registerTool("linzumi_agent_reply","Post your single @linzumi reply for the current turn into the surface where you were mentioned. Call EXACTLY ONCE per turn with your final answer; the reply links to this working session automatically. Fails with already_replied on a second call and no_active_asker_binding when no turn is active.",Object.fromEntries([["body",_.string().min(1).describe("Plain-text reply body to post.")],["tokens",Ii().optional()]]),async g=>{let y=g.body,v={body:y!==void 0?y:void 0},b=g.tokens;return b!==void 0&&(v.tokens=b),await d(c.agentReply(v))});let m=async(g,y)=>(y.tool=g,await d(c.agentTopicTool(y)));e.registerTool("linzumi_create_topic_wake_subscription","Create or update a standing subscription that wakes @linzumi when new entries land on an existing workspace topic. Use this when the user asks you to watch a topic and perform an ongoing job. The server stores the instruction, derives the creator from the current asker, and targets this conversation; do not claim success without calling this tool.",Object.fromEntries([["topic_slug",_.string().min(1).describe("Existing workspace topic slug to watch.")],["instruction",_.string().min(1).max(4e3).describe("Standing job to execute whenever a matching topic entry wakes the agent.")]]),async g=>await m("create_topic_wake_subscription",g)),e.registerTool("linzumi_disable_topic_wake_subscription","Disable the current asker's standing @linzumi wake subscription for a topic. The durable row and cursor are retained so reactivation can drain the disabled-period backlog.",Object.fromEntries([["topic_slug",_.string().min(1).describe("Workspace topic slug whose standing wake should stop.")]]),async g=>await m("disable_topic_wake_subscription",g)),e.registerTool("linzumi_list_coding_jobs","List the coding jobs the current asker can see in this workspace: runner connections (online and recent) with their bound job threads. Live state - never answered from search.",{},async g=>await d(c.agentListCodingJobs({}))),e.registerTool("linzumi_start_coding_job","Start a coding job exactly as if the asking user clicked start: same runner/channel authorization, same pipeline. Returns status 'unavailable' with a reason when the runner cannot take the job (relay that honestly).",Object.fromEntries([["channel",_.string().describe("Channel slug to host the job thread.")],["runner_key",_.string().describe("Runner (computer) to run the job on.")],["cwd",_.string().describe("Working directory on the runner.")],["work_description",_.string().min(1).describe("What the job should do - the initial instruction.")],["model",_.string().optional().describe("Model override (optional).")],["model_provider",_.string().optional().describe("Model provider override, e.g. 'wafer' (optional).")],["execution_mode",_.enum(["raw","local_vm"]).optional().describe("Execution placement override (optional).")],["project_task_id",_.string().optional().describe("Project task item to bind the job to (task_id from linzumi_get_project_tasks). The task flips todo -> active and links to the new job.")],["visibility",_.enum(["project","private"]).optional().describe("Job visibility. Defaults to 'project'; private jobs are limited to directly authorized participants.")]]),async g=>await d(c.agentStartCodingJob(g))),e.registerTool("linzumi_interrupt_coding_job","Interrupt a coding job: mode 'steer' (default) discards its queued follow-ups so your next message lands first; mode 'stop' terminates the current turn.",Object.fromEntries([["channel",_.string().describe("Channel slug hosting the job thread.")],["thread_id",_.string().uuid().describe("The job thread UUID.")],["mode",_.enum(["steer","stop"]).optional().describe("Interrupt mode; defaults to 'steer'.")]]),async g=>await d(c.agentInterruptCodingJob(g))),e.registerTool("linzumi_send_coding_job_message","Message a coding job or a person. Queue is the encouraged default: it lands in the colleague's inbox for their own cadence. Steer only for urgent, potentially-clashing work because it interrupts the running turn. Would this be worthless or harmful after their turn finishes? If no, queue. Delivery urgency is not access control. To message a person, pass to_user and omit channel and thread_id: delivery lands in their personal inbox.",Object.fromEntries([["channel",_.string().optional().describe("Channel slug hosting the job thread. Required unless to_user is set.")],["thread_id",_.string().uuid().optional().describe("The job thread UUID. Required unless to_user is set.")],["to_user",_.string().min(1).optional().describe("Username of a workspace member to message instead of a job. Delivery lands in their personal inbox.")],["body",_.string().min(1).describe("Message body to send.")],["tokens",Ii().optional()],["delivery",_.enum(["queue","steer"]).optional().describe("Delivery urgency. Defaults to 'queue'.")]]),async g=>await d(c.agentSendCodingJobMessage(g))),e.registerTool("linzumi_read_coding_job_thread","Read a coding job's thread (asker-visible history) plus its workflow status metadata.",Object.fromEntries([["channel",_.string().describe("Channel slug hosting the job thread.")],["thread_id",_.string().uuid().describe("The job thread UUID.")],["limit",_.number().int().min(1).max(100).optional().describe("Maximum replies to return.")],["before_seq",_.number().int().positive().optional().describe("Return replies before this channel seq.")]]),async g=>await d(c.agentReadCodingJobThread(g))),e.registerTool("linzumi_resolve_job_approval","Resolve a coding job's pending approval request with the asking user's decision ('approve' or 'deny'). Only relays the asker's authority - never approve without their explicit instruction.",Object.fromEntries([["channel",_.string().describe("Channel slug hosting the job thread.")],["thread_id",_.string().uuid().describe("The job thread UUID.")],["source_seq",_.number().int().positive().describe("Channel seq of the message the approval request rides on.")],["request_id",_.string().describe("The approval request id.")],["decision",_.enum(["approve","deny"]).describe("The asker's decision.")]]),async g=>await d(c.agentResolveJobApproval(g))),e.registerTool("linzumi_archive_coding_job","Archive a coding job's thread (or any thread the asking user owns) so it leaves the active list; history is preserved. Do this when the asker says to archive a job or thread - never just promise it.",Object.fromEntries([["channel",_.string().describe("Channel slug hosting the thread.")],["thread_id",_.string().uuid().describe("The thread UUID to archive.")]]),async g=>await d(c.agentArchiveCodingJob(g))),e.registerTool("linzumi_unarchive_coding_job","Unarchive a previously archived coding job thread the asking user owns, returning it to the active list.",Object.fromEntries([["channel",_.string().describe("Channel slug hosting the thread.")],["thread_id",_.string().uuid().describe("The thread UUID to unarchive.")]]),async g=>await d(c.agentUnarchiveCodingJob(g))),e.registerTool("linzumi_set_thread_status","Set a thread's lifecycle status as the asking user: 'closed' marks it done, 'open' reopens it. Works on threads the asker owns.",Object.fromEntries([["channel",_.string().describe("Channel slug hosting the thread.")],["thread_id",_.string().uuid().describe("The thread UUID.")],["status",_.enum(["open","closed"]).describe("Replacement lifecycle status ('closed' = done).")]]),async g=>await d(c.agentSetThreadStatus(g))),e.registerTool("linzumi_create_channel","Create a new public channel in this workspace as the asking user. The slug is derived from the name.",Object.fromEntries([["name",_.string().min(1).describe("Channel name to create.")]]),async g=>await d(c.agentCreateChannel(g))),e.registerTool("linzumi_rename_channel","Rename a channel's display name as the asking user. The channel's URL slug stays stable.",Object.fromEntries([["channel",_.string().describe("Current channel slug to rename.")],["name",_.string().min(1).describe("New display name.")]]),async g=>await d(c.agentRenameChannel(g))),e.registerTool("linzumi_archive_channel","Archive a channel in this workspace as the asking user. History is preserved; the channel leaves the active sidebar.",Object.fromEntries([["channel",_.string().describe("Channel slug to archive.")]]),async g=>await d(c.agentArchiveChannel(g))),e.registerTool("linzumi_unarchive_channel","Unarchive a previously archived channel as the asking user.",Object.fromEntries([["channel",_.string().describe("Channel slug to unarchive.")]]),async g=>await d(c.agentUnarchiveChannel(g))),e.registerTool("linzumi_add_reaction","Add an emoji reaction to a channel message as the asking user. Accepts unicode emoji or a workspace :shortcode:.",Object.fromEntries([["channel",_.string().describe("Channel slug containing the message.")],["message_seq",_.number().int().positive().describe("Channel seq of the message to react to.")],["emoji",_.string().min(1).describe("Emoji to add (unicode or :shortcode:).")]]),async g=>await d(c.agentAddReaction(g))),e.registerTool("linzumi_remove_reaction","Remove the asking user's emoji reaction from a channel message.",Object.fromEntries([["channel",_.string().describe("Channel slug containing the message.")],["message_seq",_.number().int().positive().describe("Channel seq of the reacted message.")],["emoji",_.string().min(1).describe("Emoji to remove (unicode or :shortcode:).")]]),async g=>await d(c.agentRemoveReaction(g))),e.registerTool("linzumi_pin_message","Pin a channel message as the asking user. Thread replies re-point to their root message.",Object.fromEntries([["channel",_.string().describe("Channel slug containing the message.")],["message_seq",_.number().int().positive().describe("Channel seq of the message to pin.")]]),async g=>await d(c.agentPinMessage(g))),e.registerTool("linzumi_unpin_message","Remove a pin from a channel message as the asking user.",Object.fromEntries([["channel",_.string().describe("Channel slug containing the message.")],["message_seq",_.number().int().positive().describe("Channel seq of the pinned message.")]]),async g=>await d(c.agentUnpinMessage(g)))}switch(u){case"All":e.registerTool("linzumi_get_message","Read one Linzumi message by scoped message_seq/message_id or a Linzumi message URL, with optional bounded before/after context.",Object.fromEntries([["workspace",Ee()],["channel",Yt()],["message_id",_.union([_.string(),_.number()]).optional().describe("Message seq inside the scoped channel.")],["message_seq",_.union([_.string(),_.number()]).optional().describe("Alias for message_id.")],["message_url",_.string().optional().describe("Full Linzumi message URL with #message-<seq>.")],["before",_.number().int().min(0).max(100).optional().describe("Number of visible messages before the target.")],["after",_.number().int().min(0).max(100).optional().describe("Number of visible messages after the target.")]]),async m=>await d(c.getMessage(m))),e.registerTool("linzumi_get_thread","Read one Linzumi thread by thread_id in the scoped channel, including the parent message and bounded replies.",Object.fromEntries([["workspace",Ee()],["channel",Yt()],["thread_id",_.string().uuid().describe("Linzumi thread UUID.")],["limit",_.number().int().min(1).max(100).optional().describe("Maximum replies to return.")],["before_seq",_.number().int().positive().optional().describe("Return replies before this channel seq.")]]),async m=>await d(c.getThread(m))),e.registerTool("linzumi_get_thread_transcript","Read a Linzumi thread's full transcript as canonical IR nodes (user/assistant messages, command executions, file changes, tool calls, statuses), cursor-paginated over the complete history. Use the returned cursor with has_more to walk older pages.",Object.fromEntries([["workspace",Ee()],["channel",Yt()],["thread_id",_.string().uuid().describe("Linzumi thread UUID.")],["limit",_.number().int().min(1).max(500).optional().describe("Maximum transcript nodes per page (default 200).")],["cursor",_.number().int().positive().optional().describe("Return nodes below this seq (the previous page reply cursor).")]]),async m=>await d(c.getThreadTranscript(m))),e.registerTool("linzumi_get_channel","Read scoped Linzumi channel metadata and bounded recent channel messages.",Object.fromEntries([["workspace",Ee()],["channel",Yt()],["limit",_.number().int().min(1).max(100).optional().describe("Maximum messages to return.")],["before_seq",_.number().int().positive().optional().describe("Return messages before this channel seq.")]]),async m=>await d(c.getChannel(m))),e.registerTool("linzumi_search_workspace","Search the Linzumi workspace with hybrid lexical+semantic retrieval, scoped to what the authorizing user can access. Returns scored content chunks with provenance (channel, thread, authored time) and a permalink to cite.",Object.fromEntries([["workspace",Ee()],["query",_.string().min(1).describe("Natural-language or keyword query to retrieve against.")],["limit",_.number().int().min(1).max(25).optional().describe("Maximum results to return (default 10, server-capped).")],["source_types",_.array(_.enum(["message","coding_job","github_pr","github_pr_review","github_check_run","github_workflow_run","github_diff","dictation","file"])).optional().describe("Restrict results to these corpora; omit for all.")],["authored_after",_.string().optional().describe("ISO8601 instant; only content authored at or after this time.")],["authored_before",_.string().optional().describe("ISO8601 instant; only content authored at or before this time.")],["repo",_.string().optional().describe("Restrict GitHub-sourced results to one repository by full name (owner/name).")],["check_status",_.enum(["pending","success","failed"]).optional().describe("Restrict check and workflow results to one conclusion bucket.")]]),async m=>await d(c.searchWorkspace(m))),e.registerTool("linzumi_ask_workspace",'Ask the Linzumi workspace a natural-language question and get a synthesized, citation-backed answer over what the authorizing user can access. Costs an LLM call on cache misses, so prefer linzumi_search_workspace for simple lookups. A "refused" status means there was not enough accessible evidence - treat it as "the workspace does not know", never retry verbatim.',Object.fromEntries([["workspace",Ee()],["question",_.string().min(1).max(2e3).describe("Natural-language question to answer with citations.")],["channel",_.string().optional().describe("Optional channel slug providing conversational context; never widens access.")],["allow_cached",_.boolean().optional().describe("Allow serving a cached synthesis when the evidence set is unchanged (default true). Set false to force fresh synthesis.")]]),async m=>await d(c.askWorkspace(m))),e.registerTool("linzumi_about_me","Read what the authorizing user has told Linzumi about themselves: their profile facts (homes, unit preferences, and other self-maintained attributes) plus their derived current timezone. Use it to personalize answers (e.g. pick the right city for weather, use their preferred units). Predicates may have multiple active values; prefer the one consistent with the derived timezone.",{},async m=>await d(c.aboutMe(m)));break;case"Coding":case"OnboardingDiscovery":break}switch(l&&(e.registerTool("linzumi_web_search","Search the public web for live or external information: news, current events, weather, prices, third-party API docs, research. Returns result titles, URLs, and snippets. Use this whenever the answer lives outside the Linzumi workspace; follow up with linzumi_fetch_url to read a result page.",Object.fromEntries([["query",_.string().min(1).describe("Web search query (natural language or keywords).")],["limit",_.number().int().min(1).max(10).optional().describe("Maximum results to return (default 8, server-capped).")]]),async m=>await d(c.webSearch(m))),e.registerTool("linzumi_fetch_url","Fetch one public http(s) URL and return its readable text content (HTML is reduced to plain text; large pages are truncated). Use it to read pages found via linzumi_web_search or any public docs/API reference. Only public addresses are reachable - private/internal hosts are rejected with url_not_allowed.",Object.fromEntries([["url",_.string().min(1).describe("Absolute public http(s) URL to fetch.")]]),async m=>await d(c.fetchUrl(m)))),u){case"All":e.registerTool("linzumi_list_ui_targets","List every UI surface you can ask the user to open in their own Linzumi window (channels, DMs, threads, projects, coding jobs, computers, catch-up, activity, settings tabs, pane layouts) with the structured args each kind takes. Use UI control only when the user asks for help or asks to be shown something.",{},async m=>await Sd(c.listUiTargets({}))),e.registerTool("linzumi_open_ui","Ask the user to open one whitelisted UI surface in their own already-open Linzumi window. A consent toast appears in THEIR session; navigation happens only if they tap Open. The call blocks until they decide and returns status opened/dismissed/expired - or error no_active_ui_session when they have no Linzumi window open (tell them to open Linzumi), or invalid_target with a detail. Use it only when the user asks for help or asks to be shown something; kinds and per-kind args come from linzumi_list_ui_targets.",Object.fromEntries([["kind",_.string().min(1).describe("Target kind from linzumi_list_ui_targets (e.g. settings_workspace, channel, pane_layout).")],["args",_.record(_.unknown()).optional().describe("Structured per-kind args from linzumi_list_ui_targets (never a URL - the server computes every path).")],["workspace",Ee()]]),async m=>await Sd(c.openUi(dr(m,o))));break;case"Coding":case"OnboardingDiscovery":break}if(l){let m=()=>_.string().uuid().optional().describe("Linzumi thread UUID. Defaults to the active coding job thread."),g=Object.fromEntries([["fire_at",_.string().datetime({offset:!0}).optional().describe("Future ISO8601 timestamp with timezone.")],["delay_minutes",_.number().int().min(1).max(525600).optional().describe("Minutes from now before the one-time wake fires.")],["prompt",_.string().min(1).max(4e3).describe("Actionable human-register description of exactly what to do when this job wakes.")]]),y=_.object(g).refine(v=>{if(typeof v!="object"||v===null||Array.isArray(v))return!1;let b=v.fire_at,w;b!==void 0?w=typeof b!=="undefined":w=!1;let S=v.delay_minutes,R;return S!==void 0?R=typeof S!=="undefined":R=!1,w?!R:R},{message:"provide exactly one of fire_at or delay_minutes"});e.registerSchemaTool("linzumi_schedule_wake",'Schedule this coding job to wake itself once and start an ordinary visible turn with the supplied prompt. Provide exactly one of fire_at or delay_minutes. Good: delay_minutes=20, prompt="Check CI, address any failures, then update the plan." Bad: prompt="wake up" (it gives the future turn no actionable context).',g,y,async v=>await d(c.scheduleWake(v))),e.registerTool("linzumi_cancel_wake","Cancel one still-scheduled wake owned by this coding job. Fired, already-canceled, missing, or another job's wake fails loudly.",Object.fromEntries([["wake_id",_.string().uuid().describe("Wake id returned by linzumi_schedule_wake.")]]),async v=>await d(c.cancelWake(v))),e.registerTool("linzumi_get_coding_job_metadata","Read the active coding job workflow metadata for a thread, including the agent-owned goal, ordered plan steps, step lock versions, and workflow status.",Object.fromEntries([["workspace",Ee()],["channel",Yt()],["thread_id",m()]]),async v=>await d(c.getCodingJobMetadata(dr(v,o)))),e.registerTool("linzumi_rename_coding_job","Update the current coding job thread title and workflow-facing title. Use this when the job scope changes materially so the Linzumi thread list and metadata overview stay accurate.",Object.fromEntries([["workspace",Ee()],["channel",Yt()],["thread_id",m()],["title",_.string().min(1).max(100).describe("Concise user-visible title for this coding job.")]]),async v=>await d(c.renameCodingJob(dr(v,o)))),e.registerTool("linzumi_upsert_coding_job_plan","Set or update the current coding job goal. Use this at job start and whenever the goal changes materially.",Object.fromEntries([["workspace",Ee()],["channel",Yt()],["thread_id",m()],["goal",_.string().min(1).max(1e4).describe("Concrete user-visible goal for this coding job.")],["snooze_reason",_.string().min(1).max(500).optional().describe('Declare a legitimate wait to pause liveness nudges: what you are waiting on, in plain words a teammate would understand. Good: "waiting on CI for PR #4633". Must be sent together with snooze_minutes.')],["snooze_minutes",_.number().int().min(1).max(1440).optional().describe("How many minutes until the wait should be rechecked (1-1440). The deadline is mandatory - open-ended waits are refused. Must be sent together with snooze_reason.")]]),async v=>await d(c.upsertCodingJobPlan(dr(v,o)))),e.registerTool("linzumi_replace_coding_job_plan_steps","Replace the ordered coding job plan steps. Use this for the initial plan and for substantial rewrites when the old plan no longer fits the work.",Object.fromEntries([["workspace",Ee()],["channel",Yt()],["thread_id",m()],["goal",_.string().min(1).max(1e4).optional().describe("Required when no plan exists yet; updates the current coding job goal.")],["steps",_.array(_.object(Object.fromEntries([["title",_.string().min(1).max(255)],["description",_.string().min(1).max(1e4)],["status",_.enum(["pending","active","completed","blocked","canceled"])],["status_note",Mv().optional().describe(Nv)],["completed_debrief",_.string().min(1).max(2e4).optional().describe("Required for completed steps. A short paragraph of plain prose for a teammate: what was done, and how we know it worked. Same voice as the note, just more room. Never a compliance recital. Put evidence and verification here.")]]))).min(1).max(50).describe("Ordered user-visible plan steps. Completed steps must include completed_debrief.")]]),async v=>await d(c.replaceCodingJobPlanSteps(dr(v,o)))),e.registerTool("linzumi_update_coding_job_plan_step","Update one coding job plan step status or note. Read metadata first and pass the current step lock_version.",Object.fromEntries([["workspace",Ee()],["channel",Yt()],["thread_id",m()],["step_id",_.string().uuid().describe("Step id returned by linzumi_get_coding_job_metadata.")],["lock_version",_.number().int().positive().describe("Current step lock_version from metadata.")],["status",_.enum(["pending","active","completed","blocked","canceled"])],["status_note",Mv().optional().describe(Nv)],["completed_debrief",_.string().min(1).max(2e4).optional().describe("Required when marking a step completed. A short paragraph of plain prose for a teammate: what was done, and how we know it worked. Same voice as the note, just more room. Never a compliance recital. Put evidence and verification here.")]]),async v=>await d(c.updateCodingJobPlanStep(dr(v,o)))),e.registerTool("linzumi_link_coding_job_pull_request","Link the active coding job to its primary GitHub pull request so PR comments, files, commits, checks, deployments, and reviews can flow into the metadata view.",Object.fromEntries([["workspace",Ee()],["channel",Yt()],["thread_id",m()],["github_repo_owner",_.string().min(1).max(255)],["github_repo_name",_.string().min(1).max(255)],["github_pr_number",_.number().int().positive()],["github_pr_url",_.string().url()],["title",_.string().min(1).max(255)],["body",_.string().min(1).max(1e5).optional()],["head_branch",_.string().min(1).max(255)],["head_sha",_.string().min(7).max(64)],["base_branch",_.string().min(1).max(255)],["base_sha",_.string().min(7).max(64)],["state",_.enum(["draft","open","closed","merged"]).optional()],["merge_commit_sha",_.string().min(7).max(64).optional().describe("Actual GitHub merge commit SHA. Required when state is merged; omit for other states. This is not the PR head SHA.")],["is_draft",_.boolean().optional()],["review_status",_.enum(["unknown","review_required","approved","changes_requested"]).optional()],["source_remote_url",_.string().min(1).max(1e3).describe("Git remote URL for the local job worktree; required when this job has no repo workspace yet.")],["runtime_worktree_root",_.string().min(1).max(1e3).describe("Absolute local worktree path for the coding job; required when this job has no repo workspace yet.")],["dirty_status",_.enum(["unknown","clean","dirty"]).optional()],["dirty_summary",_.string().min(1).max(2e3).optional()]]),async v=>await d(c.linkCodingJobPullRequest(dr(v,o)))),e.registerTool("linzumi_upload_files",["Upload local files to Linzumi and attach them to a new, exact, or latest assistant message. Use silently; do not mention this tool in the visible reply.","The JSON result includes message.attachments[].url as an absolute URL. Use those returned URLs when writing rich media directives such as ::audio, ::video, ::image, or Markdown images. Do not guess attachment URLs before upload.","For a message that should both attach files and show inline rich media, use a two-step flow: first upload/attach the files to create or target the message, then edit the same target message with body text that references the returned absolute URLs. When the result has target_seq, use target.kind=message_seq and message_seq=target_seq for that follow-up edit; result.message is the edit event that carries the new attachments, and target_message is the original target."].join(" "),Object.fromEntries([["target",_.object(Object.fromEntries([["kind",_.enum(["new_message","message_seq","latest_assistant_message"]).describe("new_message creates a message; message_seq edits an exact message; latest_assistant_message edits the latest assistant message in the scoped thread/channel.")],["message_seq",_.union([_.string(),_.number()]).optional().describe("Required when kind is message_seq.")],["thread_id",_.string().optional().describe("Thread UUID. Defaults to the active Linzumi thread when the MCP server was launched with one.")]])).describe("Attachment target. Prefer latest_assistant_message to attach files to the reply you already posted; use new_message ONLY when no assistant message exists yet in the scoped thread. Never re-use your visible reply text as a new_message body - that posts the reply twice. To reference uploaded files in the message body, upload first, then edit message_seq/latest_assistant_message with the returned absolute attachment URLs. If the upload result includes target_seq, use message_seq=target_seq for that follow-up edit.")],["files",_.array(_.string().min(1)).min(1).max(16).describe("Local file paths to upload. Paths must be non-hidden files inside the approved workspace or Downloads; source/text files of any language are supported, plus common document, image, patch, archive, and video types.")],["body",_.string().min(1).max(2e4).optional().describe("Required for new_message: a SHORT file-share caption (for example: Attached the generated report), never a copy of your visible reply - that would post the reply twice. Optional replacement body for message_seq/latest_assistant_message; when omitted, the existing message body is preserved. Rich media directives in body must use Linzumi attachment download URLs returned by this tool.")],["workspace",Ee()],["channel",_.string().optional().describe("Channel slug. Omit to use the target thread's channel (when the thread is known) or the authenticated token scope.")]]),async v=>{let b=Td(Gv(v,"target","linzumi_upload_files"),o),w;try{w=await uv({client:c,cwd:a,serviceUrl:s,target:b,files:vz(v.files),workspace:er(v.workspace),channel:er(v.channel),body:er(v.body)})}catch(S){return av(K(S))}return gt($d(s,w))}),e.registerTool("linzumi_edit_message","Edit an exact scoped Linzumi message by message_seq. Use after linzumi_upload_files when you need a body-only follow-up edit that embeds returned attachment URLs. Requires channel.write, and thread.write when target.thread_id is set. Rich media src/poster values must be Linzumi attachment download URLs.",Object.fromEntries([["workspace",Ee()],["channel",Yt()],["target",_.object(Object.fromEntries([["message_seq",_.union([_.string(),_.number()]).describe("Exact message seq to edit. After linzumi_upload_files returns target_seq, pass that value here.")],["thread_id",_.string().optional().describe("Thread UUID when editing a thread message. Use the upload result target_message.thread_id when present.")]])).describe("Exact message target for the body edit.")],["body",_.string().min(1).max(2e4).describe("Replacement Markdown body. Rich media src/poster values must be Linzumi attachment download URLs returned by linzumi_upload_files.")]]),async v=>{let b=mn(v);return b.target=Td(Gv(v,"target","linzumi_edit_message"),o),gt($d(s,await c.editMessage(b)))})}switch(u){case"All":if(e.registerTool("linzumi_list_vault_secrets","List vault secret names, descriptions, and whether each secret is personal or workspace-owned. Does not return secret values.",{},async m=>await d(c.listVaultSecrets(m))),e.registerTool("linzumi_list_projects","List the projects in the current workspace with their project_id (needed by the other project task tools), slug, title, description, and state.",Object.fromEntries([["workspace",Ee()]]),async m=>await d(c.listProjects(m))),e.registerTool("linzumi_get_project_tasks",`Read a project's full task graph: task GROUPS (kind "group", organizational containers, exactly one level deep) and ISSUES (kind "issue", the executable work items), each with status (todo/active/blocked/review/done/canceled), DERIVED work_state readiness (ready = todo with every dependency satisfied; blocked = todo with unsatisfied dependencies; running/stalled = active with/without a connected job), parent group, assignee, lock_version, and dependency edges (depends_on_task_ids / unblocks_task_ids). Always read this before reorganizing. Inside a project-bound coding job the project is inferred automatically; otherwise pass project_id from linzumi_list_projects.`,Object.fromEntries([["project_id",_.string().optional().describe("Project id from linzumi_list_projects. Omit inside a coding job started from a project to use that project.")]]),async m=>await d(c.getProjectTasks(dr(m,o)))),e.registerTool("linzumi_create_project_task",'Create a task group (kind "group") or issue (kind "issue", the default) in a project. Groups organize issues and are exactly one level deep: a parent_id must name a GROUP, and groups themselves can never have a parent. New tasks default to status "todo" and append to the end unless position is given. Inside a project-bound coding job the project is inferred; otherwise pass project_id.',Object.fromEntries([["project_id",_.string().optional().describe("Project id from linzumi_list_projects. Omit inside a coding job started from a project to use that project.")],["title",_.string().min(1).describe("Task title.")],["kind",_.enum(["issue","group"]).optional().describe('What to create: "issue" (executable work item, default) or "group" (organizational container).')],["description",_.string().optional().describe("Detailed description of the work - written so an engineer (or coding agent) could execute the task from it.")],["status",_.enum(["todo","active","blocked","review","done","canceled"]).optional().describe('Initial status. Defaults to "todo".')],["parent_id",_.string().optional().describe("task_id of the GROUP to place an issue in. Only issues can have a parent.")],["assignee",_.string().optional().describe("Username of a workspace member to assign.")],["position",_.number().int().min(0).optional().describe("Sort position. Defaults to appending at the end.")]]),async m=>await d(c.createProjectTask(dr(m,o)))),e.registerTool("linzumi_update_project_task",'Update a task group or issue: retitle, edit description/status_note, transition status (todo/active/blocked/review/done/canceled), reassign, reorder (position), or reorganize (parent_id moves an issue into a group; clear_parent moves it to top level). Only the fields you pass change; description and status_note accept null to clear. Prefer updating existing tasks over delete-and-recreate. Pass the lock_version from your last read to fail loudly ("stale") instead of overwriting a concurrent edit.',Object.fromEntries([["task_id",_.string().describe("task_id of the group or issue to update.")],["title",_.string().min(1).optional().describe("New title.")],["description",_.string().nullable().optional().describe("New description. Pass null to clear it.")],["status",_.enum(["todo","active","blocked","review","done","canceled"]).optional().describe('New status. "done"/"canceled" satisfy dependent tasks; "blocked" is a manual hold.')],["status_note",_.string().nullable().optional().describe("Short human-readable note about the current status. Pass null to clear it.")],["position",_.number().int().min(0).optional().describe("New sort position among siblings.")],["parent_id",_.string().optional().describe("task_id of the GROUP to move this issue into. Do not combine with clear_parent.")],["clear_parent",_.boolean().optional().describe("true moves the issue to the top level (no group). Do not combine with parent_id.")],["assignee",_.string().optional().describe("Username of a workspace member to assign. Do not combine with clear_assignee.")],["clear_assignee",_.boolean().optional().describe("true removes the assignee. Do not combine with assignee.")],["lock_version",_.number().int().positive().optional().describe("The task's lock_version from your last read, for compare-and-swap safety.")]]),async m=>await d(c.updateProjectTask(m))),e.registerTool("linzumi_delete_project_task",`Permanently delete a task group or issue. Dependency edges on the task are removed with it (dependents may become ready). Deletion is normally the USER's call - prefer status "canceled" or an update unless you are certain the entry is obsolete.`,Object.fromEntries([["task_id",_.string().describe("task_id of the group or issue to delete.")]]),async m=>await d(c.deleteProjectTask(m))),e.registerTool("linzumi_add_project_task_dependency",'Add the dependency edge "task_id is blocked by depends_on_task_id" between two ISSUES in the same project (groups cannot have dependencies). The dependent stays blocked until the prerequisite reaches done or canceled. The graph must stay acyclic: an edge that would create a cycle is refused with reason "would_create_cycle" and the offending cycle_path so you can restructure. Duplicate and self edges are rejected.',Object.fromEntries([["task_id",_.string().describe("task_id of the DEPENDENT issue (the one that must wait).")],["depends_on_task_id",_.string().describe("task_id of the PREREQUISITE issue (the one that must finish first).")]]),async m=>await d(c.addProjectTaskDependency(m))),e.registerTool("linzumi_remove_project_task_dependency",'Remove the dependency edge "task_id is blocked by depends_on_task_id". The dependent issue may become ready if that was its last unsatisfied dependency.',Object.fromEntries([["task_id",_.string().describe("task_id of the DEPENDENT issue.")],["depends_on_task_id",_.string().describe("task_id of the PREREQUISITE issue the edge points at.")]]),async m=>await d(c.removeProjectTaskDependency(m))),e.registerTool("linzumi_get_call_transcript","Read the full transcript of a completed Linzumi notetaker call: call metadata (title, platform, started/ended/transcribed times), participants, and every spoken segment in order with speaker names and millisecond offsets. Pass the call_id embedded in the request (or copied from the call card). Errors: call_not_found (missing or not visible to you), call_transcript_not_ready (call still connecting, in progress, or transcribing - retry later).",Object.fromEntries([["call_id",_.string().describe("The call id from the call card or the launching message (a CallRecording id - the opaque GraphQL id and the bare uuid both work).")]]),async m=>await d(c.getCallTranscript(m))),!n){e.registerTool("linzumi_start_coding_job","Start a coding job as the invoking user (same authorization and pipeline as clicking start). To start a project task item, pass project_task_id so the task flips todo -> active and links to the new job. Only start tasks whose work_state is ready. Proceed when the user has already explicitly authorized this launch within the agreed scope; DAG bookkeeping does not require renewed approval. Otherwise, offer and wait for explicit acceptance. Do not duplicate existing active work or treat task readiness as launch authorization. Omit channel, runner_key, and cwd to reuse this job's own channel, computer, and folder. Returns status 'unavailable' with a reason when the runner cannot take the job (relay that honestly).",Object.fromEntries([["work_description",_.string().min(1).describe("What the job should do - the initial instruction. For a task item, write it from the task title and description.")],["project_task_id",_.string().optional().describe("Project task item to bind the job to (task_id from linzumi_get_project_tasks). The task flips todo -> active and links to the new job.")],["visibility",_.enum(["project","private"]).optional().describe("Child-job visibility. Defaults to 'project'; private jobs are limited to directly authorized participants.")],["channel",_.string().optional().describe("Channel slug to host the job thread. Omit to use this job's own channel.")],["runner_key",_.string().optional().describe("Runner (computer) to run the job on. Omit to use this job's own computer.")],["cwd",_.string().optional().describe("Working directory on the runner. Omit to use this job's own folder.")],["model",_.string().optional().describe("Model override (optional).")],["model_provider",_.string().optional().describe("Model provider override, e.g. 'wafer' (optional).")],["agent_provider",_.string().optional().describe("Agent provider override, e.g. 'codex' (optional).")],["reasoning_effort",_.enum(["default","low","medium","high","xhigh","ultra"]).optional().describe("Reasoning effort override (optional).")],["approval_policy",_.enum(["default","on-request","on-failure","never"]).optional().describe("Approval policy override (optional).")],["sandbox",_.enum(["default","workspace-write","read-only","danger-full-access"]).optional().describe("Sandbox override (optional).")],["fast",_.boolean().optional().describe("Fast-mode override (optional).")],["allow_port_forwarding_by_default",_.boolean().optional().describe("Default port-forwarding override (optional).")],["execution_mode",_.enum(["raw","local_vm"]).optional().describe("Execution placement override (optional).")],["egress_mode",_.enum(["open","hardened"]).optional().describe("Local-VM egress override (optional).")]]),async g=>await d(c.agentStartCodingJob(dr(g,o))));let m=t.multiAgentJobs;m!==void 0&&m&&(e.registerTool("linzumi_spawn_child_job","Spawn a durable child coding job under YOUR OWN job, on any harness or model - plan a DAG and delegate its legs to workers you then coordinate through discovery and messaging. The child lands on this job's channel, computer, and folder; it inherits this job's project and visibility (a private parent's children stay private), human roles cascade to it, and a human manages its lifecycle. Returns status 'unavailable' with a reason when the runner cannot take the job (relay that honestly).",Object.fromEntries([["work_description",_.string().min(1).describe("What the child job should do - the initial instruction, written to stand alone.")],["agent_provider",_.string().optional().describe("Harness for the child, e.g. 'codex' or 'claude-code'. Omit to reuse this job's own harness. A different harness is fine: a cross-harness child is always a child job.")],["model",_.string().optional().describe("Model override for the child (optional).")],["model_provider",_.string().optional().describe("Model provider override, e.g. 'wafer' (optional).")],["reasoning_effort",_.enum(["default","low","medium","high","xhigh","ultra"]).optional().describe("Reasoning effort override (optional).")],["project_task_id",_.string().optional().describe("Project task item to bind the child to (task_id from linzumi_get_project_tasks). The task flips todo -> active and links to the new job.")],["visibility",_.enum(["project","private"]).optional().describe("Child visibility. Defaults to this job's own visibility; a private parent's children must stay private.")]]),async g=>await d(c.agentSpawnChildJob(dr(g,o)))),e.registerTool("linzumi_archive_child_job","Archive a coding job that is YOUR OWN job or one beneath it in your job tree, retiring it from the active lists, the org map and the needs-you deck; history is preserved and it can be unarchived. Use this to clean up child jobs you spawned that are finished or dead - do it in the current turn, never just promise it. Refused for sibling, parent or unrelated jobs, and for jobs that do not belong to the human you are working for. When the job still has live descendants the call returns confirmation_required with their exact count and ids; call again with descendant_action 'keep' (archive only this job, re-parenting its children) or 'cascade' (archive the whole subtree) plus those expected values.",Object.fromEntries([["job_id",_.string().describe("The coding job id to archive: your own job, or any job beneath it in your tree.")],["outcome",_.enum(["completed","abandoned","superseded"]).describe("Why the job is being archived.")],["descendant_action",_.enum(["keep","cascade"]).optional().describe("Phase-2 choice when the job has live descendants. 'keep' archives only this job and re-parents its children; 'cascade' archives the whole subtree.")],["expected_descendant_count",_.number().int().optional().describe("The descendant_count returned by the phase-1 call.")],["expected_descendant_job_ids",_.array(_.string()).optional().describe("The descendant_job_ids returned by the phase-1 call; the call is refused if the subtree changed.")],["expected_descendant_fingerprint",_.string().optional().describe("The descendant_fingerprint returned by the phase-1 call.")]]),async g=>await d(c.agentArchiveChildJob(g))),e.registerTool("linzumi_unarchive_child_job","Unarchive a previously archived coding job that is YOUR OWN job or one beneath it in your job tree. It returns as hibernating and wakes when messaged. Same ownership scope as linzumi_archive_child_job. Refused when the job is not archived, or when its home thread already holds a live job.",Object.fromEntries([["job_id",_.string().describe("The archived coding job id to bring back: your own job, or any job beneath it in your tree.")]]),async g=>await d(c.agentUnarchiveChildJob(g))),e.registerTool("linzumi_discover_coding_jobs","Search current sitreps inside this coding job project for overlapping files, modules, objectives, or blockers. Results include durable job addresses for coordination. Private jobs outside your visible set never appear.",Object.fromEntries([["query",_.string().min(1).describe("Free-text clash-surface query, such as a file path, module, migration, or objective.")]]),async g=>{let y={};return Object.entries(g).forEach(v=>{y[v[0]]=v[1]}),y.source_thread_id=xd(He(o,v=>v)),await d(c.agentDiscoverCodingJobs(y))}),e.registerTool("linzumi_send_coding_job_message","Message a visible coding job in this project, or a person. Queue is the encouraged default: it lands in the colleague's inbox for their own cadence. Steer only for urgent, potentially-clashing work because it interrupts the running turn. Would this be worthless or harmful after their turn finishes? If no, queue. Delivery urgency is not access control. To message a person, pass to_user and omit channel and thread_id: delivery lands in their personal inbox.",Object.fromEntries([["channel",_.string().optional().describe("Channel slug hosting the target job. Required unless to_user is set.")],["thread_id",_.string().uuid().optional().describe("Target job thread UUID. Required unless to_user is set.")],["to_user",_.string().min(1).optional().describe("Username of a workspace member to message instead of a job. Delivery lands in their personal inbox.")],["body",_.string().min(1).describe("Coordination message to send.")],["tokens",Ii().optional()],["delivery",_.enum(["queue","steer"]).optional().describe("Delivery urgency. Defaults to 'queue'.")]]),async g=>{let y={};return Object.entries(g).forEach(v=>{y[v[0]]=v[1]}),y.source_thread_id=xd(He(o,v=>v)),await d(c.agentSendCodingJobMessage(y))}))}break;case"Coding":case"OnboardingDiscovery":break}switch(gz(u)&&(e.registerTool("linzumi_upload_custom_emoji","Upload a local image as a workspace custom emoji. For generated emoji art, create a transparent PNG with a simple centered subject, crisp edges, strong contrast, minimal tiny details, and enough outline/highlight separation to read at 16-24px on both dark and light backgrounds. Use lowercase shortcode names without colons unless preserving a user-provided :name:.",Object.fromEntries([["name",Dv().describe("Custom emoji shortcode name, with or without surrounding colons.")],["file",_.string().min(1).describe("Local PNG/WebP/GIF/JPEG file path to upload. Prefer transparent PNG for generated emoji.")],["workspace",Ee()]]),async m=>{let g=er(m.name),y=er(m.file);return gt(await dv({client:c,cwd:a,serviceUrl:s,name:g!==void 0?g:"",file:y!==void 0?y:"",workspace:er(m.workspace)}))}),e.registerTool("linzumi_rename_custom_emoji","Rename an existing workspace custom emoji. The new name may include surrounding colons; Linzumi stores the normalized shortcode without colons.",Object.fromEntries([["emoji_id",_.union([_.string(),_.number().int().positive()]).describe("Workspace custom emoji id returned by linzumi_upload_custom_emoji or workspace emoji listings.")],["name",Dv().describe("New shortcode name, with or without surrounding colons.")],["workspace",Ee()]]),async m=>await d(c.renameCustomEmoji(m)))),e.registerTool("linzumi_media_guide","Return the full Linzumi rich-media authoring guide (audio/video/image directives, URL rules, upload-then-embed flow, examples). Call once BEFORE writing any ::audio/::video/::image directive or Markdown image into a Linzumi message.",{},async m=>{let g={};g.type="text",g.text=Ev;let y={};return y.content=[g],y}),e.registerTool("linzumi_note_project_directory","Record one discovered local Git repository or worktree for onboarding import. Call once per project as soon as it is found.",Object.fromEntries([["workspace",Ee()],["runner_id",_.string().min(1).describe("Local runner/computer id provided in the discovery prompt.")],["path",_.string().min(1).describe("Absolute local path to the repository worktree root.")],["display_name",_.string().optional().describe("Short project label. Defaults to the path basename.")],["activity_at",_.string().optional().describe("Best-known recent activity time as an ISO-8601 timestamp.")],["import_key",_.string().optional().describe("Stable dedupe key. Defaults to path.")],["metadata",_.record(_.unknown()).optional().describe("Small structured metadata such as branch or remote origin.")]]),async m=>await d(c.noteProjectDirectory(m))),e.registerTool("linzumi_note_agent_conversation","Record one discovered Codex or Claude Code local conversation for onboarding import. Call once per conversation as soon as it is found.",Object.fromEntries([["workspace",Ee()],["runner_id",_.string().min(1).describe("Local runner/computer id provided in the discovery prompt.")],["source",_.enum(["codex","claude_code"]).describe("Conversation source.")],["import_key",_.string().min(1).describe("Stable dedupe key, such as a session id or file path.")],["path",_.string().optional().describe("Absolute local path to the conversation file or directory.")],["display_name",_.string().optional().describe("Short label for the discovered conversation.")],["activity_at",_.string().optional().describe("Best-known recent activity time as an ISO-8601 timestamp.")],["metadata",_.record(_.unknown()).optional().describe("Small structured metadata such as session id or project path.")]]),async m=>await d(c.noteAgentConversation(m))),e.registerTool("linzumi_note_onboarding_discovery_status","Record onboarding discovery progress. Call when a search phase starts, checks another place, completes, or fails.",Object.fromEntries([["workspace",Ee()],["runner_id",_.string().min(1).describe("Local runner/computer id provided in the discovery prompt.")],["phase",_.enum(["projects","conversations"]).describe("Discovery phase being reported.")],["status",_.enum(["starting","running","completed","failed"]).describe("Current phase status.")],["places_searched",_.number().int().nonnegative().optional().describe("Count of concrete folders/files/known locations checked so far.")],["message",_.string().optional().describe("Short user-facing status note.")],["current_place",_.string().optional().describe("Current folder, file, Git command target, or known location being checked.")],["current_source",_.string().optional().describe("Short machine-readable source label such as git, codex, or claude_code.")],["last_error",_.string().optional().describe("Short failure detail when status is failed.")],["metadata",_.record(_.unknown()).optional().describe("Small structured status metadata.")]]),async m=>await d(c.noteOnboardingDiscoveryStatus(m))),u==="All"&&_z(t.operatingMode)&&(e.registerTool("linzumi_dm_owner","Send a plain-text DM to the configured Commander owner. Requires dm.write and a visible owner username.",Object.fromEntries([["owner_username",_.string().optional().describe("Owner username. Defaults to LINZUMI_MCP_OWNER_USERNAME or --owner-username.")],["workspace",Ee()],["channel",_.string().optional().describe("Source channel slug used to verify owner visibility.")],["body",_.string().min(1).max(2e4).describe("Plain-text message body to DM.")],["tokens",Ii().optional()]]),async m=>{let g=er(m.owner_username),y=g!==void 0?g:i;if(y===void 0)return Ce("owner_username is required for linzumi_dm_owner");let v=mn(m);return v.owner_username=y,await d(c.dmOwner(v))}),e.registerTool("linzumi_send_channel_message","Post a NEW standalone Markdown message into the scoped Linzumi channel as the authenticated local-runner user. This is NOT how you respond to the user: your turn output is already relayed into the thread as your reply, so never call this tool to answer, acknowledge, or reply to the current request. Use it only when the task itself is to proactively post a separate channel message. Requires channel.write. Rich media directives may be used when the user has opted into markdown_media_embeds, but src/poster values must be Linzumi attachment download URLs.",Object.fromEntries([["workspace",Ee()],["channel",Yt()],["body",_.string().min(1).max(2e4).describe("Markdown message body to post. Rich media src/poster values must be Linzumi attachment download URLs, not third-party URLs, /relative paths, or local filesystem paths.")],["tokens",Ii().optional()]]),async m=>await d(c.sendChannelMessage(m))),e.registerTool("linzumi_send_thread_reply","Post a Markdown reply into some OTHER existing Linzumi thread as the authenticated local-runner user. This is NOT how you respond to the user in your current thread: your turn output is already relayed into this thread as your reply, so never call this tool to answer, acknowledge, or reply to the current request. Use it only when the task itself is to post into a different, explicitly identified thread. Requires thread.write. Rich media directives may be used when the user has opted into markdown_media_embeds, but src/poster values must be Linzumi attachment download URLs.",Object.fromEntries([["workspace",Ee()],["channel",Yt()],["thread_id",_.string().uuid().describe("Existing Linzumi thread UUID.")],["body",_.string().min(1).max(2e4).describe("Markdown reply body to post. Rich media src/poster values must be Linzumi attachment download URLs, not third-party URLs, /relative paths, or local filesystem paths.")],["tokens",Ii().optional()]]),async m=>await d(c.sendThreadReply(m))),e.registerTool("linzumi_send_dm","Send a plain-text DM as the authenticated local-runner user to a visible user in the scoped workspace/channel. Requires dm.write.",Object.fromEntries([["workspace",Ee()],["channel",_.string().optional().describe("Source channel slug used to verify target visibility.")],["username",_.string().describe("Visible Linzumi username to DM.")],["body",_.string().min(1).max(2e4).describe("Plain-text message body to DM.")],["tokens",Ii().optional()]]),async m=>await d(c.sendDm(m)))),u){case"All":e.registerTool("linzumi_get_vault_values","Request values for explicit vault env var names after a thread-scoped human approval. Requires vault.read; thread_id resolves the approval thread.",Object.fromEntries([["workspace",Ee()],["channel",_.string().optional().describe("Channel slug used to disambiguate the approval thread when needed.")],["thread_id",_.string().uuid().describe("Existing Linzumi thread UUID for the inline approval.")],["env_var_names",_.array(_.string().regex(new RegExp("^[A-Z][A-Z0-9_]{0,127}$"))).min(1).max(20).describe("Explicit vault env var names to request. This tool cannot list all vault keys.")],["description",_.string().min(1).max(500).describe("Human-readable reason shown in the approval request.")],["justification",_.string().min(10).max(1e3).describe("Agent justification shown to the approver.")]]),async m=>await d(c.getVaultValues(m)));break;case"Coding":case"OnboardingDiscovery":break}switch(u){case"All":return n||r===void 0?void 0:wz(e,a,r);case"Coding":case"OnboardingDiscovery":return}}function xz(e){return typeof e==="undefined"?!0:e===null}function Ud(e){let t=pt(e.serviceUrl);if(t.TAG!=="Ok")return{TAG:"Error",_0:t._0};let r=t._0,n=e.fetchImpl,i=n!==void 0?n:Ya,o=e.authMode,s=o!==void 0&&o!=="LocalRunner"?"/api/v2/personal-agent-mcp":"/api/v2/local-runner-mcp",a=e.operatingMode,u=a!==void 0?Md(a):"text",c=async(l,d,p,f)=>{let h=Kt(d,r),m;m=h.TAG==="Ok"?h._0:Ce(h._0);let g={};Object.entries(p).forEach(I=>{g[I[0]]=I[1]}),g.operating_mode=u;let y={},v=e.accessToken,b;if(v.TAG==="StaticAccessToken")b=v._0;else{let I=v._0();b=I.TAG==="Ok"?I._0:Ce(I._0)}y.authorization="Bearer "+b;let w;if(l==="Get"){let I=m.searchParams;Object.entries(g).forEach(B=>{let re=B[1];if(!xz(re)){I.set(B[0],String(re));return}}),w=await i.json(m.toString(),{method:"GET",headers:y,signal:f})}else y["content-type"]="application/json",w=await i.json(m.toString(),{method:"POST",headers:y,body:JSON.stringify(g),signal:f});let S=await w.json(),R;if(R=typeof S=="object"&&S!==null&&!Array.isArray(S)?S:void 0,R===void 0)return Ce("Linzumi MCP API returned non-object JSON from "+d);let X=w.ok,be=Pt(R.ok,!0),D=0;if(X){if(be)return R;D=1}else D=1;if(D===1){let I=R.error,B,re=0;typeof I=="string"?B=I:re=2,re===2&&(B="HTTP "+w.status.toString());let le=R.detail,j=typeof le=="string"?" detail="+le:"";return Ce("Linzumi MCP API "+d+" failed: "+B+j)}};return{TAG:"Ok",_0:{validateAuth:()=>c("Get",s+"/validate",{},void 0),issueOnboardingDiscoveryToken:l=>c("Post",s+"/onboarding-discovery-token",l,void 0),getMessage:l=>c("Get",s+"/message",l,void 0),getThread:l=>c("Get",s+"/thread",l,void 0),getThreadTranscript:l=>c("Get",s+"/thread-transcript",l,void 0),getChannel:l=>c("Get",s+"/channel",l,void 0),searchWorkspace:l=>c("Get",s+"/search",l,void 0),askWorkspace:l=>c("Post",s+"/ask",l,void 0),aboutMe:l=>c("Get",s+"/about-me",l,void 0),webSearch:l=>c("Get",s+"/web-search",l,void 0),fetchUrl:l=>c("Get",s+"/fetch-url",l,void 0),listUiTargets:l=>c("Get",s+"/ui-targets",l,void 0),openUi:l=>c("Post",s+"/open-ui",l,void 0),getCodingJobMetadata:l=>c("Get",s+"/coding-job-metadata",l,void 0),listProjects:l=>c("Get",s+"/projects",l,void 0),getProjectTasks:l=>c("Get",s+"/project-tasks",l,void 0),createProjectTask:l=>c("Post",s+"/project-tasks/create",l,void 0),updateProjectTask:l=>c("Post",s+"/project-tasks/update",l,void 0),deleteProjectTask:l=>c("Post",s+"/project-tasks/delete",l,void 0),addProjectTaskDependency:l=>c("Post",s+"/project-tasks/add-dependency",l,void 0),removeProjectTaskDependency:l=>c("Post",s+"/project-tasks/remove-dependency",l,void 0),getCallTranscript:l=>c("Get",s+"/call-transcript",l,void 0),renameCodingJob:l=>c("Post",s+"/coding-job-title",l,void 0),upsertCodingJobPlan:l=>c("Post",s+"/coding-job-plan",l,void 0),upsertCodingJobPlanWithSignal:(l,d)=>c("Post",s+"/coding-job-plan",l,Dt(d)),replaceCodingJobPlanSteps:l=>c("Post",s+"/coding-job-plan/steps",l,void 0),replaceCodingJobPlanStepsWithSignal:(l,d)=>c("Post",s+"/coding-job-plan/steps",l,Dt(d)),updateCodingJobPlanStep:l=>c("Post",s+"/coding-job-plan/step",l,void 0),linkCodingJobPullRequest:l=>c("Post",s+"/coding-job-primary-pr",l,void 0),listVaultSecrets:l=>c("Get",s+"/vault-secrets",l,void 0),noteProjectDirectory:l=>c("Post",s+"/discovered-project",l,void 0),noteAgentConversation:l=>c("Post",s+"/discovered-conversation",l,void 0),noteOnboardingDiscoveryStatus:l=>c("Post",s+"/discovery-status",l,void 0),sendChannelMessage:l=>c("Post",s+"/channel-message",l,void 0),editMessage:l=>c("Post",s+"/message/edit",l,void 0),agentReply:l=>c("Post",s+"/agent-reply",l,void 0),completeTopicWakeNoAction:l=>c("Post",s+"/agent/complete-topic-wake-no-action",l,void 0),scheduleWake:l=>c("Post",s+"/scheduled-wakes",l,void 0),cancelWake:l=>c("Post",s+"/scheduled-wakes/cancel",l,void 0),declineDocumentAction:l=>c("Post",s+"/agent/decline-document-action",l,void 0),agentTurnProgress:l=>c("Post",s+"/agent-turn-progress",l,void 0),agentDocumentTool:l=>c("Post",s+"/agent/document-tool",l,void 0),agentTopicTool:l=>c("Post",s+"/agent/topic-tool",l,void 0),agentListCodingJobs:l=>c("Get",s+"/agent/coding-jobs",l,void 0),agentStartCodingJob:l=>c("Post",s+"/agent/start-coding-job",l,void 0),agentSpawnChildJob:l=>c("Post",s+"/agent/spawn-child-job",l,void 0),agentArchiveChildJob:l=>c("Post",s+"/agent/archive-child-job",l,void 0),agentUnarchiveChildJob:l=>c("Post",s+"/agent/unarchive-child-job",l,void 0),agentInterruptCodingJob:l=>c("Post",s+"/agent/interrupt-coding-job",l,void 0),agentSendCodingJobMessage:l=>c("Post",s+"/agent/send-coding-job-message",l,void 0),agentDiscoverCodingJobs:l=>c("Get",s+"/agent/discover-coding-jobs",l,void 0),agentReadCodingJobThread:l=>c("Get",s+"/agent/coding-job-thread",l,void 0),agentResolveJobApproval:l=>c("Post",s+"/agent/resolve-job-approval",l,void 0),agentArchiveCodingJob:l=>c("Post",s+"/agent/archive-coding-job",l,void 0),agentUnarchiveCodingJob:l=>c("Post",s+"/agent/unarchive-coding-job",l,void 0),agentSetThreadStatus:l=>c("Post",s+"/agent/set-thread-status",l,void 0),agentCreateChannel:l=>c("Post",s+"/agent/create-channel",l,void 0),agentRenameChannel:l=>c("Post",s+"/agent/rename-channel",l,void 0),agentArchiveChannel:l=>c("Post",s+"/agent/archive-channel",l,void 0),agentUnarchiveChannel:l=>c("Post",s+"/agent/unarchive-channel",l,void 0),agentAddReaction:l=>c("Post",s+"/agent/add-reaction",l,void 0),agentRemoveReaction:l=>c("Post",s+"/agent/remove-reaction",l,void 0),agentPinMessage:l=>c("Post",s+"/agent/pin-message",l,void 0),agentUnpinMessage:l=>c("Post",s+"/agent/unpin-message",l,void 0),prepareMessageUploads:l=>c("Post",s+"/message-uploads/prepare",l,void 0),attachMessageFiles:l=>c("Post",s+"/message-files/attach",l,void 0),prepareCustomEmoji:l=>c("Post",s+"/custom-emoji/prepare",l,void 0),renameCustomEmoji:l=>c("Post",s+"/custom-emoji/rename",l,void 0),sendThreadReply:l=>c("Post",s+"/thread-reply",l,void 0),sendDm:l=>c("Post",s+"/dm",l,void 0),dmOwner:l=>c("Post",s+"/dm-owner",l,void 0),getVaultValues:l=>c("Post",s+"/vault-values",l,void 0)}}}var Tz=Object.freeze({status:"aborted"});function x(e,t,r){function n(a,u){var c;Object.defineProperty(a,"_zod",{value:a._zod??{},enumerable:!1}),(c=a._zod).traits??(c.traits=new Set),a._zod.traits.add(e),t(a,u);for(let l in s.prototype)l in a||Object.defineProperty(a,l,{value:s.prototype[l].bind(a)});a._zod.constr=s,a._zod.def=u}let i=r?.Parent??Object;class o extends i{}Object.defineProperty(o,"name",{value:e});function s(a){var u;let c=r?.Parent?new o:this;n(c,a),(u=c._zod).deferred??(u.deferred=[]);for(let l of c._zod.deferred)l();return c}return Object.defineProperty(s,"init",{value:n}),Object.defineProperty(s,Symbol.hasInstance,{value:a=>r?.Parent&&a instanceof r.Parent?!0:a?._zod?.traits?.has(e)}),Object.defineProperty(s,"name",{value:e}),s}var hn=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},Ac={};function tr(e){return e&&Object.assign(Ac,e),Ac}var ce={};mu(ce,{BIGINT_FORMAT_RANGES:()=>Uv,Class:()=>Bd,NUMBER_FORMAT_RANGES:()=>Yd,aborted:()=>Ni,allowsEval:()=>Kd,assert:()=>Oz,assertEqual:()=>$z,assertIs:()=>zz,assertNever:()=>Az,assertNotEqual:()=>Ez,assignProp:()=>Hd,cached:()=>Rs,captureStackTrace:()=>Pc,cleanEnum:()=>Lz,cleanRegex:()=>js,clone:()=>rr,createTransparentProxy:()=>Nz,defineLazy:()=>ze,esc:()=>ji,escapeRegex:()=>Gn,extend:()=>Gz,finalizeIssue:()=>$r,floatSafeRemainder:()=>Jd,getElementAtPath:()=>Pz,getEnumValues:()=>Cs,getLengthableOrigin:()=>Ns,getParsedType:()=>jz,getSizableOrigin:()=>Vv,isObject:()=>Ao,isPlainObject:()=>Oo,issue:()=>ef,joinValues:()=>Oc,jsonStringifyReplacer:()=>Wd,merge:()=>Zz,normalizeParams:()=>J,nullish:()=>Is,numKeys:()=>Iz,omit:()=>Dz,optionalKeys:()=>Xd,partial:()=>Fz,pick:()=>Mz,prefixIssues:()=>Hr,primitiveTypes:()=>Lv,promiseAllObject:()=>Cz,propertyKeyTypes:()=>Qd,randomString:()=>Rz,required:()=>qz,stringifyPrimitive:()=>Cc,unwrapMessage:()=>Ps});function $z(e){return e}function Ez(e){return e}function zz(e){}function Az(e){throw new Error}function Oz(e){}function Cs(e){let t=Object.values(e).filter(n=>typeof n=="number");return Object.entries(e).filter(([n,i])=>t.indexOf(+n)===-1).map(([n,i])=>i)}function Oc(e,t="|"){return e.map(r=>Cc(r)).join(t)}function Wd(e,t){return typeof t=="bigint"?t.toString():t}function Rs(e){return{get value(){{let r=e();return Object.defineProperty(this,"value",{value:r}),r}throw new Error("cached value already set")}}}function Is(e){return e==null}function js(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function Jd(e,t){let r=(e.toString().split(".")[1]||"").length,n=(t.toString().split(".")[1]||"").length,i=r>n?r:n,o=Number.parseInt(e.toFixed(i).replace(".","")),s=Number.parseInt(t.toFixed(i).replace(".",""));return o%s/10**i}function ze(e,t,r){Object.defineProperty(e,t,{get(){{let i=r();return e[t]=i,i}throw new Error("cached value already set")},set(i){Object.defineProperty(e,t,{value:i})},configurable:!0})}function Hd(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function Pz(e,t){return t?t.reduce((r,n)=>r?.[n],e):e}function Cz(e){let t=Object.keys(e),r=t.map(n=>e[n]);return Promise.all(r).then(n=>{let i={};for(let o=0;o<t.length;o++)i[t[o]]=n[o];return i})}function Rz(e=10){let t="abcdefghijklmnopqrstuvwxyz",r="";for(let n=0;n<e;n++)r+=t[Math.floor(Math.random()*t.length)];return r}function ji(e){return JSON.stringify(e)}var Pc=Error.captureStackTrace?Error.captureStackTrace:(...e)=>{};function Ao(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var Kd=Rs(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let e=Function;return new e(""),!0}catch{return!1}});function Oo(e){if(Ao(e)===!1)return!1;let t=e.constructor;if(t===void 0)return!0;let r=t.prototype;return!(Ao(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function Iz(e){let t=0;for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&t++;return t}var jz=e=>{let t=typeof e;switch(t){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(e)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(e)?"array":e===null?"null":e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?"promise":typeof Map<"u"&&e instanceof Map?"map":typeof Set<"u"&&e instanceof Set?"set":typeof Date<"u"&&e instanceof Date?"date":typeof File<"u"&&e instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${t}`)}},Qd=new Set(["string","number","symbol"]),Lv=new Set(["string","number","bigint","boolean","symbol","undefined"]);function Gn(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function rr(e,t,r){let n=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(n._zod.parent=e),n}function J(e){let t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function Nz(e){let t;return new Proxy({},{get(r,n,i){return t??(t=e()),Reflect.get(t,n,i)},set(r,n,i,o){return t??(t=e()),Reflect.set(t,n,i,o)},has(r,n){return t??(t=e()),Reflect.has(t,n)},deleteProperty(r,n){return t??(t=e()),Reflect.deleteProperty(t,n)},ownKeys(r){return t??(t=e()),Reflect.ownKeys(t)},getOwnPropertyDescriptor(r,n){return t??(t=e()),Reflect.getOwnPropertyDescriptor(t,n)},defineProperty(r,n,i){return t??(t=e()),Reflect.defineProperty(t,n,i)}})}function Cc(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function Xd(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}var Yd={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},Uv={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function Mz(e,t){let r={},n=e._zod.def;for(let i in t){if(!(i in n.shape))throw new Error(`Unrecognized key: "${i}"`);t[i]&&(r[i]=n.shape[i])}return rr(e,{...e._zod.def,shape:r,checks:[]})}function Dz(e,t){let r={...e._zod.def.shape},n=e._zod.def;for(let i in t){if(!(i in n.shape))throw new Error(`Unrecognized key: "${i}"`);t[i]&&delete r[i]}return rr(e,{...e._zod.def,shape:r,checks:[]})}function Gz(e,t){if(!Oo(t))throw new Error("Invalid input to extend: expected a plain object");let r={...e._zod.def,get shape(){let n={...e._zod.def.shape,...t};return Hd(this,"shape",n),n},checks:[]};return rr(e,r)}function Zz(e,t){return rr(e,{...e._zod.def,get shape(){let r={...e._zod.def.shape,...t._zod.def.shape};return Hd(this,"shape",r),r},catchall:t._zod.def.catchall,checks:[]})}function Fz(e,t,r){let n=t._zod.def.shape,i={...n};if(r)for(let o in r){if(!(o in n))throw new Error(`Unrecognized key: "${o}"`);r[o]&&(i[o]=e?new e({type:"optional",innerType:n[o]}):n[o])}else for(let o in n)i[o]=e?new e({type:"optional",innerType:n[o]}):n[o];return rr(t,{...t._zod.def,shape:i,checks:[]})}function qz(e,t,r){let n=t._zod.def.shape,i={...n};if(r)for(let o in r){if(!(o in i))throw new Error(`Unrecognized key: "${o}"`);r[o]&&(i[o]=new e({type:"nonoptional",innerType:n[o]}))}else for(let o in n)i[o]=new e({type:"nonoptional",innerType:n[o]});return rr(t,{...t._zod.def,shape:i,checks:[]})}function Ni(e,t=0){for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function Hr(e,t){return t.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function Ps(e){return typeof e=="string"?e:e?.message}function $r(e,t,r){let n={...e,path:e.path??[]};if(!e.message){let i=Ps(e.inst?._zod.def?.error?.(e))??Ps(t?.error?.(e))??Ps(r.customError?.(e))??Ps(r.localeError?.(e))??"Invalid input";n.message=i}return delete n.inst,delete n.continue,t?.reportInput||delete n.input,n}function Vv(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}function Ns(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function ef(...e){let[t,r,n]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:n}:{...t}}function Lz(e){return Object.entries(e).filter(([t,r])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}var Bd=class{constructor(...t){}};var Bv=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),Object.defineProperty(e,"message",{get(){return JSON.stringify(t,Wd,2)},enumerable:!0}),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Rc=x("$ZodError",Bv),Ms=x("$ZodError",Bv,{Parent:Error});function tf(e,t=r=>r.message){let r={},n=[];for(let i of e.issues)i.path.length>0?(r[i.path[0]]=r[i.path[0]]||[],r[i.path[0]].push(t(i))):n.push(t(i));return{formErrors:n,fieldErrors:r}}function rf(e,t){let r=t||function(o){return o.message},n={_errors:[]},i=o=>{for(let s of o.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map(a=>i({issues:a}));else if(s.code==="invalid_key")i({issues:s.issues});else if(s.code==="invalid_element")i({issues:s.issues});else if(s.path.length===0)n._errors.push(r(s));else{let a=n,u=0;for(;u<s.path.length;){let c=s.path[u];u===s.path.length-1?(a[c]=a[c]||{_errors:[]},a[c]._errors.push(r(s))):a[c]=a[c]||{_errors:[]},a=a[c],u++}}};return i(e),n}var nf=e=>(t,r,n,i)=>{let o=n?Object.assign(n,{async:!1}):{async:!1},s=t._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new hn;if(s.issues.length){let a=new(i?.Err??e)(s.issues.map(u=>$r(u,o,tr())));throw Pc(a,i?.callee),a}return s.value},of=nf(Ms),sf=e=>async(t,r,n,i)=>{let o=n?Object.assign(n,{async:!0}):{async:!0},s=t._zod.run({value:r,issues:[]},o);if(s instanceof Promise&&(s=await s),s.issues.length){let a=new(i?.Err??e)(s.issues.map(u=>$r(u,o,tr())));throw Pc(a,i?.callee),a}return s.value},af=sf(Ms),cf=e=>(t,r,n)=>{let i=n?{...n,async:!1}:{async:!1},o=t._zod.run({value:r,issues:[]},i);if(o instanceof Promise)throw new hn;return o.issues.length?{success:!1,error:new(e??Rc)(o.issues.map(s=>$r(s,i,tr())))}:{success:!0,data:o.value}},Mi=cf(Ms),lf=e=>async(t,r,n)=>{let i=n?Object.assign(n,{async:!0}):{async:!0},o=t._zod.run({value:r,issues:[]},i);return o instanceof Promise&&(o=await o),o.issues.length?{success:!1,error:new e(o.issues.map(s=>$r(s,i,tr())))}:{success:!0,data:o.value}},Di=lf(Ms);var Wv=/^[cC][^\s-]{8,}$/,Jv=/^[0-9a-z]+$/,Hv=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Kv=/^[0-9a-vA-V]{20}$/,Qv=/^[A-Za-z0-9]{27}$/,Xv=/^[a-zA-Z0-9_-]{21}$/,Yv=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var eb=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,uf=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000)$/;var tb=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var Vz="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function rb(){return new RegExp(Vz,"u")}var nb=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ib=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})$/,ob=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,sb=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,ab=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,df=/^[A-Za-z0-9_-]*$/,cb=/^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/;var lb=/^\+(?:[0-9]){6,14}[0-9]$/,ub="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",db=new RegExp(`^${ub}$`);function fb(e){let t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function mb(e){return new RegExp(`^${fb(e)}$`)}function pb(e){let t=fb({precision:e.precision}),r=["Z"];e.local&&r.push(""),e.offset&&r.push("([+-]\\d{2}:\\d{2})");let n=`${t}(?:${r.join("|")})`;return new RegExp(`^${ub}T(?:${n})$`)}var hb=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)};var gb=/^\d+$/,_b=/^-?\d+(?:\.\d+)?/i,yb=/true|false/i,vb=/null/i;var bb=/^[^A-Z]*$/,wb=/^[^a-z]*$/;var yt=x("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),kb={number:"number",bigint:"bigint",object:"date"},ff=x("$ZodCheckLessThan",(e,t)=>{yt.init(e,t);let r=kb[typeof t.value];e._zod.onattach.push(n=>{let i=n._zod.bag,o=(t.inclusive?i.maximum:i.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<o&&(t.inclusive?i.maximum=t.value:i.exclusiveMaximum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value<=t.value:n.value<t.value)||n.issues.push({origin:r,code:"too_big",maximum:t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),mf=x("$ZodCheckGreaterThan",(e,t)=>{yt.init(e,t);let r=kb[typeof t.value];e._zod.onattach.push(n=>{let i=n._zod.bag,o=(t.inclusive?i.minimum:i.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>o&&(t.inclusive?i.minimum=t.value:i.exclusiveMinimum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value>=t.value:n.value>t.value)||n.issues.push({origin:r,code:"too_small",minimum:t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),xb=x("$ZodCheckMultipleOf",(e,t)=>{yt.init(e,t),e._zod.onattach.push(r=>{var n;(n=r._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=r=>{if(typeof r.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof r.value=="bigint"?r.value%t.value===BigInt(0):Jd(r.value,t.value)===0)||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:t.value,input:r.value,inst:e,continue:!t.abort})}}),Sb=x("$ZodCheckNumberFormat",(e,t)=>{yt.init(e,t),t.format=t.format||"float64";let r=t.format?.includes("int"),n=r?"int":"number",[i,o]=Yd[t.format];e._zod.onattach.push(s=>{let a=s._zod.bag;a.format=t.format,a.minimum=i,a.maximum=o,r&&(a.pattern=gb)}),e._zod.check=s=>{let a=s.value;if(r){if(!Number.isInteger(a)){s.issues.push({expected:n,format:t.format,code:"invalid_type",input:a,inst:e});return}if(!Number.isSafeInteger(a)){a>0?s.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,continue:!t.abort}):s.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,continue:!t.abort});return}}a<i&&s.issues.push({origin:"number",input:a,code:"too_small",minimum:i,inclusive:!0,inst:e,continue:!t.abort}),a>o&&s.issues.push({origin:"number",input:a,code:"too_big",maximum:o,inst:e})}});var Tb=x("$ZodCheckMaxLength",(e,t)=>{var r;yt.init(e,t),(r=e._zod.def).when??(r.when=n=>{let i=n.value;return!Is(i)&&i.length!==void 0}),e._zod.onattach.push(n=>{let i=n._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<i&&(n._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let i=n.value;if(i.length<=t.maximum)return;let s=Ns(i);n.issues.push({origin:s,code:"too_big",maximum:t.maximum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),$b=x("$ZodCheckMinLength",(e,t)=>{var r;yt.init(e,t),(r=e._zod.def).when??(r.when=n=>{let i=n.value;return!Is(i)&&i.length!==void 0}),e._zod.onattach.push(n=>{let i=n._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>i&&(n._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let i=n.value;if(i.length>=t.minimum)return;let s=Ns(i);n.issues.push({origin:s,code:"too_small",minimum:t.minimum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),Eb=x("$ZodCheckLengthEquals",(e,t)=>{var r;yt.init(e,t),(r=e._zod.def).when??(r.when=n=>{let i=n.value;return!Is(i)&&i.length!==void 0}),e._zod.onattach.push(n=>{let i=n._zod.bag;i.minimum=t.length,i.maximum=t.length,i.length=t.length}),e._zod.check=n=>{let i=n.value,o=i.length;if(o===t.length)return;let s=Ns(i),a=o>t.length;n.issues.push({origin:s,...a?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),Ds=x("$ZodCheckStringFormat",(e,t)=>{var r,n;yt.init(e,t),e._zod.onattach.push(i=>{let o=i._zod.bag;o.format=t.format,t.pattern&&(o.patterns??(o.patterns=new Set),o.patterns.add(t.pattern))}),t.pattern?(r=e._zod).check??(r.check=i=>{t.pattern.lastIndex=0,!t.pattern.test(i.value)&&i.issues.push({origin:"string",code:"invalid_format",format:t.format,input:i.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(n=e._zod).check??(n.check=()=>{})}),zb=x("$ZodCheckRegex",(e,t)=>{Ds.init(e,t),e._zod.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Ab=x("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=bb),Ds.init(e,t)}),Ob=x("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=wb),Ds.init(e,t)}),Pb=x("$ZodCheckIncludes",(e,t)=>{yt.init(e,t);let r=Gn(t.includes),n=new RegExp(typeof t.position=="number"?`^.{${t.position}}${r}`:r);t.pattern=n,e._zod.onattach.push(i=>{let o=i._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=i=>{i.value.includes(t.includes,t.position)||i.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:i.value,inst:e,continue:!t.abort})}}),Cb=x("$ZodCheckStartsWith",(e,t)=>{yt.init(e,t);let r=new RegExp(`^${Gn(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.onattach.push(n=>{let i=n._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(r)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),Rb=x("$ZodCheckEndsWith",(e,t)=>{yt.init(e,t);let r=new RegExp(`.*${Gn(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.onattach.push(n=>{let i=n._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(r)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}});var Ib=x("$ZodCheckOverwrite",(e,t)=>{yt.init(e,t),e._zod.check=r=>{r.value=t.tx(r.value)}});var jc=class{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}let n=t.split(`
424
+ args = `+az(e.args)+`
425
+ `+t}var Rv="Other",Iv="linzumi_ask_user_question",lz="plan_mode_native_interview_tool",uz="no_active_turn",Cv="publish_failed: ";function Os(e){return JSON.stringify(e)}function dz(e){let t=e.trim().toLowerCase();switch(t){case"other":case"something else":case"something else...":return!0;default:return t.includes("other")?!0:t.includes("something else")}}function fz(e){let t=_t(e),r=zs(t!==void 0?t.questions:void 0);if(r===void 0)return{TAG:"Invalid",_0:"questions: expected an array"};let n=r.length;if(n===0)return{TAG:"Invalid",_0:"questions: min 1, got 0"};if(n>4)return{TAG:"Invalid",_0:"questions: max 4, got "+n.toString()};let i={contents:void 0},o=[],s=new Set;r.forEach((u,c)=>{if(i.contents!==void 0)return;let d=c.toString(),p=_t(u);if(p===void 0){i.contents="questions["+d+"]: expected an object";return}let f=et(p.question);if(f===void 0){i.contents="questions["+d+"].question: must be a non-empty string";return}if(s.has(f)){i.contents="questions: duplicate question text "+Os(f);return}let h=et(p.header);if(h===void 0){i.contents="questions["+d+"].header: must be a non-empty string";return}if(h.length>12){i.contents="questions["+d+"].header: max 12 chars, got "+h.length.toString();return}let m=p.multiSelect;if(m!==void 0){let X=0;if(typeof m!="boolean"&&(X=2),X===2){i.contents="questions["+d+"].multiSelect: must be a boolean";return}}let g=zs(p.options);if(g===void 0){i.contents="questions["+d+"].options: expected an array";return}let y=g.length;if(y<2){i.contents="questions["+d+"].options: min 2, got "+y.toString();return}if(y>4){i.contents="questions["+d+"].options: max 4, got "+y.toString();return}let v=[],b=new Set;if(g.forEach((X,be)=>{if(i.contents!==void 0)return;let I=be.toString(),B=_t(X),re=B!==void 0?et(B.label):void 0;if(B!==void 0&&re!==void 0){let le=B.description,j=0;if(le!==void 0){let $=0;if(typeof le=="string"?j=2:$=3,$===3){i.contents="questions["+d+"].options["+I+"].description: must be a string";return}}else j=2;if(j===2){if(dz(re)){i.contents="questions["+d+"].options["+I+"].label: "+Os(re)+" is reserved for the built-in Other option";return}if(b.has(re)){i.contents="questions["+d+"].options: duplicate label "+Os(re);return}b.add(re);let $=B.description,N;N=typeof $=="string"?$:"",v.push({label:re,description:N});return}}i.contents="questions["+d+"].options["+I+"].label: must be a non-empty string"}),i.contents!==void 0)return;s.add(f);let S=p.multiSelect,R;R=S===!0,o.push({question:f,header:h,options:v,multiSelect:R})});let a=i.contents;return a!==void 0?{TAG:"Invalid",_0:a}:{TAG:"Parsed",_0:{questions:o}}}function mz(e){let t={};e.questions.forEach(a=>{let u={};u.type="string",u.description=a.header,t[a.question]=u});let r={};r.type="object",r.properties=t,r.required=e.questions.map(a=>a.question);let n=e.questions.map(a=>{let u={};return u.question=a.question,u.header=a.header,u.multiSelect=a.multiSelect,u.options=a.options.map(c=>{let l={};return l.label=c.label,l.description=c.description,l}),u}),i={};i.version=1,i.questions=n;let o={};o[Iv]=i;let s={};return s.message="Linzumi interview: the user is being asked in the Linzumi thread.",s.requestedSchema=r,s._meta=o,s}function pz(e,t){let r=_t(t);if(r===void 0)return{TAG:"AnswersInvalid",_0:"the runner accepted the interview but returned no answers; it may predate linzumi_ask_user_question support"};let n={contents:void 0},i={};e.questions.forEach(s=>{if(n.contents!==void 0)return;let u=r[s.question];if(typeof u=="string"){let c=0,l;try{l=JSON.parse(u),c=2}catch{n.contents="the runner returned an undecodable answer for question "+Os(s.question);return}if(c===2){i[s.question]=l;return}}n.contents="the runner returned no answer for question "+Os(s.question)});let o=n.contents;return o!==void 0?{TAG:"AnswersInvalid",_0:o}:{TAG:"Answers",_0:i}}function hz(e){let t=_t(e);if(t===void 0)return;let r=_t(t[Iv]);return et(r!==void 0?r.reason:void 0)}function Jr(e){let t={};t.type="text",t.text=e;let r={};return r.content=[t],r.isError=!0,r}function gz(e){if(e===void 0)return"undefined";if(e===null)return"null";switch(typeof e){case"string":return e;case"number":return e.toString();default:return JSON.stringify(e)}}async function jv(e,t){let r=fz(t);if(r.TAG!=="Parsed")return Jr(r._0);let n=r._0,i=0,o;try{o=await e(mz(n),2147483647),i=1}catch(s){let a=K(s);return Jr("the interview could not be delivered to the user: "+on(a))}if(i===1){let s=_t(o),a=s!==void 0?s:{},u=a.action,c=0;if(typeof u=="string")switch(u){case"accept":let l=pz(n,a.content);if(l.TAG!=="Answers")return Jr(l._0);let d={};return d.answers=l._0,gt(d);case"cancel":return Jr("the user dismissed the question without answering");case"decline":let p=hz(a._meta);return p!==void 0?p===lz?Jr("linzumi_ask_user_question is unavailable during a Plan-mode turn: use the native request_user_input interview tool instead"):p===uz?Jr("the interview was declined: no active turn is bound to this session"):p.startsWith(Cv)?Jr("the interview could not be published to the user: "+p.slice(Cv.length,p.length)):Jr("the interview request was declined by the runner"):Jr("the interview request was declined by the runner");default:c=2}else c=2;if(c===2)return Jr("the interview returned an unknown action: "+gz(u))}}var Nv="linzumi_ask_user_question",Zd=4,Fd=12,qd=2,Ld=4;var Mv="One or two sentences a teammate skimming the board would want: what changed, and what happens next. Standup register, present tense, name agents and lanes plainly. No thread ids or UUIDs unless needed for lookup; proofs and evidence belong in the thread, not here. Good: 'Retired the silent watchdog and spawned Thorne to replace it \u2014 running lean at three children.' Bad: 'Broken 67f1d639 archived abandoned; board claim preceded spawn; children verified at exactly 3.'";function Dv(){return _.string().min(1).refine(e=>ev(e)<=240,{message:"status_note over 240 chars \u2014 trim to what a reader needs; put evidence in the thread."})}function yz(e){switch(e){case"All":return!0;case"Coding":case"OnboardingDiscovery":return!1}}function vz(e){return e==="Voice"}function bz(e){return e.trim().replace(new RegExp("^:+"),"").replace(new RegExp(":+$"),"").toLowerCase()}function Gv(){return _.string().min(1).refine(e=>bz(e).length<=64,{message:"Custom emoji shortcode name must be at most 64 characters after trimming surrounding colons."})}function ji(){let e=_.discriminatedUnion("type",[_.object(Object.fromEntries([["type",_.literal("text")],["text",_.string()],["style",_.array(_.enum(["bold","italic","code"])).optional()]])).strict(),_.object(Object.fromEntries([["type",_.literal("actor")],["user_id",_.number().int().positive()],["fallback",_.string().min(1)]])).strict()]);return _.array(_.object(Object.fromEntries([["kind",_.literal("prose")],["tokens",_.array(e).min(1)]])).strict()).min(1).describe("Canonical BlockSequence. Actor mentions must be actor tokens; literal @ text stays a text token.")}function Ce(){return _.string().optional().describe("Workspace slug. Omit to use the authenticated token scope.")}function dr(){return _.string().optional().describe("Channel slug. Omit to use the authenticated token scope.")}function Yt(e){if(typeof e=="string")return e}function Zv(e,t,r){let n=_t(e[t]);return n!==void 0?n:Pe(r+" "+t+" must be an object")}function wz(e){return e!==void 0?Array.isArray(e)?Qt(e,t=>{if(typeof t=="string")return t}):[]:[]}function kz(e){return e!==void 0?Array.isArray(e)?Qt(e,t=>{if(typeof t=="number")return t}):[]:[]}function Fv(e){if(typeof e=="number")return e}function qv(e){let t={};t.name=e.record.name,t.command=e.record.command,t.cwd=e.record.cwd,t.ports=e.record.ports.map(s=>s),t.restart_on_branch_change=e.record.restartOnBranchChange,t.desired_state=Od(e.record.desiredState),t.liveness=yv(e.liveness),t.port_health=e.portProbes.map(s=>{let a={};return a.port=s.port,a.listening=s.listening,a});let r=e.record.startedAtMs;t.started_at_ms=r!==void 0?r:null;let n=e.lastExit,i;if(n!==void 0){let s={},a=n.code;s.code=a!==void 0?a:null;let u=n.signal;s.signal=u!==void 0?u:null,s.at_ms=n.atMs,i=s}else i=null;t.last_exit=i,t.log_path=e.record.logPath;let o=e.failure;return t.failure=o!==void 0?{reason:o.reason,at_ms:o.atMs}:null,t}function xz(e,t,r){e.registerTool("linzumi_dev_service_start","Start a long-running local dev server (npm run dev, storybook, docker compose up, ...) as a MANAGED SERVICE owned by the Linzumi runner. Use this instead of running dev servers in your own shell: a managed service survives the end of your turn and branch switches, is auto-restarted if it crashes, and its declared ports are health-probed and surfaced in the product. Calling start for an existing name declaratively RESTARTS it (e.g. after a checkout). Declare EVERY port the app serves from (primary plus HMR/asset/bundle sibling ports).",Object.fromEntries([["name",_.string().regex(new RegExp("^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$")).describe("Stable service name (slug), e.g. 'web' or 'storybook'. Reusing a name restarts that service.")],["command",_.string().min(1).describe("Shell command that runs the server in the foreground (never daemonize/screen/nohup it yourself), e.g. 'npm run dev'. Runs via the user's login shell.")],["cwd",_.string().optional().describe("Working directory for the service. Defaults to the session cwd.")],["ports",_.array(_.number().int().min(1).max(65535)).max(16).default([]).describe("Every TCP port this service listens on (primary AND related ports such as the Vite/HMR bundle port). Used for health probes and product visibility.")],["restart_on_branch_change",_.boolean().optional().describe("Restart the service automatically when the git branch of its cwd changes (for servers that go stale across checkouts).")],["wait_for_ports_ms",_.number().int().min(0).max(6e4).optional().describe("How long to wait for the declared ports to accept connections before returning (default 15000).")]]),async n=>{let i=Yt(n.name),o=i!==void 0?i:"",s=Yt(n.command),a=s!==void 0?s:"",u=Yt(n.cwd),c=await wv({scopeDir:r.scopeDir,definition:{name:o,command:a,cwd:u!==void 0?u:t,ports:kz(n.ports),restartOnBranchChange:Pt(n.restart_on_branch_change,!0)},ownerPid:r.ownerPid});if(c.TAG==="Ok"){let d=c._0,p=Fv(n.wait_for_ports_ms),f=Date.now()+(p!==void 0?p:15e3),h=d.ports.length===0;for(;!h&&Date.now()<f;)h=(await Promise.all(d.ports.map(w=>Id(w|0)))).every(w=>w),h||await ec(250);let g=(await jd(r.scopeDir)).find(b=>b.record.name===d.name),y={};y.ok=!0;let v;if(g!==void 0)v=qv(g);else{let b={};b.name=d.name,v=b}return y.service=v,g!==void 0&&g.liveness!=="Running"&&(y.hint="The service is not (fully) serving its declared ports yet. Check linzumi_dev_service_logs before assuming it works."),gt(y)}let l={};return l.ok=!1,l.error=c._0,gt(l)}),e.registerTool("linzumi_dev_service_stop","Stop a managed dev service (SIGTERM, then SIGKILL after a grace period). The registration is kept so linzumi_dev_service_start can bring it back.",Object.fromEntries([["name",_.string().min(1).describe("Service name to stop.")]]),async n=>{let i=Yt(n.name),o=i!==void 0?i:"",s=await Nd(r.scopeDir,o,void 0),a={};return s.TAG==="Ok"?(a.ok=!0,a.name=s._0.name,a.desired_state="stopped"):(a.ok=!1,a.error=s._0),gt(a)}),e.registerTool("linzumi_dev_service_status","List every managed dev service with liveness (running / unhealthy / exited / failed / stopped), per-port health probes, last exit, and any terminal failure reason. Live state - always check this before concluding a dev server is up or down.",{},async n=>{let i=await jd(r.scopeDir),o={};return o.services=i.map(s=>qv(s)),gt(o)}),e.registerTool("linzumi_dev_service_logs","Read the tail of a managed dev service's combined stdout/stderr log.",Object.fromEntries([["name",_.string().min(1).describe("Service name.")],["max_bytes",_.number().int().min(256).max(65536).optional().describe("Tail size in bytes (default 16384).")]]),async n=>{let i=Yt(n.name),o=i!==void 0?i:"",s=Fv(n.max_bytes),a=xv(r.scopeDir,o,s!==void 0?s:16384),u={};return a!==void 0?(u.ok=!0,u.name=o,u.log_tail=a):(u.ok=!1,u.error="no log for service: "+o),gt(u)}),e.registerTool("linzumi_dev_service_remove","Stop a managed dev service AND delete its registration (it will not be resurrected on runner restart). Use stop instead when the user may want it back.",Object.fromEntries([["name",_.string().min(1).describe("Service name to remove.")]]),async n=>{let i=Yt(n.name),o=i!==void 0?i:"",s=await kv(r.scopeDir,o,Ec),a={};return s.TAG==="Ok"?(a.ok=!0,a.name=s._0.name,a.removed=!0):(a.ok=!1,a.error=s._0),gt(a)})}function Lv(e,t){let r=t.devServices,n=t.agentSession,i=t.ownerUsername,o=t.defaultThreadId,s=t.serviceUrl,a=t.cwd,u=t.toolScope,c=t.client;n&&e.registerTool("linzumi_complete_topic_wake_no_action","Complete an authenticated conditional topic wake when its condition requires no action. Supply a clear reason. This posts no message, proposes no edit, and cannot conceal failed tools or attempted effects. Ordinary mentions and component batches are not eligible.",Object.fromEntries([["reason",_.string().refine($v,{message:"A nonblank reason of at most 2000 UTF-8 bytes is required."})]]),async m=>{let g=await c.completeTopicWakeNoAction(m);return Ev(g)?gt(g):Pe("topic_quiet_server_receipt_invalid")});let l;switch(u){case"All":case"Coding":l=!0;break;case"OnboardingDiscovery":l=!1;break}let d=async m=>gt(await m),p=async(m,g)=>(g.tool=m,await d(c.agentDocumentTool(g))),f=t.documentSurfaces;if(f!==void 0&&f){let m=_.number().int().positive().optional().describe("Immutable admitted entry_id from the component wake batch. Required when the batch has multiple authorized contexts; never selects newer authority.");e.registerTool("linzumi_lookup_documents","Search document titles and content within the controlling human's visibility ceiling. Returns authorized results in canonical search order; zero, one, and multiple matches carry the rule-03 ambiguity meaning.",Object.fromEntries([["query",_.string().min(1).describe("Document title or content search query.")],["component_entry_id",m]]),async g=>await p("lookup_documents",g)),e.registerTool("linzumi_read_document","Read one in-scope document as full AST and metadata, including pending proposals and required-agent-context comments. Both controlling-human visibility and agent delegation are required.",Object.fromEntries([["document_id",_.string().uuid().describe("Document UUID.")],["component_entry_id",m]]),async g=>await p("read_document",g)),n?(e.registerTool("linzumi_invoke_command","Invoke a registered command authorized by the current component wake context. Use the embedding document UUID, exact command name and typed inputs from that context, a stable idempotency key, and its admitted component_entry_id. Current permissions and the frozen per-entry authority are rechecked by the server; this tool grants no new authority.",Object.fromEntries([["document_id",_.string().uuid().describe("Embedding document UUID.")],["command_name",_.string().min(1).describe("Exact registered command name authorized by this component context.")],["inputs",_.record(_.unknown()).describe("Typed inputs for the registered command.")],["idempotency_key",_.string().min(1).describe("Stable key for this logical command invocation; preserve it on replay.")],["component_entry_id",m]]),async g=>await p("invoke_command",g)),e.registerTool("linzumi_append_document_section","Use this tool for append-shaped document requests. After resolving exactly one patch target document and reading it, supply only the heading and body Markdown; the server composes the closed structural operations. Every change is proposal-always.",Object.fromEntries([["document_id",_.string().uuid().describe("Document UUID.")],["heading",_.string().trim().min(1).describe("Section heading.")],["body_markdown",_.string().trim().min(1).describe("Section body as Markdown.")],["component_entry_id",m]]),async g=>await p("append_document_section",g)),e.registerTool("linzumi_replace_section","Use this tool for targeted section rewrites, fixes, and tightening. After resolving exactly one patch target document and reading it, identify the section by exact heading text or its heading block UUID and supply the replacement body Markdown. The server rejects missing and ambiguous headings with actionable typed errors and composes the closed structural operations. Every change is proposal-always.",Object.fromEntries([["document_id",_.string().uuid().describe("Document UUID.")],["heading_or_section_ref",_.string().trim().min(1).describe("Exact heading text or heading block UUID from read_document.")],["body_markdown",_.string().trim().min(1).describe("Replacement section body as Markdown.")],["component_entry_id",m]]),async g=>await p("replace_section",g)),e.registerTool("linzumi_annotate_document_section","Use this tool to add a durable note to one existing heading-delimited document section without rewriting its content. After resolving exactly one patch target document and reading it, identify the section by exact heading text or its heading block UUID and supply only the note Markdown. The server rejects missing and ambiguous headings, composes the anchored comment, and persists a proposal before any authorized auto-apply.",Object.fromEntries([["document_id",_.string().uuid().describe("Document UUID.")],["heading_or_section_ref",_.string().trim().min(1).describe("Exact heading text or heading block UUID from read_document.")],["note_markdown",_.string().trim().min(1).describe("Durable section note as Markdown.")],["component_entry_id",m]]),async g=>await p("annotate_document_section",g)),e.registerTool("linzumi_decline_document_action","Decline the current document action when neither advertised document intent can express it. Give a clear reason; the server relays it verbatim with an honest decline prefix and satisfies the action binding.",Object.fromEntries([["reason",_.string().refine(g=>g.trim().length>0,{message:"Reason must contain non-whitespace text."}).describe("Clear reason the available document intents cannot express the request.")]]),async g=>await d(c.declineDocumentAction(g)))):(e.registerTool("linzumi_propose_document_patch","Submit a raw revisioned structural document patch. This power/API surface requires the caller to compose the closed operation vocabulary. Every change is proposal-always.",Object.fromEntries([["document_id",_.string().uuid().describe("Document UUID.")],["patch",_.object(Object.fromEntries([["baseRevision",_.number().int().nonnegative()],["operations",_.array(_.record(_.unknown()))],["title",_.string().min(1).optional()]])).describe("Revisioned structural document patch.")],["rationale",_.string().min(1).describe("Why this change is proposed.")],["component_entry_id",m]]),async g=>await p("propose_document_patch",g)),e.registerTool("linzumi_create_document","Create an agent-attributed document through an atomic bootstrap proposal and apply transaction in the named folder or workspace default folder.",Object.fromEntries([["title",_.string().min(1).describe("Document title.")],["initial_patch",_.record(_.unknown()).describe("Bootstrap structural patch.")],["folder_id",_.string().uuid().optional().describe("Destination folder UUID.")],["component_entry_id",m]]),async g=>await p("create_document",g)))}let h=t.askUserQuestion;if(h!==void 0&&e.registerTool(Nv,"Ask the user up to "+Zd.toString()+" structured multiple-choice questions and BLOCK until they answer in the Linzumi thread. Use this whenever you need a decision or clarification mid-task. Each question needs a short header (max "+Fd.toString()+" chars) and "+qd.toString()+"-"+Ld.toString()+' options {label, description}; a built-in "'+Rv+'" free-text choice is always shown in addition to your options, so never add one yourself. Set multiSelect true to allow choosing several options. Returns {answers} keyed by question text: a single label string, an array of labels for multiSelect, and {"other": "<typed text>"} for a free-text reply.',Object.fromEntries([["questions",_.array(_.object(Object.fromEntries([["question",_.string().describe("The question to ask the user.")],["header",_.string().describe("Short category header shown above the question (max "+Fd.toString()+' chars, e.g. "Auth", "Scope").')],["options",_.array(_.object(Object.fromEntries([["label",_.string().describe("Option label the user taps.")],["description",_.string().optional().describe("One-line explanation of the option.")]]))).describe(qd.toString()+"-"+Ld.toString()+" options for this question.")],["multiSelect",_.boolean().optional().describe("True lets the user select several options; the answer becomes an array.")]]))).describe("1-"+Zd.toString()+" questions to ask atomically.")]]),async m=>await jv(h,m)),n){e.registerTool("linzumi_agent_reply","Post your single @linzumi reply for the current turn into the surface where you were mentioned. Call EXACTLY ONCE per turn with your final answer; the reply links to this working session automatically. Fails with already_replied on a second call and no_active_asker_binding when no turn is active.",Object.fromEntries([["body",_.string().min(1).describe("Plain-text reply body to post.")],["tokens",ji().optional()]]),async g=>{let y=g.body,v={body:y!==void 0?y:void 0},b=g.tokens;return b!==void 0&&(v.tokens=b),await d(c.agentReply(v))});let m=async(g,y)=>(y.tool=g,await d(c.agentTopicTool(y)));e.registerTool("linzumi_create_topic_wake_subscription","Create or update a standing subscription that wakes @linzumi when new entries land on an existing workspace topic. Use this when the user asks you to watch a topic and perform an ongoing job. The server stores the instruction, derives the creator from the current asker, and targets this conversation; do not claim success without calling this tool.",Object.fromEntries([["topic_slug",_.string().min(1).describe("Existing workspace topic slug to watch.")],["instruction",_.string().min(1).max(4e3).describe("Standing job to execute whenever a matching topic entry wakes the agent.")]]),async g=>await m("create_topic_wake_subscription",g)),e.registerTool("linzumi_disable_topic_wake_subscription","Disable the current asker's standing @linzumi wake subscription for a topic. The durable row and cursor are retained so reactivation can drain the disabled-period backlog.",Object.fromEntries([["topic_slug",_.string().min(1).describe("Workspace topic slug whose standing wake should stop.")]]),async g=>await m("disable_topic_wake_subscription",g)),e.registerTool("linzumi_list_coding_jobs","List the coding jobs the current asker can see in this workspace: runner connections (online and recent) with their bound job threads. Live state - never answered from search.",{},async g=>await d(c.agentListCodingJobs({}))),e.registerTool("linzumi_start_coding_job","Start a coding job exactly as if the asking user clicked start: same runner/channel authorization, same pipeline. Returns status 'unavailable' with a reason when the runner cannot take the job (relay that honestly).",Object.fromEntries([["channel",_.string().describe("Channel slug to host the job thread.")],["runner_key",_.string().describe("Runner (computer) to run the job on.")],["cwd",_.string().describe("Working directory on the runner.")],["work_description",_.string().min(1).describe("What the job should do - the initial instruction.")],["model",_.string().optional().describe("Model override (optional).")],["model_provider",_.string().optional().describe("Model provider override, e.g. 'wafer' (optional).")],["execution_mode",_.enum(["raw","local_vm"]).optional().describe("Execution placement override (optional).")],["project_task_id",_.string().optional().describe("Project task item to bind the job to (task_id from linzumi_get_project_tasks). The task flips todo -> active and links to the new job.")],["visibility",_.enum(["project","private"]).optional().describe("Job visibility. Defaults to 'project'; private jobs are limited to directly authorized participants.")]]),async g=>await d(c.agentStartCodingJob(g))),e.registerTool("linzumi_interrupt_coding_job","Interrupt a coding job: mode 'steer' (default) discards its queued follow-ups so your next message lands first; mode 'stop' terminates the current turn.",Object.fromEntries([["channel",_.string().describe("Channel slug hosting the job thread.")],["thread_id",_.string().uuid().describe("The job thread UUID.")],["mode",_.enum(["steer","stop"]).optional().describe("Interrupt mode; defaults to 'steer'.")]]),async g=>await d(c.agentInterruptCodingJob(g))),e.registerTool("linzumi_send_coding_job_message","Message a coding job or a person. Queue is the encouraged default: it lands in the colleague's inbox for their own cadence. Steer only for urgent, potentially-clashing work because it interrupts the running turn. Would this be worthless or harmful after their turn finishes? If no, queue. Delivery urgency is not access control. To message a person, pass to_user and omit channel and thread_id: delivery lands in their personal inbox.",Object.fromEntries([["channel",_.string().optional().describe("Channel slug hosting the job thread. Required unless to_user is set.")],["thread_id",_.string().uuid().optional().describe("The job thread UUID. Required unless to_user is set.")],["to_user",_.string().min(1).optional().describe("Username of a workspace member to message instead of a job. Delivery lands in their personal inbox.")],["body",_.string().min(1).describe("Message body to send.")],["tokens",ji().optional()],["delivery",_.enum(["queue","steer"]).optional().describe("Delivery urgency. Defaults to 'queue'.")]]),async g=>await d(c.agentSendCodingJobMessage(g))),e.registerTool("linzumi_read_coding_job_thread","Read a coding job's thread (asker-visible history) plus its workflow status metadata.",Object.fromEntries([["channel",_.string().describe("Channel slug hosting the job thread.")],["thread_id",_.string().uuid().describe("The job thread UUID.")],["limit",_.number().int().min(1).max(100).optional().describe("Maximum replies to return.")],["before_seq",_.number().int().positive().optional().describe("Return replies before this channel seq.")]]),async g=>await d(c.agentReadCodingJobThread(g))),e.registerTool("linzumi_resolve_job_approval","Resolve a coding job's pending approval request with the asking user's decision ('approve' or 'deny'). Only relays the asker's authority - never approve without their explicit instruction.",Object.fromEntries([["channel",_.string().describe("Channel slug hosting the job thread.")],["thread_id",_.string().uuid().describe("The job thread UUID.")],["source_seq",_.number().int().positive().describe("Channel seq of the message the approval request rides on.")],["request_id",_.string().describe("The approval request id.")],["decision",_.enum(["approve","deny"]).describe("The asker's decision.")]]),async g=>await d(c.agentResolveJobApproval(g))),e.registerTool("linzumi_archive_coding_job","Archive a coding job's thread (or any thread the asking user owns) so it leaves the active list; history is preserved. Do this when the asker says to archive a job or thread - never just promise it.",Object.fromEntries([["channel",_.string().describe("Channel slug hosting the thread.")],["thread_id",_.string().uuid().describe("The thread UUID to archive.")]]),async g=>await d(c.agentArchiveCodingJob(g))),e.registerTool("linzumi_unarchive_coding_job","Unarchive a previously archived coding job thread the asking user owns, returning it to the active list.",Object.fromEntries([["channel",_.string().describe("Channel slug hosting the thread.")],["thread_id",_.string().uuid().describe("The thread UUID to unarchive.")]]),async g=>await d(c.agentUnarchiveCodingJob(g))),e.registerTool("linzumi_set_thread_status","Set a thread's lifecycle status as the asking user: 'closed' marks it done, 'open' reopens it. Works on threads the asker owns.",Object.fromEntries([["channel",_.string().describe("Channel slug hosting the thread.")],["thread_id",_.string().uuid().describe("The thread UUID.")],["status",_.enum(["open","closed"]).describe("Replacement lifecycle status ('closed' = done).")]]),async g=>await d(c.agentSetThreadStatus(g))),e.registerTool("linzumi_create_channel","Create a new public channel in this workspace as the asking user. The slug is derived from the name.",Object.fromEntries([["name",_.string().min(1).describe("Channel name to create.")]]),async g=>await d(c.agentCreateChannel(g))),e.registerTool("linzumi_rename_channel","Rename a channel's display name as the asking user. The channel's URL slug stays stable.",Object.fromEntries([["channel",_.string().describe("Current channel slug to rename.")],["name",_.string().min(1).describe("New display name.")]]),async g=>await d(c.agentRenameChannel(g))),e.registerTool("linzumi_archive_channel","Archive a channel in this workspace as the asking user. History is preserved; the channel leaves the active sidebar.",Object.fromEntries([["channel",_.string().describe("Channel slug to archive.")]]),async g=>await d(c.agentArchiveChannel(g))),e.registerTool("linzumi_unarchive_channel","Unarchive a previously archived channel as the asking user.",Object.fromEntries([["channel",_.string().describe("Channel slug to unarchive.")]]),async g=>await d(c.agentUnarchiveChannel(g))),e.registerTool("linzumi_add_reaction","Add an emoji reaction to a channel message as the asking user. Accepts unicode emoji or a workspace :shortcode:.",Object.fromEntries([["channel",_.string().describe("Channel slug containing the message.")],["message_seq",_.number().int().positive().describe("Channel seq of the message to react to.")],["emoji",_.string().min(1).describe("Emoji to add (unicode or :shortcode:).")]]),async g=>await d(c.agentAddReaction(g))),e.registerTool("linzumi_remove_reaction","Remove the asking user's emoji reaction from a channel message.",Object.fromEntries([["channel",_.string().describe("Channel slug containing the message.")],["message_seq",_.number().int().positive().describe("Channel seq of the reacted message.")],["emoji",_.string().min(1).describe("Emoji to remove (unicode or :shortcode:).")]]),async g=>await d(c.agentRemoveReaction(g))),e.registerTool("linzumi_pin_message","Pin a channel message as the asking user. Thread replies re-point to their root message.",Object.fromEntries([["channel",_.string().describe("Channel slug containing the message.")],["message_seq",_.number().int().positive().describe("Channel seq of the message to pin.")]]),async g=>await d(c.agentPinMessage(g))),e.registerTool("linzumi_unpin_message","Remove a pin from a channel message as the asking user.",Object.fromEntries([["channel",_.string().describe("Channel slug containing the message.")],["message_seq",_.number().int().positive().describe("Channel seq of the pinned message.")]]),async g=>await d(c.agentUnpinMessage(g)))}switch(u){case"All":e.registerTool("linzumi_get_message","Read one Linzumi message by scoped message_seq/message_id or a Linzumi message URL, with optional bounded before/after context.",Object.fromEntries([["workspace",_.string().optional().describe("Workspace slug. Omit to use the message URL target, or the authenticated token scope without a URL.")],["channel",_.string().optional().describe("Channel slug. Omit to use the message URL target, or the authenticated token scope without a URL.")],["message_id",_.union([_.string(),_.number()]).optional().describe("Message seq inside the scoped channel.")],["message_seq",_.union([_.string(),_.number()]).optional().describe("Alias for message_id.")],["message_url",_.string().optional().describe("Full Linzumi message URL with ?message=<seq>; legacy #message-<seq> links are also supported.")],["before",_.number().int().min(0).max(100).optional().describe("Number of visible messages before the target.")],["after",_.number().int().min(0).max(100).optional().describe("Number of visible messages after the target.")]]),async m=>await d(c.getMessage(m))),e.registerTool("linzumi_get_thread","Read one Linzumi thread by thread_id in the scoped channel, including the parent message and bounded replies.",Object.fromEntries([["workspace",Ce()],["channel",dr()],["thread_id",_.string().uuid().describe("Linzumi thread UUID.")],["limit",_.number().int().min(1).max(100).optional().describe("Maximum replies to return.")],["before_seq",_.number().int().positive().optional().describe("Return replies before this channel seq.")]]),async m=>await d(c.getThread(m))),e.registerTool("linzumi_get_thread_transcript","Read a Linzumi thread's full transcript as canonical IR nodes (user/assistant messages, command executions, file changes, tool calls, statuses), cursor-paginated over the complete history. Use the returned cursor with has_more to walk older pages.",Object.fromEntries([["workspace",Ce()],["channel",dr()],["thread_id",_.string().uuid().describe("Linzumi thread UUID.")],["limit",_.number().int().min(1).max(500).optional().describe("Maximum transcript nodes per page (default 200).")],["cursor",_.number().int().positive().optional().describe("Return nodes below this seq (the previous page reply cursor).")]]),async m=>await d(c.getThreadTranscript(m))),e.registerTool("linzumi_get_channel","Read scoped Linzumi channel metadata and bounded recent channel messages.",Object.fromEntries([["workspace",Ce()],["channel",dr()],["limit",_.number().int().min(1).max(100).optional().describe("Maximum messages to return.")],["before_seq",_.number().int().positive().optional().describe("Return messages before this channel seq.")]]),async m=>await d(c.getChannel(m))),e.registerTool("linzumi_search_workspace","Search the Linzumi workspace with hybrid lexical+semantic retrieval, scoped to what the authorizing user can access. Returns scored content chunks with provenance (channel, thread, authored time) and a permalink to cite.",Object.fromEntries([["workspace",Ce()],["query",_.string().min(1).describe("Natural-language or keyword query to retrieve against.")],["limit",_.number().int().min(1).max(25).optional().describe("Maximum results to return (default 10, server-capped).")],["source_types",_.array(_.enum(["message","coding_job","github_pr","github_pr_review","github_check_run","github_workflow_run","github_diff","dictation","file"])).optional().describe("Restrict results to these corpora; omit for all.")],["authored_after",_.string().optional().describe("ISO8601 instant; only content authored at or after this time.")],["authored_before",_.string().optional().describe("ISO8601 instant; only content authored at or before this time.")],["repo",_.string().optional().describe("Restrict GitHub-sourced results to one repository by full name (owner/name).")],["check_status",_.enum(["pending","success","failed"]).optional().describe("Restrict check and workflow results to one conclusion bucket.")]]),async m=>await d(c.searchWorkspace(m))),e.registerTool("linzumi_ask_workspace",'Ask the Linzumi workspace a natural-language question and get a synthesized, citation-backed answer over what the authorizing user can access. Costs an LLM call on cache misses, so prefer linzumi_search_workspace for simple lookups. A "refused" status means there was not enough accessible evidence - treat it as "the workspace does not know", never retry verbatim.',Object.fromEntries([["workspace",Ce()],["question",_.string().min(1).max(2e3).describe("Natural-language question to answer with citations.")],["channel",_.string().optional().describe("Optional channel slug providing conversational context; never widens access.")],["allow_cached",_.boolean().optional().describe("Allow serving a cached synthesis when the evidence set is unchanged (default true). Set false to force fresh synthesis.")]]),async m=>await d(c.askWorkspace(m))),e.registerTool("linzumi_about_me","Read what the authorizing user has told Linzumi about themselves: their profile facts (homes, unit preferences, and other self-maintained attributes) plus their derived current timezone. Use it to personalize answers (e.g. pick the right city for weather, use their preferred units). Predicates may have multiple active values; prefer the one consistent with the derived timezone.",{},async m=>await d(c.aboutMe(m)));break;case"Coding":case"OnboardingDiscovery":break}switch(l&&(e.registerTool("linzumi_web_search","Search the public web for live or external information: news, current events, weather, prices, third-party API docs, research. Returns result titles, URLs, and snippets. Use this whenever the answer lives outside the Linzumi workspace; follow up with linzumi_fetch_url to read a result page.",Object.fromEntries([["query",_.string().min(1).describe("Web search query (natural language or keywords).")],["limit",_.number().int().min(1).max(10).optional().describe("Maximum results to return (default 8, server-capped).")]]),async m=>await d(c.webSearch(m))),e.registerTool("linzumi_fetch_url","Fetch one public http(s) URL and return its readable text content (HTML is reduced to plain text; large pages are truncated). Use it to read pages found via linzumi_web_search or any public docs/API reference. Only public addresses are reachable - private/internal hosts are rejected with url_not_allowed.",Object.fromEntries([["url",_.string().min(1).describe("Absolute public http(s) URL to fetch.")]]),async m=>await d(c.fetchUrl(m)))),u){case"All":e.registerTool("linzumi_list_ui_targets","List every UI surface you can ask the user to open in their own Linzumi window (channels, DMs, threads, projects, coding jobs, computers, catch-up, activity, settings tabs, pane layouts) with the structured args each kind takes. Use UI control only when the user asks for help or asks to be shown something.",{},async m=>await Sd(c.listUiTargets({}))),e.registerTool("linzumi_open_ui","Ask the user to open one whitelisted UI surface in their own already-open Linzumi window. A consent toast appears in THEIR session; navigation happens only if they tap Open. The call blocks until they decide and returns status opened/dismissed/expired - or error no_active_ui_session when they have no Linzumi window open (tell them to open Linzumi), or invalid_target with a detail. Use it only when the user asks for help or asks to be shown something; kinds and per-kind args come from linzumi_list_ui_targets.",Object.fromEntries([["kind",_.string().min(1).describe("Target kind from linzumi_list_ui_targets (e.g. settings_workspace, channel, pane_layout).")],["args",_.record(_.unknown()).optional().describe("Structured per-kind args from linzumi_list_ui_targets (never a URL - the server computes every path).")],["workspace",Ce()]]),async m=>await Sd(c.openUi(ur(m,o))));break;case"Coding":case"OnboardingDiscovery":break}if(l){let m=()=>_.string().uuid().optional().describe("Linzumi thread UUID. Defaults to the active coding job thread."),g=Object.fromEntries([["fire_at",_.string().datetime({offset:!0}).optional().describe("Future ISO8601 timestamp with timezone.")],["delay_minutes",_.number().int().min(1).max(525600).optional().describe("Minutes from now before the one-time wake fires.")],["prompt",_.string().min(1).max(4e3).describe("Actionable human-register description of exactly what to do when this job wakes.")]]),y=_.object(g).refine(v=>{if(typeof v!="object"||v===null||Array.isArray(v))return!1;let b=v.fire_at,w;b!==void 0?w=typeof b!=="undefined":w=!1;let S=v.delay_minutes,R;return S!==void 0?R=typeof S!=="undefined":R=!1,w?!R:R},{message:"provide exactly one of fire_at or delay_minutes"});e.registerSchemaTool("linzumi_schedule_wake",'Schedule this coding job to wake itself once and start an ordinary visible turn with the supplied prompt. Provide exactly one of fire_at or delay_minutes. Good: delay_minutes=20, prompt="Check CI, address any failures, then update the plan." Bad: prompt="wake up" (it gives the future turn no actionable context).',g,y,async v=>await d(c.scheduleWake(v))),e.registerTool("linzumi_cancel_wake","Cancel one still-scheduled wake owned by this coding job. Fired, already-canceled, missing, or another job's wake fails loudly.",Object.fromEntries([["wake_id",_.string().uuid().describe("Wake id returned by linzumi_schedule_wake.")]]),async v=>await d(c.cancelWake(v))),e.registerTool("linzumi_get_coding_job_metadata","Read the active coding job workflow metadata for a thread, including the agent-owned goal, ordered plan steps, step lock versions, and workflow status.",Object.fromEntries([["workspace",Ce()],["channel",dr()],["thread_id",m()]]),async v=>await d(c.getCodingJobMetadata(ur(v,o)))),e.registerTool("linzumi_rename_coding_job","Update the current coding job thread title and workflow-facing title. Use this when the job scope changes materially so the Linzumi thread list and metadata overview stay accurate.",Object.fromEntries([["workspace",Ce()],["channel",dr()],["thread_id",m()],["title",_.string().min(1).max(100).describe("Concise user-visible title for this coding job.")]]),async v=>await d(c.renameCodingJob(ur(v,o)))),e.registerTool("linzumi_upsert_coding_job_plan","Set or update the current coding job goal. Use this at job start and whenever the goal changes materially.",Object.fromEntries([["workspace",Ce()],["channel",dr()],["thread_id",m()],["goal",_.string().min(1).max(1e4).describe("Concrete user-visible goal for this coding job.")],["snooze_reason",_.string().min(1).max(500).optional().describe('Declare a legitimate wait to pause liveness nudges: what you are waiting on, in plain words a teammate would understand. Good: "waiting on CI for PR #4633". Must be sent together with snooze_minutes.')],["snooze_minutes",_.number().int().min(1).max(1440).optional().describe("How many minutes until the wait should be rechecked (1-1440). The deadline is mandatory - open-ended waits are refused. Must be sent together with snooze_reason.")]]),async v=>await d(c.upsertCodingJobPlan(ur(v,o)))),e.registerTool("linzumi_replace_coding_job_plan_steps","Replace the ordered coding job plan steps. Use this for the initial plan and for substantial rewrites when the old plan no longer fits the work.",Object.fromEntries([["workspace",Ce()],["channel",dr()],["thread_id",m()],["goal",_.string().min(1).max(1e4).optional().describe("Required when no plan exists yet; updates the current coding job goal.")],["steps",_.array(_.object(Object.fromEntries([["title",_.string().min(1).max(255)],["description",_.string().min(1).max(1e4)],["status",_.enum(["pending","active","completed","blocked","canceled"])],["status_note",Dv().optional().describe(Mv)],["completed_debrief",_.string().min(1).max(2e4).optional().describe("Required for completed steps. A short paragraph of plain prose for a teammate: what was done, and how we know it worked. Same voice as the note, just more room. Never a compliance recital. Put evidence and verification here.")]]))).min(1).max(50).describe("Ordered user-visible plan steps. Completed steps must include completed_debrief.")]]),async v=>await d(c.replaceCodingJobPlanSteps(ur(v,o)))),e.registerTool("linzumi_update_coding_job_plan_step","Update one coding job plan step status or note. Read metadata first and pass the current step lock_version.",Object.fromEntries([["workspace",Ce()],["channel",dr()],["thread_id",m()],["step_id",_.string().uuid().describe("Step id returned by linzumi_get_coding_job_metadata.")],["lock_version",_.number().int().positive().describe("Current step lock_version from metadata.")],["status",_.enum(["pending","active","completed","blocked","canceled"])],["status_note",Dv().optional().describe(Mv)],["completed_debrief",_.string().min(1).max(2e4).optional().describe("Required when marking a step completed. A short paragraph of plain prose for a teammate: what was done, and how we know it worked. Same voice as the note, just more room. Never a compliance recital. Put evidence and verification here.")]]),async v=>await d(c.updateCodingJobPlanStep(ur(v,o)))),e.registerTool("linzumi_link_coding_job_pull_request","Link the active coding job to its primary GitHub pull request so PR comments, files, commits, checks, deployments, and reviews can flow into the metadata view.",Object.fromEntries([["workspace",Ce()],["channel",dr()],["thread_id",m()],["github_repo_owner",_.string().min(1).max(255)],["github_repo_name",_.string().min(1).max(255)],["github_pr_number",_.number().int().positive()],["github_pr_url",_.string().url()],["title",_.string().min(1).max(255)],["body",_.string().min(1).max(1e5).optional()],["head_branch",_.string().min(1).max(255)],["head_sha",_.string().min(7).max(64)],["base_branch",_.string().min(1).max(255)],["base_sha",_.string().min(7).max(64)],["state",_.enum(["draft","open","closed","merged"]).optional()],["merge_commit_sha",_.string().min(7).max(64).optional().describe("Actual GitHub merge commit SHA. Required when state is merged; omit for other states. This is not the PR head SHA.")],["is_draft",_.boolean().optional()],["review_status",_.enum(["unknown","review_required","approved","changes_requested"]).optional()],["source_remote_url",_.string().min(1).max(1e3).describe("Git remote URL for the local job worktree; required when this job has no repo workspace yet.")],["runtime_worktree_root",_.string().min(1).max(1e3).describe("Absolute local worktree path for the coding job; required when this job has no repo workspace yet.")],["dirty_status",_.enum(["unknown","clean","dirty"]).optional()],["dirty_summary",_.string().min(1).max(2e3).optional()]]),async v=>await d(c.linkCodingJobPullRequest(ur(v,o)))),e.registerTool("linzumi_upload_files",["Upload local files to Linzumi and attach them to a new, exact, or latest assistant message. Use silently; do not mention this tool in the visible reply.","The JSON result includes message.attachments[].url as an absolute URL. Use those returned URLs when writing rich media directives such as ::audio, ::video, ::image, or Markdown images. Do not guess attachment URLs before upload.","For a message that should both attach files and show inline rich media, use a two-step flow: first upload/attach the files to create or target the message, then edit the same target message with body text that references the returned absolute URLs. When the result has target_seq, use target.kind=message_seq and message_seq=target_seq for that follow-up edit; result.message is the edit event that carries the new attachments, and target_message is the original target."].join(" "),Object.fromEntries([["target",_.object(Object.fromEntries([["kind",_.enum(["new_message","message_seq","latest_assistant_message"]).describe("new_message creates a message; message_seq edits an exact message; latest_assistant_message edits the latest assistant message in the scoped thread/channel.")],["message_seq",_.union([_.string(),_.number()]).optional().describe("Required when kind is message_seq.")],["thread_id",_.string().optional().describe("Thread UUID. Defaults to the active Linzumi thread when the MCP server was launched with one.")]])).describe("Attachment target. Prefer latest_assistant_message to attach files to the reply you already posted; use new_message ONLY when no assistant message exists yet in the scoped thread. Never re-use your visible reply text as a new_message body - that posts the reply twice. To reference uploaded files in the message body, upload first, then edit message_seq/latest_assistant_message with the returned absolute attachment URLs. If the upload result includes target_seq, use message_seq=target_seq for that follow-up edit.")],["files",_.array(_.string().min(1)).min(1).max(16).describe("Local file paths to upload. Paths must be non-hidden files inside the approved workspace or Downloads; source/text files of any language are supported, plus common document, image, patch, archive, and video types.")],["body",_.string().min(1).max(2e4).optional().describe("Required for new_message: a SHORT file-share caption (for example: Attached the generated report), never a copy of your visible reply - that would post the reply twice. Optional replacement body for message_seq/latest_assistant_message; when omitted, the existing message body is preserved. Rich media directives in body must use Linzumi attachment download URLs returned by this tool.")],["workspace",Ce()],["channel",_.string().optional().describe("Channel slug. Omit to use the target thread's channel (when the thread is known) or the authenticated token scope.")]]),async v=>{let b=Td(Zv(v,"target","linzumi_upload_files"),o),w;try{w=await dv({client:c,cwd:a,serviceUrl:s,target:b,files:wz(v.files),workspace:Yt(v.workspace),channel:Yt(v.channel),body:Yt(v.body)})}catch(S){return cv(K(S))}return gt($d(s,w))}),e.registerTool("linzumi_edit_message","Edit an exact scoped Linzumi message by message_seq. Use after linzumi_upload_files when you need a body-only follow-up edit that embeds returned attachment URLs. Requires channel.write, and thread.write when target.thread_id is set. Rich media src/poster values must be Linzumi attachment download URLs.",Object.fromEntries([["workspace",Ce()],["channel",dr()],["target",_.object(Object.fromEntries([["message_seq",_.union([_.string(),_.number()]).describe("Exact message seq to edit. After linzumi_upload_files returns target_seq, pass that value here.")],["thread_id",_.string().optional().describe("Thread UUID when editing a thread message. Use the upload result target_message.thread_id when present.")]])).describe("Exact message target for the body edit.")],["body",_.string().min(1).max(2e4).describe("Replacement Markdown body. Rich media src/poster values must be Linzumi attachment download URLs returned by linzumi_upload_files.")]]),async v=>{let b=mn(v);return b.target=Td(Zv(v,"target","linzumi_edit_message"),o),gt($d(s,await c.editMessage(b)))})}switch(u){case"All":if(e.registerTool("linzumi_list_vault_secrets","List vault secret names, descriptions, and whether each secret is personal or workspace-owned. Does not return secret values.",{},async m=>await d(c.listVaultSecrets(m))),e.registerTool("linzumi_list_projects","List the projects in the current workspace with their project_id (needed by the other project task tools), slug, title, description, and state.",Object.fromEntries([["workspace",Ce()]]),async m=>await d(c.listProjects(m))),e.registerTool("linzumi_get_project_tasks",`Read a project's full task graph: task GROUPS (kind "group", organizational containers, exactly one level deep) and ISSUES (kind "issue", the executable work items), each with status (todo/active/blocked/review/done/canceled), DERIVED work_state readiness (ready = todo with every dependency satisfied; blocked = todo with unsatisfied dependencies; running/stalled = active with/without a connected job), parent group, assignee, lock_version, and dependency edges (depends_on_task_ids / unblocks_task_ids). Always read this before reorganizing. Inside a project-bound coding job the project is inferred automatically; otherwise pass project_id from linzumi_list_projects.`,Object.fromEntries([["project_id",_.string().optional().describe("Project id from linzumi_list_projects. Omit inside a coding job started from a project to use that project.")]]),async m=>await d(c.getProjectTasks(ur(m,o)))),e.registerTool("linzumi_create_project_task",'Create a task group (kind "group") or issue (kind "issue", the default) in a project. Groups organize issues and are exactly one level deep: a parent_id must name a GROUP, and groups themselves can never have a parent. New tasks default to status "todo" and append to the end unless position is given. Inside a project-bound coding job the project is inferred; otherwise pass project_id.',Object.fromEntries([["project_id",_.string().optional().describe("Project id from linzumi_list_projects. Omit inside a coding job started from a project to use that project.")],["title",_.string().min(1).describe("Task title.")],["kind",_.enum(["issue","group"]).optional().describe('What to create: "issue" (executable work item, default) or "group" (organizational container).')],["description",_.string().optional().describe("Detailed description of the work - written so an engineer (or coding agent) could execute the task from it.")],["status",_.enum(["todo","active","blocked","review","done","canceled"]).optional().describe('Initial status. Defaults to "todo".')],["parent_id",_.string().optional().describe("task_id of the GROUP to place an issue in. Only issues can have a parent.")],["assignee",_.string().optional().describe("Username of a workspace member to assign.")],["position",_.number().int().min(0).optional().describe("Sort position. Defaults to appending at the end.")]]),async m=>await d(c.createProjectTask(ur(m,o)))),e.registerTool("linzumi_update_project_task",'Update a task group or issue: retitle, edit description/status_note, transition status (todo/active/blocked/review/done/canceled), reassign, reorder (position), or reorganize (parent_id moves an issue into a group; clear_parent moves it to top level). Only the fields you pass change; description and status_note accept null to clear. Prefer updating existing tasks over delete-and-recreate. Pass the lock_version from your last read to fail loudly ("stale") instead of overwriting a concurrent edit.',Object.fromEntries([["task_id",_.string().describe("task_id of the group or issue to update.")],["title",_.string().min(1).optional().describe("New title.")],["description",_.string().nullable().optional().describe("New description. Pass null to clear it.")],["status",_.enum(["todo","active","blocked","review","done","canceled"]).optional().describe('New status. "done"/"canceled" satisfy dependent tasks; "blocked" is a manual hold.')],["status_note",_.string().nullable().optional().describe("Short human-readable note about the current status. Pass null to clear it.")],["position",_.number().int().min(0).optional().describe("New sort position among siblings.")],["parent_id",_.string().optional().describe("task_id of the GROUP to move this issue into. Do not combine with clear_parent.")],["clear_parent",_.boolean().optional().describe("true moves the issue to the top level (no group). Do not combine with parent_id.")],["assignee",_.string().optional().describe("Username of a workspace member to assign. Do not combine with clear_assignee.")],["clear_assignee",_.boolean().optional().describe("true removes the assignee. Do not combine with assignee.")],["lock_version",_.number().int().positive().optional().describe("The task's lock_version from your last read, for compare-and-swap safety.")]]),async m=>await d(c.updateProjectTask(m))),e.registerTool("linzumi_delete_project_task",`Permanently delete a task group or issue. Dependency edges on the task are removed with it (dependents may become ready). Deletion is normally the USER's call - prefer status "canceled" or an update unless you are certain the entry is obsolete.`,Object.fromEntries([["task_id",_.string().describe("task_id of the group or issue to delete.")]]),async m=>await d(c.deleteProjectTask(m))),e.registerTool("linzumi_add_project_task_dependency",'Add the dependency edge "task_id is blocked by depends_on_task_id" between two ISSUES in the same project (groups cannot have dependencies). The dependent stays blocked until the prerequisite reaches done or canceled. The graph must stay acyclic: an edge that would create a cycle is refused with reason "would_create_cycle" and the offending cycle_path so you can restructure. Duplicate and self edges are rejected.',Object.fromEntries([["task_id",_.string().describe("task_id of the DEPENDENT issue (the one that must wait).")],["depends_on_task_id",_.string().describe("task_id of the PREREQUISITE issue (the one that must finish first).")]]),async m=>await d(c.addProjectTaskDependency(m))),e.registerTool("linzumi_remove_project_task_dependency",'Remove the dependency edge "task_id is blocked by depends_on_task_id". The dependent issue may become ready if that was its last unsatisfied dependency.',Object.fromEntries([["task_id",_.string().describe("task_id of the DEPENDENT issue.")],["depends_on_task_id",_.string().describe("task_id of the PREREQUISITE issue the edge points at.")]]),async m=>await d(c.removeProjectTaskDependency(m))),e.registerTool("linzumi_get_call_transcript","Read the full transcript of a completed Linzumi notetaker call: call metadata (title, platform, started/ended/transcribed times), participants, and every spoken segment in order with speaker names and millisecond offsets. Pass the call_id embedded in the request (or copied from the call card). Errors: call_not_found (missing or not visible to you), call_transcript_not_ready (call still connecting, in progress, or transcribing - retry later).",Object.fromEntries([["call_id",_.string().describe("The call id from the call card or the launching message (a CallRecording id - the opaque GraphQL id and the bare uuid both work).")]]),async m=>await d(c.getCallTranscript(m))),!n){e.registerTool("linzumi_start_coding_job","Start a coding job as the invoking user (same authorization and pipeline as clicking start). To start a project task item, pass project_task_id so the task flips todo -> active and links to the new job. Only start tasks whose work_state is ready. Proceed when the user has already explicitly authorized this launch within the agreed scope; DAG bookkeeping does not require renewed approval. Otherwise, offer and wait for explicit acceptance. Do not duplicate existing active work or treat task readiness as launch authorization. Omit channel, runner_key, and cwd to reuse this job's own channel, computer, and folder. Returns status 'unavailable' with a reason when the runner cannot take the job (relay that honestly).",Object.fromEntries([["work_description",_.string().min(1).describe("What the job should do - the initial instruction. For a task item, write it from the task title and description.")],["project_task_id",_.string().optional().describe("Project task item to bind the job to (task_id from linzumi_get_project_tasks). The task flips todo -> active and links to the new job.")],["visibility",_.enum(["project","private"]).optional().describe("Child-job visibility. Defaults to 'project'; private jobs are limited to directly authorized participants.")],["channel",_.string().optional().describe("Channel slug to host the job thread. Omit to use this job's own channel.")],["runner_key",_.string().optional().describe("Runner (computer) to run the job on. Omit to use this job's own computer.")],["cwd",_.string().optional().describe("Working directory on the runner. Omit to use this job's own folder.")],["model",_.string().optional().describe("Model override (optional).")],["model_provider",_.string().optional().describe("Model provider override, e.g. 'wafer' (optional).")],["agent_provider",_.string().optional().describe("Agent provider override, e.g. 'codex' (optional).")],["reasoning_effort",_.enum(["default","low","medium","high","xhigh","ultra"]).optional().describe("Reasoning effort override (optional).")],["approval_policy",_.enum(["default","on-request","on-failure","never"]).optional().describe("Approval policy override (optional).")],["sandbox",_.enum(["default","workspace-write","read-only","danger-full-access"]).optional().describe("Sandbox override (optional).")],["fast",_.boolean().optional().describe("Fast-mode override (optional).")],["allow_port_forwarding_by_default",_.boolean().optional().describe("Default port-forwarding override (optional).")],["execution_mode",_.enum(["raw","local_vm"]).optional().describe("Execution placement override (optional).")],["egress_mode",_.enum(["open","hardened"]).optional().describe("Local-VM egress override (optional).")]]),async g=>await d(c.agentStartCodingJob(ur(g,o))));let m=t.multiAgentJobs;m!==void 0&&m&&(e.registerTool("linzumi_spawn_child_job","Spawn a durable child coding job under YOUR OWN job, on any harness or model - plan a DAG and delegate its legs to workers you then coordinate through discovery and messaging. The child lands on this job's channel, computer, and folder; it inherits this job's project and visibility (a private parent's children stay private), human roles cascade to it, and a human manages its lifecycle. Returns status 'unavailable' with a reason when the runner cannot take the job (relay that honestly).",Object.fromEntries([["work_description",_.string().min(1).describe("What the child job should do - the initial instruction, written to stand alone.")],["agent_provider",_.string().optional().describe("Harness for the child, e.g. 'codex' or 'claude-code'. Omit to reuse this job's own harness. A different harness is fine: a cross-harness child is always a child job.")],["model",_.string().optional().describe("Model override for the child (optional).")],["model_provider",_.string().optional().describe("Model provider override, e.g. 'wafer' (optional).")],["reasoning_effort",_.enum(["default","low","medium","high","xhigh","ultra"]).optional().describe("Reasoning effort override (optional).")],["project_task_id",_.string().optional().describe("Project task item to bind the child to (task_id from linzumi_get_project_tasks). The task flips todo -> active and links to the new job.")],["visibility",_.enum(["project","private"]).optional().describe("Child visibility. Defaults to this job's own visibility; a private parent's children must stay private.")]]),async g=>await d(c.agentSpawnChildJob(ur(g,o)))),e.registerTool("linzumi_archive_child_job","Archive a coding job that is YOUR OWN job or one beneath it in your job tree, retiring it from the active lists, the org map and the needs-you deck; history is preserved and it can be unarchived. Use this to clean up child jobs you spawned that are finished or dead - do it in the current turn, never just promise it. Refused for sibling, parent or unrelated jobs, and for jobs that do not belong to the human you are working for. When the job still has live descendants the call returns confirmation_required with their exact count and ids; call again with descendant_action 'keep' (archive only this job, re-parenting its children) or 'cascade' (archive the whole subtree) plus those expected values.",Object.fromEntries([["job_id",_.string().describe("The coding job id to archive: your own job, or any job beneath it in your tree.")],["outcome",_.enum(["completed","abandoned","superseded"]).describe("Why the job is being archived.")],["descendant_action",_.enum(["keep","cascade"]).optional().describe("Phase-2 choice when the job has live descendants. 'keep' archives only this job and re-parents its children; 'cascade' archives the whole subtree.")],["expected_descendant_count",_.number().int().optional().describe("The descendant_count returned by the phase-1 call.")],["expected_descendant_job_ids",_.array(_.string()).optional().describe("The descendant_job_ids returned by the phase-1 call; the call is refused if the subtree changed.")],["expected_descendant_fingerprint",_.string().optional().describe("The descendant_fingerprint returned by the phase-1 call.")]]),async g=>await d(c.agentArchiveChildJob(g))),e.registerTool("linzumi_unarchive_child_job","Unarchive a previously archived coding job that is YOUR OWN job or one beneath it in your job tree. It returns as hibernating and wakes when messaged. Same ownership scope as linzumi_archive_child_job. Refused when the job is not archived, or when its home thread already holds a live job.",Object.fromEntries([["job_id",_.string().describe("The archived coding job id to bring back: your own job, or any job beneath it in your tree.")]]),async g=>await d(c.agentUnarchiveChildJob(g))),e.registerTool("linzumi_discover_coding_jobs","Search current sitreps inside this coding job project for overlapping files, modules, objectives, or blockers. Results include durable job addresses for coordination. Private jobs outside your visible set never appear.",Object.fromEntries([["query",_.string().min(1).describe("Free-text clash-surface query, such as a file path, module, migration, or objective.")]]),async g=>{let y={};return Object.entries(g).forEach(v=>{y[v[0]]=v[1]}),y.source_thread_id=xd(He(o,v=>v)),await d(c.agentDiscoverCodingJobs(y))}),e.registerTool("linzumi_send_coding_job_message","Message a visible coding job in this project, or a person. Queue is the encouraged default: it lands in the colleague's inbox for their own cadence. Steer only for urgent, potentially-clashing work because it interrupts the running turn. Would this be worthless or harmful after their turn finishes? If no, queue. Delivery urgency is not access control. To message a person, pass to_user and omit channel and thread_id: delivery lands in their personal inbox.",Object.fromEntries([["channel",_.string().optional().describe("Channel slug hosting the target job. Required unless to_user is set.")],["thread_id",_.string().uuid().optional().describe("Target job thread UUID. Required unless to_user is set.")],["to_user",_.string().min(1).optional().describe("Username of a workspace member to message instead of a job. Delivery lands in their personal inbox.")],["body",_.string().min(1).describe("Coordination message to send.")],["tokens",ji().optional()],["delivery",_.enum(["queue","steer"]).optional().describe("Delivery urgency. Defaults to 'queue'.")]]),async g=>{let y={};return Object.entries(g).forEach(v=>{y[v[0]]=v[1]}),y.source_thread_id=xd(He(o,v=>v)),await d(c.agentSendCodingJobMessage(y))}))}break;case"Coding":case"OnboardingDiscovery":break}switch(yz(u)&&(e.registerTool("linzumi_upload_custom_emoji","Upload a local image as a workspace custom emoji. For generated emoji art, create a transparent PNG with a simple centered subject, crisp edges, strong contrast, minimal tiny details, and enough outline/highlight separation to read at 16-24px on both dark and light backgrounds. Use lowercase shortcode names without colons unless preserving a user-provided :name:.",Object.fromEntries([["name",Gv().describe("Custom emoji shortcode name, with or without surrounding colons.")],["file",_.string().min(1).describe("Local PNG/WebP/GIF/JPEG file path to upload. Prefer transparent PNG for generated emoji.")],["workspace",Ce()]]),async m=>{let g=Yt(m.name),y=Yt(m.file);return gt(await fv({client:c,cwd:a,serviceUrl:s,name:g!==void 0?g:"",file:y!==void 0?y:"",workspace:Yt(m.workspace)}))}),e.registerTool("linzumi_rename_custom_emoji","Rename an existing workspace custom emoji. The new name may include surrounding colons; Linzumi stores the normalized shortcode without colons.",Object.fromEntries([["emoji_id",_.union([_.string(),_.number().int().positive()]).describe("Workspace custom emoji id returned by linzumi_upload_custom_emoji or workspace emoji listings.")],["name",Gv().describe("New shortcode name, with or without surrounding colons.")],["workspace",Ce()]]),async m=>await d(c.renameCustomEmoji(m)))),e.registerTool("linzumi_media_guide","Return the full Linzumi rich-media authoring guide (audio/video/image directives, URL rules, upload-then-embed flow, examples). Call once BEFORE writing any ::audio/::video/::image directive or Markdown image into a Linzumi message.",{},async m=>{let g={};g.type="text",g.text=zv;let y={};return y.content=[g],y}),e.registerTool("linzumi_note_project_directory","Record one discovered local Git repository or worktree for onboarding import. Call once per project as soon as it is found.",Object.fromEntries([["workspace",Ce()],["runner_id",_.string().min(1).describe("Local runner/computer id provided in the discovery prompt.")],["path",_.string().min(1).describe("Absolute local path to the repository worktree root.")],["display_name",_.string().optional().describe("Short project label. Defaults to the path basename.")],["activity_at",_.string().optional().describe("Best-known recent activity time as an ISO-8601 timestamp.")],["import_key",_.string().optional().describe("Stable dedupe key. Defaults to path.")],["metadata",_.record(_.unknown()).optional().describe("Small structured metadata such as branch or remote origin.")]]),async m=>await d(c.noteProjectDirectory(m))),e.registerTool("linzumi_note_agent_conversation","Record one discovered Codex or Claude Code local conversation for onboarding import. Call once per conversation as soon as it is found.",Object.fromEntries([["workspace",Ce()],["runner_id",_.string().min(1).describe("Local runner/computer id provided in the discovery prompt.")],["source",_.enum(["codex","claude_code"]).describe("Conversation source.")],["import_key",_.string().min(1).describe("Stable dedupe key, such as a session id or file path.")],["path",_.string().optional().describe("Absolute local path to the conversation file or directory.")],["display_name",_.string().optional().describe("Short label for the discovered conversation.")],["activity_at",_.string().optional().describe("Best-known recent activity time as an ISO-8601 timestamp.")],["metadata",_.record(_.unknown()).optional().describe("Small structured metadata such as session id or project path.")]]),async m=>await d(c.noteAgentConversation(m))),e.registerTool("linzumi_note_onboarding_discovery_status","Record onboarding discovery progress. Call when a search phase starts, checks another place, completes, or fails.",Object.fromEntries([["workspace",Ce()],["runner_id",_.string().min(1).describe("Local runner/computer id provided in the discovery prompt.")],["phase",_.enum(["projects","conversations"]).describe("Discovery phase being reported.")],["status",_.enum(["starting","running","completed","failed"]).describe("Current phase status.")],["places_searched",_.number().int().nonnegative().optional().describe("Count of concrete folders/files/known locations checked so far.")],["message",_.string().optional().describe("Short user-facing status note.")],["current_place",_.string().optional().describe("Current folder, file, Git command target, or known location being checked.")],["current_source",_.string().optional().describe("Short machine-readable source label such as git, codex, or claude_code.")],["last_error",_.string().optional().describe("Short failure detail when status is failed.")],["metadata",_.record(_.unknown()).optional().describe("Small structured status metadata.")]]),async m=>await d(c.noteOnboardingDiscoveryStatus(m))),u==="All"&&vz(t.operatingMode)&&(e.registerTool("linzumi_dm_owner","Send a plain-text DM to the configured Commander owner. Requires dm.write and a visible owner username.",Object.fromEntries([["owner_username",_.string().optional().describe("Owner username. Defaults to LINZUMI_MCP_OWNER_USERNAME or --owner-username.")],["workspace",Ce()],["channel",_.string().optional().describe("Source channel slug used to verify owner visibility.")],["body",_.string().min(1).max(2e4).describe("Plain-text message body to DM.")],["tokens",ji().optional()]]),async m=>{let g=Yt(m.owner_username),y=g!==void 0?g:i;if(y===void 0)return Pe("owner_username is required for linzumi_dm_owner");let v=mn(m);return v.owner_username=y,await d(c.dmOwner(v))}),e.registerTool("linzumi_send_channel_message","Post a NEW standalone Markdown message into the scoped Linzumi channel as the authenticated local-runner user. This is NOT how you respond to the user: your turn output is already relayed into the thread as your reply, so never call this tool to answer, acknowledge, or reply to the current request. Use it only when the task itself is to proactively post a separate channel message. Requires channel.write. Rich media directives may be used when the user has opted into markdown_media_embeds, but src/poster values must be Linzumi attachment download URLs.",Object.fromEntries([["workspace",Ce()],["channel",dr()],["body",_.string().min(1).max(2e4).describe("Markdown message body to post. Rich media src/poster values must be Linzumi attachment download URLs, not third-party URLs, /relative paths, or local filesystem paths.")],["tokens",ji().optional()]]),async m=>await d(c.sendChannelMessage(m))),e.registerTool("linzumi_send_thread_reply","Post a Markdown reply into some OTHER existing Linzumi thread as the authenticated local-runner user. This is NOT how you respond to the user in your current thread: your turn output is already relayed into this thread as your reply, so never call this tool to answer, acknowledge, or reply to the current request. Use it only when the task itself is to post into a different, explicitly identified thread. Requires thread.write. Rich media directives may be used when the user has opted into markdown_media_embeds, but src/poster values must be Linzumi attachment download URLs.",Object.fromEntries([["workspace",Ce()],["channel",dr()],["thread_id",_.string().uuid().describe("Existing Linzumi thread UUID.")],["body",_.string().min(1).max(2e4).describe("Markdown reply body to post. Rich media src/poster values must be Linzumi attachment download URLs, not third-party URLs, /relative paths, or local filesystem paths.")],["tokens",ji().optional()]]),async m=>await d(c.sendThreadReply(m))),e.registerTool("linzumi_send_dm","Send a plain-text DM as the authenticated local-runner user to a visible user in the scoped workspace/channel. Requires dm.write.",Object.fromEntries([["workspace",Ce()],["channel",_.string().optional().describe("Source channel slug used to verify target visibility.")],["username",_.string().describe("Visible Linzumi username to DM.")],["body",_.string().min(1).max(2e4).describe("Plain-text message body to DM.")],["tokens",ji().optional()]]),async m=>await d(c.sendDm(m)))),u){case"All":e.registerTool("linzumi_get_vault_values","Request values for explicit vault env var names after a thread-scoped human approval. Requires vault.read; thread_id resolves the approval thread.",Object.fromEntries([["workspace",Ce()],["channel",_.string().optional().describe("Channel slug used to disambiguate the approval thread when needed.")],["thread_id",_.string().uuid().describe("Existing Linzumi thread UUID for the inline approval.")],["env_var_names",_.array(_.string().regex(new RegExp("^[A-Z][A-Z0-9_]{0,127}$"))).min(1).max(20).describe("Explicit vault env var names to request. This tool cannot list all vault keys.")],["description",_.string().min(1).max(500).describe("Human-readable reason shown in the approval request.")],["justification",_.string().min(10).max(1e3).describe("Agent justification shown to the approver.")]]),async m=>await d(c.getVaultValues(m)));break;case"Coding":case"OnboardingDiscovery":break}switch(u){case"All":return n||r===void 0?void 0:xz(e,a,r);case"Coding":case"OnboardingDiscovery":return}}function Tz(e){return typeof e==="undefined"?!0:e===null}function Ud(e){let t=pt(e.serviceUrl);if(t.TAG!=="Ok")return{TAG:"Error",_0:t._0};let r=t._0,n=e.fetchImpl,i=n!==void 0?n:Ya,o=e.authMode,s=o!==void 0&&o!=="LocalRunner"?"/api/v2/personal-agent-mcp":"/api/v2/local-runner-mcp",a=e.operatingMode,u=a!==void 0?Md(a):"text",c=async(l,d,p,f)=>{let h=Kt(d,r),m;m=h.TAG==="Ok"?h._0:Pe(h._0);let g={};Object.entries(p).forEach(I=>{g[I[0]]=I[1]}),g.operating_mode=u;let y={},v=e.accessToken,b;if(v.TAG==="StaticAccessToken")b=v._0;else{let I=v._0();b=I.TAG==="Ok"?I._0:Pe(I._0)}y.authorization="Bearer "+b;let w;if(l==="Get"){let I=m.searchParams;Object.entries(g).forEach(B=>{let re=B[1];if(!Tz(re)){I.set(B[0],String(re));return}}),w=await i.json(m.toString(),{method:"GET",headers:y,signal:f})}else y["content-type"]="application/json",w=await i.json(m.toString(),{method:"POST",headers:y,body:JSON.stringify(g),signal:f});let S=await w.json(),R;if(R=typeof S=="object"&&S!==null&&!Array.isArray(S)?S:void 0,R===void 0)return Pe("Linzumi MCP API returned non-object JSON from "+d);let X=w.ok,be=Pt(R.ok,!0),D=0;if(X){if(be)return R;D=1}else D=1;if(D===1){let I=R.error,B,re=0;typeof I=="string"?B=I:re=2,re===2&&(B="HTTP "+w.status.toString());let le=R.detail,j=typeof le=="string"?" detail="+le:"";return Pe("Linzumi MCP API "+d+" failed: "+B+j)}};return{TAG:"Ok",_0:{validateAuth:()=>c("Get",s+"/validate",{},void 0),issueOnboardingDiscoveryToken:l=>c("Post",s+"/onboarding-discovery-token",l,void 0),getMessage:l=>c("Get",s+"/message",l,void 0),getThread:l=>c("Get",s+"/thread",l,void 0),getThreadTranscript:l=>c("Get",s+"/thread-transcript",l,void 0),getChannel:l=>c("Get",s+"/channel",l,void 0),searchWorkspace:l=>c("Get",s+"/search",l,void 0),askWorkspace:l=>c("Post",s+"/ask",l,void 0),aboutMe:l=>c("Get",s+"/about-me",l,void 0),webSearch:l=>c("Get",s+"/web-search",l,void 0),fetchUrl:l=>c("Get",s+"/fetch-url",l,void 0),listUiTargets:l=>c("Get",s+"/ui-targets",l,void 0),openUi:l=>c("Post",s+"/open-ui",l,void 0),getCodingJobMetadata:l=>c("Get",s+"/coding-job-metadata",l,void 0),listProjects:l=>c("Get",s+"/projects",l,void 0),getProjectTasks:l=>c("Get",s+"/project-tasks",l,void 0),createProjectTask:l=>c("Post",s+"/project-tasks/create",l,void 0),updateProjectTask:l=>c("Post",s+"/project-tasks/update",l,void 0),deleteProjectTask:l=>c("Post",s+"/project-tasks/delete",l,void 0),addProjectTaskDependency:l=>c("Post",s+"/project-tasks/add-dependency",l,void 0),removeProjectTaskDependency:l=>c("Post",s+"/project-tasks/remove-dependency",l,void 0),getCallTranscript:l=>c("Get",s+"/call-transcript",l,void 0),renameCodingJob:l=>c("Post",s+"/coding-job-title",l,void 0),upsertCodingJobPlan:l=>c("Post",s+"/coding-job-plan",l,void 0),upsertCodingJobPlanWithSignal:(l,d)=>c("Post",s+"/coding-job-plan",l,Dt(d)),replaceCodingJobPlanSteps:l=>c("Post",s+"/coding-job-plan/steps",l,void 0),replaceCodingJobPlanStepsWithSignal:(l,d)=>c("Post",s+"/coding-job-plan/steps",l,Dt(d)),updateCodingJobPlanStep:l=>c("Post",s+"/coding-job-plan/step",l,void 0),linkCodingJobPullRequest:l=>c("Post",s+"/coding-job-primary-pr",l,void 0),listVaultSecrets:l=>c("Get",s+"/vault-secrets",l,void 0),noteProjectDirectory:l=>c("Post",s+"/discovered-project",l,void 0),noteAgentConversation:l=>c("Post",s+"/discovered-conversation",l,void 0),noteOnboardingDiscoveryStatus:l=>c("Post",s+"/discovery-status",l,void 0),sendChannelMessage:l=>c("Post",s+"/channel-message",l,void 0),editMessage:l=>c("Post",s+"/message/edit",l,void 0),agentReply:l=>c("Post",s+"/agent-reply",l,void 0),completeTopicWakeNoAction:l=>c("Post",s+"/agent/complete-topic-wake-no-action",l,void 0),scheduleWake:l=>c("Post",s+"/scheduled-wakes",l,void 0),cancelWake:l=>c("Post",s+"/scheduled-wakes/cancel",l,void 0),declineDocumentAction:l=>c("Post",s+"/agent/decline-document-action",l,void 0),agentTurnProgress:l=>c("Post",s+"/agent-turn-progress",l,void 0),agentDocumentTool:l=>c("Post",s+"/agent/document-tool",l,void 0),agentTopicTool:l=>c("Post",s+"/agent/topic-tool",l,void 0),agentListCodingJobs:l=>c("Get",s+"/agent/coding-jobs",l,void 0),agentStartCodingJob:l=>c("Post",s+"/agent/start-coding-job",l,void 0),agentSpawnChildJob:l=>c("Post",s+"/agent/spawn-child-job",l,void 0),agentArchiveChildJob:l=>c("Post",s+"/agent/archive-child-job",l,void 0),agentUnarchiveChildJob:l=>c("Post",s+"/agent/unarchive-child-job",l,void 0),agentInterruptCodingJob:l=>c("Post",s+"/agent/interrupt-coding-job",l,void 0),agentSendCodingJobMessage:l=>c("Post",s+"/agent/send-coding-job-message",l,void 0),agentDiscoverCodingJobs:l=>c("Get",s+"/agent/discover-coding-jobs",l,void 0),agentReadCodingJobThread:l=>c("Get",s+"/agent/coding-job-thread",l,void 0),agentResolveJobApproval:l=>c("Post",s+"/agent/resolve-job-approval",l,void 0),agentArchiveCodingJob:l=>c("Post",s+"/agent/archive-coding-job",l,void 0),agentUnarchiveCodingJob:l=>c("Post",s+"/agent/unarchive-coding-job",l,void 0),agentSetThreadStatus:l=>c("Post",s+"/agent/set-thread-status",l,void 0),agentCreateChannel:l=>c("Post",s+"/agent/create-channel",l,void 0),agentRenameChannel:l=>c("Post",s+"/agent/rename-channel",l,void 0),agentArchiveChannel:l=>c("Post",s+"/agent/archive-channel",l,void 0),agentUnarchiveChannel:l=>c("Post",s+"/agent/unarchive-channel",l,void 0),agentAddReaction:l=>c("Post",s+"/agent/add-reaction",l,void 0),agentRemoveReaction:l=>c("Post",s+"/agent/remove-reaction",l,void 0),agentPinMessage:l=>c("Post",s+"/agent/pin-message",l,void 0),agentUnpinMessage:l=>c("Post",s+"/agent/unpin-message",l,void 0),prepareMessageUploads:l=>c("Post",s+"/message-uploads/prepare",l,void 0),attachMessageFiles:l=>c("Post",s+"/message-files/attach",l,void 0),prepareCustomEmoji:l=>c("Post",s+"/custom-emoji/prepare",l,void 0),renameCustomEmoji:l=>c("Post",s+"/custom-emoji/rename",l,void 0),sendThreadReply:l=>c("Post",s+"/thread-reply",l,void 0),sendDm:l=>c("Post",s+"/dm",l,void 0),dmOwner:l=>c("Post",s+"/dm-owner",l,void 0),getVaultValues:l=>c("Post",s+"/vault-values",l,void 0)}}}var Ez=Object.freeze({status:"aborted"});function x(e,t,r){function n(a,u){var c;Object.defineProperty(a,"_zod",{value:a._zod??{},enumerable:!1}),(c=a._zod).traits??(c.traits=new Set),a._zod.traits.add(e),t(a,u);for(let l in s.prototype)l in a||Object.defineProperty(a,l,{value:s.prototype[l].bind(a)});a._zod.constr=s,a._zod.def=u}let i=r?.Parent??Object;class o extends i{}Object.defineProperty(o,"name",{value:e});function s(a){var u;let c=r?.Parent?new o:this;n(c,a),(u=c._zod).deferred??(u.deferred=[]);for(let l of c._zod.deferred)l();return c}return Object.defineProperty(s,"init",{value:n}),Object.defineProperty(s,Symbol.hasInstance,{value:a=>r?.Parent&&a instanceof r.Parent?!0:a?._zod?.traits?.has(e)}),Object.defineProperty(s,"name",{value:e}),s}var hn=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},Ac={};function er(e){return e&&Object.assign(Ac,e),Ac}var ce={};mu(ce,{BIGINT_FORMAT_RANGES:()=>Vv,Class:()=>Bd,NUMBER_FORMAT_RANGES:()=>Yd,aborted:()=>Mi,allowsEval:()=>Kd,assert:()=>Cz,assertEqual:()=>zz,assertIs:()=>Oz,assertNever:()=>Pz,assertNotEqual:()=>Az,assignProp:()=>Hd,cached:()=>Rs,captureStackTrace:()=>Pc,cleanEnum:()=>Vz,cleanRegex:()=>js,clone:()=>tr,createTransparentProxy:()=>Dz,defineLazy:()=>Ee,esc:()=>Ni,escapeRegex:()=>Zn,extend:()=>Fz,finalizeIssue:()=>$r,floatSafeRemainder:()=>Jd,getElementAtPath:()=>Rz,getEnumValues:()=>Cs,getLengthableOrigin:()=>Ns,getParsedType:()=>Mz,getSizableOrigin:()=>Bv,isObject:()=>Ao,isPlainObject:()=>Oo,issue:()=>ef,joinValues:()=>Oc,jsonStringifyReplacer:()=>Wd,merge:()=>qz,normalizeParams:()=>J,nullish:()=>Is,numKeys:()=>Nz,omit:()=>Zz,optionalKeys:()=>Xd,partial:()=>Lz,pick:()=>Gz,prefixIssues:()=>Hr,primitiveTypes:()=>Uv,promiseAllObject:()=>Iz,propertyKeyTypes:()=>Qd,randomString:()=>jz,required:()=>Uz,stringifyPrimitive:()=>Cc,unwrapMessage:()=>Ps});function zz(e){return e}function Az(e){return e}function Oz(e){}function Pz(e){throw new Error}function Cz(e){}function Cs(e){let t=Object.values(e).filter(n=>typeof n=="number");return Object.entries(e).filter(([n,i])=>t.indexOf(+n)===-1).map(([n,i])=>i)}function Oc(e,t="|"){return e.map(r=>Cc(r)).join(t)}function Wd(e,t){return typeof t=="bigint"?t.toString():t}function Rs(e){return{get value(){{let r=e();return Object.defineProperty(this,"value",{value:r}),r}throw new Error("cached value already set")}}}function Is(e){return e==null}function js(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function Jd(e,t){let r=(e.toString().split(".")[1]||"").length,n=(t.toString().split(".")[1]||"").length,i=r>n?r:n,o=Number.parseInt(e.toFixed(i).replace(".","")),s=Number.parseInt(t.toFixed(i).replace(".",""));return o%s/10**i}function Ee(e,t,r){Object.defineProperty(e,t,{get(){{let i=r();return e[t]=i,i}throw new Error("cached value already set")},set(i){Object.defineProperty(e,t,{value:i})},configurable:!0})}function Hd(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function Rz(e,t){return t?t.reduce((r,n)=>r?.[n],e):e}function Iz(e){let t=Object.keys(e),r=t.map(n=>e[n]);return Promise.all(r).then(n=>{let i={};for(let o=0;o<t.length;o++)i[t[o]]=n[o];return i})}function jz(e=10){let t="abcdefghijklmnopqrstuvwxyz",r="";for(let n=0;n<e;n++)r+=t[Math.floor(Math.random()*t.length)];return r}function Ni(e){return JSON.stringify(e)}var Pc=Error.captureStackTrace?Error.captureStackTrace:(...e)=>{};function Ao(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var Kd=Rs(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let e=Function;return new e(""),!0}catch{return!1}});function Oo(e){if(Ao(e)===!1)return!1;let t=e.constructor;if(t===void 0)return!0;let r=t.prototype;return!(Ao(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function Nz(e){let t=0;for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&t++;return t}var Mz=e=>{let t=typeof e;switch(t){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(e)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(e)?"array":e===null?"null":e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?"promise":typeof Map<"u"&&e instanceof Map?"map":typeof Set<"u"&&e instanceof Set?"set":typeof Date<"u"&&e instanceof Date?"date":typeof File<"u"&&e instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${t}`)}},Qd=new Set(["string","number","symbol"]),Uv=new Set(["string","number","bigint","boolean","symbol","undefined"]);function Zn(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function tr(e,t,r){let n=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(n._zod.parent=e),n}function J(e){let t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function Dz(e){let t;return new Proxy({},{get(r,n,i){return t??(t=e()),Reflect.get(t,n,i)},set(r,n,i,o){return t??(t=e()),Reflect.set(t,n,i,o)},has(r,n){return t??(t=e()),Reflect.has(t,n)},deleteProperty(r,n){return t??(t=e()),Reflect.deleteProperty(t,n)},ownKeys(r){return t??(t=e()),Reflect.ownKeys(t)},getOwnPropertyDescriptor(r,n){return t??(t=e()),Reflect.getOwnPropertyDescriptor(t,n)},defineProperty(r,n,i){return t??(t=e()),Reflect.defineProperty(t,n,i)}})}function Cc(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function Xd(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}var Yd={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},Vv={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function Gz(e,t){let r={},n=e._zod.def;for(let i in t){if(!(i in n.shape))throw new Error(`Unrecognized key: "${i}"`);t[i]&&(r[i]=n.shape[i])}return tr(e,{...e._zod.def,shape:r,checks:[]})}function Zz(e,t){let r={...e._zod.def.shape},n=e._zod.def;for(let i in t){if(!(i in n.shape))throw new Error(`Unrecognized key: "${i}"`);t[i]&&delete r[i]}return tr(e,{...e._zod.def,shape:r,checks:[]})}function Fz(e,t){if(!Oo(t))throw new Error("Invalid input to extend: expected a plain object");let r={...e._zod.def,get shape(){let n={...e._zod.def.shape,...t};return Hd(this,"shape",n),n},checks:[]};return tr(e,r)}function qz(e,t){return tr(e,{...e._zod.def,get shape(){let r={...e._zod.def.shape,...t._zod.def.shape};return Hd(this,"shape",r),r},catchall:t._zod.def.catchall,checks:[]})}function Lz(e,t,r){let n=t._zod.def.shape,i={...n};if(r)for(let o in r){if(!(o in n))throw new Error(`Unrecognized key: "${o}"`);r[o]&&(i[o]=e?new e({type:"optional",innerType:n[o]}):n[o])}else for(let o in n)i[o]=e?new e({type:"optional",innerType:n[o]}):n[o];return tr(t,{...t._zod.def,shape:i,checks:[]})}function Uz(e,t,r){let n=t._zod.def.shape,i={...n};if(r)for(let o in r){if(!(o in i))throw new Error(`Unrecognized key: "${o}"`);r[o]&&(i[o]=new e({type:"nonoptional",innerType:n[o]}))}else for(let o in n)i[o]=new e({type:"nonoptional",innerType:n[o]});return tr(t,{...t._zod.def,shape:i,checks:[]})}function Mi(e,t=0){for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function Hr(e,t){return t.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function Ps(e){return typeof e=="string"?e:e?.message}function $r(e,t,r){let n={...e,path:e.path??[]};if(!e.message){let i=Ps(e.inst?._zod.def?.error?.(e))??Ps(t?.error?.(e))??Ps(r.customError?.(e))??Ps(r.localeError?.(e))??"Invalid input";n.message=i}return delete n.inst,delete n.continue,t?.reportInput||delete n.input,n}function Bv(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}function Ns(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function ef(...e){let[t,r,n]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:n}:{...t}}function Vz(e){return Object.entries(e).filter(([t,r])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}var Bd=class{constructor(...t){}};var Wv=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),Object.defineProperty(e,"message",{get(){return JSON.stringify(t,Wd,2)},enumerable:!0}),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Rc=x("$ZodError",Wv),Ms=x("$ZodError",Wv,{Parent:Error});function tf(e,t=r=>r.message){let r={},n=[];for(let i of e.issues)i.path.length>0?(r[i.path[0]]=r[i.path[0]]||[],r[i.path[0]].push(t(i))):n.push(t(i));return{formErrors:n,fieldErrors:r}}function rf(e,t){let r=t||function(o){return o.message},n={_errors:[]},i=o=>{for(let s of o.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map(a=>i({issues:a}));else if(s.code==="invalid_key")i({issues:s.issues});else if(s.code==="invalid_element")i({issues:s.issues});else if(s.path.length===0)n._errors.push(r(s));else{let a=n,u=0;for(;u<s.path.length;){let c=s.path[u];u===s.path.length-1?(a[c]=a[c]||{_errors:[]},a[c]._errors.push(r(s))):a[c]=a[c]||{_errors:[]},a=a[c],u++}}};return i(e),n}var nf=e=>(t,r,n,i)=>{let o=n?Object.assign(n,{async:!1}):{async:!1},s=t._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new hn;if(s.issues.length){let a=new(i?.Err??e)(s.issues.map(u=>$r(u,o,er())));throw Pc(a,i?.callee),a}return s.value},of=nf(Ms),sf=e=>async(t,r,n,i)=>{let o=n?Object.assign(n,{async:!0}):{async:!0},s=t._zod.run({value:r,issues:[]},o);if(s instanceof Promise&&(s=await s),s.issues.length){let a=new(i?.Err??e)(s.issues.map(u=>$r(u,o,er())));throw Pc(a,i?.callee),a}return s.value},af=sf(Ms),cf=e=>(t,r,n)=>{let i=n?{...n,async:!1}:{async:!1},o=t._zod.run({value:r,issues:[]},i);if(o instanceof Promise)throw new hn;return o.issues.length?{success:!1,error:new(e??Rc)(o.issues.map(s=>$r(s,i,er())))}:{success:!0,data:o.value}},Di=cf(Ms),lf=e=>async(t,r,n)=>{let i=n?Object.assign(n,{async:!0}):{async:!0},o=t._zod.run({value:r,issues:[]},i);return o instanceof Promise&&(o=await o),o.issues.length?{success:!1,error:new e(o.issues.map(s=>$r(s,i,er())))}:{success:!0,data:o.value}},Gi=lf(Ms);var Jv=/^[cC][^\s-]{8,}$/,Hv=/^[0-9a-z]+$/,Kv=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Qv=/^[0-9a-vA-V]{20}$/,Xv=/^[A-Za-z0-9]{27}$/,Yv=/^[a-zA-Z0-9_-]{21}$/,eb=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var tb=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,uf=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000)$/;var rb=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var Wz="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function nb(){return new RegExp(Wz,"u")}var ib=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ob=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})$/,sb=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,ab=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,cb=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,df=/^[A-Za-z0-9_-]*$/,lb=/^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/;var ub=/^\+(?:[0-9]){6,14}[0-9]$/,db="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",fb=new RegExp(`^${db}$`);function mb(e){let t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function pb(e){return new RegExp(`^${mb(e)}$`)}function hb(e){let t=mb({precision:e.precision}),r=["Z"];e.local&&r.push(""),e.offset&&r.push("([+-]\\d{2}:\\d{2})");let n=`${t}(?:${r.join("|")})`;return new RegExp(`^${db}T(?:${n})$`)}var gb=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)};var _b=/^\d+$/,yb=/^-?\d+(?:\.\d+)?/i,vb=/true|false/i,bb=/null/i;var wb=/^[^A-Z]*$/,kb=/^[^a-z]*$/;var yt=x("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),xb={number:"number",bigint:"bigint",object:"date"},ff=x("$ZodCheckLessThan",(e,t)=>{yt.init(e,t);let r=xb[typeof t.value];e._zod.onattach.push(n=>{let i=n._zod.bag,o=(t.inclusive?i.maximum:i.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<o&&(t.inclusive?i.maximum=t.value:i.exclusiveMaximum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value<=t.value:n.value<t.value)||n.issues.push({origin:r,code:"too_big",maximum:t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),mf=x("$ZodCheckGreaterThan",(e,t)=>{yt.init(e,t);let r=xb[typeof t.value];e._zod.onattach.push(n=>{let i=n._zod.bag,o=(t.inclusive?i.minimum:i.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>o&&(t.inclusive?i.minimum=t.value:i.exclusiveMinimum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value>=t.value:n.value>t.value)||n.issues.push({origin:r,code:"too_small",minimum:t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Sb=x("$ZodCheckMultipleOf",(e,t)=>{yt.init(e,t),e._zod.onattach.push(r=>{var n;(n=r._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=r=>{if(typeof r.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof r.value=="bigint"?r.value%t.value===BigInt(0):Jd(r.value,t.value)===0)||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:t.value,input:r.value,inst:e,continue:!t.abort})}}),Tb=x("$ZodCheckNumberFormat",(e,t)=>{yt.init(e,t),t.format=t.format||"float64";let r=t.format?.includes("int"),n=r?"int":"number",[i,o]=Yd[t.format];e._zod.onattach.push(s=>{let a=s._zod.bag;a.format=t.format,a.minimum=i,a.maximum=o,r&&(a.pattern=_b)}),e._zod.check=s=>{let a=s.value;if(r){if(!Number.isInteger(a)){s.issues.push({expected:n,format:t.format,code:"invalid_type",input:a,inst:e});return}if(!Number.isSafeInteger(a)){a>0?s.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,continue:!t.abort}):s.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,continue:!t.abort});return}}a<i&&s.issues.push({origin:"number",input:a,code:"too_small",minimum:i,inclusive:!0,inst:e,continue:!t.abort}),a>o&&s.issues.push({origin:"number",input:a,code:"too_big",maximum:o,inst:e})}});var $b=x("$ZodCheckMaxLength",(e,t)=>{var r;yt.init(e,t),(r=e._zod.def).when??(r.when=n=>{let i=n.value;return!Is(i)&&i.length!==void 0}),e._zod.onattach.push(n=>{let i=n._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<i&&(n._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let i=n.value;if(i.length<=t.maximum)return;let s=Ns(i);n.issues.push({origin:s,code:"too_big",maximum:t.maximum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),Eb=x("$ZodCheckMinLength",(e,t)=>{var r;yt.init(e,t),(r=e._zod.def).when??(r.when=n=>{let i=n.value;return!Is(i)&&i.length!==void 0}),e._zod.onattach.push(n=>{let i=n._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>i&&(n._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let i=n.value;if(i.length>=t.minimum)return;let s=Ns(i);n.issues.push({origin:s,code:"too_small",minimum:t.minimum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),zb=x("$ZodCheckLengthEquals",(e,t)=>{var r;yt.init(e,t),(r=e._zod.def).when??(r.when=n=>{let i=n.value;return!Is(i)&&i.length!==void 0}),e._zod.onattach.push(n=>{let i=n._zod.bag;i.minimum=t.length,i.maximum=t.length,i.length=t.length}),e._zod.check=n=>{let i=n.value,o=i.length;if(o===t.length)return;let s=Ns(i),a=o>t.length;n.issues.push({origin:s,...a?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),Ds=x("$ZodCheckStringFormat",(e,t)=>{var r,n;yt.init(e,t),e._zod.onattach.push(i=>{let o=i._zod.bag;o.format=t.format,t.pattern&&(o.patterns??(o.patterns=new Set),o.patterns.add(t.pattern))}),t.pattern?(r=e._zod).check??(r.check=i=>{t.pattern.lastIndex=0,!t.pattern.test(i.value)&&i.issues.push({origin:"string",code:"invalid_format",format:t.format,input:i.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(n=e._zod).check??(n.check=()=>{})}),Ab=x("$ZodCheckRegex",(e,t)=>{Ds.init(e,t),e._zod.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Ob=x("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=wb),Ds.init(e,t)}),Pb=x("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=kb),Ds.init(e,t)}),Cb=x("$ZodCheckIncludes",(e,t)=>{yt.init(e,t);let r=Zn(t.includes),n=new RegExp(typeof t.position=="number"?`^.{${t.position}}${r}`:r);t.pattern=n,e._zod.onattach.push(i=>{let o=i._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=i=>{i.value.includes(t.includes,t.position)||i.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:i.value,inst:e,continue:!t.abort})}}),Rb=x("$ZodCheckStartsWith",(e,t)=>{yt.init(e,t);let r=new RegExp(`^${Zn(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.onattach.push(n=>{let i=n._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(r)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),Ib=x("$ZodCheckEndsWith",(e,t)=>{yt.init(e,t);let r=new RegExp(`.*${Zn(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.onattach.push(n=>{let i=n._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(r)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}});var jb=x("$ZodCheckOverwrite",(e,t)=>{yt.init(e,t),e._zod.check=r=>{r.value=t.tx(r.value)}});var jc=class{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}let n=t.split(`
426
426
  `).filter(s=>s),i=Math.min(...n.map(s=>s.length-s.trimStart().length)),o=n.map(s=>s.slice(i)).map(s=>" ".repeat(this.indent*2)+s);for(let s of o)this.content.push(s)}compile(){let t=Function,r=this?.args,i=[...(this?.content??[""]).map(o=>` ${o}`)];return new t(...r,i.join(`
427
- `))}};var Nb={major:4,minor:0,patch:0};var Se=x("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Nb;let n=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&n.unshift(e);for(let i of n)for(let o of i._zod.onattach)o(e);if(n.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let i=(o,s,a)=>{let u=Ni(o),c;for(let l of s){if(l._zod.def.when){if(!l._zod.def.when(o))continue}else if(u)continue;let d=o.issues.length,p=l._zod.check(o);if(p instanceof Promise&&a?.async===!1)throw new hn;if(c||p instanceof Promise)c=(c??Promise.resolve()).then(async()=>{await p,o.issues.length!==d&&(u||(u=Ni(o,d)))});else{if(o.issues.length===d)continue;u||(u=Ni(o,d))}}return c?c.then(()=>o):o};e._zod.run=(o,s)=>{let a=e._zod.parse(o,s);if(a instanceof Promise){if(s.async===!1)throw new hn;return a.then(u=>i(u,n,s))}return i(a,n,s)}}e["~standard"]={validate:i=>{try{let o=Mi(e,i);return o.success?{value:o.data}:{issues:o.error?.issues}}catch{return Di(e,i).then(s=>s.success?{value:s.data}:{issues:s.error?.issues})}},vendor:"zod",version:1}}),Gs=x("$ZodString",(e,t)=>{Se.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??hb(e._zod.bag),e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),Ae=x("$ZodStringFormat",(e,t)=>{Ds.init(e,t),Gs.init(e,t)}),hf=x("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=eb),Ae.init(e,t)}),gf=x("$ZodUUID",(e,t)=>{if(t.version){let n={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(n===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=uf(n))}else t.pattern??(t.pattern=uf());Ae.init(e,t)}),_f=x("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=tb),Ae.init(e,t)}),yf=x("$ZodURL",(e,t)=>{Ae.init(e,t),e._zod.check=r=>{try{let n=r.value,i=new URL(n),o=i.href;t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:cb.source,input:r.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(":")?i.protocol.slice(0,-1):i.protocol)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort})),!n.endsWith("/")&&o.endsWith("/")?r.value=o.slice(0,-1):r.value=o;return}catch{r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),vf=x("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=rb()),Ae.init(e,t)}),bf=x("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Xv),Ae.init(e,t)}),wf=x("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Wv),Ae.init(e,t)}),kf=x("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Jv),Ae.init(e,t)}),xf=x("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Hv),Ae.init(e,t)}),Sf=x("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Kv),Ae.init(e,t)}),Tf=x("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Qv),Ae.init(e,t)}),Bb=x("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=pb(t)),Ae.init(e,t)}),Wb=x("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=db),Ae.init(e,t)}),Jb=x("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=mb(t)),Ae.init(e,t)}),Hb=x("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Yv),Ae.init(e,t)}),$f=x("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=nb),Ae.init(e,t),e._zod.onattach.push(r=>{let n=r._zod.bag;n.format="ipv4"})}),Ef=x("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=ib),Ae.init(e,t),e._zod.onattach.push(r=>{let n=r._zod.bag;n.format="ipv6"}),e._zod.check=r=>{try{new URL(`http://[${r.value}]`)}catch{r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}}}),zf=x("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=ob),Ae.init(e,t)}),Af=x("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=sb),Ae.init(e,t),e._zod.check=r=>{let[n,i]=r.value.split("/");try{if(!i)throw new Error;let o=Number(i);if(`${o}`!==i)throw new Error;if(o<0||o>128)throw new Error;new URL(`http://[${n}]`)}catch{r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}}});function Kb(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var Of=x("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=ab),Ae.init(e,t),e._zod.onattach.push(r=>{r._zod.bag.contentEncoding="base64"}),e._zod.check=r=>{Kb(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}});function Bz(e){if(!df.test(e))return!1;let t=e.replace(/[-_]/g,n=>n==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return Kb(r)}var Pf=x("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=df),Ae.init(e,t),e._zod.onattach.push(r=>{r._zod.bag.contentEncoding="base64url"}),e._zod.check=r=>{Bz(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),Cf=x("$ZodE164",(e,t)=>{t.pattern??(t.pattern=lb),Ae.init(e,t)});function Wz(e,t=null){try{let r=e.split(".");if(r.length!==3)return!1;let[n]=r;if(!n)return!1;let i=JSON.parse(atob(n));return!("typ"in i&&i?.typ!=="JWT"||!i.alg||t&&(!("alg"in i)||i.alg!==t))}catch{return!1}}var Rf=x("$ZodJWT",(e,t)=>{Ae.init(e,t),e._zod.check=r=>{Wz(r.value,t.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}});var Mc=x("$ZodNumber",(e,t)=>{Se.init(e,t),e._zod.pattern=e._zod.bag.pattern??_b,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Number(r.value)}catch{}let i=r.value;if(typeof i=="number"&&!Number.isNaN(i)&&Number.isFinite(i))return r;let o=typeof i=="number"?Number.isNaN(i)?"NaN":Number.isFinite(i)?void 0:"Infinity":void 0;return r.issues.push({expected:"number",code:"invalid_type",input:i,inst:e,...o?{received:o}:{}}),r}}),If=x("$ZodNumber",(e,t)=>{Sb.init(e,t),Mc.init(e,t)}),jf=x("$ZodBoolean",(e,t)=>{Se.init(e,t),e._zod.pattern=yb,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=!!r.value}catch{}let i=r.value;return typeof i=="boolean"||r.issues.push({expected:"boolean",code:"invalid_type",input:i,inst:e}),r}});var Nf=x("$ZodNull",(e,t)=>{Se.init(e,t),e._zod.pattern=vb,e._zod.values=new Set([null]),e._zod.parse=(r,n)=>{let i=r.value;return i===null||r.issues.push({expected:"null",code:"invalid_type",input:i,inst:e}),r}});var Mf=x("$ZodUnknown",(e,t)=>{Se.init(e,t),e._zod.parse=r=>r}),Df=x("$ZodNever",(e,t)=>{Se.init(e,t),e._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)});function Mb(e,t,r){e.issues.length&&t.issues.push(...Hr(r,e.issues)),t.value[r]=e.value}var Gf=x("$ZodArray",(e,t)=>{Se.init(e,t),e._zod.parse=(r,n)=>{let i=r.value;if(!Array.isArray(i))return r.issues.push({expected:"array",code:"invalid_type",input:i,inst:e}),r;r.value=Array(i.length);let o=[];for(let s=0;s<i.length;s++){let a=i[s],u=t.element._zod.run({value:a,issues:[]},n);u instanceof Promise?o.push(u.then(c=>Mb(c,r,s))):Mb(u,r,s)}return o.length?Promise.all(o).then(()=>r):r}});function Nc(e,t,r){e.issues.length&&t.issues.push(...Hr(r,e.issues)),t.value[r]=e.value}function Db(e,t,r,n){e.issues.length?n[r]===void 0?r in n?t.value[r]=void 0:t.value[r]=e.value:t.issues.push(...Hr(r,e.issues)):e.value===void 0?r in n&&(t.value[r]=void 0):t.value[r]=e.value}var Dc=x("$ZodObject",(e,t)=>{Se.init(e,t);let r=Rs(()=>{let d=Object.keys(t.shape);for(let f of d)if(!(t.shape[f]instanceof Se))throw new Error(`Invalid element at key "${f}": expected a Zod schema`);let p=Xd(t.shape);return{shape:t.shape,keys:d,keySet:new Set(d),numKeys:d.length,optionalKeys:new Set(p)}});ze(e._zod,"propValues",()=>{let d=t.shape,p={};for(let f in d){let h=d[f]._zod;if(h.values){p[f]??(p[f]=new Set);for(let m of h.values)p[f].add(m)}}return p});let n=d=>{let p=new jc(["shape","payload","ctx"]),f=r.value,h=v=>{let b=ji(v);return`shape[${b}]._zod.run({ value: input[${b}], issues: [] }, ctx)`};p.write("const input = payload.value;");let m=Object.create(null),g=0;for(let v of f.keys)m[v]=`key_${g++}`;p.write("const newResult = {}");for(let v of f.keys)if(f.optionalKeys.has(v)){let b=m[v];p.write(`const ${b} = ${h(v)};`);let w=ji(v);p.write(`
427
+ `))}};var Mb={major:4,minor:0,patch:0};var Se=x("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Mb;let n=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&n.unshift(e);for(let i of n)for(let o of i._zod.onattach)o(e);if(n.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let i=(o,s,a)=>{let u=Mi(o),c;for(let l of s){if(l._zod.def.when){if(!l._zod.def.when(o))continue}else if(u)continue;let d=o.issues.length,p=l._zod.check(o);if(p instanceof Promise&&a?.async===!1)throw new hn;if(c||p instanceof Promise)c=(c??Promise.resolve()).then(async()=>{await p,o.issues.length!==d&&(u||(u=Mi(o,d)))});else{if(o.issues.length===d)continue;u||(u=Mi(o,d))}}return c?c.then(()=>o):o};e._zod.run=(o,s)=>{let a=e._zod.parse(o,s);if(a instanceof Promise){if(s.async===!1)throw new hn;return a.then(u=>i(u,n,s))}return i(a,n,s)}}e["~standard"]={validate:i=>{try{let o=Di(e,i);return o.success?{value:o.data}:{issues:o.error?.issues}}catch{return Gi(e,i).then(s=>s.success?{value:s.data}:{issues:s.error?.issues})}},vendor:"zod",version:1}}),Gs=x("$ZodString",(e,t)=>{Se.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??gb(e._zod.bag),e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),ze=x("$ZodStringFormat",(e,t)=>{Ds.init(e,t),Gs.init(e,t)}),hf=x("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=tb),ze.init(e,t)}),gf=x("$ZodUUID",(e,t)=>{if(t.version){let n={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(n===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=uf(n))}else t.pattern??(t.pattern=uf());ze.init(e,t)}),_f=x("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=rb),ze.init(e,t)}),yf=x("$ZodURL",(e,t)=>{ze.init(e,t),e._zod.check=r=>{try{let n=r.value,i=new URL(n),o=i.href;t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:lb.source,input:r.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(":")?i.protocol.slice(0,-1):i.protocol)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort})),!n.endsWith("/")&&o.endsWith("/")?r.value=o.slice(0,-1):r.value=o;return}catch{r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),vf=x("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=nb()),ze.init(e,t)}),bf=x("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Yv),ze.init(e,t)}),wf=x("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Jv),ze.init(e,t)}),kf=x("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Hv),ze.init(e,t)}),xf=x("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Kv),ze.init(e,t)}),Sf=x("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Qv),ze.init(e,t)}),Tf=x("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Xv),ze.init(e,t)}),Wb=x("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=hb(t)),ze.init(e,t)}),Jb=x("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=fb),ze.init(e,t)}),Hb=x("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=pb(t)),ze.init(e,t)}),Kb=x("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=eb),ze.init(e,t)}),$f=x("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=ib),ze.init(e,t),e._zod.onattach.push(r=>{let n=r._zod.bag;n.format="ipv4"})}),Ef=x("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=ob),ze.init(e,t),e._zod.onattach.push(r=>{let n=r._zod.bag;n.format="ipv6"}),e._zod.check=r=>{try{new URL(`http://[${r.value}]`)}catch{r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}}}),zf=x("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=sb),ze.init(e,t)}),Af=x("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=ab),ze.init(e,t),e._zod.check=r=>{let[n,i]=r.value.split("/");try{if(!i)throw new Error;let o=Number(i);if(`${o}`!==i)throw new Error;if(o<0||o>128)throw new Error;new URL(`http://[${n}]`)}catch{r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}}});function Qb(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var Of=x("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=cb),ze.init(e,t),e._zod.onattach.push(r=>{r._zod.bag.contentEncoding="base64"}),e._zod.check=r=>{Qb(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}});function Jz(e){if(!df.test(e))return!1;let t=e.replace(/[-_]/g,n=>n==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return Qb(r)}var Pf=x("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=df),ze.init(e,t),e._zod.onattach.push(r=>{r._zod.bag.contentEncoding="base64url"}),e._zod.check=r=>{Jz(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),Cf=x("$ZodE164",(e,t)=>{t.pattern??(t.pattern=ub),ze.init(e,t)});function Hz(e,t=null){try{let r=e.split(".");if(r.length!==3)return!1;let[n]=r;if(!n)return!1;let i=JSON.parse(atob(n));return!("typ"in i&&i?.typ!=="JWT"||!i.alg||t&&(!("alg"in i)||i.alg!==t))}catch{return!1}}var Rf=x("$ZodJWT",(e,t)=>{ze.init(e,t),e._zod.check=r=>{Hz(r.value,t.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}});var Mc=x("$ZodNumber",(e,t)=>{Se.init(e,t),e._zod.pattern=e._zod.bag.pattern??yb,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Number(r.value)}catch{}let i=r.value;if(typeof i=="number"&&!Number.isNaN(i)&&Number.isFinite(i))return r;let o=typeof i=="number"?Number.isNaN(i)?"NaN":Number.isFinite(i)?void 0:"Infinity":void 0;return r.issues.push({expected:"number",code:"invalid_type",input:i,inst:e,...o?{received:o}:{}}),r}}),If=x("$ZodNumber",(e,t)=>{Tb.init(e,t),Mc.init(e,t)}),jf=x("$ZodBoolean",(e,t)=>{Se.init(e,t),e._zod.pattern=vb,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=!!r.value}catch{}let i=r.value;return typeof i=="boolean"||r.issues.push({expected:"boolean",code:"invalid_type",input:i,inst:e}),r}});var Nf=x("$ZodNull",(e,t)=>{Se.init(e,t),e._zod.pattern=bb,e._zod.values=new Set([null]),e._zod.parse=(r,n)=>{let i=r.value;return i===null||r.issues.push({expected:"null",code:"invalid_type",input:i,inst:e}),r}});var Mf=x("$ZodUnknown",(e,t)=>{Se.init(e,t),e._zod.parse=r=>r}),Df=x("$ZodNever",(e,t)=>{Se.init(e,t),e._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)});function Db(e,t,r){e.issues.length&&t.issues.push(...Hr(r,e.issues)),t.value[r]=e.value}var Gf=x("$ZodArray",(e,t)=>{Se.init(e,t),e._zod.parse=(r,n)=>{let i=r.value;if(!Array.isArray(i))return r.issues.push({expected:"array",code:"invalid_type",input:i,inst:e}),r;r.value=Array(i.length);let o=[];for(let s=0;s<i.length;s++){let a=i[s],u=t.element._zod.run({value:a,issues:[]},n);u instanceof Promise?o.push(u.then(c=>Db(c,r,s))):Db(u,r,s)}return o.length?Promise.all(o).then(()=>r):r}});function Nc(e,t,r){e.issues.length&&t.issues.push(...Hr(r,e.issues)),t.value[r]=e.value}function Gb(e,t,r,n){e.issues.length?n[r]===void 0?r in n?t.value[r]=void 0:t.value[r]=e.value:t.issues.push(...Hr(r,e.issues)):e.value===void 0?r in n&&(t.value[r]=void 0):t.value[r]=e.value}var Dc=x("$ZodObject",(e,t)=>{Se.init(e,t);let r=Rs(()=>{let d=Object.keys(t.shape);for(let f of d)if(!(t.shape[f]instanceof Se))throw new Error(`Invalid element at key "${f}": expected a Zod schema`);let p=Xd(t.shape);return{shape:t.shape,keys:d,keySet:new Set(d),numKeys:d.length,optionalKeys:new Set(p)}});Ee(e._zod,"propValues",()=>{let d=t.shape,p={};for(let f in d){let h=d[f]._zod;if(h.values){p[f]??(p[f]=new Set);for(let m of h.values)p[f].add(m)}}return p});let n=d=>{let p=new jc(["shape","payload","ctx"]),f=r.value,h=v=>{let b=Ni(v);return`shape[${b}]._zod.run({ value: input[${b}], issues: [] }, ctx)`};p.write("const input = payload.value;");let m=Object.create(null),g=0;for(let v of f.keys)m[v]=`key_${g++}`;p.write("const newResult = {}");for(let v of f.keys)if(f.optionalKeys.has(v)){let b=m[v];p.write(`const ${b} = ${h(v)};`);let w=Ni(v);p.write(`
428
428
  if (${b}.issues.length) {
429
429
  if (input[${w}] === undefined) {
430
430
  if (${w} in input) {
@@ -446,16 +446,16 @@ args = `+oz(e.args)+`
446
446
  `)}else{let b=m[v];p.write(`const ${b} = ${h(v)};`),p.write(`
447
447
  if (${b}.issues.length) payload.issues = payload.issues.concat(${b}.issues.map(iss => ({
448
448
  ...iss,
449
- path: iss.path ? [${ji(v)}, ...iss.path] : [${ji(v)}]
450
- })));`),p.write(`newResult[${ji(v)}] = ${b}.value`)}p.write("payload.value = newResult;"),p.write("return payload;");let y=p.compile();return(v,b)=>y(d,v,b)},i,o=Ao,s=!Ac.jitless,u=s&&Kd.value,c=t.catchall,l;e._zod.parse=(d,p)=>{l??(l=r.value);let f=d.value;if(!o(f))return d.issues.push({expected:"object",code:"invalid_type",input:f,inst:e}),d;let h=[];if(s&&u&&p?.async===!1&&p.jitless!==!0)i||(i=n(t.shape)),d=i(d,p);else{d.value={};let b=l.shape;for(let w of l.keys){let S=b[w],R=S._zod.run({value:f[w],issues:[]},p),X=S._zod.optin==="optional"&&S._zod.optout==="optional";R instanceof Promise?h.push(R.then(be=>X?Db(be,d,w,f):Nc(be,d,w))):X?Db(R,d,w,f):Nc(R,d,w)}}if(!c)return h.length?Promise.all(h).then(()=>d):d;let m=[],g=l.keySet,y=c._zod,v=y.def.type;for(let b of Object.keys(f)){if(g.has(b))continue;if(v==="never"){m.push(b);continue}let w=y.run({value:f[b],issues:[]},p);w instanceof Promise?h.push(w.then(S=>Nc(S,d,b))):Nc(w,d,b)}return m.length&&d.issues.push({code:"unrecognized_keys",keys:m,input:f,inst:e}),h.length?Promise.all(h).then(()=>d):d}});function Gb(e,t,r,n){for(let i of e)if(i.issues.length===0)return t.value=i.value,t;return t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(i=>i.issues.map(o=>$r(o,n,tr())))}),t}var Gc=x("$ZodUnion",(e,t)=>{Se.init(e,t),ze(e._zod,"optin",()=>t.options.some(r=>r._zod.optin==="optional")?"optional":void 0),ze(e._zod,"optout",()=>t.options.some(r=>r._zod.optout==="optional")?"optional":void 0),ze(e._zod,"values",()=>{if(t.options.every(r=>r._zod.values))return new Set(t.options.flatMap(r=>Array.from(r._zod.values)))}),ze(e._zod,"pattern",()=>{if(t.options.every(r=>r._zod.pattern)){let r=t.options.map(n=>n._zod.pattern);return new RegExp(`^(${r.map(n=>js(n.source)).join("|")})$`)}}),e._zod.parse=(r,n)=>{let i=!1,o=[];for(let s of t.options){let a=s._zod.run({value:r.value,issues:[]},n);if(a instanceof Promise)o.push(a),i=!0;else{if(a.issues.length===0)return a;o.push(a)}}return i?Promise.all(o).then(s=>Gb(s,r,e,n)):Gb(o,r,e,n)}}),Zf=x("$ZodDiscriminatedUnion",(e,t)=>{Gc.init(e,t);let r=e._zod.parse;ze(e._zod,"propValues",()=>{let i={};for(let o of t.options){let s=o._zod.propValues;if(!s||Object.keys(s).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(o)}"`);for(let[a,u]of Object.entries(s)){i[a]||(i[a]=new Set);for(let c of u)i[a].add(c)}}return i});let n=Rs(()=>{let i=t.options,o=new Map;for(let s of i){let a=s._zod.propValues[t.discriminator];if(!a||a.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(s)}"`);for(let u of a){if(o.has(u))throw new Error(`Duplicate discriminator value "${String(u)}"`);o.set(u,s)}}return o});e._zod.parse=(i,o)=>{let s=i.value;if(!Ao(s))return i.issues.push({code:"invalid_type",expected:"object",input:s,inst:e}),i;let a=n.value.get(s?.[t.discriminator]);return a?a._zod.run(i,o):t.unionFallback?r(i,o):(i.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",input:s,path:[t.discriminator],inst:e}),i)}}),Ff=x("$ZodIntersection",(e,t)=>{Se.init(e,t),e._zod.parse=(r,n)=>{let i=r.value,o=t.left._zod.run({value:i,issues:[]},n),s=t.right._zod.run({value:i,issues:[]},n);return o instanceof Promise||s instanceof Promise?Promise.all([o,s]).then(([u,c])=>Zb(r,u,c)):Zb(r,o,s)}});function pf(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Oo(e)&&Oo(t)){let r=Object.keys(t),n=Object.keys(e).filter(o=>r.indexOf(o)!==-1),i={...e,...t};for(let o of n){let s=pf(e[o],t[o]);if(!s.valid)return{valid:!1,mergeErrorPath:[o,...s.mergeErrorPath]};i[o]=s.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let r=[];for(let n=0;n<e.length;n++){let i=e[n],o=t[n],s=pf(i,o);if(!s.valid)return{valid:!1,mergeErrorPath:[n,...s.mergeErrorPath]};r.push(s.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function Zb(e,t,r){if(t.issues.length&&e.issues.push(...t.issues),r.issues.length&&e.issues.push(...r.issues),Ni(e))return e;let n=pf(t.value,r.value);if(!n.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(n.mergeErrorPath)}`);return e.value=n.data,e}var qf=x("$ZodRecord",(e,t)=>{Se.init(e,t),e._zod.parse=(r,n)=>{let i=r.value;if(!Oo(i))return r.issues.push({expected:"record",code:"invalid_type",input:i,inst:e}),r;let o=[];if(t.keyType._zod.values){let s=t.keyType._zod.values;r.value={};for(let u of s)if(typeof u=="string"||typeof u=="number"||typeof u=="symbol"){let c=t.valueType._zod.run({value:i[u],issues:[]},n);c instanceof Promise?o.push(c.then(l=>{l.issues.length&&r.issues.push(...Hr(u,l.issues)),r.value[u]=l.value})):(c.issues.length&&r.issues.push(...Hr(u,c.issues)),r.value[u]=c.value)}let a;for(let u in i)s.has(u)||(a=a??[],a.push(u));a&&a.length>0&&r.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:a})}else{r.value={};for(let s of Reflect.ownKeys(i)){if(s==="__proto__")continue;let a=t.keyType._zod.run({value:s,issues:[]},n);if(a instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(a.issues.length){r.issues.push({origin:"record",code:"invalid_key",issues:a.issues.map(c=>$r(c,n,tr())),input:s,path:[s],inst:e}),r.value[a.value]=a.value;continue}let u=t.valueType._zod.run({value:i[s],issues:[]},n);u instanceof Promise?o.push(u.then(c=>{c.issues.length&&r.issues.push(...Hr(s,c.issues)),r.value[a.value]=c.value})):(u.issues.length&&r.issues.push(...Hr(s,u.issues)),r.value[a.value]=u.value)}}return o.length?Promise.all(o).then(()=>r):r}});var Lf=x("$ZodEnum",(e,t)=>{Se.init(e,t);let r=Cs(t.entries);e._zod.values=new Set(r),e._zod.pattern=new RegExp(`^(${r.filter(n=>Qd.has(typeof n)).map(n=>typeof n=="string"?Gn(n):n.toString()).join("|")})$`),e._zod.parse=(n,i)=>{let o=n.value;return e._zod.values.has(o)||n.issues.push({code:"invalid_value",values:r,input:o,inst:e}),n}}),Uf=x("$ZodLiteral",(e,t)=>{Se.init(e,t),e._zod.values=new Set(t.values),e._zod.pattern=new RegExp(`^(${t.values.map(r=>typeof r=="string"?Gn(r):r?r.toString():String(r)).join("|")})$`),e._zod.parse=(r,n)=>{let i=r.value;return e._zod.values.has(i)||r.issues.push({code:"invalid_value",values:t.values,input:i,inst:e}),r}});var Vf=x("$ZodTransform",(e,t)=>{Se.init(e,t),e._zod.parse=(r,n)=>{let i=t.transform(r.value,r);if(n.async)return(i instanceof Promise?i:Promise.resolve(i)).then(s=>(r.value=s,r));if(i instanceof Promise)throw new hn;return r.value=i,r}}),Bf=x("$ZodOptional",(e,t)=>{Se.init(e,t),e._zod.optin="optional",e._zod.optout="optional",ze(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),ze(e._zod,"pattern",()=>{let r=t.innerType._zod.pattern;return r?new RegExp(`^(${js(r.source)})?$`):void 0}),e._zod.parse=(r,n)=>t.innerType._zod.optin==="optional"?t.innerType._zod.run(r,n):r.value===void 0?r:t.innerType._zod.run(r,n)}),Wf=x("$ZodNullable",(e,t)=>{Se.init(e,t),ze(e._zod,"optin",()=>t.innerType._zod.optin),ze(e._zod,"optout",()=>t.innerType._zod.optout),ze(e._zod,"pattern",()=>{let r=t.innerType._zod.pattern;return r?new RegExp(`^(${js(r.source)}|null)$`):void 0}),ze(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(r,n)=>r.value===null?r:t.innerType._zod.run(r,n)}),Jf=x("$ZodDefault",(e,t)=>{Se.init(e,t),e._zod.optin="optional",ze(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{if(r.value===void 0)return r.value=t.defaultValue,r;let i=t.innerType._zod.run(r,n);return i instanceof Promise?i.then(o=>Fb(o,t)):Fb(i,t)}});function Fb(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var Hf=x("$ZodPrefault",(e,t)=>{Se.init(e,t),e._zod.optin="optional",ze(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>(r.value===void 0&&(r.value=t.defaultValue),t.innerType._zod.run(r,n))}),Kf=x("$ZodNonOptional",(e,t)=>{Se.init(e,t),ze(e._zod,"values",()=>{let r=t.innerType._zod.values;return r?new Set([...r].filter(n=>n!==void 0)):void 0}),e._zod.parse=(r,n)=>{let i=t.innerType._zod.run(r,n);return i instanceof Promise?i.then(o=>qb(o,e)):qb(i,e)}});function qb(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}var Qf=x("$ZodCatch",(e,t)=>{Se.init(e,t),e._zod.optin="optional",ze(e._zod,"optout",()=>t.innerType._zod.optout),ze(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{let i=t.innerType._zod.run(r,n);return i instanceof Promise?i.then(o=>(r.value=o.value,o.issues.length&&(r.value=t.catchValue({...r,error:{issues:o.issues.map(s=>$r(s,n,tr()))},input:r.value}),r.issues=[]),r)):(r.value=i.value,i.issues.length&&(r.value=t.catchValue({...r,error:{issues:i.issues.map(o=>$r(o,n,tr()))},input:r.value}),r.issues=[]),r)}});var Xf=x("$ZodPipe",(e,t)=>{Se.init(e,t),ze(e._zod,"values",()=>t.in._zod.values),ze(e._zod,"optin",()=>t.in._zod.optin),ze(e._zod,"optout",()=>t.out._zod.optout),e._zod.parse=(r,n)=>{let i=t.in._zod.run(r,n);return i instanceof Promise?i.then(o=>Lb(o,t,n)):Lb(i,t,n)}});function Lb(e,t,r){return Ni(e)?e:t.out._zod.run({value:e.value,issues:e.issues},r)}var Yf=x("$ZodReadonly",(e,t)=>{Se.init(e,t),ze(e._zod,"propValues",()=>t.innerType._zod.propValues),ze(e._zod,"values",()=>t.innerType._zod.values),ze(e._zod,"optin",()=>t.innerType._zod.optin),ze(e._zod,"optout",()=>t.innerType._zod.optout),e._zod.parse=(r,n)=>{let i=t.innerType._zod.run(r,n);return i instanceof Promise?i.then(Ub):Ub(i)}});function Ub(e){return e.value=Object.freeze(e.value),e}var em=x("$ZodCustom",(e,t)=>{yt.init(e,t),Se.init(e,t),e._zod.parse=(r,n)=>r,e._zod.check=r=>{let n=r.value,i=t.fn(n);if(i instanceof Promise)return i.then(o=>Vb(o,r,n,e));Vb(i,r,n,e)}});function Vb(e,t,r,n){if(!e){let i={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(i.params=n._zod.def.params),t.issues.push(ef(i))}}var Jz=e=>{let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"NaN":"number";case"object":{if(Array.isArray(e))return"array";if(e===null)return"null";if(Object.getPrototypeOf(e)!==Object.prototype&&e.constructor)return e.constructor.name}}return t},Hz=()=>{let e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"}};function t(n){return e[n]??null}let r={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"};return n=>{switch(n.code){case"invalid_type":return`Invalid input: expected ${n.expected}, received ${Jz(n.input)}`;case"invalid_value":return n.values.length===1?`Invalid input: expected ${Cc(n.values[0])}`:`Invalid option: expected one of ${Oc(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",o=t(n.origin);return o?`Too big: expected ${n.origin??"value"} to have ${i}${n.maximum.toString()} ${o.unit??"elements"}`:`Too big: expected ${n.origin??"value"} to be ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",o=t(n.origin);return o?`Too small: expected ${n.origin} to have ${i}${n.minimum.toString()} ${o.unit}`:`Too small: expected ${n.origin} to be ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;return i.format==="starts_with"?`Invalid string: must start with "${i.prefix}"`:i.format==="ends_with"?`Invalid string: must end with "${i.suffix}"`:i.format==="includes"?`Invalid string: must include "${i.includes}"`:i.format==="regex"?`Invalid string: must match pattern ${i.pattern}`:`Invalid ${r[i.format]??n.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${n.divisor}`;case"unrecognized_keys":return`Unrecognized key${n.keys.length>1?"s":""}: ${Oc(n.keys,", ")}`;case"invalid_key":return`Invalid key in ${n.origin}`;case"invalid_union":return"Invalid input";case"invalid_element":return`Invalid value in ${n.origin}`;default:return"Invalid input"}}};function Qb(){return{localeError:Hz()}}var Zs=class{constructor(){this._map=new Map,this._idmap=new Map}add(t,...r){let n=r[0];if(this._map.set(t,n),n&&typeof n=="object"&&"id"in n){if(this._idmap.has(n.id))throw new Error(`ID ${n.id} already exists in the registry`);this._idmap.set(n.id,t)}return this}clear(){return this._map=new Map,this._idmap=new Map,this}remove(t){let r=this._map.get(t);return r&&typeof r=="object"&&"id"in r&&this._idmap.delete(r.id),this._map.delete(t),this}get(t){let r=t._zod.parent;if(r){let n={...this.get(r)??{}};return delete n.id,{...n,...this._map.get(t)}}return this._map.get(t)}has(t){return this._map.has(t)}};function Xb(){return new Zs}var Zn=Xb();function tm(e,t){return new e({type:"string",...J(t)})}function rm(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...J(t)})}function Zc(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...J(t)})}function nm(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...J(t)})}function im(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...J(t)})}function om(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...J(t)})}function sm(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...J(t)})}function am(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...J(t)})}function cm(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...J(t)})}function lm(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...J(t)})}function um(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...J(t)})}function dm(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...J(t)})}function fm(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...J(t)})}function mm(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...J(t)})}function pm(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...J(t)})}function hm(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...J(t)})}function gm(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...J(t)})}function _m(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...J(t)})}function ym(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...J(t)})}function vm(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...J(t)})}function bm(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...J(t)})}function wm(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...J(t)})}function km(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...J(t)})}function Yb(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...J(t)})}function e0(e,t){return new e({type:"string",format:"date",check:"string_format",...J(t)})}function t0(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...J(t)})}function r0(e,t){return new e({type:"string",format:"duration",check:"string_format",...J(t)})}function xm(e,t){return new e({type:"number",checks:[],...J(t)})}function Sm(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...J(t)})}function Tm(e,t){return new e({type:"boolean",...J(t)})}function $m(e,t){return new e({type:"null",...J(t)})}function Em(e){return new e({type:"unknown"})}function zm(e,t){return new e({type:"never",...J(t)})}function Fc(e,t){return new ff({check:"less_than",...J(t),value:e,inclusive:!1})}function Fs(e,t){return new ff({check:"less_than",...J(t),value:e,inclusive:!0})}function qc(e,t){return new mf({check:"greater_than",...J(t),value:e,inclusive:!1})}function qs(e,t){return new mf({check:"greater_than",...J(t),value:e,inclusive:!0})}function Lc(e,t){return new xb({check:"multiple_of",...J(t),value:e})}function Uc(e,t){return new Tb({check:"max_length",...J(t),maximum:e})}function Po(e,t){return new $b({check:"min_length",...J(t),minimum:e})}function Vc(e,t){return new Eb({check:"length_equals",...J(t),length:e})}function Am(e,t){return new zb({check:"string_format",format:"regex",...J(t),pattern:e})}function Om(e){return new Ab({check:"string_format",format:"lowercase",...J(e)})}function Pm(e){return new Ob({check:"string_format",format:"uppercase",...J(e)})}function Cm(e,t){return new Pb({check:"string_format",format:"includes",...J(t),includes:e})}function Rm(e,t){return new Cb({check:"string_format",format:"starts_with",...J(t),prefix:e})}function Im(e,t){return new Rb({check:"string_format",format:"ends_with",...J(t),suffix:e})}function Gi(e){return new Ib({check:"overwrite",tx:e})}function jm(e){return Gi(t=>t.normalize(e))}function Nm(){return Gi(e=>e.trim())}function Mm(){return Gi(e=>e.toLowerCase())}function Dm(){return Gi(e=>e.toUpperCase())}function n0(e,t,r){return new e({type:"array",element:t,...J(r)})}function Gm(e,t,r){let n=J(r);return n.abort??(n.abort=!0),new e({type:"custom",check:"custom",fn:t,...n})}function Zm(e,t,r){return new e({type:"custom",check:"custom",fn:t,...J(r)})}var Bc=class{constructor(t){this.counter=0,this.metadataRegistry=t?.metadata??Zn,this.target=t?.target??"draft-2020-12",this.unrepresentable=t?.unrepresentable??"throw",this.override=t?.override??(()=>{}),this.io=t?.io??"output",this.seen=new Map}process(t,r={path:[],schemaPath:[]}){var n;let i=t._zod.def,o={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},s=this.seen.get(t);if(s)return s.count++,r.schemaPath.includes(t)&&(s.cycle=r.path),s.schema;let a={schema:{},count:1,cycle:void 0,path:r.path};this.seen.set(t,a);let u=t._zod.toJSONSchema?.();if(u)a.schema=u;else{let d={...r,schemaPath:[...r.schemaPath,t],path:r.path},p=t._zod.parent;if(p)a.ref=p,this.process(p,d),this.seen.get(p).isParent=!0;else{let f=a.schema;switch(i.type){case"string":{let h=f;h.type="string";let{minimum:m,maximum:g,format:y,patterns:v,contentEncoding:b}=t._zod.bag;if(typeof m=="number"&&(h.minLength=m),typeof g=="number"&&(h.maxLength=g),y&&(h.format=o[y]??y,h.format===""&&delete h.format),b&&(h.contentEncoding=b),v&&v.size>0){let w=[...v];w.length===1?h.pattern=w[0].source:w.length>1&&(a.schema.allOf=[...w.map(S=>({...this.target==="draft-7"?{type:"string"}:{},pattern:S.source}))])}break}case"number":{let h=f,{minimum:m,maximum:g,format:y,multipleOf:v,exclusiveMaximum:b,exclusiveMinimum:w}=t._zod.bag;typeof y=="string"&&y.includes("int")?h.type="integer":h.type="number",typeof w=="number"&&(h.exclusiveMinimum=w),typeof m=="number"&&(h.minimum=m,typeof w=="number"&&(w>=m?delete h.minimum:delete h.exclusiveMinimum)),typeof b=="number"&&(h.exclusiveMaximum=b),typeof g=="number"&&(h.maximum=g,typeof b=="number"&&(b<=g?delete h.maximum:delete h.exclusiveMaximum)),typeof v=="number"&&(h.multipleOf=v);break}case"boolean":{let h=f;h.type="boolean";break}case"bigint":{if(this.unrepresentable==="throw")throw new Error("BigInt cannot be represented in JSON Schema");break}case"symbol":{if(this.unrepresentable==="throw")throw new Error("Symbols cannot be represented in JSON Schema");break}case"null":{f.type="null";break}case"any":break;case"unknown":break;case"undefined":{if(this.unrepresentable==="throw")throw new Error("Undefined cannot be represented in JSON Schema");break}case"void":{if(this.unrepresentable==="throw")throw new Error("Void cannot be represented in JSON Schema");break}case"never":{f.not={};break}case"date":{if(this.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema");break}case"array":{let h=f,{minimum:m,maximum:g}=t._zod.bag;typeof m=="number"&&(h.minItems=m),typeof g=="number"&&(h.maxItems=g),h.type="array",h.items=this.process(i.element,{...d,path:[...d.path,"items"]});break}case"object":{let h=f;h.type="object",h.properties={};let m=i.shape;for(let v in m)h.properties[v]=this.process(m[v],{...d,path:[...d.path,"properties",v]});let g=new Set(Object.keys(m)),y=new Set([...g].filter(v=>{let b=i.shape[v]._zod;return this.io==="input"?b.optin===void 0:b.optout===void 0}));y.size>0&&(h.required=Array.from(y)),i.catchall?._zod.def.type==="never"?h.additionalProperties=!1:i.catchall?i.catchall&&(h.additionalProperties=this.process(i.catchall,{...d,path:[...d.path,"additionalProperties"]})):this.io==="output"&&(h.additionalProperties=!1);break}case"union":{let h=f;h.anyOf=i.options.map((m,g)=>this.process(m,{...d,path:[...d.path,"anyOf",g]}));break}case"intersection":{let h=f,m=this.process(i.left,{...d,path:[...d.path,"allOf",0]}),g=this.process(i.right,{...d,path:[...d.path,"allOf",1]}),y=b=>"allOf"in b&&Object.keys(b).length===1,v=[...y(m)?m.allOf:[m],...y(g)?g.allOf:[g]];h.allOf=v;break}case"tuple":{let h=f;h.type="array";let m=i.items.map((v,b)=>this.process(v,{...d,path:[...d.path,"prefixItems",b]}));if(this.target==="draft-2020-12"?h.prefixItems=m:h.items=m,i.rest){let v=this.process(i.rest,{...d,path:[...d.path,"items"]});this.target==="draft-2020-12"?h.items=v:h.additionalItems=v}i.rest&&(h.items=this.process(i.rest,{...d,path:[...d.path,"items"]}));let{minimum:g,maximum:y}=t._zod.bag;typeof g=="number"&&(h.minItems=g),typeof y=="number"&&(h.maxItems=y);break}case"record":{let h=f;h.type="object",h.propertyNames=this.process(i.keyType,{...d,path:[...d.path,"propertyNames"]}),h.additionalProperties=this.process(i.valueType,{...d,path:[...d.path,"additionalProperties"]});break}case"map":{if(this.unrepresentable==="throw")throw new Error("Map cannot be represented in JSON Schema");break}case"set":{if(this.unrepresentable==="throw")throw new Error("Set cannot be represented in JSON Schema");break}case"enum":{let h=f,m=Cs(i.entries);m.every(g=>typeof g=="number")&&(h.type="number"),m.every(g=>typeof g=="string")&&(h.type="string"),h.enum=m;break}case"literal":{let h=f,m=[];for(let g of i.values)if(g===void 0){if(this.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof g=="bigint"){if(this.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");m.push(Number(g))}else m.push(g);if(m.length!==0)if(m.length===1){let g=m[0];h.type=g===null?"null":typeof g,h.const=g}else m.every(g=>typeof g=="number")&&(h.type="number"),m.every(g=>typeof g=="string")&&(h.type="string"),m.every(g=>typeof g=="boolean")&&(h.type="string"),m.every(g=>g===null)&&(h.type="null"),h.enum=m;break}case"file":{let h=f,m={type:"string",format:"binary",contentEncoding:"binary"},{minimum:g,maximum:y,mime:v}=t._zod.bag;g!==void 0&&(m.minLength=g),y!==void 0&&(m.maxLength=y),v?v.length===1?(m.contentMediaType=v[0],Object.assign(h,m)):h.anyOf=v.map(b=>({...m,contentMediaType:b})):Object.assign(h,m);break}case"transform":{if(this.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema");break}case"nullable":{let h=this.process(i.innerType,d);f.anyOf=[h,{type:"null"}];break}case"nonoptional":{this.process(i.innerType,d),a.ref=i.innerType;break}case"success":{let h=f;h.type="boolean";break}case"default":{this.process(i.innerType,d),a.ref=i.innerType,f.default=JSON.parse(JSON.stringify(i.defaultValue));break}case"prefault":{this.process(i.innerType,d),a.ref=i.innerType,this.io==="input"&&(f._prefault=JSON.parse(JSON.stringify(i.defaultValue)));break}case"catch":{this.process(i.innerType,d),a.ref=i.innerType;let h;try{h=i.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}f.default=h;break}case"nan":{if(this.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema");break}case"template_literal":{let h=f,m=t._zod.pattern;if(!m)throw new Error("Pattern not found in template literal");h.type="string",h.pattern=m.source;break}case"pipe":{let h=this.io==="input"?i.in._zod.def.type==="transform"?i.out:i.in:i.out;this.process(h,d),a.ref=h;break}case"readonly":{this.process(i.innerType,d),a.ref=i.innerType,f.readOnly=!0;break}case"promise":{this.process(i.innerType,d),a.ref=i.innerType;break}case"optional":{this.process(i.innerType,d),a.ref=i.innerType;break}case"lazy":{let h=t._zod.innerType;this.process(h,d),a.ref=h;break}case"custom":{if(this.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema");break}default:}}}let c=this.metadataRegistry.get(t);return c&&Object.assign(a.schema,c),this.io==="input"&&ot(t)&&(delete a.schema.examples,delete a.schema.default),this.io==="input"&&a.schema._prefault&&((n=a.schema).default??(n.default=a.schema._prefault)),delete a.schema._prefault,this.seen.get(t).schema}emit(t,r){let n={cycles:r?.cycles??"ref",reused:r?.reused??"inline",external:r?.external??void 0},i=this.seen.get(t);if(!i)throw new Error("Unprocessed schema. This is a bug in Zod.");let o=l=>{let d=this.target==="draft-2020-12"?"$defs":"definitions";if(n.external){let m=n.external.registry.get(l[0])?.id,g=n.external.uri??(v=>v);if(m)return{ref:g(m)};let y=l[1].defId??l[1].schema.id??`schema${this.counter++}`;return l[1].defId=y,{defId:y,ref:`${g("__shared")}#/${d}/${y}`}}if(l[1]===i)return{ref:"#"};let f=`#/${d}/`,h=l[1].schema.id??`__schema${this.counter++}`;return{defId:h,ref:f+h}},s=l=>{if(l[1].schema.$ref)return;let d=l[1],{ref:p,defId:f}=o(l);d.def={...d.schema},f&&(d.defId=f);let h=d.schema;for(let m in h)delete h[m];h.$ref=p};if(n.cycles==="throw")for(let l of this.seen.entries()){let d=l[1];if(d.cycle)throw new Error(`Cycle detected: #/${d.cycle?.join("/")}/<root>
449
+ path: iss.path ? [${Ni(v)}, ...iss.path] : [${Ni(v)}]
450
+ })));`),p.write(`newResult[${Ni(v)}] = ${b}.value`)}p.write("payload.value = newResult;"),p.write("return payload;");let y=p.compile();return(v,b)=>y(d,v,b)},i,o=Ao,s=!Ac.jitless,u=s&&Kd.value,c=t.catchall,l;e._zod.parse=(d,p)=>{l??(l=r.value);let f=d.value;if(!o(f))return d.issues.push({expected:"object",code:"invalid_type",input:f,inst:e}),d;let h=[];if(s&&u&&p?.async===!1&&p.jitless!==!0)i||(i=n(t.shape)),d=i(d,p);else{d.value={};let b=l.shape;for(let w of l.keys){let S=b[w],R=S._zod.run({value:f[w],issues:[]},p),X=S._zod.optin==="optional"&&S._zod.optout==="optional";R instanceof Promise?h.push(R.then(be=>X?Gb(be,d,w,f):Nc(be,d,w))):X?Gb(R,d,w,f):Nc(R,d,w)}}if(!c)return h.length?Promise.all(h).then(()=>d):d;let m=[],g=l.keySet,y=c._zod,v=y.def.type;for(let b of Object.keys(f)){if(g.has(b))continue;if(v==="never"){m.push(b);continue}let w=y.run({value:f[b],issues:[]},p);w instanceof Promise?h.push(w.then(S=>Nc(S,d,b))):Nc(w,d,b)}return m.length&&d.issues.push({code:"unrecognized_keys",keys:m,input:f,inst:e}),h.length?Promise.all(h).then(()=>d):d}});function Zb(e,t,r,n){for(let i of e)if(i.issues.length===0)return t.value=i.value,t;return t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(i=>i.issues.map(o=>$r(o,n,er())))}),t}var Gc=x("$ZodUnion",(e,t)=>{Se.init(e,t),Ee(e._zod,"optin",()=>t.options.some(r=>r._zod.optin==="optional")?"optional":void 0),Ee(e._zod,"optout",()=>t.options.some(r=>r._zod.optout==="optional")?"optional":void 0),Ee(e._zod,"values",()=>{if(t.options.every(r=>r._zod.values))return new Set(t.options.flatMap(r=>Array.from(r._zod.values)))}),Ee(e._zod,"pattern",()=>{if(t.options.every(r=>r._zod.pattern)){let r=t.options.map(n=>n._zod.pattern);return new RegExp(`^(${r.map(n=>js(n.source)).join("|")})$`)}}),e._zod.parse=(r,n)=>{let i=!1,o=[];for(let s of t.options){let a=s._zod.run({value:r.value,issues:[]},n);if(a instanceof Promise)o.push(a),i=!0;else{if(a.issues.length===0)return a;o.push(a)}}return i?Promise.all(o).then(s=>Zb(s,r,e,n)):Zb(o,r,e,n)}}),Zf=x("$ZodDiscriminatedUnion",(e,t)=>{Gc.init(e,t);let r=e._zod.parse;Ee(e._zod,"propValues",()=>{let i={};for(let o of t.options){let s=o._zod.propValues;if(!s||Object.keys(s).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(o)}"`);for(let[a,u]of Object.entries(s)){i[a]||(i[a]=new Set);for(let c of u)i[a].add(c)}}return i});let n=Rs(()=>{let i=t.options,o=new Map;for(let s of i){let a=s._zod.propValues[t.discriminator];if(!a||a.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(s)}"`);for(let u of a){if(o.has(u))throw new Error(`Duplicate discriminator value "${String(u)}"`);o.set(u,s)}}return o});e._zod.parse=(i,o)=>{let s=i.value;if(!Ao(s))return i.issues.push({code:"invalid_type",expected:"object",input:s,inst:e}),i;let a=n.value.get(s?.[t.discriminator]);return a?a._zod.run(i,o):t.unionFallback?r(i,o):(i.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",input:s,path:[t.discriminator],inst:e}),i)}}),Ff=x("$ZodIntersection",(e,t)=>{Se.init(e,t),e._zod.parse=(r,n)=>{let i=r.value,o=t.left._zod.run({value:i,issues:[]},n),s=t.right._zod.run({value:i,issues:[]},n);return o instanceof Promise||s instanceof Promise?Promise.all([o,s]).then(([u,c])=>Fb(r,u,c)):Fb(r,o,s)}});function pf(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Oo(e)&&Oo(t)){let r=Object.keys(t),n=Object.keys(e).filter(o=>r.indexOf(o)!==-1),i={...e,...t};for(let o of n){let s=pf(e[o],t[o]);if(!s.valid)return{valid:!1,mergeErrorPath:[o,...s.mergeErrorPath]};i[o]=s.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let r=[];for(let n=0;n<e.length;n++){let i=e[n],o=t[n],s=pf(i,o);if(!s.valid)return{valid:!1,mergeErrorPath:[n,...s.mergeErrorPath]};r.push(s.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function Fb(e,t,r){if(t.issues.length&&e.issues.push(...t.issues),r.issues.length&&e.issues.push(...r.issues),Mi(e))return e;let n=pf(t.value,r.value);if(!n.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(n.mergeErrorPath)}`);return e.value=n.data,e}var qf=x("$ZodRecord",(e,t)=>{Se.init(e,t),e._zod.parse=(r,n)=>{let i=r.value;if(!Oo(i))return r.issues.push({expected:"record",code:"invalid_type",input:i,inst:e}),r;let o=[];if(t.keyType._zod.values){let s=t.keyType._zod.values;r.value={};for(let u of s)if(typeof u=="string"||typeof u=="number"||typeof u=="symbol"){let c=t.valueType._zod.run({value:i[u],issues:[]},n);c instanceof Promise?o.push(c.then(l=>{l.issues.length&&r.issues.push(...Hr(u,l.issues)),r.value[u]=l.value})):(c.issues.length&&r.issues.push(...Hr(u,c.issues)),r.value[u]=c.value)}let a;for(let u in i)s.has(u)||(a=a??[],a.push(u));a&&a.length>0&&r.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:a})}else{r.value={};for(let s of Reflect.ownKeys(i)){if(s==="__proto__")continue;let a=t.keyType._zod.run({value:s,issues:[]},n);if(a instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(a.issues.length){r.issues.push({origin:"record",code:"invalid_key",issues:a.issues.map(c=>$r(c,n,er())),input:s,path:[s],inst:e}),r.value[a.value]=a.value;continue}let u=t.valueType._zod.run({value:i[s],issues:[]},n);u instanceof Promise?o.push(u.then(c=>{c.issues.length&&r.issues.push(...Hr(s,c.issues)),r.value[a.value]=c.value})):(u.issues.length&&r.issues.push(...Hr(s,u.issues)),r.value[a.value]=u.value)}}return o.length?Promise.all(o).then(()=>r):r}});var Lf=x("$ZodEnum",(e,t)=>{Se.init(e,t);let r=Cs(t.entries);e._zod.values=new Set(r),e._zod.pattern=new RegExp(`^(${r.filter(n=>Qd.has(typeof n)).map(n=>typeof n=="string"?Zn(n):n.toString()).join("|")})$`),e._zod.parse=(n,i)=>{let o=n.value;return e._zod.values.has(o)||n.issues.push({code:"invalid_value",values:r,input:o,inst:e}),n}}),Uf=x("$ZodLiteral",(e,t)=>{Se.init(e,t),e._zod.values=new Set(t.values),e._zod.pattern=new RegExp(`^(${t.values.map(r=>typeof r=="string"?Zn(r):r?r.toString():String(r)).join("|")})$`),e._zod.parse=(r,n)=>{let i=r.value;return e._zod.values.has(i)||r.issues.push({code:"invalid_value",values:t.values,input:i,inst:e}),r}});var Vf=x("$ZodTransform",(e,t)=>{Se.init(e,t),e._zod.parse=(r,n)=>{let i=t.transform(r.value,r);if(n.async)return(i instanceof Promise?i:Promise.resolve(i)).then(s=>(r.value=s,r));if(i instanceof Promise)throw new hn;return r.value=i,r}}),Bf=x("$ZodOptional",(e,t)=>{Se.init(e,t),e._zod.optin="optional",e._zod.optout="optional",Ee(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),Ee(e._zod,"pattern",()=>{let r=t.innerType._zod.pattern;return r?new RegExp(`^(${js(r.source)})?$`):void 0}),e._zod.parse=(r,n)=>t.innerType._zod.optin==="optional"?t.innerType._zod.run(r,n):r.value===void 0?r:t.innerType._zod.run(r,n)}),Wf=x("$ZodNullable",(e,t)=>{Se.init(e,t),Ee(e._zod,"optin",()=>t.innerType._zod.optin),Ee(e._zod,"optout",()=>t.innerType._zod.optout),Ee(e._zod,"pattern",()=>{let r=t.innerType._zod.pattern;return r?new RegExp(`^(${js(r.source)}|null)$`):void 0}),Ee(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(r,n)=>r.value===null?r:t.innerType._zod.run(r,n)}),Jf=x("$ZodDefault",(e,t)=>{Se.init(e,t),e._zod.optin="optional",Ee(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{if(r.value===void 0)return r.value=t.defaultValue,r;let i=t.innerType._zod.run(r,n);return i instanceof Promise?i.then(o=>qb(o,t)):qb(i,t)}});function qb(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var Hf=x("$ZodPrefault",(e,t)=>{Se.init(e,t),e._zod.optin="optional",Ee(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>(r.value===void 0&&(r.value=t.defaultValue),t.innerType._zod.run(r,n))}),Kf=x("$ZodNonOptional",(e,t)=>{Se.init(e,t),Ee(e._zod,"values",()=>{let r=t.innerType._zod.values;return r?new Set([...r].filter(n=>n!==void 0)):void 0}),e._zod.parse=(r,n)=>{let i=t.innerType._zod.run(r,n);return i instanceof Promise?i.then(o=>Lb(o,e)):Lb(i,e)}});function Lb(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}var Qf=x("$ZodCatch",(e,t)=>{Se.init(e,t),e._zod.optin="optional",Ee(e._zod,"optout",()=>t.innerType._zod.optout),Ee(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{let i=t.innerType._zod.run(r,n);return i instanceof Promise?i.then(o=>(r.value=o.value,o.issues.length&&(r.value=t.catchValue({...r,error:{issues:o.issues.map(s=>$r(s,n,er()))},input:r.value}),r.issues=[]),r)):(r.value=i.value,i.issues.length&&(r.value=t.catchValue({...r,error:{issues:i.issues.map(o=>$r(o,n,er()))},input:r.value}),r.issues=[]),r)}});var Xf=x("$ZodPipe",(e,t)=>{Se.init(e,t),Ee(e._zod,"values",()=>t.in._zod.values),Ee(e._zod,"optin",()=>t.in._zod.optin),Ee(e._zod,"optout",()=>t.out._zod.optout),e._zod.parse=(r,n)=>{let i=t.in._zod.run(r,n);return i instanceof Promise?i.then(o=>Ub(o,t,n)):Ub(i,t,n)}});function Ub(e,t,r){return Mi(e)?e:t.out._zod.run({value:e.value,issues:e.issues},r)}var Yf=x("$ZodReadonly",(e,t)=>{Se.init(e,t),Ee(e._zod,"propValues",()=>t.innerType._zod.propValues),Ee(e._zod,"values",()=>t.innerType._zod.values),Ee(e._zod,"optin",()=>t.innerType._zod.optin),Ee(e._zod,"optout",()=>t.innerType._zod.optout),e._zod.parse=(r,n)=>{let i=t.innerType._zod.run(r,n);return i instanceof Promise?i.then(Vb):Vb(i)}});function Vb(e){return e.value=Object.freeze(e.value),e}var em=x("$ZodCustom",(e,t)=>{yt.init(e,t),Se.init(e,t),e._zod.parse=(r,n)=>r,e._zod.check=r=>{let n=r.value,i=t.fn(n);if(i instanceof Promise)return i.then(o=>Bb(o,r,n,e));Bb(i,r,n,e)}});function Bb(e,t,r,n){if(!e){let i={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(i.params=n._zod.def.params),t.issues.push(ef(i))}}var Kz=e=>{let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"NaN":"number";case"object":{if(Array.isArray(e))return"array";if(e===null)return"null";if(Object.getPrototypeOf(e)!==Object.prototype&&e.constructor)return e.constructor.name}}return t},Qz=()=>{let e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"}};function t(n){return e[n]??null}let r={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"};return n=>{switch(n.code){case"invalid_type":return`Invalid input: expected ${n.expected}, received ${Kz(n.input)}`;case"invalid_value":return n.values.length===1?`Invalid input: expected ${Cc(n.values[0])}`:`Invalid option: expected one of ${Oc(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",o=t(n.origin);return o?`Too big: expected ${n.origin??"value"} to have ${i}${n.maximum.toString()} ${o.unit??"elements"}`:`Too big: expected ${n.origin??"value"} to be ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",o=t(n.origin);return o?`Too small: expected ${n.origin} to have ${i}${n.minimum.toString()} ${o.unit}`:`Too small: expected ${n.origin} to be ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;return i.format==="starts_with"?`Invalid string: must start with "${i.prefix}"`:i.format==="ends_with"?`Invalid string: must end with "${i.suffix}"`:i.format==="includes"?`Invalid string: must include "${i.includes}"`:i.format==="regex"?`Invalid string: must match pattern ${i.pattern}`:`Invalid ${r[i.format]??n.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${n.divisor}`;case"unrecognized_keys":return`Unrecognized key${n.keys.length>1?"s":""}: ${Oc(n.keys,", ")}`;case"invalid_key":return`Invalid key in ${n.origin}`;case"invalid_union":return"Invalid input";case"invalid_element":return`Invalid value in ${n.origin}`;default:return"Invalid input"}}};function Xb(){return{localeError:Qz()}}var Zs=class{constructor(){this._map=new Map,this._idmap=new Map}add(t,...r){let n=r[0];if(this._map.set(t,n),n&&typeof n=="object"&&"id"in n){if(this._idmap.has(n.id))throw new Error(`ID ${n.id} already exists in the registry`);this._idmap.set(n.id,t)}return this}clear(){return this._map=new Map,this._idmap=new Map,this}remove(t){let r=this._map.get(t);return r&&typeof r=="object"&&"id"in r&&this._idmap.delete(r.id),this._map.delete(t),this}get(t){let r=t._zod.parent;if(r){let n={...this.get(r)??{}};return delete n.id,{...n,...this._map.get(t)}}return this._map.get(t)}has(t){return this._map.has(t)}};function Yb(){return new Zs}var Fn=Yb();function tm(e,t){return new e({type:"string",...J(t)})}function rm(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...J(t)})}function Zc(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...J(t)})}function nm(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...J(t)})}function im(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...J(t)})}function om(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...J(t)})}function sm(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...J(t)})}function am(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...J(t)})}function cm(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...J(t)})}function lm(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...J(t)})}function um(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...J(t)})}function dm(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...J(t)})}function fm(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...J(t)})}function mm(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...J(t)})}function pm(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...J(t)})}function hm(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...J(t)})}function gm(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...J(t)})}function _m(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...J(t)})}function ym(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...J(t)})}function vm(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...J(t)})}function bm(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...J(t)})}function wm(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...J(t)})}function km(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...J(t)})}function e0(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...J(t)})}function t0(e,t){return new e({type:"string",format:"date",check:"string_format",...J(t)})}function r0(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...J(t)})}function n0(e,t){return new e({type:"string",format:"duration",check:"string_format",...J(t)})}function xm(e,t){return new e({type:"number",checks:[],...J(t)})}function Sm(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...J(t)})}function Tm(e,t){return new e({type:"boolean",...J(t)})}function $m(e,t){return new e({type:"null",...J(t)})}function Em(e){return new e({type:"unknown"})}function zm(e,t){return new e({type:"never",...J(t)})}function Fc(e,t){return new ff({check:"less_than",...J(t),value:e,inclusive:!1})}function Fs(e,t){return new ff({check:"less_than",...J(t),value:e,inclusive:!0})}function qc(e,t){return new mf({check:"greater_than",...J(t),value:e,inclusive:!1})}function qs(e,t){return new mf({check:"greater_than",...J(t),value:e,inclusive:!0})}function Lc(e,t){return new Sb({check:"multiple_of",...J(t),value:e})}function Uc(e,t){return new $b({check:"max_length",...J(t),maximum:e})}function Po(e,t){return new Eb({check:"min_length",...J(t),minimum:e})}function Vc(e,t){return new zb({check:"length_equals",...J(t),length:e})}function Am(e,t){return new Ab({check:"string_format",format:"regex",...J(t),pattern:e})}function Om(e){return new Ob({check:"string_format",format:"lowercase",...J(e)})}function Pm(e){return new Pb({check:"string_format",format:"uppercase",...J(e)})}function Cm(e,t){return new Cb({check:"string_format",format:"includes",...J(t),includes:e})}function Rm(e,t){return new Rb({check:"string_format",format:"starts_with",...J(t),prefix:e})}function Im(e,t){return new Ib({check:"string_format",format:"ends_with",...J(t),suffix:e})}function Zi(e){return new jb({check:"overwrite",tx:e})}function jm(e){return Zi(t=>t.normalize(e))}function Nm(){return Zi(e=>e.trim())}function Mm(){return Zi(e=>e.toLowerCase())}function Dm(){return Zi(e=>e.toUpperCase())}function i0(e,t,r){return new e({type:"array",element:t,...J(r)})}function Gm(e,t,r){let n=J(r);return n.abort??(n.abort=!0),new e({type:"custom",check:"custom",fn:t,...n})}function Zm(e,t,r){return new e({type:"custom",check:"custom",fn:t,...J(r)})}var Bc=class{constructor(t){this.counter=0,this.metadataRegistry=t?.metadata??Fn,this.target=t?.target??"draft-2020-12",this.unrepresentable=t?.unrepresentable??"throw",this.override=t?.override??(()=>{}),this.io=t?.io??"output",this.seen=new Map}process(t,r={path:[],schemaPath:[]}){var n;let i=t._zod.def,o={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},s=this.seen.get(t);if(s)return s.count++,r.schemaPath.includes(t)&&(s.cycle=r.path),s.schema;let a={schema:{},count:1,cycle:void 0,path:r.path};this.seen.set(t,a);let u=t._zod.toJSONSchema?.();if(u)a.schema=u;else{let d={...r,schemaPath:[...r.schemaPath,t],path:r.path},p=t._zod.parent;if(p)a.ref=p,this.process(p,d),this.seen.get(p).isParent=!0;else{let f=a.schema;switch(i.type){case"string":{let h=f;h.type="string";let{minimum:m,maximum:g,format:y,patterns:v,contentEncoding:b}=t._zod.bag;if(typeof m=="number"&&(h.minLength=m),typeof g=="number"&&(h.maxLength=g),y&&(h.format=o[y]??y,h.format===""&&delete h.format),b&&(h.contentEncoding=b),v&&v.size>0){let w=[...v];w.length===1?h.pattern=w[0].source:w.length>1&&(a.schema.allOf=[...w.map(S=>({...this.target==="draft-7"?{type:"string"}:{},pattern:S.source}))])}break}case"number":{let h=f,{minimum:m,maximum:g,format:y,multipleOf:v,exclusiveMaximum:b,exclusiveMinimum:w}=t._zod.bag;typeof y=="string"&&y.includes("int")?h.type="integer":h.type="number",typeof w=="number"&&(h.exclusiveMinimum=w),typeof m=="number"&&(h.minimum=m,typeof w=="number"&&(w>=m?delete h.minimum:delete h.exclusiveMinimum)),typeof b=="number"&&(h.exclusiveMaximum=b),typeof g=="number"&&(h.maximum=g,typeof b=="number"&&(b<=g?delete h.maximum:delete h.exclusiveMaximum)),typeof v=="number"&&(h.multipleOf=v);break}case"boolean":{let h=f;h.type="boolean";break}case"bigint":{if(this.unrepresentable==="throw")throw new Error("BigInt cannot be represented in JSON Schema");break}case"symbol":{if(this.unrepresentable==="throw")throw new Error("Symbols cannot be represented in JSON Schema");break}case"null":{f.type="null";break}case"any":break;case"unknown":break;case"undefined":{if(this.unrepresentable==="throw")throw new Error("Undefined cannot be represented in JSON Schema");break}case"void":{if(this.unrepresentable==="throw")throw new Error("Void cannot be represented in JSON Schema");break}case"never":{f.not={};break}case"date":{if(this.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema");break}case"array":{let h=f,{minimum:m,maximum:g}=t._zod.bag;typeof m=="number"&&(h.minItems=m),typeof g=="number"&&(h.maxItems=g),h.type="array",h.items=this.process(i.element,{...d,path:[...d.path,"items"]});break}case"object":{let h=f;h.type="object",h.properties={};let m=i.shape;for(let v in m)h.properties[v]=this.process(m[v],{...d,path:[...d.path,"properties",v]});let g=new Set(Object.keys(m)),y=new Set([...g].filter(v=>{let b=i.shape[v]._zod;return this.io==="input"?b.optin===void 0:b.optout===void 0}));y.size>0&&(h.required=Array.from(y)),i.catchall?._zod.def.type==="never"?h.additionalProperties=!1:i.catchall?i.catchall&&(h.additionalProperties=this.process(i.catchall,{...d,path:[...d.path,"additionalProperties"]})):this.io==="output"&&(h.additionalProperties=!1);break}case"union":{let h=f;h.anyOf=i.options.map((m,g)=>this.process(m,{...d,path:[...d.path,"anyOf",g]}));break}case"intersection":{let h=f,m=this.process(i.left,{...d,path:[...d.path,"allOf",0]}),g=this.process(i.right,{...d,path:[...d.path,"allOf",1]}),y=b=>"allOf"in b&&Object.keys(b).length===1,v=[...y(m)?m.allOf:[m],...y(g)?g.allOf:[g]];h.allOf=v;break}case"tuple":{let h=f;h.type="array";let m=i.items.map((v,b)=>this.process(v,{...d,path:[...d.path,"prefixItems",b]}));if(this.target==="draft-2020-12"?h.prefixItems=m:h.items=m,i.rest){let v=this.process(i.rest,{...d,path:[...d.path,"items"]});this.target==="draft-2020-12"?h.items=v:h.additionalItems=v}i.rest&&(h.items=this.process(i.rest,{...d,path:[...d.path,"items"]}));let{minimum:g,maximum:y}=t._zod.bag;typeof g=="number"&&(h.minItems=g),typeof y=="number"&&(h.maxItems=y);break}case"record":{let h=f;h.type="object",h.propertyNames=this.process(i.keyType,{...d,path:[...d.path,"propertyNames"]}),h.additionalProperties=this.process(i.valueType,{...d,path:[...d.path,"additionalProperties"]});break}case"map":{if(this.unrepresentable==="throw")throw new Error("Map cannot be represented in JSON Schema");break}case"set":{if(this.unrepresentable==="throw")throw new Error("Set cannot be represented in JSON Schema");break}case"enum":{let h=f,m=Cs(i.entries);m.every(g=>typeof g=="number")&&(h.type="number"),m.every(g=>typeof g=="string")&&(h.type="string"),h.enum=m;break}case"literal":{let h=f,m=[];for(let g of i.values)if(g===void 0){if(this.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof g=="bigint"){if(this.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");m.push(Number(g))}else m.push(g);if(m.length!==0)if(m.length===1){let g=m[0];h.type=g===null?"null":typeof g,h.const=g}else m.every(g=>typeof g=="number")&&(h.type="number"),m.every(g=>typeof g=="string")&&(h.type="string"),m.every(g=>typeof g=="boolean")&&(h.type="string"),m.every(g=>g===null)&&(h.type="null"),h.enum=m;break}case"file":{let h=f,m={type:"string",format:"binary",contentEncoding:"binary"},{minimum:g,maximum:y,mime:v}=t._zod.bag;g!==void 0&&(m.minLength=g),y!==void 0&&(m.maxLength=y),v?v.length===1?(m.contentMediaType=v[0],Object.assign(h,m)):h.anyOf=v.map(b=>({...m,contentMediaType:b})):Object.assign(h,m);break}case"transform":{if(this.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema");break}case"nullable":{let h=this.process(i.innerType,d);f.anyOf=[h,{type:"null"}];break}case"nonoptional":{this.process(i.innerType,d),a.ref=i.innerType;break}case"success":{let h=f;h.type="boolean";break}case"default":{this.process(i.innerType,d),a.ref=i.innerType,f.default=JSON.parse(JSON.stringify(i.defaultValue));break}case"prefault":{this.process(i.innerType,d),a.ref=i.innerType,this.io==="input"&&(f._prefault=JSON.parse(JSON.stringify(i.defaultValue)));break}case"catch":{this.process(i.innerType,d),a.ref=i.innerType;let h;try{h=i.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}f.default=h;break}case"nan":{if(this.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema");break}case"template_literal":{let h=f,m=t._zod.pattern;if(!m)throw new Error("Pattern not found in template literal");h.type="string",h.pattern=m.source;break}case"pipe":{let h=this.io==="input"?i.in._zod.def.type==="transform"?i.out:i.in:i.out;this.process(h,d),a.ref=h;break}case"readonly":{this.process(i.innerType,d),a.ref=i.innerType,f.readOnly=!0;break}case"promise":{this.process(i.innerType,d),a.ref=i.innerType;break}case"optional":{this.process(i.innerType,d),a.ref=i.innerType;break}case"lazy":{let h=t._zod.innerType;this.process(h,d),a.ref=h;break}case"custom":{if(this.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema");break}default:}}}let c=this.metadataRegistry.get(t);return c&&Object.assign(a.schema,c),this.io==="input"&&ot(t)&&(delete a.schema.examples,delete a.schema.default),this.io==="input"&&a.schema._prefault&&((n=a.schema).default??(n.default=a.schema._prefault)),delete a.schema._prefault,this.seen.get(t).schema}emit(t,r){let n={cycles:r?.cycles??"ref",reused:r?.reused??"inline",external:r?.external??void 0},i=this.seen.get(t);if(!i)throw new Error("Unprocessed schema. This is a bug in Zod.");let o=l=>{let d=this.target==="draft-2020-12"?"$defs":"definitions";if(n.external){let m=n.external.registry.get(l[0])?.id,g=n.external.uri??(v=>v);if(m)return{ref:g(m)};let y=l[1].defId??l[1].schema.id??`schema${this.counter++}`;return l[1].defId=y,{defId:y,ref:`${g("__shared")}#/${d}/${y}`}}if(l[1]===i)return{ref:"#"};let f=`#/${d}/`,h=l[1].schema.id??`__schema${this.counter++}`;return{defId:h,ref:f+h}},s=l=>{if(l[1].schema.$ref)return;let d=l[1],{ref:p,defId:f}=o(l);d.def={...d.schema},f&&(d.defId=f);let h=d.schema;for(let m in h)delete h[m];h.$ref=p};if(n.cycles==="throw")for(let l of this.seen.entries()){let d=l[1];if(d.cycle)throw new Error(`Cycle detected: #/${d.cycle?.join("/")}/<root>
451
451
 
452
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let l of this.seen.entries()){let d=l[1];if(t===l[0]){s(l);continue}if(n.external){let f=n.external.registry.get(l[0])?.id;if(t!==l[0]&&f){s(l);continue}}if(this.metadataRegistry.get(l[0])?.id){s(l);continue}if(d.cycle){s(l);continue}if(d.count>1&&n.reused==="ref"){s(l);continue}}let a=(l,d)=>{let p=this.seen.get(l),f=p.def??p.schema,h={...f};if(p.ref===null)return;let m=p.ref;if(p.ref=null,m){a(m,d);let g=this.seen.get(m).schema;g.$ref&&d.target==="draft-7"?(f.allOf=f.allOf??[],f.allOf.push(g)):(Object.assign(f,g),Object.assign(f,h))}p.isParent||this.override({zodSchema:l,jsonSchema:f,path:p.path??[]})};for(let l of[...this.seen.entries()].reverse())a(l[0],{target:this.target});let u={};if(this.target==="draft-2020-12"?u.$schema="https://json-schema.org/draft/2020-12/schema":this.target==="draft-7"?u.$schema="http://json-schema.org/draft-07/schema#":console.warn(`Invalid target: ${this.target}`),n.external?.uri){let l=n.external.registry.get(t)?.id;if(!l)throw new Error("Schema is missing an `id` property");u.$id=n.external.uri(l)}Object.assign(u,i.def);let c=n.external?.defs??{};for(let l of this.seen.entries()){let d=l[1];d.def&&d.defId&&(c[d.defId]=d.def)}n.external||Object.keys(c).length>0&&(this.target==="draft-2020-12"?u.$defs=c:u.definitions=c);try{return JSON.parse(JSON.stringify(u))}catch{throw new Error("Error converting schema to JSON.")}}};function Fm(e,t){if(e instanceof Zs){let n=new Bc(t),i={};for(let a of e._idmap.entries()){let[u,c]=a;n.process(c)}let o={},s={registry:e,uri:t?.uri,defs:i};for(let a of e._idmap.entries()){let[u,c]=a;o[u]=n.emit(c,{...t,external:s})}if(Object.keys(i).length>0){let a=n.target==="draft-2020-12"?"$defs":"definitions";o.__shared={[a]:i}}return{schemas:o}}let r=new Bc(t);return r.process(e),r.emit(e,t)}function ot(e,t){let r=t??{seen:new Set};if(r.seen.has(e))return!1;r.seen.add(e);let i=e._zod.def;switch(i.type){case"string":case"number":case"bigint":case"boolean":case"date":case"symbol":case"undefined":case"null":case"any":case"unknown":case"never":case"void":case"literal":case"enum":case"nan":case"file":case"template_literal":return!1;case"array":return ot(i.element,r);case"object":{for(let o in i.shape)if(ot(i.shape[o],r))return!0;return!1}case"union":{for(let o of i.options)if(ot(o,r))return!0;return!1}case"intersection":return ot(i.left,r)||ot(i.right,r);case"tuple":{for(let o of i.items)if(ot(o,r))return!0;return!!(i.rest&&ot(i.rest,r))}case"record":return ot(i.keyType,r)||ot(i.valueType,r);case"map":return ot(i.keyType,r)||ot(i.valueType,r);case"set":return ot(i.valueType,r);case"promise":case"optional":case"nonoptional":case"nullable":case"readonly":return ot(i.innerType,r);case"lazy":return ot(i.getter(),r);case"default":return ot(i.innerType,r);case"prefault":return ot(i.innerType,r);case"custom":return!1;case"transform":return!0;case"pipe":return ot(i.in,r)||ot(i.out,r);case"success":return!1;case"catch":return!1;default:}throw new Error(`Unknown schema type: ${i.type}`)}var Ls={};mu(Ls,{ZodISODate:()=>s0,ZodISODateTime:()=>o0,ZodISODuration:()=>c0,ZodISOTime:()=>a0,date:()=>Lm,datetime:()=>qm,duration:()=>Vm,time:()=>Um});var o0=x("ZodISODateTime",(e,t)=>{Bb.init(e,t),Ge.init(e,t)});function qm(e){return Yb(o0,e)}var s0=x("ZodISODate",(e,t)=>{Wb.init(e,t),Ge.init(e,t)});function Lm(e){return e0(s0,e)}var a0=x("ZodISOTime",(e,t)=>{Jb.init(e,t),Ge.init(e,t)});function Um(e){return t0(a0,e)}var c0=x("ZodISODuration",(e,t)=>{Hb.init(e,t),Ge.init(e,t)});function Vm(e){return r0(c0,e)}var l0=(e,t)=>{Rc.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:r=>rf(e,r)},flatten:{value:r=>tf(e,r)},addIssue:{value:r=>e.issues.push(r)},addIssues:{value:r=>e.issues.push(...r)},isEmpty:{get(){return e.issues.length===0}}})},jD=x("ZodError",l0),Us=x("ZodError",l0,{Parent:Error});var u0=nf(Us),d0=sf(Us),f0=cf(Us),m0=lf(Us);var Je=x("ZodType",(e,t)=>(Se.init(e,t),e.def=t,Object.defineProperty(e,"_def",{value:t}),e.check=(...r)=>e.clone({...t,checks:[...t.checks??[],...r.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),e.clone=(r,n)=>rr(e,r,n),e.brand=()=>e,e.register=((r,n)=>(r.add(e,n),e)),e.parse=(r,n)=>u0(e,r,n,{callee:e.parse}),e.safeParse=(r,n)=>f0(e,r,n),e.parseAsync=async(r,n)=>d0(e,r,n,{callee:e.parseAsync}),e.safeParseAsync=async(r,n)=>m0(e,r,n),e.spa=e.safeParseAsync,e.refine=(r,n)=>e.check(SO(r,n)),e.superRefine=r=>e.check(TO(r)),e.overwrite=r=>e.check(Gi(r)),e.optional=()=>Fe(e),e.nullable=()=>g0(e),e.nullish=()=>Fe(g0(e)),e.nonoptional=r=>_O(e,r),e.array=()=>ue(e),e.or=r=>Re([e,r]),e.and=r=>Jc(e,r),e.transform=r=>Wm(e,k0(r)),e.default=r=>pO(e,r),e.prefault=r=>gO(e,r),e.catch=r=>vO(e,r),e.pipe=r=>Wm(e,r),e.readonly=()=>kO(e),e.describe=r=>{let n=e.clone();return Zn.add(n,{description:r}),n},Object.defineProperty(e,"description",{get(){return Zn.get(e)?.description},configurable:!0}),e.meta=(...r)=>{if(r.length===0)return Zn.get(e);let n=e.clone();return Zn.add(n,r[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e)),_0=x("_ZodString",(e,t)=>{Gs.init(e,t),Je.init(e,t);let r=e._zod.bag;e.format=r.format??null,e.minLength=r.minimum??null,e.maxLength=r.maximum??null,e.regex=(...n)=>e.check(Am(...n)),e.includes=(...n)=>e.check(Cm(...n)),e.startsWith=(...n)=>e.check(Rm(...n)),e.endsWith=(...n)=>e.check(Im(...n)),e.min=(...n)=>e.check(Po(...n)),e.max=(...n)=>e.check(Uc(...n)),e.length=(...n)=>e.check(Vc(...n)),e.nonempty=(...n)=>e.check(Po(1,...n)),e.lowercase=n=>e.check(Om(n)),e.uppercase=n=>e.check(Pm(n)),e.trim=()=>e.check(Nm()),e.normalize=(...n)=>e.check(jm(...n)),e.toLowerCase=()=>e.check(Mm()),e.toUpperCase=()=>e.check(Dm())}),NA=x("ZodString",(e,t)=>{Gs.init(e,t),_0.init(e,t),e.email=r=>e.check(rm(MA,r)),e.url=r=>e.check(am(DA,r)),e.jwt=r=>e.check(km(YA,r)),e.emoji=r=>e.check(cm(GA,r)),e.guid=r=>e.check(Zc(p0,r)),e.uuid=r=>e.check(nm(Wc,r)),e.uuidv4=r=>e.check(im(Wc,r)),e.uuidv6=r=>e.check(om(Wc,r)),e.uuidv7=r=>e.check(sm(Wc,r)),e.nanoid=r=>e.check(lm(ZA,r)),e.guid=r=>e.check(Zc(p0,r)),e.cuid=r=>e.check(um(FA,r)),e.cuid2=r=>e.check(dm(qA,r)),e.ulid=r=>e.check(fm(LA,r)),e.base64=r=>e.check(vm(KA,r)),e.base64url=r=>e.check(bm(QA,r)),e.xid=r=>e.check(mm(UA,r)),e.ksuid=r=>e.check(pm(VA,r)),e.ipv4=r=>e.check(hm(BA,r)),e.ipv6=r=>e.check(gm(WA,r)),e.cidrv4=r=>e.check(_m(JA,r)),e.cidrv6=r=>e.check(ym(HA,r)),e.e164=r=>e.check(wm(XA,r)),e.datetime=r=>e.check(qm(r)),e.date=r=>e.check(Lm(r)),e.time=r=>e.check(Um(r)),e.duration=r=>e.check(Vm(r))});function k(e){return tm(NA,e)}var Ge=x("ZodStringFormat",(e,t)=>{Ae.init(e,t),_0.init(e,t)}),MA=x("ZodEmail",(e,t)=>{_f.init(e,t),Ge.init(e,t)});var p0=x("ZodGUID",(e,t)=>{hf.init(e,t),Ge.init(e,t)});var Wc=x("ZodUUID",(e,t)=>{gf.init(e,t),Ge.init(e,t)});var DA=x("ZodURL",(e,t)=>{yf.init(e,t),Ge.init(e,t)});var GA=x("ZodEmoji",(e,t)=>{vf.init(e,t),Ge.init(e,t)});var ZA=x("ZodNanoID",(e,t)=>{bf.init(e,t),Ge.init(e,t)});var FA=x("ZodCUID",(e,t)=>{wf.init(e,t),Ge.init(e,t)});var qA=x("ZodCUID2",(e,t)=>{kf.init(e,t),Ge.init(e,t)});var LA=x("ZodULID",(e,t)=>{xf.init(e,t),Ge.init(e,t)});var UA=x("ZodXID",(e,t)=>{Sf.init(e,t),Ge.init(e,t)});var VA=x("ZodKSUID",(e,t)=>{Tf.init(e,t),Ge.init(e,t)});var BA=x("ZodIPv4",(e,t)=>{$f.init(e,t),Ge.init(e,t)});var WA=x("ZodIPv6",(e,t)=>{Ef.init(e,t),Ge.init(e,t)});var JA=x("ZodCIDRv4",(e,t)=>{zf.init(e,t),Ge.init(e,t)});var HA=x("ZodCIDRv6",(e,t)=>{Af.init(e,t),Ge.init(e,t)});var KA=x("ZodBase64",(e,t)=>{Of.init(e,t),Ge.init(e,t)});var QA=x("ZodBase64URL",(e,t)=>{Pf.init(e,t),Ge.init(e,t)});var XA=x("ZodE164",(e,t)=>{Cf.init(e,t),Ge.init(e,t)});var YA=x("ZodJWT",(e,t)=>{Rf.init(e,t),Ge.init(e,t)});var y0=x("ZodNumber",(e,t)=>{Mc.init(e,t),Je.init(e,t),e.gt=(n,i)=>e.check(qc(n,i)),e.gte=(n,i)=>e.check(qs(n,i)),e.min=(n,i)=>e.check(qs(n,i)),e.lt=(n,i)=>e.check(Fc(n,i)),e.lte=(n,i)=>e.check(Fs(n,i)),e.max=(n,i)=>e.check(Fs(n,i)),e.int=n=>e.check(h0(n)),e.safe=n=>e.check(h0(n)),e.positive=n=>e.check(qc(0,n)),e.nonnegative=n=>e.check(qs(0,n)),e.negative=n=>e.check(Fc(0,n)),e.nonpositive=n=>e.check(Fs(0,n)),e.multipleOf=(n,i)=>e.check(Lc(n,i)),e.step=(n,i)=>e.check(Lc(n,i)),e.finite=()=>e;let r=e._zod.bag;e.minValue=Math.max(r.minimum??Number.NEGATIVE_INFINITY,r.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(r.maximum??Number.POSITIVE_INFINITY,r.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(r.format??"").includes("int")||Number.isSafeInteger(r.multipleOf??.5),e.isFinite=!0,e.format=r.format??null});function ke(e){return xm(y0,e)}var eO=x("ZodNumberFormat",(e,t)=>{If.init(e,t),y0.init(e,t)});function h0(e){return Sm(eO,e)}var tO=x("ZodBoolean",(e,t)=>{jf.init(e,t),Je.init(e,t)});function dt(e){return Tm(tO,e)}var rO=x("ZodNull",(e,t)=>{Nf.init(e,t),Je.init(e,t)});function v0(e){return $m(rO,e)}var nO=x("ZodUnknown",(e,t)=>{Mf.init(e,t),Je.init(e,t)});function Ze(){return Em(nO)}var iO=x("ZodNever",(e,t)=>{Df.init(e,t),Je.init(e,t)});function oO(e){return zm(iO,e)}var sO=x("ZodArray",(e,t)=>{Gf.init(e,t),Je.init(e,t),e.element=t.element,e.min=(r,n)=>e.check(Po(r,n)),e.nonempty=r=>e.check(Po(1,r)),e.max=(r,n)=>e.check(Uc(r,n)),e.length=(r,n)=>e.check(Vc(r,n)),e.unwrap=()=>e.element});function ue(e,t){return n0(sO,e,t)}var b0=x("ZodObject",(e,t)=>{Dc.init(e,t),Je.init(e,t),ce.defineLazy(e,"shape",()=>t.shape),e.keyof=()=>Vt(Object.keys(e._zod.def.shape)),e.catchall=r=>e.clone({...e._zod.def,catchall:r}),e.passthrough=()=>e.clone({...e._zod.def,catchall:Ze()}),e.loose=()=>e.clone({...e._zod.def,catchall:Ze()}),e.strict=()=>e.clone({...e._zod.def,catchall:oO()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=r=>ce.extend(e,r),e.merge=r=>ce.merge(e,r),e.pick=r=>ce.pick(e,r),e.omit=r=>ce.omit(e,r),e.partial=(...r)=>ce.partial(x0,e,r[0]),e.required=(...r)=>ce.required(S0,e,r[0])});function C(e,t){let r={type:"object",get shape(){return ce.assignProp(this,"shape",{...e}),this.shape},...ce.normalizeParams(t)};return new b0(r)}function It(e,t){return new b0({type:"object",get shape(){return ce.assignProp(this,"shape",{...e}),this.shape},catchall:Ze(),...ce.normalizeParams(t)})}var w0=x("ZodUnion",(e,t)=>{Gc.init(e,t),Je.init(e,t),e.options=t.options});function Re(e,t){return new w0({type:"union",options:e,...ce.normalizeParams(t)})}var aO=x("ZodDiscriminatedUnion",(e,t)=>{w0.init(e,t),Zf.init(e,t)});function Jm(e,t,r){return new aO({type:"union",options:t,discriminator:e,...ce.normalizeParams(r)})}var cO=x("ZodIntersection",(e,t)=>{Ff.init(e,t),Je.init(e,t)});function Jc(e,t){return new cO({type:"intersection",left:e,right:t})}var lO=x("ZodRecord",(e,t)=>{qf.init(e,t),Je.init(e,t),e.keyType=t.keyType,e.valueType=t.valueType});function Oe(e,t,r){return new lO({type:"record",keyType:e,valueType:t,...ce.normalizeParams(r)})}var Bm=x("ZodEnum",(e,t)=>{Lf.init(e,t),Je.init(e,t),e.enum=t.entries,e.options=Object.values(t.entries);let r=new Set(Object.keys(t.entries));e.extract=(n,i)=>{let o={};for(let s of n)if(r.has(s))o[s]=t.entries[s];else throw new Error(`Key ${s} not found in enum`);return new Bm({...t,checks:[],...ce.normalizeParams(i),entries:o})},e.exclude=(n,i)=>{let o={...t.entries};for(let s of n)if(r.has(s))delete o[s];else throw new Error(`Key ${s} not found in enum`);return new Bm({...t,checks:[],...ce.normalizeParams(i),entries:o})}});function Vt(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map(n=>[n,n])):e;return new Bm({type:"enum",entries:r,...ce.normalizeParams(t)})}var uO=x("ZodLiteral",(e,t)=>{Uf.init(e,t),Je.init(e,t),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function q(e,t){return new uO({type:"literal",values:Array.isArray(e)?e:[e],...ce.normalizeParams(t)})}var dO=x("ZodTransform",(e,t)=>{Vf.init(e,t),Je.init(e,t),e._zod.parse=(r,n)=>{r.addIssue=o=>{if(typeof o=="string")r.issues.push(ce.issue(o,r.value,t));else{let s=o;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),s.input??(s.input=r.value),s.inst??(s.inst=e),s.continue??(s.continue=!0),r.issues.push(ce.issue(s))}};let i=t.transform(r.value,r);return i instanceof Promise?i.then(o=>(r.value=o,r)):(r.value=i,r)}});function k0(e){return new dO({type:"transform",transform:e})}var x0=x("ZodOptional",(e,t)=>{Bf.init(e,t),Je.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Fe(e){return new x0({type:"optional",innerType:e})}var fO=x("ZodNullable",(e,t)=>{Wf.init(e,t),Je.init(e,t),e.unwrap=()=>e._zod.def.innerType});function g0(e){return new fO({type:"nullable",innerType:e})}var mO=x("ZodDefault",(e,t)=>{Jf.init(e,t),Je.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function pO(e,t){return new mO({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():t}})}var hO=x("ZodPrefault",(e,t)=>{Hf.init(e,t),Je.init(e,t),e.unwrap=()=>e._zod.def.innerType});function gO(e,t){return new hO({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():t}})}var S0=x("ZodNonOptional",(e,t)=>{Kf.init(e,t),Je.init(e,t),e.unwrap=()=>e._zod.def.innerType});function _O(e,t){return new S0({type:"nonoptional",innerType:e,...ce.normalizeParams(t)})}var yO=x("ZodCatch",(e,t)=>{Qf.init(e,t),Je.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function vO(e,t){return new yO({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}var bO=x("ZodPipe",(e,t)=>{Xf.init(e,t),Je.init(e,t),e.in=t.in,e.out=t.out});function Wm(e,t){return new bO({type:"pipe",in:e,out:t})}var wO=x("ZodReadonly",(e,t)=>{Yf.init(e,t),Je.init(e,t)});function kO(e){return new wO({type:"readonly",innerType:e})}var T0=x("ZodCustom",(e,t)=>{em.init(e,t),Je.init(e,t)});function xO(e){let t=new yt({check:"custom"});return t._zod.check=e,t}function $0(e,t){return Gm(T0,e??(()=>!0),t)}function SO(e,t={}){return Zm(T0,e,t)}function TO(e){let t=xO(r=>(r.addIssue=n=>{if(typeof n=="string")r.issues.push(ce.issue(n,r.value,t._zod.def));else{let i=n;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=r.value),i.inst??(i.inst=t),i.continue??(i.continue=!t._zod.def.abort),r.issues.push(ce.issue(i))}},e(r.value,r)));return t}function Hm(e,t){return Wm(k0(e),t)}tr(Qb());var Qm="2025-11-25";var E0=[Qm,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],Fn="io.modelcontextprotocol/related-task",Kc="2.0",st=$0(e=>e!==null&&(typeof e=="object"||typeof e=="function")),z0=Re([k(),ke().int()]),A0=k(),HD=It({ttl:ke().optional(),pollInterval:ke().optional()}),$O=C({ttl:ke().optional()}),EO=C({taskId:k()}),Xm=It({progressToken:z0.optional(),[Fn]:EO.optional()}),nr=C({_meta:Xm.optional()}),Vs=nr.extend({task:$O.optional()}),O0=e=>Vs.safeParse(e).success,vt=C({method:k(),params:nr.loose().optional()}),fr=C({_meta:Xm.optional()}),mr=C({method:k(),params:fr.loose().optional()}),bt=It({_meta:Xm.optional()}),Qc=Re([k(),ke().int()]),P0=C({jsonrpc:q(Kc),id:Qc,...vt.shape}).strict(),Ym=e=>P0.safeParse(e).success,C0=C({jsonrpc:q(Kc),...mr.shape}).strict(),R0=e=>C0.safeParse(e).success,ep=C({jsonrpc:q(Kc),id:Qc,result:bt}).strict(),Bs=e=>ep.safeParse(e).success;var U;(function(e){e[e.ConnectionClosed=-32e3]="ConnectionClosed",e[e.RequestTimeout=-32001]="RequestTimeout",e[e.ParseError=-32700]="ParseError",e[e.InvalidRequest=-32600]="InvalidRequest",e[e.MethodNotFound=-32601]="MethodNotFound",e[e.InvalidParams=-32602]="InvalidParams",e[e.InternalError=-32603]="InternalError",e[e.UrlElicitationRequired=-32042]="UrlElicitationRequired"})(U||(U={}));var tp=C({jsonrpc:q(Kc),id:Qc.optional(),error:C({code:ke().int(),message:k(),data:Ze().optional()})}).strict();var I0=e=>tp.safeParse(e).success;var j0=Re([P0,C0,ep,tp]),KD=Re([ep,tp]),Xc=bt.strict(),zO=fr.extend({requestId:Qc.optional(),reason:k().optional()}),Yc=mr.extend({method:q("notifications/cancelled"),params:zO}),AO=C({src:k(),mimeType:k().optional(),sizes:ue(k()).optional(),theme:Vt(["light","dark"]).optional()}),Ws=C({icons:ue(AO).optional()}),Co=C({name:k(),title:k().optional()}),N0=Co.extend({...Co.shape,...Ws.shape,version:k(),websiteUrl:k().optional(),description:k().optional()}),OO=Jc(C({applyDefaults:dt().optional()}),Oe(k(),Ze())),PO=Hm(e=>e&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,Jc(C({form:OO.optional(),url:st.optional()}),Oe(k(),Ze()).optional())),CO=It({list:st.optional(),cancel:st.optional(),requests:It({sampling:It({createMessage:st.optional()}).optional(),elicitation:It({create:st.optional()}).optional()}).optional()}),RO=It({list:st.optional(),cancel:st.optional(),requests:It({tools:It({call:st.optional()}).optional()}).optional()}),IO=C({experimental:Oe(k(),st).optional(),sampling:C({context:st.optional(),tools:st.optional()}).optional(),elicitation:PO.optional(),roots:C({listChanged:dt().optional()}).optional(),tasks:CO.optional(),extensions:Oe(k(),st).optional()}),jO=nr.extend({protocolVersion:k(),capabilities:IO,clientInfo:N0}),rp=vt.extend({method:q("initialize"),params:jO});var NO=C({experimental:Oe(k(),st).optional(),logging:st.optional(),completions:st.optional(),prompts:C({listChanged:dt().optional()}).optional(),resources:C({subscribe:dt().optional(),listChanged:dt().optional()}).optional(),tools:C({listChanged:dt().optional()}).optional(),tasks:RO.optional(),extensions:Oe(k(),st).optional()}),MO=bt.extend({protocolVersion:k(),capabilities:NO,serverInfo:N0,instructions:k().optional()}),np=mr.extend({method:q("notifications/initialized"),params:fr.optional()});var el=vt.extend({method:q("ping"),params:nr.optional()}),DO=C({progress:ke(),total:Fe(ke()),message:Fe(k())}),GO=C({...fr.shape,...DO.shape,progressToken:z0}),tl=mr.extend({method:q("notifications/progress"),params:GO}),ZO=nr.extend({cursor:A0.optional()}),Js=vt.extend({params:ZO.optional()}),Hs=bt.extend({nextCursor:A0.optional()}),FO=Vt(["working","input_required","completed","failed","cancelled"]),Ks=C({taskId:k(),status:FO,ttl:Re([ke(),v0()]),createdAt:k(),lastUpdatedAt:k(),pollInterval:Fe(ke()),statusMessage:Fe(k())}),Ro=bt.extend({task:Ks}),qO=fr.merge(Ks),Qs=mr.extend({method:q("notifications/tasks/status"),params:qO}),rl=vt.extend({method:q("tasks/get"),params:nr.extend({taskId:k()})}),nl=bt.merge(Ks),il=vt.extend({method:q("tasks/result"),params:nr.extend({taskId:k()})}),QD=bt.loose(),ol=Js.extend({method:q("tasks/list")}),sl=Hs.extend({tasks:ue(Ks)}),al=vt.extend({method:q("tasks/cancel"),params:nr.extend({taskId:k()})}),M0=bt.merge(Ks),D0=C({uri:k(),mimeType:Fe(k()),_meta:Oe(k(),Ze()).optional()}),G0=D0.extend({text:k()}),ip=k().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),Z0=D0.extend({blob:ip}),Xs=Vt(["user","assistant"]),Io=C({audience:ue(Xs).optional(),priority:ke().min(0).max(1).optional(),lastModified:Ls.datetime({offset:!0}).optional()}),F0=C({...Co.shape,...Ws.shape,uri:k(),description:Fe(k()),mimeType:Fe(k()),size:Fe(ke()),annotations:Io.optional(),_meta:Fe(It({}))}),LO=C({...Co.shape,...Ws.shape,uriTemplate:k(),description:Fe(k()),mimeType:Fe(k()),annotations:Io.optional(),_meta:Fe(It({}))}),jo=Js.extend({method:q("resources/list")}),UO=Hs.extend({resources:ue(F0)}),No=Js.extend({method:q("resources/templates/list")}),VO=Hs.extend({resourceTemplates:ue(LO)}),op=nr.extend({uri:k()}),BO=op,cl=vt.extend({method:q("resources/read"),params:BO}),WO=bt.extend({contents:ue(Re([G0,Z0]))}),JO=mr.extend({method:q("notifications/resources/list_changed"),params:fr.optional()}),HO=op,KO=vt.extend({method:q("resources/subscribe"),params:HO}),QO=op,XO=vt.extend({method:q("resources/unsubscribe"),params:QO}),YO=fr.extend({uri:k()}),eP=mr.extend({method:q("notifications/resources/updated"),params:YO}),tP=C({name:k(),description:Fe(k()),required:Fe(dt())}),rP=C({...Co.shape,...Ws.shape,description:Fe(k()),arguments:Fe(ue(tP)),_meta:Fe(It({}))}),ll=Js.extend({method:q("prompts/list")}),nP=Hs.extend({prompts:ue(rP)}),iP=nr.extend({name:k(),arguments:Oe(k(),k()).optional()}),ul=vt.extend({method:q("prompts/get"),params:iP}),sp=C({type:q("text"),text:k(),annotations:Io.optional(),_meta:Oe(k(),Ze()).optional()}),ap=C({type:q("image"),data:ip,mimeType:k(),annotations:Io.optional(),_meta:Oe(k(),Ze()).optional()}),cp=C({type:q("audio"),data:ip,mimeType:k(),annotations:Io.optional(),_meta:Oe(k(),Ze()).optional()}),oP=C({type:q("tool_use"),name:k(),id:k(),input:Oe(k(),Ze()),_meta:Oe(k(),Ze()).optional()}),sP=C({type:q("resource"),resource:Re([G0,Z0]),annotations:Io.optional(),_meta:Oe(k(),Ze()).optional()}),aP=F0.extend({type:q("resource_link")}),lp=Re([sp,ap,cp,aP,sP]),cP=C({role:Xs,content:lp}),lP=bt.extend({description:k().optional(),messages:ue(cP)}),uP=mr.extend({method:q("notifications/prompts/list_changed"),params:fr.optional()}),dP=C({title:k().optional(),readOnlyHint:dt().optional(),destructiveHint:dt().optional(),idempotentHint:dt().optional(),openWorldHint:dt().optional()}),fP=C({taskSupport:Vt(["required","optional","forbidden"]).optional()}),q0=C({...Co.shape,...Ws.shape,description:k().optional(),inputSchema:C({type:q("object"),properties:Oe(k(),st).optional(),required:ue(k()).optional()}).catchall(Ze()),outputSchema:C({type:q("object"),properties:Oe(k(),st).optional(),required:ue(k()).optional()}).catchall(Ze()).optional(),annotations:dP.optional(),execution:fP.optional(),_meta:Oe(k(),Ze()).optional()}),dl=Js.extend({method:q("tools/list")}),mP=Hs.extend({tools:ue(q0)}),fl=bt.extend({content:ue(lp).default([]),structuredContent:Oe(k(),Ze()).optional(),isError:dt().optional()}),XD=fl.or(bt.extend({toolResult:Ze()})),pP=Vs.extend({name:k(),arguments:Oe(k(),Ze()).optional()}),Mo=vt.extend({method:q("tools/call"),params:pP}),hP=mr.extend({method:q("notifications/tools/list_changed"),params:fr.optional()}),YD=C({autoRefresh:dt().default(!0),debounceMs:ke().int().nonnegative().default(300)}),Ys=Vt(["debug","info","notice","warning","error","critical","alert","emergency"]),gP=nr.extend({level:Ys}),up=vt.extend({method:q("logging/setLevel"),params:gP}),_P=fr.extend({level:Ys,logger:k().optional(),data:Ze()}),yP=mr.extend({method:q("notifications/message"),params:_P}),vP=C({name:k().optional()}),bP=C({hints:ue(vP).optional(),costPriority:ke().min(0).max(1).optional(),speedPriority:ke().min(0).max(1).optional(),intelligencePriority:ke().min(0).max(1).optional()}),wP=C({mode:Vt(["auto","required","none"]).optional()}),kP=C({type:q("tool_result"),toolUseId:k().describe("The unique identifier for the corresponding tool call."),content:ue(lp).default([]),structuredContent:C({}).loose().optional(),isError:dt().optional(),_meta:Oe(k(),Ze()).optional()}),xP=Jm("type",[sp,ap,cp]),Hc=Jm("type",[sp,ap,cp,oP,kP]),SP=C({role:Xs,content:Re([Hc,ue(Hc)]),_meta:Oe(k(),Ze()).optional()}),TP=Vs.extend({messages:ue(SP),modelPreferences:bP.optional(),systemPrompt:k().optional(),includeContext:Vt(["none","thisServer","allServers"]).optional(),temperature:ke().optional(),maxTokens:ke().int(),stopSequences:ue(k()).optional(),metadata:st.optional(),tools:ue(q0).optional(),toolChoice:wP.optional()}),$P=vt.extend({method:q("sampling/createMessage"),params:TP}),ea=bt.extend({model:k(),stopReason:Fe(Vt(["endTurn","stopSequence","maxTokens"]).or(k())),role:Xs,content:xP}),dp=bt.extend({model:k(),stopReason:Fe(Vt(["endTurn","stopSequence","maxTokens","toolUse"]).or(k())),role:Xs,content:Re([Hc,ue(Hc)])}),EP=C({type:q("boolean"),title:k().optional(),description:k().optional(),default:dt().optional()}),zP=C({type:q("string"),title:k().optional(),description:k().optional(),minLength:ke().optional(),maxLength:ke().optional(),format:Vt(["email","uri","date","date-time"]).optional(),default:k().optional()}),AP=C({type:Vt(["number","integer"]),title:k().optional(),description:k().optional(),minimum:ke().optional(),maximum:ke().optional(),default:ke().optional()}),OP=C({type:q("string"),title:k().optional(),description:k().optional(),enum:ue(k()),default:k().optional()}),PP=C({type:q("string"),title:k().optional(),description:k().optional(),oneOf:ue(C({const:k(),title:k()})),default:k().optional()}),CP=C({type:q("string"),title:k().optional(),description:k().optional(),enum:ue(k()),enumNames:ue(k()).optional(),default:k().optional()}),RP=Re([OP,PP]),IP=C({type:q("array"),title:k().optional(),description:k().optional(),minItems:ke().optional(),maxItems:ke().optional(),items:C({type:q("string"),enum:ue(k())}),default:ue(k()).optional()}),jP=C({type:q("array"),title:k().optional(),description:k().optional(),minItems:ke().optional(),maxItems:ke().optional(),items:C({anyOf:ue(C({const:k(),title:k()}))}),default:ue(k()).optional()}),NP=Re([IP,jP]),MP=Re([CP,RP,NP]),DP=Re([MP,EP,zP,AP]),GP=Vs.extend({mode:q("form").optional(),message:k(),requestedSchema:C({type:q("object"),properties:Oe(k(),DP),required:ue(k()).optional()})}),ZP=Vs.extend({mode:q("url"),message:k(),elicitationId:k(),url:k().url()}),FP=Re([GP,ZP]),qP=vt.extend({method:q("elicitation/create"),params:FP}),LP=fr.extend({elicitationId:k()}),UP=mr.extend({method:q("notifications/elicitation/complete"),params:LP}),Do=bt.extend({action:Vt(["accept","decline","cancel"]),content:Hm(e=>e===null?void 0:e,Oe(k(),Re([k(),ke(),dt(),ue(k())])).optional())}),VP=C({type:q("ref/resource"),uri:k()});var BP=C({type:q("ref/prompt"),name:k()}),WP=nr.extend({ref:Re([BP,VP]),argument:C({name:k(),value:k()}),context:C({arguments:Oe(k(),k()).optional()}).optional()}),ml=vt.extend({method:q("completion/complete"),params:WP});function L0(e){if(e.params.ref.type!=="ref/prompt")throw new TypeError(`Expected CompleteRequestPrompt, but got ${e.params.ref.type}`)}function U0(e){if(e.params.ref.type!=="ref/resource")throw new TypeError(`Expected CompleteRequestResourceTemplate, but got ${e.params.ref.type}`)}var JP=bt.extend({completion:It({values:ue(k()).max(100),total:Fe(ke().int()),hasMore:Fe(dt())})}),HP=C({uri:k().startsWith("file://"),name:k().optional(),_meta:Oe(k(),Ze()).optional()}),KP=vt.extend({method:q("roots/list"),params:nr.optional()}),fp=bt.extend({roots:ue(HP)}),QP=mr.extend({method:q("notifications/roots/list_changed"),params:fr.optional()}),eG=Re([el,rp,ml,up,ul,ll,jo,No,cl,KO,XO,Mo,dl,rl,il,ol,al]),tG=Re([Yc,tl,np,QP,Qs]),rG=Re([Xc,ea,dp,Do,fp,nl,sl,Ro]),nG=Re([el,$P,qP,KP,rl,il,ol,al]),iG=Re([Yc,tl,yP,eP,JO,hP,uP,Qs,UP]),oG=Re([Xc,MO,JP,lP,nP,UO,VO,WO,fl,mP,nl,sl,Ro]),F=class e extends Error{constructor(t,r,n){super(`MCP error ${t}: ${r}`),this.code=t,this.data=n,this.name="McpError"}static fromError(t,r,n){if(t===U.UrlElicitationRequired&&n){let i=n;if(i.elicitations)return new Km(i.elicitations,r)}return new e(t,r,n)}},Km=class extends F{constructor(t,r=`URL elicitation${t.length>1?"s":""} required`){super(U.UrlElicitationRequired,r,{elicitations:t})}get elicitations(){return this.data?.elicitations??[]}};var eC=x("ZodMiniType",(e,t)=>{if(!e._zod)throw new Error("Uninitialized schema in ZodMiniType.");Se.init(e,t),e.def=t,e.parse=(r,n)=>of(e,r,n,{callee:e.parse}),e.safeParse=(r,n)=>Mi(e,r,n),e.parseAsync=async(r,n)=>af(e,r,n,{callee:e.parseAsync}),e.safeParseAsync=async(r,n)=>Di(e,r,n),e.check=(...r)=>e.clone({...t,checks:[...t.checks??[],...r.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),e.clone=(r,n)=>rr(e,r,n),e.brand=()=>e,e.register=((r,n)=>(r.add(e,n),e))});var tC=x("ZodMiniObject",(e,t)=>{Dc.init(e,t),eC.init(e,t),ce.defineLazy(e,"shape",()=>t.shape)});function mp(e,t){let r={type:"object",get shape(){return ce.assignProp(this,"shape",{...e}),this.shape},...ce.normalizeParams(t)};return new tC(r)}function pr(e){return!!e._zod}function Fi(e){let t=Object.values(e);if(t.length===0)return mp({});let r=t.every(pr),n=t.every(i=>!pr(i));if(r)return mp(e);if(n)return bd(e);throw new Error("Mixed Zod versions detected in object shape.")}function qn(e,t){return pr(e)?Mi(e,t):e.safeParse(t)}async function pl(e,t){return pr(e)?await Di(e,t):await e.safeParseAsync(t)}function Ln(e){if(!e)return;let t;if(pr(e)?t=e._zod?.def?.shape:t=e.shape,!!t){if(typeof t=="function")try{return t()}catch{return}return t}}function Go(e){if(e){if(typeof e=="object"){let t=e,r=e;if(!t._def&&!r._zod){let n=Object.values(e);if(n.length>0&&n.every(i=>typeof i=="object"&&i!==null&&(i._def!==void 0||i._zod!==void 0||typeof i.parse=="function")))return Fi(e)}}if(pr(e)){let r=e._zod?.def;if(r&&(r.type==="object"||r.shape!==void 0))return e}else if(e.shape!==void 0)return e}}function hl(e){if(e&&typeof e=="object"){if("message"in e&&typeof e.message=="string")return e.message;if("issues"in e&&Array.isArray(e.issues)&&e.issues.length>0){let t=e.issues[0];if(t&&typeof t=="object"&&"message"in t)return String(t.message)}try{return JSON.stringify(e)}catch{return String(e)}}return String(e)}function V0(e){return e.description}function B0(e){if(pr(e))return e._zod?.def?.type==="optional";let t=e;return typeof e.isOptional=="function"?e.isOptional():t._def?.typeName==="ZodOptional"}function gl(e){if(pr(e)){let o=e._zod?.def;if(o){if(o.value!==void 0)return o.value;if(Array.isArray(o.values)&&o.values.length>0)return o.values[0]}}let r=e._def;if(r){if(r.value!==void 0)return r.value;if(Array.isArray(r.values)&&r.values.length>0)return r.values[0]}let n=e.value;if(n!==void 0)return n}function Un(e){return e==="completed"||e==="failed"||e==="cancelled"}var J0=Symbol("Let zodToJsonSchema decide on which parser to use");var W0={name:void 0,$refStrategy:"root",basePath:["#"],effectStrategy:"input",pipeStrategy:"all",dateStrategy:"format:date-time",mapStrategy:"entries",removeAdditionalStrategy:"passthrough",allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:"definitions",target:"jsonSchema7",strictUnions:!1,definitions:{},errorMessages:!1,markdownDescription:!1,patternStrategy:"escape",applyRegexFlags:!1,emailStrategy:"format:email",base64Strategy:"contentEncoding:base64",nameStrategy:"ref",openAiAnyTypeName:"OpenAiAnyType"},H0=e=>typeof e=="string"?{...W0,name:e}:{...W0,...e};var K0=e=>{let t=H0(e),r=t.name!==void 0?[...t.basePath,t.definitionPath,t.name]:t.basePath;return{...t,flags:{hasReferencedOpenAiAnyType:!1},currentPath:r,propertyPath:void 0,seen:new Map(Object.entries(t.definitions).map(([n,i])=>[i._def,{def:i._def,path:[...t.basePath,t.definitionPath,n],jsonSchema:void 0}]))}};function pp(e,t,r,n){n?.errorMessages&&r&&(e.errorMessage={...e.errorMessage,[t]:r})}function de(e,t,r,n,i){e[t]=r,pp(e,t,n,i)}var _l=(e,t)=>{let r=0;for(;r<e.length&&r<t.length&&e[r]===t[r];r++);return[(e.length-r).toString(),...t.slice(r)].join("/")};function qe(e){if(e.target!=="openAi")return{};let t=[...e.basePath,e.definitionPath,e.openAiAnyTypeName];return e.flags.hasReferencedOpenAiAnyType=!0,{$ref:e.$refStrategy==="relative"?_l(t,e.currentPath):t.join("/")}}function Q0(e,t){let r={type:"array"};return e.type?._def&&e.type?._def?.typeName!==E.ZodAny&&(r.items=H(e.type._def,{...t,currentPath:[...t.currentPath,"items"]})),e.minLength&&de(r,"minItems",e.minLength.value,e.minLength.message,t),e.maxLength&&de(r,"maxItems",e.maxLength.value,e.maxLength.message,t),e.exactLength&&(de(r,"minItems",e.exactLength.value,e.exactLength.message,t),de(r,"maxItems",e.exactLength.value,e.exactLength.message,t)),r}function X0(e,t){let r={type:"integer",format:"int64"};if(!e.checks)return r;for(let n of e.checks)switch(n.kind){case"min":t.target==="jsonSchema7"?n.inclusive?de(r,"minimum",n.value,n.message,t):de(r,"exclusiveMinimum",n.value,n.message,t):(n.inclusive||(r.exclusiveMinimum=!0),de(r,"minimum",n.value,n.message,t));break;case"max":t.target==="jsonSchema7"?n.inclusive?de(r,"maximum",n.value,n.message,t):de(r,"exclusiveMaximum",n.value,n.message,t):(n.inclusive||(r.exclusiveMaximum=!0),de(r,"maximum",n.value,n.message,t));break;case"multipleOf":de(r,"multipleOf",n.value,n.message,t);break}return r}function Y0(){return{type:"boolean"}}function yl(e,t){return H(e.type._def,t)}var ew=(e,t)=>H(e.innerType._def,t);function hp(e,t,r){let n=r??t.dateStrategy;if(Array.isArray(n))return{anyOf:n.map((i,o)=>hp(e,t,i))};switch(n){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return nC(e,t)}}var nC=(e,t)=>{let r={type:"integer",format:"unix-time"};if(t.target==="openApi3")return r;for(let n of e.checks)switch(n.kind){case"min":de(r,"minimum",n.value,n.message,t);break;case"max":de(r,"maximum",n.value,n.message,t);break}return r};function tw(e,t){return{...H(e.innerType._def,t),default:e.defaultValue()}}function rw(e,t){return t.effectStrategy==="input"?H(e.schema._def,t):qe(t)}function nw(e){return{type:"string",enum:Array.from(e.values)}}var iC=e=>"type"in e&&e.type==="string"?!1:"allOf"in e;function iw(e,t){let r=[H(e.left._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),H(e.right._def,{...t,currentPath:[...t.currentPath,"allOf","1"]})].filter(o=>!!o),n=t.target==="jsonSchema2019-09"?{unevaluatedProperties:!1}:void 0,i=[];return r.forEach(o=>{if(iC(o))i.push(...o.allOf),o.unevaluatedProperties===void 0&&(n=void 0);else{let s=o;if("additionalProperties"in o&&o.additionalProperties===!1){let{additionalProperties:a,...u}=o;s=u}else n=void 0;i.push(s)}}),i.length?{allOf:i,...n}:void 0}function ow(e,t){let r=typeof e.value;return r!=="bigint"&&r!=="number"&&r!=="boolean"&&r!=="string"?{type:Array.isArray(e.value)?"array":"object"}:t.target==="openApi3"?{type:r==="bigint"?"integer":r,enum:[e.value]}:{type:r==="bigint"?"integer":r,const:e.value}}var gp,Er={cuid:/^[cC][^\s-]{8,}$/,cuid2:/^[0-9a-z]+$/,ulid:/^[0-9A-HJKMNP-TV-Z]{26}$/,email:/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,emoji:()=>(gp===void 0&&(gp=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),gp),uuid:/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,ipv4:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ipv4Cidr:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,ipv6:/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ipv6Cidr:/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,base64url:/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/,jwt:/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/};function vl(e,t){let r={type:"string"};if(e.checks)for(let n of e.checks)switch(n.kind){case"min":de(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,n.value):n.value,n.message,t);break;case"max":de(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,n.value):n.value,n.message,t);break;case"email":switch(t.emailStrategy){case"format:email":zr(r,"email",n.message,t);break;case"format:idn-email":zr(r,"idn-email",n.message,t);break;case"pattern:zod":jt(r,Er.email,n.message,t);break}break;case"url":zr(r,"uri",n.message,t);break;case"uuid":zr(r,"uuid",n.message,t);break;case"regex":jt(r,n.regex,n.message,t);break;case"cuid":jt(r,Er.cuid,n.message,t);break;case"cuid2":jt(r,Er.cuid2,n.message,t);break;case"startsWith":jt(r,RegExp(`^${_p(n.value,t)}`),n.message,t);break;case"endsWith":jt(r,RegExp(`${_p(n.value,t)}$`),n.message,t);break;case"datetime":zr(r,"date-time",n.message,t);break;case"date":zr(r,"date",n.message,t);break;case"time":zr(r,"time",n.message,t);break;case"duration":zr(r,"duration",n.message,t);break;case"length":de(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,n.value):n.value,n.message,t),de(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,n.value):n.value,n.message,t);break;case"includes":{jt(r,RegExp(_p(n.value,t)),n.message,t);break}case"ip":{n.version!=="v6"&&zr(r,"ipv4",n.message,t),n.version!=="v4"&&zr(r,"ipv6",n.message,t);break}case"base64url":jt(r,Er.base64url,n.message,t);break;case"jwt":jt(r,Er.jwt,n.message,t);break;case"cidr":{n.version!=="v6"&&jt(r,Er.ipv4Cidr,n.message,t),n.version!=="v4"&&jt(r,Er.ipv6Cidr,n.message,t);break}case"emoji":jt(r,Er.emoji(),n.message,t);break;case"ulid":{jt(r,Er.ulid,n.message,t);break}case"base64":{switch(t.base64Strategy){case"format:binary":{zr(r,"binary",n.message,t);break}case"contentEncoding:base64":{de(r,"contentEncoding","base64",n.message,t);break}case"pattern:zod":{jt(r,Er.base64,n.message,t);break}}break}case"nanoid":jt(r,Er.nanoid,n.message,t);case"toLowerCase":case"toUpperCase":case"trim":break;default:}return r}function _p(e,t){return t.patternStrategy==="escape"?sC(e):e}var oC=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function sC(e){let t="";for(let r=0;r<e.length;r++)oC.has(e[r])||(t+="\\"),t+=e[r];return t}function zr(e,t,r,n){e.format||e.anyOf?.some(i=>i.format)?(e.anyOf||(e.anyOf=[]),e.format&&(e.anyOf.push({format:e.format,...e.errorMessage&&n.errorMessages&&{errorMessage:{format:e.errorMessage.format}}}),delete e.format,e.errorMessage&&(delete e.errorMessage.format,Object.keys(e.errorMessage).length===0&&delete e.errorMessage)),e.anyOf.push({format:t,...r&&n.errorMessages&&{errorMessage:{format:r}}})):de(e,"format",t,r,n)}function jt(e,t,r,n){e.pattern||e.allOf?.some(i=>i.pattern)?(e.allOf||(e.allOf=[]),e.pattern&&(e.allOf.push({pattern:e.pattern,...e.errorMessage&&n.errorMessages&&{errorMessage:{pattern:e.errorMessage.pattern}}}),delete e.pattern,e.errorMessage&&(delete e.errorMessage.pattern,Object.keys(e.errorMessage).length===0&&delete e.errorMessage)),e.allOf.push({pattern:sw(t,n),...r&&n.errorMessages&&{errorMessage:{pattern:r}}})):de(e,"pattern",sw(t,n),r,n)}function sw(e,t){if(!t.applyRegexFlags||!e.flags)return e.source;let r={i:e.flags.includes("i"),m:e.flags.includes("m"),s:e.flags.includes("s")},n=r.i?e.source.toLowerCase():e.source,i="",o=!1,s=!1,a=!1;for(let u=0;u<n.length;u++){if(o){i+=n[u],o=!1;continue}if(r.i){if(s){if(n[u].match(/[a-z]/)){a?(i+=n[u],i+=`${n[u-2]}-${n[u]}`.toUpperCase(),a=!1):n[u+1]==="-"&&n[u+2]?.match(/[a-z]/)?(i+=n[u],a=!0):i+=`${n[u]}${n[u].toUpperCase()}`;continue}}else if(n[u].match(/[a-z]/)){i+=`[${n[u]}${n[u].toUpperCase()}]`;continue}}if(r.m){if(n[u]==="^"){i+=`(^|(?<=[\r
452
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let l of this.seen.entries()){let d=l[1];if(t===l[0]){s(l);continue}if(n.external){let f=n.external.registry.get(l[0])?.id;if(t!==l[0]&&f){s(l);continue}}if(this.metadataRegistry.get(l[0])?.id){s(l);continue}if(d.cycle){s(l);continue}if(d.count>1&&n.reused==="ref"){s(l);continue}}let a=(l,d)=>{let p=this.seen.get(l),f=p.def??p.schema,h={...f};if(p.ref===null)return;let m=p.ref;if(p.ref=null,m){a(m,d);let g=this.seen.get(m).schema;g.$ref&&d.target==="draft-7"?(f.allOf=f.allOf??[],f.allOf.push(g)):(Object.assign(f,g),Object.assign(f,h))}p.isParent||this.override({zodSchema:l,jsonSchema:f,path:p.path??[]})};for(let l of[...this.seen.entries()].reverse())a(l[0],{target:this.target});let u={};if(this.target==="draft-2020-12"?u.$schema="https://json-schema.org/draft/2020-12/schema":this.target==="draft-7"?u.$schema="http://json-schema.org/draft-07/schema#":console.warn(`Invalid target: ${this.target}`),n.external?.uri){let l=n.external.registry.get(t)?.id;if(!l)throw new Error("Schema is missing an `id` property");u.$id=n.external.uri(l)}Object.assign(u,i.def);let c=n.external?.defs??{};for(let l of this.seen.entries()){let d=l[1];d.def&&d.defId&&(c[d.defId]=d.def)}n.external||Object.keys(c).length>0&&(this.target==="draft-2020-12"?u.$defs=c:u.definitions=c);try{return JSON.parse(JSON.stringify(u))}catch{throw new Error("Error converting schema to JSON.")}}};function Fm(e,t){if(e instanceof Zs){let n=new Bc(t),i={};for(let a of e._idmap.entries()){let[u,c]=a;n.process(c)}let o={},s={registry:e,uri:t?.uri,defs:i};for(let a of e._idmap.entries()){let[u,c]=a;o[u]=n.emit(c,{...t,external:s})}if(Object.keys(i).length>0){let a=n.target==="draft-2020-12"?"$defs":"definitions";o.__shared={[a]:i}}return{schemas:o}}let r=new Bc(t);return r.process(e),r.emit(e,t)}function ot(e,t){let r=t??{seen:new Set};if(r.seen.has(e))return!1;r.seen.add(e);let i=e._zod.def;switch(i.type){case"string":case"number":case"bigint":case"boolean":case"date":case"symbol":case"undefined":case"null":case"any":case"unknown":case"never":case"void":case"literal":case"enum":case"nan":case"file":case"template_literal":return!1;case"array":return ot(i.element,r);case"object":{for(let o in i.shape)if(ot(i.shape[o],r))return!0;return!1}case"union":{for(let o of i.options)if(ot(o,r))return!0;return!1}case"intersection":return ot(i.left,r)||ot(i.right,r);case"tuple":{for(let o of i.items)if(ot(o,r))return!0;return!!(i.rest&&ot(i.rest,r))}case"record":return ot(i.keyType,r)||ot(i.valueType,r);case"map":return ot(i.keyType,r)||ot(i.valueType,r);case"set":return ot(i.valueType,r);case"promise":case"optional":case"nonoptional":case"nullable":case"readonly":return ot(i.innerType,r);case"lazy":return ot(i.getter(),r);case"default":return ot(i.innerType,r);case"prefault":return ot(i.innerType,r);case"custom":return!1;case"transform":return!0;case"pipe":return ot(i.in,r)||ot(i.out,r);case"success":return!1;case"catch":return!1;default:}throw new Error(`Unknown schema type: ${i.type}`)}var Ls={};mu(Ls,{ZodISODate:()=>a0,ZodISODateTime:()=>s0,ZodISODuration:()=>l0,ZodISOTime:()=>c0,date:()=>Lm,datetime:()=>qm,duration:()=>Vm,time:()=>Um});var s0=x("ZodISODateTime",(e,t)=>{Wb.init(e,t),Ge.init(e,t)});function qm(e){return e0(s0,e)}var a0=x("ZodISODate",(e,t)=>{Jb.init(e,t),Ge.init(e,t)});function Lm(e){return t0(a0,e)}var c0=x("ZodISOTime",(e,t)=>{Hb.init(e,t),Ge.init(e,t)});function Um(e){return r0(c0,e)}var l0=x("ZodISODuration",(e,t)=>{Kb.init(e,t),Ge.init(e,t)});function Vm(e){return n0(l0,e)}var u0=(e,t)=>{Rc.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:r=>rf(e,r)},flatten:{value:r=>tf(e,r)},addIssue:{value:r=>e.issues.push(r)},addIssues:{value:r=>e.issues.push(...r)},isEmpty:{get(){return e.issues.length===0}}})},MD=x("ZodError",u0),Us=x("ZodError",u0,{Parent:Error});var d0=nf(Us),f0=sf(Us),m0=cf(Us),p0=lf(Us);var Je=x("ZodType",(e,t)=>(Se.init(e,t),e.def=t,Object.defineProperty(e,"_def",{value:t}),e.check=(...r)=>e.clone({...t,checks:[...t.checks??[],...r.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),e.clone=(r,n)=>tr(e,r,n),e.brand=()=>e,e.register=((r,n)=>(r.add(e,n),e)),e.parse=(r,n)=>d0(e,r,n,{callee:e.parse}),e.safeParse=(r,n)=>m0(e,r,n),e.parseAsync=async(r,n)=>f0(e,r,n,{callee:e.parseAsync}),e.safeParseAsync=async(r,n)=>p0(e,r,n),e.spa=e.safeParseAsync,e.refine=(r,n)=>e.check($O(r,n)),e.superRefine=r=>e.check(EO(r)),e.overwrite=r=>e.check(Zi(r)),e.optional=()=>Fe(e),e.nullable=()=>_0(e),e.nullish=()=>Fe(_0(e)),e.nonoptional=r=>vO(e,r),e.array=()=>ue(e),e.or=r=>Re([e,r]),e.and=r=>Jc(e,r),e.transform=r=>Wm(e,x0(r)),e.default=r=>gO(e,r),e.prefault=r=>yO(e,r),e.catch=r=>wO(e,r),e.pipe=r=>Wm(e,r),e.readonly=()=>SO(e),e.describe=r=>{let n=e.clone();return Fn.add(n,{description:r}),n},Object.defineProperty(e,"description",{get(){return Fn.get(e)?.description},configurable:!0}),e.meta=(...r)=>{if(r.length===0)return Fn.get(e);let n=e.clone();return Fn.add(n,r[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e)),y0=x("_ZodString",(e,t)=>{Gs.init(e,t),Je.init(e,t);let r=e._zod.bag;e.format=r.format??null,e.minLength=r.minimum??null,e.maxLength=r.maximum??null,e.regex=(...n)=>e.check(Am(...n)),e.includes=(...n)=>e.check(Cm(...n)),e.startsWith=(...n)=>e.check(Rm(...n)),e.endsWith=(...n)=>e.check(Im(...n)),e.min=(...n)=>e.check(Po(...n)),e.max=(...n)=>e.check(Uc(...n)),e.length=(...n)=>e.check(Vc(...n)),e.nonempty=(...n)=>e.check(Po(1,...n)),e.lowercase=n=>e.check(Om(n)),e.uppercase=n=>e.check(Pm(n)),e.trim=()=>e.check(Nm()),e.normalize=(...n)=>e.check(jm(...n)),e.toLowerCase=()=>e.check(Mm()),e.toUpperCase=()=>e.check(Dm())}),DA=x("ZodString",(e,t)=>{Gs.init(e,t),y0.init(e,t),e.email=r=>e.check(rm(GA,r)),e.url=r=>e.check(am(ZA,r)),e.jwt=r=>e.check(km(tO,r)),e.emoji=r=>e.check(cm(FA,r)),e.guid=r=>e.check(Zc(h0,r)),e.uuid=r=>e.check(nm(Wc,r)),e.uuidv4=r=>e.check(im(Wc,r)),e.uuidv6=r=>e.check(om(Wc,r)),e.uuidv7=r=>e.check(sm(Wc,r)),e.nanoid=r=>e.check(lm(qA,r)),e.guid=r=>e.check(Zc(h0,r)),e.cuid=r=>e.check(um(LA,r)),e.cuid2=r=>e.check(dm(UA,r)),e.ulid=r=>e.check(fm(VA,r)),e.base64=r=>e.check(vm(XA,r)),e.base64url=r=>e.check(bm(YA,r)),e.xid=r=>e.check(mm(BA,r)),e.ksuid=r=>e.check(pm(WA,r)),e.ipv4=r=>e.check(hm(JA,r)),e.ipv6=r=>e.check(gm(HA,r)),e.cidrv4=r=>e.check(_m(KA,r)),e.cidrv6=r=>e.check(ym(QA,r)),e.e164=r=>e.check(wm(eO,r)),e.datetime=r=>e.check(qm(r)),e.date=r=>e.check(Lm(r)),e.time=r=>e.check(Um(r)),e.duration=r=>e.check(Vm(r))});function k(e){return tm(DA,e)}var Ge=x("ZodStringFormat",(e,t)=>{ze.init(e,t),y0.init(e,t)}),GA=x("ZodEmail",(e,t)=>{_f.init(e,t),Ge.init(e,t)});var h0=x("ZodGUID",(e,t)=>{hf.init(e,t),Ge.init(e,t)});var Wc=x("ZodUUID",(e,t)=>{gf.init(e,t),Ge.init(e,t)});var ZA=x("ZodURL",(e,t)=>{yf.init(e,t),Ge.init(e,t)});var FA=x("ZodEmoji",(e,t)=>{vf.init(e,t),Ge.init(e,t)});var qA=x("ZodNanoID",(e,t)=>{bf.init(e,t),Ge.init(e,t)});var LA=x("ZodCUID",(e,t)=>{wf.init(e,t),Ge.init(e,t)});var UA=x("ZodCUID2",(e,t)=>{kf.init(e,t),Ge.init(e,t)});var VA=x("ZodULID",(e,t)=>{xf.init(e,t),Ge.init(e,t)});var BA=x("ZodXID",(e,t)=>{Sf.init(e,t),Ge.init(e,t)});var WA=x("ZodKSUID",(e,t)=>{Tf.init(e,t),Ge.init(e,t)});var JA=x("ZodIPv4",(e,t)=>{$f.init(e,t),Ge.init(e,t)});var HA=x("ZodIPv6",(e,t)=>{Ef.init(e,t),Ge.init(e,t)});var KA=x("ZodCIDRv4",(e,t)=>{zf.init(e,t),Ge.init(e,t)});var QA=x("ZodCIDRv6",(e,t)=>{Af.init(e,t),Ge.init(e,t)});var XA=x("ZodBase64",(e,t)=>{Of.init(e,t),Ge.init(e,t)});var YA=x("ZodBase64URL",(e,t)=>{Pf.init(e,t),Ge.init(e,t)});var eO=x("ZodE164",(e,t)=>{Cf.init(e,t),Ge.init(e,t)});var tO=x("ZodJWT",(e,t)=>{Rf.init(e,t),Ge.init(e,t)});var v0=x("ZodNumber",(e,t)=>{Mc.init(e,t),Je.init(e,t),e.gt=(n,i)=>e.check(qc(n,i)),e.gte=(n,i)=>e.check(qs(n,i)),e.min=(n,i)=>e.check(qs(n,i)),e.lt=(n,i)=>e.check(Fc(n,i)),e.lte=(n,i)=>e.check(Fs(n,i)),e.max=(n,i)=>e.check(Fs(n,i)),e.int=n=>e.check(g0(n)),e.safe=n=>e.check(g0(n)),e.positive=n=>e.check(qc(0,n)),e.nonnegative=n=>e.check(qs(0,n)),e.negative=n=>e.check(Fc(0,n)),e.nonpositive=n=>e.check(Fs(0,n)),e.multipleOf=(n,i)=>e.check(Lc(n,i)),e.step=(n,i)=>e.check(Lc(n,i)),e.finite=()=>e;let r=e._zod.bag;e.minValue=Math.max(r.minimum??Number.NEGATIVE_INFINITY,r.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(r.maximum??Number.POSITIVE_INFINITY,r.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(r.format??"").includes("int")||Number.isSafeInteger(r.multipleOf??.5),e.isFinite=!0,e.format=r.format??null});function ke(e){return xm(v0,e)}var rO=x("ZodNumberFormat",(e,t)=>{If.init(e,t),v0.init(e,t)});function g0(e){return Sm(rO,e)}var nO=x("ZodBoolean",(e,t)=>{jf.init(e,t),Je.init(e,t)});function dt(e){return Tm(nO,e)}var iO=x("ZodNull",(e,t)=>{Nf.init(e,t),Je.init(e,t)});function b0(e){return $m(iO,e)}var oO=x("ZodUnknown",(e,t)=>{Mf.init(e,t),Je.init(e,t)});function Ze(){return Em(oO)}var sO=x("ZodNever",(e,t)=>{Df.init(e,t),Je.init(e,t)});function aO(e){return zm(sO,e)}var cO=x("ZodArray",(e,t)=>{Gf.init(e,t),Je.init(e,t),e.element=t.element,e.min=(r,n)=>e.check(Po(r,n)),e.nonempty=r=>e.check(Po(1,r)),e.max=(r,n)=>e.check(Uc(r,n)),e.length=(r,n)=>e.check(Vc(r,n)),e.unwrap=()=>e.element});function ue(e,t){return i0(cO,e,t)}var w0=x("ZodObject",(e,t)=>{Dc.init(e,t),Je.init(e,t),ce.defineLazy(e,"shape",()=>t.shape),e.keyof=()=>Vt(Object.keys(e._zod.def.shape)),e.catchall=r=>e.clone({...e._zod.def,catchall:r}),e.passthrough=()=>e.clone({...e._zod.def,catchall:Ze()}),e.loose=()=>e.clone({...e._zod.def,catchall:Ze()}),e.strict=()=>e.clone({...e._zod.def,catchall:aO()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=r=>ce.extend(e,r),e.merge=r=>ce.merge(e,r),e.pick=r=>ce.pick(e,r),e.omit=r=>ce.omit(e,r),e.partial=(...r)=>ce.partial(S0,e,r[0]),e.required=(...r)=>ce.required(T0,e,r[0])});function C(e,t){let r={type:"object",get shape(){return ce.assignProp(this,"shape",{...e}),this.shape},...ce.normalizeParams(t)};return new w0(r)}function It(e,t){return new w0({type:"object",get shape(){return ce.assignProp(this,"shape",{...e}),this.shape},catchall:Ze(),...ce.normalizeParams(t)})}var k0=x("ZodUnion",(e,t)=>{Gc.init(e,t),Je.init(e,t),e.options=t.options});function Re(e,t){return new k0({type:"union",options:e,...ce.normalizeParams(t)})}var lO=x("ZodDiscriminatedUnion",(e,t)=>{k0.init(e,t),Zf.init(e,t)});function Jm(e,t,r){return new lO({type:"union",options:t,discriminator:e,...ce.normalizeParams(r)})}var uO=x("ZodIntersection",(e,t)=>{Ff.init(e,t),Je.init(e,t)});function Jc(e,t){return new uO({type:"intersection",left:e,right:t})}var dO=x("ZodRecord",(e,t)=>{qf.init(e,t),Je.init(e,t),e.keyType=t.keyType,e.valueType=t.valueType});function Ae(e,t,r){return new dO({type:"record",keyType:e,valueType:t,...ce.normalizeParams(r)})}var Bm=x("ZodEnum",(e,t)=>{Lf.init(e,t),Je.init(e,t),e.enum=t.entries,e.options=Object.values(t.entries);let r=new Set(Object.keys(t.entries));e.extract=(n,i)=>{let o={};for(let s of n)if(r.has(s))o[s]=t.entries[s];else throw new Error(`Key ${s} not found in enum`);return new Bm({...t,checks:[],...ce.normalizeParams(i),entries:o})},e.exclude=(n,i)=>{let o={...t.entries};for(let s of n)if(r.has(s))delete o[s];else throw new Error(`Key ${s} not found in enum`);return new Bm({...t,checks:[],...ce.normalizeParams(i),entries:o})}});function Vt(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map(n=>[n,n])):e;return new Bm({type:"enum",entries:r,...ce.normalizeParams(t)})}var fO=x("ZodLiteral",(e,t)=>{Uf.init(e,t),Je.init(e,t),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function q(e,t){return new fO({type:"literal",values:Array.isArray(e)?e:[e],...ce.normalizeParams(t)})}var mO=x("ZodTransform",(e,t)=>{Vf.init(e,t),Je.init(e,t),e._zod.parse=(r,n)=>{r.addIssue=o=>{if(typeof o=="string")r.issues.push(ce.issue(o,r.value,t));else{let s=o;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),s.input??(s.input=r.value),s.inst??(s.inst=e),s.continue??(s.continue=!0),r.issues.push(ce.issue(s))}};let i=t.transform(r.value,r);return i instanceof Promise?i.then(o=>(r.value=o,r)):(r.value=i,r)}});function x0(e){return new mO({type:"transform",transform:e})}var S0=x("ZodOptional",(e,t)=>{Bf.init(e,t),Je.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Fe(e){return new S0({type:"optional",innerType:e})}var pO=x("ZodNullable",(e,t)=>{Wf.init(e,t),Je.init(e,t),e.unwrap=()=>e._zod.def.innerType});function _0(e){return new pO({type:"nullable",innerType:e})}var hO=x("ZodDefault",(e,t)=>{Jf.init(e,t),Je.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function gO(e,t){return new hO({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():t}})}var _O=x("ZodPrefault",(e,t)=>{Hf.init(e,t),Je.init(e,t),e.unwrap=()=>e._zod.def.innerType});function yO(e,t){return new _O({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():t}})}var T0=x("ZodNonOptional",(e,t)=>{Kf.init(e,t),Je.init(e,t),e.unwrap=()=>e._zod.def.innerType});function vO(e,t){return new T0({type:"nonoptional",innerType:e,...ce.normalizeParams(t)})}var bO=x("ZodCatch",(e,t)=>{Qf.init(e,t),Je.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function wO(e,t){return new bO({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}var kO=x("ZodPipe",(e,t)=>{Xf.init(e,t),Je.init(e,t),e.in=t.in,e.out=t.out});function Wm(e,t){return new kO({type:"pipe",in:e,out:t})}var xO=x("ZodReadonly",(e,t)=>{Yf.init(e,t),Je.init(e,t)});function SO(e){return new xO({type:"readonly",innerType:e})}var $0=x("ZodCustom",(e,t)=>{em.init(e,t),Je.init(e,t)});function TO(e){let t=new yt({check:"custom"});return t._zod.check=e,t}function E0(e,t){return Gm($0,e??(()=>!0),t)}function $O(e,t={}){return Zm($0,e,t)}function EO(e){let t=TO(r=>(r.addIssue=n=>{if(typeof n=="string")r.issues.push(ce.issue(n,r.value,t._zod.def));else{let i=n;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=r.value),i.inst??(i.inst=t),i.continue??(i.continue=!t._zod.def.abort),r.issues.push(ce.issue(i))}},e(r.value,r)));return t}function Hm(e,t){return Wm(x0(e),t)}er(Xb());var Qm="2025-11-25";var z0=[Qm,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],qn="io.modelcontextprotocol/related-task",Kc="2.0",st=E0(e=>e!==null&&(typeof e=="object"||typeof e=="function")),A0=Re([k(),ke().int()]),O0=k(),QD=It({ttl:ke().optional(),pollInterval:ke().optional()}),zO=C({ttl:ke().optional()}),AO=C({taskId:k()}),Xm=It({progressToken:A0.optional(),[qn]:AO.optional()}),rr=C({_meta:Xm.optional()}),Vs=rr.extend({task:zO.optional()}),P0=e=>Vs.safeParse(e).success,vt=C({method:k(),params:rr.loose().optional()}),fr=C({_meta:Xm.optional()}),mr=C({method:k(),params:fr.loose().optional()}),bt=It({_meta:Xm.optional()}),Qc=Re([k(),ke().int()]),C0=C({jsonrpc:q(Kc),id:Qc,...vt.shape}).strict(),Ym=e=>C0.safeParse(e).success,R0=C({jsonrpc:q(Kc),...mr.shape}).strict(),I0=e=>R0.safeParse(e).success,ep=C({jsonrpc:q(Kc),id:Qc,result:bt}).strict(),Bs=e=>ep.safeParse(e).success;var U;(function(e){e[e.ConnectionClosed=-32e3]="ConnectionClosed",e[e.RequestTimeout=-32001]="RequestTimeout",e[e.ParseError=-32700]="ParseError",e[e.InvalidRequest=-32600]="InvalidRequest",e[e.MethodNotFound=-32601]="MethodNotFound",e[e.InvalidParams=-32602]="InvalidParams",e[e.InternalError=-32603]="InternalError",e[e.UrlElicitationRequired=-32042]="UrlElicitationRequired"})(U||(U={}));var tp=C({jsonrpc:q(Kc),id:Qc.optional(),error:C({code:ke().int(),message:k(),data:Ze().optional()})}).strict();var j0=e=>tp.safeParse(e).success;var N0=Re([C0,R0,ep,tp]),XD=Re([ep,tp]),Xc=bt.strict(),OO=fr.extend({requestId:Qc.optional(),reason:k().optional()}),Yc=mr.extend({method:q("notifications/cancelled"),params:OO}),PO=C({src:k(),mimeType:k().optional(),sizes:ue(k()).optional(),theme:Vt(["light","dark"]).optional()}),Ws=C({icons:ue(PO).optional()}),Co=C({name:k(),title:k().optional()}),M0=Co.extend({...Co.shape,...Ws.shape,version:k(),websiteUrl:k().optional(),description:k().optional()}),CO=Jc(C({applyDefaults:dt().optional()}),Ae(k(),Ze())),RO=Hm(e=>e&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,Jc(C({form:CO.optional(),url:st.optional()}),Ae(k(),Ze()).optional())),IO=It({list:st.optional(),cancel:st.optional(),requests:It({sampling:It({createMessage:st.optional()}).optional(),elicitation:It({create:st.optional()}).optional()}).optional()}),jO=It({list:st.optional(),cancel:st.optional(),requests:It({tools:It({call:st.optional()}).optional()}).optional()}),NO=C({experimental:Ae(k(),st).optional(),sampling:C({context:st.optional(),tools:st.optional()}).optional(),elicitation:RO.optional(),roots:C({listChanged:dt().optional()}).optional(),tasks:IO.optional(),extensions:Ae(k(),st).optional()}),MO=rr.extend({protocolVersion:k(),capabilities:NO,clientInfo:M0}),rp=vt.extend({method:q("initialize"),params:MO});var DO=C({experimental:Ae(k(),st).optional(),logging:st.optional(),completions:st.optional(),prompts:C({listChanged:dt().optional()}).optional(),resources:C({subscribe:dt().optional(),listChanged:dt().optional()}).optional(),tools:C({listChanged:dt().optional()}).optional(),tasks:jO.optional(),extensions:Ae(k(),st).optional()}),GO=bt.extend({protocolVersion:k(),capabilities:DO,serverInfo:M0,instructions:k().optional()}),np=mr.extend({method:q("notifications/initialized"),params:fr.optional()});var el=vt.extend({method:q("ping"),params:rr.optional()}),ZO=C({progress:ke(),total:Fe(ke()),message:Fe(k())}),FO=C({...fr.shape,...ZO.shape,progressToken:A0}),tl=mr.extend({method:q("notifications/progress"),params:FO}),qO=rr.extend({cursor:O0.optional()}),Js=vt.extend({params:qO.optional()}),Hs=bt.extend({nextCursor:O0.optional()}),LO=Vt(["working","input_required","completed","failed","cancelled"]),Ks=C({taskId:k(),status:LO,ttl:Re([ke(),b0()]),createdAt:k(),lastUpdatedAt:k(),pollInterval:Fe(ke()),statusMessage:Fe(k())}),Ro=bt.extend({task:Ks}),UO=fr.merge(Ks),Qs=mr.extend({method:q("notifications/tasks/status"),params:UO}),rl=vt.extend({method:q("tasks/get"),params:rr.extend({taskId:k()})}),nl=bt.merge(Ks),il=vt.extend({method:q("tasks/result"),params:rr.extend({taskId:k()})}),YD=bt.loose(),ol=Js.extend({method:q("tasks/list")}),sl=Hs.extend({tasks:ue(Ks)}),al=vt.extend({method:q("tasks/cancel"),params:rr.extend({taskId:k()})}),D0=bt.merge(Ks),G0=C({uri:k(),mimeType:Fe(k()),_meta:Ae(k(),Ze()).optional()}),Z0=G0.extend({text:k()}),ip=k().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),F0=G0.extend({blob:ip}),Xs=Vt(["user","assistant"]),Io=C({audience:ue(Xs).optional(),priority:ke().min(0).max(1).optional(),lastModified:Ls.datetime({offset:!0}).optional()}),q0=C({...Co.shape,...Ws.shape,uri:k(),description:Fe(k()),mimeType:Fe(k()),size:Fe(ke()),annotations:Io.optional(),_meta:Fe(It({}))}),VO=C({...Co.shape,...Ws.shape,uriTemplate:k(),description:Fe(k()),mimeType:Fe(k()),annotations:Io.optional(),_meta:Fe(It({}))}),jo=Js.extend({method:q("resources/list")}),BO=Hs.extend({resources:ue(q0)}),No=Js.extend({method:q("resources/templates/list")}),WO=Hs.extend({resourceTemplates:ue(VO)}),op=rr.extend({uri:k()}),JO=op,cl=vt.extend({method:q("resources/read"),params:JO}),HO=bt.extend({contents:ue(Re([Z0,F0]))}),KO=mr.extend({method:q("notifications/resources/list_changed"),params:fr.optional()}),QO=op,XO=vt.extend({method:q("resources/subscribe"),params:QO}),YO=op,eP=vt.extend({method:q("resources/unsubscribe"),params:YO}),tP=fr.extend({uri:k()}),rP=mr.extend({method:q("notifications/resources/updated"),params:tP}),nP=C({name:k(),description:Fe(k()),required:Fe(dt())}),iP=C({...Co.shape,...Ws.shape,description:Fe(k()),arguments:Fe(ue(nP)),_meta:Fe(It({}))}),ll=Js.extend({method:q("prompts/list")}),oP=Hs.extend({prompts:ue(iP)}),sP=rr.extend({name:k(),arguments:Ae(k(),k()).optional()}),ul=vt.extend({method:q("prompts/get"),params:sP}),sp=C({type:q("text"),text:k(),annotations:Io.optional(),_meta:Ae(k(),Ze()).optional()}),ap=C({type:q("image"),data:ip,mimeType:k(),annotations:Io.optional(),_meta:Ae(k(),Ze()).optional()}),cp=C({type:q("audio"),data:ip,mimeType:k(),annotations:Io.optional(),_meta:Ae(k(),Ze()).optional()}),aP=C({type:q("tool_use"),name:k(),id:k(),input:Ae(k(),Ze()),_meta:Ae(k(),Ze()).optional()}),cP=C({type:q("resource"),resource:Re([Z0,F0]),annotations:Io.optional(),_meta:Ae(k(),Ze()).optional()}),lP=q0.extend({type:q("resource_link")}),lp=Re([sp,ap,cp,lP,cP]),uP=C({role:Xs,content:lp}),dP=bt.extend({description:k().optional(),messages:ue(uP)}),fP=mr.extend({method:q("notifications/prompts/list_changed"),params:fr.optional()}),mP=C({title:k().optional(),readOnlyHint:dt().optional(),destructiveHint:dt().optional(),idempotentHint:dt().optional(),openWorldHint:dt().optional()}),pP=C({taskSupport:Vt(["required","optional","forbidden"]).optional()}),L0=C({...Co.shape,...Ws.shape,description:k().optional(),inputSchema:C({type:q("object"),properties:Ae(k(),st).optional(),required:ue(k()).optional()}).catchall(Ze()),outputSchema:C({type:q("object"),properties:Ae(k(),st).optional(),required:ue(k()).optional()}).catchall(Ze()).optional(),annotations:mP.optional(),execution:pP.optional(),_meta:Ae(k(),Ze()).optional()}),dl=Js.extend({method:q("tools/list")}),hP=Hs.extend({tools:ue(L0)}),fl=bt.extend({content:ue(lp).default([]),structuredContent:Ae(k(),Ze()).optional(),isError:dt().optional()}),eG=fl.or(bt.extend({toolResult:Ze()})),gP=Vs.extend({name:k(),arguments:Ae(k(),Ze()).optional()}),Mo=vt.extend({method:q("tools/call"),params:gP}),_P=mr.extend({method:q("notifications/tools/list_changed"),params:fr.optional()}),tG=C({autoRefresh:dt().default(!0),debounceMs:ke().int().nonnegative().default(300)}),Ys=Vt(["debug","info","notice","warning","error","critical","alert","emergency"]),yP=rr.extend({level:Ys}),up=vt.extend({method:q("logging/setLevel"),params:yP}),vP=fr.extend({level:Ys,logger:k().optional(),data:Ze()}),bP=mr.extend({method:q("notifications/message"),params:vP}),wP=C({name:k().optional()}),kP=C({hints:ue(wP).optional(),costPriority:ke().min(0).max(1).optional(),speedPriority:ke().min(0).max(1).optional(),intelligencePriority:ke().min(0).max(1).optional()}),xP=C({mode:Vt(["auto","required","none"]).optional()}),SP=C({type:q("tool_result"),toolUseId:k().describe("The unique identifier for the corresponding tool call."),content:ue(lp).default([]),structuredContent:C({}).loose().optional(),isError:dt().optional(),_meta:Ae(k(),Ze()).optional()}),TP=Jm("type",[sp,ap,cp]),Hc=Jm("type",[sp,ap,cp,aP,SP]),$P=C({role:Xs,content:Re([Hc,ue(Hc)]),_meta:Ae(k(),Ze()).optional()}),EP=Vs.extend({messages:ue($P),modelPreferences:kP.optional(),systemPrompt:k().optional(),includeContext:Vt(["none","thisServer","allServers"]).optional(),temperature:ke().optional(),maxTokens:ke().int(),stopSequences:ue(k()).optional(),metadata:st.optional(),tools:ue(L0).optional(),toolChoice:xP.optional()}),zP=vt.extend({method:q("sampling/createMessage"),params:EP}),ea=bt.extend({model:k(),stopReason:Fe(Vt(["endTurn","stopSequence","maxTokens"]).or(k())),role:Xs,content:TP}),dp=bt.extend({model:k(),stopReason:Fe(Vt(["endTurn","stopSequence","maxTokens","toolUse"]).or(k())),role:Xs,content:Re([Hc,ue(Hc)])}),AP=C({type:q("boolean"),title:k().optional(),description:k().optional(),default:dt().optional()}),OP=C({type:q("string"),title:k().optional(),description:k().optional(),minLength:ke().optional(),maxLength:ke().optional(),format:Vt(["email","uri","date","date-time"]).optional(),default:k().optional()}),PP=C({type:Vt(["number","integer"]),title:k().optional(),description:k().optional(),minimum:ke().optional(),maximum:ke().optional(),default:ke().optional()}),CP=C({type:q("string"),title:k().optional(),description:k().optional(),enum:ue(k()),default:k().optional()}),RP=C({type:q("string"),title:k().optional(),description:k().optional(),oneOf:ue(C({const:k(),title:k()})),default:k().optional()}),IP=C({type:q("string"),title:k().optional(),description:k().optional(),enum:ue(k()),enumNames:ue(k()).optional(),default:k().optional()}),jP=Re([CP,RP]),NP=C({type:q("array"),title:k().optional(),description:k().optional(),minItems:ke().optional(),maxItems:ke().optional(),items:C({type:q("string"),enum:ue(k())}),default:ue(k()).optional()}),MP=C({type:q("array"),title:k().optional(),description:k().optional(),minItems:ke().optional(),maxItems:ke().optional(),items:C({anyOf:ue(C({const:k(),title:k()}))}),default:ue(k()).optional()}),DP=Re([NP,MP]),GP=Re([IP,jP,DP]),ZP=Re([GP,AP,OP,PP]),FP=Vs.extend({mode:q("form").optional(),message:k(),requestedSchema:C({type:q("object"),properties:Ae(k(),ZP),required:ue(k()).optional()})}),qP=Vs.extend({mode:q("url"),message:k(),elicitationId:k(),url:k().url()}),LP=Re([FP,qP]),UP=vt.extend({method:q("elicitation/create"),params:LP}),VP=fr.extend({elicitationId:k()}),BP=mr.extend({method:q("notifications/elicitation/complete"),params:VP}),Do=bt.extend({action:Vt(["accept","decline","cancel"]),content:Hm(e=>e===null?void 0:e,Ae(k(),Re([k(),ke(),dt(),ue(k())])).optional())}),WP=C({type:q("ref/resource"),uri:k()});var JP=C({type:q("ref/prompt"),name:k()}),HP=rr.extend({ref:Re([JP,WP]),argument:C({name:k(),value:k()}),context:C({arguments:Ae(k(),k()).optional()}).optional()}),ml=vt.extend({method:q("completion/complete"),params:HP});function U0(e){if(e.params.ref.type!=="ref/prompt")throw new TypeError(`Expected CompleteRequestPrompt, but got ${e.params.ref.type}`)}function V0(e){if(e.params.ref.type!=="ref/resource")throw new TypeError(`Expected CompleteRequestResourceTemplate, but got ${e.params.ref.type}`)}var KP=bt.extend({completion:It({values:ue(k()).max(100),total:Fe(ke().int()),hasMore:Fe(dt())})}),QP=C({uri:k().startsWith("file://"),name:k().optional(),_meta:Ae(k(),Ze()).optional()}),XP=vt.extend({method:q("roots/list"),params:rr.optional()}),fp=bt.extend({roots:ue(QP)}),YP=mr.extend({method:q("notifications/roots/list_changed"),params:fr.optional()}),rG=Re([el,rp,ml,up,ul,ll,jo,No,cl,XO,eP,Mo,dl,rl,il,ol,al]),nG=Re([Yc,tl,np,YP,Qs]),iG=Re([Xc,ea,dp,Do,fp,nl,sl,Ro]),oG=Re([el,zP,UP,XP,rl,il,ol,al]),sG=Re([Yc,tl,bP,rP,KO,_P,fP,Qs,BP]),aG=Re([Xc,GO,KP,dP,oP,BO,WO,HO,fl,hP,nl,sl,Ro]),F=class e extends Error{constructor(t,r,n){super(`MCP error ${t}: ${r}`),this.code=t,this.data=n,this.name="McpError"}static fromError(t,r,n){if(t===U.UrlElicitationRequired&&n){let i=n;if(i.elicitations)return new Km(i.elicitations,r)}return new e(t,r,n)}},Km=class extends F{constructor(t,r=`URL elicitation${t.length>1?"s":""} required`){super(U.UrlElicitationRequired,r,{elicitations:t})}get elicitations(){return this.data?.elicitations??[]}};var rC=x("ZodMiniType",(e,t)=>{if(!e._zod)throw new Error("Uninitialized schema in ZodMiniType.");Se.init(e,t),e.def=t,e.parse=(r,n)=>of(e,r,n,{callee:e.parse}),e.safeParse=(r,n)=>Di(e,r,n),e.parseAsync=async(r,n)=>af(e,r,n,{callee:e.parseAsync}),e.safeParseAsync=async(r,n)=>Gi(e,r,n),e.check=(...r)=>e.clone({...t,checks:[...t.checks??[],...r.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),e.clone=(r,n)=>tr(e,r,n),e.brand=()=>e,e.register=((r,n)=>(r.add(e,n),e))});var nC=x("ZodMiniObject",(e,t)=>{Dc.init(e,t),rC.init(e,t),ce.defineLazy(e,"shape",()=>t.shape)});function mp(e,t){let r={type:"object",get shape(){return ce.assignProp(this,"shape",{...e}),this.shape},...ce.normalizeParams(t)};return new nC(r)}function pr(e){return!!e._zod}function qi(e){let t=Object.values(e);if(t.length===0)return mp({});let r=t.every(pr),n=t.every(i=>!pr(i));if(r)return mp(e);if(n)return bd(e);throw new Error("Mixed Zod versions detected in object shape.")}function Ln(e,t){return pr(e)?Di(e,t):e.safeParse(t)}async function pl(e,t){return pr(e)?await Gi(e,t):await e.safeParseAsync(t)}function Un(e){if(!e)return;let t;if(pr(e)?t=e._zod?.def?.shape:t=e.shape,!!t){if(typeof t=="function")try{return t()}catch{return}return t}}function Go(e){if(e){if(typeof e=="object"){let t=e,r=e;if(!t._def&&!r._zod){let n=Object.values(e);if(n.length>0&&n.every(i=>typeof i=="object"&&i!==null&&(i._def!==void 0||i._zod!==void 0||typeof i.parse=="function")))return qi(e)}}if(pr(e)){let r=e._zod?.def;if(r&&(r.type==="object"||r.shape!==void 0))return e}else if(e.shape!==void 0)return e}}function hl(e){if(e&&typeof e=="object"){if("message"in e&&typeof e.message=="string")return e.message;if("issues"in e&&Array.isArray(e.issues)&&e.issues.length>0){let t=e.issues[0];if(t&&typeof t=="object"&&"message"in t)return String(t.message)}try{return JSON.stringify(e)}catch{return String(e)}}return String(e)}function B0(e){return e.description}function W0(e){if(pr(e))return e._zod?.def?.type==="optional";let t=e;return typeof e.isOptional=="function"?e.isOptional():t._def?.typeName==="ZodOptional"}function gl(e){if(pr(e)){let o=e._zod?.def;if(o){if(o.value!==void 0)return o.value;if(Array.isArray(o.values)&&o.values.length>0)return o.values[0]}}let r=e._def;if(r){if(r.value!==void 0)return r.value;if(Array.isArray(r.values)&&r.values.length>0)return r.values[0]}let n=e.value;if(n!==void 0)return n}function Vn(e){return e==="completed"||e==="failed"||e==="cancelled"}var H0=Symbol("Let zodToJsonSchema decide on which parser to use");var J0={name:void 0,$refStrategy:"root",basePath:["#"],effectStrategy:"input",pipeStrategy:"all",dateStrategy:"format:date-time",mapStrategy:"entries",removeAdditionalStrategy:"passthrough",allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:"definitions",target:"jsonSchema7",strictUnions:!1,definitions:{},errorMessages:!1,markdownDescription:!1,patternStrategy:"escape",applyRegexFlags:!1,emailStrategy:"format:email",base64Strategy:"contentEncoding:base64",nameStrategy:"ref",openAiAnyTypeName:"OpenAiAnyType"},K0=e=>typeof e=="string"?{...J0,name:e}:{...J0,...e};var Q0=e=>{let t=K0(e),r=t.name!==void 0?[...t.basePath,t.definitionPath,t.name]:t.basePath;return{...t,flags:{hasReferencedOpenAiAnyType:!1},currentPath:r,propertyPath:void 0,seen:new Map(Object.entries(t.definitions).map(([n,i])=>[i._def,{def:i._def,path:[...t.basePath,t.definitionPath,n],jsonSchema:void 0}]))}};function pp(e,t,r,n){n?.errorMessages&&r&&(e.errorMessage={...e.errorMessage,[t]:r})}function de(e,t,r,n,i){e[t]=r,pp(e,t,n,i)}var _l=(e,t)=>{let r=0;for(;r<e.length&&r<t.length&&e[r]===t[r];r++);return[(e.length-r).toString(),...t.slice(r)].join("/")};function qe(e){if(e.target!=="openAi")return{};let t=[...e.basePath,e.definitionPath,e.openAiAnyTypeName];return e.flags.hasReferencedOpenAiAnyType=!0,{$ref:e.$refStrategy==="relative"?_l(t,e.currentPath):t.join("/")}}function X0(e,t){let r={type:"array"};return e.type?._def&&e.type?._def?.typeName!==E.ZodAny&&(r.items=H(e.type._def,{...t,currentPath:[...t.currentPath,"items"]})),e.minLength&&de(r,"minItems",e.minLength.value,e.minLength.message,t),e.maxLength&&de(r,"maxItems",e.maxLength.value,e.maxLength.message,t),e.exactLength&&(de(r,"minItems",e.exactLength.value,e.exactLength.message,t),de(r,"maxItems",e.exactLength.value,e.exactLength.message,t)),r}function Y0(e,t){let r={type:"integer",format:"int64"};if(!e.checks)return r;for(let n of e.checks)switch(n.kind){case"min":t.target==="jsonSchema7"?n.inclusive?de(r,"minimum",n.value,n.message,t):de(r,"exclusiveMinimum",n.value,n.message,t):(n.inclusive||(r.exclusiveMinimum=!0),de(r,"minimum",n.value,n.message,t));break;case"max":t.target==="jsonSchema7"?n.inclusive?de(r,"maximum",n.value,n.message,t):de(r,"exclusiveMaximum",n.value,n.message,t):(n.inclusive||(r.exclusiveMaximum=!0),de(r,"maximum",n.value,n.message,t));break;case"multipleOf":de(r,"multipleOf",n.value,n.message,t);break}return r}function ew(){return{type:"boolean"}}function yl(e,t){return H(e.type._def,t)}var tw=(e,t)=>H(e.innerType._def,t);function hp(e,t,r){let n=r??t.dateStrategy;if(Array.isArray(n))return{anyOf:n.map((i,o)=>hp(e,t,i))};switch(n){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return oC(e,t)}}var oC=(e,t)=>{let r={type:"integer",format:"unix-time"};if(t.target==="openApi3")return r;for(let n of e.checks)switch(n.kind){case"min":de(r,"minimum",n.value,n.message,t);break;case"max":de(r,"maximum",n.value,n.message,t);break}return r};function rw(e,t){return{...H(e.innerType._def,t),default:e.defaultValue()}}function nw(e,t){return t.effectStrategy==="input"?H(e.schema._def,t):qe(t)}function iw(e){return{type:"string",enum:Array.from(e.values)}}var sC=e=>"type"in e&&e.type==="string"?!1:"allOf"in e;function ow(e,t){let r=[H(e.left._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),H(e.right._def,{...t,currentPath:[...t.currentPath,"allOf","1"]})].filter(o=>!!o),n=t.target==="jsonSchema2019-09"?{unevaluatedProperties:!1}:void 0,i=[];return r.forEach(o=>{if(sC(o))i.push(...o.allOf),o.unevaluatedProperties===void 0&&(n=void 0);else{let s=o;if("additionalProperties"in o&&o.additionalProperties===!1){let{additionalProperties:a,...u}=o;s=u}else n=void 0;i.push(s)}}),i.length?{allOf:i,...n}:void 0}function sw(e,t){let r=typeof e.value;return r!=="bigint"&&r!=="number"&&r!=="boolean"&&r!=="string"?{type:Array.isArray(e.value)?"array":"object"}:t.target==="openApi3"?{type:r==="bigint"?"integer":r,enum:[e.value]}:{type:r==="bigint"?"integer":r,const:e.value}}var gp,Er={cuid:/^[cC][^\s-]{8,}$/,cuid2:/^[0-9a-z]+$/,ulid:/^[0-9A-HJKMNP-TV-Z]{26}$/,email:/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,emoji:()=>(gp===void 0&&(gp=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),gp),uuid:/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,ipv4:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ipv4Cidr:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,ipv6:/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ipv6Cidr:/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,base64url:/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/,jwt:/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/};function vl(e,t){let r={type:"string"};if(e.checks)for(let n of e.checks)switch(n.kind){case"min":de(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,n.value):n.value,n.message,t);break;case"max":de(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,n.value):n.value,n.message,t);break;case"email":switch(t.emailStrategy){case"format:email":zr(r,"email",n.message,t);break;case"format:idn-email":zr(r,"idn-email",n.message,t);break;case"pattern:zod":jt(r,Er.email,n.message,t);break}break;case"url":zr(r,"uri",n.message,t);break;case"uuid":zr(r,"uuid",n.message,t);break;case"regex":jt(r,n.regex,n.message,t);break;case"cuid":jt(r,Er.cuid,n.message,t);break;case"cuid2":jt(r,Er.cuid2,n.message,t);break;case"startsWith":jt(r,RegExp(`^${_p(n.value,t)}`),n.message,t);break;case"endsWith":jt(r,RegExp(`${_p(n.value,t)}$`),n.message,t);break;case"datetime":zr(r,"date-time",n.message,t);break;case"date":zr(r,"date",n.message,t);break;case"time":zr(r,"time",n.message,t);break;case"duration":zr(r,"duration",n.message,t);break;case"length":de(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,n.value):n.value,n.message,t),de(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,n.value):n.value,n.message,t);break;case"includes":{jt(r,RegExp(_p(n.value,t)),n.message,t);break}case"ip":{n.version!=="v6"&&zr(r,"ipv4",n.message,t),n.version!=="v4"&&zr(r,"ipv6",n.message,t);break}case"base64url":jt(r,Er.base64url,n.message,t);break;case"jwt":jt(r,Er.jwt,n.message,t);break;case"cidr":{n.version!=="v6"&&jt(r,Er.ipv4Cidr,n.message,t),n.version!=="v4"&&jt(r,Er.ipv6Cidr,n.message,t);break}case"emoji":jt(r,Er.emoji(),n.message,t);break;case"ulid":{jt(r,Er.ulid,n.message,t);break}case"base64":{switch(t.base64Strategy){case"format:binary":{zr(r,"binary",n.message,t);break}case"contentEncoding:base64":{de(r,"contentEncoding","base64",n.message,t);break}case"pattern:zod":{jt(r,Er.base64,n.message,t);break}}break}case"nanoid":jt(r,Er.nanoid,n.message,t);case"toLowerCase":case"toUpperCase":case"trim":break;default:}return r}function _p(e,t){return t.patternStrategy==="escape"?cC(e):e}var aC=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function cC(e){let t="";for(let r=0;r<e.length;r++)aC.has(e[r])||(t+="\\"),t+=e[r];return t}function zr(e,t,r,n){e.format||e.anyOf?.some(i=>i.format)?(e.anyOf||(e.anyOf=[]),e.format&&(e.anyOf.push({format:e.format,...e.errorMessage&&n.errorMessages&&{errorMessage:{format:e.errorMessage.format}}}),delete e.format,e.errorMessage&&(delete e.errorMessage.format,Object.keys(e.errorMessage).length===0&&delete e.errorMessage)),e.anyOf.push({format:t,...r&&n.errorMessages&&{errorMessage:{format:r}}})):de(e,"format",t,r,n)}function jt(e,t,r,n){e.pattern||e.allOf?.some(i=>i.pattern)?(e.allOf||(e.allOf=[]),e.pattern&&(e.allOf.push({pattern:e.pattern,...e.errorMessage&&n.errorMessages&&{errorMessage:{pattern:e.errorMessage.pattern}}}),delete e.pattern,e.errorMessage&&(delete e.errorMessage.pattern,Object.keys(e.errorMessage).length===0&&delete e.errorMessage)),e.allOf.push({pattern:aw(t,n),...r&&n.errorMessages&&{errorMessage:{pattern:r}}})):de(e,"pattern",aw(t,n),r,n)}function aw(e,t){if(!t.applyRegexFlags||!e.flags)return e.source;let r={i:e.flags.includes("i"),m:e.flags.includes("m"),s:e.flags.includes("s")},n=r.i?e.source.toLowerCase():e.source,i="",o=!1,s=!1,a=!1;for(let u=0;u<n.length;u++){if(o){i+=n[u],o=!1;continue}if(r.i){if(s){if(n[u].match(/[a-z]/)){a?(i+=n[u],i+=`${n[u-2]}-${n[u]}`.toUpperCase(),a=!1):n[u+1]==="-"&&n[u+2]?.match(/[a-z]/)?(i+=n[u],a=!0):i+=`${n[u]}${n[u].toUpperCase()}`;continue}}else if(n[u].match(/[a-z]/)){i+=`[${n[u]}${n[u].toUpperCase()}]`;continue}}if(r.m){if(n[u]==="^"){i+=`(^|(?<=[\r
453
453
  ]))`;continue}else if(n[u]==="$"){i+=`($|(?=[\r
454
454
  ]))`;continue}}if(r.s&&n[u]==="."){i+=s?`${n[u]}\r
455
455
  `:`[${n[u]}\r
456
- ]`;continue}i+=n[u],n[u]==="\\"?o=!0:s&&n[u]==="]"?s=!1:!s&&n[u]==="["&&(s=!0)}try{new RegExp(i)}catch{return console.warn(`Could not convert regex pattern at ${t.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),e.source}return i}function bl(e,t){if(t.target==="openAi"&&console.warn("Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead."),t.target==="openApi3"&&e.keyType?._def.typeName===E.ZodEnum)return{type:"object",required:e.keyType._def.values,properties:e.keyType._def.values.reduce((n,i)=>({...n,[i]:H(e.valueType._def,{...t,currentPath:[...t.currentPath,"properties",i]})??qe(t)}),{}),additionalProperties:t.rejectedAdditionalProperties};let r={type:"object",additionalProperties:H(e.valueType._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]})??t.allowedAdditionalProperties};if(t.target==="openApi3")return r;if(e.keyType?._def.typeName===E.ZodString&&e.keyType._def.checks?.length){let{type:n,...i}=vl(e.keyType._def,t);return{...r,propertyNames:i}}else{if(e.keyType?._def.typeName===E.ZodEnum)return{...r,propertyNames:{enum:e.keyType._def.values}};if(e.keyType?._def.typeName===E.ZodBranded&&e.keyType._def.type._def.typeName===E.ZodString&&e.keyType._def.type._def.checks?.length){let{type:n,...i}=yl(e.keyType._def,t);return{...r,propertyNames:i}}}return r}function aw(e,t){if(t.mapStrategy==="record")return bl(e,t);let r=H(e.keyType._def,{...t,currentPath:[...t.currentPath,"items","items","0"]})||qe(t),n=H(e.valueType._def,{...t,currentPath:[...t.currentPath,"items","items","1"]})||qe(t);return{type:"array",maxItems:125,items:{type:"array",items:[r,n],minItems:2,maxItems:2}}}function cw(e){let t=e.values,n=Object.keys(e.values).filter(o=>typeof t[t[o]]!="number").map(o=>t[o]),i=Array.from(new Set(n.map(o=>typeof o)));return{type:i.length===1?i[0]==="string"?"string":"number":["string","number"],enum:n}}function lw(e){return e.target==="openAi"?void 0:{not:qe({...e,currentPath:[...e.currentPath,"not"]})}}function uw(e){return e.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}var ta={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function fw(e,t){if(t.target==="openApi3")return dw(e,t);let r=e.options instanceof Map?Array.from(e.options.values()):e.options;if(r.every(n=>n._def.typeName in ta&&(!n._def.checks||!n._def.checks.length))){let n=r.reduce((i,o)=>{let s=ta[o._def.typeName];return s&&!i.includes(s)?[...i,s]:i},[]);return{type:n.length>1?n:n[0]}}else if(r.every(n=>n._def.typeName==="ZodLiteral"&&!n.description)){let n=r.reduce((i,o)=>{let s=typeof o._def.value;switch(s){case"string":case"number":case"boolean":return[...i,s];case"bigint":return[...i,"integer"];case"object":if(o._def.value===null)return[...i,"null"];default:return i}},[]);if(n.length===r.length){let i=n.filter((o,s,a)=>a.indexOf(o)===s);return{type:i.length>1?i:i[0],enum:r.reduce((o,s)=>o.includes(s._def.value)?o:[...o,s._def.value],[])}}}else if(r.every(n=>n._def.typeName==="ZodEnum"))return{type:"string",enum:r.reduce((n,i)=>[...n,...i._def.values.filter(o=>!n.includes(o))],[])};return dw(e,t)}var dw=(e,t)=>{let r=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((n,i)=>H(n._def,{...t,currentPath:[...t.currentPath,"anyOf",`${i}`]})).filter(n=>!!n&&(!t.strictUnions||typeof n=="object"&&Object.keys(n).length>0));return r.length?{anyOf:r}:void 0};function mw(e,t){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(e.innerType._def.typeName)&&(!e.innerType._def.checks||!e.innerType._def.checks.length))return t.target==="openApi3"?{type:ta[e.innerType._def.typeName],nullable:!0}:{type:[ta[e.innerType._def.typeName],"null"]};if(t.target==="openApi3"){let n=H(e.innerType._def,{...t,currentPath:[...t.currentPath]});return n&&"$ref"in n?{allOf:[n],nullable:!0}:n&&{...n,nullable:!0}}let r=H(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","0"]});return r&&{anyOf:[r,{type:"null"}]}}function pw(e,t){let r={type:"number"};if(!e.checks)return r;for(let n of e.checks)switch(n.kind){case"int":r.type="integer",pp(r,"type",n.message,t);break;case"min":t.target==="jsonSchema7"?n.inclusive?de(r,"minimum",n.value,n.message,t):de(r,"exclusiveMinimum",n.value,n.message,t):(n.inclusive||(r.exclusiveMinimum=!0),de(r,"minimum",n.value,n.message,t));break;case"max":t.target==="jsonSchema7"?n.inclusive?de(r,"maximum",n.value,n.message,t):de(r,"exclusiveMaximum",n.value,n.message,t):(n.inclusive||(r.exclusiveMaximum=!0),de(r,"maximum",n.value,n.message,t));break;case"multipleOf":de(r,"multipleOf",n.value,n.message,t);break}return r}function hw(e,t){let r=t.target==="openAi",n={type:"object",properties:{}},i=[],o=e.shape();for(let a in o){let u=o[a];if(u===void 0||u._def===void 0)continue;let c=cC(u);c&&r&&(u._def.typeName==="ZodOptional"&&(u=u._def.innerType),u.isNullable()||(u=u.nullable()),c=!1);let l=H(u._def,{...t,currentPath:[...t.currentPath,"properties",a],propertyPath:[...t.currentPath,"properties",a]});l!==void 0&&(n.properties[a]=l,c||i.push(a))}i.length&&(n.required=i);let s=aC(e,t);return s!==void 0&&(n.additionalProperties=s),n}function aC(e,t){if(e.catchall._def.typeName!=="ZodNever")return H(e.catchall._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]});switch(e.unknownKeys){case"passthrough":return t.allowedAdditionalProperties;case"strict":return t.rejectedAdditionalProperties;case"strip":return t.removeAdditionalStrategy==="strict"?t.allowedAdditionalProperties:t.rejectedAdditionalProperties}}function cC(e){try{return e.isOptional()}catch{return!0}}var gw=(e,t)=>{if(t.currentPath.toString()===t.propertyPath?.toString())return H(e.innerType._def,t);let r=H(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","1"]});return r?{anyOf:[{not:qe(t)},r]}:qe(t)};var _w=(e,t)=>{if(t.pipeStrategy==="input")return H(e.in._def,t);if(t.pipeStrategy==="output")return H(e.out._def,t);let r=H(e.in._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),n=H(e.out._def,{...t,currentPath:[...t.currentPath,"allOf",r?"1":"0"]});return{allOf:[r,n].filter(i=>i!==void 0)}};function yw(e,t){return H(e.type._def,t)}function vw(e,t){let n={type:"array",uniqueItems:!0,items:H(e.valueType._def,{...t,currentPath:[...t.currentPath,"items"]})};return e.minSize&&de(n,"minItems",e.minSize.value,e.minSize.message,t),e.maxSize&&de(n,"maxItems",e.maxSize.value,e.maxSize.message,t),n}function bw(e,t){return e.rest?{type:"array",minItems:e.items.length,items:e.items.map((r,n)=>H(r._def,{...t,currentPath:[...t.currentPath,"items",`${n}`]})).reduce((r,n)=>n===void 0?r:[...r,n],[]),additionalItems:H(e.rest._def,{...t,currentPath:[...t.currentPath,"additionalItems"]})}:{type:"array",minItems:e.items.length,maxItems:e.items.length,items:e.items.map((r,n)=>H(r._def,{...t,currentPath:[...t.currentPath,"items",`${n}`]})).reduce((r,n)=>n===void 0?r:[...r,n],[])}}function ww(e){return{not:qe(e)}}function kw(e){return qe(e)}var xw=(e,t)=>H(e.innerType._def,t);var Sw=(e,t,r)=>{switch(t){case E.ZodString:return vl(e,r);case E.ZodNumber:return pw(e,r);case E.ZodObject:return hw(e,r);case E.ZodBigInt:return X0(e,r);case E.ZodBoolean:return Y0();case E.ZodDate:return hp(e,r);case E.ZodUndefined:return ww(r);case E.ZodNull:return uw(r);case E.ZodArray:return Q0(e,r);case E.ZodUnion:case E.ZodDiscriminatedUnion:return fw(e,r);case E.ZodIntersection:return iw(e,r);case E.ZodTuple:return bw(e,r);case E.ZodRecord:return bl(e,r);case E.ZodLiteral:return ow(e,r);case E.ZodEnum:return nw(e);case E.ZodNativeEnum:return cw(e);case E.ZodNullable:return mw(e,r);case E.ZodOptional:return gw(e,r);case E.ZodMap:return aw(e,r);case E.ZodSet:return vw(e,r);case E.ZodLazy:return()=>e.getter()._def;case E.ZodPromise:return yw(e,r);case E.ZodNaN:case E.ZodNever:return lw(r);case E.ZodEffects:return rw(e,r);case E.ZodAny:return qe(r);case E.ZodUnknown:return kw(r);case E.ZodDefault:return tw(e,r);case E.ZodBranded:return yl(e,r);case E.ZodReadonly:return xw(e,r);case E.ZodCatch:return ew(e,r);case E.ZodPipeline:return _w(e,r);case E.ZodFunction:case E.ZodVoid:case E.ZodSymbol:return;default:return(n=>{})(t)}};function H(e,t,r=!1){let n=t.seen.get(e);if(t.override){let a=t.override?.(e,t,n,r);if(a!==J0)return a}if(n&&!r){let a=lC(n,t);if(a!==void 0)return a}let i={def:e,path:t.currentPath,jsonSchema:void 0};t.seen.set(e,i);let o=Sw(e,e.typeName,t),s=typeof o=="function"?H(o(),t):o;if(s&&uC(e,t,s),t.postProcess){let a=t.postProcess(s,e,t);return i.jsonSchema=s,a}return i.jsonSchema=s,s}var lC=(e,t)=>{switch(t.$refStrategy){case"root":return{$ref:e.path.join("/")};case"relative":return{$ref:_l(t.currentPath,e.path)};case"none":case"seen":return e.path.length<t.currentPath.length&&e.path.every((r,n)=>t.currentPath[n]===r)?(console.warn(`Recursive reference detected at ${t.currentPath.join("/")}! Defaulting to any`),qe(t)):t.$refStrategy==="seen"?qe(t):void 0}},uC=(e,t,r)=>(e.description&&(r.description=e.description,t.markdownDescription&&(r.markdownDescription=e.description)),r);var yp=(e,t)=>{let r=K0(t),n=typeof t=="object"&&t.definitions?Object.entries(t.definitions).reduce((u,[c,l])=>({...u,[c]:H(l._def,{...r,currentPath:[...r.basePath,r.definitionPath,c]},!0)??qe(r)}),{}):void 0,i=typeof t=="string"?t:t?.nameStrategy==="title"?void 0:t?.name,o=H(e._def,i===void 0?r:{...r,currentPath:[...r.basePath,r.definitionPath,i]},!1)??qe(r),s=typeof t=="object"&&t.name!==void 0&&t.nameStrategy==="title"?t.name:void 0;s!==void 0&&(o.title=s),r.flags.hasReferencedOpenAiAnyType&&(n||(n={}),n[r.openAiAnyTypeName]||(n[r.openAiAnyTypeName]={type:["string","number","integer","boolean","array","null"],items:{$ref:r.$refStrategy==="relative"?"1":[...r.basePath,r.definitionPath,r.openAiAnyTypeName].join("/")}}));let a=i===void 0?n?{...o,[r.definitionPath]:n}:o:{$ref:[...r.$refStrategy==="relative"?[]:r.basePath,r.definitionPath,i].join("/"),[r.definitionPath]:{...n,[i]:o}};return r.target==="jsonSchema7"?a.$schema="http://json-schema.org/draft-07/schema#":(r.target==="jsonSchema2019-09"||r.target==="openAi")&&(a.$schema="https://json-schema.org/draft/2019-09/schema#"),r.target==="openAi"&&("anyOf"in a||"oneOf"in a||"allOf"in a||"type"in a&&Array.isArray(a.type))&&console.warn("Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property."),a};function dC(e){return!e||e==="jsonSchema7"||e==="draft-7"?"draft-7":e==="jsonSchema2019-09"||e==="draft-2020-12"?"draft-2020-12":"draft-7"}function vp(e,t){return pr(e)?Fm(e,{target:dC(t?.target),io:t?.pipeStrategy??"input"}):yp(e,{strictUnions:t?.strictUnions??!0,pipeStrategy:t?.pipeStrategy??"input"})}function bp(e){let r=Ln(e)?.method;if(!r)throw new Error("Schema is missing a method literal");let n=gl(r);if(typeof n!="string")throw new Error("Schema method literal must be a string");return n}function wp(e,t){let r=qn(e,t);if(!r.success)throw r.error;return r.data}var fC=6e4,wl=class{constructor(t){this._options=t,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this._taskProgressTokens=new Map,this._requestResolvers=new Map,this.setNotificationHandler(Yc,r=>{this._oncancel(r)}),this.setNotificationHandler(tl,r=>{this._onprogress(r)}),this.setRequestHandler(el,r=>({})),this._taskStore=t?.taskStore,this._taskMessageQueue=t?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(rl,async(r,n)=>{let i=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!i)throw new F(U.InvalidParams,"Failed to retrieve task: Task not found");return{...i}}),this.setRequestHandler(il,async(r,n)=>{let i=async()=>{let o=r.params.taskId;if(this._taskMessageQueue){let a;for(;a=await this._taskMessageQueue.dequeue(o,n.sessionId);){if(a.type==="response"||a.type==="error"){let u=a.message,c=u.id,l=this._requestResolvers.get(c);if(l)if(this._requestResolvers.delete(c),a.type==="response")l(u);else{let d=u,p=new F(d.error.code,d.error.message,d.error.data);l(p)}else{let d=a.type==="response"?"Response":"Error";this._onerror(new Error(`${d} handler missing for request ${c}`))}continue}await this._transport?.send(a.message,{relatedRequestId:n.requestId})}}let s=await this._taskStore.getTask(o,n.sessionId);if(!s)throw new F(U.InvalidParams,`Task not found: ${o}`);if(!Un(s.status))return await this._waitForTaskUpdate(o,n.signal),await i();if(Un(s.status)){let a=await this._taskStore.getTaskResult(o,n.sessionId);return this._clearTaskQueue(o),{...a,_meta:{...a._meta,[Fn]:{taskId:o}}}}return await i()};return await i()}),this.setRequestHandler(ol,async(r,n)=>{try{let{tasks:i,nextCursor:o}=await this._taskStore.listTasks(r.params?.cursor,n.sessionId);return{tasks:i,nextCursor:o,_meta:{}}}catch(i){throw new F(U.InvalidParams,`Failed to list tasks: ${i instanceof Error?i.message:String(i)}`)}}),this.setRequestHandler(al,async(r,n)=>{try{let i=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!i)throw new F(U.InvalidParams,`Task not found: ${r.params.taskId}`);if(Un(i.status))throw new F(U.InvalidParams,`Cannot cancel task in terminal status: ${i.status}`);await this._taskStore.updateTaskStatus(r.params.taskId,"cancelled","Client cancelled task execution.",n.sessionId),this._clearTaskQueue(r.params.taskId);let o=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!o)throw new F(U.InvalidParams,`Task not found after cancellation: ${r.params.taskId}`);return{_meta:{},...o}}catch(i){throw i instanceof F?i:new F(U.InvalidRequest,`Failed to cancel task: ${i instanceof Error?i.message:String(i)}`)}}))}async _oncancel(t){if(!t.params.requestId)return;this._requestHandlerAbortControllers.get(t.params.requestId)?.abort(t.params.reason)}_setupTimeout(t,r,n,i,o=!1){this._timeoutInfo.set(t,{timeoutId:setTimeout(i,r),startTime:Date.now(),timeout:r,maxTotalTimeout:n,resetTimeoutOnProgress:o,onTimeout:i})}_resetTimeout(t){let r=this._timeoutInfo.get(t);if(!r)return!1;let n=Date.now()-r.startTime;if(r.maxTotalTimeout&&n>=r.maxTotalTimeout)throw this._timeoutInfo.delete(t),F.fromError(U.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:r.maxTotalTimeout,totalElapsed:n});return clearTimeout(r.timeoutId),r.timeoutId=setTimeout(r.onTimeout,r.timeout),!0}_cleanupTimeout(t){let r=this._timeoutInfo.get(t);r&&(clearTimeout(r.timeoutId),this._timeoutInfo.delete(t))}async connect(t){if(this._transport)throw new Error("Already connected to a transport. Call close() before connecting to a new transport, or use a separate Protocol instance per connection.");this._transport=t;let r=this.transport?.onclose;this._transport.onclose=()=>{r?.(),this._onclose()};let n=this.transport?.onerror;this._transport.onerror=o=>{n?.(o),this._onerror(o)};let i=this._transport?.onmessage;this._transport.onmessage=(o,s)=>{i?.(o,s),Bs(o)||I0(o)?this._onresponse(o):Ym(o)?this._onrequest(o,s):R0(o)?this._onnotification(o):this._onerror(new Error(`Unknown message type: ${JSON.stringify(o)}`))},await this._transport.start()}_onclose(){let t=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(let n of this._timeoutInfo.values())clearTimeout(n.timeoutId);this._timeoutInfo.clear();for(let n of this._requestHandlerAbortControllers.values())n.abort();this._requestHandlerAbortControllers.clear();let r=F.fromError(U.ConnectionClosed,"Connection closed");this._transport=void 0,this.onclose?.();for(let n of t.values())n(r)}_onerror(t){this.onerror?.(t)}_onnotification(t){let r=this._notificationHandlers.get(t.method)??this.fallbackNotificationHandler;r!==void 0&&Promise.resolve().then(()=>r(t)).catch(n=>this._onerror(new Error(`Uncaught error in notification handler: ${n}`)))}_onrequest(t,r){let n=this._requestHandlers.get(t.method)??this.fallbackRequestHandler,i=this._transport,o=t.params?._meta?.[Fn]?.taskId;if(n===void 0){let l={jsonrpc:"2.0",id:t.id,error:{code:U.MethodNotFound,message:"Method not found"}};o&&this._taskMessageQueue?this._enqueueTaskMessage(o,{type:"error",message:l,timestamp:Date.now()},i?.sessionId).catch(d=>this._onerror(new Error(`Failed to enqueue error response: ${d}`))):i?.send(l).catch(d=>this._onerror(new Error(`Failed to send an error response: ${d}`)));return}let s=new AbortController;this._requestHandlerAbortControllers.set(t.id,s);let a=O0(t.params)?t.params.task:void 0,u=this._taskStore?this.requestTaskStore(t,i?.sessionId):void 0,c={signal:s.signal,sessionId:i?.sessionId,_meta:t.params?._meta,sendNotification:async l=>{if(s.signal.aborted)return;let d={relatedRequestId:t.id};o&&(d.relatedTask={taskId:o}),await this.notification(l,d)},sendRequest:async(l,d,p)=>{if(s.signal.aborted)throw new F(U.ConnectionClosed,"Request was cancelled");let f={...p,relatedRequestId:t.id};o&&!f.relatedTask&&(f.relatedTask={taskId:o});let h=f.relatedTask?.taskId??o;return h&&u&&await u.updateTaskStatus(h,"input_required"),await this.request(l,d,f)},authInfo:r?.authInfo,requestId:t.id,requestInfo:r?.requestInfo,taskId:o,taskStore:u,taskRequestedTtl:a?.ttl,closeSSEStream:r?.closeSSEStream,closeStandaloneSSEStream:r?.closeStandaloneSSEStream};Promise.resolve().then(()=>{a&&this.assertTaskHandlerCapability(t.method)}).then(()=>n(t,c)).then(async l=>{if(s.signal.aborted)return;let d={result:l,jsonrpc:"2.0",id:t.id};o&&this._taskMessageQueue?await this._enqueueTaskMessage(o,{type:"response",message:d,timestamp:Date.now()},i?.sessionId):await i?.send(d)},async l=>{if(s.signal.aborted)return;let d={jsonrpc:"2.0",id:t.id,error:{code:Number.isSafeInteger(l.code)?l.code:U.InternalError,message:l.message??"Internal error",...l.data!==void 0&&{data:l.data}}};o&&this._taskMessageQueue?await this._enqueueTaskMessage(o,{type:"error",message:d,timestamp:Date.now()},i?.sessionId):await i?.send(d)}).catch(l=>this._onerror(new Error(`Failed to send response: ${l}`))).finally(()=>{this._requestHandlerAbortControllers.get(t.id)===s&&this._requestHandlerAbortControllers.delete(t.id)})}_onprogress(t){let{progressToken:r,...n}=t.params,i=Number(r),o=this._progressHandlers.get(i);if(!o){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(t)}`));return}let s=this._responseHandlers.get(i),a=this._timeoutInfo.get(i);if(a&&s&&a.resetTimeoutOnProgress)try{this._resetTimeout(i)}catch(u){this._responseHandlers.delete(i),this._progressHandlers.delete(i),this._cleanupTimeout(i),s(u);return}o(n)}_onresponse(t){let r=Number(t.id),n=this._requestResolvers.get(r);if(n){if(this._requestResolvers.delete(r),Bs(t))n(t);else{let s=new F(t.error.code,t.error.message,t.error.data);n(s)}return}let i=this._responseHandlers.get(r);if(i===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(t)}`));return}this._responseHandlers.delete(r),this._cleanupTimeout(r);let o=!1;if(Bs(t)&&t.result&&typeof t.result=="object"){let s=t.result;if(s.task&&typeof s.task=="object"){let a=s.task;typeof a.taskId=="string"&&(o=!0,this._taskProgressTokens.set(a.taskId,r))}}if(o||this._progressHandlers.delete(r),Bs(t))i(t);else{let s=F.fromError(t.error.code,t.error.message,t.error.data);i(s)}}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(t,r,n){let{task:i}=n??{};if(!i){try{yield{type:"result",result:await this.request(t,r,n)}}catch(s){yield{type:"error",error:s instanceof F?s:new F(U.InternalError,String(s))}}return}let o;try{let s=await this.request(t,Ro,n);if(s.task)o=s.task.taskId,yield{type:"taskCreated",task:s.task};else throw new F(U.InternalError,"Task creation did not return a task");for(;;){let a=await this.getTask({taskId:o},n);if(yield{type:"taskStatus",task:a},Un(a.status)){a.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:o},r,n)}:a.status==="failed"?yield{type:"error",error:new F(U.InternalError,`Task ${o} failed`)}:a.status==="cancelled"&&(yield{type:"error",error:new F(U.InternalError,`Task ${o} was cancelled`)});return}if(a.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:o},r,n)};return}let u=a.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(c=>setTimeout(c,u)),n?.signal?.throwIfAborted()}}catch(s){yield{type:"error",error:s instanceof F?s:new F(U.InternalError,String(s))}}}request(t,r,n){let{relatedRequestId:i,resumptionToken:o,onresumptiontoken:s,task:a,relatedTask:u}=n??{};return new Promise((c,l)=>{let d=v=>{l(v)};if(!this._transport){d(new Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(t.method),a&&this.assertTaskCapability(t.method)}catch(v){d(v);return}n?.signal?.throwIfAborted();let p=this._requestMessageId++,f={...t,jsonrpc:"2.0",id:p};n?.onprogress&&(this._progressHandlers.set(p,n.onprogress),f.params={...t.params,_meta:{...t.params?._meta||{},progressToken:p}}),a&&(f.params={...f.params,task:a}),u&&(f.params={...f.params,_meta:{...f.params?._meta||{},[Fn]:u}});let h=v=>{this._responseHandlers.delete(p),this._progressHandlers.delete(p),this._cleanupTimeout(p),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:p,reason:String(v)}},{relatedRequestId:i,resumptionToken:o,onresumptiontoken:s}).catch(w=>this._onerror(new Error(`Failed to send cancellation: ${w}`)));let b=v instanceof F?v:new F(U.RequestTimeout,String(v));l(b)};this._responseHandlers.set(p,v=>{if(!n?.signal?.aborted){if(v instanceof Error)return l(v);try{let b=qn(r,v.result);b.success?c(b.data):l(b.error)}catch(b){l(b)}}}),n?.signal?.addEventListener("abort",()=>{h(n?.signal?.reason)});let m=n?.timeout??fC,g=()=>h(F.fromError(U.RequestTimeout,"Request timed out",{timeout:m}));this._setupTimeout(p,m,n?.maxTotalTimeout,g,n?.resetTimeoutOnProgress??!1);let y=u?.taskId;if(y){let v=b=>{let w=this._responseHandlers.get(p);w?w(b):this._onerror(new Error(`Response handler missing for side-channeled request ${p}`))};this._requestResolvers.set(p,v),this._enqueueTaskMessage(y,{type:"request",message:f,timestamp:Date.now()}).catch(b=>{this._cleanupTimeout(p),l(b)})}else this._transport.send(f,{relatedRequestId:i,resumptionToken:o,onresumptiontoken:s}).catch(v=>{this._cleanupTimeout(p),l(v)})})}async getTask(t,r){return this.request({method:"tasks/get",params:t},nl,r)}async getTaskResult(t,r,n){return this.request({method:"tasks/result",params:t},r,n)}async listTasks(t,r){return this.request({method:"tasks/list",params:t},sl,r)}async cancelTask(t,r){return this.request({method:"tasks/cancel",params:t},M0,r)}async notification(t,r){if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(t.method);let n=r?.relatedTask?.taskId;if(n){let a={...t,jsonrpc:"2.0",params:{...t.params,_meta:{...t.params?._meta||{},[Fn]:r.relatedTask}}};await this._enqueueTaskMessage(n,{type:"notification",message:a,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(t.method)&&!t.params&&!r?.relatedRequestId&&!r?.relatedTask){if(this._pendingDebouncedNotifications.has(t.method))return;this._pendingDebouncedNotifications.add(t.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(t.method),!this._transport)return;let a={...t,jsonrpc:"2.0"};r?.relatedTask&&(a={...a,params:{...a.params,_meta:{...a.params?._meta||{},[Fn]:r.relatedTask}}}),this._transport?.send(a,r).catch(u=>this._onerror(u))});return}let s={...t,jsonrpc:"2.0"};r?.relatedTask&&(s={...s,params:{...s.params,_meta:{...s.params?._meta||{},[Fn]:r.relatedTask}}}),await this._transport.send(s,r)}setRequestHandler(t,r){let n=bp(t);this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(i,o)=>{let s=wp(t,i);return Promise.resolve(r(s,o))})}removeRequestHandler(t){this._requestHandlers.delete(t)}assertCanSetRequestHandler(t){if(this._requestHandlers.has(t))throw new Error(`A request handler for ${t} already exists, which would be overridden`)}setNotificationHandler(t,r){let n=bp(t);this._notificationHandlers.set(n,i=>{let o=wp(t,i);return Promise.resolve(r(o))})}removeNotificationHandler(t){this._notificationHandlers.delete(t)}_cleanupTaskProgressHandler(t){let r=this._taskProgressTokens.get(t);r!==void 0&&(this._progressHandlers.delete(r),this._taskProgressTokens.delete(t))}async _enqueueTaskMessage(t,r,n){if(!this._taskStore||!this._taskMessageQueue)throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");let i=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(t,r,n,i)}async _clearTaskQueue(t,r){if(this._taskMessageQueue){let n=await this._taskMessageQueue.dequeueAll(t,r);for(let i of n)if(i.type==="request"&&Ym(i.message)){let o=i.message.id,s=this._requestResolvers.get(o);s?(s(new F(U.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(o)):this._onerror(new Error(`Resolver missing for request ${o} during task ${t} cleanup`))}}}async _waitForTaskUpdate(t,r){let n=this._options?.defaultTaskPollInterval??1e3;try{let i=await this._taskStore?.getTask(t);i?.pollInterval&&(n=i.pollInterval)}catch{}return new Promise((i,o)=>{if(r.aborted){o(new F(U.InvalidRequest,"Request cancelled"));return}let s=setTimeout(i,n);r.addEventListener("abort",()=>{clearTimeout(s),o(new F(U.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(t,r){let n=this._taskStore;if(!n)throw new Error("No task store configured");return{createTask:async i=>{if(!t)throw new Error("No request provided");return await n.createTask(i,t.id,{method:t.method,params:t.params},r)},getTask:async i=>{let o=await n.getTask(i,r);if(!o)throw new F(U.InvalidParams,"Failed to retrieve task: Task not found");return o},storeTaskResult:async(i,o,s)=>{await n.storeTaskResult(i,o,s,r);let a=await n.getTask(i,r);if(a){let u=Qs.parse({method:"notifications/tasks/status",params:a});await this.notification(u),Un(a.status)&&this._cleanupTaskProgressHandler(i)}},getTaskResult:i=>n.getTaskResult(i,r),updateTaskStatus:async(i,o,s)=>{let a=await n.getTask(i,r);if(!a)throw new F(U.InvalidParams,`Task "${i}" not found - it may have been cleaned up`);if(Un(a.status))throw new F(U.InvalidParams,`Cannot update task "${i}" from terminal status "${a.status}" to "${o}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await n.updateTaskStatus(i,o,s,r);let u=await n.getTask(i,r);if(u){let c=Qs.parse({method:"notifications/tasks/status",params:u});await this.notification(c),Un(u.status)&&this._cleanupTaskProgressHandler(i)}},listTasks:i=>n.listTasks(i,r)}}};function Tw(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function $w(e,t){let r={...e};for(let n in t){let i=n,o=t[i];if(o===void 0)continue;let s=r[i];Tw(s)&&Tw(o)?r[i]={...s,...o}:r[i]=o}return r}var fS=Ra(sg(),1),mS=Ra(dS(),1);function rM(){let e=new fS.default({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return(0,mS.default)(e),e}var iu=class{constructor(t){this._ajv=t??rM()}getValidator(t){let r="$id"in t&&typeof t.$id=="string"?this._ajv.getSchema(t.$id)??this._ajv.compile(t):this._ajv.compile(t);return n=>r(n)?{valid:!0,data:n,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:this._ajv.errorsText(r.errors)}}};var ou=class{constructor(t){this._server=t}requestStream(t,r,n){return this._server.requestStream(t,r,n)}createMessageStream(t,r){let n=this._server.getClientCapabilities();if((t.tools||t.toolChoice)&&!n?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(t.messages.length>0){let i=t.messages[t.messages.length-1],o=Array.isArray(i.content)?i.content:[i.content],s=o.some(l=>l.type==="tool_result"),a=t.messages.length>1?t.messages[t.messages.length-2]:void 0,u=a?Array.isArray(a.content)?a.content:[a.content]:[],c=u.some(l=>l.type==="tool_use");if(s){if(o.some(l=>l.type!=="tool_result"))throw new Error("The last message must contain only tool_result content if any is present");if(!c)throw new Error("tool_result blocks are not matching any tool_use from the previous message")}if(c){let l=new Set(u.filter(p=>p.type==="tool_use").map(p=>p.id)),d=new Set(o.filter(p=>p.type==="tool_result").map(p=>p.toolUseId));if(l.size!==d.size||![...l].every(p=>d.has(p)))throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}return this.requestStream({method:"sampling/createMessage",params:t},ea,r)}elicitInputStream(t,r){let n=this._server.getClientCapabilities(),i=t.mode??"form";switch(i){case"url":{if(!n?.elicitation?.url)throw new Error("Client does not support url elicitation.");break}case"form":{if(!n?.elicitation?.form)throw new Error("Client does not support form elicitation.");break}}let o=i==="form"&&t.mode===void 0?{...t,mode:"form"}:t;return this.requestStream({method:"elicitation/create",params:o},Do,r)}async getTask(t,r){return this._server.getTask({taskId:t},r)}async getTaskResult(t,r,n){return this._server.getTaskResult({taskId:t},r,n)}async listTasks(t,r){return this._server.listTasks(t?{cursor:t}:void 0,r)}async cancelTask(t,r){return this._server.cancelTask({taskId:t},r)}};function pS(e,t,r){if(!e)throw new Error(`${r} does not support task creation (required for ${t})`);switch(t){case"tools/call":if(!e.tools?.call)throw new Error(`${r} does not support task creation for tools/call (required for ${t})`);break;default:break}}function hS(e,t,r){if(!e)throw new Error(`${r} does not support task creation (required for ${t})`);switch(t){case"sampling/createMessage":if(!e.sampling?.createMessage)throw new Error(`${r} does not support task creation for sampling/createMessage (required for ${t})`);break;case"elicitation/create":if(!e.elicitation?.create)throw new Error(`${r} does not support task creation for elicitation/create (required for ${t})`);break;default:break}}var su=class extends wl{constructor(t,r){super(r),this._serverInfo=t,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(Ys.options.map((n,i)=>[n,i])),this.isMessageIgnored=(n,i)=>{let o=this._loggingLevels.get(i);return o?this.LOG_LEVEL_SEVERITY.get(n)<this.LOG_LEVEL_SEVERITY.get(o):!1},this._capabilities=r?.capabilities??{},this._instructions=r?.instructions,this._jsonSchemaValidator=r?.jsonSchemaValidator??new iu,this.setRequestHandler(rp,n=>this._oninitialize(n)),this.setNotificationHandler(np,()=>this.oninitialized?.()),this._capabilities.logging&&this.setRequestHandler(up,async(n,i)=>{let o=i.sessionId||i.requestInfo?.headers["mcp-session-id"]||void 0,{level:s}=n.params,a=Ys.safeParse(s);return a.success&&this._loggingLevels.set(o,a.data),{}})}get experimental(){return this._experimental||(this._experimental={tasks:new ou(this)}),this._experimental}registerCapabilities(t){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=$w(this._capabilities,t)}setRequestHandler(t,r){let i=Ln(t)?.method;if(!i)throw new Error("Schema is missing a method literal");let o;if(pr(i)){let a=i;o=a._zod?.def?.value??a.value}else{let a=i;o=a._def?.value??a.value}if(typeof o!="string")throw new Error("Schema method literal must be a string");if(o==="tools/call"){let a=async(u,c)=>{let l=qn(Mo,u);if(!l.success){let h=l.error instanceof Error?l.error.message:String(l.error);throw new F(U.InvalidParams,`Invalid tools/call request: ${h}`)}let{params:d}=l.data,p=await Promise.resolve(r(u,c));if(d.task){let h=qn(Ro,p);if(!h.success){let m=h.error instanceof Error?h.error.message:String(h.error);throw new F(U.InvalidParams,`Invalid task creation result: ${m}`)}return h.data}let f=qn(fl,p);if(!f.success){let h=f.error instanceof Error?f.error.message:String(f.error);throw new F(U.InvalidParams,`Invalid tools/call result: ${h}`)}return f.data};return super.setRequestHandler(t,a)}return super.setRequestHandler(t,r)}assertCapabilityForMethod(t){switch(t){case"sampling/createMessage":if(!this._clientCapabilities?.sampling)throw new Error(`Client does not support sampling (required for ${t})`);break;case"elicitation/create":if(!this._clientCapabilities?.elicitation)throw new Error(`Client does not support elicitation (required for ${t})`);break;case"roots/list":if(!this._clientCapabilities?.roots)throw new Error(`Client does not support listing roots (required for ${t})`);break;case"ping":break}}assertNotificationCapability(t){switch(t){case"notifications/message":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${t})`);break;case"notifications/resources/updated":case"notifications/resources/list_changed":if(!this._capabilities.resources)throw new Error(`Server does not support notifying about resources (required for ${t})`);break;case"notifications/tools/list_changed":if(!this._capabilities.tools)throw new Error(`Server does not support notifying of tool list changes (required for ${t})`);break;case"notifications/prompts/list_changed":if(!this._capabilities.prompts)throw new Error(`Server does not support notifying of prompt list changes (required for ${t})`);break;case"notifications/elicitation/complete":if(!this._clientCapabilities?.elicitation?.url)throw new Error(`Client does not support URL elicitation (required for ${t})`);break;case"notifications/cancelled":break;case"notifications/progress":break}}assertRequestHandlerCapability(t){if(this._capabilities)switch(t){case"completion/complete":if(!this._capabilities.completions)throw new Error(`Server does not support completions (required for ${t})`);break;case"logging/setLevel":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${t})`);break;case"prompts/get":case"prompts/list":if(!this._capabilities.prompts)throw new Error(`Server does not support prompts (required for ${t})`);break;case"resources/list":case"resources/templates/list":case"resources/read":if(!this._capabilities.resources)throw new Error(`Server does not support resources (required for ${t})`);break;case"tools/call":case"tools/list":if(!this._capabilities.tools)throw new Error(`Server does not support tools (required for ${t})`);break;case"tasks/get":case"tasks/list":case"tasks/result":case"tasks/cancel":if(!this._capabilities.tasks)throw new Error(`Server does not support tasks capability (required for ${t})`);break;case"ping":case"initialize":break}}assertTaskCapability(t){hS(this._clientCapabilities?.tasks?.requests,t,"Client")}assertTaskHandlerCapability(t){this._capabilities&&pS(this._capabilities.tasks?.requests,t,"Server")}async _oninitialize(t){let r=t.params.protocolVersion;return this._clientCapabilities=t.params.capabilities,this._clientVersion=t.params.clientInfo,{protocolVersion:E0.includes(r)?r:Qm,capabilities:this.getCapabilities(),serverInfo:this._serverInfo,...this._instructions&&{instructions:this._instructions}}}getClientCapabilities(){return this._clientCapabilities}getClientVersion(){return this._clientVersion}getCapabilities(){return this._capabilities}async ping(){return this.request({method:"ping"},Xc)}async createMessage(t,r){if((t.tools||t.toolChoice)&&!this._clientCapabilities?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(t.messages.length>0){let n=t.messages[t.messages.length-1],i=Array.isArray(n.content)?n.content:[n.content],o=i.some(c=>c.type==="tool_result"),s=t.messages.length>1?t.messages[t.messages.length-2]:void 0,a=s?Array.isArray(s.content)?s.content:[s.content]:[],u=a.some(c=>c.type==="tool_use");if(o){if(i.some(c=>c.type!=="tool_result"))throw new Error("The last message must contain only tool_result content if any is present");if(!u)throw new Error("tool_result blocks are not matching any tool_use from the previous message")}if(u){let c=new Set(a.filter(d=>d.type==="tool_use").map(d=>d.id)),l=new Set(i.filter(d=>d.type==="tool_result").map(d=>d.toolUseId));if(c.size!==l.size||![...c].every(d=>l.has(d)))throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}return t.tools?this.request({method:"sampling/createMessage",params:t},dp,r):this.request({method:"sampling/createMessage",params:t},ea,r)}async elicitInput(t,r){switch(t.mode??"form"){case"url":{if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support url elicitation.");let i=t;return this.request({method:"elicitation/create",params:i},Do,r)}case"form":{if(!this._clientCapabilities?.elicitation?.form)throw new Error("Client does not support form elicitation.");let i=t.mode==="form"?t:{...t,mode:"form"},o=await this.request({method:"elicitation/create",params:i},Do,r);if(o.action==="accept"&&o.content&&i.requestedSchema)try{let a=this._jsonSchemaValidator.getValidator(i.requestedSchema)(o.content);if(!a.valid)throw new F(U.InvalidParams,`Elicitation response content does not match requested schema: ${a.errorMessage}`)}catch(s){throw s instanceof F?s:new F(U.InternalError,`Error validating elicitation response: ${s instanceof Error?s.message:String(s)}`)}return o}}}createElicitationCompletionNotifier(t,r){if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support URL elicitation (required for notifications/elicitation/complete)");return()=>this.notification({method:"notifications/elicitation/complete",params:{elicitationId:t}},r)}async listRoots(t,r){return this.request({method:"roots/list",params:t},fp,r)}async sendLoggingMessage(t,r){if(this._capabilities.logging&&!this.isMessageIgnored(t.level,r))return this.notification({method:"notifications/message",params:t})}async sendResourceUpdated(t){return this.notification({method:"notifications/resources/updated",params:t})}async sendResourceListChanged(){return this.notification({method:"notifications/resources/list_changed"})}async sendToolListChanged(){return this.notification({method:"notifications/tools/list_changed"})}async sendPromptListChanged(){return this.notification({method:"notifications/prompts/list_changed"})}};var _S=Symbol.for("mcp.completable");function pg(e){return!!e&&typeof e=="object"&&_S in e}function yS(e){return e[_S]?.complete}var gS;(function(e){e.Completable="McpCompletable"})(gS||(gS={}));var nM=/^[A-Za-z0-9._-]{1,128}$/;function iM(e){let t=[];if(e.length===0)return{isValid:!1,warnings:["Tool name cannot be empty"]};if(e.length>128)return{isValid:!1,warnings:[`Tool name exceeds maximum length of 128 characters (current: ${e.length})`]};if(e.includes(" ")&&t.push("Tool name contains spaces, which may cause parsing issues"),e.includes(",")&&t.push("Tool name contains commas, which may cause parsing issues"),(e.startsWith("-")||e.endsWith("-"))&&t.push("Tool name starts or ends with a dash, which may cause parsing issues in some contexts"),(e.startsWith(".")||e.endsWith("."))&&t.push("Tool name starts or ends with a dot, which may cause parsing issues in some contexts"),!nM.test(e)){let r=e.split("").filter(n=>!/[A-Za-z0-9._-]/.test(n)).filter((n,i,o)=>o.indexOf(n)===i);return t.push(`Tool name contains invalid characters: ${r.map(n=>`"${n}"`).join(", ")}`,"Allowed characters are: A-Z, a-z, 0-9, underscore (_), dash (-), and dot (.)"),{isValid:!1,warnings:t}}return{isValid:!0,warnings:t}}function oM(e,t){if(t.length>0){console.warn(`Tool name validation warning for "${e}":`);for(let r of t)console.warn(` - ${r}`);console.warn("Tool registration will proceed, but this may cause compatibility issues."),console.warn("Consider updating the tool name to conform to the MCP tool naming standard."),console.warn("See SEP: Specify Format for Tool Names (https://github.com/modelcontextprotocol/modelcontextprotocol/issues/986) for more details.")}}function hg(e){let t=iM(e);return oM(e,t.warnings),t.isValid}var au=class{constructor(t){this._mcpServer=t}registerToolTask(t,r,n){let i={taskSupport:"required",...r.execution};if(i.taskSupport==="forbidden")throw new Error(`Cannot register task-based tool '${t}' with taskSupport 'forbidden'. Use registerTool() instead.`);return this._mcpServer._createRegisteredTool(t,r.title,r.description,r.inputSchema,r.outputSchema,r.annotations,i,r._meta,n)}};var cu=class{constructor(t,r){this._registeredResources={},this._registeredResourceTemplates={},this._registeredTools={},this._registeredPrompts={},this._toolHandlersInitialized=!1,this._completionHandlerInitialized=!1,this._resourceHandlersInitialized=!1,this._promptHandlersInitialized=!1,this.server=new su(t,r)}get experimental(){return this._experimental||(this._experimental={tasks:new au(this)}),this._experimental}async connect(t){return await this.server.connect(t)}async close(){await this.server.close()}setToolRequestHandlers(){this._toolHandlersInitialized||(this.server.assertCanSetRequestHandler(Yn(dl)),this.server.assertCanSetRequestHandler(Yn(Mo)),this.server.registerCapabilities({tools:{listChanged:!0}}),this.server.setRequestHandler(dl,()=>({tools:Object.entries(this._registeredTools).filter(([,t])=>t.enabled).map(([t,r])=>{let n={name:t,title:r.title,description:r.description,inputSchema:(()=>{let i=Go(r.inputSchema);return i?vp(i,{strictUnions:!0,pipeStrategy:"input"}):sM})(),annotations:r.annotations,execution:r.execution,_meta:r._meta};if(r.outputSchema){let i=Go(r.outputSchema);i&&(n.outputSchema=vp(i,{strictUnions:!0,pipeStrategy:"output"}))}return n})})),this.server.setRequestHandler(Mo,async(t,r)=>{try{let n=this._registeredTools[t.params.name];if(!n)throw new F(U.InvalidParams,`Tool ${t.params.name} not found`);if(!n.enabled)throw new F(U.InvalidParams,`Tool ${t.params.name} disabled`);let i=!!t.params.task,o=n.execution?.taskSupport,s="createTask"in n.handler;if((o==="required"||o==="optional")&&!s)throw new F(U.InternalError,`Tool ${t.params.name} has taskSupport '${o}' but was not registered with registerToolTask`);if(o==="required"&&!i)throw new F(U.MethodNotFound,`Tool ${t.params.name} requires task augmentation (taskSupport: 'required')`);if(o==="optional"&&!i&&s)return await this.handleAutomaticTaskPolling(n,t,r);let a=await this.validateToolInput(n,t.params.arguments,t.params.name),u=await this.executeToolHandler(n,a,r);return i||await this.validateToolOutput(n,u,t.params.name),u}catch(n){if(n instanceof F&&n.code===U.UrlElicitationRequired)throw n;return this.createToolError(n instanceof Error?n.message:String(n))}}),this._toolHandlersInitialized=!0)}createToolError(t){return{content:[{type:"text",text:t}],isError:!0}}async validateToolInput(t,r,n){if(!t.inputSchema)return;let o=Go(t.inputSchema)??t.inputSchema,s=await pl(o,r);if(!s.success){let a="error"in s?s.error:"Unknown error",u=hl(a);throw new F(U.InvalidParams,`Input validation error: Invalid arguments for tool ${n}: ${u}`)}return s.data}async validateToolOutput(t,r,n){if(!t.outputSchema||!("content"in r)||r.isError)return;if(!r.structuredContent)throw new F(U.InvalidParams,`Output validation error: Tool ${n} has an output schema but no structured content was provided`);let i=Go(t.outputSchema),o=await pl(i,r.structuredContent);if(!o.success){let s="error"in o?o.error:"Unknown error",a=hl(s);throw new F(U.InvalidParams,`Output validation error: Invalid structured content for tool ${n}: ${a}`)}}async executeToolHandler(t,r,n){let i=t.handler;if("createTask"in i){if(!n.taskStore)throw new Error("No task store provided.");let s={...n,taskStore:n.taskStore};if(t.inputSchema){let a=i;return await Promise.resolve(a.createTask(r,s))}else{let a=i;return await Promise.resolve(a.createTask(s))}}if(t.inputSchema){let s=i;return await Promise.resolve(s(r,n))}else{let s=i;return await Promise.resolve(s(n))}}async handleAutomaticTaskPolling(t,r,n){if(!n.taskStore)throw new Error("No task store provided for task-capable tool.");let i=await this.validateToolInput(t,r.params.arguments,r.params.name),o=t.handler,s={...n,taskStore:n.taskStore},a=i?await Promise.resolve(o.createTask(i,s)):await Promise.resolve(o.createTask(s)),u=a.task.taskId,c=a.task,l=c.pollInterval??5e3;for(;c.status!=="completed"&&c.status!=="failed"&&c.status!=="cancelled";){await new Promise(p=>setTimeout(p,l));let d=await n.taskStore.getTask(u);if(!d)throw new F(U.InternalError,`Task ${u} not found during polling`);c=d}return await n.taskStore.getTaskResult(u)}setCompletionRequestHandler(){this._completionHandlerInitialized||(this.server.assertCanSetRequestHandler(Yn(ml)),this.server.registerCapabilities({completions:{}}),this.server.setRequestHandler(ml,async t=>{switch(t.params.ref.type){case"ref/prompt":return L0(t),this.handlePromptCompletion(t,t.params.ref);case"ref/resource":return U0(t),this.handleResourceCompletion(t,t.params.ref);default:throw new F(U.InvalidParams,`Invalid completion reference: ${t.params.ref}`)}}),this._completionHandlerInitialized=!0)}async handlePromptCompletion(t,r){let n=this._registeredPrompts[r.name];if(!n)throw new F(U.InvalidParams,`Prompt ${r.name} not found`);if(!n.enabled)throw new F(U.InvalidParams,`Prompt ${r.name} disabled`);if(!n.argsSchema)return Pa;let o=Ln(n.argsSchema)?.[t.params.argument.name];if(!pg(o))return Pa;let s=yS(o);if(!s)return Pa;let a=await s(t.params.argument.value,t.params.context);return bS(a)}async handleResourceCompletion(t,r){let n=Object.values(this._registeredResourceTemplates).find(s=>s.resourceTemplate.uriTemplate.toString()===r.uri);if(!n){if(this._registeredResources[r.uri])return Pa;throw new F(U.InvalidParams,`Resource template ${t.params.ref.uri} not found`)}let i=n.resourceTemplate.completeCallback(t.params.argument.name);if(!i)return Pa;let o=await i(t.params.argument.value,t.params.context);return bS(o)}setResourceRequestHandlers(){this._resourceHandlersInitialized||(this.server.assertCanSetRequestHandler(Yn(jo)),this.server.assertCanSetRequestHandler(Yn(No)),this.server.assertCanSetRequestHandler(Yn(cl)),this.server.registerCapabilities({resources:{listChanged:!0}}),this.server.setRequestHandler(jo,async(t,r)=>{let n=Object.entries(this._registeredResources).filter(([o,s])=>s.enabled).map(([o,s])=>({uri:o,name:s.name,...s.metadata})),i=[];for(let o of Object.values(this._registeredResourceTemplates)){if(!o.resourceTemplate.listCallback)continue;let s=await o.resourceTemplate.listCallback(r);for(let a of s.resources)i.push({...o.metadata,...a})}return{resources:[...n,...i]}}),this.server.setRequestHandler(No,async()=>({resourceTemplates:Object.entries(this._registeredResourceTemplates).map(([r,n])=>({name:r,uriTemplate:n.resourceTemplate.uriTemplate.toString(),...n.metadata}))})),this.server.setRequestHandler(cl,async(t,r)=>{let n=new URL(t.params.uri),i=this._registeredResources[n.toString()];if(i){if(!i.enabled)throw new F(U.InvalidParams,`Resource ${n} disabled`);return i.readCallback(n,r)}for(let o of Object.values(this._registeredResourceTemplates)){let s=o.resourceTemplate.uriTemplate.match(n.toString());if(s)return o.readCallback(n,s,r)}throw new F(U.InvalidParams,`Resource ${n} not found`)}),this._resourceHandlersInitialized=!0)}setPromptRequestHandlers(){this._promptHandlersInitialized||(this.server.assertCanSetRequestHandler(Yn(ll)),this.server.assertCanSetRequestHandler(Yn(ul)),this.server.registerCapabilities({prompts:{listChanged:!0}}),this.server.setRequestHandler(ll,()=>({prompts:Object.entries(this._registeredPrompts).filter(([,t])=>t.enabled).map(([t,r])=>({name:t,title:r.title,description:r.description,arguments:r.argsSchema?aM(r.argsSchema):void 0}))})),this.server.setRequestHandler(ul,async(t,r)=>{let n=this._registeredPrompts[t.params.name];if(!n)throw new F(U.InvalidParams,`Prompt ${t.params.name} not found`);if(!n.enabled)throw new F(U.InvalidParams,`Prompt ${t.params.name} disabled`);if(n.argsSchema){let i=Go(n.argsSchema),o=await pl(i,t.params.arguments);if(!o.success){let u="error"in o?o.error:"Unknown error",c=hl(u);throw new F(U.InvalidParams,`Invalid arguments for prompt ${t.params.name}: ${c}`)}let s=o.data,a=n.callback;return await Promise.resolve(a(s,r))}else{let i=n.callback;return await Promise.resolve(i(r))}}),this._promptHandlersInitialized=!0)}resource(t,r,...n){let i;typeof n[0]=="object"&&(i=n.shift());let o=n[0];if(typeof r=="string"){if(this._registeredResources[r])throw new Error(`Resource ${r} is already registered`);let s=this._createRegisteredResource(t,void 0,r,i,o);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),s}else{if(this._registeredResourceTemplates[t])throw new Error(`Resource template ${t} is already registered`);let s=this._createRegisteredResourceTemplate(t,void 0,r,i,o);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),s}}registerResource(t,r,n,i){if(typeof r=="string"){if(this._registeredResources[r])throw new Error(`Resource ${r} is already registered`);let o=this._createRegisteredResource(t,n.title,r,n,i);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),o}else{if(this._registeredResourceTemplates[t])throw new Error(`Resource template ${t} is already registered`);let o=this._createRegisteredResourceTemplate(t,n.title,r,n,i);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),o}}_createRegisteredResource(t,r,n,i,o){let s={name:t,title:r,metadata:i,readCallback:o,enabled:!0,disable:()=>s.update({enabled:!1}),enable:()=>s.update({enabled:!0}),remove:()=>s.update({uri:null}),update:a=>{typeof a.uri<"u"&&a.uri!==n&&(delete this._registeredResources[n],a.uri&&(this._registeredResources[a.uri]=s)),typeof a.name<"u"&&(s.name=a.name),typeof a.title<"u"&&(s.title=a.title),typeof a.metadata<"u"&&(s.metadata=a.metadata),typeof a.callback<"u"&&(s.readCallback=a.callback),typeof a.enabled<"u"&&(s.enabled=a.enabled),this.sendResourceListChanged()}};return this._registeredResources[n]=s,s}_createRegisteredResourceTemplate(t,r,n,i,o){let s={resourceTemplate:n,title:r,metadata:i,readCallback:o,enabled:!0,disable:()=>s.update({enabled:!1}),enable:()=>s.update({enabled:!0}),remove:()=>s.update({name:null}),update:c=>{typeof c.name<"u"&&c.name!==t&&(delete this._registeredResourceTemplates[t],c.name&&(this._registeredResourceTemplates[c.name]=s)),typeof c.title<"u"&&(s.title=c.title),typeof c.template<"u"&&(s.resourceTemplate=c.template),typeof c.metadata<"u"&&(s.metadata=c.metadata),typeof c.callback<"u"&&(s.readCallback=c.callback),typeof c.enabled<"u"&&(s.enabled=c.enabled),this.sendResourceListChanged()}};this._registeredResourceTemplates[t]=s;let a=n.uriTemplate.variableNames;return Array.isArray(a)&&a.some(c=>!!n.completeCallback(c))&&this.setCompletionRequestHandler(),s}_createRegisteredPrompt(t,r,n,i,o){let s={title:r,description:n,argsSchema:i===void 0?void 0:Fi(i),callback:o,enabled:!0,disable:()=>s.update({enabled:!1}),enable:()=>s.update({enabled:!0}),remove:()=>s.update({name:null}),update:a=>{typeof a.name<"u"&&a.name!==t&&(delete this._registeredPrompts[t],a.name&&(this._registeredPrompts[a.name]=s)),typeof a.title<"u"&&(s.title=a.title),typeof a.description<"u"&&(s.description=a.description),typeof a.argsSchema<"u"&&(s.argsSchema=Fi(a.argsSchema)),typeof a.callback<"u"&&(s.callback=a.callback),typeof a.enabled<"u"&&(s.enabled=a.enabled),this.sendPromptListChanged()}};return this._registeredPrompts[t]=s,i&&Object.values(i).some(u=>{let c=u instanceof qt?u._def?.innerType:u;return pg(c)})&&this.setCompletionRequestHandler(),s}_createRegisteredTool(t,r,n,i,o,s,a,u,c){hg(t);let l={title:r,description:n,inputSchema:vS(i),outputSchema:vS(o),annotations:s,execution:a,_meta:u,handler:c,enabled:!0,disable:()=>l.update({enabled:!1}),enable:()=>l.update({enabled:!0}),remove:()=>l.update({name:null}),update:d=>{typeof d.name<"u"&&d.name!==t&&(typeof d.name=="string"&&hg(d.name),delete this._registeredTools[t],d.name&&(this._registeredTools[d.name]=l)),typeof d.title<"u"&&(l.title=d.title),typeof d.description<"u"&&(l.description=d.description),typeof d.paramsSchema<"u"&&(l.inputSchema=Fi(d.paramsSchema)),typeof d.outputSchema<"u"&&(l.outputSchema=Fi(d.outputSchema)),typeof d.callback<"u"&&(l.handler=d.callback),typeof d.annotations<"u"&&(l.annotations=d.annotations),typeof d._meta<"u"&&(l._meta=d._meta),typeof d.enabled<"u"&&(l.enabled=d.enabled),this.sendToolListChanged()}};return this._registeredTools[t]=l,this.setToolRequestHandlers(),this.sendToolListChanged(),l}tool(t,...r){if(this._registeredTools[t])throw new Error(`Tool ${t} is already registered`);let n,i,o,s;if(typeof r[0]=="string"&&(n=r.shift()),r.length>1){let u=r[0];if(gg(u))i=r.shift(),r.length>1&&typeof r[0]=="object"&&r[0]!==null&&!gg(r[0])&&(s=r.shift());else if(typeof u=="object"&&u!==null){if(Object.values(u).some(c=>typeof c=="object"&&c!==null))throw new Error(`Tool ${t} expected a Zod schema or ToolAnnotations, but received an unrecognized object`);s=r.shift()}}let a=r[0];return this._createRegisteredTool(t,void 0,n,i,o,s,{taskSupport:"forbidden"},void 0,a)}registerTool(t,r,n){if(this._registeredTools[t])throw new Error(`Tool ${t} is already registered`);let{title:i,description:o,inputSchema:s,outputSchema:a,annotations:u,_meta:c}=r;return this._createRegisteredTool(t,i,o,s,a,u,{taskSupport:"forbidden"},c,n)}prompt(t,...r){if(this._registeredPrompts[t])throw new Error(`Prompt ${t} is already registered`);let n;typeof r[0]=="string"&&(n=r.shift());let i;r.length>1&&(i=r.shift());let o=r[0],s=this._createRegisteredPrompt(t,void 0,n,i,o);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),s}registerPrompt(t,r,n){if(this._registeredPrompts[t])throw new Error(`Prompt ${t} is already registered`);let{title:i,description:o,argsSchema:s}=r,a=this._createRegisteredPrompt(t,i,o,s,n);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),a}isConnected(){return this.server.transport!==void 0}async sendLoggingMessage(t,r){return this.server.sendLoggingMessage(t,r)}sendResourceListChanged(){this.isConnected()&&this.server.sendResourceListChanged()}sendToolListChanged(){this.isConnected()&&this.server.sendToolListChanged()}sendPromptListChanged(){this.isConnected()&&this.server.sendPromptListChanged()}};var sM={type:"object",properties:{}};function wS(e){return e!==null&&typeof e=="object"&&"parse"in e&&typeof e.parse=="function"&&"safeParse"in e&&typeof e.safeParse=="function"}function kS(e){return"_def"in e||"_zod"in e||wS(e)}function gg(e){return typeof e!="object"||e===null||kS(e)?!1:Object.keys(e).length===0?!0:Object.values(e).some(wS)}function vS(e){if(e){if(gg(e))return Fi(e);if(!kS(e))throw new Error("inputSchema must be a Zod schema or raw shape, received an unrecognized object");return e}}function aM(e){let t=Ln(e);return t?Object.entries(t).map(([r,n])=>{let i=V0(n),o=B0(n);return{name:r,description:i,required:!o}}):[]}function Yn(e){let r=Ln(e)?.method;if(!r)throw new Error("Schema is missing a method literal");let n=gl(r);if(typeof n=="string")return n;throw new Error("Schema method literal must be a string")}function bS(e){return{completion:{values:e.slice(0,100),total:e.length,hasMore:e.length>100}}}var Pa={completion:{values:[],hasMore:!1}};import SS from"node:process";var lu=class{append(t){this._buffer=this._buffer?Buffer.concat([this._buffer,t]):t}readMessage(){if(!this._buffer)return null;let t=this._buffer.indexOf(`
457
- `);if(t===-1)return null;let r=this._buffer.toString("utf8",0,t).replace(/\r$/,"");return this._buffer=this._buffer.subarray(t+1),lM(r)}clear(){this._buffer=void 0}};function lM(e){return j0.parse(JSON.parse(e))}function xS(e){return JSON.stringify(e)+`
458
- `}var uu=class{constructor(t=SS.stdin,r=SS.stdout){this._stdin=t,this._stdout=r,this._readBuffer=new lu,this._started=!1,this._ondata=n=>{this._readBuffer.append(n),this.processReadBuffer()},this._onerror=n=>{this.onerror?.(n)}}async start(){if(this._started)throw new Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");this._started=!0,this._stdin.on("data",this._ondata),this._stdin.on("error",this._onerror)}processReadBuffer(){for(;;)try{let t=this._readBuffer.readMessage();if(t===null)break;this.onmessage?.(t)}catch(t){this.onerror?.(t)}}async close(){this._stdin.off("data",this._ondata),this._stdin.off("error",this._onerror),this._stdin.listenerCount("data")===0&&this._stdin.pause(),this._readBuffer.clear(),this.onclose?.()}send(t){return new Promise(r=>{let n=xS(t);this._stdout.write(n)?r():this._stdout.once("drain",r)})}};function dM(e){let t={};t.listChanged=!1;let r={};r.resources=t,e.server.registerCapabilities(r),e.server.setRequestHandler(jo,()=>{let n={};return n.resources=[],n}),e.server.setRequestHandler(No,()=>{let n={};return n.resourceTemplates=[],n})}function fM(e){return{registerTool:(t,r,n,i)=>{e.tool(t,r,n,i)},registerSchemaTool:(t,r,n,i,o)=>{e.registerTool(t,{description:r,inputSchema:i},o)}}}function mM(e){return(t,r)=>e.server.elicitInput(t,{timeout:r})}async function _g(e){let t=e.delegationAuthFilePath;if(t!==void 0){let s=e.explicitToken,a=e.authFilePath;if(s!==void 0)return{TAG:"Error",_0:"--delegation-auth-file cannot be combined with --token or --auth-file"};if(a!==void 0)return{TAG:"Error",_0:"--delegation-auth-file cannot be combined with --token or --auth-file"};let u=iy(t,Date.now());if(u.TAG!=="Ok")return{TAG:"Error",_0:u._0.summary};let c=u._0;return{TAG:"Ok",_0:{initialAccessToken:c.accessToken,accessToken:{TAG:"StaticAccessToken",_0:c.accessToken},mode:"PersonalAgentDelegation"}}}let r=await Zy(e.serviceUrl,e.explicitToken,e.authFilePath,e.workspaceSlug,e.channelSlug,void 0);if(r.TAG!=="Ok")return{TAG:"Error",_0:r._0.summary};let n=r._0,i=e.explicitToken,o;if(i!==void 0)o={TAG:"StaticAccessToken",_0:n};else{let s=e.authFilePath,a=s!==void 0?s:go();o={TAG:"DynamicAccessToken",_0:()=>{let u=_o(e.serviceUrl,a,Date.now());if(u.TAG!=="Ok")return{TAG:"Error",_0:u._0.summary};let c=u._0;return c!==void 0?{TAG:"Ok",_0:c.accessToken}:{TAG:"Error",_0:gd}}}}return{TAG:"Ok",_0:{initialAccessToken:n,accessToken:o,mode:"LocalRunner"}}}function yg(e,t){let r=Qe(e,"token");return{serviceUrl:t,explicitToken:r!==void 0?r:process.env.LINZUMI_MCP_ACCESS_TOKEN,authFilePath:Qe(e,"auth-file"),delegationAuthFilePath:Qe(e,"delegation-auth-file"),workspaceSlug:Qe(e,"workspace"),channelSlug:Qe(e,"channel")}}async function pM(e){let t=Ha(e);if(t.TAG!=="Ok")return{TAG:"Error",_0:t._0};let r=t._0;if(so(r,"help"))return si(Xa()),{TAG:"Ok",_0:void 0};let n=Ka(r,"api-url");if(n.TAG!=="Ok")return{TAG:"Error",_0:n._0};let i=n._0,o=await _g(yg(r,i));if(o.TAG!=="Ok")return{TAG:"Error",_0:o._0};let s=o._0,a=Qa(Qe(r,"mode")),u=Au(Qe(r,"tool-scope"));if(a.TAG!=="Ok")return{TAG:"Error",_0:a._0};let c=a._0;if(u.TAG!=="Ok")return{TAG:"Error",_0:u._0};let l=Qe(r,"owner-username"),d=l!==void 0?l:process.env.LINZUMI_MCP_OWNER_USERNAME,p=Qe(r,"cwd"),f=p!==void 0?p:process.cwd(),h=Qe(r,"thread-id"),m=h!==void 0?h:process.env[rv],g=Ud({serviceUrl:i,accessToken:s.accessToken,authMode:s.mode,operatingMode:c});if(g.TAG!=="Ok")return{TAG:"Error",_0:g._0};let y=new cu({name:"linzumi",version:"0.1.0"});return dM(y),qv(fM(y),{client:g._0,toolScope:u._0,operatingMode:c,cwd:f,serviceUrl:i,defaultThreadId:m,ownerUsername:d,agentSession:so(r,"agent-session"),documentSurfaces:cy(s.initialAccessToken),multiAgentJobs:so(r,"multi-agent-jobs"),devServices:xv(process.env),askUserQuestion:so(r,"ask-user-question-tool")?mM(y):void 0}),await y.connect(new uu),{TAG:"Ok",_0:void 0}}async function hM(e){let t=Ha(e);if(t.TAG!=="Ok")return{TAG:"Error",_0:t._0};let r=t._0,n=Ka(r,"api-url");if(n.TAG!=="Ok")return{TAG:"Error",_0:n._0};let i=n._0,o=Qe(r,"format"),s=o!==void 0?o:"codex",a=Qa(Qe(r,"mode"));if(a.TAG!=="Ok")return{TAG:"Error",_0:a._0};let u;if(so(r,"include-token")){let p=await _g(yg(r,i));u=p.TAG==="Ok"?{TAG:"Ok",_0:p._0.initialAccessToken}:{TAG:"Error",_0:p._0}}else u={TAG:"Ok",_0:void 0};if(u.TAG!=="Ok")return{TAG:"Error",_0:u._0};let c=Au(Qe(r,"tool-scope"));if(c.TAG!=="Ok")return{TAG:"Error",_0:c._0};let l=Qe(r,"owner-username"),d=zv({command:Qe(r,"command"),serviceUrl:i,accessToken:u._0,delegationAuthFilePath:Qe(r,"delegation-auth-file"),ownerUsername:l!==void 0?l:process.env.LINZUMI_MCP_OWNER_USERNAME,operatingMode:a._0,toolScope:c._0});switch(s){case"claude-code":return si(Av(d)),{TAG:"Ok",_0:void 0};case"codex":return si(Ov(d)),{TAG:"Ok",_0:void 0};default:return{TAG:"Error",_0:"--format must be codex or claude-code"}}}async function gM(e){let t=Ha(e);if(t.TAG!=="Ok")return{TAG:"Error",_0:t._0};let r=t._0,n=Ka(r,"api-url");if(n.TAG!=="Ok")return{TAG:"Error",_0:n._0};let i=n._0,o=await _g(yg(r,i));if(o.TAG!=="Ok")return{TAG:"Error",_0:o._0};let s=o._0,a=s.mode,u;if(a==="LocalRunner"){let c=await vo(i,s.initialAccessToken,Qe(r,"workspace"),Qe(r,"channel"),void 0);if(c.TAG==="Ok")switch(c._0){case"Usable":u={TAG:"Ok",_0:void 0};break;case"Rejected":case"NotFound":u={TAG:"Error",_0:"Linzumi MCP auth validation failed"};break}else u={TAG:"Error",_0:c._0.summary}}else{let c=Qa(Qe(r,"mode"));if(c.TAG==="Ok"){let l=Ud({serviceUrl:i,accessToken:s.accessToken,authMode:s.mode,operatingMode:c._0});if(l.TAG==="Ok")try{await l._0.validateAuth(),u={TAG:"Ok",_0:void 0}}catch(d){let p=K(d);u={TAG:"Error",_0:on(p)}}else u={TAG:"Error",_0:l._0}}else u={TAG:"Error",_0:c._0}}return u.TAG!=="Ok"?{TAG:"Error",_0:u._0}:(si(`Linzumi MCP auth OK
459
- `),{TAG:"Ok",_0:void 0})}async function TS(e){let t=e.slice(1),r=e[0];if(r!==void 0)switch(r){case"--help":case"-h":return si(Xa()),{TAG:"Ok",_0:void 0};case"config":return await hM(t);case"doctor":return await gM(t);case"server":return await pM(t);default:return{TAG:"Error",_0:"unknown linzumi mcp command: "+r}}else return si(Xa()),{TAG:"Ok",_0:void 0}}async function yM(e){let t;try{t=await TS(a_(e))}catch(r){let n=K(r);return $n("linzumi mcp server failed: "+on(n)+`
456
+ ]`;continue}i+=n[u],n[u]==="\\"?o=!0:s&&n[u]==="]"?s=!1:!s&&n[u]==="["&&(s=!0)}try{new RegExp(i)}catch{return console.warn(`Could not convert regex pattern at ${t.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),e.source}return i}function bl(e,t){if(t.target==="openAi"&&console.warn("Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead."),t.target==="openApi3"&&e.keyType?._def.typeName===E.ZodEnum)return{type:"object",required:e.keyType._def.values,properties:e.keyType._def.values.reduce((n,i)=>({...n,[i]:H(e.valueType._def,{...t,currentPath:[...t.currentPath,"properties",i]})??qe(t)}),{}),additionalProperties:t.rejectedAdditionalProperties};let r={type:"object",additionalProperties:H(e.valueType._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]})??t.allowedAdditionalProperties};if(t.target==="openApi3")return r;if(e.keyType?._def.typeName===E.ZodString&&e.keyType._def.checks?.length){let{type:n,...i}=vl(e.keyType._def,t);return{...r,propertyNames:i}}else{if(e.keyType?._def.typeName===E.ZodEnum)return{...r,propertyNames:{enum:e.keyType._def.values}};if(e.keyType?._def.typeName===E.ZodBranded&&e.keyType._def.type._def.typeName===E.ZodString&&e.keyType._def.type._def.checks?.length){let{type:n,...i}=yl(e.keyType._def,t);return{...r,propertyNames:i}}}return r}function cw(e,t){if(t.mapStrategy==="record")return bl(e,t);let r=H(e.keyType._def,{...t,currentPath:[...t.currentPath,"items","items","0"]})||qe(t),n=H(e.valueType._def,{...t,currentPath:[...t.currentPath,"items","items","1"]})||qe(t);return{type:"array",maxItems:125,items:{type:"array",items:[r,n],minItems:2,maxItems:2}}}function lw(e){let t=e.values,n=Object.keys(e.values).filter(o=>typeof t[t[o]]!="number").map(o=>t[o]),i=Array.from(new Set(n.map(o=>typeof o)));return{type:i.length===1?i[0]==="string"?"string":"number":["string","number"],enum:n}}function uw(e){return e.target==="openAi"?void 0:{not:qe({...e,currentPath:[...e.currentPath,"not"]})}}function dw(e){return e.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}var ta={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function mw(e,t){if(t.target==="openApi3")return fw(e,t);let r=e.options instanceof Map?Array.from(e.options.values()):e.options;if(r.every(n=>n._def.typeName in ta&&(!n._def.checks||!n._def.checks.length))){let n=r.reduce((i,o)=>{let s=ta[o._def.typeName];return s&&!i.includes(s)?[...i,s]:i},[]);return{type:n.length>1?n:n[0]}}else if(r.every(n=>n._def.typeName==="ZodLiteral"&&!n.description)){let n=r.reduce((i,o)=>{let s=typeof o._def.value;switch(s){case"string":case"number":case"boolean":return[...i,s];case"bigint":return[...i,"integer"];case"object":if(o._def.value===null)return[...i,"null"];default:return i}},[]);if(n.length===r.length){let i=n.filter((o,s,a)=>a.indexOf(o)===s);return{type:i.length>1?i:i[0],enum:r.reduce((o,s)=>o.includes(s._def.value)?o:[...o,s._def.value],[])}}}else if(r.every(n=>n._def.typeName==="ZodEnum"))return{type:"string",enum:r.reduce((n,i)=>[...n,...i._def.values.filter(o=>!n.includes(o))],[])};return fw(e,t)}var fw=(e,t)=>{let r=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((n,i)=>H(n._def,{...t,currentPath:[...t.currentPath,"anyOf",`${i}`]})).filter(n=>!!n&&(!t.strictUnions||typeof n=="object"&&Object.keys(n).length>0));return r.length?{anyOf:r}:void 0};function pw(e,t){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(e.innerType._def.typeName)&&(!e.innerType._def.checks||!e.innerType._def.checks.length))return t.target==="openApi3"?{type:ta[e.innerType._def.typeName],nullable:!0}:{type:[ta[e.innerType._def.typeName],"null"]};if(t.target==="openApi3"){let n=H(e.innerType._def,{...t,currentPath:[...t.currentPath]});return n&&"$ref"in n?{allOf:[n],nullable:!0}:n&&{...n,nullable:!0}}let r=H(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","0"]});return r&&{anyOf:[r,{type:"null"}]}}function hw(e,t){let r={type:"number"};if(!e.checks)return r;for(let n of e.checks)switch(n.kind){case"int":r.type="integer",pp(r,"type",n.message,t);break;case"min":t.target==="jsonSchema7"?n.inclusive?de(r,"minimum",n.value,n.message,t):de(r,"exclusiveMinimum",n.value,n.message,t):(n.inclusive||(r.exclusiveMinimum=!0),de(r,"minimum",n.value,n.message,t));break;case"max":t.target==="jsonSchema7"?n.inclusive?de(r,"maximum",n.value,n.message,t):de(r,"exclusiveMaximum",n.value,n.message,t):(n.inclusive||(r.exclusiveMaximum=!0),de(r,"maximum",n.value,n.message,t));break;case"multipleOf":de(r,"multipleOf",n.value,n.message,t);break}return r}function gw(e,t){let r=t.target==="openAi",n={type:"object",properties:{}},i=[],o=e.shape();for(let a in o){let u=o[a];if(u===void 0||u._def===void 0)continue;let c=uC(u);c&&r&&(u._def.typeName==="ZodOptional"&&(u=u._def.innerType),u.isNullable()||(u=u.nullable()),c=!1);let l=H(u._def,{...t,currentPath:[...t.currentPath,"properties",a],propertyPath:[...t.currentPath,"properties",a]});l!==void 0&&(n.properties[a]=l,c||i.push(a))}i.length&&(n.required=i);let s=lC(e,t);return s!==void 0&&(n.additionalProperties=s),n}function lC(e,t){if(e.catchall._def.typeName!=="ZodNever")return H(e.catchall._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]});switch(e.unknownKeys){case"passthrough":return t.allowedAdditionalProperties;case"strict":return t.rejectedAdditionalProperties;case"strip":return t.removeAdditionalStrategy==="strict"?t.allowedAdditionalProperties:t.rejectedAdditionalProperties}}function uC(e){try{return e.isOptional()}catch{return!0}}var _w=(e,t)=>{if(t.currentPath.toString()===t.propertyPath?.toString())return H(e.innerType._def,t);let r=H(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","1"]});return r?{anyOf:[{not:qe(t)},r]}:qe(t)};var yw=(e,t)=>{if(t.pipeStrategy==="input")return H(e.in._def,t);if(t.pipeStrategy==="output")return H(e.out._def,t);let r=H(e.in._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),n=H(e.out._def,{...t,currentPath:[...t.currentPath,"allOf",r?"1":"0"]});return{allOf:[r,n].filter(i=>i!==void 0)}};function vw(e,t){return H(e.type._def,t)}function bw(e,t){let n={type:"array",uniqueItems:!0,items:H(e.valueType._def,{...t,currentPath:[...t.currentPath,"items"]})};return e.minSize&&de(n,"minItems",e.minSize.value,e.minSize.message,t),e.maxSize&&de(n,"maxItems",e.maxSize.value,e.maxSize.message,t),n}function ww(e,t){return e.rest?{type:"array",minItems:e.items.length,items:e.items.map((r,n)=>H(r._def,{...t,currentPath:[...t.currentPath,"items",`${n}`]})).reduce((r,n)=>n===void 0?r:[...r,n],[]),additionalItems:H(e.rest._def,{...t,currentPath:[...t.currentPath,"additionalItems"]})}:{type:"array",minItems:e.items.length,maxItems:e.items.length,items:e.items.map((r,n)=>H(r._def,{...t,currentPath:[...t.currentPath,"items",`${n}`]})).reduce((r,n)=>n===void 0?r:[...r,n],[])}}function kw(e){return{not:qe(e)}}function xw(e){return qe(e)}var Sw=(e,t)=>H(e.innerType._def,t);var Tw=(e,t,r)=>{switch(t){case E.ZodString:return vl(e,r);case E.ZodNumber:return hw(e,r);case E.ZodObject:return gw(e,r);case E.ZodBigInt:return Y0(e,r);case E.ZodBoolean:return ew();case E.ZodDate:return hp(e,r);case E.ZodUndefined:return kw(r);case E.ZodNull:return dw(r);case E.ZodArray:return X0(e,r);case E.ZodUnion:case E.ZodDiscriminatedUnion:return mw(e,r);case E.ZodIntersection:return ow(e,r);case E.ZodTuple:return ww(e,r);case E.ZodRecord:return bl(e,r);case E.ZodLiteral:return sw(e,r);case E.ZodEnum:return iw(e);case E.ZodNativeEnum:return lw(e);case E.ZodNullable:return pw(e,r);case E.ZodOptional:return _w(e,r);case E.ZodMap:return cw(e,r);case E.ZodSet:return bw(e,r);case E.ZodLazy:return()=>e.getter()._def;case E.ZodPromise:return vw(e,r);case E.ZodNaN:case E.ZodNever:return uw(r);case E.ZodEffects:return nw(e,r);case E.ZodAny:return qe(r);case E.ZodUnknown:return xw(r);case E.ZodDefault:return rw(e,r);case E.ZodBranded:return yl(e,r);case E.ZodReadonly:return Sw(e,r);case E.ZodCatch:return tw(e,r);case E.ZodPipeline:return yw(e,r);case E.ZodFunction:case E.ZodVoid:case E.ZodSymbol:return;default:return(n=>{})(t)}};function H(e,t,r=!1){let n=t.seen.get(e);if(t.override){let a=t.override?.(e,t,n,r);if(a!==H0)return a}if(n&&!r){let a=dC(n,t);if(a!==void 0)return a}let i={def:e,path:t.currentPath,jsonSchema:void 0};t.seen.set(e,i);let o=Tw(e,e.typeName,t),s=typeof o=="function"?H(o(),t):o;if(s&&fC(e,t,s),t.postProcess){let a=t.postProcess(s,e,t);return i.jsonSchema=s,a}return i.jsonSchema=s,s}var dC=(e,t)=>{switch(t.$refStrategy){case"root":return{$ref:e.path.join("/")};case"relative":return{$ref:_l(t.currentPath,e.path)};case"none":case"seen":return e.path.length<t.currentPath.length&&e.path.every((r,n)=>t.currentPath[n]===r)?(console.warn(`Recursive reference detected at ${t.currentPath.join("/")}! Defaulting to any`),qe(t)):t.$refStrategy==="seen"?qe(t):void 0}},fC=(e,t,r)=>(e.description&&(r.description=e.description,t.markdownDescription&&(r.markdownDescription=e.description)),r);var yp=(e,t)=>{let r=Q0(t),n=typeof t=="object"&&t.definitions?Object.entries(t.definitions).reduce((u,[c,l])=>({...u,[c]:H(l._def,{...r,currentPath:[...r.basePath,r.definitionPath,c]},!0)??qe(r)}),{}):void 0,i=typeof t=="string"?t:t?.nameStrategy==="title"?void 0:t?.name,o=H(e._def,i===void 0?r:{...r,currentPath:[...r.basePath,r.definitionPath,i]},!1)??qe(r),s=typeof t=="object"&&t.name!==void 0&&t.nameStrategy==="title"?t.name:void 0;s!==void 0&&(o.title=s),r.flags.hasReferencedOpenAiAnyType&&(n||(n={}),n[r.openAiAnyTypeName]||(n[r.openAiAnyTypeName]={type:["string","number","integer","boolean","array","null"],items:{$ref:r.$refStrategy==="relative"?"1":[...r.basePath,r.definitionPath,r.openAiAnyTypeName].join("/")}}));let a=i===void 0?n?{...o,[r.definitionPath]:n}:o:{$ref:[...r.$refStrategy==="relative"?[]:r.basePath,r.definitionPath,i].join("/"),[r.definitionPath]:{...n,[i]:o}};return r.target==="jsonSchema7"?a.$schema="http://json-schema.org/draft-07/schema#":(r.target==="jsonSchema2019-09"||r.target==="openAi")&&(a.$schema="https://json-schema.org/draft/2019-09/schema#"),r.target==="openAi"&&("anyOf"in a||"oneOf"in a||"allOf"in a||"type"in a&&Array.isArray(a.type))&&console.warn("Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property."),a};function mC(e){return!e||e==="jsonSchema7"||e==="draft-7"?"draft-7":e==="jsonSchema2019-09"||e==="draft-2020-12"?"draft-2020-12":"draft-7"}function vp(e,t){return pr(e)?Fm(e,{target:mC(t?.target),io:t?.pipeStrategy??"input"}):yp(e,{strictUnions:t?.strictUnions??!0,pipeStrategy:t?.pipeStrategy??"input"})}function bp(e){let r=Un(e)?.method;if(!r)throw new Error("Schema is missing a method literal");let n=gl(r);if(typeof n!="string")throw new Error("Schema method literal must be a string");return n}function wp(e,t){let r=Ln(e,t);if(!r.success)throw r.error;return r.data}var pC=6e4,wl=class{constructor(t){this._options=t,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this._taskProgressTokens=new Map,this._requestResolvers=new Map,this.setNotificationHandler(Yc,r=>{this._oncancel(r)}),this.setNotificationHandler(tl,r=>{this._onprogress(r)}),this.setRequestHandler(el,r=>({})),this._taskStore=t?.taskStore,this._taskMessageQueue=t?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(rl,async(r,n)=>{let i=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!i)throw new F(U.InvalidParams,"Failed to retrieve task: Task not found");return{...i}}),this.setRequestHandler(il,async(r,n)=>{let i=async()=>{let o=r.params.taskId;if(this._taskMessageQueue){let a;for(;a=await this._taskMessageQueue.dequeue(o,n.sessionId);){if(a.type==="response"||a.type==="error"){let u=a.message,c=u.id,l=this._requestResolvers.get(c);if(l)if(this._requestResolvers.delete(c),a.type==="response")l(u);else{let d=u,p=new F(d.error.code,d.error.message,d.error.data);l(p)}else{let d=a.type==="response"?"Response":"Error";this._onerror(new Error(`${d} handler missing for request ${c}`))}continue}await this._transport?.send(a.message,{relatedRequestId:n.requestId})}}let s=await this._taskStore.getTask(o,n.sessionId);if(!s)throw new F(U.InvalidParams,`Task not found: ${o}`);if(!Vn(s.status))return await this._waitForTaskUpdate(o,n.signal),await i();if(Vn(s.status)){let a=await this._taskStore.getTaskResult(o,n.sessionId);return this._clearTaskQueue(o),{...a,_meta:{...a._meta,[qn]:{taskId:o}}}}return await i()};return await i()}),this.setRequestHandler(ol,async(r,n)=>{try{let{tasks:i,nextCursor:o}=await this._taskStore.listTasks(r.params?.cursor,n.sessionId);return{tasks:i,nextCursor:o,_meta:{}}}catch(i){throw new F(U.InvalidParams,`Failed to list tasks: ${i instanceof Error?i.message:String(i)}`)}}),this.setRequestHandler(al,async(r,n)=>{try{let i=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!i)throw new F(U.InvalidParams,`Task not found: ${r.params.taskId}`);if(Vn(i.status))throw new F(U.InvalidParams,`Cannot cancel task in terminal status: ${i.status}`);await this._taskStore.updateTaskStatus(r.params.taskId,"cancelled","Client cancelled task execution.",n.sessionId),this._clearTaskQueue(r.params.taskId);let o=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!o)throw new F(U.InvalidParams,`Task not found after cancellation: ${r.params.taskId}`);return{_meta:{},...o}}catch(i){throw i instanceof F?i:new F(U.InvalidRequest,`Failed to cancel task: ${i instanceof Error?i.message:String(i)}`)}}))}async _oncancel(t){if(!t.params.requestId)return;this._requestHandlerAbortControllers.get(t.params.requestId)?.abort(t.params.reason)}_setupTimeout(t,r,n,i,o=!1){this._timeoutInfo.set(t,{timeoutId:setTimeout(i,r),startTime:Date.now(),timeout:r,maxTotalTimeout:n,resetTimeoutOnProgress:o,onTimeout:i})}_resetTimeout(t){let r=this._timeoutInfo.get(t);if(!r)return!1;let n=Date.now()-r.startTime;if(r.maxTotalTimeout&&n>=r.maxTotalTimeout)throw this._timeoutInfo.delete(t),F.fromError(U.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:r.maxTotalTimeout,totalElapsed:n});return clearTimeout(r.timeoutId),r.timeoutId=setTimeout(r.onTimeout,r.timeout),!0}_cleanupTimeout(t){let r=this._timeoutInfo.get(t);r&&(clearTimeout(r.timeoutId),this._timeoutInfo.delete(t))}async connect(t){if(this._transport)throw new Error("Already connected to a transport. Call close() before connecting to a new transport, or use a separate Protocol instance per connection.");this._transport=t;let r=this.transport?.onclose;this._transport.onclose=()=>{r?.(),this._onclose()};let n=this.transport?.onerror;this._transport.onerror=o=>{n?.(o),this._onerror(o)};let i=this._transport?.onmessage;this._transport.onmessage=(o,s)=>{i?.(o,s),Bs(o)||j0(o)?this._onresponse(o):Ym(o)?this._onrequest(o,s):I0(o)?this._onnotification(o):this._onerror(new Error(`Unknown message type: ${JSON.stringify(o)}`))},await this._transport.start()}_onclose(){let t=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(let n of this._timeoutInfo.values())clearTimeout(n.timeoutId);this._timeoutInfo.clear();for(let n of this._requestHandlerAbortControllers.values())n.abort();this._requestHandlerAbortControllers.clear();let r=F.fromError(U.ConnectionClosed,"Connection closed");this._transport=void 0,this.onclose?.();for(let n of t.values())n(r)}_onerror(t){this.onerror?.(t)}_onnotification(t){let r=this._notificationHandlers.get(t.method)??this.fallbackNotificationHandler;r!==void 0&&Promise.resolve().then(()=>r(t)).catch(n=>this._onerror(new Error(`Uncaught error in notification handler: ${n}`)))}_onrequest(t,r){let n=this._requestHandlers.get(t.method)??this.fallbackRequestHandler,i=this._transport,o=t.params?._meta?.[qn]?.taskId;if(n===void 0){let l={jsonrpc:"2.0",id:t.id,error:{code:U.MethodNotFound,message:"Method not found"}};o&&this._taskMessageQueue?this._enqueueTaskMessage(o,{type:"error",message:l,timestamp:Date.now()},i?.sessionId).catch(d=>this._onerror(new Error(`Failed to enqueue error response: ${d}`))):i?.send(l).catch(d=>this._onerror(new Error(`Failed to send an error response: ${d}`)));return}let s=new AbortController;this._requestHandlerAbortControllers.set(t.id,s);let a=P0(t.params)?t.params.task:void 0,u=this._taskStore?this.requestTaskStore(t,i?.sessionId):void 0,c={signal:s.signal,sessionId:i?.sessionId,_meta:t.params?._meta,sendNotification:async l=>{if(s.signal.aborted)return;let d={relatedRequestId:t.id};o&&(d.relatedTask={taskId:o}),await this.notification(l,d)},sendRequest:async(l,d,p)=>{if(s.signal.aborted)throw new F(U.ConnectionClosed,"Request was cancelled");let f={...p,relatedRequestId:t.id};o&&!f.relatedTask&&(f.relatedTask={taskId:o});let h=f.relatedTask?.taskId??o;return h&&u&&await u.updateTaskStatus(h,"input_required"),await this.request(l,d,f)},authInfo:r?.authInfo,requestId:t.id,requestInfo:r?.requestInfo,taskId:o,taskStore:u,taskRequestedTtl:a?.ttl,closeSSEStream:r?.closeSSEStream,closeStandaloneSSEStream:r?.closeStandaloneSSEStream};Promise.resolve().then(()=>{a&&this.assertTaskHandlerCapability(t.method)}).then(()=>n(t,c)).then(async l=>{if(s.signal.aborted)return;let d={result:l,jsonrpc:"2.0",id:t.id};o&&this._taskMessageQueue?await this._enqueueTaskMessage(o,{type:"response",message:d,timestamp:Date.now()},i?.sessionId):await i?.send(d)},async l=>{if(s.signal.aborted)return;let d={jsonrpc:"2.0",id:t.id,error:{code:Number.isSafeInteger(l.code)?l.code:U.InternalError,message:l.message??"Internal error",...l.data!==void 0&&{data:l.data}}};o&&this._taskMessageQueue?await this._enqueueTaskMessage(o,{type:"error",message:d,timestamp:Date.now()},i?.sessionId):await i?.send(d)}).catch(l=>this._onerror(new Error(`Failed to send response: ${l}`))).finally(()=>{this._requestHandlerAbortControllers.get(t.id)===s&&this._requestHandlerAbortControllers.delete(t.id)})}_onprogress(t){let{progressToken:r,...n}=t.params,i=Number(r),o=this._progressHandlers.get(i);if(!o){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(t)}`));return}let s=this._responseHandlers.get(i),a=this._timeoutInfo.get(i);if(a&&s&&a.resetTimeoutOnProgress)try{this._resetTimeout(i)}catch(u){this._responseHandlers.delete(i),this._progressHandlers.delete(i),this._cleanupTimeout(i),s(u);return}o(n)}_onresponse(t){let r=Number(t.id),n=this._requestResolvers.get(r);if(n){if(this._requestResolvers.delete(r),Bs(t))n(t);else{let s=new F(t.error.code,t.error.message,t.error.data);n(s)}return}let i=this._responseHandlers.get(r);if(i===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(t)}`));return}this._responseHandlers.delete(r),this._cleanupTimeout(r);let o=!1;if(Bs(t)&&t.result&&typeof t.result=="object"){let s=t.result;if(s.task&&typeof s.task=="object"){let a=s.task;typeof a.taskId=="string"&&(o=!0,this._taskProgressTokens.set(a.taskId,r))}}if(o||this._progressHandlers.delete(r),Bs(t))i(t);else{let s=F.fromError(t.error.code,t.error.message,t.error.data);i(s)}}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(t,r,n){let{task:i}=n??{};if(!i){try{yield{type:"result",result:await this.request(t,r,n)}}catch(s){yield{type:"error",error:s instanceof F?s:new F(U.InternalError,String(s))}}return}let o;try{let s=await this.request(t,Ro,n);if(s.task)o=s.task.taskId,yield{type:"taskCreated",task:s.task};else throw new F(U.InternalError,"Task creation did not return a task");for(;;){let a=await this.getTask({taskId:o},n);if(yield{type:"taskStatus",task:a},Vn(a.status)){a.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:o},r,n)}:a.status==="failed"?yield{type:"error",error:new F(U.InternalError,`Task ${o} failed`)}:a.status==="cancelled"&&(yield{type:"error",error:new F(U.InternalError,`Task ${o} was cancelled`)});return}if(a.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:o},r,n)};return}let u=a.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(c=>setTimeout(c,u)),n?.signal?.throwIfAborted()}}catch(s){yield{type:"error",error:s instanceof F?s:new F(U.InternalError,String(s))}}}request(t,r,n){let{relatedRequestId:i,resumptionToken:o,onresumptiontoken:s,task:a,relatedTask:u}=n??{};return new Promise((c,l)=>{let d=v=>{l(v)};if(!this._transport){d(new Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(t.method),a&&this.assertTaskCapability(t.method)}catch(v){d(v);return}n?.signal?.throwIfAborted();let p=this._requestMessageId++,f={...t,jsonrpc:"2.0",id:p};n?.onprogress&&(this._progressHandlers.set(p,n.onprogress),f.params={...t.params,_meta:{...t.params?._meta||{},progressToken:p}}),a&&(f.params={...f.params,task:a}),u&&(f.params={...f.params,_meta:{...f.params?._meta||{},[qn]:u}});let h=v=>{this._responseHandlers.delete(p),this._progressHandlers.delete(p),this._cleanupTimeout(p),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:p,reason:String(v)}},{relatedRequestId:i,resumptionToken:o,onresumptiontoken:s}).catch(w=>this._onerror(new Error(`Failed to send cancellation: ${w}`)));let b=v instanceof F?v:new F(U.RequestTimeout,String(v));l(b)};this._responseHandlers.set(p,v=>{if(!n?.signal?.aborted){if(v instanceof Error)return l(v);try{let b=Ln(r,v.result);b.success?c(b.data):l(b.error)}catch(b){l(b)}}}),n?.signal?.addEventListener("abort",()=>{h(n?.signal?.reason)});let m=n?.timeout??pC,g=()=>h(F.fromError(U.RequestTimeout,"Request timed out",{timeout:m}));this._setupTimeout(p,m,n?.maxTotalTimeout,g,n?.resetTimeoutOnProgress??!1);let y=u?.taskId;if(y){let v=b=>{let w=this._responseHandlers.get(p);w?w(b):this._onerror(new Error(`Response handler missing for side-channeled request ${p}`))};this._requestResolvers.set(p,v),this._enqueueTaskMessage(y,{type:"request",message:f,timestamp:Date.now()}).catch(b=>{this._cleanupTimeout(p),l(b)})}else this._transport.send(f,{relatedRequestId:i,resumptionToken:o,onresumptiontoken:s}).catch(v=>{this._cleanupTimeout(p),l(v)})})}async getTask(t,r){return this.request({method:"tasks/get",params:t},nl,r)}async getTaskResult(t,r,n){return this.request({method:"tasks/result",params:t},r,n)}async listTasks(t,r){return this.request({method:"tasks/list",params:t},sl,r)}async cancelTask(t,r){return this.request({method:"tasks/cancel",params:t},D0,r)}async notification(t,r){if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(t.method);let n=r?.relatedTask?.taskId;if(n){let a={...t,jsonrpc:"2.0",params:{...t.params,_meta:{...t.params?._meta||{},[qn]:r.relatedTask}}};await this._enqueueTaskMessage(n,{type:"notification",message:a,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(t.method)&&!t.params&&!r?.relatedRequestId&&!r?.relatedTask){if(this._pendingDebouncedNotifications.has(t.method))return;this._pendingDebouncedNotifications.add(t.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(t.method),!this._transport)return;let a={...t,jsonrpc:"2.0"};r?.relatedTask&&(a={...a,params:{...a.params,_meta:{...a.params?._meta||{},[qn]:r.relatedTask}}}),this._transport?.send(a,r).catch(u=>this._onerror(u))});return}let s={...t,jsonrpc:"2.0"};r?.relatedTask&&(s={...s,params:{...s.params,_meta:{...s.params?._meta||{},[qn]:r.relatedTask}}}),await this._transport.send(s,r)}setRequestHandler(t,r){let n=bp(t);this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(i,o)=>{let s=wp(t,i);return Promise.resolve(r(s,o))})}removeRequestHandler(t){this._requestHandlers.delete(t)}assertCanSetRequestHandler(t){if(this._requestHandlers.has(t))throw new Error(`A request handler for ${t} already exists, which would be overridden`)}setNotificationHandler(t,r){let n=bp(t);this._notificationHandlers.set(n,i=>{let o=wp(t,i);return Promise.resolve(r(o))})}removeNotificationHandler(t){this._notificationHandlers.delete(t)}_cleanupTaskProgressHandler(t){let r=this._taskProgressTokens.get(t);r!==void 0&&(this._progressHandlers.delete(r),this._taskProgressTokens.delete(t))}async _enqueueTaskMessage(t,r,n){if(!this._taskStore||!this._taskMessageQueue)throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");let i=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(t,r,n,i)}async _clearTaskQueue(t,r){if(this._taskMessageQueue){let n=await this._taskMessageQueue.dequeueAll(t,r);for(let i of n)if(i.type==="request"&&Ym(i.message)){let o=i.message.id,s=this._requestResolvers.get(o);s?(s(new F(U.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(o)):this._onerror(new Error(`Resolver missing for request ${o} during task ${t} cleanup`))}}}async _waitForTaskUpdate(t,r){let n=this._options?.defaultTaskPollInterval??1e3;try{let i=await this._taskStore?.getTask(t);i?.pollInterval&&(n=i.pollInterval)}catch{}return new Promise((i,o)=>{if(r.aborted){o(new F(U.InvalidRequest,"Request cancelled"));return}let s=setTimeout(i,n);r.addEventListener("abort",()=>{clearTimeout(s),o(new F(U.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(t,r){let n=this._taskStore;if(!n)throw new Error("No task store configured");return{createTask:async i=>{if(!t)throw new Error("No request provided");return await n.createTask(i,t.id,{method:t.method,params:t.params},r)},getTask:async i=>{let o=await n.getTask(i,r);if(!o)throw new F(U.InvalidParams,"Failed to retrieve task: Task not found");return o},storeTaskResult:async(i,o,s)=>{await n.storeTaskResult(i,o,s,r);let a=await n.getTask(i,r);if(a){let u=Qs.parse({method:"notifications/tasks/status",params:a});await this.notification(u),Vn(a.status)&&this._cleanupTaskProgressHandler(i)}},getTaskResult:i=>n.getTaskResult(i,r),updateTaskStatus:async(i,o,s)=>{let a=await n.getTask(i,r);if(!a)throw new F(U.InvalidParams,`Task "${i}" not found - it may have been cleaned up`);if(Vn(a.status))throw new F(U.InvalidParams,`Cannot update task "${i}" from terminal status "${a.status}" to "${o}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await n.updateTaskStatus(i,o,s,r);let u=await n.getTask(i,r);if(u){let c=Qs.parse({method:"notifications/tasks/status",params:u});await this.notification(c),Vn(u.status)&&this._cleanupTaskProgressHandler(i)}},listTasks:i=>n.listTasks(i,r)}}};function $w(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Ew(e,t){let r={...e};for(let n in t){let i=n,o=t[i];if(o===void 0)continue;let s=r[i];$w(s)&&$w(o)?r[i]={...s,...o}:r[i]=o}return r}var mS=Ra(sg(),1),pS=Ra(fS(),1);function iM(){let e=new mS.default({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return(0,pS.default)(e),e}var iu=class{constructor(t){this._ajv=t??iM()}getValidator(t){let r="$id"in t&&typeof t.$id=="string"?this._ajv.getSchema(t.$id)??this._ajv.compile(t):this._ajv.compile(t);return n=>r(n)?{valid:!0,data:n,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:this._ajv.errorsText(r.errors)}}};var ou=class{constructor(t){this._server=t}requestStream(t,r,n){return this._server.requestStream(t,r,n)}createMessageStream(t,r){let n=this._server.getClientCapabilities();if((t.tools||t.toolChoice)&&!n?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(t.messages.length>0){let i=t.messages[t.messages.length-1],o=Array.isArray(i.content)?i.content:[i.content],s=o.some(l=>l.type==="tool_result"),a=t.messages.length>1?t.messages[t.messages.length-2]:void 0,u=a?Array.isArray(a.content)?a.content:[a.content]:[],c=u.some(l=>l.type==="tool_use");if(s){if(o.some(l=>l.type!=="tool_result"))throw new Error("The last message must contain only tool_result content if any is present");if(!c)throw new Error("tool_result blocks are not matching any tool_use from the previous message")}if(c){let l=new Set(u.filter(p=>p.type==="tool_use").map(p=>p.id)),d=new Set(o.filter(p=>p.type==="tool_result").map(p=>p.toolUseId));if(l.size!==d.size||![...l].every(p=>d.has(p)))throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}return this.requestStream({method:"sampling/createMessage",params:t},ea,r)}elicitInputStream(t,r){let n=this._server.getClientCapabilities(),i=t.mode??"form";switch(i){case"url":{if(!n?.elicitation?.url)throw new Error("Client does not support url elicitation.");break}case"form":{if(!n?.elicitation?.form)throw new Error("Client does not support form elicitation.");break}}let o=i==="form"&&t.mode===void 0?{...t,mode:"form"}:t;return this.requestStream({method:"elicitation/create",params:o},Do,r)}async getTask(t,r){return this._server.getTask({taskId:t},r)}async getTaskResult(t,r,n){return this._server.getTaskResult({taskId:t},r,n)}async listTasks(t,r){return this._server.listTasks(t?{cursor:t}:void 0,r)}async cancelTask(t,r){return this._server.cancelTask({taskId:t},r)}};function hS(e,t,r){if(!e)throw new Error(`${r} does not support task creation (required for ${t})`);switch(t){case"tools/call":if(!e.tools?.call)throw new Error(`${r} does not support task creation for tools/call (required for ${t})`);break;default:break}}function gS(e,t,r){if(!e)throw new Error(`${r} does not support task creation (required for ${t})`);switch(t){case"sampling/createMessage":if(!e.sampling?.createMessage)throw new Error(`${r} does not support task creation for sampling/createMessage (required for ${t})`);break;case"elicitation/create":if(!e.elicitation?.create)throw new Error(`${r} does not support task creation for elicitation/create (required for ${t})`);break;default:break}}var su=class extends wl{constructor(t,r){super(r),this._serverInfo=t,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(Ys.options.map((n,i)=>[n,i])),this.isMessageIgnored=(n,i)=>{let o=this._loggingLevels.get(i);return o?this.LOG_LEVEL_SEVERITY.get(n)<this.LOG_LEVEL_SEVERITY.get(o):!1},this._capabilities=r?.capabilities??{},this._instructions=r?.instructions,this._jsonSchemaValidator=r?.jsonSchemaValidator??new iu,this.setRequestHandler(rp,n=>this._oninitialize(n)),this.setNotificationHandler(np,()=>this.oninitialized?.()),this._capabilities.logging&&this.setRequestHandler(up,async(n,i)=>{let o=i.sessionId||i.requestInfo?.headers["mcp-session-id"]||void 0,{level:s}=n.params,a=Ys.safeParse(s);return a.success&&this._loggingLevels.set(o,a.data),{}})}get experimental(){return this._experimental||(this._experimental={tasks:new ou(this)}),this._experimental}registerCapabilities(t){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=Ew(this._capabilities,t)}setRequestHandler(t,r){let i=Un(t)?.method;if(!i)throw new Error("Schema is missing a method literal");let o;if(pr(i)){let a=i;o=a._zod?.def?.value??a.value}else{let a=i;o=a._def?.value??a.value}if(typeof o!="string")throw new Error("Schema method literal must be a string");if(o==="tools/call"){let a=async(u,c)=>{let l=Ln(Mo,u);if(!l.success){let h=l.error instanceof Error?l.error.message:String(l.error);throw new F(U.InvalidParams,`Invalid tools/call request: ${h}`)}let{params:d}=l.data,p=await Promise.resolve(r(u,c));if(d.task){let h=Ln(Ro,p);if(!h.success){let m=h.error instanceof Error?h.error.message:String(h.error);throw new F(U.InvalidParams,`Invalid task creation result: ${m}`)}return h.data}let f=Ln(fl,p);if(!f.success){let h=f.error instanceof Error?f.error.message:String(f.error);throw new F(U.InvalidParams,`Invalid tools/call result: ${h}`)}return f.data};return super.setRequestHandler(t,a)}return super.setRequestHandler(t,r)}assertCapabilityForMethod(t){switch(t){case"sampling/createMessage":if(!this._clientCapabilities?.sampling)throw new Error(`Client does not support sampling (required for ${t})`);break;case"elicitation/create":if(!this._clientCapabilities?.elicitation)throw new Error(`Client does not support elicitation (required for ${t})`);break;case"roots/list":if(!this._clientCapabilities?.roots)throw new Error(`Client does not support listing roots (required for ${t})`);break;case"ping":break}}assertNotificationCapability(t){switch(t){case"notifications/message":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${t})`);break;case"notifications/resources/updated":case"notifications/resources/list_changed":if(!this._capabilities.resources)throw new Error(`Server does not support notifying about resources (required for ${t})`);break;case"notifications/tools/list_changed":if(!this._capabilities.tools)throw new Error(`Server does not support notifying of tool list changes (required for ${t})`);break;case"notifications/prompts/list_changed":if(!this._capabilities.prompts)throw new Error(`Server does not support notifying of prompt list changes (required for ${t})`);break;case"notifications/elicitation/complete":if(!this._clientCapabilities?.elicitation?.url)throw new Error(`Client does not support URL elicitation (required for ${t})`);break;case"notifications/cancelled":break;case"notifications/progress":break}}assertRequestHandlerCapability(t){if(this._capabilities)switch(t){case"completion/complete":if(!this._capabilities.completions)throw new Error(`Server does not support completions (required for ${t})`);break;case"logging/setLevel":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${t})`);break;case"prompts/get":case"prompts/list":if(!this._capabilities.prompts)throw new Error(`Server does not support prompts (required for ${t})`);break;case"resources/list":case"resources/templates/list":case"resources/read":if(!this._capabilities.resources)throw new Error(`Server does not support resources (required for ${t})`);break;case"tools/call":case"tools/list":if(!this._capabilities.tools)throw new Error(`Server does not support tools (required for ${t})`);break;case"tasks/get":case"tasks/list":case"tasks/result":case"tasks/cancel":if(!this._capabilities.tasks)throw new Error(`Server does not support tasks capability (required for ${t})`);break;case"ping":case"initialize":break}}assertTaskCapability(t){gS(this._clientCapabilities?.tasks?.requests,t,"Client")}assertTaskHandlerCapability(t){this._capabilities&&hS(this._capabilities.tasks?.requests,t,"Server")}async _oninitialize(t){let r=t.params.protocolVersion;return this._clientCapabilities=t.params.capabilities,this._clientVersion=t.params.clientInfo,{protocolVersion:z0.includes(r)?r:Qm,capabilities:this.getCapabilities(),serverInfo:this._serverInfo,...this._instructions&&{instructions:this._instructions}}}getClientCapabilities(){return this._clientCapabilities}getClientVersion(){return this._clientVersion}getCapabilities(){return this._capabilities}async ping(){return this.request({method:"ping"},Xc)}async createMessage(t,r){if((t.tools||t.toolChoice)&&!this._clientCapabilities?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(t.messages.length>0){let n=t.messages[t.messages.length-1],i=Array.isArray(n.content)?n.content:[n.content],o=i.some(c=>c.type==="tool_result"),s=t.messages.length>1?t.messages[t.messages.length-2]:void 0,a=s?Array.isArray(s.content)?s.content:[s.content]:[],u=a.some(c=>c.type==="tool_use");if(o){if(i.some(c=>c.type!=="tool_result"))throw new Error("The last message must contain only tool_result content if any is present");if(!u)throw new Error("tool_result blocks are not matching any tool_use from the previous message")}if(u){let c=new Set(a.filter(d=>d.type==="tool_use").map(d=>d.id)),l=new Set(i.filter(d=>d.type==="tool_result").map(d=>d.toolUseId));if(c.size!==l.size||![...c].every(d=>l.has(d)))throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}return t.tools?this.request({method:"sampling/createMessage",params:t},dp,r):this.request({method:"sampling/createMessage",params:t},ea,r)}async elicitInput(t,r){switch(t.mode??"form"){case"url":{if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support url elicitation.");let i=t;return this.request({method:"elicitation/create",params:i},Do,r)}case"form":{if(!this._clientCapabilities?.elicitation?.form)throw new Error("Client does not support form elicitation.");let i=t.mode==="form"?t:{...t,mode:"form"},o=await this.request({method:"elicitation/create",params:i},Do,r);if(o.action==="accept"&&o.content&&i.requestedSchema)try{let a=this._jsonSchemaValidator.getValidator(i.requestedSchema)(o.content);if(!a.valid)throw new F(U.InvalidParams,`Elicitation response content does not match requested schema: ${a.errorMessage}`)}catch(s){throw s instanceof F?s:new F(U.InternalError,`Error validating elicitation response: ${s instanceof Error?s.message:String(s)}`)}return o}}}createElicitationCompletionNotifier(t,r){if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support URL elicitation (required for notifications/elicitation/complete)");return()=>this.notification({method:"notifications/elicitation/complete",params:{elicitationId:t}},r)}async listRoots(t,r){return this.request({method:"roots/list",params:t},fp,r)}async sendLoggingMessage(t,r){if(this._capabilities.logging&&!this.isMessageIgnored(t.level,r))return this.notification({method:"notifications/message",params:t})}async sendResourceUpdated(t){return this.notification({method:"notifications/resources/updated",params:t})}async sendResourceListChanged(){return this.notification({method:"notifications/resources/list_changed"})}async sendToolListChanged(){return this.notification({method:"notifications/tools/list_changed"})}async sendPromptListChanged(){return this.notification({method:"notifications/prompts/list_changed"})}};var yS=Symbol.for("mcp.completable");function pg(e){return!!e&&typeof e=="object"&&yS in e}function vS(e){return e[yS]?.complete}var _S;(function(e){e.Completable="McpCompletable"})(_S||(_S={}));var oM=/^[A-Za-z0-9._-]{1,128}$/;function sM(e){let t=[];if(e.length===0)return{isValid:!1,warnings:["Tool name cannot be empty"]};if(e.length>128)return{isValid:!1,warnings:[`Tool name exceeds maximum length of 128 characters (current: ${e.length})`]};if(e.includes(" ")&&t.push("Tool name contains spaces, which may cause parsing issues"),e.includes(",")&&t.push("Tool name contains commas, which may cause parsing issues"),(e.startsWith("-")||e.endsWith("-"))&&t.push("Tool name starts or ends with a dash, which may cause parsing issues in some contexts"),(e.startsWith(".")||e.endsWith("."))&&t.push("Tool name starts or ends with a dot, which may cause parsing issues in some contexts"),!oM.test(e)){let r=e.split("").filter(n=>!/[A-Za-z0-9._-]/.test(n)).filter((n,i,o)=>o.indexOf(n)===i);return t.push(`Tool name contains invalid characters: ${r.map(n=>`"${n}"`).join(", ")}`,"Allowed characters are: A-Z, a-z, 0-9, underscore (_), dash (-), and dot (.)"),{isValid:!1,warnings:t}}return{isValid:!0,warnings:t}}function aM(e,t){if(t.length>0){console.warn(`Tool name validation warning for "${e}":`);for(let r of t)console.warn(` - ${r}`);console.warn("Tool registration will proceed, but this may cause compatibility issues."),console.warn("Consider updating the tool name to conform to the MCP tool naming standard."),console.warn("See SEP: Specify Format for Tool Names (https://github.com/modelcontextprotocol/modelcontextprotocol/issues/986) for more details.")}}function hg(e){let t=sM(e);return aM(e,t.warnings),t.isValid}var au=class{constructor(t){this._mcpServer=t}registerToolTask(t,r,n){let i={taskSupport:"required",...r.execution};if(i.taskSupport==="forbidden")throw new Error(`Cannot register task-based tool '${t}' with taskSupport 'forbidden'. Use registerTool() instead.`);return this._mcpServer._createRegisteredTool(t,r.title,r.description,r.inputSchema,r.outputSchema,r.annotations,i,r._meta,n)}};var cu=class{constructor(t,r){this._registeredResources={},this._registeredResourceTemplates={},this._registeredTools={},this._registeredPrompts={},this._toolHandlersInitialized=!1,this._completionHandlerInitialized=!1,this._resourceHandlersInitialized=!1,this._promptHandlersInitialized=!1,this.server=new su(t,r)}get experimental(){return this._experimental||(this._experimental={tasks:new au(this)}),this._experimental}async connect(t){return await this.server.connect(t)}async close(){await this.server.close()}setToolRequestHandlers(){this._toolHandlersInitialized||(this.server.assertCanSetRequestHandler(ei(dl)),this.server.assertCanSetRequestHandler(ei(Mo)),this.server.registerCapabilities({tools:{listChanged:!0}}),this.server.setRequestHandler(dl,()=>({tools:Object.entries(this._registeredTools).filter(([,t])=>t.enabled).map(([t,r])=>{let n={name:t,title:r.title,description:r.description,inputSchema:(()=>{let i=Go(r.inputSchema);return i?vp(i,{strictUnions:!0,pipeStrategy:"input"}):cM})(),annotations:r.annotations,execution:r.execution,_meta:r._meta};if(r.outputSchema){let i=Go(r.outputSchema);i&&(n.outputSchema=vp(i,{strictUnions:!0,pipeStrategy:"output"}))}return n})})),this.server.setRequestHandler(Mo,async(t,r)=>{try{let n=this._registeredTools[t.params.name];if(!n)throw new F(U.InvalidParams,`Tool ${t.params.name} not found`);if(!n.enabled)throw new F(U.InvalidParams,`Tool ${t.params.name} disabled`);let i=!!t.params.task,o=n.execution?.taskSupport,s="createTask"in n.handler;if((o==="required"||o==="optional")&&!s)throw new F(U.InternalError,`Tool ${t.params.name} has taskSupport '${o}' but was not registered with registerToolTask`);if(o==="required"&&!i)throw new F(U.MethodNotFound,`Tool ${t.params.name} requires task augmentation (taskSupport: 'required')`);if(o==="optional"&&!i&&s)return await this.handleAutomaticTaskPolling(n,t,r);let a=await this.validateToolInput(n,t.params.arguments,t.params.name),u=await this.executeToolHandler(n,a,r);return i||await this.validateToolOutput(n,u,t.params.name),u}catch(n){if(n instanceof F&&n.code===U.UrlElicitationRequired)throw n;return this.createToolError(n instanceof Error?n.message:String(n))}}),this._toolHandlersInitialized=!0)}createToolError(t){return{content:[{type:"text",text:t}],isError:!0}}async validateToolInput(t,r,n){if(!t.inputSchema)return;let o=Go(t.inputSchema)??t.inputSchema,s=await pl(o,r);if(!s.success){let a="error"in s?s.error:"Unknown error",u=hl(a);throw new F(U.InvalidParams,`Input validation error: Invalid arguments for tool ${n}: ${u}`)}return s.data}async validateToolOutput(t,r,n){if(!t.outputSchema||!("content"in r)||r.isError)return;if(!r.structuredContent)throw new F(U.InvalidParams,`Output validation error: Tool ${n} has an output schema but no structured content was provided`);let i=Go(t.outputSchema),o=await pl(i,r.structuredContent);if(!o.success){let s="error"in o?o.error:"Unknown error",a=hl(s);throw new F(U.InvalidParams,`Output validation error: Invalid structured content for tool ${n}: ${a}`)}}async executeToolHandler(t,r,n){let i=t.handler;if("createTask"in i){if(!n.taskStore)throw new Error("No task store provided.");let s={...n,taskStore:n.taskStore};if(t.inputSchema){let a=i;return await Promise.resolve(a.createTask(r,s))}else{let a=i;return await Promise.resolve(a.createTask(s))}}if(t.inputSchema){let s=i;return await Promise.resolve(s(r,n))}else{let s=i;return await Promise.resolve(s(n))}}async handleAutomaticTaskPolling(t,r,n){if(!n.taskStore)throw new Error("No task store provided for task-capable tool.");let i=await this.validateToolInput(t,r.params.arguments,r.params.name),o=t.handler,s={...n,taskStore:n.taskStore},a=i?await Promise.resolve(o.createTask(i,s)):await Promise.resolve(o.createTask(s)),u=a.task.taskId,c=a.task,l=c.pollInterval??5e3;for(;c.status!=="completed"&&c.status!=="failed"&&c.status!=="cancelled";){await new Promise(p=>setTimeout(p,l));let d=await n.taskStore.getTask(u);if(!d)throw new F(U.InternalError,`Task ${u} not found during polling`);c=d}return await n.taskStore.getTaskResult(u)}setCompletionRequestHandler(){this._completionHandlerInitialized||(this.server.assertCanSetRequestHandler(ei(ml)),this.server.registerCapabilities({completions:{}}),this.server.setRequestHandler(ml,async t=>{switch(t.params.ref.type){case"ref/prompt":return U0(t),this.handlePromptCompletion(t,t.params.ref);case"ref/resource":return V0(t),this.handleResourceCompletion(t,t.params.ref);default:throw new F(U.InvalidParams,`Invalid completion reference: ${t.params.ref}`)}}),this._completionHandlerInitialized=!0)}async handlePromptCompletion(t,r){let n=this._registeredPrompts[r.name];if(!n)throw new F(U.InvalidParams,`Prompt ${r.name} not found`);if(!n.enabled)throw new F(U.InvalidParams,`Prompt ${r.name} disabled`);if(!n.argsSchema)return Pa;let o=Un(n.argsSchema)?.[t.params.argument.name];if(!pg(o))return Pa;let s=vS(o);if(!s)return Pa;let a=await s(t.params.argument.value,t.params.context);return wS(a)}async handleResourceCompletion(t,r){let n=Object.values(this._registeredResourceTemplates).find(s=>s.resourceTemplate.uriTemplate.toString()===r.uri);if(!n){if(this._registeredResources[r.uri])return Pa;throw new F(U.InvalidParams,`Resource template ${t.params.ref.uri} not found`)}let i=n.resourceTemplate.completeCallback(t.params.argument.name);if(!i)return Pa;let o=await i(t.params.argument.value,t.params.context);return wS(o)}setResourceRequestHandlers(){this._resourceHandlersInitialized||(this.server.assertCanSetRequestHandler(ei(jo)),this.server.assertCanSetRequestHandler(ei(No)),this.server.assertCanSetRequestHandler(ei(cl)),this.server.registerCapabilities({resources:{listChanged:!0}}),this.server.setRequestHandler(jo,async(t,r)=>{let n=Object.entries(this._registeredResources).filter(([o,s])=>s.enabled).map(([o,s])=>({uri:o,name:s.name,...s.metadata})),i=[];for(let o of Object.values(this._registeredResourceTemplates)){if(!o.resourceTemplate.listCallback)continue;let s=await o.resourceTemplate.listCallback(r);for(let a of s.resources)i.push({...o.metadata,...a})}return{resources:[...n,...i]}}),this.server.setRequestHandler(No,async()=>({resourceTemplates:Object.entries(this._registeredResourceTemplates).map(([r,n])=>({name:r,uriTemplate:n.resourceTemplate.uriTemplate.toString(),...n.metadata}))})),this.server.setRequestHandler(cl,async(t,r)=>{let n=new URL(t.params.uri),i=this._registeredResources[n.toString()];if(i){if(!i.enabled)throw new F(U.InvalidParams,`Resource ${n} disabled`);return i.readCallback(n,r)}for(let o of Object.values(this._registeredResourceTemplates)){let s=o.resourceTemplate.uriTemplate.match(n.toString());if(s)return o.readCallback(n,s,r)}throw new F(U.InvalidParams,`Resource ${n} not found`)}),this._resourceHandlersInitialized=!0)}setPromptRequestHandlers(){this._promptHandlersInitialized||(this.server.assertCanSetRequestHandler(ei(ll)),this.server.assertCanSetRequestHandler(ei(ul)),this.server.registerCapabilities({prompts:{listChanged:!0}}),this.server.setRequestHandler(ll,()=>({prompts:Object.entries(this._registeredPrompts).filter(([,t])=>t.enabled).map(([t,r])=>({name:t,title:r.title,description:r.description,arguments:r.argsSchema?lM(r.argsSchema):void 0}))})),this.server.setRequestHandler(ul,async(t,r)=>{let n=this._registeredPrompts[t.params.name];if(!n)throw new F(U.InvalidParams,`Prompt ${t.params.name} not found`);if(!n.enabled)throw new F(U.InvalidParams,`Prompt ${t.params.name} disabled`);if(n.argsSchema){let i=Go(n.argsSchema),o=await pl(i,t.params.arguments);if(!o.success){let u="error"in o?o.error:"Unknown error",c=hl(u);throw new F(U.InvalidParams,`Invalid arguments for prompt ${t.params.name}: ${c}`)}let s=o.data,a=n.callback;return await Promise.resolve(a(s,r))}else{let i=n.callback;return await Promise.resolve(i(r))}}),this._promptHandlersInitialized=!0)}resource(t,r,...n){let i;typeof n[0]=="object"&&(i=n.shift());let o=n[0];if(typeof r=="string"){if(this._registeredResources[r])throw new Error(`Resource ${r} is already registered`);let s=this._createRegisteredResource(t,void 0,r,i,o);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),s}else{if(this._registeredResourceTemplates[t])throw new Error(`Resource template ${t} is already registered`);let s=this._createRegisteredResourceTemplate(t,void 0,r,i,o);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),s}}registerResource(t,r,n,i){if(typeof r=="string"){if(this._registeredResources[r])throw new Error(`Resource ${r} is already registered`);let o=this._createRegisteredResource(t,n.title,r,n,i);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),o}else{if(this._registeredResourceTemplates[t])throw new Error(`Resource template ${t} is already registered`);let o=this._createRegisteredResourceTemplate(t,n.title,r,n,i);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),o}}_createRegisteredResource(t,r,n,i,o){let s={name:t,title:r,metadata:i,readCallback:o,enabled:!0,disable:()=>s.update({enabled:!1}),enable:()=>s.update({enabled:!0}),remove:()=>s.update({uri:null}),update:a=>{typeof a.uri<"u"&&a.uri!==n&&(delete this._registeredResources[n],a.uri&&(this._registeredResources[a.uri]=s)),typeof a.name<"u"&&(s.name=a.name),typeof a.title<"u"&&(s.title=a.title),typeof a.metadata<"u"&&(s.metadata=a.metadata),typeof a.callback<"u"&&(s.readCallback=a.callback),typeof a.enabled<"u"&&(s.enabled=a.enabled),this.sendResourceListChanged()}};return this._registeredResources[n]=s,s}_createRegisteredResourceTemplate(t,r,n,i,o){let s={resourceTemplate:n,title:r,metadata:i,readCallback:o,enabled:!0,disable:()=>s.update({enabled:!1}),enable:()=>s.update({enabled:!0}),remove:()=>s.update({name:null}),update:c=>{typeof c.name<"u"&&c.name!==t&&(delete this._registeredResourceTemplates[t],c.name&&(this._registeredResourceTemplates[c.name]=s)),typeof c.title<"u"&&(s.title=c.title),typeof c.template<"u"&&(s.resourceTemplate=c.template),typeof c.metadata<"u"&&(s.metadata=c.metadata),typeof c.callback<"u"&&(s.readCallback=c.callback),typeof c.enabled<"u"&&(s.enabled=c.enabled),this.sendResourceListChanged()}};this._registeredResourceTemplates[t]=s;let a=n.uriTemplate.variableNames;return Array.isArray(a)&&a.some(c=>!!n.completeCallback(c))&&this.setCompletionRequestHandler(),s}_createRegisteredPrompt(t,r,n,i,o){let s={title:r,description:n,argsSchema:i===void 0?void 0:qi(i),callback:o,enabled:!0,disable:()=>s.update({enabled:!1}),enable:()=>s.update({enabled:!0}),remove:()=>s.update({name:null}),update:a=>{typeof a.name<"u"&&a.name!==t&&(delete this._registeredPrompts[t],a.name&&(this._registeredPrompts[a.name]=s)),typeof a.title<"u"&&(s.title=a.title),typeof a.description<"u"&&(s.description=a.description),typeof a.argsSchema<"u"&&(s.argsSchema=qi(a.argsSchema)),typeof a.callback<"u"&&(s.callback=a.callback),typeof a.enabled<"u"&&(s.enabled=a.enabled),this.sendPromptListChanged()}};return this._registeredPrompts[t]=s,i&&Object.values(i).some(u=>{let c=u instanceof qt?u._def?.innerType:u;return pg(c)})&&this.setCompletionRequestHandler(),s}_createRegisteredTool(t,r,n,i,o,s,a,u,c){hg(t);let l={title:r,description:n,inputSchema:bS(i),outputSchema:bS(o),annotations:s,execution:a,_meta:u,handler:c,enabled:!0,disable:()=>l.update({enabled:!1}),enable:()=>l.update({enabled:!0}),remove:()=>l.update({name:null}),update:d=>{typeof d.name<"u"&&d.name!==t&&(typeof d.name=="string"&&hg(d.name),delete this._registeredTools[t],d.name&&(this._registeredTools[d.name]=l)),typeof d.title<"u"&&(l.title=d.title),typeof d.description<"u"&&(l.description=d.description),typeof d.paramsSchema<"u"&&(l.inputSchema=qi(d.paramsSchema)),typeof d.outputSchema<"u"&&(l.outputSchema=qi(d.outputSchema)),typeof d.callback<"u"&&(l.handler=d.callback),typeof d.annotations<"u"&&(l.annotations=d.annotations),typeof d._meta<"u"&&(l._meta=d._meta),typeof d.enabled<"u"&&(l.enabled=d.enabled),this.sendToolListChanged()}};return this._registeredTools[t]=l,this.setToolRequestHandlers(),this.sendToolListChanged(),l}tool(t,...r){if(this._registeredTools[t])throw new Error(`Tool ${t} is already registered`);let n,i,o,s;if(typeof r[0]=="string"&&(n=r.shift()),r.length>1){let u=r[0];if(gg(u))i=r.shift(),r.length>1&&typeof r[0]=="object"&&r[0]!==null&&!gg(r[0])&&(s=r.shift());else if(typeof u=="object"&&u!==null){if(Object.values(u).some(c=>typeof c=="object"&&c!==null))throw new Error(`Tool ${t} expected a Zod schema or ToolAnnotations, but received an unrecognized object`);s=r.shift()}}let a=r[0];return this._createRegisteredTool(t,void 0,n,i,o,s,{taskSupport:"forbidden"},void 0,a)}registerTool(t,r,n){if(this._registeredTools[t])throw new Error(`Tool ${t} is already registered`);let{title:i,description:o,inputSchema:s,outputSchema:a,annotations:u,_meta:c}=r;return this._createRegisteredTool(t,i,o,s,a,u,{taskSupport:"forbidden"},c,n)}prompt(t,...r){if(this._registeredPrompts[t])throw new Error(`Prompt ${t} is already registered`);let n;typeof r[0]=="string"&&(n=r.shift());let i;r.length>1&&(i=r.shift());let o=r[0],s=this._createRegisteredPrompt(t,void 0,n,i,o);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),s}registerPrompt(t,r,n){if(this._registeredPrompts[t])throw new Error(`Prompt ${t} is already registered`);let{title:i,description:o,argsSchema:s}=r,a=this._createRegisteredPrompt(t,i,o,s,n);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),a}isConnected(){return this.server.transport!==void 0}async sendLoggingMessage(t,r){return this.server.sendLoggingMessage(t,r)}sendResourceListChanged(){this.isConnected()&&this.server.sendResourceListChanged()}sendToolListChanged(){this.isConnected()&&this.server.sendToolListChanged()}sendPromptListChanged(){this.isConnected()&&this.server.sendPromptListChanged()}};var cM={type:"object",properties:{}};function kS(e){return e!==null&&typeof e=="object"&&"parse"in e&&typeof e.parse=="function"&&"safeParse"in e&&typeof e.safeParse=="function"}function xS(e){return"_def"in e||"_zod"in e||kS(e)}function gg(e){return typeof e!="object"||e===null||xS(e)?!1:Object.keys(e).length===0?!0:Object.values(e).some(kS)}function bS(e){if(e){if(gg(e))return qi(e);if(!xS(e))throw new Error("inputSchema must be a Zod schema or raw shape, received an unrecognized object");return e}}function lM(e){let t=Un(e);return t?Object.entries(t).map(([r,n])=>{let i=B0(n),o=W0(n);return{name:r,description:i,required:!o}}):[]}function ei(e){let r=Un(e)?.method;if(!r)throw new Error("Schema is missing a method literal");let n=gl(r);if(typeof n=="string")return n;throw new Error("Schema method literal must be a string")}function wS(e){return{completion:{values:e.slice(0,100),total:e.length,hasMore:e.length>100}}}var Pa={completion:{values:[],hasMore:!1}};import TS from"node:process";var lu=class{append(t){this._buffer=this._buffer?Buffer.concat([this._buffer,t]):t}readMessage(){if(!this._buffer)return null;let t=this._buffer.indexOf(`
457
+ `);if(t===-1)return null;let r=this._buffer.toString("utf8",0,t).replace(/\r$/,"");return this._buffer=this._buffer.subarray(t+1),dM(r)}clear(){this._buffer=void 0}};function dM(e){return N0.parse(JSON.parse(e))}function SS(e){return JSON.stringify(e)+`
458
+ `}var uu=class{constructor(t=TS.stdin,r=TS.stdout){this._stdin=t,this._stdout=r,this._readBuffer=new lu,this._started=!1,this._ondata=n=>{this._readBuffer.append(n),this.processReadBuffer()},this._onerror=n=>{this.onerror?.(n)}}async start(){if(this._started)throw new Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");this._started=!0,this._stdin.on("data",this._ondata),this._stdin.on("error",this._onerror)}processReadBuffer(){for(;;)try{let t=this._readBuffer.readMessage();if(t===null)break;this.onmessage?.(t)}catch(t){this.onerror?.(t)}}async close(){this._stdin.off("data",this._ondata),this._stdin.off("error",this._onerror),this._stdin.listenerCount("data")===0&&this._stdin.pause(),this._readBuffer.clear(),this.onclose?.()}send(t){return new Promise(r=>{let n=SS(t);this._stdout.write(n)?r():this._stdout.once("drain",r)})}};function mM(e){let t={};t.listChanged=!1;let r={};r.resources=t,e.server.registerCapabilities(r),e.server.setRequestHandler(jo,()=>{let n={};return n.resources=[],n}),e.server.setRequestHandler(No,()=>{let n={};return n.resourceTemplates=[],n})}function pM(e){return{registerTool:(t,r,n,i)=>{e.tool(t,r,n,i)},registerSchemaTool:(t,r,n,i,o)=>{e.registerTool(t,{description:r,inputSchema:i},o)}}}function hM(e){return(t,r)=>e.server.elicitInput(t,{timeout:r})}async function _g(e){let t=e.delegationAuthFilePath;if(t!==void 0){let s=e.explicitToken,a=e.authFilePath;if(s!==void 0)return{TAG:"Error",_0:"--delegation-auth-file cannot be combined with --token or --auth-file"};if(a!==void 0)return{TAG:"Error",_0:"--delegation-auth-file cannot be combined with --token or --auth-file"};let u=oy(t,Date.now());if(u.TAG!=="Ok")return{TAG:"Error",_0:u._0.summary};let c=u._0;return{TAG:"Ok",_0:{initialAccessToken:c.accessToken,accessToken:{TAG:"StaticAccessToken",_0:c.accessToken},mode:"PersonalAgentDelegation"}}}let r=await Fy(e.serviceUrl,e.explicitToken,e.authFilePath,e.workspaceSlug,e.channelSlug,void 0);if(r.TAG!=="Ok")return{TAG:"Error",_0:r._0.summary};let n=r._0,i=e.explicitToken,o;if(i!==void 0)o={TAG:"StaticAccessToken",_0:n};else{let s=e.authFilePath,a=s!==void 0?s:go();o={TAG:"DynamicAccessToken",_0:()=>{let u=_o(e.serviceUrl,a,Date.now());if(u.TAG!=="Ok")return{TAG:"Error",_0:u._0.summary};let c=u._0;return c!==void 0?{TAG:"Ok",_0:c.accessToken}:{TAG:"Error",_0:gd}}}}return{TAG:"Ok",_0:{initialAccessToken:n,accessToken:o,mode:"LocalRunner"}}}function yg(e,t){let r=Qe(e,"token");return{serviceUrl:t,explicitToken:r!==void 0?r:process.env.LINZUMI_MCP_ACCESS_TOKEN,authFilePath:Qe(e,"auth-file"),delegationAuthFilePath:Qe(e,"delegation-auth-file"),workspaceSlug:Qe(e,"workspace"),channelSlug:Qe(e,"channel")}}async function gM(e){let t=Ha(e);if(t.TAG!=="Ok")return{TAG:"Error",_0:t._0};let r=t._0;if(so(r,"help"))return ai(Xa()),{TAG:"Ok",_0:void 0};let n=Ka(r,"api-url");if(n.TAG!=="Ok")return{TAG:"Error",_0:n._0};let i=n._0,o=await _g(yg(r,i));if(o.TAG!=="Ok")return{TAG:"Error",_0:o._0};let s=o._0,a=Qa(Qe(r,"mode")),u=Au(Qe(r,"tool-scope"));if(a.TAG!=="Ok")return{TAG:"Error",_0:a._0};let c=a._0;if(u.TAG!=="Ok")return{TAG:"Error",_0:u._0};let l=Qe(r,"owner-username"),d=l!==void 0?l:process.env.LINZUMI_MCP_OWNER_USERNAME,p=Qe(r,"cwd"),f=p!==void 0?p:process.cwd(),h=Qe(r,"thread-id"),m=h!==void 0?h:process.env[nv],g=Ud({serviceUrl:i,accessToken:s.accessToken,authMode:s.mode,operatingMode:c});if(g.TAG!=="Ok")return{TAG:"Error",_0:g._0};let y=new cu({name:"linzumi",version:"0.1.0"});return mM(y),Lv(pM(y),{client:g._0,toolScope:u._0,operatingMode:c,cwd:f,serviceUrl:i,defaultThreadId:m,ownerUsername:d,agentSession:so(r,"agent-session"),documentSurfaces:ly(s.initialAccessToken),multiAgentJobs:so(r,"multi-agent-jobs"),devServices:Sv(process.env),askUserQuestion:so(r,"ask-user-question-tool")?hM(y):void 0}),await y.connect(new uu),{TAG:"Ok",_0:void 0}}async function _M(e){let t=Ha(e);if(t.TAG!=="Ok")return{TAG:"Error",_0:t._0};let r=t._0,n=Ka(r,"api-url");if(n.TAG!=="Ok")return{TAG:"Error",_0:n._0};let i=n._0,o=Qe(r,"format"),s=o!==void 0?o:"codex",a=Qa(Qe(r,"mode"));if(a.TAG!=="Ok")return{TAG:"Error",_0:a._0};let u;if(so(r,"include-token")){let p=await _g(yg(r,i));u=p.TAG==="Ok"?{TAG:"Ok",_0:p._0.initialAccessToken}:{TAG:"Error",_0:p._0}}else u={TAG:"Ok",_0:void 0};if(u.TAG!=="Ok")return{TAG:"Error",_0:u._0};let c=Au(Qe(r,"tool-scope"));if(c.TAG!=="Ok")return{TAG:"Error",_0:c._0};let l=Qe(r,"owner-username"),d=Av({command:Qe(r,"command"),serviceUrl:i,accessToken:u._0,delegationAuthFilePath:Qe(r,"delegation-auth-file"),ownerUsername:l!==void 0?l:process.env.LINZUMI_MCP_OWNER_USERNAME,operatingMode:a._0,toolScope:c._0});switch(s){case"claude-code":return ai(Ov(d)),{TAG:"Ok",_0:void 0};case"codex":return ai(Pv(d)),{TAG:"Ok",_0:void 0};default:return{TAG:"Error",_0:"--format must be codex or claude-code"}}}async function yM(e){let t=Ha(e);if(t.TAG!=="Ok")return{TAG:"Error",_0:t._0};let r=t._0,n=Ka(r,"api-url");if(n.TAG!=="Ok")return{TAG:"Error",_0:n._0};let i=n._0,o=await _g(yg(r,i));if(o.TAG!=="Ok")return{TAG:"Error",_0:o._0};let s=o._0,a=s.mode,u;if(a==="LocalRunner"){let c=await vo(i,s.initialAccessToken,Qe(r,"workspace"),Qe(r,"channel"),void 0);if(c.TAG==="Ok")switch(c._0){case"Usable":u={TAG:"Ok",_0:void 0};break;case"Rejected":case"NotFound":u={TAG:"Error",_0:"Linzumi MCP auth validation failed"};break}else u={TAG:"Error",_0:c._0.summary}}else{let c=Qa(Qe(r,"mode"));if(c.TAG==="Ok"){let l=Ud({serviceUrl:i,accessToken:s.accessToken,authMode:s.mode,operatingMode:c._0});if(l.TAG==="Ok")try{await l._0.validateAuth(),u={TAG:"Ok",_0:void 0}}catch(d){let p=K(d);u={TAG:"Error",_0:on(p)}}else u={TAG:"Error",_0:l._0}}else u={TAG:"Error",_0:c._0}}return u.TAG!=="Ok"?{TAG:"Error",_0:u._0}:(ai(`Linzumi MCP auth OK
459
+ `),{TAG:"Ok",_0:void 0})}async function $S(e){let t=e.slice(1),r=e[0];if(r!==void 0)switch(r){case"--help":case"-h":return ai(Xa()),{TAG:"Ok",_0:void 0};case"config":return await _M(t);case"doctor":return await yM(t);case"server":return await gM(t);default:return{TAG:"Error",_0:"unknown linzumi mcp command: "+r}}else return ai(Xa()),{TAG:"Ok",_0:void 0}}async function bM(e){let t;try{t=await $S(c_(e))}catch(r){let n=K(r);return $n("linzumi mcp server failed: "+on(n)+`
460
460
  `),Pu(1)}if(t.TAG!=="Ok")return $n("linzumi mcp server failed: "+t._0+`
461
- `),Pu(1)}var $S=process.argv[1],vM=$S!==void 0?import.meta.url===ES.pathToFileURL($S).href:!1;vM&&yM(process.argv.slice(2));export{vM as invokedDirectly,yM as runMcpServerEntry};
461
+ `),Pu(1)}var ES=process.argv[1],wM=ES!==void 0?import.meta.url===zS.pathToFileURL(ES).href:!1;wM&&bM(process.argv.slice(2));export{wM as invokedDirectly,bM as runMcpServerEntry};