@chatsystem/client 1.1.70 → 1.1.72
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/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +2 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -81,7 +81,7 @@ For more details see https://formatjs.io/docs/getting-started/message-distributi
|
|
|
81
81
|
flex
|
|
82
82
|
justify-center
|
|
83
83
|
items-center
|
|
84
|
-
`,children:_.jsx(na,{facet:e.agent.display[Le.AgentDisplayFacetRoleType.ASSISTANT]})})},ou=new Set;function zT(e){return ou.has(e)?!1:(ou.add(e),!0)}function $T(e,{root:t,rootSelector:n,rootMargin:r="0px",threshold:i=0,dedupeKey:a}={}){const s=k.useRef(!1),u=k.useRef();return k.useCallback(c=>{if(u.current?.(),u.current=void 0,!c||s.current)return;const f=t??(n?document.querySelector(n):null),d=()=>{a&&!zT(a)||(s.current=!0,e())};if(typeof window>"u"||!("IntersectionObserver"in window)){d();return}const h=new IntersectionObserver((m,b)=>{m[0]?.isIntersecting&&(b.disconnect(),d())},{root:f,rootMargin:r,threshold:i});h.observe(c),u.current=()=>h.disconnect()},[t,n,r,i,a,e])}class Fn{constructor(){}static getApiUrl=()=>typeof document<"u"&&new URL(document.URL)?.host.includes("localhost:3080")?"http://localhost:3001":"https://www.api.chatsystem.ai";static getHeaders=({contentType:t="text/plain"})=>({"Content-Type":t,credendials:"omit"});static getFetchConfig=({contentType:t="text/plain",httpVerb:n="GET",body:r,options:i={}})=>{const a={method:n,headers:this.getHeaders({contentType:t}),...i};return r&&(a.body=JSON.stringify(r)),a}}function YT(e,t){if(!t||!e)return e;const n=t.replace(/^[?&]+/,""),[r,i]=e.split("#"),a=r.includes("?")?"&":"?",s=`${r}${a}${n}`;return i?`${s}#${i}`:s}function GT({href:e="",queryParamToAppend:t="",children:n,context:r,onClick:i,seenRootEl:a,...s}){const{companySettings:u}=k.useContext(dn),o=e.startsWith("/")||typeof window<"u"&&e.startsWith(window.location.origin),c=Fn.getApiUrl(),f=YT(e,u.api.tracking?.queryParamToAppend),d=()=>{const y=`${c}/tracking/clicked/${r.appToken}`,S={discussionId:r.discussionId,urlClicked:e};try{fetch(y,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(S),keepalive:!0,cache:"no-store",credentials:"omit",mode:"cors"}).catch(()=>{})}catch{}},h=()=>{const y=`${c}/tracking/displayed/${r.appToken}`,S={discussionId:r.discussionId,urlSeen:e};try{fetch(y,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(S),keepalive:!0,cache:"no-store",credentials:"omit",mode:"cors"}).catch(()=>{})}catch{}},m=k.useMemo(()=>`${r.appToken}::${r.discussionId}::${e}`,[r.appToken,r.discussionId,e]),b=$T(h,{root:a,threshold:0,rootMargin:"0px 0px -10% 0px",dedupeKey:m}),A=y=>{d(),i?.(y)},C=o?{}:{target:"_blank",rel:"noopener noreferrer"};return o?_.jsx("a",{ref:b,href:f,...s,onClick:A,className:"customLinkInternal",children:n}):_.jsx("a",{ref:b,href:f,...C,...s,onClick:A,className:"customLinkExternal",children:n})}const VT=({content:e,metaData:t,context:n,seenRootEl:r})=>{const{chatlineLabelAssistantTranslation:i}=ua();return _.jsxs("div",{className:"flex justify-between mt-8 px-3 chatLineAssistant",children:[_.jsx("div",{className:"w-10 mr-3 mt-6",children:_.jsx("div",{children:_.jsx(jT,{})})}),_.jsxs("div",{className:`w-full p-4 rounded-lg transition-all duration-300 ${t?.isErrorMessage?"bg-red-100 border-l-4 border-red-400 text-red-800 shadow-md animate-fade-in":"bg-white text-gray-800"}`,children:[_.jsx("p",{className:"font-bold",children:i}),_.jsx("div",{children:_.jsx(Go,{remarkPlugins:[UT],remarkRehypeOptions:{passThrough:["link"]},rehypePlugins:[Ol],components:{a:({node:a,href:s,children:u,...o})=>_.jsx(GT,{href:s??"",...o,context:n,seenRootEl:r,children:u})},children:e&&e})})]})]})},qT=({userType:e,content:t,metaData:n,context:r,seenRootEl:i})=>{const a=e==="user",s=e==="assistant";return _.jsxs(_.Fragment,{children:[a&&_.jsx(Ob,{content:t,metaData:n}),s&&_.jsx(VT,{content:t,metaData:n,context:r,seenRootEl:i})]})};function WT(e,t,n){let[r,i]=k.useState(e||t),a=k.useRef(e!==void 0),s=e!==void 0;k.useEffect(()=>{let c=a.current;c!==s&&console.warn(`WARN: A component changed from ${c?"controlled":"uncontrolled"} to ${s?"controlled":"uncontrolled"}.`),a.current=s},[s]);let u=s?e:r,o=k.useCallback((c,...f)=>{let d=(h,...m)=>{n&&(Object.is(u,h)||n(h,...m)),s||(u=h)};typeof c=="function"?(console.warn("We can not support a function callback. See Github Issues for details https://github.com/adobe/react-spectrum/issues/2320"),i((m,...b)=>{let A=c(s?u:m,...b);return d(A,...f),s?m:A})):(s||i(c),d(c,...f))},[s,u,n]);return[u,o]}const br={prefix:String(Math.round(Math.random()*1e10)),current:0},tc=k.createContext(br),XT=k.createContext(!1);let QT=!!(typeof window<"u"&&window.document&&window.document.createElement),mi=new WeakMap;function KT(e=!1){let t=k.useContext(tc),n=k.useRef(null);if(n.current===null&&!e){var r,i;let a=(i=k.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED)===null||i===void 0||(r=i.ReactCurrentOwner)===null||r===void 0?void 0:r.current;if(a){let s=mi.get(a);s==null?mi.set(a,{id:t.current,state:a.memoizedState}):a.memoizedState!==s.state&&(t.current=s.id,mi.delete(a))}n.current=++t.current}return n.current}function ZT(e){let t=k.useContext(tc);t===br&&!QT&&console.warn("When server rendering, you must wrap your application in an <SSRProvider> to ensure consistent ids are generated between the client and server.");let n=KT(!!e),r=t===br&&process.env.NODE_ENV==="test"?"react-aria":`react-aria${t.prefix}`;return e||`${r}-${n}`}function JT(e){let t=k.useId(),[n]=k.useState(i2()),r=n||process.env.NODE_ENV==="test"?"react-aria":`react-aria${br.prefix}`;return e||`${r}-${t}`}const e2=typeof k.useId=="function"?JT:ZT;function t2(){return!1}function n2(){return!0}function r2(e){return()=>{}}function i2(){return typeof k.useSyncExternalStore=="function"?k.useSyncExternalStore(r2,t2,n2):k.useContext(XT)}function nc(e){var t,n,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=nc(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function a2(){for(var e,t,n=0,r="",i=arguments.length;n<i;n++)(e=arguments[n])&&(t=nc(e))&&(r&&(r+=" "),r+=t);return r}const Qt=typeof document<"u"?k.useLayoutEffect:()=>{};function $t(e){const t=k.useRef(null);return Qt(()=>{t.current=e},[e]),k.useCallback((...n)=>{const r=t.current;return r?.(...n)},[])}function s2(e){let[t,n]=k.useState(e),r=k.useRef(null),i=$t(()=>{if(!r.current)return;let s=r.current.next();if(s.done){r.current=null;return}t===s.value?i():n(s.value)});Qt(()=>{r.current&&i()});let a=$t(s=>{r.current=s(t),i()});return[t,a]}let u2=!!(typeof window<"u"&&window.document&&window.document.createElement),Er=new Map;function Tr(e){let[t,n]=k.useState(e),r=k.useRef(null),i=e2(t),a=k.useCallback(s=>{r.current=s},[]);return u2&&Er.set(i,a),Qt(()=>{let s=i;return()=>{Er.delete(s)}},[i]),k.useEffect(()=>{let s=r.current;s&&(r.current=null,n(s))}),i}function o2(e,t){if(e===t)return e;let n=Er.get(e);if(n)return n(t),t;let r=Er.get(t);return r?(r(e),e):t}function lu(e=[]){let t=Tr(),[n,r]=s2(t),i=k.useCallback(()=>{r(function*(){yield t,yield document.getElementById(t)?t:void 0})},[t,r]);return Qt(i,[t,i,...e]),n}function l2(...e){return(...t)=>{for(let n of e)typeof n=="function"&&n(...t)}}const qn=e=>{var t;return(t=e?.ownerDocument)!==null&&t!==void 0?t:document},xr=e=>e&&"window"in e&&e.window===e?e:qn(e).defaultView||window;function yr(...e){let t={...e[0]};for(let n=1;n<e.length;n++){let r=e[n];for(let i in r){let a=t[i],s=r[i];typeof a=="function"&&typeof s=="function"&&i[0]==="o"&&i[1]==="n"&&i.charCodeAt(2)>=65&&i.charCodeAt(2)<=90?t[i]=l2(a,s):(i==="className"||i==="UNSAFE_className")&&typeof a=="string"&&typeof s=="string"?t[i]=a2(a,s):i==="id"&&a&&s?t.id=o2(a,s):t[i]=s!==void 0?s:a}}return t}const c2=new Set(["id"]),f2=new Set(["aria-label","aria-labelledby","aria-describedby","aria-details"]),d2=new Set(["href","target","rel","download","ping","referrerPolicy"]),h2=/^(data-.*)$/;function m2(e,t={}){let{labelable:n,isLink:r,propNames:i}=t,a={};for(const s in e)Object.prototype.hasOwnProperty.call(e,s)&&(c2.has(s)||n&&f2.has(s)||r&&d2.has(s)||i?.has(s)||h2.test(s))&&(a[s]=e[s]);return a}function cu(e){if(p2())e.focus({preventScroll:!0});else{let t=g2(e);e.focus(),b2(t)}}let rr=null;function p2(){if(rr==null){rr=!1;try{document.createElement("div").focus({get preventScroll(){return rr=!0,!0}})}catch{}}return rr}function g2(e){let t=e.parentNode,n=[],r=document.scrollingElement||document.documentElement;for(;t instanceof HTMLElement&&t!==r;)(t.offsetHeight<t.scrollHeight||t.offsetWidth<t.scrollWidth)&&n.push({element:t,scrollTop:t.scrollTop,scrollLeft:t.scrollLeft}),t=t.parentNode;return r instanceof HTMLElement&&n.push({element:r,scrollTop:r.scrollTop,scrollLeft:r.scrollLeft}),n}function b2(e){for(let{element:t,scrollTop:n,scrollLeft:r}of e)t.scrollTop=n,t.scrollLeft=r}function E2(e){var t;return typeof window>"u"||window.navigator==null?!1:((t=window.navigator.userAgentData)===null||t===void 0?void 0:t.brands.some(n=>e.test(n.brand)))||e.test(window.navigator.userAgent)}function T2(e){var t;return typeof window<"u"&&window.navigator!=null?e.test(((t=window.navigator.userAgentData)===null||t===void 0?void 0:t.platform)||window.navigator.platform):!1}function x2(){return T2(/^Mac/i)}function y2(){return E2(/Android/i)}let nn=new Map,Xi=new Set;function fu(){if(typeof window>"u")return;function e(r){return"propertyName"in r}let t=r=>{if(!e(r)||!r.target)return;let i=nn.get(r.target);i||(i=new Set,nn.set(r.target,i),r.target.addEventListener("transitioncancel",n,{once:!0})),i.add(r.propertyName)},n=r=>{if(!e(r)||!r.target)return;let i=nn.get(r.target);if(i&&(i.delete(r.propertyName),i.size===0&&(r.target.removeEventListener("transitioncancel",n),nn.delete(r.target)),nn.size===0)){for(let a of Xi)a();Xi.clear()}};document.body.addEventListener("transitionrun",t),document.body.addEventListener("transitionend",n)}typeof document<"u"&&(document.readyState!=="loading"?fu():document.addEventListener("DOMContentLoaded",fu));function A2(e){requestAnimationFrame(()=>{nn.size===0?e():Xi.add(e)})}function _2(e,t){let{id:n,"aria-label":r,"aria-labelledby":i}=e;return n=Tr(n),i&&r?i=[...new Set([n,...i.trim().split(/\s+/)])].join(" "):i&&(i=i.trim().split(/\s+/).join(" ")),!r&&!i&&t&&(r=t),{id:n,"aria-label":r,"aria-labelledby":i}}function S2(e,t){Qt(()=>{if(e&&e.ref&&t)return e.ref.current=t.current,()=>{e.ref&&(e.ref.current=null)}})}function C2(e){return e.mozInputSource===0&&e.isTrusted?!0:y2()&&e.pointerType?e.type==="click"&&e.buttons===1:e.detail===0&&!e.pointerType}function w2(e,t,n){let r=k.useRef(t),i=$t(()=>{n&&n(r.current)});k.useEffect(()=>{var a;let s=e==null||(a=e.current)===null||a===void 0?void 0:a.form;return s?.addEventListener("reset",i),()=>{s?.removeEventListener("reset",i)}},[e,i])}const v2=k.createContext({register:()=>{}});v2.displayName="PressResponderContext";class I2{isDefaultPrevented(){return this.nativeEvent.defaultPrevented}preventDefault(){this.defaultPrevented=!0,this.nativeEvent.preventDefault()}stopPropagation(){this.nativeEvent.stopPropagation(),this.isPropagationStopped=()=>!0}isPropagationStopped(){return!1}persist(){}constructor(t,n){this.nativeEvent=n,this.target=n.target,this.currentTarget=n.currentTarget,this.relatedTarget=n.relatedTarget,this.bubbles=n.bubbles,this.cancelable=n.cancelable,this.defaultPrevented=n.defaultPrevented,this.eventPhase=n.eventPhase,this.isTrusted=n.isTrusted,this.timeStamp=n.timeStamp,this.type=t}}function N2(e){let t=k.useRef({isFocused:!1,observer:null});Qt(()=>{const r=t.current;return()=>{r.observer&&(r.observer.disconnect(),r.observer=null)}},[]);let n=$t(r=>{e?.(r)});return k.useCallback(r=>{if(r.target instanceof HTMLButtonElement||r.target instanceof HTMLInputElement||r.target instanceof HTMLTextAreaElement||r.target instanceof HTMLSelectElement){t.current.isFocused=!0;let i=r.target,a=s=>{t.current.isFocused=!1,i.disabled&&n(new I2("blur",s)),t.current.observer&&(t.current.observer.disconnect(),t.current.observer=null)};i.addEventListener("focusout",a,{once:!0}),t.current.observer=new MutationObserver(()=>{if(t.current.isFocused&&i.disabled){var s;(s=t.current.observer)===null||s===void 0||s.disconnect();let u=i===document.activeElement?null:document.activeElement;i.dispatchEvent(new FocusEvent("blur",{relatedTarget:u})),i.dispatchEvent(new FocusEvent("focusout",{bubbles:!0,relatedTarget:u}))}}),t.current.observer.observe(i,{attributes:!0,attributeFilter:["disabled"]})}},[n])}function k2(e){let{isDisabled:t,onFocus:n,onBlur:r,onFocusChange:i}=e;const a=k.useCallback(o=>{if(o.target===o.currentTarget)return r&&r(o),i&&i(!1),!0},[r,i]),s=N2(a),u=k.useCallback(o=>{o.target===o.currentTarget&&document.activeElement===o.target&&(n&&n(o),i&&i(!0),s(o))},[i,n,s]);return{focusProps:{onFocus:!t&&(n||i||r)?u:void 0,onBlur:!t&&(r||i)?a:void 0}}}let Tn=null,O2=new Set,Dn=new Map,Vt=!1,Qi=!1;function Hr(e,t){for(let n of O2)n(e,t)}function R2(e){return!(e.metaKey||!x2()&&e.altKey||e.ctrlKey||e.key==="Control"||e.key==="Shift"||e.key==="Meta")}function Ar(e){Vt=!0,R2(e)&&(Tn="keyboard",Hr("keyboard",e))}function tt(e){Tn="pointer",(e.type==="mousedown"||e.type==="pointerdown")&&(Vt=!0,Hr("pointer",e))}function rc(e){C2(e)&&(Vt=!0,Tn="virtual")}function ic(e){e.target===window||e.target===document||(!Vt&&!Qi&&(Tn="virtual",Hr("virtual",e)),Vt=!1,Qi=!1)}function ac(){Vt=!1,Qi=!0}function du(e){if(typeof window>"u"||Dn.get(xr(e)))return;const t=xr(e),n=qn(e);let r=t.HTMLElement.prototype.focus;t.HTMLElement.prototype.focus=function(){Vt=!0,r.apply(this,arguments)},n.addEventListener("keydown",Ar,!0),n.addEventListener("keyup",Ar,!0),n.addEventListener("click",rc,!0),t.addEventListener("focus",ic,!0),t.addEventListener("blur",ac,!1),typeof PointerEvent<"u"?(n.addEventListener("pointerdown",tt,!0),n.addEventListener("pointermove",tt,!0),n.addEventListener("pointerup",tt,!0)):(n.addEventListener("mousedown",tt,!0),n.addEventListener("mousemove",tt,!0),n.addEventListener("mouseup",tt,!0)),t.addEventListener("beforeunload",()=>{sc(e)},{once:!0}),Dn.set(t,{focus:r})}const sc=(e,t)=>{const n=xr(e),r=qn(e);t&&r.removeEventListener("DOMContentLoaded",t),Dn.has(n)&&(n.HTMLElement.prototype.focus=Dn.get(n).focus,r.removeEventListener("keydown",Ar,!0),r.removeEventListener("keyup",Ar,!0),r.removeEventListener("click",rc,!0),n.removeEventListener("focus",ic,!0),n.removeEventListener("blur",ac,!1),typeof PointerEvent<"u"?(r.removeEventListener("pointerdown",tt,!0),r.removeEventListener("pointermove",tt,!0),r.removeEventListener("pointerup",tt,!0)):(r.removeEventListener("mousedown",tt,!0),r.removeEventListener("mousemove",tt,!0),r.removeEventListener("mouseup",tt,!0)),Dn.delete(n))};function L2(e){const t=qn(e);let n;return t.readyState!=="loading"?du(e):(n=()=>{du(e)},t.addEventListener("DOMContentLoaded",n)),()=>sc(e,n)}typeof document<"u"&&L2();function D2(){return Tn}function P2(e){Tn=e,Hr(e,null)}function hu(e){if(!e)return;let t=!0;return n=>{let r={...n,preventDefault(){n.preventDefault()},isDefaultPrevented(){return n.isDefaultPrevented()},stopPropagation(){console.error("stopPropagation is now the default behavior for events in React Spectrum. You can use continuePropagation() to revert this behavior.")},continuePropagation(){t=!1}};e(r),t&&n.stopPropagation()}}function M2(e){return{keyboardProps:e.isDisabled?{}:{onKeyDown:hu(e.onKeyDown),onKeyUp:hu(e.onKeyUp)}}}function B2(e){const t=qn(e);if(D2()==="virtual"){let n=t.activeElement;A2(()=>{t.activeElement===n&&e.isConnected&&cu(e)})}else cu(e)}function F2(e,t){return!e||!t?!1:t.some(n=>n.contains(e))}class Na{get size(){return this.fastMap.size}getTreeNode(t){return this.fastMap.get(t)}addTreeNode(t,n,r){let i=this.fastMap.get(n??null);if(!i)return;let a=new mu({scopeRef:t});i.addChild(a),a.parent=i,this.fastMap.set(t,a),r&&(a.nodeToRestore=r)}addNode(t){this.fastMap.set(t.scopeRef,t)}removeTreeNode(t){if(t===null)return;let n=this.fastMap.get(t);if(!n)return;let r=n.parent;for(let a of this.traverse())a!==n&&n.nodeToRestore&&a.nodeToRestore&&n.scopeRef&&n.scopeRef.current&&F2(a.nodeToRestore,n.scopeRef.current)&&(a.nodeToRestore=n.nodeToRestore);let i=n.children;r&&(r.removeChild(n),i.size>0&&i.forEach(a=>r&&r.addChild(a))),this.fastMap.delete(n.scopeRef)}*traverse(t=this.root){if(t.scopeRef!=null&&(yield t),t.children.size>0)for(let n of t.children)yield*this.traverse(n)}clone(){var t;let n=new Na;var r;for(let i of this.traverse())n.addTreeNode(i.scopeRef,(r=(t=i.parent)===null||t===void 0?void 0:t.scopeRef)!==null&&r!==void 0?r:null,i.nodeToRestore);return n}constructor(){this.fastMap=new Map,this.root=new mu({scopeRef:null}),this.fastMap.set(null,this.root)}}class mu{addChild(t){this.children.add(t),t.parent=this}removeChild(t){this.children.delete(t),t.parent=void 0}constructor(t){this.children=new Set,this.contain=!1,this.scopeRef=t.scopeRef}}new Na;let H2=k.createContext(null);function U2(e){let t=k.useContext(H2)||{};S2(t,e);let{ref:n,...r}=t;return r}function j2(e,t){let{focusProps:n}=k2(e),{keyboardProps:r}=M2(e),i=yr(n,r),a=U2(t),s=e.isDisabled?{}:a,u=k.useRef(e.autoFocus);return k.useEffect(()=>{u.current&&t.current&&B2(t.current),u.current=!1},[t]),{focusableProps:yr({...i,tabIndex:e.excludeFromTabOrder&&!e.isDisabled?-1:void 0},s)}}function z2(e,t,n){let{validationBehavior:r,focus:i}=e;Qt(()=>{if(r==="native"&&n?.current){let o=t.realtimeValidation.isInvalid?t.realtimeValidation.validationErrors.join(" ")||"Invalid value.":"";n.current.setCustomValidity(o),n.current.hasAttribute("title")||(n.current.title=""),t.realtimeValidation.isInvalid||t.updateValidation(Y2(n.current))}});let a=$t(()=>{t.resetValidation()}),s=$t(o=>{var c;t.displayValidation.isInvalid||t.commitValidation();let f=n==null||(c=n.current)===null||c===void 0?void 0:c.form;if(!o.defaultPrevented&&n&&f&&G2(f)===n.current){var d;i?i():(d=n.current)===null||d===void 0||d.focus(),P2("keyboard")}o.preventDefault()}),u=$t(()=>{t.commitValidation()});k.useEffect(()=>{let o=n?.current;if(!o)return;let c=o.form;return o.addEventListener("invalid",s),o.addEventListener("change",u),c?.addEventListener("reset",a),()=>{o.removeEventListener("invalid",s),o.removeEventListener("change",u),c?.removeEventListener("reset",a)}},[n,s,u,a,r])}function $2(e){let t=e.validity;return{badInput:t.badInput,customError:t.customError,patternMismatch:t.patternMismatch,rangeOverflow:t.rangeOverflow,rangeUnderflow:t.rangeUnderflow,stepMismatch:t.stepMismatch,tooLong:t.tooLong,tooShort:t.tooShort,typeMismatch:t.typeMismatch,valueMissing:t.valueMissing,valid:t.valid}}function Y2(e){return{isInvalid:!e.validity.valid,validationDetails:$2(e),validationErrors:e.validationMessage?[e.validationMessage]:[]}}function G2(e){for(let t=0;t<e.elements.length;t++){let n=e.elements[t];if(!n.validity.valid)return n}return null}const uc={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valueMissing:!1,valid:!0},oc={...uc,customError:!0,valid:!1},_n={isInvalid:!1,validationDetails:uc,validationErrors:[]},V2=k.createContext({}),pu="__formValidationState"+Date.now();function q2(e){if(e[pu]){let{realtimeValidation:t,displayValidation:n,updateValidation:r,resetValidation:i,commitValidation:a}=e[pu];return{realtimeValidation:t,displayValidation:n,updateValidation:r,resetValidation:i,commitValidation:a}}return W2(e)}function W2(e){let{isInvalid:t,validationState:n,name:r,value:i,builtinValidation:a,validate:s,validationBehavior:u="aria"}=e;n&&(t||(t=n==="invalid"));let o=t?{isInvalid:!0,validationErrors:[],validationDetails:oc}:null,c=k.useMemo(()=>gu(X2(s,i)),[s,i]);a?.validationDetails.valid&&(a=null);let f=k.useContext(V2),d=k.useMemo(()=>r?Array.isArray(r)?r.flatMap(w=>Ki(f[w])):Ki(f[r]):[],[f,r]),[h,m]=k.useState(f),[b,A]=k.useState(!1);f!==h&&(m(f),A(!1));let C=k.useMemo(()=>gu(b?[]:d),[b,d]),y=k.useRef(_n),[S,v]=k.useState(_n),D=k.useRef(_n),N=()=>{if(!O)return;q(!1);let w=c||a||y.current;pi(w,D.current)||(D.current=w,v(w))},[O,q]=k.useState(!1);return k.useEffect(N),{realtimeValidation:o||C||c||a||_n,displayValidation:u==="native"?o||C||S:o||C||c||a||S,updateValidation(w){u==="aria"&&!pi(S,w)?v(w):y.current=w},resetValidation(){let w=_n;pi(w,D.current)||(D.current=w,v(w)),u==="native"&&q(!1),A(!0)},commitValidation(){u==="native"&&q(!0),A(!0)}}}function Ki(e){return e?Array.isArray(e)?e:[e]:[]}function X2(e,t){if(typeof e=="function"){let n=e(t);if(n&&typeof n!="boolean")return Ki(n)}return[]}function gu(e){return e.length?{isInvalid:!0,validationErrors:e,validationDetails:oc}:null}function pi(e,t){return e===t?!0:e&&t&&e.isInvalid===t.isInvalid&&e.validationErrors.length===t.validationErrors.length&&e.validationErrors.every((n,r)=>n===t.validationErrors[r])&&Object.entries(e.validationDetails).every(([n,r])=>t.validationDetails[n]===r)}function Q2(e){let{id:t,label:n,"aria-labelledby":r,"aria-label":i,labelElementType:a="label"}=e;t=Tr(t);let s=Tr(),u={};n?(r=r?`${s} ${r}`:s,u={id:s,htmlFor:a==="label"?t:void 0}):!r&&!i&&console.warn("If you do not provide a visible label, you must specify an aria-label or aria-labelledby attribute for accessibility");let o=_2({id:t,"aria-label":i,"aria-labelledby":r});return{labelProps:u,fieldProps:o}}function K2(e){let{description:t,errorMessage:n,isInvalid:r,validationState:i}=e,{labelProps:a,fieldProps:s}=Q2(e),u=lu([!!t,!!n,r,i]),o=lu([!!t,!!n,r,i]);return s=yr(s,{"aria-describedby":[u,o,e["aria-describedby"]].filter(Boolean).join(" ")||void 0}),{labelProps:a,fieldProps:s,descriptionProps:{id:u},errorMessageProps:{id:o}}}function Z2(e,t){let{inputElementType:n="input",isDisabled:r=!1,isRequired:i=!1,isReadOnly:a=!1,type:s="text",validationBehavior:u="aria"}=e,[o,c]=WT(e.value,e.defaultValue||"",e.onChange),{focusableProps:f}=j2(e,t),d=q2({...e,value:o}),{isInvalid:h,validationErrors:m,validationDetails:b}=d.displayValidation,{labelProps:A,fieldProps:C,descriptionProps:y,errorMessageProps:S}=K2({...e,isInvalid:h,errorMessage:e.errorMessage||m}),v=m2(e,{labelable:!0});const D={type:s,pattern:e.pattern};return w2(t,o,c),z2(e,d,t),k.useEffect(()=>{if(t.current instanceof xr(t.current).HTMLTextAreaElement){let N=t.current;Object.defineProperty(N,"defaultValue",{get:()=>N.value,set:()=>{},configurable:!0})}},[t]),{labelProps:A,inputProps:yr(v,n==="input"&&D,{disabled:r,readOnly:a,required:i&&u==="native","aria-required":i&&u==="aria"||void 0,"aria-invalid":h||void 0,"aria-errormessage":e["aria-errormessage"],"aria-activedescendant":e["aria-activedescendant"],"aria-autocomplete":e["aria-autocomplete"],"aria-haspopup":e["aria-haspopup"],value:o,onChange:N=>c(N.target.value),autoComplete:e.autoComplete,autoCapitalize:e.autoCapitalize,maxLength:e.maxLength,minLength:e.minLength,name:e.name,placeholder:e.placeholder,inputMode:e.inputMode,onCopy:e.onCopy,onCut:e.onCut,onPaste:e.onPaste,onCompositionEnd:e.onCompositionEnd,onCompositionStart:e.onCompositionStart,onCompositionUpdate:e.onCompositionUpdate,onSelect:e.onSelect,onBeforeInput:e.onBeforeInput,onInput:e.onInput,...f,...C}),descriptionProps:y,errorMessageProps:S,isInvalid:h,validationErrors:m,validationDetails:b}}const J2=e=>e.charCodeAt(e.length-1)===10,ex=e=>{const[t,n]=k.useState(""),r=()=>{A.current&&(A.current.style.height=A.current.scrollHeight+"px")},i=()=>{A.current&&(A.current.style.height="48px")},a=G=>{n(G)};k.useEffect(r,[t]);let{label:s,SubmitComponent:u,onSubmit:o,isLoadingStream:c,audioEnabled:f=!1,MicComponent:d,onPressMicButton:h,LoadingComponent:m,onPressLoadingButton:b}=e,A=k.useRef(null),{labelProps:C,inputProps:y}=Z2({...e,inputElementType:"textarea"},A);const S=G=>{J2(G.target.value)||a(G.target.value)},v=G=>{if(G.key==="Enter"||G.code==="Enter"||G.keyCode===13||G.code==="NumpadEnter"){if(G.shiftKey)a(t+`
|
|
84
|
+
`,children:_.jsx(na,{facet:e.agent.display[Le.AgentDisplayFacetRoleType.ASSISTANT]})})},ou=new Set;function zT(e){return ou.has(e)?!1:(ou.add(e),!0)}function $T(e,{root:t,rootSelector:n,rootMargin:r="0px",threshold:i=0,dedupeKey:a}={}){const s=k.useRef(!1),u=k.useRef();return k.useCallback(c=>{if(u.current?.(),u.current=void 0,!c||s.current)return;const f=t??(n?document.querySelector(n):null),d=()=>{a&&!zT(a)||(s.current=!0,e())};if(typeof window>"u"||!("IntersectionObserver"in window)){d();return}const h=new IntersectionObserver((m,b)=>{m[0]?.isIntersecting&&(b.disconnect(),d())},{root:f,rootMargin:r,threshold:i});h.observe(c),u.current=()=>h.disconnect()},[t,n,r,i,a,e])}class Fn{constructor(){}static getApiUrl=()=>typeof document<"u"&&new URL(document.URL)?.host.includes("localhost:3080")?"http://localhost:3001":"https://www.api.chatsystem.ai";static getHeaders=({contentType:t="text/plain"})=>({"Content-Type":t});static getFetchConfig=({contentType:t="text/plain",httpVerb:n="GET",body:r,options:i={}})=>{const a={method:n,headers:this.getHeaders({contentType:t}),...i};return r&&(a.body=JSON.stringify(r)),a}}function YT(e,t){if(!t||!e)return e;const n=t.replace(/^[?&]+/,""),[r,i]=e.split("#"),a=r.includes("?")?"&":"?",s=`${r}${a}${n}`;return i?`${s}#${i}`:s}function GT({href:e="",queryParamToAppend:t="",children:n,context:r,onClick:i,seenRootEl:a,...s}){const{companySettings:u}=k.useContext(dn),o=e.startsWith("/")||typeof window<"u"&&e.startsWith(window.location.origin),c=Fn.getApiUrl(),f=YT(e,u.api.tracking?.queryParamToAppend),d=()=>{const y=`${c}/tracking/clicked/${r.appToken}`,S={discussionId:r.discussionId,urlClicked:e};try{fetch(y,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(S),keepalive:!0,cache:"no-store",credentials:"omit",mode:"cors"}).catch(()=>{})}catch{}},h=()=>{const y=`${c}/tracking/displayed/${r.appToken}`,S={discussionId:r.discussionId,urlSeen:e};try{fetch(y,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(S),keepalive:!0,cache:"no-store",credentials:"omit",mode:"cors"}).catch(()=>{})}catch{}},m=k.useMemo(()=>`${r.appToken}::${r.discussionId}::${e}`,[r.appToken,r.discussionId,e]),b=$T(h,{root:a,threshold:0,rootMargin:"0px 0px -10% 0px",dedupeKey:m}),A=y=>{d(),i?.(y)},C=o?{}:{target:"_blank",rel:"noopener noreferrer"};return o?_.jsx("a",{ref:b,href:f,...s,onClick:A,className:"customLinkInternal",children:n}):_.jsx("a",{ref:b,href:f,...C,...s,onClick:A,className:"customLinkExternal",children:n})}const VT=({content:e,metaData:t,context:n,seenRootEl:r})=>{const{chatlineLabelAssistantTranslation:i}=ua();return _.jsxs("div",{className:"flex justify-between mt-8 px-3 chatLineAssistant",children:[_.jsx("div",{className:"w-10 mr-3 mt-6",children:_.jsx("div",{children:_.jsx(jT,{})})}),_.jsxs("div",{className:`w-full p-4 rounded-lg transition-all duration-300 ${t?.isErrorMessage?"bg-red-100 border-l-4 border-red-400 text-red-800 shadow-md animate-fade-in":"bg-white text-gray-800"}`,children:[_.jsx("p",{className:"font-bold",children:i}),_.jsx("div",{children:_.jsx(Go,{remarkPlugins:[UT],remarkRehypeOptions:{passThrough:["link"]},rehypePlugins:[Ol],components:{a:({node:a,href:s,children:u,...o})=>_.jsx(GT,{href:s??"",...o,context:n,seenRootEl:r,children:u})},children:e&&e})})]})]})},qT=({userType:e,content:t,metaData:n,context:r,seenRootEl:i})=>{const a=e==="user",s=e==="assistant";return _.jsxs(_.Fragment,{children:[a&&_.jsx(Ob,{content:t,metaData:n}),s&&_.jsx(VT,{content:t,metaData:n,context:r,seenRootEl:i})]})};function WT(e,t,n){let[r,i]=k.useState(e||t),a=k.useRef(e!==void 0),s=e!==void 0;k.useEffect(()=>{let c=a.current;c!==s&&console.warn(`WARN: A component changed from ${c?"controlled":"uncontrolled"} to ${s?"controlled":"uncontrolled"}.`),a.current=s},[s]);let u=s?e:r,o=k.useCallback((c,...f)=>{let d=(h,...m)=>{n&&(Object.is(u,h)||n(h,...m)),s||(u=h)};typeof c=="function"?(console.warn("We can not support a function callback. See Github Issues for details https://github.com/adobe/react-spectrum/issues/2320"),i((m,...b)=>{let A=c(s?u:m,...b);return d(A,...f),s?m:A})):(s||i(c),d(c,...f))},[s,u,n]);return[u,o]}const br={prefix:String(Math.round(Math.random()*1e10)),current:0},tc=k.createContext(br),XT=k.createContext(!1);let QT=!!(typeof window<"u"&&window.document&&window.document.createElement),mi=new WeakMap;function KT(e=!1){let t=k.useContext(tc),n=k.useRef(null);if(n.current===null&&!e){var r,i;let a=(i=k.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED)===null||i===void 0||(r=i.ReactCurrentOwner)===null||r===void 0?void 0:r.current;if(a){let s=mi.get(a);s==null?mi.set(a,{id:t.current,state:a.memoizedState}):a.memoizedState!==s.state&&(t.current=s.id,mi.delete(a))}n.current=++t.current}return n.current}function ZT(e){let t=k.useContext(tc);t===br&&!QT&&console.warn("When server rendering, you must wrap your application in an <SSRProvider> to ensure consistent ids are generated between the client and server.");let n=KT(!!e),r=t===br&&process.env.NODE_ENV==="test"?"react-aria":`react-aria${t.prefix}`;return e||`${r}-${n}`}function JT(e){let t=k.useId(),[n]=k.useState(i2()),r=n||process.env.NODE_ENV==="test"?"react-aria":`react-aria${br.prefix}`;return e||`${r}-${t}`}const e2=typeof k.useId=="function"?JT:ZT;function t2(){return!1}function n2(){return!0}function r2(e){return()=>{}}function i2(){return typeof k.useSyncExternalStore=="function"?k.useSyncExternalStore(r2,t2,n2):k.useContext(XT)}function nc(e){var t,n,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=nc(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function a2(){for(var e,t,n=0,r="",i=arguments.length;n<i;n++)(e=arguments[n])&&(t=nc(e))&&(r&&(r+=" "),r+=t);return r}const Qt=typeof document<"u"?k.useLayoutEffect:()=>{};function $t(e){const t=k.useRef(null);return Qt(()=>{t.current=e},[e]),k.useCallback((...n)=>{const r=t.current;return r?.(...n)},[])}function s2(e){let[t,n]=k.useState(e),r=k.useRef(null),i=$t(()=>{if(!r.current)return;let s=r.current.next();if(s.done){r.current=null;return}t===s.value?i():n(s.value)});Qt(()=>{r.current&&i()});let a=$t(s=>{r.current=s(t),i()});return[t,a]}let u2=!!(typeof window<"u"&&window.document&&window.document.createElement),Er=new Map;function Tr(e){let[t,n]=k.useState(e),r=k.useRef(null),i=e2(t),a=k.useCallback(s=>{r.current=s},[]);return u2&&Er.set(i,a),Qt(()=>{let s=i;return()=>{Er.delete(s)}},[i]),k.useEffect(()=>{let s=r.current;s&&(r.current=null,n(s))}),i}function o2(e,t){if(e===t)return e;let n=Er.get(e);if(n)return n(t),t;let r=Er.get(t);return r?(r(e),e):t}function lu(e=[]){let t=Tr(),[n,r]=s2(t),i=k.useCallback(()=>{r(function*(){yield t,yield document.getElementById(t)?t:void 0})},[t,r]);return Qt(i,[t,i,...e]),n}function l2(...e){return(...t)=>{for(let n of e)typeof n=="function"&&n(...t)}}const qn=e=>{var t;return(t=e?.ownerDocument)!==null&&t!==void 0?t:document},xr=e=>e&&"window"in e&&e.window===e?e:qn(e).defaultView||window;function yr(...e){let t={...e[0]};for(let n=1;n<e.length;n++){let r=e[n];for(let i in r){let a=t[i],s=r[i];typeof a=="function"&&typeof s=="function"&&i[0]==="o"&&i[1]==="n"&&i.charCodeAt(2)>=65&&i.charCodeAt(2)<=90?t[i]=l2(a,s):(i==="className"||i==="UNSAFE_className")&&typeof a=="string"&&typeof s=="string"?t[i]=a2(a,s):i==="id"&&a&&s?t.id=o2(a,s):t[i]=s!==void 0?s:a}}return t}const c2=new Set(["id"]),f2=new Set(["aria-label","aria-labelledby","aria-describedby","aria-details"]),d2=new Set(["href","target","rel","download","ping","referrerPolicy"]),h2=/^(data-.*)$/;function m2(e,t={}){let{labelable:n,isLink:r,propNames:i}=t,a={};for(const s in e)Object.prototype.hasOwnProperty.call(e,s)&&(c2.has(s)||n&&f2.has(s)||r&&d2.has(s)||i?.has(s)||h2.test(s))&&(a[s]=e[s]);return a}function cu(e){if(p2())e.focus({preventScroll:!0});else{let t=g2(e);e.focus(),b2(t)}}let rr=null;function p2(){if(rr==null){rr=!1;try{document.createElement("div").focus({get preventScroll(){return rr=!0,!0}})}catch{}}return rr}function g2(e){let t=e.parentNode,n=[],r=document.scrollingElement||document.documentElement;for(;t instanceof HTMLElement&&t!==r;)(t.offsetHeight<t.scrollHeight||t.offsetWidth<t.scrollWidth)&&n.push({element:t,scrollTop:t.scrollTop,scrollLeft:t.scrollLeft}),t=t.parentNode;return r instanceof HTMLElement&&n.push({element:r,scrollTop:r.scrollTop,scrollLeft:r.scrollLeft}),n}function b2(e){for(let{element:t,scrollTop:n,scrollLeft:r}of e)t.scrollTop=n,t.scrollLeft=r}function E2(e){var t;return typeof window>"u"||window.navigator==null?!1:((t=window.navigator.userAgentData)===null||t===void 0?void 0:t.brands.some(n=>e.test(n.brand)))||e.test(window.navigator.userAgent)}function T2(e){var t;return typeof window<"u"&&window.navigator!=null?e.test(((t=window.navigator.userAgentData)===null||t===void 0?void 0:t.platform)||window.navigator.platform):!1}function x2(){return T2(/^Mac/i)}function y2(){return E2(/Android/i)}let nn=new Map,Xi=new Set;function fu(){if(typeof window>"u")return;function e(r){return"propertyName"in r}let t=r=>{if(!e(r)||!r.target)return;let i=nn.get(r.target);i||(i=new Set,nn.set(r.target,i),r.target.addEventListener("transitioncancel",n,{once:!0})),i.add(r.propertyName)},n=r=>{if(!e(r)||!r.target)return;let i=nn.get(r.target);if(i&&(i.delete(r.propertyName),i.size===0&&(r.target.removeEventListener("transitioncancel",n),nn.delete(r.target)),nn.size===0)){for(let a of Xi)a();Xi.clear()}};document.body.addEventListener("transitionrun",t),document.body.addEventListener("transitionend",n)}typeof document<"u"&&(document.readyState!=="loading"?fu():document.addEventListener("DOMContentLoaded",fu));function A2(e){requestAnimationFrame(()=>{nn.size===0?e():Xi.add(e)})}function _2(e,t){let{id:n,"aria-label":r,"aria-labelledby":i}=e;return n=Tr(n),i&&r?i=[...new Set([n,...i.trim().split(/\s+/)])].join(" "):i&&(i=i.trim().split(/\s+/).join(" ")),!r&&!i&&t&&(r=t),{id:n,"aria-label":r,"aria-labelledby":i}}function S2(e,t){Qt(()=>{if(e&&e.ref&&t)return e.ref.current=t.current,()=>{e.ref&&(e.ref.current=null)}})}function C2(e){return e.mozInputSource===0&&e.isTrusted?!0:y2()&&e.pointerType?e.type==="click"&&e.buttons===1:e.detail===0&&!e.pointerType}function w2(e,t,n){let r=k.useRef(t),i=$t(()=>{n&&n(r.current)});k.useEffect(()=>{var a;let s=e==null||(a=e.current)===null||a===void 0?void 0:a.form;return s?.addEventListener("reset",i),()=>{s?.removeEventListener("reset",i)}},[e,i])}const v2=k.createContext({register:()=>{}});v2.displayName="PressResponderContext";class I2{isDefaultPrevented(){return this.nativeEvent.defaultPrevented}preventDefault(){this.defaultPrevented=!0,this.nativeEvent.preventDefault()}stopPropagation(){this.nativeEvent.stopPropagation(),this.isPropagationStopped=()=>!0}isPropagationStopped(){return!1}persist(){}constructor(t,n){this.nativeEvent=n,this.target=n.target,this.currentTarget=n.currentTarget,this.relatedTarget=n.relatedTarget,this.bubbles=n.bubbles,this.cancelable=n.cancelable,this.defaultPrevented=n.defaultPrevented,this.eventPhase=n.eventPhase,this.isTrusted=n.isTrusted,this.timeStamp=n.timeStamp,this.type=t}}function N2(e){let t=k.useRef({isFocused:!1,observer:null});Qt(()=>{const r=t.current;return()=>{r.observer&&(r.observer.disconnect(),r.observer=null)}},[]);let n=$t(r=>{e?.(r)});return k.useCallback(r=>{if(r.target instanceof HTMLButtonElement||r.target instanceof HTMLInputElement||r.target instanceof HTMLTextAreaElement||r.target instanceof HTMLSelectElement){t.current.isFocused=!0;let i=r.target,a=s=>{t.current.isFocused=!1,i.disabled&&n(new I2("blur",s)),t.current.observer&&(t.current.observer.disconnect(),t.current.observer=null)};i.addEventListener("focusout",a,{once:!0}),t.current.observer=new MutationObserver(()=>{if(t.current.isFocused&&i.disabled){var s;(s=t.current.observer)===null||s===void 0||s.disconnect();let u=i===document.activeElement?null:document.activeElement;i.dispatchEvent(new FocusEvent("blur",{relatedTarget:u})),i.dispatchEvent(new FocusEvent("focusout",{bubbles:!0,relatedTarget:u}))}}),t.current.observer.observe(i,{attributes:!0,attributeFilter:["disabled"]})}},[n])}function k2(e){let{isDisabled:t,onFocus:n,onBlur:r,onFocusChange:i}=e;const a=k.useCallback(o=>{if(o.target===o.currentTarget)return r&&r(o),i&&i(!1),!0},[r,i]),s=N2(a),u=k.useCallback(o=>{o.target===o.currentTarget&&document.activeElement===o.target&&(n&&n(o),i&&i(!0),s(o))},[i,n,s]);return{focusProps:{onFocus:!t&&(n||i||r)?u:void 0,onBlur:!t&&(r||i)?a:void 0}}}let Tn=null,O2=new Set,Dn=new Map,Vt=!1,Qi=!1;function Hr(e,t){for(let n of O2)n(e,t)}function R2(e){return!(e.metaKey||!x2()&&e.altKey||e.ctrlKey||e.key==="Control"||e.key==="Shift"||e.key==="Meta")}function Ar(e){Vt=!0,R2(e)&&(Tn="keyboard",Hr("keyboard",e))}function tt(e){Tn="pointer",(e.type==="mousedown"||e.type==="pointerdown")&&(Vt=!0,Hr("pointer",e))}function rc(e){C2(e)&&(Vt=!0,Tn="virtual")}function ic(e){e.target===window||e.target===document||(!Vt&&!Qi&&(Tn="virtual",Hr("virtual",e)),Vt=!1,Qi=!1)}function ac(){Vt=!1,Qi=!0}function du(e){if(typeof window>"u"||Dn.get(xr(e)))return;const t=xr(e),n=qn(e);let r=t.HTMLElement.prototype.focus;t.HTMLElement.prototype.focus=function(){Vt=!0,r.apply(this,arguments)},n.addEventListener("keydown",Ar,!0),n.addEventListener("keyup",Ar,!0),n.addEventListener("click",rc,!0),t.addEventListener("focus",ic,!0),t.addEventListener("blur",ac,!1),typeof PointerEvent<"u"?(n.addEventListener("pointerdown",tt,!0),n.addEventListener("pointermove",tt,!0),n.addEventListener("pointerup",tt,!0)):(n.addEventListener("mousedown",tt,!0),n.addEventListener("mousemove",tt,!0),n.addEventListener("mouseup",tt,!0)),t.addEventListener("beforeunload",()=>{sc(e)},{once:!0}),Dn.set(t,{focus:r})}const sc=(e,t)=>{const n=xr(e),r=qn(e);t&&r.removeEventListener("DOMContentLoaded",t),Dn.has(n)&&(n.HTMLElement.prototype.focus=Dn.get(n).focus,r.removeEventListener("keydown",Ar,!0),r.removeEventListener("keyup",Ar,!0),r.removeEventListener("click",rc,!0),n.removeEventListener("focus",ic,!0),n.removeEventListener("blur",ac,!1),typeof PointerEvent<"u"?(r.removeEventListener("pointerdown",tt,!0),r.removeEventListener("pointermove",tt,!0),r.removeEventListener("pointerup",tt,!0)):(r.removeEventListener("mousedown",tt,!0),r.removeEventListener("mousemove",tt,!0),r.removeEventListener("mouseup",tt,!0)),Dn.delete(n))};function L2(e){const t=qn(e);let n;return t.readyState!=="loading"?du(e):(n=()=>{du(e)},t.addEventListener("DOMContentLoaded",n)),()=>sc(e,n)}typeof document<"u"&&L2();function D2(){return Tn}function P2(e){Tn=e,Hr(e,null)}function hu(e){if(!e)return;let t=!0;return n=>{let r={...n,preventDefault(){n.preventDefault()},isDefaultPrevented(){return n.isDefaultPrevented()},stopPropagation(){console.error("stopPropagation is now the default behavior for events in React Spectrum. You can use continuePropagation() to revert this behavior.")},continuePropagation(){t=!1}};e(r),t&&n.stopPropagation()}}function M2(e){return{keyboardProps:e.isDisabled?{}:{onKeyDown:hu(e.onKeyDown),onKeyUp:hu(e.onKeyUp)}}}function B2(e){const t=qn(e);if(D2()==="virtual"){let n=t.activeElement;A2(()=>{t.activeElement===n&&e.isConnected&&cu(e)})}else cu(e)}function F2(e,t){return!e||!t?!1:t.some(n=>n.contains(e))}class Na{get size(){return this.fastMap.size}getTreeNode(t){return this.fastMap.get(t)}addTreeNode(t,n,r){let i=this.fastMap.get(n??null);if(!i)return;let a=new mu({scopeRef:t});i.addChild(a),a.parent=i,this.fastMap.set(t,a),r&&(a.nodeToRestore=r)}addNode(t){this.fastMap.set(t.scopeRef,t)}removeTreeNode(t){if(t===null)return;let n=this.fastMap.get(t);if(!n)return;let r=n.parent;for(let a of this.traverse())a!==n&&n.nodeToRestore&&a.nodeToRestore&&n.scopeRef&&n.scopeRef.current&&F2(a.nodeToRestore,n.scopeRef.current)&&(a.nodeToRestore=n.nodeToRestore);let i=n.children;r&&(r.removeChild(n),i.size>0&&i.forEach(a=>r&&r.addChild(a))),this.fastMap.delete(n.scopeRef)}*traverse(t=this.root){if(t.scopeRef!=null&&(yield t),t.children.size>0)for(let n of t.children)yield*this.traverse(n)}clone(){var t;let n=new Na;var r;for(let i of this.traverse())n.addTreeNode(i.scopeRef,(r=(t=i.parent)===null||t===void 0?void 0:t.scopeRef)!==null&&r!==void 0?r:null,i.nodeToRestore);return n}constructor(){this.fastMap=new Map,this.root=new mu({scopeRef:null}),this.fastMap.set(null,this.root)}}class mu{addChild(t){this.children.add(t),t.parent=this}removeChild(t){this.children.delete(t),t.parent=void 0}constructor(t){this.children=new Set,this.contain=!1,this.scopeRef=t.scopeRef}}new Na;let H2=k.createContext(null);function U2(e){let t=k.useContext(H2)||{};S2(t,e);let{ref:n,...r}=t;return r}function j2(e,t){let{focusProps:n}=k2(e),{keyboardProps:r}=M2(e),i=yr(n,r),a=U2(t),s=e.isDisabled?{}:a,u=k.useRef(e.autoFocus);return k.useEffect(()=>{u.current&&t.current&&B2(t.current),u.current=!1},[t]),{focusableProps:yr({...i,tabIndex:e.excludeFromTabOrder&&!e.isDisabled?-1:void 0},s)}}function z2(e,t,n){let{validationBehavior:r,focus:i}=e;Qt(()=>{if(r==="native"&&n?.current){let o=t.realtimeValidation.isInvalid?t.realtimeValidation.validationErrors.join(" ")||"Invalid value.":"";n.current.setCustomValidity(o),n.current.hasAttribute("title")||(n.current.title=""),t.realtimeValidation.isInvalid||t.updateValidation(Y2(n.current))}});let a=$t(()=>{t.resetValidation()}),s=$t(o=>{var c;t.displayValidation.isInvalid||t.commitValidation();let f=n==null||(c=n.current)===null||c===void 0?void 0:c.form;if(!o.defaultPrevented&&n&&f&&G2(f)===n.current){var d;i?i():(d=n.current)===null||d===void 0||d.focus(),P2("keyboard")}o.preventDefault()}),u=$t(()=>{t.commitValidation()});k.useEffect(()=>{let o=n?.current;if(!o)return;let c=o.form;return o.addEventListener("invalid",s),o.addEventListener("change",u),c?.addEventListener("reset",a),()=>{o.removeEventListener("invalid",s),o.removeEventListener("change",u),c?.removeEventListener("reset",a)}},[n,s,u,a,r])}function $2(e){let t=e.validity;return{badInput:t.badInput,customError:t.customError,patternMismatch:t.patternMismatch,rangeOverflow:t.rangeOverflow,rangeUnderflow:t.rangeUnderflow,stepMismatch:t.stepMismatch,tooLong:t.tooLong,tooShort:t.tooShort,typeMismatch:t.typeMismatch,valueMissing:t.valueMissing,valid:t.valid}}function Y2(e){return{isInvalid:!e.validity.valid,validationDetails:$2(e),validationErrors:e.validationMessage?[e.validationMessage]:[]}}function G2(e){for(let t=0;t<e.elements.length;t++){let n=e.elements[t];if(!n.validity.valid)return n}return null}const uc={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valueMissing:!1,valid:!0},oc={...uc,customError:!0,valid:!1},_n={isInvalid:!1,validationDetails:uc,validationErrors:[]},V2=k.createContext({}),pu="__formValidationState"+Date.now();function q2(e){if(e[pu]){let{realtimeValidation:t,displayValidation:n,updateValidation:r,resetValidation:i,commitValidation:a}=e[pu];return{realtimeValidation:t,displayValidation:n,updateValidation:r,resetValidation:i,commitValidation:a}}return W2(e)}function W2(e){let{isInvalid:t,validationState:n,name:r,value:i,builtinValidation:a,validate:s,validationBehavior:u="aria"}=e;n&&(t||(t=n==="invalid"));let o=t?{isInvalid:!0,validationErrors:[],validationDetails:oc}:null,c=k.useMemo(()=>gu(X2(s,i)),[s,i]);a?.validationDetails.valid&&(a=null);let f=k.useContext(V2),d=k.useMemo(()=>r?Array.isArray(r)?r.flatMap(w=>Ki(f[w])):Ki(f[r]):[],[f,r]),[h,m]=k.useState(f),[b,A]=k.useState(!1);f!==h&&(m(f),A(!1));let C=k.useMemo(()=>gu(b?[]:d),[b,d]),y=k.useRef(_n),[S,v]=k.useState(_n),D=k.useRef(_n),N=()=>{if(!O)return;q(!1);let w=c||a||y.current;pi(w,D.current)||(D.current=w,v(w))},[O,q]=k.useState(!1);return k.useEffect(N),{realtimeValidation:o||C||c||a||_n,displayValidation:u==="native"?o||C||S:o||C||c||a||S,updateValidation(w){u==="aria"&&!pi(S,w)?v(w):y.current=w},resetValidation(){let w=_n;pi(w,D.current)||(D.current=w,v(w)),u==="native"&&q(!1),A(!0)},commitValidation(){u==="native"&&q(!0),A(!0)}}}function Ki(e){return e?Array.isArray(e)?e:[e]:[]}function X2(e,t){if(typeof e=="function"){let n=e(t);if(n&&typeof n!="boolean")return Ki(n)}return[]}function gu(e){return e.length?{isInvalid:!0,validationErrors:e,validationDetails:oc}:null}function pi(e,t){return e===t?!0:e&&t&&e.isInvalid===t.isInvalid&&e.validationErrors.length===t.validationErrors.length&&e.validationErrors.every((n,r)=>n===t.validationErrors[r])&&Object.entries(e.validationDetails).every(([n,r])=>t.validationDetails[n]===r)}function Q2(e){let{id:t,label:n,"aria-labelledby":r,"aria-label":i,labelElementType:a="label"}=e;t=Tr(t);let s=Tr(),u={};n?(r=r?`${s} ${r}`:s,u={id:s,htmlFor:a==="label"?t:void 0}):!r&&!i&&console.warn("If you do not provide a visible label, you must specify an aria-label or aria-labelledby attribute for accessibility");let o=_2({id:t,"aria-label":i,"aria-labelledby":r});return{labelProps:u,fieldProps:o}}function K2(e){let{description:t,errorMessage:n,isInvalid:r,validationState:i}=e,{labelProps:a,fieldProps:s}=Q2(e),u=lu([!!t,!!n,r,i]),o=lu([!!t,!!n,r,i]);return s=yr(s,{"aria-describedby":[u,o,e["aria-describedby"]].filter(Boolean).join(" ")||void 0}),{labelProps:a,fieldProps:s,descriptionProps:{id:u},errorMessageProps:{id:o}}}function Z2(e,t){let{inputElementType:n="input",isDisabled:r=!1,isRequired:i=!1,isReadOnly:a=!1,type:s="text",validationBehavior:u="aria"}=e,[o,c]=WT(e.value,e.defaultValue||"",e.onChange),{focusableProps:f}=j2(e,t),d=q2({...e,value:o}),{isInvalid:h,validationErrors:m,validationDetails:b}=d.displayValidation,{labelProps:A,fieldProps:C,descriptionProps:y,errorMessageProps:S}=K2({...e,isInvalid:h,errorMessage:e.errorMessage||m}),v=m2(e,{labelable:!0});const D={type:s,pattern:e.pattern};return w2(t,o,c),z2(e,d,t),k.useEffect(()=>{if(t.current instanceof xr(t.current).HTMLTextAreaElement){let N=t.current;Object.defineProperty(N,"defaultValue",{get:()=>N.value,set:()=>{},configurable:!0})}},[t]),{labelProps:A,inputProps:yr(v,n==="input"&&D,{disabled:r,readOnly:a,required:i&&u==="native","aria-required":i&&u==="aria"||void 0,"aria-invalid":h||void 0,"aria-errormessage":e["aria-errormessage"],"aria-activedescendant":e["aria-activedescendant"],"aria-autocomplete":e["aria-autocomplete"],"aria-haspopup":e["aria-haspopup"],value:o,onChange:N=>c(N.target.value),autoComplete:e.autoComplete,autoCapitalize:e.autoCapitalize,maxLength:e.maxLength,minLength:e.minLength,name:e.name,placeholder:e.placeholder,inputMode:e.inputMode,onCopy:e.onCopy,onCut:e.onCut,onPaste:e.onPaste,onCompositionEnd:e.onCompositionEnd,onCompositionStart:e.onCompositionStart,onCompositionUpdate:e.onCompositionUpdate,onSelect:e.onSelect,onBeforeInput:e.onBeforeInput,onInput:e.onInput,...f,...C}),descriptionProps:y,errorMessageProps:S,isInvalid:h,validationErrors:m,validationDetails:b}}const J2=e=>e.charCodeAt(e.length-1)===10,ex=e=>{const[t,n]=k.useState(""),r=()=>{A.current&&(A.current.style.height=A.current.scrollHeight+"px")},i=()=>{A.current&&(A.current.style.height="48px")},a=G=>{n(G)};k.useEffect(r,[t]);let{label:s,SubmitComponent:u,onSubmit:o,isLoadingStream:c,audioEnabled:f=!1,MicComponent:d,onPressMicButton:h,LoadingComponent:m,onPressLoadingButton:b}=e,A=k.useRef(null),{labelProps:C,inputProps:y}=Z2({...e,inputElementType:"textarea"},A);const S=G=>{J2(G.target.value)||a(G.target.value)},v=G=>{if(G.key==="Enter"||G.code==="Enter"||G.keyCode===13||G.code==="NumpadEnter"){if(G.shiftKey)a(t+`
|
|
85
85
|
`);else if(!G.shiftKey){G.preventDefault(),G.stopPropagation(),c||O();return}}},D=G=>{(G.key==="Enter"||G.code==="Enter"||G.keyCode===13||G.code==="NumpadEnter")&&(G.preventDefault(),G.stopPropagation())};let N=e.isDisabled;e.shouldDisableIfInputIsEmpty&&(N=e.isDisabled||t.length===0);const O=()=>{i(),o&&o(t),a("")},q=t.trim().length>0;console.log("audio",f);const ue=()=>c&&m?_.jsx("div",{className:"relative",children:_.jsx(m,{onPressLoadingButton:b})}):u?!f||!d?_.jsx("div",{className:"relative",children:_.jsx(u,{onSubmitButton:O,isDisabled:N})}):q?_.jsx("div",{className:"relative",children:_.jsx(u,{onSubmitButton:O,isDisabled:N})}):_.jsxs("div",{className:"relative",children:[_.jsx("div",{className:"block md:hidden",children:_.jsx(d,{onPressMicButton:h})}),_.jsxs("div",{className:"hidden md:block",children:[_.jsx(d,{onPressMicButton:h,className:"md:right-12"}),_.jsx(u,{onSubmitButton:O,isDisabled:N,className:"md:right-3"})]})]}):null;return _.jsxs("div",{style:{display:"flex",flexDirection:"column"},className:`${e.classNameContainer} w-full`,children:[_.jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[_.jsx("label",{...C,className:e.classNameLabel,children:s}),_.jsx("textarea",{...y,ref:A,className:`${e.classNameTextarea} p-3`,onChange:S,value:t,rows:1,style:{overflow:"hidden",outlineColor:"#a8a8a8",border:"none",outline:"none",width:"calc(100% - 30px)",resize:"none"},onKeyDown:v,onKeyUp:D})]}),ue()]})},tx=({onSubmitButton:e,isDisabled:t,className:n})=>_.jsx("div",{children:_.jsx("button",{className:`absolute
|
|
86
86
|
bg-violet-600
|
|
87
87
|
md:bottom-2
|
|
@@ -155,7 +155,7 @@ Valid keys: `+JSON.stringify(Object.keys(p),null," "));var z=Ne(ee,ae,Q,ne,W+".
|
|
|
155
155
|
md:h-[clamp(420px,70dvh,640px)]
|
|
156
156
|
md:rounded-xl
|
|
157
157
|
bg-white shadow-xl flex flex-col overflow-hidden
|
|
158
|
-
`,children:[_.jsxs("div",{className:"relative bg-violet-700 py-2 text-white text-center flex justify-center items-center",children:[_.jsx("span",{className:"font-medium",children:"Assistant"}),_.jsx(zx,{setIsWidgetOpen:e.setIsWidgetOpen})]}),_.jsx(hc,{appToken:e.appToken})]})),Yx=({isWidgetOpen:e,appToken:t,setIsWidgetOpen:n})=>{const r=k.useRef(null);return _.jsx("div",{children:_.jsx(Oa,{nodeRef:r,in:e,timeout:200,classNames:"menuTransition",unmountOnExit:!0,children:_.jsx($x,{ref:r,props:{appToken:t,setIsWidgetOpen:n}})})})},Tc=()=>({hasFetchedSettings:!1,hasDisplayedCSS:!1}),Gx=()=>{const[e,t]=k.useState(Tc());return{appInternalContext:e,setAppInternalContext:t,setHasFetchedSettings:()=>{t(i=>({...i,hasFetchedSettings:!0}))},setHasDisplayedCss:()=>{t(i=>({...i,hasDisplayedCSS:!0}))}}},xc=k.createContext({appInternalContext:Tc(),setAppInternalContext:()=>{},setHasFetchedSettings:()=>{}}),Vx=({displayMode:e,appToken:t})=>{const[n,r]=k.useState(!1),{appInternalContext:i}=k.useContext(xc);return _.jsxs(_.Fragment,{children:[e===fn.LAUNCHER&&i.hasFetchedSettings&&_.jsxs(_.Fragment,{children:[_.jsx(Uc,{isWidgetOpen:n,setIsWidgetOpen:r}),_.jsx(Yx,{isWidgetOpen:n,appToken:t,setIsWidgetOpen:r})]}),e===fn.CHATBOX&&i.hasFetchedSettings&&_.jsx("div",{className:"chatBox",children:_.jsx(hc,{appToken:t})})]})},qx=e=>Object.values(fn).includes(e),Wx=e=>qx(e)?e:(console.warn(`Display mode not valid. Using ${fn.LAUNCHER} as default.`),fn.LAUNCHER),Xx=(e,t)=>{let n,r;return typeof window<"u"&&(r=window.localStorage.getItem(ax)),r&&e?.[r]!==void 0?n=e[r]:(n=e[t],n.isDefault=!0),n},Qx=(e,t)=>{const[n,r]=k.useState(e[t]),i=a=>{Object.keys(e).includes(a?.locale)?r(a):r(e[nt.ENGLISH])};return k.useEffect(()=>{let a=Xx(e,t);a.locale!==t&&r(e[a.locale])},[]),{appCurrentLang:n,handleSetContextCurrentLang:i}},Kx=e=>Object.values(nt).includes(e),Zx=e=>Kx(e)?e:(console.log(`Language ${e} not handled for now. Using ${nt.ENGLISH}.`),nt.ENGLISH);function Jx(e,t=Date.now()){return t-e}function ey(e,t=Date.now()){return Jx(new Date(e).getTime(),t)<=Tx}function ty({settings:e,setCurrentConversation:t,setArchivedConversation:n}){const r=_x({key:fc});if(!r){t({discussionId:null,items:[{userType:"assistant",content:e.agent.text.initialText}]});return}ey(r.updatedAt)?t({discussionId:r.discussionId,items:r.items,updatedAt:r.updatedAt}):(t({discussionId:null,items:[{userType:"assistant",content:e.agent.text.initialText}]}),n({discussionId:r.discussionId,items:r.items,updatedAt:r.updatedAt}))}const ny=({agentId:e,appToken:t,onFetched:n})=>{const[r,i]=k.useState({}),a={companySettings:r,setCompanySettings:i},[s,u]=k.useState({discussionId:null,items:[],updatedAt:null}),[o,c]=k.useState({discussionId:null,items:[],updatedAt:null}),f={currentConversation:s,setCurrentConversation:u,archivedConversation:o,setArchivedConversation:c};return k.useEffect(()=>{const d=Fn.getApiUrl(),h=Fn.getFetchConfig({httpVerb:"GET",contentType:"application/json"});let m=`${d}/company/settings/${t}`;e&&(m+=`/${e}`),fetch(m,h).then(async b=>{const A=await b.json();i(A),ty({settings:A,setCurrentConversation:u,setArchivedConversation:c}),n?.()}).catch(b=>console.log("error in settings fetch",b))},[t,e]),{contextCompanySettings:a,contextInitialConversationState:f}};function ry(e,t={},n,r){const{id:i,nonce:a,target:s,disableConstructable:u}=t,o=s,c=k.useRef(null),f=k.useRef(null);k.useEffect(()=>{if(!s)return;if(!e){n&&(console.log("No custom css found."),r?.());return}if(!u&&"adoptedStyleSheets"in o&&typeof CSSStyleSheet<"u"&&"replaceSync"in CSSStyleSheet.prototype)return c.current||(c.current=new CSSStyleSheet,o.adoptedStyleSheets=[...o.adoptedStyleSheets,c.current]),c.current.replaceSync(e),console.log("Loading custom css via stylesheet."),r?.(),()=>{const h=o.adoptedStyleSheets||[],m=h.indexOf(c.current);if(m>=0){const b=h.slice();b.splice(m,1),o.adoptedStyleSheets=b}c.current=null};if(!f.current){const h=document.createElement("style");h.type="text/css",i&&(h.id=i),a&&(h.nonce=a),(o instanceof Document&&o.head||o).appendChild(h),f.current=h}return f.current.textContent=e,console.log("Loading custom css via style tag."),r?.(),()=>{f.current?.parentNode?.removeChild(f.current),f.current=null}},[e,i,a,s,u])}function iy(e){const{manifest:t,origins:n}=ay(e);n.forEach(Nc),Oc(t),Ic(t)}function ay(e){const t=sy(e),n=new Set,r=new Set,i=new Set,a=new Set;for(const{url:o,mode:c}of t)switch(uy(c,o)){case"svg":r.add(o);break;case"lottie":i.add(o);break;case"spritesheet":a.add(o);break;case"image":n.add(o);break}const s={images:Array.from(n),svgs:Array.from(r),lotties:Array.from(i),sprites:Array.from(a)},u=oy(s);return{manifest:s,origins:u}}function sy(e){if(!e?.agent?.display)return[];const t=e.agent.display,n=[t.launcher,t.assistant,t.search].filter(Boolean),r=[];for(const i of n)i?.assetUrl&&r.push({url:i.assetUrl,mode:i.mode});return r}function uy(e,t){if(e)switch(e){case"svg":return"svg";case"lottie":return"lottie";case"spritesheet":return"spritesheet";case"image":return"image";case"video":return"video"}try{const r=new URL(t,document.baseURI).pathname.toLowerCase();if(r.endsWith(".svg"))return"svg";if(r.endsWith(".lottie")||r.endsWith(".zip")||r.endsWith(".json"))return r.endsWith(".json"),"lottie";if(/\.(png|webp|jpg|jpeg|gif|avi,ef)$/.test(r))return"image";if(/\.(mp4|webm|mov|m4v|ogg)$/.test(r))return"video"}catch(n){console.log("error in normalizeKind:",n)}return"unknown"}function oy(e){const t=new Set,n=r=>{if(r)try{const i=new URL(r,document.baseURI);t.add(`${i.protocol}//${i.host}`)}catch(i){console.log("error in uniqueOriginsFromManifest",i)}};return(e.images??[]).forEach(n),(e.svgs??[]).forEach(n),(e.lotties??[]).forEach(n),(e.sprites??[]).forEach(n),Array.from(t)}const ly=({children:e,appToken:t,agentId:n,appRoot:r})=>{var i=navigator.language;console.log("Brower language",i);const a=Zx(i),{appCurrentLang:s,handleSetContextCurrentLang:u}=Qx(Ur,a),o={appCurrentLang:s,setAppCurrentLang:u},c=Gx(),{contextCompanySettings:f,contextInitialConversationState:d}=ny({agentId:n,appToken:t,onFetched:c.setHasFetchedSettings});return iy(f.companySettings),ry(f.companySettings?.agent?.display?.CSSRules,{id:`${n}`,target:r},c.appInternalContext.hasFetchedSettings,c.setHasDisplayedCss),_.jsx(_.Fragment,{children:_.jsx(fd,{locale:s?.locale,messages:s?.translatedText,children:_.jsx(lc.Provider,{value:o,children:_.jsx(xc.Provider,{value:c,children:_.jsx(dn.Provider,{value:f,children:_.jsx(dc.Provider,{value:d,children:c.appInternalContext.hasDisplayedCSS&&e})})})})})})};var fn=(e=>(e.LAUNCHER="launcher",e.CHATBOX="chatbox",e))(fn||{});function cy({appToken:e,displayMode:t="launcher",agentId:n,appRoot:r}){e||console.warn("appToken not defined in ai-client. Please see the documentation at URL_ERROR_IN_DOC");const i=Wx(t);return console.log(`App boot in ${i} mode.`),_.jsx("div",{className:"chatSystemWidget app-root",id:"chatSystemWidget",children:_.jsx(ly,{appToken:e,agentId:n,appRoot:r,children:_.jsx(Vx,{displayMode:i,appToken:e})})})}const fy=`*, ::before, ::after {
|
|
158
|
+
`,children:[_.jsxs("div",{className:"relative bg-violet-700 py-2 text-white text-center flex justify-center items-center",children:[_.jsx("span",{className:"font-medium",children:"Assistant"}),_.jsx(zx,{setIsWidgetOpen:e.setIsWidgetOpen})]}),_.jsx(hc,{appToken:e.appToken})]})),Yx=({isWidgetOpen:e,appToken:t,setIsWidgetOpen:n})=>{const r=k.useRef(null);return _.jsx("div",{children:_.jsx(Oa,{nodeRef:r,in:e,timeout:200,classNames:"menuTransition",unmountOnExit:!0,children:_.jsx($x,{ref:r,props:{appToken:t,setIsWidgetOpen:n}})})})},Tc=()=>({hasFetchedSettings:!1,hasDisplayedCSS:!1}),Gx=()=>{const[e,t]=k.useState(Tc());return{appInternalContext:e,setAppInternalContext:t,setHasFetchedSettings:()=>{t(i=>({...i,hasFetchedSettings:!0}))},setHasDisplayedCss:()=>{t(i=>({...i,hasDisplayedCSS:!0}))}}},xc=k.createContext({appInternalContext:Tc(),setAppInternalContext:()=>{},setHasFetchedSettings:()=>{}}),Vx=({displayMode:e,appToken:t})=>{const[n,r]=k.useState(!1),{appInternalContext:i}=k.useContext(xc);return _.jsxs(_.Fragment,{children:[e===fn.LAUNCHER&&i.hasFetchedSettings&&_.jsxs(_.Fragment,{children:[_.jsx(Uc,{isWidgetOpen:n,setIsWidgetOpen:r}),_.jsx(Yx,{isWidgetOpen:n,appToken:t,setIsWidgetOpen:r})]}),e===fn.CHATBOX&&i.hasFetchedSettings&&_.jsx("div",{className:"chatBox",children:_.jsx(hc,{appToken:t})})]})},qx=e=>Object.values(fn).includes(e),Wx=e=>qx(e)?e:(console.warn(`Display mode not valid. Using ${fn.LAUNCHER} as default.`),fn.LAUNCHER),Xx=(e,t)=>{let n,r;return typeof window<"u"&&(r=window.localStorage.getItem(ax)),r&&e?.[r]!==void 0?n=e[r]:(n=e[t],n.isDefault=!0),n},Qx=(e,t)=>{const[n,r]=k.useState(e[t]),i=a=>{Object.keys(e).includes(a?.locale)?r(a):r(e[nt.ENGLISH])};return k.useEffect(()=>{let a=Xx(e,t);a.locale!==t&&r(e[a.locale])},[]),{appCurrentLang:n,handleSetContextCurrentLang:i}},Kx=e=>Object.values(nt).includes(e),Zx=e=>Kx(e)?e:(console.log(`Language ${e} not handled for now. Using ${nt.ENGLISH}.`),nt.ENGLISH);function Jx(e,t=Date.now()){return t-e}function ey(e,t=Date.now()){return Jx(new Date(e).getTime(),t)<=Tx}function ty({settings:e,setCurrentConversation:t,setArchivedConversation:n}){const r=_x({key:fc});if(!r){t({discussionId:null,items:[{userType:"assistant",content:e.agent.text.initialText}]});return}ey(r.updatedAt)?t({discussionId:r.discussionId,items:r.items,updatedAt:r.updatedAt}):(t({discussionId:null,items:[{userType:"assistant",content:e.agent.text.initialText}]}),n({discussionId:r.discussionId,items:r.items,updatedAt:r.updatedAt}))}const ny=({agentId:e,appToken:t,onFetched:n})=>{const[r,i]=k.useState({}),a={companySettings:r,setCompanySettings:i},[s,u]=k.useState({discussionId:null,items:[],updatedAt:null}),[o,c]=k.useState({discussionId:null,items:[],updatedAt:null}),f={currentConversation:s,setCurrentConversation:u,archivedConversation:o,setArchivedConversation:c};return k.useEffect(()=>{const d=Fn.getApiUrl(),h=Fn.getFetchConfig({httpVerb:"GET",contentType:"application/json"});let m=`${d}/company/settings/${t}`;e&&(m+=`/${e}`),fetch(m,{...h,credentials:"omit"}).then(async b=>{const A=await b.json();i(A),ty({settings:A,setCurrentConversation:u,setArchivedConversation:c}),n?.()}).catch(b=>console.log("error in settings fetch",b))},[t,e]),{contextCompanySettings:a,contextInitialConversationState:f}};function ry(e,t={},n,r){const{id:i,nonce:a,target:s,disableConstructable:u}=t,o=s,c=k.useRef(null),f=k.useRef(null);k.useEffect(()=>{if(!s)return;if(!e){n&&(console.log("No custom css found."),r?.());return}if(!u&&"adoptedStyleSheets"in o&&typeof CSSStyleSheet<"u"&&"replaceSync"in CSSStyleSheet.prototype)return c.current||(c.current=new CSSStyleSheet,o.adoptedStyleSheets=[...o.adoptedStyleSheets,c.current]),c.current.replaceSync(e),console.log("Loading custom css via stylesheet."),r?.(),()=>{const h=o.adoptedStyleSheets||[],m=h.indexOf(c.current);if(m>=0){const b=h.slice();b.splice(m,1),o.adoptedStyleSheets=b}c.current=null};if(!f.current){const h=document.createElement("style");h.type="text/css",i&&(h.id=i),a&&(h.nonce=a),(o instanceof Document&&o.head||o).appendChild(h),f.current=h}return f.current.textContent=e,console.log("Loading custom css via style tag."),r?.(),()=>{f.current?.parentNode?.removeChild(f.current),f.current=null}},[e,i,a,s,u])}function iy(e){const{manifest:t,origins:n}=ay(e);n.forEach(Nc),Oc(t),Ic(t)}function ay(e){const t=sy(e),n=new Set,r=new Set,i=new Set,a=new Set;for(const{url:o,mode:c}of t)switch(uy(c,o)){case"svg":r.add(o);break;case"lottie":i.add(o);break;case"spritesheet":a.add(o);break;case"image":n.add(o);break}const s={images:Array.from(n),svgs:Array.from(r),lotties:Array.from(i),sprites:Array.from(a)},u=oy(s);return{manifest:s,origins:u}}function sy(e){if(!e?.agent?.display)return[];const t=e.agent.display,n=[t.launcher,t.assistant,t.search].filter(Boolean),r=[];for(const i of n)i?.assetUrl&&r.push({url:i.assetUrl,mode:i.mode});return r}function uy(e,t){if(e)switch(e){case"svg":return"svg";case"lottie":return"lottie";case"spritesheet":return"spritesheet";case"image":return"image";case"video":return"video"}try{const r=new URL(t,document.baseURI).pathname.toLowerCase();if(r.endsWith(".svg"))return"svg";if(r.endsWith(".lottie")||r.endsWith(".zip")||r.endsWith(".json"))return r.endsWith(".json"),"lottie";if(/\.(png|webp|jpg|jpeg|gif|avi,ef)$/.test(r))return"image";if(/\.(mp4|webm|mov|m4v|ogg)$/.test(r))return"video"}catch(n){console.log("error in normalizeKind:",n)}return"unknown"}function oy(e){const t=new Set,n=r=>{if(r)try{const i=new URL(r,document.baseURI);t.add(`${i.protocol}//${i.host}`)}catch(i){console.log("error in uniqueOriginsFromManifest",i)}};return(e.images??[]).forEach(n),(e.svgs??[]).forEach(n),(e.lotties??[]).forEach(n),(e.sprites??[]).forEach(n),Array.from(t)}const ly=({children:e,appToken:t,agentId:n,appRoot:r})=>{var i=navigator.language;console.log("Brower language",i);const a=Zx(i),{appCurrentLang:s,handleSetContextCurrentLang:u}=Qx(Ur,a),o={appCurrentLang:s,setAppCurrentLang:u},c=Gx(),{contextCompanySettings:f,contextInitialConversationState:d}=ny({agentId:n,appToken:t,onFetched:c.setHasFetchedSettings});return iy(f.companySettings),ry(f.companySettings?.agent?.display?.CSSRules,{id:`${n}`,target:r},c.appInternalContext.hasFetchedSettings,c.setHasDisplayedCss),_.jsx(_.Fragment,{children:_.jsx(fd,{locale:s?.locale,messages:s?.translatedText,children:_.jsx(lc.Provider,{value:o,children:_.jsx(xc.Provider,{value:c,children:_.jsx(dn.Provider,{value:f,children:_.jsx(dc.Provider,{value:d,children:c.appInternalContext.hasDisplayedCSS&&e})})})})})})};var fn=(e=>(e.LAUNCHER="launcher",e.CHATBOX="chatbox",e))(fn||{});function cy({appToken:e,displayMode:t="launcher",agentId:n,appRoot:r}){e||console.warn("appToken not defined in ai-client. Please see the documentation at URL_ERROR_IN_DOC");const i=Wx(t);return console.log(`App boot in ${i} mode.`),_.jsx("div",{className:"chatSystemWidget app-root",id:"chatSystemWidget",children:_.jsx(ly,{appToken:e,agentId:n,appRoot:r,children:_.jsx(Vx,{displayMode:i,appToken:e})})})}const fy=`*, ::before, ::after {
|
|
159
159
|
--tw-border-spacing-x: 0;
|
|
160
160
|
--tw-border-spacing-y: 0;
|
|
161
161
|
--tw-translate-x: 0;
|