@logosphere-ui/core 0.0.0-alpha.17 → 0.0.0-alpha.19

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.
@@ -1,5 +1,5 @@
1
- "use strict";const n=require("lit"),i=require("lit/decorators.js"),b=require("lit/directives/unsafe-html.js");require("./combobox-C6zoQopK.cjs");require("./button-CDRccsk9.cjs");require("./input-JpAWN-M1.cjs");require("./ui-icon-DWh1MhBa.cjs");const m=":host{display:block;z-index:9999}.chatbot{font-family:var(--font-family-base)}.chatbot__overlay{position:fixed;inset:0;background-color:#0003;z-index:var(--z-index-modal-backdrop)}.chatbot__launcher{position:fixed;z-index:var(--z-index-modal);display:flex;align-items:center;gap:var(--spacing-4);padding-left:var(--spacing-4);padding-right:var(--spacing-4);height:66px;color:#fff;border-radius:var(--radius-xl);cursor:pointer;box-shadow:var(--shadow-base);background-color:var(--color-body-bg);overflow:hidden;transition:box-shadow var(--transition-speed-fast) var(--transition-timing)}.chatbot__launcher:hover{box-shadow:var(--shadow-md)}.chatbot__launcher--draggable{cursor:move}.chatbot__launcher--hidden{visibility:hidden;width:72px;height:66px;justify-content:center;padding:0}.chatbot__launcher-icon{width:40px;height:34px;flex-shrink:0}.chatbot__launcher-text{display:flex;flex-direction:column}.chatbot__launcher-title{font-weight:var(--font-weight-semibold);font-size:var(--font-size-xl);margin:0;line-height:24px;white-space:nowrap;color:var(--color-body-text)}.chatbot__launcher-subtitle{font-weight:var(--font-weight-semibold);font-size:var(--font-size-sm);margin:0;line-height:20px;white-space:nowrap;color:var(--color-tertiary)}.chatbot__window{position:fixed;z-index:var(--z-index-modal);display:flex;flex-direction:column;box-shadow:var(--shadow-xl);border-radius:var(--radius-md);overflow:hidden;background-color:var(--color-body-bg)}.chatbot__window--hidden{display:none}.chatbot__window--fullscreen{inset:80px 50px;width:auto;height:auto}.chatbot__resize-top{position:absolute;top:0;left:0;right:0;height:8px;cursor:ns-resize;z-index:50;transition:background-color var(--transition-speed-fast) var(--transition-timing)}.chatbot__resize-top:hover{background-color:#0000000d}.chatbot__resize-side{position:absolute;top:0;bottom:0;width:8px;cursor:ew-resize;z-index:50;transition:background-color var(--transition-speed-fast) var(--transition-timing)}.chatbot__resize-side:hover{background-color:#0000000d}.chatbot__resize-side--left{left:0}.chatbot__resize-side--right{right:0}.chatbot__resize-corner{position:absolute;top:0;width:16px;height:16px;z-index:50;transition:background-color var(--transition-speed-fast) var(--transition-timing)}.chatbot__resize-corner:hover{background-color:#0000001a}.chatbot__resize-corner--nwse{left:0;cursor:nwse-resize}.chatbot__resize-corner--nesw{right:0;cursor:nesw-resize}.chatbot__header{height:74px;display:flex;align-items:center;justify-content:space-between;padding-left:var(--spacing-5);padding-right:var(--spacing-4);gap:var(--spacing-4);flex-shrink:0;background-color:var(--color-body-bg);border-bottom:1px solid var(--color-border)}.chatbot__header-info{display:flex;align-items:center;gap:var(--spacing-4)}.chatbot__header-logo{width:50px;height:41px}.chatbot__header-title{font-weight:var(--font-weight-semibold);font-size:var(--font-size-xl);margin:0;line-height:24px;color:var(--color-body-text)}.chatbot__header-subtitle{font-weight:var(--font-weight-semibold);font-size:var(--font-size-sm);margin:0;line-height:20px;color:var(--color-tertiary)}.chatbot__header-actions{display:flex;align-items:center;gap:var(--spacing-2)}.chatbot__body{flex:1;display:flex;flex-direction:column;background-color:var(--color-body-bg);position:relative;overflow:hidden}.chatbot__product{padding:var(--spacing-3);padding-bottom:0;flex-shrink:0;margin:0 var(--spacing-3)}.chatbot__messages{flex:1;display:flex;flex-direction:column;gap:var(--spacing-3);margin-top:var(--spacing-4);padding:var(--spacing-4);overflow-y:auto;scrollbar-width:none;-ms-overflow-style:none}.chatbot__messages::-webkit-scrollbar{display:none}.chatbot__message{display:flex}.chatbot__message--user{justify-content:flex-end}.chatbot__message--assistant,.chatbot__message--system{justify-content:flex-start}.chatbot__bubble{position:relative;color:var(--color-body-text);max-width:85%;border-radius:var(--radius-md);padding:var(--spacing-4);font-size:var(--font-size-sm);line-height:20px;font-weight:var(--font-weight-medium)}.chatbot__bubble--user{background-color:var(--color-primary);color:#fff;border-bottom-right-radius:0;border-top-right-radius:var(--radius-xl);border-top-left-radius:var(--radius-xl);border-bottom-left-radius:var(--radius-xl)}.chatbot__bubble--user a{color:#ffffffe6}.chatbot__bubble--assistant,.chatbot__bubble--system{background-color:var(--color-tertiary-bg);border-bottom-left-radius:0;border-top-right-radius:var(--radius-xl);border-top-left-radius:var(--radius-xl);border-bottom-right-radius:var(--radius-xl)}.chatbot__message-content p{margin:0}.chatbot__message-content ol{list-style-type:decimal;margin:0;padding-left:var(--spacing-5)}.chatbot__message-content ul{list-style-type:disc;margin:0;padding-left:var(--spacing-5)}.chatbot__message-content li{padding-left:var(--spacing-1)}.chatbot__message-content a{color:var(--color-primary);text-decoration:underline;transition:color var(--transition-speed-fast) var(--transition-timing)}.chatbot__message-content a:hover{color:var(--color-primary-hover)}.chatbot__feedback{display:flex;align-items:center;gap:var(--spacing-2);padding-top:var(--spacing-2)}.chatbot__typing-wrapper{display:flex;justify-content:flex-start}.chatbot__typing{background-color:var(--color-tertiary-bg);padding:var(--spacing-3);border-radius:var(--radius-xl);border-bottom-left-radius:0;display:inline-flex;align-items:center;gap:2px}.chatbot__typing-dot{display:inline-block;width:6px;height:6px;background-color:var(--color-gray-300);border-radius:var(--radius-full);animation:chatbot-typing 1.4s infinite ease-in-out both;margin:0 2px}.chatbot__typing-dot:nth-child(1){animation-delay:-.32s}.chatbot__typing-dot:nth-child(2){animation-delay:-.16s}@keyframes chatbot-typing{0%,80%,to{transform:scale(0)}40%{transform:scale(1)}}.chatbot__input-area{padding:var(--spacing-4);padding-top:var(--spacing-2);padding-bottom:var(--spacing-1);background-color:var(--color-body-bg)}.chatbot__input-wrapper{position:relative;display:flex;align-items:center;gap:var(--spacing-2);background-color:var(--color-tertiary-bg);border-radius:var(--radius-md);padding:var(--spacing-2);border:1px solid transparent;transition:background-color var(--transition-speed-fast) var(--transition-timing),border-color var(--transition-speed-fast) var(--transition-timing)}.chatbot__input-wrapper:focus-within{background-color:var(--color-body-bg);border-color:var(--color-border)}.chatbot__input{flex:1;background:transparent;border:none;outline:none;font-family:var(--font-family-base);font-size:var(--font-size-sm);color:var(--color-body-text)}.chatbot__input::placeholder{color:var(--color-tertiary)}.chatbot__input:disabled{opacity:.5;cursor:not-allowed}.chatbot__footer{display:flex;align-items:center;justify-content:center;padding-bottom:var(--spacing-2)}.chatbot__footer-text{margin:0;padding:0;color:var(--color-secondary);font-size:var(--font-size-xs);font-family:var(--font-family-base)}";var f=Object.defineProperty,v=Object.getOwnPropertyDescriptor,s=(l,t,e,r)=>{for(var o=r>1?void 0:r?v(t,e):t,a=l.length-1,h;a>=0;a--)(h=l[a])&&(o=(r?h(t,e,o):h(o))||o);return r&&o&&f(t,e,o),o};exports.LogosphereChatBot=class extends n.LitElement{constructor(){super(...arguments),this.returnUri="",this.questionPrompt="",this.minimizedIconOnly=!1,this.draggable=!1,this.resizable=!1,this.products=[],this.openInitially=!1,this.showFeedbackButtons=!1,this.open=!1,this.fullscreen=!1,this.messages=[],this.isLoading=!1,this.inputText="",this.selectedProductId="",this.windowWidth=440,this.windowHeight=Math.min(700,window.innerHeight-40),this.position={right:20,bottom:20},this.isDragging=!1,this.screenWidth=window.innerWidth,this.dragStartPos={x:0,y:0},this.initialPosition={right:0,bottom:0},this.isResizing=!1,this.resizeDirection="horizontal",this.resizeStartWidth=0,this.resizeStartHeight=0,this.onWindowResize=()=>{this.screenWidth=window.innerWidth;const t=window.innerHeight-40;this.windowHeight>t&&(this.windowHeight=t)},this.onToggle=()=>{this.open=!this.open,this.scrollToBottom()},this.onClose=()=>{this.open=!1,this.fullscreen=!1},this.onToggleFullscreen=()=>{this.fullscreen=!this.fullscreen},this.onMouseMove=t=>{if(this.isDragging){const e=this.dragStartPos.x-t.clientX,r=this.dragStartPos.y-t.clientY,a=this.shadowRoot?.querySelector(".chatbot__launcher")?.getBoundingClientRect(),h=a?.width||72,c=a?.height||66;this.position={right:Math.max(0,Math.min(window.innerWidth-h,this.initialPosition.right+e)),bottom:Math.max(0,Math.min(window.innerHeight-c,this.initialPosition.bottom+r))}}else if(this.isResizing){const e=this.dragStartPos.x-t.clientX,r=this.dragStartPos.y-t.clientY;if(this.resizeDirection==="horizontal"||this.resizeDirection==="both"){const o=this.position.right<this.screenWidth/2;this.windowWidth=Math.max(300,this.resizeStartWidth+(o?e:-e))}(this.resizeDirection==="vertical"||this.resizeDirection==="both")&&(this.windowHeight=Math.max(400,this.resizeStartHeight+r))}},this.onMouseUp=t=>{this.isDragging?(this.isDragging=!1,window.removeEventListener("mousemove",this.onMouseMove),window.removeEventListener("mouseup",this.onMouseUp),Math.hypot(t.clientX-this.dragStartPos.x,t.clientY-this.dragStartPos.y)<5&&this.onToggle()):this.isResizing&&(this.isResizing=!1,window.removeEventListener("mousemove",this.onMouseMove),window.removeEventListener("mouseup",this.onMouseUp))},this.handleKeyDown=t=>{t.key==="Enter"&&!t.shiftKey&&(t.preventDefault(),this.sendMessage())},this.onInput=t=>{const e=t.target;this.inputText=e?e.value:t.detail},this.onCopyMessage=t=>{navigator.clipboard.writeText(t)}}connectedCallback(){super.connectedCallback(),window.addEventListener("resize",this.onWindowResize)}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("resize",this.onWindowResize),window.removeEventListener("mousemove",this.onMouseMove),window.removeEventListener("mouseup",this.onMouseUp)}async firstUpdated(){this.products.length===1&&(this.selectedProductId=this.products[0].id),this.open=this.openInitially,this.open&&await this.initConversation()}updated(t){t.has("products")&&this.handleProductUpdate(),t.has("messages")&&this.scrollToBottom(),t.has("open")&&this.open&&!this.conversationId&&this.initConversation()}handleProductUpdate(){if(!this.products.length)return;const t=this.products.some(e=>e.id===this.selectedProductId);this.products.length===1&&(this.selectedProductId=this.products[0].id),t||(this.messages=[],this.conversationId=void 0,this.open&&this.initConversation()),requestAnimationFrame(()=>this.updateComboboxItems())}updateComboboxItems(){const t=this.productEl;if(!t||this.products?.length<=1)return;const e=this.products.map(o=>({value:o.id,label:o.name}));t.items=e;const r=t.selectedItems?.()||[];if(r.length>0){const o=r[0]?.value;!this.products.some(h=>h.id===o)&&t.setSelected&&t.setSelected([])}}async onProductChange(t){const e=t.detail?.selected?.[0]?.value;e&&e!==this.selectedProductId&&(this.selectedProductId=e)}onMouseDown(t){this.draggable&&(t.preventDefault(),this.isDragging=!0,this.dragStartPos={x:t.clientX,y:t.clientY},this.initialPosition={...this.position},window.addEventListener("mousemove",this.onMouseMove),window.addEventListener("mouseup",this.onMouseUp))}startResize(t,e){this.resizable&&(t.preventDefault(),t.stopPropagation(),this.isResizing=!0,this.resizeDirection=e,this.dragStartPos={x:t.clientX,y:t.clientY},this.resizeStartWidth=this.windowWidth,this.resizeStartHeight=this.windowHeight,window.addEventListener("mousemove",this.onMouseMove),window.addEventListener("mouseup",this.onMouseUp))}async ensureToken(t=!1){const e="logosphere_chatbot_token";if(t&&(this.assertionToken=void 0,localStorage.removeItem(e)),!t){const a=localStorage.getItem(e);if(a){this.assertionToken=a;return}}const o=await(await fetch(`${this.returnUri}/api/chat/start`)).json();if(!o.Success||!o.Data?.Token)throw new Error("Token alınamadı");this.assertionToken=o.Data.Token,localStorage.setItem(e,this.assertionToken)}async postChat(t){await this.ensureToken();const e=`${this.returnUri}/api/chat/completions`,r=()=>fetch(e,{method:"POST",headers:{"Content-Type":"application/json",client_assertion:this.assertionToken,client_assertion_type:"urn:ietf:params:oauth:client-assertion-type:jwt-bearer"},body:JSON.stringify(t)});let o=await r();if(o.status===401&&(await this.ensureToken(!0),o=await r()),!o.ok)throw new Error(`HTTP ${o.status}`);return o.json()}async initConversation(){if(!this.isLoading){this.isLoading=!0;try{await this.ensureToken();const t=await this.postChat({ChatCompletionType:"NewConversation",Context:this.selectedProductId,QuestionPrompt:this.questionPrompt});this.conversationId=t.Data.ConversationId;const e=t.Data.Choices?.[0]?.Message?.Content;e&&this.addMessage(e,"assistant")}catch{this.addMessage("Bir hata oluştu, lütfen tekrar deneyiniz.","system")}finally{this.isLoading=!1}}}async sendMessage(){const t=this.inputText.trim();if(!(!t||!this.conversationId||this.isLoading)){if(!this.selectedProductId){this.addMessage("Lütfen önce bir ürün seçiniz.","system");return}this.addMessage(t,"user"),this.inputText="",this.isLoading=!0;try{const r=(await this.postChat({ChatCompletionType:"ConversationUpdate",Content:t,Context:this.selectedProductId,ConversationId:this.conversationId,QuestionPrompt:this.questionPrompt})).Data?.Choices?.[0]?.Message?.Content;this.addMessage(r||"Cevap alınamadı.","assistant")}catch{this.addMessage("Bağlantı hatası.","system")}finally{this.isLoading=!1}}}addMessage(t,e){this.messages=[...this.messages,{content:t,role:e,timestamp:Date.now()}]}scrollToBottom(){setTimeout(()=>{this.chatContainer&&(this.chatContainer.scrollTop=this.chatContainer.scrollHeight)},0)}formatContent(t){if(!t)return"";const r=t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").split(`
2
- `);let o="",a=!1,h="";for(const c of r){const u=c.trim()==="",d=c.match(/^\s*\d+\.\s+(.*)/),g=c.match(/^\s*[-*]\s+(.*)/);if(d||g){const p=d?"ol":"ul";(!a||h!==p)&&(a&&(o+=`</${h}>`),o+=`<${p}>`,a=!0,h=p),o+=`<li>${d?d[1]:g[1]}</li>`}else u?a||(o+="<br>"):(a&&(o+=`</${h}>`,a=!1,h=""),o+=`<p>${c}</p>`)}return a&&(o+=`</${h}>`),o.replace(/\*\*(.*?)\*\*/g,"<strong>$1</strong>").replace(/\*(.*?)\*/g,"<em>$1</em>").replace(/\[([^\]]+)\]\(([^)]+)\)/g,'<a href="$2" target="_blank" rel="noopener noreferrer">$1</a>')}render(){const t=this.position.right<this.screenWidth/2;return n.html`
1
+ "use strict";const n=require("lit"),s=require("lit/decorators.js"),y=require("lit/directives/unsafe-html.js");require("./combobox-C6zoQopK.cjs");require("./button-CDRccsk9.cjs");require("./input-JpAWN-M1.cjs");require("./ui-icon-DWh1MhBa.cjs");const w=":host{display:block;z-index:9999}.chatbot{font-family:var(--font-family-base)}.chatbot__overlay{position:fixed;inset:0;background-color:#0003;z-index:var(--z-index-modal-backdrop)}.chatbot__launcher{position:fixed;z-index:var(--z-index-modal);display:flex;align-items:center;gap:var(--spacing-4);padding-left:var(--spacing-4);padding-right:var(--spacing-4);height:66px;color:#fff;border-radius:var(--radius-xl);cursor:pointer;box-shadow:var(--shadow-base);background-color:var(--color-body-bg);overflow:hidden;transition:box-shadow var(--transition-speed-fast) var(--transition-timing)}.chatbot__launcher:hover{box-shadow:var(--shadow-md)}.chatbot__launcher--draggable{cursor:move}.chatbot__launcher--hidden{visibility:hidden;width:72px;height:66px;justify-content:center;padding:0}.chatbot__launcher-icon{width:40px;height:34px;flex-shrink:0}.chatbot__launcher-text{display:flex;flex-direction:column}.chatbot__launcher-title{font-weight:var(--font-weight-semibold);font-size:var(--font-size-xl);margin:0;line-height:24px;white-space:nowrap;color:var(--color-body-text)}.chatbot__launcher-subtitle{font-weight:var(--font-weight-semibold);font-size:var(--font-size-sm);margin:0;line-height:20px;white-space:nowrap;color:var(--color-tertiary)}.chatbot__window{position:fixed;z-index:var(--z-index-modal);display:flex;flex-direction:column;box-shadow:var(--shadow-xl);border-radius:var(--radius-md);overflow:hidden;background-color:var(--color-body-bg)}.chatbot__window--hidden{display:none}.chatbot__window--fullscreen{inset:80px 50px;width:auto;height:auto}.chatbot__resize-top{position:absolute;top:0;left:0;right:0;height:8px;cursor:ns-resize;z-index:50;transition:background-color var(--transition-speed-fast) var(--transition-timing)}.chatbot__resize-top:hover{background-color:#0000000d}.chatbot__resize-side{position:absolute;top:0;bottom:0;width:8px;cursor:ew-resize;z-index:50;transition:background-color var(--transition-speed-fast) var(--transition-timing)}.chatbot__resize-side:hover{background-color:#0000000d}.chatbot__resize-side--left{left:0}.chatbot__resize-side--right{right:0}.chatbot__resize-corner{position:absolute;top:0;width:16px;height:16px;z-index:50;transition:background-color var(--transition-speed-fast) var(--transition-timing)}.chatbot__resize-corner:hover{background-color:#0000001a}.chatbot__resize-corner--nwse{left:0;cursor:nwse-resize}.chatbot__resize-corner--nesw{right:0;cursor:nesw-resize}.chatbot__header{height:74px;display:flex;align-items:center;justify-content:space-between;padding-left:var(--spacing-5);padding-right:var(--spacing-4);gap:var(--spacing-4);flex-shrink:0;background-color:var(--color-body-bg);border-bottom:1px solid var(--color-border)}.chatbot__header-info{display:flex;align-items:center;gap:var(--spacing-4)}.chatbot__header-logo{width:50px;height:41px}.chatbot__header-title{font-weight:var(--font-weight-semibold);font-size:var(--font-size-xl);margin:0;line-height:24px;color:var(--color-body-text)}.chatbot__header-subtitle{font-weight:var(--font-weight-semibold);font-size:var(--font-size-sm);margin:0;line-height:20px;color:var(--color-tertiary)}.chatbot__header-actions{display:flex;align-items:center;gap:var(--spacing-2)}.chatbot__body{flex:1;display:flex;flex-direction:column;background-color:var(--color-body-bg);position:relative;overflow:hidden}.chatbot__product{padding:var(--spacing-3);padding-bottom:0;flex-shrink:0;margin:0 var(--spacing-3)}.chatbot__messages{flex:1;display:flex;flex-direction:column;gap:var(--spacing-3);margin-top:var(--spacing-4);padding:var(--spacing-4);overflow-y:auto;scrollbar-width:none;-ms-overflow-style:none}.chatbot__messages::-webkit-scrollbar{display:none}.chatbot__message{display:flex}.chatbot__message--user{justify-content:flex-end}.chatbot__message--assistant,.chatbot__message--system{justify-content:flex-start}.chatbot__bubble{position:relative;color:var(--color-body-text);max-width:85%;border-radius:var(--radius-md);padding:var(--spacing-4);font-size:var(--font-size-sm);line-height:20px;font-weight:var(--font-weight-medium)}.chatbot__bubble--user{background-color:var(--color-primary);color:#fff;border-bottom-right-radius:0;border-top-right-radius:var(--radius-xl);border-top-left-radius:var(--radius-xl);border-bottom-left-radius:var(--radius-xl)}.chatbot__bubble--user a{color:#ffffffe6}.chatbot__bubble--assistant,.chatbot__bubble--system{background-color:var(--color-tertiary-bg);border-bottom-left-radius:0;border-top-right-radius:var(--radius-xl);border-top-left-radius:var(--radius-xl);border-bottom-right-radius:var(--radius-xl)}.chatbot__message-content p{margin:0}.chatbot__message-content ol{list-style-type:decimal;margin:0;padding-left:var(--spacing-5)}.chatbot__message-content ul{list-style-type:disc;margin:0;padding-left:var(--spacing-5)}.chatbot__message-content li>ol,.chatbot__message-content li>ul{margin-top:var(--spacing-1);margin-bottom:var(--spacing-1)}.chatbot__message-content ol ol{list-style-type:lower-alpha}.chatbot__message-content ol ol ol{list-style-type:lower-roman}.chatbot__message-content ul ul{list-style-type:circle}.chatbot__message-content ul ul ul{list-style-type:square}.chatbot__message-content li{padding-left:var(--spacing-1)}.chatbot__message-content a{color:var(--color-primary);text-decoration:underline;transition:color var(--transition-speed-fast) var(--transition-timing)}.chatbot__message-content a:hover{color:var(--color-primary-hover)}.chatbot__feedback{display:flex;align-items:center;gap:var(--spacing-2);padding-top:var(--spacing-2)}.chatbot__typing-wrapper{display:flex;justify-content:flex-start}.chatbot__typing{background-color:var(--color-tertiary-bg);padding:var(--spacing-3);border-radius:var(--radius-xl);border-bottom-left-radius:0;display:inline-flex;align-items:center;gap:2px}.chatbot__typing-dot{display:inline-block;width:6px;height:6px;background-color:var(--color-gray-300);border-radius:var(--radius-full);animation:chatbot-typing 1.4s infinite ease-in-out both;margin:0 2px}.chatbot__typing-dot:nth-child(1){animation-delay:-.32s}.chatbot__typing-dot:nth-child(2){animation-delay:-.16s}@keyframes chatbot-typing{0%,80%,to{transform:scale(0)}40%{transform:scale(1)}}.chatbot__input-area{padding:var(--spacing-4);padding-top:var(--spacing-2);padding-bottom:var(--spacing-1);background-color:var(--color-body-bg)}.chatbot__input-wrapper{position:relative;display:flex;align-items:center;gap:var(--spacing-2);background-color:var(--color-tertiary-bg);border-radius:var(--radius-md);padding:var(--spacing-2);border:1px solid transparent;transition:background-color var(--transition-speed-fast) var(--transition-timing),border-color var(--transition-speed-fast) var(--transition-timing)}.chatbot__input-wrapper:focus-within{background-color:var(--color-body-bg);border-color:var(--color-border)}.chatbot__input{flex:1;background:transparent;border:none;outline:none;font-family:var(--font-family-base);font-size:var(--font-size-sm);color:var(--color-body-text)}.chatbot__input::placeholder{color:var(--color-tertiary)}.chatbot__input:disabled{opacity:.5;cursor:not-allowed}.chatbot__footer{display:flex;align-items:center;justify-content:center;padding-bottom:var(--spacing-2)}.chatbot__footer-text{margin:0;padding:0;color:var(--color-secondary);font-size:var(--font-size-xs);font-family:var(--font-family-base)}.chatbot__product-selector{padding:var(--spacing-3) var(--spacing-3) 0;flex-shrink:0}.chatbot__product-input{display:block;width:100%;height:24px;padding-left:var(--spacing-1);border:1px solid var(--color-border);border-radius:var(--radius-md);background:transparent;color:var(--color-body-color);font-size:var(--font-size-md);outline:none}";var x=Object.defineProperty,C=Object.getOwnPropertyDescriptor,a=(l,t,e,r)=>{for(var o=r>1?void 0:r?C(t,e):t,i=l.length-1,h;i>=0;i--)(h=l[i])&&(o=(r?h(t,e,o):h(o))||o);return r&&o&&x(t,e,o),o};exports.LogosphereChatBot=class extends n.LitElement{constructor(){super(...arguments),this.returnUri="",this.questionPrompt="",this.minimizedIconOnly=!1,this.draggable=!1,this.resizable=!1,this.products=[],this.openInitially=!1,this.showFeedbackButtons=!1,this.open=!1,this.fullscreen=!1,this.messages=[],this.isLoading=!1,this.inputText="",this.selectedProductId="",this.windowWidth=440,this.windowHeight=Math.min(700,window.innerHeight-40),this.position={right:20,bottom:20},this.isDragging=!1,this.screenWidth=window.innerWidth,this.dragStartPos={x:0,y:0},this.initialPosition={right:0,bottom:0},this.isResizing=!1,this.resizeDirection="horizontal",this.resizeStartWidth=0,this.resizeStartHeight=0,this.onWindowResize=()=>{this.screenWidth=window.innerWidth;const t=window.innerHeight-40;this.windowHeight>t&&(this.windowHeight=t)},this.onToggle=()=>{this.open=!this.open,this.scrollToBottom()},this.onClose=()=>{this.open=!1,this.fullscreen=!1},this.onToggleFullscreen=()=>{this.fullscreen=!this.fullscreen},this.onMouseMove=t=>{if(this.isDragging){const e=this.dragStartPos.x-t.clientX,r=this.dragStartPos.y-t.clientY,i=this.shadowRoot?.querySelector(".chatbot__launcher")?.getBoundingClientRect(),h=i?.width||72,u=i?.height||66;this.position={right:Math.max(0,Math.min(window.innerWidth-h,this.initialPosition.right+e)),bottom:Math.max(0,Math.min(window.innerHeight-u,this.initialPosition.bottom+r))}}else if(this.isResizing){const e=this.dragStartPos.x-t.clientX,r=this.dragStartPos.y-t.clientY;if(this.resizeDirection==="horizontal"||this.resizeDirection==="both"){const o=this.position.right<this.screenWidth/2;this.windowWidth=Math.max(300,this.resizeStartWidth+(o?e:-e))}(this.resizeDirection==="vertical"||this.resizeDirection==="both")&&(this.windowHeight=Math.max(400,this.resizeStartHeight+r))}},this.onMouseUp=t=>{this.isDragging?(this.isDragging=!1,window.removeEventListener("mousemove",this.onMouseMove),window.removeEventListener("mouseup",this.onMouseUp),Math.hypot(t.clientX-this.dragStartPos.x,t.clientY-this.dragStartPos.y)<5&&this.onToggle()):this.isResizing&&(this.isResizing=!1,window.removeEventListener("mousemove",this.onMouseMove),window.removeEventListener("mouseup",this.onMouseUp))},this.handleKeyDown=t=>{t.key==="Enter"&&!t.shiftKey&&(t.preventDefault(),this.sendMessage())},this.onInput=t=>{const e=t.target;this.inputText=e?e.value:t.detail},this.onCopyMessage=t=>{navigator.clipboard.writeText(t)}}connectedCallback(){super.connectedCallback(),window.addEventListener("resize",this.onWindowResize)}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("resize",this.onWindowResize),window.removeEventListener("mousemove",this.onMouseMove),window.removeEventListener("mouseup",this.onMouseUp)}async firstUpdated(){this.selectedProductId=this._resolveInitialProduct(),this.open=this.openInitially,this.open&&await this.initConversation()}updated(t){t.has("products")&&this.handleProductUpdate(),t.has("messages")&&this.scrollToBottom(),t.has("open")&&this.open&&!this.conversationId&&this.initConversation()}_resolveInitialProduct(){if(!this.products.length)return"";const t=this.products.find(e=>e.selected);return t?t.id:this.products.length===1?this.products[0].id:""}handleProductUpdate(){if(!this.products.length)return;const t=this._resolveInitialProduct();this.products.some(r=>r.id===this.selectedProductId)||(this.selectedProductId=t,this.messages=[],this.conversationId=void 0,this.open&&this.initConversation()),requestAnimationFrame(()=>this.updateComboboxItems())}updateComboboxItems(){const t=this.productEl;if(!t||this.products?.length<=1)return;const e=this.products.map(o=>({value:o.id,label:o.name}));t.items=e;const r=t.selectedItems?.()||[];if(r.length===0&&this.selectedProductId){const o=e.find(i=>i.value===this.selectedProductId);o&&t.setSelected&&t.setSelected([o])}else if(r.length>0){const o=r[0]?.value;!this.products.some(h=>h.id===o)&&t.setSelected&&t.setSelected([])}}async onProductChange(t){const e=t.detail?.selected?.[0]?.value;e&&e!==this.selectedProductId&&(this.selectedProductId=e)}onMouseDown(t){this.draggable&&(t.preventDefault(),this.isDragging=!0,this.dragStartPos={x:t.clientX,y:t.clientY},this.initialPosition={...this.position},window.addEventListener("mousemove",this.onMouseMove),window.addEventListener("mouseup",this.onMouseUp))}startResize(t,e){this.resizable&&(t.preventDefault(),t.stopPropagation(),this.isResizing=!0,this.resizeDirection=e,this.dragStartPos={x:t.clientX,y:t.clientY},this.resizeStartWidth=this.windowWidth,this.resizeStartHeight=this.windowHeight,window.addEventListener("mousemove",this.onMouseMove),window.addEventListener("mouseup",this.onMouseUp))}async ensureToken(t=!1){const e="logosphere_chatbot_token";if(t&&(this.assertionToken=void 0,localStorage.removeItem(e)),!t){const i=localStorage.getItem(e);if(i){this.assertionToken=i;return}}const o=await(await fetch(`${this.returnUri}/api/chat/start`)).json();if(!o.Success||!o.Data?.Token)throw new Error("Token alınamadı");this.assertionToken=o.Data.Token,localStorage.setItem(e,this.assertionToken)}async postChat(t){await this.ensureToken();const e=`${this.returnUri}/api/chat/completions`,r=()=>fetch(e,{method:"POST",headers:{"Content-Type":"application/json",client_assertion:this.assertionToken,client_assertion_type:"urn:ietf:params:oauth:client-assertion-type:jwt-bearer"},body:JSON.stringify(t)});let o=await r();if(o.status===401&&(await this.ensureToken(!0),o=await r()),!o.ok)throw new Error(`HTTP ${o.status}`);return o.json()}async initConversation(){if(!this.isLoading){this.isLoading=!0;try{await this.ensureToken();const t=await this.postChat({ChatCompletionType:"NewConversation",Context:this.selectedProductId,QuestionPrompt:this.questionPrompt});this.conversationId=t.Data.ConversationId;const e=t.Data.Choices?.[0]?.Message?.Content;e&&this.addMessage(e,"assistant")}catch{this.addMessage("Bir hata oluştu, lütfen tekrar deneyiniz.","system")}finally{this.isLoading=!1}}}async sendMessage(){const t=this.inputText.trim();if(!(!t||!this.conversationId||this.isLoading)){if(!this.selectedProductId){this.addMessage("Lütfen önce bir ürün seçiniz.","system");return}this.addMessage(t,"user"),this.inputText="",this.isLoading=!0;try{const r=(await this.postChat({ChatCompletionType:"ConversationUpdate",Content:t,Context:this.selectedProductId,ConversationId:this.conversationId,QuestionPrompt:this.questionPrompt})).Data?.Choices?.[0]?.Message?.Content;this.addMessage(r||"Cevap alınamadı.","assistant")}catch{this.addMessage("Bağlantı hatası.","system")}finally{this.isLoading=!1}}}addMessage(t,e){this.messages=[...this.messages,{content:t,role:e,timestamp:Date.now()}]}scrollToBottom(){setTimeout(()=>{this.chatContainer&&(this.chatContainer.scrollTop=this.chatContainer.scrollHeight)},0)}formatContent(t){if(!t)return"";const r=t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").split(`
2
+ `);let o="";const i=[];let h=!1;const u=()=>{h&&(o+="</li>",h=!1)},f=d=>{for(;i.length>0&&i[i.length-1].indent>=d;)u(),o+=`</${i.pop().type}>`,i.length>0&&(h=!0)},b=()=>f(-1);for(const d of r){const p=d.match(/^(\s*)\d+\.\s+(.*)/),m=d.match(/^(\s*)[-*]\s+(.*)/);if(p||m){const c=(p?p[1]:m[1]).length,g=p?"ol":"ul",_=p?p[2]:m[2];if(i.length===0)o+=`<${g}>`,i.push({type:g,indent:c});else{const v=i[i.length-1];c>v.indent?(o+=`<${g}>`,i.push({type:g,indent:c})):c===v.indent?u():(f(c+1),i.length>0&&i[i.length-1].indent===c?u():(b(),o+=`<${g}>`,i.push({type:g,indent:c})))}o+=`<li>${_}`,h=!0}else d.trim()===""?i.length===0&&(o+="<br>"):(b(),o+=`<p>${d}</p>`)}return b(),o.replace(/\*\*(.*?)\*\*/g,"<strong>$1</strong>").replace(/\*(.*?)\*/g,"<em>$1</em>").replace(/\[([^\]]+)\]\(([^)]+)\)/g,'<a href="$2" target="_blank" rel="noopener noreferrer">$1</a>')}render(){const t=this.position.right<this.screenWidth/2;return n.html`
3
3
  <div class="chatbot">
4
4
  ${this.renderOverlay()}
5
5
  ${this.renderLauncher()}
@@ -71,25 +71,25 @@
71
71
  </div>
72
72
  </div>
73
73
  `}renderProductSelector(){return n.html`
74
- <div class="p-3 pb-0 flex-shrink-0 ml-[12px] mr-[12px]">
74
+ <div class="chatbot__product-selector">
75
75
  ${this.products.length>1?n.html`
76
- <logosphere-combobox
77
- id="product"
78
- .items=${this.products.map(t=>({value:t.id,label:t.name}))}
79
- optionValue="value"
80
- optionLabel="label"
81
- placeholder="Ürün seçiniz"
82
- @selected=${this.onProductChange}
83
- ></logosphere-combobox>
84
- `:n.html`
85
- <input
86
- id="product"
87
- placeholder="Ürün seçiniz"
88
- .value=${this.products.length===1?this.products[0].name:""}
89
- readOnly="true"
90
- class="border h-[24px] rounded-[8px] pl-1 text-md border-[var(--color-light)] bg-transparent w-full text-[var(--color-body-color)]"
91
- >
92
- `}
76
+ <logosphere-combobox
77
+ id="product"
78
+ .items=${this.products.map(t=>({value:t.id,label:t.name}))}
79
+ optionValue="value"
80
+ optionLabel="label"
81
+ placeholder="Ürün seçiniz"
82
+ @selected=${this.onProductChange}
83
+ ></logosphere-combobox>
84
+ `:n.html`
85
+ <input
86
+ id="product"
87
+ class="chatbot__product-input"
88
+ placeholder="Ürün seçiniz"
89
+ .value=${this.products.length===1?this.products[0].name:""}
90
+ readOnly="true"
91
+ >
92
+ `}
93
93
  </div>
94
94
  `}renderChatArea(){return n.html`
95
95
  <div id="chat-container" class="chatbot__messages">
@@ -100,7 +100,7 @@
100
100
  <div class="chatbot__message chatbot__message--${t.role}">
101
101
  <div class="${e}">
102
102
  <div class="chatbot__message-content">
103
- ${b.unsafeHTML(this.formatContent(t.content))}
103
+ ${y.unsafeHTML(this.formatContent(t.content))}
104
104
  </div>
105
105
  ${this.showFeedbackButtons&&t.role==="assistant"?this.renderFeedbackButtons(t):""}
106
106
  </div>
@@ -158,4 +158,4 @@
158
158
  <div class="chatbot__footer">
159
159
  <p class="chatbot__footer-text">İçerik Yapay Zeka ile Üretilmiştir</p>
160
160
  </div>
161
- `}};exports.LogosphereChatBot.styles=[n.css`${n.unsafeCSS(m)}`];exports.LogosphereChatBot.ICONS={launcher:"data:image/svg+xml,%3Csvg%20width%3D%2251%22%20height%3D%2242%22%20viewBox%3D%220%200%2051%2042%22%20fill%3D%22none%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20fill-rule%3D%22evenodd%22%20clip-rule%3D%22evenodd%22%20d%3D%22M38.457%200C40.0338%200%2041.542%200.293293%2042.9302%200.8283L49.15%206.07675C50.2611%207.93912%2050.8994%2010.1162%2050.8994%2012.4424V23.084C50.8994%2024.4858%2050.6676%2025.8334%2050.2402%2027.0907L43.1534%2034.6096C41.7043%2035.2006%2040.1187%2035.5264%2038.457%2035.5264H30.7605L38.5805%2027.2296C40.814%2027.1643%2042.6045%2025.3332%2042.6045%2023.084V12.4424C42.6045%2010.1518%2040.7476%208.29492%2038.457%208.29492H12.4424C10.1518%208.29492%208.29492%2010.1518%208.29492%2012.4424V23.084C8.29492%2025.3746%2010.1518%2027.2314%2012.4424%2027.2314H33.5078L20.4487%2041.0866C17.7992%2042.5379%2014.3381%2040.2741%2014.7842%2036.7803C14.8402%2036.3421%2014.9629%2035.9194%2015.1416%2035.5264H12.4424C10.9217%2035.5264%209.46472%2035.2536%208.11774%2034.7542L0.610679%2026.945C0.214298%2025.7295%200%2024.4318%200%2023.084V12.4424C0%2010.8011%200.317794%209.23402%200.895207%207.79935L7.12424%201.19058C8.73679%200.427072%2010.5397%200%2012.4424%200H38.457ZM23.1357%2017.7881C23.1357%2015.4815%2021.2656%2013.6113%2018.959%2013.6113C16.6525%2013.6114%2014.7822%2015.4815%2014.7822%2017.7881C14.7824%2020.0945%2016.6526%2021.9638%2018.959%2021.9639C21.2655%2021.9639%2023.1356%2020.0945%2023.1357%2017.7881ZM36.2344%2017.7881C36.2344%2015.4815%2034.3642%2013.6113%2032.0576%2013.6113C29.7511%2013.6114%2027.8809%2015.4815%2027.8809%2017.7881C27.881%2020.0945%2029.7512%2021.9638%2032.0576%2021.9639C34.3641%2021.9639%2036.2342%2020.0945%2036.2344%2017.7881Z%22%20fill%3D%22url(%23paint0_linear_97_4585)%22%2F%3E%3Cdefs%3E%3ClinearGradient%20id%3D%22paint0_linear_97_4585%22%20x1%3D%2231.662%22%20y1%3D%224.88016%22%20x2%3D%2214.4119%22%20y2%3D%2237.9167%22%20gradientUnits%3D%22userSpaceOnUse%22%3E%3Cstop%20stop-color%3D%22%23F22727%22%2F%3E%3Cstop%20offset%3D%221%22%20stop-color%3D%22%23CA0D0D%22%2F%3E%3C%2FlinearGradient%3E%3C%2Fdefs%3E%3C%2Fsvg%3E"};s([i.property({type:String,attribute:"return-uri"})],exports.LogosphereChatBot.prototype,"returnUri",2);s([i.property({type:String,attribute:"question-prompt"})],exports.LogosphereChatBot.prototype,"questionPrompt",2);s([i.property({type:Boolean,attribute:"minimized-icon-only"})],exports.LogosphereChatBot.prototype,"minimizedIconOnly",2);s([i.property({type:Boolean,attribute:"draggable"})],exports.LogosphereChatBot.prototype,"draggable",2);s([i.property({type:Boolean,attribute:"resizable"})],exports.LogosphereChatBot.prototype,"resizable",2);s([i.property({type:Array,hasChanged:(l,t)=>l===t?!1:!t||!l||l.length!==t.length?!0:JSON.stringify(l)!==JSON.stringify(t)}),i.property({type:Array})],exports.LogosphereChatBot.prototype,"products",2);s([i.property({type:Boolean,attribute:"open-initially"})],exports.LogosphereChatBot.prototype,"openInitially",2);s([i.property({type:Boolean,attribute:"show-feedback-buttons"})],exports.LogosphereChatBot.prototype,"showFeedbackButtons",2);s([i.state()],exports.LogosphereChatBot.prototype,"open",2);s([i.state()],exports.LogosphereChatBot.prototype,"fullscreen",2);s([i.state()],exports.LogosphereChatBot.prototype,"messages",2);s([i.state()],exports.LogosphereChatBot.prototype,"conversationId",2);s([i.state()],exports.LogosphereChatBot.prototype,"assertionToken",2);s([i.state()],exports.LogosphereChatBot.prototype,"isLoading",2);s([i.state()],exports.LogosphereChatBot.prototype,"inputText",2);s([i.state()],exports.LogosphereChatBot.prototype,"selectedProductId",2);s([i.state()],exports.LogosphereChatBot.prototype,"windowWidth",2);s([i.state()],exports.LogosphereChatBot.prototype,"windowHeight",2);s([i.state()],exports.LogosphereChatBot.prototype,"position",2);s([i.state()],exports.LogosphereChatBot.prototype,"isDragging",2);s([i.state()],exports.LogosphereChatBot.prototype,"screenWidth",2);s([i.query("#chat-container")],exports.LogosphereChatBot.prototype,"chatContainer",2);s([i.query("#product")],exports.LogosphereChatBot.prototype,"productEl",2);exports.LogosphereChatBot=s([i.customElement("logosphere-chatbot")],exports.LogosphereChatBot);
161
+ `}};exports.LogosphereChatBot.styles=[n.css`${n.unsafeCSS(w)}`];exports.LogosphereChatBot.ICONS={launcher:"data:image/svg+xml,%3Csvg%20width%3D%2251%22%20height%3D%2242%22%20viewBox%3D%220%200%2051%2042%22%20fill%3D%22none%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20fill-rule%3D%22evenodd%22%20clip-rule%3D%22evenodd%22%20d%3D%22M38.457%200C40.0338%200%2041.542%200.293293%2042.9302%200.8283L49.15%206.07675C50.2611%207.93912%2050.8994%2010.1162%2050.8994%2012.4424V23.084C50.8994%2024.4858%2050.6676%2025.8334%2050.2402%2027.0907L43.1534%2034.6096C41.7043%2035.2006%2040.1187%2035.5264%2038.457%2035.5264H30.7605L38.5805%2027.2296C40.814%2027.1643%2042.6045%2025.3332%2042.6045%2023.084V12.4424C42.6045%2010.1518%2040.7476%208.29492%2038.457%208.29492H12.4424C10.1518%208.29492%208.29492%2010.1518%208.29492%2012.4424V23.084C8.29492%2025.3746%2010.1518%2027.2314%2012.4424%2027.2314H33.5078L20.4487%2041.0866C17.7992%2042.5379%2014.3381%2040.2741%2014.7842%2036.7803C14.8402%2036.3421%2014.9629%2035.9194%2015.1416%2035.5264H12.4424C10.9217%2035.5264%209.46472%2035.2536%208.11774%2034.7542L0.610679%2026.945C0.214298%2025.7295%200%2024.4318%200%2023.084V12.4424C0%2010.8011%200.317794%209.23402%200.895207%207.79935L7.12424%201.19058C8.73679%200.427072%2010.5397%200%2012.4424%200H38.457ZM23.1357%2017.7881C23.1357%2015.4815%2021.2656%2013.6113%2018.959%2013.6113C16.6525%2013.6114%2014.7822%2015.4815%2014.7822%2017.7881C14.7824%2020.0945%2016.6526%2021.9638%2018.959%2021.9639C21.2655%2021.9639%2023.1356%2020.0945%2023.1357%2017.7881ZM36.2344%2017.7881C36.2344%2015.4815%2034.3642%2013.6113%2032.0576%2013.6113C29.7511%2013.6114%2027.8809%2015.4815%2027.8809%2017.7881C27.881%2020.0945%2029.7512%2021.9638%2032.0576%2021.9639C34.3641%2021.9639%2036.2342%2020.0945%2036.2344%2017.7881Z%22%20fill%3D%22url(%23paint0_linear_97_4585)%22%2F%3E%3Cdefs%3E%3ClinearGradient%20id%3D%22paint0_linear_97_4585%22%20x1%3D%2231.662%22%20y1%3D%224.88016%22%20x2%3D%2214.4119%22%20y2%3D%2237.9167%22%20gradientUnits%3D%22userSpaceOnUse%22%3E%3Cstop%20stop-color%3D%22%23F22727%22%2F%3E%3Cstop%20offset%3D%221%22%20stop-color%3D%22%23CA0D0D%22%2F%3E%3C%2FlinearGradient%3E%3C%2Fdefs%3E%3C%2Fsvg%3E"};a([s.property({type:String,attribute:"return-uri"})],exports.LogosphereChatBot.prototype,"returnUri",2);a([s.property({type:String,attribute:"question-prompt"})],exports.LogosphereChatBot.prototype,"questionPrompt",2);a([s.property({type:Boolean,attribute:"minimized-icon-only"})],exports.LogosphereChatBot.prototype,"minimizedIconOnly",2);a([s.property({type:Boolean,attribute:"draggable"})],exports.LogosphereChatBot.prototype,"draggable",2);a([s.property({type:Boolean,attribute:"resizable"})],exports.LogosphereChatBot.prototype,"resizable",2);a([s.property({type:Array,hasChanged:(l,t)=>l===t?!1:!t||!l||l.length!==t.length?!0:JSON.stringify(l)!==JSON.stringify(t)}),s.property({type:Array})],exports.LogosphereChatBot.prototype,"products",2);a([s.property({type:Boolean,attribute:"open-initially"})],exports.LogosphereChatBot.prototype,"openInitially",2);a([s.property({type:Boolean,attribute:"show-feedback-buttons"})],exports.LogosphereChatBot.prototype,"showFeedbackButtons",2);a([s.state()],exports.LogosphereChatBot.prototype,"open",2);a([s.state()],exports.LogosphereChatBot.prototype,"fullscreen",2);a([s.state()],exports.LogosphereChatBot.prototype,"messages",2);a([s.state()],exports.LogosphereChatBot.prototype,"conversationId",2);a([s.state()],exports.LogosphereChatBot.prototype,"assertionToken",2);a([s.state()],exports.LogosphereChatBot.prototype,"isLoading",2);a([s.state()],exports.LogosphereChatBot.prototype,"inputText",2);a([s.state()],exports.LogosphereChatBot.prototype,"selectedProductId",2);a([s.state()],exports.LogosphereChatBot.prototype,"windowWidth",2);a([s.state()],exports.LogosphereChatBot.prototype,"windowHeight",2);a([s.state()],exports.LogosphereChatBot.prototype,"position",2);a([s.state()],exports.LogosphereChatBot.prototype,"isDragging",2);a([s.state()],exports.LogosphereChatBot.prototype,"screenWidth",2);a([s.query("#chat-container")],exports.LogosphereChatBot.prototype,"chatContainer",2);a([s.query("#product")],exports.LogosphereChatBot.prototype,"productEl",2);exports.LogosphereChatBot=a([s.customElement("logosphere-chatbot")],exports.LogosphereChatBot);
@@ -1,17 +1,17 @@
1
- import { unsafeCSS as f, css as v, LitElement as _, html as a } from "lit";
2
- import { property as d, state as c, query as b, customElement as y } from "lit/decorators.js";
3
- import { unsafeHTML as w } from "lit/directives/unsafe-html.js";
1
+ import { unsafeCSS as x, css as z, LitElement as C, html as a } from "lit";
2
+ import { property as d, state as l, query as y, customElement as k } from "lit/decorators.js";
3
+ import { unsafeHTML as $ } from "lit/directives/unsafe-html.js";
4
4
  import "./combobox-LBU6VHLi.js";
5
5
  import "./button-BqOMevro.js";
6
6
  import "./input-jmbvgWEq.js";
7
7
  import "./ui-icon-Bys4HYSQ.js";
8
- const x = ":host{display:block;z-index:9999}.chatbot{font-family:var(--font-family-base)}.chatbot__overlay{position:fixed;inset:0;background-color:#0003;z-index:var(--z-index-modal-backdrop)}.chatbot__launcher{position:fixed;z-index:var(--z-index-modal);display:flex;align-items:center;gap:var(--spacing-4);padding-left:var(--spacing-4);padding-right:var(--spacing-4);height:66px;color:#fff;border-radius:var(--radius-xl);cursor:pointer;box-shadow:var(--shadow-base);background-color:var(--color-body-bg);overflow:hidden;transition:box-shadow var(--transition-speed-fast) var(--transition-timing)}.chatbot__launcher:hover{box-shadow:var(--shadow-md)}.chatbot__launcher--draggable{cursor:move}.chatbot__launcher--hidden{visibility:hidden;width:72px;height:66px;justify-content:center;padding:0}.chatbot__launcher-icon{width:40px;height:34px;flex-shrink:0}.chatbot__launcher-text{display:flex;flex-direction:column}.chatbot__launcher-title{font-weight:var(--font-weight-semibold);font-size:var(--font-size-xl);margin:0;line-height:24px;white-space:nowrap;color:var(--color-body-text)}.chatbot__launcher-subtitle{font-weight:var(--font-weight-semibold);font-size:var(--font-size-sm);margin:0;line-height:20px;white-space:nowrap;color:var(--color-tertiary)}.chatbot__window{position:fixed;z-index:var(--z-index-modal);display:flex;flex-direction:column;box-shadow:var(--shadow-xl);border-radius:var(--radius-md);overflow:hidden;background-color:var(--color-body-bg)}.chatbot__window--hidden{display:none}.chatbot__window--fullscreen{inset:80px 50px;width:auto;height:auto}.chatbot__resize-top{position:absolute;top:0;left:0;right:0;height:8px;cursor:ns-resize;z-index:50;transition:background-color var(--transition-speed-fast) var(--transition-timing)}.chatbot__resize-top:hover{background-color:#0000000d}.chatbot__resize-side{position:absolute;top:0;bottom:0;width:8px;cursor:ew-resize;z-index:50;transition:background-color var(--transition-speed-fast) var(--transition-timing)}.chatbot__resize-side:hover{background-color:#0000000d}.chatbot__resize-side--left{left:0}.chatbot__resize-side--right{right:0}.chatbot__resize-corner{position:absolute;top:0;width:16px;height:16px;z-index:50;transition:background-color var(--transition-speed-fast) var(--transition-timing)}.chatbot__resize-corner:hover{background-color:#0000001a}.chatbot__resize-corner--nwse{left:0;cursor:nwse-resize}.chatbot__resize-corner--nesw{right:0;cursor:nesw-resize}.chatbot__header{height:74px;display:flex;align-items:center;justify-content:space-between;padding-left:var(--spacing-5);padding-right:var(--spacing-4);gap:var(--spacing-4);flex-shrink:0;background-color:var(--color-body-bg);border-bottom:1px solid var(--color-border)}.chatbot__header-info{display:flex;align-items:center;gap:var(--spacing-4)}.chatbot__header-logo{width:50px;height:41px}.chatbot__header-title{font-weight:var(--font-weight-semibold);font-size:var(--font-size-xl);margin:0;line-height:24px;color:var(--color-body-text)}.chatbot__header-subtitle{font-weight:var(--font-weight-semibold);font-size:var(--font-size-sm);margin:0;line-height:20px;color:var(--color-tertiary)}.chatbot__header-actions{display:flex;align-items:center;gap:var(--spacing-2)}.chatbot__body{flex:1;display:flex;flex-direction:column;background-color:var(--color-body-bg);position:relative;overflow:hidden}.chatbot__product{padding:var(--spacing-3);padding-bottom:0;flex-shrink:0;margin:0 var(--spacing-3)}.chatbot__messages{flex:1;display:flex;flex-direction:column;gap:var(--spacing-3);margin-top:var(--spacing-4);padding:var(--spacing-4);overflow-y:auto;scrollbar-width:none;-ms-overflow-style:none}.chatbot__messages::-webkit-scrollbar{display:none}.chatbot__message{display:flex}.chatbot__message--user{justify-content:flex-end}.chatbot__message--assistant,.chatbot__message--system{justify-content:flex-start}.chatbot__bubble{position:relative;color:var(--color-body-text);max-width:85%;border-radius:var(--radius-md);padding:var(--spacing-4);font-size:var(--font-size-sm);line-height:20px;font-weight:var(--font-weight-medium)}.chatbot__bubble--user{background-color:var(--color-primary);color:#fff;border-bottom-right-radius:0;border-top-right-radius:var(--radius-xl);border-top-left-radius:var(--radius-xl);border-bottom-left-radius:var(--radius-xl)}.chatbot__bubble--user a{color:#ffffffe6}.chatbot__bubble--assistant,.chatbot__bubble--system{background-color:var(--color-tertiary-bg);border-bottom-left-radius:0;border-top-right-radius:var(--radius-xl);border-top-left-radius:var(--radius-xl);border-bottom-right-radius:var(--radius-xl)}.chatbot__message-content p{margin:0}.chatbot__message-content ol{list-style-type:decimal;margin:0;padding-left:var(--spacing-5)}.chatbot__message-content ul{list-style-type:disc;margin:0;padding-left:var(--spacing-5)}.chatbot__message-content li{padding-left:var(--spacing-1)}.chatbot__message-content a{color:var(--color-primary);text-decoration:underline;transition:color var(--transition-speed-fast) var(--transition-timing)}.chatbot__message-content a:hover{color:var(--color-primary-hover)}.chatbot__feedback{display:flex;align-items:center;gap:var(--spacing-2);padding-top:var(--spacing-2)}.chatbot__typing-wrapper{display:flex;justify-content:flex-start}.chatbot__typing{background-color:var(--color-tertiary-bg);padding:var(--spacing-3);border-radius:var(--radius-xl);border-bottom-left-radius:0;display:inline-flex;align-items:center;gap:2px}.chatbot__typing-dot{display:inline-block;width:6px;height:6px;background-color:var(--color-gray-300);border-radius:var(--radius-full);animation:chatbot-typing 1.4s infinite ease-in-out both;margin:0 2px}.chatbot__typing-dot:nth-child(1){animation-delay:-.32s}.chatbot__typing-dot:nth-child(2){animation-delay:-.16s}@keyframes chatbot-typing{0%,80%,to{transform:scale(0)}40%{transform:scale(1)}}.chatbot__input-area{padding:var(--spacing-4);padding-top:var(--spacing-2);padding-bottom:var(--spacing-1);background-color:var(--color-body-bg)}.chatbot__input-wrapper{position:relative;display:flex;align-items:center;gap:var(--spacing-2);background-color:var(--color-tertiary-bg);border-radius:var(--radius-md);padding:var(--spacing-2);border:1px solid transparent;transition:background-color var(--transition-speed-fast) var(--transition-timing),border-color var(--transition-speed-fast) var(--transition-timing)}.chatbot__input-wrapper:focus-within{background-color:var(--color-body-bg);border-color:var(--color-border)}.chatbot__input{flex:1;background:transparent;border:none;outline:none;font-family:var(--font-family-base);font-size:var(--font-size-sm);color:var(--color-body-text)}.chatbot__input::placeholder{color:var(--color-tertiary)}.chatbot__input:disabled{opacity:.5;cursor:not-allowed}.chatbot__footer{display:flex;align-items:center;justify-content:center;padding-bottom:var(--spacing-2)}.chatbot__footer-text{margin:0;padding:0;color:var(--color-secondary);font-size:var(--font-size-xs);font-family:var(--font-family-base)}";
9
- var z = Object.defineProperty, C = Object.getOwnPropertyDescriptor, s = (t, e, n, i) => {
10
- for (var r = i > 1 ? void 0 : i ? C(e, n) : e, l = t.length - 1, h; l >= 0; l--)
11
- (h = t[l]) && (r = (i ? h(e, n, r) : h(r)) || r);
12
- return i && r && z(e, n, r), r;
8
+ const D = ":host{display:block;z-index:9999}.chatbot{font-family:var(--font-family-base)}.chatbot__overlay{position:fixed;inset:0;background-color:#0003;z-index:var(--z-index-modal-backdrop)}.chatbot__launcher{position:fixed;z-index:var(--z-index-modal);display:flex;align-items:center;gap:var(--spacing-4);padding-left:var(--spacing-4);padding-right:var(--spacing-4);height:66px;color:#fff;border-radius:var(--radius-xl);cursor:pointer;box-shadow:var(--shadow-base);background-color:var(--color-body-bg);overflow:hidden;transition:box-shadow var(--transition-speed-fast) var(--transition-timing)}.chatbot__launcher:hover{box-shadow:var(--shadow-md)}.chatbot__launcher--draggable{cursor:move}.chatbot__launcher--hidden{visibility:hidden;width:72px;height:66px;justify-content:center;padding:0}.chatbot__launcher-icon{width:40px;height:34px;flex-shrink:0}.chatbot__launcher-text{display:flex;flex-direction:column}.chatbot__launcher-title{font-weight:var(--font-weight-semibold);font-size:var(--font-size-xl);margin:0;line-height:24px;white-space:nowrap;color:var(--color-body-text)}.chatbot__launcher-subtitle{font-weight:var(--font-weight-semibold);font-size:var(--font-size-sm);margin:0;line-height:20px;white-space:nowrap;color:var(--color-tertiary)}.chatbot__window{position:fixed;z-index:var(--z-index-modal);display:flex;flex-direction:column;box-shadow:var(--shadow-xl);border-radius:var(--radius-md);overflow:hidden;background-color:var(--color-body-bg)}.chatbot__window--hidden{display:none}.chatbot__window--fullscreen{inset:80px 50px;width:auto;height:auto}.chatbot__resize-top{position:absolute;top:0;left:0;right:0;height:8px;cursor:ns-resize;z-index:50;transition:background-color var(--transition-speed-fast) var(--transition-timing)}.chatbot__resize-top:hover{background-color:#0000000d}.chatbot__resize-side{position:absolute;top:0;bottom:0;width:8px;cursor:ew-resize;z-index:50;transition:background-color var(--transition-speed-fast) var(--transition-timing)}.chatbot__resize-side:hover{background-color:#0000000d}.chatbot__resize-side--left{left:0}.chatbot__resize-side--right{right:0}.chatbot__resize-corner{position:absolute;top:0;width:16px;height:16px;z-index:50;transition:background-color var(--transition-speed-fast) var(--transition-timing)}.chatbot__resize-corner:hover{background-color:#0000001a}.chatbot__resize-corner--nwse{left:0;cursor:nwse-resize}.chatbot__resize-corner--nesw{right:0;cursor:nesw-resize}.chatbot__header{height:74px;display:flex;align-items:center;justify-content:space-between;padding-left:var(--spacing-5);padding-right:var(--spacing-4);gap:var(--spacing-4);flex-shrink:0;background-color:var(--color-body-bg);border-bottom:1px solid var(--color-border)}.chatbot__header-info{display:flex;align-items:center;gap:var(--spacing-4)}.chatbot__header-logo{width:50px;height:41px}.chatbot__header-title{font-weight:var(--font-weight-semibold);font-size:var(--font-size-xl);margin:0;line-height:24px;color:var(--color-body-text)}.chatbot__header-subtitle{font-weight:var(--font-weight-semibold);font-size:var(--font-size-sm);margin:0;line-height:20px;color:var(--color-tertiary)}.chatbot__header-actions{display:flex;align-items:center;gap:var(--spacing-2)}.chatbot__body{flex:1;display:flex;flex-direction:column;background-color:var(--color-body-bg);position:relative;overflow:hidden}.chatbot__product{padding:var(--spacing-3);padding-bottom:0;flex-shrink:0;margin:0 var(--spacing-3)}.chatbot__messages{flex:1;display:flex;flex-direction:column;gap:var(--spacing-3);margin-top:var(--spacing-4);padding:var(--spacing-4);overflow-y:auto;scrollbar-width:none;-ms-overflow-style:none}.chatbot__messages::-webkit-scrollbar{display:none}.chatbot__message{display:flex}.chatbot__message--user{justify-content:flex-end}.chatbot__message--assistant,.chatbot__message--system{justify-content:flex-start}.chatbot__bubble{position:relative;color:var(--color-body-text);max-width:85%;border-radius:var(--radius-md);padding:var(--spacing-4);font-size:var(--font-size-sm);line-height:20px;font-weight:var(--font-weight-medium)}.chatbot__bubble--user{background-color:var(--color-primary);color:#fff;border-bottom-right-radius:0;border-top-right-radius:var(--radius-xl);border-top-left-radius:var(--radius-xl);border-bottom-left-radius:var(--radius-xl)}.chatbot__bubble--user a{color:#ffffffe6}.chatbot__bubble--assistant,.chatbot__bubble--system{background-color:var(--color-tertiary-bg);border-bottom-left-radius:0;border-top-right-radius:var(--radius-xl);border-top-left-radius:var(--radius-xl);border-bottom-right-radius:var(--radius-xl)}.chatbot__message-content p{margin:0}.chatbot__message-content ol{list-style-type:decimal;margin:0;padding-left:var(--spacing-5)}.chatbot__message-content ul{list-style-type:disc;margin:0;padding-left:var(--spacing-5)}.chatbot__message-content li>ol,.chatbot__message-content li>ul{margin-top:var(--spacing-1);margin-bottom:var(--spacing-1)}.chatbot__message-content ol ol{list-style-type:lower-alpha}.chatbot__message-content ol ol ol{list-style-type:lower-roman}.chatbot__message-content ul ul{list-style-type:circle}.chatbot__message-content ul ul ul{list-style-type:square}.chatbot__message-content li{padding-left:var(--spacing-1)}.chatbot__message-content a{color:var(--color-primary);text-decoration:underline;transition:color var(--transition-speed-fast) var(--transition-timing)}.chatbot__message-content a:hover{color:var(--color-primary-hover)}.chatbot__feedback{display:flex;align-items:center;gap:var(--spacing-2);padding-top:var(--spacing-2)}.chatbot__typing-wrapper{display:flex;justify-content:flex-start}.chatbot__typing{background-color:var(--color-tertiary-bg);padding:var(--spacing-3);border-radius:var(--radius-xl);border-bottom-left-radius:0;display:inline-flex;align-items:center;gap:2px}.chatbot__typing-dot{display:inline-block;width:6px;height:6px;background-color:var(--color-gray-300);border-radius:var(--radius-full);animation:chatbot-typing 1.4s infinite ease-in-out both;margin:0 2px}.chatbot__typing-dot:nth-child(1){animation-delay:-.32s}.chatbot__typing-dot:nth-child(2){animation-delay:-.16s}@keyframes chatbot-typing{0%,80%,to{transform:scale(0)}40%{transform:scale(1)}}.chatbot__input-area{padding:var(--spacing-4);padding-top:var(--spacing-2);padding-bottom:var(--spacing-1);background-color:var(--color-body-bg)}.chatbot__input-wrapper{position:relative;display:flex;align-items:center;gap:var(--spacing-2);background-color:var(--color-tertiary-bg);border-radius:var(--radius-md);padding:var(--spacing-2);border:1px solid transparent;transition:background-color var(--transition-speed-fast) var(--transition-timing),border-color var(--transition-speed-fast) var(--transition-timing)}.chatbot__input-wrapper:focus-within{background-color:var(--color-body-bg);border-color:var(--color-border)}.chatbot__input{flex:1;background:transparent;border:none;outline:none;font-family:var(--font-family-base);font-size:var(--font-size-sm);color:var(--color-body-text)}.chatbot__input::placeholder{color:var(--color-tertiary)}.chatbot__input:disabled{opacity:.5;cursor:not-allowed}.chatbot__footer{display:flex;align-items:center;justify-content:center;padding-bottom:var(--spacing-2)}.chatbot__footer-text{margin:0;padding:0;color:var(--color-secondary);font-size:var(--font-size-xs);font-family:var(--font-family-base)}.chatbot__product-selector{padding:var(--spacing-3) var(--spacing-3) 0;flex-shrink:0}.chatbot__product-input{display:block;width:100%;height:24px;padding-left:var(--spacing-1);border:1px solid var(--color-border);border-radius:var(--radius-md);background:transparent;color:var(--color-body-color);font-size:var(--font-size-md);outline:none}";
9
+ var M = Object.defineProperty, I = Object.getOwnPropertyDescriptor, r = (t, e, n, i) => {
10
+ for (var o = i > 1 ? void 0 : i ? I(e, n) : e, c = t.length - 1, h; c >= 0; c--)
11
+ (h = t[c]) && (o = (i ? h(e, n, o) : h(o)) || o);
12
+ return i && o && M(e, n, o), o;
13
13
  };
14
- let o = class extends _ {
14
+ let s = class extends C {
15
15
  constructor() {
16
16
  super(...arguments), this.returnUri = "", this.questionPrompt = "", this.minimizedIconOnly = !1, this.draggable = !1, this.resizable = !1, this.products = [], this.openInitially = !1, this.showFeedbackButtons = !1, this.open = !1, this.fullscreen = !1, this.messages = [], this.isLoading = !1, this.inputText = "", this.selectedProductId = "", this.windowWidth = 440, this.windowHeight = Math.min(700, window.innerHeight - 40), this.position = { right: 20, bottom: 20 }, this.isDragging = !1, this.screenWidth = window.innerWidth, this.dragStartPos = { x: 0, y: 0 }, this.initialPosition = { right: 0, bottom: 0 }, this.isResizing = !1, this.resizeDirection = "horizontal", this.resizeStartWidth = 0, this.resizeStartHeight = 0, this.onWindowResize = () => {
17
17
  this.screenWidth = window.innerWidth;
@@ -25,9 +25,9 @@ let o = class extends _ {
25
25
  this.fullscreen = !this.fullscreen;
26
26
  }, this.onMouseMove = (t) => {
27
27
  if (this.isDragging) {
28
- const e = this.dragStartPos.x - t.clientX, n = this.dragStartPos.y - t.clientY, r = this.shadowRoot?.querySelector(".chatbot__launcher")?.getBoundingClientRect(), l = r?.width || 72, h = r?.height || 66;
28
+ const e = this.dragStartPos.x - t.clientX, n = this.dragStartPos.y - t.clientY, o = this.shadowRoot?.querySelector(".chatbot__launcher")?.getBoundingClientRect(), c = o?.width || 72, h = o?.height || 66;
29
29
  this.position = {
30
- right: Math.max(0, Math.min(window.innerWidth - l, this.initialPosition.right + e)),
30
+ right: Math.max(0, Math.min(window.innerWidth - c, this.initialPosition.right + e)),
31
31
  bottom: Math.max(0, Math.min(window.innerHeight - h, this.initialPosition.bottom + n))
32
32
  };
33
33
  } else if (this.isResizing) {
@@ -56,16 +56,21 @@ let o = class extends _ {
56
56
  super.disconnectedCallback(), window.removeEventListener("resize", this.onWindowResize), window.removeEventListener("mousemove", this.onMouseMove), window.removeEventListener("mouseup", this.onMouseUp);
57
57
  }
58
58
  async firstUpdated() {
59
- this.products.length === 1 && (this.selectedProductId = this.products[0].id), this.open = this.openInitially, this.open && await this.initConversation();
59
+ this.selectedProductId = this._resolveInitialProduct(), this.open = this.openInitially, this.open && await this.initConversation();
60
60
  }
61
61
  updated(t) {
62
62
  t.has("products") && this.handleProductUpdate(), t.has("messages") && this.scrollToBottom(), t.has("open") && this.open && !this.conversationId && this.initConversation();
63
63
  }
64
64
  // ==================== PRODUCT ====================
65
+ _resolveInitialProduct() {
66
+ if (!this.products.length) return "";
67
+ const t = this.products.find((e) => e.selected);
68
+ return t ? t.id : this.products.length === 1 ? this.products[0].id : "";
69
+ }
65
70
  handleProductUpdate() {
66
71
  if (!this.products.length) return;
67
- const t = this.products.some((e) => e.id === this.selectedProductId);
68
- this.products.length === 1 && (this.selectedProductId = this.products[0].id), t || (this.messages = [], this.conversationId = void 0, this.open && this.initConversation()), requestAnimationFrame(() => this.updateComboboxItems());
72
+ const t = this._resolveInitialProduct();
73
+ this.products.some((n) => n.id === this.selectedProductId) || (this.selectedProductId = t, this.messages = [], this.conversationId = void 0, this.open && this.initConversation()), requestAnimationFrame(() => this.updateComboboxItems());
69
74
  }
70
75
  updateComboboxItems() {
71
76
  const t = this.productEl;
@@ -73,9 +78,12 @@ let o = class extends _ {
73
78
  const e = this.products.map((i) => ({ value: i.id, label: i.name }));
74
79
  t.items = e;
75
80
  const n = t.selectedItems?.() || [];
76
- if (n.length > 0) {
81
+ if (n.length === 0 && this.selectedProductId) {
82
+ const i = e.find((o) => o.value === this.selectedProductId);
83
+ i && t.setSelected && t.setSelected([i]);
84
+ } else if (n.length > 0) {
77
85
  const i = n[0]?.value;
78
- !this.products.some((l) => l.id === i) && t.setSelected && t.setSelected([]);
86
+ !this.products.some((c) => c.id === i) && t.setSelected && t.setSelected([]);
79
87
  }
80
88
  }
81
89
  async onProductChange(t) {
@@ -93,9 +101,9 @@ let o = class extends _ {
93
101
  async ensureToken(t = !1) {
94
102
  const e = "logosphere_chatbot_token";
95
103
  if (t && (this.assertionToken = void 0, localStorage.removeItem(e)), !t) {
96
- const r = localStorage.getItem(e);
97
- if (r) {
98
- this.assertionToken = r;
104
+ const o = localStorage.getItem(e);
105
+ if (o) {
106
+ this.assertionToken = o;
99
107
  return;
100
108
  }
101
109
  }
@@ -175,16 +183,29 @@ let o = class extends _ {
175
183
  if (!t) return "";
176
184
  const n = t.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").split(`
