@@ -1,2 +0,2 @@ | ||
| var Chatsy=(()=>{var m=Object.defineProperty;var A=Object.getOwnPropertyDescriptor;var B=Object.getOwnPropertyNames,v=Object.getOwnPropertySymbols;var w=Object.prototype.hasOwnProperty,z=Object.prototype.propertyIsEnumerable;var x=(t,e,o)=>e in t?m(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o,S=(t,e)=>{for(var o in e||(e={}))w.call(e,o)&&x(t,o,e[o]);if(v)for(var o of v(e))z.call(e,o)&&x(t,o,e[o]);return t};var H=(t,e)=>{for(var o in e)m(t,o,{get:e[o],enumerable:!0})},R=(t,e,o,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of B(e))!w.call(t,i)&&i!==o&&m(t,i,{get:()=>e[i],enumerable:!(s=A(e,i))||s.enumerable});return t};var j=t=>R(m({},"__esModule",{value:!0}),t);var U={};H(U,{Chatsy:()=>a,default:()=>T});var c="2.0.13",f=typeof window!="undefined"&&typeof document!="undefined",h="https://chatsy.ai",I={settings:{button:{backgroundColor:"#297bf7",textColor:"#FFFFFF",position:"bottom-right",type:"round",icon:"default"}},user:{},context:{}},y={default:t=>`<svg viewBox="0 0 700 700" width="28" height="28" fill="${t}" style="pointer-events:none"> | ||
| var Chatsy=(()=>{var m=Object.defineProperty;var M=Object.getOwnPropertyDescriptor;var B=Object.getOwnPropertyNames,v=Object.getOwnPropertySymbols;var w=Object.prototype.hasOwnProperty,z=Object.prototype.propertyIsEnumerable;var x=(t,e,o)=>e in t?m(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o,S=(t,e)=>{for(var o in e||(e={}))w.call(e,o)&&x(t,o,e[o]);if(v)for(var o of v(e))z.call(e,o)&&x(t,o,e[o]);return t};var H=(t,e)=>{for(var o in e)m(t,o,{get:e[o],enumerable:!0})},R=(t,e,o,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of B(e))!w.call(t,i)&&i!==o&&m(t,i,{get:()=>e[i],enumerable:!(s=M(e,i))||s.enumerable});return t};var j=t=>R(m({},"__esModule",{value:!0}),t);var U={};H(U,{Chatsy:()=>a,default:()=>T});var c="2.0.14",f=typeof window!="undefined"&&typeof document!="undefined",h="https://chatsy.ai",I={settings:{button:{backgroundColor:"#297bf7",textColor:"#FFFFFF",position:"bottom-right",type:"round",icon:"default"}},user:{},context:{}},y={default:t=>`<svg viewBox="0 0 700 700" width="28" height="28" fill="${t}" style="pointer-events:none"> | ||
| <path d="M62.75 600.75V606c0 19.25 10.75 36.5 28.25 45 7 3.5 14.5 5 22 5 10.75 0 21.75-3.5 30.75-10.75l19.75-15.25c23-18.25 51.75-28 81-28h135.25c28.75 0 53.75-16.25 66.5-40-19.75-10.5-41.75-16.25-64-16.25H202.25c-78.75 0-142.75-63.75-142.75-142V252.25C25.5 259.75 0 290 0 326.25v200.5c0 37.25 27.25 68.25 62.75 74z"/> | ||
@@ -35,3 +35,3 @@ <path d="M607.5 44H202c-51 0-92.5 41.25-92.5 92v267.75c0 50.75 41.5 92 92.75 92H382.25c41 0 81.25 13.75 113.25 39l40 31.25c9 7.25 19.75 10.75 30.75 10.75 7.25 0 14.75-1.75 21.75-5 17.5-8.5 28.25-25.75 28.25-45v-31.5c47-4.25 83.75-43.75 83.75-91.5V136C700 85.25 658.5 44 607.5 44zM504.75 347.75H304.75c-13.75 0-25-11.25-25-25s11.25-25 25-25h200c14 0 25 11 25 25s-11 25-25 25zm0-105.25H304.75c-13.75 0-25-11.25-25-25.25s11.25-25 25-25h200c14 0 25 11.25 25 25s-11 25.25-25 25.25z"/> | ||
| } | ||
| [id$="-btn"]::before { | ||
| .chatsy-btn::before { | ||
| content: ''; | ||
@@ -44,3 +44,3 @@ position: absolute; | ||
| } | ||
| `,document.head.appendChild(r)}let s=document.createElement("div");s.id=t._instanceId+"-btn",s.setAttribute("role","button"),s.setAttribute("aria-label","Open chat"),s.setAttribute("tabindex","0"),Object.assign(s.style,{position:"fixed",overflow:"visible",bottom:"20px",[o?"left":"right"]:"20px",width:"60px",height:"60px",borderRadius:e.type==="round"?"50%":"12px",backgroundColor:e.backgroundColor,color:e.textColor,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:"0 2px 10px rgba(0, 0, 0, 0.16)",zIndex:"2147483646",transition:"transform 167ms cubic-bezier(0.33, 0, 0, 1)",transformOrigin:"center center",animation:"chatsy-bounce-in 1.5s cubic-bezier(0.4, 0.1, 0.2, 1)"}),s.innerHTML=k(e),s.addEventListener("mouseenter",()=>{s.style.transition="transform 250ms cubic-bezier(0.33, 0, 0, 1)",s.style.transform="scale(1.1)"}),s.addEventListener("mouseleave",()=>{s.style.transition="transform 167ms cubic-bezier(0.33, 0, 0, 1)",s.style.transform="scale(1)"}),s.addEventListener("mousedown",()=>{s.style.transition="transform 134ms cubic-bezier(0.45, 0, 0.2, 1)",s.style.transform="scale(0.85)"}),s.addEventListener("mouseup",()=>{s.style.transition="transform 250ms cubic-bezier(0.33, 0, 0, 1)",s.style.transform="scale(1.1)"}),s.addEventListener("click",()=>t.toggle()),s.addEventListener("keydown",r=>{(r.key==="Enter"||r.key===" ")&&(r.preventDefault(),t.toggle())});let i=document.createElement("div");Object.assign(i.style,{position:"absolute",top:"-4px",right:"-4px",width:"22px",height:"22px",borderRadius:"50%",backgroundColor:"#EF4444",color:"#FFFFFF",fontSize:"12px",fontWeight:"700",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',display:"flex",alignItems:"center",justifyContent:"center",lineHeight:"1",border:"2px solid #FFFFFF",boxShadow:"0 2px 4px rgba(0, 0, 0, 0.2)",transform:"scale(0)",pointerEvents:"none"}),i.textContent="1",s.appendChild(i),t._badge=i,setTimeout(()=>{t._badge&&!t._isOpen&&(i.style.animation="chatsy-badge-in 400ms cubic-bezier(0.34, 1.56, 0.64, 1) forwards",t._badgeInterval=setInterval(()=>{if(!t._badge){clearInterval(t._badgeInterval);return}i.style.animation="none",i.offsetHeight,i.style.animation="chatsy-badge-pop 400ms cubic-bezier(0.34, 1.56, 0.64, 1) forwards"},1e4))},2e3),document.body.appendChild(s),t._button=s,n("Button created",{position:e.position,type:e.type,icon:e.icon})}function C(t){if(!t._badge)return;clearInterval(t._badgeInterval),t._badge.style.animation="chatsy-badge-out 200ms ease-in forwards";let e=t._badge;t._badge=null,setTimeout(()=>e.remove(),200)}function b(t,e){if(!t._button)return;let o=t._button_;t._button.innerHTML=e?W(o):k(o),t._button.setAttribute("aria-label",e?"Close chat":"Open chat")}function k(t){return(y[t.icon]||y.default)(t.textColor)}function W(t){return O(t.textColor)}function L(t){let e=document.createElement("div");e.id=t._instanceId+"-overlay",Object.assign(e.style,{position:"fixed",zIndex:"2147483646",display:"none",opacity:"0",transition:"opacity 0.25s ease",touchAction:"none"}),e.addEventListener("click",()=>t.close()),document.body.appendChild(e),t._overlay=e;let o=t._options._embedUrl||h,s=new URL("/chat/embed",o);s.searchParams.set("agentId",t._agentId),s.searchParams.set("version",c),s.searchParams.set("settings",JSON.stringify(t._options.settings)),s.searchParams.set("user",JSON.stringify(t._options.user)),s.searchParams.set("context",JSON.stringify(t._options.context));let i=document.createElement("iframe");i.id=t._instanceId+"-iframe",i.src=s.toString(),i.setAttribute("sandbox","allow-scripts allow-same-origin allow-forms allow-popups"),i.setAttribute("allow","clipboard-write"),Object.assign(i.style,{position:"fixed",border:"none",zIndex:"2147483647",display:"none",opacity:"0",overflow:"hidden"}),document.body.appendChild(i),t._iframe=i,_(t),n("Iframe created",{src:i.src})}function _(t){let e=window.innerWidth<=480,o=t._button_.position==="bottom-left",s=t._iframe,i=t._overlay;!s||!i||(n("Syncing styles",{isMobile:e,innerWidth:window.innerWidth}),Object.assign(i.style,{top:e?"-200%":"0",left:e?"-200%":"0",width:e?"500%":"100%",height:e?"500%":"100%",backgroundColor:e?"#0b0b1a":"rgba(0, 0, 0, 0.3)"}),s.style.top="",s.style.bottom="",s.style.left="",s.style.right="",s.style.width="",s.style.height="",e?Object.assign(s.style,{top:"0",bottom:"0",left:"0",right:"0",width:"100%",height:"100%",maxHeight:"none",borderRadius:"0",boxShadow:"none",transform:"none",transition:"opacity 200ms ease-out"}):Object.assign(s.style,{bottom:"84px",[o?"left":"right"]:"20px",width:"400px",height:"min(704px, calc(100% - 104px))",maxHeight:"704px",borderRadius:"16px",boxShadow:"0 5px 40px rgba(0, 0, 0, 0.16)",transform:"scale(0)",transformOrigin:`${o?"left":"right"} bottom`,transition:"transform 300ms cubic-bezier(0, 1.2, 1, 1), opacity 83ms ease-out"}))}function l(t,e,o){if(!t._iframe||!t._iframe.contentWindow)return;let s=t._options._embedUrl||h;t._iframe.contentWindow.postMessage({type:e,instanceId:t._instanceId,payload:o},s)}function d(t,e,o){let s=t._listeners[e]||[];s.length&&n(`Emitting "${e}" to ${s.length} listener(s)`),s.forEach(i=>{try{i(o)}catch(r){u(`Event "${e}" handler error:`,r)}})}function F(t,e){var r;let o=e.data;if(!o||typeof o.type!="string"||!o.type.startsWith("chatsy:"))return;let s=new URL(t._options._embedUrl||h).origin;if(e.origin!==s&&!e.origin.startsWith("http://localhost"))return;let i=o.payload||{};switch(n(`Received postMessage: ${o.type}`,i),o.type){case"chatsy:ready":t._ready=!0,n("Iframe ready, sending init config"),l(t,"chatsy:init",{agentId:t._agentId,version:c,settings:t._options.settings,user:t._options.user,context:t._options.context}),d(t,"ready"),t._pendingSend&&(n("Flushing queued message:",t._pendingSend),l(t,"chatsy:send",{message:t._pendingSend}),t._pendingSend=null);break;case"chatsy:message":i.message&&t._messages.push(i.message),i.messages&&(t._messages=i.messages),n("Received message from iframe:",(r=i.message)==null?void 0:r.content),d(t,"message",i.message);break;case"chatsy:close":n("Close requested by embed"),t.close();break;case"chatsy:state":n("State update:",i.state),i.state==="error"&&(u("Error from iframe:",i.error),d(t,"error",i.error));break}}var $=0,a=class{constructor(e,o={}){if(!e||typeof e!="string")throw new Error("Chatsy: agentId is required as the first argument");this._agentId=e,this._options=p(I,o),this._button_=this._options.settings.button,this._instanceId=`chatsy-${++$}`,f&&(this._options.context=p({page:{url:window.location.href,referrer:document.referrer,title:document.title}},this._options.context)),this._isOpen=!1,this._ready=!1,this._messages=[],this._listeners={},this._button=null,this._iframe=null,this._overlay=null,this._pendingSend=null,this._savedBodyStyles=null,this._savedHtmlStyles=null,this._savedScrollY=0,n(`Initializing instance ${this._instanceId}`,{agentId:e,options:this._options}),this._onMessage=F.bind(null,this),this._emit=d.bind(null,this),f?(window.addEventListener("message",this._onMessage),document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>g(this)):g(this)):E("Non-browser environment detected, skipping DOM setup")}open(){if(this._isOpen)return;let e=window.innerWidth<=480;if(n("Opening chat",{isMobile:e,innerWidth:window.innerWidth,innerHeight:window.innerHeight}),C(this),this._iframe||L(this),_(this),this._isOpen=!0,this._iframe.style.display="block",this._overlay.style.display="block",n("Iframe styles after display:block",{opacity:this._iframe.style.opacity,transform:this._iframe.style.transform,width:this._iframe.style.width,height:this._iframe.style.height,top:this._iframe.style.top,bottom:this._iframe.style.bottom}),e){this._savedScrollY=window.scrollY;let o=document.documentElement;this._savedBodyStyles={overflow:document.body.style.overflow,height:document.body.style.height,overscrollBehavior:document.body.style.overscrollBehavior},this._savedHtmlStyles={overflow:o.style.overflow,height:o.style.height},Object.assign(document.body.style,{overflow:"hidden",height:"0",overscrollBehavior:"none"}),Object.assign(o.style,{overflow:"hidden",height:"0"})}requestAnimationFrame(()=>{this._iframe.style.opacity="1",e||(this._iframe.style.transform="scale(1)"),this._overlay.style.opacity="1",n("Animation frame fired",{opacity:this._iframe.style.opacity,transform:this._iframe.style.transform})}),b(this,!0),setTimeout(()=>{l(this,"chatsy:open",{}),this._iframe&&this._iframe.focus()},300),d(this,"open")}close(){this._isOpen&&(n("Closing chat"),this._isOpen=!1,this._savedBodyStyles&&(Object.assign(document.body.style,this._savedBodyStyles),Object.assign(document.documentElement.style,this._savedHtmlStyles),window.scrollTo(0,this._savedScrollY),this._savedBodyStyles=null,this._savedHtmlStyles=null),this._iframe.style.opacity="0",window.innerWidth>480&&(this._iframe.style.transform="scale(0)"),this._overlay.style.opacity="0",setTimeout(()=>{!this._isOpen&&this._iframe&&(this._iframe.style.display="none",this._overlay.style.display="none")},250),b(this,!1),l(this,"chatsy:close",{}),d(this,"close"))}toggle(){this._isOpen?this.close():this.open()}setUser(e){this._options.user=e||{},this._ready&&l(this,"chatsy:update",{user:this._options.user})}send(e){!e||typeof e!="string"||(this._isOpen||this.open(),this._ready?(n("Sending message to iframe:",e),l(this,"chatsy:send",{message:e})):(n("Iframe not ready, queuing message:",e),this._pendingSend=e))}getMessages(){return[...this._messages]}on(e,o){return this._listeners[e]||(this._listeners[e]=[]),this._listeners[e].push(o),this}destroy(){n(`Destroying instance ${this._instanceId}`),this._savedBodyStyles&&(Object.assign(document.body.style,this._savedBodyStyles),Object.assign(document.documentElement.style,this._savedHtmlStyles),window.scrollTo(0,this._savedScrollY),this._savedBodyStyles=null,this._savedHtmlStyles=null),f&&window.removeEventListener("message",this._onMessage),this._button&&this._button.remove(),this._iframe&&this._iframe.remove(),this._overlay&&this._overlay.remove(),this._button=null,this._iframe=null,this._overlay=null,this._listeners={},this._messages=[]}};a.version=c;a._instances=[];function M(){let t=document.querySelectorAll("script[data-agent-id]");n(`Auto-init: found ${t.length} script tag(s) with data-agent-id`),t.forEach(e=>{let o=e.getAttribute("data-agent-id");if(!o)return;let s=new a(o,{settings:{button:{backgroundColor:e.getAttribute("data-button-background-color")||void 0,textColor:e.getAttribute("data-button-text-color")||void 0,position:e.getAttribute("data-button-position")||void 0,type:e.getAttribute("data-button-type")||void 0,icon:e.getAttribute("data-button-icon")||void 0}}});a._instances.push(s)})}typeof window!="undefined"&&(window.Chatsy=a,document.readyState==="loading"?document.addEventListener("DOMContentLoaded",M):M());var T=a;return j(U);})(); | ||
| `,document.head.appendChild(r)}let s=document.createElement("div");s.className="chatsy-btn",s.setAttribute("data-chatsy-id",t._instanceId),s.setAttribute("role","button"),s.setAttribute("aria-label","Open chat"),s.setAttribute("tabindex","0"),Object.assign(s.style,{position:"fixed",overflow:"visible",bottom:"20px",[o?"left":"right"]:"20px",width:"60px",height:"60px",borderRadius:e.type==="round"?"50%":"12px",backgroundColor:e.backgroundColor,color:e.textColor,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:"0 2px 10px rgba(0, 0, 0, 0.16)",zIndex:"2147483646",transition:"transform 167ms cubic-bezier(0.33, 0, 0, 1)",transformOrigin:"center center",animation:"chatsy-bounce-in 1.5s cubic-bezier(0.4, 0.1, 0.2, 1)"}),s.innerHTML=k(e),s.addEventListener("mouseenter",()=>{s.style.transition="transform 250ms cubic-bezier(0.33, 0, 0, 1)",s.style.transform="scale(1.1)"}),s.addEventListener("mouseleave",()=>{s.style.transition="transform 167ms cubic-bezier(0.33, 0, 0, 1)",s.style.transform="scale(1)"}),s.addEventListener("mousedown",()=>{s.style.transition="transform 134ms cubic-bezier(0.45, 0, 0.2, 1)",s.style.transform="scale(0.85)"}),s.addEventListener("mouseup",()=>{s.style.transition="transform 250ms cubic-bezier(0.33, 0, 0, 1)",s.style.transform="scale(1.1)"}),s.addEventListener("click",()=>t.toggle()),s.addEventListener("keydown",r=>{(r.key==="Enter"||r.key===" ")&&(r.preventDefault(),t.toggle())});let i=document.createElement("div");Object.assign(i.style,{position:"absolute",top:"-4px",right:"-4px",width:"22px",height:"22px",borderRadius:"50%",backgroundColor:"#EF4444",color:"#FFFFFF",fontSize:"12px",fontWeight:"700",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',display:"flex",alignItems:"center",justifyContent:"center",lineHeight:"1",border:"2px solid #FFFFFF",boxShadow:"0 2px 4px rgba(0, 0, 0, 0.2)",transform:"scale(0)",pointerEvents:"none"}),i.textContent="1",s.appendChild(i),t._badge=i,setTimeout(()=>{t._badge&&!t._isOpen&&(i.style.animation="chatsy-badge-in 400ms cubic-bezier(0.34, 1.56, 0.64, 1) forwards",t._badgeInterval=setInterval(()=>{if(!t._badge){clearInterval(t._badgeInterval);return}i.style.animation="none",i.offsetHeight,i.style.animation="chatsy-badge-pop 400ms cubic-bezier(0.34, 1.56, 0.64, 1) forwards"},1e4))},2e3),document.body.appendChild(s),t._button=s,n("Button created",{position:e.position,type:e.type,icon:e.icon})}function C(t){if(!t._badge)return;clearInterval(t._badgeInterval),t._badge.style.animation="chatsy-badge-out 200ms ease-in forwards";let e=t._badge;t._badge=null,setTimeout(()=>e.remove(),200)}function b(t,e){if(!t._button)return;let o=t._button_;t._button.innerHTML=e?W(o):k(o),t._button.setAttribute("aria-label",e?"Close chat":"Open chat")}function k(t){return(y[t.icon]||y.default)(t.textColor)}function W(t){return O(t.textColor)}function L(t){let e=document.createElement("div");e.id=t._instanceId+"-overlay",Object.assign(e.style,{position:"fixed",zIndex:"2147483646",display:"none",opacity:"0",transition:"opacity 0.25s ease",touchAction:"none"}),e.addEventListener("click",()=>t.close()),document.body.appendChild(e),t._overlay=e;let o=t._options._embedUrl||h,s=new URL("/chat/embed",o);s.searchParams.set("agentId",t._agentId),s.searchParams.set("version",c),s.searchParams.set("settings",JSON.stringify(t._options.settings)),s.searchParams.set("user",JSON.stringify(t._options.user)),s.searchParams.set("context",JSON.stringify(t._options.context));let i=document.createElement("iframe");i.id=t._instanceId+"-iframe",i.src=s.toString(),i.setAttribute("sandbox","allow-scripts allow-same-origin allow-forms allow-popups"),i.setAttribute("allow","clipboard-write"),Object.assign(i.style,{position:"fixed",border:"none",zIndex:"2147483647",display:"none",opacity:"0",overflow:"hidden"}),document.body.appendChild(i),t._iframe=i,_(t),n("Iframe created",{src:i.src})}function _(t){let e=window.innerWidth<=480,o=t._button_.position==="bottom-left",s=t._iframe,i=t._overlay;!s||!i||(n("Syncing styles",{isMobile:e,innerWidth:window.innerWidth}),Object.assign(i.style,{top:e?"-200%":"0",left:e?"-200%":"0",width:e?"500%":"100%",height:e?"500%":"100%",backgroundColor:e?"#0b0b1a":"rgba(0, 0, 0, 0.3)"}),s.style.top="",s.style.bottom="",s.style.left="",s.style.right="",s.style.width="",s.style.height="",e?Object.assign(s.style,{top:"0",bottom:"0",left:"0",right:"0",width:"100%",height:"100%",maxHeight:"none",borderRadius:"0",boxShadow:"none",transform:"none",transition:"opacity 200ms ease-out"}):Object.assign(s.style,{bottom:"84px",[o?"left":"right"]:"20px",width:"400px",height:"min(704px, calc(100% - 104px))",maxHeight:"704px",borderRadius:"16px",boxShadow:"0 5px 40px rgba(0, 0, 0, 0.16)",transform:"scale(0)",transformOrigin:`${o?"left":"right"} bottom`,transition:"transform 300ms cubic-bezier(0, 1.2, 1, 1), opacity 83ms ease-out"}))}function l(t,e,o){if(!t._iframe||!t._iframe.contentWindow)return;let s=t._options._embedUrl||h;t._iframe.contentWindow.postMessage({type:e,instanceId:t._instanceId,payload:o},s)}function d(t,e,o){let s=t._listeners[e]||[];s.length&&n(`Emitting "${e}" to ${s.length} listener(s)`),s.forEach(i=>{try{i(o)}catch(r){u(`Event "${e}" handler error:`,r)}})}function A(t,e){var r;let o=e.data;if(!o||typeof o.type!="string"||!o.type.startsWith("chatsy:"))return;let s=new URL(t._options._embedUrl||h).origin;if(e.origin!==s&&!e.origin.startsWith("http://localhost"))return;let i=o.payload||{};switch(n(`Received postMessage: ${o.type}`,i),o.type){case"chatsy:ready":t._ready=!0,n("Iframe ready, sending init config"),l(t,"chatsy:init",{agentId:t._agentId,version:c,settings:t._options.settings,user:t._options.user,context:t._options.context}),d(t,"ready"),t._pendingSend&&(n("Flushing queued message:",t._pendingSend),l(t,"chatsy:send",{message:t._pendingSend}),t._pendingSend=null);break;case"chatsy:message":i.message&&t._messages.push(i.message),i.messages&&(t._messages=i.messages),n("Received message from iframe:",(r=i.message)==null?void 0:r.content),d(t,"message",i.message);break;case"chatsy:close":n("Close requested by embed"),t.close();break;case"chatsy:state":n("State update:",i.state),i.state==="error"&&(u("Error from iframe:",i.error),d(t,"error",i.error));break}}var N=0,a=class{constructor(e,o={}){if(!e||typeof e!="string")throw new Error("Chatsy: agentId is required as the first argument");this._agentId=e,this._options=p(I,o),this._button_=this._options.settings.button,this._instanceId=`chatsy-${++N}`,f&&(this._options.context=p({page:{url:window.location.href,referrer:document.referrer,title:document.title}},this._options.context)),this._isOpen=!1,this._ready=!1,this._messages=[],this._listeners={},this._button=null,this._iframe=null,this._overlay=null,this._pendingSend=null,this._savedBodyStyles=null,this._savedHtmlStyles=null,this._savedScrollY=0,n(`Initializing instance ${this._instanceId}`,{agentId:e,options:this._options}),this._onMessage=A.bind(null,this),this._emit=d.bind(null,this),f?(window.addEventListener("message",this._onMessage),document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>g(this)):g(this)):E("Non-browser environment detected, skipping DOM setup")}open(){if(this._isOpen)return;let e=window.innerWidth<=480;if(n("Opening chat",{isMobile:e,innerWidth:window.innerWidth,innerHeight:window.innerHeight}),C(this),this._iframe||L(this),_(this),this._isOpen=!0,this._iframe.style.display="block",this._overlay.style.display="block",n("Iframe styles after display:block",{opacity:this._iframe.style.opacity,transform:this._iframe.style.transform,width:this._iframe.style.width,height:this._iframe.style.height,top:this._iframe.style.top,bottom:this._iframe.style.bottom}),e){this._savedScrollY=window.scrollY;let o=document.documentElement;this._savedBodyStyles={overflow:document.body.style.overflow,height:document.body.style.height,overscrollBehavior:document.body.style.overscrollBehavior},this._savedHtmlStyles={overflow:o.style.overflow,height:o.style.height},Object.assign(document.body.style,{overflow:"hidden",height:"0",overscrollBehavior:"none"}),Object.assign(o.style,{overflow:"hidden",height:"0"})}requestAnimationFrame(()=>{this._iframe.style.opacity="1",e||(this._iframe.style.transform="scale(1)"),this._overlay.style.opacity="1",n("Animation frame fired",{opacity:this._iframe.style.opacity,transform:this._iframe.style.transform})}),b(this,!0),setTimeout(()=>{l(this,"chatsy:open",{}),this._iframe&&this._iframe.focus()},300),d(this,"open")}close(){this._isOpen&&(n("Closing chat"),this._isOpen=!1,this._savedBodyStyles&&(Object.assign(document.body.style,this._savedBodyStyles),Object.assign(document.documentElement.style,this._savedHtmlStyles),window.scrollTo(0,this._savedScrollY),this._savedBodyStyles=null,this._savedHtmlStyles=null),this._iframe.style.opacity="0",window.innerWidth>480&&(this._iframe.style.transform="scale(0)"),this._overlay.style.opacity="0",setTimeout(()=>{!this._isOpen&&this._iframe&&(this._iframe.style.display="none",this._overlay.style.display="none")},250),b(this,!1),l(this,"chatsy:close",{}),d(this,"close"))}toggle(){this._isOpen?this.close():this.open()}setUser(e){this._options.user=e||{},this._ready&&l(this,"chatsy:update",{user:this._options.user})}send(e){!e||typeof e!="string"||(this._isOpen||this.open(),this._ready?(n("Sending message to iframe:",e),l(this,"chatsy:send",{message:e})):(n("Iframe not ready, queuing message:",e),this._pendingSend=e))}getMessages(){return[...this._messages]}on(e,o){return this._listeners[e]||(this._listeners[e]=[]),this._listeners[e].push(o),this}destroy(){n(`Destroying instance ${this._instanceId}`),this._savedBodyStyles&&(Object.assign(document.body.style,this._savedBodyStyles),Object.assign(document.documentElement.style,this._savedHtmlStyles),window.scrollTo(0,this._savedScrollY),this._savedBodyStyles=null,this._savedHtmlStyles=null),f&&window.removeEventListener("message",this._onMessage),this._button&&this._button.remove(),this._iframe&&this._iframe.remove(),this._overlay&&this._overlay.remove(),this._button=null,this._iframe=null,this._overlay=null,this._listeners={},this._messages=[]}};a.version=c;a._instances=[];function F(){let t=document.querySelectorAll("script[data-agent-id]");n(`Auto-init: found ${t.length} script tag(s) with data-agent-id`),t.forEach(e=>{let o=e.getAttribute("data-agent-id");if(!o)return;let s=new a(o,{settings:{button:{backgroundColor:e.getAttribute("data-button-background-color")||void 0,textColor:e.getAttribute("data-button-text-color")||void 0,position:e.getAttribute("data-button-position")||void 0,type:e.getAttribute("data-button-type")||void 0,icon:e.getAttribute("data-button-icon")||void 0}}});a._instances.push(s)})}typeof window!="undefined"&&(window.Chatsy=a,document.readyState==="loading"?document.addEventListener("DOMContentLoaded",F):F());var T=a;return j(U);})(); | ||
| Chatsy=Chatsy.default||Chatsy.Chatsy||Chatsy; |
+4
-3
@@ -28,3 +28,3 @@ var __defProp = Object.defineProperty; | ||
| // src/lib/constants.js | ||
| var VERSION = "2.0.13"; | ||
| var VERSION = "2.0.14"; | ||
| var IS_BROWSER = typeof window !== "undefined" && typeof document !== "undefined"; | ||
@@ -112,3 +112,3 @@ var API_URL = "https://chatsy.ai"; | ||
| } | ||
| [id$="-btn"]::before { | ||
| .chatsy-btn::before { | ||
| content: ''; | ||
@@ -125,3 +125,4 @@ position: absolute; | ||
| const btn = document.createElement("div"); | ||
| btn.id = instance._instanceId + "-btn"; | ||
| btn.className = "chatsy-btn"; | ||
| btn.setAttribute("data-chatsy-id", instance._instanceId); | ||
| btn.setAttribute("role", "button"); | ||
@@ -128,0 +129,0 @@ btn.setAttribute("aria-label", "Open chat"); |
+4
-3
| // src/lib/constants.js | ||
| var VERSION = "2.0.13"; | ||
| var VERSION = "2.0.14"; | ||
| var IS_BROWSER = typeof window !== "undefined" && typeof document !== "undefined"; | ||
@@ -85,3 +85,3 @@ var API_URL = "https://chatsy.ai"; | ||
| } | ||
| [id$="-btn"]::before { | ||
| .chatsy-btn::before { | ||
| content: ''; | ||
@@ -98,3 +98,4 @@ position: absolute; | ||
| const btn = document.createElement("div"); | ||
| btn.id = instance._instanceId + "-btn"; | ||
| btn.className = "chatsy-btn"; | ||
| btn.setAttribute("data-chatsy-id", instance._instanceId); | ||
| btn.setAttribute("role", "button"); | ||
@@ -101,0 +102,0 @@ btn.setAttribute("aria-label", "Open chat"); |
+1
-1
| { | ||
| "name": "chatsy", | ||
| "version": "2.0.13", | ||
| "version": "2.0.14", | ||
| "description": "Embeddable AI chatbot widget. Add a chat widget to any website with one line of code.", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
66115
0.22%1350
0.15%