@hidemikimura/chit-ui 0.2.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/CHANGELOG.md +59 -0
  2. package/README.md +148 -3
  3. package/dist/chit-ui.iife.min.js +218 -99
  4. package/dist/chit-ui.iife.min.js.map +1 -1
  5. package/dist/chit-ui.min.js +209 -90
  6. package/dist/chit-ui.min.js.map +1 -1
  7. package/dist/types/chit-ui.d.ts +64 -4
  8. package/dist/types/controllers/composer-controller.d.ts +4 -0
  9. package/dist/types/controllers/drag-controller.d.ts +118 -0
  10. package/dist/types/controllers/scroll-lock-controller.d.ts +37 -0
  11. package/dist/types/controllers/viewport-controller.d.ts +38 -0
  12. package/dist/types/events.d.ts +1 -0
  13. package/dist/types/global.d.ts +7 -1
  14. package/dist/types/i18n/labels.d.ts +8 -0
  15. package/dist/types/index.d.ts +162 -0
  16. package/dist/types/render/message-list.d.ts +0 -1
  17. package/dist/types/theme/default-theme.d.ts +8 -0
  18. package/dist/types/types.d.ts +40 -0
  19. package/package.json +1 -1
  20. package/src/chit-ui.js +261 -4
  21. package/src/controllers/composer-controller.js +2 -0
  22. package/src/controllers/drag-controller.js +319 -0
  23. package/src/controllers/scroll-controller.js +21 -1
  24. package/src/controllers/scroll-lock-controller.js +185 -0
  25. package/src/controllers/viewport-controller.js +102 -0
  26. package/src/events.js +1 -0
  27. package/src/global.d.ts +7 -1
  28. package/src/i18n/labels.js +6 -0
  29. package/src/index.js +34 -0
  30. package/src/render/launcher.js +9 -1
  31. package/src/render/message-list.js +40 -10
  32. package/src/render/panel.js +17 -1
  33. package/src/styles/composer.css.js +18 -0
  34. package/src/styles/launcher.css.js +13 -0
  35. package/src/styles/message.css.js +60 -15
  36. package/src/styles/panel.css.js +30 -3
  37. package/src/theme/default-theme.js +16 -0
  38. package/src/types.js +18 -0
@@ -1 +1 @@
1
- {"version":3,"file":"chit-ui.min.js","sources":["../node_modules/@lit/reactive-element/css-tag.js","../node_modules/@lit/reactive-element/reactive-element.js","../node_modules/lit-html/lit-html.js","../node_modules/lit-element/lit-element.js","../node_modules/lit-html/directive.js","../node_modules/lit-html/directives/unsafe-html.js","../src/events.js","../src/controllers/state-controller.js","../src/controllers/breakpoint-controller.js","../src/theme/default-theme.js","../src/theme/merge-theme.js","../src/theme/theme-to-css.js","../src/styles/adopted-sheet.js","../src/controllers/theme-controller.js","../src/controllers/scroll-controller.js","../src/controllers/composer-controller.js","../src/render/content.js","../src/render/launcher.js","../node_modules/lit-html/directive-helpers.js","../node_modules/lit-html/directives/repeat.js","../src/render/message.js","../node_modules/lit-html/directives/live.js","../src/render/composer.js","../src/render/panel.js","../src/render/message-list.js","../src/i18n/labels.js","../src/styles/host.css.js","../src/styles/launcher.css.js","../src/styles/panel.css.js","../src/styles/message.css.js","../src/styles/content.css.js","../src/styles/composer.css.js","../src/chit-ui.js","../src/index.js","../src/themes/green.js","../node_modules/lit-html/directives/class-map.js","../node_modules/lit-html/directives/style-map.js"],"sourcesContent":["/**\n * @license\n * Copyright 2019 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\nconst t=globalThis,e=t.ShadowRoot&&(void 0===t.ShadyCSS||t.ShadyCSS.nativeShadow)&&\"adoptedStyleSheets\"in Document.prototype&&\"replace\"in CSSStyleSheet.prototype,s=Symbol(),o=new WeakMap;class n{constructor(t,e,o){if(this._$cssResult$=!0,o!==s)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&&void 0===t){const e=void 0!==s&&1===s.length;e&&(t=o.get(s)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),e&&o.set(s,t))}return t}toString(){return this.cssText}}const r=t=>new n(\"string\"==typeof t?t:t+\"\",void 0,s),i=(t,...e)=>{const o=1===t.length?t[0]:e.reduce((e,s,o)=>e+(t=>{if(!0===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(o,t,s)},S=(s,o)=>{if(e)s.adoptedStyleSheets=o.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet);else for(const e of o){const o=document.createElement(\"style\"),n=t.litNonce;void 0!==n&&o.setAttribute(\"nonce\",n),o.textContent=e.cssText,s.appendChild(o)}},c=e?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e=\"\";for(const s of t.cssRules)e+=s.cssText;return r(e)})(t):t;export{n as CSSResult,S as adoptStyles,i as css,c as getCompatibleStyle,e as supportsAdoptingStyleSheets,r as unsafeCSS};\n//# sourceMappingURL=css-tag.js.map\n","import{getCompatibleStyle as t,adoptStyles as s}from\"./css-tag.js\";export{CSSResult,css,supportsAdoptingStyleSheets,unsafeCSS}from\"./css-tag.js\";\n/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */const{is:i,defineProperty:e,getOwnPropertyDescriptor:h,getOwnPropertyNames:r,getOwnPropertySymbols:o,getPrototypeOf:n}=Object,a=globalThis,c=a.trustedTypes,l=c?c.emptyScript:\"\",p=a.reactiveElementPolyfillSupport,d=(t,s)=>t,u={toAttribute(t,s){switch(s){case Boolean:t=t?l: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=(t,s)=>!i(t,s),b={attribute:!0,type:String,converter:u,reflect:!1,useDefault:!1,hasChanged:f};Symbol.metadata??=Symbol(\"metadata\"),a.litPropertyMetadata??=new WeakMap;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){if(s.state&&(s.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(t)&&((s=Object.create(s)).wrapped=!0),this.elementProperties.set(t,s),!s.noAccessor){const i=Symbol(),h=this.getPropertyDescriptor(t,i,s);void 0!==h&&e(this.prototype,t,h)}}static getPropertyDescriptor(t,s,i){const{get:e,set:r}=h(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:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??b}static _$Ei(){if(this.hasOwnProperty(d(\"elementProperties\")))return;const t=n(this);t.finalize(),void 0!==t.l&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(d(\"finalized\")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(d(\"properties\"))){const t=this.properties,s=[...r(t),...o(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(t(s))}else void 0!==s&&i.push(t(s));return i}static _$Eu(t,s){const i=s.attribute;return!1===i?void 0:\"string\"==typeof i?i:\"string\"==typeof t?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,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(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),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&&!0===i.reflect){const h=(void 0!==i.converter?.toAttribute?i.converter:u).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;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=!1,h){if(void 0!==t){const r=this.constructor;if(!1===e&&(h=this[t]),i??=r.getPropertyOptions(t),!((i.hasChanged??f)(h,s)||i.useDefault&&i.reflect&&h===this._$Ej?.get(t)&&!this.hasAttribute(r._$Eu(t,i))))return;this.C(t,s,i)}!1===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]),!0!==h||void 0!==r)||(this._$AL.has(t)||(this.hasUpdated||i||(s=void 0),this._$AL.set(t,s)),!0===e&&this._$Em!==t&&(this._$Eq??=new Set).add(t))}async _$EP(){this.isUpdatePending=!0;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];!0!==t||this._$AL.has(s)||void 0===e||this.C(s,void 0,i,e)}}let t=!1;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=!1,this._$EM(),s}t&&this._$AE(s)}willUpdate(t){}_$AE(t){this._$EO?.forEach(t=>t.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Eq&&=this._$Eq.forEach(t=>this._$ET(t,this[t])),this._$EM()}updated(t){}firstUpdated(t){}}y.elementStyles=[],y.shadowRootOptions={mode:\"open\"},y[d(\"elementProperties\")]=new Map,y[d(\"finalized\")]=new Map,p?.({ReactiveElement:y}),(a.reactiveElementVersions??=[]).push(\"2.1.2\");export{y as ReactiveElement,s as adoptStyles,u as defaultConverter,t as getCompatibleStyle,f as notEqual};\n//# sourceMappingURL=reactive-element.js.map\n","/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\nconst t=globalThis,i=t=>t,s=t.trustedTypes,e=s?s.createPolicy(\"lit-html\",{createHTML:t=>t}):void 0,h=\"$lit$\",o=`lit$${Math.random().toFixed(9).slice(2)}$`,n=\"?\"+o,r=`<${n}>`,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),w=x(2),T=x(3),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?e.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:d>=0?(e.push(a),s.slice(0,d)+h+s.slice(d)+o+x):s+o+(-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),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)&&(d.push({type:6,index:l}),r.removeAttribute(t));if(y.test(r.tagName)){const t=r.textContent.split(o),i=t.length-1;if(i>0){r.textContent=s?s.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)d.push({type:2,index:l});else{let t=-1;for(;-1!==(t=r.data.indexOf(o,t+1));)d.push({type:7,index:l}),t+=o.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?.(!1),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,!0);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??!0}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?.(!1,!0,s);t!==this._$AB;){const s=i(t).nextSibling;i(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=!1;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 j={M:h,P:o,A:n,C:1,L:N,R,D:d,V:M,I:k,H,N:L,U:z,B:I,F:Z},B=t.litHtmlPolyfillSupport;B?.(S,k),(t.litHtmlVersions??=[]).push(\"3.3.3\");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};export{j as _$LH,b as html,T as mathml,E as noChange,A as nothing,D as render,w as svg};\n//# sourceMappingURL=lit-html.js.map\n","import{ReactiveElement as t}from\"@lit/reactive-element\";export*from\"@lit/reactive-element\";import{render as e,noChange as r}from\"lit-html\";export*from\"lit-html\";\n/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */const s=globalThis;class i extends t{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){const t=super.createRenderRoot();return this.renderOptions.renderBefore??=t.firstChild,t}update(t){const r=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=e(r,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return r}}i._$litElement$=!0,i[\"finalized\"]=!0,s.litElementHydrateSupport?.({LitElement:i});const o=s.litElementPolyfillSupport;o?.({LitElement:i});const n={_$AK:(t,e,r)=>{t._$AK(e,r)},_$AL:t=>t._$AL};(s.litElementVersions??=[]).push(\"4.2.2\");export{i as LitElement,n as _$LE};\n//# sourceMappingURL=lit-element.js.map\n","/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\nconst t={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},e=t=>(...e)=>({_$litDirective$:t,values:e});class i{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,e,i){this._$Ct=t,this._$AM=e,this._$Ci=i}_$AS(t,e){return this.update(t,e)}update(t,e){return this.render(...e)}}export{i as Directive,t as PartType,e as directive};\n//# sourceMappingURL=directive.js.map\n","import{nothing as t,noChange as i}from\"../lit-html.js\";import{directive as r,Directive as s,PartType as n}from\"../directive.js\";\n/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */class e extends s{constructor(i){if(super(i),this.it=t,i.type!==n.CHILD)throw Error(this.constructor.directiveName+\"() can only be used in child bindings\")}render(r){if(r===t||null==r)return this._t=void 0,this.it=r;if(r===i)return r;if(\"string\"!=typeof r)throw Error(this.constructor.directiveName+\"() called with a non-string value\");if(r===this.it)return this._t;this.it=r;const s=[r];return s.raw=s,this._t={_$litType$:this.constructor.resultType,strings:s,values:[]}}}e.directiveName=\"unsafeHTML\",e.resultType=1;const o=r(e);export{e as UnsafeHTMLDirective,o as unsafeHTML};\n//# sourceMappingURL=unsafe-html.js.map\n","// @ts-check\n\n/** Every event this library dispatches. Never write the string literals elsewhere. */\nexport const Events = Object.freeze({\n SUBMIT: 'chat-submit',\n BEFORE_OPEN: 'chat-before-open',\n OPEN: 'chat-open',\n BEFORE_CLOSE: 'chat-before-close',\n CLOSE: 'chat-close',\n HIDE: 'chat-hide',\n SHOW: 'chat-show',\n STATE_CHANGE: 'chat-state-change',\n INPUT: 'chat-input',\n MESSAGE_RENDER: 'chat-message-render',\n MESSAGE_CLICK: 'chat-message-click',\n SCROLL_TOP: 'chat-scroll-top',\n BREAKPOINT_CHANGE: 'chat-breakpoint-change',\n HOME: 'chat-home',\n ATTACH: 'chat-attach',\n});\n\n/**\n * Dispatch a composed, bubbling CustomEvent from the host.\n *\n * @param {HTMLElement} host\n * @param {string} name\n * @param {unknown} detail\n * @param {{ cancelable?: boolean }} [options]\n * @returns {boolean} false when a listener called preventDefault().\n */\nexport function emit(host, name, detail, { cancelable = false } = {}) {\n return host.dispatchEvent(\n new CustomEvent(name, { detail, bubbles: true, composed: true, cancelable }),\n );\n}\n","// @ts-check\nimport { Events, emit } from '../events.js';\n\n/** @import { ReactiveController, LitElement } from 'lit' */\n/** @import { ChatState, Trigger, Effect } from '../types.js' */\n\n/**\n * @typedef {{ effect: Effect, duration: number }} AnimationSpec\n * @typedef {(from: ChatState, to: ChatState, phase: 'enter' | 'exit') => AnimationSpec} AnimationResolver\n *\n * @typedef {Object} StateControllerOptions\n * @property {AnimationResolver} animation Which effect and duration to play.\n * @property {() => boolean} keepsLauncher True when the launcher stays visible behind an open panel.\n * @property {() => void} onOpened Called once the panel is open and settled.\n */\n\n/** Which `part` carries the visible element of each state. */\nconst PART_FOR_STATE = /** @type {const} */ ({\n closed: 'launcher',\n open: 'panel',\n hidden: null,\n});\n\n/**\n * Owns everything about moving between closed / open / hidden.\n *\n * The host's `state` property changes the instant it is assigned; what the DOM\n * shows lags behind it for as long as the transition animation runs. That\n * lagging value is `renderedState`, and the render functions key off it — so a\n * panel animating out is still in the DOM while `state` already reads 'closed'.\n *\n * @implements {ReactiveController}\n */\nexport class StateController {\n /** @type {LitElement & { state: ChatState }} */\n #host;\n /** @type {AnimationResolver} */\n #resolveAnimation;\n /** @type {() => boolean} */\n #keepsLauncher;\n /** @type {() => void} */\n #onOpened;\n\n /** Logical state: the target of the most recent transition. */\n #current = /** @type {ChatState} */ ('closed');\n /** What the DOM is showing right now. */\n #rendered = /** @type {ChatState} */ ('closed');\n\n /** Guards the host's own `state` setter against re-entering us. */\n #applying = false;\n /** Bumped per transition so a superseded one can bail out after an await. */\n #generation = 0;\n /** @type {((settled: boolean) => void) | null} */\n #settle = null;\n /** @type {(() => void) | null} */\n #stopWaiting = null;\n /** @type {boolean} */\n #restoreFocusToLauncher = false;\n\n /**\n * @param {LitElement & { state: ChatState }} host\n * @param {StateControllerOptions} options\n */\n constructor(host, { animation, keepsLauncher, onOpened }) {\n this.#host = host;\n this.#resolveAnimation = animation;\n this.#keepsLauncher = keepsLauncher;\n this.#onOpened = onOpened;\n host.addController(this);\n }\n\n /** @returns {ChatState} What the DOM currently shows. */\n get renderedState() {\n return this.#rendered;\n }\n\n /** @returns {boolean} True while the host's own setter must not call us back. */\n get applying() {\n return this.#applying;\n }\n\n hostConnected() {\n this.#current = this.#host.state;\n this.#rendered = this.#host.state;\n this.#host.dataset.renderedState = this.#rendered;\n }\n\n hostDisconnected() {\n this.#stopWaiting?.();\n this.#stopWaiting = null;\n this.#settle?.(false);\n this.#settle = null;\n }\n\n hostUpdated() {\n this.#host.dataset.renderedState = this.#rendered;\n }\n\n /**\n * Move to `to`, running the before-event, the animations and the completion\n * events in order.\n *\n * @param {ChatState} to\n * @param {Trigger} trigger\n * @returns {Promise<boolean>} false when a listener cancelled it, or when a\n * later transition superseded this one.\n */\n request(to, trigger) {\n const from = this.#current;\n if (to === from) return Promise.resolve(true);\n\n if (!this.#announceIntent(from, to, trigger)) {\n this.#assign(from);\n return Promise.resolve(false);\n }\n\n // A transition already in flight loses: snap the DOM to where it was\n // heading, tell its caller it did not finish, and start over from there.\n this.#interrupt();\n\n this.#current = to;\n this.#assign(to);\n emit(this.#host, Events.STATE_CHANGE, { from, to, trigger });\n\n return this.#run(from, to, trigger);\n }\n\n /**\n * Fire the cancelable before-event for this transition, if it has one.\n *\n * @param {ChatState} from\n * @param {ChatState} to\n * @param {Trigger} trigger\n * @returns {boolean} false when a listener called preventDefault().\n */\n #announceIntent(from, to, trigger) {\n if (to === 'open') {\n return emit(this.#host, Events.BEFORE_OPEN, { from, trigger }, { cancelable: true });\n }\n if (to === 'closed' && from === 'open') {\n return emit(this.#host, Events.BEFORE_CLOSE, { from, trigger }, { cancelable: true });\n }\n return true;\n }\n\n #interrupt() {\n this.#generation += 1;\n this.#stopWaiting?.();\n this.#stopWaiting = null;\n this.#settle?.(false);\n this.#settle = null;\n if (this.#rendered !== this.#current) {\n this.#rendered = this.#current;\n this.#host.requestUpdate();\n }\n }\n\n /**\n * @param {ChatState} from\n * @param {ChatState} to\n * @param {Trigger} trigger\n * @returns {Promise<boolean>}\n */\n #run(from, to, trigger) {\n const generation = this.#generation;\n /** @type {Promise<boolean>} */\n const settled = new Promise((resolve) => {\n this.#settle = resolve;\n });\n\n void (async () => {\n this.#restoreFocusToLauncher = this.#focusIsInsidePanel();\n await this.#host.updateComplete;\n if (generation !== this.#generation) return;\n\n const leaving = this.#elementFor(from);\n if (leaving && !this.#launcherSurvives(from, to)) {\n await this.#animate(leaving, 'exit', this.#resolveAnimation(from, to, 'exit'));\n if (generation !== this.#generation) return;\n }\n\n this.#rendered = to;\n this.#host.requestUpdate();\n await this.#host.updateComplete;\n if (generation !== this.#generation) return;\n\n const arriving = this.#elementFor(to);\n if (arriving) {\n await this.#animate(arriving, 'enter', this.#resolveAnimation(from, to, 'enter'));\n if (generation !== this.#generation) return;\n }\n\n this.#announceArrival(from, to, trigger);\n this.#manageFocus(to);\n\n this.#settle?.(true);\n this.#settle = null;\n })();\n\n return settled;\n }\n\n /**\n * Whether the element of `from` survives the transition and so must not play\n * an exit animation. Only the launcher can, and only when the theme asks to\n * keep it visible behind an open panel.\n *\n * @param {ChatState} from\n * @param {ChatState} to\n * @returns {boolean}\n */\n #launcherSurvives(from, to) {\n return from === 'closed' && to === 'open' && this.#keepsLauncher();\n }\n\n /**\n * @param {ChatState} from\n * @param {ChatState} to\n * @param {Trigger} trigger\n */\n #announceArrival(from, to, trigger) {\n if (from === 'hidden') emit(this.#host, Events.SHOW, { from, to });\n if (to === 'hidden') {\n emit(this.#host, Events.HIDE, { from, to });\n return;\n }\n if (to === 'open') emit(this.#host, Events.OPEN, { from, trigger });\n else if (to === 'closed' && from === 'open') emit(this.#host, Events.CLOSE, { from, trigger });\n }\n\n /** @param {ChatState} to */\n #manageFocus(to) {\n if (to === 'open') {\n this.#onOpened();\n return;\n }\n if (to === 'closed' && this.#restoreFocusToLauncher) {\n this.#elementFor('closed')?.focus();\n }\n this.#restoreFocusToLauncher = false;\n }\n\n #focusIsInsidePanel() {\n const active = this.#host.renderRoot instanceof ShadowRoot\n ? this.#host.renderRoot.activeElement\n : null;\n const panel = this.#elementFor('open');\n return !!(active && panel && (active === panel || panel.contains(active)));\n }\n\n /**\n * @param {ChatState} state\n * @returns {HTMLElement | null}\n */\n #elementFor(state) {\n const part = PART_FOR_STATE[state];\n if (!part) return null;\n return /** @type {HTMLElement | null} */ (\n this.#host.renderRoot.querySelector(`[part~=\"${part}\"]`)\n );\n }\n\n /**\n * Assign the host's `state` without the setter calling us back.\n *\n * @param {ChatState} state\n */\n #assign(state) {\n if (this.#host.state === state) return;\n this.#applying = true;\n this.#host.state = state;\n this.#applying = false;\n }\n\n /**\n * Play one CSS animation and resolve when it ends. Resolves immediately when\n * there is nothing to play; falls back to a timer in case `animationend`\n * never arrives (a backgrounded tab, a display:none ancestor).\n *\n * @param {HTMLElement} element\n * @param {'enter' | 'exit'} phase\n * @param {AnimationSpec} spec\n * @returns {Promise<void>}\n */\n #animate(element, phase, spec) {\n const { effect, duration } = spec;\n const skip =\n effect === 'none' ||\n duration <= 0 ||\n window.matchMedia('(prefers-reduced-motion: reduce)').matches;\n if (skip) return Promise.resolve();\n\n return new Promise((resolve) => {\n let finished = false;\n /** @param {Event} [event] */\n const finish = (event) => {\n if (event && event.target !== element) return;\n if (finished) return;\n finished = true;\n clearTimeout(timer);\n element.removeEventListener('animationend', finish);\n element.removeAttribute('data-anim');\n element.style.removeProperty('--_chit-anim-duration');\n if (this.#stopWaiting === finish) this.#stopWaiting = null;\n resolve();\n };\n\n element.dataset.effect = effect;\n element.dataset.anim = phase;\n element.style.setProperty('--_chit-anim-duration', `${duration}ms`);\n element.addEventListener('animationend', finish);\n const timer = setTimeout(finish, duration + 50);\n this.#stopWaiting = finish;\n });\n }\n}\n","// @ts-check\nimport { Events, emit } from '../events.js';\n\n/** @import { ReactiveController, LitElement } from 'lit' */\n/** @import { Device } from '../types.js' */\n\n/**\n * Tracks whether the viewport is narrow enough to count as a phone.\n *\n * Uses matchMedia rather than a resize listener: it only fires when the\n * boundary is actually crossed, so nothing runs while the user drags a window\n * around inside one bucket.\n *\n * @implements {ReactiveController}\n */\nexport class BreakpointController {\n /** @type {LitElement} */\n #host;\n /** @type {MediaQueryList | null} */\n #query = null;\n /** @type {number} */\n #breakpoint = 0;\n /** @type {Device} */\n #device = 'pc';\n /** Set once the first measurement is in, so start-up is not a \"change\". */\n #measured = false;\n\n /** @param {LitElement} host */\n constructor(host) {\n this.#host = host;\n host.addController(this);\n }\n\n /** @returns {Device} */\n get device() {\n return this.#device;\n }\n\n hostDisconnected() {\n this.#query?.removeEventListener('change', this.#onChange);\n this.#query = null;\n }\n\n /**\n * Point the controller at a breakpoint. Safe to call on every update; the\n * media query is only rebuilt when the value actually changes.\n *\n * @param {number} breakpoint\n */\n observe(breakpoint) {\n if (breakpoint === this.#breakpoint && this.#query) return;\n this.#breakpoint = breakpoint;\n this.#query?.removeEventListener('change', this.#onChange);\n this.#query = window.matchMedia(`(max-width: ${breakpoint - 1}px)`);\n this.#query.addEventListener('change', this.#onChange);\n this.#apply(this.#query.matches ? 'mobile' : 'pc');\n }\n\n /** @param {MediaQueryListEvent} event */\n #onChange = (event) => {\n this.#apply(event.matches ? 'mobile' : 'pc');\n };\n\n /**\n * Record the device and announce it, unless this is the first measurement —\n * start-up is not a change. A later flip is announced whether it came from\n * the viewport resizing or from the theme moving the breakpoint, because\n * either way the answer a consumer asked for is now different.\n *\n * @param {Device} device\n */\n #apply(device) {\n if (device === this.#device && this.#host.dataset.device) return;\n\n this.#device = device;\n this.#host.dataset.device = device;\n this.#host.requestUpdate();\n\n if (this.#measured) emit(this.#host, Events.BREAKPOINT_CHANGE, { device });\n this.#measured = true;\n }\n}\n","// @ts-check\n\n/** @import { ResolvedClosed } from '../types.js' */\n\n/**\n * Neutral light palette. Every text/background pair here clears WCAG AA\n * (4.5:1); `test/theme.test.js` re-checks the ratios so a future tweak cannot\n * quietly drop below it.\n */\nconst PALETTE = {\n accent: '#2563eb',\n ink: '#1f2328',\n muted: '#5c6370',\n surface: '#ffffff',\n raised: '#f1f3f5',\n line: '#e4e4e7',\n onAccent: '#ffffff',\n};\n\n/** @type {ResolvedClosed} */\nconst CLOSED_PC = {\n size: 60,\n position: 'bottom-right',\n offset: { x: 24, y: 24 },\n radius: 30,\n image: null,\n label: null,\n component: null,\n props: {},\n colors: {\n background: PALETTE.accent,\n text: PALETTE.onAccent,\n shadow: '0 4px 12px rgba(0, 0, 0, 0.2)',\n },\n animation: { enter: 'scale', exit: 'scale', duration: 200, idle: 'none' },\n};\n\n/**\n * What a phone gets when the theme does not say. Only the measurements differ:\n * a thumb needs a slightly smaller target closer to the screen edge.\n *\n * @type {Partial<ResolvedClosed>}\n */\nconst CLOSED_MOBILE_DIFF = {\n size: 56,\n offset: { x: 16, y: 16 },\n radius: 28,\n};\n\n/**\n * The library's own theme. A user theme is merged over this, so everything\n * here is what you get when the user says nothing at all.\n *\n * `closed` carries both device buckets; `mergeTheme` narrows it to one.\n */\nexport const defaultTheme = {\n breakpoint: 768,\n zIndex: 2147483000,\n font: {\n family:\n \"system-ui, -apple-system, 'Segoe UI', 'Hiragino Sans', 'Noto Sans JP', sans-serif\",\n size: 14,\n },\n closed: {\n pc: CLOSED_PC,\n mobile: /** @type {ResolvedClosed} */ ({ ...CLOSED_PC, ...CLOSED_MOBILE_DIFF }),\n },\n open: {\n width: 380,\n height: 600,\n position: /** @type {const} */ ('bottom-right'),\n offset: { x: 24, y: 24 },\n radius: 16,\n launcher: /** @type {const} */ ('hidden'),\n header: { visible: true, title: null, logo: null, home: false },\n background: { image: null },\n colors: {\n background: PALETTE.surface,\n text: PALETTE.ink,\n accent: PALETTE.accent,\n border: PALETTE.line,\n shadow: '0 8px 32px rgba(0, 0, 0, 0.24)',\n headerBackground: PALETTE.surface,\n headerText: PALETTE.ink,\n userBubble: PALETTE.accent,\n userText: PALETTE.onAccent,\n assistantBubble: PALETTE.raised,\n assistantText: PALETTE.ink,\n systemText: PALETTE.muted,\n inputBackground: PALETTE.surface,\n inputText: PALETTE.ink,\n inputPlaceholder: PALETTE.muted,\n },\n // No tail by default: the squared-off corner on the speaker's side is\n // enough to show who is talking, and a tail is a strong look to impose on\n // a widget that has to sit in someone else's page.\n bubble: { radius: 14, tail: /** @type {const} */ ('none') },\n // Who is talking. Nothing by default: a widget that invents a name and a\n // face for the consumer's support desk would be guessing.\n speaker: {\n assistant: { name: null, avatar: null },\n user: { name: null, avatar: null },\n },\n animation: {\n enter: /** @type {const} */ ('scale'),\n exit: /** @type {const} */ ('fade'),\n duration: 150,\n // How the conversation follows a new message. Growth within a message\n // (a streamed reply, an image loading) is always instant; see\n // ScrollController for why.\n scroll: /** @type {const} */ ('smooth'),\n },\n // `attach` is off by default: a widget that offers to take files when\n // nothing is listening for them would be promising something it cannot\n // keep. `accept` and `multiple` go straight to the file input.\n input: {\n maxRows: 5,\n placeholder: null,\n attach: false,\n accept: 'image/*,video/*',\n multiple: false,\n },\n },\n hidden: {\n animation: { exit: /** @type {const} */ ('fade'), duration: 150 },\n },\n};\n\n/** The measurements a phone falls back to when only `closed.pc` was given. */\nexport const mobileClosedDefaults = CLOSED_MOBILE_DIFF;\n","// @ts-check\nimport { defaultTheme, mobileClosedDefaults } from './default-theme.js';\n\n/** @import { Theme, ClosedTheme, Device, ResolvedTheme } from '../types.js' */\n\n/**\n * @param {unknown} value\n * @returns {value is Record<string, unknown>}\n */\nfunction isPlainObject(value) {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\n/**\n * Merge `override` onto `base`, recursing into plain objects.\n *\n * `undefined` means \"say nothing\" and leaves the base value alone; `null` means\n * \"clear it\", so `{ image: null }` removes a default icon rather than being\n * ignored. There are no arrays anywhere in a theme, so a plain recursive merge\n * is enough.\n *\n * @template {Record<string, any>} T\n * @param {T} base\n * @param {Record<string, any> | undefined} override\n * @returns {T}\n */\nexport function mergeTheme(base, override) {\n if (!isPlainObject(override)) return base;\n\n /** @type {Record<string, any>} */\n const out = { ...base };\n for (const [key, value] of Object.entries(override)) {\n if (value === undefined) continue;\n const current = out[key];\n out[key] = isPlainObject(value) && isPlainObject(current) ? mergeTheme(current, value) : value;\n }\n return /** @type {T} */ (out);\n}\n\n/**\n * Decide which `closed` settings this device gets.\n *\n * Three shapes are allowed, and this is where they collapse into one:\n * no pc/mobile keys at all (the same settings serve both), both given, or only\n * one given. When only `pc` is given the phone inherits it but keeps the\n * default phone measurements, so a custom icon carries over without a\n * desktop-sized button landing on a phone.\n *\n * @param {ClosedTheme | { pc?: ClosedTheme, mobile?: ClosedTheme } | undefined} closed\n * @param {Device} device\n * @returns {ClosedTheme}\n */\nfunction resolveClosed(closed, device) {\n const perDevice = /** @type {{ pc?: ClosedTheme, mobile?: ClosedTheme }} */ (closed ?? {});\n const split = 'pc' in perDevice || 'mobile' in perDevice;\n\n if (!split) {\n const shared = /** @type {ClosedTheme} */ (closed ?? {});\n return mergeTheme(defaultTheme.closed[device], shared);\n }\n\n const pc = mergeTheme(defaultTheme.closed.pc, perDevice.pc);\n if (device === 'pc') return pc;\n\n if (perDevice.mobile) return mergeTheme(defaultTheme.closed.mobile, perDevice.mobile);\n return mergeTheme(pc, mobileClosedDefaults);\n}\n\n/**\n * Fill every gap in a user theme and narrow it to one device.\n *\n * @param {Theme | undefined} theme\n * @param {Device} device\n * @returns {ResolvedTheme}\n */\nexport function resolveTheme(theme, device) {\n const user = theme ?? {};\n const closed = resolveClosed(user.closed, device);\n\n return /** @type {ResolvedTheme} */ ({\n breakpoint: user.breakpoint ?? defaultTheme.breakpoint,\n zIndex: user.zIndex ?? defaultTheme.zIndex,\n font: mergeTheme(defaultTheme.font, user.font),\n closed: mergeTheme(defaultTheme.closed[device], closed),\n open: mergeTheme(defaultTheme.open, user.open),\n hidden: mergeTheme(defaultTheme.hidden, user.hidden),\n device,\n });\n}\n\n/**\n * The breakpoint a theme asks for, readable before the full resolve (the\n * device is not known until the breakpoint is).\n *\n * @param {Theme | undefined} theme\n * @returns {number}\n */\nexport function breakpointOf(theme) {\n return theme?.breakpoint ?? defaultTheme.breakpoint;\n}\n","// @ts-check\n\n/** @import { ResolvedTheme } from '../types.js' */\n\n/**\n * @param {number} value\n * @returns {string}\n */\nconst px = (value) => `${value}px`;\n\n/**\n * A CSS `url()` for an image, or `none`. Quotes and backslashes are escaped so\n * a filename with an apostrophe cannot break out of the declaration.\n *\n * @param {string | null | undefined} value\n * @returns {string}\n */\nfunction url(value) {\n if (!value) return 'none';\n return `url(\"${value.replace(/[\\\\\"]/g, '\\\\$&')}\")`;\n}\n\n/**\n * Turn a resolved theme into the custom properties the stylesheets read.\n *\n * Only values CSS can act on are here. Positions, animation effects, text and\n * images that belong in markup are applied as attributes or drawn by the\n * render functions instead.\n *\n * Animation durations are deliberately absent: the transition code has to know\n * when an animation ends, so the theme is the single source of truth for them\n * and it writes the duration onto the element as it starts. A custom property\n * here would look like a knob that does nothing.\n *\n * @param {ResolvedTheme} theme\n * @returns {Record<string, string>}\n */\nexport function themeToVariables(theme) {\n const { closed, open } = theme;\n const c = open.colors;\n\n return {\n '--chit-z-index': String(theme.zIndex),\n '--chit-font-family': theme.font.family,\n '--chit-font-size': px(theme.font.size),\n\n '--chit-launcher-size': closed.size === 'auto' ? 'auto' : px(closed.size),\n '--chit-launcher-offset-x': px(closed.offset.x),\n '--chit-launcher-offset-y': px(closed.offset.y),\n '--chit-launcher-radius': px(closed.radius),\n '--chit-launcher-image': url(closed.image),\n '--chit-launcher-bg': closed.colors.background,\n '--chit-launcher-text': closed.colors.text,\n '--chit-launcher-shadow': closed.colors.shadow,\n\n '--chit-panel-width': px(open.width),\n '--chit-panel-height': px(open.height),\n '--chit-panel-offset-x': px(open.offset.x),\n '--chit-panel-offset-y': px(open.offset.y),\n '--chit-panel-radius': px(open.radius),\n '--chit-panel-bg-image': url(open.background.image),\n '--chit-panel-shadow': c.shadow,\n\n '--chit-color-bg': c.background,\n '--chit-color-text': c.text,\n '--chit-color-accent': c.accent,\n '--chit-color-border': c.border,\n '--chit-color-header-bg': c.headerBackground,\n '--chit-color-header-text': c.headerText,\n '--chit-color-user-bg': c.userBubble,\n '--chit-color-user-text': c.userText,\n '--chit-color-assistant-bg': c.assistantBubble,\n '--chit-color-assistant-text': c.assistantText,\n '--chit-color-system-text': c.systemText,\n '--chit-color-input-bg': c.inputBackground,\n '--chit-color-input-text': c.inputText,\n '--chit-color-input-placeholder': c.inputPlaceholder,\n\n '--chit-bubble-radius': px(open.bubble.radius),\n\n '--_chit-input-max-rows': String(open.input.maxRows),\n // Internal: the width the speaker's icon takes up, so the typing\n // indicator lines up with the bubbles it belongs to.\n '--_chit-speaker-gutter': open.speaker.assistant.avatar ? '2.5em' : '0px',\n };\n}\n\n/**\n * The stylesheet text for a resolved theme.\n *\n * @param {ResolvedTheme} theme\n * @returns {string}\n */\nexport function themeToCss(theme) {\n const declarations = Object.entries(themeToVariables(theme))\n .map(([name, value]) => ` ${name}: ${value};`)\n .join('\\n');\n return `:host {\\n${declarations}\\n}\\n`;\n}\n","// @ts-check\n\n/**\n * Constructable stylesheets landed in Safari 16.4 and we support 16, so the\n * same fallback Lit uses applies here: a <style> element in the shadow root.\n */\nconst SUPPORTS_ADOPTING =\n typeof ShadowRoot !== 'undefined' &&\n 'adoptedStyleSheets' in Document.prototype &&\n 'replaceSync' in CSSStyleSheet.prototype;\n\n/**\n * A stylesheet the component owns and rewrites at runtime, appended after the\n * component's static styles so its declarations win over them.\n */\nexport class AdoptedSheet {\n /** @type {CSSStyleSheet | null} */\n #sheet = null;\n /** @type {HTMLStyleElement | null} */\n #element = null;\n /** @type {string} */\n #written = '';\n /** @type {string} */\n #marker;\n\n /** @param {string} marker Identifies the sheet in the DOM when the fallback is used. */\n constructor(marker) {\n this.#marker = marker;\n }\n\n /** @param {ShadowRoot | HTMLElement | DocumentFragment} root */\n attach(root) {\n if (!(root instanceof ShadowRoot)) return;\n\n if (SUPPORTS_ADOPTING) {\n if (!this.#sheet) this.#sheet = new CSSStyleSheet();\n if (!root.adoptedStyleSheets.includes(this.#sheet)) {\n root.adoptedStyleSheets = [...root.adoptedStyleSheets, this.#sheet];\n }\n return;\n }\n\n if (!this.#element) {\n this.#element = document.createElement('style');\n this.#element.setAttribute(this.#marker, '');\n }\n if (this.#element.parentNode !== root) root.append(this.#element);\n }\n\n /**\n * Replace the sheet's contents. Cheap to call on every update: identical CSS\n * is ignored.\n *\n * @param {string} css\n * @param {ShadowRoot | HTMLElement | DocumentFragment} root\n */\n write(css, root) {\n if (css === this.#written) return;\n this.attach(root);\n\n if (this.#sheet) this.#sheet.replaceSync(css);\n else if (this.#element) this.#element.textContent = css;\n else return;\n\n this.#written = css;\n }\n\n detach() {\n this.#element?.remove();\n this.#element = null;\n }\n}\n","// @ts-check\nimport { resolveTheme, breakpointOf } from '../theme/merge-theme.js';\nimport { themeToCss } from '../theme/theme-to-css.js';\nimport { AdoptedSheet } from '../styles/adopted-sheet.js';\n\n/** @import { ReactiveController, LitElement } from 'lit' */\n/** @import { Theme, ResolvedTheme, Device } from '../types.js' */\n\n/**\n * Turns the `theme` property into the custom properties everything else reads.\n *\n * The generated sheet is adopted *after* the component's own stylesheets, so a\n * theme value beats the fallback declared alongside the rules that use it.\n * Page CSS still wins over both: a `chit-ui { --chit-color-accent: ... }` rule\n * lives in the outer tree, and the outer tree takes precedence over `:host`.\n *\n * @implements {ReactiveController}\n */\nexport class ThemeController {\n /** @type {LitElement} */\n #host;\n /** @type {AdoptedSheet} */\n #sheet = new AdoptedSheet('data-chit-theme');\n /** @type {ResolvedTheme} */\n #resolved;\n\n /**\n * @param {LitElement} host\n * @param {{ device: () => Device }} options\n */\n constructor(host, { device }) {\n this.#host = host;\n this.#resolved = resolveTheme(undefined, device());\n }\n\n /** @returns {ResolvedTheme} The theme in force, defaults filled in. */\n get current() {\n return this.#resolved;\n }\n\n hostConnected() {\n this.#write();\n }\n\n hostDisconnected() {\n this.#sheet.detach();\n }\n\n /**\n * The breakpoint a theme asks for. Needed before `apply`, because the device\n * cannot be decided until the breakpoint is known.\n *\n * @param {Theme | undefined} theme\n * @returns {number}\n */\n static breakpointOf(theme) {\n return breakpointOf(theme);\n }\n\n /**\n * Re-resolve for the current theme and device. Cheap to call on every update:\n * the stylesheet is only rewritten when the generated text actually changes.\n *\n * @param {Theme | undefined} theme\n * @param {Device} device\n */\n apply(theme, device) {\n this.#resolved = resolveTheme(theme, device);\n this.#write();\n }\n\n #write() {\n this.#sheet.write(themeToCss(this.#resolved), this.#host.renderRoot);\n }\n}\n","// @ts-check\nimport { Events, emit } from '../events.js';\n\n/** @import { ReactiveController, LitElement } from 'lit' */\n/** @import { Message } from '../types.js' */\n\n/** How close to the end still counts as \"at the bottom\", in pixels. */\nconst BOTTOM_SLACK = 24;\n\n/**\n * How long to keep treating the viewport as \"ours\" after starting a smooth\n * scroll, when the browser has no scrollend event to tell us it finished.\n */\nconst SMOOTH_GRACE_MS = 700;\n\n/**\n * Keeps the conversation pinned to the newest message while the reader is at\n * the bottom, and gets out of the way the moment they scroll up.\n *\n * Two things follow from that rule. A reply arriving while the reader is up in\n * the history must not yank them down — it raises the \"jump to latest\" button\n * instead. And their own message always scrolls into view, because they just\n * pressed send and expect to see it.\n *\n * @implements {ReactiveController}\n */\nexport class ScrollController {\n /** @type {LitElement & { messages: Message[] }} */\n #host;\n /** @type {() => 'smooth' | 'instant'} */\n #preferredBehavior;\n /** @type {HTMLElement | null} */\n #viewport = null;\n /** @type {ResizeObserver | null} */\n #resize = null;\n\n #atBottom = true;\n #hasUnseen = false;\n #atTop = false;\n #followAfterRender = true;\n\n /**\n * True while a scroll we started is still animating. Scroll events during\n * that window report positions we caused, not where the reader went.\n */\n #selfScrolling = false;\n /** @type {ReturnType<typeof setTimeout> | undefined} */\n #selfScrollTimer;\n /** The first jump after the panel opens has nothing to animate from. */\n #openingJump = true;\n\n /** @type {string | undefined} */\n #lastId;\n #lastCount = 0;\n\n /**\n * @param {LitElement & { messages: Message[] }} host\n * @param {{ behavior: () => 'smooth' | 'instant' }} options\n */\n constructor(host, { behavior }) {\n this.#host = host;\n this.#preferredBehavior = behavior;\n host.addController(this);\n }\n\n /** @returns {boolean} True when newer content arrived while scrolled up. */\n get hasUnseen() {\n return this.#hasUnseen;\n }\n\n /** @returns {boolean} */\n get atBottom() {\n return this.#atBottom;\n }\n\n hostDisconnected() {\n this.#unbind();\n clearTimeout(this.#selfScrollTimer);\n }\n\n /**\n * Runs before the render, so a decision made here lands in the same frame.\n * Whether the conversation grew is knowable from the array alone; only the\n * scrolling itself has to wait for the DOM.\n */\n hostUpdate() {\n const messages = this.#host.messages;\n const last = messages[messages.length - 1];\n const grew = messages.length > this.#lastCount;\n const newTail = last?.id !== this.#lastId;\n\n this.#lastId = last?.id;\n this.#lastCount = messages.length;\n\n if (!grew && !newTail) return;\n\n // Their own message always scrolls into view: they just pressed send.\n if (this.#atBottom || last?.role === 'user') this.#followAfterRender = true;\n else this.#hasUnseen = true;\n }\n\n hostUpdated() {\n const viewport = /** @type {HTMLElement | null} */ (\n this.#host.renderRoot.querySelector('[part~=\"messages\"]')\n );\n\n if (viewport !== this.#viewport) {\n this.#unbind();\n this.#viewport = viewport;\n this.#bind();\n // A freshly opened panel starts at the newest message, with no animation\n // to watch: there was nothing on screen to move away from.\n if (viewport) {\n this.#atBottom = true;\n this.#hasUnseen = false;\n this.#followAfterRender = true;\n this.#openingJump = true;\n }\n }\n\n if (this.#followAfterRender) {\n const behavior = this.#followBehavior;\n this.#followAfterRender = false;\n this.#scrollNow({ behavior });\n }\n }\n\n #bind() {\n if (!this.#viewport) return;\n this.#viewport.addEventListener('scroll', this.#onScroll, { passive: true });\n // Precise end-of-scroll where it exists (Chrome 114, Firefox 109,\n // Safari 17.4); the timer below covers the rest.\n this.#viewport.addEventListener('scrollend', this.#onScrollEnd);\n\n // Images finishing and streamed text growing both change the height\n // without a scroll event, so the follow has to react to size too.\n const inner = this.#viewport.firstElementChild;\n if (inner && typeof ResizeObserver !== 'undefined') {\n this.#resize = new ResizeObserver(() => {\n if (!this.#atBottom) return;\n // Content settling (an image loading, a tall block laying out) right\n // after a message arrived must not cut the follow short, so while our\n // own animation is running it is re-aimed rather than replaced. With\n // nothing in flight this is a streamed reply growing, and that is\n // followed instantly: an animation restarted every few tens of\n // milliseconds never lands.\n this.#scrollNow({ behavior: this.#selfScrolling ? 'smooth' : 'instant' });\n });\n this.#resize.observe(inner);\n }\n }\n\n #unbind() {\n this.#viewport?.removeEventListener('scroll', this.#onScroll);\n this.#viewport?.removeEventListener('scrollend', this.#onScrollEnd);\n this.#resize?.disconnect();\n this.#resize = null;\n this.#viewport = null;\n }\n\n #onScrollEnd = () => {\n this.#endSelfScroll();\n };\n\n #onScroll = () => {\n const viewport = this.#viewport;\n if (!viewport) return;\n\n const distance = viewport.scrollHeight - viewport.scrollTop - viewport.clientHeight;\n const atBottom = distance <= BOTTOM_SLACK;\n\n // Our own animation passing through the middle of the list is not the\n // reader scrolling up.\n if (this.#selfScrolling) {\n if (atBottom) this.#endSelfScroll();\n return;\n }\n\n if (atBottom !== this.#atBottom) {\n this.#atBottom = atBottom;\n if (atBottom && this.#hasUnseen) {\n this.#hasUnseen = false;\n this.#host.requestUpdate();\n }\n }\n\n // One event per visit to the top, so a consumer loading older messages is\n // not asked again while the reader sits there.\n const atTop = viewport.scrollTop <= 0;\n if (atTop && !this.#atTop) emit(this.#host, Events.SCROLL_TOP, {});\n this.#atTop = atTop;\n };\n\n /**\n * @param {{ smooth?: boolean }} [options] Defaults to the theme's setting.\n */\n scrollToBottom({ smooth } = {}) {\n const behavior =\n smooth === undefined ? this.#followBehavior : smooth ? 'smooth' : 'instant';\n this.#scrollNow({ behavior });\n\n if (this.#hasUnseen) {\n this.#hasUnseen = false;\n this.#host.requestUpdate();\n }\n }\n\n /**\n * What the next follow should look like: the theme's choice, unless the\n * reader asked for less motion, or this is the jump that happens as the\n * panel opens.\n *\n * @returns {'smooth' | 'instant'}\n */\n get #followBehavior() {\n if (this.#openingJump) return 'instant';\n if (window.matchMedia('(prefers-reduced-motion: reduce)').matches) return 'instant';\n return this.#preferredBehavior();\n }\n\n /** @param {{ behavior?: 'smooth' | 'instant' }} [options] */\n #scrollNow({ behavior = 'instant' } = {}) {\n const viewport = this.#viewport;\n if (!viewport) return;\n\n this.#openingJump = false;\n if (behavior === 'smooth') this.#beginSelfScroll();\n\n viewport.scrollTo({ top: viewport.scrollHeight, behavior });\n this.#atBottom = true;\n this.#atTop = false;\n this.#hasUnseen = false;\n }\n\n #beginSelfScroll() {\n this.#selfScrolling = true;\n clearTimeout(this.#selfScrollTimer);\n this.#selfScrollTimer = setTimeout(() => this.#endSelfScroll(), SMOOTH_GRACE_MS);\n }\n\n #endSelfScroll() {\n if (!this.#selfScrolling) return;\n this.#selfScrolling = false;\n clearTimeout(this.#selfScrollTimer);\n\n // Take a reading now that the viewport has settled.\n const viewport = this.#viewport;\n if (!viewport) return;\n const distance = viewport.scrollHeight - viewport.scrollTop - viewport.clientHeight;\n this.#atBottom = distance <= BOTTOM_SLACK;\n }\n}\n","// @ts-check\nimport { Events, emit } from '../events.js';\n\n/** @import { ReactiveController, LitElement } from 'lit' */\n\n/** Browsers that size a textarea to its content need no JS help. */\nconst SUPPORTS_FIELD_SIZING =\n typeof CSS !== 'undefined' && CSS.supports?.('field-sizing', 'content');\n\n/**\n * Owns the composer: what has been typed, whether an IME is mid-composition,\n * and when a keystroke counts as \"send\".\n *\n * The typed text is deliberately not a reactive property. A keystroke would\n * otherwise re-render the whole shadow tree, `repeat` over every message\n * included; instead the two things that depend on it — the send button's\n * enabled state and the character counter — are updated in place.\n *\n * @implements {ReactiveController}\n */\nexport class ComposerController {\n /** @type {LitElement & ComposerHost} */\n #host;\n\n #value = '';\n\n /** True between compositionstart and compositionend. */\n #composing = false;\n\n /**\n * True for one turn of the event loop after a composition ends.\n *\n * WebKit dispatches the Enter that confirmed an IME candidate as a plain\n * keydown *after* compositionend, with `isComposing` already false — so\n * without this flag, confirming a Japanese candidate would send the message.\n */\n #justComposed = false;\n\n /** @type {ReturnType<typeof setTimeout> | undefined} */\n #composedTimer;\n\n /** @param {LitElement & ComposerHost} host */\n constructor(host) {\n this.#host = host;\n host.addController(this);\n }\n\n /** @returns {string} */\n get value() {\n return this.#value;\n }\n\n set value(next) {\n this.#value = next ?? '';\n const input = this.#input;\n if (input && input.value !== this.#value) input.value = this.#value;\n this.#grow();\n this.#syncDerived();\n }\n\n /** @returns {boolean} True while an IME candidate window is open. */\n get composing() {\n return this.#composing;\n }\n\n /** @returns {number} Characters typed, counted by code point. */\n get length() {\n return Array.from(this.#value).length;\n }\n\n /** @returns {boolean} Whether the current text could be sent right now. */\n get canSend() {\n if (this.#host.busy || this.#host.inputDisabled) return false;\n if (this.#value.trim() === '') return false;\n const limit = this.#host.maxLength;\n return limit === undefined || this.length <= limit;\n }\n\n hostDisconnected() {\n clearTimeout(this.#composedTimer);\n }\n\n hostUpdated() {\n const input = this.#input;\n if (input && input.value !== this.#value) input.value = this.#value;\n this.#grow();\n this.#syncDerived();\n }\n\n /** @returns {HTMLTextAreaElement | null} */\n get #input() {\n return /** @type {HTMLTextAreaElement | null} */ (\n this.#host.renderRoot.querySelector('[part~=\"input\"]')\n );\n }\n\n /** @param {Event} event */\n onInput(event) {\n this.#value = /** @type {HTMLTextAreaElement} */ (event.target).value;\n this.#grow();\n this.#syncDerived();\n emit(this.#host, Events.INPUT, { value: this.#value });\n }\n\n onCompositionStart() {\n this.#composing = true;\n }\n\n onCompositionEnd() {\n this.#composing = false;\n this.#justComposed = true;\n clearTimeout(this.#composedTimer);\n this.#composedTimer = setTimeout(() => {\n this.#justComposed = false;\n }, 0);\n }\n\n /** @param {KeyboardEvent} event */\n onKeydown(event) {\n if (event.key !== 'Enter') return;\n if (!this.#host.sendOnEnter) return;\n // Shift+Enter is a newline; the others are the browser's or the page's.\n if (event.shiftKey || event.altKey || event.ctrlKey || event.metaKey) return;\n\n // Chrome, Edge and Firefox mark the confirming Enter on the event itself.\n // Older engines only set keyCode 229.\n if (event.isComposing || event.keyCode === 229) return;\n // Safari's post-compositionend Enter, and Android soft keyboards that send\n // Enter while a composition is still open.\n if (this.#composing || this.#justComposed) return;\n\n event.preventDefault();\n this.submit();\n }\n\n /**\n * Hand the text to the consumer and clear the box.\n *\n * The text is passed as typed: leading and trailing newlines are theirs to\n * keep or strip, since only they know whether the message is prose or code.\n *\n * @param {string} [text] Defaults to what is in the box.\n * @returns {boolean} False when there was nothing to send.\n */\n submit(text) {\n const value = text ?? this.#value;\n if (text === undefined && !this.canSend) return false;\n if (text !== undefined && (this.#host.busy || this.#host.inputDisabled)) return false;\n if (value.trim() === '') return false;\n\n const allowed = emit(this.#host, Events.SUBMIT, { text: value }, { cancelable: true });\n if (!allowed) return false;\n\n this.clear();\n return true;\n }\n\n clear() {\n this.value = '';\n this.focus();\n }\n\n focus() {\n this.#input?.focus();\n }\n\n /** Grow the box with its content, up to the theme's row limit. */\n #grow() {\n if (SUPPORTS_FIELD_SIZING) return;\n const input = this.#input;\n if (!input) return;\n input.style.height = 'auto';\n input.style.height = `${input.scrollHeight}px`;\n }\n\n /**\n * Update the parts that depend on the typed text without a re-render.\n */\n #syncDerived() {\n const root = this.#host.renderRoot;\n\n const send = /** @type {HTMLButtonElement | null} */ (\n root.querySelector('[part~=\"send-button\"]')\n );\n if (send) send.disabled = !this.canSend;\n\n const input = this.#input;\n const counter = /** @type {HTMLElement | null} */ (root.querySelector('[part~=\"counter\"]'));\n const limit = this.#host.maxLength;\n if (limit === undefined) return;\n\n const remaining = limit - this.length;\n const over = remaining < 0;\n input?.setAttribute('aria-invalid', over ? 'true' : 'false');\n\n if (!counter) return;\n counter.textContent = String(remaining);\n counter.toggleAttribute('data-over', over);\n // The digits alone (\"-14\") say nothing out loud, so the counter carries a\n // sentence for assistive tech while showing just the number.\n const labels = this.#host.currentLabels;\n const template = over ? labels.overLimit : labels.charactersLeft;\n counter.setAttribute('aria-label', template.replace('{n}', String(Math.abs(remaining))));\n counter.hidden = this.length <= limit * 0.8;\n }\n}\n\n/**\n * @typedef {Object} ComposerHost\n * @property {boolean} busy\n * @property {boolean} inputDisabled\n * @property {boolean} sendOnEnter\n * @property {number | undefined} maxLength\n * @property {import('../i18n/labels.js').Labels} currentLabels\n */\n","// @ts-check\nimport { unsafeHTML } from 'lit/directives/unsafe-html.js';\n\n/** @import { ChitUI } from '../chit-ui.js' */\n/** @import { Message } from '../types.js' */\n\n/**\n * @typedef {Object} ComponentEntry\n * @property {(new () => HTMLElement) | string} source What `component` held when this was built.\n * @property {HTMLElement} element\n * @property {Record<string, unknown>} props Last props written to the element.\n */\n\n/**\n * Per-host component instances, keyed by a caller-chosen string.\n *\n * Messages key by `msg:<id>`; the launcher has its own key. Keeping one cache\n * means one place decides when an element is rebuilt and when its props are\n * merely re-assigned.\n */\nconst INSTANCES = new WeakMap();\n\n/**\n * The cache key for a message's component.\n *\n * @param {string} id\n * @returns {string}\n */\nconst messageKey = (id) => `msg:${id}`;\n\n/** The cache key for the closed-state component. */\nexport const LAUNCHER_KEY = 'launcher';\n\n/** The five ways a message can carry its content. Exactly one may be present. */\nconst CONTENT_FIELDS = /** @type {const} */ ([\n 'text',\n 'html',\n 'template',\n 'element',\n 'component',\n]);\n\n/**\n * Which form a message uses. Also drives the `data-content` attribute, because\n * plain text is the one form whose whitespace has to survive.\n *\n * @param {Message} message\n * @returns {'text' | 'html' | 'template' | 'element' | 'component'}\n */\nexport function contentField(message) {\n const present = CONTENT_FIELDS.filter((field) => field in message);\n if (present.length === 1) return present[0];\n if (present.length === 0) {\n throw new Error(\n `ChitUI: message \"${message.id}\" has no content. Give it one of html, template, element or component.`,\n );\n }\n throw new Error(\n `ChitUI: message \"${message.id}\" has ${present.join(' and ')}. Give it exactly one.`,\n );\n}\n\n/**\n * The value a message's content is built from. Used to decide whether a\n * message actually changed, so `chat-message-render` does not fire on every\n * unrelated update.\n *\n * @param {Message} message\n * @returns {unknown}\n */\nexport function contentKey(message) {\n return /** @type {Record<string, unknown>} */ (message)[contentField(message)];\n}\n\n/**\n * The registered tag name for a `component`.\n *\n * Registration stays the consumer's job: the library never invents a tag name\n * and calls `customElements.define` behind their back, because that name would\n * then be taken globally for the life of the page.\n *\n * @param {(new () => HTMLElement) | string} source\n * @returns {string}\n */\nfunction tagNameOf(source) {\n if (typeof source === 'string') return source;\n\n const registry = /** @type {CustomElementRegistry & { getName?: (c: unknown) => string | null }} */ (\n customElements\n );\n const registered = registry.getName?.(source);\n if (registered) return registered;\n\n const declared = /** @type {{ tagName?: string }} */ (/** @type {unknown} */ (source)).tagName;\n if (typeof declared === 'string' && declared) return declared;\n\n throw new Error(\n 'ChitUI: component is not registered in customElements. ' +\n 'Call customElements.define() for it, or pass its tag name as a string.',\n );\n}\n\n/**\n * Build (or reuse) an element for a component reference and write its props.\n *\n * The instance is kept across renders so the component keeps its own state; a\n * changed reference replaces it, and changed props are assigned one by one so\n * the component's own setters see each change.\n *\n * @param {ChitUI} host\n * @param {string} key Cache key.\n * @param {(new () => HTMLElement) | string} source\n * @param {Record<string, unknown>} [props]\n * @returns {HTMLElement}\n */\nexport function resolveComponent(host, key, source, props = {}) {\n let cache = INSTANCES.get(host);\n if (!cache) {\n cache = new Map();\n INSTANCES.set(host, cache);\n }\n\n const existing = /** @type {ComponentEntry | undefined} */ (cache.get(key));\n\n if (existing && existing.source === source) {\n for (const [name, value] of Object.entries(props)) {\n if (!Object.is(existing.props[name], value)) {\n /** @type {Record<string, unknown>} */ (/** @type {unknown} */ (existing.element))[name] = value;\n }\n }\n existing.props = { ...props };\n return existing.element;\n }\n\n const element = document.createElement(tagNameOf(source));\n for (const [name, value] of Object.entries(props)) {\n /** @type {Record<string, unknown>} */ (/** @type {unknown} */ (element))[name] = value;\n }\n cache.set(key, { source, element, props: { ...props } });\n return element;\n}\n\n/**\n * Drop cached instances for messages that are gone, so a long conversation\n * does not hold on to elements it will never show again. Non-message entries,\n * such as the launcher's, are left alone.\n *\n * @param {ChitUI} host\n * @param {Set<string>} liveIds\n */\nexport function pruneComponents(host, liveIds) {\n const cache = INSTANCES.get(host);\n if (!cache) return;\n for (const key of cache.keys()) {\n if (!key.startsWith('msg:')) continue;\n if (!liveIds.has(key.slice(4))) cache.delete(key);\n }\n}\n\n/**\n * The component instance backing a message, when it has one.\n *\n * @param {ChitUI} host\n * @param {string} id\n * @returns {HTMLElement | undefined}\n */\nexport function componentInstance(host, id) {\n return INSTANCES.get(host)?.get(messageKey(id))?.element;\n}\n\n/**\n * Turn a message's content into something Lit can render as a child value.\n *\n * All four shapes collapse here: an HTML string becomes an `unsafeHTML`\n * directive, a Lit template passes straight through, and an element or a\n * component becomes a Node, which Lit inserts as-is.\n *\n * @param {ChitUI} host\n * @param {Message} message\n * @returns {unknown}\n */\nexport function renderContent(host, message) {\n switch (contentField(message)) {\n case 'text':\n // A string child is rendered by Lit as a text node, so the escaping is\n // structural: there is no parse step for markup to sneak through. Line\n // breaks survive because the content box is pre-wrap for this form.\n return /** @type {{ text: string }} */ (/** @type {unknown} */ (message)).text;\n\n case 'template':\n return /** @type {{ template: unknown }} */ (/** @type {unknown} */ (message)).template;\n\n case 'element':\n return /** @type {{ element: HTMLElement }} */ (/** @type {unknown} */ (message)).element;\n\n case 'component': {\n const carrier = /** @type {{ component: (new () => HTMLElement) | string, props?: Record<string, unknown> }} */ (\n /** @type {unknown} */ (message)\n );\n return resolveComponent(host, messageKey(message.id), carrier.component, carrier.props);\n }\n\n default: {\n // Only the html form goes through `sanitize`: `text` is escaped by\n // construction, and the rest are structures the consumer built\n // themselves rather than markup we could meaningfully clean.\n const raw = /** @type {{ html: string }} */ (/** @type {unknown} */ (message)).html;\n return unsafeHTML(host.sanitize ? host.sanitize(raw) : raw);\n }\n }\n}\n","// @ts-check\nimport { html, nothing } from 'lit';\nimport { LAUNCHER_KEY, resolveComponent } from './content.js';\n\n/** @import { ChitUI } from '../chit-ui.js' */\n\n/**\n * The closed state: one button.\n *\n * What goes inside it has three routes, in order of how much the consumer\n * takes over:\n *\n * - the theme's image or label, drawn inside the themed circle;\n * - the `launcher` slot, their markup inside that same circle;\n * - `closed.component`, a component that draws the whole launcher — the button\n * then keeps only its role, and gives up its size, background, shadow and\n * radius, because two parties styling one box is how things end up clipped.\n *\n * @param {ChitUI} host\n * @returns {import('lit').TemplateResult}\n */\nexport function renderLauncher(host) {\n const closed = host.currentTheme.closed;\n const labels = host.currentLabels;\n const custom = closed.component\n ? resolveComponent(host, LAUNCHER_KEY, closed.component, closed.props)\n : null;\n\n return html`\n <button\n part=\"launcher\"\n type=\"button\"\n aria-label=${closed.label || labels.launcher}\n aria-expanded=${host.state === 'open'}\n ?data-has-image=${!custom && !!closed.image}\n ?data-custom=${!!custom}\n @click=${() => host.toggleFromUser()}\n >\n ${custom ?? html`<slot name=\"launcher\">${defaultContent(closed)}</slot>`}\n </button>\n `;\n}\n\n/**\n * @param {import('../types.js').ResolvedClosed} closed\n * @returns {unknown}\n */\nfunction defaultContent(closed) {\n if (closed.image) return nothing;\n if (closed.label) return html`<span part=\"launcher-label\">${closed.label}</span>`;\n return defaultIcon();\n}\n\n/** A plain speech bubble, so the widget looks like something before theming. */\nfunction defaultIcon() {\n return html`\n <svg part=\"launcher-icon\" viewBox=\"0 0 24 24\" aria-hidden=\"true\" focusable=\"false\">\n <path\n fill=\"currentColor\"\n d=\"M12 3c-4.97 0-9 3.36-9 7.5 0 2.3 1.25 4.36 3.2 5.73-.13 1.2-.6 2.3-1.36 3.2a.5.5 0 0 0 .5.82 8.2 8.2 0 0 0 3.87-1.86c.88.26 1.82.41 2.79.41 4.97 0 9-3.36 9-7.5S16.97 3 12 3Z\"\n />\n </svg>\n `;\n}\n","import{_$LH as o}from\"./lit-html.js\";\n/**\n * @license\n * Copyright 2020 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */const{I:t}=o,i=o=>o,n=o=>null===o||\"object\"!=typeof o&&\"function\"!=typeof o,e={HTML:1,SVG:2,MATHML:3},l=(o,t)=>void 0===t?void 0!==o?._$litType$:o?._$litType$===t,d=o=>null!=o?._$litType$?.h,c=o=>void 0!==o?._$litDirective$,f=o=>o?._$litDirective$,r=o=>void 0===o.strings,s=()=>document.createComment(\"\"),v=(o,n,e)=>{const l=o._$AA.parentNode,d=void 0===n?o._$AB:n._$AA;if(void 0===e){const i=l.insertBefore(s(),d),n=l.insertBefore(s(),d);e=new t(i,n,o,o.options)}else{const t=e._$AB.nextSibling,n=e._$AM,c=n!==o;if(c){let t;e._$AQ?.(o),e._$AM=o,void 0!==e._$AP&&(t=o._$AU)!==n._$AU&&e._$AP(t)}if(t!==d||c){let o=e._$AA;for(;o!==t;){const t=i(o).nextSibling;i(l).insertBefore(o,d),o=t}}}return e},u=(o,t,i=o)=>(o._$AI(t,i),o),m={},p=(o,t=m)=>o._$AH=t,M=o=>o._$AH,h=o=>{o._$AR(),o._$AA.remove()},j=o=>{o._$AR()};export{e as TemplateResultType,j as clearPart,M as getCommittedValue,f as getDirectiveClass,v as insertPart,d as isCompiledTemplateResult,c as isDirectiveResult,n as isPrimitive,r as isSingleExpression,l as isTemplateResult,h as removePart,u as setChildPartValue,p as setCommittedValue};\n//# sourceMappingURL=directive-helpers.js.map\n","import{noChange as e}from\"../lit-html.js\";import{directive as s,Directive as t,PartType as r}from\"../directive.js\";import{getCommittedValue as l,setChildPartValue as o,insertPart as i,removePart as n,setCommittedValue as f}from\"../directive-helpers.js\";\n/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\nconst u=(e,s,t)=>{const r=new Map;for(let l=s;l<=t;l++)r.set(e[l],l);return r},c=s(class extends t{constructor(e){if(super(e),e.type!==r.CHILD)throw Error(\"repeat() can only be used in text expressions\")}dt(e,s,t){let r;void 0===t?t=s:void 0!==s&&(r=s);const l=[],o=[];let i=0;for(const s of e)l[i]=r?r(s,i):i,o[i]=t(s,i),i++;return{values:o,keys:l}}render(e,s,t){return this.dt(e,s,t).values}update(s,[t,r,c]){const d=l(s),{values:p,keys:a}=this.dt(t,r,c);if(!Array.isArray(d))return this.ut=a,p;const h=this.ut??=[],v=[];let m,y,x=0,j=d.length-1,k=0,w=p.length-1;for(;x<=j&&k<=w;)if(null===d[x])x++;else if(null===d[j])j--;else if(h[x]===a[k])v[k]=o(d[x],p[k]),x++,k++;else if(h[j]===a[w])v[w]=o(d[j],p[w]),j--,w--;else if(h[x]===a[w])v[w]=o(d[x],p[w]),i(s,v[w+1],d[x]),x++,w--;else if(h[j]===a[k])v[k]=o(d[j],p[k]),i(s,d[x],d[j]),j--,k++;else if(void 0===m&&(m=u(a,k,w),y=u(h,x,j)),m.has(h[x]))if(m.has(h[j])){const e=y.get(a[k]),t=void 0!==e?d[e]:null;if(null===t){const e=i(s,d[x]);o(e,p[k]),v[k]=e}else v[k]=o(t,p[k]),i(s,d[x],t),d[e]=null;k++}else n(d[j]),j--;else n(d[x]),x++;for(;k<=w;){const e=i(s,v[w+1]);o(e,p[k]),v[k++]=e}for(;x<=j;){const e=d[x++];null!==e&&n(e)}return this.ut=a,f(s,v),e}});export{c as repeat};\n//# sourceMappingURL=repeat.js.map\n","// @ts-check\nimport { html, nothing } from 'lit';\nimport { contentField, renderContent } from './content.js';\n\n/** @import { ChitUI } from '../chit-ui.js' */\n/** @import { Message } from '../types.js' */\n\n/**\n * Format a timestamp. The consumer's `formatTime` wins; otherwise a plain\n * locale-aware hour:minute, which is what a chat bubble wants.\n *\n * @param {ChitUI} host\n * @param {string | Date} time\n * @returns {string}\n */\nfunction formatTime(host, time) {\n const date = time instanceof Date ? time : new Date(time);\n if (Number.isNaN(date.getTime())) return '';\n if (host.formatTime) return host.formatTime(date);\n return new Intl.DateTimeFormat(host.resolvedLocale, {\n hour: '2-digit',\n minute: '2-digit',\n }).format(date);\n}\n\n/**\n * One message.\n *\n * `system` messages are a centred line rather than a bubble: they are the\n * widget talking about the conversation (\"an operator joined\"), not a party to\n * it, so they get no avatar, no name and no timestamp.\n *\n * @param {ChitUI} host\n * @param {Message} message\n * @returns {import('lit').TemplateResult}\n */\nexport function renderMessage(host, message) {\n if (message.role === 'system') {\n return html`\n <article part=\"message message-system\" data-role=\"system\" data-id=${message.id}>\n <div part=\"message-content\" data-content=${contentField(message)}>${renderContent(host, message)}</div>\n </article>\n `;\n }\n\n const meta = message.time || message.status;\n\n // The theme says who is talking; a message overrides either half. `null` on\n // the message hides what the theme set, which is how a run of replies shows\n // the icon only on the first of them.\n const speaker = host.currentTheme.open.speaker[message.role];\n const avatar = message.avatar === undefined ? speaker.avatar : message.avatar;\n const name = message.name === undefined ? speaker.name : message.name;\n\n return html`\n <article\n part=\"message message-${message.role}\"\n data-role=${message.role}\n data-id=${message.id}\n ?data-streaming=${!!message.streaming}\n aria-busy=${message.streaming ? 'true' : 'false'}\n >\n ${avatar\n ? html`<img part=\"avatar\" src=${avatar} alt=\"\" loading=\"lazy\" />`\n : speaker.avatar\n ? html`<span part=\"avatar\" data-placeholder aria-hidden=\"true\"></span>`\n : nothing}\n <div class=\"body\">\n ${name ? html`<span part=\"name\">${name}</span>` : nothing}\n <div part=\"bubble\">\n <div part=\"message-content\" data-content=${contentField(message)}>${renderContent(host, message)}</div>\n ${message.streaming ? html`<span part=\"cursor\" aria-hidden=\"true\"></span>` : nothing}\n </div>\n ${meta\n ? html`\n <div part=\"meta\" class=\"meta\">\n ${message.time\n ? html`<time part=\"time\">${formatTime(host, message.time)}</time>`\n : nothing}\n ${message.status\n ? html`<span part=\"status\" data-status=${message.status}>\n ${host.currentLabels.status[message.status]}\n </span>`\n : nothing}\n </div>\n `\n : nothing}\n </div>\n </article>\n `;\n}\n","import{noChange as r,nothing as e}from\"../lit-html.js\";import{directive as i,Directive as t,PartType as n}from\"../directive.js\";import{isSingleExpression as o,setCommittedValue as s}from\"../directive-helpers.js\";\n/**\n * @license\n * Copyright 2020 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */const l=i(class extends t{constructor(r){if(super(r),r.type!==n.PROPERTY&&r.type!==n.ATTRIBUTE&&r.type!==n.BOOLEAN_ATTRIBUTE)throw Error(\"The `live` directive is not allowed on child or event bindings\");if(!o(r))throw Error(\"`live` bindings can only contain a single expression\")}render(r){return r}update(i,[t]){if(t===r||t===e)return t;const o=i.element,l=i.name;if(i.type===n.PROPERTY){if(t===o[l])return r}else if(i.type===n.BOOLEAN_ATTRIBUTE){if(!!t===o.hasAttribute(l))return r}else if(i.type===n.ATTRIBUTE&&o.getAttribute(l)===t+\"\")return r;return s(i),t}});export{l as live};\n//# sourceMappingURL=live.js.map\n","// @ts-check\nimport { html, nothing } from 'lit';\nimport { live } from 'lit/directives/live.js';\n\n/** @import { ChitUI } from '../chit-ui.js' */\n\n/**\n * The attach button and the file input it opens.\n *\n * The widget owns the picking and nothing else: it hands the chosen files to\n * the consumer through `chat-attach` and forgets them. Uploading them, showing\n * a preview and adding a message are all things only the consumer can do, and\n * a half-done version here would be in the way of the real one.\n *\n * The input is reset after every pick so that choosing the same file twice in\n * a row still reports the second time.\n *\n * @param {ChitUI} host\n * @param {boolean} disabled\n * @returns {import('lit').TemplateResult}\n */\nfunction renderAttach(host, disabled) {\n const labels = host.currentLabels;\n const input = host.currentTheme.open.input;\n\n return html`\n <button\n part=\"attach-button\"\n type=\"button\"\n aria-label=${labels.attach}\n title=${labels.attach}\n ?disabled=${disabled}\n @click=${() => host.openAttach()}\n >\n <svg viewBox=\"0 0 24 24\" aria-hidden=\"true\" focusable=\"false\">\n <path\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n d=\"M20 11.5 12.2 19.3a4.6 4.6 0 0 1-6.5-6.5l7.8-7.8a3 3 0 0 1 4.3 4.3l-7.8 7.8a1.5 1.5 0 0 1-2.1-2.1l7.1-7.1\"\n />\n </svg>\n </button>\n <input\n part=\"attach-input\"\n type=\"file\"\n tabindex=\"-1\"\n aria-hidden=\"true\"\n accept=${input.accept}\n ?multiple=${input.multiple}\n @change=${(/** @type {Event} */ event) => {\n const field = /** @type {HTMLInputElement} */ (event.target);\n const files = Array.from(field.files ?? []);\n field.value = '';\n if (files.length) host.handleAttach(files);\n }}\n />\n `;\n}\n\n/**\n * The composer: a textarea that grows with its content, and a send button.\n *\n * The whole thing can be replaced through the `composer` slot; a consumer who\n * does that calls `host.submit(text)` themselves. `input-before` and\n * `input-after` are the lighter option, for an attach or emoji button beside\n * the box the library still owns.\n *\n * @param {ChitUI} host\n * @returns {import('lit').TemplateResult | typeof nothing}\n */\nexport function renderComposer(host) {\n if (host.inputHidden) return nothing;\n\n const labels = host.currentLabels;\n const theme = host.currentTheme.open;\n const disabled = host.busy || host.inputDisabled;\n const placeholder = host.placeholder ?? theme.input.placeholder ?? labels.input;\n\n return html`\n <form\n part=\"composer\"\n @submit=${(/** @type {SubmitEvent} */ event) => {\n event.preventDefault();\n host.submit();\n }}\n >\n <slot name=\"composer\">\n ${theme.input.attach ? renderAttach(host, disabled) : nothing}\n\n <slot name=\"input-before\"></slot>\n\n <textarea\n part=\"input\"\n rows=\"1\"\n .value=${live(host.value)}\n placeholder=${placeholder}\n aria-label=${labels.input}\n ?disabled=${disabled}\n aria-describedby=${host.maxLength === undefined ? nothing : 'chit-counter'}\n @input=${(/** @type {Event} */ event) => host.handleInput(event)}\n @keydown=${(/** @type {KeyboardEvent} */ event) => host.handleKeydown(event)}\n @compositionstart=${() => host.handleComposition(true)}\n @compositionend=${() => host.handleComposition(false)}\n ></textarea>\n\n <slot name=\"input-after\"></slot>\n\n ${host.maxLength === undefined\n ? nothing\n : html`<span part=\"counter\" id=\"chit-counter\" aria-live=\"polite\" hidden></span>`}\n\n <button\n part=\"send-button\"\n type=\"submit\"\n aria-label=${labels.send}\n ?disabled=${!host.canSend}\n >\n ${host.busy\n ? html`<span part=\"spinner\" aria-hidden=\"true\"></span>`\n : html`<svg viewBox=\"0 0 24 24\" aria-hidden=\"true\" focusable=\"false\">\n <path fill=\"currentColor\" d=\"M3.4 20.4 21 12 3.4 3.6 3.39 10.2 15.6 12 3.39 13.8z\" />\n </svg>`}\n </button>\n </slot>\n </form>\n `;\n}\n","// @ts-check\nimport { html, nothing } from 'lit';\nimport { renderMessageList } from './message-list.js';\nimport { renderComposer } from './composer.js';\n\n/** @import { ChitUI } from '../chit-ui.js' */\n\n/**\n * The open state. Header and footer are slots; the message list and the\n * composer arrive in later milestones and are placeholders for now.\n *\n * @param {ChitUI} host\n * @returns {import('lit').TemplateResult}\n */\nexport function renderPanel(host) {\n const open = host.currentTheme.open;\n const labels = host.currentLabels;\n const title = open.header.title ?? labels.panel;\n\n return html`\n <section\n part=\"panel\"\n role=\"dialog\"\n aria-modal=\"false\"\n aria-label=${title}\n tabindex=\"-1\"\n @keydown=${(/** @type {KeyboardEvent} */ event) => onKeydown(host, event)}\n >\n ${open.header.visible ? renderHeader(host, title) : nothing}\n\n ${renderMessageList(host)} ${renderComposer(host)}\n\n <slot name=\"footer\"></slot>\n </section>\n `;\n}\n\n/**\n * The title bar.\n *\n * It can be left out entirely (`open.header.visible = false`), which is what a\n * widget embedded in a host that already draws its own title bar wants — LINE\n * LIFF, for one — rather than two stacked titles. The dialog keeps its\n * accessible name either way: that name is read, not seen.\n *\n * Note that hiding it takes the close button with it. Esc and the launcher\n * still close the panel, and the host's own chrome usually supplies the rest.\n *\n * @param {ChitUI} host\n * @param {string} title\n * @returns {import('lit').TemplateResult}\n */\nfunction renderHeader(host, title) {\n const open = host.currentTheme.open;\n const labels = host.currentLabels;\n\n return html`\n <header part=\"header\">\n <slot name=\"header\">\n <slot name=\"header-title\">\n <span part=\"header-title\">\n ${open.header.logo\n ? html`<img part=\"header-logo\" src=${open.header.logo} alt=\"\" />`\n : nothing}\n <span part=\"header-heading\">${title}</span>\n </span>\n </slot>\n <span part=\"header-actions\">\n <slot name=\"header-actions\"></slot>\n ${open.header.home\n ? html`<button\n part=\"home-button\"\n type=\"button\"\n aria-label=${labels.home}\n title=${labels.home}\n @click=${() => host.home('user')}\n >\n <svg viewBox=\"0 0 24 24\" aria-hidden=\"true\" focusable=\"false\">\n <path\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linejoin=\"round\"\n stroke-linecap=\"round\"\n d=\"M4 11.2 12 4l8 7.2M6.5 9.8V19h11V9.8M10 19v-4.6h4V19\"\n />\n </svg>\n </button>`\n : nothing}\n <button\n part=\"close-button\"\n type=\"button\"\n aria-label=${labels.close}\n @click=${() => host.closeFromUser()}\n >\n <svg viewBox=\"0 0 24 24\" aria-hidden=\"true\" focusable=\"false\">\n <path\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n d=\"M6 6l12 12M18 6L6 18\"\n />\n </svg>\n </button>\n </span>\n </slot>\n </header>\n `;\n}\n\n/**\n * Esc closes the panel. It is handled here rather than on the host so that it\n * only applies while the panel has focus inside it.\n *\n * @param {ChitUI} host\n * @param {KeyboardEvent} event\n */\nfunction onKeydown(host, event) {\n if (event.key !== 'Escape' || event.defaultPrevented) return;\n event.preventDefault();\n host.closeFromUser();\n}\n","// @ts-check\nimport { html, nothing } from 'lit';\nimport { repeat } from 'lit/directives/repeat.js';\nimport { renderMessage } from './message.js';\n\n/** @import { ChitUI } from '../chit-ui.js' */\n\n/**\n * The scrolling conversation.\n *\n * `repeat` keys on the message id so an existing bubble's DOM is reused when\n * the consumer assigns a new array; without it Lit would reorder by position\n * and a component message would lose its state on every insert.\n *\n * Clicks are handled once here and re-published as `chat-message-click`, which\n * is how a consumer reaches a button inside a message without hunting through\n * the shadow root.\n *\n * @param {ChitUI} host\n * @returns {import('lit').TemplateResult}\n */\nexport function renderMessageList(host) {\n const labels = host.currentLabels;\n const typing = host.typing;\n const empty = host.messages.length === 0 && !typing;\n\n return html`\n <div\n part=\"messages\"\n role=\"log\"\n aria-live=\"polite\"\n aria-relevant=\"additions text\"\n aria-label=${labels.conversation}\n @click=${(/** @type {MouseEvent} */ event) => host.handleMessageClick(event)}\n >\n <div part=\"messages-inner\" class=\"inner\">\n ${empty ? html`<slot name=\"empty\"></slot>` : nothing}\n ${repeat(\n host.messages,\n (message) => message.id,\n (message) => renderMessage(host, message),\n )}\n ${typing\n ? html`\n <div part=\"typing\" role=\"status\" aria-label=${labels.typing}>\n ${typeof typing === 'object' && typing.html\n ? host.renderTypingHtml(typing.html)\n : html`<span class=\"dots\" aria-hidden=\"true\"><i></i><i></i><i></i></span>`}\n </div>\n `\n : nothing}\n </div>\n </div>\n\n ${host.hasUnseen\n ? html`\n <button\n part=\"to-latest\"\n type=\"button\"\n @click=${() => host.scrollToBottom({ smooth: true })}\n >\n ${labels.toLatest}\n </button>\n `\n : nothing}\n `;\n}\n","// @ts-check\n\n/**\n * @typedef {Object} Labels\n * @property {string} launcher Accessible name of the closed-state button.\n * @property {string} panel Accessible name of the dialog.\n * @property {string} conversation Accessible name of the message log.\n * @property {string} close Close button.\n * @property {string} home Home button: back to the start of the conversation.\n * @property {string} send Send button.\n * @property {string} attach Attach button beside the composer.\n * @property {string} input Composer textarea.\n * @property {string} typing Announced while the other side is typing.\n * @property {string} toLatest \"Jump to newest\" button.\n * @property {{ sending: string, sent: string, error: string }} status Delivery state of one's own message.\n * @property {string} charactersLeft Counter, with {n} for the number remaining.\n * @property {string} overLimit Counter past the limit, with {n} for the excess.\n */\n\n/** @type {Record<string, Labels>} */\nconst BUILT_IN = {\n ja: {\n launcher: 'チャットを開く',\n panel: 'チャット',\n conversation: '会話',\n close: 'チャットを閉じる',\n home: '最初に戻る',\n send: '送信',\n attach: '画像や動画を添付',\n input: 'メッセージを入力',\n typing: '入力中',\n toLatest: '最新へ',\n status: { sending: '送信中', sent: '送信済み', error: '送信できませんでした' },\n charactersLeft: '残り {n} 文字',\n overLimit: '{n} 文字超過しています',\n },\n en: {\n launcher: 'Open chat',\n panel: 'Chat',\n conversation: 'Conversation',\n close: 'Close chat',\n home: 'Back to the start',\n send: 'Send',\n attach: 'Attach an image or video',\n input: 'Type a message',\n typing: 'Typing',\n toLatest: 'Jump to latest',\n status: { sending: 'Sending', sent: 'Sent', error: 'Not delivered' },\n charactersLeft: '{n} characters left',\n overLimit: '{n} characters over the limit',\n },\n};\n\n/**\n * The language the widget speaks: the `locale` property, else the document's,\n * else the browser's. Everything locale-dependent — labels and timestamps\n * alike — goes through this, so they cannot disagree.\n *\n * @param {string | undefined} locale\n * @returns {string | undefined} undefined means \"whatever the browser uses\".\n */\nexport function resolveLocale(locale) {\n return locale || document.documentElement.lang || undefined;\n}\n\n/**\n * Pick the label set for a locale, falling back to English for anything we do\n * not ship. `overrides` is the host's `labels` property.\n *\n * @param {string | undefined} locale\n * @param {Partial<Labels> | undefined} [overrides]\n * @returns {Labels}\n */\nexport function resolveLabels(locale, overrides) {\n const lang = (resolveLocale(locale) || 'en').toLowerCase();\n const base = BUILT_IN[lang] ?? BUILT_IN[lang.split('-')[0]] ?? BUILT_IN.en;\n return overrides ? { ...base, ...overrides } : base;\n}\n","// @ts-check\nimport { css } from 'lit';\n\n/**\n * Host-level concerns: the coordinate space the widget lives in, the theme\n * fallbacks, and the transition animations.\n *\n * Every custom property here is a fallback only. ThemeController writes the\n * real values into an adopted stylesheet that sits ahead of this one, and page\n * CSS (`chit-ui { --chit-color-accent: ... }`) beats both.\n */\nexport const hostStyles = css`\n :host {\n --chit-z-index: 2147483000;\n --chit-font-family: system-ui, -apple-system, 'Segoe UI', 'Hiragino Sans', 'Noto Sans JP', sans-serif;\n --chit-font-size: 14px;\n\n --chit-launcher-size: 60px;\n --chit-launcher-offset-x: 24px;\n --chit-launcher-offset-y: 24px;\n --chit-launcher-radius: 30px;\n --chit-launcher-bg: #1a73e8;\n --chit-launcher-text: #ffffff;\n --chit-launcher-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);\n\n --chit-panel-width: 380px;\n --chit-panel-height: 600px;\n --chit-panel-offset-x: 24px;\n --chit-panel-offset-y: 24px;\n --chit-panel-radius: 16px;\n --chit-panel-shadow: 0 8px 32px rgba(0, 0, 0, 0.24);\n\n --chit-color-bg: #ffffff;\n --chit-color-text: #1f1f1f;\n --chit-color-accent: #1a73e8;\n --chit-color-border: #e4e4e7;\n --chit-color-header-bg: #ffffff;\n --chit-color-header-text: #1f1f1f;\n\n --chit-bubble-radius: 14px;\n\n position: fixed;\n inset: 0;\n z-index: var(--chit-z-index);\n /* The host is only a coordinate space; clicks land on the page behind it. */\n pointer-events: none;\n font-family: var(--chit-font-family);\n font-size: var(--chit-font-size);\n color: var(--chit-color-text);\n -webkit-font-smoothing: antialiased;\n }\n\n /*\n * Keyed off what the DOM is showing, not off the state property: that flips\n * to 'hidden' the moment it is assigned, while the exit animation still has\n * to play.\n */\n :host([data-rendered-state='hidden']) {\n display: none;\n }\n\n :host > *,\n [part] {\n pointer-events: auto;\n }\n\n *,\n *::before,\n *::after {\n box-sizing: border-box;\n }\n\n /* --- transitions ------------------------------------------------------ */\n\n [data-anim] {\n animation-duration: var(--_chit-anim-duration, 200ms);\n animation-fill-mode: both;\n animation-timing-function: cubic-bezier(0.2, 0.8, 0.2, 1);\n }\n\n [data-anim='enter'][data-effect='fade'] {\n animation-name: chit-fade-in;\n }\n [data-anim='exit'][data-effect='fade'] {\n animation-name: chit-fade-out;\n }\n [data-anim='enter'][data-effect='scale'] {\n animation-name: chit-scale-in;\n }\n [data-anim='exit'][data-effect='scale'] {\n animation-name: chit-scale-out;\n }\n [data-anim='enter'][data-effect='slide'] {\n animation-name: chit-slide-in;\n }\n [data-anim='exit'][data-effect='slide'] {\n animation-name: chit-slide-out;\n }\n\n @keyframes chit-fade-in {\n from {\n opacity: 0;\n }\n to {\n opacity: 1;\n }\n }\n @keyframes chit-fade-out {\n from {\n opacity: 1;\n }\n to {\n opacity: 0;\n }\n }\n @keyframes chit-scale-in {\n from {\n opacity: 0;\n transform: scale(0.85);\n }\n to {\n opacity: 1;\n transform: none;\n }\n }\n @keyframes chit-scale-out {\n from {\n opacity: 1;\n transform: none;\n }\n to {\n opacity: 0;\n transform: scale(0.85);\n }\n }\n @keyframes chit-slide-in {\n from {\n opacity: 0;\n transform: translateY(16px);\n }\n to {\n opacity: 1;\n transform: none;\n }\n }\n @keyframes chit-slide-out {\n from {\n opacity: 1;\n transform: none;\n }\n to {\n opacity: 0;\n transform: translateY(16px);\n }\n }\n\n @media (prefers-reduced-motion: reduce) {\n [data-anim] {\n animation: none !important;\n }\n }\n`;\n","// @ts-check\nimport { css } from 'lit';\n\nexport const launcherStyles = css`\n [part~='launcher'] {\n position: absolute;\n display: grid;\n place-items: center;\n width: var(--chit-launcher-size);\n height: var(--chit-launcher-size);\n padding: 0;\n border: 0;\n border-radius: var(--chit-launcher-radius);\n background-color: var(--chit-launcher-bg);\n background-position: center;\n background-size: cover;\n background-repeat: no-repeat;\n color: var(--chit-launcher-text);\n box-shadow: var(--chit-launcher-shadow);\n font: inherit;\n line-height: 1;\n cursor: pointer;\n transition: filter 120ms ease;\n }\n\n /* The image comes from the theme, so it is a background rather than an <img>. */\n [part~='launcher'][data-has-image] {\n background-image: var(--chit-launcher-image);\n }\n\n /*\n * A consumer component draws the whole launcher, so the button stops being a\n * visual of its own: no box to squeeze the component into, and none of the\n * widget's own paint behind it. It keeps being a button, which is the part\n * that matters for keyboards and screen readers.\n */\n [part~='launcher'][data-custom] {\n width: auto;\n height: auto;\n padding: 0;\n border-radius: 0;\n background: none;\n box-shadow: none;\n color: inherit;\n }\n\n [part~='launcher'][data-custom]:hover {\n filter: none;\n }\n\n [part~='launcher']:hover {\n filter: brightness(1.06);\n }\n\n [part~='launcher']:focus-visible {\n outline: 2px solid var(--chit-launcher-bg);\n outline-offset: 3px;\n }\n\n [part~='launcher-icon'] {\n width: 55%;\n height: 55%;\n }\n\n [part~='launcher-label'] {\n padding: 0 0.75em;\n font-size: 0.95em;\n white-space: nowrap;\n }\n\n /* --- placement -------------------------------------------------------- */\n\n :host([data-launcher-position='bottom-right']) [part~='launcher'] {\n right: var(--chit-launcher-offset-x);\n bottom: var(--chit-launcher-offset-y);\n transform-origin: bottom right;\n }\n :host([data-launcher-position='bottom-left']) [part~='launcher'] {\n left: var(--chit-launcher-offset-x);\n bottom: var(--chit-launcher-offset-y);\n transform-origin: bottom left;\n }\n :host([data-launcher-position='top-right']) [part~='launcher'] {\n right: var(--chit-launcher-offset-x);\n top: var(--chit-launcher-offset-y);\n transform-origin: top right;\n }\n :host([data-launcher-position='top-left']) [part~='launcher'] {\n left: var(--chit-launcher-offset-x);\n top: var(--chit-launcher-offset-y);\n transform-origin: top left;\n }\n\n /* --- idle motion ------------------------------------------------------ */\n\n /*\n * Only while nothing else is animating: a transition sets data-anim and owns\n * the animation property for as long as it runs.\n */\n :host([data-idle='pulse']) [part~='launcher']:not([data-anim]) {\n animation: chit-idle-pulse 2.4s ease-in-out infinite;\n }\n :host([data-idle='bounce']) [part~='launcher']:not([data-anim]) {\n animation: chit-idle-bounce 2.4s ease-in-out infinite;\n }\n\n @keyframes chit-idle-pulse {\n 0%,\n 70%,\n 100% {\n box-shadow: var(--chit-launcher-shadow);\n }\n 35% {\n box-shadow:\n var(--chit-launcher-shadow),\n 0 0 0 10px color-mix(in srgb, var(--chit-launcher-bg) 22%, transparent);\n }\n }\n\n @keyframes chit-idle-bounce {\n 0%,\n 62%,\n 100% {\n transform: translateY(0);\n }\n 72% {\n transform: translateY(-6px);\n }\n 86% {\n transform: translateY(-2px);\n }\n }\n\n @media (prefers-reduced-motion: reduce) {\n :host([data-idle]) [part~='launcher']:not([data-anim]) {\n animation: none;\n }\n }\n`;\n","// @ts-check\nimport { css } from 'lit';\n\nexport const panelStyles = css`\n [part~='panel'] {\n position: absolute;\n display: flex;\n flex-direction: column;\n width: var(--chit-panel-width);\n height: var(--chit-panel-height);\n max-width: calc(100vw - var(--chit-panel-offset-x) * 2);\n max-height: calc(100vh - var(--chit-panel-offset-y) * 2);\n overflow: hidden;\n border-radius: var(--chit-panel-radius);\n background-color: var(--chit-color-bg);\n background-image: var(--chit-panel-bg-image);\n background-size: cover;\n background-position: center;\n box-shadow: var(--chit-panel-shadow);\n }\n\n /* --- placement -------------------------------------------------------- */\n\n :host([data-panel-position='bottom-right']) [part~='panel'] {\n right: var(--chit-panel-offset-x);\n bottom: var(--chit-panel-offset-y);\n transform-origin: bottom right;\n }\n :host([data-panel-position='bottom-left']) [part~='panel'] {\n left: var(--chit-panel-offset-x);\n bottom: var(--chit-panel-offset-y);\n transform-origin: bottom left;\n }\n :host([data-panel-position='top-right']) [part~='panel'] {\n right: var(--chit-panel-offset-x);\n top: var(--chit-panel-offset-y);\n transform-origin: top right;\n }\n :host([data-panel-position='top-left']) [part~='panel'] {\n left: var(--chit-panel-offset-x);\n top: var(--chit-panel-offset-y);\n transform-origin: top left;\n }\n\n [part~='panel']:focus {\n outline: none;\n }\n\n /*\n * A phone gets the whole screen. dvh rather than vh so the browser chrome\n * collapsing does not leave a gap, and the safe-area insets keep the header\n * clear of the notch.\n */\n :host([data-device='mobile']) [part~='panel'],\n :host([data-device='mobile'][data-panel-position]) [part~='panel'] {\n inset: 0;\n width: 100vw;\n height: 100dvh;\n max-width: none;\n max-height: none;\n border-radius: 0;\n padding-top: env(safe-area-inset-top);\n padding-bottom: env(safe-area-inset-bottom);\n overscroll-behavior: contain;\n }\n\n [part~='header'] {\n display: flex;\n flex: none;\n align-items: center;\n justify-content: space-between;\n gap: 0.5em;\n padding: 0.875em 1em;\n border-bottom: 1px solid var(--chit-color-border);\n background: var(--chit-color-header-bg);\n color: var(--chit-color-header-text);\n }\n\n /*\n * The image and the title are one flex item. A slot is display: contents,\n * so without this wrapper its children become items of the header itself\n * and space-between pushes the image to one edge and the title to the\n * middle, away from each other.\n */\n [part~='header-title'] {\n display: inline-flex;\n min-width: 0;\n align-items: center;\n gap: 0.5em;\n }\n\n [part~='header-heading'] {\n overflow: hidden;\n font-size: 1.05em;\n font-weight: 600;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n\n [part~='header-logo'] {\n flex: none;\n width: 1.75em;\n height: 1.75em;\n border-radius: 50%;\n object-fit: cover;\n }\n\n [part~='header-actions'] {\n display: inline-flex;\n align-items: center;\n gap: 0.25em;\n }\n\n [part~='home-button'],\n [part~='close-button'] {\n display: grid;\n place-items: center;\n width: 2em;\n height: 2em;\n padding: 0;\n border: 0;\n border-radius: 50%;\n background: transparent;\n color: inherit;\n cursor: pointer;\n }\n\n [part~='home-button']:hover,\n [part~='close-button']:hover {\n background: color-mix(in srgb, currentColor 10%, transparent);\n }\n\n [part~='home-button']:focus-visible,\n [part~='close-button']:focus-visible {\n outline: 2px solid var(--chit-color-accent);\n outline-offset: 1px;\n }\n\n [part~='home-button'] svg,\n [part~='close-button'] svg {\n width: 1.1em;\n height: 1.1em;\n }\n\n`;\n","// @ts-check\nimport { css } from 'lit';\n\nexport const messageStyles = css`\n :host {\n /* Internal: the box the tail's path is drawn in. The path is written in\n these units, so the two move together. */\n --_chit-tail-w: 18px;\n --_chit-tail-h: 20px;\n /* How deep the tail's root sits inside the bubble. Less than the\n bubble's own padding, so it never reaches the text. */\n --_chit-tail-root: 9px;\n /* Far enough down that the bubble's edge has straightened out under it. */\n --_chit-tail-offset: calc(var(--chit-bubble-radius) / 4 + 1px);\n }\n\n [part~='messages'] {\n flex: 1 1 auto;\n min-height: 0;\n overflow-y: auto;\n overscroll-behavior: contain;\n scrollbar-width: thin;\n }\n\n [part~='messages-inner'] {\n display: flex;\n flex-direction: column;\n gap: 0.75em;\n padding: 1em;\n }\n\n /*\n * The row spans the full width and the bubble is capped inside it. Letting\n * the row shrink to fit instead would make the bubble's percentage cap\n * resolve against a shrink-to-fit parent, and because the content sets\n * overflow-wrap: anywhere its min-content width is one character — so the\n * bubble collapsed to a single column of letters.\n */\n [part~='message'] {\n display: flex;\n /*\n * The icon sits level with the top of the speaker's block — beside the\n * name when there is one, beside the bubble's first line otherwise. At\n * the bottom it would end up next to the timestamp, away from everything\n * it identifies.\n */\n align-items: flex-start;\n gap: 0.5em;\n width: 100%;\n max-width: 100%;\n }\n\n [part~='message'] .body {\n display: flex;\n min-width: 0;\n max-width: 78%;\n flex-direction: column;\n gap: 0.25em;\n }\n\n /* Reversed row: the bubble sits at the right edge without shrinking the row. */\n [part~='message-user'] {\n flex-direction: row-reverse;\n }\n\n [part~='message-user'] .body {\n align-items: flex-end;\n }\n\n [part~='bubble'] {\n position: relative;\n padding: 0.6em 0.85em;\n border-radius: var(--chit-bubble-radius);\n background: var(--chit-color-assistant-bg);\n color: var(--chit-color-assistant-text);\n }\n\n [part~='message-user'] [part~='bubble'] {\n background: var(--chit-color-user-bg);\n color: var(--chit-color-user-text);\n border-bottom-right-radius: 4px;\n }\n\n [part~='message-assistant'] [part~='bubble'] {\n border-bottom-left-radius: 4px;\n }\n\n /* --- tails -------------------------------------------------------------\n *\n * A tail is one pseudo-element: a box in the bubble's colour, clipped to a\n * leaf whose point sits outside the bubble and whose root is buried inside\n * it. Burying the root is what makes the join disappear — the bubble's own\n * background covers the seam, so every corner keeps its radius and the two\n * read as one shape at any radius.\n *\n * It hangs a little below the corner, where the bubble's edge has\n * straightened out, so the root has something flat to sit against. The\n * offset follows the radius for that reason.\n *\n * The other side and the downward version are the same path mirrored, so\n * the curve is written once.\n */\n\n [part~='bubble']::after,\n [part~='typing']::after {\n content: '';\n display: none;\n position: absolute;\n width: var(--_chit-tail-w);\n height: var(--_chit-tail-h);\n clip-path: path('M 18 0.5 Q 8 0.8 0.5 3.5 Q 0 5.2 2 7 Q 10 9.5 18 19 Z');\n }\n\n /*\n * Everything below needs clip-path: path() to draw the leaf. Where that is\n * missing the tail stays hidden and the bubble keeps its default shape,\n * rather than a bare rectangle poking out of its side.\n */\n @supports (clip-path: path('M 0 0 Z')) {\n :host([data-bubble-tail='top']) [part~='bubble']::after,\n :host([data-bubble-tail='bottom']) [part~='bubble']::after,\n :host([data-bubble-tail='top']) [part~='typing']::after,\n :host([data-bubble-tail='bottom']) [part~='typing']::after {\n display: block;\n }\n\n /*\n * With a tail there is no need to clip the speaker's corner as well: one\n * bubble carries one cue about who is talking, not two.\n */\n :host([data-bubble-tail='top']) [part~='bubble'],\n :host([data-bubble-tail='bottom']) [part~='bubble'],\n :host([data-bubble-tail='top']) [part~='typing'],\n :host([data-bubble-tail='bottom']) [part~='typing'] {\n border-radius: var(--chit-bubble-radius);\n }\n\n /* Their side: the leaf points left, its root inside the bubble. */\n :host([data-bubble-tail]) [part~='message-assistant'] [part~='bubble']::after,\n :host([data-bubble-tail]) [part~='typing']::after {\n right: calc(100% - var(--_chit-tail-root));\n background: var(--chit-color-assistant-bg);\n }\n\n /* Your side: the same leaf, mirrored. */\n :host([data-bubble-tail]) [part~='message-user'] [part~='bubble']::after {\n left: calc(100% - var(--_chit-tail-root));\n background: var(--chit-color-user-bg);\n transform: scaleX(-1);\n }\n\n :host([data-bubble-tail='top']) [part~='bubble']::after,\n :host([data-bubble-tail='top']) [part~='typing']::after {\n top: var(--_chit-tail-offset);\n }\n\n :host([data-bubble-tail='bottom']) [part~='bubble']::after,\n :host([data-bubble-tail='bottom']) [part~='typing']::after {\n bottom: var(--_chit-tail-offset);\n }\n\n :host([data-bubble-tail='bottom']) [part~='message-assistant'] [part~='bubble']::after,\n :host([data-bubble-tail='bottom']) [part~='typing']::after {\n transform: scaleY(-1);\n }\n\n :host([data-bubble-tail='bottom']) [part~='message-user'] [part~='bubble']::after {\n transform: scale(-1, -1);\n }\n }\n\n [part~='avatar'] {\n flex: none;\n width: 2em;\n height: 2em;\n border-radius: 50%;\n object-fit: cover;\n }\n\n /*\n * A message that hides the theme's icon (avatar: null, for the second and\n * later messages in a run) keeps its place in the row, so the bubbles below\n * stay in line with the one that shows the face.\n */\n [part~='avatar'][data-placeholder] {\n visibility: hidden;\n }\n\n [part~='name'] {\n font-size: 0.8em;\n color: var(--chit-color-system-text);\n }\n\n [part~='meta'] {\n display: flex;\n gap: 0.5em;\n font-size: 0.75em;\n color: var(--chit-color-system-text);\n }\n\n [part~='status'][data-status='error'] {\n color: #d93025;\n }\n\n [part~='message-system'] {\n justify-content: center;\n font-size: 0.8em;\n color: var(--chit-color-system-text);\n text-align: center;\n }\n\n /* --- streaming and typing --------------------------------------------- */\n\n [part~='cursor'] {\n display: inline-block;\n width: 0.5em;\n height: 1em;\n margin-inline-start: 0.15em;\n background: currentColor;\n opacity: 0.6;\n vertical-align: text-bottom;\n animation: chit-caret 1s step-end infinite;\n }\n\n @keyframes chit-caret {\n 50% {\n opacity: 0;\n }\n }\n\n [part~='typing'] {\n position: relative;\n align-self: flex-start;\n /* Indented past the speaker's icon, when the theme gives them one. */\n margin-inline-start: var(--_chit-speaker-gutter, 0px);\n padding: 0.7em 0.9em;\n border-radius: var(--chit-bubble-radius);\n border-bottom-left-radius: 4px;\n background: var(--chit-color-assistant-bg);\n color: var(--chit-color-assistant-text);\n }\n\n [part~='typing'] .dots {\n display: inline-flex;\n gap: 0.25em;\n }\n\n [part~='typing'] .dots i {\n width: 0.4em;\n height: 0.4em;\n border-radius: 50%;\n background: currentColor;\n opacity: 0.4;\n animation: chit-typing 1.2s ease-in-out infinite;\n }\n\n [part~='typing'] .dots i:nth-child(2) {\n animation-delay: 0.15s;\n }\n [part~='typing'] .dots i:nth-child(3) {\n animation-delay: 0.3s;\n }\n\n @keyframes chit-typing {\n 0%,\n 60%,\n 100% {\n opacity: 0.35;\n transform: translateY(0);\n }\n 30% {\n opacity: 1;\n transform: translateY(-3px);\n }\n }\n\n /* --- jump to latest ---------------------------------------------------- */\n\n [part~='to-latest'] {\n position: absolute;\n left: 50%;\n bottom: 5.5em;\n transform: translateX(-50%);\n padding: 0.35em 0.9em;\n border: 1px solid var(--chit-color-border);\n border-radius: 999px;\n background: var(--chit-color-bg);\n color: var(--chit-color-text);\n box-shadow: 0 2px 8px rgba(0, 0, 0, 0.16);\n font: inherit;\n font-size: 0.8em;\n cursor: pointer;\n }\n\n [part~='to-latest']:focus-visible {\n outline: 2px solid var(--chit-color-accent);\n outline-offset: 2px;\n }\n\n @media (prefers-reduced-motion: reduce) {\n [part~='cursor'],\n [part~='typing'] .dots i {\n animation: none;\n }\n }\n`;\n","// @ts-check\nimport { css } from 'lit';\n\n/**\n * Everything that keeps arbitrary consumer HTML inside its bubble.\n *\n * The widget has no say over what goes in a message, so the containment is\n * structural rather than a list of rules per element: the content box declares\n * its own size, refuses to grow past the bubble, and contains its layout and\n * paint so a stray position or margin cannot escape.\n */\nexport const contentStyles = css`\n [part~='message-content'] {\n min-width: 0;\n max-width: 100%;\n /* Long URLs and unbroken words wrap instead of widening the bubble. */\n overflow-wrap: anywhere;\n word-break: normal;\n overflow-x: hidden;\n /* Keeps a fixed or hugely-margined child from painting outside. */\n contain: layout paint;\n line-height: 1.5;\n }\n\n /*\n * Plain text keeps its line breaks. Only this form: applying pre-wrap to\n * html content would turn the newlines and indentation of the markup itself\n * into visible blank lines.\n */\n [part~='message-content'][data-content='text'] {\n white-space: pre-wrap;\n }\n\n [part~='message-content'] > :first-child {\n margin-top: 0;\n }\n [part~='message-content'] > :last-child {\n margin-bottom: 0;\n }\n\n /* Only direct children: a tooltip nested deeper still positions normally. */\n [part~='message-content'] > * {\n position: static !important;\n }\n\n [part~='message-content'] img,\n [part~='message-content'] video,\n [part~='message-content'] iframe,\n [part~='message-content'] svg,\n [part~='message-content'] canvas,\n [part~='message-content'] picture,\n [part~='message-content'] embed,\n [part~='message-content'] object {\n max-width: 100%;\n height: auto;\n display: block;\n }\n\n /* Wide content scrolls inside itself rather than stretching the bubble. */\n [part~='message-content'] table {\n display: block;\n max-width: 100%;\n overflow-x: auto;\n border-collapse: collapse;\n }\n\n [part~='message-content'] pre {\n max-width: 100%;\n overflow-x: auto;\n white-space: pre;\n }\n\n [part~='message-content'] code {\n overflow-wrap: anywhere;\n }\n\n [part~='message-content'] a {\n color: var(--chit-color-accent);\n }\n\n [part~='message-content'] button,\n [part~='message-content'] input,\n [part~='message-content'] select,\n [part~='message-content'] textarea {\n font: inherit;\n max-width: 100%;\n }\n\n [part~='message-content'] h1,\n [part~='message-content'] h2,\n [part~='message-content'] h3,\n [part~='message-content'] h4,\n [part~='message-content'] h5,\n [part~='message-content'] h6 {\n font-size: 1.1em;\n margin: 0.5em 0;\n }\n\n [part~='message-content'] p {\n margin: 0.5em 0;\n }\n\n [part~='message-content'] ul,\n [part~='message-content'] ol {\n margin: 0.5em 0;\n padding-inline-start: 1.5em;\n }\n\n [part~='message-content'] blockquote {\n margin: 0.5em 0;\n padding-inline-start: 0.75em;\n border-inline-start: 3px solid var(--chit-color-border);\n }\n\n [part~='message-content'] hr {\n border: 0;\n border-top: 1px solid var(--chit-color-border);\n }\n`;\n","// @ts-check\nimport { css } from 'lit';\n\nexport const composerStyles = css`\n [part~='composer'] {\n display: flex;\n flex: none;\n align-items: flex-end;\n gap: 0.5em;\n padding: 0.6em 0.75em;\n border-top: 1px solid var(--chit-color-border);\n background: var(--chit-color-input-bg);\n }\n\n [part~='input'] {\n flex: 1 1 auto;\n min-width: 0;\n /* One row to start with, growing to the theme's limit. */\n field-sizing: content;\n max-height: calc(1.5em * var(--_chit-input-max-rows, 5) + 1em);\n padding: 0.45em 0.6em;\n border: 1px solid var(--chit-color-border);\n border-radius: 12px;\n background: var(--chit-color-input-bg);\n color: var(--chit-color-input-text);\n font: inherit;\n line-height: 1.5;\n resize: none;\n overflow-y: auto;\n }\n\n [part~='input']::placeholder {\n color: var(--chit-color-input-placeholder);\n }\n\n [part~='input']:focus-visible {\n outline: 2px solid var(--chit-color-accent);\n outline-offset: -1px;\n }\n\n [part~='input']:disabled {\n opacity: 0.6;\n cursor: not-allowed;\n }\n\n [part~='counter'] {\n align-self: center;\n font-size: 0.75em;\n color: var(--chit-color-system-text);\n font-variant-numeric: tabular-nums;\n }\n\n [part~='counter'][data-over] {\n color: #d93025;\n font-weight: 600;\n }\n\n /* Out of sight, but still clickable from the button beside it. */\n [part~='attach-input'] {\n display: none;\n }\n\n [part~='attach-button'] {\n display: grid;\n flex: none;\n place-items: center;\n width: 2.4em;\n height: 2.4em;\n padding: 0;\n border: 0;\n border-radius: 50%;\n background: transparent;\n color: var(--chit-color-system-text);\n cursor: pointer;\n transition: opacity 120ms ease;\n }\n\n [part~='attach-button'] svg {\n width: 1.3em;\n height: 1.3em;\n }\n\n [part~='attach-button']:hover:not(:disabled) {\n background: color-mix(in srgb, currentColor 10%, transparent);\n }\n\n [part~='attach-button']:focus-visible {\n outline: 2px solid var(--chit-color-accent);\n outline-offset: 2px;\n }\n\n [part~='attach-button']:disabled {\n opacity: 0.4;\n cursor: default;\n }\n\n [part~='send-button'] {\n display: grid;\n flex: none;\n place-items: center;\n width: 2.4em;\n height: 2.4em;\n padding: 0;\n border: 0;\n border-radius: 50%;\n background: var(--chit-color-accent);\n color: #fff;\n cursor: pointer;\n transition: opacity 120ms ease;\n }\n\n [part~='send-button'] svg {\n width: 1.1em;\n height: 1.1em;\n }\n\n [part~='send-button']:disabled {\n opacity: 0.4;\n cursor: default;\n }\n\n [part~='send-button']:focus-visible {\n outline: 2px solid var(--chit-color-accent);\n outline-offset: 2px;\n }\n\n [part~='spinner'] {\n width: 1.1em;\n height: 1.1em;\n border: 2px solid currentColor;\n border-top-color: transparent;\n border-radius: 50%;\n animation: chit-spin 0.7s linear infinite;\n }\n\n @keyframes chit-spin {\n to {\n transform: rotate(360deg);\n }\n }\n\n @media (prefers-reduced-motion: reduce) {\n [part~='spinner'] {\n animation-duration: 2s;\n }\n }\n`;\n","// @ts-check\nimport { LitElement, html, nothing } from 'lit';\n\nimport { unsafeHTML } from 'lit/directives/unsafe-html.js';\n\nimport { StateController } from './controllers/state-controller.js';\nimport { BreakpointController } from './controllers/breakpoint-controller.js';\nimport { ThemeController } from './controllers/theme-controller.js';\nimport { ScrollController } from './controllers/scroll-controller.js';\nimport { ComposerController } from './controllers/composer-controller.js';\nimport { renderLauncher } from './render/launcher.js';\nimport { renderPanel } from './render/panel.js';\nimport { resolveLabels, resolveLocale } from './i18n/labels.js';\nimport { Events, emit } from './events.js';\nimport { componentInstance, contentKey, pruneComponents } from './render/content.js';\nimport { AdoptedSheet } from './styles/adopted-sheet.js';\nimport { hostStyles } from './styles/host.css.js';\nimport { launcherStyles } from './styles/launcher.css.js';\nimport { panelStyles } from './styles/panel.css.js';\nimport { messageStyles } from './styles/message.css.js';\nimport { contentStyles } from './styles/content.css.js';\nimport { composerStyles } from './styles/composer.css.js';\n\n/** @import { Message, Theme, ChatState, Trigger, Effect, Device, ResolvedTheme } from './types.js' */\n/** @import { Labels } from './i18n/labels.js' */\n\n/**\n * The chat widget.\n *\n * One custom element, one shadow root. Everything inside is drawn by plain\n * functions in `render/` and driven by the reactive controllers in\n * `controllers/`; no nested custom elements, so `::part()` and the theme's\n * custom properties reach every corner without being forwarded.\n *\n * @element chit-ui\n *\n * @slot launcher - Replaces the whole closed-state button content.\n * @slot header - Replaces the panel header.\n * @slot header-title - Replaces only the title area of the header.\n * @slot header-actions - Extra buttons beside the close button.\n * @slot footer - Below the composer (disclaimers, attribution).\n */\nexport class ChitUI extends LitElement {\n /** @override */\n static styles = [\n hostStyles,\n launcherStyles,\n panelStyles,\n messageStyles,\n contentStyles,\n composerStyles,\n ];\n\n /** @override */\n static properties = {\n state: { type: String, reflect: true, noAccessor: true },\n theme: { type: Object },\n messages: { type: Array },\n typing: { type: Object },\n busy: { type: Boolean, reflect: true },\n inputDisabled: { type: Boolean, reflect: true, attribute: 'input-disabled' },\n inputHidden: { type: Boolean, reflect: true, attribute: 'input-hidden' },\n placeholder: { type: String, reflect: true },\n sendOnEnter: { type: Boolean, reflect: true, attribute: 'send-on-enter' },\n maxLength: { type: Number, reflect: true, attribute: 'max-length' },\n focusOnOpen: { type: String, reflect: true, attribute: 'focus-on-open' },\n locale: { type: String, reflect: true },\n labels: { type: Object },\n messageStyles: { type: String },\n };\n\n /** @type {ChatState} */\n #state = 'closed';\n\n /**\n * Set by the widget's own event handlers just before they move the state, so\n * the events can say the move came from a person rather than from code.\n *\n * @type {Trigger}\n */\n #trigger = 'api';\n\n /** @type {StateController} */\n #transitions;\n\n /** @type {BreakpointController} */\n #breakpoint;\n\n /** @type {ThemeController} */\n #themes;\n\n /** @type {ScrollController} */\n #scroll;\n\n /** @type {ComposerController} */\n #composer;\n\n /** Consumer CSS for the inside of message bubbles. */\n #messageSheet = new AdoptedSheet('data-chit-message-styles');\n\n /** What each message's content was built from last render, by id. */\n /** @type {Map<string, unknown>} */\n #renderedContent = new Map();\n\n /** The in-flight transition, so the methods can hand it back to the caller. */\n /** @type {Promise<boolean> | null} */\n #settled = null;\n\n constructor() {\n super();\n\n /** @type {Theme} Partial; unset keys fall back to the default theme. */\n this.theme = {};\n\n /** @type {Message[]} Rendered as given. The library never mutates this. */\n this.messages = [];\n\n /** @type {boolean | { html: string }} Show the \"typing\" bubble. */\n this.typing = false;\n\n /** @type {boolean} Lock the composer while a reply is in flight. */\n this.busy = false;\n\n /** @type {boolean} */\n this.inputDisabled = false;\n\n /** @type {boolean} */\n this.inputHidden = false;\n\n /** @type {string | undefined} */\n this.placeholder = undefined;\n\n /** @type {boolean} */\n this.sendOnEnter = true;\n\n /** @type {number | undefined} */\n this.maxLength = undefined;\n\n /**\n * Focus the composer once the open transition finishes. 'auto' focuses on\n * PC only, so a phone keyboard never pops up unasked.\n *\n * Named focusOnOpen rather than autofocus: HTMLElement.autofocus is a\n * standard boolean property and cannot carry a third value.\n *\n * @type {'auto' | 'always' | 'never'}\n */\n this.focusOnOpen = 'auto';\n\n /** @type {string | undefined} */\n this.locale = undefined;\n\n /** @type {Partial<Labels> | undefined} Overrides for the built-in UI strings. */\n this.labels = undefined;\n\n /** @type {string} Extra CSS applied inside message content. */\n this.messageStyles = '';\n\n /** @type {((html: string) => string) | undefined} Applied to `html` messages only. */\n this.sanitize = undefined;\n\n /** @type {((time: Date) => string) | undefined} */\n this.formatTime = undefined;\n\n this.#transitions = new StateController(this, {\n animation: (from, to, phase) => this.#animationFor(from, to, phase),\n keepsLauncher: () => this.currentTheme.open.launcher === 'visible',\n onOpened: () => this.#applyOpenFocus(),\n });\n\n this.#breakpoint = new BreakpointController(this);\n this.#themes = new ThemeController(this, { device: () => this.#breakpoint.device });\n this.addController(this.#themes);\n this.#scroll = new ScrollController(this, {\n behavior: () => this.currentTheme.open.animation.scroll,\n });\n this.#composer = new ComposerController(this);\n }\n\n /**\n * Current state. Assigning it starts the transition, exactly as calling the\n * matching method would.\n *\n * @type {ChatState}\n */\n get state() {\n return this.#state;\n }\n\n set state(value) {\n const previous = this.#state;\n if (value === previous) return;\n this.#state = value;\n this.requestUpdate('state', previous);\n\n // A transition the controller itself is applying (a revert, or the tail of\n // a method call) must not start another one.\n if (!this.#transitions || this.#transitions.applying) return;\n const trigger = this.#trigger;\n this.#trigger = 'api';\n\n const settled = this.#transitions.request(value, trigger);\n this.#settled = settled;\n void settled.then(() => {\n if (this.#settled === settled) this.#settled = null;\n });\n }\n\n /** @returns {Device} Which theme bucket the viewport currently falls in. */\n get device() {\n return this.#breakpoint.device;\n }\n\n /**\n * The theme in force for this device, every gap filled in.\n *\n * @returns {ResolvedTheme}\n */\n get currentTheme() {\n return this.#themes.current;\n }\n\n /** @returns {Labels} */\n get currentLabels() {\n return resolveLabels(this.locale, this.labels);\n }\n\n /**\n * The language in force: the `locale` property, else the document's.\n * Labels and timestamps both read it, so a page in Japanese does not end up\n * with Japanese buttons and American clock times.\n *\n * @returns {string | undefined}\n */\n get resolvedLocale() {\n return resolveLocale(this.locale);\n }\n\n /** @returns {ChatState} What the DOM is showing, which lags `state` while animating. */\n get renderedState() {\n return this.#transitions.renderedState;\n }\n\n /** @returns {boolean} True when messages arrived while the reader was scrolled up. */\n get hasUnseen() {\n return this.#scroll.hasUnseen;\n }\n\n /**\n * What is currently typed in the composer.\n *\n * Not a reactive property on purpose: a keystroke would otherwise re-render\n * the whole shadow tree, every message included.\n *\n * @type {string}\n */\n get value() {\n return this.#composer.value;\n }\n\n set value(next) {\n this.#composer.value = next;\n }\n\n /** @returns {boolean} Whether what is typed could be sent right now. */\n get canSend() {\n return this.#composer.canSend;\n }\n\n // --- public API -------------------------------------------------------\n\n /** @returns {Promise<boolean>} Resolves once the open animation has finished. */\n open() {\n return this.#go('open', 'api');\n }\n\n /** @returns {Promise<boolean>} */\n close() {\n return this.#go('closed', 'api');\n }\n\n /** @returns {Promise<boolean>} */\n hide() {\n return this.#go('hidden', 'api');\n }\n\n /** @returns {Promise<boolean>} From `hidden` back to the launcher. A no-op otherwise. */\n show() {\n return this.#state === 'hidden' ? this.#go('closed', 'api') : Promise.resolve(true);\n }\n\n /** @returns {Promise<boolean>} */\n toggle() {\n return this.#go(this.state === 'open' ? 'closed' : 'open', 'api');\n }\n\n /**\n * Send what is in the composer, or the given text, as `chat-submit`.\n *\n * Adding the message to `messages` stays the consumer's job; the widget only\n * reports that someone pressed send.\n *\n * @param {string} [text]\n * @returns {boolean} False when there was nothing to send.\n */\n submit(text) {\n return this.#composer.submit(text);\n }\n\n /** Empty the composer and put the caret back in it. */\n clearInput() {\n this.#composer.clear();\n }\n\n /**\n * Scroll the conversation to the newest message.\n *\n * @param {{ smooth?: boolean }} [options]\n */\n scrollToBottom(options) {\n this.#scroll.scrollToBottom(options);\n }\n\n /**\n * The content container of one message, once it has been drawn.\n *\n * @param {string} id\n * @returns {HTMLElement | null}\n */\n getMessageElement(id) {\n return /** @type {HTMLElement | null} */ (\n this.renderRoot.querySelector(`[part~=\"message\"][data-id=\"${CSS.escape(id)}\"] [part~=\"message-content\"]`)\n );\n }\n\n /**\n * Put the caret in the composer.\n *\n * This obeys the caller, not `focusOnOpen`: someone who calls it has asked\n * for focus. `focusOnOpen` only governs what happens by itself on open.\n *\n * @returns {boolean} False when there is no composer to focus.\n */\n focusInput() {\n const input = /** @type {HTMLElement | null} */ (\n this.renderRoot.querySelector('[part~=\"input\"]')\n );\n if (!input) return false;\n input.focus();\n return true;\n }\n\n /**\n * What the widget does with focus when the panel finishes opening.\n *\n * 'never' means exactly that: focus is left wherever the person had it, so a\n * widget that opens on its own does not steal the caret out of a form on the\n * page. Otherwise the composer takes it, or the panel does when there is no\n * composer, so that Esc and screen-reader navigation start inside the dialog.\n */\n #applyOpenFocus() {\n if (this.focusOnOpen === 'never') return;\n if (this.focusOnOpen === 'auto' && this.device === 'mobile') return;\n if (this.focusInput()) return;\n\n const panel = /** @type {HTMLElement | null} */ (\n this.renderRoot.querySelector('[part~=\"panel\"]')\n );\n panel?.focus();\n }\n\n // --- composer plumbing, called by the render functions ------------------\n\n /** @param {Event} event */\n handleInput(event) {\n this.#composer.onInput(event);\n }\n\n /** @param {KeyboardEvent} event */\n handleKeydown(event) {\n this.#composer.onKeydown(event);\n }\n\n /** @param {boolean} started */\n handleComposition(started) {\n if (started) this.#composer.onCompositionStart();\n else this.#composer.onCompositionEnd();\n }\n\n /**\n * Report files the reader picked with the attach button.\n *\n * Nothing is uploaded, previewed or added to the conversation here: the\n * widget does not own `messages` and has nowhere to send bytes.\n *\n * @param {File[]} files\n * @returns {void}\n */\n handleAttach(files) {\n emit(this, Events.ATTACH, { files });\n }\n\n /** Open the file picker from code, as the attach button does. */\n openAttach() {\n const field = /** @type {HTMLInputElement | null} */ (\n this.renderRoot.querySelector('[part~=\"attach-input\"]')\n );\n field?.click();\n }\n\n // --- internal ---------------------------------------------------------\n\n /**\n * Render a consumer-supplied typing bubble.\n *\n * @param {string} markup\n * @returns {unknown}\n */\n renderTypingHtml(markup) {\n return unsafeHTML(this.sanitize ? this.sanitize(markup) : markup);\n }\n\n /**\n * Re-publish a click inside a message as `chat-message-click`.\n *\n * `composedPath()[0]` rather than `event.target`: the target is retargeted to\n * the message container once the event leaves a component's shadow root, and\n * the consumer wants the element actually clicked.\n *\n * @param {MouseEvent} event\n */\n handleMessageClick(event) {\n const path = event.composedPath();\n const article = /** @type {HTMLElement | undefined} */ (\n path.find(\n (node) =>\n node instanceof HTMLElement && node.getAttribute('part')?.split(/\\s+/).includes('message'),\n )\n );\n if (!article) return;\n\n const id = article.dataset.id;\n const message = this.messages.find((candidate) => candidate.id === id);\n if (!message) return;\n\n const target = /** @type {Element} */ (path[0]);\n const allowed = emit(\n this,\n Events.MESSAGE_CLICK,\n { message, target, originalEvent: event },\n { cancelable: true },\n );\n if (!allowed) event.preventDefault();\n }\n\n /** Called by the launcher; the resulting events report `trigger: 'user'`. */\n toggleFromUser() {\n return this.#go(this.state === 'open' ? 'closed' : 'open', 'user');\n }\n\n /** Called by the close button and by Esc. */\n closeFromUser() {\n return this.#go('closed', 'user');\n }\n\n /**\n * Ask to start the conversation over.\n *\n * The widget only announces it: `messages` belongs to the consumer, so\n * clearing it, replaying a scenario or asking for confirmation first are all\n * theirs to do. Cancelling the event is not offered for the same reason —\n * there is nothing here to cancel.\n *\n * @param {Trigger} [trigger='api']\n * @returns {void}\n */\n home(trigger = 'api') {\n emit(this, Events.HOME, { trigger });\n }\n\n /**\n * @param {ChatState} to\n * @param {Trigger} trigger\n * @returns {Promise<boolean>}\n */\n #go(to, trigger) {\n if (to !== this.#state) {\n this.#trigger = trigger;\n this.state = to;\n }\n return this.#settled ?? Promise.resolve(true);\n }\n\n /**\n * Which effect and how long, for one leg of a transition.\n *\n * Leaving for `hidden` uses the hidden theme's exit; every other leg uses the\n * theme of the state being left or entered.\n *\n * @param {ChatState} from\n * @param {ChatState} to\n * @param {'enter' | 'exit'} phase\n * @returns {{ effect: Effect, duration: number }}\n */\n #animationFor(from, to, phase) {\n const theme = this.currentTheme;\n\n if (phase === 'exit' && to === 'hidden') {\n return { effect: theme.hidden.animation.exit, duration: theme.hidden.animation.duration };\n }\n\n const source = (phase === 'exit' ? from : to) === 'open' ? theme.open : theme.closed;\n return {\n effect: phase === 'exit' ? source.animation.exit : source.animation.enter,\n duration: source.animation.duration,\n };\n }\n\n /** @override */\n willUpdate() {\n // Order matters: the breakpoint decides the device, and the device decides\n // which `closed` settings the theme resolves to.\n this.#breakpoint.observe(ThemeController.breakpointOf(this.theme));\n this.#themes.apply(this.theme, this.#breakpoint.device);\n\n this.#messageSheet.write(this.messageStyles ?? '', this.renderRoot);\n\n const theme = this.currentTheme;\n this.dataset.launcherPosition = theme.closed.position;\n this.dataset.panelPosition = theme.open.position;\n this.dataset.idle = theme.closed.animation.idle;\n this.dataset.bubbleTail = theme.open.bubble.tail;\n }\n\n /** @override */\n updated() {\n const live = new Set(this.messages.map((message) => message.id));\n pruneComponents(this, live);\n this.#announceRenders(live);\n }\n\n /**\n * Fire `chat-message-render` for messages that were drawn for the first time\n * or whose content changed.\n *\n * Only the content matters here: a status or streaming flag flipping redraws\n * the bubble but leaves the consumer's markup alone, and firing then would\n * make listeners re-bind on every token of a streamed reply.\n *\n * @param {Set<string>} live\n */\n #announceRenders(live) {\n for (const id of this.#renderedContent.keys()) {\n if (!live.has(id)) this.#renderedContent.delete(id);\n }\n\n for (const message of this.messages) {\n const key = contentKey(message);\n if (this.#renderedContent.has(message.id) && Object.is(this.#renderedContent.get(message.id), key)) {\n continue;\n }\n this.#renderedContent.set(message.id, key);\n\n const element = this.getMessageElement(message.id);\n if (!element) continue;\n emit(this, Events.MESSAGE_RENDER, {\n message,\n element,\n instance: componentInstance(this, message.id),\n });\n }\n }\n\n /** @override */\n render() {\n const shown = this.renderedState;\n const showLauncher =\n shown === 'closed' || (shown === 'open' && this.currentTheme.open.launcher === 'visible');\n const showPanel = shown === 'open';\n\n return html`\n ${showLauncher ? renderLauncher(this) : nothing} ${showPanel ? renderPanel(this) : nothing}\n `;\n }\n}\n","// @ts-check\nimport { ChitUI } from './chit-ui.js';\n\nif (!customElements.get('chit-ui')) {\n customElements.define('chit-ui', ChitUI);\n}\n\nexport { ChitUI };\nexport { Events } from './events.js';\n","// @ts-check\n\n/** @import { Theme } from '../types.js' */\n\n/**\n * A green messenger look: a pale blue-grey conversation background, white\n * bubbles for them, bright green for you, tails on the top corner.\n *\n * This is Chit UI's own palette in that familiar shape. It carries no other\n * product's logo, wordmark or artwork, and the greens are Chit UI's own: the\n * deep green is dark enough that white text and the send icon clear WCAG AA\n * on it, which the bright green of the bubbles could not do.\n * `test/theme.test.js` re-checks every pair here, so a later tweak cannot\n * quietly drop below AA.\n *\n * @type {Theme}\n */\nexport const greenTheme = {\n closed: {\n colors: {\n background: '#0a6b36',\n text: '#ffffff',\n shadow: '0 4px 12px rgba(16, 42, 26, 0.32)',\n },\n },\n open: {\n radius: 12,\n colors: {\n background: '#d3ddea',\n text: '#16212c',\n accent: '#0a6b36',\n border: '#b6c5d6',\n shadow: '0 8px 32px rgba(16, 32, 48, 0.28)',\n headerBackground: '#ffffff',\n headerText: '#16212c',\n userBubble: '#9ce26c',\n userText: '#14240c',\n assistantBubble: '#ffffff',\n assistantText: '#16212c',\n systemText: '#37475a',\n inputBackground: '#ffffff',\n inputText: '#16212c',\n inputPlaceholder: '#5c6370',\n },\n bubble: { radius: 18, tail: 'top' },\n },\n};\n","import{noChange as t}from\"../lit-html.js\";import{directive as s,Directive as i,PartType as r}from\"../directive.js\";\n/**\n * @license\n * Copyright 2018 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */const e=s(class extends i{constructor(t){if(super(t),t.type!==r.ATTRIBUTE||\"class\"!==t.name||t.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 t}});export{e as classMap};\n//# sourceMappingURL=class-map.js.map\n","import{noChange as t}from\"../lit-html.js\";import{directive as e,Directive as r,PartType as s}from\"../directive.js\";\n/**\n * @license\n * Copyright 2018 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */const n=\"important\",i=\" !\"+n,o=e(class extends r{constructor(t){if(super(t),t.type!==s.ATTRIBUTE||\"style\"!==t.name||t.strings?.length>2)throw Error(\"The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute.\")}render(t){return Object.keys(t).reduce((e,r)=>{const s=t[r];return null==s?e:e+`${r=r.includes(\"-\")?r:r.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,\"-$&\").toLowerCase()}:${s};`},\"\")}update(e,[r]){const{style:s}=e.element;if(void 0===this.ft)return this.ft=new Set(Object.keys(r)),this.render(r);for(const t of this.ft)null==r[t]&&(this.ft.delete(t),t.includes(\"-\")?s.removeProperty(t):s[t]=null);for(const t in r){const e=r[t];if(null!=e){this.ft.add(t);const r=\"string\"==typeof e&&e.endsWith(i);t.includes(\"-\")||r?s.setProperty(t,r?e.slice(0,-11):e,r?n:\"\"):s[t]=e}}return t}});export{o as styleMap};\n//# sourceMappingURL=style-map.js.map\n"],"names":["t","globalThis","e","ShadowRoot","ShadyCSS","nativeShadow","Document","prototype","CSSStyleSheet","s","Symbol","o","WeakMap","n$3","constructor","this","_$cssResult$","Error","cssText","styleSheet","length","get","replaceSync","set","toString","i","reduce","n","c","cssRules","r","is","defineProperty","getOwnPropertyDescriptor","h","getOwnPropertyNames","getOwnPropertySymbols","getPrototypeOf","Object","a","trustedTypes","l","emptyScript","p","reactiveElementPolyfillSupport","d","u","toAttribute","Boolean","Array","JSON","stringify","fromAttribute","Number","parse","f","b","attribute","type","String","converter","reflect","useDefault","hasChanged","metadata","litPropertyMetadata","y$1","HTMLElement","addInitializer","_$Ei","push","observedAttributes","finalize","_$Eh","keys","createProperty","state","hasOwnProperty","create","wrapped","elementProperties","noAccessor","getPropertyDescriptor","call","requestUpdate","configurable","enumerable","getPropertyOptions","Map","finalized","properties","_$Eu","elementStyles","finalizeStyles","styles","isArray","Set","flat","reverse","unshift","toLowerCase","super","_$Ep","isUpdatePending","hasUpdated","_$Em","_$Ev","_$ES","Promise","enableUpdating","_$AL","_$E_","forEach","addController","_$EO","add","renderRoot","isConnected","hostConnected","removeController","delete","size","createRenderRoot","shadowRoot","attachShadow","shadowRootOptions","adoptedStyleSheets","map","document","createElement","litNonce","setAttribute","textContent","appendChild","connectedCallback","disconnectedCallback","hostDisconnected","attributeChangedCallback","_$AK","_$ET","removeAttribute","_$Ej","hasAttribute","C","_$EP","has","_$Eq","reject","scheduleUpdate","performUpdate","shouldUpdate","willUpdate","hostUpdate","update","_$EM","_$AE","hostUpdated","firstUpdated","updated","updateComplete","getUpdateComplete","y","mode","ReactiveElement","reactiveElementVersions","createPolicy","createHTML","Math","random","toFixed","slice","createComment","v","_","m","RegExp","g","$","x","_$litType$","strings","values","w","E","for","A","P","createTreeWalker","V","S","parts","lastIndex","exec","test","startsWith","N","el","currentNode","content","firstChild","replaceWith","childNodes","nextNode","nodeType","hasAttributes","getAttributeNames","endsWith","getAttribute","split","index","name","ctor","I","L","z","H","tagName","append","data","indexOf","innerHTML","M","_$Co","_$Cl","_$litDirective$","_$AO","_$AT","_$AS","R","_$AV","_$AN","_$AD","_$AM","parentNode","_$AU","creationScope","importNode","k","nextSibling","Z","_$AI","_$Cv","_$AH","_$AA","_$AB","options","startNode","endNode","_$AR","T","iterator","O","insertBefore","createTextNode","_$AC","_$AP","remove","setConnected","element","fill","j","arguments","toggleAttribute","capture","once","passive","removeEventListener","addEventListener","handleEvent","host","B","litHtmlPolyfillSupport","litHtmlVersions","D","renderBefore","_$litPart$","renderOptions","_$Do","render","_$litElement$","litElementHydrateSupport","LitElement","litElementPolyfillSupport","litElementVersions","i$2","_$Ct","_$Ci","e$1","it","directiveName","_t","raw","resultType","Events","freeze","SUBMIT","BEFORE_OPEN","OPEN","BEFORE_CLOSE","CLOSE","HIDE","SHOW","STATE_CHANGE","INPUT","MESSAGE_RENDER","MESSAGE_CLICK","SCROLL_TOP","BREAKPOINT_CHANGE","HOME","ATTACH","emit","detail","cancelable","dispatchEvent","CustomEvent","bubbles","composed","PART_FOR_STATE","closed","open","hidden","StateController","resolveAnimation","keepsLauncher","onOpened","current","rendered","applying","generation","settle","stopWaiting","restoreFocusToLauncher","animation","renderedState","dataset","request","to","trigger","from","resolve","announceIntent","interrupt","assign","run","settled","focusIsInsidePanel","leaving","elementFor","launcherSurvives","animate","arriving","announceArrival","manageFocus","focus","active","activeElement","panel","contains","part","querySelector","phase","spec","effect","duration","window","matchMedia","matches","finished","finish","event","target","clearTimeout","timer","style","removeProperty","anim","setProperty","setTimeout","BreakpointController","query","breakpoint","device","measured","onChange","observe","apply","PALETTE","CLOSED_PC","position","offset","radius","image","label","component","props","colors","background","text","shadow","enter","exit","idle","CLOSED_MOBILE_DIFF","defaultTheme","zIndex","font","family","pc","mobile","width","height","launcher","header","visible","title","logo","home","accent","border","headerBackground","headerText","userBubble","userText","assistantBubble","assistantText","systemText","inputBackground","inputText","inputPlaceholder","bubble","tail","speaker","assistant","avatar","user","scroll","input","maxRows","placeholder","attach","accept","multiple","mobileClosedDefaults","isPlainObject","value","mergeTheme","base","override","out","key","entries","undefined","resolveTheme","theme","perDevice","shared","resolveClosed","px","url","replace","themeToCss","declarations","themeToVariables","join","SUPPORTS_ADOPTING","AdoptedSheet","sheet","written","marker","root","includes","write","css","detach","ThemeController","resolved","breakpointOf","ScrollController","preferredBehavior","viewport","resize","atBottom","hasUnseen","atTop","followAfterRender","selfScrolling","selfScrollTimer","openingJump","lastId","lastCount","behavior","unbind","messages","last","grew","newTail","id","role","bind","followBehavior","scrollNow","onScroll","onScrollEnd","inner","firstElementChild","ResizeObserver","disconnect","endSelfScroll","scrollHeight","scrollTop","clientHeight","scrollToBottom","smooth","beginSelfScroll","scrollTo","top","distance","SUPPORTS_FIELD_SIZING","CSS","supports","ComposerController","composing","justComposed","composedTimer","next","grow","syncDerived","canSend","busy","inputDisabled","trim","limit","maxLength","onInput","onCompositionStart","onCompositionEnd","onKeydown","sendOnEnter","shiftKey","altKey","ctrlKey","metaKey","isComposing","keyCode","preventDefault","submit","clear","send","disabled","counter","remaining","over","labels","currentLabels","template","overLimit","charactersLeft","abs","INSTANCES","messageKey","CONTENT_FIELDS","contentField","message","present","filter","field","contentKey","resolveComponent","source","cache","existing","registry","registered","getName","declared","tagNameOf","componentInstance","renderContent","carrier","html","unsafeHTML","sanitize","renderLauncher","currentTheme","custom","toggleFromUser","nothing","defaultIcon","defaultContent","_$AQ","dt","ut","renderMessage","meta","time","status","streaming","date","Date","isNaN","getTime","formatTime","Intl","DateTimeFormat","resolvedLocale","hour","minute","format","renderComposer","inputHidden","openAttach","files","handleAttach","renderAttach","live","handleInput","handleKeydown","handleComposition","renderPanel","defaultPrevented","closeFromUser","close","renderHeader","typing","empty","conversation","handleMessageClick","repeat","renderTypingHtml","toLatest","renderMessageList","BUILT_IN","ja","sending","sent","error","en","resolveLocale","locale","documentElement","lang","hostStyles","launcherStyles","panelStyles","messageStyles","contentStyles","composerStyles","ChitUI","static","focusOnOpen","transitions","themes","composer","messageSheet","renderedContent","animationFor","applyOpenFocus","previous","then","overrides","resolveLabels","go","hide","show","toggle","clearInput","getMessageElement","escape","focusInput","started","click","markup","path","composedPath","article","find","node","candidate","originalEvent","launcherPosition","panelPosition","bubbleTail","liveIds","pruneComponents","announceRenders","instance","shown","showLauncher","showPanel","customElements","define","greenTheme","st","nt","classList","ft"],"mappings":"AAKA,MAAMA,EAAEC,WAAWC,EAAEF,EAAEG,kBAAa,IAASH,EAAEI,UAAUJ,EAAEI,SAASC,eAAe,uBAAuBC,SAASC,WAAW,YAAYC,cAAcD,UAAUE,EAAEC,SAASC,EAAE,IAAIC,QAAO,IAAAC,EAAC,MAAQ,WAAAC,CAAYd,EAAEE,EAAES,GAAG,GAAGI,KAAKC,cAAa,EAAGL,IAAIF,EAAE,MAAMQ,MAAM,qEAAqEF,KAAKG,QAAQlB,EAAEe,KAAKf,EAAEE,CAAC,CAAC,cAAIiB,GAAa,IAAInB,EAAEe,KAAKJ,EAAE,MAAMF,EAAEM,KAAKf,EAAE,GAAGE,QAAG,IAASF,EAAE,CAAC,MAAME,OAAE,IAASO,GAAG,IAAIA,EAAEW,OAAOlB,IAAIF,EAAEW,EAAEU,IAAIZ,SAAI,IAAST,KAAKe,KAAKJ,EAAEX,EAAE,IAAIQ,eAAec,YAAYP,KAAKG,SAAShB,GAAGS,EAAEY,IAAId,EAAET,GAAG,CAAC,OAAOA,CAAC,CAAC,QAAAwB,GAAW,OAAOT,KAAKG,OAAO,GAAO,MAAgDO,EAAE,CAACzB,KAAKE,KAAK,MAAMS,EAAE,IAAIX,EAAEoB,OAAOpB,EAAE,GAAGE,EAAEwB,OAAO,CAACxB,EAAEO,EAAEE,IAAIT,EAAE,CAACF,IAAI,IAAG,IAAKA,EAAEgB,aAAa,OAAOhB,EAAEkB,QAAQ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,KAAKe,KAAKwqB,GAAG,MAAMzpB,EAAE9B,KAAKe,KAAKwqB,GAAG/jB,OAAOxH,GAAGA,EAAEsd,SAAS,KAAK7c,EAAE6W,eAAetX,GAAGS,EAAET,GAAG,MAAM,IAAI,MAAMA,KAAK8B,EAAE,CAAC,MAAM5B,EAAE4B,EAAE9B,GAAG,GAAG,MAAME,EAAE,CAACa,KAAKwqB,GAAGpkB,IAAInH,GAAG,MAAM8B,EAAE,iBAAiB5B,GAAGA,EAAE4M,SAASrL,IAAGzB,EAAEsd,SAAS,MAAMxb,EAAErB,EAAE+W,YAAYxX,EAAE8B,EAAE5B,EAAEwK,MAAM,GAAE,IAAKxK,EAAE4B,EAAEH,GAAE,IAAIlB,EAAET,GAAGE,CAAC,CAAC,CAAC,OAAOF,CAAC","x_google_ignoreList":[0,1,2,3,4,5,18,19,21,35,36]}
1
+ {"version":3,"file":"chit-ui.min.js","sources":["../node_modules/@lit/reactive-element/css-tag.js","../node_modules/@lit/reactive-element/reactive-element.js","../node_modules/lit-html/lit-html.js","../node_modules/lit-element/lit-element.js","../node_modules/lit-html/directive.js","../node_modules/lit-html/directives/unsafe-html.js","../src/events.js","../src/controllers/state-controller.js","../src/controllers/breakpoint-controller.js","../src/theme/default-theme.js","../src/theme/merge-theme.js","../src/theme/theme-to-css.js","../src/styles/adopted-sheet.js","../src/controllers/theme-controller.js","../src/controllers/scroll-controller.js","../src/controllers/composer-controller.js","../src/controllers/drag-controller.js","../src/controllers/scroll-lock-controller.js","../src/controllers/viewport-controller.js","../src/render/content.js","../src/render/launcher.js","../node_modules/lit-html/directive-helpers.js","../node_modules/lit-html/directives/repeat.js","../src/render/message.js","../src/render/message-list.js","../node_modules/lit-html/directives/live.js","../src/render/composer.js","../src/render/panel.js","../src/i18n/labels.js","../src/styles/host.css.js","../src/styles/launcher.css.js","../src/styles/panel.css.js","../src/styles/message.css.js","../src/styles/content.css.js","../src/styles/composer.css.js","../src/chit-ui.js","../src/index.js","../src/themes/green.js","../node_modules/lit-html/directives/class-map.js","../node_modules/lit-html/directives/style-map.js"],"sourcesContent":["/**\n * @license\n * Copyright 2019 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\nconst t=globalThis,e=t.ShadowRoot&&(void 0===t.ShadyCSS||t.ShadyCSS.nativeShadow)&&\"adoptedStyleSheets\"in Document.prototype&&\"replace\"in CSSStyleSheet.prototype,s=Symbol(),o=new WeakMap;class n{constructor(t,e,o){if(this._$cssResult$=!0,o!==s)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&&void 0===t){const e=void 0!==s&&1===s.length;e&&(t=o.get(s)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),e&&o.set(s,t))}return t}toString(){return this.cssText}}const r=t=>new n(\"string\"==typeof t?t:t+\"\",void 0,s),i=(t,...e)=>{const o=1===t.length?t[0]:e.reduce((e,s,o)=>e+(t=>{if(!0===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(o,t,s)},S=(s,o)=>{if(e)s.adoptedStyleSheets=o.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet);else for(const e of o){const o=document.createElement(\"style\"),n=t.litNonce;void 0!==n&&o.setAttribute(\"nonce\",n),o.textContent=e.cssText,s.appendChild(o)}},c=e?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e=\"\";for(const s of t.cssRules)e+=s.cssText;return r(e)})(t):t;export{n as CSSResult,S as adoptStyles,i as css,c as getCompatibleStyle,e as supportsAdoptingStyleSheets,r as unsafeCSS};\n//# sourceMappingURL=css-tag.js.map\n","import{getCompatibleStyle as t,adoptStyles as s}from\"./css-tag.js\";export{CSSResult,css,supportsAdoptingStyleSheets,unsafeCSS}from\"./css-tag.js\";\n/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */const{is:i,defineProperty:e,getOwnPropertyDescriptor:h,getOwnPropertyNames:r,getOwnPropertySymbols:o,getPrototypeOf:n}=Object,a=globalThis,c=a.trustedTypes,l=c?c.emptyScript:\"\",p=a.reactiveElementPolyfillSupport,d=(t,s)=>t,u={toAttribute(t,s){switch(s){case Boolean:t=t?l: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=(t,s)=>!i(t,s),b={attribute:!0,type:String,converter:u,reflect:!1,useDefault:!1,hasChanged:f};Symbol.metadata??=Symbol(\"metadata\"),a.litPropertyMetadata??=new WeakMap;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){if(s.state&&(s.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(t)&&((s=Object.create(s)).wrapped=!0),this.elementProperties.set(t,s),!s.noAccessor){const i=Symbol(),h=this.getPropertyDescriptor(t,i,s);void 0!==h&&e(this.prototype,t,h)}}static getPropertyDescriptor(t,s,i){const{get:e,set:r}=h(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:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??b}static _$Ei(){if(this.hasOwnProperty(d(\"elementProperties\")))return;const t=n(this);t.finalize(),void 0!==t.l&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(d(\"finalized\")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(d(\"properties\"))){const t=this.properties,s=[...r(t),...o(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(t(s))}else void 0!==s&&i.push(t(s));return i}static _$Eu(t,s){const i=s.attribute;return!1===i?void 0:\"string\"==typeof i?i:\"string\"==typeof t?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,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(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),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&&!0===i.reflect){const h=(void 0!==i.converter?.toAttribute?i.converter:u).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;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=!1,h){if(void 0!==t){const r=this.constructor;if(!1===e&&(h=this[t]),i??=r.getPropertyOptions(t),!((i.hasChanged??f)(h,s)||i.useDefault&&i.reflect&&h===this._$Ej?.get(t)&&!this.hasAttribute(r._$Eu(t,i))))return;this.C(t,s,i)}!1===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]),!0!==h||void 0!==r)||(this._$AL.has(t)||(this.hasUpdated||i||(s=void 0),this._$AL.set(t,s)),!0===e&&this._$Em!==t&&(this._$Eq??=new Set).add(t))}async _$EP(){this.isUpdatePending=!0;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];!0!==t||this._$AL.has(s)||void 0===e||this.C(s,void 0,i,e)}}let t=!1;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=!1,this._$EM(),s}t&&this._$AE(s)}willUpdate(t){}_$AE(t){this._$EO?.forEach(t=>t.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Eq&&=this._$Eq.forEach(t=>this._$ET(t,this[t])),this._$EM()}updated(t){}firstUpdated(t){}}y.elementStyles=[],y.shadowRootOptions={mode:\"open\"},y[d(\"elementProperties\")]=new Map,y[d(\"finalized\")]=new Map,p?.({ReactiveElement:y}),(a.reactiveElementVersions??=[]).push(\"2.1.2\");export{y as ReactiveElement,s as adoptStyles,u as defaultConverter,t as getCompatibleStyle,f as notEqual};\n//# sourceMappingURL=reactive-element.js.map\n","/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\nconst t=globalThis,i=t=>t,s=t.trustedTypes,e=s?s.createPolicy(\"lit-html\",{createHTML:t=>t}):void 0,h=\"$lit$\",o=`lit$${Math.random().toFixed(9).slice(2)}$`,n=\"?\"+o,r=`<${n}>`,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),w=x(2),T=x(3),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?e.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:d>=0?(e.push(a),s.slice(0,d)+h+s.slice(d)+o+x):s+o+(-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),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)&&(d.push({type:6,index:l}),r.removeAttribute(t));if(y.test(r.tagName)){const t=r.textContent.split(o),i=t.length-1;if(i>0){r.textContent=s?s.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)d.push({type:2,index:l});else{let t=-1;for(;-1!==(t=r.data.indexOf(o,t+1));)d.push({type:7,index:l}),t+=o.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?.(!1),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,!0);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??!0}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?.(!1,!0,s);t!==this._$AB;){const s=i(t).nextSibling;i(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=!1;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 j={M:h,P:o,A:n,C:1,L:N,R,D:d,V:M,I:k,H,N:L,U:z,B:I,F:Z},B=t.litHtmlPolyfillSupport;B?.(S,k),(t.litHtmlVersions??=[]).push(\"3.3.3\");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};export{j as _$LH,b as html,T as mathml,E as noChange,A as nothing,D as render,w as svg};\n//# sourceMappingURL=lit-html.js.map\n","import{ReactiveElement as t}from\"@lit/reactive-element\";export*from\"@lit/reactive-element\";import{render as e,noChange as r}from\"lit-html\";export*from\"lit-html\";\n/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */const s=globalThis;class i extends t{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){const t=super.createRenderRoot();return this.renderOptions.renderBefore??=t.firstChild,t}update(t){const r=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=e(r,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return r}}i._$litElement$=!0,i[\"finalized\"]=!0,s.litElementHydrateSupport?.({LitElement:i});const o=s.litElementPolyfillSupport;o?.({LitElement:i});const n={_$AK:(t,e,r)=>{t._$AK(e,r)},_$AL:t=>t._$AL};(s.litElementVersions??=[]).push(\"4.2.2\");export{i as LitElement,n as _$LE};\n//# sourceMappingURL=lit-element.js.map\n","/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\nconst t={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},e=t=>(...e)=>({_$litDirective$:t,values:e});class i{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,e,i){this._$Ct=t,this._$AM=e,this._$Ci=i}_$AS(t,e){return this.update(t,e)}update(t,e){return this.render(...e)}}export{i as Directive,t as PartType,e as directive};\n//# sourceMappingURL=directive.js.map\n","import{nothing as t,noChange as i}from\"../lit-html.js\";import{directive as r,Directive as s,PartType as n}from\"../directive.js\";\n/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */class e extends s{constructor(i){if(super(i),this.it=t,i.type!==n.CHILD)throw Error(this.constructor.directiveName+\"() can only be used in child bindings\")}render(r){if(r===t||null==r)return this._t=void 0,this.it=r;if(r===i)return r;if(\"string\"!=typeof r)throw Error(this.constructor.directiveName+\"() called with a non-string value\");if(r===this.it)return this._t;this.it=r;const s=[r];return s.raw=s,this._t={_$litType$:this.constructor.resultType,strings:s,values:[]}}}e.directiveName=\"unsafeHTML\",e.resultType=1;const o=r(e);export{e as UnsafeHTMLDirective,o as unsafeHTML};\n//# sourceMappingURL=unsafe-html.js.map\n","// @ts-check\n\n/** Every event this library dispatches. Never write the string literals elsewhere. */\nexport const Events = Object.freeze({\n SUBMIT: 'chat-submit',\n BEFORE_OPEN: 'chat-before-open',\n OPEN: 'chat-open',\n BEFORE_CLOSE: 'chat-before-close',\n CLOSE: 'chat-close',\n HIDE: 'chat-hide',\n SHOW: 'chat-show',\n STATE_CHANGE: 'chat-state-change',\n INPUT: 'chat-input',\n MESSAGE_RENDER: 'chat-message-render',\n MESSAGE_CLICK: 'chat-message-click',\n SCROLL_TOP: 'chat-scroll-top',\n BREAKPOINT_CHANGE: 'chat-breakpoint-change',\n HOME: 'chat-home',\n ATTACH: 'chat-attach',\n MOVE: 'chat-move',\n});\n\n/**\n * Dispatch a composed, bubbling CustomEvent from the host.\n *\n * @param {HTMLElement} host\n * @param {string} name\n * @param {unknown} detail\n * @param {{ cancelable?: boolean }} [options]\n * @returns {boolean} false when a listener called preventDefault().\n */\nexport function emit(host, name, detail, { cancelable = false } = {}) {\n return host.dispatchEvent(\n new CustomEvent(name, { detail, bubbles: true, composed: true, cancelable }),\n );\n}\n","// @ts-check\nimport { Events, emit } from '../events.js';\n\n/** @import { ReactiveController, LitElement } from 'lit' */\n/** @import { ChatState, Trigger, Effect } from '../types.js' */\n\n/**\n * @typedef {{ effect: Effect, duration: number }} AnimationSpec\n * @typedef {(from: ChatState, to: ChatState, phase: 'enter' | 'exit') => AnimationSpec} AnimationResolver\n *\n * @typedef {Object} StateControllerOptions\n * @property {AnimationResolver} animation Which effect and duration to play.\n * @property {() => boolean} keepsLauncher True when the launcher stays visible behind an open panel.\n * @property {() => void} onOpened Called once the panel is open and settled.\n */\n\n/** Which `part` carries the visible element of each state. */\nconst PART_FOR_STATE = /** @type {const} */ ({\n closed: 'launcher',\n open: 'panel',\n hidden: null,\n});\n\n/**\n * Owns everything about moving between closed / open / hidden.\n *\n * The host's `state` property changes the instant it is assigned; what the DOM\n * shows lags behind it for as long as the transition animation runs. That\n * lagging value is `renderedState`, and the render functions key off it — so a\n * panel animating out is still in the DOM while `state` already reads 'closed'.\n *\n * @implements {ReactiveController}\n */\nexport class StateController {\n /** @type {LitElement & { state: ChatState }} */\n #host;\n /** @type {AnimationResolver} */\n #resolveAnimation;\n /** @type {() => boolean} */\n #keepsLauncher;\n /** @type {() => void} */\n #onOpened;\n\n /** Logical state: the target of the most recent transition. */\n #current = /** @type {ChatState} */ ('closed');\n /** What the DOM is showing right now. */\n #rendered = /** @type {ChatState} */ ('closed');\n\n /** Guards the host's own `state` setter against re-entering us. */\n #applying = false;\n /** Bumped per transition so a superseded one can bail out after an await. */\n #generation = 0;\n /** @type {((settled: boolean) => void) | null} */\n #settle = null;\n /** @type {(() => void) | null} */\n #stopWaiting = null;\n /** @type {boolean} */\n #restoreFocusToLauncher = false;\n\n /**\n * @param {LitElement & { state: ChatState }} host\n * @param {StateControllerOptions} options\n */\n constructor(host, { animation, keepsLauncher, onOpened }) {\n this.#host = host;\n this.#resolveAnimation = animation;\n this.#keepsLauncher = keepsLauncher;\n this.#onOpened = onOpened;\n host.addController(this);\n }\n\n /** @returns {ChatState} What the DOM currently shows. */\n get renderedState() {\n return this.#rendered;\n }\n\n /** @returns {boolean} True while the host's own setter must not call us back. */\n get applying() {\n return this.#applying;\n }\n\n hostConnected() {\n this.#current = this.#host.state;\n this.#rendered = this.#host.state;\n this.#host.dataset.renderedState = this.#rendered;\n }\n\n hostDisconnected() {\n this.#stopWaiting?.();\n this.#stopWaiting = null;\n this.#settle?.(false);\n this.#settle = null;\n }\n\n hostUpdated() {\n this.#host.dataset.renderedState = this.#rendered;\n }\n\n /**\n * Move to `to`, running the before-event, the animations and the completion\n * events in order.\n *\n * @param {ChatState} to\n * @param {Trigger} trigger\n * @returns {Promise<boolean>} false when a listener cancelled it, or when a\n * later transition superseded this one.\n */\n request(to, trigger) {\n const from = this.#current;\n if (to === from) return Promise.resolve(true);\n\n if (!this.#announceIntent(from, to, trigger)) {\n this.#assign(from);\n return Promise.resolve(false);\n }\n\n // A transition already in flight loses: snap the DOM to where it was\n // heading, tell its caller it did not finish, and start over from there.\n this.#interrupt();\n\n this.#current = to;\n this.#assign(to);\n emit(this.#host, Events.STATE_CHANGE, { from, to, trigger });\n\n return this.#run(from, to, trigger);\n }\n\n /**\n * Fire the cancelable before-event for this transition, if it has one.\n *\n * @param {ChatState} from\n * @param {ChatState} to\n * @param {Trigger} trigger\n * @returns {boolean} false when a listener called preventDefault().\n */\n #announceIntent(from, to, trigger) {\n if (to === 'open') {\n return emit(this.#host, Events.BEFORE_OPEN, { from, trigger }, { cancelable: true });\n }\n if (to === 'closed' && from === 'open') {\n return emit(this.#host, Events.BEFORE_CLOSE, { from, trigger }, { cancelable: true });\n }\n return true;\n }\n\n #interrupt() {\n this.#generation += 1;\n this.#stopWaiting?.();\n this.#stopWaiting = null;\n this.#settle?.(false);\n this.#settle = null;\n if (this.#rendered !== this.#current) {\n this.#rendered = this.#current;\n this.#host.requestUpdate();\n }\n }\n\n /**\n * @param {ChatState} from\n * @param {ChatState} to\n * @param {Trigger} trigger\n * @returns {Promise<boolean>}\n */\n #run(from, to, trigger) {\n const generation = this.#generation;\n /** @type {Promise<boolean>} */\n const settled = new Promise((resolve) => {\n this.#settle = resolve;\n });\n\n void (async () => {\n this.#restoreFocusToLauncher = this.#focusIsInsidePanel();\n await this.#host.updateComplete;\n if (generation !== this.#generation) return;\n\n const leaving = this.#elementFor(from);\n if (leaving && !this.#launcherSurvives(from, to)) {\n await this.#animate(leaving, 'exit', this.#resolveAnimation(from, to, 'exit'));\n if (generation !== this.#generation) return;\n }\n\n this.#rendered = to;\n this.#host.requestUpdate();\n await this.#host.updateComplete;\n if (generation !== this.#generation) return;\n\n const arriving = this.#elementFor(to);\n if (arriving) {\n await this.#animate(arriving, 'enter', this.#resolveAnimation(from, to, 'enter'));\n if (generation !== this.#generation) return;\n }\n\n this.#announceArrival(from, to, trigger);\n this.#manageFocus(to);\n\n this.#settle?.(true);\n this.#settle = null;\n })();\n\n return settled;\n }\n\n /**\n * Whether the element of `from` survives the transition and so must not play\n * an exit animation. Only the launcher can, and only when the theme asks to\n * keep it visible behind an open panel.\n *\n * @param {ChatState} from\n * @param {ChatState} to\n * @returns {boolean}\n */\n #launcherSurvives(from, to) {\n return from === 'closed' && to === 'open' && this.#keepsLauncher();\n }\n\n /**\n * @param {ChatState} from\n * @param {ChatState} to\n * @param {Trigger} trigger\n */\n #announceArrival(from, to, trigger) {\n if (from === 'hidden') emit(this.#host, Events.SHOW, { from, to });\n if (to === 'hidden') {\n emit(this.#host, Events.HIDE, { from, to });\n return;\n }\n if (to === 'open') emit(this.#host, Events.OPEN, { from, trigger });\n else if (to === 'closed' && from === 'open') emit(this.#host, Events.CLOSE, { from, trigger });\n }\n\n /** @param {ChatState} to */\n #manageFocus(to) {\n if (to === 'open') {\n this.#onOpened();\n return;\n }\n if (to === 'closed' && this.#restoreFocusToLauncher) {\n this.#elementFor('closed')?.focus();\n }\n this.#restoreFocusToLauncher = false;\n }\n\n #focusIsInsidePanel() {\n const active = this.#host.renderRoot instanceof ShadowRoot\n ? this.#host.renderRoot.activeElement\n : null;\n const panel = this.#elementFor('open');\n return !!(active && panel && (active === panel || panel.contains(active)));\n }\n\n /**\n * @param {ChatState} state\n * @returns {HTMLElement | null}\n */\n #elementFor(state) {\n const part = PART_FOR_STATE[state];\n if (!part) return null;\n return /** @type {HTMLElement | null} */ (\n this.#host.renderRoot.querySelector(`[part~=\"${part}\"]`)\n );\n }\n\n /**\n * Assign the host's `state` without the setter calling us back.\n *\n * @param {ChatState} state\n */\n #assign(state) {\n if (this.#host.state === state) return;\n this.#applying = true;\n this.#host.state = state;\n this.#applying = false;\n }\n\n /**\n * Play one CSS animation and resolve when it ends. Resolves immediately when\n * there is nothing to play; falls back to a timer in case `animationend`\n * never arrives (a backgrounded tab, a display:none ancestor).\n *\n * @param {HTMLElement} element\n * @param {'enter' | 'exit'} phase\n * @param {AnimationSpec} spec\n * @returns {Promise<void>}\n */\n #animate(element, phase, spec) {\n const { effect, duration } = spec;\n const skip =\n effect === 'none' ||\n duration <= 0 ||\n window.matchMedia('(prefers-reduced-motion: reduce)').matches;\n if (skip) return Promise.resolve();\n\n return new Promise((resolve) => {\n let finished = false;\n /** @param {Event} [event] */\n const finish = (event) => {\n if (event && event.target !== element) return;\n if (finished) return;\n finished = true;\n clearTimeout(timer);\n element.removeEventListener('animationend', finish);\n element.removeAttribute('data-anim');\n element.style.removeProperty('--_chit-anim-duration');\n if (this.#stopWaiting === finish) this.#stopWaiting = null;\n resolve();\n };\n\n element.dataset.effect = effect;\n element.dataset.anim = phase;\n element.style.setProperty('--_chit-anim-duration', `${duration}ms`);\n element.addEventListener('animationend', finish);\n const timer = setTimeout(finish, duration + 50);\n this.#stopWaiting = finish;\n });\n }\n}\n","// @ts-check\nimport { Events, emit } from '../events.js';\n\n/** @import { ReactiveController, LitElement } from 'lit' */\n/** @import { Device } from '../types.js' */\n\n/**\n * Tracks whether the viewport is narrow enough to count as a phone.\n *\n * Uses matchMedia rather than a resize listener: it only fires when the\n * boundary is actually crossed, so nothing runs while the user drags a window\n * around inside one bucket.\n *\n * @implements {ReactiveController}\n */\nexport class BreakpointController {\n /** @type {LitElement} */\n #host;\n /** @type {MediaQueryList | null} */\n #query = null;\n /** @type {number} */\n #breakpoint = 0;\n /** @type {Device} */\n #device = 'pc';\n /** Set once the first measurement is in, so start-up is not a \"change\". */\n #measured = false;\n\n /** @param {LitElement} host */\n constructor(host) {\n this.#host = host;\n host.addController(this);\n }\n\n /** @returns {Device} */\n get device() {\n return this.#device;\n }\n\n hostDisconnected() {\n this.#query?.removeEventListener('change', this.#onChange);\n this.#query = null;\n }\n\n /**\n * Point the controller at a breakpoint. Safe to call on every update; the\n * media query is only rebuilt when the value actually changes.\n *\n * @param {number} breakpoint\n */\n observe(breakpoint) {\n if (breakpoint === this.#breakpoint && this.#query) return;\n this.#breakpoint = breakpoint;\n this.#query?.removeEventListener('change', this.#onChange);\n this.#query = window.matchMedia(`(max-width: ${breakpoint - 1}px)`);\n this.#query.addEventListener('change', this.#onChange);\n this.#apply(this.#query.matches ? 'mobile' : 'pc');\n }\n\n /** @param {MediaQueryListEvent} event */\n #onChange = (event) => {\n this.#apply(event.matches ? 'mobile' : 'pc');\n };\n\n /**\n * Record the device and announce it, unless this is the first measurement —\n * start-up is not a change. A later flip is announced whether it came from\n * the viewport resizing or from the theme moving the breakpoint, because\n * either way the answer a consumer asked for is now different.\n *\n * @param {Device} device\n */\n #apply(device) {\n if (device === this.#device && this.#host.dataset.device) return;\n\n this.#device = device;\n this.#host.dataset.device = device;\n this.#host.requestUpdate();\n\n if (this.#measured) emit(this.#host, Events.BREAKPOINT_CHANGE, { device });\n this.#measured = true;\n }\n}\n","// @ts-check\n\n/** @import { ResolvedClosed } from '../types.js' */\n\n/**\n * Neutral light palette. Every text/background pair here clears WCAG AA\n * (4.5:1); `test/theme.test.js` re-checks the ratios so a future tweak cannot\n * quietly drop below it.\n */\nconst PALETTE = {\n accent: '#2563eb',\n ink: '#1f2328',\n muted: '#5c6370',\n surface: '#ffffff',\n raised: '#f1f3f5',\n line: '#e4e4e7',\n onAccent: '#ffffff',\n};\n\n/** @type {ResolvedClosed} */\nconst CLOSED_PC = {\n size: 60,\n position: 'bottom-right',\n offset: { x: 24, y: 24 },\n radius: 30,\n draggable: false,\n image: null,\n label: null,\n component: null,\n props: {},\n colors: {\n background: PALETTE.accent,\n text: PALETTE.onAccent,\n shadow: '0 4px 12px rgba(0, 0, 0, 0.2)',\n },\n animation: { enter: 'scale', exit: 'scale', duration: 200, idle: 'none' },\n};\n\n/**\n * What a phone gets when the theme does not say. Only the measurements differ:\n * a thumb needs a slightly smaller target closer to the screen edge.\n *\n * @type {Partial<ResolvedClosed>}\n */\nconst CLOSED_MOBILE_DIFF = {\n size: 56,\n offset: { x: 16, y: 16 },\n radius: 28,\n};\n\n/**\n * The library's own theme. A user theme is merged over this, so everything\n * here is what you get when the user says nothing at all.\n *\n * `closed` carries both device buckets; `mergeTheme` narrows it to one.\n */\nexport const defaultTheme = {\n breakpoint: 768,\n zIndex: 2147483000,\n font: {\n family:\n \"system-ui, -apple-system, 'Segoe UI', 'Hiragino Sans', 'Noto Sans JP', sans-serif\",\n size: 14,\n },\n closed: {\n pc: CLOSED_PC,\n mobile: /** @type {ResolvedClosed} */ ({ ...CLOSED_PC, ...CLOSED_MOBILE_DIFF }),\n },\n open: {\n width: 380,\n height: 600,\n position: /** @type {const} */ ('bottom-right'),\n offset: { x: 24, y: 24 },\n radius: 16,\n launcher: /** @type {const} */ ('hidden'),\n // Off by default: a widget that slides around under the thumb on a first\n // touch would be startling, and most pages want it where they put it.\n draggable: false,\n header: { visible: true, title: null, logo: null, home: false },\n background: { image: null },\n colors: {\n background: PALETTE.surface,\n text: PALETTE.ink,\n accent: PALETTE.accent,\n border: PALETTE.line,\n shadow: '0 8px 32px rgba(0, 0, 0, 0.24)',\n headerBackground: PALETTE.surface,\n headerText: PALETTE.ink,\n userBubble: PALETTE.accent,\n userText: PALETTE.onAccent,\n assistantBubble: PALETTE.raised,\n assistantText: PALETTE.ink,\n systemText: PALETTE.muted,\n inputBackground: PALETTE.surface,\n inputText: PALETTE.ink,\n inputPlaceholder: PALETTE.muted,\n },\n // No tail by default: the squared-off corner on the speaker's side is\n // enough to show who is talking, and a tail is a strong look to impose on\n // a widget that has to sit in someone else's page.\n bubble: { radius: 14, tail: /** @type {const} */ ('none') },\n // The wait for an answer. `auto` is opt-in: a widget that starts showing\n // a wait on its own would be guessing that every submit is followed by a\n // round trip, which is not true of a form or a scenario branch.\n loading: {\n auto: false,\n // A spinner rather than the typing dots: the same three dots would say\n // \"someone is writing to you\", which is not what a wait on a server is.\n // `'dots'` is there for the cases where it really is a person.\n style: /** @type {const} */ ('spinner'),\n text: null,\n timeout: 0,\n },\n // Who is talking. Nothing by default: a widget that invents a name and a\n // face for the consumer's support desk would be guessing.\n speaker: {\n assistant: { name: null, avatar: null },\n user: { name: null, avatar: null },\n },\n animation: {\n enter: /** @type {const} */ ('scale'),\n exit: /** @type {const} */ ('fade'),\n duration: 150,\n // How the conversation follows a new message. Growth within a message\n // (a streamed reply, an image loading) is always instant; see\n // ScrollController for why.\n scroll: /** @type {const} */ ('smooth'),\n },\n // `attach` is off by default: a widget that offers to take files when\n // nothing is listening for them would be promising something it cannot\n // keep. `accept` and `multiple` go straight to the file input.\n input: {\n maxRows: 5,\n placeholder: null,\n attach: false,\n accept: 'image/*,video/*',\n multiple: false,\n },\n },\n hidden: {\n animation: { exit: /** @type {const} */ ('fade'), duration: 150 },\n },\n};\n\n/** The measurements a phone falls back to when only `closed.pc` was given. */\nexport const mobileClosedDefaults = CLOSED_MOBILE_DIFF;\n","// @ts-check\nimport { defaultTheme, mobileClosedDefaults } from './default-theme.js';\n\n/** @import { Theme, ClosedTheme, Device, ResolvedTheme } from '../types.js' */\n\n/**\n * @param {unknown} value\n * @returns {value is Record<string, unknown>}\n */\nfunction isPlainObject(value) {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\n/**\n * Merge `override` onto `base`, recursing into plain objects.\n *\n * `undefined` means \"say nothing\" and leaves the base value alone; `null` means\n * \"clear it\", so `{ image: null }` removes a default icon rather than being\n * ignored. There are no arrays anywhere in a theme, so a plain recursive merge\n * is enough.\n *\n * @template {Record<string, any>} T\n * @param {T} base\n * @param {Record<string, any> | undefined} override\n * @returns {T}\n */\nexport function mergeTheme(base, override) {\n if (!isPlainObject(override)) return base;\n\n /** @type {Record<string, any>} */\n const out = { ...base };\n for (const [key, value] of Object.entries(override)) {\n if (value === undefined) continue;\n const current = out[key];\n out[key] = isPlainObject(value) && isPlainObject(current) ? mergeTheme(current, value) : value;\n }\n return /** @type {T} */ (out);\n}\n\n/**\n * Decide which `closed` settings this device gets.\n *\n * Three shapes are allowed, and this is where they collapse into one:\n * no pc/mobile keys at all (the same settings serve both), both given, or only\n * one given. When only `pc` is given the phone inherits it but keeps the\n * default phone measurements, so a custom icon carries over without a\n * desktop-sized button landing on a phone.\n *\n * @param {ClosedTheme | { pc?: ClosedTheme, mobile?: ClosedTheme } | undefined} closed\n * @param {Device} device\n * @returns {ClosedTheme}\n */\nfunction resolveClosed(closed, device) {\n const perDevice = /** @type {{ pc?: ClosedTheme, mobile?: ClosedTheme }} */ (closed ?? {});\n const split = 'pc' in perDevice || 'mobile' in perDevice;\n\n if (!split) {\n const shared = /** @type {ClosedTheme} */ (closed ?? {});\n return mergeTheme(defaultTheme.closed[device], shared);\n }\n\n const pc = mergeTheme(defaultTheme.closed.pc, perDevice.pc);\n if (device === 'pc') return pc;\n\n if (perDevice.mobile) return mergeTheme(defaultTheme.closed.mobile, perDevice.mobile);\n return mergeTheme(pc, mobileClosedDefaults);\n}\n\n/**\n * Fill every gap in a user theme and narrow it to one device.\n *\n * @param {Theme | undefined} theme\n * @param {Device} device\n * @returns {ResolvedTheme}\n */\nexport function resolveTheme(theme, device) {\n const user = theme ?? {};\n const closed = resolveClosed(user.closed, device);\n\n return /** @type {ResolvedTheme} */ ({\n breakpoint: user.breakpoint ?? defaultTheme.breakpoint,\n zIndex: user.zIndex ?? defaultTheme.zIndex,\n font: mergeTheme(defaultTheme.font, user.font),\n closed: mergeTheme(defaultTheme.closed[device], closed),\n open: mergeTheme(defaultTheme.open, user.open),\n hidden: mergeTheme(defaultTheme.hidden, user.hidden),\n device,\n });\n}\n\n/**\n * The breakpoint a theme asks for, readable before the full resolve (the\n * device is not known until the breakpoint is).\n *\n * @param {Theme | undefined} theme\n * @returns {number}\n */\nexport function breakpointOf(theme) {\n return theme?.breakpoint ?? defaultTheme.breakpoint;\n}\n","// @ts-check\n\n/** @import { ResolvedTheme } from '../types.js' */\n\n/**\n * @param {number} value\n * @returns {string}\n */\nconst px = (value) => `${value}px`;\n\n/**\n * A CSS `url()` for an image, or `none`. Quotes and backslashes are escaped so\n * a filename with an apostrophe cannot break out of the declaration.\n *\n * @param {string | null | undefined} value\n * @returns {string}\n */\nfunction url(value) {\n if (!value) return 'none';\n return `url(\"${value.replace(/[\\\\\"]/g, '\\\\$&')}\")`;\n}\n\n/**\n * Turn a resolved theme into the custom properties the stylesheets read.\n *\n * Only values CSS can act on are here. Positions, animation effects, text and\n * images that belong in markup are applied as attributes or drawn by the\n * render functions instead.\n *\n * Animation durations are deliberately absent: the transition code has to know\n * when an animation ends, so the theme is the single source of truth for them\n * and it writes the duration onto the element as it starts. A custom property\n * here would look like a knob that does nothing.\n *\n * @param {ResolvedTheme} theme\n * @returns {Record<string, string>}\n */\nexport function themeToVariables(theme) {\n const { closed, open } = theme;\n const c = open.colors;\n\n return {\n '--chit-z-index': String(theme.zIndex),\n '--chit-font-family': theme.font.family,\n '--chit-font-size': px(theme.font.size),\n\n '--chit-launcher-size': closed.size === 'auto' ? 'auto' : px(closed.size),\n '--chit-launcher-offset-x': px(closed.offset.x),\n '--chit-launcher-offset-y': px(closed.offset.y),\n '--chit-launcher-radius': px(closed.radius),\n '--chit-launcher-image': url(closed.image),\n '--chit-launcher-bg': closed.colors.background,\n '--chit-launcher-text': closed.colors.text,\n '--chit-launcher-shadow': closed.colors.shadow,\n\n '--chit-panel-width': px(open.width),\n '--chit-panel-height': px(open.height),\n '--chit-panel-offset-x': px(open.offset.x),\n '--chit-panel-offset-y': px(open.offset.y),\n '--chit-panel-radius': px(open.radius),\n '--chit-panel-bg-image': url(open.background.image),\n '--chit-panel-shadow': c.shadow,\n\n '--chit-color-bg': c.background,\n '--chit-color-text': c.text,\n '--chit-color-accent': c.accent,\n '--chit-color-border': c.border,\n '--chit-color-header-bg': c.headerBackground,\n '--chit-color-header-text': c.headerText,\n '--chit-color-user-bg': c.userBubble,\n '--chit-color-user-text': c.userText,\n '--chit-color-assistant-bg': c.assistantBubble,\n '--chit-color-assistant-text': c.assistantText,\n '--chit-color-system-text': c.systemText,\n '--chit-color-input-bg': c.inputBackground,\n '--chit-color-input-text': c.inputText,\n '--chit-color-input-placeholder': c.inputPlaceholder,\n\n '--chit-bubble-radius': px(open.bubble.radius),\n\n '--_chit-input-max-rows': String(open.input.maxRows),\n // Internal: the width the speaker's icon takes up, so the typing\n // indicator lines up with the bubbles it belongs to.\n '--_chit-speaker-gutter': open.speaker.assistant.avatar ? '2.5em' : '0px',\n };\n}\n\n/**\n * The stylesheet text for a resolved theme.\n *\n * @param {ResolvedTheme} theme\n * @returns {string}\n */\nexport function themeToCss(theme) {\n const declarations = Object.entries(themeToVariables(theme))\n .map(([name, value]) => ` ${name}: ${value};`)\n .join('\\n');\n return `:host {\\n${declarations}\\n}\\n`;\n}\n","// @ts-check\n\n/**\n * Constructable stylesheets landed in Safari 16.4 and we support 16, so the\n * same fallback Lit uses applies here: a <style> element in the shadow root.\n */\nconst SUPPORTS_ADOPTING =\n typeof ShadowRoot !== 'undefined' &&\n 'adoptedStyleSheets' in Document.prototype &&\n 'replaceSync' in CSSStyleSheet.prototype;\n\n/**\n * A stylesheet the component owns and rewrites at runtime, appended after the\n * component's static styles so its declarations win over them.\n */\nexport class AdoptedSheet {\n /** @type {CSSStyleSheet | null} */\n #sheet = null;\n /** @type {HTMLStyleElement | null} */\n #element = null;\n /** @type {string} */\n #written = '';\n /** @type {string} */\n #marker;\n\n /** @param {string} marker Identifies the sheet in the DOM when the fallback is used. */\n constructor(marker) {\n this.#marker = marker;\n }\n\n /** @param {ShadowRoot | HTMLElement | DocumentFragment} root */\n attach(root) {\n if (!(root instanceof ShadowRoot)) return;\n\n if (SUPPORTS_ADOPTING) {\n if (!this.#sheet) this.#sheet = new CSSStyleSheet();\n if (!root.adoptedStyleSheets.includes(this.#sheet)) {\n root.adoptedStyleSheets = [...root.adoptedStyleSheets, this.#sheet];\n }\n return;\n }\n\n if (!this.#element) {\n this.#element = document.createElement('style');\n this.#element.setAttribute(this.#marker, '');\n }\n if (this.#element.parentNode !== root) root.append(this.#element);\n }\n\n /**\n * Replace the sheet's contents. Cheap to call on every update: identical CSS\n * is ignored.\n *\n * @param {string} css\n * @param {ShadowRoot | HTMLElement | DocumentFragment} root\n */\n write(css, root) {\n if (css === this.#written) return;\n this.attach(root);\n\n if (this.#sheet) this.#sheet.replaceSync(css);\n else if (this.#element) this.#element.textContent = css;\n else return;\n\n this.#written = css;\n }\n\n detach() {\n this.#element?.remove();\n this.#element = null;\n }\n}\n","// @ts-check\nimport { resolveTheme, breakpointOf } from '../theme/merge-theme.js';\nimport { themeToCss } from '../theme/theme-to-css.js';\nimport { AdoptedSheet } from '../styles/adopted-sheet.js';\n\n/** @import { ReactiveController, LitElement } from 'lit' */\n/** @import { Theme, ResolvedTheme, Device } from '../types.js' */\n\n/**\n * Turns the `theme` property into the custom properties everything else reads.\n *\n * The generated sheet is adopted *after* the component's own stylesheets, so a\n * theme value beats the fallback declared alongside the rules that use it.\n * Page CSS still wins over both: a `chit-ui { --chit-color-accent: ... }` rule\n * lives in the outer tree, and the outer tree takes precedence over `:host`.\n *\n * @implements {ReactiveController}\n */\nexport class ThemeController {\n /** @type {LitElement} */\n #host;\n /** @type {AdoptedSheet} */\n #sheet = new AdoptedSheet('data-chit-theme');\n /** @type {ResolvedTheme} */\n #resolved;\n\n /**\n * @param {LitElement} host\n * @param {{ device: () => Device }} options\n */\n constructor(host, { device }) {\n this.#host = host;\n this.#resolved = resolveTheme(undefined, device());\n }\n\n /** @returns {ResolvedTheme} The theme in force, defaults filled in. */\n get current() {\n return this.#resolved;\n }\n\n hostConnected() {\n this.#write();\n }\n\n hostDisconnected() {\n this.#sheet.detach();\n }\n\n /**\n * The breakpoint a theme asks for. Needed before `apply`, because the device\n * cannot be decided until the breakpoint is known.\n *\n * @param {Theme | undefined} theme\n * @returns {number}\n */\n static breakpointOf(theme) {\n return breakpointOf(theme);\n }\n\n /**\n * Re-resolve for the current theme and device. Cheap to call on every update:\n * the stylesheet is only rewritten when the generated text actually changes.\n *\n * @param {Theme | undefined} theme\n * @param {Device} device\n */\n apply(theme, device) {\n this.#resolved = resolveTheme(theme, device);\n this.#write();\n }\n\n #write() {\n this.#sheet.write(themeToCss(this.#resolved), this.#host.renderRoot);\n }\n}\n","// @ts-check\nimport { Events, emit } from '../events.js';\n\n/** @import { ReactiveController, LitElement } from 'lit' */\n/** @import { Message } from '../types.js' */\n\n/** How close to the end still counts as \"at the bottom\", in pixels. */\nconst BOTTOM_SLACK = 24;\n\n/**\n * How long to keep treating the viewport as \"ours\" after starting a smooth\n * scroll, when the browser has no scrollend event to tell us it finished.\n */\nconst SMOOTH_GRACE_MS = 700;\n\n/**\n * Keeps the conversation pinned to the newest message while the reader is at\n * the bottom, and gets out of the way the moment they scroll up.\n *\n * Two things follow from that rule. A reply arriving while the reader is up in\n * the history must not yank them down — it raises the \"jump to latest\" button\n * instead. And their own message always scrolls into view, because they just\n * pressed send and expect to see it.\n *\n * @implements {ReactiveController}\n */\nexport class ScrollController {\n /** @type {LitElement & { messages: Message[] }} */\n #host;\n /** @type {() => 'smooth' | 'instant'} */\n #preferredBehavior;\n /** @type {HTMLElement | null} */\n #viewport = null;\n /** @type {ResizeObserver | null} */\n #resize = null;\n\n #atBottom = true;\n #hasUnseen = false;\n #atTop = false;\n #followAfterRender = true;\n\n /**\n * True while a scroll we started is still animating. Scroll events during\n * that window report positions we caused, not where the reader went.\n */\n #selfScrolling = false;\n /** @type {ReturnType<typeof setTimeout> | undefined} */\n #selfScrollTimer;\n /** The first jump after the panel opens has nothing to animate from. */\n #openingJump = true;\n\n /**\n * The viewport's height as of the last reading. A scroll event that arrives\n * with a different height is the box having been resized under the reader —\n * a keyboard opening, say — and says nothing about where they chose to be.\n */\n #viewportHeight = 0;\n\n /** @type {string | undefined} */\n #lastId;\n #lastCount = 0;\n\n /**\n * @param {LitElement & { messages: Message[] }} host\n * @param {{ behavior: () => 'smooth' | 'instant' }} options\n */\n constructor(host, { behavior }) {\n this.#host = host;\n this.#preferredBehavior = behavior;\n host.addController(this);\n }\n\n /** @returns {boolean} True when newer content arrived while scrolled up. */\n get hasUnseen() {\n return this.#hasUnseen;\n }\n\n /** @returns {boolean} */\n get atBottom() {\n return this.#atBottom;\n }\n\n hostDisconnected() {\n this.#unbind();\n clearTimeout(this.#selfScrollTimer);\n }\n\n /**\n * Runs before the render, so a decision made here lands in the same frame.\n * Whether the conversation grew is knowable from the array alone; only the\n * scrolling itself has to wait for the DOM.\n */\n hostUpdate() {\n const messages = this.#host.messages;\n const last = messages[messages.length - 1];\n const grew = messages.length > this.#lastCount;\n const newTail = last?.id !== this.#lastId;\n\n this.#lastId = last?.id;\n this.#lastCount = messages.length;\n\n if (!grew && !newTail) return;\n\n // Their own message always scrolls into view: they just pressed send.\n if (this.#atBottom || last?.role === 'user') this.#followAfterRender = true;\n else this.#hasUnseen = true;\n }\n\n hostUpdated() {\n const viewport = /** @type {HTMLElement | null} */ (\n this.#host.renderRoot.querySelector('[part~=\"messages\"]')\n );\n\n if (viewport !== this.#viewport) {\n this.#unbind();\n this.#viewport = viewport;\n this.#bind();\n // A freshly opened panel starts at the newest message, with no animation\n // to watch: there was nothing on screen to move away from.\n if (viewport) {\n this.#atBottom = true;\n this.#hasUnseen = false;\n this.#followAfterRender = true;\n this.#openingJump = true;\n }\n }\n\n if (this.#followAfterRender) {\n const behavior = this.#followBehavior;\n this.#followAfterRender = false;\n this.#scrollNow({ behavior });\n }\n }\n\n #bind() {\n if (!this.#viewport) return;\n this.#viewportHeight = this.#viewport.clientHeight;\n this.#viewport.addEventListener('scroll', this.#onScroll, { passive: true });\n // Precise end-of-scroll where it exists (Chrome 114, Firefox 109,\n // Safari 17.4); the timer below covers the rest.\n this.#viewport.addEventListener('scrollend', this.#onScrollEnd);\n\n // Images finishing and streamed text growing both change the height\n // without a scroll event, so the follow has to react to size too. The\n // viewport is watched alongside the content because a keyboard opening\n // shortens the list without touching what is in it, and the newest\n // message would otherwise slide out of sight.\n const inner = this.#viewport.firstElementChild;\n if (inner && typeof ResizeObserver !== 'undefined') {\n this.#resize = new ResizeObserver(() => {\n this.#viewportHeight = this.#viewport?.clientHeight ?? 0;\n if (!this.#atBottom) return;\n // Content settling (an image loading, a tall block laying out) right\n // after a message arrived must not cut the follow short, so while our\n // own animation is running it is re-aimed rather than replaced. With\n // nothing in flight this is a streamed reply growing, and that is\n // followed instantly: an animation restarted every few tens of\n // milliseconds never lands.\n this.#scrollNow({ behavior: this.#selfScrolling ? 'smooth' : 'instant' });\n });\n this.#resize.observe(inner);\n this.#resize.observe(this.#viewport);\n }\n }\n\n #unbind() {\n this.#viewport?.removeEventListener('scroll', this.#onScroll);\n this.#viewport?.removeEventListener('scrollend', this.#onScrollEnd);\n this.#resize?.disconnect();\n this.#resize = null;\n this.#viewport = null;\n }\n\n #onScrollEnd = () => {\n this.#endSelfScroll();\n };\n\n #onScroll = () => {\n const viewport = this.#viewport;\n if (!viewport) return;\n\n // The box changed size under this scroll, so the reader did not move:\n // the resize handler below puts them back where they were.\n if (viewport.clientHeight !== this.#viewportHeight) {\n this.#viewportHeight = viewport.clientHeight;\n return;\n }\n\n const distance = viewport.scrollHeight - viewport.scrollTop - viewport.clientHeight;\n const atBottom = distance <= BOTTOM_SLACK;\n\n // Our own animation passing through the middle of the list is not the\n // reader scrolling up.\n if (this.#selfScrolling) {\n if (atBottom) this.#endSelfScroll();\n return;\n }\n\n if (atBottom !== this.#atBottom) {\n this.#atBottom = atBottom;\n if (atBottom && this.#hasUnseen) {\n this.#hasUnseen = false;\n this.#host.requestUpdate();\n }\n }\n\n // One event per visit to the top, so a consumer loading older messages is\n // not asked again while the reader sits there.\n const atTop = viewport.scrollTop <= 0;\n if (atTop && !this.#atTop) emit(this.#host, Events.SCROLL_TOP, {});\n this.#atTop = atTop;\n };\n\n /**\n * @param {{ smooth?: boolean }} [options] Defaults to the theme's setting.\n */\n scrollToBottom({ smooth } = {}) {\n const behavior =\n smooth === undefined ? this.#followBehavior : smooth ? 'smooth' : 'instant';\n this.#scrollNow({ behavior });\n\n if (this.#hasUnseen) {\n this.#hasUnseen = false;\n this.#host.requestUpdate();\n }\n }\n\n /**\n * What the next follow should look like: the theme's choice, unless the\n * reader asked for less motion, or this is the jump that happens as the\n * panel opens.\n *\n * @returns {'smooth' | 'instant'}\n */\n get #followBehavior() {\n if (this.#openingJump) return 'instant';\n if (window.matchMedia('(prefers-reduced-motion: reduce)').matches) return 'instant';\n return this.#preferredBehavior();\n }\n\n /** @param {{ behavior?: 'smooth' | 'instant' }} [options] */\n #scrollNow({ behavior = 'instant' } = {}) {\n const viewport = this.#viewport;\n if (!viewport) return;\n\n this.#openingJump = false;\n if (behavior === 'smooth') this.#beginSelfScroll();\n\n viewport.scrollTo({ top: viewport.scrollHeight, behavior });\n this.#atBottom = true;\n this.#atTop = false;\n this.#hasUnseen = false;\n }\n\n #beginSelfScroll() {\n this.#selfScrolling = true;\n clearTimeout(this.#selfScrollTimer);\n this.#selfScrollTimer = setTimeout(() => this.#endSelfScroll(), SMOOTH_GRACE_MS);\n }\n\n #endSelfScroll() {\n if (!this.#selfScrolling) return;\n this.#selfScrolling = false;\n clearTimeout(this.#selfScrollTimer);\n\n // Take a reading now that the viewport has settled.\n const viewport = this.#viewport;\n if (!viewport) return;\n const distance = viewport.scrollHeight - viewport.scrollTop - viewport.clientHeight;\n this.#atBottom = distance <= BOTTOM_SLACK;\n }\n}\n","// @ts-check\nimport { Events, emit } from '../events.js';\n\n/** @import { ReactiveController, LitElement } from 'lit' */\n\n/** Browsers that size a textarea to its content need no JS help. */\nconst SUPPORTS_FIELD_SIZING =\n typeof CSS !== 'undefined' && CSS.supports?.('field-sizing', 'content');\n\n/**\n * Owns the composer: what has been typed, whether an IME is mid-composition,\n * and when a keystroke counts as \"send\".\n *\n * The typed text is deliberately not a reactive property. A keystroke would\n * otherwise re-render the whole shadow tree, `repeat` over every message\n * included; instead the two things that depend on it — the send button's\n * enabled state and the character counter — are updated in place.\n *\n * @implements {ReactiveController}\n */\nexport class ComposerController {\n /** @type {LitElement & ComposerHost} */\n #host;\n\n #value = '';\n\n /** True between compositionstart and compositionend. */\n #composing = false;\n\n /**\n * True for one turn of the event loop after a composition ends.\n *\n * WebKit dispatches the Enter that confirmed an IME candidate as a plain\n * keydown *after* compositionend, with `isComposing` already false — so\n * without this flag, confirming a Japanese candidate would send the message.\n */\n #justComposed = false;\n\n /** @type {ReturnType<typeof setTimeout> | undefined} */\n #composedTimer;\n\n /** @param {LitElement & ComposerHost} host */\n constructor(host) {\n this.#host = host;\n host.addController(this);\n }\n\n /** @returns {string} */\n get value() {\n return this.#value;\n }\n\n set value(next) {\n this.#value = next ?? '';\n const input = this.#input;\n if (input && input.value !== this.#value) input.value = this.#value;\n this.#grow();\n this.#syncDerived();\n }\n\n /** @returns {boolean} True while an IME candidate window is open. */\n get composing() {\n return this.#composing;\n }\n\n /** @returns {number} Characters typed, counted by code point. */\n get length() {\n return Array.from(this.#value).length;\n }\n\n /** @returns {boolean} Whether the current text could be sent right now. */\n get canSend() {\n if (this.#host.busy || this.#host.inputDisabled) return false;\n if (this.#value.trim() === '') return false;\n const limit = this.#host.maxLength;\n return limit === undefined || this.length <= limit;\n }\n\n hostDisconnected() {\n clearTimeout(this.#composedTimer);\n }\n\n hostUpdated() {\n const input = this.#input;\n if (input && input.value !== this.#value) input.value = this.#value;\n this.#grow();\n this.#syncDerived();\n }\n\n /** @returns {HTMLTextAreaElement | null} */\n get #input() {\n return /** @type {HTMLTextAreaElement | null} */ (\n this.#host.renderRoot.querySelector('[part~=\"input\"]')\n );\n }\n\n /** @param {Event} event */\n onInput(event) {\n this.#value = /** @type {HTMLTextAreaElement} */ (event.target).value;\n this.#grow();\n this.#syncDerived();\n emit(this.#host, Events.INPUT, { value: this.#value });\n }\n\n onCompositionStart() {\n this.#composing = true;\n }\n\n onCompositionEnd() {\n this.#composing = false;\n this.#justComposed = true;\n clearTimeout(this.#composedTimer);\n this.#composedTimer = setTimeout(() => {\n this.#justComposed = false;\n }, 0);\n }\n\n /** @param {KeyboardEvent} event */\n onKeydown(event) {\n if (event.key !== 'Enter') return;\n if (!this.#host.sendOnEnter) return;\n // Shift+Enter is a newline; the others are the browser's or the page's.\n if (event.shiftKey || event.altKey || event.ctrlKey || event.metaKey) return;\n\n // Chrome, Edge and Firefox mark the confirming Enter on the event itself.\n // Older engines only set keyCode 229.\n if (event.isComposing || event.keyCode === 229) return;\n // Safari's post-compositionend Enter, and Android soft keyboards that send\n // Enter while a composition is still open.\n if (this.#composing || this.#justComposed) return;\n\n event.preventDefault();\n this.submit();\n }\n\n /**\n * Hand the text to the consumer and clear the box.\n *\n * The text is passed as typed: leading and trailing newlines are theirs to\n * keep or strip, since only they know whether the message is prose or code.\n *\n * @param {string} [text] Defaults to what is in the box.\n * @returns {boolean} False when there was nothing to send.\n */\n submit(text) {\n const value = text ?? this.#value;\n if (text === undefined && !this.canSend) return false;\n if (text !== undefined && (this.#host.busy || this.#host.inputDisabled)) return false;\n if (value.trim() === '') return false;\n\n const allowed = emit(this.#host, Events.SUBMIT, { text: value }, { cancelable: true });\n if (!allowed) return false;\n\n this.clear();\n this.#host.handleSubmitted();\n return true;\n }\n\n clear() {\n this.value = '';\n this.focus();\n }\n\n focus() {\n this.#input?.focus();\n }\n\n /** Grow the box with its content, up to the theme's row limit. */\n #grow() {\n if (SUPPORTS_FIELD_SIZING) return;\n const input = this.#input;\n if (!input) return;\n input.style.height = 'auto';\n input.style.height = `${input.scrollHeight}px`;\n }\n\n /**\n * Update the parts that depend on the typed text without a re-render.\n */\n #syncDerived() {\n const root = this.#host.renderRoot;\n\n const send = /** @type {HTMLButtonElement | null} */ (\n root.querySelector('[part~=\"send-button\"]')\n );\n if (send) send.disabled = !this.canSend;\n\n const input = this.#input;\n const counter = /** @type {HTMLElement | null} */ (root.querySelector('[part~=\"counter\"]'));\n const limit = this.#host.maxLength;\n if (limit === undefined) return;\n\n const remaining = limit - this.length;\n const over = remaining < 0;\n input?.setAttribute('aria-invalid', over ? 'true' : 'false');\n\n if (!counter) return;\n counter.textContent = String(remaining);\n counter.toggleAttribute('data-over', over);\n // The digits alone (\"-14\") say nothing out loud, so the counter carries a\n // sentence for assistive tech while showing just the number.\n const labels = this.#host.currentLabels;\n const template = over ? labels.overLimit : labels.charactersLeft;\n counter.setAttribute('aria-label', template.replace('{n}', String(Math.abs(remaining))));\n counter.hidden = this.length <= limit * 0.8;\n }\n}\n\n/**\n * @typedef {Object} ComposerHost\n * @property {boolean} busy\n * @property {boolean} inputDisabled\n * @property {boolean} sendOnEnter\n * @property {number | undefined} maxLength\n * @property {import('../i18n/labels.js').Labels} currentLabels\n * @property {() => void} handleSubmitted Called after a submit that no listener cancelled.\n */\n","// @ts-check\n\n/** @import { ReactiveController, LitElement } from 'lit' */\n/** @import { Position } from '../types.js' */\n\n/** How far a pointer may travel before the gesture counts as a drag, not a click. */\nconst SLOP = 4;\n\n/** How close to the viewport edge the dragged thing may come. */\nconst MARGIN = 8;\n\n/** Arrow-key step, and the bigger step Shift asks for. */\nconst STEP = 8;\nconst BIG_STEP = 32;\n\n/**\n * Moves one thing — the launcher or the panel — around the viewport.\n *\n * What a gesture produces is not a position but a displacement: how far the\n * reader has dragged the widget from wherever the theme put it, in screen\n * pixels. The host keeps one such displacement for the whole widget and hands\n * it to both controllers, which is what makes the two states travel together:\n * drag the launcher into a corner and the panel opens in that same corner,\n * because both are the theme's position plus the same shift.\n *\n * Each controller then turns the displacement into the terms its own corner\n * uses — at a right-hand corner, moving right means a smaller offset — and\n * writes it into the two custom properties the stylesheet already reads. The\n * offset lives on the host as an inline property, which outranks the theme's\n * sheet and the page's CSS: a reader who dragged the widget somewhere means\n * it, and until the drag is cleared theirs is the most specific word on where\n * it goes.\n *\n * @implements {ReactiveController}\n */\nexport class DragController {\n /** @type {LitElement} */\n #host;\n\n /** @type {DragOptions} */\n #options;\n\n /**\n * Pointer state, only while a gesture is in flight.\n *\n * @type {{\n * pointer: { x: number, y: number },\n * displacement: { x: number, y: number },\n * size: { width: number, height: number },\n * corner: Position,\n * base: { x: number, y: number },\n * moved: boolean,\n * pointerId: number,\n * target: HTMLElement,\n * } | undefined}\n */\n #from;\n\n /** True once a gesture has passed the slop, until the click that follows it. */\n #dragged = false;\n\n /**\n * @param {LitElement} host\n * @param {DragOptions} options\n */\n constructor(host, options) {\n this.#host = host;\n this.#options = options;\n host.addController(this);\n }\n\n hostConnected() {\n // A smaller window can leave the widget hanging off the edge; placing it\n // again runs it back through the clamp.\n this.#onResize = () => {\n const now = this.#options.current();\n if (now) this.#options.onMove(now);\n };\n window.addEventListener('resize', this.#onResize);\n }\n\n hostDisconnected() {\n if (this.#onResize) window.removeEventListener('resize', this.#onResize);\n this.#onResize = undefined;\n }\n\n /** @type {(() => void) | undefined} */\n #onResize;\n\n /**\n * True when the gesture that just ended was a drag. Reading it clears it, so\n * the click a pointer-up fires can be skipped exactly once.\n *\n * @returns {boolean}\n */\n consumeDrag() {\n const dragged = this.#dragged;\n this.#dragged = false;\n return dragged;\n }\n\n /**\n * Put this thing where the displacement says, within the viewport.\n *\n * @param {{ x: number, y: number } | null} displacement\n * @returns {{ x: number, y: number } | undefined} Where it ended up, when it is on screen.\n */\n place(displacement) {\n if (!displacement) {\n for (const name of [this.#options.vars.x, this.#options.vars.y]) {\n this.#host.style.removeProperty(name);\n }\n return undefined;\n }\n\n const element = this.#options.element();\n const offset = this.#toOffset(displacement);\n // Nothing on screen yet: write it anyway, so the thing is already in\n // place the moment it is rendered, and let the next pass clamp it.\n const placed = element ? this.#clamp(offset, this.#options.size()) : offset;\n\n this.#host.style.setProperty(this.#options.vars.x, `${placed.x}px`);\n this.#host.style.setProperty(this.#options.vars.y, `${placed.y}px`);\n return element ? placed : undefined;\n }\n\n /**\n * Begin a drag.\n *\n * @param {PointerEvent} event\n * @returns {void}\n */\n start(event) {\n if (!this.#options.enabled() || event.button !== 0) return;\n const element = this.#options.element();\n if (!element) return;\n\n this.#from = {\n pointer: { x: event.clientX, y: event.clientY },\n displacement: this.#options.current() ?? { x: 0, y: 0 },\n size: this.#options.size(),\n corner: this.#options.corner(),\n base: this.#options.base(),\n moved: false,\n pointerId: event.pointerId,\n target: /** @type {HTMLElement} */ (event.currentTarget),\n };\n\n // Capture keeps the moves coming even when the pointer leaves the handle.\n // It throws if the pointer has already gone; the drag still works without\n // it, so there is nothing to do about that but carry on.\n try {\n this.#from.target.setPointerCapture(event.pointerId);\n } catch {\n /* no capture available */\n }\n\n this.#from.target.addEventListener('pointermove', this.#onPointerMove);\n this.#from.target.addEventListener('pointerup', this.#onPointerEnd);\n this.#from.target.addEventListener('pointercancel', this.#onPointerEnd);\n }\n\n /** @param {PointerEvent} event */\n #onPointerMove = (event) => {\n const from = this.#from;\n if (!from || event.pointerId !== from.pointerId) return;\n\n const dx = event.clientX - from.pointer.x;\n const dy = event.clientY - from.pointer.y;\n if (!from.moved && Math.hypot(dx, dy) < SLOP) return;\n\n from.moved = true;\n // A drag must not also select text or scroll the page under the finger.\n event.preventDefault();\n this.#options.onMove(\n this.#limit(\n { x: from.displacement.x + dx, y: from.displacement.y + dy },\n from.base,\n from.corner,\n from.size,\n ),\n );\n };\n\n /** @param {PointerEvent} event */\n #onPointerEnd = (event) => {\n const from = this.#from;\n if (!from || event.pointerId !== from.pointerId) return;\n\n from.target.removeEventListener('pointermove', this.#onPointerMove);\n from.target.removeEventListener('pointerup', this.#onPointerEnd);\n from.target.removeEventListener('pointercancel', this.#onPointerEnd);\n try {\n if (from.target.hasPointerCapture(event.pointerId)) {\n from.target.releasePointerCapture(event.pointerId);\n }\n } catch {\n /* never had it */\n }\n\n this.#from = undefined;\n if (!from.moved) return;\n this.#dragged = true;\n this.#options.onSettle(this.#options.name);\n };\n\n /**\n * Move with the arrow keys, so the same thing can be done without a pointer.\n *\n * @param {KeyboardEvent} event\n * @returns {boolean} True when the key was used.\n */\n nudge(event) {\n if (!this.#options.enabled()) return false;\n if (event.altKey || event.ctrlKey || event.metaKey) return false;\n\n /** @type {Record<string, [number, number]>} */\n const directions = {\n ArrowLeft: [-1, 0],\n ArrowRight: [1, 0],\n ArrowUp: [0, -1],\n ArrowDown: [0, 1],\n };\n const direction = directions[event.key];\n if (!direction) return false;\n\n const element = this.#options.element();\n if (!element) return false;\n\n const step = event.shiftKey ? BIG_STEP : STEP;\n const now = this.#options.current() ?? { x: 0, y: 0 };\n event.preventDefault();\n this.#options.onMove(\n this.#limit(\n { x: now.x + direction[0] * step, y: now.y + direction[1] * step },\n this.#options.base(),\n this.#options.corner(),\n this.#options.size(),\n ),\n );\n this.#options.onSettle(this.#options.name);\n return true;\n }\n\n /**\n * The displacement in the terms this corner counts in.\n *\n * @param {{ x: number, y: number }} displacement\n * @param {{ x: number, y: number }} [base]\n * @param {Position} [corner]\n * @returns {{ x: number, y: number }}\n */\n #toOffset(displacement, base = this.#options.base(), corner = this.#options.corner()) {\n return {\n x: base.x + (corner.endsWith('right') ? -displacement.x : displacement.x),\n y: base.y + (corner.startsWith('bottom') ? -displacement.y : displacement.y),\n };\n }\n\n /**\n * As much of a displacement as this thing can take without leaving the\n * viewport. The dragged thing sets the shared displacement, so the limit\n * has to be expressed there rather than only in the offset it writes.\n *\n * The size is the size the thing means to be, not the one it happens to\n * have: the panel's own stylesheet caps it against the space between its\n * corner and the far edge, so measuring it while it is being pushed into\n * that corner would read back a smaller box and let it be pushed further,\n * squeezing it flat instead of stopping it.\n *\n * @param {{ x: number, y: number }} displacement\n * @param {{ x: number, y: number }} base\n * @param {Position} corner\n * @param {{ width: number, height: number }} size\n * @returns {{ x: number, y: number }}\n */\n #limit(displacement, base, corner, size) {\n const offset = this.#clamp(this.#toOffset(displacement, base, corner), size);\n return {\n x: corner.endsWith('right') ? base.x - offset.x : offset.x - base.x,\n y: corner.startsWith('bottom') ? base.y - offset.y : offset.y - base.y,\n };\n }\n\n /**\n * @param {{ x: number, y: number }} offset\n * @param {{ width: number, height: number }} size\n * @returns {{ x: number, y: number }}\n */\n #clamp(offset, size) {\n return {\n x: clamp(offset.x, window.innerWidth - size.width),\n y: clamp(offset.y, window.innerHeight - size.height),\n };\n }\n}\n\n/**\n * @param {number} value\n * @param {number} max The offset at which the far edge touches the viewport.\n * @returns {number}\n */\nfunction clamp(value, max) {\n return Math.round(Math.min(Math.max(value, MARGIN), Math.max(MARGIN, max - MARGIN)));\n}\n\n/**\n * @typedef {Object} DragOptions\n * @property {'launcher' | 'panel'} name\n * @property {() => boolean} enabled\n * @property {() => HTMLElement | null} element What moves.\n * @property {() => { width: number, height: number }} size How big it means to be.\n * @property {() => Position} corner Which corner the offset counts from.\n * @property {() => { x: number, y: number }} base The theme's offset, before any drag.\n * @property {() => { x: number, y: number } | null} current The widget's displacement now.\n * @property {(displacement: { x: number, y: number }) => void} onMove A new displacement.\n * @property {(name: 'launcher' | 'panel') => void} onSettle The gesture ended here.\n * @property {{ x: string, y: string }} vars The custom properties to write.\n */\n","// @ts-check\n\n/** @import { ReactiveController, LitElement } from 'lit' */\n\n/** How far a finger must travel before the gesture's direction is trusted. */\nconst THRESHOLD = 3;\n\n/** Slack on the \"is there anywhere left to scroll\" reading, in pixels. */\nconst EDGE_SLACK = 1;\n\n/** Overflow values that make an element a scroll container. */\nconst SCROLLABLE = /^(auto|scroll|overlay)$/;\n\n/**\n * Keeps a touch that lands on the open panel from scrolling the page behind\n * it.\n *\n * `overscroll-behavior: contain` is on the message list already, and it does\n * the job for the case it covers: a list that can scroll, dragged past its\n * own end. It has nothing to say about the cases that actually leak. A short\n * conversation does not overflow, so the list is not a scroll container at\n * all and the touch goes straight through to the document — which is what a\n * reader on an iPhone sees as the page sliding around underneath a chat that\n * looks like it should be holding still. The same happens for a touch that\n * starts on the title bar or beside the input.\n *\n * So the rule is decided here instead: a touch on the panel may scroll\n * something inside the panel, and otherwise it does nothing. On the first\n * move of each gesture the controller looks along the touch's own path —\n * `composedPath`, so a scroller inside a consumer's component counts too —\n * for something that can still travel in the direction the finger is going.\n * Finding one, it stands aside for the rest of the gesture; finding none, it\n * cancels the move, and iOS then takes the whole gesture as \"not a scroll\".\n *\n * Two touches are left alone: that is a pinch, and zooming is the reader's.\n * A move that is no longer cancelable is left alone too — the browser has\n * already committed to scrolling, and `overscroll-behavior` is what keeps\n * that inside the list.\n *\n * @implements {ReactiveController}\n */\nexport class ScrollLockController {\n /** @type {LitElement} */\n #host;\n\n /** @type {HTMLElement | null} */\n #panel = null;\n\n /**\n * The gesture in flight: where it started, and what was decided about it.\n *\n * @type {{ x: number, y: number, verdict: 'undecided' | 'allow' | 'block' } | undefined}\n */\n #touch;\n\n /** @param {LitElement} host */\n constructor(host) {\n this.#host = host;\n host.addController(this);\n }\n\n hostUpdated() {\n const panel = /** @type {HTMLElement | null} */ (\n this.#host.renderRoot?.querySelector('[part~=\"panel\"]') ?? null\n );\n if (panel === this.#panel) return;\n\n this.#unbind();\n this.#panel = panel;\n this.#bind();\n }\n\n hostDisconnected() {\n this.#unbind();\n }\n\n #bind() {\n const panel = this.#panel;\n if (!panel) return;\n panel.addEventListener('touchstart', this.#onStart, { passive: true });\n // Cancelling a move is the whole point, so this one cannot be passive.\n panel.addEventListener('touchmove', this.#onMove, { passive: false });\n panel.addEventListener('touchend', this.#onEnd, { passive: true });\n panel.addEventListener('touchcancel', this.#onEnd, { passive: true });\n }\n\n #unbind() {\n const panel = this.#panel;\n if (!panel) return;\n panel.removeEventListener('touchstart', this.#onStart);\n panel.removeEventListener('touchmove', this.#onMove);\n panel.removeEventListener('touchend', this.#onEnd);\n panel.removeEventListener('touchcancel', this.#onEnd);\n this.#panel = null;\n this.#touch = undefined;\n }\n\n /** @param {TouchEvent} event */\n #onStart = (event) => {\n if (event.touches.length !== 1) {\n this.#touch = undefined;\n return;\n }\n const touch = event.touches[0];\n this.#touch = { x: touch.clientX, y: touch.clientY, verdict: 'undecided' };\n };\n\n #onEnd = () => {\n this.#touch = undefined;\n };\n\n /** @param {TouchEvent} event */\n #onMove = (event) => {\n const from = this.#touch;\n if (!from) return;\n\n // A second finger arriving turns this into a pinch. Hands off for the\n // rest of the gesture, zoom included.\n if (event.touches.length > 1) {\n this.#touch = undefined;\n return;\n }\n\n if (from.verdict === 'block') {\n if (event.cancelable) event.preventDefault();\n return;\n }\n if (from.verdict === 'allow') return;\n\n const touch = event.touches[0];\n const dx = touch.clientX - from.x;\n const dy = touch.clientY - from.y;\n // Too small to read a direction from, and too small for the browser to\n // have started scrolling either.\n if (Math.abs(dx) < THRESHOLD && Math.abs(dy) < THRESHOLD) return;\n\n const vertical = Math.abs(dy) >= Math.abs(dx);\n const allowed = this.#canScroll(event, vertical, vertical ? dy : dx);\n from.verdict = allowed ? 'allow' : 'block';\n if (!allowed && event.cancelable) event.preventDefault();\n };\n\n /**\n * Is there something between the touch and the panel that can still scroll\n * the way the finger is going?\n *\n * @param {TouchEvent} event\n * @param {boolean} vertical\n * @param {number} delta Positive when the finger moves down, or right.\n * @returns {boolean}\n */\n #canScroll(event, vertical, delta) {\n const panel = this.#panel;\n if (!panel) return true;\n\n for (const node of event.composedPath()) {\n if (!(node instanceof HTMLElement)) continue;\n\n if (this.#hasRoom(node, vertical, delta)) return true;\n if (node === panel) break;\n }\n return false;\n }\n\n /**\n * @param {HTMLElement} element\n * @param {boolean} vertical\n * @param {number} delta\n * @returns {boolean}\n */\n #hasRoom(element, vertical, delta) {\n const style = getComputedStyle(element);\n const overflow = vertical ? style.overflowY : style.overflowX;\n if (!SCROLLABLE.test(overflow)) return false;\n\n const position = vertical ? element.scrollTop : element.scrollLeft;\n const size = vertical ? element.clientHeight : element.clientWidth;\n const content = vertical ? element.scrollHeight : element.scrollWidth;\n if (content <= size + EDGE_SLACK) return false;\n\n // A finger moving down pulls the content down, which means reading from\n // further up: there has to be something above the current position.\n return delta > 0 ? position > EDGE_SLACK : position < content - size - EDGE_SLACK;\n }\n}\n","// @ts-check\n\n/** @import { ReactiveController, LitElement } from 'lit' */\n\n/**\n * Past this the reader has pinched to zoom, and the widget stays out of it.\n * A little over 1 because browsers report scales like 1.0000002.\n */\nconst ZOOMED = 1.01;\n\n/**\n * Keeps the full-screen panel inside the part of the screen the reader can\n * actually see.\n *\n * On a phone the panel is `position: fixed` across the whole viewport, and\n * that viewport is not what is on screen once a keyboard slides up: the\n * layout viewport keeps its full height, so the composer — and with it the\n * last few messages — ends up behind the keyboard. iOS then scrolls the page\n * to chase the focused field, which moves the fixed panel out of frame\n * instead of helping. `dvh` is no use here either; it tracks the browser's\n * own chrome collapsing, not the keyboard.\n *\n * `visualViewport` is the one thing that does report the visible box, so the\n * panel is pinned to it: its top to `offsetTop`, its height to `height`. The\n * composer lands just above the keyboard, and the conversation gets whatever\n * is left.\n *\n * A pinch is left alone. Zooming is how a reader gets a closer look, and a\n * panel that re-fitted itself to the magnified box would take that away by\n * reflowing the text back to the same apparent size.\n *\n * @implements {ReactiveController}\n */\nexport class ViewportController {\n /** @type {LitElement} */\n #host;\n\n /** @type {() => boolean} */\n #enabled;\n\n /** @type {(() => void) | undefined} */\n #onChange;\n\n /** True while the custom properties are set, to avoid pointless writes. */\n #applied = false;\n\n /**\n * @param {LitElement} host\n * @param {{ enabled: () => boolean }} options\n */\n constructor(host, { enabled }) {\n this.#host = host;\n this.#enabled = enabled;\n host.addController(this);\n }\n\n hostConnected() {\n const viewport = window.visualViewport;\n if (!viewport) return;\n\n this.#onChange = () => this.#apply();\n // Resize is the keyboard arriving and leaving; scroll is iOS shifting the\n // visible box around while it is up.\n viewport.addEventListener('resize', this.#onChange);\n viewport.addEventListener('scroll', this.#onChange);\n }\n\n hostDisconnected() {\n const viewport = window.visualViewport;\n if (viewport && this.#onChange) {\n viewport.removeEventListener('resize', this.#onChange);\n viewport.removeEventListener('scroll', this.#onChange);\n }\n this.#onChange = undefined;\n this.#clear();\n }\n\n hostUpdated() {\n this.#apply();\n }\n\n #apply() {\n const viewport = window.visualViewport;\n const panel = this.#host.renderRoot?.querySelector('[part~=\"panel\"]');\n\n if (!viewport || !panel || !this.#enabled() || viewport.scale > ZOOMED) {\n this.#clear();\n return;\n }\n\n this.#host.style.setProperty('--_chit-vv-top', `${Math.round(viewport.offsetTop)}px`);\n this.#host.style.setProperty('--_chit-vv-height', `${Math.round(viewport.height)}px`);\n this.#applied = true;\n }\n\n #clear() {\n if (!this.#applied) return;\n this.#host.style.removeProperty('--_chit-vv-top');\n this.#host.style.removeProperty('--_chit-vv-height');\n this.#applied = false;\n }\n}\n","// @ts-check\nimport { unsafeHTML } from 'lit/directives/unsafe-html.js';\n\n/** @import { ChitUI } from '../chit-ui.js' */\n/** @import { Message } from '../types.js' */\n\n/**\n * @typedef {Object} ComponentEntry\n * @property {(new () => HTMLElement) | string} source What `component` held when this was built.\n * @property {HTMLElement} element\n * @property {Record<string, unknown>} props Last props written to the element.\n */\n\n/**\n * Per-host component instances, keyed by a caller-chosen string.\n *\n * Messages key by `msg:<id>`; the launcher has its own key. Keeping one cache\n * means one place decides when an element is rebuilt and when its props are\n * merely re-assigned.\n */\nconst INSTANCES = new WeakMap();\n\n/**\n * The cache key for a message's component.\n *\n * @param {string} id\n * @returns {string}\n */\nconst messageKey = (id) => `msg:${id}`;\n\n/** The cache key for the closed-state component. */\nexport const LAUNCHER_KEY = 'launcher';\n\n/** The five ways a message can carry its content. Exactly one may be present. */\nconst CONTENT_FIELDS = /** @type {const} */ ([\n 'text',\n 'html',\n 'template',\n 'element',\n 'component',\n]);\n\n/**\n * Which form a message uses. Also drives the `data-content` attribute, because\n * plain text is the one form whose whitespace has to survive.\n *\n * @param {Message} message\n * @returns {'text' | 'html' | 'template' | 'element' | 'component'}\n */\nexport function contentField(message) {\n const present = CONTENT_FIELDS.filter((field) => field in message);\n if (present.length === 1) return present[0];\n if (present.length === 0) {\n throw new Error(\n `ChitUI: message \"${message.id}\" has no content. Give it one of html, template, element or component.`,\n );\n }\n throw new Error(\n `ChitUI: message \"${message.id}\" has ${present.join(' and ')}. Give it exactly one.`,\n );\n}\n\n/**\n * The value a message's content is built from. Used to decide whether a\n * message actually changed, so `chat-message-render` does not fire on every\n * unrelated update.\n *\n * @param {Message} message\n * @returns {unknown}\n */\nexport function contentKey(message) {\n return /** @type {Record<string, unknown>} */ (message)[contentField(message)];\n}\n\n/**\n * The registered tag name for a `component`.\n *\n * Registration stays the consumer's job: the library never invents a tag name\n * and calls `customElements.define` behind their back, because that name would\n * then be taken globally for the life of the page.\n *\n * @param {(new () => HTMLElement) | string} source\n * @returns {string}\n */\nfunction tagNameOf(source) {\n if (typeof source === 'string') return source;\n\n const registry = /** @type {CustomElementRegistry & { getName?: (c: unknown) => string | null }} */ (\n customElements\n );\n const registered = registry.getName?.(source);\n if (registered) return registered;\n\n const declared = /** @type {{ tagName?: string }} */ (/** @type {unknown} */ (source)).tagName;\n if (typeof declared === 'string' && declared) return declared;\n\n throw new Error(\n 'ChitUI: component is not registered in customElements. ' +\n 'Call customElements.define() for it, or pass its tag name as a string.',\n );\n}\n\n/**\n * Build (or reuse) an element for a component reference and write its props.\n *\n * The instance is kept across renders so the component keeps its own state; a\n * changed reference replaces it, and changed props are assigned one by one so\n * the component's own setters see each change.\n *\n * @param {ChitUI} host\n * @param {string} key Cache key.\n * @param {(new () => HTMLElement) | string} source\n * @param {Record<string, unknown>} [props]\n * @returns {HTMLElement}\n */\nexport function resolveComponent(host, key, source, props = {}) {\n let cache = INSTANCES.get(host);\n if (!cache) {\n cache = new Map();\n INSTANCES.set(host, cache);\n }\n\n const existing = /** @type {ComponentEntry | undefined} */ (cache.get(key));\n\n if (existing && existing.source === source) {\n for (const [name, value] of Object.entries(props)) {\n if (!Object.is(existing.props[name], value)) {\n /** @type {Record<string, unknown>} */ (/** @type {unknown} */ (existing.element))[name] = value;\n }\n }\n existing.props = { ...props };\n return existing.element;\n }\n\n const element = document.createElement(tagNameOf(source));\n for (const [name, value] of Object.entries(props)) {\n /** @type {Record<string, unknown>} */ (/** @type {unknown} */ (element))[name] = value;\n }\n cache.set(key, { source, element, props: { ...props } });\n return element;\n}\n\n/**\n * Drop cached instances for messages that are gone, so a long conversation\n * does not hold on to elements it will never show again. Non-message entries,\n * such as the launcher's, are left alone.\n *\n * @param {ChitUI} host\n * @param {Set<string>} liveIds\n */\nexport function pruneComponents(host, liveIds) {\n const cache = INSTANCES.get(host);\n if (!cache) return;\n for (const key of cache.keys()) {\n if (!key.startsWith('msg:')) continue;\n if (!liveIds.has(key.slice(4))) cache.delete(key);\n }\n}\n\n/**\n * The component instance backing a message, when it has one.\n *\n * @param {ChitUI} host\n * @param {string} id\n * @returns {HTMLElement | undefined}\n */\nexport function componentInstance(host, id) {\n return INSTANCES.get(host)?.get(messageKey(id))?.element;\n}\n\n/**\n * Turn a message's content into something Lit can render as a child value.\n *\n * All four shapes collapse here: an HTML string becomes an `unsafeHTML`\n * directive, a Lit template passes straight through, and an element or a\n * component becomes a Node, which Lit inserts as-is.\n *\n * @param {ChitUI} host\n * @param {Message} message\n * @returns {unknown}\n */\nexport function renderContent(host, message) {\n switch (contentField(message)) {\n case 'text':\n // A string child is rendered by Lit as a text node, so the escaping is\n // structural: there is no parse step for markup to sneak through. Line\n // breaks survive because the content box is pre-wrap for this form.\n return /** @type {{ text: string }} */ (/** @type {unknown} */ (message)).text;\n\n case 'template':\n return /** @type {{ template: unknown }} */ (/** @type {unknown} */ (message)).template;\n\n case 'element':\n return /** @type {{ element: HTMLElement }} */ (/** @type {unknown} */ (message)).element;\n\n case 'component': {\n const carrier = /** @type {{ component: (new () => HTMLElement) | string, props?: Record<string, unknown> }} */ (\n /** @type {unknown} */ (message)\n );\n return resolveComponent(host, messageKey(message.id), carrier.component, carrier.props);\n }\n\n default: {\n // Only the html form goes through `sanitize`: `text` is escaped by\n // construction, and the rest are structures the consumer built\n // themselves rather than markup we could meaningfully clean.\n const raw = /** @type {{ html: string }} */ (/** @type {unknown} */ (message)).html;\n return unsafeHTML(host.sanitize ? host.sanitize(raw) : raw);\n }\n }\n}\n","// @ts-check\nimport { html, nothing } from 'lit';\nimport { LAUNCHER_KEY, resolveComponent } from './content.js';\n\n/** @import { ChitUI } from '../chit-ui.js' */\n\n/**\n * The closed state: one button.\n *\n * What goes inside it has three routes, in order of how much the consumer\n * takes over:\n *\n * - the theme's image or label, drawn inside the themed circle;\n * - the `launcher` slot, their markup inside that same circle;\n * - `closed.component`, a component that draws the whole launcher — the button\n * then keeps only its role, and gives up its size, background, shadow and\n * radius, because two parties styling one box is how things end up clipped.\n *\n * @param {ChitUI} host\n * @returns {import('lit').TemplateResult}\n */\nexport function renderLauncher(host) {\n const closed = host.currentTheme.closed;\n const labels = host.currentLabels;\n const custom = closed.component\n ? resolveComponent(host, LAUNCHER_KEY, closed.component, closed.props)\n : null;\n\n return html`\n <button\n part=\"launcher\"\n type=\"button\"\n aria-label=${closed.label || labels.launcher}\n aria-expanded=${host.state === 'open'}\n ?data-has-image=${!custom && !!closed.image}\n ?data-custom=${!!custom}\n ?data-draggable=${closed.draggable}\n @pointerdown=${(/** @type {PointerEvent} */ event) => host.launcherDrag.start(event)}\n @keydown=${(/** @type {KeyboardEvent} */ event) => host.launcherDrag.nudge(event)}\n @click=${() => {\n // The pointer-up that ends a drag is followed by a click; opening the\n // panel then would punish the reader for having moved the button.\n if (host.launcherDrag.consumeDrag()) return;\n host.toggleFromUser();\n }}\n >\n ${custom ?? html`<slot name=\"launcher\">${defaultContent(closed)}</slot>`}\n </button>\n `;\n}\n\n/**\n * @param {import('../types.js').ResolvedClosed} closed\n * @returns {unknown}\n */\nfunction defaultContent(closed) {\n if (closed.image) return nothing;\n if (closed.label) return html`<span part=\"launcher-label\">${closed.label}</span>`;\n return defaultIcon();\n}\n\n/** A plain speech bubble, so the widget looks like something before theming. */\nfunction defaultIcon() {\n return html`\n <svg part=\"launcher-icon\" viewBox=\"0 0 24 24\" aria-hidden=\"true\" focusable=\"false\">\n <path\n fill=\"currentColor\"\n d=\"M12 3c-4.97 0-9 3.36-9 7.5 0 2.3 1.25 4.36 3.2 5.73-.13 1.2-.6 2.3-1.36 3.2a.5.5 0 0 0 .5.82 8.2 8.2 0 0 0 3.87-1.86c.88.26 1.82.41 2.79.41 4.97 0 9-3.36 9-7.5S16.97 3 12 3Z\"\n />\n </svg>\n `;\n}\n","import{_$LH as o}from\"./lit-html.js\";\n/**\n * @license\n * Copyright 2020 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */const{I:t}=o,i=o=>o,n=o=>null===o||\"object\"!=typeof o&&\"function\"!=typeof o,e={HTML:1,SVG:2,MATHML:3},l=(o,t)=>void 0===t?void 0!==o?._$litType$:o?._$litType$===t,d=o=>null!=o?._$litType$?.h,c=o=>void 0!==o?._$litDirective$,f=o=>o?._$litDirective$,r=o=>void 0===o.strings,s=()=>document.createComment(\"\"),v=(o,n,e)=>{const l=o._$AA.parentNode,d=void 0===n?o._$AB:n._$AA;if(void 0===e){const i=l.insertBefore(s(),d),n=l.insertBefore(s(),d);e=new t(i,n,o,o.options)}else{const t=e._$AB.nextSibling,n=e._$AM,c=n!==o;if(c){let t;e._$AQ?.(o),e._$AM=o,void 0!==e._$AP&&(t=o._$AU)!==n._$AU&&e._$AP(t)}if(t!==d||c){let o=e._$AA;for(;o!==t;){const t=i(o).nextSibling;i(l).insertBefore(o,d),o=t}}}return e},u=(o,t,i=o)=>(o._$AI(t,i),o),m={},p=(o,t=m)=>o._$AH=t,M=o=>o._$AH,h=o=>{o._$AR(),o._$AA.remove()},j=o=>{o._$AR()};export{e as TemplateResultType,j as clearPart,M as getCommittedValue,f as getDirectiveClass,v as insertPart,d as isCompiledTemplateResult,c as isDirectiveResult,n as isPrimitive,r as isSingleExpression,l as isTemplateResult,h as removePart,u as setChildPartValue,p as setCommittedValue};\n//# sourceMappingURL=directive-helpers.js.map\n","import{noChange as e}from\"../lit-html.js\";import{directive as s,Directive as t,PartType as r}from\"../directive.js\";import{getCommittedValue as l,setChildPartValue as o,insertPart as i,removePart as n,setCommittedValue as f}from\"../directive-helpers.js\";\n/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\nconst u=(e,s,t)=>{const r=new Map;for(let l=s;l<=t;l++)r.set(e[l],l);return r},c=s(class extends t{constructor(e){if(super(e),e.type!==r.CHILD)throw Error(\"repeat() can only be used in text expressions\")}dt(e,s,t){let r;void 0===t?t=s:void 0!==s&&(r=s);const l=[],o=[];let i=0;for(const s of e)l[i]=r?r(s,i):i,o[i]=t(s,i),i++;return{values:o,keys:l}}render(e,s,t){return this.dt(e,s,t).values}update(s,[t,r,c]){const d=l(s),{values:p,keys:a}=this.dt(t,r,c);if(!Array.isArray(d))return this.ut=a,p;const h=this.ut??=[],v=[];let m,y,x=0,j=d.length-1,k=0,w=p.length-1;for(;x<=j&&k<=w;)if(null===d[x])x++;else if(null===d[j])j--;else if(h[x]===a[k])v[k]=o(d[x],p[k]),x++,k++;else if(h[j]===a[w])v[w]=o(d[j],p[w]),j--,w--;else if(h[x]===a[w])v[w]=o(d[x],p[w]),i(s,v[w+1],d[x]),x++,w--;else if(h[j]===a[k])v[k]=o(d[j],p[k]),i(s,d[x],d[j]),j--,k++;else if(void 0===m&&(m=u(a,k,w),y=u(h,x,j)),m.has(h[x]))if(m.has(h[j])){const e=y.get(a[k]),t=void 0!==e?d[e]:null;if(null===t){const e=i(s,d[x]);o(e,p[k]),v[k]=e}else v[k]=o(t,p[k]),i(s,d[x],t),d[e]=null;k++}else n(d[j]),j--;else n(d[x]),x++;for(;k<=w;){const e=i(s,v[w+1]);o(e,p[k]),v[k++]=e}for(;x<=j;){const e=d[x++];null!==e&&n(e)}return this.ut=a,f(s,v),e}});export{c as repeat};\n//# sourceMappingURL=repeat.js.map\n","// @ts-check\nimport { html, nothing } from 'lit';\nimport { contentField, renderContent } from './content.js';\n\n/** @import { ChitUI } from '../chit-ui.js' */\n/** @import { Message } from '../types.js' */\n\n/**\n * Format a timestamp. The consumer's `formatTime` wins; otherwise a plain\n * locale-aware hour:minute, which is what a chat bubble wants.\n *\n * @param {ChitUI} host\n * @param {string | Date} time\n * @returns {string}\n */\nfunction formatTime(host, time) {\n const date = time instanceof Date ? time : new Date(time);\n if (Number.isNaN(date.getTime())) return '';\n if (host.formatTime) return host.formatTime(date);\n return new Intl.DateTimeFormat(host.resolvedLocale, {\n hour: '2-digit',\n minute: '2-digit',\n }).format(date);\n}\n\n/**\n * One message.\n *\n * `system` messages are a centred line rather than a bubble: they are the\n * widget talking about the conversation (\"an operator joined\"), not a party to\n * it, so they get no avatar, no name and no timestamp.\n *\n * @param {ChitUI} host\n * @param {Message} message\n * @returns {import('lit').TemplateResult}\n */\nexport function renderMessage(host, message) {\n if (message.role === 'system') {\n return html`\n <article part=\"message message-system\" data-role=\"system\" data-id=${message.id}>\n <div part=\"message-content\" data-content=${contentField(message)}>${renderContent(host, message)}</div>\n </article>\n `;\n }\n\n const meta = message.time || message.status;\n\n // The theme says who is talking; a message overrides either half. `null` on\n // the message hides what the theme set, which is how a run of replies shows\n // the icon only on the first of them.\n const speaker = host.currentTheme.open.speaker[message.role];\n const avatar = message.avatar === undefined ? speaker.avatar : message.avatar;\n const name = message.name === undefined ? speaker.name : message.name;\n\n return html`\n <article\n part=\"message message-${message.role}\"\n data-role=${message.role}\n data-id=${message.id}\n ?data-streaming=${!!message.streaming}\n aria-busy=${message.streaming ? 'true' : 'false'}\n >\n ${avatar\n ? html`<img part=\"avatar\" src=${avatar} alt=\"\" loading=\"lazy\" />`\n : speaker.avatar\n ? html`<span part=\"avatar\" data-placeholder aria-hidden=\"true\"></span>`\n : nothing}\n <div class=\"body\">\n ${name ? html`<span part=\"name\">${name}</span>` : nothing}\n <div part=\"bubble\">\n <div part=\"message-content\" data-content=${contentField(message)}>${renderContent(host, message)}</div>\n ${message.streaming ? html`<span part=\"cursor\" aria-hidden=\"true\"></span>` : nothing}\n </div>\n ${meta\n ? html`\n <div part=\"meta\" class=\"meta\">\n ${message.time\n ? html`<time part=\"time\">${formatTime(host, message.time)}</time>`\n : nothing}\n ${message.status\n ? html`<span part=\"status\" data-status=${message.status}>\n ${host.currentLabels.status[message.status]}\n </span>`\n : nothing}\n </div>\n `\n : nothing}\n </div>\n </article>\n `;\n}\n","// @ts-check\nimport { html, nothing } from 'lit';\nimport { repeat } from 'lit/directives/repeat.js';\nimport { renderMessage } from './message.js';\n\n/** @import { ChitUI } from '../chit-ui.js' */\n\n/**\n * The wait for an answer, at the end of the conversation.\n *\n * It stands where the typing bubble stands and replaces it while it is up:\n * \"typing\" and \"waiting for the server\" are the same moment of the\n * conversation, and two indicators for one wait would only ask the reader to\n * work out the difference.\n *\n * @param {ChitUI} host\n * @returns {import('lit').TemplateResult}\n */\nfunction renderLoading(host) {\n const { style, text } = host.currentTheme.open.loading;\n const label = text ?? host.currentLabels.loading;\n\n return html`\n <div part=\"loading\" data-style=${style} role=\"status\" aria-label=${label}>\n ${style === 'dots'\n ? html`<span class=\"dots\" aria-hidden=\"true\"><i></i><i></i><i></i></span>`\n : nothing}\n ${style === 'spinner' ? html`<span part=\"spinner\" aria-hidden=\"true\"></span>` : nothing}\n ${style === 'text' || text\n ? html`<span part=\"loading-text\">${label}</span>`\n : nothing}\n </div>\n `;\n}\n\n/**\n * The scrolling conversation.\n *\n * `repeat` keys on the message id so an existing bubble's DOM is reused when\n * the consumer assigns a new array; without it Lit would reorder by position\n * and a component message would lose its state on every insert.\n *\n * Clicks are handled once here and re-published as `chat-message-click`, which\n * is how a consumer reaches a button inside a message without hunting through\n * the shadow root.\n *\n * @param {ChitUI} host\n * @returns {import('lit').TemplateResult}\n */\nexport function renderMessageList(host) {\n const labels = host.currentLabels;\n const typing = host.typing;\n const empty = host.messages.length === 0 && !typing && !host.loading;\n\n return html`\n <div\n part=\"messages\"\n role=\"log\"\n aria-live=\"polite\"\n aria-relevant=\"additions text\"\n aria-label=${labels.conversation}\n @click=${(/** @type {MouseEvent} */ event) => host.handleMessageClick(event)}\n >\n <div part=\"messages-inner\" class=\"inner\">\n ${empty ? html`<slot name=\"empty\"></slot>` : nothing}\n ${repeat(\n host.messages,\n (message) => message.id,\n (message) => renderMessage(host, message),\n )}\n ${host.loading\n ? renderLoading(host)\n : typing\n ? html`\n <div part=\"typing\" role=\"status\" aria-label=${labels.typing}>\n ${typeof typing === 'object' && typing.html\n ? host.renderTypingHtml(typing.html)\n : html`<span class=\"dots\" aria-hidden=\"true\"><i></i><i></i><i></i></span>`}\n </div>\n `\n : nothing}\n </div>\n </div>\n\n ${host.hasUnseen\n ? html`\n <button\n part=\"to-latest\"\n type=\"button\"\n @click=${() => host.scrollToBottom({ smooth: true })}\n >\n ${labels.toLatest}\n </button>\n `\n : nothing}\n `;\n}\n","import{noChange as r,nothing as e}from\"../lit-html.js\";import{directive as i,Directive as t,PartType as n}from\"../directive.js\";import{isSingleExpression as o,setCommittedValue as s}from\"../directive-helpers.js\";\n/**\n * @license\n * Copyright 2020 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */const l=i(class extends t{constructor(r){if(super(r),r.type!==n.PROPERTY&&r.type!==n.ATTRIBUTE&&r.type!==n.BOOLEAN_ATTRIBUTE)throw Error(\"The `live` directive is not allowed on child or event bindings\");if(!o(r))throw Error(\"`live` bindings can only contain a single expression\")}render(r){return r}update(i,[t]){if(t===r||t===e)return t;const o=i.element,l=i.name;if(i.type===n.PROPERTY){if(t===o[l])return r}else if(i.type===n.BOOLEAN_ATTRIBUTE){if(!!t===o.hasAttribute(l))return r}else if(i.type===n.ATTRIBUTE&&o.getAttribute(l)===t+\"\")return r;return s(i),t}});export{l as live};\n//# sourceMappingURL=live.js.map\n","// @ts-check\nimport { html, nothing } from 'lit';\nimport { live } from 'lit/directives/live.js';\n\n/** @import { ChitUI } from '../chit-ui.js' */\n\n/**\n * The attach button and the file input it opens.\n *\n * The widget owns the picking and nothing else: it hands the chosen files to\n * the consumer through `chat-attach` and forgets them. Uploading them, showing\n * a preview and adding a message are all things only the consumer can do, and\n * a half-done version here would be in the way of the real one.\n *\n * The input is reset after every pick so that choosing the same file twice in\n * a row still reports the second time.\n *\n * @param {ChitUI} host\n * @param {boolean} disabled\n * @returns {import('lit').TemplateResult}\n */\nfunction renderAttach(host, disabled) {\n const labels = host.currentLabels;\n const input = host.currentTheme.open.input;\n\n return html`\n <button\n part=\"attach-button\"\n type=\"button\"\n aria-label=${labels.attach}\n title=${labels.attach}\n ?disabled=${disabled}\n @click=${() => host.openAttach()}\n >\n <svg viewBox=\"0 0 24 24\" aria-hidden=\"true\" focusable=\"false\">\n <path\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n d=\"M20 11.5 12.2 19.3a4.6 4.6 0 0 1-6.5-6.5l7.8-7.8a3 3 0 0 1 4.3 4.3l-7.8 7.8a1.5 1.5 0 0 1-2.1-2.1l7.1-7.1\"\n />\n </svg>\n </button>\n <input\n part=\"attach-input\"\n type=\"file\"\n tabindex=\"-1\"\n aria-hidden=\"true\"\n accept=${input.accept}\n ?multiple=${input.multiple}\n @change=${(/** @type {Event} */ event) => {\n const field = /** @type {HTMLInputElement} */ (event.target);\n const files = Array.from(field.files ?? []);\n field.value = '';\n if (files.length) host.handleAttach(files);\n }}\n />\n `;\n}\n\n/**\n * The composer: a textarea that grows with its content, and a send button.\n *\n * The whole thing can be replaced through the `composer` slot; a consumer who\n * does that calls `host.submit(text)` themselves. `input-before` and\n * `input-after` are the lighter option, for an attach or emoji button beside\n * the box the library still owns.\n *\n * @param {ChitUI} host\n * @returns {import('lit').TemplateResult | typeof nothing}\n */\nexport function renderComposer(host) {\n if (host.inputHidden) return nothing;\n\n const labels = host.currentLabels;\n const theme = host.currentTheme.open;\n const disabled = host.busy || host.inputDisabled;\n const placeholder = host.placeholder ?? theme.input.placeholder ?? labels.input;\n\n return html`\n <form\n part=\"composer\"\n @submit=${(/** @type {SubmitEvent} */ event) => {\n event.preventDefault();\n host.submit();\n }}\n >\n <slot name=\"composer\">\n ${theme.input.attach ? renderAttach(host, disabled) : nothing}\n\n <slot name=\"input-before\"></slot>\n\n <textarea\n part=\"input\"\n rows=\"1\"\n .value=${live(host.value)}\n placeholder=${placeholder}\n aria-label=${labels.input}\n ?disabled=${disabled}\n aria-describedby=${host.maxLength === undefined ? nothing : 'chit-counter'}\n @input=${(/** @type {Event} */ event) => host.handleInput(event)}\n @keydown=${(/** @type {KeyboardEvent} */ event) => host.handleKeydown(event)}\n @compositionstart=${() => host.handleComposition(true)}\n @compositionend=${() => host.handleComposition(false)}\n ></textarea>\n\n <slot name=\"input-after\"></slot>\n\n ${host.maxLength === undefined\n ? nothing\n : html`<span part=\"counter\" id=\"chit-counter\" aria-live=\"polite\" hidden></span>`}\n\n <button\n part=\"send-button\"\n type=\"submit\"\n aria-label=${labels.send}\n ?disabled=${!host.canSend}\n >\n ${host.busy\n ? html`<span part=\"spinner\" aria-hidden=\"true\"></span>`\n : html`<svg viewBox=\"0 0 24 24\" aria-hidden=\"true\" focusable=\"false\">\n <path fill=\"currentColor\" d=\"M3.4 20.4 21 12 3.4 3.6 3.39 10.2 15.6 12 3.39 13.8z\" />\n </svg>`}\n </button>\n </slot>\n </form>\n `;\n}\n","// @ts-check\nimport { html, nothing } from 'lit';\nimport { renderMessageList } from './message-list.js';\nimport { renderComposer } from './composer.js';\n\n/** @import { ChitUI } from '../chit-ui.js' */\n\n/**\n * The open state. Header and footer are slots; the message list and the\n * composer arrive in later milestones and are placeholders for now.\n *\n * @param {ChitUI} host\n * @returns {import('lit').TemplateResult}\n */\nexport function renderPanel(host) {\n const open = host.currentTheme.open;\n const labels = host.currentLabels;\n const title = open.header.title ?? labels.panel;\n\n return html`\n <section\n part=\"panel\"\n role=\"dialog\"\n aria-modal=\"false\"\n aria-label=${title}\n tabindex=\"-1\"\n @keydown=${(/** @type {KeyboardEvent} */ event) => onKeydown(host, event)}\n >\n ${open.header.visible ? renderHeader(host, title) : nothing}\n\n ${renderMessageList(host)} ${renderComposer(host)}\n\n <slot name=\"footer\"></slot>\n </section>\n `;\n}\n\n/**\n * The title bar.\n *\n * It can be left out entirely (`open.header.visible = false`), which is what a\n * widget embedded in a host that already draws its own title bar wants — LINE\n * LIFF, for one — rather than two stacked titles. The dialog keeps its\n * accessible name either way: that name is read, not seen.\n *\n * Note that hiding it takes the close button with it. Esc and the launcher\n * still close the panel, and the host's own chrome usually supplies the rest.\n *\n * @param {ChitUI} host\n * @param {string} title\n * @returns {import('lit').TemplateResult}\n */\nfunction renderHeader(host, title) {\n const open = host.currentTheme.open;\n const labels = host.currentLabels;\n const draggable = open.draggable && host.device === 'pc';\n\n return html`\n <header\n part=\"header\"\n ?data-draggable=${draggable}\n tabindex=${draggable ? '0' : nothing}\n aria-label=${draggable ? labels.move : nothing}\n @pointerdown=${(/** @type {PointerEvent} */ event) => {\n // Only the bar itself is a handle: a drag that starts on the close\n // button would swallow the click that closes the panel.\n if (/** @type {HTMLElement} */ (event.target).closest('button')) return;\n host.panelDrag.start(event);\n }}\n @keydown=${(/** @type {KeyboardEvent} */ event) => {\n if (event.target !== event.currentTarget) return;\n host.panelDrag.nudge(event);\n }}\n >\n <slot name=\"header\">\n <slot name=\"header-title\">\n <span part=\"header-title\">\n ${open.header.logo\n ? html`<img part=\"header-logo\" src=${open.header.logo} alt=\"\" />`\n : nothing}\n <span part=\"header-heading\">${title}</span>\n </span>\n </slot>\n <span part=\"header-actions\">\n <slot name=\"header-actions\"></slot>\n ${open.header.home\n ? html`<button\n part=\"home-button\"\n type=\"button\"\n aria-label=${labels.home}\n title=${labels.home}\n @click=${() => host.home('user')}\n >\n <svg viewBox=\"0 0 24 24\" aria-hidden=\"true\" focusable=\"false\">\n <path\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linejoin=\"round\"\n stroke-linecap=\"round\"\n d=\"M4 11.2 12 4l8 7.2M6.5 9.8V19h11V9.8M10 19v-4.6h4V19\"\n />\n </svg>\n </button>`\n : nothing}\n <button\n part=\"close-button\"\n type=\"button\"\n aria-label=${labels.close}\n @click=${() => host.closeFromUser()}\n >\n <svg viewBox=\"0 0 24 24\" aria-hidden=\"true\" focusable=\"false\">\n <path\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n d=\"M6 6l12 12M18 6L6 18\"\n />\n </svg>\n </button>\n </span>\n </slot>\n </header>\n `;\n}\n\n/**\n * Esc closes the panel. It is handled here rather than on the host so that it\n * only applies while the panel has focus inside it.\n *\n * @param {ChitUI} host\n * @param {KeyboardEvent} event\n */\nfunction onKeydown(host, event) {\n if (event.key !== 'Escape' || event.defaultPrevented) return;\n event.preventDefault();\n host.closeFromUser();\n}\n","// @ts-check\n\n/**\n * @typedef {Object} Labels\n * @property {string} launcher Accessible name of the closed-state button.\n * @property {string} panel Accessible name of the dialog.\n * @property {string} conversation Accessible name of the message log.\n * @property {string} close Close button.\n * @property {string} home Home button: back to the start of the conversation.\n * @property {string} send Send button.\n * @property {string} attach Attach button beside the composer.\n * @property {string} input Composer textarea.\n * @property {string} typing Announced while the other side is typing.\n * @property {string} loading Announced while waiting for an answer.\n * @property {string} move The panel's drag handle.\n * @property {string} toLatest \"Jump to newest\" button.\n * @property {{ sending: string, sent: string, error: string }} status Delivery state of one's own message.\n * @property {string} charactersLeft Counter, with {n} for the number remaining.\n * @property {string} overLimit Counter past the limit, with {n} for the excess.\n */\n\n/** @type {Record<string, Labels>} */\nconst BUILT_IN = {\n ja: {\n launcher: 'チャットを開く',\n panel: 'チャット',\n conversation: '会話',\n close: 'チャットを閉じる',\n home: '最初に戻る',\n send: '送信',\n attach: '画像や動画を添付',\n input: 'メッセージを入力',\n typing: '入力中',\n loading: '応答を待っています',\n move: 'チャットの位置を移動(矢印キー)',\n toLatest: '最新へ',\n status: { sending: '送信中', sent: '送信済み', error: '送信できませんでした' },\n charactersLeft: '残り {n} 文字',\n overLimit: '{n} 文字超過しています',\n },\n en: {\n launcher: 'Open chat',\n panel: 'Chat',\n conversation: 'Conversation',\n close: 'Close chat',\n home: 'Back to the start',\n send: 'Send',\n attach: 'Attach an image or video',\n input: 'Type a message',\n typing: 'Typing',\n loading: 'Waiting for a reply',\n move: 'Move the chat (arrow keys)',\n toLatest: 'Jump to latest',\n status: { sending: 'Sending', sent: 'Sent', error: 'Not delivered' },\n charactersLeft: '{n} characters left',\n overLimit: '{n} characters over the limit',\n },\n};\n\n/**\n * The language the widget speaks: the `locale` property, else the document's,\n * else the browser's. Everything locale-dependent — labels and timestamps\n * alike — goes through this, so they cannot disagree.\n *\n * @param {string | undefined} locale\n * @returns {string | undefined} undefined means \"whatever the browser uses\".\n */\nexport function resolveLocale(locale) {\n return locale || document.documentElement.lang || undefined;\n}\n\n/**\n * Pick the label set for a locale, falling back to English for anything we do\n * not ship. `overrides` is the host's `labels` property.\n *\n * @param {string | undefined} locale\n * @param {Partial<Labels> | undefined} [overrides]\n * @returns {Labels}\n */\nexport function resolveLabels(locale, overrides) {\n const lang = (resolveLocale(locale) || 'en').toLowerCase();\n const base = BUILT_IN[lang] ?? BUILT_IN[lang.split('-')[0]] ?? BUILT_IN.en;\n return overrides ? { ...base, ...overrides } : base;\n}\n","// @ts-check\nimport { css } from 'lit';\n\n/**\n * Host-level concerns: the coordinate space the widget lives in, the theme\n * fallbacks, and the transition animations.\n *\n * Every custom property here is a fallback only. ThemeController writes the\n * real values into an adopted stylesheet that sits ahead of this one, and page\n * CSS (`chit-ui { --chit-color-accent: ... }`) beats both.\n */\nexport const hostStyles = css`\n :host {\n --chit-z-index: 2147483000;\n --chit-font-family: system-ui, -apple-system, 'Segoe UI', 'Hiragino Sans', 'Noto Sans JP', sans-serif;\n --chit-font-size: 14px;\n\n --chit-launcher-size: 60px;\n --chit-launcher-offset-x: 24px;\n --chit-launcher-offset-y: 24px;\n --chit-launcher-radius: 30px;\n --chit-launcher-bg: #1a73e8;\n --chit-launcher-text: #ffffff;\n --chit-launcher-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);\n\n --chit-panel-width: 380px;\n --chit-panel-height: 600px;\n --chit-panel-offset-x: 24px;\n --chit-panel-offset-y: 24px;\n --chit-panel-radius: 16px;\n --chit-panel-shadow: 0 8px 32px rgba(0, 0, 0, 0.24);\n\n --chit-color-bg: #ffffff;\n --chit-color-text: #1f1f1f;\n --chit-color-accent: #1a73e8;\n --chit-color-border: #e4e4e7;\n --chit-color-header-bg: #ffffff;\n --chit-color-header-text: #1f1f1f;\n\n --chit-bubble-radius: 14px;\n\n position: fixed;\n inset: 0;\n z-index: var(--chit-z-index);\n /* The host is only a coordinate space; clicks land on the page behind it. */\n pointer-events: none;\n font-family: var(--chit-font-family);\n font-size: var(--chit-font-size);\n color: var(--chit-color-text);\n -webkit-font-smoothing: antialiased;\n }\n\n /*\n * Keyed off what the DOM is showing, not off the state property: that flips\n * to 'hidden' the moment it is assigned, while the exit animation still has\n * to play.\n */\n :host([data-rendered-state='hidden']) {\n display: none;\n }\n\n :host > *,\n [part] {\n pointer-events: auto;\n }\n\n *,\n *::before,\n *::after {\n box-sizing: border-box;\n }\n\n /* --- transitions ------------------------------------------------------ */\n\n [data-anim] {\n animation-duration: var(--_chit-anim-duration, 200ms);\n animation-fill-mode: both;\n animation-timing-function: cubic-bezier(0.2, 0.8, 0.2, 1);\n }\n\n [data-anim='enter'][data-effect='fade'] {\n animation-name: chit-fade-in;\n }\n [data-anim='exit'][data-effect='fade'] {\n animation-name: chit-fade-out;\n }\n [data-anim='enter'][data-effect='scale'] {\n animation-name: chit-scale-in;\n }\n [data-anim='exit'][data-effect='scale'] {\n animation-name: chit-scale-out;\n }\n [data-anim='enter'][data-effect='slide'] {\n animation-name: chit-slide-in;\n }\n [data-anim='exit'][data-effect='slide'] {\n animation-name: chit-slide-out;\n }\n\n @keyframes chit-fade-in {\n from {\n opacity: 0;\n }\n to {\n opacity: 1;\n }\n }\n @keyframes chit-fade-out {\n from {\n opacity: 1;\n }\n to {\n opacity: 0;\n }\n }\n @keyframes chit-scale-in {\n from {\n opacity: 0;\n transform: scale(0.85);\n }\n to {\n opacity: 1;\n transform: none;\n }\n }\n @keyframes chit-scale-out {\n from {\n opacity: 1;\n transform: none;\n }\n to {\n opacity: 0;\n transform: scale(0.85);\n }\n }\n @keyframes chit-slide-in {\n from {\n opacity: 0;\n transform: translateY(16px);\n }\n to {\n opacity: 1;\n transform: none;\n }\n }\n @keyframes chit-slide-out {\n from {\n opacity: 1;\n transform: none;\n }\n to {\n opacity: 0;\n transform: translateY(16px);\n }\n }\n\n @media (prefers-reduced-motion: reduce) {\n [data-anim] {\n animation: none !important;\n }\n }\n`;\n","// @ts-check\nimport { css } from 'lit';\n\nexport const launcherStyles = css`\n [part~='launcher'] {\n position: absolute;\n display: grid;\n place-items: center;\n width: var(--chit-launcher-size);\n height: var(--chit-launcher-size);\n padding: 0;\n border: 0;\n border-radius: var(--chit-launcher-radius);\n background-color: var(--chit-launcher-bg);\n background-position: center;\n background-size: cover;\n background-repeat: no-repeat;\n color: var(--chit-launcher-text);\n box-shadow: var(--chit-launcher-shadow);\n font: inherit;\n line-height: 1;\n cursor: pointer;\n transition: filter 120ms ease;\n }\n\n /*\n * A draggable launcher takes the touch gestures for itself, so a finger on\n * it moves the button instead of scrolling the page behind it.\n */\n [part~='launcher'][data-draggable] {\n cursor: grab;\n touch-action: none;\n }\n\n [part~='launcher'][data-draggable]:active {\n cursor: grabbing;\n }\n\n /* The image comes from the theme, so it is a background rather than an <img>. */\n [part~='launcher'][data-has-image] {\n background-image: var(--chit-launcher-image);\n }\n\n /*\n * A consumer component draws the whole launcher, so the button stops being a\n * visual of its own: no box to squeeze the component into, and none of the\n * widget's own paint behind it. It keeps being a button, which is the part\n * that matters for keyboards and screen readers.\n */\n [part~='launcher'][data-custom] {\n width: auto;\n height: auto;\n padding: 0;\n border-radius: 0;\n background: none;\n box-shadow: none;\n color: inherit;\n }\n\n [part~='launcher'][data-custom]:hover {\n filter: none;\n }\n\n [part~='launcher']:hover {\n filter: brightness(1.06);\n }\n\n [part~='launcher']:focus-visible {\n outline: 2px solid var(--chit-launcher-bg);\n outline-offset: 3px;\n }\n\n [part~='launcher-icon'] {\n width: 55%;\n height: 55%;\n }\n\n [part~='launcher-label'] {\n padding: 0 0.75em;\n font-size: 0.95em;\n white-space: nowrap;\n }\n\n /* --- placement -------------------------------------------------------- */\n\n :host([data-launcher-position='bottom-right']) [part~='launcher'] {\n right: var(--chit-launcher-offset-x);\n bottom: var(--chit-launcher-offset-y);\n transform-origin: bottom right;\n }\n :host([data-launcher-position='bottom-left']) [part~='launcher'] {\n left: var(--chit-launcher-offset-x);\n bottom: var(--chit-launcher-offset-y);\n transform-origin: bottom left;\n }\n :host([data-launcher-position='top-right']) [part~='launcher'] {\n right: var(--chit-launcher-offset-x);\n top: var(--chit-launcher-offset-y);\n transform-origin: top right;\n }\n :host([data-launcher-position='top-left']) [part~='launcher'] {\n left: var(--chit-launcher-offset-x);\n top: var(--chit-launcher-offset-y);\n transform-origin: top left;\n }\n\n /* --- idle motion ------------------------------------------------------ */\n\n /*\n * Only while nothing else is animating: a transition sets data-anim and owns\n * the animation property for as long as it runs.\n */\n :host([data-idle='pulse']) [part~='launcher']:not([data-anim]) {\n animation: chit-idle-pulse 2.4s ease-in-out infinite;\n }\n :host([data-idle='bounce']) [part~='launcher']:not([data-anim]) {\n animation: chit-idle-bounce 2.4s ease-in-out infinite;\n }\n\n @keyframes chit-idle-pulse {\n 0%,\n 70%,\n 100% {\n box-shadow: var(--chit-launcher-shadow);\n }\n 35% {\n box-shadow:\n var(--chit-launcher-shadow),\n 0 0 0 10px color-mix(in srgb, var(--chit-launcher-bg) 22%, transparent);\n }\n }\n\n @keyframes chit-idle-bounce {\n 0%,\n 62%,\n 100% {\n transform: translateY(0);\n }\n 72% {\n transform: translateY(-6px);\n }\n 86% {\n transform: translateY(-2px);\n }\n }\n\n @media (prefers-reduced-motion: reduce) {\n :host([data-idle]) [part~='launcher']:not([data-anim]) {\n animation: none;\n }\n }\n`;\n","// @ts-check\nimport { css } from 'lit';\n\nexport const panelStyles = css`\n [part~='panel'] {\n position: absolute;\n display: flex;\n flex-direction: column;\n width: var(--chit-panel-width);\n height: var(--chit-panel-height);\n /*\n * The room left between the panel's own corner and the far edge. Doubling\n * the offset instead would assume the panel is centred between two equal\n * gaps, which stops being true the moment it is dragged: moving it up\n * would have made it shorter on the way.\n */\n max-width: calc(100vw - var(--chit-panel-offset-x) - 8px);\n max-height: calc(100vh - var(--chit-panel-offset-y) - 8px);\n overflow: hidden;\n border-radius: var(--chit-panel-radius);\n background-color: var(--chit-color-bg);\n background-image: var(--chit-panel-bg-image);\n background-size: cover;\n background-position: center;\n box-shadow: var(--chit-panel-shadow);\n }\n\n /* --- placement -------------------------------------------------------- */\n\n :host([data-panel-position='bottom-right']) [part~='panel'] {\n right: var(--chit-panel-offset-x);\n bottom: var(--chit-panel-offset-y);\n transform-origin: bottom right;\n }\n :host([data-panel-position='bottom-left']) [part~='panel'] {\n left: var(--chit-panel-offset-x);\n bottom: var(--chit-panel-offset-y);\n transform-origin: bottom left;\n }\n :host([data-panel-position='top-right']) [part~='panel'] {\n right: var(--chit-panel-offset-x);\n top: var(--chit-panel-offset-y);\n transform-origin: top right;\n }\n :host([data-panel-position='top-left']) [part~='panel'] {\n left: var(--chit-panel-offset-x);\n top: var(--chit-panel-offset-y);\n transform-origin: top left;\n }\n\n [part~='panel']:focus {\n outline: none;\n }\n\n /*\n * A phone gets the whole screen. dvh rather than vh so the browser chrome\n * collapsing does not leave a gap, and the safe-area insets keep the header\n * clear of the notch.\n *\n * While a keyboard is up, the two --_chit-vv-* properties carry what is\n * actually on screen (ViewportController fills them in from\n * visualViewport); dvh knows nothing about a keyboard and would leave the\n * composer behind it.\n */\n :host([data-device='mobile']) [part~='panel'],\n :host([data-device='mobile'][data-panel-position]) [part~='panel'] {\n inset: 0;\n top: var(--_chit-vv-top, 0px);\n width: 100vw;\n height: var(--_chit-vv-height, 100dvh);\n max-width: none;\n max-height: none;\n border-radius: 0;\n padding-top: env(safe-area-inset-top);\n padding-bottom: env(safe-area-inset-bottom);\n overscroll-behavior: contain;\n }\n\n [part~='header'] {\n display: flex;\n flex: none;\n align-items: center;\n justify-content: space-between;\n gap: 0.5em;\n padding: 0.875em 1em;\n border-bottom: 1px solid var(--chit-color-border);\n background: var(--chit-color-header-bg);\n color: var(--chit-color-header-text);\n }\n\n /*\n * The image and the title are one flex item. A slot is display: contents,\n * so without this wrapper its children become items of the header itself\n * and space-between pushes the image to one edge and the title to the\n * middle, away from each other.\n */\n [part~='header'][data-draggable] {\n cursor: grab;\n touch-action: none;\n user-select: none;\n }\n\n [part~='header'][data-draggable]:active {\n cursor: grabbing;\n }\n\n [part~='header'][data-draggable]:focus-visible {\n outline: 2px solid var(--chit-color-accent);\n outline-offset: -2px;\n }\n\n [part~='header-title'] {\n display: inline-flex;\n min-width: 0;\n align-items: center;\n gap: 0.5em;\n }\n\n [part~='header-heading'] {\n overflow: hidden;\n font-size: 1.05em;\n font-weight: 600;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n\n [part~='header-logo'] {\n flex: none;\n width: 1.75em;\n height: 1.75em;\n border-radius: 50%;\n object-fit: cover;\n }\n\n [part~='header-actions'] {\n display: inline-flex;\n align-items: center;\n gap: 0.25em;\n }\n\n [part~='home-button'],\n [part~='close-button'] {\n display: grid;\n place-items: center;\n width: 2em;\n height: 2em;\n padding: 0;\n border: 0;\n border-radius: 50%;\n background: transparent;\n color: inherit;\n cursor: pointer;\n }\n\n [part~='home-button']:hover,\n [part~='close-button']:hover {\n background: color-mix(in srgb, currentColor 10%, transparent);\n }\n\n [part~='home-button']:focus-visible,\n [part~='close-button']:focus-visible {\n outline: 2px solid var(--chit-color-accent);\n outline-offset: 1px;\n }\n\n [part~='home-button'] svg,\n [part~='close-button'] svg {\n width: 1.1em;\n height: 1.1em;\n }\n\n`;\n","// @ts-check\nimport { css } from 'lit';\n\nexport const messageStyles = css`\n :host {\n /* Internal: the box the tail's path is drawn in. The path is written in\n these units, so the two move together. */\n --_chit-tail-w: 18px;\n --_chit-tail-h: 20px;\n /* How deep the tail's root sits inside the bubble. Less than the\n bubble's own padding, so it never reaches the text. */\n --_chit-tail-root: 9px;\n /* Far enough down that the bubble's edge has straightened out under it. */\n --_chit-tail-offset: calc(var(--chit-bubble-radius) / 4 + 1px);\n }\n\n [part~='messages'] {\n flex: 1 1 auto;\n min-height: 0;\n overflow-y: auto;\n overscroll-behavior: contain;\n scrollbar-width: thin;\n }\n\n [part~='messages-inner'] {\n display: flex;\n flex-direction: column;\n gap: 0.75em;\n padding: 1em;\n }\n\n /*\n * The row spans the full width and the bubble is capped inside it. Letting\n * the row shrink to fit instead would make the bubble's percentage cap\n * resolve against a shrink-to-fit parent, and because the content sets\n * overflow-wrap: anywhere its min-content width is one character — so the\n * bubble collapsed to a single column of letters.\n */\n [part~='message'] {\n display: flex;\n /*\n * The icon sits level with the top of the speaker's block — beside the\n * name when there is one, beside the bubble's first line otherwise. At\n * the bottom it would end up next to the timestamp, away from everything\n * it identifies.\n */\n align-items: flex-start;\n gap: 0.5em;\n width: 100%;\n max-width: 100%;\n }\n\n [part~='message'] .body {\n display: flex;\n min-width: 0;\n max-width: 78%;\n flex-direction: column;\n gap: 0.25em;\n }\n\n /* Reversed row: the bubble sits at the right edge without shrinking the row. */\n [part~='message-user'] {\n flex-direction: row-reverse;\n }\n\n [part~='message-user'] .body {\n align-items: flex-end;\n }\n\n [part~='bubble'] {\n position: relative;\n padding: 0.6em 0.85em;\n border-radius: var(--chit-bubble-radius);\n background: var(--chit-color-assistant-bg);\n color: var(--chit-color-assistant-text);\n }\n\n [part~='message-user'] [part~='bubble'] {\n background: var(--chit-color-user-bg);\n color: var(--chit-color-user-text);\n border-bottom-right-radius: 4px;\n }\n\n [part~='message-assistant'] [part~='bubble'] {\n border-bottom-left-radius: 4px;\n }\n\n /* --- tails -------------------------------------------------------------\n *\n * A tail is one pseudo-element: a box in the bubble's colour, clipped to a\n * leaf whose point sits outside the bubble and whose root is buried inside\n * it. Burying the root is what makes the join disappear — the bubble's own\n * background covers the seam, so every corner keeps its radius and the two\n * read as one shape at any radius.\n *\n * It hangs a little below the corner, where the bubble's edge has\n * straightened out, so the root has something flat to sit against. The\n * offset follows the radius for that reason.\n *\n * The other side and the downward version are the same path mirrored, so\n * the curve is written once.\n */\n\n [part~='bubble']::after,\n [part~='typing']::after,\n [part~='loading']::after {\n content: '';\n display: none;\n position: absolute;\n width: var(--_chit-tail-w);\n height: var(--_chit-tail-h);\n clip-path: path('M 18 0.5 Q 8 0.8 0.5 3.5 Q 0 5.2 2 7 Q 10 9.5 18 19 Z');\n }\n\n /*\n * Everything below needs clip-path: path() to draw the leaf. Where that is\n * missing the tail stays hidden and the bubble keeps its default shape,\n * rather than a bare rectangle poking out of its side.\n */\n @supports (clip-path: path('M 0 0 Z')) {\n :host([data-bubble-tail='top']) [part~='bubble']::after,\n :host([data-bubble-tail='top']) [part~='typing']::after,\n :host([data-bubble-tail='top']) [part~='loading']::after,\n :host([data-bubble-tail='bottom']) [part~='bubble']::after,\n :host([data-bubble-tail='bottom']) [part~='typing']::after,\n :host([data-bubble-tail='bottom']) [part~='loading']::after {\n display: block;\n }\n\n /*\n * With a tail there is no need to clip the speaker's corner as well: one\n * bubble carries one cue about who is talking, not two.\n */\n :host([data-bubble-tail='top']) [part~='bubble'],\n :host([data-bubble-tail='top']) [part~='typing'],\n :host([data-bubble-tail='top']) [part~='loading'],\n :host([data-bubble-tail='bottom']) [part~='bubble'],\n :host([data-bubble-tail='bottom']) [part~='typing'],\n :host([data-bubble-tail='bottom']) [part~='loading'] {\n border-radius: var(--chit-bubble-radius);\n }\n\n /* Their side: the leaf points left, its root inside the bubble. */\n :host([data-bubble-tail]) [part~='message-assistant'] [part~='bubble']::after,\n :host([data-bubble-tail]) [part~='typing']::after,\n :host([data-bubble-tail]) [part~='loading']::after {\n right: calc(100% - var(--_chit-tail-root));\n background: var(--chit-color-assistant-bg);\n }\n\n /* Your side: the same leaf, mirrored. */\n :host([data-bubble-tail]) [part~='message-user'] [part~='bubble']::after {\n left: calc(100% - var(--_chit-tail-root));\n background: var(--chit-color-user-bg);\n transform: scaleX(-1);\n }\n\n :host([data-bubble-tail='top']) [part~='bubble']::after,\n :host([data-bubble-tail='top']) [part~='typing']::after,\n :host([data-bubble-tail='top']) [part~='loading']::after {\n top: var(--_chit-tail-offset);\n }\n\n :host([data-bubble-tail='bottom']) [part~='bubble']::after,\n :host([data-bubble-tail='bottom']) [part~='typing']::after,\n :host([data-bubble-tail='bottom']) [part~='loading']::after {\n bottom: var(--_chit-tail-offset);\n }\n\n :host([data-bubble-tail='bottom']) [part~='message-assistant'] [part~='bubble']::after,\n :host([data-bubble-tail='bottom']) [part~='typing']::after,\n :host([data-bubble-tail='bottom']) [part~='loading']::after {\n transform: scaleY(-1);\n }\n\n :host([data-bubble-tail='bottom']) [part~='message-user'] [part~='bubble']::after {\n transform: scale(-1, -1);\n }\n }\n\n [part~='avatar'] {\n flex: none;\n width: 2em;\n height: 2em;\n border-radius: 50%;\n object-fit: cover;\n }\n\n /*\n * A message that hides the theme's icon (avatar: null, for the second and\n * later messages in a run) keeps its place in the row, so the bubbles below\n * stay in line with the one that shows the face.\n */\n [part~='avatar'][data-placeholder] {\n visibility: hidden;\n }\n\n [part~='name'] {\n font-size: 0.8em;\n color: var(--chit-color-system-text);\n }\n\n [part~='meta'] {\n display: flex;\n gap: 0.5em;\n font-size: 0.75em;\n color: var(--chit-color-system-text);\n }\n\n [part~='status'][data-status='error'] {\n color: #d93025;\n }\n\n [part~='message-system'] {\n justify-content: center;\n font-size: 0.8em;\n color: var(--chit-color-system-text);\n text-align: center;\n }\n\n /* --- streaming and typing --------------------------------------------- */\n\n [part~='cursor'] {\n display: inline-block;\n width: 0.5em;\n height: 1em;\n margin-inline-start: 0.15em;\n background: currentColor;\n opacity: 0.6;\n vertical-align: text-bottom;\n animation: chit-caret 1s step-end infinite;\n }\n\n @keyframes chit-caret {\n 50% {\n opacity: 0;\n }\n }\n\n [part~='typing'],\n [part~='loading'] {\n position: relative;\n align-self: flex-start;\n /* Indented past the speaker's icon, when the theme gives them one. */\n margin-inline-start: var(--_chit-speaker-gutter, 0px);\n padding: 0.7em 0.9em;\n /*\n * Stated rather than left to the font's idea of \"normal\", so that both\n * indicators are the same height whatever the page's typeface does, and\n * so the spinner has a line box it is known to fit inside.\n */\n line-height: 1.5;\n border-radius: var(--chit-bubble-radius);\n border-bottom-left-radius: 4px;\n background: var(--chit-color-assistant-bg);\n color: var(--chit-color-assistant-text);\n }\n\n /*\n * The wait is laid out inline, like the typing bubble it stands in for. A\n * flex box has no line box of its own, so dots or a spinner alone would sit\n * in a noticeably shorter bubble than one holding a line of text.\n */\n [part~='loading'] > * + * {\n margin-inline-start: 0.5em;\n }\n\n [part~='loading'] [part~='spinner'] {\n display: inline-block;\n /*\n * Centred on the line rather than sitting on the baseline: at 1.1em it\n * then fits inside the line box the text would have made on its own, so\n * a spinner bubble is exactly as tall as a typing bubble.\n */\n vertical-align: middle;\n color: var(--chit-color-system-text);\n }\n\n [part~='loading-text'] {\n font-size: 0.9em;\n }\n\n [part~='typing'] .dots,\n [part~='loading'] .dots {\n display: inline-flex;\n gap: 0.25em;\n }\n\n [part~='typing'] .dots i,\n [part~='loading'] .dots i {\n width: 0.4em;\n height: 0.4em;\n border-radius: 50%;\n background: currentColor;\n opacity: 0.4;\n animation: chit-typing 1.2s ease-in-out infinite;\n }\n\n [part~='typing'] .dots i:nth-child(2),\n [part~='loading'] .dots i:nth-child(2) {\n animation-delay: 0.15s;\n }\n [part~='typing'] .dots i:nth-child(3),\n [part~='loading'] .dots i:nth-child(3) {\n animation-delay: 0.3s;\n }\n\n @keyframes chit-typing {\n 0%,\n 60%,\n 100% {\n opacity: 0.35;\n transform: translateY(0);\n }\n 30% {\n opacity: 1;\n transform: translateY(-3px);\n }\n }\n\n /* --- jump to latest ---------------------------------------------------- */\n\n [part~='to-latest'] {\n position: absolute;\n left: 50%;\n bottom: 5.5em;\n transform: translateX(-50%);\n padding: 0.35em 0.9em;\n border: 1px solid var(--chit-color-border);\n border-radius: 999px;\n background: var(--chit-color-bg);\n color: var(--chit-color-text);\n box-shadow: 0 2px 8px rgba(0, 0, 0, 0.16);\n font: inherit;\n font-size: 0.8em;\n cursor: pointer;\n }\n\n [part~='to-latest']:focus-visible {\n outline: 2px solid var(--chit-color-accent);\n outline-offset: 2px;\n }\n\n @media (prefers-reduced-motion: reduce) {\n [part~='cursor'],\n [part~='typing'] .dots i,\n [part~='loading'] .dots i {\n animation: none;\n }\n }\n`;\n","// @ts-check\nimport { css } from 'lit';\n\n/**\n * Everything that keeps arbitrary consumer HTML inside its bubble.\n *\n * The widget has no say over what goes in a message, so the containment is\n * structural rather than a list of rules per element: the content box declares\n * its own size, refuses to grow past the bubble, and contains its layout and\n * paint so a stray position or margin cannot escape.\n */\nexport const contentStyles = css`\n [part~='message-content'] {\n min-width: 0;\n max-width: 100%;\n /* Long URLs and unbroken words wrap instead of widening the bubble. */\n overflow-wrap: anywhere;\n word-break: normal;\n overflow-x: hidden;\n /* Keeps a fixed or hugely-margined child from painting outside. */\n contain: layout paint;\n line-height: 1.5;\n }\n\n /*\n * Plain text keeps its line breaks. Only this form: applying pre-wrap to\n * html content would turn the newlines and indentation of the markup itself\n * into visible blank lines.\n */\n [part~='message-content'][data-content='text'] {\n white-space: pre-wrap;\n }\n\n [part~='message-content'] > :first-child {\n margin-top: 0;\n }\n [part~='message-content'] > :last-child {\n margin-bottom: 0;\n }\n\n /* Only direct children: a tooltip nested deeper still positions normally. */\n [part~='message-content'] > * {\n position: static !important;\n }\n\n [part~='message-content'] img,\n [part~='message-content'] video,\n [part~='message-content'] iframe,\n [part~='message-content'] svg,\n [part~='message-content'] canvas,\n [part~='message-content'] picture,\n [part~='message-content'] embed,\n [part~='message-content'] object {\n max-width: 100%;\n height: auto;\n display: block;\n }\n\n /* Wide content scrolls inside itself rather than stretching the bubble. */\n [part~='message-content'] table {\n display: block;\n max-width: 100%;\n overflow-x: auto;\n border-collapse: collapse;\n }\n\n [part~='message-content'] pre {\n max-width: 100%;\n overflow-x: auto;\n white-space: pre;\n }\n\n [part~='message-content'] code {\n overflow-wrap: anywhere;\n }\n\n [part~='message-content'] a {\n color: var(--chit-color-accent);\n }\n\n [part~='message-content'] button,\n [part~='message-content'] input,\n [part~='message-content'] select,\n [part~='message-content'] textarea {\n font: inherit;\n max-width: 100%;\n }\n\n [part~='message-content'] h1,\n [part~='message-content'] h2,\n [part~='message-content'] h3,\n [part~='message-content'] h4,\n [part~='message-content'] h5,\n [part~='message-content'] h6 {\n font-size: 1.1em;\n margin: 0.5em 0;\n }\n\n [part~='message-content'] p {\n margin: 0.5em 0;\n }\n\n [part~='message-content'] ul,\n [part~='message-content'] ol {\n margin: 0.5em 0;\n padding-inline-start: 1.5em;\n }\n\n [part~='message-content'] blockquote {\n margin: 0.5em 0;\n padding-inline-start: 0.75em;\n border-inline-start: 3px solid var(--chit-color-border);\n }\n\n [part~='message-content'] hr {\n border: 0;\n border-top: 1px solid var(--chit-color-border);\n }\n`;\n","// @ts-check\nimport { css } from 'lit';\n\nexport const composerStyles = css`\n [part~='composer'] {\n display: flex;\n flex: none;\n align-items: flex-end;\n gap: 0.5em;\n padding: 0.6em 0.75em;\n border-top: 1px solid var(--chit-color-border);\n background: var(--chit-color-input-bg);\n }\n\n [part~='input'] {\n flex: 1 1 auto;\n min-width: 0;\n /* One row to start with, growing to the theme's limit. */\n field-sizing: content;\n max-height: calc(1.5em * var(--_chit-input-max-rows, 5) + 1em);\n padding: 0.45em 0.6em;\n border: 1px solid var(--chit-color-border);\n border-radius: 12px;\n background: var(--chit-color-input-bg);\n color: var(--chit-color-input-text);\n font: inherit;\n line-height: 1.5;\n resize: none;\n overflow-y: auto;\n }\n\n /*\n * iOS Safari zooms the page in whenever a field smaller than 16px takes\n * focus, and it does not zoom back out when the field is done with — the\n * reader is left with a widget wider than the screen and no obvious way\n * back. Nothing in the page can undo that zoom short of pinning the\n * viewport's scale, which would also take pinch-zoom away from everyone.\n * So the field is kept at the size that never triggers it, and larger\n * still if the theme's font is larger.\n *\n * Coarse pointers only: on a desktop the same rule would make the field\n * stand out from the rest of the widget for no reason.\n */\n @media (pointer: coarse) {\n [part~='input'] {\n font-size: max(16px, 1em);\n }\n }\n\n [part~='input']::placeholder {\n color: var(--chit-color-input-placeholder);\n }\n\n [part~='input']:focus-visible {\n outline: 2px solid var(--chit-color-accent);\n outline-offset: -1px;\n }\n\n [part~='input']:disabled {\n opacity: 0.6;\n cursor: not-allowed;\n }\n\n [part~='counter'] {\n align-self: center;\n font-size: 0.75em;\n color: var(--chit-color-system-text);\n font-variant-numeric: tabular-nums;\n }\n\n [part~='counter'][data-over] {\n color: #d93025;\n font-weight: 600;\n }\n\n /* Out of sight, but still clickable from the button beside it. */\n [part~='attach-input'] {\n display: none;\n }\n\n [part~='attach-button'] {\n display: grid;\n flex: none;\n place-items: center;\n width: 2.4em;\n height: 2.4em;\n padding: 0;\n border: 0;\n border-radius: 50%;\n background: transparent;\n color: var(--chit-color-system-text);\n cursor: pointer;\n transition: opacity 120ms ease;\n }\n\n [part~='attach-button'] svg {\n width: 1.3em;\n height: 1.3em;\n }\n\n [part~='attach-button']:hover:not(:disabled) {\n background: color-mix(in srgb, currentColor 10%, transparent);\n }\n\n [part~='attach-button']:focus-visible {\n outline: 2px solid var(--chit-color-accent);\n outline-offset: 2px;\n }\n\n [part~='attach-button']:disabled {\n opacity: 0.4;\n cursor: default;\n }\n\n [part~='send-button'] {\n display: grid;\n flex: none;\n place-items: center;\n width: 2.4em;\n height: 2.4em;\n padding: 0;\n border: 0;\n border-radius: 50%;\n background: var(--chit-color-accent);\n color: #fff;\n cursor: pointer;\n transition: opacity 120ms ease;\n }\n\n [part~='send-button'] svg {\n width: 1.1em;\n height: 1.1em;\n }\n\n [part~='send-button']:disabled {\n opacity: 0.4;\n cursor: default;\n }\n\n [part~='send-button']:focus-visible {\n outline: 2px solid var(--chit-color-accent);\n outline-offset: 2px;\n }\n\n [part~='spinner'] {\n width: 1.1em;\n height: 1.1em;\n border: 2px solid currentColor;\n border-top-color: transparent;\n border-radius: 50%;\n animation: chit-spin 0.7s linear infinite;\n }\n\n @keyframes chit-spin {\n to {\n transform: rotate(360deg);\n }\n }\n\n @media (prefers-reduced-motion: reduce) {\n [part~='spinner'] {\n animation-duration: 2s;\n }\n }\n`;\n","// @ts-check\nimport { LitElement, html, nothing } from 'lit';\n\nimport { unsafeHTML } from 'lit/directives/unsafe-html.js';\n\nimport { StateController } from './controllers/state-controller.js';\nimport { BreakpointController } from './controllers/breakpoint-controller.js';\nimport { ThemeController } from './controllers/theme-controller.js';\nimport { ScrollController } from './controllers/scroll-controller.js';\nimport { ComposerController } from './controllers/composer-controller.js';\nimport { DragController } from './controllers/drag-controller.js';\nimport { ScrollLockController } from './controllers/scroll-lock-controller.js';\nimport { ViewportController } from './controllers/viewport-controller.js';\nimport { renderLauncher } from './render/launcher.js';\nimport { renderPanel } from './render/panel.js';\nimport { resolveLabels, resolveLocale } from './i18n/labels.js';\nimport { Events, emit } from './events.js';\nimport { componentInstance, contentKey, pruneComponents } from './render/content.js';\nimport { AdoptedSheet } from './styles/adopted-sheet.js';\nimport { hostStyles } from './styles/host.css.js';\nimport { launcherStyles } from './styles/launcher.css.js';\nimport { panelStyles } from './styles/panel.css.js';\nimport { messageStyles } from './styles/message.css.js';\nimport { contentStyles } from './styles/content.css.js';\nimport { composerStyles } from './styles/composer.css.js';\n\n/** @import { Message, Theme, ChatState, Trigger, Effect, Device, ResolvedTheme } from './types.js' */\n/** @import { Labels } from './i18n/labels.js' */\n\n/**\n * The chat widget.\n *\n * One custom element, one shadow root. Everything inside is drawn by plain\n * functions in `render/` and driven by the reactive controllers in\n * `controllers/`; no nested custom elements, so `::part()` and the theme's\n * custom properties reach every corner without being forwarded.\n *\n * @element chit-ui\n *\n * @slot launcher - Replaces the whole closed-state button content.\n * @slot header - Replaces the panel header.\n * @slot header-title - Replaces only the title area of the header.\n * @slot header-actions - Extra buttons beside the close button.\n * @slot footer - Below the composer (disclaimers, attribution).\n */\nexport class ChitUI extends LitElement {\n /** @override */\n static styles = [\n hostStyles,\n launcherStyles,\n panelStyles,\n messageStyles,\n contentStyles,\n composerStyles,\n ];\n\n /** @override */\n static properties = {\n state: { type: String, reflect: true, noAccessor: true },\n theme: { type: Object },\n messages: { type: Array },\n typing: { type: Object, noAccessor: true },\n loading: { type: Boolean, reflect: true, noAccessor: true },\n busy: { type: Boolean, reflect: true },\n inputDisabled: { type: Boolean, reflect: true, attribute: 'input-disabled' },\n inputHidden: { type: Boolean, reflect: true, attribute: 'input-hidden' },\n placeholder: { type: String, reflect: true },\n sendOnEnter: { type: Boolean, reflect: true, attribute: 'send-on-enter' },\n maxLength: { type: Number, reflect: true, attribute: 'max-length' },\n focusOnOpen: { type: String, reflect: true, attribute: 'focus-on-open' },\n locale: { type: String, reflect: true },\n labels: { type: Object },\n messageStyles: { type: String },\n };\n\n /** @type {ChatState} */\n #state = 'closed';\n\n /** @type {boolean | { html: string }} */\n #typing = false;\n\n /** @type {boolean} */\n #loading = false;\n\n /**\n * Set by the widget's own event handlers just before they move the state, so\n * the events can say the move came from a person rather than from code.\n *\n * @type {Trigger}\n */\n #trigger = 'api';\n\n /** @type {StateController} */\n #transitions;\n\n /** @type {BreakpointController} */\n #breakpoint;\n\n /** @type {ThemeController} */\n #themes;\n\n /** @type {ScrollController} */\n #scroll;\n\n /** @type {ComposerController} */\n #composer;\n\n /** Consumer CSS for the inside of message bubbles. */\n #messageSheet = new AdoptedSheet('data-chit-message-styles');\n\n /** What each message's content was built from last render, by id. */\n /** @type {Map<string, unknown>} */\n #renderedContent = new Map();\n\n /** The in-flight transition, so the methods can hand it back to the caller. */\n /** @type {Promise<boolean> | null} */\n #settled = null;\n\n constructor() {\n super();\n\n /** @type {Theme} Partial; unset keys fall back to the default theme. */\n this.theme = {};\n\n /** @type {Message[]} Rendered as given. The library never mutates this. */\n this.messages = [];\n\n /** @type {boolean} Lock the composer while a reply is in flight. */\n this.busy = false;\n\n /** @type {boolean} */\n this.inputDisabled = false;\n\n /** @type {boolean} */\n this.inputHidden = false;\n\n /** @type {string | undefined} */\n this.placeholder = undefined;\n\n /** @type {boolean} */\n this.sendOnEnter = true;\n\n /** @type {number | undefined} */\n this.maxLength = undefined;\n\n /**\n * Focus the composer once the open transition finishes. 'auto' focuses on\n * PC only, so a phone keyboard never pops up unasked.\n *\n * Named focusOnOpen rather than autofocus: HTMLElement.autofocus is a\n * standard boolean property and cannot carry a third value.\n *\n * @type {'auto' | 'always' | 'never'}\n */\n this.focusOnOpen = 'auto';\n\n /** @type {string | undefined} */\n this.locale = undefined;\n\n /** @type {Partial<Labels> | undefined} Overrides for the built-in UI strings. */\n this.labels = undefined;\n\n /** @type {string} Extra CSS applied inside message content. */\n this.messageStyles = '';\n\n /** @type {((html: string) => string) | undefined} Applied to `html` messages only. */\n this.sanitize = undefined;\n\n /** @type {((time: Date) => string) | undefined} */\n this.formatTime = undefined;\n\n this.#transitions = new StateController(this, {\n animation: (from, to, phase) => this.#animationFor(from, to, phase),\n keepsLauncher: () => this.currentTheme.open.launcher === 'visible',\n onOpened: () => this.#applyOpenFocus(),\n });\n\n this.#breakpoint = new BreakpointController(this);\n this.#themes = new ThemeController(this, { device: () => this.#breakpoint.device });\n this.addController(this.#themes);\n this.#scroll = new ScrollController(this, {\n behavior: () => this.currentTheme.open.animation.scroll,\n });\n this.#composer = new ComposerController(this);\n // Both register themselves with the host and need nothing from us\n // afterwards.\n new ScrollLockController(this);\n new ViewportController(this, { enabled: () => this.device === 'mobile' });\n\n this.#launcherDrag = new DragController(this, {\n name: 'launcher',\n enabled: () => this.currentTheme.closed.draggable,\n element: () => this.#part('launcher'),\n size: () => boxOf(this.#part('launcher')),\n corner: () => this.currentTheme.closed.position,\n base: () => this.currentTheme.closed.offset,\n current: () => this.#dragOffset,\n onMove: (displacement) => this.#moveTo(displacement),\n onSettle: (name) => this.#announceMove(name),\n vars: { x: '--chit-launcher-offset-x', y: '--chit-launcher-offset-y' },\n });\n\n this.#panelDrag = new DragController(this, {\n name: 'panel',\n // On a phone the panel is the whole screen; there is nowhere to move it.\n enabled: () => this.currentTheme.open.draggable && this.device === 'pc',\n element: () => this.#part('panel'),\n // What the theme asks for, capped by the window — never the measured\n // box, which shrinks as the panel is pushed towards its own corner.\n size: () => {\n const open = this.currentTheme.open;\n return {\n width: Math.min(open.width, window.innerWidth - 16),\n height: Math.min(open.height, window.innerHeight - 16),\n };\n },\n corner: () => this.currentTheme.open.position,\n base: () => this.currentTheme.open.offset,\n current: () => this.#dragOffset,\n onMove: (displacement) => this.#moveTo(displacement),\n onSettle: (name) => this.#announceMove(name),\n vars: { x: '--chit-panel-offset-x', y: '--chit-panel-offset-y' },\n });\n }\n\n /** @type {DragController} */\n #launcherDrag;\n\n /** @type {DragController} */\n #panelDrag;\n\n /**\n * @param {string} name\n * @returns {HTMLElement | null}\n */\n #part(name) {\n return /** @type {HTMLElement | null} */ (\n this.renderRoot?.querySelector(`[part~=\"${name}\"]`) ?? null\n );\n }\n\n /** The launcher's drag, for the render function to hook up. */\n get launcherDrag() {\n return this.#launcherDrag;\n }\n\n /** The panel's drag, likewise. */\n get panelDrag() {\n return this.#panelDrag;\n }\n\n /**\n * How far the reader has dragged the widget from where the theme put it, in\n * screen pixels, or null when it is still there.\n *\n * There is one of these for the whole widget rather than one per state: the\n * launcher and the panel are the same widget wearing two shapes, so moving\n * either moves both, and the panel opens where the launcher was left.\n *\n * @type {{ x: number, y: number } | null}\n */\n get dragOffset() {\n return this.#dragOffset;\n }\n\n set dragOffset(value) {\n this.#dragOffset = value ? { x: value.x, y: value.y } : null;\n this.#place();\n }\n\n /** Forget the dragged position and go back to what the theme says. */\n resetPosition() {\n this.dragOffset = null;\n }\n\n /** @type {{ x: number, y: number } | null} */\n #dragOffset = null;\n\n /**\n * @param {{ x: number, y: number }} displacement\n * @returns {void}\n */\n #moveTo(displacement) {\n this.#dragOffset = displacement;\n this.#place();\n }\n\n /** Put both shapes where the displacement says. */\n #place() {\n this.#launcherDrag.place(this.#dragOffset);\n this.#panelDrag.place(this.#dragOffset);\n }\n\n /**\n * @param {'launcher' | 'panel'} name\n * @returns {void}\n */\n #announceMove(name) {\n if (!this.#dragOffset) return;\n const theme = this.currentTheme;\n const side = name === 'launcher' ? theme.closed : theme.open;\n const drag = name === 'launcher' ? this.#launcherDrag : this.#panelDrag;\n emit(this, Events.MOVE, {\n target: name,\n position: side.position,\n // The thing that was dragged is on screen by definition, so `place`\n // gives the offset it actually landed on, clamp included.\n offset: drag.place(this.#dragOffset) ?? side.offset,\n displacement: { ...this.#dragOffset },\n });\n }\n\n /** @type {ReturnType<typeof setTimeout> | undefined} */\n #loadingTimer;\n\n /**\n * The ids present when the wait began. A reply is anything from the other\n * side that was not among them; the consumer's own echo of what the reader\n * just sent is not an answer and must not end the wait.\n *\n * @type {Set<string> | undefined}\n */\n #waitFrom;\n\n /**\n * The composer calls this once a submit has gone out and no listener\n * cancelled it. Listening for `chat-submit` here instead would be wrong:\n * this element's own listener runs before the consumer's, so it cannot see\n * a `preventDefault()` that is still to come.\n *\n * @returns {void}\n */\n handleSubmitted() {\n this.#startWaiting();\n }\n\n /** Begin the automatic wait, if the theme asked for one. */\n #startWaiting() {\n const loading = this.currentTheme.open.loading;\n if (!loading.auto) return;\n\n this.#waitFrom = new Set(this.messages.map((message) => message.id));\n this.loading = true;\n this.#clearLoadingTimer();\n if (loading.timeout > 0) {\n this.#loadingTimer = setTimeout(() => {\n this.#loadingTimer = undefined;\n this.#stopWaiting();\n }, loading.timeout);\n }\n }\n\n /** End it, however it ended. */\n #stopWaiting() {\n this.#clearLoadingTimer();\n this.#waitFrom = undefined;\n this.loading = false;\n }\n\n #clearLoadingTimer() {\n if (this.#loadingTimer !== undefined) clearTimeout(this.#loadingTimer);\n this.#loadingTimer = undefined;\n }\n\n /**\n * Show the \"typing\" bubble: `true`, or `{ html }` for your own markup.\n *\n * Turning this on turns `loading` off. The two describe the same pause in\n * the conversation — one says a person is writing, the other that a server\n * has not answered yet — and showing both would leave the reader to work\n * out the difference.\n *\n * @type {boolean | { html: string }}\n */\n get typing() {\n return this.#typing;\n }\n\n set typing(value) {\n const previous = this.#typing;\n if (value === previous) return;\n this.#typing = value;\n this.requestUpdate('typing', previous);\n if (value) this.loading = false;\n }\n\n /**\n * Show the \"waiting for an answer\" indicator. Turning this on turns\n * `typing` off, for the reason given above.\n *\n * @type {boolean}\n */\n get loading() {\n return this.#loading;\n }\n\n set loading(value) {\n const previous = this.#loading;\n if (value === previous) return;\n this.#loading = value;\n this.requestUpdate('loading', previous);\n if (value) this.typing = false;\n }\n\n /**\n * Current state. Assigning it starts the transition, exactly as calling the\n * matching method would.\n *\n * @type {ChatState}\n */\n get state() {\n return this.#state;\n }\n\n set state(value) {\n const previous = this.#state;\n if (value === previous) return;\n this.#state = value;\n this.requestUpdate('state', previous);\n\n // A transition the controller itself is applying (a revert, or the tail of\n // a method call) must not start another one.\n if (!this.#transitions || this.#transitions.applying) return;\n const trigger = this.#trigger;\n this.#trigger = 'api';\n\n const settled = this.#transitions.request(value, trigger);\n this.#settled = settled;\n void settled.then(() => {\n if (this.#settled === settled) this.#settled = null;\n });\n }\n\n /** @returns {Device} Which theme bucket the viewport currently falls in. */\n get device() {\n return this.#breakpoint.device;\n }\n\n /**\n * The theme in force for this device, every gap filled in.\n *\n * @returns {ResolvedTheme}\n */\n get currentTheme() {\n return this.#themes.current;\n }\n\n /** @returns {Labels} */\n get currentLabels() {\n return resolveLabels(this.locale, this.labels);\n }\n\n /**\n * The language in force: the `locale` property, else the document's.\n * Labels and timestamps both read it, so a page in Japanese does not end up\n * with Japanese buttons and American clock times.\n *\n * @returns {string | undefined}\n */\n get resolvedLocale() {\n return resolveLocale(this.locale);\n }\n\n /** @returns {ChatState} What the DOM is showing, which lags `state` while animating. */\n get renderedState() {\n return this.#transitions.renderedState;\n }\n\n /** @returns {boolean} True when messages arrived while the reader was scrolled up. */\n get hasUnseen() {\n return this.#scroll.hasUnseen;\n }\n\n /**\n * What is currently typed in the composer.\n *\n * Not a reactive property on purpose: a keystroke would otherwise re-render\n * the whole shadow tree, every message included.\n *\n * @type {string}\n */\n get value() {\n return this.#composer.value;\n }\n\n set value(next) {\n this.#composer.value = next;\n }\n\n /** @returns {boolean} Whether what is typed could be sent right now. */\n get canSend() {\n return this.#composer.canSend;\n }\n\n // --- public API -------------------------------------------------------\n\n /** @returns {Promise<boolean>} Resolves once the open animation has finished. */\n open() {\n return this.#go('open', 'api');\n }\n\n /** @returns {Promise<boolean>} */\n close() {\n return this.#go('closed', 'api');\n }\n\n /** @returns {Promise<boolean>} */\n hide() {\n return this.#go('hidden', 'api');\n }\n\n /** @returns {Promise<boolean>} From `hidden` back to the launcher. A no-op otherwise. */\n show() {\n return this.#state === 'hidden' ? this.#go('closed', 'api') : Promise.resolve(true);\n }\n\n /** @returns {Promise<boolean>} */\n toggle() {\n return this.#go(this.state === 'open' ? 'closed' : 'open', 'api');\n }\n\n /**\n * Send what is in the composer, or the given text, as `chat-submit`.\n *\n * Adding the message to `messages` stays the consumer's job; the widget only\n * reports that someone pressed send.\n *\n * @param {string} [text]\n * @returns {boolean} False when there was nothing to send.\n */\n submit(text) {\n return this.#composer.submit(text);\n }\n\n /** Empty the composer and put the caret back in it. */\n clearInput() {\n this.#composer.clear();\n }\n\n /**\n * Scroll the conversation to the newest message.\n *\n * @param {{ smooth?: boolean }} [options]\n */\n scrollToBottom(options) {\n this.#scroll.scrollToBottom(options);\n }\n\n /**\n * The content container of one message, once it has been drawn.\n *\n * @param {string} id\n * @returns {HTMLElement | null}\n */\n getMessageElement(id) {\n return /** @type {HTMLElement | null} */ (\n this.renderRoot.querySelector(`[part~=\"message\"][data-id=\"${CSS.escape(id)}\"] [part~=\"message-content\"]`)\n );\n }\n\n /**\n * Put the caret in the composer.\n *\n * This obeys the caller, not `focusOnOpen`: someone who calls it has asked\n * for focus. `focusOnOpen` only governs what happens by itself on open.\n *\n * @returns {boolean} False when there is no composer to focus.\n */\n focusInput() {\n const input = /** @type {HTMLElement | null} */ (\n this.renderRoot.querySelector('[part~=\"input\"]')\n );\n if (!input) return false;\n input.focus();\n return true;\n }\n\n /**\n * What the widget does with focus when the panel finishes opening.\n *\n * 'never' means exactly that: focus is left wherever the person had it, so a\n * widget that opens on its own does not steal the caret out of a form on the\n * page. Otherwise the composer takes it, or the panel does when there is no\n * composer, so that Esc and screen-reader navigation start inside the dialog.\n */\n #applyOpenFocus() {\n if (this.focusOnOpen === 'never') return;\n if (this.focusOnOpen === 'auto' && this.device === 'mobile') return;\n if (this.focusInput()) return;\n\n const panel = /** @type {HTMLElement | null} */ (\n this.renderRoot.querySelector('[part~=\"panel\"]')\n );\n panel?.focus();\n }\n\n // --- composer plumbing, called by the render functions ------------------\n\n /** @param {Event} event */\n handleInput(event) {\n this.#composer.onInput(event);\n }\n\n /** @param {KeyboardEvent} event */\n handleKeydown(event) {\n this.#composer.onKeydown(event);\n }\n\n /** @param {boolean} started */\n handleComposition(started) {\n if (started) this.#composer.onCompositionStart();\n else this.#composer.onCompositionEnd();\n }\n\n /**\n * Report files the reader picked with the attach button.\n *\n * Nothing is uploaded, previewed or added to the conversation here: the\n * widget does not own `messages` and has nowhere to send bytes.\n *\n * @param {File[]} files\n * @returns {void}\n */\n handleAttach(files) {\n emit(this, Events.ATTACH, { files });\n }\n\n /** Open the file picker from code, as the attach button does. */\n openAttach() {\n const field = /** @type {HTMLInputElement | null} */ (\n this.renderRoot.querySelector('[part~=\"attach-input\"]')\n );\n field?.click();\n }\n\n // --- internal ---------------------------------------------------------\n\n /**\n * Render a consumer-supplied typing bubble.\n *\n * @param {string} markup\n * @returns {unknown}\n */\n renderTypingHtml(markup) {\n return unsafeHTML(this.sanitize ? this.sanitize(markup) : markup);\n }\n\n /**\n * Re-publish a click inside a message as `chat-message-click`.\n *\n * `composedPath()[0]` rather than `event.target`: the target is retargeted to\n * the message container once the event leaves a component's shadow root, and\n * the consumer wants the element actually clicked.\n *\n * @param {MouseEvent} event\n */\n handleMessageClick(event) {\n const path = event.composedPath();\n const article = /** @type {HTMLElement | undefined} */ (\n path.find(\n (node) =>\n node instanceof HTMLElement && node.getAttribute('part')?.split(/\\s+/).includes('message'),\n )\n );\n if (!article) return;\n\n const id = article.dataset.id;\n const message = this.messages.find((candidate) => candidate.id === id);\n if (!message) return;\n\n const target = /** @type {Element} */ (path[0]);\n const allowed = emit(\n this,\n Events.MESSAGE_CLICK,\n { message, target, originalEvent: event },\n { cancelable: true },\n );\n if (!allowed) event.preventDefault();\n }\n\n /** Called by the launcher; the resulting events report `trigger: 'user'`. */\n toggleFromUser() {\n return this.#go(this.state === 'open' ? 'closed' : 'open', 'user');\n }\n\n /** Called by the close button and by Esc. */\n closeFromUser() {\n return this.#go('closed', 'user');\n }\n\n /**\n * Ask to start the conversation over.\n *\n * The widget only announces it: `messages` belongs to the consumer, so\n * clearing it, replaying a scenario or asking for confirmation first are all\n * theirs to do. Cancelling the event is not offered for the same reason —\n * there is nothing here to cancel.\n *\n * @param {Trigger} [trigger='api']\n * @returns {void}\n */\n home(trigger = 'api') {\n emit(this, Events.HOME, { trigger });\n }\n\n /**\n * @param {ChatState} to\n * @param {Trigger} trigger\n * @returns {Promise<boolean>}\n */\n #go(to, trigger) {\n if (to !== this.#state) {\n this.#trigger = trigger;\n this.state = to;\n }\n return this.#settled ?? Promise.resolve(true);\n }\n\n /**\n * Which effect and how long, for one leg of a transition.\n *\n * Leaving for `hidden` uses the hidden theme's exit; every other leg uses the\n * theme of the state being left or entered.\n *\n * @param {ChatState} from\n * @param {ChatState} to\n * @param {'enter' | 'exit'} phase\n * @returns {{ effect: Effect, duration: number }}\n */\n #animationFor(from, to, phase) {\n const theme = this.currentTheme;\n\n if (phase === 'exit' && to === 'hidden') {\n return { effect: theme.hidden.animation.exit, duration: theme.hidden.animation.duration };\n }\n\n const source = (phase === 'exit' ? from : to) === 'open' ? theme.open : theme.closed;\n return {\n effect: phase === 'exit' ? source.animation.exit : source.animation.enter,\n duration: source.animation.duration,\n };\n }\n\n /** @override */\n willUpdate() {\n // Order matters: the breakpoint decides the device, and the device decides\n // which `closed` settings the theme resolves to.\n this.#breakpoint.observe(ThemeController.breakpointOf(this.theme));\n this.#themes.apply(this.theme, this.#breakpoint.device);\n\n this.#messageSheet.write(this.messageStyles ?? '', this.renderRoot);\n\n const theme = this.currentTheme;\n this.dataset.launcherPosition = theme.closed.position;\n this.dataset.panelPosition = theme.open.position;\n this.dataset.idle = theme.closed.animation.idle;\n this.dataset.bubbleTail = theme.open.bubble.tail;\n }\n\n /** @override */\n updated() {\n const live = new Set(this.messages.map((message) => message.id));\n pruneComponents(this, live);\n this.#announceRenders(live);\n\n // An answer has arrived when a message from the other side appears that\n // was not there when the wait began.\n // The shape on screen has just changed, so whatever is there now needs to\n // be put where the drag left the widget — and clamped to today's window.\n if (this.#dragOffset) this.#place();\n\n if (this.#waitFrom) {\n const answered = this.messages.some(\n (message) =>\n message.role !== 'user' && !(/** @type {Set<string>} */ (this.#waitFrom).has(message.id)),\n );\n if (answered) this.#stopWaiting();\n }\n }\n\n /** @override */\n disconnectedCallback() {\n super.disconnectedCallback();\n this.#clearLoadingTimer();\n }\n\n /**\n * Fire `chat-message-render` for messages that were drawn for the first time\n * or whose content changed.\n *\n * Only the content matters here: a status or streaming flag flipping redraws\n * the bubble but leaves the consumer's markup alone, and firing then would\n * make listeners re-bind on every token of a streamed reply.\n *\n * @param {Set<string>} live\n */\n #announceRenders(live) {\n for (const id of this.#renderedContent.keys()) {\n if (!live.has(id)) this.#renderedContent.delete(id);\n }\n\n for (const message of this.messages) {\n const key = contentKey(message);\n if (this.#renderedContent.has(message.id) && Object.is(this.#renderedContent.get(message.id), key)) {\n continue;\n }\n this.#renderedContent.set(message.id, key);\n\n const element = this.getMessageElement(message.id);\n if (!element) continue;\n emit(this, Events.MESSAGE_RENDER, {\n message,\n element,\n instance: componentInstance(this, message.id),\n });\n }\n }\n\n /** @override */\n render() {\n const shown = this.renderedState;\n const showLauncher =\n shown === 'closed' || (shown === 'open' && this.currentTheme.open.launcher === 'visible');\n const showPanel = shown === 'open';\n\n return html`\n ${showLauncher ? renderLauncher(this) : nothing} ${showPanel ? renderPanel(this) : nothing}\n `;\n }\n}\n\n/**\n * The size of something on screen, or nothing at all when it is not there.\n *\n * @param {HTMLElement | null} element\n * @returns {{ width: number, height: number }}\n */\nfunction boxOf(element) {\n if (!element) return { width: 0, height: 0 };\n const box = element.getBoundingClientRect();\n return { width: box.width, height: box.height };\n}\n","// @ts-check\nimport { ChitUI } from './chit-ui.js';\n\nif (!customElements.get('chit-ui')) {\n customElements.define('chit-ui', ChitUI);\n}\n\nexport { ChitUI };\nexport { Events } from './events.js';\n\n/**\n * The public types, re-exported so a consumer can write\n * `import type { Message } from '@hidemikimura/chit-ui'` instead of reaching\n * into `dist/types/` for them.\n *\n * @typedef {import('./types.js').Role} Role\n * @typedef {import('./types.js').MessageStatus} MessageStatus\n * @typedef {import('./types.js').ChatState} ChatState\n * @typedef {import('./types.js').Trigger} Trigger\n * @typedef {import('./types.js').Device} Device\n * @typedef {import('./types.js').Effect} Effect\n * @typedef {import('./types.js').Position} Position\n * @typedef {import('./types.js').BubbleTail} BubbleTail\n * @typedef {import('./types.js').LoadingStyle} LoadingStyle\n * @typedef {import('./types.js').MessageBase} MessageBase\n * @typedef {import('./types.js').TextMessage} TextMessage\n * @typedef {import('./types.js').HtmlMessage} HtmlMessage\n * @typedef {import('./types.js').TemplateMessage} TemplateMessage\n * @typedef {import('./types.js').ElementMessage} ElementMessage\n * @typedef {import('./types.js').ComponentMessage} ComponentMessage\n * @typedef {import('./types.js').Message} Message\n * @typedef {import('./types.js').Animation} Animation\n * @typedef {import('./types.js').Offset} Offset\n * @typedef {import('./types.js').ClosedTheme} ClosedTheme\n * @typedef {import('./types.js').OpenColors} OpenColors\n * @typedef {import('./types.js').SpeakerTheme} SpeakerTheme\n * @typedef {import('./types.js').LoadingTheme} LoadingTheme\n * @typedef {import('./types.js').OpenTheme} OpenTheme\n * @typedef {import('./types.js').Theme} Theme\n * @typedef {import('./types.js').ResolvedClosed} ResolvedClosed\n * @typedef {import('./types.js').ResolvedOpen} ResolvedOpen\n * @typedef {import('./types.js').ResolvedTheme} ResolvedTheme\n */\n","// @ts-check\n\n/** @import { Theme } from '../types.js' */\n\n/**\n * A green messenger look: a pale blue-grey conversation background, white\n * bubbles for them, bright green for you, tails on the top corner.\n *\n * This is Chit UI's own palette in that familiar shape. It carries no other\n * product's logo, wordmark or artwork, and the greens are Chit UI's own: the\n * deep green is dark enough that white text and the send icon clear WCAG AA\n * on it, which the bright green of the bubbles could not do.\n * `test/theme.test.js` re-checks every pair here, so a later tweak cannot\n * quietly drop below AA.\n *\n * @type {Theme}\n */\nexport const greenTheme = {\n closed: {\n colors: {\n background: '#0a6b36',\n text: '#ffffff',\n shadow: '0 4px 12px rgba(16, 42, 26, 0.32)',\n },\n },\n open: {\n radius: 12,\n colors: {\n background: '#d3ddea',\n text: '#16212c',\n accent: '#0a6b36',\n border: '#b6c5d6',\n shadow: '0 8px 32px rgba(16, 32, 48, 0.28)',\n headerBackground: '#ffffff',\n headerText: '#16212c',\n userBubble: '#9ce26c',\n userText: '#14240c',\n assistantBubble: '#ffffff',\n assistantText: '#16212c',\n systemText: '#37475a',\n inputBackground: '#ffffff',\n inputText: '#16212c',\n inputPlaceholder: '#5c6370',\n },\n bubble: { radius: 18, tail: 'top' },\n },\n};\n","import{noChange as t}from\"../lit-html.js\";import{directive as s,Directive as i,PartType as r}from\"../directive.js\";\n/**\n * @license\n * Copyright 2018 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */const e=s(class extends i{constructor(t){if(super(t),t.type!==r.ATTRIBUTE||\"class\"!==t.name||t.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 t}});export{e as classMap};\n//# sourceMappingURL=class-map.js.map\n","import{noChange as t}from\"../lit-html.js\";import{directive as e,Directive as r,PartType as s}from\"../directive.js\";\n/**\n * @license\n * Copyright 2018 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */const n=\"important\",i=\" !\"+n,o=e(class extends r{constructor(t){if(super(t),t.type!==s.ATTRIBUTE||\"style\"!==t.name||t.strings?.length>2)throw Error(\"The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute.\")}render(t){return Object.keys(t).reduce((e,r)=>{const s=t[r];return null==s?e:e+`${r=r.includes(\"-\")?r:r.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,\"-$&\").toLowerCase()}:${s};`},\"\")}update(e,[r]){const{style:s}=e.element;if(void 0===this.ft)return this.ft=new Set(Object.keys(r)),this.render(r);for(const t of this.ft)null==r[t]&&(this.ft.delete(t),t.includes(\"-\")?s.removeProperty(t):s[t]=null);for(const t in r){const e=r[t];if(null!=e){this.ft.add(t);const r=\"string\"==typeof e&&e.endsWith(i);t.includes(\"-\")||r?s.setProperty(t,r?e.slice(0,-11):e,r?n:\"\"):s[t]=e}}return t}});export{o as styleMap};\n//# sourceMappingURL=style-map.js.map\n"],"names":["t","globalThis","e","ShadowRoot","ShadyCSS","nativeShadow","Document","prototype","CSSStyleSheet","s","Symbol","o","WeakMap","n$3","constructor","this","_$cssResult$","Error","cssText","styleSheet","length","get","replaceSync","set","toString","i","reduce","n","c","cssRules","r","is","defineProperty","getOwnPropertyDescriptor","h","getOwnPropertyNames","getOwnPropertySymbols","getPrototypeOf","Object","a","trustedTypes","l","emptyScript","p","reactiveElementPolyfillSupport","d","u","toAttribute","Boolean","Array","JSON","stringify","fromAttribute","Number","parse","f","b","attribute","type","String","converter","reflect","useDefault","hasChanged","metadata","litPropertyMetadata","y$1","HTMLElement","addInitializer","_$Ei","push","observedAttributes","finalize","_$Eh","keys","createProperty","state","hasOwnProperty","create","wrapped","elementProperties","noAccessor","getPropertyDescriptor","call","requestUpdate","configurable","enumerable","getPropertyOptions","Map","finalized","properties","_$Eu","elementStyles","finalizeStyles","styles","isArray","Set","flat","reverse","unshift","toLowerCase","super","_$Ep","isUpdatePending","hasUpdated","_$Em","_$Ev","_$ES","Promise","enableUpdating","_$AL","_$E_","forEach","addController","_$EO","add","renderRoot","isConnected","hostConnected","removeController","delete","size","createRenderRoot","shadowRoot","attachShadow","shadowRootOptions","adoptedStyleSheets","map","document","createElement","litNonce","setAttribute","textContent","appendChild","connectedCallback","disconnectedCallback","hostDisconnected","attributeChangedCallback","_$AK","_$ET","removeAttribute","_$Ej","hasAttribute","C","_$EP","has","_$Eq","reject","scheduleUpdate","performUpdate","shouldUpdate","willUpdate","hostUpdate","update","_$EM","_$AE","hostUpdated","firstUpdated","updated","updateComplete","getUpdateComplete","y","mode","ReactiveElement","reactiveElementVersions","createPolicy","createHTML","Math","random","toFixed","slice","createComment","v","_","m","RegExp","g","$","x","_$litType$","strings","values","w","E","for","A","P","createTreeWalker","V","S","parts","lastIndex","exec","test","startsWith","N","el","currentNode","content","firstChild","replaceWith","childNodes","nextNode","nodeType","hasAttributes","getAttributeNames","endsWith","getAttribute","split","index","name","ctor","I","L","z","H","tagName","append","data","indexOf","innerHTML","M","_$Co","_$Cl","_$litDirective$","_$AO","_$AT","_$AS","R","_$AV","_$AN","_$AD","_$AM","parentNode","_$AU","creationScope","importNode","k","nextSibling","Z","_$AI","_$Cv","_$AH","_$AA","_$AB","options","startNode","endNode","_$AR","T","iterator","O","insertBefore","createTextNode","_$AC","_$AP","remove","setConnected","element","fill","j","arguments","toggleAttribute","capture","once","passive","removeEventListener","addEventListener","handleEvent","host","B","litHtmlPolyfillSupport","litHtmlVersions","D","renderBefore","_$litPart$","renderOptions","_$Do","render","_$litElement$","litElementHydrateSupport","LitElement","litElementPolyfillSupport","litElementVersions","i$2","_$Ct","_$Ci","e$1","it","directiveName","_t","raw","resultType","Events","freeze","SUBMIT","BEFORE_OPEN","OPEN","BEFORE_CLOSE","CLOSE","HIDE","SHOW","STATE_CHANGE","INPUT","MESSAGE_RENDER","MESSAGE_CLICK","SCROLL_TOP","BREAKPOINT_CHANGE","HOME","ATTACH","MOVE","emit","detail","cancelable","dispatchEvent","CustomEvent","bubbles","composed","PART_FOR_STATE","closed","open","hidden","StateController","resolveAnimation","keepsLauncher","onOpened","current","rendered","applying","generation","settle","stopWaiting","restoreFocusToLauncher","animation","renderedState","dataset","request","to","trigger","from","resolve","announceIntent","interrupt","assign","run","settled","focusIsInsidePanel","leaving","elementFor","launcherSurvives","animate","arriving","announceArrival","manageFocus","focus","active","activeElement","panel","contains","part","querySelector","phase","spec","effect","duration","window","matchMedia","matches","finished","finish","event","target","clearTimeout","timer","style","removeProperty","anim","setProperty","setTimeout","BreakpointController","query","breakpoint","device","measured","onChange","observe","apply","PALETTE","CLOSED_PC","position","offset","radius","draggable","image","label","component","props","colors","background","text","shadow","enter","exit","idle","CLOSED_MOBILE_DIFF","defaultTheme","zIndex","font","family","pc","mobile","width","height","launcher","header","visible","title","logo","home","accent","border","headerBackground","headerText","userBubble","userText","assistantBubble","assistantText","systemText","inputBackground","inputText","inputPlaceholder","bubble","tail","loading","auto","timeout","speaker","assistant","avatar","user","scroll","input","maxRows","placeholder","attach","accept","multiple","mobileClosedDefaults","isPlainObject","value","mergeTheme","base","override","out","key","entries","undefined","resolveTheme","theme","perDevice","shared","resolveClosed","px","url","replace","themeToCss","declarations","themeToVariables","join","SUPPORTS_ADOPTING","AdoptedSheet","sheet","written","marker","root","includes","write","css","detach","ThemeController","resolved","breakpointOf","ScrollController","preferredBehavior","viewport","resize","atBottom","hasUnseen","atTop","followAfterRender","selfScrolling","selfScrollTimer","openingJump","viewportHeight","lastId","lastCount","behavior","unbind","messages","last","grew","newTail","id","role","bind","followBehavior","scrollNow","clientHeight","onScroll","onScrollEnd","inner","firstElementChild","ResizeObserver","disconnect","endSelfScroll","scrollHeight","scrollTop","scrollToBottom","smooth","beginSelfScroll","scrollTo","top","distance","SUPPORTS_FIELD_SIZING","CSS","supports","ComposerController","composing","justComposed","composedTimer","next","grow","syncDerived","canSend","busy","inputDisabled","trim","limit","maxLength","onInput","onCompositionStart","onCompositionEnd","onKeydown","sendOnEnter","shiftKey","altKey","ctrlKey","metaKey","isComposing","keyCode","preventDefault","submit","clear","handleSubmitted","send","disabled","counter","remaining","over","labels","currentLabels","template","overLimit","charactersLeft","abs","DragController","dragged","onResize","now","onMove","consumeDrag","place","displacement","vars","toOffset","placed","clamp","start","enabled","button","pointer","clientX","clientY","corner","moved","pointerId","setPointerCapture","onPointerMove","onPointerEnd","dx","dy","hypot","hasPointerCapture","releasePointerCapture","onSettle","nudge","direction","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","step","innerWidth","innerHeight","max","round","min","SCROLLABLE","ScrollLockController","touch","onStart","onEnd","touches","verdict","vertical","allowed","canScroll","delta","node","composedPath","hasRoom","getComputedStyle","overflow","overflowY","overflowX","scrollLeft","clientWidth","scrollWidth","ViewportController","applied","visualViewport","scale","offsetTop","INSTANCES","messageKey","CONTENT_FIELDS","contentField","message","present","filter","field","contentKey","resolveComponent","source","cache","existing","registry","registered","getName","declared","tagNameOf","componentInstance","renderContent","carrier","html","unsafeHTML","sanitize","renderLauncher","currentTheme","custom","launcherDrag","toggleFromUser","nothing","defaultIcon","defaultContent","_$AQ","dt","ut","renderMessage","meta","time","status","streaming","date","Date","isNaN","getTime","formatTime","Intl","DateTimeFormat","resolvedLocale","hour","minute","format","renderMessageList","typing","empty","conversation","handleMessageClick","repeat","renderLoading","renderTypingHtml","toLatest","renderComposer","inputHidden","openAttach","files","handleAttach","renderAttach","live","handleInput","handleKeydown","handleComposition","renderPanel","defaultPrevented","closeFromUser","move","closest","panelDrag","currentTarget","close","renderHeader","BUILT_IN","ja","sending","sent","error","en","resolveLocale","locale","documentElement","lang","hostStyles","launcherStyles","panelStyles","messageStyles","contentStyles","composerStyles","ChitUI","static","focusOnOpen","transitions","themes","composer","messageSheet","renderedContent","animationFor","applyOpenFocus","box","getBoundingClientRect","boxOf","dragOffset","moveTo","announceMove","resetPosition","side","drag","loadingTimer","waitFrom","startWaiting","clearLoadingTimer","previous","then","overrides","resolveLabels","go","hide","show","toggle","clearInput","getMessageElement","escape","focusInput","started","click","markup","path","article","find","candidate","originalEvent","launcherPosition","panelPosition","bubbleTail","liveIds","pruneComponents","announceRenders","some","instance","shown","showLauncher","showPanel","customElements","define","greenTheme","st","nt","classList","ft"],"mappings":"AAKA,MAAMA,EAAEC,WAAWC,EAAEF,EAAEG,kBAAa,IAASH,EAAEI,UAAUJ,EAAEI,S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