@hidemikimura/chit-ui 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +440 -0
- package/dist/chit-ui.iife.min.js +964 -0
- package/dist/chit-ui.iife.min.js.map +1 -0
- package/dist/chit-ui.min.js +964 -0
- package/dist/chit-ui.min.js.map +1 -0
- package/dist/types/bundle.d.ts +7 -0
- package/dist/types/chit-ui.d.ts +251 -0
- package/dist/types/controllers/breakpoint-controller.d.ts +29 -0
- package/dist/types/controllers/composer-controller.d.ts +54 -0
- package/dist/types/controllers/scroll-controller.d.ts +44 -0
- package/dist/types/controllers/state-controller.d.ts +61 -0
- package/dist/types/controllers/theme-controller.d.ts +47 -0
- package/dist/types/element.d.ts +1 -0
- package/dist/types/events.d.ts +28 -0
- package/dist/types/global.d.ts +25 -0
- package/dist/types/i18n/labels.d.ts +68 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/render/composer.d.ts +15 -0
- package/dist/types/render/content.d.ts +75 -0
- package/dist/types/render/launcher.d.ts +18 -0
- package/dist/types/render/message-list.d.ts +17 -0
- package/dist/types/render/message.d.ts +14 -0
- package/dist/types/render/panel.d.ts +10 -0
- package/dist/types/styles/adopted-sheet.d.ts +20 -0
- package/dist/types/styles/composer.css.d.ts +1 -0
- package/dist/types/styles/content.css.d.ts +9 -0
- package/dist/types/styles/host.css.d.ts +9 -0
- package/dist/types/styles/launcher.css.d.ts +1 -0
- package/dist/types/styles/message.css.d.ts +1 -0
- package/dist/types/styles/panel.css.d.ts +1 -0
- package/dist/types/theme/default-theme.d.ts +97 -0
- package/dist/types/theme/merge-theme.d.ts +33 -0
- package/dist/types/theme/theme-to-css.d.ts +24 -0
- package/dist/types/types.d.ts +268 -0
- package/package.json +71 -0
- package/src/bundle.js +11 -0
- package/src/chit-ui.js +548 -0
- package/src/controllers/breakpoint-controller.js +82 -0
- package/src/controllers/composer-controller.js +215 -0
- package/src/controllers/scroll-controller.js +252 -0
- package/src/controllers/state-controller.js +316 -0
- package/src/controllers/theme-controller.js +75 -0
- package/src/element.js +4 -0
- package/src/events.js +33 -0
- package/src/global.d.ts +25 -0
- package/src/i18n/labels.js +72 -0
- package/src/index.js +9 -0
- package/src/render/composer.js +72 -0
- package/src/render/content.js +211 -0
- package/src/render/launcher.js +64 -0
- package/src/render/message-list.js +67 -0
- package/src/render/message.js +82 -0
- package/src/render/panel.js +77 -0
- package/src/styles/adopted-sheet.js +72 -0
- package/src/styles/composer.css.js +108 -0
- package/src/styles/content.css.js +119 -0
- package/src/styles/host.css.js +160 -0
- package/src/styles/launcher.css.js +139 -0
- package/src/styles/message.css.js +192 -0
- package/src/styles/panel.css.js +126 -0
- package/src/theme/default-theme.js +111 -0
- package/src/theme/merge-theme.js +100 -0
- package/src/theme/theme-to-css.js +94 -0
- package/src/types.js +143 -0
|
@@ -0,0 +1,964 @@
|
|
|
1
|
+
const t=globalThis,e=t.ShadowRoot&&(void 0===t.ShadyCSS||t.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,s=Symbol(),i=new WeakMap;let n=class{constructor(t,e,i){if(this._$cssResult$=!0,i!==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=i.get(s)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),e&&i.set(s,t))}return t}toString(){return this.cssText}};const o=(t,...e)=>{const i=1===t.length?t[0]:e.reduce((e,s,i)=>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[i+1],t[0]);return new n(i,t,s)},r=e?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const s of t.cssRules)e+=s.cssText;return(t=>new n("string"==typeof t?t:t+"",void 0,s))(e)})(t):t,{is:a,defineProperty:h,getOwnPropertyDescriptor:l,getOwnPropertyNames:c,getOwnPropertySymbols:d,getPrototypeOf:p}=Object,u=globalThis,m=u.trustedTypes,f=m?m.emptyScript:"",g=u.reactiveElementPolyfillSupport,b=(t,e)=>t,v={toAttribute(t,e){switch(e){case Boolean:t=t?f:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){let s=t;switch(e){case Boolean:s=null!==t;break;case Number:s=null===t?null:Number(t);break;case Object:case Array:try{s=JSON.parse(t)}catch(t){s=null}}return s}},y=(t,e)=>!a(t,e),$={attribute:!0,type:String,converter:v,reflect:!1,useDefault:!1,hasChanged:y};Symbol.metadata??=Symbol("metadata"),u.litPropertyMetadata??=new WeakMap;let w=class 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,e=$){if(e.state&&(e.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(t)&&((e=Object.create(e)).wrapped=!0),this.elementProperties.set(t,e),!e.noAccessor){const s=Symbol(),i=this.getPropertyDescriptor(t,s,e);void 0!==i&&h(this.prototype,t,i)}}static getPropertyDescriptor(t,e,s){const{get:i,set:n}=l(this.prototype,t)??{get(){return this[e]},set(t){this[e]=t}};return{get:i,set(e){const o=i?.call(this);n?.call(this,e),this.requestUpdate(t,o,s)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??$}static _$Ei(){if(this.hasOwnProperty(b("elementProperties")))return;const t=p(this);t.finalize(),void 0!==t.l&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(b("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(b("properties"))){const t=this.properties,e=[...c(t),...d(t)];for(const s of e)this.createProperty(s,t[s])}const t=this[Symbol.metadata];if(null!==t){const e=litPropertyMetadata.get(t);if(void 0!==e)for(const[t,s]of e)this.elementProperties.set(t,s)}this._$Eh=new Map;for(const[t,e]of this.elementProperties){const s=this._$Eu(t,e);void 0!==s&&this._$Eh.set(s,t)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const s=new Set(t.flat(1/0).reverse());for(const t of s)e.unshift(r(t))}else void 0!==t&&e.push(r(t));return e}static _$Eu(t,e){const s=e.attribute;return!1===s?void 0:"string"==typeof s?s:"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,e=this.constructor.elementProperties;for(const s of e.keys())this.hasOwnProperty(s)&&(t.set(s,this[s]),delete this[s]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const s=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return((s,i)=>{if(e)s.adoptedStyleSheets=i.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet);else for(const e of i){const i=document.createElement("style"),n=t.litNonce;void 0!==n&&i.setAttribute("nonce",n),i.textContent=e.cssText,s.appendChild(i)}})(s,this.constructor.elementStyles),s}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,e,s){this._$AK(t,s)}_$ET(t,e){const s=this.constructor.elementProperties.get(t),i=this.constructor._$Eu(t,s);if(void 0!==i&&!0===s.reflect){const n=(void 0!==s.converter?.toAttribute?s.converter:v).toAttribute(e,s.type);this._$Em=t,null==n?this.removeAttribute(i):this.setAttribute(i,n),this._$Em=null}}_$AK(t,e){const s=this.constructor,i=s._$Eh.get(t);if(void 0!==i&&this._$Em!==i){const t=s.getPropertyOptions(i),n="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==t.converter?.fromAttribute?t.converter:v;this._$Em=i;const o=n.fromAttribute(e,t.type);this[i]=o??this._$Ej?.get(i)??o,this._$Em=null}}requestUpdate(t,e,s,i=!1,n){if(void 0!==t){const o=this.constructor;if(!1===i&&(n=this[t]),s??=o.getPropertyOptions(t),!((s.hasChanged??y)(n,e)||s.useDefault&&s.reflect&&n===this._$Ej?.get(t)&&!this.hasAttribute(o._$Eu(t,s))))return;this.C(t,e,s)}!1===this.isUpdatePending&&(this._$ES=this._$EP())}C(t,e,{useDefault:s,reflect:i,wrapped:n},o){s&&!(this._$Ej??=new Map).has(t)&&(this._$Ej.set(t,o??e??this[t]),!0!==n||void 0!==o)||(this._$AL.has(t)||(this.hasUpdated||s||(e=void 0),this._$AL.set(t,e)),!0===i&&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,e]of this._$Ep)this[t]=e;this._$Ep=void 0}const t=this.constructor.elementProperties;if(t.size>0)for(const[e,s]of t){const{wrapped:t}=s,i=this[e];!0!==t||this._$AL.has(e)||void 0===i||this.C(e,void 0,s,i)}}let t=!1;const e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),this._$EO?.forEach(t=>t.hostUpdate?.()),this.update(e)):this._$EM()}catch(e){throw t=!1,this._$EM(),e}t&&this._$AE(e)}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){}};w.elementStyles=[],w.shadowRootOptions={mode:"open"},w[b("elementProperties")]=new Map,w[b("finalized")]=new Map,g?.({ReactiveElement:w}),(u.reactiveElementVersions??=[]).push("2.1.2");const x=globalThis,_=t=>t,S=x.trustedTypes,A=S?S.createPolicy("lit-html",{createHTML:t=>t}):void 0,E="$lit$",C=`lit$${Math.random().toFixed(9).slice(2)}$`,k="?"+C,T=`<${k}>`,O=document,U=()=>O.createComment(""),P=t=>null===t||"object"!=typeof t&&"function"!=typeof t,L=Array.isArray,R="[ \t\n\f\r]",z=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,M=/-->/g,N=/>/g,H=RegExp(`>|${R}(?:([^\\s"'>=/]+)(${R}*=${R}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),B=/'/g,I=/"/g,j=/^(?:script|style|textarea|title)$/i,D=t=>(e,...s)=>({_$litType$:t,strings:e,values:s}),q=D(1),F=D(2),W=Symbol.for("lit-noChange"),K=Symbol.for("lit-nothing"),G=new WeakMap,J=O.createTreeWalker(O,129);function V(t,e){if(!L(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==A?A.createHTML(e):e}class Y{constructor({strings:t,_$litType$:e},s){let i;this.parts=[];let n=0,o=0;const r=t.length-1,a=this.parts,[h,l]=((t,e)=>{const s=t.length-1,i=[];let n,o=2===e?"<svg>":3===e?"<math>":"",r=z;for(let e=0;e<s;e++){const s=t[e];let a,h,l=-1,c=0;for(;c<s.length&&(r.lastIndex=c,h=r.exec(s),null!==h);)c=r.lastIndex,r===z?"!--"===h[1]?r=M:void 0!==h[1]?r=N:void 0!==h[2]?(j.test(h[2])&&(n=RegExp("</"+h[2],"g")),r=H):void 0!==h[3]&&(r=H):r===H?">"===h[0]?(r=n??z,l=-1):void 0===h[1]?l=-2:(l=r.lastIndex-h[2].length,a=h[1],r=void 0===h[3]?H:'"'===h[3]?I:B):r===I||r===B?r=H:r===M||r===N?r=z:(r=H,n=void 0);const d=r===H&&t[e+1].startsWith("/>")?" ":"";o+=r===z?s+T:l>=0?(i.push(a),s.slice(0,l)+E+s.slice(l)+C+d):s+C+(-2===l?e:d)}return[V(t,o+(t[s]||"<?>")+(2===e?"</svg>":3===e?"</math>":"")),i]})(t,e);if(this.el=Y.createElement(h,s),J.currentNode=this.el.content,2===e||3===e){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes)}for(;null!==(i=J.nextNode())&&a.length<r;){if(1===i.nodeType){if(i.hasAttributes())for(const t of i.getAttributeNames())if(t.endsWith(E)){const e=l[o++],s=i.getAttribute(t).split(C),r=/([.?@])?(.*)/.exec(e);a.push({type:1,index:n,name:r[2],strings:s,ctor:"."===r[1]?et:"?"===r[1]?st:"@"===r[1]?it:tt}),i.removeAttribute(t)}else t.startsWith(C)&&(a.push({type:6,index:n}),i.removeAttribute(t));if(j.test(i.tagName)){const t=i.textContent.split(C),e=t.length-1;if(e>0){i.textContent=S?S.emptyScript:"";for(let s=0;s<e;s++)i.append(t[s],U()),J.nextNode(),a.push({type:2,index:++n});i.append(t[e],U())}}}else if(8===i.nodeType)if(i.data===k)a.push({type:2,index:n});else{let t=-1;for(;-1!==(t=i.data.indexOf(C,t+1));)a.push({type:7,index:n}),t+=C.length-1}n++}}static createElement(t,e){const s=O.createElement("template");return s.innerHTML=t,s}}function Z(t,e,s=t,i){if(e===W)return e;let n=void 0!==i?s._$Co?.[i]:s._$Cl;const o=P(e)?void 0:e._$litDirective$;return n?.constructor!==o&&(n?._$AO?.(!1),void 0===o?n=void 0:(n=new o(t),n._$AT(t,s,i)),void 0!==i?(s._$Co??=[])[i]=n:s._$Cl=n),void 0!==n&&(e=Z(t,n._$AS(t,e.values),n,i)),e}class Q{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:e},parts:s}=this._$AD,i=(t?.creationScope??O).importNode(e,!0);J.currentNode=i;let n=J.nextNode(),o=0,r=0,a=s[0];for(;void 0!==a;){if(o===a.index){let e;2===a.type?e=new X(n,n.nextSibling,this,t):1===a.type?e=new a.ctor(n,a.name,a.strings,this,t):6===a.type&&(e=new nt(n,this,t)),this._$AV.push(e),a=s[++r]}o!==a?.index&&(n=J.nextNode(),o++)}return J.currentNode=O,i}p(t){let e=0;for(const s of this._$AV)void 0!==s&&(void 0!==s.strings?(s._$AI(t,s,e),e+=s.strings.length-2):s._$AI(t[e])),e++}}class X{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,e,s,i){this.type=2,this._$AH=K,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=s,this.options=i,this._$Cv=i?.isConnected??!0}get parentNode(){let t=this._$AA.parentNode;const e=this._$AM;return void 0!==e&&11===t?.nodeType&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=Z(this,t,e),P(t)?t===K||null==t||""===t?(this._$AH!==K&&this._$AR(),this._$AH=K):t!==this._$AH&&t!==W&&this._(t):void 0!==t._$litType$?this.$(t):void 0!==t.nodeType?this.T(t):(t=>L(t)||"function"==typeof t?.[Symbol.iterator])(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!==K&&P(this._$AH)?this._$AA.nextSibling.data=t:this.T(O.createTextNode(t)),this._$AH=t}$(t){const{values:e,_$litType$:s}=t,i="number"==typeof s?this._$AC(t):(void 0===s.el&&(s.el=Y.createElement(V(s.h,s.h[0]),this.options)),s);if(this._$AH?._$AD===i)this._$AH.p(e);else{const t=new Q(i,this),s=t.u(this.options);t.p(e),this.T(s),this._$AH=t}}_$AC(t){let e=G.get(t.strings);return void 0===e&&G.set(t.strings,e=new Y(t)),e}k(t){L(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let s,i=0;for(const n of t)i===e.length?e.push(s=new X(this.O(U()),this.O(U()),this,this.options)):s=e[i],s._$AI(n),i++;i<e.length&&(this._$AR(s&&s._$AB.nextSibling,i),e.length=i)}_$AR(t=this._$AA.nextSibling,e){for(this._$AP?.(!1,!0,e);t!==this._$AB;){const e=_(t).nextSibling;_(t).remove(),t=e}}setConnected(t){void 0===this._$AM&&(this._$Cv=t,this._$AP?.(t))}}class tt{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,s,i,n){this.type=1,this._$AH=K,this._$AN=void 0,this.element=t,this.name=e,this._$AM=i,this.options=n,s.length>2||""!==s[0]||""!==s[1]?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=K}_$AI(t,e=this,s,i){const n=this.strings;let o=!1;if(void 0===n)t=Z(this,t,e,0),o=!P(t)||t!==this._$AH&&t!==W,o&&(this._$AH=t);else{const i=t;let r,a;for(t=n[0],r=0;r<n.length-1;r++)a=Z(this,i[s+r],e,r),a===W&&(a=this._$AH[r]),o||=!P(a)||a!==this._$AH[r],a===K?t=K:t!==K&&(t+=(a??"")+n[r+1]),this._$AH[r]=a}o&&!i&&this.j(t)}j(t){t===K?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}class et extends tt{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===K?void 0:t}}class st extends tt{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==K)}}class it extends tt{constructor(t,e,s,i,n){super(t,e,s,i,n),this.type=5}_$AI(t,e=this){if((t=Z(this,t,e,0)??K)===W)return;const s=this._$AH,i=t===K&&s!==K||t.capture!==s.capture||t.once!==s.once||t.passive!==s.passive,n=t!==K&&(s===K||i);i&&this.element.removeEventListener(this.name,this,s),n&&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 nt{constructor(t,e,s){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=s}get _$AU(){return this._$AM._$AU}_$AI(t){Z(this,t)}}const ot={I:X},rt=x.litHtmlPolyfillSupport;rt?.(Y,X),(x.litHtmlVersions??=[]).push("3.3.3");const at=(t,e,s)=>{const i=s?.renderBefore??e;let n=i._$litPart$;if(void 0===n){const t=s?.renderBefore??null;i._$litPart$=n=new X(e.insertBefore(U(),t),t,void 0,s??{})}return n._$AI(t),n},ht=globalThis;let lt=class extends w{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 e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=at(e,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return W}};lt._$litElement$=!0,lt.finalized=!0,ht.litElementHydrateSupport?.({LitElement:lt});const ct=ht.litElementPolyfillSupport;ct?.({LitElement:lt}),(ht.litElementVersions??=[]).push("4.2.2");const dt=1,pt=2,ut=3,mt=4,ft=t=>(...e)=>({_$litDirective$:t,values:e});let gt=class{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,e,s){this._$Ct=t,this._$AM=e,this._$Ci=s}_$AS(t,e){return this.update(t,e)}update(t,e){return this.render(...e)}},bt=class extends gt{constructor(t){if(super(t),this.it=K,t.type!==pt)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(t){if(t===K||null==t)return this._t=void 0,this.it=t;if(t===W)return t;if("string"!=typeof t)throw Error(this.constructor.directiveName+"() called with a non-string value");if(t===this.it)return this._t;this.it=t;const e=[t];return e.raw=e,this._t={_$litType$:this.constructor.resultType,strings:e,values:[]}}};bt.directiveName="unsafeHTML",bt.resultType=1;const vt=ft(bt),yt=Object.freeze({SUBMIT:"chat-submit",BEFORE_OPEN:"chat-before-open",OPEN:"chat-open",BEFORE_CLOSE:"chat-before-close",CLOSE:"chat-close",HIDE:"chat-hide",SHOW:"chat-show",STATE_CHANGE:"chat-state-change",INPUT:"chat-input",MESSAGE_RENDER:"chat-message-render",MESSAGE_CLICK:"chat-message-click",SCROLL_TOP:"chat-scroll-top",BREAKPOINT_CHANGE:"chat-breakpoint-change"});function $t(t,e,s,{cancelable:i=!1}={}){return t.dispatchEvent(new CustomEvent(e,{detail:s,bubbles:!0,composed:!0,cancelable:i}))}const wt={closed:"launcher",open:"panel",hidden:null};class xt{#t;#e;#s;#i;#n="closed";#o="closed";#r=!1;#a=0;#h=null;#l=null;#c=!1;constructor(t,{animation:e,keepsLauncher:s,onOpened:i}){this.#t=t,this.#e=e,this.#s=s,this.#i=i,t.addController(this)}get renderedState(){return this.#o}get applying(){return this.#r}hostConnected(){this.#n=this.#t.state,this.#o=this.#t.state,this.#t.dataset.renderedState=this.#o}hostDisconnected(){this.#l?.(),this.#l=null,this.#h?.(!1),this.#h=null}hostUpdated(){this.#t.dataset.renderedState=this.#o}request(t,e){const s=this.#n;return t===s?Promise.resolve(!0):this.#d(s,t,e)?(this.#p(),this.#n=t,this.#u(t),$t(this.#t,yt.STATE_CHANGE,{from:s,to:t,trigger:e}),this.#m(s,t,e)):(this.#u(s),Promise.resolve(!1))}#d(t,e,s){return"open"===e?$t(this.#t,yt.BEFORE_OPEN,{from:t,trigger:s},{cancelable:!0}):"closed"!==e||"open"!==t||$t(this.#t,yt.BEFORE_CLOSE,{from:t,trigger:s},{cancelable:!0})}#p(){this.#a+=1,this.#l?.(),this.#l=null,this.#h?.(!1),this.#h=null,this.#o!==this.#n&&(this.#o=this.#n,this.#t.requestUpdate())}#m(t,e,s){const i=this.#a,n=new Promise(t=>{this.#h=t});return(async()=>{if(this.#c=this.#f(),await this.#t.updateComplete,i!==this.#a)return;const n=this.#g(t);if(n&&!this.#b(t,e)&&(await this.#v(n,"exit",this.#e(t,e,"exit")),i!==this.#a))return;if(this.#o=e,this.#t.requestUpdate(),await this.#t.updateComplete,i!==this.#a)return;const o=this.#g(e);o&&(await this.#v(o,"enter",this.#e(t,e,"enter")),i!==this.#a)||(this.#y(t,e,s),this.#$(e),this.#h?.(!0),this.#h=null)})(),n}#b(t,e){return"closed"===t&&"open"===e&&this.#s()}#y(t,e,s){"hidden"===t&&$t(this.#t,yt.SHOW,{from:t,to:e}),"hidden"!==e?"open"===e?$t(this.#t,yt.OPEN,{from:t,trigger:s}):"closed"===e&&"open"===t&&$t(this.#t,yt.CLOSE,{from:t,trigger:s}):$t(this.#t,yt.HIDE,{from:t,to:e})}#$(t){"open"!==t?("closed"===t&&this.#c&&this.#g("closed")?.focus(),this.#c=!1):this.#i()}#f(){const t=this.#t.renderRoot instanceof ShadowRoot?this.#t.renderRoot.activeElement:null,e=this.#g("open");return!(!t||!e||t!==e&&!e.contains(t))}#g(t){const e=wt[t];return e?this.#t.renderRoot.querySelector(`[part~="${e}"]`):null}#u(t){this.#t.state!==t&&(this.#r=!0,this.#t.state=t,this.#r=!1)}#v(t,e,s){const{effect:i,duration:n}=s;return"none"===i||n<=0||window.matchMedia("(prefers-reduced-motion: reduce)").matches?Promise.resolve():new Promise(s=>{let o=!1;const r=e=>{e&&e.target!==t||o||(o=!0,clearTimeout(a),t.removeEventListener("animationend",r),t.removeAttribute("data-anim"),t.style.removeProperty("--_chit-anim-duration"),this.#l===r&&(this.#l=null),s())};t.dataset.effect=i,t.dataset.anim=e,t.style.setProperty("--_chit-anim-duration",`${n}ms`),t.addEventListener("animationend",r);const a=setTimeout(r,n+50);this.#l=r})}}class _t{#t;#w=null;#x=0;#_="pc";#S=!1;constructor(t){this.#t=t,t.addController(this)}get device(){return this.#_}hostDisconnected(){this.#w?.removeEventListener("change",this.#A),this.#w=null}observe(t){t===this.#x&&this.#w||(this.#x=t,this.#w?.removeEventListener("change",this.#A),this.#w=window.matchMedia(`(max-width: ${t-1}px)`),this.#w.addEventListener("change",this.#A),this.#E(this.#w.matches?"mobile":"pc"))}#A=t=>{this.#E(t.matches?"mobile":"pc")};#E(t){t===this.#_&&this.#t.dataset.device||(this.#_=t,this.#t.dataset.device=t,this.#t.requestUpdate(),this.#S&&$t(this.#t,yt.BREAKPOINT_CHANGE,{device:t}),this.#S=!0)}}const St="#2563eb",At="#1f2328",Et="#5c6370",Ct="#ffffff",kt="#f1f3f5",Tt="#e4e4e7",Ot="#ffffff",Ut={size:60,position:"bottom-right",offset:{x:24,y:24},radius:30,image:null,label:null,component:null,props:{},colors:{background:St,text:Ot,shadow:"0 4px 12px rgba(0, 0, 0, 0.2)"},animation:{enter:"scale",exit:"scale",duration:200,idle:"none"}},Pt={size:56,offset:{x:16,y:16},radius:28},Lt={breakpoint:768,zIndex:2147483e3,font:{family:"system-ui, -apple-system, 'Segoe UI', 'Hiragino Sans', 'Noto Sans JP', sans-serif",size:14},closed:{pc:Ut,mobile:{...Ut,...Pt}},open:{width:380,height:600,position:"bottom-right",offset:{x:24,y:24},radius:16,launcher:"hidden",header:{title:null,logo:null,avatar:null},background:{image:null},colors:{background:Ct,text:At,accent:St,border:Tt,shadow:"0 8px 32px rgba(0, 0, 0, 0.24)",headerBackground:Ct,headerText:At,userBubble:St,userText:Ot,assistantBubble:kt,assistantText:At,systemText:Et,inputBackground:Ct,inputText:At,inputPlaceholder:Et},animation:{enter:"scale",exit:"fade",duration:150,scroll:"smooth"},input:{maxRows:5,placeholder:null}},hidden:{animation:{exit:"fade",duration:150}}},Rt=Pt;function zt(t){return"object"==typeof t&&null!==t&&!Array.isArray(t)}function Mt(t,e){if(!zt(e))return t;const s={...t};for(const[t,i]of Object.entries(e)){if(void 0===i)continue;const e=s[t];s[t]=zt(i)&&zt(e)?Mt(e,i):i}return s}function Nt(t,e){const s=t??{},i=function(t,e){const s=t??{};if(!("pc"in s)&&!("mobile"in s)){const s=t??{};return Mt(Lt.closed[e],s)}const i=Mt(Lt.closed.pc,s.pc);return"pc"===e?i:s.mobile?Mt(Lt.closed.mobile,s.mobile):Mt(i,Rt)}(s.closed,e);return{breakpoint:s.breakpoint??Lt.breakpoint,zIndex:s.zIndex??Lt.zIndex,font:Mt(Lt.font,s.font),closed:Mt(Lt.closed[e],i),open:Mt(Lt.open,s.open),hidden:Mt(Lt.hidden,s.hidden),device:e}}const Ht=t=>`${t}px`;function Bt(t){return t?`url("${t.replace(/[\\"]/g,"\\$&")}")`:"none"}function It(t){const e=Object.entries(function(t){const{closed:e,open:s}=t,i=s.colors;return{"--chit-z-index":String(t.zIndex),"--chit-font-family":t.font.family,"--chit-font-size":Ht(t.font.size),"--chit-launcher-size":"auto"===e.size?"auto":Ht(e.size),"--chit-launcher-offset-x":Ht(e.offset.x),"--chit-launcher-offset-y":Ht(e.offset.y),"--chit-launcher-radius":Ht(e.radius),"--chit-launcher-image":Bt(e.image),"--chit-launcher-bg":e.colors.background,"--chit-launcher-text":e.colors.text,"--chit-launcher-shadow":e.colors.shadow,"--chit-panel-width":Ht(s.width),"--chit-panel-height":Ht(s.height),"--chit-panel-offset-x":Ht(s.offset.x),"--chit-panel-offset-y":Ht(s.offset.y),"--chit-panel-radius":Ht(s.radius),"--chit-panel-bg-image":Bt(s.background.image),"--chit-panel-shadow":i.shadow,"--chit-color-bg":i.background,"--chit-color-text":i.text,"--chit-color-accent":i.accent,"--chit-color-border":i.border,"--chit-color-header-bg":i.headerBackground,"--chit-color-header-text":i.headerText,"--chit-color-user-bg":i.userBubble,"--chit-color-user-text":i.userText,"--chit-color-assistant-bg":i.assistantBubble,"--chit-color-assistant-text":i.assistantText,"--chit-color-system-text":i.systemText,"--chit-color-input-bg":i.inputBackground,"--chit-color-input-text":i.inputText,"--chit-color-input-placeholder":i.inputPlaceholder,"--_chit-input-max-rows":String(s.input.maxRows)}}(t)).map(([t,e])=>` ${t}: ${e};`).join("\n");return`:host {\n${e}\n}\n`}const jt="undefined"!=typeof ShadowRoot&&"adoptedStyleSheets"in Document.prototype&&"replaceSync"in CSSStyleSheet.prototype;class Dt{#C=null;#k=null;#T="";#O;constructor(t){this.#O=t}attach(t){if(t instanceof ShadowRoot){if(jt)return this.#C||(this.#C=new CSSStyleSheet),void(t.adoptedStyleSheets.includes(this.#C)||(t.adoptedStyleSheets=[...t.adoptedStyleSheets,this.#C]));this.#k||(this.#k=document.createElement("style"),this.#k.setAttribute(this.#O,"")),this.#k.parentNode!==t&&t.append(this.#k)}}write(t,e){if(t!==this.#T){if(this.attach(e),this.#C)this.#C.replaceSync(t);else{if(!this.#k)return;this.#k.textContent=t}this.#T=t}}detach(){this.#k?.remove(),this.#k=null}}class qt{#t;#C=new Dt("data-chit-theme");#U;constructor(t,{device:e}){this.#t=t,this.#U=Nt(void 0,e())}get current(){return this.#U}hostConnected(){this.#P()}hostDisconnected(){this.#C.detach()}static breakpointOf(t){return function(t){return t?.breakpoint??Lt.breakpoint}(t)}apply(t,e){this.#U=Nt(t,e),this.#P()}#P(){this.#C.write(It(this.#U),this.#t.renderRoot)}}class Ft{#t;#L;#R=null;#z=null;#M=!0;#N=!1;#H=!1;#B=!0;#I=!1;#j;#D=!0;#q;#F=0;constructor(t,{behavior:e}){this.#t=t,this.#L=e,t.addController(this)}get hasUnseen(){return this.#N}get atBottom(){return this.#M}hostDisconnected(){this.#W(),clearTimeout(this.#j)}hostUpdate(){const t=this.#t.messages,e=t[t.length-1],s=t.length>this.#F,i=e?.id!==this.#q;this.#q=e?.id,this.#F=t.length,(s||i)&&(this.#M||"user"===e?.role?this.#B=!0:this.#N=!0)}hostUpdated(){const t=this.#t.renderRoot.querySelector('[part~="messages"]');if(t!==this.#R&&(this.#W(),this.#R=t,this.#K(),t&&(this.#M=!0,this.#N=!1,this.#B=!0,this.#D=!0)),this.#B){const t=this.#G;this.#B=!1,this.#J({behavior:t})}}#K(){if(!this.#R)return;this.#R.addEventListener("scroll",this.#V,{passive:!0}),this.#R.addEventListener("scrollend",this.#Y);const t=this.#R.firstElementChild;t&&"undefined"!=typeof ResizeObserver&&(this.#z=new ResizeObserver(()=>{this.#M&&this.#J({behavior:this.#I?"smooth":"instant"})}),this.#z.observe(t))}#W(){this.#R?.removeEventListener("scroll",this.#V),this.#R?.removeEventListener("scrollend",this.#Y),this.#z?.disconnect(),this.#z=null,this.#R=null}#Y=()=>{this.#Z()};#V=()=>{const t=this.#R;if(!t)return;const e=t.scrollHeight-t.scrollTop-t.clientHeight<=24;if(this.#I)return void(e&&this.#Z());e!==this.#M&&(this.#M=e,e&&this.#N&&(this.#N=!1,this.#t.requestUpdate()));const s=t.scrollTop<=0;s&&!this.#H&&$t(this.#t,yt.SCROLL_TOP,{}),this.#H=s};scrollToBottom({smooth:t}={}){const e=void 0===t?this.#G:t?"smooth":"instant";this.#J({behavior:e}),this.#N&&(this.#N=!1,this.#t.requestUpdate())}get#G(){return this.#D||window.matchMedia("(prefers-reduced-motion: reduce)").matches?"instant":this.#L()}#J({behavior:t="instant"}={}){const e=this.#R;e&&(this.#D=!1,"smooth"===t&&this.#Q(),e.scrollTo({top:e.scrollHeight,behavior:t}),this.#M=!0,this.#H=!1,this.#N=!1)}#Q(){this.#I=!0,clearTimeout(this.#j),this.#j=setTimeout(()=>this.#Z(),700)}#Z(){if(!this.#I)return;this.#I=!1,clearTimeout(this.#j);const t=this.#R;if(!t)return;const e=t.scrollHeight-t.scrollTop-t.clientHeight;this.#M=e<=24}}const Wt="undefined"!=typeof CSS&&CSS.supports?.("field-sizing","content");class Kt{#t;#X="";#tt=!1;#et=!1;#st;constructor(t){this.#t=t,t.addController(this)}get value(){return this.#X}set value(t){this.#X=t??"";const e=this.#it;e&&e.value!==this.#X&&(e.value=this.#X),this.#nt(),this.#ot()}get composing(){return this.#tt}get length(){return Array.from(this.#X).length}get canSend(){if(this.#t.busy||this.#t.inputDisabled)return!1;if(""===this.#X.trim())return!1;const t=this.#t.maxLength;return void 0===t||this.length<=t}hostDisconnected(){clearTimeout(this.#st)}hostUpdated(){const t=this.#it;t&&t.value!==this.#X&&(t.value=this.#X),this.#nt(),this.#ot()}get#it(){return this.#t.renderRoot.querySelector('[part~="input"]')}onInput(t){this.#X=t.target.value,this.#nt(),this.#ot(),$t(this.#t,yt.INPUT,{value:this.#X})}onCompositionStart(){this.#tt=!0}onCompositionEnd(){this.#tt=!1,this.#et=!0,clearTimeout(this.#st),this.#st=setTimeout(()=>{this.#et=!1},0)}onKeydown(t){"Enter"===t.key&&this.#t.sendOnEnter&&(t.shiftKey||t.altKey||t.ctrlKey||t.metaKey||t.isComposing||229===t.keyCode||this.#tt||this.#et||(t.preventDefault(),this.submit()))}submit(t){const e=t??this.#X;if(void 0===t&&!this.canSend)return!1;if(void 0!==t&&(this.#t.busy||this.#t.inputDisabled))return!1;if(""===e.trim())return!1;return!!$t(this.#t,yt.SUBMIT,{text:e},{cancelable:!0})&&(this.clear(),!0)}clear(){this.value="",this.focus()}focus(){this.#it?.focus()}#nt(){if(Wt)return;const t=this.#it;t&&(t.style.height="auto",t.style.height=`${t.scrollHeight}px`)}#ot(){const t=this.#t.renderRoot,e=t.querySelector('[part~="send-button"]');e&&(e.disabled=!this.canSend);const s=this.#it,i=t.querySelector('[part~="counter"]'),n=this.#t.maxLength;if(void 0===n)return;const o=n-this.length,r=o<0;if(s?.setAttribute("aria-invalid",r?"true":"false"),!i)return;i.textContent=String(o),i.toggleAttribute("data-over",r);const a=this.#t.currentLabels,h=r?a.overLimit:a.charactersLeft;i.setAttribute("aria-label",h.replace("{n}",String(Math.abs(o)))),i.hidden=this.length<=.8*n}}const Gt=new WeakMap,Jt=t=>`msg:${t}`,Vt=["text","html","template","element","component"];function Yt(t){const e=Vt.filter(e=>e in t);if(1===e.length)return e[0];if(0===e.length)throw new Error(`ChitUI: message "${t.id}" has no content. Give it one of html, template, element or component.`);throw new Error(`ChitUI: message "${t.id}" has ${e.join(" and ")}. Give it exactly one.`)}function Zt(t){return t[Yt(t)]}function Qt(t,e,s,i={}){let n=Gt.get(t);n||(n=new Map,Gt.set(t,n));const o=n.get(e);if(o&&o.source===s){for(const[t,e]of Object.entries(i))Object.is(o.props[t],e)||(o.element[t]=e);return o.props={...i},o.element}const r=document.createElement(function(t){if("string"==typeof t)return t;const e=customElements,s=e.getName?.(t);if(s)return s;const i=t.tagName;if("string"==typeof i&&i)return i;throw new Error("ChitUI: component is not registered in customElements. Call customElements.define() for it, or pass its tag name as a string.")}(s));for(const[t,e]of Object.entries(i))r[t]=e;return n.set(e,{source:s,element:r,props:{...i}}),r}function Xt(t,e){return Gt.get(t)?.get(Jt(e))?.element}function te(t,e){switch(Yt(e)){case"text":return e.text;case"template":return e.template;case"element":return e.element;case"component":{const s=e;return Qt(t,Jt(e.id),s.component,s.props)}default:{const s=e.html;return vt(t.sanitize?t.sanitize(s):s)}}}function ee(t){const e=t.currentTheme.closed,s=t.currentLabels,i=e.component?Qt(t,"launcher",e.component,e.props):null;return q`
|
|
2
|
+
<button
|
|
3
|
+
part="launcher"
|
|
4
|
+
type="button"
|
|
5
|
+
aria-label=${e.label||s.launcher}
|
|
6
|
+
aria-expanded=${"open"===t.state}
|
|
7
|
+
?data-has-image=${!i&&!!e.image}
|
|
8
|
+
?data-custom=${!!i}
|
|
9
|
+
@click=${()=>t.toggleFromUser()}
|
|
10
|
+
>
|
|
11
|
+
${i??q`<slot name="launcher">${function(t){return t.image?K:t.label?q`<span part="launcher-label">${t.label}</span>`:function(){return q`
|
|
12
|
+
<svg part="launcher-icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false">
|
|
13
|
+
<path
|
|
14
|
+
fill="currentColor"
|
|
15
|
+
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"
|
|
16
|
+
/>
|
|
17
|
+
</svg>
|
|
18
|
+
`}()}(e)}</slot>`}
|
|
19
|
+
</button>
|
|
20
|
+
`}const{I:se}=ot,ie=t=>t,ne=()=>document.createComment(""),oe=(t,e,s)=>{const i=t._$AA.parentNode,n=void 0===e?t._$AB:e._$AA;if(void 0===s){const e=i.insertBefore(ne(),n),o=i.insertBefore(ne(),n);s=new se(e,o,t,t.options)}else{const e=s._$AB.nextSibling,o=s._$AM,r=o!==t;if(r){let e;s._$AQ?.(t),s._$AM=t,void 0!==s._$AP&&(e=t._$AU)!==o._$AU&&s._$AP(e)}if(e!==n||r){let t=s._$AA;for(;t!==e;){const e=ie(t).nextSibling;ie(i).insertBefore(t,n),t=e}}}return s},re=(t,e,s=t)=>(t._$AI(e,s),t),ae={},he=(t,e=ae)=>t._$AH=e,le=t=>{t._$AR(),t._$AA.remove()},ce=(t,e,s)=>{const i=new Map;for(let n=e;n<=s;n++)i.set(t[n],n);return i},de=ft(class extends gt{constructor(t){if(super(t),t.type!==pt)throw Error("repeat() can only be used in text expressions")}dt(t,e,s){let i;void 0===s?s=e:void 0!==e&&(i=e);const n=[],o=[];let r=0;for(const e of t)n[r]=i?i(e,r):r,o[r]=s(e,r),r++;return{values:o,keys:n}}render(t,e,s){return this.dt(t,e,s).values}update(t,[e,s,i]){const n=(t=>t._$AH)(t),{values:o,keys:r}=this.dt(e,s,i);if(!Array.isArray(n))return this.ut=r,o;const a=this.ut??=[],h=[];let l,c,d=0,p=n.length-1,u=0,m=o.length-1;for(;d<=p&&u<=m;)if(null===n[d])d++;else if(null===n[p])p--;else if(a[d]===r[u])h[u]=re(n[d],o[u]),d++,u++;else if(a[p]===r[m])h[m]=re(n[p],o[m]),p--,m--;else if(a[d]===r[m])h[m]=re(n[d],o[m]),oe(t,h[m+1],n[d]),d++,m--;else if(a[p]===r[u])h[u]=re(n[p],o[u]),oe(t,n[d],n[p]),p--,u++;else if(void 0===l&&(l=ce(r,u,m),c=ce(a,d,p)),l.has(a[d]))if(l.has(a[p])){const e=c.get(r[u]),s=void 0!==e?n[e]:null;if(null===s){const e=oe(t,n[d]);re(e,o[u]),h[u]=e}else h[u]=re(s,o[u]),oe(t,n[d],s),n[e]=null;u++}else le(n[p]),p--;else le(n[d]),d++;for(;u<=m;){const e=oe(t,h[m+1]);re(e,o[u]),h[u++]=e}for(;d<=p;){const t=n[d++];null!==t&&le(t)}return this.ut=r,he(t,h),W}});function pe(t,e){if("system"===e.role)return q`
|
|
21
|
+
<article part="message message-system" data-role="system" data-id=${e.id}>
|
|
22
|
+
<div part="message-content" data-content=${Yt(e)}>${te(t,e)}</div>
|
|
23
|
+
</article>
|
|
24
|
+
`;const s=e.time||e.status;return q`
|
|
25
|
+
<article
|
|
26
|
+
part="message message-${e.role}"
|
|
27
|
+
data-role=${e.role}
|
|
28
|
+
data-id=${e.id}
|
|
29
|
+
?data-streaming=${!!e.streaming}
|
|
30
|
+
aria-busy=${e.streaming?"true":"false"}
|
|
31
|
+
>
|
|
32
|
+
${e.avatar?q`<img part="avatar" src=${e.avatar} alt="" loading="lazy" />`:K}
|
|
33
|
+
<div class="body">
|
|
34
|
+
${e.name?q`<span part="name">${e.name}</span>`:K}
|
|
35
|
+
<div part="bubble">
|
|
36
|
+
<div part="message-content" data-content=${Yt(e)}>${te(t,e)}</div>
|
|
37
|
+
${e.streaming?q`<span part="cursor" aria-hidden="true"></span>`:K}
|
|
38
|
+
</div>
|
|
39
|
+
${s?q`
|
|
40
|
+
<div part="meta" class="meta">
|
|
41
|
+
${e.time?q`<time part="time">${function(t,e){const s=e instanceof Date?e:new Date(e);return Number.isNaN(s.getTime())?"":t.formatTime?t.formatTime(s):new Intl.DateTimeFormat(t.resolvedLocale,{hour:"2-digit",minute:"2-digit"}).format(s)}(t,e.time)}</time>`:K}
|
|
42
|
+
${e.status?q`<span part="status" data-status=${e.status}>
|
|
43
|
+
${t.currentLabels.status[e.status]}
|
|
44
|
+
</span>`:K}
|
|
45
|
+
</div>
|
|
46
|
+
`:K}
|
|
47
|
+
</div>
|
|
48
|
+
</article>
|
|
49
|
+
`}const ue=ft(class extends gt{constructor(t){if(super(t),t.type!==ut&&t.type!==dt&&t.type!==mt)throw Error("The `live` directive is not allowed on child or event bindings");if(!(t=>void 0===t.strings)(t))throw Error("`live` bindings can only contain a single expression")}render(t){return t}update(t,[e]){if(e===W||e===K)return e;const s=t.element,i=t.name;if(t.type===ut){if(e===s[i])return W}else if(t.type===mt){if(!!e===s.hasAttribute(i))return W}else if(t.type===dt&&s.getAttribute(i)===e+"")return W;return he(t),e}});function me(t){const e=t.currentTheme.open,s=t.currentLabels,i=e.header?.title??s.panel;return q`
|
|
50
|
+
<section
|
|
51
|
+
part="panel"
|
|
52
|
+
role="dialog"
|
|
53
|
+
aria-modal="false"
|
|
54
|
+
aria-label=${i}
|
|
55
|
+
tabindex="-1"
|
|
56
|
+
@keydown=${e=>function(t,e){if("Escape"!==e.key||e.defaultPrevented)return;e.preventDefault(),t.closeFromUser()}(t,e)}
|
|
57
|
+
>
|
|
58
|
+
<header part="header">
|
|
59
|
+
<slot name="header">
|
|
60
|
+
<slot name="header-title">
|
|
61
|
+
${e.header?.logo?q`<img part="header-logo" src=${e.header.logo} alt="" />`:K}
|
|
62
|
+
<span part="header-heading">${i}</span>
|
|
63
|
+
</slot>
|
|
64
|
+
<span part="header-actions">
|
|
65
|
+
<slot name="header-actions"></slot>
|
|
66
|
+
<button
|
|
67
|
+
part="close-button"
|
|
68
|
+
type="button"
|
|
69
|
+
aria-label=${s.close}
|
|
70
|
+
@click=${()=>t.closeFromUser()}
|
|
71
|
+
>
|
|
72
|
+
<svg viewBox="0 0 24 24" aria-hidden="true" focusable="false">
|
|
73
|
+
<path
|
|
74
|
+
fill="none"
|
|
75
|
+
stroke="currentColor"
|
|
76
|
+
stroke-width="2"
|
|
77
|
+
stroke-linecap="round"
|
|
78
|
+
d="M6 6l12 12M18 6L6 18"
|
|
79
|
+
/>
|
|
80
|
+
</svg>
|
|
81
|
+
</button>
|
|
82
|
+
</span>
|
|
83
|
+
</slot>
|
|
84
|
+
</header>
|
|
85
|
+
|
|
86
|
+
${function(t){const e=t.currentLabels,s=t.typing,i=0===t.messages.length&&!s;return q`
|
|
87
|
+
<div
|
|
88
|
+
part="messages"
|
|
89
|
+
role="log"
|
|
90
|
+
aria-live="polite"
|
|
91
|
+
aria-relevant="additions text"
|
|
92
|
+
aria-label=${e.conversation}
|
|
93
|
+
@click=${e=>t.handleMessageClick(e)}
|
|
94
|
+
>
|
|
95
|
+
<div part="messages-inner" class="inner">
|
|
96
|
+
${i?q`<slot name="empty"></slot>`:K}
|
|
97
|
+
${de(t.messages,t=>t.id,e=>pe(t,e))}
|
|
98
|
+
${s?q`
|
|
99
|
+
<div part="typing" role="status" aria-label=${e.typing}>
|
|
100
|
+
${"object"==typeof s&&s.html?t.renderTypingHtml(s.html):q`<span class="dots" aria-hidden="true"><i></i><i></i><i></i></span>`}
|
|
101
|
+
</div>
|
|
102
|
+
`:K}
|
|
103
|
+
</div>
|
|
104
|
+
</div>
|
|
105
|
+
|
|
106
|
+
${t.hasUnseen?q`
|
|
107
|
+
<button
|
|
108
|
+
part="to-latest"
|
|
109
|
+
type="button"
|
|
110
|
+
@click=${()=>t.scrollToBottom({smooth:!0})}
|
|
111
|
+
>
|
|
112
|
+
${e.toLatest}
|
|
113
|
+
</button>
|
|
114
|
+
`:K}
|
|
115
|
+
`}(t)} ${function(t){if(t.inputHidden)return K;const e=t.currentLabels,s=t.currentTheme.open,i=t.busy||t.inputDisabled,n=t.placeholder??s.input.placeholder??e.input;return q`
|
|
116
|
+
<form
|
|
117
|
+
part="composer"
|
|
118
|
+
@submit=${e=>{e.preventDefault(),t.submit()}}
|
|
119
|
+
>
|
|
120
|
+
<slot name="composer">
|
|
121
|
+
<slot name="input-before"></slot>
|
|
122
|
+
|
|
123
|
+
<textarea
|
|
124
|
+
part="input"
|
|
125
|
+
rows="1"
|
|
126
|
+
.value=${ue(t.value)}
|
|
127
|
+
placeholder=${n}
|
|
128
|
+
aria-label=${e.input}
|
|
129
|
+
?disabled=${i}
|
|
130
|
+
aria-describedby=${void 0===t.maxLength?K:"chit-counter"}
|
|
131
|
+
@input=${e=>t.handleInput(e)}
|
|
132
|
+
@keydown=${e=>t.handleKeydown(e)}
|
|
133
|
+
@compositionstart=${()=>t.handleComposition(!0)}
|
|
134
|
+
@compositionend=${()=>t.handleComposition(!1)}
|
|
135
|
+
></textarea>
|
|
136
|
+
|
|
137
|
+
<slot name="input-after"></slot>
|
|
138
|
+
|
|
139
|
+
${void 0===t.maxLength?K:q`<span part="counter" id="chit-counter" aria-live="polite" hidden></span>`}
|
|
140
|
+
|
|
141
|
+
<button
|
|
142
|
+
part="send-button"
|
|
143
|
+
type="submit"
|
|
144
|
+
aria-label=${e.send}
|
|
145
|
+
?disabled=${!t.canSend}
|
|
146
|
+
>
|
|
147
|
+
${t.busy?q`<span part="spinner" aria-hidden="true"></span>`:q`<svg viewBox="0 0 24 24" aria-hidden="true" focusable="false">
|
|
148
|
+
<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" />
|
|
149
|
+
</svg>`}
|
|
150
|
+
</button>
|
|
151
|
+
</slot>
|
|
152
|
+
</form>
|
|
153
|
+
`}(t)}
|
|
154
|
+
|
|
155
|
+
<slot name="footer"></slot>
|
|
156
|
+
</section>
|
|
157
|
+
`}const fe={ja:{launcher:"チャットを開く",panel:"チャット",conversation:"会話",close:"チャットを閉じる",send:"送信",input:"メッセージを入力",typing:"入力中",toLatest:"最新へ",status:{sending:"送信中",sent:"送信済み",error:"送信できませんでした"},charactersLeft:"残り {n} 文字",overLimit:"{n} 文字超過しています"},en:{launcher:"Open chat",panel:"Chat",conversation:"Conversation",close:"Close chat",send:"Send",input:"Type a message",typing:"Typing",toLatest:"Jump to latest",status:{sending:"Sending",sent:"Sent",error:"Not delivered"},charactersLeft:"{n} characters left",overLimit:"{n} characters over the limit"}};function ge(t){return t||document.documentElement.lang||void 0}const be=o`
|
|
158
|
+
:host {
|
|
159
|
+
--chit-z-index: 2147483000;
|
|
160
|
+
--chit-font-family: system-ui, -apple-system, 'Segoe UI', 'Hiragino Sans', 'Noto Sans JP', sans-serif;
|
|
161
|
+
--chit-font-size: 14px;
|
|
162
|
+
|
|
163
|
+
--chit-launcher-size: 60px;
|
|
164
|
+
--chit-launcher-offset-x: 24px;
|
|
165
|
+
--chit-launcher-offset-y: 24px;
|
|
166
|
+
--chit-launcher-radius: 30px;
|
|
167
|
+
--chit-launcher-bg: #1a73e8;
|
|
168
|
+
--chit-launcher-text: #ffffff;
|
|
169
|
+
--chit-launcher-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
|
|
170
|
+
|
|
171
|
+
--chit-panel-width: 380px;
|
|
172
|
+
--chit-panel-height: 600px;
|
|
173
|
+
--chit-panel-offset-x: 24px;
|
|
174
|
+
--chit-panel-offset-y: 24px;
|
|
175
|
+
--chit-panel-radius: 16px;
|
|
176
|
+
--chit-panel-shadow: 0 8px 32px rgba(0, 0, 0, 0.24);
|
|
177
|
+
|
|
178
|
+
--chit-color-bg: #ffffff;
|
|
179
|
+
--chit-color-text: #1f1f1f;
|
|
180
|
+
--chit-color-accent: #1a73e8;
|
|
181
|
+
--chit-color-border: #e4e4e7;
|
|
182
|
+
--chit-color-header-bg: #ffffff;
|
|
183
|
+
--chit-color-header-text: #1f1f1f;
|
|
184
|
+
|
|
185
|
+
position: fixed;
|
|
186
|
+
inset: 0;
|
|
187
|
+
z-index: var(--chit-z-index);
|
|
188
|
+
/* The host is only a coordinate space; clicks land on the page behind it. */
|
|
189
|
+
pointer-events: none;
|
|
190
|
+
font-family: var(--chit-font-family);
|
|
191
|
+
font-size: var(--chit-font-size);
|
|
192
|
+
color: var(--chit-color-text);
|
|
193
|
+
-webkit-font-smoothing: antialiased;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/*
|
|
197
|
+
* Keyed off what the DOM is showing, not off the state property: that flips
|
|
198
|
+
* to 'hidden' the moment it is assigned, while the exit animation still has
|
|
199
|
+
* to play.
|
|
200
|
+
*/
|
|
201
|
+
:host([data-rendered-state='hidden']) {
|
|
202
|
+
display: none;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
:host > *,
|
|
206
|
+
[part] {
|
|
207
|
+
pointer-events: auto;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
*,
|
|
211
|
+
*::before,
|
|
212
|
+
*::after {
|
|
213
|
+
box-sizing: border-box;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/* --- transitions ------------------------------------------------------ */
|
|
217
|
+
|
|
218
|
+
[data-anim] {
|
|
219
|
+
animation-duration: var(--_chit-anim-duration, 200ms);
|
|
220
|
+
animation-fill-mode: both;
|
|
221
|
+
animation-timing-function: cubic-bezier(0.2, 0.8, 0.2, 1);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
[data-anim='enter'][data-effect='fade'] {
|
|
225
|
+
animation-name: chit-fade-in;
|
|
226
|
+
}
|
|
227
|
+
[data-anim='exit'][data-effect='fade'] {
|
|
228
|
+
animation-name: chit-fade-out;
|
|
229
|
+
}
|
|
230
|
+
[data-anim='enter'][data-effect='scale'] {
|
|
231
|
+
animation-name: chit-scale-in;
|
|
232
|
+
}
|
|
233
|
+
[data-anim='exit'][data-effect='scale'] {
|
|
234
|
+
animation-name: chit-scale-out;
|
|
235
|
+
}
|
|
236
|
+
[data-anim='enter'][data-effect='slide'] {
|
|
237
|
+
animation-name: chit-slide-in;
|
|
238
|
+
}
|
|
239
|
+
[data-anim='exit'][data-effect='slide'] {
|
|
240
|
+
animation-name: chit-slide-out;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
@keyframes chit-fade-in {
|
|
244
|
+
from {
|
|
245
|
+
opacity: 0;
|
|
246
|
+
}
|
|
247
|
+
to {
|
|
248
|
+
opacity: 1;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
@keyframes chit-fade-out {
|
|
252
|
+
from {
|
|
253
|
+
opacity: 1;
|
|
254
|
+
}
|
|
255
|
+
to {
|
|
256
|
+
opacity: 0;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
@keyframes chit-scale-in {
|
|
260
|
+
from {
|
|
261
|
+
opacity: 0;
|
|
262
|
+
transform: scale(0.85);
|
|
263
|
+
}
|
|
264
|
+
to {
|
|
265
|
+
opacity: 1;
|
|
266
|
+
transform: none;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
@keyframes chit-scale-out {
|
|
270
|
+
from {
|
|
271
|
+
opacity: 1;
|
|
272
|
+
transform: none;
|
|
273
|
+
}
|
|
274
|
+
to {
|
|
275
|
+
opacity: 0;
|
|
276
|
+
transform: scale(0.85);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
@keyframes chit-slide-in {
|
|
280
|
+
from {
|
|
281
|
+
opacity: 0;
|
|
282
|
+
transform: translateY(16px);
|
|
283
|
+
}
|
|
284
|
+
to {
|
|
285
|
+
opacity: 1;
|
|
286
|
+
transform: none;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
@keyframes chit-slide-out {
|
|
290
|
+
from {
|
|
291
|
+
opacity: 1;
|
|
292
|
+
transform: none;
|
|
293
|
+
}
|
|
294
|
+
to {
|
|
295
|
+
opacity: 0;
|
|
296
|
+
transform: translateY(16px);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
@media (prefers-reduced-motion: reduce) {
|
|
301
|
+
[data-anim] {
|
|
302
|
+
animation: none !important;
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
`,ve=o`
|
|
306
|
+
[part~='launcher'] {
|
|
307
|
+
position: absolute;
|
|
308
|
+
display: grid;
|
|
309
|
+
place-items: center;
|
|
310
|
+
width: var(--chit-launcher-size);
|
|
311
|
+
height: var(--chit-launcher-size);
|
|
312
|
+
padding: 0;
|
|
313
|
+
border: 0;
|
|
314
|
+
border-radius: var(--chit-launcher-radius);
|
|
315
|
+
background-color: var(--chit-launcher-bg);
|
|
316
|
+
background-position: center;
|
|
317
|
+
background-size: cover;
|
|
318
|
+
background-repeat: no-repeat;
|
|
319
|
+
color: var(--chit-launcher-text);
|
|
320
|
+
box-shadow: var(--chit-launcher-shadow);
|
|
321
|
+
font: inherit;
|
|
322
|
+
line-height: 1;
|
|
323
|
+
cursor: pointer;
|
|
324
|
+
transition: filter 120ms ease;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
/* The image comes from the theme, so it is a background rather than an <img>. */
|
|
328
|
+
[part~='launcher'][data-has-image] {
|
|
329
|
+
background-image: var(--chit-launcher-image);
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
/*
|
|
333
|
+
* A consumer component draws the whole launcher, so the button stops being a
|
|
334
|
+
* visual of its own: no box to squeeze the component into, and none of the
|
|
335
|
+
* widget's own paint behind it. It keeps being a button, which is the part
|
|
336
|
+
* that matters for keyboards and screen readers.
|
|
337
|
+
*/
|
|
338
|
+
[part~='launcher'][data-custom] {
|
|
339
|
+
width: auto;
|
|
340
|
+
height: auto;
|
|
341
|
+
padding: 0;
|
|
342
|
+
border-radius: 0;
|
|
343
|
+
background: none;
|
|
344
|
+
box-shadow: none;
|
|
345
|
+
color: inherit;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
[part~='launcher'][data-custom]:hover {
|
|
349
|
+
filter: none;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
[part~='launcher']:hover {
|
|
353
|
+
filter: brightness(1.06);
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
[part~='launcher']:focus-visible {
|
|
357
|
+
outline: 2px solid var(--chit-launcher-bg);
|
|
358
|
+
outline-offset: 3px;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
[part~='launcher-icon'] {
|
|
362
|
+
width: 55%;
|
|
363
|
+
height: 55%;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
[part~='launcher-label'] {
|
|
367
|
+
padding: 0 0.75em;
|
|
368
|
+
font-size: 0.95em;
|
|
369
|
+
white-space: nowrap;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
/* --- placement -------------------------------------------------------- */
|
|
373
|
+
|
|
374
|
+
:host([data-launcher-position='bottom-right']) [part~='launcher'] {
|
|
375
|
+
right: var(--chit-launcher-offset-x);
|
|
376
|
+
bottom: var(--chit-launcher-offset-y);
|
|
377
|
+
transform-origin: bottom right;
|
|
378
|
+
}
|
|
379
|
+
:host([data-launcher-position='bottom-left']) [part~='launcher'] {
|
|
380
|
+
left: var(--chit-launcher-offset-x);
|
|
381
|
+
bottom: var(--chit-launcher-offset-y);
|
|
382
|
+
transform-origin: bottom left;
|
|
383
|
+
}
|
|
384
|
+
:host([data-launcher-position='top-right']) [part~='launcher'] {
|
|
385
|
+
right: var(--chit-launcher-offset-x);
|
|
386
|
+
top: var(--chit-launcher-offset-y);
|
|
387
|
+
transform-origin: top right;
|
|
388
|
+
}
|
|
389
|
+
:host([data-launcher-position='top-left']) [part~='launcher'] {
|
|
390
|
+
left: var(--chit-launcher-offset-x);
|
|
391
|
+
top: var(--chit-launcher-offset-y);
|
|
392
|
+
transform-origin: top left;
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
/* --- idle motion ------------------------------------------------------ */
|
|
396
|
+
|
|
397
|
+
/*
|
|
398
|
+
* Only while nothing else is animating: a transition sets data-anim and owns
|
|
399
|
+
* the animation property for as long as it runs.
|
|
400
|
+
*/
|
|
401
|
+
:host([data-idle='pulse']) [part~='launcher']:not([data-anim]) {
|
|
402
|
+
animation: chit-idle-pulse 2.4s ease-in-out infinite;
|
|
403
|
+
}
|
|
404
|
+
:host([data-idle='bounce']) [part~='launcher']:not([data-anim]) {
|
|
405
|
+
animation: chit-idle-bounce 2.4s ease-in-out infinite;
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
@keyframes chit-idle-pulse {
|
|
409
|
+
0%,
|
|
410
|
+
70%,
|
|
411
|
+
100% {
|
|
412
|
+
box-shadow: var(--chit-launcher-shadow);
|
|
413
|
+
}
|
|
414
|
+
35% {
|
|
415
|
+
box-shadow:
|
|
416
|
+
var(--chit-launcher-shadow),
|
|
417
|
+
0 0 0 10px color-mix(in srgb, var(--chit-launcher-bg) 22%, transparent);
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
@keyframes chit-idle-bounce {
|
|
422
|
+
0%,
|
|
423
|
+
62%,
|
|
424
|
+
100% {
|
|
425
|
+
transform: translateY(0);
|
|
426
|
+
}
|
|
427
|
+
72% {
|
|
428
|
+
transform: translateY(-6px);
|
|
429
|
+
}
|
|
430
|
+
86% {
|
|
431
|
+
transform: translateY(-2px);
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
@media (prefers-reduced-motion: reduce) {
|
|
436
|
+
:host([data-idle]) [part~='launcher']:not([data-anim]) {
|
|
437
|
+
animation: none;
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
`,ye=o`
|
|
441
|
+
[part~='panel'] {
|
|
442
|
+
position: absolute;
|
|
443
|
+
display: flex;
|
|
444
|
+
flex-direction: column;
|
|
445
|
+
width: var(--chit-panel-width);
|
|
446
|
+
height: var(--chit-panel-height);
|
|
447
|
+
max-width: calc(100vw - var(--chit-panel-offset-x) * 2);
|
|
448
|
+
max-height: calc(100vh - var(--chit-panel-offset-y) * 2);
|
|
449
|
+
overflow: hidden;
|
|
450
|
+
border-radius: var(--chit-panel-radius);
|
|
451
|
+
background-color: var(--chit-color-bg);
|
|
452
|
+
background-image: var(--chit-panel-bg-image);
|
|
453
|
+
background-size: cover;
|
|
454
|
+
background-position: center;
|
|
455
|
+
box-shadow: var(--chit-panel-shadow);
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
/* --- placement -------------------------------------------------------- */
|
|
459
|
+
|
|
460
|
+
:host([data-panel-position='bottom-right']) [part~='panel'] {
|
|
461
|
+
right: var(--chit-panel-offset-x);
|
|
462
|
+
bottom: var(--chit-panel-offset-y);
|
|
463
|
+
transform-origin: bottom right;
|
|
464
|
+
}
|
|
465
|
+
:host([data-panel-position='bottom-left']) [part~='panel'] {
|
|
466
|
+
left: var(--chit-panel-offset-x);
|
|
467
|
+
bottom: var(--chit-panel-offset-y);
|
|
468
|
+
transform-origin: bottom left;
|
|
469
|
+
}
|
|
470
|
+
:host([data-panel-position='top-right']) [part~='panel'] {
|
|
471
|
+
right: var(--chit-panel-offset-x);
|
|
472
|
+
top: var(--chit-panel-offset-y);
|
|
473
|
+
transform-origin: top right;
|
|
474
|
+
}
|
|
475
|
+
:host([data-panel-position='top-left']) [part~='panel'] {
|
|
476
|
+
left: var(--chit-panel-offset-x);
|
|
477
|
+
top: var(--chit-panel-offset-y);
|
|
478
|
+
transform-origin: top left;
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
[part~='panel']:focus {
|
|
482
|
+
outline: none;
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
/*
|
|
486
|
+
* A phone gets the whole screen. dvh rather than vh so the browser chrome
|
|
487
|
+
* collapsing does not leave a gap, and the safe-area insets keep the header
|
|
488
|
+
* clear of the notch.
|
|
489
|
+
*/
|
|
490
|
+
:host([data-device='mobile']) [part~='panel'],
|
|
491
|
+
:host([data-device='mobile'][data-panel-position]) [part~='panel'] {
|
|
492
|
+
inset: 0;
|
|
493
|
+
width: 100vw;
|
|
494
|
+
height: 100dvh;
|
|
495
|
+
max-width: none;
|
|
496
|
+
max-height: none;
|
|
497
|
+
border-radius: 0;
|
|
498
|
+
padding-top: env(safe-area-inset-top);
|
|
499
|
+
padding-bottom: env(safe-area-inset-bottom);
|
|
500
|
+
overscroll-behavior: contain;
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
[part~='header'] {
|
|
504
|
+
display: flex;
|
|
505
|
+
flex: none;
|
|
506
|
+
align-items: center;
|
|
507
|
+
justify-content: space-between;
|
|
508
|
+
gap: 0.5em;
|
|
509
|
+
padding: 0.875em 1em;
|
|
510
|
+
border-bottom: 1px solid var(--chit-color-border);
|
|
511
|
+
background: var(--chit-color-header-bg);
|
|
512
|
+
color: var(--chit-color-header-text);
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
[part~='header-heading'] {
|
|
516
|
+
font-size: 1.05em;
|
|
517
|
+
font-weight: 600;
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
[part~='header-logo'] {
|
|
521
|
+
width: 1.75em;
|
|
522
|
+
height: 1.75em;
|
|
523
|
+
margin-inline-end: 0.5em;
|
|
524
|
+
border-radius: 50%;
|
|
525
|
+
object-fit: cover;
|
|
526
|
+
vertical-align: middle;
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
[part~='header-actions'] {
|
|
530
|
+
display: inline-flex;
|
|
531
|
+
align-items: center;
|
|
532
|
+
gap: 0.25em;
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
[part~='close-button'] {
|
|
536
|
+
display: grid;
|
|
537
|
+
place-items: center;
|
|
538
|
+
width: 2em;
|
|
539
|
+
height: 2em;
|
|
540
|
+
padding: 0;
|
|
541
|
+
border: 0;
|
|
542
|
+
border-radius: 50%;
|
|
543
|
+
background: transparent;
|
|
544
|
+
color: inherit;
|
|
545
|
+
cursor: pointer;
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
[part~='close-button']:hover {
|
|
549
|
+
background: color-mix(in srgb, currentColor 10%, transparent);
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
[part~='close-button']:focus-visible {
|
|
553
|
+
outline: 2px solid var(--chit-color-accent);
|
|
554
|
+
outline-offset: 1px;
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
[part~='close-button'] svg {
|
|
558
|
+
width: 1.1em;
|
|
559
|
+
height: 1.1em;
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
`,$e=o`
|
|
563
|
+
[part~='messages'] {
|
|
564
|
+
flex: 1 1 auto;
|
|
565
|
+
min-height: 0;
|
|
566
|
+
overflow-y: auto;
|
|
567
|
+
overscroll-behavior: contain;
|
|
568
|
+
scrollbar-width: thin;
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
[part~='messages-inner'] {
|
|
572
|
+
display: flex;
|
|
573
|
+
flex-direction: column;
|
|
574
|
+
gap: 0.75em;
|
|
575
|
+
padding: 1em;
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
/*
|
|
579
|
+
* The row spans the full width and the bubble is capped inside it. Letting
|
|
580
|
+
* the row shrink to fit instead would make the bubble's percentage cap
|
|
581
|
+
* resolve against a shrink-to-fit parent, and because the content sets
|
|
582
|
+
* overflow-wrap: anywhere its min-content width is one character — so the
|
|
583
|
+
* bubble collapsed to a single column of letters.
|
|
584
|
+
*/
|
|
585
|
+
[part~='message'] {
|
|
586
|
+
display: flex;
|
|
587
|
+
align-items: flex-end;
|
|
588
|
+
gap: 0.5em;
|
|
589
|
+
width: 100%;
|
|
590
|
+
max-width: 100%;
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
[part~='message'] .body {
|
|
594
|
+
display: flex;
|
|
595
|
+
min-width: 0;
|
|
596
|
+
max-width: 78%;
|
|
597
|
+
flex-direction: column;
|
|
598
|
+
gap: 0.25em;
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
/* Reversed row: the bubble sits at the right edge without shrinking the row. */
|
|
602
|
+
[part~='message-user'] {
|
|
603
|
+
flex-direction: row-reverse;
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
[part~='message-user'] .body {
|
|
607
|
+
align-items: flex-end;
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
[part~='bubble'] {
|
|
611
|
+
position: relative;
|
|
612
|
+
padding: 0.6em 0.85em;
|
|
613
|
+
border-radius: 14px;
|
|
614
|
+
background: var(--chit-color-assistant-bg);
|
|
615
|
+
color: var(--chit-color-assistant-text);
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
[part~='message-user'] [part~='bubble'] {
|
|
619
|
+
background: var(--chit-color-user-bg);
|
|
620
|
+
color: var(--chit-color-user-text);
|
|
621
|
+
border-bottom-right-radius: 4px;
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
[part~='message-assistant'] [part~='bubble'] {
|
|
625
|
+
border-bottom-left-radius: 4px;
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
[part~='avatar'] {
|
|
629
|
+
flex: none;
|
|
630
|
+
width: 2em;
|
|
631
|
+
height: 2em;
|
|
632
|
+
border-radius: 50%;
|
|
633
|
+
object-fit: cover;
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
[part~='name'] {
|
|
637
|
+
font-size: 0.8em;
|
|
638
|
+
color: var(--chit-color-system-text);
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
[part~='meta'] {
|
|
642
|
+
display: flex;
|
|
643
|
+
gap: 0.5em;
|
|
644
|
+
font-size: 0.75em;
|
|
645
|
+
color: var(--chit-color-system-text);
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
[part~='status'][data-status='error'] {
|
|
649
|
+
color: #d93025;
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
[part~='message-system'] {
|
|
653
|
+
justify-content: center;
|
|
654
|
+
font-size: 0.8em;
|
|
655
|
+
color: var(--chit-color-system-text);
|
|
656
|
+
text-align: center;
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
/* --- streaming and typing --------------------------------------------- */
|
|
660
|
+
|
|
661
|
+
[part~='cursor'] {
|
|
662
|
+
display: inline-block;
|
|
663
|
+
width: 0.5em;
|
|
664
|
+
height: 1em;
|
|
665
|
+
margin-inline-start: 0.15em;
|
|
666
|
+
background: currentColor;
|
|
667
|
+
opacity: 0.6;
|
|
668
|
+
vertical-align: text-bottom;
|
|
669
|
+
animation: chit-caret 1s step-end infinite;
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
@keyframes chit-caret {
|
|
673
|
+
50% {
|
|
674
|
+
opacity: 0;
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
[part~='typing'] {
|
|
679
|
+
align-self: flex-start;
|
|
680
|
+
padding: 0.7em 0.9em;
|
|
681
|
+
border-radius: 14px;
|
|
682
|
+
border-bottom-left-radius: 4px;
|
|
683
|
+
background: var(--chit-color-assistant-bg);
|
|
684
|
+
color: var(--chit-color-assistant-text);
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
[part~='typing'] .dots {
|
|
688
|
+
display: inline-flex;
|
|
689
|
+
gap: 0.25em;
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
[part~='typing'] .dots i {
|
|
693
|
+
width: 0.4em;
|
|
694
|
+
height: 0.4em;
|
|
695
|
+
border-radius: 50%;
|
|
696
|
+
background: currentColor;
|
|
697
|
+
opacity: 0.4;
|
|
698
|
+
animation: chit-typing 1.2s ease-in-out infinite;
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
[part~='typing'] .dots i:nth-child(2) {
|
|
702
|
+
animation-delay: 0.15s;
|
|
703
|
+
}
|
|
704
|
+
[part~='typing'] .dots i:nth-child(3) {
|
|
705
|
+
animation-delay: 0.3s;
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
@keyframes chit-typing {
|
|
709
|
+
0%,
|
|
710
|
+
60%,
|
|
711
|
+
100% {
|
|
712
|
+
opacity: 0.35;
|
|
713
|
+
transform: translateY(0);
|
|
714
|
+
}
|
|
715
|
+
30% {
|
|
716
|
+
opacity: 1;
|
|
717
|
+
transform: translateY(-3px);
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
|
|
721
|
+
/* --- jump to latest ---------------------------------------------------- */
|
|
722
|
+
|
|
723
|
+
[part~='to-latest'] {
|
|
724
|
+
position: absolute;
|
|
725
|
+
left: 50%;
|
|
726
|
+
bottom: 5.5em;
|
|
727
|
+
transform: translateX(-50%);
|
|
728
|
+
padding: 0.35em 0.9em;
|
|
729
|
+
border: 1px solid var(--chit-color-border);
|
|
730
|
+
border-radius: 999px;
|
|
731
|
+
background: var(--chit-color-bg);
|
|
732
|
+
color: var(--chit-color-text);
|
|
733
|
+
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.16);
|
|
734
|
+
font: inherit;
|
|
735
|
+
font-size: 0.8em;
|
|
736
|
+
cursor: pointer;
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
[part~='to-latest']:focus-visible {
|
|
740
|
+
outline: 2px solid var(--chit-color-accent);
|
|
741
|
+
outline-offset: 2px;
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
@media (prefers-reduced-motion: reduce) {
|
|
745
|
+
[part~='cursor'],
|
|
746
|
+
[part~='typing'] .dots i {
|
|
747
|
+
animation: none;
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
`,we=o`
|
|
751
|
+
[part~='message-content'] {
|
|
752
|
+
min-width: 0;
|
|
753
|
+
max-width: 100%;
|
|
754
|
+
/* Long URLs and unbroken words wrap instead of widening the bubble. */
|
|
755
|
+
overflow-wrap: anywhere;
|
|
756
|
+
word-break: normal;
|
|
757
|
+
overflow-x: hidden;
|
|
758
|
+
/* Keeps a fixed or hugely-margined child from painting outside. */
|
|
759
|
+
contain: layout paint;
|
|
760
|
+
line-height: 1.5;
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
/*
|
|
764
|
+
* Plain text keeps its line breaks. Only this form: applying pre-wrap to
|
|
765
|
+
* html content would turn the newlines and indentation of the markup itself
|
|
766
|
+
* into visible blank lines.
|
|
767
|
+
*/
|
|
768
|
+
[part~='message-content'][data-content='text'] {
|
|
769
|
+
white-space: pre-wrap;
|
|
770
|
+
}
|
|
771
|
+
|
|
772
|
+
[part~='message-content'] > :first-child {
|
|
773
|
+
margin-top: 0;
|
|
774
|
+
}
|
|
775
|
+
[part~='message-content'] > :last-child {
|
|
776
|
+
margin-bottom: 0;
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
/* Only direct children: a tooltip nested deeper still positions normally. */
|
|
780
|
+
[part~='message-content'] > * {
|
|
781
|
+
position: static !important;
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
[part~='message-content'] img,
|
|
785
|
+
[part~='message-content'] video,
|
|
786
|
+
[part~='message-content'] iframe,
|
|
787
|
+
[part~='message-content'] svg,
|
|
788
|
+
[part~='message-content'] canvas,
|
|
789
|
+
[part~='message-content'] picture,
|
|
790
|
+
[part~='message-content'] embed,
|
|
791
|
+
[part~='message-content'] object {
|
|
792
|
+
max-width: 100%;
|
|
793
|
+
height: auto;
|
|
794
|
+
display: block;
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
/* Wide content scrolls inside itself rather than stretching the bubble. */
|
|
798
|
+
[part~='message-content'] table {
|
|
799
|
+
display: block;
|
|
800
|
+
max-width: 100%;
|
|
801
|
+
overflow-x: auto;
|
|
802
|
+
border-collapse: collapse;
|
|
803
|
+
}
|
|
804
|
+
|
|
805
|
+
[part~='message-content'] pre {
|
|
806
|
+
max-width: 100%;
|
|
807
|
+
overflow-x: auto;
|
|
808
|
+
white-space: pre;
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
[part~='message-content'] code {
|
|
812
|
+
overflow-wrap: anywhere;
|
|
813
|
+
}
|
|
814
|
+
|
|
815
|
+
[part~='message-content'] a {
|
|
816
|
+
color: var(--chit-color-accent);
|
|
817
|
+
}
|
|
818
|
+
|
|
819
|
+
[part~='message-content'] button,
|
|
820
|
+
[part~='message-content'] input,
|
|
821
|
+
[part~='message-content'] select,
|
|
822
|
+
[part~='message-content'] textarea {
|
|
823
|
+
font: inherit;
|
|
824
|
+
max-width: 100%;
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
[part~='message-content'] h1,
|
|
828
|
+
[part~='message-content'] h2,
|
|
829
|
+
[part~='message-content'] h3,
|
|
830
|
+
[part~='message-content'] h4,
|
|
831
|
+
[part~='message-content'] h5,
|
|
832
|
+
[part~='message-content'] h6 {
|
|
833
|
+
font-size: 1.1em;
|
|
834
|
+
margin: 0.5em 0;
|
|
835
|
+
}
|
|
836
|
+
|
|
837
|
+
[part~='message-content'] p {
|
|
838
|
+
margin: 0.5em 0;
|
|
839
|
+
}
|
|
840
|
+
|
|
841
|
+
[part~='message-content'] ul,
|
|
842
|
+
[part~='message-content'] ol {
|
|
843
|
+
margin: 0.5em 0;
|
|
844
|
+
padding-inline-start: 1.5em;
|
|
845
|
+
}
|
|
846
|
+
|
|
847
|
+
[part~='message-content'] blockquote {
|
|
848
|
+
margin: 0.5em 0;
|
|
849
|
+
padding-inline-start: 0.75em;
|
|
850
|
+
border-inline-start: 3px solid var(--chit-color-border);
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
[part~='message-content'] hr {
|
|
854
|
+
border: 0;
|
|
855
|
+
border-top: 1px solid var(--chit-color-border);
|
|
856
|
+
}
|
|
857
|
+
`,xe=o`
|
|
858
|
+
[part~='composer'] {
|
|
859
|
+
display: flex;
|
|
860
|
+
flex: none;
|
|
861
|
+
align-items: flex-end;
|
|
862
|
+
gap: 0.5em;
|
|
863
|
+
padding: 0.6em 0.75em;
|
|
864
|
+
border-top: 1px solid var(--chit-color-border);
|
|
865
|
+
background: var(--chit-color-input-bg);
|
|
866
|
+
}
|
|
867
|
+
|
|
868
|
+
[part~='input'] {
|
|
869
|
+
flex: 1 1 auto;
|
|
870
|
+
min-width: 0;
|
|
871
|
+
/* One row to start with, growing to the theme's limit. */
|
|
872
|
+
field-sizing: content;
|
|
873
|
+
max-height: calc(1.5em * var(--_chit-input-max-rows, 5) + 1em);
|
|
874
|
+
padding: 0.45em 0.6em;
|
|
875
|
+
border: 1px solid var(--chit-color-border);
|
|
876
|
+
border-radius: 12px;
|
|
877
|
+
background: var(--chit-color-input-bg);
|
|
878
|
+
color: var(--chit-color-input-text);
|
|
879
|
+
font: inherit;
|
|
880
|
+
line-height: 1.5;
|
|
881
|
+
resize: none;
|
|
882
|
+
overflow-y: auto;
|
|
883
|
+
}
|
|
884
|
+
|
|
885
|
+
[part~='input']::placeholder {
|
|
886
|
+
color: var(--chit-color-input-placeholder);
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
[part~='input']:focus-visible {
|
|
890
|
+
outline: 2px solid var(--chit-color-accent);
|
|
891
|
+
outline-offset: -1px;
|
|
892
|
+
}
|
|
893
|
+
|
|
894
|
+
[part~='input']:disabled {
|
|
895
|
+
opacity: 0.6;
|
|
896
|
+
cursor: not-allowed;
|
|
897
|
+
}
|
|
898
|
+
|
|
899
|
+
[part~='counter'] {
|
|
900
|
+
align-self: center;
|
|
901
|
+
font-size: 0.75em;
|
|
902
|
+
color: var(--chit-color-system-text);
|
|
903
|
+
font-variant-numeric: tabular-nums;
|
|
904
|
+
}
|
|
905
|
+
|
|
906
|
+
[part~='counter'][data-over] {
|
|
907
|
+
color: #d93025;
|
|
908
|
+
font-weight: 600;
|
|
909
|
+
}
|
|
910
|
+
|
|
911
|
+
[part~='send-button'] {
|
|
912
|
+
display: grid;
|
|
913
|
+
flex: none;
|
|
914
|
+
place-items: center;
|
|
915
|
+
width: 2.4em;
|
|
916
|
+
height: 2.4em;
|
|
917
|
+
padding: 0;
|
|
918
|
+
border: 0;
|
|
919
|
+
border-radius: 50%;
|
|
920
|
+
background: var(--chit-color-accent);
|
|
921
|
+
color: #fff;
|
|
922
|
+
cursor: pointer;
|
|
923
|
+
transition: opacity 120ms ease;
|
|
924
|
+
}
|
|
925
|
+
|
|
926
|
+
[part~='send-button'] svg {
|
|
927
|
+
width: 1.1em;
|
|
928
|
+
height: 1.1em;
|
|
929
|
+
}
|
|
930
|
+
|
|
931
|
+
[part~='send-button']:disabled {
|
|
932
|
+
opacity: 0.4;
|
|
933
|
+
cursor: default;
|
|
934
|
+
}
|
|
935
|
+
|
|
936
|
+
[part~='send-button']:focus-visible {
|
|
937
|
+
outline: 2px solid var(--chit-color-accent);
|
|
938
|
+
outline-offset: 2px;
|
|
939
|
+
}
|
|
940
|
+
|
|
941
|
+
[part~='spinner'] {
|
|
942
|
+
width: 1.1em;
|
|
943
|
+
height: 1.1em;
|
|
944
|
+
border: 2px solid currentColor;
|
|
945
|
+
border-top-color: transparent;
|
|
946
|
+
border-radius: 50%;
|
|
947
|
+
animation: chit-spin 0.7s linear infinite;
|
|
948
|
+
}
|
|
949
|
+
|
|
950
|
+
@keyframes chit-spin {
|
|
951
|
+
to {
|
|
952
|
+
transform: rotate(360deg);
|
|
953
|
+
}
|
|
954
|
+
}
|
|
955
|
+
|
|
956
|
+
@media (prefers-reduced-motion: reduce) {
|
|
957
|
+
[part~='spinner'] {
|
|
958
|
+
animation-duration: 2s;
|
|
959
|
+
}
|
|
960
|
+
}
|
|
961
|
+
`;class _e extends lt{static styles=[be,ve,ye,$e,we,xe];static properties={state:{type:String,reflect:!0,noAccessor:!0},theme:{type:Object},messages:{type:Array},typing:{type:Object},busy:{type:Boolean,reflect:!0},inputDisabled:{type:Boolean,reflect:!0,attribute:"input-disabled"},inputHidden:{type:Boolean,reflect:!0,attribute:"input-hidden"},placeholder:{type:String,reflect:!0},sendOnEnter:{type:Boolean,reflect:!0,attribute:"send-on-enter"},maxLength:{type:Number,reflect:!0,attribute:"max-length"},focusOnOpen:{type:String,reflect:!0,attribute:"focus-on-open"},locale:{type:String,reflect:!0},labels:{type:Object},messageStyles:{type:String}};#rt="closed";#at="api";#ht;#x;#lt;#ct;#dt;#pt=new Dt("data-chit-message-styles");#ut=new Map;#mt=null;constructor(){super(),this.theme={},this.messages=[],this.typing=!1,this.busy=!1,this.inputDisabled=!1,this.inputHidden=!1,this.placeholder=void 0,this.sendOnEnter=!0,this.maxLength=void 0,this.focusOnOpen="auto",this.locale=void 0,this.labels=void 0,this.messageStyles="",this.sanitize=void 0,this.formatTime=void 0,this.#ht=new xt(this,{animation:(t,e,s)=>this.#ft(t,e,s),keepsLauncher:()=>"visible"===this.currentTheme.open.launcher,onOpened:()=>this.#gt()}),this.#x=new _t(this),this.#lt=new qt(this,{device:()=>this.#x.device}),this.addController(this.#lt),this.#ct=new Ft(this,{behavior:()=>this.currentTheme.open.animation.scroll}),this.#dt=new Kt(this)}get state(){return this.#rt}set state(t){const e=this.#rt;if(t===e)return;if(this.#rt=t,this.requestUpdate("state",e),!this.#ht||this.#ht.applying)return;const s=this.#at;this.#at="api";const i=this.#ht.request(t,s);this.#mt=i,i.then(()=>{this.#mt===i&&(this.#mt=null)})}get device(){return this.#x.device}get currentTheme(){return this.#lt.current}get currentLabels(){return function(t,e){const s=(ge(t)||"en").toLowerCase(),i=fe[s]??fe[s.split("-")[0]]??fe.en;return e?{...i,...e}:i}(this.locale,this.labels)}get resolvedLocale(){return ge(this.locale)}get renderedState(){return this.#ht.renderedState}get hasUnseen(){return this.#ct.hasUnseen}get value(){return this.#dt.value}set value(t){this.#dt.value=t}get canSend(){return this.#dt.canSend}open(){return this.#bt("open","api")}close(){return this.#bt("closed","api")}hide(){return this.#bt("hidden","api")}show(){return"hidden"===this.#rt?this.#bt("closed","api"):Promise.resolve(!0)}toggle(){return this.#bt("open"===this.state?"closed":"open","api")}submit(t){return this.#dt.submit(t)}clearInput(){this.#dt.clear()}scrollToBottom(t){this.#ct.scrollToBottom(t)}getMessageElement(t){return this.renderRoot.querySelector(`[part~="message"][data-id="${CSS.escape(t)}"] [part~="message-content"]`)}focusInput(){const t=this.renderRoot.querySelector('[part~="input"]');return!!t&&(t.focus(),!0)}#gt(){if("never"===this.focusOnOpen)return;if("auto"===this.focusOnOpen&&"mobile"===this.device)return;if(this.focusInput())return;const t=this.renderRoot.querySelector('[part~="panel"]');t?.focus()}handleInput(t){this.#dt.onInput(t)}handleKeydown(t){this.#dt.onKeydown(t)}handleComposition(t){t?this.#dt.onCompositionStart():this.#dt.onCompositionEnd()}renderTypingHtml(t){return vt(this.sanitize?this.sanitize(t):t)}handleMessageClick(t){const e=t.composedPath(),s=e.find(t=>t instanceof HTMLElement&&t.getAttribute("part")?.split(/\s+/).includes("message"));if(!s)return;const i=s.dataset.id,n=this.messages.find(t=>t.id===i);if(!n)return;const o=e[0];$t(this,yt.MESSAGE_CLICK,{message:n,target:o,originalEvent:t},{cancelable:!0})||t.preventDefault()}toggleFromUser(){return this.#bt("open"===this.state?"closed":"open","user")}closeFromUser(){return this.#bt("closed","user")}#bt(t,e){return t!==this.#rt&&(this.#at=e,this.state=t),this.#mt??Promise.resolve(!0)}#ft(t,e,s){const i=this.currentTheme;if("exit"===s&&"hidden"===e)return{effect:i.hidden.animation.exit,duration:i.hidden.animation.duration};const n="open"===("exit"===s?t:e)?i.open:i.closed;return{effect:"exit"===s?n.animation.exit:n.animation.enter,duration:n.animation.duration}}willUpdate(){this.#x.observe(qt.breakpointOf(this.theme)),this.#lt.apply(this.theme,this.#x.device),this.#pt.write(this.messageStyles??"",this.renderRoot);const t=this.currentTheme;this.dataset.launcherPosition=t.closed.position,this.dataset.panelPosition=t.open.position,this.dataset.idle=t.closed.animation.idle}updated(){const t=new Set(this.messages.map(t=>t.id));!function(t,e){const s=Gt.get(t);if(s)for(const t of s.keys())t.startsWith("msg:")&&(e.has(t.slice(4))||s.delete(t))}(this,t),this.#vt(t)}#vt(t){for(const e of this.#ut.keys())t.has(e)||this.#ut.delete(e);for(const t of this.messages){const e=Zt(t);if(this.#ut.has(t.id)&&Object.is(this.#ut.get(t.id),e))continue;this.#ut.set(t.id,e);const s=this.getMessageElement(t.id);s&&$t(this,yt.MESSAGE_RENDER,{message:t,element:s,instance:Xt(this,t.id)})}}render(){const t=this.renderedState,e="closed"===t||"open"===t&&"visible"===this.currentTheme.open.launcher,s="open"===t;return q`
|
|
962
|
+
${e?ee(this):K} ${s?me(this):K}
|
|
963
|
+
`}}customElements.get("chit-ui")||customElements.define("chit-ui",_e);const Se=ft(class extends gt{constructor(t){if(super(t),t.type!==dt||"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(e=>t[e]).join(" ")+" "}update(t,[e]){if(void 0===this.st){this.st=new Set,void 0!==t.strings&&(this.nt=new Set(t.strings.join(" ").split(/\s/).filter(t=>""!==t)));for(const t in e)e[t]&&!this.nt?.has(t)&&this.st.add(t);return this.render(e)}const s=t.element.classList;for(const t of this.st)t in e||(s.remove(t),this.st.delete(t));for(const t in e){const i=!!e[t];i===this.st.has(t)||this.nt?.has(t)||(i?(s.add(t),this.st.add(t)):(s.remove(t),this.st.delete(t)))}return W}}),Ae="important",Ee=" !"+Ae,Ce=ft(class extends gt{constructor(t){if(super(t),t.type!==dt||"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,s)=>{const i=t[s];return null==i?e:e+`${s=s.includes("-")?s:s.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,"-$&").toLowerCase()}:${i};`},"")}update(t,[e]){const{style:s}=t.element;if(void 0===this.ft)return this.ft=new Set(Object.keys(e)),this.render(e);for(const t of this.ft)null==e[t]&&(this.ft.delete(t),t.includes("-")?s.removeProperty(t):s[t]=null);for(const t in e){const i=e[t];if(null!=i){this.ft.add(t);const e="string"==typeof i&&i.endsWith(Ee);t.includes("-")||e?s.setProperty(t,e?i.slice(0,-11):i,e?Ae:""):s[t]=i}}return W}});export{_e as ChitUI,yt as Events,lt as LitElement,Se as classMap,o as css,q as html,ue as live,K as nothing,at as render,de as repeat,Ce as styleMap,F as svg,vt as unsafeHTML};
|
|
964
|
+
//# sourceMappingURL=chit-ui.min.js.map
|