ss-support-widget 1.0.13 → 1.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.
package/dist/x-bot-widget.js
CHANGED
|
@@ -157,7 +157,7 @@ export default theme;`}function Kg(e){return typeof e=="number"?`${(e*100).toFix
|
|
|
157
157
|
`});++o<e.length;)o&&i.push({type:"text",value:`
|
|
158
158
|
`}),i.push(e[o]);return t&&e.length>0&&i.push({type:"text",value:`
|
|
159
159
|
`}),i}function cb(e){let t=0,i=e.charCodeAt(t);for(;i===9||i===32;)t++,i=e.charCodeAt(t);return e.slice(t)}function fb(e,t){const i=t5(e,t),o=i.one(e,void 0),l=V3(i),u=Array.isArray(o)?{type:"root",children:o}:o||{type:"root",children:[]};return l&&u.children.push({type:"text",value:`
|
|
160
|
-
`},l),u}function a5(e,t){return e&&"run"in e?async function(i,o){const l=fb(i,{file:o,...t});await e.run(l,o)}:function(i,o){return fb(i,{file:o,...e||t})}}function db(e){if(e)throw e}var Ud,hb;function l5(){if(hb)return Ud;hb=1;var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,i=Object.defineProperty,o=Object.getOwnPropertyDescriptor,l=function(p){return typeof Array.isArray=="function"?Array.isArray(p):t.call(p)==="[object Array]"},u=function(p){if(!p||t.call(p)!=="[object Object]")return!1;var g=e.call(p,"constructor"),y=p.constructor&&p.constructor.prototype&&e.call(p.constructor.prototype,"isPrototypeOf");if(p.constructor&&!g&&!y)return!1;var v;for(v in p);return typeof v>"u"||e.call(p,v)},c=function(p,g){i&&g.name==="__proto__"?i(p,g.name,{enumerable:!0,configurable:!0,value:g.newValue,writable:!0}):p[g.name]=g.newValue},d=function(p,g){if(g==="__proto__")if(e.call(p,g)){if(o)return o(p,g).value}else return;return p[g]};return Ud=function m(){var p,g,y,v,S,E,w=arguments[0],R=1,k=arguments.length,I=!1;for(typeof w=="boolean"&&(I=w,w=arguments[1]||{},R=2),(w==null||typeof w!="object"&&typeof w!="function")&&(w={});R<k;++R)if(p=arguments[R],p!=null)for(g in p)y=d(w,g),v=d(p,g),w!==v&&(I&&v&&(u(v)||(S=l(v)))?(S?(S=!1,E=y&&l(y)?y:[]):E=y&&u(y)?y:{},c(w,{name:g,newValue:m(I,E,v)})):typeof v<"u"&&c(w,{name:g,newValue:v}));return w},Ud}var s5=l5();const Ld=Es(s5);function jd(e){if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function u5(){const e=[],t={run:i,use:o};return t;function i(...l){let u=-1;const c=l.pop();if(typeof c!="function")throw new TypeError("Expected function as last argument, not "+c);d(null,...l);function d(m,...p){const g=e[++u];let y=-1;if(m){c(m);return}for(;++y<l.length;)(p[y]===null||p[y]===void 0)&&(p[y]=l[y]);l=p,g?c5(g,d)(...p):c(null,...p)}}function o(l){if(typeof l!="function")throw new TypeError("Expected `middelware` to be a function, not "+l);return e.push(l),t}}function c5(e,t){let i;return o;function o(...c){const d=e.length>c.length;let m;d&&c.push(l);try{m=e.apply(this,c)}catch(p){const g=p;if(d&&i)throw g;return l(g)}d||(m&&m.then&&typeof m.then=="function"?m.then(u,l):m instanceof Error?l(m):u(m))}function l(c,...d){i||(i=!0,t(c,...d))}function u(c){l(null,c)}}const Ir={basename:f5,dirname:d5,extname:h5,join:p5,sep:"/"};function f5(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');Tl(e);let i=0,o=-1,l=e.length,u;if(t===void 0||t.length===0||t.length>e.length){for(;l--;)if(e.codePointAt(l)===47){if(u){i=l+1;break}}else o<0&&(u=!0,o=l+1);return o<0?"":e.slice(i,o)}if(t===e)return"";let c=-1,d=t.length-1;for(;l--;)if(e.codePointAt(l)===47){if(u){i=l+1;break}}else c<0&&(u=!0,c=l+1),d>-1&&(e.codePointAt(l)===t.codePointAt(d--)?d<0&&(o=l):(d=-1,o=c));return i===o?o=c:o<0&&(o=e.length),e.slice(i,o)}function d5(e){if(Tl(e),e.length===0)return".";let t=-1,i=e.length,o;for(;--i;)if(e.codePointAt(i)===47){if(o){t=i;break}}else o||(o=!0);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function h5(e){Tl(e);let t=e.length,i=-1,o=0,l=-1,u=0,c;for(;t--;){const d=e.codePointAt(t);if(d===47){if(c){o=t+1;break}continue}i<0&&(c=!0,i=t+1),d===46?l<0?l=t:u!==1&&(u=1):l>-1&&(u=-1)}return l<0||i<0||u===0||u===1&&l===i-1&&l===o+1?"":e.slice(l,i)}function p5(...e){let t=-1,i;for(;++t<e.length;)Tl(e[t]),e[t]&&(i=i===void 0?e[t]:i+"/"+e[t]);return i===void 0?".":m5(i)}function m5(e){Tl(e);const t=e.codePointAt(0)===47;let i=g5(e,!t);return i.length===0&&!t&&(i="."),i.length>0&&e.codePointAt(e.length-1)===47&&(i+="/"),t?"/"+i:i}function g5(e,t){let i="",o=0,l=-1,u=0,c=-1,d,m;for(;++c<=e.length;){if(c<e.length)d=e.codePointAt(c);else{if(d===47)break;d=47}if(d===47){if(!(l===c-1||u===1))if(l!==c-1&&u===2){if(i.length<2||o!==2||i.codePointAt(i.length-1)!==46||i.codePointAt(i.length-2)!==46){if(i.length>2){if(m=i.lastIndexOf("/"),m!==i.length-1){m<0?(i="",o=0):(i=i.slice(0,m),o=i.length-1-i.lastIndexOf("/")),l=c,u=0;continue}}else if(i.length>0){i="",o=0,l=c,u=0;continue}}t&&(i=i.length>0?i+"/..":"..",o=2)}else i.length>0?i+="/"+e.slice(l+1,c):i=e.slice(l+1,c),o=c-l-1;l=c,u=0}else d===46&&u>-1?u++:u=-1}return i}function Tl(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const y5={cwd:b5};function b5(){return"/"}function Pd(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function S5(e){if(typeof e=="string")e=new URL(e);else if(!Pd(e)){const t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if(e.protocol!=="file:"){const t=new TypeError("The URL must be of scheme file");throw t.code="ERR_INVALID_URL_SCHEME",t}return v5(e)}function v5(e){if(e.hostname!==""){const o=new TypeError('File URL host must be "localhost" or empty on darwin');throw o.code="ERR_INVALID_FILE_URL_HOST",o}const t=e.pathname;let i=-1;for(;++i<t.length;)if(t.codePointAt(i)===37&&t.codePointAt(i+1)===50){const o=t.codePointAt(i+2);if(o===70||o===102){const l=new TypeError("File URL path must not include encoded / characters");throw l.code="ERR_INVALID_FILE_URL_PATH",l}}return decodeURIComponent(t)}const Hd=["history","path","basename","stem","extname","dirname"];class pb{constructor(t){let i;t?Pd(t)?i={path:t}:typeof t=="string"||x5(t)?i={value:t}:i=t:i={},this.cwd="cwd"in i?"":y5.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let o=-1;for(;++o<Hd.length;){const u=Hd[o];u in i&&i[u]!==void 0&&i[u]!==null&&(this[u]=u==="history"?[...i[u]]:i[u])}let l;for(l in i)Hd.includes(l)||(this[l]=i[l])}get basename(){return typeof this.path=="string"?Ir.basename(this.path):void 0}set basename(t){Vd(t,"basename"),qd(t,"basename"),this.path=Ir.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?Ir.dirname(this.path):void 0}set dirname(t){mb(this.basename,"dirname"),this.path=Ir.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?Ir.extname(this.path):void 0}set extname(t){if(qd(t,"extname"),mb(this.dirname,"extname"),t){if(t.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(t.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=Ir.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){Pd(t)&&(t=S5(t)),Vd(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?Ir.basename(this.path,this.extname):void 0}set stem(t){Vd(t,"stem"),qd(t,"stem"),this.path=Ir.join(this.dirname||"",t+(this.extname||""))}fail(t,i,o){const l=this.message(t,i,o);throw l.fatal=!0,l}info(t,i,o){const l=this.message(t,i,o);return l.fatal=void 0,l}message(t,i,o){const l=new bn(t,i,o);return this.path&&(l.name=this.path+":"+l.name,l.file=this.path),l.fatal=!1,this.messages.push(l),l}toString(t){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(t||void 0).decode(this.value)}}function qd(e,t){if(e&&e.includes(Ir.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+Ir.sep+"`")}function Vd(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function mb(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function x5(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const w5=(function(e){const o=this.constructor.prototype,l=o[e],u=function(){return l.apply(u,arguments)};return Object.setPrototypeOf(u,o),u}),C5={}.hasOwnProperty;class Fd extends w5{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=u5()}copy(){const t=new Fd;let i=-1;for(;++i<this.attachers.length;){const o=this.attachers[i];t.use(...o)}return t.data(Ld(!0,{},this.namespace)),t}data(t,i){return typeof t=="string"?arguments.length===2?(Xd("data",this.frozen),this.namespace[t]=i,this):C5.call(this.namespace,t)&&this.namespace[t]||void 0:t?(Xd("data",this.frozen),this.namespace=t,this):this.namespace}freeze(){if(this.frozen)return this;const t=this;for(;++this.freezeIndex<this.attachers.length;){const[i,...o]=this.attachers[this.freezeIndex];if(o[0]===!1)continue;o[0]===!0&&(o[0]=void 0);const l=i.call(t,...o);typeof l=="function"&&this.transformers.use(l)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(t){this.freeze();const i=Eu(t),o=this.parser||this.Parser;return Yd("parse",o),o(String(i),i)}process(t,i){const o=this;return this.freeze(),Yd("process",this.parser||this.Parser),Gd("process",this.compiler||this.Compiler),i?l(void 0,i):new Promise(l);function l(u,c){const d=Eu(t),m=o.parse(d);o.run(m,d,function(g,y,v){if(g||!y||!v)return p(g);const S=y,E=o.stringify(S,v);_5(E)?v.value=E:v.result=E,p(g,v)});function p(g,y){g||!y?c(g):u?u(y):i(void 0,y)}}}processSync(t){let i=!1,o;return this.freeze(),Yd("processSync",this.parser||this.Parser),Gd("processSync",this.compiler||this.Compiler),this.process(t,l),yb("processSync","process",i),o;function l(u,c){i=!0,db(u),o=c}}run(t,i,o){gb(t),this.freeze();const l=this.transformers;return!o&&typeof i=="function"&&(o=i,i=void 0),o?u(void 0,o):new Promise(u);function u(c,d){const m=Eu(i);l.run(t,m,p);function p(g,y,v){const S=y||t;g?d(g):c?c(S):o(void 0,S,v)}}}runSync(t,i){let o=!1,l;return this.run(t,i,u),yb("runSync","run",o),l;function u(c,d){db(c),l=d,o=!0}}stringify(t,i){this.freeze();const o=Eu(i),l=this.compiler||this.Compiler;return Gd("stringify",l),gb(t),l(t,o)}use(t,...i){const o=this.attachers,l=this.namespace;if(Xd("use",this.frozen),t!=null)if(typeof t=="function")m(t,i);else if(typeof t=="object")Array.isArray(t)?d(t):c(t);else throw new TypeError("Expected usable value, not `"+t+"`");return this;function u(p){if(typeof p=="function")m(p,[]);else if(typeof p=="object")if(Array.isArray(p)){const[g,...y]=p;m(g,y)}else c(p);else throw new TypeError("Expected usable value, not `"+p+"`")}function c(p){if(!("plugins"in p)&&!("settings"in p))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");d(p.plugins),p.settings&&(l.settings=Ld(!0,l.settings,p.settings))}function d(p){let g=-1;if(p!=null)if(Array.isArray(p))for(;++g<p.length;){const y=p[g];u(y)}else throw new TypeError("Expected a list of plugins, not `"+p+"`")}function m(p,g){let y=-1,v=-1;for(;++y<o.length;)if(o[y][0]===p){v=y;break}if(v===-1)o.push([p,...g]);else if(g.length>0){let[S,...E]=g;const w=o[v][1];jd(w)&&jd(S)&&(S=Ld(!0,w,S)),o[v]=[p,S,...E]}}}}const E5=new Fd().freeze();function Yd(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function Gd(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function Xd(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function gb(e){if(!jd(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function yb(e,t,i){if(!i)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function Eu(e){return T5(e)?e:new pb(e)}function T5(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function _5(e){return typeof e=="string"||A5(e)}function A5(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const k5="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",bb=[],Sb={allowDangerousHtml:!0},R5=/^(https?|ircs?|mailto|xmpp)$/i,O5=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function M5(e){const t=N5(e),i=z5(e);return B5(t.runSync(t.parse(i),i),e)}function N5(e){const t=e.rehypePlugins||bb,i=e.remarkPlugins||bb,o=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...Sb}:Sb;return E5().use(f3).use(i).use(a5,o).use(t)}function z5(e){const t=e.children||"",i=new pb;return typeof t=="string"&&(i.value=t),i}function B5(e,t){const i=t.allowedElements,o=t.allowElement,l=t.components,u=t.disallowedElements,c=t.skipHtml,d=t.unwrapDisallowed,m=t.urlTransform||D5;for(const g of O5)Object.hasOwn(t,g.from)&&(""+g.from+(g.to?"use `"+g.to+"` instead":"remove it")+k5+g.id,void 0);return ub(e,p),Jk(e,{Fragment:Y.Fragment,components:l,ignoreInvalidStyle:!0,jsx:Y.jsx,jsxs:Y.jsxs,passKeys:!0,passNode:!0});function p(g,y,v){if(g.type==="raw"&&v&&typeof y=="number")return c?v.children.splice(y,1):v.children[y]={type:"text",value:g.value},y;if(g.type==="element"){let S;for(S in Ed)if(Object.hasOwn(Ed,S)&&Object.hasOwn(g.properties,S)){const E=g.properties[S],w=Ed[S];(w===null||w.includes(g.tagName))&&(g.properties[S]=m(String(E||""),S,g))}}if(g.type==="element"){let S=i?!i.includes(g.tagName):u?u.includes(g.tagName):!1;if(!S&&o&&typeof y=="number"&&(S=!o(g,y,v)),S&&v&&typeof y=="number")return d&&g.children?v.children.splice(y,1,...g.children):v.children.splice(y,1),y}}}function D5(e){const t=e.indexOf(":"),i=e.indexOf("?"),o=e.indexOf("#"),l=e.indexOf("/");return t===-1||l!==-1&&t>l||i!==-1&&t>i||o!==-1&&t>o||R5.test(e.slice(0,t))?e:""}function I5(){if(typeof document>"u"||document.querySelector('meta[name="viewport"]'))return;const t=document.createElement("meta");t.name="viewport",t.content="width=device-width, initial-scale=1",document.head.appendChild(t)}function $5(){O.useEffect(()=>{const e=()=>{const t=window.innerHeight*.01;document.documentElement.style.setProperty("--vh",`${t}px`)};return e(),window.addEventListener("resize",e),window.addEventListener("orientationchange",e),()=>{window.removeEventListener("resize",e),window.removeEventListener("orientationchange",e)}},[])}function U5({open:e,setOpen:t,msgs:i,input:o,setInput:l,sending:u,send:c,anchorSx:d,conversationMode:m}){const p=O.useRef(null),g=O.useRef(null),y=al(),v=fk(y.breakpoints.down("md"));$5(),O.useEffect(()=>{g.current?.scrollIntoView({behavior:"smooth",block:"end"}),requestAnimationFrame(()=>p.current?.focus())},[i.length,u]),O.useEffect(()=>{e&&g.current?.scrollIntoView({behavior:"auto",block:"end"})},[e]),O.useEffect(()=>{if(!(e&&v))return;const w=window.scrollY;return document.body.style.position="fixed",document.body.style.top=`-${w}px`,document.body.style.left="0",document.body.style.right="0",document.body.style.width="100%",()=>{document.body.style.position="",document.body.style.top="",document.body.style.left="",document.body.style.right="",document.body.style.width="",window.scrollTo(0,w)}},[e,v]);const S=O.useCallback((w,R,k,I)=>{const M=w===k.length-1,_=k[k.length-1],z=M&&R&&_?.seen,T=z&&_?.id===I.id;return{showSeenIndicator:z,isSeen:T}},[]),E=w=>w==="AI"?"Răspunde automat":w==="Human"?"In conversatie cu un operator":w==="Disconnected"?"Conexiune pierduta. Reincarcati pagina!":w==="Ended"?"Conversație închisă":"Conversație nouă";return Y.jsxs(tn,{sx:d,children:[!e&&Y.jsx(b_,{variant:"contained",onClick:()=>t(!0),startIcon:Y.jsx(Ck,{}),sx:{borderRadius:999,px:2,py:1,textTransform:"none",boxShadow:"0 10px 30px rgba(0,0,0,.18)"},children:"Chat"}),e&&Y.jsx(yy,{elevation:v?0:10,sx:{width:v?"100vw":380,height:v?"calc(var(--vh, 1vh) * 100)":560,"@supports (height: 100dvh)":{height:v?"100dvh":560},maxWidth:"100vw",maxHeight:"100dvh",borderRadius:v?0:4,position:v?"fixed":"relative",inset:v?0:"auto",overflow:"hidden",border:v?"none":"1px solid",borderColor:"divider",boxShadow:v?"none":"0 18px 60px rgba(0,0,0,.28)"},children:Y.jsxs(tn,{sx:{display:"flex",flexDirection:"column",height:"100%"},children:[Y.jsxs(tn,{sx:{px:1.75,py:1.25,display:"flex",alignItems:"center",gap:1,borderBottom:"1px solid",borderColor:"divider",background:"linear-gradient(135deg, rgba(25,118,210,.18), rgba(156,39,176,.14))",backdropFilter:v?"none":"blur(10px)"},children:[Y.jsx(l_,{overlap:"circular",variant:"dot",color:m!="Disconnected"?"success":"error",sx:{"& .MuiBadge-badge":{width:10,height:10,borderRadius:999,border:"2px solid",borderColor:"background.paper"}},children:Y.jsx(su,{sx:{bgcolor:"primary.main"},children:Y.jsx(fd,{})})}),Y.jsxs(tn,{sx:{flex:1,minWidth:0},children:[Y.jsx(Lo,{variant:"subtitle1",sx:{fontWeight:700,lineHeight:1.1},children:"Asistent"}),Y.jsx(Lo,{variant:"caption",sx:{color:"text.secondary"},children:E(m)})]}),Y.jsx(xy,{size:"small",onClick:()=>t(!1),sx:{bgcolor:"rgba(255,255,255,.55)",border:"1px solid",borderColor:"divider","&:hover":{bgcolor:"rgba(255,255,255,.75)"}},children:Y.jsx(xk,{fontSize:"small"})})]}),Y.jsxs(tn,{sx:{flex:1,minHeight:0,overflow:"auto",px:1.5,pt:1.5,backgroundImage:"radial-gradient(circle at 20% 10%, rgba(25,118,210,.10), transparent 45%),radial-gradient(circle at 80% 20%, rgba(156,39,176,.10), transparent 50%),radial-gradient(circle at 40% 90%, rgba(0,200,83,.08), transparent 45%)","&::-webkit-scrollbar":{width:10},"&::-webkit-scrollbar-thumb":{backgroundColor:"rgba(0,0,0,.18)",borderRadius:999,border:"3px solid transparent",backgroundClip:"content-box"}},children:[Y.jsx(L5,{msgs:i,isMessageSeen:S}),Y.jsxs("div",{ref:g,style:{paddingBottom:2},children:[u&&Y.jsxs(tn,{sx:{display:"flex",alignItems:"flex-end",gap:1,mb:1.2},children:[Y.jsx(su,{sx:{width:30,height:30,bgcolor:"primary.main"},children:Y.jsx(fd,{sx:{fontSize:18}})}),Y.jsxs(tn,{sx:{px:1.4,py:1.1,borderRadius:3,border:"1px solid",borderColor:"divider",bgcolor:"background.paper",boxShadow:"0 10px 30px rgba(0,0,0,.10)",display:"flex",alignItems:"center",gap:.6},children:[Y.jsx(tn,{sx:{width:6,height:6,borderRadius:999,bgcolor:"text.secondary",animation:"dot 1.1s infinite ease-in-out","@keyframes dot":{"0%, 80%, 100%":{transform:"scale(0.6)",opacity:.4},"40%":{transform:"scale(1)",opacity:1}}}}),Y.jsx(tn,{sx:{width:6,height:6,borderRadius:999,bgcolor:"text.secondary",animation:"dot 1.1s infinite ease-in-out",animationDelay:"0.15s","@keyframes dot":{"0%, 80%, 100%":{transform:"scale(0.6)",opacity:.4},"40%":{transform:"scale(1)",opacity:1}}}}),Y.jsx(tn,{sx:{width:6,height:6,borderRadius:999,bgcolor:"text.secondary",animation:"dot 1.1s infinite ease-in-out",animationDelay:"0.3s","@keyframes dot":{"0%, 80%, 100%":{transform:"scale(0.6)",opacity:.4},"40%":{transform:"scale(1)",opacity:1}}}})]})]}),Y.jsx(SA,{href:"https://x-bot.ro",target:"_blank",rel:"noreferrer",underline:"none",sx:{fontSize:12,color:"text.secondary",opacity:.75,"&:hover":{opacity:1,color:"text.primary"},display:"flex",justifyContent:"center"},children:"Chat oferit de X-bot.ro"})]})]}),Y.jsx(tn,{sx:{p:1.25,borderTop:"1px solid",borderColor:"divider",display:"flex",gap:1,bgcolor:"background.paper",flexShrink:0},children:Y.jsx(ck,{inputRef:p,focused:!0,size:"small",fullWidth:!0,value:o,disabled:u||o.length>=dk,onChange:w=>l(w.target.value),onKeyDown:w=>{w.key==="Enter"&&!w.shiftKey&&(w.preventDefault(),c())},placeholder:"Scrie un mesaj",multiline:!0,maxRows:4,sx:{"& .MuiOutlinedInput-root":{borderRadius:3,pr:.75,backgroundColor:"rgba(0,0,0,.02)"}},InputProps:{endAdornment:Y.jsx(xy,{size:"small",onClick:c,disabled:u||!o.trim(),sx:{ml:.5,borderRadius:999},children:Y.jsx(wk,{})})}})})]})})]})}const L5=dr.memo(function({msgs:t,isMessageSeen:i,endRef:o}){return Y.jsxs(Y.Fragment,{children:[t.map((l,u)=>{const c=l.role==="User",{showSeenIndicator:d,isSeen:m}=i(u,c,t,l);return Y.jsxs(tn,{sx:{display:"flex",justifyContent:c?"flex-end":"flex-start",gap:1,mb:1.2,overflowAnchor:"none"},children:[!c&&Y.jsxs(tn,{children:[Y.jsx(su,{sx:{width:30,height:30,mt:.25,bgcolor:"primary.main"},children:Y.jsx(fd,{sx:{fontSize:18}})}),l.sentAt&&Y.jsx(tn,{sx:{display:"flex",justifyContent:c?"flex-end":"flex-start",mt:.5},children:Y.jsx(Lo,{variant:"caption",sx:{color:"text.secondary",fontSize:11},children:l.sentAt})})]},"asistent"+l.id),Y.jsxs(tn,{sx:{maxWidth:"78%"},children:[Y.jsx(tn,{sx:{wordBreak:"break-word",position:"relative",px:1.4,py:1.05,borderRadius:3,border:"1px solid",borderColor:"divider",bgcolor:c?"primary.main":"background.paper",color:c?"primary.contrastText":"text.primary",boxShadow:c?"0 10px 30px rgba(25,118,210,.22)":"0 10px 30px rgba(0,0,0,.10)",whiteSpace:"pre-wrap","&:before":{content:'""',position:"absolute",top:14,width:10,height:10,transform:"rotate(45deg)",bgcolor:c?"primary.main":"background.paper",borderLeft:c?"none":"1px solid",borderTop:c?"none":"1px solid",borderColor:"divider",right:c?-5:"auto",left:c?"auto":-5},"& p":{margin:0},"& a":{color:"inherit",textDecoration:"underline"},"& code":{fontFamily:"ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace",fontSize:"0.9em",padding:"2px 6px",borderRadius:8,backgroundColor:c?"rgba(255,255,255,.14)":"rgba(0,0,0,.06)"},"& pre":{margin:0,marginTop:8,padding:12,overflow:"auto",borderRadius:12,backgroundColor:c?"rgba(255,255,255,.12)":"rgba(0,0,0,.05)"}},children:Y.jsx(M5,{children:l.text},"message"+l.id)}),d?Y.jsx(Lo,{sx:{mt:.35,fontSize:12,textAlign:"right",color:m?"text.secondary":"text.disabled"},children:m?"Seen":"Sent"}):null]},"container"+l.id),Y.jsx(tn,{children:c&&Y.jsxs(tn,{children:[Y.jsx(su,{sx:{width:30,height:30,mt:.25,bgcolor:"grey.900"},children:Y.jsx(Ek,{sx:{fontSize:18}})}),l.sentAt&&Y.jsx(tn,{sx:{display:"flex",justifyContent:c?"flex-end":"flex-start",mt:.5},children:Y.jsx(Lo,{variant:"caption",sx:{color:"text.secondary",fontSize:11},children:l.sentAt})})]},"sentad"+l.id)})]},l.id)}),Y.jsx("div",{ref:o})]})});class ro extends Error{constructor(t,i){const o=new.target.prototype;super(`${t}: Status code '${i}'`),this.statusCode=i,this.__proto__=o}}class Kd extends Error{constructor(t="A timeout occurred."){const i=new.target.prototype;super(t),this.__proto__=i}}class br extends Error{constructor(t="An abort occurred."){const i=new.target.prototype;super(t),this.__proto__=i}}class j5 extends Error{constructor(t,i){const o=new.target.prototype;super(t),this.transport=i,this.errorType="UnsupportedTransportError",this.__proto__=o}}class P5 extends Error{constructor(t,i){const o=new.target.prototype;super(t),this.transport=i,this.errorType="DisabledTransportError",this.__proto__=o}}class H5 extends Error{constructor(t,i){const o=new.target.prototype;super(t),this.transport=i,this.errorType="FailedToStartTransportError",this.__proto__=o}}class vb extends Error{constructor(t){const i=new.target.prototype;super(t),this.errorType="FailedToNegotiateWithServerError",this.__proto__=i}}class q5 extends Error{constructor(t,i){const o=new.target.prototype;super(t),this.innerErrors=i,this.__proto__=o}}class xb{constructor(t,i,o){this.statusCode=t,this.statusText=i,this.content=o}}class Tu{get(t,i){return this.send({...i,method:"GET",url:t})}post(t,i){return this.send({...i,method:"POST",url:t})}delete(t,i){return this.send({...i,method:"DELETE",url:t})}getCookieString(t){return""}}var ae;(function(e){e[e.Trace=0]="Trace",e[e.Debug=1]="Debug",e[e.Information=2]="Information",e[e.Warning=3]="Warning",e[e.Error=4]="Error",e[e.Critical=5]="Critical",e[e.None=6]="None"})(ae||(ae={}));class _l{constructor(){}log(t,i){}}_l.instance=new _l;const V5="10.0.0";class Kt{static isRequired(t,i){if(t==null)throw new Error(`The '${i}' argument is required.`)}static isNotEmpty(t,i){if(!t||t.match(/^\s*$/))throw new Error(`The '${i}' argument should not be empty.`)}static isIn(t,i,o){if(!(t in i))throw new Error(`Unknown ${o} value: ${t}.`)}}class Mt{static get isBrowser(){return!Mt.isNode&&typeof window=="object"&&typeof window.document=="object"}static get isWebWorker(){return!Mt.isNode&&typeof self=="object"&&"importScripts"in self}static get isReactNative(){return!Mt.isNode&&typeof window=="object"&&typeof window.document>"u"}static get isNode(){return typeof process<"u"&&process.release&&process.release.name==="node"}}function Al(e,t){let i="";return io(e)?(i=`Binary data of length ${e.byteLength}`,t&&(i+=`. Content: '${F5(e)}'`)):typeof e=="string"&&(i=`String data of length ${e.length}`,t&&(i+=`. Content: '${e}'`)),i}function F5(e){const t=new Uint8Array(e);let i="";return t.forEach(o=>{const l=o<16?"0":"";i+=`0x${l}${o.toString(16)} `}),i.substring(0,i.length-1)}function io(e){return e&&typeof ArrayBuffer<"u"&&(e instanceof ArrayBuffer||e.constructor&&e.constructor.name==="ArrayBuffer")}async function wb(e,t,i,o,l,u){const c={},[d,m]=Ko();c[d]=m,e.log(ae.Trace,`(${t} transport) sending data. ${Al(l,u.logMessageContent)}.`);const p=io(l)?"arraybuffer":"text",g=await i.post(o,{content:l,headers:{...c,...u.headers},responseType:p,timeout:u.timeout,withCredentials:u.withCredentials});e.log(ae.Trace,`(${t} transport) request complete. Response status: ${g.statusCode}.`)}function Y5(e){return e===void 0?new _u(ae.Information):e===null?_l.instance:e.log!==void 0?e:new _u(e)}class G5{constructor(t,i){this._subject=t,this._observer=i}dispose(){const t=this._subject.observers.indexOf(this._observer);t>-1&&this._subject.observers.splice(t,1),this._subject.observers.length===0&&this._subject.cancelCallback&&this._subject.cancelCallback().catch(i=>{})}}class _u{constructor(t){this._minLevel=t,this.out=console}log(t,i){if(t>=this._minLevel){const o=`[${new Date().toISOString()}] ${ae[t]}: ${i}`;switch(t){case ae.Critical:case ae.Error:this.out.error(o);break;case ae.Warning:this.out.warn(o);break;case ae.Information:this.out.info(o);break;default:this.out.log(o);break}}}}function Ko(){let e="X-SignalR-User-Agent";return Mt.isNode&&(e="User-Agent"),[e,X5(V5,K5(),Z5(),Q5())]}function X5(e,t,i,o){let l="Microsoft SignalR/";const u=e.split(".");return l+=`${u[0]}.${u[1]}`,l+=` (${e}; `,t&&t!==""?l+=`${t}; `:l+="Unknown OS; ",l+=`${i}`,o?l+=`; ${o}`:l+="; Unknown Runtime Version",l+=")",l}function K5(){if(Mt.isNode)switch(process.platform){case"win32":return"Windows NT";case"darwin":return"macOS";case"linux":return"Linux";default:return process.platform}else return""}function Q5(){if(Mt.isNode)return process.versions.node}function Z5(){return Mt.isNode?"NodeJS":"Browser"}function Qd(e){return e.stack?e.stack:e.message?e.message:`${e}`}function W5(){if(typeof globalThis<"u")return globalThis;if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof global<"u")return global;throw new Error("could not find global")}class J5 extends Tu{constructor(t){if(super(),this._logger=t,typeof fetch>"u"||Mt.isNode){const i=typeof __webpack_require__=="function"?__non_webpack_require__:require;this._jar=new(i("tough-cookie")).CookieJar,typeof fetch>"u"?this._fetchType=i("node-fetch"):this._fetchType=fetch,this._fetchType=i("fetch-cookie")(this._fetchType,this._jar)}else this._fetchType=fetch.bind(W5());if(typeof AbortController>"u"){const i=typeof __webpack_require__=="function"?__non_webpack_require__:require;this._abortControllerType=i("abort-controller")}else this._abortControllerType=AbortController}async send(t){if(t.abortSignal&&t.abortSignal.aborted)throw new br;if(!t.method)throw new Error("No method defined.");if(!t.url)throw new Error("No url defined.");const i=new this._abortControllerType;let o;t.abortSignal&&(t.abortSignal.onabort=()=>{i.abort(),o=new br});let l=null;if(t.timeout){const m=t.timeout;l=setTimeout(()=>{i.abort(),this._logger.log(ae.Warning,"Timeout from HTTP request."),o=new Kd},m)}t.content===""&&(t.content=void 0),t.content&&(t.headers=t.headers||{},io(t.content)?t.headers["Content-Type"]="application/octet-stream":t.headers["Content-Type"]="text/plain;charset=UTF-8");let u;try{u=await this._fetchType(t.url,{body:t.content,cache:"no-cache",credentials:t.withCredentials===!0?"include":"same-origin",headers:{"X-Requested-With":"XMLHttpRequest",...t.headers},method:t.method,mode:"cors",redirect:"follow",signal:i.signal})}catch(m){throw o||(this._logger.log(ae.Warning,`Error from HTTP request. ${m}.`),m)}finally{l&&clearTimeout(l),t.abortSignal&&(t.abortSignal.onabort=null)}if(!u.ok){const m=await Cb(u,"text");throw new ro(m||u.statusText,u.status)}const d=await Cb(u,t.responseType);return new xb(u.status,u.statusText,d)}getCookieString(t){let i="";return Mt.isNode&&this._jar&&this._jar.getCookies(t,(o,l)=>i=l.join("; ")),i}}function Cb(e,t){let i;switch(t){case"arraybuffer":i=e.arrayBuffer();break;case"text":i=e.text();break;case"blob":case"document":case"json":throw new Error(`${t} is not supported.`);default:i=e.text();break}return i}class eM extends Tu{constructor(t){super(),this._logger=t}send(t){return t.abortSignal&&t.abortSignal.aborted?Promise.reject(new br):t.method?t.url?new Promise((i,o)=>{const l=new XMLHttpRequest;l.open(t.method,t.url,!0),l.withCredentials=t.withCredentials===void 0?!0:t.withCredentials,l.setRequestHeader("X-Requested-With","XMLHttpRequest"),t.content===""&&(t.content=void 0),t.content&&(io(t.content)?l.setRequestHeader("Content-Type","application/octet-stream"):l.setRequestHeader("Content-Type","text/plain;charset=UTF-8"));const u=t.headers;u&&Object.keys(u).forEach(c=>{l.setRequestHeader(c,u[c])}),t.responseType&&(l.responseType=t.responseType),t.abortSignal&&(t.abortSignal.onabort=()=>{l.abort(),o(new br)}),t.timeout&&(l.timeout=t.timeout),l.onload=()=>{t.abortSignal&&(t.abortSignal.onabort=null),l.status>=200&&l.status<300?i(new xb(l.status,l.statusText,l.response||l.responseText)):o(new ro(l.response||l.responseText||l.statusText,l.status))},l.onerror=()=>{this._logger.log(ae.Warning,`Error from HTTP request. ${l.status}: ${l.statusText}.`),o(new ro(l.statusText,l.status))},l.ontimeout=()=>{this._logger.log(ae.Warning,"Timeout from HTTP request."),o(new Kd)},l.send(t.content)}):Promise.reject(new Error("No url defined.")):Promise.reject(new Error("No method defined."))}}class tM extends Tu{constructor(t){if(super(),typeof fetch<"u"||Mt.isNode)this._httpClient=new J5(t);else if(typeof XMLHttpRequest<"u")this._httpClient=new eM(t);else throw new Error("No usable HttpClient found.")}send(t){return t.abortSignal&&t.abortSignal.aborted?Promise.reject(new br):t.method?t.url?this._httpClient.send(t):Promise.reject(new Error("No url defined.")):Promise.reject(new Error("No method defined."))}getCookieString(t){return this._httpClient.getCookieString(t)}}class Ln{static write(t){return`${t}${Ln.RecordSeparator}`}static parse(t){if(t[t.length-1]!==Ln.RecordSeparator)throw new Error("Message is incomplete.");const i=t.split(Ln.RecordSeparator);return i.pop(),i}}Ln.RecordSeparatorCode=30,Ln.RecordSeparator=String.fromCharCode(Ln.RecordSeparatorCode);class nM{writeHandshakeRequest(t){return Ln.write(JSON.stringify(t))}parseHandshakeResponse(t){let i,o;if(io(t)){const d=new Uint8Array(t),m=d.indexOf(Ln.RecordSeparatorCode);if(m===-1)throw new Error("Message is incomplete.");const p=m+1;i=String.fromCharCode.apply(null,Array.prototype.slice.call(d.slice(0,p))),o=d.byteLength>p?d.slice(p).buffer:null}else{const d=t,m=d.indexOf(Ln.RecordSeparator);if(m===-1)throw new Error("Message is incomplete.");const p=m+1;i=d.substring(0,p),o=d.length>p?d.substring(p):null}const l=Ln.parse(i),u=JSON.parse(l[0]);if(u.type)throw new Error("Expected a handshake response from the server.");return[o,u]}}var Be;(function(e){e[e.Invocation=1]="Invocation",e[e.StreamItem=2]="StreamItem",e[e.Completion=3]="Completion",e[e.StreamInvocation=4]="StreamInvocation",e[e.CancelInvocation=5]="CancelInvocation",e[e.Ping=6]="Ping",e[e.Close=7]="Close",e[e.Ack=8]="Ack",e[e.Sequence=9]="Sequence"})(Be||(Be={}));class rM{constructor(){this.observers=[]}next(t){for(const i of this.observers)i.next(t)}error(t){for(const i of this.observers)i.error&&i.error(t)}complete(){for(const t of this.observers)t.complete&&t.complete()}subscribe(t){return this.observers.push(t),new G5(this,t)}}class iM{constructor(t,i,o){this._bufferSize=1e5,this._messages=[],this._totalMessageCount=0,this._waitForSequenceMessage=!1,this._nextReceivingSequenceId=1,this._latestReceivedSequenceId=0,this._bufferedByteCount=0,this._reconnectInProgress=!1,this._protocol=t,this._connection=i,this._bufferSize=o}async _send(t){const i=this._protocol.writeMessage(t);let o=Promise.resolve();if(this._isInvocationMessage(t)){this._totalMessageCount++;let l=()=>{},u=()=>{};io(i)?this._bufferedByteCount+=i.byteLength:this._bufferedByteCount+=i.length,this._bufferedByteCount>=this._bufferSize&&(o=new Promise((c,d)=>{l=c,u=d})),this._messages.push(new oM(i,this._totalMessageCount,l,u))}try{this._reconnectInProgress||await this._connection.send(i)}catch{this._disconnected()}await o}_ack(t){let i=-1;for(let o=0;o<this._messages.length;o++){const l=this._messages[o];if(l._id<=t.sequenceId)i=o,io(l._message)?this._bufferedByteCount-=l._message.byteLength:this._bufferedByteCount-=l._message.length,l._resolver();else if(this._bufferedByteCount<this._bufferSize)l._resolver();else break}i!==-1&&(this._messages=this._messages.slice(i+1))}_shouldProcessMessage(t){if(this._waitForSequenceMessage)return t.type!==Be.Sequence?!1:(this._waitForSequenceMessage=!1,!0);if(!this._isInvocationMessage(t))return!0;const i=this._nextReceivingSequenceId;return this._nextReceivingSequenceId++,i<=this._latestReceivedSequenceId?(i===this._latestReceivedSequenceId&&this._ackTimer(),!1):(this._latestReceivedSequenceId=i,this._ackTimer(),!0)}_resetSequence(t){if(t.sequenceId>this._nextReceivingSequenceId){this._connection.stop(new Error("Sequence ID greater than amount of messages we've received."));return}this._nextReceivingSequenceId=t.sequenceId}_disconnected(){this._reconnectInProgress=!0,this._waitForSequenceMessage=!0}async _resend(){const t=this._messages.length!==0?this._messages[0]._id:this._totalMessageCount+1;await this._connection.send(this._protocol.writeMessage({type:Be.Sequence,sequenceId:t}));const i=this._messages;for(const o of i)await this._connection.send(o._message);this._reconnectInProgress=!1}_dispose(t){t??(t=new Error("Unable to reconnect to server."));for(const i of this._messages)i._rejector(t)}_isInvocationMessage(t){switch(t.type){case Be.Invocation:case Be.StreamItem:case Be.Completion:case Be.StreamInvocation:case Be.CancelInvocation:return!0;case Be.Close:case Be.Sequence:case Be.Ping:case Be.Ack:return!1}}_ackTimer(){this._ackTimerHandle===void 0&&(this._ackTimerHandle=setTimeout(async()=>{try{this._reconnectInProgress||await this._connection.send(this._protocol.writeMessage({type:Be.Ack,sequenceId:this._latestReceivedSequenceId}))}catch{}clearTimeout(this._ackTimerHandle),this._ackTimerHandle=void 0},1e3))}}class oM{constructor(t,i,o,l){this._message=t,this._id=i,this._resolver=o,this._rejector=l}}const aM=30*1e3,lM=15*1e3,sM=1e5;var ut;(function(e){e.Disconnected="Disconnected",e.Connecting="Connecting",e.Connected="Connected",e.Disconnecting="Disconnecting",e.Reconnecting="Reconnecting"})(ut||(ut={}));class Zd{static create(t,i,o,l,u,c,d){return new Zd(t,i,o,l,u,c,d)}constructor(t,i,o,l,u,c,d){this._nextKeepAlive=0,this._freezeEventListener=()=>{this._logger.log(ae.Warning,"The page is being frozen, this will likely lead to the connection being closed and messages being lost. For more information see the docs at https://learn.microsoft.com/aspnet/core/signalr/javascript-client#bsleep")},Kt.isRequired(t,"connection"),Kt.isRequired(i,"logger"),Kt.isRequired(o,"protocol"),this.serverTimeoutInMilliseconds=u??aM,this.keepAliveIntervalInMilliseconds=c??lM,this._statefulReconnectBufferSize=d??sM,this._logger=i,this._protocol=o,this.connection=t,this._reconnectPolicy=l,this._handshakeProtocol=new nM,this.connection.onreceive=m=>this._processIncomingData(m),this.connection.onclose=m=>this._connectionClosed(m),this._callbacks={},this._methods={},this._closedCallbacks=[],this._reconnectingCallbacks=[],this._reconnectedCallbacks=[],this._invocationId=0,this._receivedHandshakeResponse=!1,this._connectionState=ut.Disconnected,this._connectionStarted=!1,this._cachedPingMessage=this._protocol.writeMessage({type:Be.Ping})}get state(){return this._connectionState}get connectionId(){return this.connection&&this.connection.connectionId||null}get baseUrl(){return this.connection.baseUrl||""}set baseUrl(t){if(this._connectionState!==ut.Disconnected&&this._connectionState!==ut.Reconnecting)throw new Error("The HubConnection must be in the Disconnected or Reconnecting state to change the url.");if(!t)throw new Error("The HubConnection url must be a valid url.");this.connection.baseUrl=t}start(){return this._startPromise=this._startWithStateTransitions(),this._startPromise}async _startWithStateTransitions(){if(this._connectionState!==ut.Disconnected)return Promise.reject(new Error("Cannot start a HubConnection that is not in the 'Disconnected' state."));this._connectionState=ut.Connecting,this._logger.log(ae.Debug,"Starting HubConnection.");try{await this._startInternal(),Mt.isBrowser&&window.document.addEventListener("freeze",this._freezeEventListener),this._connectionState=ut.Connected,this._connectionStarted=!0,this._logger.log(ae.Debug,"HubConnection connected successfully.")}catch(t){return this._connectionState=ut.Disconnected,this._logger.log(ae.Debug,`HubConnection failed to start successfully because of error '${t}'.`),Promise.reject(t)}}async _startInternal(){this._stopDuringStartError=void 0,this._receivedHandshakeResponse=!1;const t=new Promise((i,o)=>{this._handshakeResolver=i,this._handshakeRejecter=o});await this.connection.start(this._protocol.transferFormat);try{let i=this._protocol.version;this.connection.features.reconnect||(i=1);const o={protocol:this._protocol.name,version:i};if(this._logger.log(ae.Debug,"Sending handshake request."),await this._sendMessage(this._handshakeProtocol.writeHandshakeRequest(o)),this._logger.log(ae.Information,`Using HubProtocol '${this._protocol.name}'.`),this._cleanupTimeout(),this._resetTimeoutPeriod(),this._resetKeepAliveInterval(),await t,this._stopDuringStartError)throw this._stopDuringStartError;(this.connection.features.reconnect||!1)&&(this._messageBuffer=new iM(this._protocol,this.connection,this._statefulReconnectBufferSize),this.connection.features.disconnected=this._messageBuffer._disconnected.bind(this._messageBuffer),this.connection.features.resend=()=>{if(this._messageBuffer)return this._messageBuffer._resend()}),this.connection.features.inherentKeepAlive||await this._sendMessage(this._cachedPingMessage)}catch(i){throw this._logger.log(ae.Debug,`Hub handshake failed with error '${i}' during start(). Stopping HubConnection.`),this._cleanupTimeout(),this._cleanupPingTimer(),await this.connection.stop(i),i}}async stop(){const t=this._startPromise;this.connection.features.reconnect=!1,this._stopPromise=this._stopInternal(),await this._stopPromise;try{await t}catch{}}_stopInternal(t){if(this._connectionState===ut.Disconnected)return this._logger.log(ae.Debug,`Call to HubConnection.stop(${t}) ignored because it is already in the disconnected state.`),Promise.resolve();if(this._connectionState===ut.Disconnecting)return this._logger.log(ae.Debug,`Call to HttpConnection.stop(${t}) ignored because the connection is already in the disconnecting state.`),this._stopPromise;const i=this._connectionState;return this._connectionState=ut.Disconnecting,this._logger.log(ae.Debug,"Stopping HubConnection."),this._reconnectDelayHandle?(this._logger.log(ae.Debug,"Connection stopped during reconnect delay. Done reconnecting."),clearTimeout(this._reconnectDelayHandle),this._reconnectDelayHandle=void 0,this._completeClose(),Promise.resolve()):(i===ut.Connected&&this._sendCloseMessage(),this._cleanupTimeout(),this._cleanupPingTimer(),this._stopDuringStartError=t||new br("The connection was stopped before the hub handshake could complete."),this.connection.stop(t))}async _sendCloseMessage(){try{await this._sendWithProtocol(this._createCloseMessage())}catch{}}stream(t,...i){const[o,l]=this._replaceStreamingParams(i),u=this._createStreamInvocation(t,i,l);let c;const d=new rM;return d.cancelCallback=()=>{const m=this._createCancelInvocation(u.invocationId);return delete this._callbacks[u.invocationId],c.then(()=>this._sendWithProtocol(m))},this._callbacks[u.invocationId]=(m,p)=>{if(p){d.error(p);return}else m&&(m.type===Be.Completion?m.error?d.error(new Error(m.error)):d.complete():d.next(m.item))},c=this._sendWithProtocol(u).catch(m=>{d.error(m),delete this._callbacks[u.invocationId]}),this._launchStreams(o,c),d}_sendMessage(t){return this._resetKeepAliveInterval(),this.connection.send(t)}_sendWithProtocol(t){return this._messageBuffer?this._messageBuffer._send(t):this._sendMessage(this._protocol.writeMessage(t))}send(t,...i){const[o,l]=this._replaceStreamingParams(i),u=this._sendWithProtocol(this._createInvocation(t,i,!0,l));return this._launchStreams(o,u),u}invoke(t,...i){const[o,l]=this._replaceStreamingParams(i),u=this._createInvocation(t,i,!1,l);return new Promise((d,m)=>{this._callbacks[u.invocationId]=(g,y)=>{if(y){m(y);return}else g&&(g.type===Be.Completion?g.error?m(new Error(g.error)):d(g.result):m(new Error(`Unexpected message type: ${g.type}`)))};const p=this._sendWithProtocol(u).catch(g=>{m(g),delete this._callbacks[u.invocationId]});this._launchStreams(o,p)})}on(t,i){!t||!i||(t=t.toLowerCase(),this._methods[t]||(this._methods[t]=[]),this._methods[t].indexOf(i)===-1&&this._methods[t].push(i))}off(t,i){if(!t)return;t=t.toLowerCase();const o=this._methods[t];if(o)if(i){const l=o.indexOf(i);l!==-1&&(o.splice(l,1),o.length===0&&delete this._methods[t])}else delete this._methods[t]}onclose(t){t&&this._closedCallbacks.push(t)}onreconnecting(t){t&&this._reconnectingCallbacks.push(t)}onreconnected(t){t&&this._reconnectedCallbacks.push(t)}_processIncomingData(t){if(this._cleanupTimeout(),this._receivedHandshakeResponse||(t=this._processHandshakeResponse(t),this._receivedHandshakeResponse=!0),t){const i=this._protocol.parseMessages(t,this._logger);for(const o of i)if(!(this._messageBuffer&&!this._messageBuffer._shouldProcessMessage(o)))switch(o.type){case Be.Invocation:this._invokeClientMethod(o).catch(l=>{this._logger.log(ae.Error,`Invoke client method threw error: ${Qd(l)}`)});break;case Be.StreamItem:case Be.Completion:{const l=this._callbacks[o.invocationId];if(l){o.type===Be.Completion&&delete this._callbacks[o.invocationId];try{l(o)}catch(u){this._logger.log(ae.Error,`Stream callback threw error: ${Qd(u)}`)}}break}case Be.Ping:break;case Be.Close:{this._logger.log(ae.Information,"Close message received from server.");const l=o.error?new Error("Server returned an error on close: "+o.error):void 0;o.allowReconnect===!0?this.connection.stop(l):this._stopPromise=this._stopInternal(l);break}case Be.Ack:this._messageBuffer&&this._messageBuffer._ack(o);break;case Be.Sequence:this._messageBuffer&&this._messageBuffer._resetSequence(o);break;default:this._logger.log(ae.Warning,`Invalid message type: ${o.type}.`);break}}this._resetTimeoutPeriod()}_processHandshakeResponse(t){let i,o;try{[o,i]=this._handshakeProtocol.parseHandshakeResponse(t)}catch(l){const u="Error parsing handshake response: "+l;this._logger.log(ae.Error,u);const c=new Error(u);throw this._handshakeRejecter(c),c}if(i.error){const l="Server returned handshake error: "+i.error;this._logger.log(ae.Error,l);const u=new Error(l);throw this._handshakeRejecter(u),u}else this._logger.log(ae.Debug,"Server handshake complete.");return this._handshakeResolver(),o}_resetKeepAliveInterval(){this.connection.features.inherentKeepAlive||(this._nextKeepAlive=new Date().getTime()+this.keepAliveIntervalInMilliseconds,this._cleanupPingTimer())}_resetTimeoutPeriod(){if(!this.connection.features||!this.connection.features.inherentKeepAlive){this._timeoutHandle=setTimeout(()=>this.serverTimeout(),this.serverTimeoutInMilliseconds);let t=this._nextKeepAlive-new Date().getTime();if(t<0){this._connectionState===ut.Connected&&this._trySendPingMessage();return}this._pingServerHandle===void 0&&(t<0&&(t=0),this._pingServerHandle=setTimeout(async()=>{this._connectionState===ut.Connected&&await this._trySendPingMessage()},t))}}serverTimeout(){this.connection.stop(new Error("Server timeout elapsed without receiving a message from the server."))}async _invokeClientMethod(t){const i=t.target.toLowerCase(),o=this._methods[i];if(!o){this._logger.log(ae.Warning,`No client method with the name '${i}' found.`),t.invocationId&&(this._logger.log(ae.Warning,`No result given for '${i}' method and invocation ID '${t.invocationId}'.`),await this._sendWithProtocol(this._createCompletionMessage(t.invocationId,"Client didn't provide a result.",null)));return}const l=o.slice(),u=!!t.invocationId;let c,d,m;for(const p of l)try{const g=c;c=await p.apply(this,t.arguments),u&&c&&g&&(this._logger.log(ae.Error,`Multiple results provided for '${i}'. Sending error to server.`),m=this._createCompletionMessage(t.invocationId,"Client provided multiple results.",null)),d=void 0}catch(g){d=g,this._logger.log(ae.Error,`A callback for the method '${i}' threw error '${g}'.`)}m?await this._sendWithProtocol(m):u?(d?m=this._createCompletionMessage(t.invocationId,`${d}`,null):c!==void 0?m=this._createCompletionMessage(t.invocationId,null,c):(this._logger.log(ae.Warning,`No result given for '${i}' method and invocation ID '${t.invocationId}'.`),m=this._createCompletionMessage(t.invocationId,"Client didn't provide a result.",null)),await this._sendWithProtocol(m)):c&&this._logger.log(ae.Error,`Result given for '${i}' method but server is not expecting a result.`)}_connectionClosed(t){this._logger.log(ae.Debug,`HubConnection.connectionClosed(${t}) called while in state ${this._connectionState}.`),this._stopDuringStartError=this._stopDuringStartError||t||new br("The underlying connection was closed before the hub handshake could complete."),this._handshakeResolver&&this._handshakeResolver(),this._cancelCallbacksWithError(t||new Error("Invocation canceled due to the underlying connection being closed.")),this._cleanupTimeout(),this._cleanupPingTimer(),this._connectionState===ut.Disconnecting?this._completeClose(t):this._connectionState===ut.Connected&&this._reconnectPolicy?this._reconnect(t):this._connectionState===ut.Connected&&this._completeClose(t)}_completeClose(t){if(this._connectionStarted){this._connectionState=ut.Disconnected,this._connectionStarted=!1,this._messageBuffer&&(this._messageBuffer._dispose(t??new Error("Connection closed.")),this._messageBuffer=void 0),Mt.isBrowser&&window.document.removeEventListener("freeze",this._freezeEventListener);try{this._closedCallbacks.forEach(i=>i.apply(this,[t]))}catch(i){this._logger.log(ae.Error,`An onclose callback called with error '${t}' threw error '${i}'.`)}}}async _reconnect(t){const i=Date.now();let o=0,l=t!==void 0?t:new Error("Attempting to reconnect due to a unknown error."),u=this._getNextRetryDelay(o,0,l);if(u===null){this._logger.log(ae.Debug,"Connection not reconnecting because the IRetryPolicy returned null on the first reconnect attempt."),this._completeClose(t);return}if(this._connectionState=ut.Reconnecting,t?this._logger.log(ae.Information,`Connection reconnecting because of error '${t}'.`):this._logger.log(ae.Information,"Connection reconnecting."),this._reconnectingCallbacks.length!==0){try{this._reconnectingCallbacks.forEach(c=>c.apply(this,[t]))}catch(c){this._logger.log(ae.Error,`An onreconnecting callback called with error '${t}' threw error '${c}'.`)}if(this._connectionState!==ut.Reconnecting){this._logger.log(ae.Debug,"Connection left the reconnecting state in onreconnecting callback. Done reconnecting.");return}}for(;u!==null;){if(this._logger.log(ae.Information,`Reconnect attempt number ${o+1} will start in ${u} ms.`),await new Promise(c=>{this._reconnectDelayHandle=setTimeout(c,u)}),this._reconnectDelayHandle=void 0,this._connectionState!==ut.Reconnecting){this._logger.log(ae.Debug,"Connection left the reconnecting state during reconnect delay. Done reconnecting.");return}try{if(await this._startInternal(),this._connectionState=ut.Connected,this._logger.log(ae.Information,"HubConnection reconnected successfully."),this._reconnectedCallbacks.length!==0)try{this._reconnectedCallbacks.forEach(c=>c.apply(this,[this.connection.connectionId]))}catch(c){this._logger.log(ae.Error,`An onreconnected callback called with connectionId '${this.connection.connectionId}; threw error '${c}'.`)}return}catch(c){if(this._logger.log(ae.Information,`Reconnect attempt failed because of error '${c}'.`),this._connectionState!==ut.Reconnecting){this._logger.log(ae.Debug,`Connection moved to the '${this._connectionState}' from the reconnecting state during reconnect attempt. Done reconnecting.`),this._connectionState===ut.Disconnecting&&this._completeClose();return}o++,l=c instanceof Error?c:new Error(c.toString()),u=this._getNextRetryDelay(o,Date.now()-i,l)}}this._logger.log(ae.Information,`Reconnect retries have been exhausted after ${Date.now()-i} ms and ${o} failed attempts. Connection disconnecting.`),this._completeClose()}_getNextRetryDelay(t,i,o){try{return this._reconnectPolicy.nextRetryDelayInMilliseconds({elapsedMilliseconds:i,previousRetryCount:t,retryReason:o})}catch(l){return this._logger.log(ae.Error,`IRetryPolicy.nextRetryDelayInMilliseconds(${t}, ${i}) threw error '${l}'.`),null}}_cancelCallbacksWithError(t){const i=this._callbacks;this._callbacks={},Object.keys(i).forEach(o=>{const l=i[o];try{l(null,t)}catch(u){this._logger.log(ae.Error,`Stream 'error' callback called with '${t}' threw error: ${Qd(u)}`)}})}_cleanupPingTimer(){this._pingServerHandle&&(clearTimeout(this._pingServerHandle),this._pingServerHandle=void 0)}_cleanupTimeout(){this._timeoutHandle&&clearTimeout(this._timeoutHandle)}_createInvocation(t,i,o,l){if(o)return l.length!==0?{target:t,arguments:i,streamIds:l,type:Be.Invocation}:{target:t,arguments:i,type:Be.Invocation};{const u=this._invocationId;return this._invocationId++,l.length!==0?{target:t,arguments:i,invocationId:u.toString(),streamIds:l,type:Be.Invocation}:{target:t,arguments:i,invocationId:u.toString(),type:Be.Invocation}}}_launchStreams(t,i){if(t.length!==0){i||(i=Promise.resolve());for(const o in t)t[o].subscribe({complete:()=>{i=i.then(()=>this._sendWithProtocol(this._createCompletionMessage(o)))},error:l=>{let u;l instanceof Error?u=l.message:l&&l.toString?u=l.toString():u="Unknown error",i=i.then(()=>this._sendWithProtocol(this._createCompletionMessage(o,u)))},next:l=>{i=i.then(()=>this._sendWithProtocol(this._createStreamItemMessage(o,l)))}})}}_replaceStreamingParams(t){const i=[],o=[];for(let l=0;l<t.length;l++){const u=t[l];if(this._isObservable(u)){const c=this._invocationId;this._invocationId++,i[c]=u,o.push(c.toString()),t.splice(l,1)}}return[i,o]}_isObservable(t){return t&&t.subscribe&&typeof t.subscribe=="function"}_createStreamInvocation(t,i,o){const l=this._invocationId;return this._invocationId++,o.length!==0?{target:t,arguments:i,invocationId:l.toString(),streamIds:o,type:Be.StreamInvocation}:{target:t,arguments:i,invocationId:l.toString(),type:Be.StreamInvocation}}_createCancelInvocation(t){return{invocationId:t,type:Be.CancelInvocation}}_createStreamItemMessage(t,i){return{invocationId:t,item:i,type:Be.StreamItem}}_createCompletionMessage(t,i,o){return i?{error:i,invocationId:t,type:Be.Completion}:{invocationId:t,result:o,type:Be.Completion}}_createCloseMessage(){return{type:Be.Close}}async _trySendPingMessage(){try{await this._sendMessage(this._cachedPingMessage)}catch{this._cleanupPingTimer()}}}const uM=[0,2e3,1e4,3e4,null];class Eb{constructor(t){this._retryDelays=t!==void 0?[...t,null]:uM}nextRetryDelayInMilliseconds(t){return this._retryDelays[t.previousRetryCount]}}class oo{}oo.Authorization="Authorization",oo.Cookie="Cookie";class cM extends Tu{constructor(t,i){super(),this._innerClient=t,this._accessTokenFactory=i}async send(t){let i=!0;this._accessTokenFactory&&(!this._accessToken||t.url&&t.url.indexOf("/negotiate?")>0)&&(i=!1,this._accessToken=await this._accessTokenFactory()),this._setAuthorizationHeader(t);const o=await this._innerClient.send(t);return i&&o.statusCode===401&&this._accessTokenFactory?(this._accessToken=await this._accessTokenFactory(),this._setAuthorizationHeader(t),await this._innerClient.send(t)):o}_setAuthorizationHeader(t){t.headers||(t.headers={}),this._accessToken?t.headers[oo.Authorization]=`Bearer ${this._accessToken}`:this._accessTokenFactory&&t.headers[oo.Authorization]&&delete t.headers[oo.Authorization]}getCookieString(t){return this._innerClient.getCookieString(t)}}var nn;(function(e){e[e.None=0]="None",e[e.WebSockets=1]="WebSockets",e[e.ServerSentEvents=2]="ServerSentEvents",e[e.LongPolling=4]="LongPolling"})(nn||(nn={}));var Sn;(function(e){e[e.Text=1]="Text",e[e.Binary=2]="Binary"})(Sn||(Sn={}));let fM=class{constructor(){this._isAborted=!1,this.onabort=null}abort(){this._isAborted||(this._isAborted=!0,this.onabort&&this.onabort())}get signal(){return this}get aborted(){return this._isAborted}};class Tb{get pollAborted(){return this._pollAbort.aborted}constructor(t,i,o){this._httpClient=t,this._logger=i,this._pollAbort=new fM,this._options=o,this._running=!1,this.onreceive=null,this.onclose=null}async connect(t,i){if(Kt.isRequired(t,"url"),Kt.isRequired(i,"transferFormat"),Kt.isIn(i,Sn,"transferFormat"),this._url=t,this._logger.log(ae.Trace,"(LongPolling transport) Connecting."),i===Sn.Binary&&typeof XMLHttpRequest<"u"&&typeof new XMLHttpRequest().responseType!="string")throw new Error("Binary protocols over XmlHttpRequest not implementing advanced features are not supported.");const[o,l]=Ko(),u={[o]:l,...this._options.headers},c={abortSignal:this._pollAbort.signal,headers:u,timeout:1e5,withCredentials:this._options.withCredentials};i===Sn.Binary&&(c.responseType="arraybuffer");const d=`${t}&_=${Date.now()}`;this._logger.log(ae.Trace,`(LongPolling transport) polling: ${d}.`);const m=await this._httpClient.get(d,c);m.statusCode!==200?(this._logger.log(ae.Error,`(LongPolling transport) Unexpected response code: ${m.statusCode}.`),this._closeError=new ro(m.statusText||"",m.statusCode),this._running=!1):this._running=!0,this._receiving=this._poll(this._url,c)}async _poll(t,i){try{for(;this._running;)try{const o=`${t}&_=${Date.now()}`;this._logger.log(ae.Trace,`(LongPolling transport) polling: ${o}.`);const l=await this._httpClient.get(o,i);l.statusCode===204?(this._logger.log(ae.Information,"(LongPolling transport) Poll terminated by server."),this._running=!1):l.statusCode!==200?(this._logger.log(ae.Error,`(LongPolling transport) Unexpected response code: ${l.statusCode}.`),this._closeError=new ro(l.statusText||"",l.statusCode),this._running=!1):l.content?(this._logger.log(ae.Trace,`(LongPolling transport) data received. ${Al(l.content,this._options.logMessageContent)}.`),this.onreceive&&this.onreceive(l.content)):this._logger.log(ae.Trace,"(LongPolling transport) Poll timed out, reissuing.")}catch(o){this._running?o instanceof Kd?this._logger.log(ae.Trace,"(LongPolling transport) Poll timed out, reissuing."):(this._closeError=o,this._running=!1):this._logger.log(ae.Trace,`(LongPolling transport) Poll errored after shutdown: ${o.message}`)}}finally{this._logger.log(ae.Trace,"(LongPolling transport) Polling complete."),this.pollAborted||this._raiseOnClose()}}async send(t){return this._running?wb(this._logger,"LongPolling",this._httpClient,this._url,t,this._options):Promise.reject(new Error("Cannot send until the transport is connected"))}async stop(){this._logger.log(ae.Trace,"(LongPolling transport) Stopping polling."),this._running=!1,this._pollAbort.abort();try{await this._receiving,this._logger.log(ae.Trace,`(LongPolling transport) sending DELETE request to ${this._url}.`);const t={},[i,o]=Ko();t[i]=o;const l={headers:{...t,...this._options.headers},timeout:this._options.timeout,withCredentials:this._options.withCredentials};let u;try{await this._httpClient.delete(this._url,l)}catch(c){u=c}u?u instanceof ro&&(u.statusCode===404?this._logger.log(ae.Trace,"(LongPolling transport) A 404 response was returned from sending a DELETE request."):this._logger.log(ae.Trace,`(LongPolling transport) Error sending a DELETE request: ${u}`)):this._logger.log(ae.Trace,"(LongPolling transport) DELETE request accepted.")}finally{this._logger.log(ae.Trace,"(LongPolling transport) Stop finished."),this._raiseOnClose()}}_raiseOnClose(){if(this.onclose){let t="(LongPolling transport) Firing onclose event.";this._closeError&&(t+=" Error: "+this._closeError),this._logger.log(ae.Trace,t),this.onclose(this._closeError)}}}class dM{constructor(t,i,o,l){this._httpClient=t,this._accessToken=i,this._logger=o,this._options=l,this.onreceive=null,this.onclose=null}async connect(t,i){return Kt.isRequired(t,"url"),Kt.isRequired(i,"transferFormat"),Kt.isIn(i,Sn,"transferFormat"),this._logger.log(ae.Trace,"(SSE transport) Connecting."),this._url=t,this._accessToken&&(t+=(t.indexOf("?")<0?"?":"&")+`access_token=${encodeURIComponent(this._accessToken)}`),new Promise((o,l)=>{let u=!1;if(i!==Sn.Text){l(new Error("The Server-Sent Events transport only supports the 'Text' transfer format"));return}let c;if(Mt.isBrowser||Mt.isWebWorker)c=new this._options.EventSource(t,{withCredentials:this._options.withCredentials});else{const d=this._httpClient.getCookieString(t),m={};m.Cookie=d;const[p,g]=Ko();m[p]=g,c=new this._options.EventSource(t,{withCredentials:this._options.withCredentials,headers:{...m,...this._options.headers}})}try{c.onmessage=d=>{if(this.onreceive)try{this._logger.log(ae.Trace,`(SSE transport) data received. ${Al(d.data,this._options.logMessageContent)}.`),this.onreceive(d.data)}catch(m){this._close(m);return}},c.onerror=d=>{u?this._close():l(new Error("EventSource failed to connect. The connection could not be found on the server, either the connection ID is not present on the server, or a proxy is refusing/buffering the connection. If you have multiple servers check that sticky sessions are enabled."))},c.onopen=()=>{this._logger.log(ae.Information,`SSE connected to ${this._url}`),this._eventSource=c,u=!0,o()}}catch(d){l(d);return}})}async send(t){return this._eventSource?wb(this._logger,"SSE",this._httpClient,this._url,t,this._options):Promise.reject(new Error("Cannot send until the transport is connected"))}stop(){return this._close(),Promise.resolve()}_close(t){this._eventSource&&(this._eventSource.close(),this._eventSource=void 0,this.onclose&&this.onclose(t))}}class hM{constructor(t,i,o,l,u,c){this._logger=o,this._accessTokenFactory=i,this._logMessageContent=l,this._webSocketConstructor=u,this._httpClient=t,this.onreceive=null,this.onclose=null,this._headers=c}async connect(t,i){Kt.isRequired(t,"url"),Kt.isRequired(i,"transferFormat"),Kt.isIn(i,Sn,"transferFormat"),this._logger.log(ae.Trace,"(WebSockets transport) Connecting.");let o;return this._accessTokenFactory&&(o=await this._accessTokenFactory()),new Promise((l,u)=>{t=t.replace(/^http/,"ws");let c;const d=this._httpClient.getCookieString(t);let m=!1;if(Mt.isNode||Mt.isReactNative){const p={},[g,y]=Ko();p[g]=y,o&&(p[oo.Authorization]=`Bearer ${o}`),d&&(p[oo.Cookie]=d),c=new this._webSocketConstructor(t,void 0,{headers:{...p,...this._headers}})}else o&&(t+=(t.indexOf("?")<0?"?":"&")+`access_token=${encodeURIComponent(o)}`);c||(c=new this._webSocketConstructor(t)),i===Sn.Binary&&(c.binaryType="arraybuffer"),c.onopen=p=>{this._logger.log(ae.Information,`WebSocket connected to ${t}.`),this._webSocket=c,m=!0,l()},c.onerror=p=>{let g=null;typeof ErrorEvent<"u"&&p instanceof ErrorEvent?g=p.error:g="There was an error with the transport",this._logger.log(ae.Information,`(WebSockets transport) ${g}.`)},c.onmessage=p=>{if(this._logger.log(ae.Trace,`(WebSockets transport) data received. ${Al(p.data,this._logMessageContent)}.`),this.onreceive)try{this.onreceive(p.data)}catch(g){this._close(g);return}},c.onclose=p=>{if(m)this._close(p);else{let g=null;typeof ErrorEvent<"u"&&p instanceof ErrorEvent?g=p.error:g="WebSocket failed to connect. The connection could not be found on the server, either the endpoint may not be a SignalR endpoint, the connection ID is not present on the server, or there is a proxy blocking WebSockets. If you have multiple servers check that sticky sessions are enabled.",u(new Error(g))}}})}send(t){return this._webSocket&&this._webSocket.readyState===this._webSocketConstructor.OPEN?(this._logger.log(ae.Trace,`(WebSockets transport) sending data. ${Al(t,this._logMessageContent)}.`),this._webSocket.send(t),Promise.resolve()):Promise.reject("WebSocket is not in the OPEN state")}stop(){return this._webSocket&&this._close(void 0),Promise.resolve()}_close(t){this._webSocket&&(this._webSocket.onclose=()=>{},this._webSocket.onmessage=()=>{},this._webSocket.onerror=()=>{},this._webSocket.close(),this._webSocket=void 0),this._logger.log(ae.Trace,"(WebSockets transport) socket closed."),this.onclose&&(this._isCloseEvent(t)&&(t.wasClean===!1||t.code!==1e3)?this.onclose(new Error(`WebSocket closed with status code: ${t.code} (${t.reason||"no reason given"}).`)):t instanceof Error?this.onclose(t):this.onclose())}_isCloseEvent(t){return t&&typeof t.wasClean=="boolean"&&typeof t.code=="number"}}const _b=100;class pM{constructor(t,i={}){if(this._stopPromiseResolver=()=>{},this.features={},this._negotiateVersion=1,Kt.isRequired(t,"url"),this._logger=Y5(i.logger),this.baseUrl=this._resolveUrl(t),i=i||{},i.logMessageContent=i.logMessageContent===void 0?!1:i.logMessageContent,typeof i.withCredentials=="boolean"||i.withCredentials===void 0)i.withCredentials=i.withCredentials===void 0?!0:i.withCredentials;else throw new Error("withCredentials option was not a 'boolean' or 'undefined' value");i.timeout=i.timeout===void 0?100*1e3:i.timeout;let o=null,l=null;if(Mt.isNode&&typeof require<"u"){const u=typeof __webpack_require__=="function"?__non_webpack_require__:require;o=u("ws"),l=u("eventsource")}!Mt.isNode&&typeof WebSocket<"u"&&!i.WebSocket?i.WebSocket=WebSocket:Mt.isNode&&!i.WebSocket&&o&&(i.WebSocket=o),!Mt.isNode&&typeof EventSource<"u"&&!i.EventSource?i.EventSource=EventSource:Mt.isNode&&!i.EventSource&&typeof l<"u"&&(i.EventSource=l),this._httpClient=new cM(i.httpClient||new tM(this._logger),i.accessTokenFactory),this._connectionState="Disconnected",this._connectionStarted=!1,this._options=i,this.onreceive=null,this.onclose=null}async start(t){if(t=t||Sn.Binary,Kt.isIn(t,Sn,"transferFormat"),this._logger.log(ae.Debug,`Starting connection with transfer format '${Sn[t]}'.`),this._connectionState!=="Disconnected")return Promise.reject(new Error("Cannot start an HttpConnection that is not in the 'Disconnected' state."));if(this._connectionState="Connecting",this._startInternalPromise=this._startInternal(t),await this._startInternalPromise,this._connectionState==="Disconnecting"){const i="Failed to start the HttpConnection before stop() was called.";return this._logger.log(ae.Error,i),await this._stopPromise,Promise.reject(new br(i))}else if(this._connectionState!=="Connected"){const i="HttpConnection.startInternal completed gracefully but didn't enter the connection into the connected state!";return this._logger.log(ae.Error,i),Promise.reject(new br(i))}this._connectionStarted=!0}send(t){return this._connectionState!=="Connected"?Promise.reject(new Error("Cannot send data if the connection is not in the 'Connected' State.")):(this._sendQueue||(this._sendQueue=new Wd(this.transport)),this._sendQueue.send(t))}async stop(t){if(this._connectionState==="Disconnected")return this._logger.log(ae.Debug,`Call to HttpConnection.stop(${t}) ignored because the connection is already in the disconnected state.`),Promise.resolve();if(this._connectionState==="Disconnecting")return this._logger.log(ae.Debug,`Call to HttpConnection.stop(${t}) ignored because the connection is already in the disconnecting state.`),this._stopPromise;this._connectionState="Disconnecting",this._stopPromise=new Promise(i=>{this._stopPromiseResolver=i}),await this._stopInternal(t),await this._stopPromise}async _stopInternal(t){this._stopError=t;try{await this._startInternalPromise}catch{}if(this.transport){try{await this.transport.stop()}catch(i){this._logger.log(ae.Error,`HttpConnection.transport.stop() threw error '${i}'.`),this._stopConnection()}this.transport=void 0}else this._logger.log(ae.Debug,"HttpConnection.transport is undefined in HttpConnection.stop() because start() failed.")}async _startInternal(t){let i=this.baseUrl;this._accessTokenFactory=this._options.accessTokenFactory,this._httpClient._accessTokenFactory=this._accessTokenFactory;try{if(this._options.skipNegotiation)if(this._options.transport===nn.WebSockets)this.transport=this._constructTransport(nn.WebSockets),await this._startTransport(i,t);else throw new Error("Negotiation can only be skipped when using the WebSocket transport directly.");else{let o=null,l=0;do{if(o=await this._getNegotiationResponse(i),this._connectionState==="Disconnecting"||this._connectionState==="Disconnected")throw new br("The connection was stopped during negotiation.");if(o.error)throw new Error(o.error);if(o.ProtocolVersion)throw new Error("Detected a connection attempt to an ASP.NET SignalR Server. This client only supports connecting to an ASP.NET Core SignalR Server. See https://aka.ms/signalr-core-differences for details.");if(o.url&&(i=o.url),o.accessToken){const u=o.accessToken;this._accessTokenFactory=()=>u,this._httpClient._accessToken=u,this._httpClient._accessTokenFactory=void 0}l++}while(o.url&&l<_b);if(l===_b&&o.url)throw new Error("Negotiate redirection limit exceeded.");await this._createTransport(i,this._options.transport,o,t)}this.transport instanceof Tb&&(this.features.inherentKeepAlive=!0),this._connectionState==="Connecting"&&(this._logger.log(ae.Debug,"The HttpConnection connected successfully."),this._connectionState="Connected")}catch(o){return this._logger.log(ae.Error,"Failed to start the connection: "+o),this._connectionState="Disconnected",this.transport=void 0,this._stopPromiseResolver(),Promise.reject(o)}}async _getNegotiationResponse(t){const i={},[o,l]=Ko();i[o]=l;const u=this._resolveNegotiateUrl(t);this._logger.log(ae.Debug,`Sending negotiation request: ${u}.`);try{const c=await this._httpClient.post(u,{content:"",headers:{...i,...this._options.headers},timeout:this._options.timeout,withCredentials:this._options.withCredentials});if(c.statusCode!==200)return Promise.reject(new Error(`Unexpected status code returned from negotiate '${c.statusCode}'`));const d=JSON.parse(c.content);return(!d.negotiateVersion||d.negotiateVersion<1)&&(d.connectionToken=d.connectionId),d.useStatefulReconnect&&this._options._useStatefulReconnect!==!0?Promise.reject(new vb("Client didn't negotiate Stateful Reconnect but the server did.")):d}catch(c){let d="Failed to complete negotiation with the server: "+c;return c instanceof ro&&c.statusCode===404&&(d=d+" Either this is not a SignalR endpoint or there is a proxy blocking the connection."),this._logger.log(ae.Error,d),Promise.reject(new vb(d))}}_createConnectUrl(t,i){return i?t+(t.indexOf("?")===-1?"?":"&")+`id=${i}`:t}async _createTransport(t,i,o,l){let u=this._createConnectUrl(t,o.connectionToken);if(this._isITransport(i)){this._logger.log(ae.Debug,"Connection was provided an instance of ITransport, using that directly."),this.transport=i,await this._startTransport(u,l),this.connectionId=o.connectionId;return}const c=[],d=o.availableTransports||[];let m=o;for(const p of d){const g=this._resolveTransportOrError(p,i,l,m?.useStatefulReconnect===!0);if(g instanceof Error)c.push(`${p.transport} failed:`),c.push(g);else if(this._isITransport(g)){if(this.transport=g,!m){try{m=await this._getNegotiationResponse(t)}catch(y){return Promise.reject(y)}u=this._createConnectUrl(t,m.connectionToken)}try{await this._startTransport(u,l),this.connectionId=m.connectionId;return}catch(y){if(this._logger.log(ae.Error,`Failed to start the transport '${p.transport}': ${y}`),m=void 0,c.push(new H5(`${p.transport} failed: ${y}`,nn[p.transport])),this._connectionState!=="Connecting"){const v="Failed to select transport before stop() was called.";return this._logger.log(ae.Debug,v),Promise.reject(new br(v))}}}}return c.length>0?Promise.reject(new q5(`Unable to connect to the server with any of the available transports. ${c.join(" ")}`,c)):Promise.reject(new Error("None of the transports supported by the client are supported by the server."))}_constructTransport(t){switch(t){case nn.WebSockets:if(!this._options.WebSocket)throw new Error("'WebSocket' is not supported in your environment.");return new hM(this._httpClient,this._accessTokenFactory,this._logger,this._options.logMessageContent,this._options.WebSocket,this._options.headers||{});case nn.ServerSentEvents:if(!this._options.EventSource)throw new Error("'EventSource' is not supported in your environment.");return new dM(this._httpClient,this._httpClient._accessToken,this._logger,this._options);case nn.LongPolling:return new Tb(this._httpClient,this._logger,this._options);default:throw new Error(`Unknown transport: ${t}.`)}}_startTransport(t,i){return this.transport.onreceive=this.onreceive,this.features.reconnect?this.transport.onclose=async o=>{let l=!1;if(this.features.reconnect)try{this.features.disconnected(),await this.transport.connect(t,i),await this.features.resend()}catch{l=!0}else{this._stopConnection(o);return}l&&this._stopConnection(o)}:this.transport.onclose=o=>this._stopConnection(o),this.transport.connect(t,i)}_resolveTransportOrError(t,i,o,l){const u=nn[t.transport];if(u==null)return this._logger.log(ae.Debug,`Skipping transport '${t.transport}' because it is not supported by this client.`),new Error(`Skipping transport '${t.transport}' because it is not supported by this client.`);if(mM(i,u))if(t.transferFormats.map(d=>Sn[d]).indexOf(o)>=0){if(u===nn.WebSockets&&!this._options.WebSocket||u===nn.ServerSentEvents&&!this._options.EventSource)return this._logger.log(ae.Debug,`Skipping transport '${nn[u]}' because it is not supported in your environment.'`),new j5(`'${nn[u]}' is not supported in your environment.`,u);this._logger.log(ae.Debug,`Selecting transport '${nn[u]}'.`);try{return this.features.reconnect=u===nn.WebSockets?l:void 0,this._constructTransport(u)}catch(d){return d}}else return this._logger.log(ae.Debug,`Skipping transport '${nn[u]}' because it does not support the requested transfer format '${Sn[o]}'.`),new Error(`'${nn[u]}' does not support ${Sn[o]}.`);else return this._logger.log(ae.Debug,`Skipping transport '${nn[u]}' because it was disabled by the client.`),new P5(`'${nn[u]}' is disabled by the client.`,u)}_isITransport(t){return t&&typeof t=="object"&&"connect"in t}_stopConnection(t){if(this._logger.log(ae.Debug,`HttpConnection.stopConnection(${t}) called while in state ${this._connectionState}.`),this.transport=void 0,t=this._stopError||t,this._stopError=void 0,this._connectionState==="Disconnected"){this._logger.log(ae.Debug,`Call to HttpConnection.stopConnection(${t}) was ignored because the connection is already in the disconnected state.`);return}if(this._connectionState==="Connecting")throw this._logger.log(ae.Warning,`Call to HttpConnection.stopConnection(${t}) was ignored because the connection is still in the connecting state.`),new Error(`HttpConnection.stopConnection(${t}) was called while the connection is still in the connecting state.`);if(this._connectionState==="Disconnecting"&&this._stopPromiseResolver(),t?this._logger.log(ae.Error,`Connection disconnected with error '${t}'.`):this._logger.log(ae.Information,"Connection disconnected."),this._sendQueue&&(this._sendQueue.stop().catch(i=>{this._logger.log(ae.Error,`TransportSendQueue.stop() threw error '${i}'.`)}),this._sendQueue=void 0),this.connectionId=void 0,this._connectionState="Disconnected",this._connectionStarted){this._connectionStarted=!1;try{this.onclose&&this.onclose(t)}catch(i){this._logger.log(ae.Error,`HttpConnection.onclose(${t}) threw error '${i}'.`)}}}_resolveUrl(t){if(t.lastIndexOf("https://",0)===0||t.lastIndexOf("http://",0)===0)return t;if(!Mt.isBrowser)throw new Error(`Cannot resolve '${t}'.`);const i=window.document.createElement("a");return i.href=t,this._logger.log(ae.Information,`Normalizing '${t}' to '${i.href}'.`),i.href}_resolveNegotiateUrl(t){const i=new URL(t);i.pathname.endsWith("/")?i.pathname+="negotiate":i.pathname+="/negotiate";const o=new URLSearchParams(i.searchParams);return o.has("negotiateVersion")||o.append("negotiateVersion",this._negotiateVersion.toString()),o.has("useStatefulReconnect")?o.get("useStatefulReconnect")==="true"&&(this._options._useStatefulReconnect=!0):this._options._useStatefulReconnect===!0&&o.append("useStatefulReconnect","true"),i.search=o.toString(),i.toString()}}function mM(e,t){return!e||(t&e)!==0}class Wd{constructor(t){this._transport=t,this._buffer=[],this._executing=!0,this._sendBufferedData=new Au,this._transportResult=new Au,this._sendLoopPromise=this._sendLoop()}send(t){return this._bufferData(t),this._transportResult||(this._transportResult=new Au),this._transportResult.promise}stop(){return this._executing=!1,this._sendBufferedData.resolve(),this._sendLoopPromise}_bufferData(t){if(this._buffer.length&&typeof this._buffer[0]!=typeof t)throw new Error(`Expected data to be of type ${typeof this._buffer} but was of type ${typeof t}`);this._buffer.push(t),this._sendBufferedData.resolve()}async _sendLoop(){for(;;){if(await this._sendBufferedData.promise,!this._executing){this._transportResult&&this._transportResult.reject("Connection stopped.");break}this._sendBufferedData=new Au;const t=this._transportResult;this._transportResult=void 0;const i=typeof this._buffer[0]=="string"?this._buffer.join(""):Wd._concatBuffers(this._buffer);this._buffer.length=0;try{await this._transport.send(i),t.resolve()}catch(o){t.reject(o)}}}static _concatBuffers(t){const i=t.map(u=>u.byteLength).reduce((u,c)=>u+c),o=new Uint8Array(i);let l=0;for(const u of t)o.set(new Uint8Array(u),l),l+=u.byteLength;return o.buffer}}class Au{constructor(){this.promise=new Promise((t,i)=>[this._resolver,this._rejecter]=[t,i])}resolve(){this._resolver()}reject(t){this._rejecter(t)}}const gM="json";class yM{constructor(){this.name=gM,this.version=2,this.transferFormat=Sn.Text}parseMessages(t,i){if(typeof t!="string")throw new Error("Invalid input for JSON hub protocol. Expected a string.");if(!t)return[];i===null&&(i=_l.instance);const o=Ln.parse(t),l=[];for(const u of o){const c=JSON.parse(u);if(typeof c.type!="number")throw new Error("Invalid payload.");switch(c.type){case Be.Invocation:this._isInvocationMessage(c);break;case Be.StreamItem:this._isStreamItemMessage(c);break;case Be.Completion:this._isCompletionMessage(c);break;case Be.Ping:break;case Be.Close:break;case Be.Ack:this._isAckMessage(c);break;case Be.Sequence:this._isSequenceMessage(c);break;default:i.log(ae.Information,"Unknown message type '"+c.type+"' ignored.");continue}l.push(c)}return l}writeMessage(t){return Ln.write(JSON.stringify(t))}_isInvocationMessage(t){this._assertNotEmptyString(t.target,"Invalid payload for Invocation message."),t.invocationId!==void 0&&this._assertNotEmptyString(t.invocationId,"Invalid payload for Invocation message.")}_isStreamItemMessage(t){if(this._assertNotEmptyString(t.invocationId,"Invalid payload for StreamItem message."),t.item===void 0)throw new Error("Invalid payload for StreamItem message.")}_isCompletionMessage(t){if(t.result&&t.error)throw new Error("Invalid payload for Completion message.");!t.result&&t.error&&this._assertNotEmptyString(t.error,"Invalid payload for Completion message."),this._assertNotEmptyString(t.invocationId,"Invalid payload for Completion message.")}_isAckMessage(t){if(typeof t.sequenceId!="number")throw new Error("Invalid SequenceId for Ack message.")}_isSequenceMessage(t){if(typeof t.sequenceId!="number")throw new Error("Invalid SequenceId for Sequence message.")}_assertNotEmptyString(t,i){if(typeof t!="string"||t==="")throw new Error(i)}}const bM={trace:ae.Trace,debug:ae.Debug,info:ae.Information,information:ae.Information,warn:ae.Warning,warning:ae.Warning,error:ae.Error,critical:ae.Critical,none:ae.None};function SM(e){const t=bM[e.toLowerCase()];if(typeof t<"u")return t;throw new Error(`Unknown log level: ${e}`)}class vM{configureLogging(t){if(Kt.isRequired(t,"logging"),xM(t))this.logger=t;else if(typeof t=="string"){const i=SM(t);this.logger=new _u(i)}else this.logger=new _u(t);return this}withUrl(t,i){return Kt.isRequired(t,"url"),Kt.isNotEmpty(t,"url"),this.url=t,typeof i=="object"?this.httpConnectionOptions={...this.httpConnectionOptions,...i}:this.httpConnectionOptions={...this.httpConnectionOptions,transport:i},this}withHubProtocol(t){return Kt.isRequired(t,"protocol"),this.protocol=t,this}withAutomaticReconnect(t){if(this.reconnectPolicy)throw new Error("A reconnectPolicy has already been set.");return t?Array.isArray(t)?this.reconnectPolicy=new Eb(t):this.reconnectPolicy=t:this.reconnectPolicy=new Eb,this}withServerTimeout(t){return Kt.isRequired(t,"milliseconds"),this._serverTimeoutInMilliseconds=t,this}withKeepAliveInterval(t){return Kt.isRequired(t,"milliseconds"),this._keepAliveIntervalInMilliseconds=t,this}withStatefulReconnect(t){return this.httpConnectionOptions===void 0&&(this.httpConnectionOptions={}),this.httpConnectionOptions._useStatefulReconnect=!0,this._statefulReconnectBufferSize=t?.bufferSize,this}build(){const t=this.httpConnectionOptions||{};if(t.logger===void 0&&(t.logger=this.logger),!this.url)throw new Error("The 'HubConnectionBuilder.withUrl' method must be called before building the connection.");const i=new pM(this.url,t);return Zd.create(i,this.logger||_l.instance,this.protocol||new yM,this.reconnectPolicy,this._serverTimeoutInMilliseconds,this._keepAliveIntervalInMilliseconds,this._statefulReconnectBufferSize)}}function xM(e){return e.log!==void 0}function wM({url:e,accessToken:t,autoStart:i=!0}){const o=O.useRef(null),l=O.useRef(new Map),u=O.useRef(null),c=O.useRef(0),d=O.useRef(!1),[m,p]=O.useState("disconnected"),[g,y]=O.useState(null),v=O.useCallback(()=>{u.current&&(clearTimeout(u.current),u.current=null)},[]),S=O.useCallback(()=>{if(d.current||u.current)return;c.current+=1;const T=c.current,L=Math.min(3e4,1e3*Math.pow(2,T-1)),V=Math.floor(Math.random()*500),q=L+V;u.current=setTimeout(()=>{u.current=null,k()},q)},[v]),E=O.useCallback(T=>{l.current.forEach((L,V)=>{T.off(V),L.forEach(q=>{T.on(V,q)})})},[]),w=O.useCallback(async()=>Jy(),[]),R=O.useCallback(()=>{const T=new vM().withUrl(e,{accessTokenFactory:w}).withAutomaticReconnect({nextRetryDelayInMilliseconds:L=>L.elapsedMilliseconds<6e4?Math.random()*1e4:null}).build();return T.onreconnecting(()=>{v(),p("reconnecting")}),T.onreconnected(()=>{v(),c.current=0,p("connected"),E(T)}),T.onclose(L=>{p("disconnected"),L&&y(L),d.current||S()}),T},[e,w,E,v,S]),k=O.useCallback(async()=>{d.current=!1,v(),o.current||(o.current=R());const T=o.current;if(T.state===ut.Connected){p("connected");return}if(T.state===ut.Connecting){p("connecting");return}if(T.state===ut.Reconnecting){p("reconnecting");return}p("connecting");try{await T.start(),E(T),c.current=0,p("connected"),y(null)}catch(L){y(L),p("disconnected"),S()}},[E,R,v,S]),I=O.useCallback(async()=>{d.current=!0,v(),c.current=0;const T=o.current;if(o.current=null,!T){p("disconnected");return}try{await T.stop()}finally{p("disconnected")}},[v]),M=O.useCallback((T,L)=>{let V=l.current.get(T);V||(V=new Set,l.current.set(T,V)),V.add(L);const q=o.current;q&&q.on(T,L)},[]),_=O.useCallback((T,L)=>{const V=l.current.get(T);if(!V)return;V.delete(L),V.size===0&&l.current.delete(T);const q=o.current;q&&q.off(T,L)},[]),z=O.useCallback(async(T,...L)=>{const V=o.current;if(!V||V.state!==ut.Connected)throw new Error("SignalR not connected");return V.invoke(T,...L)},[]);return O.useEffect(()=>(i&&k(),()=>{I()}),[i,k,I]),{status:m,connected:m==="connected",error:g,start:k,stop:I,on:M,off:_,invoke:z}}const CM=(()=>{const e=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Uint8Array.prototype),Symbol.toStringTag).get;return t=>e.call(t)})();function Ab(e){return CM(e)==="Uint8Array"}function EM(e){return typeof e=="object"&&e!=null&&Symbol.toStringTag in e&&(e[Symbol.toStringTag]==="ArrayBuffer"||e[Symbol.toStringTag]==="SharedArrayBuffer")}function TM(e){return e instanceof RegExp||Object.prototype.toString.call(e)==="[object RegExp]"}function kb(e){return typeof e=="object"&&e!=null&&Symbol.toStringTag in e&&e[Symbol.toStringTag]==="Map"}function _M(e){return e instanceof Date||Object.prototype.toString.call(e)==="[object Date]"}function jn(e,t){return JSON.stringify(e,(i,o)=>typeof o=="bigint"?{$numberLong:`${o}`}:kb(o)?Object.fromEntries(o):o)}function AM(e){if(e!=null&&typeof e=="object"&&"stylize"in e&&typeof e.stylize=="function")return e.stylize}const Jd=7,Rb=Symbol.for("@@mdb.bson.version"),eh=2147483647,th=-2147483648,Ob=Math.pow(2,63)-1,Mb=-Math.pow(2,63),kM=Math.pow(2,53),RM=-Math.pow(2,53),Nb=4;class pe extends Error{get bsonError(){return!0}get name(){return"BSONError"}constructor(t,i){super(t,i)}static isBSONError(t){return t!=null&&typeof t=="object"&&"bsonError"in t&&t.bsonError===!0&&"name"in t&&"message"in t&&"stack"in t}}class OM extends pe{get name(){return"BSONVersionError"}constructor(){super(`Unsupported BSON version, bson types must be from bson ${Jd}.x.x`)}}class zb extends pe{get name(){return"BSONRuntimeError"}constructor(t){super(t)}}class vi extends pe{get name(){return"BSONOffsetError"}offset;constructor(t,i,o){super(`${t}. offset: ${i}`,o),this.offset=i}}let Bb,Db;function Ib(e,t,i,o){if(o){Bb??=new TextDecoder("utf8",{fatal:!0});try{return Bb.decode(e.subarray(t,i))}catch(l){throw new pe("Invalid UTF-8 string in BSON document",{cause:l})}}return Db??=new TextDecoder("utf8",{fatal:!1}),Db.decode(e.subarray(t,i))}function $b(e,t,i){if(e.length===0)return"";const o=i-t;if(o===0)return"";if(o>20)return null;if(o===1&&e[t]<128)return String.fromCharCode(e[t]);if(o===2&&e[t]<128&&e[t+1]<128)return String.fromCharCode(e[t])+String.fromCharCode(e[t+1]);if(o===3&&e[t]<128&&e[t+1]<128&&e[t+2]<128)return String.fromCharCode(e[t])+String.fromCharCode(e[t+1])+String.fromCharCode(e[t+2]);const l=[];for(let u=t;u<i;u++){const c=e[u];if(c>127)return null;l.push(c)}return String.fromCharCode(...l)}function MM(e,t,i){if(t.length===0)return 0;if(t.length>25||e.length-i<t.length)return null;for(let o=0,l=i;o<t.length;o++,l++){const u=t.charCodeAt(o);if(u>127)return null;e[l]=u}return t.length}function NM(e){return $r.fromNumberArray(Array.from({length:e},()=>Math.floor(Math.random()*256)))}function zM(e){return crypto.getRandomValues($r.allocate(e))}const BM=(()=>{const{crypto:e}=globalThis;return e!=null&&typeof e.getRandomValues=="function"?zM:NM})(),$r={toLocalBufferType(e){if(Buffer.isBuffer(e))return e;if(ArrayBuffer.isView(e))return Buffer.from(e.buffer,e.byteOffset,e.byteLength);const t=e?.[Symbol.toStringTag]??Object.prototype.toString.call(e);if(t==="ArrayBuffer"||t==="SharedArrayBuffer"||t==="[object ArrayBuffer]"||t==="[object SharedArrayBuffer]")return Buffer.from(e);throw new pe("Cannot create Buffer from the passed potentialBuffer.")},allocate(e){return Buffer.alloc(e)},allocateUnsafe(e){return Buffer.allocUnsafe(e)},equals(e,t){return $r.toLocalBufferType(e).equals(t)},fromNumberArray(e){return Buffer.from(e)},fromBase64(e){return Buffer.from(e,"base64")},toBase64(e){return $r.toLocalBufferType(e).toString("base64")},fromISO88591(e){return Buffer.from(e,"binary")},toISO88591(e){return $r.toLocalBufferType(e).toString("binary")},fromHex(e){return Buffer.from(e,"hex")},toHex(e){return $r.toLocalBufferType(e).toString("hex")},toUTF8(e,t,i,o){const l=i-t<=20?$b(e,t,i):null;if(l!=null)return l;const u=$r.toLocalBufferType(e).toString("utf8",t,i);if(o){for(let c=0;c<u.length;c++)if(u.charCodeAt(c)===65533){Ib(e,t,i,!0);break}}return u},utf8ByteLength(e){return Buffer.byteLength(e,"utf8")},encodeUTF8Into(e,t,i){const o=MM(e,t,i);return o??$r.toLocalBufferType(e).write(t,i,void 0,"utf8")},randomBytes:BM,swap32(e){return $r.toLocalBufferType(e).swap32()}};function DM(){const{navigator:e}=globalThis;return typeof e=="object"&&e.product==="ReactNative"}function IM(e){if(e<0)throw new RangeError(`The argument 'byteLength' is invalid. Received ${e}`);return kl.fromNumberArray(Array.from({length:e},()=>Math.floor(Math.random()*256)))}const $M=(()=>{const{crypto:e}=globalThis;if(e!=null&&typeof e.getRandomValues=="function")return t=>e.getRandomValues(kl.allocate(t));if(DM()){const{console:t}=globalThis;t?.warn?.("BSON: For React Native please polyfill crypto.getRandomValues, e.g. using: https://www.npmjs.com/package/react-native-get-random-values.")}return IM})(),Ub=/(\d|[a-f])/i,kl={toLocalBufferType(e){const t=e?.[Symbol.toStringTag]??Object.prototype.toString.call(e);if(t==="Uint8Array")return e;if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength));if(t==="ArrayBuffer"||t==="SharedArrayBuffer"||t==="[object ArrayBuffer]"||t==="[object SharedArrayBuffer]")return new Uint8Array(e);throw new pe("Cannot make a Uint8Array from passed potentialBuffer.")},allocate(e){if(typeof e!="number")throw new TypeError(`The "size" argument must be of type number. Received ${String(e)}`);return new Uint8Array(e)},allocateUnsafe(e){return kl.allocate(e)},equals(e,t){if(e.byteLength!==t.byteLength)return!1;for(let i=0;i<e.byteLength;i++)if(e[i]!==t[i])return!1;return!0},fromNumberArray(e){return Uint8Array.from(e)},fromBase64(e){return Uint8Array.from(atob(e),t=>t.charCodeAt(0))},toBase64(e){return btoa(kl.toISO88591(e))},fromISO88591(e){return Uint8Array.from(e,t=>t.charCodeAt(0)&255)},toISO88591(e){return Array.from(Uint16Array.from(e),t=>String.fromCharCode(t)).join("")},fromHex(e){const t=e.length%2===0?e:e.slice(0,e.length-1),i=[];for(let o=0;o<t.length;o+=2){const l=t[o],u=t[o+1];if(!Ub.test(l)||!Ub.test(u))break;const c=Number.parseInt(`${l}${u}`,16);i.push(c)}return Uint8Array.from(i)},toHex(e){return Array.from(e,t=>t.toString(16).padStart(2,"0")).join("")},toUTF8(e,t,i,o){const l=i-t<=20?$b(e,t,i):null;return l??Ib(e,t,i,o)},utf8ByteLength(e){return new TextEncoder().encode(e).byteLength},encodeUTF8Into(e,t,i){const o=new TextEncoder().encode(t);return e.set(o,i),o.byteLength},randomBytes:$M,swap32(e){if(e.length%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let t=0;t<e.length;t+=4){const i=e[t],o=e[t+1],l=e[t+2],u=e[t+3];e[t]=u,e[t+1]=l,e[t+2]=o,e[t+3]=i}return e}},_e=typeof Buffer=="function"&&Buffer.prototype?._isBuffer!==!0?$r:kl,Lb=Symbol.for("@@mdb.bson.type");class er{get[Lb](){return this._bsontype}get[Rb](){return Jd}[Symbol.for("nodejs.util.inspect.custom")](t,i,o){return this.inspect(t,i,o)}}const Qo=new Float64Array(1),We=new Uint8Array(Qo.buffer,0,8);Qo[0]=-1;const nh=We[7]===0,ao={isBigEndian:nh,getNonnegativeInt32LE(e,t){if(e[t+3]>127)throw new RangeError(`Size cannot be negative at offset: ${t}`);return e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24},getInt32LE(e,t){return e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24},getUint32LE(e,t){return e[t]+e[t+1]*256+e[t+2]*65536+e[t+3]*16777216},getUint32BE(e,t){return e[t+3]+e[t+2]*256+e[t+1]*65536+e[t]*16777216},getBigInt64LE(e,t){const i=BigInt(e[t+4]+e[t+5]*256+e[t+6]*65536+(e[t+7]<<24)),o=BigInt(e[t]+e[t+1]*256+e[t+2]*65536+e[t+3]*16777216);return(i<<32n)+o},getFloat64LE:nh?(e,t)=>(We[7]=e[t],We[6]=e[t+1],We[5]=e[t+2],We[4]=e[t+3],We[3]=e[t+4],We[2]=e[t+5],We[1]=e[t+6],We[0]=e[t+7],Qo[0]):(e,t)=>(We[0]=e[t],We[1]=e[t+1],We[2]=e[t+2],We[3]=e[t+3],We[4]=e[t+4],We[5]=e[t+5],We[6]=e[t+6],We[7]=e[t+7],Qo[0]),setInt32BE(e,t,i){return e[t+3]=i,i>>>=8,e[t+2]=i,i>>>=8,e[t+1]=i,i>>>=8,e[t]=i,4},setInt32LE(e,t,i){return e[t]=i,i>>>=8,e[t+1]=i,i>>>=8,e[t+2]=i,i>>>=8,e[t+3]=i,4},setBigInt64LE(e,t,i){const o=0xffffffffn;let l=Number(i&o);e[t]=l,l>>=8,e[t+1]=l,l>>=8,e[t+2]=l,l>>=8,e[t+3]=l;let u=Number(i>>32n&o);return e[t+4]=u,u>>=8,e[t+5]=u,u>>=8,e[t+6]=u,u>>=8,e[t+7]=u,8},setFloat64LE:nh?(e,t,i)=>(Qo[0]=i,e[t]=We[7],e[t+1]=We[6],e[t+2]=We[5],e[t+3]=We[4],e[t+4]=We[3],e[t+5]=We[2],e[t+6]=We[1],e[t+7]=We[0],8):(e,t,i)=>(Qo[0]=i,e[t]=We[0],e[t+1]=We[1],e[t+2]=We[2],e[t+3]=We[3],e[t+4]=We[4],e[t+5]=We[5],e[t+6]=We[6],e[t+7]=We[7],8)};class Ke extends er{get _bsontype(){return"Binary"}static BSON_BINARY_SUBTYPE_DEFAULT=0;static BUFFER_SIZE=256;static SUBTYPE_DEFAULT=0;static SUBTYPE_FUNCTION=1;static SUBTYPE_BYTE_ARRAY=2;static SUBTYPE_UUID_OLD=3;static SUBTYPE_UUID=4;static SUBTYPE_MD5=5;static SUBTYPE_ENCRYPTED=6;static SUBTYPE_COLUMN=7;static SUBTYPE_SENSITIVE=8;static SUBTYPE_VECTOR=9;static SUBTYPE_USER_DEFINED=128;static VECTOR_TYPE=Object.freeze({Int8:3,Float32:39,PackedBit:16});buffer;sub_type;position;constructor(t,i){if(super(),t!=null&&typeof t=="string"&&!ArrayBuffer.isView(t)&&!EM(t)&&!Array.isArray(t))throw new pe("Binary can only be constructed from Uint8Array or number[]");this.sub_type=i??Ke.BSON_BINARY_SUBTYPE_DEFAULT,t==null?(this.buffer=_e.allocate(Ke.BUFFER_SIZE),this.position=0):(this.buffer=Array.isArray(t)?_e.fromNumberArray(t):_e.toLocalBufferType(t),this.position=this.buffer.byteLength)}put(t){if(typeof t=="string"&&t.length!==1)throw new pe("only accepts single character String");if(typeof t!="number"&&t.length!==1)throw new pe("only accepts single character Uint8Array or Array");let i;if(typeof t=="string"?i=t.charCodeAt(0):typeof t=="number"?i=t:i=t[0],i<0||i>255)throw new pe("only accepts number in a valid unsigned byte range 0-255");if(this.buffer.byteLength>this.position)this.buffer[this.position++]=i;else{const o=_e.allocate(Ke.BUFFER_SIZE+this.buffer.length);o.set(this.buffer,0),this.buffer=o,this.buffer[this.position++]=i}}write(t,i){if(i=typeof i=="number"?i:this.position,this.buffer.byteLength<i+t.length){const o=_e.allocate(this.buffer.byteLength+t.length);o.set(this.buffer,0),this.buffer=o}if(ArrayBuffer.isView(t))this.buffer.set(_e.toLocalBufferType(t),i),this.position=i+t.byteLength>this.position?i+t.length:this.position;else if(typeof t=="string")throw new pe("input cannot be string")}read(t,i){i=i&&i>0?i:this.position;const o=t+i;return this.buffer.subarray(t,o>this.position?this.position:o)}value(){return this.buffer.length===this.position?this.buffer:this.buffer.subarray(0,this.position)}length(){return this.position}toJSON(){return _e.toBase64(this.buffer.subarray(0,this.position))}toString(t){return t==="hex"?_e.toHex(this.buffer.subarray(0,this.position)):t==="base64"?_e.toBase64(this.buffer.subarray(0,this.position)):t==="utf8"||t==="utf-8"?_e.toUTF8(this.buffer,0,this.position,!1):_e.toUTF8(this.buffer,0,this.position,!1)}toExtendedJSON(t){t=t||{},this.sub_type===Ke.SUBTYPE_VECTOR&&xi(this);const i=_e.toBase64(this.buffer),o=Number(this.sub_type).toString(16);return t.legacy?{$binary:i,$type:o.length===1?"0"+o:o}:{$binary:{base64:i,subType:o.length===1?"0"+o:o}}}toUUID(){if(this.sub_type===Ke.SUBTYPE_UUID)return new xn(this.buffer.subarray(0,this.position));throw new pe(`Binary sub_type "${this.sub_type}" is not supported for converting to UUID. Only "${Ke.SUBTYPE_UUID}" is currently supported.`)}static createFromHexString(t,i){return new Ke(_e.fromHex(t),i)}static createFromBase64(t,i){return new Ke(_e.fromBase64(t),i)}static fromExtendedJSON(t,i){i=i||{};let o,l;if("$binary"in t?i.legacy&&typeof t.$binary=="string"&&"$type"in t?(l=t.$type?parseInt(t.$type,16):0,o=_e.fromBase64(t.$binary)):typeof t.$binary!="string"&&(l=t.$binary.subType?parseInt(t.$binary.subType,16):0,o=_e.fromBase64(t.$binary.base64)):"$uuid"in t&&(l=4,o=xn.bytesFromString(t.$uuid)),!o)throw new pe(`Unexpected Binary Extended JSON format ${JSON.stringify(t)}`);return l===Nb?new xn(o):new Ke(o,l)}inspect(t,i,o){o??=jn;const l=_e.toBase64(this.buffer.subarray(0,this.position)),u=o(l,i),c=o(this.sub_type,i);return`Binary.createFromBase64(${u}, ${c})`}toInt8Array(){if(this.sub_type!==Ke.SUBTYPE_VECTOR)throw new pe("Binary sub_type is not Vector");if(this.buffer[0]!==Ke.VECTOR_TYPE.Int8)throw new pe("Binary datatype field is not Int8");return xi(this),new Int8Array(this.buffer.buffer.slice(this.buffer.byteOffset+2,this.buffer.byteOffset+this.position))}toFloat32Array(){if(this.sub_type!==Ke.SUBTYPE_VECTOR)throw new pe("Binary sub_type is not Vector");if(this.buffer[0]!==Ke.VECTOR_TYPE.Float32)throw new pe("Binary datatype field is not Float32");xi(this);const t=new Uint8Array(this.buffer.buffer.slice(this.buffer.byteOffset+2,this.buffer.byteOffset+this.position));return ao.isBigEndian&&_e.swap32(t),new Float32Array(t.buffer)}toPackedBits(){if(this.sub_type!==Ke.SUBTYPE_VECTOR)throw new pe("Binary sub_type is not Vector");if(this.buffer[0]!==Ke.VECTOR_TYPE.PackedBit)throw new pe("Binary datatype field is not packed bit");return xi(this),new Uint8Array(this.buffer.buffer.slice(this.buffer.byteOffset+2,this.buffer.byteOffset+this.position))}toBits(){if(this.sub_type!==Ke.SUBTYPE_VECTOR)throw new pe("Binary sub_type is not Vector");if(this.buffer[0]!==Ke.VECTOR_TYPE.PackedBit)throw new pe("Binary datatype field is not packed bit");xi(this);const i=(this.length()-2)*8-this.buffer[1],o=new Int8Array(i);for(let l=0;l<o.length;l++){const u=l/8|0,c=this.buffer[u+2],d=7-l%8,m=c>>d&1;o[l]=m}return o}static fromInt8Array(t){const i=_e.allocate(t.byteLength+2);i[0]=Ke.VECTOR_TYPE.Int8,i[1]=0;const o=new Uint8Array(t.buffer,t.byteOffset,t.byteLength);i.set(o,2);const l=new this(i,this.SUBTYPE_VECTOR);return xi(l),l}static fromFloat32Array(t){const i=_e.allocate(t.byteLength+2);i[0]=Ke.VECTOR_TYPE.Float32,i[1]=0;const o=new Uint8Array(t.buffer,t.byteOffset,t.byteLength);i.set(o,2),ao.isBigEndian&&_e.swap32(new Uint8Array(i.buffer,2));const l=new this(i,this.SUBTYPE_VECTOR);return xi(l),l}static fromPackedBits(t,i=0){const o=_e.allocate(t.byteLength+2);o[0]=Ke.VECTOR_TYPE.PackedBit,o[1]=i,o.set(t,2);const l=new this(o,this.SUBTYPE_VECTOR);return xi(l),l}static fromBits(t){const i=t.length+7>>>3,o=new Uint8Array(i+2);o[0]=Ke.VECTOR_TYPE.PackedBit;const l=t.length%8;o[1]=l===0?0:8-l;for(let u=0;u<t.length;u++){const c=u>>>3,d=t[u];if(d!==0&&d!==1)throw new pe(`Invalid bit value at ${u}: must be 0 or 1, found ${t[u]}`);if(d===0)continue;const m=7-u%8;o[c+2]|=d<<m}return new this(o,Ke.SUBTYPE_VECTOR)}}function xi(e){if(e.sub_type!==Ke.SUBTYPE_VECTOR)return;const t=e.position,i=e.buffer[0],o=e.buffer[1];if((i===Ke.VECTOR_TYPE.Float32||i===Ke.VECTOR_TYPE.Int8)&&o!==0)throw new pe("Invalid Vector: padding must be zero for int8 and float32 vectors");if(i===Ke.VECTOR_TYPE.Float32&&t!==0&&t-2!==0&&(t-2)%4!==0)throw new pe("Invalid Vector: Float32 vector must contain a multiple of 4 bytes");if(i===Ke.VECTOR_TYPE.PackedBit&&o!==0&&t===2)throw new pe("Invalid Vector: padding must be zero for packed bit vectors that are empty");if(i===Ke.VECTOR_TYPE.PackedBit&&o>7)throw new pe(`Invalid Vector: padding must be a value between 0 and 7. found: ${o}`)}const rh=16,UM=/^[0-9A-F]{32}$/i,LM=/^[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$/i;class xn extends Ke{constructor(t){let i;if(t==null)i=xn.generate();else if(t instanceof xn)i=_e.toLocalBufferType(new Uint8Array(t.buffer));else if(ArrayBuffer.isView(t)&&t.byteLength===rh)i=_e.toLocalBufferType(t);else if(typeof t=="string")i=xn.bytesFromString(t);else throw new pe("Argument passed in UUID constructor must be a UUID, a 16 byte Buffer or a 32/36 character hex string (dashes excluded/included, format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).");super(i,Nb)}get id(){return this.buffer}set id(t){this.buffer=t}toHexString(t=!0){return t?[_e.toHex(this.buffer.subarray(0,4)),_e.toHex(this.buffer.subarray(4,6)),_e.toHex(this.buffer.subarray(6,8)),_e.toHex(this.buffer.subarray(8,10)),_e.toHex(this.buffer.subarray(10,16))].join("-"):_e.toHex(this.buffer)}toString(t){return t==="hex"?_e.toHex(this.id):t==="base64"?_e.toBase64(this.id):this.toHexString()}toJSON(){return this.toHexString()}equals(t){if(!t)return!1;if(t instanceof xn)return _e.equals(t.id,this.id);try{return _e.equals(new xn(t).id,this.id)}catch{return!1}}toBinary(){return new Ke(this.id,Ke.SUBTYPE_UUID)}static generate(){const t=_e.randomBytes(rh);return t[6]=t[6]&15|64,t[8]=t[8]&63|128,t}static isValid(t){return t?typeof t=="string"?xn.isValidUUIDString(t):Ab(t)?t.byteLength===rh:t._bsontype==="Binary"&&t.sub_type===this.SUBTYPE_UUID&&t.buffer.byteLength===16:!1}static createFromHexString(t){const i=xn.bytesFromString(t);return new xn(i)}static createFromBase64(t){return new xn(_e.fromBase64(t))}static bytesFromString(t){if(!xn.isValidUUIDString(t))throw new pe("UUID string representation must be 32 hex digits or canonical hyphenated representation");return _e.fromHex(t.replace(/-/g,""))}static isValidUUIDString(t){return UM.test(t)||LM.test(t)}inspect(t,i,o){return o??=jn,`new UUID(${o(this.toHexString(),i)})`}}class Rl extends er{get _bsontype(){return"Code"}code;scope;constructor(t,i){super(),this.code=t.toString(),this.scope=i??null}toJSON(){return this.scope!=null?{code:this.code,scope:this.scope}:{code:this.code}}toExtendedJSON(){return this.scope?{$code:this.code,$scope:this.scope}:{$code:this.code}}static fromExtendedJSON(t){return new Rl(t.$code,t.$scope)}inspect(t,i,o){o??=jn;let l=o(this.code,i);const u=l.includes(`
|
|
160
|
+
`},l),u}function a5(e,t){return e&&"run"in e?async function(i,o){const l=fb(i,{file:o,...t});await e.run(l,o)}:function(i,o){return fb(i,{file:o,...e||t})}}function db(e){if(e)throw e}var Ud,hb;function l5(){if(hb)return Ud;hb=1;var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,i=Object.defineProperty,o=Object.getOwnPropertyDescriptor,l=function(p){return typeof Array.isArray=="function"?Array.isArray(p):t.call(p)==="[object Array]"},u=function(p){if(!p||t.call(p)!=="[object Object]")return!1;var g=e.call(p,"constructor"),y=p.constructor&&p.constructor.prototype&&e.call(p.constructor.prototype,"isPrototypeOf");if(p.constructor&&!g&&!y)return!1;var v;for(v in p);return typeof v>"u"||e.call(p,v)},c=function(p,g){i&&g.name==="__proto__"?i(p,g.name,{enumerable:!0,configurable:!0,value:g.newValue,writable:!0}):p[g.name]=g.newValue},d=function(p,g){if(g==="__proto__")if(e.call(p,g)){if(o)return o(p,g).value}else return;return p[g]};return Ud=function m(){var p,g,y,v,S,E,w=arguments[0],R=1,k=arguments.length,I=!1;for(typeof w=="boolean"&&(I=w,w=arguments[1]||{},R=2),(w==null||typeof w!="object"&&typeof w!="function")&&(w={});R<k;++R)if(p=arguments[R],p!=null)for(g in p)y=d(w,g),v=d(p,g),w!==v&&(I&&v&&(u(v)||(S=l(v)))?(S?(S=!1,E=y&&l(y)?y:[]):E=y&&u(y)?y:{},c(w,{name:g,newValue:m(I,E,v)})):typeof v<"u"&&c(w,{name:g,newValue:v}));return w},Ud}var s5=l5();const Ld=Es(s5);function jd(e){if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function u5(){const e=[],t={run:i,use:o};return t;function i(...l){let u=-1;const c=l.pop();if(typeof c!="function")throw new TypeError("Expected function as last argument, not "+c);d(null,...l);function d(m,...p){const g=e[++u];let y=-1;if(m){c(m);return}for(;++y<l.length;)(p[y]===null||p[y]===void 0)&&(p[y]=l[y]);l=p,g?c5(g,d)(...p):c(null,...p)}}function o(l){if(typeof l!="function")throw new TypeError("Expected `middelware` to be a function, not "+l);return e.push(l),t}}function c5(e,t){let i;return o;function o(...c){const d=e.length>c.length;let m;d&&c.push(l);try{m=e.apply(this,c)}catch(p){const g=p;if(d&&i)throw g;return l(g)}d||(m&&m.then&&typeof m.then=="function"?m.then(u,l):m instanceof Error?l(m):u(m))}function l(c,...d){i||(i=!0,t(c,...d))}function u(c){l(null,c)}}const Ir={basename:f5,dirname:d5,extname:h5,join:p5,sep:"/"};function f5(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');Tl(e);let i=0,o=-1,l=e.length,u;if(t===void 0||t.length===0||t.length>e.length){for(;l--;)if(e.codePointAt(l)===47){if(u){i=l+1;break}}else o<0&&(u=!0,o=l+1);return o<0?"":e.slice(i,o)}if(t===e)return"";let c=-1,d=t.length-1;for(;l--;)if(e.codePointAt(l)===47){if(u){i=l+1;break}}else c<0&&(u=!0,c=l+1),d>-1&&(e.codePointAt(l)===t.codePointAt(d--)?d<0&&(o=l):(d=-1,o=c));return i===o?o=c:o<0&&(o=e.length),e.slice(i,o)}function d5(e){if(Tl(e),e.length===0)return".";let t=-1,i=e.length,o;for(;--i;)if(e.codePointAt(i)===47){if(o){t=i;break}}else o||(o=!0);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function h5(e){Tl(e);let t=e.length,i=-1,o=0,l=-1,u=0,c;for(;t--;){const d=e.codePointAt(t);if(d===47){if(c){o=t+1;break}continue}i<0&&(c=!0,i=t+1),d===46?l<0?l=t:u!==1&&(u=1):l>-1&&(u=-1)}return l<0||i<0||u===0||u===1&&l===i-1&&l===o+1?"":e.slice(l,i)}function p5(...e){let t=-1,i;for(;++t<e.length;)Tl(e[t]),e[t]&&(i=i===void 0?e[t]:i+"/"+e[t]);return i===void 0?".":m5(i)}function m5(e){Tl(e);const t=e.codePointAt(0)===47;let i=g5(e,!t);return i.length===0&&!t&&(i="."),i.length>0&&e.codePointAt(e.length-1)===47&&(i+="/"),t?"/"+i:i}function g5(e,t){let i="",o=0,l=-1,u=0,c=-1,d,m;for(;++c<=e.length;){if(c<e.length)d=e.codePointAt(c);else{if(d===47)break;d=47}if(d===47){if(!(l===c-1||u===1))if(l!==c-1&&u===2){if(i.length<2||o!==2||i.codePointAt(i.length-1)!==46||i.codePointAt(i.length-2)!==46){if(i.length>2){if(m=i.lastIndexOf("/"),m!==i.length-1){m<0?(i="",o=0):(i=i.slice(0,m),o=i.length-1-i.lastIndexOf("/")),l=c,u=0;continue}}else if(i.length>0){i="",o=0,l=c,u=0;continue}}t&&(i=i.length>0?i+"/..":"..",o=2)}else i.length>0?i+="/"+e.slice(l+1,c):i=e.slice(l+1,c),o=c-l-1;l=c,u=0}else d===46&&u>-1?u++:u=-1}return i}function Tl(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const y5={cwd:b5};function b5(){return"/"}function Pd(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function S5(e){if(typeof e=="string")e=new URL(e);else if(!Pd(e)){const t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if(e.protocol!=="file:"){const t=new TypeError("The URL must be of scheme file");throw t.code="ERR_INVALID_URL_SCHEME",t}return v5(e)}function v5(e){if(e.hostname!==""){const o=new TypeError('File URL host must be "localhost" or empty on darwin');throw o.code="ERR_INVALID_FILE_URL_HOST",o}const t=e.pathname;let i=-1;for(;++i<t.length;)if(t.codePointAt(i)===37&&t.codePointAt(i+1)===50){const o=t.codePointAt(i+2);if(o===70||o===102){const l=new TypeError("File URL path must not include encoded / characters");throw l.code="ERR_INVALID_FILE_URL_PATH",l}}return decodeURIComponent(t)}const Hd=["history","path","basename","stem","extname","dirname"];class pb{constructor(t){let i;t?Pd(t)?i={path:t}:typeof t=="string"||x5(t)?i={value:t}:i=t:i={},this.cwd="cwd"in i?"":y5.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let o=-1;for(;++o<Hd.length;){const u=Hd[o];u in i&&i[u]!==void 0&&i[u]!==null&&(this[u]=u==="history"?[...i[u]]:i[u])}let l;for(l in i)Hd.includes(l)||(this[l]=i[l])}get basename(){return typeof this.path=="string"?Ir.basename(this.path):void 0}set basename(t){Vd(t,"basename"),qd(t,"basename"),this.path=Ir.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?Ir.dirname(this.path):void 0}set dirname(t){mb(this.basename,"dirname"),this.path=Ir.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?Ir.extname(this.path):void 0}set extname(t){if(qd(t,"extname"),mb(this.dirname,"extname"),t){if(t.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(t.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=Ir.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){Pd(t)&&(t=S5(t)),Vd(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?Ir.basename(this.path,this.extname):void 0}set stem(t){Vd(t,"stem"),qd(t,"stem"),this.path=Ir.join(this.dirname||"",t+(this.extname||""))}fail(t,i,o){const l=this.message(t,i,o);throw l.fatal=!0,l}info(t,i,o){const l=this.message(t,i,o);return l.fatal=void 0,l}message(t,i,o){const l=new bn(t,i,o);return this.path&&(l.name=this.path+":"+l.name,l.file=this.path),l.fatal=!1,this.messages.push(l),l}toString(t){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(t||void 0).decode(this.value)}}function qd(e,t){if(e&&e.includes(Ir.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+Ir.sep+"`")}function Vd(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function mb(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function x5(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const w5=(function(e){const o=this.constructor.prototype,l=o[e],u=function(){return l.apply(u,arguments)};return Object.setPrototypeOf(u,o),u}),C5={}.hasOwnProperty;class Fd extends w5{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=u5()}copy(){const t=new Fd;let i=-1;for(;++i<this.attachers.length;){const o=this.attachers[i];t.use(...o)}return t.data(Ld(!0,{},this.namespace)),t}data(t,i){return typeof t=="string"?arguments.length===2?(Xd("data",this.frozen),this.namespace[t]=i,this):C5.call(this.namespace,t)&&this.namespace[t]||void 0:t?(Xd("data",this.frozen),this.namespace=t,this):this.namespace}freeze(){if(this.frozen)return this;const t=this;for(;++this.freezeIndex<this.attachers.length;){const[i,...o]=this.attachers[this.freezeIndex];if(o[0]===!1)continue;o[0]===!0&&(o[0]=void 0);const l=i.call(t,...o);typeof l=="function"&&this.transformers.use(l)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(t){this.freeze();const i=Eu(t),o=this.parser||this.Parser;return Yd("parse",o),o(String(i),i)}process(t,i){const o=this;return this.freeze(),Yd("process",this.parser||this.Parser),Gd("process",this.compiler||this.Compiler),i?l(void 0,i):new Promise(l);function l(u,c){const d=Eu(t),m=o.parse(d);o.run(m,d,function(g,y,v){if(g||!y||!v)return p(g);const S=y,E=o.stringify(S,v);_5(E)?v.value=E:v.result=E,p(g,v)});function p(g,y){g||!y?c(g):u?u(y):i(void 0,y)}}}processSync(t){let i=!1,o;return this.freeze(),Yd("processSync",this.parser||this.Parser),Gd("processSync",this.compiler||this.Compiler),this.process(t,l),yb("processSync","process",i),o;function l(u,c){i=!0,db(u),o=c}}run(t,i,o){gb(t),this.freeze();const l=this.transformers;return!o&&typeof i=="function"&&(o=i,i=void 0),o?u(void 0,o):new Promise(u);function u(c,d){const m=Eu(i);l.run(t,m,p);function p(g,y,v){const S=y||t;g?d(g):c?c(S):o(void 0,S,v)}}}runSync(t,i){let o=!1,l;return this.run(t,i,u),yb("runSync","run",o),l;function u(c,d){db(c),l=d,o=!0}}stringify(t,i){this.freeze();const o=Eu(i),l=this.compiler||this.Compiler;return Gd("stringify",l),gb(t),l(t,o)}use(t,...i){const o=this.attachers,l=this.namespace;if(Xd("use",this.frozen),t!=null)if(typeof t=="function")m(t,i);else if(typeof t=="object")Array.isArray(t)?d(t):c(t);else throw new TypeError("Expected usable value, not `"+t+"`");return this;function u(p){if(typeof p=="function")m(p,[]);else if(typeof p=="object")if(Array.isArray(p)){const[g,...y]=p;m(g,y)}else c(p);else throw new TypeError("Expected usable value, not `"+p+"`")}function c(p){if(!("plugins"in p)&&!("settings"in p))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");d(p.plugins),p.settings&&(l.settings=Ld(!0,l.settings,p.settings))}function d(p){let g=-1;if(p!=null)if(Array.isArray(p))for(;++g<p.length;){const y=p[g];u(y)}else throw new TypeError("Expected a list of plugins, not `"+p+"`")}function m(p,g){let y=-1,v=-1;for(;++y<o.length;)if(o[y][0]===p){v=y;break}if(v===-1)o.push([p,...g]);else if(g.length>0){let[S,...E]=g;const w=o[v][1];jd(w)&&jd(S)&&(S=Ld(!0,w,S)),o[v]=[p,S,...E]}}}}const E5=new Fd().freeze();function Yd(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function Gd(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function Xd(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function gb(e){if(!jd(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function yb(e,t,i){if(!i)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function Eu(e){return T5(e)?e:new pb(e)}function T5(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function _5(e){return typeof e=="string"||A5(e)}function A5(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const k5="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",bb=[],Sb={allowDangerousHtml:!0},R5=/^(https?|ircs?|mailto|xmpp)$/i,O5=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function M5(e){const t=N5(e),i=z5(e);return B5(t.runSync(t.parse(i),i),e)}function N5(e){const t=e.rehypePlugins||bb,i=e.remarkPlugins||bb,o=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...Sb}:Sb;return E5().use(f3).use(i).use(a5,o).use(t)}function z5(e){const t=e.children||"",i=new pb;return typeof t=="string"&&(i.value=t),i}function B5(e,t){const i=t.allowedElements,o=t.allowElement,l=t.components,u=t.disallowedElements,c=t.skipHtml,d=t.unwrapDisallowed,m=t.urlTransform||D5;for(const g of O5)Object.hasOwn(t,g.from)&&(""+g.from+(g.to?"use `"+g.to+"` instead":"remove it")+k5+g.id,void 0);return ub(e,p),Jk(e,{Fragment:Y.Fragment,components:l,ignoreInvalidStyle:!0,jsx:Y.jsx,jsxs:Y.jsxs,passKeys:!0,passNode:!0});function p(g,y,v){if(g.type==="raw"&&v&&typeof y=="number")return c?v.children.splice(y,1):v.children[y]={type:"text",value:g.value},y;if(g.type==="element"){let S;for(S in Ed)if(Object.hasOwn(Ed,S)&&Object.hasOwn(g.properties,S)){const E=g.properties[S],w=Ed[S];(w===null||w.includes(g.tagName))&&(g.properties[S]=m(String(E||""),S,g))}}if(g.type==="element"){let S=i?!i.includes(g.tagName):u?u.includes(g.tagName):!1;if(!S&&o&&typeof y=="number"&&(S=!o(g,y,v)),S&&v&&typeof y=="number")return d&&g.children?v.children.splice(y,1,...g.children):v.children.splice(y,1),y}}}function D5(e){const t=e.indexOf(":"),i=e.indexOf("?"),o=e.indexOf("#"),l=e.indexOf("/");return t===-1||l!==-1&&t>l||i!==-1&&t>i||o!==-1&&t>o||R5.test(e.slice(0,t))?e:""}function I5(){if(typeof document>"u"||document.querySelector('meta[name="viewport"]'))return;const t=document.createElement("meta");t.name="viewport",t.content="width=device-width, initial-scale=1",document.head.appendChild(t)}function $5(){O.useEffect(()=>{const e=()=>{const t=window.innerHeight*.01;document.documentElement.style.setProperty("--vh",`${t}px`)};return e(),window.addEventListener("resize",e),window.addEventListener("orientationchange",e),()=>{window.removeEventListener("resize",e),window.removeEventListener("orientationchange",e)}},[])}function U5({open:e,setOpen:t,msgs:i,input:o,setInput:l,sending:u,send:c,anchorSx:d,conversationMode:m}){const p=O.useRef(null),g=O.useRef(null),y=al(),v=fk(y.breakpoints.down("md"));$5(),O.useEffect(()=>{g.current?.scrollIntoView({behavior:"smooth",block:"end"}),requestAnimationFrame(()=>p.current?.focus())},[i.length,u]),O.useEffect(()=>{e&&g.current?.scrollIntoView({behavior:"auto",block:"end"})},[e]),O.useEffect(()=>{if(!(e&&v))return;const w=window.scrollY;return document.body.style.position="fixed",document.body.style.top=`-${w}px`,document.body.style.left="0",document.body.style.right="0",document.body.style.width="100%",()=>{document.body.style.position="",document.body.style.top="",document.body.style.left="",document.body.style.right="",document.body.style.width="",window.scrollTo(0,w)}},[e,v]);const S=O.useCallback((w,R,k,I)=>{const M=w===k.length-1,_=k[k.length-1],z=M&&R&&_?.seen,T=z&&_?.id===I.id;return{showSeenIndicator:z,isSeen:T}},[]),E=w=>w==="AI"?"Răspunde automat":w==="Human"?"In conversatie cu un operator":w==="Disconnected"?"Conexiune pierduta. Reincarcati pagina!":w==="Ended"?"Conversație închisă":"Conversație nouă";return Y.jsxs(tn,{sx:d,children:[!e&&Y.jsx(b_,{variant:"contained",onClick:()=>t(!0),startIcon:Y.jsx(Ck,{}),sx:{borderRadius:999,px:2,py:1,textTransform:"none",boxShadow:"0 10px 30px rgba(0,0,0,.18)"},children:"Chat"}),e&&Y.jsx(yy,{elevation:v?0:10,sx:{width:v?"100vw":380,height:v?"calc(var(--vh, 1vh) * 100)":560,"@supports (height: 100dvh)":{height:v?"100dvh":560},maxWidth:"100vw",maxHeight:"100dvh",borderRadius:v?0:4,position:v?"fixed":"relative",inset:v?0:"auto",overflow:"hidden",border:v?"none":"1px solid",borderColor:"divider",boxShadow:v?"none":"0 18px 60px rgba(0,0,0,.28)"},children:Y.jsxs(tn,{sx:{display:"flex",flexDirection:"column",height:"100%"},children:[Y.jsxs(tn,{sx:{px:1.75,py:1.25,display:"flex",alignItems:"center",gap:1,borderBottom:"1px solid",borderColor:"divider",background:"linear-gradient(135deg, rgba(25,118,210,.18), rgba(156,39,176,.14))",backdropFilter:v?"none":"blur(10px)"},children:[Y.jsx(l_,{overlap:"circular",variant:"dot",color:m!="Disconnected"?"success":"error",sx:{"& .MuiBadge-badge":{width:10,height:10,borderRadius:999,border:"2px solid",borderColor:"background.paper"}},children:Y.jsx(su,{sx:{bgcolor:"primary.main"},children:Y.jsx(fd,{})})}),Y.jsxs(tn,{sx:{flex:1,minWidth:0},children:[Y.jsx(Lo,{variant:"subtitle1",sx:{fontWeight:700,lineHeight:1.1},children:"Asistent"}),Y.jsx(Lo,{variant:"caption",sx:{color:"text.secondary"},children:E(m)})]}),Y.jsx(xy,{size:"small",onClick:()=>t(!1),sx:{bgcolor:"rgba(255,255,255,.55)",border:"1px solid",borderColor:"divider","&:hover":{bgcolor:"rgba(255,255,255,.75)"}},children:Y.jsx(xk,{fontSize:"small"})})]}),Y.jsxs(tn,{sx:{display:"flex",flexDirection:"column",flex:1,minHeight:0,overflow:"auto",px:1.5,pt:1.5,backgroundImage:"radial-gradient(circle at 20% 10%, rgba(25,118,210,.10), transparent 45%),radial-gradient(circle at 80% 20%, rgba(156,39,176,.10), transparent 50%),radial-gradient(circle at 40% 90%, rgba(0,200,83,.08), transparent 45%)","&::-webkit-scrollbar":{width:10},"&::-webkit-scrollbar-thumb":{backgroundColor:"rgba(0,0,0,.18)",borderRadius:999,border:"3px solid transparent",backgroundClip:"content-box"}},children:[Y.jsx(L5,{msgs:i,isMessageSeen:S}),Y.jsx("div",{style:{paddingBottom:2},children:u&&Y.jsxs(tn,{sx:{display:"flex",alignItems:"flex-end",gap:1,mb:1.2},children:[Y.jsx(su,{sx:{width:30,height:30,bgcolor:"primary.main"},children:Y.jsx(fd,{sx:{fontSize:18}})}),Y.jsxs(tn,{sx:{px:1.4,py:1.1,borderRadius:3,border:"1px solid",borderColor:"divider",bgcolor:"background.paper",boxShadow:"0 10px 30px rgba(0,0,0,.10)",display:"flex",alignItems:"center",gap:.6},children:[Y.jsx(tn,{sx:{width:6,height:6,borderRadius:999,bgcolor:"text.secondary",animation:"dot 1.1s infinite ease-in-out","@keyframes dot":{"0%, 80%, 100%":{transform:"scale(0.6)",opacity:.4},"40%":{transform:"scale(1)",opacity:1}}}}),Y.jsx(tn,{sx:{width:6,height:6,borderRadius:999,bgcolor:"text.secondary",animation:"dot 1.1s infinite ease-in-out",animationDelay:"0.15s","@keyframes dot":{"0%, 80%, 100%":{transform:"scale(0.6)",opacity:.4},"40%":{transform:"scale(1)",opacity:1}}}}),Y.jsx(tn,{sx:{width:6,height:6,borderRadius:999,bgcolor:"text.secondary",animation:"dot 1.1s infinite ease-in-out",animationDelay:"0.3s","@keyframes dot":{"0%, 80%, 100%":{transform:"scale(0.6)",opacity:.4},"40%":{transform:"scale(1)",opacity:1}}}})]})]})}),Y.jsx(SA,{ref:g,href:"https://x-bot.ro",target:"_blank",rel:"noreferrer",underline:"none",sx:{pb:1,marginTop:"auto",alignSelf:"center",fontSize:12,color:"text.secondary",opacity:.75,"&:hover":{opacity:1,color:"text.primary"},justifyContent:"center"},children:"Chat oferit de X-bot.ro"})]}),Y.jsx(tn,{sx:{p:1.25,borderTop:"1px solid",borderColor:"divider",display:"flex",gap:1,bgcolor:"background.paper",flexShrink:0},children:Y.jsx(ck,{inputRef:p,focused:!0,size:"small",fullWidth:!0,value:o,disabled:u||o.length>=dk,onChange:w=>l(w.target.value),onKeyDown:w=>{w.key==="Enter"&&!w.shiftKey&&(w.preventDefault(),c())},placeholder:"Scrie un mesaj",multiline:!0,maxRows:4,sx:{"& .MuiOutlinedInput-root":{borderRadius:3,pr:.75,backgroundColor:"rgba(0,0,0,.02)"}},InputProps:{endAdornment:Y.jsx(xy,{size:"small",onClick:c,disabled:u||!o.trim(),sx:{ml:.5,borderRadius:999},children:Y.jsx(wk,{})})}})})]})})]})}const L5=dr.memo(function({msgs:t,isMessageSeen:i,endRef:o}){return Y.jsxs(Y.Fragment,{children:[t.map((l,u)=>{const c=l.role==="User",{showSeenIndicator:d,isSeen:m}=i(u,c,t,l);return Y.jsxs(tn,{sx:{display:"flex",justifyContent:c?"flex-end":"flex-start",gap:1,mb:1.2,overflowAnchor:"none"},children:[!c&&Y.jsxs(tn,{children:[Y.jsx(su,{sx:{width:30,height:30,mt:.25,bgcolor:"primary.main"},children:Y.jsx(fd,{sx:{fontSize:18}})}),l.sentAt&&Y.jsx(tn,{sx:{display:"flex",justifyContent:c?"flex-end":"flex-start",mt:.5},children:Y.jsx(Lo,{variant:"caption",sx:{color:"text.secondary",fontSize:11},children:l.sentAt})})]},"asistent"+l.id),Y.jsxs(tn,{sx:{maxWidth:"78%"},children:[Y.jsx(tn,{sx:{wordBreak:"break-word",position:"relative",px:1.4,py:1.05,borderRadius:3,border:"1px solid",borderColor:"divider",bgcolor:c?"primary.main":"background.paper",color:c?"primary.contrastText":"text.primary",boxShadow:c?"0 10px 30px rgba(25,118,210,.22)":"0 10px 30px rgba(0,0,0,.10)",whiteSpace:"pre-wrap","&:before":{content:'""',position:"absolute",top:14,width:10,height:10,transform:"rotate(45deg)",bgcolor:c?"primary.main":"background.paper",borderLeft:c?"none":"1px solid",borderTop:c?"none":"1px solid",borderColor:"divider",right:c?-5:"auto",left:c?"auto":-5},"& p":{margin:0},"& a":{color:"inherit",textDecoration:"underline"},"& code":{fontFamily:"ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace",fontSize:"0.9em",padding:"2px 6px",borderRadius:8,backgroundColor:c?"rgba(255,255,255,.14)":"rgba(0,0,0,.06)"},"& pre":{margin:0,marginTop:8,padding:12,overflow:"auto",borderRadius:12,backgroundColor:c?"rgba(255,255,255,.12)":"rgba(0,0,0,.05)"}},children:Y.jsx(M5,{children:l.text},"message"+l.id)}),d?Y.jsx(Lo,{sx:{mt:.35,fontSize:12,textAlign:"right",color:m?"text.secondary":"text.disabled"},children:m?"Seen":"Sent"}):null]},"container"+l.id),Y.jsx(tn,{children:c&&Y.jsxs(tn,{children:[Y.jsx(su,{sx:{width:30,height:30,mt:.25,bgcolor:"grey.900"},children:Y.jsx(Ek,{sx:{fontSize:18}})}),l.sentAt&&Y.jsx(tn,{sx:{display:"flex",justifyContent:c?"flex-end":"flex-start",mt:.5},children:Y.jsx(Lo,{variant:"caption",sx:{color:"text.secondary",fontSize:11},children:l.sentAt})})]},"sentad"+l.id)})]},l.id)}),Y.jsx("div",{ref:o})]})});class ro extends Error{constructor(t,i){const o=new.target.prototype;super(`${t}: Status code '${i}'`),this.statusCode=i,this.__proto__=o}}class Kd extends Error{constructor(t="A timeout occurred."){const i=new.target.prototype;super(t),this.__proto__=i}}class br extends Error{constructor(t="An abort occurred."){const i=new.target.prototype;super(t),this.__proto__=i}}class j5 extends Error{constructor(t,i){const o=new.target.prototype;super(t),this.transport=i,this.errorType="UnsupportedTransportError",this.__proto__=o}}class P5 extends Error{constructor(t,i){const o=new.target.prototype;super(t),this.transport=i,this.errorType="DisabledTransportError",this.__proto__=o}}class H5 extends Error{constructor(t,i){const o=new.target.prototype;super(t),this.transport=i,this.errorType="FailedToStartTransportError",this.__proto__=o}}class vb extends Error{constructor(t){const i=new.target.prototype;super(t),this.errorType="FailedToNegotiateWithServerError",this.__proto__=i}}class q5 extends Error{constructor(t,i){const o=new.target.prototype;super(t),this.innerErrors=i,this.__proto__=o}}class xb{constructor(t,i,o){this.statusCode=t,this.statusText=i,this.content=o}}class Tu{get(t,i){return this.send({...i,method:"GET",url:t})}post(t,i){return this.send({...i,method:"POST",url:t})}delete(t,i){return this.send({...i,method:"DELETE",url:t})}getCookieString(t){return""}}var ae;(function(e){e[e.Trace=0]="Trace",e[e.Debug=1]="Debug",e[e.Information=2]="Information",e[e.Warning=3]="Warning",e[e.Error=4]="Error",e[e.Critical=5]="Critical",e[e.None=6]="None"})(ae||(ae={}));class _l{constructor(){}log(t,i){}}_l.instance=new _l;const V5="10.0.0";class Kt{static isRequired(t,i){if(t==null)throw new Error(`The '${i}' argument is required.`)}static isNotEmpty(t,i){if(!t||t.match(/^\s*$/))throw new Error(`The '${i}' argument should not be empty.`)}static isIn(t,i,o){if(!(t in i))throw new Error(`Unknown ${o} value: ${t}.`)}}class Mt{static get isBrowser(){return!Mt.isNode&&typeof window=="object"&&typeof window.document=="object"}static get isWebWorker(){return!Mt.isNode&&typeof self=="object"&&"importScripts"in self}static get isReactNative(){return!Mt.isNode&&typeof window=="object"&&typeof window.document>"u"}static get isNode(){return typeof process<"u"&&process.release&&process.release.name==="node"}}function Al(e,t){let i="";return io(e)?(i=`Binary data of length ${e.byteLength}`,t&&(i+=`. Content: '${F5(e)}'`)):typeof e=="string"&&(i=`String data of length ${e.length}`,t&&(i+=`. Content: '${e}'`)),i}function F5(e){const t=new Uint8Array(e);let i="";return t.forEach(o=>{const l=o<16?"0":"";i+=`0x${l}${o.toString(16)} `}),i.substring(0,i.length-1)}function io(e){return e&&typeof ArrayBuffer<"u"&&(e instanceof ArrayBuffer||e.constructor&&e.constructor.name==="ArrayBuffer")}async function wb(e,t,i,o,l,u){const c={},[d,m]=Ko();c[d]=m,e.log(ae.Trace,`(${t} transport) sending data. ${Al(l,u.logMessageContent)}.`);const p=io(l)?"arraybuffer":"text",g=await i.post(o,{content:l,headers:{...c,...u.headers},responseType:p,timeout:u.timeout,withCredentials:u.withCredentials});e.log(ae.Trace,`(${t} transport) request complete. Response status: ${g.statusCode}.`)}function Y5(e){return e===void 0?new _u(ae.Information):e===null?_l.instance:e.log!==void 0?e:new _u(e)}class G5{constructor(t,i){this._subject=t,this._observer=i}dispose(){const t=this._subject.observers.indexOf(this._observer);t>-1&&this._subject.observers.splice(t,1),this._subject.observers.length===0&&this._subject.cancelCallback&&this._subject.cancelCallback().catch(i=>{})}}class _u{constructor(t){this._minLevel=t,this.out=console}log(t,i){if(t>=this._minLevel){const o=`[${new Date().toISOString()}] ${ae[t]}: ${i}`;switch(t){case ae.Critical:case ae.Error:this.out.error(o);break;case ae.Warning:this.out.warn(o);break;case ae.Information:this.out.info(o);break;default:this.out.log(o);break}}}}function Ko(){let e="X-SignalR-User-Agent";return Mt.isNode&&(e="User-Agent"),[e,X5(V5,K5(),Z5(),Q5())]}function X5(e,t,i,o){let l="Microsoft SignalR/";const u=e.split(".");return l+=`${u[0]}.${u[1]}`,l+=` (${e}; `,t&&t!==""?l+=`${t}; `:l+="Unknown OS; ",l+=`${i}`,o?l+=`; ${o}`:l+="; Unknown Runtime Version",l+=")",l}function K5(){if(Mt.isNode)switch(process.platform){case"win32":return"Windows NT";case"darwin":return"macOS";case"linux":return"Linux";default:return process.platform}else return""}function Q5(){if(Mt.isNode)return process.versions.node}function Z5(){return Mt.isNode?"NodeJS":"Browser"}function Qd(e){return e.stack?e.stack:e.message?e.message:`${e}`}function W5(){if(typeof globalThis<"u")return globalThis;if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof global<"u")return global;throw new Error("could not find global")}class J5 extends Tu{constructor(t){if(super(),this._logger=t,typeof fetch>"u"||Mt.isNode){const i=typeof __webpack_require__=="function"?__non_webpack_require__:require;this._jar=new(i("tough-cookie")).CookieJar,typeof fetch>"u"?this._fetchType=i("node-fetch"):this._fetchType=fetch,this._fetchType=i("fetch-cookie")(this._fetchType,this._jar)}else this._fetchType=fetch.bind(W5());if(typeof AbortController>"u"){const i=typeof __webpack_require__=="function"?__non_webpack_require__:require;this._abortControllerType=i("abort-controller")}else this._abortControllerType=AbortController}async send(t){if(t.abortSignal&&t.abortSignal.aborted)throw new br;if(!t.method)throw new Error("No method defined.");if(!t.url)throw new Error("No url defined.");const i=new this._abortControllerType;let o;t.abortSignal&&(t.abortSignal.onabort=()=>{i.abort(),o=new br});let l=null;if(t.timeout){const m=t.timeout;l=setTimeout(()=>{i.abort(),this._logger.log(ae.Warning,"Timeout from HTTP request."),o=new Kd},m)}t.content===""&&(t.content=void 0),t.content&&(t.headers=t.headers||{},io(t.content)?t.headers["Content-Type"]="application/octet-stream":t.headers["Content-Type"]="text/plain;charset=UTF-8");let u;try{u=await this._fetchType(t.url,{body:t.content,cache:"no-cache",credentials:t.withCredentials===!0?"include":"same-origin",headers:{"X-Requested-With":"XMLHttpRequest",...t.headers},method:t.method,mode:"cors",redirect:"follow",signal:i.signal})}catch(m){throw o||(this._logger.log(ae.Warning,`Error from HTTP request. ${m}.`),m)}finally{l&&clearTimeout(l),t.abortSignal&&(t.abortSignal.onabort=null)}if(!u.ok){const m=await Cb(u,"text");throw new ro(m||u.statusText,u.status)}const d=await Cb(u,t.responseType);return new xb(u.status,u.statusText,d)}getCookieString(t){let i="";return Mt.isNode&&this._jar&&this._jar.getCookies(t,(o,l)=>i=l.join("; ")),i}}function Cb(e,t){let i;switch(t){case"arraybuffer":i=e.arrayBuffer();break;case"text":i=e.text();break;case"blob":case"document":case"json":throw new Error(`${t} is not supported.`);default:i=e.text();break}return i}class eM extends Tu{constructor(t){super(),this._logger=t}send(t){return t.abortSignal&&t.abortSignal.aborted?Promise.reject(new br):t.method?t.url?new Promise((i,o)=>{const l=new XMLHttpRequest;l.open(t.method,t.url,!0),l.withCredentials=t.withCredentials===void 0?!0:t.withCredentials,l.setRequestHeader("X-Requested-With","XMLHttpRequest"),t.content===""&&(t.content=void 0),t.content&&(io(t.content)?l.setRequestHeader("Content-Type","application/octet-stream"):l.setRequestHeader("Content-Type","text/plain;charset=UTF-8"));const u=t.headers;u&&Object.keys(u).forEach(c=>{l.setRequestHeader(c,u[c])}),t.responseType&&(l.responseType=t.responseType),t.abortSignal&&(t.abortSignal.onabort=()=>{l.abort(),o(new br)}),t.timeout&&(l.timeout=t.timeout),l.onload=()=>{t.abortSignal&&(t.abortSignal.onabort=null),l.status>=200&&l.status<300?i(new xb(l.status,l.statusText,l.response||l.responseText)):o(new ro(l.response||l.responseText||l.statusText,l.status))},l.onerror=()=>{this._logger.log(ae.Warning,`Error from HTTP request. ${l.status}: ${l.statusText}.`),o(new ro(l.statusText,l.status))},l.ontimeout=()=>{this._logger.log(ae.Warning,"Timeout from HTTP request."),o(new Kd)},l.send(t.content)}):Promise.reject(new Error("No url defined.")):Promise.reject(new Error("No method defined."))}}class tM extends Tu{constructor(t){if(super(),typeof fetch<"u"||Mt.isNode)this._httpClient=new J5(t);else if(typeof XMLHttpRequest<"u")this._httpClient=new eM(t);else throw new Error("No usable HttpClient found.")}send(t){return t.abortSignal&&t.abortSignal.aborted?Promise.reject(new br):t.method?t.url?this._httpClient.send(t):Promise.reject(new Error("No url defined.")):Promise.reject(new Error("No method defined."))}getCookieString(t){return this._httpClient.getCookieString(t)}}class Ln{static write(t){return`${t}${Ln.RecordSeparator}`}static parse(t){if(t[t.length-1]!==Ln.RecordSeparator)throw new Error("Message is incomplete.");const i=t.split(Ln.RecordSeparator);return i.pop(),i}}Ln.RecordSeparatorCode=30,Ln.RecordSeparator=String.fromCharCode(Ln.RecordSeparatorCode);class nM{writeHandshakeRequest(t){return Ln.write(JSON.stringify(t))}parseHandshakeResponse(t){let i,o;if(io(t)){const d=new Uint8Array(t),m=d.indexOf(Ln.RecordSeparatorCode);if(m===-1)throw new Error("Message is incomplete.");const p=m+1;i=String.fromCharCode.apply(null,Array.prototype.slice.call(d.slice(0,p))),o=d.byteLength>p?d.slice(p).buffer:null}else{const d=t,m=d.indexOf(Ln.RecordSeparator);if(m===-1)throw new Error("Message is incomplete.");const p=m+1;i=d.substring(0,p),o=d.length>p?d.substring(p):null}const l=Ln.parse(i),u=JSON.parse(l[0]);if(u.type)throw new Error("Expected a handshake response from the server.");return[o,u]}}var Be;(function(e){e[e.Invocation=1]="Invocation",e[e.StreamItem=2]="StreamItem",e[e.Completion=3]="Completion",e[e.StreamInvocation=4]="StreamInvocation",e[e.CancelInvocation=5]="CancelInvocation",e[e.Ping=6]="Ping",e[e.Close=7]="Close",e[e.Ack=8]="Ack",e[e.Sequence=9]="Sequence"})(Be||(Be={}));class rM{constructor(){this.observers=[]}next(t){for(const i of this.observers)i.next(t)}error(t){for(const i of this.observers)i.error&&i.error(t)}complete(){for(const t of this.observers)t.complete&&t.complete()}subscribe(t){return this.observers.push(t),new G5(this,t)}}class iM{constructor(t,i,o){this._bufferSize=1e5,this._messages=[],this._totalMessageCount=0,this._waitForSequenceMessage=!1,this._nextReceivingSequenceId=1,this._latestReceivedSequenceId=0,this._bufferedByteCount=0,this._reconnectInProgress=!1,this._protocol=t,this._connection=i,this._bufferSize=o}async _send(t){const i=this._protocol.writeMessage(t);let o=Promise.resolve();if(this._isInvocationMessage(t)){this._totalMessageCount++;let l=()=>{},u=()=>{};io(i)?this._bufferedByteCount+=i.byteLength:this._bufferedByteCount+=i.length,this._bufferedByteCount>=this._bufferSize&&(o=new Promise((c,d)=>{l=c,u=d})),this._messages.push(new oM(i,this._totalMessageCount,l,u))}try{this._reconnectInProgress||await this._connection.send(i)}catch{this._disconnected()}await o}_ack(t){let i=-1;for(let o=0;o<this._messages.length;o++){const l=this._messages[o];if(l._id<=t.sequenceId)i=o,io(l._message)?this._bufferedByteCount-=l._message.byteLength:this._bufferedByteCount-=l._message.length,l._resolver();else if(this._bufferedByteCount<this._bufferSize)l._resolver();else break}i!==-1&&(this._messages=this._messages.slice(i+1))}_shouldProcessMessage(t){if(this._waitForSequenceMessage)return t.type!==Be.Sequence?!1:(this._waitForSequenceMessage=!1,!0);if(!this._isInvocationMessage(t))return!0;const i=this._nextReceivingSequenceId;return this._nextReceivingSequenceId++,i<=this._latestReceivedSequenceId?(i===this._latestReceivedSequenceId&&this._ackTimer(),!1):(this._latestReceivedSequenceId=i,this._ackTimer(),!0)}_resetSequence(t){if(t.sequenceId>this._nextReceivingSequenceId){this._connection.stop(new Error("Sequence ID greater than amount of messages we've received."));return}this._nextReceivingSequenceId=t.sequenceId}_disconnected(){this._reconnectInProgress=!0,this._waitForSequenceMessage=!0}async _resend(){const t=this._messages.length!==0?this._messages[0]._id:this._totalMessageCount+1;await this._connection.send(this._protocol.writeMessage({type:Be.Sequence,sequenceId:t}));const i=this._messages;for(const o of i)await this._connection.send(o._message);this._reconnectInProgress=!1}_dispose(t){t??(t=new Error("Unable to reconnect to server."));for(const i of this._messages)i._rejector(t)}_isInvocationMessage(t){switch(t.type){case Be.Invocation:case Be.StreamItem:case Be.Completion:case Be.StreamInvocation:case Be.CancelInvocation:return!0;case Be.Close:case Be.Sequence:case Be.Ping:case Be.Ack:return!1}}_ackTimer(){this._ackTimerHandle===void 0&&(this._ackTimerHandle=setTimeout(async()=>{try{this._reconnectInProgress||await this._connection.send(this._protocol.writeMessage({type:Be.Ack,sequenceId:this._latestReceivedSequenceId}))}catch{}clearTimeout(this._ackTimerHandle),this._ackTimerHandle=void 0},1e3))}}class oM{constructor(t,i,o,l){this._message=t,this._id=i,this._resolver=o,this._rejector=l}}const aM=30*1e3,lM=15*1e3,sM=1e5;var ut;(function(e){e.Disconnected="Disconnected",e.Connecting="Connecting",e.Connected="Connected",e.Disconnecting="Disconnecting",e.Reconnecting="Reconnecting"})(ut||(ut={}));class Zd{static create(t,i,o,l,u,c,d){return new Zd(t,i,o,l,u,c,d)}constructor(t,i,o,l,u,c,d){this._nextKeepAlive=0,this._freezeEventListener=()=>{this._logger.log(ae.Warning,"The page is being frozen, this will likely lead to the connection being closed and messages being lost. For more information see the docs at https://learn.microsoft.com/aspnet/core/signalr/javascript-client#bsleep")},Kt.isRequired(t,"connection"),Kt.isRequired(i,"logger"),Kt.isRequired(o,"protocol"),this.serverTimeoutInMilliseconds=u??aM,this.keepAliveIntervalInMilliseconds=c??lM,this._statefulReconnectBufferSize=d??sM,this._logger=i,this._protocol=o,this.connection=t,this._reconnectPolicy=l,this._handshakeProtocol=new nM,this.connection.onreceive=m=>this._processIncomingData(m),this.connection.onclose=m=>this._connectionClosed(m),this._callbacks={},this._methods={},this._closedCallbacks=[],this._reconnectingCallbacks=[],this._reconnectedCallbacks=[],this._invocationId=0,this._receivedHandshakeResponse=!1,this._connectionState=ut.Disconnected,this._connectionStarted=!1,this._cachedPingMessage=this._protocol.writeMessage({type:Be.Ping})}get state(){return this._connectionState}get connectionId(){return this.connection&&this.connection.connectionId||null}get baseUrl(){return this.connection.baseUrl||""}set baseUrl(t){if(this._connectionState!==ut.Disconnected&&this._connectionState!==ut.Reconnecting)throw new Error("The HubConnection must be in the Disconnected or Reconnecting state to change the url.");if(!t)throw new Error("The HubConnection url must be a valid url.");this.connection.baseUrl=t}start(){return this._startPromise=this._startWithStateTransitions(),this._startPromise}async _startWithStateTransitions(){if(this._connectionState!==ut.Disconnected)return Promise.reject(new Error("Cannot start a HubConnection that is not in the 'Disconnected' state."));this._connectionState=ut.Connecting,this._logger.log(ae.Debug,"Starting HubConnection.");try{await this._startInternal(),Mt.isBrowser&&window.document.addEventListener("freeze",this._freezeEventListener),this._connectionState=ut.Connected,this._connectionStarted=!0,this._logger.log(ae.Debug,"HubConnection connected successfully.")}catch(t){return this._connectionState=ut.Disconnected,this._logger.log(ae.Debug,`HubConnection failed to start successfully because of error '${t}'.`),Promise.reject(t)}}async _startInternal(){this._stopDuringStartError=void 0,this._receivedHandshakeResponse=!1;const t=new Promise((i,o)=>{this._handshakeResolver=i,this._handshakeRejecter=o});await this.connection.start(this._protocol.transferFormat);try{let i=this._protocol.version;this.connection.features.reconnect||(i=1);const o={protocol:this._protocol.name,version:i};if(this._logger.log(ae.Debug,"Sending handshake request."),await this._sendMessage(this._handshakeProtocol.writeHandshakeRequest(o)),this._logger.log(ae.Information,`Using HubProtocol '${this._protocol.name}'.`),this._cleanupTimeout(),this._resetTimeoutPeriod(),this._resetKeepAliveInterval(),await t,this._stopDuringStartError)throw this._stopDuringStartError;(this.connection.features.reconnect||!1)&&(this._messageBuffer=new iM(this._protocol,this.connection,this._statefulReconnectBufferSize),this.connection.features.disconnected=this._messageBuffer._disconnected.bind(this._messageBuffer),this.connection.features.resend=()=>{if(this._messageBuffer)return this._messageBuffer._resend()}),this.connection.features.inherentKeepAlive||await this._sendMessage(this._cachedPingMessage)}catch(i){throw this._logger.log(ae.Debug,`Hub handshake failed with error '${i}' during start(). Stopping HubConnection.`),this._cleanupTimeout(),this._cleanupPingTimer(),await this.connection.stop(i),i}}async stop(){const t=this._startPromise;this.connection.features.reconnect=!1,this._stopPromise=this._stopInternal(),await this._stopPromise;try{await t}catch{}}_stopInternal(t){if(this._connectionState===ut.Disconnected)return this._logger.log(ae.Debug,`Call to HubConnection.stop(${t}) ignored because it is already in the disconnected state.`),Promise.resolve();if(this._connectionState===ut.Disconnecting)return this._logger.log(ae.Debug,`Call to HttpConnection.stop(${t}) ignored because the connection is already in the disconnecting state.`),this._stopPromise;const i=this._connectionState;return this._connectionState=ut.Disconnecting,this._logger.log(ae.Debug,"Stopping HubConnection."),this._reconnectDelayHandle?(this._logger.log(ae.Debug,"Connection stopped during reconnect delay. Done reconnecting."),clearTimeout(this._reconnectDelayHandle),this._reconnectDelayHandle=void 0,this._completeClose(),Promise.resolve()):(i===ut.Connected&&this._sendCloseMessage(),this._cleanupTimeout(),this._cleanupPingTimer(),this._stopDuringStartError=t||new br("The connection was stopped before the hub handshake could complete."),this.connection.stop(t))}async _sendCloseMessage(){try{await this._sendWithProtocol(this._createCloseMessage())}catch{}}stream(t,...i){const[o,l]=this._replaceStreamingParams(i),u=this._createStreamInvocation(t,i,l);let c;const d=new rM;return d.cancelCallback=()=>{const m=this._createCancelInvocation(u.invocationId);return delete this._callbacks[u.invocationId],c.then(()=>this._sendWithProtocol(m))},this._callbacks[u.invocationId]=(m,p)=>{if(p){d.error(p);return}else m&&(m.type===Be.Completion?m.error?d.error(new Error(m.error)):d.complete():d.next(m.item))},c=this._sendWithProtocol(u).catch(m=>{d.error(m),delete this._callbacks[u.invocationId]}),this._launchStreams(o,c),d}_sendMessage(t){return this._resetKeepAliveInterval(),this.connection.send(t)}_sendWithProtocol(t){return this._messageBuffer?this._messageBuffer._send(t):this._sendMessage(this._protocol.writeMessage(t))}send(t,...i){const[o,l]=this._replaceStreamingParams(i),u=this._sendWithProtocol(this._createInvocation(t,i,!0,l));return this._launchStreams(o,u),u}invoke(t,...i){const[o,l]=this._replaceStreamingParams(i),u=this._createInvocation(t,i,!1,l);return new Promise((d,m)=>{this._callbacks[u.invocationId]=(g,y)=>{if(y){m(y);return}else g&&(g.type===Be.Completion?g.error?m(new Error(g.error)):d(g.result):m(new Error(`Unexpected message type: ${g.type}`)))};const p=this._sendWithProtocol(u).catch(g=>{m(g),delete this._callbacks[u.invocationId]});this._launchStreams(o,p)})}on(t,i){!t||!i||(t=t.toLowerCase(),this._methods[t]||(this._methods[t]=[]),this._methods[t].indexOf(i)===-1&&this._methods[t].push(i))}off(t,i){if(!t)return;t=t.toLowerCase();const o=this._methods[t];if(o)if(i){const l=o.indexOf(i);l!==-1&&(o.splice(l,1),o.length===0&&delete this._methods[t])}else delete this._methods[t]}onclose(t){t&&this._closedCallbacks.push(t)}onreconnecting(t){t&&this._reconnectingCallbacks.push(t)}onreconnected(t){t&&this._reconnectedCallbacks.push(t)}_processIncomingData(t){if(this._cleanupTimeout(),this._receivedHandshakeResponse||(t=this._processHandshakeResponse(t),this._receivedHandshakeResponse=!0),t){const i=this._protocol.parseMessages(t,this._logger);for(const o of i)if(!(this._messageBuffer&&!this._messageBuffer._shouldProcessMessage(o)))switch(o.type){case Be.Invocation:this._invokeClientMethod(o).catch(l=>{this._logger.log(ae.Error,`Invoke client method threw error: ${Qd(l)}`)});break;case Be.StreamItem:case Be.Completion:{const l=this._callbacks[o.invocationId];if(l){o.type===Be.Completion&&delete this._callbacks[o.invocationId];try{l(o)}catch(u){this._logger.log(ae.Error,`Stream callback threw error: ${Qd(u)}`)}}break}case Be.Ping:break;case Be.Close:{this._logger.log(ae.Information,"Close message received from server.");const l=o.error?new Error("Server returned an error on close: "+o.error):void 0;o.allowReconnect===!0?this.connection.stop(l):this._stopPromise=this._stopInternal(l);break}case Be.Ack:this._messageBuffer&&this._messageBuffer._ack(o);break;case Be.Sequence:this._messageBuffer&&this._messageBuffer._resetSequence(o);break;default:this._logger.log(ae.Warning,`Invalid message type: ${o.type}.`);break}}this._resetTimeoutPeriod()}_processHandshakeResponse(t){let i,o;try{[o,i]=this._handshakeProtocol.parseHandshakeResponse(t)}catch(l){const u="Error parsing handshake response: "+l;this._logger.log(ae.Error,u);const c=new Error(u);throw this._handshakeRejecter(c),c}if(i.error){const l="Server returned handshake error: "+i.error;this._logger.log(ae.Error,l);const u=new Error(l);throw this._handshakeRejecter(u),u}else this._logger.log(ae.Debug,"Server handshake complete.");return this._handshakeResolver(),o}_resetKeepAliveInterval(){this.connection.features.inherentKeepAlive||(this._nextKeepAlive=new Date().getTime()+this.keepAliveIntervalInMilliseconds,this._cleanupPingTimer())}_resetTimeoutPeriod(){if(!this.connection.features||!this.connection.features.inherentKeepAlive){this._timeoutHandle=setTimeout(()=>this.serverTimeout(),this.serverTimeoutInMilliseconds);let t=this._nextKeepAlive-new Date().getTime();if(t<0){this._connectionState===ut.Connected&&this._trySendPingMessage();return}this._pingServerHandle===void 0&&(t<0&&(t=0),this._pingServerHandle=setTimeout(async()=>{this._connectionState===ut.Connected&&await this._trySendPingMessage()},t))}}serverTimeout(){this.connection.stop(new Error("Server timeout elapsed without receiving a message from the server."))}async _invokeClientMethod(t){const i=t.target.toLowerCase(),o=this._methods[i];if(!o){this._logger.log(ae.Warning,`No client method with the name '${i}' found.`),t.invocationId&&(this._logger.log(ae.Warning,`No result given for '${i}' method and invocation ID '${t.invocationId}'.`),await this._sendWithProtocol(this._createCompletionMessage(t.invocationId,"Client didn't provide a result.",null)));return}const l=o.slice(),u=!!t.invocationId;let c,d,m;for(const p of l)try{const g=c;c=await p.apply(this,t.arguments),u&&c&&g&&(this._logger.log(ae.Error,`Multiple results provided for '${i}'. Sending error to server.`),m=this._createCompletionMessage(t.invocationId,"Client provided multiple results.",null)),d=void 0}catch(g){d=g,this._logger.log(ae.Error,`A callback for the method '${i}' threw error '${g}'.`)}m?await this._sendWithProtocol(m):u?(d?m=this._createCompletionMessage(t.invocationId,`${d}`,null):c!==void 0?m=this._createCompletionMessage(t.invocationId,null,c):(this._logger.log(ae.Warning,`No result given for '${i}' method and invocation ID '${t.invocationId}'.`),m=this._createCompletionMessage(t.invocationId,"Client didn't provide a result.",null)),await this._sendWithProtocol(m)):c&&this._logger.log(ae.Error,`Result given for '${i}' method but server is not expecting a result.`)}_connectionClosed(t){this._logger.log(ae.Debug,`HubConnection.connectionClosed(${t}) called while in state ${this._connectionState}.`),this._stopDuringStartError=this._stopDuringStartError||t||new br("The underlying connection was closed before the hub handshake could complete."),this._handshakeResolver&&this._handshakeResolver(),this._cancelCallbacksWithError(t||new Error("Invocation canceled due to the underlying connection being closed.")),this._cleanupTimeout(),this._cleanupPingTimer(),this._connectionState===ut.Disconnecting?this._completeClose(t):this._connectionState===ut.Connected&&this._reconnectPolicy?this._reconnect(t):this._connectionState===ut.Connected&&this._completeClose(t)}_completeClose(t){if(this._connectionStarted){this._connectionState=ut.Disconnected,this._connectionStarted=!1,this._messageBuffer&&(this._messageBuffer._dispose(t??new Error("Connection closed.")),this._messageBuffer=void 0),Mt.isBrowser&&window.document.removeEventListener("freeze",this._freezeEventListener);try{this._closedCallbacks.forEach(i=>i.apply(this,[t]))}catch(i){this._logger.log(ae.Error,`An onclose callback called with error '${t}' threw error '${i}'.`)}}}async _reconnect(t){const i=Date.now();let o=0,l=t!==void 0?t:new Error("Attempting to reconnect due to a unknown error."),u=this._getNextRetryDelay(o,0,l);if(u===null){this._logger.log(ae.Debug,"Connection not reconnecting because the IRetryPolicy returned null on the first reconnect attempt."),this._completeClose(t);return}if(this._connectionState=ut.Reconnecting,t?this._logger.log(ae.Information,`Connection reconnecting because of error '${t}'.`):this._logger.log(ae.Information,"Connection reconnecting."),this._reconnectingCallbacks.length!==0){try{this._reconnectingCallbacks.forEach(c=>c.apply(this,[t]))}catch(c){this._logger.log(ae.Error,`An onreconnecting callback called with error '${t}' threw error '${c}'.`)}if(this._connectionState!==ut.Reconnecting){this._logger.log(ae.Debug,"Connection left the reconnecting state in onreconnecting callback. Done reconnecting.");return}}for(;u!==null;){if(this._logger.log(ae.Information,`Reconnect attempt number ${o+1} will start in ${u} ms.`),await new Promise(c=>{this._reconnectDelayHandle=setTimeout(c,u)}),this._reconnectDelayHandle=void 0,this._connectionState!==ut.Reconnecting){this._logger.log(ae.Debug,"Connection left the reconnecting state during reconnect delay. Done reconnecting.");return}try{if(await this._startInternal(),this._connectionState=ut.Connected,this._logger.log(ae.Information,"HubConnection reconnected successfully."),this._reconnectedCallbacks.length!==0)try{this._reconnectedCallbacks.forEach(c=>c.apply(this,[this.connection.connectionId]))}catch(c){this._logger.log(ae.Error,`An onreconnected callback called with connectionId '${this.connection.connectionId}; threw error '${c}'.`)}return}catch(c){if(this._logger.log(ae.Information,`Reconnect attempt failed because of error '${c}'.`),this._connectionState!==ut.Reconnecting){this._logger.log(ae.Debug,`Connection moved to the '${this._connectionState}' from the reconnecting state during reconnect attempt. Done reconnecting.`),this._connectionState===ut.Disconnecting&&this._completeClose();return}o++,l=c instanceof Error?c:new Error(c.toString()),u=this._getNextRetryDelay(o,Date.now()-i,l)}}this._logger.log(ae.Information,`Reconnect retries have been exhausted after ${Date.now()-i} ms and ${o} failed attempts. Connection disconnecting.`),this._completeClose()}_getNextRetryDelay(t,i,o){try{return this._reconnectPolicy.nextRetryDelayInMilliseconds({elapsedMilliseconds:i,previousRetryCount:t,retryReason:o})}catch(l){return this._logger.log(ae.Error,`IRetryPolicy.nextRetryDelayInMilliseconds(${t}, ${i}) threw error '${l}'.`),null}}_cancelCallbacksWithError(t){const i=this._callbacks;this._callbacks={},Object.keys(i).forEach(o=>{const l=i[o];try{l(null,t)}catch(u){this._logger.log(ae.Error,`Stream 'error' callback called with '${t}' threw error: ${Qd(u)}`)}})}_cleanupPingTimer(){this._pingServerHandle&&(clearTimeout(this._pingServerHandle),this._pingServerHandle=void 0)}_cleanupTimeout(){this._timeoutHandle&&clearTimeout(this._timeoutHandle)}_createInvocation(t,i,o,l){if(o)return l.length!==0?{target:t,arguments:i,streamIds:l,type:Be.Invocation}:{target:t,arguments:i,type:Be.Invocation};{const u=this._invocationId;return this._invocationId++,l.length!==0?{target:t,arguments:i,invocationId:u.toString(),streamIds:l,type:Be.Invocation}:{target:t,arguments:i,invocationId:u.toString(),type:Be.Invocation}}}_launchStreams(t,i){if(t.length!==0){i||(i=Promise.resolve());for(const o in t)t[o].subscribe({complete:()=>{i=i.then(()=>this._sendWithProtocol(this._createCompletionMessage(o)))},error:l=>{let u;l instanceof Error?u=l.message:l&&l.toString?u=l.toString():u="Unknown error",i=i.then(()=>this._sendWithProtocol(this._createCompletionMessage(o,u)))},next:l=>{i=i.then(()=>this._sendWithProtocol(this._createStreamItemMessage(o,l)))}})}}_replaceStreamingParams(t){const i=[],o=[];for(let l=0;l<t.length;l++){const u=t[l];if(this._isObservable(u)){const c=this._invocationId;this._invocationId++,i[c]=u,o.push(c.toString()),t.splice(l,1)}}return[i,o]}_isObservable(t){return t&&t.subscribe&&typeof t.subscribe=="function"}_createStreamInvocation(t,i,o){const l=this._invocationId;return this._invocationId++,o.length!==0?{target:t,arguments:i,invocationId:l.toString(),streamIds:o,type:Be.StreamInvocation}:{target:t,arguments:i,invocationId:l.toString(),type:Be.StreamInvocation}}_createCancelInvocation(t){return{invocationId:t,type:Be.CancelInvocation}}_createStreamItemMessage(t,i){return{invocationId:t,item:i,type:Be.StreamItem}}_createCompletionMessage(t,i,o){return i?{error:i,invocationId:t,type:Be.Completion}:{invocationId:t,result:o,type:Be.Completion}}_createCloseMessage(){return{type:Be.Close}}async _trySendPingMessage(){try{await this._sendMessage(this._cachedPingMessage)}catch{this._cleanupPingTimer()}}}const uM=[0,2e3,1e4,3e4,null];class Eb{constructor(t){this._retryDelays=t!==void 0?[...t,null]:uM}nextRetryDelayInMilliseconds(t){return this._retryDelays[t.previousRetryCount]}}class oo{}oo.Authorization="Authorization",oo.Cookie="Cookie";class cM extends Tu{constructor(t,i){super(),this._innerClient=t,this._accessTokenFactory=i}async send(t){let i=!0;this._accessTokenFactory&&(!this._accessToken||t.url&&t.url.indexOf("/negotiate?")>0)&&(i=!1,this._accessToken=await this._accessTokenFactory()),this._setAuthorizationHeader(t);const o=await this._innerClient.send(t);return i&&o.statusCode===401&&this._accessTokenFactory?(this._accessToken=await this._accessTokenFactory(),this._setAuthorizationHeader(t),await this._innerClient.send(t)):o}_setAuthorizationHeader(t){t.headers||(t.headers={}),this._accessToken?t.headers[oo.Authorization]=`Bearer ${this._accessToken}`:this._accessTokenFactory&&t.headers[oo.Authorization]&&delete t.headers[oo.Authorization]}getCookieString(t){return this._innerClient.getCookieString(t)}}var nn;(function(e){e[e.None=0]="None",e[e.WebSockets=1]="WebSockets",e[e.ServerSentEvents=2]="ServerSentEvents",e[e.LongPolling=4]="LongPolling"})(nn||(nn={}));var Sn;(function(e){e[e.Text=1]="Text",e[e.Binary=2]="Binary"})(Sn||(Sn={}));let fM=class{constructor(){this._isAborted=!1,this.onabort=null}abort(){this._isAborted||(this._isAborted=!0,this.onabort&&this.onabort())}get signal(){return this}get aborted(){return this._isAborted}};class Tb{get pollAborted(){return this._pollAbort.aborted}constructor(t,i,o){this._httpClient=t,this._logger=i,this._pollAbort=new fM,this._options=o,this._running=!1,this.onreceive=null,this.onclose=null}async connect(t,i){if(Kt.isRequired(t,"url"),Kt.isRequired(i,"transferFormat"),Kt.isIn(i,Sn,"transferFormat"),this._url=t,this._logger.log(ae.Trace,"(LongPolling transport) Connecting."),i===Sn.Binary&&typeof XMLHttpRequest<"u"&&typeof new XMLHttpRequest().responseType!="string")throw new Error("Binary protocols over XmlHttpRequest not implementing advanced features are not supported.");const[o,l]=Ko(),u={[o]:l,...this._options.headers},c={abortSignal:this._pollAbort.signal,headers:u,timeout:1e5,withCredentials:this._options.withCredentials};i===Sn.Binary&&(c.responseType="arraybuffer");const d=`${t}&_=${Date.now()}`;this._logger.log(ae.Trace,`(LongPolling transport) polling: ${d}.`);const m=await this._httpClient.get(d,c);m.statusCode!==200?(this._logger.log(ae.Error,`(LongPolling transport) Unexpected response code: ${m.statusCode}.`),this._closeError=new ro(m.statusText||"",m.statusCode),this._running=!1):this._running=!0,this._receiving=this._poll(this._url,c)}async _poll(t,i){try{for(;this._running;)try{const o=`${t}&_=${Date.now()}`;this._logger.log(ae.Trace,`(LongPolling transport) polling: ${o}.`);const l=await this._httpClient.get(o,i);l.statusCode===204?(this._logger.log(ae.Information,"(LongPolling transport) Poll terminated by server."),this._running=!1):l.statusCode!==200?(this._logger.log(ae.Error,`(LongPolling transport) Unexpected response code: ${l.statusCode}.`),this._closeError=new ro(l.statusText||"",l.statusCode),this._running=!1):l.content?(this._logger.log(ae.Trace,`(LongPolling transport) data received. ${Al(l.content,this._options.logMessageContent)}.`),this.onreceive&&this.onreceive(l.content)):this._logger.log(ae.Trace,"(LongPolling transport) Poll timed out, reissuing.")}catch(o){this._running?o instanceof Kd?this._logger.log(ae.Trace,"(LongPolling transport) Poll timed out, reissuing."):(this._closeError=o,this._running=!1):this._logger.log(ae.Trace,`(LongPolling transport) Poll errored after shutdown: ${o.message}`)}}finally{this._logger.log(ae.Trace,"(LongPolling transport) Polling complete."),this.pollAborted||this._raiseOnClose()}}async send(t){return this._running?wb(this._logger,"LongPolling",this._httpClient,this._url,t,this._options):Promise.reject(new Error("Cannot send until the transport is connected"))}async stop(){this._logger.log(ae.Trace,"(LongPolling transport) Stopping polling."),this._running=!1,this._pollAbort.abort();try{await this._receiving,this._logger.log(ae.Trace,`(LongPolling transport) sending DELETE request to ${this._url}.`);const t={},[i,o]=Ko();t[i]=o;const l={headers:{...t,...this._options.headers},timeout:this._options.timeout,withCredentials:this._options.withCredentials};let u;try{await this._httpClient.delete(this._url,l)}catch(c){u=c}u?u instanceof ro&&(u.statusCode===404?this._logger.log(ae.Trace,"(LongPolling transport) A 404 response was returned from sending a DELETE request."):this._logger.log(ae.Trace,`(LongPolling transport) Error sending a DELETE request: ${u}`)):this._logger.log(ae.Trace,"(LongPolling transport) DELETE request accepted.")}finally{this._logger.log(ae.Trace,"(LongPolling transport) Stop finished."),this._raiseOnClose()}}_raiseOnClose(){if(this.onclose){let t="(LongPolling transport) Firing onclose event.";this._closeError&&(t+=" Error: "+this._closeError),this._logger.log(ae.Trace,t),this.onclose(this._closeError)}}}class dM{constructor(t,i,o,l){this._httpClient=t,this._accessToken=i,this._logger=o,this._options=l,this.onreceive=null,this.onclose=null}async connect(t,i){return Kt.isRequired(t,"url"),Kt.isRequired(i,"transferFormat"),Kt.isIn(i,Sn,"transferFormat"),this._logger.log(ae.Trace,"(SSE transport) Connecting."),this._url=t,this._accessToken&&(t+=(t.indexOf("?")<0?"?":"&")+`access_token=${encodeURIComponent(this._accessToken)}`),new Promise((o,l)=>{let u=!1;if(i!==Sn.Text){l(new Error("The Server-Sent Events transport only supports the 'Text' transfer format"));return}let c;if(Mt.isBrowser||Mt.isWebWorker)c=new this._options.EventSource(t,{withCredentials:this._options.withCredentials});else{const d=this._httpClient.getCookieString(t),m={};m.Cookie=d;const[p,g]=Ko();m[p]=g,c=new this._options.EventSource(t,{withCredentials:this._options.withCredentials,headers:{...m,...this._options.headers}})}try{c.onmessage=d=>{if(this.onreceive)try{this._logger.log(ae.Trace,`(SSE transport) data received. ${Al(d.data,this._options.logMessageContent)}.`),this.onreceive(d.data)}catch(m){this._close(m);return}},c.onerror=d=>{u?this._close():l(new Error("EventSource failed to connect. The connection could not be found on the server, either the connection ID is not present on the server, or a proxy is refusing/buffering the connection. If you have multiple servers check that sticky sessions are enabled."))},c.onopen=()=>{this._logger.log(ae.Information,`SSE connected to ${this._url}`),this._eventSource=c,u=!0,o()}}catch(d){l(d);return}})}async send(t){return this._eventSource?wb(this._logger,"SSE",this._httpClient,this._url,t,this._options):Promise.reject(new Error("Cannot send until the transport is connected"))}stop(){return this._close(),Promise.resolve()}_close(t){this._eventSource&&(this._eventSource.close(),this._eventSource=void 0,this.onclose&&this.onclose(t))}}class hM{constructor(t,i,o,l,u,c){this._logger=o,this._accessTokenFactory=i,this._logMessageContent=l,this._webSocketConstructor=u,this._httpClient=t,this.onreceive=null,this.onclose=null,this._headers=c}async connect(t,i){Kt.isRequired(t,"url"),Kt.isRequired(i,"transferFormat"),Kt.isIn(i,Sn,"transferFormat"),this._logger.log(ae.Trace,"(WebSockets transport) Connecting.");let o;return this._accessTokenFactory&&(o=await this._accessTokenFactory()),new Promise((l,u)=>{t=t.replace(/^http/,"ws");let c;const d=this._httpClient.getCookieString(t);let m=!1;if(Mt.isNode||Mt.isReactNative){const p={},[g,y]=Ko();p[g]=y,o&&(p[oo.Authorization]=`Bearer ${o}`),d&&(p[oo.Cookie]=d),c=new this._webSocketConstructor(t,void 0,{headers:{...p,...this._headers}})}else o&&(t+=(t.indexOf("?")<0?"?":"&")+`access_token=${encodeURIComponent(o)}`);c||(c=new this._webSocketConstructor(t)),i===Sn.Binary&&(c.binaryType="arraybuffer"),c.onopen=p=>{this._logger.log(ae.Information,`WebSocket connected to ${t}.`),this._webSocket=c,m=!0,l()},c.onerror=p=>{let g=null;typeof ErrorEvent<"u"&&p instanceof ErrorEvent?g=p.error:g="There was an error with the transport",this._logger.log(ae.Information,`(WebSockets transport) ${g}.`)},c.onmessage=p=>{if(this._logger.log(ae.Trace,`(WebSockets transport) data received. ${Al(p.data,this._logMessageContent)}.`),this.onreceive)try{this.onreceive(p.data)}catch(g){this._close(g);return}},c.onclose=p=>{if(m)this._close(p);else{let g=null;typeof ErrorEvent<"u"&&p instanceof ErrorEvent?g=p.error:g="WebSocket failed to connect. The connection could not be found on the server, either the endpoint may not be a SignalR endpoint, the connection ID is not present on the server, or there is a proxy blocking WebSockets. If you have multiple servers check that sticky sessions are enabled.",u(new Error(g))}}})}send(t){return this._webSocket&&this._webSocket.readyState===this._webSocketConstructor.OPEN?(this._logger.log(ae.Trace,`(WebSockets transport) sending data. ${Al(t,this._logMessageContent)}.`),this._webSocket.send(t),Promise.resolve()):Promise.reject("WebSocket is not in the OPEN state")}stop(){return this._webSocket&&this._close(void 0),Promise.resolve()}_close(t){this._webSocket&&(this._webSocket.onclose=()=>{},this._webSocket.onmessage=()=>{},this._webSocket.onerror=()=>{},this._webSocket.close(),this._webSocket=void 0),this._logger.log(ae.Trace,"(WebSockets transport) socket closed."),this.onclose&&(this._isCloseEvent(t)&&(t.wasClean===!1||t.code!==1e3)?this.onclose(new Error(`WebSocket closed with status code: ${t.code} (${t.reason||"no reason given"}).`)):t instanceof Error?this.onclose(t):this.onclose())}_isCloseEvent(t){return t&&typeof t.wasClean=="boolean"&&typeof t.code=="number"}}const _b=100;class pM{constructor(t,i={}){if(this._stopPromiseResolver=()=>{},this.features={},this._negotiateVersion=1,Kt.isRequired(t,"url"),this._logger=Y5(i.logger),this.baseUrl=this._resolveUrl(t),i=i||{},i.logMessageContent=i.logMessageContent===void 0?!1:i.logMessageContent,typeof i.withCredentials=="boolean"||i.withCredentials===void 0)i.withCredentials=i.withCredentials===void 0?!0:i.withCredentials;else throw new Error("withCredentials option was not a 'boolean' or 'undefined' value");i.timeout=i.timeout===void 0?100*1e3:i.timeout;let o=null,l=null;if(Mt.isNode&&typeof require<"u"){const u=typeof __webpack_require__=="function"?__non_webpack_require__:require;o=u("ws"),l=u("eventsource")}!Mt.isNode&&typeof WebSocket<"u"&&!i.WebSocket?i.WebSocket=WebSocket:Mt.isNode&&!i.WebSocket&&o&&(i.WebSocket=o),!Mt.isNode&&typeof EventSource<"u"&&!i.EventSource?i.EventSource=EventSource:Mt.isNode&&!i.EventSource&&typeof l<"u"&&(i.EventSource=l),this._httpClient=new cM(i.httpClient||new tM(this._logger),i.accessTokenFactory),this._connectionState="Disconnected",this._connectionStarted=!1,this._options=i,this.onreceive=null,this.onclose=null}async start(t){if(t=t||Sn.Binary,Kt.isIn(t,Sn,"transferFormat"),this._logger.log(ae.Debug,`Starting connection with transfer format '${Sn[t]}'.`),this._connectionState!=="Disconnected")return Promise.reject(new Error("Cannot start an HttpConnection that is not in the 'Disconnected' state."));if(this._connectionState="Connecting",this._startInternalPromise=this._startInternal(t),await this._startInternalPromise,this._connectionState==="Disconnecting"){const i="Failed to start the HttpConnection before stop() was called.";return this._logger.log(ae.Error,i),await this._stopPromise,Promise.reject(new br(i))}else if(this._connectionState!=="Connected"){const i="HttpConnection.startInternal completed gracefully but didn't enter the connection into the connected state!";return this._logger.log(ae.Error,i),Promise.reject(new br(i))}this._connectionStarted=!0}send(t){return this._connectionState!=="Connected"?Promise.reject(new Error("Cannot send data if the connection is not in the 'Connected' State.")):(this._sendQueue||(this._sendQueue=new Wd(this.transport)),this._sendQueue.send(t))}async stop(t){if(this._connectionState==="Disconnected")return this._logger.log(ae.Debug,`Call to HttpConnection.stop(${t}) ignored because the connection is already in the disconnected state.`),Promise.resolve();if(this._connectionState==="Disconnecting")return this._logger.log(ae.Debug,`Call to HttpConnection.stop(${t}) ignored because the connection is already in the disconnecting state.`),this._stopPromise;this._connectionState="Disconnecting",this._stopPromise=new Promise(i=>{this._stopPromiseResolver=i}),await this._stopInternal(t),await this._stopPromise}async _stopInternal(t){this._stopError=t;try{await this._startInternalPromise}catch{}if(this.transport){try{await this.transport.stop()}catch(i){this._logger.log(ae.Error,`HttpConnection.transport.stop() threw error '${i}'.`),this._stopConnection()}this.transport=void 0}else this._logger.log(ae.Debug,"HttpConnection.transport is undefined in HttpConnection.stop() because start() failed.")}async _startInternal(t){let i=this.baseUrl;this._accessTokenFactory=this._options.accessTokenFactory,this._httpClient._accessTokenFactory=this._accessTokenFactory;try{if(this._options.skipNegotiation)if(this._options.transport===nn.WebSockets)this.transport=this._constructTransport(nn.WebSockets),await this._startTransport(i,t);else throw new Error("Negotiation can only be skipped when using the WebSocket transport directly.");else{let o=null,l=0;do{if(o=await this._getNegotiationResponse(i),this._connectionState==="Disconnecting"||this._connectionState==="Disconnected")throw new br("The connection was stopped during negotiation.");if(o.error)throw new Error(o.error);if(o.ProtocolVersion)throw new Error("Detected a connection attempt to an ASP.NET SignalR Server. This client only supports connecting to an ASP.NET Core SignalR Server. See https://aka.ms/signalr-core-differences for details.");if(o.url&&(i=o.url),o.accessToken){const u=o.accessToken;this._accessTokenFactory=()=>u,this._httpClient._accessToken=u,this._httpClient._accessTokenFactory=void 0}l++}while(o.url&&l<_b);if(l===_b&&o.url)throw new Error("Negotiate redirection limit exceeded.");await this._createTransport(i,this._options.transport,o,t)}this.transport instanceof Tb&&(this.features.inherentKeepAlive=!0),this._connectionState==="Connecting"&&(this._logger.log(ae.Debug,"The HttpConnection connected successfully."),this._connectionState="Connected")}catch(o){return this._logger.log(ae.Error,"Failed to start the connection: "+o),this._connectionState="Disconnected",this.transport=void 0,this._stopPromiseResolver(),Promise.reject(o)}}async _getNegotiationResponse(t){const i={},[o,l]=Ko();i[o]=l;const u=this._resolveNegotiateUrl(t);this._logger.log(ae.Debug,`Sending negotiation request: ${u}.`);try{const c=await this._httpClient.post(u,{content:"",headers:{...i,...this._options.headers},timeout:this._options.timeout,withCredentials:this._options.withCredentials});if(c.statusCode!==200)return Promise.reject(new Error(`Unexpected status code returned from negotiate '${c.statusCode}'`));const d=JSON.parse(c.content);return(!d.negotiateVersion||d.negotiateVersion<1)&&(d.connectionToken=d.connectionId),d.useStatefulReconnect&&this._options._useStatefulReconnect!==!0?Promise.reject(new vb("Client didn't negotiate Stateful Reconnect but the server did.")):d}catch(c){let d="Failed to complete negotiation with the server: "+c;return c instanceof ro&&c.statusCode===404&&(d=d+" Either this is not a SignalR endpoint or there is a proxy blocking the connection."),this._logger.log(ae.Error,d),Promise.reject(new vb(d))}}_createConnectUrl(t,i){return i?t+(t.indexOf("?")===-1?"?":"&")+`id=${i}`:t}async _createTransport(t,i,o,l){let u=this._createConnectUrl(t,o.connectionToken);if(this._isITransport(i)){this._logger.log(ae.Debug,"Connection was provided an instance of ITransport, using that directly."),this.transport=i,await this._startTransport(u,l),this.connectionId=o.connectionId;return}const c=[],d=o.availableTransports||[];let m=o;for(const p of d){const g=this._resolveTransportOrError(p,i,l,m?.useStatefulReconnect===!0);if(g instanceof Error)c.push(`${p.transport} failed:`),c.push(g);else if(this._isITransport(g)){if(this.transport=g,!m){try{m=await this._getNegotiationResponse(t)}catch(y){return Promise.reject(y)}u=this._createConnectUrl(t,m.connectionToken)}try{await this._startTransport(u,l),this.connectionId=m.connectionId;return}catch(y){if(this._logger.log(ae.Error,`Failed to start the transport '${p.transport}': ${y}`),m=void 0,c.push(new H5(`${p.transport} failed: ${y}`,nn[p.transport])),this._connectionState!=="Connecting"){const v="Failed to select transport before stop() was called.";return this._logger.log(ae.Debug,v),Promise.reject(new br(v))}}}}return c.length>0?Promise.reject(new q5(`Unable to connect to the server with any of the available transports. ${c.join(" ")}`,c)):Promise.reject(new Error("None of the transports supported by the client are supported by the server."))}_constructTransport(t){switch(t){case nn.WebSockets:if(!this._options.WebSocket)throw new Error("'WebSocket' is not supported in your environment.");return new hM(this._httpClient,this._accessTokenFactory,this._logger,this._options.logMessageContent,this._options.WebSocket,this._options.headers||{});case nn.ServerSentEvents:if(!this._options.EventSource)throw new Error("'EventSource' is not supported in your environment.");return new dM(this._httpClient,this._httpClient._accessToken,this._logger,this._options);case nn.LongPolling:return new Tb(this._httpClient,this._logger,this._options);default:throw new Error(`Unknown transport: ${t}.`)}}_startTransport(t,i){return this.transport.onreceive=this.onreceive,this.features.reconnect?this.transport.onclose=async o=>{let l=!1;if(this.features.reconnect)try{this.features.disconnected(),await this.transport.connect(t,i),await this.features.resend()}catch{l=!0}else{this._stopConnection(o);return}l&&this._stopConnection(o)}:this.transport.onclose=o=>this._stopConnection(o),this.transport.connect(t,i)}_resolveTransportOrError(t,i,o,l){const u=nn[t.transport];if(u==null)return this._logger.log(ae.Debug,`Skipping transport '${t.transport}' because it is not supported by this client.`),new Error(`Skipping transport '${t.transport}' because it is not supported by this client.`);if(mM(i,u))if(t.transferFormats.map(d=>Sn[d]).indexOf(o)>=0){if(u===nn.WebSockets&&!this._options.WebSocket||u===nn.ServerSentEvents&&!this._options.EventSource)return this._logger.log(ae.Debug,`Skipping transport '${nn[u]}' because it is not supported in your environment.'`),new j5(`'${nn[u]}' is not supported in your environment.`,u);this._logger.log(ae.Debug,`Selecting transport '${nn[u]}'.`);try{return this.features.reconnect=u===nn.WebSockets?l:void 0,this._constructTransport(u)}catch(d){return d}}else return this._logger.log(ae.Debug,`Skipping transport '${nn[u]}' because it does not support the requested transfer format '${Sn[o]}'.`),new Error(`'${nn[u]}' does not support ${Sn[o]}.`);else return this._logger.log(ae.Debug,`Skipping transport '${nn[u]}' because it was disabled by the client.`),new P5(`'${nn[u]}' is disabled by the client.`,u)}_isITransport(t){return t&&typeof t=="object"&&"connect"in t}_stopConnection(t){if(this._logger.log(ae.Debug,`HttpConnection.stopConnection(${t}) called while in state ${this._connectionState}.`),this.transport=void 0,t=this._stopError||t,this._stopError=void 0,this._connectionState==="Disconnected"){this._logger.log(ae.Debug,`Call to HttpConnection.stopConnection(${t}) was ignored because the connection is already in the disconnected state.`);return}if(this._connectionState==="Connecting")throw this._logger.log(ae.Warning,`Call to HttpConnection.stopConnection(${t}) was ignored because the connection is still in the connecting state.`),new Error(`HttpConnection.stopConnection(${t}) was called while the connection is still in the connecting state.`);if(this._connectionState==="Disconnecting"&&this._stopPromiseResolver(),t?this._logger.log(ae.Error,`Connection disconnected with error '${t}'.`):this._logger.log(ae.Information,"Connection disconnected."),this._sendQueue&&(this._sendQueue.stop().catch(i=>{this._logger.log(ae.Error,`TransportSendQueue.stop() threw error '${i}'.`)}),this._sendQueue=void 0),this.connectionId=void 0,this._connectionState="Disconnected",this._connectionStarted){this._connectionStarted=!1;try{this.onclose&&this.onclose(t)}catch(i){this._logger.log(ae.Error,`HttpConnection.onclose(${t}) threw error '${i}'.`)}}}_resolveUrl(t){if(t.lastIndexOf("https://",0)===0||t.lastIndexOf("http://",0)===0)return t;if(!Mt.isBrowser)throw new Error(`Cannot resolve '${t}'.`);const i=window.document.createElement("a");return i.href=t,this._logger.log(ae.Information,`Normalizing '${t}' to '${i.href}'.`),i.href}_resolveNegotiateUrl(t){const i=new URL(t);i.pathname.endsWith("/")?i.pathname+="negotiate":i.pathname+="/negotiate";const o=new URLSearchParams(i.searchParams);return o.has("negotiateVersion")||o.append("negotiateVersion",this._negotiateVersion.toString()),o.has("useStatefulReconnect")?o.get("useStatefulReconnect")==="true"&&(this._options._useStatefulReconnect=!0):this._options._useStatefulReconnect===!0&&o.append("useStatefulReconnect","true"),i.search=o.toString(),i.toString()}}function mM(e,t){return!e||(t&e)!==0}class Wd{constructor(t){this._transport=t,this._buffer=[],this._executing=!0,this._sendBufferedData=new Au,this._transportResult=new Au,this._sendLoopPromise=this._sendLoop()}send(t){return this._bufferData(t),this._transportResult||(this._transportResult=new Au),this._transportResult.promise}stop(){return this._executing=!1,this._sendBufferedData.resolve(),this._sendLoopPromise}_bufferData(t){if(this._buffer.length&&typeof this._buffer[0]!=typeof t)throw new Error(`Expected data to be of type ${typeof this._buffer} but was of type ${typeof t}`);this._buffer.push(t),this._sendBufferedData.resolve()}async _sendLoop(){for(;;){if(await this._sendBufferedData.promise,!this._executing){this._transportResult&&this._transportResult.reject("Connection stopped.");break}this._sendBufferedData=new Au;const t=this._transportResult;this._transportResult=void 0;const i=typeof this._buffer[0]=="string"?this._buffer.join(""):Wd._concatBuffers(this._buffer);this._buffer.length=0;try{await this._transport.send(i),t.resolve()}catch(o){t.reject(o)}}}static _concatBuffers(t){const i=t.map(u=>u.byteLength).reduce((u,c)=>u+c),o=new Uint8Array(i);let l=0;for(const u of t)o.set(new Uint8Array(u),l),l+=u.byteLength;return o.buffer}}class Au{constructor(){this.promise=new Promise((t,i)=>[this._resolver,this._rejecter]=[t,i])}resolve(){this._resolver()}reject(t){this._rejecter(t)}}const gM="json";class yM{constructor(){this.name=gM,this.version=2,this.transferFormat=Sn.Text}parseMessages(t,i){if(typeof t!="string")throw new Error("Invalid input for JSON hub protocol. Expected a string.");if(!t)return[];i===null&&(i=_l.instance);const o=Ln.parse(t),l=[];for(const u of o){const c=JSON.parse(u);if(typeof c.type!="number")throw new Error("Invalid payload.");switch(c.type){case Be.Invocation:this._isInvocationMessage(c);break;case Be.StreamItem:this._isStreamItemMessage(c);break;case Be.Completion:this._isCompletionMessage(c);break;case Be.Ping:break;case Be.Close:break;case Be.Ack:this._isAckMessage(c);break;case Be.Sequence:this._isSequenceMessage(c);break;default:i.log(ae.Information,"Unknown message type '"+c.type+"' ignored.");continue}l.push(c)}return l}writeMessage(t){return Ln.write(JSON.stringify(t))}_isInvocationMessage(t){this._assertNotEmptyString(t.target,"Invalid payload for Invocation message."),t.invocationId!==void 0&&this._assertNotEmptyString(t.invocationId,"Invalid payload for Invocation message.")}_isStreamItemMessage(t){if(this._assertNotEmptyString(t.invocationId,"Invalid payload for StreamItem message."),t.item===void 0)throw new Error("Invalid payload for StreamItem message.")}_isCompletionMessage(t){if(t.result&&t.error)throw new Error("Invalid payload for Completion message.");!t.result&&t.error&&this._assertNotEmptyString(t.error,"Invalid payload for Completion message."),this._assertNotEmptyString(t.invocationId,"Invalid payload for Completion message.")}_isAckMessage(t){if(typeof t.sequenceId!="number")throw new Error("Invalid SequenceId for Ack message.")}_isSequenceMessage(t){if(typeof t.sequenceId!="number")throw new Error("Invalid SequenceId for Sequence message.")}_assertNotEmptyString(t,i){if(typeof t!="string"||t==="")throw new Error(i)}}const bM={trace:ae.Trace,debug:ae.Debug,info:ae.Information,information:ae.Information,warn:ae.Warning,warning:ae.Warning,error:ae.Error,critical:ae.Critical,none:ae.None};function SM(e){const t=bM[e.toLowerCase()];if(typeof t<"u")return t;throw new Error(`Unknown log level: ${e}`)}class vM{configureLogging(t){if(Kt.isRequired(t,"logging"),xM(t))this.logger=t;else if(typeof t=="string"){const i=SM(t);this.logger=new _u(i)}else this.logger=new _u(t);return this}withUrl(t,i){return Kt.isRequired(t,"url"),Kt.isNotEmpty(t,"url"),this.url=t,typeof i=="object"?this.httpConnectionOptions={...this.httpConnectionOptions,...i}:this.httpConnectionOptions={...this.httpConnectionOptions,transport:i},this}withHubProtocol(t){return Kt.isRequired(t,"protocol"),this.protocol=t,this}withAutomaticReconnect(t){if(this.reconnectPolicy)throw new Error("A reconnectPolicy has already been set.");return t?Array.isArray(t)?this.reconnectPolicy=new Eb(t):this.reconnectPolicy=t:this.reconnectPolicy=new Eb,this}withServerTimeout(t){return Kt.isRequired(t,"milliseconds"),this._serverTimeoutInMilliseconds=t,this}withKeepAliveInterval(t){return Kt.isRequired(t,"milliseconds"),this._keepAliveIntervalInMilliseconds=t,this}withStatefulReconnect(t){return this.httpConnectionOptions===void 0&&(this.httpConnectionOptions={}),this.httpConnectionOptions._useStatefulReconnect=!0,this._statefulReconnectBufferSize=t?.bufferSize,this}build(){const t=this.httpConnectionOptions||{};if(t.logger===void 0&&(t.logger=this.logger),!this.url)throw new Error("The 'HubConnectionBuilder.withUrl' method must be called before building the connection.");const i=new pM(this.url,t);return Zd.create(i,this.logger||_l.instance,this.protocol||new yM,this.reconnectPolicy,this._serverTimeoutInMilliseconds,this._keepAliveIntervalInMilliseconds,this._statefulReconnectBufferSize)}}function xM(e){return e.log!==void 0}function wM({url:e,accessToken:t,autoStart:i=!0}){const o=O.useRef(null),l=O.useRef(new Map),u=O.useRef(null),c=O.useRef(0),d=O.useRef(!1),[m,p]=O.useState("disconnected"),[g,y]=O.useState(null),v=O.useCallback(()=>{u.current&&(clearTimeout(u.current),u.current=null)},[]),S=O.useCallback(()=>{if(d.current||u.current)return;c.current+=1;const T=c.current,L=Math.min(3e4,1e3*Math.pow(2,T-1)),V=Math.floor(Math.random()*500),q=L+V;u.current=setTimeout(()=>{u.current=null,k()},q)},[v]),E=O.useCallback(T=>{l.current.forEach((L,V)=>{T.off(V),L.forEach(q=>{T.on(V,q)})})},[]),w=O.useCallback(async()=>Jy(),[]),R=O.useCallback(()=>{const T=new vM().withUrl(e,{accessTokenFactory:w}).withAutomaticReconnect({nextRetryDelayInMilliseconds:L=>L.elapsedMilliseconds<6e4?Math.random()*1e4:null}).build();return T.onreconnecting(()=>{v(),p("reconnecting")}),T.onreconnected(()=>{v(),c.current=0,p("connected"),E(T)}),T.onclose(L=>{p("disconnected"),L&&y(L),d.current||S()}),T},[e,w,E,v,S]),k=O.useCallback(async()=>{d.current=!1,v(),o.current||(o.current=R());const T=o.current;if(T.state===ut.Connected){p("connected");return}if(T.state===ut.Connecting){p("connecting");return}if(T.state===ut.Reconnecting){p("reconnecting");return}p("connecting");try{await T.start(),E(T),c.current=0,p("connected"),y(null)}catch(L){y(L),p("disconnected"),S()}},[E,R,v,S]),I=O.useCallback(async()=>{d.current=!0,v(),c.current=0;const T=o.current;if(o.current=null,!T){p("disconnected");return}try{await T.stop()}finally{p("disconnected")}},[v]),M=O.useCallback((T,L)=>{let V=l.current.get(T);V||(V=new Set,l.current.set(T,V)),V.add(L);const q=o.current;q&&q.on(T,L)},[]),_=O.useCallback((T,L)=>{const V=l.current.get(T);if(!V)return;V.delete(L),V.size===0&&l.current.delete(T);const q=o.current;q&&q.off(T,L)},[]),z=O.useCallback(async(T,...L)=>{const V=o.current;if(!V||V.state!==ut.Connected)throw new Error("SignalR not connected");return V.invoke(T,...L)},[]);return O.useEffect(()=>(i&&k(),()=>{I()}),[i,k,I]),{status:m,connected:m==="connected",error:g,start:k,stop:I,on:M,off:_,invoke:z}}const CM=(()=>{const e=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Uint8Array.prototype),Symbol.toStringTag).get;return t=>e.call(t)})();function Ab(e){return CM(e)==="Uint8Array"}function EM(e){return typeof e=="object"&&e!=null&&Symbol.toStringTag in e&&(e[Symbol.toStringTag]==="ArrayBuffer"||e[Symbol.toStringTag]==="SharedArrayBuffer")}function TM(e){return e instanceof RegExp||Object.prototype.toString.call(e)==="[object RegExp]"}function kb(e){return typeof e=="object"&&e!=null&&Symbol.toStringTag in e&&e[Symbol.toStringTag]==="Map"}function _M(e){return e instanceof Date||Object.prototype.toString.call(e)==="[object Date]"}function jn(e,t){return JSON.stringify(e,(i,o)=>typeof o=="bigint"?{$numberLong:`${o}`}:kb(o)?Object.fromEntries(o):o)}function AM(e){if(e!=null&&typeof e=="object"&&"stylize"in e&&typeof e.stylize=="function")return e.stylize}const Jd=7,Rb=Symbol.for("@@mdb.bson.version"),eh=2147483647,th=-2147483648,Ob=Math.pow(2,63)-1,Mb=-Math.pow(2,63),kM=Math.pow(2,53),RM=-Math.pow(2,53),Nb=4;class pe extends Error{get bsonError(){return!0}get name(){return"BSONError"}constructor(t,i){super(t,i)}static isBSONError(t){return t!=null&&typeof t=="object"&&"bsonError"in t&&t.bsonError===!0&&"name"in t&&"message"in t&&"stack"in t}}class OM extends pe{get name(){return"BSONVersionError"}constructor(){super(`Unsupported BSON version, bson types must be from bson ${Jd}.x.x`)}}class zb extends pe{get name(){return"BSONRuntimeError"}constructor(t){super(t)}}class vi extends pe{get name(){return"BSONOffsetError"}offset;constructor(t,i,o){super(`${t}. offset: ${i}`,o),this.offset=i}}let Bb,Db;function Ib(e,t,i,o){if(o){Bb??=new TextDecoder("utf8",{fatal:!0});try{return Bb.decode(e.subarray(t,i))}catch(l){throw new pe("Invalid UTF-8 string in BSON document",{cause:l})}}return Db??=new TextDecoder("utf8",{fatal:!1}),Db.decode(e.subarray(t,i))}function $b(e,t,i){if(e.length===0)return"";const o=i-t;if(o===0)return"";if(o>20)return null;if(o===1&&e[t]<128)return String.fromCharCode(e[t]);if(o===2&&e[t]<128&&e[t+1]<128)return String.fromCharCode(e[t])+String.fromCharCode(e[t+1]);if(o===3&&e[t]<128&&e[t+1]<128&&e[t+2]<128)return String.fromCharCode(e[t])+String.fromCharCode(e[t+1])+String.fromCharCode(e[t+2]);const l=[];for(let u=t;u<i;u++){const c=e[u];if(c>127)return null;l.push(c)}return String.fromCharCode(...l)}function MM(e,t,i){if(t.length===0)return 0;if(t.length>25||e.length-i<t.length)return null;for(let o=0,l=i;o<t.length;o++,l++){const u=t.charCodeAt(o);if(u>127)return null;e[l]=u}return t.length}function NM(e){return $r.fromNumberArray(Array.from({length:e},()=>Math.floor(Math.random()*256)))}function zM(e){return crypto.getRandomValues($r.allocate(e))}const BM=(()=>{const{crypto:e}=globalThis;return e!=null&&typeof e.getRandomValues=="function"?zM:NM})(),$r={toLocalBufferType(e){if(Buffer.isBuffer(e))return e;if(ArrayBuffer.isView(e))return Buffer.from(e.buffer,e.byteOffset,e.byteLength);const t=e?.[Symbol.toStringTag]??Object.prototype.toString.call(e);if(t==="ArrayBuffer"||t==="SharedArrayBuffer"||t==="[object ArrayBuffer]"||t==="[object SharedArrayBuffer]")return Buffer.from(e);throw new pe("Cannot create Buffer from the passed potentialBuffer.")},allocate(e){return Buffer.alloc(e)},allocateUnsafe(e){return Buffer.allocUnsafe(e)},equals(e,t){return $r.toLocalBufferType(e).equals(t)},fromNumberArray(e){return Buffer.from(e)},fromBase64(e){return Buffer.from(e,"base64")},toBase64(e){return $r.toLocalBufferType(e).toString("base64")},fromISO88591(e){return Buffer.from(e,"binary")},toISO88591(e){return $r.toLocalBufferType(e).toString("binary")},fromHex(e){return Buffer.from(e,"hex")},toHex(e){return $r.toLocalBufferType(e).toString("hex")},toUTF8(e,t,i,o){const l=i-t<=20?$b(e,t,i):null;if(l!=null)return l;const u=$r.toLocalBufferType(e).toString("utf8",t,i);if(o){for(let c=0;c<u.length;c++)if(u.charCodeAt(c)===65533){Ib(e,t,i,!0);break}}return u},utf8ByteLength(e){return Buffer.byteLength(e,"utf8")},encodeUTF8Into(e,t,i){const o=MM(e,t,i);return o??$r.toLocalBufferType(e).write(t,i,void 0,"utf8")},randomBytes:BM,swap32(e){return $r.toLocalBufferType(e).swap32()}};function DM(){const{navigator:e}=globalThis;return typeof e=="object"&&e.product==="ReactNative"}function IM(e){if(e<0)throw new RangeError(`The argument 'byteLength' is invalid. Received ${e}`);return kl.fromNumberArray(Array.from({length:e},()=>Math.floor(Math.random()*256)))}const $M=(()=>{const{crypto:e}=globalThis;if(e!=null&&typeof e.getRandomValues=="function")return t=>e.getRandomValues(kl.allocate(t));if(DM()){const{console:t}=globalThis;t?.warn?.("BSON: For React Native please polyfill crypto.getRandomValues, e.g. using: https://www.npmjs.com/package/react-native-get-random-values.")}return IM})(),Ub=/(\d|[a-f])/i,kl={toLocalBufferType(e){const t=e?.[Symbol.toStringTag]??Object.prototype.toString.call(e);if(t==="Uint8Array")return e;if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength));if(t==="ArrayBuffer"||t==="SharedArrayBuffer"||t==="[object ArrayBuffer]"||t==="[object SharedArrayBuffer]")return new Uint8Array(e);throw new pe("Cannot make a Uint8Array from passed potentialBuffer.")},allocate(e){if(typeof e!="number")throw new TypeError(`The "size" argument must be of type number. Received ${String(e)}`);return new Uint8Array(e)},allocateUnsafe(e){return kl.allocate(e)},equals(e,t){if(e.byteLength!==t.byteLength)return!1;for(let i=0;i<e.byteLength;i++)if(e[i]!==t[i])return!1;return!0},fromNumberArray(e){return Uint8Array.from(e)},fromBase64(e){return Uint8Array.from(atob(e),t=>t.charCodeAt(0))},toBase64(e){return btoa(kl.toISO88591(e))},fromISO88591(e){return Uint8Array.from(e,t=>t.charCodeAt(0)&255)},toISO88591(e){return Array.from(Uint16Array.from(e),t=>String.fromCharCode(t)).join("")},fromHex(e){const t=e.length%2===0?e:e.slice(0,e.length-1),i=[];for(let o=0;o<t.length;o+=2){const l=t[o],u=t[o+1];if(!Ub.test(l)||!Ub.test(u))break;const c=Number.parseInt(`${l}${u}`,16);i.push(c)}return Uint8Array.from(i)},toHex(e){return Array.from(e,t=>t.toString(16).padStart(2,"0")).join("")},toUTF8(e,t,i,o){const l=i-t<=20?$b(e,t,i):null;return l??Ib(e,t,i,o)},utf8ByteLength(e){return new TextEncoder().encode(e).byteLength},encodeUTF8Into(e,t,i){const o=new TextEncoder().encode(t);return e.set(o,i),o.byteLength},randomBytes:$M,swap32(e){if(e.length%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let t=0;t<e.length;t+=4){const i=e[t],o=e[t+1],l=e[t+2],u=e[t+3];e[t]=u,e[t+1]=l,e[t+2]=o,e[t+3]=i}return e}},_e=typeof Buffer=="function"&&Buffer.prototype?._isBuffer!==!0?$r:kl,Lb=Symbol.for("@@mdb.bson.type");class er{get[Lb](){return this._bsontype}get[Rb](){return Jd}[Symbol.for("nodejs.util.inspect.custom")](t,i,o){return this.inspect(t,i,o)}}const Qo=new Float64Array(1),We=new Uint8Array(Qo.buffer,0,8);Qo[0]=-1;const nh=We[7]===0,ao={isBigEndian:nh,getNonnegativeInt32LE(e,t){if(e[t+3]>127)throw new RangeError(`Size cannot be negative at offset: ${t}`);return e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24},getInt32LE(e,t){return e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24},getUint32LE(e,t){return e[t]+e[t+1]*256+e[t+2]*65536+e[t+3]*16777216},getUint32BE(e,t){return e[t+3]+e[t+2]*256+e[t+1]*65536+e[t]*16777216},getBigInt64LE(e,t){const i=BigInt(e[t+4]+e[t+5]*256+e[t+6]*65536+(e[t+7]<<24)),o=BigInt(e[t]+e[t+1]*256+e[t+2]*65536+e[t+3]*16777216);return(i<<32n)+o},getFloat64LE:nh?(e,t)=>(We[7]=e[t],We[6]=e[t+1],We[5]=e[t+2],We[4]=e[t+3],We[3]=e[t+4],We[2]=e[t+5],We[1]=e[t+6],We[0]=e[t+7],Qo[0]):(e,t)=>(We[0]=e[t],We[1]=e[t+1],We[2]=e[t+2],We[3]=e[t+3],We[4]=e[t+4],We[5]=e[t+5],We[6]=e[t+6],We[7]=e[t+7],Qo[0]),setInt32BE(e,t,i){return e[t+3]=i,i>>>=8,e[t+2]=i,i>>>=8,e[t+1]=i,i>>>=8,e[t]=i,4},setInt32LE(e,t,i){return e[t]=i,i>>>=8,e[t+1]=i,i>>>=8,e[t+2]=i,i>>>=8,e[t+3]=i,4},setBigInt64LE(e,t,i){const o=0xffffffffn;let l=Number(i&o);e[t]=l,l>>=8,e[t+1]=l,l>>=8,e[t+2]=l,l>>=8,e[t+3]=l;let u=Number(i>>32n&o);return e[t+4]=u,u>>=8,e[t+5]=u,u>>=8,e[t+6]=u,u>>=8,e[t+7]=u,8},setFloat64LE:nh?(e,t,i)=>(Qo[0]=i,e[t]=We[7],e[t+1]=We[6],e[t+2]=We[5],e[t+3]=We[4],e[t+4]=We[3],e[t+5]=We[2],e[t+6]=We[1],e[t+7]=We[0],8):(e,t,i)=>(Qo[0]=i,e[t]=We[0],e[t+1]=We[1],e[t+2]=We[2],e[t+3]=We[3],e[t+4]=We[4],e[t+5]=We[5],e[t+6]=We[6],e[t+7]=We[7],8)};class Ke extends er{get _bsontype(){return"Binary"}static BSON_BINARY_SUBTYPE_DEFAULT=0;static BUFFER_SIZE=256;static SUBTYPE_DEFAULT=0;static SUBTYPE_FUNCTION=1;static SUBTYPE_BYTE_ARRAY=2;static SUBTYPE_UUID_OLD=3;static SUBTYPE_UUID=4;static SUBTYPE_MD5=5;static SUBTYPE_ENCRYPTED=6;static SUBTYPE_COLUMN=7;static SUBTYPE_SENSITIVE=8;static SUBTYPE_VECTOR=9;static SUBTYPE_USER_DEFINED=128;static VECTOR_TYPE=Object.freeze({Int8:3,Float32:39,PackedBit:16});buffer;sub_type;position;constructor(t,i){if(super(),t!=null&&typeof t=="string"&&!ArrayBuffer.isView(t)&&!EM(t)&&!Array.isArray(t))throw new pe("Binary can only be constructed from Uint8Array or number[]");this.sub_type=i??Ke.BSON_BINARY_SUBTYPE_DEFAULT,t==null?(this.buffer=_e.allocate(Ke.BUFFER_SIZE),this.position=0):(this.buffer=Array.isArray(t)?_e.fromNumberArray(t):_e.toLocalBufferType(t),this.position=this.buffer.byteLength)}put(t){if(typeof t=="string"&&t.length!==1)throw new pe("only accepts single character String");if(typeof t!="number"&&t.length!==1)throw new pe("only accepts single character Uint8Array or Array");let i;if(typeof t=="string"?i=t.charCodeAt(0):typeof t=="number"?i=t:i=t[0],i<0||i>255)throw new pe("only accepts number in a valid unsigned byte range 0-255");if(this.buffer.byteLength>this.position)this.buffer[this.position++]=i;else{const o=_e.allocate(Ke.BUFFER_SIZE+this.buffer.length);o.set(this.buffer,0),this.buffer=o,this.buffer[this.position++]=i}}write(t,i){if(i=typeof i=="number"?i:this.position,this.buffer.byteLength<i+t.length){const o=_e.allocate(this.buffer.byteLength+t.length);o.set(this.buffer,0),this.buffer=o}if(ArrayBuffer.isView(t))this.buffer.set(_e.toLocalBufferType(t),i),this.position=i+t.byteLength>this.position?i+t.length:this.position;else if(typeof t=="string")throw new pe("input cannot be string")}read(t,i){i=i&&i>0?i:this.position;const o=t+i;return this.buffer.subarray(t,o>this.position?this.position:o)}value(){return this.buffer.length===this.position?this.buffer:this.buffer.subarray(0,this.position)}length(){return this.position}toJSON(){return _e.toBase64(this.buffer.subarray(0,this.position))}toString(t){return t==="hex"?_e.toHex(this.buffer.subarray(0,this.position)):t==="base64"?_e.toBase64(this.buffer.subarray(0,this.position)):t==="utf8"||t==="utf-8"?_e.toUTF8(this.buffer,0,this.position,!1):_e.toUTF8(this.buffer,0,this.position,!1)}toExtendedJSON(t){t=t||{},this.sub_type===Ke.SUBTYPE_VECTOR&&xi(this);const i=_e.toBase64(this.buffer),o=Number(this.sub_type).toString(16);return t.legacy?{$binary:i,$type:o.length===1?"0"+o:o}:{$binary:{base64:i,subType:o.length===1?"0"+o:o}}}toUUID(){if(this.sub_type===Ke.SUBTYPE_UUID)return new xn(this.buffer.subarray(0,this.position));throw new pe(`Binary sub_type "${this.sub_type}" is not supported for converting to UUID. Only "${Ke.SUBTYPE_UUID}" is currently supported.`)}static createFromHexString(t,i){return new Ke(_e.fromHex(t),i)}static createFromBase64(t,i){return new Ke(_e.fromBase64(t),i)}static fromExtendedJSON(t,i){i=i||{};let o,l;if("$binary"in t?i.legacy&&typeof t.$binary=="string"&&"$type"in t?(l=t.$type?parseInt(t.$type,16):0,o=_e.fromBase64(t.$binary)):typeof t.$binary!="string"&&(l=t.$binary.subType?parseInt(t.$binary.subType,16):0,o=_e.fromBase64(t.$binary.base64)):"$uuid"in t&&(l=4,o=xn.bytesFromString(t.$uuid)),!o)throw new pe(`Unexpected Binary Extended JSON format ${JSON.stringify(t)}`);return l===Nb?new xn(o):new Ke(o,l)}inspect(t,i,o){o??=jn;const l=_e.toBase64(this.buffer.subarray(0,this.position)),u=o(l,i),c=o(this.sub_type,i);return`Binary.createFromBase64(${u}, ${c})`}toInt8Array(){if(this.sub_type!==Ke.SUBTYPE_VECTOR)throw new pe("Binary sub_type is not Vector");if(this.buffer[0]!==Ke.VECTOR_TYPE.Int8)throw new pe("Binary datatype field is not Int8");return xi(this),new Int8Array(this.buffer.buffer.slice(this.buffer.byteOffset+2,this.buffer.byteOffset+this.position))}toFloat32Array(){if(this.sub_type!==Ke.SUBTYPE_VECTOR)throw new pe("Binary sub_type is not Vector");if(this.buffer[0]!==Ke.VECTOR_TYPE.Float32)throw new pe("Binary datatype field is not Float32");xi(this);const t=new Uint8Array(this.buffer.buffer.slice(this.buffer.byteOffset+2,this.buffer.byteOffset+this.position));return ao.isBigEndian&&_e.swap32(t),new Float32Array(t.buffer)}toPackedBits(){if(this.sub_type!==Ke.SUBTYPE_VECTOR)throw new pe("Binary sub_type is not Vector");if(this.buffer[0]!==Ke.VECTOR_TYPE.PackedBit)throw new pe("Binary datatype field is not packed bit");return xi(this),new Uint8Array(this.buffer.buffer.slice(this.buffer.byteOffset+2,this.buffer.byteOffset+this.position))}toBits(){if(this.sub_type!==Ke.SUBTYPE_VECTOR)throw new pe("Binary sub_type is not Vector");if(this.buffer[0]!==Ke.VECTOR_TYPE.PackedBit)throw new pe("Binary datatype field is not packed bit");xi(this);const i=(this.length()-2)*8-this.buffer[1],o=new Int8Array(i);for(let l=0;l<o.length;l++){const u=l/8|0,c=this.buffer[u+2],d=7-l%8,m=c>>d&1;o[l]=m}return o}static fromInt8Array(t){const i=_e.allocate(t.byteLength+2);i[0]=Ke.VECTOR_TYPE.Int8,i[1]=0;const o=new Uint8Array(t.buffer,t.byteOffset,t.byteLength);i.set(o,2);const l=new this(i,this.SUBTYPE_VECTOR);return xi(l),l}static fromFloat32Array(t){const i=_e.allocate(t.byteLength+2);i[0]=Ke.VECTOR_TYPE.Float32,i[1]=0;const o=new Uint8Array(t.buffer,t.byteOffset,t.byteLength);i.set(o,2),ao.isBigEndian&&_e.swap32(new Uint8Array(i.buffer,2));const l=new this(i,this.SUBTYPE_VECTOR);return xi(l),l}static fromPackedBits(t,i=0){const o=_e.allocate(t.byteLength+2);o[0]=Ke.VECTOR_TYPE.PackedBit,o[1]=i,o.set(t,2);const l=new this(o,this.SUBTYPE_VECTOR);return xi(l),l}static fromBits(t){const i=t.length+7>>>3,o=new Uint8Array(i+2);o[0]=Ke.VECTOR_TYPE.PackedBit;const l=t.length%8;o[1]=l===0?0:8-l;for(let u=0;u<t.length;u++){const c=u>>>3,d=t[u];if(d!==0&&d!==1)throw new pe(`Invalid bit value at ${u}: must be 0 or 1, found ${t[u]}`);if(d===0)continue;const m=7-u%8;o[c+2]|=d<<m}return new this(o,Ke.SUBTYPE_VECTOR)}}function xi(e){if(e.sub_type!==Ke.SUBTYPE_VECTOR)return;const t=e.position,i=e.buffer[0],o=e.buffer[1];if((i===Ke.VECTOR_TYPE.Float32||i===Ke.VECTOR_TYPE.Int8)&&o!==0)throw new pe("Invalid Vector: padding must be zero for int8 and float32 vectors");if(i===Ke.VECTOR_TYPE.Float32&&t!==0&&t-2!==0&&(t-2)%4!==0)throw new pe("Invalid Vector: Float32 vector must contain a multiple of 4 bytes");if(i===Ke.VECTOR_TYPE.PackedBit&&o!==0&&t===2)throw new pe("Invalid Vector: padding must be zero for packed bit vectors that are empty");if(i===Ke.VECTOR_TYPE.PackedBit&&o>7)throw new pe(`Invalid Vector: padding must be a value between 0 and 7. found: ${o}`)}const rh=16,UM=/^[0-9A-F]{32}$/i,LM=/^[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$/i;class xn extends Ke{constructor(t){let i;if(t==null)i=xn.generate();else if(t instanceof xn)i=_e.toLocalBufferType(new Uint8Array(t.buffer));else if(ArrayBuffer.isView(t)&&t.byteLength===rh)i=_e.toLocalBufferType(t);else if(typeof t=="string")i=xn.bytesFromString(t);else throw new pe("Argument passed in UUID constructor must be a UUID, a 16 byte Buffer or a 32/36 character hex string (dashes excluded/included, format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).");super(i,Nb)}get id(){return this.buffer}set id(t){this.buffer=t}toHexString(t=!0){return t?[_e.toHex(this.buffer.subarray(0,4)),_e.toHex(this.buffer.subarray(4,6)),_e.toHex(this.buffer.subarray(6,8)),_e.toHex(this.buffer.subarray(8,10)),_e.toHex(this.buffer.subarray(10,16))].join("-"):_e.toHex(this.buffer)}toString(t){return t==="hex"?_e.toHex(this.id):t==="base64"?_e.toBase64(this.id):this.toHexString()}toJSON(){return this.toHexString()}equals(t){if(!t)return!1;if(t instanceof xn)return _e.equals(t.id,this.id);try{return _e.equals(new xn(t).id,this.id)}catch{return!1}}toBinary(){return new Ke(this.id,Ke.SUBTYPE_UUID)}static generate(){const t=_e.randomBytes(rh);return t[6]=t[6]&15|64,t[8]=t[8]&63|128,t}static isValid(t){return t?typeof t=="string"?xn.isValidUUIDString(t):Ab(t)?t.byteLength===rh:t._bsontype==="Binary"&&t.sub_type===this.SUBTYPE_UUID&&t.buffer.byteLength===16:!1}static createFromHexString(t){const i=xn.bytesFromString(t);return new xn(i)}static createFromBase64(t){return new xn(_e.fromBase64(t))}static bytesFromString(t){if(!xn.isValidUUIDString(t))throw new pe("UUID string representation must be 32 hex digits or canonical hyphenated representation");return _e.fromHex(t.replace(/-/g,""))}static isValidUUIDString(t){return UM.test(t)||LM.test(t)}inspect(t,i,o){return o??=jn,`new UUID(${o(this.toHexString(),i)})`}}class Rl extends er{get _bsontype(){return"Code"}code;scope;constructor(t,i){super(),this.code=t.toString(),this.scope=i??null}toJSON(){return this.scope!=null?{code:this.code,scope:this.scope}:{code:this.code}}toExtendedJSON(){return this.scope?{$code:this.code,$scope:this.scope}:{$code:this.code}}static fromExtendedJSON(t){return new Rl(t.$code,t.$scope)}inspect(t,i,o){o??=jn;let l=o(this.code,i);const u=l.includes(`
|
|
161
161
|
`);this.scope!=null&&(l+=`,${u?`
|
|
162
162
|
`:" "}${o(this.scope,i)}`);const c=u&&this.scope===null;return`new Code(${u?`
|
|
163
163
|
`:""}${l}${c?`
|
package/package.json
CHANGED
|
@@ -46,7 +46,7 @@ export function ChatWidget({
|
|
|
46
46
|
}) {
|
|
47
47
|
|
|
48
48
|
const inputRef = useRef<HTMLInputElement | HTMLTextAreaElement | null>(null);
|
|
49
|
-
const endRef = useRef<
|
|
49
|
+
const endRef = useRef<HTMLAnchorElement | null>(null);
|
|
50
50
|
const theme = useTheme();
|
|
51
51
|
const isMobile = useMediaQuery(theme.breakpoints.down("md"));
|
|
52
52
|
useViewportHeightVar();
|
|
@@ -142,7 +142,7 @@ export function ChatWidget({
|
|
|
142
142
|
boxShadow: isMobile ? "none" : "0 18px 60px rgba(0,0,0,.28)"
|
|
143
143
|
}}
|
|
144
144
|
>
|
|
145
|
-
<Box sx={{ display: "flex", flexDirection: "column", height: "100%"}}>
|
|
145
|
+
<Box sx={{ display: "flex", flexDirection: "column", height: "100%" }}>
|
|
146
146
|
|
|
147
147
|
<Box
|
|
148
148
|
sx={{
|
|
@@ -202,6 +202,8 @@ export function ChatWidget({
|
|
|
202
202
|
|
|
203
203
|
<Box
|
|
204
204
|
sx={{
|
|
205
|
+
display: "flex",
|
|
206
|
+
flexDirection: "column",
|
|
205
207
|
flex: 1,
|
|
206
208
|
minHeight: 0,
|
|
207
209
|
overflow: "auto",
|
|
@@ -221,7 +223,7 @@ export function ChatWidget({
|
|
|
221
223
|
}}
|
|
222
224
|
>
|
|
223
225
|
<MessageList msgs={msgs} isMessageSeen={isMessageSeen} />
|
|
224
|
-
<div
|
|
226
|
+
<div style={{ paddingBottom: 2 }}>
|
|
225
227
|
{sending && (
|
|
226
228
|
<Box sx={{ display: "flex", alignItems: "flex-end", gap: 1, mb: 1.2 }}>
|
|
227
229
|
<Avatar sx={{ width: 30, height: 30, bgcolor: "primary.main" }}>
|
|
@@ -286,24 +288,26 @@ export function ChatWidget({
|
|
|
286
288
|
</Box>
|
|
287
289
|
</Box>
|
|
288
290
|
)}
|
|
289
|
-
|
|
290
|
-
<Link
|
|
291
|
-
href="https://x-bot.ro"
|
|
292
|
-
target="_blank"
|
|
293
|
-
rel="noreferrer"
|
|
294
|
-
underline="none"
|
|
295
|
-
sx={{
|
|
296
|
-
fontSize: 12,
|
|
297
|
-
color: "text.secondary",
|
|
298
|
-
opacity: 0.75,
|
|
299
|
-
"&:hover": { opacity: 1, color: "text.primary" },
|
|
300
|
-
display: "flex", justifyContent: "center"
|
|
301
|
-
}}
|
|
302
|
-
>
|
|
303
|
-
Chat oferit de X-bot.ro
|
|
304
|
-
</Link>
|
|
305
291
|
</div>
|
|
306
|
-
|
|
292
|
+
<Link
|
|
293
|
+
ref={endRef}
|
|
294
|
+
href="https://x-bot.ro"
|
|
295
|
+
target="_blank"
|
|
296
|
+
rel="noreferrer"
|
|
297
|
+
underline="none"
|
|
298
|
+
sx={{
|
|
299
|
+
pb:1,
|
|
300
|
+
marginTop: "auto",
|
|
301
|
+
alignSelf: "center",
|
|
302
|
+
fontSize: 12,
|
|
303
|
+
color: "text.secondary",
|
|
304
|
+
opacity: 0.75,
|
|
305
|
+
"&:hover": { opacity: 1, color: "text.primary" },
|
|
306
|
+
justifyContent: "center"
|
|
307
|
+
}}
|
|
308
|
+
>
|
|
309
|
+
Chat oferit de X-bot.ro
|
|
310
|
+
</Link>
|
|
307
311
|
|
|
308
312
|
</Box>
|
|
309
313
|
|
|
index 547fbdd..0d84101 100644
|
|
|
Binary file
|