@crestapps/ai-chat-ui 1.0.0-preview-22-preview.1

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.
@@ -0,0 +1 @@
1
+ function _slicedToArray(e,t){return _arrayWithHoles(e)||_iterableToArrayLimit(e,t)||_unsupportedIterableToArray(e,t)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _iterableToArrayLimit(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var i,o,a,r,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;c=!1}else for(;!(c=(i=a.call(n)).done)&&(s.push(i.value),s.length!==t);c=!0);}catch(e){l=!0,o=e}finally{try{if(!c&&null!=n.return&&(r=n.return(),Object(r)!==r))return}finally{if(l)throw o}}return s}}function _arrayWithHoles(e){if(Array.isArray(e))return e}function _typeof(e){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_typeof(e)}function _regenerator(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */var e,t,n="function"==typeof Symbol?Symbol:{},i=n.iterator||"@@iterator",o=n.toStringTag||"@@toStringTag";function a(n,i,o,a){var c=i&&i.prototype instanceof s?i:s,l=Object.create(c.prototype);return _regeneratorDefine2(l,"_invoke",function(n,i,o){var a,s,c,l=0,u=o||[],d=!1,h={p:0,n:0,v:e,a:m,f:m.bind(e,4),d:function(t,n){return a=t,s=0,c=e,h.n=n,r}};function m(n,i){for(s=n,c=i,t=0;!d&&l&&!o&&t<u.length;t++){var o,a=u[t],m=h.p,f=a[2];n>3?(o=f===i)&&(c=a[(s=a[4])?5:(s=3,3)],a[4]=a[5]=e):a[0]<=m&&((o=n<2&&m<a[1])?(s=0,h.v=i,h.n=a[1]):m<f&&(o=n<3||a[0]>i||i>f)&&(a[4]=n,a[5]=i,h.n=f,s=0))}if(o||n>1)return r;throw d=!0,i}return function(o,u,f){if(l>1)throw TypeError("Generator is already running");for(d&&1===u&&m(u,f),s=u,c=f;(t=s<2?e:c)||!d;){a||(s?s<3?(s>1&&(h.n=-1),m(s,c)):h.n=c:h.v=c);try{if(l=2,a){if(s||(o="next"),t=a[o]){if(!(t=t.call(a,c)))throw TypeError("iterator result is not an object");if(!t.done)return t;c=t.value,s<2&&(s=0)}else 1===s&&(t=a.return)&&t.call(a),s<2&&(c=TypeError("The iterator does not provide a '"+o+"' method"),s=1);a=e}else if((t=(d=h.n<0)?c:n.call(i,h))!==r)break}catch(t){a=e,s=1,c=t}finally{l=1}}return{value:t,done:d}}}(n,o,a),!0),l}var r={};function s(){}function c(){}function l(){}t=Object.getPrototypeOf;var u=[][i]?t(t([][i]())):(_regeneratorDefine2(t={},i,function(){return this}),t),d=l.prototype=s.prototype=Object.create(u);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,l):(e.__proto__=l,_regeneratorDefine2(e,o,"GeneratorFunction")),e.prototype=Object.create(d),e}return c.prototype=l,_regeneratorDefine2(d,"constructor",l),_regeneratorDefine2(l,"constructor",c),c.displayName="GeneratorFunction",_regeneratorDefine2(l,o,"GeneratorFunction"),_regeneratorDefine2(d),_regeneratorDefine2(d,o,"Generator"),_regeneratorDefine2(d,i,function(){return this}),_regeneratorDefine2(d,"toString",function(){return"[object Generator]"}),(_regenerator=function(){return{w:a,m:h}})()}function _regeneratorDefine2(e,t,n,i){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}_regeneratorDefine2=function(e,t,n,i){function a(t,n){_regeneratorDefine2(e,t,function(e){return this._invoke(t,n,e)})}t?o?o(e,t,{value:n,enumerable:!i,configurable:!i,writable:!i}):e[t]=n:(a("next",0),a("throw",1),a("return",2))},_regeneratorDefine2(e,t,n,i)}function asyncGeneratorStep(e,t,n,i,o,a,r){try{var s=e[a](r),c=s.value}catch(e){return void n(e)}s.done?t(c):Promise.resolve(c).then(i,o)}function _asyncToGenerator(e){return function(){var t=this,n=arguments;return new Promise(function(i,o){var a=e.apply(t,n);function r(e){asyncGeneratorStep(a,i,o,r,s,"next",e)}function s(e){asyncGeneratorStep(a,i,o,r,s,"throw",e)}r(void 0)})}}function _createForOfIteratorHelper(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=_unsupportedIterableToArray(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var i=0,o=function(){};return{s:o,n:function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,r=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return r=e.done,e},e:function(e){s=!0,a=e},f:function(){try{r||null==n.return||n.return()}finally{if(s)throw a}}}}function _toConsumableArray(e){return _arrayWithoutHoles(e)||_iterableToArray(e)||_unsupportedIterableToArray(e)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_arrayLikeToArray(e,t):void 0}}function _iterableToArray(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function _arrayWithoutHoles(e){if(Array.isArray(e))return _arrayLikeToArray(e)}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i}window.chatInteractionManager=function(){var e={generatedImageAltText:"Generated Image",generatedImageMaxWidth:400,generatedChartMaxWidth:900,downloadImageTitle:"Download image",downloadChartTitle:"Download chart as image",downloadChartButtonText:"Download",codeCopiedText:"Copied!",assistantLabel:"Assistant",messageTemplate:'\n <div class="ai-chat-messages">\n <div v-for="(message, index) in messages" :key="index" class="ai-chat-message-item">\n <div>\n <div v-if="message.role === \'user\'" class="ai-chat-msg-role ai-chat-msg-role-user">You</div>\n <div v-else-if="message.role !== \'indicator\'" :class="getAssistantRoleClasses(message)">\n <span :class="getAssistantIconClasses(message, index)"><i :class="getAssistantIcon(message)"></i></span>\n {{ getAssistantLabel(message) }}\n </div>\n <div class="lh-base">\n <h4 v-if="message.title">{{ message.title }}</h4>\n <div v-html="message.htmlContent"></div>\n <span class="message-buttons-container" v-if="!isIndicator(message)">\n <button class="btn btn-sm btn-link text-secondary p-0 button-message-toolbox" @click="copyResponse(message.content)" title="Click here to copy response to clipboard.">\n <i class="fa-solid fa-copy"></i>\n </button>\n </span>\n </div>\n </div>\n </div>\n <div v-for="notification in notifications" :key="\'notif-\' + notification.type" class="ai-chat-notification" :class="\'ai-chat-notification-\' + (notification.type || \'info\') + \' \' + (notification.cssClass || \'\')">\n <div class="ai-chat-notification-content">\n <i v-if="notification.icon" :class="notification.icon" class="ai-chat-notification-icon"></i>\n <span class="ai-chat-notification-text">{{ notification.content }}</span>\n <button v-if="notification.dismissible" class="btn btn-sm btn-link p-0 ms-2 ai-chat-notification-dismiss" @click="dismissNotification(notification.type)" title="Dismiss">\n <i class="fa-solid fa-xmark"></i>\n </button>\n </div>\n <div v-if="notification.actions && notification.actions.length" class="ai-chat-notification-actions">\n <button v-for="action in notification.actions" :key="action.name" class="btn btn-sm" :class="action.cssClass || \'btn-outline-secondary\'" @click="handleNotificationAction(notification.type, action.name)">\n <i v-if="action.icon" :class="action.icon" class="me-1"></i>\n {{ action.label }}\n </button>\n </div>\n </div>\n </div>\n ',indicatorTemplate:'\n <div class="ai-chat-msg-role ai-chat-msg-role-assistant">\n <span class="ai-streaming-icon"><i class="fa fa-robot" style="display: inline-block;"></i></span>\n Assistant\n </div>\n ',untitledText:"Untitled",clearHistoryTitle:"Clear History",clearHistoryMessage:"Are you sure you want to clear the chat history? This action cannot be undone. Your documents, parameters, and tools will be preserved.",clearHistoryOkText:"Yes",clearHistoryCancelText:"Cancel"};function t(e){if(!e)return"";var t=e.trim();return/^javascript:/i.test(t)||/^vbscript:/i.test(t)||/^data:text\/html/i.test(t)?"":e}function n(e){var t=document.createElement("span");return t.textContent=e,t.innerHTML}var i=new marked.Renderer;i.link=function(e){var n=t(e.href);return n?'<a href="'.concat(n,'" target="_blank" rel="noopener noreferrer">').concat(e.text,"</a>"):e.text||""},i.code=function(e){var t=e.text||"",i=(e.lang||"").trim(),o=t;if("undefined"!=typeof hljs)if(i&&hljs.getLanguage(i))try{o=hljs.highlight(t,{language:i}).value}catch(e){}else try{o=hljs.highlightAuto(t).value}catch(e){}else o=n(t);var a=i?n(i):"code";return'<div class="ai-code-block"><div class="ai-code-header"><span class="ai-code-lang"><i class="fa-solid fa-code"></i> '.concat(a,'</span><button type="button" class="ai-code-copy-btn" title="Copy code"><i class="fa-regular fa-copy"></i></button></div><pre><code class="hljs').concat(i?" language-"+i:"",'">').concat(o,"</code></pre></div>")},i.image=function(n){var i=t(n.href);if(!i)return"";var o=n.text||e.generatedImageAltText,a=e.generatedImageMaxWidth;return'<div class="generated-image-container">\n <img src="'.concat(i,'" alt="').concat(o,'" class="img-thumbnail" style="max-width: ').concat(a,'px; height: auto;" />\n <div class="mt-2">\n <a href="').concat(i,'" target="_blank" download="').concat(o,'" title="').concat(e.downloadImageTitle,'" class="btn btn-sm btn-outline-secondary ai-download-image">\n <i class="fa-solid fa-download"></i>\n </a>\n </div>\n </div>')};var o=0,a=[];function r(e){if(e&&e._pendingCharts&&e._pendingCharts.length){var t=_toConsumableArray(e._pendingCharts);e._pendingCharts=[],requestAnimationFrame(function(){var e,n=_createForOfIteratorHelper(t);try{for(n.s();!(e=n.n()).done;){var i=e.value,o=document.getElementById(i.chartId);if(o)if("undefined"!=typeof Chart)try{var a;o._chartInstance&&o._chartInstance.destroy();var r="string"==typeof i.config?JSON.parse(i.config):i.config;null!==(a=r.options)&&void 0!==a||(r.options={}),r.options.responsive=!0,r.options.maintainAspectRatio=!1,o._chartInstance=new Chart(o,r)}catch(e){console.error("Error creating chart:",e)}else console.warn('Chart.js is not loaded. To render interactive charts, include the Chart.js library on the page (e.g., <script src="https://cdn.jsdelivr.net/npm/chart.js@4/dist/chart.umd.min.js"><\/script>).')}}catch(e){n.e(e)}finally{n.f()}})}}function s(e,t){a=[];var n=marked.parse(e,{renderer:i});return t._pendingCharts=a.length>0?_toConsumableArray(a):[],DOMPurify.sanitize(n,{ADD_ATTR:["target"]})}window.__chartConfigs=window.__chartConfigs||{},marked.use({extensions:[{name:"chart",level:"block",start:function(e){var t=e.indexOf("[chart:");return t>=0?t:void 0},tokenizer:function(e){var t=function(e){var t="[chart:",n=e.indexOf(t);if(n<0)return null;var i=n+t.length,o=i;for(;o<e.length&&(" "===e[o]||"\n"===e[o]||"\r"===e[o]||"\t"===e[o]);)o++;if(o>=e.length||"{"!==e[o])return null;for(var a=0,r=!1,s=!1;o<e.length;o++){var c=e[o];if(r){if(s){s=!1;continue}if("\\"===c){s=!0;continue}'"'===c&&(r=!1)}else if('"'!==c){if("{"===c)a++;else if("}"===c&&0===--a){var l=o,u=e.indexOf("]",l+1);return u<0?null:{startIndex:n,endIndex:u+1,json:e.substring(i,l+1).trim()}}}else r=!0}return null}(e);if(t&&0===t.startIndex){var n="chat_chart_".concat(++o);return{type:"chart",raw:e.substring(0,t.endIndex),chartId:n,json:t.json}}},renderer:function(t){return a.push({chartId:t.chartId,config:t.json}),window.__chartConfigs[t.chartId]=t.json,n=t.chartId,i=e.generatedChartMaxWidth,'<div class="chart-container" style="position: relative; width: 100%; max-width: '.concat(i,'px;">')+'<canvas id="'.concat(n,'" class="img-thumbnail"></canvas>')+'</div><div class="mt-2">'+'<button type="button" class="btn btn-sm btn-outline-secondary download-chart-btn" data-chart-id="'.concat(n,'" title="').concat(e.downloadChartTitle,'">')+'<i class="fa-solid fa-download"></i> '.concat(e.downloadChartButtonText)+"</button></div>";var n,i}}]});return{initialize:function(t){var n=Object.assign({},e,t);if(e=n,n.signalRHubUrl)if(n.appElementSelector)if(n.chatContainerElementSelector)if(n.inputElementSelector){if(n.sendButtonElementSelector)return Vue.createApp({data:function(){return{inputElement:null,buttonElement:null,chatContainer:null,placeholder:null,isInteractionStarted:!1,isPlaceholderVisible:!0,isStreaming:!1,isNavigatingAway:!1,autoScroll:!0,stream:null,messages:[],prompt:"",initialFieldValues:new Map,settingsDirty:!1,saveSettingsTimeout:null,saveIndicatorTimeout:null,isRecording:!1,mediaRecorder:null,preRecordingPrompt:"",micButton:null,speechToTextEnabled:"AudioInput"===n.chatMode||"Conversation"===n.chatMode,textToSpeechEnabled:"Conversation"===n.chatMode,ttsVoiceName:n.ttsVoiceName||null,audioChunks:[],audioPlayQueue:[],isPlayingAudio:!1,currentAudioElement:null,conversationModeEnabled:"Conversation"===n.chatMode,conversationButton:null,isConversationMode:!1,notifications:[],notificationDismissTimers:{}}},computed:{lastAssistantIndex:function(){for(var e=this.messages.length-1;e>=0;e--)if("assistant"===this.messages[e].role)return e;return-1}},methods:{handleBeforeUnload:function(){this.isNavigatingAway=!0},startConnection:function(){var e=this;return _asyncToGenerator(_regenerator().m(function t(){var i;return _regenerator().w(function(t){for(;;)switch(t.p=t.n){case 0:return e.connection=(new signalR.HubConnectionBuilder).withUrl(n.signalRHubUrl).withAutomaticReconnect().build(),e.connection.serverTimeoutInMilliseconds=6e5,e.connection.keepAliveIntervalInMilliseconds=15e3,e.connection.on("LoadInteraction",function(t){var n;e.initializeInteraction(t.itemId,!0),e.messages=[];var i=document.querySelector('[data-chat-interaction-title], .setting-input[data-setting="title"], input[name="ChatInteraction.Title"], input[name="Title"]');i&&t.title&&(i.value=t.title),(null!==(n=t.messages)&&void 0!==n?n:[]).forEach(function(t){e.addMessage(t),e.$nextTick(function(){r(t)})})}),e.connection.on("SettingsSaved",function(t,i){var o=document.querySelector('.chat-interaction-history-item[data-interaction-id="'.concat(t,'"]'));o&&(o.textContent=i||n.untitledText);var a=document.querySelector('[data-chat-interaction-title], .setting-input[data-setting="title"], input[name="ChatInteraction.Title"], input[name="Title"]');a&&i&&(a.value=i),e.showSaveIndicator("Saved","text-success")}),e.connection.on("ReceiveError",function(t){console.error("SignalR Error: ",t),e.showSaveIndicator("Save failed","text-danger"),e.isRecording&&e.stopRecording()}),e.connection.on("ReceiveTranscript",function(t,n,i){if(e.isConversationMode){if(!i&&n){e._conversationPartialTranscript=n;var o='<p class="ai-partial-transcript">'+n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")+"</p>";e._conversationPartialMessage?(e._conversationPartialMessage.content=n,e._conversationPartialMessage.htmlContent=o):(e.hidePlaceholder(),e._conversationPartialMessage={role:"user",content:n,htmlContent:o,isPartial:!0},e.messages.push(e._conversationPartialMessage)),e.scrollToBottom()}}else n&&!e._audioInputSent&&(e.prompt=e.preRecordingPrompt+n,e.inputElement&&(e.inputElement.value=e.prompt,e.inputElement.dispatchEvent(new Event("input"))))}),e.connection.on("ReceiveConversationUserMessage",function(t,n){if(n){if(e.stopAudio(),e._conversationAssistantMessage){var i=e.messages[e._conversationAssistantMessage.index];i&&(i.isStreaming=!1),e._conversationAssistantMessage=null}if(e._conversationPartialMessage){var o=n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");e._conversationPartialMessage.content=n,e._conversationPartialMessage.htmlContent="<p>"+o+"</p>",e._conversationPartialMessage.isPartial=!1,e._conversationPartialMessage=null}else e.addMessage({role:"user",content:n});e.scrollToBottom()}}),e.connection.on("ReceiveConversationAssistantToken",function(t,n,i,o,a){if(!e._conversationAssistantMessage){e.stopAudio(),e.hideTypingIndicator();for(var c=0;c<e.messages.length;c++)e.messages[c].isStreaming&&(e.messages[c].isStreaming=!1);var l=e.messages.length,u={id:n,role:"assistant",content:"",htmlContent:"",isStreaming:!0,appearance:e.normalizeAssistantAppearance(a)};e.messages.push(u),e._conversationAssistantMessage={index:l,content:""}}e._conversationAssistantMessage.content+=i;var d=e.messages[e._conversationAssistantMessage.index];d&&(d.appearance||(d.appearance=e.normalizeAssistantAppearance(a)),d.content=e._conversationAssistantMessage.content,d.htmlContent=s(d.content,d),e.$nextTick(function(){r(d),e.scrollToBottom()}))}),e.connection.on("ReceiveConversationAssistantComplete",function(t,n){if(e._conversationAssistantMessage){var i=e.messages[e._conversationAssistantMessage.index];i&&(i.isStreaming=!1),e._conversationAssistantMessage=null}}),e.connection.on("ReceiveAudioChunk",function(t,n,i){if(n){for(var o=atob(n),a=new Uint8Array(o.length),r=0;r<o.length;r++)a[r]=o.charCodeAt(r);e.audioChunks.push(a)}}),e.connection.on("ReceiveAudioComplete",function(t){e.playCollectedAudio()}),e.connection.on("HistoryCleared",function(t){e.messages=[],e.showPlaceholder();var n=document.getElementById("clearHistoryBtn");n&&n.classList.add("d-none")}),e.connection.on("ReceiveNotification",function(t){e.receiveNotification(t)}),e.connection.on("UpdateNotification",function(t){e.updateNotification(t)}),e.connection.on("RemoveNotification",function(t){e.removeNotification(t)}),e.connection.onreconnecting(function(){console.warn("SignalR: reconnecting...")}),e.connection.onreconnected(function(){console.info("SignalR: reconnected."),e.reloadCurrentInteraction()}),e.connection.onclose(function(t){e.isNavigatingAway||t&&console.warn("SignalR connection closed with error:",t.message||t)}),t.p=1,t.n=2,e.connection.start();case 2:t.n=4;break;case 3:t.p=3,i=t.v,console.error("SignalR Connection Error: ",i);case 4:return t.a(2)}},t,null,[[1,3]])}))()},addMessageInternal:function(e){var t=this;"assistant"===e.role&&(e.appearance=this.normalizeAssistantAppearance(e.appearance)),e.content&&!e.htmlContent&&(e.htmlContent=s(e.content,e)),this.fireEvent(new CustomEvent("addingChatInteractionMessage",{detail:{message:e}})),this.messages.push(e),this.$nextTick(function(){t.fireEvent(new CustomEvent("addedChatInteractionMessage",{detail:{message:e}}))})},addMessage:function(e){var t=this;if(e.content){var n=e.content.trim();if(e.references&&"object"===_typeof(e.references)&&Object.keys(e.references).length){var i=Object.entries(e.references).filter(function(e){var t=_slicedToArray(e,1)[0];return n.includes(t)});if(i.length){i.sort(function(e,t){var n=_slicedToArray(e,2)[1],i=_slicedToArray(t,2)[1];return n.index-i.index});var o,a=1,c=_createForOfIteratorHelper(i);try{for(c.s();!(o=c.n()).done;){var l=_slicedToArray(o.value,2),u=l[0],d=l[1],h="__CITE_".concat(d.index,"__");n=n.replaceAll(u,h),d._displayIndex=a++,d._placeholder=h}}catch(e){c.e(e)}finally{c.f()}var m,f=_createForOfIteratorHelper(i);try{for(f.s();!(m=f.n()).done;){var g=_slicedToArray(m.value,2)[1];n=n.replaceAll(g._placeholder,"<sup><strong>".concat(g._displayIndex,"</strong></sup>"))}}catch(e){f.e(e)}finally{f.f()}n=n.replaceAll("</strong></sup><sup>","</strong></sup><sup>,</sup><sup>"),n+="<br><br>";var p,v=_createForOfIteratorHelper(i);try{for(v.s();!(p=v.n()).done;){var y=_slicedToArray(p.value,2),b=(y[0],y[1]),S=b.text||"[doc:".concat(b.index,"]");n+=b.link?"**".concat(b._displayIndex,"**. [").concat(S,"](").concat(b.link,")<br>"):"**".concat(b._displayIndex,"**. ").concat(S,"<br>")}}catch(e){v.e(e)}finally{v.f()}}}e.content=n,e.htmlContent=s(n,e)}this.addMessageInternal(e),this.hidePlaceholder(),this.$nextTick(function(){r(e),t.scrollToBottom()})},hidePlaceholder:function(){this.placeholder&&this.placeholder.classList.add("d-none"),this.isPlaceholderVisible=!1},showPlaceholder:function(){this.placeholder&&this.placeholder.classList.remove("d-none"),this.isPlaceholderVisible=!0},fireEvent:function(e){document.dispatchEvent(e)},normalizeAssistantAppearance:function(e){if(!e)return null;var t="string"==typeof e.label?e.label.trim():"",n="string"==typeof e.icon?e.icon.trim():"",i="string"==typeof e.cssClass?e.cssClass.trim():"",o=!!e.disableStreamingAnimation;return t||n||i||o?{label:t,icon:n,cssClass:i,disableStreamingAnimation:o}:null},getAssistantLabel:function(t){var n=t?this.normalizeAssistantAppearance(t.appearance):null;return n&&n.label?n.label:e.assistantLabel},getAssistantRoleClasses:function(e){var t=e?this.normalizeAssistantAppearance(e.appearance):null,n=["ai-chat-msg-role"];return t&&t.cssClass?n.push(t.cssClass):n.push("ai-chat-msg-role-assistant"),n},getAssistantIconClasses:function(e,t){var n=e?this.normalizeAssistantAppearance(e.appearance):null;return[this.shouldAnimateAssistantIcon(e,t)?"ai-streaming-icon":"ai-bot-icon",n&&n.cssClass?n.cssClass:""]},getAssistantIcon:function(e){var t=e?this.normalizeAssistantAppearance(e.appearance):null;return t&&t.icon?t.icon:"fa fa-robot"},shouldAnimateAssistantIcon:function(e,t){var n=e?this.normalizeAssistantAppearance(e.appearance):null;return!!e&&e.isStreaming&&t===this.lastAssistantIndex&&!(n&&n.disableStreamingAnimation)},isIndicator:function(e){return"indicator"===e.role},sendMessage:function(){var e=this;return _asyncToGenerator(_regenerator().m(function t(){var n,i;return _regenerator().w(function(t){for(;;)switch(t.n){case 0:if(n=e.prompt.trim()){t.n=1;break}return t.a(2);case 1:return e.isRecording&&e.stopRecording(),e._audioInputSent=!0,t.n=2,e.flushPendingSave();case 2:e.addMessage({role:"user",content:n}),(i=document.getElementById("clearHistoryBtn"))&&i.classList.remove("d-none"),e.streamMessage(n),e.inputElement.value="",e.prompt="";case 3:return t.a(2)}},t)}))()},streamMessage:function(e){var t=this;this.stream&&(this.stream.dispose(),this.stream=null),this.streamingStarted(),this.showTypingIndicator(),this.autoScroll=!0;var n="",i={},o=null,a=this.messages.length,c=this.getItemId();this.stream=this.connection.stream("SendMessage",c,e).subscribe({next:function(e){var l=t.messages[a];if(!l){e.sessionId&&!c&&t.setItemId(e.sessionId),t.hideTypingIndicator(),a=t.messages.length;var u={role:"assistant",content:"",htmlContent:"",isStreaming:!0};t.messages.push(u),l=u}if(e.references&&"object"===_typeof(e.references)&&Object.keys(e.references).length)for(var d=0,h=Object.entries(e.references);d<h.length;d++){var m=_slicedToArray(h[d],2),f=m[0],g=m[1];i[f]=g}if(e.content){e.responseId&&o&&e.responseId!==o&&(n+="\n\n"),e.responseId&&(o=e.responseId);for(var p=e.content,v=0,y=Object.entries(i);v<y.length;v++){var b=_slicedToArray(y[v],2),S=b[0],A=b[1];p=p.replaceAll(S,"<sup><strong>".concat(A.index,"</strong></sup>"))}n+=p.replaceAll("</strong></sup><sup>","</strong></sup><sup>,</sup><sup>")}l.content=n,l.htmlContent=s(n,l),t.messages[a]=l,t.$nextTick(function(){r(l),t.scrollToBottom()})},complete:function(){var e;t.processReferences(i,a),t.streamingFinished();var n=t.messages[a];n&&(n.isStreaming=!1),n&&n.content||t.hideTypingIndicator(),t.isConversationMode&&t.textToSpeechEnabled&&n&&n.content&&t.synthesizeSpeech(n.content),null===(e=t.stream)||void 0===e||e.dispose(),t.stream=null},error:function(e){var n;t.processReferences(i,a),t.streamingFinished();var o=t.messages[a];o&&(o.isStreaming=!1),t.hideTypingIndicator(),t.isNavigatingAway||t.addMessage(t.getServiceDownMessage()),null===(n=t.stream)||void 0===n||n.dispose(),t.stream=null,console.error("Stream error:",e)}})},getServiceDownMessage:function(){return{role:"assistant",content:"Our service is currently unavailable. Please try again later. We apologize for the inconvenience.",htmlContent:""}},processReferences:function(e,t){var n=this;if(Object.keys(e).length){var i=this.messages[t],o=i.content||"",a=Object.entries(e).filter(function(e){var t=_slicedToArray(e,2),n=t[0],i=t[1];return o.includes(n)||o.includes("<sup><strong>".concat(i.index,"</strong></sup>"))});if(!a.length)return;a.sort(function(e,t){var n=_slicedToArray(e,2)[1],i=_slicedToArray(t,2)[1];return n.index-i.index});var c,l=o.trim(),u=1,d=_createForOfIteratorHelper(a);try{for(d.s();!(c=d.n()).done;){var h=_slicedToArray(c.value,2),m=h[0],f=h[1],g="__CITE_".concat(f.index,"__");l=(l=l.replaceAll(m,g)).replaceAll("<sup><strong>".concat(f.index,"</strong></sup>"),g),f._displayIndex=u++,f._placeholder=g}}catch(e){d.e(e)}finally{d.f()}var p,v=_createForOfIteratorHelper(a);try{for(v.s();!(p=v.n()).done;){var y=_slicedToArray(p.value,2)[1];l=l.replaceAll(y._placeholder,"<sup><strong>".concat(y._displayIndex,"</strong></sup>"))}}catch(e){v.e(e)}finally{v.f()}l=l.replaceAll("</strong></sup><sup>","</strong></sup><sup>,</sup><sup>"),l+="<br><br>";var b,S=_createForOfIteratorHelper(a);try{for(S.s();!(b=S.n()).done;){var A=_slicedToArray(b.value,2),I=(A[0],A[1]),C=I.text||"[doc:".concat(I.index,"]");l+=I.link?"**".concat(I._displayIndex,"**. [").concat(C,"](").concat(I.link,")<br>"):"**".concat(I._displayIndex,"**. ").concat(C,"<br>")}}catch(e){S.e(e)}finally{S.f()}i.content=l,i.htmlContent=s(l,i),this.messages[t]=i,this.$nextTick(function(){r(i),n.scrollToBottom()})}},streamingStarted:function(){var e=this.buttonElement.getAttribute("data-stop-icon");e&&this.buttonElement.replaceChildren(DOMPurify.sanitize(e,{RETURN_DOM_FRAGMENT:!0}))},streamingFinished:function(){var e=this.buttonElement.getAttribute("data-start-icon");if(e&&this.buttonElement.replaceChildren(DOMPurify.sanitize(e,{RETURN_DOM_FRAGMENT:!0})),this.chatContainer)for(var t=this.chatContainer.querySelectorAll(".ai-streaming-icon"),n=0;n<t.length;n++)t[n].classList.remove("ai-streaming-icon"),t[n].classList.add("ai-bot-icon");for(n=0;n<this.messages.length;n++)this.messages[n].isStreaming&&(this.messages[n].isStreaming=!1);this.settingsDirty&&this.debouncedSaveSettings()},synthesizeSpeech:function(e){var t=this;this.textToSpeechEnabled&&e&&this.connection&&(this.audioChunks=[],this.isPlayingAudio=!0,this.connection.invoke("SynthesizeSpeech",this.getItemId(),e,this.ttsVoiceName).catch(function(e){console.error("TTS synthesis error:",e),t.isPlayingAudio=!1}))},playCollectedAudio:function(){if(0!==this.audioChunks.length){var e,t=this.audioChunks.reduce(function(e,t){return e+t.length},0),n=new Uint8Array(t),i=0,o=_createForOfIteratorHelper(this.audioChunks);try{for(o.s();!(e=o.n()).done;){var a=e.value;n.set(a,i),i+=a.length}}catch(e){o.e(e)}finally{o.f()}this.audioChunks=[];var r=new Blob([n],{type:"audio/mp3"});this.isPlayingAudio&&this.currentAudioElement?this.audioPlayQueue.push(r):this.playAudioBlob(r)}else this.isPlayingAudio||0!==this.audioPlayQueue.length||(this.isPlayingAudio=!1)},playAudioBlob:function(e){var t=this,n=URL.createObjectURL(e),i=new Audio(n);this.currentAudioElement=i,this.isPlayingAudio=!0,i.addEventListener("ended",function(){URL.revokeObjectURL(n),t.currentAudioElement=null,t.playNextInQueue()}),i.addEventListener("error",function(){URL.revokeObjectURL(n),t.currentAudioElement=null,t.playNextInQueue()}),i.play().catch(function(e){console.error("Audio playback error:",e),URL.revokeObjectURL(n),t.currentAudioElement=null,t.isPlayingAudio=!1})},playNextInQueue:function(){if(this.audioPlayQueue.length>0){var e=this.audioPlayQueue.shift();this.playAudioBlob(e)}else this.isPlayingAudio=!1,this.conversationModeOnAudioEnded()},stopAudio:function(){this.currentAudioElement&&(this.currentAudioElement.pause(),this.currentAudioElement.currentTime=0,this.currentAudioElement=null),this.audioChunks=[],this.audioPlayQueue=[],this.isPlayingAudio=!1},toggleConversationMode:function(){this.isConversationMode?this.stopConversationMode():this.startConversationMode()},startConversationMode:function(){var e=this;this.conversationModeEnabled&&!this.isConversationMode&&this.connection&&(this.isConversationMode=!0,this.updateConversationButton(),this._conversationPartialTranscript="",this._conversationAssistantMessage=null,this._conversationPartialMessage=null,this.removeNotification("conversation-ended"),navigator.mediaDevices.getUserMedia({audio:{echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0}}).then(function(t){var n=MediaRecorder.isTypeSupported("audio/ogg;codecs=opus")?"audio/ogg;codecs=opus":MediaRecorder.isTypeSupported("audio/webm;codecs=opus")?"audio/webm;codecs=opus":"audio/webm";e.mediaRecorder=new MediaRecorder(t,{mimeType:n,audioBitsPerSecond:128e3}),e._conversationSubject=new signalR.Subject,e._conversationStream=t;var i=window.AudioContext||window.webkitAudioContext;i&&(e._conversationAudioCtx=new i,e._conversationAnalyser=e._conversationAudioCtx.createAnalyser(),e._conversationAnalyser.fftSize=256,e._conversationAudioCtx.createMediaStreamSource(t).connect(e._conversationAnalyser));var o=Promise.resolve(),a=e._conversationAnalyser;e.mediaRecorder.addEventListener("dataavailable",function(t){if(t.data&&t.data.size>0){if(e.isPlayingAudio&&a){var n=new Uint8Array(a.frequencyBinCount);a.getByteFrequencyData(n);for(var i=0,r=0;r<n.length;r++)i+=n[r];i/n.length>=30&&e.stopAudio()}o=o.then(_asyncToGenerator(_regenerator().m(function n(){var i,o,a,r;return _regenerator().w(function(n){for(;;)switch(n.n){case 0:return n.n=1,t.data.arrayBuffer();case 1:i=n.v,o=new Uint8Array(i),a=o.reduce(function(e,t){return e+String.fromCharCode(t)},""),r=btoa(a);try{e._conversationSubject.next(r)}catch(e){}case 2:return n.a(2)}},n)})))}}),e.mediaRecorder.addEventListener("stop",function(){t.getTracks().forEach(function(e){return e.stop()}),o.then(function(){try{e._conversationSubject.complete()}catch(e){}})});var r=e.getItemId(),s=navigator.language||document.documentElement.lang||"en-US";e.connection.send("StartConversation",r,e._conversationSubject,n,s),e.mediaRecorder.start(250),e.isRecording=!0}).catch(function(t){console.error("Microphone access denied:",t),e.isConversationMode=!1,e.updateConversationButton()}))},stopConversationMode:function(){if(this.isConversationMode){if(this.isConversationMode=!1,this.updateConversationButton(),this.connection&&this.connection.invoke("StopConversation").catch(function(){}),this.isRecording&&this.mediaRecorder&&(this.mediaRecorder.stop(),this.isRecording=!1),this.stopAudio(),this._conversationPartialTranscript="",this._conversationPartialMessage=null,this._conversationAudioCtx&&(this._conversationAudioCtx.close().catch(function(){}),this._conversationAudioCtx=null,this._conversationAnalyser=null),this._conversationAssistantMessage){var e=this.messages[this._conversationAssistantMessage.index];e&&(e.isStreaming=!1),this._conversationAssistantMessage=null}for(var t=0;t<this.messages.length;t++)this.messages[t].isStreaming&&(this.messages[t].isStreaming=!1);this.receiveNotification({type:"conversation-ended",content:"Conversation ended.",icon:"fa-solid fa-circle-check",dismissible:!0,autoDismissMs:5e3})}},updateConversationButton:function(){if(this.conversationButton)if(this.isConversationMode){this.conversationButton.classList.add("active","btn-primary"),this.conversationButton.classList.remove("btn-dark","btn-outline-dark","btn-outline-secondary"),this.conversationButton.title=this.conversationButton.getAttribute("data-end-title")||"End Conversation";var e=this.conversationButton.getAttribute("data-end-html");e&&this.conversationButton.replaceChildren(DOMPurify.sanitize(e,{RETURN_DOM_FRAGMENT:!0}))}else{this.conversationButton.classList.remove("active","btn-primary"),this.conversationButton.classList.remove("btn-dark","btn-outline-secondary"),this.conversationButton.classList.add("btn-outline-dark"),this.conversationButton.blur(),this.conversationButton.title=this.conversationButton.getAttribute("data-start-title")||"Start Conversation";var t=this.conversationButton.getAttribute("data-start-html");t&&this.conversationButton.replaceChildren(DOMPurify.sanitize(t,{RETURN_DOM_FRAGMENT:!0}))}},conversationModeSendPrompt:function(){},conversationModeOnAudioEnded:function(){},showTypingIndicator:function(){this.addMessage({role:"indicator",htmlContent:n.indicatorTemplate})},hideTypingIndicator:function(){var e=this.messages.length;return this.messages=this.messages.filter(function(e){return"indicator"!==e.role}),e-this.messages.length},scrollToBottom:function(){var e=this;this.autoScroll&&setTimeout(function(){e.chatContainer.scrollTop=e.chatContainer.scrollHeight-e.chatContainer.clientHeight},50)},handleUserInput:function(e){this.prompt=e.target.value},getItemId:function(){return this.inputElement.getAttribute("data-interaction-id")||this.inputElement.getAttribute("data-item-id")},getSaveIndicatorElement:function(){return n.saveIndicatorElementSelector?document.querySelector(n.saveIndicatorElementSelector):document.querySelector("[data-chat-interaction-save-indicator]")},showSaveIndicator:function(e,t){var n=this,i=this.getSaveIndicatorElement();i&&(i.textContent=e||"",i.className="settings-save-indicator "+(t||"text-muted"),this.saveIndicatorTimeout&&(clearTimeout(this.saveIndicatorTimeout),this.saveIndicatorTimeout=null),e&&(this.saveIndicatorTimeout=setTimeout(function(){i.textContent="",n.saveIndicatorTimeout=null},3e3)))},clearPendingSettingsSave:function(){this.saveSettingsTimeout&&(clearTimeout(this.saveSettingsTimeout),this.saveSettingsTimeout=null)},getFieldLabel:function(e){var t,n=null===(t=e.closest(".mb-3, .col-6, .col, .form-group, .form-floating"))||void 0===t?void 0:t.querySelector("label");return n?(n.textContent||"").replace(/\s+/g," ").trim()||e.dataset.setting||"This field":e.dataset.setting||"This field"},getValidationFeedbackElement:function(e){var t=e.nextElementSibling;return t&&t.classList.contains("invalid-feedback")||((t=document.createElement("div")).className="invalid-feedback",e.insertAdjacentElement("afterend",t)),t},clearSettingValidationError:function(e){e.classList.remove("is-invalid"),e.removeAttribute("aria-invalid");var t=e.nextElementSibling;t&&t.classList.contains("invalid-feedback")&&(t.textContent="")},setSettingValidationError:function(e,t){var n=this.getValidationFeedbackElement(e);e.classList.add("is-invalid"),e.setAttribute("aria-invalid","true"),n.textContent=t},getSettingValidationMessage:function(e){if(!e||e.disabled||"number"!==e.type)return null;var t=(e.value||"").trim();if(!t)return null;var n=Number(t),i=this.getFieldLabel(e);if(Number.isNaN(n))return"".concat(i," must be a valid number.");var o=e.getAttribute("min");if(null!==o&&n<Number(o))return"".concat(i," must be ").concat(o," or greater.");var a=e.getAttribute("max");return null!==a&&n>Number(a)?"".concat(i," must be ").concat(a," or less."):null},validateSettingInput:function(e){var t=this.getSettingValidationMessage(e);return t?(this.setSettingValidationError(e,t),!1):(this.clearSettingValidationError(e),!0)},validateSettings:function(){var e=this,t=!0;return this.getSettingInputs().forEach(function(n){t=e.validateSettingInput(n)&&t}),t},queueSettingsSave:function(){if(!this.validateSettings())return this.clearPendingSettingsSave(),this.settingsDirty=!1,void this.showSaveIndicator("Fix errors","text-danger");this.settingsDirty=!0,this.showSaveIndicator("Saving...","text-warning"),this.debouncedSaveSettings()},getSettingInputs:function(){var e=document.querySelectorAll(".setting-input[data-setting]");return e.length>0?e:document.querySelectorAll('input[name^="ChatInteraction."]:not([name*=".Tools["]):not([name*=".Connections["]), select[name^="ChatInteraction."]:not([name*=".Tools["]):not([name*=".Connections["]), textarea[name^="ChatInteraction."]:not([name*=".Tools["]):not([name*=".Connections["])')},getSelectedGroupValues:function(e,t){var n=document.querySelectorAll('.capability-checkbox[data-save-group="'.concat(e,'"]:checked'));if(n.length>0){var i=[];return n.forEach(function(e){var t=e.getAttribute("data-item-id")||e.value;t&&i.push(t)}),i}if(!t)return[];var o=[];return document.querySelectorAll(t).forEach(function(e){var t=e.name.replace(".IsSelected",".ItemId"),n=document.querySelector('input[type="hidden"][name="'.concat(t,'"]'));n&&n.value&&o.push(n.value)}),o},getPromptTemplateSelections:function(){var e=[];return document.querySelectorAll(".prompt-template-card").forEach(function(t){var n=t.querySelector(".prompt-template-id-input"),i=t.querySelector(".prompt-template-parameters-input"),o=n?n.value:t.getAttribute("data-template-id");o&&e.push({templateId:o,promptParameters:i?(i.value||"").trim():""})}),e},receiveNotification:function(e){if(e&&e.type){this.clearNotificationDismiss(e.type);var t=this.notifications.findIndex(function(t){return t.type===e.type});t>=0?this.notifications.splice(t,1,e):this.notifications.push(e),this.scheduleNotificationDismiss(e),this.scrollToBottom()}},updateNotification:function(e){if(e&&e.type){this.clearNotificationDismiss(e.type);var t=this.notifications.findIndex(function(t){return t.type===e.type});t>=0&&(this.notifications.splice(t,1,e),this.scheduleNotificationDismiss(e),this.scrollToBottom())}},scheduleNotificationDismiss:function(e){var t=this;e&&e.type&&e.autoDismissMs&&!(e.autoDismissMs<=0)&&(this.notificationDismissTimers[e.type]=setTimeout(function(){t.removeNotification(e.type)},e.autoDismissMs))},clearNotificationDismiss:function(e){var t=this.notificationDismissTimers[e];t&&(clearTimeout(t),delete this.notificationDismissTimers[e])},removeNotification:function(e){this.clearNotificationDismiss(e),this.notifications=this.notifications.filter(function(t){return t.type!==e})},dismissNotification:function(e){this.removeNotification(e)},handleNotificationAction:function(e,t){if(this.connection){var n=this.getItemId();this.connection.invoke("HandleNotificationAction",n,e,t).catch(function(e){return console.error("Failed to handle notification action:",e)})}},setItemId:function(e){this.inputElement.setAttribute("data-interaction-id",e||""),this.inputElement.setAttribute("data-item-id",e||"")},resetInteraction:function(){this.setItemId(""),this.isInteractionStarted=!1,this.messages=[],this.showPlaceholder()},initializeApp:function(){var e=this;this.inputElement=document.querySelector(n.inputElementSelector),this.buttonElement=document.querySelector(n.sendButtonElementSelector),this.chatContainer=document.querySelector(n.chatContainerElementSelector),this.placeholder=document.querySelector(n.placeholderElementSelector);var t=this.getItemId();t&&this.loadInteraction(t),this.chatContainer.addEventListener("scroll",function(){if(e.stream){var t=e.chatContainer.scrollHeight-e.chatContainer.clientHeight-e.chatContainer.scrollTop<=30;e.autoScroll=t}}),this.inputElement.addEventListener("keyup",function(t){null==e.stream&&("Enter"!==t.key||t.shiftKey||e.buttonElement.click())}),this.inputElement.addEventListener("input",function(t){e.handleUserInput(t),t.target.value.trim()?e.buttonElement.removeAttribute("disabled"):e.buttonElement.setAttribute("disabled",!0)}),this.inputElement.addEventListener("paste",function(t){setTimeout(function(){e.prompt=e.inputElement.value,e.inputElement.value.trim()?e.buttonElement.removeAttribute("disabled"):e.buttonElement.setAttribute("disabled",!0)},0)}),this.buttonElement.addEventListener("click",function(){if(null==e.stream)e.sendMessage();else if(e.stream.dispose(),e.stream=null,e.streamingFinished(),e.hideTypingIndicator(),e.messages.length>0){var t=e.messages[e.messages.length-1];"assistant"!==t.role||t.content?t.isStreaming&&(t.isStreaming=!1):e.messages.pop()}});for(var i=document.getElementsByClassName("chat-interaction-history-item"),o=0;o<i.length;o++)i[o].addEventListener("click",function(t){t.preventDefault();var n=t.target.getAttribute("data-interaction-id");n?e.loadInteraction(n):console.error("An element with the class chat-interaction-history-item with no data-interaction-id set.")});for(var a=0;a<n.messages.length;a++)this.addMessage(n.messages[a]);this.chatContainer&&this.chatContainer.addEventListener("click",function(e){var t=e.target.closest(".ai-code-copy-btn");if(t){var i=t.closest(".ai-code-block")||t.closest("pre");if(i){var o=i.querySelector("code");if(o){navigator.clipboard.writeText(o.textContent);var a=n.codeCopiedText||"Copied!";t.innerHTML='<i class="fa-solid fa-check"></i> '+a,setTimeout(function(){t.innerHTML='<i class="fa-regular fa-copy"></i>'},2e3)}}}}),document.addEventListener("input",function(t){t.target.matches(".setting-input[data-setting]")&&(e.validateSettingInput(t.target),e.queueSettingsSave())}),document.addEventListener("change",function(t){if(t.target.matches(".setting-input[data-setting], .capability-checkbox[data-save-group], .group-toggle, .ci-agent-global-toggle"))return t.target.matches(".setting-input[data-setting]")&&e.validateSettingInput(t.target),void e.queueSettingsSave();t.target.closest(".prompt-template-parameters-input, .prompt-template-id-input")&&e.queueSettingsSave()}),document.addEventListener("click",function(t){t.target.closest(".prompt-template-add-btn, .remove-prompt-template-btn")&&setTimeout(function(){e.queueSettingsSave()},0)});var r=document.getElementById("clearHistoryBtn");r&&r.addEventListener("click",function(){var t=r.getAttribute("data-interaction-id");t&&e.clearHistory(t)}),this.speechToTextEnabled&&n.micButtonElementSelector&&(this.micButton=document.querySelector(n.micButtonElementSelector),this.micButton&&(this.micButton.style.display="",this.micButton.addEventListener("click",function(){e.toggleRecording()}))),this.conversationModeEnabled&&n.conversationButtonElementSelector&&(this.conversationButton=document.querySelector(n.conversationButtonElementSelector),this.conversationButton&&this.conversationButton.addEventListener("click",function(){e.toggleConversationMode()}))},loadInteraction:function(e){this.connection.invoke("LoadInteraction",e).catch(function(e){return console.error(e)})},reloadCurrentInteraction:function(){var e=this.getItemId();e&&this.loadInteraction(e)},clearHistory:function(e){var t=this;confirmDialog({title:n.clearHistoryTitle,message:n.clearHistoryMessage,okText:n.clearHistoryOkText,cancelText:n.clearHistoryCancelText,callback:function(n){n&&(t.stream&&(t.stream.dispose(),t.stream=null,t.hideTypingIndicator(),t.streamingFinished()),t.connection.invoke("ClearHistory",e).catch(function(e){return console.error("Error clearing history:",e)}))}})},debouncedSaveSettings:function(){var e=this;this.clearPendingSettingsSave(),this.stream||(this.saveSettingsTimeout=setTimeout(function(){e.settingsDirty&&(e.saveSettings(),e.settingsDirty=!1),e.saveSettingsTimeout=null},850))},getSelectedToolNames:function(){return this.getSelectedGroupValues("toolNames",'input[type="checkbox"][name$="].IsSelected"][name^="ChatInteraction.Tools["]:checked')},getSelectedMcpConnectionIds:function(){return this.getSelectedGroupValues("mcpConnectionIds",'input[type="checkbox"][name$="].IsSelected"][name^="ChatInteraction.Connections["]:checked')},getSelectedA2AConnectionIds:function(){return this.getSelectedGroupValues("a2aConnectionIds")},getSelectedAgentNames:function(){return this.getSelectedGroupValues("agentNames",'input[type="checkbox"][name$="].IsSelected"][name^="ChatInteraction.Agents["]:checked')},saveSettings:function(){var e=this,t=this.getItemId();if(!t)return Promise.resolve();if(!this.validateSettings())return this.showSaveIndicator("Fix errors","text-danger"),Promise.resolve();var n={};this.getSettingInputs().forEach(function(e){var t=e.dataset.setting||(e.name||"").replace("ChatInteraction.","").replace(/^[A-Z]/,function(e){return e.toLowerCase()});t&&("checkbox"===e.type?n[t]=e.checked:"number"===e.type?n[t]=e.value?parseFloat(e.value):null:n[t]=e.value||null)}),n.toolNames=this.getSelectedToolNames(),n.mcpConnectionIds=this.getSelectedMcpConnectionIds(),n.a2aConnectionIds=this.getSelectedA2AConnectionIds(),n.agentNames=this.getSelectedAgentNames();var i=this.getPromptTemplateSelections();return i.length>0&&(n.promptTemplates=i,n.promptTemplateIds=i.map(function(e){return e.templateId})),this.connection.invoke("SaveSettings",t,n).catch(function(t){console.error("Error saving settings:",t),e.showSaveIndicator("Save failed","text-danger")})},flushPendingSave:function(){return this.saveSettingsTimeout&&(clearTimeout(this.saveSettingsTimeout),this.saveSettingsTimeout=null),this.settingsDirty?(this.settingsDirty=!1,this.saveSettings()):Promise.resolve()},initializeInteraction:function(e,t){this.isInteractionStarted&&!t||(this.fireEvent(new CustomEvent("initializingChatInteraction",{detail:{itemId:e}})),this.setItemId(e),this.isInteractionStarted=!0)},copyResponse:function(e){navigator.clipboard.writeText(e)},startRecording:function(){var e=this;!this.isRecording&&this.connection&&navigator.mediaDevices.getUserMedia({audio:{echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0}}).then(function(t){var n=MediaRecorder.isTypeSupported("audio/ogg;codecs=opus")?"audio/ogg;codecs=opus":MediaRecorder.isTypeSupported("audio/webm;codecs=opus")?"audio/webm;codecs=opus":"audio/webm";e.mediaRecorder=new MediaRecorder(t,{mimeType:n,audioBitsPerSecond:128e3}),e.preRecordingPrompt=e.prompt,e._audioInputSent=!1;var i=new signalR.Subject,o=e.getItemId(),a=Promise.resolve();e.mediaRecorder.addEventListener("dataavailable",function(e){e.data&&e.data.size>0&&(a=a.then(_asyncToGenerator(_regenerator().m(function t(){var n,o,a,r;return _regenerator().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,e.data.arrayBuffer();case 1:n=t.v,o=new Uint8Array(n),a=o.reduce(function(e,t){return e+String.fromCharCode(t)},""),r=btoa(a),i.next(r);case 2:return t.a(2)}},t)}))))}),e.mediaRecorder.addEventListener("stop",function(){t.getTracks().forEach(function(e){return e.stop()}),a.then(function(){return i.complete()})});var r=navigator.language||document.documentElement.lang||"en-US";e.connection.send("SendAudioStream",o,i,n,r),e.mediaRecorder.start(250),e.isRecording=!0,e.updateMicButton()}).catch(function(e){console.error("Microphone access denied:",e)})},stopRecording:function(){this.isRecording&&this.mediaRecorder&&(this.mediaRecorder.stop(),this.isRecording=!1,this.updateMicButton())},toggleRecording:function(){this.isRecording?this.stopRecording():this.startRecording()},updateMicButton:function(){this.micButton&&(this.isRecording?(this.micButton.classList.add("stt-recording"),this.micButton.innerHTML='<i class="fa-solid fa-stop"></i>'):(this.micButton.classList.remove("stt-recording"),this.micButton.innerHTML='<i class="fa-solid fa-microphone"></i>'))}},watch:{isPlayingAudio:function(){},isConversationMode:function(e){this.micButton&&(this.micButton.style.display=e?"none":this.speechToTextEnabled?"":"none"),this.buttonElement&&(this.buttonElement.style.display=e?"none":""),this.inputElement&&(this.inputElement.disabled=e,e&&(this.inputElement.placeholder=""))}},mounted:function(){var e=this;_asyncToGenerator(_regenerator().m(function t(){return _regenerator().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,e.startConnection();case 1:e.initializeApp();case 2:return t.a(2)}},t)}))(),window.addEventListener("beforeunload",this.handleBeforeUnload)},beforeUnmount:function(){window.removeEventListener("beforeunload",this.handleBeforeUnload),this.stream&&(this.stream.dispose(),this.stream=null),this.connection&&this.connection.stop()},template:n.messageTemplate}).mount(n.appElementSelector);console.error("The sendButtonElementSelector is required.")}else console.error("The inputElementSelector is required.");else console.error("The chatContainerElementSelector is required.");else console.error("The appElementSelector is required.");else console.error("The signalRHubUrl is required.")}}}(),document.addEventListener("click",function(e){var t=e.target.closest(".download-chart-btn");if(t){var n=t.getAttribute("data-chart-id"),i=n?document.getElementById(n):null;if(i){var o=document.createElement("a");o.download="chart-"+n+".png",o.href=i.toDataURL("image/png"),o.click()}else console.error("Chart canvas not found:",n)}}),document.addEventListener("click",function(e){var t=e.target.closest(".ai-download-image");if(t){var n=t.closest(".generated-image-container"),i=null==n?void 0:n.querySelector("img");if(i){var o=i.src;o&&o.startsWith("data:")&&(e.preventDefault(),fetch(o).then(function(e){return e.blob()}).then(function(e){var n=URL.createObjectURL(e),i=document.createElement("a");i.href=n,i.download=t.getAttribute("download")||"generated-image.png",document.body.appendChild(i),i.click(),document.body.removeChild(i),setTimeout(function(){URL.revokeObjectURL(n)},100)}).catch(function(e){console.error("Failed to download image:",e)}))}}});
@@ -0,0 +1,232 @@
1
+ /* CrestApps AI Chat Widget */
2
+ :root {
3
+ --ai-widget-primary: var(--bs-secondary, #6c757d);
4
+ --ai-widget-width: 380px;
5
+ --ai-widget-height: 520px;
6
+ }
7
+
8
+ .ai-chat-widget-toggle {
9
+ position: fixed;
10
+ bottom: 1.25rem;
11
+ right: 1.25rem;
12
+ z-index: 10000;
13
+ width: 52px;
14
+ height: 52px;
15
+ border-radius: 50%;
16
+ background: var(--ai-widget-primary);
17
+ color: white;
18
+ border: none;
19
+ cursor: pointer;
20
+ display: flex;
21
+ align-items: center;
22
+ justify-content: center;
23
+ font-size: 1.5rem;
24
+ box-shadow: 0 4px 12px rgba(0,0,0,0.2);
25
+ transition: transform 0.2s, box-shadow 0.2s;
26
+ }
27
+
28
+ .ai-chat-widget-toggle:hover {
29
+ transform: scale(1.1);
30
+ box-shadow: 0 6px 16px rgba(0,0,0,0.3);
31
+ }
32
+
33
+ .ai-chat-widget-container {
34
+ position: fixed;
35
+ bottom: 5rem;
36
+ right: 1.25rem;
37
+ z-index: 10001;
38
+ width: var(--ai-widget-width);
39
+ height: var(--ai-widget-height);
40
+ background: #fff;
41
+ border-radius: 12px;
42
+ box-shadow: 0 8px 32px rgba(0,0,0,0.18);
43
+ display: none;
44
+ flex-direction: column;
45
+ overflow: hidden;
46
+ }
47
+
48
+ .ai-chat-widget-container.open {
49
+ display: flex;
50
+ }
51
+
52
+ .ai-chat-widget-header {
53
+ display: flex;
54
+ align-items: center;
55
+ justify-content: space-between;
56
+ padding: 0.75rem 1rem;
57
+ background: var(--ai-widget-primary);
58
+ color: white;
59
+ }
60
+
61
+ .ai-chat-widget-header .title {
62
+ font-weight: 600;
63
+ font-size: 0.95rem;
64
+ }
65
+
66
+ .ai-chat-widget-header button {
67
+ background: none;
68
+ border: none;
69
+ color: white;
70
+ cursor: pointer;
71
+ font-size: 1rem;
72
+ padding: 0 0.25rem;
73
+ opacity: 0.8;
74
+ }
75
+
76
+ .ai-chat-widget-header button:hover {
77
+ opacity: 1;
78
+ }
79
+
80
+ .ai-chat-widget-profile-select {
81
+ padding: 0.5rem 0.75rem;
82
+ border-bottom: 1px solid #e9ecef;
83
+ background: #f8f9fa;
84
+ }
85
+
86
+ .ai-chat-widget-profile-select select {
87
+ width: 100%;
88
+ padding: 0.35rem 0.5rem;
89
+ border: 1px solid #ced4da;
90
+ border-radius: 6px;
91
+ font-size: 0.85rem;
92
+ }
93
+
94
+ .ai-chat-widget-messages {
95
+ flex: 1;
96
+ overflow-y: auto;
97
+ padding: 0.75rem;
98
+ font-size: 0.9rem;
99
+ }
100
+
101
+ .ai-chat-widget-messages .msg {
102
+ margin-bottom: 0.75rem;
103
+ display: flex;
104
+ gap: 0.5rem;
105
+ }
106
+
107
+ .ai-chat-widget-messages .msg.user {
108
+ flex-direction: row-reverse;
109
+ }
110
+
111
+ .ai-chat-widget-messages .msg .bubble {
112
+ max-width: 80%;
113
+ padding: 0.5rem 0.75rem;
114
+ border-radius: 10px;
115
+ line-height: 1.4;
116
+ word-wrap: break-word;
117
+ }
118
+
119
+ .ai-chat-widget-messages .msg.user .bubble {
120
+ background: var(--ai-widget-primary);
121
+ color: white;
122
+ border-bottom-right-radius: 2px;
123
+ }
124
+
125
+ .ai-chat-widget-messages .msg.assistant .bubble {
126
+ background: #f1f3f5;
127
+ color: #212529;
128
+ border-bottom-left-radius: 2px;
129
+ }
130
+
131
+ .ai-chat-widget-messages .msg.system .bubble {
132
+ background: #fff3cd;
133
+ color: #664d03;
134
+ font-size: 0.85rem;
135
+ width: 100%;
136
+ text-align: center;
137
+ }
138
+
139
+ .ai-chat-widget-messages .msg .bubble.streaming::after {
140
+ content: '▌';
141
+ animation: blink 0.7s steps(1) infinite;
142
+ }
143
+
144
+ @keyframes blink {
145
+ 50% { opacity: 0; }
146
+ }
147
+
148
+ .ai-chat-widget-messages .msg .bubble pre {
149
+ background: #2d2d2d;
150
+ color: #f8f8f2;
151
+ padding: 0.5rem;
152
+ border-radius: 4px;
153
+ overflow-x: auto;
154
+ font-size: 0.8rem;
155
+ }
156
+
157
+ .ai-chat-widget-messages .msg .bubble code {
158
+ font-size: 0.85em;
159
+ }
160
+
161
+ .ai-chat-widget-messages .msg .bubble p:last-child {
162
+ margin-bottom: 0;
163
+ }
164
+
165
+ .ai-chat-widget-input {
166
+ border-top: 1px solid #e9ecef;
167
+ padding: 0.5rem 0.75rem;
168
+ display: flex;
169
+ gap: 0.5rem;
170
+ align-items: flex-end;
171
+ }
172
+
173
+ .ai-chat-widget-input textarea {
174
+ flex: 1;
175
+ border: 1px solid #ced4da;
176
+ border-radius: 8px;
177
+ padding: 0.4rem 0.6rem;
178
+ font-size: 0.9rem;
179
+ resize: none;
180
+ max-height: 80px;
181
+ min-height: 36px;
182
+ line-height: 1.4;
183
+ outline: none;
184
+ }
185
+
186
+ .ai-chat-widget-input textarea:focus {
187
+ border-color: var(--ai-widget-primary);
188
+ box-shadow: 0 0 0 2px rgba(65,182,112,0.15);
189
+ }
190
+
191
+ .ai-chat-widget-input button {
192
+ background: var(--ai-widget-primary);
193
+ color: white;
194
+ border: none;
195
+ border-radius: 8px;
196
+ padding: 0.4rem 0.75rem;
197
+ cursor: pointer;
198
+ font-size: 0.9rem;
199
+ white-space: nowrap;
200
+ }
201
+
202
+ .ai-chat-widget-input button:disabled {
203
+ opacity: 0.5;
204
+ cursor: not-allowed;
205
+ }
206
+
207
+ .ai-chat-widget-status {
208
+ padding: 0.25rem 0.75rem;
209
+ font-size: 0.8rem;
210
+ color: #6c757d;
211
+ display: none;
212
+ }
213
+
214
+ .ai-chat-widget-status.visible {
215
+ display: block;
216
+ }
217
+
218
+ .ai-chat-widget-welcome {
219
+ text-align: center;
220
+ color: #6c757d;
221
+ padding: 2rem 1rem;
222
+ font-size: 0.9rem;
223
+ }
224
+
225
+ @media (max-width: 576px) {
226
+ .ai-chat-widget-container {
227
+ width: calc(100vw - 1rem);
228
+ height: calc(100vh - 6rem);
229
+ right: 0.5rem;
230
+ bottom: 4.5rem;
231
+ }
232
+ }
@@ -0,0 +1 @@
1
+ :root{--ai-widget-primary:var(--bs-secondary, #6c757d);--ai-widget-width:380px;--ai-widget-height:520px}.ai-chat-widget-toggle{position:fixed;bottom:1.25rem;right:1.25rem;z-index:10000;width:52px;height:52px;border-radius:50%;background:var(--ai-widget-primary);color:#fff;border:none;cursor:pointer;display:flex;align-items:center;justify-content:center;font-size:1.5rem;box-shadow:0 4px 12px rgba(0,0,0,.2);transition:transform .2s,box-shadow .2s}.ai-chat-widget-toggle:hover{transform:scale(1.1);box-shadow:0 6px 16px rgba(0,0,0,.3)}.ai-chat-widget-container{position:fixed;bottom:5rem;right:1.25rem;z-index:10001;width:var(--ai-widget-width);height:var(--ai-widget-height);background:#fff;border-radius:12px;box-shadow:0 8px 32px rgba(0,0,0,.18);display:none;flex-direction:column;overflow:hidden}.ai-chat-widget-container.open{display:flex}.ai-chat-widget-header{display:flex;align-items:center;justify-content:space-between;padding:.75rem 1rem;background:var(--ai-widget-primary);color:#fff}.ai-chat-widget-header .title{font-weight:600;font-size:.95rem}.ai-chat-widget-header button{background:0 0;border:none;color:#fff;cursor:pointer;font-size:1rem;padding:0 .25rem;opacity:.8}.ai-chat-widget-header button:hover{opacity:1}.ai-chat-widget-profile-select{padding:.5rem .75rem;border-bottom:1px solid #e9ecef;background:#f8f9fa}.ai-chat-widget-profile-select select{width:100%;padding:.35rem .5rem;border:1px solid #ced4da;border-radius:6px;font-size:.85rem}.ai-chat-widget-messages{flex:1;overflow-y:auto;padding:.75rem;font-size:.9rem}.ai-chat-widget-messages .msg{margin-bottom:.75rem;display:flex;gap:.5rem}.ai-chat-widget-messages .msg.user{flex-direction:row-reverse}.ai-chat-widget-messages .msg .bubble{max-width:80%;padding:.5rem .75rem;border-radius:10px;line-height:1.4;word-wrap:break-word}.ai-chat-widget-messages .msg.user .bubble{background:var(--ai-widget-primary);color:#fff;border-bottom-right-radius:2px}.ai-chat-widget-messages .msg.assistant .bubble{background:#f1f3f5;color:#212529;border-bottom-left-radius:2px}.ai-chat-widget-messages .msg.system .bubble{background:#fff3cd;color:#664d03;font-size:.85rem;width:100%;text-align:center}.ai-chat-widget-messages .msg .bubble.streaming::after{content:'▌';animation:blink .7s steps(1) infinite}@keyframes blink{50%{opacity:0}}.ai-chat-widget-messages .msg .bubble pre{background:#2d2d2d;color:#f8f8f2;padding:.5rem;border-radius:4px;overflow-x:auto;font-size:.8rem}.ai-chat-widget-messages .msg .bubble code{font-size:.85em}.ai-chat-widget-messages .msg .bubble p:last-child{margin-bottom:0}.ai-chat-widget-input{border-top:1px solid #e9ecef;padding:.5rem .75rem;display:flex;gap:.5rem;align-items:flex-end}.ai-chat-widget-input textarea{flex:1;border:1px solid #ced4da;border-radius:8px;padding:.4rem .6rem;font-size:.9rem;resize:none;max-height:80px;min-height:36px;line-height:1.4;outline:0}.ai-chat-widget-input textarea:focus{border-color:var(--ai-widget-primary);box-shadow:0 0 0 2px rgba(65,182,112,.15)}.ai-chat-widget-input button{background:var(--ai-widget-primary);color:#fff;border:none;border-radius:8px;padding:.4rem .75rem;cursor:pointer;font-size:.9rem;white-space:nowrap}.ai-chat-widget-input button:disabled{opacity:.5;cursor:not-allowed}.ai-chat-widget-status{padding:.25rem .75rem;font-size:.8rem;color:#6c757d;display:none}.ai-chat-widget-status.visible{display:block}.ai-chat-widget-welcome{text-align:center;color:#6c757d;padding:2rem 1rem;font-size:.9rem}@media (max-width:576px){.ai-chat-widget-container{width:calc(100vw - 1rem);height:calc(100vh - 6rem);right:.5rem;bottom:4.5rem}}
@@ -0,0 +1,101 @@
1
+ .attached-documents-panel {
2
+ border: 1px solid var(--bs-border-color, #dee2e6);
3
+ border-radius: 0.75rem;
4
+ background: linear-gradient(180deg, rgba(13, 110, 253, 0.04), rgba(13, 110, 253, 0.01));
5
+ padding: 1rem;
6
+ }
7
+
8
+ .document-drop-zone {
9
+ position: relative;
10
+ border: 2px dashed rgba(13, 110, 253, 0.35);
11
+ border-radius: 1rem;
12
+ background: rgba(248, 249, 250, 0.8);
13
+ transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
14
+ }
15
+
16
+ .document-drop-zone:hover {
17
+ border-color: rgba(13, 110, 253, 0.55);
18
+ background: rgba(248, 249, 250, 0.95);
19
+ }
20
+
21
+ .document-drop-zone--dragover {
22
+ border-color: var(--bs-primary, #0d6efd);
23
+ background: rgba(13, 110, 253, 0.08);
24
+ box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.12);
25
+ transform: translateY(-1px);
26
+ }
27
+
28
+ .document-drop-zone__body {
29
+ display: flex;
30
+ flex-direction: column;
31
+ align-items: center;
32
+ gap: 0.75rem;
33
+ padding: 1.5rem 1rem;
34
+ text-align: center;
35
+ }
36
+
37
+ .document-drop-zone__icon {
38
+ width: 3.5rem;
39
+ height: 3.5rem;
40
+ display: inline-flex;
41
+ align-items: center;
42
+ justify-content: center;
43
+ border-radius: 50%;
44
+ background: rgba(13, 110, 253, 0.12);
45
+ color: var(--bs-primary, #0d6efd);
46
+ font-size: 1.5rem;
47
+ }
48
+
49
+ .document-drop-zone__title {
50
+ font-weight: 600;
51
+ }
52
+
53
+ .document-drop-zone__actions {
54
+ display: flex;
55
+ flex-wrap: wrap;
56
+ justify-content: center;
57
+ gap: 0.75rem;
58
+ }
59
+
60
+ .attached-documents-list {
61
+ display: flex;
62
+ flex-direction: column;
63
+ gap: 0.5rem;
64
+ }
65
+
66
+ .attached-document-card,
67
+ .pending-doc-row {
68
+ display: flex;
69
+ align-items: center;
70
+ gap: 0.75rem;
71
+ padding: 0.75rem 0.875rem;
72
+ border: 1px solid var(--bs-border-color, #dee2e6);
73
+ border-radius: 0.75rem;
74
+ background: #fff;
75
+ }
76
+
77
+ .attached-document-icon {
78
+ width: 2.25rem;
79
+ height: 2.25rem;
80
+ display: inline-flex;
81
+ align-items: center;
82
+ justify-content: center;
83
+ border-radius: 0.65rem;
84
+ background: rgba(13, 110, 253, 0.1);
85
+ color: var(--bs-primary, #0d6efd);
86
+ flex-shrink: 0;
87
+ }
88
+
89
+ .attached-document-meta {
90
+ min-width: 0;
91
+ }
92
+
93
+ .attached-document-name {
94
+ font-weight: 500;
95
+ word-break: break-word;
96
+ }
97
+
98
+ .attached-document-size {
99
+ color: var(--bs-secondary-color, #6c757d);
100
+ font-size: 0.875rem;
101
+ }
@@ -0,0 +1,77 @@
1
+ /*
2
+ ** NOTE: This file is generated by Gulp and should not be edited directly!
3
+ ** Any changes made directly to this file will be overwritten next time its asset group is processed by Gulp.
4
+ */
5
+
6
+ (function (window, document) {
7
+ 'use strict';
8
+
9
+ function assignFiles(fileInput, files) {
10
+ if (!fileInput || !files) {
11
+ return;
12
+ }
13
+ var dataTransfer = new DataTransfer();
14
+ Array.prototype.forEach.call(files, function (file) {
15
+ dataTransfer.items.add(file);
16
+ });
17
+ fileInput.files = dataTransfer.files;
18
+ fileInput.dispatchEvent(new Event('change', {
19
+ bubbles: true
20
+ }));
21
+ }
22
+ window.initDocumentDropZone = function initDocumentDropZone(options) {
23
+ if (!options) {
24
+ return;
25
+ }
26
+ var dropZone = typeof options.dropZone === 'string' ? document.querySelector(options.dropZone) : options.dropZone;
27
+ var fileInput = typeof options.fileInput === 'string' ? document.querySelector(options.fileInput) : options.fileInput;
28
+ var browseButton = typeof options.browseButton === 'string' ? document.querySelector(options.browseButton) : options.browseButton;
29
+ if (!dropZone || !fileInput) {
30
+ return;
31
+ }
32
+ function openPicker() {
33
+ fileInput.click();
34
+ }
35
+ function preventDefaults(event) {
36
+ event.preventDefault();
37
+ event.stopPropagation();
38
+ }
39
+ function setDragState(isActive) {
40
+ dropZone.classList.toggle('document-drop-zone--dragover', isActive);
41
+ }
42
+ ['dragenter', 'dragover', 'dragleave', 'drop'].forEach(function (eventName) {
43
+ dropZone.addEventListener(eventName, preventDefaults);
44
+ });
45
+ dropZone.addEventListener('dragenter', function () {
46
+ setDragState(true);
47
+ });
48
+ dropZone.addEventListener('dragover', function () {
49
+ setDragState(true);
50
+ });
51
+ dropZone.addEventListener('dragleave', function (event) {
52
+ if (!dropZone.contains(event.relatedTarget)) {
53
+ setDragState(false);
54
+ }
55
+ });
56
+ dropZone.addEventListener('drop', function (event) {
57
+ setDragState(false);
58
+ var files = event.dataTransfer ? event.dataTransfer.files : null;
59
+ if (files && files.length > 0) {
60
+ assignFiles(fileInput, files);
61
+ }
62
+ });
63
+ if (browseButton) {
64
+ browseButton.addEventListener('click', function (event) {
65
+ event.preventDefault();
66
+ event.stopPropagation();
67
+ openPicker();
68
+ });
69
+ }
70
+ dropZone.addEventListener('click', function (event) {
71
+ if (event.target.closest('[data-drop-zone-browse]')) {
72
+ return;
73
+ }
74
+ openPicker();
75
+ });
76
+ };
77
+ })(window, document);
@@ -0,0 +1 @@
1
+ .attached-documents-panel{border:1px solid var(--bs-border-color,#dee2e6);border-radius:.75rem;background:linear-gradient(180deg,rgba(13,110,253,.04),rgba(13,110,253,.01));padding:1rem}.document-drop-zone{position:relative;border:2px dashed rgba(13,110,253,.35);border-radius:1rem;background:rgba(248,249,250,.8);transition:border-color .15s ease,background-color .15s ease,box-shadow .15s ease,transform .15s ease}.document-drop-zone:hover{border-color:rgba(13,110,253,.55);background:rgba(248,249,250,.95)}.document-drop-zone--dragover{border-color:var(--bs-primary,#0d6efd);background:rgba(13,110,253,.08);box-shadow:0 0 0 .2rem rgba(13,110,253,.12);transform:translateY(-1px)}.document-drop-zone__body{display:flex;flex-direction:column;align-items:center;gap:.75rem;padding:1.5rem 1rem;text-align:center}.document-drop-zone__icon{width:3.5rem;height:3.5rem;display:inline-flex;align-items:center;justify-content:center;border-radius:50%;background:rgba(13,110,253,.12);color:var(--bs-primary,#0d6efd);font-size:1.5rem}.document-drop-zone__title{font-weight:600}.document-drop-zone__actions{display:flex;flex-wrap:wrap;justify-content:center;gap:.75rem}.attached-documents-list{display:flex;flex-direction:column;gap:.5rem}.attached-document-card,.pending-doc-row{display:flex;align-items:center;gap:.75rem;padding:.75rem .875rem;border:1px solid var(--bs-border-color,#dee2e6);border-radius:.75rem;background:#fff}.attached-document-icon{width:2.25rem;height:2.25rem;display:inline-flex;align-items:center;justify-content:center;border-radius:.65rem;background:rgba(13,110,253,.1);color:var(--bs-primary,#0d6efd);flex-shrink:0}.attached-document-meta{min-width:0}.attached-document-name{font-weight:500;word-break:break-word}.attached-document-size{color:var(--bs-secondary-color,#6c757d);font-size:.875rem}
@@ -0,0 +1 @@
1
+ !function(e,t){"use strict";e.initDocumentDropZone=function(e){if(e){var n="string"==typeof e.dropZone?t.querySelector(e.dropZone):e.dropZone,r="string"==typeof e.fileInput?t.querySelector(e.fileInput):e.fileInput,o="string"==typeof e.browseButton?t.querySelector(e.browseButton):e.browseButton;n&&r&&(["dragenter","dragover","dragleave","drop"].forEach(function(e){n.addEventListener(e,i)}),n.addEventListener("dragenter",function(){d(!0)}),n.addEventListener("dragover",function(){d(!0)}),n.addEventListener("dragleave",function(e){n.contains(e.relatedTarget)||d(!1)}),n.addEventListener("drop",function(e){d(!1);var t=e.dataTransfer?e.dataTransfer.files:null;t&&t.length>0&&function(e,t){if(e&&t){var n=new DataTransfer;Array.prototype.forEach.call(t,function(e){n.items.add(e)}),e.files=n.files,e.dispatchEvent(new Event("change",{bubbles:!0}))}}(r,t)}),o&&o.addEventListener("click",function(e){e.preventDefault(),e.stopPropagation(),a()}),n.addEventListener("click",function(e){e.target.closest("[data-drop-zone-browse]")||a()}))}function a(){r.click()}function i(e){e.preventDefault(),e.stopPropagation()}function d(e){n.classList.toggle("document-drop-zone--dragover",e)}}}(window,document);
@@ -0,0 +1,55 @@
1
+ /*
2
+ ** NOTE: This file is generated by Gulp and should not be edited directly!
3
+ ** Any changes made directly to this file will be overwritten next time its asset group is processed by Gulp.
4
+ */
5
+
6
+ (function () {
7
+ // Expose initializer globally so views can call it with specific field IDs.
8
+ function toTitleCaseNoSpaces(value) {
9
+ return (value || '').trim()
10
+ // split on whitespace or common separators or any non-alphanumeric
11
+ .split(/[^A-Za-z0-9]+/).filter(function (w) {
12
+ return w.length > 0;
13
+ }).map(function (w) {
14
+ return w.charAt(0).toUpperCase() + w.slice(1).toLowerCase();
15
+ }).join('');
16
+ }
17
+ function initAutoGenerateTechnicalName(displayId, nameId) {
18
+ if (!displayId || !nameId) return;
19
+ document.addEventListener('DOMContentLoaded', function () {
20
+ var displayEl = document.getElementById(displayId);
21
+ var nameEl = document.getElementById(nameId);
22
+ if (!displayEl || !nameEl) return;
23
+
24
+ // Track whether the user has entered a non-empty value in the Name field.
25
+ var userEdited = nameEl.value.trim() !== '';
26
+
27
+ // Resume auto-generation only when the Name field is empty again.
28
+ nameEl.addEventListener('input', function () {
29
+ userEdited = nameEl.value.trim() !== '';
30
+ });
31
+
32
+ // Generate on keyup as requested
33
+ displayEl.addEventListener('keyup', function () {
34
+ if (userEdited) return;
35
+ var generated = toTitleCaseNoSpaces(displayEl.value || '');
36
+ nameEl.value = generated;
37
+ });
38
+ });
39
+ }
40
+
41
+ // Automatically initialize for any elements using the data attributes.
42
+ document.addEventListener('DOMContentLoaded', function () {
43
+ var autoEls = document.querySelectorAll('[data-auto-tech-name]');
44
+ for (var i = 0; i < autoEls.length; i++) {
45
+ var el = autoEls[i];
46
+ var displayId = el.getAttribute('data-display-id');
47
+ var nameId = el.getAttribute('data-name-id');
48
+ if (displayId && nameId) {
49
+ // call initializer immediately (it will attach listeners)
50
+ initAutoGenerateTechnicalName(displayId, nameId);
51
+ }
52
+ }
53
+ });
54
+ window.initAutoGenerateTechnicalName = initAutoGenerateTechnicalName;
55
+ })();
@@ -0,0 +1 @@
1
+ !function(){function t(t,e){t&&e&&document.addEventListener("DOMContentLoaded",function(){var n=document.getElementById(t),a=document.getElementById(e);if(n&&a){var i=""!==a.value.trim();a.addEventListener("input",function(){i=""!==a.value.trim()}),n.addEventListener("keyup",function(){if(!i){var t=(n.value||""||"").trim().split(/[^A-Za-z0-9]+/).filter(function(t){return t.length>0}).map(function(t){return t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()}).join("");a.value=t}})}})}document.addEventListener("DOMContentLoaded",function(){for(var e=document.querySelectorAll("[data-auto-tech-name]"),n=0;n<e.length;n++){var a=e[n],i=a.getAttribute("data-display-id"),d=a.getAttribute("data-name-id");i&&d&&t(i,d)}}),window.initAutoGenerateTechnicalName=t}();