@kodaris/krubble-app-components 1.0.62 → 1.0.63
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chatbot.d.ts +158 -0
- package/dist/chatbot.d.ts.map +1 -0
- package/dist/chatbot.js +1320 -0
- package/dist/chatbot.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/krubble-app.bundled.js +1378 -50
- package/dist/krubble-app.bundled.js.map +1 -1
- package/dist/krubble-app.bundled.min.js +790 -71
- package/dist/krubble-app.bundled.min.js.map +1 -1
- package/dist/krubble-app.umd.js +1377 -49
- package/dist/krubble-app.umd.js.map +1 -1
- package/dist/krubble-app.umd.min.js +790 -71
- package/dist/krubble-app.umd.min.js.map +1 -1
- package/package.json +5 -1
package/dist/krubble-app.umd.js
CHANGED
|
@@ -9,20 +9,20 @@
|
|
|
9
9
|
* Copyright 2019 Google LLC
|
|
10
10
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
11
11
|
*/
|
|
12
|
-
const t$3=globalThis,e$
|
|
12
|
+
const t$3=globalThis,e$7=t$3.ShadowRoot&&(void 0===t$3.ShadyCSS||t$3.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,s$2=Symbol(),o$5=new WeakMap;let n$3 = class n{constructor(t,e,o){if(this._$cssResult$=true,o!==s$2)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e;}get styleSheet(){let t=this.o;const s=this.t;if(e$7&&void 0===t){const e=void 0!==s&&1===s.length;e&&(t=o$5.get(s)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),e&&o$5.set(s,t));}return t}toString(){return this.cssText}};const r$4=t=>new n$3("string"==typeof t?t:t+"",void 0,s$2),i$4=(t,...e)=>{const o=1===t.length?t[0]:e.reduce((e,s,o)=>e+(t=>{if(true===t._$cssResult$)return t.cssText;if("number"==typeof t)return t;throw Error("Value passed to 'css' function must be a 'css' function result: "+t+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(s)+t[o+1],t[0]);return new n$3(o,t,s$2)},S$1=(s,o)=>{if(e$7)s.adoptedStyleSheets=o.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet);else for(const e of o){const o=document.createElement("style"),n=t$3.litNonce;void 0!==n&&o.setAttribute("nonce",n),o.textContent=e.cssText,s.appendChild(o);}},c$2=e$7?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const s of t.cssRules)e+=s.cssText;return r$4(e)})(t):t;
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* @license
|
|
16
16
|
* Copyright 2017 Google LLC
|
|
17
17
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
18
|
-
*/const{is:i$3,defineProperty:e$
|
|
18
|
+
*/const{is:i$3,defineProperty:e$6,getOwnPropertyDescriptor:h$1,getOwnPropertyNames:r$3,getOwnPropertySymbols:o$4,getPrototypeOf:n$2}=Object,a$1=globalThis,c$1=a$1.trustedTypes,l$1=c$1?c$1.emptyScript:"",p$1=a$1.reactiveElementPolyfillSupport,d$1=(t,s)=>t,u$1={toAttribute(t,s){switch(s){case Boolean:t=t?l$1:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t);}return t},fromAttribute(t,s){let i=t;switch(s){case Boolean:i=null!==t;break;case Number:i=null===t?null:Number(t);break;case Object:case Array:try{i=JSON.parse(t);}catch(t){i=null;}}return i}},f$1=(t,s)=>!i$3(t,s),b$1={attribute:true,type:String,converter:u$1,reflect:false,useDefault:false,hasChanged:f$1};Symbol.metadata??=Symbol("metadata"),a$1.litPropertyMetadata??=new WeakMap;let y$1 = class y extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??=[]).push(t);}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,s=b$1){if(s.state&&(s.attribute=false),this._$Ei(),this.prototype.hasOwnProperty(t)&&((s=Object.create(s)).wrapped=true),this.elementProperties.set(t,s),!s.noAccessor){const i=Symbol(),h=this.getPropertyDescriptor(t,i,s);void 0!==h&&e$6(this.prototype,t,h);}}static getPropertyDescriptor(t,s,i){const{get:e,set:r}=h$1(this.prototype,t)??{get(){return this[s]},set(t){this[s]=t;}};return {get:e,set(s){const h=e?.call(this);r?.call(this,s),this.requestUpdate(t,h,i);},configurable:true,enumerable:true}}static getPropertyOptions(t){return this.elementProperties.get(t)??b$1}static _$Ei(){if(this.hasOwnProperty(d$1("elementProperties")))return;const t=n$2(this);t.finalize(),void 0!==t.l&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties);}static finalize(){if(this.hasOwnProperty(d$1("finalized")))return;if(this.finalized=true,this._$Ei(),this.hasOwnProperty(d$1("properties"))){const t=this.properties,s=[...r$3(t),...o$4(t)];for(const i of s)this.createProperty(i,t[i]);}const t=this[Symbol.metadata];if(null!==t){const s=litPropertyMetadata.get(t);if(void 0!==s)for(const[t,i]of s)this.elementProperties.set(t,i);}this._$Eh=new Map;for(const[t,s]of this.elementProperties){const i=this._$Eu(t,s);void 0!==i&&this._$Eh.set(i,t);}this.elementStyles=this.finalizeStyles(this.styles);}static finalizeStyles(s){const i=[];if(Array.isArray(s)){const e=new Set(s.flat(1/0).reverse());for(const s of e)i.unshift(c$2(s));}else void 0!==s&&i.push(c$2(s));return i}static _$Eu(t,s){const i=s.attribute;return false===i?void 0:"string"==typeof i?i:"string"==typeof t?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=false,this.hasUpdated=false,this._$Em=null,this._$Ev();}_$Ev(){this._$ES=new Promise(t=>this.enableUpdating=t),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(t=>t(this));}addController(t){(this._$EO??=new Set).add(t),void 0!==this.renderRoot&&this.isConnected&&t.hostConnected?.();}removeController(t){this._$EO?.delete(t);}_$E_(){const t=new Map,s=this.constructor.elementProperties;for(const i of s.keys())this.hasOwnProperty(i)&&(t.set(i,this[i]),delete this[i]);t.size>0&&(this._$Ep=t);}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return S$1(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(true),this._$EO?.forEach(t=>t.hostConnected?.());}enableUpdating(t){}disconnectedCallback(){this._$EO?.forEach(t=>t.hostDisconnected?.());}attributeChangedCallback(t,s,i){this._$AK(t,i);}_$ET(t,s){const i=this.constructor.elementProperties.get(t),e=this.constructor._$Eu(t,i);if(void 0!==e&&true===i.reflect){const h=(void 0!==i.converter?.toAttribute?i.converter:u$1).toAttribute(s,i.type);this._$Em=t,null==h?this.removeAttribute(e):this.setAttribute(e,h),this._$Em=null;}}_$AK(t,s){const i=this.constructor,e=i._$Eh.get(t);if(void 0!==e&&this._$Em!==e){const t=i.getPropertyOptions(e),h="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==t.converter?.fromAttribute?t.converter:u$1;this._$Em=e;const r=h.fromAttribute(s,t.type);this[e]=r??this._$Ej?.get(e)??r,this._$Em=null;}}requestUpdate(t,s,i,e=false,h){if(void 0!==t){const r=this.constructor;if(false===e&&(h=this[t]),i??=r.getPropertyOptions(t),!((i.hasChanged??f$1)(h,s)||i.useDefault&&i.reflect&&h===this._$Ej?.get(t)&&!this.hasAttribute(r._$Eu(t,i))))return;this.C(t,s,i);} false===this.isUpdatePending&&(this._$ES=this._$EP());}C(t,s,{useDefault:i,reflect:e,wrapped:h},r){i&&!(this._$Ej??=new Map).has(t)&&(this._$Ej.set(t,r??s??this[t]),true!==h||void 0!==r)||(this._$AL.has(t)||(this.hasUpdated||i||(s=void 0),this._$AL.set(t,s)),true===e&&this._$Em!==t&&(this._$Eq??=new Set).add(t));}async _$EP(){this.isUpdatePending=true;try{await this._$ES;}catch(t){Promise.reject(t);}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[t,s]of this._$Ep)this[t]=s;this._$Ep=void 0;}const t=this.constructor.elementProperties;if(t.size>0)for(const[s,i]of t){const{wrapped:t}=i,e=this[s];true!==t||this._$AL.has(s)||void 0===e||this.C(s,void 0,i,e);}}let t=false;const s=this._$AL;try{t=this.shouldUpdate(s),t?(this.willUpdate(s),this._$EO?.forEach(t=>t.hostUpdate?.()),this.update(s)):this._$EM();}catch(s){throw t=false,this._$EM(),s}t&&this._$AE(s);}willUpdate(t){}_$AE(t){this._$EO?.forEach(t=>t.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=true,this.firstUpdated(t)),this.updated(t);}_$EM(){this._$AL=new Map,this.isUpdatePending=false;}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return true}update(t){this._$Eq&&=this._$Eq.forEach(t=>this._$ET(t,this[t])),this._$EM();}updated(t){}firstUpdated(t){}};y$1.elementStyles=[],y$1.shadowRootOptions={mode:"open"},y$1[d$1("elementProperties")]=new Map,y$1[d$1("finalized")]=new Map,p$1?.({ReactiveElement:y$1}),(a$1.reactiveElementVersions??=[]).push("2.1.2");
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
21
|
* @license
|
|
22
22
|
* Copyright 2017 Google LLC
|
|
23
23
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
24
24
|
*/
|
|
25
|
-
const t$2=globalThis,i$2=t=>t,s$1=t$2.trustedTypes,e$
|
|
25
|
+
const t$2=globalThis,i$2=t=>t,s$1=t$2.trustedTypes,e$5=s$1?s$1.createPolicy("lit-html",{createHTML:t=>t}):void 0,h="$lit$",o$3=`lit$${Math.random().toFixed(9).slice(2)}$`,n$1="?"+o$3,r$2=`<${n$1}>`,l=document,c=()=>l.createComment(""),a=t=>null===t||"object"!=typeof t&&"function"!=typeof t,u=Array.isArray,d=t=>u(t)||"function"==typeof t?.[Symbol.iterator],f="[ \t\n\f\r]",v=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,_=/-->/g,m=/>/g,p=RegExp(`>|${f}(?:([^\\s"'>=/]+)(${f}*=${f}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),g=/'/g,$=/"/g,y=/^(?:script|style|textarea|title)$/i,x=t=>(i,...s)=>({_$litType$:t,strings:i,values:s}),b=x(1),E=Symbol.for("lit-noChange"),A=Symbol.for("lit-nothing"),C=new WeakMap,P=l.createTreeWalker(l,129);function V(t,i){if(!u(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==e$5?e$5.createHTML(i):i}const N=(t,i)=>{const s=t.length-1,e=[];let n,l=2===i?"<svg>":3===i?"<math>":"",c=v;for(let i=0;i<s;i++){const s=t[i];let a,u,d=-1,f=0;for(;f<s.length&&(c.lastIndex=f,u=c.exec(s),null!==u);)f=c.lastIndex,c===v?"!--"===u[1]?c=_:void 0!==u[1]?c=m:void 0!==u[2]?(y.test(u[2])&&(n=RegExp("</"+u[2],"g")),c=p):void 0!==u[3]&&(c=p):c===p?">"===u[0]?(c=n??v,d=-1):void 0===u[1]?d=-2:(d=c.lastIndex-u[2].length,a=u[1],c=void 0===u[3]?p:'"'===u[3]?$:g):c===$||c===g?c=p:c===_||c===m?c=v:(c=p,n=void 0);const x=c===p&&t[i+1].startsWith("/>")?" ":"";l+=c===v?s+r$2:d>=0?(e.push(a),s.slice(0,d)+h+s.slice(d)+o$3+x):s+o$3+(-2===d?i:x);}return [V(t,l+(t[s]||"<?>")+(2===i?"</svg>":3===i?"</math>":"")),e]};class S{constructor({strings:t,_$litType$:i},e){let r;this.parts=[];let l=0,a=0;const u=t.length-1,d=this.parts,[f,v]=N(t,i);if(this.el=S.createElement(f,e),P.currentNode=this.el.content,2===i||3===i){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes);}for(;null!==(r=P.nextNode())&&d.length<u;){if(1===r.nodeType){if(r.hasAttributes())for(const t of r.getAttributeNames())if(t.endsWith(h)){const i=v[a++],s=r.getAttribute(t).split(o$3),e=/([.?@])?(.*)/.exec(i);d.push({type:1,index:l,name:e[2],strings:s,ctor:"."===e[1]?I:"?"===e[1]?L:"@"===e[1]?z:H}),r.removeAttribute(t);}else t.startsWith(o$3)&&(d.push({type:6,index:l}),r.removeAttribute(t));if(y.test(r.tagName)){const t=r.textContent.split(o$3),i=t.length-1;if(i>0){r.textContent=s$1?s$1.emptyScript:"";for(let s=0;s<i;s++)r.append(t[s],c()),P.nextNode(),d.push({type:2,index:++l});r.append(t[i],c());}}}else if(8===r.nodeType)if(r.data===n$1)d.push({type:2,index:l});else {let t=-1;for(;-1!==(t=r.data.indexOf(o$3,t+1));)d.push({type:7,index:l}),t+=o$3.length-1;}l++;}}static createElement(t,i){const s=l.createElement("template");return s.innerHTML=t,s}}function M(t,i,s=t,e){if(i===E)return i;let h=void 0!==e?s._$Co?.[e]:s._$Cl;const o=a(i)?void 0:i._$litDirective$;return h?.constructor!==o&&(h?._$AO?.(false),void 0===o?h=void 0:(h=new o(t),h._$AT(t,s,e)),void 0!==e?(s._$Co??=[])[e]=h:s._$Cl=h),void 0!==h&&(i=M(t,h._$AS(t,i.values),h,e)),i}class R{constructor(t,i){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=i;}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:i},parts:s}=this._$AD,e=(t?.creationScope??l).importNode(i,true);P.currentNode=e;let h=P.nextNode(),o=0,n=0,r=s[0];for(;void 0!==r;){if(o===r.index){let i;2===r.type?i=new k(h,h.nextSibling,this,t):1===r.type?i=new r.ctor(h,r.name,r.strings,this,t):6===r.type&&(i=new Z(h,this,t)),this._$AV.push(i),r=s[++n];}o!==r?.index&&(h=P.nextNode(),o++);}return P.currentNode=l,e}p(t){let i=0;for(const s of this._$AV) void 0!==s&&(void 0!==s.strings?(s._$AI(t,s,i),i+=s.strings.length-2):s._$AI(t[i])),i++;}}class k{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,i,s,e){this.type=2,this._$AH=A,this._$AN=void 0,this._$AA=t,this._$AB=i,this._$AM=s,this.options=e,this._$Cv=e?.isConnected??true;}get parentNode(){let t=this._$AA.parentNode;const i=this._$AM;return void 0!==i&&11===t?.nodeType&&(t=i.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,i=this){t=M(this,t,i),a(t)?t===A||null==t||""===t?(this._$AH!==A&&this._$AR(),this._$AH=A):t!==this._$AH&&t!==E&&this._(t):void 0!==t._$litType$?this.$(t):void 0!==t.nodeType?this.T(t):d(t)?this.k(t):this._(t);}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t));}_(t){this._$AH!==A&&a(this._$AH)?this._$AA.nextSibling.data=t:this.T(l.createTextNode(t)),this._$AH=t;}$(t){const{values:i,_$litType$:s}=t,e="number"==typeof s?this._$AC(t):(void 0===s.el&&(s.el=S.createElement(V(s.h,s.h[0]),this.options)),s);if(this._$AH?._$AD===e)this._$AH.p(i);else {const t=new R(e,this),s=t.u(this.options);t.p(i),this.T(s),this._$AH=t;}}_$AC(t){let i=C.get(t.strings);return void 0===i&&C.set(t.strings,i=new S(t)),i}k(t){u(this._$AH)||(this._$AH=[],this._$AR());const i=this._$AH;let s,e=0;for(const h of t)e===i.length?i.push(s=new k(this.O(c()),this.O(c()),this,this.options)):s=i[e],s._$AI(h),e++;e<i.length&&(this._$AR(s&&s._$AB.nextSibling,e),i.length=e);}_$AR(t=this._$AA.nextSibling,s){for(this._$AP?.(false,true,s);t!==this._$AB;){const s=i$2(t).nextSibling;i$2(t).remove(),t=s;}}setConnected(t){ void 0===this._$AM&&(this._$Cv=t,this._$AP?.(t));}}class H{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,i,s,e,h){this.type=1,this._$AH=A,this._$AN=void 0,this.element=t,this.name=i,this._$AM=e,this.options=h,s.length>2||""!==s[0]||""!==s[1]?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=A;}_$AI(t,i=this,s,e){const h=this.strings;let o=false;if(void 0===h)t=M(this,t,i,0),o=!a(t)||t!==this._$AH&&t!==E,o&&(this._$AH=t);else {const e=t;let n,r;for(t=h[0],n=0;n<h.length-1;n++)r=M(this,e[s+n],i,n),r===E&&(r=this._$AH[n]),o||=!a(r)||r!==this._$AH[n],r===A?t=A:t!==A&&(t+=(r??"")+h[n+1]),this._$AH[n]=r;}o&&!e&&this.j(t);}j(t){t===A?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"");}}class I extends H{constructor(){super(...arguments),this.type=3;}j(t){this.element[this.name]=t===A?void 0:t;}}class L extends H{constructor(){super(...arguments),this.type=4;}j(t){this.element.toggleAttribute(this.name,!!t&&t!==A);}}class z extends H{constructor(t,i,s,e,h){super(t,i,s,e,h),this.type=5;}_$AI(t,i=this){if((t=M(this,t,i,0)??A)===E)return;const s=this._$AH,e=t===A&&s!==A||t.capture!==s.capture||t.once!==s.once||t.passive!==s.passive,h=t!==A&&(s===A||e);e&&this.element.removeEventListener(this.name,this,s),h&&this.element.addEventListener(this.name,this,t),this._$AH=t;}handleEvent(t){"function"==typeof this._$AH?this._$AH.call(this.options?.host??this.element,t):this._$AH.handleEvent(t);}}class Z{constructor(t,i,s){this.element=t,this.type=6,this._$AN=void 0,this._$AM=i,this.options=s;}get _$AU(){return this._$AM._$AU}_$AI(t){M(this,t);}}const B=t$2.litHtmlPolyfillSupport;B?.(S,k),(t$2.litHtmlVersions??=[]).push("3.3.2");const D=(t,i,s)=>{const e=s?.renderBefore??i;let h=e._$litPart$;if(void 0===h){const t=s?.renderBefore??null;e._$litPart$=h=new k(i.insertBefore(c(),t),t,void 0,s??{});}return h._$AI(t),h};
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
28
|
* @license
|
|
@@ -49,6 +49,19 @@
|
|
|
49
49
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
50
50
|
*/function r(r){return n({...r,state:true,attribute:false})}
|
|
51
51
|
|
|
52
|
+
/**
|
|
53
|
+
* @license
|
|
54
|
+
* Copyright 2017 Google LLC
|
|
55
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
56
|
+
*/
|
|
57
|
+
const e$4=(e,t,c)=>(c.configurable=true,c.enumerable=true,Reflect.decorate&&"object"!=typeof t&&Object.defineProperty(e,t,c),c);
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* @license
|
|
61
|
+
* Copyright 2017 Google LLC
|
|
62
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
63
|
+
*/function e$3(e,r){return (n,s,i)=>{const o=t=>t.renderRoot?.querySelector(e)??null;return e$4(n,s,{get(){return o(this)}})}}
|
|
64
|
+
|
|
52
65
|
/**
|
|
53
66
|
* @license
|
|
54
67
|
* Copyright 2017 Google LLC
|
|
@@ -68,7 +81,7 @@
|
|
|
68
81
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
69
82
|
*/const e=e$2(class extends i{constructor(t$1){if(super(t$1),t$1.type!==t.ATTRIBUTE||"class"!==t$1.name||t$1.strings?.length>2)throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.")}render(t){return " "+Object.keys(t).filter(s=>t[s]).join(" ")+" "}update(s,[i]){if(void 0===this.st){this.st=new Set,void 0!==s.strings&&(this.nt=new Set(s.strings.join(" ").split(/\s/).filter(t=>""!==t)));for(const t in i)i[t]&&!this.nt?.has(t)&&this.st.add(t);return this.render(i)}const r=s.element.classList;for(const t of this.st)t in i||(r.remove(t),this.st.delete(t));for(const t in i){const s=!!i[t];s===this.st.has(t)||this.nt?.has(t)||(s?(r.add(t),this.st.add(t)):(r.remove(t),this.st.delete(t)));}return E}});
|
|
70
83
|
|
|
71
|
-
var __decorate$
|
|
84
|
+
var __decorate$6 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
72
85
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
73
86
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
74
87
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
@@ -264,23 +277,23 @@
|
|
|
264
277
|
background: #d4f472;
|
|
265
278
|
}
|
|
266
279
|
`;
|
|
267
|
-
__decorate$
|
|
280
|
+
__decorate$6([
|
|
268
281
|
r()
|
|
269
282
|
], KRNavItemEdit.prototype, "label", void 0);
|
|
270
|
-
__decorate$
|
|
283
|
+
__decorate$6([
|
|
271
284
|
r()
|
|
272
285
|
], KRNavItemEdit.prototype, "icon", void 0);
|
|
273
|
-
__decorate$
|
|
286
|
+
__decorate$6([
|
|
274
287
|
r()
|
|
275
288
|
], KRNavItemEdit.prototype, "url", void 0);
|
|
276
|
-
__decorate$
|
|
289
|
+
__decorate$6([
|
|
277
290
|
r()
|
|
278
291
|
], KRNavItemEdit.prototype, "active", void 0);
|
|
279
|
-
KRNavItemEdit = __decorate$
|
|
292
|
+
KRNavItemEdit = __decorate$6([
|
|
280
293
|
t$1('kr-nav-item-edit')
|
|
281
294
|
], KRNavItemEdit);
|
|
282
295
|
|
|
283
|
-
var __decorate$
|
|
296
|
+
var __decorate$5 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
284
297
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
285
298
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
286
299
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
@@ -2131,80 +2144,80 @@
|
|
|
2131
2144
|
}
|
|
2132
2145
|
}
|
|
2133
2146
|
`;
|
|
2134
|
-
__decorate$
|
|
2147
|
+
__decorate$5([
|
|
2135
2148
|
r()
|
|
2136
2149
|
], exports.Scaffold.prototype, "navItemsExpanded", void 0);
|
|
2137
|
-
__decorate$
|
|
2150
|
+
__decorate$5([
|
|
2138
2151
|
r()
|
|
2139
2152
|
], exports.Scaffold.prototype, "navQuery", void 0);
|
|
2140
|
-
__decorate$
|
|
2153
|
+
__decorate$5([
|
|
2141
2154
|
r()
|
|
2142
2155
|
], exports.Scaffold.prototype, "activeNavItemId", void 0);
|
|
2143
|
-
__decorate$
|
|
2156
|
+
__decorate$5([
|
|
2144
2157
|
r()
|
|
2145
2158
|
], exports.Scaffold.prototype, "isNavScrolled", void 0);
|
|
2146
|
-
__decorate$
|
|
2159
|
+
__decorate$5([
|
|
2147
2160
|
r()
|
|
2148
2161
|
], exports.Scaffold.prototype, "isNavOpened", void 0);
|
|
2149
|
-
__decorate$
|
|
2162
|
+
__decorate$5([
|
|
2150
2163
|
r()
|
|
2151
2164
|
], exports.Scaffold.prototype, "isEditing", void 0);
|
|
2152
|
-
__decorate$
|
|
2165
|
+
__decorate$5([
|
|
2153
2166
|
r()
|
|
2154
2167
|
], exports.Scaffold.prototype, "isUserMenuOpen", void 0);
|
|
2155
|
-
__decorate$
|
|
2168
|
+
__decorate$5([
|
|
2156
2169
|
r()
|
|
2157
2170
|
], exports.Scaffold.prototype, "pref", void 0);
|
|
2158
|
-
__decorate$
|
|
2171
|
+
__decorate$5([
|
|
2159
2172
|
r()
|
|
2160
2173
|
], exports.Scaffold.prototype, "draggedNavItemId", void 0);
|
|
2161
|
-
__decorate$
|
|
2174
|
+
__decorate$5([
|
|
2162
2175
|
r()
|
|
2163
2176
|
], exports.Scaffold.prototype, "navItemDropTargetId", void 0);
|
|
2164
|
-
__decorate$
|
|
2177
|
+
__decorate$5([
|
|
2165
2178
|
r()
|
|
2166
2179
|
], exports.Scaffold.prototype, "navItemDropPosition", void 0);
|
|
2167
|
-
__decorate$
|
|
2180
|
+
__decorate$5([
|
|
2168
2181
|
r()
|
|
2169
2182
|
], exports.Scaffold.prototype, "pendingRequests", void 0);
|
|
2170
|
-
__decorate$
|
|
2183
|
+
__decorate$5([
|
|
2171
2184
|
n({ type: String })
|
|
2172
2185
|
], exports.Scaffold.prototype, "logo", void 0);
|
|
2173
|
-
__decorate$
|
|
2186
|
+
__decorate$5([
|
|
2174
2187
|
n({ type: String })
|
|
2175
2188
|
], exports.Scaffold.prototype, "label", void 0);
|
|
2176
|
-
__decorate$
|
|
2189
|
+
__decorate$5([
|
|
2177
2190
|
n({ type: String, attribute: 'home-url' })
|
|
2178
2191
|
], exports.Scaffold.prototype, "homeUrl", void 0);
|
|
2179
|
-
__decorate$
|
|
2192
|
+
__decorate$5([
|
|
2180
2193
|
n({ type: String, reflect: true })
|
|
2181
2194
|
], exports.Scaffold.prototype, "scheme", void 0);
|
|
2182
|
-
__decorate$
|
|
2195
|
+
__decorate$5([
|
|
2183
2196
|
n({ type: Array })
|
|
2184
2197
|
], exports.Scaffold.prototype, "nav", void 0);
|
|
2185
|
-
__decorate$
|
|
2198
|
+
__decorate$5([
|
|
2186
2199
|
n({ type: Boolean, attribute: 'nav-icons-displayed', reflect: true })
|
|
2187
2200
|
], exports.Scaffold.prototype, "navIconsDisplayed", void 0);
|
|
2188
|
-
__decorate$
|
|
2201
|
+
__decorate$5([
|
|
2189
2202
|
n({ type: Boolean, attribute: 'nav-expanded' })
|
|
2190
2203
|
], exports.Scaffold.prototype, "navExpanded", void 0);
|
|
2191
|
-
__decorate$
|
|
2204
|
+
__decorate$5([
|
|
2192
2205
|
n({ type: Object })
|
|
2193
2206
|
], exports.Scaffold.prototype, "user", void 0);
|
|
2194
|
-
__decorate$
|
|
2207
|
+
__decorate$5([
|
|
2195
2208
|
n({ type: Boolean })
|
|
2196
2209
|
], exports.Scaffold.prototype, "subbar", void 0);
|
|
2197
|
-
__decorate$
|
|
2210
|
+
__decorate$5([
|
|
2198
2211
|
n({ type: Boolean, attribute: 'nav-enabled' })
|
|
2199
2212
|
], exports.Scaffold.prototype, "navEnabled", void 0);
|
|
2200
|
-
__decorate$
|
|
2213
|
+
__decorate$5([
|
|
2201
2214
|
n({ type: Array })
|
|
2202
2215
|
], exports.Scaffold.prototype, "breadcrumbs", void 0);
|
|
2203
|
-
exports.Scaffold = __decorate$
|
|
2216
|
+
exports.Scaffold = __decorate$5([
|
|
2204
2217
|
t$1('kr-scaffold')
|
|
2205
2218
|
], exports.Scaffold);
|
|
2206
2219
|
|
|
2207
|
-
var __decorate$
|
|
2220
|
+
var __decorate$4 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
2208
2221
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2209
2222
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
2210
2223
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
@@ -2443,23 +2456,23 @@
|
|
|
2443
2456
|
overflow-y: auto;
|
|
2444
2457
|
}
|
|
2445
2458
|
`;
|
|
2446
|
-
__decorate$
|
|
2459
|
+
__decorate$4([
|
|
2447
2460
|
n({ type: String })
|
|
2448
2461
|
], exports.ScreenNav.prototype, "label", void 0);
|
|
2449
|
-
__decorate$
|
|
2462
|
+
__decorate$4([
|
|
2450
2463
|
n({ type: String })
|
|
2451
2464
|
], exports.ScreenNav.prototype, "subLabel", void 0);
|
|
2452
|
-
__decorate$
|
|
2465
|
+
__decorate$4([
|
|
2453
2466
|
n({ type: Array })
|
|
2454
2467
|
], exports.ScreenNav.prototype, "navItems", void 0);
|
|
2455
|
-
__decorate$
|
|
2468
|
+
__decorate$4([
|
|
2456
2469
|
n({ type: String })
|
|
2457
2470
|
], exports.ScreenNav.prototype, "activeId", void 0);
|
|
2458
|
-
exports.ScreenNav = __decorate$
|
|
2471
|
+
exports.ScreenNav = __decorate$4([
|
|
2459
2472
|
t$1('kr-screen-nav')
|
|
2460
2473
|
], exports.ScreenNav);
|
|
2461
2474
|
|
|
2462
|
-
var __decorate$
|
|
2475
|
+
var __decorate$3 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
2463
2476
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2464
2477
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
2465
2478
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
@@ -2553,14 +2566,14 @@
|
|
|
2553
2566
|
max-width: 700px;
|
|
2554
2567
|
}
|
|
2555
2568
|
`;
|
|
2556
|
-
__decorate$
|
|
2569
|
+
__decorate$3([
|
|
2557
2570
|
n({ type: String })
|
|
2558
2571
|
], exports.ScreenDetail.prototype, "title", void 0);
|
|
2559
|
-
exports.ScreenDetail = __decorate$
|
|
2572
|
+
exports.ScreenDetail = __decorate$3([
|
|
2560
2573
|
t$1('kr-screen-detail')
|
|
2561
2574
|
], exports.ScreenDetail);
|
|
2562
2575
|
|
|
2563
|
-
var __decorate$
|
|
2576
|
+
var __decorate$2 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
2564
2577
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2565
2578
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
2566
2579
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
@@ -2733,17 +2746,17 @@
|
|
|
2733
2746
|
height: 18px;
|
|
2734
2747
|
}
|
|
2735
2748
|
`;
|
|
2736
|
-
__decorate$
|
|
2749
|
+
__decorate$2([
|
|
2737
2750
|
n({ type: Array })
|
|
2738
2751
|
], exports.Subbar.prototype, "breadcrumbs", void 0);
|
|
2739
|
-
__decorate$
|
|
2752
|
+
__decorate$2([
|
|
2740
2753
|
n({ type: Boolean })
|
|
2741
2754
|
], exports.Subbar.prototype, "menu", void 0);
|
|
2742
|
-
exports.Subbar = __decorate$
|
|
2755
|
+
exports.Subbar = __decorate$2([
|
|
2743
2756
|
t$1('kr-subbar')
|
|
2744
2757
|
], exports.Subbar);
|
|
2745
2758
|
|
|
2746
|
-
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
2759
|
+
var __decorate$1 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
2747
2760
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2748
2761
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
2749
2762
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
@@ -2924,10 +2937,1325 @@
|
|
|
2924
2937
|
height: 100%;
|
|
2925
2938
|
}
|
|
2926
2939
|
`;
|
|
2927
|
-
exports.RouterOutlet = __decorate([
|
|
2940
|
+
exports.RouterOutlet = __decorate$1([
|
|
2928
2941
|
t$1('kr-router-outlet')
|
|
2929
2942
|
], exports.RouterOutlet);
|
|
2930
2943
|
|
|
2944
|
+
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
2945
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2946
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
2947
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2948
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2949
|
+
};
|
|
2950
|
+
/**
|
|
2951
|
+
* AI chatbot component with SSE streaming and native browser action execution.
|
|
2952
|
+
*
|
|
2953
|
+
* Accepts a `send` callback that returns a streaming Response (SSE format).
|
|
2954
|
+
* Parses the stream for text tokens, status updates, errors, and frontend actions.
|
|
2955
|
+
* When an ACTION event arrives, dispatches a cancelable `action` custom event.
|
|
2956
|
+
* If not prevented, executes the native browser action (reload, navigate, etc.).
|
|
2957
|
+
*
|
|
2958
|
+
* ## SSE Stream Format
|
|
2959
|
+
* The component expects `data:` lines with JSON payloads containing a `type` field:
|
|
2960
|
+
* - `STATUS` — `{ type: "STATUS", message: "Thinking..." }`
|
|
2961
|
+
* - `RESPONSE_PART` — `{ type: "RESPONSE_PART", message: "token text" }`
|
|
2962
|
+
* - `ACTION` — `{ type: "ACTION", action: "RELOAD" }` (see KRChatbotAction)
|
|
2963
|
+
* - `ERROR` — `{ type: "ERROR", message: "Something went wrong" }`
|
|
2964
|
+
* - `HEARTBEAT` — `{ type: "HEARTBEAT" }` (ignored)
|
|
2965
|
+
*
|
|
2966
|
+
* The final event should include `finished: true` to signal stream completion.
|
|
2967
|
+
*
|
|
2968
|
+
* ## Usage
|
|
2969
|
+
* ```html
|
|
2970
|
+
* <kr-chatbot
|
|
2971
|
+
* title="AI Assistant"
|
|
2972
|
+
* .send=${(params) => {
|
|
2973
|
+
* return fetch('/api/ai/chat/stream', {
|
|
2974
|
+
* method: 'POST',
|
|
2975
|
+
* headers: { 'Content-Type': 'application/json', 'Accept': 'text/event-stream' },
|
|
2976
|
+
* credentials: 'include',
|
|
2977
|
+
* body: JSON.stringify({ userText: params.message })
|
|
2978
|
+
* });
|
|
2979
|
+
* }}
|
|
2980
|
+
* ></kr-chatbot>
|
|
2981
|
+
* ```
|
|
2982
|
+
*
|
|
2983
|
+
* @slot - Optional slot content displayed above the messages area
|
|
2984
|
+
*
|
|
2985
|
+
* @fires message-submit - When the user sends a message. Cancelable. Detail: `{ message: string }`
|
|
2986
|
+
* @fires action - When the AI requests a frontend action. Cancelable. Detail: `{ action: KRChatbotAction }`
|
|
2987
|
+
*/
|
|
2988
|
+
exports.Chatbot = class KRChatbot extends i$1 {
|
|
2989
|
+
constructor() {
|
|
2990
|
+
super(...arguments);
|
|
2991
|
+
// --- Private properties ---
|
|
2992
|
+
this._reader = null;
|
|
2993
|
+
this._decoder = new TextDecoder();
|
|
2994
|
+
this._buffer = '';
|
|
2995
|
+
this._userHasScrolledUp = false;
|
|
2996
|
+
this._isDragging = false;
|
|
2997
|
+
this._isResizing = false;
|
|
2998
|
+
this._resizeDir = '';
|
|
2999
|
+
this._dragStartX = 0;
|
|
3000
|
+
this._dragStartY = 0;
|
|
3001
|
+
this._dragStartLeft = 0;
|
|
3002
|
+
this._dragStartTop = 0;
|
|
3003
|
+
this._resizeStartW = 0;
|
|
3004
|
+
this._resizeStartH = 0;
|
|
3005
|
+
// --- @property (public API) ---
|
|
3006
|
+
/**
|
|
3007
|
+
* Callback function for sending messages. Receives the user's message and
|
|
3008
|
+
* current conversation history. Must return a Response with a streaming SSE body.
|
|
3009
|
+
*/
|
|
3010
|
+
this.send = null;
|
|
3011
|
+
/**
|
|
3012
|
+
* Callback function called when the user clears the conversation.
|
|
3013
|
+
* Must return a Promise — messages are only cleared if it resolves.
|
|
3014
|
+
*/
|
|
3015
|
+
this.clear = null;
|
|
3016
|
+
/**
|
|
3017
|
+
* Conversation messages. Can be set externally for initial messages.
|
|
3018
|
+
* Updated internally as the conversation progresses.
|
|
3019
|
+
*/
|
|
3020
|
+
this.messages = [];
|
|
3021
|
+
/**
|
|
3022
|
+
* Header title text.
|
|
3023
|
+
*/
|
|
3024
|
+
this.title = 'AI Assistant';
|
|
3025
|
+
/**
|
|
3026
|
+
* Header subtitle text (shown below title with a green status dot).
|
|
3027
|
+
*/
|
|
3028
|
+
this.subtitle = '';
|
|
3029
|
+
/**
|
|
3030
|
+
* Input placeholder text.
|
|
3031
|
+
*/
|
|
3032
|
+
this.placeholder = 'Type a message...';
|
|
3033
|
+
/**
|
|
3034
|
+
* Whether the chat panel is open. Only relevant in floating mode.
|
|
3035
|
+
*/
|
|
3036
|
+
this.opened = false;
|
|
3037
|
+
// --- @state (internal) ---
|
|
3038
|
+
this._inputValue = '';
|
|
3039
|
+
this._isStreaming = false;
|
|
3040
|
+
this._statusText = '';
|
|
3041
|
+
this._error = '';
|
|
3042
|
+
this._handleMouseMove = (e) => {
|
|
3043
|
+
if (this._isDragging) {
|
|
3044
|
+
let newLeft = this._dragStartLeft + (e.clientX - this._dragStartX);
|
|
3045
|
+
let newTop = this._dragStartTop + (e.clientY - this._dragStartY);
|
|
3046
|
+
const w = this._panelEl.offsetWidth;
|
|
3047
|
+
const h = this._panelEl.offsetHeight;
|
|
3048
|
+
newLeft = Math.max(-w + 48, Math.min(newLeft, window.innerWidth - 48));
|
|
3049
|
+
newTop = Math.max(-h + 48, Math.min(newTop, window.innerHeight - 48));
|
|
3050
|
+
this._panelEl.style.left = newLeft + 'px';
|
|
3051
|
+
this._panelEl.style.top = newTop + 'px';
|
|
3052
|
+
}
|
|
3053
|
+
else if (this._isResizing) {
|
|
3054
|
+
const dx = e.clientX - this._dragStartX;
|
|
3055
|
+
const dy = e.clientY - this._dragStartY;
|
|
3056
|
+
const minW = 340;
|
|
3057
|
+
const minH = 380;
|
|
3058
|
+
const maxW = window.innerWidth * 0.9;
|
|
3059
|
+
const maxH = window.innerHeight - 72;
|
|
3060
|
+
let newW = this._resizeStartW;
|
|
3061
|
+
let newH = this._resizeStartH;
|
|
3062
|
+
let newLeft = this._dragStartLeft;
|
|
3063
|
+
let newTop = this._dragStartTop;
|
|
3064
|
+
if (this._resizeDir.includes('e')) {
|
|
3065
|
+
newW = Math.max(minW, Math.min(this._resizeStartW + dx, maxW));
|
|
3066
|
+
}
|
|
3067
|
+
if (this._resizeDir.includes('w')) {
|
|
3068
|
+
const proposedW = this._resizeStartW - dx;
|
|
3069
|
+
if (proposedW >= minW && proposedW <= maxW) {
|
|
3070
|
+
newW = proposedW;
|
|
3071
|
+
newLeft = this._dragStartLeft + dx;
|
|
3072
|
+
}
|
|
3073
|
+
}
|
|
3074
|
+
if (this._resizeDir.includes('s')) {
|
|
3075
|
+
newH = Math.max(minH, Math.min(this._resizeStartH + dy, maxH));
|
|
3076
|
+
}
|
|
3077
|
+
if (this._resizeDir.includes('n')) {
|
|
3078
|
+
const proposedH = this._resizeStartH - dy;
|
|
3079
|
+
if (proposedH >= minH && proposedH <= maxH) {
|
|
3080
|
+
newH = proposedH;
|
|
3081
|
+
newTop = this._dragStartTop + dy;
|
|
3082
|
+
}
|
|
3083
|
+
}
|
|
3084
|
+
newLeft = Math.max(0, newLeft);
|
|
3085
|
+
newTop = Math.max(0, newTop);
|
|
3086
|
+
this._panelEl.style.width = newW + 'px';
|
|
3087
|
+
this._panelEl.style.height = newH + 'px';
|
|
3088
|
+
this._panelEl.style.left = newLeft + 'px';
|
|
3089
|
+
this._panelEl.style.top = newTop + 'px';
|
|
3090
|
+
}
|
|
3091
|
+
};
|
|
3092
|
+
this._handleMouseUp = () => {
|
|
3093
|
+
if (this._isDragging) {
|
|
3094
|
+
this._isDragging = false;
|
|
3095
|
+
this._panelEl.classList.remove('chatbot__panel--dragging');
|
|
3096
|
+
}
|
|
3097
|
+
if (this._isResizing) {
|
|
3098
|
+
this._isResizing = false;
|
|
3099
|
+
this._panelEl.classList.remove('chatbot__panel--resizing');
|
|
3100
|
+
}
|
|
3101
|
+
document.removeEventListener('mousemove', this._handleMouseMove);
|
|
3102
|
+
document.removeEventListener('mouseup', this._handleMouseUp);
|
|
3103
|
+
};
|
|
3104
|
+
}
|
|
3105
|
+
// --- Lifecycle ---
|
|
3106
|
+
disconnectedCallback() {
|
|
3107
|
+
super.disconnectedCallback();
|
|
3108
|
+
if (this._reader) {
|
|
3109
|
+
this._reader.cancel();
|
|
3110
|
+
this._reader = null;
|
|
3111
|
+
}
|
|
3112
|
+
document.removeEventListener('mousemove', this._handleMouseMove);
|
|
3113
|
+
document.removeEventListener('mouseup', this._handleMouseUp);
|
|
3114
|
+
}
|
|
3115
|
+
updated(changed) {
|
|
3116
|
+
if (changed.has('messages') || changed.has('_statusText')) {
|
|
3117
|
+
if (!this._userHasScrolledUp && this._messagesEl) {
|
|
3118
|
+
requestAnimationFrame(() => {
|
|
3119
|
+
if (this._messagesEl) {
|
|
3120
|
+
this._messagesEl.scrollTop = this._messagesEl.scrollHeight;
|
|
3121
|
+
}
|
|
3122
|
+
});
|
|
3123
|
+
}
|
|
3124
|
+
}
|
|
3125
|
+
if (changed.has('opened') && this.opened && this._inputEl) {
|
|
3126
|
+
setTimeout(() => {
|
|
3127
|
+
if (this._inputEl) {
|
|
3128
|
+
this._inputEl.focus();
|
|
3129
|
+
}
|
|
3130
|
+
}, 200);
|
|
3131
|
+
}
|
|
3132
|
+
}
|
|
3133
|
+
// --- Public methods ---
|
|
3134
|
+
/**
|
|
3135
|
+
* Stops the current stream without clearing the conversation.
|
|
3136
|
+
*/
|
|
3137
|
+
stop() {
|
|
3138
|
+
this._handleStop();
|
|
3139
|
+
}
|
|
3140
|
+
// --- Private methods ---
|
|
3141
|
+
_handleHeaderMouseDown(e) {
|
|
3142
|
+
// Ignore clicks on buttons inside the header
|
|
3143
|
+
if (e.target.closest('button')) {
|
|
3144
|
+
return;
|
|
3145
|
+
}
|
|
3146
|
+
if (!this._panelEl) {
|
|
3147
|
+
return;
|
|
3148
|
+
}
|
|
3149
|
+
this._isDragging = true;
|
|
3150
|
+
this._panelEl.classList.add('chatbot__panel--dragging');
|
|
3151
|
+
const rect = this._panelEl.getBoundingClientRect();
|
|
3152
|
+
this._panelEl.style.left = rect.left + 'px';
|
|
3153
|
+
this._panelEl.style.top = rect.top + 'px';
|
|
3154
|
+
this._panelEl.style.right = 'auto';
|
|
3155
|
+
this._panelEl.style.bottom = 'auto';
|
|
3156
|
+
this._panelEl.style.position = 'fixed';
|
|
3157
|
+
this._dragStartX = e.clientX;
|
|
3158
|
+
this._dragStartY = e.clientY;
|
|
3159
|
+
this._dragStartLeft = rect.left;
|
|
3160
|
+
this._dragStartTop = rect.top;
|
|
3161
|
+
e.preventDefault();
|
|
3162
|
+
document.addEventListener('mousemove', this._handleMouseMove);
|
|
3163
|
+
document.addEventListener('mouseup', this._handleMouseUp);
|
|
3164
|
+
}
|
|
3165
|
+
_handleResizeMouseDown(e) {
|
|
3166
|
+
if (!this._panelEl) {
|
|
3167
|
+
return;
|
|
3168
|
+
}
|
|
3169
|
+
this._isResizing = true;
|
|
3170
|
+
this._resizeDir = e.currentTarget.dataset.dir || '';
|
|
3171
|
+
this._panelEl.classList.add('chatbot__panel--resizing');
|
|
3172
|
+
const rect = this._panelEl.getBoundingClientRect();
|
|
3173
|
+
this._panelEl.style.left = rect.left + 'px';
|
|
3174
|
+
this._panelEl.style.top = rect.top + 'px';
|
|
3175
|
+
this._panelEl.style.right = 'auto';
|
|
3176
|
+
this._panelEl.style.bottom = 'auto';
|
|
3177
|
+
this._panelEl.style.position = 'fixed';
|
|
3178
|
+
this._dragStartX = e.clientX;
|
|
3179
|
+
this._dragStartY = e.clientY;
|
|
3180
|
+
this._dragStartLeft = rect.left;
|
|
3181
|
+
this._dragStartTop = rect.top;
|
|
3182
|
+
this._resizeStartW = rect.width;
|
|
3183
|
+
this._resizeStartH = rect.height;
|
|
3184
|
+
e.preventDefault();
|
|
3185
|
+
e.stopPropagation();
|
|
3186
|
+
document.addEventListener('mousemove', this._handleMouseMove);
|
|
3187
|
+
document.addEventListener('mouseup', this._handleMouseUp);
|
|
3188
|
+
}
|
|
3189
|
+
_handleToggle() {
|
|
3190
|
+
this.opened = !this.opened;
|
|
3191
|
+
// Reset position when opening so it returns to default bottom-right
|
|
3192
|
+
if (this.opened && this._panelEl) {
|
|
3193
|
+
this._panelEl.style.left = '';
|
|
3194
|
+
this._panelEl.style.top = '';
|
|
3195
|
+
this._panelEl.style.right = '';
|
|
3196
|
+
this._panelEl.style.bottom = '';
|
|
3197
|
+
this._panelEl.style.width = '';
|
|
3198
|
+
this._panelEl.style.height = '';
|
|
3199
|
+
this._panelEl.style.position = '';
|
|
3200
|
+
}
|
|
3201
|
+
}
|
|
3202
|
+
_handleInputChange(e) {
|
|
3203
|
+
this._inputValue = e.target.value;
|
|
3204
|
+
// Auto-resize textarea
|
|
3205
|
+
const textarea = e.target;
|
|
3206
|
+
textarea.style.height = 'auto';
|
|
3207
|
+
textarea.style.height = Math.min(textarea.scrollHeight, 120) + 'px';
|
|
3208
|
+
}
|
|
3209
|
+
_handleKeyDown(e) {
|
|
3210
|
+
if (e.key === 'Enter' && !e.shiftKey) {
|
|
3211
|
+
e.preventDefault();
|
|
3212
|
+
this._handleSubmit();
|
|
3213
|
+
}
|
|
3214
|
+
}
|
|
3215
|
+
_handleSubmit() {
|
|
3216
|
+
if (!this._inputValue.trim() || !this.send || this._isStreaming) {
|
|
3217
|
+
return;
|
|
3218
|
+
}
|
|
3219
|
+
const messageText = this._inputValue.trim();
|
|
3220
|
+
const submitEvent = new CustomEvent('message-submit', {
|
|
3221
|
+
detail: {
|
|
3222
|
+
message: messageText,
|
|
3223
|
+
},
|
|
3224
|
+
bubbles: true,
|
|
3225
|
+
composed: true,
|
|
3226
|
+
cancelable: true,
|
|
3227
|
+
});
|
|
3228
|
+
this.dispatchEvent(submitEvent);
|
|
3229
|
+
if (submitEvent.defaultPrevented) {
|
|
3230
|
+
return;
|
|
3231
|
+
}
|
|
3232
|
+
this.messages = [...this.messages, {
|
|
3233
|
+
role: 'user',
|
|
3234
|
+
content: messageText,
|
|
3235
|
+
}];
|
|
3236
|
+
this._inputValue = '';
|
|
3237
|
+
this._error = '';
|
|
3238
|
+
this._userHasScrolledUp = false;
|
|
3239
|
+
// Reset textarea height
|
|
3240
|
+
if (this._inputEl) {
|
|
3241
|
+
this._inputEl.style.height = 'auto';
|
|
3242
|
+
}
|
|
3243
|
+
// Add empty assistant message to stream into
|
|
3244
|
+
this.messages = [...this.messages, {
|
|
3245
|
+
role: 'assistant',
|
|
3246
|
+
content: '',
|
|
3247
|
+
}];
|
|
3248
|
+
this._isStreaming = true;
|
|
3249
|
+
this._statusText = '';
|
|
3250
|
+
this.send({
|
|
3251
|
+
message: messageText,
|
|
3252
|
+
messages: this.messages.slice(0, -1),
|
|
3253
|
+
}).then((response) => {
|
|
3254
|
+
if (!response.ok) {
|
|
3255
|
+
this._handleStreamError('Request failed: ' + response.status);
|
|
3256
|
+
return;
|
|
3257
|
+
}
|
|
3258
|
+
if (!response.body) {
|
|
3259
|
+
this._handleStreamError('No response body');
|
|
3260
|
+
return;
|
|
3261
|
+
}
|
|
3262
|
+
this._reader = response.body.getReader();
|
|
3263
|
+
this._decoder = new TextDecoder();
|
|
3264
|
+
this._buffer = '';
|
|
3265
|
+
this._readStreamChunk();
|
|
3266
|
+
}).catch((err) => {
|
|
3267
|
+
if (err.name !== 'AbortError') {
|
|
3268
|
+
this._handleStreamError(err.message);
|
|
3269
|
+
}
|
|
3270
|
+
});
|
|
3271
|
+
}
|
|
3272
|
+
_handleStop() {
|
|
3273
|
+
if (this._reader) {
|
|
3274
|
+
this._reader.cancel();
|
|
3275
|
+
this._reader = null;
|
|
3276
|
+
}
|
|
3277
|
+
this._isStreaming = false;
|
|
3278
|
+
this._statusText = '';
|
|
3279
|
+
}
|
|
3280
|
+
_handleClear() {
|
|
3281
|
+
if (!this.clear) {
|
|
3282
|
+
return;
|
|
3283
|
+
}
|
|
3284
|
+
this.clear().then(() => {
|
|
3285
|
+
if (this._reader) {
|
|
3286
|
+
this._reader.cancel();
|
|
3287
|
+
this._reader = null;
|
|
3288
|
+
}
|
|
3289
|
+
this.messages = [];
|
|
3290
|
+
this._isStreaming = false;
|
|
3291
|
+
this._statusText = '';
|
|
3292
|
+
this._error = '';
|
|
3293
|
+
this._inputValue = '';
|
|
3294
|
+
this._userHasScrolledUp = false;
|
|
3295
|
+
});
|
|
3296
|
+
}
|
|
3297
|
+
_handleMessagesScroll(e) {
|
|
3298
|
+
const container = e.target;
|
|
3299
|
+
const distanceFromBottom = container.scrollHeight - container.scrollTop - container.clientHeight;
|
|
3300
|
+
if (distanceFromBottom > 50) {
|
|
3301
|
+
this._userHasScrolledUp = true;
|
|
3302
|
+
}
|
|
3303
|
+
else {
|
|
3304
|
+
this._userHasScrolledUp = false;
|
|
3305
|
+
}
|
|
3306
|
+
}
|
|
3307
|
+
_handleErrorDismiss() {
|
|
3308
|
+
this._error = '';
|
|
3309
|
+
}
|
|
3310
|
+
_readStreamChunk() {
|
|
3311
|
+
if (!this._reader) {
|
|
3312
|
+
return;
|
|
3313
|
+
}
|
|
3314
|
+
this._reader.read().then((result) => {
|
|
3315
|
+
if (result.done) {
|
|
3316
|
+
this._isStreaming = false;
|
|
3317
|
+
this._statusText = '';
|
|
3318
|
+
this._reader = null;
|
|
3319
|
+
return;
|
|
3320
|
+
}
|
|
3321
|
+
this._buffer = this._buffer + this._decoder.decode(result.value, { stream: true });
|
|
3322
|
+
const events = this._buffer.split('\n\n');
|
|
3323
|
+
this._buffer = events.pop() || '';
|
|
3324
|
+
for (let i = 0; i < events.length; i++) {
|
|
3325
|
+
if (!events[i].trim()) {
|
|
3326
|
+
continue;
|
|
3327
|
+
}
|
|
3328
|
+
const lines = events[i].split('\n');
|
|
3329
|
+
for (let j = 0; j < lines.length; j++) {
|
|
3330
|
+
if (!lines[j].startsWith('data:')) {
|
|
3331
|
+
continue;
|
|
3332
|
+
}
|
|
3333
|
+
const raw = lines[j].slice(5).trim();
|
|
3334
|
+
if (!raw) {
|
|
3335
|
+
continue;
|
|
3336
|
+
}
|
|
3337
|
+
let data;
|
|
3338
|
+
try {
|
|
3339
|
+
data = JSON.parse(raw);
|
|
3340
|
+
}
|
|
3341
|
+
catch {
|
|
3342
|
+
continue;
|
|
3343
|
+
}
|
|
3344
|
+
if (data.type === 'STATUS') {
|
|
3345
|
+
if (data.message) {
|
|
3346
|
+
this._statusText = String(data.message);
|
|
3347
|
+
}
|
|
3348
|
+
}
|
|
3349
|
+
else if (data.type === 'REASONING_PART') {
|
|
3350
|
+
if (data.message) {
|
|
3351
|
+
const lastIndex = this.messages.length - 1;
|
|
3352
|
+
if (lastIndex >= 0 && this.messages[lastIndex].role === 'assistant') {
|
|
3353
|
+
if (!this.messages[lastIndex].reasoning) {
|
|
3354
|
+
this.messages[lastIndex].reasoning = '';
|
|
3355
|
+
}
|
|
3356
|
+
this.messages[lastIndex].reasoning += String(data.message);
|
|
3357
|
+
this.requestUpdate();
|
|
3358
|
+
}
|
|
3359
|
+
}
|
|
3360
|
+
}
|
|
3361
|
+
else if (data.type === 'RESPONSE_PART') {
|
|
3362
|
+
if (data.message) {
|
|
3363
|
+
this._statusText = '';
|
|
3364
|
+
const lastIndex = this.messages.length - 1;
|
|
3365
|
+
if (lastIndex >= 0 && this.messages[lastIndex].role === 'assistant') {
|
|
3366
|
+
this.messages[lastIndex].content += String(data.message);
|
|
3367
|
+
this.requestUpdate();
|
|
3368
|
+
}
|
|
3369
|
+
}
|
|
3370
|
+
}
|
|
3371
|
+
else if (data.type === 'ACTION') {
|
|
3372
|
+
const action = data;
|
|
3373
|
+
const actionEvent = new CustomEvent('action', {
|
|
3374
|
+
detail: {
|
|
3375
|
+
action: action,
|
|
3376
|
+
},
|
|
3377
|
+
bubbles: true,
|
|
3378
|
+
composed: true,
|
|
3379
|
+
cancelable: true,
|
|
3380
|
+
});
|
|
3381
|
+
this.dispatchEvent(actionEvent);
|
|
3382
|
+
if (!actionEvent.defaultPrevented) {
|
|
3383
|
+
if (action.action === 'RELOAD') {
|
|
3384
|
+
location.reload();
|
|
3385
|
+
}
|
|
3386
|
+
else if (action.action === 'NAVIGATE') {
|
|
3387
|
+
if (action.data && action.data.url) {
|
|
3388
|
+
window.location.href = action.data.url;
|
|
3389
|
+
}
|
|
3390
|
+
}
|
|
3391
|
+
else if (action.action === 'OPEN_TAB') {
|
|
3392
|
+
if (action.data && action.data.url) {
|
|
3393
|
+
window.open(action.data.url, '_blank');
|
|
3394
|
+
}
|
|
3395
|
+
}
|
|
3396
|
+
else if (action.action === 'UPDATE_HTML') {
|
|
3397
|
+
if (action.data && action.data.selector && action.data.html) {
|
|
3398
|
+
const el = document.querySelector(action.data.selector);
|
|
3399
|
+
if (el) {
|
|
3400
|
+
el.innerHTML = action.data.html;
|
|
3401
|
+
}
|
|
3402
|
+
}
|
|
3403
|
+
}
|
|
3404
|
+
else if (action.action === 'SCROLL_TO') {
|
|
3405
|
+
if (action.data && action.data.selector) {
|
|
3406
|
+
const el = document.querySelector(action.data.selector);
|
|
3407
|
+
if (el) {
|
|
3408
|
+
el.scrollIntoView({ behavior: 'smooth' });
|
|
3409
|
+
}
|
|
3410
|
+
}
|
|
3411
|
+
}
|
|
3412
|
+
}
|
|
3413
|
+
}
|
|
3414
|
+
else if (data.type === 'ERROR') {
|
|
3415
|
+
this._handleStreamError(String(data.message || 'Unknown error'));
|
|
3416
|
+
}
|
|
3417
|
+
if (data.finished) {
|
|
3418
|
+
this._isStreaming = false;
|
|
3419
|
+
this._statusText = '';
|
|
3420
|
+
this._reader = null;
|
|
3421
|
+
}
|
|
3422
|
+
}
|
|
3423
|
+
}
|
|
3424
|
+
this._readStreamChunk();
|
|
3425
|
+
}).catch((err) => {
|
|
3426
|
+
if (err.name !== 'AbortError') {
|
|
3427
|
+
this._handleStreamError(err.message);
|
|
3428
|
+
}
|
|
3429
|
+
});
|
|
3430
|
+
}
|
|
3431
|
+
_handleStreamError(message) {
|
|
3432
|
+
this._isStreaming = false;
|
|
3433
|
+
this._statusText = '';
|
|
3434
|
+
this._error = message;
|
|
3435
|
+
if (this._reader) {
|
|
3436
|
+
this._reader.cancel();
|
|
3437
|
+
this._reader = null;
|
|
3438
|
+
}
|
|
3439
|
+
// Remove the empty assistant message if it has no content
|
|
3440
|
+
if (this.messages.length > 0) {
|
|
3441
|
+
const lastMessage = this.messages[this.messages.length - 1];
|
|
3442
|
+
if (lastMessage.role === 'assistant' && !lastMessage.content) {
|
|
3443
|
+
this.messages = this.messages.slice(0, -1);
|
|
3444
|
+
}
|
|
3445
|
+
}
|
|
3446
|
+
}
|
|
3447
|
+
/**
|
|
3448
|
+
* Lightweight text formatting for assistant messages.
|
|
3449
|
+
* Handles code blocks, inline code, bold, and line breaks.
|
|
3450
|
+
* Escapes HTML entities first to prevent XSS.
|
|
3451
|
+
*/
|
|
3452
|
+
_formatAssistantContent(text) {
|
|
3453
|
+
// Escape HTML entities
|
|
3454
|
+
let escaped = text
|
|
3455
|
+
.replace(/&/g, '&')
|
|
3456
|
+
.replace(/</g, '<')
|
|
3457
|
+
.replace(/>/g, '>')
|
|
3458
|
+
.replace(/"/g, '"')
|
|
3459
|
+
.replace(/'/g, ''');
|
|
3460
|
+
// Code blocks: ```...```
|
|
3461
|
+
escaped = escaped.replace(/```(\w*)\n?([\s\S]*?)```/g, '<pre><code>$2</code></pre>');
|
|
3462
|
+
// Inline code: `...`
|
|
3463
|
+
escaped = escaped.replace(/`([^`]+)`/g, '<code>$1</code>');
|
|
3464
|
+
// Bold: **...**
|
|
3465
|
+
escaped = escaped.replace(/\*\*([^*]+)\*\*/g, '<strong>$1</strong>');
|
|
3466
|
+
// Split on code blocks to only convert newlines outside of pre tags
|
|
3467
|
+
const parts = escaped.split(/(<pre><code>[\s\S]*?<\/code><\/pre>)/g);
|
|
3468
|
+
for (let i = 0; i < parts.length; i++) {
|
|
3469
|
+
// Skip code blocks (odd indices from the split)
|
|
3470
|
+
if (i % 2 === 0) {
|
|
3471
|
+
// Convert double newlines to paragraph breaks
|
|
3472
|
+
parts[i] = parts[i].replace(/\n\n/g, '</p><p>');
|
|
3473
|
+
// Convert single newlines to line breaks
|
|
3474
|
+
parts[i] = parts[i].replace(/\n/g, '<br>');
|
|
3475
|
+
}
|
|
3476
|
+
}
|
|
3477
|
+
escaped = parts.join('');
|
|
3478
|
+
// Wrap in paragraph if we inserted paragraph breaks
|
|
3479
|
+
if (escaped.includes('</p><p>')) {
|
|
3480
|
+
escaped = '<p>' + escaped + '</p>';
|
|
3481
|
+
}
|
|
3482
|
+
return escaped;
|
|
3483
|
+
}
|
|
3484
|
+
// --- Render ---
|
|
3485
|
+
render() {
|
|
3486
|
+
return b `
|
|
3487
|
+
<button
|
|
3488
|
+
class=${e({
|
|
3489
|
+
'chatbot__toggle': true,
|
|
3490
|
+
'chatbot__toggle--hidden': this.opened,
|
|
3491
|
+
})}
|
|
3492
|
+
@click=${this._handleToggle}
|
|
3493
|
+
title="Open chat"
|
|
3494
|
+
>
|
|
3495
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" class="chatbot__toggle-icon">
|
|
3496
|
+
<path d="M12 2C6.48 2 2 6.03 2 11c0 2.61 1.19 4.94 3.05 6.55L4 22l4.8-2.4C9.82 19.85 10.88 20 12 20c5.52 0 10-4.03 10-9S17.52 2 12 2z"/>
|
|
3497
|
+
<path d="M8 11h.01M12 11h.01M16 11h.01" stroke-width="2.5"/>
|
|
3498
|
+
</svg>
|
|
3499
|
+
</button>
|
|
3500
|
+
|
|
3501
|
+
<div class=${e({
|
|
3502
|
+
'chatbot__panel': true,
|
|
3503
|
+
'chatbot__panel--opened': this.opened,
|
|
3504
|
+
})}>
|
|
3505
|
+
<div class="chatbot__resize chatbot__resize--n" data-dir="n" @mousedown=${this._handleResizeMouseDown}></div>
|
|
3506
|
+
<div class="chatbot__resize chatbot__resize--s" data-dir="s" @mousedown=${this._handleResizeMouseDown}></div>
|
|
3507
|
+
<div class="chatbot__resize chatbot__resize--w" data-dir="w" @mousedown=${this._handleResizeMouseDown}></div>
|
|
3508
|
+
<div class="chatbot__resize chatbot__resize--e" data-dir="e" @mousedown=${this._handleResizeMouseDown}></div>
|
|
3509
|
+
<div class="chatbot__resize chatbot__resize--nw" data-dir="nw" @mousedown=${this._handleResizeMouseDown}></div>
|
|
3510
|
+
<div class="chatbot__resize chatbot__resize--ne" data-dir="ne" @mousedown=${this._handleResizeMouseDown}></div>
|
|
3511
|
+
<div class="chatbot__resize chatbot__resize--sw" data-dir="sw" @mousedown=${this._handleResizeMouseDown}></div>
|
|
3512
|
+
<div class="chatbot__resize chatbot__resize--se" data-dir="se" @mousedown=${this._handleResizeMouseDown}></div>
|
|
3513
|
+
<div class="chatbot__header" @mousedown=${this._handleHeaderMouseDown}>
|
|
3514
|
+
<div class="chatbot__header-left">
|
|
3515
|
+
<div class="chatbot__header-drag-hint">
|
|
3516
|
+
<span></span>
|
|
3517
|
+
<span></span>
|
|
3518
|
+
<span></span>
|
|
3519
|
+
</div>
|
|
3520
|
+
<div class="chatbot__header-info">
|
|
3521
|
+
<span class="chatbot__header-title">${this.title}</span>
|
|
3522
|
+
${this.subtitle ? b `
|
|
3523
|
+
<span class="chatbot__header-subtitle">${this.subtitle}</span>
|
|
3524
|
+
` : A}
|
|
3525
|
+
</div>
|
|
3526
|
+
</div>
|
|
3527
|
+
<div class="chatbot__header-actions">
|
|
3528
|
+
${this.messages.length > 0 ? b `
|
|
3529
|
+
<button class="chatbot__header-action" @click=${this._handleClear} title="Clear conversation">
|
|
3530
|
+
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="chatbot__header-action-icon">
|
|
3531
|
+
<path stroke-linecap="round" stroke-linejoin="round" d="m14.74 9-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 0 1-2.244 2.077H8.084a2.25 2.25 0 0 1-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 0 0-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 0 1 3.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 0 0-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 0 0-7.5 0" />
|
|
3532
|
+
</svg>
|
|
3533
|
+
</button>
|
|
3534
|
+
` : A}
|
|
3535
|
+
<button class="chatbot__header-action" @click=${this._handleToggle} title="Close">
|
|
3536
|
+
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" class="chatbot__header-action-icon">
|
|
3537
|
+
<path stroke-linecap="round" stroke-linejoin="round" d="M6 18 18 6M6 6l12 12" />
|
|
3538
|
+
</svg>
|
|
3539
|
+
</button>
|
|
3540
|
+
</div>
|
|
3541
|
+
</div>
|
|
3542
|
+
|
|
3543
|
+
<div class="chatbot__messages" @scroll=${this._handleMessagesScroll}>
|
|
3544
|
+
${this.messages.length === 0 ? b `
|
|
3545
|
+
<div class="chatbot__empty">
|
|
3546
|
+
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1" stroke="currentColor" class="chatbot__empty-icon">
|
|
3547
|
+
<path stroke-linecap="round" stroke-linejoin="round" d="M7.5 8.25h9m-9 3H12m-9.75 1.51c0 1.6 1.123 2.994 2.707 3.227 1.087.16 2.185.283 3.293.369V21l4.076-4.076a1.526 1.526 0 0 1 1.037-.443 48.282 48.282 0 0 0 5.68-.494c1.584-.233 2.707-1.626 2.707-3.228V6.741c0-1.602-1.123-2.995-2.707-3.228A48.394 48.394 0 0 0 12 3c-2.392 0-4.744.175-7.043.513C3.373 3.746 2.25 5.14 2.25 6.741v6.018Z" />
|
|
3548
|
+
</svg>
|
|
3549
|
+
<span class="chatbot__empty-text">How can I help?</span>
|
|
3550
|
+
</div>
|
|
3551
|
+
` : A}
|
|
3552
|
+
${this.messages.map((msg) => b `
|
|
3553
|
+
<div class=${e({
|
|
3554
|
+
'chatbot__message': true,
|
|
3555
|
+
'chatbot__message--user': msg.role === 'user',
|
|
3556
|
+
'chatbot__message--assistant': msg.role === 'assistant',
|
|
3557
|
+
})}>
|
|
3558
|
+
${msg.reasoning ? b `
|
|
3559
|
+
<details class="chatbot__reasoning">
|
|
3560
|
+
<summary>Thinking</summary>
|
|
3561
|
+
<div class="chatbot__reasoning-content">${msg.reasoning}</div>
|
|
3562
|
+
</details>
|
|
3563
|
+
` : A}
|
|
3564
|
+
<div class="chatbot__message-content">
|
|
3565
|
+
${msg.role === 'user'
|
|
3566
|
+
? msg.content
|
|
3567
|
+
: o(this._formatAssistantContent(msg.content))}
|
|
3568
|
+
</div>
|
|
3569
|
+
</div>
|
|
3570
|
+
`)}
|
|
3571
|
+
${this._statusText ? b `
|
|
3572
|
+
<div class="chatbot__message chatbot__message--assistant">
|
|
3573
|
+
<div class="chatbot__typing">
|
|
3574
|
+
<span></span>
|
|
3575
|
+
<span></span>
|
|
3576
|
+
<span></span>
|
|
3577
|
+
</div>
|
|
3578
|
+
</div>
|
|
3579
|
+
` : A}
|
|
3580
|
+
</div>
|
|
3581
|
+
|
|
3582
|
+
${this._error ? b `
|
|
3583
|
+
<div class="chatbot__error">
|
|
3584
|
+
<span>${this._error}</span>
|
|
3585
|
+
<button class="chatbot__error-dismiss" @click=${this._handleErrorDismiss}>
|
|
3586
|
+
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" class="chatbot__error-dismiss-icon">
|
|
3587
|
+
<path stroke-linecap="round" stroke-linejoin="round" d="M6 18 18 6M6 6l12 12" />
|
|
3588
|
+
</svg>
|
|
3589
|
+
</button>
|
|
3590
|
+
</div>
|
|
3591
|
+
` : A}
|
|
3592
|
+
|
|
3593
|
+
<div class="chatbot__footer">
|
|
3594
|
+
<div class="chatbot__input-wrapper">
|
|
3595
|
+
<button class="chatbot__input-plus" title="Attach">+</button>
|
|
3596
|
+
<textarea
|
|
3597
|
+
class="chatbot__input"
|
|
3598
|
+
.value=${this._inputValue}
|
|
3599
|
+
placeholder=${this.placeholder}
|
|
3600
|
+
rows="1"
|
|
3601
|
+
@input=${this._handleInputChange}
|
|
3602
|
+
@keydown=${this._handleKeyDown}
|
|
3603
|
+
></textarea>
|
|
3604
|
+
${this._isStreaming ? b `
|
|
3605
|
+
<button class="chatbot__stop" @click=${this._handleStop} title="Stop generating">
|
|
3606
|
+
<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24" class="chatbot__stop-icon">
|
|
3607
|
+
<rect x="6" y="6" width="12" height="12" rx="2" />
|
|
3608
|
+
</svg>
|
|
3609
|
+
</button>
|
|
3610
|
+
` : b `
|
|
3611
|
+
<button
|
|
3612
|
+
class=${e({
|
|
3613
|
+
'chatbot__send': true,
|
|
3614
|
+
'chatbot__send--disabled': !this._inputValue.trim(),
|
|
3615
|
+
})}
|
|
3616
|
+
@click=${this._handleSubmit}
|
|
3617
|
+
title="Send message"
|
|
3618
|
+
>
|
|
3619
|
+
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" class="chatbot__send-icon">
|
|
3620
|
+
<path d="M12 19V5M5 12l7-7 7 7"/>
|
|
3621
|
+
</svg>
|
|
3622
|
+
</button>
|
|
3623
|
+
`}
|
|
3624
|
+
</div>
|
|
3625
|
+
</div>
|
|
3626
|
+
</div>
|
|
3627
|
+
`;
|
|
3628
|
+
}
|
|
3629
|
+
};
|
|
3630
|
+
exports.Chatbot.styles = i$4 `
|
|
3631
|
+
*,
|
|
3632
|
+
*::before,
|
|
3633
|
+
*::after {
|
|
3634
|
+
box-sizing: border-box;
|
|
3635
|
+
}
|
|
3636
|
+
|
|
3637
|
+
:host {
|
|
3638
|
+
display: block;
|
|
3639
|
+
font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
|
3640
|
+
font-size: 14px;
|
|
3641
|
+
line-height: 1.6;
|
|
3642
|
+
|
|
3643
|
+
--kr-chatbot-primary: #163052;
|
|
3644
|
+
--kr-chatbot-primary-hover: #1e4068;
|
|
3645
|
+
--kr-chatbot-bg: #ffffff;
|
|
3646
|
+
--kr-chatbot-border: #d9d9d9;
|
|
3647
|
+
--kr-chatbot-text: #1a1a2e;
|
|
3648
|
+
--kr-chatbot-text-secondary: #64668b;
|
|
3649
|
+
--kr-chatbot-user-bg: #e9e9e980;
|
|
3650
|
+
--kr-chatbot-user-text: #1a1a2e;
|
|
3651
|
+
--kr-chatbot-error-bg: #fef2f2;
|
|
3652
|
+
--kr-chatbot-error-text: #dc2626;
|
|
3653
|
+
--kr-chatbot-success: #00b894;
|
|
3654
|
+
--kr-chatbot-toggle-size: 56px;
|
|
3655
|
+
--kr-chatbot-panel-width: 440px;
|
|
3656
|
+
--kr-chatbot-panel-height: 620px;
|
|
3657
|
+
}
|
|
3658
|
+
|
|
3659
|
+
:host {
|
|
3660
|
+
position: fixed;
|
|
3661
|
+
bottom: 24px;
|
|
3662
|
+
right: 24px;
|
|
3663
|
+
z-index: 10000;
|
|
3664
|
+
}
|
|
3665
|
+
|
|
3666
|
+
/* Toggle button */
|
|
3667
|
+
.chatbot__toggle {
|
|
3668
|
+
width: var(--kr-chatbot-toggle-size);
|
|
3669
|
+
height: var(--kr-chatbot-toggle-size);
|
|
3670
|
+
border-radius: 18px;
|
|
3671
|
+
background: var(--kr-chatbot-primary);
|
|
3672
|
+
color: white;
|
|
3673
|
+
border: none;
|
|
3674
|
+
cursor: pointer;
|
|
3675
|
+
display: flex;
|
|
3676
|
+
align-items: center;
|
|
3677
|
+
justify-content: center;
|
|
3678
|
+
box-shadow: 0 4px 24px rgba(22, 48, 82, 0.4);
|
|
3679
|
+
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
|
3680
|
+
}
|
|
3681
|
+
|
|
3682
|
+
.chatbot__toggle:hover {
|
|
3683
|
+
transform: scale(1.05);
|
|
3684
|
+
box-shadow: 0 6px 32px rgba(22, 48, 82, 0.5);
|
|
3685
|
+
}
|
|
3686
|
+
|
|
3687
|
+
.chatbot__toggle--hidden {
|
|
3688
|
+
transform: scale(0);
|
|
3689
|
+
opacity: 0;
|
|
3690
|
+
pointer-events: none;
|
|
3691
|
+
}
|
|
3692
|
+
|
|
3693
|
+
.chatbot__toggle-icon {
|
|
3694
|
+
width: 26px;
|
|
3695
|
+
height: 26px;
|
|
3696
|
+
}
|
|
3697
|
+
|
|
3698
|
+
/* Panel */
|
|
3699
|
+
.chatbot__panel {
|
|
3700
|
+
display: none;
|
|
3701
|
+
flex-direction: column;
|
|
3702
|
+
background: var(--kr-chatbot-bg);
|
|
3703
|
+
overflow: hidden;
|
|
3704
|
+
position: absolute;
|
|
3705
|
+
bottom: 0;
|
|
3706
|
+
right: 0;
|
|
3707
|
+
width: var(--kr-chatbot-panel-width);
|
|
3708
|
+
height: var(--kr-chatbot-panel-height);
|
|
3709
|
+
max-height: calc(100vh - 72px);
|
|
3710
|
+
border-radius: 16px;
|
|
3711
|
+
box-shadow: 0 8px 40px rgba(0, 0, 0, 0.08), 0 2px 12px rgba(0, 0, 0, 0.04);
|
|
3712
|
+
border: 1px solid rgba(0, 0, 0, 0.08);
|
|
3713
|
+
animation: chatbot-panel-in 0.35s cubic-bezier(0.4, 0, 0.2, 1);
|
|
3714
|
+
transform-origin: bottom right;
|
|
3715
|
+
}
|
|
3716
|
+
|
|
3717
|
+
.chatbot__panel--opened {
|
|
3718
|
+
display: flex;
|
|
3719
|
+
}
|
|
3720
|
+
|
|
3721
|
+
@keyframes chatbot-panel-in {
|
|
3722
|
+
from {
|
|
3723
|
+
opacity: 0;
|
|
3724
|
+
transform: scale(0.92) translateY(20px);
|
|
3725
|
+
}
|
|
3726
|
+
to {
|
|
3727
|
+
opacity: 1;
|
|
3728
|
+
transform: scale(1) translateY(0);
|
|
3729
|
+
}
|
|
3730
|
+
}
|
|
3731
|
+
|
|
3732
|
+
/* Header */
|
|
3733
|
+
.chatbot__header {
|
|
3734
|
+
padding: 10px 16px;
|
|
3735
|
+
background: var(--kr-chatbot-primary);
|
|
3736
|
+
color: white;
|
|
3737
|
+
display: flex;
|
|
3738
|
+
align-items: center;
|
|
3739
|
+
justify-content: space-between;
|
|
3740
|
+
flex-shrink: 0;
|
|
3741
|
+
}
|
|
3742
|
+
|
|
3743
|
+
.chatbot__header-left {
|
|
3744
|
+
display: flex;
|
|
3745
|
+
align-items: center;
|
|
3746
|
+
gap: 10px;
|
|
3747
|
+
}
|
|
3748
|
+
|
|
3749
|
+
.chatbot__header-drag-hint {
|
|
3750
|
+
display: flex;
|
|
3751
|
+
flex-direction: column;
|
|
3752
|
+
gap: 2px;
|
|
3753
|
+
opacity: 0.35;
|
|
3754
|
+
}
|
|
3755
|
+
|
|
3756
|
+
.chatbot__header-drag-hint span {
|
|
3757
|
+
display: block;
|
|
3758
|
+
width: 14px;
|
|
3759
|
+
height: 2px;
|
|
3760
|
+
background: white;
|
|
3761
|
+
border-radius: 1px;
|
|
3762
|
+
}
|
|
3763
|
+
|
|
3764
|
+
.chatbot__header-info {
|
|
3765
|
+
display: flex;
|
|
3766
|
+
flex-direction: column;
|
|
3767
|
+
}
|
|
3768
|
+
|
|
3769
|
+
.chatbot__header-title {
|
|
3770
|
+
font-size: 13px;
|
|
3771
|
+
font-weight: 600;
|
|
3772
|
+
letter-spacing: -0.2px;
|
|
3773
|
+
}
|
|
3774
|
+
|
|
3775
|
+
.chatbot__header-subtitle {
|
|
3776
|
+
color: rgba(255, 255, 255, 0.5);
|
|
3777
|
+
font-size: 11px;
|
|
3778
|
+
display: flex;
|
|
3779
|
+
align-items: center;
|
|
3780
|
+
gap: 4px;
|
|
3781
|
+
}
|
|
3782
|
+
|
|
3783
|
+
.chatbot__header-subtitle::before {
|
|
3784
|
+
content: '';
|
|
3785
|
+
width: 5px;
|
|
3786
|
+
height: 5px;
|
|
3787
|
+
background: var(--kr-chatbot-success);
|
|
3788
|
+
border-radius: 50%;
|
|
3789
|
+
}
|
|
3790
|
+
|
|
3791
|
+
.chatbot__header-actions {
|
|
3792
|
+
display: flex;
|
|
3793
|
+
align-items: center;
|
|
3794
|
+
gap: 4px;
|
|
3795
|
+
}
|
|
3796
|
+
|
|
3797
|
+
.chatbot__header-action {
|
|
3798
|
+
width: 28px;
|
|
3799
|
+
height: 28px;
|
|
3800
|
+
background: transparent;
|
|
3801
|
+
border: none;
|
|
3802
|
+
color: rgba(255, 255, 255, 0.6);
|
|
3803
|
+
border-radius: 8px;
|
|
3804
|
+
cursor: pointer;
|
|
3805
|
+
display: flex;
|
|
3806
|
+
align-items: center;
|
|
3807
|
+
justify-content: center;
|
|
3808
|
+
transition: all 0.15s;
|
|
3809
|
+
}
|
|
3810
|
+
|
|
3811
|
+
.chatbot__header-action:hover {
|
|
3812
|
+
background: rgba(255, 255, 255, 0.1);
|
|
3813
|
+
color: white;
|
|
3814
|
+
}
|
|
3815
|
+
|
|
3816
|
+
.chatbot__header-action-icon {
|
|
3817
|
+
width: 16px;
|
|
3818
|
+
height: 16px;
|
|
3819
|
+
}
|
|
3820
|
+
|
|
3821
|
+
/* Messages */
|
|
3822
|
+
.chatbot__messages {
|
|
3823
|
+
flex: 1;
|
|
3824
|
+
overflow-y: auto;
|
|
3825
|
+
padding: 32px;
|
|
3826
|
+
display: flex;
|
|
3827
|
+
flex-direction: column;
|
|
3828
|
+
gap: 24px;
|
|
3829
|
+
scroll-behavior: smooth;
|
|
3830
|
+
background: white;
|
|
3831
|
+
}
|
|
3832
|
+
|
|
3833
|
+
.chatbot__messages::-webkit-scrollbar {
|
|
3834
|
+
width: 4px;
|
|
3835
|
+
}
|
|
3836
|
+
|
|
3837
|
+
.chatbot__messages::-webkit-scrollbar-track {
|
|
3838
|
+
background: transparent;
|
|
3839
|
+
}
|
|
3840
|
+
|
|
3841
|
+
.chatbot__messages::-webkit-scrollbar-thumb {
|
|
3842
|
+
background: rgba(0, 0, 0, 0.08);
|
|
3843
|
+
border-radius: 2px;
|
|
3844
|
+
}
|
|
3845
|
+
|
|
3846
|
+
.chatbot__empty {
|
|
3847
|
+
flex: 1;
|
|
3848
|
+
display: flex;
|
|
3849
|
+
flex-direction: column;
|
|
3850
|
+
align-items: center;
|
|
3851
|
+
justify-content: center;
|
|
3852
|
+
color: var(--kr-chatbot-text-secondary);
|
|
3853
|
+
gap: 8px;
|
|
3854
|
+
}
|
|
3855
|
+
|
|
3856
|
+
.chatbot__empty-icon {
|
|
3857
|
+
width: 40px;
|
|
3858
|
+
height: 40px;
|
|
3859
|
+
opacity: 0.4;
|
|
3860
|
+
}
|
|
3861
|
+
|
|
3862
|
+
.chatbot__empty-text {
|
|
3863
|
+
font-size: 13px;
|
|
3864
|
+
}
|
|
3865
|
+
|
|
3866
|
+
.chatbot__message {
|
|
3867
|
+
display: flex;
|
|
3868
|
+
flex-direction: column;
|
|
3869
|
+
max-width: 100%;
|
|
3870
|
+
animation: chatbot-msg-in 0.3s ease-out;
|
|
3871
|
+
}
|
|
3872
|
+
|
|
3873
|
+
@keyframes chatbot-msg-in {
|
|
3874
|
+
from {
|
|
3875
|
+
opacity: 0;
|
|
3876
|
+
transform: translateY(6px);
|
|
3877
|
+
}
|
|
3878
|
+
to {
|
|
3879
|
+
opacity: 1;
|
|
3880
|
+
transform: translateY(0);
|
|
3881
|
+
}
|
|
3882
|
+
}
|
|
3883
|
+
|
|
3884
|
+
.chatbot__message--user {
|
|
3885
|
+
align-self: flex-end;
|
|
3886
|
+
align-items: flex-end;
|
|
3887
|
+
max-width: 85%;
|
|
3888
|
+
}
|
|
3889
|
+
|
|
3890
|
+
.chatbot__message--assistant {
|
|
3891
|
+
align-self: flex-start;
|
|
3892
|
+
}
|
|
3893
|
+
|
|
3894
|
+
.chatbot__message-content {
|
|
3895
|
+
line-height: 1.7;
|
|
3896
|
+
word-wrap: break-word;
|
|
3897
|
+
overflow-wrap: break-word;
|
|
3898
|
+
}
|
|
3899
|
+
|
|
3900
|
+
.chatbot__message--user .chatbot__message-content {
|
|
3901
|
+
display: inline-block;
|
|
3902
|
+
background: var(--kr-chatbot-user-bg);
|
|
3903
|
+
color: var(--kr-chatbot-user-text);
|
|
3904
|
+
padding: 10px 16px;
|
|
3905
|
+
border-radius: 20px;
|
|
3906
|
+
border-bottom-right-radius: 6px;
|
|
3907
|
+
font-size: 14px;
|
|
3908
|
+
}
|
|
3909
|
+
|
|
3910
|
+
.chatbot__message--assistant .chatbot__message-content {
|
|
3911
|
+
background: transparent;
|
|
3912
|
+
color: var(--kr-chatbot-text);
|
|
3913
|
+
padding: 0;
|
|
3914
|
+
font-size: 14px;
|
|
3915
|
+
}
|
|
3916
|
+
|
|
3917
|
+
.chatbot__message--assistant .chatbot__message-content pre {
|
|
3918
|
+
background: #1e1e1e;
|
|
3919
|
+
color: #d4d4d4;
|
|
3920
|
+
padding: 12px;
|
|
3921
|
+
border-radius: 6px;
|
|
3922
|
+
overflow-x: auto;
|
|
3923
|
+
margin: 8px 0;
|
|
3924
|
+
font-size: 13px;
|
|
3925
|
+
line-height: 1.4;
|
|
3926
|
+
}
|
|
3927
|
+
|
|
3928
|
+
.chatbot__message--assistant .chatbot__message-content code {
|
|
3929
|
+
font-family: 'SF Mono', 'Fira Code', Monaco, monospace;
|
|
3930
|
+
font-size: 13px;
|
|
3931
|
+
}
|
|
3932
|
+
|
|
3933
|
+
.chatbot__message--assistant .chatbot__message-content :not(pre) > code {
|
|
3934
|
+
background: rgba(0, 0, 0, 0.06);
|
|
3935
|
+
padding: 2px 5px;
|
|
3936
|
+
border-radius: 3px;
|
|
3937
|
+
}
|
|
3938
|
+
|
|
3939
|
+
.chatbot__message--assistant .chatbot__message-content strong {
|
|
3940
|
+
font-weight: 600;
|
|
3941
|
+
}
|
|
3942
|
+
|
|
3943
|
+
.chatbot__message--assistant .chatbot__message-content p {
|
|
3944
|
+
margin: 0 0 8px 0;
|
|
3945
|
+
}
|
|
3946
|
+
|
|
3947
|
+
.chatbot__message--assistant .chatbot__message-content p:last-child {
|
|
3948
|
+
margin-bottom: 0;
|
|
3949
|
+
}
|
|
3950
|
+
|
|
3951
|
+
/* Reasoning */
|
|
3952
|
+
.chatbot__reasoning {
|
|
3953
|
+
margin-bottom: 8px;
|
|
3954
|
+
border-radius: 6px;
|
|
3955
|
+
background: rgba(0, 0, 0, 0.03);
|
|
3956
|
+
font-size: 12px;
|
|
3957
|
+
}
|
|
3958
|
+
|
|
3959
|
+
.chatbot__reasoning summary {
|
|
3960
|
+
cursor: pointer;
|
|
3961
|
+
padding: 6px 10px;
|
|
3962
|
+
color: var(--kr-chatbot-text-secondary);
|
|
3963
|
+
font-style: italic;
|
|
3964
|
+
user-select: none;
|
|
3965
|
+
}
|
|
3966
|
+
|
|
3967
|
+
.chatbot__reasoning-content {
|
|
3968
|
+
padding: 6px 10px 10px;
|
|
3969
|
+
color: var(--kr-chatbot-text-secondary);
|
|
3970
|
+
line-height: 1.5;
|
|
3971
|
+
white-space: pre-wrap;
|
|
3972
|
+
word-wrap: break-word;
|
|
3973
|
+
}
|
|
3974
|
+
|
|
3975
|
+
/* Status */
|
|
3976
|
+
.chatbot__status {
|
|
3977
|
+
font-size: 13px;
|
|
3978
|
+
color: var(--kr-chatbot-text-secondary);
|
|
3979
|
+
font-style: italic;
|
|
3980
|
+
}
|
|
3981
|
+
|
|
3982
|
+
.chatbot__typing {
|
|
3983
|
+
display: flex;
|
|
3984
|
+
gap: 4px;
|
|
3985
|
+
padding: 4px 0;
|
|
3986
|
+
}
|
|
3987
|
+
|
|
3988
|
+
.chatbot__typing span {
|
|
3989
|
+
width: 6px;
|
|
3990
|
+
height: 6px;
|
|
3991
|
+
background: var(--kr-chatbot-text-secondary);
|
|
3992
|
+
border-radius: 50%;
|
|
3993
|
+
animation: chatbot-typing 1.4s infinite;
|
|
3994
|
+
opacity: 0.4;
|
|
3995
|
+
}
|
|
3996
|
+
|
|
3997
|
+
.chatbot__typing span:nth-child(2) {
|
|
3998
|
+
animation-delay: 0.2s;
|
|
3999
|
+
}
|
|
4000
|
+
|
|
4001
|
+
.chatbot__typing span:nth-child(3) {
|
|
4002
|
+
animation-delay: 0.4s;
|
|
4003
|
+
}
|
|
4004
|
+
|
|
4005
|
+
@keyframes chatbot-typing {
|
|
4006
|
+
0%, 60%, 100% {
|
|
4007
|
+
opacity: 0.4;
|
|
4008
|
+
transform: translateY(0);
|
|
4009
|
+
}
|
|
4010
|
+
30% {
|
|
4011
|
+
opacity: 1;
|
|
4012
|
+
transform: translateY(-4px);
|
|
4013
|
+
}
|
|
4014
|
+
}
|
|
4015
|
+
|
|
4016
|
+
/* Error */
|
|
4017
|
+
.chatbot__error {
|
|
4018
|
+
padding: 8px 16px;
|
|
4019
|
+
background: var(--kr-chatbot-error-bg);
|
|
4020
|
+
color: var(--kr-chatbot-error-text);
|
|
4021
|
+
font-size: 13px;
|
|
4022
|
+
display: flex;
|
|
4023
|
+
align-items: center;
|
|
4024
|
+
justify-content: space-between;
|
|
4025
|
+
gap: 8px;
|
|
4026
|
+
flex-shrink: 0;
|
|
4027
|
+
}
|
|
4028
|
+
|
|
4029
|
+
.chatbot__error-dismiss {
|
|
4030
|
+
background: none;
|
|
4031
|
+
border: none;
|
|
4032
|
+
color: var(--kr-chatbot-error-text);
|
|
4033
|
+
cursor: pointer;
|
|
4034
|
+
padding: 2px;
|
|
4035
|
+
display: flex;
|
|
4036
|
+
align-items: center;
|
|
4037
|
+
flex-shrink: 0;
|
|
4038
|
+
}
|
|
4039
|
+
|
|
4040
|
+
.chatbot__error-dismiss-icon {
|
|
4041
|
+
width: 14px;
|
|
4042
|
+
height: 14px;
|
|
4043
|
+
}
|
|
4044
|
+
|
|
4045
|
+
/* Footer / Input */
|
|
4046
|
+
.chatbot__footer {
|
|
4047
|
+
padding: 12px 16px 16px;
|
|
4048
|
+
flex-shrink: 0;
|
|
4049
|
+
background: white;
|
|
4050
|
+
}
|
|
4051
|
+
|
|
4052
|
+
.chatbot__input-wrapper {
|
|
4053
|
+
display: flex;
|
|
4054
|
+
align-items: center;
|
|
4055
|
+
gap: 4px;
|
|
4056
|
+
background: white;
|
|
4057
|
+
border: 1px solid var(--kr-chatbot-border);
|
|
4058
|
+
border-radius: 26px;
|
|
4059
|
+
padding: 6px;
|
|
4060
|
+
transition: border-color 0.2s, box-shadow 0.2s;
|
|
4061
|
+
}
|
|
4062
|
+
|
|
4063
|
+
.chatbot__input-wrapper:focus-within {
|
|
4064
|
+
border-color: #b0b0b0;
|
|
4065
|
+
box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.04);
|
|
4066
|
+
}
|
|
4067
|
+
|
|
4068
|
+
.chatbot__input-plus {
|
|
4069
|
+
width: 34px;
|
|
4070
|
+
height: 34px;
|
|
4071
|
+
border: none;
|
|
4072
|
+
background: transparent;
|
|
4073
|
+
color: var(--kr-chatbot-text);
|
|
4074
|
+
border-radius: 50%;
|
|
4075
|
+
cursor: pointer;
|
|
4076
|
+
display: flex;
|
|
4077
|
+
align-items: center;
|
|
4078
|
+
justify-content: center;
|
|
4079
|
+
flex-shrink: 0;
|
|
4080
|
+
font-size: 20px;
|
|
4081
|
+
font-weight: 300;
|
|
4082
|
+
transition: background 0.15s;
|
|
4083
|
+
}
|
|
4084
|
+
|
|
4085
|
+
.chatbot__input-plus:hover {
|
|
4086
|
+
background: #f8f9fc;
|
|
4087
|
+
}
|
|
4088
|
+
|
|
4089
|
+
.chatbot__input {
|
|
4090
|
+
flex: 1;
|
|
4091
|
+
border: none;
|
|
4092
|
+
outline: none;
|
|
4093
|
+
resize: none;
|
|
4094
|
+
font-family: inherit;
|
|
4095
|
+
font-size: 15px;
|
|
4096
|
+
line-height: 1.5;
|
|
4097
|
+
padding: 4px 0;
|
|
4098
|
+
min-height: 26px;
|
|
4099
|
+
max-height: 120px;
|
|
4100
|
+
background: transparent;
|
|
4101
|
+
color: var(--kr-chatbot-text);
|
|
4102
|
+
}
|
|
4103
|
+
|
|
4104
|
+
.chatbot__input::placeholder {
|
|
4105
|
+
color: #b0b0b0;
|
|
4106
|
+
}
|
|
4107
|
+
|
|
4108
|
+
.chatbot__send {
|
|
4109
|
+
width: 34px;
|
|
4110
|
+
height: 34px;
|
|
4111
|
+
border-radius: 50%;
|
|
4112
|
+
background: var(--kr-chatbot-primary);
|
|
4113
|
+
color: white;
|
|
4114
|
+
border: none;
|
|
4115
|
+
cursor: pointer;
|
|
4116
|
+
display: flex;
|
|
4117
|
+
align-items: center;
|
|
4118
|
+
justify-content: center;
|
|
4119
|
+
flex-shrink: 0;
|
|
4120
|
+
transition: all 0.15s;
|
|
4121
|
+
}
|
|
4122
|
+
|
|
4123
|
+
.chatbot__send:hover {
|
|
4124
|
+
background: var(--kr-chatbot-primary-hover);
|
|
4125
|
+
}
|
|
4126
|
+
|
|
4127
|
+
.chatbot__send--disabled {
|
|
4128
|
+
opacity: 0.4;
|
|
4129
|
+
cursor: default;
|
|
4130
|
+
}
|
|
4131
|
+
|
|
4132
|
+
.chatbot__send--disabled:hover {
|
|
4133
|
+
background: var(--kr-chatbot-primary);
|
|
4134
|
+
}
|
|
4135
|
+
|
|
4136
|
+
.chatbot__send-icon {
|
|
4137
|
+
width: 16px;
|
|
4138
|
+
height: 16px;
|
|
4139
|
+
}
|
|
4140
|
+
|
|
4141
|
+
.chatbot__stop {
|
|
4142
|
+
width: 34px;
|
|
4143
|
+
height: 34px;
|
|
4144
|
+
border-radius: 50%;
|
|
4145
|
+
background: var(--kr-chatbot-error-text);
|
|
4146
|
+
color: white;
|
|
4147
|
+
border: none;
|
|
4148
|
+
cursor: pointer;
|
|
4149
|
+
display: flex;
|
|
4150
|
+
align-items: center;
|
|
4151
|
+
justify-content: center;
|
|
4152
|
+
flex-shrink: 0;
|
|
4153
|
+
transition: all 0.15s;
|
|
4154
|
+
}
|
|
4155
|
+
|
|
4156
|
+
.chatbot__stop:hover {
|
|
4157
|
+
background: #b91c1c;
|
|
4158
|
+
}
|
|
4159
|
+
|
|
4160
|
+
.chatbot__stop-icon {
|
|
4161
|
+
width: 14px;
|
|
4162
|
+
height: 14px;
|
|
4163
|
+
}
|
|
4164
|
+
|
|
4165
|
+
/* Header drag cursor */
|
|
4166
|
+
.chatbot__header {
|
|
4167
|
+
cursor: grab;
|
|
4168
|
+
user-select: none;
|
|
4169
|
+
}
|
|
4170
|
+
|
|
4171
|
+
.chatbot__header:active {
|
|
4172
|
+
cursor: grabbing;
|
|
4173
|
+
}
|
|
4174
|
+
|
|
4175
|
+
/* Drag / Resize states */
|
|
4176
|
+
.chatbot__panel--dragging,
|
|
4177
|
+
.chatbot__panel--resizing {
|
|
4178
|
+
transition: none;
|
|
4179
|
+
user-select: none;
|
|
4180
|
+
}
|
|
4181
|
+
|
|
4182
|
+
.chatbot__panel--dragging {
|
|
4183
|
+
box-shadow: 0 32px 96px rgba(0, 0, 0, 0.18), 0 12px 40px rgba(0, 0, 0, 0.1);
|
|
4184
|
+
}
|
|
4185
|
+
|
|
4186
|
+
/* Resize handles */
|
|
4187
|
+
.chatbot__resize {
|
|
4188
|
+
position: absolute;
|
|
4189
|
+
z-index: 10;
|
|
4190
|
+
}
|
|
4191
|
+
|
|
4192
|
+
.chatbot__resize--n { top: -4px; left: 12px; right: 12px; height: 8px; cursor: n-resize; }
|
|
4193
|
+
.chatbot__resize--s { bottom: -4px; left: 12px; right: 12px; height: 8px; cursor: s-resize; }
|
|
4194
|
+
.chatbot__resize--w { left: -4px; top: 12px; bottom: 12px; width: 8px; cursor: w-resize; }
|
|
4195
|
+
.chatbot__resize--e { right: -4px; top: 12px; bottom: 12px; width: 8px; cursor: e-resize; }
|
|
4196
|
+
.chatbot__resize--nw { top: -4px; left: -4px; width: 16px; height: 16px; cursor: nw-resize; }
|
|
4197
|
+
.chatbot__resize--ne { top: -4px; right: -4px; width: 16px; height: 16px; cursor: ne-resize; }
|
|
4198
|
+
.chatbot__resize--sw { bottom: -4px; left: -4px; width: 16px; height: 16px; cursor: sw-resize; }
|
|
4199
|
+
.chatbot__resize--se { bottom: -4px; right: -4px; width: 16px; height: 16px; cursor: se-resize; }
|
|
4200
|
+
|
|
4201
|
+
.chatbot__resize--se::after {
|
|
4202
|
+
content: '';
|
|
4203
|
+
position: absolute;
|
|
4204
|
+
bottom: 7px;
|
|
4205
|
+
right: 7px;
|
|
4206
|
+
width: 10px;
|
|
4207
|
+
height: 10px;
|
|
4208
|
+
border-right: 2px solid rgba(0, 0, 0, 0.12);
|
|
4209
|
+
border-bottom: 2px solid rgba(0, 0, 0, 0.12);
|
|
4210
|
+
border-radius: 0 0 3px 0;
|
|
4211
|
+
}
|
|
4212
|
+
`;
|
|
4213
|
+
__decorate([
|
|
4214
|
+
n({ attribute: false })
|
|
4215
|
+
], exports.Chatbot.prototype, "send", void 0);
|
|
4216
|
+
__decorate([
|
|
4217
|
+
n({ attribute: false })
|
|
4218
|
+
], exports.Chatbot.prototype, "clear", void 0);
|
|
4219
|
+
__decorate([
|
|
4220
|
+
n({ attribute: false })
|
|
4221
|
+
], exports.Chatbot.prototype, "messages", void 0);
|
|
4222
|
+
__decorate([
|
|
4223
|
+
n({ type: String })
|
|
4224
|
+
], exports.Chatbot.prototype, "title", void 0);
|
|
4225
|
+
__decorate([
|
|
4226
|
+
n({ type: String })
|
|
4227
|
+
], exports.Chatbot.prototype, "subtitle", void 0);
|
|
4228
|
+
__decorate([
|
|
4229
|
+
n({ type: String })
|
|
4230
|
+
], exports.Chatbot.prototype, "placeholder", void 0);
|
|
4231
|
+
__decorate([
|
|
4232
|
+
n({ type: Boolean, reflect: true })
|
|
4233
|
+
], exports.Chatbot.prototype, "opened", void 0);
|
|
4234
|
+
__decorate([
|
|
4235
|
+
r()
|
|
4236
|
+
], exports.Chatbot.prototype, "_inputValue", void 0);
|
|
4237
|
+
__decorate([
|
|
4238
|
+
r()
|
|
4239
|
+
], exports.Chatbot.prototype, "_isStreaming", void 0);
|
|
4240
|
+
__decorate([
|
|
4241
|
+
r()
|
|
4242
|
+
], exports.Chatbot.prototype, "_statusText", void 0);
|
|
4243
|
+
__decorate([
|
|
4244
|
+
r()
|
|
4245
|
+
], exports.Chatbot.prototype, "_error", void 0);
|
|
4246
|
+
__decorate([
|
|
4247
|
+
e$3('.chatbot__panel')
|
|
4248
|
+
], exports.Chatbot.prototype, "_panelEl", void 0);
|
|
4249
|
+
__decorate([
|
|
4250
|
+
e$3('.chatbot__messages')
|
|
4251
|
+
], exports.Chatbot.prototype, "_messagesEl", void 0);
|
|
4252
|
+
__decorate([
|
|
4253
|
+
e$3('.chatbot__input')
|
|
4254
|
+
], exports.Chatbot.prototype, "_inputEl", void 0);
|
|
4255
|
+
exports.Chatbot = __decorate([
|
|
4256
|
+
t$1('kr-chatbot')
|
|
4257
|
+
], exports.Chatbot);
|
|
4258
|
+
|
|
2931
4259
|
exports.Router = KRRouter;
|
|
2932
4260
|
|
|
2933
4261
|
}));
|