177
185
  `);
178
- let i = "", r = !1, l = "";
179
- for (const h of n) {
180
- const m = h.trim() === "", p = h.match(/^\s*\d+\.\s+(.*)/), g = h.match(/^\s*[-*]\s+(.*)/);
181
- if (p || g) {
182
- const u = p ? "ol" : "ul";
183
- (!r || l !== u) && (r && (i += `</${l}>`), i += `<${u}>`, r = !0, l = u), i += `<li>${p ? p[1] : g[1]}</li>`;
184
- } else
185
- m ? r || (i += "<br>") : (r && (i += `</${l}>`, r = !1, l = ""), i += `<p>${h}</p>`);
186
+ let i = "";
187
+ const o = [];
188
+ let c = !1;
189
+ const h = () => {
190
+ c && (i += "</li>", c = !1);
191
+ }, v = (u) => {
192
+ for (; o.length > 0 && o[o.length - 1].indent >= u; )
193
+ h(), i += `</${o.pop().type}>`, o.length > 0 && (c = !0);
194
+ }, m = () => v(-1);
195
+ for (const u of n) {
196
+ const g = u.match(/^(\s*)\d+\.\s+(.*)/), f = u.match(/^(\s*)[-*]\s+(.*)/);
197
+ if (g || f) {
198
+ const p = (g ? g[1] : f[1]).length, b = g ? "ol" : "ul", w = g ? g[2] : f[2];
199
+ if (o.length === 0)
200
+ i += `<${b}>`, o.push({ type: b, indent: p });
201
+ else {
202
+ const _ = o[o.length - 1];
203
+ p > _.indent ? (i += `<${b}>`, o.push({ type: b, indent: p })) : p === _.indent ? h() : (v(p + 1), o.length > 0 && o[o.length - 1].indent === p ? h() : (m(), i += `<${b}>`, o.push({ type: b, indent: p })));
204
+ }
205
+ i += `<li>${w}`, c = !0;
206
+ } else u.trim() === "" ? o.length === 0 && (i += "<br>") : (m(), i += `<p>${u}</p>`);
186
207
  }
187
- return r && (i += `</${l}>`), i.replace(/\*\*(.*?)\*\*/g, "<strong>$1</strong>").replace(/\*(.*?)\*/g, "<em>$1</em>").replace(
208
+ return m(), i.replace(/\*\*(.*?)\*\*/g, "<strong>$1</strong>").replace(/\*(.*?)\*/g, "<em>$1</em>").replace(
188
209
  /\[([^\]]+)\]\(([^)]+)\)/g,
189
210
  '<a href="$2" target="_blank" rel="noopener noreferrer">$1</a>'
190
211
  );
@@ -217,7 +238,7 @@ let o = class extends _ {
217
238
  @click=${this.draggable ? null : this.onToggle}
218
239
  aria-expanded=${this.open ? "true" : "false"}
219
240
  >
220
- <img class="chatbot__launcher-icon" src="${o.ICONS.launcher}" alt="chatbot" />
241
+ <img class="chatbot__launcher-icon" src="${s.ICONS.launcher}" alt="chatbot" />
221
242
  ${!this.open && !this.minimizedIconOnly ? a`
