(function(je,Be){typeof exports=="object"&&typeof module<"u"?Be(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],Be):(je=typeof globalThis<"u"?globalThis:je||self,Be(je["rc-mqtt"]={},je.react))})(this,function(je,Be){"use strict";var Ju=Object.defineProperty;var Xu=(je,Be,We)=>Be in je?Ju(je,Be,{enumerable:!0,configurable:!0,writable:!0,value:We}):je[Be]=We;var rt=(je,Be,We)=>(Xu(je,typeof Be!="symbol"?Be+"":Be,We),We),ao=(je,Be,We)=>{if(!Be.has(je))throw TypeError("Cannot "+We)};var x=(je,Be,We)=>(ao(je,Be,"read from private field"),We?We.call(je):Be.get(je)),Me=(je,Be,We)=>{if(Be.has(je))throw TypeError("Cannot add the same private member more than once");Be instanceof WeakSet?Be.add(je):Be.set(je,We)},Ce=(je,Be,We,Bt)=>(ao(je,Be,"write to private field"),Bt?Bt.call(je,We):Be.set(je,We),We);var dn=(je,Be,We,Bt)=>({set _(Xt){Ce(je,Be,Xt,We)},get _(){return x(je,Be,Bt)}}),Re=(je,Be,We)=>(ao(je,Be,"access private method"),We);var We="/",Bt="+",Xt="#",Qa={matches:po,extract:go,exec:Ga,fill:Ja,clean:Xa};function Ga(e,o){return po(e,o)?go(e,o):null}function po(e,o){for(var t=e.split(We),l=o.split(We),h=t.length,i=l.length,r=h-1,s=0;s{t==null||t.subscribe(e,o)},[t,o,e]),n=Be.useCallback((a,c)=>{[e].flat().some(d=>Qa.matches(d,a))&&r({topic:a,message:(h==null?void 0:h(c))||c.toString()})},[h,e]);return Be.useEffect(()=>(t!=null&&t.connected&&(s(),t.on("message",n)),()=>{t==null||t.off("message",n)}),[n,t,s]),{client:t,topic:e,message:i,connectionStatus:l}}function el(){const{connectionStatus:e,client:o,parserMethod:t}=Be.useContext(Wr);return{connectionStatus:e,client:o,parserMethod:t}}var bn={exports:{}},Rr={};/** * @license React * react-jsx-runtime.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var bo;function tl(){if(bo)return Rr;bo=1;var e=Be,o=Symbol.for("react.element"),t=Symbol.for("react.fragment"),l=Object.prototype.hasOwnProperty,h=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};function r(s,n,a){var c,d={},g=null,b=null;a!==void 0&&(g=""+a),n.key!==void 0&&(g=""+n.key),n.ref!==void 0&&(b=n.ref);for(c in n)l.call(n,c)&&!i.hasOwnProperty(c)&&(d[c]=n[c]);if(s&&s.defaultProps)for(c in n=s.defaultProps,n)d[c]===void 0&&(d[c]=n[c]);return{$$typeof:o,type:s,key:g,ref:b,props:d,_owner:h.current}}return Rr.Fragment=t,Rr.jsx=r,Rr.jsxs=r,Rr}var Or={};/** * @license React * react-jsx-runtime.development.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var mo;function rl(){return mo||(mo=1,process.env.NODE_ENV!=="production"&&function(){var e=Be,o=Symbol.for("react.element"),t=Symbol.for("react.portal"),l=Symbol.for("react.fragment"),h=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),r=Symbol.for("react.provider"),s=Symbol.for("react.context"),n=Symbol.for("react.forward_ref"),a=Symbol.for("react.suspense"),c=Symbol.for("react.suspense_list"),d=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),b=Symbol.for("react.offscreen"),m=Symbol.iterator,y="@@iterator";function T(L){if(L===null||typeof L!="object")return null;var _e=m&&L[m]||L[y];return typeof _e=="function"?_e:null}var U=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function S(L){{for(var _e=arguments.length,Te=new Array(_e>1?_e-1:0),Pe=1;Pe<_e;Pe++)Te[Pe-1]=arguments[Pe];R("error",L,Te)}}function R(L,_e,Te){{var Pe=U.ReactDebugCurrentFrame,Fe=Pe.getStackAddendum();Fe!==""&&(_e+="%s",Te=Te.concat([Fe]));var He=Te.map(function(De){return String(De)});He.unshift("Warning: "+_e),Function.prototype.apply.call(console[L],console,He)}}var F=!1,W=!1,C=!1,O=!1,M=!1,$;$=Symbol.for("react.module.reference");function X(L){return!!(typeof L=="string"||typeof L=="function"||L===l||L===i||M||L===h||L===a||L===c||O||L===b||F||W||C||typeof L=="object"&&L!==null&&(L.$$typeof===g||L.$$typeof===d||L.$$typeof===r||L.$$typeof===s||L.$$typeof===n||L.$$typeof===$||L.getModuleId!==void 0))}function te(L,_e,Te){var Pe=L.displayName;if(Pe)return Pe;var Fe=_e.displayName||_e.name||"";return Fe!==""?Te+"("+Fe+")":Te}function E(L){return L.displayName||"Context"}function q(L){if(L==null)return null;if(typeof L.tag=="number"&&S("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof L=="function")return L.displayName||L.name||null;if(typeof L=="string")return L;switch(L){case l:return"Fragment";case t:return"Portal";case i:return"Profiler";case h:return"StrictMode";case a:return"Suspense";case c:return"SuspenseList"}if(typeof L=="object")switch(L.$$typeof){case s:var _e=L;return E(_e)+".Consumer";case r:var Te=L;return E(Te._context)+".Provider";case n:return te(L,L.render,"ForwardRef");case d:var Pe=L.displayName||null;return Pe!==null?Pe:q(L.type)||"Memo";case g:{var Fe=L,He=Fe._payload,De=Fe._init;try{return q(De(He))}catch{return null}}}return null}var Z=Object.assign,z=0,be,ie,V,me,ne,Ee,A;function Q(){}Q.__reactDisabledLog=!0;function fe(){{if(z===0){be=console.log,ie=console.info,V=console.warn,me=console.error,ne=console.group,Ee=console.groupCollapsed,A=console.groupEnd;var L={configurable:!0,enumerable:!0,value:Q,writable:!0};Object.defineProperties(console,{info:L,log:L,warn:L,error:L,group:L,groupCollapsed:L,groupEnd:L})}z++}}function Ae(){{if(z--,z===0){var L={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:Z({},L,{value:be}),info:Z({},L,{value:ie}),warn:Z({},L,{value:V}),error:Z({},L,{value:me}),group:Z({},L,{value:ne}),groupCollapsed:Z({},L,{value:Ee}),groupEnd:Z({},L,{value:A})})}z<0&&S("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var ae=U.ReactCurrentDispatcher,B;function _(L,_e,Te){{if(B===void 0)try{throw Error()}catch(Fe){var Pe=Fe.stack.trim().match(/\n( *(at )?)/);B=Pe&&Pe[1]||""}return` `+B+L}}var Y=!1,se;{var ee=typeof WeakMap=="function"?WeakMap:Map;se=new ee}function J(L,_e){if(!L||Y)return"";{var Te=se.get(L);if(Te!==void 0)return Te}var Pe;Y=!0;var Fe=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var He;He=ae.current,ae.current=null,fe();try{if(_e){var De=function(){throw Error()};if(Object.defineProperty(De.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(De,[])}catch(wt){Pe=wt}Reflect.construct(L,[],De)}else{try{De.call()}catch(wt){Pe=wt}L.call(De.prototype)}}else{try{throw Error()}catch(wt){Pe=wt}L()}}catch(wt){if(wt&&Pe&&typeof wt.stack=="string"){for(var Le=wt.stack.split(` `),mt=Pe.stack.split(` `),it=Le.length-1,ot=mt.length-1;it>=1&&ot>=0&&Le[it]!==mt[ot];)ot--;for(;it>=1&&ot>=0;it--,ot--)if(Le[it]!==mt[ot]){if(it!==1||ot!==1)do if(it--,ot--,ot<0||Le[it]!==mt[ot]){var Tt=` `+Le[it].replace(" at new "," at ");return L.displayName&&Tt.includes("")&&(Tt=Tt.replace("",L.displayName)),typeof L=="function"&&se.set(L,Tt),Tt}while(it>=1&&ot>=0);break}}}finally{Y=!1,ae.current=He,Ae(),Error.prepareStackTrace=Fe}var kr=L?L.displayName||L.name:"",_r=kr?_(kr):"";return typeof L=="function"&&se.set(L,_r),_r}function ce(L,_e,Te){return J(L,!1)}function pe(L){var _e=L.prototype;return!!(_e&&_e.isReactComponent)}function k(L,_e,Te){if(L==null)return"";if(typeof L=="function")return J(L,pe(L));if(typeof L=="string")return _(L);switch(L){case a:return _("Suspense");case c:return _("SuspenseList")}if(typeof L=="object")switch(L.$$typeof){case n:return ce(L.render);case d:return k(L.type,_e,Te);case g:{var Pe=L,Fe=Pe._payload,He=Pe._init;try{return k(He(Fe),_e,Te)}catch{}}}return""}var N=Object.prototype.hasOwnProperty,D={},re=U.ReactDebugCurrentFrame;function G(L){if(L){var _e=L._owner,Te=k(L.type,L._source,_e?_e.type:null);re.setExtraStackFrame(Te)}else re.setExtraStackFrame(null)}function j(L,_e,Te,Pe,Fe){{var He=Function.call.bind(N);for(var De in L)if(He(L,De)){var Le=void 0;try{if(typeof L[De]!="function"){var mt=Error((Pe||"React class")+": "+Te+" type `"+De+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof L[De]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw mt.name="Invariant Violation",mt}Le=L[De](_e,De,Pe,Te,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(it){Le=it}Le&&!(Le instanceof Error)&&(G(Fe),S("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",Pe||"React class",Te,De,typeof Le),G(null)),Le instanceof Error&&!(Le.message in D)&&(D[Le.message]=!0,G(Fe),S("Failed %s type: %s",Te,Le.message),G(null))}}}var K=Array.isArray;function ve(L){return K(L)}function Se(L){{var _e=typeof Symbol=="function"&&Symbol.toStringTag,Te=_e&&L[Symbol.toStringTag]||L.constructor.name||"Object";return Te}}function ke(L){try{return Ue(L),!1}catch{return!0}}function Ue(L){return""+L}function f(L){if(ke(L))return S("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Se(L)),Ue(L)}var u=U.ReactCurrentOwner,p={key:!0,ref:!0,__self:!0,__source:!0},w,I,v;v={};function P(L){if(N.call(L,"ref")){var _e=Object.getOwnPropertyDescriptor(L,"ref").get;if(_e&&_e.isReactWarning)return!1}return L.ref!==void 0}function H(L){if(N.call(L,"key")){var _e=Object.getOwnPropertyDescriptor(L,"key").get;if(_e&&_e.isReactWarning)return!1}return L.key!==void 0}function de(L,_e){if(typeof L.ref=="string"&&u.current&&_e&&u.current.stateNode!==_e){var Te=q(u.current.type);v[Te]||(S('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',q(u.current.type),L.ref),v[Te]=!0)}}function oe(L,_e){{var Te=function(){w||(w=!0,S("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",_e))};Te.isReactWarning=!0,Object.defineProperty(L,"key",{get:Te,configurable:!0})}}function we(L,_e){{var Te=function(){I||(I=!0,S("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",_e))};Te.isReactWarning=!0,Object.defineProperty(L,"ref",{get:Te,configurable:!0})}}var Ie=function(L,_e,Te,Pe,Fe,He,De){var Le={$$typeof:o,type:L,key:_e,ref:Te,props:De,_owner:He};return Le._store={},Object.defineProperty(Le._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(Le,"_self",{configurable:!1,enumerable:!1,writable:!1,value:Pe}),Object.defineProperty(Le,"_source",{configurable:!1,enumerable:!1,writable:!1,value:Fe}),Object.freeze&&(Object.freeze(Le.props),Object.freeze(Le)),Le};function Oe(L,_e,Te,Pe,Fe){{var He,De={},Le=null,mt=null;Te!==void 0&&(f(Te),Le=""+Te),H(_e)&&(f(_e.key),Le=""+_e.key),P(_e)&&(mt=_e.ref,de(_e,Fe));for(He in _e)N.call(_e,He)&&!p.hasOwnProperty(He)&&(De[He]=_e[He]);if(L&&L.defaultProps){var it=L.defaultProps;for(He in it)De[He]===void 0&&(De[He]=it[He])}if(Le||mt){var ot=typeof L=="function"?L.displayName||L.name||"Unknown":L;Le&&oe(De,ot),mt&&we(De,ot)}return Ie(L,Le,mt,Fe,Pe,u.current,De)}}var Ke=U.ReactCurrentOwner,pt=U.ReactDebugCurrentFrame;function Ne(L){if(L){var _e=L._owner,Te=k(L.type,L._source,_e?_e.type:null);pt.setExtraStackFrame(Te)}else pt.setExtraStackFrame(null)}var ht;ht=!1;function Je(L){return typeof L=="object"&&L!==null&&L.$$typeof===o}function et(){{if(Ke.current){var L=q(Ke.current.type);if(L)return` Check the render method of \``+L+"`."}return""}}function tt(L){return""}var at={};function xe(L){{var _e=et();if(!_e){var Te=typeof L=="string"?L:L.displayName||L.name;Te&&(_e=` Check the top-level render call using <`+Te+">.")}return _e}}function Ye(L,_e){{if(!L._store||L._store.validated||L.key!=null)return;L._store.validated=!0;var Te=xe(_e);if(at[Te])return;at[Te]=!0;var Pe="";L&&L._owner&&L._owner!==Ke.current&&(Pe=" It was passed a child from "+q(L._owner.type)+"."),Ne(L),S('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',Te,Pe),Ne(null)}}function gt(L,_e){{if(typeof L!="object")return;if(ve(L))for(var Te=0;Te",Le=" Did you accidentally export a JSX literal instead of a component?"):it=typeof L,S("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",it,Le)}var ot=Oe(L,_e,Te,Fe,He);if(ot==null)return ot;if(De){var Tt=_e.children;if(Tt!==void 0)if(Pe)if(ve(Tt)){for(var kr=0;kr0?"{key: someKey, "+wt.join(": ..., ")+": ...}":"{key: someKey}";if(!jt[_r+so]){var Qu=wt.length>0?"{"+wt.join(": ..., ")+": ...}":"{}";S(`A props object containing a "key" prop is being spread into JSX: let props = %s; <%s {...props} /> React keys must be passed directly to JSX without using spread: let props = %s; <%s key={someKey} {...props} />`,so,_r,Qu,_r),jt[_r+so]=!0}}return L===l?At(ot):lt(ot),ot}}function cn(L,_e,Te){return Pt(L,_e,Te,!0)}function fn(L,_e,Te){return Pt(L,_e,Te,!1)}var Ku=fn,Yu=cn;Or.Fragment=l,Or.jsx=Ku,Or.jsxs=Yu}()),Or}process.env.NODE_ENV==="production"?bn.exports=tl():bn.exports=rl();var nl=bn.exports,mn=Object.defineProperty,il=Object.getOwnPropertyDescriptor,ol=Object.getOwnPropertyNames,sl=Object.prototype.hasOwnProperty,ct=(e,o)=>()=>(e&&(o=e(e=0)),o),ye=(e,o)=>()=>(o||e((o={exports:{}}).exports,o),o.exports),ir=(e,o)=>{for(var t in o)mn(e,t,{get:o[t],enumerable:!0})},al=(e,o,t,l)=>{if(o&&typeof o=="object"||typeof o=="function")for(let h of ol(o))!sl.call(e,h)&&h!==t&&mn(e,h,{get:()=>o[h],enumerable:!(l=il(o,h))||l.enumerable});return e},Ve=e=>al(mn({},"__esModule",{value:!0}),e),_t,le=ct(()=>{_t={deviceMemory:8,hardwareConcurrency:8,language:"en-US"}}),ze={};ir(ze,{_debugEnd:()=>Jn,_debugProcess:()=>Gn,_events:()=>di,_eventsCount:()=>pi,_exiting:()=>Ln,_fatalExceptions:()=>Kn,_getActiveHandles:()=>Ao,_getActiveRequests:()=>So,_kill:()=>Dn,_linkedBinding:()=>_o,_maxListeners:()=>fi,_preload_modules:()=>ui,_rawDebug:()=>xn,_startProfilerIdleNotifier:()=>Xn,_stopProfilerIdleNotifier:()=>Zn,_tickCallback:()=>Qn,abort:()=>ni,addListener:()=>gi,allowedNodeEnvironmentFlags:()=>Hn,arch:()=>wn,argv:()=>Sn,argv0:()=>li,assert:()=>Io,binding:()=>Rn,chdir:()=>Pn,config:()=>jn,cpuUsage:()=>Pr,cwd:()=>Cn,debugPort:()=>ai,default:()=>Si,dlopen:()=>Eo,domain:()=>Un,emit:()=>wi,emitWarning:()=>kn,env:()=>En,execArgv:()=>An,execPath:()=>si,exit:()=>qn,features:()=>zn,hasUncaughtExceptionCaptureCallback:()=>To,hrtime:()=>$r,kill:()=>$n,listeners:()=>Ro,memoryUsage:()=>Wn,moduleLoadList:()=>Mn,nextTick:()=>vo,off:()=>mi,on:()=>Nt,once:()=>bi,openStdin:()=>Vn,pid:()=>ii,platform:()=>_n,ppid:()=>oi,prependListener:()=>_i,prependOnceListener:()=>Ei,reallyExit:()=>Nn,release:()=>Bn,removeAllListeners:()=>vi,removeListener:()=>yi,resourceUsage:()=>Fn,setSourceMapsEnabled:()=>hi,setUncaughtExceptionCaptureCallback:()=>Yn,stderr:()=>ti,stdin:()=>ri,stdout:()=>ei,title:()=>vn,umask:()=>On,uptime:()=>ko,version:()=>In,versions:()=>Tn});function yn(e){throw new Error("Node.js process "+e+" is not supported by JSPM core outside of Node.js")}function ll(){!or||!sr||(or=!1,sr.length?xt=sr.concat(xt):Cr=-1,xt.length&&yo())}function yo(){if(!or){var e=setTimeout(ll,0);or=!0;for(var o=xt.length;o;){for(sr=xt,xt=[];++Cr1)for(var t=1;t{he(),ue(),le(),xt=[],or=!1,Cr=-1,wo.prototype.run=function(){this.fun.apply(null,this.array)},vn="browser",wn="x64",_n="browser",En={PATH:"/usr/bin",LANG:_t.language+".UTF-8",PWD:"/",HOME:"/home",TMP:"/tmp"},Sn=["/usr/bin/node"],An=[],In="v16.8.0",Tn={},kn=function(e,o){console.warn((o?o+": ":"")+e)},Rn=function(e){yn("binding")},On=function(e){return 0},Cn=function(){return"/"},Pn=function(e){},Bn={name:"node",sourceUrl:"",headersUrl:"",libUrl:""},xn=bt,Mn=[],Un={},Ln=!1,jn={},Nn=bt,Dn=bt,Pr=function(){return{}},Fn=Pr,Wn=Pr,$n=bt,qn=bt,Vn=bt,Hn={},zn={inspector:!1,debug:!1,uv:!1,ipv6:!1,tls_alpn:!1,tls_sni:!1,tls_ocsp:!1,tls:!1,cached_builtins:!0},Kn=bt,Yn=bt,Qn=bt,Gn=bt,Jn=bt,Xn=bt,Zn=bt,ei=void 0,ti=void 0,ri=void 0,ni=bt,ii=2,oi=1,si="/bin/usr/node",ai=9229,li="node",ui=[],hi=bt,Dt={now:typeof performance<"u"?performance.now.bind(performance):void 0,timing:typeof performance<"u"?performance.timing:void 0},Dt.now===void 0&&(ci=Date.now(),Dt.timing&&Dt.timing.navigationStart&&(ci=Dt.timing.navigationStart),Dt.now=()=>Date.now()-ci),qr=1e9,$r.bigint=function(e){var o=$r(e);return typeof BigInt>"u"?o[0]*qr+o[1]:BigInt(o[0]*qr)+BigInt(o[1])},fi=10,di={},pi=0,gi=Nt,bi=Nt,mi=Nt,yi=Nt,vi=Nt,wi=bt,_i=Nt,Ei=Nt,Si={version:In,versions:Tn,arch:wn,platform:_n,release:Bn,_rawDebug:xn,moduleLoadList:Mn,binding:Rn,_linkedBinding:_o,_events:di,_eventsCount:pi,_maxListeners:fi,on:Nt,addListener:gi,once:bi,off:mi,removeListener:yi,removeAllListeners:vi,emit:wi,prependListener:_i,prependOnceListener:Ei,listeners:Ro,domain:Un,_exiting:Ln,config:jn,dlopen:Eo,uptime:ko,_getActiveRequests:So,_getActiveHandles:Ao,reallyExit:Nn,_kill:Dn,cpuUsage:Pr,resourceUsage:Fn,memoryUsage:Wn,kill:$n,exit:qn,openStdin:Vn,allowedNodeEnvironmentFlags:Hn,assert:Io,features:zn,_fatalExceptions:Kn,setUncaughtExceptionCaptureCallback:Yn,hasUncaughtExceptionCaptureCallback:To,emitWarning:kn,nextTick:vo,_tickCallback:Qn,_debugProcess:Gn,_debugEnd:Jn,_startProfilerIdleNotifier:Xn,_stopProfilerIdleNotifier:Zn,stdout:ei,stdin:ri,stderr:ti,abort:ni,umask:On,chdir:Pn,cwd:Cn,env:En,title:vn,argv:Sn,execArgv:An,pid:ii,ppid:oi,execPath:si,debugPort:ai,hrtime:$r,argv0:li,_preload_modules:ui,setSourceMapsEnabled:hi}}),ue=ct(()=>{ul()}),ft={};ir(ft,{Buffer:()=>Vr,INSPECT_MAX_BYTES:()=>Oo,default:()=>Ft,kMaxLength:()=>Co});function hl(){if(Ai)return Er;Ai=!0,Er.byteLength=s,Er.toByteArray=a,Er.fromByteArray=g;for(var e=[],o=[],t=typeof Uint8Array<"u"?Uint8Array:Array,l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",h=0,i=l.length;h0)throw new Error("Invalid string. Length must be a multiple of 4");var y=b.indexOf("=");y===-1&&(y=m);var T=y===m?0:4-y%4;return[y,T]}function s(b){var m=r(b),y=m[0],T=m[1];return(y+T)*3/4-T}function n(b,m,y){return(m+y)*3/4-y}function a(b){var m,y=r(b),T=y[0],U=y[1],S=new t(n(b,T,U)),R=0,F=U>0?T-4:T,W;for(W=0;W>16&255,S[R++]=m>>8&255,S[R++]=m&255;return U===2&&(m=o[b.charCodeAt(W)]<<2|o[b.charCodeAt(W+1)]>>4,S[R++]=m&255),U===1&&(m=o[b.charCodeAt(W)]<<10|o[b.charCodeAt(W+1)]<<4|o[b.charCodeAt(W+2)]>>2,S[R++]=m>>8&255,S[R++]=m&255),S}function c(b){return e[b>>18&63]+e[b>>12&63]+e[b>>6&63]+e[b&63]}function d(b,m,y){for(var T,U=[],S=m;SF?F:R+S));return T===1?(m=b[y-1],U.push(e[m>>2]+e[m<<4&63]+"==")):T===2&&(m=(b[y-2]<<8)+b[y-1],U.push(e[m>>10]+e[m>>4&63]+e[m<<2&63]+"=")),U.join("")}return Er}function cl(){return Ii?Br:(Ii=!0,Br.read=function(e,o,t,l,h){var i,r,s=h*8-l-1,n=(1<>1,c=-7,d=t?h-1:0,g=t?-1:1,b=e[o+d];for(d+=g,i=b&(1<<-c)-1,b>>=-c,c+=s;c>0;i=i*256+e[o+d],d+=g,c-=8);for(r=i&(1<<-c)-1,i>>=-c,c+=l;c>0;r=r*256+e[o+d],d+=g,c-=8);if(i===0)i=1-a;else{if(i===n)return r?NaN:(b?-1:1)*(1/0);r=r+Math.pow(2,l),i=i-a}return(b?-1:1)*r*Math.pow(2,i-l)},Br.write=function(e,o,t,l,h,i){var r,s,n,a=i*8-h-1,c=(1<>1,g=h===23?Math.pow(2,-24)-Math.pow(2,-77):0,b=l?0:i-1,m=l?1:-1,y=o<0||o===0&&1/o<0?1:0;for(o=Math.abs(o),isNaN(o)||o===1/0?(s=isNaN(o)?1:0,r=c):(r=Math.floor(Math.log(o)/Math.LN2),o*(n=Math.pow(2,-r))<1&&(r--,n*=2),r+d>=1?o+=g/n:o+=g*Math.pow(2,1-d),o*n>=2&&(r++,n/=2),r+d>=c?(s=0,r=c):r+d>=1?(s=(o*n-1)*Math.pow(2,h),r=r+d):(s=o*Math.pow(2,d-1)*Math.pow(2,h),r=0));h>=8;e[t+b]=s&255,b+=m,s/=256,h-=8);for(r=r<0;e[t+b]=r&255,b+=m,r/=256,a-=8);e[t+b-m]|=y*128},Br)}function fl(){if(Ti)return Zt;Ti=!0;let e=hl(),o=cl(),t=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;Zt.Buffer=r,Zt.SlowBuffer=U,Zt.INSPECT_MAX_BYTES=50;let l=2147483647;Zt.kMaxLength=l,r.TYPED_ARRAY_SUPPORT=h(),!r.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function h(){try{let f=new Uint8Array(1),u={foo:function(){return 42}};return Object.setPrototypeOf(u,Uint8Array.prototype),Object.setPrototypeOf(f,u),f.foo()===42}catch{return!1}}Object.defineProperty(r.prototype,"parent",{enumerable:!0,get:function(){if(r.isBuffer(this))return this.buffer}}),Object.defineProperty(r.prototype,"offset",{enumerable:!0,get:function(){if(r.isBuffer(this))return this.byteOffset}});function i(f){if(f>l)throw new RangeError('The value "'+f+'" is invalid for option "size"');let u=new Uint8Array(f);return Object.setPrototypeOf(u,r.prototype),u}function r(f,u,p){if(typeof f=="number"){if(typeof u=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return c(f)}return s(f,u,p)}r.poolSize=8192;function s(f,u,p){if(typeof f=="string")return d(f,u);if(ArrayBuffer.isView(f))return b(f);if(f==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof f);if(K(f,ArrayBuffer)||f&&K(f.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(K(f,SharedArrayBuffer)||f&&K(f.buffer,SharedArrayBuffer)))return m(f,u,p);if(typeof f=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let w=f.valueOf&&f.valueOf();if(w!=null&&w!==f)return r.from(w,u,p);let I=y(f);if(I)return I;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof f[Symbol.toPrimitive]=="function")return r.from(f[Symbol.toPrimitive]("string"),u,p);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof f)}r.from=function(f,u,p){return s(f,u,p)},Object.setPrototypeOf(r.prototype,Uint8Array.prototype),Object.setPrototypeOf(r,Uint8Array);function n(f){if(typeof f!="number")throw new TypeError('"size" argument must be of type number');if(f<0)throw new RangeError('The value "'+f+'" is invalid for option "size"')}function a(f,u,p){return n(f),f<=0?i(f):u!==void 0?typeof p=="string"?i(f).fill(u,p):i(f).fill(u):i(f)}r.alloc=function(f,u,p){return a(f,u,p)};function c(f){return n(f),i(f<0?0:T(f)|0)}r.allocUnsafe=function(f){return c(f)},r.allocUnsafeSlow=function(f){return c(f)};function d(f,u){if((typeof u!="string"||u==="")&&(u="utf8"),!r.isEncoding(u))throw new TypeError("Unknown encoding: "+u);let p=S(f,u)|0,w=i(p),I=w.write(f,u);return I!==p&&(w=w.slice(0,I)),w}function g(f){let u=f.length<0?0:T(f.length)|0,p=i(u);for(let w=0;w=l)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+l.toString(16)+" bytes");return f|0}function U(f){return+f!=f&&(f=0),r.alloc(+f)}r.isBuffer=function(f){return f!=null&&f._isBuffer===!0&&f!==r.prototype},r.compare=function(f,u){if(K(f,Uint8Array)&&(f=r.from(f,f.offset,f.byteLength)),K(u,Uint8Array)&&(u=r.from(u,u.offset,u.byteLength)),!r.isBuffer(f)||!r.isBuffer(u))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(f===u)return 0;let p=f.length,w=u.length;for(let I=0,v=Math.min(p,w);Iw.length?(r.isBuffer(v)||(v=r.from(v)),v.copy(w,I)):Uint8Array.prototype.set.call(w,v,I);else if(r.isBuffer(v))v.copy(w,I);else throw new TypeError('"list" argument must be an Array of Buffers');I+=v.length}return w};function S(f,u){if(r.isBuffer(f))return f.length;if(ArrayBuffer.isView(f)||K(f,ArrayBuffer))return f.byteLength;if(typeof f!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof f);let p=f.length,w=arguments.length>2&&arguments[2]===!0;if(!w&&p===0)return 0;let I=!1;for(;;)switch(u){case"ascii":case"latin1":case"binary":return p;case"utf8":case"utf-8":return N(f).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return p*2;case"hex":return p>>>1;case"base64":return G(f).length;default:if(I)return w?-1:N(f).length;u=(""+u).toLowerCase(),I=!0}}r.byteLength=S;function R(f,u,p){let w=!1;if((u===void 0||u<0)&&(u=0),u>this.length||((p===void 0||p>this.length)&&(p=this.length),p<=0)||(p>>>=0,u>>>=0,p<=u))return"";for(f||(f="utf8");;)switch(f){case"hex":return V(this,u,p);case"utf8":case"utf-8":return q(this,u,p);case"ascii":return be(this,u,p);case"latin1":case"binary":return ie(this,u,p);case"base64":return E(this,u,p);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return me(this,u,p);default:if(w)throw new TypeError("Unknown encoding: "+f);f=(f+"").toLowerCase(),w=!0}}r.prototype._isBuffer=!0;function F(f,u,p){let w=f[u];f[u]=f[p],f[p]=w}r.prototype.swap16=function(){let f=this.length;if(f%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let u=0;uu&&(f+=" ... "),""},t&&(r.prototype[t]=r.prototype.inspect),r.prototype.compare=function(f,u,p,w,I){if(K(f,Uint8Array)&&(f=r.from(f,f.offset,f.byteLength)),!r.isBuffer(f))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof f);if(u===void 0&&(u=0),p===void 0&&(p=f?f.length:0),w===void 0&&(w=0),I===void 0&&(I=this.length),u<0||p>f.length||w<0||I>this.length)throw new RangeError("out of range index");if(w>=I&&u>=p)return 0;if(w>=I)return-1;if(u>=p)return 1;if(u>>>=0,p>>>=0,w>>>=0,I>>>=0,this===f)return 0;let v=I-w,P=p-u,H=Math.min(v,P),de=this.slice(w,I),oe=f.slice(u,p);for(let we=0;we2147483647?p=2147483647:p<-2147483648&&(p=-2147483648),p=+p,ve(p)&&(p=I?0:f.length-1),p<0&&(p=f.length+p),p>=f.length){if(I)return-1;p=f.length-1}else if(p<0)if(I)p=0;else return-1;if(typeof u=="string"&&(u=r.from(u,w)),r.isBuffer(u))return u.length===0?-1:C(f,u,p,w,I);if(typeof u=="number")return u=u&255,typeof Uint8Array.prototype.indexOf=="function"?I?Uint8Array.prototype.indexOf.call(f,u,p):Uint8Array.prototype.lastIndexOf.call(f,u,p):C(f,[u],p,w,I);throw new TypeError("val must be string, number or Buffer")}function C(f,u,p,w,I){let v=1,P=f.length,H=u.length;if(w!==void 0&&(w=String(w).toLowerCase(),w==="ucs2"||w==="ucs-2"||w==="utf16le"||w==="utf-16le")){if(f.length<2||u.length<2)return-1;v=2,P/=2,H/=2,p/=2}function de(we,Ie){return v===1?we[Ie]:we.readUInt16BE(Ie*v)}let oe;if(I){let we=-1;for(oe=p;oeP&&(p=P-H),oe=p;oe>=0;oe--){let we=!0;for(let Ie=0;IeI&&(w=I)):w=I;let v=u.length;w>v/2&&(w=v/2);let P;for(P=0;P>>0,isFinite(p)?(p=p>>>0,w===void 0&&(w="utf8")):(w=p,p=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let I=this.length-u;if((p===void 0||p>I)&&(p=I),f.length>0&&(p<0||u<0)||u>this.length)throw new RangeError("Attempt to write outside buffer bounds");w||(w="utf8");let v=!1;for(;;)switch(w){case"hex":return O(this,f,u,p);case"utf8":case"utf-8":return M(this,f,u,p);case"ascii":case"latin1":case"binary":return $(this,f,u,p);case"base64":return X(this,f,u,p);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return te(this,f,u,p);default:if(v)throw new TypeError("Unknown encoding: "+w);w=(""+w).toLowerCase(),v=!0}},r.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function E(f,u,p){return u===0&&p===f.length?e.fromByteArray(f):e.fromByteArray(f.slice(u,p))}function q(f,u,p){p=Math.min(f.length,p);let w=[],I=u;for(;I239?4:v>223?3:v>191?2:1;if(I+H<=p){let de,oe,we,Ie;switch(H){case 1:v<128&&(P=v);break;case 2:de=f[I+1],(de&192)===128&&(Ie=(v&31)<<6|de&63,Ie>127&&(P=Ie));break;case 3:de=f[I+1],oe=f[I+2],(de&192)===128&&(oe&192)===128&&(Ie=(v&15)<<12|(de&63)<<6|oe&63,Ie>2047&&(Ie<55296||Ie>57343)&&(P=Ie));break;case 4:de=f[I+1],oe=f[I+2],we=f[I+3],(de&192)===128&&(oe&192)===128&&(we&192)===128&&(Ie=(v&15)<<18|(de&63)<<12|(oe&63)<<6|we&63,Ie>65535&&Ie<1114112&&(P=Ie))}}P===null?(P=65533,H=1):P>65535&&(P-=65536,w.push(P>>>10&1023|55296),P=56320|P&1023),w.push(P),I+=H}return z(w)}let Z=4096;function z(f){let u=f.length;if(u<=Z)return String.fromCharCode.apply(String,f);let p="",w=0;for(;ww)&&(p=w);let I="";for(let v=u;vp&&(f=p),u<0?(u+=p,u<0&&(u=0)):u>p&&(u=p),up)throw new RangeError("Trying to access beyond buffer length")}r.prototype.readUintLE=r.prototype.readUIntLE=function(f,u,p){f=f>>>0,u=u>>>0,p||ne(f,u,this.length);let w=this[f],I=1,v=0;for(;++v>>0,u=u>>>0,p||ne(f,u,this.length);let w=this[f+--u],I=1;for(;u>0&&(I*=256);)w+=this[f+--u]*I;return w},r.prototype.readUint8=r.prototype.readUInt8=function(f,u){return f=f>>>0,u||ne(f,1,this.length),this[f]},r.prototype.readUint16LE=r.prototype.readUInt16LE=function(f,u){return f=f>>>0,u||ne(f,2,this.length),this[f]|this[f+1]<<8},r.prototype.readUint16BE=r.prototype.readUInt16BE=function(f,u){return f=f>>>0,u||ne(f,2,this.length),this[f]<<8|this[f+1]},r.prototype.readUint32LE=r.prototype.readUInt32LE=function(f,u){return f=f>>>0,u||ne(f,4,this.length),(this[f]|this[f+1]<<8|this[f+2]<<16)+this[f+3]*16777216},r.prototype.readUint32BE=r.prototype.readUInt32BE=function(f,u){return f=f>>>0,u||ne(f,4,this.length),this[f]*16777216+(this[f+1]<<16|this[f+2]<<8|this[f+3])},r.prototype.readBigUInt64LE=ke(function(f){f=f>>>0,J(f,"offset");let u=this[f],p=this[f+7];(u===void 0||p===void 0)&&ce(f,this.length-8);let w=u+this[++f]*2**8+this[++f]*2**16+this[++f]*2**24,I=this[++f]+this[++f]*2**8+this[++f]*2**16+p*2**24;return BigInt(w)+(BigInt(I)<>>0,J(f,"offset");let u=this[f],p=this[f+7];(u===void 0||p===void 0)&&ce(f,this.length-8);let w=u*2**24+this[++f]*2**16+this[++f]*2**8+this[++f],I=this[++f]*2**24+this[++f]*2**16+this[++f]*2**8+p;return(BigInt(w)<>>0,u=u>>>0,p||ne(f,u,this.length);let w=this[f],I=1,v=0;for(;++v=I&&(w-=Math.pow(2,8*u)),w},r.prototype.readIntBE=function(f,u,p){f=f>>>0,u=u>>>0,p||ne(f,u,this.length);let w=u,I=1,v=this[f+--w];for(;w>0&&(I*=256);)v+=this[f+--w]*I;return I*=128,v>=I&&(v-=Math.pow(2,8*u)),v},r.prototype.readInt8=function(f,u){return f=f>>>0,u||ne(f,1,this.length),this[f]&128?(255-this[f]+1)*-1:this[f]},r.prototype.readInt16LE=function(f,u){f=f>>>0,u||ne(f,2,this.length);let p=this[f]|this[f+1]<<8;return p&32768?p|4294901760:p},r.prototype.readInt16BE=function(f,u){f=f>>>0,u||ne(f,2,this.length);let p=this[f+1]|this[f]<<8;return p&32768?p|4294901760:p},r.prototype.readInt32LE=function(f,u){return f=f>>>0,u||ne(f,4,this.length),this[f]|this[f+1]<<8|this[f+2]<<16|this[f+3]<<24},r.prototype.readInt32BE=function(f,u){return f=f>>>0,u||ne(f,4,this.length),this[f]<<24|this[f+1]<<16|this[f+2]<<8|this[f+3]},r.prototype.readBigInt64LE=ke(function(f){f=f>>>0,J(f,"offset");let u=this[f],p=this[f+7];(u===void 0||p===void 0)&&ce(f,this.length-8);let w=this[f+4]+this[f+5]*2**8+this[f+6]*2**16+(p<<24);return(BigInt(w)<>>0,J(f,"offset");let u=this[f],p=this[f+7];(u===void 0||p===void 0)&&ce(f,this.length-8);let w=(u<<24)+this[++f]*2**16+this[++f]*2**8+this[++f];return(BigInt(w)<>>0,u||ne(f,4,this.length),o.read(this,f,!0,23,4)},r.prototype.readFloatBE=function(f,u){return f=f>>>0,u||ne(f,4,this.length),o.read(this,f,!1,23,4)},r.prototype.readDoubleLE=function(f,u){return f=f>>>0,u||ne(f,8,this.length),o.read(this,f,!0,52,8)},r.prototype.readDoubleBE=function(f,u){return f=f>>>0,u||ne(f,8,this.length),o.read(this,f,!1,52,8)};function Ee(f,u,p,w,I,v){if(!r.isBuffer(f))throw new TypeError('"buffer" argument must be a Buffer instance');if(u>I||uf.length)throw new RangeError("Index out of range")}r.prototype.writeUintLE=r.prototype.writeUIntLE=function(f,u,p,w){if(f=+f,u=u>>>0,p=p>>>0,!w){let P=Math.pow(2,8*p)-1;Ee(this,f,u,p,P,0)}let I=1,v=0;for(this[u]=f&255;++v>>0,p=p>>>0,!w){let P=Math.pow(2,8*p)-1;Ee(this,f,u,p,P,0)}let I=p-1,v=1;for(this[u+I]=f&255;--I>=0&&(v*=256);)this[u+I]=f/v&255;return u+p},r.prototype.writeUint8=r.prototype.writeUInt8=function(f,u,p){return f=+f,u=u>>>0,p||Ee(this,f,u,1,255,0),this[u]=f&255,u+1},r.prototype.writeUint16LE=r.prototype.writeUInt16LE=function(f,u,p){return f=+f,u=u>>>0,p||Ee(this,f,u,2,65535,0),this[u]=f&255,this[u+1]=f>>>8,u+2},r.prototype.writeUint16BE=r.prototype.writeUInt16BE=function(f,u,p){return f=+f,u=u>>>0,p||Ee(this,f,u,2,65535,0),this[u]=f>>>8,this[u+1]=f&255,u+2},r.prototype.writeUint32LE=r.prototype.writeUInt32LE=function(f,u,p){return f=+f,u=u>>>0,p||Ee(this,f,u,4,4294967295,0),this[u+3]=f>>>24,this[u+2]=f>>>16,this[u+1]=f>>>8,this[u]=f&255,u+4},r.prototype.writeUint32BE=r.prototype.writeUInt32BE=function(f,u,p){return f=+f,u=u>>>0,p||Ee(this,f,u,4,4294967295,0),this[u]=f>>>24,this[u+1]=f>>>16,this[u+2]=f>>>8,this[u+3]=f&255,u+4};function A(f,u,p,w,I){ee(u,w,I,f,p,7);let v=Number(u&BigInt(4294967295));f[p++]=v,v=v>>8,f[p++]=v,v=v>>8,f[p++]=v,v=v>>8,f[p++]=v;let P=Number(u>>BigInt(32)&BigInt(4294967295));return f[p++]=P,P=P>>8,f[p++]=P,P=P>>8,f[p++]=P,P=P>>8,f[p++]=P,p}function Q(f,u,p,w,I){ee(u,w,I,f,p,7);let v=Number(u&BigInt(4294967295));f[p+7]=v,v=v>>8,f[p+6]=v,v=v>>8,f[p+5]=v,v=v>>8,f[p+4]=v;let P=Number(u>>BigInt(32)&BigInt(4294967295));return f[p+3]=P,P=P>>8,f[p+2]=P,P=P>>8,f[p+1]=P,P=P>>8,f[p]=P,p+8}r.prototype.writeBigUInt64LE=ke(function(f,u=0){return A(this,f,u,BigInt(0),BigInt("0xffffffffffffffff"))}),r.prototype.writeBigUInt64BE=ke(function(f,u=0){return Q(this,f,u,BigInt(0),BigInt("0xffffffffffffffff"))}),r.prototype.writeIntLE=function(f,u,p,w){if(f=+f,u=u>>>0,!w){let H=Math.pow(2,8*p-1);Ee(this,f,u,p,H-1,-H)}let I=0,v=1,P=0;for(this[u]=f&255;++I>0)-P&255;return u+p},r.prototype.writeIntBE=function(f,u,p,w){if(f=+f,u=u>>>0,!w){let H=Math.pow(2,8*p-1);Ee(this,f,u,p,H-1,-H)}let I=p-1,v=1,P=0;for(this[u+I]=f&255;--I>=0&&(v*=256);)f<0&&P===0&&this[u+I+1]!==0&&(P=1),this[u+I]=(f/v>>0)-P&255;return u+p},r.prototype.writeInt8=function(f,u,p){return f=+f,u=u>>>0,p||Ee(this,f,u,1,127,-128),f<0&&(f=255+f+1),this[u]=f&255,u+1},r.prototype.writeInt16LE=function(f,u,p){return f=+f,u=u>>>0,p||Ee(this,f,u,2,32767,-32768),this[u]=f&255,this[u+1]=f>>>8,u+2},r.prototype.writeInt16BE=function(f,u,p){return f=+f,u=u>>>0,p||Ee(this,f,u,2,32767,-32768),this[u]=f>>>8,this[u+1]=f&255,u+2},r.prototype.writeInt32LE=function(f,u,p){return f=+f,u=u>>>0,p||Ee(this,f,u,4,2147483647,-2147483648),this[u]=f&255,this[u+1]=f>>>8,this[u+2]=f>>>16,this[u+3]=f>>>24,u+4},r.prototype.writeInt32BE=function(f,u,p){return f=+f,u=u>>>0,p||Ee(this,f,u,4,2147483647,-2147483648),f<0&&(f=4294967295+f+1),this[u]=f>>>24,this[u+1]=f>>>16,this[u+2]=f>>>8,this[u+3]=f&255,u+4},r.prototype.writeBigInt64LE=ke(function(f,u=0){return A(this,f,u,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),r.prototype.writeBigInt64BE=ke(function(f,u=0){return Q(this,f,u,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function fe(f,u,p,w,I,v){if(p+w>f.length)throw new RangeError("Index out of range");if(p<0)throw new RangeError("Index out of range")}function Ae(f,u,p,w,I){return u=+u,p=p>>>0,I||fe(f,u,p,4),o.write(f,u,p,w,23,4),p+4}r.prototype.writeFloatLE=function(f,u,p){return Ae(this,f,u,!0,p)},r.prototype.writeFloatBE=function(f,u,p){return Ae(this,f,u,!1,p)};function ae(f,u,p,w,I){return u=+u,p=p>>>0,I||fe(f,u,p,8),o.write(f,u,p,w,52,8),p+8}r.prototype.writeDoubleLE=function(f,u,p){return ae(this,f,u,!0,p)},r.prototype.writeDoubleBE=function(f,u,p){return ae(this,f,u,!1,p)},r.prototype.copy=function(f,u,p,w){if(!r.isBuffer(f))throw new TypeError("argument should be a Buffer");if(p||(p=0),!w&&w!==0&&(w=this.length),u>=f.length&&(u=f.length),u||(u=0),w>0&&w=this.length)throw new RangeError("Index out of range");if(w<0)throw new RangeError("sourceEnd out of bounds");w>this.length&&(w=this.length),f.length-u>>0,p=p===void 0?this.length:p>>>0,f||(f=0);let I;if(typeof f=="number")for(I=u;I2**32?I=Y(String(p)):typeof p=="bigint"&&(I=String(p),(p>BigInt(2)**BigInt(32)||p<-(BigInt(2)**BigInt(32)))&&(I=Y(I)),I+="n"),w+=` It must be ${u}. Received ${I}`,w},RangeError);function Y(f){let u="",p=f.length,w=f[0]==="-"?1:0;for(;p>=w+4;p-=3)u=`_${f.slice(p-3,p)}${u}`;return`${f.slice(0,p)}${u}`}function se(f,u,p){J(u,"offset"),(f[u]===void 0||f[u+p]===void 0)&&ce(u,f.length-(p+1))}function ee(f,u,p,w,I,v){if(f>p||f= 0${P} and < 2${P} ** ${(v+1)*8}${P}`:H=`>= -(2${P} ** ${(v+1)*8-1}${P}) and < 2 ** ${(v+1)*8-1}${P}`,new B.ERR_OUT_OF_RANGE("value",H,f)}se(w,I,v)}function J(f,u){if(typeof f!="number")throw new B.ERR_INVALID_ARG_TYPE(u,"number",f)}function ce(f,u,p){throw Math.floor(f)!==f?(J(f,p),new B.ERR_OUT_OF_RANGE("offset","an integer",f)):u<0?new B.ERR_BUFFER_OUT_OF_BOUNDS:new B.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${u}`,f)}let pe=/[^+/0-9A-Za-z-_]/g;function k(f){if(f=f.split("=")[0],f=f.trim().replace(pe,""),f.length<2)return"";for(;f.length%4!==0;)f=f+"=";return f}function N(f,u){u=u||1/0;let p,w=f.length,I=null,v=[];for(let P=0;P55295&&p<57344){if(!I){if(p>56319){(u-=3)>-1&&v.push(239,191,189);continue}else if(P+1===w){(u-=3)>-1&&v.push(239,191,189);continue}I=p;continue}if(p<56320){(u-=3)>-1&&v.push(239,191,189),I=p;continue}p=(I-55296<<10|p-56320)+65536}else I&&(u-=3)>-1&&v.push(239,191,189);if(I=null,p<128){if((u-=1)<0)break;v.push(p)}else if(p<2048){if((u-=2)<0)break;v.push(p>>6|192,p&63|128)}else if(p<65536){if((u-=3)<0)break;v.push(p>>12|224,p>>6&63|128,p&63|128)}else if(p<1114112){if((u-=4)<0)break;v.push(p>>18|240,p>>12&63|128,p>>6&63|128,p&63|128)}else throw new Error("Invalid code point")}return v}function D(f){let u=[];for(let p=0;p>8,I=p%256,v.push(I),v.push(w);return v}function G(f){return e.toByteArray(k(f))}function j(f,u,p,w){let I;for(I=0;I=u.length||I>=f.length);++I)u[I+p]=f[I];return I}function K(f,u){return f instanceof u||f!=null&&f.constructor!=null&&f.constructor.name!=null&&f.constructor.name===u.name}function ve(f){return f!==f}let Se=function(){let f="0123456789abcdef",u=new Array(256);for(let p=0;p<16;++p){let w=p*16;for(let I=0;I<16;++I)u[w+I]=f[p]+f[I]}return u}();function ke(f){return typeof BigInt>"u"?Ue:f}function Ue(){throw new Error("BigInt not supported")}return Zt}var Er,Ai,Br,Ii,Zt,Ti,Ft,Vr,Oo,Co,dt=ct(()=>{he(),ue(),le(),Er={},Ai=!1,Br={},Ii=!1,Zt={},Ti=!1,Ft=fl(),Ft.Buffer,Ft.SlowBuffer,Ft.INSPECT_MAX_BYTES,Ft.kMaxLength,Vr=Ft.Buffer,Oo=Ft.INSPECT_MAX_BYTES,Co=Ft.kMaxLength}),he=ct(()=>{dt()}),dl=ye(e=>{he(),ue(),le(),Object.defineProperty(e,"__esModule",{value:!0});var o=class{constructor(t){this.aliasToTopic={},this.max=t}put(t,l){return l===0||l>this.max?!1:(this.aliasToTopic[l]=t,this.length=Object.keys(this.aliasToTopic).length,!0)}getTopicByAlias(t){return this.aliasToTopic[t]}clear(){this.aliasToTopic={}}};e.default=o}),st=ye((e,o)=>{he(),ue(),le(),o.exports={ArrayIsArray(t){return Array.isArray(t)},ArrayPrototypeIncludes(t,l){return t.includes(l)},ArrayPrototypeIndexOf(t,l){return t.indexOf(l)},ArrayPrototypeJoin(t,l){return t.join(l)},ArrayPrototypeMap(t,l){return t.map(l)},ArrayPrototypePop(t,l){return t.pop(l)},ArrayPrototypePush(t,l){return t.push(l)},ArrayPrototypeSlice(t,l,h){return t.slice(l,h)},Error,FunctionPrototypeCall(t,l,...h){return t.call(l,...h)},FunctionPrototypeSymbolHasInstance(t,l){return Function.prototype[Symbol.hasInstance].call(t,l)},MathFloor:Math.floor,Number,NumberIsInteger:Number.isInteger,NumberIsNaN:Number.isNaN,NumberMAX_SAFE_INTEGER:Number.MAX_SAFE_INTEGER,NumberMIN_SAFE_INTEGER:Number.MIN_SAFE_INTEGER,NumberParseInt:Number.parseInt,ObjectDefineProperties(t,l){return Object.defineProperties(t,l)},ObjectDefineProperty(t,l,h){return Object.defineProperty(t,l,h)},ObjectGetOwnPropertyDescriptor(t,l){return Object.getOwnPropertyDescriptor(t,l)},ObjectKeys(t){return Object.keys(t)},ObjectSetPrototypeOf(t,l){return Object.setPrototypeOf(t,l)},Promise,PromisePrototypeCatch(t,l){return t.catch(l)},PromisePrototypeThen(t,l,h){return t.then(l,h)},PromiseReject(t){return Promise.reject(t)},ReflectApply:Reflect.apply,RegExpPrototypeTest(t,l){return t.test(l)},SafeSet:Set,String,StringPrototypeSlice(t,l,h){return t.slice(l,h)},StringPrototypeToLowerCase(t){return t.toLowerCase()},StringPrototypeToUpperCase(t){return t.toUpperCase()},StringPrototypeTrim(t){return t.trim()},Symbol,SymbolFor:Symbol.for,SymbolAsyncIterator:Symbol.asyncIterator,SymbolHasInstance:Symbol.hasInstance,SymbolIterator:Symbol.iterator,TypedArrayPrototypeSet(t,l,h){return t.set(l,h)},Uint8Array}}),Wt=ye((e,o)=>{he(),ue(),le();var t=(dt(),Ve(ft)),l=Object.getPrototypeOf(async function(){}).constructor,h=globalThis.Blob||t.Blob,i=typeof h<"u"?function(s){return s instanceof h}:function(s){return!1},r=class extends Error{constructor(s){if(!Array.isArray(s))throw new TypeError(`Expected input to be an Array, got ${typeof s}`);let n="";for(let a=0;a{s=a,n=c}),resolve:s,reject:n}},promisify(s){return new Promise((n,a)=>{s((c,...d)=>c?a(c):n(...d))})},debuglog(){return function(){}},format(s,...n){return s.replace(/%([sdifj])/g,function(...[a,c]){let d=n.shift();return c==="f"?d.toFixed(6):c==="j"?JSON.stringify(d):c==="s"&&typeof d=="object"?`${d.constructor!==Object?d.constructor.name:""} {}`.trim():d.toString()})},inspect(s){switch(typeof s){case"string":if(s.includes("'"))if(s.includes('"')){if(!s.includes("`")&&!s.includes("${"))return`\`${s}\``}else return`"${s}"`;return`'${s}'`;case"number":return isNaN(s)?"NaN":Object.is(s,-0)?String(s):s;case"bigint":return`${String(s)}n`;case"boolean":case"undefined":return String(s);case"object":return"{}"}},types:{isAsyncFunction(s){return s instanceof l},isArrayBufferView(s){return ArrayBuffer.isView(s)}},isBlob:i},o.exports.promisify.custom=Symbol.for("nodejs.util.promisify.custom")}),ki=ye((e,o)=>{he(),ue(),le();var{AbortController:t,AbortSignal:l}=typeof self<"u"?self:typeof window<"u"?window:void 0;o.exports=t,o.exports.AbortSignal=l,o.exports.default=t}),yt=ye((e,o)=>{he(),ue(),le();var{format:t,inspect:l,AggregateError:h}=Wt(),i=globalThis.AggregateError||h,r=Symbol("kIsNodeError"),s=["string","function","number","object","Function","Object","boolean","bigint","symbol"],n=/^([A-Z][a-z0-9]*)+$/,a="__node_internal_",c={};function d(S,R){if(!S)throw new c.ERR_INTERNAL_ASSERTION(R)}function g(S){let R="",F=S.length,W=S[0]==="-"?1:0;for(;F>=W+4;F-=3)R=`_${S.slice(F-3,F)}${R}`;return`${S.slice(0,F)}${R}`}function b(S,R,F){if(typeof R=="function")return d(R.length<=F.length,`Code: ${S}; The provided arguments length (${F.length}) does not match the required ones (${R.length}).`),R(...F);let W=(R.match(/%[dfijoOs]/g)||[]).length;return d(W===F.length,`Code: ${S}; The provided arguments length (${F.length}) does not match the required ones (${W}).`),F.length===0?R:t(R,...F)}function m(S,R,F){F||(F=Error);class W extends F{constructor(...O){super(b(S,R,O))}toString(){return`${this.name} [${S}]: ${this.message}`}}Object.defineProperties(W.prototype,{name:{value:F.name,writable:!0,enumerable:!1,configurable:!0},toString:{value(){return`${this.name} [${S}]: ${this.message}`},writable:!0,enumerable:!1,configurable:!0}}),W.prototype.code=S,W.prototype[r]=!0,c[S]=W}function y(S){let R=a+S.name;return Object.defineProperty(S,"name",{value:R}),S}function T(S,R){if(S&&R&&S!==R){if(Array.isArray(R.errors))return R.errors.push(S),R;let F=new i([R,S],R.message);return F.code=R.code,F}return S||R}var U=class extends Error{constructor(S="The operation was aborted",R=void 0){if(R!==void 0&&typeof R!="object")throw new c.ERR_INVALID_ARG_TYPE("options","Object",R);super(S,R),this.code="ABORT_ERR",this.name="AbortError"}};m("ERR_ASSERTION","%s",Error),m("ERR_INVALID_ARG_TYPE",(S,R,F)=>{d(typeof S=="string","'name' must be a string"),Array.isArray(R)||(R=[R]);let W="The ";S.endsWith(" argument")?W+=`${S} `:W+=`"${S}" ${S.includes(".")?"property":"argument"} `,W+="must be ";let C=[],O=[],M=[];for(let X of R)d(typeof X=="string","All expected entries have to be of type string"),s.includes(X)?C.push(X.toLowerCase()):n.test(X)?O.push(X):(d(X!=="object",'The value "object" should be written as "Object"'),M.push(X));if(O.length>0){let X=C.indexOf("object");X!==-1&&(C.splice(C,X,1),O.push("Object"))}if(C.length>0){switch(C.length){case 1:W+=`of type ${C[0]}`;break;case 2:W+=`one of type ${C[0]} or ${C[1]}`;break;default:{let X=C.pop();W+=`one of type ${C.join(", ")}, or ${X}`}}(O.length>0||M.length>0)&&(W+=" or ")}if(O.length>0){switch(O.length){case 1:W+=`an instance of ${O[0]}`;break;case 2:W+=`an instance of ${O[0]} or ${O[1]}`;break;default:{let X=O.pop();W+=`an instance of ${O.join(", ")}, or ${X}`}}M.length>0&&(W+=" or ")}switch(M.length){case 0:break;case 1:M[0].toLowerCase()!==M[0]&&(W+="an "),W+=`${M[0]}`;break;case 2:W+=`one of ${M[0]} or ${M[1]}`;break;default:{let X=M.pop();W+=`one of ${M.join(", ")}, or ${X}`}}if(F==null)W+=`. Received ${F}`;else if(typeof F=="function"&&F.name)W+=`. Received function ${F.name}`;else if(typeof F=="object"){var $;if(($=F.constructor)!==null&&$!==void 0&&$.name)W+=`. Received an instance of ${F.constructor.name}`;else{let X=l(F,{depth:-1});W+=`. Received ${X}`}}else{let X=l(F,{colors:!1});X.length>25&&(X=`${X.slice(0,25)}...`),W+=`. Received type ${typeof F} (${X})`}return W},TypeError),m("ERR_INVALID_ARG_VALUE",(S,R,F="is invalid")=>{let W=l(R);return W.length>128&&(W=W.slice(0,128)+"..."),`The ${S.includes(".")?"property":"argument"} '${S}' ${F}. Received ${W}`},TypeError),m("ERR_INVALID_RETURN_VALUE",(S,R,F)=>{var W;let C=F!=null&&(W=F.constructor)!==null&&W!==void 0&&W.name?`instance of ${F.constructor.name}`:`type ${typeof F}`;return`Expected ${S} to be returned from the "${R}" function but got ${C}.`},TypeError),m("ERR_MISSING_ARGS",(...S)=>{d(S.length>0,"At least one arg needs to be specified");let R,F=S.length;switch(S=(Array.isArray(S)?S:[S]).map(W=>`"${W}"`).join(" or "),F){case 1:R+=`The ${S[0]} argument`;break;case 2:R+=`The ${S[0]} and ${S[1]} arguments`;break;default:{let W=S.pop();R+=`The ${S.join(", ")}, and ${W} arguments`}break}return`${R} must be specified`},TypeError),m("ERR_OUT_OF_RANGE",(S,R,F)=>{d(R,'Missing "range" argument');let W;return Number.isInteger(F)&&Math.abs(F)>2**32?W=g(String(F)):typeof F=="bigint"?(W=String(F),(F>2n**32n||F<-(2n**32n))&&(W=g(W)),W+="n"):W=l(F),`The value of "${S}" is out of range. It must be ${R}. Received ${W}`},RangeError),m("ERR_MULTIPLE_CALLBACK","Callback called multiple times",Error),m("ERR_METHOD_NOT_IMPLEMENTED","The %s method is not implemented",Error),m("ERR_STREAM_ALREADY_FINISHED","Cannot call %s after a stream was finished",Error),m("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable",Error),m("ERR_STREAM_DESTROYED","Cannot call %s after a stream was destroyed",Error),m("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),m("ERR_STREAM_PREMATURE_CLOSE","Premature close",Error),m("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF",Error),m("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event",Error),m("ERR_STREAM_WRITE_AFTER_END","write after end",Error),m("ERR_UNKNOWN_ENCODING","Unknown encoding: %s",TypeError),o.exports={AbortError:U,aggregateTwoErrors:y(T),hideStackFrames:y,codes:c}}),Hr=ye((e,o)=>{he(),ue(),le();var{ArrayIsArray:t,ArrayPrototypeIncludes:l,ArrayPrototypeJoin:h,ArrayPrototypeMap:i,NumberIsInteger:r,NumberIsNaN:s,NumberMAX_SAFE_INTEGER:n,NumberMIN_SAFE_INTEGER:a,NumberParseInt:c,ObjectPrototypeHasOwnProperty:d,RegExpPrototypeExec:g,String:b,StringPrototypeToUpperCase:m,StringPrototypeTrim:y}=st(),{hideStackFrames:T,codes:{ERR_SOCKET_BAD_PORT:U,ERR_INVALID_ARG_TYPE:S,ERR_INVALID_ARG_VALUE:R,ERR_OUT_OF_RANGE:F,ERR_UNKNOWN_SIGNAL:W}}=yt(),{normalizeEncoding:C}=Wt(),{isAsyncFunction:O,isArrayBufferView:M}=Wt().types,$={};function X(j){return j===(j|0)}function te(j){return j===j>>>0}var E=/^[0-7]+$/,q="must be a 32-bit unsigned integer or an octal string";function Z(j,K,ve){if(typeof j>"u"&&(j=ve),typeof j=="string"){if(g(E,j)===null)throw new R(K,j,q);j=c(j,8)}return ie(j,K),j}var z=T((j,K,ve=a,Se=n)=>{if(typeof j!="number")throw new S(K,"number",j);if(!r(j))throw new F(K,"an integer",j);if(jSe)throw new F(K,`>= ${ve} && <= ${Se}`,j)}),be=T((j,K,ve=-2147483648,Se=2147483647)=>{if(typeof j!="number")throw new S(K,"number",j);if(!r(j))throw new F(K,"an integer",j);if(jSe)throw new F(K,`>= ${ve} && <= ${Se}`,j)}),ie=T((j,K,ve=!1)=>{if(typeof j!="number")throw new S(K,"number",j);if(!r(j))throw new F(K,"an integer",j);let Se=ve?1:0,ke=4294967295;if(jke)throw new F(K,`>= ${Se} && <= ${ke}`,j)});function V(j,K){if(typeof j!="string")throw new S(K,"string",j)}function me(j,K,ve=void 0,Se){if(typeof j!="number")throw new S(K,"number",j);if(ve!=null&&jSe||(ve!=null||Se!=null)&&s(j))throw new F(K,`${ve!=null?`>= ${ve}`:""}${ve!=null&&Se!=null?" && ":""}${Se!=null?`<= ${Se}`:""}`,j)}var ne=T((j,K,ve)=>{if(!l(ve,j)){let Se="must be one of: "+h(i(ve,ke=>typeof ke=="string"?`'${ke}'`:b(ke)),", ");throw new R(K,j,Se)}});function Ee(j,K){if(typeof j!="boolean")throw new S(K,"boolean",j)}function A(j,K,ve){return j==null||!d(j,K)?ve:j[K]}var Q=T((j,K,ve=null)=>{let Se=A(ve,"allowArray",!1),ke=A(ve,"allowFunction",!1);if(!A(ve,"nullable",!1)&&j===null||!Se&&t(j)||typeof j!="object"&&(!ke||typeof j!="function"))throw new S(K,"Object",j)}),fe=T((j,K)=>{if(j!=null&&typeof j!="object"&&typeof j!="function")throw new S(K,"a dictionary",j)}),Ae=T((j,K,ve=0)=>{if(!t(j))throw new S(K,"Array",j);if(j.length{if(!M(j))throw new S(K,["Buffer","TypedArray","DataView"],j)});function se(j,K){let ve=C(K),Se=j.length;if(ve==="hex"&&Se%2!==0)throw new R("encoding",K,`is invalid for data of length ${Se}`)}function ee(j,K="Port",ve=!0){if(typeof j!="number"&&typeof j!="string"||typeof j=="string"&&y(j).length===0||+j!==+j>>>0||j>65535||j===0&&!ve)throw new U(K,j,ve);return j|0}var J=T((j,K)=>{if(j!==void 0&&(j===null||typeof j!="object"||!("aborted"in j)))throw new S(K,"AbortSignal",j)}),ce=T((j,K)=>{if(typeof j!="function")throw new S(K,"Function",j)}),pe=T((j,K)=>{if(typeof j!="function"||O(j))throw new S(K,"Function",j)}),k=T((j,K)=>{if(j!==void 0)throw new S(K,"undefined",j)});function N(j,K,ve){if(!l(ve,j))throw new S(K,`('${h(ve,"|")}')`,j)}var D=/^(?:<[^>]*>)(?:\s*;\s*[^;"\s]+(?:=(")?[^;"\s]*\1)?)*$/;function re(j,K){if(typeof j>"u"||!g(D,j))throw new R(K,j,'must be an array or string of format "; rel=preload; as=style"')}function G(j){if(typeof j=="string")return re(j,"hints"),j;if(t(j)){let K=j.length,ve="";if(K===0)return ve;for(let Se=0;Se; rel=preload; as=style"')}o.exports={isInt32:X,isUint32:te,parseFileMode:Z,validateArray:Ae,validateStringArray:ae,validateBooleanArray:B,validateBoolean:Ee,validateBuffer:Y,validateDictionary:fe,validateEncoding:se,validateFunction:ce,validateInt32:be,validateInteger:z,validateNumber:me,validateObject:Q,validateOneOf:ne,validatePlainFunction:pe,validatePort:ee,validateSignalName:_,validateString:V,validateUint32:ie,validateUndefined:k,validateUnion:N,validateAbortSignal:J,validateLinkHeaderValue:G}}),ar=ye((e,o)=>{he(),ue(),le();var t=o.exports={},l,h;function i(){throw new Error("setTimeout has not been defined")}function r(){throw new Error("clearTimeout has not been defined")}(function(){try{typeof setTimeout=="function"?l=setTimeout:l=i}catch{l=i}try{typeof clearTimeout=="function"?h=clearTimeout:h=r}catch{h=r}})();function s(U){if(l===setTimeout)return setTimeout(U,0);if((l===i||!l)&&setTimeout)return l=setTimeout,setTimeout(U,0);try{return l(U,0)}catch{try{return l.call(null,U,0)}catch{return l.call(this,U,0)}}}function n(U){if(h===clearTimeout)return clearTimeout(U);if((h===r||!h)&&clearTimeout)return h=clearTimeout,clearTimeout(U);try{return h(U)}catch{try{return h.call(null,U)}catch{return h.call(this,U)}}}var a=[],c=!1,d,g=-1;function b(){!c||!d||(c=!1,d.length?a=d.concat(a):g=-1,a.length&&m())}function m(){if(!c){var U=s(b);c=!0;for(var S=a.length;S;){for(d=a,a=[];++g1)for(var R=1;R{he(),ue(),le();var{Symbol:t,SymbolAsyncIterator:l,SymbolIterator:h,SymbolFor:i}=st(),r=t("kDestroyed"),s=t("kIsErrored"),n=t("kIsReadable"),a=t("kIsDisturbed"),c=i("nodejs.webstream.isClosedPromise"),d=i("nodejs.webstream.controllerErrorFunction");function g(A,Q=!1){var fe;return!!(A&&typeof A.pipe=="function"&&typeof A.on=="function"&&(!Q||typeof A.pause=="function"&&typeof A.resume=="function")&&(!A._writableState||((fe=A._readableState)===null||fe===void 0?void 0:fe.readable)!==!1)&&(!A._writableState||A._readableState))}function b(A){var Q;return!!(A&&typeof A.write=="function"&&typeof A.on=="function"&&(!A._readableState||((Q=A._writableState)===null||Q===void 0?void 0:Q.writable)!==!1))}function m(A){return!!(A&&typeof A.pipe=="function"&&A._readableState&&typeof A.on=="function"&&typeof A.write=="function")}function y(A){return A&&(A._readableState||A._writableState||typeof A.write=="function"&&typeof A.on=="function"||typeof A.pipe=="function"&&typeof A.on=="function")}function T(A){return!!(A&&!y(A)&&typeof A.pipeThrough=="function"&&typeof A.getReader=="function"&&typeof A.cancel=="function")}function U(A){return!!(A&&!y(A)&&typeof A.getWriter=="function"&&typeof A.abort=="function")}function S(A){return!!(A&&!y(A)&&typeof A.readable=="object"&&typeof A.writable=="object")}function R(A){return T(A)||U(A)||S(A)}function F(A,Q){return A==null?!1:Q===!0?typeof A[l]=="function":Q===!1?typeof A[h]=="function":typeof A[l]=="function"||typeof A[h]=="function"}function W(A){if(!y(A))return null;let Q=A._writableState,fe=A._readableState,Ae=Q||fe;return!!(A.destroyed||A[r]||Ae!=null&&Ae.destroyed)}function C(A){if(!b(A))return null;if(A.writableEnded===!0)return!0;let Q=A._writableState;return Q!=null&&Q.errored?!1:typeof(Q==null?void 0:Q.ended)!="boolean"?null:Q.ended}function O(A,Q){if(!b(A))return null;if(A.writableFinished===!0)return!0;let fe=A._writableState;return fe!=null&&fe.errored?!1:typeof(fe==null?void 0:fe.finished)!="boolean"?null:!!(fe.finished||Q===!1&&fe.ended===!0&&fe.length===0)}function M(A){if(!g(A))return null;if(A.readableEnded===!0)return!0;let Q=A._readableState;return!Q||Q.errored?!1:typeof(Q==null?void 0:Q.ended)!="boolean"?null:Q.ended}function $(A,Q){if(!g(A))return null;let fe=A._readableState;return fe!=null&&fe.errored?!1:typeof(fe==null?void 0:fe.endEmitted)!="boolean"?null:!!(fe.endEmitted||Q===!1&&fe.ended===!0&&fe.length===0)}function X(A){return A&&A[n]!=null?A[n]:typeof(A==null?void 0:A.readable)!="boolean"?null:W(A)?!1:g(A)&&A.readable&&!$(A)}function te(A){return typeof(A==null?void 0:A.writable)!="boolean"?null:W(A)?!1:b(A)&&A.writable&&!C(A)}function E(A,Q){return y(A)?W(A)?!0:!((Q==null?void 0:Q.readable)!==!1&&X(A)||(Q==null?void 0:Q.writable)!==!1&&te(A)):null}function q(A){var Q,fe;return y(A)?A.writableErrored?A.writableErrored:(Q=(fe=A._writableState)===null||fe===void 0?void 0:fe.errored)!==null&&Q!==void 0?Q:null:null}function Z(A){var Q,fe;return y(A)?A.readableErrored?A.readableErrored:(Q=(fe=A._readableState)===null||fe===void 0?void 0:fe.errored)!==null&&Q!==void 0?Q:null:null}function z(A){if(!y(A))return null;if(typeof A.closed=="boolean")return A.closed;let Q=A._writableState,fe=A._readableState;return typeof(Q==null?void 0:Q.closed)=="boolean"||typeof(fe==null?void 0:fe.closed)=="boolean"?(Q==null?void 0:Q.closed)||(fe==null?void 0:fe.closed):typeof A._closed=="boolean"&&be(A)?A._closed:null}function be(A){return typeof A._closed=="boolean"&&typeof A._defaultKeepAlive=="boolean"&&typeof A._removedConnection=="boolean"&&typeof A._removedContLen=="boolean"}function ie(A){return typeof A._sent100=="boolean"&&be(A)}function V(A){var Q;return typeof A._consuming=="boolean"&&typeof A._dumped=="boolean"&&((Q=A.req)===null||Q===void 0?void 0:Q.upgradeOrConnect)===void 0}function me(A){if(!y(A))return null;let Q=A._writableState,fe=A._readableState,Ae=Q||fe;return!Ae&&ie(A)||!!(Ae&&Ae.autoDestroy&&Ae.emitClose&&Ae.closed===!1)}function ne(A){var Q;return!!(A&&((Q=A[a])!==null&&Q!==void 0?Q:A.readableDidRead||A.readableAborted))}function Ee(A){var Q,fe,Ae,ae,B,_,Y,se,ee,J;return!!(A&&((Q=(fe=(Ae=(ae=(B=(_=A[s])!==null&&_!==void 0?_:A.readableErrored)!==null&&B!==void 0?B:A.writableErrored)!==null&&ae!==void 0?ae:(Y=A._readableState)===null||Y===void 0?void 0:Y.errorEmitted)!==null&&Ae!==void 0?Ae:(se=A._writableState)===null||se===void 0?void 0:se.errorEmitted)!==null&&fe!==void 0?fe:(ee=A._readableState)===null||ee===void 0?void 0:ee.errored)!==null&&Q!==void 0?Q:!((J=A._writableState)===null||J===void 0)&&J.errored))}o.exports={kDestroyed:r,isDisturbed:ne,kIsDisturbed:a,isErrored:Ee,kIsErrored:s,isReadable:X,kIsReadable:n,kIsClosedPromise:c,kControllerErrorFunction:d,isClosed:z,isDestroyed:W,isDuplexNodeStream:m,isFinished:E,isIterable:F,isReadableNodeStream:g,isReadableStream:T,isReadableEnded:M,isReadableFinished:$,isReadableErrored:Z,isNodeStream:y,isWebStream:R,isWritable:te,isWritableNodeStream:b,isWritableStream:U,isWritableEnded:C,isWritableFinished:O,isWritableErrored:q,isServerRequest:V,isServerResponse:ie,willEmitClose:me,isTransformStream:S}}),er=ye((e,o)=>{he(),ue(),le();var t=ar(),{AbortError:l,codes:h}=yt(),{ERR_INVALID_ARG_TYPE:i,ERR_STREAM_PREMATURE_CLOSE:r}=h,{kEmptyObject:s,once:n}=Wt(),{validateAbortSignal:a,validateFunction:c,validateObject:d,validateBoolean:g}=Hr(),{Promise:b,PromisePrototypeThen:m}=st(),{isClosed:y,isReadable:T,isReadableNodeStream:U,isReadableStream:S,isReadableFinished:R,isReadableErrored:F,isWritable:W,isWritableNodeStream:C,isWritableStream:O,isWritableFinished:M,isWritableErrored:$,isNodeStream:X,willEmitClose:te,kIsClosedPromise:E}=$t();function q(V){return V.setHeader&&typeof V.abort=="function"}var Z=()=>{};function z(V,me,ne){var Ee,A;if(arguments.length===2?(ne=me,me=s):me==null?me=s:d(me,"options"),c(ne,"callback"),a(me.signal,"options.signal"),ne=n(ne),S(V)||O(V))return be(V,me,ne);if(!X(V))throw new i("stream",["ReadableStream","WritableStream","Stream"],V);let Q=(Ee=me.readable)!==null&&Ee!==void 0?Ee:U(V),fe=(A=me.writable)!==null&&A!==void 0?A:C(V),Ae=V._writableState,ae=V._readableState,B=()=>{V.writable||se()},_=te(V)&&U(V)===Q&&C(V)===fe,Y=M(V,!1),se=()=>{Y=!0,V.destroyed&&(_=!1),!(_&&(!V.readable||Q))&&(!Q||ee)&&ne.call(V)},ee=R(V,!1),J=()=>{ee=!0,V.destroyed&&(_=!1),!(_&&(!V.writable||fe))&&(!fe||Y)&&ne.call(V)},ce=G=>{ne.call(V,G)},pe=y(V),k=()=>{pe=!0;let G=$(V)||F(V);if(G&&typeof G!="boolean")return ne.call(V,G);if(Q&&!ee&&U(V,!0)&&!R(V,!1))return ne.call(V,new r);if(fe&&!Y&&!M(V,!1))return ne.call(V,new r);ne.call(V)},N=()=>{pe=!0;let G=$(V)||F(V);if(G&&typeof G!="boolean")return ne.call(V,G);ne.call(V)},D=()=>{V.req.on("finish",se)};q(V)?(V.on("complete",se),_||V.on("abort",k),V.req?D():V.on("request",D)):fe&&!Ae&&(V.on("end",B),V.on("close",B)),!_&&typeof V.aborted=="boolean"&&V.on("aborted",k),V.on("end",J),V.on("finish",se),me.error!==!1&&V.on("error",ce),V.on("close",k),pe?t.nextTick(k):Ae!=null&&Ae.errorEmitted||ae!=null&&ae.errorEmitted?_||t.nextTick(N):(!Q&&(!_||T(V))&&(Y||W(V)===!1)||!fe&&(!_||W(V))&&(ee||T(V)===!1)||ae&&V.req&&V.aborted)&&t.nextTick(N);let re=()=>{ne=Z,V.removeListener("aborted",k),V.removeListener("complete",se),V.removeListener("abort",k),V.removeListener("request",D),V.req&&V.req.removeListener("finish",se),V.removeListener("end",B),V.removeListener("close",B),V.removeListener("finish",se),V.removeListener("end",J),V.removeListener("error",ce),V.removeListener("close",k)};if(me.signal&&!pe){let G=()=>{let j=ne;re(),j.call(V,new l(void 0,{cause:me.signal.reason}))};if(me.signal.aborted)t.nextTick(G);else{let j=ne;ne=n((...K)=>{me.signal.removeEventListener("abort",G),j.apply(V,K)}),me.signal.addEventListener("abort",G)}}return re}function be(V,me,ne){let Ee=!1,A=Z;if(me.signal)if(A=()=>{Ee=!0,ne.call(V,new l(void 0,{cause:me.signal.reason}))},me.signal.aborted)t.nextTick(A);else{let fe=ne;ne=n((...Ae)=>{me.signal.removeEventListener("abort",A),fe.apply(V,Ae)}),me.signal.addEventListener("abort",A)}let Q=(...fe)=>{Ee||t.nextTick(()=>ne.apply(V,fe))};return m(V[E].promise,Q,Q),Z}function ie(V,me){var ne;let Ee=!1;return me===null&&(me=s),(ne=me)!==null&&ne!==void 0&&ne.cleanup&&(g(me.cleanup,"cleanup"),Ee=me.cleanup),new b((A,Q)=>{let fe=z(V,me,Ae=>{Ee&&fe(),Ae?Q(Ae):A()})})}o.exports=z,o.exports.finished=ie}),Sr=ye((e,o)=>{he(),ue(),le();var t=ar(),{aggregateTwoErrors:l,codes:{ERR_MULTIPLE_CALLBACK:h},AbortError:i}=yt(),{Symbol:r}=st(),{kDestroyed:s,isDestroyed:n,isFinished:a,isServerRequest:c}=$t(),d=r("kDestroy"),g=r("kConstruct");function b(E,q,Z){E&&(E.stack,q&&!q.errored&&(q.errored=E),Z&&!Z.errored&&(Z.errored=E))}function m(E,q){let Z=this._readableState,z=this._writableState,be=z||Z;return z!=null&&z.destroyed||Z!=null&&Z.destroyed?(typeof q=="function"&&q(),this):(b(E,z,Z),z&&(z.destroyed=!0),Z&&(Z.destroyed=!0),be.constructed?y(this,E,q):this.once(d,function(ie){y(this,l(ie,E),q)}),this)}function y(E,q,Z){let z=!1;function be(ie){if(z)return;z=!0;let V=E._readableState,me=E._writableState;b(ie,me,V),me&&(me.closed=!0),V&&(V.closed=!0),typeof Z=="function"&&Z(ie),ie?t.nextTick(T,E,ie):t.nextTick(U,E)}try{E._destroy(q||null,be)}catch(ie){be(ie)}}function T(E,q){S(E,q),U(E)}function U(E){let q=E._readableState,Z=E._writableState;Z&&(Z.closeEmitted=!0),q&&(q.closeEmitted=!0),(Z!=null&&Z.emitClose||q!=null&&q.emitClose)&&E.emit("close")}function S(E,q){let Z=E._readableState,z=E._writableState;z!=null&&z.errorEmitted||Z!=null&&Z.errorEmitted||(z&&(z.errorEmitted=!0),Z&&(Z.errorEmitted=!0),E.emit("error",q))}function R(){let E=this._readableState,q=this._writableState;E&&(E.constructed=!0,E.closed=!1,E.closeEmitted=!1,E.destroyed=!1,E.errored=null,E.errorEmitted=!1,E.reading=!1,E.ended=E.readable===!1,E.endEmitted=E.readable===!1),q&&(q.constructed=!0,q.destroyed=!1,q.closed=!1,q.closeEmitted=!1,q.errored=null,q.errorEmitted=!1,q.finalCalled=!1,q.prefinished=!1,q.ended=q.writable===!1,q.ending=q.writable===!1,q.finished=q.writable===!1)}function F(E,q,Z){let z=E._readableState,be=E._writableState;if(be!=null&&be.destroyed||z!=null&&z.destroyed)return this;z!=null&&z.autoDestroy||be!=null&&be.autoDestroy?E.destroy(q):q&&(q.stack,be&&!be.errored&&(be.errored=q),z&&!z.errored&&(z.errored=q),Z?t.nextTick(S,E,q):S(E,q))}function W(E,q){if(typeof E._construct!="function")return;let Z=E._readableState,z=E._writableState;Z&&(Z.constructed=!1),z&&(z.constructed=!1),E.once(g,q),!(E.listenerCount(g)>1)&&t.nextTick(C,E)}function C(E){let q=!1;function Z(z){if(q){F(E,z??new h);return}q=!0;let be=E._readableState,ie=E._writableState,V=ie||be;be&&(be.constructed=!0),ie&&(ie.constructed=!0),V.destroyed?E.emit(d,z):z?F(E,z,!0):t.nextTick(O,E)}try{E._construct(z=>{t.nextTick(Z,z)})}catch(z){t.nextTick(Z,z)}}function O(E){E.emit(g)}function M(E){return(E==null?void 0:E.setHeader)&&typeof E.abort=="function"}function $(E){E.emit("close")}function X(E,q){E.emit("error",q),t.nextTick($,E)}function te(E,q){!E||n(E)||(!q&&!a(E)&&(q=new i),c(E)?(E.socket=null,E.destroy(q)):M(E)?E.abort():M(E.req)?E.req.abort():typeof E.destroy=="function"?E.destroy(q):typeof E.close=="function"?E.close():q?t.nextTick(X,E,q):t.nextTick($,E),E.destroyed||(E[s]=!0))}o.exports={construct:W,destroyer:te,destroy:m,undestroy:R,errorOrDestroy:F}});function $e(){$e.init.call(this)}function zr(e){if(typeof e!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function Po(e){return e._maxListeners===void 0?$e.defaultMaxListeners:e._maxListeners}function Bo(e,o,t,l){var h,i,r,s;if(zr(t),(i=e._events)===void 0?(i=e._events=Object.create(null),e._eventsCount=0):(i.newListener!==void 0&&(e.emit("newListener",o,t.listener?t.listener:t),i=e._events),r=i[o]),r===void 0)r=i[o]=t,++e._eventsCount;else if(typeof r=="function"?r=i[o]=l?[t,r]:[r,t]:l?r.unshift(t):r.push(t),(h=Po(e))>0&&r.length>h&&!r.warned){r.warned=!0;var n=new Error("Possible EventEmitter memory leak detected. "+r.length+" "+String(o)+" listeners added. Use emitter.setMaxListeners() to increase limit");n.name="MaxListenersExceededWarning",n.emitter=e,n.type=o,n.count=r.length,s=n,console&&console.warn&&console.warn(s)}return e}function pl(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function xo(e,o,t){var l={fired:!1,wrapFn:void 0,target:e,type:o,listener:t},h=pl.bind(l);return h.listener=t,l.wrapFn=h,h}function Mo(e,o,t){var l=e._events;if(l===void 0)return[];var h=l[o];return h===void 0?[]:typeof h=="function"?t?[h.listener||h]:[h]:t?function(i){for(var r=new Array(i.length),s=0;s{he(),ue(),le(),lr=typeof Reflect=="object"?Reflect:null,Ri=lr&&typeof lr.apply=="function"?lr.apply:function(e,o,t){return Function.prototype.apply.call(e,o,t)},No=lr&&typeof lr.ownKeys=="function"?lr.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)},Oi=Number.isNaN||function(e){return e!=e},jo=$e,$e.EventEmitter=$e,$e.prototype._events=void 0,$e.prototype._eventsCount=0,$e.prototype._maxListeners=void 0,Ci=10,Object.defineProperty($e,"defaultMaxListeners",{enumerable:!0,get:function(){return Ci},set:function(e){if(typeof e!="number"||e<0||Oi(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");Ci=e}}),$e.init=function(){this._events!==void 0&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},$e.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||Oi(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},$e.prototype.getMaxListeners=function(){return Po(this)},$e.prototype.emit=function(e){for(var o=[],t=1;t0&&(i=o[0]),i instanceof Error)throw i;var r=new Error("Unhandled error."+(i?" ("+i.message+")":""));throw r.context=i,r}var s=h[e];if(s===void 0)return!1;if(typeof s=="function")Ri(s,this,o);else{var n=s.length,a=Lo(s,n);for(t=0;t=0;i--)if(t[i]===o||t[i].listener===o){r=t[i].listener,h=i;break}if(h<0)return this;h===0?t.shift():function(s,n){for(;n+1=0;l--)this.removeListener(e,o[l]);return this},$e.prototype.listeners=function(e){return Mo(this,e,!0)},$e.prototype.rawListeners=function(e){return Mo(this,e,!1)},$e.listenerCount=function(e,o){return typeof e.listenerCount=="function"?e.listenerCount(o):Uo.call(e,o)},$e.prototype.listenerCount=Uo,$e.prototype.eventNames=function(){return this._eventsCount>0?No(this._events):[]},Et=jo,Et.EventEmitter,Et.defaultMaxListeners,Et.init,Et.listenerCount,Et.EventEmitter,Et.defaultMaxListeners,Et.init,Et.listenerCount}),ur={};ir(ur,{EventEmitter:()=>Fo,default:()=>Et,defaultMaxListeners:()=>Wo,init:()=>$o,listenerCount:()=>qo,on:()=>Vo,once:()=>Ho});var Fo,Wo,$o,qo,Vo,Ho,Ar=ct(()=>{he(),ue(),le(),Do(),Do(),Et.once=function(e,o){return new Promise((t,l)=>{function h(...r){i!==void 0&&e.removeListener("error",i),t(r)}let i;o!=="error"&&(i=r=>{e.removeListener(name,h),l(r)},e.once("error",i)),e.once(o,h)})},Et.on=function(e,o){let t=[],l=[],h=null,i=!1,r={async next(){let a=t.shift();if(a)return createIterResult(a,!1);if(h){let c=Promise.reject(h);return h=null,c}return i?createIterResult(void 0,!0):new Promise((c,d)=>l.push({resolve:c,reject:d}))},async return(){e.removeListener(o,s),e.removeListener("error",n),i=!0;for(let a of l)a.resolve(createIterResult(void 0,!0));return createIterResult(void 0,!0)},throw(a){h=a,e.removeListener(o,s),e.removeListener("error",n)},[Symbol.asyncIterator](){return this}};return e.on(o,s),e.on("error",n),r;function s(...a){let c=l.shift();c?c.resolve(createIterResult(a,!1)):t.push(a)}function n(a){i=!0;let c=l.shift();c?c.reject(a):h=a,r.return()}},{EventEmitter:Fo,defaultMaxListeners:Wo,init:$o,listenerCount:qo,on:Vo,once:Ho}=Et}),Pi=ye((e,o)=>{he(),ue(),le();var{ArrayIsArray:t,ObjectSetPrototypeOf:l}=st(),{EventEmitter:h}=(Ar(),Ve(ur));function i(s){h.call(this,s)}l(i.prototype,h.prototype),l(i,h),i.prototype.pipe=function(s,n){let a=this;function c(U){s.writable&&s.write(U)===!1&&a.pause&&a.pause()}a.on("data",c);function d(){a.readable&&a.resume&&a.resume()}s.on("drain",d),!s._isStdio&&(!n||n.end!==!1)&&(a.on("end",b),a.on("close",m));let g=!1;function b(){g||(g=!0,s.end())}function m(){g||(g=!0,typeof s.destroy=="function"&&s.destroy())}function y(U){T(),h.listenerCount(this,"error")===0&&this.emit("error",U)}r(a,"error",y),r(s,"error",y);function T(){a.removeListener("data",c),s.removeListener("drain",d),a.removeListener("end",b),a.removeListener("close",m),a.removeListener("error",y),s.removeListener("error",y),a.removeListener("end",T),a.removeListener("close",T),s.removeListener("close",T)}return a.on("end",T),a.on("close",T),s.on("close",T),s.emit("pipe",a),s};function r(s,n,a){if(typeof s.prependListener=="function")return s.prependListener(n,a);!s._events||!s._events[n]?s.on(n,a):t(s._events[n])?s._events[n].unshift(a):s._events[n]=[a,s._events[n]]}o.exports={Stream:i,prependListener:r}}),Kr=ye((e,o)=>{he(),ue(),le();var{AbortError:t,codes:l}=yt(),{isNodeStream:h,isWebStream:i,kControllerErrorFunction:r}=$t(),s=er(),{ERR_INVALID_ARG_TYPE:n}=l,a=(c,d)=>{if(typeof c!="object"||!("aborted"in c))throw new n(d,"AbortSignal",c)};o.exports.addAbortSignal=function(c,d){if(a(c,"signal"),!h(d)&&!i(d))throw new n("stream",["ReadableStream","WritableStream","Stream"],d);return o.exports.addAbortSignalNoValidate(c,d)},o.exports.addAbortSignalNoValidate=function(c,d){if(typeof c!="object"||!("aborted"in c))return d;let g=h(d)?()=>{d.destroy(new t(void 0,{cause:c.reason}))}:()=>{d[r](new t(void 0,{cause:c.reason}))};return c.aborted?g():(c.addEventListener("abort",g),s(d,()=>c.removeEventListener("abort",g))),d}}),gl=ye((e,o)=>{he(),ue(),le();var{StringPrototypeSlice:t,SymbolIterator:l,TypedArrayPrototypeSet:h,Uint8Array:i}=st(),{Buffer:r}=(dt(),Ve(ft)),{inspect:s}=Wt();o.exports=class{constructor(){this.head=null,this.tail=null,this.length=0}push(n){let a={data:n,next:null};this.length>0?this.tail.next=a:this.head=a,this.tail=a,++this.length}unshift(n){let a={data:n,next:this.head};this.length===0&&(this.tail=a),this.head=a,++this.length}shift(){if(this.length===0)return;let n=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,n}clear(){this.head=this.tail=null,this.length=0}join(n){if(this.length===0)return"";let a=this.head,c=""+a.data;for(;(a=a.next)!==null;)c+=n+a.data;return c}concat(n){if(this.length===0)return r.alloc(0);let a=r.allocUnsafe(n>>>0),c=this.head,d=0;for(;c;)h(a,c.data,d),d+=c.data.length,c=c.next;return a}consume(n,a){let c=this.head.data;if(ng.length)a+=g,n-=g.length;else{n===g.length?(a+=g,++d,c.next?this.head=c.next:this.head=this.tail=null):(a+=t(g,0,n),this.head=c,c.data=t(g,n));break}++d}while((c=c.next)!==null);return this.length-=d,a}_getBuffer(n){let a=r.allocUnsafe(n),c=n,d=this.head,g=0;do{let b=d.data;if(n>b.length)h(a,b,c-n),n-=b.length;else{n===b.length?(h(a,b,c-n),++g,d.next?this.head=d.next:this.head=this.tail=null):(h(a,new i(b.buffer,b.byteOffset,n),c-n),this.head=d,d.data=b.slice(n));break}++g}while((d=d.next)!==null);return this.length-=g,a}[Symbol.for("nodejs.util.inspect.custom")](n,a){return s(this,{...a,depth:0,customInspect:!1})}}}),Bi=ye((e,o)=>{he(),ue(),le();var{MathFloor:t,NumberIsInteger:l}=st(),{ERR_INVALID_ARG_VALUE:h}=yt().codes;function i(n,a,c){return n.highWaterMark!=null?n.highWaterMark:a?n[c]:null}function r(n){return n?16:16*1024}function s(n,a,c,d){let g=i(a,d,c);if(g!=null){if(!l(g)||g<0){let b=d?`options.${c}`:"options.highWaterMark";throw new h(b,g)}return t(g)}return r(n.objectMode)}o.exports={getHighWaterMark:s,getDefaultHighWaterMark:r}});function zo(e){var o=e.length;if(o%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var t=e.indexOf("=");return t===-1&&(t=o),[t,t===o?0:4-t%4]}function bl(e,o,t){for(var l,h,i=[],r=o;r>18&63]+kt[h>>12&63]+kt[h>>6&63]+kt[63&h]);return i.join("")}function qt(e){if(e>2147483647)throw new RangeError('The value "'+e+'" is invalid for option "size"');var o=new Uint8Array(e);return Object.setPrototypeOf(o,ge.prototype),o}function ge(e,o,t){if(typeof e=="number"){if(typeof o=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return xi(e)}return Ko(e,o,t)}function Ko(e,o,t){if(typeof e=="string")return function(i,r){if(typeof r=="string"&&r!==""||(r="utf8"),!ge.isEncoding(r))throw new TypeError("Unknown encoding: "+r);var s=0|Qo(i,r),n=qt(s),a=n.write(i,r);return a!==s&&(n=n.slice(0,a)),n}(e,o);if(ArrayBuffer.isView(e))return Mi(e);if(e==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(Vt(e,ArrayBuffer)||e&&Vt(e.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(Vt(e,SharedArrayBuffer)||e&&Vt(e.buffer,SharedArrayBuffer)))return ml(e,o,t);if(typeof e=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');var l=e.valueOf&&e.valueOf();if(l!=null&&l!==e)return ge.from(l,o,t);var h=function(i){if(ge.isBuffer(i)){var r=0|Ui(i.length),s=qt(r);return s.length===0||i.copy(s,0,0,r),s}if(i.length!==void 0)return typeof i.length!="number"||ji(i.length)?qt(0):Mi(i);if(i.type==="Buffer"&&Array.isArray(i.data))return Mi(i.data)}(e);if(h)return h;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof e[Symbol.toPrimitive]=="function")return ge.from(e[Symbol.toPrimitive]("string"),o,t);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}function Yo(e){if(typeof e!="number")throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function xi(e){return Yo(e),qt(e<0?0:0|Ui(e))}function Mi(e){for(var o=e.length<0?0:0|Ui(e.length),t=qt(o),l=0;l=2147483647)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x7fffffff bytes");return 0|e}function Qo(e,o){if(ge.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||Vt(e,ArrayBuffer))return e.byteLength;if(typeof e!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);var t=e.length,l=arguments.length>2&&arguments[2]===!0;if(!l&&t===0)return 0;for(var h=!1;;)switch(o){case"ascii":case"latin1":case"binary":return t;case"utf8":case"utf-8":return Li(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*t;case"hex":return t>>>1;case"base64":return ns(e).length;default:if(h)return l?-1:Li(e).length;o=(""+o).toLowerCase(),h=!0}}function yl(e,o,t){var l=!1;if((o===void 0||o<0)&&(o=0),o>this.length||((t===void 0||t>this.length)&&(t=this.length),t<=0)||(t>>>=0)<=(o>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return kl(this,o,t);case"utf8":case"utf-8":return Zo(this,o,t);case"ascii":return Il(this,o,t);case"latin1":case"binary":return Tl(this,o,t);case"base64":return Al(this,o,t);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Rl(this,o,t);default:if(l)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),l=!0}}function hr(e,o,t){var l=e[o];e[o]=e[t],e[t]=l}function Go(e,o,t,l,h){if(e.length===0)return-1;if(typeof t=="string"?(l=t,t=0):t>2147483647?t=2147483647:t<-2147483648&&(t=-2147483648),ji(t=+t)&&(t=h?0:e.length-1),t<0&&(t=e.length+t),t>=e.length){if(h)return-1;t=e.length-1}else if(t<0){if(!h)return-1;t=0}if(typeof o=="string"&&(o=ge.from(o,l)),ge.isBuffer(o))return o.length===0?-1:Jo(e,o,t,l,h);if(typeof o=="number")return o&=255,typeof Uint8Array.prototype.indexOf=="function"?h?Uint8Array.prototype.indexOf.call(e,o,t):Uint8Array.prototype.lastIndexOf.call(e,o,t):Jo(e,[o],t,l,h);throw new TypeError("val must be string, number or Buffer")}function Jo(e,o,t,l,h){var i,r=1,s=e.length,n=o.length;if(l!==void 0&&((l=String(l).toLowerCase())==="ucs2"||l==="ucs-2"||l==="utf16le"||l==="utf-16le")){if(e.length<2||o.length<2)return-1;r=2,s/=2,n/=2,t/=2}function a(b,m){return r===1?b[m]:b.readUInt16BE(m*r)}if(h){var c=-1;for(i=t;is&&(t=s-n),i=t;i>=0;i--){for(var d=!0,g=0;gh&&(l=h):l=h;var i=o.length;l>i/2&&(l=i/2);for(var r=0;r>8,n=r%256,a.push(n),a.push(s);return a}(o,e.length-t),e,t,l)}function Al(e,o,t){return o===0&&t===e.length?Gr.fromByteArray(e):Gr.fromByteArray(e.slice(o,t))}function Zo(e,o,t){t=Math.min(e.length,t);for(var l=[],h=o;h239?4:a>223?3:a>191?2:1;if(h+d<=t)switch(d){case 1:a<128&&(c=a);break;case 2:(192&(i=e[h+1]))==128&&(n=(31&a)<<6|63&i)>127&&(c=n);break;case 3:i=e[h+1],r=e[h+2],(192&i)==128&&(192&r)==128&&(n=(15&a)<<12|(63&i)<<6|63&r)>2047&&(n<55296||n>57343)&&(c=n);break;case 4:i=e[h+1],r=e[h+2],s=e[h+3],(192&i)==128&&(192&r)==128&&(192&s)==128&&(n=(15&a)<<18|(63&i)<<12|(63&r)<<6|63&s)>65535&&n<1114112&&(c=n)}c===null?(c=65533,d=1):c>65535&&(c-=65536,l.push(c>>>10&1023|55296),c=56320|1023&c),l.push(c),h+=d}return function(g){var b=g.length;if(b<=4096)return String.fromCharCode.apply(String,g);for(var m="",y=0;yl)&&(t=l);for(var h="",i=o;it)throw new RangeError("Trying to access beyond buffer length")}function vt(e,o,t,l,h,i){if(!ge.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(o>h||oe.length)throw new RangeError("Index out of range")}function es(e,o,t,l,h,i){if(t+l>e.length)throw new RangeError("Index out of range");if(t<0)throw new RangeError("Index out of range")}function ts(e,o,t,l,h){return o=+o,t>>>=0,h||es(e,0,t,4),dr.write(e,o,t,l,23,4),t+4}function rs(e,o,t,l,h){return o=+o,t>>>=0,h||es(e,0,t,8),dr.write(e,o,t,l,52,8),t+8}function Li(e,o){var t;o=o||1/0;for(var l=e.length,h=null,i=[],r=0;r55295&&t<57344){if(!h){if(t>56319){(o-=3)>-1&&i.push(239,191,189);continue}if(r+1===l){(o-=3)>-1&&i.push(239,191,189);continue}h=t;continue}if(t<56320){(o-=3)>-1&&i.push(239,191,189),h=t;continue}t=65536+(h-55296<<10|t-56320)}else h&&(o-=3)>-1&&i.push(239,191,189);if(h=null,t<128){if((o-=1)<0)break;i.push(t)}else if(t<2048){if((o-=2)<0)break;i.push(t>>6|192,63&t|128)}else if(t<65536){if((o-=3)<0)break;i.push(t>>12|224,t>>6&63|128,63&t|128)}else{if(!(t<1114112))throw new Error("Invalid code point");if((o-=4)<0)break;i.push(t>>18|240,t>>12&63|128,t>>6&63|128,63&t|128)}}return i}function ns(e){return Gr.toByteArray(function(o){if((o=(o=o.split("=")[0]).trim().replace(us,"")).length<2)return"";for(;o.length%4!=0;)o+="=";return o}(e))}function Yr(e,o,t,l){for(var h=0;h=o.length||h>=e.length);++h)o[h+t]=e[h];return h}function Vt(e,o){return e instanceof o||e!=null&&e.constructor!=null&&e.constructor.name!=null&&e.constructor.name===o.name}function ji(e){return e!=e}function is(e,o){for(var t in e)o[t]=e[t]}function cr(e,o,t){return Rt(e,o,t)}function xr(e){var o;switch(this.encoding=function(t){var l=function(h){if(!h)return"utf8";for(var i;;)switch(h){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return h;default:if(i)return;h=(""+h).toLowerCase(),i=!0}}(t);if(typeof l!="string"&&(Jr.isEncoding===Fi||!Fi(t)))throw new Error("Unknown encoding: "+t);return l||t}(e),this.encoding){case"utf16le":this.text=Cl,this.end=Pl,o=4;break;case"utf8":this.fillLast=Ol,o=4;break;case"base64":this.text=Bl,this.end=xl,o=3;break;default:return this.write=Ml,this.end=Ul,void 0}this.lastNeed=0,this.lastTotal=0,this.lastChar=Jr.allocUnsafe(o)}function Ni(e){return e<=127?0:e>>5==6?2:e>>4==14?3:e>>3==30?4:e>>6==2?-1:-2}function Ol(e){var o=this.lastTotal-this.lastNeed,t=function(l,h,i){if((192&h[0])!=128)return l.lastNeed=0,"�";if(l.lastNeed>1&&h.length>1){if((192&h[1])!=128)return l.lastNeed=1,"�";if(l.lastNeed>2&&h.length>2&&(192&h[2])!=128)return l.lastNeed=2,"�"}}(this,e);return t!==void 0?t:this.lastNeed<=e.length?(e.copy(this.lastChar,o,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(e.copy(this.lastChar,o,0,e.length),this.lastNeed-=e.length,void 0)}function Cl(e,o){if((e.length-o)%2==0){var t=e.toString("utf16le",o);if(t){var l=t.charCodeAt(t.length-1);if(l>=55296&&l<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],t.slice(0,-1)}return t}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",o,e.length-1)}function Pl(e){var o=e&&e.length?this.write(e):"";if(this.lastNeed){var t=this.lastTotal-this.lastNeed;return o+this.lastChar.toString("utf16le",0,t)}return o}function Bl(e,o){var t=(e.length-o)%3;return t===0?e.toString("base64",o):(this.lastNeed=3-t,this.lastTotal=3,t===1?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",o,e.length-t))}function xl(e){var o=e&&e.length?this.write(e):"";return this.lastNeed?o+this.lastChar.toString("base64",0,3-this.lastNeed):o}function Ml(e){return e.toString(this.encoding)}function Ul(e){return e&&e.length?this.write(e):""}var os,kt,St,ss,Qr,fr,as,ls,Mt,Gr,dr,Di,us,hs,Mr,Ur,Rt,cs,Ir,Jr,Fi,fs=ct(()=>{for(he(),ue(),le(),os={byteLength:function(e){var o=zo(e),t=o[0],l=o[1];return 3*(t+l)/4-l},toByteArray:function(e){var o,t,l=zo(e),h=l[0],i=l[1],r=new ss(function(a,c,d){return 3*(c+d)/4-d}(0,h,i)),s=0,n=i>0?h-4:h;for(t=0;t>16&255,r[s++]=o>>8&255,r[s++]=255&o;return i===2&&(o=St[e.charCodeAt(t)]<<2|St[e.charCodeAt(t+1)]>>4,r[s++]=255&o),i===1&&(o=St[e.charCodeAt(t)]<<10|St[e.charCodeAt(t+1)]<<4|St[e.charCodeAt(t+2)]>>2,r[s++]=o>>8&255,r[s++]=255&o),r},fromByteArray:function(e){for(var o,t=e.length,l=t%3,h=[],i=0,r=t-l;ir?r:i+16383));return l===1?(o=e[t-1],h.push(kt[o>>2]+kt[o<<4&63]+"==")):l===2&&(o=(e[t-2]<<8)+e[t-1],h.push(kt[o>>10]+kt[o>>4&63]+kt[o<<2&63]+"=")),h.join("")}},kt=[],St=[],ss=typeof Uint8Array<"u"?Uint8Array:Array,Qr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",fr=0,as=Qr.length;fr>1,c=-7,d=t?h-1:0,g=t?-1:1,b=e[o+d];for(d+=g,i=b&(1<<-c)-1,b>>=-c,c+=s;c>0;i=256*i+e[o+d],d+=g,c-=8);for(r=i&(1<<-c)-1,i>>=-c,c+=l;c>0;r=256*r+e[o+d],d+=g,c-=8);if(i===0)i=1-a;else{if(i===n)return r?NaN:1/0*(b?-1:1);r+=Math.pow(2,l),i-=a}return(b?-1:1)*r*Math.pow(2,i-l)},write:function(e,o,t,l,h,i){var r,s,n,a=8*i-h-1,c=(1<>1,g=h===23?Math.pow(2,-24)-Math.pow(2,-77):0,b=l?0:i-1,m=l?1:-1,y=o<0||o===0&&1/o<0?1:0;for(o=Math.abs(o),isNaN(o)||o===1/0?(s=isNaN(o)?1:0,r=c):(r=Math.floor(Math.log(o)/Math.LN2),o*(n=Math.pow(2,-r))<1&&(r--,n*=2),(o+=r+d>=1?g/n:g*Math.pow(2,1-d))*n>=2&&(r++,n/=2),r+d>=c?(s=0,r=c):r+d>=1?(s=(o*n-1)*Math.pow(2,h),r+=d):(s=o*Math.pow(2,d-1)*Math.pow(2,h),r=0));h>=8;e[t+b]=255&s,b+=m,s/=256,h-=8);for(r=r<0;e[t+b]=255&r,b+=m,r/=256,a-=8);e[t+b-m]|=128*y}},Mt={},Gr=os,dr=ls,Di=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null,Mt.Buffer=ge,Mt.SlowBuffer=function(e){return+e!=e&&(e=0),ge.alloc(+e)},Mt.INSPECT_MAX_BYTES=50,Mt.kMaxLength=2147483647,ge.TYPED_ARRAY_SUPPORT=function(){try{var e=new Uint8Array(1),o={foo:function(){return 42}};return Object.setPrototypeOf(o,Uint8Array.prototype),Object.setPrototypeOf(e,o),e.foo()===42}catch{return!1}}(),ge.TYPED_ARRAY_SUPPORT||typeof console>"u"||typeof console.error!="function"||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(ge.prototype,"parent",{enumerable:!0,get:function(){if(ge.isBuffer(this))return this.buffer}}),Object.defineProperty(ge.prototype,"offset",{enumerable:!0,get:function(){if(ge.isBuffer(this))return this.byteOffset}}),ge.poolSize=8192,ge.from=function(e,o,t){return Ko(e,o,t)},Object.setPrototypeOf(ge.prototype,Uint8Array.prototype),Object.setPrototypeOf(ge,Uint8Array),ge.alloc=function(e,o,t){return function(l,h,i){return Yo(l),l<=0?qt(l):h!==void 0?typeof i=="string"?qt(l).fill(h,i):qt(l).fill(h):qt(l)}(e,o,t)},ge.allocUnsafe=function(e){return xi(e)},ge.allocUnsafeSlow=function(e){return xi(e)},ge.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==ge.prototype},ge.compare=function(e,o){if(Vt(e,Uint8Array)&&(e=ge.from(e,e.offset,e.byteLength)),Vt(o,Uint8Array)&&(o=ge.from(o,o.offset,o.byteLength)),!ge.isBuffer(e)||!ge.isBuffer(o))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===o)return 0;for(var t=e.length,l=o.length,h=0,i=Math.min(t,l);ho&&(e+=" ... "),""},Di&&(ge.prototype[Di]=ge.prototype.inspect),ge.prototype.compare=function(e,o,t,l,h){if(Vt(e,Uint8Array)&&(e=ge.from(e,e.offset,e.byteLength)),!ge.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(o===void 0&&(o=0),t===void 0&&(t=e?e.length:0),l===void 0&&(l=0),h===void 0&&(h=this.length),o<0||t>e.length||l<0||h>this.length)throw new RangeError("out of range index");if(l>=h&&o>=t)return 0;if(l>=h)return-1;if(o>=t)return 1;if(this===e)return 0;for(var i=(h>>>=0)-(l>>>=0),r=(t>>>=0)-(o>>>=0),s=Math.min(i,r),n=this.slice(l,h),a=e.slice(o,t),c=0;c>>=0,isFinite(t)?(t>>>=0,l===void 0&&(l="utf8")):(l=t,t=void 0)}var h=this.length-o;if((t===void 0||t>h)&&(t=h),e.length>0&&(t<0||o<0)||o>this.length)throw new RangeError("Attempt to write outside buffer bounds");l||(l="utf8");for(var i=!1;;)switch(l){case"hex":return vl(this,e,o,t);case"utf8":case"utf-8":return wl(this,e,o,t);case"ascii":return Xo(this,e,o,t);case"latin1":case"binary":return _l(this,e,o,t);case"base64":return El(this,e,o,t);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Sl(this,e,o,t);default:if(i)throw new TypeError("Unknown encoding: "+l);l=(""+l).toLowerCase(),i=!0}},ge.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},ge.prototype.slice=function(e,o){var t=this.length;(e=~~e)<0?(e+=t)<0&&(e=0):e>t&&(e=t),(o=o===void 0?t:~~o)<0?(o+=t)<0&&(o=0):o>t&&(o=t),o>>=0,o>>>=0,t||ut(e,o,this.length);for(var l=this[e],h=1,i=0;++i>>=0,o>>>=0,t||ut(e,o,this.length);for(var l=this[e+--o],h=1;o>0&&(h*=256);)l+=this[e+--o]*h;return l},ge.prototype.readUInt8=function(e,o){return e>>>=0,o||ut(e,1,this.length),this[e]},ge.prototype.readUInt16LE=function(e,o){return e>>>=0,o||ut(e,2,this.length),this[e]|this[e+1]<<8},ge.prototype.readUInt16BE=function(e,o){return e>>>=0,o||ut(e,2,this.length),this[e]<<8|this[e+1]},ge.prototype.readUInt32LE=function(e,o){return e>>>=0,o||ut(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},ge.prototype.readUInt32BE=function(e,o){return e>>>=0,o||ut(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},ge.prototype.readIntLE=function(e,o,t){e>>>=0,o>>>=0,t||ut(e,o,this.length);for(var l=this[e],h=1,i=0;++i=(h*=128)&&(l-=Math.pow(2,8*o)),l},ge.prototype.readIntBE=function(e,o,t){e>>>=0,o>>>=0,t||ut(e,o,this.length);for(var l=o,h=1,i=this[e+--l];l>0&&(h*=256);)i+=this[e+--l]*h;return i>=(h*=128)&&(i-=Math.pow(2,8*o)),i},ge.prototype.readInt8=function(e,o){return e>>>=0,o||ut(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},ge.prototype.readInt16LE=function(e,o){e>>>=0,o||ut(e,2,this.length);var t=this[e]|this[e+1]<<8;return 32768&t?4294901760|t:t},ge.prototype.readInt16BE=function(e,o){e>>>=0,o||ut(e,2,this.length);var t=this[e+1]|this[e]<<8;return 32768&t?4294901760|t:t},ge.prototype.readInt32LE=function(e,o){return e>>>=0,o||ut(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},ge.prototype.readInt32BE=function(e,o){return e>>>=0,o||ut(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},ge.prototype.readFloatLE=function(e,o){return e>>>=0,o||ut(e,4,this.length),dr.read(this,e,!0,23,4)},ge.prototype.readFloatBE=function(e,o){return e>>>=0,o||ut(e,4,this.length),dr.read(this,e,!1,23,4)},ge.prototype.readDoubleLE=function(e,o){return e>>>=0,o||ut(e,8,this.length),dr.read(this,e,!0,52,8)},ge.prototype.readDoubleBE=function(e,o){return e>>>=0,o||ut(e,8,this.length),dr.read(this,e,!1,52,8)},ge.prototype.writeUIntLE=function(e,o,t,l){e=+e,o>>>=0,t>>>=0,l||vt(this,e,o,t,Math.pow(2,8*t)-1,0);var h=1,i=0;for(this[o]=255&e;++i>>=0,t>>>=0,l||vt(this,e,o,t,Math.pow(2,8*t)-1,0);var h=t-1,i=1;for(this[o+h]=255&e;--h>=0&&(i*=256);)this[o+h]=e/i&255;return o+t},ge.prototype.writeUInt8=function(e,o,t){return e=+e,o>>>=0,t||vt(this,e,o,1,255,0),this[o]=255&e,o+1},ge.prototype.writeUInt16LE=function(e,o,t){return e=+e,o>>>=0,t||vt(this,e,o,2,65535,0),this[o]=255&e,this[o+1]=e>>>8,o+2},ge.prototype.writeUInt16BE=function(e,o,t){return e=+e,o>>>=0,t||vt(this,e,o,2,65535,0),this[o]=e>>>8,this[o+1]=255&e,o+2},ge.prototype.writeUInt32LE=function(e,o,t){return e=+e,o>>>=0,t||vt(this,e,o,4,4294967295,0),this[o+3]=e>>>24,this[o+2]=e>>>16,this[o+1]=e>>>8,this[o]=255&e,o+4},ge.prototype.writeUInt32BE=function(e,o,t){return e=+e,o>>>=0,t||vt(this,e,o,4,4294967295,0),this[o]=e>>>24,this[o+1]=e>>>16,this[o+2]=e>>>8,this[o+3]=255&e,o+4},ge.prototype.writeIntLE=function(e,o,t,l){if(e=+e,o>>>=0,!l){var h=Math.pow(2,8*t-1);vt(this,e,o,t,h-1,-h)}var i=0,r=1,s=0;for(this[o]=255&e;++i>0)-s&255;return o+t},ge.prototype.writeIntBE=function(e,o,t,l){if(e=+e,o>>>=0,!l){var h=Math.pow(2,8*t-1);vt(this,e,o,t,h-1,-h)}var i=t-1,r=1,s=0;for(this[o+i]=255&e;--i>=0&&(r*=256);)e<0&&s===0&&this[o+i+1]!==0&&(s=1),this[o+i]=(e/r>>0)-s&255;return o+t},ge.prototype.writeInt8=function(e,o,t){return e=+e,o>>>=0,t||vt(this,e,o,1,127,-128),e<0&&(e=255+e+1),this[o]=255&e,o+1},ge.prototype.writeInt16LE=function(e,o,t){return e=+e,o>>>=0,t||vt(this,e,o,2,32767,-32768),this[o]=255&e,this[o+1]=e>>>8,o+2},ge.prototype.writeInt16BE=function(e,o,t){return e=+e,o>>>=0,t||vt(this,e,o,2,32767,-32768),this[o]=e>>>8,this[o+1]=255&e,o+2},ge.prototype.writeInt32LE=function(e,o,t){return e=+e,o>>>=0,t||vt(this,e,o,4,2147483647,-2147483648),this[o]=255&e,this[o+1]=e>>>8,this[o+2]=e>>>16,this[o+3]=e>>>24,o+4},ge.prototype.writeInt32BE=function(e,o,t){return e=+e,o>>>=0,t||vt(this,e,o,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[o]=e>>>24,this[o+1]=e>>>16,this[o+2]=e>>>8,this[o+3]=255&e,o+4},ge.prototype.writeFloatLE=function(e,o,t){return ts(this,e,o,!0,t)},ge.prototype.writeFloatBE=function(e,o,t){return ts(this,e,o,!1,t)},ge.prototype.writeDoubleLE=function(e,o,t){return rs(this,e,o,!0,t)},ge.prototype.writeDoubleBE=function(e,o,t){return rs(this,e,o,!1,t)},ge.prototype.copy=function(e,o,t,l){if(!ge.isBuffer(e))throw new TypeError("argument should be a Buffer");if(t||(t=0),l||l===0||(l=this.length),o>=e.length&&(o=e.length),o||(o=0),l>0&&l=this.length)throw new RangeError("Index out of range");if(l<0)throw new RangeError("sourceEnd out of bounds");l>this.length&&(l=this.length),e.length-o=0;--i)e[i+o]=this[i+t];else Uint8Array.prototype.set.call(e,this.subarray(t,l),o);return h},ge.prototype.fill=function(e,o,t,l){if(typeof e=="string"){if(typeof o=="string"?(l=o,o=0,t=this.length):typeof t=="string"&&(l=t,t=this.length),l!==void 0&&typeof l!="string")throw new TypeError("encoding must be a string");if(typeof l=="string"&&!ge.isEncoding(l))throw new TypeError("Unknown encoding: "+l);if(e.length===1){var h=e.charCodeAt(0);(l==="utf8"&&h<128||l==="latin1")&&(e=h)}}else typeof e=="number"?e&=255:typeof e=="boolean"&&(e=Number(e));if(o<0||this.length>>=0,t=t===void 0?this.length:t>>>0,e||(e=0),typeof e=="number")for(i=o;i=0?(n>0&&(h.lastNeed=n-1),n):--s=0?(n>0&&(h.lastNeed=n-2),n):--s=0?(n>0&&(n===2?n=0:h.lastNeed=n-3),n):0}(this,e,o);if(!this.lastNeed)return e.toString("utf8",o);this.lastTotal=t;var l=e.length-(t-this.lastNeed);return e.copy(this.lastChar,0,l),e.toString("utf8",o,l)},xr.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length},Ir.StringDecoder,Ir.StringDecoder}),ds={};ir(ds,{StringDecoder:()=>ps,default:()=>Ir});var ps,Ll=ct(()=>{he(),ue(),le(),fs(),fs(),ps=Ir.StringDecoder}),gs=ye((e,o)=>{he(),ue(),le();var t=ar(),{PromisePrototypeThen:l,SymbolAsyncIterator:h,SymbolIterator:i}=st(),{Buffer:r}=(dt(),Ve(ft)),{ERR_INVALID_ARG_TYPE:s,ERR_STREAM_NULL_VALUES:n}=yt().codes;function a(c,d,g){let b;if(typeof d=="string"||d instanceof r)return new c({objectMode:!0,...g,read(){this.push(d),this.push(null)}});let m;if(d&&d[h])m=!0,b=d[h]();else if(d&&d[i])m=!1,b=d[i]();else throw new s("iterable",["Iterable"],d);let y=new c({objectMode:!0,highWaterMark:1,...g}),T=!1;y._read=function(){T||(T=!0,S())},y._destroy=function(R,F){l(U(R),()=>t.nextTick(F,R),W=>t.nextTick(F,W||R))};async function U(R){let F=R!=null,W=typeof b.throw=="function";if(F&&W){let{value:C,done:O}=await b.throw(R);if(await C,O)return}if(typeof b.return=="function"){let{value:C}=await b.return();await C}}async function S(){for(;;){try{let{value:R,done:F}=m?await b.next():b.next();if(F)y.push(null);else{let W=R&&typeof R.then=="function"?await R:R;if(W===null)throw T=!1,new n;if(y.push(W))continue;T=!1}}catch(R){y.destroy(R)}break}}return y}o.exports=a}),Xr=ye((e,o)=>{he(),ue(),le();var t=ar(),{ArrayPrototypeIndexOf:l,NumberIsInteger:h,NumberIsNaN:i,NumberParseInt:r,ObjectDefineProperties:s,ObjectKeys:n,ObjectSetPrototypeOf:a,Promise:c,SafeSet:d,SymbolAsyncIterator:g,Symbol:b}=st();o.exports=A,A.ReadableState=Ee;var{EventEmitter:m}=(Ar(),Ve(ur)),{Stream:y,prependListener:T}=Pi(),{Buffer:U}=(dt(),Ve(ft)),{addAbortSignal:S}=Kr(),R=er(),F=Wt().debuglog("stream",u=>{F=u}),W=gl(),C=Sr(),{getHighWaterMark:O,getDefaultHighWaterMark:M}=Bi(),{aggregateTwoErrors:$,codes:{ERR_INVALID_ARG_TYPE:X,ERR_METHOD_NOT_IMPLEMENTED:te,ERR_OUT_OF_RANGE:E,ERR_STREAM_PUSH_AFTER_EOF:q,ERR_STREAM_UNSHIFT_AFTER_END_EVENT:Z}}=yt(),{validateObject:z}=Hr(),be=b("kPaused"),{StringDecoder:ie}=(Ll(),Ve(ds)),V=gs();a(A.prototype,y.prototype),a(A,y);var me=()=>{},{errorOrDestroy:ne}=C;function Ee(u,p,w){typeof w!="boolean"&&(w=p instanceof Ht()),this.objectMode=!!(u&&u.objectMode),w&&(this.objectMode=this.objectMode||!!(u&&u.readableObjectMode)),this.highWaterMark=u?O(this,u,"readableHighWaterMark",w):M(!1),this.buffer=new W,this.length=0,this.pipes=[],this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.constructed=!0,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this[be]=null,this.errorEmitted=!1,this.emitClose=!u||u.emitClose!==!1,this.autoDestroy=!u||u.autoDestroy!==!1,this.destroyed=!1,this.errored=null,this.closed=!1,this.closeEmitted=!1,this.defaultEncoding=u&&u.defaultEncoding||"utf8",this.awaitDrainWriters=null,this.multiAwaitDrain=!1,this.readingMore=!1,this.dataEmitted=!1,this.decoder=null,this.encoding=null,u&&u.encoding&&(this.decoder=new ie(u.encoding),this.encoding=u.encoding)}function A(u){if(!(this instanceof A))return new A(u);let p=this instanceof Ht();this._readableState=new Ee(u,this,p),u&&(typeof u.read=="function"&&(this._read=u.read),typeof u.destroy=="function"&&(this._destroy=u.destroy),typeof u.construct=="function"&&(this._construct=u.construct),u.signal&&!p&&S(u.signal,this)),y.call(this,u),C.construct(this,()=>{this._readableState.needReadable&&ee(this,this._readableState)})}A.prototype.destroy=C.destroy,A.prototype._undestroy=C.undestroy,A.prototype._destroy=function(u,p){p(u)},A.prototype[m.captureRejectionSymbol]=function(u){this.destroy(u)},A.prototype.push=function(u,p){return Q(this,u,p,!1)},A.prototype.unshift=function(u,p){return Q(this,u,p,!0)};function Q(u,p,w,I){F("readableAddChunk",p);let v=u._readableState,P;if(v.objectMode||(typeof p=="string"?(w=w||v.defaultEncoding,v.encoding!==w&&(I&&v.encoding?p=U.from(p,w).toString(v.encoding):(p=U.from(p,w),w=""))):p instanceof U?w="":y._isUint8Array(p)?(p=y._uint8ArrayToBuffer(p),w=""):p!=null&&(P=new X("chunk",["string","Buffer","Uint8Array"],p))),P)ne(u,P);else if(p===null)v.reading=!1,_(u,v);else if(v.objectMode||p&&p.length>0)if(I)if(v.endEmitted)ne(u,new Z);else{if(v.destroyed||v.errored)return!1;fe(u,v,p,!0)}else if(v.ended)ne(u,new q);else{if(v.destroyed||v.errored)return!1;v.reading=!1,v.decoder&&!w?(p=v.decoder.write(p),v.objectMode||p.length!==0?fe(u,v,p,!1):ee(u,v)):fe(u,v,p,!1)}else I||(v.reading=!1,ee(u,v));return!v.ended&&(v.length0?(p.multiAwaitDrain?p.awaitDrainWriters.clear():p.awaitDrainWriters=null,p.dataEmitted=!0,u.emit("data",w)):(p.length+=p.objectMode?1:w.length,I?p.buffer.unshift(w):p.buffer.push(w),p.needReadable&&Y(u)),ee(u,p)}A.prototype.isPaused=function(){let u=this._readableState;return u[be]===!0||u.flowing===!1},A.prototype.setEncoding=function(u){let p=new ie(u);this._readableState.decoder=p,this._readableState.encoding=this._readableState.decoder.encoding;let w=this._readableState.buffer,I="";for(let v of w)I+=p.write(v);return w.clear(),I!==""&&w.push(I),this._readableState.length=I.length,this};var Ae=1073741824;function ae(u){if(u>Ae)throw new E("size","<= 1GiB",u);return u--,u|=u>>>1,u|=u>>>2,u|=u>>>4,u|=u>>>8,u|=u>>>16,u++,u}function B(u,p){return u<=0||p.length===0&&p.ended?0:p.objectMode?1:i(u)?p.flowing&&p.length?p.buffer.first().length:p.length:u<=p.length?u:p.ended?p.length:0}A.prototype.read=function(u){F("read",u),u===void 0?u=NaN:h(u)||(u=r(u,10));let p=this._readableState,w=u;if(u>p.highWaterMark&&(p.highWaterMark=ae(u)),u!==0&&(p.emittedReadable=!1),u===0&&p.needReadable&&((p.highWaterMark!==0?p.length>=p.highWaterMark:p.length>0)||p.ended))return F("read: emitReadable",p.length,p.ended),p.length===0&&p.ended?ve(this):Y(this),null;if(u=B(u,p),u===0&&p.ended)return p.length===0&&ve(this),null;let I=p.needReadable;if(F("need readable",I),(p.length===0||p.length-u0?v=K(u,p):v=null,v===null?(p.needReadable=p.length<=p.highWaterMark,u=0):(p.length-=u,p.multiAwaitDrain?p.awaitDrainWriters.clear():p.awaitDrainWriters=null),p.length===0&&(p.ended||(p.needReadable=!0),w!==u&&p.ended&&ve(this)),v!==null&&!p.errorEmitted&&!p.closeEmitted&&(p.dataEmitted=!0,this.emit("data",v)),v};function _(u,p){if(F("onEofChunk"),!p.ended){if(p.decoder){let w=p.decoder.end();w&&w.length&&(p.buffer.push(w),p.length+=p.objectMode?1:w.length)}p.ended=!0,p.sync?Y(u):(p.needReadable=!1,p.emittedReadable=!0,se(u))}}function Y(u){let p=u._readableState;F("emitReadable",p.needReadable,p.emittedReadable),p.needReadable=!1,p.emittedReadable||(F("emitReadable",p.flowing),p.emittedReadable=!0,t.nextTick(se,u))}function se(u){let p=u._readableState;F("emitReadable_",p.destroyed,p.length,p.ended),!p.destroyed&&!p.errored&&(p.length||p.ended)&&(u.emit("readable"),p.emittedReadable=!1),p.needReadable=!p.flowing&&!p.ended&&p.length<=p.highWaterMark,re(u)}function ee(u,p){!p.readingMore&&p.constructed&&(p.readingMore=!0,t.nextTick(J,u,p))}function J(u,p){for(;!p.reading&&!p.ended&&(p.length1&&I.pipes.includes(u)&&(F("false write response, pause",I.awaitDrainWriters.size),I.awaitDrainWriters.add(u)),w.pause()),de||(de=ce(w,u),u.on("drain",de))}w.on("data",Oe);function Oe(Je){F("ondata");let et=u.write(Je);F("dest.write",et),et===!1&&Ie()}function Ke(Je){if(F("onerror",Je),ht(),u.removeListener("error",Ke),u.listenerCount("error")===0){let et=u._writableState||u._readableState;et&&!et.errorEmitted?ne(u,Je):u.emit("error",Je)}}T(u,"error",Ke);function pt(){u.removeListener("finish",Ne),ht()}u.once("close",pt);function Ne(){F("onfinish"),u.removeListener("close",pt),ht()}u.once("finish",Ne);function ht(){F("unpipe"),w.unpipe(u)}return u.emit("pipe",w),u.writableNeedDrain===!0?I.flowing&&Ie():I.flowing||(F("pipe resume"),w.resume()),u};function ce(u,p){return function(){let w=u._readableState;w.awaitDrainWriters===p?(F("pipeOnDrain",1),w.awaitDrainWriters=null):w.multiAwaitDrain&&(F("pipeOnDrain",w.awaitDrainWriters.size),w.awaitDrainWriters.delete(p)),(!w.awaitDrainWriters||w.awaitDrainWriters.size===0)&&u.listenerCount("data")&&u.resume()}}A.prototype.unpipe=function(u){let p=this._readableState,w={hasUnpiped:!1};if(p.pipes.length===0)return this;if(!u){let v=p.pipes;p.pipes=[],this.pause();for(let P=0;P0,I.flowing!==!1&&this.resume()):u==="readable"&&!I.endEmitted&&!I.readableListening&&(I.readableListening=I.needReadable=!0,I.flowing=!1,I.emittedReadable=!1,F("on readable",I.length,I.reading),I.length?Y(this):I.reading||t.nextTick(k,this)),w},A.prototype.addListener=A.prototype.on,A.prototype.removeListener=function(u,p){let w=y.prototype.removeListener.call(this,u,p);return u==="readable"&&t.nextTick(pe,this),w},A.prototype.off=A.prototype.removeListener,A.prototype.removeAllListeners=function(u){let p=y.prototype.removeAllListeners.apply(this,arguments);return(u==="readable"||u===void 0)&&t.nextTick(pe,this),p};function pe(u){let p=u._readableState;p.readableListening=u.listenerCount("readable")>0,p.resumeScheduled&&p[be]===!1?p.flowing=!0:u.listenerCount("data")>0?u.resume():p.readableListening||(p.flowing=null)}function k(u){F("readable nexttick read 0"),u.read(0)}A.prototype.resume=function(){let u=this._readableState;return u.flowing||(F("resume"),u.flowing=!u.readableListening,N(this,u)),u[be]=!1,this};function N(u,p){p.resumeScheduled||(p.resumeScheduled=!0,t.nextTick(D,u,p))}function D(u,p){F("resume",p.reading),p.reading||u.read(0),p.resumeScheduled=!1,u.emit("resume"),re(u),p.flowing&&!p.reading&&u.read(0)}A.prototype.pause=function(){return F("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(F("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState[be]=!0,this};function re(u){let p=u._readableState;for(F("flow",p.flowing);p.flowing&&u.read()!==null;);}A.prototype.wrap=function(u){let p=!1;u.on("data",I=>{!this.push(I)&&u.pause&&(p=!0,u.pause())}),u.on("end",()=>{this.push(null)}),u.on("error",I=>{ne(this,I)}),u.on("close",()=>{this.destroy()}),u.on("destroy",()=>{this.destroy()}),this._read=()=>{p&&u.resume&&(p=!1,u.resume())};let w=n(u);for(let I=1;I{v=H?$(v,H):null,w(),w=me});try{for(;;){let H=u.destroyed?null:u.read();if(H!==null)yield H;else{if(v)throw v;if(v===null)return;await new c(I)}}}catch(H){throw v=$(v,H),v}finally{(v||(p==null?void 0:p.destroyOnReturn)!==!1)&&(v===void 0||u._readableState.autoDestroy)?C.destroyer(u,null):(u.off("readable",I),P())}}s(A.prototype,{readable:{__proto__:null,get(){let u=this._readableState;return!!u&&u.readable!==!1&&!u.destroyed&&!u.errorEmitted&&!u.endEmitted},set(u){this._readableState&&(this._readableState.readable=!!u)}},readableDidRead:{__proto__:null,enumerable:!1,get:function(){return this._readableState.dataEmitted}},readableAborted:{__proto__:null,enumerable:!1,get:function(){return!!(this._readableState.readable!==!1&&(this._readableState.destroyed||this._readableState.errored)&&!this._readableState.endEmitted)}},readableHighWaterMark:{__proto__:null,enumerable:!1,get:function(){return this._readableState.highWaterMark}},readableBuffer:{__proto__:null,enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}},readableFlowing:{__proto__:null,enumerable:!1,get:function(){return this._readableState.flowing},set:function(u){this._readableState&&(this._readableState.flowing=u)}},readableLength:{__proto__:null,enumerable:!1,get(){return this._readableState.length}},readableObjectMode:{__proto__:null,enumerable:!1,get(){return this._readableState?this._readableState.objectMode:!1}},readableEncoding:{__proto__:null,enumerable:!1,get(){return this._readableState?this._readableState.encoding:null}},errored:{__proto__:null,enumerable:!1,get(){return this._readableState?this._readableState.errored:null}},closed:{__proto__:null,get(){return this._readableState?this._readableState.closed:!1}},destroyed:{__proto__:null,enumerable:!1,get(){return this._readableState?this._readableState.destroyed:!1},set(u){this._readableState&&(this._readableState.destroyed=u)}},readableEnded:{__proto__:null,enumerable:!1,get(){return this._readableState?this._readableState.endEmitted:!1}}}),s(Ee.prototype,{pipesCount:{__proto__:null,get(){return this.pipes.length}},paused:{__proto__:null,get(){return this[be]!==!1},set(u){this[be]=!!u}}}),A._fromList=K;function K(u,p){if(p.length===0)return null;let w;return p.objectMode?w=p.buffer.shift():!u||u>=p.length?(p.decoder?w=p.buffer.join(""):p.buffer.length===1?w=p.buffer.first():w=p.buffer.concat(p.length),p.buffer.clear()):w=p.buffer.consume(u,p.decoder),w}function ve(u){let p=u._readableState;F("endReadable",p.endEmitted),p.endEmitted||(p.ended=!0,t.nextTick(Se,p,u))}function Se(u,p){if(F("endReadableNT",u.endEmitted,u.length),!u.errored&&!u.closeEmitted&&!u.endEmitted&&u.length===0){if(u.endEmitted=!0,p.emit("end"),p.writable&&p.allowHalfOpen===!1)t.nextTick(ke,p);else if(u.autoDestroy){let w=p._writableState;(!w||w.autoDestroy&&(w.finished||w.writable===!1))&&p.destroy()}}}function ke(u){u.writable&&!u.writableEnded&&!u.destroyed&&u.end()}A.from=function(u,p){return V(A,u,p)};var Ue;function f(){return Ue===void 0&&(Ue={}),Ue}A.fromWeb=function(u,p){return f().newStreamReadableFromReadableStream(u,p)},A.toWeb=function(u,p){return f().newReadableStreamFromStreamReadable(u,p)},A.wrap=function(u,p){var w,I;return new A({objectMode:(w=(I=u.readableObjectMode)!==null&&I!==void 0?I:u.objectMode)!==null&&w!==void 0?w:!0,...p,destroy(v,P){C.destroyer(u,v),P(v)}}).wrap(u)}}),bs=ye((e,o)=>{he(),ue(),le();var t=ar(),{ArrayPrototypeSlice:l,Error:h,FunctionPrototypeSymbolHasInstance:i,ObjectDefineProperty:r,ObjectDefineProperties:s,ObjectSetPrototypeOf:n,StringPrototypeToLowerCase:a,Symbol:c,SymbolHasInstance:d}=st();o.exports=ie,ie.WritableState=z;var{EventEmitter:g}=(Ar(),Ve(ur)),b=Pi().Stream,{Buffer:m}=(dt(),Ve(ft)),y=Sr(),{addAbortSignal:T}=Kr(),{getHighWaterMark:U,getDefaultHighWaterMark:S}=Bi(),{ERR_INVALID_ARG_TYPE:R,ERR_METHOD_NOT_IMPLEMENTED:F,ERR_MULTIPLE_CALLBACK:W,ERR_STREAM_CANNOT_PIPE:C,ERR_STREAM_DESTROYED:O,ERR_STREAM_ALREADY_FINISHED:M,ERR_STREAM_NULL_VALUES:$,ERR_STREAM_WRITE_AFTER_END:X,ERR_UNKNOWN_ENCODING:te}=yt().codes,{errorOrDestroy:E}=y;n(ie.prototype,b.prototype),n(ie,b);function q(){}var Z=c("kOnFinished");function z(k,N,D){typeof D!="boolean"&&(D=N instanceof Ht()),this.objectMode=!!(k&&k.objectMode),D&&(this.objectMode=this.objectMode||!!(k&&k.writableObjectMode)),this.highWaterMark=k?U(this,k,"writableHighWaterMark",D):S(!1),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;let re=!!(k&&k.decodeStrings===!1);this.decodeStrings=!re,this.defaultEncoding=k&&k.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=A.bind(void 0,N),this.writecb=null,this.writelen=0,this.afterWriteTickInfo=null,be(this),this.pendingcb=0,this.constructed=!0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!k||k.emitClose!==!1,this.autoDestroy=!k||k.autoDestroy!==!1,this.errored=null,this.closed=!1,this.closeEmitted=!1,this[Z]=[]}function be(k){k.buffered=[],k.bufferedIndex=0,k.allBuffers=!0,k.allNoop=!0}z.prototype.getBuffer=function(){return l(this.buffered,this.bufferedIndex)},r(z.prototype,"bufferedRequestCount",{__proto__:null,get(){return this.buffered.length-this.bufferedIndex}});function ie(k){let N=this instanceof Ht();if(!N&&!i(ie,this))return new ie(k);this._writableState=new z(k,this,N),k&&(typeof k.write=="function"&&(this._write=k.write),typeof k.writev=="function"&&(this._writev=k.writev),typeof k.destroy=="function"&&(this._destroy=k.destroy),typeof k.final=="function"&&(this._final=k.final),typeof k.construct=="function"&&(this._construct=k.construct),k.signal&&T(k.signal,this)),b.call(this,k),y.construct(this,()=>{let D=this._writableState;D.writing||ae(this,D),se(this,D)})}r(ie,d,{__proto__:null,value:function(k){return i(this,k)?!0:this!==ie?!1:k&&k._writableState instanceof z}}),ie.prototype.pipe=function(){E(this,new C)};function V(k,N,D,re){let G=k._writableState;if(typeof D=="function")re=D,D=G.defaultEncoding;else{if(!D)D=G.defaultEncoding;else if(D!=="buffer"&&!m.isEncoding(D))throw new te(D);typeof re!="function"&&(re=q)}if(N===null)throw new $;if(!G.objectMode)if(typeof N=="string")G.decodeStrings!==!1&&(N=m.from(N,D),D="buffer");else if(N instanceof m)D="buffer";else if(b._isUint8Array(N))N=b._uint8ArrayToBuffer(N),D="buffer";else throw new R("chunk",["string","Buffer","Uint8Array"],N);let j;return G.ending?j=new X:G.destroyed&&(j=new O("write")),j?(t.nextTick(re,j),E(k,j,!0),j):(G.pendingcb++,me(k,G,N,D,re))}ie.prototype.write=function(k,N,D){return V(this,k,N,D)===!0},ie.prototype.cork=function(){this._writableState.corked++},ie.prototype.uncork=function(){let k=this._writableState;k.corked&&(k.corked--,k.writing||ae(this,k))},ie.prototype.setDefaultEncoding=function(k){if(typeof k=="string"&&(k=a(k)),!m.isEncoding(k))throw new te(k);return this._writableState.defaultEncoding=k,this};function me(k,N,D,re,G){let j=N.objectMode?1:D.length;N.length+=j;let K=N.lengthD.bufferedIndex&&ae(k,D),re?D.afterWriteTickInfo!==null&&D.afterWriteTickInfo.cb===G?D.afterWriteTickInfo.count++:(D.afterWriteTickInfo={count:1,cb:G,stream:k,state:D},t.nextTick(Q,D.afterWriteTickInfo)):fe(k,D,1,G))}function Q({stream:k,state:N,count:D,cb:re}){return N.afterWriteTickInfo=null,fe(k,N,D,re)}function fe(k,N,D,re){for(!N.ending&&!k.destroyed&&N.length===0&&N.needDrain&&(N.needDrain=!1,k.emit("drain"));D-- >0;)N.pendingcb--,re();N.destroyed&&Ae(N),se(k,N)}function Ae(k){if(k.writing)return;for(let G=k.bufferedIndex;G1&&k._writev){N.pendingcb-=j-1;let ve=N.allNoop?q:ke=>{for(let Ue=K;Ue256?(D.splice(0,K),N.bufferedIndex=0):N.bufferedIndex=K}N.bufferProcessing=!1}ie.prototype._write=function(k,N,D){if(this._writev)this._writev([{chunk:k,encoding:N}],D);else throw new F("_write()")},ie.prototype._writev=null,ie.prototype.end=function(k,N,D){let re=this._writableState;typeof k=="function"?(D=k,k=null,N=null):typeof N=="function"&&(D=N,N=null);let G;if(k!=null){let j=V(this,k,N);j instanceof h&&(G=j)}return re.corked&&(re.corked=1,this.uncork()),G||(!re.errored&&!re.ending?(re.ending=!0,se(this,re,!0),re.ended=!0):re.finished?G=new M("end"):re.destroyed&&(G=new O("end"))),typeof D=="function"&&(G||re.finished?t.nextTick(D,G):re[Z].push(D)),this};function B(k){return k.ending&&!k.destroyed&&k.constructed&&k.length===0&&!k.errored&&k.buffered.length===0&&!k.finished&&!k.writing&&!k.errorEmitted&&!k.closeEmitted}function _(k,N){let D=!1;function re(G){if(D){E(k,G??W());return}if(D=!0,N.pendingcb--,G){let j=N[Z].splice(0);for(let K=0;K{B(G)?ee(re,G):G.pendingcb--},k,N)):B(N)&&(N.pendingcb++,ee(k,N))))}function ee(k,N){N.pendingcb--,N.finished=!0;let D=N[Z].splice(0);for(let re=0;re{he(),ue(),le();var t=ar(),l=(dt(),Ve(ft)),{isReadable:h,isWritable:i,isIterable:r,isNodeStream:s,isReadableNodeStream:n,isWritableNodeStream:a,isDuplexNodeStream:c}=$t(),d=er(),{AbortError:g,codes:{ERR_INVALID_ARG_TYPE:b,ERR_INVALID_RETURN_VALUE:m}}=yt(),{destroyer:y}=Sr(),T=Ht(),U=Xr(),{createDeferredPromise:S}=Wt(),R=gs(),F=globalThis.Blob||l.Blob,W=typeof F<"u"?function(te){return te instanceof F}:function(te){return!1},C=globalThis.AbortController||ki().AbortController,{FunctionPrototypeCall:O}=st(),M=class extends T{constructor(te){super(te),(te==null?void 0:te.readable)===!1&&(this._readableState.readable=!1,this._readableState.ended=!0,this._readableState.endEmitted=!0),(te==null?void 0:te.writable)===!1&&(this._writableState.writable=!1,this._writableState.ending=!0,this._writableState.ended=!0,this._writableState.finished=!0)}};o.exports=function te(E,q){if(c(E))return E;if(n(E))return X({readable:E});if(a(E))return X({writable:E});if(s(E))return X({writable:!1,readable:!1});if(typeof E=="function"){let{value:z,write:be,final:ie,destroy:V}=$(E);if(r(z))return R(M,z,{objectMode:!0,write:be,final:ie,destroy:V});let me=z==null?void 0:z.then;if(typeof me=="function"){let ne,Ee=O(me,z,A=>{if(A!=null)throw new m("nully","body",A)},A=>{y(ne,A)});return ne=new M({objectMode:!0,readable:!1,write:be,final(A){ie(async()=>{try{await Ee,t.nextTick(A,null)}catch(Q){t.nextTick(A,Q)}})},destroy:V})}throw new m("Iterable, AsyncIterable or AsyncFunction",q,z)}if(W(E))return te(E.arrayBuffer());if(r(E))return R(M,E,{objectMode:!0,writable:!1});if(typeof(E==null?void 0:E.writable)=="object"||typeof(E==null?void 0:E.readable)=="object"){let z=E!=null&&E.readable?n(E==null?void 0:E.readable)?E==null?void 0:E.readable:te(E.readable):void 0,be=E!=null&&E.writable?a(E==null?void 0:E.writable)?E==null?void 0:E.writable:te(E.writable):void 0;return X({readable:z,writable:be})}let Z=E==null?void 0:E.then;if(typeof Z=="function"){let z;return O(Z,E,be=>{be!=null&&z.push(be),z.push(null)},be=>{y(z,be)}),z=new M({objectMode:!0,writable:!1,read(){}})}throw new b(q,["Blob","ReadableStream","WritableStream","Stream","Iterable","AsyncIterable","Function","{ readable, writable } pair","Promise"],E)};function $(te){let{promise:E,resolve:q}=S(),Z=new C,z=Z.signal;return{value:te(async function*(){for(;;){let be=E;E=null;let{chunk:ie,done:V,cb:me}=await be;if(t.nextTick(me),V)return;if(z.aborted)throw new g(void 0,{cause:z.reason});({promise:E,resolve:q}=S()),yield ie}}(),{signal:z}),write(be,ie,V){let me=q;q=null,me({chunk:be,done:!1,cb:V})},final(be){let ie=q;q=null,ie({done:!0,cb:be})},destroy(be,ie){Z.abort(),ie(be)}}}function X(te){let E=te.readable&&typeof te.readable.read!="function"?U.wrap(te.readable):te.readable,q=te.writable,Z=!!h(E),z=!!i(q),be,ie,V,me,ne;function Ee(A){let Q=me;me=null,Q?Q(A):A&&ne.destroy(A)}return ne=new M({readableObjectMode:!!(E!=null&&E.readableObjectMode),writableObjectMode:!!(q!=null&&q.writableObjectMode),readable:Z,writable:z}),z&&(d(q,A=>{z=!1,A&&y(E,A),Ee(A)}),ne._write=function(A,Q,fe){q.write(A,Q)?fe():be=fe},ne._final=function(A){q.end(),ie=A},q.on("drain",function(){if(be){let A=be;be=null,A()}}),q.on("finish",function(){if(ie){let A=ie;ie=null,A()}})),Z&&(d(E,A=>{Z=!1,A&&y(E,A),Ee(A)}),E.on("readable",function(){if(V){let A=V;V=null,A()}}),E.on("end",function(){ne.push(null)}),ne._read=function(){for(;;){let A=E.read();if(A===null){V=ne._read;return}if(!ne.push(A))return}}),ne._destroy=function(A,Q){!A&&me!==null&&(A=new g),V=null,be=null,ie=null,me===null?Q(A):(me=Q,y(q,A),y(E,A))},ne}}),Ht=ye((e,o)=>{he(),ue(),le();var{ObjectDefineProperties:t,ObjectGetOwnPropertyDescriptor:l,ObjectKeys:h,ObjectSetPrototypeOf:i}=st();o.exports=n;var r=Xr(),s=bs();i(n.prototype,r.prototype),i(n,r);{let g=h(s.prototype);for(let b=0;b{he(),ue(),le();var{ObjectSetPrototypeOf:t,Symbol:l}=st();o.exports=n;var{ERR_METHOD_NOT_IMPLEMENTED:h}=yt().codes,i=Ht(),{getHighWaterMark:r}=Bi();t(n.prototype,i.prototype),t(n,i);var s=l("kCallback");function n(d){if(!(this instanceof n))return new n(d);let g=d?r(this,d,"readableHighWaterMark",!0):null;g===0&&(d={...d,highWaterMark:null,readableHighWaterMark:g,writableHighWaterMark:d.writableHighWaterMark||0}),i.call(this,d),this._readableState.sync=!1,this[s]=null,d&&(typeof d.transform=="function"&&(this._transform=d.transform),typeof d.flush=="function"&&(this._flush=d.flush)),this.on("prefinish",c)}function a(d){typeof this._flush=="function"&&!this.destroyed?this._flush((g,b)=>{if(g){d?d(g):this.destroy(g);return}b!=null&&this.push(b),this.push(null),d&&d()}):(this.push(null),d&&d())}function c(){this._final!==a&&a.call(this)}n.prototype._final=a,n.prototype._transform=function(d,g,b){throw new h("_transform()")},n.prototype._write=function(d,g,b){let m=this._readableState,y=this._writableState,T=m.length;this._transform(d,g,(U,S)=>{if(U){b(U);return}S!=null&&this.push(S),y.ended||T===m.length||m.length{he(),ue(),le();var{ObjectSetPrototypeOf:t}=st();o.exports=h;var l=ms();t(h.prototype,l.prototype),t(h,l);function h(i){if(!(this instanceof h))return new h(i);l.call(this,i)}h.prototype._transform=function(i,r,s){s(null,i)}}),Wi=ye((e,o)=>{he(),ue(),le();var t=ar(),{ArrayIsArray:l,Promise:h,SymbolAsyncIterator:i}=st(),r=er(),{once:s}=Wt(),n=Sr(),a=Ht(),{aggregateTwoErrors:c,codes:{ERR_INVALID_ARG_TYPE:d,ERR_INVALID_RETURN_VALUE:g,ERR_MISSING_ARGS:b,ERR_STREAM_DESTROYED:m,ERR_STREAM_PREMATURE_CLOSE:y},AbortError:T}=yt(),{validateFunction:U,validateAbortSignal:S}=Hr(),{isIterable:R,isReadable:F,isReadableNodeStream:W,isNodeStream:C,isTransformStream:O,isWebStream:M,isReadableStream:$,isReadableEnded:X}=$t(),te=globalThis.AbortController||ki().AbortController,E,q;function Z(Q,fe,Ae){let ae=!1;Q.on("close",()=>{ae=!0});let B=r(Q,{readable:fe,writable:Ae},_=>{ae=!_});return{destroy:_=>{ae||(ae=!0,n.destroyer(Q,_||new m("pipe")))},cleanup:B}}function z(Q){return U(Q[Q.length-1],"streams[stream.length - 1]"),Q.pop()}function be(Q){if(R(Q))return Q;if(W(Q))return ie(Q);throw new d("val",["Readable","Iterable","AsyncIterable"],Q)}async function*ie(Q){q||(q=Xr()),yield*q.prototype[i].call(Q)}async function V(Q,fe,Ae,{end:ae}){let B,_=null,Y=J=>{if(J&&(B=J),_){let ce=_;_=null,ce()}},se=()=>new h((J,ce)=>{B?ce(B):_=()=>{B?ce(B):J()}});fe.on("drain",Y);let ee=r(fe,{readable:!1},Y);try{fe.writableNeedDrain&&await se();for await(let J of Q)fe.write(J)||await se();ae&&fe.end(),await se(),Ae()}catch(J){Ae(B!==J?c(B,J):J)}finally{ee(),fe.off("drain",Y)}}async function me(Q,fe,Ae,{end:ae}){O(fe)&&(fe=fe.writable);let B=fe.getWriter();try{for await(let _ of Q)await B.ready,B.write(_).catch(()=>{});await B.ready,ae&&await B.close(),Ae()}catch(_){try{await B.abort(_),Ae(_)}catch(Y){Ae(Y)}}}function ne(...Q){return Ee(Q,s(z(Q)))}function Ee(Q,fe,Ae){if(Q.length===1&&l(Q[0])&&(Q=Q[0]),Q.length<2)throw new b("streams");let ae=new te,B=ae.signal,_=Ae==null?void 0:Ae.signal,Y=[];S(_,"options.signal");function se(){N(new T)}_==null||_.addEventListener("abort",se);let ee,J,ce=[],pe=0;function k(j){N(j,--pe===0)}function N(j,K){if(j&&(!ee||ee.code==="ERR_STREAM_PREMATURE_CLOSE")&&(ee=j),!(!ee&&!K)){for(;ce.length;)ce.shift()(ee);_==null||_.removeEventListener("abort",se),ae.abort(),K&&(ee||Y.forEach(ve=>ve()),t.nextTick(fe,ee,J))}}let D;for(let j=0;j0,ke=ve||(Ae==null?void 0:Ae.end)!==!1,Ue=j===Q.length-1;if(C(K)){let f=function(u){u&&u.name!=="AbortError"&&u.code!=="ERR_STREAM_PREMATURE_CLOSE"&&k(u)};if(ke){let{destroy:u,cleanup:p}=Z(K,ve,Se);ce.push(u),F(K)&&Ue&&Y.push(p)}K.on("error",f),F(K)&&Ue&&Y.push(()=>{K.removeListener("error",f)})}if(j===0)if(typeof K=="function"){if(D=K({signal:B}),!R(D))throw new g("Iterable, AsyncIterable or Stream","source",D)}else R(K)||W(K)||O(K)?D=K:D=a.from(K);else if(typeof K=="function"){if(O(D)){var re;D=be((re=D)===null||re===void 0?void 0:re.readable)}else D=be(D);if(D=K(D,{signal:B}),ve){if(!R(D,!0))throw new g("AsyncIterable",`transform[${j-1}]`,D)}else{var G;E||(E=ys());let f=new E({objectMode:!0}),u=(G=D)===null||G===void 0?void 0:G.then;if(typeof u=="function")pe++,u.call(D,I=>{J=I,I!=null&&f.write(I),ke&&f.end(),t.nextTick(k)},I=>{f.destroy(I),t.nextTick(k,I)});else if(R(D,!0))pe++,V(D,f,k,{end:ke});else if($(D)||O(D)){let I=D.readable||D;pe++,V(I,f,k,{end:ke})}else throw new g("AsyncIterable or Promise","destination",D);D=f;let{destroy:p,cleanup:w}=Z(D,!1,!0);ce.push(p),Ue&&Y.push(w)}}else if(C(K)){if(W(D)){pe+=2;let f=A(D,K,k,{end:ke});F(K)&&Ue&&Y.push(f)}else if(O(D)||$(D)){let f=D.readable||D;pe++,V(f,K,k,{end:ke})}else if(R(D))pe++,V(D,K,k,{end:ke});else throw new d("val",["Readable","Iterable","AsyncIterable","ReadableStream","TransformStream"],D);D=K}else if(M(K)){if(W(D))pe++,me(be(D),K,k,{end:ke});else if($(D)||R(D))pe++,me(D,K,k,{end:ke});else if(O(D))pe++,me(D.readable,K,k,{end:ke});else throw new d("val",["Readable","Iterable","AsyncIterable","ReadableStream","TransformStream"],D);D=K}else D=a.from(K)}return(B!=null&&B.aborted||_!=null&&_.aborted)&&t.nextTick(se),D}function A(Q,fe,Ae,{end:ae}){let B=!1;if(fe.on("close",()=>{B||Ae(new y)}),Q.pipe(fe,{end:!1}),ae){let _=function(){B=!0,fe.end()};X(Q)?t.nextTick(_):Q.once("end",_)}else Ae();return r(Q,{readable:!0,writable:!1},_=>{let Y=Q._readableState;_&&_.code==="ERR_STREAM_PREMATURE_CLOSE"&&Y&&Y.ended&&!Y.errored&&!Y.errorEmitted?Q.once("end",Ae).once("error",Ae):Ae(_)}),r(fe,{readable:!1,writable:!0},Ae)}o.exports={pipelineImpl:Ee,pipeline:ne}}),vs=ye((e,o)=>{he(),ue(),le();var{pipeline:t}=Wi(),l=Ht(),{destroyer:h}=Sr(),{isNodeStream:i,isReadable:r,isWritable:s,isWebStream:n,isTransformStream:a,isWritableStream:c,isReadableStream:d}=$t(),{AbortError:g,codes:{ERR_INVALID_ARG_VALUE:b,ERR_MISSING_ARGS:m}}=yt(),y=er();o.exports=function(...T){if(T.length===0)throw new m("streams");if(T.length===1)return l.from(T[0]);let U=[...T];if(typeof T[0]=="function"&&(T[0]=l.from(T[0])),typeof T[T.length-1]=="function"){let E=T.length-1;T[E]=l.from(T[E])}for(let E=0;E0&&!(s(T[E])||c(T[E])||a(T[E])))throw new b(`streams[${E}]`,U[E],"must be writable")}let S,R,F,W,C;function O(E){let q=W;W=null,q?q(E):E?C.destroy(E):!te&&!X&&C.destroy()}let M=T[0],$=t(T,O),X=!!(s(M)||c(M)||a(M)),te=!!(r($)||d($)||a($));if(C=new l({writableObjectMode:!!(M!=null&&M.writableObjectMode),readableObjectMode:!!($!=null&&$.writableObjectMode),writable:X,readable:te}),X){if(i(M))C._write=function(q,Z,z){M.write(q,Z)?z():S=z},C._final=function(q){M.end(),R=q},M.on("drain",function(){if(S){let q=S;S=null,q()}});else if(n(M)){let q=(a(M)?M.writable:M).getWriter();C._write=async function(Z,z,be){try{await q.ready,q.write(Z).catch(()=>{}),be()}catch(ie){be(ie)}},C._final=async function(Z){try{await q.ready,q.close().catch(()=>{}),R=Z}catch(z){Z(z)}}}let E=a($)?$.readable:$;y(E,()=>{if(R){let q=R;R=null,q()}})}if(te){if(i($))$.on("readable",function(){if(F){let E=F;F=null,E()}}),$.on("end",function(){C.push(null)}),C._read=function(){for(;;){let E=$.read();if(E===null){F=C._read;return}if(!C.push(E))return}};else if(n($)){let E=(a($)?$.readable:$).getReader();C._read=async function(){for(;;)try{let{value:q,done:Z}=await E.read();if(!C.push(q))return;if(Z){C.push(null);return}}catch{return}}}}return C._destroy=function(E,q){!E&&W!==null&&(E=new g),F=null,S=null,R=null,W===null?q(E):(W=q,i($)&&h($,E))},C}}),Nl=ye((e,o)=>{he(),ue(),le();var t=globalThis.AbortController||ki().AbortController,{codes:{ERR_INVALID_ARG_VALUE:l,ERR_INVALID_ARG_TYPE:h,ERR_MISSING_ARGS:i,ERR_OUT_OF_RANGE:r},AbortError:s}=yt(),{validateAbortSignal:n,validateInteger:a,validateObject:c}=Hr(),d=st().Symbol("kWeak"),{finished:g}=er(),b=vs(),{addAbortSignalNoValidate:m}=Kr(),{isWritable:y,isNodeStream:T}=$t(),{ArrayPrototypePush:U,MathFloor:S,Number:R,NumberIsNaN:F,Promise:W,PromiseReject:C,PromisePrototypeThen:O,Symbol:M}=st(),$=M("kEmpty"),X=M("kEof");function te(ae,B){if(B!=null&&c(B,"options"),(B==null?void 0:B.signal)!=null&&n(B.signal,"options.signal"),T(ae)&&!y(ae))throw new l("stream",ae,"must be writable");let _=b(this,ae);return B!=null&&B.signal&&m(B.signal,_),_}function E(ae,B){if(typeof ae!="function")throw new h("fn",["Function","AsyncFunction"],ae);B!=null&&c(B,"options"),(B==null?void 0:B.signal)!=null&&n(B.signal,"options.signal");let _=1;return(B==null?void 0:B.concurrency)!=null&&(_=S(B.concurrency)),a(_,"concurrency",1),(async function*(){var Y,se;let ee=new t,J=this,ce=[],pe=ee.signal,k={signal:pe},N=()=>ee.abort();B!=null&&(Y=B.signal)!==null&&Y!==void 0&&Y.aborted&&N(),B==null||(se=B.signal)===null||se===void 0||se.addEventListener("abort",N);let D,re,G=!1;function j(){G=!0}async function K(){try{for await(let ke of J){var ve;if(G)return;if(pe.aborted)throw new s;try{ke=ae(ke,k)}catch(Ue){ke=C(Ue)}ke!==$&&(typeof((ve=ke)===null||ve===void 0?void 0:ve.catch)=="function"&&ke.catch(j),ce.push(ke),D&&(D(),D=null),!G&&ce.length&&ce.length>=_&&await new W(Ue=>{re=Ue}))}ce.push(X)}catch(ke){let Ue=C(ke);O(Ue,void 0,j),ce.push(Ue)}finally{var Se;G=!0,D&&(D(),D=null),B==null||(Se=B.signal)===null||Se===void 0||Se.removeEventListener("abort",N)}}K();try{for(;;){for(;ce.length>0;){let ve=await ce[0];if(ve===X)return;if(pe.aborted)throw new s;ve!==$&&(yield ve),ce.shift(),re&&(re(),re=null)}await new W(ve=>{D=ve})}}finally{ee.abort(),G=!0,re&&(re(),re=null)}}).call(this)}function q(ae=void 0){return ae!=null&&c(ae,"options"),(ae==null?void 0:ae.signal)!=null&&n(ae.signal,"options.signal"),(async function*(){let B=0;for await(let Y of this){var _;if(ae!=null&&(_=ae.signal)!==null&&_!==void 0&&_.aborted)throw new s({cause:ae.signal.reason});yield[B++,Y]}}).call(this)}async function Z(ae,B=void 0){for await(let _ of V.call(this,ae,B))return!0;return!1}async function z(ae,B=void 0){if(typeof ae!="function")throw new h("fn",["Function","AsyncFunction"],ae);return!await Z.call(this,async(..._)=>!await ae(..._),B)}async function be(ae,B){for await(let _ of V.call(this,ae,B))return _}async function ie(ae,B){if(typeof ae!="function")throw new h("fn",["Function","AsyncFunction"],ae);async function _(Y,se){return await ae(Y,se),$}for await(let Y of E.call(this,_,B));}function V(ae,B){if(typeof ae!="function")throw new h("fn",["Function","AsyncFunction"],ae);async function _(Y,se){return await ae(Y,se)?Y:$}return E.call(this,_,B)}var me=class extends i{constructor(){super("reduce"),this.message="Reduce of an empty stream requires an initial value"}};async function ne(ae,B,_){var Y;if(typeof ae!="function")throw new h("reducer",["Function","AsyncFunction"],ae);_!=null&&c(_,"options"),(_==null?void 0:_.signal)!=null&&n(_.signal,"options.signal");let se=arguments.length>1;if(_!=null&&(Y=_.signal)!==null&&Y!==void 0&&Y.aborted){let k=new s(void 0,{cause:_.signal.reason});throw this.once("error",()=>{}),await g(this.destroy(k)),k}let ee=new t,J=ee.signal;if(_!=null&&_.signal){let k={once:!0,[d]:this};_.signal.addEventListener("abort",()=>ee.abort(),k)}let ce=!1;try{for await(let k of this){var pe;if(ce=!0,_!=null&&(pe=_.signal)!==null&&pe!==void 0&&pe.aborted)throw new s;se?B=await ae(B,k,{signal:J}):(B=k,se=!0)}if(!ce&&!se)throw new me}finally{ee.abort()}return B}async function Ee(ae){ae!=null&&c(ae,"options"),(ae==null?void 0:ae.signal)!=null&&n(ae.signal,"options.signal");let B=[];for await(let Y of this){var _;if(ae!=null&&(_=ae.signal)!==null&&_!==void 0&&_.aborted)throw new s(void 0,{cause:ae.signal.reason});U(B,Y)}return B}function A(ae,B){let _=E.call(this,ae,B);return(async function*(){for await(let Y of _)yield*Y}).call(this)}function Q(ae){if(ae=R(ae),F(ae))return 0;if(ae<0)throw new r("number",">= 0",ae);return ae}function fe(ae,B=void 0){return B!=null&&c(B,"options"),(B==null?void 0:B.signal)!=null&&n(B.signal,"options.signal"),ae=Q(ae),(async function*(){var _;if(B!=null&&(_=B.signal)!==null&&_!==void 0&&_.aborted)throw new s;for await(let se of this){var Y;if(B!=null&&(Y=B.signal)!==null&&Y!==void 0&&Y.aborted)throw new s;ae--<=0&&(yield se)}}).call(this)}function Ae(ae,B=void 0){return B!=null&&c(B,"options"),(B==null?void 0:B.signal)!=null&&n(B.signal,"options.signal"),ae=Q(ae),(async function*(){var _;if(B!=null&&(_=B.signal)!==null&&_!==void 0&&_.aborted)throw new s;for await(let se of this){var Y;if(B!=null&&(Y=B.signal)!==null&&Y!==void 0&&Y.aborted)throw new s;if(ae-- >0)yield se;else return}}).call(this)}o.exports.streamReturningOperators={asIndexedPairs:q,drop:fe,filter:V,flatMap:A,map:E,take:Ae,compose:te},o.exports.promiseReturningOperators={every:z,forEach:ie,reduce:ne,toArray:Ee,some:Z,find:be}}),ws=ye((e,o)=>{he(),ue(),le();var{ArrayPrototypePop:t,Promise:l}=st(),{isIterable:h,isNodeStream:i,isWebStream:r}=$t(),{pipelineImpl:s}=Wi(),{finished:n}=er();_s();function a(...c){return new l((d,g)=>{let b,m,y=c[c.length-1];if(y&&typeof y=="object"&&!i(y)&&!h(y)&&!r(y)){let T=t(c);b=T.signal,m=T.end}s(c,(T,U)=>{T?g(T):d(U)},{signal:b,end:m})})}o.exports={finished:n,pipeline:a}}),_s=ye((e,o)=>{he(),ue(),le();var{Buffer:t}=(dt(),Ve(ft)),{ObjectDefineProperty:l,ObjectKeys:h,ReflectApply:i}=st(),{promisify:{custom:r}}=Wt(),{streamReturningOperators:s,promiseReturningOperators:n}=Nl(),{codes:{ERR_ILLEGAL_CONSTRUCTOR:a}}=yt(),c=vs(),{pipeline:d}=Wi(),{destroyer:g}=Sr(),b=er(),m=ws(),y=$t(),T=o.exports=Pi().Stream;T.isDisturbed=y.isDisturbed,T.isErrored=y.isErrored,T.isReadable=y.isReadable,T.Readable=Xr();for(let S of h(s)){let R=function(...W){if(new.target)throw a();return T.Readable.from(i(F,this,W))},F=s[S];l(R,"name",{__proto__:null,value:F.name}),l(R,"length",{__proto__:null,value:F.length}),l(T.Readable.prototype,S,{__proto__:null,value:R,enumerable:!1,configurable:!0,writable:!0})}for(let S of h(n)){let R=function(...W){if(new.target)throw a();return i(F,this,W)},F=n[S];l(R,"name",{__proto__:null,value:F.name}),l(R,"length",{__proto__:null,value:F.length}),l(T.Readable.prototype,S,{__proto__:null,value:R,enumerable:!1,configurable:!0,writable:!0})}T.Writable=bs(),T.Duplex=Ht(),T.Transform=ms(),T.PassThrough=ys(),T.pipeline=d;var{addAbortSignal:U}=Kr();T.addAbortSignal=U,T.finished=b,T.destroy=g,T.compose=c,l(T,"promises",{__proto__:null,configurable:!0,enumerable:!0,get(){return m}}),l(d,r,{__proto__:null,enumerable:!0,get(){return m.pipeline}}),l(b,r,{__proto__:null,enumerable:!0,get(){return m.finished}}),T.Stream=T,T._isUint8Array=function(S){return S instanceof Uint8Array},T._uint8ArrayToBuffer=function(S){return t.from(S.buffer,S.byteOffset,S.byteLength)}}),pr=ye((e,o)=>{he(),ue(),le();var t=_s(),l=ws(),h=t.Readable.destroy;o.exports=t.Readable,o.exports._uint8ArrayToBuffer=t._uint8ArrayToBuffer,o.exports._isUint8Array=t._isUint8Array,o.exports.isDisturbed=t.isDisturbed,o.exports.isErrored=t.isErrored,o.exports.isReadable=t.isReadable,o.exports.Readable=t.Readable,o.exports.Writable=t.Writable,o.exports.Duplex=t.Duplex,o.exports.Transform=t.Transform,o.exports.PassThrough=t.PassThrough,o.exports.addAbortSignal=t.addAbortSignal,o.exports.finished=t.finished,o.exports.destroy=t.destroy,o.exports.destroy=h,o.exports.pipeline=t.pipeline,o.exports.compose=t.compose,Object.defineProperty(t,"promises",{configurable:!0,enumerable:!0,get(){return l}}),o.exports.Stream=t.Stream,o.exports.default=o.exports}),Dl=ye((e,o)=>{he(),ue(),le(),typeof Object.create=="function"?o.exports=function(t,l){l&&(t.super_=l,t.prototype=Object.create(l.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:o.exports=function(t,l){if(l){t.super_=l;var h=function(){};h.prototype=l.prototype,t.prototype=new h,t.prototype.constructor=t}}}),Fl=ye((e,o)=>{he(),ue(),le();var{Buffer:t}=(dt(),Ve(ft)),l=Symbol.for("BufferList");function h(i){if(!(this instanceof h))return new h(i);h._init.call(this,i)}h._init=function(i){Object.defineProperty(this,l,{value:!0}),this._bufs=[],this.length=0,i&&this.append(i)},h.prototype._new=function(i){return new h(i)},h.prototype._offset=function(i){if(i===0)return[0,0];let r=0;for(let s=0;sthis.length||i<0)return;let r=this._offset(i);return this._bufs[r[0]][r[1]]},h.prototype.slice=function(i,r){return typeof i=="number"&&i<0&&(i+=this.length),typeof r=="number"&&r<0&&(r+=this.length),this.copy(null,0,i,r)},h.prototype.copy=function(i,r,s,n){if((typeof s!="number"||s<0)&&(s=0),(typeof n!="number"||n>this.length)&&(n=this.length),s>=this.length||n<=0)return i||t.alloc(0);let a=!!i,c=this._offset(s),d=n-s,g=d,b=a&&r||0,m=c[1];if(s===0&&n===this.length){if(!a)return this._bufs.length===1?this._bufs[0]:t.concat(this._bufs,this.length);for(let y=0;yT)this._bufs[y].copy(i,b,m),b+=T;else{this._bufs[y].copy(i,b,m,m+g),b+=T;break}g-=T,m&&(m=0)}return i.length>b?i.slice(0,b):i},h.prototype.shallowSlice=function(i,r){if(i=i||0,r=typeof r!="number"?this.length:r,i<0&&(i+=this.length),r<0&&(r+=this.length),i===r)return this._new();let s=this._offset(i),n=this._offset(r),a=this._bufs.slice(s[0],n[0]+1);return n[1]===0?a.pop():a[a.length-1]=a[a.length-1].slice(0,n[1]),s[1]!==0&&(a[0]=a[0].slice(s[1])),this._new(a)},h.prototype.toString=function(i,r,s){return this.slice(r,s).toString(i)},h.prototype.consume=function(i){if(i=Math.trunc(i),Number.isNaN(i)||i<=0)return this;for(;this._bufs.length;)if(i>=this._bufs[0].length)i-=this._bufs[0].length,this.length-=this._bufs[0].length,this._bufs.shift();else{this._bufs[0]=this._bufs[0].slice(i),this.length-=i;break}return this},h.prototype.duplicate=function(){let i=this._new();for(let r=0;rthis.length?this.length:r;let n=this._offset(r),a=n[0],c=n[1];for(;a=i.length){let g=d.indexOf(i,c);if(g!==-1)return this._reverseOffset([a,g]);c=d.length-i.length+1}else{let g=this._reverseOffset([a,c]);if(this._match(g,i))return g;c++}c=0}return-1},h.prototype._match=function(i,r){if(this.length-i{he(),ue(),le();var t=pr().Duplex,l=Dl(),h=Fl();function i(r){if(!(this instanceof i))return new i(r);if(typeof r=="function"){this._callback=r;let s=(function(n){this._callback&&(this._callback(n),this._callback=null)}).bind(this);this.on("pipe",function(n){n.on("error",s)}),this.on("unpipe",function(n){n.removeListener("error",s)}),r=null}h._init.call(this,r),t.call(this)}l(i,t),Object.assign(i.prototype,h.prototype),i.prototype._new=function(r){return new i(r)},i.prototype._write=function(r,s,n){this._appendBuffer(r),typeof n=="function"&&n()},i.prototype._read=function(r){if(!this.length)return this.push(null);r=Math.min(r,this.length),this.push(this.slice(0,r)),this.consume(r)},i.prototype.end=function(r){t.prototype.end.call(this,r),this._callback&&(this._callback(null,this.slice()),this._callback=null)},i.prototype._destroy=function(r,s){this._bufs.length=0,this.length=0,s(r)},i.prototype._isBufferList=function(r){return r instanceof i||r instanceof h||i.isBufferList(r)},i.isBufferList=h.isBufferList,o.exports=i,o.exports.BufferListStream=i,o.exports.BufferList=h}),$l=ye((e,o)=>{he(),ue(),le();var t=class{constructor(){this.cmd=null,this.retain=!1,this.qos=0,this.dup=!1,this.length=-1,this.topic=null,this.payload=null}};o.exports=t}),Es=ye((e,o)=>{he(),ue(),le();var t=o.exports,{Buffer:l}=(dt(),Ve(ft));t.types={0:"reserved",1:"connect",2:"connack",3:"publish",4:"puback",5:"pubrec",6:"pubrel",7:"pubcomp",8:"subscribe",9:"suback",10:"unsubscribe",11:"unsuback",12:"pingreq",13:"pingresp",14:"disconnect",15:"auth"},t.requiredHeaderFlags={1:0,2:0,4:0,5:0,6:2,7:0,8:2,9:0,10:2,11:0,12:0,13:0,14:0,15:0},t.requiredHeaderFlagsErrors={};for(let i in t.requiredHeaderFlags){let r=t.requiredHeaderFlags[i];t.requiredHeaderFlagsErrors[i]="Invalid header flag bits, must be 0x"+r.toString(16)+" for "+t.types[i]+" packet"}t.codes={};for(let i in t.types){let r=t.types[i];t.codes[r]=i}t.CMD_SHIFT=4,t.CMD_MASK=240,t.DUP_MASK=8,t.QOS_MASK=3,t.QOS_SHIFT=1,t.RETAIN_MASK=1,t.VARBYTEINT_MASK=127,t.VARBYTEINT_FIN_MASK=128,t.VARBYTEINT_MAX=268435455,t.SESSIONPRESENT_MASK=1,t.SESSIONPRESENT_HEADER=l.from([t.SESSIONPRESENT_MASK]),t.CONNACK_HEADER=l.from([t.codes.connack<[0,1].map(s=>[0,1].map(n=>{let a=l.alloc(1);return a.writeUInt8(t.codes[i]<l.from([i])),t.EMPTY={pingreq:l.from([t.codes.pingreq<<4,0]),pingresp:l.from([t.codes.pingresp<<4,0]),disconnect:l.from([t.codes.disconnect<<4,0])},t.MQTT5_PUBACK_PUBREC_CODES={0:"Success",16:"No matching subscribers",128:"Unspecified error",131:"Implementation specific error",135:"Not authorized",144:"Topic Name invalid",145:"Packet identifier in use",151:"Quota exceeded",153:"Payload format invalid"},t.MQTT5_PUBREL_PUBCOMP_CODES={0:"Success",146:"Packet Identifier not found"},t.MQTT5_SUBACK_CODES={0:"Granted QoS 0",1:"Granted QoS 1",2:"Granted QoS 2",128:"Unspecified error",131:"Implementation specific error",135:"Not authorized",143:"Topic Filter invalid",145:"Packet Identifier in use",151:"Quota exceeded",158:"Shared Subscriptions not supported",161:"Subscription Identifiers not supported",162:"Wildcard Subscriptions not supported"},t.MQTT5_UNSUBACK_CODES={0:"Success",17:"No subscription existed",128:"Unspecified error",131:"Implementation specific error",135:"Not authorized",143:"Topic Filter invalid",145:"Packet Identifier in use"},t.MQTT5_DISCONNECT_CODES={0:"Normal disconnection",4:"Disconnect with Will Message",128:"Unspecified error",129:"Malformed Packet",130:"Protocol Error",131:"Implementation specific error",135:"Not authorized",137:"Server busy",139:"Server shutting down",141:"Keep Alive timeout",142:"Session taken over",143:"Topic Filter invalid",144:"Topic Name invalid",147:"Receive Maximum exceeded",148:"Topic Alias invalid",149:"Packet too large",150:"Message rate too high",151:"Quota exceeded",152:"Administrative action",153:"Payload format invalid",154:"Retain not supported",155:"QoS not supported",156:"Use another server",157:"Server moved",158:"Shared Subscriptions not supported",159:"Connection rate exceeded",160:"Maximum connect time",161:"Subscription Identifiers not supported",162:"Wildcard Subscriptions not supported"},t.MQTT5_AUTH_CODES={0:"Success",24:"Continue authentication",25:"Re-authenticate"}}),ql=ye((e,o)=>{he(),ue(),le();var t=1e3,l=t*60,h=l*60,i=h*24,r=i*7,s=i*365.25;o.exports=function(g,b){b=b||{};var m=typeof g;if(m==="string"&&g.length>0)return n(g);if(m==="number"&&isFinite(g))return b.long?c(g):a(g);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(g))};function n(g){if(g=String(g),!(g.length>100)){var b=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(g);if(b){var m=parseFloat(b[1]),y=(b[2]||"ms").toLowerCase();switch(y){case"years":case"year":case"yrs":case"yr":case"y":return m*s;case"weeks":case"week":case"w":return m*r;case"days":case"day":case"d":return m*i;case"hours":case"hour":case"hrs":case"hr":case"h":return m*h;case"minutes":case"minute":case"mins":case"min":case"m":return m*l;case"seconds":case"second":case"secs":case"sec":case"s":return m*t;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return m;default:return}}}}function a(g){var b=Math.abs(g);return b>=i?Math.round(g/i)+"d":b>=h?Math.round(g/h)+"h":b>=l?Math.round(g/l)+"m":b>=t?Math.round(g/t)+"s":g+"ms"}function c(g){var b=Math.abs(g);return b>=i?d(g,b,i,"day"):b>=h?d(g,b,h,"hour"):b>=l?d(g,b,l,"minute"):b>=t?d(g,b,t,"second"):g+" ms"}function d(g,b,m,y){var T=b>=m*1.5;return Math.round(g/m)+" "+y+(T?"s":"")}}),Vl=ye((e,o)=>{he(),ue(),le();function t(l){i.debug=i,i.default=i,i.coerce=d,i.disable=n,i.enable=s,i.enabled=a,i.humanize=ql(),i.destroy=g,Object.keys(l).forEach(b=>{i[b]=l[b]}),i.names=[],i.skips=[],i.formatters={};function h(b){let m=0;for(let y=0;y{if(M==="%%")return"%";O++;let X=i.formatters[$];if(typeof X=="function"){let te=R[O];M=X.call(F,te),R.splice(O,1),O--}return M}),i.formatArgs.call(F,R),(F.log||i.log).apply(F,R)}return S.namespace=b,S.useColors=i.useColors(),S.color=i.selectColor(b),S.extend=r,S.destroy=i.destroy,Object.defineProperty(S,"enabled",{enumerable:!0,configurable:!1,get:()=>y!==null?y:(T!==i.namespaces&&(T=i.namespaces,U=i.enabled(b)),U),set:R=>{y=R}}),typeof i.init=="function"&&i.init(S),S}function r(b,m){let y=i(this.namespace+(typeof m>"u"?":":m)+b);return y.log=this.log,y}function s(b){i.save(b),i.namespaces=b,i.names=[],i.skips=[];let m,y=(typeof b=="string"?b:"").split(/[\s,]+/),T=y.length;for(m=0;m"-"+m)].join(",");return i.enable(""),b}function a(b){if(b[b.length-1]==="*")return!0;let m,y;for(m=0,y=i.skips.length;m{he(),ue(),le(),e.formatArgs=l,e.save=h,e.load=i,e.useColors=t,e.storage=r(),e.destroy=(()=>{let n=!1;return()=>{n||(n=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),e.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function t(){return typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)?!0:typeof _t<"u"&&_t.userAgent&&_t.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)?!1:typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof _t<"u"&&_t.userAgent&&_t.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof _t<"u"&&_t.userAgent&&_t.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function l(n){if(n[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+n[0]+(this.useColors?"%c ":" ")+"+"+o.exports.humanize(this.diff),!this.useColors)return;let a="color: "+this.color;n.splice(1,0,a,"color: inherit");let c=0,d=0;n[0].replace(/%[a-zA-Z%]/g,g=>{g!=="%%"&&(c++,g==="%c"&&(d=c))}),n.splice(d,0,a)}e.log=console.debug||console.log||(()=>{});function h(n){try{n?e.storage.setItem("debug",n):e.storage.removeItem("debug")}catch{}}function i(){let n;try{n=e.storage.getItem("debug")}catch{}return!n&&typeof ze<"u"&&"env"in ze&&(n=ze.env.DEBUG),n}function r(){try{return localStorage}catch{}}o.exports=Vl()(e);var{formatters:s}=o.exports;s.j=function(n){try{return JSON.stringify(n)}catch(a){return"[UnexpectedJSONParseError]: "+a.message}}}),Hl=ye((e,o)=>{he(),ue(),le();var t=Wl(),{EventEmitter:l}=(Ar(),Ve(ur)),h=$l(),i=Es(),r=zt()("mqtt-packet:parser"),s=class lo extends l{constructor(){super(),this.parser=this.constructor.parser}static parser(a){return this instanceof lo?(this.settings=a||{},this._states=["_parseHeader","_parseLength","_parsePayload","_newPacket"],this._resetState(),this):new lo().parser(a)}_resetState(){r("_resetState: resetting packet, error, _list, and _stateCounter"),this.packet=new h,this.error=null,this._list=t(),this._stateCounter=0}parse(a){for(this.error&&this._resetState(),this._list.append(a),r("parse: current state: %s",this._states[this._stateCounter]);(this.packet.length!==-1||this._list.length>0)&&this[this._states[this._stateCounter]]()&&!this.error;)this._stateCounter++,r("parse: state complete. _stateCounter is now: %d",this._stateCounter),r("parse: packet.length: %d, buffer list length: %d",this.packet.length,this._list.length),this._stateCounter>=this._states.length&&(this._stateCounter=0);return r("parse: exited while loop. packet: %d, buffer list length: %d",this.packet.length,this._list.length),this._list.length}_parseHeader(){let a=this._list.readUInt8(0),c=a>>i.CMD_SHIFT;this.packet.cmd=i.types[c];let d=a&15,g=i.requiredHeaderFlags[c];return g!=null&&d!==g?this._emitError(new Error(i.requiredHeaderFlagsErrors[c])):(this.packet.retain=(a&i.RETAIN_MASK)!==0,this.packet.qos=a>>i.QOS_SHIFT&i.QOS_MASK,this.packet.qos>2?this._emitError(new Error("Packet must not have both QoS bits set to 1")):(this.packet.dup=(a&i.DUP_MASK)!==0,r("_parseHeader: packet: %o",this.packet),this._list.consume(1),!0))}_parseLength(){let a=this._parseVarByteNum(!0);return a&&(this.packet.length=a.value,this._list.consume(a.bytes)),r("_parseLength %d",a.value),!!a}_parsePayload(){r("_parsePayload: payload %O",this._list);let a=!1;if(this.packet.length===0||this._list.length>=this.packet.length){switch(this._pos=0,this.packet.cmd){case"connect":this._parseConnect();break;case"connack":this._parseConnack();break;case"publish":this._parsePublish();break;case"puback":case"pubrec":case"pubrel":case"pubcomp":this._parseConfirmation();break;case"subscribe":this._parseSubscribe();break;case"suback":this._parseSuback();break;case"unsubscribe":this._parseUnsubscribe();break;case"unsuback":this._parseUnsuback();break;case"pingreq":case"pingresp":break;case"disconnect":this._parseDisconnect();break;case"auth":this._parseAuth();break;default:this._emitError(new Error("Not supported"))}a=!0}return r("_parsePayload complete result: %s",a),a}_parseConnect(){r("_parseConnect");let a,c,d,g,b={},m=this.packet,y=this._parseString();if(y===null)return this._emitError(new Error("Cannot parse protocolId"));if(y!=="MQTT"&&y!=="MQIsdp")return this._emitError(new Error("Invalid protocolId"));if(m.protocolId=y,this._pos>=this._list.length)return this._emitError(new Error("Packet too short"));if(m.protocolVersion=this._list.readUInt8(this._pos),m.protocolVersion>=128&&(m.bridgeMode=!0,m.protocolVersion=m.protocolVersion-128),m.protocolVersion!==3&&m.protocolVersion!==4&&m.protocolVersion!==5)return this._emitError(new Error("Invalid protocol version"));if(this._pos++,this._pos>=this._list.length)return this._emitError(new Error("Packet too short"));if(this._list.readUInt8(this._pos)&1)return this._emitError(new Error("Connect flag bit 0 must be 0, but got 1"));b.username=this._list.readUInt8(this._pos)&i.USERNAME_MASK,b.password=this._list.readUInt8(this._pos)&i.PASSWORD_MASK,b.will=this._list.readUInt8(this._pos)&i.WILL_FLAG_MASK;let T=!!(this._list.readUInt8(this._pos)&i.WILL_RETAIN_MASK),U=(this._list.readUInt8(this._pos)&i.WILL_QOS_MASK)>>i.WILL_QOS_SHIFT;if(b.will)m.will={},m.will.retain=T,m.will.qos=U;else{if(T)return this._emitError(new Error("Will Retain Flag must be set to zero when Will Flag is set to 0"));if(U)return this._emitError(new Error("Will QoS must be set to zero when Will Flag is set to 0"))}if(m.clean=(this._list.readUInt8(this._pos)&i.CLEAN_SESSION_MASK)!==0,this._pos++,m.keepalive=this._parseNum(),m.keepalive===-1)return this._emitError(new Error("Packet too short"));if(m.protocolVersion===5){let R=this._parseProperties();Object.getOwnPropertyNames(R).length&&(m.properties=R)}let S=this._parseString();if(S===null)return this._emitError(new Error("Packet too short"));if(m.clientId=S,r("_parseConnect: packet.clientId: %s",m.clientId),b.will){if(m.protocolVersion===5){let R=this._parseProperties();Object.getOwnPropertyNames(R).length&&(m.will.properties=R)}if(a=this._parseString(),a===null)return this._emitError(new Error("Cannot parse will topic"));if(m.will.topic=a,r("_parseConnect: packet.will.topic: %s",m.will.topic),c=this._parseBuffer(),c===null)return this._emitError(new Error("Cannot parse will payload"));m.will.payload=c,r("_parseConnect: packet.will.paylaod: %s",m.will.payload)}if(b.username){if(g=this._parseString(),g===null)return this._emitError(new Error("Cannot parse username"));m.username=g,r("_parseConnect: packet.username: %s",m.username)}if(b.password){if(d=this._parseBuffer(),d===null)return this._emitError(new Error("Cannot parse password"));m.password=d}return this.settings=m,r("_parseConnect: complete"),m}_parseConnack(){r("_parseConnack");let a=this.packet;if(this._list.length<1)return null;let c=this._list.readUInt8(this._pos++);if(c>1)return this._emitError(new Error("Invalid connack flags, bits 7-1 must be set to 0"));if(a.sessionPresent=!!(c&i.SESSIONPRESENT_MASK),this.settings.protocolVersion===5)this._list.length>=2?a.reasonCode=this._list.readUInt8(this._pos++):a.reasonCode=0;else{if(this._list.length<2)return null;a.returnCode=this._list.readUInt8(this._pos++)}if(a.returnCode===-1||a.reasonCode===-1)return this._emitError(new Error("Cannot parse return code"));if(this.settings.protocolVersion===5){let d=this._parseProperties();Object.getOwnPropertyNames(d).length&&(a.properties=d)}r("_parseConnack: complete")}_parsePublish(){r("_parsePublish");let a=this.packet;if(a.topic=this._parseString(),a.topic===null)return this._emitError(new Error("Cannot parse topic"));if(!(a.qos>0&&!this._parseMessageId())){if(this.settings.protocolVersion===5){let c=this._parseProperties();Object.getOwnPropertyNames(c).length&&(a.properties=c)}a.payload=this._list.slice(this._pos,a.length),r("_parsePublish: payload from buffer list: %o",a.payload)}}_parseSubscribe(){r("_parseSubscribe");let a=this.packet,c,d,g,b,m,y,T;if(a.subscriptions=[],!!this._parseMessageId()){if(this.settings.protocolVersion===5){let U=this._parseProperties();Object.getOwnPropertyNames(U).length&&(a.properties=U)}if(a.length<=0)return this._emitError(new Error("Malformed subscribe, no payload specified"));for(;this._pos=a.length)return this._emitError(new Error("Malformed Subscribe Payload"));if(d=this._parseByte(),this.settings.protocolVersion===5){if(d&192)return this._emitError(new Error("Invalid subscribe topic flag bits, bits 7-6 must be 0"))}else if(d&252)return this._emitError(new Error("Invalid subscribe topic flag bits, bits 7-2 must be 0"));if(g=d&i.SUBSCRIBE_OPTIONS_QOS_MASK,g>2)return this._emitError(new Error("Invalid subscribe QoS, must be <= 2"));if(y=(d>>i.SUBSCRIBE_OPTIONS_NL_SHIFT&i.SUBSCRIBE_OPTIONS_NL_MASK)!==0,m=(d>>i.SUBSCRIBE_OPTIONS_RAP_SHIFT&i.SUBSCRIBE_OPTIONS_RAP_MASK)!==0,b=d>>i.SUBSCRIBE_OPTIONS_RH_SHIFT&i.SUBSCRIBE_OPTIONS_RH_MASK,b>2)return this._emitError(new Error("Invalid retain handling, must be <= 2"));T={topic:c,qos:g},this.settings.protocolVersion===5?(T.nl=y,T.rap=m,T.rh=b):this.settings.bridgeMode&&(T.rh=0,T.rap=!0,T.nl=!0),r("_parseSubscribe: push subscription `%s` to subscription",T),a.subscriptions.push(T)}}}_parseSuback(){r("_parseSuback");let a=this.packet;if(this.packet.granted=[],!!this._parseMessageId()){if(this.settings.protocolVersion===5){let c=this._parseProperties();Object.getOwnPropertyNames(c).length&&(a.properties=c)}if(a.length<=0)return this._emitError(new Error("Malformed suback, no payload specified"));for(;this._pos2&&c!==128)return this._emitError(new Error("Invalid suback QoS, must be 0, 1, 2 or 128"));this.packet.granted.push(c)}}}_parseUnsubscribe(){r("_parseUnsubscribe");let a=this.packet;if(a.unsubscriptions=[],!!this._parseMessageId()){if(this.settings.protocolVersion===5){let c=this._parseProperties();Object.getOwnPropertyNames(c).length&&(a.properties=c)}if(a.length<=0)return this._emitError(new Error("Malformed unsubscribe, no payload specified"));for(;this._pos2){switch(a.reasonCode=this._parseByte(),this.packet.cmd){case"puback":case"pubrec":if(!i.MQTT5_PUBACK_PUBREC_CODES[a.reasonCode])return this._emitError(new Error("Invalid "+this.packet.cmd+" reason code"));break;case"pubrel":case"pubcomp":if(!i.MQTT5_PUBREL_PUBCOMP_CODES[a.reasonCode])return this._emitError(new Error("Invalid "+this.packet.cmd+" reason code"));break}r("_parseConfirmation: packet.reasonCode `%d`",a.reasonCode)}else a.reasonCode=0;if(a.length>3){let c=this._parseProperties();Object.getOwnPropertyNames(c).length&&(a.properties=c)}}return!0}_parseDisconnect(){let a=this.packet;if(r("_parseDisconnect"),this.settings.protocolVersion===5){this._list.length>0?(a.reasonCode=this._parseByte(),i.MQTT5_DISCONNECT_CODES[a.reasonCode]||this._emitError(new Error("Invalid disconnect reason code"))):a.reasonCode=0;let c=this._parseProperties();Object.getOwnPropertyNames(c).length&&(a.properties=c)}return r("_parseDisconnect result: true"),!0}_parseAuth(){r("_parseAuth");let a=this.packet;if(this.settings.protocolVersion!==5)return this._emitError(new Error("Not supported auth packet for this version MQTT"));if(a.reasonCode=this._parseByte(),!i.MQTT5_AUTH_CODES[a.reasonCode])return this._emitError(new Error("Invalid auth reason code"));let c=this._parseProperties();return Object.getOwnPropertyNames(c).length&&(a.properties=c),r("_parseAuth: result: true"),!0}_parseMessageId(){let a=this.packet;return a.messageId=this._parseNum(),a.messageId===null?(this._emitError(new Error("Cannot parse messageId")),!1):(r("_parseMessageId: packet.messageId %d",a.messageId),!0)}_parseString(a){let c=this._parseNum(),d=c+this._pos;if(c===-1||d>this._list.length||d>this.packet.length)return null;let g=this._list.toString("utf8",this._pos,d);return this._pos+=c,r("_parseString: result: %s",g),g}_parseStringPair(){return r("_parseStringPair"),{name:this._parseString(),value:this._parseString()}}_parseBuffer(){let a=this._parseNum(),c=a+this._pos;if(a===-1||c>this._list.length||c>this.packet.length)return null;let d=this._list.slice(this._pos,c);return this._pos+=a,r("_parseBuffer: result: %o",d),d}_parseNum(){if(this._list.length-this._pos<2)return-1;let a=this._list.readUInt16BE(this._pos);return this._pos+=2,r("_parseNum: result: %s",a),a}_parse4ByteNum(){if(this._list.length-this._pos<4)return-1;let a=this._list.readUInt32BE(this._pos);return this._pos+=4,r("_parse4ByteNum: result: %s",a),a}_parseVarByteNum(a){r("_parseVarByteNum");let c=4,d=0,g=1,b=0,m=!1,y,T=this._pos?this._pos:0;for(;d=d&&this._emitError(new Error("Invalid variable byte integer")),T&&(this._pos+=d),m?a?m={bytes:d,value:b}:m=b:m=!1,r("_parseVarByteNum: result: %o",m),m}_parseByte(){let a;return this._pos{he(),ue(),le();var{Buffer:t}=(dt(),Ve(ft)),l=65536,h={},i=t.isBuffer(t.from([1,2]).subarray(0,1));function r(c){let d=t.allocUnsafe(2);return d.writeUInt8(c>>8,0),d.writeUInt8(c&255,1),d}function s(){for(let c=0;c0&&(d=d|128),b.writeUInt8(d,g++);while(c>0&&g<4);return c>0&&(g=0),i?b.subarray(0,g):b.slice(0,g)}function a(c){let d=t.allocUnsafe(4);return d.writeUInt32BE(c,0),d}o.exports={cache:h,generateCache:s,generateNumber:r,genBufVariableByteInt:n,generate4ByteBuffer:a}}),Kl=ye((e,o)=>{he(),ue(),le(),typeof ze>"u"||!ze.version||ze.version.indexOf("v0.")===0||ze.version.indexOf("v1.")===0&&ze.version.indexOf("v1.8.")!==0?o.exports={nextTick:t}:o.exports=ze;function t(l,h,i,r){if(typeof l!="function")throw new TypeError('"callback" argument must be a function');var s=arguments.length,n,a;switch(s){case 0:case 1:return ze.nextTick(l);case 2:return ze.nextTick(function(){l.call(null,h)});case 3:return ze.nextTick(function(){l.call(null,h,i)});case 4:return ze.nextTick(function(){l.call(null,h,i,r)});default:for(n=new Array(s-1),a=0;a{he(),ue(),le();var t=Es(),{Buffer:l}=(dt(),Ve(ft)),h=l.allocUnsafe(0),i=l.from([0]),r=zl(),s=Kl().nextTick,n=zt()("mqtt-packet:writeToStream"),a=r.cache,c=r.generateNumber,d=r.generateCache,g=r.genBufVariableByteInt,b=r.generate4ByteBuffer,m=ie,y=!0;function T(B,_,Y){switch(n("generate called"),_.cork&&(_.cork(),s(U,_)),y&&(y=!1,d()),n("generate: packet.cmd: %s",B.cmd),B.cmd){case"connect":return S(B,_);case"connack":return R(B,_,Y);case"publish":return F(B,_,Y);case"puback":case"pubrec":case"pubrel":case"pubcomp":return W(B,_,Y);case"subscribe":return C(B,_,Y);case"suback":return O(B,_,Y);case"unsubscribe":return M(B,_,Y);case"unsuback":return $(B,_,Y);case"pingreq":case"pingresp":return X(B,_);case"disconnect":return te(B,_,Y);case"auth":return E(B,_,Y);default:return _.destroy(new Error("Unknown command")),!1}}Object.defineProperty(T,"cacheNumbers",{get(){return m===ie},set(B){B?((!a||Object.keys(a).length===0)&&(y=!0),m=ie):(y=!1,m=V)}});function U(B){B.uncork()}function S(B,_,Y){let se=B||{},ee=se.protocolId||"MQTT",J=se.protocolVersion||4,ce=se.will,pe=se.clean,k=se.keepalive||0,N=se.clientId||"",D=se.username,re=se.password,G=se.properties;pe===void 0&&(pe=!0);let j=0;if(!ee||typeof ee!="string"&&!l.isBuffer(ee))return _.destroy(new Error("Invalid protocolId")),!1;if(j+=ee.length+2,J!==3&&J!==4&&J!==5)return _.destroy(new Error("Invalid protocol version")),!1;if(j+=1,(typeof N=="string"||l.isBuffer(N))&&(N||J>=4)&&(N||pe))j+=l.byteLength(N)+2;else{if(J<4)return _.destroy(new Error("clientId must be supplied before 3.1.1")),!1;if(pe*1===0)return _.destroy(new Error("clientId must be given if cleanSession set to 0")),!1}if(typeof k!="number"||k<0||k>65535||k%1!==0)return _.destroy(new Error("Invalid keepalive")),!1;j+=2,j+=1;let K,ve;if(J===5){if(K=Ee(_,G),!K)return!1;j+=K.length}if(ce){if(typeof ce!="object")return _.destroy(new Error("Invalid will")),!1;if(!ce.topic||typeof ce.topic!="string")return _.destroy(new Error("Invalid will topic")),!1;if(j+=l.byteLength(ce.topic)+2,j+=2,ce.payload)if(ce.payload.length>=0)typeof ce.payload=="string"?j+=l.byteLength(ce.payload):j+=ce.payload.length;else return _.destroy(new Error("Invalid will payload")),!1;if(ve={},J===5){if(ve=Ee(_,ce.properties),!ve)return!1;j+=ve.length}}let Se=!1;if(D!=null)if(ae(D))Se=!0,j+=l.byteLength(D)+2;else return _.destroy(new Error("Invalid username")),!1;if(re!=null){if(!Se)return _.destroy(new Error("Username is required to use password")),!1;if(ae(re))j+=Ae(re)+2;else return _.destroy(new Error("Invalid password")),!1}_.write(t.CONNECT_HEADER),Z(_,j),ne(_,ee),se.bridgeMode&&(J+=128),_.write(J===131?t.VERSION131:J===132?t.VERSION132:J===4?t.VERSION4:J===5?t.VERSION5:t.VERSION3);let ke=0;return ke|=D!=null?t.USERNAME_MASK:0,ke|=re!=null?t.PASSWORD_MASK:0,ke|=ce&&ce.retain?t.WILL_RETAIN_MASK:0,ke|=ce&&ce.qos?ce.qos<0&&m(_,N),G==null||G.write(),n("publish: payload: %o",k),_.write(k)}function W(B,_,Y){let se=Y?Y.protocolVersion:4,ee=B||{},J=ee.cmd||"puback",ce=ee.messageId,pe=ee.dup&&J==="pubrel"?t.DUP_MASK:0,k=0,N=ee.reasonCode,D=ee.properties,re=se===5?3:2;if(J==="pubrel"&&(k=1),typeof ce!="number")return _.destroy(new Error("Invalid messageId")),!1;let G=null;if(se===5&&typeof D=="object"){if(G=A(_,D,Y,re),!G)return!1;re+=G.length}return _.write(t.ACKS[J][k][pe][0]),re===3&&(re+=N!==0?1:-1),Z(_,re),m(_,ce),se===5&&re!==2&&_.write(l.from([N])),G!==null?G.write():re===4&&_.write(l.from([0])),!0}function C(B,_,Y){n("subscribe: packet: ");let se=Y?Y.protocolVersion:4,ee=B||{},J=ee.dup?t.DUP_MASK:0,ce=ee.messageId,pe=ee.subscriptions,k=ee.properties,N=0;if(typeof ce!="number")return _.destroy(new Error("Invalid messageId")),!1;N+=2;let D=null;if(se===5){if(D=Ee(_,k),!D)return!1;N+=D.length}if(typeof pe=="object"&&pe.length)for(let G=0;G2)return _.destroy(new Error("Invalid subscriptions - invalid Retain Handling")),!1}N+=l.byteLength(j)+2+1}else return _.destroy(new Error("Invalid subscriptions")),!1;n("subscribe: writing to stream: %o",t.SUBSCRIBE_HEADER),_.write(t.SUBSCRIBE_HEADER[1][J?1:0][0]),Z(_,N),m(_,ce),D!==null&&D.write();let re=!0;for(let G of pe){let j=G.topic,K=G.qos,ve=+G.nl,Se=+G.rap,ke=G.rh,Ue;z(_,j),Ue=t.SUBSCRIBE_OPTIONS_QOS[K],se===5&&(Ue|=ve?t.SUBSCRIBE_OPTIONS_NL:0,Ue|=Se?t.SUBSCRIBE_OPTIONS_RAP:0,Ue|=ke?t.SUBSCRIBE_OPTIONS_RH[ke]:0),re=_.write(l.from([Ue]))}return re}function O(B,_,Y){let se=Y?Y.protocolVersion:4,ee=B||{},J=ee.messageId,ce=ee.granted,pe=ee.properties,k=0;if(typeof J!="number")return _.destroy(new Error("Invalid messageId")),!1;if(k+=2,typeof ce=="object"&&ce.length)for(let D=0;Dt.VARBYTEINT_MAX)return B.destroy(new Error(`Invalid variable byte integer: ${_}`)),!1;let Y=q[_];return Y||(Y=g(_),_<16384&&(q[_]=Y)),n("writeVarByteInt: writing to stream: %o",Y),B.write(Y)}function z(B,_){let Y=l.byteLength(_);return m(B,Y),n("writeString: %s",_),B.write(_,"utf8")}function be(B,_,Y){z(B,_),z(B,Y)}function ie(B,_){return n("writeNumberCached: number: %d",_),n("writeNumberCached: %o",a[_]),B.write(a[_])}function V(B,_){let Y=c(_);return n("writeNumberGenerated: %o",Y),B.write(Y)}function me(B,_){let Y=b(_);return n("write4ByteNumber: %o",Y),B.write(Y)}function ne(B,_){typeof _=="string"?z(B,_):_?(m(B,_.length),B.write(_)):m(B,0)}function Ee(B,_){if(typeof _!="object"||_.length!=null)return{length:1,write(){fe(B,{},0)}};let Y=0;function se(ee,J){let ce=t.propertiesTypes[ee],pe=0;switch(ce){case"byte":{if(typeof J!="boolean")return B.destroy(new Error(`Invalid ${ee}: ${J}`)),!1;pe+=2;break}case"int8":{if(typeof J!="number"||J<0||J>255)return B.destroy(new Error(`Invalid ${ee}: ${J}`)),!1;pe+=2;break}case"binary":{if(J&&J===null)return B.destroy(new Error(`Invalid ${ee}: ${J}`)),!1;pe+=1+l.byteLength(J)+2;break}case"int16":{if(typeof J!="number"||J<0||J>65535)return B.destroy(new Error(`Invalid ${ee}: ${J}`)),!1;pe+=3;break}case"int32":{if(typeof J!="number"||J<0||J>4294967295)return B.destroy(new Error(`Invalid ${ee}: ${J}`)),!1;pe+=5;break}case"var":{if(typeof J!="number"||J<0||J>268435455)return B.destroy(new Error(`Invalid ${ee}: ${J}`)),!1;pe+=1+l.byteLength(g(J));break}case"string":{if(typeof J!="string")return B.destroy(new Error(`Invalid ${ee}: ${J}`)),!1;pe+=3+l.byteLength(J.toString());break}case"pair":{if(typeof J!="object")return B.destroy(new Error(`Invalid ${ee}: ${J}`)),!1;pe+=Object.getOwnPropertyNames(J).reduce((k,N)=>{let D=J[N];return Array.isArray(D)?k+=D.reduce((re,G)=>(re+=3+l.byteLength(N.toString())+2+l.byteLength(G.toString()),re),0):k+=3+l.byteLength(N.toString())+2+l.byteLength(J[N].toString()),k},0);break}default:return B.destroy(new Error(`Invalid property ${ee}: ${J}`)),!1}return pe}if(_)for(let ee in _){let J=0,ce=0,pe=_[ee];if(Array.isArray(pe))for(let k=0;kJ;){let pe=ee.shift();if(pe&&_[pe])delete _[pe],ce=Ee(B,_);else return!1}return ce}function Q(B,_,Y){switch(t.propertiesTypes[_]){case"byte":{B.write(l.from([t.properties[_]])),B.write(l.from([+Y]));break}case"int8":{B.write(l.from([t.properties[_]])),B.write(l.from([Y]));break}case"binary":{B.write(l.from([t.properties[_]])),ne(B,Y);break}case"int16":{B.write(l.from([t.properties[_]])),m(B,Y);break}case"int32":{B.write(l.from([t.properties[_]])),me(B,Y);break}case"var":{B.write(l.from([t.properties[_]])),Z(B,Y);break}case"string":{B.write(l.from([t.properties[_]])),z(B,Y);break}case"pair":{Object.getOwnPropertyNames(Y).forEach(se=>{let ee=Y[se];Array.isArray(ee)?ee.forEach(J=>{B.write(l.from([t.properties[_]])),be(B,se.toString(),J.toString())}):(B.write(l.from([t.properties[_]])),be(B,se.toString(),ee.toString()))});break}default:return B.destroy(new Error(`Invalid property ${_} value: ${Y}`)),!1}}function fe(B,_,Y){Z(B,Y);for(let se in _)if(Object.prototype.hasOwnProperty.call(_,se)&&_[se]!==null){let ee=_[se];if(Array.isArray(ee))for(let J=0;J{he(),ue(),le();var t=Ss(),{EventEmitter:l}=(Ar(),Ve(ur)),{Buffer:h}=(dt(),Ve(ft));function i(s,n){let a=new r;return t(s,a,n),a.concat()}var r=class extends l{constructor(){super(),this._array=new Array(20),this._i=0}write(s){return this._array[this._i++]=s,!0}concat(){let s=0,n=new Array(this._array.length),a=this._array,c=0,d;for(d=0;d{he(),ue(),le(),e.parser=Hl().parser,e.generate=Yl(),e.writeToStream=Ss()}),As=ye(e=>{he(),ue(),le(),Object.defineProperty(e,"__esModule",{value:!0});var o=class{constructor(){this.nextId=Math.max(1,Math.floor(Math.random()*65535))}allocate(){let t=this.nextId++;return this.nextId===65536&&(this.nextId=1),t}getLastAllocated(){return this.nextId===1?65535:this.nextId-1}register(t){return!0}deallocate(t){}clear(){}};e.default=o}),Gl=ye((e,o)=>{he(),ue(),le(),o.exports=l;function t(i){return i instanceof Vr?Vr.from(i):new i.constructor(i.buffer.slice(),i.byteOffset,i.length)}function l(i){if(i=i||{},i.circles)return h(i);return i.proto?n:s;function r(a,c){for(var d=Object.keys(a),g=new Array(d.length),b=0;b{he(),ue(),le(),o.exports=Gl()()}),Xl=ye(e=>{he(),ue(),le(),Object.defineProperty(e,"__esModule",{value:!0}),e.validateTopics=e.validateTopic=void 0;function o(l){let h=l.split("/");for(let i=0;i{he(),ue(),le(),Object.defineProperty(e,"__esModule",{value:!0});var o=pr(),t={objectMode:!0},l={clean:!0},h=class{constructor(i){this.options=i||{},this.options=Object.assign(Object.assign({},l),i),this._inflights=new Map}put(i,r){return this._inflights.set(i.messageId,i),r&&r(),this}createStream(){let i=new o.Readable(t),r=[],s=!1,n=0;return this._inflights.forEach((a,c)=>{r.push(a)}),i._read=()=>{!s&&n{if(!s)return s=!0,setTimeout(()=>{i.emit("close")},0),i},i}del(i,r){let s=this._inflights.get(i.messageId);return s?(this._inflights.delete(i.messageId),r(null,s)):r&&r(new Error("missing packet")),this}get(i,r){let s=this._inflights.get(i.messageId);return s?r(null,s):r&&r(new Error("missing packet")),this}close(i){this.options.clean&&(this._inflights=null),i&&i()}};e.default=h}),Zl=ye(e=>{he(),ue(),le(),Object.defineProperty(e,"__esModule",{value:!0});var o=[0,16,128,131,135,144,145,151,153],t=(l,h,i)=>{l.log("handlePublish: packet %o",h),i=typeof i<"u"?i:l.noop;let r=h.topic.toString(),s=h.payload,{qos:n}=h,{messageId:a}=h,{options:c}=l;if(l.options.protocolVersion===5){let d;if(h.properties&&(d=h.properties.topicAlias),typeof d<"u")if(r.length===0)if(d>0&&d<=65535){let g=l.topicAliasRecv.getTopicByAlias(d);if(g)r=g,l.log("handlePublish :: topic complemented by alias. topic: %s - alias: %d",r,d);else{l.log("handlePublish :: unregistered topic alias. alias: %d",d),l.emit("error",new Error("Received unregistered Topic Alias"));return}}else{l.log("handlePublish :: topic alias out of range. alias: %d",d),l.emit("error",new Error("Received Topic Alias is out of range"));return}else if(l.topicAliasRecv.put(r,d))l.log("handlePublish :: registered topic: %s - alias: %d",r,d);else{l.log("handlePublish :: topic alias out of range. alias: %d",d),l.emit("error",new Error("Received Topic Alias is out of range"));return}}switch(l.log("handlePublish: qos %d",n),n){case 2:{c.customHandleAcks(r,s,h,(d,g)=>{if(typeof d=="number"&&(g=d,d=null),d)return l.emit("error",d);if(o.indexOf(g)===-1)return l.emit("error",new Error("Wrong reason code for pubrec"));g?l._sendPacket({cmd:"pubrec",messageId:a,reasonCode:g},i):l.incomingStore.put(h,()=>{l._sendPacket({cmd:"pubrec",messageId:a},i)})});break}case 1:{c.customHandleAcks(r,s,h,(d,g)=>{if(typeof d=="number"&&(g=d,d=null),d)return l.emit("error",d);if(o.indexOf(g)===-1)return l.emit("error",new Error("Wrong reason code for puback"));g||l.emit("message",r,s,h),l.handleMessage(h,b=>{if(b)return i&&i(b);l._sendPacket({cmd:"puback",messageId:a,reasonCode:g},i)})});break}case 0:l.emit("message",r,s,h),l.handleMessage(h,i);break;default:l.log("handlePublish: unknown QoS. Doing nothing.");break}};e.default=t}),eu=ye((e,o)=>{o.exports={version:"5.5.5"}}),Lr=ye(e=>{he(),ue(),le(),Object.defineProperty(e,"__esModule",{value:!0}),e.MQTTJS_VERSION=e.nextTick=e.applyMixin=e.ErrorWithReasonCode=void 0;var o=class Fa extends Error{constructor(h,i){super(h),this.code=i,Object.setPrototypeOf(this,Fa.prototype),Object.getPrototypeOf(this).name="ErrorWithReasonCode"}};e.ErrorWithReasonCode=o;function t(l,h,i=!1){var r;let s=[h];for(;;){let n=s[0],a=Object.getPrototypeOf(n);if(a!=null&&a.prototype)s.unshift(a);else break}for(let n of s)for(let a of Object.getOwnPropertyNames(n.prototype))(i||a!=="constructor")&&Object.defineProperty(l.prototype,a,(r=Object.getOwnPropertyDescriptor(n.prototype,a))!==null&&r!==void 0?r:Object.create(null))}e.applyMixin=t,e.nextTick=typeof(ze==null?void 0:ze.nextTick)=="function"?ze.nextTick:l=>{setTimeout(l,0)},e.MQTTJS_VERSION=eu().version}),Zr=ye(e=>{he(),ue(),le(),Object.defineProperty(e,"__esModule",{value:!0}),e.ReasonCodes=void 0,e.ReasonCodes={0:"",1:"Unacceptable protocol version",2:"Identifier rejected",3:"Server unavailable",4:"Bad username or password",5:"Not authorized",16:"No matching subscribers",17:"No subscription existed",128:"Unspecified error",129:"Malformed Packet",130:"Protocol Error",131:"Implementation specific error",132:"Unsupported Protocol Version",133:"Client Identifier not valid",134:"Bad User Name or Password",135:"Not authorized",136:"Server unavailable",137:"Server busy",138:"Banned",139:"Server shutting down",140:"Bad authentication method",141:"Keep Alive timeout",142:"Session taken over",143:"Topic Filter invalid",144:"Topic Name invalid",145:"Packet identifier in use",146:"Packet Identifier not found",147:"Receive Maximum exceeded",148:"Topic Alias invalid",149:"Packet too large",150:"Message rate too high",151:"Quota exceeded",152:"Administrative action",153:"Payload format invalid",154:"Retain not supported",155:"QoS not supported",156:"Use another server",157:"Server moved",158:"Shared Subscriptions not supported",159:"Connection rate exceeded",160:"Maximum connect time",161:"Subscription Identifiers not supported",162:"Wildcard Subscriptions not supported"};var o=(t,l)=>{let{messageId:h}=l,i=l.cmd,r=null,s=t.outgoing[h]?t.outgoing[h].cb:null,n;if(!s){t.log("_handleAck :: Server sent an ack in error. Ignoring.");return}switch(t.log("_handleAck :: packet type",i),i){case"pubcomp":case"puback":{let a=l.reasonCode;a&&a>0&&a!==16?(n=new Error(`Publish error: ${e.ReasonCodes[a]}`),n.code=a,t._removeOutgoingAndStoreMessage(h,()=>{s(n,l)})):t._removeOutgoingAndStoreMessage(h,s);break}case"pubrec":{r={cmd:"pubrel",qos:2,messageId:h};let a=l.reasonCode;a&&a>0&&a!==16?(n=new Error(`Publish error: ${e.ReasonCodes[a]}`),n.code=a,t._removeOutgoingAndStoreMessage(h,()=>{s(n,l)})):t._sendPacket(r);break}case"suback":{delete t.outgoing[h],t.messageIdProvider.deallocate(h);let a=l.granted;for(let c=0;c{delete t._resubscribeTopics[g]})}delete t.messageIdToTopic[h],t._invokeStoreProcessingQueue(),s(null,l);break}case"unsuback":{delete t.outgoing[h],t.messageIdProvider.deallocate(h),t._invokeStoreProcessingQueue(),s(null);break}default:t.emit("error",new Error("unrecognized packet type"))}t.disconnecting&&Object.keys(t.outgoing).length===0&&t.emit("outgoingEmpty")};e.default=o}),tu=ye(e=>{he(),ue(),le(),Object.defineProperty(e,"__esModule",{value:!0});var o=Lr(),t=Zr(),l=(h,i)=>{let{options:r}=h,s=r.protocolVersion,n=s===5?i.reasonCode:i.returnCode;if(s!==5){let a=new o.ErrorWithReasonCode(`Protocol error: Auth packets are only supported in MQTT 5. Your version:${s}`,n);h.emit("error",a);return}h.handleAuth(i,(a,c)=>{if(a){h.emit("error",a);return}if(n===24)h.reconnecting=!1,h._sendPacket(c);else{let d=new o.ErrorWithReasonCode(`Connection refused: ${t.ReasonCodes[n]}`,n);h.emit("error",d)}})};e.default=l}),ru=ye(e=>{var b,m,y,T,U,S,R,F,W,C,O,M,$,X,te,E,q,Z,z,be,ie,V,me,ne,Ee,A,uo,fe,Ae,ae,B,_,Wa,se,ee,J,ce,rr,k,nr,D,ho,G,pn,K,gn,Se,Xe,Ue,co,u,Fr,w;he(),ue(),le(),Object.defineProperty(e,"__esModule",{value:!0}),e.LRUCache=void 0;var o=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,t=new Set,l=typeof ze=="object"&&ze?ze:{},h=(I,v,P,H)=>{typeof l.emitWarning=="function"?l.emitWarning(I,v,P,H):console.error(`[${P}] ${v}: ${I}`)},i=globalThis.AbortController,r=globalThis.AbortSignal;if(typeof i>"u"){r=class{constructor(){rt(this,"onabort");rt(this,"_onabort",[]);rt(this,"reason");rt(this,"aborted",!1)}addEventListener(P,H){this._onabort.push(H)}},i=class{constructor(){rt(this,"signal",new r);v()}abort(P){var H,de;if(!this.signal.aborted){this.signal.reason=P,this.signal.aborted=!0;for(let oe of this.signal._onabort)oe(P);(de=(H=this.signal).onabort)==null||de.call(H,P)}}};let I=((b=l.env)==null?void 0:b.LRU_CACHE_IGNORE_AC_WARNING)!=="1",v=()=>{I&&(I=!1,h("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",v))}}var s=I=>!t.has(I),n=I=>I&&I===Math.floor(I)&&I>0&&isFinite(I),a=I=>n(I)?I<=Math.pow(2,8)?Uint8Array:I<=Math.pow(2,16)?Uint16Array:I<=Math.pow(2,32)?Uint32Array:I<=Number.MAX_SAFE_INTEGER?c:null:null,c=class extends Array{constructor(I){super(I),this.fill(0)}},d=(m=class{constructor(v,P){rt(this,"heap");rt(this,"length");if(!x(m,y))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new P(v),this.length=0}static create(v){let P=a(v);if(!P)return[];Ce(m,y,!0);let H=new m(v,P);return Ce(m,y,!1),H}push(v){this.heap[this.length++]=v}pop(){return this.heap[--this.length]}},y=new WeakMap,Me(m,y,!1),m),g=(w=class{constructor(v){Me(this,A);Me(this,_);Me(this,ce);Me(this,k);Me(this,D);Me(this,G);Me(this,K);Me(this,Se);Me(this,Ue);Me(this,u);Me(this,T,void 0);Me(this,U,void 0);Me(this,S,void 0);Me(this,R,void 0);Me(this,F,void 0);rt(this,"ttl");rt(this,"ttlResolution");rt(this,"ttlAutopurge");rt(this,"updateAgeOnGet");rt(this,"updateAgeOnHas");rt(this,"allowStale");rt(this,"noDisposeOnSet");rt(this,"noUpdateTTL");rt(this,"maxEntrySize");rt(this,"sizeCalculation");rt(this,"noDeleteOnFetchRejection");rt(this,"noDeleteOnStaleGet");rt(this,"allowStaleOnFetchAbort");rt(this,"allowStaleOnFetchRejection");rt(this,"ignoreFetchAbort");Me(this,W,void 0);Me(this,C,void 0);Me(this,O,void 0);Me(this,M,void 0);Me(this,$,void 0);Me(this,X,void 0);Me(this,te,void 0);Me(this,E,void 0);Me(this,q,void 0);Me(this,Z,void 0);Me(this,z,void 0);Me(this,be,void 0);Me(this,ie,void 0);Me(this,V,void 0);Me(this,me,void 0);Me(this,ne,void 0);Me(this,Ee,void 0);Me(this,fe,()=>{});Me(this,Ae,()=>{});Me(this,ae,()=>{});Me(this,B,()=>!1);Me(this,se,v=>{});Me(this,ee,(v,P,H)=>{});Me(this,J,(v,P,H,de)=>{if(H||de)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});let{max:P=0,ttl:H,ttlResolution:de=1,ttlAutopurge:oe,updateAgeOnGet:we,updateAgeOnHas:Ie,allowStale:Oe,dispose:Ke,disposeAfter:pt,noDisposeOnSet:Ne,noUpdateTTL:ht,maxSize:Je=0,maxEntrySize:et=0,sizeCalculation:tt,fetchMethod:at,noDeleteOnFetchRejection:xe,noDeleteOnStaleGet:Ye,allowStaleOnFetchRejection:gt,allowStaleOnFetchAbort:lt,ignoreFetchAbort:At}=v;if(P!==0&&!n(P))throw new TypeError("max option must be a nonnegative integer");let jt=P?a(P):Array;if(!jt)throw new Error("invalid max value: "+P);if(Ce(this,T,P),Ce(this,U,Je),this.maxEntrySize=et||x(this,U),this.sizeCalculation=tt,this.sizeCalculation){if(!x(this,U)&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(at!==void 0&&typeof at!="function")throw new TypeError("fetchMethod must be a function if specified");if(Ce(this,F,at),Ce(this,ne,!!at),Ce(this,O,new Map),Ce(this,M,new Array(P).fill(void 0)),Ce(this,$,new Array(P).fill(void 0)),Ce(this,X,new jt(P)),Ce(this,te,new jt(P)),Ce(this,E,0),Ce(this,q,0),Ce(this,Z,d.create(P)),Ce(this,W,0),Ce(this,C,0),typeof Ke=="function"&&Ce(this,S,Ke),typeof pt=="function"?(Ce(this,R,pt),Ce(this,z,[])):(Ce(this,R,void 0),Ce(this,z,void 0)),Ce(this,me,!!x(this,S)),Ce(this,Ee,!!x(this,R)),this.noDisposeOnSet=!!Ne,this.noUpdateTTL=!!ht,this.noDeleteOnFetchRejection=!!xe,this.allowStaleOnFetchRejection=!!gt,this.allowStaleOnFetchAbort=!!lt,this.ignoreFetchAbort=!!At,this.maxEntrySize!==0){if(x(this,U)!==0&&!n(x(this,U)))throw new TypeError("maxSize must be a positive integer if specified");if(!n(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");Re(this,_,Wa).call(this)}if(this.allowStale=!!Oe,this.noDeleteOnStaleGet=!!Ye,this.updateAgeOnGet=!!we,this.updateAgeOnHas=!!Ie,this.ttlResolution=n(de)||de===0?de:1,this.ttlAutopurge=!!oe,this.ttl=H||0,this.ttl){if(!n(this.ttl))throw new TypeError("ttl must be a positive integer if specified");Re(this,A,uo).call(this)}if(x(this,T)===0&&this.ttl===0&&x(this,U)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!x(this,T)&&!x(this,U)){let Pt="LRU_CACHE_UNBOUNDED";s(Pt)&&(t.add(Pt),h("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",Pt,w))}}static unsafeExposeInternals(v){return{starts:x(v,ie),ttls:x(v,V),sizes:x(v,be),keyMap:x(v,O),keyList:x(v,M),valList:x(v,$),next:x(v,X),prev:x(v,te),get head(){return x(v,E)},get tail(){return x(v,q)},free:x(v,Z),isBackgroundFetch:P=>{var H;return Re(H=v,Se,Xe).call(H,P)},backgroundFetch:(P,H,de,oe)=>{var we;return Re(we=v,K,gn).call(we,P,H,de,oe)},moveToTail:P=>{var H;return Re(H=v,u,Fr).call(H,P)},indexes:P=>{var H;return Re(H=v,ce,rr).call(H,P)},rindexes:P=>{var H;return Re(H=v,k,nr).call(H,P)},isStale:P=>{var H;return x(H=v,B).call(H,P)}}}get max(){return x(this,T)}get maxSize(){return x(this,U)}get calculatedSize(){return x(this,C)}get size(){return x(this,W)}get fetchMethod(){return x(this,F)}get dispose(){return x(this,S)}get disposeAfter(){return x(this,R)}getRemainingTTL(v){return x(this,O).has(v)?1/0:0}*entries(){for(let v of Re(this,ce,rr).call(this))x(this,$)[v]!==void 0&&x(this,M)[v]!==void 0&&!Re(this,Se,Xe).call(this,x(this,$)[v])&&(yield[x(this,M)[v],x(this,$)[v]])}*rentries(){for(let v of Re(this,k,nr).call(this))x(this,$)[v]!==void 0&&x(this,M)[v]!==void 0&&!Re(this,Se,Xe).call(this,x(this,$)[v])&&(yield[x(this,M)[v],x(this,$)[v]])}*keys(){for(let v of Re(this,ce,rr).call(this)){let P=x(this,M)[v];P!==void 0&&!Re(this,Se,Xe).call(this,x(this,$)[v])&&(yield P)}}*rkeys(){for(let v of Re(this,k,nr).call(this)){let P=x(this,M)[v];P!==void 0&&!Re(this,Se,Xe).call(this,x(this,$)[v])&&(yield P)}}*values(){for(let v of Re(this,ce,rr).call(this))x(this,$)[v]!==void 0&&!Re(this,Se,Xe).call(this,x(this,$)[v])&&(yield x(this,$)[v])}*rvalues(){for(let v of Re(this,k,nr).call(this))x(this,$)[v]!==void 0&&!Re(this,Se,Xe).call(this,x(this,$)[v])&&(yield x(this,$)[v])}[Symbol.iterator](){return this.entries()}find(v,P={}){for(let H of Re(this,ce,rr).call(this)){let de=x(this,$)[H],oe=Re(this,Se,Xe).call(this,de)?de.__staleWhileFetching:de;if(oe!==void 0&&v(oe,x(this,M)[H],this))return this.get(x(this,M)[H],P)}}forEach(v,P=this){for(let H of Re(this,ce,rr).call(this)){let de=x(this,$)[H],oe=Re(this,Se,Xe).call(this,de)?de.__staleWhileFetching:de;oe!==void 0&&v.call(P,oe,x(this,M)[H],this)}}rforEach(v,P=this){for(let H of Re(this,k,nr).call(this)){let de=x(this,$)[H],oe=Re(this,Se,Xe).call(this,de)?de.__staleWhileFetching:de;oe!==void 0&&v.call(P,oe,x(this,M)[H],this)}}purgeStale(){let v=!1;for(let P of Re(this,k,nr).call(this,{allowStale:!0}))x(this,B).call(this,P)&&(this.delete(x(this,M)[P]),v=!0);return v}dump(){let v=[];for(let P of Re(this,ce,rr).call(this,{allowStale:!0})){let H=x(this,M)[P],de=x(this,$)[P],oe=Re(this,Se,Xe).call(this,de)?de.__staleWhileFetching:de;if(oe===void 0||H===void 0)continue;let we={value:oe};if(x(this,V)&&x(this,ie)){we.ttl=x(this,V)[P];let Ie=o.now()-x(this,ie)[P];we.start=Math.floor(Date.now()-Ie)}x(this,be)&&(we.size=x(this,be)[P]),v.unshift([H,we])}return v}load(v){this.clear();for(let[P,H]of v){if(H.start){let de=Date.now()-H.start;H.start=o.now()-de}this.set(P,H.value,H)}}set(v,P,H={}){var ht,Je,et,tt,at;if(P===void 0)return this.delete(v),this;let{ttl:de=this.ttl,start:oe,noDisposeOnSet:we=this.noDisposeOnSet,sizeCalculation:Ie=this.sizeCalculation,status:Oe}=H,{noUpdateTTL:Ke=this.noUpdateTTL}=H,pt=x(this,J).call(this,v,P,H.size||0,Ie);if(this.maxEntrySize&&pt>this.maxEntrySize)return Oe&&(Oe.set="miss",Oe.maxEntrySizeExceeded=!0),this.delete(v),this;let Ne=x(this,W)===0?void 0:x(this,O).get(v);if(Ne===void 0)Ne=x(this,W)===0?x(this,q):x(this,Z).length!==0?x(this,Z).pop():x(this,W)===x(this,T)?Re(this,G,pn).call(this,!1):x(this,W),x(this,M)[Ne]=v,x(this,$)[Ne]=P,x(this,O).set(v,Ne),x(this,X)[x(this,q)]=Ne,x(this,te)[Ne]=x(this,q),Ce(this,q,Ne),dn(this,W)._++,x(this,ee).call(this,Ne,pt,Oe),Oe&&(Oe.set="add"),Ke=!1;else{Re(this,u,Fr).call(this,Ne);let xe=x(this,$)[Ne];if(P!==xe){if(x(this,ne)&&Re(this,Se,Xe).call(this,xe)){xe.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:Ye}=xe;Ye!==void 0&&!we&&(x(this,me)&&((ht=x(this,S))==null||ht.call(this,Ye,v,"set")),x(this,Ee)&&((Je=x(this,z))==null||Je.push([Ye,v,"set"])))}else we||(x(this,me)&&((et=x(this,S))==null||et.call(this,xe,v,"set")),x(this,Ee)&&((tt=x(this,z))==null||tt.push([xe,v,"set"])));if(x(this,se).call(this,Ne),x(this,ee).call(this,Ne,pt,Oe),x(this,$)[Ne]=P,Oe){Oe.set="replace";let Ye=xe&&Re(this,Se,Xe).call(this,xe)?xe.__staleWhileFetching:xe;Ye!==void 0&&(Oe.oldValue=Ye)}}else Oe&&(Oe.set="update")}if(de!==0&&!x(this,V)&&Re(this,A,uo).call(this),x(this,V)&&(Ke||x(this,ae).call(this,Ne,de,oe),Oe&&x(this,Ae).call(this,Oe,Ne)),!we&&x(this,Ee)&&x(this,z)){let xe=x(this,z),Ye;for(;Ye=xe==null?void 0:xe.shift();)(at=x(this,R))==null||at.call(this,...Ye)}return this}pop(){var v;try{for(;x(this,W);){let P=x(this,$)[x(this,E)];if(Re(this,G,pn).call(this,!0),Re(this,Se,Xe).call(this,P)){if(P.__staleWhileFetching)return P.__staleWhileFetching}else if(P!==void 0)return P}}finally{if(x(this,Ee)&&x(this,z)){let P=x(this,z),H;for(;H=P==null?void 0:P.shift();)(v=x(this,R))==null||v.call(this,...H)}}}has(v,P={}){let{updateAgeOnHas:H=this.updateAgeOnHas,status:de}=P,oe=x(this,O).get(v);if(oe!==void 0){let we=x(this,$)[oe];if(Re(this,Se,Xe).call(this,we)&&we.__staleWhileFetching===void 0)return!1;if(x(this,B).call(this,oe))de&&(de.has="stale",x(this,Ae).call(this,de,oe));else return H&&x(this,fe).call(this,oe),de&&(de.has="hit",x(this,Ae).call(this,de,oe)),!0}else de&&(de.has="miss");return!1}peek(v,P={}){let{allowStale:H=this.allowStale}=P,de=x(this,O).get(v);if(de!==void 0&&(H||!x(this,B).call(this,de))){let oe=x(this,$)[de];return Re(this,Se,Xe).call(this,oe)?oe.__staleWhileFetching:oe}}async fetch(v,P={}){let{allowStale:H=this.allowStale,updateAgeOnGet:de=this.updateAgeOnGet,noDeleteOnStaleGet:oe=this.noDeleteOnStaleGet,ttl:we=this.ttl,noDisposeOnSet:Ie=this.noDisposeOnSet,size:Oe=0,sizeCalculation:Ke=this.sizeCalculation,noUpdateTTL:pt=this.noUpdateTTL,noDeleteOnFetchRejection:Ne=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:ht=this.allowStaleOnFetchRejection,ignoreFetchAbort:Je=this.ignoreFetchAbort,allowStaleOnFetchAbort:et=this.allowStaleOnFetchAbort,context:tt,forceRefresh:at=!1,status:xe,signal:Ye}=P;if(!x(this,ne))return xe&&(xe.fetch="get"),this.get(v,{allowStale:H,updateAgeOnGet:de,noDeleteOnStaleGet:oe,status:xe});let gt={allowStale:H,updateAgeOnGet:de,noDeleteOnStaleGet:oe,ttl:we,noDisposeOnSet:Ie,size:Oe,sizeCalculation:Ke,noUpdateTTL:pt,noDeleteOnFetchRejection:Ne,allowStaleOnFetchRejection:ht,allowStaleOnFetchAbort:et,ignoreFetchAbort:Je,status:xe,signal:Ye},lt=x(this,O).get(v);if(lt===void 0){xe&&(xe.fetch="miss");let At=Re(this,K,gn).call(this,v,lt,gt,tt);return At.__returned=At}else{let At=x(this,$)[lt];if(Re(this,Se,Xe).call(this,At)){let fn=H&&At.__staleWhileFetching!==void 0;return xe&&(xe.fetch="inflight",fn&&(xe.returnedStale=!0)),fn?At.__staleWhileFetching:At.__returned=At}let jt=x(this,B).call(this,lt);if(!at&&!jt)return xe&&(xe.fetch="hit"),Re(this,u,Fr).call(this,lt),de&&x(this,fe).call(this,lt),xe&&x(this,Ae).call(this,xe,lt),At;let Pt=Re(this,K,gn).call(this,v,lt,gt,tt),cn=Pt.__staleWhileFetching!==void 0&&H;return xe&&(xe.fetch=jt?"stale":"refresh",cn&&jt&&(xe.returnedStale=!0)),cn?Pt.__staleWhileFetching:Pt.__returned=Pt}}get(v,P={}){let{allowStale:H=this.allowStale,updateAgeOnGet:de=this.updateAgeOnGet,noDeleteOnStaleGet:oe=this.noDeleteOnStaleGet,status:we}=P,Ie=x(this,O).get(v);if(Ie!==void 0){let Oe=x(this,$)[Ie],Ke=Re(this,Se,Xe).call(this,Oe);return we&&x(this,Ae).call(this,we,Ie),x(this,B).call(this,Ie)?(we&&(we.get="stale"),Ke?(we&&H&&Oe.__staleWhileFetching!==void 0&&(we.returnedStale=!0),H?Oe.__staleWhileFetching:void 0):(oe||this.delete(v),we&&H&&(we.returnedStale=!0),H?Oe:void 0)):(we&&(we.get="hit"),Ke?Oe.__staleWhileFetching:(Re(this,u,Fr).call(this,Ie),de&&x(this,fe).call(this,Ie),Oe))}else we&&(we.get="miss")}delete(v){var H,de,oe,we;let P=!1;if(x(this,W)!==0){let Ie=x(this,O).get(v);if(Ie!==void 0)if(P=!0,x(this,W)===1)this.clear();else{x(this,se).call(this,Ie);let Oe=x(this,$)[Ie];Re(this,Se,Xe).call(this,Oe)?Oe.__abortController.abort(new Error("deleted")):(x(this,me)||x(this,Ee))&&(x(this,me)&&((H=x(this,S))==null||H.call(this,Oe,v,"delete")),x(this,Ee)&&((de=x(this,z))==null||de.push([Oe,v,"delete"]))),x(this,O).delete(v),x(this,M)[Ie]=void 0,x(this,$)[Ie]=void 0,Ie===x(this,q)?Ce(this,q,x(this,te)[Ie]):Ie===x(this,E)?Ce(this,E,x(this,X)[Ie]):(x(this,X)[x(this,te)[Ie]]=x(this,X)[Ie],x(this,te)[x(this,X)[Ie]]=x(this,te)[Ie]),dn(this,W)._--,x(this,Z).push(Ie)}}if(x(this,Ee)&&((oe=x(this,z))!=null&&oe.length)){let Ie=x(this,z),Oe;for(;Oe=Ie==null?void 0:Ie.shift();)(we=x(this,R))==null||we.call(this,...Oe)}return P}clear(){var v,P,H;for(let de of Re(this,k,nr).call(this,{allowStale:!0})){let oe=x(this,$)[de];if(Re(this,Se,Xe).call(this,oe))oe.__abortController.abort(new Error("deleted"));else{let we=x(this,M)[de];x(this,me)&&((v=x(this,S))==null||v.call(this,oe,we,"delete")),x(this,Ee)&&((P=x(this,z))==null||P.push([oe,we,"delete"]))}}if(x(this,O).clear(),x(this,$).fill(void 0),x(this,M).fill(void 0),x(this,V)&&x(this,ie)&&(x(this,V).fill(0),x(this,ie).fill(0)),x(this,be)&&x(this,be).fill(0),Ce(this,E,0),Ce(this,q,0),x(this,Z).length=0,Ce(this,C,0),Ce(this,W,0),x(this,Ee)&&x(this,z)){let de=x(this,z),oe;for(;oe=de==null?void 0:de.shift();)(H=x(this,R))==null||H.call(this,...oe)}}},T=new WeakMap,U=new WeakMap,S=new WeakMap,R=new WeakMap,F=new WeakMap,W=new WeakMap,C=new WeakMap,O=new WeakMap,M=new WeakMap,$=new WeakMap,X=new WeakMap,te=new WeakMap,E=new WeakMap,q=new WeakMap,Z=new WeakMap,z=new WeakMap,be=new WeakMap,ie=new WeakMap,V=new WeakMap,me=new WeakMap,ne=new WeakMap,Ee=new WeakMap,A=new WeakSet,uo=function(){let v=new c(x(this,T)),P=new c(x(this,T));Ce(this,V,v),Ce(this,ie,P),Ce(this,ae,(oe,we,Ie=o.now())=>{if(P[oe]=we!==0?Ie:0,v[oe]=we,we!==0&&this.ttlAutopurge){let Oe=setTimeout(()=>{x(this,B).call(this,oe)&&this.delete(x(this,M)[oe])},we+1);Oe.unref&&Oe.unref()}}),Ce(this,fe,oe=>{P[oe]=v[oe]!==0?o.now():0}),Ce(this,Ae,(oe,we)=>{if(v[we]){let Ie=v[we],Oe=P[we];oe.ttl=Ie,oe.start=Oe,oe.now=H||de();let Ke=oe.now-Oe;oe.remainingTTL=Ie-Ke}});let H=0,de=()=>{let oe=o.now();if(this.ttlResolution>0){H=oe;let we=setTimeout(()=>H=0,this.ttlResolution);we.unref&&we.unref()}return oe};this.getRemainingTTL=oe=>{let we=x(this,O).get(oe);if(we===void 0)return 0;let Ie=v[we],Oe=P[we];if(Ie===0||Oe===0)return 1/0;let Ke=(H||de())-Oe;return Ie-Ke},Ce(this,B,oe=>v[oe]!==0&&P[oe]!==0&&(H||de())-P[oe]>v[oe])},fe=new WeakMap,Ae=new WeakMap,ae=new WeakMap,B=new WeakMap,_=new WeakSet,Wa=function(){let v=new c(x(this,T));Ce(this,C,0),Ce(this,be,v),Ce(this,se,P=>{Ce(this,C,x(this,C)-v[P]),v[P]=0}),Ce(this,J,(P,H,de,oe)=>{if(Re(this,Se,Xe).call(this,H))return 0;if(!n(de))if(oe){if(typeof oe!="function")throw new TypeError("sizeCalculation must be a function");if(de=oe(H,P),!n(de))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return de}),Ce(this,ee,(P,H,de)=>{if(v[P]=H,x(this,U)){let oe=x(this,U)-v[P];for(;x(this,C)>oe;)Re(this,G,pn).call(this,!0)}Ce(this,C,x(this,C)+v[P]),de&&(de.entrySize=H,de.totalCalculatedSize=x(this,C))})},se=new WeakMap,ee=new WeakMap,J=new WeakMap,ce=new WeakSet,rr=function*({allowStale:v=this.allowStale}={}){if(x(this,W))for(let P=x(this,q);!(!Re(this,D,ho).call(this,P)||((v||!x(this,B).call(this,P))&&(yield P),P===x(this,E)));)P=x(this,te)[P]},k=new WeakSet,nr=function*({allowStale:v=this.allowStale}={}){if(x(this,W))for(let P=x(this,E);!(!Re(this,D,ho).call(this,P)||((v||!x(this,B).call(this,P))&&(yield P),P===x(this,q)));)P=x(this,X)[P]},D=new WeakSet,ho=function(v){return v!==void 0&&x(this,O).get(x(this,M)[v])===v},G=new WeakSet,pn=function(v){var oe,we;let P=x(this,E),H=x(this,M)[P],de=x(this,$)[P];return x(this,ne)&&Re(this,Se,Xe).call(this,de)?de.__abortController.abort(new Error("evicted")):(x(this,me)||x(this,Ee))&&(x(this,me)&&((oe=x(this,S))==null||oe.call(this,de,H,"evict")),x(this,Ee)&&((we=x(this,z))==null||we.push([de,H,"evict"]))),x(this,se).call(this,P),v&&(x(this,M)[P]=void 0,x(this,$)[P]=void 0,x(this,Z).push(P)),x(this,W)===1?(Ce(this,E,Ce(this,q,0)),x(this,Z).length=0):Ce(this,E,x(this,X)[P]),x(this,O).delete(H),dn(this,W)._--,P},K=new WeakSet,gn=function(v,P,H,de){let oe=P===void 0?void 0:x(this,$)[P];if(Re(this,Se,Xe).call(this,oe))return oe;let we=new i,{signal:Ie}=H;Ie==null||Ie.addEventListener("abort",()=>we.abort(Ie.reason),{signal:we.signal});let Oe={signal:we.signal,options:H,context:de},Ke=(tt,at=!1)=>{let{aborted:xe}=we.signal,Ye=H.ignoreFetchAbort&&tt!==void 0;if(H.status&&(xe&&!at?(H.status.fetchAborted=!0,H.status.fetchError=we.signal.reason,Ye&&(H.status.fetchAbortIgnored=!0)):H.status.fetchResolved=!0),xe&&!Ye&&!at)return Ne(we.signal.reason);let gt=Je;return x(this,$)[P]===Je&&(tt===void 0?gt.__staleWhileFetching?x(this,$)[P]=gt.__staleWhileFetching:this.delete(v):(H.status&&(H.status.fetchUpdated=!0),this.set(v,tt,Oe.options))),tt},pt=tt=>(H.status&&(H.status.fetchRejected=!0,H.status.fetchError=tt),Ne(tt)),Ne=tt=>{let{aborted:at}=we.signal,xe=at&&H.allowStaleOnFetchAbort,Ye=xe||H.allowStaleOnFetchRejection,gt=Ye||H.noDeleteOnFetchRejection,lt=Je;if(x(this,$)[P]===Je&&(!gt||lt.__staleWhileFetching===void 0?this.delete(v):xe||(x(this,$)[P]=lt.__staleWhileFetching)),Ye)return H.status&<.__staleWhileFetching!==void 0&&(H.status.returnedStale=!0),lt.__staleWhileFetching;if(lt.__returned===lt)throw tt},ht=(tt,at)=>{var Ye;let xe=(Ye=x(this,F))==null?void 0:Ye.call(this,v,oe,Oe);xe&&xe instanceof Promise&&xe.then(gt=>tt(gt===void 0?void 0:gt),at),we.signal.addEventListener("abort",()=>{(!H.ignoreFetchAbort||H.allowStaleOnFetchAbort)&&(tt(void 0),H.allowStaleOnFetchAbort&&(tt=gt=>Ke(gt,!0)))})};H.status&&(H.status.fetchDispatched=!0);let Je=new Promise(ht).then(Ke,pt),et=Object.assign(Je,{__abortController:we,__staleWhileFetching:oe,__returned:void 0});return P===void 0?(this.set(v,et,{...Oe.options,status:void 0}),P=x(this,O).get(v)):x(this,$)[P]=et,et},Se=new WeakSet,Xe=function(v){if(!x(this,ne))return!1;let P=v;return!!P&&P instanceof Promise&&P.hasOwnProperty("__staleWhileFetching")&&P.__abortController instanceof i},Ue=new WeakSet,co=function(v,P){x(this,te)[P]=v,x(this,X)[v]=P},u=new WeakSet,Fr=function(v){v!==x(this,q)&&(v===x(this,E)?Ce(this,E,x(this,X)[v]):Re(this,Ue,co).call(this,x(this,te)[v],x(this,X)[v]),Re(this,Ue,co).call(this,x(this,q),v),Ce(this,q,v))},w);e.LRUCache=g}),Kt=ye(e=>{he(),ue(),le(),Object.defineProperty(e,"t",{value:!0}),e.ContainerIterator=e.Container=e.Base=void 0;var o=class{constructor(h=0){this.iteratorType=h}equals(h){return this.o===h.o}};e.ContainerIterator=o;var t=class{constructor(){this.i=0}get length(){return this.i}size(){return this.i}empty(){return this.i===0}};e.Base=t;var l=class extends t{};e.Container=l}),nu=ye(e=>{he(),ue(),le(),Object.defineProperty(e,"t",{value:!0}),e.default=void 0;var o=Kt(),t=class extends o.Base{constructor(h=[]){super(),this.S=[];let i=this;h.forEach(function(r){i.push(r)})}clear(){this.i=0,this.S=[]}push(h){return this.S.push(h),this.i+=1,this.i}pop(){if(this.i!==0)return this.i-=1,this.S.pop()}top(){return this.S[this.i-1]}},l=t;e.default=l}),iu=ye(e=>{he(),ue(),le(),Object.defineProperty(e,"t",{value:!0}),e.default=void 0;var o=Kt(),t=class extends o.Base{constructor(h=[]){super(),this.j=0,this.q=[];let i=this;h.forEach(function(r){i.push(r)})}clear(){this.q=[],this.i=this.j=0}push(h){let i=this.q.length;if(this.j/i>.5&&this.j+this.i>=i&&i>4096){let r=this.i;for(let s=0;s{he(),ue(),le(),Object.defineProperty(e,"t",{value:!0}),e.default=void 0;var o=Kt(),t=class extends o.Base{constructor(h=[],i=function(s,n){return s>n?-1:s>1;for(let n=this.i-1>>1;n>=0;--n)this.k(n,s)}m(h){let i=this.C[h];for(;h>0;){let r=h-1>>1,s=this.C[r];if(this.v(s,i)<=0)break;this.C[h]=s,h=r}this.C[h]=i}k(h,i){let r=this.C[h];for(;h0&&(s=n,a=this.C[n]),this.v(a,r)>=0)break;this.C[h]=a,h=s}this.C[h]=r}clear(){this.i=0,this.C.length=0}push(h){this.C.push(h),this.m(this.i),this.i+=1}pop(){if(this.i===0)return;let h=this.C[0],i=this.C.pop();return this.i-=1,this.i&&(this.C[0]=i,this.k(0,this.i>>1)),h}top(){return this.C[0]}find(h){return this.C.indexOf(h)>=0}remove(h){let i=this.C.indexOf(h);return i<0?!1:(i===0?this.pop():i===this.i-1?(this.C.pop(),this.i-=1):(this.C.splice(i,1,this.C.pop()),this.i-=1,this.m(i),this.k(i,this.i>>1)),!0)}updateItem(h){let i=this.C.indexOf(h);return i<0?!1:(this.m(i),this.k(i,this.i>>1),!0)}toArray(){return[...this.C]}},l=t;e.default=l}),$i=ye(e=>{he(),ue(),le(),Object.defineProperty(e,"t",{value:!0}),e.default=void 0;var o=Kt(),t=class extends o.Container{},l=t;e.default=l}),Yt=ye(e=>{he(),ue(),le(),Object.defineProperty(e,"t",{value:!0}),e.throwIteratorAccessError=o;function o(){throw new RangeError("Iterator access denied!")}}),Ts=ye(e=>{he(),ue(),le(),Object.defineProperty(e,"t",{value:!0}),e.RandomIterator=void 0;var o=Kt(),t=Yt(),l=class extends o.ContainerIterator{constructor(h,i){super(i),this.o=h,this.iteratorType===0?(this.pre=function(){return this.o===0&&(0,t.throwIteratorAccessError)(),this.o-=1,this},this.next=function(){return this.o===this.container.size()&&(0,t.throwIteratorAccessError)(),this.o+=1,this}):(this.pre=function(){return this.o===this.container.size()-1&&(0,t.throwIteratorAccessError)(),this.o+=1,this},this.next=function(){return this.o===-1&&(0,t.throwIteratorAccessError)(),this.o-=1,this})}get pointer(){return this.container.getElementByPos(this.o)}set pointer(h){this.container.setElementByPos(this.o,h)}};e.RandomIterator=l}),su=ye(e=>{he(),ue(),le(),Object.defineProperty(e,"t",{value:!0}),e.default=void 0;var o=l($i()),t=Ts();function l(s){return s&&s.t?s:{default:s}}var h=class $a extends t.RandomIterator{constructor(n,a,c){super(n,c),this.container=a}copy(){return new $a(this.o,this.container,this.iteratorType)}},i=class extends o.default{constructor(s=[],n=!0){if(super(),Array.isArray(s))this.J=n?[...s]:s,this.i=s.length;else{this.J=[];let a=this;s.forEach(function(c){a.pushBack(c)})}}clear(){this.i=0,this.J.length=0}begin(){return new h(0,this)}end(){return new h(this.i,this)}rBegin(){return new h(this.i-1,this,1)}rEnd(){return new h(-1,this,1)}front(){return this.J[0]}back(){return this.J[this.i-1]}getElementByPos(s){if(s<0||s>this.i-1)throw new RangeError;return this.J[s]}eraseElementByPos(s){if(s<0||s>this.i-1)throw new RangeError;return this.J.splice(s,1),this.i-=1,this.i}eraseElementByValue(s){let n=0;for(let a=0;athis.i-1)throw new RangeError;this.J[s]=n}insert(s,n,a=1){if(s<0||s>this.i)throw new RangeError;return this.J.splice(s,0,...new Array(a).fill(n)),this.i+=a,this.i}find(s){for(let n=0;n{he(),ue(),le(),Object.defineProperty(e,"t",{value:!0}),e.default=void 0;var o=h($i()),t=Kt(),l=Yt();function h(n){return n&&n.t?n:{default:n}}var i=class qa extends t.ContainerIterator{constructor(a,c,d,g){super(g),this.o=a,this.h=c,this.container=d,this.iteratorType===0?(this.pre=function(){return this.o.L===this.h&&(0,l.throwIteratorAccessError)(),this.o=this.o.L,this},this.next=function(){return this.o===this.h&&(0,l.throwIteratorAccessError)(),this.o=this.o.B,this}):(this.pre=function(){return this.o.B===this.h&&(0,l.throwIteratorAccessError)(),this.o=this.o.B,this},this.next=function(){return this.o===this.h&&(0,l.throwIteratorAccessError)(),this.o=this.o.L,this})}get pointer(){return this.o===this.h&&(0,l.throwIteratorAccessError)(),this.o.l}set pointer(a){this.o===this.h&&(0,l.throwIteratorAccessError)(),this.o.l=a}copy(){return new qa(this.o,this.h,this.container,this.iteratorType)}},r=class extends o.default{constructor(n=[]){super(),this.h={},this.p=this._=this.h.L=this.h.B=this.h;let a=this;n.forEach(function(c){a.pushBack(c)})}V(n){let{L:a,B:c}=n;a.B=c,c.L=a,n===this.p&&(this.p=c),n===this._&&(this._=a),this.i-=1}G(n,a){let c=a.B,d={l:n,L:a,B:c};a.B=d,c.L=d,a===this.h&&(this.p=d),c===this.h&&(this._=d),this.i+=1}clear(){this.i=0,this.p=this._=this.h.L=this.h.B=this.h}begin(){return new i(this.p,this.h,this)}end(){return new i(this.h,this.h,this)}rBegin(){return new i(this._,this.h,this,1)}rEnd(){return new i(this.h,this.h,this,1)}front(){return this.p.l}back(){return this._.l}getElementByPos(n){if(n<0||n>this.i-1)throw new RangeError;let a=this.p;for(;n--;)a=a.B;return a.l}eraseElementByPos(n){if(n<0||n>this.i-1)throw new RangeError;let a=this.p;for(;n--;)a=a.B;return this.V(a),this.i}eraseElementByValue(n){let a=this.p;for(;a!==this.h;)a.l===n&&this.V(a),a=a.B;return this.i}eraseElementByIterator(n){let a=n.o;return a===this.h&&(0,l.throwIteratorAccessError)(),n=n.next(),this.V(a),n}pushBack(n){return this.G(n,this._),this.i}popBack(){if(this.i===0)return;let n=this._.l;return this.V(this._),n}pushFront(n){return this.G(n,this.h),this.i}popFront(){if(this.i===0)return;let n=this.p.l;return this.V(this.p),n}setElementByPos(n,a){if(n<0||n>this.i-1)throw new RangeError;let c=this.p;for(;n--;)c=c.B;c.l=a}insert(n,a,c=1){if(n<0||n>this.i)throw new RangeError;if(c<=0)return this.i;if(n===0)for(;c--;)this.pushFront(a);else if(n===this.i)for(;c--;)this.pushBack(a);else{let d=this.p;for(let b=1;b{he(),ue(),le(),Object.defineProperty(e,"t",{value:!0}),e.default=void 0;var o=l($i()),t=Ts();function l(s){return s&&s.t?s:{default:s}}var h=class Va extends t.RandomIterator{constructor(n,a,c){super(n,c),this.container=a}copy(){return new Va(this.o,this.container,this.iteratorType)}},i=class extends o.default{constructor(s=[],n=4096){super(),this.j=0,this.D=0,this.R=0,this.N=0,this.P=0,this.A=[];let a=(()=>{if(typeof s.length=="number")return s.length;if(typeof s.size=="number")return s.size;if(typeof s.size=="function")return s.size();throw new TypeError("Cannot get the length or size of the container")})();this.F=n,this.P=Math.max(Math.ceil(a/this.F),1);for(let g=0;g>1)-(c>>1),this.D=this.N=this.F-a%this.F>>1;let d=this;s.forEach(function(g){d.pushBack(g)})}T(){let s=[],n=Math.max(this.P>>1,1);for(let a=0;a>1}begin(){return new h(0,this)}end(){return new h(this.i,this)}rBegin(){return new h(this.i-1,this,1)}rEnd(){return new h(-1,this,1)}front(){if(this.i!==0)return this.A[this.j][this.D]}back(){if(this.i!==0)return this.A[this.R][this.N]}pushBack(s){return this.i&&(this.N0?this.N-=1:this.R>0?(this.R-=1,this.N=this.F-1):(this.R=this.P-1,this.N=this.F-1)),this.i-=1,s}pushFront(s){return this.i&&(this.D>0?this.D-=1:this.j>0?(this.j-=1,this.D=this.F-1):(this.j=this.P-1,this.D=this.F-1),this.j===this.R&&this.D===this.N&&this.T()),this.i+=1,this.A[this.j][this.D]=s,this.i}popFront(){if(this.i===0)return;let s=this.A[this.j][this.D];return this.i!==1&&(this.Dthis.i-1)throw new RangeError;let{curNodeBucketIndex:n,curNodePointerIndex:a}=this.O(s);return this.A[n][a]}setElementByPos(s,n){if(s<0||s>this.i-1)throw new RangeError;let{curNodeBucketIndex:a,curNodePointerIndex:c}=this.O(s);this.A[a][c]=n}insert(s,n,a=1){if(s<0||s>this.i)throw new RangeError;if(s===0)for(;a--;)this.pushFront(n);else if(s===this.i)for(;a--;)this.pushBack(n);else{let c=[];for(let d=s;dthis.i-1)throw new RangeError;if(s===0)this.popFront();else if(s===this.i-1)this.popBack();else{let n=[];for(let c=s+1;cs;)this.popBack();return this.i}sort(s){let n=[];for(let a=0;a{he(),ue(),le(),Object.defineProperty(e,"t",{value:!0}),e.TreeNodeEnableIndex=e.TreeNode=void 0;var o=class{constructor(l,h){this.ee=1,this.u=void 0,this.l=void 0,this.U=void 0,this.W=void 0,this.tt=void 0,this.u=l,this.l=h}L(){let l=this;if(l.ee===1&&l.tt.tt===l)l=l.W;else if(l.U)for(l=l.U;l.W;)l=l.W;else{let h=l.tt;for(;h.U===l;)l=h,h=l.tt;l=h}return l}B(){let l=this;if(l.W){for(l=l.W;l.U;)l=l.U;return l}else{let h=l.tt;for(;h.W===l;)l=h,h=l.tt;return l.W!==h?h:l}}te(){let l=this.tt,h=this.W,i=h.U;return l.tt===this?l.tt=h:l.U===this?l.U=h:l.W=h,h.tt=l,h.U=this,this.tt=h,this.W=i,i&&(i.tt=this),h}se(){let l=this.tt,h=this.U,i=h.W;return l.tt===this?l.tt=h:l.U===this?l.U=h:l.W=h,h.tt=l,h.W=this,this.tt=h,this.U=i,i&&(i.tt=this),h}};e.TreeNode=o;var t=class extends o{constructor(){super(...arguments),this.rt=1}te(){let l=super.te();return this.ie(),l.ie(),l}se(){let l=super.se();return this.ie(),l.ie(),l}ie(){this.rt=1,this.U&&(this.rt+=this.U.rt),this.W&&(this.rt+=this.W.rt)}};e.TreeNodeEnableIndex=t}),ks=ye(e=>{he(),ue(),le(),Object.defineProperty(e,"t",{value:!0}),e.default=void 0;var o=uu(),t=Kt(),l=Yt(),h=class extends t.Container{constructor(r=function(n,a){return na?1:0},s=!1){super(),this.Y=void 0,this.v=r,s?(this.re=o.TreeNodeEnableIndex,this.M=function(n,a,c){let d=this.ne(n,a,c);if(d){let g=d.tt;for(;g!==this.h;)g.rt+=1,g=g.tt;let b=this.he(d);if(b){let{parentNode:m,grandParent:y,curNode:T}=b;m.ie(),y.ie(),T.ie()}}return this.i},this.V=function(n){let a=this.fe(n);for(;a!==this.h;)a.rt-=1,a=a.tt}):(this.re=o.TreeNode,this.M=function(n,a,c){let d=this.ne(n,a,c);return d&&this.he(d),this.i},this.V=this.fe),this.h=new this.re}X(r,s){let n=this.h;for(;r;){let a=this.v(r.u,s);if(a<0)r=r.W;else if(a>0)n=r,r=r.U;else return r}return n}Z(r,s){let n=this.h;for(;r;)this.v(r.u,s)<=0?r=r.W:(n=r,r=r.U);return n}$(r,s){let n=this.h;for(;r;){let a=this.v(r.u,s);if(a<0)n=r,r=r.W;else if(a>0)r=r.U;else return r}return n}rr(r,s){let n=this.h;for(;r;)this.v(r.u,s)<0?(n=r,r=r.W):r=r.U;return n}ue(r){for(;;){let s=r.tt;if(s===this.h)return;if(r.ee===1){r.ee=0;return}if(r===s.U){let n=s.W;if(n.ee===1)n.ee=0,s.ee=1,s===this.Y?this.Y=s.te():s.te();else if(n.W&&n.W.ee===1){n.ee=s.ee,s.ee=0,n.W.ee=0,s===this.Y?this.Y=s.te():s.te();return}else n.U&&n.U.ee===1?(n.ee=1,n.U.ee=0,n.se()):(n.ee=1,r=s)}else{let n=s.U;if(n.ee===1)n.ee=0,s.ee=1,s===this.Y?this.Y=s.se():s.se();else if(n.U&&n.U.ee===1){n.ee=s.ee,s.ee=0,n.U.ee=0,s===this.Y?this.Y=s.se():s.se();return}else n.W&&n.W.ee===1?(n.ee=1,n.W.ee=0,n.te()):(n.ee=1,r=s)}}}fe(r){if(this.i===1)return this.clear(),this.h;let s=r;for(;s.U||s.W;){if(s.W)for(s=s.W;s.U;)s=s.U;else s=s.U;[r.u,s.u]=[s.u,r.u],[r.l,s.l]=[s.l,r.l],r=s}this.h.U===s?this.h.U=s.tt:this.h.W===s&&(this.h.W=s.tt),this.ue(s);let n=s.tt;return s===n.U?n.U=void 0:n.W=void 0,this.i-=1,this.Y.ee=0,n}oe(r,s){return r===void 0?!1:this.oe(r.U,s)||s(r)?!0:this.oe(r.W,s)}he(r){for(;;){let s=r.tt;if(s.ee===0)return;let n=s.tt;if(s===n.U){let a=n.W;if(a&&a.ee===1){if(a.ee=s.ee=0,n===this.Y)return;n.ee=1,r=n;continue}else if(r===s.W){if(r.ee=0,r.U&&(r.U.tt=s),r.W&&(r.W.tt=n),s.W=r.U,n.U=r.W,r.U=s,r.W=n,n===this.Y)this.Y=r,this.h.tt=r;else{let c=n.tt;c.U===n?c.U=r:c.W=r}return r.tt=n.tt,s.tt=r,n.tt=r,n.ee=1,{parentNode:s,grandParent:n,curNode:r}}else s.ee=0,n===this.Y?this.Y=n.se():n.se(),n.ee=1}else{let a=n.U;if(a&&a.ee===1){if(a.ee=s.ee=0,n===this.Y)return;n.ee=1,r=n;continue}else if(r===s.U){if(r.ee=0,r.U&&(r.U.tt=n),r.W&&(r.W.tt=s),n.W=r.U,s.U=r.W,r.U=n,r.W=s,n===this.Y)this.Y=r,this.h.tt=r;else{let c=n.tt;c.U===n?c.U=r:c.W=r}return r.tt=n.tt,s.tt=r,n.tt=r,n.ee=1,{parentNode:s,grandParent:n,curNode:r}}else s.ee=0,n===this.Y?this.Y=n.te():n.te(),n.ee=1}return}}ne(r,s,n){if(this.Y===void 0){this.i+=1,this.Y=new this.re(r,s),this.Y.ee=0,this.Y.tt=this.h,this.h.tt=this.Y,this.h.U=this.Y,this.h.W=this.Y;return}let a,c=this.h.U,d=this.v(c.u,r);if(d===0){c.l=s;return}else if(d>0)c.U=new this.re(r,s),c.U.tt=c,a=c.U,this.h.U=a;else{let g=this.h.W,b=this.v(g.u,r);if(b===0){g.l=s;return}else if(b<0)g.W=new this.re(r,s),g.W.tt=g,a=g.W,this.h.W=a;else{if(n!==void 0){let m=n.o;if(m!==this.h){let y=this.v(m.u,r);if(y===0){m.l=s;return}else if(y>0){let T=m.L(),U=this.v(T.u,r);if(U===0){T.l=s;return}else U<0&&(a=new this.re(r,s),T.W===void 0?(T.W=a,a.tt=T):(m.U=a,a.tt=m))}}}if(a===void 0)for(a=this.Y;;){let m=this.v(a.u,r);if(m>0){if(a.U===void 0){a.U=new this.re(r,s),a.U.tt=a,a=a.U;break}a=a.U}else if(m<0){if(a.W===void 0){a.W=new this.re(r,s),a.W.tt=a,a=a.W;break}a=a.W}else{a.l=s;return}}}}return this.i+=1,a}I(r,s){for(;r;){let n=this.v(r.u,s);if(n<0)r=r.W;else if(n>0)r=r.U;else return r}return r||this.h}clear(){this.i=0,this.Y=void 0,this.h.tt=void 0,this.h.U=this.h.W=void 0}updateKeyByIterator(r,s){let n=r.o;if(n===this.h&&(0,l.throwIteratorAccessError)(),this.i===1)return n.u=s,!0;if(n===this.h.U)return this.v(n.B().u,s)>0?(n.u=s,!0):!1;if(n===this.h.W)return this.v(n.L().u,s)<0?(n.u=s,!0):!1;let a=n.L().u;if(this.v(a,s)>=0)return!1;let c=n.B().u;return this.v(c,s)<=0?!1:(n.u=s,!0)}eraseElementByPos(r){if(r<0||r>this.i-1)throw new RangeError;let s=0,n=this;return this.oe(this.Y,function(a){return r===s?(n.V(a),!0):(s+=1,!1)}),this.i}eraseElementByKey(r){if(this.i===0)return!1;let s=this.I(this.Y,r);return s===this.h?!1:(this.V(s),!0)}eraseElementByIterator(r){let s=r.o;s===this.h&&(0,l.throwIteratorAccessError)();let n=s.W===void 0;return r.iteratorType===0?n&&r.next():(!n||s.U===void 0)&&r.next(),this.V(s),r}forEach(r){let s=0;for(let n of this)r(n,s++,this)}getElementByPos(r){if(r<0||r>this.i-1)throw new RangeError;let s,n=0;for(let a of this){if(n===r){s=a;break}n+=1}return s}getHeight(){if(this.i===0)return 0;let r=function(s){return s?Math.max(r(s.U),r(s.W))+1:0};return r(this.Y)}},i=h;e.default=i}),Rs=ye(e=>{he(),ue(),le(),Object.defineProperty(e,"t",{value:!0}),e.default=void 0;var o=Kt(),t=Yt(),l=class extends o.ContainerIterator{constructor(i,r,s){super(s),this.o=i,this.h=r,this.iteratorType===0?(this.pre=function(){return this.o===this.h.U&&(0,t.throwIteratorAccessError)(),this.o=this.o.L(),this},this.next=function(){return this.o===this.h&&(0,t.throwIteratorAccessError)(),this.o=this.o.B(),this}):(this.pre=function(){return this.o===this.h.W&&(0,t.throwIteratorAccessError)(),this.o=this.o.B(),this},this.next=function(){return this.o===this.h&&(0,t.throwIteratorAccessError)(),this.o=this.o.L(),this})}get index(){let i=this.o,r=this.h.tt;if(i===this.h)return r?r.rt-1:0;let s=0;for(i.U&&(s+=i.U.rt);i!==r;){let n=i.tt;i===n.W&&(s+=1,n.U&&(s+=n.U.rt)),i=n}return s}},h=l;e.default=h}),hu=ye(e=>{he(),ue(),le(),Object.defineProperty(e,"t",{value:!0}),e.default=void 0;var o=h(ks()),t=h(Rs()),l=Yt();function h(n){return n&&n.t?n:{default:n}}var i=class Ha extends t.default{constructor(a,c,d,g){super(a,c,g),this.container=d}get pointer(){return this.o===this.h&&(0,l.throwIteratorAccessError)(),this.o.u}copy(){return new Ha(this.o,this.h,this.container,this.iteratorType)}},r=class extends o.default{constructor(n=[],a,c){super(a,c);let d=this;n.forEach(function(g){d.insert(g)})}*K(n){n!==void 0&&(yield*this.K(n.U),yield n.u,yield*this.K(n.W))}begin(){return new i(this.h.U||this.h,this.h,this)}end(){return new i(this.h,this.h,this)}rBegin(){return new i(this.h.W||this.h,this.h,this,1)}rEnd(){return new i(this.h,this.h,this,1)}front(){return this.h.U?this.h.U.u:void 0}back(){return this.h.W?this.h.W.u:void 0}insert(n,a){return this.M(n,void 0,a)}find(n){let a=this.I(this.Y,n);return new i(a,this.h,this)}lowerBound(n){let a=this.X(this.Y,n);return new i(a,this.h,this)}upperBound(n){let a=this.Z(this.Y,n);return new i(a,this.h,this)}reverseLowerBound(n){let a=this.$(this.Y,n);return new i(a,this.h,this)}reverseUpperBound(n){let a=this.rr(this.Y,n);return new i(a,this.h,this)}union(n){let a=this;return n.forEach(function(c){a.insert(c)}),this.i}[Symbol.iterator](){return this.K(this.Y)}},s=r;e.default=s}),cu=ye(e=>{he(),ue(),le(),Object.defineProperty(e,"t",{value:!0}),e.default=void 0;var o=h(ks()),t=h(Rs()),l=Yt();function h(n){return n&&n.t?n:{default:n}}var i=class za extends t.default{constructor(a,c,d,g){super(a,c,g),this.container=d}get pointer(){this.o===this.h&&(0,l.throwIteratorAccessError)();let a=this;return new Proxy([],{get(c,d){if(d==="0")return a.o.u;if(d==="1")return a.o.l},set(c,d,g){if(d!=="1")throw new TypeError("props must be 1");return a.o.l=g,!0}})}copy(){return new za(this.o,this.h,this.container,this.iteratorType)}},r=class extends o.default{constructor(n=[],a,c){super(a,c);let d=this;n.forEach(function(g){d.setElement(g[0],g[1])})}*K(n){n!==void 0&&(yield*this.K(n.U),yield[n.u,n.l],yield*this.K(n.W))}begin(){return new i(this.h.U||this.h,this.h,this)}end(){return new i(this.h,this.h,this)}rBegin(){return new i(this.h.W||this.h,this.h,this,1)}rEnd(){return new i(this.h,this.h,this,1)}front(){if(this.i===0)return;let n=this.h.U;return[n.u,n.l]}back(){if(this.i===0)return;let n=this.h.W;return[n.u,n.l]}lowerBound(n){let a=this.X(this.Y,n);return new i(a,this.h,this)}upperBound(n){let a=this.Z(this.Y,n);return new i(a,this.h,this)}reverseLowerBound(n){let a=this.$(this.Y,n);return new i(a,this.h,this)}reverseUpperBound(n){let a=this.rr(this.Y,n);return new i(a,this.h,this)}setElement(n,a,c){return this.M(n,a,c)}find(n){let a=this.I(this.Y,n);return new i(a,this.h,this)}getElementByKey(n){return this.I(this.Y,n).l}union(n){let a=this;return n.forEach(function(c){a.setElement(c[0],c[1])}),this.i}[Symbol.iterator](){return this.K(this.Y)}},s=r;e.default=s}),Os=ye(e=>{he(),ue(),le(),Object.defineProperty(e,"t",{value:!0}),e.default=o;function o(t){let l=typeof t;return l==="object"&&t!==null||l==="function"}}),Cs=ye(e=>{he(),ue(),le(),Object.defineProperty(e,"t",{value:!0}),e.HashContainerIterator=e.HashContainer=void 0;var o=Kt(),t=h(Os()),l=Yt();function h(s){return s&&s.t?s:{default:s}}var i=class extends o.ContainerIterator{constructor(s,n,a){super(a),this.o=s,this.h=n,this.iteratorType===0?(this.pre=function(){return this.o.L===this.h&&(0,l.throwIteratorAccessError)(),this.o=this.o.L,this},this.next=function(){return this.o===this.h&&(0,l.throwIteratorAccessError)(),this.o=this.o.B,this}):(this.pre=function(){return this.o.B===this.h&&(0,l.throwIteratorAccessError)(),this.o=this.o.B,this},this.next=function(){return this.o===this.h&&(0,l.throwIteratorAccessError)(),this.o=this.o.L,this})}};e.HashContainerIterator=i;var r=class extends o.Container{constructor(){super(),this.H=[],this.g={},this.HASH_TAG=Symbol("@@HASH_TAG"),Object.setPrototypeOf(this.g,null),this.h={},this.h.L=this.h.B=this.p=this._=this.h}V(s){let{L:n,B:a}=s;n.B=a,a.L=n,s===this.p&&(this.p=a),s===this._&&(this._=n),this.i-=1}M(s,n,a){a===void 0&&(a=(0,t.default)(s));let c;if(a){let d=s[this.HASH_TAG];if(d!==void 0)return this.H[d].l=n,this.i;Object.defineProperty(s,this.HASH_TAG,{value:this.H.length,configurable:!0}),c={u:s,l:n,L:this._,B:this.h},this.H.push(c)}else{let d=this.g[s];if(d)return d.l=n,this.i;c={u:s,l:n,L:this._,B:this.h},this.g[s]=c}return this.i===0?(this.p=c,this.h.B=c):this._.B=c,this._=c,this.h.L=c,++this.i}I(s,n){if(n===void 0&&(n=(0,t.default)(s)),n){let a=s[this.HASH_TAG];return a===void 0?this.h:this.H[a]}else return this.g[s]||this.h}clear(){let s=this.HASH_TAG;this.H.forEach(function(n){delete n.u[s]}),this.H=[],this.g={},Object.setPrototypeOf(this.g,null),this.i=0,this.p=this._=this.h.L=this.h.B=this.h}eraseElementByKey(s,n){let a;if(n===void 0&&(n=(0,t.default)(s)),n){let c=s[this.HASH_TAG];if(c===void 0)return!1;delete s[this.HASH_TAG],a=this.H[c],delete this.H[c]}else{if(a=this.g[s],a===void 0)return!1;delete this.g[s]}return this.V(a),!0}eraseElementByIterator(s){let n=s.o;return n===this.h&&(0,l.throwIteratorAccessError)(),this.V(n),s.next()}eraseElementByPos(s){if(s<0||s>this.i-1)throw new RangeError;let n=this.p;for(;s--;)n=n.B;return this.V(n),this.i}};e.HashContainer=r}),fu=ye(e=>{he(),ue(),le(),Object.defineProperty(e,"t",{value:!0}),e.default=void 0;var o=Cs(),t=Yt(),l=class Ka extends o.HashContainerIterator{constructor(s,n,a,c){super(s,n,c),this.container=a}get pointer(){return this.o===this.h&&(0,t.throwIteratorAccessError)(),this.o.u}copy(){return new Ka(this.o,this.h,this.container,this.iteratorType)}},h=class extends o.HashContainer{constructor(r=[]){super();let s=this;r.forEach(function(n){s.insert(n)})}begin(){return new l(this.p,this.h,this)}end(){return new l(this.h,this.h,this)}rBegin(){return new l(this._,this.h,this,1)}rEnd(){return new l(this.h,this.h,this,1)}front(){return this.p.u}back(){return this._.u}insert(r,s){return this.M(r,void 0,s)}getElementByPos(r){if(r<0||r>this.i-1)throw new RangeError;let s=this.p;for(;r--;)s=s.B;return s.u}find(r,s){let n=this.I(r,s);return new l(n,this.h,this)}forEach(r){let s=0,n=this.p;for(;n!==this.h;)r(n.u,s++,this),n=n.B}[Symbol.iterator](){return(function*(){let r=this.p;for(;r!==this.h;)yield r.u,r=r.B}).bind(this)()}},i=h;e.default=i}),du=ye(e=>{he(),ue(),le(),Object.defineProperty(e,"t",{value:!0}),e.default=void 0;var o=Cs(),t=h(Os()),l=Yt();function h(n){return n&&n.t?n:{default:n}}var i=class Ya extends o.HashContainerIterator{constructor(a,c,d,g){super(a,c,g),this.container=d}get pointer(){this.o===this.h&&(0,l.throwIteratorAccessError)();let a=this;return new Proxy([],{get(c,d){if(d==="0")return a.o.u;if(d==="1")return a.o.l},set(c,d,g){if(d!=="1")throw new TypeError("props must be 1");return a.o.l=g,!0}})}copy(){return new Ya(this.o,this.h,this.container,this.iteratorType)}},r=class extends o.HashContainer{constructor(n=[]){super();let a=this;n.forEach(function(c){a.setElement(c[0],c[1])})}begin(){return new i(this.p,this.h,this)}end(){return new i(this.h,this.h,this)}rBegin(){return new i(this._,this.h,this,1)}rEnd(){return new i(this.h,this.h,this,1)}front(){if(this.i!==0)return[this.p.u,this.p.l]}back(){if(this.i!==0)return[this._.u,this._.l]}setElement(n,a,c){return this.M(n,a,c)}getElementByKey(n,a){if(a===void 0&&(a=(0,t.default)(n)),a){let d=n[this.HASH_TAG];return d!==void 0?this.H[d].l:void 0}let c=this.g[n];return c?c.l:void 0}getElementByPos(n){if(n<0||n>this.i-1)throw new RangeError;let a=this.p;for(;n--;)a=a.B;return[a.u,a.l]}find(n,a){let c=this.I(n,a);return new i(c,this.h,this)}forEach(n){let a=0,c=this.p;for(;c!==this.h;)n([c.u,c.l],a++,this),c=c.B}[Symbol.iterator](){return(function*(){let n=this.p;for(;n!==this.h;)yield[n.u,n.l],n=n.B}).bind(this)()}},s=r;e.default=s}),pu=ye(e=>{he(),ue(),le(),Object.defineProperty(e,"t",{value:!0}),Object.defineProperty(e,"Deque",{enumerable:!0,get:function(){return r.default}}),Object.defineProperty(e,"HashMap",{enumerable:!0,get:function(){return c.default}}),Object.defineProperty(e,"HashSet",{enumerable:!0,get:function(){return a.default}}),Object.defineProperty(e,"LinkList",{enumerable:!0,get:function(){return i.default}}),Object.defineProperty(e,"OrderedMap",{enumerable:!0,get:function(){return n.default}}),Object.defineProperty(e,"OrderedSet",{enumerable:!0,get:function(){return s.default}}),Object.defineProperty(e,"PriorityQueue",{enumerable:!0,get:function(){return l.default}}),Object.defineProperty(e,"Queue",{enumerable:!0,get:function(){return t.default}}),Object.defineProperty(e,"Stack",{enumerable:!0,get:function(){return o.default}}),Object.defineProperty(e,"Vector",{enumerable:!0,get:function(){return h.default}});var o=d(nu()),t=d(iu()),l=d(ou()),h=d(su()),i=d(au()),r=d(lu()),s=d(hu()),n=d(cu()),a=d(fu()),c=d(du());function d(g){return g&&g.t?g:{default:g}}}),gu=ye((e,o)=>{he(),ue(),le();var t=pu().OrderedSet,l=zt()("number-allocator:trace"),h=zt()("number-allocator:error");function i(s,n){this.low=s,this.high=n}i.prototype.equals=function(s){return this.low===s.low&&this.high===s.high},i.prototype.compare=function(s){return this.lowa.compare(c)),l("Create"),this.clear()}r.prototype.firstVacant=function(){return this.ss.size()===0?null:this.ss.front().low},r.prototype.alloc=function(){if(this.ss.size()===0)return l("alloc():empty"),null;let s=this.ss.begin(),n=s.pointer.low,a=s.pointer.high,c=n;return c+1<=a?this.ss.updateKeyByIterator(s,new i(n+1,a)):this.ss.eraseElementByPos(0),l("alloc():"+c),c},r.prototype.use=function(s){let n=new i(s,s),a=this.ss.lowerBound(n);if(!a.equals(this.ss.end())){let c=a.pointer.low,d=a.pointer.high;return a.pointer.equals(n)?(this.ss.eraseElementByIterator(a),l("use():"+s),!0):c>s?!1:c===s?(this.ss.updateKeyByIterator(a,new i(c+1,d)),l("use():"+s),!0):d===s?(this.ss.updateKeyByIterator(a,new i(c,d-1)),l("use():"+s),!0):(this.ss.updateKeyByIterator(a,new i(s+1,d)),this.ss.insert(new i(c,s-1)),l("use():"+s),!0)}return l("use():failed"),!1},r.prototype.free=function(s){if(sthis.max){h("free():"+s+" is out of range");return}let n=new i(s,s),a=this.ss.upperBound(n);if(a.equals(this.ss.end())){if(a.equals(this.ss.begin())){this.ss.insert(n);return}a.pre();let c=a.pointer.high;a.pointer.high+1===s?this.ss.updateKeyByIterator(a,new i(c,s)):this.ss.insert(n)}else if(a.equals(this.ss.begin()))if(s+1===a.pointer.low){let c=a.pointer.high;this.ss.updateKeyByIterator(a,new i(s,c))}else this.ss.insert(n);else{let c=a.pointer.low,d=a.pointer.high;a.pre();let g=a.pointer.low;a.pointer.high+1===s?s+1===c?(this.ss.eraseElementByIterator(a),this.ss.updateKeyByIterator(a,new i(g,d))):this.ss.updateKeyByIterator(a,new i(g,s)):s+1===c?(this.ss.eraseElementByIterator(a.next()),this.ss.insert(new i(s,d))):this.ss.insert(n)}l("free():"+s)},r.prototype.clear=function(){l("clear()"),this.ss.clear(),this.ss.insert(new i(this.min,this.max))},r.prototype.intervalCount=function(){return this.ss.size()},r.prototype.dump=function(){console.log("length:"+this.ss.size());for(let s of this.ss)console.log(s)},o.exports=r}),Ps=ye((e,o)=>{he(),ue(),le();var t=gu();o.exports.NumberAllocator=t}),bu=ye(e=>{he(),ue(),le(),Object.defineProperty(e,"__esModule",{value:!0});var o=ru(),t=Ps(),l=class{constructor(h){h>0&&(this.aliasToTopic=new o.LRUCache({max:h}),this.topicToAlias={},this.numberAllocator=new t.NumberAllocator(1,h),this.max=h,this.length=0)}put(h,i){if(i===0||i>this.max)return!1;let r=this.aliasToTopic.get(i);return r&&delete this.topicToAlias[r],this.aliasToTopic.set(i,h),this.topicToAlias[h]=i,this.numberAllocator.use(i),this.length=this.aliasToTopic.size,!0}getTopicByAlias(h){return this.aliasToTopic.get(h)}getAliasByTopic(h){let i=this.topicToAlias[h];return typeof i<"u"&&this.aliasToTopic.get(i),i}clear(){this.aliasToTopic.clear(),this.topicToAlias={},this.numberAllocator.clear(),this.length=0}getLruAlias(){return this.numberAllocator.firstVacant()||[...this.aliasToTopic.keys()][this.aliasToTopic.size-1]}};e.default=l}),mu=ye(e=>{he(),ue(),le();var o=e&&e.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(e,"__esModule",{value:!0});var t=Zr(),l=o(bu()),h=Lr(),i=(r,s)=>{r.log("_handleConnack");let{options:n}=r,a=n.protocolVersion===5?s.reasonCode:s.returnCode;if(clearTimeout(r.connackTimer),delete r.topicAliasSend,s.properties){if(s.properties.topicAliasMaximum){if(s.properties.topicAliasMaximum>65535){r.emit("error",new Error("topicAliasMaximum from broker is out of range"));return}s.properties.topicAliasMaximum>0&&(r.topicAliasSend=new l.default(s.properties.topicAliasMaximum))}s.properties.serverKeepAlive&&n.keepalive&&(n.keepalive=s.properties.serverKeepAlive,r._shiftPingInterval()),s.properties.maximumPacketSize&&(n.properties||(n.properties={}),n.properties.maximumPacketSize=s.properties.maximumPacketSize)}if(a===0)r.reconnecting=!1,r._onConnect(s);else if(a>0){let c=new h.ErrorWithReasonCode(`Connection refused: ${t.ReasonCodes[a]}`,a);r.emit("error",c)}};e.default=i}),yu=ye(e=>{he(),ue(),le(),Object.defineProperty(e,"__esModule",{value:!0});var o=(t,l,h)=>{t.log("handling pubrel packet");let i=typeof h<"u"?h:t.noop,{messageId:r}=l,s={cmd:"pubcomp",messageId:r};t.incomingStore.get(l,(n,a)=>{n?t._sendPacket(s,i):(t.emit("message",a.topic,a.payload,a),t.handleMessage(a,c=>{if(c)return i(c);t.incomingStore.del(a,t.noop),t._sendPacket(s,i)}))})};e.default=o}),vu=ye(e=>{he(),ue(),le();var o=e&&e.__importDefault||function(n){return n&&n.__esModule?n:{default:n}};Object.defineProperty(e,"__esModule",{value:!0});var t=o(Zl()),l=o(tu()),h=o(mu()),i=o(Zr()),r=o(yu()),s=(n,a,c)=>{let{options:d}=n;if(d.protocolVersion===5&&d.properties&&d.properties.maximumPacketSize&&d.properties.maximumPacketSize{he(),ue(),le();var o=e&&e.__importDefault||function(i){return i&&i.__esModule?i:{default:i}};Object.defineProperty(e,"__esModule",{value:!0}),e.TypedEventEmitter=void 0;var t=o((Ar(),Ve(ur))),l=Lr(),h=class{};e.TypedEventEmitter=h,(0,l.applyMixin)(h,t.default)}),en=ye(e=>{he(),ue(),le(),Object.defineProperty(e,"__esModule",{value:!0}),e.isReactNativeBrowser=e.isWebWorker=void 0;var o=()=>typeof window<"u"&&typeof window.document<"u",t=()=>{var i,r;return!!(typeof self=="object"&&!((r=(i=self==null?void 0:self.constructor)===null||i===void 0?void 0:i.name)===null||r===void 0)&&r.includes("WorkerGlobalScope"))},l=()=>typeof _t<"u"&&_t.product==="ReactNative",h=o()||t()||l();e.isWebWorker=t(),e.isReactNativeBrowser=l(),e.default=h}),_u=ye((e,o)=>{he(),ue(),le(),function(t,l){typeof e=="object"&&typeof o<"u"?l(e):typeof define=="function"&&define.amd?define(["exports"],l):(t=typeof globalThis<"u"?globalThis:t||self,l(t.fastUniqueNumbers={}))}(e,function(t){var l=function(b){return function(m){var y=b(m);return m.add(y),y}},h=function(b){return function(m,y){return b.set(m,y),y}},i=Number.MAX_SAFE_INTEGER===void 0?9007199254740991:Number.MAX_SAFE_INTEGER,r=536870912,s=r*2,n=function(b,m){return function(y){var T=m.get(y),U=T===void 0?y.size:Ti)throw new Error("Congratulations, you created a collection of unique numbers which uses all available integers!");for(;y.has(U);)U=Math.floor(Math.random()*i);return b(y,U)}},a=new WeakMap,c=h(a),d=n(c,a),g=l(d);t.addUniqueNumber=g,t.generateUniqueNumber=d})}),Eu=ye((e,o)=>{he(),ue(),le(),function(t,l){typeof e=="object"&&typeof o<"u"?l(e,_u()):typeof define=="function"&&define.amd?define(["exports","fast-unique-numbers"],l):(t=typeof globalThis<"u"?globalThis:t||self,l(t.workerTimersBroker={},t.fastUniqueNumbers))}(e,function(t,l){var h=function(s){return s.method!==void 0&&s.method==="call"},i=function(s){return s.error===null&&typeof s.id=="number"},r=function(s){var n=new Map([[0,function(){}]]),a=new Map([[0,function(){}]]),c=new Map,d=new Worker(s);d.addEventListener("message",function(T){var U=T.data;if(h(U)){var S=U.params,R=S.timerId,F=S.timerType;if(F==="interval"){var W=n.get(R);if(typeof W=="number"){var C=c.get(W);if(C===void 0||C.timerId!==R||C.timerType!==F)throw new Error("The timer is in an undefined state.")}else if(typeof W<"u")W();else throw new Error("The timer is in an undefined state.")}else if(F==="timeout"){var O=a.get(R);if(typeof O=="number"){var M=c.get(O);if(M===void 0||M.timerId!==R||M.timerType!==F)throw new Error("The timer is in an undefined state.")}else if(typeof O<"u")O(),a.delete(R);else throw new Error("The timer is in an undefined state.")}}else if(i(U)){var $=U.id,X=c.get($);if(X===void 0)throw new Error("The timer is in an undefined state.");var te=X.timerId,E=X.timerType;c.delete($),E==="interval"?n.delete(te):a.delete(te)}else{var q=U.error.message;throw new Error(q)}});var g=function(T){var U=l.generateUniqueNumber(c);c.set(U,{timerId:T,timerType:"interval"}),n.set(T,U),d.postMessage({id:U,method:"clear",params:{timerId:T,timerType:"interval"}})},b=function(T){var U=l.generateUniqueNumber(c);c.set(U,{timerId:T,timerType:"timeout"}),a.set(T,U),d.postMessage({id:U,method:"clear",params:{timerId:T,timerType:"timeout"}})},m=function(T){var U=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,S=l.generateUniqueNumber(n);return n.set(S,function(){T(),typeof n.get(S)=="function"&&d.postMessage({id:null,method:"set",params:{delay:U,now:performance.now(),timerId:S,timerType:"interval"}})}),d.postMessage({id:null,method:"set",params:{delay:U,now:performance.now(),timerId:S,timerType:"interval"}}),S},y=function(T){var U=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,S=l.generateUniqueNumber(a);return a.set(S,T),d.postMessage({id:null,method:"set",params:{delay:U,now:performance.now(),timerId:S,timerType:"timeout"}}),S};return{clearInterval:g,clearTimeout:b,setInterval:m,setTimeout:y}};t.load=r})}),Su=ye((e,o)=>{he(),ue(),le(),function(t,l){typeof e=="object"&&typeof o<"u"?l(e,Eu()):typeof define=="function"&&define.amd?define(["exports","worker-timers-broker"],l):(t=typeof globalThis<"u"?globalThis:t||self,l(t.workerTimers={},t.workerTimersBroker))}(e,function(t,l){var h=function(d,g){var b=null;return function(){if(b!==null)return b;var m=new Blob([g],{type:"application/javascript; charset=utf-8"}),y=URL.createObjectURL(m);return b=d(y),setTimeout(function(){return URL.revokeObjectURL(y)}),b}},i=`(()=>{var e={472:(e,t,r)=>{var o,i;void 0===(i="function"==typeof(o=function(){"use strict";var e=new Map,t=new Map,r=function(t){var r=e.get(t);if(void 0===r)throw new Error('There is no interval scheduled with the given id "'.concat(t,'".'));clearTimeout(r),e.delete(t)},o=function(e){var r=t.get(e);if(void 0===r)throw new Error('There is no timeout scheduled with the given id "'.concat(e,'".'));clearTimeout(r),t.delete(e)},i=function(e,t){var r,o=performance.now();return{expected:o+(r=e-Math.max(0,o-t)),remainingDelay:r}},n=function e(t,r,o,i){var n=performance.now();n>o?postMessage({id:null,method:"call",params:{timerId:r,timerType:i}}):t.set(r,setTimeout(e,o-n,t,r,o,i))},a=function(t,r,o){var a=i(t,o),s=a.expected,d=a.remainingDelay;e.set(r,setTimeout(n,d,e,r,s,"interval"))},s=function(e,r,o){var a=i(e,o),s=a.expected,d=a.remainingDelay;t.set(r,setTimeout(n,d,t,r,s,"timeout"))};addEventListener("message",(function(e){var t=e.data;try{if("clear"===t.method){var i=t.id,n=t.params,d=n.timerId,c=n.timerType;if("interval"===c)r(d),postMessage({error:null,id:i});else{if("timeout"!==c)throw new Error('The given type "'.concat(c,'" is not supported'));o(d),postMessage({error:null,id:i})}}else{if("set"!==t.method)throw new Error('The given method "'.concat(t.method,'" is not supported'));var u=t.params,l=u.delay,p=u.now,m=u.timerId,v=u.timerType;if("interval"===v)a(l,m,p);else{if("timeout"!==v)throw new Error('The given type "'.concat(v,'" is not supported'));s(l,m,p)}}}catch(e){postMessage({error:{message:e.message},id:t.id,result:null})}}))})?o.call(t,r,t,e):o)||(e.exports=i)}},t={};function r(o){var i=t[o];if(void 0!==i)return i.exports;var n=t[o]={exports:{}};return e[o](n,n.exports,r),n.exports}r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var o in t)r.o(t,o)&&!r.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{"use strict";r(472)})()})();`,r=h(l.load,i),s=function(d){return r().clearInterval(d)},n=function(d){return r().clearTimeout(d)},a=function(){var d;return(d=r()).setInterval.apply(d,arguments)},c=function(){var d;return(d=r()).setTimeout.apply(d,arguments)};t.clearInterval=s,t.clearTimeout=n,t.setInterval=a,t.setTimeout=c})}),Au=ye(e=>{he(),ue(),le();var o=e&&e.__createBinding||(Object.create?function(a,c,d,g){g===void 0&&(g=d);var b=Object.getOwnPropertyDescriptor(c,d);(!b||("get"in b?!c.__esModule:b.writable||b.configurable))&&(b={enumerable:!0,get:function(){return c[d]}}),Object.defineProperty(a,g,b)}:function(a,c,d,g){g===void 0&&(g=d),a[g]=c[d]}),t=e&&e.__setModuleDefault||(Object.create?function(a,c){Object.defineProperty(a,"default",{enumerable:!0,value:c})}:function(a,c){a.default=c}),l=e&&e.__importStar||function(a){if(a&&a.__esModule)return a;var c={};if(a!=null)for(var d in a)d!=="default"&&Object.prototype.hasOwnProperty.call(a,d)&&o(c,a,d);return t(c,a),c};Object.defineProperty(e,"__esModule",{value:!0});var h=l(en()),i=Su(),r={set:i.setTimeout,clear:i.clearTimeout},s={set:(a,c)=>setTimeout(a,c),clear:a=>clearTimeout(a)},n=a=>{switch(a){case"native":return s;case"worker":return r;case"auto":default:return h.default&&!h.isWebWorker&&!h.isReactNativeBrowser?r:s}};e.default=n}),Bs=ye(e=>{he(),ue(),le();var o=e&&e.__importDefault||function(h){return h&&h.__esModule?h:{default:h}};Object.defineProperty(e,"__esModule",{value:!0});var t=o(Au()),l=class{constructor(h,i,r){this.destroyed=!1,this.keepalive=h*1e3,this.checkPing=i,this.timer=(0,t.default)(r),this.reschedule()}clear(){this.timerId&&(this.timer.clear(this.timerId),this.timerId=null)}destroy(){this.clear(),this.destroyed=!0}reschedule(){this.destroyed||(this.clear(),this.timerId=this.timer.set(()=>{this.destroyed||(this.checkPing(),this.reschedule())},this.keepalive))}};e.default=l}),qi=ye(e=>{he(),ue(),le();var o=e&&e.__createBinding||(Object.create?function(W,C,O,M){M===void 0&&(M=O);var $=Object.getOwnPropertyDescriptor(C,O);(!$||("get"in $?!C.__esModule:$.writable||$.configurable))&&($={enumerable:!0,get:function(){return C[O]}}),Object.defineProperty(W,M,$)}:function(W,C,O,M){M===void 0&&(M=O),W[M]=C[O]}),t=e&&e.__setModuleDefault||(Object.create?function(W,C){Object.defineProperty(W,"default",{enumerable:!0,value:C})}:function(W,C){W.default=C}),l=e&&e.__importStar||function(W){if(W&&W.__esModule)return W;var C={};if(W!=null)for(var O in W)O!=="default"&&Object.prototype.hasOwnProperty.call(W,O)&&o(C,W,O);return t(C,W),C},h=e&&e.__importDefault||function(W){return W&&W.__esModule?W:{default:W}};Object.defineProperty(e,"__esModule",{value:!0});var i=h(dl()),r=h(Ql()),s=h(As()),n=pr(),a=h(Jl()),c=l(Xl()),d=h(zt()),g=h(Is()),b=h(vu()),m=Lr(),y=wu(),T=h(Bs()),U=l(en()),S=globalThis.setImmediate||((...W)=>{let C=W.shift();(0,m.nextTick)(()=>{C(...W)})}),R={keepalive:60,reschedulePings:!0,protocolId:"MQTT",protocolVersion:4,reconnectPeriod:1e3,connectTimeout:30*1e3,clean:!0,resubscribe:!0,writeCache:!0,timerVariant:"auto"},F=class fo extends y.TypedEventEmitter{static defaultId(){return`mqttjs_${Math.random().toString(16).substr(2,8)}`}constructor(C,O){super(),this.options=O||{};for(let M in R)typeof this.options[M]>"u"?this.options[M]=R[M]:this.options[M]=O[M];this.log=this.options.log||(0,d.default)("mqttjs:client"),this.noop=this._noop.bind(this),this.log("MqttClient :: version:",fo.VERSION),U.isWebWorker?this.log("MqttClient :: environment","webworker"):this.log("MqttClient :: environment",U.default?"browser":"node"),this.log("MqttClient :: options.protocol",O.protocol),this.log("MqttClient :: options.protocolVersion",O.protocolVersion),this.log("MqttClient :: options.username",O.username),this.log("MqttClient :: options.keepalive",O.keepalive),this.log("MqttClient :: options.reconnectPeriod",O.reconnectPeriod),this.log("MqttClient :: options.rejectUnauthorized",O.rejectUnauthorized),this.log("MqttClient :: options.properties.topicAliasMaximum",O.properties?O.properties.topicAliasMaximum:void 0),this.options.clientId=typeof O.clientId=="string"?O.clientId:fo.defaultId(),this.log("MqttClient :: clientId",this.options.clientId),this.options.customHandleAcks=O.protocolVersion===5&&O.customHandleAcks?O.customHandleAcks:(...M)=>{M[3](null,0)},this.options.writeCache||(r.default.writeToStream.cacheNumbers=!1),this.streamBuilder=C,this.messageIdProvider=typeof this.options.messageIdProvider>"u"?new s.default:this.options.messageIdProvider,this.outgoingStore=O.outgoingStore||new g.default,this.incomingStore=O.incomingStore||new g.default,this.queueQoSZero=O.queueQoSZero===void 0?!0:O.queueQoSZero,this._resubscribeTopics={},this.messageIdToTopic={},this.pingTimer=null,this.connected=!1,this.disconnecting=!1,this.reconnecting=!1,this.queue=[],this.connackTimer=null,this.reconnectTimer=null,this._storeProcessing=!1,this._packetIdsDuringStoreProcessing={},this._storeProcessingQueue=[],this.outgoing={},this._firstConnection=!0,O.properties&&O.properties.topicAliasMaximum>0&&(O.properties.topicAliasMaximum>65535?this.log("MqttClient :: options.properties.topicAliasMaximum is out of range"):this.topicAliasRecv=new i.default(O.properties.topicAliasMaximum)),this.on("connect",()=>{let{queue:M}=this,$=()=>{let X=M.shift();this.log("deliver :: entry %o",X);let te=null;if(!X){this._resubscribe();return}te=X.packet,this.log("deliver :: call _sendPacket for %o",te);let E=!0;te.messageId&&te.messageId!==0&&(this.messageIdProvider.register(te.messageId)||(E=!1)),E?this._sendPacket(te,q=>{X.cb&&X.cb(q),$()}):(this.log("messageId: %d has already used. The message is skipped and removed.",te.messageId),$())};this.log("connect :: sending queued packets"),$()}),this.on("close",()=>{this.log("close :: connected set to `false`"),this.connected=!1,this.log("close :: clearing connackTimer"),clearTimeout(this.connackTimer),this._destroyPingTimer(),this.topicAliasRecv&&this.topicAliasRecv.clear(),this.log("close :: calling _setupReconnect"),this._setupReconnect()}),this.options.manualConnect||(this.log("MqttClient :: setting up stream"),this.connect())}handleAuth(C,O){O()}handleMessage(C,O){O()}_nextId(){return this.messageIdProvider.allocate()}getLastMessageId(){return this.messageIdProvider.getLastAllocated()}connect(){var C;let O=new n.Writable,M=r.default.parser(this.options),$=null,X=[];this.log("connect :: calling method to clear reconnect"),this._clearReconnect(),this.log("connect :: using streamBuilder provided to client to create stream"),this.stream=this.streamBuilder(this),M.on("packet",z=>{this.log("parser :: on packet push to packets array."),X.push(z)});let te=()=>{this.log("work :: getting next packet in queue");let z=X.shift();if(z)this.log("work :: packet pulled from queue"),(0,b.default)(this,z,E);else{this.log("work :: no packets in queue");let be=$;$=null,this.log("work :: done flag is %s",!!be),be&&be()}},E=()=>{if(X.length)(0,m.nextTick)(te);else{let z=$;$=null,z()}};O._write=(z,be,ie)=>{$=ie,this.log("writable stream :: parsing buffer"),M.parse(z),te()};let q=z=>{this.log("streamErrorHandler :: error",z.message),z.code?(this.log("streamErrorHandler :: emitting error"),this.emit("error",z)):this.noop(z)};this.log("connect :: pipe stream to writable stream"),this.stream.pipe(O),this.stream.on("error",q),this.stream.on("close",()=>{this.log("(%s)stream :: on close",this.options.clientId),this._flushVolatile(),this.log("stream: emit close to MqttClient"),this.emit("close")}),this.log("connect: sending packet `connect`");let Z={cmd:"connect",protocolId:this.options.protocolId,protocolVersion:this.options.protocolVersion,clean:this.options.clean,clientId:this.options.clientId,keepalive:this.options.keepalive,username:this.options.username,password:this.options.password,properties:this.options.properties};if(this.options.will&&(Z.will=Object.assign(Object.assign({},this.options.will),{payload:(C=this.options.will)===null||C===void 0?void 0:C.payload})),this.topicAliasRecv&&(Z.properties||(Z.properties={}),this.topicAliasRecv&&(Z.properties.topicAliasMaximum=this.topicAliasRecv.max)),this._writePacket(Z),M.on("error",this.emit.bind(this,"error")),this.options.properties){if(!this.options.properties.authenticationMethod&&this.options.properties.authenticationData)return this.end(()=>this.emit("error",new Error("Packet has no Authentication Method"))),this;if(this.options.properties.authenticationMethod&&this.options.authPacket&&typeof this.options.authPacket=="object"){let z=Object.assign({cmd:"auth",reasonCode:0},this.options.authPacket);this._writePacket(z)}}return this.stream.setMaxListeners(1e3),clearTimeout(this.connackTimer),this.connackTimer=setTimeout(()=>{this.log("!!connectTimeout hit!! Calling _cleanUp with force `true`"),this.emit("error",new Error("connack timeout")),this._cleanUp(!0)},this.options.connectTimeout),this}publish(C,O,M,$){this.log("publish :: message `%s` to topic `%s`",O,C);let{options:X}=this;typeof M=="function"&&($=M,M=null),M=M||{},M=Object.assign(Object.assign({},{qos:0,retain:!1,dup:!1}),M);let{qos:te,retain:E,dup:q,properties:Z,cbStorePut:z}=M;if(this._checkDisconnecting($))return this;let be=()=>{let ie=0;if((te===1||te===2)&&(ie=this._nextId(),ie===null))return this.log("No messageId left"),!1;let V={cmd:"publish",topic:C,payload:O,qos:te,retain:E,messageId:ie,dup:q};switch(X.protocolVersion===5&&(V.properties=Z),this.log("publish :: qos",te),te){case 1:case 2:this.outgoing[V.messageId]={volatile:!1,cb:$||this.noop},this.log("MqttClient:publish: packet cmd: %s",V.cmd),this._sendPacket(V,void 0,z);break;default:this.log("MqttClient:publish: packet cmd: %s",V.cmd),this._sendPacket(V,$,z);break}return!0};return(this._storeProcessing||this._storeProcessingQueue.length>0||!be())&&this._storeProcessingQueue.push({invoke:be,cbStorePut:M.cbStorePut,callback:$}),this}publishAsync(C,O,M){return new Promise(($,X)=>{this.publish(C,O,M,(te,E)=>{te?X(te):$(E)})})}subscribe(C,O,M){let $=this.options.protocolVersion;typeof O=="function"&&(M=O),M=M||this.noop;let X=!1,te=[];typeof C=="string"?(C=[C],te=C):Array.isArray(C)?te=C:typeof C=="object"&&(X=C.resubscribe,delete C.resubscribe,te=Object.keys(C));let E=c.validateTopics(te);if(E!==null)return S(M,new Error(`Invalid topic ${E}`)),this;if(this._checkDisconnecting(M))return this.log("subscribe: discconecting true"),this;let q={qos:0};$===5&&(q.nl=!1,q.rap=!1,q.rh=0),O=Object.assign(Object.assign({},q),O);let Z=O.properties,z=[],be=(V,me)=>{if(me=me||O,!Object.prototype.hasOwnProperty.call(this._resubscribeTopics,V)||this._resubscribeTopics[V].qos{this.log("subscribe: array topic %s",V),be(V)}):Object.keys(C).forEach(V=>{this.log("subscribe: object topic %s, %o",V,C[V]),be(V,C[V])}),!z.length)return M(null,[]),this;let ie=()=>{let V=this._nextId();if(V===null)return this.log("No messageId left"),!1;let me={cmd:"subscribe",subscriptions:z,messageId:V};if(Z&&(me.properties=Z),this.options.resubscribe){this.log("subscribe :: resubscribe true");let ne=[];z.forEach(Ee=>{if(this.options.reconnectPeriod>0){let A={qos:Ee.qos};$===5&&(A.nl=Ee.nl||!1,A.rap=Ee.rap||!1,A.rh=Ee.rh||0,A.properties=Ee.properties),this._resubscribeTopics[Ee.topic]=A,ne.push(Ee.topic)}}),this.messageIdToTopic[me.messageId]=ne}return this.outgoing[me.messageId]={volatile:!0,cb(ne,Ee){if(!ne){let{granted:A}=Ee;for(let Q=0;Q0||!ie())&&this._storeProcessingQueue.push({invoke:ie,callback:M}),this}subscribeAsync(C,O){return new Promise((M,$)=>{this.subscribe(C,O,(X,te)=>{X?$(X):M(te)})})}unsubscribe(C,O,M){typeof C=="string"&&(C=[C]),typeof O=="function"&&(M=O),M=M||this.noop;let $=c.validateTopics(C);if($!==null)return S(M,new Error(`Invalid topic ${$}`)),this;if(this._checkDisconnecting(M))return this;let X=()=>{let te=this._nextId();if(te===null)return this.log("No messageId left"),!1;let E={cmd:"unsubscribe",messageId:te,unsubscriptions:[]};return typeof C=="string"?E.unsubscriptions=[C]:Array.isArray(C)&&(E.unsubscriptions=C),this.options.resubscribe&&E.unsubscriptions.forEach(q=>{delete this._resubscribeTopics[q]}),typeof O=="object"&&O.properties&&(E.properties=O.properties),this.outgoing[E.messageId]={volatile:!0,cb:M},this.log("unsubscribe: call _sendPacket"),this._sendPacket(E),!0};return(this._storeProcessing||this._storeProcessingQueue.length>0||!X())&&this._storeProcessingQueue.push({invoke:X,callback:M}),this}unsubscribeAsync(C,O){return new Promise((M,$)=>{this.unsubscribe(C,O,(X,te)=>{X?$(X):M(te)})})}end(C,O,M){this.log("end :: (%s)",this.options.clientId),(C==null||typeof C!="boolean")&&(M=M||O,O=C,C=!1),typeof O!="object"&&(M=M||O,O=null),this.log("end :: cb? %s",!!M),(!M||typeof M!="function")&&(M=this.noop);let $=()=>{this.log("end :: closeStores: closing incoming and outgoing stores"),this.disconnected=!0,this.incomingStore.close(te=>{this.outgoingStore.close(E=>{if(this.log("end :: closeStores: emitting end"),this.emit("end"),M){let q=te||E;this.log("end :: closeStores: invoking callback with args"),M(q)}})}),this._deferredReconnect&&this._deferredReconnect()},X=()=>{this.log("end :: (%s) :: finish :: calling _cleanUp with force %s",this.options.clientId,C),this._cleanUp(C,()=>{this.log("end :: finish :: calling process.nextTick on closeStores"),(0,m.nextTick)($)},O)};return this.disconnecting?(M(),this):(this._clearReconnect(),this.disconnecting=!0,!C&&Object.keys(this.outgoing).length>0?(this.log("end :: (%s) :: calling finish in 10ms once outgoing is empty",this.options.clientId),this.once("outgoingEmpty",setTimeout.bind(null,X,10))):(this.log("end :: (%s) :: immediately calling finish",this.options.clientId),X()),this)}endAsync(C,O){return new Promise((M,$)=>{this.end(C,O,X=>{X?$(X):M()})})}removeOutgoingMessage(C){if(this.outgoing[C]){let{cb:O}=this.outgoing[C];this._removeOutgoingAndStoreMessage(C,()=>{O(new Error("Message removed"))})}return this}reconnect(C){this.log("client reconnect");let O=()=>{C?(this.options.incomingStore=C.incomingStore,this.options.outgoingStore=C.outgoingStore):(this.options.incomingStore=null,this.options.outgoingStore=null),this.incomingStore=this.options.incomingStore||new g.default,this.outgoingStore=this.options.outgoingStore||new g.default,this.disconnecting=!1,this.disconnected=!1,this._deferredReconnect=null,this._reconnect()};return this.disconnecting&&!this.disconnected?this._deferredReconnect=O:O(),this}_flushVolatile(){this.outgoing&&(this.log("_flushVolatile :: deleting volatile messages from the queue and setting their callbacks as error function"),Object.keys(this.outgoing).forEach(C=>{this.outgoing[C].volatile&&typeof this.outgoing[C].cb=="function"&&(this.outgoing[C].cb(new Error("Connection closed")),delete this.outgoing[C])}))}_flush(){this.outgoing&&(this.log("_flush: queue exists? %b",!!this.outgoing),Object.keys(this.outgoing).forEach(C=>{typeof this.outgoing[C].cb=="function"&&(this.outgoing[C].cb(new Error("Connection closed")),delete this.outgoing[C])}))}_removeTopicAliasAndRecoverTopicName(C){let O;C.properties&&(O=C.properties.topicAlias);let M=C.topic.toString();if(this.log("_removeTopicAliasAndRecoverTopicName :: alias %d, topic %o",O,M),M.length===0){if(typeof O>"u")return new Error("Unregistered Topic Alias");if(M=this.topicAliasSend.getTopicByAlias(O),typeof M>"u")return new Error("Unregistered Topic Alias");C.topic=M}O&&delete C.properties.topicAlias}_checkDisconnecting(C){return this.disconnecting&&(C&&C!==this.noop?C(new Error("client disconnecting")):this.emit("error",new Error("client disconnecting"))),this.disconnecting}_reconnect(){this.log("_reconnect: emitting reconnect to client"),this.emit("reconnect"),this.connected?(this.end(()=>{this.connect()}),this.log("client already connected. disconnecting first.")):(this.log("_reconnect: calling connect"),this.connect())}_setupReconnect(){!this.disconnecting&&!this.reconnectTimer&&this.options.reconnectPeriod>0?(this.reconnecting||(this.log("_setupReconnect :: emit `offline` state"),this.emit("offline"),this.log("_setupReconnect :: set `reconnecting` to `true`"),this.reconnecting=!0),this.log("_setupReconnect :: setting reconnectTimer for %d ms",this.options.reconnectPeriod),this.reconnectTimer=setInterval(()=>{this.log("reconnectTimer :: reconnect triggered!"),this._reconnect()},this.options.reconnectPeriod)):this.log("_setupReconnect :: doing nothing...")}_clearReconnect(){this.log("_clearReconnect : clearing reconnect timer"),this.reconnectTimer&&(clearInterval(this.reconnectTimer),this.reconnectTimer=null)}_cleanUp(C,O,M={}){if(O&&(this.log("_cleanUp :: done callback provided for on stream close"),this.stream.on("close",O)),this.log("_cleanUp :: forced? %s",C),C)this.options.reconnectPeriod===0&&this.options.clean&&this._flush(),this.log("_cleanUp :: (%s) :: destroying stream",this.options.clientId),this.stream.destroy();else{let $=Object.assign({cmd:"disconnect"},M);this.log("_cleanUp :: (%s) :: call _sendPacket with disconnect packet",this.options.clientId),this._sendPacket($,()=>{this.log("_cleanUp :: (%s) :: destroying stream",this.options.clientId),S(()=>{this.stream.end(()=>{this.log("_cleanUp :: (%s) :: stream destroyed",this.options.clientId)})})})}!this.disconnecting&&!this.reconnecting&&(this.log("_cleanUp :: client not disconnecting/reconnecting. Clearing and resetting reconnect."),this._clearReconnect(),this._setupReconnect()),this._destroyPingTimer(),O&&!this.connected&&(this.log("_cleanUp :: (%s) :: removing stream `done` callback `close` listener",this.options.clientId),this.stream.removeListener("close",O),O())}_storeAndSend(C,O,M){this.log("storeAndSend :: store packet with cmd %s to outgoingStore",C.cmd);let $=C,X;if($.cmd==="publish"&&($=(0,a.default)(C),X=this._removeTopicAliasAndRecoverTopicName($),X))return O&&O(X);this.outgoingStore.put($,te=>{if(te)return O&&O(te);M(),this._writePacket(C,O)})}_applyTopicAlias(C){if(this.options.protocolVersion===5&&C.cmd==="publish"){let O;C.properties&&(O=C.properties.topicAlias);let M=C.topic.toString();if(this.topicAliasSend)if(O){if(M.length!==0&&(this.log("applyTopicAlias :: register topic: %s - alias: %d",M,O),!this.topicAliasSend.put(M,O)))return this.log("applyTopicAlias :: error out of range. topic: %s - alias: %d",M,O),new Error("Sending Topic Alias out of range")}else M.length!==0&&(this.options.autoAssignTopicAlias?(O=this.topicAliasSend.getAliasByTopic(M),O?(C.topic="",C.properties=Object.assign(Object.assign({},C.properties),{topicAlias:O}),this.log("applyTopicAlias :: auto assign(use) topic: %s - alias: %d",M,O)):(O=this.topicAliasSend.getLruAlias(),this.topicAliasSend.put(M,O),C.properties=Object.assign(Object.assign({},C.properties),{topicAlias:O}),this.log("applyTopicAlias :: auto assign topic: %s - alias: %d",M,O))):this.options.autoUseTopicAlias&&(O=this.topicAliasSend.getAliasByTopic(M),O&&(C.topic="",C.properties=Object.assign(Object.assign({},C.properties),{topicAlias:O}),this.log("applyTopicAlias :: auto use topic: %s - alias: %d",M,O))));else if(O)return this.log("applyTopicAlias :: error out of range. topic: %s - alias: %d",M,O),new Error("Sending Topic Alias out of range")}}_noop(C){this.log("noop ::",C)}_writePacket(C,O){this.log("_writePacket :: packet: %O",C),this.log("_writePacket :: emitting `packetsend`"),this.emit("packetsend",C),this.log("_writePacket :: writing to stream");let M=r.default.writeToStream(C,this.stream,this.options);this.log("_writePacket :: writeToStream result %s",M),!M&&O&&O!==this.noop?(this.log("_writePacket :: handle events on `drain` once through callback."),this.stream.once("drain",O)):O&&(this.log("_writePacket :: invoking cb"),O())}_sendPacket(C,O,M,$){this.log("_sendPacket :: (%s) :: start",this.options.clientId),M=M||this.noop,O=O||this.noop;let X=this._applyTopicAlias(C);if(X){O(X);return}if(!this.connected){if(C.cmd==="auth"){this._writePacket(C,O);return}this.log("_sendPacket :: client not connected. Storing packet offline."),this._storePacket(C,O,M);return}if($){this._writePacket(C,O);return}switch(C.cmd){case"publish":break;case"pubrel":this._storeAndSend(C,O,M);return;default:this._writePacket(C,O);return}switch(C.qos){case 2:case 1:this._storeAndSend(C,O,M);break;case 0:default:this._writePacket(C,O);break}this.log("_sendPacket :: (%s) :: end",this.options.clientId)}_storePacket(C,O,M){this.log("_storePacket :: packet: %o",C),this.log("_storePacket :: cb? %s",!!O),M=M||this.noop;let $=C;if($.cmd==="publish"){$=(0,a.default)(C);let te=this._removeTopicAliasAndRecoverTopicName($);if(te)return O&&O(te)}let X=$.qos||0;X===0&&this.queueQoSZero||$.cmd!=="publish"?this.queue.push({packet:$,cb:O}):X>0?(O=this.outgoing[$.messageId]?this.outgoing[$.messageId].cb:null,this.outgoingStore.put($,te=>{if(te)return O&&O(te);M()})):O&&O(new Error("No connection to broker"))}_setupPingTimer(){this.log("_setupPingTimer :: keepalive %d (seconds)",this.options.keepalive),!this.pingTimer&&this.options.keepalive&&(this.pingTimer=new T.default(this.options.keepalive,()=>{this._checkPing()},this.options.timerVariant),this.pingResp=Date.now())}_destroyPingTimer(){this.pingTimer&&(this.log("_destroyPingTimer :: destroying ping timer"),this.pingTimer.destroy(),this.pingTimer=null)}_shiftPingInterval(){this.pingTimer&&this.options.keepalive&&this.options.reschedulePings&&this._reschedulePing()}_reschedulePing(){this.log("_reschedulePing :: rescheduling ping"),this.pingTimer.reschedule()}_checkPing(){this.log("_checkPing :: checking ping..."),Date.now()-this.pingResp-100<=this.options.keepalive*1e3?(this.log("_checkPing :: ping response received in time"),this._sendPing()):(this.emit("error",new Error("Keepalive timeout")),this.log("_checkPing :: calling _cleanUp with force true"),this._cleanUp(!0))}_sendPing(){this.log("_sendPing :: sending pingreq"),this._sendPacket({cmd:"pingreq"})}_resubscribe(){this.log("_resubscribe");let C=Object.keys(this._resubscribeTopics);if(!this._firstConnection&&(this.options.clean||this.options.protocolVersion>=4&&!this.connackPacket.sessionPresent)&&C.length>0)if(this.options.resubscribe)if(this.options.protocolVersion===5){this.log("_resubscribe: protocolVersion 5");for(let O=0;O{let M=this.outgoingStore.createStream(),$=()=>{M.destroy(),M=null,this._flushStoreProcessingQueue(),X()},X=()=>{this._storeProcessing=!1,this._packetIdsDuringStoreProcessing={}};this.once("close",$),M.on("error",E=>{X(),this._flushStoreProcessingQueue(),this.removeListener("close",$),this.emit("error",E)});let te=()=>{if(!M)return;let E=M.read(1),q;if(!E){M.once("readable",te);return}if(this._storeProcessing=!0,this._packetIdsDuringStoreProcessing[E.messageId]){te();return}!this.disconnecting&&!this.reconnectTimer?(q=this.outgoing[E.messageId]?this.outgoing[E.messageId].cb:null,this.outgoing[E.messageId]={volatile:!1,cb(Z,z){q&&q(Z,z),te()}},this._packetIdsDuringStoreProcessing[E.messageId]=!0,this.messageIdProvider.register(E.messageId)?this._sendPacket(E,void 0,void 0,!0):this.log("messageId: %d has already used.",E.messageId)):M.destroy&&M.destroy()};M.on("end",()=>{let E=!0;for(let q in this._packetIdsDuringStoreProcessing)if(!this._packetIdsDuringStoreProcessing[q]){E=!1;break}this.removeListener("close",$),E?(X(),this._invokeAllStoreProcessingQueue(),this.emit("connect",C)):O()}),te()};O()}_invokeStoreProcessingQueue(){if(!this._storeProcessing&&this._storeProcessingQueue.length>0){let C=this._storeProcessingQueue[0];if(C&&C.invoke())return this._storeProcessingQueue.shift(),!0}return!1}_invokeAllStoreProcessingQueue(){for(;this._invokeStoreProcessingQueue(););}_flushStoreProcessingQueue(){for(let C of this._storeProcessingQueue)C.cbStorePut&&C.cbStorePut(new Error("Connection closed")),C.callback&&C.callback(new Error("Connection closed"));this._storeProcessingQueue.splice(0)}_removeOutgoingAndStoreMessage(C,O){delete this.outgoing[C],this.outgoingStore.del({messageId:C},(M,$)=>{O(M,$),this.messageIdProvider.deallocate(C),this._invokeStoreProcessingQueue()})}};F.VERSION=m.MQTTJS_VERSION,e.default=F}),Iu=ye(e=>{he(),ue(),le(),Object.defineProperty(e,"__esModule",{value:!0});var o=Ps(),t=class{constructor(){this.numberAllocator=new o.NumberAllocator(1,65535)}allocate(){return this.lastId=this.numberAllocator.alloc(),this.lastId}getLastAllocated(){return this.lastId}register(l){return this.numberAllocator.use(l)}deallocate(l){this.numberAllocator.free(l)}clear(){this.numberAllocator.clear()}};e.default=t});function gr(e){throw new RangeError(Ns[e])}function xs(e,o){let t=e.split("@"),l="";t.length>1&&(l=t[0]+"@",e=t[1]);let h=function(i,r){let s=[],n=i.length;for(;n--;)s[n]=r(i[n]);return s}((e=e.replace(js,".")).split("."),o).join(".");return l+h}function Ms(e){let o=[],t=0,l=e.length;for(;t=55296&&h<=56319&&t{he(),ue(),le(),Us=/^xn--/,Ls=/[^\0-\x7E]/,js=/[\x2E\u3002\uFF0E\uFF61]/g,Ns={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},Ot=Math.floor,tn=String.fromCharCode,Vi=function(e,o){return e+22+75*(e<26)-((o!=0)<<5)},Hi=function(e,o,t){let l=0;for(e=t?Ot(e/700):e>>1,e+=Ot(e/o);e>455;l+=36)e=Ot(e/35);return Ot(l+36*e/(e+38))},zi=function(e){let o=[],t=e.length,l=0,h=128,i=72,r=e.lastIndexOf("-");r<0&&(r=0);for(let n=0;n=128&&gr("not-basic"),o.push(e.charCodeAt(n));for(let n=r>0?r+1:0;n=t&&gr("invalid-input");let b=(s=e.charCodeAt(n++))-48<10?s-22:s-65<26?s-65:s-97<26?s-97:36;(b>=36||b>Ot((2147483647-l)/d))&&gr("overflow"),l+=b*d;let m=g<=i?1:g>=i+26?26:g-i;if(bOt(2147483647/y)&&gr("overflow"),d*=y}let c=o.length+1;i=Hi(l-a,c,a==0),Ot(l/c)>2147483647-h&&gr("overflow"),h+=Ot(l/c),l%=c,o.splice(l++,0,h)}var s;return String.fromCodePoint(...o)},Ki=function(e){let o=[],t=(e=Ms(e)).length,l=128,h=0,i=72;for(let n of e)n<128&&o.push(tn(n));let r=o.length,s=r;for(r&&o.push("-");s=l&&cOt((2147483647-h)/a)&&gr("overflow"),h+=(n-l)*a,l=n;for(let c of e)if(c2147483647&&gr("overflow"),c==l){let d=h;for(let g=36;;g+=36){let b=g<=i?1:g>=i+26?26:g-i;if(dString.fromCodePoint(...e)},decode:zi,encode:Ki,toASCII:function(e){return xs(e,function(o){return Ls.test(o)?"xn--"+Ki(o):o})},toUnicode:function(e){return xs(e,function(o){return Us.test(o)?zi(o.slice(4).toLowerCase()):o})}},tr.decode,tr.encode,tr.toASCII,tr.toUnicode,tr.ucs2,tr.version});function ku(e,o){return Object.prototype.hasOwnProperty.call(e,o)}var Ds,Tr,Fs,Ut,Ru=ct(()=>{he(),ue(),le(),Ds=function(e,o,t,l){o=o||"&",t=t||"=";var h={};if(typeof e!="string"||e.length===0)return h;var i=/\+/g;e=e.split(o);var r=1e3;l&&typeof l.maxKeys=="number"&&(r=l.maxKeys);var s=e.length;r>0&&s>r&&(s=r);for(var n=0;n=0?(a=b.substr(0,m),c=b.substr(m+1)):(a=b,c=""),d=decodeURIComponent(a),g=decodeURIComponent(c),ku(h,d)?Array.isArray(h[d])?h[d].push(g):h[d]=[h[d],g]:h[d]=g}return h},Tr=function(e){switch(typeof e){case"string":return e;case"boolean":return e?"true":"false";case"number":return isFinite(e)?e:"";default:return""}},Fs=function(e,o,t,l){return o=o||"&",t=t||"=",e===null&&(e=void 0),typeof e=="object"?Object.keys(e).map(function(h){var i=encodeURIComponent(Tr(h))+t;return Array.isArray(e[h])?e[h].map(function(r){return i+encodeURIComponent(Tr(r))}).join(o):i+encodeURIComponent(Tr(e[h]))}).join(o):l?encodeURIComponent(Tr(l))+t+encodeURIComponent(Tr(e)):""},Ut={},Ut.decode=Ut.parse=Ds,Ut.encode=Ut.stringify=Fs,Ut.decode,Ut.encode,Ut.parse,Ut.stringify});function Yi(){throw new Error("setTimeout has not been defined")}function Qi(){throw new Error("clearTimeout has not been defined")}function Ws(e){if(Gt===setTimeout)return setTimeout(e,0);if((Gt===Yi||!Gt)&&setTimeout)return Gt=setTimeout,setTimeout(e,0);try{return Gt(e,0)}catch{try{return Gt.call(null,e,0)}catch{return Gt.call(this||br,e,0)}}}function Ou(){yr&&mr&&(yr=!1,mr.length?Lt=mr.concat(Lt):jr=-1,Lt.length&&$s())}function $s(){if(!yr){var e=Ws(Ou);yr=!0;for(var o=Lt.length;o;){for(mr=Lt,Lt=[];++jr{he(),ue(),le(),br=typeof globalThis<"u"?globalThis:typeof self<"u"?self:global,nt=Vs={},function(){try{Gt=typeof setTimeout=="function"?setTimeout:Yi}catch{Gt=Yi}try{Jt=typeof clearTimeout=="function"?clearTimeout:Qi}catch{Jt=Qi}}(),Lt=[],yr=!1,jr=-1,nt.nextTick=function(e){var o=new Array(arguments.length-1);if(arguments.length>1)for(var t=1;t1)for(var U=1;U{he(),ue(),le(),rn={},Gi=!1,vr=typeof globalThis<"u"?globalThis:typeof self<"u"?self:global,Qe=Pu(),Qe.platform="browser",Qe.addListener,Qe.argv,Qe.binding,Qe.browser,Qe.chdir,Qe.cwd,Qe.emit,Qe.env,Qe.listeners,Qe.nextTick,Qe.off,Qe.on,Qe.once,Qe.prependListener,Qe.prependOnceListener,Qe.removeAllListeners,Qe.removeListener,Qe.title,Qe.umask,Qe.version,Qe.versions});function Bu(){if(Ji)return nn;Ji=!0;var e=Qe;function o(i){if(typeof i!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(i))}function t(i,r){for(var s="",n=0,a=-1,c=0,d,g=0;g<=i.length;++g){if(g2){var b=s.lastIndexOf("/");if(b!==s.length-1){b===-1?(s="",n=0):(s=s.slice(0,b),n=s.length-1-s.lastIndexOf("/")),a=g,c=0;continue}}else if(s.length===2||s.length===1){s="",n=0,a=g,c=0;continue}}r&&(s.length>0?s+="/..":s="..",n=2)}else s.length>0?s+="/"+i.slice(a+1,g):s=i.slice(a+1,g),n=g-a-1;a=g,c=0}else d===46&&c!==-1?++c:c=-1}return s}function l(i,r){var s=r.dir||r.root,n=r.base||(r.name||"")+(r.ext||"");return s?s===r.root?s+n:s+i+n:n}var h={resolve:function(){for(var i="",r=!1,s,n=arguments.length-1;n>=-1&&!r;n--){var a;n>=0?a=arguments[n]:(s===void 0&&(s=e.cwd()),a=s),o(a),a.length!==0&&(i=a+"/"+i,r=a.charCodeAt(0)===47)}return i=t(i,!r),r?i.length>0?"/"+i:"/":i.length>0?i:"."},normalize:function(i){if(o(i),i.length===0)return".";var r=i.charCodeAt(0)===47,s=i.charCodeAt(i.length-1)===47;return i=t(i,!r),i.length===0&&!r&&(i="."),i.length>0&&s&&(i+="/"),r?"/"+i:i},isAbsolute:function(i){return o(i),i.length>0&&i.charCodeAt(0)===47},join:function(){if(arguments.length===0)return".";for(var i,r=0;r0&&(i===void 0?i=s:i+="/"+s)}return i===void 0?".":h.normalize(i)},relative:function(i,r){if(o(i),o(r),i===r||(i=h.resolve(i),r=h.resolve(r),i===r))return"";for(var s=1;sb){if(r.charCodeAt(c+y)===47)return r.slice(c+y+1);if(y===0)return r.slice(c+y)}else a>b&&(i.charCodeAt(s+y)===47?m=y:y===0&&(m=0));break}var T=i.charCodeAt(s+y),U=r.charCodeAt(c+y);if(T!==U)break;T===47&&(m=y)}var S="";for(y=s+m+1;y<=n;++y)(y===n||i.charCodeAt(y)===47)&&(S.length===0?S+="..":S+="/..");return S.length>0?S+r.slice(c+m):(c+=m,r.charCodeAt(c)===47&&++c,r.slice(c))},_makeLong:function(i){return i},dirname:function(i){if(o(i),i.length===0)return".";for(var r=i.charCodeAt(0),s=r===47,n=-1,a=!0,c=i.length-1;c>=1;--c)if(r=i.charCodeAt(c),r===47){if(!a){n=c;break}}else a=!1;return n===-1?s?"/":".":s&&n===1?"//":i.slice(0,n)},basename:function(i,r){if(r!==void 0&&typeof r!="string")throw new TypeError('"ext" argument must be a string');o(i);var s=0,n=-1,a=!0,c;if(r!==void 0&&r.length>0&&r.length<=i.length){if(r.length===i.length&&r===i)return"";var d=r.length-1,g=-1;for(c=i.length-1;c>=0;--c){var b=i.charCodeAt(c);if(b===47){if(!a){s=c+1;break}}else g===-1&&(a=!1,g=c+1),d>=0&&(b===r.charCodeAt(d)?--d===-1&&(n=c):(d=-1,n=g))}return s===n?n=g:n===-1&&(n=i.length),i.slice(s,n)}else{for(c=i.length-1;c>=0;--c)if(i.charCodeAt(c)===47){if(!a){s=c+1;break}}else n===-1&&(a=!1,n=c+1);return n===-1?"":i.slice(s,n)}},extname:function(i){o(i);for(var r=-1,s=0,n=-1,a=!0,c=0,d=i.length-1;d>=0;--d){var g=i.charCodeAt(d);if(g===47){if(!a){s=d+1;break}continue}n===-1&&(a=!1,n=d+1),g===46?r===-1?r=d:c!==1&&(c=1):r!==-1&&(c=-1)}return r===-1||n===-1||c===0||c===1&&r===n-1&&r===s+1?"":i.slice(r,n)},format:function(i){if(i===null||typeof i!="object")throw new TypeError('The "pathObject" argument must be of type Object. Received type '+typeof i);return l("/",i)},parse:function(i){o(i);var r={root:"",dir:"",base:"",ext:"",name:""};if(i.length===0)return r;var s=i.charCodeAt(0),n=s===47,a;n?(r.root="/",a=1):a=0;for(var c=-1,d=0,g=-1,b=!0,m=i.length-1,y=0;m>=a;--m){if(s=i.charCodeAt(m),s===47){if(!b){d=m+1;break}continue}g===-1&&(b=!1,g=m+1),s===46?c===-1?c=m:y!==1&&(y=1):c!==-1&&(y=-1)}return c===-1||g===-1||y===0||y===1&&c===g-1&&c===d+1?g!==-1&&(d===0&&n?r.base=r.name=i.slice(1,g):r.base=r.name=i.slice(d,g)):(d===0&&n?(r.name=i.slice(1,c),r.base=i.slice(1,g)):(r.name=i.slice(d,c),r.base=i.slice(d,g)),r.ext=i.slice(c,g)),d>0?r.dir=i.slice(0,d-1):n&&(r.dir="/"),r},sep:"/",delimiter:":",win32:null,posix:null};return h.posix=h,nn=h,nn}var nn,Ji,Xi,xu=ct(()=>{he(),ue(),le(),Hs(),nn={},Ji=!1,Xi=Bu()}),zs={};ir(zs,{URL:()=>va,Url:()=>pa,default:()=>qe,fileURLToPath:()=>Ks,format:()=>ga,parse:()=>ya,pathToFileURL:()=>Ys,resolve:()=>ba,resolveObject:()=>ma});function It(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}function Nr(e,o,t){if(e&&Ct.isObject(e)&&e instanceof It)return e;var l=new It;return l.parse(e,o,t),l}function Mu(){if(ro)return ln;ro=!0;var e=Ze;function o(i){if(typeof i!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(i))}function t(i,r){for(var s="",n=0,a=-1,c=0,d,g=0;g<=i.length;++g){if(g2){var b=s.lastIndexOf("/");if(b!==s.length-1){b===-1?(s="",n=0):(s=s.slice(0,b),n=s.length-1-s.lastIndexOf("/")),a=g,c=0;continue}}else if(s.length===2||s.length===1){s="",n=0,a=g,c=0;continue}}r&&(s.length>0?s+="/..":s="..",n=2)}else s.length>0?s+="/"+i.slice(a+1,g):s=i.slice(a+1,g),n=g-a-1;a=g,c=0}else d===46&&c!==-1?++c:c=-1}return s}function l(i,r){var s=r.dir||r.root,n=r.base||(r.name||"")+(r.ext||"");return s?s===r.root?s+n:s+i+n:n}var h={resolve:function(){for(var i="",r=!1,s,n=arguments.length-1;n>=-1&&!r;n--){var a;n>=0?a=arguments[n]:(s===void 0&&(s=e.cwd()),a=s),o(a),a.length!==0&&(i=a+"/"+i,r=a.charCodeAt(0)===47)}return i=t(i,!r),r?i.length>0?"/"+i:"/":i.length>0?i:"."},normalize:function(i){if(o(i),i.length===0)return".";var r=i.charCodeAt(0)===47,s=i.charCodeAt(i.length-1)===47;return i=t(i,!r),i.length===0&&!r&&(i="."),i.length>0&&s&&(i+="/"),r?"/"+i:i},isAbsolute:function(i){return o(i),i.length>0&&i.charCodeAt(0)===47},join:function(){if(arguments.length===0)return".";for(var i,r=0;r0&&(i===void 0?i=s:i+="/"+s)}return i===void 0?".":h.normalize(i)},relative:function(i,r){if(o(i),o(r),i===r||(i=h.resolve(i),r=h.resolve(r),i===r))return"";for(var s=1;sb){if(r.charCodeAt(c+y)===47)return r.slice(c+y+1);if(y===0)return r.slice(c+y)}else a>b&&(i.charCodeAt(s+y)===47?m=y:y===0&&(m=0));break}var T=i.charCodeAt(s+y),U=r.charCodeAt(c+y);if(T!==U)break;T===47&&(m=y)}var S="";for(y=s+m+1;y<=n;++y)(y===n||i.charCodeAt(y)===47)&&(S.length===0?S+="..":S+="/..");return S.length>0?S+r.slice(c+m):(c+=m,r.charCodeAt(c)===47&&++c,r.slice(c))},_makeLong:function(i){return i},dirname:function(i){if(o(i),i.length===0)return".";for(var r=i.charCodeAt(0),s=r===47,n=-1,a=!0,c=i.length-1;c>=1;--c)if(r=i.charCodeAt(c),r===47){if(!a){n=c;break}}else a=!1;return n===-1?s?"/":".":s&&n===1?"//":i.slice(0,n)},basename:function(i,r){if(r!==void 0&&typeof r!="string")throw new TypeError('"ext" argument must be a string');o(i);var s=0,n=-1,a=!0,c;if(r!==void 0&&r.length>0&&r.length<=i.length){if(r.length===i.length&&r===i)return"";var d=r.length-1,g=-1;for(c=i.length-1;c>=0;--c){var b=i.charCodeAt(c);if(b===47){if(!a){s=c+1;break}}else g===-1&&(a=!1,g=c+1),d>=0&&(b===r.charCodeAt(d)?--d===-1&&(n=c):(d=-1,n=g))}return s===n?n=g:n===-1&&(n=i.length),i.slice(s,n)}else{for(c=i.length-1;c>=0;--c)if(i.charCodeAt(c)===47){if(!a){s=c+1;break}}else n===-1&&(a=!1,n=c+1);return n===-1?"":i.slice(s,n)}},extname:function(i){o(i);for(var r=-1,s=0,n=-1,a=!0,c=0,d=i.length-1;d>=0;--d){var g=i.charCodeAt(d);if(g===47){if(!a){s=d+1;break}continue}n===-1&&(a=!1,n=d+1),g===46?r===-1?r=d:c!==1&&(c=1):r!==-1&&(c=-1)}return r===-1||n===-1||c===0||c===1&&r===n-1&&r===s+1?"":i.slice(r,n)},format:function(i){if(i===null||typeof i!="object")throw new TypeError('The "pathObject" argument must be of type Object. Received type '+typeof i);return l("/",i)},parse:function(i){o(i);var r={root:"",dir:"",base:"",ext:"",name:""};if(i.length===0)return r;var s=i.charCodeAt(0),n=s===47,a;n?(r.root="/",a=1):a=0;for(var c=-1,d=0,g=-1,b=!0,m=i.length-1,y=0;m>=a;--m){if(s=i.charCodeAt(m),s===47){if(!b){d=m+1;break}continue}g===-1&&(b=!1,g=m+1),s===46?c===-1?c=m:y!==1&&(y=1):c!==-1&&(y=-1)}return c===-1||g===-1||y===0||y===1&&c===g-1&&c===d+1?g!==-1&&(d===0&&n?r.base=r.name=i.slice(1,g):r.base=r.name=i.slice(d,g)):(d===0&&n?(r.name=i.slice(1,c),r.base=i.slice(1,g)):(r.name=i.slice(d,c),r.base=i.slice(d,g)),r.ext=i.slice(c,g)),d>0?r.dir=i.slice(0,d-1):n&&(r.dir="/"),r},sep:"/",delimiter:":",win32:null,posix:null};return h.posix=h,ln=h,ln}function Uu(e){if(typeof e=="string")e=new URL(e);else if(!(e instanceof URL))throw new Deno.errors.InvalidData("invalid argument path , must be a string or URL");if(e.protocol!=="file:")throw new Deno.errors.InvalidData("invalid url scheme");return un?Lu(e):ju(e)}function Lu(e){let o=e.hostname,t=e.pathname;for(let l=0;lsa||h!==":")throw new Deno.errors.InvalidData("file url path must be absolute");return t.slice(1)}}function ju(e){if(e.hostname!=="")throw new Deno.errors.InvalidData("invalid file url hostname");let o=e.pathname;for(let t=0;tSa||h!==":")throw new Deno.errors.InvalidData("file url path must be absolute");return t.slice(1)}}function Fu(e){if(e.hostname!=="")throw new Deno.errors.InvalidData("invalid file url hostname");let o=e.pathname;for(let t=0;t{he(),ue(),le(),Tu(),Ru(),Cu(),xu(),Hs(),qe={},Qs=tr,Ct={isString:function(e){return typeof e=="string"},isObject:function(e){return typeof e=="object"&&e!==null},isNull:function(e){return e===null},isNullOrUndefined:function(e){return e==null}},qe.parse=Nr,qe.resolve=function(e,o){return Nr(e,!1,!0).resolve(o)},qe.resolveObject=function(e,o){return e?Nr(e,!1,!0).resolveObject(o):o},qe.format=function(e){return Ct.isString(e)&&(e=Nr(e)),e instanceof It?e.format():It.prototype.format.call(e)},qe.Url=It,Gs=/^([a-z0-9.+-]+:)/i,Js=/:[0-9]*$/,Xs=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,Zs=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r",` `," "]),on=["'"].concat(Zs),Zi=["%","/","?",";","#"].concat(on),eo=["/","?","#"],to=/^[+a-z0-9A-Z_-]{0,63}$/,ea=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,ta={javascript:!0,"javascript:":!0},sn={javascript:!0,"javascript:":!0},wr={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},an=Ut,It.prototype.parse=function(e,o,t){if(!Ct.isString(e))throw new TypeError("Parameter 'url' must be a string, not "+typeof e);var l=e.indexOf("?"),h=l!==-1&&l127?F+="x":F+=R[W];if(!F.match(to)){var O=U.slice(0,m),M=U.slice(m+1),$=R.match(ea);$&&(O.push($[1]),M.unshift($[2])),M.length&&(r="/"+M.join(".")+r),this.hostname=O.join(".");break}}}this.hostname.length>255?this.hostname="":this.hostname=this.hostname.toLowerCase(),T||(this.hostname=Qs.toASCII(this.hostname));var X=this.port?":"+this.port:"",te=this.hostname||"";this.host=te+X,this.href+=this.host,T&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),r[0]!=="/"&&(r="/"+r))}if(!ta[a])for(m=0,S=on.length;m0)&&t.host.split("@"))&&(t.auth=$.shift(),t.host=t.hostname=$.shift())),t.search=e.search,t.query=e.query,Ct.isNull(t.pathname)&&Ct.isNull(t.search)||(t.path=(t.pathname?t.pathname:"")+(t.search?t.search:"")),t.href=t.format(),t;if(!R.length)return t.pathname=null,t.search?t.path="/"+t.search:t.path=null,t.href=t.format(),t;for(var W=R.slice(-1)[0],C=(t.host||e.host||R.length>1)&&(W==="."||W==="..")||W==="",O=0,M=R.length;M>=0;M--)(W=R[M])==="."?R.splice(M,1):W===".."?(R.splice(M,1),O++):O&&(R.splice(M,1),O--);if(!U&&!S)for(;O--;O)R.unshift("..");!U||R[0]===""||R[0]&&R[0].charAt(0)==="/"||R.unshift(""),C&&R.join("/").substr(-1)!=="/"&&R.push("");var $,X=R[0]===""||R[0]&&R[0].charAt(0)==="/";return F&&(t.hostname=t.host=X?"":R.length?R.shift():"",($=!!(t.host&&t.host.indexOf("@")>0)&&t.host.split("@"))&&(t.auth=$.shift(),t.host=t.hostname=$.shift())),(U=U||t.host&&R.length)&&!X&&R.unshift(""),R.length?t.pathname=R.join("/"):(t.pathname=null,t.path=null),Ct.isNull(t.pathname)&&Ct.isNull(t.search)||(t.path=(t.pathname?t.pathname:"")+(t.search?t.search:"")),t.auth=e.auth||t.auth,t.slashes=t.slashes||e.slashes,t.href=t.format(),t},It.prototype.parseHost=function(){var e=this.host,o=Js.exec(e);o&&((o=o[0])!==":"&&(this.port=o.substr(1)),e=e.substr(0,e.length-o.length)),e&&(this.hostname=e)},qe.Url,qe.format,qe.resolve,qe.resolveObject,ln={},ro=!1,no=Mu(),ra=typeof Deno<"u"?Deno.build.os==="windows"?"win32":Deno.build.os:void 0,qe.URL=typeof URL<"u"?URL:null,qe.pathToFileURL=Nu,qe.fileURLToPath=Uu,qe.Url,qe.format,qe.resolve,qe.resolveObject,qe.URL,na=92,ia=47,oa=97,sa=122,un=ra==="win32",aa=/\//g,la=/%/g,ua=/\\/g,ha=/\n/g,ca=/\r/g,fa=/\t/g,da=typeof Deno<"u"?Deno.build.os==="windows"?"win32":Deno.build.os:void 0,qe.URL=typeof URL<"u"?URL:null,qe.pathToFileURL=Ys,qe.fileURLToPath=Ks,pa=qe.Url,ga=qe.format,ba=qe.resolve,ma=qe.resolveObject,ya=qe.parse,va=qe.URL,wa=92,_a=47,Ea=97,Sa=122,hn=da==="win32",Aa=/\//g,Ia=/%/g,Ta=/\\/g,ka=/\n/g,Ra=/\r/g,Oa=/\t/g}),io={};ir(io,{Server:()=>Ge,Socket:()=>Ge,Stream:()=>Ge,_createServerHandle:()=>Ge,_normalizeArgs:()=>Ge,_setSimultaneousAccepts:()=>Ge,connect:()=>Ge,createConnection:()=>Ge,createServer:()=>Ge,default:()=>Ca,isIP:()=>Ge,isIPv4:()=>Ge,isIPv6:()=>Ge});function Ge(){throw new Error("Node.js net module is not supported by JSPM core outside of Node.js")}var Ca,Pa=ct(()=>{he(),ue(),le(),Ca={_createServerHandle:Ge,_normalizeArgs:Ge,_setSimultaneousAccepts:Ge,connect:Ge,createConnection:Ge,createServer:Ge,isIP:Ge,isIPv4:Ge,isIPv6:Ge,Server:Ge,Socket:Ge,Stream:Ge}}),Ba=ye(e=>{he(),ue(),le();var o=e&&e.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(e,"__esModule",{value:!0});var t=o((Pa(),Ve(io))),l=o(zt()),h=(0,l.default)("mqttjs:tcp"),i=(r,s)=>{s.port=s.port||1883,s.hostname=s.hostname||s.host||"localhost";let{port:n,path:a}=s,c=s.hostname;return h("port %d and host %s",n,c),t.default.createConnection({port:n,host:c,path:a})};e.default=i}),xa={};ir(xa,{default:()=>Ma});var Ma,$u=ct(()=>{he(),ue(),le(),Ma={}}),Ua=ye(e=>{he(),ue(),le();var o=e&&e.__importDefault||function(s){return s&&s.__esModule?s:{default:s}};Object.defineProperty(e,"__esModule",{value:!0});var t=o(($u(),Ve(xa))),l=o((Pa(),Ve(io))),h=o(zt()),i=(0,h.default)("mqttjs:tls"),r=(s,n)=>{n.port=n.port||8883,n.host=n.hostname||n.host||"localhost",l.default.isIP(n.host)===0&&(n.servername=n.host),n.rejectUnauthorized=n.rejectUnauthorized!==!1,delete n.path,i("port %d host %s rejectUnauthorized %b",n.port,n.host,n.rejectUnauthorized);let a=t.default.connect(n);a.on("secureConnect",()=>{n.rejectUnauthorized&&!a.authorized?a.emit("error",new Error("TLS not authorized")):a.removeListener("error",c)});function c(d){n.rejectUnauthorized&&s.emit("error",d),a.end()}return a.on("error",c),a};e.default=r}),oo=ye(e=>{he(),ue(),le(),Object.defineProperty(e,"__esModule",{value:!0}),e.BufferedDuplex=e.writev=void 0;var o=pr(),t=(dt(),Ve(ft));function l(i,r){let s=new Array(i.length);for(let n=0;n{this.push(n)})}_read(i){this.proxy.read(i)}_write(i,r,s){this.isSocketOpen?this.writeToProxy(i,r,s):this.writeQueue.push({chunk:i,encoding:r,cb:s})}_final(i){this.writeQueue=[],this.proxy.end(i)}_destroy(i,r){this.writeQueue=[],this.proxy.destroy(),r(i)}socketReady(){this.emit("connect"),this.isSocketOpen=!0,this.processWriteQueue()}writeToProxy(i,r,s){this.proxy.write(i,r)===!1?this.proxy.once("drain",s):s()}processWriteQueue(){for(;this.writeQueue.length>0;){let{chunk:i,encoding:r,cb:s}=this.writeQueue.shift();this.writeToProxy(i,r,s)}}};e.BufferedDuplex=h}),La=ye(e=>{he(),ue(),le(),Object.defineProperty(e,"__esModule",{value:!0});var o=(dt(),Ve(ft)),t=pr(),l=oo(),h,i,r;function s(){let g=new t.Transform;return g._write=(b,m,y)=>{h.send({data:b.buffer,success(){y()},fail(T){y(new Error(T))}})},g._flush=b=>{h.close({success(){b()}})},g}function n(g){g.hostname||(g.hostname="localhost"),g.path||(g.path="/"),g.wsOptions||(g.wsOptions={})}function a(g,b){let m=g.protocol==="wxs"?"wss":"ws",y=`${m}://${g.hostname}${g.path}`;return g.port&&g.port!==80&&g.port!==443&&(y=`${m}://${g.hostname}:${g.port}${g.path}`),typeof g.transformWsUrl=="function"&&(y=g.transformWsUrl(y,g,b)),y}function c(){h.onOpen(()=>{r.socketReady()}),h.onMessage(g=>{let{data:b}=g;b instanceof ArrayBuffer?b=o.Buffer.from(b):b=o.Buffer.from(b,"utf8"),i.push(b)}),h.onClose(()=>{r.emit("close"),r.end(),r.destroy()}),h.onError(g=>{let b=new Error(g.errMsg);r.destroy(b)})}var d=(g,b)=>{if(b.hostname=b.hostname||b.host,!b.hostname)throw new Error("Could not determine host. Specify host manually.");let m=b.protocolId==="MQIsdp"&&b.protocolVersion===3?"mqttv3.1":"mqtt";n(b);let y=a(b,g);h=wx.connectSocket({url:y,protocols:[m]}),i=s(),r=new l.BufferedDuplex(b,i,h),r._destroy=(U,S)=>{h.close({success(){S&&S(U)}})};let T=r.destroy;return r.destroy=(U,S)=>(r.destroy=T,setTimeout(()=>{h.close({fail(){r._destroy(U,S)}})},0),r),c(),r};e.default=d}),ja=ye(e=>{he(),ue(),le(),Object.defineProperty(e,"__esModule",{value:!0});var o=(dt(),Ve(ft)),t=pr(),l=oo(),h,i,r,s=!1;function n(){let b=new t.Transform;return b._write=(m,y,T)=>{h.sendSocketMessage({data:m.buffer,success(){T()},fail(){T(new Error)}})},b._flush=m=>{h.closeSocket({success(){m()}})},b}function a(b){b.hostname||(b.hostname="localhost"),b.path||(b.path="/"),b.wsOptions||(b.wsOptions={})}function c(b,m){let y=b.protocol==="alis"?"wss":"ws",T=`${y}://${b.hostname}${b.path}`;return b.port&&b.port!==80&&b.port!==443&&(T=`${y}://${b.hostname}:${b.port}${b.path}`),typeof b.transformWsUrl=="function"&&(T=b.transformWsUrl(T,b,m)),T}function d(){s||(s=!0,h.onSocketOpen(()=>{r.socketReady()}),h.onSocketMessage(b=>{if(typeof b.data=="string"){let m=o.Buffer.from(b.data,"base64");i.push(m)}else{let m=new FileReader;m.addEventListener("load",()=>{let y=m.result;y instanceof ArrayBuffer?y=o.Buffer.from(y):y=o.Buffer.from(y,"utf8"),i.push(y)}),m.readAsArrayBuffer(b.data)}}),h.onSocketClose(()=>{r.end(),r.destroy()}),h.onSocketError(b=>{r.destroy(b)}))}var g=(b,m)=>{if(m.hostname=m.hostname||m.host,!m.hostname)throw new Error("Could not determine host. Specify host manually.");let y=m.protocolId==="MQIsdp"&&m.protocolVersion===3?"mqttv3.1":"mqtt";a(m);let T=c(m,b);return h=m.my,h.connectSocket({url:T,protocols:y}),i=n(),r=new l.BufferedDuplex(m,i,h),d(),r};e.default=g}),qu=ye((e,o)=>{he(),ue(),le(),o.exports=function(){throw new Error("ws does not work in the browser. Browser clients must use the native WebSocket object")}}),Na=ye(e=>{he(),ue(),le();var o=e&&e.__importDefault||function(U){return U&&U.__esModule?U:{default:U}};Object.defineProperty(e,"__esModule",{value:!0});var t=(dt(),Ve(ft)),l=o(qu()),h=o(zt()),i=pr(),r=o(en()),s=oo(),n=(0,h.default)("mqttjs:ws"),a=["rejectUnauthorized","ca","cert","key","pfx","passphrase"];function c(U,S){let R=`${U.protocol}://${U.hostname}:${U.port}${U.path}`;return typeof U.transformWsUrl=="function"&&(R=U.transformWsUrl(R,U,S)),R}function d(U){let S=U;return U.hostname||(S.hostname="localhost"),U.port||(U.protocol==="wss"?S.port=443:S.port=80),U.path||(S.path="/"),U.wsOptions||(S.wsOptions={}),!r.default&&U.protocol==="wss"&&a.forEach(R=>{Object.prototype.hasOwnProperty.call(U,R)&&!Object.prototype.hasOwnProperty.call(U.wsOptions,R)&&(S.wsOptions[R]=U[R])}),S}function g(U){let S=d(U);if(S.hostname||(S.hostname=S.host),!S.hostname){if(typeof document>"u")throw new Error("Could not determine host. Specify host manually.");let R=new URL(document.URL);S.hostname=R.hostname,S.port||(S.port=Number(R.port))}return S.objectMode===void 0&&(S.objectMode=!(S.binary===!0||S.binary===void 0)),S}function b(U,S,R){n("createWebSocket"),n(`protocol: ${R.protocolId} ${R.protocolVersion}`);let F=R.protocolId==="MQIsdp"&&R.protocolVersion===3?"mqttv3.1":"mqtt";n(`creating new Websocket for url: ${S} and protocol: ${F}`);let W;return R.createWebsocket?W=R.createWebsocket(S,[F],R):W=new l.default(S,[F],R.wsOptions),W}function m(U,S){let R=S.protocolId==="MQIsdp"&&S.protocolVersion===3?"mqttv3.1":"mqtt",F=c(S,U),W;return S.createWebsocket?W=S.createWebsocket(F,[R],S):W=new WebSocket(F,[R]),W.binaryType="arraybuffer",W}var y=(U,S)=>{n("streamBuilder");let R=d(S),F=c(R,U),W=b(U,F,R),C=l.default.createWebSocketStream(W,R.wsOptions);return C.url=F,W.on("close",()=>{C.destroy()}),C},T=(U,S)=>{n("browserStreamBuilder");let R,F=g(S).browserBufferSize||1024*512,W=S.browserBufferTimeout||1e3,C=!S.objectMode,O=m(U,S),M=X(S,z,be);S.objectMode||(M._writev=s.writev.bind(M)),M.on("close",()=>{O.close()});let $=typeof O.addEventListener<"u";O.readyState===O.OPEN?(R=M,R.socket=O):(R=new s.BufferedDuplex(S,M,O),$?O.addEventListener("open",te):O.onopen=te),$?(O.addEventListener("close",E),O.addEventListener("error",q),O.addEventListener("message",Z)):(O.onclose=E,O.onerror=q,O.onmessage=Z);function X(ie,V,me){let ne=new i.Transform({objectMode:ie.objectMode});return ne._write=V,ne._flush=me,ne}function te(){n("WebSocket onOpen"),R instanceof s.BufferedDuplex&&R.socketReady()}function E(ie){n("WebSocket onClose",ie),R.end(),R.destroy()}function q(ie){n("WebSocket onError",ie);let V=new Error("WebSocket error");V.event=ie,R.destroy(V)}function Z(ie){let{data:V}=ie;V instanceof ArrayBuffer?V=t.Buffer.from(V):V=t.Buffer.from(V,"utf8"),M.push(V)}function z(ie,V,me){if(O.bufferedAmount>F){setTimeout(z,W,ie,V,me);return}C&&typeof ie=="string"&&(ie=t.Buffer.from(ie,"utf8"));try{O.send(ie)}catch(ne){return me(ne)}me()}function be(ie){O.close(),ie()}return R};e.default=r.default?T:y}),Vu=ye(e=>{he(),ue(),le();var o=e&&e.__importDefault||function(d){return d&&d.__esModule?d:{default:d}};Object.defineProperty(e,"__esModule",{value:!0}),e.connectAsync=void 0;var t=o(zt()),l=o((Wu(),Ve(zs))),h=o(qi()),i=o(en());typeof(ze==null?void 0:ze.nextTick)!="function"&&(ze.nextTick=setImmediate);var r=(0,t.default)("mqttjs"),s={};i.default?(s.wx=La().default,s.wxs=La().default,s.ali=ja().default,s.alis=ja().default):(s.mqtt=Ba().default,s.tcp=Ba().default,s.ssl=Ua().default,s.tls=s.ssl,s.mqtts=Ua().default),s.ws=Na().default,s.wss=Na().default;function n(d){let g;d.auth&&(g=d.auth.match(/^(.+):(.+)$/),g?(d.username=g[1],d.password=g[2]):d.username=d.auth)}function a(d,g){if(r("connecting to an MQTT broker..."),typeof d=="object"&&!g&&(g=d,d=""),g=g||{},d&&typeof d=="string"){let y=l.default.parse(d,!0);if(y.port!=null&&(y.port=Number(y.port)),g=Object.assign(Object.assign({},y),g),g.protocol===null)throw new Error("Missing protocol");g.protocol=g.protocol.replace(/:$/,"")}if(n(g),g.query&&typeof g.query.clientId=="string"&&(g.clientId=g.query.clientId),g.cert&&g.key)if(g.protocol){if(["mqtts","wss","wxs","alis"].indexOf(g.protocol)===-1)switch(g.protocol){case"mqtt":g.protocol="mqtts";break;case"ws":g.protocol="wss";break;case"wx":g.protocol="wxs";break;case"ali":g.protocol="alis";break;default:throw new Error(`Unknown protocol for secure connection: "${g.protocol}"!`)}}else throw new Error("Missing secure protocol key");if(!s[g.protocol]){let y=["mqtts","wss"].indexOf(g.protocol)!==-1;g.protocol=["mqtt","mqtts","ws","wss","wx","wxs","ali","alis"].filter((T,U)=>y&&U%2===0?!1:typeof s[T]=="function")[0]}if(g.clean===!1&&!g.clientId)throw new Error("Missing clientId for unclean clients");g.protocol&&(g.defaultProtocol=g.protocol);function b(y){return g.servers&&((!y._reconnectCount||y._reconnectCount===g.servers.length)&&(y._reconnectCount=0),g.host=g.servers[y._reconnectCount].host,g.port=g.servers[y._reconnectCount].port,g.protocol=g.servers[y._reconnectCount].protocol?g.servers[y._reconnectCount].protocol:g.defaultProtocol,g.hostname=g.host,y._reconnectCount++),r("calling streambuilder for",g.protocol),s[g.protocol](y,g)}let m=new h.default(b,g);return m.on("error",()=>{}),m}function c(d,g,b=!0){return new Promise((m,y)=>{let T=a(d,g),U={connect:R=>{S(),m(T)},end:()=>{S(),m(T)},error:R=>{S(),T.end(),y(R)}};b===!1&&(U.close=()=>{U.error(new Error("Couldn't connect to server"))});function S(){Object.keys(U).forEach(R=>{T.off(R,U[R])})}Object.keys(U).forEach(R=>{T.on(R,U[R])})})}e.connectAsync=c,e.default=a}),Da=ye(e=>{he(),ue(),le();var o=e&&e.__createBinding||(Object.create?function(b,m,y,T){T===void 0&&(T=y);var U=Object.getOwnPropertyDescriptor(m,y);(!U||("get"in U?!m.__esModule:U.writable||U.configurable))&&(U={enumerable:!0,get:function(){return m[y]}}),Object.defineProperty(b,T,U)}:function(b,m,y,T){T===void 0&&(T=y),b[T]=m[y]}),t=e&&e.__setModuleDefault||(Object.create?function(b,m){Object.defineProperty(b,"default",{enumerable:!0,value:m})}:function(b,m){b.default=m}),l=e&&e.__importStar||function(b){if(b&&b.__esModule)return b;var m={};if(b!=null)for(var y in b)y!=="default"&&Object.prototype.hasOwnProperty.call(b,y)&&o(m,b,y);return t(m,b),m},h=e&&e.__exportStar||function(b,m){for(var y in b)y!=="default"&&!Object.prototype.hasOwnProperty.call(m,y)&&o(m,b,y)},i=e&&e.__importDefault||function(b){return b&&b.__esModule?b:{default:b}};Object.defineProperty(e,"__esModule",{value:!0}),e.ReasonCodes=e.PingTimer=e.UniqueMessageIdProvider=e.DefaultMessageIdProvider=e.Store=e.MqttClient=e.connectAsync=e.connect=e.Client=void 0;var r=i(qi());e.MqttClient=r.default;var s=i(As());e.DefaultMessageIdProvider=s.default;var n=i(Iu());e.UniqueMessageIdProvider=n.default;var a=i(Is());e.Store=a.default;var c=l(Vu());e.connect=c.default,Object.defineProperty(e,"connectAsync",{enumerable:!0,get:function(){return c.connectAsync}});var d=i(Bs());e.PingTimer=d.default,e.Client=r.default,h(qi(),e),h(Lr(),e);var g=Zr();Object.defineProperty(e,"ReasonCodes",{enumerable:!0,get:function(){return g.ReasonCodes}})}),Hu=ye(e=>{he(),ue(),le();var o=e&&e.__createBinding||(Object.create?function(r,s,n,a){a===void 0&&(a=n);var c=Object.getOwnPropertyDescriptor(s,n);(!c||("get"in c?!s.__esModule:c.writable||c.configurable))&&(c={enumerable:!0,get:function(){return s[n]}}),Object.defineProperty(r,a,c)}:function(r,s,n,a){a===void 0&&(a=n),r[a]=s[n]}),t=e&&e.__setModuleDefault||(Object.create?function(r,s){Object.defineProperty(r,"default",{enumerable:!0,value:s})}:function(r,s){r.default=s}),l=e&&e.__importStar||function(r){if(r&&r.__esModule)return r;var s={};if(r!=null)for(var n in r)n!=="default"&&Object.prototype.hasOwnProperty.call(r,n)&&o(s,r,n);return t(s,r),s},h=e&&e.__exportStar||function(r,s){for(var n in r)n!=="default"&&!Object.prototype.hasOwnProperty.call(s,n)&&o(s,r,n)};Object.defineProperty(e,"__esModule",{value:!0});var i=l(Da());e.default=i,h(Da(),e)});Hu();/*! Bundled license information: @jspm/core/nodelibs/browser/buffer.js: (*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh *) */const Dr={CONNECTING:"CONNECTING",CONNECTED:"CONNECTED",DISCONNECTED:"DISCONNECTED",OFFLINE:"OFFLINE",ERROR:"ERROR"};function zu({children:e,brokerUrl:o,options:t={keepalive:0},parserMethod:l}){const h=Be.useRef(!1),[i,r]=Be.useState(Dr.OFFLINE),[s,n]=Be.useState(null);Be.useEffect(()=>{if(!s&&!h.current){h.current=!0,r(Dr.CONNECTING);const c=(void 0)(o,t);c.on("connect",()=>{r(Dr.CONNECTED),n(c)}),c.on("reconnect",()=>{r("Reconnecting")}),c.on("error",d=>{console.log(`Connection error: ${d}`),r(d.message)}),c.on("offline",()=>{r(Dr.OFFLINE)}),c.on("end",()=>{r(Dr.OFFLINE)})}},[s,h,o,t]),Be.useEffect(()=>()=>{s&&(s.end(!0),n(null),h.current=!1)},[s,h]);const a=Be.useMemo(()=>({connectionStatus:i,client:s,parserMethod:l}),[i,s,l]);return nl.jsx(Wr.Provider,{value:a,children:e})}je.Connector=zu,je.MqttContext=Wr,je.useMqttState=el,je.useSubscription=Za,Object.defineProperty(je,Symbol.toStringTag,{value:"Module"})}); //# sourceMappingURL=rc-mqtt.umd.cjs.map