@edifice.io/directory-node-client 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,23 @@
1
+ (function(Ie,he){typeof exports=="object"&&typeof module<"u"?he(exports):typeof define=="function"&&define.amd?define(["exports"],he):(Ie=typeof globalThis<"u"?globalThis:Ie||self,he((Ie["@edifice"]=Ie["@edifice"]||{},Ie["@edifice"]["io/directory-node-client"]={})))})(this,function(Ie){"use strict";var Qi=Object.defineProperty;var eo=(Ie,he,tt)=>he in Ie?Qi(Ie,he,{enumerable:!0,configurable:!0,writable:!0,value:tt}):Ie[he]=tt;var d=(Ie,he,tt)=>(eo(Ie,typeof he!="symbol"?he+"":he,tt),tt);var he=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function tt(t){if(t.__esModule)return t;var e=t.default;if(typeof e=="function"){var r=function s(){return this instanceof s?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};r.prototype=e.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(t).forEach(function(s){var o=Object.getOwnPropertyDescriptor(t,s);Object.defineProperty(r,s,o.get?o:{enumerable:!0,get:function(){return t[s]}})}),r}var Hr={},Jr={},Et={},ye={},ke={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.TD=t.TE=t.Empty=void 0,t.encode=r,t.decode=s,t.Empty=new Uint8Array(0),t.TE=new TextEncoder,t.TD=new TextDecoder;function e(...o){let f=0;for(let P=0;P<o.length;P++)f+=o[P].length;const l=new Uint8Array(f);let m=0;for(let P=0;P<o.length;P++)l.set(o[P],m),m+=o[P].length;return l}function r(...o){const f=[];for(let l=0;l<o.length;l++)f.push(t.TE.encode(o[l]));return f.length===0?t.Empty:f.length===1?f[0]:e(...f)}function s(o){return!o||o.length===0?"":t.TD.decode(o)}})(ke);var te={};Object.defineProperty(te,"__esModule",{value:!0}),te.errors=te.PermissionViolationError=te.NoRespondersError=te.TimeoutError=te.RequestError=te.ProtocolError=te.ConnectionError=te.DrainingConnectionError=te.ClosedConnectionError=te.AuthorizationError=te.UserAuthenticationExpiredError=te.InvalidOperationError=te.InvalidArgumentError=te.InvalidSubjectError=void 0;class Vr extends Error{constructor(e,r){super(`illegal subject: '${e}'`,r),this.name="InvalidSubjectError"}}te.InvalidSubjectError=Vr;class Dt extends Error{constructor(e,r){super(e,r),this.name="InvalidArgumentError"}static format(e,r,s){return Array.isArray(r)&&r.length>1&&(r=r[0]),Array.isArray(e)?(e=e.map(o=>`'${o}'`),e=e.join(",")):e=`'${e}'`,new Dt(`${e} ${r}`,s)}}te.InvalidArgumentError=Dt;class Yr extends Error{constructor(e,r){super(e,r),this.name="InvalidOperationError"}}te.InvalidOperationError=Yr;class Gt extends Error{constructor(e,r){super(e,r),this.name="UserAuthenticationExpiredError"}static parse(e){return e.toLowerCase().indexOf("user authentication expired")!==-1?new Gt(e):null}}te.UserAuthenticationExpiredError=Gt;class zt extends Error{constructor(e,r){super(e,r),this.name="AuthorizationError"}static parse(e){const r=["authorization violation","account authentication expired","authentication timeout"],s=e.toLowerCase();for(let o=0;o<r.length;o++)if(s.indexOf(r[o])!==-1)return new zt(e);return null}}te.AuthorizationError=zt;class Wr extends Error{constructor(){super("closed connection"),this.name="ClosedConnectionError"}}te.ClosedConnectionError=Wr;class Xr extends Error{constructor(){super("connection draining"),this.name="DrainingConnectionError"}}te.DrainingConnectionError=Xr;class Zr extends Error{constructor(e,r){super(e,r),this.name="ConnectionError"}}te.ConnectionError=Zr;class Qr extends Error{constructor(e,r){super(e,r),this.name="ProtocolError"}}te.ProtocolError=Qr;class en extends Error{constructor(e="",r){super(e,r),this.name="RequestError"}isNoResponders(){return this.cause instanceof dr}}te.RequestError=en;class tn extends Error{constructor(e){super("timeout",e),this.name="TimeoutError"}}te.TimeoutError=tn;class dr extends Error{constructor(r,s){super(`no responders: '${r}'`,s);d(this,"subject");this.subject=r,this.name="NoResponders"}}te.NoRespondersError=dr;class Ht extends Error{constructor(r,s,o,f,l){super(r,l);d(this,"operation");d(this,"subject");d(this,"queue");this.name="PermissionViolationError",this.operation=s,this.subject=o,this.queue=f}static parse(r){if((r?r.toLowerCase():"").indexOf("permissions violation")===-1)return null;let o="publish",f="",l;const m=r.match(/(Publish|Subscription) to "(\S+)"/);if(m&&(o=m[1].toLowerCase(),f=m[2],o==="subscription")){const P=r.match(/using queue "(\S+)"/);P&&(l=P[1])}return new Ht(r,o,f,l)}}te.PermissionViolationError=Ht,te.errors={AuthorizationError:zt,ClosedConnectionError:Wr,ConnectionError:Zr,DrainingConnectionError:Xr,InvalidArgumentError:Dt,InvalidOperationError:Yr,InvalidSubjectError:Vr,NoRespondersError:dr,PermissionViolationError:Ht,ProtocolError:Qr,RequestError:en,TimeoutError:tn,UserAuthenticationExpiredError:Gt},Object.defineProperty(ye,"__esModule",{value:!0}),ye.SimpleMutex=ye.Perf=void 0,ye.extend=fs,ye.render=us,ye.timeout=hs,ye.delay=ds,ye.deadline=ls,ye.deferred=br,ye.debugDeferred=bs,ye.shuffle=ys,ye.collect=gs,ye.jitter=rn,ye.backoff=vs,ye.nanos=ps,ye.millis=xs;const cs=ke,lr=te;function fs(t,...e){for(let r=0;r<e.length;r++){const s=e[r];Object.keys(s).forEach(function(o){t[o]=s[o]})}return t}function us(t){return cs.TD.decode(t).replace(/\n/g,"␊").replace(/\r/g,"␍")}function hs(t,e=!0){const r=e?new lr.TimeoutError:null;let s,o;const f=new Promise((l,m)=>{s={cancel:()=>{o&&clearTimeout(o)}},o=setTimeout(()=>{m(r===null?new lr.TimeoutError:r)},t)});return Object.assign(f,s)}function ds(t=0){let e;const r=new Promise(s=>{const o=setTimeout(()=>{s()},t);e={cancel:()=>{o&&(clearTimeout(o),s())}}});return Object.assign(r,e)}async function ls(t,e=1e3){const r=br(),s=setTimeout(()=>{r.reject(new lr.TimeoutError)},e);try{return await Promise.race([t,r])}finally{clearTimeout(s)}}function br(){let t={};const e=new Promise((r,s)=>{t={resolve:r,reject:s}});return Object.assign(e,t)}function bs(){let t={};const e=new Promise((r,s)=>{t={resolve:o=>{console.trace("resolve",o),r(o)},reject:o=>{console.trace("reject"),s(o)}}});return Object.assign(e,t)}function ys(t){for(let e=t.length-1;e>0;e--){const r=Math.floor(Math.random()*(e+1));[t[e],t[r]]=[t[r],t[e]]}return t}async function gs(t){const e=[];for await(const r of t)e.push(r);return e}class _s{constructor(){d(this,"timers");d(this,"measures");this.timers=new Map,this.measures=new Map}mark(e){this.timers.set(e,performance.now())}measure(e,r,s){const o=this.timers.get(r);if(o===void 0)throw new Error(`${r} is not defined`);const f=this.timers.get(s);if(f===void 0)throw new Error(`${s} is not defined`);this.measures.set(e,f-o)}getEntries(){const e=[];return this.measures.forEach((r,s)=>{e.push({name:s,duration:r})}),e}}ye.Perf=_s;class ms{constructor(e=1){d(this,"max");d(this,"current");d(this,"waiting");this.max=e,this.current=0,this.waiting=[]}lock(){if(this.current++,this.current<=this.max)return Promise.resolve();const e=br();return this.waiting.push(e),e}unlock(){this.current--;const e=this.waiting.pop();e==null||e.resolve()}}ye.SimpleMutex=ms;function rn(t){return t===0?0:Math.floor(t/2+Math.random()*t)}function vs(t=[0,250,250,500,500,3e3,5e3]){Array.isArray(t)||(t=[0,250,250,500,500,3e3,5e3]);const e=t.length-1;return{backoff(r){return rn(r>e?t[e]:t[r])}}}function ps(t){return t*1e6}function xs(t){return Math.floor(t/1e6)}var Me={},rt={},Oe={},Pt={},ft={};Object.defineProperty(ft,"__esModule",{value:!0}),ft.nuid=ft.Nuid=void 0;const nn="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",yr=36,Jt=12,ws=10,sn=0xcfd41b9100000,on=33,Es=333,an=Jt+ws;function Ps(t){for(let e=0;e<t.length;e++)t[e]=Math.floor(Math.random()*255)}function Ss(t){var e;(e=globalThis==null?void 0:globalThis.crypto)!=null&&e.getRandomValues?globalThis.crypto.getRandomValues(t):Ps(t)}class cn{constructor(){d(this,"buf");d(this,"seq");d(this,"inc");d(this,"inited");this.buf=new Uint8Array(an),this.inited=!1}init(){this.inited=!0,this.setPre(),this.initSeqAndInc(),this.fillSeq()}initSeqAndInc(){this.seq=Math.floor(Math.random()*sn),this.inc=Math.floor(Math.random()*(Es-on)+on)}setPre(){const e=new Uint8Array(Jt);Ss(e);for(let r=0;r<Jt;r++){const s=e[r]%yr;this.buf[r]=nn.charCodeAt(s)}}fillSeq(){let e=this.seq;for(let r=an-1;r>=Jt;r--)this.buf[r]=nn.charCodeAt(e%yr),e=Math.floor(e/yr)}next(){return this.inited||this.init(),this.seq+=this.inc,this.seq>sn&&(this.setPre(),this.initSeqAndInc()),this.fillSeq(),String.fromCharCode.apply(String,this.buf)}reset(){this.init()}}ft.Nuid=cn,ft.nuid=new cn,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.nuid=t.Nuid=void 0;var e=ft;Object.defineProperty(t,"Nuid",{enumerable:!0,get:function(){return e.Nuid}}),Object.defineProperty(t,"nuid",{enumerable:!0,get:function(){return e.nuid}})}(Pt),Object.defineProperty(Oe,"__esModule",{value:!0}),Oe.DEFAULT_HOST=Oe.DEFAULT_PORT=Oe.Match=void 0,Oe.syncIterator=Cs,Oe.createInbox=js;const As=Pt,Os=te;Oe.Match={Exact:"exact",CanonicalMIME:"canonical",IgnoreCase:"insensitive"};function Cs(t){const e=t[Symbol.asyncIterator]();return{async next(){const r=await e.next();return r.done?Promise.resolve(null):Promise.resolve(r.value)}}}function js(t=""){if(t=t||"_INBOX",typeof t!="string")throw new TypeError("prefix must be a string");return t.split(".").forEach(e=>{if(e==="*"||e===">")throw Os.InvalidArgumentError.format("prefix",`cannot have wildcards ('${t}')`)}),`${t}.${As.nuid.next()}`}Oe.DEFAULT_PORT=4222,Oe.DEFAULT_HOST="127.0.0.1";var nt={};Object.defineProperty(nt,"__esModule",{value:!0}),nt.DataBuffer=void 0;const fn=ke;class Ns{constructor(){d(this,"buffers");d(this,"byteLength");this.buffers=[],this.byteLength=0}static concat(...e){let r=0;for(let f=0;f<e.length;f++)r+=e[f].length;const s=new Uint8Array(r);let o=0;for(let f=0;f<e.length;f++)s.set(e[f],o),o+=e[f].length;return s}static fromAscii(e){return e||(e=""),fn.TE.encode(e)}static toAscii(e){return fn.TD.decode(e)}reset(){this.buffers.length=0,this.byteLength=0}pack(){if(this.buffers.length>1){const e=new Uint8Array(this.byteLength);let r=0;for(let s=0;s<this.buffers.length;s++)e.set(this.buffers[s],r),r+=this.buffers[s].length;this.buffers.length=0,this.buffers.push(e)}}shift(){if(this.buffers.length){const e=this.buffers.shift();if(e)return this.byteLength-=e.length,e}return new Uint8Array(0)}drain(e){if(this.buffers.length){this.pack();const r=this.buffers.pop();if(r){const s=this.byteLength;(e===void 0||e>s)&&(e=s);const o=r.subarray(0,e);return s>e&&this.buffers.push(r.subarray(e)),this.byteLength=s-e,o}}return new Uint8Array(0)}fill(e,...r){e&&(this.buffers.push(e),this.byteLength+=e.length);for(let s=0;s<r.length;s++)r[s]&&r[s].length&&(this.buffers.push(r[s]),this.byteLength+=r[s].length)}peek(){return this.buffers.length?(this.pack(),this.buffers[0]):new Uint8Array(0)}size(){return this.byteLength}length(){return this.buffers.length}}nt.DataBuffer=Ns,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.LF=t.CR=t.CRLF=t.CR_LF_LEN=t.CR_LF=void 0,t.setTransportFactory=f,t.defaultPort=l,t.getUrlParseFn=m,t.newTransport=P,t.getResolveFn=_,t.protoLen=w,t.extractProtocolMessage=E;const e=ke,r=Oe,s=nt;let o;function f(b){o=b}function l(){return o!==void 0&&o.defaultPort!==void 0?o.defaultPort:r.DEFAULT_PORT}function m(){return o!==void 0&&o.urlParseFn?o.urlParseFn:void 0}function P(){if(!o||typeof o.factory!="function")throw new Error("transport fn is not set");return o.factory()}function _(){return o!==void 0&&o.dnsResolveFn?o.dnsResolveFn:void 0}t.CR_LF=`\r
2
+ `,t.CR_LF_LEN=t.CR_LF.length,t.CRLF=s.DataBuffer.fromAscii(t.CR_LF),t.CR=new Uint8Array(t.CRLF)[0],t.LF=new Uint8Array(t.CRLF)[1];function w(b){for(let p=0;p<b.length;p++){const R=p+1;if(b.byteLength>R&&b[p]===t.CR&&b[R]===t.LF)return R+1}return 0}function E(b){const p=w(b);if(p>0){const M=new Uint8Array(b).slice(0,p);return e.TD.decode(M)}return""}}(rt);var Ve={},ut={};Object.defineProperty(ut,"__esModule",{value:!0}),ut.ipV4=ln,ut.isIP=Ts,ut.parseIP=bn;const St=4,st=16,Vt=48,un=57,hn=65,Ms=70,dn=97,Is=102,gr=16777215;function ln(t,e,r,s){const o=new Uint8Array(st);return[0,0,0,0,0,0,0,0,0,0,255,255].forEach((l,m)=>{o[m]=l}),o[12]=t,o[13]=e,o[14]=r,o[15]=s,o}function Ts(t){return bn(t)!==void 0}function bn(t){for(let e=0;e<t.length;e++)switch(t[e]){case".":return yn(t);case":":return Rs(t)}}function yn(t){const e=new Uint8Array(St);for(let r=0;r<St;r++){if(t.length===0)return;if(r>0){if(t[0]!==".")return;t=t.substring(1)}const{n:s,c:o,ok:f}=ks(t);if(!f||s>255)return;t=t.substring(o),e[r]=s}return ln(e[0],e[1],e[2],e[3])}function Rs(t){const e=new Uint8Array(st);let r=-1;if(t.length>=2&&t[0]===":"&&t[1]===":"&&(r=0,t=t.substring(2),t.length===0))return e;let s=0;for(;s<st;){const{n:o,c:f,ok:l}=Us(t);if(!l||o>65535)return;if(f<t.length&&t[f]==="."){if(r<0&&s!=st-St||s+St>st)return;const m=yn(t);if(m===void 0)return;e[s]=m[12],e[s+1]=m[13],e[s+2]=m[14],e[s+3]=m[15],t="",s+=St;break}if(e[s]=o>>8,e[s+1]=o,s+=2,t=t.substring(f),t.length===0)break;if(t[0]!==":"||t.length==1)return;if(t=t.substring(1),t[0]===":"){if(r>=0)return;if(r=s,t=t.substring(1),t.length===0)break}}if(t.length===0){if(s<st){if(r<0)return;const o=st-s;for(let f=s-1;f>=r;f--)e[f+o]=e[f];for(let f=r+o-1;f>=r;f--)e[f]=0}else if(r>=0)return;return e}}function ks(t){let e=0,r=0;for(e=0;e<t.length&&Vt<=t.charCodeAt(e)&&t.charCodeAt(e)<=un;e++)if(r=r*10+(t.charCodeAt(e)-Vt),r>=gr)return{n:gr,c:e,ok:!1};return e===0?{n:0,c:0,ok:!1}:{n:r,c:e,ok:!0}}function Us(t){let e=0,r=0;for(r=0;r<t.length;r++){if(Vt<=t.charCodeAt(r)&&t.charCodeAt(r)<=un)e*=16,e+=t.charCodeAt(r)-Vt;else if(dn<=t.charCodeAt(r)&&t.charCodeAt(r)<=Is)e*=16,e+=t.charCodeAt(r)-dn+10;else if(hn<=t.charCodeAt(r)&&t.charCodeAt(r)<=Ms)e*=16,e+=t.charCodeAt(r)-hn+10;else break;if(e>=gr)return{n:0,c:r,ok:!1}}return r===0?{n:0,c:r,ok:!1}:{n:e,c:r,ok:!0}}Object.defineProperty(Ve,"__esModule",{value:!0}),Ve.Servers=Ve.ServerImpl=void 0,Ve.isIPV4OrHostname=mn,Ve.hostPort=vn;const Yt=rt,gn=ye,_r=ut,_n=Oe;function mn(t){return t.indexOf("[")!==-1||t.indexOf("::")!==-1?!1:t.indexOf(".")!==-1||t.split(":").length<=2}function mr(t){return!mn(t)}function Ls(t){const e="::FFFF:",r=t.toUpperCase().indexOf(e);if(r!==-1&&t.indexOf(".")!==-1){let s=t.substring(r+e.length);return s=s.replace("[",""),s.replace("]","")}return t}function vn(t){t=t.trim(),t.match(/^(.*:\/\/)(.*)/m)&&(t=t.replace(/^(.*:\/\/)(.*)/gm,"$2")),t=Ls(t),mr(t)&&t.indexOf("[")===-1&&(t=`[${t}]`);const e=mr(t)?t.match(/(]:)(\d+)/):t.match(/(:)(\d+)/),r=e&&e.length===3&&e[1]&&e[2]?parseInt(e[2]):_n.DEFAULT_PORT,s=r===80?"https":"http",o=new URL(`${s}://${t}`);o.port=`${r}`;let f=o.hostname;return f.charAt(0)==="["&&(f=f.substring(1,f.length-1)),{listen:o.host,hostname:f,port:r}}class ht{constructor(e,r=!1){d(this,"src");d(this,"listen");d(this,"hostname");d(this,"port");d(this,"didConnect");d(this,"reconnects");d(this,"lastConnect");d(this,"gossiped");d(this,"tlsName");d(this,"resolves");this.src=e,this.tlsName="";const s=vn(e);this.listen=s.listen,this.hostname=s.hostname,this.port=s.port,this.didConnect=!1,this.reconnects=0,this.lastConnect=0,this.gossiped=r}toString(){return this.listen}async resolve(e){if(!e.fn||e.resolve===!1)return[this];const r=[];if((0,_r.isIP)(this.hostname))return[this];{const s=await e.fn(this.hostname);e.debug&&console.log(`resolve ${this.hostname} = ${s.join(",")}`);for(const o of s){const f=this.port===80?"https":"http",l=new URL(`${f}://${mr(o)?"["+o+"]":o}`);l.port=`${this.port}`;const m=new ht(l.host,!1);m.tlsName=this.hostname,r.push(m)}}return e.randomize&&(0,gn.shuffle)(r),this.resolves=r,r}}Ve.ServerImpl=ht;class Fs{constructor(e=[],r={}){d(this,"firstSelect");d(this,"servers");d(this,"currentServer");d(this,"tlsName");d(this,"randomize");this.firstSelect=!0,this.servers=[],this.tlsName="",this.randomize=r.randomize||!1;const s=(0,Yt.getUrlParseFn)();e&&(e.forEach(o=>{o=s?s(o):o,this.servers.push(new ht(o))}),this.randomize&&(this.servers=(0,gn.shuffle)(this.servers))),this.servers.length===0&&this.addServer(`${_n.DEFAULT_HOST}:${(0,Yt.defaultPort)()}`,!1),this.currentServer=this.servers[0]}clear(){this.servers.length=0}updateTLSName(){const e=this.getCurrentServer();(0,_r.isIP)(e.hostname)||(this.tlsName=e.hostname,this.servers.forEach(r=>{r.gossiped&&(r.tlsName=this.tlsName)}))}getCurrentServer(){return this.currentServer}addServer(e,r=!1){const s=(0,Yt.getUrlParseFn)();e=s?s(e):e;const o=new ht(e,r);(0,_r.isIP)(o.hostname)&&(o.tlsName=this.tlsName),this.servers.push(o)}selectServer(){if(this.firstSelect)return this.firstSelect=!1,this.currentServer;const e=this.servers.shift();return e&&(this.servers.push(e),this.currentServer=e),e}removeCurrentServer(){this.removeServer(this.currentServer)}removeServer(e){if(e){const r=this.servers.indexOf(e);this.servers.splice(r,1)}}length(){return this.servers.length}next(){return this.servers.length?this.servers[0]:void 0}getServers(){return this.servers}update(e,r){const s=[];let o=[];const f=(0,Yt.getUrlParseFn)(),l=new Map;e.connect_urls&&e.connect_urls.length>0&&e.connect_urls.forEach(P=>{P=f?f(P,r):P;const _=new ht(P,!0);l.set(P,_)});const m=[];return this.servers.forEach((P,_)=>{const w=P.listen;P.gossiped&&this.currentServer.listen!==w&&l.get(w)===void 0&&m.push(_),l.delete(w)}),m.reverse(),m.forEach(P=>{const _=this.servers.splice(P,1);o=o.concat(_[0].listen)}),l.forEach((P,_)=>{this.servers.push(P),s.push(_)}),{added:s,deleted:o}}}Ve.Servers=Fs;var dt={};Object.defineProperty(dt,"__esModule",{value:!0}),dt.QueuedIteratorImpl=void 0;const vr=ye,pn=te;class Bs{constructor(){d(this,"inflight");d(this,"processed");d(this,"received");d(this,"noIterator");d(this,"iterClosed");d(this,"done");d(this,"signal");d(this,"yields");d(this,"filtered");d(this,"pendingFiltered");d(this,"ctx");d(this,"_data");d(this,"err");d(this,"time");d(this,"profile");d(this,"yielding");d(this,"didBreak");this.inflight=0,this.filtered=0,this.pendingFiltered=0,this.processed=0,this.received=0,this.noIterator=!1,this.done=!1,this.signal=(0,vr.deferred)(),this.yields=[],this.iterClosed=(0,vr.deferred)(),this.time=0,this.yielding=!1,this.didBreak=!1,this.profile=!1}[Symbol.asyncIterator](){return this.iterate()}push(e){if(!this.done){if(this.didBreak){if(typeof e=="function"){const r=e;try{r()}catch{}}return}typeof e=="function"&&this.pendingFiltered++,this.yields.push(e),this.signal.resolve()}}async*iterate(){if(this.noIterator)throw new pn.InvalidOperationError("iterator cannot be used when a callback is registered");if(this.yielding)throw new pn.InvalidOperationError("iterator is already yielding");this.yielding=!0;try{for(;;){if(this.yields.length===0&&await this.signal,this.err)throw this.err;const e=this.yields;this.inflight=e.length,this.yields=[];for(let r=0;r<e.length;r++){if(typeof e[r]=="function"){this.pendingFiltered--;const o=e[r];try{o()}catch(f){throw f}if(this.err)throw this.err;continue}this.processed++,this.inflight--;const s=this.profile?Date.now():0;yield e[r],this.time=this.profile?Date.now()-s:0}if(this.done)break;this.yields.length===0&&(e.length=0,this.yields=e,this.signal=(0,vr.deferred)())}}finally{this.didBreak=!0,this.stop()}}stop(e){this.done||(this.err=e,this.done=!0,this.signal.resolve(),this.iterClosed.resolve(e))}getProcessed(){return this.noIterator?this.received:this.processed}getPending(){return this.yields.length+this.inflight-this.pendingFiltered}getReceived(){return this.received-this.filtered}}dt.QueuedIteratorImpl=Bs;var At={};Object.defineProperty(At,"__esModule",{value:!0}),At.MuxSubscription=void 0;const Ks=Oe,xn=te;class $s{constructor(){d(this,"baseInbox");d(this,"reqs");this.reqs=new Map}size(){return this.reqs.size}init(e){return this.baseInbox=`${(0,Ks.createInbox)(e)}.`,this.baseInbox}add(e){isNaN(e.received)||(e.received=0),this.reqs.set(e.token,e)}get(e){return this.reqs.get(e)}cancel(e){this.reqs.delete(e.token)}getToken(e){const r=e.subject||"";return r.indexOf(this.baseInbox)===0?r.substring(this.baseInbox.length):null}all(){return Array.from(this.reqs.values())}handleError(e,r){if(e)return this.all().forEach(s=>{s.resolver(r,{})}),!0;if(r.operation==="publish"){const s=this.all().find(o=>o.requestSubject===r.subject);if(s)return s.resolver(r,{}),!0}return!1}dispatcher(){return(e,r)=>{var o,f;const s=this.getToken(r);if(s){const l=this.get(s);l&&(e===null&&(e=((o=r==null?void 0:r.data)==null?void 0:o.length)===0&&((f=r.headers)==null?void 0:f.code)===503?new xn.NoRespondersError(l.requestSubject):null),l.resolver(e,r))}}}close(){const e=new xn.RequestError("connection closed");this.reqs.forEach(r=>{r.resolver(e,{})})}}At.MuxSubscription=$s;var Ot={};Object.defineProperty(Ot,"__esModule",{value:!0}),Ot.Heartbeat=void 0;const qs=ye;class Ds{constructor(e,r,s){d(this,"ph");d(this,"interval");d(this,"maxOut");d(this,"timer");d(this,"pendings");this.ph=e,this.interval=r,this.maxOut=s,this.pendings=[]}start(){this.cancel(),this._schedule()}cancel(e){this.timer&&(clearTimeout(this.timer),this.timer=void 0),this._reset(),e&&this.ph.disconnect()}_schedule(){this.timer=setTimeout(()=>{if(this.ph.dispatchStatus({type:"ping",pendingPings:this.pendings.length+1}),this.pendings.length===this.maxOut){this.cancel(!0);return}const e=(0,qs.deferred)();this.ph.flush(e).then(()=>{this._reset()}).catch(()=>{this.cancel()}),this.pendings.push(e),this._schedule()},this.interval)}_reset(){this.pendings=this.pendings.filter(e=>(e.resolve(),!1))}}Ot.Heartbeat=Ds;var pr={},xr={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.DenoBuffer=t.MAX_SIZE=t.AssertionError=void 0,t.assert=s,t.concat=l,t.append=m,t.readAll=_,t.writeAll=w;const e=ke;class r extends Error{constructor(b){super(b),this.name="AssertionError"}}t.AssertionError=r;function s(E,b="Assertion failed."){if(!E)throw new r(b)}const o=32*1024;t.MAX_SIZE=2**32-2;function f(E,b,p=0){const R=b.byteLength-p;return E.byteLength>R&&(E=E.subarray(0,R)),b.set(E,p),E.byteLength}function l(E,b){if(E===void 0&&b===void 0)return new Uint8Array(0);if(E===void 0)return b;if(b===void 0)return E;const p=new Uint8Array(E.length+b.length);return p.set(E,0),p.set(b,E.length),p}function m(E,b){return l(E,Uint8Array.of(b))}class P{constructor(b){d(this,"_buf");d(this,"_off");if(this._off=0,b==null){this._buf=new Uint8Array(0);return}this._buf=new Uint8Array(b)}bytes(b={copy:!0}){return b.copy===!1?this._buf.subarray(this._off):this._buf.slice(this._off)}empty(){return this._buf.byteLength<=this._off}get length(){return this._buf.byteLength-this._off}get capacity(){return this._buf.buffer.byteLength}truncate(b){if(b===0){this.reset();return}if(b<0||b>this.length)throw Error("bytes.Buffer: truncation out of range");this._reslice(this._off+b)}reset(){this._reslice(0),this._off=0}_tryGrowByReslice(b){const p=this._buf.byteLength;return b<=this.capacity-p?(this._reslice(p+b),p):-1}_reslice(b){s(b<=this._buf.buffer.byteLength),this._buf=new Uint8Array(this._buf.buffer,0,b)}readByte(){const b=new Uint8Array(1);return this.read(b)?b[0]:null}read(b){if(this.empty())return this.reset(),b.byteLength===0?0:null;const p=f(this._buf.subarray(this._off),b);return this._off+=p,p}writeByte(b){return this.write(Uint8Array.of(b))}writeString(b){return this.write(e.TE.encode(b))}write(b){const p=this._grow(b.byteLength);return f(b,this._buf,p)}_grow(b){const p=this.length;p===0&&this._off!==0&&this.reset();const R=this._tryGrowByReslice(b);if(R>=0)return R;const M=this.capacity;if(b<=Math.floor(M/2)-p)f(this._buf.subarray(this._off),this._buf);else{if(M+b>t.MAX_SIZE)throw new Error("The buffer cannot be grown beyond the maximum size.");{const U=new Uint8Array(Math.min(2*M+b,t.MAX_SIZE));f(this._buf.subarray(this._off),U),this._buf=U}}return this._off=0,this._reslice(Math.min(p+b,t.MAX_SIZE)),p}grow(b){if(b<0)throw Error("Buffer._grow: negative count");const p=this._grow(b);this._reslice(p)}readFrom(b){let p=0;const R=new Uint8Array(o);for(;;){const M=this.capacity-this.length<o,U=M?R:new Uint8Array(this._buf.buffer,this.length),se=b.read(U);if(se===null)return p;M?this.write(U.subarray(0,se)):this._reslice(this.length+se),p+=se}}}t.DenoBuffer=P;function _(E){const b=new P;return b.readFrom(E),b.bytes()}function w(E,b){let p=0;for(;p<b.length;)p+=E.write(b.subarray(p))}})(xr),function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.cc=t.State=t.Parser=t.Kind=void 0,t.describe=s;const e=xr,r=ke;t.Kind={OK:0,ERR:1,MSG:2,INFO:3,PING:4,PONG:5};function s(P){let _,w="";switch(P.kind){case t.Kind.MSG:_="MSG";break;case t.Kind.OK:_="OK";break;case t.Kind.ERR:_="ERR",w=r.TD.decode(P.data);break;case t.Kind.PING:_="PING";break;case t.Kind.PONG:_="PONG";break;case t.Kind.INFO:_="INFO",w=r.TD.decode(P.data)}return`${_}: ${w}`}function o(){const P={};return P.sid=-1,P.hdr=-1,P.size=-1,P}const f=48,l=57;class m{constructor(_){d(this,"dispatcher");d(this,"state");d(this,"as");d(this,"drop");d(this,"hdr");d(this,"ma");d(this,"argBuf");d(this,"msgBuf");this.dispatcher=_,this.state=t.State.OP_START,this.as=0,this.drop=0,this.hdr=0}parse(_){let w;for(w=0;w<_.length;w++){const E=_[w];switch(this.state){case t.State.OP_START:switch(E){case t.cc.M:case t.cc.m:this.state=t.State.OP_M,this.hdr=-1,this.ma=o();break;case t.cc.H:case t.cc.h:this.state=t.State.OP_H,this.hdr=0,this.ma=o();break;case t.cc.P:case t.cc.p:this.state=t.State.OP_P;break;case t.cc.PLUS:this.state=t.State.OP_PLUS;break;case t.cc.MINUS:this.state=t.State.OP_MINUS;break;case t.cc.I:case t.cc.i:this.state=t.State.OP_I;break;default:throw this.fail(_.subarray(w))}break;case t.State.OP_H:switch(E){case t.cc.M:case t.cc.m:this.state=t.State.OP_M;break;default:throw this.fail(_.subarray(w))}break;case t.State.OP_M:switch(E){case t.cc.S:case t.cc.s:this.state=t.State.OP_MS;break;default:throw this.fail(_.subarray(w))}break;case t.State.OP_MS:switch(E){case t.cc.G:case t.cc.g:this.state=t.State.OP_MSG;break;default:throw this.fail(_.subarray(w))}break;case t.State.OP_MSG:switch(E){case t.cc.SPACE:case t.cc.TAB:this.state=t.State.OP_MSG_SPC;break;default:throw this.fail(_.subarray(w))}break;case t.State.OP_MSG_SPC:switch(E){case t.cc.SPACE:case t.cc.TAB:continue;default:this.state=t.State.MSG_ARG,this.as=w}break;case t.State.MSG_ARG:switch(E){case t.cc.CR:this.drop=1;break;case t.cc.NL:{const b=this.argBuf?this.argBuf.bytes():_.subarray(this.as,w-this.drop);this.processMsgArgs(b),this.drop=0,this.as=w+1,this.state=t.State.MSG_PAYLOAD,w=this.as+this.ma.size-1;break}default:this.argBuf&&this.argBuf.writeByte(E)}break;case t.State.MSG_PAYLOAD:if(this.msgBuf)if(this.msgBuf.length>=this.ma.size){const b=this.msgBuf.bytes({copy:!1});this.dispatcher.push({kind:t.Kind.MSG,msg:this.ma,data:b}),this.argBuf=void 0,this.msgBuf=void 0,this.state=t.State.MSG_END}else{let b=this.ma.size-this.msgBuf.length;const p=_.length-w;p<b&&(b=p),b>0?(this.msgBuf.write(_.subarray(w,w+b)),w=w+b-1):this.msgBuf.writeByte(E)}else w-this.as>=this.ma.size&&(this.dispatcher.push({kind:t.Kind.MSG,msg:this.ma,data:_.subarray(this.as,w)}),this.argBuf=void 0,this.msgBuf=void 0,this.state=t.State.MSG_END);break;case t.State.MSG_END:switch(E){case t.cc.NL:this.drop=0,this.as=w+1,this.state=t.State.OP_START;break;default:continue}break;case t.State.OP_PLUS:switch(E){case t.cc.O:case t.cc.o:this.state=t.State.OP_PLUS_O;break;default:throw this.fail(_.subarray(w))}break;case t.State.OP_PLUS_O:switch(E){case t.cc.K:case t.cc.k:this.state=t.State.OP_PLUS_OK;break;default:throw this.fail(_.subarray(w))}break;case t.State.OP_PLUS_OK:switch(E){case t.cc.NL:this.dispatcher.push({kind:t.Kind.OK}),this.drop=0,this.state=t.State.OP_START;break}break;case t.State.OP_MINUS:switch(E){case t.cc.E:case t.cc.e:this.state=t.State.OP_MINUS_E;break;default:throw this.fail(_.subarray(w))}break;case t.State.OP_MINUS_E:switch(E){case t.cc.R:case t.cc.r:this.state=t.State.OP_MINUS_ER;break;default:throw this.fail(_.subarray(w))}break;case t.State.OP_MINUS_ER:switch(E){case t.cc.R:case t.cc.r:this.state=t.State.OP_MINUS_ERR;break;default:throw this.fail(_.subarray(w))}break;case t.State.OP_MINUS_ERR:switch(E){case t.cc.SPACE:case t.cc.TAB:this.state=t.State.OP_MINUS_ERR_SPC;break;default:throw this.fail(_.subarray(w))}break;case t.State.OP_MINUS_ERR_SPC:switch(E){case t.cc.SPACE:case t.cc.TAB:continue;default:this.state=t.State.MINUS_ERR_ARG,this.as=w}break;case t.State.MINUS_ERR_ARG:switch(E){case t.cc.CR:this.drop=1;break;case t.cc.NL:{let b;this.argBuf?(b=this.argBuf.bytes(),this.argBuf=void 0):b=_.subarray(this.as,w-this.drop),this.dispatcher.push({kind:t.Kind.ERR,data:b}),this.drop=0,this.as=w+1,this.state=t.State.OP_START;break}default:this.argBuf&&this.argBuf.write(Uint8Array.of(E))}break;case t.State.OP_P:switch(E){case t.cc.I:case t.cc.i:this.state=t.State.OP_PI;break;case t.cc.O:case t.cc.o:this.state=t.State.OP_PO;break;default:throw this.fail(_.subarray(w))}break;case t.State.OP_PO:switch(E){case t.cc.N:case t.cc.n:this.state=t.State.OP_PON;break;default:throw this.fail(_.subarray(w))}break;case t.State.OP_PON:switch(E){case t.cc.G:case t.cc.g:this.state=t.State.OP_PONG;break;default:throw this.fail(_.subarray(w))}break;case t.State.OP_PONG:switch(E){case t.cc.NL:this.dispatcher.push({kind:t.Kind.PONG}),this.drop=0,this.state=t.State.OP_START;break}break;case t.State.OP_PI:switch(E){case t.cc.N:case t.cc.n:this.state=t.State.OP_PIN;break;default:throw this.fail(_.subarray(w))}break;case t.State.OP_PIN:switch(E){case t.cc.G:case t.cc.g:this.state=t.State.OP_PING;break;default:throw this.fail(_.subarray(w))}break;case t.State.OP_PING:switch(E){case t.cc.NL:this.dispatcher.push({kind:t.Kind.PING}),this.drop=0,this.state=t.State.OP_START;break}break;case t.State.OP_I:switch(E){case t.cc.N:case t.cc.n:this.state=t.State.OP_IN;break;default:throw this.fail(_.subarray(w))}break;case t.State.OP_IN:switch(E){case t.cc.F:case t.cc.f:this.state=t.State.OP_INF;break;default:throw this.fail(_.subarray(w))}break;case t.State.OP_INF:switch(E){case t.cc.O:case t.cc.o:this.state=t.State.OP_INFO;break;default:throw this.fail(_.subarray(w))}break;case t.State.OP_INFO:switch(E){case t.cc.SPACE:case t.cc.TAB:this.state=t.State.OP_INFO_SPC;break;default:throw this.fail(_.subarray(w))}break;case t.State.OP_INFO_SPC:switch(E){case t.cc.SPACE:case t.cc.TAB:continue;default:this.state=t.State.INFO_ARG,this.as=w}break;case t.State.INFO_ARG:switch(E){case t.cc.CR:this.drop=1;break;case t.cc.NL:{let b;this.argBuf?(b=this.argBuf.bytes(),this.argBuf=void 0):b=_.subarray(this.as,w-this.drop),this.dispatcher.push({kind:t.Kind.INFO,data:b}),this.drop=0,this.as=w+1,this.state=t.State.OP_START;break}default:this.argBuf&&this.argBuf.writeByte(E)}break;default:throw this.fail(_.subarray(w))}}(this.state===t.State.MSG_ARG||this.state===t.State.MINUS_ERR_ARG||this.state===t.State.INFO_ARG)&&!this.argBuf&&(this.argBuf=new e.DenoBuffer(_.subarray(this.as,w-this.drop))),this.state===t.State.MSG_PAYLOAD&&!this.msgBuf&&(this.argBuf||this.cloneMsgArg(),this.msgBuf=new e.DenoBuffer(_.subarray(this.as)))}cloneMsgArg(){const _=this.ma.subject.length,w=this.ma.reply?this.ma.reply.length:0,E=new Uint8Array(_+w);E.set(this.ma.subject),this.ma.reply&&E.set(this.ma.reply,_),this.argBuf=new e.DenoBuffer(E),this.ma.subject=E.subarray(0,_),this.ma.reply&&(this.ma.reply=E.subarray(_))}processMsgArgs(_){if(this.hdr>=0)return this.processHeaderMsgArgs(_);const w=[];let E=-1;for(let b=0;b<_.length;b++)switch(_[b]){case t.cc.SPACE:case t.cc.TAB:case t.cc.CR:case t.cc.NL:E>=0&&(w.push(_.subarray(E,b)),E=-1);break;default:E<0&&(E=b)}switch(E>=0&&w.push(_.subarray(E)),w.length){case 3:this.ma.subject=w[0],this.ma.sid=this.protoParseInt(w[1]),this.ma.reply=void 0,this.ma.size=this.protoParseInt(w[2]);break;case 4:this.ma.subject=w[0],this.ma.sid=this.protoParseInt(w[1]),this.ma.reply=w[2],this.ma.size=this.protoParseInt(w[3]);break;default:throw this.fail(_,"processMsgArgs Parse Error")}if(this.ma.sid<0)throw this.fail(_,"processMsgArgs Bad or Missing Sid Error");if(this.ma.size<0)throw this.fail(_,"processMsgArgs Bad or Missing Size Error")}fail(_,w=""){return w?w=`${w} [${this.state}]`:w=`parse error [${this.state}]`,new Error(`${w}: ${r.TD.decode(_)}`)}processHeaderMsgArgs(_){const w=[];let E=-1;for(let b=0;b<_.length;b++)switch(_[b]){case t.cc.SPACE:case t.cc.TAB:case t.cc.CR:case t.cc.NL:E>=0&&(w.push(_.subarray(E,b)),E=-1);break;default:E<0&&(E=b)}switch(E>=0&&w.push(_.subarray(E)),w.length){case 4:this.ma.subject=w[0],this.ma.sid=this.protoParseInt(w[1]),this.ma.reply=void 0,this.ma.hdr=this.protoParseInt(w[2]),this.ma.size=this.protoParseInt(w[3]);break;case 5:this.ma.subject=w[0],this.ma.sid=this.protoParseInt(w[1]),this.ma.reply=w[2],this.ma.hdr=this.protoParseInt(w[3]),this.ma.size=this.protoParseInt(w[4]);break;default:throw this.fail(_,"processHeaderMsgArgs Parse Error")}if(this.ma.sid<0)throw this.fail(_,"processHeaderMsgArgs Bad or Missing Sid Error");if(this.ma.hdr<0||this.ma.hdr>this.ma.size)throw this.fail(_,"processHeaderMsgArgs Bad or Missing Header Size Error");if(this.ma.size<0)throw this.fail(_,"processHeaderMsgArgs Bad or Missing Size Error")}protoParseInt(_){if(_.length===0)return-1;let w=0;for(let E=0;E<_.length;E++){if(_[E]<f||_[E]>l)return-1;w=w*10+(_[E]-f)}return w}}t.Parser=m,t.State={OP_START:0,OP_PLUS:1,OP_PLUS_O:2,OP_PLUS_OK:3,OP_MINUS:4,OP_MINUS_E:5,OP_MINUS_ER:6,OP_MINUS_ERR:7,OP_MINUS_ERR_SPC:8,MINUS_ERR_ARG:9,OP_M:10,OP_MS:11,OP_MSG:12,OP_MSG_SPC:13,MSG_ARG:14,MSG_PAYLOAD:15,MSG_END:16,OP_H:17,OP_P:18,OP_PI:19,OP_PIN:20,OP_PING:21,OP_PO:22,OP_PON:23,OP_PONG:24,OP_I:25,OP_IN:26,OP_INF:27,OP_INFO:28,OP_INFO_SPC:29,INFO_ARG:30},t.cc={CR:13,E:69,e:101,F:70,f:102,G:71,g:103,H:72,h:104,I:73,i:105,K:75,k:107,M:77,m:109,MINUS:45,N:78,n:110,NL:10,O:79,o:111,P:80,p:112,PLUS:43,R:82,r:114,S:83,s:115,SPACE:32,TAB:9}}(pr);var Ct={},Qe={};Object.defineProperty(Qe,"__esModule",{value:!0}),Qe.MsgHdrsImpl=void 0,Qe.canonicalMIMEHeaderKey=Er,Qe.headers=Gs;const wn=ke,Ke=Oe,wr=te;function Er(t){let w=!0;const E=new Array(t.length);for(let b=0;b<t.length;b++){let p=t.charCodeAt(b);if(p===58||p<33||p>126)throw wr.InvalidArgumentError.format("header",`'${t[b]}' is not a valid character in a header name`);w&&97<=p&&p<=122?p-=32:!w&&65<=p&&p<=90&&(p+=32),E[b]=p,w=p==45}return String.fromCharCode(...E)}function Gs(t=0,e=""){if(t===0&&e!==""||t>0&&e==="")throw wr.InvalidArgumentError.format("description","is required");return new lt(t,e)}const Pr="NATS/1.0";class lt{constructor(e=0,r=""){d(this,"_code");d(this,"headers");d(this,"_description");this._code=e,this._description=r,this.headers=new Map}[Symbol.iterator](){return this.headers.entries()}size(){return this.headers.size}equals(e){if(e&&this.headers.size===e.headers.size&&this._code===e._code){for(const[r,s]of this.headers){const o=e.values(r);if(s.length!==o.length)return!1;const f=[...s].sort(),l=[...o].sort();for(let m=0;m<f.length;m++)if(f[m]!==l[m])return!1}return!0}return!1}static decode(e){const r=new lt,o=wn.TD.decode(e).split(`\r
3
+ `),f=o[0];if(f!==Pr){let l=f.replace(Pr,"").trim();if(l.length>0){r._code=parseInt(l,10),isNaN(r._code)&&(r._code=0);const m=r._code.toString();l=l.replace(m,""),r._description=l.trim()}}return o.length>=1&&o.slice(1).map(l=>{if(l){const m=l.indexOf(":");if(m>-1){const P=l.slice(0,m),_=l.slice(m+1).trim();r.append(P,_)}}}),r}toString(){if(this.headers.size===0&&this._code===0)return"";let e=Pr;this._code>0&&this._description!==""&&(e+=` ${this._code} ${this._description}`);for(const[r,s]of this.headers)for(let o=0;o<s.length;o++)e=`${e}\r
4
+ ${r}: ${s[o]}`;return`${e}\r
5
+ \r
6
+ `}encode(){return wn.TE.encode(this.toString())}static validHeaderValue(e){if(/[\r\n]/.test(e))throw wr.InvalidArgumentError.format("header","values cannot contain \\r or \\n");return e.trim()}keys(){const e=[];for(const r of this.headers.keys())e.push(r);return e}findKeys(e,r=Ke.Match.Exact){const s=this.keys();switch(r){case Ke.Match.Exact:return s.filter(o=>o===e);case Ke.Match.CanonicalMIME:return e=Er(e),s.filter(o=>o===e);default:{const o=e.toLowerCase();return s.filter(f=>o===f.toLowerCase())}}}get(e,r=Ke.Match.Exact){const s=this.findKeys(e,r);if(s.length){const o=this.headers.get(s[0]);if(o)return Array.isArray(o)?o[0]:o}return""}last(e,r=Ke.Match.Exact){const s=this.findKeys(e,r);if(s.length){const o=this.headers.get(s[0]);if(o)return Array.isArray(o)?o[o.length-1]:o}return""}has(e,r=Ke.Match.Exact){return this.findKeys(e,r).length>0}set(e,r,s=Ke.Match.Exact){this.delete(e,s),this.append(e,r,s)}append(e,r,s=Ke.Match.Exact){const o=Er(e);s===Ke.Match.CanonicalMIME&&(e=o);const f=this.findKeys(e,s);e=f.length>0?f[0]:e;const l=lt.validHeaderValue(r);let m=this.headers.get(e);m||(m=[],this.headers.set(e,m)),m.push(l)}values(e,r=Ke.Match.Exact){const s=[];return this.findKeys(e,r).forEach(f=>{const l=this.headers.get(f);l&&s.push(...l)}),s}delete(e,r=Ke.Match.Exact){this.findKeys(e,r).forEach(o=>{this.headers.delete(o)})}get hasError(){return this._code>=300}get status(){return`${this._code} ${this._description}`.trim()}toRecord(){const e={};return this.keys().forEach(r=>{e[r]=this.values(r)}),e}get code(){return this._code}get description(){return this._description}static fromRecord(e){const r=new lt;for(const s in e)r.headers.set(s,e[s]);return r}}Qe.MsgHdrsImpl=lt,Object.defineProperty(Ct,"__esModule",{value:!0}),Ct.MsgImpl=void 0;const zs=Qe,Wt=ke;class Hs{constructor(e,r,s){d(this,"_headers");d(this,"_msg");d(this,"_rdata");d(this,"_reply");d(this,"_subject");d(this,"publisher");this._msg=e,this._rdata=r,this.publisher=s}get subject(){return this._subject?this._subject:(this._subject=Wt.TD.decode(this._msg.subject),this._subject)}get reply(){return this._reply?this._reply:(this._reply=Wt.TD.decode(this._msg.reply),this._reply)}get sid(){return this._msg.sid}get headers(){if(this._msg.hdr>-1&&!this._headers){const e=this._rdata.subarray(0,this._msg.hdr);this._headers=zs.MsgHdrsImpl.decode(e)}return this._headers}get data(){return this._rdata?this._msg.hdr>-1?this._rdata.subarray(this._msg.hdr):this._rdata:new Uint8Array(0)}respond(e=Wt.Empty,r){return this.reply?(this.publisher.publish(this.reply,e,r),!0):!1}size(){var o;const e=this._msg.subject.length,r=((o=this._msg.reply)==null?void 0:o.length)||0,s=this._msg.size===-1?0:this._msg.size;return e+r+s}json(e){return JSON.parse(this.string(),e)}string(){return Wt.TD.decode(this.data)}requestInfo(){var r;const e=(r=this.headers)==null?void 0:r.get("Nats-Request-Info");return e?JSON.parse(e,function(s,o){return(s==="start"||s==="stop")&&o!==""?new Date(Date.parse(o)):o}):null}}Ct.MsgImpl=Hs;var Xt={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Features=t.Feature=void 0,t.parseSemVer=e,t.compare=r;function e(o=""){const f=o.match(/(\d+).(\d+).(\d+)/);if(f)return{major:parseInt(f[1]),minor:parseInt(f[2]),micro:parseInt(f[3])};throw new Error(`'${o}' is not a semver value`)}function r(o,f){return o.major<f.major?-1:o.major>f.major?1:o.minor<f.minor?-1:o.minor>f.minor?1:o.micro<f.micro?-1:o.micro>f.micro?1:0}t.Feature={JS_KV:"js_kv",JS_OBJECTSTORE:"js_objectstore",JS_PULL_MAX_BYTES:"js_pull_max_bytes",JS_NEW_CONSUMER_CREATE_API:"js_new_consumer_create",JS_ALLOW_DIRECT:"js_allow_direct",JS_MULTIPLE_CONSUMER_FILTER:"js_multiple_consumer_filter",JS_SIMPLIFICATION:"js_simplification",JS_STREAM_CONSUMER_METADATA:"js_stream_consumer_metadata",JS_CONSUMER_FILTER_SUBJECTS:"js_consumer_filter_subjects",JS_STREAM_FIRST_SEQ:"js_stream_first_seq",JS_STREAM_SUBJECT_TRANSFORM:"js_stream_subject_transform",JS_STREAM_SOURCE_SUBJECT_TRANSFORM:"js_stream_source_subject_transform",JS_STREAM_COMPRESSION:"js_stream_compression",JS_DEFAULT_CONSUMER_LIMITS:"js_default_consumer_limits",JS_BATCH_DIRECT_GET:"js_batch_direct_get",JS_PRIORITY_GROUPS:"js_priority_groups"};class s{constructor(f){d(this,"server");d(this,"features");d(this,"disabled");this.features=new Map,this.disabled=[],this.update(f)}resetDisabled(){this.disabled.length=0,this.update(this.server)}disable(f){this.disabled.push(f),this.update(this.server)}isDisabled(f){return this.disabled.indexOf(f)!==-1}update(f){typeof f=="string"&&(f=e(f)),this.server=f,this.set(t.Feature.JS_KV,"2.6.2"),this.set(t.Feature.JS_OBJECTSTORE,"2.6.3"),this.set(t.Feature.JS_PULL_MAX_BYTES,"2.8.3"),this.set(t.Feature.JS_NEW_CONSUMER_CREATE_API,"2.9.0"),this.set(t.Feature.JS_ALLOW_DIRECT,"2.9.0"),this.set(t.Feature.JS_MULTIPLE_CONSUMER_FILTER,"2.10.0"),this.set(t.Feature.JS_SIMPLIFICATION,"2.9.4"),this.set(t.Feature.JS_STREAM_CONSUMER_METADATA,"2.10.0"),this.set(t.Feature.JS_CONSUMER_FILTER_SUBJECTS,"2.10.0"),this.set(t.Feature.JS_STREAM_FIRST_SEQ,"2.10.0"),this.set(t.Feature.JS_STREAM_SUBJECT_TRANSFORM,"2.10.0"),this.set(t.Feature.JS_STREAM_SOURCE_SUBJECT_TRANSFORM,"2.10.0"),this.set(t.Feature.JS_STREAM_COMPRESSION,"2.10.0"),this.set(t.Feature.JS_DEFAULT_CONSUMER_LIMITS,"2.10.0"),this.set(t.Feature.JS_BATCH_DIRECT_GET,"2.11.0"),this.set(t.Feature.JS_PRIORITY_GROUPS,"2.11.0"),this.disabled.forEach(l=>{this.features.delete(l)})}set(f,l){this.features.set(f,{min:l,ok:r(this.server,e(l))>=0})}get(f){return this.features.get(f)||{min:"unknown",ok:!1}}supports(f){var l;return((l=this.get(f))==null?void 0:l.ok)||!1}require(f){return typeof f=="string"&&(f=e(f)),r(this.server,f)>=0}}t.Features=s})(Xt);var jt={},De={},Nt={},En={},pe={},Mt={},It={},Tt={};Object.defineProperty(Tt,"__esModule",{value:!0}),Tt.crc16=void 0;const Js=new Uint16Array([0,4129,8258,12387,16516,20645,24774,28903,33032,37161,41290,45419,49548,53677,57806,61935,4657,528,12915,8786,21173,17044,29431,25302,37689,33560,45947,41818,54205,50076,62463,58334,9314,13379,1056,5121,25830,29895,17572,21637,42346,46411,34088,38153,58862,62927,50604,54669,13907,9842,5649,1584,30423,26358,22165,18100,46939,42874,38681,34616,63455,59390,55197,51132,18628,22757,26758,30887,2112,6241,10242,14371,51660,55789,59790,63919,35144,39273,43274,47403,23285,19156,31415,27286,6769,2640,14899,10770,56317,52188,64447,60318,39801,35672,47931,43802,27814,31879,19684,23749,11298,15363,3168,7233,60846,64911,52716,56781,44330,48395,36200,40265,32407,28342,24277,20212,15891,11826,7761,3696,65439,61374,57309,53244,48923,44858,40793,36728,37256,33193,45514,41451,53516,49453,61774,57711,4224,161,12482,8419,20484,16421,28742,24679,33721,37784,41979,46042,49981,54044,58239,62302,689,4752,8947,13010,16949,21012,25207,29270,46570,42443,38312,34185,62830,58703,54572,50445,13538,9411,5280,1153,29798,25671,21540,17413,42971,47098,34713,38840,59231,63358,50973,55100,9939,14066,1681,5808,26199,30326,17941,22068,55628,51565,63758,59695,39368,35305,47498,43435,22596,18533,30726,26663,6336,2273,14466,10403,52093,56156,60223,64286,35833,39896,43963,48026,19061,23124,27191,31254,2801,6864,10931,14994,64814,60687,56684,52557,48554,44427,40424,36297,31782,27655,23652,19525,15522,11395,7392,3265,61215,65342,53085,57212,44955,49082,36825,40952,28183,32310,20053,24180,11923,16050,3793,7920]);class Sr{static checksum(e){let r=0;for(let s=0;s<e.byteLength;s++){const o=e[s];r=r<<8&65535^Js[(r>>8^o)&255]}return r}static validate(e,r){return Sr.checksum(e)==r}}Tt.crc16=Sr;var Rt={};Object.defineProperty(Rt,"__esModule",{value:!0}),Rt.base32=void 0;const Ar="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";class Vs{static encode(e){let r=0,s=0;const o=new Uint8Array(e),f=new Uint8Array(e.byteLength*2);let l=0;for(let m=0;m<o.byteLength;m++)for(s=s<<8|o[m],r+=8;r>=5;){const P=s>>>r-5&31;f[l++]=Ar.charAt(P).charCodeAt(0),r-=5}if(r>0){const m=s<<5-r&31;f[l++]=Ar.charAt(m).charCodeAt(0)}return f.slice(0,l)}static decode(e){let r=0,s=0,o=0;const f=new Uint8Array(e),l=new Uint8Array(f.byteLength*5/8|0);for(let m=0;m<f.byteLength;m++){const P=String.fromCharCode(f[m]),_=Ar.indexOf(P);if(_===-1)throw new Error("Illegal Base32 character: "+f[m]);s=s<<5|_,r+=5,r>=8&&(l[o++]=s>>>r-8&255,r-=8)}return l.slice(0,o)}}Rt.base32=Vs;var Pn;function Zt(){if(Pn)return It;Pn=1,Object.defineProperty(It,"__esModule",{value:!0}),It.Codec=void 0;const t=Tt,e=yt(),r=Rt;class s{static encode(f,l){if(!l||!(l instanceof Uint8Array))throw new e.NKeysError(e.NKeysErrorCode.SerializationError);if(!e.Prefixes.isValidPrefix(f))throw new e.NKeysError(e.NKeysErrorCode.InvalidPrefixByte);return s._encode(!1,f,l)}static encodeSeed(f,l){if(!l)throw new e.NKeysError(e.NKeysErrorCode.ApiError);if(!e.Prefixes.isValidPublicPrefix(f))throw new e.NKeysError(e.NKeysErrorCode.InvalidPrefixByte);if(l.byteLength!==32)throw new e.NKeysError(e.NKeysErrorCode.InvalidSeedLen);return s._encode(!0,f,l)}static decode(f,l){if(!e.Prefixes.isValidPrefix(f))throw new e.NKeysError(e.NKeysErrorCode.InvalidPrefixByte);const m=s._decode(l);if(m[0]!==f)throw new e.NKeysError(e.NKeysErrorCode.InvalidPrefixByte);return m.slice(1)}static decodeSeed(f){const l=s._decode(f),m=s._decodePrefix(l);if(m[0]!=e.Prefix.Seed)throw new e.NKeysError(e.NKeysErrorCode.InvalidSeed);if(!e.Prefixes.isValidPublicPrefix(m[1]))throw new e.NKeysError(e.NKeysErrorCode.InvalidPrefixByte);return{buf:l.slice(2),prefix:m[1]}}static _encode(f,l,m){const P=f?2:1,_=m.byteLength,E=P+_+2,b=P+_,p=new Uint8Array(E);if(f){const U=s._encodePrefix(e.Prefix.Seed,l);p.set(U)}else p[0]=l;p.set(m,P);const R=t.crc16.checksum(p.slice(0,b));return new DataView(p.buffer).setUint16(b,R,!0),r.base32.encode(p)}static _decode(f){if(f.byteLength<4)throw new e.NKeysError(e.NKeysErrorCode.InvalidEncoding);let l;try{l=r.base32.decode(f)}catch(E){throw new e.NKeysError(e.NKeysErrorCode.InvalidEncoding,{cause:E})}const m=l.byteLength-2,_=new DataView(l.buffer).getUint16(m,!0),w=l.slice(0,m);if(!t.crc16.validate(w,_))throw new e.NKeysError(e.NKeysErrorCode.InvalidChecksum);return w}static _encodePrefix(f,l){const m=f|l>>5,P=(l&31)<<3;return new Uint8Array([m,P])}static _decodePrefix(f){const l=f[0]&248,m=(f[0]&7)<<5|(f[1]&248)>>3;return new Uint8Array([l,m])}}return It.Codec=s,It}var bt={};function Ys(t){throw new Error('Could not dynamically require "'+t+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Sn={exports:{}};const Ws=tt(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));(function(t){(function(e){var r=function(i){var c,a=new Float64Array(16);if(i)for(c=0;c<i.length;c++)a[c]=i[c];return a},s=function(){throw new Error("no PRNG")},o=new Uint8Array(16),f=new Uint8Array(32);f[0]=9;var l=r(),m=r([1]),P=r([56129,1]),_=r([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),w=r([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),E=r([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),b=r([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),p=r([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function R(i,c,a,n){i[c]=a>>24&255,i[c+1]=a>>16&255,i[c+2]=a>>8&255,i[c+3]=a&255,i[c+4]=n>>24&255,i[c+5]=n>>16&255,i[c+6]=n>>8&255,i[c+7]=n&255}function M(i,c,a,n,u){var y,g=0;for(y=0;y<u;y++)g|=i[c+y]^a[n+y];return(1&g-1>>>8)-1}function U(i,c,a,n){return M(i,c,a,n,16)}function se(i,c,a,n){return M(i,c,a,n,32)}function ge(i,c,a,n){for(var u=n[0]&255|(n[1]&255)<<8|(n[2]&255)<<16|(n[3]&255)<<24,y=a[0]&255|(a[1]&255)<<8|(a[2]&255)<<16|(a[3]&255)<<24,g=a[4]&255|(a[5]&255)<<8|(a[6]&255)<<16|(a[7]&255)<<24,A=a[8]&255|(a[9]&255)<<8|(a[10]&255)<<16|(a[11]&255)<<24,N=a[12]&255|(a[13]&255)<<8|(a[14]&255)<<16|(a[15]&255)<<24,q=n[4]&255|(n[5]&255)<<8|(n[6]&255)<<16|(n[7]&255)<<24,T=c[0]&255|(c[1]&255)<<8|(c[2]&255)<<16|(c[3]&255)<<24,ce=c[4]&255|(c[5]&255)<<8|(c[6]&255)<<16|(c[7]&255)<<24,F=c[8]&255|(c[9]&255)<<8|(c[10]&255)<<16|(c[11]&255)<<24,z=c[12]&255|(c[13]&255)<<8|(c[14]&255)<<16|(c[15]&255)<<24,H=n[8]&255|(n[9]&255)<<8|(n[10]&255)<<16|(n[11]&255)<<24,X=a[16]&255|(a[17]&255)<<8|(a[18]&255)<<16|(a[19]&255)<<24,W=a[20]&255|(a[21]&255)<<8|(a[22]&255)<<16|(a[23]&255)<<24,J=a[24]&255|(a[25]&255)<<8|(a[26]&255)<<16|(a[27]&255)<<24,Y=a[28]&255|(a[29]&255)<<8|(a[30]&255)<<16|(a[31]&255)<<24,V=n[12]&255|(n[13]&255)<<8|(n[14]&255)<<16|(n[15]&255)<<24,B=u,D=y,k=g,K=A,$=N,I=q,v=T,x=ce,C=F,S=z,O=H,j=X,G=W,Z=J,ee=Y,Q=V,h,ne=0;ne<20;ne+=2)h=B+G|0,$^=h<<7|h>>>25,h=$+B|0,C^=h<<9|h>>>23,h=C+$|0,G^=h<<13|h>>>19,h=G+C|0,B^=h<<18|h>>>14,h=I+D|0,S^=h<<7|h>>>25,h=S+I|0,Z^=h<<9|h>>>23,h=Z+S|0,D^=h<<13|h>>>19,h=D+Z|0,I^=h<<18|h>>>14,h=O+v|0,ee^=h<<7|h>>>25,h=ee+O|0,k^=h<<9|h>>>23,h=k+ee|0,v^=h<<13|h>>>19,h=v+k|0,O^=h<<18|h>>>14,h=Q+j|0,K^=h<<7|h>>>25,h=K+Q|0,x^=h<<9|h>>>23,h=x+K|0,j^=h<<13|h>>>19,h=j+x|0,Q^=h<<18|h>>>14,h=B+K|0,D^=h<<7|h>>>25,h=D+B|0,k^=h<<9|h>>>23,h=k+D|0,K^=h<<13|h>>>19,h=K+k|0,B^=h<<18|h>>>14,h=I+$|0,v^=h<<7|h>>>25,h=v+I|0,x^=h<<9|h>>>23,h=x+v|0,$^=h<<13|h>>>19,h=$+x|0,I^=h<<18|h>>>14,h=O+S|0,j^=h<<7|h>>>25,h=j+O|0,C^=h<<9|h>>>23,h=C+j|0,S^=h<<13|h>>>19,h=S+C|0,O^=h<<18|h>>>14,h=Q+ee|0,G^=h<<7|h>>>25,h=G+Q|0,Z^=h<<9|h>>>23,h=Z+G|0,ee^=h<<13|h>>>19,h=ee+Z|0,Q^=h<<18|h>>>14;B=B+u|0,D=D+y|0,k=k+g|0,K=K+A|0,$=$+N|0,I=I+q|0,v=v+T|0,x=x+ce|0,C=C+F|0,S=S+z|0,O=O+H|0,j=j+X|0,G=G+W|0,Z=Z+J|0,ee=ee+Y|0,Q=Q+V|0,i[0]=B>>>0&255,i[1]=B>>>8&255,i[2]=B>>>16&255,i[3]=B>>>24&255,i[4]=D>>>0&255,i[5]=D>>>8&255,i[6]=D>>>16&255,i[7]=D>>>24&255,i[8]=k>>>0&255,i[9]=k>>>8&255,i[10]=k>>>16&255,i[11]=k>>>24&255,i[12]=K>>>0&255,i[13]=K>>>8&255,i[14]=K>>>16&255,i[15]=K>>>24&255,i[16]=$>>>0&255,i[17]=$>>>8&255,i[18]=$>>>16&255,i[19]=$>>>24&255,i[20]=I>>>0&255,i[21]=I>>>8&255,i[22]=I>>>16&255,i[23]=I>>>24&255,i[24]=v>>>0&255,i[25]=v>>>8&255,i[26]=v>>>16&255,i[27]=v>>>24&255,i[28]=x>>>0&255,i[29]=x>>>8&255,i[30]=x>>>16&255,i[31]=x>>>24&255,i[32]=C>>>0&255,i[33]=C>>>8&255,i[34]=C>>>16&255,i[35]=C>>>24&255,i[36]=S>>>0&255,i[37]=S>>>8&255,i[38]=S>>>16&255,i[39]=S>>>24&255,i[40]=O>>>0&255,i[41]=O>>>8&255,i[42]=O>>>16&255,i[43]=O>>>24&255,i[44]=j>>>0&255,i[45]=j>>>8&255,i[46]=j>>>16&255,i[47]=j>>>24&255,i[48]=G>>>0&255,i[49]=G>>>8&255,i[50]=G>>>16&255,i[51]=G>>>24&255,i[52]=Z>>>0&255,i[53]=Z>>>8&255,i[54]=Z>>>16&255,i[55]=Z>>>24&255,i[56]=ee>>>0&255,i[57]=ee>>>8&255,i[58]=ee>>>16&255,i[59]=ee>>>24&255,i[60]=Q>>>0&255,i[61]=Q>>>8&255,i[62]=Q>>>16&255,i[63]=Q>>>24&255}function Fe(i,c,a,n){for(var u=n[0]&255|(n[1]&255)<<8|(n[2]&255)<<16|(n[3]&255)<<24,y=a[0]&255|(a[1]&255)<<8|(a[2]&255)<<16|(a[3]&255)<<24,g=a[4]&255|(a[5]&255)<<8|(a[6]&255)<<16|(a[7]&255)<<24,A=a[8]&255|(a[9]&255)<<8|(a[10]&255)<<16|(a[11]&255)<<24,N=a[12]&255|(a[13]&255)<<8|(a[14]&255)<<16|(a[15]&255)<<24,q=n[4]&255|(n[5]&255)<<8|(n[6]&255)<<16|(n[7]&255)<<24,T=c[0]&255|(c[1]&255)<<8|(c[2]&255)<<16|(c[3]&255)<<24,ce=c[4]&255|(c[5]&255)<<8|(c[6]&255)<<16|(c[7]&255)<<24,F=c[8]&255|(c[9]&255)<<8|(c[10]&255)<<16|(c[11]&255)<<24,z=c[12]&255|(c[13]&255)<<8|(c[14]&255)<<16|(c[15]&255)<<24,H=n[8]&255|(n[9]&255)<<8|(n[10]&255)<<16|(n[11]&255)<<24,X=a[16]&255|(a[17]&255)<<8|(a[18]&255)<<16|(a[19]&255)<<24,W=a[20]&255|(a[21]&255)<<8|(a[22]&255)<<16|(a[23]&255)<<24,J=a[24]&255|(a[25]&255)<<8|(a[26]&255)<<16|(a[27]&255)<<24,Y=a[28]&255|(a[29]&255)<<8|(a[30]&255)<<16|(a[31]&255)<<24,V=n[12]&255|(n[13]&255)<<8|(n[14]&255)<<16|(n[15]&255)<<24,B=u,D=y,k=g,K=A,$=N,I=q,v=T,x=ce,C=F,S=z,O=H,j=X,G=W,Z=J,ee=Y,Q=V,h,ne=0;ne<20;ne+=2)h=B+G|0,$^=h<<7|h>>>25,h=$+B|0,C^=h<<9|h>>>23,h=C+$|0,G^=h<<13|h>>>19,h=G+C|0,B^=h<<18|h>>>14,h=I+D|0,S^=h<<7|h>>>25,h=S+I|0,Z^=h<<9|h>>>23,h=Z+S|0,D^=h<<13|h>>>19,h=D+Z|0,I^=h<<18|h>>>14,h=O+v|0,ee^=h<<7|h>>>25,h=ee+O|0,k^=h<<9|h>>>23,h=k+ee|0,v^=h<<13|h>>>19,h=v+k|0,O^=h<<18|h>>>14,h=Q+j|0,K^=h<<7|h>>>25,h=K+Q|0,x^=h<<9|h>>>23,h=x+K|0,j^=h<<13|h>>>19,h=j+x|0,Q^=h<<18|h>>>14,h=B+K|0,D^=h<<7|h>>>25,h=D+B|0,k^=h<<9|h>>>23,h=k+D|0,K^=h<<13|h>>>19,h=K+k|0,B^=h<<18|h>>>14,h=I+$|0,v^=h<<7|h>>>25,h=v+I|0,x^=h<<9|h>>>23,h=x+v|0,$^=h<<13|h>>>19,h=$+x|0,I^=h<<18|h>>>14,h=O+S|0,j^=h<<7|h>>>25,h=j+O|0,C^=h<<9|h>>>23,h=C+j|0,S^=h<<13|h>>>19,h=S+C|0,O^=h<<18|h>>>14,h=Q+ee|0,G^=h<<7|h>>>25,h=G+Q|0,Z^=h<<9|h>>>23,h=Z+G|0,ee^=h<<13|h>>>19,h=ee+Z|0,Q^=h<<18|h>>>14;i[0]=B>>>0&255,i[1]=B>>>8&255,i[2]=B>>>16&255,i[3]=B>>>24&255,i[4]=I>>>0&255,i[5]=I>>>8&255,i[6]=I>>>16&255,i[7]=I>>>24&255,i[8]=O>>>0&255,i[9]=O>>>8&255,i[10]=O>>>16&255,i[11]=O>>>24&255,i[12]=Q>>>0&255,i[13]=Q>>>8&255,i[14]=Q>>>16&255,i[15]=Q>>>24&255,i[16]=v>>>0&255,i[17]=v>>>8&255,i[18]=v>>>16&255,i[19]=v>>>24&255,i[20]=x>>>0&255,i[21]=x>>>8&255,i[22]=x>>>16&255,i[23]=x>>>24&255,i[24]=C>>>0&255,i[25]=C>>>8&255,i[26]=C>>>16&255,i[27]=C>>>24&255,i[28]=S>>>0&255,i[29]=S>>>8&255,i[30]=S>>>16&255,i[31]=S>>>24&255}function L(i,c,a,n){ge(i,c,a,n)}function de(i,c,a,n){Fe(i,c,a,n)}var le=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function He(i,c,a,n,u,y,g){var A=new Uint8Array(16),N=new Uint8Array(64),q,T;for(T=0;T<16;T++)A[T]=0;for(T=0;T<8;T++)A[T]=y[T];for(;u>=64;){for(L(N,A,g,le),T=0;T<64;T++)i[c+T]=a[n+T]^N[T];for(q=1,T=8;T<16;T++)q=q+(A[T]&255)|0,A[T]=q&255,q>>>=8;u-=64,c+=64,n+=64}if(u>0)for(L(N,A,g,le),T=0;T<u;T++)i[c+T]=a[n+T]^N[T];return 0}function Lt(i,c,a,n,u){var y=new Uint8Array(16),g=new Uint8Array(64),A,N;for(N=0;N<16;N++)y[N]=0;for(N=0;N<8;N++)y[N]=n[N];for(;a>=64;){for(L(g,y,u,le),N=0;N<64;N++)i[c+N]=g[N];for(A=1,N=8;N<16;N++)A=A+(y[N]&255)|0,y[N]=A&255,A>>>=8;a-=64,c+=64}if(a>0)for(L(g,y,u,le),N=0;N<a;N++)i[c+N]=g[N];return 0}function _t(i,c,a,n,u){var y=new Uint8Array(32);de(y,n,u,le);for(var g=new Uint8Array(8),A=0;A<8;A++)g[A]=n[A+16];return Lt(i,c,a,g,y)}function mt(i,c,a,n,u,y,g){var A=new Uint8Array(32);de(A,y,g,le);for(var N=new Uint8Array(8),q=0;q<8;q++)N[q]=y[q+16];return He(i,c,a,n,u,N,A)}var vt=function(i){this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.leftover=0,this.fin=0;var c,a,n,u,y,g,A,N;c=i[0]&255|(i[1]&255)<<8,this.r[0]=c&8191,a=i[2]&255|(i[3]&255)<<8,this.r[1]=(c>>>13|a<<3)&8191,n=i[4]&255|(i[5]&255)<<8,this.r[2]=(a>>>10|n<<6)&7939,u=i[6]&255|(i[7]&255)<<8,this.r[3]=(n>>>7|u<<9)&8191,y=i[8]&255|(i[9]&255)<<8,this.r[4]=(u>>>4|y<<12)&255,this.r[5]=y>>>1&8190,g=i[10]&255|(i[11]&255)<<8,this.r[6]=(y>>>14|g<<2)&8191,A=i[12]&255|(i[13]&255)<<8,this.r[7]=(g>>>11|A<<5)&8065,N=i[14]&255|(i[15]&255)<<8,this.r[8]=(A>>>8|N<<8)&8191,this.r[9]=N>>>5&127,this.pad[0]=i[16]&255|(i[17]&255)<<8,this.pad[1]=i[18]&255|(i[19]&255)<<8,this.pad[2]=i[20]&255|(i[21]&255)<<8,this.pad[3]=i[22]&255|(i[23]&255)<<8,this.pad[4]=i[24]&255|(i[25]&255)<<8,this.pad[5]=i[26]&255|(i[27]&255)<<8,this.pad[6]=i[28]&255|(i[29]&255)<<8,this.pad[7]=i[30]&255|(i[31]&255)<<8};vt.prototype.blocks=function(i,c,a){for(var n=this.fin?0:2048,u,y,g,A,N,q,T,ce,F,z,H,X,W,J,Y,V,B,D,k,K=this.h[0],$=this.h[1],I=this.h[2],v=this.h[3],x=this.h[4],C=this.h[5],S=this.h[6],O=this.h[7],j=this.h[8],G=this.h[9],Z=this.r[0],ee=this.r[1],Q=this.r[2],h=this.r[3],ne=this.r[4],fe=this.r[5],ue=this.r[6],re=this.r[7],oe=this.r[8],ae=this.r[9];a>=16;)u=i[c+0]&255|(i[c+1]&255)<<8,K+=u&8191,y=i[c+2]&255|(i[c+3]&255)<<8,$+=(u>>>13|y<<3)&8191,g=i[c+4]&255|(i[c+5]&255)<<8,I+=(y>>>10|g<<6)&8191,A=i[c+6]&255|(i[c+7]&255)<<8,v+=(g>>>7|A<<9)&8191,N=i[c+8]&255|(i[c+9]&255)<<8,x+=(A>>>4|N<<12)&8191,C+=N>>>1&8191,q=i[c+10]&255|(i[c+11]&255)<<8,S+=(N>>>14|q<<2)&8191,T=i[c+12]&255|(i[c+13]&255)<<8,O+=(q>>>11|T<<5)&8191,ce=i[c+14]&255|(i[c+15]&255)<<8,j+=(T>>>8|ce<<8)&8191,G+=ce>>>5|n,F=0,z=F,z+=K*Z,z+=$*(5*ae),z+=I*(5*oe),z+=v*(5*re),z+=x*(5*ue),F=z>>>13,z&=8191,z+=C*(5*fe),z+=S*(5*ne),z+=O*(5*h),z+=j*(5*Q),z+=G*(5*ee),F+=z>>>13,z&=8191,H=F,H+=K*ee,H+=$*Z,H+=I*(5*ae),H+=v*(5*oe),H+=x*(5*re),F=H>>>13,H&=8191,H+=C*(5*ue),H+=S*(5*fe),H+=O*(5*ne),H+=j*(5*h),H+=G*(5*Q),F+=H>>>13,H&=8191,X=F,X+=K*Q,X+=$*ee,X+=I*Z,X+=v*(5*ae),X+=x*(5*oe),F=X>>>13,X&=8191,X+=C*(5*re),X+=S*(5*ue),X+=O*(5*fe),X+=j*(5*ne),X+=G*(5*h),F+=X>>>13,X&=8191,W=F,W+=K*h,W+=$*Q,W+=I*ee,W+=v*Z,W+=x*(5*ae),F=W>>>13,W&=8191,W+=C*(5*oe),W+=S*(5*re),W+=O*(5*ue),W+=j*(5*fe),W+=G*(5*ne),F+=W>>>13,W&=8191,J=F,J+=K*ne,J+=$*h,J+=I*Q,J+=v*ee,J+=x*Z,F=J>>>13,J&=8191,J+=C*(5*ae),J+=S*(5*oe),J+=O*(5*re),J+=j*(5*ue),J+=G*(5*fe),F+=J>>>13,J&=8191,Y=F,Y+=K*fe,Y+=$*ne,Y+=I*h,Y+=v*Q,Y+=x*ee,F=Y>>>13,Y&=8191,Y+=C*Z,Y+=S*(5*ae),Y+=O*(5*oe),Y+=j*(5*re),Y+=G*(5*ue),F+=Y>>>13,Y&=8191,V=F,V+=K*ue,V+=$*fe,V+=I*ne,V+=v*h,V+=x*Q,F=V>>>13,V&=8191,V+=C*ee,V+=S*Z,V+=O*(5*ae),V+=j*(5*oe),V+=G*(5*re),F+=V>>>13,V&=8191,B=F,B+=K*re,B+=$*ue,B+=I*fe,B+=v*ne,B+=x*h,F=B>>>13,B&=8191,B+=C*Q,B+=S*ee,B+=O*Z,B+=j*(5*ae),B+=G*(5*oe),F+=B>>>13,B&=8191,D=F,D+=K*oe,D+=$*re,D+=I*ue,D+=v*fe,D+=x*ne,F=D>>>13,D&=8191,D+=C*h,D+=S*Q,D+=O*ee,D+=j*Z,D+=G*(5*ae),F+=D>>>13,D&=8191,k=F,k+=K*ae,k+=$*oe,k+=I*re,k+=v*ue,k+=x*fe,F=k>>>13,k&=8191,k+=C*ne,k+=S*h,k+=O*Q,k+=j*ee,k+=G*Z,F+=k>>>13,k&=8191,F=(F<<2)+F|0,F=F+z|0,z=F&8191,F=F>>>13,H+=F,K=z,$=H,I=X,v=W,x=J,C=Y,S=V,O=B,j=D,G=k,c+=16,a-=16;this.h[0]=K,this.h[1]=$,this.h[2]=I,this.h[3]=v,this.h[4]=x,this.h[5]=C,this.h[6]=S,this.h[7]=O,this.h[8]=j,this.h[9]=G},vt.prototype.finish=function(i,c){var a=new Uint16Array(10),n,u,y,g;if(this.leftover){for(g=this.leftover,this.buffer[g++]=1;g<16;g++)this.buffer[g]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(n=this.h[1]>>>13,this.h[1]&=8191,g=2;g<10;g++)this.h[g]+=n,n=this.h[g]>>>13,this.h[g]&=8191;for(this.h[0]+=n*5,n=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=n,n=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=n,a[0]=this.h[0]+5,n=a[0]>>>13,a[0]&=8191,g=1;g<10;g++)a[g]=this.h[g]+n,n=a[g]>>>13,a[g]&=8191;for(a[9]-=8192,u=(n^1)-1,g=0;g<10;g++)a[g]&=u;for(u=~u,g=0;g<10;g++)this.h[g]=this.h[g]&u|a[g];for(this.h[0]=(this.h[0]|this.h[1]<<13)&65535,this.h[1]=(this.h[1]>>>3|this.h[2]<<10)&65535,this.h[2]=(this.h[2]>>>6|this.h[3]<<7)&65535,this.h[3]=(this.h[3]>>>9|this.h[4]<<4)&65535,this.h[4]=(this.h[4]>>>12|this.h[5]<<1|this.h[6]<<14)&65535,this.h[5]=(this.h[6]>>>2|this.h[7]<<11)&65535,this.h[6]=(this.h[7]>>>5|this.h[8]<<8)&65535,this.h[7]=(this.h[8]>>>8|this.h[9]<<5)&65535,y=this.h[0]+this.pad[0],this.h[0]=y&65535,g=1;g<8;g++)y=(this.h[g]+this.pad[g]|0)+(y>>>16)|0,this.h[g]=y&65535;i[c+0]=this.h[0]>>>0&255,i[c+1]=this.h[0]>>>8&255,i[c+2]=this.h[1]>>>0&255,i[c+3]=this.h[1]>>>8&255,i[c+4]=this.h[2]>>>0&255,i[c+5]=this.h[2]>>>8&255,i[c+6]=this.h[3]>>>0&255,i[c+7]=this.h[3]>>>8&255,i[c+8]=this.h[4]>>>0&255,i[c+9]=this.h[4]>>>8&255,i[c+10]=this.h[5]>>>0&255,i[c+11]=this.h[5]>>>8&255,i[c+12]=this.h[6]>>>0&255,i[c+13]=this.h[6]>>>8&255,i[c+14]=this.h[7]>>>0&255,i[c+15]=this.h[7]>>>8&255},vt.prototype.update=function(i,c,a){var n,u;if(this.leftover){for(u=16-this.leftover,u>a&&(u=a),n=0;n<u;n++)this.buffer[this.leftover+n]=i[c+n];if(a-=u,c+=u,this.leftover+=u,this.leftover<16)return;this.blocks(this.buffer,0,16),this.leftover=0}if(a>=16&&(u=a-a%16,this.blocks(i,c,u),c+=u,a-=u),a){for(n=0;n<a;n++)this.buffer[this.leftover+n]=i[c+n];this.leftover+=a}};function pt(i,c,a,n,u,y){var g=new vt(y);return g.update(a,n,u),g.finish(i,c),0}function Ft(i,c,a,n,u,y){var g=new Uint8Array(16);return pt(g,0,a,n,u,y),U(i,c,g,0)}function Pe(i,c,a,n,u){var y;if(a<32)return-1;for(mt(i,0,c,0,a,n,u),pt(i,16,i,32,a-32,i),y=0;y<16;y++)i[y]=0;return 0}function Je(i,c,a,n,u){var y,g=new Uint8Array(32);if(a<32||(_t(g,0,32,n,u),Ft(c,16,c,32,a-32,g)!==0))return-1;for(mt(i,0,c,0,a,n,u),y=0;y<32;y++)i[y]=0;return 0}function Se(i,c){var a;for(a=0;a<16;a++)i[a]=c[a]|0}function Te(i){var c,a,n=1;for(c=0;c<16;c++)a=i[c]+n+65535,n=Math.floor(a/65536),i[c]=a-n*65536;i[0]+=n-1+37*(n-1)}function Re(i,c,a){for(var n,u=~(a-1),y=0;y<16;y++)n=u&(i[y]^c[y]),i[y]^=n,c[y]^=n}function Ue(i,c){var a,n,u,y=r(),g=r();for(a=0;a<16;a++)g[a]=c[a];for(Te(g),Te(g),Te(g),n=0;n<2;n++){for(y[0]=g[0]-65517,a=1;a<15;a++)y[a]=g[a]-65535-(y[a-1]>>16&1),y[a-1]&=65535;y[15]=g[15]-32767-(y[14]>>16&1),u=y[15]>>16&1,y[14]&=65535,Re(g,y,1-u)}for(a=0;a<16;a++)i[2*a]=g[a]&255,i[2*a+1]=g[a]>>8}function Yn(i,c){var a=new Uint8Array(32),n=new Uint8Array(32);return Ue(a,i),Ue(n,c),se(a,0,n,0)}function Wn(i){var c=new Uint8Array(32);return Ue(c,i),c[0]&1}function kr(i,c){var a;for(a=0;a<16;a++)i[a]=c[2*a]+(c[2*a+1]<<8);i[15]&=32767}function $e(i,c,a){for(var n=0;n<16;n++)i[n]=c[n]+a[n]}function qe(i,c,a){for(var n=0;n<16;n++)i[n]=c[n]-a[n]}function ie(i,c,a){var n,u,y=0,g=0,A=0,N=0,q=0,T=0,ce=0,F=0,z=0,H=0,X=0,W=0,J=0,Y=0,V=0,B=0,D=0,k=0,K=0,$=0,I=0,v=0,x=0,C=0,S=0,O=0,j=0,G=0,Z=0,ee=0,Q=0,h=a[0],ne=a[1],fe=a[2],ue=a[3],re=a[4],oe=a[5],ae=a[6],xe=a[7],be=a[8],_e=a[9],me=a[10],ve=a[11],Ee=a[12],Ce=a[13],je=a[14],Ne=a[15];n=c[0],y+=n*h,g+=n*ne,A+=n*fe,N+=n*ue,q+=n*re,T+=n*oe,ce+=n*ae,F+=n*xe,z+=n*be,H+=n*_e,X+=n*me,W+=n*ve,J+=n*Ee,Y+=n*Ce,V+=n*je,B+=n*Ne,n=c[1],g+=n*h,A+=n*ne,N+=n*fe,q+=n*ue,T+=n*re,ce+=n*oe,F+=n*ae,z+=n*xe,H+=n*be,X+=n*_e,W+=n*me,J+=n*ve,Y+=n*Ee,V+=n*Ce,B+=n*je,D+=n*Ne,n=c[2],A+=n*h,N+=n*ne,q+=n*fe,T+=n*ue,ce+=n*re,F+=n*oe,z+=n*ae,H+=n*xe,X+=n*be,W+=n*_e,J+=n*me,Y+=n*ve,V+=n*Ee,B+=n*Ce,D+=n*je,k+=n*Ne,n=c[3],N+=n*h,q+=n*ne,T+=n*fe,ce+=n*ue,F+=n*re,z+=n*oe,H+=n*ae,X+=n*xe,W+=n*be,J+=n*_e,Y+=n*me,V+=n*ve,B+=n*Ee,D+=n*Ce,k+=n*je,K+=n*Ne,n=c[4],q+=n*h,T+=n*ne,ce+=n*fe,F+=n*ue,z+=n*re,H+=n*oe,X+=n*ae,W+=n*xe,J+=n*be,Y+=n*_e,V+=n*me,B+=n*ve,D+=n*Ee,k+=n*Ce,K+=n*je,$+=n*Ne,n=c[5],T+=n*h,ce+=n*ne,F+=n*fe,z+=n*ue,H+=n*re,X+=n*oe,W+=n*ae,J+=n*xe,Y+=n*be,V+=n*_e,B+=n*me,D+=n*ve,k+=n*Ee,K+=n*Ce,$+=n*je,I+=n*Ne,n=c[6],ce+=n*h,F+=n*ne,z+=n*fe,H+=n*ue,X+=n*re,W+=n*oe,J+=n*ae,Y+=n*xe,V+=n*be,B+=n*_e,D+=n*me,k+=n*ve,K+=n*Ee,$+=n*Ce,I+=n*je,v+=n*Ne,n=c[7],F+=n*h,z+=n*ne,H+=n*fe,X+=n*ue,W+=n*re,J+=n*oe,Y+=n*ae,V+=n*xe,B+=n*be,D+=n*_e,k+=n*me,K+=n*ve,$+=n*Ee,I+=n*Ce,v+=n*je,x+=n*Ne,n=c[8],z+=n*h,H+=n*ne,X+=n*fe,W+=n*ue,J+=n*re,Y+=n*oe,V+=n*ae,B+=n*xe,D+=n*be,k+=n*_e,K+=n*me,$+=n*ve,I+=n*Ee,v+=n*Ce,x+=n*je,C+=n*Ne,n=c[9],H+=n*h,X+=n*ne,W+=n*fe,J+=n*ue,Y+=n*re,V+=n*oe,B+=n*ae,D+=n*xe,k+=n*be,K+=n*_e,$+=n*me,I+=n*ve,v+=n*Ee,x+=n*Ce,C+=n*je,S+=n*Ne,n=c[10],X+=n*h,W+=n*ne,J+=n*fe,Y+=n*ue,V+=n*re,B+=n*oe,D+=n*ae,k+=n*xe,K+=n*be,$+=n*_e,I+=n*me,v+=n*ve,x+=n*Ee,C+=n*Ce,S+=n*je,O+=n*Ne,n=c[11],W+=n*h,J+=n*ne,Y+=n*fe,V+=n*ue,B+=n*re,D+=n*oe,k+=n*ae,K+=n*xe,$+=n*be,I+=n*_e,v+=n*me,x+=n*ve,C+=n*Ee,S+=n*Ce,O+=n*je,j+=n*Ne,n=c[12],J+=n*h,Y+=n*ne,V+=n*fe,B+=n*ue,D+=n*re,k+=n*oe,K+=n*ae,$+=n*xe,I+=n*be,v+=n*_e,x+=n*me,C+=n*ve,S+=n*Ee,O+=n*Ce,j+=n*je,G+=n*Ne,n=c[13],Y+=n*h,V+=n*ne,B+=n*fe,D+=n*ue,k+=n*re,K+=n*oe,$+=n*ae,I+=n*xe,v+=n*be,x+=n*_e,C+=n*me,S+=n*ve,O+=n*Ee,j+=n*Ce,G+=n*je,Z+=n*Ne,n=c[14],V+=n*h,B+=n*ne,D+=n*fe,k+=n*ue,K+=n*re,$+=n*oe,I+=n*ae,v+=n*xe,x+=n*be,C+=n*_e,S+=n*me,O+=n*ve,j+=n*Ee,G+=n*Ce,Z+=n*je,ee+=n*Ne,n=c[15],B+=n*h,D+=n*ne,k+=n*fe,K+=n*ue,$+=n*re,I+=n*oe,v+=n*ae,x+=n*xe,C+=n*be,S+=n*_e,O+=n*me,j+=n*ve,G+=n*Ee,Z+=n*Ce,ee+=n*je,Q+=n*Ne,y+=38*D,g+=38*k,A+=38*K,N+=38*$,q+=38*I,T+=38*v,ce+=38*x,F+=38*C,z+=38*S,H+=38*O,X+=38*j,W+=38*G,J+=38*Z,Y+=38*ee,V+=38*Q,u=1,n=y+u+65535,u=Math.floor(n/65536),y=n-u*65536,n=g+u+65535,u=Math.floor(n/65536),g=n-u*65536,n=A+u+65535,u=Math.floor(n/65536),A=n-u*65536,n=N+u+65535,u=Math.floor(n/65536),N=n-u*65536,n=q+u+65535,u=Math.floor(n/65536),q=n-u*65536,n=T+u+65535,u=Math.floor(n/65536),T=n-u*65536,n=ce+u+65535,u=Math.floor(n/65536),ce=n-u*65536,n=F+u+65535,u=Math.floor(n/65536),F=n-u*65536,n=z+u+65535,u=Math.floor(n/65536),z=n-u*65536,n=H+u+65535,u=Math.floor(n/65536),H=n-u*65536,n=X+u+65535,u=Math.floor(n/65536),X=n-u*65536,n=W+u+65535,u=Math.floor(n/65536),W=n-u*65536,n=J+u+65535,u=Math.floor(n/65536),J=n-u*65536,n=Y+u+65535,u=Math.floor(n/65536),Y=n-u*65536,n=V+u+65535,u=Math.floor(n/65536),V=n-u*65536,n=B+u+65535,u=Math.floor(n/65536),B=n-u*65536,y+=u-1+37*(u-1),u=1,n=y+u+65535,u=Math.floor(n/65536),y=n-u*65536,n=g+u+65535,u=Math.floor(n/65536),g=n-u*65536,n=A+u+65535,u=Math.floor(n/65536),A=n-u*65536,n=N+u+65535,u=Math.floor(n/65536),N=n-u*65536,n=q+u+65535,u=Math.floor(n/65536),q=n-u*65536,n=T+u+65535,u=Math.floor(n/65536),T=n-u*65536,n=ce+u+65535,u=Math.floor(n/65536),ce=n-u*65536,n=F+u+65535,u=Math.floor(n/65536),F=n-u*65536,n=z+u+65535,u=Math.floor(n/65536),z=n-u*65536,n=H+u+65535,u=Math.floor(n/65536),H=n-u*65536,n=X+u+65535,u=Math.floor(n/65536),X=n-u*65536,n=W+u+65535,u=Math.floor(n/65536),W=n-u*65536,n=J+u+65535,u=Math.floor(n/65536),J=n-u*65536,n=Y+u+65535,u=Math.floor(n/65536),Y=n-u*65536,n=V+u+65535,u=Math.floor(n/65536),V=n-u*65536,n=B+u+65535,u=Math.floor(n/65536),B=n-u*65536,y+=u-1+37*(u-1),i[0]=y,i[1]=g,i[2]=A,i[3]=N,i[4]=q,i[5]=T,i[6]=ce,i[7]=F,i[8]=z,i[9]=H,i[10]=X,i[11]=W,i[12]=J,i[13]=Y,i[14]=V,i[15]=B}function Be(i,c){ie(i,c,c)}function Xn(i,c){var a=r(),n;for(n=0;n<16;n++)a[n]=c[n];for(n=253;n>=0;n--)Be(a,a),n!==2&&n!==4&&ie(a,a,c);for(n=0;n<16;n++)i[n]=a[n]}function Zn(i,c){var a=r(),n;for(n=0;n<16;n++)a[n]=c[n];for(n=250;n>=0;n--)Be(a,a),n!==1&&ie(a,a,c);for(n=0;n<16;n++)i[n]=a[n]}function sr(i,c,a){var n=new Uint8Array(32),u=new Float64Array(80),y,g,A=r(),N=r(),q=r(),T=r(),ce=r(),F=r();for(g=0;g<31;g++)n[g]=c[g];for(n[31]=c[31]&127|64,n[0]&=248,kr(u,a),g=0;g<16;g++)N[g]=u[g],T[g]=A[g]=q[g]=0;for(A[0]=T[0]=1,g=254;g>=0;--g)y=n[g>>>3]>>>(g&7)&1,Re(A,N,y),Re(q,T,y),$e(ce,A,q),qe(A,A,q),$e(q,N,T),qe(N,N,T),Be(T,ce),Be(F,A),ie(A,q,A),ie(q,N,ce),$e(ce,A,q),qe(A,A,q),Be(N,A),qe(q,T,F),ie(A,q,P),$e(A,A,T),ie(q,q,A),ie(A,T,F),ie(T,N,u),Be(N,ce),Re(A,N,y),Re(q,T,y);for(g=0;g<16;g++)u[g+16]=A[g],u[g+32]=q[g],u[g+48]=N[g],u[g+64]=T[g];var z=u.subarray(32),H=u.subarray(16);return Xn(z,z),ie(H,H,z),Ue(i,H),0}function ir(i,c){return sr(i,c,f)}function Qn(i,c){return s(c,32),ir(i,c)}function or(i,c,a){var n=new Uint8Array(32);return sr(n,a,c),de(i,o,n,le)}var es=Pe,Hi=Je;function Ji(i,c,a,n,u,y){var g=new Uint8Array(32);return or(g,u,y),es(i,c,a,n,g)}function Vi(i,c,a,n,u,y){var g=new Uint8Array(32);return or(g,u,y),Hi(i,c,a,n,g)}var ts=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function rs(i,c,a,n){for(var u=new Int32Array(16),y=new Int32Array(16),g,A,N,q,T,ce,F,z,H,X,W,J,Y,V,B,D,k,K,$,I,v,x,C,S,O,j,G=i[0],Z=i[1],ee=i[2],Q=i[3],h=i[4],ne=i[5],fe=i[6],ue=i[7],re=c[0],oe=c[1],ae=c[2],xe=c[3],be=c[4],_e=c[5],me=c[6],ve=c[7],Ee=0;n>=128;){for($=0;$<16;$++)I=8*$+Ee,u[$]=a[I+0]<<24|a[I+1]<<16|a[I+2]<<8|a[I+3],y[$]=a[I+4]<<24|a[I+5]<<16|a[I+6]<<8|a[I+7];for($=0;$<80;$++)if(g=G,A=Z,N=ee,q=Q,T=h,ce=ne,F=fe,z=ue,H=re,X=oe,W=ae,J=xe,Y=be,V=_e,B=me,D=ve,v=ue,x=ve,C=x&65535,S=x>>>16,O=v&65535,j=v>>>16,v=(h>>>14|be<<18)^(h>>>18|be<<14)^(be>>>9|h<<23),x=(be>>>14|h<<18)^(be>>>18|h<<14)^(h>>>9|be<<23),C+=x&65535,S+=x>>>16,O+=v&65535,j+=v>>>16,v=h&ne^~h&fe,x=be&_e^~be&me,C+=x&65535,S+=x>>>16,O+=v&65535,j+=v>>>16,v=ts[$*2],x=ts[$*2+1],C+=x&65535,S+=x>>>16,O+=v&65535,j+=v>>>16,v=u[$%16],x=y[$%16],C+=x&65535,S+=x>>>16,O+=v&65535,j+=v>>>16,S+=C>>>16,O+=S>>>16,j+=O>>>16,k=O&65535|j<<16,K=C&65535|S<<16,v=k,x=K,C=x&65535,S=x>>>16,O=v&65535,j=v>>>16,v=(G>>>28|re<<4)^(re>>>2|G<<30)^(re>>>7|G<<25),x=(re>>>28|G<<4)^(G>>>2|re<<30)^(G>>>7|re<<25),C+=x&65535,S+=x>>>16,O+=v&65535,j+=v>>>16,v=G&Z^G&ee^Z&ee,x=re&oe^re&ae^oe&ae,C+=x&65535,S+=x>>>16,O+=v&65535,j+=v>>>16,S+=C>>>16,O+=S>>>16,j+=O>>>16,z=O&65535|j<<16,D=C&65535|S<<16,v=q,x=J,C=x&65535,S=x>>>16,O=v&65535,j=v>>>16,v=k,x=K,C+=x&65535,S+=x>>>16,O+=v&65535,j+=v>>>16,S+=C>>>16,O+=S>>>16,j+=O>>>16,q=O&65535|j<<16,J=C&65535|S<<16,Z=g,ee=A,Q=N,h=q,ne=T,fe=ce,ue=F,G=z,oe=H,ae=X,xe=W,be=J,_e=Y,me=V,ve=B,re=D,$%16===15)for(I=0;I<16;I++)v=u[I],x=y[I],C=x&65535,S=x>>>16,O=v&65535,j=v>>>16,v=u[(I+9)%16],x=y[(I+9)%16],C+=x&65535,S+=x>>>16,O+=v&65535,j+=v>>>16,k=u[(I+1)%16],K=y[(I+1)%16],v=(k>>>1|K<<31)^(k>>>8|K<<24)^k>>>7,x=(K>>>1|k<<31)^(K>>>8|k<<24)^(K>>>7|k<<25),C+=x&65535,S+=x>>>16,O+=v&65535,j+=v>>>16,k=u[(I+14)%16],K=y[(I+14)%16],v=(k>>>19|K<<13)^(K>>>29|k<<3)^k>>>6,x=(K>>>19|k<<13)^(k>>>29|K<<3)^(K>>>6|k<<26),C+=x&65535,S+=x>>>16,O+=v&65535,j+=v>>>16,S+=C>>>16,O+=S>>>16,j+=O>>>16,u[I]=O&65535|j<<16,y[I]=C&65535|S<<16;v=G,x=re,C=x&65535,S=x>>>16,O=v&65535,j=v>>>16,v=i[0],x=c[0],C+=x&65535,S+=x>>>16,O+=v&65535,j+=v>>>16,S+=C>>>16,O+=S>>>16,j+=O>>>16,i[0]=G=O&65535|j<<16,c[0]=re=C&65535|S<<16,v=Z,x=oe,C=x&65535,S=x>>>16,O=v&65535,j=v>>>16,v=i[1],x=c[1],C+=x&65535,S+=x>>>16,O+=v&65535,j+=v>>>16,S+=C>>>16,O+=S>>>16,j+=O>>>16,i[1]=Z=O&65535|j<<16,c[1]=oe=C&65535|S<<16,v=ee,x=ae,C=x&65535,S=x>>>16,O=v&65535,j=v>>>16,v=i[2],x=c[2],C+=x&65535,S+=x>>>16,O+=v&65535,j+=v>>>16,S+=C>>>16,O+=S>>>16,j+=O>>>16,i[2]=ee=O&65535|j<<16,c[2]=ae=C&65535|S<<16,v=Q,x=xe,C=x&65535,S=x>>>16,O=v&65535,j=v>>>16,v=i[3],x=c[3],C+=x&65535,S+=x>>>16,O+=v&65535,j+=v>>>16,S+=C>>>16,O+=S>>>16,j+=O>>>16,i[3]=Q=O&65535|j<<16,c[3]=xe=C&65535|S<<16,v=h,x=be,C=x&65535,S=x>>>16,O=v&65535,j=v>>>16,v=i[4],x=c[4],C+=x&65535,S+=x>>>16,O+=v&65535,j+=v>>>16,S+=C>>>16,O+=S>>>16,j+=O>>>16,i[4]=h=O&65535|j<<16,c[4]=be=C&65535|S<<16,v=ne,x=_e,C=x&65535,S=x>>>16,O=v&65535,j=v>>>16,v=i[5],x=c[5],C+=x&65535,S+=x>>>16,O+=v&65535,j+=v>>>16,S+=C>>>16,O+=S>>>16,j+=O>>>16,i[5]=ne=O&65535|j<<16,c[5]=_e=C&65535|S<<16,v=fe,x=me,C=x&65535,S=x>>>16,O=v&65535,j=v>>>16,v=i[6],x=c[6],C+=x&65535,S+=x>>>16,O+=v&65535,j+=v>>>16,S+=C>>>16,O+=S>>>16,j+=O>>>16,i[6]=fe=O&65535|j<<16,c[6]=me=C&65535|S<<16,v=ue,x=ve,C=x&65535,S=x>>>16,O=v&65535,j=v>>>16,v=i[7],x=c[7],C+=x&65535,S+=x>>>16,O+=v&65535,j+=v>>>16,S+=C>>>16,O+=S>>>16,j+=O>>>16,i[7]=ue=O&65535|j<<16,c[7]=ve=C&65535|S<<16,Ee+=128,n-=128}return n}function at(i,c,a){var n=new Int32Array(8),u=new Int32Array(8),y=new Uint8Array(256),g,A=a;for(n[0]=1779033703,n[1]=3144134277,n[2]=1013904242,n[3]=2773480762,n[4]=1359893119,n[5]=2600822924,n[6]=528734635,n[7]=1541459225,u[0]=4089235720,u[1]=2227873595,u[2]=4271175723,u[3]=1595750129,u[4]=2917565137,u[5]=725511199,u[6]=4215389547,u[7]=327033209,rs(n,u,c,a),a%=128,g=0;g<a;g++)y[g]=c[A-a+g];for(y[a]=128,a=256-128*(a<112?1:0),y[a-9]=0,R(y,a-8,A/536870912|0,A<<3),rs(n,u,y,a),g=0;g<8;g++)R(i,8*g,n[g],u[g]);return 0}function ar(i,c){var a=r(),n=r(),u=r(),y=r(),g=r(),A=r(),N=r(),q=r(),T=r();qe(a,i[1],i[0]),qe(T,c[1],c[0]),ie(a,a,T),$e(n,i[0],i[1]),$e(T,c[0],c[1]),ie(n,n,T),ie(u,i[3],c[3]),ie(u,u,w),ie(y,i[2],c[2]),$e(y,y,y),qe(g,n,a),qe(A,y,u),$e(N,y,u),$e(q,n,a),ie(i[0],g,A),ie(i[1],q,N),ie(i[2],N,A),ie(i[3],g,q)}function ns(i,c,a){var n;for(n=0;n<4;n++)Re(i[n],c[n],a)}function Ur(i,c){var a=r(),n=r(),u=r();Xn(u,c[2]),ie(a,c[0],u),ie(n,c[1],u),Ue(i,n),i[31]^=Wn(a)<<7}function Lr(i,c,a){var n,u;for(Se(i[0],l),Se(i[1],m),Se(i[2],m),Se(i[3],l),u=255;u>=0;--u)n=a[u/8|0]>>(u&7)&1,ns(i,c,n),ar(c,i),ar(i,i),ns(i,c,n)}function cr(i,c){var a=[r(),r(),r(),r()];Se(a[0],E),Se(a[1],b),Se(a[2],m),ie(a[3],E,b),Lr(i,a,c)}function Fr(i,c,a){var n=new Uint8Array(64),u=[r(),r(),r(),r()],y;for(a||s(c,32),at(n,c,32),n[0]&=248,n[31]&=127,n[31]|=64,cr(u,n),Ur(i,u),y=0;y<32;y++)c[y+32]=i[y];return 0}var fr=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function Br(i,c){var a,n,u,y;for(n=63;n>=32;--n){for(a=0,u=n-32,y=n-12;u<y;++u)c[u]+=a-16*c[n]*fr[u-(n-32)],a=Math.floor((c[u]+128)/256),c[u]-=a*256;c[u]+=a,c[n]=0}for(a=0,u=0;u<32;u++)c[u]+=a-(c[31]>>4)*fr[u],a=c[u]>>8,c[u]&=255;for(u=0;u<32;u++)c[u]-=a*fr[u];for(n=0;n<32;n++)c[n+1]+=c[n]>>8,i[n]=c[n]&255}function Kr(i){var c=new Float64Array(64),a;for(a=0;a<64;a++)c[a]=i[a];for(a=0;a<64;a++)i[a]=0;Br(i,c)}function ss(i,c,a,n){var u=new Uint8Array(64),y=new Uint8Array(64),g=new Uint8Array(64),A,N,q=new Float64Array(64),T=[r(),r(),r(),r()];at(u,n,32),u[0]&=248,u[31]&=127,u[31]|=64;var ce=a+64;for(A=0;A<a;A++)i[64+A]=c[A];for(A=0;A<32;A++)i[32+A]=u[32+A];for(at(g,i.subarray(32),a+32),Kr(g),cr(T,g),Ur(i,T),A=32;A<64;A++)i[A]=n[A];for(at(y,i,a+64),Kr(y),A=0;A<64;A++)q[A]=0;for(A=0;A<32;A++)q[A]=g[A];for(A=0;A<32;A++)for(N=0;N<32;N++)q[A+N]+=y[A]*u[N];return Br(i.subarray(32),q),ce}function Yi(i,c){var a=r(),n=r(),u=r(),y=r(),g=r(),A=r(),N=r();return Se(i[2],m),kr(i[1],c),Be(u,i[1]),ie(y,u,_),qe(u,u,i[2]),$e(y,i[2],y),Be(g,y),Be(A,g),ie(N,A,g),ie(a,N,u),ie(a,a,y),Zn(a,a),ie(a,a,u),ie(a,a,y),ie(a,a,y),ie(i[0],a,y),Be(n,i[0]),ie(n,n,y),Yn(n,u)&&ie(i[0],i[0],p),Be(n,i[0]),ie(n,n,y),Yn(n,u)?-1:(Wn(i[0])===c[31]>>7&&qe(i[0],l,i[0]),ie(i[3],i[0],i[1]),0)}function $r(i,c,a,n){var u,y=new Uint8Array(32),g=new Uint8Array(64),A=[r(),r(),r(),r()],N=[r(),r(),r(),r()];if(a<64||Yi(N,n))return-1;for(u=0;u<a;u++)i[u]=c[u];for(u=0;u<32;u++)i[u+32]=n[u];if(at(g,i,a),Kr(g),Lr(A,N,g),cr(N,c.subarray(32)),ar(A,N),Ur(y,A),a-=64,se(c,0,y,0)){for(u=0;u<a;u++)i[u]=0;return-1}for(u=0;u<a;u++)i[u]=c[u+64];return a}var qr=32,ur=24,Bt=32,xt=16,Kt=32,hr=32,$t=32,qt=32,Dr=32,is=ur,Wi=Bt,Xi=xt,Ze=64,ct=32,wt=64,Gr=32,zr=64;e.lowlevel={crypto_core_hsalsa20:de,crypto_stream_xor:mt,crypto_stream:_t,crypto_stream_salsa20_xor:He,crypto_stream_salsa20:Lt,crypto_onetimeauth:pt,crypto_onetimeauth_verify:Ft,crypto_verify_16:U,crypto_verify_32:se,crypto_secretbox:Pe,crypto_secretbox_open:Je,crypto_scalarmult:sr,crypto_scalarmult_base:ir,crypto_box_beforenm:or,crypto_box_afternm:es,crypto_box:Ji,crypto_box_open:Vi,crypto_box_keypair:Qn,crypto_hash:at,crypto_sign:ss,crypto_sign_keypair:Fr,crypto_sign_open:$r,crypto_secretbox_KEYBYTES:qr,crypto_secretbox_NONCEBYTES:ur,crypto_secretbox_ZEROBYTES:Bt,crypto_secretbox_BOXZEROBYTES:xt,crypto_scalarmult_BYTES:Kt,crypto_scalarmult_SCALARBYTES:hr,crypto_box_PUBLICKEYBYTES:$t,crypto_box_SECRETKEYBYTES:qt,crypto_box_BEFORENMBYTES:Dr,crypto_box_NONCEBYTES:is,crypto_box_ZEROBYTES:Wi,crypto_box_BOXZEROBYTES:Xi,crypto_sign_BYTES:Ze,crypto_sign_PUBLICKEYBYTES:ct,crypto_sign_SECRETKEYBYTES:wt,crypto_sign_SEEDBYTES:Gr,crypto_hash_BYTES:zr,gf:r,D:_,L:fr,pack25519:Ue,unpack25519:kr,M:ie,A:$e,S:Be,Z:qe,pow2523:Zn,add:ar,set25519:Se,modL:Br,scalarmult:Lr,scalarbase:cr};function os(i,c){if(i.length!==qr)throw new Error("bad key size");if(c.length!==ur)throw new Error("bad nonce size")}function Zi(i,c){if(i.length!==$t)throw new Error("bad public key size");if(c.length!==qt)throw new Error("bad secret key size")}function Le(){for(var i=0;i<arguments.length;i++)if(!(arguments[i]instanceof Uint8Array))throw new TypeError("unexpected type, use Uint8Array")}function as(i){for(var c=0;c<i.length;c++)i[c]=0}e.randomBytes=function(i){var c=new Uint8Array(i);return s(c,i),c},e.secretbox=function(i,c,a){Le(i,c,a),os(a,c);for(var n=new Uint8Array(Bt+i.length),u=new Uint8Array(n.length),y=0;y<i.length;y++)n[y+Bt]=i[y];return Pe(u,n,n.length,c,a),u.subarray(xt)},e.secretbox.open=function(i,c,a){Le(i,c,a),os(a,c);for(var n=new Uint8Array(xt+i.length),u=new Uint8Array(n.length),y=0;y<i.length;y++)n[y+xt]=i[y];return n.length<32||Je(u,n,n.length,c,a)!==0?null:u.subarray(Bt)},e.secretbox.keyLength=qr,e.secretbox.nonceLength=ur,e.secretbox.overheadLength=xt,e.scalarMult=function(i,c){if(Le(i,c),i.length!==hr)throw new Error("bad n size");if(c.length!==Kt)throw new Error("bad p size");var a=new Uint8Array(Kt);return sr(a,i,c),a},e.scalarMult.base=function(i){if(Le(i),i.length!==hr)throw new Error("bad n size");var c=new Uint8Array(Kt);return ir(c,i),c},e.scalarMult.scalarLength=hr,e.scalarMult.groupElementLength=Kt,e.box=function(i,c,a,n){var u=e.box.before(a,n);return e.secretbox(i,c,u)},e.box.before=function(i,c){Le(i,c),Zi(i,c);var a=new Uint8Array(Dr);return or(a,i,c),a},e.box.after=e.secretbox,e.box.open=function(i,c,a,n){var u=e.box.before(a,n);return e.secretbox.open(i,c,u)},e.box.open.after=e.secretbox.open,e.box.keyPair=function(){var i=new Uint8Array($t),c=new Uint8Array(qt);return Qn(i,c),{publicKey:i,secretKey:c}},e.box.keyPair.fromSecretKey=function(i){if(Le(i),i.length!==qt)throw new Error("bad secret key size");var c=new Uint8Array($t);return ir(c,i),{publicKey:c,secretKey:new Uint8Array(i)}},e.box.publicKeyLength=$t,e.box.secretKeyLength=qt,e.box.sharedKeyLength=Dr,e.box.nonceLength=is,e.box.overheadLength=e.secretbox.overheadLength,e.sign=function(i,c){if(Le(i,c),c.length!==wt)throw new Error("bad secret key size");var a=new Uint8Array(Ze+i.length);return ss(a,i,i.length,c),a},e.sign.open=function(i,c){if(Le(i,c),c.length!==ct)throw new Error("bad public key size");var a=new Uint8Array(i.length),n=$r(a,i,i.length,c);if(n<0)return null;for(var u=new Uint8Array(n),y=0;y<u.length;y++)u[y]=a[y];return u},e.sign.detached=function(i,c){for(var a=e.sign(i,c),n=new Uint8Array(Ze),u=0;u<n.length;u++)n[u]=a[u];return n},e.sign.detached.verify=function(i,c,a){if(Le(i,c,a),c.length!==Ze)throw new Error("bad signature size");if(a.length!==ct)throw new Error("bad public key size");var n=new Uint8Array(Ze+i.length),u=new Uint8Array(Ze+i.length),y;for(y=0;y<Ze;y++)n[y]=c[y];for(y=0;y<i.length;y++)n[y+Ze]=i[y];return $r(u,n,n.length,a)>=0},e.sign.keyPair=function(){var i=new Uint8Array(ct),c=new Uint8Array(wt);return Fr(i,c),{publicKey:i,secretKey:c}},e.sign.keyPair.fromSecretKey=function(i){if(Le(i),i.length!==wt)throw new Error("bad secret key size");for(var c=new Uint8Array(ct),a=0;a<c.length;a++)c[a]=i[32+a];return{publicKey:c,secretKey:new Uint8Array(i)}},e.sign.keyPair.fromSeed=function(i){if(Le(i),i.length!==Gr)throw new Error("bad seed size");for(var c=new Uint8Array(ct),a=new Uint8Array(wt),n=0;n<32;n++)a[n]=i[n];return Fr(c,a,!0),{publicKey:c,secretKey:a}},e.sign.publicKeyLength=ct,e.sign.secretKeyLength=wt,e.sign.seedLength=Gr,e.sign.signatureLength=Ze,e.hash=function(i){Le(i);var c=new Uint8Array(zr);return at(c,i,i.length),c},e.hash.hashLength=zr,e.verify=function(i,c){return Le(i,c),i.length===0||c.length===0||i.length!==c.length?!1:M(i,0,c,0,i.length)===0},e.setPRNG=function(i){s=i},function(){var i=typeof self<"u"?self.crypto||self.msCrypto:null;if(i&&i.getRandomValues){var c=65536;e.setPRNG(function(a,n){var u,y=new Uint8Array(n);for(u=0;u<n;u+=c)i.getRandomValues(y.subarray(u,u+Math.min(n-u,c)));for(u=0;u<n;u++)a[u]=y[u];as(y)})}else typeof Ys<"u"&&(i=Ws,i&&i.randomBytes&&e.setPRNG(function(a,n){var u,y=i.randomBytes(n);for(u=0;u<n;u++)a[u]=y[u];as(y)}))}()})(t.exports?t.exports:self.nacl=self.nacl||{})})(Sn);var Xs=Sn.exports,Zs=he&&he.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(bt,"__esModule",{value:!0});const Qs=Zs(Xs);bt.default=Qs.default;var An;function ei(){if(An)return Mt;An=1;var t=he&&he.__importDefault||function(f){return f&&f.__esModule?f:{default:f}};Object.defineProperty(Mt,"__esModule",{value:!0}),Mt.KP=void 0;const e=Zt(),r=yt(),s=t(bt);class o{constructor(l){d(this,"seed");this.seed=l}getRawSeed(){if(!this.seed)throw new r.NKeysError(r.NKeysErrorCode.ClearedPair);return e.Codec.decodeSeed(this.seed).buf}getSeed(){if(!this.seed)throw new r.NKeysError(r.NKeysErrorCode.ClearedPair);return this.seed}getPublicKey(){if(!this.seed)throw new r.NKeysError(r.NKeysErrorCode.ClearedPair);const l=e.Codec.decodeSeed(this.seed),m=s.default.sign.keyPair.fromSeed(this.getRawSeed()),P=e.Codec.encode(l.prefix,m.publicKey);return new TextDecoder().decode(P)}getPrivateKey(){if(!this.seed)throw new r.NKeysError(r.NKeysErrorCode.ClearedPair);const l=s.default.sign.keyPair.fromSeed(this.getRawSeed());return e.Codec.encode(r.Prefix.Private,l.secretKey)}sign(l){if(!this.seed)throw new r.NKeysError(r.NKeysErrorCode.ClearedPair);const m=s.default.sign.keyPair.fromSeed(this.getRawSeed());return s.default.sign.detached(l,m.secretKey)}verify(l,m){if(!this.seed)throw new r.NKeysError(r.NKeysErrorCode.ClearedPair);const P=s.default.sign.keyPair.fromSeed(this.getRawSeed());return s.default.sign.detached.verify(l,m,P.publicKey)}clear(){this.seed&&(this.seed.fill(0),this.seed=void 0)}seal(l,m,P){throw new r.NKeysError(r.NKeysErrorCode.InvalidNKeyOperation)}open(l,m){throw new r.NKeysError(r.NKeysErrorCode.InvalidNKeyOperation)}}return Mt.KP=o,Mt}var kt={},On;function ti(){if(On)return kt;On=1;var t=he&&he.__importDefault||function(f){return f&&f.__esModule?f:{default:f}};Object.defineProperty(kt,"__esModule",{value:!0}),kt.PublicKey=void 0;const e=Zt(),r=yt(),s=t(bt);class o{constructor(l){d(this,"publicKey");this.publicKey=l}getPublicKey(){if(!this.publicKey)throw new r.NKeysError(r.NKeysErrorCode.ClearedPair);return new TextDecoder().decode(this.publicKey)}getPrivateKey(){throw this.publicKey?new r.NKeysError(r.NKeysErrorCode.PublicKeyOnly):new r.NKeysError(r.NKeysErrorCode.ClearedPair)}getSeed(){throw this.publicKey?new r.NKeysError(r.NKeysErrorCode.PublicKeyOnly):new r.NKeysError(r.NKeysErrorCode.ClearedPair)}sign(l){throw this.publicKey?new r.NKeysError(r.NKeysErrorCode.CannotSign):new r.NKeysError(r.NKeysErrorCode.ClearedPair)}verify(l,m){if(!this.publicKey)throw new r.NKeysError(r.NKeysErrorCode.ClearedPair);const P=e.Codec._decode(this.publicKey);return s.default.sign.detached.verify(l,m,P.slice(1))}clear(){this.publicKey&&(this.publicKey.fill(0),this.publicKey=void 0)}seal(l,m,P){throw new r.NKeysError(r.NKeysErrorCode.InvalidNKeyOperation)}open(l,m){throw new r.NKeysError(r.NKeysErrorCode.InvalidNKeyOperation)}}return kt.PublicKey=o,kt}var Or={},Cn;function ri(){return Cn||(Cn=1,function(t){var e=he&&he.__importDefault||function(E){return E&&E.__esModule?E:{default:E}};Object.defineProperty(t,"__esModule",{value:!0}),t.CurveKP=t.curveNonceLen=t.curveKeyLen=void 0;const r=yt(),s=e(bt),o=Zt(),f=yt(),l=Rt,m=Tt;t.curveKeyLen=32;const P=35;t.curveNonceLen=24;const _=[120,107,118,49];class w{constructor(b){d(this,"seed");this.seed=b}clear(){this.seed&&(this.seed.fill(0),this.seed=void 0)}getPrivateKey(){if(!this.seed)throw new r.NKeysError(r.NKeysErrorCode.ClearedPair);return o.Codec.encode(f.Prefix.Private,this.seed)}getPublicKey(){if(!this.seed)throw new r.NKeysError(r.NKeysErrorCode.ClearedPair);const b=s.default.scalarMult.base(this.seed),p=o.Codec.encode(f.Prefix.Curve,b);return new TextDecoder().decode(p)}getSeed(){if(!this.seed)throw new r.NKeysError(r.NKeysErrorCode.ClearedPair);return o.Codec.encodeSeed(f.Prefix.Curve,this.seed)}sign(){throw new r.NKeysError(r.NKeysErrorCode.InvalidCurveOperation)}verify(){throw new r.NKeysError(r.NKeysErrorCode.InvalidCurveOperation)}decodePubCurveKey(b){try{const p=l.base32.decode(new TextEncoder().encode(b));if(p.byteLength!==P)throw new r.NKeysError(r.NKeysErrorCode.InvalidCurveKey);if(p[0]!==f.Prefix.Curve)throw new r.NKeysError(r.NKeysErrorCode.InvalidPublicKey);const R=p.byteLength-2,U=new DataView(p.buffer).getUint16(R,!0),se=p.slice(0,R);if(!m.crc16.validate(se,U))throw new r.NKeysError(r.NKeysErrorCode.InvalidChecksum);return se.slice(1)}catch(p){throw new r.NKeysError(r.NKeysErrorCode.InvalidRecipient,{cause:p})}}seal(b,p,R){if(!this.seed)throw new r.NKeysError(r.NKeysErrorCode.ClearedPair);R||(R=s.default.randomBytes(t.curveNonceLen));const M=this.decodePubCurveKey(p),U=new Uint8Array(_.length+t.curveNonceLen);U.set(_,0),U.set(R,_.length);const se=s.default.box(b,R,M,this.seed),ge=new Uint8Array(U.length+se.length);return ge.set(U),ge.set(se,U.length),ge}open(b,p){if(!this.seed)throw new r.NKeysError(r.NKeysErrorCode.ClearedPair);if(b.length<=t.curveNonceLen+_.length)throw new r.NKeysError(r.NKeysErrorCode.InvalidEncrypted);for(let U=0;U<_.length;U++)if(b[U]!==_[U])throw new r.NKeysError(r.NKeysErrorCode.InvalidEncrypted);const R=this.decodePubCurveKey(p);b=b.slice(_.length);const M=b.slice(0,t.curveNonceLen);return b=b.slice(t.curveNonceLen),s.default.box.open(b,M,R,this.seed)}}t.CurveKP=w}(Or)),Or}var jn;function yt(){if(jn)return pe;jn=1;var t=he&&he.__importDefault||function(L){return L&&L.__esModule?L:{default:L}};Object.defineProperty(pe,"__esModule",{value:!0}),pe.NKeysError=pe.NKeysErrorCode=pe.Prefixes=pe.Prefix=void 0,pe.createPair=l,pe.createOperator=m,pe.createAccount=P,pe.createUser=_,pe.createCluster=w,pe.createServer=E,pe.createCurve=b,pe.fromPublic=p,pe.fromCurveSeed=R,pe.fromSeed=M;const e=ei(),r=ti(),s=Zt(),o=ri(),f=t(bt);function l(L){const de=L===U.Curve?o.curveKeyLen:32,le=f.default.randomBytes(de),He=s.Codec.encodeSeed(L,new Uint8Array(le));return L===U.Curve?new o.CurveKP(new Uint8Array(le)):new e.KP(He)}function m(){return l(U.Operator)}function P(){return l(U.Account)}function _(){return l(U.User)}function w(){return l(U.Cluster)}function E(){return l(U.Server)}function b(){return l(U.Curve)}function p(L){const de=new TextEncoder().encode(L),le=s.Codec._decode(de),He=se.parsePrefix(le[0]);if(se.isValidPublicPrefix(He))return new r.PublicKey(de);throw new Fe(ge.InvalidPublicKey)}function R(L){const de=s.Codec.decodeSeed(L);if(de.prefix!==U.Curve)throw new Fe(ge.InvalidCurveSeed);if(de.buf.byteLength!==o.curveKeyLen)throw new Fe(ge.InvalidSeedLen);return new o.CurveKP(de.buf)}function M(L){return s.Codec.decodeSeed(L).prefix===U.Curve?R(L):new e.KP(L)}var U;(function(L){L[L.Unknown=-1]="Unknown",L[L.Seed=144]="Seed",L[L.Private=120]="Private",L[L.Operator=112]="Operator",L[L.Server=104]="Server",L[L.Cluster=16]="Cluster",L[L.Account=0]="Account",L[L.User=160]="User",L[L.Curve=184]="Curve"})(U||(pe.Prefix=U={}));class se{static isValidPublicPrefix(de){return de==U.Server||de==U.Operator||de==U.Cluster||de==U.Account||de==U.User||de==U.Curve}static startsWithValidPrefix(de){const le=de[0];return le=="S"||le=="P"||le=="O"||le=="N"||le=="C"||le=="A"||le=="U"||le=="X"}static isValidPrefix(de){return this.parsePrefix(de)!==U.Unknown}static parsePrefix(de){switch(de){case U.Seed:return U.Seed;case U.Private:return U.Private;case U.Operator:return U.Operator;case U.Server:return U.Server;case U.Cluster:return U.Cluster;case U.Account:return U.Account;case U.User:return U.User;case U.Curve:return U.Curve;default:return U.Unknown}}}pe.Prefixes=se;var ge;(function(L){L.InvalidPrefixByte="nkeys: invalid prefix byte",L.InvalidKey="nkeys: invalid key",L.InvalidPublicKey="nkeys: invalid public key",L.InvalidSeedLen="nkeys: invalid seed length",L.InvalidSeed="nkeys: invalid seed",L.InvalidCurveSeed="nkeys: invalid curve seed",L.InvalidCurveKey="nkeys: not a valid curve key",L.InvalidCurveOperation="nkeys: curve key is not valid for sign/verify",L.InvalidNKeyOperation="keys: only curve key can seal/open",L.InvalidEncoding="nkeys: invalid encoded key",L.InvalidRecipient="nkeys: not a valid recipient public curve key",L.InvalidEncrypted="nkeys: encrypted input is not valid",L.CannotSign="nkeys: cannot sign, no private key available",L.PublicKeyOnly="nkeys: no seed or private key available",L.InvalidChecksum="nkeys: invalid checksum",L.SerializationError="nkeys: serialization error",L.ApiError="nkeys: api error",L.ClearedPair="nkeys: pair is cleared"})(ge||(pe.NKeysErrorCode=ge={}));class Fe extends Error{constructor(le,He){super(le,He);d(this,"code");this.code=le}}return pe.NKeysError=Fe,pe}var Ut={};Object.defineProperty(Ut,"__esModule",{value:!0}),Ut.encode=ni,Ut.decode=si,Ut.dump=ii;function ni(t){return btoa(String.fromCharCode(...t))}function si(t){const e=atob(t),r=new Uint8Array(e.length);for(let s=0;s<e.length;s++)r[s]=e.charCodeAt(s);return r}function ii(t,e){e&&console.log(e);const r=[];for(let s=0;s<t.byteLength;s++){s%8===0&&r.push(`
7
+ `);let o=t[s].toString(16);o.length===1&&(o="0"+o),r.push(o)}console.log(r.join(" "))}var Qt={};Object.defineProperty(Qt,"__esModule",{value:!0}),Qt.version=void 0,Qt.version="2.0.3",function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.version=t.encode=t.decode=t.Prefixes=t.Prefix=t.NKeysErrorCode=t.NKeysError=t.fromSeed=t.fromPublic=t.fromCurveSeed=t.createUser=t.createServer=t.createPair=t.createOperator=t.createCurve=t.createCluster=t.createAccount=void 0;var e=yt();Object.defineProperty(t,"createAccount",{enumerable:!0,get:function(){return e.createAccount}}),Object.defineProperty(t,"createCluster",{enumerable:!0,get:function(){return e.createCluster}}),Object.defineProperty(t,"createCurve",{enumerable:!0,get:function(){return e.createCurve}}),Object.defineProperty(t,"createOperator",{enumerable:!0,get:function(){return e.createOperator}}),Object.defineProperty(t,"createPair",{enumerable:!0,get:function(){return e.createPair}}),Object.defineProperty(t,"createServer",{enumerable:!0,get:function(){return e.createServer}}),Object.defineProperty(t,"createUser",{enumerable:!0,get:function(){return e.createUser}}),Object.defineProperty(t,"fromCurveSeed",{enumerable:!0,get:function(){return e.fromCurveSeed}}),Object.defineProperty(t,"fromPublic",{enumerable:!0,get:function(){return e.fromPublic}}),Object.defineProperty(t,"fromSeed",{enumerable:!0,get:function(){return e.fromSeed}}),Object.defineProperty(t,"NKeysError",{enumerable:!0,get:function(){return e.NKeysError}}),Object.defineProperty(t,"NKeysErrorCode",{enumerable:!0,get:function(){return e.NKeysErrorCode}}),Object.defineProperty(t,"Prefix",{enumerable:!0,get:function(){return e.Prefix}}),Object.defineProperty(t,"Prefixes",{enumerable:!0,get:function(){return e.Prefixes}});var r=Ut;Object.defineProperty(t,"decode",{enumerable:!0,get:function(){return r.decode}}),Object.defineProperty(t,"encode",{enumerable:!0,get:function(){return r.encode}});var s=Qt;Object.defineProperty(t,"version",{enumerable:!0,get:function(){return s.version}})}(En);var oi=he&&he.__createBinding||(Object.create?function(t,e,r,s){s===void 0&&(s=r);var o=Object.getOwnPropertyDescriptor(e,r);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,s,o)}:function(t,e,r,s){s===void 0&&(s=r),t[s]=e[r]}),ai=he&&he.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),ci=he&&he.__importStar||function(){var t=function(e){return t=Object.getOwnPropertyNames||function(r){var s=[];for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(s[s.length]=o);return s},t(e)};return function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var s=t(e),o=0;o<s.length;o++)s[o]!=="default"&&oi(r,e,s[o]);return ai(r,e),r}}();Object.defineProperty(Nt,"__esModule",{value:!0}),Nt.nkeys=void 0,Nt.nkeys=ci(En),Object.defineProperty(De,"__esModule",{value:!0}),De.multiAuthenticator=fi,De.noAuthFn=ui,De.usernamePasswordAuthenticator=hi,De.tokenAuthenticator=di,De.nkeyAuthenticator=Mn,De.jwtAuthenticator=In,De.credsAuthenticator=li;const Nn=Nt,Cr=ke;function fi(t){return e=>{let r={};return t.forEach(s=>{const o=s(e)||{};r=Object.assign(r,o)}),r}}function ui(){return()=>{}}function hi(t,e){return()=>{const r=typeof t=="function"?t():t,s=typeof e=="function"?e():e;return{user:r,pass:s}}}function di(t){return()=>({auth_token:typeof t=="function"?t():t})}function Mn(t){return e=>{const r=typeof t=="function"?t():t,s=r?Nn.nkeys.fromSeed(r):void 0,o=s?s.getPublicKey():"",f=Cr.TE.encode(e||""),l=s!==void 0&&e?s.sign(f):void 0,m=l?Nn.nkeys.encode(l):"";return{nkey:o,sig:m}}}function In(t,e){return r=>{const s=typeof t=="function"?t():t,o=Mn(e),{nkey:f,sig:l}=o(r);return{jwt:s,nkey:f,sig:l}}}function li(t){const e=typeof t!="function"?()=>t:t,r=()=>{const f=/\s*(?:(?:[-]{3,}[^\n]*[-]{3,}\n)(.+)(?:\n\s*[-]{3,}[^\n]*[-]{3,}\n))/ig,l=Cr.TD.decode(e());let m=f.exec(l);if(!m)throw new Error("unable to parse credentials");const P=m[1].trim();if(m=f.exec(l),!m)throw new Error("unable to parse credentials");const _=Cr.TE.encode(m[1].trim());return{jwt:P,seed:_}};return In(()=>{const{jwt:f}=r();return f},()=>{const{seed:f}=r();return f})}(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.DEFAULT_RECONNECT_TIME_WAIT=t.DEFAULT_MAX_PING_OUT=t.DEFAULT_PING_INTERVAL=t.DEFAULT_JITTER_TLS=t.DEFAULT_JITTER=t.DEFAULT_MAX_RECONNECT_ATTEMPTS=void 0,t.defaultOptions=l,t.hasWsProtocol=m,t.buildAuthenticator=P,t.parseOptions=_,t.checkOptions=w,t.checkUnsupportedOption=E;const e=ye,r=rt,s=Oe,o=De,f=te;t.DEFAULT_MAX_RECONNECT_ATTEMPTS=10,t.DEFAULT_JITTER=100,t.DEFAULT_JITTER_TLS=1e3,t.DEFAULT_PING_INTERVAL=2*60*1e3,t.DEFAULT_MAX_PING_OUT=2,t.DEFAULT_RECONNECT_TIME_WAIT=2*1e3;function l(){return{maxPingOut:t.DEFAULT_MAX_PING_OUT,maxReconnectAttempts:t.DEFAULT_MAX_RECONNECT_ATTEMPTS,noRandomize:!1,pedantic:!1,pingInterval:t.DEFAULT_PING_INTERVAL,reconnect:!0,reconnectJitter:t.DEFAULT_JITTER,reconnectJitterTLS:t.DEFAULT_JITTER_TLS,reconnectTimeWait:t.DEFAULT_RECONNECT_TIME_WAIT,tls:void 0,verbose:!1,waitOnFirstConnect:!1,ignoreAuthErrorAbort:!1}}function m(b){if(b){let{servers:p}=b;if(typeof p=="string"&&(p=[p]),p)for(let R=0;R<p.length;R++){const M=p[R].toLowerCase();if(M.startsWith("ws://")||M.startsWith("wss://"))return!0}}return!1}function P(b){const p=[];return typeof b.authenticator=="function"&&p.push(b.authenticator),Array.isArray(b.authenticator)&&p.push(...b.authenticator),b.token&&p.push((0,o.tokenAuthenticator)(b.token)),b.user&&p.push((0,o.usernamePasswordAuthenticator)(b.user,b.pass)),p.length===0?(0,o.noAuthFn)():(0,o.multiAuthenticator)(p)}function _(b){const p=`${s.DEFAULT_HOST}:${(0,r.defaultPort)()}`;if(b=b||{servers:[p]},b.servers=b.servers||[],typeof b.servers=="string"&&(b.servers=[b.servers]),b.servers.length>0&&b.port)throw f.InvalidArgumentError.format(["servers","port"],"are mutually exclusive");b.servers.length===0&&b.port&&(b.servers=[`${s.DEFAULT_HOST}:${b.port}`]),b.servers&&b.servers.length===0&&(b.servers=[p]);const R=(0,e.extend)(l(),b);if(R.authenticator=P(R),["reconnectDelayHandler","authenticator"].forEach(M=>{if(R[M]&&typeof R[M]!="function")throw TypeError(`'${M}' must be a function`)}),R.reconnectDelayHandler||(R.reconnectDelayHandler=()=>{let M=R.tls?R.reconnectJitterTLS:R.reconnectJitter;return M&&(M++,M=Math.floor(Math.random()*M)),R.reconnectTimeWait+M}),R.inboxPrefix&&(0,s.createInbox)(R.inboxPrefix),R.resolve===void 0&&(R.resolve=typeof(0,r.getResolveFn)()=="function"),R.resolve&&typeof(0,r.getResolveFn)()!="function")throw f.InvalidArgumentError.format("resolve","is not supported in the current runtime");return R}function w(b,p){const{proto:R,tls_required:M,tls_available:U}=b;if((R===void 0||R<1)&&p.noEcho)throw new f.errors.ConnectionError("server does not support 'noEcho'");const se=M||U||!1;if(p.tls&&!se)throw new f.errors.ConnectionError("server does not support 'tls'")}function E(b,p){if(p)throw f.InvalidArgumentError.format(b,"is not supported")}})(jt),Object.defineProperty(Me,"__esModule",{value:!0}),Me.ProtocolHandler=Me.Subscriptions=Me.SubscriptionImpl=Me.Connect=Me.INFO=void 0;const Ge=ke,it=rt,ze=ye,bi=nt,yi=Ve,gi=dt,_i=At,mi=Ot,et=pr,vi=Ct,Tn=Xt,jr=jt,Ae=te,pi=1024*32;Me.INFO=/^INFO\s+([^\r\n]+)\r\n/i;const xi=(0,Ge.encode)(`PONG\r
8
+ `),Rn=(0,Ge.encode)(`PING\r
9
+ `);class kn{constructor(e,r,s){d(this,"echo");d(this,"no_responders");d(this,"protocol");d(this,"verbose");d(this,"pedantic");d(this,"jwt");d(this,"nkey");d(this,"sig");d(this,"user");d(this,"pass");d(this,"auth_token");d(this,"tls_required");d(this,"name");d(this,"lang");d(this,"version");d(this,"headers");this.protocol=1,this.version=e.version,this.lang=e.lang,this.echo=r.noEcho?!1:void 0,this.verbose=r.verbose,this.pedantic=r.pedantic,this.tls_required=r.tls?!0:void 0,this.name=r.name;const o=(r&&typeof r.authenticator=="function"?r.authenticator(s):{})||{};(0,ze.extend)(this,o)}}Me.Connect=kn;class wi{constructor(e,r){d(this,"slow");d(this,"cb");d(this,"notified");this.slow=e,this.cb=r,this.notified=!1}maybeNotify(e){e<=this.slow?this.notified=!1:this.notified||(this.cb(e),this.notified=!0)}}class Un extends gi.QueuedIteratorImpl{constructor(r,s,o={}){var l;super();d(this,"sid");d(this,"queue");d(this,"draining");d(this,"max");d(this,"subject");d(this,"drained");d(this,"protocol");d(this,"timer");d(this,"info");d(this,"cleanupFn");d(this,"closed");d(this,"requestSubject");d(this,"slow");(0,ze.extend)(this,o),this.protocol=r,this.subject=s,this.draining=!1,this.noIterator=typeof o.callback=="function",this.closed=(0,ze.deferred)();const f=!((l=r.options)!=null&&l.noAsyncTraces);o.timeout&&(this.timer=(0,ze.timeout)(o.timeout,f),this.timer.then(()=>{this.timer=void 0}).catch(m=>{this.stop(m),this.noIterator&&this.callback(m,{})})),this.noIterator||this.iterClosed.then(m=>{this.closed.resolve(m),this.unsubscribe()})}setSlowNotificationFn(r,s){if(this.slow=void 0,s){if(this.noIterator)throw new Error("callbacks don't support slow notifications");this.slow=new wi(r,s)}}callback(r,s){this.cancelTimeout(),r?this.stop(r):this.push(s),!r&&this.slow&&this.slow.maybeNotify(this.getPending())}close(r){if(!this.isClosed()){this.cancelTimeout();const s=()=>{if(this.stop(),this.cleanupFn)try{this.cleanupFn(this,this.info)}catch{}this.closed.resolve(r)};this.noIterator?s():this.push(s)}}unsubscribe(r){this.protocol.unsubscribe(this,r)}cancelTimeout(){this.timer&&(this.timer.cancel(),this.timer=void 0)}drain(){return this.protocol.isClosed()?Promise.reject(new Ae.errors.ClosedConnectionError):this.isClosed()?Promise.reject(new Ae.errors.InvalidOperationError("subscription is already closed")):(this.drained||(this.draining=!0,this.protocol.unsub(this),this.drained=this.protocol.flush((0,ze.deferred)()).then(()=>{this.protocol.subscriptions.cancel(this)}).catch(()=>{this.protocol.subscriptions.cancel(this)})),this.drained)}isDraining(){return this.draining}isClosed(){return this.done}getSubject(){return this.subject}getMax(){return this.max}getID(){return this.sid}}Me.SubscriptionImpl=Un;class Ln{constructor(){d(this,"mux");d(this,"subs");d(this,"sidCounter");this.sidCounter=0,this.mux=null,this.subs=new Map}size(){return this.subs.size}add(e){return this.sidCounter++,e.sid=this.sidCounter,this.subs.set(e.sid,e),e}setMux(e){return this.mux=e,e}getMux(){return this.mux}get(e){return this.subs.get(e)}resub(e){return this.sidCounter++,this.subs.delete(e.sid),e.sid=this.sidCounter,this.subs.set(e.sid,e),e}all(){return Array.from(this.subs.values())}cancel(e){e&&(e.close(),this.subs.delete(e.sid))}handleError(e){const r=this.all();let s;return e.operation==="subscription"?s=r.find(o=>o.subject===e.subject&&o.queue===e.queue):e.operation==="publish"&&(s=r.find(o=>o.requestSubject===e.subject)),s?(s.callback(e,{}),s.close(e),this.subs.delete(s.sid),s!==this.mux):!1}close(){this.subs.forEach(e=>{e.close()})}}Me.Subscriptions=Ln;class er{constructor(e,r){d(this,"connected");d(this,"connectedOnce");d(this,"infoReceived");d(this,"info");d(this,"muxSubscriptions");d(this,"options");d(this,"outbound");d(this,"pongs");d(this,"subscriptions");d(this,"transport");d(this,"noMorePublishing");d(this,"connectError");d(this,"publisher");d(this,"_closed");d(this,"closed");d(this,"listeners");d(this,"heartbeats");d(this,"parser");d(this,"outMsgs");d(this,"inMsgs");d(this,"outBytes");d(this,"inBytes");d(this,"pendingLimit");d(this,"lastError");d(this,"abortReconnect");d(this,"whyClosed");d(this,"servers");d(this,"server");d(this,"features");d(this,"connectPromise");d(this,"dialDelay");d(this,"raceTimer");this._closed=!1,this.connected=!1,this.connectedOnce=!1,this.infoReceived=!1,this.noMorePublishing=!1,this.abortReconnect=!1,this.listeners=[],this.pendingLimit=pi,this.outMsgs=0,this.inMsgs=0,this.outBytes=0,this.inBytes=0,this.options=e,this.publisher=r,this.subscriptions=new Ln,this.muxSubscriptions=new _i.MuxSubscription,this.outbound=new bi.DataBuffer,this.pongs=[],this.whyClosed="",this.pendingLimit=e.pendingLimit||this.pendingLimit,this.features=new Tn.Features({major:0,minor:0,micro:0}),this.connectPromise=null,this.dialDelay=null;const s=typeof e.servers=="string"?[e.servers]:e.servers;this.servers=new yi.Servers(s,{randomize:!e.noRandomize}),this.closed=(0,ze.deferred)(),this.parser=new et.Parser(this),this.heartbeats=new mi.Heartbeat(this,this.options.pingInterval||jr.DEFAULT_PING_INTERVAL,this.options.maxPingOut||jr.DEFAULT_MAX_PING_OUT)}resetOutbound(){this.outbound.reset();const e=this.pongs;this.pongs=[];const r=new Ae.errors.RequestError("connection disconnected");r.stack="",e.forEach(s=>{s.reject(r)}),this.parser=new et.Parser(this),this.infoReceived=!1}dispatchStatus(e){this.listeners.forEach(r=>{r.push(e)})}prepare(){this.transport&&this.transport.discard(),this.info=void 0,this.resetOutbound();const e=(0,ze.deferred)();return e.catch(()=>{}),this.pongs.unshift(e),this.connectError=r=>{e.reject(r)},this.transport=(0,it.newTransport)(),this.transport.closed().then(async r=>{if(this.connected=!1,!this.isClosed()){await this.disconnected(this.transport.closeError||this.lastError);return}}),e}disconnect(){this.dispatchStatus({type:"staleConnection"}),this.transport.disconnect()}reconnect(){return this.connected&&(this.dispatchStatus({type:"forceReconnect"}),this.transport.disconnect()),Promise.resolve()}async disconnected(e){this.dispatchStatus({type:"disconnect",server:this.servers.getCurrentServer().toString()}),this.options.reconnect?await this.dialLoop().then(()=>{this.dispatchStatus({type:"reconnect",server:this.servers.getCurrentServer().toString()}),this.lastError instanceof Ae.errors.UserAuthenticationExpiredError&&(this.lastError=void 0)}).catch(r=>{this.close(r).catch()}):await this.close(e).catch()}async dial(e){var s,o;const r=this.prepare();try{this.raceTimer=(0,ze.timeout)(this.options.timeout||2e4);const f=this.transport.connect(e,this.options);await Promise.race([f,this.raceTimer]),(async()=>{try{for await(const l of this.transport)this.parser.parse(l)}catch(l){console.log("reader closed",l)}})().then()}catch(f){r.reject(f)}try{await Promise.race([this.raceTimer,r]),(s=this.raceTimer)==null||s.cancel(),this.connected=!0,this.connectError=void 0,this.sendSubscriptions(),this.connectedOnce=!0,this.server.didConnect=!0,this.server.reconnects=0,this.flushPending(),this.heartbeats.start()}catch(f){throw(o=this.raceTimer)==null||o.cancel(),await this.transport.close(f),f}}async _doDial(e){const{resolve:r}=this.options,s=await e.resolve({fn:(0,it.getResolveFn)(),debug:this.options.debug,randomize:!this.options.noRandomize,resolve:r});let o=null;for(const f of s)try{o=null,this.dispatchStatus({type:"reconnecting"}),await this.dial(f);return}catch(l){o=l}throw o}dialLoop(){return this.connectPromise===null&&(this.connectPromise=this.dodialLoop(),this.connectPromise.then(()=>{}).catch(()=>{}).finally(()=>{this.connectPromise=null})),this.connectPromise}async dodialLoop(){let e;for(;;){this._closed&&this.servers.clear();const r=this.options.reconnectDelayHandler?this.options.reconnectDelayHandler():jr.DEFAULT_RECONNECT_TIME_WAIT;let s=r;const o=this.selectServer();if(!o||this.abortReconnect)throw e||(this.lastError?this.lastError:new Ae.errors.ConnectionError("connection refused"));const f=Date.now();if(o.lastConnect===0||o.lastConnect+r<=f){o.lastConnect=Date.now();try{await this._doDial(o);break}catch(l){if(e=l,!this.connectedOnce){if(this.options.waitOnFirstConnect)continue;this.servers.removeCurrentServer()}o.reconnects++;const m=this.options.maxReconnectAttempts||0;m!==-1&&o.reconnects>=m&&this.servers.removeCurrentServer()}}else s=Math.min(s,o.lastConnect+r-f),this.dialDelay=(0,ze.delay)(s),await this.dialDelay}}static async connect(e,r){const s=new er(e,r);return await s.dialLoop(),s}static toError(e){let r=Ae.errors.PermissionViolationError.parse(e);return r||(r=Ae.errors.UserAuthenticationExpiredError.parse(e),r)||(r=Ae.errors.AuthorizationError.parse(e),r)?r:new Ae.errors.ProtocolError(e)}processMsg(e,r){if(this.inMsgs++,this.inBytes+=r.length,!this.subscriptions.sidCounter)return;const s=this.subscriptions.get(e.sid);s&&(s.received+=1,s.callback&&s.callback(null,new vi.MsgImpl(e,r,this)),s.max!==void 0&&s.received>=s.max&&s.unsubscribe())}processError(e){let r=(0,Ge.decode)(e);r.startsWith("'")&&r.endsWith("'")&&(r=r.slice(1,r.length-1));const s=er.toError(r);switch(s.constructor){case Ae.errors.PermissionViolationError:{const o=s,f=this.subscriptions.getMux(),l=f?o.subject===f.subject:!1;this.subscriptions.handleError(o),this.muxSubscriptions.handleError(l,o),l&&this.subscriptions.setMux(null)}}this.dispatchStatus({type:"error",error:s}),this.handleError(s)}handleError(e){(e instanceof Ae.errors.UserAuthenticationExpiredError||e instanceof Ae.errors.AuthorizationError)&&this.handleAuthError(e),e instanceof Ae.errors.PermissionViolationError||(this.lastError=e)}handleAuthError(e){(this.lastError instanceof Ae.errors.UserAuthenticationExpiredError||this.lastError instanceof Ae.errors.AuthorizationError)&&this.options.ignoreAuthErrorAbort===!1&&(this.abortReconnect=!0),this.connectError?this.connectError(e):this.disconnect()}processPing(){this.transport.send(xi)}processPong(){const e=this.pongs.shift();e&&e.resolve()}processInfo(e){const r=JSON.parse((0,Ge.decode)(e));this.info=r;const s=this.options&&this.options.ignoreClusterUpdates?void 0:this.servers.update(r,this.transport.isEncrypted());if(!this.infoReceived){this.features.update((0,Tn.parseSemVer)(r.version)),this.infoReceived=!0,this.transport.isEncrypted()&&this.servers.updateTLSName();const{version:f,lang:l}=this.transport;try{const m=new kn({version:f,lang:l},this.options,r.nonce);r.headers&&(m.headers=!0,m.no_responders=!0);const P=JSON.stringify(m);this.transport.send((0,Ge.encode)(`CONNECT ${P}${it.CR_LF}`)),this.transport.send(Rn)}catch(m){this.close(m).catch()}}if(s){const{added:f,deleted:l}=s;this.dispatchStatus({type:"update",added:f,deleted:l})}(r.ldm!==void 0?r.ldm:!1)&&this.dispatchStatus({type:"ldm",server:this.servers.getCurrentServer().toString()})}push(e){switch(e.kind){case et.Kind.MSG:{const{msg:r,data:s}=e;this.processMsg(r,s);break}case et.Kind.OK:break;case et.Kind.ERR:this.processError(e.data);break;case et.Kind.PING:this.processPing();break;case et.Kind.PONG:this.processPong();break;case et.Kind.INFO:this.processInfo(e.data);break}}sendCommand(e,...r){const s=this.outbound.length();let o;typeof e=="string"?o=(0,Ge.encode)(e):o=e,this.outbound.fill(o,...r),s===0?queueMicrotask(()=>{this.flushPending()}):this.outbound.size()>=this.pendingLimit&&this.flushPending()}publish(e,r=Ge.Empty,s){let o;if(r instanceof Uint8Array)o=r;else if(typeof r=="string")o=Ge.TE.encode(r);else throw new TypeError("payload types can be strings or Uint8Array");let f=o.length;s=s||{},s.reply=s.reply||"";let l=Ge.Empty,m=0;if(s.headers&&(this.info&&!this.info.headers&&Ae.InvalidArgumentError.format("headers","are not available on this server"),l=s.headers.encode(),m=l.length,f=o.length+m),this.info&&f>this.info.max_payload)throw Ae.InvalidArgumentError.format("payload","max_payload size exceeded");this.outBytes+=f,this.outMsgs++;let P;s.headers?(s.reply?P=`HPUB ${e} ${s.reply} ${m} ${f}\r
10
+ `:P=`HPUB ${e} ${m} ${f}\r
11
+ `,this.sendCommand(P,l,o,it.CRLF)):(s.reply?P=`PUB ${e} ${s.reply} ${f}\r
12
+ `:P=`PUB ${e} ${f}\r
13
+ `,this.sendCommand(P,o,it.CRLF))}request(e){return this.initMux(),this.muxSubscriptions.add(e),e}subscribe(e){return this.subscriptions.add(e),this._subunsub(e),e}_sub(e){e.queue?this.sendCommand(`SUB ${e.subject} ${e.queue} ${e.sid}\r
14
+ `):this.sendCommand(`SUB ${e.subject} ${e.sid}\r
15
+ `)}_subunsub(e){return this._sub(e),e.max&&this.unsubscribe(e,e.max),e}unsubscribe(e,r){this.unsub(e,r),(e.max===void 0||e.received>=e.max)&&this.subscriptions.cancel(e)}unsub(e,r){!e||this.isClosed()||(r?this.sendCommand(`UNSUB ${e.sid} ${r}\r
16
+ `):this.sendCommand(`UNSUB ${e.sid}\r
17
+ `),e.max=r)}resub(e,r){!e||this.isClosed()||(this.unsub(e),e.subject=r,this.subscriptions.resub(e),this._sub(e))}flush(e){return e||(e=(0,ze.deferred)()),this.pongs.push(e),this.outbound.fill(Rn),this.flushPending(),e}sendSubscriptions(){const e=[];this.subscriptions.all().forEach(r=>{const s=r;s.queue?e.push(`SUB ${s.subject} ${s.queue} ${s.sid}${it.CR_LF}`):e.push(`SUB ${s.subject} ${s.sid}${it.CR_LF}`)}),e.length&&this.transport.send((0,Ge.encode)(e.join("")))}async close(e){var s,o;if(this._closed)return;this.whyClosed=new Error("close trace").stack||"",this.heartbeats.cancel(),this.connectError&&(this.connectError(e),this.connectError=void 0),this.muxSubscriptions.close(),this.subscriptions.close();const r=[];for(let f=0;f<this.listeners.length;f++){const l=this.listeners[f];l&&(l.push({type:"close"}),l.stop(),r.push(l.iterClosed))}r.length&&await Promise.all(r),this._closed=!0,await this.transport.close(e),(s=this.raceTimer)==null||s.cancel(),(o=this.dialDelay)==null||o.cancel(),this.closed.resolve(e)}isClosed(){return this._closed}async drain(){const e=this.subscriptions.all(),r=[];e.forEach(s=>{r.push(s.drain())});try{await Promise.allSettled(r)}catch{}finally{this.noMorePublishing=!0,await this.flush()}return this.close()}flushPending(){if(!(!this.infoReceived||!this.connected)&&this.outbound.size()){const e=this.outbound.drain();this.transport.send(e)}}initMux(){if(!this.subscriptions.getMux()){const r=this.muxSubscriptions.init(this.options.inboxPrefix),s=new Un(this,`${r}*`);s.callback=this.muxSubscriptions.dispatcher(),this.subscriptions.setMux(s),this.subscribe(s)}}selectServer(){const e=this.servers.selectServer();if(e!==void 0)return this.server=e,this.server}getServer(){return this.server}}Me.ProtocolHandler=er;var Ye={};Object.defineProperty(Ye,"__esModule",{value:!0}),Ye.RequestOne=Ye.RequestMany=Ye.BaseRequest=void 0;const Nr=ye,Ei=Pt,tr=te;class Mr{constructor(e,r,s=!0){d(this,"token");d(this,"received");d(this,"ctx");d(this,"requestSubject");d(this,"mux");this.mux=e,this.requestSubject=r,this.received=0,this.token=Ei.nuid.next(),s&&(this.ctx=new tr.RequestError)}}Ye.BaseRequest=Mr;class Pi extends Mr{constructor(r,s,o={maxWait:1e3}){super(r,s);d(this,"callback");d(this,"done");d(this,"timer");d(this,"max");d(this,"opts");if(this.opts=o,typeof this.opts.callback!="function")throw new TypeError("callback must be a function");this.callback=this.opts.callback,this.max=typeof o.maxMessages=="number"&&o.maxMessages>0?o.maxMessages:-1,this.done=(0,Nr.deferred)(),this.done.then(()=>{this.callback(null,null)}),this.timer=setTimeout(()=>{this.cancel()},o.maxWait)}cancel(r){r&&this.callback(r,null),clearTimeout(this.timer),this.mux.cancel(this),this.done.resolve()}resolver(r,s){r?(this.ctx&&(r.stack+=`
18
+
19
+ ${this.ctx.stack}`),this.cancel(r)):(this.callback(null,s),this.opts.strategy==="count"&&(this.max--,this.max===0&&this.cancel()),this.opts.strategy==="stall"&&(clearTimeout(this.timer),this.timer=setTimeout(()=>{this.cancel()},this.opts.stall||300)),this.opts.strategy==="sentinel"&&s&&s.data.length===0&&this.cancel())}}Ye.RequestMany=Pi;class Si extends Mr{constructor(r,s,o={timeout:1e3},f=!0){super(r,s,f);d(this,"deferred");d(this,"timer");this.deferred=(0,Nr.deferred)(),this.timer=(0,Nr.timeout)(o.timeout,f)}resolver(r,s){this.timer&&this.timer.cancel(),r?(r instanceof tr.TimeoutError||(this.ctx?(this.ctx.message=r.message,this.ctx.cause=r,r=this.ctx):r=new tr.errors.RequestError(r.message,{cause:r})),this.deferred.reject(r)):this.deferred.resolve(s),this.cancel()}cancel(r){this.timer&&this.timer.cancel(),this.mux.cancel(this),this.deferred.reject(r||new tr.RequestError("cancelled"))}}Ye.RequestOne=Si,Object.defineProperty(Et,"__esModule",{value:!0}),Et.NatsConnectionImpl=void 0;const Ai=ye,Fn=Me,Oi=ke,Bn=Qe,Ci=Xt,ji=jt,Kn=dt,$n=Ye,qn=Oe,we=te;class Ir{constructor(e){d(this,"options");d(this,"protocol");d(this,"draining");d(this,"closeListeners");this.draining=!1,this.options=(0,ji.parseOptions)(e)}static connect(e={}){return new Promise((r,s)=>{const o=new Ir(e);Fn.ProtocolHandler.connect(o.options,o).then(f=>{o.protocol=f,r(o)}).catch(f=>{s(f)})})}closed(){return this.protocol.closed}async close(){await this.protocol.close()}_check(e,r,s){if(this.isClosed())throw new we.errors.ClosedConnectionError;if(r&&this.isDraining())throw new we.errors.DrainingConnectionError;if(s&&this.protocol.noMorePublishing)throw new we.errors.DrainingConnectionError;if(e=e||"",e.length===0)throw new we.errors.InvalidSubjectError(e)}publish(e,r,s){if(this._check(e,!1,!0),s!=null&&s.reply&&this._check(s.reply,!1,!0),typeof(s==null?void 0:s.traceOnly)=="boolean"){const o=s.headers||(0,Bn.headers)();o.set("Nats-Trace-Only","true"),s.headers=o}if(typeof(s==null?void 0:s.traceDestination)=="string"){const o=s.headers||(0,Bn.headers)();o.set("Nats-Trace-Dest",s.traceDestination),s.headers=o}this.protocol.publish(e,r,s)}publishMessage(e){return this.publish(e.subject,e.data,{reply:e.reply,headers:e.headers})}respondMessage(e){return e.reply?(this.publish(e.reply,e.data,{reply:e.reply,headers:e.headers}),!0):!1}subscribe(e,r={}){this._check(e,!0,!1);const s=new Fn.SubscriptionImpl(this.protocol,e,r);return typeof r.callback!="function"&&typeof r.slow=="number"&&s.setSlowNotificationFn(r.slow,o=>{this.protocol.dispatchStatus({type:"slowConsumer",sub:s,pending:o})}),this.protocol.subscribe(s),s}_resub(e,r,s){this._check(r,!0,!1);const o=e;o.max=s,s&&(o.max=s+o.received),this.protocol.resub(o,r)}requestMany(e,r=Oi.Empty,s={maxWait:1e3,maxMessages:-1}){const o=!this.protocol.options.noAsyncTraces;try{this._check(e,!0,!0)}catch(P){return Promise.reject(P)}if(s.strategy=s.strategy||"timer",s.maxWait=s.maxWait||1e3,s.maxWait<1)return Promise.reject(we.InvalidArgumentError.format("timeout","must be greater than 0"));const f=new Kn.QueuedIteratorImpl;function l(P){f.push(()=>{f.stop(P)})}function m(P,_){P||_===null?l(P===null?void 0:P):f.push(_)}if(s.noMux){const P=o?new Error().stack:null;let _=typeof s.maxMessages=="number"&&s.maxMessages>0?s.maxMessages:-1;const w=this.subscribe((0,qn.createInbox)(this.options.inboxPrefix),{callback:(se,ge)=>{var Fe,L;if(((Fe=ge==null?void 0:ge.data)==null?void 0:Fe.length)===0&&((L=ge==null?void 0:ge.headers)==null?void 0:L.status)==="503"&&(se=new we.errors.NoRespondersError(e)),se){P&&(se.stack+=`
20
+
21
+ ${P}`),E(se);return}m(null,ge),s.strategy==="count"&&(_--,_===0&&E()),s.strategy==="stall"&&(U(),M=setTimeout(()=>{E()},300)),s.strategy==="sentinel"&&ge&&ge.data.length===0&&E()}});w.requestSubject=e,w.closed.then(()=>{l()}).catch(se=>{f.stop(se)});const E=se=>{se&&f.push(()=>{throw se}),U(),w.drain().then(()=>{l()}).catch(ge=>{l()})};f.iterClosed.then(()=>{U(),w==null||w.unsubscribe()}).catch(se=>{U(),w==null||w.unsubscribe()});const{headers:b,traceDestination:p,traceOnly:R}=s;try{this.publish(e,r,{reply:w.getSubject(),headers:b,traceDestination:p,traceOnly:R})}catch(se){E(se)}let M=setTimeout(()=>{E()},s.maxWait);const U=()=>{M&&clearTimeout(M)}}else{const P=s;P.callback=m,f.iterClosed.then(()=>{_.cancel()}).catch(p=>{_.cancel(p)});const _=new $n.RequestMany(this.protocol.muxSubscriptions,e,P);this.protocol.request(_);const{headers:w,traceDestination:E,traceOnly:b}=s;try{this.publish(e,r,{reply:`${this.protocol.muxSubscriptions.baseInbox}${_.token}`,headers:w,traceDestination:E,traceOnly:b})}catch(p){_.cancel(p)}}return Promise.resolve(f)}request(e,r,s={timeout:1e3,noMux:!1}){try{this._check(e,!0,!0)}catch(f){return Promise.reject(f)}const o=!this.protocol.options.noAsyncTraces;if(s.timeout=s.timeout||1e3,s.timeout<1)return Promise.reject(we.InvalidArgumentError.format("timeout","must be greater than 0"));if(!s.noMux&&s.reply)return Promise.reject(we.InvalidArgumentError.format(["reply","noMux"],"are mutually exclusive"));if(s.noMux){const f=s.reply?s.reply:(0,qn.createInbox)(this.options.inboxPrefix),l=(0,Ai.deferred)(),m=o?new we.errors.RequestError(""):null,P=this.subscribe(f,{max:1,timeout:s.timeout,callback:(_,w)=>{var E,b;w&&((E=w.data)==null?void 0:E.length)===0&&((b=w.headers)==null?void 0:b.code)===503&&(_=new we.errors.NoRespondersError(e)),_?(_ instanceof we.TimeoutError||(m?(m.message=_.message,m.cause=_,_=m):_=new we.errors.RequestError(_.message,{cause:_})),l.reject(_),P.unsubscribe()):l.resolve(w)}});return P.requestSubject=e,this.protocol.publish(e,r,{reply:f,headers:s.headers}),l}else{const f=new $n.RequestOne(this.protocol.muxSubscriptions,e,s,o);this.protocol.request(f);const{headers:l,traceDestination:m,traceOnly:P}=s;try{this.publish(e,r,{reply:`${this.protocol.muxSubscriptions.baseInbox}${f.token}`,headers:l,traceDestination:m,traceOnly:P})}catch(w){f.cancel(w)}const _=Promise.race([f.timer,f.deferred]);return _.catch(()=>{f.cancel()}),_}}flush(){return this.isClosed()?Promise.reject(new we.errors.ClosedConnectionError):this.protocol.flush()}drain(){return this.isClosed()?Promise.reject(new we.errors.ClosedConnectionError):this.isDraining()?Promise.reject(new we.errors.DrainingConnectionError):(this.draining=!0,this.protocol.drain())}isClosed(){return this.protocol.isClosed()}isDraining(){return this.draining}getServer(){const e=this.protocol.getServer();return e?e.listen:""}status(){const e=new Kn.QueuedIteratorImpl;return e.iterClosed.then(()=>{const r=this.protocol.listeners.indexOf(e);r>-1&&this.protocol.listeners.splice(r,1)}),this.protocol.listeners.push(e),e}get info(){return this.protocol.isClosed()?void 0:this.protocol.info}async context(){return(await this.request("$SYS.REQ.USER.INFO")).json((r,s)=>r==="time"?new Date(Date.parse(s)):s)}stats(){return{inBytes:this.protocol.inBytes,outBytes:this.protocol.outBytes,inMsgs:this.protocol.inMsgs,outMsgs:this.protocol.outMsgs}}getServerVersion(){const e=this.info;return e?(0,Ci.parseSemVer)(e.version):void 0}async rtt(){if(this.isClosed())throw new we.errors.ClosedConnectionError;if(!this.protocol.connected)throw new we.errors.RequestError("connection disconnected");const e=Date.now();return await this.flush(),Date.now()-e}get features(){return this.protocol.features}reconnect(){return this.isClosed()?Promise.reject(new we.errors.ClosedConnectionError):this.isDraining()?Promise.reject(new we.errors.DrainingConnectionError):this.protocol.reconnect()}addCloseListener(e){this.closeListeners===void 0&&(this.closeListeners=new Ni(this.closed())),this.closeListeners.add(e)}removeCloseListener(e){this.closeListeners&&this.closeListeners.remove(e)}}Et.NatsConnectionImpl=Ir;class Ni{constructor(e){d(this,"listeners");this.listeners=[],e.then(r=>{this.notify(r)})}add(e){this.listeners.push(e)}remove(e){this.listeners=this.listeners.filter(r=>r!==e)}notify(e){this.listeners.forEach(r=>{if(typeof r.connectionClosedCallback=="function")try{r.connectionClosedCallback(e)}catch{}}),this.listeners=[]}}var We={},Tr={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Empty=void 0;var e=ke;Object.defineProperty(t,"Empty",{enumerable:!0,get:function(){return e.Empty}})})(Tr),Object.defineProperty(We,"__esModule",{value:!0}),We.Bench=We.Metric=void 0,We.throughput=Dn,We.msgThroughput=Ri,We.humanizeBytes=Gn;const Mi=Tr,Ii=Pt,Rr=ye;class ot{constructor(e,r){d(this,"name");d(this,"duration");d(this,"date");d(this,"payload");d(this,"msgs");d(this,"lang");d(this,"version");d(this,"bytes");d(this,"asyncRequests");d(this,"min");d(this,"max");this.name=e,this.duration=r,this.date=Date.now(),this.payload=0,this.msgs=0,this.bytes=0}toString(){const e=this.duration/1e3,r=Math.round(this.msgs/e),s=this.asyncRequests?"asyncRequests":"";let o="";return this.max&&(o=`${this.min}/${this.max}`),`${this.name}${s?" [asyncRequests]":""} ${ki(r)} msgs/sec - [${e.toFixed(2)} secs] ~ ${Dn(this.bytes,e)} ${o}`}toCsv(){return`"${this.name}",${new Date(this.date).toISOString()},${this.lang},${this.version},${this.msgs},${this.payload},${this.bytes},${this.duration},${this.asyncRequests?this.asyncRequests:!1}
22
+ `}static header(){return`Test,Date,Lang,Version,Count,MsgPayload,Bytes,Millis,Async
23
+ `}}We.Metric=ot;class Ti{constructor(e,r={msgs:1e5,size:128,subject:"",asyncRequests:!1,pub:!1,sub:!1,req:!1,rep:!1}){d(this,"nc");d(this,"callbacks");d(this,"msgs");d(this,"size");d(this,"subject");d(this,"asyncRequests");d(this,"pub");d(this,"sub");d(this,"req");d(this,"rep");d(this,"perf");d(this,"payload");if(this.nc=e,this.callbacks=r.callbacks||!1,this.msgs=r.msgs||0,this.size=r.size||0,this.subject=r.subject||Ii.nuid.next(),this.asyncRequests=r.asyncRequests||!1,this.pub=r.pub||!1,this.sub=r.sub||!1,this.req=r.req||!1,this.rep=r.rep||!1,this.perf=new Rr.Perf,this.payload=this.size?new Uint8Array(this.size):Mi.Empty,!this.pub&&!this.sub&&!this.req&&!this.rep)throw new Error("no options selected")}async run(){return this.nc.closed().then(e=>{if(e)throw e}),this.callbacks?await this.runCallbacks():await this.runAsync(),this.processMetrics()}processMetrics(){const e=this.nc,{lang:r,version:s}=e.protocol.transport;this.pub&&this.sub&&this.perf.measure("pubsub","pubStart","subStop"),this.req&&this.rep&&this.perf.measure("reqrep","reqStart","reqStop");const o=this.perf.getEntries(),f=o.find(p=>p.name==="pubsub"),l=o.find(p=>p.name==="reqrep"),m=o.find(p=>p.name==="req"),P=o.find(p=>p.name==="rep"),_=o.find(p=>p.name==="pub"),w=o.find(p=>p.name==="sub"),E=this.nc.stats(),b=[];if(f){const{name:p,duration:R}=f,M=new ot(p,R);M.msgs=this.msgs*2,M.bytes=E.inBytes+E.outBytes,M.lang=r,M.version=s,M.payload=this.payload.length,b.push(M)}if(l){const{name:p,duration:R}=l,M=new ot(p,R);M.msgs=this.msgs*2,M.bytes=E.inBytes+E.outBytes,M.lang=r,M.version=s,M.payload=this.payload.length,b.push(M)}if(_){const{name:p,duration:R}=_,M=new ot(p,R);M.msgs=this.msgs,M.bytes=E.outBytes,M.lang=r,M.version=s,M.payload=this.payload.length,b.push(M)}if(w){const{name:p,duration:R}=w,M=new ot(p,R);M.msgs=this.msgs,M.bytes=E.inBytes,M.lang=r,M.version=s,M.payload=this.payload.length,b.push(M)}if(P){const{name:p,duration:R}=P,M=new ot(p,R);M.msgs=this.msgs,M.bytes=E.inBytes+E.outBytes,M.lang=r,M.version=s,M.payload=this.payload.length,b.push(M)}if(m){const{name:p,duration:R}=m,M=new ot(p,R);M.msgs=this.msgs,M.bytes=E.inBytes+E.outBytes,M.lang=r,M.version=s,M.payload=this.payload.length,b.push(M)}return b}async runCallbacks(){const e=[];if(this.sub){const r=(0,Rr.deferred)();e.push(r);let s=0;this.nc.subscribe(this.subject,{max:this.msgs,callback:()=>{s++,s===1&&this.perf.mark("subStart"),s===this.msgs&&(this.perf.mark("subStop"),this.perf.measure("sub","subStart","subStop"),r.resolve())}})}if(this.rep){const r=(0,Rr.deferred)();e.push(r);let s=0;this.nc.subscribe(this.subject,{max:this.msgs,callback:(o,f)=>{f.respond(this.payload),s++,s===1&&this.perf.mark("repStart"),s===this.msgs&&(this.perf.mark("repStop"),this.perf.measure("rep","repStart","repStop"),r.resolve())}})}if(this.pub){const r=(async()=>{this.perf.mark("pubStart");for(let s=0;s<this.msgs;s++)this.nc.publish(this.subject,this.payload);await this.nc.flush(),this.perf.mark("pubStop"),this.perf.measure("pub","pubStart","pubStop")})();e.push(r)}if(this.req){const r=(async()=>{if(this.asyncRequests){this.perf.mark("reqStart");const s=[];for(let o=0;o<this.msgs;o++)s.push(this.nc.request(this.subject,this.payload,{timeout:2e4}));await Promise.all(s),this.perf.mark("reqStop"),this.perf.measure("req","reqStart","reqStop")}else{this.perf.mark("reqStart");for(let s=0;s<this.msgs;s++)await this.nc.request(this.subject);this.perf.mark("reqStop"),this.perf.measure("req","reqStart","reqStop")}})();e.push(r)}await Promise.all(e)}async runAsync(){const e=[];if(this.rep){let r=!1;const s=this.nc.subscribe(this.subject,{max:this.msgs}),o=(async()=>{for await(const f of s)r||(this.perf.mark("repStart"),r=!0),f.respond(this.payload);await this.nc.flush(),this.perf.mark("repStop"),this.perf.measure("rep","repStart","repStop")})();e.push(o)}if(this.sub){let r=!1;const s=this.nc.subscribe(this.subject,{max:this.msgs}),o=(async()=>{for await(const f of s)r||(this.perf.mark("subStart"),r=!0);this.perf.mark("subStop"),this.perf.measure("sub","subStart","subStop")})();e.push(o)}if(this.pub){const r=(async()=>{this.perf.mark("pubStart");for(let s=0;s<this.msgs;s++)this.nc.publish(this.subject,this.payload);await this.nc.flush(),this.perf.mark("pubStop"),this.perf.measure("pub","pubStart","pubStop")})();e.push(r)}if(this.req){const r=(async()=>{if(this.asyncRequests){this.perf.mark("reqStart");const s=[];for(let o=0;o<this.msgs;o++)s.push(this.nc.request(this.subject,this.payload,{timeout:2e4}));await Promise.all(s),this.perf.mark("reqStop"),this.perf.measure("req","reqStart","reqStop")}else{this.perf.mark("reqStart");for(let s=0;s<this.msgs;s++)await this.nc.request(this.subject);this.perf.mark("reqStop"),this.perf.measure("req","reqStart","reqStop")}})();e.push(r)}await Promise.all(e)}}We.Bench=Ti;function Dn(t,e){return`${Gn(t/e)}/sec`}function Ri(t,e){return`${Math.floor(t/e)} msgs/sec`}function Gn(t,e=!1){const r=e?1e3:1024,s=e?["k","M","G","T","P","E"]:["K","M","G","T","P","E"],o=e?"iB":"B";if(t<r)return`${t.toFixed(2)} ${o}`;const f=parseInt(Math.log(t)/Math.log(r)+""),l=parseInt(f-1+"");return`${(t/Math.pow(r,f)).toFixed(2)} ${s[l]}${o}`}function ki(t){return t.toString().replace(/\B(?=(\d{3})+(?!\d))/g,",")}var rr={};Object.defineProperty(rr,"__esModule",{value:!0}),rr.IdleHeartbeatMonitor=void 0;class Ui{constructor(e,r,s={maxOut:2}){d(this,"interval");d(this,"maxOut");d(this,"cancelAfter");d(this,"timer");d(this,"autoCancelTimer");d(this,"last");d(this,"missed");d(this,"count");d(this,"callback");this.interval=e,this.maxOut=(s==null?void 0:s.maxOut)||2,this.cancelAfter=(s==null?void 0:s.cancelAfter)||0,this.last=Date.now(),this.missed=0,this.count=0,this.callback=r,this._schedule()}cancel(){this.autoCancelTimer&&clearTimeout(this.autoCancelTimer),this.timer&&clearInterval(this.timer),this.timer=0,this.autoCancelTimer=0,this.missed=0}work(){this.last=Date.now(),this.missed=0}_change(e,r=0,s=2){this.interval=e,this.maxOut=s,this.cancelAfter=r,this.restart()}restart(){this.cancel(),this._schedule()}_schedule(){this.cancelAfter>0&&(this.autoCancelTimer=setTimeout(()=>{this.cancel()},this.cancelAfter)),this.timer=setInterval(()=>{if(this.count++,Date.now()-this.last>this.interval&&this.missed++,this.missed>=this.maxOut)try{this.callback(this.missed)===!0&&this.cancel()}catch(e){console.log(e)}},this.interval)}}rr.IdleHeartbeatMonitor=Ui;var gt={},nr={};Object.defineProperty(nr,"__esModule",{value:!0}),nr.version=void 0,nr.version="3.2.0",Object.defineProperty(gt,"__esModule",{value:!0}),gt.WsTransport=void 0,gt.wsUrlParseFn=Vn,gt.wsconnect=Gi;const Xe=ye,zn=rt,Li=jt,Fi=nt,Bi=Me,Ki=Et,$i=nr,Hn=te,qi=$i.version,Di="nats.ws";class Jn{constructor(){d(this,"version");d(this,"lang");d(this,"closeError");d(this,"connected");d(this,"done");d(this,"socket");d(this,"options");d(this,"socketClosed");d(this,"encrypted");d(this,"peeked");d(this,"yields");d(this,"signal");d(this,"closedNotification");this.version=qi,this.lang=Di,this.connected=!1,this.done=!1,this.socketClosed=!1,this.encrypted=!1,this.peeked=!1,this.yields=[],this.signal=(0,Xe.deferred)(),this.closedNotification=(0,Xe.deferred)()}async connect(e,r){const s=(0,Xe.deferred)();this.options=r;const o=e.src;if(r.wsFactory){const{socket:f,encrypted:l}=await r.wsFactory(e.src,r);this.socket=f,this.encrypted=l}else this.encrypted=o.indexOf("wss://")===0,this.socket=new WebSocket(o);return this.socket.binaryType="arraybuffer",this.socket.onopen=()=>{this.done&&this._closed(new Error("aborted"))},this.socket.onmessage=f=>{if(this.done)return;if(this.yields.push(new Uint8Array(f.data)),this.peeked){this.signal.resolve();return}const l=Fi.DataBuffer.concat(...this.yields),m=(0,zn.extractProtocolMessage)(l);if(m!==""){const P=Bi.INFO.exec(m);if(!P){r.debug&&console.error("!!!",(0,Xe.render)(l)),s.reject(new Error("unexpected response from server"));return}try{const _=JSON.parse(P[1]);(0,Li.checkOptions)(_,this.options),this.peeked=!0,this.connected=!0,this.signal.resolve(),s.resolve()}catch(_){s.reject(_);return}}},this.socket.onclose=f=>{let l;!f.wasClean&&f.reason!==""&&(l=new Error(f.reason)),this._closed(l),this._cleanup()},this.socket.onerror=f=>{if(this.done)return;const l=f,m=new Hn.errors.ConnectionError(l.message);s.reject(m),this._cleanup()},s}_cleanup(){this.socketClosed===!1&&(this.socketClosed=!0,this.socket.onopen=null,this.socket.onmessage=null,this.socket.onerror=null,this.socket.onclose=null,this.closedNotification.resolve(this.closeError))}disconnect(){this._closed(void 0,!0)}async _closed(e,r=!0){if(this.done){try{this.socket.close()}catch{}return}if(this.closeError=e,!e)for(;!this.socketClosed&&this.socket.bufferedAmount>0;)await(0,Xe.delay)(100);this.done=!0;try{this.socket.close()}catch{}return this.closedNotification}get isClosed(){return this.done}[Symbol.asyncIterator](){return this.iterate()}async*iterate(){for(;;){if(this.done)return;this.yields.length===0&&await this.signal;const e=this.yields;this.yields=[];for(let r=0;r<e.length;r++)this.options.debug&&console.info(`> ${(0,Xe.render)(e[r])}`),yield e[r];if(this.done)break;this.yields.length===0&&(e.length=0,this.yields=e,this.signal=(0,Xe.deferred)())}}isEncrypted(){return this.connected&&this.encrypted}send(e){if(!this.done)try{this.socket.send(e.buffer),this.options.debug&&console.info(`< ${(0,Xe.render)(e)}`);return}catch(r){this.options.debug&&console.error(`!!! ${(0,Xe.render)(e)}: ${r}`)}}close(e){return this._closed(e,!1)}closed(){return this.closedNotification}discard(){var e;(e=this.socket)==null||e.close()}}gt.WsTransport=Jn;function Vn(t,e){/^(.*:\/\/)(.*)/.test(t)||(typeof e=="boolean"?t=`${e===!0?"https":"http"}://${t}`:t=`https://${t}`);let s=new URL(t);const o=s.protocol.toLowerCase();o==="ws:"&&(e=!1),o==="wss:"&&(e=!0),o!=="https:"&&o!=="http"&&(t=t.replace(/^(.*:\/\/)(.*)/gm,"$2"),s=new URL(`http://${t}`));let f,l;const m=s.hostname,P=s.pathname,_=s.search||"";switch(o){case"http:":case"ws:":case"nats:":l=s.port||"80",f="ws:";break;case"https:":case"wss:":case"tls:":l=s.port||"443",f="wss:";break;default:l=s.port||e===!0?"443":"80",f=e===!0?"wss:":"ws:";break}return`${f}//${m}:${l}${P}${_}`}function Gi(t={}){return(0,zn.setTransportFactory)({defaultPort:443,urlParseFn:Vn,factory:()=>{if(t.tls)throw Hn.InvalidArgumentError.format("tls","is not configurable on w3c websocket connections");return new Jn}}),Ki.NatsConnectionImpl.connect(t)}(function(t){var e=he&&he.__createBinding||(Object.create?function(Je,Se,Te,Re){Re===void 0&&(Re=Te);var Ue=Object.getOwnPropertyDescriptor(Se,Te);(!Ue||("get"in Ue?!Se.__esModule:Ue.writable||Ue.configurable))&&(Ue={enumerable:!0,get:function(){return Se[Te]}}),Object.defineProperty(Je,Re,Ue)}:function(Je,Se,Te,Re){Re===void 0&&(Re=Te),Je[Re]=Se[Te]}),r=he&&he.__exportStar||function(Je,Se){for(var Te in Je)Te!=="default"&&!Object.prototype.hasOwnProperty.call(Se,Te)&&e(Se,Je,Te)};Object.defineProperty(t,"__esModule",{value:!0}),t.TD=t.Metric=t.Bench=t.writeAll=t.readAll=t.MAX_SIZE=t.DenoBuffer=t.State=t.Parser=t.Kind=t.QueuedIteratorImpl=t.usernamePasswordAuthenticator=t.tokenAuthenticator=t.nkeyAuthenticator=t.jwtAuthenticator=t.credsAuthenticator=t.RequestOne=t.parseOptions=t.hasWsProtocol=t.defaultOptions=t.DEFAULT_MAX_RECONNECT_ATTEMPTS=t.checkUnsupportedOption=t.checkOptions=t.buildAuthenticator=t.DataBuffer=t.MuxSubscription=t.Heartbeat=t.MsgHdrsImpl=t.headers=t.canonicalMIMEHeaderKey=t.timeout=t.SimpleMutex=t.render=t.nanos=t.millis=t.extend=t.delay=t.deferred=t.deadline=t.collect=t.backoff=t.ProtocolHandler=t.INFO=t.Connect=t.setTransportFactory=t.getResolveFn=t.MsgImpl=t.nuid=t.Nuid=t.NatsConnectionImpl=void 0,t.UserAuthenticationExpiredError=t.TimeoutError=t.RequestError=t.ProtocolError=t.PermissionViolationError=t.NoRespondersError=t.InvalidSubjectError=t.InvalidOperationError=t.InvalidArgumentError=t.errors=t.DrainingConnectionError=t.ConnectionError=t.ClosedConnectionError=t.AuthorizationError=t.wsUrlParseFn=t.wsconnect=t.Servers=t.isIPV4OrHostname=t.IdleHeartbeatMonitor=t.Subscriptions=t.SubscriptionImpl=t.syncIterator=t.Match=t.createInbox=t.protoLen=t.extractProtocolMessage=t.Empty=t.parseSemVer=t.Features=t.Feature=t.compare=t.parseIP=t.isIP=t.ipV4=t.TE=void 0;var s=Et;Object.defineProperty(t,"NatsConnectionImpl",{enumerable:!0,get:function(){return s.NatsConnectionImpl}});var o=Pt;Object.defineProperty(t,"Nuid",{enumerable:!0,get:function(){return o.Nuid}}),Object.defineProperty(t,"nuid",{enumerable:!0,get:function(){return o.nuid}});var f=Ct;Object.defineProperty(t,"MsgImpl",{enumerable:!0,get:function(){return f.MsgImpl}});var l=rt;Object.defineProperty(t,"getResolveFn",{enumerable:!0,get:function(){return l.getResolveFn}}),Object.defineProperty(t,"setTransportFactory",{enumerable:!0,get:function(){return l.setTransportFactory}});var m=Me;Object.defineProperty(t,"Connect",{enumerable:!0,get:function(){return m.Connect}}),Object.defineProperty(t,"INFO",{enumerable:!0,get:function(){return m.INFO}}),Object.defineProperty(t,"ProtocolHandler",{enumerable:!0,get:function(){return m.ProtocolHandler}});var P=ye;Object.defineProperty(t,"backoff",{enumerable:!0,get:function(){return P.backoff}}),Object.defineProperty(t,"collect",{enumerable:!0,get:function(){return P.collect}}),Object.defineProperty(t,"deadline",{enumerable:!0,get:function(){return P.deadline}}),Object.defineProperty(t,"deferred",{enumerable:!0,get:function(){return P.deferred}}),Object.defineProperty(t,"delay",{enumerable:!0,get:function(){return P.delay}}),Object.defineProperty(t,"extend",{enumerable:!0,get:function(){return P.extend}}),Object.defineProperty(t,"millis",{enumerable:!0,get:function(){return P.millis}}),Object.defineProperty(t,"nanos",{enumerable:!0,get:function(){return P.nanos}}),Object.defineProperty(t,"render",{enumerable:!0,get:function(){return P.render}}),Object.defineProperty(t,"SimpleMutex",{enumerable:!0,get:function(){return P.SimpleMutex}}),Object.defineProperty(t,"timeout",{enumerable:!0,get:function(){return P.timeout}});var _=Qe;Object.defineProperty(t,"canonicalMIMEHeaderKey",{enumerable:!0,get:function(){return _.canonicalMIMEHeaderKey}}),Object.defineProperty(t,"headers",{enumerable:!0,get:function(){return _.headers}}),Object.defineProperty(t,"MsgHdrsImpl",{enumerable:!0,get:function(){return _.MsgHdrsImpl}});var w=Ot;Object.defineProperty(t,"Heartbeat",{enumerable:!0,get:function(){return w.Heartbeat}});var E=At;Object.defineProperty(t,"MuxSubscription",{enumerable:!0,get:function(){return E.MuxSubscription}});var b=nt;Object.defineProperty(t,"DataBuffer",{enumerable:!0,get:function(){return b.DataBuffer}});var p=jt;Object.defineProperty(t,"buildAuthenticator",{enumerable:!0,get:function(){return p.buildAuthenticator}}),Object.defineProperty(t,"checkOptions",{enumerable:!0,get:function(){return p.checkOptions}}),Object.defineProperty(t,"checkUnsupportedOption",{enumerable:!0,get:function(){return p.checkUnsupportedOption}}),Object.defineProperty(t,"DEFAULT_MAX_RECONNECT_ATTEMPTS",{enumerable:!0,get:function(){return p.DEFAULT_MAX_RECONNECT_ATTEMPTS}}),Object.defineProperty(t,"defaultOptions",{enumerable:!0,get:function(){return p.defaultOptions}}),Object.defineProperty(t,"hasWsProtocol",{enumerable:!0,get:function(){return p.hasWsProtocol}}),Object.defineProperty(t,"parseOptions",{enumerable:!0,get:function(){return p.parseOptions}});var R=Ye;Object.defineProperty(t,"RequestOne",{enumerable:!0,get:function(){return R.RequestOne}});var M=De;Object.defineProperty(t,"credsAuthenticator",{enumerable:!0,get:function(){return M.credsAuthenticator}}),Object.defineProperty(t,"jwtAuthenticator",{enumerable:!0,get:function(){return M.jwtAuthenticator}}),Object.defineProperty(t,"nkeyAuthenticator",{enumerable:!0,get:function(){return M.nkeyAuthenticator}}),Object.defineProperty(t,"tokenAuthenticator",{enumerable:!0,get:function(){return M.tokenAuthenticator}}),Object.defineProperty(t,"usernamePasswordAuthenticator",{enumerable:!0,get:function(){return M.usernamePasswordAuthenticator}}),r(Nt,t);var U=dt;Object.defineProperty(t,"QueuedIteratorImpl",{enumerable:!0,get:function(){return U.QueuedIteratorImpl}});var se=pr;Object.defineProperty(t,"Kind",{enumerable:!0,get:function(){return se.Kind}}),Object.defineProperty(t,"Parser",{enumerable:!0,get:function(){return se.Parser}}),Object.defineProperty(t,"State",{enumerable:!0,get:function(){return se.State}});var ge=xr;Object.defineProperty(t,"DenoBuffer",{enumerable:!0,get:function(){return ge.DenoBuffer}}),Object.defineProperty(t,"MAX_SIZE",{enumerable:!0,get:function(){return ge.MAX_SIZE}}),Object.defineProperty(t,"readAll",{enumerable:!0,get:function(){return ge.readAll}}),Object.defineProperty(t,"writeAll",{enumerable:!0,get:function(){return ge.writeAll}});var Fe=We;Object.defineProperty(t,"Bench",{enumerable:!0,get:function(){return Fe.Bench}}),Object.defineProperty(t,"Metric",{enumerable:!0,get:function(){return Fe.Metric}});var L=ke;Object.defineProperty(t,"TD",{enumerable:!0,get:function(){return L.TD}}),Object.defineProperty(t,"TE",{enumerable:!0,get:function(){return L.TE}});var de=ut;Object.defineProperty(t,"ipV4",{enumerable:!0,get:function(){return de.ipV4}}),Object.defineProperty(t,"isIP",{enumerable:!0,get:function(){return de.isIP}}),Object.defineProperty(t,"parseIP",{enumerable:!0,get:function(){return de.parseIP}});var le=Xt;Object.defineProperty(t,"compare",{enumerable:!0,get:function(){return le.compare}}),Object.defineProperty(t,"Feature",{enumerable:!0,get:function(){return le.Feature}}),Object.defineProperty(t,"Features",{enumerable:!0,get:function(){return le.Features}}),Object.defineProperty(t,"parseSemVer",{enumerable:!0,get:function(){return le.parseSemVer}});var He=Tr;Object.defineProperty(t,"Empty",{enumerable:!0,get:function(){return He.Empty}});var Lt=rt;Object.defineProperty(t,"extractProtocolMessage",{enumerable:!0,get:function(){return Lt.extractProtocolMessage}}),Object.defineProperty(t,"protoLen",{enumerable:!0,get:function(){return Lt.protoLen}});var _t=Oe;Object.defineProperty(t,"createInbox",{enumerable:!0,get:function(){return _t.createInbox}}),Object.defineProperty(t,"Match",{enumerable:!0,get:function(){return _t.Match}}),Object.defineProperty(t,"syncIterator",{enumerable:!0,get:function(){return _t.syncIterator}});var mt=Me;Object.defineProperty(t,"SubscriptionImpl",{enumerable:!0,get:function(){return mt.SubscriptionImpl}}),Object.defineProperty(t,"Subscriptions",{enumerable:!0,get:function(){return mt.Subscriptions}});var vt=rr;Object.defineProperty(t,"IdleHeartbeatMonitor",{enumerable:!0,get:function(){return vt.IdleHeartbeatMonitor}});var pt=Ve;Object.defineProperty(t,"isIPV4OrHostname",{enumerable:!0,get:function(){return pt.isIPV4OrHostname}}),Object.defineProperty(t,"Servers",{enumerable:!0,get:function(){return pt.Servers}});var Ft=gt;Object.defineProperty(t,"wsconnect",{enumerable:!0,get:function(){return Ft.wsconnect}}),Object.defineProperty(t,"wsUrlParseFn",{enumerable:!0,get:function(){return Ft.wsUrlParseFn}});var Pe=te;Object.defineProperty(t,"AuthorizationError",{enumerable:!0,get:function(){return Pe.AuthorizationError}}),Object.defineProperty(t,"ClosedConnectionError",{enumerable:!0,get:function(){return Pe.ClosedConnectionError}}),Object.defineProperty(t,"ConnectionError",{enumerable:!0,get:function(){return Pe.ConnectionError}}),Object.defineProperty(t,"DrainingConnectionError",{enumerable:!0,get:function(){return Pe.DrainingConnectionError}}),Object.defineProperty(t,"errors",{enumerable:!0,get:function(){return Pe.errors}}),Object.defineProperty(t,"InvalidArgumentError",{enumerable:!0,get:function(){return Pe.InvalidArgumentError}}),Object.defineProperty(t,"InvalidOperationError",{enumerable:!0,get:function(){return Pe.InvalidOperationError}}),Object.defineProperty(t,"InvalidSubjectError",{enumerable:!0,get:function(){return Pe.InvalidSubjectError}}),Object.defineProperty(t,"NoRespondersError",{enumerable:!0,get:function(){return Pe.NoRespondersError}}),Object.defineProperty(t,"PermissionViolationError",{enumerable:!0,get:function(){return Pe.PermissionViolationError}}),Object.defineProperty(t,"ProtocolError",{enumerable:!0,get:function(){return Pe.ProtocolError}}),Object.defineProperty(t,"RequestError",{enumerable:!0,get:function(){return Pe.RequestError}}),Object.defineProperty(t,"TimeoutError",{enumerable:!0,get:function(){return Pe.TimeoutError}}),Object.defineProperty(t,"UserAuthenticationExpiredError",{enumerable:!0,get:function(){return Pe.UserAuthenticationExpiredError}})})(Jr),function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.wsconnect=t.usernamePasswordAuthenticator=t.UserAuthenticationExpiredError=t.tokenAuthenticator=t.TimeoutError=t.syncIterator=t.RequestError=t.ProtocolError=t.PermissionViolationError=t.nuid=t.Nuid=t.NoRespondersError=t.nkeys=t.nkeyAuthenticator=t.nanos=t.MsgHdrsImpl=t.millis=t.Metric=t.Match=t.jwtAuthenticator=t.InvalidSubjectError=t.InvalidOperationError=t.InvalidArgumentError=t.headers=t.hasWsProtocol=t.errors=t.Empty=t.DrainingConnectionError=t.delay=t.deferred=t.deadline=t.credsAuthenticator=t.createInbox=t.ConnectionError=t.ClosedConnectionError=t.canonicalMIMEHeaderKey=t.buildAuthenticator=t.Bench=t.backoff=t.AuthorizationError=void 0;var e=Jr;Object.defineProperty(t,"AuthorizationError",{enumerable:!0,get:function(){return e.AuthorizationError}}),Object.defineProperty(t,"backoff",{enumerable:!0,get:function(){return e.backoff}}),Object.defineProperty(t,"Bench",{enumerable:!0,get:function(){return e.Bench}}),Object.defineProperty(t,"buildAuthenticator",{enumerable:!0,get:function(){return e.buildAuthenticator}}),Object.defineProperty(t,"canonicalMIMEHeaderKey",{enumerable:!0,get:function(){return e.canonicalMIMEHeaderKey}}),Object.defineProperty(t,"ClosedConnectionError",{enumerable:!0,get:function(){return e.ClosedConnectionError}}),Object.defineProperty(t,"ConnectionError",{enumerable:!0,get:function(){return e.ConnectionError}}),Object.defineProperty(t,"createInbox",{enumerable:!0,get:function(){return e.createInbox}}),Object.defineProperty(t,"credsAuthenticator",{enumerable:!0,get:function(){return e.credsAuthenticator}}),Object.defineProperty(t,"deadline",{enumerable:!0,get:function(){return e.deadline}}),Object.defineProperty(t,"deferred",{enumerable:!0,get:function(){return e.deferred}}),Object.defineProperty(t,"delay",{enumerable:!0,get:function(){return e.delay}}),Object.defineProperty(t,"DrainingConnectionError",{enumerable:!0,get:function(){return e.DrainingConnectionError}}),Object.defineProperty(t,"Empty",{enumerable:!0,get:function(){return e.Empty}}),Object.defineProperty(t,"errors",{enumerable:!0,get:function(){return e.errors}}),Object.defineProperty(t,"hasWsProtocol",{enumerable:!0,get:function(){return e.hasWsProtocol}}),Object.defineProperty(t,"headers",{enumerable:!0,get:function(){return e.headers}}),Object.defineProperty(t,"InvalidArgumentError",{enumerable:!0,get:function(){return e.InvalidArgumentError}}),Object.defineProperty(t,"InvalidOperationError",{enumerable:!0,get:function(){return e.InvalidOperationError}}),Object.defineProperty(t,"InvalidSubjectError",{enumerable:!0,get:function(){return e.InvalidSubjectError}}),Object.defineProperty(t,"jwtAuthenticator",{enumerable:!0,get:function(){return e.jwtAuthenticator}}),Object.defineProperty(t,"Match",{enumerable:!0,get:function(){return e.Match}}),Object.defineProperty(t,"Metric",{enumerable:!0,get:function(){return e.Metric}}),Object.defineProperty(t,"millis",{enumerable:!0,get:function(){return e.millis}}),Object.defineProperty(t,"MsgHdrsImpl",{enumerable:!0,get:function(){return e.MsgHdrsImpl}}),Object.defineProperty(t,"nanos",{enumerable:!0,get:function(){return e.nanos}}),Object.defineProperty(t,"nkeyAuthenticator",{enumerable:!0,get:function(){return e.nkeyAuthenticator}}),Object.defineProperty(t,"nkeys",{enumerable:!0,get:function(){return e.nkeys}}),Object.defineProperty(t,"NoRespondersError",{enumerable:!0,get:function(){return e.NoRespondersError}}),Object.defineProperty(t,"Nuid",{enumerable:!0,get:function(){return e.Nuid}}),Object.defineProperty(t,"nuid",{enumerable:!0,get:function(){return e.nuid}}),Object.defineProperty(t,"PermissionViolationError",{enumerable:!0,get:function(){return e.PermissionViolationError}}),Object.defineProperty(t,"ProtocolError",{enumerable:!0,get:function(){return e.ProtocolError}}),Object.defineProperty(t,"RequestError",{enumerable:!0,get:function(){return e.RequestError}}),Object.defineProperty(t,"syncIterator",{enumerable:!0,get:function(){return e.syncIterator}}),Object.defineProperty(t,"TimeoutError",{enumerable:!0,get:function(){return e.TimeoutError}}),Object.defineProperty(t,"tokenAuthenticator",{enumerable:!0,get:function(){return e.tokenAuthenticator}}),Object.defineProperty(t,"UserAuthenticationExpiredError",{enumerable:!0,get:function(){return e.UserAuthenticationExpiredError}}),Object.defineProperty(t,"usernamePasswordAuthenticator",{enumerable:!0,get:function(){return e.usernamePasswordAuthenticator}}),Object.defineProperty(t,"wsconnect",{enumerable:!0,get:function(){return e.wsconnect}})}(Hr);class zi{constructor(e){d(this,"defaultTimeout");this.natsConnection=e,this.defaultTimeout=parseInt(process.env.NATS_REQUEST_TIMEOUT||"5000",10)}async addGroupMember(e,r="",s){let o="directory.group.member.add";r&&(o=`${r}.${o}`),console.debug("Sending request to NATS subject",{messageAddress:o});const f=await this.natsConnection.request(o,JSON.stringify(e),this.toNatsOptions(s));if(!f)throw console.warn("No reply received for subject",{messageAddress:o}),new Error("No reply received");return this.extractResponse(f.json())}async createManualGroup(e,r="",s){let o="directory.group.manual.create";r&&(o=`${r}.${o}`),console.debug("Sending request to NATS subject",{messageAddress:o});const f=await this.natsConnection.request(o,JSON.stringify(e),this.toNatsOptions(s));if(!f)throw console.warn("No reply received for subject",{messageAddress:o}),new Error("No reply received");return this.extractResponse(f.json())}async deleteManualGroup(e,r="",s){let o="directory.group.manual.delete";r&&(o=`${r}.${o}`),console.debug("Sending request to NATS subject",{messageAddress:o});const f=await this.natsConnection.request(o,JSON.stringify(e),this.toNatsOptions(s));if(!f)throw console.warn("No reply received for subject",{messageAddress:o}),new Error("No reply received");return this.extractResponse(f.json())}async findGroupByExternalId(e,r="",s){let o="directory.group.find.byexternalid";r&&(o=`${r}.${o}`),console.debug("Sending request to NATS subject",{messageAddress:o});const f=await this.natsConnection.request(o,JSON.stringify(e),this.toNatsOptions(s));if(!f)throw console.warn("No reply received for subject",{messageAddress:o}),new Error("No reply received");return this.extractResponse(f.json())}async getClassAdminUsers(e,r="",s){let o="directory.class.admin.by.id";r&&(o=`${r}.${o}`),console.debug("Sending request to NATS subject",{messageAddress:o});const f=await this.natsConnection.request(o,JSON.stringify(e),this.toNatsOptions(s));if(!f)throw console.warn("No reply received for subject",{messageAddress:o}),new Error("No reply received");return this.extractResponse(f.json())}async getGroupsByIds(e,r="",s){let o="directory.groups.get.byids";r&&(o=`${r}.${o}`),console.debug("Sending request to NATS subject",{messageAddress:o});const f=await this.natsConnection.request(o,JSON.stringify(e),this.toNatsOptions(s));if(!f)throw console.warn("No reply received for subject",{messageAddress:o}),new Error("No reply received");return this.extractResponse(f.json())}async getStructureUsers(e,r="",s){let o="directory.structure.users.by.id";r&&(o=`${r}.${o}`),console.debug("Sending request to NATS subject",{messageAddress:o});const f=await this.natsConnection.request(o,JSON.stringify(e),this.toNatsOptions(s));if(!f)throw console.warn("No reply received for subject",{messageAddress:o}),new Error("No reply received");return this.extractResponse(f.json())}async getUserDisplayNames(e,r="",s){let o="directory.users.get.displaynames";r&&(o=`${r}.${o}`),console.debug("Sending request to NATS subject",{messageAddress:o});const f=await this.natsConnection.request(o,JSON.stringify(e),this.toNatsOptions(s));if(!f)throw console.warn("No reply received for subject",{messageAddress:o}),new Error("No reply received");return this.extractResponse(f.json())}async getUserInClassWithParams(e,r="",s){let o="directory.class.by.id.with.params";r&&(o=`${r}.${o}`),console.debug("Sending request to NATS subject",{messageAddress:o});const f=await this.natsConnection.request(o,JSON.stringify(e),this.toNatsOptions(s));if(!f)throw console.warn("No reply received for subject",{messageAddress:o}),new Error("No reply received");return this.extractResponse(f.json())}async getUsersByIds(e,r="",s){let o="directory.users.get.byids";r&&(o=`${r}.${o}`),console.debug("Sending request to NATS subject",{messageAddress:o});const f=await this.natsConnection.request(o,JSON.stringify(e),this.toNatsOptions(s));if(!f)throw console.warn("No reply received for subject",{messageAddress:o}),new Error("No reply received");return this.extractResponse(f.json())}async getUsersFromGroups(e,r="",s){let o="directory.users.get.bygroupids";r&&(o=`${r}.${o}`),console.debug("Sending request to NATS subject",{messageAddress:o});const f=await this.natsConnection.request(o,JSON.stringify(e),this.toNatsOptions(s));if(!f)throw console.warn("No reply received for subject",{messageAddress:o}),new Error("No reply received");return this.extractResponse(f.json())}async notifyGroupMembersChanged(e,r="",s){let o="directory.group.members.changed";r&&(o=`${r}.${o}`),console.debug("Publishing to NATS subject",{messageAddress:o}),this.natsConnection.publish(o,JSON.stringify(e),this.toNatsOptions(s))}async notifyGroupsDeleted(e,r="",s){let o="directory.groups.deleted";r&&(o=`${r}.${o}`),console.debug("Publishing to NATS subject",{messageAddress:o}),this.natsConnection.publish(o,JSON.stringify(e),this.toNatsOptions(s))}async notifyUsersDeleted(e,r="",s){let o="directory.users.deleted";r&&(o=`${r}.${o}`),console.debug("Publishing to NATS subject",{messageAddress:o}),this.natsConnection.publish(o,JSON.stringify(e),this.toNatsOptions(s))}async removeGroupMember(e,r="",s){let o="directory.group.member.delete";r&&(o=`${r}.${o}`),console.debug("Sending request to NATS subject",{messageAddress:o});const f=await this.natsConnection.request(o,JSON.stringify(e),this.toNatsOptions(s));if(!f)throw console.warn("No reply received for subject",{messageAddress:o}),new Error("No reply received");return this.extractResponse(f.json())}async searchStructures(e,r="",s){let o="directory.structures.search";r&&(o=`${r}.${o}`),console.debug("Sending request to NATS subject",{messageAddress:o});const f=await this.natsConnection.request(o,JSON.stringify(e),this.toNatsOptions(s));if(!f)throw console.warn("No reply received for subject",{messageAddress:o}),new Error("No reply received");return this.extractResponse(f.json())}async updateManualGroup(e,r="",s){let o="directory.group.manual.update";r&&(o=`${r}.${o}`),console.debug("Sending request to NATS subject",{messageAddress:o});const f=await this.natsConnection.request(o,JSON.stringify(e),this.toNatsOptions(s));if(!f)throw console.warn("No reply received for subject",{messageAddress:o}),new Error("No reply received");return this.extractResponse(f.json())}extractResponse(e){return e.response||e}toNatsOptions(e){const s={timeout:(e==null?void 0:e.timeout)??this.defaultTimeout};if(e!=null&&e.headers){const o=Hr.headers();for(const[f,l]of Object.entries(e.headers))Array.isArray(l)?l.forEach(m=>o.append(f,m)):o.set(f,l);s.headers=o}return s}}Ie.DirectoryNatsServiceClient=zi,Object.defineProperty(Ie,Symbol.toStringTag,{value:"Module"})});
@@ -0,0 +1,84 @@
1
+ import { AddGroupMemberRequest, AddGroupMemberResponse, CreateGroupRequest, CreateGroupResponse, DeleteGroupRequest, DeleteGroupResponse, FindGroupByExternalIdRequest, FindGroupByExternalIdResponse, GetClassAdminRequest, GetClassAdminResponse, GetGroupsByIdsRequest, GetGroupsByIdsResponse, GetStructureUsersRequest, GetStructureUsersResponse, GetUserDisplayNamesRequest, GetUserDisplayNamesResponse, GetUserInClassWithParamsRequest, GetUserInClassWithParamsResponse, GetUsersByIdsRequest, GetUsersByIdsResponse, GetUsersFromGroupsRequest, GetUsersFromGroupsResponse, GroupMembersChanged, GroupsDeleted, RemoveGroupMemberRequest, RemoveGroupMemberResponse, SearchStructuresRequest, SearchStructuresResponse, UpdateGroupRequest, UpdateGroupResponse, UsersDeleted } from '@edifice.io/directory-node-api';
2
+ import { NatsConnection } from '@nats-io/nats-core';
3
+ export interface RequestOptions {
4
+ timeout?: number;
5
+ headers?: Record<string, string[] | string>;
6
+ }
7
+ export declare class DirectoryNatsServiceClient {
8
+ private readonly natsConnection;
9
+ private readonly defaultTimeout;
10
+ constructor(natsConnection: NatsConnection);
11
+ /**
12
+ * Adds a member to a group in the directory.
13
+ */
14
+ addGroupMember(request: AddGroupMemberRequest, platformId?: string, options?: RequestOptions): Promise<AddGroupMemberResponse>;
15
+ /**
16
+ * Creates a new manual group in the directory.
17
+ */
18
+ createManualGroup(request: CreateGroupRequest, platformId?: string, options?: RequestOptions): Promise<CreateGroupResponse>;
19
+ /**
20
+ * Deletes an existing manual group in the directory.
21
+ */
22
+ deleteManualGroup(request: DeleteGroupRequest, platformId?: string, options?: RequestOptions): Promise<DeleteGroupResponse>;
23
+ /**
24
+ * Finds a group by its external ID in the directory.
25
+ * The response contains the group or an indication that the group was not found.
26
+ */
27
+ findGroupByExternalId(request: FindGroupByExternalIdRequest, platformId?: string, options?: RequestOptions): Promise<FindGroupByExternalIdResponse>;
28
+ /**
29
+ * Retrieves users by their ENT IDs with basic profile information, classes informations and hobbies.
30
+ */
31
+ getClassAdminUsers(request: GetClassAdminRequest, platformId?: string, options?: RequestOptions): Promise<GetClassAdminResponse>;
32
+ /**
33
+ * Retrieves groups by their ENT IDs with basic information (id, name).
34
+ * Unlike communication-rights-filtered lookups, this returns every group found
35
+ * regardless of the caller's communication rights or structure attachment.
36
+ */
37
+ getGroupsByIds(request: GetGroupsByIdsRequest, platformId?: string, options?: RequestOptions): Promise<GetGroupsByIdsResponse>;
38
+ /**
39
+ * Retrieves a list of users linked to a structure.
40
+ */
41
+ getStructureUsers(request: GetStructureUsersRequest, platformId?: string, options?: RequestOptions): Promise<GetStructureUsersResponse>;
42
+ /**
43
+ * Retrieves display names for multiple users by their ENT IDs.
44
+ */
45
+ getUserDisplayNames(request: GetUserDisplayNamesRequest, platformId?: string, options?: RequestOptions): Promise<GetUserDisplayNamesResponse>;
46
+ /**
47
+ * Retrieves users present in the class.
48
+ * It's getting more informations like INE and other relatives informations.
49
+ */
50
+ getUserInClassWithParams(request: GetUserInClassWithParamsRequest, platformId?: string, options?: RequestOptions): Promise<GetUserInClassWithParamsResponse>;
51
+ /**
52
+ * Retrieves users by their ENT IDs with basic profile information.
53
+ */
54
+ getUsersByIds(request: GetUsersByIdsRequest, platformId?: string, options?: RequestOptions): Promise<GetUsersByIdsResponse>;
55
+ /**
56
+ * Retrieves all users in provided groups with basic profile information.
57
+ */
58
+ getUsersFromGroups(request: GetUsersFromGroupsRequest, platformId?: string, options?: RequestOptions): Promise<GetUsersFromGroupsResponse>;
59
+ /**
60
+ * Notifies subscribers that the membership of a group has changed.
61
+ * This includes both current members and members who have been removed.
62
+ */
63
+ notifyGroupMembersChanged(request: GroupMembersChanged, platformId?: string, options?: RequestOptions): Promise<void>;
64
+ /**
65
+ * Notifies subscribers that groups have been deleted from the directory.
66
+ */
67
+ notifyGroupsDeleted(request: GroupsDeleted, platformId?: string, options?: RequestOptions): Promise<void>;
68
+ /**
69
+ * Notifies subscribers that users have been deleted from the directory.
70
+ */
71
+ notifyUsersDeleted(request: UsersDeleted, platformId?: string, options?: RequestOptions): Promise<void>;
72
+ /**
73
+ * Removes a member from a group in the directory.
74
+ */
75
+ removeGroupMember(request: RemoveGroupMemberRequest, platformId?: string, options?: RequestOptions): Promise<RemoveGroupMemberResponse>;
76
+ searchStructures(request: SearchStructuresRequest, platformId?: string, options?: RequestOptions): Promise<SearchStructuresResponse>;
77
+ /**
78
+ * Updates an existing manual group in the directory.
79
+ */
80
+ updateManualGroup(request: UpdateGroupRequest, platformId?: string, options?: RequestOptions): Promise<UpdateGroupResponse>;
81
+ private extractResponse;
82
+ private toNatsOptions;
83
+ }
84
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/nats/client.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAE5E,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AAE7E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAEzE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAE1E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAEzE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAE1E,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AAEnF,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,gCAAgC,CAAC;AAEpF,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AAE3E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAE5E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAE5E,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AAE7E,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAE/E,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAEhF,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,gCAAgC,CAAC;AAEjF,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,gCAAgC,CAAC;AAElF,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,gCAAgC,CAAC;AAEtF,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,gCAAgC,CAAC;AAEvF,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AAE3E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAE5E,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAEhF,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,gCAAgC,CAAC;AAEjF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAE1E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAEpE,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAE/E,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAEhF,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAE9E,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAE/E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAEzE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAE1E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAGnE,OAAO,KAAK,EAAE,cAAc,EAA6C,MAAM,oBAAoB,CAAC;AAGpG,MAAM,WAAW,cAAc;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC,CAAA;CAC9C;AAED,qBAAa,0BAA0B;IAIzB,OAAO,CAAC,QAAQ,CAAC,cAAc;IAF3C,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAS;gBAEX,cAAc,EAAE,cAAc;IAM3D;;OAEG;IACG,cAAc,CAAC,OAAO,EAAE,qBAAqB,EAAE,UAAU,GAAE,MAAW,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,sBAAsB,CAAC;IAgBxI;;OAEG;IACG,iBAAiB,CAAC,OAAO,EAAE,kBAAkB,EAAE,UAAU,GAAE,MAAW,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAgBrI;;OAEG;IACG,iBAAiB,CAAC,OAAO,EAAE,kBAAkB,EAAE,UAAU,GAAE,MAAW,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAgBrI;;;OAGG;IACG,qBAAqB,CAAC,OAAO,EAAE,4BAA4B,EAAE,UAAU,GAAE,MAAW,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,6BAA6B,CAAC;IAgB7J;;OAEG;IACG,kBAAkB,CAAC,OAAO,EAAE,oBAAoB,EAAE,UAAU,GAAE,MAAW,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAgB1I;;;;OAIG;IACG,cAAc,CAAC,OAAO,EAAE,qBAAqB,EAAE,UAAU,GAAE,MAAW,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,sBAAsB,CAAC;IAgBxI;;OAEG;IACG,iBAAiB,CAAC,OAAO,EAAE,wBAAwB,EAAE,UAAU,GAAE,MAAW,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,yBAAyB,CAAC;IAgBjJ;;OAEG;IACG,mBAAmB,CAAC,OAAO,EAAE,0BAA0B,EAAE,UAAU,GAAE,MAAW,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,2BAA2B,CAAC;IAgBvJ;;;OAGG;IACG,wBAAwB,CAAC,OAAO,EAAE,+BAA+B,EAAE,UAAU,GAAE,MAAW,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,gCAAgC,CAAC;IAgBtK;;OAEG;IACG,aAAa,CAAC,OAAO,EAAE,oBAAoB,EAAE,UAAU,GAAE,MAAW,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAgBrI;;OAEG;IACG,kBAAkB,CAAC,OAAO,EAAE,yBAAyB,EAAE,UAAU,GAAE,MAAW,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,0BAA0B,CAAC;IAgBpJ;;;OAGG;IACG,yBAAyB,CAAC,OAAO,EAAE,mBAAmB,EAAE,UAAU,GAAE,MAAW,EAAE,OAAO,CAAC,EAAE,cAAc;IAW/G;;OAEG;IACG,mBAAmB,CAAC,OAAO,EAAE,aAAa,EAAE,UAAU,GAAE,MAAW,EAAE,OAAO,CAAC,EAAE,cAAc;IAWnG;;OAEG;IACG,kBAAkB,CAAC,OAAO,EAAE,YAAY,EAAE,UAAU,GAAE,MAAW,EAAE,OAAO,CAAC,EAAE,cAAc;IAWjG;;OAEG;IACG,iBAAiB,CAAC,OAAO,EAAE,wBAAwB,EAAE,UAAU,GAAE,MAAW,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,yBAAyB,CAAC;IAgB3I,gBAAgB,CAAC,OAAO,EAAE,uBAAuB,EAAE,UAAU,GAAE,MAAW,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,wBAAwB,CAAC;IAgB9I;;OAEG;IACG,iBAAiB,CAAC,OAAO,EAAE,kBAAkB,EAAE,UAAU,GAAE,MAAW,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAgBrI,OAAO,CAAC,eAAe;IAKvB,OAAO,CAAC,aAAa;CAmBtB"}
package/package.json CHANGED
@@ -1,6 +1,59 @@
1
1
  {
2
2
  "name": "@edifice.io/directory-node-client",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.0",
4
+ "description": "Clients to interact with directory-nats-service",
5
+ "private": false,
6
+ "publishConfig": {
7
+ "access": "public"
8
+ },
9
+ "keywords": [],
10
+ "author": "Edifice",
11
+ "license": "AGPL-3.0",
12
+ "engines": {
13
+ "node": "22"
14
+ },
15
+ "engineStrict": true,
16
+ "type": "module",
17
+ "exports": {
18
+ ".": {
19
+ "require": "./dist/index.umd.cjs",
20
+ "import": "./dist/index.js",
21
+ "types": "./dist/index.d.ts"
22
+ }
23
+ },
24
+ "main": "dist/index.umd.cjs",
25
+ "module": "dist/index.js",
26
+ "types": "dist/index.d.ts",
27
+ "files": [
28
+ "dist"
29
+ ],
30
+ "dependencies": {
31
+ "@edifice.io/directory-node-api": "0.1.0",
32
+ "@nats-io/transport-node": "3.2.0",
33
+ "@nats-io/nats-core": "3.2.0"
34
+ },
35
+ "devDependencies": {
36
+ "@types/node": "25.2.0",
37
+ "husky": "9.0.11",
38
+ "prettier": "3.2.5",
39
+ "semantic-release": "23.0.2",
40
+ "typescript": "5.2.2",
41
+ "vite": "5.1.4",
42
+ "vite-plugin-dts": "4.3.0",
43
+ "rxjs": "7.8.1"
44
+ },
45
+ "lint-staged": {
46
+ "*.{js,ts,jsx,tsx,json,css,md}": "pnpm format"
47
+ },
48
+ "scripts": {
49
+ "dev": "vite",
50
+ "build": "tsc && vite build",
51
+ "build:types": "tsc --build",
52
+ "preview": "vite preview",
53
+ "clean": "rm -Rf dist",
54
+ "format": "pnpm run format:write && pnpm run format:check",
55
+ "format:check": "npx prettier --check \"src/**/*.ts\"",
56
+ "format:write": "npx prettier --write \"src/**/*.ts\"",
57
+ "pre-commit": "pnpm run format"
58
+ }
6
59
  }
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.