randmarcomps 1.455.0 → 1.456.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/randmarcomps.js +16 -11
- package/dist/randmarcomps.umd.cjs +1 -1
- package/package.json +1 -1
package/dist/randmarcomps.js
CHANGED
|
@@ -59692,7 +59692,10 @@ function ChatMessages({ messages: t, appID: e, botStatus: n, isAssistantChat: o
|
|
|
59692
59692
|
] }) }, d.id);
|
|
59693
59693
|
}),
|
|
59694
59694
|
n !== "" && /* @__PURE__ */ jsx(SkeletonMessage, { botStatus: n }),
|
|
59695
|
-
t.length === 0 && !o && /* @__PURE__ */
|
|
59695
|
+
t.length === 0 && !o && /* @__PURE__ */ jsxs("div", { className: "mt-1 text-xl", children: [
|
|
59696
|
+
/* @__PURE__ */ jsx(Send, { className: "w-full h-32" }),
|
|
59697
|
+
/* @__PURE__ */ jsx("p", { className: "text-center", children: "No messages yet... Say hello!" })
|
|
59698
|
+
] }),
|
|
59696
59699
|
t.length === 0 && n === "" && o && /* @__PURE__ */ jsxs("div", { className: "text-center py-8", children: [
|
|
59697
59700
|
/* @__PURE__ */ jsx("p", { children: "The Randmar Assistant is ready to help you. Ask anything about products, orders, carts, shipments and tracking numbers." }),
|
|
59698
59701
|
/* @__PURE__ */ jsx("p", { children: /* @__PURE__ */ jsx("strong", { children: 'Try it now, type "my open orders"!' }) })
|
|
@@ -59730,7 +59733,7 @@ function ChatMainArea({
|
|
|
59730
59733
|
] }),
|
|
59731
59734
|
e != null && e.pending && e.partner1 == n ? /* @__PURE__ */ jsx("p", { className: "mt-8 p-2 mx-auto", children: "This conversation is awaiting approval by the other party — please check back later." }) : /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
59732
59735
|
/* @__PURE__ */ jsxs(ScrollArea, { className: "flex-1 pl-2 pr-2 bg-slate-50", children: [
|
|
59733
|
-
/* @__PURE__ */ jsx(
|
|
59736
|
+
/* @__PURE__ */ jsx("div", { className: (e == null ? void 0 : e.messages) === null ? " opacity-0" : "", children: /* @__PURE__ */ jsx(
|
|
59734
59737
|
ChatMessages,
|
|
59735
59738
|
{
|
|
59736
59739
|
messages: (e == null ? void 0 : e.messages) ?? [],
|
|
@@ -59738,7 +59741,7 @@ function ChatMainArea({
|
|
|
59738
59741
|
isAssistantChat: !1,
|
|
59739
59742
|
botStatus: ""
|
|
59740
59743
|
}
|
|
59741
|
-
),
|
|
59744
|
+
) }),
|
|
59742
59745
|
/* @__PURE__ */ jsx("div", { ref: o })
|
|
59743
59746
|
] }),
|
|
59744
59747
|
/* @__PURE__ */ jsxs("div", { className: "p-4 border-t border-r flex", children: [
|
|
@@ -59884,7 +59887,7 @@ function ChatLayout({ appID: t, inputRef: e, className: n }) {
|
|
|
59884
59887
|
name: ((We = Mt.Participant) == null ? void 0 : We.PublicName) ?? "missing public name",
|
|
59885
59888
|
unread: (It == null ? void 0 : It.unread) ?? 0,
|
|
59886
59889
|
pending: Mt.Status !== "Approved",
|
|
59887
|
-
messages: (It == null ? void 0 : It.messages) ??
|
|
59890
|
+
messages: (It == null ? void 0 : It.messages) ?? null,
|
|
59888
59891
|
conversationID: Mt.ConversationId,
|
|
59889
59892
|
lastMessageTime: Mt.LastMessageTime ?? null
|
|
59890
59893
|
};
|
|
@@ -59912,13 +59915,15 @@ function ChatLayout({ appID: t, inputRef: e, className: n }) {
|
|
|
59912
59915
|
return;
|
|
59913
59916
|
}
|
|
59914
59917
|
se((It) => It.map((We) => {
|
|
59915
|
-
if (!ct(Mt, We)
|
|
59916
|
-
|
|
59917
|
-
|
|
59918
|
-
|
|
59919
|
-
|
|
59920
|
-
|
|
59921
|
-
|
|
59918
|
+
if (!ct(Mt, We)) return We;
|
|
59919
|
+
const Ye = We.messages ?? [];
|
|
59920
|
+
if (Ye.some((pt) => pt.id === Mt.id)) return We;
|
|
59921
|
+
let nt = 1;
|
|
59922
|
+
const ut = document.activeElement && document.activeElement === Le.current;
|
|
59923
|
+
return (V == null ? void 0 : V[0]) == We.partner1 && V[1] == We.partner2 && ut && (ut && (nt = 0, Qe()), setTimeout(() => {
|
|
59924
|
+
var pt;
|
|
59925
|
+
return (pt = Ne.current) == null ? void 0 : pt.scrollIntoView({ behavior: "smooth" });
|
|
59926
|
+
}, 50)), { ...We, pending: !1, unread: We.unread + nt, messages: [...Ye, Mt] };
|
|
59922
59927
|
}).sort(sortChats));
|
|
59923
59928
|
}), console.log("need refetch:", Ct), Ct && d(), Ve([]);
|
|
59924
59929
|
}, [Fe, Ve, se, j, V]), useEffect(() => {
|
|
@@ -1135,7 +1135,7 @@ ${t}</tr>
|
|
|
1135
1135
|
`}strong({tokens:t}){return`<strong>${this.parser.parseInline(t)}</strong>`}em({tokens:t}){return`<em>${this.parser.parseInline(t)}</em>`}codespan({text:t}){return`<code>${escape2(t,!0)}</code>`}br(t){return"<br>"}del({tokens:t}){return`<del>${this.parser.parseInline(t)}</del>`}link({href:t,title:e,tokens:n}){const o=this.parser.parseInline(n),l=cleanUrl(t);if(l===null)return o;t=l;let d='<a href="'+t+'"';return e&&(d+=' title="'+escape2(e)+'"'),d+=">"+o+"</a>",d}image({href:t,title:e,text:n,tokens:o}){o&&(n=this.parser.parseInline(o,this.parser.textRenderer));const l=cleanUrl(t);if(l===null)return escape2(n);t=l;let d=`<img src="${t}" alt="${n}"`;return e&&(d+=` title="${escape2(e)}"`),d+=">",d}text(t){return"tokens"in t&&t.tokens?this.parser.parseInline(t.tokens):"escaped"in t&&t.escaped?t.text:escape2(t.text)}},_TextRenderer=class{strong({text:t}){return t}em({text:t}){return t}codespan({text:t}){return t}del({text:t}){return t}html({text:t}){return t}text({text:t}){return t}link({text:t}){return""+t}image({text:t}){return""+t}br(){return""}},_Parser=class yr{constructor(e){Zt(this,"options");Zt(this,"renderer");Zt(this,"textRenderer");this.options=e||_defaults,this.options.renderer=this.options.renderer||new _Renderer,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new _TextRenderer}static parse(e,n){return new yr(n).parse(e)}static parseInline(e,n){return new yr(n).parseInline(e)}parse(e,n=!0){var l,d;let o="";for(let f=0;f<e.length;f++){const g=e[f];if((d=(l=this.options.extensions)==null?void 0:l.renderers)!=null&&d[g.type]){const _=g,S=this.options.extensions.renderers[_.type].call({parser:this},_);if(S!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(_.type)){o+=S||"";continue}}const b=g;switch(b.type){case"space":{o+=this.renderer.space(b);continue}case"hr":{o+=this.renderer.hr(b);continue}case"heading":{o+=this.renderer.heading(b);continue}case"code":{o+=this.renderer.code(b);continue}case"table":{o+=this.renderer.table(b);continue}case"blockquote":{o+=this.renderer.blockquote(b);continue}case"list":{o+=this.renderer.list(b);continue}case"html":{o+=this.renderer.html(b);continue}case"paragraph":{o+=this.renderer.paragraph(b);continue}case"text":{let _=b,S=this.renderer.text(_);for(;f+1<e.length&&e[f+1].type==="text";)_=e[++f],S+=`
|
|
1136
1136
|
`+this.renderer.text(_);n?o+=this.renderer.paragraph({type:"paragraph",raw:S,text:S,tokens:[{type:"text",raw:S,text:S,escaped:!0}]}):o+=S;continue}default:{const _='Token with "'+b.type+'" type was not found.';if(this.options.silent)return console.error(_),"";throw new Error(_)}}}return o}parseInline(e,n=this.renderer){var l,d;let o="";for(let f=0;f<e.length;f++){const g=e[f];if((d=(l=this.options.extensions)==null?void 0:l.renderers)!=null&&d[g.type]){const _=this.options.extensions.renderers[g.type].call({parser:this},g);if(_!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(g.type)){o+=_||"";continue}}const b=g;switch(b.type){case"escape":{o+=n.text(b);break}case"html":{o+=n.html(b);break}case"link":{o+=n.link(b);break}case"image":{o+=n.image(b);break}case"strong":{o+=n.strong(b);break}case"em":{o+=n.em(b);break}case"codespan":{o+=n.codespan(b);break}case"br":{o+=n.br(b);break}case"del":{o+=n.del(b);break}case"text":{o+=n.text(b);break}default:{const _='Token with "'+b.type+'" type was not found.';if(this.options.silent)return console.error(_),"";throw new Error(_)}}}return o}},_Hooks=(on=class{constructor(t){Zt(this,"options");Zt(this,"block");this.options=t||_defaults}preprocess(t){return t}postprocess(t){return t}processAllTokens(t){return t}provideLexer(){return this.block?_Lexer.lex:_Lexer.lexInline}provideParser(){return this.block?_Parser.parse:_Parser.parseInline}},Zt(on,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens"])),on),Marked=class{constructor(...t){Zt(this,"defaults",_getDefaults());Zt(this,"options",this.setOptions);Zt(this,"parse",this.parseMarkdown(!0));Zt(this,"parseInline",this.parseMarkdown(!1));Zt(this,"Parser",_Parser);Zt(this,"Renderer",_Renderer);Zt(this,"TextRenderer",_TextRenderer);Zt(this,"Lexer",_Lexer);Zt(this,"Tokenizer",_Tokenizer);Zt(this,"Hooks",_Hooks);this.use(...t)}walkTokens(t,e){var o,l;let n=[];for(const d of t)switch(n=n.concat(e.call(this,d)),d.type){case"table":{const f=d;for(const g of f.header)n=n.concat(this.walkTokens(g.tokens,e));for(const g of f.rows)for(const b of g)n=n.concat(this.walkTokens(b.tokens,e));break}case"list":{const f=d;n=n.concat(this.walkTokens(f.items,e));break}default:{const f=d;(l=(o=this.defaults.extensions)==null?void 0:o.childTokens)!=null&&l[f.type]?this.defaults.extensions.childTokens[f.type].forEach(g=>{const b=f[g].flat(1/0);n=n.concat(this.walkTokens(b,e))}):f.tokens&&(n=n.concat(this.walkTokens(f.tokens,e)))}}return n}use(...t){const e=this.defaults.extensions||{renderers:{},childTokens:{}};return t.forEach(n=>{const o={...n};if(o.async=this.defaults.async||o.async||!1,n.extensions&&(n.extensions.forEach(l=>{if(!l.name)throw new Error("extension name required");if("renderer"in l){const d=e.renderers[l.name];d?e.renderers[l.name]=function(...f){let g=l.renderer.apply(this,f);return g===!1&&(g=d.apply(this,f)),g}:e.renderers[l.name]=l.renderer}if("tokenizer"in l){if(!l.level||l.level!=="block"&&l.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");const d=e[l.level];d?d.unshift(l.tokenizer):e[l.level]=[l.tokenizer],l.start&&(l.level==="block"?e.startBlock?e.startBlock.push(l.start):e.startBlock=[l.start]:l.level==="inline"&&(e.startInline?e.startInline.push(l.start):e.startInline=[l.start]))}"childTokens"in l&&l.childTokens&&(e.childTokens[l.name]=l.childTokens)}),o.extensions=e),n.renderer){const l=this.defaults.renderer||new _Renderer(this.defaults);for(const d in n.renderer){if(!(d in l))throw new Error(`renderer '${d}' does not exist`);if(["options","parser"].includes(d))continue;const f=d,g=n.renderer[f],b=l[f];l[f]=(..._)=>{let S=g.apply(l,_);return S===!1&&(S=b.apply(l,_)),S||""}}o.renderer=l}if(n.tokenizer){const l=this.defaults.tokenizer||new _Tokenizer(this.defaults);for(const d in n.tokenizer){if(!(d in l))throw new Error(`tokenizer '${d}' does not exist`);if(["options","rules","lexer"].includes(d))continue;const f=d,g=n.tokenizer[f],b=l[f];l[f]=(..._)=>{let S=g.apply(l,_);return S===!1&&(S=b.apply(l,_)),S}}o.tokenizer=l}if(n.hooks){const l=this.defaults.hooks||new _Hooks;for(const d in n.hooks){if(!(d in l))throw new Error(`hook '${d}' does not exist`);if(["options","block"].includes(d))continue;const f=d,g=n.hooks[f],b=l[f];_Hooks.passThroughHooks.has(d)?l[f]=_=>{if(this.defaults.async)return Promise.resolve(g.call(l,_)).then(R=>b.call(l,R));const S=g.call(l,_);return b.call(l,S)}:l[f]=(..._)=>{let S=g.apply(l,_);return S===!1&&(S=b.apply(l,_)),S}}o.hooks=l}if(n.walkTokens){const l=this.defaults.walkTokens,d=n.walkTokens;o.walkTokens=function(f){let g=[];return g.push(d.call(this,f)),l&&(g=g.concat(l.call(this,f))),g}}this.defaults={...this.defaults,...o}}),this}setOptions(t){return this.defaults={...this.defaults,...t},this}lexer(t,e){return _Lexer.lex(t,e??this.defaults)}parser(t,e){return _Parser.parse(t,e??this.defaults)}parseMarkdown(t){return(n,o)=>{const l={...o},d={...this.defaults,...l},f=this.onError(!!d.silent,!!d.async);if(this.defaults.async===!0&&l.async===!1)return f(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof n>"u"||n===null)return f(new Error("marked(): input parameter is undefined or null"));if(typeof n!="string")return f(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(n)+", string expected"));d.hooks&&(d.hooks.options=d,d.hooks.block=t);const g=d.hooks?d.hooks.provideLexer():t?_Lexer.lex:_Lexer.lexInline,b=d.hooks?d.hooks.provideParser():t?_Parser.parse:_Parser.parseInline;if(d.async)return Promise.resolve(d.hooks?d.hooks.preprocess(n):n).then(_=>g(_,d)).then(_=>d.hooks?d.hooks.processAllTokens(_):_).then(_=>d.walkTokens?Promise.all(this.walkTokens(_,d.walkTokens)).then(()=>_):_).then(_=>b(_,d)).then(_=>d.hooks?d.hooks.postprocess(_):_).catch(f);try{d.hooks&&(n=d.hooks.preprocess(n));let _=g(n,d);d.hooks&&(_=d.hooks.processAllTokens(_)),d.walkTokens&&this.walkTokens(_,d.walkTokens);let S=b(_,d);return d.hooks&&(S=d.hooks.postprocess(S)),S}catch(_){return f(_)}}}onError(t,e){return n=>{if(n.message+=`
|
|
1137
1137
|
Please report this to https://github.com/markedjs/marked.`,t){const o="<p>An error occurred:</p><pre>"+escape2(n.message+"",!0)+"</pre>";return e?Promise.resolve(o):o}if(e)return Promise.reject(n);throw n}}},markedInstance=new Marked;function marked(t,e){return markedInstance.parse(t,e)}marked.options=marked.setOptions=function(t){return markedInstance.setOptions(t),marked.defaults=markedInstance.defaults,changeDefaults(marked.defaults),marked},marked.getDefaults=_getDefaults,marked.defaults=_defaults,marked.use=function(...t){return markedInstance.use(...t),marked.defaults=markedInstance.defaults,changeDefaults(marked.defaults),marked},marked.walkTokens=function(t,e){return markedInstance.walkTokens(t,e)},marked.parseInline=markedInstance.parseInline,marked.Parser=_Parser,marked.parser=_Parser.parse,marked.Renderer=_Renderer,marked.TextRenderer=_TextRenderer,marked.Lexer=_Lexer,marked.lexer=_Lexer.lex,marked.Tokenizer=_Tokenizer,marked.Hooks=_Hooks,marked.parse=marked,marked.options,marked.setOptions,marked.use,marked.walkTokens,marked.parseInline,_Parser.parse,_Lexer.lex;/*! @license DOMPurify 3.3.0 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.3.0/LICENSE */const{entries,setPrototypeOf,isFrozen,getPrototypeOf,getOwnPropertyDescriptor}=Object;let{freeze,seal,create}=Object,{apply:apply$1,construct}=typeof Reflect<"u"&&Reflect;freeze||(freeze=function(e){return e}),seal||(seal=function(e){return e}),apply$1||(apply$1=function(e,n){for(var o=arguments.length,l=new Array(o>2?o-2:0),d=2;d<o;d++)l[d-2]=arguments[d];return e.apply(n,l)}),construct||(construct=function(e){for(var n=arguments.length,o=new Array(n>1?n-1:0),l=1;l<n;l++)o[l-1]=arguments[l];return new e(...o)});const arrayForEach=unapply(Array.prototype.forEach),arrayLastIndexOf=unapply(Array.prototype.lastIndexOf),arrayPop=unapply(Array.prototype.pop),arrayPush=unapply(Array.prototype.push),arraySplice=unapply(Array.prototype.splice),stringToLowerCase=unapply(String.prototype.toLowerCase),stringToString=unapply(String.prototype.toString),stringMatch=unapply(String.prototype.match),stringReplace=unapply(String.prototype.replace),stringIndexOf=unapply(String.prototype.indexOf),stringTrim=unapply(String.prototype.trim),objectHasOwnProperty=unapply(Object.prototype.hasOwnProperty),regExpTest=unapply(RegExp.prototype.test),typeErrorCreate=unconstruct(TypeError);function unapply(t){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var n=arguments.length,o=new Array(n>1?n-1:0),l=1;l<n;l++)o[l-1]=arguments[l];return apply$1(t,e,o)}}function unconstruct(t){return function(){for(var e=arguments.length,n=new Array(e),o=0;o<e;o++)n[o]=arguments[o];return construct(t,n)}}function addToSet(t,e){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:stringToLowerCase;setPrototypeOf&&setPrototypeOf(t,null);let o=e.length;for(;o--;){let l=e[o];if(typeof l=="string"){const d=n(l);d!==l&&(isFrozen(e)||(e[o]=d),l=d)}t[l]=!0}return t}function cleanArray(t){for(let e=0;e<t.length;e++)objectHasOwnProperty(t,e)||(t[e]=null);return t}function clone(t){const e=create(null);for(const[n,o]of entries(t))objectHasOwnProperty(t,n)&&(Array.isArray(o)?e[n]=cleanArray(o):o&&typeof o=="object"&&o.constructor===Object?e[n]=clone(o):e[n]=o);return e}function lookupGetter(t,e){for(;t!==null;){const o=getOwnPropertyDescriptor(t,e);if(o){if(o.get)return unapply(o.get);if(typeof o.value=="function")return unapply(o.value)}t=getPrototypeOf(t)}function n(){return null}return n}const html$1=freeze(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),svg$1=freeze(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),svgFilters=freeze(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),svgDisallowed=freeze(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),mathMl$1=freeze(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),mathMlDisallowed=freeze(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),text$1=freeze(["#text"]),html=freeze(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),svg=freeze(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),mathMl=freeze(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),xml=freeze(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),MUSTACHE_EXPR=seal(/\{\{[\w\W]*|[\w\W]*\}\}/gm),ERB_EXPR=seal(/<%[\w\W]*|[\w\W]*%>/gm),TMPLIT_EXPR=seal(/\$\{[\w\W]*/gm),DATA_ATTR=seal(/^data-[\-\w.\u00B7-\uFFFF]+$/),ARIA_ATTR=seal(/^aria-[\-\w]+$/),IS_ALLOWED_URI=seal(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),IS_SCRIPT_OR_DATA=seal(/^(?:\w+script|data):/i),ATTR_WHITESPACE=seal(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),DOCTYPE_NAME=seal(/^html$/i),CUSTOM_ELEMENT=seal(/^[a-z][.\w]*(-[.\w]+)+$/i);var EXPRESSIONS=Object.freeze({__proto__:null,ARIA_ATTR,ATTR_WHITESPACE,CUSTOM_ELEMENT,DATA_ATTR,DOCTYPE_NAME,ERB_EXPR,IS_ALLOWED_URI,IS_SCRIPT_OR_DATA,MUSTACHE_EXPR,TMPLIT_EXPR});const NODE_TYPE={element:1,text:3,progressingInstruction:7,comment:8,document:9},getGlobal=function t(){return typeof window>"u"?null:window},_createTrustedTypesPolicy=function t(e,n){if(typeof e!="object"||typeof e.createPolicy!="function")return null;let o=null;const l="data-tt-policy-suffix";n&&n.hasAttribute(l)&&(o=n.getAttribute(l));const d="dompurify"+(o?"#"+o:"");try{return e.createPolicy(d,{createHTML(f){return f},createScriptURL(f){return f}})}catch{return console.warn("TrustedTypes policy "+d+" could not be created."),null}},_createHooksMap=function t(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function createDOMPurify(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:getGlobal();const e=Yt=>createDOMPurify(Yt);if(e.version="3.3.0",e.removed=[],!t||!t.document||t.document.nodeType!==NODE_TYPE.document||!t.Element)return e.isSupported=!1,e;let{document:n}=t;const o=n,l=o.currentScript,{DocumentFragment:d,HTMLTemplateElement:f,Node:g,Element:b,NodeFilter:_,NamedNodeMap:S=t.NamedNodeMap||t.MozNamedAttrMap,HTMLFormElement:R,DOMParser:C,trustedTypes:E}=t,A=b.prototype,M=lookupGetter(A,"cloneNode"),I=lookupGetter(A,"remove"),j=lookupGetter(A,"nextSibling"),F=lookupGetter(A,"childNodes"),z=lookupGetter(A,"parentNode");if(typeof f=="function"){const Yt=n.createElement("template");Yt.content&&Yt.content.ownerDocument&&(n=Yt.content.ownerDocument)}let Q,O="";const{implementation:V,createNodeIterator:te,createDocumentFragment:ne,getElementsByTagName:ae}=n,{importNode:$e}=o;let ge=_createHooksMap();e.isSupported=typeof entries=="function"&&typeof z=="function"&&V&&V.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:se,ERB_EXPR:je,TMPLIT_EXPR:Ae,DATA_ATTR:Ne,ARIA_ATTR:Ve,IS_SCRIPT_OR_DATA:Fe,ATTR_WHITESPACE:Oe,CUSTOM_ELEMENT:Be}=EXPRESSIONS;let{IS_ALLOWED_URI:Ue}=EXPRESSIONS,ze=null;const He=addToSet({},[...html$1,...svg$1,...svgFilters,...mathMl$1,...text$1]);let Qe=null;const et=addToSet({},[...html,...svg,...mathMl,...xml]);let Je=Object.seal(create(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Ze=null,Ke=null;const at=Object.seal(create(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let nt=!0,st=!0,lt=!1,Ge=!0,Ct=!1,tt=!0,yt=!1,ct=!1,Rt=!1,Mt=!1,It=!1,We=!1,Ye=!0,rt=!1;const ut="user-content-";let pt=!0,ft=!1,mt={},Ut=null;const Wt=addToSet({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let sn=null;const pn=addToSet({},["audio","video","img","source","image","track"]);let qt=null;const Tn=addToSet({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),vn="http://www.w3.org/1998/Math/MathML",Sn="http://www.w3.org/2000/svg",yn="http://www.w3.org/1999/xhtml";let Rn=yn,jn=!1,Nn=null;const Qt=addToSet({},[vn,Sn,yn],stringToString);let en=addToSet({},["mi","mo","mn","ms","mtext"]),Kt=addToSet({},["annotation-xml"]);const Jt=addToSet({},["title","style","font","a","script"]);let dn=null;const Vt=["application/xhtml+xml","text/html"],Gn="text/html";let hn=null,$n=null;const On=n.createElement("form"),Pn=function(it){return it instanceof RegExp||it instanceof Function},Xn=function(){let it=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!($n&&$n===it)){if((!it||typeof it!="object")&&(it={}),it=clone(it),dn=Vt.indexOf(it.PARSER_MEDIA_TYPE)===-1?Gn:it.PARSER_MEDIA_TYPE,hn=dn==="application/xhtml+xml"?stringToString:stringToLowerCase,ze=objectHasOwnProperty(it,"ALLOWED_TAGS")?addToSet({},it.ALLOWED_TAGS,hn):He,Qe=objectHasOwnProperty(it,"ALLOWED_ATTR")?addToSet({},it.ALLOWED_ATTR,hn):et,Nn=objectHasOwnProperty(it,"ALLOWED_NAMESPACES")?addToSet({},it.ALLOWED_NAMESPACES,stringToString):Qt,qt=objectHasOwnProperty(it,"ADD_URI_SAFE_ATTR")?addToSet(clone(Tn),it.ADD_URI_SAFE_ATTR,hn):Tn,sn=objectHasOwnProperty(it,"ADD_DATA_URI_TAGS")?addToSet(clone(pn),it.ADD_DATA_URI_TAGS,hn):pn,Ut=objectHasOwnProperty(it,"FORBID_CONTENTS")?addToSet({},it.FORBID_CONTENTS,hn):Wt,Ze=objectHasOwnProperty(it,"FORBID_TAGS")?addToSet({},it.FORBID_TAGS,hn):clone({}),Ke=objectHasOwnProperty(it,"FORBID_ATTR")?addToSet({},it.FORBID_ATTR,hn):clone({}),mt=objectHasOwnProperty(it,"USE_PROFILES")?it.USE_PROFILES:!1,nt=it.ALLOW_ARIA_ATTR!==!1,st=it.ALLOW_DATA_ATTR!==!1,lt=it.ALLOW_UNKNOWN_PROTOCOLS||!1,Ge=it.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Ct=it.SAFE_FOR_TEMPLATES||!1,tt=it.SAFE_FOR_XML!==!1,yt=it.WHOLE_DOCUMENT||!1,Mt=it.RETURN_DOM||!1,It=it.RETURN_DOM_FRAGMENT||!1,We=it.RETURN_TRUSTED_TYPE||!1,Rt=it.FORCE_BODY||!1,Ye=it.SANITIZE_DOM!==!1,rt=it.SANITIZE_NAMED_PROPS||!1,pt=it.KEEP_CONTENT!==!1,ft=it.IN_PLACE||!1,Ue=it.ALLOWED_URI_REGEXP||IS_ALLOWED_URI,Rn=it.NAMESPACE||yn,en=it.MATHML_TEXT_INTEGRATION_POINTS||en,Kt=it.HTML_INTEGRATION_POINTS||Kt,Je=it.CUSTOM_ELEMENT_HANDLING||{},it.CUSTOM_ELEMENT_HANDLING&&Pn(it.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(Je.tagNameCheck=it.CUSTOM_ELEMENT_HANDLING.tagNameCheck),it.CUSTOM_ELEMENT_HANDLING&&Pn(it.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(Je.attributeNameCheck=it.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),it.CUSTOM_ELEMENT_HANDLING&&typeof it.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(Je.allowCustomizedBuiltInElements=it.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),Ct&&(st=!1),It&&(Mt=!0),mt&&(ze=addToSet({},text$1),Qe=[],mt.html===!0&&(addToSet(ze,html$1),addToSet(Qe,html)),mt.svg===!0&&(addToSet(ze,svg$1),addToSet(Qe,svg),addToSet(Qe,xml)),mt.svgFilters===!0&&(addToSet(ze,svgFilters),addToSet(Qe,svg),addToSet(Qe,xml)),mt.mathMl===!0&&(addToSet(ze,mathMl$1),addToSet(Qe,mathMl),addToSet(Qe,xml))),it.ADD_TAGS&&(typeof it.ADD_TAGS=="function"?at.tagCheck=it.ADD_TAGS:(ze===He&&(ze=clone(ze)),addToSet(ze,it.ADD_TAGS,hn))),it.ADD_ATTR&&(typeof it.ADD_ATTR=="function"?at.attributeCheck=it.ADD_ATTR:(Qe===et&&(Qe=clone(Qe)),addToSet(Qe,it.ADD_ATTR,hn))),it.ADD_URI_SAFE_ATTR&&addToSet(qt,it.ADD_URI_SAFE_ATTR,hn),it.FORBID_CONTENTS&&(Ut===Wt&&(Ut=clone(Ut)),addToSet(Ut,it.FORBID_CONTENTS,hn)),pt&&(ze["#text"]=!0),yt&&addToSet(ze,["html","head","body"]),ze.table&&(addToSet(ze,["tbody"]),delete Ze.tbody),it.TRUSTED_TYPES_POLICY){if(typeof it.TRUSTED_TYPES_POLICY.createHTML!="function")throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof it.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');Q=it.TRUSTED_TYPES_POLICY,O=Q.createHTML("")}else Q===void 0&&(Q=_createTrustedTypesPolicy(E,l)),Q!==null&&typeof O=="string"&&(O=Q.createHTML(""));freeze&&freeze(it),$n=it}},Bn=addToSet({},[...svg$1,...svgFilters,...svgDisallowed]),Ln=addToSet({},[...mathMl$1,...mathMlDisallowed]),ar=function(it){let $t=z(it);(!$t||!$t.tagName)&&($t={namespaceURI:Rn,tagName:"template"});const zt=stringToLowerCase(it.tagName),fn=stringToLowerCase($t.tagName);return Nn[it.namespaceURI]?it.namespaceURI===Sn?$t.namespaceURI===yn?zt==="svg":$t.namespaceURI===vn?zt==="svg"&&(fn==="annotation-xml"||en[fn]):!!Bn[zt]:it.namespaceURI===vn?$t.namespaceURI===yn?zt==="math":$t.namespaceURI===Sn?zt==="math"&&Kt[fn]:!!Ln[zt]:it.namespaceURI===yn?$t.namespaceURI===Sn&&!Kt[fn]||$t.namespaceURI===vn&&!en[fn]?!1:!Ln[zt]&&(Jt[zt]||!Bn[zt]):!!(dn==="application/xhtml+xml"&&Nn[it.namespaceURI]):!1},Cn=function(it){arrayPush(e.removed,{element:it});try{z(it).removeChild(it)}catch{I(it)}},Dn=function(it,$t){try{arrayPush(e.removed,{attribute:$t.getAttributeNode(it),from:$t})}catch{arrayPush(e.removed,{attribute:null,from:$t})}if($t.removeAttribute(it),it==="is")if(Mt||It)try{Cn($t)}catch{}else try{$t.setAttribute(it,"")}catch{}},Qn=function(it){let $t=null,zt=null;if(Rt)it="<remove></remove>"+it;else{const mn=stringMatch(it,/^[\r\n\t ]+/);zt=mn&&mn[0]}dn==="application/xhtml+xml"&&Rn===yn&&(it='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+it+"</body></html>");const fn=Q?Q.createHTML(it):it;if(Rn===yn)try{$t=new C().parseFromString(fn,dn)}catch{}if(!$t||!$t.documentElement){$t=V.createDocument(Rn,"template",null);try{$t.documentElement.innerHTML=jn?O:fn}catch{}}const xn=$t.body||$t.documentElement;return it&&zt&&xn.insertBefore(n.createTextNode(zt),xn.childNodes[0]||null),Rn===yn?ae.call($t,yt?"html":"body")[0]:yt?$t.documentElement:xn},Zn=function(it){return te.call(it.ownerDocument||it,it,_.SHOW_ELEMENT|_.SHOW_COMMENT|_.SHOW_TEXT|_.SHOW_PROCESSING_INSTRUCTION|_.SHOW_CDATA_SECTION,null)},zn=function(it){return it instanceof R&&(typeof it.nodeName!="string"||typeof it.textContent!="string"||typeof it.removeChild!="function"||!(it.attributes instanceof S)||typeof it.removeAttribute!="function"||typeof it.setAttribute!="function"||typeof it.namespaceURI!="string"||typeof it.insertBefore!="function"||typeof it.hasChildNodes!="function")},sr=function(it){return typeof g=="function"&&it instanceof g};function kn(Yt,it,$t){arrayForEach(Yt,zt=>{zt.call(e,it,$t,$n)})}const or=function(it){let $t=null;if(kn(ge.beforeSanitizeElements,it,null),zn(it))return Cn(it),!0;const zt=hn(it.nodeName);if(kn(ge.uponSanitizeElement,it,{tagName:zt,allowedTags:ze}),tt&&it.hasChildNodes()&&!sr(it.firstElementChild)&®ExpTest(/<[/\w!]/g,it.innerHTML)&®ExpTest(/<[/\w!]/g,it.textContent)||it.nodeType===NODE_TYPE.progressingInstruction||tt&&it.nodeType===NODE_TYPE.comment&®ExpTest(/<[/\w]/g,it.data))return Cn(it),!0;if(!(at.tagCheck instanceof Function&&at.tagCheck(zt))&&(!ze[zt]||Ze[zt])){if(!Ze[zt]&&er(zt)&&(Je.tagNameCheck instanceof RegExp&®ExpTest(Je.tagNameCheck,zt)||Je.tagNameCheck instanceof Function&&Je.tagNameCheck(zt)))return!1;if(pt&&!Ut[zt]){const fn=z(it)||it.parentNode,xn=F(it)||it.childNodes;if(xn&&fn){const mn=xn.length;for(let _n=mn-1;_n>=0;--_n){const An=M(xn[_n],!0);An.__removalCount=(it.__removalCount||0)+1,fn.insertBefore(An,j(it))}}}return Cn(it),!0}return it instanceof b&&!ar(it)||(zt==="noscript"||zt==="noembed"||zt==="noframes")&®ExpTest(/<\/no(script|embed|frames)/i,it.innerHTML)?(Cn(it),!0):(Ct&&it.nodeType===NODE_TYPE.text&&($t=it.textContent,arrayForEach([se,je,Ae],fn=>{$t=stringReplace($t,fn," ")}),it.textContent!==$t&&(arrayPush(e.removed,{element:it.cloneNode()}),it.textContent=$t)),kn(ge.afterSanitizeElements,it,null),!1)},lr=function(it,$t,zt){if(Ye&&($t==="id"||$t==="name")&&(zt in n||zt in On))return!1;if(!(st&&!Ke[$t]&®ExpTest(Ne,$t))){if(!(nt&®ExpTest(Ve,$t))){if(!(at.attributeCheck instanceof Function&&at.attributeCheck($t,it))){if(!Qe[$t]||Ke[$t]){if(!(er(it)&&(Je.tagNameCheck instanceof RegExp&®ExpTest(Je.tagNameCheck,it)||Je.tagNameCheck instanceof Function&&Je.tagNameCheck(it))&&(Je.attributeNameCheck instanceof RegExp&®ExpTest(Je.attributeNameCheck,$t)||Je.attributeNameCheck instanceof Function&&Je.attributeNameCheck($t,it))||$t==="is"&&Je.allowCustomizedBuiltInElements&&(Je.tagNameCheck instanceof RegExp&®ExpTest(Je.tagNameCheck,zt)||Je.tagNameCheck instanceof Function&&Je.tagNameCheck(zt))))return!1}else if(!qt[$t]){if(!regExpTest(Ue,stringReplace(zt,Oe,""))){if(!(($t==="src"||$t==="xlink:href"||$t==="href")&&it!=="script"&&stringIndexOf(zt,"data:")===0&&sn[it])){if(!(lt&&!regExpTest(Fe,stringReplace(zt,Oe,"")))){if(zt)return!1}}}}}}}return!0},er=function(it){return it!=="annotation-xml"&&stringMatch(it,Be)},tr=function(it){kn(ge.beforeSanitizeAttributes,it,null);const{attributes:$t}=it;if(!$t||zn(it))return;const zt={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Qe,forceKeepAttr:void 0};let fn=$t.length;for(;fn--;){const xn=$t[fn],{name:mn,namespaceURI:_n,value:An}=xn,Fn=hn(mn),Ht=An;let gn=mn==="value"?Ht:stringTrim(Ht);if(zt.attrName=Fn,zt.attrValue=gn,zt.keepAttr=!0,zt.forceKeepAttr=void 0,kn(ge.uponSanitizeAttribute,it,zt),gn=zt.attrValue,rt&&(Fn==="id"||Fn==="name")&&(Dn(mn,it),gn=ut+gn),tt&®ExpTest(/((--!?|])>)|<\/(style|title|textarea)/i,gn)){Dn(mn,it);continue}if(Fn==="attributename"&&stringMatch(gn,"href")){Dn(mn,it);continue}if(zt.forceKeepAttr)continue;if(!zt.keepAttr){Dn(mn,it);continue}if(!Ge&®ExpTest(/\/>/i,gn)){Dn(mn,it);continue}Ct&&arrayForEach([se,je,Ae],ur=>{gn=stringReplace(gn,ur," ")});const wn=hn(it.nodeName);if(!lr(wn,Fn,gn)){Dn(mn,it);continue}if(Q&&typeof E=="object"&&typeof E.getAttributeType=="function"&&!_n)switch(E.getAttributeType(wn,Fn)){case"TrustedHTML":{gn=Q.createHTML(gn);break}case"TrustedScriptURL":{gn=Q.createScriptURL(gn);break}}if(gn!==Ht)try{_n?it.setAttributeNS(_n,mn,gn):it.setAttribute(mn,gn),zn(it)?Cn(it):arrayPop(e.removed)}catch{Dn(mn,it)}}kn(ge.afterSanitizeAttributes,it,null)},cr=function Yt(it){let $t=null;const zt=Zn(it);for(kn(ge.beforeSanitizeShadowDOM,it,null);$t=zt.nextNode();)kn(ge.uponSanitizeShadowNode,$t,null),or($t),tr($t),$t.content instanceof d&&Yt($t.content);kn(ge.afterSanitizeShadowDOM,it,null)};return e.sanitize=function(Yt){let it=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},$t=null,zt=null,fn=null,xn=null;if(jn=!Yt,jn&&(Yt="<!-->"),typeof Yt!="string"&&!sr(Yt))if(typeof Yt.toString=="function"){if(Yt=Yt.toString(),typeof Yt!="string")throw typeErrorCreate("dirty is not a string, aborting")}else throw typeErrorCreate("toString is not a function");if(!e.isSupported)return Yt;if(ct||Xn(it),e.removed=[],typeof Yt=="string"&&(ft=!1),ft){if(Yt.nodeName){const An=hn(Yt.nodeName);if(!ze[An]||Ze[An])throw typeErrorCreate("root node is forbidden and cannot be sanitized in-place")}}else if(Yt instanceof g)$t=Qn("<!---->"),zt=$t.ownerDocument.importNode(Yt,!0),zt.nodeType===NODE_TYPE.element&&zt.nodeName==="BODY"||zt.nodeName==="HTML"?$t=zt:$t.appendChild(zt);else{if(!Mt&&!Ct&&!yt&&Yt.indexOf("<")===-1)return Q&&We?Q.createHTML(Yt):Yt;if($t=Qn(Yt),!$t)return Mt?null:We?O:""}$t&&Rt&&Cn($t.firstChild);const mn=Zn(ft?Yt:$t);for(;fn=mn.nextNode();)or(fn),tr(fn),fn.content instanceof d&&cr(fn.content);if(ft)return Yt;if(Mt){if(It)for(xn=ne.call($t.ownerDocument);$t.firstChild;)xn.appendChild($t.firstChild);else xn=$t;return(Qe.shadowroot||Qe.shadowrootmode)&&(xn=$e.call(o,xn,!0)),xn}let _n=yt?$t.outerHTML:$t.innerHTML;return yt&&ze["!doctype"]&&$t.ownerDocument&&$t.ownerDocument.doctype&&$t.ownerDocument.doctype.name&®ExpTest(DOCTYPE_NAME,$t.ownerDocument.doctype.name)&&(_n="<!DOCTYPE "+$t.ownerDocument.doctype.name+`>
|
|
1138
|
-
`+_n),Ct&&arrayForEach([se,je,Ae],An=>{_n=stringReplace(_n,An," ")}),Q&&We?Q.createHTML(_n):_n},e.setConfig=function(){let Yt=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Xn(Yt),ct=!0},e.clearConfig=function(){$n=null,ct=!1},e.isValidAttribute=function(Yt,it,$t){$n||Xn({});const zt=hn(Yt),fn=hn(it);return lr(zt,fn,$t)},e.addHook=function(Yt,it){typeof it=="function"&&arrayPush(ge[Yt],it)},e.removeHook=function(Yt,it){if(it!==void 0){const $t=arrayLastIndexOf(ge[Yt],it);return $t===-1?void 0:arraySplice(ge[Yt],$t,1)[0]}return arrayPop(ge[Yt])},e.removeHooks=function(Yt){ge[Yt]=[]},e.removeAllHooks=function(){ge=_createHooksMap()},e}var purify=createDOMPurify();function markdownToSafeHTML(t){const e=marked(t,{async:!1});return purify.sanitize(e,{ALLOWED_TAGS:["h1","h2","h3","h4","h5","h6","b","strong","i","em","u","s","sub","sup","mark","blockquote","q","ul","ol","li","dl","dt","dd","p","div","span","br","hr","table","thead","tbody","tfoot","tr","th","td"]})}function SkeletonMessage({botStatus:t}){return jsxRuntime.jsxs("div",{className:"flex items-start gap-2",children:[jsxRuntime.jsx("div",{className:"h-8 w-8 mt-1 rounded-full bg-gray-300 animate-pulse flex-shrink-0"}),jsxRuntime.jsxs("div",{className:"flex flex-col max-w-[70%]",children:[jsxRuntime.jsx("p",{className:"mb-1",children:"Assistant"}),jsxRuntime.jsxs("div",{className:"flex items-end gap-2",children:[jsxRuntime.jsx("div",{className:"rounded-md p-3 break-words bg-white border rounded-tl-none",children:jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx("div",{className:"h-2 w-2 rounded-full bg-primary animate-pulse"}),jsxRuntime.jsx("div",{className:"h-2 w-2 rounded-full bg-primary animate-pulse delay-150"}),jsxRuntime.jsx("div",{className:"h-2 w-2 rounded-full bg-primary animate-pulse delay-300"}),jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground ml-1",children:t})]})}),jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:new Date().toLocaleTimeString([],{hour:"numeric",minute:"2-digit",hour12:!0})})]})]})]})}function ChatMessages({messages:t,appID:e,botStatus:n,isAssistantChat:o}){const l=(()=>{const d=new Set;let f=null;for(const g of t){const b=(g.senderName??"").trim();b&&(f===b?d.add(g.id):f=b)}return d})();return jsxRuntime.jsxs("div",{children:[t.map(d=>{var g;const f=d.fromPartnerID===e;return jsxRuntime.jsx("div",{className:cn("flex items-start gap-2 mt-2 mb-2",f&&"flex-row-reverse"),children:jsxRuntime.jsxs("div",{className:"flex flex-col max-w-[70%]",children:[!l.has(d.id)&&!!((g=d.senderName)!=null&&g.trim())&&jsxRuntime.jsx("p",{className:cn("mb-1 flex",f&&"flex-row-reverse"),children:d.senderName}),jsxRuntime.jsxs("div",{className:cn("flex items-baseline gap-2",f&&"flex-row-reverse"),children:[jsxRuntime.jsx("div",{className:cn("rounded-md p-3 break-words [&_li]:ml-6 [&_li]:list-disc [&_h1]:text-lg [&_h1]:font-bold [&_h1]:mt-4 [&_h2]:font-bold [&_h2]:mt-4 [&_h3]:mt-4 ",f?"bg-primary text-white rounded-tr-none":"bg-white border rounded-tl-none"),children:parser(markdownToSafeHTML(d.content))}),jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:(()=>{const b=new Date(d.timestamp);return isToday(b)?b.toLocaleTimeString([],{hour:"numeric",minute:"2-digit",hour12:!0}):isYesterday(b)?`Yesterday, ${b.toLocaleTimeString([],{hour:"numeric",minute:"2-digit",hour12:!0})}`:`${b.toLocaleDateString([],{month:"short",day:"numeric"})} ${b.toLocaleTimeString([],{hour:"numeric",minute:"2-digit",hour12:!0})}`})()})]})]})},d.id)}),n!==""&&jsxRuntime.jsx(SkeletonMessage,{botStatus:n}),t.length===0&&!o&&jsxRuntime.jsx("div",{className:"text-center text-muted-foreground py-8",children:"No messages yet"}),t.length===0&&n===""&&o&&jsxRuntime.jsxs("div",{className:"text-center py-8",children:[jsxRuntime.jsx("p",{children:"The Randmar Assistant is ready to help you. Ask anything about products, orders, carts, shipments and tracking numbers."}),jsxRuntime.jsx("p",{children:jsxRuntime.jsx("strong",{children:'Try it now, type "my open orders"!'})})]})]})}const Textarea=React__namespace.forwardRef(({className:t,...e},n)=>jsxRuntime.jsx("textarea",{className:cn("flex min-h-[60px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-base shadow-xs placeholder:text-muted-foreground focus-visible:outline-hidden focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",t),ref:n,...e}));Textarea.displayName="Textarea";function ChatMainArea({activeChat:t,activeChatObj:e,appID:n,messagesEndRef:o,inputRef:l,content:d,setContent:f,handleSendMessage:g,isPostBizDevConvoLoading:b,acceptChat:_}){return jsxRuntime.jsx("div",{className:"flex-5 flex flex-col",children:t?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex items-center p-4 border-b",children:[jsxRuntime.jsx(Avatar,{className:"h-8 w-8 flex-shrink-0 rounded-none",children:jsxRuntime.jsx(PartnerLogo,{id:t[0]===n?t[1]:t[0],width:72,height:72})}),jsxRuntime.jsx("div",{className:"ml-3 font-medium",children:e==null?void 0:e.name})]}),e!=null&&e.pending&&e.partner1==n?jsxRuntime.jsx("p",{className:"mt-8 p-2 mx-auto",children:"This conversation is awaiting approval by the other party — please check back later."}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(ScrollArea,{className:"flex-1 pl-2 pr-2 bg-slate-50",children:[jsxRuntime.jsx(ChatMessages,{messages:(e==null?void 0:e.messages)??[],appID:n,isAssistantChat:!1,botStatus:""}),jsxRuntime.jsx("div",{ref:o})]}),jsxRuntime.jsxs("div",{className:"p-4 border-t border-r flex",children:[(e==null?void 0:e.pending)&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(Button$1,{disabled:b,onClick:()=>_(),children:[jsxRuntime.jsx(Handshake,{}),"Accept Conversation Request"]}),jsxRuntime.jsxs(Button$1,{disabled:!0,className:"ml-2",children:[jsxRuntime.jsx(ThumbsDown,{}),"Block Partner"]})]}),jsxRuntime.jsx(Textarea,{ref:l,placeholder:"Type a message...",value:d,onChange:S=>f(S.target.value),onKeyDown:S=>{S.key!=="Enter"||S.shiftKey||(S.preventDefault(),g())},className:e!=null&&e.pending?"collapse":"flex-1 resize-none field-sizing-content max-h-[30em]",disabled:e==null?void 0:e.pending}),jsxRuntime.jsx("div",{className:"flex items-center",children:jsxRuntime.jsx(Button$1,{size:"icon",variant:"default",className:e!=null&&e.pending?"collapse":"ml-2 h-8 w-8",disabled:e==null?void 0:e.pending,onClick:g,children:jsxRuntime.jsx(Send,{className:"h-6 w-6"})})})]})]})]}):jsxRuntime.jsxs("div",{className:"flex flex-col m-auto text-xl",children:[jsxRuntime.jsx(MousePointerClick,{className:"w-full h-32"}),jsxRuntime.jsx("p",{children:"Select a chat from the left menu to start messaging"})]})})}function ChatRightSidebar({activeChatObj:t,appID:e,sendChatToAssistant:n,isAnalyzingPartnership:o,analyzePartnership:l}){const d=t?[t.partner1,t.partner2]:void 0;return jsxRuntime.jsx("div",{className:"flex border-l flex-1",children:jsxRuntime.jsxs("div",{className:"flex flex-col p-4 border-b gap-2",children:[jsxRuntime.jsx("p",{className:"h-9 font-medium text-base/9",children:"Actions"}),jsxRuntime.jsx(reactRouterDom.Link,{className:"w-full",inert:d===void 0,to:`/${e}/Partner/${(d==null?void 0:d[0])===e?d[1]:d==null?void 0:d[0]}`,children:jsxRuntime.jsx(Button$1,{className:"w-full",disabled:d===void 0,children:"View Partner"})}),jsxRuntime.jsx(Button$1,{disabled:((t==null?void 0:t.messages)??[]).length<1,onClick:()=>n(t.messages),children:"Export to Randmar Assistant"}),jsxRuntime.jsx(Button$1,{disabled:d===void 0||o,onClick:l,children:o?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Analyzing..."]}):"Analyze Partnership"}),jsxRuntime.jsx("p",{className:"font-medium pt-2 border-t",children:"People"}),jsxRuntime.jsx("p",{className:"font-light",children:"Members of this conversation will show up here."}),jsxRuntime.jsx(LinkSection,{appID:e,activeChatObj:t})]})})}const LinkSection=({appID:t,activeChatObj:e})=>{const[n,o]=React.useState(!1),{data:l,isLoading:d}=useGetV4PartnerByRouteApplicationIdBusinessDevelopmentConversationAndConversationIdLinksQuery({routeApplicationId:t,conversationId:e==null?void 0:e.conversationID},{skip:!(e!=null&&e.conversationID)});console.log(l);const[f]=usePostV4PartnerByRouteApplicationIdBusinessDevelopmentConversationAndConversationIdLinkMutation(),[g]=useDeleteV4PartnerByRouteApplicationIdBusinessDevelopmentConversationLinkAndLinkIdMutation();return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("p",{className:"font-medium pt-2 border-t",children:"Links"}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-1",children:[d?jsxRuntime.jsx("p",{children:"Loading links..."}):(l==null?void 0:l.length)===0?jsxRuntime.jsx("p",{children:"No links attached."}):null,l==null?void 0:l.map(b=>jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("a",{href:b.URL,target:"_blank",rel:"noopener noreferrer",className:"text-randmar-red underline break-all",children:b.Title}),jsxRuntime.jsx(Button$1,{variant:"secondary",size:"icon",onClick:()=>g({routeApplicationId:t,linkId:b.LinkId}),children:jsxRuntime.jsx(Trash2,{className:"h-4 w-4"})})]},b.LinkId))]}),jsxRuntime.jsxs(Dialog,{open:n,onOpenChange:o,children:[jsxRuntime.jsx(DialogTrigger$1,{asChild:!0,children:jsxRuntime.jsx(Button$1,{className:"p-0",disabled:e===void 0,children:"Add Link"})}),jsxRuntime.jsxs(DialogContent,{children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsx(DialogTitle$1,{children:"Add Link"}),jsxRuntime.jsx(DialogDescription$1,{children:"Please enter the details for the new link."})]}),jsxRuntime.jsxs("form",{className:"space-y-4",onSubmit:b=>{b.preventDefault();const _=document.getElementById("link-title").value,S=document.getElementById("link-url").value;f({routeApplicationId:t,conversationId:e==null?void 0:e.conversationID,createLinkRequest:{Title:_,Url:S}}),o(!1)},children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Label$2,{htmlFor:"link-title",children:"Title"}),jsxRuntime.jsx(Input,{id:"link-title",required:!0,minLength:2})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Label$2,{htmlFor:"link-url",children:"URL"}),jsxRuntime.jsx(Input,{id:"link-url",type:"url",required:!0,minLength:2,placeholder:"https://"})]}),jsxRuntime.jsx(Button$1,{type:"submit",children:"Add Link"})]})]})]})]})},UserSetupForm=t=>{const[e]=usePostV4UserByFieldNameMutation(),[n,o]=React.useState(""),[l,d]=React.useState(""),[f,g]=React.useState(!1),[b]=usePostV4PartnerByRouteApplicationIdBusinessDevelopmentConversationPartnerAndPartnerIdMutation();return jsxRuntime.jsxs("div",{className:"mx-auto mt-2",children:[jsxRuntime.jsx("p",{className:"mb-4",children:"Before you can start chatting, please set up your profile."}),jsxRuntime.jsxs("form",{className:"space-y-2",onSubmit:_=>{f||(g(!0),_.preventDefault(),e({fieldName:"Name",newValue:n}).then(()=>{b({routeApplicationId:t.appID,partnerId:"2"})}),e({fieldName:"Role",newValue:l}))},children:[jsxRuntime.jsx(Label$2,{htmlFor:"name",children:"Name"}),jsxRuntime.jsx(Input,{id:"name",required:!0,minLength:2,value:n,onChange:_=>o(_.target.value)}),jsxRuntime.jsx(Label$2,{htmlFor:"role",children:"Role"}),jsxRuntime.jsx(Input,{id:"role",required:!0,minLength:2,value:l,onChange:_=>d(_.target.value)}),jsxRuntime.jsx(Button$1,{type:"submit",disabled:f,children:f?"Saving...":"Save"})]})]})},sortChats=(t,e)=>t.unread>0&&e.unread===0?-1:e.unread>0&&t.unread===0?1:t.name.localeCompare(e.name);function ChatLayout({appID:t,inputRef:e,className:n}){const{setHasUnreads:o}=useChat(),{data:l,refetch:d}=useGetV4PartnerByRouteApplicationIdBusinessDevelopmentConversationsQuery({routeApplicationId:t}),[f,g]=React.useState(!1),[b,{isLoading:_}]=usePostV4PartnerByRouteApplicationIdBusinessDevelopmentConversationPartnerAndPartnerIdMutation(),S=React.useRef(null),[R]=useLazyGetV4PartnerByApplicationIdAccountQuery(),{sendPrompt:C}=useGemini({outputFormat:"text",useProModel:!0}),[E,A]=React.useState(!1),[M]=usePostV4PartnerByRouteApplicationIdBusinessDevelopmentConversationPartnerAndPartnerIdMutation(),[I]=usePostV4PartnerByRouteApplicationIdBusinessDevelopmentConversationAndConversationIdReadMutation(),[j]=useLazyGetV4PartnerByRouteApplicationIdBusinessDevelopmentConversationAndConversationIdMessagesQuery(),[F]=useLazyGetV4PartnerByRouteApplicationIdPartnerAndPartnerIdQuery(),[z,Q]=React.useState(!1);React.useEffect(()=>{l&&(se(ct=>{const Rt=l.map(Mt=>{var We;const It=ct.find(Ye=>Ye.conversationID===Mt.ConversationId);return{partner1:Mt.Participant1,partner2:Mt.Participant2,name:((We=Mt.Participant)==null?void 0:We.PublicName)??"missing public name",unread:(It==null?void 0:It.unread)??0,pending:Mt.Status!=="Approved",messages:(It==null?void 0:It.messages)??[],conversationID:Mt.ConversationId,lastMessageTime:Mt.LastMessageTime??null}});return Rt.sort(sortChats),Rt}),g(!0),setTimeout(()=>{var ct;return(ct=Be.current)==null?void 0:ct.focus()},50))},[l,t]);const[O,V]=React.useState(void 0),[te,ne]=React.useState(""),[ae,$e]=React.useState(null),[ge,se]=React.useState([]),[je,Ae]=React.useState(null),Ne=React.useRef(null),Ve=React.useRef(null),[Fe,Oe]=React.useState([]),Be=e||Ve,Ue=React.useRef(null),{toast:ze}=useToast(),He=()=>ge.find(ct=>ct.partner1===(O==null?void 0:O[0])&&ct.partner2===(O==null?void 0:O[1]));function Qe(){const ct=He();ct&&I({routeApplicationId:t,conversationId:ct.conversationID})}const et=ct=>Oe(Rt=>[...Rt,ct]);React.useEffect(()=>{if(Fe.length==0)return;console.log(Fe.length,"unprocessedMessages detected");const ct=(Mt,It)=>It.partner1===Mt.toPartnerID&&It.partner2===Mt.fromPartnerID||It.partner2===Mt.toPartnerID&&It.partner1===Mt.fromPartnerID;let Rt=!1;Fe.forEach(Mt=>{if(!ge.some(It=>ct(Mt,It))){console.log("message received for unknown convo ID - need to refetch!"),Rt=!0;return}se(It=>It.map(We=>{if(!ct(Mt,We)||We.messages.some(ut=>ut.id===Mt.id))return We;let Ye=1;const rt=document.activeElement&&document.activeElement===Be.current;return(O==null?void 0:O[0])==We.partner1&&O[1]==We.partner2&&rt&&(rt&&(Ye=0,Qe()),setTimeout(()=>{var ut;return(ut=Ne.current)==null?void 0:ut.scrollIntoView({behavior:"smooth"})},50)),{...We,pending:!1,unread:We.unread+Ye,messages:[...We.messages,Mt]}}).sort(sortChats))}),console.log("need refetch:",Rt),Rt&&d(),Oe([])},[Fe,Oe,se,V,O]),React.useEffect(()=>{const ct=new HubConnectionBuilder().withUrl("https://api.randmar.io/hub",{accessTokenFactory:()=>localStorage.getItem("access_token"),headers:{"X-Impersonated-Id":t}}).configureLogging(LogLevel.Information).withAutomaticReconnect().withHubProtocol(new JsonHubProtocol).build();return ct.on("ReceiveMessage",et),ct.start().catch(Rt=>console.error("Error connecting to SignalR hub:",Rt)),Ae(ct),()=>{ct&&ct.stop()}},[t]),React.useEffect(()=>{var Rt;!O||!He()||((Rt=Be.current)==null||Rt.focus(),setTimeout(()=>{var Mt;return(Mt=Ne.current)==null?void 0:Mt.scrollIntoView({behavior:"smooth"})},50))},[O]),React.useEffect(()=>{if(!O)return;const ct=He();ct&&ct.conversationID!==-1&&(async()=>{var Rt;try{const It=((Rt=(await j({routeApplicationId:t,conversationId:ct.conversationID})).data)==null?void 0:Rt.map(We=>({id:"history"+We.MessageId,fromPartnerID:We.SenderId,toPartnerID:We.SenderId==ct.partner1?ct.partner2:ct.partner1,senderName:We.SenderName??"missing name",timestamp:new Date(We.SentDate+"Z").getTime(),content:We.Content??"no content"})))??[];se(We=>We.map(Ye=>Ye.conversationID===ct.conversationID?{...Ye,messages:It}:Ye).sort(sortChats))}catch(Mt){console.error("Error fetching conversation messages:",Mt)}})()},[O,j,t]),React.useEffect(()=>{if(!O)return;const ct=He();if(!ct)return;const Rt=document.activeElement&&document.activeElement===Be.current;ct.unread>0&&Rt&&(Qe(),se(Mt=>Mt.map(It=>It.partner1===O[0]&&It.partner2===O[1]?{...It,unread:0}:It)))},[O,ge]);const{sendMessage:Je}=useChat(),Ze=React.useCallback(ct=>{Je(`We have been talking with another Randmar partner and would like you to have the conversation as context for follow-up questions. Please acknowledge your reception of this chat history (one line summary of recent messages will do) and let me know that you're ready to answer questions: ${JSON.stringify(ct,null,2)}`)},[Je]),Ke=React.useCallback(async()=>{if(O)try{Q(!0);const ct=await R({applicationId:t}),Rt=O[0]===t?O[1]:O[0],Mt=await F({routeApplicationId:t,partnerId:Rt,withSpecification:!0}),It=buildPartnershipAssistantPrompt(ct.data,Mt.data);It?Je(It):ze({title:"Missing data",description:"We couldn't load enough data to analyze this partnership yet. Please try again shortly.",variant:"destructive"})}catch(ct){console.error("Error preparing partnership analysis:",ct),ze({title:"Error",description:"Could not analyze the partnership. Please try again later.",variant:"destructive"})}finally{Q(!1)}},[O,R,F,Je,ze,t]);React.useEffect(()=>{o(ge.some(ct=>ct.unread>0))},[ge,o]);const at=(ct,Rt)=>{Rt=Rt.replace(/\n/g,`
|
|
1138
|
+
`+_n),Ct&&arrayForEach([se,je,Ae],An=>{_n=stringReplace(_n,An," ")}),Q&&We?Q.createHTML(_n):_n},e.setConfig=function(){let Yt=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Xn(Yt),ct=!0},e.clearConfig=function(){$n=null,ct=!1},e.isValidAttribute=function(Yt,it,$t){$n||Xn({});const zt=hn(Yt),fn=hn(it);return lr(zt,fn,$t)},e.addHook=function(Yt,it){typeof it=="function"&&arrayPush(ge[Yt],it)},e.removeHook=function(Yt,it){if(it!==void 0){const $t=arrayLastIndexOf(ge[Yt],it);return $t===-1?void 0:arraySplice(ge[Yt],$t,1)[0]}return arrayPop(ge[Yt])},e.removeHooks=function(Yt){ge[Yt]=[]},e.removeAllHooks=function(){ge=_createHooksMap()},e}var purify=createDOMPurify();function markdownToSafeHTML(t){const e=marked(t,{async:!1});return purify.sanitize(e,{ALLOWED_TAGS:["h1","h2","h3","h4","h5","h6","b","strong","i","em","u","s","sub","sup","mark","blockquote","q","ul","ol","li","dl","dt","dd","p","div","span","br","hr","table","thead","tbody","tfoot","tr","th","td"]})}function SkeletonMessage({botStatus:t}){return jsxRuntime.jsxs("div",{className:"flex items-start gap-2",children:[jsxRuntime.jsx("div",{className:"h-8 w-8 mt-1 rounded-full bg-gray-300 animate-pulse flex-shrink-0"}),jsxRuntime.jsxs("div",{className:"flex flex-col max-w-[70%]",children:[jsxRuntime.jsx("p",{className:"mb-1",children:"Assistant"}),jsxRuntime.jsxs("div",{className:"flex items-end gap-2",children:[jsxRuntime.jsx("div",{className:"rounded-md p-3 break-words bg-white border rounded-tl-none",children:jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx("div",{className:"h-2 w-2 rounded-full bg-primary animate-pulse"}),jsxRuntime.jsx("div",{className:"h-2 w-2 rounded-full bg-primary animate-pulse delay-150"}),jsxRuntime.jsx("div",{className:"h-2 w-2 rounded-full bg-primary animate-pulse delay-300"}),jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground ml-1",children:t})]})}),jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:new Date().toLocaleTimeString([],{hour:"numeric",minute:"2-digit",hour12:!0})})]})]})]})}function ChatMessages({messages:t,appID:e,botStatus:n,isAssistantChat:o}){const l=(()=>{const d=new Set;let f=null;for(const g of t){const b=(g.senderName??"").trim();b&&(f===b?d.add(g.id):f=b)}return d})();return jsxRuntime.jsxs("div",{children:[t.map(d=>{var g;const f=d.fromPartnerID===e;return jsxRuntime.jsx("div",{className:cn("flex items-start gap-2 mt-2 mb-2",f&&"flex-row-reverse"),children:jsxRuntime.jsxs("div",{className:"flex flex-col max-w-[70%]",children:[!l.has(d.id)&&!!((g=d.senderName)!=null&&g.trim())&&jsxRuntime.jsx("p",{className:cn("mb-1 flex",f&&"flex-row-reverse"),children:d.senderName}),jsxRuntime.jsxs("div",{className:cn("flex items-baseline gap-2",f&&"flex-row-reverse"),children:[jsxRuntime.jsx("div",{className:cn("rounded-md p-3 break-words [&_li]:ml-6 [&_li]:list-disc [&_h1]:text-lg [&_h1]:font-bold [&_h1]:mt-4 [&_h2]:font-bold [&_h2]:mt-4 [&_h3]:mt-4 ",f?"bg-primary text-white rounded-tr-none":"bg-white border rounded-tl-none"),children:parser(markdownToSafeHTML(d.content))}),jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:(()=>{const b=new Date(d.timestamp);return isToday(b)?b.toLocaleTimeString([],{hour:"numeric",minute:"2-digit",hour12:!0}):isYesterday(b)?`Yesterday, ${b.toLocaleTimeString([],{hour:"numeric",minute:"2-digit",hour12:!0})}`:`${b.toLocaleDateString([],{month:"short",day:"numeric"})} ${b.toLocaleTimeString([],{hour:"numeric",minute:"2-digit",hour12:!0})}`})()})]})]})},d.id)}),n!==""&&jsxRuntime.jsx(SkeletonMessage,{botStatus:n}),t.length===0&&!o&&jsxRuntime.jsxs("div",{className:"mt-1 text-xl",children:[jsxRuntime.jsx(Send,{className:"w-full h-32"}),jsxRuntime.jsx("p",{className:"text-center",children:"No messages yet... Say hello!"})]}),t.length===0&&n===""&&o&&jsxRuntime.jsxs("div",{className:"text-center py-8",children:[jsxRuntime.jsx("p",{children:"The Randmar Assistant is ready to help you. Ask anything about products, orders, carts, shipments and tracking numbers."}),jsxRuntime.jsx("p",{children:jsxRuntime.jsx("strong",{children:'Try it now, type "my open orders"!'})})]})]})}const Textarea=React__namespace.forwardRef(({className:t,...e},n)=>jsxRuntime.jsx("textarea",{className:cn("flex min-h-[60px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-base shadow-xs placeholder:text-muted-foreground focus-visible:outline-hidden focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",t),ref:n,...e}));Textarea.displayName="Textarea";function ChatMainArea({activeChat:t,activeChatObj:e,appID:n,messagesEndRef:o,inputRef:l,content:d,setContent:f,handleSendMessage:g,isPostBizDevConvoLoading:b,acceptChat:_}){return jsxRuntime.jsx("div",{className:"flex-5 flex flex-col",children:t?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex items-center p-4 border-b",children:[jsxRuntime.jsx(Avatar,{className:"h-8 w-8 flex-shrink-0 rounded-none",children:jsxRuntime.jsx(PartnerLogo,{id:t[0]===n?t[1]:t[0],width:72,height:72})}),jsxRuntime.jsx("div",{className:"ml-3 font-medium",children:e==null?void 0:e.name})]}),e!=null&&e.pending&&e.partner1==n?jsxRuntime.jsx("p",{className:"mt-8 p-2 mx-auto",children:"This conversation is awaiting approval by the other party — please check back later."}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(ScrollArea,{className:"flex-1 pl-2 pr-2 bg-slate-50",children:[jsxRuntime.jsx("div",{className:(e==null?void 0:e.messages)===null?" opacity-0":"",children:jsxRuntime.jsx(ChatMessages,{messages:(e==null?void 0:e.messages)??[],appID:n,isAssistantChat:!1,botStatus:""})}),jsxRuntime.jsx("div",{ref:o})]}),jsxRuntime.jsxs("div",{className:"p-4 border-t border-r flex",children:[(e==null?void 0:e.pending)&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(Button$1,{disabled:b,onClick:()=>_(),children:[jsxRuntime.jsx(Handshake,{}),"Accept Conversation Request"]}),jsxRuntime.jsxs(Button$1,{disabled:!0,className:"ml-2",children:[jsxRuntime.jsx(ThumbsDown,{}),"Block Partner"]})]}),jsxRuntime.jsx(Textarea,{ref:l,placeholder:"Type a message...",value:d,onChange:S=>f(S.target.value),onKeyDown:S=>{S.key!=="Enter"||S.shiftKey||(S.preventDefault(),g())},className:e!=null&&e.pending?"collapse":"flex-1 resize-none field-sizing-content max-h-[30em]",disabled:e==null?void 0:e.pending}),jsxRuntime.jsx("div",{className:"flex items-center",children:jsxRuntime.jsx(Button$1,{size:"icon",variant:"default",className:e!=null&&e.pending?"collapse":"ml-2 h-8 w-8",disabled:e==null?void 0:e.pending,onClick:g,children:jsxRuntime.jsx(Send,{className:"h-6 w-6"})})})]})]})]}):jsxRuntime.jsxs("div",{className:"flex flex-col m-auto text-xl",children:[jsxRuntime.jsx(MousePointerClick,{className:"w-full h-32"}),jsxRuntime.jsx("p",{children:"Select a chat from the left menu to start messaging"})]})})}function ChatRightSidebar({activeChatObj:t,appID:e,sendChatToAssistant:n,isAnalyzingPartnership:o,analyzePartnership:l}){const d=t?[t.partner1,t.partner2]:void 0;return jsxRuntime.jsx("div",{className:"flex border-l flex-1",children:jsxRuntime.jsxs("div",{className:"flex flex-col p-4 border-b gap-2",children:[jsxRuntime.jsx("p",{className:"h-9 font-medium text-base/9",children:"Actions"}),jsxRuntime.jsx(reactRouterDom.Link,{className:"w-full",inert:d===void 0,to:`/${e}/Partner/${(d==null?void 0:d[0])===e?d[1]:d==null?void 0:d[0]}`,children:jsxRuntime.jsx(Button$1,{className:"w-full",disabled:d===void 0,children:"View Partner"})}),jsxRuntime.jsx(Button$1,{disabled:((t==null?void 0:t.messages)??[]).length<1,onClick:()=>n(t.messages),children:"Export to Randmar Assistant"}),jsxRuntime.jsx(Button$1,{disabled:d===void 0||o,onClick:l,children:o?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Analyzing..."]}):"Analyze Partnership"}),jsxRuntime.jsx("p",{className:"font-medium pt-2 border-t",children:"People"}),jsxRuntime.jsx("p",{className:"font-light",children:"Members of this conversation will show up here."}),jsxRuntime.jsx(LinkSection,{appID:e,activeChatObj:t})]})})}const LinkSection=({appID:t,activeChatObj:e})=>{const[n,o]=React.useState(!1),{data:l,isLoading:d}=useGetV4PartnerByRouteApplicationIdBusinessDevelopmentConversationAndConversationIdLinksQuery({routeApplicationId:t,conversationId:e==null?void 0:e.conversationID},{skip:!(e!=null&&e.conversationID)});console.log(l);const[f]=usePostV4PartnerByRouteApplicationIdBusinessDevelopmentConversationAndConversationIdLinkMutation(),[g]=useDeleteV4PartnerByRouteApplicationIdBusinessDevelopmentConversationLinkAndLinkIdMutation();return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("p",{className:"font-medium pt-2 border-t",children:"Links"}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-1",children:[d?jsxRuntime.jsx("p",{children:"Loading links..."}):(l==null?void 0:l.length)===0?jsxRuntime.jsx("p",{children:"No links attached."}):null,l==null?void 0:l.map(b=>jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("a",{href:b.URL,target:"_blank",rel:"noopener noreferrer",className:"text-randmar-red underline break-all",children:b.Title}),jsxRuntime.jsx(Button$1,{variant:"secondary",size:"icon",onClick:()=>g({routeApplicationId:t,linkId:b.LinkId}),children:jsxRuntime.jsx(Trash2,{className:"h-4 w-4"})})]},b.LinkId))]}),jsxRuntime.jsxs(Dialog,{open:n,onOpenChange:o,children:[jsxRuntime.jsx(DialogTrigger$1,{asChild:!0,children:jsxRuntime.jsx(Button$1,{className:"p-0",disabled:e===void 0,children:"Add Link"})}),jsxRuntime.jsxs(DialogContent,{children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsx(DialogTitle$1,{children:"Add Link"}),jsxRuntime.jsx(DialogDescription$1,{children:"Please enter the details for the new link."})]}),jsxRuntime.jsxs("form",{className:"space-y-4",onSubmit:b=>{b.preventDefault();const _=document.getElementById("link-title").value,S=document.getElementById("link-url").value;f({routeApplicationId:t,conversationId:e==null?void 0:e.conversationID,createLinkRequest:{Title:_,Url:S}}),o(!1)},children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Label$2,{htmlFor:"link-title",children:"Title"}),jsxRuntime.jsx(Input,{id:"link-title",required:!0,minLength:2})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Label$2,{htmlFor:"link-url",children:"URL"}),jsxRuntime.jsx(Input,{id:"link-url",type:"url",required:!0,minLength:2,placeholder:"https://"})]}),jsxRuntime.jsx(Button$1,{type:"submit",children:"Add Link"})]})]})]})]})},UserSetupForm=t=>{const[e]=usePostV4UserByFieldNameMutation(),[n,o]=React.useState(""),[l,d]=React.useState(""),[f,g]=React.useState(!1),[b]=usePostV4PartnerByRouteApplicationIdBusinessDevelopmentConversationPartnerAndPartnerIdMutation();return jsxRuntime.jsxs("div",{className:"mx-auto mt-2",children:[jsxRuntime.jsx("p",{className:"mb-4",children:"Before you can start chatting, please set up your profile."}),jsxRuntime.jsxs("form",{className:"space-y-2",onSubmit:_=>{f||(g(!0),_.preventDefault(),e({fieldName:"Name",newValue:n}).then(()=>{b({routeApplicationId:t.appID,partnerId:"2"})}),e({fieldName:"Role",newValue:l}))},children:[jsxRuntime.jsx(Label$2,{htmlFor:"name",children:"Name"}),jsxRuntime.jsx(Input,{id:"name",required:!0,minLength:2,value:n,onChange:_=>o(_.target.value)}),jsxRuntime.jsx(Label$2,{htmlFor:"role",children:"Role"}),jsxRuntime.jsx(Input,{id:"role",required:!0,minLength:2,value:l,onChange:_=>d(_.target.value)}),jsxRuntime.jsx(Button$1,{type:"submit",disabled:f,children:f?"Saving...":"Save"})]})]})},sortChats=(t,e)=>t.unread>0&&e.unread===0?-1:e.unread>0&&t.unread===0?1:t.name.localeCompare(e.name);function ChatLayout({appID:t,inputRef:e,className:n}){const{setHasUnreads:o}=useChat(),{data:l,refetch:d}=useGetV4PartnerByRouteApplicationIdBusinessDevelopmentConversationsQuery({routeApplicationId:t}),[f,g]=React.useState(!1),[b,{isLoading:_}]=usePostV4PartnerByRouteApplicationIdBusinessDevelopmentConversationPartnerAndPartnerIdMutation(),S=React.useRef(null),[R]=useLazyGetV4PartnerByApplicationIdAccountQuery(),{sendPrompt:C}=useGemini({outputFormat:"text",useProModel:!0}),[E,A]=React.useState(!1),[M]=usePostV4PartnerByRouteApplicationIdBusinessDevelopmentConversationPartnerAndPartnerIdMutation(),[I]=usePostV4PartnerByRouteApplicationIdBusinessDevelopmentConversationAndConversationIdReadMutation(),[j]=useLazyGetV4PartnerByRouteApplicationIdBusinessDevelopmentConversationAndConversationIdMessagesQuery(),[F]=useLazyGetV4PartnerByRouteApplicationIdPartnerAndPartnerIdQuery(),[z,Q]=React.useState(!1);React.useEffect(()=>{l&&(se(ct=>{const Rt=l.map(Mt=>{var We;const It=ct.find(Ye=>Ye.conversationID===Mt.ConversationId);return{partner1:Mt.Participant1,partner2:Mt.Participant2,name:((We=Mt.Participant)==null?void 0:We.PublicName)??"missing public name",unread:(It==null?void 0:It.unread)??0,pending:Mt.Status!=="Approved",messages:(It==null?void 0:It.messages)??null,conversationID:Mt.ConversationId,lastMessageTime:Mt.LastMessageTime??null}});return Rt.sort(sortChats),Rt}),g(!0),setTimeout(()=>{var ct;return(ct=Be.current)==null?void 0:ct.focus()},50))},[l,t]);const[O,V]=React.useState(void 0),[te,ne]=React.useState(""),[ae,$e]=React.useState(null),[ge,se]=React.useState([]),[je,Ae]=React.useState(null),Ne=React.useRef(null),Ve=React.useRef(null),[Fe,Oe]=React.useState([]),Be=e||Ve,Ue=React.useRef(null),{toast:ze}=useToast(),He=()=>ge.find(ct=>ct.partner1===(O==null?void 0:O[0])&&ct.partner2===(O==null?void 0:O[1]));function Qe(){const ct=He();ct&&I({routeApplicationId:t,conversationId:ct.conversationID})}const et=ct=>Oe(Rt=>[...Rt,ct]);React.useEffect(()=>{if(Fe.length==0)return;console.log(Fe.length,"unprocessedMessages detected");const ct=(Mt,It)=>It.partner1===Mt.toPartnerID&&It.partner2===Mt.fromPartnerID||It.partner2===Mt.toPartnerID&&It.partner1===Mt.fromPartnerID;let Rt=!1;Fe.forEach(Mt=>{if(!ge.some(It=>ct(Mt,It))){console.log("message received for unknown convo ID - need to refetch!"),Rt=!0;return}se(It=>It.map(We=>{if(!ct(Mt,We))return We;const Ye=We.messages??[];if(Ye.some(pt=>pt.id===Mt.id))return We;let rt=1;const ut=document.activeElement&&document.activeElement===Be.current;return(O==null?void 0:O[0])==We.partner1&&O[1]==We.partner2&&ut&&(ut&&(rt=0,Qe()),setTimeout(()=>{var pt;return(pt=Ne.current)==null?void 0:pt.scrollIntoView({behavior:"smooth"})},50)),{...We,pending:!1,unread:We.unread+rt,messages:[...Ye,Mt]}}).sort(sortChats))}),console.log("need refetch:",Rt),Rt&&d(),Oe([])},[Fe,Oe,se,V,O]),React.useEffect(()=>{const ct=new HubConnectionBuilder().withUrl("https://api.randmar.io/hub",{accessTokenFactory:()=>localStorage.getItem("access_token"),headers:{"X-Impersonated-Id":t}}).configureLogging(LogLevel.Information).withAutomaticReconnect().withHubProtocol(new JsonHubProtocol).build();return ct.on("ReceiveMessage",et),ct.start().catch(Rt=>console.error("Error connecting to SignalR hub:",Rt)),Ae(ct),()=>{ct&&ct.stop()}},[t]),React.useEffect(()=>{var Rt;!O||!He()||((Rt=Be.current)==null||Rt.focus(),setTimeout(()=>{var Mt;return(Mt=Ne.current)==null?void 0:Mt.scrollIntoView({behavior:"smooth"})},50))},[O]),React.useEffect(()=>{if(!O)return;const ct=He();ct&&ct.conversationID!==-1&&(async()=>{var Rt;try{const It=((Rt=(await j({routeApplicationId:t,conversationId:ct.conversationID})).data)==null?void 0:Rt.map(We=>({id:"history"+We.MessageId,fromPartnerID:We.SenderId,toPartnerID:We.SenderId==ct.partner1?ct.partner2:ct.partner1,senderName:We.SenderName??"missing name",timestamp:new Date(We.SentDate+"Z").getTime(),content:We.Content??"no content"})))??[];se(We=>We.map(Ye=>Ye.conversationID===ct.conversationID?{...Ye,messages:It}:Ye).sort(sortChats))}catch(Mt){console.error("Error fetching conversation messages:",Mt)}})()},[O,j,t]),React.useEffect(()=>{if(!O)return;const ct=He();if(!ct)return;const Rt=document.activeElement&&document.activeElement===Be.current;ct.unread>0&&Rt&&(Qe(),se(Mt=>Mt.map(It=>It.partner1===O[0]&&It.partner2===O[1]?{...It,unread:0}:It)))},[O,ge]);const{sendMessage:Je}=useChat(),Ze=React.useCallback(ct=>{Je(`We have been talking with another Randmar partner and would like you to have the conversation as context for follow-up questions. Please acknowledge your reception of this chat history (one line summary of recent messages will do) and let me know that you're ready to answer questions: ${JSON.stringify(ct,null,2)}`)},[Je]),Ke=React.useCallback(async()=>{if(O)try{Q(!0);const ct=await R({applicationId:t}),Rt=O[0]===t?O[1]:O[0],Mt=await F({routeApplicationId:t,partnerId:Rt,withSpecification:!0}),It=buildPartnershipAssistantPrompt(ct.data,Mt.data);It?Je(It):ze({title:"Missing data",description:"We couldn't load enough data to analyze this partnership yet. Please try again shortly.",variant:"destructive"})}catch(ct){console.error("Error preparing partnership analysis:",ct),ze({title:"Error",description:"Could not analyze the partnership. Please try again later.",variant:"destructive"})}finally{Q(!1)}},[O,R,F,Je,ze,t]);React.useEffect(()=>{o(ge.some(ct=>ct.unread>0))},[ge,o]);const at=(ct,Rt)=>{Rt=Rt.replace(/\n/g,`
|
|
1139
1139
|
`),console.log("doSend",Rt),console.log("target",ct);const Mt={id:crypto.randomUUID(),senderName:(lt==null?void 0:lt.Name)??(lt==null?void 0:lt.EmailAddress)??"User",fromPartnerID:t,toPartnerID:ct.partner1===t?ct.partner2:ct.partner1,content:Rt,timestamp:Date.now()};et(Mt),je.invoke("NewMessage",Mt).catch(It=>console.error("Error sending message:",It)),ne(""),Ue.current&&(Ue.current.value="")},nt=()=>{let ct=te.trim();!yt||!ct||!O||!je||(yt.unread>0&&(Qe(),se(Rt=>Rt.map(Mt=>Mt.partner1===O[0]&&Mt.partner2===O[1]?{...Mt,unread:0}:Mt))),at(yt,ct))},st=(ct,Rt)=>$e([ct,Rt]);React.useEffect(()=>{if(ae===null)return;const ct=ge.find(Mt=>Mt.conversationID===ae[0]);if(!ct||(V([ct.partner1,ct.partner2]),!je))return;const Rt=ae[1];$e(null),Rt&&at(ct,Rt)},[ae,ge,V,je]);const{data:lt,isLoading:Ge}=useGetV4UserQuery();if(!f||Ge)return jsxRuntime.jsx(LoaderCircle,{className:"h-12 w-12 animate-spin mx-auto mb-4"});if(!(lt!=null&<.Name))return jsxRuntime.jsx(UserSetupForm,{appID:(lt==null?void 0:lt.ApplicationId)??""});const Ct=async()=>{var ct,Rt,Mt,It,We;S.current&&(S.current.disabled=!0),A(!0);try{const Ye=await R({applicationId:t}),rt=((ct=Ye.data)==null?void 0:ct.About)??"a new business venture",ut=[];(Rt=Ye.data)!=null&&Rt.IsManufacturer&&ut.push("Manufacturer"),(Mt=Ye.data)!=null&&Mt.IsReseller&&ut.push("Reseller"),(It=Ye.data)!=null&&It.IsSalesAgency&&ut.push("Sales Agency");const ft=`
|
|
1140
1140
|
Your task is to draft a ready-to-send opening message from a user to the Randmar team.
|
|
1141
1141
|
|