@horneross/embeds 1.0.246 → 1.0.247
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/chatbox/index.js +1 -1
- package/package.json +1 -1
package/dist/chatbox/index.js
CHANGED
|
@@ -379,7 +379,7 @@ Error message: ${y0e(r)}`,cause:r}),this[A0e]=!0,this.value=t}static isInstance(
|
|
|
379
379
|
height: 100%;
|
|
380
380
|
min-height: 0;
|
|
381
381
|
}
|
|
382
|
-
`}),(0,gd.jsx)(MS,{...o,...s?{agentIconUrl:s}:{},emptyComponent:(0,gd.jsx)(ybe,{agentIconUrl:s,agentName:r?.displayName??void 0,agentDescription:r?.initialMessage??void 0,helpLinks:r?.helpLinks??void 0,primaryColor:r?.primaryColor??void 0})})]})})},xbe=qKe;c();var Np=E(W());var Ku=E(q()),wbe=(0,Np.memo)(({messages:e,delay:t=1e3,shouldAnimate:r=!0})=>{let[a,n]=(0,Np.useState)(0),[o,i]=(0,Np.useState)({});(0,Np.useEffect)(()=>{if(!r){n(e.length);return}if(e.length===0){n(0);return}n(0);let l=setTimeout(()=>{n(1)},500);return()=>clearTimeout(l)},[e,r]),(0,Np.useEffect)(()=>{if(!r||a>=e.length)return;let l=setTimeout(()=>{n(u=>Math.min(u+1,e.length))},t);return()=>clearTimeout(l)},[a,e.length,t,r]);let s=l=>{i(u=>({...u,[l]:!0}))};return(0,Ku.jsx)(G1,{spacing:2,className:"p-2",children:(0,Ku.jsx)(rr,{children:e.slice(0,a).map((l,u)=>(0,Ku.jsx)(we.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.3},children:(0,Ku.jsxs)(G1,{direction:"row",spacing:2,align:"start",children:[l.iconUrl&&(0,Ku.jsx)($u,{className:"size-8 mt-1 bg-[#E5E5E5] dark:bg-[#404040]",children:o[u]?(0,Ku.jsx)("span",{className:"text-xs font-semibold uppercase text-black dark:text-white",children:l.from==="agent"?"A":l.from?.[0]?.toUpperCase()||"H"}):(0,Ku.jsx)(Hu,{src:l.iconUrl,alt:"Agent avatar",onError:()=>s(u)})}),(0,Ku.jsx)("div",{className:V("rounded-2xl px-4 py-3 max-w-[80%] text-sm",l.from==="agent"?"bg-white dark:bg-white text-black dark:text-black border border-gray-200":"bg-primary text-white"),children:l.message})]})},u))})})});wbe.displayName="InitialMessagesRenderer";var Sbe=wbe;c();var Cbe=E(W()),GKe=e=>(0,Cbe.useReducer)((r,a)=>({...r,...a}),{...e}),kbe=GKe;c();var Tbe=E(W()),Fv=we(Tbe.default.forwardRef(function({children:t},r){return t?.({ref:r})}));c();var q9=E(q()),WKe=e=>{let{startNewChat:t,messages:r}=Ov(),{className:a,alwaysShow:n,...o}=e;return!n&&(!Array.isArray(r)||r.length<2)?null:(0,q9.jsx)("button",{onClick:()=>t(),className:Sn("p-1.5 text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-white/5 transition-colors rounded-md flex items-center justify-center",a),title:"Nuevo Chat",...o,children:(0,q9.jsx)(Wd,{className:"w-3.5 h-3.5",strokeWidth:2.5})})},RR=WKe;var qe=E(q()),YKe={theme:"light",primaryColor:"#000000",position:"right",initialMessages:[]},W2r=wl(),ZKe=e=>{let[t,r]=(0,Kn.useState)(!1),a=(0,Kn.useRef)(null);return(0,Kn.useEffect)(()=>{let n=o=>{a.current&&!a.current.contains(o.target)&&r(!1)};if(t)return document.addEventListener("mousedown",n),()=>{document.removeEventListener("mousedown",n)}},[t]),(0,Kn.useEffect)(()=>{if(t&&!e.isLoadingConversations&&(e.conversations?.length||0)===0){let n=e.visitorId||null;if(!n&&typeof window<"u"&&(n=localStorage.getItem("visitorId")),!n||!e.agentId){console.warn("[Bubble] Missing visitorId or agentId, skipping conversations load");return}e.onUpdateConversations?.({isLoadingConversations:!0});let i=`${wl()}/api/v2/agent/${e.agentId}/conversations?visitorId=${n}`;fetch(i).then(s=>s.json()).then(s=>{e.onUpdateConversations?.({conversations:s.conversations||[],isLoadingConversations:!1})}).catch(s=>{console.error("[Bubble] Failed to load conversations:",s),e.onUpdateConversations?.({conversations:[],isLoadingConversations:!1})})}},[t,e.isLoadingConversations,e.conversations?.length,e.agentId,e.onUpdateConversations]),(0,qe.jsxs)("div",{className:"relative flex flex-col w-full h-full max-h-full overflow-visible",children:[(0,qe.jsx)("div",{className:"sticky top-0 w-full z-10 bg-white dark:bg-[#171717]",children:(0,qe.jsxs)("div",{className:"flex flex-row px-2.5 py-2 items-center gap-2",children:[!e.hasMessages&&(0,qe.jsx)("span",{className:"text-sm font-semibold text-black dark:text-white px-2",children:"New chat"}),e.hasMessages&&(0,qe.jsxs)(qe.Fragment,{children:[(0,qe.jsxs)($u,{className:"h-9 w-9 bg-[#E5E5E5] dark:bg-[#404040] flex-shrink-0",children:[(0,qe.jsx)(Hu,{src:e?.imageUrl,className:"object-cover"}),(0,qe.jsx)(ip,{className:"text-sm font-semibold uppercase text-black dark:text-white",children:e.config?.displayName?.[0]||"H"})]}),(0,qe.jsxs)("div",{ref:a,className:"relative",children:[(0,qe.jsxs)("div",{role:"button",tabIndex:0,onMouseDown:n=>{n.preventDefault(),n.stopPropagation()},onClick:n=>{n.preventDefault(),n.stopPropagation(),r(!t)},onKeyDown:n=>{(n.key==="Enter"||n.key===" ")&&(n.preventDefault(),n.stopPropagation(),r(!t))},className:Sn("flex items-center gap-2 text-left h-8 px-3 rounded-lg cursor-pointer select-none","bg-gray-100 dark:bg-white/10","border border-gray-200 dark:border-white/10","hover:bg-gray-200 dark:hover:bg-white/15 transition-colors"),children:[(0,qe.jsx)("span",{className:"text-sm font-medium text-black dark:text-white truncate max-w-[160px]",children:e.config?.displayName||"Assistant"}),(0,qe.jsx)(er,{className:Sn("h-4 w-4 text-gray-500 dark:text-gray-400 flex-shrink-0 transition-transform duration-200",t&&"rotate-180"),strokeWidth:2})]}),(0,qe.jsx)(rr,{children:t&&(0,qe.jsx)(Fv,{initial:{opacity:0,y:-10,scale:.95},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-10,scale:.95},transition:{duration:.15},children:({ref:n})=>{let o=e.conversations||[],i=o.length>0;if(e.isLoadingConversations||!1)return(0,qe.jsx)("div",{ref:n,className:"absolute left-0 top-full mt-1 w-64 bg-white dark:bg-[#1a1a1a] border border-gray-200 dark:border-white/10 rounded-lg shadow-lg overflow-hidden z-50",children:(0,qe.jsx)("div",{className:"p-4 text-center",children:(0,qe.jsx)("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Cargando conversaciones..."})})});if(!i)return(0,qe.jsx)("div",{ref:n,className:"absolute left-0 top-full mt-1 w-64 bg-white dark:bg-[#1a1a1a] border border-gray-200 dark:border-white/10 rounded-lg shadow-lg overflow-hidden z-50",children:(0,qe.jsx)("div",{className:"p-4 text-center",children:(0,qe.jsx)("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:"No hay conversaciones previas"})})});let l=new Date,u=new Date(l.getFullYear(),l.getMonth(),l.getDate()),d=new Date(u);d.setDate(d.getDate()-1);let f=new Date(u);f.setDate(f.getDate()-7);let p={today:o.filter(m=>new Date(m.updatedAt)>=u),yesterday:o.filter(m=>{let g=new Date(m.updatedAt);return g>=d&&g<u}),thisWeek:o.filter(m=>{let g=new Date(m.updatedAt);return g>=f&&g<d}),older:o.filter(m=>new Date(m.updatedAt)<f)};return(0,qe.jsx)("div",{ref:n,className:"absolute left-0 top-full mt-1 w-64 bg-white dark:bg-[#1a1a1a] border border-gray-200 dark:border-white/10 rounded-lg shadow-lg overflow-hidden z-50",children:(0,qe.jsxs)("div",{className:"max-h-64 overflow-y-auto",children:[p.today.length>0&&(0,qe.jsxs)(qe.Fragment,{children:[(0,qe.jsx)("div",{className:"px-3 py-2",children:(0,qe.jsx)("p",{className:"text-[10px] font-semibold uppercase text-gray-500 dark:text-gray-400",children:"Hoy"})}),(0,qe.jsx)("div",{className:"py-1",children:p.today.map(m=>(0,qe.jsx)("button",{type:"button",onClick:g=>{g.preventDefault(),g.stopPropagation(),e.onLoadConversation?.(m.id),r(!1)},className:"w-full px-3 py-2 text-left text-xs hover:bg-gray-100 dark:hover:bg-white/5 transition-colors",children:(0,qe.jsx)("p",{className:"text-gray-900 dark:text-white truncate",children:m.title||"Nueva conversaci\xF3n"})},m.id))})]}),p.yesterday.length>0&&(0,qe.jsxs)(qe.Fragment,{children:[(0,qe.jsx)("div",{className:"px-3 py-2",children:(0,qe.jsx)("p",{className:"text-[10px] font-semibold uppercase text-gray-500 dark:text-gray-400",children:"Ayer"})}),(0,qe.jsx)("div",{className:"py-1",children:p.yesterday.map(m=>(0,qe.jsx)("button",{type:"button",onClick:g=>{g.preventDefault(),g.stopPropagation(),e.onLoadConversation?.(m.id),r(!1)},className:"w-full px-3 py-2 text-left text-xs hover:bg-gray-100 dark:hover:bg-white/5 transition-colors",children:(0,qe.jsx)("p",{className:"text-gray-900 dark:text-white truncate",children:m.title||"Nueva conversaci\xF3n"})},m.id))})]}),p.thisWeek.length>0&&(0,qe.jsxs)(qe.Fragment,{children:[(0,qe.jsx)("div",{className:"px-3 py-2",children:(0,qe.jsx)("p",{className:"text-[10px] font-semibold uppercase text-gray-500 dark:text-gray-400",children:"Esta semana"})}),(0,qe.jsx)("div",{className:"py-1",children:p.thisWeek.map(m=>(0,qe.jsx)("button",{type:"button",onClick:g=>{g.preventDefault(),g.stopPropagation(),e.onLoadConversation?.(m.id),r(!1)},className:"w-full px-3 py-2 text-left text-xs hover:bg-gray-100 dark:hover:bg-white/5 transition-colors",children:(0,qe.jsx)("p",{className:"text-gray-900 dark:text-white truncate",children:m.title||"Nueva conversaci\xF3n"})},m.id))})]}),p.older.length>0&&(0,qe.jsxs)(qe.Fragment,{children:[(0,qe.jsx)("div",{className:"px-3 py-2",children:(0,qe.jsx)("p",{className:"text-[10px] font-semibold uppercase text-gray-500 dark:text-gray-400",children:"M\xE1s antiguas"})}),(0,qe.jsx)("div",{className:"py-1",children:p.older.map(m=>(0,qe.jsx)("button",{type:"button",onClick:g=>{g.preventDefault(),g.stopPropagation(),e.onLoadConversation?.(m.id),r(!1)},className:"w-full px-3 py-2 text-left text-xs hover:bg-gray-100 dark:hover:bg-white/5 transition-colors",children:(0,qe.jsx)("p",{className:"text-gray-900 dark:text-white truncate",children:m.title||"Nueva conversaci\xF3n"})},m.id))})]})]})})}})})]})]}),(0,qe.jsx)("div",{className:"flex-1 min-w-0"}),(0,qe.jsxs)("div",{className:"flex flex-row items-center gap-1",children:[e.hasMessages&&(0,qe.jsx)(RR,{alwaysShow:!0}),e.handleClose&&(0,qe.jsx)("button",{type:"button",onClick:e.handleClose,className:"p-1.5 hover:bg-gray-100 dark:hover:bg-white/5 rounded-md text-gray-700 dark:text-gray-300 transition-colors flex items-center justify-center",title:"Minimizar",children:(0,qe.jsx)(Bh,{className:"h-3.5 w-3.5",strokeWidth:2.5})})]})]})}),(0,qe.jsx)("div",{className:"flex-1 flex flex-col overflow-hidden relative",children:e.children})]})},KKe=({...e})=>{let t=e.interfaceConfig||YKe,r=e?.interfaceConfig?.iconUrl||e?.agentIconUrl||"/images/chatbubble-default-icon.png",a=(0,Kn.useRef)(null),[n,o]=kbe({isOpen:!!e.isOpen,hasOpenOnce:!1,showInitialMessage:!1,visitorEmail:"",showLeadFormAfterMessageId:"",conversations:[],isLoadingConversations:!1});(0,Kn.useEffect)(()=>{o({isOpen:!!e.isOpen})},[e.isOpen]);let i=(0,Kn.useMemo)(()=>(t.initialMessages||[]).map(p=>p?.trim?.()).filter(p=>!!p),[t?.initialMessages]);(0,Kn.useEffect)(()=>{let f=null;return i?.length>0&&!t?.isInitMessagePopupDisabled&&(f=setTimeout(()=>{o({showInitialMessage:!0})},5e3)),()=>{f&&clearTimeout(f)}},[i?.length,t?.isInitMessagePopupDisabled]);let s=(0,Kn.useCallback)(()=>{o({isOpen:!1})},[]),l=(0,Kn.useMemo)(()=>(0,qe.jsxs)($u,{className:"w-full h-full bg-transparent",style:t?.bubbleIconStyle,children:[(0,qe.jsx)(Hu,{src:r}),(0,qe.jsx)(ip,{className:"text-sm font-semibold uppercase",children:t?.displayName?.[0]||"H"})]}),[r,t?.bubbleIconStyle,t?.displayName]),u=(0,Kn.useCallback)(f=>{o(f)},[o]),d=Kn.default.useMemo(()=>f=>(0,qe.jsx)(ZKe,{...f,handleClose:s,imageUrl:r,config:t,agentId:e.agentId,conversations:n.conversations,isLoadingConversations:n.isLoadingConversations,onUpdateConversations:u,visitorId:e.visitorId,onLoadConversation:e.onLoadConversation}),[t,r,s,e.agentId,n.conversations,n.isLoadingConversations,u,e.visitorId,e.onLoadConversation]);return e?.isLoadingAgent?null:(0,qe.jsxs)(qe.Fragment,{children:[i?.length>0&&n.showInitialMessage&&!n.hasOpenOnce&&(0,qe.jsxs)("div",{ref:a,className:Sn("horneross-init-messages fixed bottom-[72px] flex flex-col gap-2 max-w-[90%] sm:max-w-[500px]",t?.position==="left"?"left-4":"right-4"),style:{zIndex:9999999999-1},children:[(0,qe.jsx)(Rr,{variant:"outline",size:"sm",className:Sn("absolute z-[2] -top-2 p-1 min-w-0 h-auto rounded-full -translate-y-full","bg-white dark:bg-[#171717]","border-gray-300 dark:border-white/20","hover:bg-gray-100 dark:hover:bg-white/10","text-black dark:text-white",t?.position==="left"&&"right-0",t?.position==="right"&&"right-0"),onClick:()=>o({showInitialMessage:!1}),children:(0,qe.jsx)(ua,{className:"h-3 w-3"})}),(0,qe.jsx)(Sbe,{messages:i.map(f=>({iconUrl:r,from:"agent",message:f,approvals:[]}))})]}),(0,qe.jsx)(Fv,{initial:{opacity:0,scale:.95,y:10},animate:{opacity:n.isOpen?1:0,scale:n.isOpen?1:.95,y:n.isOpen?0:10},exit:{opacity:0,scale:.95,y:10},transition:{duration:.2,ease:[.4,0,.2,1]},children:({ref:f})=>(0,qe.jsx)(d2,{ref:f,className:Sn("fixed bottom-[72px] flex-col box-border p-0 gap-0 rounded-2xl overflow-hidden","border border-gray-300 dark:border-white/20","bg-white dark:bg-[#171717]",n.isOpen?"flex":"hidden",!n.isOpen&&"pointer-events-none",t?.position==="left"?"left-4":"right-4","w-[380px] h-[560px] max-h-[560px]","max-[640px]:w-screen max-[640px]:h-screen max-[640px]:max-h-screen max-[640px]:max-w-screen max-[640px]:left-0 max-[640px]:top-0 max-[640px]:bottom-0 max-[640px]:right-0 max-[640px]:rounded-none max-[640px]:border-0"),style:{zIndex:9999999999},children:(0,qe.jsx)("div",{className:"relative flex flex-col h-full w-full flex-1 p-0 overflow-hidden",children:(0,qe.jsx)(xbe,{...e,chatBoxProps:{...e.chatBoxProps,isOpen:n.isOpen},agentIconUrl:r,interfaceConfig:t,layout:d})})})}),(0,qe.jsx)("div",{className:Sn("horneross-widget fixed h-[48px] bottom-4",t?.position==="left"?"left-4":"right-4"),style:{zIndex:9999999999},children:(0,qe.jsx)(Fv,{initial:"visible",animate:"visible",variants:{visible:{y:0,opacity:1,scale:1,transition:{when:"beforeChildren",staggerChildren:.3}},hidden:{y:100,opacity:0,scale:.8,transition:{when:"afterChildren"}}},children:({ref:f})=>(0,qe.jsx)(Rr,{ref:f,variant:"default",className:Sn("horneross-launcher relative flex shrink-0 w-[48px] h-[48px] rounded-full p-0 overflow-hidden","transition-all duration-300 ease-out","hover:opacity-90","active:scale-95"),style:{backgroundColor:t?.primaryColor||"#000000",...t?.bubbleButtonStyle},onClick:()=>o({isOpen:!n.isOpen,...n.isOpen?{}:{hasOpenOnce:!0}}),children:(0,qe.jsxs)(rr,{mode:"wait",children:[n.isOpen&&(0,qe.jsx)(Fv,{initial:{rotate:-180,opacity:0},animate:{rotate:0,opacity:1},exit:{rotate:180,opacity:0},transition:{duration:.3},children:({ref:p})=>(0,qe.jsx)(Bh,{ref:p,className:"h-5 w-5"})},"close-icon"),!n.isOpen&&(0,qe.jsx)(Fv,{initial:{rotate:180,opacity:0},animate:{rotate:0,opacity:1},exit:{rotate:-180,opacity:0},transition:{duration:.3},children:({ref:p})=>(0,qe.jsx)("div",{ref:p,className:"w-[48px] h-[48px] flex items-center justify-center",children:l})},"bubble-icon")]})})})})]})},Ebe=KKe;c();var im=E(W()),e1e=E(Qwe());c();var Od=E(q()),CQe={"phone-number":"phoneNumber","user-id":"userId","first-name":"firstName","last-name":"lastName",email:"email","visitor-id":"visitorId"},kQe="https://cdn.jsdelivr.net/npm/@horneross/embeds@latest",TQe=({children:e,container:t})=>((0,im.useEffect)(()=>{let r=()=>{document.documentElement.classList.contains("dark")?t.classList.add("dark"):t.classList.remove("dark")};r();let a=new MutationObserver(r);return a.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>a.disconnect()},[t]),(0,Od.jsx)(Od.Fragment,{children:e})),EQe=({name:e,widget:t,type:r})=>class extends HTMLElement{cssProvider=kQe+`/dist/${r}/index.css`;root;shadowRootElement;instanceId;setIsOpen;isOpen;onEnd;destroy(){this.innerHTML="",this.instanceId&&(window[this.instanceId]=null)}constructor(n){super(),this.instanceId=n?.instanceId,this.onEnd=n?.onEnd;let o=this.attachShadow({mode:"open"}),i=document.createElement("link");i.setAttribute("rel","preconnect"),i.setAttribute("href","https://fonts.googleapis.com");let s=document.createElement("link");s.setAttribute("rel","preconnect"),s.setAttribute("href","https://fonts.gstatic.com"),s.setAttribute("crossorigin","");let l=document.createElement("link");l.setAttribute("rel","stylesheet"),l.setAttribute("type","text/css"),l.setAttribute("href","https://fonts.googleapis.com/css2?family=Roboto+Flex:opsz,wght@8..144,100..1000&display=swap");let u=document.createElement("link");u.setAttribute("rel","stylesheet"),u.setAttribute("type","text/css"),u.setAttribute("href",this.cssProvider),this.shadowRootElement=document.createElement("div"),this.shadowRootElement.className="light",o.appendChild(i),o.appendChild(s),o.appendChild(l),o.appendChild(u),o.appendChild(this.shadowRootElement),this.root=(0,e1e.createRoot)(this.shadowRootElement)}open(){this.setIsOpen?.(!0)}close(){this.setIsOpen?.(!1)}toggle(){this.setIsOpen?.(!this.isOpen)}createNewConversation(){this.dispatchEvent(new Event("CREATE_NEW_CONVERSATION",{bubbles:!0,composed:!0}))}updateConfig(n){n&&this.setAttribute("interface",JSON.stringify(n)),this.root.render((0,Od.jsx)(this.Component,{isOpen:this.isOpen,onEnd:this.onEnd}))}Component=n=>{let[o,i]=(0,im.useState)(!1);this.setIsOpen=i,this.isOpen=o;let s=Object.entries(CQe).reduce((f,[p,m])=>{let g=this.getAttribute(p);return g&&p!=="visitor-id"&&(f[m]=g),f},{}),l=this.getAttribute("visitor-id")||void 0,u=this.getAttribute("context"),d={};try{d=JSON.parse(this.getAttribute("interface"))}catch{}return(0,Od.jsx)(im.StrictMode,{children:(0,Od.jsx)(TQe,{container:this.shadowRootElement,children:(0,Od.jsx)("div",{className:"bg-transparent",children:im.default.createElement(t,{...n,isOpen:o,onEnd:this.onEnd,initConfig:d,context:u,agentId:this.getAttribute("agent-id")||"",formId:this.getAttribute("form-id")||"",contact:s,visitorId:l,styles:this.getAttribute("styles")?JSON.parse(this.getAttribute("styles")):{},onAgentLoaded:f=>{let p=f?.interfaceConfig?.customCSS;if(p){let m=document.createElement("style");m.innerHTML=p,this.shadowRootElement.appendChild(m)}}})})})})};connectedCallback(){this.root.render((0,Od.jsx)(this.Component,{isOpen:this.isOpen,onEnd:this.onEnd}))}},oN=EQe;var n1e=E(q()),t1e="horneross-chatbox-bubble",r1e=oN({type:"chatbox",widget:e=>(0,n1e.jsx)(AR,{...e,className:Sn("horneross-widget",e.className),children:Ebe}),name:t1e});customElements.define(t1e,r1e);var a1e=r1e;var IQe=async e=>{if(typeof window<"u"&&!window?.ChatboxBubble){let t=document?.currentScript?.src,r=document?.currentScript?.id,a=e.agentId||r;!a&&t&&(a=new URL(t).searchParams.get("agentId")||r||e.agentId),FC(e);let n=new a1e({instanceId:"ChatBoxBubble"});zC({element:n,...e}),window.ChatboxBubble=n,document?.body?.prepend(n)}return window?.ChatboxBubble},o1e=IQe;c();c();c();var hl=E(q()),_Qe="https://app.horneross.com/images/chatbubble-default-horneross.svg",AQe=e=>{let{query:t}=Hy({id:e.agentId});return(0,hl.jsxs)("div",{className:Sn("relative w-full h-full flex flex-col",e.className),children:[(0,hl.jsx)("div",{className:"flex-shrink-0 px-2 pt-2 pb-2",children:(0,hl.jsxs)("div",{className:"px-2 py-1 flex items-center border border-gray-700 max-w-[700px] mx-auto bg-[#161618] rounded-lg",children:[(0,hl.jsx)("div",{className:"w-8 h-8 mr-2 rounded-full border border-gray-600 flex items-center justify-center overflow-hidden",children:t?.data?.iconUrl?(0,hl.jsx)("img",{src:t?.data?.iconUrl||_Qe,alt:"Agent",className:"w-full h-full object-cover"}):(0,hl.jsx)(lc,{className:"w-4 h-4 text-gray-400"})}),(0,hl.jsx)("h3",{className:"text-white font-medium text-lg font-['Bricolage_Grotesque']",children:e?.config?.displayName||t?.data?.name}),(0,hl.jsx)("div",{className:"ml-auto flex items-center",children:(0,hl.jsx)(RR,{variant:"plain"})})]})}),(0,hl.jsx)("div",{className:"flex-1 flex flex-col min-h-0",children:e.children})]})},i1e=AQe;var s1e=E(q()),hh="horneross-chatbox-standard",RQe=oN({type:"chatbox",widget:e=>(0,s1e.jsx)(AR,{layout:i1e,...e,className:Sn("horneross-widget",e.className)}),name:hh}),TH=RQe;var PQe=e=>{customElements.get(hh)||customElements.define(hh,TH),FC(e);let t="ChatBoxStandard_"+(e.id||""),r=new TH({instanceId:t}),a=e.id?document.querySelector(`${hh}[id="${e.id}"]`):document.querySelector(hh);if(!a)throw new Error(`<${hh}> element${`${e.id?` with ID ${e.id}`:""}`} not found.`);if(!window[t]){let n={...e.styles,...Array.from(a.style).reduce((o,i)=>(o[i]=a?.style.getPropertyValue(i),o),{})};zC({element:r,...e,styles:n}),window[t]=r,a.replaceWith(r)}return window[t]},l1e=PQe;var NQe={initBubble:o1e,initStandard:l1e},XAr=NQe;export{XAr as default};
|
|
382
|
+
`}),(0,gd.jsx)(MS,{...o,...s?{agentIconUrl:s}:{},emptyComponent:(0,gd.jsx)(ybe,{agentIconUrl:s,agentName:r?.displayName??void 0,agentDescription:r?.initialMessage??void 0,helpLinks:r?.helpLinks??void 0,primaryColor:r?.primaryColor??void 0})})]})})},xbe=qKe;c();var Np=E(W());var Ku=E(q()),wbe=(0,Np.memo)(({messages:e,delay:t=1e3,shouldAnimate:r=!0})=>{let[a,n]=(0,Np.useState)(0),[o,i]=(0,Np.useState)({});(0,Np.useEffect)(()=>{if(!r){n(e.length);return}if(e.length===0){n(0);return}n(0);let l=setTimeout(()=>{n(1)},500);return()=>clearTimeout(l)},[e,r]),(0,Np.useEffect)(()=>{if(!r||a>=e.length)return;let l=setTimeout(()=>{n(u=>Math.min(u+1,e.length))},t);return()=>clearTimeout(l)},[a,e.length,t,r]);let s=l=>{i(u=>({...u,[l]:!0}))};return(0,Ku.jsx)(G1,{spacing:2,className:"p-2",children:(0,Ku.jsx)(rr,{children:e.slice(0,a).map((l,u)=>(0,Ku.jsx)(we.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.3},children:(0,Ku.jsxs)(G1,{direction:"row",spacing:2,align:"start",children:[l.iconUrl&&(0,Ku.jsx)($u,{className:"size-8 mt-1 bg-[#E5E5E5] dark:bg-[#404040]",children:o[u]?(0,Ku.jsx)("span",{className:"text-xs font-semibold uppercase text-black dark:text-white",children:l.from==="agent"?"A":l.from?.[0]?.toUpperCase()||"H"}):(0,Ku.jsx)(Hu,{src:l.iconUrl,alt:"Agent avatar",onError:()=>s(u)})}),(0,Ku.jsx)("div",{className:V("rounded-2xl px-4 py-3 max-w-[80%] text-sm",l.from==="agent"?"bg-white dark:bg-white text-black dark:text-black border border-gray-200":"bg-primary text-white"),children:l.message})]})},u))})})});wbe.displayName="InitialMessagesRenderer";var Sbe=wbe;c();var Cbe=E(W()),GKe=e=>(0,Cbe.useReducer)((r,a)=>({...r,...a}),{...e}),kbe=GKe;c();var Tbe=E(W()),Fv=we(Tbe.default.forwardRef(function({children:t},r){return t?.({ref:r})}));c();var q9=E(q()),WKe=e=>{let{startNewChat:t,messages:r}=Ov(),{className:a,alwaysShow:n,...o}=e;return!n&&(!Array.isArray(r)||r.length<2)?null:(0,q9.jsx)("button",{onClick:()=>t(),className:Sn("p-1.5 text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-white/5 transition-colors rounded-md flex items-center justify-center",a),title:"Nuevo Chat",...o,children:(0,q9.jsx)(Wd,{className:"w-3.5 h-3.5",strokeWidth:2.5})})},RR=WKe;var qe=E(q()),YKe={theme:"light",primaryColor:"#000000",position:"right",initialMessages:[]},W2r=wl(),ZKe=e=>{let[t,r]=(0,Kn.useState)(!1),a=(0,Kn.useRef)(null);return(0,Kn.useEffect)(()=>{let n=o=>{a.current&&!a.current.contains(o.target)&&r(!1)};if(t)return document.addEventListener("mousedown",n),()=>{document.removeEventListener("mousedown",n)}},[t]),(0,Kn.useEffect)(()=>{if(t&&!e.isLoadingConversations&&(e.conversations?.length||0)===0){let n=e.visitorId||null;if(!n&&typeof window<"u"&&(n=localStorage.getItem("visitorId")),!n||!e.agentId){console.warn("[Bubble] Missing visitorId or agentId, skipping conversations load");return}e.onUpdateConversations?.({isLoadingConversations:!0});let i=`${wl()}/api/v2/agent/${e.agentId}/conversations?visitorId=${n}`;fetch(i).then(s=>s.json()).then(s=>{e.onUpdateConversations?.({conversations:s.conversations||[],isLoadingConversations:!1})}).catch(s=>{console.error("[Bubble] Failed to load conversations:",s),e.onUpdateConversations?.({conversations:[],isLoadingConversations:!1})})}},[t,e.isLoadingConversations,e.conversations?.length,e.agentId,e.onUpdateConversations]),(0,qe.jsxs)("div",{className:"relative flex flex-col w-full h-full max-h-full overflow-visible",children:[(0,qe.jsx)("div",{className:"sticky top-0 w-full z-10 bg-white dark:bg-[#171717]",children:(0,qe.jsxs)("div",{className:"flex flex-row px-2.5 py-2 items-center gap-2",children:[!e.hasMessages&&(0,qe.jsx)("span",{className:"text-sm font-semibold text-black dark:text-white px-2",children:"New chat"}),e.hasMessages&&(0,qe.jsxs)(qe.Fragment,{children:[(0,qe.jsxs)($u,{className:"h-9 w-9 bg-[#E5E5E5] dark:bg-[#404040] flex-shrink-0",children:[(0,qe.jsx)(Hu,{src:e?.imageUrl,className:"object-cover"}),(0,qe.jsx)(ip,{className:"text-sm font-semibold uppercase text-black dark:text-white",children:e.config?.displayName?.[0]||"H"})]}),(0,qe.jsxs)("div",{ref:a,className:"relative",children:[(0,qe.jsxs)("div",{role:"button",tabIndex:0,onMouseDown:n=>{n.preventDefault(),n.stopPropagation()},onClick:n=>{n.preventDefault(),n.stopPropagation(),r(!t)},onKeyDown:n=>{(n.key==="Enter"||n.key===" ")&&(n.preventDefault(),n.stopPropagation(),r(!t))},className:Sn("flex items-center gap-2 text-left h-8 px-3 rounded-lg cursor-pointer select-none","bg-gray-100 dark:bg-white/10","border border-gray-200 dark:border-white/10","hover:bg-gray-200 dark:hover:bg-white/15 transition-colors"),children:[(0,qe.jsx)("span",{className:"text-sm font-medium text-black dark:text-white truncate max-w-[160px]",children:e.config?.displayName||"Assistant"}),(0,qe.jsx)(er,{className:Sn("h-4 w-4 text-gray-500 dark:text-gray-400 flex-shrink-0 transition-transform duration-200",t&&"rotate-180"),strokeWidth:2})]}),(0,qe.jsx)(rr,{children:t&&(0,qe.jsx)(Fv,{initial:{opacity:0,y:-10,scale:.95},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-10,scale:.95},transition:{duration:.15},children:({ref:n})=>{let o=e.conversations||[],i=o.length>0;if(e.isLoadingConversations||!1)return(0,qe.jsx)("div",{ref:n,className:"absolute left-0 top-full mt-1 w-64 bg-white dark:bg-[#1a1a1a] border border-gray-200 dark:border-white/10 rounded-lg shadow-lg overflow-hidden z-50",children:(0,qe.jsx)("div",{className:"p-4 text-center",children:(0,qe.jsx)("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Cargando conversaciones..."})})});if(!i)return(0,qe.jsx)("div",{ref:n,className:"absolute left-0 top-full mt-1 w-64 bg-white dark:bg-[#1a1a1a] border border-gray-200 dark:border-white/10 rounded-lg shadow-lg overflow-hidden z-50",children:(0,qe.jsx)("div",{className:"p-4 text-center",children:(0,qe.jsx)("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:"No hay conversaciones previas"})})});let l=new Date,u=new Date(l.getFullYear(),l.getMonth(),l.getDate()),d=new Date(u);d.setDate(d.getDate()-1);let f=new Date(u);f.setDate(f.getDate()-7);let p={today:o.filter(m=>new Date(m.updatedAt)>=u),yesterday:o.filter(m=>{let g=new Date(m.updatedAt);return g>=d&&g<u}),thisWeek:o.filter(m=>{let g=new Date(m.updatedAt);return g>=f&&g<d}),older:o.filter(m=>new Date(m.updatedAt)<f)};return(0,qe.jsx)("div",{ref:n,className:"absolute left-0 top-full mt-1 w-64 bg-white dark:bg-[#1a1a1a] border border-gray-200 dark:border-white/10 rounded-lg shadow-lg overflow-hidden z-50",children:(0,qe.jsxs)("div",{className:"max-h-64 overflow-y-auto",children:[p.today.length>0&&(0,qe.jsxs)(qe.Fragment,{children:[(0,qe.jsx)("div",{className:"px-3 py-2",children:(0,qe.jsx)("p",{className:"text-[10px] font-semibold uppercase text-gray-500 dark:text-gray-400",children:"Hoy"})}),(0,qe.jsx)("div",{className:"py-1",children:p.today.map(m=>(0,qe.jsx)("button",{type:"button",onClick:g=>{g.preventDefault(),g.stopPropagation(),e.onLoadConversation?.(m.id),r(!1)},className:"w-full px-3 py-2 text-left text-xs hover:bg-gray-100 dark:hover:bg-white/5 transition-colors",children:(0,qe.jsx)("p",{className:"text-gray-900 dark:text-white truncate",children:m.title||"Nueva conversaci\xF3n"})},m.id))})]}),p.yesterday.length>0&&(0,qe.jsxs)(qe.Fragment,{children:[(0,qe.jsx)("div",{className:"px-3 py-2",children:(0,qe.jsx)("p",{className:"text-[10px] font-semibold uppercase text-gray-500 dark:text-gray-400",children:"Ayer"})}),(0,qe.jsx)("div",{className:"py-1",children:p.yesterday.map(m=>(0,qe.jsx)("button",{type:"button",onClick:g=>{g.preventDefault(),g.stopPropagation(),e.onLoadConversation?.(m.id),r(!1)},className:"w-full px-3 py-2 text-left text-xs hover:bg-gray-100 dark:hover:bg-white/5 transition-colors",children:(0,qe.jsx)("p",{className:"text-gray-900 dark:text-white truncate",children:m.title||"Nueva conversaci\xF3n"})},m.id))})]}),p.thisWeek.length>0&&(0,qe.jsxs)(qe.Fragment,{children:[(0,qe.jsx)("div",{className:"px-3 py-2",children:(0,qe.jsx)("p",{className:"text-[10px] font-semibold uppercase text-gray-500 dark:text-gray-400",children:"Esta semana"})}),(0,qe.jsx)("div",{className:"py-1",children:p.thisWeek.map(m=>(0,qe.jsx)("button",{type:"button",onClick:g=>{g.preventDefault(),g.stopPropagation(),e.onLoadConversation?.(m.id),r(!1)},className:"w-full px-3 py-2 text-left text-xs hover:bg-gray-100 dark:hover:bg-white/5 transition-colors",children:(0,qe.jsx)("p",{className:"text-gray-900 dark:text-white truncate",children:m.title||"Nueva conversaci\xF3n"})},m.id))})]}),p.older.length>0&&(0,qe.jsxs)(qe.Fragment,{children:[(0,qe.jsx)("div",{className:"px-3 py-2",children:(0,qe.jsx)("p",{className:"text-[10px] font-semibold uppercase text-gray-500 dark:text-gray-400",children:"M\xE1s antiguas"})}),(0,qe.jsx)("div",{className:"py-1",children:p.older.map(m=>(0,qe.jsx)("button",{type:"button",onClick:g=>{g.preventDefault(),g.stopPropagation(),e.onLoadConversation?.(m.id),r(!1)},className:"w-full px-3 py-2 text-left text-xs hover:bg-gray-100 dark:hover:bg-white/5 transition-colors",children:(0,qe.jsx)("p",{className:"text-gray-900 dark:text-white truncate",children:m.title||"Nueva conversaci\xF3n"})},m.id))})]})]})})}})})]})]}),(0,qe.jsx)("div",{className:"flex-1 min-w-0"}),(0,qe.jsxs)("div",{className:"flex flex-row items-center gap-1",children:[e.hasMessages&&(0,qe.jsx)(RR,{alwaysShow:!0}),e.handleClose&&(0,qe.jsx)("button",{type:"button",onClick:e.handleClose,className:"p-1.5 hover:bg-gray-100 dark:hover:bg-white/5 rounded-md text-gray-700 dark:text-gray-300 transition-colors flex items-center justify-center",title:"Minimizar",children:(0,qe.jsx)(Bh,{className:"h-3.5 w-3.5",strokeWidth:2.5})})]})]})}),(0,qe.jsx)("div",{className:"flex-1 flex flex-col overflow-hidden relative",children:e.children})]})},KKe=({...e})=>{let t=e.interfaceConfig||YKe,r=e?.interfaceConfig?.iconUrl||e?.agentIconUrl||"/images/chatbubble-default-icon.png",a=(0,Kn.useRef)(null),[n,o]=kbe({isOpen:!!e.isOpen,hasOpenOnce:!1,showInitialMessage:!1,visitorEmail:"",showLeadFormAfterMessageId:"",conversations:[],isLoadingConversations:!1});(0,Kn.useEffect)(()=>{o({isOpen:!!e.isOpen})},[e.isOpen]);let i=(0,Kn.useMemo)(()=>(t.initialMessages||[]).map(p=>p?.trim?.()).filter(p=>!!p),[t?.initialMessages]);(0,Kn.useEffect)(()=>{let f=null;return i?.length>0&&!t?.isInitMessagePopupDisabled&&(f=setTimeout(()=>{o({showInitialMessage:!0})},5e3)),()=>{f&&clearTimeout(f)}},[i?.length,t?.isInitMessagePopupDisabled]);let s=(0,Kn.useCallback)(()=>{o({isOpen:!1})},[]),l=(0,Kn.useMemo)(()=>(0,qe.jsxs)($u,{className:"w-[48px] h-[48px] bg-transparent",style:t?.bubbleIconStyle,children:[(0,qe.jsx)(Hu,{src:r}),(0,qe.jsx)(ip,{className:"text-sm font-semibold uppercase",children:t?.displayName?.[0]||"H"})]}),[r,t?.bubbleIconStyle,t?.displayName]),u=(0,Kn.useCallback)(f=>{o(f)},[o]),d=Kn.default.useMemo(()=>f=>(0,qe.jsx)(ZKe,{...f,handleClose:s,imageUrl:r,config:t,agentId:e.agentId,conversations:n.conversations,isLoadingConversations:n.isLoadingConversations,onUpdateConversations:u,visitorId:e.visitorId,onLoadConversation:e.onLoadConversation}),[t,r,s,e.agentId,n.conversations,n.isLoadingConversations,u,e.visitorId,e.onLoadConversation]);return e?.isLoadingAgent?null:(0,qe.jsxs)(qe.Fragment,{children:[i?.length>0&&n.showInitialMessage&&!n.hasOpenOnce&&(0,qe.jsxs)("div",{ref:a,className:Sn("horneross-init-messages fixed bottom-[72px] flex flex-col gap-2 max-w-[90%] sm:max-w-[500px]",t?.position==="left"?"left-4":"right-4"),style:{zIndex:9999999999-1},children:[(0,qe.jsx)(Rr,{variant:"outline",size:"sm",className:Sn("absolute z-[2] -top-2 p-1 min-w-0 h-auto rounded-full -translate-y-full","bg-white dark:bg-[#171717]","border-gray-300 dark:border-white/20","hover:bg-gray-100 dark:hover:bg-white/10","text-black dark:text-white",t?.position==="left"&&"right-0",t?.position==="right"&&"right-0"),onClick:()=>o({showInitialMessage:!1}),children:(0,qe.jsx)(ua,{className:"h-3 w-3"})}),(0,qe.jsx)(Sbe,{messages:i.map(f=>({iconUrl:r,from:"agent",message:f,approvals:[]}))})]}),(0,qe.jsx)(Fv,{initial:{opacity:0,scale:.95,y:10},animate:{opacity:n.isOpen?1:0,scale:n.isOpen?1:.95,y:n.isOpen?0:10},exit:{opacity:0,scale:.95,y:10},transition:{duration:.2,ease:[.4,0,.2,1]},children:({ref:f})=>(0,qe.jsx)(d2,{ref:f,className:Sn("fixed bottom-[72px] flex-col box-border p-0 gap-0 rounded-2xl overflow-hidden","border border-gray-300 dark:border-white/20","bg-white dark:bg-[#171717]",n.isOpen?"flex":"hidden",!n.isOpen&&"pointer-events-none",t?.position==="left"?"left-4":"right-4","w-[380px] h-[560px] max-h-[560px]","max-[640px]:w-screen max-[640px]:h-screen max-[640px]:max-h-screen max-[640px]:max-w-screen max-[640px]:left-0 max-[640px]:top-0 max-[640px]:bottom-0 max-[640px]:right-0 max-[640px]:rounded-none max-[640px]:border-0"),style:{zIndex:9999999999},children:(0,qe.jsx)("div",{className:"relative flex flex-col h-full w-full flex-1 p-0 overflow-hidden",children:(0,qe.jsx)(xbe,{...e,chatBoxProps:{...e.chatBoxProps,isOpen:n.isOpen},agentIconUrl:r,interfaceConfig:t,layout:d})})})}),(0,qe.jsx)("div",{className:Sn("horneross-widget fixed h-[48px] bottom-4",t?.position==="left"?"left-4":"right-4"),style:{zIndex:9999999999},children:(0,qe.jsx)(Fv,{initial:"visible",animate:"visible",variants:{visible:{y:0,opacity:1,scale:1,transition:{when:"beforeChildren",staggerChildren:.3}},hidden:{y:100,opacity:0,scale:.8,transition:{when:"afterChildren"}}},children:({ref:f})=>(0,qe.jsx)(Rr,{ref:f,variant:"default",className:Sn("horneross-launcher relative flex shrink-0 w-[48px] h-[48px] rounded-full p-0 overflow-hidden","transition-all duration-300 ease-out","hover:opacity-90","active:scale-95"),style:{backgroundColor:t?.primaryColor||"#000000",...t?.bubbleButtonStyle},onClick:()=>o({isOpen:!n.isOpen,...n.isOpen?{}:{hasOpenOnce:!0}}),children:(0,qe.jsxs)(rr,{mode:"wait",children:[n.isOpen&&(0,qe.jsx)(Fv,{initial:{rotate:-180,opacity:0},animate:{rotate:0,opacity:1},exit:{rotate:180,opacity:0},transition:{duration:.3},children:({ref:p})=>(0,qe.jsx)(Bh,{ref:p,className:"h-5 w-5"})},"close-icon"),!n.isOpen&&(0,qe.jsx)(Fv,{initial:{rotate:180,opacity:0},animate:{rotate:0,opacity:1},exit:{rotate:-180,opacity:0},transition:{duration:.3},children:({ref:p})=>(0,qe.jsx)("div",{ref:p,className:"flex items-center justify-center",children:l})},"bubble-icon")]})})})})]})},Ebe=KKe;c();var im=E(W()),e1e=E(Qwe());c();var Od=E(q()),CQe={"phone-number":"phoneNumber","user-id":"userId","first-name":"firstName","last-name":"lastName",email:"email","visitor-id":"visitorId"},kQe="https://cdn.jsdelivr.net/npm/@horneross/embeds@latest",TQe=({children:e,container:t})=>((0,im.useEffect)(()=>{let r=()=>{document.documentElement.classList.contains("dark")?t.classList.add("dark"):t.classList.remove("dark")};r();let a=new MutationObserver(r);return a.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>a.disconnect()},[t]),(0,Od.jsx)(Od.Fragment,{children:e})),EQe=({name:e,widget:t,type:r})=>class extends HTMLElement{cssProvider=kQe+`/dist/${r}/index.css`;root;shadowRootElement;instanceId;setIsOpen;isOpen;onEnd;destroy(){this.innerHTML="",this.instanceId&&(window[this.instanceId]=null)}constructor(n){super(),this.instanceId=n?.instanceId,this.onEnd=n?.onEnd;let o=this.attachShadow({mode:"open"}),i=document.createElement("link");i.setAttribute("rel","preconnect"),i.setAttribute("href","https://fonts.googleapis.com");let s=document.createElement("link");s.setAttribute("rel","preconnect"),s.setAttribute("href","https://fonts.gstatic.com"),s.setAttribute("crossorigin","");let l=document.createElement("link");l.setAttribute("rel","stylesheet"),l.setAttribute("type","text/css"),l.setAttribute("href","https://fonts.googleapis.com/css2?family=Roboto+Flex:opsz,wght@8..144,100..1000&display=swap");let u=document.createElement("link");u.setAttribute("rel","stylesheet"),u.setAttribute("type","text/css"),u.setAttribute("href",this.cssProvider),this.shadowRootElement=document.createElement("div"),this.shadowRootElement.className="light",o.appendChild(i),o.appendChild(s),o.appendChild(l),o.appendChild(u),o.appendChild(this.shadowRootElement),this.root=(0,e1e.createRoot)(this.shadowRootElement)}open(){this.setIsOpen?.(!0)}close(){this.setIsOpen?.(!1)}toggle(){this.setIsOpen?.(!this.isOpen)}createNewConversation(){this.dispatchEvent(new Event("CREATE_NEW_CONVERSATION",{bubbles:!0,composed:!0}))}updateConfig(n){n&&this.setAttribute("interface",JSON.stringify(n)),this.root.render((0,Od.jsx)(this.Component,{isOpen:this.isOpen,onEnd:this.onEnd}))}Component=n=>{let[o,i]=(0,im.useState)(!1);this.setIsOpen=i,this.isOpen=o;let s=Object.entries(CQe).reduce((f,[p,m])=>{let g=this.getAttribute(p);return g&&p!=="visitor-id"&&(f[m]=g),f},{}),l=this.getAttribute("visitor-id")||void 0,u=this.getAttribute("context"),d={};try{d=JSON.parse(this.getAttribute("interface"))}catch{}return(0,Od.jsx)(im.StrictMode,{children:(0,Od.jsx)(TQe,{container:this.shadowRootElement,children:(0,Od.jsx)("div",{className:"bg-transparent",children:im.default.createElement(t,{...n,isOpen:o,onEnd:this.onEnd,initConfig:d,context:u,agentId:this.getAttribute("agent-id")||"",formId:this.getAttribute("form-id")||"",contact:s,visitorId:l,styles:this.getAttribute("styles")?JSON.parse(this.getAttribute("styles")):{},onAgentLoaded:f=>{let p=f?.interfaceConfig?.customCSS;if(p){let m=document.createElement("style");m.innerHTML=p,this.shadowRootElement.appendChild(m)}}})})})})};connectedCallback(){this.root.render((0,Od.jsx)(this.Component,{isOpen:this.isOpen,onEnd:this.onEnd}))}},oN=EQe;var n1e=E(q()),t1e="horneross-chatbox-bubble",r1e=oN({type:"chatbox",widget:e=>(0,n1e.jsx)(AR,{...e,className:Sn("horneross-widget",e.className),children:Ebe}),name:t1e});customElements.define(t1e,r1e);var a1e=r1e;var IQe=async e=>{if(typeof window<"u"&&!window?.ChatboxBubble){let t=document?.currentScript?.src,r=document?.currentScript?.id,a=e.agentId||r;!a&&t&&(a=new URL(t).searchParams.get("agentId")||r||e.agentId),FC(e);let n=new a1e({instanceId:"ChatBoxBubble"});zC({element:n,...e}),window.ChatboxBubble=n,document?.body?.prepend(n)}return window?.ChatboxBubble},o1e=IQe;c();c();c();var hl=E(q()),_Qe="https://app.horneross.com/images/chatbubble-default-horneross.svg",AQe=e=>{let{query:t}=Hy({id:e.agentId});return(0,hl.jsxs)("div",{className:Sn("relative w-full h-full flex flex-col",e.className),children:[(0,hl.jsx)("div",{className:"flex-shrink-0 px-2 pt-2 pb-2",children:(0,hl.jsxs)("div",{className:"px-2 py-1 flex items-center border border-gray-700 max-w-[700px] mx-auto bg-[#161618] rounded-lg",children:[(0,hl.jsx)("div",{className:"w-8 h-8 mr-2 rounded-full border border-gray-600 flex items-center justify-center overflow-hidden",children:t?.data?.iconUrl?(0,hl.jsx)("img",{src:t?.data?.iconUrl||_Qe,alt:"Agent",className:"w-full h-full object-cover"}):(0,hl.jsx)(lc,{className:"w-4 h-4 text-gray-400"})}),(0,hl.jsx)("h3",{className:"text-white font-medium text-lg font-['Bricolage_Grotesque']",children:e?.config?.displayName||t?.data?.name}),(0,hl.jsx)("div",{className:"ml-auto flex items-center",children:(0,hl.jsx)(RR,{variant:"plain"})})]})}),(0,hl.jsx)("div",{className:"flex-1 flex flex-col min-h-0",children:e.children})]})},i1e=AQe;var s1e=E(q()),hh="horneross-chatbox-standard",RQe=oN({type:"chatbox",widget:e=>(0,s1e.jsx)(AR,{layout:i1e,...e,className:Sn("horneross-widget",e.className)}),name:hh}),TH=RQe;var PQe=e=>{customElements.get(hh)||customElements.define(hh,TH),FC(e);let t="ChatBoxStandard_"+(e.id||""),r=new TH({instanceId:t}),a=e.id?document.querySelector(`${hh}[id="${e.id}"]`):document.querySelector(hh);if(!a)throw new Error(`<${hh}> element${`${e.id?` with ID ${e.id}`:""}`} not found.`);if(!window[t]){let n={...e.styles,...Array.from(a.style).reduce((o,i)=>(o[i]=a?.style.getPropertyValue(i),o),{})};zC({element:r,...e,styles:n}),window[t]=r,a.replaceWith(r)}return window[t]},l1e=PQe;var NQe={initBubble:o1e,initStandard:l1e},XAr=NQe;export{XAr as default};
|
|
383
383
|
/*! Bundled license information:
|
|
384
384
|
|
|
385
385
|
react/cjs/react.production.js:
|