@crestapps/ai-chat-ui 1.0.0-preview.95 → 1.0.0-preview.97
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/ai-chat-widget.js +2 -0
- package/dist/ai-chat-widget.js.map +1 -1
- package/dist/ai-chat-widget.min.js +1 -1
- package/dist/ai-chat-widget.min.js.map +1 -1
- package/dist/ai-chat.css +22 -3
- package/dist/ai-chat.css.map +1 -1
- package/dist/ai-chat.js +10 -2
- package/dist/ai-chat.js.map +1 -1
- package/dist/ai-chat.min.css +1 -1
- package/dist/ai-chat.min.js +1 -1
- package/dist/ai-chat.min.js.map +1 -1
- package/dist/chat-widget.css +40 -9
- package/dist/chat-widget.css.map +1 -1
- package/dist/chat-widget.min.css +1 -1
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
function clampWidgetValue(e,t,i){return Math.min(Math.max(e,t),i)}window.coreAIChatWidgetBehavior=window.coreAIChatWidgetBehavior||function(){function e(e){if("number"==typeof e&&Number.isFinite(e))return e;if("string"!=typeof e)return null;var t=parseFloat(e);return Number.isFinite(t)?t:null}function t(t,i){if(t&&!t.widgetIsInitialized)if(i.widget.chatWidgetContainer)if(i.widget.chatWidgetStateName){var n=document.querySelector(i.widget.chatWidgetContainer);if(n){i.widget.chatHistorySection&&(t.chatHistorySection=document.querySelector(i.widget.chatHistorySection)),t.chatWidgetStateName=i.widget.chatWidgetStateName,t.chatWidgetStateSession=i.widget.chatWidgetStateName+"Session",t.chatWidgetStateDocuments=i.widget.chatWidgetStateName+"Documents",t.chatWidgetLayoutKey=i.widget.chatWidgetStateName+"Layout",t.widgetContainerElement=n,t.widgetToggleButtonElement=i.widget.toggleButtonSelector?document.querySelector(i.widget.toggleButtonSelector):null,t.widgetResetSizeButtonElement=i.widget.resetSizeButtonSelector?document.querySelector(i.widget.resetSizeButtonSelector):null,t.widgetDefaultWidth=e(i.widget.defaultWidth)||e(window.getComputedStyle(n).width)||380,t.widgetDefaultHeight=e(i.widget.defaultHeight)||e(window.getComputedStyle(n).height)||520,t.widgetIsInitialized=!0,t.clearStoredWidgetDocuments(),t.documents=[],i.widget.enableResizing&&(n.classList.add("ai-chat-widget-resizable"),n.style.minWidth=(e(i.widget.minWidth)||320)+"px",n.style.minHeight=(e(i.widget.minHeight)||420)+"px","undefined"!=typeof ResizeObserver&&(t.widgetResizeObserver=new ResizeObserver(function(){t.persistWidgetPanelSize(),t.constrainWidgetElementsToViewport(),t.updateWidgetResetSizeButtonVisibility()}),t.widgetResizeObserver.observe(n)));var o=i.widget.dragHandleSelector||".ai-chat-widget-header",a=n.querySelector(o);if(i.widget.enableDragging&&a&&(a.classList.add("ai-chat-widget-drag-handle"),n.classList.add("ai-chat-widget-draggable"),t.attachDraggableWidgetElement(n,a,"panel",!1)),i.widget.enableDragging&&t.widgetToggleButtonElement&&(t.widgetToggleButtonElement.classList.add("ai-chat-widget-draggable"),t.attachDraggableWidgetElement(t.widgetToggleButtonElement,t.widgetToggleButtonElement,"toggle",!0)),t.widgetResetSizeButtonElement&&t.widgetResetSizeButtonElement.addEventListener("click",function(e){e.preventDefault(),t.resetWidgetSize()}),t.restoreWidgetLayout(),t.widgetViewportResizeHandler||(t.widgetViewportResizeHandler=function(){i.widget.persistLayout?t.restoreWidgetLayout():t.constrainWidgetElementsToViewport(),t.updateWidgetResetSizeButtonVisibility()},window.addEventListener("resize",t.widgetViewportResizeHandler)),t.reloadCurrentSession(),i.autoCreateSession&&!t.getSessionId()&&t.startNewSession(),i.widget.showHistoryButton&&t.chatHistorySection){var s=document.querySelector(i.widget.showHistoryButton);if(s&&s.addEventListener("click",function(){t.chatHistorySection.classList.toggle("show")}),i.widget.closeHistoryButton){var l=document.querySelector(i.widget.closeHistoryButton);l&&l.addEventListener("click",function(){t.showChatScreen()})}}if(i.widget.newChatButton){var r=document.querySelector(i.widget.newChatButton);r&&r.addEventListener("click",function(){t.resetSession(),t.showChatScreen()})}}}else console.error("The widget chatWidgetStateName is required.");else console.error("The widget chatWidgetContainer is required.")}function i(e){e&&(e.widgetResizeObserver&&(e.widgetResizeObserver.disconnect(),e.widgetResizeObserver=null),e.widgetViewportResizeHandler&&(window.removeEventListener("resize",e.widgetViewportResizeHandler),e.widgetViewportResizeHandler=null))}return{attach:function(t,i){t&&!t.__aiChatWidgetAttached&&(t.__aiChatWidgetAttached=!0,t.chatWidgetStateName=null,t.chatWidgetStateSession=null,t.chatWidgetStateDocuments=null,t.chatWidgetLayoutKey=null,t.chatHistorySection=null,t.widgetContainerElement=null,t.widgetToggleButtonElement=null,t.widgetResetSizeButtonElement=null,t.widgetResizeObserver=null,t.widgetViewportResizeHandler=null,t.widgetDefaultWidth=null,t.widgetDefaultHeight=null,t.widgetIsInitialized=!1,t.getStoredWidgetLayout=function(){if(!this.chatWidgetLayoutKey||!i.widget.persistLayout)return{};try{var e=localStorage.getItem(this.chatWidgetLayoutKey);return e&&JSON.parse(e)||{}}catch(e){return console.warn("Failed to read widget layout state.",e),{}}},t.saveStoredWidgetLayout=function(e){if(this.chatWidgetLayoutKey&&i.widget.persistLayout){var t=this.getStoredWidgetLayout(),n=Object.assign({},t);void 0!==e.panel&&(n.panel=Object.assign({},t.panel||{},e.panel||{})),void 0!==e.position&&(n.position=Object.assign({},t.position||{},e.position||{})),localStorage.setItem(this.chatWidgetLayoutKey,JSON.stringify(n))}},t.getElementSize=function(t,i,n){if(!t)return{width:i||0,height:n||0};var o=t.getBoundingClientRect(),a=window.getComputedStyle(t);return{width:Math.round(o.width||e(a.width)||i||0),height:Math.round(o.height||e(a.height)||n||0)}},t.getElementPosition=function(t){if(!t)return{left:0,top:0};var i=t.getBoundingClientRect(),n=window.getComputedStyle(t),o=e(t.style.left),a=e(t.style.top),s=e(n.left),l=e(n.top),r="none"===n.display;return{left:Math.round(r&&Number.isFinite(o)?o:i.left||o||s||0),top:Math.round(r&&Number.isFinite(a)?a:i.top||a||l||0)}},t.getAvailableWidgetPositionRange=function(e,t){return{padding:8,maxLeft:Math.max(8,window.innerWidth-e-8),maxTop:Math.max(8,window.innerHeight-t-8)}},t.createStoredPosition=function(e,t,i,n){var o=this.getAvailableWidgetPositionRange(i,n),a=Math.max(0,o.maxLeft-o.padding),s=Math.max(0,o.maxTop-o.padding);return{left:Math.round(e),top:Math.round(t),leftRatio:0===a?0:(e-o.padding)/a,topRatio:0===s?0:(t-o.padding)/s}},t.resolveStoredPosition=function(e,t,i){if(!e)return null;var n=this.getAvailableWidgetPositionRange(t,i),o=Number(e.left),a=Number(e.top),s=Number(e.leftRatio),l=Number(e.topRatio);return Number.isFinite(s)&&(o=n.padding+Math.max(0,n.maxLeft-n.padding)*s),Number.isFinite(l)&&(a=n.padding+Math.max(0,n.maxTop-n.padding)*l),Number.isFinite(o)&&Number.isFinite(a)?this.clampWidgetPosition(o,a,t,i):null},t.clampWidgetPosition=function(e,t,i,n){var o=this.getAvailableWidgetPositionRange(i,n);return{left:Math.round(clampWidgetValue(e,o.padding,o.maxLeft)),top:Math.round(clampWidgetValue(t,o.padding,o.maxTop))}},t.getStoredWidgetDocuments=function(){return this.clearStoredWidgetDocuments(),[]},t.saveStoredWidgetDocuments=function(){this.clearStoredWidgetDocuments()},t.clearStoredWidgetDocuments=function(){this.chatWidgetStateDocuments&&localStorage.removeItem(this.chatWidgetStateDocuments)},t.applyAbsolutePosition=function(e,t,i){e&&(e.style.left=t+"px",e.style.top=i+"px",e.style.right="auto",e.style.bottom="auto")},t.getWidgetDefaultSize=function(){return{width:this.widgetDefaultWidth||e(i.widget.defaultWidth)||380,height:this.widgetDefaultHeight||e(i.widget.defaultHeight)||520}},t.getWidgetToggleGap=function(){return 8},t.isWidgetPanelVisible=function(){if(!this.widgetContainerElement)return!1;var e=window.getComputedStyle(this.widgetContainerElement);return this.widgetContainerElement.classList.contains("open")&&"none"!==e.display},t.persistWidgetPanelPosition=function(){if(this.widgetContainerElement&&i.widget.persistLayout){var e=this.getWidgetDefaultSize(),t=this.getElementPosition(this.widgetContainerElement),n=this.getElementSize(this.widgetContainerElement,e.width,e.height),o=this.getElementSize(this.widgetToggleButtonElement,52,52),a=this.clampWidgetPosition(t.left+n.width-o.width,t.top+n.height+this.getWidgetToggleGap(),o.width,o.height);this.saveStoredWidgetLayout({position:this.createStoredPosition(a.left,a.top,o.width,o.height)})}},t.persistWidgetTogglePosition=function(){if(this.widgetToggleButtonElement&&i.widget.persistLayout){var e=this.getElementPosition(this.widgetToggleButtonElement),t=this.getElementSize(this.widgetToggleButtonElement,52,52);this.saveStoredWidgetLayout({position:this.createStoredPosition(e.left,e.top,t.width,t.height)})}},t.persistWidgetPanelSize=function(){if(this.widgetContainerElement&&i.widget.enableResizing&&i.widget.persistLayout){var e=this.getWidgetDefaultSize(),t=this.getElementSize(this.widgetContainerElement,e.width,e.height);this.saveStoredWidgetLayout({panel:{width:Math.abs(t.width-e.width)<=1?null:t.width,height:Math.abs(t.height-e.height)<=1?null:t.height}})}},t.syncTogglePositionToPanel=function(e){if(void 0===e&&(e=!0),this.widgetContainerElement&&this.widgetToggleButtonElement){var t=this.getWidgetDefaultSize(),n=this.getElementSize(this.widgetContainerElement,t.width,t.height),o=this.getElementSize(this.widgetToggleButtonElement,52,52),a=this.getElementPosition(this.widgetContainerElement),s=this.clampWidgetPosition(a.left+n.width-o.width,a.top+n.height+this.getWidgetToggleGap(),o.width,o.height);this.applyAbsolutePosition(this.widgetToggleButtonElement,s.left,s.top),e&&i.widget.persistLayout&&this.persistWidgetTogglePosition()}},t.syncPanelPositionToToggle=function(e){if(void 0===e&&(e=!0),this.widgetContainerElement&&this.widgetToggleButtonElement){var t=this.getWidgetDefaultSize(),n=this.getElementSize(this.widgetContainerElement,t.width,t.height),o=this.getElementSize(this.widgetToggleButtonElement,52,52),a=this.getElementPosition(this.widgetToggleButtonElement),s=this.clampWidgetPosition(a.left+o.width-n.width,a.top-n.height-this.getWidgetToggleGap(),n.width,n.height);this.applyAbsolutePosition(this.widgetContainerElement,s.left,s.top),e&&i.widget.persistLayout&&this.persistWidgetPanelPosition()}},t.updateWidgetResetSizeButtonVisibility=function(){if(this.widgetResetSizeButtonElement)if(i.widget.enableResizing&&this.widgetContainerElement){var e=this.getWidgetDefaultSize(),t=this.getElementSize(this.widgetContainerElement,e.width,e.height),n=Math.abs(t.width-e.width)>1||Math.abs(t.height-e.height)>1||!!this.widgetContainerElement.style.width||!!this.widgetContainerElement.style.height;this.widgetResetSizeButtonElement.classList.toggle("d-none",!n)}else this.widgetResetSizeButtonElement.classList.add("d-none")},t.resetWidgetSize=function(){this.widgetContainerElement&&i.widget.enableResizing&&(this.widgetContainerElement.style.removeProperty("width"),this.widgetContainerElement.style.removeProperty("height"),this.persistWidgetPanelSize(),this.constrainWidgetElementsToViewport(),this.updateWidgetResetSizeButtonVisibility())},t.restoreWidgetLayout=function(){var e=this.getStoredWidgetLayout();this.widgetContainerElement&&i.widget.enableResizing&&(Number.isFinite(e.panel&&e.panel.width)?this.widgetContainerElement.style.width=e.panel.width+"px":this.widgetContainerElement.style.removeProperty("width"),Number.isFinite(e.panel&&e.panel.height)?this.widgetContainerElement.style.height=e.panel.height+"px":this.widgetContainerElement.style.removeProperty("height"));var t=this.getElementSize(this.widgetToggleButtonElement,52,52),n=this.resolveStoredPosition(e.position,t.width,t.height);this.widgetToggleButtonElement&&i.widget.enableDragging&&n?(this.applyAbsolutePosition(this.widgetToggleButtonElement,n.left,n.top),this.syncPanelPositionToToggle(!1)):this.widgetToggleButtonElement&&i.widget.enableDragging&&Number.isFinite(e.toggle&&e.toggle.left)&&Number.isFinite(e.toggle&&e.toggle.top)?(this.applyAbsolutePosition(this.widgetToggleButtonElement,e.toggle.left,e.toggle.top),this.syncPanelPositionToToggle(!1)):this.widgetContainerElement&&i.widget.enableDragging&&Number.isFinite(e.panel&&e.panel.left)&&Number.isFinite(e.panel&&e.panel.top)&&(this.applyAbsolutePosition(this.widgetContainerElement,e.panel.left,e.panel.top),this.syncTogglePositionToPanel(!1)),this.constrainWidgetElementsToViewport(),this.updateWidgetResetSizeButtonVisibility()},t.attachDraggableWidgetElement=function(e,t,n,o){if(e&&t&&i.widget.enableDragging){var a=null,s=0,l=0,r=0,d=0,g=!1,c=this;t.addEventListener("pointerdown",function(i){if(0===i.button&&("panel"!==n||!i.target.closest("button, a, input, textarea, select, option, label"))){var o=e.getBoundingClientRect();s=i.clientX,l=i.clientY,r=o.left,d=o.top,g=!1,a=i.pointerId,e.classList.add("ai-chat-widget-dragging"),t.setPointerCapture&&t.setPointerCapture(i.pointerId),document.addEventListener("pointermove",h),document.addEventListener("pointerup",u),document.addEventListener("pointercancel",u),i.preventDefault()}})}function u(t){null!==a&&(t&&void 0!==t.pointerId&&t.pointerId!==a||(document.removeEventListener("pointermove",h),document.removeEventListener("pointerup",u),document.removeEventListener("pointercancel",u),e.classList.remove("ai-chat-widget-dragging"),a=null,g&&("panel"===n?(c.syncTogglePositionToPanel(!1),c.persistWidgetPanelPosition()):"toggle"===n&&(c.syncPanelPositionToToggle(!1),c.persistWidgetTogglePosition()),i.widget.persistLayout&&(c.persistWidgetPanelPosition(),c.persistWidgetTogglePosition()),o&&(e.dataset.dragSuppressClick="true",window.setTimeout(function(){"true"===e.dataset.dragSuppressClick&&(e.dataset.dragSuppressClick="false")},0)))))}function h(t){if(null!==a&&t.pointerId===a){var i=t.clientX-s,o=t.clientY-l;if(g||!(Math.hypot(i,o)<4)){g=!0;var u=c.getWidgetDefaultSize(),h=c.getElementSize(e,"panel"===n?u.width:52,"panel"===n?u.height:52),w=c.clampWidgetPosition(r+i,d+o,h.width,h.height);c.applyAbsolutePosition(e,w.left,w.top),"panel"===n?c.syncTogglePositionToPanel(!1):"toggle"===n&&c.syncPanelPositionToToggle(!1)}}}},t.constrainWidgetElementsToViewport=function(){if(this.widgetContainerElement&&this.widgetContainerElement.style.left&&this.isWidgetPanelVisible()){var e=this.getWidgetDefaultSize(),t=this.getElementSize(this.widgetContainerElement,e.width,e.height),n=this.getElementPosition(this.widgetContainerElement),o=this.clampWidgetPosition(n.left,n.top,t.width,t.height);this.applyAbsolutePosition(this.widgetContainerElement,o.left,o.top),this.syncTogglePositionToPanel(!1),i.widget.persistLayout&&(this.persistWidgetPanelPosition(),this.persistWidgetTogglePosition())}else if(this.widgetToggleButtonElement&&this.widgetToggleButtonElement.style.left){var a=this.getElementSize(this.widgetToggleButtonElement,52,52),s=this.getElementPosition(this.widgetToggleButtonElement),l=this.clampWidgetPosition(s.left,s.top,a.width,a.height);this.applyAbsolutePosition(this.widgetToggleButtonElement,l.left,l.top),this.syncPanelPositionToToggle(!1),i.widget.persistLayout&&(this.persistWidgetTogglePosition(),this.persistWidgetPanelPosition())}},t.showChatScreen=function(){this.chatHistorySection&&this.chatHistorySection.classList.remove("show")})},initialize:t,onMounted:t,resolveSessionId:function(e){return e&&e.widgetIsInitialized?localStorage.getItem(e.chatWidgetStateSession):null},onSessionInitialized:function(e,t){e&&e.widgetIsInitialized&&localStorage.setItem(e.chatWidgetStateSession,t)},onSessionReset:function(e){e&&e.widgetIsInitialized&&(localStorage.removeItem(e.chatWidgetStateSession),e.clearStoredWidgetDocuments())},onDocumentsChanged:function(e,t){e&&e.widgetIsInitialized&&e.saveStoredWidgetDocuments(t)},handleReceiveError:function(e){e&&e.widgetIsInitialized&&!e.isSessionStarted&&!e._attemptedSessionRecovery&&(e._attemptedSessionRecovery=!0,localStorage.removeItem(e.chatWidgetStateSession),e.clearStoredWidgetDocuments(),e.startNewSession())},dispose:i,onBeforeUnmount:i}}(),window.coreAIChatWidgetManager=window.coreAIChatWidgetManager||function(){function e(e,t){var i=e.getAttribute(t);return null===i||""===i?null:i}function t(e){if(null==e)return null;if("boolean"==typeof e)return e;var t=String(e).trim().toLowerCase();return"true"===t||"false"!==t&&null}function i(t,i,n){var o=e(t,i);if(!o)return null;try{return JSON.parse(o)}catch(e){return console.error("Failed to parse "+n+" JSON.",e),null}}function n(e){if(!e)return null;var t=e.chatConfig;if(!t&&e.configElementSelector){var n=document.querySelector(e.configElementSelector);t=n?i(n,"data-config","AI chat widget config"):null}if(!t)return null;if(e.messageTemplateSelector){var o=document.querySelector(e.messageTemplateSelector);o&&(t.messageTemplate=o.innerHTML)}if(e.indicatorTemplateSelector){var a=document.querySelector(e.indicatorTemplateSelector);a&&(t.indicatorTemplate=a.innerHTML)}var s=document.querySelector(e.shellSelector),l=document.querySelector(e.widgetContainerSelector),r=document.querySelector(e.toggleButtonSelector),d=document.querySelector(e.closeButtonSelector),g=e.inputSelector?document.querySelector(e.inputSelector):null,c=e.widgetStateName||t.widget.chatWidgetStateName,u=e.widgetOpenStateKey||c+"Open",h=c+"Layout",w=e.openStateValue||"open",m=e.closedStateValue||"closed";g&&e.profile&&e.profile.id&&g.setAttribute("data-profile-id",e.profile.id);try{var p=localStorage.getItem(h),f=p&&JSON.parse(p)||{},S=f.position||{},y=f.panel||{},v=Number(S.left),b=Number(S.top),W=localStorage.getItem(u)===w;if(s&&(s.dataset.deferReveal=W?"true":"false",s.dataset.initialOpen=W?"true":"false"),l&&r){var E=Number.isFinite(Number(y.width))?Number(y.width):Math.round(parseFloat(window.getComputedStyle(l).width)||380),P=Number.isFinite(Number(y.height))?Number(y.height):Math.round(parseFloat(window.getComputedStyle(l).height)||520),T=Math.max(8,window.innerWidth-52-8),C=Math.max(8,window.innerHeight-52-8);if(Number.isFinite(Number(S.leftRatio))&&(v=8+Math.max(0,T-8)*Number(S.leftRatio)),Number.isFinite(Number(S.topRatio))&&(b=8+Math.max(0,C-8)*Number(S.topRatio)),Number.isFinite(v)&&Number.isFinite(b)&&(v=Math.round(clampWidgetValue(v,8,T)),b=Math.round(clampWidgetValue(b,8,C))),Number.isFinite(v)&&Number.isFinite(b)){r.style.left=v+"px",r.style.top=b+"px",r.style.right="auto",r.style.bottom="auto";l.style.left=v+52-E+"px",l.style.top=b-P-8+"px",l.style.right="auto",l.style.bottom="auto"}}l&&(l.classList.remove("open"),l.style.display="none",l.setAttribute("aria-hidden","true")),r&&(r.innerHTML=W?e.openIconHtml:e.closedIconHtml)}catch(e){console.warn("Failed to restore widget layout before initialization.",e)}finally{s&&"true"!==s.dataset.deferReveal&&(s.style.visibility="")}var z=window.coreAIChatManager.initialize(t);function L(){s&&(s.style.visibility="",s.dataset.deferReveal="false")}function B(){z&&"function"==typeof z.syncPanelPositionToToggle&&z.syncPanelPositionToToggle(!1)}function R(){l&&l.querySelectorAll("[data-tts-message-index]").forEach(function(e){var t=Number(e.getAttribute("data-tts-message-index"))===z.ttsPlayingMessageIndex;e.classList.toggle("tts-playing",t),e.setAttribute("title",t?"Pause audio":"Read aloud")})}function I(){requestAnimationFrame(R)}function N(t){if(z){var i=l.classList.contains("open");t&&!i&&"function"==typeof z.syncPanelPositionToToggle?z.syncPanelPositionToToggle():!t&&i&&"function"==typeof z.syncTogglePositionToPanel&&z.syncTogglePositionToPanel()}l.classList.toggle("open",t),l.style.display=t?"flex":"none",l.setAttribute("aria-hidden",t?"false":"true"),r.innerHTML=t?e.openIconHtml:e.closedIconHtml,localStorage.setItem(u,t?w:m),t&&"function"==typeof window.renderPendingCharts&&setTimeout(function(){window.renderPendingCharts()},100)}!1!==e.applySessionProfilePatch&&window.crestAppsAIChat&&window.crestAppsAIChat.patchSessionProfileSync&&window.crestAppsAIChat.patchSessionProfileSync(z);var M=s&&"true"===s.dataset.initialOpen;return N(M),function(e){if(s&&"true"===s.dataset.deferReveal&&e){var t=!1,i=null;if("undefined"!=typeof ResizeObserver){var n=0,o=0,a=0;(i=new ResizeObserver(function(e){var t=e&&e[0];if(t){var i=Math.round(t.contentRect.width),s=Math.round(t.contentRect.height);i&&s&&(B(),i===n&&s===o?a++:(n=i,o=s,a=0),a>=1&&r())}})).observe(l),window.setTimeout(r,150)}else window.setTimeout(r,0)}else L();function r(){t||(t=!0,i&&i.disconnect(),requestAnimationFrame(function(){B(),requestAnimationFrame(function(){L()})}))}}(M),z&&"function"==typeof z.$watch&&z.$watch("ttsPlayingMessageIndex",function(){I()}),I(),r&&r.addEventListener("click",function(){"true"!==r.dataset.dragSuppressClick?N(!l.classList.contains("open")):r.dataset.dragSuppressClick="false"}),d&&d.addEventListener("click",function(){N(!1)}),z}function o(o){if(!o||"true"===o.dataset.coreAiChatWidgetInitialized)return o&&o.__coreAIChatWidgetApp||null;var a=i(o,"data-coreai-chat-widget-config","CoreAI chat widget config"),s=function(i){var n=e(i,"data-coreai-chat-widget-container-selector");if(!n)return null;var o=null;window.coreAIChatManager&&"function"==typeof window.coreAIChatManager.buildConfigFromElement&&(o=window.coreAIChatManager.buildConfigFromElement(i,{allowWidgetHost:!0}));var a=e(i,"data-coreai-chat-widget-profile-id"),s=e(i,"data-coreai-chat-widget-profile-name"),l=e(i,"data-coreai-chat-widget-profile-display-text"),r=e(i,"data-coreai-chat-widget-profile-welcome-message"),d=e(i,"data-coreai-chat-widget-profile-chat-mode"),g=e(i,"data-coreai-chat-widget-profile-tts-voice-name"),c=t(e(i,"data-coreai-chat-widget-profile-enable-session-metrics")),u=t(e(i,"data-coreai-chat-widget-profile-allow-session-documents")),h=null;(a||s||l||r||d||g||null!==c||null!==u)&&(h={id:a,name:s,displayText:l,welcomeMessage:r,chatMode:d,ttsVoiceName:g,enableSessionMetrics:!0===c,allowSessionDocuments:!0===u});var w=t(e(i,"data-coreai-chat-widget-enable-dragging")),m=t(e(i,"data-coreai-chat-widget-enable-resizing")),p=t(e(i,"data-coreai-chat-widget-persist-layout"));return{shellSelector:e(i,"data-coreai-chat-widget-shell-selector"),widgetContainerSelector:n,toggleButtonSelector:e(i,"data-coreai-chat-widget-toggle-button-selector"),closeButtonSelector:e(i,"data-coreai-chat-widget-close-button-selector"),inputSelector:e(i,"data-coreai-chat-widget-input-selector"),profile:h,widgetStateName:e(i,"data-coreai-chat-widget-state-name"),openStateValue:e(i,"data-coreai-chat-widget-open-state-value"),closedStateValue:e(i,"data-coreai-chat-widget-closed-state-value"),openIconHtml:e(i,"data-coreai-chat-widget-open-icon-html"),closedIconHtml:e(i,"data-coreai-chat-widget-closed-icon-html"),chatConfig:o?Object.assign({},o,{widget:Object.assign({},o.widget||{},{chatWidgetContainer:n,chatWidgetStateName:e(i,"data-coreai-chat-widget-state-name"),newChatButton:e(i,"data-coreai-chat-widget-new-chat-button-selector"),toggleButtonSelector:e(i,"data-coreai-chat-widget-toggle-button-selector"),resetSizeButtonSelector:e(i,"data-coreai-chat-widget-reset-size-button-selector"),dragHandleSelector:e(i,"data-coreai-chat-widget-drag-handle-selector"),enableDragging:null===w?void 0:w,enableResizing:null===m?void 0:m,persistLayout:null===p?void 0:p})}):null}}(o);if(!a&&!s)return null;var l=n(Object.assign({},a||{},s||{}));return l?(o.dataset.coreAiChatWidgetInitialized="true",o.__coreAIChatWidgetApp=l,l):null}function a(e){e&&"function"==typeof e.querySelectorAll&&("function"==typeof e.matches&&e.matches("[data-coreai-chat-widget-config],[data-coreai-chat-widget-container-selector]")&&o(e),e.querySelectorAll("[data-coreai-chat-widget-config],[data-coreai-chat-widget-container-selector]").forEach(o))}function s(){(a(document),"undefined"!=typeof MutationObserver)&&new MutationObserver(function(e){e.forEach(function(e){e.addedNodes.forEach(function(e){e&&1===e.nodeType&&a(e)})})}).observe(document.body,{childList:!0,subtree:!0})}return"loading"===document.readyState?document.addEventListener("DOMContentLoaded",s,{once:!0}):s(),{initialize:n,initializeFromElement:o}}();
|
|
1
|
+
function clampWidgetValue(e,t,i){return Math.min(Math.max(e,t),i)}window.coreAIChatWidgetBehavior=window.coreAIChatWidgetBehavior||function(){function e(e){if("number"==typeof e&&Number.isFinite(e))return e;if("string"!=typeof e)return null;var t=parseFloat(e);return Number.isFinite(t)?t:null}function t(t,i){if(t&&!t.widgetIsInitialized)if(i.widget.chatWidgetContainer)if(i.widget.chatWidgetStateName){var n=document.querySelector(i.widget.chatWidgetContainer);if(n){i.widget.chatHistorySection&&(t.chatHistorySection=document.querySelector(i.widget.chatHistorySection)),t.chatWidgetStateName=i.widget.chatWidgetStateName,t.chatWidgetStateSession=i.widget.chatWidgetStateName+"Session",t.chatWidgetStateDocuments=i.widget.chatWidgetStateName+"Documents",t.chatWidgetLayoutKey=i.widget.chatWidgetStateName+"Layout",t.widgetContainerElement=n,t.widgetToggleButtonElement=i.widget.toggleButtonSelector?document.querySelector(i.widget.toggleButtonSelector):null,t.widgetResetSizeButtonElement=i.widget.resetSizeButtonSelector?document.querySelector(i.widget.resetSizeButtonSelector):null,t.widgetDefaultWidth=e(i.widget.defaultWidth)||e(window.getComputedStyle(n).width)||380,t.widgetDefaultHeight=e(i.widget.defaultHeight)||e(window.getComputedStyle(n).height)||520,t.widgetIsInitialized=!0,t.clearStoredWidgetDocuments(),t.documents=[],i.widget.enableResizing&&(n.classList.add("ai-chat-widget-resizable"),n.style.minWidth=(e(i.widget.minWidth)||320)+"px",n.style.minHeight=(e(i.widget.minHeight)||420)+"px","undefined"!=typeof ResizeObserver&&(t.widgetResizeObserver=new ResizeObserver(function(){t.persistWidgetPanelSize(),t.constrainWidgetElementsToViewport(),t.updateWidgetResetSizeButtonVisibility()}),t.widgetResizeObserver.observe(n)));var o=i.widget.dragHandleSelector||".ai-chat-widget-header",a=n.querySelector(o);if(i.widget.enableDragging&&a&&(a.classList.add("ai-chat-widget-drag-handle"),n.classList.add("ai-chat-widget-draggable"),t.attachDraggableWidgetElement(n,a,"panel",!1)),i.widget.enableDragging&&t.widgetToggleButtonElement&&(t.widgetToggleButtonElement.classList.add("ai-chat-widget-draggable"),t.attachDraggableWidgetElement(t.widgetToggleButtonElement,t.widgetToggleButtonElement,"toggle",!0)),t.widgetResetSizeButtonElement&&t.widgetResetSizeButtonElement.addEventListener("click",function(e){e.preventDefault(),t.resetWidgetSize()}),t.restoreWidgetLayout(),t.widgetViewportResizeHandler||(t.widgetViewportResizeHandler=function(){i.widget.persistLayout?t.restoreWidgetLayout():t.constrainWidgetElementsToViewport(),t.updateWidgetResetSizeButtonVisibility()},window.addEventListener("resize",t.widgetViewportResizeHandler)),t.reloadCurrentSession(),i.autoCreateSession&&!t.getSessionId()&&t.startNewSession(),i.widget.showHistoryButton&&t.chatHistorySection){var s=document.querySelector(i.widget.showHistoryButton);if(s&&s.addEventListener("click",function(){t.chatHistorySection.classList.toggle("show")}),i.widget.closeHistoryButton){var l=document.querySelector(i.widget.closeHistoryButton);l&&l.addEventListener("click",function(){t.showChatScreen()})}}if(i.widget.newChatButton){var r=document.querySelector(i.widget.newChatButton);r&&r.addEventListener("click",function(){t.resetSession(),t.showChatScreen()})}}}else console.error("The widget chatWidgetStateName is required.");else console.error("The widget chatWidgetContainer is required.")}function i(e){e&&(e.widgetResizeObserver&&(e.widgetResizeObserver.disconnect(),e.widgetResizeObserver=null),e.widgetViewportResizeHandler&&(window.removeEventListener("resize",e.widgetViewportResizeHandler),e.widgetViewportResizeHandler=null))}return{attach:function(t,i){t&&!t.__aiChatWidgetAttached&&(t.__aiChatWidgetAttached=!0,t.chatWidgetStateName=null,t.chatWidgetStateSession=null,t.chatWidgetStateDocuments=null,t.chatWidgetLayoutKey=null,t.chatHistorySection=null,t.widgetContainerElement=null,t.widgetToggleButtonElement=null,t.widgetResetSizeButtonElement=null,t.widgetResizeObserver=null,t.widgetViewportResizeHandler=null,t.widgetDefaultWidth=null,t.widgetDefaultHeight=null,t.widgetIsInitialized=!1,t.getStoredWidgetLayout=function(){if(!this.chatWidgetLayoutKey||!i.widget.persistLayout)return{};try{var e=localStorage.getItem(this.chatWidgetLayoutKey);return e&&JSON.parse(e)||{}}catch(e){return console.warn("Failed to read widget layout state.",e),{}}},t.saveStoredWidgetLayout=function(e){if(this.chatWidgetLayoutKey&&i.widget.persistLayout){var t=this.getStoredWidgetLayout(),n=Object.assign({},t);void 0!==e.panel&&(n.panel=Object.assign({},t.panel||{},e.panel||{})),void 0!==e.position&&(n.position=Object.assign({},t.position||{},e.position||{})),localStorage.setItem(this.chatWidgetLayoutKey,JSON.stringify(n))}},t.getElementSize=function(t,i,n){if(!t)return{width:i||0,height:n||0};var o=t.getBoundingClientRect(),a=window.getComputedStyle(t);return{width:Math.round(o.width||e(a.width)||i||0),height:Math.round(o.height||e(a.height)||n||0)}},t.getElementPosition=function(t){if(!t)return{left:0,top:0};var i=t.getBoundingClientRect(),n=window.getComputedStyle(t),o=e(t.style.left),a=e(t.style.top),s=e(n.left),l=e(n.top),r="none"===n.display;return{left:Math.round(r&&Number.isFinite(o)?o:i.left||o||s||0),top:Math.round(r&&Number.isFinite(a)?a:i.top||a||l||0)}},t.getAvailableWidgetPositionRange=function(e,t){return{padding:8,maxLeft:Math.max(8,window.innerWidth-e-8),maxTop:Math.max(8,window.innerHeight-t-8)}},t.createStoredPosition=function(e,t,i,n){var o=this.getAvailableWidgetPositionRange(i,n),a=Math.max(0,o.maxLeft-o.padding),s=Math.max(0,o.maxTop-o.padding);return{left:Math.round(e),top:Math.round(t),leftRatio:0===a?0:(e-o.padding)/a,topRatio:0===s?0:(t-o.padding)/s}},t.resolveStoredPosition=function(e,t,i){if(!e)return null;var n=this.getAvailableWidgetPositionRange(t,i),o=Number(e.left),a=Number(e.top),s=Number(e.leftRatio),l=Number(e.topRatio);return Number.isFinite(s)&&(o=n.padding+Math.max(0,n.maxLeft-n.padding)*s),Number.isFinite(l)&&(a=n.padding+Math.max(0,n.maxTop-n.padding)*l),Number.isFinite(o)&&Number.isFinite(a)?this.clampWidgetPosition(o,a,t,i):null},t.clampWidgetPosition=function(e,t,i,n){var o=this.getAvailableWidgetPositionRange(i,n);return{left:Math.round(clampWidgetValue(e,o.padding,o.maxLeft)),top:Math.round(clampWidgetValue(t,o.padding,o.maxTop))}},t.getStoredWidgetDocuments=function(){return this.clearStoredWidgetDocuments(),[]},t.saveStoredWidgetDocuments=function(){this.clearStoredWidgetDocuments()},t.clearStoredWidgetDocuments=function(){this.chatWidgetStateDocuments&&localStorage.removeItem(this.chatWidgetStateDocuments)},t.applyAbsolutePosition=function(e,t,i){e&&(e.style.left=t+"px",e.style.top=i+"px",e.style.right="auto",e.style.bottom="auto")},t.getWidgetDefaultSize=function(){return{width:this.widgetDefaultWidth||e(i.widget.defaultWidth)||380,height:this.widgetDefaultHeight||e(i.widget.defaultHeight)||520}},t.getWidgetToggleGap=function(){return 8},t.isWidgetPanelVisible=function(){if(!this.widgetContainerElement)return!1;var e=window.getComputedStyle(this.widgetContainerElement);return this.widgetContainerElement.classList.contains("open")&&"none"!==e.display},t.persistWidgetPanelPosition=function(){if(this.widgetContainerElement&&i.widget.persistLayout){var e=this.getWidgetDefaultSize(),t=this.getElementPosition(this.widgetContainerElement),n=this.getElementSize(this.widgetContainerElement,e.width,e.height),o=this.getElementSize(this.widgetToggleButtonElement,52,52),a=this.clampWidgetPosition(t.left+n.width-o.width,t.top+n.height+this.getWidgetToggleGap(),o.width,o.height);this.saveStoredWidgetLayout({position:this.createStoredPosition(a.left,a.top,o.width,o.height)})}},t.persistWidgetTogglePosition=function(){if(this.widgetToggleButtonElement&&i.widget.persistLayout){var e=this.getElementPosition(this.widgetToggleButtonElement),t=this.getElementSize(this.widgetToggleButtonElement,52,52);this.saveStoredWidgetLayout({position:this.createStoredPosition(e.left,e.top,t.width,t.height)})}},t.persistWidgetPanelSize=function(){if(this.widgetContainerElement&&i.widget.enableResizing&&i.widget.persistLayout){var e=this.getWidgetDefaultSize(),t=this.getElementSize(this.widgetContainerElement,e.width,e.height);this.saveStoredWidgetLayout({panel:{width:Math.abs(t.width-e.width)<=1?null:t.width,height:Math.abs(t.height-e.height)<=1?null:t.height}})}},t.syncTogglePositionToPanel=function(e){if(void 0===e&&(e=!0),this.widgetContainerElement&&this.widgetToggleButtonElement){var t=this.getWidgetDefaultSize(),n=this.getElementSize(this.widgetContainerElement,t.width,t.height),o=this.getElementSize(this.widgetToggleButtonElement,52,52),a=this.getElementPosition(this.widgetContainerElement),s=this.clampWidgetPosition(a.left+n.width-o.width,a.top+n.height+this.getWidgetToggleGap(),o.width,o.height);this.applyAbsolutePosition(this.widgetToggleButtonElement,s.left,s.top),e&&i.widget.persistLayout&&this.persistWidgetTogglePosition()}},t.syncPanelPositionToToggle=function(e){if(void 0===e&&(e=!0),this.widgetContainerElement&&this.widgetToggleButtonElement){var t=this.getWidgetDefaultSize(),n=this.getElementSize(this.widgetContainerElement,t.width,t.height),o=this.getElementSize(this.widgetToggleButtonElement,52,52),a=this.getElementPosition(this.widgetToggleButtonElement),s=this.clampWidgetPosition(a.left+o.width-n.width,a.top-n.height-this.getWidgetToggleGap(),n.width,n.height);this.applyAbsolutePosition(this.widgetContainerElement,s.left,s.top),e&&i.widget.persistLayout&&this.persistWidgetPanelPosition()}},t.updateWidgetResetSizeButtonVisibility=function(){if(this.widgetResetSizeButtonElement)if(i.widget.enableResizing&&this.widgetContainerElement){var e=this.getWidgetDefaultSize(),t=this.getElementSize(this.widgetContainerElement,e.width,e.height),n=Math.abs(t.width-e.width)>1||Math.abs(t.height-e.height)>1||!!this.widgetContainerElement.style.width||!!this.widgetContainerElement.style.height;this.widgetResetSizeButtonElement.classList.toggle("d-none",!n)}else this.widgetResetSizeButtonElement.classList.add("d-none")},t.resetWidgetSize=function(){this.widgetContainerElement&&i.widget.enableResizing&&(this.widgetContainerElement.style.removeProperty("width"),this.widgetContainerElement.style.removeProperty("height"),this.persistWidgetPanelSize(),this.constrainWidgetElementsToViewport(),this.updateWidgetResetSizeButtonVisibility())},t.restoreWidgetLayout=function(){var e=this.getStoredWidgetLayout();this.widgetContainerElement&&i.widget.enableResizing&&(Number.isFinite(e.panel&&e.panel.width)?this.widgetContainerElement.style.width=e.panel.width+"px":this.widgetContainerElement.style.removeProperty("width"),Number.isFinite(e.panel&&e.panel.height)?this.widgetContainerElement.style.height=e.panel.height+"px":this.widgetContainerElement.style.removeProperty("height"));var t=this.getElementSize(this.widgetToggleButtonElement,52,52),n=this.resolveStoredPosition(e.position,t.width,t.height);this.widgetToggleButtonElement&&i.widget.enableDragging&&n?(this.applyAbsolutePosition(this.widgetToggleButtonElement,n.left,n.top),this.syncPanelPositionToToggle(!1)):this.widgetToggleButtonElement&&i.widget.enableDragging&&Number.isFinite(e.toggle&&e.toggle.left)&&Number.isFinite(e.toggle&&e.toggle.top)?(this.applyAbsolutePosition(this.widgetToggleButtonElement,e.toggle.left,e.toggle.top),this.syncPanelPositionToToggle(!1)):this.widgetContainerElement&&i.widget.enableDragging&&Number.isFinite(e.panel&&e.panel.left)&&Number.isFinite(e.panel&&e.panel.top)&&(this.applyAbsolutePosition(this.widgetContainerElement,e.panel.left,e.panel.top),this.syncTogglePositionToPanel(!1)),this.constrainWidgetElementsToViewport(),this.updateWidgetResetSizeButtonVisibility()},t.attachDraggableWidgetElement=function(e,t,n,o){if(e&&t&&i.widget.enableDragging){var a=null,s=0,l=0,r=0,d=0,g=!1,c=this;t.addEventListener("pointerdown",function(i){if(0===i.button&&("panel"!==n||!i.target.closest("button, a, input, textarea, select, option, label"))){var o=e.getBoundingClientRect();s=i.clientX,l=i.clientY,r=o.left,d=o.top,g=!1,a=i.pointerId,e.classList.add("ai-chat-widget-dragging"),t.setPointerCapture&&t.setPointerCapture(i.pointerId),document.addEventListener("pointermove",h),document.addEventListener("pointerup",u),document.addEventListener("pointercancel",u),i.preventDefault()}})}function u(t){null!==a&&(t&&void 0!==t.pointerId&&t.pointerId!==a||(document.removeEventListener("pointermove",h),document.removeEventListener("pointerup",u),document.removeEventListener("pointercancel",u),e.classList.remove("ai-chat-widget-dragging"),a=null,g&&("panel"===n?(c.syncTogglePositionToPanel(!1),c.persistWidgetPanelPosition()):"toggle"===n&&(c.syncPanelPositionToToggle(!1),c.persistWidgetTogglePosition()),i.widget.persistLayout&&(c.persistWidgetPanelPosition(),c.persistWidgetTogglePosition()),o&&(e.dataset.dragSuppressClick="true",window.setTimeout(function(){"true"===e.dataset.dragSuppressClick&&(e.dataset.dragSuppressClick="false")},0)))))}function h(t){if(null!==a&&t.pointerId===a){var i=t.clientX-s,o=t.clientY-l;if(g||!(Math.hypot(i,o)<4)){g=!0;var u=c.getWidgetDefaultSize(),h=c.getElementSize(e,"panel"===n?u.width:52,"panel"===n?u.height:52),w=c.clampWidgetPosition(r+i,d+o,h.width,h.height);c.applyAbsolutePosition(e,w.left,w.top),"panel"===n?c.syncTogglePositionToPanel(!1):"toggle"===n&&c.syncPanelPositionToToggle(!1)}}}},t.constrainWidgetElementsToViewport=function(){if(this.widgetContainerElement&&this.widgetContainerElement.style.left&&this.isWidgetPanelVisible()){var e=this.getWidgetDefaultSize(),t=this.getElementSize(this.widgetContainerElement,e.width,e.height),n=this.getElementPosition(this.widgetContainerElement),o=this.clampWidgetPosition(n.left,n.top,t.width,t.height);this.applyAbsolutePosition(this.widgetContainerElement,o.left,o.top),this.syncTogglePositionToPanel(!1),i.widget.persistLayout&&(this.persistWidgetPanelPosition(),this.persistWidgetTogglePosition())}else if(this.widgetToggleButtonElement&&this.widgetToggleButtonElement.style.left){var a=this.getElementSize(this.widgetToggleButtonElement,52,52),s=this.getElementPosition(this.widgetToggleButtonElement),l=this.clampWidgetPosition(s.left,s.top,a.width,a.height);this.applyAbsolutePosition(this.widgetToggleButtonElement,l.left,l.top),this.syncPanelPositionToToggle(!1),i.widget.persistLayout&&(this.persistWidgetTogglePosition(),this.persistWidgetPanelPosition())}},t.showChatScreen=function(){this.chatHistorySection&&this.chatHistorySection.classList.remove("show")})},initialize:t,onMounted:t,resolveSessionId:function(e){return e&&e.widgetIsInitialized?localStorage.getItem(e.chatWidgetStateSession):null},onSessionInitialized:function(e,t){e&&e.widgetIsInitialized&&localStorage.setItem(e.chatWidgetStateSession,t)},onSessionReset:function(e){e&&e.widgetIsInitialized&&(localStorage.removeItem(e.chatWidgetStateSession),e.clearStoredWidgetDocuments())},onDocumentsChanged:function(e,t){e&&e.widgetIsInitialized&&e.saveStoredWidgetDocuments(t)},handleReceiveError:function(e){e&&e.widgetIsInitialized&&!e.isSessionStarted&&!e._attemptedSessionRecovery&&(e._attemptedSessionRecovery=!0,localStorage.removeItem(e.chatWidgetStateSession),e.clearStoredWidgetDocuments(),e.startNewSession())},dispose:i,onBeforeUnmount:i}}(),window.coreAIChatWidgetManager=window.coreAIChatWidgetManager||function(){function e(e,t){var i=e.getAttribute(t);return null===i||""===i?null:i}function t(e){if(null==e)return null;if("boolean"==typeof e)return e;var t=String(e).trim().toLowerCase();return"true"===t||"false"!==t&&null}function i(t,i,n){var o=e(t,i);if(!o)return null;try{return JSON.parse(o)}catch(e){return console.error("Failed to parse "+n+" JSON.",e),null}}function n(e){if(!e)return null;var t=e.chatConfig;if(!t&&e.configElementSelector){var n=document.querySelector(e.configElementSelector);t=n?i(n,"data-config","AI chat widget config"):null}if(!t)return null;if(e.messageTemplateSelector){var o=document.querySelector(e.messageTemplateSelector);o&&(t.messageTemplate=o.innerHTML)}if(e.indicatorTemplateSelector){var a=document.querySelector(e.indicatorTemplateSelector);a&&(t.indicatorTemplate=a.innerHTML)}var s=document.querySelector(e.shellSelector),l=document.querySelector(e.widgetContainerSelector),r=document.querySelector(e.toggleButtonSelector),d=document.querySelector(e.closeButtonSelector),g=e.inputSelector?document.querySelector(e.inputSelector):null,c=e.widgetStateName||t.widget.chatWidgetStateName,u=e.widgetOpenStateKey||c+"Open",h=c+"Layout",w=e.openStateValue||"open",m=e.closedStateValue||"closed";g&&e.profile&&e.profile.id&&g.setAttribute("data-profile-id",e.profile.id);try{var p=localStorage.getItem(h),f=p&&JSON.parse(p)||{},S=f.position||{},y=f.panel||{},v=Number(S.left),b=Number(S.top),W=localStorage.getItem(u)===w;if(s&&(s.dataset.deferReveal=W?"true":"false",s.dataset.initialOpen=W?"true":"false"),l&&r){var E=Number.isFinite(Number(y.width))?Number(y.width):Math.round(parseFloat(window.getComputedStyle(l).width)||380),P=Number.isFinite(Number(y.height))?Number(y.height):Math.round(parseFloat(window.getComputedStyle(l).height)||520),T=Math.max(8,window.innerWidth-52-8),C=Math.max(8,window.innerHeight-52-8);if(Number.isFinite(Number(S.leftRatio))&&(v=8+Math.max(0,T-8)*Number(S.leftRatio)),Number.isFinite(Number(S.topRatio))&&(b=8+Math.max(0,C-8)*Number(S.topRatio)),Number.isFinite(v)&&Number.isFinite(b)&&(v=Math.round(clampWidgetValue(v,8,T)),b=Math.round(clampWidgetValue(b,8,C))),Number.isFinite(v)&&Number.isFinite(b)){r.style.left=v+"px",r.style.top=b+"px",r.style.right="auto",r.style.bottom="auto";l.style.left=v+52-E+"px",l.style.top=b-P-8+"px",l.style.right="auto",l.style.bottom="auto"}}l&&(l.classList.remove("open"),l.style.display="none",l.setAttribute("aria-hidden","true")),r&&(r.innerHTML=W?e.openIconHtml:e.closedIconHtml)}catch(e){console.warn("Failed to restore widget layout before initialization.",e)}finally{s&&"true"!==s.dataset.deferReveal&&(s.style.visibility="")}var z=window.coreAIChatManager.initialize(t);function L(){s&&(s.style.visibility="",s.dataset.deferReveal="false")}function B(){z&&"function"==typeof z.syncPanelPositionToToggle&&z.syncPanelPositionToToggle(!1)}function R(){l&&l.querySelectorAll("[data-tts-message-index]").forEach(function(e){var t=Number(e.getAttribute("data-tts-message-index"))===z.ttsPlayingMessageIndex;e.classList.toggle("tts-playing",t),e.setAttribute("title",t?"Pause audio":"Read aloud")})}function I(){requestAnimationFrame(R)}function N(t){if(z){var i=l.classList.contains("open");t&&!i&&"function"==typeof z.syncPanelPositionToToggle?z.syncPanelPositionToToggle():!t&&i&&"function"==typeof z.syncTogglePositionToPanel&&z.syncTogglePositionToPanel()}l.classList.toggle("open",t),l.style.display=t?"flex":"none",l.setAttribute("aria-hidden",t?"false":"true"),r.innerHTML=t?e.openIconHtml:e.closedIconHtml,localStorage.setItem(u,t?w:m),t&&"function"==typeof window.renderPendingCharts&&setTimeout(function(){window.renderPendingCharts()},100)}!1!==e.applySessionProfilePatch&&window.crestAppsAIChat&&window.crestAppsAIChat.patchSessionProfileSync&&window.crestAppsAIChat.patchSessionProfileSync(z);var M=s&&"true"===s.dataset.initialOpen;return N(M),function(e){if(s&&"true"===s.dataset.deferReveal&&e){var t=!1,i=null;if("undefined"!=typeof ResizeObserver){var n=0,o=0,a=0;(i=new ResizeObserver(function(e){var t=e&&e[0];if(t){var i=Math.round(t.contentRect.width),s=Math.round(t.contentRect.height);i&&s&&(B(),i===n&&s===o?a++:(n=i,o=s,a=0),a>=1&&r())}})).observe(l),window.setTimeout(r,150)}else window.setTimeout(r,0)}else L();function r(){t||(t=!0,i&&i.disconnect(),requestAnimationFrame(function(){B(),requestAnimationFrame(function(){L()})}))}}(M),z&&"function"==typeof z.$watch&&z.$watch("ttsPlayingMessageIndex",function(){I()}),I(),r&&r.addEventListener("click",function(){"true"!==r.dataset.dragSuppressClick?N(!l.classList.contains("open")):r.dataset.dragSuppressClick="false"}),d&&d.addEventListener("click",function(){N(!1)}),z}function o(o){if(!o||"true"===o.dataset.coreAiChatWidgetInitialized)return o&&o.__coreAIChatWidgetApp||null;var a=i(o,"data-coreai-chat-widget-config","CoreAI chat widget config"),s=function(i){var n=e(i,"data-coreai-chat-widget-container-selector");if(!n)return null;var o=null;window.coreAIChatManager&&"function"==typeof window.coreAIChatManager.buildConfigFromElement&&(o=window.coreAIChatManager.buildConfigFromElement(i,{allowWidgetHost:!0}));var a=e(i,"data-coreai-chat-widget-profile-id"),s=e(i,"data-coreai-chat-widget-profile-name"),l=e(i,"data-coreai-chat-widget-profile-display-text"),r=e(i,"data-coreai-chat-widget-profile-welcome-message"),d=e(i,"data-coreai-chat-widget-profile-chat-mode"),g=e(i,"data-coreai-chat-widget-profile-tts-voice-name"),c=t(e(i,"data-coreai-chat-widget-profile-enable-session-metrics")),u=t(e(i,"data-coreai-chat-widget-profile-allow-session-documents")),h=null;(a||s||l||r||d||g||null!==c||null!==u)&&(h={id:a,name:s,displayText:l,welcomeMessage:r,chatMode:d,ttsVoiceName:g,enableSessionMetrics:!0===c,allowSessionDocuments:!0===u});var w=t(e(i,"data-coreai-chat-widget-enable-dragging")),m=t(e(i,"data-coreai-chat-widget-enable-resizing")),p=t(e(i,"data-coreai-chat-widget-persist-layout"));return{shellSelector:e(i,"data-coreai-chat-widget-shell-selector"),widgetContainerSelector:n,toggleButtonSelector:e(i,"data-coreai-chat-widget-toggle-button-selector"),closeButtonSelector:e(i,"data-coreai-chat-widget-close-button-selector"),inputSelector:e(i,"data-coreai-chat-widget-input-selector"),messageTemplateSelector:e(i,"data-coreai-chat-widget-message-template-selector"),indicatorTemplateSelector:e(i,"data-coreai-chat-widget-indicator-template-selector"),profile:h,widgetStateName:e(i,"data-coreai-chat-widget-state-name"),openStateValue:e(i,"data-coreai-chat-widget-open-state-value"),closedStateValue:e(i,"data-coreai-chat-widget-closed-state-value"),openIconHtml:e(i,"data-coreai-chat-widget-open-icon-html"),closedIconHtml:e(i,"data-coreai-chat-widget-closed-icon-html"),chatConfig:o?Object.assign({},o,{widget:Object.assign({},o.widget||{},{chatWidgetContainer:n,chatWidgetStateName:e(i,"data-coreai-chat-widget-state-name"),newChatButton:e(i,"data-coreai-chat-widget-new-chat-button-selector"),toggleButtonSelector:e(i,"data-coreai-chat-widget-toggle-button-selector"),resetSizeButtonSelector:e(i,"data-coreai-chat-widget-reset-size-button-selector"),dragHandleSelector:e(i,"data-coreai-chat-widget-drag-handle-selector"),enableDragging:null===w?void 0:w,enableResizing:null===m?void 0:m,persistLayout:null===p?void 0:p})}):null}}(o);if(!a&&!s)return null;var l=n(Object.assign({},a||{},s||{}));return l?(o.dataset.coreAiChatWidgetInitialized="true",o.__coreAIChatWidgetApp=l,l):null}function a(e){e&&"function"==typeof e.querySelectorAll&&("function"==typeof e.matches&&e.matches("[data-coreai-chat-widget-config],[data-coreai-chat-widget-container-selector]")&&o(e),e.querySelectorAll("[data-coreai-chat-widget-config],[data-coreai-chat-widget-container-selector]").forEach(o))}function s(){(a(document),"undefined"!=typeof MutationObserver)&&new MutationObserver(function(e){e.forEach(function(e){e.addedNodes.forEach(function(e){e&&1===e.nodeType&&a(e)})})}).observe(document.body,{childList:!0,subtree:!0})}return"loading"===document.readyState?document.addEventListener("DOMContentLoaded",s,{once:!0}):s(),{initialize:n,initializeFromElement:o}}();
|
|
2
2
|
//# sourceMappingURL=ai-chat-widget.min.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["ai-chat-widget.js"],"names":["clampWidgetValue","value","min","max","Math","window","coreAIChatWidgetBehavior","parsePixelValue","Number","isFinite","parsed","parseFloat","initialize","app","config","widgetIsInitialized","widget","chatWidgetContainer","chatWidgetStateName","document","querySelector","chatHistorySection","chatWidgetStateSession","chatWidgetStateDocuments","chatWidgetLayoutKey","widgetContainerElement","widgetToggleButtonElement","toggleButtonSelector","widgetResetSizeButtonElement","resetSizeButtonSelector","widgetDefaultWidth","defaultWidth","getComputedStyle","width","widgetDefaultHeight","defaultHeight","height","clearStoredWidgetDocuments","documents","enableResizing","classList","add","style","minWidth","minHeight","ResizeObserver","widgetResizeObserver","persistWidgetPanelSize","constrainWidgetElementsToViewport","updateWidgetResetSizeButtonVisibility","observe","dragHandleSelector","dragHandle","enableDragging","attachDraggableWidgetElement","addEventListener","event","preventDefault","resetWidgetSize","restoreWidgetLayout","widgetViewportResizeHandler","persistLayout","reloadCurrentSession","autoCreateSession","getSessionId","startNewSession","showHistoryButton","toggle","closeHistoryButton","showChatScreen","newChatButton","resetSession","console","error","dispose","disconnect","removeEventListener","attach","__aiChatWidgetAttached","getStoredWidgetLayout","this","storedLayout","localStorage","getItem","JSON","parse","warn","saveStoredWidgetLayout","partialLayout","currentLayout","nextLayout","Object","assign","undefined","panel","position","setItem","stringify","getElementSize","element","fallbackWidth","fallbackHeight","rect","getBoundingClientRect","computed","round","getElementPosition","left","top","inlineLeft","inlineTop","computedLeft","computedTop","isHidden","display","getAvailableWidgetPositionRange","padding","maxLeft","innerWidth","maxTop","innerHeight","createStoredPosition","range","leftSpan","topSpan","leftRatio","topRatio","resolveStoredPosition","storedPosition","clampWidgetPosition","getStoredWidgetDocuments","saveStoredWidgetDocuments","removeItem","applyAbsolutePosition","right","bottom","getWidgetDefaultSize","getWidgetToggleGap","isWidgetPanelVisible","contains","persistWidgetPanelPosition","panelDefaultSize","panelPosition","panelSize","toggleSize","linkedPosition","persistWidgetTogglePosition","togglePosition","defaultSize","currentSize","abs","syncTogglePositionToPanel","syncPanelPositionToToggle","isResized","removeProperty","storedTogglePosition","handle","layoutKey","suppressClickOnDrag","activePointerId","startX","startY","startLeft","startTop","dragged","self","button","target","closest","clientX","clientY","pointerId","setPointerCapture","onPointerMove","stopDragging","remove","dataset","dragSuppressClick","setTimeout","deltaX","deltaY","hypot","nextPosition","clampedPanel","clampedToggle","onMounted","resolveSessionId","onSessionInitialized","sessionId","onSessionReset","onDocumentsChanged","handleReceiveError","isSessionStarted","_attemptedSessionRecovery","onBeforeUnmount","coreAIChatWidgetManager","getAttributeValue","attributeName","getAttribute","parseBooleanAttributeValue","normalized","String","trim","toLowerCase","parseJsonAttribute","description","rawValue","options","chatConfig","configElementSelector","configElement","messageTemplateSelector","messageTemplate","innerHTML","indicatorTemplateSelector","indicatorTemplate","shell","shellSelector","widgetContainer","widgetContainerSelector","toggleButton","closeButton","closeButtonSelector","profileInput","inputSelector","widgetStateName","widgetOpenStateKey","widgetLayoutKey","openStateValue","closedStateValue","profile","id","setAttribute","layout","panelLayout","toggleLeft","toggleTop","isOpen","deferReveal","initialOpen","panelWidth","panelHeight","openIconHtml","closedIconHtml","visibility","widgetApp","coreAIChatManager","revealShell","syncOpenPanelPosition","updateTtsPlaybackButtons","querySelectorAll","forEach","isPlaying","ttsPlayingMessageIndex","queueTtsPlaybackButtonUpdate","requestAnimationFrame","setWidgetOpen","isCurrentlyOpen","renderPendingCharts","applySessionProfilePatch","crestAppsAIChat","patchSessionProfileSync","hasRevealed","resizeObserver","lastWidth","lastHeight","stablePasses","entries","entry","contentRect","finalizeReveal","revealShellWhenStable","$watch","initializeFromElement","coreAiChatWidgetInitialized","__coreAIChatWidgetApp","jsonOptions","attributeOptions","buildConfigFromElement","allowWidgetHost","profileId","profileName","profileDisplayText","profileWelcomeMessage","profileChatMode","profileTtsVoiceName","profileMetricsEnabled","profileSessionDocuments","name","displayText","welcomeMessage","chatMode","ttsVoiceName","enableSessionMetrics","allowSessionDocuments","buildOptionsFromDataAttributes","scanForAutoInitialization","root","matches","startAutoInitialization","MutationObserver","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OAAyBgC,EAAYhC,MAEvD,KAEb,CA4R2B0O,CAA+BpM,GACtD,IAAKiL,IAAgBC,EACjB,OAAO,KAGX,IAEIhC,EAAYzO,EAFF+E,OAAOC,OAAO,CAAC,EAAGwL,GAAe,CAAC,EAAGC,GAAoB,CAAC,IAGxE,OAAKhC,GAILlJ,EAAQ6E,QAAQkG,4BAA8B,OAC9C/K,EAAQgL,sBAAwB9B,EAEzBA,GANI,IAOf,CAEA,SAASmD,EAA0BC,GAC1BA,GAAyC,mBAA1BA,EAAK/C,mBAIG,mBAAjB+C,EAAKC,SAA0BD,EAAKC,QAAQ,kFACnDzB,EAAsBwB,GAG1BA,EAAK/C,iBAAiB,iFAAiFC,QAAQsB,GACnH,CAEA,SAAS0B,KACLH,EAA0BrR,UAEM,oBAArByR,mBAII,IAAIA,iBAAiB,SAAUC,GAC1CA,EAAUlD,QAAQ,SAAUmD,GACxBA,EAASC,WAAWpD,QAAQ,SAAUqD,GAC9BA,GAA0B,IAAlBA,EAAKC,UACbT,EAA0BQ,EAElC,EACJ,EACJ,GAES9P,QAAQ/B,SAAS+R,KAAM,CAC5BC,WAAW,EACXC,SAAS,GAEjB,CAQA,MAN4B,YAAxBjS,SAASkS,WACTlS,SAASoC,iBAAiB,mBAAoBoP,EAAyB,CAAEW,MAAM,IAE/EX,IAGG,CACH/R,WAAYA,EACZqQ,sBAAuBA,EAE/B,CArcmE","file":"ai-chat-widget.min.js","sourcesContent":["function clampWidgetValue(value, min, max) {\n return Math.min(Math.max(value, min), max);\n}\n\nwindow.coreAIChatWidgetBehavior = window.coreAIChatWidgetBehavior || function () {\n function parsePixelValue(value) {\n if (typeof value === 'number' && Number.isFinite(value)) {\n return value;\n }\n\n if (typeof value !== 'string') {\n return null;\n }\n\n var parsed = parseFloat(value);\n return Number.isFinite(parsed) ? parsed : null;\n }\n\n function attach(app, config) {\n if (!app || app.__aiChatWidgetAttached) {\n return;\n }\n\n app.__aiChatWidgetAttached = true;\n app.chatWidgetStateName = null;\n app.chatWidgetStateSession = null;\n app.chatWidgetStateDocuments = null;\n app.chatWidgetLayoutKey = null;\n app.chatHistorySection = null;\n app.widgetContainerElement = null;\n app.widgetToggleButtonElement = null;\n app.widgetResetSizeButtonElement = null;\n app.widgetResizeObserver = null;\n app.widgetViewportResizeHandler = null;\n app.widgetDefaultWidth = null;\n app.widgetDefaultHeight = null;\n app.widgetIsInitialized = false;\n\n app.getStoredWidgetLayout = function () {\n if (!this.chatWidgetLayoutKey || !config.widget.persistLayout) {\n return {};\n }\n\n try {\n var storedLayout = localStorage.getItem(this.chatWidgetLayoutKey);\n return storedLayout ? JSON.parse(storedLayout) || {} : {};\n }\n catch (error) {\n console.warn('Failed to read widget layout state.', error);\n return {};\n }\n };\n\n app.saveStoredWidgetLayout = function (partialLayout) {\n if (!this.chatWidgetLayoutKey || !config.widget.persistLayout) {\n return;\n }\n\n var currentLayout = this.getStoredWidgetLayout();\n var nextLayout = Object.assign({}, currentLayout);\n\n if (partialLayout.panel !== undefined) {\n nextLayout.panel = Object.assign({}, currentLayout.panel || {}, partialLayout.panel || {});\n }\n\n if (partialLayout.position !== undefined) {\n nextLayout.position = Object.assign({}, currentLayout.position || {}, partialLayout.position || {});\n }\n\n localStorage.setItem(this.chatWidgetLayoutKey, JSON.stringify(nextLayout));\n };\n\n app.getElementSize = function (element, fallbackWidth, fallbackHeight) {\n if (!element) {\n return {\n width: fallbackWidth || 0,\n height: fallbackHeight || 0\n };\n }\n\n var rect = element.getBoundingClientRect();\n var computed = window.getComputedStyle(element);\n\n return {\n width: Math.round(rect.width || parsePixelValue(computed.width) || fallbackWidth || 0),\n height: Math.round(rect.height || parsePixelValue(computed.height) || fallbackHeight || 0)\n };\n };\n\n app.getElementPosition = function (element) {\n if (!element) {\n return {\n left: 0,\n top: 0\n };\n }\n\n var rect = element.getBoundingClientRect();\n var computed = window.getComputedStyle(element);\n var inlineLeft = parsePixelValue(element.style.left);\n var inlineTop = parsePixelValue(element.style.top);\n var computedLeft = parsePixelValue(computed.left);\n var computedTop = parsePixelValue(computed.top);\n var isHidden = computed.display === 'none';\n\n return {\n left: Math.round(isHidden && Number.isFinite(inlineLeft) ? inlineLeft : rect.left || inlineLeft || computedLeft || 0),\n top: Math.round(isHidden && Number.isFinite(inlineTop) ? inlineTop : rect.top || inlineTop || computedTop || 0)\n };\n };\n\n app.getAvailableWidgetPositionRange = function (width, height) {\n var viewportPadding = 8;\n return {\n padding: viewportPadding,\n maxLeft: Math.max(viewportPadding, window.innerWidth - width - viewportPadding),\n maxTop: Math.max(viewportPadding, window.innerHeight - height - viewportPadding)\n };\n };\n\n app.createStoredPosition = function (left, top, width, height) {\n var range = this.getAvailableWidgetPositionRange(width, height);\n var leftSpan = Math.max(0, range.maxLeft - range.padding);\n var topSpan = Math.max(0, range.maxTop - range.padding);\n\n return {\n left: Math.round(left),\n top: Math.round(top),\n leftRatio: leftSpan === 0 ? 0 : (left - range.padding) / leftSpan,\n topRatio: topSpan === 0 ? 0 : (top - range.padding) / topSpan\n };\n };\n\n app.resolveStoredPosition = function (storedPosition, width, height) {\n if (!storedPosition) {\n return null;\n }\n\n var range = this.getAvailableWidgetPositionRange(width, height);\n var left = Number(storedPosition.left);\n var top = Number(storedPosition.top);\n var leftRatio = Number(storedPosition.leftRatio);\n var topRatio = Number(storedPosition.topRatio);\n\n if (Number.isFinite(leftRatio)) {\n left = range.padding + Math.max(0, range.maxLeft - range.padding) * leftRatio;\n }\n\n if (Number.isFinite(topRatio)) {\n top = range.padding + Math.max(0, range.maxTop - range.padding) * topRatio;\n }\n\n if (!Number.isFinite(left) || !Number.isFinite(top)) {\n return null;\n }\n\n return this.clampWidgetPosition(left, top, width, height);\n };\n\n app.clampWidgetPosition = function (left, top, width, height) {\n var range = this.getAvailableWidgetPositionRange(width, height);\n\n return {\n left: Math.round(clampWidgetValue(left, range.padding, range.maxLeft)),\n top: Math.round(clampWidgetValue(top, range.padding, range.maxTop))\n };\n };\n\n app.getStoredWidgetDocuments = function () {\n this.clearStoredWidgetDocuments();\n return [];\n };\n\n app.saveStoredWidgetDocuments = function () {\n this.clearStoredWidgetDocuments();\n };\n\n app.clearStoredWidgetDocuments = function () {\n if (!this.chatWidgetStateDocuments) {\n return;\n }\n\n localStorage.removeItem(this.chatWidgetStateDocuments);\n };\n\n app.applyAbsolutePosition = function (element, left, top) {\n if (!element) {\n return;\n }\n\n element.style.left = left + 'px';\n element.style.top = top + 'px';\n element.style.right = 'auto';\n element.style.bottom = 'auto';\n };\n\n app.getWidgetDefaultSize = function () {\n return {\n width: this.widgetDefaultWidth || parsePixelValue(config.widget.defaultWidth) || 380,\n height: this.widgetDefaultHeight || parsePixelValue(config.widget.defaultHeight) || 520\n };\n };\n\n app.getWidgetToggleGap = function () {\n return 8;\n };\n\n app.isWidgetPanelVisible = function () {\n if (!this.widgetContainerElement) {\n return false;\n }\n\n var computed = window.getComputedStyle(this.widgetContainerElement);\n return this.widgetContainerElement.classList.contains('open') && computed.display !== 'none';\n };\n\n app.persistWidgetPanelPosition = function () {\n if (!this.widgetContainerElement || !config.widget.persistLayout) {\n return;\n }\n\n var panelDefaultSize = this.getWidgetDefaultSize();\n var panelPosition = this.getElementPosition(this.widgetContainerElement);\n var panelSize = this.getElementSize(this.widgetContainerElement, panelDefaultSize.width, panelDefaultSize.height);\n var toggleSize = this.getElementSize(this.widgetToggleButtonElement, 52, 52);\n var linkedPosition = this.clampWidgetPosition(\n panelPosition.left + panelSize.width - toggleSize.width,\n panelPosition.top + panelSize.height + this.getWidgetToggleGap(),\n toggleSize.width,\n toggleSize.height);\n\n this.saveStoredWidgetLayout({ position: this.createStoredPosition(linkedPosition.left, linkedPosition.top, toggleSize.width, toggleSize.height) });\n };\n\n app.persistWidgetTogglePosition = function () {\n if (!this.widgetToggleButtonElement || !config.widget.persistLayout) {\n return;\n }\n\n var togglePosition = this.getElementPosition(this.widgetToggleButtonElement);\n var toggleSize = this.getElementSize(this.widgetToggleButtonElement, 52, 52);\n this.saveStoredWidgetLayout({ position: this.createStoredPosition(togglePosition.left, togglePosition.top, toggleSize.width, toggleSize.height) });\n };\n\n app.persistWidgetPanelSize = function () {\n if (!this.widgetContainerElement || !config.widget.enableResizing || !config.widget.persistLayout) {\n return;\n }\n\n var defaultSize = this.getWidgetDefaultSize();\n var currentSize = this.getElementSize(this.widgetContainerElement, defaultSize.width, defaultSize.height);\n\n this.saveStoredWidgetLayout({\n panel: {\n width: Math.abs(currentSize.width - defaultSize.width) <= 1 ? null : currentSize.width,\n height: Math.abs(currentSize.height - defaultSize.height) <= 1 ? null : currentSize.height\n }\n });\n };\n\n app.syncTogglePositionToPanel = function (persistLayout) {\n if (persistLayout === undefined) {\n persistLayout = true;\n }\n\n if (!this.widgetContainerElement || !this.widgetToggleButtonElement) {\n return;\n }\n\n var panelDefaultSize = this.getWidgetDefaultSize();\n var panelSize = this.getElementSize(this.widgetContainerElement, panelDefaultSize.width, panelDefaultSize.height);\n var toggleSize = this.getElementSize(this.widgetToggleButtonElement, 52, 52);\n var panelPosition = this.getElementPosition(this.widgetContainerElement);\n var linkedPosition = this.clampWidgetPosition(\n panelPosition.left + panelSize.width - toggleSize.width,\n panelPosition.top + panelSize.height + this.getWidgetToggleGap(),\n toggleSize.width,\n toggleSize.height);\n\n this.applyAbsolutePosition(this.widgetToggleButtonElement, linkedPosition.left, linkedPosition.top);\n\n if (persistLayout && config.widget.persistLayout) {\n this.persistWidgetTogglePosition();\n }\n };\n\n app.syncPanelPositionToToggle = function (persistLayout) {\n if (persistLayout === undefined) {\n persistLayout = true;\n }\n\n if (!this.widgetContainerElement || !this.widgetToggleButtonElement) {\n return;\n }\n\n var panelDefaultSize = this.getWidgetDefaultSize();\n var panelSize = this.getElementSize(this.widgetContainerElement, panelDefaultSize.width, panelDefaultSize.height);\n var toggleSize = this.getElementSize(this.widgetToggleButtonElement, 52, 52);\n var togglePosition = this.getElementPosition(this.widgetToggleButtonElement);\n var linkedPosition = this.clampWidgetPosition(\n togglePosition.left + toggleSize.width - panelSize.width,\n togglePosition.top - panelSize.height - this.getWidgetToggleGap(),\n panelSize.width,\n panelSize.height);\n\n this.applyAbsolutePosition(this.widgetContainerElement, linkedPosition.left, linkedPosition.top);\n\n if (persistLayout && config.widget.persistLayout) {\n this.persistWidgetPanelPosition();\n }\n };\n\n app.updateWidgetResetSizeButtonVisibility = function () {\n if (!this.widgetResetSizeButtonElement) {\n return;\n }\n\n if (!config.widget.enableResizing || !this.widgetContainerElement) {\n this.widgetResetSizeButtonElement.classList.add('d-none');\n return;\n }\n\n var defaultSize = this.getWidgetDefaultSize();\n var currentSize = this.getElementSize(this.widgetContainerElement, defaultSize.width, defaultSize.height);\n var isResized =\n Math.abs(currentSize.width - defaultSize.width) > 1 ||\n Math.abs(currentSize.height - defaultSize.height) > 1 ||\n !!this.widgetContainerElement.style.width ||\n !!this.widgetContainerElement.style.height;\n\n this.widgetResetSizeButtonElement.classList.toggle('d-none', !isResized);\n };\n\n app.resetWidgetSize = function () {\n if (!this.widgetContainerElement || !config.widget.enableResizing) {\n return;\n }\n\n this.widgetContainerElement.style.removeProperty('width');\n this.widgetContainerElement.style.removeProperty('height');\n this.persistWidgetPanelSize();\n this.constrainWidgetElementsToViewport();\n this.updateWidgetResetSizeButtonVisibility();\n };\n\n app.restoreWidgetLayout = function () {\n var storedLayout = this.getStoredWidgetLayout();\n\n if (this.widgetContainerElement && config.widget.enableResizing) {\n if (Number.isFinite(storedLayout.panel && storedLayout.panel.width)) {\n this.widgetContainerElement.style.width = storedLayout.panel.width + 'px';\n }\n else {\n this.widgetContainerElement.style.removeProperty('width');\n }\n\n if (Number.isFinite(storedLayout.panel && storedLayout.panel.height)) {\n this.widgetContainerElement.style.height = storedLayout.panel.height + 'px';\n }\n else {\n this.widgetContainerElement.style.removeProperty('height');\n }\n }\n\n var toggleSize = this.getElementSize(this.widgetToggleButtonElement, 52, 52);\n var storedTogglePosition = this.resolveStoredPosition(storedLayout.position, toggleSize.width, toggleSize.height);\n if (this.widgetToggleButtonElement && config.widget.enableDragging && storedTogglePosition) {\n this.applyAbsolutePosition(this.widgetToggleButtonElement, storedTogglePosition.left, storedTogglePosition.top);\n this.syncPanelPositionToToggle(false);\n }\n else if (this.widgetToggleButtonElement && config.widget.enableDragging &&\n Number.isFinite(storedLayout.toggle && storedLayout.toggle.left) &&\n Number.isFinite(storedLayout.toggle && storedLayout.toggle.top)) {\n this.applyAbsolutePosition(this.widgetToggleButtonElement, storedLayout.toggle.left, storedLayout.toggle.top);\n this.syncPanelPositionToToggle(false);\n }\n else if (this.widgetContainerElement && config.widget.enableDragging &&\n Number.isFinite(storedLayout.panel && storedLayout.panel.left) &&\n Number.isFinite(storedLayout.panel && storedLayout.panel.top)) {\n this.applyAbsolutePosition(this.widgetContainerElement, storedLayout.panel.left, storedLayout.panel.top);\n this.syncTogglePositionToPanel(false);\n }\n\n this.constrainWidgetElementsToViewport();\n this.updateWidgetResetSizeButtonVisibility();\n };\n\n app.attachDraggableWidgetElement = function (element, handle, layoutKey, suppressClickOnDrag) {\n if (!element || !handle || !config.widget.enableDragging) {\n return;\n }\n\n var activePointerId = null;\n var startX = 0;\n var startY = 0;\n var startLeft = 0;\n var startTop = 0;\n var dragged = false;\n var dragThreshold = 4;\n var interactiveSelector = 'button, a, input, textarea, select, option, label';\n var self = this;\n\n function stopDragging(event) {\n if (activePointerId === null) {\n return;\n }\n\n if (event && event.pointerId !== undefined && event.pointerId !== activePointerId) {\n return;\n }\n\n document.removeEventListener('pointermove', onPointerMove);\n document.removeEventListener('pointerup', stopDragging);\n document.removeEventListener('pointercancel', stopDragging);\n element.classList.remove('ai-chat-widget-dragging');\n activePointerId = null;\n\n if (!dragged) {\n return;\n }\n\n if (layoutKey === 'panel') {\n self.syncTogglePositionToPanel(false);\n self.persistWidgetPanelPosition();\n }\n else if (layoutKey === 'toggle') {\n self.syncPanelPositionToToggle(false);\n self.persistWidgetTogglePosition();\n }\n\n if (config.widget.persistLayout) {\n self.persistWidgetPanelPosition();\n self.persistWidgetTogglePosition();\n }\n\n if (suppressClickOnDrag) {\n element.dataset.dragSuppressClick = 'true';\n window.setTimeout(function () {\n if (element.dataset.dragSuppressClick === 'true') {\n element.dataset.dragSuppressClick = 'false';\n }\n }, 0);\n }\n }\n\n function onPointerMove(event) {\n if (activePointerId === null || event.pointerId !== activePointerId) {\n return;\n }\n\n var deltaX = event.clientX - startX;\n var deltaY = event.clientY - startY;\n\n if (!dragged && Math.hypot(deltaX, deltaY) < dragThreshold) {\n return;\n }\n\n dragged = true;\n\n var defaultSize = self.getWidgetDefaultSize();\n var currentSize = self.getElementSize(\n element,\n layoutKey === 'panel' ? defaultSize.width : 52,\n layoutKey === 'panel' ? defaultSize.height : 52);\n var nextPosition = self.clampWidgetPosition(startLeft + deltaX, startTop + deltaY, currentSize.width, currentSize.height);\n\n self.applyAbsolutePosition(element, nextPosition.left, nextPosition.top);\n\n if (layoutKey === 'panel') {\n self.syncTogglePositionToPanel(false);\n }\n else if (layoutKey === 'toggle') {\n self.syncPanelPositionToToggle(false);\n }\n }\n\n handle.addEventListener('pointerdown', function (event) {\n if (event.button !== 0) {\n return;\n }\n\n if (layoutKey === 'panel' && event.target.closest(interactiveSelector)) {\n return;\n }\n\n var rect = element.getBoundingClientRect();\n startX = event.clientX;\n startY = event.clientY;\n startLeft = rect.left;\n startTop = rect.top;\n dragged = false;\n activePointerId = event.pointerId;\n element.classList.add('ai-chat-widget-dragging');\n\n if (handle.setPointerCapture) {\n handle.setPointerCapture(event.pointerId);\n }\n\n document.addEventListener('pointermove', onPointerMove);\n document.addEventListener('pointerup', stopDragging);\n document.addEventListener('pointercancel', stopDragging);\n event.preventDefault();\n });\n };\n\n app.constrainWidgetElementsToViewport = function () {\n if (this.widgetContainerElement && this.widgetContainerElement.style.left && this.isWidgetPanelVisible()) {\n var panelDefaultSize = this.getWidgetDefaultSize();\n var panelSize = this.getElementSize(this.widgetContainerElement, panelDefaultSize.width, panelDefaultSize.height);\n var panelPosition = this.getElementPosition(this.widgetContainerElement);\n var clampedPanel = this.clampWidgetPosition(panelPosition.left, panelPosition.top, panelSize.width, panelSize.height);\n\n this.applyAbsolutePosition(this.widgetContainerElement, clampedPanel.left, clampedPanel.top);\n this.syncTogglePositionToPanel(false);\n\n if (config.widget.persistLayout) {\n this.persistWidgetPanelPosition();\n this.persistWidgetTogglePosition();\n }\n }\n else if (this.widgetToggleButtonElement && this.widgetToggleButtonElement.style.left) {\n var toggleSize = this.getElementSize(this.widgetToggleButtonElement, 52, 52);\n var togglePosition = this.getElementPosition(this.widgetToggleButtonElement);\n var clampedToggle = this.clampWidgetPosition(togglePosition.left, togglePosition.top, toggleSize.width, toggleSize.height);\n\n this.applyAbsolutePosition(this.widgetToggleButtonElement, clampedToggle.left, clampedToggle.top);\n this.syncPanelPositionToToggle(false);\n\n if (config.widget.persistLayout) {\n this.persistWidgetTogglePosition();\n this.persistWidgetPanelPosition();\n }\n }\n };\n\n app.showChatScreen = function () {\n if (!this.chatHistorySection) {\n return;\n }\n\n this.chatHistorySection.classList.remove('show');\n };\n }\n\n function initialize(app, config) {\n if (!app || app.widgetIsInitialized) {\n return;\n }\n\n if (!config.widget.chatWidgetContainer) {\n console.error('The widget chatWidgetContainer is required.');\n return;\n }\n\n if (!config.widget.chatWidgetStateName) {\n console.error('The widget chatWidgetStateName is required.');\n return;\n }\n\n var chatWidgetContainer = document.querySelector(config.widget.chatWidgetContainer);\n if (!chatWidgetContainer) {\n return;\n }\n\n if (config.widget.chatHistorySection) {\n app.chatHistorySection = document.querySelector(config.widget.chatHistorySection);\n }\n\n app.chatWidgetStateName = config.widget.chatWidgetStateName;\n app.chatWidgetStateSession = config.widget.chatWidgetStateName + 'Session';\n app.chatWidgetStateDocuments = config.widget.chatWidgetStateName + 'Documents';\n app.chatWidgetLayoutKey = config.widget.chatWidgetStateName + 'Layout';\n app.widgetContainerElement = chatWidgetContainer;\n app.widgetToggleButtonElement = config.widget.toggleButtonSelector ? document.querySelector(config.widget.toggleButtonSelector) : null;\n app.widgetResetSizeButtonElement = config.widget.resetSizeButtonSelector ? document.querySelector(config.widget.resetSizeButtonSelector) : null;\n app.widgetDefaultWidth = parsePixelValue(config.widget.defaultWidth) || parsePixelValue(window.getComputedStyle(chatWidgetContainer).width) || 380;\n app.widgetDefaultHeight = parsePixelValue(config.widget.defaultHeight) || parsePixelValue(window.getComputedStyle(chatWidgetContainer).height) || 520;\n app.widgetIsInitialized = true;\n app.clearStoredWidgetDocuments();\n app.documents = [];\n\n if (config.widget.enableResizing) {\n chatWidgetContainer.classList.add('ai-chat-widget-resizable');\n chatWidgetContainer.style.minWidth = (parsePixelValue(config.widget.minWidth) || 320) + 'px';\n chatWidgetContainer.style.minHeight = (parsePixelValue(config.widget.minHeight) || 420) + 'px';\n\n if (typeof ResizeObserver !== 'undefined') {\n app.widgetResizeObserver = new ResizeObserver(function () {\n app.persistWidgetPanelSize();\n app.constrainWidgetElementsToViewport();\n app.updateWidgetResetSizeButtonVisibility();\n });\n\n app.widgetResizeObserver.observe(chatWidgetContainer);\n }\n }\n\n var dragHandleSelector = config.widget.dragHandleSelector || '.ai-chat-widget-header';\n var dragHandle = chatWidgetContainer.querySelector(dragHandleSelector);\n\n if (config.widget.enableDragging && dragHandle) {\n dragHandle.classList.add('ai-chat-widget-drag-handle');\n chatWidgetContainer.classList.add('ai-chat-widget-draggable');\n app.attachDraggableWidgetElement(chatWidgetContainer, dragHandle, 'panel', false);\n }\n\n if (config.widget.enableDragging && app.widgetToggleButtonElement) {\n app.widgetToggleButtonElement.classList.add('ai-chat-widget-draggable');\n app.attachDraggableWidgetElement(app.widgetToggleButtonElement, app.widgetToggleButtonElement, 'toggle', true);\n }\n\n if (app.widgetResetSizeButtonElement) {\n app.widgetResetSizeButtonElement.addEventListener('click', function (event) {\n event.preventDefault();\n app.resetWidgetSize();\n });\n }\n\n app.restoreWidgetLayout();\n\n if (!app.widgetViewportResizeHandler) {\n app.widgetViewportResizeHandler = function () {\n if (config.widget.persistLayout) {\n app.restoreWidgetLayout();\n } else {\n app.constrainWidgetElementsToViewport();\n }\n\n app.updateWidgetResetSizeButtonVisibility();\n };\n\n window.addEventListener('resize', app.widgetViewportResizeHandler);\n }\n\n app.reloadCurrentSession();\n\n if (config.autoCreateSession && !app.getSessionId()) {\n app.startNewSession();\n }\n\n if (config.widget.showHistoryButton && app.chatHistorySection) {\n var showHistoryButton = document.querySelector(config.widget.showHistoryButton);\n if (showHistoryButton) {\n showHistoryButton.addEventListener('click', function () {\n app.chatHistorySection.classList.toggle('show');\n });\n }\n\n if (config.widget.closeHistoryButton) {\n var closeHistoryButton = document.querySelector(config.widget.closeHistoryButton);\n if (closeHistoryButton) {\n closeHistoryButton.addEventListener('click', function () {\n app.showChatScreen();\n });\n }\n }\n }\n\n if (config.widget.newChatButton) {\n var newChatButton = document.querySelector(config.widget.newChatButton);\n if (newChatButton) {\n newChatButton.addEventListener('click', function () {\n app.resetSession();\n app.showChatScreen();\n });\n }\n }\n }\n\n function resolveSessionId(app) {\n if (!app || !app.widgetIsInitialized) {\n return null;\n }\n\n return localStorage.getItem(app.chatWidgetStateSession);\n }\n\n function onSessionInitialized(app, sessionId) {\n if (app && app.widgetIsInitialized) {\n localStorage.setItem(app.chatWidgetStateSession, sessionId);\n }\n }\n\n function onSessionReset(app) {\n if (app && app.widgetIsInitialized) {\n localStorage.removeItem(app.chatWidgetStateSession);\n app.clearStoredWidgetDocuments();\n }\n }\n\n function onDocumentsChanged(app, documents) {\n if (app && app.widgetIsInitialized) {\n app.saveStoredWidgetDocuments(documents);\n }\n }\n\n function handleReceiveError(app) {\n if (app && app.widgetIsInitialized && !app.isSessionStarted && !app._attemptedSessionRecovery) {\n app._attemptedSessionRecovery = true;\n localStorage.removeItem(app.chatWidgetStateSession);\n app.clearStoredWidgetDocuments();\n app.startNewSession();\n }\n }\n\n function dispose(app) {\n if (!app) {\n return;\n }\n\n if (app.widgetResizeObserver) {\n app.widgetResizeObserver.disconnect();\n app.widgetResizeObserver = null;\n }\n\n if (app.widgetViewportResizeHandler) {\n window.removeEventListener('resize', app.widgetViewportResizeHandler);\n app.widgetViewportResizeHandler = null;\n }\n }\n\n return {\n attach: attach,\n initialize: initialize,\n onMounted: initialize,\n resolveSessionId: resolveSessionId,\n onSessionInitialized: onSessionInitialized,\n onSessionReset: onSessionReset,\n onDocumentsChanged: onDocumentsChanged,\n handleReceiveError: handleReceiveError,\n dispose: dispose,\n onBeforeUnmount: dispose\n };\n}();\n\nwindow.coreAIChatWidgetManager = window.coreAIChatWidgetManager || function () {\n function getAttributeValue(element, attributeName) {\n var value = element.getAttribute(attributeName);\n return value === null || value === '' ? null : value;\n }\n\n function parseBooleanAttributeValue(value) {\n if (value === null || value === undefined) {\n return null;\n }\n\n if (typeof value === 'boolean') {\n return value;\n }\n\n var normalized = String(value).trim().toLowerCase();\n if (normalized === 'true') {\n return true;\n }\n\n if (normalized === 'false') {\n return false;\n }\n\n return null;\n }\n\n function parseJsonAttribute(element, attributeName, description) {\n var rawValue = getAttributeValue(element, attributeName);\n if (!rawValue) {\n return null;\n }\n\n try {\n return JSON.parse(rawValue);\n }\n catch (error) {\n console.error('Failed to parse ' + description + ' JSON.', error);\n return null;\n }\n }\n\n function buildOptionsFromDataAttributes(element) {\n var widgetContainerSelector = getAttributeValue(element, 'data-coreai-chat-widget-container-selector');\n if (!widgetContainerSelector) {\n return null;\n }\n\n var chatConfig = null;\n if (window.coreAIChatManager && typeof window.coreAIChatManager.buildConfigFromElement === 'function') {\n chatConfig = window.coreAIChatManager.buildConfigFromElement(element, { allowWidgetHost: true });\n }\n\n var profileId = getAttributeValue(element, 'data-coreai-chat-widget-profile-id');\n var profileName = getAttributeValue(element, 'data-coreai-chat-widget-profile-name');\n var profileDisplayText = getAttributeValue(element, 'data-coreai-chat-widget-profile-display-text');\n var profileWelcomeMessage = getAttributeValue(element, 'data-coreai-chat-widget-profile-welcome-message');\n var profileChatMode = getAttributeValue(element, 'data-coreai-chat-widget-profile-chat-mode');\n var profileTtsVoiceName = getAttributeValue(element, 'data-coreai-chat-widget-profile-tts-voice-name');\n var profileMetricsEnabled = parseBooleanAttributeValue(getAttributeValue(element, 'data-coreai-chat-widget-profile-enable-session-metrics'));\n var profileSessionDocuments = parseBooleanAttributeValue(getAttributeValue(element, 'data-coreai-chat-widget-profile-allow-session-documents'));\n var profile = null;\n\n if (profileId || profileName || profileDisplayText || profileWelcomeMessage || profileChatMode || profileTtsVoiceName || profileMetricsEnabled !== null || profileSessionDocuments !== null) {\n profile = {\n id: profileId,\n name: profileName,\n displayText: profileDisplayText,\n welcomeMessage: profileWelcomeMessage,\n chatMode: profileChatMode,\n ttsVoiceName: profileTtsVoiceName,\n enableSessionMetrics: profileMetricsEnabled === true,\n allowSessionDocuments: profileSessionDocuments === true\n };\n }\n\n var enableDragging = parseBooleanAttributeValue(getAttributeValue(element, 'data-coreai-chat-widget-enable-dragging'));\n var enableResizing = parseBooleanAttributeValue(getAttributeValue(element, 'data-coreai-chat-widget-enable-resizing'));\n var persistLayout = parseBooleanAttributeValue(getAttributeValue(element, 'data-coreai-chat-widget-persist-layout'));\n\n return {\n shellSelector: getAttributeValue(element, 'data-coreai-chat-widget-shell-selector'),\n widgetContainerSelector: widgetContainerSelector,\n toggleButtonSelector: getAttributeValue(element, 'data-coreai-chat-widget-toggle-button-selector'),\n closeButtonSelector: getAttributeValue(element, 'data-coreai-chat-widget-close-button-selector'),\n inputSelector: getAttributeValue(element, 'data-coreai-chat-widget-input-selector'),\n profile: profile,\n widgetStateName: getAttributeValue(element, 'data-coreai-chat-widget-state-name'),\n openStateValue: getAttributeValue(element, 'data-coreai-chat-widget-open-state-value'),\n closedStateValue: getAttributeValue(element, 'data-coreai-chat-widget-closed-state-value'),\n openIconHtml: getAttributeValue(element, 'data-coreai-chat-widget-open-icon-html'),\n closedIconHtml: getAttributeValue(element, 'data-coreai-chat-widget-closed-icon-html'),\n chatConfig: chatConfig ? Object.assign({}, chatConfig, {\n widget: Object.assign({}, chatConfig.widget || {}, {\n chatWidgetContainer: widgetContainerSelector,\n chatWidgetStateName: getAttributeValue(element, 'data-coreai-chat-widget-state-name'),\n newChatButton: getAttributeValue(element, 'data-coreai-chat-widget-new-chat-button-selector'),\n toggleButtonSelector: getAttributeValue(element, 'data-coreai-chat-widget-toggle-button-selector'),\n resetSizeButtonSelector: getAttributeValue(element, 'data-coreai-chat-widget-reset-size-button-selector'),\n dragHandleSelector: getAttributeValue(element, 'data-coreai-chat-widget-drag-handle-selector'),\n enableDragging: enableDragging === null ? undefined : enableDragging,\n enableResizing: enableResizing === null ? undefined : enableResizing,\n persistLayout: persistLayout === null ? undefined : persistLayout,\n })\n }) : null\n };\n }\n\n function initialize(options) {\n if (!options) {\n return null;\n }\n\n var chatConfig = options.chatConfig;\n if (!chatConfig && options.configElementSelector) {\n var configElement = document.querySelector(options.configElementSelector);\n chatConfig = configElement ? parseJsonAttribute(configElement, 'data-config', 'AI chat widget config') : null;\n }\n\n if (!chatConfig) {\n return null;\n }\n\n if (options.messageTemplateSelector) {\n var messageTemplate = document.querySelector(options.messageTemplateSelector);\n if (messageTemplate) {\n chatConfig.messageTemplate = messageTemplate.innerHTML;\n }\n }\n\n if (options.indicatorTemplateSelector) {\n var indicatorTemplate = document.querySelector(options.indicatorTemplateSelector);\n if (indicatorTemplate) {\n chatConfig.indicatorTemplate = indicatorTemplate.innerHTML;\n }\n }\n\n var shell = document.querySelector(options.shellSelector);\n var widgetContainer = document.querySelector(options.widgetContainerSelector);\n var toggleButton = document.querySelector(options.toggleButtonSelector);\n var closeButton = document.querySelector(options.closeButtonSelector);\n var profileInput = options.inputSelector ? document.querySelector(options.inputSelector) : null;\n var widgetStateName = options.widgetStateName || chatConfig.widget.chatWidgetStateName;\n var widgetOpenStateKey = options.widgetOpenStateKey || (widgetStateName + 'Open');\n var widgetLayoutKey = widgetStateName + 'Layout';\n var openStateValue = options.openStateValue || 'open';\n var closedStateValue = options.closedStateValue || 'closed';\n\n if (profileInput && options.profile && options.profile.id) {\n profileInput.setAttribute('data-profile-id', options.profile.id);\n }\n\n try {\n var storedLayout = localStorage.getItem(widgetLayoutKey);\n var layout = storedLayout ? JSON.parse(storedLayout) || {} : {};\n var position = layout.position || {};\n var panelLayout = layout.panel || {};\n var toggleLeft = Number(position.left);\n var toggleTop = Number(position.top);\n var isOpen = localStorage.getItem(widgetOpenStateKey) === openStateValue;\n var viewportPadding = 8;\n\n if (shell) {\n shell.dataset.deferReveal = isOpen ? 'true' : 'false';\n shell.dataset.initialOpen = isOpen ? 'true' : 'false';\n }\n\n if (widgetContainer && toggleButton) {\n var toggleSize = 52;\n var panelWidth = Number.isFinite(Number(panelLayout.width))\n ? Number(panelLayout.width)\n : Math.round(parseFloat(window.getComputedStyle(widgetContainer).width) || 380);\n var panelHeight = Number.isFinite(Number(panelLayout.height))\n ? Number(panelLayout.height)\n : Math.round(parseFloat(window.getComputedStyle(widgetContainer).height) || 520);\n var maxLeft = Math.max(viewportPadding, window.innerWidth - toggleSize - viewportPadding);\n var maxTop = Math.max(viewportPadding, window.innerHeight - toggleSize - viewportPadding);\n if (Number.isFinite(Number(position.leftRatio))) {\n toggleLeft = viewportPadding + Math.max(0, maxLeft - viewportPadding) * Number(position.leftRatio);\n }\n if (Number.isFinite(Number(position.topRatio))) {\n toggleTop = viewportPadding + Math.max(0, maxTop - viewportPadding) * Number(position.topRatio);\n }\n if (Number.isFinite(toggleLeft) && Number.isFinite(toggleTop)) {\n toggleLeft = Math.round(clampWidgetValue(toggleLeft, viewportPadding, maxLeft));\n toggleTop = Math.round(clampWidgetValue(toggleTop, viewportPadding, maxTop));\n }\n\n if (Number.isFinite(toggleLeft) && Number.isFinite(toggleTop)) {\n toggleButton.style.left = toggleLeft + 'px';\n toggleButton.style.top = toggleTop + 'px';\n toggleButton.style.right = 'auto';\n toggleButton.style.bottom = 'auto';\n\n var toggleGap = 8;\n widgetContainer.style.left = (toggleLeft + toggleSize - panelWidth) + 'px';\n widgetContainer.style.top = (toggleTop - panelHeight - toggleGap) + 'px';\n widgetContainer.style.right = 'auto';\n widgetContainer.style.bottom = 'auto';\n }\n }\n\n if (widgetContainer) {\n widgetContainer.classList.remove('open');\n widgetContainer.style.display = 'none';\n widgetContainer.setAttribute('aria-hidden', 'true');\n }\n\n if (toggleButton) {\n toggleButton.innerHTML = isOpen ? options.openIconHtml : options.closedIconHtml;\n }\n }\n catch (error) {\n console.warn('Failed to restore widget layout before initialization.', error);\n }\n finally {\n if (shell && shell.dataset.deferReveal !== 'true') {\n shell.style.visibility = '';\n }\n }\n\n var widgetApp = window.coreAIChatManager.initialize(chatConfig);\n if (options.applySessionProfilePatch !== false && window.crestAppsAIChat && window.crestAppsAIChat.patchSessionProfileSync) {\n window.crestAppsAIChat.patchSessionProfileSync(widgetApp);\n }\n\n function revealShell() {\n if (!shell) {\n return;\n }\n\n shell.style.visibility = '';\n shell.dataset.deferReveal = 'false';\n }\n\n function syncOpenPanelPosition() {\n if (!widgetApp || typeof widgetApp.syncPanelPositionToToggle !== 'function') {\n return;\n }\n\n widgetApp.syncPanelPositionToToggle(false);\n }\n\n function updateTtsPlaybackButtons() {\n if (!widgetContainer) {\n return;\n }\n\n var buttons = widgetContainer.querySelectorAll('[data-tts-message-index]');\n buttons.forEach(function (button) {\n var buttonIndex = Number(button.getAttribute('data-tts-message-index'));\n var isPlaying = buttonIndex === widgetApp.ttsPlayingMessageIndex;\n button.classList.toggle('tts-playing', isPlaying);\n button.setAttribute('title', isPlaying ? 'Pause audio' : 'Read aloud');\n });\n }\n\n function queueTtsPlaybackButtonUpdate() {\n requestAnimationFrame(updateTtsPlaybackButtons);\n }\n\n function revealShellWhenStable(initialOpen) {\n if (!shell || shell.dataset.deferReveal !== 'true' || !initialOpen) {\n revealShell();\n return;\n }\n\n var hasRevealed = false;\n var resizeObserver = null;\n\n function finalizeReveal() {\n if (hasRevealed) {\n return;\n }\n\n hasRevealed = true;\n\n if (resizeObserver) {\n resizeObserver.disconnect();\n }\n\n requestAnimationFrame(function () {\n syncOpenPanelPosition();\n requestAnimationFrame(function () {\n revealShell();\n });\n });\n }\n\n if (typeof ResizeObserver === 'undefined') {\n window.setTimeout(finalizeReveal, 0);\n return;\n }\n\n var lastWidth = 0;\n var lastHeight = 0;\n var stablePasses = 0;\n\n resizeObserver = new ResizeObserver(function (entries) {\n var entry = entries && entries[0];\n if (!entry) {\n return;\n }\n\n var width = Math.round(entry.contentRect.width);\n var height = Math.round(entry.contentRect.height);\n if (!width || !height) {\n return;\n }\n\n syncOpenPanelPosition();\n\n if (width === lastWidth && height === lastHeight) {\n stablePasses++;\n }\n else {\n lastWidth = width;\n lastHeight = height;\n stablePasses = 0;\n }\n\n if (stablePasses >= 1) {\n finalizeReveal();\n }\n });\n\n resizeObserver.observe(widgetContainer);\n window.setTimeout(finalizeReveal, 150);\n }\n\n function setWidgetOpen(isOpen) {\n if (widgetApp) {\n var isCurrentlyOpen = widgetContainer.classList.contains('open');\n if (isOpen && !isCurrentlyOpen && typeof widgetApp.syncPanelPositionToToggle === 'function') {\n widgetApp.syncPanelPositionToToggle();\n }\n else if (!isOpen && isCurrentlyOpen && typeof widgetApp.syncTogglePositionToPanel === 'function') {\n widgetApp.syncTogglePositionToPanel();\n }\n }\n\n widgetContainer.classList.toggle('open', isOpen);\n widgetContainer.style.display = isOpen ? 'flex' : 'none';\n widgetContainer.setAttribute('aria-hidden', isOpen ? 'false' : 'true');\n toggleButton.innerHTML = isOpen ? options.openIconHtml : options.closedIconHtml;\n localStorage.setItem(widgetOpenStateKey, isOpen ? openStateValue : closedStateValue);\n\n if (isOpen && typeof window.renderPendingCharts === 'function') {\n setTimeout(function () { window.renderPendingCharts(); }, 100);\n }\n }\n\n var initialOpen = shell && shell.dataset.initialOpen === 'true';\n setWidgetOpen(initialOpen);\n revealShellWhenStable(initialOpen);\n\n if (widgetApp && typeof widgetApp.$watch === 'function') {\n widgetApp.$watch('ttsPlayingMessageIndex', function () {\n queueTtsPlaybackButtonUpdate();\n });\n }\n\n queueTtsPlaybackButtonUpdate();\n\n if (toggleButton) {\n toggleButton.addEventListener('click', function () {\n if (toggleButton.dataset.dragSuppressClick === 'true') {\n toggleButton.dataset.dragSuppressClick = 'false';\n return;\n }\n\n setWidgetOpen(!widgetContainer.classList.contains('open'));\n });\n }\n\n if (closeButton) {\n closeButton.addEventListener('click', function () {\n setWidgetOpen(false);\n });\n }\n\n return widgetApp;\n }\n\n function initializeFromElement(element) {\n if (!element || element.dataset.coreAiChatWidgetInitialized === 'true') {\n return element ? element.__coreAIChatWidgetApp || null : null;\n }\n\n var jsonOptions = parseJsonAttribute(element, 'data-coreai-chat-widget-config', 'CoreAI chat widget config');\n var attributeOptions = buildOptionsFromDataAttributes(element);\n if (!jsonOptions && !attributeOptions) {\n return null;\n }\n\n var options = Object.assign({}, jsonOptions || {}, attributeOptions || {});\n\n var widgetApp = initialize(options);\n if (!widgetApp) {\n return null;\n }\n\n element.dataset.coreAiChatWidgetInitialized = 'true';\n element.__coreAIChatWidgetApp = widgetApp;\n\n return widgetApp;\n }\n\n function scanForAutoInitialization(root) {\n if (!root || typeof root.querySelectorAll !== 'function') {\n return;\n }\n\n if (typeof root.matches === 'function' && root.matches('[data-coreai-chat-widget-config],[data-coreai-chat-widget-container-selector]')) {\n initializeFromElement(root);\n }\n\n root.querySelectorAll('[data-coreai-chat-widget-config],[data-coreai-chat-widget-container-selector]').forEach(initializeFromElement);\n }\n\n function startAutoInitialization() {\n scanForAutoInitialization(document);\n\n if (typeof MutationObserver === 'undefined') {\n return;\n }\n\n var observer = new MutationObserver(function (mutations) {\n mutations.forEach(function (mutation) {\n mutation.addedNodes.forEach(function (node) {\n if (node && node.nodeType === 1) {\n scanForAutoInitialization(node);\n }\n });\n });\n });\n\n observer.observe(document.body, {\n childList: true,\n subtree: true,\n });\n }\n\n if (document.readyState === 'loading') {\n document.addEventListener('DOMContentLoaded', startAutoInitialization, { once: true });\n } else {\n startAutoInitialization();\n }\n\n return {\n initialize: initialize,\n initializeFromElement: initializeFromElement,\n };\n}();\n"]}
|
|
1
|
+
{"version":3,"sources":["ai-chat-widget.js"],"names":["clampWidgetValue","value","min","max","Math","window","coreAIChatWidgetBehavior","parsePixelValue","Number","isFinite","parsed","parseFloat","initialize","app","config","widgetIsInitialized","widget","chatWidgetContainer","chatWidgetStateName","document","querySelector","chatHistorySection","chatWidgetStateSession","chatWidgetStateDocuments","chatWidgetLayoutKey","widgetContainerElement","widgetToggleButtonElement","toggleButtonSelector","widgetResetSizeButtonElement","resetSizeButtonSelector","widgetDefaultWidth","defaultWidth","getComputedStyle","width","widgetDefaultHeight","defaultHeight","height","clearStoredWidgetDocuments","documents","enableResizing","classList","add","style","minWidth","minHeight","ResizeObserver","widgetResizeObserver","persistWidgetPanelSize","constrainWidgetElementsToViewport","updateWidgetResetSizeButtonVisibility","observe","dragHandleSelector","dragHandle","enableDragging","attachDraggableWidgetElement","addEventListener","event","preventDefault","resetWidgetSize","restoreWidgetLayout","widgetViewportResizeHandler","persistLayout","reloadCurrentSession","autoCreateSession","getSessionId","startNewSession","showHistoryButton","toggle","closeHistoryButton","showChatScreen","newChatButton","resetSession","console","error","dispose","disconnect","removeEventListener","attach","__aiChatWidgetAttached","getStoredWidgetLayout","this","storedLayout","localStorage","getItem","JSON","parse","warn","saveStoredWidgetLayout","partialLayout","currentLayout","nextLayout","Object","assign","undefined","panel","position","setItem","stringify","getElementSize","element","fallbackWidth","fallbackHeight","rect","getBoundingClientRect","computed","round","getElementPosition","left","top","inlineLeft","inlineTop","computedLeft","computedTop","isHidden","display","getAvailableWidgetPositionRange","padding","maxLeft","innerWidth","maxTop","innerHeight","createStoredPosition","range","leftSpan","topSpan","leftRatio","topRatio","resolveStoredPosition","storedPosition","clampWidgetPosition","getStoredWidgetDocuments","saveStoredWidgetDocuments","removeItem","applyAbsolutePosition","right","bottom","getWidgetDefaultSize","getWidgetToggleGap","isWidgetPanelVisible","contains","persistWidgetPanelPosition","panelDefaultSize","panelPosition","panelSize","toggleSize","linkedPosition","persistWidgetTogglePosition","togglePosition","defaultSize","currentSize","abs","syncTogglePositionToPanel","syncPanelPositionToToggle","isResized","removeProperty","storedTogglePosition","handle","layoutKey","suppressClickOnDrag","activePointerId","startX","startY","startLeft","startTop","dragged","self","button","target","closest","clientX","clientY","pointerId","setPointerCapture","onPointerMove","stopDragging","remove","dataset","dragSuppressClick","setTimeout","deltaX","deltaY","hypot","nextPosition","clampedPanel","clampedToggle","onMounted","resolveSessionId","onSessionInitialized","sessionId","onSessionReset","onDocumentsChanged","handleReceiveError","isSessionStarted","_attemptedSessionRecovery","onBeforeUnmount","coreAIChatWidgetManager","getAttributeValue","attributeName","getAttribute","parseBooleanAttributeValue","normalized","String","trim","toLowerCase","parseJsonAttribute","description","rawValue","options","chatConfig","configElementSelector","configElement","messageTemplateSelector","messageTemplate","innerHTML","indicatorTemplateSelector","indicatorTemplate","shell","shellSelector","widgetContainer","widgetContainerSelector","toggleButton","closeButton","closeButtonSelector","profileInput","inputSelector","widgetStateName","widgetOpenStateKey","widgetLayoutKey","openStateValue","closedStateValue","profile","id","setAttribute","layout","panelLayout","toggleLeft","toggleTop","isOpen","deferReveal","initialOpen","panelWidth","panelHeight","openIconHtml","closedIconHtml","visibility","widgetApp","coreAIChatManager","revealShell","syncOpenPanelPosition","updateTtsPlaybackButtons","querySelectorAll","forEach","isPlaying","ttsPlayingMessageIndex","queueTtsPlaybackButtonUpdate","requestAnimationFrame","setWidgetOpen","isCurrentlyOpen","renderPendingCharts","applySessionProfilePatch","crestAppsAIChat","patchSessionProfileSync","hasRevealed","resizeObserver","lastWidth","lastHeight","stablePasses","entries","entry","contentRect","finalizeReveal","revealShellWhenStable","$watch","initializeFromElement","coreAiChatWidgetInitialized","__coreAIChatWidgetApp","jsonOptions","attributeOptions","buildConfigFromElement","allowWidgetHost","profileId","profileName","profileDisplayText","profileWelcomeMessage","profileChatMode","profileTtsVoiceName","profileMetricsEnabled","profileSessionDocuments","name","displayText","welcomeMessage","chatMode","ttsVoiceName","enableSessionMetrics","allowSessionDocuments","buildOptionsFromDataAttributes","scanForAutoInitialization","root","matches","startAutoInitialization","Mutation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C,EAAYxC,EACtDd,eAAmC,OAAnBA,OAA0BsD,EAAYtD,EACtDsB,cAAiC,OAAlBA,OAAyBgC,EAAYhC,MAEvD,KAEb,CA4R2B0O,CAA+BpM,GACtD,IAAKiL,IAAgBC,EACjB,OAAO,KAGX,IAEIhC,EAAYzO,EAFF+E,OAAOC,OAAO,CAAC,EAAGwL,GAAe,CAAC,EAAGC,GAAoB,CAAC,IAGxE,OAAKhC,GAILlJ,EAAQ6E,QAAQkG,4BAA8B,OAC9C/K,EAAQgL,sBAAwB9B,EAEzBA,GANI,IAOf,CAEA,SAASmD,EAA0BC,GAC1BA,GAAyC,mBAA1BA,EAAK/C,mBAIG,mBAAjB+C,EAAKC,SAA0BD,EAAKC,QAAQ,kFACnDzB,EAAsBwB,GAG1BA,EAAK/C,iBAAiB,iFAAiFC,QAAQsB,GACnH,CAEA,SAAS0B,KACLH,EAA0BrR,UAEM,oBAArByR,mBAII,IAAIA,iBAAiB,SAAUC,GAC1CA,EAAUlD,QAAQ,SAAUmD,GACxBA,EAASC,WAAWpD,QAAQ,SAAUqD,GAC9BA,GAA0B,IAAlBA,EAAKC,UACbT,EAA0BQ,EAElC,EACJ,EACJ,GAES9P,QAAQ/B,SAAS+R,KAAM,CAC5BC,WAAW,EACXC,SAAS,GAEjB,CAQA,MAN4B,YAAxBjS,SAASkS,WACTlS,SAASoC,iBAAiB,mBAAoBoP,EAAyB,CAAEW,MAAM,IAE/EX,IAGG,CACH/R,WAAYA,EACZqQ,sBAAuBA,EAE/B,CAvcmE","file":"ai-chat-widget.min.js","sourcesContent":["function clampWidgetValue(value, min, max) {\n return Math.min(Math.max(value, min), max);\n}\n\nwindow.coreAIChatWidgetBehavior = window.coreAIChatWidgetBehavior || function () {\n function parsePixelValue(value) {\n if (typeof value === 'number' && Number.isFinite(value)) {\n return value;\n }\n\n if (typeof value !== 'string') {\n return null;\n }\n\n var parsed = parseFloat(value);\n return Number.isFinite(parsed) ? parsed : null;\n }\n\n function attach(app, config) {\n if (!app || app.__aiChatWidgetAttached) {\n return;\n }\n\n app.__aiChatWidgetAttached = true;\n app.chatWidgetStateName = null;\n app.chatWidgetStateSession = null;\n app.chatWidgetStateDocuments = null;\n app.chatWidgetLayoutKey = null;\n app.chatHistorySection = null;\n app.widgetContainerElement = null;\n app.widgetToggleButtonElement = null;\n app.widgetResetSizeButtonElement = null;\n app.widgetResizeObserver = null;\n app.widgetViewportResizeHandler = null;\n app.widgetDefaultWidth = null;\n app.widgetDefaultHeight = null;\n app.widgetIsInitialized = false;\n\n app.getStoredWidgetLayout = function () {\n if (!this.chatWidgetLayoutKey || !config.widget.persistLayout) {\n return {};\n }\n\n try {\n var storedLayout = localStorage.getItem(this.chatWidgetLayoutKey);\n return storedLayout ? JSON.parse(storedLayout) || {} : {};\n }\n catch (error) {\n console.warn('Failed to read widget layout state.', error);\n return {};\n }\n };\n\n app.saveStoredWidgetLayout = function (partialLayout) {\n if (!this.chatWidgetLayoutKey || !config.widget.persistLayout) {\n return;\n }\n\n var currentLayout = this.getStoredWidgetLayout();\n var nextLayout = Object.assign({}, currentLayout);\n\n if (partialLayout.panel !== undefined) {\n nextLayout.panel = Object.assign({}, currentLayout.panel || {}, partialLayout.panel || {});\n }\n\n if (partialLayout.position !== undefined) {\n nextLayout.position = Object.assign({}, currentLayout.position || {}, partialLayout.position || {});\n }\n\n localStorage.setItem(this.chatWidgetLayoutKey, JSON.stringify(nextLayout));\n };\n\n app.getElementSize = function (element, fallbackWidth, fallbackHeight) {\n if (!element) {\n return {\n width: fallbackWidth || 0,\n height: fallbackHeight || 0\n };\n }\n\n var rect = element.getBoundingClientRect();\n var computed = window.getComputedStyle(element);\n\n return {\n width: Math.round(rect.width || parsePixelValue(computed.width) || fallbackWidth || 0),\n height: Math.round(rect.height || parsePixelValue(computed.height) || fallbackHeight || 0)\n };\n };\n\n app.getElementPosition = function (element) {\n if (!element) {\n return {\n left: 0,\n top: 0\n };\n }\n\n var rect = element.getBoundingClientRect();\n var computed = window.getComputedStyle(element);\n var inlineLeft = parsePixelValue(element.style.left);\n var inlineTop = parsePixelValue(element.style.top);\n var computedLeft = parsePixelValue(computed.left);\n var computedTop = parsePixelValue(computed.top);\n var isHidden = computed.display === 'none';\n\n return {\n left: Math.round(isHidden && Number.isFinite(inlineLeft) ? inlineLeft : rect.left || inlineLeft || computedLeft || 0),\n top: Math.round(isHidden && Number.isFinite(inlineTop) ? inlineTop : rect.top || inlineTop || computedTop || 0)\n };\n };\n\n app.getAvailableWidgetPositionRange = function (width, height) {\n var viewportPadding = 8;\n return {\n padding: viewportPadding,\n maxLeft: Math.max(viewportPadding, window.innerWidth - width - viewportPadding),\n maxTop: Math.max(viewportPadding, window.innerHeight - height - viewportPadding)\n };\n };\n\n app.createStoredPosition = function (left, top, width, height) {\n var range = this.getAvailableWidgetPositionRange(width, height);\n var leftSpan = Math.max(0, range.maxLeft - range.padding);\n var topSpan = Math.max(0, range.maxTop - range.padding);\n\n return {\n left: Math.round(left),\n top: Math.round(top),\n leftRatio: leftSpan === 0 ? 0 : (left - range.padding) / leftSpan,\n topRatio: topSpan === 0 ? 0 : (top - range.padding) / topSpan\n };\n };\n\n app.resolveStoredPosition = function (storedPosition, width, height) {\n if (!storedPosition) {\n return null;\n }\n\n var range = this.getAvailableWidgetPositionRange(width, height);\n var left = Number(storedPosition.left);\n var top = Number(storedPosition.top);\n var leftRatio = Number(storedPosition.leftRatio);\n var topRatio = Number(storedPosition.topRatio);\n\n if (Number.isFinite(leftRatio)) {\n left = range.padding + Math.max(0, range.maxLeft - range.padding) * leftRatio;\n }\n\n if (Number.isFinite(topRatio)) {\n top = range.padding + Math.max(0, range.maxTop - range.padding) * topRatio;\n }\n\n if (!Number.isFinite(left) || !Number.isFinite(top)) {\n return null;\n }\n\n return this.clampWidgetPosition(left, top, width, height);\n };\n\n app.clampWidgetPosition = function (left, top, width, height) {\n var range = this.getAvailableWidgetPositionRange(width, height);\n\n return {\n left: Math.round(clampWidgetValue(left, range.padding, range.maxLeft)),\n top: Math.round(clampWidgetValue(top, range.padding, range.maxTop))\n };\n };\n\n app.getStoredWidgetDocuments = function () {\n this.clearStoredWidgetDocuments();\n return [];\n };\n\n app.saveStoredWidgetDocuments = function () {\n this.clearStoredWidgetDocuments();\n };\n\n app.clearStoredWidgetDocuments = function () {\n if (!this.chatWidgetStateDocuments) {\n return;\n }\n\n localStorage.removeItem(this.chatWidgetStateDocuments);\n };\n\n app.applyAbsolutePosition = function (element, left, top) {\n if (!element) {\n return;\n }\n\n element.style.left = left + 'px';\n element.style.top = top + 'px';\n element.style.right = 'auto';\n element.style.bottom = 'auto';\n };\n\n app.getWidgetDefaultSize = function () {\n return {\n width: this.widgetDefaultWidth || parsePixelValue(config.widget.defaultWidth) || 380,\n height: this.widgetDefaultHeight || parsePixelValue(config.widget.defaultHeight) || 520\n };\n };\n\n app.getWidgetToggleGap = function () {\n return 8;\n };\n\n app.isWidgetPanelVisible = function () {\n if (!this.widgetContainerElement) {\n return false;\n }\n\n var computed = window.getComputedStyle(this.widgetContainerElement);\n return this.widgetContainerElement.classList.contains('open') && computed.display !== 'none';\n };\n\n app.persistWidgetPanelPosition = function () {\n if (!this.widgetContainerElement || !config.widget.persistLayout) {\n return;\n }\n\n var panelDefaultSize = this.getWidgetDefaultSize();\n var panelPosition = this.getElementPosition(this.widgetContainerElement);\n var panelSize = this.getElementSize(this.widgetContainerElement, panelDefaultSize.width, panelDefaultSize.height);\n var toggleSize = this.getElementSize(this.widgetToggleButtonElement, 52, 52);\n var linkedPosition = this.clampWidgetPosition(\n panelPosition.left + panelSize.width - toggleSize.width,\n panelPosition.top + panelSize.height + this.getWidgetToggleGap(),\n toggleSize.width,\n toggleSize.height);\n\n this.saveStoredWidgetLayout({ position: this.createStoredPosition(linkedPosition.left, linkedPosition.top, toggleSize.width, toggleSize.height) });\n };\n\n app.persistWidgetTogglePosition = function () {\n if (!this.widgetToggleButtonElement || !config.widget.persistLayout) {\n return;\n }\n\n var togglePosition = this.getElementPosition(this.widgetToggleButtonElement);\n var toggleSize = this.getElementSize(this.widgetToggleButtonElement, 52, 52);\n this.saveStoredWidgetLayout({ position: this.createStoredPosition(togglePosition.left, togglePosition.top, toggleSize.width, toggleSize.height) });\n };\n\n app.persistWidgetPanelSize = function () {\n if (!this.widgetContainerElement || !config.widget.enableResizing || !config.widget.persistLayout) {\n return;\n }\n\n var defaultSize = this.getWidgetDefaultSize();\n var currentSize = this.getElementSize(this.widgetContainerElement, defaultSize.width, defaultSize.height);\n\n this.saveStoredWidgetLayout({\n panel: {\n width: Math.abs(currentSize.width - defaultSize.width) <= 1 ? null : currentSize.width,\n height: Math.abs(currentSize.height - defaultSize.height) <= 1 ? null : currentSize.height\n }\n });\n };\n\n app.syncTogglePositionToPanel = function (persistLayout) {\n if (persistLayout === undefined) {\n persistLayout = true;\n }\n\n if (!this.widgetContainerElement || !this.widgetToggleButtonElement) {\n return;\n }\n\n var panelDefaultSize = this.getWidgetDefaultSize();\n var panelSize = this.getElementSize(this.widgetContainerElement, panelDefaultSize.width, panelDefaultSize.height);\n var toggleSize = this.getElementSize(this.widgetToggleButtonElement, 52, 52);\n var panelPosition = this.getElementPosition(this.widgetContainerElement);\n var linkedPosition = this.clampWidgetPosition(\n panelPosition.left + panelSize.width - toggleSize.width,\n panelPosition.top + panelSize.height + this.getWidgetToggleGap(),\n toggleSize.width,\n toggleSize.height);\n\n this.applyAbsolutePosition(this.widgetToggleButtonElement, linkedPosition.left, linkedPosition.top);\n\n if (persistLayout && config.widget.persistLayout) {\n this.persistWidgetTogglePosition();\n }\n };\n\n app.syncPanelPositionToToggle = function (persistLayout) {\n if (persistLayout === undefined) {\n persistLayout = true;\n }\n\n if (!this.widgetContainerElement || !this.widgetToggleButtonElement) {\n return;\n }\n\n var panelDefaultSize = this.getWidgetDefaultSize();\n var panelSize = this.getElementSize(this.widgetContainerElement, panelDefaultSize.width, panelDefaultSize.height);\n var toggleSize = this.getElementSize(this.widgetToggleButtonElement, 52, 52);\n var togglePosition = this.getElementPosition(this.widgetToggleButtonElement);\n var linkedPosition = this.clampWidgetPosition(\n togglePosition.left + toggleSize.width - panelSize.width,\n togglePosition.top - panelSize.height - this.getWidgetToggleGap(),\n panelSize.width,\n panelSize.height);\n\n this.applyAbsolutePosition(this.widgetContainerElement, linkedPosition.left, linkedPosition.top);\n\n if (persistLayout && config.widget.persistLayout) {\n this.persistWidgetPanelPosition();\n }\n };\n\n app.updateWidgetResetSizeButtonVisibility = function () {\n if (!this.widgetResetSizeButtonElement) {\n return;\n }\n\n if (!config.widget.enableResizing || !this.widgetContainerElement) {\n this.widgetResetSizeButtonElement.classList.add('d-none');\n return;\n }\n\n var defaultSize = this.getWidgetDefaultSize();\n var currentSize = this.getElementSize(this.widgetContainerElement, defaultSize.width, defaultSize.height);\n var isResized =\n Math.abs(currentSize.width - defaultSize.width) > 1 ||\n Math.abs(currentSize.height - defaultSize.height) > 1 ||\n !!this.widgetContainerElement.style.width ||\n !!this.widgetContainerElement.style.height;\n\n this.widgetResetSizeButtonElement.classList.toggle('d-none', !isResized);\n };\n\n app.resetWidgetSize = function () {\n if (!this.widgetContainerElement || !config.widget.enableResizing) {\n return;\n }\n\n this.widgetContainerElement.style.removeProperty('width');\n this.widgetContainerElement.style.removeProperty('height');\n this.persistWidgetPanelSize();\n this.constrainWidgetElementsToViewport();\n this.updateWidgetResetSizeButtonVisibility();\n };\n\n app.restoreWidgetLayout = function () {\n var storedLayout = this.getStoredWidgetLayout();\n\n if (this.widgetContainerElement && config.widget.enableResizing) {\n if (Number.isFinite(storedLayout.panel && storedLayout.panel.width)) {\n this.widgetContainerElement.style.width = storedLayout.panel.width + 'px';\n }\n else {\n this.widgetContainerElement.style.removeProperty('width');\n }\n\n if (Number.isFinite(storedLayout.panel && storedLayout.panel.height)) {\n this.widgetContainerElement.style.height = storedLayout.panel.height + 'px';\n }\n else {\n this.widgetContainerElement.style.removeProperty('height');\n }\n }\n\n var toggleSize = this.getElementSize(this.widgetToggleButtonElement, 52, 52);\n var storedTogglePosition = this.resolveStoredPosition(storedLayout.position, toggleSize.width, toggleSize.height);\n if (this.widgetToggleButtonElement && config.widget.enableDragging && storedTogglePosition) {\n this.applyAbsolutePosition(this.widgetToggleButtonElement, storedTogglePosition.left, storedTogglePosition.top);\n this.syncPanelPositionToToggle(false);\n }\n else if (this.widgetToggleButtonElement && config.widget.enableDragging &&\n Number.isFinite(storedLayout.toggle && storedLayout.toggle.left) &&\n Number.isFinite(storedLayout.toggle && storedLayout.toggle.top)) {\n this.applyAbsolutePosition(this.widgetToggleButtonElement, storedLayout.toggle.left, storedLayout.toggle.top);\n this.syncPanelPositionToToggle(false);\n }\n else if (this.widgetContainerElement && config.widget.enableDragging &&\n Number.isFinite(storedLayout.panel && storedLayout.panel.left) &&\n Number.isFinite(storedLayout.panel && storedLayout.panel.top)) {\n this.applyAbsolutePosition(this.widgetContainerElement, storedLayout.panel.left, storedLayout.panel.top);\n this.syncTogglePositionToPanel(false);\n }\n\n this.constrainWidgetElementsToViewport();\n this.updateWidgetResetSizeButtonVisibility();\n };\n\n app.attachDraggableWidgetElement = function (element, handle, layoutKey, suppressClickOnDrag) {\n if (!element || !handle || !config.widget.enableDragging) {\n return;\n }\n\n var activePointerId = null;\n var startX = 0;\n var startY = 0;\n var startLeft = 0;\n var startTop = 0;\n var dragged = false;\n var dragThreshold = 4;\n var interactiveSelector = 'button, a, input, textarea, select, option, label';\n var self = this;\n\n function stopDragging(event) {\n if (activePointerId === null) {\n return;\n }\n\n if (event && event.pointerId !== undefined && event.pointerId !== activePointerId) {\n return;\n }\n\n document.removeEventListener('pointermove', onPointerMove);\n document.removeEventListener('pointerup', stopDragging);\n document.removeEventListener('pointercancel', stopDragging);\n element.classList.remove('ai-chat-widget-dragging');\n activePointerId = null;\n\n if (!dragged) {\n return;\n }\n\n if (layoutKey === 'panel') {\n self.syncTogglePositionToPanel(false);\n self.persistWidgetPanelPosition();\n }\n else if (layoutKey === 'toggle') {\n self.syncPanelPositionToToggle(false);\n self.persistWidgetTogglePosition();\n }\n\n if (config.widget.persistLayout) {\n self.persistWidgetPanelPosition();\n self.persistWidgetTogglePosition();\n }\n\n if (suppressClickOnDrag) {\n element.dataset.dragSuppressClick = 'true';\n window.setTimeout(function () {\n if (element.dataset.dragSuppressClick === 'true') {\n element.dataset.dragSuppressClick = 'false';\n }\n }, 0);\n }\n }\n\n function onPointerMove(event) {\n if (activePointerId === null || event.pointerId !== activePointerId) {\n return;\n }\n\n var deltaX = event.clientX - startX;\n var deltaY = event.clientY - startY;\n\n if (!dragged && Math.hypot(deltaX, deltaY) < dragThreshold) {\n return;\n }\n\n dragged = true;\n\n var defaultSize = self.getWidgetDefaultSize();\n var currentSize = self.getElementSize(\n element,\n layoutKey === 'panel' ? defaultSize.width : 52,\n layoutKey === 'panel' ? defaultSize.height : 52);\n var nextPosition = self.clampWidgetPosition(startLeft + deltaX, startTop + deltaY, currentSize.width, currentSize.height);\n\n self.applyAbsolutePosition(element, nextPosition.left, nextPosition.top);\n\n if (layoutKey === 'panel') {\n self.syncTogglePositionToPanel(false);\n }\n else if (layoutKey === 'toggle') {\n self.syncPanelPositionToToggle(false);\n }\n }\n\n handle.addEventListener('pointerdown', function (event) {\n if (event.button !== 0) {\n return;\n }\n\n if (layoutKey === 'panel' && event.target.closest(interactiveSelector)) {\n return;\n }\n\n var rect = element.getBoundingClientRect();\n startX = event.clientX;\n startY = event.clientY;\n startLeft = rect.left;\n startTop = rect.top;\n dragged = false;\n activePointerId = event.pointerId;\n element.classList.add('ai-chat-widget-dragging');\n\n if (handle.setPointerCapture) {\n handle.setPointerCapture(event.pointerId);\n }\n\n document.addEventListener('pointermove', onPointerMove);\n document.addEventListener('pointerup', stopDragging);\n document.addEventListener('pointercancel', stopDragging);\n event.preventDefault();\n });\n };\n\n app.constrainWidgetElementsToViewport = function () {\n if (this.widgetContainerElement && this.widgetContainerElement.style.left && this.isWidgetPanelVisible()) {\n var panelDefaultSize = this.getWidgetDefaultSize();\n var panelSize = this.getElementSize(this.widgetContainerElement, panelDefaultSize.width, panelDefaultSize.height);\n var panelPosition = this.getElementPosition(this.widgetContainerElement);\n var clampedPanel = this.clampWidgetPosition(panelPosition.left, panelPosition.top, panelSize.width, panelSize.height);\n\n this.applyAbsolutePosition(this.widgetContainerElement, clampedPanel.left, clampedPanel.top);\n this.syncTogglePositionToPanel(false);\n\n if (config.widget.persistLayout) {\n this.persistWidgetPanelPosition();\n this.persistWidgetTogglePosition();\n }\n }\n else if (this.widgetToggleButtonElement && this.widgetToggleButtonElement.style.left) {\n var toggleSize = this.getElementSize(this.widgetToggleButtonElement, 52, 52);\n var togglePosition = this.getElementPosition(this.widgetToggleButtonElement);\n var clampedToggle = this.clampWidgetPosition(togglePosition.left, togglePosition.top, toggleSize.width, toggleSize.height);\n\n this.applyAbsolutePosition(this.widgetToggleButtonElement, clampedToggle.left, clampedToggle.top);\n this.syncPanelPositionToToggle(false);\n\n if (config.widget.persistLayout) {\n this.persistWidgetTogglePosition();\n this.persistWidgetPanelPosition();\n }\n }\n };\n\n app.showChatScreen = function () {\n if (!this.chatHistorySection) {\n return;\n }\n\n this.chatHistorySection.classList.remove('show');\n };\n }\n\n function initialize(app, config) {\n if (!app || app.widgetIsInitialized) {\n return;\n }\n\n if (!config.widget.chatWidgetContainer) {\n console.error('The widget chatWidgetContainer is required.');\n return;\n }\n\n if (!config.widget.chatWidgetStateName) {\n console.error('The widget chatWidgetStateName is required.');\n return;\n }\n\n var chatWidgetContainer = document.querySelector(config.widget.chatWidgetContainer);\n if (!chatWidgetContainer) {\n return;\n }\n\n if (config.widget.chatHistorySection) {\n app.chatHistorySection = document.querySelector(config.widget.chatHistorySection);\n }\n\n app.chatWidgetStateName = config.widget.chatWidgetStateName;\n app.chatWidgetStateSession = config.widget.chatWidgetStateName + 'Session';\n app.chatWidgetStateDocuments = config.widget.chatWidgetStateName + 'Documents';\n app.chatWidgetLayoutKey = config.widget.chatWidgetStateName + 'Layout';\n app.widgetContainerElement = chatWidgetContainer;\n app.widgetToggleButtonElement = config.widget.toggleButtonSelector ? document.querySelector(config.widget.toggleButtonSelector) : null;\n app.widgetResetSizeButtonElement = config.widget.resetSizeButtonSelector ? document.querySelector(config.widget.resetSizeButtonSelector) : null;\n app.widgetDefaultWidth = parsePixelValue(config.widget.defaultWidth) || parsePixelValue(window.getComputedStyle(chatWidgetContainer).width) || 380;\n app.widgetDefaultHeight = parsePixelValue(config.widget.defaultHeight) || parsePixelValue(window.getComputedStyle(chatWidgetContainer).height) || 520;\n app.widgetIsInitialized = true;\n app.clearStoredWidgetDocuments();\n app.documents = [];\n\n if (config.widget.enableResizing) {\n chatWidgetContainer.classList.add('ai-chat-widget-resizable');\n chatWidgetContainer.style.minWidth = (parsePixelValue(config.widget.minWidth) || 320) + 'px';\n chatWidgetContainer.style.minHeight = (parsePixelValue(config.widget.minHeight) || 420) + 'px';\n\n if (typeof ResizeObserver !== 'undefined') {\n app.widgetResizeObserver = new ResizeObserver(function () {\n app.persistWidgetPanelSize();\n app.constrainWidgetElementsToViewport();\n app.updateWidgetResetSizeButtonVisibility();\n });\n\n app.widgetResizeObserver.observe(chatWidgetContainer);\n }\n }\n\n var dragHandleSelector = config.widget.dragHandleSelector || '.ai-chat-widget-header';\n var dragHandle = chatWidgetContainer.querySelector(dragHandleSelector);\n\n if (config.widget.enableDragging && dragHandle) {\n dragHandle.classList.add('ai-chat-widget-drag-handle');\n chatWidgetContainer.classList.add('ai-chat-widget-draggable');\n app.attachDraggableWidgetElement(chatWidgetContainer, dragHandle, 'panel', false);\n }\n\n if (config.widget.enableDragging && app.widgetToggleButtonElement) {\n app.widgetToggleButtonElement.classList.add('ai-chat-widget-draggable');\n app.attachDraggableWidgetElement(app.widgetToggleButtonElement, app.widgetToggleButtonElement, 'toggle', true);\n }\n\n if (app.widgetResetSizeButtonElement) {\n app.widgetResetSizeButtonElement.addEventListener('click', function (event) {\n event.preventDefault();\n app.resetWidgetSize();\n });\n }\n\n app.restoreWidgetLayout();\n\n if (!app.widgetViewportResizeHandler) {\n app.widgetViewportResizeHandler = function () {\n if (config.widget.persistLayout) {\n app.restoreWidgetLayout();\n } else {\n app.constrainWidgetElementsToViewport();\n }\n\n app.updateWidgetResetSizeButtonVisibility();\n };\n\n window.addEventListener('resize', app.widgetViewportResizeHandler);\n }\n\n app.reloadCurrentSession();\n\n if (config.autoCreateSession && !app.getSessionId()) {\n app.startNewSession();\n }\n\n if (config.widget.showHistoryButton && app.chatHistorySection) {\n var showHistoryButton = document.querySelector(config.widget.showHistoryButton);\n if (showHistoryButton) {\n showHistoryButton.addEventListener('click', function () {\n app.chatHistorySection.classList.toggle('show');\n });\n }\n\n if (config.widget.closeHistoryButton) {\n var closeHistoryButton = document.querySelector(config.widget.closeHistoryButton);\n if (closeHistoryButton) {\n closeHistoryButton.addEventListener('click', function () {\n app.showChatScreen();\n });\n }\n }\n }\n\n if (config.widget.newChatButton) {\n var newChatButton = document.querySelector(config.widget.newChatButton);\n if (newChatButton) {\n newChatButton.addEventListener('click', function () {\n app.resetSession();\n app.showChatScreen();\n });\n }\n }\n }\n\n function resolveSessionId(app) {\n if (!app || !app.widgetIsInitialized) {\n return null;\n }\n\n return localStorage.getItem(app.chatWidgetStateSession);\n }\n\n function onSessionInitialized(app, sessionId) {\n if (app && app.widgetIsInitialized) {\n localStorage.setItem(app.chatWidgetStateSession, sessionId);\n }\n }\n\n function onSessionReset(app) {\n if (app && app.widgetIsInitialized) {\n localStorage.removeItem(app.chatWidgetStateSession);\n app.clearStoredWidgetDocuments();\n }\n }\n\n function onDocumentsChanged(app, documents) {\n if (app && app.widgetIsInitialized) {\n app.saveStoredWidgetDocuments(documents);\n }\n }\n\n function handleReceiveError(app) {\n if (app && app.widgetIsInitialized && !app.isSessionStarted && !app._attemptedSessionRecovery) {\n app._attemptedSessionRecovery = true;\n localStorage.removeItem(app.chatWidgetStateSession);\n app.clearStoredWidgetDocuments();\n app.startNewSession();\n }\n }\n\n function dispose(app) {\n if (!app) {\n return;\n }\n\n if (app.widgetResizeObserver) {\n app.widgetResizeObserver.disconnect();\n app.widgetResizeObserver = null;\n }\n\n if (app.widgetViewportResizeHandler) {\n window.removeEventListener('resize', app.widgetViewportResizeHandler);\n app.widgetViewportResizeHandler = null;\n }\n }\n\n return {\n attach: attach,\n initialize: initialize,\n onMounted: initialize,\n resolveSessionId: resolveSessionId,\n onSessionInitialized: onSessionInitialized,\n onSessionReset: onSessionReset,\n onDocumentsChanged: onDocumentsChanged,\n handleReceiveError: handleReceiveError,\n dispose: dispose,\n onBeforeUnmount: dispose\n };\n}();\n\nwindow.coreAIChatWidgetManager = window.coreAIChatWidgetManager || function () {\n function getAttributeValue(element, attributeName) {\n var value = element.getAttribute(attributeName);\n return value === null || value === '' ? null : value;\n }\n\n function parseBooleanAttributeValue(value) {\n if (value === null || value === undefined) {\n return null;\n }\n\n if (typeof value === 'boolean') {\n return value;\n }\n\n var normalized = String(value).trim().toLowerCase();\n if (normalized === 'true') {\n return true;\n }\n\n if (normalized === 'false') {\n return false;\n }\n\n return null;\n }\n\n function parseJsonAttribute(element, attributeName, description) {\n var rawValue = getAttributeValue(element, attributeName);\n if (!rawValue) {\n return null;\n }\n\n try {\n return JSON.parse(rawValue);\n }\n catch (error) {\n console.error('Failed to parse ' + description + ' JSON.', error);\n return null;\n }\n }\n\n function buildOptionsFromDataAttributes(element) {\n var widgetContainerSelector = getAttributeValue(element, 'data-coreai-chat-widget-container-selector');\n if (!widgetContainerSelector) {\n return null;\n }\n\n var chatConfig = null;\n if (window.coreAIChatManager && typeof window.coreAIChatManager.buildConfigFromElement === 'function') {\n chatConfig = window.coreAIChatManager.buildConfigFromElement(element, { allowWidgetHost: true });\n }\n\n var profileId = getAttributeValue(element, 'data-coreai-chat-widget-profile-id');\n var profileName = getAttributeValue(element, 'data-coreai-chat-widget-profile-name');\n var profileDisplayText = getAttributeValue(element, 'data-coreai-chat-widget-profile-display-text');\n var profileWelcomeMessage = getAttributeValue(element, 'data-coreai-chat-widget-profile-welcome-message');\n var profileChatMode = getAttributeValue(element, 'data-coreai-chat-widget-profile-chat-mode');\n var profileTtsVoiceName = getAttributeValue(element, 'data-coreai-chat-widget-profile-tts-voice-name');\n var profileMetricsEnabled = parseBooleanAttributeValue(getAttributeValue(element, 'data-coreai-chat-widget-profile-enable-session-metrics'));\n var profileSessionDocuments = parseBooleanAttributeValue(getAttributeValue(element, 'data-coreai-chat-widget-profile-allow-session-documents'));\n var profile = null;\n\n if (profileId || profileName || profileDisplayText || profileWelcomeMessage || profileChatMode || profileTtsVoiceName || profileMetricsEnabled !== null || profileSessionDocuments !== null) {\n profile = {\n id: profileId,\n name: profileName,\n displayText: profileDisplayText,\n welcomeMessage: profileWelcomeMessage,\n chatMode: profileChatMode,\n ttsVoiceName: profileTtsVoiceName,\n enableSessionMetrics: profileMetricsEnabled === true,\n allowSessionDocuments: profileSessionDocuments === true\n };\n }\n\n var enableDragging = parseBooleanAttributeValue(getAttributeValue(element, 'data-coreai-chat-widget-enable-dragging'));\n var enableResizing = parseBooleanAttributeValue(getAttributeValue(element, 'data-coreai-chat-widget-enable-resizing'));\n var persistLayout = parseBooleanAttributeValue(getAttributeValue(element, 'data-coreai-chat-widget-persist-layout'));\n\n return {\n shellSelector: getAttributeValue(element, 'data-coreai-chat-widget-shell-selector'),\n widgetContainerSelector: widgetContainerSelector,\n toggleButtonSelector: getAttributeValue(element, 'data-coreai-chat-widget-toggle-button-selector'),\n closeButtonSelector: getAttributeValue(element, 'data-coreai-chat-widget-close-button-selector'),\n inputSelector: getAttributeValue(element, 'data-coreai-chat-widget-input-selector'),\n messageTemplateSelector: getAttributeValue(element, 'data-coreai-chat-widget-message-template-selector'),\n indicatorTemplateSelector: getAttributeValue(element, 'data-coreai-chat-widget-indicator-template-selector'),\n profile: profile,\n widgetStateName: getAttributeValue(element, 'data-coreai-chat-widget-state-name'),\n openStateValue: getAttributeValue(element, 'data-coreai-chat-widget-open-state-value'),\n closedStateValue: getAttributeValue(element, 'data-coreai-chat-widget-closed-state-value'),\n openIconHtml: getAttributeValue(element, 'data-coreai-chat-widget-open-icon-html'),\n closedIconHtml: getAttributeValue(element, 'data-coreai-chat-widget-closed-icon-html'),\n chatConfig: chatConfig ? Object.assign({}, chatConfig, {\n widget: Object.assign({}, chatConfig.widget || {}, {\n chatWidgetContainer: widgetContainerSelector,\n chatWidgetStateName: getAttributeValue(element, 'data-coreai-chat-widget-state-name'),\n newChatButton: getAttributeValue(element, 'data-coreai-chat-widget-new-chat-button-selector'),\n toggleButtonSelector: getAttributeValue(element, 'data-coreai-chat-widget-toggle-button-selector'),\n resetSizeButtonSelector: getAttributeValue(element, 'data-coreai-chat-widget-reset-size-button-selector'),\n dragHandleSelector: getAttributeValue(element, 'data-coreai-chat-widget-drag-handle-selector'),\n enableDragging: enableDragging === null ? undefined : enableDragging,\n enableResizing: enableResizing === null ? undefined : enableResizing,\n persistLayout: persistLayout === null ? undefined : persistLayout,\n })\n }) : null\n };\n }\n\n function initialize(options) {\n if (!options) {\n return null;\n }\n\n var chatConfig = options.chatConfig;\n if (!chatConfig && options.configElementSelector) {\n var configElement = document.querySelector(options.configElementSelector);\n chatConfig = configElement ? parseJsonAttribute(configElement, 'data-config', 'AI chat widget config') : null;\n }\n\n if (!chatConfig) {\n return null;\n }\n\n if (options.messageTemplateSelector) {\n var messageTemplate = document.querySelector(options.messageTemplateSelector);\n if (messageTemplate) {\n chatConfig.messageTemplate = messageTemplate.innerHTML;\n }\n }\n\n if (options.indicatorTemplateSelector) {\n var indicatorTemplate = document.querySelector(options.indicatorTemplateSelector);\n if (indicatorTemplate) {\n chatConfig.indicatorTemplate = indicatorTemplate.innerHTML;\n }\n }\n\n var shell = document.querySelector(options.shellSelector);\n var widgetContainer = document.querySelector(options.widgetContainerSelector);\n var toggleButton = document.querySelector(options.toggleButtonSelector);\n var closeButton = document.querySelector(options.closeButtonSelector);\n var profileInput = options.inputSelector ? document.querySelector(options.inputSelector) : null;\n var widgetStateName = options.widgetStateName || chatConfig.widget.chatWidgetStateName;\n var widgetOpenStateKey = options.widgetOpenStateKey || (widgetStateName + 'Open');\n var widgetLayoutKey = widgetStateName + 'Layout';\n var openStateValue = options.openStateValue || 'open';\n var closedStateValue = options.closedStateValue || 'closed';\n\n if (profileInput && options.profile && options.profile.id) {\n profileInput.setAttribute('data-profile-id', options.profile.id);\n }\n\n try {\n var storedLayout = localStorage.getItem(widgetLayoutKey);\n var layout = storedLayout ? JSON.parse(storedLayout) || {} : {};\n var position = layout.position || {};\n var panelLayout = layout.panel || {};\n var toggleLeft = Number(position.left);\n var toggleTop = Number(position.top);\n var isOpen = localStorage.getItem(widgetOpenStateKey) === openStateValue;\n var viewportPadding = 8;\n\n if (shell) {\n shell.dataset.deferReveal = isOpen ? 'true' : 'false';\n shell.dataset.initialOpen = isOpen ? 'true' : 'false';\n }\n\n if (widgetContainer && toggleButton) {\n var toggleSize = 52;\n var panelWidth = Number.isFinite(Number(panelLayout.width))\n ? Number(panelLayout.width)\n : Math.round(parseFloat(window.getComputedStyle(widgetContainer).width) || 380);\n var panelHeight = Number.isFinite(Number(panelLayout.height))\n ? Number(panelLayout.height)\n : Math.round(parseFloat(window.getComputedStyle(widgetContainer).height) || 520);\n var maxLeft = Math.max(viewportPadding, window.innerWidth - toggleSize - viewportPadding);\n var maxTop = Math.max(viewportPadding, window.innerHeight - toggleSize - viewportPadding);\n if (Number.isFinite(Number(position.leftRatio))) {\n toggleLeft = viewportPadding + Math.max(0, maxLeft - viewportPadding) * Number(position.leftRatio);\n }\n if (Number.isFinite(Number(position.topRatio))) {\n toggleTop = viewportPadding + Math.max(0, maxTop - viewportPadding) * Number(position.topRatio);\n }\n if (Number.isFinite(toggleLeft) && Number.isFinite(toggleTop)) {\n toggleLeft = Math.round(clampWidgetValue(toggleLeft, viewportPadding, maxLeft));\n toggleTop = Math.round(clampWidgetValue(toggleTop, viewportPadding, maxTop));\n }\n\n if (Number.isFinite(toggleLeft) && Number.isFinite(toggleTop)) {\n toggleButton.style.left = toggleLeft + 'px';\n toggleButton.style.top = toggleTop + 'px';\n toggleButton.style.right = 'auto';\n toggleButton.style.bottom = 'auto';\n\n var toggleGap = 8;\n widgetContainer.style.left = (toggleLeft + toggleSize - panelWidth) + 'px';\n widgetContainer.style.top = (toggleTop - panelHeight - toggleGap) + 'px';\n widgetContainer.style.right = 'auto';\n widgetContainer.style.bottom = 'auto';\n }\n }\n\n if (widgetContainer) {\n widgetContainer.classList.remove('open');\n widgetContainer.style.display = 'none';\n widgetContainer.setAttribute('aria-hidden', 'true');\n }\n\n if (toggleButton) {\n toggleButton.innerHTML = isOpen ? options.openIconHtml : options.closedIconHtml;\n }\n }\n catch (error) {\n console.warn('Failed to restore widget layout before initialization.', error);\n }\n finally {\n if (shell && shell.dataset.deferReveal !== 'true') {\n shell.style.visibility = '';\n }\n }\n\n var widgetApp = window.coreAIChatManager.initialize(chatConfig);\n if (options.applySessionProfilePatch !== false && window.crestAppsAIChat && window.crestAppsAIChat.patchSessionProfileSync) {\n window.crestAppsAIChat.patchSessionProfileSync(widgetApp);\n }\n\n function revealShell() {\n if (!shell) {\n return;\n }\n\n shell.style.visibility = '';\n shell.dataset.deferReveal = 'false';\n }\n\n function syncOpenPanelPosition() {\n if (!widgetApp || typeof widgetApp.syncPanelPositionToToggle !== 'function') {\n return;\n }\n\n widgetApp.syncPanelPositionToToggle(false);\n }\n\n function updateTtsPlaybackButtons() {\n if (!widgetContainer) {\n return;\n }\n\n var buttons = widgetContainer.querySelectorAll('[data-tts-message-index]');\n buttons.forEach(function (button) {\n var buttonIndex = Number(button.getAttribute('data-tts-message-index'));\n var isPlaying = buttonIndex === widgetApp.ttsPlayingMessageIndex;\n button.classList.toggle('tts-playing', isPlaying);\n button.setAttribute('title', isPlaying ? 'Pause audio' : 'Read aloud');\n });\n }\n\n function queueTtsPlaybackButtonUpdate() {\n requestAnimationFrame(updateTtsPlaybackButtons);\n }\n\n function revealShellWhenStable(initialOpen) {\n if (!shell || shell.dataset.deferReveal !== 'true' || !initialOpen) {\n revealShell();\n return;\n }\n\n var hasRevealed = false;\n var resizeObserver = null;\n\n function finalizeReveal() {\n if (hasRevealed) {\n return;\n }\n\n hasRevealed = true;\n\n if (resizeObserver) {\n resizeObserver.disconnect();\n }\n\n requestAnimationFrame(function () {\n syncOpenPanelPosition();\n requestAnimationFrame(function () {\n revealShell();\n });\n });\n }\n\n if (typeof ResizeObserver === 'undefined') {\n window.setTimeout(finalizeReveal, 0);\n return;\n }\n\n var lastWidth = 0;\n var lastHeight = 0;\n var stablePasses = 0;\n\n resizeObserver = new ResizeObserver(function (entries) {\n var entry = entries && entries[0];\n if (!entry) {\n return;\n }\n\n var width = Math.round(entry.contentRect.width);\n var height = Math.round(entry.contentRect.height);\n if (!width || !height) {\n return;\n }\n\n syncOpenPanelPosition();\n\n if (width === lastWidth && height === lastHeight) {\n stablePasses++;\n }\n else {\n lastWidth = width;\n lastHeight = height;\n stablePasses = 0;\n }\n\n if (stablePasses >= 1) {\n finalizeReveal();\n }\n });\n\n resizeObserver.observe(widgetContainer);\n window.setTimeout(finalizeReveal, 150);\n }\n\n function setWidgetOpen(isOpen) {\n if (widgetApp) {\n var isCurrentlyOpen = widgetContainer.classList.contains('open');\n if (isOpen && !isCurrentlyOpen && typeof widgetApp.syncPanelPositionToToggle === 'function') {\n widgetApp.syncPanelPositionToToggle();\n }\n else if (!isOpen && isCurrentlyOpen && typeof widgetApp.syncTogglePositionToPanel === 'function') {\n widgetApp.syncTogglePositionToPanel();\n }\n }\n\n widgetContainer.classList.toggle('open', isOpen);\n widgetContainer.style.display = isOpen ? 'flex' : 'none';\n widgetContainer.setAttribute('aria-hidden', isOpen ? 'false' : 'true');\n toggleButton.innerHTML = isOpen ? options.openIconHtml : options.closedIconHtml;\n localStorage.setItem(widgetOpenStateKey, isOpen ? openStateValue : closedStateValue);\n\n if (isOpen && typeof window.renderPendingCharts === 'function') {\n setTimeout(function () { window.renderPendingCharts(); }, 100);\n }\n }\n\n var initialOpen = shell && shell.dataset.initialOpen === 'true';\n setWidgetOpen(initialOpen);\n revealShellWhenStable(initialOpen);\n\n if (widgetApp && typeof widgetApp.$watch === 'function') {\n widgetApp.$watch('ttsPlayingMessageIndex', function () {\n queueTtsPlaybackButtonUpdate();\n });\n }\n\n queueTtsPlaybackButtonUpdate();\n\n if (toggleButton) {\n toggleButton.addEventListener('click', function () {\n if (toggleButton.dataset.dragSuppressClick === 'true') {\n toggleButton.dataset.dragSuppressClick = 'false';\n return;\n }\n\n setWidgetOpen(!widgetContainer.classList.contains('open'));\n });\n }\n\n if (closeButton) {\n closeButton.addEventListener('click', function () {\n setWidgetOpen(false);\n });\n }\n\n return widgetApp;\n }\n\n function initializeFromElement(element) {\n if (!element || element.dataset.coreAiChatWidgetInitialized === 'true') {\n return element ? element.__coreAIChatWidgetApp || null : null;\n }\n\n var jsonOptions = parseJsonAttribute(element, 'data-coreai-chat-widget-config', 'CoreAI chat widget config');\n var attributeOptions = buildOptionsFromDataAttributes(element);\n if (!jsonOptions && !attributeOptions) {\n return null;\n }\n\n var options = Object.assign({}, jsonOptions || {}, attributeOptions || {});\n\n var widgetApp = initialize(options);\n if (!widgetApp) {\n return null;\n }\n\n element.dataset.coreAiChatWidgetInitialized = 'true';\n element.__coreAIChatWidgetApp = widgetApp;\n\n return widgetApp;\n }\n\n function scanForAutoInitialization(root) {\n if (!root || typeof root.querySelectorAll !== 'function') {\n return;\n }\n\n if (typeof root.matches === 'function' && root.matches('[data-coreai-chat-widget-config],[data-coreai-chat-widget-container-selector]')) {\n initializeFromElement(root);\n }\n\n root.querySelectorAll('[data-coreai-chat-widget-config],[data-coreai-chat-widget-container-selector]').forEach(initializeFromElement);\n }\n\n function startAutoInitialization() {\n scanForAutoInitialization(document);\n\n if (typeof MutationObserver === 'undefined') {\n return;\n }\n\n var observer = new MutationObserver(function (mutations) {\n mutations.forEach(function (mutation) {\n mutation.addedNodes.forEach(function (node) {\n if (node && node.nodeType === 1) {\n scanForAutoInitialization(node);\n }\n });\n });\n });\n\n observer.observe(document.body, {\n childList: true,\n subtree: true,\n });\n }\n\n if (document.readyState === 'loading') {\n document.addEventListener('DOMContentLoaded', startAutoInitialization, { once: true });\n } else {\n startAutoInitialization();\n }\n\n return {\n initialize: initialize,\n initializeFromElement: initializeFromElement,\n };\n}();\n"]}
|
package/dist/ai-chat.css
CHANGED
|
@@ -1,8 +1,27 @@
|
|
|
1
|
-
.ai-chat-
|
|
2
|
-
font-size:
|
|
3
|
-
|
|
1
|
+
.ai-chat-message-heading {
|
|
2
|
+
font-size: 0.75rem;
|
|
3
|
+
margin-bottom: 0.35rem;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.ai-chat-message-heading .ai-chat-msg-role {
|
|
7
|
+
margin-bottom: 0;
|
|
4
8
|
text-transform: uppercase;
|
|
5
9
|
letter-spacing: 0.03em;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.ai-chat-message-heading-assistant .ai-chat-msg-role {
|
|
13
|
+
display: inline-flex;
|
|
14
|
+
align-items: center;
|
|
15
|
+
gap: 0.35rem;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.ai-chat-message-role-label {
|
|
19
|
+
display: inline-block;
|
|
20
|
+
text-transform: inherit;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.ai-chat-msg-role {
|
|
24
|
+
font-weight: 600;
|
|
6
25
|
margin-bottom: 0.35rem;
|
|
7
26
|
}
|
|
8
27
|
|
package/dist/ai-chat.css.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["ai-chat.css"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"ai-chat.css","sourcesContent":[".ai-chat-msg-role {\n font-size: 1.25rem;\n font-weight: 600;\n text-transform: uppercase;\n letter-spacing: 0.03em;\n margin-bottom: 0.35rem;\n}\n\n.ai-chat-msg-role-user {\n color: var(--bs-primary, #0d6efd);\n}\n\n.ai-chat-msg-role-assistant {\n color: var(--ai-chat-primary, var(--bs-success, #198754));\n}\n\n.ai-chat-messages .ai-chat-message-item {\n position: relative;\n padding: 0.25rem 0;\n}\n\n.ai-chat-messages .ai-chat-message-item + .ai-chat-message-item::before {\n content: '';\n display: block;\n width: 100%;\n margin: 0.5rem auto 0.75rem;\n border-top: 1px solid var(--bs-border-color, #dee2e6);\n}\n\n.ai-chat-messages .ai-chat-message-item p:last-child {\n margin-bottom: 0;\n}\n\n.ai-chat-messages .ai-chat-message-body {\n position: relative;\n padding: 0;\n overflow-wrap: break-word;\n word-break: break-word;\n min-width: 0;\n}\n\n.ai-chat-messages .ai-chat-message-body sup {\n font-size: 0.75em;\n line-height: 0;\n}\n\n.ai-chat-messages .ai-chat-citation-list {\n margin: 0.75rem 0 0;\n padding-left: 1.25rem;\n}\n\n.ai-chat-messages .ai-chat-citation-item + .ai-chat-citation-item {\n margin-top: 0.25rem;\n}\n\n.ai-chat-messages .ai-chat-citation-item a {\n word-break: break-word;\n}\n\n.ai-partial-transcript {\n font-style: italic;\n opacity: 0.7;\n}\n\n.ai-chat-messages .message-buttons-container {\n position: absolute;\n right: 0.1rem;\n bottom: 0;\n display: inline-flex;\n align-items: center;\n gap: 0.35rem;\n width: auto;\n max-width: max-content;\n opacity: 0;\n pointer-events: none;\n transition: opacity 0.15s ease-in-out;\n background: rgba(var(--bs-body-bg-rgb, 255, 255, 255), 0.96);\n padding: 0.2rem 0.35rem;\n border-radius: 999px;\n box-shadow: 0 1px 3px rgba(var(--bs-body-color-rgb, 33, 37, 41), 0.08);\n margin-bottom: 1rem;\n transform: translateY(50%);\n z-index: 1;\n}\n\n.ai-chat-messages .ai-chat-message-item:hover .message-buttons-container,\n.ai-chat-messages .ai-chat-message-item:focus-within .message-buttons-container {\n opacity: 1;\n pointer-events: auto;\n}\n\n.ai-chat-messages .message-buttons-container:has(.tts-playing) {\n opacity: 1;\n pointer-events: auto;\n}\n\n.ai-chat-messages .message-buttons-container > .button-message-toolbox {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n flex: 0 0 auto;\n width: 1.75rem;\n height: 1.75rem;\n margin: 0 !important;\n padding: 0 !important;\n border-radius: 50%;\n color: var(--bs-secondary-color, #6c757d) !important;\n text-decoration: none;\n}\n\n.ai-chat-messages .message-buttons-container .ai-chat-message-assistant-feedback {\n display: inline-flex;\n align-items: center;\n gap: 0.35rem;\n}\n\n.ai-chat-messages .message-buttons-container > .button-message-toolbox:hover,\n.ai-chat-messages .message-buttons-container > .button-message-toolbox:focus {\n color: var(--bs-body-color, #212529) !important;\n text-decoration: none;\n}\n\n.ai-chat-messages .message-buttons-container > .button-message-toolbox.text-success,\n.ai-chat-messages .message-buttons-container > .button-message-toolbox.text-success:hover,\n.ai-chat-messages .message-buttons-container > .button-message-toolbox.text-success:focus {\n color: var(--bs-success, #198754) !important;\n text-decoration: none;\n}\n\n.ai-chat-messages .message-buttons-container > .button-message-toolbox.text-success svg {\n color: inherit !important;\n fill: currentColor;\n}\n\n.ai-chat-messages .message-buttons-container .tts-playing {\n color: var(--ai-chat-primary, var(--bs-success, #198754));\n}\n\n@keyframes spark-burst {\n 0% {\n transform: scale(1);\n opacity: 1;\n }\n 20% {\n transform: scale(1.8);\n opacity: 0.7;\n }\n 40% {\n transform: scale(0.9);\n opacity: 1;\n }\n 60% {\n transform: scale(1.3);\n }\n 100% {\n transform: scale(1);\n }\n}\n\n.spark-effect i,\n.spark-effect svg {\n display: inline-block;\n animation: spark-burst 0.5s ease-out;\n}\n\n.ai-chat-messages .ai-bot-icon {\n color: currentColor;\n display: inline-block;\n animation: none;\n}\n\n@keyframes ai-chat-streaming-effect {\n 0% { opacity: 1; transform: rotate(0deg); }\n 10% { opacity: 0.3; transform: rotate(0deg); }\n 20% { opacity: 1; transform: rotate(0deg); }\n 30% { opacity: 0.3; transform: rotate(0deg); }\n 40% { opacity: 1; transform: rotate(0deg); }\n 50% { opacity: 0.3; transform: rotate(0deg); }\n 60% { opacity: 1; transform: rotate(0deg); }\n 80% { opacity: 1; transform: rotate(360deg); }\n 100% { opacity: 1; transform: rotate(360deg); }\n}\n\n.ai-chat-messages .ai-streaming-icon {\n color: currentColor;\n display: inline-block;\n animation: ai-chat-streaming-effect 4s ease-in-out infinite;\n}\n\n.ai-chat-messages pre {\n position: relative;\n margin: 0;\n}\n\n.ai-chat-messages .ai-code-block {\n border: 1px solid var(--bs-border-color, #dee2e6);\n border-radius: 0.5rem;\n overflow: hidden;\n margin: 0.75rem 0;\n background: var(--bs-body-bg, #fff);\n}\n\n.ai-chat-messages .ai-code-header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: 0.5rem 1rem;\n font-size: 0.8rem;\n min-height: 2rem;\n}\n\n.ai-chat-messages .ai-code-lang {\n font-weight: 600;\n color: var(--bs-body-color, #212529);\n text-transform: capitalize;\n}\n\n.ai-chat-messages .ai-code-lang i {\n color: var(--bs-secondary-color, #6c757d);\n margin-right: 0.25rem;\n}\n\n.ai-chat-messages .ai-code-copy-btn {\n display: inline-flex;\n align-items: center;\n gap: 0.3rem;\n padding: 0.2rem;\n font-size: 0.8rem;\n background: transparent;\n border: none;\n cursor: pointer;\n color: var(--bs-secondary-color, #6c757d);\n transition: color 0.15s;\n white-space: nowrap;\n}\n\n.ai-chat-messages .ai-code-copy-btn:hover {\n color: var(--bs-body-color, #212529);\n}\n\n.ai-chat-messages .ai-code-block pre {\n margin: 0;\n background: transparent !important;\n}\n\n.ai-chat-messages .ai-code-block pre code.hljs {\n background: transparent !important;\n padding: 0.75rem 1rem 1rem;\n}\n\n.ai-chat-messages pre code.hljs {\n white-space: pre-wrap;\n word-wrap: break-word;\n overflow-wrap: break-word;\n border-radius: 0.375rem;\n}\n\n.ai-chat-doc-bar {\n border-bottom: 1px solid var(--bs-border-color, #dee2e6);\n}\n\n.ai-chat-drag-over {\n outline: 2px dashed var(--bs-primary, #0d6efd) !important;\n outline-offset: -2px;\n background-color: rgba(var(--bs-primary-rgb, 13, 110, 253), 0.05) !important;\n}\n\n.ai-chat-notification {\n margin: 0.75rem 0 0.25rem;\n padding: 0.625rem 0.875rem;\n border-radius: 0.5rem;\n border: 1px solid var(--bs-border-color, #dee2e6);\n background-color: var(--bs-tertiary-bg, #f8f9fa);\n font-size: 0.875rem;\n line-height: 1.4;\n}\n\n.ai-chat-notification-content {\n display: flex;\n align-items: center;\n gap: 0.5rem;\n}\n\n.ai-chat-notification-icon {\n flex-shrink: 0;\n font-size: 1rem;\n opacity: 0.8;\n}\n\n.ai-chat-notification-text {\n flex: 1;\n}\n\n.ai-chat-notification-dismiss {\n flex-shrink: 0;\n opacity: 0.5;\n transition: opacity 0.15s;\n}\n\n.ai-chat-notification-dismiss:hover {\n opacity: 1;\n}\n\n.ai-chat-notification-actions {\n display: flex;\n gap: 0.375rem;\n margin-top: 0.5rem;\n padding-top: 0.5rem;\n border-top: 1px solid var(--bs-border-color, #dee2e6);\n}\n\n.ai-chat-notification-actions .btn {\n font-size: 0.8125rem;\n padding: 0.1875rem 0.625rem;\n}\n\n.ai-chat-notification-typing {\n border-color: var(--ai-chat-primary, var(--bs-success, #198754));\n background-color: rgba(var(--ai-chat-primary-rgb, var(--bs-success-rgb, 25, 135, 84)), 0.05);\n}\n\n.ai-chat-notification-typing .ai-chat-notification-icon {\n color: var(--ai-chat-primary, var(--bs-success, #198754));\n animation: ai-chat-typing-pulse 1.5s ease-in-out infinite;\n}\n\n@keyframes ai-chat-typing-pulse {\n 0%, 100% { opacity: 0.4; }\n 50% { opacity: 1; }\n}\n\n.ai-chat-notification-transfer {\n border-color: var(--bs-warning, #ffc107);\n background-color: rgba(var(--bs-warning-rgb, 255, 193, 7), 0.06);\n}\n\n.ai-chat-notification-transfer .ai-chat-notification-icon {\n color: var(--bs-warning, #ffc107);\n animation: ai-chat-transfer-pulse 2s ease-in-out infinite;\n}\n\n@keyframes ai-chat-transfer-pulse {\n 0%, 100% { transform: scale(1); opacity: 0.7; }\n 50% { transform: scale(1.1); opacity: 1; }\n}\n\n.ai-chat-notification-ended,\n.ai-chat-notification-session-ended,\n.ai-chat-notification-conversation-ended {\n border-color: var(--bs-secondary, #6c757d);\n background-color: rgba(var(--bs-secondary-rgb, 108, 117, 125), 0.05);\n}\n\n.ai-chat-notification-ended .ai-chat-notification-icon,\n.ai-chat-notification-session-ended .ai-chat-notification-icon,\n.ai-chat-notification-conversation-ended .ai-chat-notification-icon {\n color: var(--bs-secondary, #6c757d);\n}\n\n.ai-chat-notification-info,\n.ai-chat-notification-agent-connected {\n border-color: var(--bs-info, #0dcaf0);\n background-color: rgba(var(--bs-info-rgb, 13, 202, 240), 0.05);\n}\n\n.ai-chat-notification-info .ai-chat-notification-icon,\n.ai-chat-notification-agent-connected .ai-chat-notification-icon {\n color: var(--bs-info, #0dcaf0);\n}\n\n.ai-chat-notification-warning,\n.ai-chat-notification-agent-reconnecting {\n border-color: var(--bs-warning, #ffc107);\n background-color: rgba(var(--bs-warning-rgb, 255, 193, 7), 0.06);\n}\n\n.ai-chat-notification-warning .ai-chat-notification-icon,\n.ai-chat-notification-agent-reconnecting .ai-chat-notification-icon {\n color: var(--bs-warning, #ffc107);\n}\n\n.ai-chat-notification-error,\n.ai-chat-notification-connection-lost {\n border-color: var(--bs-danger, #dc3545);\n background-color: rgba(var(--bs-danger-rgb, 220, 53, 69), 0.05);\n}\n\n.ai-chat-notification-error .ai-chat-notification-icon,\n.ai-chat-notification-connection-lost .ai-chat-notification-icon {\n color: var(--bs-danger, #dc3545);\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["ai-chat.css"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"ai-chat.css","sourcesContent":[".ai-chat-message-heading {\n font-size: 0.75rem;\n margin-bottom: 0.35rem;\n}\n\n.ai-chat-message-heading .ai-chat-msg-role {\n margin-bottom: 0;\n text-transform: uppercase;\n letter-spacing: 0.03em;\n}\n\n.ai-chat-message-heading-assistant .ai-chat-msg-role {\n display: inline-flex;\n align-items: center;\n gap: 0.35rem;\n}\n\n.ai-chat-message-role-label {\n display: inline-block;\n text-transform: inherit;\n}\n\n.ai-chat-msg-role {\n font-weight: 600;\n margin-bottom: 0.35rem;\n}\n\n.ai-chat-msg-role-user {\n color: var(--bs-primary, #0d6efd);\n}\n\n.ai-chat-msg-role-assistant {\n color: var(--ai-chat-primary, var(--bs-success, #198754));\n}\n\n.ai-chat-messages .ai-chat-message-item {\n position: relative;\n padding: 0.25rem 0;\n}\n\n.ai-chat-messages .ai-chat-message-item + .ai-chat-message-item::before {\n content: '';\n display: block;\n width: 100%;\n margin: 0.5rem auto 0.75rem;\n border-top: 1px solid var(--bs-border-color, #dee2e6);\n}\n\n.ai-chat-messages .ai-chat-message-item p:last-child {\n margin-bottom: 0;\n}\n\n.ai-chat-messages .ai-chat-message-body {\n position: relative;\n padding: 0;\n overflow-wrap: break-word;\n word-break: break-word;\n min-width: 0;\n}\n\n.ai-chat-messages .ai-chat-message-body sup {\n font-size: 0.75em;\n line-height: 0;\n}\n\n.ai-chat-messages .ai-chat-citation-list {\n margin: 0.75rem 0 0;\n padding-left: 1.25rem;\n}\n\n.ai-chat-messages .ai-chat-citation-item + .ai-chat-citation-item {\n margin-top: 0.25rem;\n}\n\n.ai-chat-messages .ai-chat-citation-item a {\n word-break: break-word;\n}\n\n.ai-partial-transcript {\n font-style: italic;\n opacity: 0.7;\n}\n\n.ai-chat-messages .message-buttons-container {\n position: absolute;\n right: 0.1rem;\n bottom: 0;\n display: inline-flex;\n align-items: center;\n gap: 0.35rem;\n width: auto;\n max-width: max-content;\n opacity: 0;\n pointer-events: none;\n transition: opacity 0.15s ease-in-out;\n background: rgba(var(--bs-body-bg-rgb, 255, 255, 255), 0.96);\n padding: 0.2rem 0.35rem;\n border-radius: 999px;\n box-shadow: 0 1px 3px rgba(var(--bs-body-color-rgb, 33, 37, 41), 0.08);\n margin-bottom: 1rem;\n transform: translateY(50%);\n z-index: 1;\n}\n\n.ai-chat-messages .ai-chat-message-item:hover .message-buttons-container,\n.ai-chat-messages .ai-chat-message-item:focus-within .message-buttons-container {\n opacity: 1;\n pointer-events: auto;\n}\n\n.ai-chat-messages .message-buttons-container:has(.tts-playing) {\n opacity: 1;\n pointer-events: auto;\n}\n\n.ai-chat-messages .message-buttons-container > .button-message-toolbox {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n flex: 0 0 auto;\n width: 1.75rem;\n height: 1.75rem;\n margin: 0 !important;\n padding: 0 !important;\n border-radius: 50%;\n color: var(--bs-secondary-color, #6c757d) !important;\n text-decoration: none;\n}\n\n.ai-chat-messages .message-buttons-container .ai-chat-message-assistant-feedback {\n display: inline-flex;\n align-items: center;\n gap: 0.35rem;\n}\n\n.ai-chat-messages .message-buttons-container > .button-message-toolbox:hover,\n.ai-chat-messages .message-buttons-container > .button-message-toolbox:focus {\n color: var(--bs-body-color, #212529) !important;\n text-decoration: none;\n}\n\n.ai-chat-messages .message-buttons-container > .button-message-toolbox.text-success,\n.ai-chat-messages .message-buttons-container > .button-message-toolbox.text-success:hover,\n.ai-chat-messages .message-buttons-container > .button-message-toolbox.text-success:focus {\n color: var(--bs-success, #198754) !important;\n text-decoration: none;\n}\n\n.ai-chat-messages .message-buttons-container > .button-message-toolbox.text-success svg {\n color: inherit !important;\n fill: currentColor;\n}\n\n.ai-chat-messages .message-buttons-container .tts-playing {\n color: var(--ai-chat-primary, var(--bs-success, #198754));\n}\n\n@keyframes spark-burst {\n 0% {\n transform: scale(1);\n opacity: 1;\n }\n 20% {\n transform: scale(1.8);\n opacity: 0.7;\n }\n 40% {\n transform: scale(0.9);\n opacity: 1;\n }\n 60% {\n transform: scale(1.3);\n }\n 100% {\n transform: scale(1);\n }\n}\n\n.spark-effect i,\n.spark-effect svg {\n display: inline-block;\n animation: spark-burst 0.5s ease-out;\n}\n\n.ai-chat-messages .ai-bot-icon {\n color: currentColor;\n display: inline-block;\n animation: none;\n}\n\n@keyframes ai-chat-streaming-effect {\n 0% { opacity: 1; transform: rotate(0deg); }\n 10% { opacity: 0.3; transform: rotate(0deg); }\n 20% { opacity: 1; transform: rotate(0deg); }\n 30% { opacity: 0.3; transform: rotate(0deg); }\n 40% { opacity: 1; transform: rotate(0deg); }\n 50% { opacity: 0.3; transform: rotate(0deg); }\n 60% { opacity: 1; transform: rotate(0deg); }\n 80% { opacity: 1; transform: rotate(360deg); }\n 100% { opacity: 1; transform: rotate(360deg); }\n}\n\n.ai-chat-messages .ai-streaming-icon {\n color: currentColor;\n display: inline-block;\n animation: ai-chat-streaming-effect 4s ease-in-out infinite;\n}\n\n.ai-chat-messages pre {\n position: relative;\n margin: 0;\n}\n\n.ai-chat-messages .ai-code-block {\n border: 1px solid var(--bs-border-color, #dee2e6);\n border-radius: 0.5rem;\n overflow: hidden;\n margin: 0.75rem 0;\n background: var(--bs-body-bg, #fff);\n}\n\n.ai-chat-messages .ai-code-header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: 0.5rem 1rem;\n font-size: 0.8rem;\n min-height: 2rem;\n}\n\n.ai-chat-messages .ai-code-lang {\n font-weight: 600;\n color: var(--bs-body-color, #212529);\n text-transform: capitalize;\n}\n\n.ai-chat-messages .ai-code-lang i {\n color: var(--bs-secondary-color, #6c757d);\n margin-right: 0.25rem;\n}\n\n.ai-chat-messages .ai-code-copy-btn {\n display: inline-flex;\n align-items: center;\n gap: 0.3rem;\n padding: 0.2rem;\n font-size: 0.8rem;\n background: transparent;\n border: none;\n cursor: pointer;\n color: var(--bs-secondary-color, #6c757d);\n transition: color 0.15s;\n white-space: nowrap;\n}\n\n.ai-chat-messages .ai-code-copy-btn:hover {\n color: var(--bs-body-color, #212529);\n}\n\n.ai-chat-messages .ai-code-block pre {\n margin: 0;\n background: transparent !important;\n}\n\n.ai-chat-messages .ai-code-block pre code.hljs {\n background: transparent !important;\n padding: 0.75rem 1rem 1rem;\n}\n\n.ai-chat-messages pre code.hljs {\n white-space: pre-wrap;\n word-wrap: break-word;\n overflow-wrap: break-word;\n border-radius: 0.375rem;\n}\n\n.ai-chat-doc-bar {\n border-bottom: 1px solid var(--bs-border-color, #dee2e6);\n}\n\n.ai-chat-drag-over {\n outline: 2px dashed var(--bs-primary, #0d6efd) !important;\n outline-offset: -2px;\n background-color: rgba(var(--bs-primary-rgb, 13, 110, 253), 0.05) !important;\n}\n\n.ai-chat-notification {\n margin: 0.75rem 0 0.25rem;\n padding: 0.625rem 0.875rem;\n border-radius: 0.5rem;\n border: 1px solid var(--bs-border-color, #dee2e6);\n background-color: var(--bs-tertiary-bg, #f8f9fa);\n font-size: 0.875rem;\n line-height: 1.4;\n}\n\n.ai-chat-notification-content {\n display: flex;\n align-items: center;\n gap: 0.5rem;\n}\n\n.ai-chat-notification-icon {\n flex-shrink: 0;\n font-size: 1rem;\n opacity: 0.8;\n}\n\n.ai-chat-notification-text {\n flex: 1;\n}\n\n.ai-chat-notification-dismiss {\n flex-shrink: 0;\n opacity: 0.5;\n transition: opacity 0.15s;\n}\n\n.ai-chat-notification-dismiss:hover {\n opacity: 1;\n}\n\n.ai-chat-notification-actions {\n display: flex;\n gap: 0.375rem;\n margin-top: 0.5rem;\n padding-top: 0.5rem;\n border-top: 1px solid var(--bs-border-color, #dee2e6);\n}\n\n.ai-chat-notification-actions .btn {\n font-size: 0.8125rem;\n padding: 0.1875rem 0.625rem;\n}\n\n.ai-chat-notification-typing {\n border-color: var(--ai-chat-primary, var(--bs-success, #198754));\n background-color: rgba(var(--ai-chat-primary-rgb, var(--bs-success-rgb, 25, 135, 84)), 0.05);\n}\n\n.ai-chat-notification-typing .ai-chat-notification-icon {\n color: var(--ai-chat-primary, var(--bs-success, #198754));\n animation: ai-chat-typing-pulse 1.5s ease-in-out infinite;\n}\n\n@keyframes ai-chat-typing-pulse {\n 0%, 100% { opacity: 0.4; }\n 50% { opacity: 1; }\n}\n\n.ai-chat-notification-transfer {\n border-color: var(--bs-warning, #ffc107);\n background-color: rgba(var(--bs-warning-rgb, 255, 193, 7), 0.06);\n}\n\n.ai-chat-notification-transfer .ai-chat-notification-icon {\n color: var(--bs-warning, #ffc107);\n animation: ai-chat-transfer-pulse 2s ease-in-out infinite;\n}\n\n@keyframes ai-chat-transfer-pulse {\n 0%, 100% { transform: scale(1); opacity: 0.7; }\n 50% { transform: scale(1.1); opacity: 1; }\n}\n\n.ai-chat-notification-ended,\n.ai-chat-notification-session-ended,\n.ai-chat-notification-conversation-ended {\n border-color: var(--bs-secondary, #6c757d);\n background-color: rgba(var(--bs-secondary-rgb, 108, 117, 125), 0.05);\n}\n\n.ai-chat-notification-ended .ai-chat-notification-icon,\n.ai-chat-notification-session-ended .ai-chat-notification-icon,\n.ai-chat-notification-conversation-ended .ai-chat-notification-icon {\n color: var(--bs-secondary, #6c757d);\n}\n\n.ai-chat-notification-info,\n.ai-chat-notification-agent-connected {\n border-color: var(--bs-info, #0dcaf0);\n background-color: rgba(var(--bs-info-rgb, 13, 202, 240), 0.05);\n}\n\n.ai-chat-notification-info .ai-chat-notification-icon,\n.ai-chat-notification-agent-connected .ai-chat-notification-icon {\n color: var(--bs-info, #0dcaf0);\n}\n\n.ai-chat-notification-warning,\n.ai-chat-notification-agent-reconnecting {\n border-color: var(--bs-warning, #ffc107);\n background-color: rgba(var(--bs-warning-rgb, 255, 193, 7), 0.06);\n}\n\n.ai-chat-notification-warning .ai-chat-notification-icon,\n.ai-chat-notification-agent-reconnecting .ai-chat-notification-icon {\n color: var(--bs-warning, #ffc107);\n}\n\n.ai-chat-notification-error,\n.ai-chat-notification-connection-lost {\n border-color: var(--bs-danger, #dc3545);\n background-color: rgba(var(--bs-danger-rgb, 220, 53, 69), 0.05);\n}\n\n.ai-chat-notification-error .ai-chat-notification-icon,\n.ai-chat-notification-connection-lost .ai-chat-notification-icon {\n color: var(--bs-danger, #dc3545);\n}\n"]}
|