@machinemetrics/mm-react-tools 4.0.14-0 → 4.0.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -23098,7 +23098,7 @@ const TF = () => {
23098
23098
  scope: t,
23099
23099
  ttl: 1209600,
23100
23100
  client_id: n,
23101
- device: u,
23101
+ ...u !== void 0 && { device: u },
23102
23102
  redirect_uri: `${window.location.origin}/authorize/mm/callback`,
23103
23103
  ...ke
23104
23104
  }), ye = `${m.loginUrl}/oauth/authorize?${Ce}`;
@@ -135,7 +135,7 @@ function print() { __p += __j.call(arguments, '') }
135
135
  font-size: 20px;
136
136
  text-align: center;
137
137
  margin-top: 300px;
138
- `;const wI=()=>{const{isAuthenticated:r}=ti(),{authorize:e,authError:t,setAuthError:n}=le.useContext(rc);return bo(async i=>{try{await e(i)}catch(a){console.log(a),n("Login Failed. Try again.")}},[]),t?nr.jsx(Fb,{loadError:t}):r?nr.jsx(Fb,{}):nr.jsx(nr.Fragment,{})},xo={production:{loginUrl:"https://login.machinemetrics.com",appUrl:"https://app.machinemetrics.com",apiUrl:"https://api.machinemetrics.com",graphQLUrl:"https://graphql.machinemetrics.com/v1/graphql",natsUrl:"https://stream.machinemetrics.com"},staging:{loginUrl:"https://login-staging.machinemetrics.com",appUrl:"https://staging.machinemetrics.com",apiUrl:"https://api-staging.machinemetrics.com",graphQLUrl:"https://hasura.tsdb.perlman.m12s.com/v1/graphql",natsUrl:"https://stream.data.dev.m12s.com"},development:{loginUrl:"https://login.development.machinemetrics.com",appUrl:"https://app.development.machinemetrics.com",apiUrl:"https://api.development.machinemetrics.com",graphQLUrl:"https://hasura.tsdb.perlman.m12s.com/v1/graphql",natsUrl:"https://stream.data.dev.m12s.com"}},_I=pn.createBrowserRouter([{path:"/authorize/mm/callback",element:nr.jsx(wI,{})},{path:"/*",element:nr.jsx(vI,{})}]),xI=({domain:r,children:e,scope:t,clientId:n,clientSecret:i,releaseStage:a,device:u,graphQLRoleOverride:c,urls:f})=>{r&&console.warn("MMProvider domain is no longer used. It is inferred from the url.");const[h,d]=le.useState(),[y,g]=le.useState(!1);let m;if(xo[a])m=xo[a];else if(!m){const Ie=ci.keys(xo).join(", "),pe=ci.keys(xo[Object.keys(xo)[0]]);throw Error(`MMProvider releaseStage must be one of the following: ${Ie}, or the following urls need to be provided: ${pe}.`)}m=ci.merge(m,f);const[b,I]=le.useState(Sk());le.useEffect(()=>{Ek(b)},[b]);const x=Ie=>{const pe=A0();I0(pe),k0(window.location.pathname+window.location.search);const Pe=(We=>ci.map(We,(ke,X)=>`${X}=${ke}`).join("&"))({response_type:"code",state:pe,scope:t,ttl:1209600,client_id:n,device:u,redirect_uri:`${window.location.origin}/authorize/mm/callback`,...Ie}),ge=`${m.loginUrl}/oauth/authorize?${Pe}`;window.location=ge},_=async Ie=>{const pe=bk.parse(window.location.search),Ce=pe.code;if(pe.error)throw Error(pe.error_description);if(pe.state!==Tk())throw Error("Oops");const Pe={grant_type:"authorization_code",client_id:n,client_secret:i,code:Ce,redirect_uri:`${window.location.origin}/authorize/mm/callback`},ge=await C0(`${m.loginUrl}/oauth/token`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded;charset=UTF-8"},body:new URLSearchParams(Pe),signal:Ie});I(ge.access_token),I0()},A=()=>{I()},P=async(Ie,pe={})=>{pe.headers={...pe.headers,"Content-Type":"application/json",Authorization:`Bearer ${b}`};const Ce=await C0(Ie,pe);if(Ce.error&&Ce.error.status===401)throw await M(),Error("UNAUTHORIZED");return Ce},M=async()=>{await P(`${m.loginUrl}/logout`,{method:"DELETE"}),A()},[$,j]=le.useState(),K=le.useRef(),ee=le.useRef();wo(async()=>{if(!b){K.current=null,j(!1);return}try{const Ie=await P(`${m.apiUrl}/user-token?graphql=1`);K.current=Ie,j(!0)}catch{}},1e3*60*4.5,[b]),wo(async()=>{if(!b){ee.current=null;return}try{const Ie=await P(`${m.apiUrl}/nats-token`);ee.current=Ie}catch{}},1e3*60*9.5,[b]);const fe=le.useMemo(()=>({clientId:n,accessToken:b,jwtRef:K,natsCredsRef:ee,isAuthenticated:$,login:x,logout:M,request:P,urls:m}),[b,n,$,K,x,M,ee,P,m]),de=le.useMemo(()=>({children:e,graphQLRoleOverride:c,authorize:_,isEmbedded:y,setIsEmbedded:g,authError:h,setAuthError:d}),[e,c,_,y,g,h,d]);return nr.jsx(c0.Provider,{value:fe,children:nr.jsx(rc.Provider,{value:de,children:nr.jsx(pn.RouterProvider,{router:_I})})})},bn=new Uint8Array(0),Si=new TextEncoder,cn=new TextDecoder;function SI(...r){let e=0;for(let i=0;i<r.length;i++)e+=r[i].length;const t=new Uint8Array(e);let n=0;for(let i=0;i<r.length;i++)t.set(r[i],n),n+=r[i].length;return t}function So(...r){const e=[];for(let t=0;t<r.length;t++)e.push(Si.encode(r[t]));return e.length===0?bn:e.length===1?e[0]:SI(...e)}function Lb(r){return!r||r.length===0?"":cn.decode(r)}const qb="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",jb=36,EI=0xcfd41b9100000,Ub=33,OI=333,$b=22;function TI(r){for(let e=0;e<r.length;e++)r[e]=Math.floor(Math.random()*255)}function AI(r){var e;(e=globalThis==null?void 0:globalThis.crypto)!=null&&e.getRandomValues?globalThis.crypto.getRandomValues(r):TI(r)}class kI{constructor(){E(this,"buf");E(this,"seq");E(this,"inc");E(this,"inited");this.buf=new Uint8Array($b),this.inited=!1}init(){this.inited=!0,this.setPre(),this.initSeqAndInc(),this.fillSeq()}initSeqAndInc(){this.seq=Math.floor(Math.random()*EI),this.inc=Math.floor(Math.random()*(OI-Ub)+Ub)}setPre(){const e=new Uint8Array(12);AI(e);for(let t=0;t<12;t++){const n=e[t]%36;this.buf[t]=qb.charCodeAt(n)}}fillSeq(){let e=this.seq;for(let t=$b-1;t>=12;t--)this.buf[t]=qb.charCodeAt(e%jb),e=Math.floor(e/jb)}next(){return this.inited||this.init(),this.seq+=this.inc,this.seq>0xcfd41b9100000&&(this.setPre(),this.initSeqAndInc()),this.fillSeq(),String.fromCharCode.apply(String,this.buf)}reset(){this.init()}}const Cs=new kI;var Ei;(function(r){r.Disconnect="disconnect",r.Reconnect="reconnect",r.Update="update",r.LDM="ldm",r.Error="error"})(Ei||(Ei={}));var pa;(function(r){r.Reconnecting="reconnecting",r.PingTimer="pingTimer",r.StaleConnection="staleConnection",r.ClientInitiatedReconnect="client initiated reconnect"})(pa||(pa={}));var be;(function(r){r.ApiError="BAD API",r.BadAuthentication="BAD_AUTHENTICATION",r.BadCreds="BAD_CREDS",r.BadHeader="BAD_HEADER",r.BadJson="BAD_JSON",r.BadPayload="BAD_PAYLOAD",r.BadSubject="BAD_SUBJECT",r.Cancelled="CANCELLED",r.ConnectionClosed="CONNECTION_CLOSED",r.ConnectionDraining="CONNECTION_DRAINING",r.ConnectionRefused="CONNECTION_REFUSED",r.ConnectionTimeout="CONNECTION_TIMEOUT",r.Disconnect="DISCONNECT",r.InvalidOption="INVALID_OPTION",r.InvalidPayload="INVALID_PAYLOAD",r.MaxPayloadExceeded="MAX_PAYLOAD_EXCEEDED",r.NoResponders="503",r.NotFunction="NOT_FUNC",r.RequestError="REQUEST_ERROR",r.ServerOptionNotAvailable="SERVER_OPT_NA",r.SubClosed="SUB_CLOSED",r.SubDraining="SUB_DRAINING",r.Timeout="TIMEOUT",r.Tls="TLS",r.Unknown="UNKNOWN_ERROR",r.WssRequired="WSS_REQUIRED",r.JetStreamInvalidAck="JESTREAM_INVALID_ACK",r.JetStream404NoMessages="404",r.JetStream408RequestTimeout="408",r.JetStream409MaxAckPendingExceeded="409",r.JetStream409="409",r.JetStreamNotEnabled="503",r.JetStreamIdleHeartBeat="IDLE_HEARTBEAT",r.AuthorizationViolation="AUTHORIZATION_VIOLATION",r.AuthenticationExpired="AUTHENTICATION_EXPIRED",r.ProtocolError="NATS_PROTOCOL_ERR",r.PermissionsViolation="PERMISSIONS_VIOLATION",r.AuthenticationTimeout="AUTHENTICATION_TIMEOUT",r.AccountExpired="ACCOUNT_EXPIRED"})(be||(be={}));function II(r){return typeof r.code=="string"}class Bb{constructor(){E(this,"messages");this.messages=new Map,this.messages.set(be.InvalidPayload,"Invalid payload type - payloads can be 'binary', 'string', or 'json'"),this.messages.set(be.BadJson,"Bad JSON"),this.messages.set(be.WssRequired,"TLS is required, therefore a secure websocket connection is also required")}static getMessage(e){return CI.getMessage(e)}getMessage(e){return this.messages.get(e)||e}}const CI=new Bb;class Re extends Error{constructor(t,n,i){super(t);E(this,"name");E(this,"message");E(this,"code");E(this,"permissionContext");E(this,"chainedError");E(this,"api_error");this.name="NatsError",this.message=t,this.code=n,this.chainedError=i}static errorForCode(t,n){const i=Bb.getMessage(t);return new Re(i,t,n)}isAuthError(){return this.code===be.AuthenticationExpired||this.code===be.AuthorizationViolation||this.code===be.AccountExpired}isAuthTimeout(){return this.code===be.AuthenticationTimeout}isPermissionError(){return this.code===be.PermissionsViolation}isProtocolError(){return this.code===be.ProtocolError}isJetStreamError(){return this.api_error!==void 0}jsError(){return this.api_error?this.api_error:null}}var wn;(function(r){r[r.Exact=0]="Exact",r[r.CanonicalMIME=1]="CanonicalMIME",r[r.IgnoreCase=2]="IgnoreCase"})(wn||(wn={}));var ri;(function(r){r.Timer="timer",r.Count="count",r.JitterTimer="jitterTimer",r.SentinelMsg="sentinelMsg"})(ri||(ri={}));var Eo;(function(r){r.STATS="io.nats.micro.v1.stats_response",r.INFO="io.nats.micro.v1.info_response",r.PING="io.nats.micro.v1.ping_response"})(Eo||(Eo={}));const nc="Nats-Service-Error",ic="Nats-Service-Error-Code";class sc extends Error{constructor(t,n){super(n);E(this,"code");this.code=t}static isServiceError(t){return sc.toServiceError(t)!==null}static toServiceError(t){var i,a;const n=((i=t==null?void 0:t.headers)==null?void 0:i.get(ic))||"";if(n!==""){const u=parseInt(n)||400,c=((a=t==null?void 0:t.headers)==null?void 0:a.get(nc))||"";return new sc(u,c.length?c:n)}return null}}function Oi(r=""){if(r=r||"_INBOX",typeof r!="string")throw new Error("prefix must be a string");return r.split(".").forEach(e=>{if(e==="*"||e===">")throw new Error(`inbox prefixes cannot have wildcards '${r}'`)}),`${r}.${Cs.next()}`}const ld="127.0.0.1";var ts;(function(r){r.PING="PING",r.STATS="STATS",r.INFO="INFO"})(ts||(ts={}));function ac(r,...e){for(let t=0;t<e.length;t++){const n=e[t];Object.keys(n).forEach(function(i){r[i]=n[i]})}return r}function oc(r){return cn.decode(r).replace(/\n/g,"␊").replace(/\r/g,"␍")}function ma(r,e=!0){const t=e?Re.errorForCode(be.Timeout):null;let n,i;const a=new Promise((u,c)=>{n={cancel:()=>{i&&clearTimeout(i)}},i=setTimeout(()=>{c(t===null?Re.errorForCode(be.Timeout):t)},r)});return Object.assign(a,n)}function ya(r=0){let e;const t=new Promise(n=>{const i=setTimeout(()=>{n()},r);e={cancel:()=>{i&&clearTimeout(i)}}});return Object.assign(t,e)}function ir(){let r={};const e=new Promise((t,n)=>{r={resolve:t,reject:n}});return Object.assign(e,r)}function Vb(r){for(let e=r.length-1;e>0;e--){const t=Math.floor(Math.random()*(e+1));[r[e],r[t]]=[r[t],r[e]]}return r}function PI(r){return r===0?0:Math.floor(r/2+Math.random()*r)}function fd(r=[0,250,250,500,500,3e3,5e3]){Array.isArray(r)||(r=[0,250,250,500,500,3e3,5e3]);const e=r.length-1;return{backoff(t){return PI(t>e?r[e]:r[t])}}}function cr(r){return r*1e6}function hd(r){return Math.floor(r/1e6)}function Wb(r){let n=!0;const i=new Array(r.length);for(let a=0;a<r.length;a++){let u=r.charCodeAt(a);if(u===58||u<33||u>126)throw new Re(`'${r[a]}' is not a valid character for a header key`,be.BadHeader);n&&97<=u&&u<=122?u-=32:!n&&65<=u&&u<=90&&(u+=32),i[a]=u,n=u==45}return String.fromCharCode(...i)}function Ti(r=0,e=""){if(r===0&&e!==""||r>0&&e==="")throw new Error("setting status requires both code and description");return new rs(r,e)}const dd="NATS/1.0";class rs{constructor(e=0,t=""){E(this,"_code");E(this,"headers");E(this,"_description");this._code=e,this._description=t,this.headers=new Map}[Symbol.iterator](){return this.headers.entries()}size(){return this.headers.size}equals(e){if(e&&this.headers.size===e.headers.size&&this._code===e._code){for(const[t,n]of this.headers){const i=e.values(t);if(n.length!==i.length)return!1;const a=[...n].sort(),u=[...i].sort();for(let c=0;c<a.length;c++)if(a[c]!==u[c])return!1}return!0}return!1}static decode(e){const t=new rs,i=cn.decode(e).split(`\r
138
+ `;const wI=()=>{const{isAuthenticated:r}=ti(),{authorize:e,authError:t,setAuthError:n}=le.useContext(rc);return bo(async i=>{try{await e(i)}catch(a){console.log(a),n("Login Failed. Try again.")}},[]),t?nr.jsx(Fb,{loadError:t}):r?nr.jsx(Fb,{}):nr.jsx(nr.Fragment,{})},xo={production:{loginUrl:"https://login.machinemetrics.com",appUrl:"https://app.machinemetrics.com",apiUrl:"https://api.machinemetrics.com",graphQLUrl:"https://graphql.machinemetrics.com/v1/graphql",natsUrl:"https://stream.machinemetrics.com"},staging:{loginUrl:"https://login-staging.machinemetrics.com",appUrl:"https://staging.machinemetrics.com",apiUrl:"https://api-staging.machinemetrics.com",graphQLUrl:"https://hasura.tsdb.perlman.m12s.com/v1/graphql",natsUrl:"https://stream.data.dev.m12s.com"},development:{loginUrl:"https://login.development.machinemetrics.com",appUrl:"https://app.development.machinemetrics.com",apiUrl:"https://api.development.machinemetrics.com",graphQLUrl:"https://hasura.tsdb.perlman.m12s.com/v1/graphql",natsUrl:"https://stream.data.dev.m12s.com"}},_I=pn.createBrowserRouter([{path:"/authorize/mm/callback",element:nr.jsx(wI,{})},{path:"/*",element:nr.jsx(vI,{})}]),xI=({domain:r,children:e,scope:t,clientId:n,clientSecret:i,releaseStage:a,device:u,graphQLRoleOverride:c,urls:f})=>{r&&console.warn("MMProvider domain is no longer used. It is inferred from the url.");const[h,d]=le.useState(),[y,g]=le.useState(!1);let m;if(xo[a])m=xo[a];else if(!m){const Ie=ci.keys(xo).join(", "),pe=ci.keys(xo[Object.keys(xo)[0]]);throw Error(`MMProvider releaseStage must be one of the following: ${Ie}, or the following urls need to be provided: ${pe}.`)}m=ci.merge(m,f);const[b,I]=le.useState(Sk());le.useEffect(()=>{Ek(b)},[b]);const x=Ie=>{const pe=A0();I0(pe),k0(window.location.pathname+window.location.search);const Pe=(We=>ci.map(We,(ke,X)=>`${X}=${ke}`).join("&"))({response_type:"code",state:pe,scope:t,ttl:1209600,client_id:n,...u!==void 0&&{device:u},redirect_uri:`${window.location.origin}/authorize/mm/callback`,...Ie}),ge=`${m.loginUrl}/oauth/authorize?${Pe}`;window.location=ge},_=async Ie=>{const pe=bk.parse(window.location.search),Ce=pe.code;if(pe.error)throw Error(pe.error_description);if(pe.state!==Tk())throw Error("Oops");const Pe={grant_type:"authorization_code",client_id:n,client_secret:i,code:Ce,redirect_uri:`${window.location.origin}/authorize/mm/callback`},ge=await C0(`${m.loginUrl}/oauth/token`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded;charset=UTF-8"},body:new URLSearchParams(Pe),signal:Ie});I(ge.access_token),I0()},A=()=>{I()},P=async(Ie,pe={})=>{pe.headers={...pe.headers,"Content-Type":"application/json",Authorization:`Bearer ${b}`};const Ce=await C0(Ie,pe);if(Ce.error&&Ce.error.status===401)throw await M(),Error("UNAUTHORIZED");return Ce},M=async()=>{await P(`${m.loginUrl}/logout`,{method:"DELETE"}),A()},[$,j]=le.useState(),K=le.useRef(),ee=le.useRef();wo(async()=>{if(!b){K.current=null,j(!1);return}try{const Ie=await P(`${m.apiUrl}/user-token?graphql=1`);K.current=Ie,j(!0)}catch{}},1e3*60*4.5,[b]),wo(async()=>{if(!b){ee.current=null;return}try{const Ie=await P(`${m.apiUrl}/nats-token`);ee.current=Ie}catch{}},1e3*60*9.5,[b]);const fe=le.useMemo(()=>({clientId:n,accessToken:b,jwtRef:K,natsCredsRef:ee,isAuthenticated:$,login:x,logout:M,request:P,urls:m}),[b,n,$,K,x,M,ee,P,m]),de=le.useMemo(()=>({children:e,graphQLRoleOverride:c,authorize:_,isEmbedded:y,setIsEmbedded:g,authError:h,setAuthError:d}),[e,c,_,y,g,h,d]);return nr.jsx(c0.Provider,{value:fe,children:nr.jsx(rc.Provider,{value:de,children:nr.jsx(pn.RouterProvider,{router:_I})})})},bn=new Uint8Array(0),Si=new TextEncoder,cn=new TextDecoder;function SI(...r){let e=0;for(let i=0;i<r.length;i++)e+=r[i].length;const t=new Uint8Array(e);let n=0;for(let i=0;i<r.length;i++)t.set(r[i],n),n+=r[i].length;return t}function So(...r){const e=[];for(let t=0;t<r.length;t++)e.push(Si.encode(r[t]));return e.length===0?bn:e.length===1?e[0]:SI(...e)}function Lb(r){return!r||r.length===0?"":cn.decode(r)}const qb="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",jb=36,EI=0xcfd41b9100000,Ub=33,OI=333,$b=22;function TI(r){for(let e=0;e<r.length;e++)r[e]=Math.floor(Math.random()*255)}function AI(r){var e;(e=globalThis==null?void 0:globalThis.crypto)!=null&&e.getRandomValues?globalThis.crypto.getRandomValues(r):TI(r)}class kI{constructor(){E(this,"buf");E(this,"seq");E(this,"inc");E(this,"inited");this.buf=new Uint8Array($b),this.inited=!1}init(){this.inited=!0,this.setPre(),this.initSeqAndInc(),this.fillSeq()}initSeqAndInc(){this.seq=Math.floor(Math.random()*EI),this.inc=Math.floor(Math.random()*(OI-Ub)+Ub)}setPre(){const e=new Uint8Array(12);AI(e);for(let t=0;t<12;t++){const n=e[t]%36;this.buf[t]=qb.charCodeAt(n)}}fillSeq(){let e=this.seq;for(let t=$b-1;t>=12;t--)this.buf[t]=qb.charCodeAt(e%jb),e=Math.floor(e/jb)}next(){return this.inited||this.init(),this.seq+=this.inc,this.seq>0xcfd41b9100000&&(this.setPre(),this.initSeqAndInc()),this.fillSeq(),String.fromCharCode.apply(String,this.buf)}reset(){this.init()}}const Cs=new kI;var Ei;(function(r){r.Disconnect="disconnect",r.Reconnect="reconnect",r.Update="update",r.LDM="ldm",r.Error="error"})(Ei||(Ei={}));var pa;(function(r){r.Reconnecting="reconnecting",r.PingTimer="pingTimer",r.StaleConnection="staleConnection",r.ClientInitiatedReconnect="client initiated reconnect"})(pa||(pa={}));var be;(function(r){r.ApiError="BAD API",r.BadAuthentication="BAD_AUTHENTICATION",r.BadCreds="BAD_CREDS",r.BadHeader="BAD_HEADER",r.BadJson="BAD_JSON",r.BadPayload="BAD_PAYLOAD",r.BadSubject="BAD_SUBJECT",r.Cancelled="CANCELLED",r.ConnectionClosed="CONNECTION_CLOSED",r.ConnectionDraining="CONNECTION_DRAINING",r.ConnectionRefused="CONNECTION_REFUSED",r.ConnectionTimeout="CONNECTION_TIMEOUT",r.Disconnect="DISCONNECT",r.InvalidOption="INVALID_OPTION",r.InvalidPayload="INVALID_PAYLOAD",r.MaxPayloadExceeded="MAX_PAYLOAD_EXCEEDED",r.NoResponders="503",r.NotFunction="NOT_FUNC",r.RequestError="REQUEST_ERROR",r.ServerOptionNotAvailable="SERVER_OPT_NA",r.SubClosed="SUB_CLOSED",r.SubDraining="SUB_DRAINING",r.Timeout="TIMEOUT",r.Tls="TLS",r.Unknown="UNKNOWN_ERROR",r.WssRequired="WSS_REQUIRED",r.JetStreamInvalidAck="JESTREAM_INVALID_ACK",r.JetStream404NoMessages="404",r.JetStream408RequestTimeout="408",r.JetStream409MaxAckPendingExceeded="409",r.JetStream409="409",r.JetStreamNotEnabled="503",r.JetStreamIdleHeartBeat="IDLE_HEARTBEAT",r.AuthorizationViolation="AUTHORIZATION_VIOLATION",r.AuthenticationExpired="AUTHENTICATION_EXPIRED",r.ProtocolError="NATS_PROTOCOL_ERR",r.PermissionsViolation="PERMISSIONS_VIOLATION",r.AuthenticationTimeout="AUTHENTICATION_TIMEOUT",r.AccountExpired="ACCOUNT_EXPIRED"})(be||(be={}));function II(r){return typeof r.code=="string"}class Bb{constructor(){E(this,"messages");this.messages=new Map,this.messages.set(be.InvalidPayload,"Invalid payload type - payloads can be 'binary', 'string', or 'json'"),this.messages.set(be.BadJson,"Bad JSON"),this.messages.set(be.WssRequired,"TLS is required, therefore a secure websocket connection is also required")}static getMessage(e){return CI.getMessage(e)}getMessage(e){return this.messages.get(e)||e}}const CI=new Bb;class Re extends Error{constructor(t,n,i){super(t);E(this,"name");E(this,"message");E(this,"code");E(this,"permissionContext");E(this,"chainedError");E(this,"api_error");this.name="NatsError",this.message=t,this.code=n,this.chainedError=i}static errorForCode(t,n){const i=Bb.getMessage(t);return new Re(i,t,n)}isAuthError(){return this.code===be.AuthenticationExpired||this.code===be.AuthorizationViolation||this.code===be.AccountExpired}isAuthTimeout(){return this.code===be.AuthenticationTimeout}isPermissionError(){return this.code===be.PermissionsViolation}isProtocolError(){return this.code===be.ProtocolError}isJetStreamError(){return this.api_error!==void 0}jsError(){return this.api_error?this.api_error:null}}var wn;(function(r){r[r.Exact=0]="Exact",r[r.CanonicalMIME=1]="CanonicalMIME",r[r.IgnoreCase=2]="IgnoreCase"})(wn||(wn={}));var ri;(function(r){r.Timer="timer",r.Count="count",r.JitterTimer="jitterTimer",r.SentinelMsg="sentinelMsg"})(ri||(ri={}));var Eo;(function(r){r.STATS="io.nats.micro.v1.stats_response",r.INFO="io.nats.micro.v1.info_response",r.PING="io.nats.micro.v1.ping_response"})(Eo||(Eo={}));const nc="Nats-Service-Error",ic="Nats-Service-Error-Code";class sc extends Error{constructor(t,n){super(n);E(this,"code");this.code=t}static isServiceError(t){return sc.toServiceError(t)!==null}static toServiceError(t){var i,a;const n=((i=t==null?void 0:t.headers)==null?void 0:i.get(ic))||"";if(n!==""){const u=parseInt(n)||400,c=((a=t==null?void 0:t.headers)==null?void 0:a.get(nc))||"";return new sc(u,c.length?c:n)}return null}}function Oi(r=""){if(r=r||"_INBOX",typeof r!="string")throw new Error("prefix must be a string");return r.split(".").forEach(e=>{if(e==="*"||e===">")throw new Error(`inbox prefixes cannot have wildcards '${r}'`)}),`${r}.${Cs.next()}`}const ld="127.0.0.1";var ts;(function(r){r.PING="PING",r.STATS="STATS",r.INFO="INFO"})(ts||(ts={}));function ac(r,...e){for(let t=0;t<e.length;t++){const n=e[t];Object.keys(n).forEach(function(i){r[i]=n[i]})}return r}function oc(r){return cn.decode(r).replace(/\n/g,"␊").replace(/\r/g,"␍")}function ma(r,e=!0){const t=e?Re.errorForCode(be.Timeout):null;let n,i;const a=new Promise((u,c)=>{n={cancel:()=>{i&&clearTimeout(i)}},i=setTimeout(()=>{c(t===null?Re.errorForCode(be.Timeout):t)},r)});return Object.assign(a,n)}function ya(r=0){let e;const t=new Promise(n=>{const i=setTimeout(()=>{n()},r);e={cancel:()=>{i&&clearTimeout(i)}}});return Object.assign(t,e)}function ir(){let r={};const e=new Promise((t,n)=>{r={resolve:t,reject:n}});return Object.assign(e,r)}function Vb(r){for(let e=r.length-1;e>0;e--){const t=Math.floor(Math.random()*(e+1));[r[e],r[t]]=[r[t],r[e]]}return r}function PI(r){return r===0?0:Math.floor(r/2+Math.random()*r)}function fd(r=[0,250,250,500,500,3e3,5e3]){Array.isArray(r)||(r=[0,250,250,500,500,3e3,5e3]);const e=r.length-1;return{backoff(t){return PI(t>e?r[e]:r[t])}}}function cr(r){return r*1e6}function hd(r){return Math.floor(r/1e6)}function Wb(r){let n=!0;const i=new Array(r.length);for(let a=0;a<r.length;a++){let u=r.charCodeAt(a);if(u===58||u<33||u>126)throw new Re(`'${r[a]}' is not a valid character for a header key`,be.BadHeader);n&&97<=u&&u<=122?u-=32:!n&&65<=u&&u<=90&&(u+=32),i[a]=u,n=u==45}return String.fromCharCode(...i)}function Ti(r=0,e=""){if(r===0&&e!==""||r>0&&e==="")throw new Error("setting status requires both code and description");return new rs(r,e)}const dd="NATS/1.0";class rs{constructor(e=0,t=""){E(this,"_code");E(this,"headers");E(this,"_description");this._code=e,this._description=t,this.headers=new Map}[Symbol.iterator](){return this.headers.entries()}size(){return this.headers.size}equals(e){if(e&&this.headers.size===e.headers.size&&this._code===e._code){for(const[t,n]of this.headers){const i=e.values(t);if(n.length!==i.length)return!1;const a=[...n].sort(),u=[...i].sort();for(let c=0;c<a.length;c++)if(a[c]!==u[c])return!1}return!0}return!1}static decode(e){const t=new rs,i=cn.decode(e).split(`\r
139
139
  `),a=i[0];if(a!==dd){let u=a.replace(dd,"").trim();if(u.length>0){t._code=parseInt(u,10),isNaN(t._code)&&(t._code=0);const c=t._code.toString();u=u.replace(c,""),t._description=u.trim()}}return i.length>=1&&i.slice(1).map(u=>{if(u){const c=u.indexOf(":");if(c>-1){const f=u.slice(0,c),h=u.slice(c+1).trim();t.append(f,h)}}}),t}toString(){if(this.headers.size===0&&this._code===0)return"";let e=dd;this._code>0&&this._description!==""&&(e+=` ${this._code} ${this._description}`);for(const[t,n]of this.headers)for(let i=0;i<n.length;i++)e=`${e}\r
140
140
  ${t}: ${n[i]}`;return`${e}\r
141
141
  \r
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@machinemetrics/mm-react-tools",
3
- "version": "4.0.14-0",
3
+ "version": "4.0.14",
4
4
  "description": "Components, hooks, and helper functions for writing React apps using MachineMetrics APIs.",
5
5
  "author": "machinemetrics",
6
6
  "license": "MIT",