222
243
  <div class="chatbot__launcher-text">
223
244
  <p class="chatbot__launcher-title">Logo</p>
@@ -259,7 +280,7 @@ let o = class extends _ {
259
280
  return a`
260
281
  <div class="chatbot__header">
261
282
  <div class="chatbot__header-info">
262
- <img class="chatbot__header-logo" alt="logo" src="${o.ICONS.launcher}" />
283
+ <img class="chatbot__header-logo" alt="logo" src="${s.ICONS.launcher}" />
263
284
  <div>
264
285
  <p class="chatbot__header-title">Logo</p>
265
286
  <p class="chatbot__header-subtitle">Dijital Danışman</p>
@@ -292,25 +313,25 @@ let o = class extends _ {
292
313
  }
293
314
  renderProductSelector() {
294
315
  return a`
295
- <div class="p-3 pb-0 flex-shrink-0 ml-[12px] mr-[12px]">
316
+ <div class="chatbot__product-selector">
296
317
  ${this.products.length > 1 ? a`
297
- <logosphere-combobox
298
- id="product"
299
- .items=${this.products.map((t) => ({ value: t.id, label: t.name }))}
300
- optionValue="value"
301
- optionLabel="label"
302
- placeholder="Ürün seçiniz"
303
- @selected=${this.onProductChange}
304
- ></logosphere-combobox>
305
- ` : a`
306
- <input
307
- id="product"
308
- placeholder="Ürün seçiniz"
309
- .value=${this.products.length === 1 ? this.products[0].name : ""}
310
- readOnly="true"
311
- class="border h-[24px] rounded-[8px] pl-1 text-md border-[var(--color-light)] bg-transparent w-full text-[var(--color-body-color)]"
312
- >
313
- `}
318
+ <logosphere-combobox
319
+ id="product"
320
+ .items=${this.products.map((t) => ({ value: t.id, label: t.name }))}
321
+ optionValue="value"
322
+ optionLabel="label"
323
+ placeholder="Ürün seçiniz"
324
+ @selected=${this.onProductChange}
325
+ ></logosphere-combobox>
326
+ ` : a`
327
+ <input
328
+ id="product"
329
+ class="chatbot__product-input"
330
+ placeholder="Ürün seçiniz"
331
+ .value=${this.products.length === 1 ? this.products[0].name : ""}
332
+ readOnly="true"
333
+ >
334
+ `}
314
335
  </div>
315
336
  `;
316
337
  }
