@kodaris/krubble-app-components 1.0.113 → 1.0.114

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.
@@ -8,18 +8,18 @@ import{KRContextMenu as e,KRDialog as t,KRSnackbar as i,KRFilePreview as s}from"
8
8
  * @license
9
9
  * Copyright 2017 Google LLC
10
10
  * SPDX-License-Identifier: BSD-3-Clause
11
- */,{is:p,defineProperty:u,getOwnPropertyDescriptor:g,getOwnPropertyNames:m,getOwnPropertySymbols:f,getPrototypeOf:b}=Object,v=globalThis,x=v.trustedTypes,_=x?x.emptyScript:"",k=v.reactiveElementPolyfillSupport,y=(e,t)=>e,w={toAttribute(e,t){switch(t){case Boolean:e=e?_:null;break;case Object:case Array:e=null==e?e:JSON.stringify(e)}return e},fromAttribute(e,t){let i=e;switch(t){case Boolean:i=null!==e;break;case Number:i=null===e?null:Number(e);break;case Object:case Array:try{i=JSON.parse(e)}catch(e){i=null}}return i}},$=(e,t)=>!p(e,t),S={attribute:!0,type:String,converter:w,reflect:!1,useDefault:!1,hasChanged:$};Symbol.metadata??=Symbol("metadata"),v.litPropertyMetadata??=new WeakMap;let I=class extends HTMLElement{static addInitializer(e){this._$Ei(),(this.l??=[]).push(e)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(e,t=S){if(t.state&&(t.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(e)&&((t=Object.create(t)).wrapped=!0),this.elementProperties.set(e,t),!t.noAccessor){const i=Symbol(),s=this.getPropertyDescriptor(e,i,t);void 0!==s&&u(this.prototype,e,s)}}static getPropertyDescriptor(e,t,i){const{get:s,set:n}=g(this.prototype,e)??{get(){return this[t]},set(e){this[t]=e}};return{get:s,set(t){const r=s?.call(this);n?.call(this,t),this.requestUpdate(e,r,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)??S}static _$Ei(){if(this.hasOwnProperty(y("elementProperties")))return;const e=b(this);e.finalize(),void 0!==e.l&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(y("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(y("properties"))){const e=this.properties,t=[...m(e),...f(e)];for(const i of t)this.createProperty(i,e[i])}const e=this[Symbol.metadata];if(null!==e){const t=litPropertyMetadata.get(e);if(void 0!==t)for(const[e,i]of t)this.elementProperties.set(e,i)}this._$Eh=new Map;for(const[e,t]of this.elementProperties){const i=this._$Eu(e,t);void 0!==i&&this._$Eh.set(i,e)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(e){const t=[];if(Array.isArray(e)){const i=new Set(e.flat(1/0).reverse());for(const e of i)t.unshift(d(e))}else void 0!==e&&t.push(d(e));return t}static _$Eu(e,t){const i=t.attribute;return!1===i?void 0:"string"==typeof i?i:"string"==typeof e?e.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((e=>this.enableUpdating=e)),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach((e=>e(this)))}addController(e){(this._$EO??=new Set).add(e),void 0!==this.renderRoot&&this.isConnected&&e.hostConnected?.()}removeController(e){this._$EO?.delete(e)}_$E_(){const e=new Map,t=this.constructor.elementProperties;for(const i of t.keys())this.hasOwnProperty(i)&&(e.set(i,this[i]),delete this[i]);e.size>0&&(this._$Ep=e)}createRenderRoot(){const e=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return((e,t)=>{if(o)e.adoptedStyleSheets=t.map((e=>e instanceof CSSStyleSheet?e:e.styleSheet));else for(const i of t){const t=document.createElement("style"),s=r.litNonce;void 0!==s&&t.setAttribute("nonce",s),t.textContent=i.cssText,e.appendChild(t)}})(e,this.constructor.elementStyles),e}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach((e=>e.hostConnected?.()))}enableUpdating(e){}disconnectedCallback(){this._$EO?.forEach((e=>e.hostDisconnected?.()))}attributeChangedCallback(e,t,i){this._$AK(e,i)}_$ET(e,t){const i=this.constructor.elementProperties.get(e),s=this.constructor._$Eu(e,i);if(void 0!==s&&!0===i.reflect){const n=(void 0!==i.converter?.toAttribute?i.converter:w).toAttribute(t,i.type);this._$Em=e,null==n?this.removeAttribute(s):this.setAttribute(s,n),this._$Em=null}}_$AK(e,t){const i=this.constructor,s=i._$Eh.get(e);if(void 0!==s&&this._$Em!==s){const e=i.getPropertyOptions(s),n="function"==typeof e.converter?{fromAttribute:e.converter}:void 0!==e.converter?.fromAttribute?e.converter:w;this._$Em=s;const r=n.fromAttribute(t,e.type);this[s]=r??this._$Ej?.get(s)??r,this._$Em=null}}requestUpdate(e,t,i,s=!1,n){if(void 0!==e){const r=this.constructor;if(!1===s&&(n=this[e]),i??=r.getPropertyOptions(e),!((i.hasChanged??$)(n,t)||i.useDefault&&i.reflect&&n===this._$Ej?.get(e)&&!this.hasAttribute(r._$Eu(e,i))))return;this.C(e,t,i)}!1===this.isUpdatePending&&(this._$ES=this._$EP())}C(e,t,{useDefault:i,reflect:s,wrapped:n},r){i&&!(this._$Ej??=new Map).has(e)&&(this._$Ej.set(e,r??t??this[e]),!0!==n||void 0!==r)||(this._$AL.has(e)||(this.hasUpdated||i||(t=void 0),this._$AL.set(e,t)),!0===s&&this._$Em!==e&&(this._$Eq??=new Set).add(e))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(e){Promise.reject(e)}const e=this.scheduleUpdate();return null!=e&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[e,t]of this._$Ep)this[e]=t;this._$Ep=void 0}const e=this.constructor.elementProperties;if(e.size>0)for(const[t,i]of e){const{wrapped:e}=i,s=this[t];!0!==e||this._$AL.has(t)||void 0===s||this.C(t,void 0,i,s)}}let e=!1;const t=this._$AL;try{e=this.shouldUpdate(t),e?(this.willUpdate(t),this._$EO?.forEach((e=>e.hostUpdate?.())),this.update(t)):this._$EM()}catch(t){throw e=!1,this._$EM(),t}e&&this._$AE(t)}willUpdate(e){}_$AE(e){this._$EO?.forEach((e=>e.hostUpdated?.())),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(e){return!0}update(e){this._$Eq&&=this._$Eq.forEach((e=>this._$ET(e,this[e]))),this._$EM()}updated(e){}firstUpdated(e){}};I.elementStyles=[],I.shadowRootOptions={mode:"open"},I[y("elementProperties")]=new Map,I[y("finalized")]=new Map,k?.({ReactiveElement:I}),(v.reactiveElementVersions??=[]).push("2.1.2");
11
+ */,{is:p,defineProperty:u,getOwnPropertyDescriptor:g,getOwnPropertyNames:m,getOwnPropertySymbols:f,getPrototypeOf:b}=Object,v=globalThis,_=v.trustedTypes,x=_?_.emptyScript:"",k=v.reactiveElementPolyfillSupport,w=(e,t)=>e,y={toAttribute(e,t){switch(t){case Boolean:e=e?x:null;break;case Object:case Array:e=null==e?e:JSON.stringify(e)}return e},fromAttribute(e,t){let i=e;switch(t){case Boolean:i=null!==e;break;case Number:i=null===e?null:Number(e);break;case Object:case Array:try{i=JSON.parse(e)}catch(e){i=null}}return i}},$=(e,t)=>!p(e,t),S={attribute:!0,type:String,converter:y,reflect:!1,useDefault:!1,hasChanged:$};Symbol.metadata??=Symbol("metadata"),v.litPropertyMetadata??=new WeakMap;let I=class extends HTMLElement{static addInitializer(e){this._$Ei(),(this.l??=[]).push(e)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(e,t=S){if(t.state&&(t.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(e)&&((t=Object.create(t)).wrapped=!0),this.elementProperties.set(e,t),!t.noAccessor){const i=Symbol(),s=this.getPropertyDescriptor(e,i,t);void 0!==s&&u(this.prototype,e,s)}}static getPropertyDescriptor(e,t,i){const{get:s,set:n}=g(this.prototype,e)??{get(){return this[t]},set(e){this[t]=e}};return{get:s,set(t){const r=s?.call(this);n?.call(this,t),this.requestUpdate(e,r,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)??S}static _$Ei(){if(this.hasOwnProperty(w("elementProperties")))return;const e=b(this);e.finalize(),void 0!==e.l&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(w("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(w("properties"))){const e=this.properties,t=[...m(e),...f(e)];for(const i of t)this.createProperty(i,e[i])}const e=this[Symbol.metadata];if(null!==e){const t=litPropertyMetadata.get(e);if(void 0!==t)for(const[e,i]of t)this.elementProperties.set(e,i)}this._$Eh=new Map;for(const[e,t]of this.elementProperties){const i=this._$Eu(e,t);void 0!==i&&this._$Eh.set(i,e)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(e){const t=[];if(Array.isArray(e)){const i=new Set(e.flat(1/0).reverse());for(const e of i)t.unshift(d(e))}else void 0!==e&&t.push(d(e));return t}static _$Eu(e,t){const i=t.attribute;return!1===i?void 0:"string"==typeof i?i:"string"==typeof e?e.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((e=>this.enableUpdating=e)),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach((e=>e(this)))}addController(e){(this._$EO??=new Set).add(e),void 0!==this.renderRoot&&this.isConnected&&e.hostConnected?.()}removeController(e){this._$EO?.delete(e)}_$E_(){const e=new Map,t=this.constructor.elementProperties;for(const i of t.keys())this.hasOwnProperty(i)&&(e.set(i,this[i]),delete this[i]);e.size>0&&(this._$Ep=e)}createRenderRoot(){const e=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return((e,t)=>{if(o)e.adoptedStyleSheets=t.map((e=>e instanceof CSSStyleSheet?e:e.styleSheet));else for(const i of t){const t=document.createElement("style"),s=r.litNonce;void 0!==s&&t.setAttribute("nonce",s),t.textContent=i.cssText,e.appendChild(t)}})(e,this.constructor.elementStyles),e}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach((e=>e.hostConnected?.()))}enableUpdating(e){}disconnectedCallback(){this._$EO?.forEach((e=>e.hostDisconnected?.()))}attributeChangedCallback(e,t,i){this._$AK(e,i)}_$ET(e,t){const i=this.constructor.elementProperties.get(e),s=this.constructor._$Eu(e,i);if(void 0!==s&&!0===i.reflect){const n=(void 0!==i.converter?.toAttribute?i.converter:y).toAttribute(t,i.type);this._$Em=e,null==n?this.removeAttribute(s):this.setAttribute(s,n),this._$Em=null}}_$AK(e,t){const i=this.constructor,s=i._$Eh.get(e);if(void 0!==s&&this._$Em!==s){const e=i.getPropertyOptions(s),n="function"==typeof e.converter?{fromAttribute:e.converter}:void 0!==e.converter?.fromAttribute?e.converter:y;this._$Em=s;const r=n.fromAttribute(t,e.type);this[s]=r??this._$Ej?.get(s)??r,this._$Em=null}}requestUpdate(e,t,i,s=!1,n){if(void 0!==e){const r=this.constructor;if(!1===s&&(n=this[e]),i??=r.getPropertyOptions(e),!((i.hasChanged??$)(n,t)||i.useDefault&&i.reflect&&n===this._$Ej?.get(e)&&!this.hasAttribute(r._$Eu(e,i))))return;this.C(e,t,i)}!1===this.isUpdatePending&&(this._$ES=this._$EP())}C(e,t,{useDefault:i,reflect:s,wrapped:n},r){i&&!(this._$Ej??=new Map).has(e)&&(this._$Ej.set(e,r??t??this[e]),!0!==n||void 0!==r)||(this._$AL.has(e)||(this.hasUpdated||i||(t=void 0),this._$AL.set(e,t)),!0===s&&this._$Em!==e&&(this._$Eq??=new Set).add(e))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(e){Promise.reject(e)}const e=this.scheduleUpdate();return null!=e&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[e,t]of this._$Ep)this[e]=t;this._$Ep=void 0}const e=this.constructor.elementProperties;if(e.size>0)for(const[t,i]of e){const{wrapped:e}=i,s=this[t];!0!==e||this._$AL.has(t)||void 0===s||this.C(t,void 0,i,s)}}let e=!1;const t=this._$AL;try{e=this.shouldUpdate(t),e?(this.willUpdate(t),this._$EO?.forEach((e=>e.hostUpdate?.())),this.update(t)):this._$EM()}catch(t){throw e=!1,this._$EM(),t}e&&this._$AE(t)}willUpdate(e){}_$AE(e){this._$EO?.forEach((e=>e.hostUpdated?.())),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(e){return!0}update(e){this._$Eq&&=this._$Eq.forEach((e=>this._$ET(e,this[e]))),this._$EM()}updated(e){}firstUpdated(e){}};I.elementStyles=[],I.shadowRootOptions={mode:"open"},I[w("elementProperties")]=new Map,I[w("finalized")]=new Map,k?.({ReactiveElement:I}),(v.reactiveElementVersions??=[]).push("2.1.2");
12
12
  /**
13
13
  * @license
14
14
  * Copyright 2017 Google LLC
15
15
  * SPDX-License-Identifier: BSD-3-Clause
16
16
  */
17
- const E=globalThis,C=E.trustedTypes,z=C?C.createPolicy("lit-html",{createHTML:e=>e}):void 0,A="$lit$",R=`lit$${Math.random().toFixed(9).slice(2)}$`,D="?"+R,T=`<${D}>`,M=document,N=()=>M.createComment(""),P=e=>null===e||"object"!=typeof e&&"function"!=typeof e,O=Array.isArray,F="[ \t\n\f\r]",U=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,L=/-->/g,H=/>/g,j=RegExp(`>|${F}(?:([^\\s"'>=/]+)(${F}*=${F}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),B=/'/g,q=/"/g,W=/^(?:script|style|textarea|title)$/i,X=(e=>(t,...i)=>({_$litType$:e,strings:t,values:i}))(1),Q=Symbol.for("lit-noChange"),V=Symbol.for("lit-nothing"),Y=new WeakMap,K=M.createTreeWalker(M,129);function Z(e,t){if(!O(e)||!e.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==z?z.createHTML(t):t}class G{constructor({strings:e,_$litType$:t},i){let s;this.parts=[];let n=0,r=0;const o=e.length-1,a=this.parts,[l,h]=((e,t)=>{const i=e.length-1,s=[];let n,r=2===t?"<svg>":3===t?"<math>":"",o=U;for(let t=0;t<i;t++){const i=e[t];let a,l,h=-1,c=0;for(;c<i.length&&(o.lastIndex=c,l=o.exec(i),null!==l);)c=o.lastIndex,o===U?"!--"===l[1]?o=L:void 0!==l[1]?o=H:void 0!==l[2]?(W.test(l[2])&&(n=RegExp("</"+l[2],"g")),o=j):void 0!==l[3]&&(o=j):o===j?">"===l[0]?(o=n??U,h=-1):void 0===l[1]?h=-2:(h=o.lastIndex-l[2].length,a=l[1],o=void 0===l[3]?j:'"'===l[3]?q:B):o===q||o===B?o=j:o===L||o===H?o=U:(o=j,n=void 0);const d=o===j&&e[t+1].startsWith("/>")?" ":"";r+=o===U?i+T:h>=0?(s.push(a),i.slice(0,h)+A+i.slice(h)+R+d):i+R+(-2===h?t:d)}return[Z(e,r+(e[i]||"<?>")+(2===t?"</svg>":3===t?"</math>":"")),s]})(e,t);if(this.el=G.createElement(l,i),K.currentNode=this.el.content,2===t||3===t){const e=this.el.content.firstChild;e.replaceWith(...e.childNodes)}for(;null!==(s=K.nextNode())&&a.length<o;){if(1===s.nodeType){if(s.hasAttributes())for(const e of s.getAttributeNames())if(e.endsWith(A)){const t=h[r++],i=s.getAttribute(e).split(R),o=/([.?@])?(.*)/.exec(t);a.push({type:1,index:n,name:o[2],strings:i,ctor:"."===o[1]?se:"?"===o[1]?ne:"@"===o[1]?re:ie}),s.removeAttribute(e)}else e.startsWith(R)&&(a.push({type:6,index:n}),s.removeAttribute(e));if(W.test(s.tagName)){const e=s.textContent.split(R),t=e.length-1;if(t>0){s.textContent=C?C.emptyScript:"";for(let i=0;i<t;i++)s.append(e[i],N()),K.nextNode(),a.push({type:2,index:++n});s.append(e[t],N())}}}else if(8===s.nodeType)if(s.data===D)a.push({type:2,index:n});else{let e=-1;for(;-1!==(e=s.data.indexOf(R,e+1));)a.push({type:7,index:n}),e+=R.length-1}n++}}static createElement(e,t){const i=M.createElement("template");return i.innerHTML=e,i}}function J(e,t,i=e,s){if(t===Q)return t;let n=void 0!==s?i._$Co?.[s]:i._$Cl;const r=P(t)?void 0:t._$litDirective$;return n?.constructor!==r&&(n?._$AO?.(!1),void 0===r?n=void 0:(n=new r(e),n._$AT(e,i,s)),void 0!==s?(i._$Co??=[])[s]=n:i._$Cl=n),void 0!==n&&(t=J(e,n._$AS(e,t.values),n,s)),t}class ee{constructor(e,t){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=t}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){const{el:{content:t},parts:i}=this._$AD,s=(e?.creationScope??M).importNode(t,!0);K.currentNode=s;let n=K.nextNode(),r=0,o=0,a=i[0];for(;void 0!==a;){if(r===a.index){let t;2===a.type?t=new te(n,n.nextSibling,this,e):1===a.type?t=new a.ctor(n,a.name,a.strings,this,e):6===a.type&&(t=new oe(n,this,e)),this._$AV.push(t),a=i[++o]}r!==a?.index&&(n=K.nextNode(),r++)}return K.currentNode=M,s}p(e){let t=0;for(const i of this._$AV)void 0!==i&&(void 0!==i.strings?(i._$AI(e,i,t),t+=i.strings.length-2):i._$AI(e[t])),t++}}class te{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(e,t,i,s){this.type=2,this._$AH=V,this._$AN=void 0,this._$AA=e,this._$AB=t,this._$AM=i,this.options=s,this._$Cv=s?.isConnected??!0}get parentNode(){let e=this._$AA.parentNode;const t=this._$AM;return void 0!==t&&11===e?.nodeType&&(e=t.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,t=this){e=J(this,e,t),P(e)?e===V||null==e||""===e?(this._$AH!==V&&this._$AR(),this._$AH=V):e!==this._$AH&&e!==Q&&this._(e):void 0!==e._$litType$?this.$(e):void 0!==e.nodeType?this.T(e):(e=>O(e)||"function"==typeof e?.[Symbol.iterator])(e)?this.k(e):this._(e)}O(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}T(e){this._$AH!==e&&(this._$AR(),this._$AH=this.O(e))}_(e){this._$AH!==V&&P(this._$AH)?this._$AA.nextSibling.data=e:this.T(M.createTextNode(e)),this._$AH=e}$(e){const{values:t,_$litType$:i}=e,s="number"==typeof i?this._$AC(e):(void 0===i.el&&(i.el=G.createElement(Z(i.h,i.h[0]),this.options)),i);if(this._$AH?._$AD===s)this._$AH.p(t);else{const e=new ee(s,this),i=e.u(this.options);e.p(t),this.T(i),this._$AH=e}}_$AC(e){let t=Y.get(e.strings);return void 0===t&&Y.set(e.strings,t=new G(e)),t}k(e){O(this._$AH)||(this._$AH=[],this._$AR());const t=this._$AH;let i,s=0;for(const n of e)s===t.length?t.push(i=new te(this.O(N()),this.O(N()),this,this.options)):i=t[s],i._$AI(n),s++;s<t.length&&(this._$AR(i&&i._$AB.nextSibling,s),t.length=s)}_$AR(e=this._$AA.nextSibling,t){for(this._$AP?.(!1,!0,t);e!==this._$AB;){const t=e.nextSibling;e.remove(),e=t}}setConnected(e){void 0===this._$AM&&(this._$Cv=e,this._$AP?.(e))}}class ie{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,t,i,s,n){this.type=1,this._$AH=V,this._$AN=void 0,this.element=e,this.name=t,this._$AM=s,this.options=n,i.length>2||""!==i[0]||""!==i[1]?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=V}_$AI(e,t=this,i,s){const n=this.strings;let r=!1;if(void 0===n)e=J(this,e,t,0),r=!P(e)||e!==this._$AH&&e!==Q,r&&(this._$AH=e);else{const s=e;let o,a;for(e=n[0],o=0;o<n.length-1;o++)a=J(this,s[i+o],t,o),a===Q&&(a=this._$AH[o]),r||=!P(a)||a!==this._$AH[o],a===V?e=V:e!==V&&(e+=(a??"")+n[o+1]),this._$AH[o]=a}r&&!s&&this.j(e)}j(e){e===V?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??"")}}class se extends ie{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===V?void 0:e}}class ne extends ie{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==V)}}class re extends ie{constructor(e,t,i,s,n){super(e,t,i,s,n),this.type=5}_$AI(e,t=this){if((e=J(this,e,t,0)??V)===Q)return;const i=this._$AH,s=e===V&&i!==V||e.capture!==i.capture||e.once!==i.once||e.passive!==i.passive,n=e!==V&&(i===V||s);s&&this.element.removeEventListener(this.name,this,i),n&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){"function"==typeof this._$AH?this._$AH.call(this.options?.host??this.element,e):this._$AH.handleEvent(e)}}class oe{constructor(e,t,i){this.element=e,this.type=6,this._$AN=void 0,this._$AM=t,this.options=i}get _$AU(){return this._$AM._$AU}_$AI(e){J(this,e)}}const ae={I:te},le=E.litHtmlPolyfillSupport;le?.(G,te),(E.litHtmlVersions??=[]).push("3.3.2");const he=globalThis;
17
+ const E=globalThis,C=E.trustedTypes,A=C?C.createPolicy("lit-html",{createHTML:e=>e}):void 0,z="$lit$",T=`lit$${Math.random().toFixed(9).slice(2)}$`,R="?"+T,M=`<${R}>`,D=document,O=()=>D.createComment(""),N=e=>null===e||"object"!=typeof e&&"function"!=typeof e,P=Array.isArray,L="[ \t\n\f\r]",F=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,U=/-->/g,j=/>/g,H=RegExp(`>|${L}(?:([^\\s"'>=/]+)(${L}*=${L}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),B=/'/g,q=/"/g,W=/^(?:script|style|textarea|title)$/i,V=(e=>(t,...i)=>({_$litType$:e,strings:t,values:i}))(1),X=Symbol.for("lit-noChange"),Q=Symbol.for("lit-nothing"),Y=new WeakMap,K=D.createTreeWalker(D,129);function Z(e,t){if(!P(e)||!e.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==A?A.createHTML(t):t}class G{constructor({strings:e,_$litType$:t},i){let s;this.parts=[];let n=0,r=0;const o=e.length-1,a=this.parts,[l,h]=((e,t)=>{const i=e.length-1,s=[];let n,r=2===t?"<svg>":3===t?"<math>":"",o=F;for(let t=0;t<i;t++){const i=e[t];let a,l,h=-1,c=0;for(;c<i.length&&(o.lastIndex=c,l=o.exec(i),null!==l);)c=o.lastIndex,o===F?"!--"===l[1]?o=U:void 0!==l[1]?o=j:void 0!==l[2]?(W.test(l[2])&&(n=RegExp("</"+l[2],"g")),o=H):void 0!==l[3]&&(o=H):o===H?">"===l[0]?(o=n??F,h=-1):void 0===l[1]?h=-2:(h=o.lastIndex-l[2].length,a=l[1],o=void 0===l[3]?H:'"'===l[3]?q:B):o===q||o===B?o=H:o===U||o===j?o=F:(o=H,n=void 0);const d=o===H&&e[t+1].startsWith("/>")?" ":"";r+=o===F?i+M:h>=0?(s.push(a),i.slice(0,h)+z+i.slice(h)+T+d):i+T+(-2===h?t:d)}return[Z(e,r+(e[i]||"<?>")+(2===t?"</svg>":3===t?"</math>":"")),s]})(e,t);if(this.el=G.createElement(l,i),K.currentNode=this.el.content,2===t||3===t){const e=this.el.content.firstChild;e.replaceWith(...e.childNodes)}for(;null!==(s=K.nextNode())&&a.length<o;){if(1===s.nodeType){if(s.hasAttributes())for(const e of s.getAttributeNames())if(e.endsWith(z)){const t=h[r++],i=s.getAttribute(e).split(T),o=/([.?@])?(.*)/.exec(t);a.push({type:1,index:n,name:o[2],strings:i,ctor:"."===o[1]?se:"?"===o[1]?ne:"@"===o[1]?re:ie}),s.removeAttribute(e)}else e.startsWith(T)&&(a.push({type:6,index:n}),s.removeAttribute(e));if(W.test(s.tagName)){const e=s.textContent.split(T),t=e.length-1;if(t>0){s.textContent=C?C.emptyScript:"";for(let i=0;i<t;i++)s.append(e[i],O()),K.nextNode(),a.push({type:2,index:++n});s.append(e[t],O())}}}else if(8===s.nodeType)if(s.data===R)a.push({type:2,index:n});else{let e=-1;for(;-1!==(e=s.data.indexOf(T,e+1));)a.push({type:7,index:n}),e+=T.length-1}n++}}static createElement(e,t){const i=D.createElement("template");return i.innerHTML=e,i}}function J(e,t,i=e,s){if(t===X)return t;let n=void 0!==s?i._$Co?.[s]:i._$Cl;const r=N(t)?void 0:t._$litDirective$;return n?.constructor!==r&&(n?._$AO?.(!1),void 0===r?n=void 0:(n=new r(e),n._$AT(e,i,s)),void 0!==s?(i._$Co??=[])[s]=n:i._$Cl=n),void 0!==n&&(t=J(e,n._$AS(e,t.values),n,s)),t}class ee{constructor(e,t){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=t}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){const{el:{content:t},parts:i}=this._$AD,s=(e?.creationScope??D).importNode(t,!0);K.currentNode=s;let n=K.nextNode(),r=0,o=0,a=i[0];for(;void 0!==a;){if(r===a.index){let t;2===a.type?t=new te(n,n.nextSibling,this,e):1===a.type?t=new a.ctor(n,a.name,a.strings,this,e):6===a.type&&(t=new oe(n,this,e)),this._$AV.push(t),a=i[++o]}r!==a?.index&&(n=K.nextNode(),r++)}return K.currentNode=D,s}p(e){let t=0;for(const i of this._$AV)void 0!==i&&(void 0!==i.strings?(i._$AI(e,i,t),t+=i.strings.length-2):i._$AI(e[t])),t++}}class te{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(e,t,i,s){this.type=2,this._$AH=Q,this._$AN=void 0,this._$AA=e,this._$AB=t,this._$AM=i,this.options=s,this._$Cv=s?.isConnected??!0}get parentNode(){let e=this._$AA.parentNode;const t=this._$AM;return void 0!==t&&11===e?.nodeType&&(e=t.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,t=this){e=J(this,e,t),N(e)?e===Q||null==e||""===e?(this._$AH!==Q&&this._$AR(),this._$AH=Q):e!==this._$AH&&e!==X&&this._(e):void 0!==e._$litType$?this.$(e):void 0!==e.nodeType?this.T(e):(e=>P(e)||"function"==typeof e?.[Symbol.iterator])(e)?this.k(e):this._(e)}O(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}T(e){this._$AH!==e&&(this._$AR(),this._$AH=this.O(e))}_(e){this._$AH!==Q&&N(this._$AH)?this._$AA.nextSibling.data=e:this.T(D.createTextNode(e)),this._$AH=e}$(e){const{values:t,_$litType$:i}=e,s="number"==typeof i?this._$AC(e):(void 0===i.el&&(i.el=G.createElement(Z(i.h,i.h[0]),this.options)),i);if(this._$AH?._$AD===s)this._$AH.p(t);else{const e=new ee(s,this),i=e.u(this.options);e.p(t),this.T(i),this._$AH=e}}_$AC(e){let t=Y.get(e.strings);return void 0===t&&Y.set(e.strings,t=new G(e)),t}k(e){P(this._$AH)||(this._$AH=[],this._$AR());const t=this._$AH;let i,s=0;for(const n of e)s===t.length?t.push(i=new te(this.O(O()),this.O(O()),this,this.options)):i=t[s],i._$AI(n),s++;s<t.length&&(this._$AR(i&&i._$AB.nextSibling,s),t.length=s)}_$AR(e=this._$AA.nextSibling,t){for(this._$AP?.(!1,!0,t);e!==this._$AB;){const t=e.nextSibling;e.remove(),e=t}}setConnected(e){void 0===this._$AM&&(this._$Cv=e,this._$AP?.(e))}}class ie{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,t,i,s,n){this.type=1,this._$AH=Q,this._$AN=void 0,this.element=e,this.name=t,this._$AM=s,this.options=n,i.length>2||""!==i[0]||""!==i[1]?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=Q}_$AI(e,t=this,i,s){const n=this.strings;let r=!1;if(void 0===n)e=J(this,e,t,0),r=!N(e)||e!==this._$AH&&e!==X,r&&(this._$AH=e);else{const s=e;let o,a;for(e=n[0],o=0;o<n.length-1;o++)a=J(this,s[i+o],t,o),a===X&&(a=this._$AH[o]),r||=!N(a)||a!==this._$AH[o],a===Q?e=Q:e!==Q&&(e+=(a??"")+n[o+1]),this._$AH[o]=a}r&&!s&&this.j(e)}j(e){e===Q?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??"")}}class se extends ie{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===Q?void 0:e}}class ne extends ie{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==Q)}}class re extends ie{constructor(e,t,i,s,n){super(e,t,i,s,n),this.type=5}_$AI(e,t=this){if((e=J(this,e,t,0)??Q)===X)return;const i=this._$AH,s=e===Q&&i!==Q||e.capture!==i.capture||e.once!==i.once||e.passive!==i.passive,n=e!==Q&&(i===Q||s);s&&this.element.removeEventListener(this.name,this,i),n&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){"function"==typeof this._$AH?this._$AH.call(this.options?.host??this.element,e):this._$AH.handleEvent(e)}}class oe{constructor(e,t,i){this.element=e,this.type=6,this._$AN=void 0,this._$AM=t,this.options=i}get _$AU(){return this._$AM._$AU}_$AI(e){J(this,e)}}const ae={I:te},le=E.litHtmlPolyfillSupport;le?.(G,te),(E.litHtmlVersions??=[]).push("3.3.2");const he=globalThis;
18
18
  /**
19
19
  * @license
20
20
  * Copyright 2017 Google LLC
21
21
  * SPDX-License-Identifier: BSD-3-Clause
22
- */let ce=class extends I{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){const e=super.createRenderRoot();return this.renderOptions.renderBefore??=e.firstChild,e}update(e){const t=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=((e,t,i)=>{const s=i?.renderBefore??t;let n=s._$litPart$;if(void 0===n){const e=i?.renderBefore??null;s._$litPart$=n=new te(t.insertBefore(N(),e),e,void 0,i??{})}return n._$AI(e),n})(t,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return Q}};ce._$litElement$=!0,ce.finalized=!0,he.litElementHydrateSupport?.({LitElement:ce});const de=he.litElementPolyfillSupport;de?.({LitElement:ce}),(he.litElementVersions??=[]).push("4.2.2");
22
+ */let ce=class extends I{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){const e=super.createRenderRoot();return this.renderOptions.renderBefore??=e.firstChild,e}update(e){const t=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=((e,t,i)=>{const s=i?.renderBefore??t;let n=s._$litPart$;if(void 0===n){const e=i?.renderBefore??null;s._$litPart$=n=new te(t.insertBefore(O(),e),e,void 0,i??{})}return n._$AI(e),n})(t,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return X}};ce._$litElement$=!0,ce.finalized=!0,he.litElementHydrateSupport?.({LitElement:ce});const de=he.litElementPolyfillSupport;de?.({LitElement:ce}),(he.litElementVersions??=[]).push("4.2.2");
23
23
  /**
24
24
  * @license
25
25
  * Copyright 2017 Google LLC
@@ -30,7 +30,7 @@ const pe=e=>(t,i)=>{void 0!==i?i.addInitializer((()=>{customElements.define(e,t)
30
30
  * @license
31
31
  * Copyright 2017 Google LLC
32
32
  * SPDX-License-Identifier: BSD-3-Clause
33
- */,ue={attribute:!0,type:String,converter:w,reflect:!1,hasChanged:$},ge=(e=ue,t,i)=>{const{kind:s,metadata:n}=i;let r=globalThis.litPropertyMetadata.get(n);if(void 0===r&&globalThis.litPropertyMetadata.set(n,r=new Map),"setter"===s&&((e=Object.create(e)).wrapped=!0),r.set(i.name,e),"accessor"===s){const{name:s}=i;return{set(i){const n=t.get.call(this);t.set.call(this,i),this.requestUpdate(s,n,e,!0,i)},init(t){return void 0!==t&&this.C(s,void 0,e,t),t}}}if("setter"===s){const{name:s}=i;return function(i){const n=this[s];t.call(this,i),this.requestUpdate(s,n,e,!0,i)}}throw Error("Unsupported decorator location: "+s)};function me(e){return(t,i)=>"object"==typeof i?ge(e,t,i):((e,t,i)=>{const s=t.hasOwnProperty(i);return t.constructor.createProperty(i,e),s?Object.getOwnPropertyDescriptor(t,i):void 0})(e,t,i)
33
+ */,ue={attribute:!0,type:String,converter:y,reflect:!1,hasChanged:$},ge=(e=ue,t,i)=>{const{kind:s,metadata:n}=i;let r=globalThis.litPropertyMetadata.get(n);if(void 0===r&&globalThis.litPropertyMetadata.set(n,r=new Map),"setter"===s&&((e=Object.create(e)).wrapped=!0),r.set(i.name,e),"accessor"===s){const{name:s}=i;return{set(i){const n=t.get.call(this);t.set.call(this,i),this.requestUpdate(s,n,e,!0,i)},init(t){return void 0!==t&&this.C(s,void 0,e,t),t}}}if("setter"===s){const{name:s}=i;return function(i){const n=this[s];t.call(this,i),this.requestUpdate(s,n,e,!0,i)}}throw Error("Unsupported decorator location: "+s)};function me(e){return(t,i)=>"object"==typeof i?ge(e,t,i):((e,t,i)=>{const s=t.hasOwnProperty(i);return t.constructor.createProperty(i,e),s?Object.getOwnPropertyDescriptor(t,i):void 0})(e,t,i)
34
34
  /**
35
35
  * @license
36
36
  * Copyright 2017 Google LLC
@@ -51,17 +51,17 @@ function be(e,t){return(t,i,s)=>((e,t,i)=>(i.configurable=!0,i.enumerable=!0,Ref
51
51
  * @license
52
52
  * Copyright 2017 Google LLC
53
53
  * SPDX-License-Identifier: BSD-3-Clause
54
- */const ve=1,xe=2,_e=e=>(...t)=>({_$litDirective$:e,values:t});let ke=class{constructor(e){}get _$AU(){return this._$AM._$AU}_$AT(e,t,i){this._$Ct=e,this._$AM=t,this._$Ci=i}_$AS(e,t){return this.update(e,t)}update(e,t){return this.render(...t)}},ye=class extends ke{constructor(e){if(super(e),this.it=V,e.type!==xe)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(e){if(e===V||null==e)return this._t=void 0,this.it=e;if(e===Q)return e;if("string"!=typeof e)throw Error(this.constructor.directiveName+"() called with a non-string value");if(e===this.it)return this._t;this.it=e;const t=[e];return t.raw=t,this._t={_$litType$:this.constructor.resultType,strings:t,values:[]}}};
54
+ */const ve=1,_e=2,xe=e=>(...t)=>({_$litDirective$:e,values:t});let ke=class{constructor(e){}get _$AU(){return this._$AM._$AU}_$AT(e,t,i){this._$Ct=e,this._$AM=t,this._$Ci=i}_$AS(e,t){return this.update(e,t)}update(e,t){return this.render(...t)}},we=class extends ke{constructor(e){if(super(e),this.it=Q,e.type!==_e)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(e){if(e===Q||null==e)return this._t=void 0,this.it=e;if(e===X)return e;if("string"!=typeof e)throw Error(this.constructor.directiveName+"() called with a non-string value");if(e===this.it)return this._t;this.it=e;const t=[e];return t.raw=t,this._t={_$litType$:this.constructor.resultType,strings:t,values:[]}}};
55
55
  /**
56
56
  * @license
57
57
  * Copyright 2017 Google LLC
58
58
  * SPDX-License-Identifier: BSD-3-Clause
59
- */ye.directiveName="unsafeHTML",ye.resultType=1;const we=_e(ye),$e=_e(class extends ke{constructor(e){if(super(e),e.type!==ve||"class"!==e.name||e.strings?.length>2)throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.")}render(e){return" "+Object.keys(e).filter((t=>e[t])).join(" ")+" "}update(e,[t]){if(void 0===this.st){this.st=new Set,void 0!==e.strings&&(this.nt=new Set(e.strings.join(" ").split(/\s/).filter((e=>""!==e))));for(const e in t)t[e]&&!this.nt?.has(e)&&this.st.add(e);return this.render(t)}const i=e.element.classList;for(const e of this.st)e in t||(i.remove(e),this.st.delete(e));for(const e in t){const s=!!t[e];s===this.st.has(e)||this.nt?.has(e)||(s?(i.add(e),this.st.add(e)):(i.remove(e),this.st.delete(e)))}return Q}});
59
+ */we.directiveName="unsafeHTML",we.resultType=1;const ye=xe(we),$e=xe(class extends ke{constructor(e){if(super(e),e.type!==ve||"class"!==e.name||e.strings?.length>2)throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.")}render(e){return" "+Object.keys(e).filter((t=>e[t])).join(" ")+" "}update(e,[t]){if(void 0===this.st){this.st=new Set,void 0!==e.strings&&(this.nt=new Set(e.strings.join(" ").split(/\s/).filter((e=>""!==e))));for(const e in t)t[e]&&!this.nt?.has(e)&&this.st.add(e);return this.render(t)}const i=e.element.classList;for(const e of this.st)e in t||(i.remove(e),this.st.delete(e));for(const e in t){const s=!!t[e];s===this.st.has(e)||this.nt?.has(e)||(s?(i.add(e),this.st.add(e)):(i.remove(e),this.st.delete(e)))}return X}});
60
60
  /**
61
61
  * @license
62
62
  * Copyright 2018 Google LLC
63
63
  * SPDX-License-Identifier: BSD-3-Clause
64
- */var Se=function(e,t,i,s){var n,r=arguments.length,o=r<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,i,s);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(o=(r<3?n(o):r>3?n(t,i,o):n(t,i))||o);return r>3&&o&&Object.defineProperty(t,i,o),o};let Ie=class extends ce{constructor(){super(...arguments),this.label="",this.icon="",this.url="",this.active=!0}connectedCallback(){super.connectedCallback(),this.data&&(this.label=this.data.label||"",this.icon=this.data.icon||"",this.url=this.data.url||"",this.active=!1!==this.data.active)}handleLabelInput(e){const t=e.target;this.label=t.value}handleIconInput(e){const t=e.target;this.icon=t.value}handleUrlInput(e){const t=e.target;this.url=t.value}handleActiveChange(e){this.active=e.target.checked}handleCancel(){this.dialogRef.close(void 0)}handleSave(){this.dialogRef.close({label:this.label,icon:this.icon||void 0,url:this.url||void 0,active:this.active})}handleKeyDown(e){"Enter"===e.key&&this.handleSave()}render(){return X`
64
+ */var Se=function(e,t,i,s){var n,r=arguments.length,o=r<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,i,s);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(o=(r<3?n(o):r>3?n(t,i,o):n(t,i))||o);return r>3&&o&&Object.defineProperty(t,i,o),o};let Ie=class extends ce{constructor(){super(...arguments),this.label="",this.icon="",this.url="",this.active=!0}connectedCallback(){super.connectedCallback(),this.data&&(this.label=this.data.label||"",this.icon=this.data.icon||"",this.url=this.data.url||"",this.active=!1!==this.data.active)}handleLabelInput(e){const t=e.target;this.label=t.value}handleIconInput(e){const t=e.target;this.icon=t.value}handleUrlInput(e){const t=e.target;this.url=t.value}handleActiveChange(e){this.active=e.target.checked}handleCancel(){this.dialogRef.close(void 0)}handleSave(){this.dialogRef.close({label:this.label,icon:this.icon||void 0,url:this.url||void 0,active:this.active})}handleKeyDown(e){"Enter"===e.key&&this.handleSave()}render(){return V`
65
65
  <h2>Edit Navigation Item</h2>
66
66
 
67
67
  <div class="form-group">
@@ -198,26 +198,26 @@ function be(e,t){return(t,i,s)=>((e,t,i)=>(i.configurable=!0,i.enumerable=!0,Ref
198
198
  .btn-save:hover {
199
199
  background: #d4f472;
200
200
  }
201
- `,Se([fe()],Ie.prototype,"label",void 0),Se([fe()],Ie.prototype,"icon",void 0),Se([fe()],Ie.prototype,"url",void 0),Se([fe()],Ie.prototype,"active",void 0),Ie=Se([pe("kr-nav-item-edit")],Ie);var Ee=function(e,t,i,s){var n,r=arguments.length,o=r<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,i,s);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(o=(r<3?n(o):r>3?n(t,i,o):n(t,i))||o);return r>3&&o&&Object.defineProperty(t,i,o),o};let Ce=class extends ce{constructor(){super(),this.defaultNavItemIcon='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><circle cx="12" cy="12" r="10"/></svg>',this.originalFetch=null,this.originalXhrOpen=null,this.navItemDragPreview=null,this.navItemDragStartY=0,this.isNavItemDragging=!1,this.navItemDragExpandTimeout=null,this.navInitialized=!1,this.logo="",this.label="",this.homeUrl="/",this.scheme="light",this.nav=[],this.navIconsDisplayed=!1,this.navExpanded=!1,this.user=null,this.subbar=!1,this.navEnabled=!0,this.userType="employee",this.breadcrumbs=[],this.navItemsExpanded=new Set,this.navQuery="",this.activeNavItemId=null,this.isNavScrolled=!1,this.isNavOpened="false"!==localStorage.getItem("kr-scaffold-nav-opened"),this.isEditing=!1,this.isUserMenuOpen=!1,this.pref={nav:{}},this.draggedNavItemId=null,this.navItemDropTargetId=null,this.navItemDropPosition="above",this.pendingRequests=0,this.boundHandleMouseMove=this.handleMouseMove.bind(this),this.boundHandleMouseUp=this.handleMouseUp.bind(this)}connectedCallback(){super.connectedCallback(),this.installFetchInterceptor()}firstUpdated(){this.loadPref()}updated(e){super.updated(e),e.has("nav")&&this.nav.length>0&&(this.updateActiveNavItem(),this.navExpanded&&!this.navInitialized&&(this.navInitialized=!0,this.getComputedNav().filter((e=>"group"===e.type)).forEach((e=>this.navItemsExpanded.add(e.id)))))}disconnectedCallback(){super.disconnectedCallback(),this.uninstallFetchInterceptor()}installFetchInterceptor(){if(this.originalFetch)return;const e=this;this.originalFetch=window.fetch.bind(window);const t=this.originalFetch;window.fetch=function(...i){return e.pendingRequests++,t(...i).finally((()=>{e.pendingRequests--}))},this.originalXhrOpen=XMLHttpRequest.prototype.open;const i=this.originalXhrOpen;XMLHttpRequest.prototype.open=function(t,s,n=!0,r,o){return e.pendingRequests++,this.addEventListener("loadend",(()=>{e.pendingRequests--}),{once:!0}),i.call(this,t,s,n,r,o)}}uninstallFetchInterceptor(){this.originalFetch&&(window.fetch=this.originalFetch,this.originalFetch=null),this.originalXhrOpen&&(XMLHttpRequest.prototype.open=this.originalXhrOpen,this.originalXhrOpen=null)}resolveUrl(e){if(!e.url)return"#";if(e.external)return e.url;let t=e.url;e.url.startsWith("/")&&(t=e.url.slice(1));const i=document.querySelector("base")?.getAttribute("href")||"/";return i.endsWith("/")?i+t:i+"/"+t}getComputedNav(){const e=[];return this.nav.forEach(((t,i)=>{const s=this.pref.nav[t.id];e.push({...t,...s,order:s?.order??t.order??i,parentId:s?.parentId??null}),"group"===t.type&&t.children&&t.children.forEach(((i,s)=>{const n=this.pref.nav[i.id];let r=t.id;void 0!==n?.parentId&&(r=n.parentId),e.push({...i,...n,order:n?.order??i.order??s,parentId:r})}))})),Object.entries(this.pref.nav).forEach((([t,i])=>{t.startsWith("custom")&&i.type&&i.label&&e.push({id:t,type:i.type,label:i.label,icon:i.icon,url:i.url,active:i.active,order:i.order??e.length,parentId:i.parentId??null})})),e}getNavItemChildren(e){let t=this.getComputedNav().filter((t=>t.parentId===e)).sort(((e,t)=>e.order-t.order));if(this.isEditing||(t=t.filter((e=>!1!==e.active))),this.navQuery){const i=this.navQuery.toLowerCase(),s=this.getComputedNav();if(null!==e){const n=s.find((t=>t.id===e));if(n?.label.toLowerCase().includes(i))return t}t=t.filter((e=>"group"===e.type?e.label.toLowerCase().includes(i)||s.some((t=>t.parentId===e.id&&!1!==t.active&&t.label.toLowerCase().includes(i))):e.label.toLowerCase().includes(i)))}return t}handleNavQueryChange(e){this.navQuery=e.target.value,this.navQuery?this.getComputedNav().forEach((e=>{"group"===e.type&&this.navItemsExpanded.add(e.id)})):this.navItemsExpanded.clear()}handleNavQueryClear(){this.navQuery="",this.navItemsExpanded.clear()}handleMenuClick(){this.isNavOpened=!this.isNavOpened,localStorage.setItem("kr-scaffold-nav-opened",String(this.isNavOpened))}handleNavHeaderClick(){this.activeNavItemId=null;const e=new CustomEvent("nav-item-click",{detail:{item:{url:this.homeUrl}},bubbles:!0,composed:!0,cancelable:!0});this.dispatchEvent(e),e.defaultPrevented||(window.location.href=this.homeUrl)}handleNavScroll(e){this.isNavScrolled=e.target.scrollTop>0}expandNavGroup(e){this.navItemsExpanded.has(e)||(this.navItemsExpanded.add(e),this.requestUpdate())}handleNavItemClick(e,t){if("group"===t.type){const e=this.shadowRoot?.querySelector(`.nav-item[data-id="${t.id}"]`),i=e?.nextElementSibling;if(!i)return;this.navItemsExpanded.has(t.id)?(this.navItemsExpanded.delete(t.id),i.animate([{height:`${i.scrollHeight}px`},{height:"0px"}],{duration:300,easing:"ease-in-out"}).onfinish=()=>{i.classList.remove("nav-group--expanded")}):(this.navItemsExpanded.add(t.id),i.classList.add("nav-group--expanded"),i.animate([{height:"0px"},{height:`${i.scrollHeight}px`}],{duration:300,easing:"ease-in-out"})),this.requestUpdate()}else{if(e.ctrlKey||e.metaKey||1===e.button)return;this.activeNavItemId=t.id;const i=new CustomEvent("nav-item-click",{detail:{item:t},bubbles:!0,composed:!0,cancelable:!0});this.dispatchEvent(i),i.defaultPrevented&&e.preventDefault()}}updateActiveNavItem(){const e=window.location.pathname,t=this.getComputedNav().filter((e=>"item"===e.type&&e.url));let i=null,s=0;for(const n of t){const t=this.resolveUrl(n);e.startsWith(t)&&t.length>s&&(i=n,s=t.length)}i?(this.activeNavItemId=i.id,i.parentId&&this.navItemsExpanded.add(i.parentId)):this.activeNavItemId=null}handleEditCancel(){this.isEditing=!1,this.loadPref()}handlePrefReset(){this.pref.nav={}}handlePrefSave(){if("customer"===this.userType)return;let e="/api/system/preference/json/scaffold?global=true",t="POST";this.pref.uuid&&(e=`/api/system/preference/json/scaffold/${this.pref.uuid}?global=true`,t="PUT"),n.fetch({url:e,method:t,body:JSON.stringify({nav:this.pref.nav})}).then((e=>e.json())).then((e=>{this.pref=e.data,this.isEditing=!1})).catch((e=>{console.error("Failed to save nav customizations:",e)}))}loadPref(){"customer"!==this.userType&&n.fetch({url:"/api/system/preference/json/scaffold?global=true",method:"GET"}).then((e=>e.json())).then((e=>{const t=e?.data?.[0];t&&(this.pref=t)})).catch((()=>{}))}handleNavItemContextMenu(t,i){this.isEditing&&(t.preventDefault(),e.open({x:t.clientX,y:t.clientY,items:[{id:"edit",label:"Edit Item"},{id:"divider-1",label:"",divider:!0},{id:"add-above",label:"Add Item Above"},{id:"add-below",label:"Add Item Below"}]}).then((e=>{if(e)switch(e.id){case"edit":this.openNavItemEdit(i);break;case"add-above":this.addNavItem(i,"above");break;case"add-below":this.addNavItem(i,"below")}})))}openNavItemEdit(e){t.open(Ie,{data:e}).afterClosed().then((t=>{const i=t;i&&(this.pref.nav[e.id]||(this.pref.nav[e.id]={}),this.pref.nav[e.id]={...this.pref.nav[e.id],...i},this.requestUpdate())}))}addNavItem(e,t){const i=`custom-${Date.now()}`,s=this.getComputedNav().filter((t=>t.parentId===e.parentId)).sort(((e,t)=>e.order-t.order)),n=s.findIndex((t=>t.id===e.id));let r;r="above"===t?n:n+1,s.forEach(((e,t)=>{t>=r&&(this.pref.nav[e.id]||(this.pref.nav[e.id]={}),this.pref.nav[e.id].order=t+1)}));const o={id:i,type:"item",label:"New Item",order:r,parentId:e.parentId,active:!0};this.pref.nav[i]=o,this.requestUpdate(),this.openNavItemEdit(o)}handleNavItemMouseDown(e,t){this.isEditing&&(e.preventDefault(),this.draggedNavItemId=t.id,this.navItemDragStartY=e.clientY,this.isNavItemDragging=!1,document.addEventListener("mousemove",this.boundHandleMouseMove),document.addEventListener("mouseup",this.boundHandleMouseUp))}handleMouseMove(e){if(this.draggedNavItemId){if(!this.isNavItemDragging&&Math.abs(e.clientY-this.navItemDragStartY)>5){this.isNavItemDragging=!0,this.classList.add("kr-scaffold--dragging");const t=this.getComputedNav().find((e=>e.id===this.draggedNavItemId));t&&(this.navItemDragPreview=document.createElement("div"),this.navItemDragPreview.className="nav-item-drag-preview",this.navItemDragPreview.textContent=t.label,this.navItemDragPreview.style.left=`${e.clientX+10}px`,this.navItemDragPreview.style.top=e.clientY-20+"px",this.shadowRoot?.appendChild(this.navItemDragPreview))}this.isNavItemDragging&&(this.navItemDragPreview&&(this.navItemDragPreview.style.left=`${e.clientX+10}px`,this.navItemDragPreview.style.top=e.clientY-20+"px"),this.updateNavItemDropTarget(e))}}handleMouseUp(){document.removeEventListener("mousemove",this.boundHandleMouseMove),document.removeEventListener("mouseup",this.boundHandleMouseUp),this.isNavItemDragging&&this.navItemDropTargetId&&this.executeNavItemDrop(),this.draggedNavItemId=null,this.navItemDropTargetId=null,this.isNavItemDragging=!1,this.classList.remove("kr-scaffold--dragging"),this.navItemDragPreview&&(this.navItemDragPreview.remove(),this.navItemDragPreview=null),this.clearNavItemDragExpandTimeout(),this.requestUpdate()}updateNavItemDropTarget(e){const t=this.shadowRoot?.querySelectorAll(".nav-item[data-id]");if(!t)return;let i=!1;t.forEach((t=>{const s=t.getBoundingClientRect(),n=t.getAttribute("data-id");if(!n||n===this.draggedNavItemId)return;if(e.clientX<s.left||e.clientX>s.right||e.clientY<s.top||e.clientY>s.bottom)return;const r=this.getComputedNav().find((e=>e.id===n));if(!r)return;const o=e.clientY-s.top;let a,l;"group"===r.type?o<s.height/3?(a="above",this.clearNavItemDragExpandTimeout()):o>2*s.height/3?(a="below",this.clearNavItemDragExpandTimeout()):(a="center",this.navItemsExpanded.has(r.id)||this.navItemDragExpandTimeout||(this.navItemDragExpandTimeout=window.setTimeout((()=>{this.navItemDropTargetId===r.id&&"center"===this.navItemDropPosition&&(this.navItemsExpanded.add(r.id),this.requestUpdate()),this.navItemDragExpandTimeout=null}),500))):(a=o<s.height/2?"above":"below",this.clearNavItemDragExpandTimeout()),l="center"===a?r.id:r.parentId;const h=this.getComputedNav().find((e=>e.id===this.draggedNavItemId));if(l===this.draggedNavItemId||"group"===h?.type&&null!==l)return this.navItemDropTargetId=null,void this.clearNavItemDragExpandTimeout();this.navItemDropTargetId=r.id,this.navItemDropPosition=a,i=!0})),i||(this.navItemDropTargetId=null,this.clearNavItemDragExpandTimeout()),this.requestUpdate()}clearNavItemDragExpandTimeout(){this.navItemDragExpandTimeout&&(clearTimeout(this.navItemDragExpandTimeout),this.navItemDragExpandTimeout=null)}executeNavItemDrop(){if(!this.draggedNavItemId||!this.navItemDropTargetId)return;const e=this.getComputedNav(),t=e.find((e=>e.id===this.draggedNavItemId)),i=e.find((e=>e.id===this.navItemDropTargetId));if(!t||!i)return;let s;if("center"===this.navItemDropPosition&&"group"===i.type){if(i.id===this.draggedNavItemId)return;s=i.id}else s=i.parentId;if(s===this.draggedNavItemId)return;const n=e.filter((e=>e.parentId===s&&e.id!==this.draggedNavItemId)).sort(((e,t)=>e.order-t.order)),r=this.pref.nav;let o;if("center"===this.navItemDropPosition)o=n.length>0?Math.max(...n.map((e=>e.order)))+1:0;else{const e=n.findIndex((e=>e.id===i.id));o=-1===e?0:"above"===this.navItemDropPosition?e:e+1,n.forEach(((e,t)=>{r[e.id]||(r[e.id]={}),r[e.id].order=t>=o?t+1:t}))}r[this.draggedNavItemId]||(r[this.draggedNavItemId]={}),r[this.draggedNavItemId].order=o,r[this.draggedNavItemId].parentId=s,this.pref.nav=r,this.requestUpdate()}handleUserMenuToggle(){this.isUserMenuOpen=!this.isUserMenuOpen}handleCustomize(){this.isUserMenuOpen=!1,this.isEditing=!0}renderNormalFooter(){if(!this.user)return V;const e=this.user.name.split(" ").map((e=>e[0])).join("").toUpperCase().slice(0,2);return X`
201
+ `,Se([fe()],Ie.prototype,"label",void 0),Se([fe()],Ie.prototype,"icon",void 0),Se([fe()],Ie.prototype,"url",void 0),Se([fe()],Ie.prototype,"active",void 0),Ie=Se([pe("kr-nav-item-edit")],Ie);var Ee=function(e,t,i,s){var n,r=arguments.length,o=r<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,i,s);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(o=(r<3?n(o):r>3?n(t,i,o):n(t,i))||o);return r>3&&o&&Object.defineProperty(t,i,o),o};let Ce=class extends ce{constructor(){super(),this.defaultNavItemIcon='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><circle cx="12" cy="12" r="10"/></svg>',this.originalFetch=null,this.originalXhrOpen=null,this.navItemDragPreview=null,this.navItemDragStartY=0,this.isNavItemDragging=!1,this.navItemDragExpandTimeout=null,this.navInitialized=!1,this.logo="",this.label="",this.homeUrl="/",this.scheme="light",this.nav=[],this.navIconsDisplayed=!1,this.navExpanded=!1,this.user=null,this.subbar=!1,this.navEnabled=!0,this.userType="employee",this.breadcrumbs=[],this.navItemsExpanded=new Set,this.navQuery="",this.activeNavItemId=null,this.isNavScrolled=!1,this.isNavOpened="false"!==localStorage.getItem("kr-scaffold-nav-opened"),this.isEditing=!1,this.isUserMenuOpen=!1,this.pref={nav:{}},this.draggedNavItemId=null,this.navItemDropTargetId=null,this.navItemDropPosition="above",this.pendingRequests=0,this.boundHandleMouseMove=this.handleMouseMove.bind(this),this.boundHandleMouseUp=this.handleMouseUp.bind(this)}connectedCallback(){super.connectedCallback(),this.installFetchInterceptor()}firstUpdated(){this.loadPref()}updated(e){super.updated(e),e.has("nav")&&this.nav.length>0&&(this.updateActiveNavItem(),this.navExpanded&&!this.navInitialized&&(this.navInitialized=!0,this.getComputedNav().filter((e=>"group"===e.type)).forEach((e=>this.navItemsExpanded.add(e.id)))))}disconnectedCallback(){super.disconnectedCallback(),this.uninstallFetchInterceptor()}installFetchInterceptor(){if(this.originalFetch)return;const e=this;this.originalFetch=window.fetch.bind(window);const t=this.originalFetch;window.fetch=function(...i){return e.pendingRequests++,t(...i).finally((()=>{e.pendingRequests--}))},this.originalXhrOpen=XMLHttpRequest.prototype.open;const i=this.originalXhrOpen;XMLHttpRequest.prototype.open=function(t,s,n=!0,r,o){return e.pendingRequests++,this.addEventListener("loadend",(()=>{e.pendingRequests--}),{once:!0}),i.call(this,t,s,n,r,o)}}uninstallFetchInterceptor(){this.originalFetch&&(window.fetch=this.originalFetch,this.originalFetch=null),this.originalXhrOpen&&(XMLHttpRequest.prototype.open=this.originalXhrOpen,this.originalXhrOpen=null)}resolveUrl(e){if(!e.url)return"#";if(e.external)return e.url;let t=e.url;e.url.startsWith("/")&&(t=e.url.slice(1));const i=document.querySelector("base")?.getAttribute("href")||"/";return i.endsWith("/")?i+t:i+"/"+t}getComputedNav(){const e=[];return this.nav.forEach(((t,i)=>{const s=this.pref.nav[t.id];e.push({...t,...s,order:s?.order??t.order??i,parentId:s?.parentId??null}),"group"===t.type&&t.children&&t.children.forEach(((i,s)=>{const n=this.pref.nav[i.id];let r=t.id;void 0!==n?.parentId&&(r=n.parentId),e.push({...i,...n,order:n?.order??i.order??s,parentId:r})}))})),Object.entries(this.pref.nav).forEach((([t,i])=>{t.startsWith("custom")&&i.type&&i.label&&e.push({id:t,type:i.type,label:i.label,icon:i.icon,url:i.url,active:i.active,order:i.order??e.length,parentId:i.parentId??null})})),e}getNavItemChildren(e){let t=this.getComputedNav().filter((t=>t.parentId===e)).sort(((e,t)=>e.order-t.order));if(this.isEditing||(t=t.filter((e=>!1!==e.active))),this.navQuery){const i=this.navQuery.toLowerCase(),s=this.getComputedNav();if(null!==e){const n=s.find((t=>t.id===e));if(n?.label.toLowerCase().includes(i))return t}t=t.filter((e=>"group"===e.type?e.label.toLowerCase().includes(i)||s.some((t=>t.parentId===e.id&&!1!==t.active&&t.label.toLowerCase().includes(i))):e.label.toLowerCase().includes(i)))}return t}handleNavQueryChange(e){this.navQuery=e.target.value,this.navQuery?this.getComputedNav().forEach((e=>{"group"===e.type&&this.navItemsExpanded.add(e.id)})):this.navItemsExpanded.clear()}handleNavQueryClear(){this.navQuery="",this.navItemsExpanded.clear()}handleMenuClick(){this.isNavOpened=!this.isNavOpened,localStorage.setItem("kr-scaffold-nav-opened",String(this.isNavOpened))}handleNavHeaderClick(){this.activeNavItemId=null;const e=new CustomEvent("nav-item-click",{detail:{item:{url:this.homeUrl}},bubbles:!0,composed:!0,cancelable:!0});this.dispatchEvent(e),e.defaultPrevented||(window.location.href=this.homeUrl)}handleNavScroll(e){this.isNavScrolled=e.target.scrollTop>0}expandNavGroup(e){this.navItemsExpanded.has(e)||(this.navItemsExpanded.add(e),this.requestUpdate())}handleNavItemClick(e,t){if("group"===t.type){const e=this.shadowRoot?.querySelector(`.nav-item[data-id="${t.id}"]`),i=e?.nextElementSibling;if(!i)return;this.navItemsExpanded.has(t.id)?(this.navItemsExpanded.delete(t.id),i.animate([{height:`${i.scrollHeight}px`},{height:"0px"}],{duration:300,easing:"ease-in-out"}).onfinish=()=>{i.classList.remove("nav-group--expanded")}):(this.navItemsExpanded.add(t.id),i.classList.add("nav-group--expanded"),i.animate([{height:"0px"},{height:`${i.scrollHeight}px`}],{duration:300,easing:"ease-in-out"})),this.requestUpdate()}else{if(e.ctrlKey||e.metaKey||1===e.button)return;this.activeNavItemId=t.id;const i=new CustomEvent("nav-item-click",{detail:{item:t},bubbles:!0,composed:!0,cancelable:!0});this.dispatchEvent(i),i.defaultPrevented&&e.preventDefault()}}updateActiveNavItem(){const e=window.location.pathname,t=this.getComputedNav().filter((e=>"item"===e.type&&e.url));let i=null,s=0;for(const n of t){const t=this.resolveUrl(n);e.startsWith(t)&&t.length>s&&(i=n,s=t.length)}i?(this.activeNavItemId=i.id,i.parentId&&this.navItemsExpanded.add(i.parentId)):this.activeNavItemId=null}handleEditCancel(){this.isEditing=!1,this.loadPref()}handlePrefReset(){this.pref.nav={}}handlePrefSave(){if("customer"===this.userType)return;let e="/api/system/preference/json/scaffold?global=true",t="POST";this.pref.uuid&&(e=`/api/system/preference/json/scaffold/${this.pref.uuid}?global=true`,t="PUT"),n.fetch({url:e,method:t,body:JSON.stringify({nav:this.pref.nav})}).then((e=>e.json())).then((e=>{this.pref=e.data,this.isEditing=!1})).catch((e=>{console.error("Failed to save nav customizations:",e)}))}loadPref(){"customer"!==this.userType&&n.fetch({url:"/api/system/preference/json/scaffold?global=true",method:"GET"}).then((e=>e.json())).then((e=>{const t=e?.data?.[0];t&&(this.pref=t)})).catch((()=>{}))}handleNavItemContextMenu(t,i){this.isEditing&&(t.preventDefault(),e.open({x:t.clientX,y:t.clientY,items:[{id:"edit",label:"Edit Item"},{id:"divider-1",label:"",divider:!0},{id:"add-above",label:"Add Item Above"},{id:"add-below",label:"Add Item Below"}]}).then((e=>{if(e)switch(e.id){case"edit":this.openNavItemEdit(i);break;case"add-above":this.addNavItem(i,"above");break;case"add-below":this.addNavItem(i,"below")}})))}openNavItemEdit(e){t.open(Ie,{data:e}).afterClosed().then((t=>{const i=t;i&&(this.pref.nav[e.id]||(this.pref.nav[e.id]={}),this.pref.nav[e.id]={...this.pref.nav[e.id],...i},this.requestUpdate())}))}addNavItem(e,t){const i=`custom-${Date.now()}`,s=this.getComputedNav().filter((t=>t.parentId===e.parentId)).sort(((e,t)=>e.order-t.order)),n=s.findIndex((t=>t.id===e.id));let r;r="above"===t?n:n+1,s.forEach(((e,t)=>{t>=r&&(this.pref.nav[e.id]||(this.pref.nav[e.id]={}),this.pref.nav[e.id].order=t+1)}));const o={id:i,type:"item",label:"New Item",order:r,parentId:e.parentId,active:!0};this.pref.nav[i]=o,this.requestUpdate(),this.openNavItemEdit(o)}handleNavItemMouseDown(e,t){this.isEditing&&(e.preventDefault(),this.draggedNavItemId=t.id,this.navItemDragStartY=e.clientY,this.isNavItemDragging=!1,document.addEventListener("mousemove",this.boundHandleMouseMove),document.addEventListener("mouseup",this.boundHandleMouseUp))}handleMouseMove(e){if(this.draggedNavItemId){if(!this.isNavItemDragging&&Math.abs(e.clientY-this.navItemDragStartY)>5){this.isNavItemDragging=!0,this.classList.add("kr-scaffold--dragging");const t=this.getComputedNav().find((e=>e.id===this.draggedNavItemId));t&&(this.navItemDragPreview=document.createElement("div"),this.navItemDragPreview.className="nav-item-drag-preview",this.navItemDragPreview.textContent=t.label,this.navItemDragPreview.style.left=`${e.clientX+10}px`,this.navItemDragPreview.style.top=e.clientY-20+"px",this.shadowRoot?.appendChild(this.navItemDragPreview))}this.isNavItemDragging&&(this.navItemDragPreview&&(this.navItemDragPreview.style.left=`${e.clientX+10}px`,this.navItemDragPreview.style.top=e.clientY-20+"px"),this.updateNavItemDropTarget(e))}}handleMouseUp(){document.removeEventListener("mousemove",this.boundHandleMouseMove),document.removeEventListener("mouseup",this.boundHandleMouseUp),this.isNavItemDragging&&this.navItemDropTargetId&&this.executeNavItemDrop(),this.draggedNavItemId=null,this.navItemDropTargetId=null,this.isNavItemDragging=!1,this.classList.remove("kr-scaffold--dragging"),this.navItemDragPreview&&(this.navItemDragPreview.remove(),this.navItemDragPreview=null),this.clearNavItemDragExpandTimeout(),this.requestUpdate()}updateNavItemDropTarget(e){const t=this.shadowRoot?.querySelectorAll(".nav-item[data-id]");if(!t)return;let i=!1;t.forEach((t=>{const s=t.getBoundingClientRect(),n=t.getAttribute("data-id");if(!n||n===this.draggedNavItemId)return;if(e.clientX<s.left||e.clientX>s.right||e.clientY<s.top||e.clientY>s.bottom)return;const r=this.getComputedNav().find((e=>e.id===n));if(!r)return;const o=e.clientY-s.top;let a,l;"group"===r.type?o<s.height/3?(a="above",this.clearNavItemDragExpandTimeout()):o>2*s.height/3?(a="below",this.clearNavItemDragExpandTimeout()):(a="center",this.navItemsExpanded.has(r.id)||this.navItemDragExpandTimeout||(this.navItemDragExpandTimeout=window.setTimeout((()=>{this.navItemDropTargetId===r.id&&"center"===this.navItemDropPosition&&(this.navItemsExpanded.add(r.id),this.requestUpdate()),this.navItemDragExpandTimeout=null}),500))):(a=o<s.height/2?"above":"below",this.clearNavItemDragExpandTimeout()),l="center"===a?r.id:r.parentId;const h=this.getComputedNav().find((e=>e.id===this.draggedNavItemId));if(l===this.draggedNavItemId||"group"===h?.type&&null!==l)return this.navItemDropTargetId=null,void this.clearNavItemDragExpandTimeout();this.navItemDropTargetId=r.id,this.navItemDropPosition=a,i=!0})),i||(this.navItemDropTargetId=null,this.clearNavItemDragExpandTimeout()),this.requestUpdate()}clearNavItemDragExpandTimeout(){this.navItemDragExpandTimeout&&(clearTimeout(this.navItemDragExpandTimeout),this.navItemDragExpandTimeout=null)}executeNavItemDrop(){if(!this.draggedNavItemId||!this.navItemDropTargetId)return;const e=this.getComputedNav(),t=e.find((e=>e.id===this.draggedNavItemId)),i=e.find((e=>e.id===this.navItemDropTargetId));if(!t||!i)return;let s;if("center"===this.navItemDropPosition&&"group"===i.type){if(i.id===this.draggedNavItemId)return;s=i.id}else s=i.parentId;if(s===this.draggedNavItemId)return;const n=e.filter((e=>e.parentId===s&&e.id!==this.draggedNavItemId)).sort(((e,t)=>e.order-t.order)),r=this.pref.nav;let o;if("center"===this.navItemDropPosition)o=n.length>0?Math.max(...n.map((e=>e.order)))+1:0;else{const e=n.findIndex((e=>e.id===i.id));o=-1===e?0:"above"===this.navItemDropPosition?e:e+1,n.forEach(((e,t)=>{r[e.id]||(r[e.id]={}),r[e.id].order=t>=o?t+1:t}))}r[this.draggedNavItemId]||(r[this.draggedNavItemId]={}),r[this.draggedNavItemId].order=o,r[this.draggedNavItemId].parentId=s,this.pref.nav=r,this.requestUpdate()}handleUserMenuToggle(){this.isUserMenuOpen=!this.isUserMenuOpen}handleCustomize(){this.isUserMenuOpen=!1,this.isEditing=!0}renderNormalFooter(){if(!this.user)return Q;const e=this.user.name.split(" ").map((e=>e[0])).join("").toUpperCase().slice(0,2);return V`
202
202
  <div class="user-menu-container">
203
- ${this.isUserMenuOpen?X`
203
+ ${this.isUserMenuOpen?V`
204
204
  <div class="user-menu">
205
205
  <button class="user-menu__item" @click=${this.handleCustomize}>
206
206
  Customize Navigation
207
207
  </button>
208
208
  </div>
209
- `:V}
209
+ `:Q}
210
210
  <div class="user" @click=${this.handleUserMenuToggle}>
211
211
  <div class="user__avatar">
212
- ${this.user.avatar?X`<img src=${this.user.avatar} alt=${this.user.name} />`:e}
212
+ ${this.user.avatar?V`<img src=${this.user.avatar} alt=${this.user.name} />`:e}
213
213
  </div>
214
214
  <div class="user__info">
215
215
  <div class="user__name">${this.user.name}</div>
216
- ${this.user.email?X`<div class="user__email">${this.user.email}</div>`:V}
216
+ ${this.user.email?V`<div class="user__email">${this.user.email}</div>`:Q}
217
217
  </div>
218
218
  </div>
219
219
  </div>
220
- `}renderEditFooter(){return X`
220
+ `}renderEditFooter(){return V`
221
221
  <div class="edit-actions">
222
222
  <button class="edit-actions__btn edit-actions__btn--primary" @click=${this.handlePrefSave}>
223
223
  Save
@@ -231,9 +231,9 @@ function be(e,t){return(t,i,s)=>((e,t,i)=>(i.configurable=!0,i.enumerable=!0,Ref
231
231
  </button>
232
232
  </div>
233
233
  </div>
234
- `}renderNavItem(e,t=!1){if("section"===e.type)return X`
234
+ `}renderNavItem(e,t=!1){if("section"===e.type)return V`
235
235
  <div class="nav-section">${e.label}</div>
236
- `;if("group"===e.type){const t=this.getNavItemChildren(e.id);return X`
236
+ `;if("group"===e.type){const t=this.getNavItemChildren(e.id);return V`
237
237
  <button
238
238
  class=${$e({"nav-item":!0,"nav-item--expanded":this.navItemsExpanded.has(e.id),"nav-item--hidden":this.isEditing&&!1===e.active,"nav-item--drop-above":this.navItemDropTargetId===e.id&&"above"===this.navItemDropPosition,"nav-item--drop-below":this.navItemDropTargetId===e.id&&"below"===this.navItemDropPosition,"nav-item--drop-center":this.navItemDropTargetId===e.id&&"center"===this.navItemDropPosition})}
239
239
  data-id="${e.id}"
@@ -241,7 +241,7 @@ function be(e,t){return(t,i,s)=>((e,t,i)=>(i.configurable=!0,i.enumerable=!0,Ref
241
241
  @click=${t=>this.handleNavItemClick(t,e)}
242
242
  @contextmenu=${t=>this.handleNavItemContextMenu(t,e)}
243
243
  >
244
- ${this.navIconsDisplayed?X`<span class="nav-item__icon">${we(e.icon||this.defaultNavItemIcon)}</span>`:V}
244
+ ${this.navIconsDisplayed?V`<span class="nav-item__icon">${ye(e.icon||this.defaultNavItemIcon)}</span>`:Q}
245
245
  <span class="nav-item__label">${e.label}</span>
246
246
  <svg
247
247
  class="nav-item__chevron"
@@ -260,20 +260,20 @@ function be(e,t){return(t,i,s)=>((e,t,i)=>(i.configurable=!0,i.enumerable=!0,Ref
260
260
  <div class=${$e({"nav-group":!0,"nav-group--expanded":this.navItemsExpanded.has(e.id)})}>
261
261
  ${t.map((e=>this.renderNavItem(e,!0)))}
262
262
  </div>
263
- `}return X`
263
+ `}return V`
264
264
  <a
265
265
  class=${$e({"nav-item":!0,"nav-item--active":this.activeNavItemId===e.id,"nav-item--hidden":this.isEditing&&!1===e.active,"nav-item--drop-above":this.navItemDropTargetId===e.id&&"above"===this.navItemDropPosition,"nav-item--drop-below":this.navItemDropTargetId===e.id&&"below"===this.navItemDropPosition})}
266
266
  data-id="${e.id}"
267
267
  href=${this.resolveUrl(e)}
268
- target=${e.external?"_blank":V}
268
+ target=${e.external?"_blank":Q}
269
269
  @mousedown=${t=>this.handleNavItemMouseDown(t,e)}
270
270
  @click=${t=>this.handleNavItemClick(t,e)}
271
271
  @contextmenu=${t=>this.handleNavItemContextMenu(t,e)}
272
272
  >
273
- ${this.navIconsDisplayed&&!t?X`<span class="nav-item__icon">${we(e.icon||this.defaultNavItemIcon)}</span>`:V}
273
+ ${this.navIconsDisplayed&&!t?V`<span class="nav-item__icon">${ye(e.icon||this.defaultNavItemIcon)}</span>`:Q}
274
274
  <span class="nav-item__label">${e.label}</span>
275
275
  </a>
276
- `}render(){const e=this.getNavItemChildren(null),t=this.getComputedNav().filter((e=>null===e.parentId)).length;return X`
276
+ `}render(){const e=this.getNavItemChildren(null),t=this.getComputedNav().filter((e=>null===e.parentId)).length;return V`
277
277
  <div class=${$e({progress:!0,"progress--loading":this.pendingRequests>0})}>
278
278
  <div class="progress__track"></div>
279
279
  <div class="progress__bar progress__bar--primary">
@@ -284,7 +284,7 @@ function be(e,t){return(t,i,s)=>((e,t,i)=>(i.configurable=!0,i.enumerable=!0,Ref
284
284
  </div>
285
285
  </div>
286
286
 
287
- ${this.subbar?X`
287
+ ${this.subbar?V`
288
288
  <kr-subbar
289
289
  menu
290
290
  .breadcrumbs=${this.breadcrumbs}
@@ -292,20 +292,20 @@ function be(e,t){return(t,i,s)=>((e,t,i)=>(i.configurable=!0,i.enumerable=!0,Ref
292
292
  >
293
293
  <slot name="subbar"></slot>
294
294
  </kr-subbar>
295
- `:V}
295
+ `:Q}
296
296
 
297
297
  <div class="wrapper">
298
- ${this.navEnabled?X`
298
+ ${this.navEnabled?V`
299
299
  <nav class=${$e({nav:!0,"nav--scrolled":this.isNavScrolled,"nav--opened":!this.subbar||this.isNavOpened})}>
300
300
  <div class="nav-header" @click=${this.handleNavHeaderClick}>
301
- ${this.label?X`<span class="nav-title">${this.label}</span>`:this.logo?X`<img
301
+ ${this.label?V`<span class="nav-title">${this.label}</span>`:this.logo?V`<img
302
302
  class="nav-logo"
303
303
  src=${this.logo}
304
304
  alt="Logo"
305
- />`:V}
305
+ />`:Q}
306
306
  </div>
307
307
  <div class="nav-content" @scroll=${this.handleNavScroll}>
308
- ${t>20?X`
308
+ ${t>20?V`
309
309
  <div class="nav-search">
310
310
  <div class="nav-search__wrapper">
311
311
  <span class="nav-search__icon">
@@ -324,7 +324,7 @@ function be(e,t){return(t,i,s)=>((e,t,i)=>(i.configurable=!0,i.enumerable=!0,Ref
324
324
  .value=${this.navQuery}
325
325
  @input=${this.handleNavQueryChange}
326
326
  />
327
- ${this.navQuery?X`
327
+ ${this.navQuery?V`
328
328
  <button class="nav-search__clear" @click=${this.handleNavQueryClear}>
329
329
  <svg
330
330
  xmlns="http://www.w3.org/2000/svg"
@@ -334,10 +334,10 @@ function be(e,t){return(t,i,s)=>((e,t,i)=>(i.configurable=!0,i.enumerable=!0,Ref
334
334
  <path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"/>
335
335
  </svg>
336
336
  </button>
337
- `:V}
337
+ `:Q}
338
338
  </div>
339
339
  </div>
340
- `:V}
340
+ `:Q}
341
341
  <div class="nav-items">
342
342
  ${e.map((e=>this.renderNavItem(e)))}
343
343
  </div>
@@ -346,7 +346,7 @@ function be(e,t){return(t,i,s)=>((e,t,i)=>(i.configurable=!0,i.enumerable=!0,Ref
346
346
  ${this.isEditing?this.renderEditFooter():this.renderNormalFooter()}
347
347
  </div> -->
348
348
  </nav>
349
- `:V}
349
+ `:Q}
350
350
 
351
351
  <main class="main">
352
352
  <slot></slot>
@@ -1078,19 +1078,19 @@ function be(e,t){return(t,i,s)=>((e,t,i)=>(i.configurable=!0,i.enumerable=!0,Ref
1078
1078
  transform: scaleX(0.08);
1079
1079
  }
1080
1080
  }
1081
- `,Ee([me({type:String})],Ce.prototype,"logo",void 0),Ee([me({type:String})],Ce.prototype,"label",void 0),Ee([me({type:String,attribute:"home-url"})],Ce.prototype,"homeUrl",void 0),Ee([me({type:String,reflect:!0})],Ce.prototype,"scheme",void 0),Ee([me({type:Array})],Ce.prototype,"nav",void 0),Ee([me({type:Boolean,attribute:"nav-icons-displayed",reflect:!0})],Ce.prototype,"navIconsDisplayed",void 0),Ee([me({type:Boolean,attribute:"nav-expanded"})],Ce.prototype,"navExpanded",void 0),Ee([me({type:Object})],Ce.prototype,"user",void 0),Ee([me({type:Boolean})],Ce.prototype,"subbar",void 0),Ee([me({type:Boolean,attribute:"nav-enabled"})],Ce.prototype,"navEnabled",void 0),Ee([me({type:String,attribute:"user-type"})],Ce.prototype,"userType",void 0),Ee([me({type:Array})],Ce.prototype,"breadcrumbs",void 0),Ee([fe()],Ce.prototype,"navItemsExpanded",void 0),Ee([fe()],Ce.prototype,"navQuery",void 0),Ee([fe()],Ce.prototype,"activeNavItemId",void 0),Ee([fe()],Ce.prototype,"isNavScrolled",void 0),Ee([fe()],Ce.prototype,"isNavOpened",void 0),Ee([fe()],Ce.prototype,"isEditing",void 0),Ee([fe()],Ce.prototype,"isUserMenuOpen",void 0),Ee([fe()],Ce.prototype,"pref",void 0),Ee([fe()],Ce.prototype,"draggedNavItemId",void 0),Ee([fe()],Ce.prototype,"navItemDropTargetId",void 0),Ee([fe()],Ce.prototype,"navItemDropPosition",void 0),Ee([fe()],Ce.prototype,"pendingRequests",void 0),Ce=Ee([pe("kr-scaffold")],Ce);var ze=function(e,t,i,s){var n,r=arguments.length,o=r<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,i,s);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(o=(r<3?n(o):r>3?n(t,i,o):n(t,i))||o);return r>3&&o&&Object.defineProperty(t,i,o),o};let Ae=class extends ce{constructor(){super(...arguments),this.label="",this.subLabel="",this.items=[],this.activeId="",this.handlePopstate=()=>{this.syncActiveFromUrl()}}connectedCallback(){super.connectedCallback(),requestAnimationFrame((()=>this.syncActiveFromUrl())),window.addEventListener("popstate",this.handlePopstate)}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("popstate",this.handlePopstate)}handleNavItemClick(e,t){const i=new CustomEvent("nav-item-click",{detail:{item:t},bubbles:!0,composed:!0,cancelable:!0});this.dispatchEvent(i),i.defaultPrevented&&e.preventDefault(),this.activeId=t.id}syncActiveFromUrl(){const e=window.location.pathname,t=this.items.find((t=>!!t.url&&(t.url.startsWith("/")?e===t.url:e.endsWith("/"+t.url))));t&&(this.activeId=t.id)}render(){return X`
1081
+ `,Ee([me({type:String})],Ce.prototype,"logo",void 0),Ee([me({type:String})],Ce.prototype,"label",void 0),Ee([me({type:String,attribute:"home-url"})],Ce.prototype,"homeUrl",void 0),Ee([me({type:String,reflect:!0})],Ce.prototype,"scheme",void 0),Ee([me({type:Array})],Ce.prototype,"nav",void 0),Ee([me({type:Boolean,attribute:"nav-icons-displayed",reflect:!0})],Ce.prototype,"navIconsDisplayed",void 0),Ee([me({type:Boolean,attribute:"nav-expanded"})],Ce.prototype,"navExpanded",void 0),Ee([me({type:Object})],Ce.prototype,"user",void 0),Ee([me({type:Boolean})],Ce.prototype,"subbar",void 0),Ee([me({type:Boolean,attribute:"nav-enabled"})],Ce.prototype,"navEnabled",void 0),Ee([me({type:String,attribute:"user-type"})],Ce.prototype,"userType",void 0),Ee([me({type:Array})],Ce.prototype,"breadcrumbs",void 0),Ee([fe()],Ce.prototype,"navItemsExpanded",void 0),Ee([fe()],Ce.prototype,"navQuery",void 0),Ee([fe()],Ce.prototype,"activeNavItemId",void 0),Ee([fe()],Ce.prototype,"isNavScrolled",void 0),Ee([fe()],Ce.prototype,"isNavOpened",void 0),Ee([fe()],Ce.prototype,"isEditing",void 0),Ee([fe()],Ce.prototype,"isUserMenuOpen",void 0),Ee([fe()],Ce.prototype,"pref",void 0),Ee([fe()],Ce.prototype,"draggedNavItemId",void 0),Ee([fe()],Ce.prototype,"navItemDropTargetId",void 0),Ee([fe()],Ce.prototype,"navItemDropPosition",void 0),Ee([fe()],Ce.prototype,"pendingRequests",void 0),Ce=Ee([pe("kr-scaffold")],Ce);var Ae=function(e,t,i,s){var n,r=arguments.length,o=r<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,i,s);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(o=(r<3?n(o):r>3?n(t,i,o):n(t,i))||o);return r>3&&o&&Object.defineProperty(t,i,o),o};let ze=class extends ce{constructor(){super(...arguments),this.label="",this.subLabel="",this.items=[],this.activeId="",this.handlePopstate=()=>{this.syncActiveFromUrl()}}connectedCallback(){super.connectedCallback(),requestAnimationFrame((()=>this.syncActiveFromUrl())),window.addEventListener("popstate",this.handlePopstate)}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("popstate",this.handlePopstate)}handleNavItemClick(e,t){const i=new CustomEvent("nav-item-click",{detail:{item:t},bubbles:!0,composed:!0,cancelable:!0});this.dispatchEvent(i),i.defaultPrevented&&e.preventDefault(),this.activeId=t.id}syncActiveFromUrl(){const e=window.location.pathname,t=this.items.find((t=>!!t.url&&(t.url.startsWith("/")?e===t.url:e.endsWith("/"+t.url))));t&&(this.activeId=t.id)}render(){return V`
1082
1082
  <nav class="nav">
1083
- ${this.label?X`
1083
+ ${this.label?V`
1084
1084
  <div class="nav-header">
1085
1085
  <div class="nav-header__text">
1086
- ${this.subLabel?X`<div class="nav-header__subtitle">${this.subLabel}</div>`:V}
1086
+ ${this.subLabel?V`<div class="nav-header__subtitle">${this.subLabel}</div>`:Q}
1087
1087
  <div class="nav-header__title">${this.label}</div>
1088
1088
  </div>
1089
1089
  </div>
1090
- `:V}
1090
+ `:Q}
1091
1091
  <div class="nav-content">
1092
1092
  <div class="nav-items">
1093
- ${this.items.map((e=>X`
1093
+ ${this.items.map((e=>V`
1094
1094
  <a
1095
1095
  class=${$e({"nav-item":!0,"nav-item--active":e.id===this.activeId})}
1096
1096
  href=${e.url||"#"}
@@ -1107,7 +1107,7 @@ function be(e,t){return(t,i,s)=>((e,t,i)=>(i.configurable=!0,i.enumerable=!0,Ref
1107
1107
  <slot></slot>
1108
1108
  </div>
1109
1109
  </main>
1110
- `}};Ae.styles=c`
1110
+ `}};ze.styles=c`
1111
1111
  :host {
1112
1112
  display: flex;
1113
1113
  height: 100%;
@@ -1198,7 +1198,7 @@ function be(e,t){return(t,i,s)=>((e,t,i)=>(i.configurable=!0,i.enumerable=!0,Ref
1198
1198
  flex: 1;
1199
1199
  overflow-y: auto;
1200
1200
  }
1201
- `,ze([me({type:String})],Ae.prototype,"label",void 0),ze([me({type:String})],Ae.prototype,"subLabel",void 0),ze([me({type:Array})],Ae.prototype,"items",void 0),ze([me({type:String})],Ae.prototype,"activeId",void 0),Ae=ze([pe("kr-screen-nav")],Ae);var Re=function(e,t,i,s){var n,r=arguments.length,o=r<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,i,s);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(o=(r<3?n(o):r>3?n(t,i,o):n(t,i))||o);return r>3&&o&&Object.defineProperty(t,i,o),o};let De=class extends ce{constructor(){super(...arguments),this.title=""}render(){return X`
1201
+ `,Ae([me({type:String})],ze.prototype,"label",void 0),Ae([me({type:String})],ze.prototype,"subLabel",void 0),Ae([me({type:Array})],ze.prototype,"items",void 0),Ae([me({type:String})],ze.prototype,"activeId",void 0),ze=Ae([pe("kr-screen-nav")],ze);var Te=function(e,t,i,s){var n,r=arguments.length,o=r<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,i,s);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(o=(r<3?n(o):r>3?n(t,i,o):n(t,i))||o);return r>3&&o&&Object.defineProperty(t,i,o),o};let Re=class extends ce{constructor(){super(...arguments),this.title=""}render(){return V`
1202
1202
  <div class="header">
1203
1203
  <h2 class="header__title">${this.title}</h2>
1204
1204
  <div class="header__actions">
@@ -1210,7 +1210,7 @@ function be(e,t){return(t,i,s)=>((e,t,i)=>(i.configurable=!0,i.enumerable=!0,Ref
1210
1210
  <slot></slot>
1211
1211
  </div>
1212
1212
  </div>
1213
- `}};De.styles=c`
1213
+ `}};Re.styles=c`
1214
1214
  :host {
1215
1215
  display: flex;
1216
1216
  flex-direction: column;
@@ -1254,8 +1254,8 @@ function be(e,t){return(t,i,s)=>((e,t,i)=>(i.configurable=!0,i.enumerable=!0,Ref
1254
1254
  width: 100%;
1255
1255
  max-width: 700px;
1256
1256
  }
1257
- `,Re([me({type:String})],De.prototype,"title",void 0),De=Re([pe("kr-screen-detail")],De);var Te=function(e,t,i,s){var n,r=arguments.length,o=r<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,i,s);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(o=(r<3?n(o):r>3?n(t,i,o):n(t,i))||o);return r>3&&o&&Object.defineProperty(t,i,o),o};let Me=class extends ce{constructor(){super(...arguments),this.breadcrumbs=[],this.menu=!1}_handleMenuClick(){this.dispatchEvent(new CustomEvent("menu-click",{bubbles:!0,composed:!0}))}_handleBreadcrumbClick(e,t,i){if(i||!t.url)return void e.preventDefault();if(e.ctrlKey||e.metaKey||1===e.button)return;const s=new CustomEvent("breadcrumb-click",{detail:{breadcrumb:t},bubbles:!0,composed:!0,cancelable:!0});this.dispatchEvent(s),s.defaultPrevented&&e.preventDefault()}render(){return X`
1258
- ${this.menu?X`
1257
+ `,Te([me({type:String})],Re.prototype,"title",void 0),Re=Te([pe("kr-screen-detail")],Re);var Me=function(e,t,i,s){var n,r=arguments.length,o=r<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,i,s);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(o=(r<3?n(o):r>3?n(t,i,o):n(t,i))||o);return r>3&&o&&Object.defineProperty(t,i,o),o};let De=class extends ce{constructor(){super(...arguments),this.breadcrumbs=[],this.menu=!1}_handleMenuClick(){this.dispatchEvent(new CustomEvent("menu-click",{bubbles:!0,composed:!0}))}_handleBreadcrumbClick(e,t,i){if(i||!t.url)return void e.preventDefault();if(e.ctrlKey||e.metaKey||1===e.button)return;const s=new CustomEvent("breadcrumb-click",{detail:{breadcrumb:t},bubbles:!0,composed:!0,cancelable:!0});this.dispatchEvent(s),s.defaultPrevented&&e.preventDefault()}render(){return V`
1258
+ ${this.menu?V`
1259
1259
  <div class="menu" @click=${this._handleMenuClick}>
1260
1260
  <svg
1261
1261
  class="menu__icon"
@@ -1284,10 +1284,10 @@ function be(e,t){return(t,i,s)=>((e,t,i)=>(i.configurable=!0,i.enumerable=!0,Ref
1284
1284
  ></line>
1285
1285
  </svg>
1286
1286
  </div>
1287
- `:V}
1287
+ `:Q}
1288
1288
  <div class="breadcrumbs">
1289
- ${this.breadcrumbs.map(((e,t)=>{const i=t===this.breadcrumbs.length-1,s=document.querySelector("base")?.getAttribute("href")||"/";let n="#";if(e.url){let t=e.url;e.url.startsWith("/")&&(t=e.url.slice(1)),n=s+t,s.endsWith("/")||(n=s+"/"+t)}return X`
1290
- ${t>0?X`<span class="breadcrumb-separator">/</span>`:""}
1289
+ ${this.breadcrumbs.map(((e,t)=>{const i=t===this.breadcrumbs.length-1,s=document.querySelector("base")?.getAttribute("href")||"/";let n="#";if(e.url){let t=e.url;e.url.startsWith("/")&&(t=e.url.slice(1)),n=s+t,s.endsWith("/")||(n=s+"/"+t)}return V`
1290
+ ${t>0?V`<span class="breadcrumb-separator">/</span>`:""}
1291
1291
  <a
1292
1292
  class=${$e({breadcrumb:!0,"breadcrumb--current":i})}
1293
1293
  href=${n}
@@ -1299,7 +1299,7 @@ function be(e,t){return(t,i,s)=>((e,t,i)=>(i.configurable=!0,i.enumerable=!0,Ref
1299
1299
  <slot></slot>
1300
1300
  </div>
1301
1301
 
1302
- `}};Me.styles=c`
1302
+ `}};De.styles=c`
1303
1303
  :host {
1304
1304
  display: flex;
1305
1305
  flex-direction: row;
@@ -1365,44 +1365,93 @@ function be(e,t){return(t,i,s)=>((e,t,i)=>(i.configurable=!0,i.enumerable=!0,Ref
1365
1365
  width: 18px;
1366
1366
  height: 18px;
1367
1367
  }
1368
- `,Te([me({type:Array})],Me.prototype,"breadcrumbs",void 0),Te([me({type:Boolean})],Me.prototype,"menu",void 0),Me=Te([pe("kr-subbar")],Me);var Ne=function(e,t,i,s){var n,r=arguments.length,o=r<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,i,s);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(o=(r<3?n(o):r>3?n(t,i,o):n(t,i))||o);return r>3&&o&&Object.defineProperty(t,i,o),o};class Pe{static configure(e){Pe.base=e.base,Pe.routes=e.routes,window.addEventListener("click",(e=>{const t=e.composedPath().find((e=>e instanceof HTMLAnchorElement));t&&t.origin===window.location.origin&&t.pathname.startsWith(Pe.base)&&(e.preventDefault(),Pe.navigate(t.pathname))}))}static navigate(e){let t=e;e.startsWith("/")||(t=Pe.base+"/"+e),window.history.pushState({},"",t),window.dispatchEvent(new PopStateEvent("popstate"))}static getParams(){const e=Pe.matchAll(),t={};for(const i of e)for(const e in i.params)t[e]=decodeURIComponent(i.params[e]);return t}static outlet(e){const t=Pe.matchAll();if(e>=t.length)return null;const i=t[e].route.component,s=Pe.elementCache.get(e+":"+i);if(s)return s;for(const t of Pe.elementCache.keys())t.startsWith(e+":")&&Pe.elementCache.delete(t);const n=document.createElement(i);return Pe.elementCache.set(e+":"+i,n),n}static matchAll(){const e=window.location.pathname;let t=e;e.startsWith(Pe.base)&&(t=e.slice(Pe.base.length));const i=t.split("/").filter((e=>e));return Pe.matchRoutes(Pe.routes,i)}static matchRoutes(e,t){for(const i of e){const e=i.path.split("/").filter((e=>e));if(0===e.length&&0===t.length)return[{route:i,params:{}}];if(0===e.length)continue;if(t.length<e.length)continue;const s={};let n=!0;for(let i=0;i<e.length;i++)if(e[i].startsWith(":"))s[e[i].slice(1)]=t[i];else if(e[i]!==t[i]){n=!1;break}if(!n)continue;const r=t.slice(e.length);if(r.length>0&&!i.children)continue;const o=[{route:i,params:s}];if(i.children&&r.length>0){const e=Pe.matchRoutes(i.children,r);if(e.length>0)return o.push(...e),o}if(i.children&&0===r.length&&i.default){window.history.replaceState({},"",window.location.pathname+"/"+i.default);const e=Pe.matchRoutes(i.children,[i.default]);if(e.length>0)return o.push(...e),o}return o}return[]}}Pe.base="",Pe.routes=[],Pe.elementCache=new Map;let Oe=class extends ce{constructor(){super(...arguments),this.level=-1,this.handlePopState=()=>{this.requestUpdate()}}connectedCallback(){super.connectedCallback(),this.level=this.detectLevel(),window.addEventListener("popstate",this.handlePopState)}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("popstate",this.handlePopState)}detectLevel(){let e=0,t=this;for(;t;)t instanceof ShadowRoot?t=t.host:(t instanceof HTMLElement&&"KR-ROUTER-OUTLET"===t.tagName&&t!==this&&e++,t=t instanceof HTMLElement?t.parentNode:null);return e}render(){const e=Pe.outlet(this.level);return e?X`${e}`:X``}};Oe.styles=c`
1368
+ `,Me([me({type:Array})],De.prototype,"breadcrumbs",void 0),Me([me({type:Boolean})],De.prototype,"menu",void 0),De=Me([pe("kr-subbar")],De);var Oe=function(e,t,i,s){var n,r=arguments.length,o=r<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,i,s);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(o=(r<3?n(o):r>3?n(t,i,o):n(t,i))||o);return r>3&&o&&Object.defineProperty(t,i,o),o};class Ne{static configure(e){Ne.base=e.base,Ne.routes=e.routes,window.addEventListener("click",(e=>{const t=e.composedPath().find((e=>e instanceof HTMLAnchorElement));t&&t.origin===window.location.origin&&t.pathname.startsWith(Ne.base)&&(e.preventDefault(),Ne.navigate(t.pathname))}))}static navigate(e){let t=e;e.startsWith("/")||(t=Ne.base+"/"+e),window.history.pushState({},"",t),window.dispatchEvent(new PopStateEvent("popstate"))}static getParams(){const e=Ne.matchAll(),t={};for(const i of e)for(const e in i.params)t[e]=decodeURIComponent(i.params[e]);return t}static outlet(e){const t=Ne.matchAll();if(e>=t.length)return null;const i=t[e].route.component,s=Ne.elementCache.get(e+":"+i);if(s)return s;for(const t of Ne.elementCache.keys())t.startsWith(e+":")&&Ne.elementCache.delete(t);const n=document.createElement(i);return Ne.elementCache.set(e+":"+i,n),n}static matchAll(){const e=window.location.pathname;let t=e;e.startsWith(Ne.base)&&(t=e.slice(Ne.base.length));const i=t.split("/").filter((e=>e));return Ne.matchRoutes(Ne.routes,i)}static matchRoutes(e,t){for(const i of e){const e=i.path.split("/").filter((e=>e));if(0===e.length&&0===t.length)return[{route:i,params:{}}];if(0===e.length)continue;if(t.length<e.length)continue;const s={};let n=!0;for(let i=0;i<e.length;i++)if(e[i].startsWith(":"))s[e[i].slice(1)]=t[i];else if(e[i]!==t[i]){n=!1;break}if(!n)continue;const r=t.slice(e.length);if(r.length>0&&!i.children)continue;const o=[{route:i,params:s}];if(i.children&&r.length>0){const e=Ne.matchRoutes(i.children,r);if(e.length>0)return o.push(...e),o}if(i.children&&0===r.length&&i.default){window.history.replaceState({},"",window.location.pathname+"/"+i.default);const e=Ne.matchRoutes(i.children,[i.default]);if(e.length>0)return o.push(...e),o}return o}return[]}}Ne.base="",Ne.routes=[],Ne.elementCache=new Map;let Pe=class extends ce{constructor(){super(...arguments),this.level=-1,this.handlePopState=()=>{this.requestUpdate()}}connectedCallback(){super.connectedCallback(),this.level=this.detectLevel(),window.addEventListener("popstate",this.handlePopState)}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("popstate",this.handlePopState)}detectLevel(){let e=0,t=this;for(;t;)t instanceof ShadowRoot?t=t.host:(t instanceof HTMLElement&&"KR-ROUTER-OUTLET"===t.tagName&&t!==this&&e++,t=t instanceof HTMLElement?t.parentNode:null);return e}render(){const e=Ne.outlet(this.level);return e?V`${e}`:V``}};Pe.styles=c`
1369
1369
  :host {
1370
1370
  display: block;
1371
1371
  height: 100%;
1372
1372
  }
1373
- `,Oe=Ne([pe("kr-router-outlet")],Oe);
1373
+ `,Pe=Oe([pe("kr-router-outlet")],Pe);
1374
1374
  /**
1375
1375
  * @license
1376
1376
  * Copyright 2018 Google LLC
1377
1377
  * SPDX-License-Identifier: BSD-3-Clause
1378
1378
  */
1379
- const Fe="important",Ue=" !"+Fe,Le=_e(class extends ke{constructor(e){if(super(e),e.type!==ve||"style"!==e.name||e.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(e){return Object.keys(e).reduce(((t,i)=>{const s=e[i];return null==s?t:t+`${i=i.includes("-")?i:i.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,"-$&").toLowerCase()}:${s};`}),"")}update(e,[t]){const{style:i}=e.element;if(void 0===this.ft)return this.ft=new Set(Object.keys(t)),this.render(t);for(const e of this.ft)null==t[e]&&(this.ft.delete(e),e.includes("-")?i.removeProperty(e):i[e]=null);for(const e in t){const s=t[e];if(null!=s){this.ft.add(e);const t="string"==typeof s&&s.endsWith(Ue);e.includes("-")||t?i.setProperty(e,t?s.slice(0,-11):s,t?Fe:""):i[e]=s}}return Q}}),{I:He}=ae,je=()=>document.createComment(""),Be=(e,t,i)=>{const s=e._$AA.parentNode,n=void 0===t?e._$AB:t._$AA;if(void 0===i){const t=s.insertBefore(je(),n),r=s.insertBefore(je(),n);i=new He(t,r,e,e.options)}else{const t=i._$AB.nextSibling,r=i._$AM,o=r!==e;if(o){let t;i._$AQ?.(e),i._$AM=e,void 0!==i._$AP&&(t=e._$AU)!==r._$AU&&i._$AP(t)}if(t!==n||o){let e=i._$AA;for(;e!==t;){const t=e.nextSibling;s.insertBefore(e,n),e=t}}}return i},qe=(e,t,i=e)=>(e._$AI(t,i),e),We={},Xe=(e,t=We)=>e._$AH=t,Qe=e=>{e._$AR(),e._$AA.remove()},Ve=(e,t,i)=>{const s=new Map;for(let n=t;n<=i;n++)s.set(e[n],n);return s},Ye=_e(class extends ke{constructor(e){if(super(e),e.type!==xe)throw Error("repeat() can only be used in text expressions")}dt(e,t,i){let s;void 0===i?i=t:void 0!==t&&(s=t);const n=[],r=[];let o=0;for(const t of e)n[o]=s?s(t,o):o,r[o]=i(t,o),o++;return{values:r,keys:n}}render(e,t,i){return this.dt(e,t,i).values}update(e,[t,i,s]){const n=(e=>e._$AH)(e),{values:r,keys:o}=this.dt(t,i,s);if(!Array.isArray(n))return this.ut=o,r;const a=this.ut??=[],l=[];let h,c,d=0,p=n.length-1,u=0,g=r.length-1;for(;d<=p&&u<=g;)if(null===n[d])d++;else if(null===n[p])p--;else if(a[d]===o[u])l[u]=qe(n[d],r[u]),d++,u++;else if(a[p]===o[g])l[g]=qe(n[p],r[g]),p--,g--;else if(a[d]===o[g])l[g]=qe(n[d],r[g]),Be(e,l[g+1],n[d]),d++,g--;else if(a[p]===o[u])l[u]=qe(n[p],r[u]),Be(e,n[d],n[p]),p--,u++;else if(void 0===h&&(h=Ve(o,u,g),c=Ve(a,d,p)),h.has(a[d]))if(h.has(a[p])){const t=c.get(o[u]),i=void 0!==t?n[t]:null;if(null===i){const t=Be(e,n[d]);qe(t,r[u]),l[u]=t}else l[u]=qe(i,r[u]),Be(e,n[d],i),n[t]=null;u++}else Qe(n[p]),p--;else Qe(n[d]),d++;for(;u<=g;){const t=Be(e,l[g+1]);qe(t,r[u]),l[u++]=t}for(;d<=p;){const e=n[d++];null!==e&&Qe(e)}return this.ut=o,Xe(e,l),Q}});
1379
+ const Le="important",Fe=" !"+Le,Ue=xe(class extends ke{constructor(e){if(super(e),e.type!==ve||"style"!==e.name||e.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(e){return Object.keys(e).reduce(((t,i)=>{const s=e[i];return null==s?t:t+`${i=i.includes("-")?i:i.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,"-$&").toLowerCase()}:${s};`}),"")}update(e,[t]){const{style:i}=e.element;if(void 0===this.ft)return this.ft=new Set(Object.keys(t)),this.render(t);for(const e of this.ft)null==t[e]&&(this.ft.delete(e),e.includes("-")?i.removeProperty(e):i[e]=null);for(const e in t){const s=t[e];if(null!=s){this.ft.add(e);const t="string"==typeof s&&s.endsWith(Fe);e.includes("-")||t?i.setProperty(e,t?s.slice(0,-11):s,t?Le:""):i[e]=s}}return X}}),{I:je}=ae,He=()=>document.createComment(""),Be=(e,t,i)=>{const s=e._$AA.parentNode,n=void 0===t?e._$AB:t._$AA;if(void 0===i){const t=s.insertBefore(He(),n),r=s.insertBefore(He(),n);i=new je(t,r,e,e.options)}else{const t=i._$AB.nextSibling,r=i._$AM,o=r!==e;if(o){let t;i._$AQ?.(e),i._$AM=e,void 0!==i._$AP&&(t=e._$AU)!==r._$AU&&i._$AP(t)}if(t!==n||o){let e=i._$AA;for(;e!==t;){const t=e.nextSibling;s.insertBefore(e,n),e=t}}}return i},qe=(e,t,i=e)=>(e._$AI(t,i),e),We={},Ve=(e,t=We)=>e._$AH=t,Xe=e=>{e._$AR(),e._$AA.remove()},Qe=(e,t,i)=>{const s=new Map;for(let n=t;n<=i;n++)s.set(e[n],n);return s},Ye=xe(class extends ke{constructor(e){if(super(e),e.type!==_e)throw Error("repeat() can only be used in text expressions")}dt(e,t,i){let s;void 0===i?i=t:void 0!==t&&(s=t);const n=[],r=[];let o=0;for(const t of e)n[o]=s?s(t,o):o,r[o]=i(t,o),o++;return{values:r,keys:n}}render(e,t,i){return this.dt(e,t,i).values}update(e,[t,i,s]){const n=(e=>e._$AH)(e),{values:r,keys:o}=this.dt(t,i,s);if(!Array.isArray(n))return this.ut=o,r;const a=this.ut??=[],l=[];let h,c,d=0,p=n.length-1,u=0,g=r.length-1;for(;d<=p&&u<=g;)if(null===n[d])d++;else if(null===n[p])p--;else if(a[d]===o[u])l[u]=qe(n[d],r[u]),d++,u++;else if(a[p]===o[g])l[g]=qe(n[p],r[g]),p--,g--;else if(a[d]===o[g])l[g]=qe(n[d],r[g]),Be(e,l[g+1],n[d]),d++,g--;else if(a[p]===o[u])l[u]=qe(n[p],r[u]),Be(e,n[d],n[p]),p--,u++;else if(void 0===h&&(h=Qe(o,u,g),c=Qe(a,d,p)),h.has(a[d]))if(h.has(a[p])){const t=c.get(o[u]),i=void 0!==t?n[t]:null;if(null===i){const t=Be(e,n[d]);qe(t,r[u]),l[u]=t}else l[u]=qe(i,r[u]),Be(e,n[d],i),n[t]=null;u++}else Xe(n[p]),p--;else Xe(n[d]),d++;for(;u<=g;){const t=Be(e,l[g+1]);qe(t,r[u]),l[u++]=t}for(;d<=p;){const e=n[d++];null!==e&&Xe(e)}return this.ut=o,Ve(e,l),X}});
1380
1380
  /**
1381
1381
  * @license
1382
1382
  * Copyright 2020 Google LLC
1383
1383
  * SPDX-License-Identifier: BSD-3-Clause
1384
- */function Ke(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}let Ze={async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null};function Ge(e){Ze=e}const Je=/[&<>"']/,et=new RegExp(Je.source,"g"),tt=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,it=new RegExp(tt.source,"g"),st={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},nt=e=>st[e];function rt(e,t){if(t){if(Je.test(e))return e.replace(et,nt)}else if(tt.test(e))return e.replace(it,nt);return e}const ot=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/gi;function at(e){return e.replace(ot,((e,t)=>"colon"===(t=t.toLowerCase())?":":"#"===t.charAt(0)?"x"===t.charAt(1)?String.fromCharCode(parseInt(t.substring(2),16)):String.fromCharCode(+t.substring(1)):""))}const lt=/(^|[^\[])\^/g;function ht(e,t){let i="string"==typeof e?e:e.source;t=t||"";const s={replace:(e,t)=>{let n="string"==typeof t?t:t.source;return n=n.replace(lt,"$1"),i=i.replace(e,n),s},getRegex:()=>new RegExp(i,t)};return s}function ct(e){try{e=encodeURI(e).replace(/%25/g,"%")}catch(e){return null}return e}const dt={exec:()=>null};function pt(e,t){const i=e.replace(/\|/g,((e,t,i)=>{let s=!1,n=t;for(;--n>=0&&"\\"===i[n];)s=!s;return s?"|":" |"})).split(/ \|/);let s=0;if(i[0].trim()||i.shift(),i.length>0&&!i[i.length-1].trim()&&i.pop(),t)if(i.length>t)i.splice(t);else for(;i.length<t;)i.push("");for(;s<i.length;s++)i[s]=i[s].trim().replace(/\\\|/g,"|");return i}function ut(e,t,i){const s=e.length;if(0===s)return"";let n=0;for(;n<s;){if(e.charAt(s-n-1)!==t)break;n++}return e.slice(0,s-n)}function gt(e,t,i,s){const n=t.href,r=t.title?rt(t.title):null,o=e[1].replace(/\\([\[\]])/g,"$1");if("!"!==e[0].charAt(0)){s.state.inLink=!0;const e={type:"link",raw:i,href:n,title:r,text:o,tokens:s.inlineTokens(o)};return s.state.inLink=!1,e}return{type:"image",raw:i,href:n,title:r,text:rt(o)}}class mt{options;rules;lexer;constructor(e){this.options=e||Ze}space(e){const t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(e){const t=this.rules.block.code.exec(e);if(t){const e=t[0].replace(/^ {1,4}/gm,"");return{type:"code",raw:t[0],codeBlockStyle:"indented",text:this.options.pedantic?e:ut(e,"\n")}}}fences(e){const t=this.rules.block.fences.exec(e);if(t){const e=t[0],i=function(e,t){const i=e.match(/^(\s+)(?:```)/);if(null===i)return t;const s=i[1];return t.split("\n").map((e=>{const t=e.match(/^\s+/);if(null===t)return e;const[i]=t;return i.length>=s.length?e.slice(s.length):e})).join("\n")}(e,t[3]||"");return{type:"code",raw:e,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:i}}}heading(e){const t=this.rules.block.heading.exec(e);if(t){let e=t[2].trim();if(/#$/.test(e)){const t=ut(e,"#");this.options.pedantic?e=t.trim():t&&!/ $/.test(t)||(e=t.trim())}return{type:"heading",raw:t[0],depth:t[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(e){const t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:t[0]}}blockquote(e){const t=this.rules.block.blockquote.exec(e);if(t){let e=t[0].replace(/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,"\n $1");e=ut(e.replace(/^ *>[ \t]?/gm,""),"\n");const i=this.lexer.state.top;this.lexer.state.top=!0;const s=this.lexer.blockTokens(e);return this.lexer.state.top=i,{type:"blockquote",raw:t[0],tokens:s,text:e}}}list(e){let t=this.rules.block.list.exec(e);if(t){let i=t[1].trim();const s=i.length>1,n={type:"list",raw:"",ordered:s,start:s?+i.slice(0,-1):"",loose:!1,items:[]};i=s?`\\d{1,9}\\${i.slice(-1)}`:`\\${i}`,this.options.pedantic&&(i=s?i:"[*+-]");const r=new RegExp(`^( {0,3}${i})((?:[\t ][^\\n]*)?(?:\\n|$))`);let o="",a="",l=!1;for(;e;){let i=!1;if(!(t=r.exec(e)))break;if(this.rules.block.hr.test(e))break;o=t[0],e=e.substring(o.length);let s=t[2].split("\n",1)[0].replace(/^\t+/,(e=>" ".repeat(3*e.length))),h=e.split("\n",1)[0],c=0;this.options.pedantic?(c=2,a=s.trimStart()):(c=t[2].search(/[^ ]/),c=c>4?1:c,a=s.slice(c),c+=t[1].length);let d=!1;if(!s&&/^ *$/.test(h)&&(o+=h+"\n",e=e.substring(h.length+1),i=!0),!i){const t=new RegExp(`^ {0,${Math.min(3,c-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ \t][^\\n]*)?(?:\\n|$))`),i=new RegExp(`^ {0,${Math.min(3,c-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),n=new RegExp(`^ {0,${Math.min(3,c-1)}}(?:\`\`\`|~~~)`),r=new RegExp(`^ {0,${Math.min(3,c-1)}}#`);for(;e;){const l=e.split("\n",1)[0];if(h=l,this.options.pedantic&&(h=h.replace(/^ {1,4}(?=( {4})*[^ ])/g," ")),n.test(h))break;if(r.test(h))break;if(t.test(h))break;if(i.test(e))break;if(h.search(/[^ ]/)>=c||!h.trim())a+="\n"+h.slice(c);else{if(d)break;if(s.search(/[^ ]/)>=4)break;if(n.test(s))break;if(r.test(s))break;if(i.test(s))break;a+="\n"+h}d||h.trim()||(d=!0),o+=l+"\n",e=e.substring(l.length+1),s=h.slice(c)}}n.loose||(l?n.loose=!0:/\n *\n *$/.test(o)&&(l=!0));let p,u=null;this.options.gfm&&(u=/^\[[ xX]\] /.exec(a),u&&(p="[ ] "!==u[0],a=a.replace(/^\[[ xX]\] +/,""))),n.items.push({type:"list_item",raw:o,task:!!u,checked:p,loose:!1,text:a,tokens:[]}),n.raw+=o}n.items[n.items.length-1].raw=o.trimEnd(),n.items[n.items.length-1].text=a.trimEnd(),n.raw=n.raw.trimEnd();for(let e=0;e<n.items.length;e++)if(this.lexer.state.top=!1,n.items[e].tokens=this.lexer.blockTokens(n.items[e].text,[]),!n.loose){const t=n.items[e].tokens.filter((e=>"space"===e.type)),i=t.length>0&&t.some((e=>/\n.*\n/.test(e.raw)));n.loose=i}if(n.loose)for(let e=0;e<n.items.length;e++)n.items[e].loose=!0;return n}}html(e){const t=this.rules.block.html.exec(e);if(t){return{type:"html",block:!0,raw:t[0],pre:"pre"===t[1]||"script"===t[1]||"style"===t[1],text:t[0]}}}def(e){const t=this.rules.block.def.exec(e);if(t){const e=t[1].toLowerCase().replace(/\s+/g," "),i=t[2]?t[2].replace(/^<(.*)>$/,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",s=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:e,raw:t[0],href:i,title:s}}}table(e){const t=this.rules.block.table.exec(e);if(!t)return;if(!/[:|]/.test(t[2]))return;const i=pt(t[1]),s=t[2].replace(/^\||\| *$/g,"").split("|"),n=t[3]&&t[3].trim()?t[3].replace(/\n[ \t]*$/,"").split("\n"):[],r={type:"table",raw:t[0],header:[],align:[],rows:[]};if(i.length===s.length){for(const e of s)/^ *-+: *$/.test(e)?r.align.push("right"):/^ *:-+: *$/.test(e)?r.align.push("center"):/^ *:-+ *$/.test(e)?r.align.push("left"):r.align.push(null);for(const e of i)r.header.push({text:e,tokens:this.lexer.inline(e)});for(const e of n)r.rows.push(pt(e,r.header.length).map((e=>({text:e,tokens:this.lexer.inline(e)}))));return r}}lheading(e){const t=this.rules.block.lheading.exec(e);if(t)return{type:"heading",raw:t[0],depth:"="===t[2].charAt(0)?1:2,text:t[1],tokens:this.lexer.inline(t[1])}}paragraph(e){const t=this.rules.block.paragraph.exec(e);if(t){const e="\n"===t[1].charAt(t[1].length-1)?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:e,tokens:this.lexer.inline(e)}}}text(e){const t=this.rules.block.text.exec(e);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){const t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:rt(t[1])}}tag(e){const t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&/^<a /i.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&/^<\/a>/i.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&/^<(pre|code|kbd|script)(\s|>)/i.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){const t=this.rules.inline.link.exec(e);if(t){const e=t[2].trim();if(!this.options.pedantic&&/^</.test(e)){if(!/>$/.test(e))return;const t=ut(e.slice(0,-1),"\\");if((e.length-t.length)%2==0)return}else{const e=function(e,t){if(-1===e.indexOf(t[1]))return-1;let i=0;for(let s=0;s<e.length;s++)if("\\"===e[s])s++;else if(e[s]===t[0])i++;else if(e[s]===t[1]&&(i--,i<0))return s;return-1}(t[2],"()");if(e>-1){const i=(0===t[0].indexOf("!")?5:4)+t[1].length+e;t[2]=t[2].substring(0,e),t[0]=t[0].substring(0,i).trim(),t[3]=""}}let i=t[2],s="";if(this.options.pedantic){const e=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(i);e&&(i=e[1],s=e[3])}else s=t[3]?t[3].slice(1,-1):"";return i=i.trim(),/^</.test(i)&&(i=this.options.pedantic&&!/>$/.test(e)?i.slice(1):i.slice(1,-1)),gt(t,{href:i?i.replace(this.rules.inline.anyPunctuation,"$1"):i,title:s?s.replace(this.rules.inline.anyPunctuation,"$1"):s},t[0],this.lexer)}}reflink(e,t){let i;if((i=this.rules.inline.reflink.exec(e))||(i=this.rules.inline.nolink.exec(e))){const e=t[(i[2]||i[1]).replace(/\s+/g," ").toLowerCase()];if(!e){const e=i[0].charAt(0);return{type:"text",raw:e,text:e}}return gt(i,e,i[0],this.lexer)}}emStrong(e,t,i=""){let s=this.rules.inline.emStrongLDelim.exec(e);if(!s)return;if(s[3]&&i.match(/[\p{L}\p{N}]/u))return;if(!(s[1]||s[2]||"")||!i||this.rules.inline.punctuation.exec(i)){const i=[...s[0]].length-1;let n,r,o=i,a=0;const l="*"===s[0][0]?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(l.lastIndex=0,t=t.slice(-1*e.length+i);null!=(s=l.exec(t));){if(n=s[1]||s[2]||s[3]||s[4]||s[5]||s[6],!n)continue;if(r=[...n].length,s[3]||s[4]){o+=r;continue}if((s[5]||s[6])&&i%3&&!((i+r)%3)){a+=r;continue}if(o-=r,o>0)continue;r=Math.min(r,r+o+a);const t=[...s[0]][0].length,l=e.slice(0,i+s.index+t+r);if(Math.min(i,r)%2){const e=l.slice(1,-1);return{type:"em",raw:l,text:e,tokens:this.lexer.inlineTokens(e)}}const h=l.slice(2,-2);return{type:"strong",raw:l,text:h,tokens:this.lexer.inlineTokens(h)}}}}codespan(e){const t=this.rules.inline.code.exec(e);if(t){let e=t[2].replace(/\n/g," ");const i=/[^ ]/.test(e),s=/^ /.test(e)&&/ $/.test(e);return i&&s&&(e=e.substring(1,e.length-1)),e=rt(e,!0),{type:"codespan",raw:t[0],text:e}}}br(e){const t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e){const t=this.rules.inline.del.exec(e);if(t)return{type:"del",raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2])}}autolink(e){const t=this.rules.inline.autolink.exec(e);if(t){let e,i;return"@"===t[2]?(e=rt(t[1]),i="mailto:"+e):(e=rt(t[1]),i=e),{type:"link",raw:t[0],text:e,href:i,tokens:[{type:"text",raw:e,text:e}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let e,i;if("@"===t[2])e=rt(t[0]),i="mailto:"+e;else{let s;do{s=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??""}while(s!==t[0]);e=rt(t[0]),i="www."===t[1]?"http://"+t[0]:t[0]}return{type:"link",raw:t[0],text:e,href:i,tokens:[{type:"text",raw:e,text:e}]}}}inlineText(e){const t=this.rules.inline.text.exec(e);if(t){let e;return e=this.lexer.state.inRawBlock?t[0]:rt(t[0]),{type:"text",raw:t[0],text:e}}}}const ft=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,bt=/(?:[*+-]|\d{1,9}[.)])/,vt=ht(/^(?!bull |blockCode|fences|blockquote|heading|html)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html))+?)\n {0,3}(=+|-+) *(?:\n+|$)/).replace(/bull/g,bt).replace(/blockCode/g,/ {4}/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).getRegex(),xt=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,_t=/(?!\s*\])(?:\\.|[^\[\]\\])+/,kt=ht(/^ {0,3}\[(label)\]: *(?:\n *)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/).replace("label",_t).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),yt=ht(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,bt).getRegex(),wt="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",$t=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,St=ht("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n *)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$))","i").replace("comment",$t).replace("tag",wt).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),It=ht(xt).replace("hr",ft).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",wt).getRegex(),Et={blockquote:ht(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",It).getRegex(),code:/^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/,def:kt,fences:/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,heading:/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,hr:ft,html:St,lheading:vt,list:yt,newline:/^(?: *(?:\n|$))+/,paragraph:It,table:dt,text:/^[^\n]+/},Ct=ht("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",ft).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code"," {4}[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",wt).getRegex(),zt={...Et,table:Ct,paragraph:ht(xt).replace("hr",ft).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Ct).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",wt).getRegex()},At={...Et,html:ht("^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:\"[^\"]*\"|'[^']*'|\\s[^'\"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))").replace("comment",$t).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:dt,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:ht(xt).replace("hr",ft).replace("heading"," *#{1,6} *[^\n]").replace("lheading",vt).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},Rt=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Dt=/^( {2,}|\\)\n(?!\s*$)/,Tt="\\p{P}\\p{S}",Mt=ht(/^((?![*_])[\spunctuation])/,"u").replace(/punctuation/g,Tt).getRegex(),Nt=ht(/^(?:\*+(?:((?!\*)[punct])|[^\s*]))|^_+(?:((?!_)[punct])|([^\s_]))/,"u").replace(/punct/g,Tt).getRegex(),Pt=ht("^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)[punct](\\*+)(?=[\\s]|$)|[^punct\\s](\\*+)(?!\\*)(?=[punct\\s]|$)|(?!\\*)[punct\\s](\\*+)(?=[^punct\\s])|[\\s](\\*+)(?!\\*)(?=[punct])|(?!\\*)[punct](\\*+)(?!\\*)(?=[punct])|[^punct\\s](\\*+)(?=[^punct\\s])","gu").replace(/punct/g,Tt).getRegex(),Ot=ht("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)[punct](_+)(?=[\\s]|$)|[^punct\\s](_+)(?!_)(?=[punct\\s]|$)|(?!_)[punct\\s](_+)(?=[^punct\\s])|[\\s](_+)(?!_)(?=[punct])|(?!_)[punct](_+)(?!_)(?=[punct])","gu").replace(/punct/g,Tt).getRegex(),Ft=ht(/\\([punct])/,"gu").replace(/punct/g,Tt).getRegex(),Ut=ht(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),Lt=ht($t).replace("(?:--\x3e|$)","--\x3e").getRegex(),Ht=ht("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",Lt).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),jt=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,Bt=ht(/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/).replace("label",jt).replace("href",/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),qt=ht(/^!?\[(label)\]\[(ref)\]/).replace("label",jt).replace("ref",_t).getRegex(),Wt=ht(/^!?\[(ref)\](?:\[\])?/).replace("ref",_t).getRegex(),Xt={_backpedal:dt,anyPunctuation:Ft,autolink:Ut,blockSkip:/\[[^[\]]*?\]\([^\(\)]*?\)|`[^`]*?`|<[^<>]*?>/g,br:Dt,code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,del:dt,emStrongLDelim:Nt,emStrongRDelimAst:Pt,emStrongRDelimUnd:Ot,escape:Rt,link:Bt,nolink:Wt,punctuation:Mt,reflink:qt,reflinkSearch:ht("reflink|nolink(?!\\()","g").replace("reflink",qt).replace("nolink",Wt).getRegex(),tag:Ht,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,url:dt},Qt={...Xt,link:ht(/^!?\[(label)\]\((.*?)\)/).replace("label",jt).getRegex(),reflink:ht(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",jt).getRegex()},Vt={...Xt,escape:ht(Rt).replace("])","~|])").getRegex(),url:ht(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,"i").replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/},Yt={...Vt,br:ht(Dt).replace("{2,}","*").getRegex(),text:ht(Vt.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Kt={normal:Et,gfm:zt,pedantic:At},Zt={normal:Xt,gfm:Vt,breaks:Yt,pedantic:Qt};class Gt{tokens;options;state;tokenizer;inlineQueue;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||Ze,this.options.tokenizer=this.options.tokenizer||new mt,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};const t={block:Kt.normal,inline:Zt.normal};this.options.pedantic?(t.block=Kt.pedantic,t.inline=Zt.pedantic):this.options.gfm&&(t.block=Kt.gfm,this.options.breaks?t.inline=Zt.breaks:t.inline=Zt.gfm),this.tokenizer.rules=t}static get rules(){return{block:Kt,inline:Zt}}static lex(e,t){return new Gt(t).lex(e)}static lexInline(e,t){return new Gt(t).inlineTokens(e)}lex(e){e=e.replace(/\r\n|\r/g,"\n"),this.blockTokens(e,this.tokens);for(let e=0;e<this.inlineQueue.length;e++){const t=this.inlineQueue[e];this.inlineTokens(t.src,t.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[]){let i,s,n,r;for(e=this.options.pedantic?e.replace(/\t/g," ").replace(/^ +$/gm,""):e.replace(/^( *)(\t+)/gm,((e,t,i)=>t+" ".repeat(i.length)));e;)if(!(this.options.extensions&&this.options.extensions.block&&this.options.extensions.block.some((s=>!!(i=s.call({lexer:this},e,t))&&(e=e.substring(i.raw.length),t.push(i),!0)))))if(i=this.tokenizer.space(e))e=e.substring(i.raw.length),1===i.raw.length&&t.length>0?t[t.length-1].raw+="\n":t.push(i);else if(i=this.tokenizer.code(e))e=e.substring(i.raw.length),s=t[t.length-1],!s||"paragraph"!==s.type&&"text"!==s.type?t.push(i):(s.raw+="\n"+i.raw,s.text+="\n"+i.text,this.inlineQueue[this.inlineQueue.length-1].src=s.text);else if(i=this.tokenizer.fences(e))e=e.substring(i.raw.length),t.push(i);else if(i=this.tokenizer.heading(e))e=e.substring(i.raw.length),t.push(i);else if(i=this.tokenizer.hr(e))e=e.substring(i.raw.length),t.push(i);else if(i=this.tokenizer.blockquote(e))e=e.substring(i.raw.length),t.push(i);else if(i=this.tokenizer.list(e))e=e.substring(i.raw.length),t.push(i);else if(i=this.tokenizer.html(e))e=e.substring(i.raw.length),t.push(i);else if(i=this.tokenizer.def(e))e=e.substring(i.raw.length),s=t[t.length-1],!s||"paragraph"!==s.type&&"text"!==s.type?this.tokens.links[i.tag]||(this.tokens.links[i.tag]={href:i.href,title:i.title}):(s.raw+="\n"+i.raw,s.text+="\n"+i.raw,this.inlineQueue[this.inlineQueue.length-1].src=s.text);else if(i=this.tokenizer.table(e))e=e.substring(i.raw.length),t.push(i);else if(i=this.tokenizer.lheading(e))e=e.substring(i.raw.length),t.push(i);else{if(n=e,this.options.extensions&&this.options.extensions.startBlock){let t=1/0;const i=e.slice(1);let s;this.options.extensions.startBlock.forEach((e=>{s=e.call({lexer:this},i),"number"==typeof s&&s>=0&&(t=Math.min(t,s))})),t<1/0&&t>=0&&(n=e.substring(0,t+1))}if(this.state.top&&(i=this.tokenizer.paragraph(n)))s=t[t.length-1],r&&"paragraph"===s.type?(s.raw+="\n"+i.raw,s.text+="\n"+i.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=s.text):t.push(i),r=n.length!==e.length,e=e.substring(i.raw.length);else if(i=this.tokenizer.text(e))e=e.substring(i.raw.length),s=t[t.length-1],s&&"text"===s.type?(s.raw+="\n"+i.raw,s.text+="\n"+i.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=s.text):t.push(i);else if(e){const t="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(t);break}throw new Error(t)}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){let i,s,n,r,o,a,l=e;if(this.tokens.links){const e=Object.keys(this.tokens.links);if(e.length>0)for(;null!=(r=this.tokenizer.rules.inline.reflinkSearch.exec(l));)e.includes(r[0].slice(r[0].lastIndexOf("[")+1,-1))&&(l=l.slice(0,r.index)+"["+"a".repeat(r[0].length-2)+"]"+l.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;null!=(r=this.tokenizer.rules.inline.blockSkip.exec(l));)l=l.slice(0,r.index)+"["+"a".repeat(r[0].length-2)+"]"+l.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;null!=(r=this.tokenizer.rules.inline.anyPunctuation.exec(l));)l=l.slice(0,r.index)+"++"+l.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;e;)if(o||(a=""),o=!1,!(this.options.extensions&&this.options.extensions.inline&&this.options.extensions.inline.some((s=>!!(i=s.call({lexer:this},e,t))&&(e=e.substring(i.raw.length),t.push(i),!0)))))if(i=this.tokenizer.escape(e))e=e.substring(i.raw.length),t.push(i);else if(i=this.tokenizer.tag(e))e=e.substring(i.raw.length),s=t[t.length-1],s&&"text"===i.type&&"text"===s.type?(s.raw+=i.raw,s.text+=i.text):t.push(i);else if(i=this.tokenizer.link(e))e=e.substring(i.raw.length),t.push(i);else if(i=this.tokenizer.reflink(e,this.tokens.links))e=e.substring(i.raw.length),s=t[t.length-1],s&&"text"===i.type&&"text"===s.type?(s.raw+=i.raw,s.text+=i.text):t.push(i);else if(i=this.tokenizer.emStrong(e,l,a))e=e.substring(i.raw.length),t.push(i);else if(i=this.tokenizer.codespan(e))e=e.substring(i.raw.length),t.push(i);else if(i=this.tokenizer.br(e))e=e.substring(i.raw.length),t.push(i);else if(i=this.tokenizer.del(e))e=e.substring(i.raw.length),t.push(i);else if(i=this.tokenizer.autolink(e))e=e.substring(i.raw.length),t.push(i);else if(this.state.inLink||!(i=this.tokenizer.url(e))){if(n=e,this.options.extensions&&this.options.extensions.startInline){let t=1/0;const i=e.slice(1);let s;this.options.extensions.startInline.forEach((e=>{s=e.call({lexer:this},i),"number"==typeof s&&s>=0&&(t=Math.min(t,s))})),t<1/0&&t>=0&&(n=e.substring(0,t+1))}if(i=this.tokenizer.inlineText(n))e=e.substring(i.raw.length),"_"!==i.raw.slice(-1)&&(a=i.raw.slice(-1)),o=!0,s=t[t.length-1],s&&"text"===s.type?(s.raw+=i.raw,s.text+=i.text):t.push(i);else if(e){const t="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(t);break}throw new Error(t)}}else e=e.substring(i.raw.length),t.push(i);return t}}class Jt{options;constructor(e){this.options=e||Ze}code(e,t,i){const s=(t||"").match(/^\S*/)?.[0];return e=e.replace(/\n$/,"")+"\n",s?'<pre><code class="language-'+rt(s)+'">'+(i?e:rt(e,!0))+"</code></pre>\n":"<pre><code>"+(i?e:rt(e,!0))+"</code></pre>\n"}blockquote(e){return`<blockquote>\n${e}</blockquote>\n`}html(e,t){return e}heading(e,t,i){return`<h${t}>${e}</h${t}>\n`}hr(){return"<hr>\n"}list(e,t,i){const s=t?"ol":"ul";return"<"+s+(t&&1!==i?' start="'+i+'"':"")+">\n"+e+"</"+s+">\n"}listitem(e,t,i){return`<li>${e}</li>\n`}checkbox(e){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox">'}paragraph(e){return`<p>${e}</p>\n`}table(e,t){return t&&(t=`<tbody>${t}</tbody>`),"<table>\n<thead>\n"+e+"</thead>\n"+t+"</table>\n"}tablerow(e){return`<tr>\n${e}</tr>\n`}tablecell(e,t){const i=t.header?"th":"td";return(t.align?`<${i} align="${t.align}">`:`<${i}>`)+e+`</${i}>\n`}strong(e){return`<strong>${e}</strong>`}em(e){return`<em>${e}</em>`}codespan(e){return`<code>${e}</code>`}br(){return"<br>"}del(e){return`<del>${e}</del>`}link(e,t,i){const s=ct(e);if(null===s)return i;let n='<a href="'+(e=s)+'"';return t&&(n+=' title="'+t+'"'),n+=">"+i+"</a>",n}image(e,t,i){const s=ct(e);if(null===s)return i;let n=`<img src="${e=s}" alt="${i}"`;return t&&(n+=` title="${t}"`),n+=">",n}text(e){return e}}class ei{strong(e){return e}em(e){return e}codespan(e){return e}del(e){return e}html(e){return e}text(e){return e}link(e,t,i){return""+i}image(e,t,i){return""+i}br(){return""}}class ti{options;renderer;textRenderer;constructor(e){this.options=e||Ze,this.options.renderer=this.options.renderer||new Jt,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new ei}static parse(e,t){return new ti(t).parse(e)}static parseInline(e,t){return new ti(t).parseInline(e)}parse(e,t=!0){let i="";for(let s=0;s<e.length;s++){const n=e[s];if(this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[n.type]){const e=n,t=this.options.extensions.renderers[e.type].call({parser:this},e);if(!1!==t||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(e.type)){i+=t||"";continue}}switch(n.type){case"space":continue;case"hr":i+=this.renderer.hr();continue;case"heading":{const e=n;i+=this.renderer.heading(this.parseInline(e.tokens),e.depth,at(this.parseInline(e.tokens,this.textRenderer)));continue}case"code":{const e=n;i+=this.renderer.code(e.text,e.lang,!!e.escaped);continue}case"table":{const e=n;let t="",s="";for(let t=0;t<e.header.length;t++)s+=this.renderer.tablecell(this.parseInline(e.header[t].tokens),{header:!0,align:e.align[t]});t+=this.renderer.tablerow(s);let r="";for(let t=0;t<e.rows.length;t++){const i=e.rows[t];s="";for(let t=0;t<i.length;t++)s+=this.renderer.tablecell(this.parseInline(i[t].tokens),{header:!1,align:e.align[t]});r+=this.renderer.tablerow(s)}i+=this.renderer.table(t,r);continue}case"blockquote":{const e=n,t=this.parse(e.tokens);i+=this.renderer.blockquote(t);continue}case"list":{const e=n,t=e.ordered,s=e.start,r=e.loose;let o="";for(let t=0;t<e.items.length;t++){const i=e.items[t],s=i.checked,n=i.task;let a="";if(i.task){const e=this.renderer.checkbox(!!s);r?i.tokens.length>0&&"paragraph"===i.tokens[0].type?(i.tokens[0].text=e+" "+i.tokens[0].text,i.tokens[0].tokens&&i.tokens[0].tokens.length>0&&"text"===i.tokens[0].tokens[0].type&&(i.tokens[0].tokens[0].text=e+" "+i.tokens[0].tokens[0].text)):i.tokens.unshift({type:"text",text:e+" "}):a+=e+" "}a+=this.parse(i.tokens,r),o+=this.renderer.listitem(a,n,!!s)}i+=this.renderer.list(o,t,s);continue}case"html":{const e=n;i+=this.renderer.html(e.text,e.block);continue}case"paragraph":{const e=n;i+=this.renderer.paragraph(this.parseInline(e.tokens));continue}case"text":{let r=n,o=r.tokens?this.parseInline(r.tokens):r.text;for(;s+1<e.length&&"text"===e[s+1].type;)r=e[++s],o+="\n"+(r.tokens?this.parseInline(r.tokens):r.text);i+=t?this.renderer.paragraph(o):o;continue}default:{const e='Token with "'+n.type+'" type was not found.';if(this.options.silent)return console.error(e),"";throw new Error(e)}}}return i}parseInline(e,t){t=t||this.renderer;let i="";for(let s=0;s<e.length;s++){const n=e[s];if(this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[n.type]){const e=this.options.extensions.renderers[n.type].call({parser:this},n);if(!1!==e||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(n.type)){i+=e||"";continue}}switch(n.type){case"escape":{const e=n;i+=t.text(e.text);break}case"html":{const e=n;i+=t.html(e.text);break}case"link":{const e=n;i+=t.link(e.href,e.title,this.parseInline(e.tokens,t));break}case"image":{const e=n;i+=t.image(e.href,e.title,e.text);break}case"strong":{const e=n;i+=t.strong(this.parseInline(e.tokens,t));break}case"em":{const e=n;i+=t.em(this.parseInline(e.tokens,t));break}case"codespan":{const e=n;i+=t.codespan(e.text);break}case"br":i+=t.br();break;case"del":{const e=n;i+=t.del(this.parseInline(e.tokens,t));break}case"text":{const e=n;i+=t.text(e.text);break}default:{const e='Token with "'+n.type+'" type was not found.';if(this.options.silent)return console.error(e),"";throw new Error(e)}}}return i}}class ii{options;constructor(e){this.options=e||Ze}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}}const si=new class{defaults={async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null};options=this.setOptions;parse=this.#e(Gt.lex,ti.parse);parseInline=this.#e(Gt.lexInline,ti.parseInline);Parser=ti;Renderer=Jt;TextRenderer=ei;Lexer=Gt;Tokenizer=mt;Hooks=ii;constructor(...e){this.use(...e)}walkTokens(e,t){let i=[];for(const s of e)switch(i=i.concat(t.call(this,s)),s.type){case"table":{const e=s;for(const s of e.header)i=i.concat(this.walkTokens(s.tokens,t));for(const s of e.rows)for(const e of s)i=i.concat(this.walkTokens(e.tokens,t));break}case"list":{const e=s;i=i.concat(this.walkTokens(e.items,t));break}default:{const e=s;this.defaults.extensions?.childTokens?.[e.type]?this.defaults.extensions.childTokens[e.type].forEach((s=>{const n=e[s].flat(1/0);i=i.concat(this.walkTokens(n,t))})):e.tokens&&(i=i.concat(this.walkTokens(e.tokens,t)))}}return i}use(...e){const t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach((e=>{const i={...e};if(i.async=this.defaults.async||i.async||!1,e.extensions&&(e.extensions.forEach((e=>{if(!e.name)throw new Error("extension name required");if("renderer"in e){const i=t.renderers[e.name];t.renderers[e.name]=i?function(...t){let s=e.renderer.apply(this,t);return!1===s&&(s=i.apply(this,t)),s}:e.renderer}if("tokenizer"in e){if(!e.level||"block"!==e.level&&"inline"!==e.level)throw new Error("extension level must be 'block' or 'inline'");const i=t[e.level];i?i.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&("block"===e.level?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:"inline"===e.level&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}"childTokens"in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)})),i.extensions=t),e.renderer){const t=this.defaults.renderer||new Jt(this.defaults);for(const i in e.renderer){if(!(i in t))throw new Error(`renderer '${i}' does not exist`);if("options"===i)continue;const s=i,n=e.renderer[s],r=t[s];t[s]=(...e)=>{let i=n.apply(t,e);return!1===i&&(i=r.apply(t,e)),i||""}}i.renderer=t}if(e.tokenizer){const t=this.defaults.tokenizer||new mt(this.defaults);for(const i in e.tokenizer){if(!(i in t))throw new Error(`tokenizer '${i}' does not exist`);if(["options","rules","lexer"].includes(i))continue;const s=i,n=e.tokenizer[s],r=t[s];t[s]=(...e)=>{let i=n.apply(t,e);return!1===i&&(i=r.apply(t,e)),i}}i.tokenizer=t}if(e.hooks){const t=this.defaults.hooks||new ii;for(const i in e.hooks){if(!(i in t))throw new Error(`hook '${i}' does not exist`);if("options"===i)continue;const s=i,n=e.hooks[s],r=t[s];ii.passThroughHooks.has(i)?t[s]=e=>{if(this.defaults.async)return Promise.resolve(n.call(t,e)).then((e=>r.call(t,e)));const i=n.call(t,e);return r.call(t,i)}:t[s]=(...e)=>{let i=n.apply(t,e);return!1===i&&(i=r.apply(t,e)),i}}i.hooks=t}if(e.walkTokens){const t=this.defaults.walkTokens,s=e.walkTokens;i.walkTokens=function(e){let i=[];return i.push(s.call(this,e)),t&&(i=i.concat(t.call(this,e))),i}}this.defaults={...this.defaults,...i}})),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return Gt.lex(e,t??this.defaults)}parser(e,t){return ti.parse(e,t??this.defaults)}#e(e,t){return(i,s)=>{const n={...s},r={...this.defaults,...n};!0===this.defaults.async&&!1===n.async&&(r.silent||console.warn("marked(): The async option was set to true by an extension. The async: false option sent to parse will be ignored."),r.async=!0);const o=this.#t(!!r.silent,!!r.async);if(null==i)return o(new Error("marked(): input parameter is undefined or null"));if("string"!=typeof i)return o(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(i)+", string expected"));if(r.hooks&&(r.hooks.options=r),r.async)return Promise.resolve(r.hooks?r.hooks.preprocess(i):i).then((t=>e(t,r))).then((e=>r.hooks?r.hooks.processAllTokens(e):e)).then((e=>r.walkTokens?Promise.all(this.walkTokens(e,r.walkTokens)).then((()=>e)):e)).then((e=>t(e,r))).then((e=>r.hooks?r.hooks.postprocess(e):e)).catch(o);try{r.hooks&&(i=r.hooks.preprocess(i));let s=e(i,r);r.hooks&&(s=r.hooks.processAllTokens(s)),r.walkTokens&&this.walkTokens(s,r.walkTokens);let n=t(s,r);return r.hooks&&(n=r.hooks.postprocess(n)),n}catch(e){return o(e)}}}#t(e,t){return i=>{if(i.message+="\nPlease report this to https://github.com/markedjs/marked.",e){const e="<p>An error occurred:</p><pre>"+rt(i.message+"",!0)+"</pre>";return t?Promise.resolve(e):e}if(t)return Promise.reject(i);throw i}}};function ni(e,t){return si.parse(e,t)}ni.options=ni.setOptions=function(e){return si.setOptions(e),ni.defaults=si.defaults,Ge(ni.defaults),ni},ni.getDefaults=Ke,ni.defaults=Ze,ni.use=function(...e){return si.use(...e),ni.defaults=si.defaults,Ge(ni.defaults),ni},ni.walkTokens=function(e,t){return si.walkTokens(e,t)},ni.parseInline=si.parseInline,ni.Parser=ti,ni.parser=ti.parse,ni.Renderer=Jt,ni.TextRenderer=ei,ni.Lexer=Gt,ni.lexer=Gt.lex,ni.Tokenizer=mt,ni.Hooks=ii,ni.parse=ni,ni.options,ni.setOptions,ni.use,ni.walkTokens,ni.parseInline,ti.parse,Gt.lex;var ri=function(e,t,i,s){var n,r=arguments.length,o=r<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,i,s);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(o=(r<3?n(o):r>3?n(t,i,o):n(t,i))||o);return r>3&&o&&Object.defineProperty(t,i,o),o};const oi=[{decision:"approve",label:"Yes"},{decision:"approveAlways",label:"Always allow"},{decision:"reject",label:"No"}],ai=["jpg","jpeg","png","gif","webp"],li=["pdf","doc","docx","xls","xlsx","csv","html","md","txt","json","xml","vtt","srt",...ai,"mp4","webm","ogg","mov"];let hi=class extends ce{constructor(){super(...arguments),this._reader=null,this._decoder=new TextDecoder,this._buffer="",this._userHasScrolledUp=!1,this._isDragging=!1,this._isResizing=!1,this._overlay=null,this._resizeDir="",this._dragStartX=0,this._dragStartY=0,this._dragStartLeft=0,this._dragStartTop=0,this._resizeStartW=0,this._resizeStartH=0,this._debugResizeStartX=0,this._debugResizeStartW=0,this._dragDepth=0,this._pendingSeq=0,this._pendingAttachAnalyze=!0,this._orgSkillRequestId=0,this._globalSkillRequestId=0,this._invocableSkillRequestId=0,this._globalSkillPending=new Set,this._speechRecognition=null,this._speechBaseValue="",this._speechFinalTranscript="",this.send=null,this.load=null,this.messages=[],this.label="Kat",this.placeholder="Type a message...",this.opened=!1,this.hideToggle=!1,this.variant="floating",this.conversationId=null,this._inputValue="",this._isStreaming=!1,this._error="",this._contextWarning="",this._contextLimitReached=!1,this._contextLimitMessage="",this._pendingActions=[],this._confirmationHighlighted=-1,this._confirmationInFlight=!1,this._telemetry=null,this._iterationLog=[],this._cacheCheckpoints={},this._debugPanelOpen=!1,this._debugDrawerWidth=430,this._isDebugResizing=!1,this._pendingConversationFiles=[],this._isDraggingFile=!1,this._skillMenuOpened=!1,this._skillQuery="",this._orgSkills=[],this._globalSkills=[],this._invocableSkills=[],this._aiFrameworkConfig={},this._skillHighlighted=0,this._copiedIndex=-1,this._skillBrowseOpened=!1,this._skillBrowseSource="org",this._skillBrowseQuery="",this._isDictating=!1,this._handleDocumentClick=e=>{if(!this._skillMenuOpened)return;e.composedPath().some((e=>e instanceof HTMLElement&&(e.classList.contains("skill-menu")||e.classList.contains("input")||e.classList.contains("input-plus"))))||(this._skillMenuOpened=!1)},this._handleMouseMove=e=>{if(this._isDragging){let t=this._dragStartLeft+(e.clientX-this._dragStartX),i=this._dragStartTop+(e.clientY-this._dragStartY);const s=this._panelEl.offsetWidth;t=Math.max(48-s,Math.min(t,window.innerWidth-48)),i=Math.max(0,Math.min(i,window.innerHeight-48)),this._panelEl.style.left=t+"px",this._panelEl.style.top=i+"px"}else if(this._isResizing){const t=e.clientX-this._dragStartX,i=e.clientY-this._dragStartY,s=340,n=380,r=.9*window.innerWidth,o=window.innerHeight-72;let a=this._resizeStartW,l=this._resizeStartH,h=this._dragStartLeft,c=this._dragStartTop;this._resizeDir.includes("e")&&(a=Math.max(s,Math.min(this._resizeStartW+t,r))),this._resizeDir.includes("w")&&(a=Math.max(s,Math.min(this._resizeStartW-t,r)),h=this._dragStartLeft+(this._resizeStartW-a)),this._resizeDir.includes("s")&&(l=Math.max(n,Math.min(this._resizeStartH+i,o))),this._resizeDir.includes("n")&&(l=Math.max(n,Math.min(this._resizeStartH-i,o)),c=this._dragStartTop+(this._resizeStartH-l)),h=Math.max(0,h),c=Math.max(0,c),this._panelEl.style.width=a+"px",this._panelEl.style.height=l+"px",this._panelEl.style.left=h+"px",this._panelEl.style.top=c+"px"}},this._handleMouseUp=()=>{this._isDragging&&(this._isDragging=!1,this._panelEl.classList.remove("panel--dragging")),this._isResizing&&(this._isResizing=!1,this._panelEl.classList.remove("panel--resizing")),this._overlay&&(this._overlay.style.display="none"),document.removeEventListener("mousemove",this._handleMouseMove),document.removeEventListener("mouseup",this._handleMouseUp),this._saveState()},this._handleDocumentKeydown=e=>{if(this._pendingActions.length&&!this._confirmationInFlight){if("ArrowRight"===e.key)return e.preventDefault(),void(this._confirmationHighlighted=(this._confirmationHighlighted+1)%oi.length);if("ArrowLeft"===e.key)return e.preventDefault(),void(this._confirmationHighlighted=(this._confirmationHighlighted-1+oi.length)%oi.length);if("Enter"===e.key){e.preventDefault();const t=oi[this._confirmationHighlighted];t&&this._handleConfirmationDecision(t.decision)}}},this._handleDebugResizeMouseMove=e=>{if(!this._isDebugResizing)return;const t=e.clientX-this._debugResizeStartX,i=Math.max(300,this.offsetWidth-300);this._debugDrawerWidth=Math.max(300,Math.min(this._debugResizeStartW-t,i))},this._handleDebugResizeMouseUp=()=>{this._isDebugResizing=!1,document.removeEventListener("mousemove",this._handleDebugResizeMouseMove),document.removeEventListener("mouseup",this._handleDebugResizeMouseUp),this._saveState()}}connectedCallback(){super.connectedCallback(),this.load||(this.load=()=>null==this.conversationId?Promise.resolve([]):n.fetch({url:`/api/system/conversation/${this.conversationId}/messages`}).then((e=>e.json())).then((e=>Promise.all((e?.data||[]).map((e=>{let t=[];try{t=JSON.parse(e.conversationFileIDs||"[]")}catch{}return t.length?Promise.all(t.map((e=>n.fetch({url:`/api/system/conversationFile/${e}`}).then((e=>e.json())).then((e=>e?.data)).catch((()=>null))))).then((t=>(e.conversationFiles=t.filter((e=>null!=e)),e))):Promise.resolve(e)})))))),this.load().then((e=>{e&&e.length&&(this.messages=e)})).catch((()=>{})),n.fetch({url:"/api/system/integration/aws/bedrock/aiFrameworkConfig"}).then((e=>e.json())).then((e=>{this._aiFrameworkConfig=e?.data||{}})).catch((()=>{})),"inline"===this.variant&&(this.opened=!0),this._restoreState(),document.addEventListener("click",this._handleDocumentClick),document.addEventListener("keydown",this._handleDocumentKeydown)}disconnectedCallback(){super.disconnectedCallback(),this._reader&&(this._reader.cancel(),this._reader=null),document.removeEventListener("mousemove",this._handleMouseMove),document.removeEventListener("mouseup",this._handleMouseUp),document.removeEventListener("click",this._handleDocumentClick),document.removeEventListener("keydown",this._handleDocumentKeydown),this._speechRecognition&&(this._speechRecognition.abort(),this._speechRecognition=null,this._isDictating=!1),this._pendingConversationFiles.forEach((e=>{e.previewUrl&&URL.revokeObjectURL(e.previewUrl)}))}updated(e){e.has("messages")&&(this._userHasScrolledUp||this._isStreaming||!this._messagesEl||requestAnimationFrame((()=>{this._messagesEl&&(this._messagesEl.scrollTop=this._messagesEl.scrollHeight)}))),e.has("opened")&&this.opened&&this._inputEl&&setTimeout((()=>{this._inputEl&&this._inputEl.focus()}),200),this._skillMenuOpened&&this._positionSkillMenu(),e.has("_skillHighlighted")&&this._skillMenuOpened&&this._skillMenuEl?.querySelector(".skill-menu__item--highlighted")?.scrollIntoView({block:"nearest"})}_positionSkillMenu(){requestAnimationFrame((()=>{if(!this._skillMenuEl||!this._inputWrapperEl)return;const e=this._inputWrapperEl.getBoundingClientRect();this._skillMenuEl.style.left=e.left+"px",this._skillMenuEl.style.width=e.width+"px";const t=this._panelEl.getBoundingClientRect().top+8,i=e.top-8-t;this._skillMenuEl.style.maxHeight=i+"px";const s=this._skillMenuEl.getBoundingClientRect(),n=Math.max(t,e.top-s.height-8);this._skillMenuEl.style.top=n+"px"}))}stop(){this._handleStop()}isStreaming(){return this._isStreaming}open(){this.opened||this._handleToggle()}close(){this.opened&&this._handleToggle()}toggle(){this._handleToggle()}_showOverlay(){this._overlay||(this._overlay=document.createElement("div"),this._overlay.style.cssText="position:fixed; inset:0; z-index:9999; display:none;",document.body.appendChild(this._overlay)),this._overlay.style.display="block"}_handleHeaderMouseDown(e){if("inline"===this.variant)return;if(e.target.closest("button"))return;if(!this._panelEl)return;this._isDragging=!0,this._panelEl.classList.add("panel--dragging"),this._showOverlay();const t=this._panelEl.getBoundingClientRect();this._panelEl.style.left=t.left+"px",this._panelEl.style.top=t.top+"px",this._panelEl.style.right="auto",this._panelEl.style.bottom="auto",this._panelEl.style.position="fixed",this._dragStartX=e.clientX,this._dragStartY=e.clientY,this._dragStartLeft=t.left,this._dragStartTop=t.top,e.preventDefault(),document.addEventListener("mousemove",this._handleMouseMove),document.addEventListener("mouseup",this._handleMouseUp)}_handleResizeMouseDown(e){if("inline"===this.variant)return;if(!this._panelEl)return;this._isResizing=!0,this._resizeDir=e.currentTarget.dataset.dir||"",this._panelEl.classList.add("panel--resizing"),this._showOverlay();const t=this._panelEl.getBoundingClientRect();this._panelEl.style.left=t.left+"px",this._panelEl.style.top=t.top+"px",this._panelEl.style.right="auto",this._panelEl.style.bottom="auto",this._panelEl.style.position="fixed",this._dragStartX=e.clientX,this._dragStartY=e.clientY,this._dragStartLeft=t.left,this._dragStartTop=t.top,this._resizeStartW=t.width,this._resizeStartH=t.height,e.preventDefault(),e.stopPropagation(),document.addEventListener("mousemove",this._handleMouseMove),document.addEventListener("mouseup",this._handleMouseUp)}_handleToggle(){this.opened=!this.opened,this.opened&&this._panelEl&&this._applyStoredLayout(),this._saveState()}_saveState(){try{const e={opened:String(this.opened),message:this._inputValue,debugPanelOpen:String(this._debugPanelOpen),debugDrawerWidth:String(this._debugDrawerWidth)};if(this._panelEl){const t=this._panelEl.style;t.left&&(e.left=t.left),t.top&&(e.top=t.top),t.width&&(e.width=t.width),t.height&&(e.height=t.height),t.position&&(e.position=t.position)}localStorage.setItem("kr-chatbot-state",JSON.stringify(e))}catch{}}_restoreState(){try{const e=localStorage.getItem("kr-chatbot-state");if(!e)return;const t=JSON.parse(e);"string"==typeof t.message&&"/"!==t.message.trim()&&(this._inputValue=t.message),this._debugPanelOpen="true"===t.debugPanelOpen;const i=Number(t.debugDrawerWidth);i>=300&&(this._debugDrawerWidth=i),"inline"!==this.variant&&"true"===t.opened&&(this.opened=!0,this.updateComplete.then((()=>this._applyStoredLayout())))}catch{}}_applyStoredLayout(){try{const e=localStorage.getItem("kr-chatbot-state");if(!e||!this._panelEl)return;const t=JSON.parse(e);t.position&&(this._panelEl.style.position=t.position),t.left&&(this._panelEl.style.left=t.left),t.top&&(this._panelEl.style.top=t.top),t.width&&(this._panelEl.style.width=t.width),t.height&&(this._panelEl.style.height=t.height)}catch{}}_handleInputChange(e){this._inputValue=e.target.value,this._saveState();const t=e.target;t.style.height="auto",t.style.height=Math.min(t.scrollHeight,120)+"px";const i=this._inputValue.match(/^\/(\S*)$/);i?(this._skillMenuOpened=!0,this._skillQuery=i[1],this._skillHighlighted=0,this._searchInvocableSkills(this._skillQuery)):this._skillMenuOpened=!1}_handleKeyDown(e){if(this._skillMenuOpened){let t=3;"inline"===this.variant&&!0===this._aiFrameworkConfig.debugTelemetryEnabled&&(t=5);const i=t+this._invocableSkills.length;if("ArrowDown"===e.key)return e.preventDefault(),void(this._skillHighlighted=(this._skillHighlighted+1)%i);if("ArrowUp"===e.key)return e.preventDefault(),void(this._skillHighlighted=(this._skillHighlighted-1+i)%i);if("Enter"===e.key&&!e.shiftKey)return e.preventDefault(),void this._activateSkillMenuItem(this._skillHighlighted);if("Escape"===e.key)return e.preventDefault(),void(this._skillMenuOpened=!1)}"Enter"!==e.key||e.shiftKey||(e.preventDefault(),this._handleSubmit())}_activateSkillMenuItem(e){const t="inline"===this.variant&&!0===this._aiFrameworkConfig.debugTelemetryEnabled;let i=3;if(t&&(i=5),0===e)return void this._openFilePicker(!0);if(1===e)return void this._openFilePicker(!1);if(2===e)return void this._handleSkillBrowseOpen();if(t&&3===e)return this._skillMenuOpened=!1,void this._send({message:"/test-context-warning",conversationFiles:[]});if(t&&4===e)return this._skillMenuOpened=!1,void this._send({message:"/test-context-limit",conversationFiles:[]});const s=this._invocableSkills[e-i];s&&this._handleSkillSelect(s)}_searchOrgSkills(e){this._orgSkillRequestId++;const t=this._orgSkillRequestId;n.fetch({url:"/api/system/conversation/localSkillList",method:"POST",body:{query:e.trim()}}).then((e=>e.json())).then((e=>{t===this._orgSkillRequestId&&(this._orgSkills=e?.data||[])})).catch((e=>{console.error("kr-chatbot: skill search failed",e)}))}_searchInvocableSkills(e){this._invocableSkillRequestId++;const t=this._invocableSkillRequestId;n.fetch({url:"/api/system/conversation/availableSkills",method:"POST",body:{query:e.trim()}}).then((e=>e.json())).then((e=>{t===this._invocableSkillRequestId&&(this._invocableSkills=e?.data||[])})).catch((e=>{console.error("kr-chatbot: invocable skill search failed",e)}))}_searchGlobalSkills(e){this._globalSkillRequestId++;const t=this._globalSkillRequestId;n.fetch({url:"/api/system/conversation/globalSkillList",method:"POST",body:{query:e.trim()}}).then((e=>e.json())).then((e=>{t===this._globalSkillRequestId&&(this._globalSkills=e?.data||[])})).catch((e=>{console.error("kr-chatbot: global skill search failed",e)}))}_handleGlobalSkillEnable(e,t){if(t.stopPropagation(),!e.canEnable)return void i.show({title:"Permission Required",message:"You do not have permission to install skills. Please contact your site administrator.",type:"error"});if(this._globalSkillPending.has(e.code))return;const s=t.currentTarget;this._globalSkillPending.add(e.code),s?.showLoading(),n.fetch({url:`/api/system/opensearch/aiskills/global/${encodeURIComponent(e.code)}/enabled`,method:"POST",body:{enabled:!e.enabled}}).then((e=>e.json())).then((t=>{e.enabled=t?.data?.enabled,s?.reset(),this.requestUpdate()})).catch((e=>{console.error("kr-chatbot: global skill enable failed",e),s?.showError("Error")})).finally((()=>{this._globalSkillPending.delete(e.code)}))}_handlePlusClick(){this._skillMenuOpened?this._skillMenuOpened=!1:(this._skillQuery="",this._skillHighlighted=0,this._skillMenuOpened=!0,this._searchInvocableSkills(""))}_handleMicClick(){if(this._speechRecognition)return void this._speechRecognition.stop();const e=window.SpeechRecognition||window.webkitSpeechRecognition;if(!e)return;const t=new e;t.continuous=!0,t.interimResults=!0,this._speechBaseValue=this._inputValue,this._speechBaseValue&&!this._speechBaseValue.endsWith(" ")&&(this._speechBaseValue+=" "),this._speechFinalTranscript="",t.onresult=e=>{let t="";for(let i=e.resultIndex;i<e.results.length;i++)e.results[i].isFinal?this._speechFinalTranscript+=e.results[i][0].transcript:t+=e.results[i][0].transcript;this._inputValue=this._speechBaseValue+this._speechFinalTranscript+t,this._saveState(),this._inputEl&&(this._inputEl.style.height="auto",this._inputEl.style.height=Math.min(this._inputEl.scrollHeight,120)+"px")},t.onerror=e=>{"not-allowed"!==e.error&&"service-not-allowed"!==e.error||(this._error="Microphone access is blocked. Allow it in your browser settings to use voice input.")},t.onend=()=>{this._speechRecognition=null,this._isDictating=!1},this._speechRecognition=t,this._isDictating=!0,this._error="",t.start(),this._inputEl?.focus()}_handleSkillSelect(e){if(!1===e.canRun){let t=`You do not have access to "${e.name}". Ask your site administrator to grant it.`;return e.allowedRoles?.length&&(t=`"${e.name}" requires the ${e.allowedRoles.join(" or ")} role. Ask your site administrator to grant it.`),void i.show({title:"Access Required",message:t,type:"error"})}!e.global||e.enabled?(this._inputValue=`/${e.code} `,this._saveState(),this._skillMenuOpened=!1,this._skillBrowseOpened=!1,this._inputEl?.focus()):i.show({title:"Not Installed",message:`"${e.name}" has to be installed on this site before you can use it — use the Install button on the card.`,type:"info"})}_handleSkillCardKeydown(e,t){"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),this._handleSkillSelect(t))}_handleCopyMessage(e,t){navigator.clipboard.writeText(e).then((()=>{this._copiedIndex=t,setTimeout((()=>{this._copiedIndex===t&&(this._copiedIndex=-1)}),2e3)})).catch((()=>{}))}_handleSkillBrowseOpen(){this._skillMenuOpened=!1,this._skillBrowseQuery="",this._skillBrowseOpened=!0,this._searchOrgSkills(""),!0!==this._aiFrameworkConfig.registryServer&&this._searchGlobalSkills("")}_handleSkillBrowseClose(){this._skillBrowseOpened=!1}_handleSkillBrowseSearch(e){this._skillBrowseQuery=e.target.value,this._searchOrgSkills(this._skillBrowseQuery),!0!==this._aiFrameworkConfig.registryServer&&this._searchGlobalSkills(this._skillBrowseQuery)}_handleSkillBrowseTabChange(e){this._skillBrowseSource=e.detail.activeTabId}_openFilePicker(e=!0){this._skillMenuOpened=!1,"/"===this._inputValue.trim()&&(this._inputValue="",this._saveState()),this._pendingAttachAnalyze=e,this._fileInputEl?.click()}_handleFileInputChange(e){const t=e.target;t.files&&this._addFiles(t.files,this._pendingAttachAnalyze),t.value=""}_handlePaste(e){const t=e.clipboardData?.items;if(!t)return;const i=[];for(let e=0;e<t.length;e++)if("file"===t[e].kind){const s=t[e].getAsFile();s&&i.push(s)}i.length&&(e.preventDefault(),this._addFiles(i))}_handleDragEnter(e){this._hasFiles(e)&&(e.preventDefault(),this._dragDepth++,this._isDraggingFile=!0)}_handleDragOver(e){this._hasFiles(e)&&e.preventDefault()}_handleDragLeave(e){this._hasFiles(e)&&(this._dragDepth--,this._dragDepth<=0&&(this._dragDepth=0,this._isDraggingFile=!1))}_handleDrop(e){this._hasFiles(e)&&(e.preventDefault(),this._dragDepth=0,this._isDraggingFile=!1,e.dataTransfer?.files&&this._addFiles(e.dataTransfer.files))}_hasFiles(e){return Array.from(e.dataTransfer?.types||[]).includes("Files")}_getFileExtension(e){const t=e.lastIndexOf(".");return t<0?"":e.slice(t+1).toLowerCase()}_addFiles(e,t=!0){const i=Array.from(e).filter((e=>li.includes(this._getFileExtension(e.name))));i.length&&i.forEach((e=>{let i;(e.type.startsWith("image/")||ai.includes(this._getFileExtension(e.name)))&&(i=URL.createObjectURL(e));const s={localId:"att-"+this._pendingSeq++,file:e,name:e.name,mimeType:e.type,previewUrl:i,aiAnalyze:t};this._pendingConversationFiles=[...this._pendingConversationFiles,s]}))}_handlePendingRemove(e){const t=this._pendingConversationFiles.find((t=>t.localId===e));t?.previewUrl&&URL.revokeObjectURL(t.previewUrl),this._pendingConversationFiles=this._pendingConversationFiles.filter((t=>t.localId!==e))}_clearPending(){this._pendingConversationFiles.forEach((e=>{e.previewUrl&&URL.revokeObjectURL(e.previewUrl)})),this._pendingConversationFiles=[]}_handleFileOpen(e){const t=e.previewUrl||`${n.getBaseUrl()}/api/system/conversationFile/${e.conversationFileID}/view`;s.open({src:t,name:e.niceName||"file"}).addEventListener("download",(()=>{window.open(`${n.getBaseUrl()}/api/system/conversationFile/${e.conversationFileID}/view?download=true`,"_blank")}))}_handleSubmit(){if(this._isStreaming)return;if(this._pendingActions.length)return;const e=this._inputValue.trim(),t=this._pendingConversationFiles;if(!e&&!t.length)return;const i=t.map((e=>({file:e.file,aiAnalyze:e.aiAnalyze}))),s=new CustomEvent("message-submit",{detail:{message:e,conversationFiles:i},bubbles:!0,composed:!0,cancelable:!0});this.dispatchEvent(s),s.defaultPrevented||this._send({message:e,conversationFiles:i})}_send(e){const t={type:"user",content:e.message};this._pendingConversationFiles.length&&(t.conversationFiles=this._pendingConversationFiles.map((e=>({conversationFileID:-1,niceName:e.name,mimeType:e.mimeType,aiAnalyze:e.aiAnalyze,previewUrl:e.previewUrl})))),this._speechRecognition&&this._speechRecognition.abort(),this.messages=[...this.messages,t],this._inputValue="",this._saveState(),this._error="",this._userHasScrolledUp=!1,this._pendingConversationFiles=[],this._inputEl&&(this._inputEl.style.height="auto"),this.messages=[...this.messages,{type:"assistant",content:""}],this._isStreaming=!0,this.updateComplete.then((()=>{if(!this._messagesEl)return;this._messagesEl.querySelectorAll(".message--assistant").forEach((e=>{e.style.minHeight=""}));const e=this._messagesEl.querySelectorAll(".message"),t=e[this.messages.length-2],i=e[this.messages.length-1];i&&(i.style.minHeight=this._messagesEl.clientHeight+"px"),t&&(this._messagesEl.scrollTop=t.offsetTop-this._messagesEl.offsetTop-24)})),this.send||(this.send=e=>{if(e.confirmation)return n.fetch({url:"/api/system/integration/aws/bedrock/stream/invokeModelForConversationWithState",method:"POST",headers:{Accept:"text/event-stream"},body:{confirmation:e.confirmation,conversationID:this.conversationId}});let t=Promise.resolve([]);return e.conversationFiles.length&&(t=Promise.all(e.conversationFiles.map((({file:e,aiAnalyze:t})=>{const i=new FormData;return i.append("file",e),i.append("type","LIBRARY"),i.append("niceName",e.name),t||i.append("aiAnalyze","false"),n.fetch({url:"/api/system/conversationFile/upload",method:"POST",body:i}).then((e=>e.json())).then((e=>e.data))})))),t.then((t=>{if(t.length)for(let e=this.messages.length-1;e>=0;e--)if("user"===this.messages[e].type){(this.messages[e].conversationFiles||[]).forEach((e=>{e.previewUrl&&URL.revokeObjectURL(e.previewUrl)})),this.messages[e].conversationFiles=t,this.requestUpdate();break}const i={userText:e.message,fileIds:t.map((e=>e.conversationFileID))};return e.pageContext&&(i.pageContext=e.pageContext),e.selectionContext&&(i.selectionContext=e.selectionContext),null!=this.conversationId?i.conversationID=this.conversationId:i.createNew=!0,n.fetch({url:"/api/system/integration/aws/bedrock/stream/invokeModelForConversationWithState",method:"POST",headers:{Accept:"text/event-stream"},body:i}).then((e=>(null==this.conversationId&&n.fetch({url:"/api/system/conversation/last"}).then((e=>e.json())).then((e=>{const t=e?.data,i=t?.conversationID;"number"==typeof i&&(this.conversationId=i,this.dispatchEvent(new CustomEvent("conversation-created",{detail:{conversation:t},bubbles:!0,composed:!0})))})).catch((()=>{})),e)))}))});const i=this._captureContext();this.send({message:e.message,messages:this.messages.slice(0,-1),conversationFiles:e.conversationFiles,pageContext:i.pageContext,selectionContext:i.selectionContext}).then((e=>{e.ok?e.body?(this._reader=e.body.getReader(),this._decoder=new TextDecoder,this._buffer="",this._readStreamChunk()):this._handleStreamError("No response body"):this._handleStreamError("Request failed: "+e.status)})).catch((e=>{"AbortError"!==e.name&&this._handleStreamError(e.message)}))}_handleConfirmationDecision(e){this._confirmationInFlight||(this._confirmationInFlight=!0,this._error="",this._pendingActions=[],this._confirmationHighlighted=-1,this.messages=[...this.messages,{type:"assistant",content:""}],this._isStreaming=!0,this._userHasScrolledUp=!1,this.send({message:"",messages:this.messages.slice(0,-1),conversationFiles:[],pageContext:"",selectionContext:"",confirmation:e}).then((e=>{this._confirmationInFlight=!1,e.ok?e.body?(this._reader=e.body.getReader(),this._decoder=new TextDecoder,this._buffer="",this._readStreamChunk()):this._handleStreamError("No response body"):this._handleStreamError("Request failed: "+e.status)})).catch((e=>{this._confirmationInFlight=!1,"AbortError"!==e.name&&this._handleStreamError(e.message)})))}_captureContext(){let e="";try{const t={url:window.location.href,title:document.title},i=document.getElementById("kodaris-page");if(i&&i.textContent)try{t.page=JSON.parse(i.textContent)}catch{}e=JSON.stringify(t)}catch{}let t="";try{const e=window.getSelection();e&&(t=e.toString().trim())}catch{}return{pageContext:e,selectionContext:t}}_handleStop(){this._reader&&(this._reader.cancel(),this._reader=null),this._isStreaming=!1}_handleMessagesScroll(e){const t=e.target,i=t.scrollHeight-t.scrollTop-t.clientHeight;this._userHasScrolledUp=i>50}_handleErrorDismiss(){this._error=""}_handleContextWarningDismiss(){this._contextWarning=""}_handleToggleDebugPanel(){this._debugPanelOpen=!this._debugPanelOpen,this._saveState()}_handleDebugResizeMouseDown(e){this._isDebugResizing=!0,this._debugResizeStartX=e.clientX,this._debugResizeStartW=this._debugDrawerWidth,e.preventDefault(),e.stopPropagation(),document.addEventListener("mousemove",this._handleDebugResizeMouseMove),document.addEventListener("mouseup",this._handleDebugResizeMouseUp)}_readStreamChunk(){this._reader&&this._reader.read().then((e=>{if(e.done)return void this._finishStream();this._buffer=this._buffer+this._decoder.decode(e.value,{stream:!0});const t=this._buffer.split("\n\n");this._buffer=t.pop()||"";for(let e=0;e<t.length;e++){if(!t[e].trim())continue;const i=t[e].split("\n");for(let e=0;e<i.length;e++){if(!i[e].startsWith("data:"))continue;const t=i[e].slice(5).trim();if(!t)continue;let s;try{s=JSON.parse(t)}catch{continue}if(this.dispatchEvent(new CustomEvent("stream-event",{detail:s,bubbles:!0,composed:!0})),"REASONING_PART"===s.type){if(s.message){const e=this.messages.length-1;e>=0&&"assistant"===this.messages[e].type&&(this.messages[e].reasoning||(this.messages[e].reasoning=""),this.messages[e].reasoning+=String(s.message),this.requestUpdate())}}else if("RESPONSE_PART"===s.type){if(s.message){const e=this.messages.length-1;e>=0&&"assistant"===this.messages[e].type&&(this.messages[e].content+=String(s.message),this.requestUpdate())}}else if("ERROR"===s.type)this._handleStreamError(String(s.message||"Unknown error"));else if("CONVERSATION_TOKEN_WARNING"===s.type)this._contextWarning=String(s.message||"");else if("CONVERSATION_TITLE"===s.type){if(s.data){const e=String(s.data.title||"");e&&(this.label=e,this.dispatchEvent(new CustomEvent("conversation-title",{detail:{title:e},bubbles:!0,composed:!0})))}}else if("CONVERSATION_LIMIT_REACHED"===s.type)this._contextLimitReached=!0,this._contextLimitMessage=String(s.message||""),this._contextWarning="";else if("ACTION_CONFIRMATION_REQUIRED"===s.type){const e=s.data?.actions;Array.isArray(e)&&e.length&&(this._pendingActions=e,this._confirmationHighlighted=0)}else if("TOKEN_USAGE"===s.type){if(s.data){const e=s.data;this._telemetry=e,1===e.iteration?(this._iterationLog=[e],this._cacheCheckpoints={}):this._iterationLog=[...this._iterationLog,e]}}else if("CACHE_CHECKPOINT"===s.type&&s.data){const e=s.data;this._cacheCheckpoints={...this._cacheCheckpoints,[e.iteration]:e}}s.finished&&this._finishStream()}}this._reader&&this._readStreamChunk()})).catch((e=>{"AbortError"!==e.name&&this._handleStreamError(e.message)}))}_finishStream(){if(this._isStreaming=!1,this._reader=null,this._pendingActions.length){const e=this.messages.length-1;e>=0&&"assistant"===this.messages[e].type&&!this.messages[e].content&&!this.messages[e].reasoning&&(this.messages=this.messages.slice(0,-1))}}_handleStreamError(e){if(this._isStreaming=!1,this._error=e,this._reader&&(this._reader.cancel(),this._reader=null),this.messages.length>0){const e=this.messages[this.messages.length-1];"assistant"!==e.type||e.content||(this.messages=this.messages.slice(0,-1))}}_renderConfirmation(){const e=this._pendingActions[0];let t="Run this action?";return e&&(t=`Run ${e.displayName||e.toolName}?`),X`
1384
+ */function Ke(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}let Ze={async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null};function Ge(e){Ze=e}const Je=/[&<>"']/,et=new RegExp(Je.source,"g"),tt=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,it=new RegExp(tt.source,"g"),st={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},nt=e=>st[e];function rt(e,t){if(t){if(Je.test(e))return e.replace(et,nt)}else if(tt.test(e))return e.replace(it,nt);return e}const ot=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/gi;function at(e){return e.replace(ot,((e,t)=>"colon"===(t=t.toLowerCase())?":":"#"===t.charAt(0)?"x"===t.charAt(1)?String.fromCharCode(parseInt(t.substring(2),16)):String.fromCharCode(+t.substring(1)):""))}const lt=/(^|[^\[])\^/g;function ht(e,t){let i="string"==typeof e?e:e.source;t=t||"";const s={replace:(e,t)=>{let n="string"==typeof t?t:t.source;return n=n.replace(lt,"$1"),i=i.replace(e,n),s},getRegex:()=>new RegExp(i,t)};return s}function ct(e){try{e=encodeURI(e).replace(/%25/g,"%")}catch(e){return null}return e}const dt={exec:()=>null};function pt(e,t){const i=e.replace(/\|/g,((e,t,i)=>{let s=!1,n=t;for(;--n>=0&&"\\"===i[n];)s=!s;return s?"|":" |"})).split(/ \|/);let s=0;if(i[0].trim()||i.shift(),i.length>0&&!i[i.length-1].trim()&&i.pop(),t)if(i.length>t)i.splice(t);else for(;i.length<t;)i.push("");for(;s<i.length;s++)i[s]=i[s].trim().replace(/\\\|/g,"|");return i}function ut(e,t,i){const s=e.length;if(0===s)return"";let n=0;for(;n<s;){if(e.charAt(s-n-1)!==t)break;n++}return e.slice(0,s-n)}function gt(e,t,i,s){const n=t.href,r=t.title?rt(t.title):null,o=e[1].replace(/\\([\[\]])/g,"$1");if("!"!==e[0].charAt(0)){s.state.inLink=!0;const e={type:"link",raw:i,href:n,title:r,text:o,tokens:s.inlineTokens(o)};return s.state.inLink=!1,e}return{type:"image",raw:i,href:n,title:r,text:rt(o)}}class mt{options;rules;lexer;constructor(e){this.options=e||Ze}space(e){const t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(e){const t=this.rules.block.code.exec(e);if(t){const e=t[0].replace(/^ {1,4}/gm,"");return{type:"code",raw:t[0],codeBlockStyle:"indented",text:this.options.pedantic?e:ut(e,"\n")}}}fences(e){const t=this.rules.block.fences.exec(e);if(t){const e=t[0],i=function(e,t){const i=e.match(/^(\s+)(?:```)/);if(null===i)return t;const s=i[1];return t.split("\n").map((e=>{const t=e.match(/^\s+/);if(null===t)return e;const[i]=t;return i.length>=s.length?e.slice(s.length):e})).join("\n")}(e,t[3]||"");return{type:"code",raw:e,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:i}}}heading(e){const t=this.rules.block.heading.exec(e);if(t){let e=t[2].trim();if(/#$/.test(e)){const t=ut(e,"#");this.options.pedantic?e=t.trim():t&&!/ $/.test(t)||(e=t.trim())}return{type:"heading",raw:t[0],depth:t[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(e){const t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:t[0]}}blockquote(e){const t=this.rules.block.blockquote.exec(e);if(t){let e=t[0].replace(/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,"\n $1");e=ut(e.replace(/^ *>[ \t]?/gm,""),"\n");const i=this.lexer.state.top;this.lexer.state.top=!0;const s=this.lexer.blockTokens(e);return this.lexer.state.top=i,{type:"blockquote",raw:t[0],tokens:s,text:e}}}list(e){let t=this.rules.block.list.exec(e);if(t){let i=t[1].trim();const s=i.length>1,n={type:"list",raw:"",ordered:s,start:s?+i.slice(0,-1):"",loose:!1,items:[]};i=s?`\\d{1,9}\\${i.slice(-1)}`:`\\${i}`,this.options.pedantic&&(i=s?i:"[*+-]");const r=new RegExp(`^( {0,3}${i})((?:[\t ][^\\n]*)?(?:\\n|$))`);let o="",a="",l=!1;for(;e;){let i=!1;if(!(t=r.exec(e)))break;if(this.rules.block.hr.test(e))break;o=t[0],e=e.substring(o.length);let s=t[2].split("\n",1)[0].replace(/^\t+/,(e=>" ".repeat(3*e.length))),h=e.split("\n",1)[0],c=0;this.options.pedantic?(c=2,a=s.trimStart()):(c=t[2].search(/[^ ]/),c=c>4?1:c,a=s.slice(c),c+=t[1].length);let d=!1;if(!s&&/^ *$/.test(h)&&(o+=h+"\n",e=e.substring(h.length+1),i=!0),!i){const t=new RegExp(`^ {0,${Math.min(3,c-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ \t][^\\n]*)?(?:\\n|$))`),i=new RegExp(`^ {0,${Math.min(3,c-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),n=new RegExp(`^ {0,${Math.min(3,c-1)}}(?:\`\`\`|~~~)`),r=new RegExp(`^ {0,${Math.min(3,c-1)}}#`);for(;e;){const l=e.split("\n",1)[0];if(h=l,this.options.pedantic&&(h=h.replace(/^ {1,4}(?=( {4})*[^ ])/g," ")),n.test(h))break;if(r.test(h))break;if(t.test(h))break;if(i.test(e))break;if(h.search(/[^ ]/)>=c||!h.trim())a+="\n"+h.slice(c);else{if(d)break;if(s.search(/[^ ]/)>=4)break;if(n.test(s))break;if(r.test(s))break;if(i.test(s))break;a+="\n"+h}d||h.trim()||(d=!0),o+=l+"\n",e=e.substring(l.length+1),s=h.slice(c)}}n.loose||(l?n.loose=!0:/\n *\n *$/.test(o)&&(l=!0));let p,u=null;this.options.gfm&&(u=/^\[[ xX]\] /.exec(a),u&&(p="[ ] "!==u[0],a=a.replace(/^\[[ xX]\] +/,""))),n.items.push({type:"list_item",raw:o,task:!!u,checked:p,loose:!1,text:a,tokens:[]}),n.raw+=o}n.items[n.items.length-1].raw=o.trimEnd(),n.items[n.items.length-1].text=a.trimEnd(),n.raw=n.raw.trimEnd();for(let e=0;e<n.items.length;e++)if(this.lexer.state.top=!1,n.items[e].tokens=this.lexer.blockTokens(n.items[e].text,[]),!n.loose){const t=n.items[e].tokens.filter((e=>"space"===e.type)),i=t.length>0&&t.some((e=>/\n.*\n/.test(e.raw)));n.loose=i}if(n.loose)for(let e=0;e<n.items.length;e++)n.items[e].loose=!0;return n}}html(e){const t=this.rules.block.html.exec(e);if(t){return{type:"html",block:!0,raw:t[0],pre:"pre"===t[1]||"script"===t[1]||"style"===t[1],text:t[0]}}}def(e){const t=this.rules.block.def.exec(e);if(t){const e=t[1].toLowerCase().replace(/\s+/g," "),i=t[2]?t[2].replace(/^<(.*)>$/,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",s=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:e,raw:t[0],href:i,title:s}}}table(e){const t=this.rules.block.table.exec(e);if(!t)return;if(!/[:|]/.test(t[2]))return;const i=pt(t[1]),s=t[2].replace(/^\||\| *$/g,"").split("|"),n=t[3]&&t[3].trim()?t[3].replace(/\n[ \t]*$/,"").split("\n"):[],r={type:"table",raw:t[0],header:[],align:[],rows:[]};if(i.length===s.length){for(const e of s)/^ *-+: *$/.test(e)?r.align.push("right"):/^ *:-+: *$/.test(e)?r.align.push("center"):/^ *:-+ *$/.test(e)?r.align.push("left"):r.align.push(null);for(const e of i)r.header.push({text:e,tokens:this.lexer.inline(e)});for(const e of n)r.rows.push(pt(e,r.header.length).map((e=>({text:e,tokens:this.lexer.inline(e)}))));return r}}lheading(e){const t=this.rules.block.lheading.exec(e);if(t)return{type:"heading",raw:t[0],depth:"="===t[2].charAt(0)?1:2,text:t[1],tokens:this.lexer.inline(t[1])}}paragraph(e){const t=this.rules.block.paragraph.exec(e);if(t){const e="\n"===t[1].charAt(t[1].length-1)?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:e,tokens:this.lexer.inline(e)}}}text(e){const t=this.rules.block.text.exec(e);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){const t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:rt(t[1])}}tag(e){const t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&/^<a /i.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&/^<\/a>/i.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&/^<(pre|code|kbd|script)(\s|>)/i.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){const t=this.rules.inline.link.exec(e);if(t){const e=t[2].trim();if(!this.options.pedantic&&/^</.test(e)){if(!/>$/.test(e))return;const t=ut(e.slice(0,-1),"\\");if((e.length-t.length)%2==0)return}else{const e=function(e,t){if(-1===e.indexOf(t[1]))return-1;let i=0;for(let s=0;s<e.length;s++)if("\\"===e[s])s++;else if(e[s]===t[0])i++;else if(e[s]===t[1]&&(i--,i<0))return s;return-1}(t[2],"()");if(e>-1){const i=(0===t[0].indexOf("!")?5:4)+t[1].length+e;t[2]=t[2].substring(0,e),t[0]=t[0].substring(0,i).trim(),t[3]=""}}let i=t[2],s="";if(this.options.pedantic){const e=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(i);e&&(i=e[1],s=e[3])}else s=t[3]?t[3].slice(1,-1):"";return i=i.trim(),/^</.test(i)&&(i=this.options.pedantic&&!/>$/.test(e)?i.slice(1):i.slice(1,-1)),gt(t,{href:i?i.replace(this.rules.inline.anyPunctuation,"$1"):i,title:s?s.replace(this.rules.inline.anyPunctuation,"$1"):s},t[0],this.lexer)}}reflink(e,t){let i;if((i=this.rules.inline.reflink.exec(e))||(i=this.rules.inline.nolink.exec(e))){const e=t[(i[2]||i[1]).replace(/\s+/g," ").toLowerCase()];if(!e){const e=i[0].charAt(0);return{type:"text",raw:e,text:e}}return gt(i,e,i[0],this.lexer)}}emStrong(e,t,i=""){let s=this.rules.inline.emStrongLDelim.exec(e);if(!s)return;if(s[3]&&i.match(/[\p{L}\p{N}]/u))return;if(!(s[1]||s[2]||"")||!i||this.rules.inline.punctuation.exec(i)){const i=[...s[0]].length-1;let n,r,o=i,a=0;const l="*"===s[0][0]?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(l.lastIndex=0,t=t.slice(-1*e.length+i);null!=(s=l.exec(t));){if(n=s[1]||s[2]||s[3]||s[4]||s[5]||s[6],!n)continue;if(r=[...n].length,s[3]||s[4]){o+=r;continue}if((s[5]||s[6])&&i%3&&!((i+r)%3)){a+=r;continue}if(o-=r,o>0)continue;r=Math.min(r,r+o+a);const t=[...s[0]][0].length,l=e.slice(0,i+s.index+t+r);if(Math.min(i,r)%2){const e=l.slice(1,-1);return{type:"em",raw:l,text:e,tokens:this.lexer.inlineTokens(e)}}const h=l.slice(2,-2);return{type:"strong",raw:l,text:h,tokens:this.lexer.inlineTokens(h)}}}}codespan(e){const t=this.rules.inline.code.exec(e);if(t){let e=t[2].replace(/\n/g," ");const i=/[^ ]/.test(e),s=/^ /.test(e)&&/ $/.test(e);return i&&s&&(e=e.substring(1,e.length-1)),e=rt(e,!0),{type:"codespan",raw:t[0],text:e}}}br(e){const t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e){const t=this.rules.inline.del.exec(e);if(t)return{type:"del",raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2])}}autolink(e){const t=this.rules.inline.autolink.exec(e);if(t){let e,i;return"@"===t[2]?(e=rt(t[1]),i="mailto:"+e):(e=rt(t[1]),i=e),{type:"link",raw:t[0],text:e,href:i,tokens:[{type:"text",raw:e,text:e}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let e,i;if("@"===t[2])e=rt(t[0]),i="mailto:"+e;else{let s;do{s=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??""}while(s!==t[0]);e=rt(t[0]),i="www."===t[1]?"http://"+t[0]:t[0]}return{type:"link",raw:t[0],text:e,href:i,tokens:[{type:"text",raw:e,text:e}]}}}inlineText(e){const t=this.rules.inline.text.exec(e);if(t){let e;return e=this.lexer.state.inRawBlock?t[0]:rt(t[0]),{type:"text",raw:t[0],text:e}}}}const ft=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,bt=/(?:[*+-]|\d{1,9}[.)])/,vt=ht(/^(?!bull |blockCode|fences|blockquote|heading|html)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html))+?)\n {0,3}(=+|-+) *(?:\n+|$)/).replace(/bull/g,bt).replace(/blockCode/g,/ {4}/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).getRegex(),_t=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,xt=/(?!\s*\])(?:\\.|[^\[\]\\])+/,kt=ht(/^ {0,3}\[(label)\]: *(?:\n *)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/).replace("label",xt).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),wt=ht(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,bt).getRegex(),yt="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",$t=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,St=ht("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n *)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$))","i").replace("comment",$t).replace("tag",yt).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),It=ht(_t).replace("hr",ft).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",yt).getRegex(),Et={blockquote:ht(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",It).getRegex(),code:/^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/,def:kt,fences:/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,heading:/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,hr:ft,html:St,lheading:vt,list:wt,newline:/^(?: *(?:\n|$))+/,paragraph:It,table:dt,text:/^[^\n]+/},Ct=ht("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",ft).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code"," {4}[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",yt).getRegex(),At={...Et,table:Ct,paragraph:ht(_t).replace("hr",ft).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Ct).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",yt).getRegex()},zt={...Et,html:ht("^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:\"[^\"]*\"|'[^']*'|\\s[^'\"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))").replace("comment",$t).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:dt,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:ht(_t).replace("hr",ft).replace("heading"," *#{1,6} *[^\n]").replace("lheading",vt).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},Tt=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Rt=/^( {2,}|\\)\n(?!\s*$)/,Mt="\\p{P}\\p{S}",Dt=ht(/^((?![*_])[\spunctuation])/,"u").replace(/punctuation/g,Mt).getRegex(),Ot=ht(/^(?:\*+(?:((?!\*)[punct])|[^\s*]))|^_+(?:((?!_)[punct])|([^\s_]))/,"u").replace(/punct/g,Mt).getRegex(),Nt=ht("^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)[punct](\\*+)(?=[\\s]|$)|[^punct\\s](\\*+)(?!\\*)(?=[punct\\s]|$)|(?!\\*)[punct\\s](\\*+)(?=[^punct\\s])|[\\s](\\*+)(?!\\*)(?=[punct])|(?!\\*)[punct](\\*+)(?!\\*)(?=[punct])|[^punct\\s](\\*+)(?=[^punct\\s])","gu").replace(/punct/g,Mt).getRegex(),Pt=ht("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)[punct](_+)(?=[\\s]|$)|[^punct\\s](_+)(?!_)(?=[punct\\s]|$)|(?!_)[punct\\s](_+)(?=[^punct\\s])|[\\s](_+)(?!_)(?=[punct])|(?!_)[punct](_+)(?!_)(?=[punct])","gu").replace(/punct/g,Mt).getRegex(),Lt=ht(/\\([punct])/,"gu").replace(/punct/g,Mt).getRegex(),Ft=ht(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),Ut=ht($t).replace("(?:--\x3e|$)","--\x3e").getRegex(),jt=ht("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",Ut).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Ht=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,Bt=ht(/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/).replace("label",Ht).replace("href",/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),qt=ht(/^!?\[(label)\]\[(ref)\]/).replace("label",Ht).replace("ref",xt).getRegex(),Wt=ht(/^!?\[(ref)\](?:\[\])?/).replace("ref",xt).getRegex(),Vt={_backpedal:dt,anyPunctuation:Lt,autolink:Ft,blockSkip:/\[[^[\]]*?\]\([^\(\)]*?\)|`[^`]*?`|<[^<>]*?>/g,br:Rt,code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,del:dt,emStrongLDelim:Ot,emStrongRDelimAst:Nt,emStrongRDelimUnd:Pt,escape:Tt,link:Bt,nolink:Wt,punctuation:Dt,reflink:qt,reflinkSearch:ht("reflink|nolink(?!\\()","g").replace("reflink",qt).replace("nolink",Wt).getRegex(),tag:jt,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,url:dt},Xt={...Vt,link:ht(/^!?\[(label)\]\((.*?)\)/).replace("label",Ht).getRegex(),reflink:ht(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Ht).getRegex()},Qt={...Vt,escape:ht(Tt).replace("])","~|])").getRegex(),url:ht(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,"i").replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/},Yt={...Qt,br:ht(Rt).replace("{2,}","*").getRegex(),text:ht(Qt.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Kt={normal:Et,gfm:At,pedantic:zt},Zt={normal:Vt,gfm:Qt,breaks:Yt,pedantic:Xt};class Gt{tokens;options;state;tokenizer;inlineQueue;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||Ze,this.options.tokenizer=this.options.tokenizer||new mt,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};const t={block:Kt.normal,inline:Zt.normal};this.options.pedantic?(t.block=Kt.pedantic,t.inline=Zt.pedantic):this.options.gfm&&(t.block=Kt.gfm,this.options.breaks?t.inline=Zt.breaks:t.inline=Zt.gfm),this.tokenizer.rules=t}static get rules(){return{block:Kt,inline:Zt}}static lex(e,t){return new Gt(t).lex(e)}static lexInline(e,t){return new Gt(t).inlineTokens(e)}lex(e){e=e.replace(/\r\n|\r/g,"\n"),this.blockTokens(e,this.tokens);for(let e=0;e<this.inlineQueue.length;e++){const t=this.inlineQueue[e];this.inlineTokens(t.src,t.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[]){let i,s,n,r;for(e=this.options.pedantic?e.replace(/\t/g," ").replace(/^ +$/gm,""):e.replace(/^( *)(\t+)/gm,((e,t,i)=>t+" ".repeat(i.length)));e;)if(!(this.options.extensions&&this.options.extensions.block&&this.options.extensions.block.some((s=>!!(i=s.call({lexer:this},e,t))&&(e=e.substring(i.raw.length),t.push(i),!0)))))if(i=this.tokenizer.space(e))e=e.substring(i.raw.length),1===i.raw.length&&t.length>0?t[t.length-1].raw+="\n":t.push(i);else if(i=this.tokenizer.code(e))e=e.substring(i.raw.length),s=t[t.length-1],!s||"paragraph"!==s.type&&"text"!==s.type?t.push(i):(s.raw+="\n"+i.raw,s.text+="\n"+i.text,this.inlineQueue[this.inlineQueue.length-1].src=s.text);else if(i=this.tokenizer.fences(e))e=e.substring(i.raw.length),t.push(i);else if(i=this.tokenizer.heading(e))e=e.substring(i.raw.length),t.push(i);else if(i=this.tokenizer.hr(e))e=e.substring(i.raw.length),t.push(i);else if(i=this.tokenizer.blockquote(e))e=e.substring(i.raw.length),t.push(i);else if(i=this.tokenizer.list(e))e=e.substring(i.raw.length),t.push(i);else if(i=this.tokenizer.html(e))e=e.substring(i.raw.length),t.push(i);else if(i=this.tokenizer.def(e))e=e.substring(i.raw.length),s=t[t.length-1],!s||"paragraph"!==s.type&&"text"!==s.type?this.tokens.links[i.tag]||(this.tokens.links[i.tag]={href:i.href,title:i.title}):(s.raw+="\n"+i.raw,s.text+="\n"+i.raw,this.inlineQueue[this.inlineQueue.length-1].src=s.text);else if(i=this.tokenizer.table(e))e=e.substring(i.raw.length),t.push(i);else if(i=this.tokenizer.lheading(e))e=e.substring(i.raw.length),t.push(i);else{if(n=e,this.options.extensions&&this.options.extensions.startBlock){let t=1/0;const i=e.slice(1);let s;this.options.extensions.startBlock.forEach((e=>{s=e.call({lexer:this},i),"number"==typeof s&&s>=0&&(t=Math.min(t,s))})),t<1/0&&t>=0&&(n=e.substring(0,t+1))}if(this.state.top&&(i=this.tokenizer.paragraph(n)))s=t[t.length-1],r&&"paragraph"===s.type?(s.raw+="\n"+i.raw,s.text+="\n"+i.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=s.text):t.push(i),r=n.length!==e.length,e=e.substring(i.raw.length);else if(i=this.tokenizer.text(e))e=e.substring(i.raw.length),s=t[t.length-1],s&&"text"===s.type?(s.raw+="\n"+i.raw,s.text+="\n"+i.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=s.text):t.push(i);else if(e){const t="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(t);break}throw new Error(t)}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){let i,s,n,r,o,a,l=e;if(this.tokens.links){const e=Object.keys(this.tokens.links);if(e.length>0)for(;null!=(r=this.tokenizer.rules.inline.reflinkSearch.exec(l));)e.includes(r[0].slice(r[0].lastIndexOf("[")+1,-1))&&(l=l.slice(0,r.index)+"["+"a".repeat(r[0].length-2)+"]"+l.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;null!=(r=this.tokenizer.rules.inline.blockSkip.exec(l));)l=l.slice(0,r.index)+"["+"a".repeat(r[0].length-2)+"]"+l.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;null!=(r=this.tokenizer.rules.inline.anyPunctuation.exec(l));)l=l.slice(0,r.index)+"++"+l.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;e;)if(o||(a=""),o=!1,!(this.options.extensions&&this.options.extensions.inline&&this.options.extensions.inline.some((s=>!!(i=s.call({lexer:this},e,t))&&(e=e.substring(i.raw.length),t.push(i),!0)))))if(i=this.tokenizer.escape(e))e=e.substring(i.raw.length),t.push(i);else if(i=this.tokenizer.tag(e))e=e.substring(i.raw.length),s=t[t.length-1],s&&"text"===i.type&&"text"===s.type?(s.raw+=i.raw,s.text+=i.text):t.push(i);else if(i=this.tokenizer.link(e))e=e.substring(i.raw.length),t.push(i);else if(i=this.tokenizer.reflink(e,this.tokens.links))e=e.substring(i.raw.length),s=t[t.length-1],s&&"text"===i.type&&"text"===s.type?(s.raw+=i.raw,s.text+=i.text):t.push(i);else if(i=this.tokenizer.emStrong(e,l,a))e=e.substring(i.raw.length),t.push(i);else if(i=this.tokenizer.codespan(e))e=e.substring(i.raw.length),t.push(i);else if(i=this.tokenizer.br(e))e=e.substring(i.raw.length),t.push(i);else if(i=this.tokenizer.del(e))e=e.substring(i.raw.length),t.push(i);else if(i=this.tokenizer.autolink(e))e=e.substring(i.raw.length),t.push(i);else if(this.state.inLink||!(i=this.tokenizer.url(e))){if(n=e,this.options.extensions&&this.options.extensions.startInline){let t=1/0;const i=e.slice(1);let s;this.options.extensions.startInline.forEach((e=>{s=e.call({lexer:this},i),"number"==typeof s&&s>=0&&(t=Math.min(t,s))})),t<1/0&&t>=0&&(n=e.substring(0,t+1))}if(i=this.tokenizer.inlineText(n))e=e.substring(i.raw.length),"_"!==i.raw.slice(-1)&&(a=i.raw.slice(-1)),o=!0,s=t[t.length-1],s&&"text"===s.type?(s.raw+=i.raw,s.text+=i.text):t.push(i);else if(e){const t="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(t);break}throw new Error(t)}}else e=e.substring(i.raw.length),t.push(i);return t}}class Jt{options;constructor(e){this.options=e||Ze}code(e,t,i){const s=(t||"").match(/^\S*/)?.[0];return e=e.replace(/\n$/,"")+"\n",s?'<pre><code class="language-'+rt(s)+'">'+(i?e:rt(e,!0))+"</code></pre>\n":"<pre><code>"+(i?e:rt(e,!0))+"</code></pre>\n"}blockquote(e){return`<blockquote>\n${e}</blockquote>\n`}html(e,t){return e}heading(e,t,i){return`<h${t}>${e}</h${t}>\n`}hr(){return"<hr>\n"}list(e,t,i){const s=t?"ol":"ul";return"<"+s+(t&&1!==i?' start="'+i+'"':"")+">\n"+e+"</"+s+">\n"}listitem(e,t,i){return`<li>${e}</li>\n`}checkbox(e){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox">'}paragraph(e){return`<p>${e}</p>\n`}table(e,t){return t&&(t=`<tbody>${t}</tbody>`),"<table>\n<thead>\n"+e+"</thead>\n"+t+"</table>\n"}tablerow(e){return`<tr>\n${e}</tr>\n`}tablecell(e,t){const i=t.header?"th":"td";return(t.align?`<${i} align="${t.align}">`:`<${i}>`)+e+`</${i}>\n`}strong(e){return`<strong>${e}</strong>`}em(e){return`<em>${e}</em>`}codespan(e){return`<code>${e}</code>`}br(){return"<br>"}del(e){return`<del>${e}</del>`}link(e,t,i){const s=ct(e);if(null===s)return i;let n='<a href="'+(e=s)+'"';return t&&(n+=' title="'+t+'"'),n+=">"+i+"</a>",n}image(e,t,i){const s=ct(e);if(null===s)return i;let n=`<img src="${e=s}" alt="${i}"`;return t&&(n+=` title="${t}"`),n+=">",n}text(e){return e}}class ei{strong(e){return e}em(e){return e}codespan(e){return e}del(e){return e}html(e){return e}text(e){return e}link(e,t,i){return""+i}image(e,t,i){return""+i}br(){return""}}class ti{options;renderer;textRenderer;constructor(e){this.options=e||Ze,this.options.renderer=this.options.renderer||new Jt,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new ei}static parse(e,t){return new ti(t).parse(e)}static parseInline(e,t){return new ti(t).parseInline(e)}parse(e,t=!0){let i="";for(let s=0;s<e.length;s++){const n=e[s];if(this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[n.type]){const e=n,t=this.options.extensions.renderers[e.type].call({parser:this},e);if(!1!==t||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(e.type)){i+=t||"";continue}}switch(n.type){case"space":continue;case"hr":i+=this.renderer.hr();continue;case"heading":{const e=n;i+=this.renderer.heading(this.parseInline(e.tokens),e.depth,at(this.parseInline(e.tokens,this.textRenderer)));continue}case"code":{const e=n;i+=this.renderer.code(e.text,e.lang,!!e.escaped);continue}case"table":{const e=n;let t="",s="";for(let t=0;t<e.header.length;t++)s+=this.renderer.tablecell(this.parseInline(e.header[t].tokens),{header:!0,align:e.align[t]});t+=this.renderer.tablerow(s);let r="";for(let t=0;t<e.rows.length;t++){const i=e.rows[t];s="";for(let t=0;t<i.length;t++)s+=this.renderer.tablecell(this.parseInline(i[t].tokens),{header:!1,align:e.align[t]});r+=this.renderer.tablerow(s)}i+=this.renderer.table(t,r);continue}case"blockquote":{const e=n,t=this.parse(e.tokens);i+=this.renderer.blockquote(t);continue}case"list":{const e=n,t=e.ordered,s=e.start,r=e.loose;let o="";for(let t=0;t<e.items.length;t++){const i=e.items[t],s=i.checked,n=i.task;let a="";if(i.task){const e=this.renderer.checkbox(!!s);r?i.tokens.length>0&&"paragraph"===i.tokens[0].type?(i.tokens[0].text=e+" "+i.tokens[0].text,i.tokens[0].tokens&&i.tokens[0].tokens.length>0&&"text"===i.tokens[0].tokens[0].type&&(i.tokens[0].tokens[0].text=e+" "+i.tokens[0].tokens[0].text)):i.tokens.unshift({type:"text",text:e+" "}):a+=e+" "}a+=this.parse(i.tokens,r),o+=this.renderer.listitem(a,n,!!s)}i+=this.renderer.list(o,t,s);continue}case"html":{const e=n;i+=this.renderer.html(e.text,e.block);continue}case"paragraph":{const e=n;i+=this.renderer.paragraph(this.parseInline(e.tokens));continue}case"text":{let r=n,o=r.tokens?this.parseInline(r.tokens):r.text;for(;s+1<e.length&&"text"===e[s+1].type;)r=e[++s],o+="\n"+(r.tokens?this.parseInline(r.tokens):r.text);i+=t?this.renderer.paragraph(o):o;continue}default:{const e='Token with "'+n.type+'" type was not found.';if(this.options.silent)return console.error(e),"";throw new Error(e)}}}return i}parseInline(e,t){t=t||this.renderer;let i="";for(let s=0;s<e.length;s++){const n=e[s];if(this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[n.type]){const e=this.options.extensions.renderers[n.type].call({parser:this},n);if(!1!==e||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(n.type)){i+=e||"";continue}}switch(n.type){case"escape":{const e=n;i+=t.text(e.text);break}case"html":{const e=n;i+=t.html(e.text);break}case"link":{const e=n;i+=t.link(e.href,e.title,this.parseInline(e.tokens,t));break}case"image":{const e=n;i+=t.image(e.href,e.title,e.text);break}case"strong":{const e=n;i+=t.strong(this.parseInline(e.tokens,t));break}case"em":{const e=n;i+=t.em(this.parseInline(e.tokens,t));break}case"codespan":{const e=n;i+=t.codespan(e.text);break}case"br":i+=t.br();break;case"del":{const e=n;i+=t.del(this.parseInline(e.tokens,t));break}case"text":{const e=n;i+=t.text(e.text);break}default:{const e='Token with "'+n.type+'" type was not found.';if(this.options.silent)return console.error(e),"";throw new Error(e)}}}return i}}class ii{options;constructor(e){this.options=e||Ze}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}}const si=new class{defaults={async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null};options=this.setOptions;parse=this.#e(Gt.lex,ti.parse);parseInline=this.#e(Gt.lexInline,ti.parseInline);Parser=ti;Renderer=Jt;TextRenderer=ei;Lexer=Gt;Tokenizer=mt;Hooks=ii;constructor(...e){this.use(...e)}walkTokens(e,t){let i=[];for(const s of e)switch(i=i.concat(t.call(this,s)),s.type){case"table":{const e=s;for(const s of e.header)i=i.concat(this.walkTokens(s.tokens,t));for(const s of e.rows)for(const e of s)i=i.concat(this.walkTokens(e.tokens,t));break}case"list":{const e=s;i=i.concat(this.walkTokens(e.items,t));break}default:{const e=s;this.defaults.extensions?.childTokens?.[e.type]?this.defaults.extensions.childTokens[e.type].forEach((s=>{const n=e[s].flat(1/0);i=i.concat(this.walkTokens(n,t))})):e.tokens&&(i=i.concat(this.walkTokens(e.tokens,t)))}}return i}use(...e){const t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach((e=>{const i={...e};if(i.async=this.defaults.async||i.async||!1,e.extensions&&(e.extensions.forEach((e=>{if(!e.name)throw new Error("extension name required");if("renderer"in e){const i=t.renderers[e.name];t.renderers[e.name]=i?function(...t){let s=e.renderer.apply(this,t);return!1===s&&(s=i.apply(this,t)),s}:e.renderer}if("tokenizer"in e){if(!e.level||"block"!==e.level&&"inline"!==e.level)throw new Error("extension level must be 'block' or 'inline'");const i=t[e.level];i?i.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&("block"===e.level?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:"inline"===e.level&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}"childTokens"in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)})),i.extensions=t),e.renderer){const t=this.defaults.renderer||new Jt(this.defaults);for(const i in e.renderer){if(!(i in t))throw new Error(`renderer '${i}' does not exist`);if("options"===i)continue;const s=i,n=e.renderer[s],r=t[s];t[s]=(...e)=>{let i=n.apply(t,e);return!1===i&&(i=r.apply(t,e)),i||""}}i.renderer=t}if(e.tokenizer){const t=this.defaults.tokenizer||new mt(this.defaults);for(const i in e.tokenizer){if(!(i in t))throw new Error(`tokenizer '${i}' does not exist`);if(["options","rules","lexer"].includes(i))continue;const s=i,n=e.tokenizer[s],r=t[s];t[s]=(...e)=>{let i=n.apply(t,e);return!1===i&&(i=r.apply(t,e)),i}}i.tokenizer=t}if(e.hooks){const t=this.defaults.hooks||new ii;for(const i in e.hooks){if(!(i in t))throw new Error(`hook '${i}' does not exist`);if("options"===i)continue;const s=i,n=e.hooks[s],r=t[s];ii.passThroughHooks.has(i)?t[s]=e=>{if(this.defaults.async)return Promise.resolve(n.call(t,e)).then((e=>r.call(t,e)));const i=n.call(t,e);return r.call(t,i)}:t[s]=(...e)=>{let i=n.apply(t,e);return!1===i&&(i=r.apply(t,e)),i}}i.hooks=t}if(e.walkTokens){const t=this.defaults.walkTokens,s=e.walkTokens;i.walkTokens=function(e){let i=[];return i.push(s.call(this,e)),t&&(i=i.concat(t.call(this,e))),i}}this.defaults={...this.defaults,...i}})),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return Gt.lex(e,t??this.defaults)}parser(e,t){return ti.parse(e,t??this.defaults)}#e(e,t){return(i,s)=>{const n={...s},r={...this.defaults,...n};!0===this.defaults.async&&!1===n.async&&(r.silent||console.warn("marked(): The async option was set to true by an extension. The async: false option sent to parse will be ignored."),r.async=!0);const o=this.#t(!!r.silent,!!r.async);if(null==i)return o(new Error("marked(): input parameter is undefined or null"));if("string"!=typeof i)return o(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(i)+", string expected"));if(r.hooks&&(r.hooks.options=r),r.async)return Promise.resolve(r.hooks?r.hooks.preprocess(i):i).then((t=>e(t,r))).then((e=>r.hooks?r.hooks.processAllTokens(e):e)).then((e=>r.walkTokens?Promise.all(this.walkTokens(e,r.walkTokens)).then((()=>e)):e)).then((e=>t(e,r))).then((e=>r.hooks?r.hooks.postprocess(e):e)).catch(o);try{r.hooks&&(i=r.hooks.preprocess(i));let s=e(i,r);r.hooks&&(s=r.hooks.processAllTokens(s)),r.walkTokens&&this.walkTokens(s,r.walkTokens);let n=t(s,r);return r.hooks&&(n=r.hooks.postprocess(n)),n}catch(e){return o(e)}}}#t(e,t){return i=>{if(i.message+="\nPlease report this to https://github.com/markedjs/marked.",e){const e="<p>An error occurred:</p><pre>"+rt(i.message+"",!0)+"</pre>";return t?Promise.resolve(e):e}if(t)return Promise.reject(i);throw i}}};function ni(e,t){return si.parse(e,t)}ni.options=ni.setOptions=function(e){return si.setOptions(e),ni.defaults=si.defaults,Ge(ni.defaults),ni},ni.getDefaults=Ke,ni.defaults=Ze,ni.use=function(...e){return si.use(...e),ni.defaults=si.defaults,Ge(ni.defaults),ni},ni.walkTokens=function(e,t){return si.walkTokens(e,t)},ni.parseInline=si.parseInline,ni.Parser=ti,ni.parser=ti.parse,ni.Renderer=Jt,ni.TextRenderer=ei,ni.Lexer=Gt,ni.lexer=Gt.lex,ni.Tokenizer=mt,ni.Hooks=ii,ni.parse=ni,ni.options,ni.setOptions,ni.use,ni.walkTokens,ni.parseInline,ti.parse,Gt.lex;var ri=function(e,t,i,s){var n,r=arguments.length,o=r<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,i,s);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(o=(r<3?n(o):r>3?n(t,i,o):n(t,i))||o);return r>3&&o&&Object.defineProperty(t,i,o),o};const oi=[{decision:"approve",label:"Yes"},{decision:"approveAlways",label:"Always allow"},{decision:"reject",label:"No"}],ai=[{mode:"NORMAL",label:"Ask",description:"Asks before making changes"},{mode:"EDIT",label:"Auto",description:"Makes changes automatically"},{mode:"PLAN",label:"Plan",description:"Suggests a plan, makes no changes"}],li=["jpg","jpeg","png","gif","webp"],hi=["pdf","doc","docx","xls","xlsx","csv","html","md","txt","json","xml","vtt","srt",...li,"mp4","webm","ogg","mov"];let ci=class extends ce{constructor(){super(...arguments),this._inlineConfirm=!0,this._reasoningAsMessage=!0,this._reader=null,this._decoder=new TextDecoder,this._buffer="",this._userHasScrolledUp=!1,this._isDragging=!1,this._isResizing=!1,this._overlay=null,this._resizeDir="",this._dragStartX=0,this._dragStartY=0,this._dragStartLeft=0,this._dragStartTop=0,this._resizeStartW=0,this._resizeStartH=0,this._debugResizeStartX=0,this._debugResizeStartW=0,this._dragDepth=0,this._pendingSeq=0,this._pendingAttachAnalyze=!0,this._orgSkillRequestId=0,this._globalSkillRequestId=0,this._invocableSkillRequestId=0,this._globalSkillPending=new Set,this._speechRecognition=null,this._speechBaseValue="",this._speechFinalTranscript="",this.send=null,this.load=null,this.messages=[],this.label="Kat",this.placeholder="Type a message...",this.opened=!1,this.hideToggle=!1,this.variant="floating",this.conversationId=null,this._inputValue="",this._isStreaming=!1,this._error="",this._contextWarning="",this._contextLimitReached=!1,this._contextLimitMessage="",this._pendingActions=[],this._confirmationHighlighted=-1,this._confirmationInFlight=!1,this._telemetry=null,this._iterationLog=[],this._cacheCheckpoints={},this._drawerOpen=!1,this._drawerView="settings",this._debugDrawerWidth=430,this._isDebugResizing=!1,this._pendingConversationFiles=[],this._isDraggingFile=!1,this._skillMenuOpened=!1,this._skillQuery="",this._orgSkills=[],this._globalSkills=[],this._invocableSkills=[],this._aiFrameworkConfig={},this._skillHighlighted=0,this._copiedIndex=-1,this._skillBrowseOpened=!1,this._skillBrowseSource="org",this._skillBrowseQuery="",this._isDictating=!1,this._mode="NORMAL",this._modeMenuOpened=!1,this._showTools=!0,this._showToolInputs=!1,this._showConfirmationInput=!1,this._handleDocumentClick=e=>{if(this._modeMenuOpened){e.composedPath().some((e=>e instanceof HTMLElement&&e.classList.contains("mode")))||(this._modeMenuOpened=!1)}if(!this._skillMenuOpened)return;e.composedPath().some((e=>e instanceof HTMLElement&&(e.classList.contains("skill-menu")||e.classList.contains("input")||e.classList.contains("input-plus"))))||(this._skillMenuOpened=!1)},this._handleMouseMove=e=>{if(this._isDragging){let t=this._dragStartLeft+(e.clientX-this._dragStartX),i=this._dragStartTop+(e.clientY-this._dragStartY);const s=this._panelEl.offsetWidth;t=Math.max(48-s,Math.min(t,window.innerWidth-48)),i=Math.max(0,Math.min(i,window.innerHeight-48)),this._panelEl.style.left=t+"px",this._panelEl.style.top=i+"px"}else if(this._isResizing){const t=e.clientX-this._dragStartX,i=e.clientY-this._dragStartY,s=340,n=380,r=.9*window.innerWidth,o=window.innerHeight-72;let a=this._resizeStartW,l=this._resizeStartH,h=this._dragStartLeft,c=this._dragStartTop;this._resizeDir.includes("e")&&(a=Math.max(s,Math.min(this._resizeStartW+t,r))),this._resizeDir.includes("w")&&(a=Math.max(s,Math.min(this._resizeStartW-t,r)),h=this._dragStartLeft+(this._resizeStartW-a)),this._resizeDir.includes("s")&&(l=Math.max(n,Math.min(this._resizeStartH+i,o))),this._resizeDir.includes("n")&&(l=Math.max(n,Math.min(this._resizeStartH-i,o)),c=this._dragStartTop+(this._resizeStartH-l)),h=Math.max(0,h),c=Math.max(0,c),this._panelEl.style.width=a+"px",this._panelEl.style.height=l+"px",this._panelEl.style.left=h+"px",this._panelEl.style.top=c+"px"}},this._handleMouseUp=()=>{this._isDragging&&(this._isDragging=!1,this._panelEl.classList.remove("panel--dragging")),this._isResizing&&(this._isResizing=!1,this._panelEl.classList.remove("panel--resizing")),this._overlay&&(this._overlay.style.display="none"),document.removeEventListener("mousemove",this._handleMouseMove),document.removeEventListener("mouseup",this._handleMouseUp),this._saveState()},this._handleDocumentKeydown=e=>{if(this._pendingActions.length&&!this._confirmationInFlight){if("ArrowRight"===e.key)return e.preventDefault(),void(this._confirmationHighlighted=(this._confirmationHighlighted+1)%oi.length);if("ArrowLeft"===e.key)return e.preventDefault(),void(this._confirmationHighlighted=(this._confirmationHighlighted-1+oi.length)%oi.length);if("Enter"===e.key){e.preventDefault();const t=oi[this._confirmationHighlighted];t&&this._handleConfirmationDecision(t.decision)}}},this._handleDebugResizeMouseMove=e=>{if(!this._isDebugResizing)return;const t=e.clientX-this._debugResizeStartX,i=Math.max(300,this.offsetWidth-300);this._debugDrawerWidth=Math.max(300,Math.min(this._debugResizeStartW-t,i))},this._handleDebugResizeMouseUp=()=>{this._isDebugResizing=!1,document.removeEventListener("mousemove",this._handleDebugResizeMouseMove),document.removeEventListener("mouseup",this._handleDebugResizeMouseUp),this._saveState()}}connectedCallback(){super.connectedCallback(),this.load||(this.load=()=>null==this.conversationId?Promise.resolve([]):n.fetch({url:`/api/system/conversation/${this.conversationId}/messages`}).then((e=>e.json())).then((e=>Promise.all((e?.data||[]).map((e=>{if("tool_use"===e.type||"tool_result"===e.type){let t={};try{t=JSON.parse(e.content||"{}")}catch{}return Promise.resolve({type:e.type,content:"",data:t})}if("action_decision"===e.type){let t={};try{t=JSON.parse(e.content||"{}")}catch{}return Promise.resolve({type:"action_decision",content:"",data:t})}let t=[];try{t=JSON.parse(e.conversationFileIDs||"[]")}catch{}return t.length?Promise.all(t.map((e=>n.fetch({url:`/api/system/conversationFile/${e}`}).then((e=>e.json())).then((e=>e?.data)).catch((()=>null))))).then((t=>(e.conversationFiles=t.filter((e=>null!=e)),e))):Promise.resolve(e)})))))),this.load().then((e=>{e&&e.length&&(this.messages=e)})).catch((()=>{})),n.fetch({url:"/api/system/integration/aws/bedrock/aiFrameworkConfig"}).then((e=>e.json())).then((e=>{this._aiFrameworkConfig=e?.data||{}})).catch((()=>{})),"inline"===this.variant&&(this.opened=!0),this._restoreState(),document.addEventListener("click",this._handleDocumentClick),document.addEventListener("keydown",this._handleDocumentKeydown)}disconnectedCallback(){super.disconnectedCallback(),this._reader&&(this._reader.cancel(),this._reader=null),document.removeEventListener("mousemove",this._handleMouseMove),document.removeEventListener("mouseup",this._handleMouseUp),document.removeEventListener("click",this._handleDocumentClick),document.removeEventListener("keydown",this._handleDocumentKeydown),this._speechRecognition&&(this._speechRecognition.abort(),this._speechRecognition=null,this._isDictating=!1),this._pendingConversationFiles.forEach((e=>{e.previewUrl&&URL.revokeObjectURL(e.previewUrl)}))}updated(e){e.has("messages")&&(this._userHasScrolledUp||this._isStreaming||!this._messagesEl||requestAnimationFrame((()=>{this._messagesEl&&(this._messagesEl.scrollTop=this._messagesEl.scrollHeight)}))),e.has("opened")&&this.opened&&this._inputEl&&setTimeout((()=>{this._inputEl&&this._inputEl.focus()}),200),this._skillMenuOpened&&this._positionSkillMenu(),e.has("_skillHighlighted")&&this._skillMenuOpened&&this._skillMenuEl?.querySelector(".skill-menu__item--highlighted")?.scrollIntoView({block:"nearest"})}_positionSkillMenu(){requestAnimationFrame((()=>{if(!this._skillMenuEl||!this._inputWrapperEl)return;const e=this._inputWrapperEl.getBoundingClientRect();this._skillMenuEl.style.left=e.left+"px",this._skillMenuEl.style.width=e.width+"px";const t=this._panelEl.getBoundingClientRect().top+8,i=e.top-8-t;this._skillMenuEl.style.maxHeight=i+"px";const s=this._skillMenuEl.getBoundingClientRect(),n=Math.max(t,e.top-s.height-8);this._skillMenuEl.style.top=n+"px"}))}stop(){this._handleStop()}isStreaming(){return this._isStreaming}open(){this.opened||this._handleToggle()}close(){this.opened&&this._handleToggle()}toggle(){this._handleToggle()}_showOverlay(){this._overlay||(this._overlay=document.createElement("div"),this._overlay.style.cssText="position:fixed; inset:0; z-index:9999; display:none;",document.body.appendChild(this._overlay)),this._overlay.style.display="block"}_handleHeaderMouseDown(e){if("inline"===this.variant)return;if(e.target.closest("button"))return;if(!this._panelEl)return;this._isDragging=!0,this._panelEl.classList.add("panel--dragging"),this._showOverlay();const t=this._panelEl.getBoundingClientRect();this._panelEl.style.left=t.left+"px",this._panelEl.style.top=t.top+"px",this._panelEl.style.right="auto",this._panelEl.style.bottom="auto",this._panelEl.style.position="fixed",this._dragStartX=e.clientX,this._dragStartY=e.clientY,this._dragStartLeft=t.left,this._dragStartTop=t.top,e.preventDefault(),document.addEventListener("mousemove",this._handleMouseMove),document.addEventListener("mouseup",this._handleMouseUp)}_handleResizeMouseDown(e){if("inline"===this.variant)return;if(!this._panelEl)return;this._isResizing=!0,this._resizeDir=e.currentTarget.dataset.dir||"",this._panelEl.classList.add("panel--resizing"),this._showOverlay();const t=this._panelEl.getBoundingClientRect();this._panelEl.style.left=t.left+"px",this._panelEl.style.top=t.top+"px",this._panelEl.style.right="auto",this._panelEl.style.bottom="auto",this._panelEl.style.position="fixed",this._dragStartX=e.clientX,this._dragStartY=e.clientY,this._dragStartLeft=t.left,this._dragStartTop=t.top,this._resizeStartW=t.width,this._resizeStartH=t.height,e.preventDefault(),e.stopPropagation(),document.addEventListener("mousemove",this._handleMouseMove),document.addEventListener("mouseup",this._handleMouseUp)}_handleToggle(){this.opened=!this.opened,this.opened&&this._panelEl&&this._applyStoredLayout(),this._saveState()}_saveState(){try{const e={opened:String(this.opened),message:this._inputValue,mode:this._mode,showTools:String(this._showTools),showToolInputs:String(this._showToolInputs),showConfirmationInput:String(this._showConfirmationInput),drawerOpen:String(this._drawerOpen),drawerView:this._drawerView,debugDrawerWidth:String(this._debugDrawerWidth)};if(this._panelEl){const t=this._panelEl.style;t.left&&(e.left=t.left),t.top&&(e.top=t.top),t.width&&(e.width=t.width),t.height&&(e.height=t.height),t.position&&(e.position=t.position)}localStorage.setItem("kr-chatbot-state",JSON.stringify(e))}catch{}}_restoreState(){try{const e=localStorage.getItem("kr-chatbot-state");if(!e)return;const t=JSON.parse(e);"string"==typeof t.message&&"/"!==t.message.trim()&&(this._inputValue=t.message),"NORMAL"!==t.mode&&"EDIT"!==t.mode&&"PLAN"!==t.mode||(this._mode=t.mode),this._showTools="true"===t.showTools,this._showToolInputs="true"===t.showToolInputs,this._showConfirmationInput="true"===t.showConfirmationInput,this._drawerOpen="true"===t.drawerOpen,"settings"!==t.drawerView&&"debug"!==t.drawerView||(this._drawerView=t.drawerView);const i=Number(t.debugDrawerWidth);i>=300&&(this._debugDrawerWidth=i),"inline"!==this.variant&&"true"===t.opened&&(this.opened=!0,this.updateComplete.then((()=>this._applyStoredLayout())))}catch{}}_applyStoredLayout(){try{const e=localStorage.getItem("kr-chatbot-state");if(!e||!this._panelEl)return;const t=JSON.parse(e);t.position&&(this._panelEl.style.position=t.position),t.left&&(this._panelEl.style.left=t.left),t.top&&(this._panelEl.style.top=t.top),t.width&&(this._panelEl.style.width=t.width),t.height&&(this._panelEl.style.height=t.height)}catch{}}_handleInputChange(e){this._inputValue=e.target.value,this._saveState();const t=e.target;t.style.height="auto",t.style.height=Math.min(t.scrollHeight,120)+"px";const i=this._inputValue.match(/^\/(\S*)$/);i?(this._skillMenuOpened=!0,this._skillQuery=i[1],this._skillHighlighted=0,this._searchInvocableSkills(this._skillQuery)):this._skillMenuOpened=!1}_handleKeyDown(e){if(this._skillMenuOpened){let t=3;"inline"===this.variant&&!0===this._aiFrameworkConfig.debugTelemetryEnabled&&(t=5);const i=t+this._invocableSkills.length;if("ArrowDown"===e.key)return e.preventDefault(),void(this._skillHighlighted=(this._skillHighlighted+1)%i);if("ArrowUp"===e.key)return e.preventDefault(),void(this._skillHighlighted=(this._skillHighlighted-1+i)%i);if("Enter"===e.key&&!e.shiftKey)return e.preventDefault(),void this._activateSkillMenuItem(this._skillHighlighted);if("Escape"===e.key)return e.preventDefault(),void(this._skillMenuOpened=!1)}"Enter"!==e.key||e.shiftKey||(e.preventDefault(),this._handleSubmit())}_activateSkillMenuItem(e){const t="inline"===this.variant&&!0===this._aiFrameworkConfig.debugTelemetryEnabled;let i=3;if(t&&(i=5),0===e)return void this._openFilePicker(!0);if(1===e)return void this._openFilePicker(!1);if(2===e)return void this._handleSkillBrowseOpen();if(t&&3===e)return this._skillMenuOpened=!1,void this._send({message:"/test-context-warning",conversationFiles:[]});if(t&&4===e)return this._skillMenuOpened=!1,void this._send({message:"/test-context-limit",conversationFiles:[]});const s=this._invocableSkills[e-i];s&&this._handleSkillSelect(s)}_searchOrgSkills(e){this._orgSkillRequestId++;const t=this._orgSkillRequestId;n.fetch({url:"/api/system/conversation/localSkillList",method:"POST",body:{query:e.trim()}}).then((e=>e.json())).then((e=>{t===this._orgSkillRequestId&&(this._orgSkills=e?.data||[])})).catch((e=>{console.error("kr-chatbot: skill search failed",e)}))}_searchInvocableSkills(e){this._invocableSkillRequestId++;const t=this._invocableSkillRequestId;n.fetch({url:"/api/system/conversation/availableSkills",method:"POST",body:{query:e.trim()}}).then((e=>e.json())).then((e=>{t===this._invocableSkillRequestId&&(this._invocableSkills=e?.data||[])})).catch((e=>{console.error("kr-chatbot: invocable skill search failed",e)}))}_searchGlobalSkills(e){this._globalSkillRequestId++;const t=this._globalSkillRequestId;n.fetch({url:"/api/system/conversation/globalSkillList",method:"POST",body:{query:e.trim()}}).then((e=>e.json())).then((e=>{t===this._globalSkillRequestId&&(this._globalSkills=e?.data||[])})).catch((e=>{console.error("kr-chatbot: global skill search failed",e)}))}_handleGlobalSkillEnable(e,t){if(t.stopPropagation(),!e.canEnable)return void i.show({title:"Permission Required",message:"You do not have permission to install skills. Please contact your site administrator.",type:"error"});if(this._globalSkillPending.has(e.code))return;const s=t.currentTarget;this._globalSkillPending.add(e.code),s?.showLoading(),n.fetch({url:`/api/system/opensearch/aiskills/global/${encodeURIComponent(e.code)}/enabled`,method:"POST",body:{enabled:!e.enabled}}).then((e=>e.json())).then((t=>{e.enabled=t?.data?.enabled,s?.reset(),this.requestUpdate()})).catch((e=>{console.error("kr-chatbot: global skill enable failed",e),s?.showError("Error")})).finally((()=>{this._globalSkillPending.delete(e.code)}))}_handlePlusClick(){this._skillMenuOpened?this._skillMenuOpened=!1:(this._skillQuery="",this._skillHighlighted=0,this._skillMenuOpened=!0,this._searchInvocableSkills(""))}_handleModeToggle(){this._modeMenuOpened=!this._modeMenuOpened}_handleModeSelect(e){this._mode=e,this._modeMenuOpened=!1,this._saveState()}_handleShowToolsChange(e){this._showTools=e.target.checked,this._saveState()}_handleShowToolInputsChange(e){this._showToolInputs=e.target.checked,this._saveState()}_handleShowConfirmationInputChange(e){this._showConfirmationInput=e.target.checked,this._saveState()}_handleMicClick(){if(this._speechRecognition)return void this._speechRecognition.stop();const e=window.SpeechRecognition||window.webkitSpeechRecognition;if(!e)return;const t=new e;t.continuous=!0,t.interimResults=!0,this._speechBaseValue=this._inputValue,this._speechBaseValue&&!this._speechBaseValue.endsWith(" ")&&(this._speechBaseValue+=" "),this._speechFinalTranscript="",t.onresult=e=>{let t="";for(let i=e.resultIndex;i<e.results.length;i++)e.results[i].isFinal?this._speechFinalTranscript+=e.results[i][0].transcript:t+=e.results[i][0].transcript;this._inputValue=this._speechBaseValue+this._speechFinalTranscript+t,this._saveState(),this._inputEl&&(this._inputEl.style.height="auto",this._inputEl.style.height=Math.min(this._inputEl.scrollHeight,120)+"px")},t.onerror=e=>{"not-allowed"!==e.error&&"service-not-allowed"!==e.error||(this._error="Microphone access is blocked. Allow it in your browser settings to use voice input.")},t.onend=()=>{this._speechRecognition=null,this._isDictating=!1},this._speechRecognition=t,this._isDictating=!0,this._error="",t.start(),this._inputEl?.focus()}_handleSkillSelect(e){if(!1===e.canRun){let t=`You do not have access to "${e.name}". Ask your site administrator to grant it.`;return e.allowedRoles?.length&&(t=`"${e.name}" requires the ${e.allowedRoles.join(" or ")} role. Ask your site administrator to grant it.`),void i.show({title:"Access Required",message:t,type:"error"})}!e.global||e.enabled?(this._inputValue=`/${e.code} `,this._saveState(),this._skillMenuOpened=!1,this._skillBrowseOpened=!1,this._inputEl?.focus()):i.show({title:"Not Installed",message:`"${e.name}" has to be installed on this site before you can use it — use the Install button on the card.`,type:"info"})}_handleSkillCardKeydown(e,t){"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),this._handleSkillSelect(t))}_handleCopyMessage(e,t){navigator.clipboard.writeText(e).then((()=>{this._copiedIndex=t,setTimeout((()=>{this._copiedIndex===t&&(this._copiedIndex=-1)}),2e3)})).catch((()=>{}))}_handleSkillBrowseOpen(){this._skillMenuOpened=!1,this._skillBrowseQuery="",this._skillBrowseOpened=!0,this._searchOrgSkills(""),!0!==this._aiFrameworkConfig.registryServer&&this._searchGlobalSkills("")}_handleSkillBrowseClose(){this._skillBrowseOpened=!1}_handleSkillBrowseSearch(e){this._skillBrowseQuery=e.target.value,this._searchOrgSkills(this._skillBrowseQuery),!0!==this._aiFrameworkConfig.registryServer&&this._searchGlobalSkills(this._skillBrowseQuery)}_handleSkillBrowseTabChange(e){this._skillBrowseSource=e.detail.activeTabId}_openFilePicker(e=!0){this._skillMenuOpened=!1,"/"===this._inputValue.trim()&&(this._inputValue="",this._saveState()),this._pendingAttachAnalyze=e,this._fileInputEl?.click()}_handleFileInputChange(e){const t=e.target;t.files&&this._addFiles(t.files,this._pendingAttachAnalyze),t.value=""}_handlePaste(e){const t=e.clipboardData?.items;if(!t)return;const i=[];for(let e=0;e<t.length;e++)if("file"===t[e].kind){const s=t[e].getAsFile();s&&i.push(s)}i.length&&(e.preventDefault(),this._addFiles(i))}_handleDragEnter(e){this._hasFiles(e)&&(e.preventDefault(),this._dragDepth++,this._isDraggingFile=!0)}_handleDragOver(e){this._hasFiles(e)&&e.preventDefault()}_handleDragLeave(e){this._hasFiles(e)&&(this._dragDepth--,this._dragDepth<=0&&(this._dragDepth=0,this._isDraggingFile=!1))}_handleDrop(e){this._hasFiles(e)&&(e.preventDefault(),this._dragDepth=0,this._isDraggingFile=!1,e.dataTransfer?.files&&this._addFiles(e.dataTransfer.files))}_hasFiles(e){return Array.from(e.dataTransfer?.types||[]).includes("Files")}_getFileExtension(e){const t=e.lastIndexOf(".");return t<0?"":e.slice(t+1).toLowerCase()}_addFiles(e,t=!0){const i=Array.from(e).filter((e=>hi.includes(this._getFileExtension(e.name))));i.length&&i.forEach((e=>{let i;(e.type.startsWith("image/")||li.includes(this._getFileExtension(e.name)))&&(i=URL.createObjectURL(e));const s={localId:"att-"+this._pendingSeq++,file:e,name:e.name,mimeType:e.type,previewUrl:i,aiAnalyze:t};this._pendingConversationFiles=[...this._pendingConversationFiles,s]}))}_handlePendingRemove(e){const t=this._pendingConversationFiles.find((t=>t.localId===e));t?.previewUrl&&URL.revokeObjectURL(t.previewUrl),this._pendingConversationFiles=this._pendingConversationFiles.filter((t=>t.localId!==e))}_clearPending(){this._pendingConversationFiles.forEach((e=>{e.previewUrl&&URL.revokeObjectURL(e.previewUrl)})),this._pendingConversationFiles=[]}_handleFileOpen(e){const t=e.previewUrl||`${n.getBaseUrl()}/api/system/conversationFile/${e.conversationFileID}/view`;s.open({src:t,name:e.niceName||"file"}).addEventListener("download",(()=>{window.open(`${n.getBaseUrl()}/api/system/conversationFile/${e.conversationFileID}/view?download=true`,"_blank")}))}_handleSubmit(){if(this._isStreaming)return;if(this._pendingActions.length)return;const e=this._inputValue.trim(),t=this._pendingConversationFiles;if(!e&&!t.length)return;const i=t.map((e=>({file:e.file,aiAnalyze:e.aiAnalyze}))),s=new CustomEvent("message-submit",{detail:{message:e,conversationFiles:i},bubbles:!0,composed:!0,cancelable:!0});this.dispatchEvent(s),s.defaultPrevented||this._send({message:e,conversationFiles:i})}_send(e){const t={type:"user",content:e.message};this._pendingConversationFiles.length&&(t.conversationFiles=this._pendingConversationFiles.map((e=>({conversationFileID:-1,niceName:e.name,mimeType:e.mimeType,aiAnalyze:e.aiAnalyze,previewUrl:e.previewUrl})))),this._speechRecognition&&this._speechRecognition.abort(),this.messages=[...this.messages,t],this._inputValue="",this._saveState(),this._error="",this._userHasScrolledUp=!1,this._pendingConversationFiles=[],this._inputEl&&(this._inputEl.style.height="auto"),this.messages=[...this.messages,{type:"assistant",content:""}],this._isStreaming=!0,this.updateComplete.then((()=>{if(!this._messagesEl)return;this._messagesEl.querySelectorAll(".agent-turn").forEach((e=>{e.style.minHeight=""}));const e=this._messagesEl.querySelectorAll(".message--user"),t=e[e.length-1],i=this._messagesEl.querySelectorAll(".agent-turn"),s=i[i.length-1];s&&(s.style.minHeight=this._messagesEl.clientHeight+"px"),t&&(this._messagesEl.scrollTop=t.offsetTop-this._messagesEl.offsetTop-24)})),this.send||(this.send=e=>{if(e.confirmation)return n.fetch({url:"/api/system/integration/aws/bedrock/stream/invokeModelForConversationWithState",method:"POST",headers:{Accept:"text/event-stream"},body:{confirmation:e.confirmation,conversationID:this.conversationId}});let t=Promise.resolve([]);return e.conversationFiles.length&&(t=Promise.all(e.conversationFiles.map((({file:e,aiAnalyze:t})=>{const i=new FormData;return i.append("file",e),i.append("type","LIBRARY"),i.append("niceName",e.name),t||i.append("aiAnalyze","false"),n.fetch({url:"/api/system/conversationFile/upload",method:"POST",body:i}).then((e=>e.json())).then((e=>e.data))})))),t.then((t=>{if(t.length)for(let e=this.messages.length-1;e>=0;e--)if("user"===this.messages[e].type){(this.messages[e].conversationFiles||[]).forEach((e=>{e.previewUrl&&URL.revokeObjectURL(e.previewUrl)})),this.messages[e].conversationFiles=t,this.requestUpdate();break}const i={userText:e.message,fileIds:t.map((e=>e.conversationFileID)),mode:this._mode};return e.pageContext&&(i.pageContext=e.pageContext),e.selectionContext&&(i.selectionContext=e.selectionContext),null!=this.conversationId?i.conversationID=this.conversationId:i.createNew=!0,n.fetch({url:"/api/system/integration/aws/bedrock/stream/invokeModelForConversationWithState",method:"POST",headers:{Accept:"text/event-stream"},body:i}).then((e=>(null==this.conversationId&&n.fetch({url:"/api/system/conversation/last"}).then((e=>e.json())).then((e=>{const t=e?.data,i=t?.conversationID;"number"==typeof i&&(this.conversationId=i,this.dispatchEvent(new CustomEvent("conversation-created",{detail:{conversation:t},bubbles:!0,composed:!0})))})).catch((()=>{})),e)))}))});const i=this._captureContext();this.send({message:e.message,messages:this.messages.slice(0,-1),conversationFiles:e.conversationFiles,pageContext:i.pageContext,selectionContext:i.selectionContext}).then((e=>{e.ok?e.body?(this._reader=e.body.getReader(),this._decoder=new TextDecoder,this._buffer="",this._readStreamChunk()):this._handleStreamError("No response body"):this._handleStreamError("Request failed: "+e.status)})).catch((e=>{"AbortError"!==e.name&&this._handleStreamError(e.message)}))}_handleConfirmationDecision(e){if(this._confirmationInFlight)return;this._confirmationInFlight=!0,this._error="";const t=this._messagesEl?.querySelector(`.confirmation__btn[data-decision="${e}"]`);t?.showLoading(),this._isStreaming=!0,this._userHasScrolledUp=!1,this.send({message:"",messages:this.messages,conversationFiles:[],pageContext:"",selectionContext:"",confirmation:e}).then((e=>e.ok?e.body?(this._reader=e.body.getReader(),this._decoder=new TextDecoder,this._buffer="",void this._readStreamChunk()):(this._confirmationInFlight=!1,t?.reset(),void this._handleStreamError("No response body")):(this._confirmationInFlight=!1,t?.reset(),void this._handleStreamError("Request failed: "+e.status)))).catch((e=>{this._confirmationInFlight=!1,t?.reset(),"AbortError"!==e.name&&this._handleStreamError(e.message)}))}_captureContext(){let e="";try{const t={url:window.location.href,title:document.title},i=document.getElementById("kodaris-page");if(i&&i.textContent)try{t.page=JSON.parse(i.textContent)}catch{}e=JSON.stringify(t)}catch{}let t="";try{const e=window.getSelection();e&&(t=e.toString().trim())}catch{}return{pageContext:e,selectionContext:t}}_handleStop(){this._reader&&(this._reader.cancel(),this._reader=null),this._isStreaming=!1}_handleMessagesScroll(e){const t=e.target,i=t.scrollHeight-t.scrollTop-t.clientHeight;this._userHasScrolledUp=i>50}_handleErrorDismiss(){this._error=""}_handleContextWarningDismiss(){this._contextWarning=""}_toggleDrawer(e){this._drawerOpen&&this._drawerView===e?this._drawerOpen=!1:(this._drawerOpen=!0,this._drawerView=e),this._saveState()}_handleCloseDrawer(){this._drawerOpen=!1,this._saveState()}_handleDebugResizeMouseDown(e){this._isDebugResizing=!0,this._debugResizeStartX=e.clientX,this._debugResizeStartW=this._debugDrawerWidth,e.preventDefault(),e.stopPropagation(),document.addEventListener("mousemove",this._handleDebugResizeMouseMove),document.addEventListener("mouseup",this._handleDebugResizeMouseUp)}_readStreamChunk(){this._reader&&this._reader.read().then((e=>{if(e.done)return void this._finishStream();this._buffer=this._buffer+this._decoder.decode(e.value,{stream:!0});const t=this._buffer.split("\n\n");this._buffer=t.pop()||"";for(let e=0;e<t.length;e++){if(!t[e].trim())continue;const i=t[e].split("\n");for(let e=0;e<i.length;e++){if(!i[e].startsWith("data:"))continue;const t=i[e].slice(5).trim();if(!t)continue;let s;try{s=JSON.parse(t)}catch{continue}if(this.dispatchEvent(new CustomEvent("stream-event",{detail:s,bubbles:!0,composed:!0})),"REASONING_PART"===s.type){if(s.message){const e=this._ensureAssistantBubble();e.reasoning||(e.reasoning=""),e.reasoning+=String(s.message),this.requestUpdate()}}else if("RESPONSE_PART"===s.type)s.message&&(this._ensureAssistantBubble().content+=String(s.message),this.requestUpdate());else if("tool_use"===s.type||"tool_result"===s.type)this.messages.push(s),this.requestUpdate();else if("action_decision"===s.type)this._pendingActions=[],this._confirmationHighlighted=-1,this._confirmationInFlight=!1,this.messages.push(s),this.requestUpdate();else if("ERROR"===s.type)this._handleStreamError(String(s.message||"Unknown error"));else if("CONVERSATION_STATE"===s.type)"NORMAL"!==s.data?.mode&&"EDIT"!==s.data?.mode&&"PLAN"!==s.data?.mode||(this._mode=s.data.mode);else if("CONVERSATION_TOKEN_WARNING"===s.type)this._contextWarning=String(s.message||"");else if("CONVERSATION_TITLE"===s.type){if(s.data?.title){const e=String(s.data.title);this.label=e,this.dispatchEvent(new CustomEvent("conversation-title",{detail:{title:e},bubbles:!0,composed:!0}))}}else if("CONVERSATION_LIMIT_REACHED"===s.type)this._contextLimitReached=!0,this._contextLimitMessage=String(s.message||""),this._contextWarning="";else if("ACTION_CONFIRMATION_REQUIRED"===s.type){const e=s.data?.actions;Array.isArray(e)&&e.length&&(this._pendingActions=e,this._confirmationHighlighted=0)}else if("TOKEN_USAGE"===s.type){if(s.data){const e=s.data;this._telemetry=e,1===e.iteration?(this._iterationLog=[e],this._cacheCheckpoints={}):this._iterationLog=[...this._iterationLog,e]}}else if("CACHE_CHECKPOINT"===s.type&&s.data){const e=s.data;this._cacheCheckpoints={...this._cacheCheckpoints,[e.iteration]:e}}s.finished&&this._finishStream()}}this._reader&&this._readStreamChunk()})).catch((e=>{"AbortError"!==e.name&&this._handleStreamError(e.message)}))}_ensureAssistantBubble(){const e=this.messages[this.messages.length-1];if(e&&"assistant"===e.type)return e;const t={type:"assistant",content:""};return this.messages=[...this.messages,t],t}_finishStream(){if(this._isStreaming=!1,this._reader=null,this._pendingActions.length){const e=this.messages.length-1;e>=0&&"assistant"===this.messages[e].type&&!this.messages[e].content&&!this.messages[e].reasoning&&(this.messages=this.messages.slice(0,-1)),this._inlineConfirm&&this.updateComplete.then((()=>{this._messagesEl?.querySelector(".confirmation")?.scrollIntoView({behavior:"smooth",block:"end"})}))}}_handleStreamError(e){if(this._isStreaming=!1,this._error=e,this._reader&&(this._reader.cancel(),this._reader=null),this.messages.length>0){const e=this.messages[this.messages.length-1];"assistant"!==e.type||e.content||(this.messages=this.messages.slice(0,-1))}}_renderModeSelector(){const e=ai.find((e=>e.mode===this._mode))||ai[0];return V`
1385
+ <div class="mode">
1386
+ ${this._modeMenuOpened?V`
1387
+ <div class="mode-menu">
1388
+ ${ai.map((e=>V`
1389
+ <button
1390
+ class=${$e({"mode-menu__item":!0,"mode-menu__item--active":e.mode===this._mode})}
1391
+ @click=${()=>this._handleModeSelect(e.mode)}
1392
+ >
1393
+ <span class="mode-menu__label">${e.label}</span>
1394
+ <span class="mode-menu__desc">${e.description}</span>
1395
+ </button>
1396
+ `))}
1397
+ </div>
1398
+ `:Q}
1399
+ <button
1400
+ class="mode-trigger"
1401
+ aria-haspopup="true"
1402
+ aria-expanded=${this._modeMenuOpened?"true":"false"}
1403
+ @click=${this._handleModeToggle}
1404
+ >
1405
+ <span class="mode-trigger__label">${e.label}</span>
1406
+ <svg
1407
+ class="mode-trigger__caret"
1408
+ viewBox="0 0 24 24"
1409
+ fill="none"
1410
+ stroke="currentColor"
1411
+ stroke-width="2"
1412
+ stroke-linecap="round"
1413
+ stroke-linejoin="round"
1414
+ aria-hidden="true"
1415
+ >
1416
+ <path d="M6 9l6 6 6-6" />
1417
+ </svg>
1418
+ </button>
1419
+ </div>
1420
+ `}_renderConfirmation(){let e="Run this action?";return this._pendingActions.length>1?e="These actions need your approval":this._pendingActions[0]&&(e=`Run "${this._pendingActions[0].displayName||this._pendingActions[0].toolName}"?`),V`
1385
1421
  <div
1386
- class="confirmation"
1422
+ class=${$e({confirmation:!0,"confirmation--inline":this._inlineConfirm})}
1387
1423
  role="alertdialog"
1388
1424
  aria-label="Confirm before continuing"
1389
1425
  >
1390
- <div class="confirmation__title">${t}</div>
1391
- <p class="confirmation__message">${e?.confirmationMessage||"The assistant wants to take an action. Is that OK?"}</p>
1426
+ <div class="confirmation__title">${e}</div>
1427
+ ${this._pendingActions.length>1?V`
1428
+ <ol class="confirmation__list">
1429
+ ${this._pendingActions.map((e=>V`
1430
+ <li class="confirmation__list-item">
1431
+ <span class="confirmation__list-name">${e.displayName||e.toolName}</span>
1432
+ ${e.confirmationMessage?V`<span class="confirmation__list-desc">${e.confirmationMessage}</span>`:Q}
1433
+ ${this._showConfirmationInput&&this._inlineConfirm&&e.input&&Object.keys(e.input).length?V`<pre class="confirmation__details-input">${JSON.stringify(e.input,null,2)}</pre>`:Q}
1434
+ </li>
1435
+ `))}
1436
+ </ol>
1437
+ `:V`
1438
+ <p class="confirmation__message">${this._pendingActions[0]?.confirmationMessage||"The assistant wants to take an action. Is that OK?"}</p>
1439
+ ${this._showConfirmationInput&&this._inlineConfirm&&this._pendingActions[0]?.input&&Object.keys(this._pendingActions[0].input).length?V`<pre class="confirmation__details-input">${JSON.stringify(this._pendingActions[0].input,null,2)}</pre>`:Q}
1440
+ `}
1392
1441
  <div class="confirmation__actions">
1393
- ${oi.map(((e,t)=>X`
1442
+ ${oi.map(((e,t)=>V`
1394
1443
  <kr-button
1395
1444
  class=${$e({confirmation__btn:!0,"confirmation__btn--highlighted":t===this._confirmationHighlighted})}
1396
1445
  variant=${"approve"===e.decision?"flat":"outline"}
1397
1446
  color=${"reject"===e.decision?"secondary":"primary"}
1398
1447
  size="small"
1399
- ?disabled=${this._confirmationInFlight}
1448
+ data-decision=${e.decision}
1400
1449
  @click=${()=>this._handleConfirmationDecision(e.decision)}
1401
1450
  >${e.label}</kr-button>
1402
1451
  `))}
1403
1452
  </div>
1404
1453
  </div>
1405
- `}_renderSkillMenu(){const e=this._invocableSkills,t="inline"===this.variant&&!0===this._aiFrameworkConfig.debugTelemetryEnabled;let i=3;return t&&(i=5),X`
1454
+ `}_renderSkillMenu(){const e=this._invocableSkills,t="inline"===this.variant&&!0===this._aiFrameworkConfig.debugTelemetryEnabled;let i=3;return t&&(i=5),V`
1406
1455
  <div class="skill-menu">
1407
1456
  <div class="skill-menu__actions">
1408
1457
  <button
@@ -1425,7 +1474,7 @@ const Fe="important",Ue=" !"+Fe,Le=_e(class extends ke{constructor(e){if(super(e
1425
1474
  >
1426
1475
  Browse All Skills
1427
1476
  </button>
1428
- ${t?X`
1477
+ ${t?V`
1429
1478
  <button
1430
1479
  class=${$e({"skill-menu__action":!0,"skill-menu__item--highlighted":3===this._skillHighlighted})}
1431
1480
  @click=${()=>this._activateSkillMenuItem(3)}
@@ -1438,27 +1487,27 @@ const Fe="important",Ue=" !"+Fe,Le=_e(class extends ke{constructor(e){if(super(e
1438
1487
  >
1439
1488
  Test Context Limit
1440
1489
  </button>
1441
- `:V}
1490
+ `:Q}
1442
1491
  </div>
1443
- ${e.length?X`
1492
+ ${e.length?V`
1444
1493
  <ul class="skill-menu__list">
1445
- ${e.map(((e,t)=>X`
1494
+ ${e.map(((e,t)=>V`
1446
1495
  <li>
1447
1496
  <button
1448
1497
  class=${$e({"skill-menu__item":!0,"skill-menu__item--highlighted":t+i===this._skillHighlighted})}
1449
1498
  @click=${()=>this._handleSkillSelect(e)}
1450
1499
  >
1451
1500
  <span class="skill-menu__name">${e.name}</span>
1452
- ${e.description?X`
1501
+ ${e.description?V`
1453
1502
  <span class="skill-menu__desc">${e.description}</span>
1454
- `:V}
1503
+ `:Q}
1455
1504
  </button>
1456
1505
  </li>
1457
1506
  `))}
1458
1507
  </ul>
1459
- `:V}
1508
+ `:Q}
1460
1509
  </div>
1461
- `}_renderSkillBrowse(){return X`
1510
+ `}_renderSkillBrowse(){return V`
1462
1511
  <kr-dialog
1463
1512
  opened
1464
1513
  label="Browse Skills"
@@ -1478,7 +1527,7 @@ const Fe="important",Ue=" !"+Fe,Le=_e(class extends ke{constructor(e){if(super(e
1478
1527
  <kr-tab id="org" label="Your Org">
1479
1528
  ${this._renderSkillGrid()}
1480
1529
  </kr-tab>
1481
- ${!0===this._aiFrameworkConfig.registryServer?V:X`
1530
+ ${!0===this._aiFrameworkConfig.registryServer?Q:V`
1482
1531
  <kr-tab id="kodaris" label="Kodaris">
1483
1532
  ${this._renderSkillGrid(!0)}
1484
1533
  </kr-tab>
@@ -1486,9 +1535,9 @@ const Fe="important",Ue=" !"+Fe,Le=_e(class extends ke{constructor(e){if(super(e
1486
1535
  </kr-tab-group>
1487
1536
  </div>
1488
1537
  </kr-dialog>
1489
- `}_renderSkillGrid(e=!1){let t=this._orgSkills;return e&&(t=this._globalSkills),t.length?X`
1538
+ `}_renderSkillGrid(e=!1){let t=this._orgSkills;return e&&(t=this._globalSkills),t.length?V`
1490
1539
  <div class="skill-browse__grid">
1491
- ${t.map((t=>X`
1540
+ ${t.map((t=>V`
1492
1541
  <div
1493
1542
  class=${$e({"skill-card":!0,"skill-card--unavailable":!1===t.canRun||!!t.global&&!t.enabled})}
1494
1543
  role="button"
@@ -1497,13 +1546,13 @@ const Fe="important",Ue=" !"+Fe,Le=_e(class extends ke{constructor(e){if(super(e
1497
1546
  @keydown=${e=>this._handleSkillCardKeydown(e,t)}
1498
1547
  >
1499
1548
  <span class="skill-card__name">${t.name}</span>
1500
- ${t.description?X`
1549
+ ${t.description?V`
1501
1550
  <span class="skill-card__desc">${t.description}</span>
1502
- `:V}
1503
- ${!e&&t.global?X`
1551
+ `:Q}
1552
+ ${!e&&t.global?V`
1504
1553
  <span class="skill-card__badge">Global</span>
1505
- `:V}
1506
- ${e?X`
1554
+ `:Q}
1555
+ ${e?V`
1507
1556
  <div class="skill-card__footer">
1508
1557
  <span class="skill-card__price">Free</span>
1509
1558
  <kr-button
@@ -1514,25 +1563,25 @@ const Fe="important",Ue=" !"+Fe,Le=_e(class extends ke{constructor(e){if(super(e
1514
1563
  @click=${e=>this._handleGlobalSkillEnable(t,e)}
1515
1564
  >${t.enabled?"Uninstall":"Install"}</kr-button>
1516
1565
  </div>
1517
- `:V}
1566
+ `:Q}
1518
1567
  </div>
1519
1568
  `))}
1520
1569
  </div>
1521
- `:V}_renderUserContent(e){const t=e.match(/^\/(\S+)(\s[\s\S]*)?$/);return t?X`<span class="message-skill">/${t[1]}</span>${t[2]||""}`:e}_fmtTokens(e){return null==e||isNaN(e)?"—":e.toLocaleString("en-US")}_fmtCost(e){return null==e||isNaN(e)?"—":"~$"+e.toFixed(4)}_renderDebugPanel(){return X`
1570
+ `:Q}_renderUserContent(e){const t=e.match(/^\/(\S+)(\s[\s\S]*)?$/);return t?V`<span class="message-skill">/${t[1]}</span>${t[2]||""}`:e}_fmtTokens(e){return null==e||isNaN(e)?"—":e.toLocaleString("en-US")}_fmtCost(e){return null==e||isNaN(e)?"—":"~$"+e.toFixed(4)}_renderDrawer(){const e="debug"===this._drawerView&&"inline"===this.variant&&!0===this._aiFrameworkConfig.debugTelemetryEnabled;return V`
1522
1571
  <div
1523
- class=${$e({"debug-drawer":!0,"debug-drawer--open":this._debugPanelOpen,"debug-drawer--resizing":this._isDebugResizing})}
1524
- style=${Le({width:`${this._debugDrawerWidth}px`})}
1572
+ class=${$e({drawer:!0,"drawer--open":this._drawerOpen,"drawer--resizing":this._isDebugResizing})}
1573
+ style=${Ue({width:`${this._debugDrawerWidth}px`})}
1525
1574
  >
1526
1575
  <div
1527
- class="debug-drawer__resize"
1576
+ class="drawer__resize"
1528
1577
  @mousedown=${this._handleDebugResizeMouseDown}
1529
1578
  ></div>
1530
- <div class="debug-drawer__header">
1531
- <span class="debug-drawer__title">Debug</span>
1579
+ <div class="drawer__header">
1580
+ <span class="drawer__title">${e?"Debug":"Settings"}</span>
1532
1581
  <button
1533
1582
  class="header-action"
1534
- @click=${this._handleToggleDebugPanel}
1535
- title="Close debug panel"
1583
+ @click=${this._handleCloseDrawer}
1584
+ title="Close"
1536
1585
  >
1537
1586
  <svg
1538
1587
  xmlns="http://www.w3.org/2000/svg"
@@ -1550,98 +1599,125 @@ const Fe="important",Ue=" !"+Fe,Le=_e(class extends ke{constructor(e){if(super(e
1550
1599
  </svg>
1551
1600
  </button>
1552
1601
  </div>
1553
- <div class="debug-drawer__body">
1554
- ${this._telemetry?X`
1555
- <div class="debug-section">
1556
- <div class="debug-section__label">Context</div>
1557
- <div class="debug-gauge">
1558
- <div class="debug-gauge__bar">
1559
- <div
1560
- class="debug-gauge__fill"
1561
- style=${Le({width:`${Math.min(100,Math.max(0,this._telemetry.contextUsedPercent||0))}%`})}
1562
- ></div>
1563
- </div>
1564
- <span class="debug-gauge__text">
1565
- ${this._fmtTokens(this._telemetry.currentContextTokens)} / ${this._fmtTokens(this._telemetry.contextWindowTokens)}
1566
- · ${this._telemetry.contextUsedPercent??0}%
1567
- </span>
1568
- </div>
1602
+ <div class="drawer__body">
1603
+ ${e?this._renderDebugContent():this._renderSettingsContent()}
1604
+ </div>
1605
+ </div>
1606
+ `}_renderSettingsContent(){return V`
1607
+ <div class="settings-section">
1608
+ <div class="settings-section__title">Tools</div>
1609
+ <div class="settings-row">
1610
+ <kr-checkbox
1611
+ label="Show tools"
1612
+ .checked=${this._showTools}
1613
+ @change=${this._handleShowToolsChange}
1614
+ ></kr-checkbox>
1615
+ </div>
1616
+ <div class="settings-row">
1617
+ <kr-checkbox
1618
+ label="Show tool inputs"
1619
+ .checked=${this._showToolInputs}
1620
+ @change=${this._handleShowToolInputsChange}
1621
+ ></kr-checkbox>
1622
+ </div>
1623
+ <div class="settings-row">
1624
+ <kr-checkbox
1625
+ label="Show tool confirmation inputs"
1626
+ .checked=${this._showConfirmationInput}
1627
+ @change=${this._handleShowConfirmationInputChange}
1628
+ ></kr-checkbox>
1629
+ </div>
1630
+ </div>
1631
+ `}_renderDebugContent(){return V`
1632
+ ${this._telemetry?V`
1633
+ <div class="debug-section">
1634
+ <div class="debug-section__label">Context</div>
1635
+ <div class="debug-gauge">
1636
+ <div class="debug-gauge__bar">
1637
+ <div
1638
+ class="debug-gauge__fill"
1639
+ style=${Ue({width:`${Math.min(100,Math.max(0,this._telemetry.contextUsedPercent||0))}%`})}
1640
+ ></div>
1569
1641
  </div>
1642
+ <span class="debug-gauge__text">
1643
+ ${this._fmtTokens(this._telemetry.currentContextTokens)} / ${this._fmtTokens(this._telemetry.contextWindowTokens)}
1644
+ · ${this._telemetry.contextUsedPercent??0}%
1645
+ </span>
1646
+ </div>
1647
+ </div>
1570
1648
 
1571
- <div class="debug-section">
1572
- <div class="debug-section__label">This turn</div>
1573
- <div class="debug-metrics">
1574
- <span class="debug-metrics__key">Input</span>
1575
- <span class="debug-metrics__val">${this._fmtTokens(this._telemetry.turnInputTokens)}</span>
1576
- <span class="debug-metrics__key">Output</span>
1577
- <span class="debug-metrics__val">${this._fmtTokens(this._telemetry.turnOutputTokens)}</span>
1578
- <span class="debug-metrics__key">Cache read</span>
1579
- <span class="debug-metrics__val">${this._fmtTokens(this._telemetry.turnCacheReadTokens)}</span>
1580
- <span class="debug-metrics__key">Hit rate</span>
1581
- <span class="debug-metrics__val">${this._telemetry.turnHitRate??"—"}%</span>
1582
- <span class="debug-metrics__key">Cost</span>
1583
- <span class="debug-metrics__val debug-cost">${this._fmtCost(this._telemetry.turnCostUsd)}</span>
1584
- </div>
1585
- </div>
1649
+ <div class="debug-section">
1650
+ <div class="debug-section__label">This turn</div>
1651
+ <div class="debug-metrics">
1652
+ <span class="debug-metrics__key">Input</span>
1653
+ <span class="debug-metrics__val">${this._fmtTokens(this._telemetry.turnInputTokens)}</span>
1654
+ <span class="debug-metrics__key">Output</span>
1655
+ <span class="debug-metrics__val">${this._fmtTokens(this._telemetry.turnOutputTokens)}</span>
1656
+ <span class="debug-metrics__key">Cache read</span>
1657
+ <span class="debug-metrics__val">${this._fmtTokens(this._telemetry.turnCacheReadTokens)}</span>
1658
+ <span class="debug-metrics__key">Hit rate</span>
1659
+ <span class="debug-metrics__val">${this._telemetry.turnHitRate??"—"}%</span>
1660
+ <span class="debug-metrics__key">Cost</span>
1661
+ <span class="debug-metrics__val debug-cost">${this._fmtCost(this._telemetry.turnCostUsd)}</span>
1662
+ </div>
1663
+ </div>
1586
1664
 
1587
- <div class="debug-section">
1588
- <div class="debug-section__label">Lifetime</div>
1589
- <div class="debug-metrics">
1590
- <span class="debug-metrics__key">Input</span>
1591
- <span class="debug-metrics__val">${this._fmtTokens(this._telemetry.conversationInputTokens)}</span>
1592
- <span class="debug-metrics__key">Output</span>
1593
- <span class="debug-metrics__val">${this._fmtTokens(this._telemetry.conversationOutputTokens)}</span>
1594
- <span class="debug-metrics__key">Cache read</span>
1595
- <span class="debug-metrics__val">${this._fmtTokens(this._telemetry.conversationCacheReadTokens)}</span>
1596
- <span class="debug-metrics__key">Cache write</span>
1597
- <span class="debug-metrics__val">${this._fmtTokens(this._telemetry.conversationCacheWriteTokens)}</span>
1598
- <span class="debug-metrics__key">Cost so far</span>
1599
- <span class="debug-metrics__val debug-cost">${this._fmtCost(this._telemetry.conversationCostUsd)}</span>
1600
- </div>
1601
- </div>
1602
- `:X`
1665
+ <div class="debug-section">
1666
+ <div class="debug-section__label">Lifetime</div>
1667
+ <div class="debug-metrics">
1668
+ <span class="debug-metrics__key">Input</span>
1669
+ <span class="debug-metrics__val">${this._fmtTokens(this._telemetry.conversationInputTokens)}</span>
1670
+ <span class="debug-metrics__key">Output</span>
1671
+ <span class="debug-metrics__val">${this._fmtTokens(this._telemetry.conversationOutputTokens)}</span>
1672
+ <span class="debug-metrics__key">Cache read</span>
1673
+ <span class="debug-metrics__val">${this._fmtTokens(this._telemetry.conversationCacheReadTokens)}</span>
1674
+ <span class="debug-metrics__key">Cache write</span>
1675
+ <span class="debug-metrics__val">${this._fmtTokens(this._telemetry.conversationCacheWriteTokens)}</span>
1676
+ <span class="debug-metrics__key">Cost so far</span>
1677
+ <span class="debug-metrics__val debug-cost">${this._fmtCost(this._telemetry.conversationCostUsd)}</span>
1678
+ </div>
1679
+ </div>
1680
+ `:V`
1603
1681
  <div class="debug-empty">No telemetry yet — send a message to populate.</div>
1604
1682
  `}
1605
1683
 
1606
- ${this._iterationLog.length?X`
1607
- <div class="debug-section">
1608
- <div class="debug-section__label">Iterations (this turn)</div>
1609
- <div class="debug-iterations-scroll">
1610
- <table class="debug-iterations">
1611
- <thead>
1684
+ ${this._iterationLog.length?V`
1685
+ <div class="debug-section">
1686
+ <div class="debug-section__label">Iterations (this turn)</div>
1687
+ <div class="debug-iterations-scroll">
1688
+ <table class="debug-iterations">
1689
+ <thead>
1690
+ <tr>
1691
+ <th>#</th>
1692
+ <th>In</th>
1693
+ <th>Out</th>
1694
+ <th>Cache R</th>
1695
+ <th>Cache W</th>
1696
+ <th>Hit</th>
1697
+ <th>Cost</th>
1698
+ <th>Ckpt</th>
1699
+ </tr>
1700
+ </thead>
1701
+ <tbody>
1702
+ ${this._iterationLog.map((e=>{const t=this._cacheCheckpoints[e.iteration];return V`
1612
1703
  <tr>
1613
- <th>#</th>
1614
- <th>In</th>
1615
- <th>Out</th>
1616
- <th>Cache R</th>
1617
- <th>Cache W</th>
1618
- <th>Hit</th>
1619
- <th>Cost</th>
1620
- <th>Ckpt</th>
1704
+ <td>${e.iteration}</td>
1705
+ <td>${this._fmtTokens(e.iterationInput)}</td>
1706
+ <td>${this._fmtTokens(e.iterationOutput)}</td>
1707
+ <td>${this._fmtTokens(e.iterationCacheRead)}</td>
1708
+ <td>${this._fmtTokens(e.iterationCacheWrite)}</td>
1709
+ <td>${e.iterationHitRate??"—"}%</td>
1710
+ <td class="debug-cost">${this._fmtCost(e.iterationCostUsd)}</td>
1711
+ <td>${t?t.mode:"—"}</td>
1621
1712
  </tr>
1622
- </thead>
1623
- <tbody>
1624
- ${this._iterationLog.map((e=>{const t=this._cacheCheckpoints[e.iteration];return X`
1625
- <tr>
1626
- <td>${e.iteration}</td>
1627
- <td>${this._fmtTokens(e.iterationInput)}</td>
1628
- <td>${this._fmtTokens(e.iterationOutput)}</td>
1629
- <td>${this._fmtTokens(e.iterationCacheRead)}</td>
1630
- <td>${this._fmtTokens(e.iterationCacheWrite)}</td>
1631
- <td>${e.iterationHitRate??"—"}%</td>
1632
- <td class="debug-cost">${this._fmtCost(e.iterationCostUsd)}</td>
1633
- <td>${t?t.mode:"—"}</td>
1634
- </tr>
1635
1713
  `}))}
1636
- </tbody>
1637
- </table>
1638
- </div>
1639
- </div>
1640
- `:V}
1714
+ </tbody>
1715
+ </table>
1716
+ </div>
1641
1717
  </div>
1642
- </div>
1643
- `}render(){const e="inline"===this.variant&&!0===this._aiFrameworkConfig.debugTelemetryEnabled;return X`
1644
- ${this.hideToggle||"inline"===this.variant?V:X`
1718
+ `:Q}
1719
+ `}render(){const e="inline"===this.variant&&!0===this._aiFrameworkConfig.debugTelemetryEnabled,t={};this._drawerOpen&&(t.paddingRight=`${this._debugDrawerWidth}px`);const i=[];return this.messages.forEach((e=>{const t=i[i.length-1];"user"!==e.type&&t&&"user"!==t[0].type?t.push(e):i.push([e])})),V`
1720
+ ${this.hideToggle||"inline"===this.variant?Q:V`
1645
1721
  <button
1646
1722
  class=${$e({toggle:!0,"toggle--hidden":this.opened})}
1647
1723
  @click=${this._handleToggle}
@@ -1663,13 +1739,13 @@ const Fe="important",Ue=" !"+Fe,Le=_e(class extends ke{constructor(e){if(super(e
1663
1739
 
1664
1740
  <div
1665
1741
  class=${$e({panel:!0,"panel--opened":this.opened,"panel--resizing-debug":this._isDebugResizing})}
1666
- style=${Le(e&&this._debugPanelOpen?{paddingRight:`${this._debugDrawerWidth}px`}:{})}
1742
+ style=${Ue(t)}
1667
1743
  @dragenter=${this._handleDragEnter}
1668
1744
  @dragover=${this._handleDragOver}
1669
1745
  @dragleave=${this._handleDragLeave}
1670
1746
  @drop=${this._handleDrop}
1671
1747
  >
1672
- ${this._isDraggingFile?X`
1748
+ ${this._isDraggingFile?V`
1673
1749
  <div class="drop-overlay">
1674
1750
  <svg
1675
1751
  xmlns="http://www.w3.org/2000/svg"
@@ -1686,8 +1762,8 @@ const Fe="important",Ue=" !"+Fe,Le=_e(class extends ke{constructor(e){if(super(e
1686
1762
  </svg>
1687
1763
  <span>Drop images to attach</span>
1688
1764
  </div>
1689
- `:V}
1690
- ${"inline"===this.variant?V:X`
1765
+ `:Q}
1766
+ ${"inline"===this.variant?Q:V`
1691
1767
  <div
1692
1768
  class="resize resize--n"
1693
1769
  data-dir="n"
@@ -1736,10 +1812,35 @@ const Fe="important",Ue=" !"+Fe,Le=_e(class extends ke{constructor(e){if(super(e
1736
1812
  </div>
1737
1813
  </div>
1738
1814
  <div class="header-actions">
1739
- ${e?X`
1815
+ <button
1816
+ class="header-action"
1817
+ @click=${()=>this._toggleDrawer("settings")}
1818
+ title="Settings"
1819
+ >
1820
+ <svg
1821
+ xmlns="http://www.w3.org/2000/svg"
1822
+ fill="none"
1823
+ viewBox="0 0 24 24"
1824
+ stroke-width="1.5"
1825
+ stroke="currentColor"
1826
+ class="header-action-icon"
1827
+ >
1828
+ <path
1829
+ stroke-linecap="round"
1830
+ stroke-linejoin="round"
1831
+ d="M9.594 3.94c.09-.542.56-.94 1.11-.94h2.593c.55 0 1.02.398 1.11.94l.213 1.281c.063.374.313.686.645.87.074.04.147.083.22.127.324.196.72.257 1.075.124l1.217-.456a1.125 1.125 0 0 1 1.37.49l1.296 2.247a1.125 1.125 0 0 1-.26 1.431l-1.003.827c-.293.241-.438.613-.43.992a7.723 7.723 0 0 1 0 .255c-.008.378.137.75.43.991l1.004.827c.424.35.534.955.26 1.43l-1.298 2.247a1.125 1.125 0 0 1-1.369.491l-1.217-.456c-.355-.133-.75-.072-1.076.124a6.47 6.47 0 0 1-.22.128c-.331.183-.581.495-.644.869l-.213 1.281c-.09.543-.56.94-1.11.94h-2.594c-.55 0-1.019-.398-1.11-.94l-.213-1.281c-.062-.374-.312-.686-.644-.87a6.52 6.52 0 0 1-.22-.127c-.325-.196-.72-.257-1.076-.124l-1.217.456a1.125 1.125 0 0 1-1.369-.49l-1.297-2.247a1.125 1.125 0 0 1 .26-1.431l1.004-.827c.292-.24.437-.613.43-.991a6.932 6.932 0 0 1 0-.255c.007-.38-.138-.751-.43-.992l-1.004-.827a1.125 1.125 0 0 1-.26-1.43l1.297-2.247a1.125 1.125 0 0 1 1.37-.491l1.216.456c.356.133.751.072 1.076-.124.072-.044.146-.086.22-.128.332-.183.582-.495.644-.869l.214-1.28Z"
1832
+ />
1833
+ <path
1834
+ stroke-linecap="round"
1835
+ stroke-linejoin="round"
1836
+ d="M15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z"
1837
+ />
1838
+ </svg>
1839
+ </button>
1840
+ ${e?V`
1740
1841
  <button
1741
- class=${$e({"header-action":!0,"header-action--active":this._debugPanelOpen})}
1742
- @click=${this._handleToggleDebugPanel}
1842
+ class="header-action"
1843
+ @click=${()=>this._toggleDrawer("debug")}
1743
1844
  title="Debug telemetry"
1744
1845
  >
1745
1846
  <svg
@@ -1757,8 +1858,8 @@ const Fe="important",Ue=" !"+Fe,Le=_e(class extends ke{constructor(e){if(super(e
1757
1858
  />
1758
1859
  </svg>
1759
1860
  </button>
1760
- `:V}
1761
- ${"inline"===this.variant?V:X`
1861
+ `:Q}
1862
+ ${"inline"===this.variant?Q:V`
1762
1863
  <button
1763
1864
  class="header-action"
1764
1865
  @click=${this._handleToggle}
@@ -1785,128 +1886,174 @@ const Fe="important",Ue=" !"+Fe,Le=_e(class extends ke{constructor(e){if(super(e
1785
1886
 
1786
1887
  <div class="messages" @scroll=${this._handleMessagesScroll}>
1787
1888
  <div class="messages-inner">
1788
- ${0===this.messages.length?X`
1889
+ ${0===this.messages.length?V`
1789
1890
  <div class="empty">
1790
1891
  <span class="empty-text">What can I help you with?</span>
1791
1892
  </div>
1792
- `:V}
1793
- ${this.messages.map(((e,t)=>X`
1794
- <div class=${$e({message:!0,"message--user":"user"===e.type,"message--assistant":"assistant"===e.type})}>
1795
- ${e.reasoning?X`
1796
- <details class="reasoning">
1797
- <summary>Thinking</summary>
1798
- <div class="reasoning-content">${e.reasoning}</div>
1799
- </details>
1800
- `:V}
1801
- ${e.conversationFiles&&e.conversationFiles.length?X`
1802
- <div class="attachments">
1803
- ${e.conversationFiles.map((e=>{const t=e.niceName||e.name||"File";let i=ai.includes(this._getFileExtension(t));return e.mimeType&&(i=e.mimeType.startsWith("image/")),i?X`
1804
- <button
1805
- class="attachment"
1806
- type="button"
1807
- title=${e.niceName||"View image"}
1808
- @click=${()=>this._handleFileOpen(e)}
1893
+ `:Q}
1894
+ ${i.map((e=>{const t=e.map((e=>{const t=this.messages.indexOf(e);if(!("assistant"!==e.type||e.content||e.reasoning||this._isStreaming&&e===this.messages[this.messages.length-1]))return Q;if(("tool_use"===e.type||"tool_result"===e.type)&&!this._showTools)return Q;if("tool_result"===e.type)return Q;let i,s="",r="",o=0;if("tool_use"===e.type){const n=this.messages[t+1];if(n&&"tool_result"===n.type&&n.data?.toolUseId===e.data?.toolUseId&&(i=n.data),this._showToolInputs&&e.data?.toolInput&&(s=String(e.data.toolInput).replace(/\s+/g," ").trim(),s.length>80&&(s=`${s.slice(0,79)}…`)),this._showToolInputs&&i?.toolResultString){let e;try{e=JSON.stringify(JSON.parse(i.toolResultString),null,2)}catch{e=String(i.toolResultString)}const t=e.split("\n");r=t.slice(0,3).join("\n"),o=Math.max(0,t.length-3)}}let a="Approved",l=[];return"action_decision"===e.type&&("denied"===e.data?.outcome?a="Denied":"alwaysAllowed"===e.data?.outcome&&(a="Always allowed"),l=(e.data?.tools||[]).map((e=>e.displayName||e.toolName))),V`
1895
+ <div class=${$e({message:!0,"message--user":"user"===e.type,"message--assistant":"user"!==e.type})}>
1896
+ ${"tool_use"===e.type?V`
1897
+ <div class="tool-activity-block">
1898
+ <div class=${$e({"tool-activity":!0,"tool-activity--error":"error"===i?.toolResultStatus})}>
1899
+ <span class="tool-activity__chevron">›</span>
1900
+ <span class="tool-activity__label">${e.data?.displayName||e.data?.toolName||"Tool"}</span>
1901
+ ${s?V`<span class="tool-activity__input">(${s})</span>`:Q}
1902
+ </div>
1903
+ ${this._showToolInputs&&i?.toolResultString?V`
1904
+ <div class=${$e({"tool-activity__result":!0,"tool-activity__result--error":"error"===i.toolResultStatus})}>
1905
+ <span class="tool-activity__connector">⎿</span>
1906
+ <pre class="tool-activity__result-body">${r}${o>0?V`\n<span class="tool-activity__more">… +${o} lines</span>`:Q}</pre>
1907
+ </div>
1908
+ `:Q}
1909
+ </div>
1910
+ `:Q}
1911
+ ${"action_decision"===e.type?V`
1912
+ <div class=${$e({decision:!0,"decision--denied":"denied"===e.data?.outcome})}>
1913
+ <span class="decision__icon">
1914
+ <svg
1915
+ viewBox="0 0 24 24"
1916
+ fill="none"
1917
+ stroke="currentColor"
1918
+ stroke-width="2"
1919
+ stroke-linecap="round"
1920
+ stroke-linejoin="round"
1921
+ >
1922
+ ${"denied"===e.data?.outcome?V`<path d="M18 6 6 18M6 6l12 12" />`:V`<path d="M20 6 9 17l-5-5" />`}
1923
+ </svg>
1924
+ </span>
1925
+ <span class="decision__label">${a}${l.length?" "+l.join(", "):Q}</span>
1926
+ </div>
1927
+ `:Q}
1928
+ ${e.reasoning?this._reasoningAsMessage?V`
1929
+ <div class="message-content">${e.reasoning}</div>
1930
+ `:V`
1931
+ <details class="reasoning">
1932
+ <summary>Thinking</summary>
1933
+ <div class="reasoning-content">${e.reasoning}</div>
1934
+ </details>
1935
+ `:Q}
1936
+ ${e.conversationFiles&&e.conversationFiles.length?V`
1937
+ <div class="attachments">
1938
+ ${e.conversationFiles.map((e=>{const t=e.niceName||e.name||"File";let i=li.includes(this._getFileExtension(t));return e.mimeType&&(i=e.mimeType.startsWith("image/")),i?V`
1939
+ <button
1940
+ class="attachment"
1941
+ type="button"
1942
+ title=${e.niceName||"View image"}
1943
+ @click=${()=>this._handleFileOpen(e)}
1944
+ >
1945
+ <img
1946
+ src=${e.previewUrl||`${n.getBaseUrl()}/api/system/conversationFile/${e.conversationFileID}/view`}
1947
+ alt=${e.niceName||""}
1948
+ />
1949
+ </button>
1950
+ `:V`
1951
+ <button
1952
+ class="attachment attachment--doc attachment--openable"
1953
+ type="button"
1954
+ title=${t}
1955
+ @click=${()=>this._handleFileOpen(e)}
1956
+ >
1957
+ <span class="attachment__type">${this._getFileExtension(t)||"File"}</span>
1958
+ <span class="attachment__name">${t}</span>
1959
+ </button>
1960
+ `}))}
1961
+ </div>
1962
+ `:Q}
1963
+ ${e.content?V`
1964
+ <div class="message-content">
1965
+ ${"user"===e.type?this._renderUserContent(e.content):ye(ni.parse(e.content,{breaks:!0}))}
1966
+ </div>
1967
+ `:Q}
1968
+ ${"assistant"===e.type&&this._isStreaming&&e===this.messages[this.messages.length-1]?V`
1969
+ <div class="typing">
1970
+ <span></span>
1971
+ <span></span>
1972
+ <span></span>
1973
+ </div>
1974
+ `:Q}
1975
+ ${e.content?V`
1976
+ <button
1977
+ class="message-copy"
1978
+ title=${this._copiedIndex===t?"Copied":"Copy"}
1979
+ @click=${()=>this._handleCopyMessage(e.content,t)}
1980
+ >
1981
+ ${this._copiedIndex===t?V`
1982
+ <svg
1983
+ viewBox="0 0 24 24"
1984
+ fill="none"
1985
+ stroke="currentColor"
1986
+ stroke-width="1.5"
1987
+ stroke-linecap="round"
1988
+ stroke-linejoin="round"
1809
1989
  >
1810
- <img
1811
- src=${e.previewUrl||`${n.getBaseUrl()}/api/system/conversationFile/${e.conversationFileID}/view`}
1812
- alt=${e.niceName||""}
1990
+ <path d="M20 6 9 17l-5-5" />
1991
+ </svg>
1992
+ `:V`
1993
+ <svg
1994
+ viewBox="0 0 24 24"
1995
+ fill="none"
1996
+ stroke="currentColor"
1997
+ stroke-width="1.5"
1998
+ stroke-linecap="round"
1999
+ stroke-linejoin="round"
2000
+ >
2001
+ <rect
2002
+ x="9"
2003
+ y="9"
2004
+ width="13"
2005
+ height="13"
2006
+ rx="2"
1813
2007
  />
1814
- </button>
1815
- `:X`
1816
- <button
1817
- class="attachment attachment--doc attachment--openable"
1818
- type="button"
1819
- title=${t}
1820
- @click=${()=>this._handleFileOpen(e)}
1821
- >
1822
- <span class="attachment__type">${this._getFileExtension(t)||"File"}</span>
1823
- <span class="attachment__name">${t}</span>
1824
- </button>
1825
- `}))}
1826
- </div>
1827
- `:V}
1828
- ${e.content?X`
1829
- <div class="message-content">
1830
- ${"user"===e.type?this._renderUserContent(e.content):we(ni.parse(e.content,{breaks:!0}))}
1831
- </div>
1832
- `:V}
1833
- ${"assistant"===e.type&&this._isStreaming&&e===this.messages[this.messages.length-1]?X`
1834
- <div class="typing">
1835
- <span></span>
1836
- <span></span>
1837
- <span></span>
2008
+ <path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" />
2009
+ </svg>
2010
+ `}
2011
+ </button>
2012
+ `:Q}
1838
2013
  </div>
1839
- `:V}
1840
- ${e.content?X`
1841
- <button
1842
- class="message-copy"
1843
- title=${this._copiedIndex===t?"Copied":"Copy"}
1844
- @click=${()=>this._handleCopyMessage(e.content,t)}
1845
- >
1846
- ${this._copiedIndex===t?X`
1847
- <svg
1848
- viewBox="0 0 24 24"
1849
- fill="none"
1850
- stroke="currentColor"
1851
- stroke-width="1.5"
1852
- stroke-linecap="round"
1853
- stroke-linejoin="round"
1854
- >
1855
- <path d="M20 6 9 17l-5-5" />
1856
- </svg>
1857
- `:X`
1858
- <svg
1859
- viewBox="0 0 24 24"
1860
- fill="none"
1861
- stroke="currentColor"
1862
- stroke-width="1.5"
1863
- stroke-linecap="round"
1864
- stroke-linejoin="round"
1865
- >
1866
- <rect
1867
- x="9"
1868
- y="9"
1869
- width="13"
1870
- height="13"
1871
- rx="2"
1872
- />
1873
- <path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" />
1874
- </svg>
1875
- `}
1876
- </button>
1877
- `:V}
2014
+ `}));if("user"===e[0].type)return t;const s=e===i[i.length-1],r=s&&this._pendingActions.length&&this._inlineConfirm,o=this.messages[this.messages.length-1],a=s&&this._isStreaming&&!this._pendingActions.length&&"assistant"!==o?.type;return V`
2015
+ <div class="agent-turn">
2016
+ ${t}
2017
+ ${a?V`
2018
+ <div class="typing">
2019
+ <span></span>
2020
+ <span></span>
2021
+ <span></span>
2022
+ </div>
2023
+ `:Q}
2024
+ ${r?this._renderConfirmation():Q}
2025
+ </div>
2026
+ `}))}
2027
+ </div>
1878
2028
  </div>
1879
- `))}
1880
- </div>
1881
- </div>
1882
2029
 
1883
- ${this._pendingActions.length?this._renderConfirmation():V}
2030
+ ${this._pendingActions.length&&!this._inlineConfirm?this._renderConfirmation():Q}
1884
2031
 
1885
- ${this._error?X`
1886
- <div class="error">
1887
- <span>${this._error}</span>
1888
- <button class="error-dismiss" @click=${this._handleErrorDismiss}>
1889
- <svg
1890
- xmlns="http://www.w3.org/2000/svg"
1891
- fill="none"
1892
- viewBox="0 0 24 24"
1893
- stroke-width="2"
1894
- stroke="currentColor"
1895
- class="error-dismiss-icon"
1896
- >
1897
- <path
1898
- stroke-linecap="round"
1899
- stroke-linejoin="round"
1900
- d="M6 18 18 6M6 6l12 12"
1901
- />
1902
- </svg>
1903
- </button>
1904
- </div>
1905
- `:this._contextLimitReached?X`
2032
+ ${this._error?V`
2033
+ <div class="error">
2034
+ <span>${this._error}</span>
2035
+ <button class="error-dismiss" @click=${this._handleErrorDismiss}>
2036
+ <svg
2037
+ xmlns="http://www.w3.org/2000/svg"
2038
+ fill="none"
2039
+ viewBox="0 0 24 24"
2040
+ stroke-width="2"
2041
+ stroke="currentColor"
2042
+ class="error-dismiss-icon"
2043
+ >
2044
+ <path
2045
+ stroke-linecap="round"
2046
+ stroke-linejoin="round"
2047
+ d="M6 18 18 6M6 6l12 12"
2048
+ />
2049
+ </svg>
2050
+ </button>
2051
+ </div>
2052
+ `:this._contextLimitReached?V`
1906
2053
  <div class="context-limit" role="alert">
1907
2054
  ${this._contextLimitMessage||"This conversation has reached its limit. Please start a new one to continue."}
1908
2055
  </div>
1909
- `:this._contextWarning?X`
2056
+ `:this._contextWarning?V`
1910
2057
  <div class="context-warning" role="status">
1911
2058
  <span>${this._contextWarning}</span>
1912
2059
  <button
@@ -1930,62 +2077,62 @@ const Fe="important",Ue=" !"+Fe,Le=_e(class extends ke{constructor(e){if(super(e
1930
2077
  </svg>
1931
2078
  </button>
1932
2079
  </div>
1933
- `:V}
1934
-
1935
- <div class="footer">
1936
- ${this._pendingConversationFiles.length?X`
1937
- <div class="composer-attachments">
1938
- ${Ye(this._pendingConversationFiles,(e=>e.localId),(e=>X`
1939
- <div
1940
- class=${$e({chip:!0,"chip--doc":!e.previewUrl})}
1941
- title=${e.name}
1942
- >
1943
- <div
1944
- class=${$e({"chip-body":!0,"chip-body--image":Boolean(e.previewUrl)})}
1945
- >
1946
- ${e.previewUrl?X`<img src=${e.previewUrl} alt=${e.name} />`:X`
1947
- <span class="chip-type">${this._getFileExtension(e.name)||"File"}</span>
1948
- <span class="chip-name">${e.name}</span>
1949
- `}
1950
- </div>
1951
- <button
1952
- class="chip-remove"
1953
- title="Remove"
1954
- @click=${()=>this._handlePendingRemove(e.localId)}
1955
- >
1956
- <svg
1957
- xmlns="http://www.w3.org/2000/svg"
1958
- fill="none"
1959
- viewBox="0 0 24 24"
1960
- stroke-width="1.75"
1961
- stroke="currentColor"
2080
+ `:Q}
2081
+
2082
+ <div class="footer">
2083
+ ${this._pendingConversationFiles.length?V`
2084
+ <div class="composer-attachments">
2085
+ ${Ye(this._pendingConversationFiles,(e=>e.localId),(e=>V`
2086
+ <div
2087
+ class=${$e({chip:!0,"chip--doc":!e.previewUrl})}
2088
+ title=${e.name}
1962
2089
  >
1963
- <path
1964
- stroke-linecap="round"
1965
- stroke-linejoin="round"
1966
- d="M6 18 18 6M6 6l12 12"
1967
- />
1968
- </svg>
1969
- </button>
1970
- </div>
2090
+ <div
2091
+ class=${$e({"chip-body":!0,"chip-body--image":Boolean(e.previewUrl)})}
2092
+ >
2093
+ ${e.previewUrl?V`<img src=${e.previewUrl} alt=${e.name} />`:V`
2094
+ <span class="chip-type">${this._getFileExtension(e.name)||"File"}</span>
2095
+ <span class="chip-name">${e.name}</span>
2096
+ `}
2097
+ </div>
2098
+ <button
2099
+ class="chip-remove"
2100
+ title="Remove"
2101
+ @click=${()=>this._handlePendingRemove(e.localId)}
2102
+ >
2103
+ <svg
2104
+ xmlns="http://www.w3.org/2000/svg"
2105
+ fill="none"
2106
+ viewBox="0 0 24 24"
2107
+ stroke-width="1.75"
2108
+ stroke="currentColor"
2109
+ >
2110
+ <path
2111
+ stroke-linecap="round"
2112
+ stroke-linejoin="round"
2113
+ d="M6 18 18 6M6 6l12 12"
2114
+ />
2115
+ </svg>
2116
+ </button>
2117
+ </div>
1971
2118
  `))}
1972
- </div>
1973
- `:V}
1974
- <input
1975
- class="file-input"
1976
- type="file"
1977
- accept=${li.map((e=>"."+e)).join(",")}
1978
- multiple
1979
- hidden
1980
- @change=${this._handleFileInputChange}
1981
- />
1982
- ${this._skillMenuOpened?this._renderSkillMenu():V}
1983
- <div class="input-wrapper">
1984
- <button
2119
+ </div>
2120
+ `:Q}
2121
+ <input
2122
+ class="file-input"
2123
+ type="file"
2124
+ accept=${hi.map((e=>"."+e)).join(",")}
2125
+ multiple
2126
+ hidden
2127
+ @change=${this._handleFileInputChange}
2128
+ />
2129
+ ${this._skillMenuOpened?this._renderSkillMenu():Q}
2130
+ <div class="input-wrapper">
2131
+ <button
1985
2132
  class="input-plus"
1986
2133
  @click=${this._handlePlusClick}
1987
- >+</button>
1988
- <textarea
2134
+ >+</button>
2135
+ <textarea
1989
2136
  class="input"
1990
2137
  .value=${this._inputValue}
1991
2138
  placeholder=${this.placeholder}
@@ -1993,32 +2140,33 @@ const Fe="important",Ue=" !"+Fe,Le=_e(class extends ke{constructor(e){if(super(e
1993
2140
  @input=${this._handleInputChange}
1994
2141
  @keydown=${this._handleKeyDown}
1995
2142
  @paste=${this._handlePaste}
1996
- ></textarea>
1997
- ${window.SpeechRecognition||window.webkitSpeechRecognition?X`
1998
- ${this._isDictating?X`
1999
- <button
2000
- class="mic-stop"
2001
- title="Stop dictation"
2002
- aria-label="Stop dictation"
2003
- @click=${this._handleMicClick}
2004
- >
2005
- <svg
2006
- xmlns="http://www.w3.org/2000/svg"
2007
- fill="currentColor"
2008
- viewBox="0 0 24 24"
2009
- class="mic-stop-icon"
2010
- aria-hidden="true"
2143
+ ></textarea>
2144
+ ${this._renderModeSelector()}
2145
+ ${window.SpeechRecognition||window.webkitSpeechRecognition?V`
2146
+ ${this._isDictating?V`
2147
+ <button
2148
+ class="mic-stop"
2149
+ title="Stop dictation"
2150
+ aria-label="Stop dictation"
2151
+ @click=${this._handleMicClick}
2011
2152
  >
2012
- <rect
2013
- x="6"
2014
- y="6"
2015
- width="12"
2016
- height="12"
2017
- rx="2"
2018
- />
2019
- </svg>
2020
- </button>
2021
- `:X`
2153
+ <svg
2154
+ xmlns="http://www.w3.org/2000/svg"
2155
+ fill="currentColor"
2156
+ viewBox="0 0 24 24"
2157
+ class="mic-stop-icon"
2158
+ aria-hidden="true"
2159
+ >
2160
+ <rect
2161
+ x="6"
2162
+ y="6"
2163
+ width="12"
2164
+ height="12"
2165
+ rx="2"
2166
+ />
2167
+ </svg>
2168
+ </button>
2169
+ `:V`
2022
2170
  <button
2023
2171
  class="mic"
2024
2172
  title="Dictate a message"
@@ -2042,29 +2190,29 @@ const Fe="important",Ue=" !"+Fe,Le=_e(class extends ke{constructor(e){if(super(e
2042
2190
  </svg>
2043
2191
  </button>
2044
2192
  `}
2045
- `:V}
2046
- ${this._isStreaming?X`
2047
- <button
2048
- class="stop"
2049
- @click=${this._handleStop}
2050
- title="Stop generating"
2051
- >
2052
- <svg
2053
- xmlns="http://www.w3.org/2000/svg"
2054
- fill="currentColor"
2055
- viewBox="0 0 24 24"
2056
- class="stop-icon"
2193
+ `:Q}
2194
+ ${this._isStreaming?V`
2195
+ <button
2196
+ class="stop"
2197
+ @click=${this._handleStop}
2198
+ title="Stop generating"
2057
2199
  >
2058
- <rect
2059
- x="6"
2060
- y="6"
2061
- width="12"
2062
- height="12"
2063
- rx="2"
2064
- />
2065
- </svg>
2066
- </button>
2067
- `:X`
2200
+ <svg
2201
+ xmlns="http://www.w3.org/2000/svg"
2202
+ fill="currentColor"
2203
+ viewBox="0 0 24 24"
2204
+ class="stop-icon"
2205
+ >
2206
+ <rect
2207
+ x="6"
2208
+ y="6"
2209
+ width="12"
2210
+ height="12"
2211
+ rx="2"
2212
+ />
2213
+ </svg>
2214
+ </button>
2215
+ `:V`
2068
2216
  <button
2069
2217
  class=${$e({send:!0,"send--disabled":!this._inputValue.trim()&&!this._pendingConversationFiles.length||this._pendingActions.length>0})}
2070
2218
  @click=${this._handleSubmit}
@@ -2084,12 +2232,12 @@ const Fe="important",Ue=" !"+Fe,Le=_e(class extends ke{constructor(e){if(super(e
2084
2232
  </svg>
2085
2233
  </button>
2086
2234
  `}
2087
- </div>
2088
- </div>
2089
- ${this._skillBrowseOpened?this._renderSkillBrowse():V}
2090
- ${e?this._renderDebugPanel():V}
2091
- </div>
2092
- `}};hi.styles=c`
2235
+ </div>
2236
+ </div>
2237
+ ${this._skillBrowseOpened?this._renderSkillBrowse():Q}
2238
+ ${this._renderDrawer()}
2239
+ </div>
2240
+ `}};ci.styles=c`
2093
2241
  *,
2094
2242
  *::before,
2095
2243
  *::after {
@@ -2199,6 +2347,14 @@ const Fe="important",Ue=" !"+Fe,Le=_e(class extends ke{constructor(e){if(super(e
2199
2347
  box-shadow: none;
2200
2348
  border: none;
2201
2349
  animation: none;
2350
+ /* Reserve space for the drawer by animating padding-right in sync with the
2351
+ drawer's slide, so the chat column shrinks rather than being overlaid. */
2352
+ transition: padding-right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
2353
+ }
2354
+
2355
+ /* Track the cursor 1:1 while dragging the drawer's resize handle. */
2356
+ :host([variant='inline']) .panel--resizing-debug {
2357
+ transition: none;
2202
2358
  }
2203
2359
 
2204
2360
  @keyframes chatbot-panel-in {
@@ -2266,16 +2422,31 @@ const Fe="important",Ue=" !"+Fe,Le=_e(class extends ke{constructor(e){if(super(e
2266
2422
  color: #000000;
2267
2423
  }
2268
2424
 
2269
- .header-action--active {
2270
- background: rgba(0, 0, 0, 0.08);
2271
- color: #000000;
2272
- }
2273
-
2274
2425
  .header-action-icon {
2275
2426
  width: 20px;
2276
2427
  height: 20px;
2277
2428
  }
2278
2429
 
2430
+ .settings-section {
2431
+ padding: 14px 20px;
2432
+ border-bottom: 1px solid rgba(0, 0, 0, 0.06);
2433
+ }
2434
+
2435
+ .settings-section:last-child {
2436
+ border-bottom: none;
2437
+ }
2438
+
2439
+ .settings-section__title {
2440
+ font-size: 14px;
2441
+ font-weight: 600;
2442
+ color: #000000;
2443
+ margin-bottom: 12px;
2444
+ }
2445
+
2446
+ .settings-row {
2447
+ padding: 6px 0;
2448
+ }
2449
+
2279
2450
  /* Messages */
2280
2451
  /* Full-width scroll container — keeps the scrollbar at the panel edge. */
2281
2452
  .messages {
@@ -2356,6 +2527,138 @@ const Fe="important",Ue=" !"+Fe,Le=_e(class extends ke{constructor(e){if(super(e
2356
2527
  gap: 24px;
2357
2528
  }
2358
2529
 
2530
+ /* An agent turn wraps all of its messages (reasoning, tool lines, text,
2531
+ decision) so the scroll-to-top runway can sit on the whole turn and content
2532
+ streams inside it instead of stacking as siblings below the runway. A flex
2533
+ column with the same 36px gap as .messages-inner, so item spacing is
2534
+ unchanged whether grouped or not. Full width so its children align exactly
2535
+ as before (assistant left, tool/decision left). */
2536
+ .agent-turn {
2537
+ display: flex;
2538
+ flex-direction: column;
2539
+ gap: 36px;
2540
+ width: 100%;
2541
+ }
2542
+
2543
+ /* Tool-activity line — "the assistant ran X" row in the transcript. Same text
2544
+ style as any other message (black, 14px); a leading › chevron marks it as a
2545
+ step (in the same text style, not an icon). */
2546
+ .tool-activity {
2547
+ align-self: flex-start;
2548
+ display: flex;
2549
+ align-items: baseline;
2550
+ gap: 6px;
2551
+ font-size: 14px;
2552
+ color: #000000;
2553
+ /* Keep the chevron + name + input on a single line; input truncates if long. */
2554
+ white-space: nowrap;
2555
+ }
2556
+
2557
+ .tool-activity--error {
2558
+ color: var(--kr-chatbot-error-text);
2559
+ }
2560
+
2561
+ /* Leading chevron — plain text in the same style as the name, so it reads as
2562
+ one label rather than an icon. */
2563
+ .tool-activity__chevron {
2564
+ flex-shrink: 0;
2565
+ }
2566
+
2567
+ /* The tool name never shrinks — it's the input that truncates if the header
2568
+ runs out of room. */
2569
+ .tool-activity__label {
2570
+ flex-shrink: 0;
2571
+ }
2572
+
2573
+ /* The tool input rendered inline in the header, Claude-CLI style:
2574
+ "Read(chatbot.ts)". Same color/font as the tool name — it reads as one
2575
+ label. Truncates with an ellipsis so the header stays on one line. */
2576
+ .tool-activity__input {
2577
+ overflow: hidden;
2578
+ text-overflow: ellipsis;
2579
+ min-width: 0;
2580
+ }
2581
+
2582
+ /* Header + result grouped as one unit so the parent .message--assistant 24px
2583
+ gap doesn't push them apart. Rows sit tight together inside. */
2584
+ .tool-activity-block {
2585
+ display: flex;
2586
+ flex-direction: column;
2587
+ gap: 4px;
2588
+ }
2589
+
2590
+ /* The result block indented under the activity line with a ⎿ tree connector,
2591
+ like Claude CLI's tool output preview. Uses the normal message text style
2592
+ (14px, black) — only the ⎿ connector is muted. */
2593
+ .tool-activity__result {
2594
+ align-self: flex-start;
2595
+ display: flex;
2596
+ gap: 2px;
2597
+ /* Align the ⎿ connector's visible stroke under the first character of the
2598
+ tool name. The name is preceded by the "› " chevron (chevron width + 6px
2599
+ gap ≈ 11px), and the ⎿ glyph carries ~5.6px more internal left bearing
2600
+ than the name's first letter — so net-shift the block right to land the
2601
+ stroke under the name. */
2602
+ margin-left: 6px;
2603
+ font-size: 14px;
2604
+ color: #000000;
2605
+ }
2606
+
2607
+ .tool-activity__result--error {
2608
+ color: var(--kr-chatbot-error-text);
2609
+ }
2610
+
2611
+ .tool-activity__connector {
2612
+ flex-shrink: 0;
2613
+ color: rgba(0, 0, 0, 0.55);
2614
+ user-select: none;
2615
+ /* The ⎿ arm sits near the baseline, ~6px below the result's first-character
2616
+ vertical center. Nudge the glyph up so the arm tip lines up with that center. */
2617
+ transform: translateY(-6px);
2618
+ }
2619
+
2620
+ .tool-activity__result-body {
2621
+ /* Small horizontal gap between the ⎿ arm and the result text so they don't
2622
+ collide (the ⎿ glyph's own arm already extends most of the way). */
2623
+ margin: 0 0 0 6px;
2624
+ white-space: pre-wrap;
2625
+ word-break: break-word;
2626
+ font: inherit;
2627
+ }
2628
+
2629
+ .tool-activity__more {
2630
+ color: rgba(0, 0, 0, 0.4);
2631
+ }
2632
+
2633
+ /* Decision line — the persistent record of an approve/deny (Rail 3). Uses the
2634
+ normal message text style (14px, black); a check/deny icon marks it. */
2635
+ .decision {
2636
+ align-self: flex-start;
2637
+ display: flex;
2638
+ align-items: center;
2639
+ gap: 8px;
2640
+ font-size: 14px;
2641
+ color: #000000;
2642
+ }
2643
+
2644
+ .decision--denied {
2645
+ color: var(--kr-chatbot-error-text);
2646
+ }
2647
+
2648
+ .decision__icon {
2649
+ display: inline-flex;
2650
+ align-items: center;
2651
+ justify-content: center;
2652
+ width: 16px;
2653
+ height: 16px;
2654
+ flex-shrink: 0;
2655
+ }
2656
+
2657
+ .decision__icon svg {
2658
+ width: 15px;
2659
+ height: 15px;
2660
+ }
2661
+
2359
2662
  /* anywhere, NOT break-word: both break a long unbreakable run (a pasted URL) for
2360
2663
  layout, but only anywhere also shrinks the element's intrinsic min-content width.
2361
2664
  With break-word the URL still reports its full unbroken width as the minimum,
@@ -2637,11 +2940,49 @@ const Fe="important",Ue=" !"+Fe,Le=_e(class extends ke{constructor(e){if(super(e
2637
2940
  overflow-y: auto;
2638
2941
  }
2639
2942
 
2943
+ /* Inline variant (Claude-CLI style): sits IN the message stream as just
2944
+ another assistant message — no card chrome (padding/background/border/
2945
+ radius/shadow), no float offsets, no height cap. It flows and scrolls with
2946
+ the transcript. */
2947
+ .confirmation--inline {
2948
+ position: static;
2949
+ left: auto;
2950
+ right: auto;
2951
+ bottom: auto;
2952
+ z-index: auto;
2953
+ max-width: none;
2954
+ margin: 0;
2955
+ max-height: none;
2956
+ overflow: visible;
2957
+ padding: 0;
2958
+ border: none;
2959
+ border-radius: 0;
2960
+ background: none;
2961
+ box-shadow: none;
2962
+ /* scrollIntoView({ block: 'end' }) aligns the card's bottom to the viewport
2963
+ bottom; this margin makes it stop short so the Yes/No buttons aren't flush
2964
+ against (or clipped by) the fold. */
2965
+ scroll-margin-bottom: 24px;
2966
+ }
2967
+
2968
+ /* The raw arguments, pretty-printed. Wraps rather than scrolling — the whole
2969
+ card grows with the transcript (the point of the inline variant). */
2970
+ .confirmation__details-input {
2971
+ margin: 8px 0 0;
2972
+ border-radius: 6px;
2973
+ color: var(--kr-chatbot-text);
2974
+ font-family: 'SF Mono', SFMono-Regular, ui-monospace, Menlo, Consolas, monospace;
2975
+ font-size: 13px;
2976
+ line-height: 1.5;
2977
+ white-space: pre-wrap;
2978
+ overflow-wrap: anywhere;
2979
+ }
2980
+
2640
2981
  /* "Run {tool}?" heading — names the tool being run. */
2641
2982
  .confirmation__title {
2642
2983
  font-size: 16px;
2643
2984
  font-weight: 600;
2644
- margin-bottom: 8px;
2985
+ margin-bottom: 12px;
2645
2986
  }
2646
2987
 
2647
2988
  .confirmation__message {
@@ -2650,8 +2991,26 @@ const Fe="important",Ue=" !"+Fe,Le=_e(class extends ke{constructor(e){if(super(e
2650
2991
  line-height: 1.5;
2651
2992
  }
2652
2993
 
2653
- .confirmation__message + .confirmation__message {
2654
- margin-top: 6px;
2994
+ /* Batch list: one bullet per pending tool — its name, then the model's
2995
+ plain-language intent under it. */
2996
+ .confirmation__list {
2997
+ margin: 0;
2998
+ padding-left: 20px;
2999
+ font-size: 14px;
3000
+ line-height: 1.5;
3001
+ }
3002
+
3003
+ .confirmation__list-item:not(:last-child) {
3004
+ margin-bottom: 8px;
3005
+ }
3006
+
3007
+ .confirmation__list-name {
3008
+ display: block;
3009
+ font-weight: 600;
3010
+ }
3011
+
3012
+ .confirmation__list-desc {
3013
+ display: block;
2655
3014
  }
2656
3015
 
2657
3016
  /* Buttons in a row; wrap on a narrow panel rather than overflowing the card. */
@@ -2659,45 +3018,34 @@ const Fe="important",Ue=" !"+Fe,Le=_e(class extends ke{constructor(e){if(super(e
2659
3018
  display: flex;
2660
3019
  flex-wrap: wrap;
2661
3020
  align-items: center;
2662
- gap: 8px;
2663
- margin-top: 16px;
3021
+ gap: 10px;
3022
+ margin-top: 20px;
2664
3023
  }
2665
3024
 
2666
- /* Keyboard-highlighted decision — a focus ring around the button host, drawn
3025
+ /* Keyboard-highlighted decision — a focus ring around the button, drawn
2667
3026
  outside its border so it reads over both the flat (Yes) and outline
2668
- variants without recoloring the button itself. */
3027
+ variants without recoloring or reshaping the button. Don't set
3028
+ border-radius here: that's the button's own (its pill shape); outline
3029
+ follows it and doesn't affect the button's size. */
2669
3030
  .confirmation__btn--highlighted {
2670
- border-radius: 8px;
2671
3031
  outline: 2px solid var(--kr-chatbot-primary);
2672
3032
  outline-offset: 2px;
2673
3033
  }
2674
3034
 
2675
3035
  /*
2676
- * INTERNAL-ONLY debug telemetry drawer. A layout drawer docked to the right
2677
- * of the inline chat — the chat column shrinks to make room; it does not
2678
- * overlay. Closed by default (width 0), animates open. Not customer-facing —
2679
- * token counts, cache internals, and approximate cost estimates for internal
2680
- * debugging. Styled to match the chatbot's light theme (Inter, design tokens).
3036
+ * Side drawer, docked to the right of the inline chat, holding the Settings
3037
+ * and Debug views. The chat column shrinks (padding-right) to make room; the
3038
+ * drawer does not overlay. It stays mounted and slides in/out via a transform,
3039
+ * so opening and closing animate; switching views just swaps the content
3040
+ * inside (no re-slide, no width change). One consistent resizable width across
3041
+ * both views; the width is set inline from _debugDrawerWidth.
2681
3042
  */
2682
- /*
2683
- * The chat column reserves space for the drawer by animating padding-right,
2684
- * so opening the drawer shrinks the chat (header/messages/composer) rather
2685
- * than overlaying it. Only applies in inline mode.
2686
- */
2687
- :host([variant='inline']) .panel {
2688
- transition: padding-right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
2689
- }
2690
-
2691
- /* Track the cursor 1:1 while dragging the drawer's resize handle. */
2692
- :host([variant='inline']) .panel--resizing-debug {
2693
- transition: none;
2694
- }
2695
-
2696
- .debug-drawer {
3043
+ .drawer {
2697
3044
  position: absolute;
2698
3045
  top: 0;
2699
3046
  right: 0;
2700
3047
  bottom: 0;
3048
+ max-width: 100%;
2701
3049
  background: var(--kr-chatbot-bg);
2702
3050
  display: flex;
2703
3051
  flex-direction: column;
@@ -2709,17 +3057,17 @@ const Fe="important",Ue=" !"+Fe,Le=_e(class extends ke{constructor(e){if(super(e
2709
3057
 
2710
3058
  /* While dragging the resize handle, suppress the slide transition so the
2711
3059
  drawer tracks the cursor 1:1. */
2712
- .debug-drawer--resizing {
3060
+ .drawer--resizing {
2713
3061
  transition: none;
2714
3062
  }
2715
3063
 
2716
- .debug-drawer--open {
3064
+ .drawer--open {
2717
3065
  transform: translateX(0);
2718
3066
  box-shadow: -4px 0 20px rgba(10, 26, 46, 0.07);
2719
3067
  }
2720
3068
 
2721
3069
  /* Left-edge grab handle for resizing the drawer. */
2722
- .debug-drawer__resize {
3070
+ .drawer__resize {
2723
3071
  position: absolute;
2724
3072
  top: 0;
2725
3073
  left: 0;
@@ -2729,7 +3077,7 @@ const Fe="important",Ue=" !"+Fe,Le=_e(class extends ke{constructor(e){if(super(e
2729
3077
  z-index: 10;
2730
3078
  }
2731
3079
 
2732
- .debug-drawer__header {
3080
+ .drawer__header {
2733
3081
  display: flex;
2734
3082
  align-items: center;
2735
3083
  justify-content: space-between;
@@ -2739,13 +3087,13 @@ const Fe="important",Ue=" !"+Fe,Le=_e(class extends ke{constructor(e){if(super(e
2739
3087
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
2740
3088
  }
2741
3089
 
2742
- .debug-drawer__title {
3090
+ .drawer__title {
2743
3091
  font-size: 14px;
2744
3092
  font-weight: 600;
2745
3093
  color: #000000;
2746
3094
  }
2747
3095
 
2748
- .debug-drawer__body {
3096
+ .drawer__body {
2749
3097
  flex: 1;
2750
3098
  overflow-y: auto;
2751
3099
  overflow-x: hidden;
@@ -2954,6 +3302,89 @@ const Fe="important",Ue=" !"+Fe,Le=_e(class extends ke{constructor(e){if(super(e
2954
3302
  margin-right: 4px;
2955
3303
  }
2956
3304
 
3305
+ /* Mode selector — Gemini-style inline label + caret before the mic. Anchors
3306
+ its upward menu; sized so it never grows the single-row composer height. */
3307
+ .mode {
3308
+ position: relative;
3309
+ flex-shrink: 0;
3310
+ display: flex;
3311
+ align-items: center;
3312
+ }
3313
+
3314
+ .mode-trigger {
3315
+ display: inline-flex;
3316
+ align-items: center;
3317
+ gap: 2px;
3318
+ height: 34px;
3319
+ padding: 0 8px;
3320
+ border: none;
3321
+ background: transparent;
3322
+ color: var(--kr-chatbot-text);
3323
+ border-radius: 17px;
3324
+ cursor: pointer;
3325
+ font: inherit;
3326
+ font-size: 14px;
3327
+ white-space: nowrap;
3328
+ transition: background 0.15s;
3329
+ }
3330
+
3331
+ .mode-trigger:hover {
3332
+ background: #f8f9fc;
3333
+ }
3334
+
3335
+ .mode-trigger__caret {
3336
+ width: 16px;
3337
+ height: 16px;
3338
+ flex-shrink: 0;
3339
+ }
3340
+
3341
+ /* Menu opens upward, anchored to the trigger's right edge. */
3342
+ .mode-menu {
3343
+ position: absolute;
3344
+ bottom: calc(100% + 8px);
3345
+ right: 0;
3346
+ min-width: 220px;
3347
+ background: white;
3348
+ border: 1px solid #b0b0b0;
3349
+ border-radius: 8px;
3350
+ box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
3351
+ padding: 6px 0;
3352
+ z-index: 10000;
3353
+ display: flex;
3354
+ flex-direction: column;
3355
+ }
3356
+
3357
+ .mode-menu__item {
3358
+ display: flex;
3359
+ flex-direction: column;
3360
+ gap: 1px;
3361
+ width: 100%;
3362
+ padding: 8px 14px;
3363
+ background: none;
3364
+ border: none;
3365
+ text-align: left;
3366
+ cursor: pointer;
3367
+ font: inherit;
3368
+ color: var(--kr-chatbot-text);
3369
+ }
3370
+
3371
+ .mode-menu__item:hover {
3372
+ background: #f3f4f6;
3373
+ }
3374
+
3375
+ .mode-menu__item--active {
3376
+ background: #eef1f6;
3377
+ }
3378
+
3379
+ .mode-menu__label {
3380
+ font-size: 14px;
3381
+ font-weight: 500;
3382
+ }
3383
+
3384
+ .mode-menu__desc {
3385
+ font-size: 12px;
3386
+ }
3387
+
2957
3388
  .mic {
2958
3389
  width: 34px;
2959
3390
  height: 34px;
@@ -3552,5 +3983,5 @@ const Fe="important",Ue=" !"+Fe,Le=_e(class extends ke{constructor(e){if(super(e
3552
3983
  height: 32px;
3553
3984
  }
3554
3985
 
3555
- `,ri([me({attribute:!1})],hi.prototype,"send",void 0),ri([me({attribute:!1})],hi.prototype,"load",void 0),ri([me({attribute:!1})],hi.prototype,"messages",void 0),ri([me({type:String})],hi.prototype,"label",void 0),ri([me({type:String})],hi.prototype,"placeholder",void 0),ri([me({type:Boolean,reflect:!0})],hi.prototype,"opened",void 0),ri([me({type:Boolean,attribute:"hide-toggle",reflect:!0})],hi.prototype,"hideToggle",void 0),ri([me({type:String,reflect:!0})],hi.prototype,"variant",void 0),ri([me({type:Number,attribute:"conversation-id",reflect:!0})],hi.prototype,"conversationId",void 0),ri([fe()],hi.prototype,"_inputValue",void 0),ri([fe()],hi.prototype,"_isStreaming",void 0),ri([fe()],hi.prototype,"_error",void 0),ri([fe()],hi.prototype,"_contextWarning",void 0),ri([fe()],hi.prototype,"_contextLimitReached",void 0),ri([fe()],hi.prototype,"_contextLimitMessage",void 0),ri([fe()],hi.prototype,"_pendingActions",void 0),ri([fe()],hi.prototype,"_confirmationHighlighted",void 0),ri([fe()],hi.prototype,"_confirmationInFlight",void 0),ri([fe()],hi.prototype,"_telemetry",void 0),ri([fe()],hi.prototype,"_iterationLog",void 0),ri([fe()],hi.prototype,"_cacheCheckpoints",void 0),ri([fe()],hi.prototype,"_debugPanelOpen",void 0),ri([fe()],hi.prototype,"_debugDrawerWidth",void 0),ri([fe()],hi.prototype,"_isDebugResizing",void 0),ri([fe()],hi.prototype,"_pendingConversationFiles",void 0),ri([fe()],hi.prototype,"_isDraggingFile",void 0),ri([fe()],hi.prototype,"_skillMenuOpened",void 0),ri([fe()],hi.prototype,"_skillQuery",void 0),ri([fe()],hi.prototype,"_orgSkills",void 0),ri([fe()],hi.prototype,"_globalSkills",void 0),ri([fe()],hi.prototype,"_invocableSkills",void 0),ri([fe()],hi.prototype,"_aiFrameworkConfig",void 0),ri([fe()],hi.prototype,"_skillHighlighted",void 0),ri([fe()],hi.prototype,"_copiedIndex",void 0),ri([fe()],hi.prototype,"_skillBrowseOpened",void 0),ri([fe()],hi.prototype,"_skillBrowseSource",void 0),ri([fe()],hi.prototype,"_skillBrowseQuery",void 0),ri([fe()],hi.prototype,"_isDictating",void 0),ri([be(".panel")],hi.prototype,"_panelEl",void 0),ri([be(".messages")],hi.prototype,"_messagesEl",void 0),ri([be(".input")],hi.prototype,"_inputEl",void 0),ri([be(".file-input")],hi.prototype,"_fileInputEl",void 0),ri([be(".input-wrapper")],hi.prototype,"_inputWrapperEl",void 0),ri([be(".skill-menu")],hi.prototype,"_skillMenuEl",void 0),hi=ri([pe("kr-chatbot")],hi);export{hi as KRChatbot,Pe as KRRouter,Oe as KRRouterOutlet,Ce as KRScaffold,De as KRScreenDetail,Ae as KRScreenNav,Me as KRSubbar};
3986
+ `,ri([me({attribute:!1})],ci.prototype,"send",void 0),ri([me({attribute:!1})],ci.prototype,"load",void 0),ri([me({attribute:!1})],ci.prototype,"messages",void 0),ri([me({type:String})],ci.prototype,"label",void 0),ri([me({type:String})],ci.prototype,"placeholder",void 0),ri([me({type:Boolean,reflect:!0})],ci.prototype,"opened",void 0),ri([me({type:Boolean,attribute:"hide-toggle",reflect:!0})],ci.prototype,"hideToggle",void 0),ri([me({type:String,reflect:!0})],ci.prototype,"variant",void 0),ri([me({type:Number,attribute:"conversation-id",reflect:!0})],ci.prototype,"conversationId",void 0),ri([fe()],ci.prototype,"_inputValue",void 0),ri([fe()],ci.prototype,"_isStreaming",void 0),ri([fe()],ci.prototype,"_error",void 0),ri([fe()],ci.prototype,"_contextWarning",void 0),ri([fe()],ci.prototype,"_contextLimitReached",void 0),ri([fe()],ci.prototype,"_contextLimitMessage",void 0),ri([fe()],ci.prototype,"_pendingActions",void 0),ri([fe()],ci.prototype,"_confirmationHighlighted",void 0),ri([fe()],ci.prototype,"_confirmationInFlight",void 0),ri([fe()],ci.prototype,"_telemetry",void 0),ri([fe()],ci.prototype,"_iterationLog",void 0),ri([fe()],ci.prototype,"_cacheCheckpoints",void 0),ri([fe()],ci.prototype,"_drawerOpen",void 0),ri([fe()],ci.prototype,"_drawerView",void 0),ri([fe()],ci.prototype,"_debugDrawerWidth",void 0),ri([fe()],ci.prototype,"_isDebugResizing",void 0),ri([fe()],ci.prototype,"_pendingConversationFiles",void 0),ri([fe()],ci.prototype,"_isDraggingFile",void 0),ri([fe()],ci.prototype,"_skillMenuOpened",void 0),ri([fe()],ci.prototype,"_skillQuery",void 0),ri([fe()],ci.prototype,"_orgSkills",void 0),ri([fe()],ci.prototype,"_globalSkills",void 0),ri([fe()],ci.prototype,"_invocableSkills",void 0),ri([fe()],ci.prototype,"_aiFrameworkConfig",void 0),ri([fe()],ci.prototype,"_skillHighlighted",void 0),ri([fe()],ci.prototype,"_copiedIndex",void 0),ri([fe()],ci.prototype,"_skillBrowseOpened",void 0),ri([fe()],ci.prototype,"_skillBrowseSource",void 0),ri([fe()],ci.prototype,"_skillBrowseQuery",void 0),ri([fe()],ci.prototype,"_isDictating",void 0),ri([fe()],ci.prototype,"_mode",void 0),ri([fe()],ci.prototype,"_modeMenuOpened",void 0),ri([fe()],ci.prototype,"_showTools",void 0),ri([fe()],ci.prototype,"_showToolInputs",void 0),ri([fe()],ci.prototype,"_showConfirmationInput",void 0),ri([be(".panel")],ci.prototype,"_panelEl",void 0),ri([be(".messages")],ci.prototype,"_messagesEl",void 0),ri([be(".input")],ci.prototype,"_inputEl",void 0),ri([be(".file-input")],ci.prototype,"_fileInputEl",void 0),ri([be(".input-wrapper")],ci.prototype,"_inputWrapperEl",void 0),ri([be(".skill-menu")],ci.prototype,"_skillMenuEl",void 0),ci=ri([pe("kr-chatbot")],ci);export{ci as KRChatbot,Ne as KRRouter,Pe as KRRouterOutlet,Ce as KRScaffold,Re as KRScreenDetail,ze as KRScreenNav,De as KRSubbar};
3556
3987
  //# sourceMappingURL=krubble-app.bundled.min.js.map