@robylon/web-react-sdk 1.1.43 → 1.1.44
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/cjs/index.js +2 -2
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/utils/launcherInfo.d.ts +2 -0
- package/dist/cjs/types/utils/systemInfo.d.ts +1 -2
- package/dist/esm/index.js +2 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/utils/launcherInfo.d.ts +2 -0
- package/dist/esm/types/utils/systemInfo.d.ts +1 -2
- package/dist/umd/robylon-chatbot.js +1 -1
- package/dist/umd/robylon-chatbot.js.map +1 -1
- package/dist/umd/types/utils/launcherInfo.d.ts +2 -0
- package/dist/umd/types/utils/systemInfo.d.ts +1 -2
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var e=require("react"),t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},t(e,n)};var n,i,o,r,a,l,s=function(){return s=Object.assign||function(e){for(var t,n=1,i=arguments.length;n<i;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},s.apply(this,arguments)};function c(e,t,n,i){return new(n||(n=Promise))((function(o,r){function a(e){try{s(i.next(e))}catch(e){r(e)}}function l(e){try{s(i.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,l)}s((i=i.apply(e,t||[])).next())}))}function d(e,t){var n,i,o,r={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=l(0),a.throw=l(1),a.return=l(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function l(l){return function(s){return function(l){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,l[0]&&(r=0)),r;)try{if(n=1,i&&(o=2&l[0]?i.return:l[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,l[1])).done)return o;switch(i=0,o&&(l=[2&l[0],o.value]),l[0]){case 0:case 1:o=l;break;case 4:return r.label++,{value:l[1],done:!1};case 5:r.label++,i=l[1],l=[0];continue;case 7:l=r.ops.pop(),r.trys.pop();continue;default:if(!(o=r.trys,(o=o.length>0&&o[o.length-1])||6!==l[0]&&2!==l[0])){r=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]<o[3])){r.label=l[1];break}if(6===l[0]&&r.label<o[1]){r.label=o[1],o=l;break}if(o&&r.label<o[2]){r.label=o[2],r.ops.push(l);break}o[2]&&r.ops.pop(),r.trys.pop();continue}l=t.call(e,r)}catch(e){l=[6,e],i=0}finally{n=o=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}([l,s])}}}function u(e,t,n){if(n||2===arguments.length)for(var i,o=0,r=t.length;o<r;o++)!i&&o in t||(i||(i=Array.prototype.slice.call(t,0,o)),i[o]=t[o]);return e.concat(i||Array.prototype.slice.call(t))}"function"==typeof SuppressedError&&SuppressedError,exports.ChatbotInterfaceType=void 0,(n=exports.ChatbotInterfaceType||(exports.ChatbotInterfaceType={})).WIDGET="WIDGET",n.POPOVER="POPOVER",n.EMBED="EMBED",exports.WidgetPositionEnums=void 0,(i=exports.WidgetPositionEnums||(exports.WidgetPositionEnums={})).RIGHT="Right",i.LEFT="Left",exports.LauncherType=void 0,(o=exports.LauncherType||(exports.LauncherType={})).TEXT="TEXT",o.IMAGE="IMAGE",o.TEXTUAL_IMAGE="TEXTUAL_IMAGE",exports.ProactiveSendTimeType=void 0,(r=exports.ProactiveSendTimeType||(exports.ProactiveSendTimeType={})).WORKING_HOURS="WORKING_HOURS",r.ALWAYS="ALWAYS",exports.DisplayAttributesType=void 0,(exports.DisplayAttributesType||(exports.DisplayAttributesType={})).URL="URL",exports.LogicalConditionType=void 0,(a=exports.LogicalConditionType||(exports.LogicalConditionType={})).AND="AND",a.OR="OR",exports.ConditionType=void 0,(l=exports.ConditionType||(exports.ConditionType={})).IS="IS",l.IS_NOT="IS_NOT",l.CONTAINS="CONTAINS",l.DOES_NOT_CONTAIN="DOES_NOT_CONTAIN",l.STARTS_WITH="STARTS_WITH",l.ENDS_WITH="ENDS_WITH";var p=function(e,t){void 0===t&&(t=.5);var n=function(e){e=e.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i,(function(e,t,n,i){return t+t+n+n+i+i}));var t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);return t?{r:parseInt(t[1],16),g:parseInt(t[2],16),b:parseInt(t[3],16)}:{r:0,g:0,b:0}}(e),i=function(e,t,n){var i=[e,t,n].map((function(e){return(e/=255)<=.03928?e/12.92:Math.pow((e+.055)/1.055,2.4)}));return.2126*i[0]+.7152*i[1]+.0722*i[2]}(n.r,n.g,n.b);return i>t?"#0E0E0F":"#FFFFFF"},f={log:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];console.log.apply(console,e)},error:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];console.error.apply(console,e)},warn:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];console.warn.apply(console,e)},info:function(){}};f.log("Raw API_URL:","https://api.robylon.ai");var m={copilotUrl:"https://chatbot.robylon.ai",environment:"production",apiUrl:"https://api.robylon.ai"};f.log("CONFIG",m);var h,v,g=function(){return"undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement},y=function(){return{copilotUrl:m.copilotUrl||"https://app.robylon.ai",environment:m.environment||"production",apiUrl:m.apiUrl||"https://app.robylon.ai"}};!function(e){e.CHATBOT_BUTTON_LOADED="CHATBOT_BUTTON_LOADED",e.CHATBOT_BUTTON_CLICKED="CHATBOT_BUTTON_CLICKED",e.CHATBOT_OPENED="CHATBOT_OPENED",e.CHATBOT_CLOSED="CHATBOT_CLOSED",e.CHATBOT_APP_READY="CHATBOT_APP_READY",e.CHATBOT_LOADED="CHATBOT_LOADED",e.CHAT_INITIALIZED="CHAT_INITIALIZED",e.SESSION_REFRESHED="SESSION_REFRESHED",e.CHAT_INITIALIZATION_FAILED="CHAT_INITIALIZATION_FAILED",e.CHATBOT_READY="CHATBOT_READY"}(h||(h={})),function(e){e.CHAT_MOVED="CHAT_MOVED",e.CHATBOT_TOKEN_EXHAUSTED="CHATBOT_TOKEN_EXHAUSTED"}(v||(v={}));var b,_="system-ui, Inter, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'",w="21px",E="",T=[],x=!1,I=function(){return"undefined"==typeof window?"":window.location.href},S=function(){return I()},C=function(){var e=I();e!==E&&(E=e,T.forEach((function(t){return t(e)})))},A=function(e){return x||O(),T.push(e),e(I()),function(){var t=T.indexOf(e);t>-1&&T.splice(t,1)}},O=function(){if(!x&&"undefined"!=typeof window){x=!0,E=I();var e=function(e){var t=history[e];return function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=t.apply(this,e);return setTimeout(C,0),i}};try{history.pushState=e("pushState"),history.replaceState=e("replaceState")}catch(e){}window.addEventListener("popstate",C),window.addEventListener("hashchange",C);var t=setInterval((function(){C()}),1e3);setInterval((function(){0===T.length&&(clearInterval(t),window.removeEventListener("popstate",C),window.removeEventListener("hashchange",C),x=!1)}),5e3)}},R=function(e,t,n,i){var o=t||"",r=I(),a=i||r,l=function(e,t){var n=/^https?:\/\//i.test(e),i=/(^|\.)[\w-]+\.[a-z]{2,}(\/|$)/i.test(e)||/www\./i.test(e);if(n||i)return-1!==t.indexOf(e);try{var o=new URL(t);return-1!=="".concat(o.pathname).concat(o.search).concat(o.hash).indexOf(e)}catch(n){return-1!==t.indexOf(e)}}(o,a);switch(n){case exports.ConditionType.IS:return a===o;case exports.ConditionType.IS_NOT:return a!==o;case exports.ConditionType.CONTAINS:return l;case exports.ConditionType.DOES_NOT_CONTAIN:return!l;case exports.ConditionType.STARTS_WITH:return a.startsWith(o);case exports.ConditionType.ENDS_WITH:return a.endsWith(o);default:return!1}},D=null,
|
|
1
|
+
"use strict";var e=require("react"),t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},t(e,n)};var n,i,o,r,a,l,s=function(){return s=Object.assign||function(e){for(var t,n=1,i=arguments.length;n<i;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},s.apply(this,arguments)};function c(e,t,n,i){return new(n||(n=Promise))((function(o,r){function a(e){try{s(i.next(e))}catch(e){r(e)}}function l(e){try{s(i.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,l)}s((i=i.apply(e,t||[])).next())}))}function d(e,t){var n,i,o,r={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=l(0),a.throw=l(1),a.return=l(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function l(l){return function(s){return function(l){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,l[0]&&(r=0)),r;)try{if(n=1,i&&(o=2&l[0]?i.return:l[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,l[1])).done)return o;switch(i=0,o&&(l=[2&l[0],o.value]),l[0]){case 0:case 1:o=l;break;case 4:return r.label++,{value:l[1],done:!1};case 5:r.label++,i=l[1],l=[0];continue;case 7:l=r.ops.pop(),r.trys.pop();continue;default:if(!(o=r.trys,(o=o.length>0&&o[o.length-1])||6!==l[0]&&2!==l[0])){r=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]<o[3])){r.label=l[1];break}if(6===l[0]&&r.label<o[1]){r.label=o[1],o=l;break}if(o&&r.label<o[2]){r.label=o[2],r.ops.push(l);break}o[2]&&r.ops.pop(),r.trys.pop();continue}l=t.call(e,r)}catch(e){l=[6,e],i=0}finally{n=o=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}([l,s])}}}function u(e,t,n){if(n||2===arguments.length)for(var i,o=0,r=t.length;o<r;o++)!i&&o in t||(i||(i=Array.prototype.slice.call(t,0,o)),i[o]=t[o]);return e.concat(i||Array.prototype.slice.call(t))}"function"==typeof SuppressedError&&SuppressedError,exports.ChatbotInterfaceType=void 0,(n=exports.ChatbotInterfaceType||(exports.ChatbotInterfaceType={})).WIDGET="WIDGET",n.POPOVER="POPOVER",n.EMBED="EMBED",exports.WidgetPositionEnums=void 0,(i=exports.WidgetPositionEnums||(exports.WidgetPositionEnums={})).RIGHT="Right",i.LEFT="Left",exports.LauncherType=void 0,(o=exports.LauncherType||(exports.LauncherType={})).TEXT="TEXT",o.IMAGE="IMAGE",o.TEXTUAL_IMAGE="TEXTUAL_IMAGE",exports.ProactiveSendTimeType=void 0,(r=exports.ProactiveSendTimeType||(exports.ProactiveSendTimeType={})).WORKING_HOURS="WORKING_HOURS",r.ALWAYS="ALWAYS",exports.DisplayAttributesType=void 0,(exports.DisplayAttributesType||(exports.DisplayAttributesType={})).URL="URL",exports.LogicalConditionType=void 0,(a=exports.LogicalConditionType||(exports.LogicalConditionType={})).AND="AND",a.OR="OR",exports.ConditionType=void 0,(l=exports.ConditionType||(exports.ConditionType={})).IS="IS",l.IS_NOT="IS_NOT",l.CONTAINS="CONTAINS",l.DOES_NOT_CONTAIN="DOES_NOT_CONTAIN",l.STARTS_WITH="STARTS_WITH",l.ENDS_WITH="ENDS_WITH";var p=function(e,t){void 0===t&&(t=.5);var n=function(e){e=e.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i,(function(e,t,n,i){return t+t+n+n+i+i}));var t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);return t?{r:parseInt(t[1],16),g:parseInt(t[2],16),b:parseInt(t[3],16)}:{r:0,g:0,b:0}}(e),i=function(e,t,n){var i=[e,t,n].map((function(e){return(e/=255)<=.03928?e/12.92:Math.pow((e+.055)/1.055,2.4)}));return.2126*i[0]+.7152*i[1]+.0722*i[2]}(n.r,n.g,n.b);return i>t?"#0E0E0F":"#FFFFFF"},f={log:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];console.log.apply(console,e)},error:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];console.error.apply(console,e)},warn:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];console.warn.apply(console,e)},info:function(){}};f.log("Raw API_URL:","https://api.robylon.ai");var m={copilotUrl:"https://chatbot.robylon.ai",environment:"production",apiUrl:"https://api.robylon.ai"};f.log("CONFIG",m);var h,v,g=function(){return"undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement},y=function(){return{copilotUrl:m.copilotUrl||"https://app.robylon.ai",environment:m.environment||"production",apiUrl:m.apiUrl||"https://app.robylon.ai"}};!function(e){e.CHATBOT_BUTTON_LOADED="CHATBOT_BUTTON_LOADED",e.CHATBOT_BUTTON_CLICKED="CHATBOT_BUTTON_CLICKED",e.CHATBOT_OPENED="CHATBOT_OPENED",e.CHATBOT_CLOSED="CHATBOT_CLOSED",e.CHATBOT_APP_READY="CHATBOT_APP_READY",e.CHATBOT_LOADED="CHATBOT_LOADED",e.CHAT_INITIALIZED="CHAT_INITIALIZED",e.SESSION_REFRESHED="SESSION_REFRESHED",e.CHAT_INITIALIZATION_FAILED="CHAT_INITIALIZATION_FAILED",e.CHATBOT_READY="CHATBOT_READY"}(h||(h={})),function(e){e.CHAT_MOVED="CHAT_MOVED",e.CHATBOT_TOKEN_EXHAUSTED="CHATBOT_TOKEN_EXHAUSTED"}(v||(v={}));var b,_="system-ui, Inter, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'",w="21px",E="",T=[],x=!1,I=function(){return"undefined"==typeof window?"":window.location.href},S=function(){return I()},C=function(){var e=I();e!==E&&(E=e,T.forEach((function(t){return t(e)})))},A=function(e){return x||O(),T.push(e),e(I()),function(){var t=T.indexOf(e);t>-1&&T.splice(t,1)}},O=function(){if(!x&&"undefined"!=typeof window){x=!0,E=I();var e=function(e){var t=history[e];return function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=t.apply(this,e);return setTimeout(C,0),i}};try{history.pushState=e("pushState"),history.replaceState=e("replaceState")}catch(e){}window.addEventListener("popstate",C),window.addEventListener("hashchange",C);var t=setInterval((function(){C()}),1e3);setInterval((function(){0===T.length&&(clearInterval(t),window.removeEventListener("popstate",C),window.removeEventListener("hashchange",C),x=!1)}),5e3)}},R=function(e,t,n,i){var o=t||"",r=I(),a=i||r,l=function(e,t){var n=/^https?:\/\//i.test(e),i=/(^|\.)[\w-]+\.[a-z]{2,}(\/|$)/i.test(e)||/www\./i.test(e);if(n||i)return-1!==t.indexOf(e);try{var o=new URL(t);return-1!=="".concat(o.pathname).concat(o.search).concat(o.hash).indexOf(e)}catch(n){return-1!==t.indexOf(e)}}(o,a);switch(n){case exports.ConditionType.IS:return a===o;case exports.ConditionType.IS_NOT:return a!==o;case exports.ConditionType.CONTAINS:return l;case exports.ConditionType.DOES_NOT_CONTAIN:return!l;case exports.ConditionType.STARTS_WITH:return a.startsWith(o);case exports.ConditionType.ENDS_WITH:return a.endsWith(o);default:return!1}},D=null,N=null,L=function(){D=S()},k=function(){return D===S()},M=function(e){N=s({input_id:null},e)},z=function(){var e=N;return N=null,e},H=function(){return!0},F=((b={})[exports.ProactiveSendTimeType.WORKING_HOURS]=function(e,t){var n=t.getHours(),i=t.getMinutes();return(n>10||10===n&&i>=0)&&(n<19||19===n&&0===i)},b[exports.ProactiveSendTimeType.ALWAYS]=H,b),U=function(e){if(!e||k())return[];var t=I(),n=new Date,i=[];return e.forEach((function(e){i.push.apply(i,function(e,t,n){var i=(null==e?void 0:e.send_time_type)||"",o=i?F[i]:H;if(!o||!o(e,n))return[];for(var r=(null==e?void 0:e.content_multiple)||[],a=Math.max(0,1e3*Number((null==e?void 0:e.delay)||0)),l=[],s=0;s<r.length;s++){for(var c=r[s],d=(null==c?void 0:c.message_display_attributes)||[],u=null,p=exports.LogicalConditionType.OR,f=0,m=d;f<m.length;f++){var h=m[f];if(null==h?void 0:h.logical_condition)p=h.logical_condition;else{var v=h,g=R(null==v||v.type,(null==v?void 0:v.value)||"",null==v?void 0:v.condition,t);u=null===u?g:p===exports.LogicalConditionType.AND?u&&g:u||g}}(null===u||u)&&(null==c?void 0:c.message)&&l.push({messageId:(null==e?void 0:e.message_id)||String(s),contentIndex:s,html:String(c.message),delayMs:a})}return l}(e,t,n))})),i};
|
|
2
2
|
/*! @license DOMPurify 3.3.0 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.3.0/LICENSE */
|
|
3
|
-
const{entries:P,setPrototypeOf:B,isFrozen:W,getPrototypeOf:j,getOwnPropertyDescriptor:G}=Object;let{freeze:X,seal:V,create:Y}=Object,{apply:K,construct:J}="undefined"!=typeof Reflect&&Reflect;X||(X=function(e){return e}),V||(V=function(e){return e}),K||(K=function(e,t){for(var n=arguments.length,i=new Array(n>2?n-2:0),o=2;o<n;o++)i[o-2]=arguments[o];return e.apply(t,i)}),J||(J=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];return new e(...n)});const Z=ue(Array.prototype.forEach),q=ue(Array.prototype.lastIndexOf),Q=ue(Array.prototype.pop),$=ue(Array.prototype.push),ee=ue(Array.prototype.splice),te=ue(String.prototype.toLowerCase),ne=ue(String.prototype.toString),ie=ue(String.prototype.match),oe=ue(String.prototype.replace),re=ue(String.prototype.indexOf),ae=ue(String.prototype.trim),le=ue(Object.prototype.hasOwnProperty),se=ue(RegExp.prototype.test),ce=(de=TypeError,function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return J(de,t)});var de;function ue(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,i=new Array(n>1?n-1:0),o=1;o<n;o++)i[o-1]=arguments[o];return K(e,t,i)}}function pe(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:te;B&&B(e,null);let i=t.length;for(;i--;){let o=t[i];if("string"==typeof o){const e=n(o);e!==o&&(W(t)||(t[i]=e),o=e)}e[o]=!0}return e}function fe(e){for(let t=0;t<e.length;t++){le(e,t)||(e[t]=null)}return e}function me(e){const t=Y(null);for(const[n,i]of P(e)){le(e,n)&&(Array.isArray(i)?t[n]=fe(i):i&&"object"==typeof i&&i.constructor===Object?t[n]=me(i):t[n]=i)}return t}function he(e,t){for(;null!==e;){const n=G(e,t);if(n){if(n.get)return ue(n.get);if("function"==typeof n.value)return ue(n.value)}e=j(e)}return function(){return null}}const ve=X(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),ge=X(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),ye=X(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),be=X(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),_e=X(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),we=X(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Ee=X(["#text"]),Te=X(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),xe=X(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),Ie=X(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Se=X(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Ce=V(/\{\{[\w\W]*|[\w\W]*\}\}/gm),Ae=V(/<%[\w\W]*|[\w\W]*%>/gm),Oe=V(/\$\{[\w\W]*/gm),Re=V(/^data-[\-\w.\u00B7-\uFFFF]+$/),De=V(/^aria-[\-\w]+$/),Le=V(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Ne=V(/^(?:\w+script|data):/i),ke=V(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Me=V(/^html$/i),ze=V(/^[a-z][.\w]*(-[.\w]+)+$/i);var He=Object.freeze({__proto__:null,ARIA_ATTR:De,ATTR_WHITESPACE:ke,CUSTOM_ELEMENT:ze,DATA_ATTR:Re,DOCTYPE_NAME:Me,ERB_EXPR:Ae,IS_ALLOWED_URI:Le,IS_SCRIPT_OR_DATA:Ne,MUSTACHE_EXPR:Ce,TMPLIT_EXPR:Oe});const Fe=1,Ue=3,Pe=7,Be=8,We=9,je=function(){return"undefined"==typeof window?null:window};var Ge,Xe=function e(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:je();const n=t=>e(t);if(n.version="3.3.0",n.removed=[],!t||!t.document||t.document.nodeType!==We||!t.Element)return n.isSupported=!1,n;let{document:i}=t;const o=i,r=o.currentScript,{DocumentFragment:a,HTMLTemplateElement:l,Node:s,Element:c,NodeFilter:d,NamedNodeMap:u=t.NamedNodeMap||t.MozNamedAttrMap,HTMLFormElement:p,DOMParser:f,trustedTypes:m}=t,h=c.prototype,v=he(h,"cloneNode"),g=he(h,"remove"),y=he(h,"nextSibling"),b=he(h,"childNodes"),_=he(h,"parentNode");if("function"==typeof l){const e=i.createElement("template");e.content&&e.content.ownerDocument&&(i=e.content.ownerDocument)}let w,E="";const{implementation:T,createNodeIterator:x,createDocumentFragment:I,getElementsByTagName:S}=i,{importNode:C}=o;let A={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]};n.isSupported="function"==typeof P&&"function"==typeof _&&T&&void 0!==T.createHTMLDocument;const{MUSTACHE_EXPR:O,ERB_EXPR:R,TMPLIT_EXPR:D,DATA_ATTR:L,ARIA_ATTR:N,IS_SCRIPT_OR_DATA:k,ATTR_WHITESPACE:M,CUSTOM_ELEMENT:z}=He;let{IS_ALLOWED_URI:H}=He,F=null;const U=pe({},[...ve,...ge,...ye,..._e,...Ee]);let B=null;const W=pe({},[...Te,...xe,...Ie,...Se]);let j=Object.seal(Y(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),G=null,V=null;const K=Object.seal(Y(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let J=!0,de=!0,ue=!1,fe=!0,Ce=!1,Ae=!0,Oe=!1,Re=!1,De=!1,Ne=!1,ke=!1,ze=!1,Ge=!0,Xe=!1,Ve=!0,Ye=!1,Ke={},Je=null;const Ze=pe({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let qe=null;const Qe=pe({},["audio","video","img","source","image","track"]);let $e=null;const et=pe({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),tt="http://www.w3.org/1998/Math/MathML",nt="http://www.w3.org/2000/svg",it="http://www.w3.org/1999/xhtml";let ot=it,rt=!1,at=null;const lt=pe({},[tt,nt,it],ne);let st=pe({},["mi","mo","mn","ms","mtext"]),ct=pe({},["annotation-xml"]);const dt=pe({},["title","style","font","a","script"]);let ut=null;const pt=["application/xhtml+xml","text/html"];let ft=null,mt=null;const ht=i.createElement("form"),vt=function(e){return e instanceof RegExp||e instanceof Function},gt=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!mt||mt!==e){if(e&&"object"==typeof e||(e={}),e=me(e),ut=-1===pt.indexOf(e.PARSER_MEDIA_TYPE)?"text/html":e.PARSER_MEDIA_TYPE,ft="application/xhtml+xml"===ut?ne:te,F=le(e,"ALLOWED_TAGS")?pe({},e.ALLOWED_TAGS,ft):U,B=le(e,"ALLOWED_ATTR")?pe({},e.ALLOWED_ATTR,ft):W,at=le(e,"ALLOWED_NAMESPACES")?pe({},e.ALLOWED_NAMESPACES,ne):lt,$e=le(e,"ADD_URI_SAFE_ATTR")?pe(me(et),e.ADD_URI_SAFE_ATTR,ft):et,qe=le(e,"ADD_DATA_URI_TAGS")?pe(me(Qe),e.ADD_DATA_URI_TAGS,ft):Qe,Je=le(e,"FORBID_CONTENTS")?pe({},e.FORBID_CONTENTS,ft):Ze,G=le(e,"FORBID_TAGS")?pe({},e.FORBID_TAGS,ft):me({}),V=le(e,"FORBID_ATTR")?pe({},e.FORBID_ATTR,ft):me({}),Ke=!!le(e,"USE_PROFILES")&&e.USE_PROFILES,J=!1!==e.ALLOW_ARIA_ATTR,de=!1!==e.ALLOW_DATA_ATTR,ue=e.ALLOW_UNKNOWN_PROTOCOLS||!1,fe=!1!==e.ALLOW_SELF_CLOSE_IN_ATTR,Ce=e.SAFE_FOR_TEMPLATES||!1,Ae=!1!==e.SAFE_FOR_XML,Oe=e.WHOLE_DOCUMENT||!1,Ne=e.RETURN_DOM||!1,ke=e.RETURN_DOM_FRAGMENT||!1,ze=e.RETURN_TRUSTED_TYPE||!1,De=e.FORCE_BODY||!1,Ge=!1!==e.SANITIZE_DOM,Xe=e.SANITIZE_NAMED_PROPS||!1,Ve=!1!==e.KEEP_CONTENT,Ye=e.IN_PLACE||!1,H=e.ALLOWED_URI_REGEXP||Le,ot=e.NAMESPACE||it,st=e.MATHML_TEXT_INTEGRATION_POINTS||st,ct=e.HTML_INTEGRATION_POINTS||ct,j=e.CUSTOM_ELEMENT_HANDLING||{},e.CUSTOM_ELEMENT_HANDLING&&vt(e.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(j.tagNameCheck=e.CUSTOM_ELEMENT_HANDLING.tagNameCheck),e.CUSTOM_ELEMENT_HANDLING&&vt(e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(j.attributeNameCheck=e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),e.CUSTOM_ELEMENT_HANDLING&&"boolean"==typeof e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements&&(j.allowCustomizedBuiltInElements=e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),Ce&&(de=!1),ke&&(Ne=!0),Ke&&(F=pe({},Ee),B=[],!0===Ke.html&&(pe(F,ve),pe(B,Te)),!0===Ke.svg&&(pe(F,ge),pe(B,xe),pe(B,Se)),!0===Ke.svgFilters&&(pe(F,ye),pe(B,xe),pe(B,Se)),!0===Ke.mathMl&&(pe(F,_e),pe(B,Ie),pe(B,Se))),e.ADD_TAGS&&("function"==typeof e.ADD_TAGS?K.tagCheck=e.ADD_TAGS:(F===U&&(F=me(F)),pe(F,e.ADD_TAGS,ft))),e.ADD_ATTR&&("function"==typeof e.ADD_ATTR?K.attributeCheck=e.ADD_ATTR:(B===W&&(B=me(B)),pe(B,e.ADD_ATTR,ft))),e.ADD_URI_SAFE_ATTR&&pe($e,e.ADD_URI_SAFE_ATTR,ft),e.FORBID_CONTENTS&&(Je===Ze&&(Je=me(Je)),pe(Je,e.FORBID_CONTENTS,ft)),Ve&&(F["#text"]=!0),Oe&&pe(F,["html","head","body"]),F.table&&(pe(F,["tbody"]),delete G.tbody),e.TRUSTED_TYPES_POLICY){if("function"!=typeof e.TRUSTED_TYPES_POLICY.createHTML)throw ce('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if("function"!=typeof e.TRUSTED_TYPES_POLICY.createScriptURL)throw ce('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');w=e.TRUSTED_TYPES_POLICY,E=w.createHTML("")}else void 0===w&&(w=function(e,t){if("object"!=typeof e||"function"!=typeof e.createPolicy)return null;let n=null;const i="data-tt-policy-suffix";t&&t.hasAttribute(i)&&(n=t.getAttribute(i));const o="dompurify"+(n?"#"+n:"");try{return e.createPolicy(o,{createHTML:e=>e,createScriptURL:e=>e})}catch(e){return console.warn("TrustedTypes policy "+o+" could not be created."),null}}(m,r)),null!==w&&"string"==typeof E&&(E=w.createHTML(""));X&&X(e),mt=e}},yt=pe({},[...ge,...ye,...be]),bt=pe({},[..._e,...we]),_t=function(e){$(n.removed,{element:e});try{_(e).removeChild(e)}catch(t){g(e)}},wt=function(e,t){try{$(n.removed,{attribute:t.getAttributeNode(e),from:t})}catch(e){$(n.removed,{attribute:null,from:t})}if(t.removeAttribute(e),"is"===e)if(Ne||ke)try{_t(t)}catch(e){}else try{t.setAttribute(e,"")}catch(e){}},Et=function(e){let t=null,n=null;if(De)e="<remove></remove>"+e;else{const t=ie(e,/^[\r\n\t ]+/);n=t&&t[0]}"application/xhtml+xml"===ut&&ot===it&&(e='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+e+"</body></html>");const o=w?w.createHTML(e):e;if(ot===it)try{t=(new f).parseFromString(o,ut)}catch(e){}if(!t||!t.documentElement){t=T.createDocument(ot,"template",null);try{t.documentElement.innerHTML=rt?E:o}catch(e){}}const r=t.body||t.documentElement;return e&&n&&r.insertBefore(i.createTextNode(n),r.childNodes[0]||null),ot===it?S.call(t,Oe?"html":"body")[0]:Oe?t.documentElement:r},Tt=function(e){return x.call(e.ownerDocument||e,e,d.SHOW_ELEMENT|d.SHOW_COMMENT|d.SHOW_TEXT|d.SHOW_PROCESSING_INSTRUCTION|d.SHOW_CDATA_SECTION,null)},xt=function(e){return e instanceof p&&("string"!=typeof e.nodeName||"string"!=typeof e.textContent||"function"!=typeof e.removeChild||!(e.attributes instanceof u)||"function"!=typeof e.removeAttribute||"function"!=typeof e.setAttribute||"string"!=typeof e.namespaceURI||"function"!=typeof e.insertBefore||"function"!=typeof e.hasChildNodes)},It=function(e){return"function"==typeof s&&e instanceof s};function St(e,t,i){Z(e,(e=>{e.call(n,t,i,mt)}))}const Ct=function(e){let t=null;if(St(A.beforeSanitizeElements,e,null),xt(e))return _t(e),!0;const i=ft(e.nodeName);if(St(A.uponSanitizeElement,e,{tagName:i,allowedTags:F}),Ae&&e.hasChildNodes()&&!It(e.firstElementChild)&&se(/<[/\w!]/g,e.innerHTML)&&se(/<[/\w!]/g,e.textContent))return _t(e),!0;if(e.nodeType===Pe)return _t(e),!0;if(Ae&&e.nodeType===Be&&se(/<[/\w]/g,e.data))return _t(e),!0;if(!(K.tagCheck instanceof Function&&K.tagCheck(i))&&(!F[i]||G[i])){if(!G[i]&&Ot(i)){if(j.tagNameCheck instanceof RegExp&&se(j.tagNameCheck,i))return!1;if(j.tagNameCheck instanceof Function&&j.tagNameCheck(i))return!1}if(Ve&&!Je[i]){const t=_(e)||e.parentNode,n=b(e)||e.childNodes;if(n&&t){for(let i=n.length-1;i>=0;--i){const o=v(n[i],!0);o.__removalCount=(e.__removalCount||0)+1,t.insertBefore(o,y(e))}}}return _t(e),!0}return e instanceof c&&!function(e){let t=_(e);t&&t.tagName||(t={namespaceURI:ot,tagName:"template"});const n=te(e.tagName),i=te(t.tagName);return!!at[e.namespaceURI]&&(e.namespaceURI===nt?t.namespaceURI===it?"svg"===n:t.namespaceURI===tt?"svg"===n&&("annotation-xml"===i||st[i]):Boolean(yt[n]):e.namespaceURI===tt?t.namespaceURI===it?"math"===n:t.namespaceURI===nt?"math"===n&&ct[i]:Boolean(bt[n]):e.namespaceURI===it?!(t.namespaceURI===nt&&!ct[i])&&!(t.namespaceURI===tt&&!st[i])&&!bt[n]&&(dt[n]||!yt[n]):!("application/xhtml+xml"!==ut||!at[e.namespaceURI]))}(e)?(_t(e),!0):"noscript"!==i&&"noembed"!==i&&"noframes"!==i||!se(/<\/no(script|embed|frames)/i,e.innerHTML)?(Ce&&e.nodeType===Ue&&(t=e.textContent,Z([O,R,D],(e=>{t=oe(t,e," ")})),e.textContent!==t&&($(n.removed,{element:e.cloneNode()}),e.textContent=t)),St(A.afterSanitizeElements,e,null),!1):(_t(e),!0)},At=function(e,t,n){if(Ge&&("id"===t||"name"===t)&&(n in i||n in ht))return!1;if(de&&!V[t]&&se(L,t));else if(J&&se(N,t));else if(K.attributeCheck instanceof Function&&K.attributeCheck(t,e));else if(!B[t]||V[t]){if(!(Ot(e)&&(j.tagNameCheck instanceof RegExp&&se(j.tagNameCheck,e)||j.tagNameCheck instanceof Function&&j.tagNameCheck(e))&&(j.attributeNameCheck instanceof RegExp&&se(j.attributeNameCheck,t)||j.attributeNameCheck instanceof Function&&j.attributeNameCheck(t,e))||"is"===t&&j.allowCustomizedBuiltInElements&&(j.tagNameCheck instanceof RegExp&&se(j.tagNameCheck,n)||j.tagNameCheck instanceof Function&&j.tagNameCheck(n))))return!1}else if($e[t]);else if(se(H,oe(n,M,"")));else if("src"!==t&&"xlink:href"!==t&&"href"!==t||"script"===e||0!==re(n,"data:")||!qe[e]){if(ue&&!se(k,oe(n,M,"")));else if(n)return!1}else;return!0},Ot=function(e){return"annotation-xml"!==e&&ie(e,z)},Rt=function(e){St(A.beforeSanitizeAttributes,e,null);const{attributes:t}=e;if(!t||xt(e))return;const i={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:B,forceKeepAttr:void 0};let o=t.length;for(;o--;){const r=t[o],{name:a,namespaceURI:l,value:s}=r,c=ft(a),d=s;let u="value"===a?d:ae(d);if(i.attrName=c,i.attrValue=u,i.keepAttr=!0,i.forceKeepAttr=void 0,St(A.uponSanitizeAttribute,e,i),u=i.attrValue,!Xe||"id"!==c&&"name"!==c||(wt(a,e),u="user-content-"+u),Ae&&se(/((--!?|])>)|<\/(style|title|textarea)/i,u)){wt(a,e);continue}if("attributename"===c&&ie(u,"href")){wt(a,e);continue}if(i.forceKeepAttr)continue;if(!i.keepAttr){wt(a,e);continue}if(!fe&&se(/\/>/i,u)){wt(a,e);continue}Ce&&Z([O,R,D],(e=>{u=oe(u,e," ")}));const p=ft(e.nodeName);if(At(p,c,u)){if(w&&"object"==typeof m&&"function"==typeof m.getAttributeType)if(l);else switch(m.getAttributeType(p,c)){case"TrustedHTML":u=w.createHTML(u);break;case"TrustedScriptURL":u=w.createScriptURL(u)}if(u!==d)try{l?e.setAttributeNS(l,a,u):e.setAttribute(a,u),xt(e)?_t(e):Q(n.removed)}catch(t){wt(a,e)}}else wt(a,e)}St(A.afterSanitizeAttributes,e,null)},Dt=function e(t){let n=null;const i=Tt(t);for(St(A.beforeSanitizeShadowDOM,t,null);n=i.nextNode();)St(A.uponSanitizeShadowNode,n,null),Ct(n),Rt(n),n.content instanceof a&&e(n.content);St(A.afterSanitizeShadowDOM,t,null)};return n.sanitize=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=null,r=null,l=null,c=null;if(rt=!e,rt&&(e="\x3c!--\x3e"),"string"!=typeof e&&!It(e)){if("function"!=typeof e.toString)throw ce("toString is not a function");if("string"!=typeof(e=e.toString()))throw ce("dirty is not a string, aborting")}if(!n.isSupported)return e;if(Re||gt(t),n.removed=[],"string"==typeof e&&(Ye=!1),Ye){if(e.nodeName){const t=ft(e.nodeName);if(!F[t]||G[t])throw ce("root node is forbidden and cannot be sanitized in-place")}}else if(e instanceof s)i=Et("\x3c!----\x3e"),r=i.ownerDocument.importNode(e,!0),r.nodeType===Fe&&"BODY"===r.nodeName||"HTML"===r.nodeName?i=r:i.appendChild(r);else{if(!Ne&&!Ce&&!Oe&&-1===e.indexOf("<"))return w&&ze?w.createHTML(e):e;if(i=Et(e),!i)return Ne?null:ze?E:""}i&&De&&_t(i.firstChild);const d=Tt(Ye?e:i);for(;l=d.nextNode();)Ct(l),Rt(l),l.content instanceof a&&Dt(l.content);if(Ye)return e;if(Ne){if(ke)for(c=I.call(i.ownerDocument);i.firstChild;)c.appendChild(i.firstChild);else c=i;return(B.shadowroot||B.shadowrootmode)&&(c=C.call(o,c,!0)),c}let u=Oe?i.outerHTML:i.innerHTML;return Oe&&F["!doctype"]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&se(Me,i.ownerDocument.doctype.name)&&(u="<!DOCTYPE "+i.ownerDocument.doctype.name+">\n"+u),Ce&&Z([O,R,D],(e=>{u=oe(u,e," ")})),w&&ze?w.createHTML(u):u},n.setConfig=function(){gt(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),Re=!0},n.clearConfig=function(){mt=null,Re=!1},n.isValidAttribute=function(e,t,n){mt||gt({});const i=ft(e),o=ft(t);return At(i,o,n)},n.addHook=function(e,t){"function"==typeof t&&$(A[e],t)},n.removeHook=function(e,t){if(void 0!==t){const n=q(A[e],t);return-1===n?void 0:ee(A[e],n,1)[0]}return Q(A[e])},n.removeHooks=function(e){A[e]=[]},n.removeAllHooks=function(){A={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},n}(),Ve=function(e){return e?Xe.sanitize(e,{ALLOWED_TAGS:["b","strong","i","em","u","br","span","a","p","s"],ALLOWED_ATTR:["href","target","rel","style"],ALLOW_ARIA_ATTR:!1,ALLOW_DATA_ATTR:!1,RETURN_TRUSTED_TYPE:!1}):""},Ye=e.memo((function(t){var n,i,o,r,a,l,c,d,m,v,g,b,E,T,x,I,S,C=t.config,O=t.toggleIframe,R=t.isIframeVisible,D=t.onEvent,L=t.onInternalEvent,z=t.position,H=t.sideSpacing,F=t.bottomSpacing,P=t.launcher_type,B=t.launcher_properties_text,W=t.shouldFadeIn,j=e.useRef(null),G=y().copilotUrl,X=e.useState(!1),V=X[0],Y=X[1],K=e.useState(!1),J=K[0],Z=K[1],q=e.useState([]),Q=q[0],$=q[1],ee=e.useState(!1),te=ee[0],ne=ee[1],ie=e.useRef([]),oe=e.useRef();e.useEffect((function(){var e=function(){var e=(null===window||void 0===window?void 0:window.innerWidth)<560;Y(e)};return e(),window.addEventListener("resize",e),function(){window.removeEventListener("resize",e)}}),[]),e.useEffect((function(){j.current&&requestAnimationFrame((function(){null==D||D({type:h.CHATBOT_BUTTON_LOADED,timestamp:Date.now()}),L(h.CHATBOT_BUTTON_LOADED)}))}),[D,L]),e.useEffect((function(){if(j.current&&W){j.current.style.opacity="0";var e=requestAnimationFrame((function(){j.current&&(j.current.style.opacity="1")}));return function(){return cancelAnimationFrame(e)}}}),[W]);var re=z||(null===(o=C.interface_properties)||void 0===o?void 0:o.position)||"Right",ae=null!==(a=null!=H?H:null===(r=C.interface_properties)||void 0===r?void 0:r.side_spacing)&&void 0!==a?a:20,le=null!==(c=null!=F?F:null===(l=C.interface_properties)||void 0===l?void 0:l.bottom_spacing)&&void 0!==c?c:20,se=P||(null==C?void 0:C.launcher_type)||exports.LauncherType.IMAGE,ce=B||(null===(d=null==C?void 0:C.launcher_properties)||void 0===d?void 0:d.text),de={zIndex:1e3,display:"flex",flexDirection:"column-reverse",alignItems:"center",justifyContent:"center",cursor:"pointer",overflow:"hidden",marginTop:"16px",boxSizing:"border-box"};se===exports.LauncherType.IMAGE&&(de.width="48px",de.height="48px",de.borderRadius="50%",de.backgroundColor=C.brand_colour);var ue=s(s({},de),((n={position:void 0,bottom:"0",borderRadius:se===exports.LauncherType.IMAGE?"50%":"9999px"})[re.toLowerCase()]="0",n)),pe=s(s({},de),((i={position:"fixed",bottom:"".concat(le,"px"),borderRadius:se===exports.LauncherType.IMAGE?"50%":"9999px"})[re.toLowerCase()]="".concat(ae,"px"),i)),fe=V?pe:ue;e.useEffect((function(){f.log("Screen width changed, isMobile:",V,"Style:",fe)}),[V,fe]),f.log("config in floating button",C);e.useEffect((function(){var e=function(){ie.current.forEach((function(e){return clearTimeout(e)})),ie.current=[]},t=function(){(e(),$([]),(null==C?void 0:C.proactive_message_obj)&&!k())&&U(null==C?void 0:C.proactive_message_obj).forEach((function(e){var t=window.setTimeout((function(){$((function(t){return t.some((function(t){return t.id===e.messageId&&t.index===e.contentIndex}))?t:u(u([],t,!0),[{id:e.messageId,index:e.contentIndex,html:e.html}],!1)}))}),e.delayMs);ie.current.push(t)}))};return oe.current=A((function(){Z(!1),t()})),t(),function(){var t;e(),null===(t=oe.current)||void 0===t||t.call(oe)}}),[null==C?void 0:C.proactive_message_obj]);var me=Q.length>0&&!R&&!J,he="Right"===(z||(null===(m=C.interface_properties)||void 0===m?void 0:m.position)||"Right"),ve=function(){ne(!0),setTimeout((function(){Z(!0),N(),ne(!1)}),400)};return e.createElement(e.Fragment,null,e.createElement("style",null,"\n @keyframes slideInFromRight {\n 0% {\n transform: translateX(120%) scale(0.95);\n opacity: 0;\n }\n 85% {\n transform: translateX(0) scale(1);\n opacity: 1;\n }\n 92% {\n transform: translateX(-1px) scale(1.002);\n }\n 100% {\n transform: translateX(0) scale(1);\n opacity: 1;\n }\n }\n @keyframes slideInFromLeft {\n 0% {\n transform: translateX(-120%) scale(0.95);\n opacity: 0;\n }\n 85% {\n transform: translateX(0) scale(1);\n opacity: 1;\n }\n 92% {\n transform: translateX(1px) scale(1.002);\n }\n 100% {\n transform: translateX(0) scale(1);\n opacity: 1;\n }\n }\n @keyframes slideOutRight {\n 0% {\n transform: translateX(0) scale(1);\n opacity: 1;\n }\n 100% {\n transform: translateX(120%) scale(0.9);\n opacity: 0;\n }\n }\n @keyframes slideOutLeft {\n 0% {\n transform: translateX(0) scale(1);\n opacity: 1;\n }\n 100% {\n transform: translateX(-120%) scale(0.9);\n opacity: 0;\n }\n }\n .proactive-bubble-enter-right {\n animation: slideInFromRight 1.2s cubic-bezier(0.5, 0.8, 0.3, 1.1) forwards;\n }\n .proactive-bubble-enter-left {\n animation: slideInFromLeft 1.2s cubic-bezier(0.5, 0.8, 0.3, 1.1) forwards;\n }\n .proactive-bubble-exit-right {\n animation: slideOutRight 0.4s ease-in forwards;\n }\n .proactive-bubble-exit-left {\n animation: slideOutLeft 0.4s ease-in forwards;\n }\n .proactive-close-enter-right {\n animation: slideInFromRight 1.2s cubic-bezier(0.5, 0.8, 0.3, 1.1) forwards;\n }\n .proactive-close-enter-left {\n animation: slideInFromLeft 1.2s cubic-bezier(0.5, 0.8, 0.3, 1.1) forwards;\n }\n /* Reset styles for proactive message content to prevent website CSS interference */\n /* Only target children of the content wrapper, not the bubble container itself */\n .proactive-message-content * {\n box-sizing: border-box !important;\n margin: 0 !important;\n padding: 0 !important;\n border: none !important;\n background: transparent;\n font-family: ".concat(_,';\n // font-size: inherit;\n // font-weight: inherit;\n line-height: inherit;\n color: inherit;\n text-align: inherit;\n // text-decoration: none ;\n list-style: none !important;\n }\n .proactive-message-content p,\n .proactive-message-content div,\n .proactive-message-content span {\n display: inline !important;\n margin: 0 !important;\n padding: 0 !important;\n }\n .proactive-message-content p:first-child,\n .proactive-message-content div:first-child,\n .proactive-message-content span:first-child {\n margin-top: 0 !important;\n }\n .proactive-message-content p:last-child,\n .proactive-message-content div:last-child,\n .proactive-message-content span:last-child {\n margin-bottom: 0 !important;\n }\n .proactive-message-content a {\n color: inherit !important;\n text-decoration: underline !important;\n cursor: pointer !important;\n }\n .proactive-message-content a:hover {\n opacity: 0.8 !important;\n }\n .proactive-message-content b,\n .proactive-message-content strong {\n font-weight: 600 !important;\n }\n .proactive-message-content i,\n .proactive-message-content em {\n font-style: italic !important;\n }\n .proactive-message-content u {\n text-decoration: underline !important;\n }\n .proactive-message-content br {\n display: block !important;\n content: "" !important;\n margin-top: 0.5em !important;\n }\n ')),me?e.createElement("div",{className:"proactive-message-container",style:{position:"fixed",bottom:"".concat((null!==(g=null!=F?F:null===(v=C.interface_properties)||void 0===v?void 0:v.bottom_spacing)&&void 0!==g?g:20)+(se===exports.LauncherType.IMAGE?48:40)+8,"px"),right:he?"".concat(null!==(E=null!=H?H:null===(b=C.interface_properties)||void 0===b?void 0:b.side_spacing)&&void 0!==E?E:20,"px"):"auto",left:he?"auto":"".concat(null!==(x=null!=H?H:null===(T=C.interface_properties)||void 0===T?void 0:T.side_spacing)&&void 0!==x?x:20,"px"),maxWidth:"22.875rem",zIndex:2147483646}},e.createElement("div",{style:{display:"flex",flexDirection:"column",alignItems:he?"flex-end":"flex-start"},className:"proactive-message-bubble-container"},Q.map((function(t,n){var i=10*(Q.length-1-n);return e.createElement("div",{key:"".concat(t.id,"-").concat(t.index,"-").concat(n),onClick:function(){M({message_id:t.id,content_string:t.html||null}),O(),ve();try{window.dispatchEvent(new CustomEvent("rblyn:proactiveClick",{detail:{message_id:t.id,content_string:t.html||null}}))}catch(e){}},className:te?he?"proactive-bubble-exit-right":"proactive-bubble-exit-left":he?"proactive-bubble-enter-right":"proactive-bubble-enter-left",style:s({background:"#fff",color:"#111",borderRadius:"12px",boxShadow:"0 2px 2px 0 rgba(0, 0, 0, 0.08)",padding:"16px",cursor:"pointer",fontFamily:_,lineHeight:w,fontSize:"14px",marginBottom:n<Q.length-1?16:0,border:"1px solid #F1F2F4",width:"fit-content",maxWidth:"100%",animationDelay:te?"0ms":"".concat(i,"ms")},te?{opacity:0}:{opacity:0,transform:he?"translateX(120%) scale(0.95)":"translateX(-120%) scale(0.95)"})},e.createElement("div",{className:"proactive-message-content",dangerouslySetInnerHTML:{__html:Ve(t.html)}}))}))),e.createElement("div",{onClick:function(e){e.stopPropagation(),ve()},className:te?"":he?"proactive-close-enter-right":"proactive-close-enter-left",style:s({position:"absolute",top:"-32px",right:"Right"===(z||(null===(I=C.interface_properties)||void 0===I?void 0:I.position)||"Right")?"0px":"auto",left:"Left"===(z||(null===(S=C.interface_properties)||void 0===S?void 0:S.position)||"Right")?"0px":"auto",width:"24px",height:"24px",borderRadius:"50%",background:"#fff",boxShadow:" 0 2.667px 2.667px 0 rgba(0, 0, 0, 0.25)",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",userSelect:"none",animationDelay:te?"0ms":"".concat(10*(Q.length-1),"ms")},te?{}:{opacity:0,transform:he?"translateX(120%) scale(0.95)":"translateX(-120%) scale(0.95)"}),"aria-label":"Close proactive message"},e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 14 14",fill:"none"},e.createElement("path",{d:"M10.3334 10.3334L7.00009 7.00009M7.00009 7.00009L3.66675 3.66675M7.00009 7.00009L10.3334 3.66675M7.00009 7.00009L3.66675 10.3334",stroke:"#444547",strokeWidth:"0.816326",strokeLinecap:"round",strokeLinejoin:"round"})))):null,e.createElement("div",{ref:j,className:"message-bubble-container",style:s(s({},fe),{transition:"transform 0.2s cubic-bezier(0.2, 1.27, 0.29, 0.97), opacity 280ms ease",transform:R?"scale(0.85)":"scale(1)",opacity:W?0:1}),onClick:function(){O(),ve()}},function(){switch(se){case exports.LauncherType.TEXT:return e.createElement("div",{style:{width:"fit-content",maxWidth:"160px",height:"40px",borderRadius:"9999px",backgroundColor:C.brand_colour,display:"flex",alignItems:"center",padding:"9px 20px",boxShadow:"0px 0px 16px 0px rgba(0, 0, 0, 0.24)",boxSizing:"border-box",fontFamily:_,lineHeight:w}},e.createElement("div",{style:{flex:1,minWidth:0}},e.createElement("p",{style:{margin:0,color:p(C.brand_colour),fontSize:"0.875rem",fontWeight:600,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",fontFamily:_,lineHeight:w,WebkitFontSmoothing:"antialiased",textRendering:"optimizeLegibility",textSizeAdjust:"100%"}},ce)));case exports.LauncherType.TEXTUAL_IMAGE:return function(){var t,n;return e.createElement("div",{style:{maxWidth:"13rem",width:"fit-content",height:"40px",borderRadius:"9999px",backgroundColor:C.brand_colour,display:"flex",alignItems:"center",paddingLeft:"20px",paddingRight:0,paddingTop:"9px",paddingBottom:"9px",boxShadow:"0px 0px 16px 0px rgba(0, 0, 0, 0.24)",gap:"8px",boxSizing:"border-box",fontFamily:_,lineHeight:w}},e.createElement("div",{style:{flex:1,minWidth:0}},e.createElement("p",{style:{margin:0,color:p(C.brand_colour),fontSize:"0.875rem",fontWeight:600,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",fontFamily:_,lineHeight:w,WebkitFontSmoothing:"antialiased",textRendering:"optimizeLegibility",textSizeAdjust:"100%"}},ce)),e.createElement("div",{style:{width:"40px",height:"40px",borderRadius:"9999px",overflow:"hidden",position:"relative",flexShrink:0}},e.createElement("img",{src:(null==C?void 0:C.launcher_type)?(null===(n=null===(t=null==C?void 0:C.images)||void 0===t?void 0:t.launcher_image_url)||void 0===n?void 0:n.url)||"".concat(G,"/chatbubble.png"):(null==C?void 0:C.image_url)||"".concat(G,"/chatbubble.png"),alt:"Chat",style:{width:"100%",height:"100%",objectFit:"cover"}})))}();case exports.LauncherType.IMAGE:default:return function(){var t,n;return R?e.createElement("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e.createElement("g",{id:"Chevron_Down"},e.createElement("path",{id:"Vector",d:"M19 9L12 16L5 9",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}))):e.createElement("img",{src:(null==C?void 0:C.launcher_type)?(null===(n=null===(t=null==C?void 0:C.images)||void 0===t?void 0:t.launcher_image_url)||void 0===n?void 0:n.url)||"".concat(G,"/chatbubble.png"):(null==C?void 0:C.image_url)||"".concat(G,"/chatbubble.png"),alt:"Chat",style:{zIndex:1e3,cursor:"pointer",borderRadius:"50%",objectFit:"cover",width:"100%",height:"100%",boxSizing:"border-box"}})}()}}()))})),Ke=function(){var e;return(null===(e=navigator.userAgentData)||void 0===e?void 0:e.platform)||(/Windows|Mac|Linux|Android|iOS/.exec(navigator.userAgent)||["Unknown"])[0]},Je=function(){var e;if(null===(e=navigator.userAgentData)||void 0===e?void 0:e.brands)for(var t=["Chrome","Firefox","Safari","Edge","Opera"],n=0,i=navigator.userAgentData.brands;n<i.length;n++){var o=i[n];if(t.includes(o.brand))return o.brand}return(/Chrome|Firefox|Safari|Edge|Opera/.exec(navigator.userAgent)||["Unknown"])[0]},Ze=function(){var e,t,n,i;return{width:(null===window||void 0===window?void 0:window.innerWidth)||(null===(e=null===document||void 0===document?void 0:document.documentElement)||void 0===e?void 0:e.clientWidth)||(null===(t=null===document||void 0===document?void 0:document.body)||void 0===t?void 0:t.clientWidth),height:(null===window||void 0===window?void 0:window.innerHeight)||(null===(n=null===document||void 0===document?void 0:document.documentElement)||void 0===n?void 0:n.clientHeight)||(null===(i=null===document||void 0===document?void 0:document.body)||void 0===i?void 0:i.clientHeight)}},qe=function(){return{platform:"web",os:Ke(),browser:Je(),sdk_version:"1.1.43",device:(e=navigator.userAgent.toLowerCase(),/(tablet|ipad|playbook|silk)|(android(?!.*mobi))/i.test(e)?"tablet":/Mobile|Android|iP(hone|od)|IEMobile|BlackBerry|Kindle|Silk-Accelerated|(hpw|web)OS|Opera M(obi|ini)/.test(e)?"mobile":"desktop"),screen_size:Ze()};var e};!function(e){e.ERROR="ERROR",e.INFO="INFO"}(Ge||(Ge={}));var Qe,$e=["@robylon/web-react-sdk","node_modules/@robylon/web-react-sdk/"],et=function(e){var t=e.filename,n=e.stack,i=e.message;return!!(t||n||i)&&$e.some((function(e){return(null==t?void 0:t.includes(e))||(null==n?void 0:n.includes(e))||(null==i?void 0:i.includes(e))}))},tt=function(){function e(){var e=this;this.apiKey="",this.userId=null,this.preInitQueue=[],this.isInitialized=!1,this.handleWindowError=function(t){var n,i={filename:t.filename,stack:null===(n=t.error)||void 0===n?void 0:n.stack,message:t.message};et(i)&&e.trackError(t.error||t.message,"GlobalErrorHandler",{filename:t.filename,lineNo:t.lineno,colNo:t.colno})},this.handleUnhandledRejection=function(t){var n,i,o={stack:null===(n=t.reason)||void 0===n?void 0:n.stack,message:(null===(i=t.reason)||void 0===i?void 0:i.message)||String(t.reason)};et(o)&&e.trackError(t.reason||"Unhandled Promise Rejection","GlobalPromiseHandler",{reason:t.reason})},this.setupGlobalHandlers()}return e.prototype.setupGlobalHandlers=function(){g()&&(null===window||void 0===window||window.addEventListener("error",null==this?void 0:this.handleWindowError),null===window||void 0===window||window.addEventListener("unhandledrejection",this.handleUnhandledRejection))},e.prototype.cleanup=function(){g()&&(null===window||void 0===window||window.removeEventListener("error",null==this?void 0:this.handleWindowError),null===window||void 0===window||window.removeEventListener("unhandledrejection",this.handleUnhandledRejection))},e.getInstance=function(){return e.instance||(e.instance=new e),e.instance},e.prototype.initialize=function(e,t){void 0===t&&(t=null);try{if(this.preInitQueue.length>0){var n={org_id:"UNINITALIZED",event_data:{message:"SDK Initialization Failed: Required parameter 'api_key' is ".concat(void 0===e?"undefined":null===e?"null":""===e?"empty string":"invalid: ".concat(e)),componentName:"ErrorTrackingService",additionalInfo:{preInitError:!0,apiKey:e,userId:t,timestamp:Date.now()},timestamp:Date.now()},metadata:qe(),event_type:Ge.ERROR,user_id:t};this.sendLog(n).catch(console.error)}this.apiKey=e,this.userId=t,this.isInitialized=!0,this.processPreInitQueue()}catch(n){f.error("Error during ErrorTrackingService initialization:",n),this.preInitQueue.push({error:n instanceof Error?n:new Error(String(n)),componentName:"ErrorTrackingService",additionalInfo:{apiKey:e,userId:t}})}},e.prototype.processPreInitQueue=function(){return c(this,void 0,void 0,(function(){var e,t,n;return d(this,(function(i){switch(i.label){case 0:if(!this.preInitQueue.length)return[2];f.info("Processing ".concat(this.preInitQueue.length," pre-initialization errors")),e=0,t=this.preInitQueue,i.label=1;case 1:return e<t.length?(n=t[e],[4,this.trackError(n.error,n.componentName,s(s({},n.additionalInfo),{preInitError:!0}))]):[3,4];case 2:i.sent(),i.label=3;case 3:return e++,[3,1];case 4:return this.preInitQueue=[],[2]}}))}))},e.prototype.sendLog=function(e){return c(this,void 0,void 0,(function(){var t,n,i,o,r,a;return d(this,(function(l){switch(l.label){case 0:return l.trys.push([0,4,,5]),t=y().apiUrl,[4,fetch("".concat(t,"/users/sdk/record-logs/"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})];case 1:return(n=l.sent()).ok?[3,3]:(o=(i=f).error,r=["Failed to send error log:"],[4,n.text()]);case 2:o.apply(i,r.concat([l.sent()])),l.label=3;case 3:return[3,5];case 4:return a=l.sent(),f.error("Error sending log:",a),[3,5];case 5:return[2]}}))}))},e.prototype.trackError=function(e,t,n){return c(this,void 0,void 0,(function(){var i,o,r;return d(this,(function(a){switch(a.label){case 0:if(this.isInitialized)return[3,5];i={org_id:"UNINITALIZED",event_data:{message:e instanceof Error?e.message:e,stack:e instanceof Error?e.stack:void 0,componentName:t,additionalInfo:s(s({},n),{preInitError:!0,timestamp:Date.now()}),timestamp:Date.now()},metadata:qe(),event_type:Ge.ERROR,user_id:this.userId},a.label=1;case 1:return a.trys.push([1,3,,4]),[4,this.sendLog(i)];case 2:return a.sent(),[3,4];case 3:return a.sent(),this.preInitQueue.push({error:e,componentName:t,additionalInfo:n}),f.warn("Error tracked before initialization, queuing:",e),[3,4];case 4:return[2];case 5:return o={message:e instanceof Error?e.message:e,stack:e instanceof Error?e.stack:void 0,componentName:t,additionalInfo:s(s({},n),{timestamp:Date.now()}),timestamp:Date.now()},r={org_id:this.apiKey||"UNINITALIZED",event_data:o,metadata:qe(),event_type:Ge.ERROR,user_id:this.userId},[4,this.sendLog(r)];case 6:return a.sent(),[2]}}))}))},e.prototype.trackInfo=function(e,t,n){return c(this,void 0,void 0,(function(){var i,o;return d(this,(function(r){switch(r.label){case 0:return this.apiKey?(i={message:e,componentName:t,additionalInfo:n,timestamp:Date.now()},o={org_id:this.apiKey,event_data:i,metadata:qe(),event_type:Ge.INFO,user_id:this.userId},[4,this.sendLog(o)]):(f.error("Error tracking not initialized"),[2]);case 1:return r.sent(),[2]}}))}))},e}(),nt=tt.getInstance(),it="MISSING_API_KEY",ot="INVALID_API_KEY",rt="CONFIG_FETCH_FAILED",at="SDK_INIT_FAILED",lt="ERROR_TRACKING_INIT_FAILED",st="API_REQUEST_FAILED",ct="NETWORK_ERROR",dt="INVALID_RESPONSE",ut="IFRAME_LOAD_FAILED",pt="COOKIE_ACCESS_ERROR",ft="COMPONENT_RENDER_ERROR",mt="INITIALIZATION_ERROR",ht="API_ERROR",vt="RUNTIME_ERROR",gt="COMPONENT_ERROR",yt=((Qe={})[it]=function(e){return"SDK Initialization Failed: Required parameter 'api_key' is ".concat(void 0===e?"undefined":null===e?"null":""===e?"empty string":"invalid: ".concat(e),". A valid API key string is required to initialize the SDK.")},Qe[ot]=function(e){return"SDK Initialization Failed: Provided API key '".concat(e,"' is invalid. API key must be a non-empty string in UUID format.")},Qe[rt]=function(e){return"Failed to fetch chatbot configuration: ".concat(e.statusCode?"Server responded with status ".concat(e.statusCode):"Could not reach server").concat(e.error?". Error: ".concat(e.error):"")},Qe[st]=function(e,t,n){return"API Request Failed: Server responded with status ".concat(e," for ").concat(n?"endpoint ".concat(n):"request"," - ").concat(t)},Qe[ct]=function(e){return"Network Error: Failed to communicate with server".concat(e.url?" at ".concat(e.url):"").concat(e.error?" - ".concat(e.error):"")},Qe[ut]=function(e){return"Failed to load chatbot interface".concat(e.src?" from ".concat(e.src):"").concat(e.error?". Error: ".concat(e.error):"")},Qe[dt]=function(e){return"Invalid API Response: Missing required fields in response data: ".concat(e.join(", "))},Qe[lt]=function(e){return"Error Tracking Service initialization failed".concat(e.apiKey?" for API key ".concat(e.apiKey):"").concat(e.error?". Error: ".concat(e.error):"")},Qe[at]=function(e){return"SDK Initialization Failed: ".concat(e.reason||"Could not initialize the chatbot SDK").concat(e.config?". Attempted initialization with config: ".concat(JSON.stringify(e.config,null,2)):"")},Qe[pt]=function(e,t){return"Cookie Access Error: Failed to ".concat(e).concat(t?" cookie '".concat(t,"'"):" cookies",". This may affect user session persistence.")},Qe[ft]=function(e){return"React Component Error: ".concat(e.component||"Unknown component"," failed to render. Error: ").concat(e.error).concat(e.stack?"\nComponent Stack: ".concat(e.stack):"")},Qe),bt=e.memo((function(t){var n,i,o,r,a=t.config,l=t.isVisible,c=t.onClose,d=t.onEvent,u=t.onInternalEvent,p=t.position,f=t.bottomSpacing,m=t.overrides,g=e.useRef(null),b=e.useRef(!1),_=e.useRef(!1),w=p||(null===(n=a.interface_properties)||void 0===n?void 0:n.position)||"Right",E=null!==(o=null!=f?f:null===(i=a.interface_properties)||void 0===i?void 0:i.bottom_spacing)&&void 0!==o?o:20,T=e.useCallback((function(){var e,t=g.current;if(t){var n=((e={width:(null===window||void 0===window?void 0:window.innerWidth)<560?"100vw":"26%",minWidth:(null===window||void 0===window?void 0:window.innerWidth)<560?"300px":"400px",height:(null===window||void 0===window?void 0:window.innerWidth)<560?"100vh":"calc(100vh - 2rem - 10vh - ".concat(E,"px)"),borderRadius:(null===window||void 0===window?void 0:window.innerWidth)<560?"0":"1rem",position:(null===window||void 0===window?void 0:window.innerWidth)<560?"fixed":"",maxHeight:(null===window||void 0===window?void 0:window.innerWidth)<560?"100%":"50rem",top:(null===window||void 0===window?void 0:window.innerWidth)<560?"0":"calc(10vh - 32px)"})[w.toLowerCase()]=(null===window||void 0===window?void 0:window.innerWidth)<560?"0":void 0,e.flexDirection=(null===window||void 0===window?void 0:window.innerWidth)<560?"column":void 0,e.flexGrow=(null===window||void 0===window?void 0:window.innerWidth)<560?"1":void 0,e);Object.assign(t.style,n)}}),[E,w]);return e.useEffect((function(){var e=g.current;if(e&&!b.current){var t=y().copilotUrl;Object.assign(e.style,{zIndex:"20000000",border:"none",boxShadow:"0px 0px 40px 0px rgba(14, 14, 15, 0.24)",transformOrigin:"bottom ".concat(w.toLowerCase()),transition:"transform 0.2s cubic-bezier(0.2, 1.27, 0.29, 0.97), opacity 0.15s ease-out",transform:"scale(0.3) translate3d(0,40px,0)",opacity:"0",display:"none"}),e.src="".concat(t,"/chatbot-plugin?id=").concat(a.chatbotId),b.current=!0,T();var n=function(){var n,i,o,r,a,l,s,c,d,u,p,f=new URL(e.src).origin||t;if(null===(n=e.contentWindow)||void 0===n||n.postMessage({domain:null===(i=null===window||void 0===window?void 0:window.location)||void 0===i?void 0:i.hostname,name:"checkDomain"},f),m){var h={header_avatar:null!==(o=null==m?void 0:m.header_avatar)&&void 0!==o?o:null,agent_avatar:null!==(r=null==m?void 0:m.agent_avatar)&&void 0!==r?r:null,header_title:null!==(a=null==m?void 0:m.header_title)&&void 0!==a?a:null,header_subtitle:null!==(l=null==m?void 0:m.header_subtitle)&&void 0!==l?l:null,header_title_text_color:null!==(s=null==m?void 0:m.header_title_text_color)&&void 0!==s?s:null,header_subtitle_text_color:null!==(c=null==m?void 0:m.header_subtitle_text_color)&&void 0!==c?c:null,header_bg:null!==(d=null==m?void 0:m.header_bg)&&void 0!==d?d:null};null===(u=e.contentWindow)||void 0===u||u.postMessage({domain:null===(p=null===window||void 0===window?void 0:window.location)||void 0===p?void 0:p.hostname,action:"updateOverrides",data:h},t)}};return e.addEventListener("load",n),function(){return e.removeEventListener("load",n)}}}),[a.chatbotId,null===(r=a.interface_properties)||void 0===r?void 0:r.position,T,m]),e.useEffect((function(){var e,t,n,i,o,r=g.current;if(r&&b.current){var c=(null===(e=a.interface_properties)||void 0===e?void 0:e.position)||"Right";if(l?(Object.assign(r.style,{transform:"scale(0.3) translate3d(0,40px,0)",opacity:"0",display:"block"}),r.getBoundingClientRect(),setTimeout((function(){Object.assign(r.style,{transform:"scale(1) translate3d(0,0,0)",opacity:"1",transition:"transform 0.2s cubic-bezier(0.2, 1.27, 0.29, 0.97), opacity 0.15s ease-out"})}),20)):(r.style.transition="none",r.getBoundingClientRect(),Object.assign(r.style,{opacity:"0",transform:"scale(0.3) translate3d(".concat((c.toLowerCase(),"0"),",40px,0)"),transition:"transform 0.2s cubic-bezier(0.2, 1.27, 0.29, 0.97), opacity 0.15s ease-out"}),setTimeout((function(){!l&&r&&(r.style.display="none")}),200)),r.contentWindow&&l){var d=y().copilotUrl;if(null===(t=null==r?void 0:r.contentWindow)||void 0===t||t.postMessage({domain:null===(n=null===window||void 0===window?void 0:window.location)||void 0===n?void 0:n.hostname,name:"openFrame"},d),!(null==_?void 0:_.current)){var u=z();null===(i=r.contentWindow)||void 0===i||i.postMessage({domain:null===(o=null===window||void 0===window?void 0:window.location)||void 0===o?void 0:o.hostname,action:"registerUserId",data:s({userId:null==a?void 0:a.userId,token:null==a?void 0:a.token,userProfile:null==a?void 0:a.userProfile,isAnonymous:null==a?void 0:a.isAnonymous},u?{proactiveData:u}:{})},d),_.current=!0}}}}),[l,a.userId,a.token,a.userProfile]),e.useEffect((function(){var e=function(e){var t,n;if(_.current&&g.current){var i=(null==e?void 0:e.detail)||{},o=y().copilotUrl;null===(t=g.current.contentWindow)||void 0===t||t.postMessage({domain:null===(n=null===window||void 0===window?void 0:window.location)||void 0===n?void 0:n.hostname,action:"proactiveClick",data:{userId:null==a?void 0:a.userId,token:null==a?void 0:a.token,userProfile:null==a?void 0:a.userProfile,isAnonymous:null==a?void 0:a.isAnonymous,proactiveData:{input_id:null,message_id:(null==i?void 0:i.message_id)||null,content_string:(null==i?void 0:i.content_string)||null}}},o)}};return window.addEventListener("rblyn:proactiveClick",e),function(){return window.removeEventListener("rblyn:proactiveClick",e)}}),[null==a?void 0:a.userId,null==a?void 0:a.token,null==a?void 0:a.userProfile,null==a?void 0:a.isAnonymous]),e.useEffect((function(){if(g.current&&b.current){var e=y().copilotUrl;l&&(null==d||d({type:h.CHATBOT_OPENED,timestamp:Date.now()}),u(h.CHATBOT_OPENED));var t=function(t){var n,i,o,r,a,l,s;if(t.origin===e){if("closeChatbot"===t.data)return void c();if("CHATBOT_TOKEN_EXHAUSTED"===(null===(n=t.data)||void 0===n?void 0:n.type))return void u(v.CHATBOT_TOKEN_EXHAUSTED);"CHATBOT_LOADED"===(null===(i=t.data)||void 0===i?void 0:i.type)&&(null==d||d({type:h.CHATBOT_LOADED,timestamp:Date.now()}),u(h.CHATBOT_LOADED)),"CHAT_INITIALIZED"===(null===(o=t.data)||void 0===o?void 0:o.type)&&(null==d||d({type:h.CHAT_INITIALIZED,timestamp:Date.now()}),u(h.CHAT_INITIALIZED)),"CHAT_INITIALIZATION_FAILED"===(null===(r=t.data)||void 0===r?void 0:r.type)&&(null==d||d({type:h.CHAT_INITIALIZATION_FAILED,timestamp:Date.now()}),u(h.CHAT_INITIALIZATION_FAILED,{error:null===(a=t.data)||void 0===a?void 0:a.error})),"SESSION_REFRESHED"===(null===(l=t.data)||void 0===l?void 0:l.type)&&(null==d||d({type:h.SESSION_REFRESHED,timestamp:Date.now()}),u(h.SESSION_REFRESHED)),"CHAT_MOVED"===(null===(s=t.data)||void 0===s?void 0:s.type)&&u(v.CHAT_MOVED,{from:t.data.from,to:t.data.to,trigger:t.data.trigger})}};return null===window||void 0===window||window.addEventListener("message",t),function(){return null===window||void 0===window?void 0:window.removeEventListener("message",t)}}}),[c,d,u,a.chatbotId,l]),e.useEffect((function(){var e=g.current;if(e&&b.current){var t=function(){nt.trackError(new Error(yt[ut]({src:e.src,error:"Failed to load iframe"})),"ChatbotIframe",{errorCode:ut,errorType:vt,context:{config:a,iframeUrl:e.src,timestamp:Date.now()}})};return e.addEventListener("error",t),function(){return e.removeEventListener("error",t)}}}),[a]),e.useEffect((function(){var e;if(g.current&&a&&l){var t=g.current,n=y().copilotUrl;null===(e=t.contentWindow)||void 0===e||e.postMessage({action:"updateUserProfile",user_profile:a.userProfile},n)}}),[a.userProfile,l]),e.createElement("iframe",{ref:g,id:"chat-iframe-rbyln",style:{display:"none"}})})),_t=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.state={hasError:!1},t}return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function i(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(i.prototype=n.prototype,new i)}(n,e),n.getDerivedStateFromError=function(e){return{hasError:!0}},n.prototype.componentDidCatch=function(e,t){nt.trackError(new Error(yt[ft]({component:this.props.componentName||void 0,error:e.message,stack:t.componentStack})),this.props.componentName||void 0,{errorCode:ft,errorType:gt,context:{originalError:e,componentStack:t.componentStack,timestamp:Date.now()}})},n.prototype.render=function(){return this.state.hasError?null:this.props.children},n}(e.Component),wt=function(){var e,t=navigator.userAgent;if(null===(e=navigator.userAgentData)||void 0===e?void 0:e.brands){var n=navigator.userAgentData.brands.find((function(e){return"Google Chrome"===e.brand}));if(null==n?void 0:n.version)return n.version}var i=t.match(/(Chrome|Firefox|Safari|Edge|Opera)\/(\d+\.\d+)/);return i?i[2]:"Unknown"},Et=function(){var e,t,n=qe();return{current_page_url:(null===(e=null===window||void 0===window?void 0:window.location)||void 0===e?void 0:e.href)||"",browser_language:(null===navigator||void 0===navigator?void 0:navigator.language)||(null===(t=null===navigator||void 0===navigator?void 0:navigator.languages)||void 0===t?void 0:t[0])||"en",browser_version:wt(),os:null==n?void 0:n.os,referral_url:(null===document||void 0===document?void 0:document.referrer)||""}},Tt=function(e,t,n){return c(void 0,void 0,void 0,(function(){var i,o,r,a,l,s,c,u;return d(this,(function(d){switch(d.label){case 0:i=y().apiUrl,o="".concat(i,"/chat/chatbot/get/"),f.log("endpointUrl",o),r={client_user_id:t,org_id:e,token:n||void 0,extra_info:{},launcher_info:Et()},d.label=1;case 1:return d.trys.push([1,6,,7]),[4,fetch(o,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)})];case 2:return(a=d.sent()).ok?[3,4]:[4,a.text()];case 3:throw l=d.sent(),new Error(yt[st](a.status,l));case 4:return[4,a.json()];case 5:s=d.sent();try{String(r.org_id||"")}catch(e){}if(!(null===(u=null==s?void 0:s.user)||void 0===u?void 0:u.org_info))throw new Error(yt[dt](["user","org_info"]));return[2,s];case 6:throw c=d.sent(),nt.trackError(c instanceof Error?c:new Error(yt[ct]({error:String(c)})),"fetchChatbotConfig",{errorCode:c instanceof Error&&c.message.includes("API Request Failed")?st:ct,errorType:ht,context:{chatbotId:e,userId:t,apiUrl:i,statusCode:c instanceof Response?c.status:void 0,timestamp:Date.now(),requestPayload:{client_user_id:t,org_id:e}}}),c;case 7:return[2]}}))}))},xt=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}))},It=function(e){var t,n="; ".concat(document.cookie).split("; ".concat(e,"="));if(2===n.length)return null===(t=n.pop())||void 0===t?void 0:t.split(";").shift()},St=function(e,t,n){var i=new Date;i.setTime(i.getTime()+24*n*60*60*1e3),document.cookie="".concat(e,"=").concat(t,";expires=").concat(i.toUTCString(),";path=/")},Ct=function(e){var t=e?"USER_DATA=%7B%22attributes%22%3A%5B%7B%22key%22%3A%22USER_ATTRIBUTE_USER_EMAIL%22%2C%22value%22%3A%22dinesh.goel%40robylon.ai%22%7D%2C%7B%22key%22%3A%22USER_ATTRIBUTE_UNIQUE_ID%22%2C%22value%22%3A%2266011f2c28d1787d13c6c796%22%7D%5D%2C%22subscribedToOldSdk%22%3Afalse%2C%22deviceUuid%22%3A%2226c02feb-2664-451d-8469-9cf1378547c6%22%2C%22deviceAdded%22%3Atrue%7D; _ga_3YS9P6ZDWX=GS1.1.1715252584.3.1.1715258696.39.0.0; _ga_V4J24F7YF9=GS1.1.1715273274.2.0.1715273274.0.0.0; city_name=Bengaluru; lang_code=en-in; cookieConcent=A; _gcl_au=1.1.343275043.1717154298; _clck=43guwd%7C2%7Cfmi%7C0%7C1561; _gid=GA1.2.1423066649.1718210058; moe_uuid=26c02feb-2664-451d-8469-9cf1378547c6; _ga_6RM65PWEZY=GS1.1.1718210058.18.1.1718211647.60.0.0; _ga=GA1.1.689213983.1712737672; AMP_MKTG_fe4beb374f=JTdCJTIycmVmZXJyZXIlMjIlM0ElMjJodHRwcyUzQSUyRiUyRmFjY291bnRzLnRlYWNobWludC5jb20lMkYlMjIlMkMlMjJyZWZlcnJpbmdfZG9tYWluJTIyJTNBJTIyYWNjb3VudHMudGVhY2htaW50LmNvbSUyMiU3RA==; AMP_fe4beb374f=JTdCJTIyZGV2aWNlSWQlMjIlM0ElMjI0MWMxMTljZC03YzVjLTRiYTctYTUzZS1mYTgzMjRlYjc0OWUlMjIlMkMlMjJ1c2VySWQlMjIlM0ElMjIxZjI2ODAwOC01OGYxLTQwYTItYjQ0Ni1mYmQ5N2E0NDQyYTAlMjIlMkMlMjJzZXNzaW9uSWQlMjIlM0ExNzE4MjEzMzEwOTc3JTJDJTIyb3B0T3V0JTIyJTNBZmFsc2UlMkMlMjJsYXN0RXZlbnRUaW1lJTIyJTNBMTcxODIxMzMxMDk4MSUyQyUyMmxhc3RFdmVudElkJTIyJTNBMTQlN0Q=; _ga_3YS9P6ZDWX=GS1.1.1718211637.26.1.1718213441.60.0.0; SESSION=%7B%22sessionKey%22%3A%22e4d76f52-9053-4277-99a4-f1ba667fd5f2%22%2C%22sessionStartTime%22%3A%222024-06-12T16%3A34%3A19.047Z%22%2C%22sessionMaxTime%22%3A1800%2C%22customIdentifiersToTrack%22%3A%5B%5D%2C%22sessionExpiryTime%22%3A1718215247464%2C%22numberOfSessions%22%3A17%7D":document.cookie;return t=t.split(";").map((function(e){var t=e.split("="),n=t[0],i=t.slice(1).join("=").trim();return{name:n=n.trim(),value:i?decodeURIComponent(i):""}})),t},At=function(){function e(e){this.logoContainer=null,this.iframe=null,this.bubblePromptContainer=null,this.chatBtnImage=null,this.config=e,this.validateDomain()&&this.init(),null===window||void 0===window||window.addEventListener("message",this.onCloseListener.bind(this),!1)}return e.prototype.onCloseListener=function(e){e.origin===this.config.domain&&"closeChatbot"===e.data&&this.closeIframe()},e.prototype.validateDomain=function(){var e,t=this.config.domain,n=null===(e=null===window||void 0===window?void 0:window.location)||void 0===e?void 0:e.origin;return f.log("expectedDomain, to current domain",t,n,t===n),t===n},e.prototype.createChatBubblContainer=function(){var e,t=this,n=document.createElement("div");n.id="chatbase-message-bubbles",Object.assign(n.style,{position:"fixed",bottom:"80px",borderRadius:"10px",fontFamily:"sans-serif",fontSize:"16px",zIndex:"2147483644",cursor:"pointer",flexDirection:"column",gap:"50px",maxWidth:"70vw",display:"block",right:"1rem",left:"unset"});var i=document.createElement("div");i.classList.add("close-btn"),i.textContent="✕",Object.assign(i.style,{position:"absolute",top:"-7px",right:"-7px",fontWeight:"bold",display:"none",justifyContent:"center",alignItems:"center",zIndex:"2147483643",width:"22px",height:"22px",borderRadius:"50%",textAlign:"center",fontSize:"12px",cursor:"pointer",backgroundColor:"rgb(224, 224, 224)",color:"black",boxShadow:"rgba(150, 150, 150, 0.15) 0px 6px 24px 0px, rgba(150, 150, 150, 0.15) 0px 0px 0px 1px"}),((null===(e=this.config.chat_interface_config)||void 0===e?void 0:e.chat_bubble_prompts)||[]).forEach((function(e){var i=t.createMessageBubble(e);n.appendChild(i)})),n.appendChild(i),document.body.appendChild(n)},e.prototype.createMessageBubble=function(e){var t=document.createElement("div");this.bubblePromptContainer=t,Object.assign(t.style,{display:"flex",position:"relative",justifyContent:"flex-end"});var n=document.createElement("div");n.classList.add("message"),n.textContent=e,Object.assign(n.style,{backgroundColor:"white",color:"black",boxShadow:"rgba(150, 150, 150, 0.2) 0px 10px 30px 0px, rgba(150, 150, 150, 0.2) 0px 0px 0px 1px",borderRadius:"10px",padding:"8px 5px",margin:"8px",fontSize:"14px",opacity:"1",transform:"scale(1)",transition:"opacity 0.5s ease 0s, transform 0.5s ease 0s"});var i=document.createElement("button");return i.innerHTML="×",Object.assign(i.style,{position:"absolute",top:"1px",left:"-3px",width:"20px",height:"20px",borderRadius:"50%",backgroundColor:"#fff",color:"#000",border:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:"0 2px 5px rgba(0,0,0,0.2)",fontSize:"14px",lineHeight:"1",padding:"0",zIndex:"100"}),i.addEventListener("click",(function(){t.remove()})),t.appendChild(i),t.appendChild(n),t},e.prototype.createFloatingButton=function(){var e=document.createElement("div");e.classList.add("message-bubble-container"),Object.assign(e.style,{position:"fixed",bottom:"1.5rem",right:"1.5rem",zIndex:"1000",width:"48px",height:"48px",display:"flex",flexDirection:"column-reverse",backgroundColor:this.config.brand_colour,color:p(this.config.brand_colour),borderRadius:"50%",alignItems:"center",justifyContent:"center",cursor:"pointer",overflow:"hidden"}),document.body.appendChild(e),this.logoContainer=e,this.loadImage(this.logoContainer),this.createChatBubblContainer(),this.logoContainer.addEventListener("click",this.toggleIframe.bind(this))},e.prototype.loadImage=function(e){var t,n,i=document.createElement("img");i.src=this.config.launcher_type?(null===(n=null===(t=this.config.images)||void 0===t?void 0:t.launcher_image_url)||void 0===n?void 0:n.url)||"".concat(this.config.domain,"/chatbubble.png"):this.config.image_url||"".concat(this.config.domain,"/chatbubble.png"),i.alt="Chat",Object.assign(i.style,{zIndex:"1000",cursor:"pointer",borderRadius:"50%",objectFit:"cover"}),this.chatBtnImage=i,e.innerHTML="",e.appendChild(i)},e.prototype.createIframe=function(){var e=this;f.log("RobylonConfig?.domain====>",this.config.domain);var t=document.createElement("iframe");Object.assign(t.style,{position:"fixed",right:"32px",bottom:"86px",minWidth:"400px",width:"26%",maxWidth:"800px",top:"calc(10vh - 32px)",maxHeight:"45rem",height:"calc(100vh - 3rem - 10vh)",zIndex:"20000000",border:"none",boxShadow:"0px 0px 40px 0px rgba(14, 14, 15, 0.24)",transformOrigin:"bottom right",transition:"transform 0.3s ease-out",borderRadius:"1rem",display:"none"}),t.src="".concat(this.config.domain,"/chatbot-plugin?id=").concat(this.config.chatbotId),f.log("iframe.src====>",t.src),document.body.appendChild(t),this.iframe=t;var n=function(){(null===window||void 0===window?void 0:window.innerWidth)<560?Object.assign(t.style,{width:"100vw",minWidth:"300px",right:"0",bottom:"0",height:"100vh",flexDirection:"column",flexGrow:"1",borderRadius:"0",top:"0",maxHeight:"100%"}):Object.assign(t.style,{width:"26%",minWidth:"400px",right:"32px",bottom:"86px",height:"calc(100vh - 3rem - 10vh)",borderRadius:"1rem",top:"calc(10vh - 32px)",maxHeight:"45rem"})};n(),null===window||void 0===window||window.addEventListener("resize",n),t.addEventListener("load",(function(){var n,i,o,r;if(e.iframe){var a=new URL(e.iframe.src).origin||e.config.domain;null===(n=t.contentWindow)||void 0===n||n.postMessage({domain:null===(i=null===window||void 0===window?void 0:window.location)||void 0===i?void 0:i.hostname,name:"checkDomain"},a),null===(o=t.contentWindow)||void 0===o||o.postMessage({domain:null===(r=null===window||void 0===window?void 0:window.location)||void 0===r?void 0:r.hostname,action:"registerUserId",data:{userId:e.config.userId,token:e.config.token,userProfile:e.config.userProfile}},a)}})),null===window||void 0===window||window.addEventListener("message",(function(n){var i,o;if(n.origin===e.config.domain){if("captureSessionData"===n.data){var r="66b33d16-5b38-4693-8772-1a1bd7dd412d"===e.config.chatbotId,a={cookies:Ct(r),localStorage:JSON.stringify(localStorage),sessionStorage:JSON.stringify(sessionStorage),action:"capturedSessionData",domain_name:null===(i=null===window||void 0===window?void 0:window.location)||void 0===i?void 0:i.hostname};null===(o=t.contentWindow)||void 0===o||o.postMessage(a,e.config.domain||"*")}"expand"===n.data&&(e.adjustIframeWidth(),t.style.height="calc(100vh - 120px)",t.style.bottom="86px"),"collapse"===n.data&&Object.assign(t.style,{width:"26%",height:"calc(100vh - 32px - 10vh)",bottom:"86px",top:"calc(32px + 10vh)"})}}))},e.prototype.adjustIframeWidth=function(){if(this.iframe){var e=null===window||void 0===window?void 0:window.innerWidth;f.log("screenWidth",e),this.iframe.style.width=e<832?"".concat(e-64,"px"):"800px"}},e.prototype.loadSvgInline=function(e){var t=document.createElement("div");t.innerHTML='\n<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">\n <g id="Chevron_Down">\n <path id="Vector" d="M19 9L12 16L5 9" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>\n </g>\n</svg>\n';var n=t.querySelector("svg");e.innerHTML="",n&&e.appendChild(n)},e.prototype.toggleIcon=function(e,t){"block"===t.style.display?this.loadSvgInline(e):this.loadImage(e)},e.prototype.toggleIframe=function(){var e;if(f.log("toggleIframe",this.iframe,this.logoContainer,this.chatBtnImage),this.iframe&&this.logoContainer&&this.chatBtnImage){var t=new URL(this.iframe.src).origin||this.config.domain;f.log("toggleIframe"),null===(e=this.iframe.contentWindow)||void 0===e||e.postMessage({domain:null===window||void 0===window?void 0:window.location.hostname,name:"none"===this.iframe.style.display?"openFrame":"closeFrame"},t),this.iframe.style.display="none"===this.iframe.style.display?"block":"none",this.toggleIcon(this.logoContainer,this.iframe),this.chatBtnImage.style.objectFit="block"===this.iframe.style.display?"none":"cover",this.bubblePromptContainer&&(this.bubblePromptContainer.style.display="none"),f.log("this.bubblePromptContainer",this.bubblePromptContainer)}},e.prototype.closeIframe=function(){this.iframe&&this.logoContainer&&this.chatBtnImage&&(this.iframe.style.display="none",this.toggleIcon(this.logoContainer,this.iframe),this.chatBtnImage.style.objectFit="cover")},e.prototype.init=function(){this.createIframe(),this.createFloatingButton()},e}(),Ot=function(e,t,n){if(e.chatbotId&&e.userId)try{new At(e);t(!0),f.log("Robylon SDK initialized successfully.")}catch(e){n(e instanceof Error?e.message:"Failed to initialize SDK")}else n("Incomplete configuration for SDK initialization.")},Rt=function(e,t,n){return c(void 0,void 0,void 0,(function(){var i,o,r,a,l,s,c,u;return d(this,(function(d){switch(d.label){case 0:return d.trys.push([0,5,,6]),i=y().apiUrl,o="".concat(i,"/chat/chatbot/get/"),f.log("endpointUrl",o),r={client_user_id:t||null,org_id:e,token:n||void 0,extra_info:{},launcher_info:Et()},[4,fetch(o,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)})];case 1:return(a=d.sent()).ok?[3,3]:[4,a.text()];case 2:throw l=d.sent(),new Error(yt[st](a.status,l));case 3:return[4,a.json()];case 4:if(s=d.sent(),!(null===(u=null==s?void 0:s.user)||void 0===u?void 0:u.org_info))throw new Error(yt[dt](["user","org_info"]));return[2,s];case 5:throw c=d.sent(),nt.trackError(c instanceof Error?c:new Error(yt[ct]({error:String(c)})),"fetchChatbotConfig",{errorCode:c instanceof Error&&c.message.includes("API Request Failed")?st:ct,errorType:ht,context:{apiKey:e,userId:t,timestamp:Date.now()}}),c;case 6:return[2]}}))}))},Dt=function(e){return c(void 0,void 0,void 0,(function(){var t,n,i,o,r,a,l,c,u,p,m,h,v,g,y,b,_,w,E,T,x,I,S,C,A,O,R,D,L,N,k,M,z,H;return d(this,(function(d){switch(d.label){case 0:return t=function(e){return{api_key:String(e.api_key||""),user_id:e.user_id?String(e.user_id):null,user_token:e.user_token?String(e.user_token):void 0,user_profile:e.user_profile||{}}}(e),n=t.user_id||void 0,i=!1,n||(n=It("rblyn_anon")||xt(),St("rblyn_anon",n,365),i=!0),[4,Rt(t.api_key,n,t.user_token)];case 1:o=d.sent();try{t.api_key}catch(e){f.warn("Failed to inject mock proactive messages",e)}return r=qe(),a=Et(),F=t.user_profile,l=F?Object.fromEntries(Object.entries(F).map((function(e){var t=e[0],n=e[1];return"boolean"==typeof n||"number"==typeof n?[t,n]:[t,String(n)]}))):{},c=s(s(s({},r),{__INT_SYS_INFO__:s(s({},r),a)}),l),[2,{chatbotId:t.api_key,userId:n,token:t.user_token,isAnonymous:i,domain:"",show_launcher:null===(p=null===(u=o.user.org_info)||void 0===u?void 0:u.show_launcher)||void 0===p||p,brand_colour:(null===(h=null===(m=o.user.org_info.brand_config)||void 0===m?void 0:m.colors)||void 0===h?void 0:h.brand_color)||"",image_url:(null===(g=null===(v=o.user.org_info)||void 0===v?void 0:v.brand_config)||void 0===g?void 0:g.launcher_logo_url)||"",userProfile:c,chat_interface_config:{chat_bubble_prompts:[],display_name:(null===(y=o.user.org_info.brand_config)||void 0===y?void 0:y.display_name)||"",welcome_message:(null===(b=o.user.org_info.brand_config)||void 0===b?void 0:b.welcome_message)||"Hey! What can we help you with today?",redirect_url:(null===(_=o.user.org_info.brand_config)||void 0===_?void 0:_.redirect_url)||""},launcher_type:(null===(w=o.user.org_info.brand_config)||void 0===w?void 0:w.launcher_type)||exports.LauncherType.IMAGE,launcher_properties:{text:(null===(T=null===(E=o.user.org_info.brand_config)||void 0===E?void 0:E.launcher_properties)||void 0===T?void 0:T.text)||""},images:{launcher_image_url:{url:(null===(S=null===(I=null===(x=o.user.org_info.brand_config)||void 0===x?void 0:x.images)||void 0===I?void 0:I.launcher_image_url)||void 0===S?void 0:S.url)||""}},proactive_message_obj:Lt(null===(O=null===(A=null===(C=null==o?void 0:o.user)||void 0===C?void 0:C.org_info)||void 0===A?void 0:A.brand_config)||void 0===O?void 0:O.proactive_message_obj),interface_properties:{position:(null===(D=null===(R=o.user.org_info.brand_config)||void 0===R?void 0:R.interface_properties)||void 0===D?void 0:D.position)||exports.WidgetPositionEnums.RIGHT,side_spacing:(null===(N=null===(L=o.user.org_info.brand_config)||void 0===L?void 0:L.interface_properties)||void 0===N?void 0:N.side_spacing)||20,bottom_spacing:(null===(M=null===(k=o.user.org_info.brand_config)||void 0===k?void 0:k.interface_properties)||void 0===M?void 0:M.bottom_spacing)||20},interface_type:(null===(z=o.user.org_info.brand_config)||void 0===z?void 0:z.interface_type)||exports.ChatbotInterfaceType.WIDGET,launcher_delay:(null===(H=o.user.org_info.brand_config)||void 0===H?void 0:H.launcher_delay)||{enabled:!1,delay:0}}]}var F}))}))},Lt=function(e){if(e){var t=(Array.isArray(e)?e:[e]).filter(Boolean).map((function(e){var t,n,i={message_id:String(null!==(t=null==e?void 0:e.message_id)&&void 0!==t?t:""),org_id:String(null!==(n=null==e?void 0:e.org_id)&&void 0!==n?n:""),name:null==e?void 0:e.name,content:null==e?void 0:e.content,send_time_type:null==e?void 0:e.send_time_type,created_by_name:null==e?void 0:e.created_by_name,updated_by_name:null==e?void 0:e.updated_by_name,updated_at:null==e?void 0:e.updated_at,created_at:null==e?void 0:e.created_at,delay:"number"==typeof(null==e?void 0:e.delay)?e.delay:void 0,content_multiple:Array.isArray(null==e?void 0:e.content_multiple)?e.content_multiple:(null==e?void 0:e.content)?[{message:String(e.content),message_display_attributes:[]}]:[]};return(null==e?void 0:e.content)&&!(null==e?void 0:e.content_multiple)&&f.warn("[Robylon SDK] proactive_message.content is deprecated; use content_multiple[].message instead."),i}));return t.length?t:void 0}},Nt=function(t){var n=e.useMemo((function(){return function(e){return{api_key:String(e.api_key||""),user_id:e.user_id?String(e.user_id):null,user_token:e.user_token?String(e.user_token):void 0,user_profile:e.user_profile||{}}}(t)}),[t.api_key,t.user_id,t.user_token,JSON.stringify(t.user_profile)]),i=e.useState({isInitialized:!1,isInitializing:!1,error:null,chatbotConfig:null,isIframeVisible:!1}),o=i[0],r=i[1],a=e.useMemo((function(){return n.user_profile?Object.fromEntries(Object.entries(n.user_profile).map((function(e){var t=e[0],n=e[1];return"boolean"==typeof n||"number"==typeof n?[t,n]:[t,String(n)]}))):{}}),[JSON.stringify(n.user_profile)]),l=e.useCallback((function(e){r((function(t){return s(s({},t),e)}))}),[]),u=e.useCallback((function(){return c(void 0,void 0,void 0,(function(){var e,t,i,o,r,c,u,p,f,m,h,v,g,y,b,_,w,E,T,x,I,S,C,A,O,R,D,L,N,k,M,z,H,F,U,P,B,W;return d(this,(function(d){switch(d.label){case 0:if(!n.api_key)return nt.trackError(new Error(yt[it](n.api_key)),"useChatbotState",{errorCode:it,errorType:mt,context:{timestamp:Date.now()}}),[2];l({isInitializing:!0}),d.label=1;case 1:return d.trys.push([1,4,5,6]),e=n.user_id||void 0,t=!1,e||(e=It("rblyn_anon")||xt(),St("rblyn_anon",e,365),t=!0),[4,Tt(n.api_key,e,n.user_token)];case 2:return i=d.sent(),o=qe(),r=Et(),c=s(s(s({},o),{__INT_SYS_INFO__:s(s({},o),r)}),a),u={chatbotId:n.api_key,userId:e,token:n.user_token,isAnonymous:t,domain:"",show_launcher:null===(h=null===(m=i.user.org_info)||void 0===m?void 0:m.show_launcher)||void 0===h||h,brand_colour:(null===(g=null===(v=i.user.org_info.brand_config)||void 0===v?void 0:v.colors)||void 0===g?void 0:g.brand_color)||"",image_url:(null===(b=null===(y=i.user.org_info)||void 0===y?void 0:y.brand_config)||void 0===b?void 0:b.launcher_logo_url)||"",userProfile:c,chat_interface_config:{chat_bubble_prompts:[],display_name:(null===(_=i.user.org_info.brand_config)||void 0===_?void 0:_.display_name)||"",welcome_message:(null===(w=i.user.org_info.brand_config)||void 0===w?void 0:w.welcome_message)||"Hey! What can we help you with today?",redirect_url:(null===(E=i.user.org_info.brand_config)||void 0===E?void 0:E.redirect_url)||""},interface_properties:{position:(null===(x=null===(T=i.user.org_info.brand_config)||void 0===T?void 0:T.interface_properties)||void 0===x?void 0:x.position)||exports.WidgetPositionEnums.RIGHT,side_spacing:null!==(C=null===(S=null===(I=i.user.org_info.brand_config)||void 0===I?void 0:I.interface_properties)||void 0===S?void 0:S.side_spacing)&&void 0!==C?C:20,bottom_spacing:null!==(R=null===(O=null===(A=i.user.org_info.brand_config)||void 0===A?void 0:A.interface_properties)||void 0===O?void 0:O.bottom_spacing)&&void 0!==R?R:20},interface_type:(null===(D=i.user.org_info.brand_config)||void 0===D?void 0:D.interface_type)||exports.ChatbotInterfaceType.WIDGET,launcher_type:(null===(L=i.user.org_info.brand_config)||void 0===L?void 0:L.launcher_type)||exports.LauncherType.IMAGE,launcher_properties:{text:(null===(k=null===(N=i.user.org_info.brand_config)||void 0===N?void 0:N.launcher_properties)||void 0===k?void 0:k.text)||""},images:{launcher_image_url:{url:(null===(H=null===(z=null===(M=i.user.org_info.brand_config)||void 0===M?void 0:M.images)||void 0===z?void 0:z.launcher_image_url)||void 0===H?void 0:H.url)||""}},proactive_message_obj:Lt(null===(P=null===(U=null===(F=null==i?void 0:i.user)||void 0===F?void 0:F.org_info)||void 0===U?void 0:U.brand_config)||void 0===P?void 0:P.proactive_message_obj),launcher_delay:(null===(W=null===(B=i.user.org_info)||void 0===B?void 0:B.brand_config)||void 0===W?void 0:W.launcher_delay)||{enabled:!1,delay:0}},[4,new Promise((function(e,t){Ot(u,(function(){l({isInitialized:!0,chatbotConfig:u}),e()}),(function(e){t(e)}))}))];case 3:return d.sent(),[3,6];case 4:return p=d.sent(),f=p instanceof Error?p.message:"Failed to initialize chatbot",l({error:f}),nt.trackError(p instanceof Error?p:new Error(f),"useChatbotState",{errorCode:at,errorType:mt,context:{timestamp:Date.now()}}),[3,6];case 5:return l({isInitializing:!1}),[7];case 6:return[2]}}))}))}),[n.api_key,n.user_id,n.user_token]);e.useEffect((function(){n.api_key&&u()}),[u]),e.useEffect((function(){o.chatbotConfig&&r((function(e){return s(s({},e),{chatbotConfig:s(s({},e.chatbotConfig),{userProfile:s(s({},qe()),a)})})}))}),[a]);var p=e.useCallback((function(){r((function(e){return s(s({},e),{isIframeVisible:!e.isIframeVisible})}))}),[]),f=e.useCallback((function(){l({isIframeVisible:!1})}),[]);return s(s({},o),{toggleIframeVisibility:p,closeIframe:f})},kt=function(t){var n,i,o,r,a,l,c,d=t.children,u=t.config,p=t.position,m=t.sideSpacing,h=t.bottomSpacing,v=e.useState(!1),g=v[0],y=v[1];e.useEffect((function(){var e=function(){var e=(null===window||void 0===window?void 0:window.innerWidth)<560;y(e)};return e(),window.addEventListener("resize",e),function(){window.removeEventListener("resize",e)}}),[]);var b=p||(null===(o=u.interface_properties)||void 0===o?void 0:o.position)||"Right",_=null!==(a=null!=m?m:null===(r=u.interface_properties)||void 0===r?void 0:r.side_spacing)&&void 0!==a?a:20,w=null!==(c=null!=h?h:null===(l=u.interface_properties)||void 0===l?void 0:l.bottom_spacing)&&void 0!==c?c:20;f.log("config",u,b,_);var E={position:"fixed",zIndex:1e3,display:"flex",flexDirection:"column"},T=s(s({},E),((n={bottom:"".concat(w,"px")})[b.toLowerCase()]="".concat(null!=_?_:20,"px"),n.alignItems="Right"===b?"flex-end":"flex-start",n.top=void 0,n["Right"===b?"left":"right"]=void 0,n)),x=s(s({},E),((i={top:0})[b.toLowerCase()]="".concat(null!=_?_:20,"px"),i.alignItems="center",i.bottom=void 0,i["Right"===b?"left":"right"]=void 0,i)),I=g?x:T;return e.useEffect((function(){console.log("Container screen width changed, isMobile:",g,"Style:",I)}),[g,I]),e.createElement("div",{className:"robylon-chatbot-container",style:I},d)},Mt=e.forwardRef((function(t,n){var i,o,r,a=t.api_key,l=t.user_id,p=t.user_token,m=t.user_profile,v=t.onEvent,g=t.position,b=t.sideSpacing,_=t.bottomSpacing,w=t.show_launcher,E=t.launcher_type,T=t.launcher_properties_text,x=t.overrides,I="string"==typeof b?""===b||isNaN(Number(b))?void 0:Number(b):b,S="string"==typeof _?""===_||isNaN(Number(_))?void 0:Number(_):_,C="string"==typeof g?"left"===g.toLowerCase()?"Left":"right"===g.toLowerCase()?"Right":void 0:g;e.useEffect((function(){}));var A=e.useMemo((function(){return{api_key:a,user_id:l,user_token:p,user_profile:m}}),[a,l,p,m]),O=e.useCallback((function(e){null==v||v(e)}),[v]),R=Nt(A),D=R.isInitialized,L=R.error,N=R.chatbotConfig,k=R.isIframeVisible,M=R.toggleIframeVisibility,z=R.closeIframe,H=e.useMemo((function(){return{api_key:a,user_profile:A.user_profile,onEvent:O,chatbotConfig:N?{isAnonymous:N.isAnonymous,userId:N.userId}:null}}),[a,A.user_profile,O,null==N?void 0:N.isAnonymous,null==N?void 0:N.userId]),F=function(t){var n=t.api_key,i=t.chatbotConfig,o=t.user_profile,r=t.onEvent,a=e.useMemo((function(){return{isAnonymous:(null==i?void 0:i.isAnonymous)||!1,userId:(null==i?void 0:i.userId)||""}}),[null==i?void 0:i.isAnonymous,null==i?void 0:i.userId]),l=e.useMemo((function(){return o||{}}),[JSON.stringify(o)]),p=e.useCallback((function(e){for(var t=[],i=1;i<arguments.length;i++)t[i-1]=arguments[i];return c(void 0,u([e],t,!0),void 0,(function(e,t){var i,o,r,c,u,p,m;return void 0===t&&(t={}),d(this,(function(d){switch(d.label){case 0:if(!n)return[2];d.label=1;case 1:return d.trys.push([1,3,,4]),i=y().apiUrl,o=qe(),r=s({trigger_time:Date.now(),channel:"CHATBOT",launch_url:(null===(m=null===window||void 0===window?void 0:window.location)||void 0===m?void 0:m.href)||"",org_id:n,client_user_id:a.isAnonymous?"Anonymous":String(a.userId),event_type:e,user_profile:l},t),c={org_id:n,event_data:r,metadata:s({timestamp:Date.now()},o),event_type:"INFO",user_id:a.userId},[4,fetch("".concat(i,"/users/sdk/record-logs/"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(c)})];case 2:if(!(u=d.sent()).ok)throw new Error("Failed to send internal event: ".concat(u.statusText));return[3,4];case 3:return p=d.sent(),f.error("Failed to send internal event:",p),[3,4];case 4:return[2]}}))}))}),[n,a]);return{emitEvent:e.useCallback((function(e,t){var n=Date.now();e!==h.CHATBOT_BUTTON_CLICKED&&e!==h.CHATBOT_CLOSED&&e!==h.CHATBOT_OPENED&&e!==h.CHATBOT_READY||(r&&r({type:e,timestamp:n,data:t}),p(e,{timestamp:n}))}),[r,p]),onInternalEvent:p}}(s({},H)),U=F.emitEvent,P=F.onInternalEvent;e.useImperativeHandle(n,(function(){return{show:function(){D&&N?k||(M(),U(h.CHATBOT_BUTTON_CLICKED)):console.warn("Robylon Chatbot: Cannot show - chatbot not ready yet")},hide:function(){D&&N?k&&(z(),U(h.CHATBOT_CLOSED)):console.warn("Robylon Chatbot: Cannot hide - chatbot not ready yet")},toggle:function(){D&&N?(M(),U(k?h.CHATBOT_CLOSED:h.CHATBOT_BUTTON_CLICKED)):console.warn("Robylon Chatbot: Cannot toggle - chatbot not ready yet")},isReady:D&&!!N}}),[D,N,k,M,z,U]),e.useEffect((function(){D&&N&&U(h.CHATBOT_READY)}),[D,N,U]);var B=e.useState(!1),W=B[0],j=B[1];e.useEffect((function(){var e,t,n,i,o,r,a;if(!(void 0!==w?Boolean(w):null===(e=null==N?void 0:N.show_launcher)||void 0===e||e))return j(!1),function(){a&&clearTimeout(a)};var l=!0===(null===(t=null==N?void 0:N.launcher_delay)||void 0===t?void 0:t.enabled),s=null!==(r=null!==(i=null===(n=null==N?void 0:N.launcher_delay)||void 0===n?void 0:n.seconds)&&void 0!==i?i:null===(o=null==N?void 0:N.launcher_delay)||void 0===o?void 0:o.delay)&&void 0!==r?r:0;return l&&Number(s)>0?(j(!1),a=window.setTimeout((function(){j(!0)}),1e3*Number(s))):j(!0),function(){a&&clearTimeout(a)}}),[w,null==N?void 0:N.show_launcher,null===(i=null==N?void 0:N.launcher_delay)||void 0===i?void 0:i.enabled,null===(o=null==N?void 0:N.launcher_delay)||void 0===o?void 0:o.seconds,null===(r=null==N?void 0:N.launcher_delay)||void 0===r?void 0:r.delay]),e.useEffect((function(){if(a)try{nt.initialize(a,l)}catch(e){nt.trackError(e instanceof Error?e:new Error(String(e)),"RobylonChatbot",{errorCode:lt,errorType:mt,context:{timestamp:Date.now()}})}else nt.trackError(new Error(yt[it](a)),"RobylonChatbot",{errorCode:it,errorType:mt,context:{timestamp:Date.now()}})}),[a,l]);var G=e.useCallback((function(){z(),U(h.CHATBOT_CLOSED)}),[z,U]),X=e.useCallback((function(){M(),U(k?h.CHATBOT_CLOSED:h.CHATBOT_BUTTON_CLICKED)}),[M,U,k]),V=e.useMemo((function(){var e,t,n,i,o;return{config:N,toggleIframe:X,isIframeVisible:k,onEvent:O,onInternalEvent:P,position:C,sideSpacing:I,bottomSpacing:S,launcher_type:E,launcher_properties_text:T,shouldFadeIn:!0===(null===(e=null==N?void 0:N.launcher_delay)||void 0===e?void 0:e.enabled)&&(null!==(o=null!==(n=null===(t=null==N?void 0:N.launcher_delay)||void 0===t?void 0:t.seconds)&&void 0!==n?n:null===(i=null==N?void 0:N.launcher_delay)||void 0===i?void 0:i.delay)&&void 0!==o?o:0)>0||!1}}),[N,X,k,O,P,C,I,S,E,T]);f.log("floatingButtonProps",V);var Y=e.useMemo((function(){return{config:N,isVisible:k,onClose:G,onEvent:O,onInternalEvent:P,position:C,bottomSpacing:S,overrides:x}}),[N,k,G,O,P,C,S,x]);return a&&!L&&N?e.createElement(_t,{componentName:"RobylonChatbot"},D?e.createElement(kt,{config:N,position:C,sideSpacing:I,bottomSpacing:S},e.createElement(_t,{componentName:"ChatbotIframe"},e.createElement(bt,s({},Y))),e.createElement(_t,{componentName:"ChatbotFloatingButton"},W?e.createElement(Ye,s({},V)):null)):null):null})),zt=e.memo(Mt,(function(e,t){return e.api_key===t.api_key&&e.user_id===t.user_id&&e.user_token===t.user_token&&JSON.stringify(e.user_profile)===JSON.stringify(t.user_profile)&&e.position===t.position&&e.sideSpacing===t.sideSpacing&&e.bottomSpacing===t.bottomSpacing&&e.show_launcher===t.show_launcher&&e.launcher_type===t.launcher_type&&e.launcher_properties_text===t.launcher_properties_text&&JSON.stringify(e.overrides)===JSON.stringify(t.overrides)&&!0})),Ht=function(){function e(e){var t=this;this.resizeObserver=null,this.proactiveElement=null,this.urlUnsubscribe=null,this.delayTimers=[],this.config=e,this.buttonElement=document.createElement("div"),this.handleResizeFunction=this.handleResize.bind(this),this.render(),this.mount();try{this.buttonElement.style.opacity="0",this.buttonElement.style.transition="transform 0.2s cubic-bezier(0.2, 1.27, 0.29, 0.97), opacity 280ms ease",requestAnimationFrame((function(){t.buttonElement.style.opacity="1"}))}catch(e){}this.setupResizeListener(),this.renderProactiveIfNeeded(),this.urlUnsubscribe=A((function(){t.clearProactiveDelays(),t.renderProactiveIfNeeded(!0)}))}return e.prototype.render=function(){var e=this;y().copilotUrl;var t=this.config,n=t.config,i={zIndex:"1000",display:"flex",flexDirection:"column-reverse",alignItems:"center",justifyContent:"center",cursor:"pointer",overflow:"hidden",marginTop:"16px",transition:"transform 0.2s cubic-bezier(0.2, 1.27, 0.29, 0.97)",transform:t.isIframeVisible?"scale(0.85)":"scale(1)",fontFamily:_};n.launcher_type===exports.LauncherType.IMAGE&&Object.assign(i,{width:"48px",height:"48px",borderRadius:"50%",backgroundColor:n.brand_colour}),this.applyResponsiveStyles(i),this.buttonElement.className="message-bubble-container",this.buttonElement.innerHTML="",this.buttonElement.appendChild(this.createLauncherElement()),this.buttonElement.onclick=function(){e.config.toggleIframe(),e.hideProactiveMessages()},this.renderProactiveIfNeeded()},e.prototype.createLauncherElement=function(){var e,t,n=this.config,i=n.config,o=n.isIframeVisible,r=y().copilotUrl;switch(console.log("config in floating button",i),i.launcher_type){case exports.LauncherType.TEXT:return this.createTextLauncher();case exports.LauncherType.TEXTUAL_IMAGE:return this.createTextualImageLauncher();case exports.LauncherType.IMAGE:default:if(o){var a=document.createElement("div");return a.innerHTML='\n <svg\n width="24"\n height="24"\n viewBox="0 0 24 24"\n fill="none"\n xmlns="http://www.w3.org/2000/svg"\n >\n <path\n d="M19 9L12 16L5 9"\n stroke="currentColor"\n stroke-width="1.5"\n stroke-linecap="round"\n stroke-linejoin="round"\n />\n </svg>\n ',a}var l=document.createElement("img");return l.src=i.launcher_type?(null===(t=null===(e=i.images)||void 0===e?void 0:e.launcher_image_url)||void 0===t?void 0:t.url)||"".concat(r,"/chatbubble.png"):i.image_url||"".concat(r,"/chatbubble.png"),l.alt="Chat",Object.assign(l.style,{zIndex:"1000",cursor:"pointer",borderRadius:"50%",objectFit:"cover",width:"100%",height:"100%",boxSizing:"border-box"}),l}},e.prototype.createTextLauncher=function(){var e=this.config.config,t=e.brand_colour,n=e.launcher_properties,i=document.createElement("div");Object.assign(i.style,{width:"fit-content",maxWidth:"160px",height:"40px",borderRadius:"9999px",backgroundColor:t,display:"flex",alignItems:"center",padding:"9px 20px",boxShadow:"0px 0px 16px 0px rgba(0, 0, 0, 0.24)",boxSizing:"border-box"});var o=document.createElement("div");Object.assign(o.style,{flex:"1",minWidth:"0"});var r=document.createElement("p");return Object.assign(r.style,{margin:"0",color:p(t),fontSize:"0.875rem",fontWeight:"600",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",lineHeight:w,fontFamily:_,WebkitFontSmoothing:"antialiased",textRendering:"optimizeLegibility",textSizeAdjust:"100%"}),r.textContent=(null==n?void 0:n.text)||"",o.appendChild(r),i.appendChild(o),i},e.prototype.createTextualImageLauncher=function(){var e,t,n,i,o,r,a=y().copilotUrl,l=this.config.config,s=l.brand_colour,c=l.launcher_properties,d=l.image_url,u=document.createElement("div");Object.assign(u.style,{maxWidth:"13rem",width:"fit-content",height:"40px",borderRadius:"9999px",backgroundColor:s,display:"flex",alignItems:"center",paddingLeft:"20px",paddingRight:"0",paddingTop:"9px",paddingBottom:"9px",boxShadow:"0px 0px 16px 0px rgba(0, 0, 0, 0.24)",gap:"8px",boxSizing:"border-box"});var f=document.createElement("div");Object.assign(f.style,{flex:"1",minWidth:"0"});var m=document.createElement("p");Object.assign(m.style,{margin:"0",color:p(s),fontSize:"0.875rem",fontWeight:"600",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",lineHeight:w,fontFamily:_,WebkitFontSmoothing:"antialiased",textRendering:"optimizeLegibility",textSizeAdjust:"100%"}),m.textContent=(null==c?void 0:c.text)||"";var h=document.createElement("div");Object.assign(h.style,{width:"40px",height:"40px",borderRadius:"9999px",overflow:"hidden",position:"relative",flexShrink:"0"});var v=document.createElement("img");return v.src=(null===(t=null===(e=null==this?void 0:this.config)||void 0===e?void 0:e.config)||void 0===t?void 0:t.launcher_type)?(null===(r=null===(o=null===(i=null===(n=null==this?void 0:this.config)||void 0===n?void 0:n.config)||void 0===i?void 0:i.images)||void 0===o?void 0:o.launcher_image_url)||void 0===r?void 0:r.url)||"".concat(a,"/chatbubble.png"):d||"".concat(a,"/chatbubble.png"),v.alt="Chat",Object.assign(v.style,{width:"100%",height:"100%",objectFit:"cover"}),f.appendChild(m),h.appendChild(v),u.appendChild(f),u.appendChild(h),u},e.prototype.applyResponsiveStyles=function(e){var t,n,i,o,r,a,l,c,d,u=(null===window||void 0===window?void 0:window.innerWidth)<560,p=this.config.config,f=this.config.position||(null===(i=p.interface_properties)||void 0===i?void 0:i.position)||"Right",m=null!==(a=null!==(o=this.config.sideSpacing)&&void 0!==o?o:null===(r=p.interface_properties)||void 0===r?void 0:r.side_spacing)&&void 0!==a?a:20,h=null!==(d=null!==(l=this.config.bottomSpacing)&&void 0!==l?l:null===(c=p.interface_properties)||void 0===c?void 0:c.bottom_spacing)&&void 0!==d?d:20;this.buttonElement.style.position="",this.buttonElement.style.bottom="",this.buttonElement.style.right="",this.buttonElement.style.left="";var v=s(s({},e),u?((t={position:"fixed",bottom:"".concat(h,"px")})[f.toLowerCase()]="".concat(m,"px"),t):((n={bottom:"".concat(h,"px")})[f.toLowerCase()]="".concat(m,"px"),n));Object.assign(this.buttonElement.style,v)},e.prototype.handleResize=function(){var e={zIndex:"1000",display:"flex",flexDirection:"column-reverse",alignItems:"center",justifyContent:"center",cursor:"pointer",overflow:"hidden",marginTop:"16px",borderRadius:this.config.config.launcher_type&&this.config.config.launcher_type!==exports.LauncherType.IMAGE?"9999px":"50%",boxSizing:"border-box"};this.config.config.launcher_type===exports.LauncherType.IMAGE&&Object.assign(e,{width:"48px",height:"48px",borderRadius:"50%",backgroundColor:this.config.config.brand_colour}),this.applyResponsiveStyles(e)},e.prototype.setupResizeListener=function(){"undefined"!=typeof ResizeObserver?(this.resizeObserver=new ResizeObserver(this.handleResizeFunction),this.resizeObserver.observe(document.body)):window.addEventListener("resize",this.handleResizeFunction)},e.prototype.getElement=function(){return this.buttonElement},e.prototype.mount=function(){var e=this;requestAnimationFrame((function(){var t,n;null===(n=(t=e.config).onEvent)||void 0===n||n.call(t,{type:h.CHATBOT_BUTTON_LOADED,timestamp:Date.now()}),e.config.onInternalEvent(h.CHATBOT_BUTTON_LOADED)}))},e.prototype.update=function(e){this.config.isIframeVisible,this.config=s(s({},this.config),e),this.buttonElement.style.transform=this.config.isIframeVisible?"scale(0.85)":"scale(1)",this.render(),this.renderProactiveIfNeeded()},e.prototype.destroy=function(){this.resizeObserver?(this.resizeObserver.disconnect(),this.resizeObserver=null):window.removeEventListener("resize",this.handleResizeFunction),this.buttonElement&&this.buttonElement.parentNode&&this.buttonElement.parentNode.removeChild(this.buttonElement),this.proactiveElement&&this.proactiveElement.parentElement&&(this.proactiveElement.parentElement.removeChild(this.proactiveElement),this.proactiveElement=null),this.clearProactiveDelays(),this.urlUnsubscribe&&(this.urlUnsubscribe(),this.urlUnsubscribe=null)},e.prototype.clearProactiveDelays=function(){this.delayTimers.forEach((function(e){return clearTimeout(e)})),this.delayTimers=[]},e.prototype.hideProactiveMessages=function(){var e,t,n=this;N();var i=null===(e=this.proactiveElement)||void 0===e?void 0:e.children[0];if(i){var o="Right"===(this.config.position||(null===(t=this.config.config.interface_properties)||void 0===t?void 0:t.position)||"Right");Array.from(i.children).forEach((function(e){e.className=o?"rblyn-proactive-exit-right":"rblyn-proactive-exit-left"})),setTimeout((function(){n.proactiveElement&&n.proactiveElement.parentElement&&n.proactiveElement.parentElement.removeChild(n.proactiveElement),n.proactiveElement=null,n.clearProactiveDelays()}),400)}else this.clearProactiveDelays()},e.prototype.injectAnimationStyles=function(){if(!document.getElementById("rblyn-proactive-animations")){var e=document.createElement("style");e.id="rblyn-proactive-animations",e.textContent="\n @keyframes slideInFromRight {\n 0% {\n transform: translateX(120%) scale(0.95);\n opacity: 0;\n }\n 85% {\n transform: translateX(0) scale(1);\n opacity: 1;\n }\n 92% {\n transform: translateX(-1px) scale(1.002);\n }\n 100% {\n transform: translateX(0) scale(1);\n opacity: 1;\n }\n }\n @keyframes slideInFromLeft {\n 0% {\n transform: translateX(-120%) scale(0.95);\n opacity: 0;\n }\n 85% {\n transform: translateX(0) scale(1);\n opacity: 1;\n }\n 92% {\n transform: translateX(1px) scale(1.002);\n }\n 100% {\n transform: translateX(0) scale(1);\n opacity: 1;\n }\n }\n @keyframes slideOutRight {\n 0% {\n transform: translateX(0) scale(1);\n opacity: 1;\n }\n 100% {\n transform: translateX(120%) scale(0.9);\n opacity: 0;\n }\n }\n @keyframes slideOutLeft {\n 0% {\n transform: translateX(0) scale(1);\n opacity: 1;\n }\n 100% {\n transform: translateX(-120%) scale(0.9);\n opacity: 0;\n }\n }\n .rblyn-proactive-enter-right {\n animation: slideInFromRight 1.2s cubic-bezier(0.5, 0.8, 0.3, 1.1) forwards;\n }\n .rblyn-proactive-enter-left {\n animation: slideInFromLeft 1.2s cubic-bezier(0.5, 0.8, 0.3, 1.1) forwards;\n }\n .rblyn-proactive-exit-right {\n animation: slideOutRight 0.4s ease-in forwards;\n }\n .rblyn-proactive-exit-left {\n animation: slideOutLeft 0.4s ease-in forwards;\n }\n .rblyn-proactive-close-enter-right {\n animation: slideInFromRight 1.2s cubic-bezier(0.5, 0.8, 0.3, 1.1) forwards;\n }\n .rblyn-proactive-close-enter-left {\n animation: slideInFromLeft 1.2s cubic-bezier(0.5, 0.8, 0.3, 1.1) forwards;\n }\n /* Reset styles for proactive message content to prevent website CSS interference */\n /* Only target children of the content wrapper, not the bubble container itself */\n .rblyn-proactive-message-content * {\n box-sizing: border-box !important;\n margin: 0 !important;\n padding: 0 !important;\n border: none !important;\n background: transparent;\n font-family: ".concat(_,' !important;\n font-size: inherit !important;\n font-weight: inherit !important;\n line-height: inherit !important;\n color: inherit;\n text-align: inherit;\n list-style: none;\n }\n .rblyn-proactive-message-content p,\n .rblyn-proactive-message-content div,\n .rblyn-proactive-message-content span {\n display: inline !important;\n margin: 0 !important;\n padding: 0 !important;\n }\n .rblyn-proactive-message-content p:first-child,\n .rblyn-proactive-message-content div:first-child,\n .rblyn-proactive-message-content span:first-child {\n margin-top: 0 !important;\n }\n .rblyn-proactive-message-content p:last-child,\n .rblyn-proactive-message-content div:last-child,\n .rblyn-proactive-message-content span:last-child {\n margin-bottom: 0 !important;\n }\n .rblyn-proactive-message-content a {\n color: inherit !important;\n text-decoration: underline !important;\n cursor: pointer !important;\n }\n .rblyn-proactive-message-content a:hover {\n opacity: 0.8 !important;\n }\n .rblyn-proactive-message-content b,\n .rblyn-proactive-message-content strong {\n font-weight: 600 !important;\n }\n .rblyn-proactive-message-content i,\n .rblyn-proactive-message-content em {\n font-style: italic !important;\n }\n .rblyn-proactive-message-content u {\n text-decoration: underline !important;\n }\n .rblyn-proactive-message-content br {\n display: block !important;\n content: "" !important;\n margin-top: 0.5em !important;\n }\n '),document.head.appendChild(e)}},e.prototype.renderProactiveIfNeeded=function(e){var t,n,i,o,r,a,l,s,c,d,u,p,f=this,m=null===(n=null===(t=this.config)||void 0===t?void 0:t.config)||void 0===n?void 0:n.proactive_message_obj;if(Array.isArray(m)&&!this.config.isIframeVisible&&!k()){if(this.injectAnimationStyles(),!this.proactiveElement){var h=document.createElement("div");h.style.position="fixed";var v=null!==(a=null!==(o=this.config.bottomSpacing)&&void 0!==o?o:null===(r=this.config.config.interface_properties)||void 0===r?void 0:r.bottom_spacing)&&void 0!==a?a:20,g=null!==(c=null!==(l=this.config.sideSpacing)&&void 0!==l?l:null===(s=this.config.config.interface_properties)||void 0===s?void 0:s.side_spacing)&&void 0!==c?c:20,y=this.config.position||(null===(d=this.config.config.interface_properties)||void 0===d?void 0:d.position)||"Right";h.style.bottom="".concat(v+(this.config.config.launcher_type===exports.LauncherType.IMAGE?48:40)+8,"px"),"Right"===y?h.style.right="".concat(g,"px"):h.style.left="".concat(g,"px"),h.style.maxWidth="22.875rem",h.style.zIndex="2147483646";var b=document.createElement("div");b.style.display="flex",b.style.flexDirection="column",b.style.alignItems="Right"===y?"flex-end":"flex-start";var E=document.createElement("div");E.style.position="absolute",E.style.top="-32px",E.style.width="24px",E.style.height="24px",E.style.borderRadius="50%",E.style.background="#fff",E.style.boxShadow="0 2.667px 2.667px 0 rgba(0, 0, 0, 0.25)",E.style.display="flex",E.style.alignItems="center",E.style.justifyContent="center",E.style.cursor="pointer",E.style.opacity="0",E.style.visibility="hidden","Right"===(this.config.position||(null===(u=this.config.config.interface_properties)||void 0===u?void 0:u.position)||"Right")?(E.style.right="0px",E.style.left="auto",E.style.transform="translateX(120%) scale(0.95)"):(E.style.left="0px",E.style.right="auto",E.style.transform="translateX(-120%) scale(0.95)"),E.onclick=function(e){e.stopPropagation(),f.hideProactiveMessages()},E.innerHTML='\n <svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 14 14" fill="none">\n <path d="M10.3334 10.3334L7.00009 7.00009M7.00009 7.00009L3.66675 3.66675M7.00009 7.00009L10.3334 3.66675M7.00009 7.00009L3.66675 10.3334" stroke="#444547" stroke-width="0.816326" stroke-linecap="round" stroke-linejoin="round"/>\n </svg>\n ',h.appendChild(b),h.appendChild(E),document.body.appendChild(h),this.proactiveElement=h}var T=this.proactiveElement.children[0];T.innerHTML="";var x="Right"===(this.config.position||(null===(p=this.config.config.interface_properties)||void 0===p?void 0:p.position)||"Right");T.style.display="flex",T.style.flexDirection="column",T.style.alignItems=x?"flex-end":"flex-start",this.clearProactiveDelays();var I=U(m),S=I.length>0?I[I.length-1].delayMs:0,C=this.proactiveElement.children[1];if(C&&I.length>0){C.style.opacity="0",C.style.visibility="hidden",C.style.transform=x?"translateX(120%) scale(0.95)":"translateX(-120%) scale(0.95)";var A=window.setTimeout((function(){C.style.visibility="visible",C.style.animationDelay="0ms",C.className=x?"rblyn-proactive-close-enter-right":"rblyn-proactive-close-enter-left"}),S);this.delayTimers.push(A)}else C&&(C.style.opacity="0",C.style.visibility="hidden");I.forEach((function(e,t){var n=window.setTimeout((function(){var n=document.createElement("div");n.style.background="#fff",n.style.color="#111",n.style.borderRadius="12px",n.style.boxShadow="0 2px 2px 0 rgba(0, 0, 0, 0.08)",n.style.padding="16px",n.style.border="1px solid #F1F2F4",n.style.cursor="pointer",n.style.fontFamily=_,n.style.fontSize="14px",n.style.lineHeight=String(w),n.style.width="fit-content",n.style.maxWidth="100%",t<I.length-1&&(n.style.marginBottom="16px");var i=10*(I.length-1-t);n.className=x?"rblyn-proactive-enter-right":"rblyn-proactive-enter-left",n.style.animationDelay="".concat(i,"ms"),n.style.opacity="0",n.style.transform=x?"translateX(120%) scale(0.95)":"translateX(-120%) scale(0.95)";var o=document.createElement("div");o.className="rblyn-proactive-message-content",o.innerHTML=Ve(e.html),n.appendChild(o),n.onclick=function(){M({message_id:e.messageId,content_string:e.html||null}),f.config.toggleIframe(),f.hideProactiveMessages();try{window.dispatchEvent(new CustomEvent("rblyn:proactiveClick",{detail:{message_id:e.messageId,content_string:e.html||null}}))}catch(e){}},T.appendChild(n)}),e.delayMs);f.delayTimers.push(n)}))}else if(this.proactiveElement&&this.proactiveElement.parentElement){var O=this.proactiveElement.children[0],R="Right"===(this.config.position||(null===(i=this.config.config.interface_properties)||void 0===i?void 0:i.position)||"Right");Array.from(O.children).forEach((function(e){e.className=R?"rblyn-proactive-exit-right":"rblyn-proactive-exit-left"})),setTimeout((function(){f.proactiveElement&&f.proactiveElement.parentElement&&f.proactiveElement.parentElement.removeChild(f.proactiveElement),f.proactiveElement=null,f.clearProactiveDelays()}),400)}else this.proactiveElement=null,this.clearProactiveDelays()},e}(),Ft=function(){function e(e){var t=this;this.isInitialized=!1,this.hasRegistered=!1,this.overridesPayloadCache=null,this.handleMessage=function(e){var n,i,o,r,a,l,s,c,d,u,p,f,m,g,b,_=y().copilotUrl;if(e.origin===_){if("closeChatbot"===e.data)return void t.config.onClose();if("CHATBOT_TOKEN_EXHAUSTED"===(null===(n=e.data)||void 0===n?void 0:n.type))return void t.config.onInternalEvent(v.CHATBOT_TOKEN_EXHAUSTED);"CHATBOT_LOADED"===(null===(i=e.data)||void 0===i?void 0:i.type)&&(null===(r=(o=t.config).onEvent)||void 0===r||r.call(o,{type:h.CHATBOT_LOADED,timestamp:Date.now()}),t.config.onInternalEvent(h.CHATBOT_LOADED)),"CHAT_INITIALIZED"===(null===(a=e.data)||void 0===a?void 0:a.type)&&(null===(s=(l=t.config).onEvent)||void 0===s||s.call(l,{type:h.CHAT_INITIALIZED,timestamp:Date.now()}),t.config.onInternalEvent(h.CHAT_INITIALIZED)),"CHAT_INITIALIZATION_FAILED"===(null===(c=e.data)||void 0===c?void 0:c.type)&&(null===(u=(d=t.config).onEvent)||void 0===u||u.call(d,{type:h.CHAT_INITIALIZATION_FAILED,timestamp:Date.now()}),t.config.onInternalEvent(h.CHAT_INITIALIZATION_FAILED,{error:null===(p=e.data)||void 0===p?void 0:p.error})),"SESSION_REFRESHED"===(null===(f=e.data)||void 0===f?void 0:f.type)&&(null===(g=(m=t.config).onEvent)||void 0===g||g.call(m,{type:h.SESSION_REFRESHED,timestamp:Date.now()}),t.config.onInternalEvent(h.SESSION_REFRESHED)),"CHAT_MOVED"===(null===(b=e.data)||void 0===b?void 0:b.type)&&t.config.onInternalEvent(v.CHAT_MOVED,{from:e.data.from,to:e.data.to,trigger:e.data.trigger})}},this.config=e,this.iframeElement=document.createElement("iframe"),this.iframeElement.id="chat-iframe-rbyln",this.resizeHandler=this.applyResponsiveStyles.bind(this),this.render(),this.initialize(),this.setupEventListeners()}return e.prototype.getElement=function(){return this.iframeElement},e.prototype.render=function(){var e,t=this.config.position||(null===(e=this.config.config.interface_properties)||void 0===e?void 0:e.position)||"Right";Object.assign(this.iframeElement.style,{zIndex:"20000000",border:"none",boxShadow:"0px 0px 40px 0px rgba(14, 14, 15, 0.24)",transformOrigin:"bottom ".concat(t.toLowerCase()),transition:"transform 0.2s cubic-bezier(0.2, 1.27, 0.29, 0.97), opacity 0.15s ease-out",transform:"scale(0.3) translate3d(0,40px,0)",opacity:"0",display:"none"}),this.applyResponsiveStyles()},e.prototype.applyResponsiveStyles=function(){var e,t,n,i,o,r;if(this.iframeElement){var a=this.config.position||(null===(n=this.config.config.interface_properties)||void 0===n?void 0:n.position)||"Right",l=null!==(r=null!==(i=this.config.bottomSpacing)&&void 0!==i?i:null===(o=this.config.config.interface_properties)||void 0===o?void 0:o.bottom_spacing)&&void 0!==r?r:20;window.innerWidth<560?Object.assign(this.iframeElement.style,((e={width:"100vw",minWidth:"300px"})[a.toLowerCase()]="0",e.bottom="0",e.height="100vh",e.flexDirection="column",e.flexGrow="1",e.borderRadius="0",e.top="0",e.maxHeight="100%",e.position="fixed",e)):Object.assign(this.iframeElement.style,((t={width:"26%",minWidth:"400px",height:"calc(100vh - 2rem - 10vh - ".concat(l,"px)"),borderRadius:"1rem",top:"calc(10vh - 32px)",maxHeight:"50rem",position:""})[a.toLowerCase()]=void 0,t))}},e.prototype.initialize=function(){var e=this;if(!this.isInitialized){var t=y().copilotUrl;this.iframeElement.src="".concat(t,"/chatbot-plugin?id=").concat(this.config.config.chatbotId),this.isInitialized=!0,this.iframeElement.addEventListener("load",(function(){var n,i,o,r,a,l,s,c,d,u,p,f,m,h,v,g,y,b,_=new URL(e.iframeElement.src).origin||t;null===(n=e.iframeElement.contentWindow)||void 0===n||n.postMessage({domain:null===(i=null===window||void 0===window?void 0:window.location)||void 0===i?void 0:i.hostname,name:"checkDomain"},_);var w={header_avatar:null!==(r=null===(o=e.config.overrides)||void 0===o?void 0:o.header_avatar)&&void 0!==r?r:null,agent_avatar:null!==(l=null===(a=e.config.overrides)||void 0===a?void 0:a.agent_avatar)&&void 0!==l?l:null,header_title:null!==(c=null===(s=e.config.overrides)||void 0===s?void 0:s.header_title)&&void 0!==c?c:null,header_subtitle:null!==(u=null===(d=e.config.overrides)||void 0===d?void 0:d.header_subtitle)&&void 0!==u?u:null,header_title_text_color:null!==(f=null===(p=e.config.overrides)||void 0===p?void 0:p.header_title_text_color)&&void 0!==f?f:null,header_subtitle_text_color:null!==(h=null===(m=e.config.overrides)||void 0===m?void 0:m.header_subtitle_text_color)&&void 0!==h?h:null,header_bg:null!==(g=null===(v=e.config.overrides)||void 0===v?void 0:v.header_bg)&&void 0!==g?g:null};null===(y=e.iframeElement.contentWindow)||void 0===y||y.postMessage({domain:null===(b=null===window||void 0===window?void 0:window.location)||void 0===b?void 0:b.hostname,action:"updateOverrides",data:w},_)}))}},e.prototype.setupEventListeners=function(){var e=this;window.addEventListener("resize",this.resizeHandler),this.iframeElement.addEventListener("error",(function(){nt.trackError(new Error(yt[ut]({src:e.iframeElement.src,error:"Failed to load iframe"})),"ChatbotIframe",{errorCode:ut,errorType:vt,context:{config:e.config.config,iframeUrl:e.iframeElement.src,timestamp:Date.now()}})})),window.addEventListener("message",this.handleMessage);window.addEventListener("rblyn:proactiveClick",(function(t){var n,i,o,r,a,l;if(e.hasRegistered){var s=(null==t?void 0:t.detail)||{},c=y().copilotUrl,d=new URL(e.iframeElement.src).origin||c;null===(n=e.iframeElement.contentWindow)||void 0===n||n.postMessage({domain:null===(i=null===window||void 0===window?void 0:window.location)||void 0===i?void 0:i.hostname,action:"proactiveClick",data:{userId:null===(o=e.config.config)||void 0===o?void 0:o.userId,token:null===(r=e.config.config)||void 0===r?void 0:r.token,userProfile:null===(a=e.config.config)||void 0===a?void 0:a.userProfile,isAnonymous:null===(l=e.config.config)||void 0===l?void 0:l.isAnonymous,proactiveData:{input_id:null,message_id:(null==s?void 0:s.message_id)||null,content_string:(null==s?void 0:s.content_string)||null}}},d)}}))},e.prototype.updateVisibility=function(e){var t,n,i,o,r,a,l,c,d,u=this;this.config.isVisible=e;var p=this.config.position||(null===(t=this.config.config.interface_properties)||void 0===t?void 0:t.position)||"Right";if(e?(this.iframeElement.style.display="block",this.iframeElement.getBoundingClientRect(),this.iframeElement.style.opacity="1",this.iframeElement.style.transform="scale(1) translate3d(0,0,0)"):(this.iframeElement.style.opacity="0",this.iframeElement.style.transform="scale(0.3) translate3d(".concat((p.toLowerCase(),"0"),",40px,0)"),setTimeout((function(){u.config.isVisible||(u.iframeElement.style.display="none")}),200)),this.iframeElement.contentWindow&&e){var f=y().copilotUrl,m=new URL(this.iframeElement.src).origin||f;if(this.iframeElement.contentWindow.postMessage({domain:null===(n=null===window||void 0===window?void 0:window.location)||void 0===n?void 0:n.hostname,name:"openFrame"},m),!this.hasRegistered){var v=z();this.iframeElement.contentWindow.postMessage({domain:null===(i=null===window||void 0===window?void 0:window.location)||void 0===i?void 0:i.hostname,action:"registerUserId",data:s({userId:null===(o=this.config.config)||void 0===o?void 0:o.userId,token:null===(r=this.config.config)||void 0===r?void 0:r.token,userProfile:null===(a=this.config.config)||void 0===a?void 0:a.userProfile,isAnonymous:null===(l=this.config.config)||void 0===l?void 0:l.isAnonymous},v?{proactiveData:v}:{})},m),this.hasRegistered=!0}null===(d=(c=this.config).onEvent)||void 0===d||d.call(c,{type:h.CHATBOT_OPENED,timestamp:Date.now()}),this.config.onInternalEvent(h.CHATBOT_OPENED)}},e.prototype.update=function(e){var t=this.config.isVisible;if(this.config=s(s({},this.config),e),t!==this.config.isVisible&&this.updateVisibility(this.config.isVisible),this.iframeElement.contentWindow&&this.config.isVisible){var n=y().copilotUrl;this.iframeElement.contentWindow.postMessage({action:"updateUserProfile",user_profile:this.config.config.userProfile},n)}},e.prototype.destroy=function(){window.removeEventListener("resize",this.resizeHandler),window.removeEventListener("message",this.handleMessage),this.iframeElement&&this.iframeElement.parentNode&&this.iframeElement.parentNode.removeChild(this.iframeElement)},e}(),Ut=function(){function e(e,t,n,i){this.resizeObserver=null,this.containerElement=document.createElement("div"),this.handleResizeFunction=this.handleResize.bind(this),this.config={config:e,position:t,sideSpacing:n,bottomSpacing:i},this.render(),this.mount(),this.setupResizeListener()}return e.prototype.render=function(){this.applyStyles(),this.containerElement.className="robylon-chatbot-container"},e.prototype.applyStyles=function(){var e,t,n,i,o,r,a,l,c,d=(null===window||void 0===window?void 0:window.innerWidth)<560,u=this.config.position||(null===(n=this.config.config.interface_properties)||void 0===n?void 0:n.position)||"Right",p=null!==(r=null!==(i=this.config.sideSpacing)&&void 0!==i?i:null===(o=this.config.config.interface_properties)||void 0===o?void 0:o.side_spacing)&&void 0!==r?r:20,f=null!==(c=null!==(a=this.config.bottomSpacing)&&void 0!==a?a:null===(l=this.config.config.interface_properties)||void 0===l?void 0:l.bottom_spacing)&&void 0!==c?c:20;this.containerElement.style.position="",this.containerElement.style.top="",this.containerElement.style.bottom="",this.containerElement.style.right="",this.containerElement.style.left="",this.containerElement.style.alignItems="";var m={position:"fixed",zIndex:"1000",display:"flex",flexDirection:"column"},h=s(s({},m),((e={bottom:"".concat(f,"px")})[u.toLowerCase()]="".concat(p,"px"),e.alignItems="Right"===u?"flex-end":"flex-start",e)),v=s(s({},m),((t={top:"0"})[u.toLowerCase()]="".concat(p,"px"),t.alignItems="center",t));Object.assign(this.containerElement.style,d?v:h)},e.prototype.handleResize=function(){this.applyStyles()},e.prototype.setupResizeListener=function(){"undefined"!=typeof ResizeObserver?(this.resizeObserver=new ResizeObserver(this.handleResizeFunction),this.resizeObserver.observe(document.body)):window.addEventListener("resize",this.handleResizeFunction)},e.prototype.mount=function(){document.body.appendChild(this.containerElement)},e.prototype.getElement=function(){return this.containerElement},e.prototype.destroy=function(){this.resizeObserver?(this.resizeObserver.disconnect(),this.resizeObserver=null):window.removeEventListener("resize",this.handleResizeFunction),this.containerElement&&this.containerElement.parentNode&&this.containerElement.parentNode.removeChild(this.containerElement)},e}(),Pt=function(e){e.api_key,e.user_profile;var t=e.onEvent;e.chatbotConfig;return{emit:function(e,n){var i={type:e,timestamp:Date.now(),data:n};null==t||t(i)},onInternalEvent:function(e,t){}}},Bt=function(){function e(e){var t=this;this.container=null,this.floatingButton=null,this.launcherDelayTimeout=null,this.iframe=null,this.isDestroyed=!1,this.handleStateChange=function(e){var n,i,o,r,a,l;if(!t.isDestroyed){var s=e.isInitialized,c=e.error,d=e.chatbotConfig,u=e.isIframeVisible;if(!c&&d&&s){if(t.eventEmitter=Pt({api_key:t.config.api_key,user_profile:t.config.user_profile,onEvent:t.config.onEvent,chatbotConfig:{isAnonymous:d.isAnonymous,userId:d.userId}}),t.container||(t.container=new Ut(d,t.config.position,t.config.sideSpacing,t.config.bottomSpacing)),t.iframe)t.iframe.update({config:d,isVisible:u,position:t.config.position,bottomSpacing:t.config.bottomSpacing,overrides:t.config.overrides});else if(t.iframe=new Ft({config:d,isVisible:u,onClose:t.handleClose,onEvent:t.config.onEvent,onInternalEvent:t.eventEmitter.onInternalEvent,position:t.config.position,bottomSpacing:t.config.bottomSpacing,overrides:t.config.overrides}),t.iframe.getElement&&"function"==typeof t.iframe.getElement){var p=t.iframe.getElement();p&&t.container&&t.container.getElement().prepend(p)}var f=void 0!==t.config.show_launcher?Boolean(t.config.show_launcher):null===(n=null==d?void 0:d.show_launcher)||void 0===n||n,m=!0===(null===(i=null==d?void 0:d.launcher_delay)||void 0===i?void 0:i.enabled),h=null!==(l=null!==(r=null===(o=null==d?void 0:d.launcher_delay)||void 0===o?void 0:o.seconds)&&void 0!==r?r:null===(a=null==d?void 0:d.launcher_delay)||void 0===a?void 0:a.delay)&&void 0!==l?l:0,v=function(){if(t.floatingButton)t.floatingButton.update({config:d,isIframeVisible:u,position:t.config.position,sideSpacing:t.config.sideSpacing,bottomSpacing:t.config.bottomSpacing});else if(t.floatingButton=new Ht({config:d,toggleIframe:t.toggleIframe,isIframeVisible:u,onEvent:t.config.onEvent,onInternalEvent:t.eventEmitter.onInternalEvent,position:t.config.position,sideSpacing:t.config.sideSpacing,bottomSpacing:t.config.bottomSpacing}),t.floatingButton.getElement&&"function"==typeof t.floatingButton.getElement){var e=t.floatingButton.getElement();e&&t.container&&t.container.getElement().appendChild(e)}};t.launcherDelayTimeout&&(clearTimeout(t.launcherDelayTimeout),t.launcherDelayTimeout=null),f?m&&Number(h)>0&&!t.floatingButton?t.launcherDelayTimeout=window.setTimeout((function(){v(),t.launcherDelayTimeout=null}),1e3*Number(h)):v():t.floatingButton&&(t.floatingButton.destroy(),t.floatingButton=null)}}},this.toggleIframe=function(){var e=t.stateManager.getState();t.stateManager.toggleIframeVisibility(),t.eventEmitter.emit(e.isIframeVisible?h.CHATBOT_CLOSED:h.CHATBOT_BUTTON_CLICKED)},this.handleClose=function(){t.stateManager.closeIframe(),t.eventEmitter.emit(h.CHATBOT_CLOSED)};var n=s(s({},e),{position:"string"==typeof e.position?"left"===e.position.toLowerCase()?"Left":"right"===e.position.toLowerCase()?"Right":void 0:void 0,sideSpacing:"string"==typeof e.sideSpacing?""===e.sideSpacing||isNaN(Number(e.sideSpacing))?void 0:Number(e.sideSpacing):e.sideSpacing,bottomSpacing:"string"==typeof e.bottomSpacing?""===e.bottomSpacing||isNaN(Number(e.bottomSpacing))?void 0:Number(e.bottomSpacing):e.bottomSpacing,show_launcher:e.show_launcher,overrides:e.overrides});if(this.config=n,!e.api_key)throw nt.trackError(new Error(yt[it](e.api_key)),"RobylonChatbot",{errorCode:it,errorType:mt,context:{timestamp:Date.now()}}),new Error("API key is required");try{nt.initialize(e.api_key,e.user_id)}catch(e){nt.trackError(e instanceof Error?e:new Error(String(e)),"RobylonChatbot",{errorCode:lt,errorType:mt,context:{timestamp:Date.now()}})}this.stateManager=function(e){var t={isInitialized:!1,isInitializing:!1,error:null,chatbotConfig:null,isIframeVisible:!1},n=[],i=function(e){t=s(s({},t),e),n.forEach((function(e){return e(t)}))};return{getState:function(){return t},initialize:function(){return c(void 0,void 0,void 0,(function(){var t,n,o;return d(this,(function(r){switch(r.label){case 0:if(!e.api_key)return nt.trackError(new Error(yt[it](e.api_key)),"ChatbotStateManager",{errorCode:it,errorType:mt,context:{timestamp:Date.now()}}),[2];i({isInitializing:!0}),r.label=1;case 1:return r.trys.push([1,4,5,6]),[4,Dt(e)];case 2:return t=r.sent(),[4,new Promise((function(e,n){Ot(t,(function(){i({isInitialized:!0,chatbotConfig:t}),e()}),(function(e){n(e)}))}))];case 3:return r.sent(),[3,6];case 4:return n=r.sent(),o=n instanceof Error?n.message:"Failed to initialize chatbot",i({error:o}),nt.trackError(n instanceof Error?n:new Error(o),"ChatbotStateManager",{errorCode:at,errorType:mt,context:{timestamp:Date.now()}}),[3,6];case 5:return i({isInitializing:!1}),[7];case 6:return[2]}}))}))},toggleIframeVisibility:function(){i({isIframeVisible:!t.isIframeVisible})},closeIframe:function(){i({isIframeVisible:!1})},updateState:i,subscribe:function(e){return n.push(e),function(){var t=n.indexOf(e);t>-1&&n.splice(t,1)}},unsubscribe:function(e){var t=n.indexOf(e);t>-1&&n.splice(t,1)}}}({api_key:e.api_key,user_id:e.user_id,user_token:e.user_token,user_profile:e.user_profile}),this.eventEmitter=Pt({api_key:e.api_key,user_profile:e.user_profile,onEvent:e.onEvent,chatbotConfig:null}),this.initialize()}return e.prototype.initialize=function(){return c(this,void 0,void 0,(function(){var e;return d(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,this.stateManager.initialize()];case 1:return t.sent(),this.stateManager.subscribe(this.handleStateChange),this.handleStateChange(this.stateManager.getState()),[3,3];case 2:return e=t.sent(),nt.trackError(e instanceof Error?e:new Error(String(e)),"RobylonChatbot.initialize",{errorCode:at,errorType:mt,context:{timestamp:Date.now()}}),[3,3];case 3:return[2]}}))}))},e.prototype.show=function(){this.stateManager.getState().isIframeVisible||(this.stateManager.toggleIframeVisibility(),this.eventEmitter.emit(h.CHATBOT_BUTTON_CLICKED))},e.prototype.hide=function(){this.stateManager.getState().isIframeVisible&&(this.stateManager.closeIframe(),this.eventEmitter.emit(h.CHATBOT_CLOSED))},e.prototype.toggle=function(){this.toggleIframe()},e.prototype.destroy=function(){this.isDestroyed=!0,this.floatingButton&&(this.floatingButton.destroy(),this.floatingButton=null),this.launcherDelayTimeout&&(clearTimeout(this.launcherDelayTimeout),this.launcherDelayTimeout=null),this.iframe&&(this.iframe.destroy(),this.iframe=null),this.container&&(this.container.destroy(),this.container=null),this.stateManager.unsubscribe(this.handleStateChange)},e.prototype.getState=function(){return this.stateManager.getState().isInitialized?"initialized":"uninitialized"},e}();function Wt(e){return new Bt(e)}"undefined"!=typeof window&&function(){if("undefined"!=typeof window){var e=window.RobylonChatbot;if(e&&Array.isArray(e.q)){var t=null;e.q.forEach((function(e){var n=e[0];if("init"===n){var i=e[1]||{};t=Wt(i)}else t&&"function"==typeof t[n]&&t[n]()})),window.RobylonChatbot=function(e){var n=Array.prototype.slice.call(arguments,1);return"init"===e?t=Wt(n[0]||{}):t&&"function"==typeof t[e]?t[e].apply(t,n):void 0},window.RobylonChatbot.getState=function(){return"initialized"}}}}();var jt={create:Wt,getState:function(){return"initialized"}};exports.Chatbot=zt,exports.RobylonChatbot=jt,exports.useChatbot=function(t){var n=e.useState({isLoading:!0,isInitialized:!1,error:null}),i=n[0],o=n[1],r=function(e){o((function(t){return s(s({},t),{isInitialized:e})}))},a=function(e){o((function(t){return s(s({},t),{error:e})}))};return e.useEffect((function(){!function(){try{Ot(t,r,a)}catch(e){o((function(t){return s(s({},t),{error:e instanceof Error?e.message:"Failed to initialize SDK",isLoading:!1})}))}}()}),[t.chatbotId,t.userId]),i};
|
|
3
|
+
const{entries:P,setPrototypeOf:B,isFrozen:W,getPrototypeOf:j,getOwnPropertyDescriptor:G}=Object;let{freeze:X,seal:V,create:Y}=Object,{apply:K,construct:J}="undefined"!=typeof Reflect&&Reflect;X||(X=function(e){return e}),V||(V=function(e){return e}),K||(K=function(e,t){for(var n=arguments.length,i=new Array(n>2?n-2:0),o=2;o<n;o++)i[o-2]=arguments[o];return e.apply(t,i)}),J||(J=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];return new e(...n)});const Z=ue(Array.prototype.forEach),q=ue(Array.prototype.lastIndexOf),Q=ue(Array.prototype.pop),$=ue(Array.prototype.push),ee=ue(Array.prototype.splice),te=ue(String.prototype.toLowerCase),ne=ue(String.prototype.toString),ie=ue(String.prototype.match),oe=ue(String.prototype.replace),re=ue(String.prototype.indexOf),ae=ue(String.prototype.trim),le=ue(Object.prototype.hasOwnProperty),se=ue(RegExp.prototype.test),ce=(de=TypeError,function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return J(de,t)});var de;function ue(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,i=new Array(n>1?n-1:0),o=1;o<n;o++)i[o-1]=arguments[o];return K(e,t,i)}}function pe(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:te;B&&B(e,null);let i=t.length;for(;i--;){let o=t[i];if("string"==typeof o){const e=n(o);e!==o&&(W(t)||(t[i]=e),o=e)}e[o]=!0}return e}function fe(e){for(let t=0;t<e.length;t++){le(e,t)||(e[t]=null)}return e}function me(e){const t=Y(null);for(const[n,i]of P(e)){le(e,n)&&(Array.isArray(i)?t[n]=fe(i):i&&"object"==typeof i&&i.constructor===Object?t[n]=me(i):t[n]=i)}return t}function he(e,t){for(;null!==e;){const n=G(e,t);if(n){if(n.get)return ue(n.get);if("function"==typeof n.value)return ue(n.value)}e=j(e)}return function(){return null}}const ve=X(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),ge=X(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),ye=X(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),be=X(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),_e=X(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),we=X(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Ee=X(["#text"]),Te=X(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),xe=X(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),Ie=X(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Se=X(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Ce=V(/\{\{[\w\W]*|[\w\W]*\}\}/gm),Ae=V(/<%[\w\W]*|[\w\W]*%>/gm),Oe=V(/\$\{[\w\W]*/gm),Re=V(/^data-[\-\w.\u00B7-\uFFFF]+$/),De=V(/^aria-[\-\w]+$/),Ne=V(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Le=V(/^(?:\w+script|data):/i),ke=V(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Me=V(/^html$/i),ze=V(/^[a-z][.\w]*(-[.\w]+)+$/i);var He=Object.freeze({__proto__:null,ARIA_ATTR:De,ATTR_WHITESPACE:ke,CUSTOM_ELEMENT:ze,DATA_ATTR:Re,DOCTYPE_NAME:Me,ERB_EXPR:Ae,IS_ALLOWED_URI:Ne,IS_SCRIPT_OR_DATA:Le,MUSTACHE_EXPR:Ce,TMPLIT_EXPR:Oe});const Fe=1,Ue=3,Pe=7,Be=8,We=9,je=function(){return"undefined"==typeof window?null:window};var Ge,Xe=function e(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:je();const n=t=>e(t);if(n.version="3.3.0",n.removed=[],!t||!t.document||t.document.nodeType!==We||!t.Element)return n.isSupported=!1,n;let{document:i}=t;const o=i,r=o.currentScript,{DocumentFragment:a,HTMLTemplateElement:l,Node:s,Element:c,NodeFilter:d,NamedNodeMap:u=t.NamedNodeMap||t.MozNamedAttrMap,HTMLFormElement:p,DOMParser:f,trustedTypes:m}=t,h=c.prototype,v=he(h,"cloneNode"),g=he(h,"remove"),y=he(h,"nextSibling"),b=he(h,"childNodes"),_=he(h,"parentNode");if("function"==typeof l){const e=i.createElement("template");e.content&&e.content.ownerDocument&&(i=e.content.ownerDocument)}let w,E="";const{implementation:T,createNodeIterator:x,createDocumentFragment:I,getElementsByTagName:S}=i,{importNode:C}=o;let A={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]};n.isSupported="function"==typeof P&&"function"==typeof _&&T&&void 0!==T.createHTMLDocument;const{MUSTACHE_EXPR:O,ERB_EXPR:R,TMPLIT_EXPR:D,DATA_ATTR:N,ARIA_ATTR:L,IS_SCRIPT_OR_DATA:k,ATTR_WHITESPACE:M,CUSTOM_ELEMENT:z}=He;let{IS_ALLOWED_URI:H}=He,F=null;const U=pe({},[...ve,...ge,...ye,..._e,...Ee]);let B=null;const W=pe({},[...Te,...xe,...Ie,...Se]);let j=Object.seal(Y(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),G=null,V=null;const K=Object.seal(Y(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let J=!0,de=!0,ue=!1,fe=!0,Ce=!1,Ae=!0,Oe=!1,Re=!1,De=!1,Le=!1,ke=!1,ze=!1,Ge=!0,Xe=!1,Ve=!0,Ye=!1,Ke={},Je=null;const Ze=pe({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let qe=null;const Qe=pe({},["audio","video","img","source","image","track"]);let $e=null;const et=pe({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),tt="http://www.w3.org/1998/Math/MathML",nt="http://www.w3.org/2000/svg",it="http://www.w3.org/1999/xhtml";let ot=it,rt=!1,at=null;const lt=pe({},[tt,nt,it],ne);let st=pe({},["mi","mo","mn","ms","mtext"]),ct=pe({},["annotation-xml"]);const dt=pe({},["title","style","font","a","script"]);let ut=null;const pt=["application/xhtml+xml","text/html"];let ft=null,mt=null;const ht=i.createElement("form"),vt=function(e){return e instanceof RegExp||e instanceof Function},gt=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!mt||mt!==e){if(e&&"object"==typeof e||(e={}),e=me(e),ut=-1===pt.indexOf(e.PARSER_MEDIA_TYPE)?"text/html":e.PARSER_MEDIA_TYPE,ft="application/xhtml+xml"===ut?ne:te,F=le(e,"ALLOWED_TAGS")?pe({},e.ALLOWED_TAGS,ft):U,B=le(e,"ALLOWED_ATTR")?pe({},e.ALLOWED_ATTR,ft):W,at=le(e,"ALLOWED_NAMESPACES")?pe({},e.ALLOWED_NAMESPACES,ne):lt,$e=le(e,"ADD_URI_SAFE_ATTR")?pe(me(et),e.ADD_URI_SAFE_ATTR,ft):et,qe=le(e,"ADD_DATA_URI_TAGS")?pe(me(Qe),e.ADD_DATA_URI_TAGS,ft):Qe,Je=le(e,"FORBID_CONTENTS")?pe({},e.FORBID_CONTENTS,ft):Ze,G=le(e,"FORBID_TAGS")?pe({},e.FORBID_TAGS,ft):me({}),V=le(e,"FORBID_ATTR")?pe({},e.FORBID_ATTR,ft):me({}),Ke=!!le(e,"USE_PROFILES")&&e.USE_PROFILES,J=!1!==e.ALLOW_ARIA_ATTR,de=!1!==e.ALLOW_DATA_ATTR,ue=e.ALLOW_UNKNOWN_PROTOCOLS||!1,fe=!1!==e.ALLOW_SELF_CLOSE_IN_ATTR,Ce=e.SAFE_FOR_TEMPLATES||!1,Ae=!1!==e.SAFE_FOR_XML,Oe=e.WHOLE_DOCUMENT||!1,Le=e.RETURN_DOM||!1,ke=e.RETURN_DOM_FRAGMENT||!1,ze=e.RETURN_TRUSTED_TYPE||!1,De=e.FORCE_BODY||!1,Ge=!1!==e.SANITIZE_DOM,Xe=e.SANITIZE_NAMED_PROPS||!1,Ve=!1!==e.KEEP_CONTENT,Ye=e.IN_PLACE||!1,H=e.ALLOWED_URI_REGEXP||Ne,ot=e.NAMESPACE||it,st=e.MATHML_TEXT_INTEGRATION_POINTS||st,ct=e.HTML_INTEGRATION_POINTS||ct,j=e.CUSTOM_ELEMENT_HANDLING||{},e.CUSTOM_ELEMENT_HANDLING&&vt(e.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(j.tagNameCheck=e.CUSTOM_ELEMENT_HANDLING.tagNameCheck),e.CUSTOM_ELEMENT_HANDLING&&vt(e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(j.attributeNameCheck=e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),e.CUSTOM_ELEMENT_HANDLING&&"boolean"==typeof e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements&&(j.allowCustomizedBuiltInElements=e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),Ce&&(de=!1),ke&&(Le=!0),Ke&&(F=pe({},Ee),B=[],!0===Ke.html&&(pe(F,ve),pe(B,Te)),!0===Ke.svg&&(pe(F,ge),pe(B,xe),pe(B,Se)),!0===Ke.svgFilters&&(pe(F,ye),pe(B,xe),pe(B,Se)),!0===Ke.mathMl&&(pe(F,_e),pe(B,Ie),pe(B,Se))),e.ADD_TAGS&&("function"==typeof e.ADD_TAGS?K.tagCheck=e.ADD_TAGS:(F===U&&(F=me(F)),pe(F,e.ADD_TAGS,ft))),e.ADD_ATTR&&("function"==typeof e.ADD_ATTR?K.attributeCheck=e.ADD_ATTR:(B===W&&(B=me(B)),pe(B,e.ADD_ATTR,ft))),e.ADD_URI_SAFE_ATTR&&pe($e,e.ADD_URI_SAFE_ATTR,ft),e.FORBID_CONTENTS&&(Je===Ze&&(Je=me(Je)),pe(Je,e.FORBID_CONTENTS,ft)),Ve&&(F["#text"]=!0),Oe&&pe(F,["html","head","body"]),F.table&&(pe(F,["tbody"]),delete G.tbody),e.TRUSTED_TYPES_POLICY){if("function"!=typeof e.TRUSTED_TYPES_POLICY.createHTML)throw ce('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if("function"!=typeof e.TRUSTED_TYPES_POLICY.createScriptURL)throw ce('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');w=e.TRUSTED_TYPES_POLICY,E=w.createHTML("")}else void 0===w&&(w=function(e,t){if("object"!=typeof e||"function"!=typeof e.createPolicy)return null;let n=null;const i="data-tt-policy-suffix";t&&t.hasAttribute(i)&&(n=t.getAttribute(i));const o="dompurify"+(n?"#"+n:"");try{return e.createPolicy(o,{createHTML:e=>e,createScriptURL:e=>e})}catch(e){return console.warn("TrustedTypes policy "+o+" could not be created."),null}}(m,r)),null!==w&&"string"==typeof E&&(E=w.createHTML(""));X&&X(e),mt=e}},yt=pe({},[...ge,...ye,...be]),bt=pe({},[..._e,...we]),_t=function(e){$(n.removed,{element:e});try{_(e).removeChild(e)}catch(t){g(e)}},wt=function(e,t){try{$(n.removed,{attribute:t.getAttributeNode(e),from:t})}catch(e){$(n.removed,{attribute:null,from:t})}if(t.removeAttribute(e),"is"===e)if(Le||ke)try{_t(t)}catch(e){}else try{t.setAttribute(e,"")}catch(e){}},Et=function(e){let t=null,n=null;if(De)e="<remove></remove>"+e;else{const t=ie(e,/^[\r\n\t ]+/);n=t&&t[0]}"application/xhtml+xml"===ut&&ot===it&&(e='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+e+"</body></html>");const o=w?w.createHTML(e):e;if(ot===it)try{t=(new f).parseFromString(o,ut)}catch(e){}if(!t||!t.documentElement){t=T.createDocument(ot,"template",null);try{t.documentElement.innerHTML=rt?E:o}catch(e){}}const r=t.body||t.documentElement;return e&&n&&r.insertBefore(i.createTextNode(n),r.childNodes[0]||null),ot===it?S.call(t,Oe?"html":"body")[0]:Oe?t.documentElement:r},Tt=function(e){return x.call(e.ownerDocument||e,e,d.SHOW_ELEMENT|d.SHOW_COMMENT|d.SHOW_TEXT|d.SHOW_PROCESSING_INSTRUCTION|d.SHOW_CDATA_SECTION,null)},xt=function(e){return e instanceof p&&("string"!=typeof e.nodeName||"string"!=typeof e.textContent||"function"!=typeof e.removeChild||!(e.attributes instanceof u)||"function"!=typeof e.removeAttribute||"function"!=typeof e.setAttribute||"string"!=typeof e.namespaceURI||"function"!=typeof e.insertBefore||"function"!=typeof e.hasChildNodes)},It=function(e){return"function"==typeof s&&e instanceof s};function St(e,t,i){Z(e,(e=>{e.call(n,t,i,mt)}))}const Ct=function(e){let t=null;if(St(A.beforeSanitizeElements,e,null),xt(e))return _t(e),!0;const i=ft(e.nodeName);if(St(A.uponSanitizeElement,e,{tagName:i,allowedTags:F}),Ae&&e.hasChildNodes()&&!It(e.firstElementChild)&&se(/<[/\w!]/g,e.innerHTML)&&se(/<[/\w!]/g,e.textContent))return _t(e),!0;if(e.nodeType===Pe)return _t(e),!0;if(Ae&&e.nodeType===Be&&se(/<[/\w]/g,e.data))return _t(e),!0;if(!(K.tagCheck instanceof Function&&K.tagCheck(i))&&(!F[i]||G[i])){if(!G[i]&&Ot(i)){if(j.tagNameCheck instanceof RegExp&&se(j.tagNameCheck,i))return!1;if(j.tagNameCheck instanceof Function&&j.tagNameCheck(i))return!1}if(Ve&&!Je[i]){const t=_(e)||e.parentNode,n=b(e)||e.childNodes;if(n&&t){for(let i=n.length-1;i>=0;--i){const o=v(n[i],!0);o.__removalCount=(e.__removalCount||0)+1,t.insertBefore(o,y(e))}}}return _t(e),!0}return e instanceof c&&!function(e){let t=_(e);t&&t.tagName||(t={namespaceURI:ot,tagName:"template"});const n=te(e.tagName),i=te(t.tagName);return!!at[e.namespaceURI]&&(e.namespaceURI===nt?t.namespaceURI===it?"svg"===n:t.namespaceURI===tt?"svg"===n&&("annotation-xml"===i||st[i]):Boolean(yt[n]):e.namespaceURI===tt?t.namespaceURI===it?"math"===n:t.namespaceURI===nt?"math"===n&&ct[i]:Boolean(bt[n]):e.namespaceURI===it?!(t.namespaceURI===nt&&!ct[i])&&!(t.namespaceURI===tt&&!st[i])&&!bt[n]&&(dt[n]||!yt[n]):!("application/xhtml+xml"!==ut||!at[e.namespaceURI]))}(e)?(_t(e),!0):"noscript"!==i&&"noembed"!==i&&"noframes"!==i||!se(/<\/no(script|embed|frames)/i,e.innerHTML)?(Ce&&e.nodeType===Ue&&(t=e.textContent,Z([O,R,D],(e=>{t=oe(t,e," ")})),e.textContent!==t&&($(n.removed,{element:e.cloneNode()}),e.textContent=t)),St(A.afterSanitizeElements,e,null),!1):(_t(e),!0)},At=function(e,t,n){if(Ge&&("id"===t||"name"===t)&&(n in i||n in ht))return!1;if(de&&!V[t]&&se(N,t));else if(J&&se(L,t));else if(K.attributeCheck instanceof Function&&K.attributeCheck(t,e));else if(!B[t]||V[t]){if(!(Ot(e)&&(j.tagNameCheck instanceof RegExp&&se(j.tagNameCheck,e)||j.tagNameCheck instanceof Function&&j.tagNameCheck(e))&&(j.attributeNameCheck instanceof RegExp&&se(j.attributeNameCheck,t)||j.attributeNameCheck instanceof Function&&j.attributeNameCheck(t,e))||"is"===t&&j.allowCustomizedBuiltInElements&&(j.tagNameCheck instanceof RegExp&&se(j.tagNameCheck,n)||j.tagNameCheck instanceof Function&&j.tagNameCheck(n))))return!1}else if($e[t]);else if(se(H,oe(n,M,"")));else if("src"!==t&&"xlink:href"!==t&&"href"!==t||"script"===e||0!==re(n,"data:")||!qe[e]){if(ue&&!se(k,oe(n,M,"")));else if(n)return!1}else;return!0},Ot=function(e){return"annotation-xml"!==e&&ie(e,z)},Rt=function(e){St(A.beforeSanitizeAttributes,e,null);const{attributes:t}=e;if(!t||xt(e))return;const i={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:B,forceKeepAttr:void 0};let o=t.length;for(;o--;){const r=t[o],{name:a,namespaceURI:l,value:s}=r,c=ft(a),d=s;let u="value"===a?d:ae(d);if(i.attrName=c,i.attrValue=u,i.keepAttr=!0,i.forceKeepAttr=void 0,St(A.uponSanitizeAttribute,e,i),u=i.attrValue,!Xe||"id"!==c&&"name"!==c||(wt(a,e),u="user-content-"+u),Ae&&se(/((--!?|])>)|<\/(style|title|textarea)/i,u)){wt(a,e);continue}if("attributename"===c&&ie(u,"href")){wt(a,e);continue}if(i.forceKeepAttr)continue;if(!i.keepAttr){wt(a,e);continue}if(!fe&&se(/\/>/i,u)){wt(a,e);continue}Ce&&Z([O,R,D],(e=>{u=oe(u,e," ")}));const p=ft(e.nodeName);if(At(p,c,u)){if(w&&"object"==typeof m&&"function"==typeof m.getAttributeType)if(l);else switch(m.getAttributeType(p,c)){case"TrustedHTML":u=w.createHTML(u);break;case"TrustedScriptURL":u=w.createScriptURL(u)}if(u!==d)try{l?e.setAttributeNS(l,a,u):e.setAttribute(a,u),xt(e)?_t(e):Q(n.removed)}catch(t){wt(a,e)}}else wt(a,e)}St(A.afterSanitizeAttributes,e,null)},Dt=function e(t){let n=null;const i=Tt(t);for(St(A.beforeSanitizeShadowDOM,t,null);n=i.nextNode();)St(A.uponSanitizeShadowNode,n,null),Ct(n),Rt(n),n.content instanceof a&&e(n.content);St(A.afterSanitizeShadowDOM,t,null)};return n.sanitize=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=null,r=null,l=null,c=null;if(rt=!e,rt&&(e="\x3c!--\x3e"),"string"!=typeof e&&!It(e)){if("function"!=typeof e.toString)throw ce("toString is not a function");if("string"!=typeof(e=e.toString()))throw ce("dirty is not a string, aborting")}if(!n.isSupported)return e;if(Re||gt(t),n.removed=[],"string"==typeof e&&(Ye=!1),Ye){if(e.nodeName){const t=ft(e.nodeName);if(!F[t]||G[t])throw ce("root node is forbidden and cannot be sanitized in-place")}}else if(e instanceof s)i=Et("\x3c!----\x3e"),r=i.ownerDocument.importNode(e,!0),r.nodeType===Fe&&"BODY"===r.nodeName||"HTML"===r.nodeName?i=r:i.appendChild(r);else{if(!Le&&!Ce&&!Oe&&-1===e.indexOf("<"))return w&&ze?w.createHTML(e):e;if(i=Et(e),!i)return Le?null:ze?E:""}i&&De&&_t(i.firstChild);const d=Tt(Ye?e:i);for(;l=d.nextNode();)Ct(l),Rt(l),l.content instanceof a&&Dt(l.content);if(Ye)return e;if(Le){if(ke)for(c=I.call(i.ownerDocument);i.firstChild;)c.appendChild(i.firstChild);else c=i;return(B.shadowroot||B.shadowrootmode)&&(c=C.call(o,c,!0)),c}let u=Oe?i.outerHTML:i.innerHTML;return Oe&&F["!doctype"]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&se(Me,i.ownerDocument.doctype.name)&&(u="<!DOCTYPE "+i.ownerDocument.doctype.name+">\n"+u),Ce&&Z([O,R,D],(e=>{u=oe(u,e," ")})),w&&ze?w.createHTML(u):u},n.setConfig=function(){gt(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),Re=!0},n.clearConfig=function(){mt=null,Re=!1},n.isValidAttribute=function(e,t,n){mt||gt({});const i=ft(e),o=ft(t);return At(i,o,n)},n.addHook=function(e,t){"function"==typeof t&&$(A[e],t)},n.removeHook=function(e,t){if(void 0!==t){const n=q(A[e],t);return-1===n?void 0:ee(A[e],n,1)[0]}return Q(A[e])},n.removeHooks=function(e){A[e]=[]},n.removeAllHooks=function(){A={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},n}(),Ve=function(e){return e?Xe.sanitize(e,{ALLOWED_TAGS:["b","strong","i","em","u","br","span","a","p","s"],ALLOWED_ATTR:["href","target","rel","style"],ALLOW_ARIA_ATTR:!1,ALLOW_DATA_ATTR:!1,RETURN_TRUSTED_TYPE:!1}):""},Ye=e.memo((function(t){var n,i,o,r,a,l,c,d,m,v,g,b,E,T,x,I,S,C=t.config,O=t.toggleIframe,R=t.isIframeVisible,D=t.onEvent,N=t.onInternalEvent,z=t.position,H=t.sideSpacing,F=t.bottomSpacing,P=t.launcher_type,B=t.launcher_properties_text,W=t.shouldFadeIn,j=e.useRef(null),G=y().copilotUrl,X=e.useState(!1),V=X[0],Y=X[1],K=e.useState(!1),J=K[0],Z=K[1],q=e.useState([]),Q=q[0],$=q[1],ee=e.useState(!1),te=ee[0],ne=ee[1],ie=e.useRef([]),oe=e.useRef();e.useEffect((function(){var e=function(){var e=(null===window||void 0===window?void 0:window.innerWidth)<560;Y(e)};return e(),window.addEventListener("resize",e),function(){window.removeEventListener("resize",e)}}),[]),e.useEffect((function(){j.current&&requestAnimationFrame((function(){null==D||D({type:h.CHATBOT_BUTTON_LOADED,timestamp:Date.now()}),N(h.CHATBOT_BUTTON_LOADED)}))}),[D,N]),e.useEffect((function(){if(j.current&&W){j.current.style.opacity="0";var e=requestAnimationFrame((function(){j.current&&(j.current.style.opacity="1")}));return function(){return cancelAnimationFrame(e)}}}),[W]);var re=z||(null===(o=C.interface_properties)||void 0===o?void 0:o.position)||"Right",ae=null!==(a=null!=H?H:null===(r=C.interface_properties)||void 0===r?void 0:r.side_spacing)&&void 0!==a?a:20,le=null!==(c=null!=F?F:null===(l=C.interface_properties)||void 0===l?void 0:l.bottom_spacing)&&void 0!==c?c:20,se=P||(null==C?void 0:C.launcher_type)||exports.LauncherType.IMAGE,ce=B||(null===(d=null==C?void 0:C.launcher_properties)||void 0===d?void 0:d.text),de={zIndex:1e3,display:"flex",flexDirection:"column-reverse",alignItems:"center",justifyContent:"center",cursor:"pointer",overflow:"hidden",marginTop:"16px",boxSizing:"border-box"};se===exports.LauncherType.IMAGE&&(de.width="48px",de.height="48px",de.borderRadius="50%",de.backgroundColor=C.brand_colour);var ue=s(s({},de),((n={position:void 0,bottom:"0",borderRadius:se===exports.LauncherType.IMAGE?"50%":"9999px"})[re.toLowerCase()]="0",n)),pe=s(s({},de),((i={position:"fixed",bottom:"".concat(le,"px"),borderRadius:se===exports.LauncherType.IMAGE?"50%":"9999px"})[re.toLowerCase()]="".concat(ae,"px"),i)),fe=V?pe:ue;e.useEffect((function(){f.log("Screen width changed, isMobile:",V,"Style:",fe)}),[V,fe]),f.log("config in floating button",C);e.useEffect((function(){var e=function(){ie.current.forEach((function(e){return clearTimeout(e)})),ie.current=[]},t=function(){(e(),$([]),(null==C?void 0:C.proactive_message_obj)&&!k())&&U(null==C?void 0:C.proactive_message_obj).forEach((function(e){var t=window.setTimeout((function(){$((function(t){return t.some((function(t){return t.id===e.messageId&&t.index===e.contentIndex}))?t:u(u([],t,!0),[{id:e.messageId,index:e.contentIndex,html:e.html}],!1)}))}),e.delayMs);ie.current.push(t)}))};return oe.current=A((function(){Z(!1),t()})),t(),function(){var t;e(),null===(t=oe.current)||void 0===t||t.call(oe)}}),[null==C?void 0:C.proactive_message_obj]);var me=Q.length>0&&!R&&!J,he="Right"===(z||(null===(m=C.interface_properties)||void 0===m?void 0:m.position)||"Right"),ve=function(){ne(!0),setTimeout((function(){Z(!0),L(),ne(!1)}),400)};return e.createElement(e.Fragment,null,e.createElement("style",null,"\n @keyframes slideInFromRight {\n 0% {\n transform: translateX(120%) scale(0.95);\n opacity: 0;\n }\n 85% {\n transform: translateX(0) scale(1);\n opacity: 1;\n }\n 92% {\n transform: translateX(-1px) scale(1.002);\n }\n 100% {\n transform: translateX(0) scale(1);\n opacity: 1;\n }\n }\n @keyframes slideInFromLeft {\n 0% {\n transform: translateX(-120%) scale(0.95);\n opacity: 0;\n }\n 85% {\n transform: translateX(0) scale(1);\n opacity: 1;\n }\n 92% {\n transform: translateX(1px) scale(1.002);\n }\n 100% {\n transform: translateX(0) scale(1);\n opacity: 1;\n }\n }\n @keyframes slideOutRight {\n 0% {\n transform: translateX(0) scale(1);\n opacity: 1;\n }\n 100% {\n transform: translateX(120%) scale(0.9);\n opacity: 0;\n }\n }\n @keyframes slideOutLeft {\n 0% {\n transform: translateX(0) scale(1);\n opacity: 1;\n }\n 100% {\n transform: translateX(-120%) scale(0.9);\n opacity: 0;\n }\n }\n .proactive-bubble-enter-right {\n animation: slideInFromRight 1.2s cubic-bezier(0.5, 0.8, 0.3, 1.1) forwards;\n }\n .proactive-bubble-enter-left {\n animation: slideInFromLeft 1.2s cubic-bezier(0.5, 0.8, 0.3, 1.1) forwards;\n }\n .proactive-bubble-exit-right {\n animation: slideOutRight 0.4s ease-in forwards;\n }\n .proactive-bubble-exit-left {\n animation: slideOutLeft 0.4s ease-in forwards;\n }\n .proactive-close-enter-right {\n animation: slideInFromRight 1.2s cubic-bezier(0.5, 0.8, 0.3, 1.1) forwards;\n }\n .proactive-close-enter-left {\n animation: slideInFromLeft 1.2s cubic-bezier(0.5, 0.8, 0.3, 1.1) forwards;\n }\n /* Reset styles for proactive message content to prevent website CSS interference */\n /* Only target children of the content wrapper, not the bubble container itself */\n .proactive-message-content * {\n box-sizing: border-box !important;\n margin: 0 !important;\n padding: 0 !important;\n border: none !important;\n background: transparent;\n font-family: ".concat(_,';\n // font-size: inherit;\n // font-weight: inherit;\n line-height: inherit;\n color: inherit;\n text-align: inherit;\n // text-decoration: none ;\n list-style: none !important;\n }\n .proactive-message-content p,\n .proactive-message-content div,\n .proactive-message-content span {\n display: inline !important;\n margin: 0 !important;\n padding: 0 !important;\n }\n .proactive-message-content p:first-child,\n .proactive-message-content div:first-child,\n .proactive-message-content span:first-child {\n margin-top: 0 !important;\n }\n .proactive-message-content p:last-child,\n .proactive-message-content div:last-child,\n .proactive-message-content span:last-child {\n margin-bottom: 0 !important;\n }\n .proactive-message-content a {\n color: inherit !important;\n text-decoration: underline !important;\n cursor: pointer !important;\n }\n .proactive-message-content a:hover {\n opacity: 0.8 !important;\n }\n .proactive-message-content b,\n .proactive-message-content strong {\n font-weight: 600 !important;\n }\n .proactive-message-content i,\n .proactive-message-content em {\n font-style: italic !important;\n }\n .proactive-message-content u {\n text-decoration: underline !important;\n }\n .proactive-message-content br {\n display: block !important;\n content: "" !important;\n margin-top: 0.5em !important;\n }\n ')),me?e.createElement("div",{className:"proactive-message-container",style:{position:"fixed",bottom:"".concat((null!==(g=null!=F?F:null===(v=C.interface_properties)||void 0===v?void 0:v.bottom_spacing)&&void 0!==g?g:20)+(se===exports.LauncherType.IMAGE?48:40)+8,"px"),right:he?"".concat(null!==(E=null!=H?H:null===(b=C.interface_properties)||void 0===b?void 0:b.side_spacing)&&void 0!==E?E:20,"px"):"auto",left:he?"auto":"".concat(null!==(x=null!=H?H:null===(T=C.interface_properties)||void 0===T?void 0:T.side_spacing)&&void 0!==x?x:20,"px"),maxWidth:"22.875rem",zIndex:2147483646}},e.createElement("div",{style:{display:"flex",flexDirection:"column",alignItems:he?"flex-end":"flex-start"},className:"proactive-message-bubble-container"},Q.map((function(t,n){var i=10*(Q.length-1-n);return e.createElement("div",{key:"".concat(t.id,"-").concat(t.index,"-").concat(n),onClick:function(){M({message_id:t.id,content_string:t.html||null}),O(),ve();try{window.dispatchEvent(new CustomEvent("rblyn:proactiveClick",{detail:{message_id:t.id,content_string:t.html||null}}))}catch(e){}},className:te?he?"proactive-bubble-exit-right":"proactive-bubble-exit-left":he?"proactive-bubble-enter-right":"proactive-bubble-enter-left",style:s({background:"#fff",color:"#111",borderRadius:"12px",boxShadow:"0 2px 2px 0 rgba(0, 0, 0, 0.08)",padding:"16px",cursor:"pointer",fontFamily:_,lineHeight:w,fontSize:"14px",marginBottom:n<Q.length-1?16:0,border:"1px solid #F1F2F4",width:"fit-content",maxWidth:"100%",animationDelay:te?"0ms":"".concat(i,"ms")},te?{opacity:0}:{opacity:0,transform:he?"translateX(120%) scale(0.95)":"translateX(-120%) scale(0.95)"})},e.createElement("div",{className:"proactive-message-content",dangerouslySetInnerHTML:{__html:Ve(t.html)}}))}))),e.createElement("div",{onClick:function(e){e.stopPropagation(),ve()},className:te?"":he?"proactive-close-enter-right":"proactive-close-enter-left",style:s({position:"absolute",top:"-32px",right:"Right"===(z||(null===(I=C.interface_properties)||void 0===I?void 0:I.position)||"Right")?"0px":"auto",left:"Left"===(z||(null===(S=C.interface_properties)||void 0===S?void 0:S.position)||"Right")?"0px":"auto",width:"24px",height:"24px",borderRadius:"50%",background:"#fff",boxShadow:" 0 2.667px 2.667px 0 rgba(0, 0, 0, 0.25)",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",userSelect:"none",animationDelay:te?"0ms":"".concat(10*(Q.length-1),"ms")},te?{}:{opacity:0,transform:he?"translateX(120%) scale(0.95)":"translateX(-120%) scale(0.95)"}),"aria-label":"Close proactive message"},e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 14 14",fill:"none"},e.createElement("path",{d:"M10.3334 10.3334L7.00009 7.00009M7.00009 7.00009L3.66675 3.66675M7.00009 7.00009L10.3334 3.66675M7.00009 7.00009L3.66675 10.3334",stroke:"#444547",strokeWidth:"0.816326",strokeLinecap:"round",strokeLinejoin:"round"})))):null,e.createElement("div",{ref:j,className:"message-bubble-container",style:s(s({},fe),{transition:"transform 0.2s cubic-bezier(0.2, 1.27, 0.29, 0.97), opacity 280ms ease",transform:R?"scale(0.85)":"scale(1)",opacity:W?0:1}),onClick:function(){O(),ve()}},function(){switch(se){case exports.LauncherType.TEXT:return e.createElement("div",{style:{width:"fit-content",maxWidth:"160px",height:"40px",borderRadius:"9999px",backgroundColor:C.brand_colour,display:"flex",alignItems:"center",padding:"9px 20px",boxShadow:"0px 0px 16px 0px rgba(0, 0, 0, 0.24)",boxSizing:"border-box",fontFamily:_,lineHeight:w}},e.createElement("div",{style:{flex:1,minWidth:0}},e.createElement("p",{style:{margin:0,color:p(C.brand_colour),fontSize:"0.875rem",fontWeight:600,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",fontFamily:_,lineHeight:w,WebkitFontSmoothing:"antialiased",textRendering:"optimizeLegibility",textSizeAdjust:"100%"}},ce)));case exports.LauncherType.TEXTUAL_IMAGE:return function(){var t,n;return e.createElement("div",{style:{maxWidth:"13rem",width:"fit-content",height:"40px",borderRadius:"9999px",backgroundColor:C.brand_colour,display:"flex",alignItems:"center",paddingLeft:"20px",paddingRight:0,paddingTop:"9px",paddingBottom:"9px",boxShadow:"0px 0px 16px 0px rgba(0, 0, 0, 0.24)",gap:"8px",boxSizing:"border-box",fontFamily:_,lineHeight:w}},e.createElement("div",{style:{flex:1,minWidth:0}},e.createElement("p",{style:{margin:0,color:p(C.brand_colour),fontSize:"0.875rem",fontWeight:600,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",fontFamily:_,lineHeight:w,WebkitFontSmoothing:"antialiased",textRendering:"optimizeLegibility",textSizeAdjust:"100%"}},ce)),e.createElement("div",{style:{width:"40px",height:"40px",borderRadius:"9999px",overflow:"hidden",position:"relative",flexShrink:0}},e.createElement("img",{src:(null==C?void 0:C.launcher_type)?(null===(n=null===(t=null==C?void 0:C.images)||void 0===t?void 0:t.launcher_image_url)||void 0===n?void 0:n.url)||"".concat(G,"/chatbubble.png"):(null==C?void 0:C.image_url)||"".concat(G,"/chatbubble.png"),alt:"Chat",style:{width:"100%",height:"100%",objectFit:"cover"}})))}();case exports.LauncherType.IMAGE:default:return function(){var t,n;return R?e.createElement("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e.createElement("g",{id:"Chevron_Down"},e.createElement("path",{id:"Vector",d:"M19 9L12 16L5 9",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}))):e.createElement("img",{src:(null==C?void 0:C.launcher_type)?(null===(n=null===(t=null==C?void 0:C.images)||void 0===t?void 0:t.launcher_image_url)||void 0===n?void 0:n.url)||"".concat(G,"/chatbubble.png"):(null==C?void 0:C.image_url)||"".concat(G,"/chatbubble.png"),alt:"Chat",style:{zIndex:1e3,cursor:"pointer",borderRadius:"50%",objectFit:"cover",width:"100%",height:"100%",boxSizing:"border-box"}})}()}}()))})),Ke=function(){var e;return(null===(e=navigator.userAgentData)||void 0===e?void 0:e.platform)||(/Windows|Mac|Linux|Android|iOS/.exec(navigator.userAgent)||["Unknown"])[0]},Je=function(){var e;if(null===(e=navigator.userAgentData)||void 0===e?void 0:e.brands)for(var t=["Chrome","Firefox","Safari","Edge","Opera"],n=0,i=navigator.userAgentData.brands;n<i.length;n++){var o=i[n];if(t.includes(o.brand))return o.brand}return(/Chrome|Firefox|Safari|Edge|Opera/.exec(navigator.userAgent)||["Unknown"])[0]},Ze=function(){var e,t,n,i;return{width:(null===window||void 0===window?void 0:window.innerWidth)||(null===(e=null===document||void 0===document?void 0:document.documentElement)||void 0===e?void 0:e.clientWidth)||(null===(t=null===document||void 0===document?void 0:document.body)||void 0===t?void 0:t.clientWidth),height:(null===window||void 0===window?void 0:window.innerHeight)||(null===(n=null===document||void 0===document?void 0:document.documentElement)||void 0===n?void 0:n.clientHeight)||(null===(i=null===document||void 0===document?void 0:document.body)||void 0===i?void 0:i.clientHeight)}},qe=function(){return{platform:"web",os:Ke(),browser:Je(),sdk_version:"1.1.44",device:(e=navigator.userAgent.toLowerCase(),/(tablet|ipad|playbook|silk)|(android(?!.*mobi))/i.test(e)?"tablet":/Mobile|Android|iP(hone|od)|IEMobile|BlackBerry|Kindle|Silk-Accelerated|(hpw|web)OS|Opera M(obi|ini)/.test(e)?"mobile":"desktop"),screen_size:Ze()};var e};!function(e){e.ERROR="ERROR",e.INFO="INFO"}(Ge||(Ge={}));var Qe,$e=["@robylon/web-react-sdk","node_modules/@robylon/web-react-sdk/"],et=function(e){var t=e.filename,n=e.stack,i=e.message;return!!(t||n||i)&&$e.some((function(e){return(null==t?void 0:t.includes(e))||(null==n?void 0:n.includes(e))||(null==i?void 0:i.includes(e))}))},tt=function(){function e(){var e=this;this.apiKey="",this.userId=null,this.preInitQueue=[],this.isInitialized=!1,this.handleWindowError=function(t){var n,i={filename:t.filename,stack:null===(n=t.error)||void 0===n?void 0:n.stack,message:t.message};et(i)&&e.trackError(t.error||t.message,"GlobalErrorHandler",{filename:t.filename,lineNo:t.lineno,colNo:t.colno})},this.handleUnhandledRejection=function(t){var n,i,o={stack:null===(n=t.reason)||void 0===n?void 0:n.stack,message:(null===(i=t.reason)||void 0===i?void 0:i.message)||String(t.reason)};et(o)&&e.trackError(t.reason||"Unhandled Promise Rejection","GlobalPromiseHandler",{reason:t.reason})},this.setupGlobalHandlers()}return e.prototype.setupGlobalHandlers=function(){g()&&(null===window||void 0===window||window.addEventListener("error",null==this?void 0:this.handleWindowError),null===window||void 0===window||window.addEventListener("unhandledrejection",this.handleUnhandledRejection))},e.prototype.cleanup=function(){g()&&(null===window||void 0===window||window.removeEventListener("error",null==this?void 0:this.handleWindowError),null===window||void 0===window||window.removeEventListener("unhandledrejection",this.handleUnhandledRejection))},e.getInstance=function(){return e.instance||(e.instance=new e),e.instance},e.prototype.initialize=function(e,t){void 0===t&&(t=null);try{if(this.preInitQueue.length>0){var n={org_id:"UNINITALIZED",event_data:{message:"SDK Initialization Failed: Required parameter 'api_key' is ".concat(void 0===e?"undefined":null===e?"null":""===e?"empty string":"invalid: ".concat(e)),componentName:"ErrorTrackingService",additionalInfo:{preInitError:!0,apiKey:e,userId:t,timestamp:Date.now()},timestamp:Date.now()},metadata:qe(),event_type:Ge.ERROR,user_id:t};this.sendLog(n).catch(console.error)}this.apiKey=e,this.userId=t,this.isInitialized=!0,this.processPreInitQueue()}catch(n){f.error("Error during ErrorTrackingService initialization:",n),this.preInitQueue.push({error:n instanceof Error?n:new Error(String(n)),componentName:"ErrorTrackingService",additionalInfo:{apiKey:e,userId:t}})}},e.prototype.processPreInitQueue=function(){return c(this,void 0,void 0,(function(){var e,t,n;return d(this,(function(i){switch(i.label){case 0:if(!this.preInitQueue.length)return[2];f.info("Processing ".concat(this.preInitQueue.length," pre-initialization errors")),e=0,t=this.preInitQueue,i.label=1;case 1:return e<t.length?(n=t[e],[4,this.trackError(n.error,n.componentName,s(s({},n.additionalInfo),{preInitError:!0}))]):[3,4];case 2:i.sent(),i.label=3;case 3:return e++,[3,1];case 4:return this.preInitQueue=[],[2]}}))}))},e.prototype.sendLog=function(e){return c(this,void 0,void 0,(function(){var t,n,i,o,r,a;return d(this,(function(l){switch(l.label){case 0:return l.trys.push([0,4,,5]),t=y().apiUrl,[4,fetch("".concat(t,"/users/sdk/record-logs/"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})];case 1:return(n=l.sent()).ok?[3,3]:(o=(i=f).error,r=["Failed to send error log:"],[4,n.text()]);case 2:o.apply(i,r.concat([l.sent()])),l.label=3;case 3:return[3,5];case 4:return a=l.sent(),f.error("Error sending log:",a),[3,5];case 5:return[2]}}))}))},e.prototype.trackError=function(e,t,n){return c(this,void 0,void 0,(function(){var i,o,r;return d(this,(function(a){switch(a.label){case 0:if(this.isInitialized)return[3,5];i={org_id:"UNINITALIZED",event_data:{message:e instanceof Error?e.message:e,stack:e instanceof Error?e.stack:void 0,componentName:t,additionalInfo:s(s({},n),{preInitError:!0,timestamp:Date.now()}),timestamp:Date.now()},metadata:qe(),event_type:Ge.ERROR,user_id:this.userId},a.label=1;case 1:return a.trys.push([1,3,,4]),[4,this.sendLog(i)];case 2:return a.sent(),[3,4];case 3:return a.sent(),this.preInitQueue.push({error:e,componentName:t,additionalInfo:n}),f.warn("Error tracked before initialization, queuing:",e),[3,4];case 4:return[2];case 5:return o={message:e instanceof Error?e.message:e,stack:e instanceof Error?e.stack:void 0,componentName:t,additionalInfo:s(s({},n),{timestamp:Date.now()}),timestamp:Date.now()},r={org_id:this.apiKey||"UNINITALIZED",event_data:o,metadata:qe(),event_type:Ge.ERROR,user_id:this.userId},[4,this.sendLog(r)];case 6:return a.sent(),[2]}}))}))},e.prototype.trackInfo=function(e,t,n){return c(this,void 0,void 0,(function(){var i,o;return d(this,(function(r){switch(r.label){case 0:return this.apiKey?(i={message:e,componentName:t,additionalInfo:n,timestamp:Date.now()},o={org_id:this.apiKey,event_data:i,metadata:qe(),event_type:Ge.INFO,user_id:this.userId},[4,this.sendLog(o)]):(f.error("Error tracking not initialized"),[2]);case 1:return r.sent(),[2]}}))}))},e}(),nt=tt.getInstance(),it="MISSING_API_KEY",ot="INVALID_API_KEY",rt="CONFIG_FETCH_FAILED",at="SDK_INIT_FAILED",lt="ERROR_TRACKING_INIT_FAILED",st="API_REQUEST_FAILED",ct="NETWORK_ERROR",dt="INVALID_RESPONSE",ut="IFRAME_LOAD_FAILED",pt="COOKIE_ACCESS_ERROR",ft="COMPONENT_RENDER_ERROR",mt="INITIALIZATION_ERROR",ht="API_ERROR",vt="RUNTIME_ERROR",gt="COMPONENT_ERROR",yt=((Qe={})[it]=function(e){return"SDK Initialization Failed: Required parameter 'api_key' is ".concat(void 0===e?"undefined":null===e?"null":""===e?"empty string":"invalid: ".concat(e),". A valid API key string is required to initialize the SDK.")},Qe[ot]=function(e){return"SDK Initialization Failed: Provided API key '".concat(e,"' is invalid. API key must be a non-empty string in UUID format.")},Qe[rt]=function(e){return"Failed to fetch chatbot configuration: ".concat(e.statusCode?"Server responded with status ".concat(e.statusCode):"Could not reach server").concat(e.error?". Error: ".concat(e.error):"")},Qe[st]=function(e,t,n){return"API Request Failed: Server responded with status ".concat(e," for ").concat(n?"endpoint ".concat(n):"request"," - ").concat(t)},Qe[ct]=function(e){return"Network Error: Failed to communicate with server".concat(e.url?" at ".concat(e.url):"").concat(e.error?" - ".concat(e.error):"")},Qe[ut]=function(e){return"Failed to load chatbot interface".concat(e.src?" from ".concat(e.src):"").concat(e.error?". Error: ".concat(e.error):"")},Qe[dt]=function(e){return"Invalid API Response: Missing required fields in response data: ".concat(e.join(", "))},Qe[lt]=function(e){return"Error Tracking Service initialization failed".concat(e.apiKey?" for API key ".concat(e.apiKey):"").concat(e.error?". Error: ".concat(e.error):"")},Qe[at]=function(e){return"SDK Initialization Failed: ".concat(e.reason||"Could not initialize the chatbot SDK").concat(e.config?". Attempted initialization with config: ".concat(JSON.stringify(e.config,null,2)):"")},Qe[pt]=function(e,t){return"Cookie Access Error: Failed to ".concat(e).concat(t?" cookie '".concat(t,"'"):" cookies",". This may affect user session persistence.")},Qe[ft]=function(e){return"React Component Error: ".concat(e.component||"Unknown component"," failed to render. Error: ").concat(e.error).concat(e.stack?"\nComponent Stack: ".concat(e.stack):"")},Qe),bt=function(){var e,t=navigator.userAgent;if(null===(e=navigator.userAgentData)||void 0===e?void 0:e.brands){var n=navigator.userAgentData.brands.find((function(e){return"Google Chrome"===e.brand}));if(null==n?void 0:n.version)return n.version}var i=t.match(/(Chrome|Firefox|Safari|Edge|Opera)\/(\d+\.\d+)/);return i?i[2]:"Unknown"},_t=function(){var e,t,n=qe();return{current_page_url:(null===(e=null===window||void 0===window?void 0:window.location)||void 0===e?void 0:e.href)||"",browser_language:(null===navigator||void 0===navigator?void 0:navigator.language)||(null===(t=null===navigator||void 0===navigator?void 0:navigator.languages)||void 0===t?void 0:t[0])||"en",browser_version:bt(),os:null==n?void 0:n.os,referral_url:(null===document||void 0===document?void 0:document.referrer)||"",system_info:n}},wt=e.memo((function(t){var n,i,o,r,a=t.config,l=t.isVisible,c=t.onClose,d=t.onEvent,u=t.onInternalEvent,p=t.position,f=t.bottomSpacing,m=t.overrides,g=e.useRef(null),b=e.useRef(!1),_=e.useRef(!1),w=p||(null===(n=a.interface_properties)||void 0===n?void 0:n.position)||"Right",E=null!==(o=null!=f?f:null===(i=a.interface_properties)||void 0===i?void 0:i.bottom_spacing)&&void 0!==o?o:20,T=e.useCallback((function(){var e,t=g.current;if(t){var n=((e={width:(null===window||void 0===window?void 0:window.innerWidth)<560?"100vw":"26%",minWidth:(null===window||void 0===window?void 0:window.innerWidth)<560?"300px":"400px",height:(null===window||void 0===window?void 0:window.innerWidth)<560?"100vh":"calc(100vh - 2rem - 10vh - ".concat(E,"px)"),borderRadius:(null===window||void 0===window?void 0:window.innerWidth)<560?"0":"1rem",position:(null===window||void 0===window?void 0:window.innerWidth)<560?"fixed":"",maxHeight:(null===window||void 0===window?void 0:window.innerWidth)<560?"100%":"50rem",top:(null===window||void 0===window?void 0:window.innerWidth)<560?"0":"calc(10vh - 32px)"})[w.toLowerCase()]=(null===window||void 0===window?void 0:window.innerWidth)<560?"0":void 0,e.flexDirection=(null===window||void 0===window?void 0:window.innerWidth)<560?"column":void 0,e.flexGrow=(null===window||void 0===window?void 0:window.innerWidth)<560?"1":void 0,e);Object.assign(t.style,n)}}),[E,w]);return e.useEffect((function(){var e=g.current;if(e&&!b.current){var t=y().copilotUrl;Object.assign(e.style,{zIndex:"20000000",border:"none",boxShadow:"0px 0px 40px 0px rgba(14, 14, 15, 0.24)",transformOrigin:"bottom ".concat(w.toLowerCase()),transition:"transform 0.2s cubic-bezier(0.2, 1.27, 0.29, 0.97), opacity 0.15s ease-out",transform:"scale(0.3) translate3d(0,40px,0)",opacity:"0",display:"none"}),e.src="".concat(t,"/chatbot-plugin?id=").concat(a.chatbotId),b.current=!0,T();var n=function(){var n,i,o,r,a,l,s,c,d,u,p,f=new URL(e.src).origin||t;if(null===(n=e.contentWindow)||void 0===n||n.postMessage({domain:null===(i=null===window||void 0===window?void 0:window.location)||void 0===i?void 0:i.hostname,name:"checkDomain"},f),m){var h={header_avatar:null!==(o=null==m?void 0:m.header_avatar)&&void 0!==o?o:null,agent_avatar:null!==(r=null==m?void 0:m.agent_avatar)&&void 0!==r?r:null,header_title:null!==(a=null==m?void 0:m.header_title)&&void 0!==a?a:null,header_subtitle:null!==(l=null==m?void 0:m.header_subtitle)&&void 0!==l?l:null,header_title_text_color:null!==(s=null==m?void 0:m.header_title_text_color)&&void 0!==s?s:null,header_subtitle_text_color:null!==(c=null==m?void 0:m.header_subtitle_text_color)&&void 0!==c?c:null,header_bg:null!==(d=null==m?void 0:m.header_bg)&&void 0!==d?d:null};null===(u=e.contentWindow)||void 0===u||u.postMessage({domain:null===(p=null===window||void 0===window?void 0:window.location)||void 0===p?void 0:p.hostname,action:"updateOverrides",data:h},t)}};return e.addEventListener("load",n),function(){return e.removeEventListener("load",n)}}}),[a.chatbotId,null===(r=a.interface_properties)||void 0===r?void 0:r.position,T,m]),e.useEffect((function(){var e,t,n,i,o,r,c=g.current;if(c&&b.current){var d=(null===(e=a.interface_properties)||void 0===e?void 0:e.position)||"Right";if(l?(Object.assign(c.style,{transform:"scale(0.3) translate3d(0,40px,0)",opacity:"0",display:"block"}),c.getBoundingClientRect(),setTimeout((function(){Object.assign(c.style,{transform:"scale(1) translate3d(0,0,0)",opacity:"1",transition:"transform 0.2s cubic-bezier(0.2, 1.27, 0.29, 0.97), opacity 0.15s ease-out"})}),20)):(c.style.transition="none",c.getBoundingClientRect(),Object.assign(c.style,{opacity:"0",transform:"scale(0.3) translate3d(".concat((d.toLowerCase(),"0"),",40px,0)"),transition:"transform 0.2s cubic-bezier(0.2, 1.27, 0.29, 0.97), opacity 0.15s ease-out"}),setTimeout((function(){!l&&c&&(c.style.display="none")}),200)),c.contentWindow&&l){var u=y().copilotUrl;if(null===(t=null==c?void 0:c.contentWindow)||void 0===t||t.postMessage({domain:null===(n=null===window||void 0===window?void 0:window.location)||void 0===n?void 0:n.hostname,name:"openFrame"},u),!(null==_?void 0:_.current)){var p=z();null===(i=c.contentWindow)||void 0===i||i.postMessage({domain:null===(o=null===window||void 0===window?void 0:window.location)||void 0===o?void 0:o.hostname,action:"registerUserId",data:s({userId:null==a?void 0:a.userId,token:null==a?void 0:a.token,userProfile:s(s({},null==a?void 0:a.userProfile),{__INT_SYS_INFO__:s(s({},(null===(r=null==a?void 0:a.userProfile)||void 0===r?void 0:r.__INT_SYS_INFO__)||{}),_t())}),isAnonymous:null==a?void 0:a.isAnonymous},p?{proactiveData:p}:{})},u),_.current=!0}}}}),[l,a.userId,a.token,a.userProfile]),e.useEffect((function(){var e=function(e){var t,n;if(_.current&&g.current){var i=(null==e?void 0:e.detail)||{},o=y().copilotUrl;null===(t=g.current.contentWindow)||void 0===t||t.postMessage({domain:null===(n=null===window||void 0===window?void 0:window.location)||void 0===n?void 0:n.hostname,action:"proactiveClick",data:{userId:null==a?void 0:a.userId,token:null==a?void 0:a.token,userProfile:null==a?void 0:a.userProfile,isAnonymous:null==a?void 0:a.isAnonymous,proactiveData:{input_id:null,message_id:(null==i?void 0:i.message_id)||null,content_string:(null==i?void 0:i.content_string)||null}}},o)}};return window.addEventListener("rblyn:proactiveClick",e),function(){return window.removeEventListener("rblyn:proactiveClick",e)}}),[null==a?void 0:a.userId,null==a?void 0:a.token,null==a?void 0:a.userProfile,null==a?void 0:a.isAnonymous]),e.useEffect((function(){if(g.current&&b.current){var e=y().copilotUrl;l&&(null==d||d({type:h.CHATBOT_OPENED,timestamp:Date.now()}),u(h.CHATBOT_OPENED));var t=function(t){var n,i,o,r,a,l,s;if(t.origin===e){if("closeChatbot"===t.data)return void c();if("CHATBOT_TOKEN_EXHAUSTED"===(null===(n=t.data)||void 0===n?void 0:n.type))return void u(v.CHATBOT_TOKEN_EXHAUSTED);"CHATBOT_LOADED"===(null===(i=t.data)||void 0===i?void 0:i.type)&&(null==d||d({type:h.CHATBOT_LOADED,timestamp:Date.now()}),u(h.CHATBOT_LOADED)),"CHAT_INITIALIZED"===(null===(o=t.data)||void 0===o?void 0:o.type)&&(null==d||d({type:h.CHAT_INITIALIZED,timestamp:Date.now()}),u(h.CHAT_INITIALIZED)),"CHAT_INITIALIZATION_FAILED"===(null===(r=t.data)||void 0===r?void 0:r.type)&&(null==d||d({type:h.CHAT_INITIALIZATION_FAILED,timestamp:Date.now()}),u(h.CHAT_INITIALIZATION_FAILED,{error:null===(a=t.data)||void 0===a?void 0:a.error})),"SESSION_REFRESHED"===(null===(l=t.data)||void 0===l?void 0:l.type)&&(null==d||d({type:h.SESSION_REFRESHED,timestamp:Date.now()}),u(h.SESSION_REFRESHED)),"CHAT_MOVED"===(null===(s=t.data)||void 0===s?void 0:s.type)&&u(v.CHAT_MOVED,{from:t.data.from,to:t.data.to,trigger:t.data.trigger})}};return null===window||void 0===window||window.addEventListener("message",t),function(){return null===window||void 0===window?void 0:window.removeEventListener("message",t)}}}),[c,d,u,a.chatbotId,l]),e.useEffect((function(){var e=g.current;if(e&&b.current){var t=function(){nt.trackError(new Error(yt[ut]({src:e.src,error:"Failed to load iframe"})),"ChatbotIframe",{errorCode:ut,errorType:vt,context:{config:a,iframeUrl:e.src,timestamp:Date.now()}})};return e.addEventListener("error",t),function(){return e.removeEventListener("error",t)}}}),[a]),e.useEffect((function(){var e;if(g.current&&a&&l){var t=g.current,n=y().copilotUrl;null===(e=t.contentWindow)||void 0===e||e.postMessage({action:"updateUserProfile",user_profile:a.userProfile},n)}}),[a.userProfile,l]),e.createElement("iframe",{ref:g,id:"chat-iframe-rbyln",style:{display:"none"}})})),Et=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.state={hasError:!1},t}return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function i(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(i.prototype=n.prototype,new i)}(n,e),n.getDerivedStateFromError=function(e){return{hasError:!0}},n.prototype.componentDidCatch=function(e,t){nt.trackError(new Error(yt[ft]({component:this.props.componentName||void 0,error:e.message,stack:t.componentStack})),this.props.componentName||void 0,{errorCode:ft,errorType:gt,context:{originalError:e,componentStack:t.componentStack,timestamp:Date.now()}})},n.prototype.render=function(){return this.state.hasError?null:this.props.children},n}(e.Component),Tt=function(e,t,n){return c(void 0,void 0,void 0,(function(){var i,o,r,a,l,s,c,u;return d(this,(function(d){switch(d.label){case 0:i=y().apiUrl,o="".concat(i,"/chat/chatbot/get/"),f.log("endpointUrl",o),r={client_user_id:t,org_id:e,token:n||void 0,extra_info:{},launcher_info:_t()},d.label=1;case 1:return d.trys.push([1,6,,7]),[4,fetch(o,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)})];case 2:return(a=d.sent()).ok?[3,4]:[4,a.text()];case 3:throw l=d.sent(),new Error(yt[st](a.status,l));case 4:return[4,a.json()];case 5:s=d.sent();try{String(r.org_id||"")}catch(e){}if(!(null===(u=null==s?void 0:s.user)||void 0===u?void 0:u.org_info))throw new Error(yt[dt](["user","org_info"]));return[2,s];case 6:throw c=d.sent(),nt.trackError(c instanceof Error?c:new Error(yt[ct]({error:String(c)})),"fetchChatbotConfig",{errorCode:c instanceof Error&&c.message.includes("API Request Failed")?st:ct,errorType:ht,context:{chatbotId:e,userId:t,apiUrl:i,statusCode:c instanceof Response?c.status:void 0,timestamp:Date.now(),requestPayload:{client_user_id:t,org_id:e}}}),c;case 7:return[2]}}))}))},xt=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}))},It=function(e){var t,n="; ".concat(document.cookie).split("; ".concat(e,"="));if(2===n.length)return null===(t=n.pop())||void 0===t?void 0:t.split(";").shift()},St=function(e,t,n){var i=new Date;i.setTime(i.getTime()+24*n*60*60*1e3),document.cookie="".concat(e,"=").concat(t,";expires=").concat(i.toUTCString(),";path=/")},Ct=function(e){var t=e?"USER_DATA=%7B%22attributes%22%3A%5B%7B%22key%22%3A%22USER_ATTRIBUTE_USER_EMAIL%22%2C%22value%22%3A%22dinesh.goel%40robylon.ai%22%7D%2C%7B%22key%22%3A%22USER_ATTRIBUTE_UNIQUE_ID%22%2C%22value%22%3A%2266011f2c28d1787d13c6c796%22%7D%5D%2C%22subscribedToOldSdk%22%3Afalse%2C%22deviceUuid%22%3A%2226c02feb-2664-451d-8469-9cf1378547c6%22%2C%22deviceAdded%22%3Atrue%7D; _ga_3YS9P6ZDWX=GS1.1.1715252584.3.1.1715258696.39.0.0; _ga_V4J24F7YF9=GS1.1.1715273274.2.0.1715273274.0.0.0; city_name=Bengaluru; lang_code=en-in; cookieConcent=A; _gcl_au=1.1.343275043.1717154298; _clck=43guwd%7C2%7Cfmi%7C0%7C1561; _gid=GA1.2.1423066649.1718210058; moe_uuid=26c02feb-2664-451d-8469-9cf1378547c6; _ga_6RM65PWEZY=GS1.1.1718210058.18.1.1718211647.60.0.0; _ga=GA1.1.689213983.1712737672; AMP_MKTG_fe4beb374f=JTdCJTIycmVmZXJyZXIlMjIlM0ElMjJodHRwcyUzQSUyRiUyRmFjY291bnRzLnRlYWNobWludC5jb20lMkYlMjIlMkMlMjJyZWZlcnJpbmdfZG9tYWluJTIyJTNBJTIyYWNjb3VudHMudGVhY2htaW50LmNvbSUyMiU3RA==; AMP_fe4beb374f=JTdCJTIyZGV2aWNlSWQlMjIlM0ElMjI0MWMxMTljZC03YzVjLTRiYTctYTUzZS1mYTgzMjRlYjc0OWUlMjIlMkMlMjJ1c2VySWQlMjIlM0ElMjIxZjI2ODAwOC01OGYxLTQwYTItYjQ0Ni1mYmQ5N2E0NDQyYTAlMjIlMkMlMjJzZXNzaW9uSWQlMjIlM0ExNzE4MjEzMzEwOTc3JTJDJTIyb3B0T3V0JTIyJTNBZmFsc2UlMkMlMjJsYXN0RXZlbnRUaW1lJTIyJTNBMTcxODIxMzMxMDk4MSUyQyUyMmxhc3RFdmVudElkJTIyJTNBMTQlN0Q=; _ga_3YS9P6ZDWX=GS1.1.1718211637.26.1.1718213441.60.0.0; SESSION=%7B%22sessionKey%22%3A%22e4d76f52-9053-4277-99a4-f1ba667fd5f2%22%2C%22sessionStartTime%22%3A%222024-06-12T16%3A34%3A19.047Z%22%2C%22sessionMaxTime%22%3A1800%2C%22customIdentifiersToTrack%22%3A%5B%5D%2C%22sessionExpiryTime%22%3A1718215247464%2C%22numberOfSessions%22%3A17%7D":document.cookie;return t=t.split(";").map((function(e){var t=e.split("="),n=t[0],i=t.slice(1).join("=").trim();return{name:n=n.trim(),value:i?decodeURIComponent(i):""}})),t},At=function(){function e(e){this.logoContainer=null,this.iframe=null,this.bubblePromptContainer=null,this.chatBtnImage=null,this.config=e,this.validateDomain()&&this.init(),null===window||void 0===window||window.addEventListener("message",this.onCloseListener.bind(this),!1)}return e.prototype.onCloseListener=function(e){e.origin===this.config.domain&&"closeChatbot"===e.data&&this.closeIframe()},e.prototype.validateDomain=function(){var e,t=this.config.domain,n=null===(e=null===window||void 0===window?void 0:window.location)||void 0===e?void 0:e.origin;return f.log("expectedDomain, to current domain",t,n,t===n),t===n},e.prototype.createChatBubblContainer=function(){var e,t=this,n=document.createElement("div");n.id="chatbase-message-bubbles",Object.assign(n.style,{position:"fixed",bottom:"80px",borderRadius:"10px",fontFamily:"sans-serif",fontSize:"16px",zIndex:"2147483644",cursor:"pointer",flexDirection:"column",gap:"50px",maxWidth:"70vw",display:"block",right:"1rem",left:"unset"});var i=document.createElement("div");i.classList.add("close-btn"),i.textContent="✕",Object.assign(i.style,{position:"absolute",top:"-7px",right:"-7px",fontWeight:"bold",display:"none",justifyContent:"center",alignItems:"center",zIndex:"2147483643",width:"22px",height:"22px",borderRadius:"50%",textAlign:"center",fontSize:"12px",cursor:"pointer",backgroundColor:"rgb(224, 224, 224)",color:"black",boxShadow:"rgba(150, 150, 150, 0.15) 0px 6px 24px 0px, rgba(150, 150, 150, 0.15) 0px 0px 0px 1px"}),((null===(e=this.config.chat_interface_config)||void 0===e?void 0:e.chat_bubble_prompts)||[]).forEach((function(e){var i=t.createMessageBubble(e);n.appendChild(i)})),n.appendChild(i),document.body.appendChild(n)},e.prototype.createMessageBubble=function(e){var t=document.createElement("div");this.bubblePromptContainer=t,Object.assign(t.style,{display:"flex",position:"relative",justifyContent:"flex-end"});var n=document.createElement("div");n.classList.add("message"),n.textContent=e,Object.assign(n.style,{backgroundColor:"white",color:"black",boxShadow:"rgba(150, 150, 150, 0.2) 0px 10px 30px 0px, rgba(150, 150, 150, 0.2) 0px 0px 0px 1px",borderRadius:"10px",padding:"8px 5px",margin:"8px",fontSize:"14px",opacity:"1",transform:"scale(1)",transition:"opacity 0.5s ease 0s, transform 0.5s ease 0s"});var i=document.createElement("button");return i.innerHTML="×",Object.assign(i.style,{position:"absolute",top:"1px",left:"-3px",width:"20px",height:"20px",borderRadius:"50%",backgroundColor:"#fff",color:"#000",border:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:"0 2px 5px rgba(0,0,0,0.2)",fontSize:"14px",lineHeight:"1",padding:"0",zIndex:"100"}),i.addEventListener("click",(function(){t.remove()})),t.appendChild(i),t.appendChild(n),t},e.prototype.createFloatingButton=function(){var e=document.createElement("div");e.classList.add("message-bubble-container"),Object.assign(e.style,{position:"fixed",bottom:"1.5rem",right:"1.5rem",zIndex:"1000",width:"48px",height:"48px",display:"flex",flexDirection:"column-reverse",backgroundColor:this.config.brand_colour,color:p(this.config.brand_colour),borderRadius:"50%",alignItems:"center",justifyContent:"center",cursor:"pointer",overflow:"hidden"}),document.body.appendChild(e),this.logoContainer=e,this.loadImage(this.logoContainer),this.createChatBubblContainer(),this.logoContainer.addEventListener("click",this.toggleIframe.bind(this))},e.prototype.loadImage=function(e){var t,n,i=document.createElement("img");i.src=this.config.launcher_type?(null===(n=null===(t=this.config.images)||void 0===t?void 0:t.launcher_image_url)||void 0===n?void 0:n.url)||"".concat(this.config.domain,"/chatbubble.png"):this.config.image_url||"".concat(this.config.domain,"/chatbubble.png"),i.alt="Chat",Object.assign(i.style,{zIndex:"1000",cursor:"pointer",borderRadius:"50%",objectFit:"cover"}),this.chatBtnImage=i,e.innerHTML="",e.appendChild(i)},e.prototype.createIframe=function(){var e=this;f.log("RobylonConfig?.domain====>",this.config.domain);var t=document.createElement("iframe");Object.assign(t.style,{position:"fixed",right:"32px",bottom:"86px",minWidth:"400px",width:"26%",maxWidth:"800px",top:"calc(10vh - 32px)",maxHeight:"45rem",height:"calc(100vh - 3rem - 10vh)",zIndex:"20000000",border:"none",boxShadow:"0px 0px 40px 0px rgba(14, 14, 15, 0.24)",transformOrigin:"bottom right",transition:"transform 0.3s ease-out",borderRadius:"1rem",display:"none"}),t.src="".concat(this.config.domain,"/chatbot-plugin?id=").concat(this.config.chatbotId),f.log("iframe.src====>",t.src),document.body.appendChild(t),this.iframe=t;var n=function(){(null===window||void 0===window?void 0:window.innerWidth)<560?Object.assign(t.style,{width:"100vw",minWidth:"300px",right:"0",bottom:"0",height:"100vh",flexDirection:"column",flexGrow:"1",borderRadius:"0",top:"0",maxHeight:"100%"}):Object.assign(t.style,{width:"26%",minWidth:"400px",right:"32px",bottom:"86px",height:"calc(100vh - 3rem - 10vh)",borderRadius:"1rem",top:"calc(10vh - 32px)",maxHeight:"45rem"})};n(),null===window||void 0===window||window.addEventListener("resize",n),t.addEventListener("load",(function(){var n,i,o,r,a;if(e.iframe){var l=new URL(e.iframe.src).origin||e.config.domain;null===(n=t.contentWindow)||void 0===n||n.postMessage({domain:null===(i=null===window||void 0===window?void 0:window.location)||void 0===i?void 0:i.hostname,name:"checkDomain"},l),null===(o=t.contentWindow)||void 0===o||o.postMessage({domain:null===(r=null===window||void 0===window?void 0:window.location)||void 0===r?void 0:r.hostname,action:"registerUserId",data:{userId:e.config.userId,token:e.config.token,userProfile:s(s({},e.config.userProfile||{}),{__INT_SYS_INFO__:s(s({},(null===(a=e.config.userProfile)||void 0===a?void 0:a.__INT_SYS_INFO__)||{}),_t())})}},l)}})),null===window||void 0===window||window.addEventListener("message",(function(n){var i,o;if(n.origin===e.config.domain){if("captureSessionData"===n.data){var r="66b33d16-5b38-4693-8772-1a1bd7dd412d"===e.config.chatbotId,a={cookies:Ct(r),localStorage:JSON.stringify(localStorage),sessionStorage:JSON.stringify(sessionStorage),action:"capturedSessionData",domain_name:null===(i=null===window||void 0===window?void 0:window.location)||void 0===i?void 0:i.hostname};null===(o=t.contentWindow)||void 0===o||o.postMessage(a,e.config.domain||"*")}"expand"===n.data&&(e.adjustIframeWidth(),t.style.height="calc(100vh - 120px)",t.style.bottom="86px"),"collapse"===n.data&&Object.assign(t.style,{width:"26%",height:"calc(100vh - 32px - 10vh)",bottom:"86px",top:"calc(32px + 10vh)"})}}))},e.prototype.adjustIframeWidth=function(){if(this.iframe){var e=null===window||void 0===window?void 0:window.innerWidth;f.log("screenWidth",e),this.iframe.style.width=e<832?"".concat(e-64,"px"):"800px"}},e.prototype.loadSvgInline=function(e){var t=document.createElement("div");t.innerHTML='\n<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">\n <g id="Chevron_Down">\n <path id="Vector" d="M19 9L12 16L5 9" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>\n </g>\n</svg>\n';var n=t.querySelector("svg");e.innerHTML="",n&&e.appendChild(n)},e.prototype.toggleIcon=function(e,t){"block"===t.style.display?this.loadSvgInline(e):this.loadImage(e)},e.prototype.toggleIframe=function(){var e;if(f.log("toggleIframe",this.iframe,this.logoContainer,this.chatBtnImage),this.iframe&&this.logoContainer&&this.chatBtnImage){var t=new URL(this.iframe.src).origin||this.config.domain;f.log("toggleIframe"),null===(e=this.iframe.contentWindow)||void 0===e||e.postMessage({domain:null===window||void 0===window?void 0:window.location.hostname,name:"none"===this.iframe.style.display?"openFrame":"closeFrame"},t),this.iframe.style.display="none"===this.iframe.style.display?"block":"none",this.toggleIcon(this.logoContainer,this.iframe),this.chatBtnImage.style.objectFit="block"===this.iframe.style.display?"none":"cover",this.bubblePromptContainer&&(this.bubblePromptContainer.style.display="none"),f.log("this.bubblePromptContainer",this.bubblePromptContainer)}},e.prototype.closeIframe=function(){this.iframe&&this.logoContainer&&this.chatBtnImage&&(this.iframe.style.display="none",this.toggleIcon(this.logoContainer,this.iframe),this.chatBtnImage.style.objectFit="cover")},e.prototype.init=function(){this.createIframe(),this.createFloatingButton()},e}(),Ot=function(e,t,n){if(e.chatbotId&&e.userId)try{new At(e);t(!0),f.log("Robylon SDK initialized successfully.")}catch(e){n(e instanceof Error?e.message:"Failed to initialize SDK")}else n("Incomplete configuration for SDK initialization.")},Rt=function(e,t,n){return c(void 0,void 0,void 0,(function(){var i,o,r,a,l,s,c,u;return d(this,(function(d){switch(d.label){case 0:return d.trys.push([0,5,,6]),i=y().apiUrl,o="".concat(i,"/chat/chatbot/get/"),f.log("endpointUrl",o),r={client_user_id:t||null,org_id:e,token:n||void 0,extra_info:{},launcher_info:_t()},[4,fetch(o,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)})];case 1:return(a=d.sent()).ok?[3,3]:[4,a.text()];case 2:throw l=d.sent(),new Error(yt[st](a.status,l));case 3:return[4,a.json()];case 4:if(s=d.sent(),!(null===(u=null==s?void 0:s.user)||void 0===u?void 0:u.org_info))throw new Error(yt[dt](["user","org_info"]));return[2,s];case 5:throw c=d.sent(),nt.trackError(c instanceof Error?c:new Error(yt[ct]({error:String(c)})),"fetchChatbotConfig",{errorCode:c instanceof Error&&c.message.includes("API Request Failed")?st:ct,errorType:ht,context:{apiKey:e,userId:t,timestamp:Date.now()}}),c;case 6:return[2]}}))}))},Dt=function(e){return c(void 0,void 0,void 0,(function(){var t,n,i,o,r,a,l,c,u,p,m,h,v,g,y,b,_,w,E,T,x,I,S,C,A,O,R,D,N,L,k,M,z,H;return d(this,(function(d){switch(d.label){case 0:return t=function(e){return{api_key:String(e.api_key||""),user_id:e.user_id?String(e.user_id):null,user_token:e.user_token?String(e.user_token):void 0,user_profile:e.user_profile||{}}}(e),n=t.user_id||void 0,i=!1,n||(n=It("rblyn_anon")||xt(),St("rblyn_anon",n,365),i=!0),[4,Rt(t.api_key,n,t.user_token)];case 1:o=d.sent();try{t.api_key}catch(e){f.warn("Failed to inject mock proactive messages",e)}return r=qe(),a=_t(),F=t.user_profile,l=F?Object.fromEntries(Object.entries(F).map((function(e){var t=e[0],n=e[1];return"boolean"==typeof n||"number"==typeof n?[t,n]:[t,String(n)]}))):{},c=s(s(s({},r),{__INT_SYS_INFO__:s(s({},r),a)}),l),[2,{chatbotId:t.api_key,userId:n,token:t.user_token,isAnonymous:i,domain:"",show_launcher:null===(p=null===(u=o.user.org_info)||void 0===u?void 0:u.show_launcher)||void 0===p||p,brand_colour:(null===(h=null===(m=o.user.org_info.brand_config)||void 0===m?void 0:m.colors)||void 0===h?void 0:h.brand_color)||"",image_url:(null===(g=null===(v=o.user.org_info)||void 0===v?void 0:v.brand_config)||void 0===g?void 0:g.launcher_logo_url)||"",userProfile:c,chat_interface_config:{chat_bubble_prompts:[],display_name:(null===(y=o.user.org_info.brand_config)||void 0===y?void 0:y.display_name)||"",welcome_message:(null===(b=o.user.org_info.brand_config)||void 0===b?void 0:b.welcome_message)||"Hey! What can we help you with today?",redirect_url:(null===(_=o.user.org_info.brand_config)||void 0===_?void 0:_.redirect_url)||""},launcher_type:(null===(w=o.user.org_info.brand_config)||void 0===w?void 0:w.launcher_type)||exports.LauncherType.IMAGE,launcher_properties:{text:(null===(T=null===(E=o.user.org_info.brand_config)||void 0===E?void 0:E.launcher_properties)||void 0===T?void 0:T.text)||""},images:{launcher_image_url:{url:(null===(S=null===(I=null===(x=o.user.org_info.brand_config)||void 0===x?void 0:x.images)||void 0===I?void 0:I.launcher_image_url)||void 0===S?void 0:S.url)||""}},proactive_message_obj:Nt(null===(O=null===(A=null===(C=null==o?void 0:o.user)||void 0===C?void 0:C.org_info)||void 0===A?void 0:A.brand_config)||void 0===O?void 0:O.proactive_message_obj),interface_properties:{position:(null===(D=null===(R=o.user.org_info.brand_config)||void 0===R?void 0:R.interface_properties)||void 0===D?void 0:D.position)||exports.WidgetPositionEnums.RIGHT,side_spacing:(null===(L=null===(N=o.user.org_info.brand_config)||void 0===N?void 0:N.interface_properties)||void 0===L?void 0:L.side_spacing)||20,bottom_spacing:(null===(M=null===(k=o.user.org_info.brand_config)||void 0===k?void 0:k.interface_properties)||void 0===M?void 0:M.bottom_spacing)||20},interface_type:(null===(z=o.user.org_info.brand_config)||void 0===z?void 0:z.interface_type)||exports.ChatbotInterfaceType.WIDGET,launcher_delay:(null===(H=o.user.org_info.brand_config)||void 0===H?void 0:H.launcher_delay)||{enabled:!1,delay:0}}]}var F}))}))},Nt=function(e){if(e){var t=(Array.isArray(e)?e:[e]).filter(Boolean).map((function(e){var t,n,i={message_id:String(null!==(t=null==e?void 0:e.message_id)&&void 0!==t?t:""),org_id:String(null!==(n=null==e?void 0:e.org_id)&&void 0!==n?n:""),name:null==e?void 0:e.name,content:null==e?void 0:e.content,send_time_type:null==e?void 0:e.send_time_type,created_by_name:null==e?void 0:e.created_by_name,updated_by_name:null==e?void 0:e.updated_by_name,updated_at:null==e?void 0:e.updated_at,created_at:null==e?void 0:e.created_at,delay:"number"==typeof(null==e?void 0:e.delay)?e.delay:void 0,content_multiple:Array.isArray(null==e?void 0:e.content_multiple)?e.content_multiple:(null==e?void 0:e.content)?[{message:String(e.content),message_display_attributes:[]}]:[]};return(null==e?void 0:e.content)&&!(null==e?void 0:e.content_multiple)&&f.warn("[Robylon SDK] proactive_message.content is deprecated; use content_multiple[].message instead."),i}));return t.length?t:void 0}},Lt=function(t){var n=e.useMemo((function(){return function(e){return{api_key:String(e.api_key||""),user_id:e.user_id?String(e.user_id):null,user_token:e.user_token?String(e.user_token):void 0,user_profile:e.user_profile||{}}}(t)}),[t.api_key,t.user_id,t.user_token,JSON.stringify(t.user_profile)]),i=e.useState({isInitialized:!1,isInitializing:!1,error:null,chatbotConfig:null,isIframeVisible:!1}),o=i[0],r=i[1],a=e.useMemo((function(){return n.user_profile?Object.fromEntries(Object.entries(n.user_profile).map((function(e){var t=e[0],n=e[1];return"boolean"==typeof n||"number"==typeof n?[t,n]:[t,String(n)]}))):{}}),[JSON.stringify(n.user_profile)]),l=e.useCallback((function(e){r((function(t){return s(s({},t),e)}))}),[]),u=e.useCallback((function(){return c(void 0,void 0,void 0,(function(){var e,t,i,o,r,c,u,p,f,m,h,v,g,y,b,_,w,E,T,x,I,S,C,A,O,R,D,N,L,k,M,z,H,F,U,P,B,W;return d(this,(function(d){switch(d.label){case 0:if(!n.api_key)return nt.trackError(new Error(yt[it](n.api_key)),"useChatbotState",{errorCode:it,errorType:mt,context:{timestamp:Date.now()}}),[2];l({isInitializing:!0}),d.label=1;case 1:return d.trys.push([1,4,5,6]),e=n.user_id||void 0,t=!1,e||(e=It("rblyn_anon")||xt(),St("rblyn_anon",e,365),t=!0),[4,Tt(n.api_key,e,n.user_token)];case 2:return i=d.sent(),o=qe(),r=_t(),c=s(s(s({},o),{__INT_SYS_INFO__:s(s({},o),r)}),a),u={chatbotId:n.api_key,userId:e,token:n.user_token,isAnonymous:t,domain:"",show_launcher:null===(h=null===(m=i.user.org_info)||void 0===m?void 0:m.show_launcher)||void 0===h||h,brand_colour:(null===(g=null===(v=i.user.org_info.brand_config)||void 0===v?void 0:v.colors)||void 0===g?void 0:g.brand_color)||"",image_url:(null===(b=null===(y=i.user.org_info)||void 0===y?void 0:y.brand_config)||void 0===b?void 0:b.launcher_logo_url)||"",userProfile:c,chat_interface_config:{chat_bubble_prompts:[],display_name:(null===(_=i.user.org_info.brand_config)||void 0===_?void 0:_.display_name)||"",welcome_message:(null===(w=i.user.org_info.brand_config)||void 0===w?void 0:w.welcome_message)||"Hey! What can we help you with today?",redirect_url:(null===(E=i.user.org_info.brand_config)||void 0===E?void 0:E.redirect_url)||""},interface_properties:{position:(null===(x=null===(T=i.user.org_info.brand_config)||void 0===T?void 0:T.interface_properties)||void 0===x?void 0:x.position)||exports.WidgetPositionEnums.RIGHT,side_spacing:null!==(C=null===(S=null===(I=i.user.org_info.brand_config)||void 0===I?void 0:I.interface_properties)||void 0===S?void 0:S.side_spacing)&&void 0!==C?C:20,bottom_spacing:null!==(R=null===(O=null===(A=i.user.org_info.brand_config)||void 0===A?void 0:A.interface_properties)||void 0===O?void 0:O.bottom_spacing)&&void 0!==R?R:20},interface_type:(null===(D=i.user.org_info.brand_config)||void 0===D?void 0:D.interface_type)||exports.ChatbotInterfaceType.WIDGET,launcher_type:(null===(N=i.user.org_info.brand_config)||void 0===N?void 0:N.launcher_type)||exports.LauncherType.IMAGE,launcher_properties:{text:(null===(k=null===(L=i.user.org_info.brand_config)||void 0===L?void 0:L.launcher_properties)||void 0===k?void 0:k.text)||""},images:{launcher_image_url:{url:(null===(H=null===(z=null===(M=i.user.org_info.brand_config)||void 0===M?void 0:M.images)||void 0===z?void 0:z.launcher_image_url)||void 0===H?void 0:H.url)||""}},proactive_message_obj:Nt(null===(P=null===(U=null===(F=null==i?void 0:i.user)||void 0===F?void 0:F.org_info)||void 0===U?void 0:U.brand_config)||void 0===P?void 0:P.proactive_message_obj),launcher_delay:(null===(W=null===(B=i.user.org_info)||void 0===B?void 0:B.brand_config)||void 0===W?void 0:W.launcher_delay)||{enabled:!1,delay:0}},[4,new Promise((function(e,t){Ot(u,(function(){l({isInitialized:!0,chatbotConfig:u}),e()}),(function(e){t(e)}))}))];case 3:return d.sent(),[3,6];case 4:return p=d.sent(),f=p instanceof Error?p.message:"Failed to initialize chatbot",l({error:f}),nt.trackError(p instanceof Error?p:new Error(f),"useChatbotState",{errorCode:at,errorType:mt,context:{timestamp:Date.now()}}),[3,6];case 5:return l({isInitializing:!1}),[7];case 6:return[2]}}))}))}),[n.api_key,n.user_id,n.user_token]);e.useEffect((function(){n.api_key&&u()}),[u]),e.useEffect((function(){o.chatbotConfig&&r((function(e){return s(s({},e),{chatbotConfig:s(s({},e.chatbotConfig),{userProfile:s(s({},qe()),a)})})}))}),[a]);var p=e.useCallback((function(){r((function(e){return s(s({},e),{isIframeVisible:!e.isIframeVisible})}))}),[]),f=e.useCallback((function(){l({isIframeVisible:!1})}),[]);return s(s({},o),{toggleIframeVisibility:p,closeIframe:f})},kt=function(t){var n,i,o,r,a,l,c,d=t.children,u=t.config,p=t.position,m=t.sideSpacing,h=t.bottomSpacing,v=e.useState(!1),g=v[0],y=v[1];e.useEffect((function(){var e=function(){var e=(null===window||void 0===window?void 0:window.innerWidth)<560;y(e)};return e(),window.addEventListener("resize",e),function(){window.removeEventListener("resize",e)}}),[]);var b=p||(null===(o=u.interface_properties)||void 0===o?void 0:o.position)||"Right",_=null!==(a=null!=m?m:null===(r=u.interface_properties)||void 0===r?void 0:r.side_spacing)&&void 0!==a?a:20,w=null!==(c=null!=h?h:null===(l=u.interface_properties)||void 0===l?void 0:l.bottom_spacing)&&void 0!==c?c:20;f.log("config",u,b,_);var E={position:"fixed",zIndex:1e3,display:"flex",flexDirection:"column"},T=s(s({},E),((n={bottom:"".concat(w,"px")})[b.toLowerCase()]="".concat(null!=_?_:20,"px"),n.alignItems="Right"===b?"flex-end":"flex-start",n.top=void 0,n["Right"===b?"left":"right"]=void 0,n)),x=s(s({},E),((i={top:0})[b.toLowerCase()]="".concat(null!=_?_:20,"px"),i.alignItems="center",i.bottom=void 0,i["Right"===b?"left":"right"]=void 0,i)),I=g?x:T;return e.useEffect((function(){console.log("Container screen width changed, isMobile:",g,"Style:",I)}),[g,I]),e.createElement("div",{className:"robylon-chatbot-container",style:I},d)},Mt=e.forwardRef((function(t,n){var i,o,r,a=t.api_key,l=t.user_id,p=t.user_token,m=t.user_profile,v=t.onEvent,g=t.position,b=t.sideSpacing,_=t.bottomSpacing,w=t.show_launcher,E=t.launcher_type,T=t.launcher_properties_text,x=t.overrides,I="string"==typeof b?""===b||isNaN(Number(b))?void 0:Number(b):b,S="string"==typeof _?""===_||isNaN(Number(_))?void 0:Number(_):_,C="string"==typeof g?"left"===g.toLowerCase()?"Left":"right"===g.toLowerCase()?"Right":void 0:g;e.useEffect((function(){}));var A=e.useMemo((function(){return{api_key:a,user_id:l,user_token:p,user_profile:m}}),[a,l,p,m]),O=e.useCallback((function(e){null==v||v(e)}),[v]),R=Lt(A),D=R.isInitialized,N=R.error,L=R.chatbotConfig,k=R.isIframeVisible,M=R.toggleIframeVisibility,z=R.closeIframe,H=e.useMemo((function(){return{api_key:a,user_profile:A.user_profile,onEvent:O,chatbotConfig:L?{isAnonymous:L.isAnonymous,userId:L.userId}:null}}),[a,A.user_profile,O,null==L?void 0:L.isAnonymous,null==L?void 0:L.userId]),F=function(t){var n=t.api_key,i=t.chatbotConfig,o=t.user_profile,r=t.onEvent,a=e.useMemo((function(){return{isAnonymous:(null==i?void 0:i.isAnonymous)||!1,userId:(null==i?void 0:i.userId)||""}}),[null==i?void 0:i.isAnonymous,null==i?void 0:i.userId]),l=e.useMemo((function(){return o||{}}),[JSON.stringify(o)]),p=e.useCallback((function(e){for(var t=[],i=1;i<arguments.length;i++)t[i-1]=arguments[i];return c(void 0,u([e],t,!0),void 0,(function(e,t){var i,o,r,c,u,p,m;return void 0===t&&(t={}),d(this,(function(d){switch(d.label){case 0:if(!n)return[2];d.label=1;case 1:return d.trys.push([1,3,,4]),i=y().apiUrl,o=qe(),r=s({trigger_time:Date.now(),channel:"CHATBOT",launch_url:(null===(m=null===window||void 0===window?void 0:window.location)||void 0===m?void 0:m.href)||"",org_id:n,client_user_id:a.isAnonymous?"Anonymous":String(a.userId),event_type:e,user_profile:l},t),c={org_id:n,event_data:r,metadata:s({timestamp:Date.now()},o),event_type:"INFO",user_id:a.userId},[4,fetch("".concat(i,"/users/sdk/record-logs/"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(c)})];case 2:if(!(u=d.sent()).ok)throw new Error("Failed to send internal event: ".concat(u.statusText));return[3,4];case 3:return p=d.sent(),f.error("Failed to send internal event:",p),[3,4];case 4:return[2]}}))}))}),[n,a]);return{emitEvent:e.useCallback((function(e,t){var n=Date.now();e!==h.CHATBOT_BUTTON_CLICKED&&e!==h.CHATBOT_CLOSED&&e!==h.CHATBOT_OPENED&&e!==h.CHATBOT_READY||(r&&r({type:e,timestamp:n,data:t}),p(e,{timestamp:n}))}),[r,p]),onInternalEvent:p}}(s({},H)),U=F.emitEvent,P=F.onInternalEvent;e.useImperativeHandle(n,(function(){return{show:function(){D&&L?k||(M(),U(h.CHATBOT_BUTTON_CLICKED)):console.warn("Robylon Chatbot: Cannot show - chatbot not ready yet")},hide:function(){D&&L?k&&(z(),U(h.CHATBOT_CLOSED)):console.warn("Robylon Chatbot: Cannot hide - chatbot not ready yet")},toggle:function(){D&&L?(M(),U(k?h.CHATBOT_CLOSED:h.CHATBOT_BUTTON_CLICKED)):console.warn("Robylon Chatbot: Cannot toggle - chatbot not ready yet")},isReady:D&&!!L}}),[D,L,k,M,z,U]),e.useEffect((function(){D&&L&&U(h.CHATBOT_READY)}),[D,L,U]);var B=e.useState(!1),W=B[0],j=B[1];e.useEffect((function(){var e,t,n,i,o,r,a;if(!(void 0!==w?Boolean(w):null===(e=null==L?void 0:L.show_launcher)||void 0===e||e))return j(!1),function(){a&&clearTimeout(a)};var l=!0===(null===(t=null==L?void 0:L.launcher_delay)||void 0===t?void 0:t.enabled),s=null!==(r=null!==(i=null===(n=null==L?void 0:L.launcher_delay)||void 0===n?void 0:n.seconds)&&void 0!==i?i:null===(o=null==L?void 0:L.launcher_delay)||void 0===o?void 0:o.delay)&&void 0!==r?r:0;return l&&Number(s)>0?(j(!1),a=window.setTimeout((function(){j(!0)}),1e3*Number(s))):j(!0),function(){a&&clearTimeout(a)}}),[w,null==L?void 0:L.show_launcher,null===(i=null==L?void 0:L.launcher_delay)||void 0===i?void 0:i.enabled,null===(o=null==L?void 0:L.launcher_delay)||void 0===o?void 0:o.seconds,null===(r=null==L?void 0:L.launcher_delay)||void 0===r?void 0:r.delay]),e.useEffect((function(){if(a)try{nt.initialize(a,l)}catch(e){nt.trackError(e instanceof Error?e:new Error(String(e)),"RobylonChatbot",{errorCode:lt,errorType:mt,context:{timestamp:Date.now()}})}else nt.trackError(new Error(yt[it](a)),"RobylonChatbot",{errorCode:it,errorType:mt,context:{timestamp:Date.now()}})}),[a,l]);var G=e.useCallback((function(){z(),U(h.CHATBOT_CLOSED)}),[z,U]),X=e.useCallback((function(){M(),U(k?h.CHATBOT_CLOSED:h.CHATBOT_BUTTON_CLICKED)}),[M,U,k]),V=e.useMemo((function(){var e,t,n,i,o;return{config:L,toggleIframe:X,isIframeVisible:k,onEvent:O,onInternalEvent:P,position:C,sideSpacing:I,bottomSpacing:S,launcher_type:E,launcher_properties_text:T,shouldFadeIn:!0===(null===(e=null==L?void 0:L.launcher_delay)||void 0===e?void 0:e.enabled)&&(null!==(o=null!==(n=null===(t=null==L?void 0:L.launcher_delay)||void 0===t?void 0:t.seconds)&&void 0!==n?n:null===(i=null==L?void 0:L.launcher_delay)||void 0===i?void 0:i.delay)&&void 0!==o?o:0)>0||!1}}),[L,X,k,O,P,C,I,S,E,T]);f.log("floatingButtonProps",V);var Y=e.useMemo((function(){return{config:L,isVisible:k,onClose:G,onEvent:O,onInternalEvent:P,position:C,bottomSpacing:S,overrides:x}}),[L,k,G,O,P,C,S,x]);return a&&!N&&L?e.createElement(Et,{componentName:"RobylonChatbot"},D?e.createElement(kt,{config:L,position:C,sideSpacing:I,bottomSpacing:S},e.createElement(Et,{componentName:"ChatbotIframe"},e.createElement(wt,s({},Y))),e.createElement(Et,{componentName:"ChatbotFloatingButton"},W?e.createElement(Ye,s({},V)):null)):null):null})),zt=e.memo(Mt,(function(e,t){return e.api_key===t.api_key&&e.user_id===t.user_id&&e.user_token===t.user_token&&JSON.stringify(e.user_profile)===JSON.stringify(t.user_profile)&&e.position===t.position&&e.sideSpacing===t.sideSpacing&&e.bottomSpacing===t.bottomSpacing&&e.show_launcher===t.show_launcher&&e.launcher_type===t.launcher_type&&e.launcher_properties_text===t.launcher_properties_text&&JSON.stringify(e.overrides)===JSON.stringify(t.overrides)&&!0})),Ht=function(){function e(e){var t=this;this.resizeObserver=null,this.proactiveElement=null,this.urlUnsubscribe=null,this.delayTimers=[],this.config=e,this.buttonElement=document.createElement("div"),this.handleResizeFunction=this.handleResize.bind(this),this.render(),this.mount();try{this.buttonElement.style.opacity="0",this.buttonElement.style.transition="transform 0.2s cubic-bezier(0.2, 1.27, 0.29, 0.97), opacity 280ms ease",requestAnimationFrame((function(){t.buttonElement.style.opacity="1"}))}catch(e){}this.setupResizeListener(),this.renderProactiveIfNeeded(),this.urlUnsubscribe=A((function(){t.clearProactiveDelays(),t.renderProactiveIfNeeded(!0)}))}return e.prototype.render=function(){var e=this;y().copilotUrl;var t=this.config,n=t.config,i={zIndex:"1000",display:"flex",flexDirection:"column-reverse",alignItems:"center",justifyContent:"center",cursor:"pointer",overflow:"hidden",marginTop:"16px",transition:"transform 0.2s cubic-bezier(0.2, 1.27, 0.29, 0.97)",transform:t.isIframeVisible?"scale(0.85)":"scale(1)",fontFamily:_};n.launcher_type===exports.LauncherType.IMAGE&&Object.assign(i,{width:"48px",height:"48px",borderRadius:"50%",backgroundColor:n.brand_colour}),this.applyResponsiveStyles(i),this.buttonElement.className="message-bubble-container",this.buttonElement.innerHTML="",this.buttonElement.appendChild(this.createLauncherElement()),this.buttonElement.onclick=function(){e.config.toggleIframe(),e.hideProactiveMessages()},this.renderProactiveIfNeeded()},e.prototype.createLauncherElement=function(){var e,t,n=this.config,i=n.config,o=n.isIframeVisible,r=y().copilotUrl;switch(console.log("config in floating button",i),i.launcher_type){case exports.LauncherType.TEXT:return this.createTextLauncher();case exports.LauncherType.TEXTUAL_IMAGE:return this.createTextualImageLauncher();case exports.LauncherType.IMAGE:default:if(o){var a=document.createElement("div");return a.innerHTML='\n <svg\n width="24"\n height="24"\n viewBox="0 0 24 24"\n fill="none"\n xmlns="http://www.w3.org/2000/svg"\n >\n <path\n d="M19 9L12 16L5 9"\n stroke="currentColor"\n stroke-width="1.5"\n stroke-linecap="round"\n stroke-linejoin="round"\n />\n </svg>\n ',a}var l=document.createElement("img");return l.src=i.launcher_type?(null===(t=null===(e=i.images)||void 0===e?void 0:e.launcher_image_url)||void 0===t?void 0:t.url)||"".concat(r,"/chatbubble.png"):i.image_url||"".concat(r,"/chatbubble.png"),l.alt="Chat",Object.assign(l.style,{zIndex:"1000",cursor:"pointer",borderRadius:"50%",objectFit:"cover",width:"100%",height:"100%",boxSizing:"border-box"}),l}},e.prototype.createTextLauncher=function(){var e=this.config.config,t=e.brand_colour,n=e.launcher_properties,i=document.createElement("div");Object.assign(i.style,{width:"fit-content",maxWidth:"160px",height:"40px",borderRadius:"9999px",backgroundColor:t,display:"flex",alignItems:"center",padding:"9px 20px",boxShadow:"0px 0px 16px 0px rgba(0, 0, 0, 0.24)",boxSizing:"border-box"});var o=document.createElement("div");Object.assign(o.style,{flex:"1",minWidth:"0"});var r=document.createElement("p");return Object.assign(r.style,{margin:"0",color:p(t),fontSize:"0.875rem",fontWeight:"600",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",lineHeight:w,fontFamily:_,WebkitFontSmoothing:"antialiased",textRendering:"optimizeLegibility",textSizeAdjust:"100%"}),r.textContent=(null==n?void 0:n.text)||"",o.appendChild(r),i.appendChild(o),i},e.prototype.createTextualImageLauncher=function(){var e,t,n,i,o,r,a=y().copilotUrl,l=this.config.config,s=l.brand_colour,c=l.launcher_properties,d=l.image_url,u=document.createElement("div");Object.assign(u.style,{maxWidth:"13rem",width:"fit-content",height:"40px",borderRadius:"9999px",backgroundColor:s,display:"flex",alignItems:"center",paddingLeft:"20px",paddingRight:"0",paddingTop:"9px",paddingBottom:"9px",boxShadow:"0px 0px 16px 0px rgba(0, 0, 0, 0.24)",gap:"8px",boxSizing:"border-box"});var f=document.createElement("div");Object.assign(f.style,{flex:"1",minWidth:"0"});var m=document.createElement("p");Object.assign(m.style,{margin:"0",color:p(s),fontSize:"0.875rem",fontWeight:"600",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",lineHeight:w,fontFamily:_,WebkitFontSmoothing:"antialiased",textRendering:"optimizeLegibility",textSizeAdjust:"100%"}),m.textContent=(null==c?void 0:c.text)||"";var h=document.createElement("div");Object.assign(h.style,{width:"40px",height:"40px",borderRadius:"9999px",overflow:"hidden",position:"relative",flexShrink:"0"});var v=document.createElement("img");return v.src=(null===(t=null===(e=null==this?void 0:this.config)||void 0===e?void 0:e.config)||void 0===t?void 0:t.launcher_type)?(null===(r=null===(o=null===(i=null===(n=null==this?void 0:this.config)||void 0===n?void 0:n.config)||void 0===i?void 0:i.images)||void 0===o?void 0:o.launcher_image_url)||void 0===r?void 0:r.url)||"".concat(a,"/chatbubble.png"):d||"".concat(a,"/chatbubble.png"),v.alt="Chat",Object.assign(v.style,{width:"100%",height:"100%",objectFit:"cover"}),f.appendChild(m),h.appendChild(v),u.appendChild(f),u.appendChild(h),u},e.prototype.applyResponsiveStyles=function(e){var t,n,i,o,r,a,l,c,d,u=(null===window||void 0===window?void 0:window.innerWidth)<560,p=this.config.config,f=this.config.position||(null===(i=p.interface_properties)||void 0===i?void 0:i.position)||"Right",m=null!==(a=null!==(o=this.config.sideSpacing)&&void 0!==o?o:null===(r=p.interface_properties)||void 0===r?void 0:r.side_spacing)&&void 0!==a?a:20,h=null!==(d=null!==(l=this.config.bottomSpacing)&&void 0!==l?l:null===(c=p.interface_properties)||void 0===c?void 0:c.bottom_spacing)&&void 0!==d?d:20;this.buttonElement.style.position="",this.buttonElement.style.bottom="",this.buttonElement.style.right="",this.buttonElement.style.left="";var v=s(s({},e),u?((t={position:"fixed",bottom:"".concat(h,"px")})[f.toLowerCase()]="".concat(m,"px"),t):((n={bottom:"".concat(h,"px")})[f.toLowerCase()]="".concat(m,"px"),n));Object.assign(this.buttonElement.style,v)},e.prototype.handleResize=function(){var e={zIndex:"1000",display:"flex",flexDirection:"column-reverse",alignItems:"center",justifyContent:"center",cursor:"pointer",overflow:"hidden",marginTop:"16px",borderRadius:this.config.config.launcher_type&&this.config.config.launcher_type!==exports.LauncherType.IMAGE?"9999px":"50%",boxSizing:"border-box"};this.config.config.launcher_type===exports.LauncherType.IMAGE&&Object.assign(e,{width:"48px",height:"48px",borderRadius:"50%",backgroundColor:this.config.config.brand_colour}),this.applyResponsiveStyles(e)},e.prototype.setupResizeListener=function(){"undefined"!=typeof ResizeObserver?(this.resizeObserver=new ResizeObserver(this.handleResizeFunction),this.resizeObserver.observe(document.body)):window.addEventListener("resize",this.handleResizeFunction)},e.prototype.getElement=function(){return this.buttonElement},e.prototype.mount=function(){var e=this;requestAnimationFrame((function(){var t,n;null===(n=(t=e.config).onEvent)||void 0===n||n.call(t,{type:h.CHATBOT_BUTTON_LOADED,timestamp:Date.now()}),e.config.onInternalEvent(h.CHATBOT_BUTTON_LOADED)}))},e.prototype.update=function(e){this.config.isIframeVisible,this.config=s(s({},this.config),e),this.buttonElement.style.transform=this.config.isIframeVisible?"scale(0.85)":"scale(1)",this.render(),this.renderProactiveIfNeeded()},e.prototype.destroy=function(){this.resizeObserver?(this.resizeObserver.disconnect(),this.resizeObserver=null):window.removeEventListener("resize",this.handleResizeFunction),this.buttonElement&&this.buttonElement.parentNode&&this.buttonElement.parentNode.removeChild(this.buttonElement),this.proactiveElement&&this.proactiveElement.parentElement&&(this.proactiveElement.parentElement.removeChild(this.proactiveElement),this.proactiveElement=null),this.clearProactiveDelays(),this.urlUnsubscribe&&(this.urlUnsubscribe(),this.urlUnsubscribe=null)},e.prototype.clearProactiveDelays=function(){this.delayTimers.forEach((function(e){return clearTimeout(e)})),this.delayTimers=[]},e.prototype.hideProactiveMessages=function(){var e,t,n=this;L();var i=null===(e=this.proactiveElement)||void 0===e?void 0:e.children[0];if(i){var o="Right"===(this.config.position||(null===(t=this.config.config.interface_properties)||void 0===t?void 0:t.position)||"Right");Array.from(i.children).forEach((function(e){e.className=o?"rblyn-proactive-exit-right":"rblyn-proactive-exit-left"})),setTimeout((function(){n.proactiveElement&&n.proactiveElement.parentElement&&n.proactiveElement.parentElement.removeChild(n.proactiveElement),n.proactiveElement=null,n.clearProactiveDelays()}),400)}else this.clearProactiveDelays()},e.prototype.injectAnimationStyles=function(){if(!document.getElementById("rblyn-proactive-animations")){var e=document.createElement("style");e.id="rblyn-proactive-animations",e.textContent="\n @keyframes slideInFromRight {\n 0% {\n transform: translateX(120%) scale(0.95);\n opacity: 0;\n }\n 85% {\n transform: translateX(0) scale(1);\n opacity: 1;\n }\n 92% {\n transform: translateX(-1px) scale(1.002);\n }\n 100% {\n transform: translateX(0) scale(1);\n opacity: 1;\n }\n }\n @keyframes slideInFromLeft {\n 0% {\n transform: translateX(-120%) scale(0.95);\n opacity: 0;\n }\n 85% {\n transform: translateX(0) scale(1);\n opacity: 1;\n }\n 92% {\n transform: translateX(1px) scale(1.002);\n }\n 100% {\n transform: translateX(0) scale(1);\n opacity: 1;\n }\n }\n @keyframes slideOutRight {\n 0% {\n transform: translateX(0) scale(1);\n opacity: 1;\n }\n 100% {\n transform: translateX(120%) scale(0.9);\n opacity: 0;\n }\n }\n @keyframes slideOutLeft {\n 0% {\n transform: translateX(0) scale(1);\n opacity: 1;\n }\n 100% {\n transform: translateX(-120%) scale(0.9);\n opacity: 0;\n }\n }\n .rblyn-proactive-enter-right {\n animation: slideInFromRight 1.2s cubic-bezier(0.5, 0.8, 0.3, 1.1) forwards;\n }\n .rblyn-proactive-enter-left {\n animation: slideInFromLeft 1.2s cubic-bezier(0.5, 0.8, 0.3, 1.1) forwards;\n }\n .rblyn-proactive-exit-right {\n animation: slideOutRight 0.4s ease-in forwards;\n }\n .rblyn-proactive-exit-left {\n animation: slideOutLeft 0.4s ease-in forwards;\n }\n .rblyn-proactive-close-enter-right {\n animation: slideInFromRight 1.2s cubic-bezier(0.5, 0.8, 0.3, 1.1) forwards;\n }\n .rblyn-proactive-close-enter-left {\n animation: slideInFromLeft 1.2s cubic-bezier(0.5, 0.8, 0.3, 1.1) forwards;\n }\n /* Reset styles for proactive message content to prevent website CSS interference */\n /* Only target children of the content wrapper, not the bubble container itself */\n .rblyn-proactive-message-content * {\n box-sizing: border-box !important;\n margin: 0 !important;\n padding: 0 !important;\n border: none !important;\n background: transparent;\n font-family: ".concat(_,' !important;\n font-size: inherit !important;\n font-weight: inherit !important;\n line-height: inherit !important;\n color: inherit;\n text-align: inherit;\n list-style: none;\n }\n .rblyn-proactive-message-content p,\n .rblyn-proactive-message-content div,\n .rblyn-proactive-message-content span {\n display: inline !important;\n margin: 0 !important;\n padding: 0 !important;\n }\n .rblyn-proactive-message-content p:first-child,\n .rblyn-proactive-message-content div:first-child,\n .rblyn-proactive-message-content span:first-child {\n margin-top: 0 !important;\n }\n .rblyn-proactive-message-content p:last-child,\n .rblyn-proactive-message-content div:last-child,\n .rblyn-proactive-message-content span:last-child {\n margin-bottom: 0 !important;\n }\n .rblyn-proactive-message-content a {\n color: inherit !important;\n text-decoration: underline !important;\n cursor: pointer !important;\n }\n .rblyn-proactive-message-content a:hover {\n opacity: 0.8 !important;\n }\n .rblyn-proactive-message-content b,\n .rblyn-proactive-message-content strong {\n font-weight: 600 !important;\n }\n .rblyn-proactive-message-content i,\n .rblyn-proactive-message-content em {\n font-style: italic !important;\n }\n .rblyn-proactive-message-content u {\n text-decoration: underline !important;\n }\n .rblyn-proactive-message-content br {\n display: block !important;\n content: "" !important;\n margin-top: 0.5em !important;\n }\n '),document.head.appendChild(e)}},e.prototype.renderProactiveIfNeeded=function(e){var t,n,i,o,r,a,l,s,c,d,u,p,f=this,m=null===(n=null===(t=this.config)||void 0===t?void 0:t.config)||void 0===n?void 0:n.proactive_message_obj;if(Array.isArray(m)&&!this.config.isIframeVisible&&!k()){if(this.injectAnimationStyles(),!this.proactiveElement){var h=document.createElement("div");h.style.position="fixed";var v=null!==(a=null!==(o=this.config.bottomSpacing)&&void 0!==o?o:null===(r=this.config.config.interface_properties)||void 0===r?void 0:r.bottom_spacing)&&void 0!==a?a:20,g=null!==(c=null!==(l=this.config.sideSpacing)&&void 0!==l?l:null===(s=this.config.config.interface_properties)||void 0===s?void 0:s.side_spacing)&&void 0!==c?c:20,y=this.config.position||(null===(d=this.config.config.interface_properties)||void 0===d?void 0:d.position)||"Right";h.style.bottom="".concat(v+(this.config.config.launcher_type===exports.LauncherType.IMAGE?48:40)+8,"px"),"Right"===y?h.style.right="".concat(g,"px"):h.style.left="".concat(g,"px"),h.style.maxWidth="22.875rem",h.style.zIndex="2147483646";var b=document.createElement("div");b.style.display="flex",b.style.flexDirection="column",b.style.alignItems="Right"===y?"flex-end":"flex-start";var E=document.createElement("div");E.style.position="absolute",E.style.top="-32px",E.style.width="24px",E.style.height="24px",E.style.borderRadius="50%",E.style.background="#fff",E.style.boxShadow="0 2.667px 2.667px 0 rgba(0, 0, 0, 0.25)",E.style.display="flex",E.style.alignItems="center",E.style.justifyContent="center",E.style.cursor="pointer",E.style.opacity="0",E.style.visibility="hidden","Right"===(this.config.position||(null===(u=this.config.config.interface_properties)||void 0===u?void 0:u.position)||"Right")?(E.style.right="0px",E.style.left="auto",E.style.transform="translateX(120%) scale(0.95)"):(E.style.left="0px",E.style.right="auto",E.style.transform="translateX(-120%) scale(0.95)"),E.onclick=function(e){e.stopPropagation(),f.hideProactiveMessages()},E.innerHTML='\n <svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 14 14" fill="none">\n <path d="M10.3334 10.3334L7.00009 7.00009M7.00009 7.00009L3.66675 3.66675M7.00009 7.00009L10.3334 3.66675M7.00009 7.00009L3.66675 10.3334" stroke="#444547" stroke-width="0.816326" stroke-linecap="round" stroke-linejoin="round"/>\n </svg>\n ',h.appendChild(b),h.appendChild(E),document.body.appendChild(h),this.proactiveElement=h}var T=this.proactiveElement.children[0];T.innerHTML="";var x="Right"===(this.config.position||(null===(p=this.config.config.interface_properties)||void 0===p?void 0:p.position)||"Right");T.style.display="flex",T.style.flexDirection="column",T.style.alignItems=x?"flex-end":"flex-start",this.clearProactiveDelays();var I=U(m),S=I.length>0?I[I.length-1].delayMs:0,C=this.proactiveElement.children[1];if(C&&I.length>0){C.style.opacity="0",C.style.visibility="hidden",C.style.transform=x?"translateX(120%) scale(0.95)":"translateX(-120%) scale(0.95)";var A=window.setTimeout((function(){C.style.visibility="visible",C.style.animationDelay="0ms",C.className=x?"rblyn-proactive-close-enter-right":"rblyn-proactive-close-enter-left"}),S);this.delayTimers.push(A)}else C&&(C.style.opacity="0",C.style.visibility="hidden");I.forEach((function(e,t){var n=window.setTimeout((function(){var n=document.createElement("div");n.style.background="#fff",n.style.color="#111",n.style.borderRadius="12px",n.style.boxShadow="0 2px 2px 0 rgba(0, 0, 0, 0.08)",n.style.padding="16px",n.style.border="1px solid #F1F2F4",n.style.cursor="pointer",n.style.fontFamily=_,n.style.fontSize="14px",n.style.lineHeight=String(w),n.style.width="fit-content",n.style.maxWidth="100%",t<I.length-1&&(n.style.marginBottom="16px");var i=10*(I.length-1-t);n.className=x?"rblyn-proactive-enter-right":"rblyn-proactive-enter-left",n.style.animationDelay="".concat(i,"ms"),n.style.opacity="0",n.style.transform=x?"translateX(120%) scale(0.95)":"translateX(-120%) scale(0.95)";var o=document.createElement("div");o.className="rblyn-proactive-message-content",o.innerHTML=Ve(e.html),n.appendChild(o),n.onclick=function(){M({message_id:e.messageId,content_string:e.html||null}),f.config.toggleIframe(),f.hideProactiveMessages();try{window.dispatchEvent(new CustomEvent("rblyn:proactiveClick",{detail:{message_id:e.messageId,content_string:e.html||null}}))}catch(e){}},T.appendChild(n)}),e.delayMs);f.delayTimers.push(n)}))}else if(this.proactiveElement&&this.proactiveElement.parentElement){var O=this.proactiveElement.children[0],R="Right"===(this.config.position||(null===(i=this.config.config.interface_properties)||void 0===i?void 0:i.position)||"Right");Array.from(O.children).forEach((function(e){e.className=R?"rblyn-proactive-exit-right":"rblyn-proactive-exit-left"})),setTimeout((function(){f.proactiveElement&&f.proactiveElement.parentElement&&f.proactiveElement.parentElement.removeChild(f.proactiveElement),f.proactiveElement=null,f.clearProactiveDelays()}),400)}else this.proactiveElement=null,this.clearProactiveDelays()},e}(),Ft=function(){function e(e){var t=this;this.isInitialized=!1,this.hasRegistered=!1,this.overridesPayloadCache=null,this.handleMessage=function(e){var n,i,o,r,a,l,s,c,d,u,p,f,m,g,b,_=y().copilotUrl;if(e.origin===_){if("closeChatbot"===e.data)return void t.config.onClose();if("CHATBOT_TOKEN_EXHAUSTED"===(null===(n=e.data)||void 0===n?void 0:n.type))return void t.config.onInternalEvent(v.CHATBOT_TOKEN_EXHAUSTED);"CHATBOT_LOADED"===(null===(i=e.data)||void 0===i?void 0:i.type)&&(null===(r=(o=t.config).onEvent)||void 0===r||r.call(o,{type:h.CHATBOT_LOADED,timestamp:Date.now()}),t.config.onInternalEvent(h.CHATBOT_LOADED)),"CHAT_INITIALIZED"===(null===(a=e.data)||void 0===a?void 0:a.type)&&(null===(s=(l=t.config).onEvent)||void 0===s||s.call(l,{type:h.CHAT_INITIALIZED,timestamp:Date.now()}),t.config.onInternalEvent(h.CHAT_INITIALIZED)),"CHAT_INITIALIZATION_FAILED"===(null===(c=e.data)||void 0===c?void 0:c.type)&&(null===(u=(d=t.config).onEvent)||void 0===u||u.call(d,{type:h.CHAT_INITIALIZATION_FAILED,timestamp:Date.now()}),t.config.onInternalEvent(h.CHAT_INITIALIZATION_FAILED,{error:null===(p=e.data)||void 0===p?void 0:p.error})),"SESSION_REFRESHED"===(null===(f=e.data)||void 0===f?void 0:f.type)&&(null===(g=(m=t.config).onEvent)||void 0===g||g.call(m,{type:h.SESSION_REFRESHED,timestamp:Date.now()}),t.config.onInternalEvent(h.SESSION_REFRESHED)),"CHAT_MOVED"===(null===(b=e.data)||void 0===b?void 0:b.type)&&t.config.onInternalEvent(v.CHAT_MOVED,{from:e.data.from,to:e.data.to,trigger:e.data.trigger})}},this.config=e,this.iframeElement=document.createElement("iframe"),this.iframeElement.id="chat-iframe-rbyln",this.resizeHandler=this.applyResponsiveStyles.bind(this),this.render(),this.initialize(),this.setupEventListeners()}return e.prototype.getElement=function(){return this.iframeElement},e.prototype.render=function(){var e,t=this.config.position||(null===(e=this.config.config.interface_properties)||void 0===e?void 0:e.position)||"Right";Object.assign(this.iframeElement.style,{zIndex:"20000000",border:"none",boxShadow:"0px 0px 40px 0px rgba(14, 14, 15, 0.24)",transformOrigin:"bottom ".concat(t.toLowerCase()),transition:"transform 0.2s cubic-bezier(0.2, 1.27, 0.29, 0.97), opacity 0.15s ease-out",transform:"scale(0.3) translate3d(0,40px,0)",opacity:"0",display:"none"}),this.applyResponsiveStyles()},e.prototype.applyResponsiveStyles=function(){var e,t,n,i,o,r;if(this.iframeElement){var a=this.config.position||(null===(n=this.config.config.interface_properties)||void 0===n?void 0:n.position)||"Right",l=null!==(r=null!==(i=this.config.bottomSpacing)&&void 0!==i?i:null===(o=this.config.config.interface_properties)||void 0===o?void 0:o.bottom_spacing)&&void 0!==r?r:20;window.innerWidth<560?Object.assign(this.iframeElement.style,((e={width:"100vw",minWidth:"300px"})[a.toLowerCase()]="0",e.bottom="0",e.height="100vh",e.flexDirection="column",e.flexGrow="1",e.borderRadius="0",e.top="0",e.maxHeight="100%",e.position="fixed",e)):Object.assign(this.iframeElement.style,((t={width:"26%",minWidth:"400px",height:"calc(100vh - 2rem - 10vh - ".concat(l,"px)"),borderRadius:"1rem",top:"calc(10vh - 32px)",maxHeight:"50rem",position:""})[a.toLowerCase()]=void 0,t))}},e.prototype.initialize=function(){var e=this;if(!this.isInitialized){var t=y().copilotUrl;this.iframeElement.src="".concat(t,"/chatbot-plugin?id=").concat(this.config.config.chatbotId),this.isInitialized=!0,this.iframeElement.addEventListener("load",(function(){var n,i,o,r,a,l,s,c,d,u,p,f,m,h,v,g,y,b,_=new URL(e.iframeElement.src).origin||t;null===(n=e.iframeElement.contentWindow)||void 0===n||n.postMessage({domain:null===(i=null===window||void 0===window?void 0:window.location)||void 0===i?void 0:i.hostname,name:"checkDomain"},_);var w={header_avatar:null!==(r=null===(o=e.config.overrides)||void 0===o?void 0:o.header_avatar)&&void 0!==r?r:null,agent_avatar:null!==(l=null===(a=e.config.overrides)||void 0===a?void 0:a.agent_avatar)&&void 0!==l?l:null,header_title:null!==(c=null===(s=e.config.overrides)||void 0===s?void 0:s.header_title)&&void 0!==c?c:null,header_subtitle:null!==(u=null===(d=e.config.overrides)||void 0===d?void 0:d.header_subtitle)&&void 0!==u?u:null,header_title_text_color:null!==(f=null===(p=e.config.overrides)||void 0===p?void 0:p.header_title_text_color)&&void 0!==f?f:null,header_subtitle_text_color:null!==(h=null===(m=e.config.overrides)||void 0===m?void 0:m.header_subtitle_text_color)&&void 0!==h?h:null,header_bg:null!==(g=null===(v=e.config.overrides)||void 0===v?void 0:v.header_bg)&&void 0!==g?g:null};null===(y=e.iframeElement.contentWindow)||void 0===y||y.postMessage({domain:null===(b=null===window||void 0===window?void 0:window.location)||void 0===b?void 0:b.hostname,action:"updateOverrides",data:w},_)}))}},e.prototype.setupEventListeners=function(){var e=this;window.addEventListener("resize",this.resizeHandler),this.iframeElement.addEventListener("error",(function(){nt.trackError(new Error(yt[ut]({src:e.iframeElement.src,error:"Failed to load iframe"})),"ChatbotIframe",{errorCode:ut,errorType:vt,context:{config:e.config.config,iframeUrl:e.iframeElement.src,timestamp:Date.now()}})})),window.addEventListener("message",this.handleMessage);window.addEventListener("rblyn:proactiveClick",(function(t){var n,i,o,r,a,l;if(e.hasRegistered){var s=(null==t?void 0:t.detail)||{},c=y().copilotUrl,d=new URL(e.iframeElement.src).origin||c;null===(n=e.iframeElement.contentWindow)||void 0===n||n.postMessage({domain:null===(i=null===window||void 0===window?void 0:window.location)||void 0===i?void 0:i.hostname,action:"proactiveClick",data:{userId:null===(o=e.config.config)||void 0===o?void 0:o.userId,token:null===(r=e.config.config)||void 0===r?void 0:r.token,userProfile:null===(a=e.config.config)||void 0===a?void 0:a.userProfile,isAnonymous:null===(l=e.config.config)||void 0===l?void 0:l.isAnonymous,proactiveData:{input_id:null,message_id:(null==s?void 0:s.message_id)||null,content_string:(null==s?void 0:s.content_string)||null}}},d)}}))},e.prototype.updateVisibility=function(e){var t,n,i,o,r,a,l,c,d,u,p,f=this;this.config.isVisible=e;var m=this.config.position||(null===(t=this.config.config.interface_properties)||void 0===t?void 0:t.position)||"Right";if(e?(this.iframeElement.style.display="block",this.iframeElement.getBoundingClientRect(),this.iframeElement.style.opacity="1",this.iframeElement.style.transform="scale(1) translate3d(0,0,0)"):(this.iframeElement.style.opacity="0",this.iframeElement.style.transform="scale(0.3) translate3d(".concat((m.toLowerCase(),"0"),",40px,0)"),setTimeout((function(){f.config.isVisible||(f.iframeElement.style.display="none")}),200)),this.iframeElement.contentWindow&&e){var v=y().copilotUrl,g=new URL(this.iframeElement.src).origin||v;if(this.iframeElement.contentWindow.postMessage({domain:null===(n=null===window||void 0===window?void 0:window.location)||void 0===n?void 0:n.hostname,name:"openFrame"},g),!this.hasRegistered){var b=z();this.iframeElement.contentWindow.postMessage({domain:null===(i=null===window||void 0===window?void 0:window.location)||void 0===i?void 0:i.hostname,action:"registerUserId",data:s({userId:null===(o=this.config.config)||void 0===o?void 0:o.userId,token:null===(r=this.config.config)||void 0===r?void 0:r.token,userProfile:s(s({},null===(a=this.config.config)||void 0===a?void 0:a.userProfile),{__INT_SYS_INFO__:s(s({},(null===(c=null===(l=this.config.config)||void 0===l?void 0:l.userProfile)||void 0===c?void 0:c.__INT_SYS_INFO__)||{}),_t())}),isAnonymous:null===(d=this.config.config)||void 0===d?void 0:d.isAnonymous},b?{proactiveData:b}:{})},g),this.hasRegistered=!0}null===(p=(u=this.config).onEvent)||void 0===p||p.call(u,{type:h.CHATBOT_OPENED,timestamp:Date.now()}),this.config.onInternalEvent(h.CHATBOT_OPENED)}},e.prototype.update=function(e){var t=this.config.isVisible;if(this.config=s(s({},this.config),e),t!==this.config.isVisible&&this.updateVisibility(this.config.isVisible),this.iframeElement.contentWindow&&this.config.isVisible){var n=y().copilotUrl;this.iframeElement.contentWindow.postMessage({action:"updateUserProfile",user_profile:this.config.config.userProfile},n)}},e.prototype.destroy=function(){window.removeEventListener("resize",this.resizeHandler),window.removeEventListener("message",this.handleMessage),this.iframeElement&&this.iframeElement.parentNode&&this.iframeElement.parentNode.removeChild(this.iframeElement)},e}(),Ut=function(){function e(e,t,n,i){this.resizeObserver=null,this.containerElement=document.createElement("div"),this.handleResizeFunction=this.handleResize.bind(this),this.config={config:e,position:t,sideSpacing:n,bottomSpacing:i},this.render(),this.mount(),this.setupResizeListener()}return e.prototype.render=function(){this.applyStyles(),this.containerElement.className="robylon-chatbot-container"},e.prototype.applyStyles=function(){var e,t,n,i,o,r,a,l,c,d=(null===window||void 0===window?void 0:window.innerWidth)<560,u=this.config.position||(null===(n=this.config.config.interface_properties)||void 0===n?void 0:n.position)||"Right",p=null!==(r=null!==(i=this.config.sideSpacing)&&void 0!==i?i:null===(o=this.config.config.interface_properties)||void 0===o?void 0:o.side_spacing)&&void 0!==r?r:20,f=null!==(c=null!==(a=this.config.bottomSpacing)&&void 0!==a?a:null===(l=this.config.config.interface_properties)||void 0===l?void 0:l.bottom_spacing)&&void 0!==c?c:20;this.containerElement.style.position="",this.containerElement.style.top="",this.containerElement.style.bottom="",this.containerElement.style.right="",this.containerElement.style.left="",this.containerElement.style.alignItems="";var m={position:"fixed",zIndex:"1000",display:"flex",flexDirection:"column"},h=s(s({},m),((e={bottom:"".concat(f,"px")})[u.toLowerCase()]="".concat(p,"px"),e.alignItems="Right"===u?"flex-end":"flex-start",e)),v=s(s({},m),((t={top:"0"})[u.toLowerCase()]="".concat(p,"px"),t.alignItems="center",t));Object.assign(this.containerElement.style,d?v:h)},e.prototype.handleResize=function(){this.applyStyles()},e.prototype.setupResizeListener=function(){"undefined"!=typeof ResizeObserver?(this.resizeObserver=new ResizeObserver(this.handleResizeFunction),this.resizeObserver.observe(document.body)):window.addEventListener("resize",this.handleResizeFunction)},e.prototype.mount=function(){document.body.appendChild(this.containerElement)},e.prototype.getElement=function(){return this.containerElement},e.prototype.destroy=function(){this.resizeObserver?(this.resizeObserver.disconnect(),this.resizeObserver=null):window.removeEventListener("resize",this.handleResizeFunction),this.containerElement&&this.containerElement.parentNode&&this.containerElement.parentNode.removeChild(this.containerElement)},e}(),Pt=function(e){e.api_key,e.user_profile;var t=e.onEvent;e.chatbotConfig;return{emit:function(e,n){var i={type:e,timestamp:Date.now(),data:n};null==t||t(i)},onInternalEvent:function(e,t){}}},Bt=function(){function e(e){var t=this;this.container=null,this.floatingButton=null,this.launcherDelayTimeout=null,this.iframe=null,this.isDestroyed=!1,this.handleStateChange=function(e){var n,i,o,r,a,l;if(!t.isDestroyed){var s=e.isInitialized,c=e.error,d=e.chatbotConfig,u=e.isIframeVisible;if(!c&&d&&s){if(t.eventEmitter=Pt({api_key:t.config.api_key,user_profile:t.config.user_profile,onEvent:t.config.onEvent,chatbotConfig:{isAnonymous:d.isAnonymous,userId:d.userId}}),t.container||(t.container=new Ut(d,t.config.position,t.config.sideSpacing,t.config.bottomSpacing)),t.iframe)t.iframe.update({config:d,isVisible:u,position:t.config.position,bottomSpacing:t.config.bottomSpacing,overrides:t.config.overrides});else if(t.iframe=new Ft({config:d,isVisible:u,onClose:t.handleClose,onEvent:t.config.onEvent,onInternalEvent:t.eventEmitter.onInternalEvent,position:t.config.position,bottomSpacing:t.config.bottomSpacing,overrides:t.config.overrides}),t.iframe.getElement&&"function"==typeof t.iframe.getElement){var p=t.iframe.getElement();p&&t.container&&t.container.getElement().prepend(p)}var f=void 0!==t.config.show_launcher?Boolean(t.config.show_launcher):null===(n=null==d?void 0:d.show_launcher)||void 0===n||n,m=!0===(null===(i=null==d?void 0:d.launcher_delay)||void 0===i?void 0:i.enabled),h=null!==(l=null!==(r=null===(o=null==d?void 0:d.launcher_delay)||void 0===o?void 0:o.seconds)&&void 0!==r?r:null===(a=null==d?void 0:d.launcher_delay)||void 0===a?void 0:a.delay)&&void 0!==l?l:0,v=function(){if(t.floatingButton)t.floatingButton.update({config:d,isIframeVisible:u,position:t.config.position,sideSpacing:t.config.sideSpacing,bottomSpacing:t.config.bottomSpacing});else if(t.floatingButton=new Ht({config:d,toggleIframe:t.toggleIframe,isIframeVisible:u,onEvent:t.config.onEvent,onInternalEvent:t.eventEmitter.onInternalEvent,position:t.config.position,sideSpacing:t.config.sideSpacing,bottomSpacing:t.config.bottomSpacing}),t.floatingButton.getElement&&"function"==typeof t.floatingButton.getElement){var e=t.floatingButton.getElement();e&&t.container&&t.container.getElement().appendChild(e)}};t.launcherDelayTimeout&&(clearTimeout(t.launcherDelayTimeout),t.launcherDelayTimeout=null),f?m&&Number(h)>0&&!t.floatingButton?t.launcherDelayTimeout=window.setTimeout((function(){v(),t.launcherDelayTimeout=null}),1e3*Number(h)):v():t.floatingButton&&(t.floatingButton.destroy(),t.floatingButton=null)}}},this.toggleIframe=function(){var e=t.stateManager.getState();t.stateManager.toggleIframeVisibility(),t.eventEmitter.emit(e.isIframeVisible?h.CHATBOT_CLOSED:h.CHATBOT_BUTTON_CLICKED)},this.handleClose=function(){t.stateManager.closeIframe(),t.eventEmitter.emit(h.CHATBOT_CLOSED)};var n=s(s({},e),{position:"string"==typeof e.position?"left"===e.position.toLowerCase()?"Left":"right"===e.position.toLowerCase()?"Right":void 0:void 0,sideSpacing:"string"==typeof e.sideSpacing?""===e.sideSpacing||isNaN(Number(e.sideSpacing))?void 0:Number(e.sideSpacing):e.sideSpacing,bottomSpacing:"string"==typeof e.bottomSpacing?""===e.bottomSpacing||isNaN(Number(e.bottomSpacing))?void 0:Number(e.bottomSpacing):e.bottomSpacing,show_launcher:e.show_launcher,overrides:e.overrides});if(this.config=n,!e.api_key)throw nt.trackError(new Error(yt[it](e.api_key)),"RobylonChatbot",{errorCode:it,errorType:mt,context:{timestamp:Date.now()}}),new Error("API key is required");try{nt.initialize(e.api_key,e.user_id)}catch(e){nt.trackError(e instanceof Error?e:new Error(String(e)),"RobylonChatbot",{errorCode:lt,errorType:mt,context:{timestamp:Date.now()}})}this.stateManager=function(e){var t={isInitialized:!1,isInitializing:!1,error:null,chatbotConfig:null,isIframeVisible:!1},n=[],i=function(e){t=s(s({},t),e),n.forEach((function(e){return e(t)}))};return{getState:function(){return t},initialize:function(){return c(void 0,void 0,void 0,(function(){var t,n,o;return d(this,(function(r){switch(r.label){case 0:if(!e.api_key)return nt.trackError(new Error(yt[it](e.api_key)),"ChatbotStateManager",{errorCode:it,errorType:mt,context:{timestamp:Date.now()}}),[2];i({isInitializing:!0}),r.label=1;case 1:return r.trys.push([1,4,5,6]),[4,Dt(e)];case 2:return t=r.sent(),[4,new Promise((function(e,n){Ot(t,(function(){i({isInitialized:!0,chatbotConfig:t}),e()}),(function(e){n(e)}))}))];case 3:return r.sent(),[3,6];case 4:return n=r.sent(),o=n instanceof Error?n.message:"Failed to initialize chatbot",i({error:o}),nt.trackError(n instanceof Error?n:new Error(o),"ChatbotStateManager",{errorCode:at,errorType:mt,context:{timestamp:Date.now()}}),[3,6];case 5:return i({isInitializing:!1}),[7];case 6:return[2]}}))}))},toggleIframeVisibility:function(){i({isIframeVisible:!t.isIframeVisible})},closeIframe:function(){i({isIframeVisible:!1})},updateState:i,subscribe:function(e){return n.push(e),function(){var t=n.indexOf(e);t>-1&&n.splice(t,1)}},unsubscribe:function(e){var t=n.indexOf(e);t>-1&&n.splice(t,1)}}}({api_key:e.api_key,user_id:e.user_id,user_token:e.user_token,user_profile:e.user_profile}),this.eventEmitter=Pt({api_key:e.api_key,user_profile:e.user_profile,onEvent:e.onEvent,chatbotConfig:null}),this.initialize()}return e.prototype.initialize=function(){return c(this,void 0,void 0,(function(){var e;return d(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,this.stateManager.initialize()];case 1:return t.sent(),this.stateManager.subscribe(this.handleStateChange),this.handleStateChange(this.stateManager.getState()),[3,3];case 2:return e=t.sent(),nt.trackError(e instanceof Error?e:new Error(String(e)),"RobylonChatbot.initialize",{errorCode:at,errorType:mt,context:{timestamp:Date.now()}}),[3,3];case 3:return[2]}}))}))},e.prototype.show=function(){this.stateManager.getState().isIframeVisible||(this.stateManager.toggleIframeVisibility(),this.eventEmitter.emit(h.CHATBOT_BUTTON_CLICKED))},e.prototype.hide=function(){this.stateManager.getState().isIframeVisible&&(this.stateManager.closeIframe(),this.eventEmitter.emit(h.CHATBOT_CLOSED))},e.prototype.toggle=function(){this.toggleIframe()},e.prototype.destroy=function(){this.isDestroyed=!0,this.floatingButton&&(this.floatingButton.destroy(),this.floatingButton=null),this.launcherDelayTimeout&&(clearTimeout(this.launcherDelayTimeout),this.launcherDelayTimeout=null),this.iframe&&(this.iframe.destroy(),this.iframe=null),this.container&&(this.container.destroy(),this.container=null),this.stateManager.unsubscribe(this.handleStateChange)},e.prototype.getState=function(){return this.stateManager.getState().isInitialized?"initialized":"uninitialized"},e}();function Wt(e){return new Bt(e)}"undefined"!=typeof window&&function(){if("undefined"!=typeof window){var e=window.RobylonChatbot;if(e&&Array.isArray(e.q)){var t=null;e.q.forEach((function(e){var n=e[0];if("init"===n){var i=e[1]||{};t=Wt(i)}else t&&"function"==typeof t[n]&&t[n]()})),window.RobylonChatbot=function(e){var n=Array.prototype.slice.call(arguments,1);return"init"===e?t=Wt(n[0]||{}):t&&"function"==typeof t[e]?t[e].apply(t,n):void 0},window.RobylonChatbot.getState=function(){return"initialized"}}}}();var jt={create:Wt,getState:function(){return"initialized"}};exports.Chatbot=zt,exports.RobylonChatbot=jt,exports.useChatbot=function(t){var n=e.useState({isLoading:!0,isInitialized:!1,error:null}),i=n[0],o=n[1],r=function(e){o((function(t){return s(s({},t),{isInitialized:e})}))},a=function(e){o((function(t){return s(s({},t),{error:e})}))};return e.useEffect((function(){!function(){try{Ot(t,r,a)}catch(e){o((function(t){return s(s({},t),{error:e instanceof Error?e.message:"Failed to initialize SDK",isLoading:!1})}))}}()}),[t.chatbotId,t.userId]),i};
|
|
4
4
|
//# sourceMappingURL=index.js.map
|