@@ -331,7 +352,7 @@ let o = class extends _ {
331
352
  <div class="chatbot__message chatbot__message--${t.role}">
332
353
  <div class="${e}">
333
354
  <div class="chatbot__message-content">
334
- ${w(this.formatContent(t.content))}
355
+ ${$(this.formatContent(t.content))}
335
356
  </div>
336
357
  ${this.showFeedbackButtons && t.role === "assistant" ? this.renderFeedbackButtons(t) : ""}
337
358
  </div>
@@ -401,86 +422,86 @@ let o = class extends _ {
401
422
  `;
402
423
  }
403
424
  };
404
- o.styles = [v`${f(x)}`];
405
- o.ICONS = {
425
+ s.styles = [z`${x(D)}`];
426
+ s.ICONS = {
406
427
  launcher: "data:image/svg+xml,%3Csvg%20width%3D%2251%22%20height%3D%2242%22%20viewBox%3D%220%200%2051%2042%22%20fill%3D%22none%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20fill-rule%3D%22evenodd%22%20clip-rule%3D%22evenodd%22%20d%3D%22M38.457%200C40.0338%200%2041.542%200.293293%2042.9302%200.8283L49.15%206.07675C50.2611%207.93912%2050.8994%2010.1162%2050.8994%2012.4424V23.084C50.8994%2024.4858%2050.6676%2025.8334%2050.2402%2027.0907L43.1534%2034.6096C41.7043%2035.2006%2040.1187%2035.5264%2038.457%2035.5264H30.7605L38.5805%2027.2296C40.814%2027.1643%2042.6045%2025.3332%2042.6045%2023.084V12.4424C42.6045%2010.1518%2040.7476%208.29492%2038.457%208.29492H12.4424C10.1518%208.29492%208.29492%2010.1518%208.29492%2012.4424V23.084C8.29492%2025.3746%2010.1518%2027.2314%2012.4424%2027.2314H33.5078L20.4487%2041.0866C17.7992%2042.5379%2014.3381%2040.2741%2014.7842%2036.7803C14.8402%2036.3421%2014.9629%2035.9194%2015.1416%2035.5264H12.4424C10.9217%2035.5264%209.46472%2035.2536%208.11774%2034.7542L0.610679%2026.945C0.214298%2025.7295%200%2024.4318%200%2023.084V12.4424C0%2010.8011%200.317794%209.23402%200.895207%207.79935L7.12424%201.19058C8.73679%200.427072%2010.5397%200%2012.4424%200H38.457ZM23.1357%2017.7881C23.1357%2015.4815%2021.2656%2013.6113%2018.959%2013.6113C16.6525%2013.6114%2014.7822%2015.4815%2014.7822%2017.7881C14.7824%2020.0945%2016.6526%2021.9638%2018.959%2021.9639C21.2655%2021.9639%2023.1356%2020.0945%2023.1357%2017.7881ZM36.2344%2017.7881C36.2344%2015.4815%2034.3642%2013.6113%2032.0576%2013.6113C29.7511%2013.6114%2027.8809%2015.4815%2027.8809%2017.7881C27.881%2020.0945%2029.7512%2021.9638%2032.0576%2021.9639C34.3641%2021.9639%2036.2342%2020.0945%2036.2344%2017.7881Z%22%20fill%3D%22url(%23paint0_linear_97_4585)%22%2F%3E%3Cdefs%3E%3ClinearGradient%20id%3D%22paint0_linear_97_4585%22%20x1%3D%2231.662%22%20y1%3D%224.88016%22%20x2%3D%2214.4119%22%20y2%3D%2237.9167%22%20gradientUnits%3D%22userSpaceOnUse%22%3E%3Cstop%20stop-color%3D%22%23F22727%22%2F%3E%3Cstop%20offset%3D%221%22%20stop-color%3D%22%23CA0D0D%22%2F%3E%3C%2FlinearGradient%3E%3C%2Fdefs%3E%3C%2Fsvg%3E"
407
428
  };
408
- s([
429
+ r([
409
430
  d({ type: String, attribute: "return-uri" })
410
- ], o.prototype, "returnUri", 2);
411
- s([
431
+ ], s.prototype, "returnUri", 2);
432
+ r([
412
433
  d({ type: String, attribute: "question-prompt" })
413
- ], o.prototype, "questionPrompt", 2);
414
- s([
434
+ ], s.prototype, "questionPrompt", 2);
435
+ r([
415
436
  d({ type: Boolean, attribute: "minimized-icon-only" })
416
- ], o.prototype, "minimizedIconOnly", 2);
417
- s([
437
+ ], s.prototype, "minimizedIconOnly", 2);
438
+ r([
418
439
  d({ type: Boolean, attribute: "draggable" })
419
- ], o.prototype, "draggable", 2);
420
- s([
440
+ ], s.prototype, "draggable", 2);
441
+ r([
421
442
  d({ type: Boolean, attribute: "resizable" })
422
- ], o.prototype, "resizable", 2);
423
- s([
443
+ ], s.prototype, "resizable", 2);
444
+ r([
424
445
  d({
425
446
  type: Array,
426
447
  hasChanged: (t, e) => t === e ? !1 : !e || !t || t.length !== e.length ? !0 : JSON.stringify(t) !== JSON.stringify(e)
427
448
  }),
428
449
  d({ type: Array })
429
- ], o.prototype, "products", 2);
430
- s([
450
+ ], s.prototype, "products", 2);
451
+ r([
431
452
  d({ type: Boolean, attribute: "open-initially" })
432
- ], o.prototype, "openInitially", 2);
433
- s([
453
+ ], s.prototype, "openInitially", 2);
454
+ r([
434
455
  d({ type: Boolean, attribute: "show-feedback-buttons" })
435
- ], o.prototype, "showFeedbackButtons", 2);
436
- s([
437
- c()
438
- ], o.prototype, "open", 2);
439
- s([
440
- c()
441
- ], o.prototype, "fullscreen", 2);
442
- s([
443
- c()
444
- ], o.prototype, "messages", 2);
445
- s([
446
- c()
447
- ], o.prototype, "conversationId", 2);
448
- s([
449
- c()
450
- ], o.prototype, "assertionToken", 2);
451
- s([
452
- c()
453
- ], o.prototype, "isLoading", 2);
454
- s([
455
- c()
456
- ], o.prototype, "inputText", 2);
457
- s([
458
- c()
459
- ], o.prototype, "selectedProductId", 2);
460
- s([
461
- c()
462
- ], o.prototype, "windowWidth", 2);
463
- s([
464
- c()
465
- ], o.prototype, "windowHeight", 2);
466
- s([
467
- c()
468
- ], o.prototype, "position", 2);
469
- s([
470
- c()
471
- ], o.prototype, "isDragging", 2);
472
- s([
473
- c()
474
- ], o.prototype, "screenWidth", 2);
475
- s([
476
- b("#chat-container")
477
- ], o.prototype, "chatContainer", 2);
478
- s([
479
- b("#product")
480
- ], o.prototype, "productEl", 2);
481
- o = s([
482
- y("logosphere-chatbot")
483
- ], o);
456
+ ], s.prototype, "showFeedbackButtons", 2);
457
+ r([
458
+ l()
459
+ ], s.prototype, "open", 2);
460
+ r([
461
+ l()
462
+ ], s.prototype, "fullscreen", 2);
463
+ r([
464
+ l()
465
+ ], s.prototype, "messages", 2);
466
+ r([
467
+ l()
468
+ ], s.prototype, "conversationId", 2);
469
+ r([
470
+ l()
471
+ ], s.prototype, "assertionToken", 2);
472
+ r([
473
+ l()
474
+ ], s.prototype, "isLoading", 2);
475
+ r([
476
+ l()
477
+ ], s.prototype, "inputText", 2);
478
+ r([
479
+ l()
480
+ ], s.prototype, "selectedProductId", 2);
481
+ r([
482
+ l()
483
+ ], s.prototype, "windowWidth", 2);
484
+ r([
485
+ l()
486
+ ], s.prototype, "windowHeight", 2);
487
+ r([
488
+ l()
489
+ ], s.prototype, "position", 2);
490
+ r([
491
+ l()
492
+ ], s.prototype, "isDragging", 2);
493
+ r([
494
+ l()
495
+ ], s.prototype, "screenWidth", 2);
496
+ r([
497
+ y("#chat-container")
498
+ ], s.prototype, "chatContainer", 2);
499
+ r([
500
+ y("#product")
501
+ ], s.prototype, "productEl", 2);
502
+ s = r([
503
+ k("logosphere-chatbot")
504
+ ], s);
484
505
  export {
485
- o as L
506
+ s as L
486
507
  };
package/dist/chatbot.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./chatbot-CIk-82Bz.cjs");Object.defineProperty(exports,"LogosphereChatBot",{enumerable:!0,get:()=>e.LogosphereChatBot});
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./chatbot-B_3w7h4T.cjs");Object.defineProperty(exports,"LogosphereChatBot",{enumerable:!0,get:()=>e.LogosphereChatBot});
package/dist/chatbot.js CHANGED
@@ -1,4 +1,4 @@
1
- import { L as r } from "./chatbot-Dl-WLXP3.js";
1
+ import { L as r } from "./chatbot-uGYcx6Nn.js";
2
2
  export {
3
3
  r as LogosphereChatBot
4
4
  };
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./button-CDRccsk9.cjs"),t=require("./badge-7IIatiRv.cjs"),o=require("./checkbox-CdDTRdKV.cjs"),n=require("./formfield-BFOIEicR.cjs"),u=require("./switch-Rnnn10bn.cjs"),a=require("./breadcrumb-Cop-B1J7.cjs"),b=require("./card-KiNHfEi2.cjs"),c=require("./input-JpAWN-M1.cjs"),i=require("./popover-C2p5Pmts.cjs"),d=require("./text-area-CZDdxbrN.cjs"),p=require("./chatbot-CIk-82Bz.cjs"),g=require("./calendar-LMn1ZF3N.cjs"),l=require("./combobox-C6zoQopK.cjs"),m=require("./datepicker-CwDDA6np.cjs"),s=require("./drawer-BvcPd5nz.cjs"),f=require("./download-manager-BSIMTGaK.cjs"),e=require("./leftmenu-DBcncBN8.cjs"),P=require("./modal-DQ8VFL-P.cjs"),y=require("./tab-DcjAlXzU.cjs"),j=require("./tree-menu-B1iwfHyd.cjs");Object.defineProperty(exports,"Button",{enumerable:!0,get:()=>r.Button});Object.defineProperty(exports,"LogosphereBadge",{enumerable:!0,get:()=>t.LogosphereBadge});Object.defineProperty(exports,"Checkbox",{enumerable:!0,get:()=>o.Checkbox});Object.defineProperty(exports,"FormField",{enumerable:!0,get:()=>n.FormField});Object.defineProperty(exports,"Switch",{enumerable:!0,get:()=>u.Switch});Object.defineProperty(exports,"Breadcrumb",{enumerable:!0,get:()=>a.Breadcrumb});Object.defineProperty(exports,"Card",{enumerable:!0,get:()=>b.Card});Object.defineProperty(exports,"LogosphereInput",{enumerable:!0,get:()=>c.LogosphereInput});Object.defineProperty(exports,"Popover",{enumerable:!0,get:()=>i.Popover});Object.defineProperty(exports,"TextArea",{enumerable:!0,get:()=>d.TextArea});Object.defineProperty(exports,"LogosphereChatBot",{enumerable:!0,get:()=>p.LogosphereChatBot});Object.defineProperty(exports,"LogosphereCalendar",{enumerable:!0,get:()=>g.LogosphereCalendar});Object.defineProperty(exports,"Combobox",{enumerable:!0,get:()=>l.Combobox});Object.defineProperty(exports,"LogosphereDatePicker",{enumerable:!0,get:()=>m.LogosphereDatePicker});Object.defineProperty(exports,"Drawer",{enumerable:!0,get:()=>s.Drawer});Object.defineProperty(exports,"DownloadManager",{enumerable:!0,get:()=>f.DownloadManager});Object.defineProperty(exports,"LeftMenu",{enumerable:!0,get:()=>e.LeftMenu});Object.defineProperty(exports,"LeftMenuItemElement",{enumerable:!0,get:()=>e.LeftMenuItemElement});Object.defineProperty(exports,"Modal",{enumerable:!0,get:()=>P.Modal});Object.defineProperty(exports,"LogosphereTab",{enumerable:!0,get:()=>y.LogosphereTab});Object.defineProperty(exports,"TreeMenu",{enumerable:!0,get:()=>j.TreeMenu});
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./button-CDRccsk9.cjs"),t=require("./badge-7IIatiRv.cjs"),o=require("./checkbox-CdDTRdKV.cjs"),n=require("./formfield-BFOIEicR.cjs"),u=require("./switch-Rnnn10bn.cjs"),a=require("./breadcrumb-Cop-B1J7.cjs"),b=require("./card-KiNHfEi2.cjs"),c=require("./input-JpAWN-M1.cjs"),i=require("./popover-C2p5Pmts.cjs"),d=require("./text-area-CZDdxbrN.cjs"),p=require("./chatbot-B_3w7h4T.cjs"),g=require("./calendar-LMn1ZF3N.cjs"),l=require("./combobox-C6zoQopK.cjs"),m=require("./datepicker-CwDDA6np.cjs"),s=require("./drawer-BvcPd5nz.cjs"),f=require("./download-manager-BSIMTGaK.cjs"),e=require("./leftmenu-DBcncBN8.cjs"),P=require("./modal-DU1sszVn.cjs"),y=require("./tab-DcjAlXzU.cjs"),j=require("./tree-menu-B1iwfHyd.cjs");Object.defineProperty(exports,"Button",{enumerable:!0,get:()=>r.Button});Object.defineProperty(exports,"LogosphereBadge",{enumerable:!0,get:()=>t.LogosphereBadge});Object.defineProperty(exports,"Checkbox",{enumerable:!0,get:()=>o.Checkbox});Object.defineProperty(exports,"FormField",{enumerable:!0,get:()=>n.FormField});Object.defineProperty(exports,"Switch",{enumerable:!0,get:()=>u.Switch});Object.defineProperty(exports,"Breadcrumb",{enumerable:!0,get:()=>a.Breadcrumb});Object.defineProperty(exports,"Card",{enumerable:!0,get:()=>b.Card});Object.defineProperty(exports,"LogosphereInput",{enumerable:!0,get:()=>c.LogosphereInput});Object.defineProperty(exports,"Popover",{enumerable:!0,get:()=>i.Popover});Object.defineProperty(exports,"TextArea",{enumerable:!0,get:()=>d.TextArea});Object.defineProperty(exports,"LogosphereChatBot",{enumerable:!0,get:()=>p.LogosphereChatBot});Object.defineProperty(exports,"LogosphereCalendar",{enumerable:!0,get:()=>g.LogosphereCalendar});Object.defineProperty(exports,"Combobox",{enumerable:!0,get:()=>l.Combobox});Object.defineProperty(exports,"LogosphereDatePicker",{enumerable:!0,get:()=>m.LogosphereDatePicker});Object.defineProperty(exports,"Drawer",{enumerable:!0,get:()=>s.Drawer});Object.defineProperty(exports,"DownloadManager",{enumerable:!0,get:()=>f.DownloadManager});Object.defineProperty(exports,"LeftMenu",{enumerable:!0,get:()=>e.LeftMenu});Object.defineProperty(exports,"LeftMenuItemElement",{enumerable:!0,get:()=>e.LeftMenuItemElement});Object.defineProperty(exports,"Modal",{enumerable:!0,get:()=>P.Modal});Object.defineProperty(exports,"LogosphereTab",{enumerable:!0,get:()=>y.LogosphereTab});Object.defineProperty(exports,"TreeMenu",{enumerable:!0,get:()=>j.TreeMenu});
package/dist/index.js CHANGED
@@ -8,14 +8,14 @@ import { C } from "./card-CNoTUaJC.js";
8
8
  import { L as u } from "./input-jmbvgWEq.js";
9
9
  import { P as M } from "./popover-CaVOXo_k.js";
10
10
  import { T as l } from "./text-area-Dec_k4rs.js";
11
- import { L as T } from "./chatbot-Dl-WLXP3.js";
11
+ import { L as T } from "./chatbot-uGYcx6Nn.js";
12
12
  import { L as i } from "./calendar-WZ_GQvnn.js";
13
13
  import { C as F } from "./combobox-LBU6VHLi.js";
14
14
  import { L as k } from "./datepicker-SwKsdw3S.js";
15
15
  import { D as S } from "./drawer-DVINJB4a.js";
16
16
  import { D as A } from "./download-manager-a541AYhr.js";
17
17
  import { L as j, a as q } from "./leftmenu-C-q1h_2U.js";
18
- import { M as z } from "./modal-CnwRIdd8.js";
18
+ import { M as z } from "./modal-B8aQyCBg.js";
19
19
  import { L as H } from "./tab-BYU_XEhp.js";
20
20
  import { T as K } from "./tree-menu-BbX8GK_z.js";
21
21
  export {