@kodaris/krubble-app-components 1.0.175 → 1.0.176

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,13 +8,13 @@
8
8
  * @license
9
9
  * Copyright 2017 Google LLC
10
10
  * SPDX-License-Identifier: BSD-3-Clause
11
- */,{is:l,defineProperty:d,getOwnPropertyDescriptor:h,getOwnPropertyNames:c,getOwnPropertySymbols:p,getPrototypeOf:u}=Object,g=globalThis,f=g.trustedTypes,m=f?f.emptyScript:"",v=g.reactiveElementPolyfillSupport,b=(e,t)=>e,_={toAttribute(e,t){switch(t){case Boolean:e=e?m: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}},y=(e,t)=>!l(e,t),k={attribute:!0,type:String,converter:_,reflect:!1,useDefault:!1,hasChanged:y};Symbol.metadata??=Symbol("metadata"),g.litPropertyMetadata??=new WeakMap;let x=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=k){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&&d(this.prototype,e,s)}}static getPropertyDescriptor(e,t,i){const{get:s,set:o}=h(this.prototype,e)??{get(){return this[t]},set(e){this[t]=e}};return{get:s,set(t){const r=s?.call(this);o?.call(this,t),this.requestUpdate(e,r,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)??k}static _$Ei(){if(this.hasOwnProperty(b("elementProperties")))return;const e=u(this);e.finalize(),void 0!==e.l&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(b("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(b("properties"))){const e=this.properties,t=[...c(e),...p(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(n(e))}else void 0!==e&&t.push(n(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,s)=>{if(i)e.adoptedStyleSheets=s.map((e=>e instanceof CSSStyleSheet?e:e.styleSheet));else for(const i of s){const s=document.createElement("style"),o=t.litNonce;void 0!==o&&s.setAttribute("nonce",o),s.textContent=i.cssText,e.appendChild(s)}})(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 o=(void 0!==i.converter?.toAttribute?i.converter:_).toAttribute(t,i.type);this._$Em=e,null==o?this.removeAttribute(s):this.setAttribute(s,o),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),o="function"==typeof e.converter?{fromAttribute:e.converter}:void 0!==e.converter?.fromAttribute?e.converter:_;this._$Em=s;const r=o.fromAttribute(t,e.type);this[s]=r??this._$Ej?.get(s)??r,this._$Em=null}}requestUpdate(e,t,i,s=!1,o){if(void 0!==e){const r=this.constructor;if(!1===s&&(o=this[e]),i??=r.getPropertyOptions(e),!((i.hasChanged??y)(o,t)||i.useDefault&&i.reflect&&o===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:o},r){i&&!(this._$Ej??=new Map).has(e)&&(this._$Ej.set(e,r??t??this[e]),!0!==o||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){}};x.elementStyles=[],x.shadowRootOptions={mode:"open"},x[b("elementProperties")]=new Map,x[b("finalized")]=new Map,v?.({ReactiveElement:x}),(g.reactiveElementVersions??=[]).push("2.1.2");
11
+ */,{is:l,defineProperty:d,getOwnPropertyDescriptor:h,getOwnPropertyNames:c,getOwnPropertySymbols:p,getPrototypeOf:u}=Object,g=globalThis,f=g.trustedTypes,v=f?f.emptyScript:"",m=g.reactiveElementPolyfillSupport,b=(e,t)=>e,_={toAttribute(e,t){switch(t){case Boolean:e=e?v: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}},y=(e,t)=>!l(e,t),k={attribute:!0,type:String,converter:_,reflect:!1,useDefault:!1,hasChanged:y};Symbol.metadata??=Symbol("metadata"),g.litPropertyMetadata??=new WeakMap;let x=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=k){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&&d(this.prototype,e,s)}}static getPropertyDescriptor(e,t,i){const{get:s,set:o}=h(this.prototype,e)??{get(){return this[t]},set(e){this[t]=e}};return{get:s,set(t){const r=s?.call(this);o?.call(this,t),this.requestUpdate(e,r,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)??k}static _$Ei(){if(this.hasOwnProperty(b("elementProperties")))return;const e=u(this);e.finalize(),void 0!==e.l&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(b("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(b("properties"))){const e=this.properties,t=[...c(e),...p(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(n(e))}else void 0!==e&&t.push(n(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,s)=>{if(i)e.adoptedStyleSheets=s.map((e=>e instanceof CSSStyleSheet?e:e.styleSheet));else for(const i of s){const s=document.createElement("style"),o=t.litNonce;void 0!==o&&s.setAttribute("nonce",o),s.textContent=i.cssText,e.appendChild(s)}})(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 o=(void 0!==i.converter?.toAttribute?i.converter:_).toAttribute(t,i.type);this._$Em=e,null==o?this.removeAttribute(s):this.setAttribute(s,o),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),o="function"==typeof e.converter?{fromAttribute:e.converter}:void 0!==e.converter?.fromAttribute?e.converter:_;this._$Em=s;const r=o.fromAttribute(t,e.type);this[s]=r??this._$Ej?.get(s)??r,this._$Em=null}}requestUpdate(e,t,i,s=!1,o){if(void 0!==e){const r=this.constructor;if(!1===s&&(o=this[e]),i??=r.getPropertyOptions(e),!((i.hasChanged??y)(o,t)||i.useDefault&&i.reflect&&o===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:o},r){i&&!(this._$Ej??=new Map).has(e)&&(this._$Ej.set(e,r??t??this[e]),!0!==o||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){}};x.elementStyles=[],x.shadowRootOptions={mode:"open"},x[b("elementProperties")]=new Map,x[b("finalized")]=new Map,m?.({ReactiveElement:x}),(g.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 w=globalThis,$=w.trustedTypes,S=$?$.createPolicy("lit-html",{createHTML:e=>e}):void 0,C="$lit$",E=`lit$${Math.random().toFixed(9).slice(2)}$`,z="?"+E,D=`<${z}>`,T=document,O=()=>T.createComment(""),A=e=>null===e||"object"!=typeof e&&"function"!=typeof e,M=Array.isArray,I="[ \t\n\f\r]",R=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,P=/-->/g,L=/>/g,q=RegExp(`>|${I}(?:([^\\s"'>=/]+)(${I}*=${I}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),V=/'/g,B=/"/g,F=/^(?:script|style|textarea|title)$/i,N=(e=>(t,...i)=>({_$litType$:e,strings:t,values:i}))(1),j=Symbol.for("lit-noChange"),U=Symbol.for("lit-nothing"),H=new WeakMap,W=T.createTreeWalker(T,129);function Y(e,t){if(!M(e)||!e.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==S?S.createHTML(t):t}class K{constructor({strings:e,_$litType$:t},i){let s;this.parts=[];let o=0,r=0;const a=e.length-1,n=this.parts,[l,d]=((e,t)=>{const i=e.length-1,s=[];let o,r=2===t?"<svg>":3===t?"<math>":"",a=R;for(let t=0;t<i;t++){const i=e[t];let n,l,d=-1,h=0;for(;h<i.length&&(a.lastIndex=h,l=a.exec(i),null!==l);)h=a.lastIndex,a===R?"!--"===l[1]?a=P:void 0!==l[1]?a=L:void 0!==l[2]?(F.test(l[2])&&(o=RegExp("</"+l[2],"g")),a=q):void 0!==l[3]&&(a=q):a===q?">"===l[0]?(a=o??R,d=-1):void 0===l[1]?d=-2:(d=a.lastIndex-l[2].length,n=l[1],a=void 0===l[3]?q:'"'===l[3]?B:V):a===B||a===V?a=q:a===P||a===L?a=R:(a=q,o=void 0);const c=a===q&&e[t+1].startsWith("/>")?" ":"";r+=a===R?i+D:d>=0?(s.push(n),i.slice(0,d)+C+i.slice(d)+E+c):i+E+(-2===d?t:c)}return[Y(e,r+(e[i]||"<?>")+(2===t?"</svg>":3===t?"</math>":"")),s]})(e,t);if(this.el=K.createElement(l,i),W.currentNode=this.el.content,2===t||3===t){const e=this.el.content.firstChild;e.replaceWith(...e.childNodes)}for(;null!==(s=W.nextNode())&&n.length<a;){if(1===s.nodeType){if(s.hasAttributes())for(const e of s.getAttributeNames())if(e.endsWith(C)){const t=d[r++],i=s.getAttribute(e).split(E),a=/([.?@])?(.*)/.exec(t);n.push({type:1,index:o,name:a[2],strings:i,ctor:"."===a[1]?G:"?"===a[1]?ee:"@"===a[1]?te:Q}),s.removeAttribute(e)}else e.startsWith(E)&&(n.push({type:6,index:o}),s.removeAttribute(e));if(F.test(s.tagName)){const e=s.textContent.split(E),t=e.length-1;if(t>0){s.textContent=$?$.emptyScript:"";for(let i=0;i<t;i++)s.append(e[i],O()),W.nextNode(),n.push({type:2,index:++o});s.append(e[t],O())}}}else if(8===s.nodeType)if(s.data===z)n.push({type:2,index:o});else{let e=-1;for(;-1!==(e=s.data.indexOf(E,e+1));)n.push({type:7,index:o}),e+=E.length-1}o++}}static createElement(e,t){const i=T.createElement("template");return i.innerHTML=e,i}}function X(e,t,i=e,s){if(t===j)return t;let o=void 0!==s?i._$Co?.[s]:i._$Cl;const r=A(t)?void 0:t._$litDirective$;return o?.constructor!==r&&(o?._$AO?.(!1),void 0===r?o=void 0:(o=new r(e),o._$AT(e,i,s)),void 0!==s?(i._$Co??=[])[s]=o:i._$Cl=o),void 0!==o&&(t=X(e,o._$AS(e,t.values),o,s)),t}class Z{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??T).importNode(t,!0);W.currentNode=s;let o=W.nextNode(),r=0,a=0,n=i[0];for(;void 0!==n;){if(r===n.index){let t;2===n.type?t=new J(o,o.nextSibling,this,e):1===n.type?t=new n.ctor(o,n.name,n.strings,this,e):6===n.type&&(t=new ie(o,this,e)),this._$AV.push(t),n=i[++a]}r!==n?.index&&(o=W.nextNode(),r++)}return W.currentNode=T,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 J{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(e,t,i,s){this.type=2,this._$AH=U,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=X(this,e,t),A(e)?e===U||null==e||""===e?(this._$AH!==U&&this._$AR(),this._$AH=U):e!==this._$AH&&e!==j&&this._(e):void 0!==e._$litType$?this.$(e):void 0!==e.nodeType?this.T(e):(e=>M(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!==U&&A(this._$AH)?this._$AA.nextSibling.data=e:this.T(T.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=K.createElement(Y(i.h,i.h[0]),this.options)),i);if(this._$AH?._$AD===s)this._$AH.p(t);else{const e=new Z(s,this),i=e.u(this.options);e.p(t),this.T(i),this._$AH=e}}_$AC(e){let t=H.get(e.strings);return void 0===t&&H.set(e.strings,t=new K(e)),t}k(e){M(this._$AH)||(this._$AH=[],this._$AR());const t=this._$AH;let i,s=0;for(const o of e)s===t.length?t.push(i=new J(this.O(O()),this.O(O()),this,this.options)):i=t[s],i._$AI(o),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 Q{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,t,i,s,o){this.type=1,this._$AH=U,this._$AN=void 0,this.element=e,this.name=t,this._$AM=s,this.options=o,i.length>2||""!==i[0]||""!==i[1]?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=U}_$AI(e,t=this,i,s){const o=this.strings;let r=!1;if(void 0===o)e=X(this,e,t,0),r=!A(e)||e!==this._$AH&&e!==j,r&&(this._$AH=e);else{const s=e;let a,n;for(e=o[0],a=0;a<o.length-1;a++)n=X(this,s[i+a],t,a),n===j&&(n=this._$AH[a]),r||=!A(n)||n!==this._$AH[a],n===U?e=U:e!==U&&(e+=(n??"")+o[a+1]),this._$AH[a]=n}r&&!s&&this.j(e)}j(e){e===U?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??"")}}class G extends Q{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===U?void 0:e}}class ee extends Q{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==U)}}class te extends Q{constructor(e,t,i,s,o){super(e,t,i,s,o),this.type=5}_$AI(e,t=this){if((e=X(this,e,t,0)??U)===j)return;const i=this._$AH,s=e===U&&i!==U||e.capture!==i.capture||e.once!==i.once||e.passive!==i.passive,o=e!==U&&(i===U||s);s&&this.element.removeEventListener(this.name,this,i),o&&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 ie{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){X(this,e)}}const se={I:J},oe=w.litHtmlPolyfillSupport;oe?.(K,J),(w.litHtmlVersions??=[]).push("3.3.2");const re=(e,t,i)=>{const s=i?.renderBefore??t;let o=s._$litPart$;if(void 0===o){const e=i?.renderBefore??null;s._$litPart$=o=new J(t.insertBefore(O(),e),e,void 0,i??{})}return o._$AI(e),o
17
+ const w=globalThis,$=w.trustedTypes,S=$?$.createPolicy("lit-html",{createHTML:e=>e}):void 0,C="$lit$",E=`lit$${Math.random().toFixed(9).slice(2)}$`,z="?"+E,D=`<${z}>`,T=document,O=()=>T.createComment(""),M=e=>null===e||"object"!=typeof e&&"function"!=typeof e,A=Array.isArray,I="[ \t\n\f\r]",R=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,P=/-->/g,L=/>/g,q=RegExp(`>|${I}(?:([^\\s"'>=/]+)(${I}*=${I}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),V=/'/g,F=/"/g,B=/^(?:script|style|textarea|title)$/i,N=(e=>(t,...i)=>({_$litType$:e,strings:t,values:i}))(1),j=Symbol.for("lit-noChange"),U=Symbol.for("lit-nothing"),H=new WeakMap,W=T.createTreeWalker(T,129);function Y(e,t){if(!A(e)||!e.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==S?S.createHTML(t):t}class K{constructor({strings:e,_$litType$:t},i){let s;this.parts=[];let o=0,r=0;const a=e.length-1,n=this.parts,[l,d]=((e,t)=>{const i=e.length-1,s=[];let o,r=2===t?"<svg>":3===t?"<math>":"",a=R;for(let t=0;t<i;t++){const i=e[t];let n,l,d=-1,h=0;for(;h<i.length&&(a.lastIndex=h,l=a.exec(i),null!==l);)h=a.lastIndex,a===R?"!--"===l[1]?a=P:void 0!==l[1]?a=L:void 0!==l[2]?(B.test(l[2])&&(o=RegExp("</"+l[2],"g")),a=q):void 0!==l[3]&&(a=q):a===q?">"===l[0]?(a=o??R,d=-1):void 0===l[1]?d=-2:(d=a.lastIndex-l[2].length,n=l[1],a=void 0===l[3]?q:'"'===l[3]?F:V):a===F||a===V?a=q:a===P||a===L?a=R:(a=q,o=void 0);const c=a===q&&e[t+1].startsWith("/>")?" ":"";r+=a===R?i+D:d>=0?(s.push(n),i.slice(0,d)+C+i.slice(d)+E+c):i+E+(-2===d?t:c)}return[Y(e,r+(e[i]||"<?>")+(2===t?"</svg>":3===t?"</math>":"")),s]})(e,t);if(this.el=K.createElement(l,i),W.currentNode=this.el.content,2===t||3===t){const e=this.el.content.firstChild;e.replaceWith(...e.childNodes)}for(;null!==(s=W.nextNode())&&n.length<a;){if(1===s.nodeType){if(s.hasAttributes())for(const e of s.getAttributeNames())if(e.endsWith(C)){const t=d[r++],i=s.getAttribute(e).split(E),a=/([.?@])?(.*)/.exec(t);n.push({type:1,index:o,name:a[2],strings:i,ctor:"."===a[1]?G:"?"===a[1]?ee:"@"===a[1]?te:Q}),s.removeAttribute(e)}else e.startsWith(E)&&(n.push({type:6,index:o}),s.removeAttribute(e));if(B.test(s.tagName)){const e=s.textContent.split(E),t=e.length-1;if(t>0){s.textContent=$?$.emptyScript:"";for(let i=0;i<t;i++)s.append(e[i],O()),W.nextNode(),n.push({type:2,index:++o});s.append(e[t],O())}}}else if(8===s.nodeType)if(s.data===z)n.push({type:2,index:o});else{let e=-1;for(;-1!==(e=s.data.indexOf(E,e+1));)n.push({type:7,index:o}),e+=E.length-1}o++}}static createElement(e,t){const i=T.createElement("template");return i.innerHTML=e,i}}function X(e,t,i=e,s){if(t===j)return t;let o=void 0!==s?i._$Co?.[s]:i._$Cl;const r=M(t)?void 0:t._$litDirective$;return o?.constructor!==r&&(o?._$AO?.(!1),void 0===r?o=void 0:(o=new r(e),o._$AT(e,i,s)),void 0!==s?(i._$Co??=[])[s]=o:i._$Cl=o),void 0!==o&&(t=X(e,o._$AS(e,t.values),o,s)),t}class Z{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??T).importNode(t,!0);W.currentNode=s;let o=W.nextNode(),r=0,a=0,n=i[0];for(;void 0!==n;){if(r===n.index){let t;2===n.type?t=new J(o,o.nextSibling,this,e):1===n.type?t=new n.ctor(o,n.name,n.strings,this,e):6===n.type&&(t=new ie(o,this,e)),this._$AV.push(t),n=i[++a]}r!==n?.index&&(o=W.nextNode(),r++)}return W.currentNode=T,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 J{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(e,t,i,s){this.type=2,this._$AH=U,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=X(this,e,t),M(e)?e===U||null==e||""===e?(this._$AH!==U&&this._$AR(),this._$AH=U):e!==this._$AH&&e!==j&&this._(e):void 0!==e._$litType$?this.$(e):void 0!==e.nodeType?this.T(e):(e=>A(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!==U&&M(this._$AH)?this._$AA.nextSibling.data=e:this.T(T.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=K.createElement(Y(i.h,i.h[0]),this.options)),i);if(this._$AH?._$AD===s)this._$AH.p(t);else{const e=new Z(s,this),i=e.u(this.options);e.p(t),this.T(i),this._$AH=e}}_$AC(e){let t=H.get(e.strings);return void 0===t&&H.set(e.strings,t=new K(e)),t}k(e){A(this._$AH)||(this._$AH=[],this._$AR());const t=this._$AH;let i,s=0;for(const o of e)s===t.length?t.push(i=new J(this.O(O()),this.O(O()),this,this.options)):i=t[s],i._$AI(o),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 Q{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,t,i,s,o){this.type=1,this._$AH=U,this._$AN=void 0,this.element=e,this.name=t,this._$AM=s,this.options=o,i.length>2||""!==i[0]||""!==i[1]?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=U}_$AI(e,t=this,i,s){const o=this.strings;let r=!1;if(void 0===o)e=X(this,e,t,0),r=!M(e)||e!==this._$AH&&e!==j,r&&(this._$AH=e);else{const s=e;let a,n;for(e=o[0],a=0;a<o.length-1;a++)n=X(this,s[i+a],t,a),n===j&&(n=this._$AH[a]),r||=!M(n)||n!==this._$AH[a],n===U?e=U:e!==U&&(e+=(n??"")+o[a+1]),this._$AH[a]=n}r&&!s&&this.j(e)}j(e){e===U?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??"")}}class G extends Q{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===U?void 0:e}}class ee extends Q{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==U)}}class te extends Q{constructor(e,t,i,s,o){super(e,t,i,s,o),this.type=5}_$AI(e,t=this){if((e=X(this,e,t,0)??U)===j)return;const i=this._$AH,s=e===U&&i!==U||e.capture!==i.capture||e.once!==i.once||e.passive!==i.passive,o=e!==U&&(i===U||s);s&&this.element.removeEventListener(this.name,this,i),o&&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 ie{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){X(this,e)}}const se={I:J},oe=w.litHtmlPolyfillSupport;oe?.(K,J),(w.litHtmlVersions??=[]).push("3.3.2");const re=(e,t,i)=>{const s=i?.renderBefore??t;let o=s._$litPart$;if(void 0===o){const e=i?.renderBefore??null;s._$litPart$=o=new J(t.insertBefore(O(),e),e,void 0,i??{})}return o._$AI(e),o
18
18
  /**
19
19
  * @license
20
20
  * Copyright 2017 Google LLC
@@ -46,7 +46,7 @@ function ue(e,t){return(t,i,s)=>((e,t,i)=>(i.configurable=!0,i.enumerable=!0,Ref
46
46
  * @license
47
47
  * Copyright 2017 Google LLC
48
48
  * SPDX-License-Identifier: BSD-3-Clause
49
- */const ge=1,fe=2,me=3,ve=4,be=e=>(...t)=>({_$litDirective$:e,values:t});let _e=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)}};
49
+ */const ge=1,fe=2,ve=3,me=4,be=e=>(...t)=>({_$litDirective$:e,values:t});let _e=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)}};
50
50
  /**
51
51
  * @license
52
52
  * Copyright 2018 Google LLC
@@ -62,12 +62,12 @@ function ue(e,t){return(t,i,s)=>((e,t,i)=>(i.configurable=!0,i.enumerable=!0,Ref
62
62
  * Copyright 2017 Google LLC
63
63
  * SPDX-License-Identifier: BSD-3-Clause
64
64
  */
65
- class $e extends _e{constructor(e){if(super(e),this.it=U,e.type!==fe)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(e){if(e===U||null==e)return this._t=void 0,this.it=e;if(e===j)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:[]}}}$e.directiveName="unsafeHTML",$e.resultType=1;const Se=be($e),{I:Ce}=se,Ee=()=>document.createComment(""),ze=(e,t,i)=>{const s=e._$AA.parentNode,o=void 0===t?e._$AB:t._$AA;if(void 0===i){const t=s.insertBefore(Ee(),o),r=s.insertBefore(Ee(),o);i=new Ce(t,r,e,e.options)}else{const t=i._$AB.nextSibling,r=i._$AM,a=r!==e;if(a){let t;i._$AQ?.(e),i._$AM=e,void 0!==i._$AP&&(t=e._$AU)!==r._$AU&&i._$AP(t)}if(t!==o||a){let e=i._$AA;for(;e!==t;){const t=e.nextSibling;s.insertBefore(e,o),e=t}}}return i},De=(e,t,i=e)=>(e._$AI(t,i),e),Te={},Oe=(e,t=Te)=>e._$AH=t,Ae=e=>{e._$AR(),e._$AA.remove()},Me=(e,t,i)=>{const s=new Map;for(let o=t;o<=i;o++)s.set(e[o],o);return s},Ie=be(class extends _e{constructor(e){if(super(e),e.type!==fe)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 o=[],r=[];let a=0;for(const t of e)o[a]=s?s(t,a):a,r[a]=i(t,a),a++;return{values:r,keys:o}}render(e,t,i){return this.dt(e,t,i).values}update(e,[t,i,s]){const o=(e=>e._$AH)(e),{values:r,keys:a}=this.dt(t,i,s);if(!Array.isArray(o))return this.ut=a,r;const n=this.ut??=[],l=[];let d,h,c=0,p=o.length-1,u=0,g=r.length-1;for(;c<=p&&u<=g;)if(null===o[c])c++;else if(null===o[p])p--;else if(n[c]===a[u])l[u]=De(o[c],r[u]),c++,u++;else if(n[p]===a[g])l[g]=De(o[p],r[g]),p--,g--;else if(n[c]===a[g])l[g]=De(o[c],r[g]),ze(e,l[g+1],o[c]),c++,g--;else if(n[p]===a[u])l[u]=De(o[p],r[u]),ze(e,o[c],o[p]),p--,u++;else if(void 0===d&&(d=Me(a,u,g),h=Me(n,c,p)),d.has(n[c]))if(d.has(n[p])){const t=h.get(a[u]),i=void 0!==t?o[t]:null;if(null===i){const t=ze(e,o[c]);De(t,r[u]),l[u]=t}else l[u]=De(i,r[u]),ze(e,o[c],i),o[t]=null;u++}else Ae(o[p]),p--;else Ae(o[c]),c++;for(;u<=g;){const t=ze(e,l[g+1]);De(t,r[u]),l[u++]=t}for(;c<=p;){const e=o[c++];null!==e&&Ae(e)}return this.ut=a,Oe(e,l),j}});
65
+ class $e extends _e{constructor(e){if(super(e),this.it=U,e.type!==fe)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(e){if(e===U||null==e)return this._t=void 0,this.it=e;if(e===j)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:[]}}}$e.directiveName="unsafeHTML",$e.resultType=1;const Se=be($e),{I:Ce}=se,Ee=()=>document.createComment(""),ze=(e,t,i)=>{const s=e._$AA.parentNode,o=void 0===t?e._$AB:t._$AA;if(void 0===i){const t=s.insertBefore(Ee(),o),r=s.insertBefore(Ee(),o);i=new Ce(t,r,e,e.options)}else{const t=i._$AB.nextSibling,r=i._$AM,a=r!==e;if(a){let t;i._$AQ?.(e),i._$AM=e,void 0!==i._$AP&&(t=e._$AU)!==r._$AU&&i._$AP(t)}if(t!==o||a){let e=i._$AA;for(;e!==t;){const t=e.nextSibling;s.insertBefore(e,o),e=t}}}return i},De=(e,t,i=e)=>(e._$AI(t,i),e),Te={},Oe=(e,t=Te)=>e._$AH=t,Me=e=>{e._$AR(),e._$AA.remove()},Ae=(e,t,i)=>{const s=new Map;for(let o=t;o<=i;o++)s.set(e[o],o);return s},Ie=be(class extends _e{constructor(e){if(super(e),e.type!==fe)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 o=[],r=[];let a=0;for(const t of e)o[a]=s?s(t,a):a,r[a]=i(t,a),a++;return{values:r,keys:o}}render(e,t,i){return this.dt(e,t,i).values}update(e,[t,i,s]){const o=(e=>e._$AH)(e),{values:r,keys:a}=this.dt(t,i,s);if(!Array.isArray(o))return this.ut=a,r;const n=this.ut??=[],l=[];let d,h,c=0,p=o.length-1,u=0,g=r.length-1;for(;c<=p&&u<=g;)if(null===o[c])c++;else if(null===o[p])p--;else if(n[c]===a[u])l[u]=De(o[c],r[u]),c++,u++;else if(n[p]===a[g])l[g]=De(o[p],r[g]),p--,g--;else if(n[c]===a[g])l[g]=De(o[c],r[g]),ze(e,l[g+1],o[c]),c++,g--;else if(n[p]===a[u])l[u]=De(o[p],r[u]),ze(e,o[c],o[p]),p--,u++;else if(void 0===d&&(d=Ae(a,u,g),h=Ae(n,c,p)),d.has(n[c]))if(d.has(n[p])){const t=h.get(a[u]),i=void 0!==t?o[t]:null;if(null===i){const t=ze(e,o[c]);De(t,r[u]),l[u]=t}else l[u]=De(i,r[u]),ze(e,o[c],i),o[t]=null;u++}else Me(o[p]),p--;else Me(o[c]),c++;for(;u<=g;){const t=ze(e,l[g+1]);De(t,r[u]),l[u++]=t}for(;c<=p;){const e=o[c++];null!==e&&Me(e)}return this.ut=a,Oe(e,l),j}});
66
66
  /**
67
67
  * @license
68
68
  * Copyright 2020 Google LLC
69
69
  * SPDX-License-Identifier: BSD-3-Clause
70
- */function Re(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}let Pe={async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null};function Le(e){Pe=e}const qe=/[&<>"']/,Ve=new RegExp(qe.source,"g"),Be=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,Fe=new RegExp(Be.source,"g"),Ne={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},je=e=>Ne[e];function Ue(e,t){if(t){if(qe.test(e))return e.replace(Ve,je)}else if(Be.test(e))return e.replace(Fe,je);return e}const He=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/gi;function We(e){return e.replace(He,((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 Ye=/(^|[^\[])\^/g;function Ke(e,t){let i="string"==typeof e?e:e.source;t=t||"";const s={replace:(e,t)=>{let o="string"==typeof t?t:t.source;return o=o.replace(Ye,"$1"),i=i.replace(e,o),s},getRegex:()=>new RegExp(i,t)};return s}function Xe(e){try{e=encodeURI(e).replace(/%25/g,"%")}catch(e){return null}return e}const Ze={exec:()=>null};function Je(e,t){const i=e.replace(/\|/g,((e,t,i)=>{let s=!1,o=t;for(;--o>=0&&"\\"===i[o];)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 Qe(e,t,i){const s=e.length;if(0===s)return"";let o=0;for(;o<s;){if(e.charAt(s-o-1)!==t)break;o++}return e.slice(0,s-o)}function Ge(e,t,i,s){const o=t.href,r=t.title?Ue(t.title):null,a=e[1].replace(/\\([\[\]])/g,"$1");if("!"!==e[0].charAt(0)){s.state.inLink=!0;const e={type:"link",raw:i,href:o,title:r,text:a,tokens:s.inlineTokens(a)};return s.state.inLink=!1,e}return{type:"image",raw:i,href:o,title:r,text:Ue(a)}}class et{options;rules;lexer;constructor(e){this.options=e||Pe}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:Qe(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=Qe(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=Qe(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,o={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 a="",n="",l=!1;for(;e;){let i=!1;if(!(t=r.exec(e)))break;if(this.rules.block.hr.test(e))break;a=t[0],e=e.substring(a.length);let s=t[2].split("\n",1)[0].replace(/^\t+/,(e=>" ".repeat(3*e.length))),d=e.split("\n",1)[0],h=0;this.options.pedantic?(h=2,n=s.trimStart()):(h=t[2].search(/[^ ]/),h=h>4?1:h,n=s.slice(h),h+=t[1].length);let c=!1;if(!s&&/^ *$/.test(d)&&(a+=d+"\n",e=e.substring(d.length+1),i=!0),!i){const t=new RegExp(`^ {0,${Math.min(3,h-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ \t][^\\n]*)?(?:\\n|$))`),i=new RegExp(`^ {0,${Math.min(3,h-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),o=new RegExp(`^ {0,${Math.min(3,h-1)}}(?:\`\`\`|~~~)`),r=new RegExp(`^ {0,${Math.min(3,h-1)}}#`);for(;e;){const l=e.split("\n",1)[0];if(d=l,this.options.pedantic&&(d=d.replace(/^ {1,4}(?=( {4})*[^ ])/g," ")),o.test(d))break;if(r.test(d))break;if(t.test(d))break;if(i.test(e))break;if(d.search(/[^ ]/)>=h||!d.trim())n+="\n"+d.slice(h);else{if(c)break;if(s.search(/[^ ]/)>=4)break;if(o.test(s))break;if(r.test(s))break;if(i.test(s))break;n+="\n"+d}c||d.trim()||(c=!0),a+=l+"\n",e=e.substring(l.length+1),s=d.slice(h)}}o.loose||(l?o.loose=!0:/\n *\n *$/.test(a)&&(l=!0));let p,u=null;this.options.gfm&&(u=/^\[[ xX]\] /.exec(n),u&&(p="[ ] "!==u[0],n=n.replace(/^\[[ xX]\] +/,""))),o.items.push({type:"list_item",raw:a,task:!!u,checked:p,loose:!1,text:n,tokens:[]}),o.raw+=a}o.items[o.items.length-1].raw=a.trimEnd(),o.items[o.items.length-1].text=n.trimEnd(),o.raw=o.raw.trimEnd();for(let e=0;e<o.items.length;e++)if(this.lexer.state.top=!1,o.items[e].tokens=this.lexer.blockTokens(o.items[e].text,[]),!o.loose){const t=o.items[e].tokens.filter((e=>"space"===e.type)),i=t.length>0&&t.some((e=>/\n.*\n/.test(e.raw)));o.loose=i}if(o.loose)for(let e=0;e<o.items.length;e++)o.items[e].loose=!0;return o}}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=Je(t[1]),s=t[2].replace(/^\||\| *$/g,"").split("|"),o=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 o)r.rows.push(Je(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:Ue(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=Qe(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)),Ge(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 Ge(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 o,r,a=i,n=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(o=s[1]||s[2]||s[3]||s[4]||s[5]||s[6],!o)continue;if(r=[...o].length,s[3]||s[4]){a+=r;continue}if((s[5]||s[6])&&i%3&&!((i+r)%3)){n+=r;continue}if(a-=r,a>0)continue;r=Math.min(r,r+a+n);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 d=l.slice(2,-2);return{type:"strong",raw:l,text:d,tokens:this.lexer.inlineTokens(d)}}}}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=Ue(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=Ue(t[1]),i="mailto:"+e):(e=Ue(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=Ue(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=Ue(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]:Ue(t[0]),{type:"text",raw:t[0],text:e}}}}const tt=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,it=/(?:[*+-]|\d{1,9}[.)])/,st=Ke(/^(?!bull |blockCode|fences|blockquote|heading|html)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html))+?)\n {0,3}(=+|-+) *(?:\n+|$)/).replace(/bull/g,it).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(),ot=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,rt=/(?!\s*\])(?:\\.|[^\[\]\\])+/,at=Ke(/^ {0,3}\[(label)\]: *(?:\n *)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/).replace("label",rt).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),nt=Ke(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,it).getRegex(),lt="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",dt=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,ht=Ke("^ {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",dt).replace("tag",lt).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),ct=Ke(ot).replace("hr",tt).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",lt).getRegex(),pt={blockquote:Ke(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",ct).getRegex(),code:/^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/,def:at,fences:/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,heading:/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,hr:tt,html:ht,lheading:st,list:nt,newline:/^(?: *(?:\n|$))+/,paragraph:ct,table:Ze,text:/^[^\n]+/},ut=Ke("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",tt).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",lt).getRegex(),gt={...pt,table:ut,paragraph:Ke(ot).replace("hr",tt).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",ut).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",lt).getRegex()},ft={...pt,html:Ke("^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:\"[^\"]*\"|'[^']*'|\\s[^'\"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))").replace("comment",dt).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:Ze,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:Ke(ot).replace("hr",tt).replace("heading"," *#{1,6} *[^\n]").replace("lheading",st).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},mt=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,vt=/^( {2,}|\\)\n(?!\s*$)/,bt="\\p{P}\\p{S}",_t=Ke(/^((?![*_])[\spunctuation])/,"u").replace(/punctuation/g,bt).getRegex(),yt=Ke(/^(?:\*+(?:((?!\*)[punct])|[^\s*]))|^_+(?:((?!_)[punct])|([^\s_]))/,"u").replace(/punct/g,bt).getRegex(),kt=Ke("^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)[punct](\\*+)(?=[\\s]|$)|[^punct\\s](\\*+)(?!\\*)(?=[punct\\s]|$)|(?!\\*)[punct\\s](\\*+)(?=[^punct\\s])|[\\s](\\*+)(?!\\*)(?=[punct])|(?!\\*)[punct](\\*+)(?!\\*)(?=[punct])|[^punct\\s](\\*+)(?=[^punct\\s])","gu").replace(/punct/g,bt).getRegex(),xt=Ke("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)[punct](_+)(?=[\\s]|$)|[^punct\\s](_+)(?!_)(?=[punct\\s]|$)|(?!_)[punct\\s](_+)(?=[^punct\\s])|[\\s](_+)(?!_)(?=[punct])|(?!_)[punct](_+)(?!_)(?=[punct])","gu").replace(/punct/g,bt).getRegex(),wt=Ke(/\\([punct])/,"gu").replace(/punct/g,bt).getRegex(),$t=Ke(/^<(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(),St=Ke(dt).replace("(?:--\x3e|$)","--\x3e").getRegex(),Ct=Ke("^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",St).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Et=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,zt=Ke(/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/).replace("label",Et).replace("href",/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Dt=Ke(/^!?\[(label)\]\[(ref)\]/).replace("label",Et).replace("ref",rt).getRegex(),Tt=Ke(/^!?\[(ref)\](?:\[\])?/).replace("ref",rt).getRegex(),Ot={_backpedal:Ze,anyPunctuation:wt,autolink:$t,blockSkip:/\[[^[\]]*?\]\([^\(\)]*?\)|`[^`]*?`|<[^<>]*?>/g,br:vt,code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,del:Ze,emStrongLDelim:yt,emStrongRDelimAst:kt,emStrongRDelimUnd:xt,escape:mt,link:zt,nolink:Tt,punctuation:_t,reflink:Dt,reflinkSearch:Ke("reflink|nolink(?!\\()","g").replace("reflink",Dt).replace("nolink",Tt).getRegex(),tag:Ct,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,url:Ze},At={...Ot,link:Ke(/^!?\[(label)\]\((.*?)\)/).replace("label",Et).getRegex(),reflink:Ke(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Et).getRegex()},Mt={...Ot,escape:Ke(mt).replace("])","~|])").getRegex(),url:Ke(/^((?: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.!#$%&'*+\/=?_`{\|}~-]+@)))/},It={...Mt,br:Ke(vt).replace("{2,}","*").getRegex(),text:Ke(Mt.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Rt={normal:pt,gfm:gt,pedantic:ft},Pt={normal:Ot,gfm:Mt,breaks:It,pedantic:At};class Lt{tokens;options;state;tokenizer;inlineQueue;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||Pe,this.options.tokenizer=this.options.tokenizer||new et,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:Rt.normal,inline:Pt.normal};this.options.pedantic?(t.block=Rt.pedantic,t.inline=Pt.pedantic):this.options.gfm&&(t.block=Rt.gfm,this.options.breaks?t.inline=Pt.breaks:t.inline=Pt.gfm),this.tokenizer.rules=t}static get rules(){return{block:Rt,inline:Pt}}static lex(e,t){return new Lt(t).lex(e)}static lexInline(e,t){return new Lt(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,o,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(o=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&&(o=e.substring(0,t+1))}if(this.state.top&&(i=this.tokenizer.paragraph(o)))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=o.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,o,r,a,n,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(a||(n=""),a=!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,n))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(o=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&&(o=e.substring(0,t+1))}if(i=this.tokenizer.inlineText(o))e=e.substring(i.raw.length),"_"!==i.raw.slice(-1)&&(n=i.raw.slice(-1)),a=!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 qt{options;constructor(e){this.options=e||Pe}code(e,t,i){const s=(t||"").match(/^\S*/)?.[0];return e=e.replace(/\n$/,"")+"\n",s?'<pre><code class="language-'+Ue(s)+'">'+(i?e:Ue(e,!0))+"</code></pre>\n":"<pre><code>"+(i?e:Ue(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=Xe(e);if(null===s)return i;let o='<a href="'+(e=s)+'"';return t&&(o+=' title="'+t+'"'),o+=">"+i+"</a>",o}image(e,t,i){const s=Xe(e);if(null===s)return i;let o=`<img src="${e=s}" alt="${i}"`;return t&&(o+=` title="${t}"`),o+=">",o}text(e){return e}}class Vt{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 Bt{options;renderer;textRenderer;constructor(e){this.options=e||Pe,this.options.renderer=this.options.renderer||new qt,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new Vt}static parse(e,t){return new Bt(t).parse(e)}static parseInline(e,t){return new Bt(t).parseInline(e)}parse(e,t=!0){let i="";for(let s=0;s<e.length;s++){const o=e[s];if(this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[o.type]){const e=o,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(o.type){case"space":continue;case"hr":i+=this.renderer.hr();continue;case"heading":{const e=o;i+=this.renderer.heading(this.parseInline(e.tokens),e.depth,We(this.parseInline(e.tokens,this.textRenderer)));continue}case"code":{const e=o;i+=this.renderer.code(e.text,e.lang,!!e.escaped);continue}case"table":{const e=o;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=o,t=this.parse(e.tokens);i+=this.renderer.blockquote(t);continue}case"list":{const e=o,t=e.ordered,s=e.start,r=e.loose;let a="";for(let t=0;t<e.items.length;t++){const i=e.items[t],s=i.checked,o=i.task;let n="";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+" "}):n+=e+" "}n+=this.parse(i.tokens,r),a+=this.renderer.listitem(n,o,!!s)}i+=this.renderer.list(a,t,s);continue}case"html":{const e=o;i+=this.renderer.html(e.text,e.block);continue}case"paragraph":{const e=o;i+=this.renderer.paragraph(this.parseInline(e.tokens));continue}case"text":{let r=o,a=r.tokens?this.parseInline(r.tokens):r.text;for(;s+1<e.length&&"text"===e[s+1].type;)r=e[++s],a+="\n"+(r.tokens?this.parseInline(r.tokens):r.text);i+=t?this.renderer.paragraph(a):a;continue}default:{const e='Token with "'+o.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 o=e[s];if(this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[o.type]){const e=this.options.extensions.renderers[o.type].call({parser:this},o);if(!1!==e||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(o.type)){i+=e||"";continue}}switch(o.type){case"escape":{const e=o;i+=t.text(e.text);break}case"html":{const e=o;i+=t.html(e.text);break}case"link":{const e=o;i+=t.link(e.href,e.title,this.parseInline(e.tokens,t));break}case"image":{const e=o;i+=t.image(e.href,e.title,e.text);break}case"strong":{const e=o;i+=t.strong(this.parseInline(e.tokens,t));break}case"em":{const e=o;i+=t.em(this.parseInline(e.tokens,t));break}case"codespan":{const e=o;i+=t.codespan(e.text);break}case"br":i+=t.br();break;case"del":{const e=o;i+=t.del(this.parseInline(e.tokens,t));break}case"text":{const e=o;i+=t.text(e.text);break}default:{const e='Token with "'+o.type+'" type was not found.';if(this.options.silent)return console.error(e),"";throw new Error(e)}}}return i}}class Ft{options;constructor(e){this.options=e||Pe}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}}const Nt=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(Lt.lex,Bt.parse);parseInline=this.#e(Lt.lexInline,Bt.parseInline);Parser=Bt;Renderer=qt;TextRenderer=Vt;Lexer=Lt;Tokenizer=et;Hooks=Ft;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 o=e[s].flat(1/0);i=i.concat(this.walkTokens(o,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 qt(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,o=e.renderer[s],r=t[s];t[s]=(...e)=>{let i=o.apply(t,e);return!1===i&&(i=r.apply(t,e)),i||""}}i.renderer=t}if(e.tokenizer){const t=this.defaults.tokenizer||new et(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,o=e.tokenizer[s],r=t[s];t[s]=(...e)=>{let i=o.apply(t,e);return!1===i&&(i=r.apply(t,e)),i}}i.tokenizer=t}if(e.hooks){const t=this.defaults.hooks||new Ft;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,o=e.hooks[s],r=t[s];Ft.passThroughHooks.has(i)?t[s]=e=>{if(this.defaults.async)return Promise.resolve(o.call(t,e)).then((e=>r.call(t,e)));const i=o.call(t,e);return r.call(t,i)}:t[s]=(...e)=>{let i=o.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 Lt.lex(e,t??this.defaults)}parser(e,t){return Bt.parse(e,t??this.defaults)}#e(e,t){return(i,s)=>{const o={...s},r={...this.defaults,...o};!0===this.defaults.async&&!1===o.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 a=this.#t(!!r.silent,!!r.async);if(null==i)return a(new Error("marked(): input parameter is undefined or null"));if("string"!=typeof i)return a(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(a);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 o=t(s,r);return r.hooks&&(o=r.hooks.postprocess(o)),o}catch(e){return a(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>"+Ue(i.message+"",!0)+"</pre>";return t?Promise.resolve(e):e}if(t)return Promise.reject(i);throw i}}};function jt(e,t){return Nt.parse(e,t)}jt.options=jt.setOptions=function(e){return Nt.setOptions(e),jt.defaults=Nt.defaults,Le(jt.defaults),jt},jt.getDefaults=Re,jt.defaults=Pe,jt.use=function(...e){return Nt.use(...e),jt.defaults=Nt.defaults,Le(jt.defaults),jt},jt.walkTokens=function(e,t){return Nt.walkTokens(e,t)},jt.parseInline=Nt.parseInline,jt.Parser=Bt,jt.parser=Bt.parse,jt.Renderer=qt,jt.TextRenderer=Vt,jt.Lexer=Lt,jt.lexer=Lt.lex,jt.Tokenizer=et,jt.Hooks=Ft,jt.parse=jt,jt.options,jt.setOptions,jt.use,jt.walkTokens,jt.parseInline,Bt.parse,Lt.lex;const Ut=a`
70
+ */function Re(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}let Pe={async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null};function Le(e){Pe=e}const qe=/[&<>"']/,Ve=new RegExp(qe.source,"g"),Fe=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,Be=new RegExp(Fe.source,"g"),Ne={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},je=e=>Ne[e];function Ue(e,t){if(t){if(qe.test(e))return e.replace(Ve,je)}else if(Fe.test(e))return e.replace(Be,je);return e}const He=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/gi;function We(e){return e.replace(He,((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 Ye=/(^|[^\[])\^/g;function Ke(e,t){let i="string"==typeof e?e:e.source;t=t||"";const s={replace:(e,t)=>{let o="string"==typeof t?t:t.source;return o=o.replace(Ye,"$1"),i=i.replace(e,o),s},getRegex:()=>new RegExp(i,t)};return s}function Xe(e){try{e=encodeURI(e).replace(/%25/g,"%")}catch(e){return null}return e}const Ze={exec:()=>null};function Je(e,t){const i=e.replace(/\|/g,((e,t,i)=>{let s=!1,o=t;for(;--o>=0&&"\\"===i[o];)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 Qe(e,t,i){const s=e.length;if(0===s)return"";let o=0;for(;o<s;){if(e.charAt(s-o-1)!==t)break;o++}return e.slice(0,s-o)}function Ge(e,t,i,s){const o=t.href,r=t.title?Ue(t.title):null,a=e[1].replace(/\\([\[\]])/g,"$1");if("!"!==e[0].charAt(0)){s.state.inLink=!0;const e={type:"link",raw:i,href:o,title:r,text:a,tokens:s.inlineTokens(a)};return s.state.inLink=!1,e}return{type:"image",raw:i,href:o,title:r,text:Ue(a)}}class et{options;rules;lexer;constructor(e){this.options=e||Pe}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:Qe(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=Qe(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=Qe(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,o={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 a="",n="",l=!1;for(;e;){let i=!1;if(!(t=r.exec(e)))break;if(this.rules.block.hr.test(e))break;a=t[0],e=e.substring(a.length);let s=t[2].split("\n",1)[0].replace(/^\t+/,(e=>" ".repeat(3*e.length))),d=e.split("\n",1)[0],h=0;this.options.pedantic?(h=2,n=s.trimStart()):(h=t[2].search(/[^ ]/),h=h>4?1:h,n=s.slice(h),h+=t[1].length);let c=!1;if(!s&&/^ *$/.test(d)&&(a+=d+"\n",e=e.substring(d.length+1),i=!0),!i){const t=new RegExp(`^ {0,${Math.min(3,h-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ \t][^\\n]*)?(?:\\n|$))`),i=new RegExp(`^ {0,${Math.min(3,h-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),o=new RegExp(`^ {0,${Math.min(3,h-1)}}(?:\`\`\`|~~~)`),r=new RegExp(`^ {0,${Math.min(3,h-1)}}#`);for(;e;){const l=e.split("\n",1)[0];if(d=l,this.options.pedantic&&(d=d.replace(/^ {1,4}(?=( {4})*[^ ])/g," ")),o.test(d))break;if(r.test(d))break;if(t.test(d))break;if(i.test(e))break;if(d.search(/[^ ]/)>=h||!d.trim())n+="\n"+d.slice(h);else{if(c)break;if(s.search(/[^ ]/)>=4)break;if(o.test(s))break;if(r.test(s))break;if(i.test(s))break;n+="\n"+d}c||d.trim()||(c=!0),a+=l+"\n",e=e.substring(l.length+1),s=d.slice(h)}}o.loose||(l?o.loose=!0:/\n *\n *$/.test(a)&&(l=!0));let p,u=null;this.options.gfm&&(u=/^\[[ xX]\] /.exec(n),u&&(p="[ ] "!==u[0],n=n.replace(/^\[[ xX]\] +/,""))),o.items.push({type:"list_item",raw:a,task:!!u,checked:p,loose:!1,text:n,tokens:[]}),o.raw+=a}o.items[o.items.length-1].raw=a.trimEnd(),o.items[o.items.length-1].text=n.trimEnd(),o.raw=o.raw.trimEnd();for(let e=0;e<o.items.length;e++)if(this.lexer.state.top=!1,o.items[e].tokens=this.lexer.blockTokens(o.items[e].text,[]),!o.loose){const t=o.items[e].tokens.filter((e=>"space"===e.type)),i=t.length>0&&t.some((e=>/\n.*\n/.test(e.raw)));o.loose=i}if(o.loose)for(let e=0;e<o.items.length;e++)o.items[e].loose=!0;return o}}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=Je(t[1]),s=t[2].replace(/^\||\| *$/g,"").split("|"),o=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 o)r.rows.push(Je(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:Ue(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=Qe(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)),Ge(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 Ge(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 o,r,a=i,n=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(o=s[1]||s[2]||s[3]||s[4]||s[5]||s[6],!o)continue;if(r=[...o].length,s[3]||s[4]){a+=r;continue}if((s[5]||s[6])&&i%3&&!((i+r)%3)){n+=r;continue}if(a-=r,a>0)continue;r=Math.min(r,r+a+n);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 d=l.slice(2,-2);return{type:"strong",raw:l,text:d,tokens:this.lexer.inlineTokens(d)}}}}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=Ue(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=Ue(t[1]),i="mailto:"+e):(e=Ue(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=Ue(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=Ue(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]:Ue(t[0]),{type:"text",raw:t[0],text:e}}}}const tt=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,it=/(?:[*+-]|\d{1,9}[.)])/,st=Ke(/^(?!bull |blockCode|fences|blockquote|heading|html)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html))+?)\n {0,3}(=+|-+) *(?:\n+|$)/).replace(/bull/g,it).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(),ot=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,rt=/(?!\s*\])(?:\\.|[^\[\]\\])+/,at=Ke(/^ {0,3}\[(label)\]: *(?:\n *)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/).replace("label",rt).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),nt=Ke(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,it).getRegex(),lt="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",dt=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,ht=Ke("^ {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",dt).replace("tag",lt).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),ct=Ke(ot).replace("hr",tt).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",lt).getRegex(),pt={blockquote:Ke(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",ct).getRegex(),code:/^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/,def:at,fences:/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,heading:/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,hr:tt,html:ht,lheading:st,list:nt,newline:/^(?: *(?:\n|$))+/,paragraph:ct,table:Ze,text:/^[^\n]+/},ut=Ke("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",tt).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",lt).getRegex(),gt={...pt,table:ut,paragraph:Ke(ot).replace("hr",tt).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",ut).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",lt).getRegex()},ft={...pt,html:Ke("^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:\"[^\"]*\"|'[^']*'|\\s[^'\"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))").replace("comment",dt).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:Ze,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:Ke(ot).replace("hr",tt).replace("heading"," *#{1,6} *[^\n]").replace("lheading",st).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},vt=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,mt=/^( {2,}|\\)\n(?!\s*$)/,bt="\\p{P}\\p{S}",_t=Ke(/^((?![*_])[\spunctuation])/,"u").replace(/punctuation/g,bt).getRegex(),yt=Ke(/^(?:\*+(?:((?!\*)[punct])|[^\s*]))|^_+(?:((?!_)[punct])|([^\s_]))/,"u").replace(/punct/g,bt).getRegex(),kt=Ke("^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)[punct](\\*+)(?=[\\s]|$)|[^punct\\s](\\*+)(?!\\*)(?=[punct\\s]|$)|(?!\\*)[punct\\s](\\*+)(?=[^punct\\s])|[\\s](\\*+)(?!\\*)(?=[punct])|(?!\\*)[punct](\\*+)(?!\\*)(?=[punct])|[^punct\\s](\\*+)(?=[^punct\\s])","gu").replace(/punct/g,bt).getRegex(),xt=Ke("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)[punct](_+)(?=[\\s]|$)|[^punct\\s](_+)(?!_)(?=[punct\\s]|$)|(?!_)[punct\\s](_+)(?=[^punct\\s])|[\\s](_+)(?!_)(?=[punct])|(?!_)[punct](_+)(?!_)(?=[punct])","gu").replace(/punct/g,bt).getRegex(),wt=Ke(/\\([punct])/,"gu").replace(/punct/g,bt).getRegex(),$t=Ke(/^<(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(),St=Ke(dt).replace("(?:--\x3e|$)","--\x3e").getRegex(),Ct=Ke("^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",St).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Et=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,zt=Ke(/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/).replace("label",Et).replace("href",/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Dt=Ke(/^!?\[(label)\]\[(ref)\]/).replace("label",Et).replace("ref",rt).getRegex(),Tt=Ke(/^!?\[(ref)\](?:\[\])?/).replace("ref",rt).getRegex(),Ot={_backpedal:Ze,anyPunctuation:wt,autolink:$t,blockSkip:/\[[^[\]]*?\]\([^\(\)]*?\)|`[^`]*?`|<[^<>]*?>/g,br:mt,code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,del:Ze,emStrongLDelim:yt,emStrongRDelimAst:kt,emStrongRDelimUnd:xt,escape:vt,link:zt,nolink:Tt,punctuation:_t,reflink:Dt,reflinkSearch:Ke("reflink|nolink(?!\\()","g").replace("reflink",Dt).replace("nolink",Tt).getRegex(),tag:Ct,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,url:Ze},Mt={...Ot,link:Ke(/^!?\[(label)\]\((.*?)\)/).replace("label",Et).getRegex(),reflink:Ke(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Et).getRegex()},At={...Ot,escape:Ke(vt).replace("])","~|])").getRegex(),url:Ke(/^((?: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.!#$%&'*+\/=?_`{\|}~-]+@)))/},It={...At,br:Ke(mt).replace("{2,}","*").getRegex(),text:Ke(At.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Rt={normal:pt,gfm:gt,pedantic:ft},Pt={normal:Ot,gfm:At,breaks:It,pedantic:Mt};class Lt{tokens;options;state;tokenizer;inlineQueue;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||Pe,this.options.tokenizer=this.options.tokenizer||new et,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:Rt.normal,inline:Pt.normal};this.options.pedantic?(t.block=Rt.pedantic,t.inline=Pt.pedantic):this.options.gfm&&(t.block=Rt.gfm,this.options.breaks?t.inline=Pt.breaks:t.inline=Pt.gfm),this.tokenizer.rules=t}static get rules(){return{block:Rt,inline:Pt}}static lex(e,t){return new Lt(t).lex(e)}static lexInline(e,t){return new Lt(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,o,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(o=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&&(o=e.substring(0,t+1))}if(this.state.top&&(i=this.tokenizer.paragraph(o)))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=o.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,o,r,a,n,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(a||(n=""),a=!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,n))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(o=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&&(o=e.substring(0,t+1))}if(i=this.tokenizer.inlineText(o))e=e.substring(i.raw.length),"_"!==i.raw.slice(-1)&&(n=i.raw.slice(-1)),a=!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 qt{options;constructor(e){this.options=e||Pe}code(e,t,i){const s=(t||"").match(/^\S*/)?.[0];return e=e.replace(/\n$/,"")+"\n",s?'<pre><code class="language-'+Ue(s)+'">'+(i?e:Ue(e,!0))+"</code></pre>\n":"<pre><code>"+(i?e:Ue(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=Xe(e);if(null===s)return i;let o='<a href="'+(e=s)+'"';return t&&(o+=' title="'+t+'"'),o+=">"+i+"</a>",o}image(e,t,i){const s=Xe(e);if(null===s)return i;let o=`<img src="${e=s}" alt="${i}"`;return t&&(o+=` title="${t}"`),o+=">",o}text(e){return e}}class Vt{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 Ft{options;renderer;textRenderer;constructor(e){this.options=e||Pe,this.options.renderer=this.options.renderer||new qt,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new Vt}static parse(e,t){return new Ft(t).parse(e)}static parseInline(e,t){return new Ft(t).parseInline(e)}parse(e,t=!0){let i="";for(let s=0;s<e.length;s++){const o=e[s];if(this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[o.type]){const e=o,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(o.type){case"space":continue;case"hr":i+=this.renderer.hr();continue;case"heading":{const e=o;i+=this.renderer.heading(this.parseInline(e.tokens),e.depth,We(this.parseInline(e.tokens,this.textRenderer)));continue}case"code":{const e=o;i+=this.renderer.code(e.text,e.lang,!!e.escaped);continue}case"table":{const e=o;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=o,t=this.parse(e.tokens);i+=this.renderer.blockquote(t);continue}case"list":{const e=o,t=e.ordered,s=e.start,r=e.loose;let a="";for(let t=0;t<e.items.length;t++){const i=e.items[t],s=i.checked,o=i.task;let n="";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+" "}):n+=e+" "}n+=this.parse(i.tokens,r),a+=this.renderer.listitem(n,o,!!s)}i+=this.renderer.list(a,t,s);continue}case"html":{const e=o;i+=this.renderer.html(e.text,e.block);continue}case"paragraph":{const e=o;i+=this.renderer.paragraph(this.parseInline(e.tokens));continue}case"text":{let r=o,a=r.tokens?this.parseInline(r.tokens):r.text;for(;s+1<e.length&&"text"===e[s+1].type;)r=e[++s],a+="\n"+(r.tokens?this.parseInline(r.tokens):r.text);i+=t?this.renderer.paragraph(a):a;continue}default:{const e='Token with "'+o.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 o=e[s];if(this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[o.type]){const e=this.options.extensions.renderers[o.type].call({parser:this},o);if(!1!==e||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(o.type)){i+=e||"";continue}}switch(o.type){case"escape":{const e=o;i+=t.text(e.text);break}case"html":{const e=o;i+=t.html(e.text);break}case"link":{const e=o;i+=t.link(e.href,e.title,this.parseInline(e.tokens,t));break}case"image":{const e=o;i+=t.image(e.href,e.title,e.text);break}case"strong":{const e=o;i+=t.strong(this.parseInline(e.tokens,t));break}case"em":{const e=o;i+=t.em(this.parseInline(e.tokens,t));break}case"codespan":{const e=o;i+=t.codespan(e.text);break}case"br":i+=t.br();break;case"del":{const e=o;i+=t.del(this.parseInline(e.tokens,t));break}case"text":{const e=o;i+=t.text(e.text);break}default:{const e='Token with "'+o.type+'" type was not found.';if(this.options.silent)return console.error(e),"";throw new Error(e)}}}return i}}class Bt{options;constructor(e){this.options=e||Pe}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}}const Nt=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(Lt.lex,Ft.parse);parseInline=this.#e(Lt.lexInline,Ft.parseInline);Parser=Ft;Renderer=qt;TextRenderer=Vt;Lexer=Lt;Tokenizer=et;Hooks=Bt;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 o=e[s].flat(1/0);i=i.concat(this.walkTokens(o,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 qt(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,o=e.renderer[s],r=t[s];t[s]=(...e)=>{let i=o.apply(t,e);return!1===i&&(i=r.apply(t,e)),i||""}}i.renderer=t}if(e.tokenizer){const t=this.defaults.tokenizer||new et(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,o=e.tokenizer[s],r=t[s];t[s]=(...e)=>{let i=o.apply(t,e);return!1===i&&(i=r.apply(t,e)),i}}i.tokenizer=t}if(e.hooks){const t=this.defaults.hooks||new Bt;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,o=e.hooks[s],r=t[s];Bt.passThroughHooks.has(i)?t[s]=e=>{if(this.defaults.async)return Promise.resolve(o.call(t,e)).then((e=>r.call(t,e)));const i=o.call(t,e);return r.call(t,i)}:t[s]=(...e)=>{let i=o.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 Lt.lex(e,t??this.defaults)}parser(e,t){return Ft.parse(e,t??this.defaults)}#e(e,t){return(i,s)=>{const o={...s},r={...this.defaults,...o};!0===this.defaults.async&&!1===o.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 a=this.#t(!!r.silent,!!r.async);if(null==i)return a(new Error("marked(): input parameter is undefined or null"));if("string"!=typeof i)return a(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(a);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 o=t(s,r);return r.hooks&&(o=r.hooks.postprocess(o)),o}catch(e){return a(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>"+Ue(i.message+"",!0)+"</pre>";return t?Promise.resolve(e):e}if(t)return Promise.reject(i);throw i}}};function jt(e,t){return Nt.parse(e,t)}jt.options=jt.setOptions=function(e){return Nt.setOptions(e),jt.defaults=Nt.defaults,Le(jt.defaults),jt},jt.getDefaults=Re,jt.defaults=Pe,jt.use=function(...e){return Nt.use(...e),jt.defaults=Nt.defaults,Le(jt.defaults),jt},jt.walkTokens=function(e,t){return Nt.walkTokens(e,t)},jt.parseInline=Nt.parseInline,jt.Parser=Ft,jt.parser=Ft.parse,jt.Renderer=qt,jt.TextRenderer=Vt,jt.Lexer=Lt,jt.lexer=Lt.lex,jt.Tokenizer=et,jt.Hooks=Bt,jt.parse=jt,jt.options,jt.setOptions,jt.use,jt.walkTokens,jt.parseInline,Ft.parse,Lt.lex;const Ut=a`
71
71
  :host,
72
72
  *,
73
73
  *::before,
@@ -2027,11 +2027,11 @@ class $e extends _e{constructor(e){if(super(e),this.it=U,e.type!==fe)throw Error
2027
2027
  width: 100%;
2028
2028
  height: 100%;
2029
2029
  }
2030
- `],ui([ce({type:String,reflect:!0})],gi.prototype,"id",void 0),ui([ce({type:String})],gi.prototype,"label",void 0),ui([ce({type:String})],gi.prototype,"badge",void 0),ui([ce({type:String,attribute:"badge-background"})],gi.prototype,"badgeBackground",void 0),ui([ce({type:String,attribute:"badge-color"})],gi.prototype,"badgeColor",void 0),ui([ce({type:Boolean})],gi.prototype,"disabled",void 0),ui([ce({type:Boolean})],gi.prototype,"dismissible",void 0),ui([ce({type:Boolean,reflect:!0})],gi.prototype,"active",void 0),customElements.get("krs-tab")||customElements.define("krs-tab",gi);var fi=function(e,t,i,s){var o,r=arguments.length,a=r<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,i,s);else for(var n=e.length-1;n>=0;n--)(o=e[n])&&(a=(r<3?o(a):r>3?o(t,i,a):o(t,i))||a);return r>3&&a&&Object.defineProperty(t,i,a),a};class mi extends ne{constructor(){super(...arguments),this.value="",this.disabled=!1}get label(){return this.textContent?.trim()||""}render(){return N`<slot></slot>`}}mi.styles=a`
2030
+ `],ui([ce({type:String,reflect:!0})],gi.prototype,"id",void 0),ui([ce({type:String})],gi.prototype,"label",void 0),ui([ce({type:String})],gi.prototype,"badge",void 0),ui([ce({type:String,attribute:"badge-background"})],gi.prototype,"badgeBackground",void 0),ui([ce({type:String,attribute:"badge-color"})],gi.prototype,"badgeColor",void 0),ui([ce({type:Boolean})],gi.prototype,"disabled",void 0),ui([ce({type:Boolean})],gi.prototype,"dismissible",void 0),ui([ce({type:Boolean,reflect:!0})],gi.prototype,"active",void 0),customElements.get("krs-tab")||customElements.define("krs-tab",gi);var fi=function(e,t,i,s){var o,r=arguments.length,a=r<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,i,s);else for(var n=e.length-1;n>=0;n--)(o=e[n])&&(a=(r<3?o(a):r>3?o(t,i,a):o(t,i))||a);return r>3&&a&&Object.defineProperty(t,i,a),a};class vi extends ne{constructor(){super(...arguments),this.value="",this.disabled=!1}get label(){return this.textContent?.trim()||""}render(){return N`<slot></slot>`}}vi.styles=a`
2031
2031
  :host {
2032
2032
  display: none;
2033
2033
  }
2034
- `,fi([ce({type:String})],mi.prototype,"value",void 0),fi([ce({type:Boolean})],mi.prototype,"disabled",void 0),customElements.get("krs-select-option")||customElements.define("krs-select-option",mi);var vi=function(e,t,i,s){var o,r=arguments.length,a=r<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,i,s);else for(var n=e.length-1;n>=0;n--)(o=e[n])&&(a=(r<3?o(a):r>3?o(t,i,a):o(t,i))||a);return r>3&&a&&Object.defineProperty(t,i,a),a};class bi extends ne{static fromJSON(e){const t=new bi;if(void 0!==e.label&&(t.label=e.label),void 0!==e.name&&(t.name=e.name),void 0!==e.value&&(t.value=e.value),void 0!==e.placeholder&&(t.placeholder=e.placeholder),void 0!==e.disabled&&(t.disabled=e.disabled),void 0!==e.required&&(t.required=e.required),void 0!==e.readonly&&(t.readonly=e.readonly),void 0!==e.hint&&(t.hint=e.hint),void 0!==e.saveMode&&(t.saveMode=e.saveMode),Array.isArray(e.options))for(const i of e.options){const e=new mi;"string"==typeof i?(e.value=i,e.textContent=i):(e.value=i.value,e.textContent=i.value,void 0!==i.label&&(e.textContent=i.label),void 0!==i.disabled&&(e.disabled=i.disabled)),t.appendChild(e)}return t}constructor(){super(),this._dirtyValue="",this.label="",this.name="",this.value="",this.placeholder="Select an option",this.disabled=!1,this.required=!1,this.readonly=!1,this.hint="",this.dirty=!1,this.saving=!1,this._isOpen=!1,this._highlightedIndex=-1,this._touched=!1,this._handleInvalid=e=>{e.preventDefault(),this._touched=!0},this._handleOutsideClick=e=>{e.composedPath().includes(this)||this._close()},this._handleKeyDown=e=>{if(!this._isOpen)return;const t=Array.from(this.querySelectorAll("krs-select-option"));switch(e.key){case"Escape":this._close(),this._triggerElement?.focus();break;case"ArrowDown":if(e.preventDefault(),t.some((e=>!e.disabled))){let e=this._highlightedIndex+1;for(;e<t.length&&t[e]?.disabled;)e++;e<t.length&&(this._highlightedIndex=e)}break;case"ArrowUp":e.preventDefault();{let e=this._highlightedIndex-1;for(;e>=0&&t[e]?.disabled;)e--;e>=0&&(this._highlightedIndex=e)}break;case"Enter":e.preventDefault(),this._highlightedIndex>=0&&this._highlightedIndex<t.length&&this._selectOption(t[this._highlightedIndex])}},this._internals=this.attachInternals()}connectedCallback(){super.connectedCallback(),this.classList.add("kr-form-field"),document.addEventListener("click",this._handleOutsideClick),document.addEventListener("keydown",this._handleKeyDown),this.addEventListener("invalid",this._handleInvalid)}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("click",this._handleOutsideClick),document.removeEventListener("keydown",this._handleKeyDown),this.removeEventListener("invalid",this._handleInvalid)}firstUpdated(){this._updateValidity()}willUpdate(e){let t=this.saveMode;t||(t=this.closest("krs-form")?.saveMode),e.has("value")&&this.dirty&&this.value!==this._dirtyValue&&"autosave"===t&&(this.value=this._dirtyValue)}updated(e){(e.has("required")||e.has("value"))&&this._updateValidity()}get form(){return this._internals.form}get validity(){return this._internals.validity}get validationMessage(){return this._internals.validationMessage}get willValidate(){return this._internals.willValidate}checkValidity(){return this._internals.checkValidity()}reportValidity(){return this._internals.reportValidity()}formResetCallback(){this.value="",this._touched=!1,this.dirty=!1,this.saving=!1,this._internals.setFormValue(""),this._internals.setValidity({})}formStateRestoreCallback(e){this.value=e}markPristine(){this.dirty=!1}markSaving(){this.saving=!0,this.dirty=!1}markSaved(){this.saving=!1}markSaveFailed(){this.saving=!1,this.dirty=!0,this._dirtyValue=this.value}focus(){this._triggerElement?.focus()}blur(){this._triggerElement?.blur()}_handleTriggerClick(){if(!this.disabled&&!this.readonly)if(this._isOpen)this._close();else{this._isOpen=!0;const e=Array.from(this.querySelectorAll("krs-select-option"));this._highlightedIndex=e.findIndex((e=>e.value===this.value)),requestAnimationFrame((()=>{const e=this.shadowRoot?.querySelector(".select-dropdown");if(e){const t=this._triggerElement.getBoundingClientRect(),i=window.innerHeight-t.bottom-4-8;e.style.top=t.bottom+4+"px",e.style.left=t.left+"px",e.style.minWidth=t.width+"px",e.style.maxHeight=i+"px"}}))}}_close(){this._isOpen=!1,this._highlightedIndex=-1}_selectOption(e){e.disabled||(this.value=e.value,this.dirty=!0,this._dirtyValue=this.value,this._internals.setFormValue(this.value),this._updateValidity(),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0})),this._close(),this._triggerElement?.focus())}_handleBlur(){this._touched=!0,this._updateValidity()}_handleOptionMouseEnter(e){this._highlightedIndex=e}_handleSlotChange(){this.requestUpdate()}_updateValidity(){this.required&&!this.value?this._internals.setValidity({valueMissing:!0},"Please select an option",this._triggerElement):this._internals.setValidity({})}render(){const e=Array.from(this.querySelectorAll("krs-select-option")),t=e.find((e=>e.value===this.value))?.label;return N`
2034
+ `,fi([ce({type:String})],vi.prototype,"value",void 0),fi([ce({type:Boolean})],vi.prototype,"disabled",void 0),customElements.get("krs-select-option")||customElements.define("krs-select-option",vi);var mi=function(e,t,i,s){var o,r=arguments.length,a=r<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,i,s);else for(var n=e.length-1;n>=0;n--)(o=e[n])&&(a=(r<3?o(a):r>3?o(t,i,a):o(t,i))||a);return r>3&&a&&Object.defineProperty(t,i,a),a};class bi extends ne{static fromJSON(e){const t=new bi;if(void 0!==e.label&&(t.label=e.label),void 0!==e.name&&(t.name=e.name),void 0!==e.value&&(t.value=e.value),void 0!==e.placeholder&&(t.placeholder=e.placeholder),void 0!==e.disabled&&(t.disabled=e.disabled),void 0!==e.required&&(t.required=e.required),void 0!==e.readonly&&(t.readonly=e.readonly),void 0!==e.hint&&(t.hint=e.hint),void 0!==e.saveMode&&(t.saveMode=e.saveMode),Array.isArray(e.options))for(const i of e.options){const e=new vi;"string"==typeof i?(e.value=i,e.textContent=i):(e.value=i.value,e.textContent=i.value,void 0!==i.label&&(e.textContent=i.label),void 0!==i.disabled&&(e.disabled=i.disabled)),t.appendChild(e)}return t}constructor(){super(),this._dirtyValue="",this.label="",this.name="",this.value="",this.placeholder="Select an option",this.disabled=!1,this.required=!1,this.readonly=!1,this.hint="",this.dirty=!1,this.saving=!1,this._isOpen=!1,this._highlightedIndex=-1,this._touched=!1,this._handleInvalid=e=>{e.preventDefault(),this._touched=!0},this._handleOutsideClick=e=>{e.composedPath().includes(this)||this._close()},this._handleKeyDown=e=>{if(!this._isOpen)return;const t=Array.from(this.querySelectorAll("krs-select-option"));switch(e.key){case"Escape":this._close(),this._triggerElement?.focus();break;case"ArrowDown":if(e.preventDefault(),t.some((e=>!e.disabled))){let e=this._highlightedIndex+1;for(;e<t.length&&t[e]?.disabled;)e++;e<t.length&&(this._highlightedIndex=e)}break;case"ArrowUp":e.preventDefault();{let e=this._highlightedIndex-1;for(;e>=0&&t[e]?.disabled;)e--;e>=0&&(this._highlightedIndex=e)}break;case"Enter":e.preventDefault(),this._highlightedIndex>=0&&this._highlightedIndex<t.length&&this._selectOption(t[this._highlightedIndex])}},this._internals=this.attachInternals()}connectedCallback(){super.connectedCallback(),this.classList.add("kr-form-field"),document.addEventListener("click",this._handleOutsideClick),document.addEventListener("keydown",this._handleKeyDown),this.addEventListener("invalid",this._handleInvalid)}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("click",this._handleOutsideClick),document.removeEventListener("keydown",this._handleKeyDown),this.removeEventListener("invalid",this._handleInvalid)}firstUpdated(){this._updateValidity()}willUpdate(e){let t=this.saveMode;t||(t=this.closest("krs-form")?.saveMode),e.has("value")&&this.dirty&&this.value!==this._dirtyValue&&"autosave"===t&&(this.value=this._dirtyValue)}updated(e){(e.has("required")||e.has("value"))&&this._updateValidity()}get form(){return this._internals.form}get validity(){return this._internals.validity}get validationMessage(){return this._internals.validationMessage}get willValidate(){return this._internals.willValidate}checkValidity(){return this._internals.checkValidity()}reportValidity(){return this._internals.reportValidity()}formResetCallback(){this.value="",this._touched=!1,this.dirty=!1,this.saving=!1,this._internals.setFormValue(""),this._internals.setValidity({})}formStateRestoreCallback(e){this.value=e}markPristine(){this.dirty=!1}markSaving(){this.saving=!0,this.dirty=!1}markSaved(){this.saving=!1}markSaveFailed(){this.saving=!1,this.dirty=!0,this._dirtyValue=this.value}focus(){this._triggerElement?.focus()}blur(){this._triggerElement?.blur()}_handleTriggerClick(){if(!this.disabled&&!this.readonly)if(this._isOpen)this._close();else{this._isOpen=!0;const e=Array.from(this.querySelectorAll("krs-select-option"));this._highlightedIndex=e.findIndex((e=>e.value===this.value)),requestAnimationFrame((()=>{const e=this.shadowRoot?.querySelector(".select-dropdown");if(e){const t=this._triggerElement.getBoundingClientRect(),i=window.innerHeight-t.bottom-4-8;e.style.top=t.bottom+4+"px",e.style.left=t.left+"px",e.style.minWidth=t.width+"px",e.style.maxHeight=i+"px"}}))}}_close(){this._isOpen=!1,this._highlightedIndex=-1}_selectOption(e){e.disabled||(this.value=e.value,this.dirty=!0,this._dirtyValue=this.value,this._internals.setFormValue(this.value),this._updateValidity(),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0})),this._close(),this._triggerElement?.focus())}_handleBlur(){this._touched=!0,this._updateValidity()}_handleOptionMouseEnter(e){this._highlightedIndex=e}_handleSlotChange(){this.requestUpdate()}_updateValidity(){this.required&&!this.value?this._internals.setValidity({valueMissing:!0},"Please select an option",this._triggerElement):this._internals.setValidity({})}render(){const e=Array.from(this.querySelectorAll("krs-select-option")),t=e.find((e=>e.value===this.value))?.label;return N`
2035
2035
  <div class="wrapper">
2036
2036
  ${this.label?N`
2037
2037
  <label>
@@ -2258,7 +2258,7 @@ class $e extends _e{constructor(e){if(super(e),this.it=U,e.type!==fe)throw Error
2258
2258
  .options-slot {
2259
2259
  display: none;
2260
2260
  }
2261
- `],bi.formAssociated=!0,vi([ce({type:String})],bi.prototype,"label",void 0),vi([ce({type:String})],bi.prototype,"name",void 0),vi([ce({type:String})],bi.prototype,"value",void 0),vi([ce({type:String})],bi.prototype,"placeholder",void 0),vi([ce({type:Boolean})],bi.prototype,"disabled",void 0),vi([ce({type:Boolean})],bi.prototype,"required",void 0),vi([ce({type:Boolean})],bi.prototype,"readonly",void 0),vi([ce({type:String})],bi.prototype,"hint",void 0),vi([ce({type:Boolean,reflect:!0})],bi.prototype,"dirty",void 0),vi([ce({attribute:"save-mode"})],bi.prototype,"saveMode",void 0),vi([ce({type:Boolean,reflect:!0})],bi.prototype,"saving",void 0),vi([pe()],bi.prototype,"_isOpen",void 0),vi([pe()],bi.prototype,"_highlightedIndex",void 0),vi([pe()],bi.prototype,"_touched",void 0),vi([ue(".select-trigger")],bi.prototype,"_triggerElement",void 0),customElements.get("krs-select-field")||customElements.define("krs-select-field",bi);const _i={equals:{key:"equals",type:"comparison",dataTypes:["string","number","date","boolean"],label:"Equals"},n_equals:{key:"n_equals",type:"comparison",dataTypes:["string","number","date","boolean"],label:"Doesn't equal"},contains:{key:"contains",type:"comparison",dataTypes:["string"],label:"Contains"},n_contains:{key:"n_contains",type:"comparison",dataTypes:["string"],label:"Doesn't contain"},starts_with:{key:"starts_with",type:"comparison",dataTypes:["string"],label:"Starts with"},ends_with:{key:"ends_with",type:"comparison",dataTypes:["string"],label:"Ends with"},less_than:{key:"less_than",type:"comparison",dataTypes:["number","date"],label:"Less than"},less_than_equal:{key:"less_than_equal",type:"comparison",dataTypes:["number","date"],label:"Less than or equal"},greater_than:{key:"greater_than",type:"comparison",dataTypes:["number","date"],label:"Greater than"},greater_than_equal:{key:"greater_than_equal",type:"comparison",dataTypes:["number","date"],label:"Greater than or equal"},between:{key:"between",type:"range",dataTypes:["number","date"],label:"Between"},in:{key:"in",type:"list",dataTypes:["string","number"],label:"In"},n_in:{key:"n_in",type:"list",dataTypes:["string","number","date","boolean"],label:"Not In"},empty:{key:"empty",type:"nil",dataTypes:["string","number","date","boolean"],label:"Empty"},n_empty:{key:"n_empty",type:"nil",dataTypes:["string","number","date","boolean"],label:"Not empty"}};function yi(e){const t=[];for(const i of Object.values(_i))i.dataTypes.includes(e)&&t.push({key:i.key,label:i.label});return t}const ki=['"',"+","-","&&","||","!","(",")","{","}","[","]","^","~","*","?",":"],xi=['\\"',"\\+","\\-","\\&\\&","\\|\\|","\\!","\\(","\\)","\\{","\\}","\\[","\\]","\\^","\\~","\\*","\\?","\\:"];function wi(e,t=!0){return!0===e||!1===e?e.toString():null===e?"(*:* NOT *)":"number"==typeof e?e.toString():"string"==typeof e?(ki.forEach(((t,i)=>{var s;e=e.replace(new RegExp(`${s=t,"string"!=typeof s?s:s.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")}`,"g"),xi[i])})),t?`"${e}"`:e.replace(/ /g,"\\ ")):e}function $i(e,t=!1){const i=new Date(e);return i.setMinutes(i.getMinutes()-i.getTimezoneOffset()),t&&(i.setUTCHours(23),i.setUTCMinutes(59),i.setUTCSeconds(59),i.setUTCMilliseconds(999)),i.toISOString().replace(/:/g,"\\:")}function Si(e,t){let i,s,o,r;if(e&&"start"in e&&"end"in e)i=new Date(e.start),s=new Date(e.end),o=t[0],r=t[1];else{if(!(e instanceof Date))return"[* TO *]";i=new Date(e),s=new Date(e),o=t[0],r=t[0]}return"year"===o?(i.setUTCMonth(0,1),i.setUTCHours(0,0,0,0)):"month"===o?(i.setUTCDate(1),i.setUTCHours(0,0,0,0)):"day"===o?i.setUTCHours(0,0,0,0):"time"===o&&i.setUTCSeconds(0,0),"year"===r?(s.setUTCMonth(11,31),s.setUTCHours(23,59,59,999)):"month"===r?(s.setUTCMonth(s.getUTCMonth()+1),s.setUTCDate(0),s.setUTCHours(23,59,59,999)):"day"===r?s.setUTCHours(23,59,59,999):"time"===r&&s.setUTCSeconds(59,999),`[${i.toISOString().replace(/:/g,"\\:")} TO ${s.toISOString().replace(/:/g,"\\:")}]`}function Ci(e,t){let i,s,o,r,a,n;return e&&"start"in e&&"end"in e?(i=new Date(e.start),s=new Date(e.end),o=t[0],r=t[1]):(i=new Date(e),s=new Date(e),o=t[0],r=t[0]),"year"===o?(i.setUTCMonth(0,1),i.setUTCHours(0,0,0,0),a=i):"month"===o?(i.setUTCDate(1),i.setUTCHours(0,0,0,0),a=i):"day"===o?(i.setUTCHours(0,0,0,0),a=i):"time"===o?(i.setUTCSeconds(0,0),a=i):a=i,"year"===r?(s.setUTCMonth(11,31),s.setUTCHours(23,59,59,999),n=s):"month"===r?(s.setUTCMonth(s.getUTCMonth()+1),s.setUTCDate(0),s.setUTCHours(23,59,59,999),n=s):"day"===r?(s.setUTCHours(23,59,59,999),n=s):"time"===r?(s.setUTCSeconds(59,999),n=s):n=s,[a.toISOString().replace(/\..+/,"").replace("T"," "),n.toISOString().replace(/\..+/,"").replace("T"," ")]}function Ei(e){return e=e.trim(),/^(\d{1,2})\/(\d{1,2})\/(\d{2})$/.test(e)||/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/.test(e)?"day":/^(\d{1,2})\/(\d{1,2})\/(\d{4}),?\s+(\d{1,2}):(\d{2})\s*(AM|PM)?$/i.test(e)||/^(?:[A-Za-z]+,\s+)?([A-Za-z]+)\s+(\d{1,2}),?\s+(\d{4}),?\s+(\d{1,2}):(\d{2})\s*(AM|PM)?$/i.test(e)?"time":/^(?:[A-Za-z]+,\s+)?([A-Za-z]+)\s+(\d{1,2}),?\s+(\d{4})$/.test(e)?"day":/^(\d{2})$/.test(e)||/^(\d{4})$/.test(e)?"year":/^([A-Za-z]+)\s+(\d{4})$/.test(e)?"month":null}class zi{constructor(){this.field="",this.operator="equals",this.value=null,this.kql="",this.text="",this.type="",this.specificity=[]}setKql(e){if(this.kql=e.trim(),this.text="",this.specificity=[],this.value=null,this.kql)if(e.startsWith("="))this.operator="equals",this.text=e.substring(1).trim(),this.value=this._parse(this.text),this.specificity=[Ei(this.text)];else if(e.startsWith("!="))this.operator="n_equals",this.text=e.substring(2).trim(),this.value=this._parse(this.text),this.specificity=[Ei(this.text)];else if(e.startsWith("~")&&"string"===this.type)this.operator="contains",this.text=e.substring(1).trim(),this.value=this._parse(this.text),this.specificity=[Ei(this.text)];else if(e.startsWith("!~")&&"string"===this.type)this.operator="n_contains",this.text=e.substring(2).trim(),this.value=this._parse(this.text),this.specificity=[Ei(this.text)];else if(e.endsWith("*")&&"string"===this.type)this.operator="starts_with",this.text=e.substring(0,e.length-1),this.value=this._parse(this.text),this.specificity=[Ei(this.text)];else if(e.startsWith("*")&&"string"===this.type)this.operator="ends_with",this.text=e.substring(1),this.value=this._parse(this.text),this.specificity=[Ei(this.text)];else if("EMPTY"===e)this.operator="empty",this.value=null,this.specificity=[];else if("NOT EMPTY"===e)this.operator="n_empty",this.value=null,this.specificity=[];else if(e.startsWith("<="))this.operator="less_than_equal",this.text=e.substring(2).trim(),this.value=this._parse(this.text),this.specificity=[Ei(this.text)];else if(e.startsWith("<"))this.operator="less_than",this.text=e.substring(1).trim(),this.value=this._parse(this.text),this.specificity=[Ei(this.text)];else if(e.startsWith(">="))this.operator="greater_than_equal",this.text=e.substring(2).trim(),this.value=this._parse(this.text),this.specificity=[Ei(this.text)];else if(e.startsWith(">"))this.operator="greater_than",this.text=e.substring(1).trim(),this.value=this._parse(this.text),this.specificity=[Ei(this.text)];else if(e.startsWith("[")&&e.endsWith("]")&&e.indexOf(" TO ")>-1){this.operator="between";const t=e.indexOf(" TO "),i=e.substring(1,t).trim(),s=e.substring(t+4,e.length-1).trim();this.text=`${i} - ${s}`,this.value={start:this._parse(i),end:this._parse(s)},this.specificity=[Ei(i),Ei(s)]}else e.startsWith("!(")&&e.endsWith(")")?(this.operator="n_in",this.text=e.substring(2,e.length-1).trim(),this.value=this.text.split(",").map((e=>e.trim())).map((e=>this._parse(e))),this.specificity=[Ei(this.text)]):e.startsWith("(")&&e.endsWith(")")?(this.operator="in",this.text=e.substring(1,e.length-1).trim(),this.value=this.text.split(",").map((e=>e.trim())).map((e=>this._parse(e))),this.specificity=[Ei(this.text)]):"date"===this.type||"boolean"===this.type||"number"===this.type?(this.operator="equals",this.text=this.kql,this.value=this._parse(this.text),this.specificity=[Ei(this.text)]):(this.operator="contains",this.text=e,this.value=this._parse(this.text),this.specificity=[Ei(this.text)]);else"string"===this.type?this.operator="contains":this.operator="equals"}setOperator(e){"empty"===this.operator||"n_empty"===this.operator||"between"===this.operator?(this.value=null,this.text=""):"in"!==this.operator&&"n_in"!==this.operator||(this.value=[],this.text=""),this.operator=e,"empty"===this.operator?(this.value="EMPTY",this.text="EMPTY"):"n_empty"===this.operator?(this.value="NOT EMPTY",this.text="NOT EMPTY"):"between"===this.operator?(this.value=null,this.text=""):"in"!==this.operator&&"n_in"!==this.operator||(this.value=[],this.text=""),this._buildKql()}setValue(e,t){this.value=e,t?this.specificity=[t]:e instanceof Date?this.specificity=["time"]:this.specificity=[],this._buildText(),this._buildKql()}setStart(e,t){void 0===this.value?.start&&(this.value={start:null,end:null}),this.value.start=e,t?this.specificity[0]=t:e instanceof Date&&(this.specificity[0]="time"),this._buildText(),this._buildKql()}setEnd(e,t){void 0===this.value?.end&&(this.value={start:null,end:null}),this.value.end=e,t?this.specificity[1]=t:e instanceof Date&&(this.specificity[1]="time"),this._buildText(),this._buildKql()}clear(){"string"===this.type?this.operator="contains":this.operator="equals",this.value=null,this.kql="",this.text="",this.specificity=[]}isEmpty(){return"empty"===this.operator||"n_empty"===this.operator?!this.text:"between"===this.operator?!this.value?.start&&!this.value?.end:"in"===this.operator||"n_in"===this.operator?!this.value?.length:void 0===this.value||null===this.value||""===this.value}has(e){return!("in"!==this.operator&&"n_in"!==this.operator||!Array.isArray(this.value))&&("boolean"===this.type&&"string"==typeof e&&("true"===e?e=!0:"false"===e&&(e=!1)),this.value.indexOf(e)>=0)}toggle(e){"in"!==this.operator&&"n_in"!==this.operator&&this.setOperator("in"),"boolean"===this.type&&"string"==typeof e&&("true"===e?e=!0:"false"===e&&(e=!1));const t=this.value.indexOf(e);t>=0?this.value.splice(t,1):this.value.push(e),this._buildText(),this._buildKql()}isValid(){return!this.kql||!!this.field&&(!!this.operator&&("empty"===this.operator||("n_empty"===this.operator||("in"===this.operator||"n_in"===this.operator?Array.isArray(this.value)&&this.value.length>0:"date"===this.type?"between"===this.operator?this.value?.start instanceof Date&&this.value?.end instanceof Date&&!isNaN(this.value.start.getTime())&&!isNaN(this.value.end.getTime()):this.value instanceof Date&&!isNaN(this.value.getTime()):"number"===this.type?"between"===this.operator?"number"==typeof this.value?.start&&"number"==typeof this.value?.end:"number"==typeof this.value:"boolean"===this.type?"boolean"==typeof this.value:"string"==typeof this.value&&!!this.value.trim().length))))}toSolrData(){const e={boost:null,fuzzy:null,not:!1,name:null,operation:null,tagged:!1,value:null};switch(e.name=this.field,this.operator){case"equals":this.value instanceof Date?(e.operation="EXPRESSION",e.value=Si(this.value,this.specificity)):(e.operation="IS",e.value=this.value);break;case"n_equals":this.value instanceof Date?(e.operation="EXPRESSION",e.not=!0,e.value=Si(this.value,this.specificity)):(e.operation="IS",e.not=!0,e.value=this.value);break;case"contains":e.operation="EXPRESSION",e.value=`*${wi(this.value,!1)}*`;break;case"n_contains":e.operation="EXPRESSION",e.not=!0,e.value=`*${wi(this.value,!1)}*`;break;case"starts_with":e.operation="EXPRESSION",e.value=`${wi(this.value,!1)}*`;break;case"ends_with":e.operation="EXPRESSION",e.value=`*${wi(this.value,!1)}`;break;case"empty":e.operation="EXPRESSION",e.not=!0,e.value="[* TO *]";break;case"n_empty":e.operation="EXPRESSION",e.value="[* TO *]";break;case"less_than":this.value instanceof Date?(e.operation="EXPRESSION",e.value=`[* TO ${$i(this.value)}}`):(e.operation="EXPRESSION",e.value=`[* TO ${wi(this.value,!0)}}`);break;case"less_than_equal":this.value instanceof Date?(e.operation="EXPRESSION",e.value=`[* TO ${$i(this.value,!0)}]`):(e.operation="EXPRESSION",e.value=`[* TO ${wi(this.value,!0)}]`);break;case"greater_than":this.value instanceof Date?(e.operation="EXPRESSION",e.value=`{${$i(this.value,!0)} TO *]`):(e.operation="EXPRESSION",e.value=`{${wi(this.value,!0)} TO *]`);break;case"greater_than_equal":this.value instanceof Date?(e.operation="EXPRESSION",e.value=`[${$i(this.value)} TO *]`):(e.operation="EXPRESSION",e.value=`[${wi(this.value,!0)} TO *]`);break;case"between":this.value?.start instanceof Date&&this.value?.end instanceof Date?(e.operation="EXPRESSION",e.value=Si(this.value,this.specificity)):(e.operation="EXPRESSION",e.value=`[${this.value.start} TO ${this.value.end}]`);break;case"in":Array.isArray(this.value)&&this.value.length>0?(e.operation="EXPRESSION",e.value=`(${this.value.map((e=>wi(e,!0))).join(" OR ")})`):(e.operation="EXPRESSION",e.value=wi(this.value,!0));break;case"n_in":Array.isArray(this.value)&&this.value.length>0?(e.operation="EXPRESSION",e.not=!0,e.value=`(${this.value.map((e=>wi(e,!0))).join(" OR ")})`):(e.operation="EXPRESSION",e.not=!0,e.value=wi(this.value,!0));break;default:e.operation="EXPRESSION",e.value=wi(this.value,!0)}return e}toDbParams(){const e={boost:null,fuzzy:null,not:!1,name:null,operation:null,tagged:!1,value:null,values:null};switch(e.name=this.field,this.operator){case"equals":"date"===this.type?(e.operation="BETWEEN",e.values=Ci(this.value,this.specificity)):(e.operation="IS",e.value=this.value);break;case"n_equals":"date"===this.type?(e.operation="BETWEEN",e.not=!0,e.values=Ci(this.value,this.specificity)):(e.operation="IS",e.value=this.value,e.not=!0);break;case"contains":e.operation="CONTAINS",e.value=this.value;break;case"n_contains":e.operation="CONTAINS",e.value=this.value,e.not=!0;break;case"starts_with":e.operation="STARTS_WITH",e.value=this.value;break;case"ends_with":e.operation="ENDS_WITH",e.value=this.value;break;case"empty":e.operation="IS_BLANK";break;case"n_empty":e.operation="IS_NOT_BLANK";break;case"less_than":e.operation="LESS_THAN",e.value=this.value;break;case"less_than_equal":e.operation="LESS_THAN_EQUAL",e.value=this.value;break;case"greater_than":e.operation="GREATER_THAN",e.value=this.value;break;case"greater_than_equal":e.operation="GREATER_THAN_EQUAL",e.value=this.value;break;case"between":e.operation="BETWEEN","date"===this.type?e.values=Ci(this.value,this.specificity):e.values=[this.value.start,this.value.end];break;case"in":e.operation="IN",e.values=this.value??[];break;case"n_in":e.operation="IN",e.not=!0,e.values=this.value??[];break;default:throw Error(`${this.operator} operator not supported by db params.`)}return e}toOpensearchData(){switch(this.operator){case"equals":return{term:{[this.field]:this.value}};case"n_equals":return{bool:{must_not:[{term:{[this.field]:this.value}}]}};case"contains":return{wildcard:{[this.field]:{value:`*${this.value}*`,case_insensitive:!0}}};case"n_contains":return{bool:{must_not:[{wildcard:{[this.field]:{value:`*${this.value}*`,case_insensitive:!0}}}]}};case"starts_with":return{wildcard:{[this.field]:{value:`${this.value}*`,case_insensitive:!0}}};case"ends_with":return{wildcard:{[this.field]:{value:`*${this.value}`,case_insensitive:!0}}};case"empty":return{bool:{must_not:[{exists:{field:this.field}}]}};case"n_empty":return{exists:{field:this.field}};case"less_than":return{range:{[this.field]:{lt:this.value}}};case"less_than_equal":return{range:{[this.field]:{lte:this.value}}};case"greater_than":return{range:{[this.field]:{gt:this.value}}};case"greater_than_equal":return{range:{[this.field]:{gte:this.value}}};case"between":return{range:{[this.field]:{gte:this.value?.start,lte:this.value?.end}}};case"in":return{terms:{[this.field]:this.value??[]}};case"n_in":return{bool:{must_not:[{terms:{[this.field]:this.value??[]}}]}};default:throw Error(`${this.operator} operator not supported by opensearch data.`)}}_buildText(){this.isEmpty()?this.text="":"between"===this.operator?this.text=`${this._format(this.value?.start)} - ${this._format(this.value?.end)}`:"in"===this.operator||"n_in"===this.operator?this.text=this.value.map((e=>this._format(e))).join(","):this.text=this._format(this.value)}_format(e){if(e instanceof Date&&!isNaN(e.getTime())){return`${String(e.getUTCMonth()+1).padStart(2,"0")}/${String(e.getUTCDate()).padStart(2,"0")}/${e.getUTCFullYear()}`}return"boolean"==typeof e?e?"Yes":"No":String(e??"")}_parse(e){if(null==e||""===e)return null;if(this.type)switch(this.type){case"boolean":{const t=e.toString().toLowerCase();return!0===e||!1!==e&&("yes"===t||"no"!==t&&("1"===t||"0"!==t&&null))}case"date":return this._parseDate(e);case"number":{const t=Number(e.toString().replace(/[$,]+/g,""));return isNaN(t)?null:t}default:return e.toString()}return e}_parseDate(e){if(null==e||""===e)return null;const t={jan:0,january:0,feb:1,february:1,mar:2,march:2,apr:3,april:3,may:4,jun:5,june:5,jul:6,july:6,aug:7,august:7,sep:8,september:8,oct:9,october:9,nov:10,november:10,dec:11,december:11};let i;if(i=e.match(/^(\d{1,2})\/(\d{1,2})\/(\d{2})$/),i)return new Date(Date.UTC(2e3+parseInt(i[3]),parseInt(i[1])-1,parseInt(i[2])));if(i=e.match(/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/),i)return new Date(Date.UTC(parseInt(i[3]),parseInt(i[1])-1,parseInt(i[2])));if(i=e.match(/^(\d{1,2})\/(\d{1,2})\/(\d{4}),?\s+(\d{1,2}):(\d{2})\s*(AM|PM)?$/i),i){let e=parseInt(i[4]);return i[6]&&("PM"===i[6].toUpperCase()&&12!==e&&(e+=12),"AM"===i[6].toUpperCase()&&12===e&&(e=0)),new Date(Date.UTC(parseInt(i[3]),parseInt(i[1])-1,parseInt(i[2]),e,parseInt(i[5])))}if(i=e.match(/^(?:[A-Za-z]+,\s+)?([A-Za-z]+)\s+(\d{1,2}),?\s+(\d{4}),?\s+(\d{1,2}):(\d{2})\s*(AM|PM)?$/i),i){const e=t[i[1].toLowerCase()];if(void 0!==e){let t=parseInt(i[4]);return i[6]&&("PM"===i[6].toUpperCase()&&12!==t&&(t+=12),"AM"===i[6].toUpperCase()&&12===t&&(t=0)),new Date(Date.UTC(parseInt(i[3]),e,parseInt(i[2]),t,parseInt(i[5])))}}if(i=e.match(/^(?:[A-Za-z]+,\s+)?([A-Za-z]+)\s+(\d{1,2}),?\s+(\d{4})$/),i){const e=t[i[1].toLowerCase()];if(void 0!==e)return new Date(Date.UTC(parseInt(i[3]),e,parseInt(i[2])))}if(i=e.match(/^(\d{2})$/),i)return new Date(Date.UTC(2e3+parseInt(i[1]),0,1));if(i=e.match(/^(\d{4})$/),i)return new Date(Date.UTC(parseInt(i[1]),0,1));if(i=e.match(/^([A-Za-z]+)\s+(\d{4})$/),i){const e=t[i[1].toLowerCase()];if(void 0!==e)return new Date(Date.UTC(parseInt(i[2]),e,1))}return null}_buildKql(){if(this.isEmpty())this.kql="";else switch(this.operator){case"equals":this.kql=`= ${this.text}`;break;case"n_equals":this.kql=`!= ${this.text}`;break;case"contains":this.kql=`~ ${this.text}`;break;case"n_contains":this.kql=`!~ ${this.text}`;break;case"starts_with":this.kql=`${this.text}*`;break;case"ends_with":this.kql=`*${this.text}`;break;case"empty":this.kql="EMPTY";break;case"n_empty":this.kql="NOT EMPTY";break;case"less_than":this.kql=`< ${this.text}`;break;case"less_than_equal":this.kql=`<= ${this.text}`;break;case"greater_than":this.kql=`> ${this.text}`;break;case"greater_than_equal":this.kql=`>= ${this.text}`;break;case"between":this.kql=`[${this._format(this.value?.start??"")} TO ${this._format(this.value?.end??"")}]`;break;case"in":this.kql=`(${this.value.map((e=>this._format(e))).join(",")})`;break;case"n_in":this.kql=`!(${this.value.map((e=>this._format(e))).join(",")})`;break;default:throw Error(`Unknown operator ${this.operator}`)}}}var Di=function(e,t,i,s){var o,r=arguments.length,a=r<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,i,s);else for(var n=e.length-1;n>=0;n--)(o=e[n])&&(a=(r<3?o(a):r>3?o(t,i,a):o(t,i))||a);return r>3&&a&&Object.defineProperty(t,i,a),a};class Ti{constructor(){this.title="",this.description="",this.actions=[],this.columns=[],this.displayedColumns=[],this.data=null,this.dataSource=null,this.refreshInterval=0,this.pageSize=0,this.rowClickable=!1,this.rowHref=null}}class Oi extends ne{constructor(){super(...arguments),this._scrollStyle="edge",this._filterPanelPos={top:0,left:0},this._resizing=null,this._resizeObserver=null,this._searchPositionLocked=!1,this._measuredColumnIds=new Set,this._model=new Ti,this.def={columns:[]},this.variant="default",this._data=[],this._dataState="idle",this._page=1,this._pageSize=50,this._totalItems=0,this._totalPages=0,this._searchQuery="",this._canScrollLeft=!1,this._canScrollRight=!1,this._canScrollHorizontal=!1,this._columnPickerOpen=!1,this._filterPanelOpened=null,this._filterPanelTab="filter",this._buckets=new Map,this._sorts=[],this._handleClickOutside=e=>{const t=e.composedPath();if(this._columnPickerOpen){const e=this.shadowRoot?.querySelector(".column-picker-wrapper");e&&!t.includes(e)&&(this._columnPickerOpen=!1)}this._filterPanelOpened&&(t.some((e=>e.classList?.contains("filter-panel")))||this._handleFilterApply())},this._handleResizeMove=e=>{if(!this._resizing)return;const t=this._model.columns.find((e=>e.id===this._resizing.columnId));if(t){const i=this._resizing.startWidth+(e.clientX-this._resizing.startX);t.width=`${Math.min(900,Math.max(50,i))}px`,this._measuredColumnIds.delete(t.id),this.requestUpdate()}},this._handleResizeEnd=()=>{this._resizing=null,document.removeEventListener("mousemove",this._handleResizeMove),document.removeEventListener("mouseup",this._handleResizeEnd)}}connectedCallback(){super.connectedCallback(),this.classList.toggle("kr-table--scroll-overlay","overlay"===this._scrollStyle),this.classList.toggle("kr-table--scroll-edge","edge"===this._scrollStyle),this._fetch(),this._initRefresh(),document.addEventListener("click",this._handleClickOutside),this._resizeObserver=new ResizeObserver((()=>{this._searchPositionLocked=!1,this._updateSearchPosition(),this._unlockColumnWidths()})),this._resizeObserver.observe(this)}disconnectedCallback(){super.disconnectedCallback(),clearInterval(this._refreshTimer),document.removeEventListener("click",this._handleClickOutside),this._resizeObserver?.disconnect()}willUpdate(e){e.has("def")&&(this._measuredColumnIds.clear(),this._model=new Ti,this._buckets=new Map,this.def.title&&(this._model.title=this.def.title),this.def.description&&(this._model.description=this.def.description),this.def.actions&&(this._model.actions=this.def.actions),this.def.data&&(this._model.data=this.def.data),this.def.dataSource&&(this._model.dataSource=this.def.dataSource),"number"==typeof this.def.refreshInterval&&(this._model.refreshInterval=this.def.refreshInterval),"number"==typeof this.def.pageSize&&(this._model.pageSize=this.def.pageSize,this._pageSize=this.def.pageSize),this.def.rowClickable&&(this._model.rowClickable=this.def.rowClickable),this.def.rowHref&&(this._model.rowHref=this.def.rowHref),this._sorts=[],this._model.columns=this.def.columns.map((e=>{const t={...e,filter:null};return t.type||(t.type="string"),e.sort&&this._sorts.push({sortBy:e.id,sortDirection:e.sort}),"actions"===t.type?(t.label=e.label??"",t.sticky="right",t.resizable=!1,t):((e.filterable||e.facetable||e.options?.length)&&(t.filter=new zi,t.filter.field=e.id,t.filter.type=t.type,e.filter?(t.filter.setOperator(e.filter.operator),t.filter.setValue(e.filter.value)):!e.facetable&&!e.options?.length||e.filterable?"string"===t.filter.type&&(t.filter.operator="contains"):(t.filter.operator="in",t.filter.value=[])),e.options?.length&&this._buckets.set(e.id,e.options.map((e=>({val:e})))),t)})),this.def.displayedColumns?this._model.displayedColumns=this.def.displayedColumns:this._model.displayedColumns=this._model.columns.map((e=>e.id)),this._fetch(),this._initRefresh())}updated(e){this.classList.toggle("kr-table--card","card"===this.variant),this._updateScrollFlags(),this._syncSlottedContent(),this._lockColumnWidths()}_lockColumnWidths(){if(0===this._data.length)return;const e=this.shadowRoot?.querySelectorAll(".header-row > .header-cell");if(!e)return;const t=this.getDisplayedColumns();e.forEach(((e,i)=>{const s=e.offsetWidth;i<t.length&&!t[i].width&&"actions"!==t[i].type&&s>0&&(t[i].width=`${s}px`,this._measuredColumnIds.add(t[i].id))}))}_unlockColumnWidths(){0!==this._measuredColumnIds.size&&(this.getDisplayedColumns().forEach((e=>{this._measuredColumnIds.has(e.id)&&(e.width=void 0)})),this._measuredColumnIds.clear(),this.requestUpdate())}_syncSlottedContent(){const e=this.getDisplayedColumns().filter((e=>e.render));e.length&&(this.querySelectorAll('[slot^="cell-"]').forEach((e=>e.remove())),this._data.forEach(((t,i)=>{e.forEach((e=>{const s=e.render(t);if(!s)return;const o=document.createElement("span");o.slot=`cell-${i}-${e.id}`,"actions"===e.type&&(o.style.display="flex",o.style.gap="8px"),"string"==typeof s?o.innerHTML=s:re(s,o),this.appendChild(o)}))})))}refresh(){this._fetch()}goToPrevPage(){this._page>1&&(this._page--,this._fetch())}goToNextPage(){this._page<this._totalPages&&(this._page++,this._fetch())}goToPage(e){e>=1&&e<=this._totalPages&&(this._page=e,this._fetch())}_toSolrData(){const e={page:this._page-1,size:this._pageSize,sorts:this._sorts,filterFields:[],queryFields:[],facetFields:[]};for(const t of this._model.columns){if(!t.filter||t.filter.isEmpty()||!t.filter.isValid())continue;const i=t.filter.toSolrData();!t.facetable||"in"!==t.filter.operator&&"n_in"!==t.filter.operator||(i.tagged=!0),e.filterFields.push(i)}for(const t of this._model.columns)t.facetable&&e.facetFields.push({name:t.id,type:"FIELD",limit:100,sort:"count",minimumCount:1});return this._searchQuery?.trim().length&&e.queryFields.push({name:"_text_",operation:"IS",value:wi(this._searchQuery,!1)}),e}_toDbParams(){const e={page:this._page-1,size:this._pageSize,sorts:this._sorts,filterFields:[],queryFields:[],facetFields:[]};for(const t of this._model.columns)t.filter&&!t.filter.isEmpty()&&t.filter.isValid()&&e.filterFields.push(t.filter.toDbParams());return this._searchQuery?.trim().length&&this._model.columns.filter((e=>e.searchable)).forEach((t=>{e.queryFields.push({name:t.id,operation:"CONTAINS",value:this._searchQuery,and:!1})})),e}_fetch(){if(this._model.data)return this._data=this._model.data,this._totalItems=this._model.data.length,this._totalPages=Math.ceil(this._model.data.length/this._pageSize),void(this._dataState="success");if(!this._model.dataSource)return;let e;this._dataState="loading",e="db"===this._model.dataSource.mode?this._toDbParams():this._toSolrData(),this._model.dataSource.fetch(e).then((e=>{switch(this._model.dataSource?.mode){case"opensearch":throw Error("Opensearch not supported yet");case"db":{const t=e;this._data=t.data.content,this._totalItems=t.data.totalElements,this._totalPages=t.data.totalPages,this._pageSize=t.data.size;break}default:{const t=e;this._data=t.data.content,this._totalItems=t.data.totalElements,this._totalPages=t.data.totalPages,this._pageSize=t.data.size,this._parseFacetResults(t)}}this._dataState="success",this._updateSearchPosition()})).catch((e=>{this._dataState="error";let t="Failed to load data";e instanceof Error&&(t=e.message),hi.show({message:t,type:"error"})}))}_parseFacetResults(e){if(e.data.facetFields){for(const t of this._model.columns){if(!t.facetable)continue;const i=e.data.facetFields[t.id];if(!i){this._buckets.set(t.id,[]);continue}const s=[];for(const e of i){let i=e.name;"boolean"===t.type&&"string"==typeof e.name&&("true"===e.name?i=!0:"false"===e.name&&(i=!1)),null===e.name&&e.count>0&&s.unshift({val:null,count:e.count}),null!==e.name&&s.push({val:i,count:e.count})}if(t.filter&&("in"===t.filter.operator||"n_in"===t.filter.operator)&&Array.isArray(t.filter.value))for(const e of t.filter.value)s.some((t=>t.val===e))||s.push({val:e,count:0});this._buckets.set(t.id,s)}this._buckets=new Map(this._buckets)}}_initRefresh(){clearInterval(this._refreshTimer),this._model.refreshInterval&&this._model.refreshInterval>0&&(this._refreshTimer=window.setInterval((()=>{this._fetch()}),this._model.refreshInterval))}_handleSearch(e){const t=e.target;this._searchQuery=t.value,this._page=1,this._fetch()}_updateSearchPosition(){if(this._searchPositionLocked)return;if("card"===this.variant)return;const e=this.shadowRoot?.querySelector(".search"),t=e?.querySelector(".search-field");e&&t&&(e.style.justifyContent="center",t.style.marginLeft="",requestAnimationFrame((()=>{const i=e.getBoundingClientRect(),s=t.getBoundingClientRect().left-i.left;e.style.justifyContent="flex-start",t.style.marginLeft=`${s}px`,this._searchPositionLocked=!0})))}_handleColumnPickerClick(){this._columnPickerOpen=!this._columnPickerOpen}_handleColumnToggle(e){this._model.displayedColumns.includes(e)?this._model.displayedColumns=this._model.displayedColumns.filter((t=>t!==e)):this._model.displayedColumns=[...this._model.displayedColumns,e],this.requestUpdate()}_handleRowMouseDown(){(this._model.rowClickable||this._model.rowHref)&&window.getSelection()?.removeAllRanges()}_handleRowClick(e,t,i){if(!this._model.rowClickable&&!this._model.rowHref)return;const s=window.getSelection();s&&s.toString().length>0?e.preventDefault():this.dispatchEvent(new CustomEvent("row-click",{detail:{row:t,rowIndex:i},bubbles:!0,composed:!0}))}getDisplayedColumns(){return this._model.displayedColumns.map((e=>this._model.columns.find((t=>t.id===e)))).sort(((e,t)=>"actions"===e.type&&"actions"!==t.type?1:"actions"!==e.type&&"actions"===t.type?-1:0))}_handleScroll(e){const t=e.target;this._canScrollLeft=t.scrollLeft>0,this._canScrollRight=t.scrollLeft<t.scrollWidth-t.clientWidth-1}_updateScrollFlags(){const e=this.shadowRoot?.querySelector(".content");e&&(this._canScrollLeft=e.scrollLeft>0,this._canScrollRight=e.scrollWidth>e.clientWidth&&e.scrollLeft<e.scrollWidth-e.clientWidth-1,this._canScrollHorizontal=e.scrollWidth>e.clientWidth),this.classList.toggle("kr-table--scroll-left-available",this._canScrollLeft),this.classList.toggle("kr-table--scroll-right-available",this._canScrollRight),this.classList.toggle("kr-table--scroll-horizontal-available",this._canScrollHorizontal),this.classList.toggle("kr-table--sticky-left",this.getDisplayedColumns().some((e=>"left"===e.sticky))),this.classList.toggle("kr-table--sticky-right",this.getDisplayedColumns().some((e=>"right"===e.sticky)))}_handleResizeStart(e,t){e.preventDefault(),this.getDisplayedColumns().forEach((e=>{if(e.width||"actions"===e.type)return;const t=this.shadowRoot?.querySelector(`.header-cell[data-column-id="${e.id}"]`);t?.offsetWidth&&(e.width=`${t.offsetWidth}px`)}));const i=this.shadowRoot?.querySelector(`.header-cell[data-column-id="${t}"]`);this._resizing={columnId:t,startX:e.clientX,startWidth:i?.offsetWidth||200},document.addEventListener("mousemove",this._handleResizeMove),document.addEventListener("mouseup",this._handleResizeEnd)}_handleSortClick(e,t){if(e.shiftKey){const e=this._sorts.findIndex((e=>e.sortBy===t.id));if(-1===e)this._sorts.push({sortBy:t.id,sortDirection:"asc"});else{const t=this._sorts[e];"asc"===t.sortDirection?t.sortDirection="desc":this._sorts.splice(e,1)}this.requestUpdate()}else{let e=null;1===this._sorts.length&&(e=this._sorts.find((e=>e.sortBy===t.id))),e?"asc"===e.sortDirection?this._sorts=[{sortBy:t.id,sortDirection:"desc"}]:this._sorts=[]:this._sorts=[{sortBy:t.id,sortDirection:"asc"}]}this._page=1,this._fetch()}_renderSortIndicator(e){if(!e.sortable)return U;const t=this._sorts.findIndex((t=>t.sortBy===e.id));if(-1===t)return N`
2261
+ `],bi.formAssociated=!0,mi([ce({type:String})],bi.prototype,"label",void 0),mi([ce({type:String})],bi.prototype,"name",void 0),mi([ce({type:String})],bi.prototype,"value",void 0),mi([ce({type:String})],bi.prototype,"placeholder",void 0),mi([ce({type:Boolean})],bi.prototype,"disabled",void 0),mi([ce({type:Boolean})],bi.prototype,"required",void 0),mi([ce({type:Boolean})],bi.prototype,"readonly",void 0),mi([ce({type:String})],bi.prototype,"hint",void 0),mi([ce({type:Boolean,reflect:!0})],bi.prototype,"dirty",void 0),mi([ce({attribute:"save-mode"})],bi.prototype,"saveMode",void 0),mi([ce({type:Boolean,reflect:!0})],bi.prototype,"saving",void 0),mi([pe()],bi.prototype,"_isOpen",void 0),mi([pe()],bi.prototype,"_highlightedIndex",void 0),mi([pe()],bi.prototype,"_touched",void 0),mi([ue(".select-trigger")],bi.prototype,"_triggerElement",void 0),customElements.get("krs-select-field")||customElements.define("krs-select-field",bi);const _i={equals:{key:"equals",type:"comparison",dataTypes:["string","number","date","boolean"],label:"Equals"},n_equals:{key:"n_equals",type:"comparison",dataTypes:["string","number","date","boolean"],label:"Doesn't equal"},contains:{key:"contains",type:"comparison",dataTypes:["string"],label:"Contains"},n_contains:{key:"n_contains",type:"comparison",dataTypes:["string"],label:"Doesn't contain"},starts_with:{key:"starts_with",type:"comparison",dataTypes:["string"],label:"Starts with"},ends_with:{key:"ends_with",type:"comparison",dataTypes:["string"],label:"Ends with"},less_than:{key:"less_than",type:"comparison",dataTypes:["number","date"],label:"Less than"},less_than_equal:{key:"less_than_equal",type:"comparison",dataTypes:["number","date"],label:"Less than or equal"},greater_than:{key:"greater_than",type:"comparison",dataTypes:["number","date"],label:"Greater than"},greater_than_equal:{key:"greater_than_equal",type:"comparison",dataTypes:["number","date"],label:"Greater than or equal"},between:{key:"between",type:"range",dataTypes:["number","date"],label:"Between"},in:{key:"in",type:"list",dataTypes:["string","number"],label:"In"},n_in:{key:"n_in",type:"list",dataTypes:["string","number","date","boolean"],label:"Not In"},empty:{key:"empty",type:"nil",dataTypes:["string","number","date","boolean"],label:"Empty"},n_empty:{key:"n_empty",type:"nil",dataTypes:["string","number","date","boolean"],label:"Not empty"}};function yi(e){const t=[];for(const i of Object.values(_i))i.dataTypes.includes(e)&&t.push({key:i.key,label:i.label});return t}const ki=['"',"+","-","&&","||","!","(",")","{","}","[","]","^","~","*","?",":"],xi=['\\"',"\\+","\\-","\\&\\&","\\|\\|","\\!","\\(","\\)","\\{","\\}","\\[","\\]","\\^","\\~","\\*","\\?","\\:"];function wi(e,t=!0){return!0===e||!1===e?e.toString():null===e?"(*:* NOT *)":"number"==typeof e?e.toString():"string"==typeof e?(ki.forEach(((t,i)=>{var s;e=e.replace(new RegExp(`${s=t,"string"!=typeof s?s:s.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")}`,"g"),xi[i])})),t?`"${e}"`:e.replace(/ /g,"\\ ")):e}function $i(e,t=!1){const i=new Date(e);return i.setMinutes(i.getMinutes()-i.getTimezoneOffset()),t&&(i.setUTCHours(23),i.setUTCMinutes(59),i.setUTCSeconds(59),i.setUTCMilliseconds(999)),i.toISOString().replace(/:/g,"\\:")}function Si(e,t){let i,s,o,r;if(e&&"start"in e&&"end"in e)i=new Date(e.start),s=new Date(e.end),o=t[0],r=t[1];else{if(!(e instanceof Date))return"[* TO *]";i=new Date(e),s=new Date(e),o=t[0],r=t[0]}return"year"===o?(i.setUTCMonth(0,1),i.setUTCHours(0,0,0,0)):"month"===o?(i.setUTCDate(1),i.setUTCHours(0,0,0,0)):"day"===o?i.setUTCHours(0,0,0,0):"time"===o&&i.setUTCSeconds(0,0),"year"===r?(s.setUTCMonth(11,31),s.setUTCHours(23,59,59,999)):"month"===r?(s.setUTCMonth(s.getUTCMonth()+1),s.setUTCDate(0),s.setUTCHours(23,59,59,999)):"day"===r?s.setUTCHours(23,59,59,999):"time"===r&&s.setUTCSeconds(59,999),`[${i.toISOString().replace(/:/g,"\\:")} TO ${s.toISOString().replace(/:/g,"\\:")}]`}function Ci(e,t){let i,s,o,r,a,n;return e&&"start"in e&&"end"in e?(i=new Date(e.start),s=new Date(e.end),o=t[0],r=t[1]):(i=new Date(e),s=new Date(e),o=t[0],r=t[0]),"year"===o?(i.setUTCMonth(0,1),i.setUTCHours(0,0,0,0),a=i):"month"===o?(i.setUTCDate(1),i.setUTCHours(0,0,0,0),a=i):"day"===o?(i.setUTCHours(0,0,0,0),a=i):"time"===o?(i.setUTCSeconds(0,0),a=i):a=i,"year"===r?(s.setUTCMonth(11,31),s.setUTCHours(23,59,59,999),n=s):"month"===r?(s.setUTCMonth(s.getUTCMonth()+1),s.setUTCDate(0),s.setUTCHours(23,59,59,999),n=s):"day"===r?(s.setUTCHours(23,59,59,999),n=s):"time"===r?(s.setUTCSeconds(59,999),n=s):n=s,[a.toISOString().replace(/\..+/,"").replace("T"," "),n.toISOString().replace(/\..+/,"").replace("T"," ")]}function Ei(e){return e=e.trim(),/^(\d{1,2})\/(\d{1,2})\/(\d{2})$/.test(e)||/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/.test(e)?"day":/^(\d{1,2})\/(\d{1,2})\/(\d{4}),?\s+(\d{1,2}):(\d{2})\s*(AM|PM)?$/i.test(e)||/^(?:[A-Za-z]+,\s+)?([A-Za-z]+)\s+(\d{1,2}),?\s+(\d{4}),?\s+(\d{1,2}):(\d{2})\s*(AM|PM)?$/i.test(e)?"time":/^(?:[A-Za-z]+,\s+)?([A-Za-z]+)\s+(\d{1,2}),?\s+(\d{4})$/.test(e)?"day":/^(\d{2})$/.test(e)||/^(\d{4})$/.test(e)?"year":/^([A-Za-z]+)\s+(\d{4})$/.test(e)?"month":null}class zi{constructor(){this.field="",this.operator="equals",this.value=null,this.kql="",this.text="",this.type="",this.specificity=[]}setKql(e){if(this.kql=e.trim(),this.text="",this.specificity=[],this.value=null,this.kql)if(e.startsWith("="))this.operator="equals",this.text=e.substring(1).trim(),this.value=this._parse(this.text),this.specificity=[Ei(this.text)];else if(e.startsWith("!="))this.operator="n_equals",this.text=e.substring(2).trim(),this.value=this._parse(this.text),this.specificity=[Ei(this.text)];else if(e.startsWith("~")&&"string"===this.type)this.operator="contains",this.text=e.substring(1).trim(),this.value=this._parse(this.text),this.specificity=[Ei(this.text)];else if(e.startsWith("!~")&&"string"===this.type)this.operator="n_contains",this.text=e.substring(2).trim(),this.value=this._parse(this.text),this.specificity=[Ei(this.text)];else if(e.endsWith("*")&&"string"===this.type)this.operator="starts_with",this.text=e.substring(0,e.length-1),this.value=this._parse(this.text),this.specificity=[Ei(this.text)];else if(e.startsWith("*")&&"string"===this.type)this.operator="ends_with",this.text=e.substring(1),this.value=this._parse(this.text),this.specificity=[Ei(this.text)];else if("EMPTY"===e)this.operator="empty",this.value=null,this.specificity=[];else if("NOT EMPTY"===e)this.operator="n_empty",this.value=null,this.specificity=[];else if(e.startsWith("<="))this.operator="less_than_equal",this.text=e.substring(2).trim(),this.value=this._parse(this.text),this.specificity=[Ei(this.text)];else if(e.startsWith("<"))this.operator="less_than",this.text=e.substring(1).trim(),this.value=this._parse(this.text),this.specificity=[Ei(this.text)];else if(e.startsWith(">="))this.operator="greater_than_equal",this.text=e.substring(2).trim(),this.value=this._parse(this.text),this.specificity=[Ei(this.text)];else if(e.startsWith(">"))this.operator="greater_than",this.text=e.substring(1).trim(),this.value=this._parse(this.text),this.specificity=[Ei(this.text)];else if(e.startsWith("[")&&e.endsWith("]")&&e.indexOf(" TO ")>-1){this.operator="between";const t=e.indexOf(" TO "),i=e.substring(1,t).trim(),s=e.substring(t+4,e.length-1).trim();this.text=`${i} - ${s}`,this.value={start:this._parse(i),end:this._parse(s)},this.specificity=[Ei(i),Ei(s)]}else e.startsWith("!(")&&e.endsWith(")")?(this.operator="n_in",this.text=e.substring(2,e.length-1).trim(),this.value=this.text.split(",").map((e=>e.trim())).map((e=>this._parse(e))),this.specificity=[Ei(this.text)]):e.startsWith("(")&&e.endsWith(")")?(this.operator="in",this.text=e.substring(1,e.length-1).trim(),this.value=this.text.split(",").map((e=>e.trim())).map((e=>this._parse(e))),this.specificity=[Ei(this.text)]):"date"===this.type||"boolean"===this.type||"number"===this.type?(this.operator="equals",this.text=this.kql,this.value=this._parse(this.text),this.specificity=[Ei(this.text)]):(this.operator="contains",this.text=e,this.value=this._parse(this.text),this.specificity=[Ei(this.text)]);else"string"===this.type?this.operator="contains":this.operator="equals"}setOperator(e){"empty"===this.operator||"n_empty"===this.operator||"between"===this.operator?(this.value=null,this.text=""):"in"!==this.operator&&"n_in"!==this.operator||(this.value=[],this.text=""),this.operator=e,"empty"===this.operator?(this.value="EMPTY",this.text="EMPTY"):"n_empty"===this.operator?(this.value="NOT EMPTY",this.text="NOT EMPTY"):"between"===this.operator?(this.value=null,this.text=""):"in"!==this.operator&&"n_in"!==this.operator||(this.value=[],this.text=""),this._buildKql()}setValue(e,t){this.value=e,t?this.specificity=[t]:e instanceof Date?this.specificity=["time"]:this.specificity=[],this._buildText(),this._buildKql()}setStart(e,t){void 0===this.value?.start&&(this.value={start:null,end:null}),this.value.start=e,t?this.specificity[0]=t:e instanceof Date&&(this.specificity[0]="time"),this._buildText(),this._buildKql()}setEnd(e,t){void 0===this.value?.end&&(this.value={start:null,end:null}),this.value.end=e,t?this.specificity[1]=t:e instanceof Date&&(this.specificity[1]="time"),this._buildText(),this._buildKql()}clear(){"string"===this.type?this.operator="contains":this.operator="equals",this.value=null,this.kql="",this.text="",this.specificity=[]}isEmpty(){return"empty"===this.operator||"n_empty"===this.operator?!this.text:"between"===this.operator?!this.value?.start&&!this.value?.end:"in"===this.operator||"n_in"===this.operator?!this.value?.length:void 0===this.value||null===this.value||""===this.value}has(e){return!("in"!==this.operator&&"n_in"!==this.operator||!Array.isArray(this.value))&&("boolean"===this.type&&"string"==typeof e&&("true"===e?e=!0:"false"===e&&(e=!1)),this.value.indexOf(e)>=0)}toggle(e){"in"!==this.operator&&"n_in"!==this.operator&&this.setOperator("in"),"boolean"===this.type&&"string"==typeof e&&("true"===e?e=!0:"false"===e&&(e=!1));const t=this.value.indexOf(e);t>=0?this.value.splice(t,1):this.value.push(e),this._buildText(),this._buildKql()}isValid(){return!this.kql||!!this.field&&(!!this.operator&&("empty"===this.operator||("n_empty"===this.operator||("in"===this.operator||"n_in"===this.operator?Array.isArray(this.value)&&this.value.length>0:"date"===this.type?"between"===this.operator?this.value?.start instanceof Date&&this.value?.end instanceof Date&&!isNaN(this.value.start.getTime())&&!isNaN(this.value.end.getTime()):this.value instanceof Date&&!isNaN(this.value.getTime()):"number"===this.type?"between"===this.operator?"number"==typeof this.value?.start&&"number"==typeof this.value?.end:"number"==typeof this.value:"boolean"===this.type?"boolean"==typeof this.value:"string"==typeof this.value&&!!this.value.trim().length))))}toSolrData(){const e={boost:null,fuzzy:null,not:!1,name:null,operation:null,tagged:!1,value:null};switch(e.name=this.field,this.operator){case"equals":this.value instanceof Date?(e.operation="EXPRESSION",e.value=Si(this.value,this.specificity)):(e.operation="IS",e.value=this.value);break;case"n_equals":this.value instanceof Date?(e.operation="EXPRESSION",e.not=!0,e.value=Si(this.value,this.specificity)):(e.operation="IS",e.not=!0,e.value=this.value);break;case"contains":e.operation="EXPRESSION",e.value=`*${wi(this.value,!1)}*`;break;case"n_contains":e.operation="EXPRESSION",e.not=!0,e.value=`*${wi(this.value,!1)}*`;break;case"starts_with":e.operation="EXPRESSION",e.value=`${wi(this.value,!1)}*`;break;case"ends_with":e.operation="EXPRESSION",e.value=`*${wi(this.value,!1)}`;break;case"empty":e.operation="EXPRESSION",e.not=!0,e.value="[* TO *]";break;case"n_empty":e.operation="EXPRESSION",e.value="[* TO *]";break;case"less_than":this.value instanceof Date?(e.operation="EXPRESSION",e.value=`[* TO ${$i(this.value)}}`):(e.operation="EXPRESSION",e.value=`[* TO ${wi(this.value,!0)}}`);break;case"less_than_equal":this.value instanceof Date?(e.operation="EXPRESSION",e.value=`[* TO ${$i(this.value,!0)}]`):(e.operation="EXPRESSION",e.value=`[* TO ${wi(this.value,!0)}]`);break;case"greater_than":this.value instanceof Date?(e.operation="EXPRESSION",e.value=`{${$i(this.value,!0)} TO *]`):(e.operation="EXPRESSION",e.value=`{${wi(this.value,!0)} TO *]`);break;case"greater_than_equal":this.value instanceof Date?(e.operation="EXPRESSION",e.value=`[${$i(this.value)} TO *]`):(e.operation="EXPRESSION",e.value=`[${wi(this.value,!0)} TO *]`);break;case"between":this.value?.start instanceof Date&&this.value?.end instanceof Date?(e.operation="EXPRESSION",e.value=Si(this.value,this.specificity)):(e.operation="EXPRESSION",e.value=`[${this.value.start} TO ${this.value.end}]`);break;case"in":Array.isArray(this.value)&&this.value.length>0?(e.operation="EXPRESSION",e.value=`(${this.value.map((e=>wi(e,!0))).join(" OR ")})`):(e.operation="EXPRESSION",e.value=wi(this.value,!0));break;case"n_in":Array.isArray(this.value)&&this.value.length>0?(e.operation="EXPRESSION",e.not=!0,e.value=`(${this.value.map((e=>wi(e,!0))).join(" OR ")})`):(e.operation="EXPRESSION",e.not=!0,e.value=wi(this.value,!0));break;default:e.operation="EXPRESSION",e.value=wi(this.value,!0)}return e}toDbParams(){const e={boost:null,fuzzy:null,not:!1,name:null,operation:null,tagged:!1,value:null,values:null};switch(e.name=this.field,this.operator){case"equals":"date"===this.type?(e.operation="BETWEEN",e.values=Ci(this.value,this.specificity)):(e.operation="IS",e.value=this.value);break;case"n_equals":"date"===this.type?(e.operation="BETWEEN",e.not=!0,e.values=Ci(this.value,this.specificity)):(e.operation="IS",e.value=this.value,e.not=!0);break;case"contains":e.operation="CONTAINS",e.value=this.value;break;case"n_contains":e.operation="CONTAINS",e.value=this.value,e.not=!0;break;case"starts_with":e.operation="STARTS_WITH",e.value=this.value;break;case"ends_with":e.operation="ENDS_WITH",e.value=this.value;break;case"empty":e.operation="IS_BLANK";break;case"n_empty":e.operation="IS_NOT_BLANK";break;case"less_than":e.operation="LESS_THAN",e.value=this.value;break;case"less_than_equal":e.operation="LESS_THAN_EQUAL",e.value=this.value;break;case"greater_than":e.operation="GREATER_THAN",e.value=this.value;break;case"greater_than_equal":e.operation="GREATER_THAN_EQUAL",e.value=this.value;break;case"between":e.operation="BETWEEN","date"===this.type?e.values=Ci(this.value,this.specificity):e.values=[this.value.start,this.value.end];break;case"in":e.operation="IN",e.values=this.value??[];break;case"n_in":e.operation="IN",e.not=!0,e.values=this.value??[];break;default:throw Error(`${this.operator} operator not supported by db params.`)}return e}toOpensearchData(){switch(this.operator){case"equals":return{term:{[this.field]:this.value}};case"n_equals":return{bool:{must_not:[{term:{[this.field]:this.value}}]}};case"contains":return{wildcard:{[this.field]:{value:`*${this.value}*`,case_insensitive:!0}}};case"n_contains":return{bool:{must_not:[{wildcard:{[this.field]:{value:`*${this.value}*`,case_insensitive:!0}}}]}};case"starts_with":return{wildcard:{[this.field]:{value:`${this.value}*`,case_insensitive:!0}}};case"ends_with":return{wildcard:{[this.field]:{value:`*${this.value}`,case_insensitive:!0}}};case"empty":return{bool:{must_not:[{exists:{field:this.field}}]}};case"n_empty":return{exists:{field:this.field}};case"less_than":return{range:{[this.field]:{lt:this.value}}};case"less_than_equal":return{range:{[this.field]:{lte:this.value}}};case"greater_than":return{range:{[this.field]:{gt:this.value}}};case"greater_than_equal":return{range:{[this.field]:{gte:this.value}}};case"between":return{range:{[this.field]:{gte:this.value?.start,lte:this.value?.end}}};case"in":return{terms:{[this.field]:this.value??[]}};case"n_in":return{bool:{must_not:[{terms:{[this.field]:this.value??[]}}]}};default:throw Error(`${this.operator} operator not supported by opensearch data.`)}}_buildText(){this.isEmpty()?this.text="":"between"===this.operator?this.text=`${this._format(this.value?.start)} - ${this._format(this.value?.end)}`:"in"===this.operator||"n_in"===this.operator?this.text=this.value.map((e=>this._format(e))).join(","):this.text=this._format(this.value)}_format(e){if(e instanceof Date&&!isNaN(e.getTime())){return`${String(e.getUTCMonth()+1).padStart(2,"0")}/${String(e.getUTCDate()).padStart(2,"0")}/${e.getUTCFullYear()}`}return"boolean"==typeof e?e?"Yes":"No":String(e??"")}_parse(e){if(null==e||""===e)return null;if(this.type)switch(this.type){case"boolean":{const t=e.toString().toLowerCase();return!0===e||!1!==e&&("yes"===t||"no"!==t&&("1"===t||"0"!==t&&null))}case"date":return this._parseDate(e);case"number":{const t=Number(e.toString().replace(/[$,]+/g,""));return isNaN(t)?null:t}default:return e.toString()}return e}_parseDate(e){if(null==e||""===e)return null;const t={jan:0,january:0,feb:1,february:1,mar:2,march:2,apr:3,april:3,may:4,jun:5,june:5,jul:6,july:6,aug:7,august:7,sep:8,september:8,oct:9,october:9,nov:10,november:10,dec:11,december:11};let i;if(i=e.match(/^(\d{1,2})\/(\d{1,2})\/(\d{2})$/),i)return new Date(Date.UTC(2e3+parseInt(i[3]),parseInt(i[1])-1,parseInt(i[2])));if(i=e.match(/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/),i)return new Date(Date.UTC(parseInt(i[3]),parseInt(i[1])-1,parseInt(i[2])));if(i=e.match(/^(\d{1,2})\/(\d{1,2})\/(\d{4}),?\s+(\d{1,2}):(\d{2})\s*(AM|PM)?$/i),i){let e=parseInt(i[4]);return i[6]&&("PM"===i[6].toUpperCase()&&12!==e&&(e+=12),"AM"===i[6].toUpperCase()&&12===e&&(e=0)),new Date(Date.UTC(parseInt(i[3]),parseInt(i[1])-1,parseInt(i[2]),e,parseInt(i[5])))}if(i=e.match(/^(?:[A-Za-z]+,\s+)?([A-Za-z]+)\s+(\d{1,2}),?\s+(\d{4}),?\s+(\d{1,2}):(\d{2})\s*(AM|PM)?$/i),i){const e=t[i[1].toLowerCase()];if(void 0!==e){let t=parseInt(i[4]);return i[6]&&("PM"===i[6].toUpperCase()&&12!==t&&(t+=12),"AM"===i[6].toUpperCase()&&12===t&&(t=0)),new Date(Date.UTC(parseInt(i[3]),e,parseInt(i[2]),t,parseInt(i[5])))}}if(i=e.match(/^(?:[A-Za-z]+,\s+)?([A-Za-z]+)\s+(\d{1,2}),?\s+(\d{4})$/),i){const e=t[i[1].toLowerCase()];if(void 0!==e)return new Date(Date.UTC(parseInt(i[3]),e,parseInt(i[2])))}if(i=e.match(/^(\d{2})$/),i)return new Date(Date.UTC(2e3+parseInt(i[1]),0,1));if(i=e.match(/^(\d{4})$/),i)return new Date(Date.UTC(parseInt(i[1]),0,1));if(i=e.match(/^([A-Za-z]+)\s+(\d{4})$/),i){const e=t[i[1].toLowerCase()];if(void 0!==e)return new Date(Date.UTC(parseInt(i[2]),e,1))}return null}_buildKql(){if(this.isEmpty())this.kql="";else switch(this.operator){case"equals":this.kql=`= ${this.text}`;break;case"n_equals":this.kql=`!= ${this.text}`;break;case"contains":this.kql=`~ ${this.text}`;break;case"n_contains":this.kql=`!~ ${this.text}`;break;case"starts_with":this.kql=`${this.text}*`;break;case"ends_with":this.kql=`*${this.text}`;break;case"empty":this.kql="EMPTY";break;case"n_empty":this.kql="NOT EMPTY";break;case"less_than":this.kql=`< ${this.text}`;break;case"less_than_equal":this.kql=`<= ${this.text}`;break;case"greater_than":this.kql=`> ${this.text}`;break;case"greater_than_equal":this.kql=`>= ${this.text}`;break;case"between":this.kql=`[${this._format(this.value?.start??"")} TO ${this._format(this.value?.end??"")}]`;break;case"in":this.kql=`(${this.value.map((e=>this._format(e))).join(",")})`;break;case"n_in":this.kql=`!(${this.value.map((e=>this._format(e))).join(",")})`;break;default:throw Error(`Unknown operator ${this.operator}`)}}}var Di=function(e,t,i,s){var o,r=arguments.length,a=r<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,i,s);else for(var n=e.length-1;n>=0;n--)(o=e[n])&&(a=(r<3?o(a):r>3?o(t,i,a):o(t,i))||a);return r>3&&a&&Object.defineProperty(t,i,a),a};class Ti{constructor(){this.title="",this.description="",this.actions=[],this.columns=[],this.displayedColumns=[],this.data=null,this.dataSource=null,this.refreshInterval=0,this.pageSize=0,this.rowClickable=!1,this.rowHref=null}}class Oi extends ne{constructor(){super(...arguments),this._scrollStyle="edge",this._filterPanelPos={top:0,left:0},this._resizing=null,this._resizeObserver=null,this._searchPositionLocked=!1,this._measuredColumnIds=new Set,this._model=new Ti,this.def={columns:[]},this.variant="default",this._data=[],this._dataState="idle",this._page=1,this._pageSize=50,this._totalItems=0,this._totalPages=0,this._searchQuery="",this._canScrollLeft=!1,this._canScrollRight=!1,this._canScrollHorizontal=!1,this._columnPickerOpen=!1,this._filterPanelOpened=null,this._filterPanelTab="filter",this._buckets=new Map,this._sorts=[],this._handleClickOutside=e=>{const t=e.composedPath();if(this._columnPickerOpen){const e=this.shadowRoot?.querySelector(".column-picker-wrapper");e&&!t.includes(e)&&(this._columnPickerOpen=!1)}this._filterPanelOpened&&(t.some((e=>e.classList?.contains("filter-panel")))||this._handleFilterApply())},this._handleResizeMove=e=>{if(!this._resizing)return;const t=this._model.columns.find((e=>e.id===this._resizing.columnId));if(t){const i=this._resizing.startWidth+(e.clientX-this._resizing.startX);t.width=`${Math.min(900,Math.max(50,i))}px`,this._measuredColumnIds.delete(t.id),this.requestUpdate()}},this._handleResizeEnd=()=>{this._resizing=null,document.removeEventListener("mousemove",this._handleResizeMove),document.removeEventListener("mouseup",this._handleResizeEnd)}}connectedCallback(){super.connectedCallback(),this.classList.toggle("kr-table--scroll-overlay","overlay"===this._scrollStyle),this.classList.toggle("kr-table--scroll-edge","edge"===this._scrollStyle),this._fetch(),this._initRefresh(),document.addEventListener("click",this._handleClickOutside),this._resizeObserver=new ResizeObserver((()=>{this._searchPositionLocked=!1,this._updateSearchPosition(),this._unlockColumnWidths()})),this._resizeObserver.observe(this)}disconnectedCallback(){super.disconnectedCallback(),clearInterval(this._refreshTimer),document.removeEventListener("click",this._handleClickOutside),this._resizeObserver?.disconnect()}willUpdate(e){e.has("def")&&(this._measuredColumnIds.clear(),this._model=new Ti,this._buckets=new Map,this.def.title&&(this._model.title=this.def.title),this.def.description&&(this._model.description=this.def.description),this.def.actions&&(this._model.actions=this.def.actions),this.def.data&&(this._model.data=this.def.data),this.def.dataSource&&(this._model.dataSource=this.def.dataSource),"number"==typeof this.def.refreshInterval&&(this._model.refreshInterval=this.def.refreshInterval),"number"==typeof this.def.pageSize&&(this._model.pageSize=this.def.pageSize,this._pageSize=this.def.pageSize),this.def.rowClickable&&(this._model.rowClickable=this.def.rowClickable),this.def.rowHref&&(this._model.rowHref=this.def.rowHref),this._sorts=[],this._model.columns=this.def.columns.map((e=>{const t={...e,filter:null};return t.type||(t.type="string"),e.sort&&this._sorts.push({sortBy:e.id,sortDirection:e.sort}),"actions"===t.type?(t.label=e.label??"",t.sticky="right",t.resizable=!1,t):((e.filterable||e.facetable||e.options?.length)&&(t.filter=new zi,t.filter.field=e.id,t.filter.type=t.type,e.filter?(t.filter.setOperator(e.filter.operator),t.filter.setValue(e.filter.value)):!e.facetable&&!e.options?.length||e.filterable?"string"===t.filter.type&&(t.filter.operator="contains"):(t.filter.operator="in",t.filter.value=[])),e.options?.length&&this._buckets.set(e.id,e.options.map((e=>({val:e})))),t)})),this.def.displayedColumns?this._model.displayedColumns=this.def.displayedColumns:this._model.displayedColumns=this._model.columns.map((e=>e.id)),this._fetch(),this._initRefresh())}updated(e){this.classList.toggle("kr-table--card","card"===this.variant),this._updateScrollFlags(),this._syncSlottedContent(),this._lockColumnWidths()}_lockColumnWidths(){if(0===this._data.length)return;const e=this.shadowRoot?.querySelectorAll(".header-row > .header-cell");if(!e)return;const t=this.getDisplayedColumns();e.forEach(((e,i)=>{const s=e.offsetWidth;i<t.length&&!t[i].width&&"actions"!==t[i].type&&s>0&&(t[i].width=`${s}px`,this._measuredColumnIds.add(t[i].id))}))}_unlockColumnWidths(){0!==this._measuredColumnIds.size&&(this.getDisplayedColumns().forEach((e=>{this._measuredColumnIds.has(e.id)&&(e.width=void 0)})),this._measuredColumnIds.clear(),this.requestUpdate())}_syncSlottedContent(){const e=this.getDisplayedColumns().filter((e=>e.render));e.length&&(this.querySelectorAll('[slot^="cell-"]').forEach((e=>e.remove())),this._data.forEach(((t,i)=>{e.forEach((e=>{const s=e.render(t);if(!s)return;const o=document.createElement("span");o.slot=`cell-${i}-${e.id}`,"actions"===e.type&&(o.style.display="flex",o.style.gap="8px"),"string"==typeof s?o.innerHTML=s:re(s,o),this.appendChild(o)}))})))}refresh(){this._fetch()}goToFirstPage(){this._page>1&&(this._page=1,this._fetch())}goToPrevPage(){this._page>1&&(this._page--,this._fetch())}goToNextPage(){this._page<this._totalPages&&(this._page++,this._fetch())}goToLastPage(){this._page<this._totalPages&&(this._page=this._totalPages,this._fetch())}goToPage(e){e>=1&&e<=this._totalPages&&(this._page=e,this._fetch())}_toSolrData(){const e={page:this._page-1,size:this._pageSize,sorts:this._sorts,filterFields:[],queryFields:[],facetFields:[]};for(const t of this._model.columns){if(!t.filter||t.filter.isEmpty()||!t.filter.isValid())continue;const i=t.filter.toSolrData();!t.facetable||"in"!==t.filter.operator&&"n_in"!==t.filter.operator||(i.tagged=!0),e.filterFields.push(i)}for(const t of this._model.columns)t.facetable&&e.facetFields.push({name:t.id,type:"FIELD",limit:100,sort:"count",minimumCount:1});return this._searchQuery?.trim().length&&e.queryFields.push({name:"_text_",operation:"IS",value:wi(this._searchQuery,!1)}),e}_toDbParams(){const e={page:this._page-1,size:this._pageSize,sorts:this._sorts,filterFields:[],queryFields:[],facetFields:[]};for(const t of this._model.columns)t.filter&&!t.filter.isEmpty()&&t.filter.isValid()&&e.filterFields.push(t.filter.toDbParams());return this._searchQuery?.trim().length&&this._model.columns.filter((e=>e.searchable)).forEach((t=>{e.queryFields.push({name:t.id,operation:"CONTAINS",value:this._searchQuery,and:!1})})),e}_fetch(){if(this._model.data)return this._data=this._model.data,this._totalItems=this._model.data.length,this._totalPages=Math.ceil(this._model.data.length/this._pageSize),void(this._dataState="success");if(!this._model.dataSource)return;let e;this._dataState="loading",e="db"===this._model.dataSource.mode?this._toDbParams():this._toSolrData(),this._model.dataSource.fetch(e).then((e=>{switch(this._model.dataSource?.mode){case"opensearch":throw Error("Opensearch not supported yet");case"db":{const t=e;this._data=t.data.content,this._totalItems=t.data.totalElements,this._totalPages=t.data.totalPages,this._pageSize=t.data.size;break}default:{const t=e;this._data=t.data.content,this._totalItems=t.data.totalElements,this._totalPages=t.data.totalPages,this._pageSize=t.data.size,this._parseFacetResults(t)}}this._dataState="success",this._updateSearchPosition()})).catch((e=>{this._dataState="error";let t="Failed to load data";e instanceof Error&&(t=e.message),hi.show({message:t,type:"error"})}))}_parseFacetResults(e){if(e.data.facetFields){for(const t of this._model.columns){if(!t.facetable)continue;const i=e.data.facetFields[t.id];if(!i){this._buckets.set(t.id,[]);continue}const s=[];for(const e of i){let i=e.name;"boolean"===t.type&&"string"==typeof e.name&&("true"===e.name?i=!0:"false"===e.name&&(i=!1)),null===e.name&&e.count>0&&s.unshift({val:null,count:e.count}),null!==e.name&&s.push({val:i,count:e.count})}if(t.filter&&("in"===t.filter.operator||"n_in"===t.filter.operator)&&Array.isArray(t.filter.value))for(const e of t.filter.value)s.some((t=>t.val===e))||s.push({val:e,count:0});this._buckets.set(t.id,s)}this._buckets=new Map(this._buckets)}}_initRefresh(){clearInterval(this._refreshTimer),this._model.refreshInterval&&this._model.refreshInterval>0&&(this._refreshTimer=window.setInterval((()=>{this._fetch()}),this._model.refreshInterval))}_handleSearch(e){const t=e.target;this._searchQuery=t.value,this._page=1,this._fetch()}_updateSearchPosition(){if(this._searchPositionLocked)return;if("card"===this.variant)return;const e=this.shadowRoot?.querySelector(".search"),t=e?.querySelector(".search-field");e&&t&&(e.style.justifyContent="center",t.style.marginLeft="",requestAnimationFrame((()=>{const i=e.getBoundingClientRect(),s=t.getBoundingClientRect().left-i.left;e.style.justifyContent="flex-start",t.style.marginLeft=`${s}px`,this._searchPositionLocked=!0})))}_handleColumnPickerClick(){this._columnPickerOpen=!this._columnPickerOpen}_handleColumnToggle(e){this._model.displayedColumns.includes(e)?this._model.displayedColumns=this._model.displayedColumns.filter((t=>t!==e)):this._model.displayedColumns=[...this._model.displayedColumns,e],this.requestUpdate()}_handleRowMouseDown(){(this._model.rowClickable||this._model.rowHref)&&window.getSelection()?.removeAllRanges()}_handleRowClick(e,t,i){if(!this._model.rowClickable&&!this._model.rowHref)return;const s=window.getSelection();s&&s.toString().length>0?e.preventDefault():this.dispatchEvent(new CustomEvent("row-click",{detail:{row:t,rowIndex:i},bubbles:!0,composed:!0}))}getDisplayedColumns(){return this._model.displayedColumns.map((e=>this._model.columns.find((t=>t.id===e)))).sort(((e,t)=>"actions"===e.type&&"actions"!==t.type?1:"actions"!==e.type&&"actions"===t.type?-1:0))}_handleScroll(e){const t=e.target;this._canScrollLeft=t.scrollLeft>0,this._canScrollRight=t.scrollLeft<t.scrollWidth-t.clientWidth-1}_updateScrollFlags(){const e=this.shadowRoot?.querySelector(".content");e&&(this._canScrollLeft=e.scrollLeft>0,this._canScrollRight=e.scrollWidth>e.clientWidth&&e.scrollLeft<e.scrollWidth-e.clientWidth-1,this._canScrollHorizontal=e.scrollWidth>e.clientWidth),this.classList.toggle("kr-table--scroll-left-available",this._canScrollLeft),this.classList.toggle("kr-table--scroll-right-available",this._canScrollRight),this.classList.toggle("kr-table--scroll-horizontal-available",this._canScrollHorizontal),this.classList.toggle("kr-table--sticky-left",this.getDisplayedColumns().some((e=>"left"===e.sticky))),this.classList.toggle("kr-table--sticky-right",this.getDisplayedColumns().some((e=>"right"===e.sticky)))}_handleResizeStart(e,t){e.preventDefault(),this.getDisplayedColumns().forEach((e=>{if(e.width||"actions"===e.type)return;const t=this.shadowRoot?.querySelector(`.header-cell[data-column-id="${e.id}"]`);t?.offsetWidth&&(e.width=`${t.offsetWidth}px`)}));const i=this.shadowRoot?.querySelector(`.header-cell[data-column-id="${t}"]`);this._resizing={columnId:t,startX:e.clientX,startWidth:i?.offsetWidth||200},document.addEventListener("mousemove",this._handleResizeMove),document.addEventListener("mouseup",this._handleResizeEnd)}_handleSortClick(e,t){if(e.shiftKey){const e=this._sorts.findIndex((e=>e.sortBy===t.id));if(-1===e)this._sorts.push({sortBy:t.id,sortDirection:"asc"});else{const t=this._sorts[e];"asc"===t.sortDirection?t.sortDirection="desc":this._sorts.splice(e,1)}this.requestUpdate()}else{let e=null;1===this._sorts.length&&(e=this._sorts.find((e=>e.sortBy===t.id))),e?"asc"===e.sortDirection?this._sorts=[{sortBy:t.id,sortDirection:"desc"}]:this._sorts=[]:this._sorts=[{sortBy:t.id,sortDirection:"asc"}]}this._page=1,this._fetch()}_renderSortIndicator(e){if(!e.sortable)return U;const t=this._sorts.findIndex((t=>t.sortBy===e.id));if(-1===t)return N`
2262
2262
  <span class="header-cell__sort" @click=${t=>this._handleSortClick(t,e)}>
2263
2263
  <svg
2264
2264
  class="header-cell__sort-arrow header-cell__sort-arrow--ghost"
@@ -2284,6 +2284,15 @@ class $e extends _e{constructor(e){if(super(e),this.it=U,e.type!==fe)throw Error
2284
2284
  </span>
2285
2285
  `}_handleAction(e){e.href||this.dispatchEvent(new CustomEvent("action",{detail:{action:e.id},bubbles:!0,composed:!0}))}_handleKqlChange(e,t){const i=e.target.value.trim();if(i){if(t.filter.setKql(i),this.requestUpdate(),!t.filter.isValid())return}else t.filter.clear(),this.requestUpdate();this._page=1,this._fetch()}_handleFilterPanelToggle(e,t){if(e.stopPropagation(),this._filterPanelOpened===t.id)this._filterPanelOpened=null;else{const i=e.currentTarget.getBoundingClientRect();let s=202;t.filterable&&(s=328),this._filterPanelPos={top:i.bottom+4,left:Math.max(0,i.right-s)},this._filterPanelOpened=t.id,t.facetable?this._filterPanelTab="counts":this._filterPanelTab="filter"}}_handleKqlClear(e){e.filter.clear(),this._page=1,this._fetch()}_handleFilterClear(){const e=this._model.columns.find((e=>e.id===this._filterPanelOpened));e&&(e.filter.clear(),e.facetable&&!e.filterable&&(e.filter.operator="in",e.filter.value=[])),this._filterPanelOpened=null,this._page=1,this._fetch()}_handleFilterTextKeydown(e,t){"Enter"===e.key&&(e.preventDefault(),this._handleFilterApply())}_handleOperatorChange(e,t){t.filter.setOperator(e.target.value),this.requestUpdate()}_handleFilterStringChange(e,t){t.filter.setValue(e.target.value),this.requestUpdate()}_handleFilterNumberChange(e,t){t.filter.setValue(Number(e.target.value)),this.requestUpdate()}_handleFilterDateChange(e,t){t.filter.setValue(new Date(e.target.value),"day"),this.requestUpdate()}_handleFilterBooleanChange(e,t){t.filter.setValue("true"===e.target.value),this.requestUpdate()}_handleFilterDateStartChange(e,t){t.filter.setStart(new Date(e.target.value),"day"),this.requestUpdate()}_handleFilterDateEndChange(e,t){t.filter.setEnd(new Date(e.target.value),"day"),this.requestUpdate()}_handleFilterNumberStartChange(e,t){t.filter.setStart(Number(e.target.value)),this.requestUpdate()}_handleFilterNumberEndChange(e,t){t.filter.setEnd(Number(e.target.value)),this.requestUpdate()}_handleFilterListChange(e,t){const i=e.target.value.split(",").map((e=>e.trim())).filter((e=>""!==e));"number"===t.type?t.filter.setValue(i.map((e=>Number(e)))):t.filter.setValue(i),this.requestUpdate()}_handleFilterApply(){this._filterPanelOpened=null,this._page=1,this._fetch()}_handleFilterPanelTabChange(e){this._filterPanelTab=e.detail.activeTabId}_handleBucketToggle(e,t,i){t.filter.toggle(i.val),this._page=1,this._fetch()}_renderCellContent(e,t,i){const s=t[e.id];if(e.render)return N`<slot name="cell-${i}-${e.id}"></slot>`;if(null==s)return"";switch(e.type){case"number":return"currency"===e.format&&"number"==typeof s?s.toLocaleString("en-US",{style:"currency",currency:"USD"}):String(s);case"date":{let e;if(s instanceof Date)e=s;else if("string"==typeof s&&/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/.test(s)){const t=s.replace(/(\d{2}:\d{2}:\d{2}):(\d+)$/,"$1.$2").replace(" ","T")+"Z";e=new Date(t)}else e=new Date(s);return e.toLocaleString(void 0,{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit"})}case"boolean":return!0===s?"Yes":!1===s?"No":"";default:return String(s)}}_getCellStyle(e,t){const i={};if("left"===e.sticky){let e=0;for(let i=0;i<t;i++){const t=this.getDisplayedColumns()[i];"left"===t.sticky&&(e+=parseInt(t.width||"0",10))}i.left=`${e}px`}if("right"===e.sticky){let e=0;for(let i=t+1;i<this.getDisplayedColumns().length;i++){const t=this.getDisplayedColumns()[i];"right"===t.sticky&&(e+=parseInt(t.width||"0",10))}i.right=`${e}px`}return i}_renderPagination(){const e=(this._page-1)*this._pageSize+1,t=Math.min(this._page*this._pageSize,this._totalItems);return N`
2286
2286
  <div class="pagination">
2287
+ <span
2288
+ class=${ye({"pagination-icon":!0,"pagination-icon--disabled":1===this._page})}
2289
+ title="First page"
2290
+ @click=${this.goToFirstPage}
2291
+ >
2292
+ <svg viewBox="0 0 24 24" fill="currentColor">
2293
+ <path d="M18.41 16.59L13.82 12l4.59-4.59L17 6l-6 6 6 6zM6 6h2v12H6z"/>
2294
+ </svg>
2295
+ </span>
2287
2296
  <span
2288
2297
  class=${ye({"pagination-icon":!0,"pagination-icon--disabled":1===this._page})}
2289
2298
  @click=${this.goToPrevPage}
@@ -2301,6 +2310,15 @@ class $e extends _e{constructor(e){if(super(e),this.it=U,e.type!==fe)throw Error
2301
2310
  <path d="M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"/>
2302
2311
  </svg>
2303
2312
  </span>
2313
+ <span
2314
+ class=${ye({"pagination-icon":!0,"pagination-icon--disabled":this._page===this._totalPages})}
2315
+ title="Last page"
2316
+ @click=${this.goToLastPage}
2317
+ >
2318
+ <svg viewBox="0 0 24 24" fill="currentColor">
2319
+ <path d="M5.59 7.41L10.18 12l-4.59 4.59L7 18l6-6-6-6zM16 6h2v12h-2z"/>
2320
+ </svg>
2321
+ </span>
2304
2322
  </div>
2305
2323
  `}_renderCardHeader(){return"card"!==this.variant?U:this._model.title||this._model.description?N`
2306
2324
  <div class="card-header">
@@ -3551,7 +3569,7 @@ class $e extends _e{constructor(e){if(super(e),this.it=U,e.type!==fe)throw Error
3551
3569
  height: auto;
3552
3570
  }
3553
3571
 
3554
- `],Di([ce({type:Object})],Oi.prototype,"def",void 0),Di([ce({type:String,reflect:!0})],Oi.prototype,"variant",void 0),Di([pe()],Oi.prototype,"_data",void 0),Di([pe()],Oi.prototype,"_dataState",void 0),Di([pe()],Oi.prototype,"_page",void 0),Di([pe()],Oi.prototype,"_pageSize",void 0),Di([pe()],Oi.prototype,"_totalItems",void 0),Di([pe()],Oi.prototype,"_totalPages",void 0),Di([pe()],Oi.prototype,"_searchQuery",void 0),Di([pe()],Oi.prototype,"_canScrollLeft",void 0),Di([pe()],Oi.prototype,"_canScrollRight",void 0),Di([pe()],Oi.prototype,"_canScrollHorizontal",void 0),Di([pe()],Oi.prototype,"_columnPickerOpen",void 0),Di([pe()],Oi.prototype,"_filterPanelOpened",void 0),Di([pe()],Oi.prototype,"_filterPanelTab",void 0),Di([pe()],Oi.prototype,"_buckets",void 0),Di([pe()],Oi.prototype,"_sorts",void 0),customElements.get("krs-table")||customElements.define("krs-table",Oi);var Ai=function(e,t,i,s){var o,r=arguments.length,a=r<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,i,s);else for(var n=e.length-1;n>=0;n--)(o=e[n])&&(a=(r<3?o(a):r>3?o(t,i,a):o(t,i))||a);return r>3&&a&&Object.defineProperty(t,i,a),a};class Mi extends ne{static fromJSON(e){const t=new Mi;return void 0!==e.label&&(t.label=e.label),void 0!==e.name&&(t.name=e.name),void 0!==e.value&&(t.value=e.value),void 0!==e.checked&&(t.checked=e.checked),void 0!==e.disabled&&(t.disabled=e.disabled),void 0!==e.required&&(t.required=e.required),void 0!==e.hint&&(t.hint=e.hint),void 0!==e.saveMode&&(t.saveMode=e.saveMode),t}constructor(){super(),this._dirtyChecked=!1,this.label="",this.name="",this.value="on",this.checked=!1,this.disabled=!1,this.required=!1,this.hint="",this.dirty=!1,this.saving=!1,this._touched=!1,this._handleInvalid=e=>{e.preventDefault(),this._touched=!0},this._internals=this.attachInternals()}connectedCallback(){super.connectedCallback(),this.classList.add("kr-form-field"),this.addEventListener("invalid",this._handleInvalid)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("invalid",this._handleInvalid)}firstUpdated(){this._syncFormValue(),this._updateValidity()}willUpdate(e){let t=this.saveMode;t||(t=this.closest("krs-form")?.saveMode),e.has("checked")&&this.dirty&&this.checked!==this._dirtyChecked&&"autosave"===t&&(this.checked=this._dirtyChecked)}updated(e){(e.has("checked")||e.has("value"))&&this._syncFormValue(),(e.has("required")||e.has("checked"))&&this._updateValidity()}get form(){return this._internals.form}get validity(){return this._internals.validity}get validationMessage(){return this._internals.validationMessage}get willValidate(){return this._internals.willValidate}checkValidity(){return this._internals.checkValidity()}reportValidity(){return this._internals.reportValidity()}formResetCallback(){this.checked=!1,this._touched=!1,this.dirty=!1,this.saving=!1,this._internals.setFormValue(""),this._internals.setValidity({})}markPristine(){this.dirty=!1}markSaving(){this.saving=!0,this.dirty=!1}markSaved(){this.saving=!1}markSaveFailed(){this.saving=!1,this.dirty=!0,this._dirtyChecked=this.checked}formStateRestoreCallback(e){this.checked=e===this.value}focus(){this.shadowRoot?.querySelector(".checkbox")?.focus()}blur(){this.shadowRoot?.querySelector(".checkbox")?.blur()}_syncFormValue(){this.checked?this._internals.setFormValue(this.value):this._internals.setFormValue("")}_updateValidity(){this.required&&!this.checked?this._internals.setValidity({valueMissing:!0},"This field is required"):this._internals.setValidity({})}_handleClick(e){this.disabled||(this.checked=!this.checked,this._touched=!0,this.dirty=!0,this._dirtyChecked=this.checked,this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0})))}_handleKeyDown(e){this.disabled||" "!==e.key&&"Enter"!==e.key||(e.preventDefault(),this._handleClick(e))}render(){return N`
3572
+ `],Di([ce({type:Object})],Oi.prototype,"def",void 0),Di([ce({type:String,reflect:!0})],Oi.prototype,"variant",void 0),Di([pe()],Oi.prototype,"_data",void 0),Di([pe()],Oi.prototype,"_dataState",void 0),Di([pe()],Oi.prototype,"_page",void 0),Di([pe()],Oi.prototype,"_pageSize",void 0),Di([pe()],Oi.prototype,"_totalItems",void 0),Di([pe()],Oi.prototype,"_totalPages",void 0),Di([pe()],Oi.prototype,"_searchQuery",void 0),Di([pe()],Oi.prototype,"_canScrollLeft",void 0),Di([pe()],Oi.prototype,"_canScrollRight",void 0),Di([pe()],Oi.prototype,"_canScrollHorizontal",void 0),Di([pe()],Oi.prototype,"_columnPickerOpen",void 0),Di([pe()],Oi.prototype,"_filterPanelOpened",void 0),Di([pe()],Oi.prototype,"_filterPanelTab",void 0),Di([pe()],Oi.prototype,"_buckets",void 0),Di([pe()],Oi.prototype,"_sorts",void 0),customElements.get("krs-table")||customElements.define("krs-table",Oi);var Mi=function(e,t,i,s){var o,r=arguments.length,a=r<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,i,s);else for(var n=e.length-1;n>=0;n--)(o=e[n])&&(a=(r<3?o(a):r>3?o(t,i,a):o(t,i))||a);return r>3&&a&&Object.defineProperty(t,i,a),a};class Ai extends ne{static fromJSON(e){const t=new Ai;return void 0!==e.label&&(t.label=e.label),void 0!==e.name&&(t.name=e.name),void 0!==e.value&&(t.value=e.value),void 0!==e.checked&&(t.checked=e.checked),void 0!==e.disabled&&(t.disabled=e.disabled),void 0!==e.required&&(t.required=e.required),void 0!==e.hint&&(t.hint=e.hint),void 0!==e.saveMode&&(t.saveMode=e.saveMode),t}constructor(){super(),this._dirtyChecked=!1,this.label="",this.name="",this.value="on",this.checked=!1,this.disabled=!1,this.required=!1,this.hint="",this.dirty=!1,this.saving=!1,this._touched=!1,this._handleInvalid=e=>{e.preventDefault(),this._touched=!0},this._internals=this.attachInternals()}connectedCallback(){super.connectedCallback(),this.classList.add("kr-form-field"),this.addEventListener("invalid",this._handleInvalid)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("invalid",this._handleInvalid)}firstUpdated(){this._syncFormValue(),this._updateValidity()}willUpdate(e){let t=this.saveMode;t||(t=this.closest("krs-form")?.saveMode),e.has("checked")&&this.dirty&&this.checked!==this._dirtyChecked&&"autosave"===t&&(this.checked=this._dirtyChecked)}updated(e){(e.has("checked")||e.has("value"))&&this._syncFormValue(),(e.has("required")||e.has("checked"))&&this._updateValidity()}get form(){return this._internals.form}get validity(){return this._internals.validity}get validationMessage(){return this._internals.validationMessage}get willValidate(){return this._internals.willValidate}checkValidity(){return this._internals.checkValidity()}reportValidity(){return this._internals.reportValidity()}formResetCallback(){this.checked=!1,this._touched=!1,this.dirty=!1,this.saving=!1,this._internals.setFormValue(""),this._internals.setValidity({})}markPristine(){this.dirty=!1}markSaving(){this.saving=!0,this.dirty=!1}markSaved(){this.saving=!1}markSaveFailed(){this.saving=!1,this.dirty=!0,this._dirtyChecked=this.checked}formStateRestoreCallback(e){this.checked=e===this.value}focus(){this.shadowRoot?.querySelector(".checkbox")?.focus()}blur(){this.shadowRoot?.querySelector(".checkbox")?.blur()}_syncFormValue(){this.checked?this._internals.setFormValue(this.value):this._internals.setFormValue("")}_updateValidity(){this.required&&!this.checked?this._internals.setValidity({valueMissing:!0},"This field is required"):this._internals.setValidity({})}_handleClick(e){this.disabled||(this.checked=!this.checked,this._touched=!0,this.dirty=!0,this._dirtyChecked=this.checked,this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0})))}_handleKeyDown(e){this.disabled||" "!==e.key&&"Enter"!==e.key||(e.preventDefault(),this._handleClick(e))}render(){return N`
3555
3573
  <div class="wrapper">
3556
3574
  <div
3557
3575
  class=${ye({checkbox:!0,"checkbox--disabled":this.disabled})}
@@ -3587,7 +3605,7 @@ class $e extends _e{constructor(e){if(super(e),this.it=U,e.type!==fe)throw Error
3587
3605
  </div>
3588
3606
  ${this._touched&&this.required&&!this.checked?N`<div class="validation-message">This field is required</div>`:this.hint?N`<div class="hint">${this.hint}</div>`:U}
3589
3607
  </div>
3590
- `}}Mi.styles=[Ut,a`
3608
+ `}}Ai.styles=[Ut,a`
3591
3609
  :host {
3592
3610
  display: inline-block;
3593
3611
  font-family: inherit;
@@ -3670,7 +3688,7 @@ class $e extends _e{constructor(e){if(super(e),this.it=U,e.type!==fe)throw Error
3670
3688
  color: var(--kr-checkbox-error-color, #ef4444);
3671
3689
  margin-left: 26px;
3672
3690
  }
3673
- `],Mi.formAssociated=!0,Ai([ce({type:String})],Mi.prototype,"label",void 0),Ai([ce({type:String})],Mi.prototype,"name",void 0),Ai([ce({type:String})],Mi.prototype,"value",void 0),Ai([ce({type:Boolean})],Mi.prototype,"checked",void 0),Ai([ce({type:Boolean})],Mi.prototype,"disabled",void 0),Ai([ce({type:Boolean})],Mi.prototype,"required",void 0),Ai([ce({type:String})],Mi.prototype,"hint",void 0),Ai([ce({type:Boolean,reflect:!0})],Mi.prototype,"dirty",void 0),Ai([ce({attribute:"save-mode"})],Mi.prototype,"saveMode",void 0),Ai([ce({type:Boolean,reflect:!0})],Mi.prototype,"saving",void 0),Ai([pe()],Mi.prototype,"_touched",void 0),customElements.get("krs-checkbox")||customElements.define("krs-checkbox",Mi);var Ii=function(e,t,i,s){var o,r=arguments.length,a=r<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,i,s);else for(var n=e.length-1;n>=0;n--)(o=e[n])&&(a=(r<3?o(a):r>3?o(t,i,a):o(t,i))||a);return r>3&&a&&Object.defineProperty(t,i,a),a};class Ri{constructor(){this.title="",this.description="",this.actions=[],this.columns=[],this.displayedColumns=[],this.data=null,this.dataSource=null,this.refreshInterval=0,this.pageSize=0,this.rowClickable=!1,this.rowHref=null,this.rowSelectable=!1,this.rowKey=null}}class Pi extends ne{constructor(){super(...arguments),this._scrollStyle="edge",this._filterPanelPos={top:0,left:0},this._resizing=null,this._resizeObserver=null,this._searchPositionLocked=!1,this._columnWidthsLocked=!1,this._model=new Ri,this._selectedRows=new Set,this.def={columns:[]},this.variant="default",this.scrollMode="contain",this._data=[],this._dataState="idle",this._page=1,this._pageSize=50,this._totalItems=0,this._totalPages=0,this._searchQuery="",this._canScrollLeft=!1,this._canScrollRight=!1,this._canScrollHorizontal=!1,this._columnPickerOpen=!1,this._filterPanelOpened=null,this._filterPanelTab="filter",this._buckets=new Map,this._sorts=[],this._handleClickOutside=e=>{const t=e.composedPath();if(this._columnPickerOpen){const e=this.shadowRoot?.querySelector(".column-picker-wrapper");e&&!t.includes(e)&&(this._columnPickerOpen=!1)}this._filterPanelOpened&&(t.some((e=>e.classList?.contains("filter-panel")))||this._handleFilterApply())},this._handleResizeMove=e=>{if(!this._resizing)return;const t=this._model.columns.find((e=>e.id===this._resizing.columnId));if(t){const i=this._resizing.startWidth+(e.clientX-this._resizing.startX);t.width=`${Math.min(900,Math.max(50,i))}px`,this.requestUpdate()}},this._handleResizeEnd=()=>{this._resizing=null,document.removeEventListener("mousemove",this._handleResizeMove),document.removeEventListener("mouseup",this._handleResizeEnd)}}connectedCallback(){super.connectedCallback(),this.classList.toggle("kr-table--scroll-overlay","overlay"===this._scrollStyle),this.classList.toggle("kr-table--scroll-edge","edge"===this._scrollStyle),this._fetch(),this._initRefresh(),document.addEventListener("click",this._handleClickOutside),this._resizeObserver=new ResizeObserver((()=>{this._searchPositionLocked=!1,this._updateSearchPosition()})),this._resizeObserver.observe(this)}disconnectedCallback(){super.disconnectedCallback(),clearInterval(this._refreshTimer),document.removeEventListener("click",this._handleClickOutside),this._resizeObserver?.disconnect()}willUpdate(e){e.has("def")&&(this._columnWidthsLocked=!1,this._model=new Ri,this.def.title&&(this._model.title=this.def.title),this.def.description&&(this._model.description=this.def.description),this.def.actions&&(this._model.actions=this.def.actions),this.def.data&&(this._model.data=this.def.data),this.def.dataSource&&(this._model.dataSource=this.def.dataSource),"number"==typeof this.def.refreshInterval&&(this._model.refreshInterval=this.def.refreshInterval),"number"==typeof this.def.pageSize&&(this._model.pageSize=this.def.pageSize,this._pageSize=this.def.pageSize),this.def.rowClickable&&(this._model.rowClickable=this.def.rowClickable),this.def.rowHref&&(this._model.rowHref=this.def.rowHref),this.def.rowKey&&(this._model.rowKey=this.def.rowKey),this.def.rowSelectable&&this.def.rowKey&&(this._model.rowSelectable=!0),this._selectedRows.clear(),this._sorts=[],this._model.columns=this.def.columns.map((e=>{const t={...e,filter:null};return t.type||(t.type="string"),e.sort&&this._sorts.push({sortBy:e.id,sortDirection:e.sort}),"actions"===t.type?(t.label=e.label??"",t.sticky="right",t.resizable=!1,t):((e.filterable||e.facetable)&&(t.filter=new zi,t.filter.field=e.searchField??e.id,t.filter.type=t.type,e.filter?(t.filter.setOperator(e.filter.operator),t.filter.setValue(e.filter.value)):e.facetable&&!e.filterable?(t.filter.operator="in",t.filter.value=[]):"string"===t.filter.type&&(t.filter.operator="contains")),t)})),this.def.displayedColumns?this._model.displayedColumns=this.def.displayedColumns:this._model.displayedColumns=this._model.columns.map((e=>e.id)),this._fetch(),this._initRefresh())}updated(e){this.classList.toggle("kr-table--card","card"===this.variant),this.classList.toggle("kr-table--page","page"===this.variant),this.classList.toggle("kr-table--dialog","dialog"===this.variant),this.classList.toggle("kr-table--scroll-auto","auto"===this.scrollMode&&"page"!==this.variant),this._updateScrollFlags(),this._syncSlottedContent(),this._lockColumnWidths()}_lockColumnWidths(){if(this._columnWidthsLocked||0===this._data.length)return;const e=this.shadowRoot?.querySelectorAll(".header-row > .header-cell:not(.header-cell--select)");if(!e)return;const t=this.getDisplayedColumns();e.forEach(((e,i)=>{const s=e.offsetWidth;i<t.length&&!t[i].width&&"actions"!==t[i].type&&s>0&&(t[i].width=`${s}px`,this._columnWidthsLocked=!0)}))}_syncSlottedContent(){const e=this.getDisplayedColumns().filter((e=>e.render));e.length&&(this.querySelectorAll('[slot^="cell-"]').forEach((e=>e.remove())),this._data.forEach(((t,i)=>{e.forEach((e=>{const s=e.render(t);if(!s)return;const o=document.createElement("span");o.slot=`cell-${i}-${e.id}`,"actions"===e.type&&(o.style.display="flex",o.style.gap="8px"),"string"==typeof s?o.innerHTML=s:re(s,o),this.appendChild(o)}))})))}refresh(){this._fetch()}goToPrevPage(){this._page>1&&(this._page--,this._fetch())}goToNextPage(){this._page<this._totalPages&&(this._page++,this._fetch())}goToPage(e){e>=1&&e<=this._totalPages&&(this._page=e,this._fetch())}getSelectedRows(){return this._model.rowSelectable?this._data.filter((e=>this._selectedRows.has(this._model.rowKey(e)))):[]}clearSelection(){this._selectedRows.clear(),this.requestUpdate(),this.dispatchEvent(new CustomEvent("selection-change",{detail:{rows:[]},bubbles:!0,composed:!0}))}_toSolrData(){const e={page:this._page-1,size:this._pageSize,sorts:this._sorts,filterFields:[],queryFields:[],facetFields:[]};for(const t of this._model.columns){if(!t.filter||t.filter.isEmpty()||!t.filter.isValid())continue;const i=t.filter.toSolrData();!t.facetable||"in"!==t.filter.operator&&"n_in"!==t.filter.operator||(i.tagged=!0),e.filterFields.push(i)}for(const t of this._model.columns)t.facetable&&e.facetFields.push({name:t.id,type:"FIELD",limit:100,sort:"count",minimumCount:1});return this._searchQuery?.trim().length&&e.queryFields.push({name:"_text_",operation:"IS",value:wi(this._searchQuery,!1)}),e}_toDbParams(){const e={page:this._page-1,size:this._pageSize,sorts:this._sorts,filterFields:[],queryFields:[],facetFields:[]};for(const t of this._model.columns)t.filter&&!t.filter.isEmpty()&&t.filter.isValid()&&e.filterFields.push(t.filter.toDbParams());return this._searchQuery?.trim().length&&this._model.columns.filter((e=>e.searchable)).forEach((t=>{e.queryFields.push({name:t.id,operation:"CONTAINS",value:this._searchQuery,and:!1})})),e}_toOpensearchParams(){const e={from:(this._page-1)*this._pageSize,size:this._pageSize,sort:this._sorts.map((e=>({[this._model.columns.find((t=>t.id===e.sortBy))?.searchField??e.sortBy]:e.sortDirection}))),query:{bool:{must:[],filter:[]}}};for(const t of this._model.columns)t.filter&&!t.filter.isEmpty()&&t.filter.isValid()&&e.query.bool.filter.push(t.filter.toOpensearchData());const t=this._searchQuery?.trim().replace(/([*?\\])/g,"\\$1");return t?e.query.bool.must.push({bool:{should:this._model.columns.filter((e=>e.searchable)).map((e=>({wildcard:{[e.searchField??e.id]:{value:`*${t}*`,case_insensitive:!0}}}))),minimum_should_match:1}}):e.query.bool.must.push({match_all:{}}),e}_fetch(){if(this._model.data)return this._data=this._model.data,this._totalItems=this._model.data.length,this._totalPages=Math.ceil(this._model.data.length/this._pageSize),void(this._dataState="success");if(!this._model.dataSource)return;let e;this._dataState="loading",e="db"===this._model.dataSource.mode?this._toDbParams():"opensearch"===this._model.dataSource.mode?this._toOpensearchParams():"array"===this._model.dataSource.mode?void 0:this._toSolrData(),this._model.dataSource.fetch(e).then((e=>{switch(this._model.dataSource?.mode){case"array":this._data=e,this._totalItems=e.length,this._totalPages=1,this._pageSize=e.length;break;case"opensearch":this._data=(e?.data?.hits?.hits||[]).map((e=>e._source)),this._totalItems=e?.data?.hits?.total?.value??0,this._totalPages=Math.ceil(this._totalItems/this._pageSize)||1;break;case"db":{const t=e;this._data=t.data.content,this._totalItems=t.data.totalElements,this._totalPages=t.data.totalPages,this._pageSize=t.data.size;break}default:{const t=e;this._data=t.data.content,this._totalItems=t.data.totalElements,this._totalPages=t.data.totalPages,this._pageSize=t.data.size,this._parseFacetResults(t)}}this._dataState="success",this._updateSearchPosition()})).catch((e=>{this._dataState="error";let t="Failed to load data";e instanceof Error&&(t=e.message),hi.show({message:t,type:"error"})}))}_parseFacetResults(e){if(e.data.facetFields){for(const t of this._model.columns){if(!t.facetable)continue;const i=e.data.facetFields[t.id];if(!i){this._buckets.set(t.id,[]);continue}const s=[];for(const e of i){let i=e.name;"boolean"===t.type&&"string"==typeof e.name&&("true"===e.name?i=!0:"false"===e.name&&(i=!1)),null===e.name&&e.count>0&&s.unshift({val:null,count:e.count}),null!==e.name&&s.push({val:i,count:e.count})}if(t.filter&&("in"===t.filter.operator||"n_in"===t.filter.operator)&&Array.isArray(t.filter.value))for(const e of t.filter.value)s.some((t=>t.val===e))||s.push({val:e,count:0});this._buckets.set(t.id,s)}this._buckets=new Map(this._buckets)}}_initRefresh(){clearInterval(this._refreshTimer),this._model.refreshInterval&&this._model.refreshInterval>0&&(this._refreshTimer=window.setInterval((()=>{this._fetch()}),this._model.refreshInterval))}_handleSearch(e){const t=e.target;this._searchQuery=t.value,this._page=1,this._fetch()}_updateSearchPosition(){if(this._searchPositionLocked)return;if("card"===this.variant||"dialog"===this.variant)return;const e=this.shadowRoot?.querySelector(".search"),t=e?.querySelector(".search-field");e&&t&&(e.style.justifyContent="center",t.style.marginLeft="",requestAnimationFrame((()=>{const i=e.getBoundingClientRect(),s=t.getBoundingClientRect().left-i.left;e.style.justifyContent="flex-start",t.style.marginLeft=`${s}px`,this._searchPositionLocked=!0})))}_handleColumnPickerClick(){this._columnPickerOpen=!this._columnPickerOpen}_handleColumnToggle(e){this._model.displayedColumns.includes(e)?this._model.displayedColumns=this._model.displayedColumns.filter((t=>t!==e)):this._model.displayedColumns=[...this._model.displayedColumns,e],this.requestUpdate()}_handleRowMouseDown(){(this._model.rowClickable||this._model.rowHref)&&window.getSelection()?.removeAllRanges()}_handleRowClick(e,t,i){if(!this._model.rowClickable&&!this._model.rowHref)return;const s=window.getSelection();s&&s.toString().length>0?e.preventDefault():this.dispatchEvent(new CustomEvent("row-click",{detail:{row:t,rowIndex:i},bubbles:!0,composed:!0}))}_handleSelectCellClick(e){e.stopPropagation(),e.preventDefault()}_handleRowSelectToggle(e,t){const i=this._model.rowKey(t);this._selectedRows.has(i)?this._selectedRows.delete(i):this._selectedRows.add(i),this.requestUpdate(),this.dispatchEvent(new CustomEvent("selection-change",{detail:{rows:this.getSelectedRows()},bubbles:!0,composed:!0}))}_handleSelectAllToggle(){this._data.every((e=>this._selectedRows.has(this._model.rowKey(e))))?this._data.forEach((e=>this._selectedRows.delete(this._model.rowKey(e)))):this._data.forEach((e=>this._selectedRows.add(this._model.rowKey(e)))),this.requestUpdate(),this.dispatchEvent(new CustomEvent("selection-change",{detail:{rows:this.getSelectedRows()},bubbles:!0,composed:!0}))}getDisplayedColumns(){return this._model.displayedColumns.map((e=>this._model.columns.find((t=>t.id===e)))).sort(((e,t)=>"actions"===e.type&&"actions"!==t.type?1:"actions"!==e.type&&"actions"===t.type?-1:0))}_handleScroll(e){const t=e.target;this._canScrollLeft=t.scrollLeft>0,this._canScrollRight=t.scrollLeft<t.scrollWidth-t.clientWidth-1}_updateScrollFlags(){const e=this.shadowRoot?.querySelector(".content");e&&(this._canScrollLeft=e.scrollLeft>0,this._canScrollRight=e.scrollWidth>e.clientWidth&&e.scrollLeft<e.scrollWidth-e.clientWidth-1,this._canScrollHorizontal=e.scrollWidth>e.clientWidth),this.classList.toggle("kr-table--scroll-left-available",this._canScrollLeft),this.classList.toggle("kr-table--scroll-right-available",this._canScrollRight),this.classList.toggle("kr-table--scroll-horizontal-available",this._canScrollHorizontal),this.classList.toggle("kr-table--sticky-left",this.getDisplayedColumns().some((e=>"left"===e.sticky))),this.classList.toggle("kr-table--sticky-right",this.getDisplayedColumns().some((e=>"right"===e.sticky)))}_handleResizeStart(e,t){e.preventDefault();const i=this.shadowRoot?.querySelector(`.header-cell[data-column-id="${t}"]`);this._resizing={columnId:t,startX:e.clientX,startWidth:i?.offsetWidth||200},document.addEventListener("mousemove",this._handleResizeMove),document.addEventListener("mouseup",this._handleResizeEnd)}_handleSortClick(e,t){if(e.shiftKey){const e=this._sorts.findIndex((e=>e.sortBy===t.id));if(-1===e)this._sorts.push({sortBy:t.id,sortDirection:"asc"});else{const t=this._sorts[e];"asc"===t.sortDirection?t.sortDirection="desc":this._sorts.splice(e,1)}this.requestUpdate()}else{let e=null;1===this._sorts.length&&(e=this._sorts.find((e=>e.sortBy===t.id))),e?"asc"===e.sortDirection?this._sorts=[{sortBy:t.id,sortDirection:"desc"}]:this._sorts=[]:this._sorts=[{sortBy:t.id,sortDirection:"asc"}]}this._page=1,this._fetch()}_renderSortIndicator(e){if(!e.sortable)return U;const t=this._sorts.findIndex((t=>t.sortBy===e.id));if(-1===t)return N`
3691
+ `],Ai.formAssociated=!0,Mi([ce({type:String})],Ai.prototype,"label",void 0),Mi([ce({type:String})],Ai.prototype,"name",void 0),Mi([ce({type:String})],Ai.prototype,"value",void 0),Mi([ce({type:Boolean})],Ai.prototype,"checked",void 0),Mi([ce({type:Boolean})],Ai.prototype,"disabled",void 0),Mi([ce({type:Boolean})],Ai.prototype,"required",void 0),Mi([ce({type:String})],Ai.prototype,"hint",void 0),Mi([ce({type:Boolean,reflect:!0})],Ai.prototype,"dirty",void 0),Mi([ce({attribute:"save-mode"})],Ai.prototype,"saveMode",void 0),Mi([ce({type:Boolean,reflect:!0})],Ai.prototype,"saving",void 0),Mi([pe()],Ai.prototype,"_touched",void 0),customElements.get("krs-checkbox")||customElements.define("krs-checkbox",Ai);var Ii=function(e,t,i,s){var o,r=arguments.length,a=r<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,i,s);else for(var n=e.length-1;n>=0;n--)(o=e[n])&&(a=(r<3?o(a):r>3?o(t,i,a):o(t,i))||a);return r>3&&a&&Object.defineProperty(t,i,a),a};class Ri{constructor(){this.title="",this.description="",this.actions=[],this.columns=[],this.displayedColumns=[],this.data=null,this.dataSource=null,this.refreshInterval=0,this.pageSize=0,this.rowClickable=!1,this.rowHref=null,this.rowSelectable=!1,this.rowKey=null}}class Pi extends ne{constructor(){super(...arguments),this._scrollStyle="edge",this._filterPanelPos={top:0,left:0},this._resizing=null,this._resizeObserver=null,this._searchPositionLocked=!1,this._columnWidthsLocked=!1,this._model=new Ri,this._selectedRows=new Set,this.def={columns:[]},this.variant="default",this.scrollMode="contain",this._data=[],this._dataState="idle",this._page=1,this._pageSize=50,this._totalItems=0,this._totalPages=0,this._searchQuery="",this._canScrollLeft=!1,this._canScrollRight=!1,this._canScrollHorizontal=!1,this._columnPickerOpen=!1,this._filterPanelOpened=null,this._filterPanelTab="filter",this._buckets=new Map,this._sorts=[],this._handleClickOutside=e=>{const t=e.composedPath();if(this._columnPickerOpen){const e=this.shadowRoot?.querySelector(".column-picker-wrapper");e&&!t.includes(e)&&(this._columnPickerOpen=!1)}this._filterPanelOpened&&(t.some((e=>e.classList?.contains("filter-panel")))||this._handleFilterApply())},this._handleResizeMove=e=>{if(!this._resizing)return;const t=this._model.columns.find((e=>e.id===this._resizing.columnId));if(t){const i=this._resizing.startWidth+(e.clientX-this._resizing.startX);t.width=`${Math.min(900,Math.max(50,i))}px`,this.requestUpdate()}},this._handleResizeEnd=()=>{this._resizing=null,document.removeEventListener("mousemove",this._handleResizeMove),document.removeEventListener("mouseup",this._handleResizeEnd)}}connectedCallback(){super.connectedCallback(),this.classList.toggle("kr-table--scroll-overlay","overlay"===this._scrollStyle),this.classList.toggle("kr-table--scroll-edge","edge"===this._scrollStyle),this._fetch(),this._initRefresh(),document.addEventListener("click",this._handleClickOutside),this._resizeObserver=new ResizeObserver((()=>{this._searchPositionLocked=!1,this._updateSearchPosition()})),this._resizeObserver.observe(this)}disconnectedCallback(){super.disconnectedCallback(),clearInterval(this._refreshTimer),document.removeEventListener("click",this._handleClickOutside),this._resizeObserver?.disconnect()}willUpdate(e){e.has("def")&&(this._columnWidthsLocked=!1,this._model=new Ri,this.def.title&&(this._model.title=this.def.title),this.def.description&&(this._model.description=this.def.description),this.def.actions&&(this._model.actions=this.def.actions),this.def.data&&(this._model.data=this.def.data),this.def.dataSource&&(this._model.dataSource=this.def.dataSource),"number"==typeof this.def.refreshInterval&&(this._model.refreshInterval=this.def.refreshInterval),"number"==typeof this.def.pageSize&&(this._model.pageSize=this.def.pageSize,this._pageSize=this.def.pageSize),this.def.rowClickable&&(this._model.rowClickable=this.def.rowClickable),this.def.rowHref&&(this._model.rowHref=this.def.rowHref),this.def.rowKey&&(this._model.rowKey=this.def.rowKey),this.def.rowSelectable&&this.def.rowKey&&(this._model.rowSelectable=!0),this._selectedRows.clear(),this._sorts=[],this._model.columns=this.def.columns.map((e=>{const t={...e,filter:null};return t.type||(t.type="string"),e.sort&&this._sorts.push({sortBy:e.id,sortDirection:e.sort}),"actions"===t.type?(t.label=e.label??"",t.sticky="right",t.resizable=!1,t):((e.filterable||e.facetable)&&(t.filter=new zi,t.filter.field=e.searchField??e.id,t.filter.type=t.type,e.filter?(t.filter.setOperator(e.filter.operator),t.filter.setValue(e.filter.value)):e.facetable&&!e.filterable?(t.filter.operator="in",t.filter.value=[]):"string"===t.filter.type&&(t.filter.operator="contains")),t)})),this.def.displayedColumns?this._model.displayedColumns=this.def.displayedColumns:this._model.displayedColumns=this._model.columns.map((e=>e.id)),this._fetch(),this._initRefresh())}updated(e){this.classList.toggle("kr-table--card","card"===this.variant),this.classList.toggle("kr-table--page","page"===this.variant),this.classList.toggle("kr-table--dialog","dialog"===this.variant),this.classList.toggle("kr-table--scroll-auto","auto"===this.scrollMode&&"page"!==this.variant),this._updateScrollFlags(),this._syncSlottedContent(),this._lockColumnWidths()}_lockColumnWidths(){if(this._columnWidthsLocked||0===this._data.length)return;const e=this.shadowRoot?.querySelectorAll(".header-row > .header-cell:not(.header-cell--select)");if(!e)return;const t=this.getDisplayedColumns();e.forEach(((e,i)=>{const s=e.offsetWidth;i<t.length&&!t[i].width&&"actions"!==t[i].type&&s>0&&(t[i].width=`${s}px`,this._columnWidthsLocked=!0)}))}_syncSlottedContent(){const e=this.getDisplayedColumns().filter((e=>e.render));e.length&&(this.querySelectorAll('[slot^="cell-"]').forEach((e=>e.remove())),this._data.forEach(((t,i)=>{e.forEach((e=>{const s=e.render(t);if(!s)return;const o=document.createElement("span");o.slot=`cell-${i}-${e.id}`,"actions"===e.type&&(o.style.display="flex",o.style.gap="8px"),"string"==typeof s?o.innerHTML=s:re(s,o),this.appendChild(o)}))})))}refresh(){this._fetch()}goToFirstPage(){this._page>1&&(this._page=1,this._fetch())}goToPrevPage(){this._page>1&&(this._page--,this._fetch())}goToNextPage(){this._page<this._totalPages&&(this._page++,this._fetch())}goToLastPage(){this._page<this._totalPages&&(this._page=this._totalPages,this._fetch())}goToPage(e){e>=1&&e<=this._totalPages&&(this._page=e,this._fetch())}getSelectedRows(){return this._model.rowSelectable?this._data.filter((e=>this._selectedRows.has(this._model.rowKey(e)))):[]}clearSelection(){this._selectedRows.clear(),this.requestUpdate(),this.dispatchEvent(new CustomEvent("selection-change",{detail:{rows:[]},bubbles:!0,composed:!0}))}_toSolrData(){const e={page:this._page-1,size:this._pageSize,sorts:this._sorts,filterFields:[],queryFields:[],facetFields:[]};for(const t of this._model.columns){if(!t.filter||t.filter.isEmpty()||!t.filter.isValid())continue;const i=t.filter.toSolrData();!t.facetable||"in"!==t.filter.operator&&"n_in"!==t.filter.operator||(i.tagged=!0),e.filterFields.push(i)}for(const t of this._model.columns)t.facetable&&e.facetFields.push({name:t.id,type:"FIELD",limit:100,sort:"count",minimumCount:1});return this._searchQuery?.trim().length&&e.queryFields.push({name:"_text_",operation:"IS",value:wi(this._searchQuery,!1)}),e}_toDbParams(){const e={page:this._page-1,size:this._pageSize,sorts:this._sorts,filterFields:[],queryFields:[],facetFields:[]};for(const t of this._model.columns)t.filter&&!t.filter.isEmpty()&&t.filter.isValid()&&e.filterFields.push(t.filter.toDbParams());return this._searchQuery?.trim().length&&this._model.columns.filter((e=>e.searchable)).forEach((t=>{e.queryFields.push({name:t.id,operation:"CONTAINS",value:this._searchQuery,and:!1})})),e}_toOpensearchParams(){const e={from:(this._page-1)*this._pageSize,size:this._pageSize,sort:this._sorts.map((e=>({[this._model.columns.find((t=>t.id===e.sortBy))?.searchField??e.sortBy]:e.sortDirection}))),query:{bool:{must:[],filter:[]}}};for(const t of this._model.columns)t.filter&&!t.filter.isEmpty()&&t.filter.isValid()&&e.query.bool.filter.push(t.filter.toOpensearchData());const t=this._searchQuery?.trim().replace(/([*?\\])/g,"\\$1");return t?e.query.bool.must.push({bool:{should:this._model.columns.filter((e=>e.searchable)).map((e=>({wildcard:{[e.searchField??e.id]:{value:`*${t}*`,case_insensitive:!0}}}))),minimum_should_match:1}}):e.query.bool.must.push({match_all:{}}),e}_fetch(){if(this._model.data)return this._data=this._model.data,this._totalItems=this._model.data.length,this._totalPages=Math.ceil(this._model.data.length/this._pageSize),void(this._dataState="success");if(!this._model.dataSource)return;let e;this._dataState="loading",e="db"===this._model.dataSource.mode?this._toDbParams():"opensearch"===this._model.dataSource.mode?this._toOpensearchParams():"array"===this._model.dataSource.mode?void 0:this._toSolrData(),this._model.dataSource.fetch(e).then((e=>{switch(this._model.dataSource?.mode){case"array":this._data=e,this._totalItems=e.length,this._totalPages=1,this._pageSize=e.length;break;case"opensearch":this._data=(e?.data?.hits?.hits||[]).map((e=>e._source)),this._totalItems=e?.data?.hits?.total?.value??0,this._totalPages=Math.ceil(this._totalItems/this._pageSize)||1;break;case"db":{const t=e;this._data=t.data.content,this._totalItems=t.data.totalElements,this._totalPages=t.data.totalPages,this._pageSize=t.data.size;break}default:{const t=e;this._data=t.data.content,this._totalItems=t.data.totalElements,this._totalPages=t.data.totalPages,this._pageSize=t.data.size,this._parseFacetResults(t)}}this._dataState="success",this._updateSearchPosition()})).catch((e=>{this._dataState="error";let t="Failed to load data";e instanceof Error&&(t=e.message),hi.show({message:t,type:"error"})}))}_parseFacetResults(e){if(e.data.facetFields){for(const t of this._model.columns){if(!t.facetable)continue;const i=e.data.facetFields[t.id];if(!i){this._buckets.set(t.id,[]);continue}const s=[];for(const e of i){let i=e.name;"boolean"===t.type&&"string"==typeof e.name&&("true"===e.name?i=!0:"false"===e.name&&(i=!1)),null===e.name&&e.count>0&&s.unshift({val:null,count:e.count}),null!==e.name&&s.push({val:i,count:e.count})}if(t.filter&&("in"===t.filter.operator||"n_in"===t.filter.operator)&&Array.isArray(t.filter.value))for(const e of t.filter.value)s.some((t=>t.val===e))||s.push({val:e,count:0});this._buckets.set(t.id,s)}this._buckets=new Map(this._buckets)}}_initRefresh(){clearInterval(this._refreshTimer),this._model.refreshInterval&&this._model.refreshInterval>0&&(this._refreshTimer=window.setInterval((()=>{this._fetch()}),this._model.refreshInterval))}_handleSearch(e){const t=e.target;this._searchQuery=t.value,this._page=1,this._fetch()}_updateSearchPosition(){if(this._searchPositionLocked)return;if("card"===this.variant||"dialog"===this.variant)return;const e=this.shadowRoot?.querySelector(".search"),t=e?.querySelector(".search-field");e&&t&&(e.style.justifyContent="center",t.style.marginLeft="",requestAnimationFrame((()=>{const i=e.getBoundingClientRect(),s=t.getBoundingClientRect().left-i.left;e.style.justifyContent="flex-start",t.style.marginLeft=`${s}px`,this._searchPositionLocked=!0})))}_handleColumnPickerClick(){this._columnPickerOpen=!this._columnPickerOpen}_handleColumnToggle(e){this._model.displayedColumns.includes(e)?this._model.displayedColumns=this._model.displayedColumns.filter((t=>t!==e)):this._model.displayedColumns=[...this._model.displayedColumns,e],this.requestUpdate()}_handleRowMouseDown(){(this._model.rowClickable||this._model.rowHref)&&window.getSelection()?.removeAllRanges()}_handleRowClick(e,t,i){if(!this._model.rowClickable&&!this._model.rowHref)return;const s=window.getSelection();s&&s.toString().length>0?e.preventDefault():this.dispatchEvent(new CustomEvent("row-click",{detail:{row:t,rowIndex:i},bubbles:!0,composed:!0}))}_handleSelectCellClick(e){e.stopPropagation(),e.preventDefault()}_handleRowSelectToggle(e,t){const i=this._model.rowKey(t);this._selectedRows.has(i)?this._selectedRows.delete(i):this._selectedRows.add(i),this.requestUpdate(),this.dispatchEvent(new CustomEvent("selection-change",{detail:{rows:this.getSelectedRows()},bubbles:!0,composed:!0}))}_handleSelectAllToggle(){this._data.every((e=>this._selectedRows.has(this._model.rowKey(e))))?this._data.forEach((e=>this._selectedRows.delete(this._model.rowKey(e)))):this._data.forEach((e=>this._selectedRows.add(this._model.rowKey(e)))),this.requestUpdate(),this.dispatchEvent(new CustomEvent("selection-change",{detail:{rows:this.getSelectedRows()},bubbles:!0,composed:!0}))}getDisplayedColumns(){return this._model.displayedColumns.map((e=>this._model.columns.find((t=>t.id===e)))).sort(((e,t)=>"actions"===e.type&&"actions"!==t.type?1:"actions"!==e.type&&"actions"===t.type?-1:0))}_handleScroll(e){const t=e.target;this._canScrollLeft=t.scrollLeft>0,this._canScrollRight=t.scrollLeft<t.scrollWidth-t.clientWidth-1}_updateScrollFlags(){const e=this.shadowRoot?.querySelector(".content");e&&(this._canScrollLeft=e.scrollLeft>0,this._canScrollRight=e.scrollWidth>e.clientWidth&&e.scrollLeft<e.scrollWidth-e.clientWidth-1,this._canScrollHorizontal=e.scrollWidth>e.clientWidth),this.classList.toggle("kr-table--scroll-left-available",this._canScrollLeft),this.classList.toggle("kr-table--scroll-right-available",this._canScrollRight),this.classList.toggle("kr-table--scroll-horizontal-available",this._canScrollHorizontal),this.classList.toggle("kr-table--sticky-left",this.getDisplayedColumns().some((e=>"left"===e.sticky))),this.classList.toggle("kr-table--sticky-right",this.getDisplayedColumns().some((e=>"right"===e.sticky)))}_handleResizeStart(e,t){e.preventDefault();const i=this.shadowRoot?.querySelector(`.header-cell[data-column-id="${t}"]`);this._resizing={columnId:t,startX:e.clientX,startWidth:i?.offsetWidth||200},document.addEventListener("mousemove",this._handleResizeMove),document.addEventListener("mouseup",this._handleResizeEnd)}_handleSortClick(e,t){if(e.shiftKey){const e=this._sorts.findIndex((e=>e.sortBy===t.id));if(-1===e)this._sorts.push({sortBy:t.id,sortDirection:"asc"});else{const t=this._sorts[e];"asc"===t.sortDirection?t.sortDirection="desc":this._sorts.splice(e,1)}this.requestUpdate()}else{let e=null;1===this._sorts.length&&(e=this._sorts.find((e=>e.sortBy===t.id))),e?"asc"===e.sortDirection?this._sorts=[{sortBy:t.id,sortDirection:"desc"}]:this._sorts=[]:this._sorts=[{sortBy:t.id,sortDirection:"asc"}]}this._page=1,this._fetch()}_renderSortIndicator(e){if(!e.sortable)return U;const t=this._sorts.findIndex((t=>t.sortBy===e.id));if(-1===t)return N`
3674
3692
  <span class="header-cell__sort" @click=${t=>this._handleSortClick(t,e)}>
3675
3693
  <svg
3676
3694
  class="header-cell__sort-arrow header-cell__sort-arrow--ghost"
@@ -3696,6 +3714,15 @@ class $e extends _e{constructor(e){if(super(e),this.it=U,e.type!==fe)throw Error
3696
3714
  </span>
3697
3715
  `}_handleAction(e){e.href||this.dispatchEvent(new CustomEvent("action",{detail:{action:e.id},bubbles:!0,composed:!0}))}showActionLoading(){this.shadowRoot?.querySelector(".actions")?.showLoading()}showActionSuccess(e="Done"){this.shadowRoot?.querySelector(".actions")?.showSuccess(e)}showActionError(e="Failed"){this.shadowRoot?.querySelector(".actions")?.showError(e)}resetAction(){this.shadowRoot?.querySelector(".actions")?.reset()}_handleKqlChange(e,t){const i=e.target.value.trim();if(i){if(t.filter.setKql(i),this.requestUpdate(),!t.filter.isValid())return}else t.filter.clear(),this.requestUpdate();this._page=1,this._fetch()}_handleFilterPanelToggle(e,t){if(e.stopPropagation(),this._filterPanelOpened===t.id)this._filterPanelOpened=null;else{const i=e.currentTarget.getBoundingClientRect();let s=i.left;s+328>window.innerWidth&&(s=window.innerWidth-328),this._filterPanelPos={top:i.bottom+4,left:s},this._filterPanelOpened=t.id,t.facetable?this._filterPanelTab="counts":this._filterPanelTab="filter"}}_handleKqlClear(e){e.filter.clear(),this._page=1,this._fetch()}_handleFilterClear(){const e=this._model.columns.find((e=>e.id===this._filterPanelOpened));e&&(e.filter.clear(),e.facetable&&!e.filterable&&(e.filter.operator="in",e.filter.value=[])),this._filterPanelOpened=null,this._page=1,this._fetch()}_handleFilterTextKeydown(e,t){"Enter"===e.key&&(e.preventDefault(),this._handleFilterApply())}_handleOperatorChange(e,t){t.filter.setOperator(e.target.value),this.requestUpdate()}_handleFilterStringChange(e,t){t.filter.setValue(e.target.value),this.requestUpdate()}_handleFilterNumberChange(e,t){t.filter.setValue(Number(e.target.value)),this.requestUpdate()}_handleFilterDateChange(e,t){t.filter.setValue(new Date(e.target.value),"day"),this.requestUpdate()}_handleFilterBooleanChange(e,t){t.filter.setValue("true"===e.target.value),this.requestUpdate()}_handleFilterDateStartChange(e,t){t.filter.setStart(new Date(e.target.value),"day"),this.requestUpdate()}_handleFilterDateEndChange(e,t){t.filter.setEnd(new Date(e.target.value),"day"),this.requestUpdate()}_handleFilterNumberStartChange(e,t){t.filter.setStart(Number(e.target.value)),this.requestUpdate()}_handleFilterNumberEndChange(e,t){t.filter.setEnd(Number(e.target.value)),this.requestUpdate()}_handleFilterListChange(e,t){const i=e.target.value.split(",").map((e=>e.trim())).filter((e=>""!==e));"number"===t.type?t.filter.setValue(i.map((e=>Number(e)))):t.filter.setValue(i),this.requestUpdate()}_handleFilterApply(){this._filterPanelOpened=null,this._page=1,this._fetch()}_handleFilterPanelTabChange(e){this._filterPanelTab=e.detail.activeTabId}_handleBucketToggle(e,t,i){t.filter.toggle(i.val),this._page=1,this._fetch()}_renderCellContent(e,t,i){const s=t[e.id];if(e.render)return N`<slot name="cell-${i}-${e.id}"></slot>`;if(null==s)return"";switch(e.type){case"number":return"currency"===e.format&&"number"==typeof s?s.toLocaleString("en-US",{style:"currency",currency:"USD"}):String(s);case"date":{let e;if(s instanceof Date)e=s;else if("string"==typeof s&&/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/.test(s)){const t=s.replace(/(\d{2}:\d{2}:\d{2}):(\d+)$/,"$1.$2").replace(" ","T")+"Z";e=new Date(t)}else e=new Date(s);return e.toLocaleString(void 0,{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit"})}case"boolean":return!0===s?"Yes":!1===s?"No":"";default:return String(s)}}_getCellStyle(e,t){const i={};if("left"===e.sticky){let e=0;this._model.rowSelectable&&(e+=54);for(let i=0;i<t;i++){const t=this.getDisplayedColumns()[i];"left"===t.sticky&&(e+=parseInt(t.width||"0",10))}i.left=`${e}px`}if("right"===e.sticky){let e=0;for(let i=t+1;i<this.getDisplayedColumns().length;i++){const t=this.getDisplayedColumns()[i];"right"===t.sticky&&(e+=parseInt(t.width||"0",10))}i.right=`${e}px`}return i}_renderPagination(){const e=(this._page-1)*this._pageSize+1,t=Math.min(this._page*this._pageSize,this._totalItems);return N`
3698
3716
  <div class="pagination">
3717
+ <span
3718
+ class=${ye({"pagination-icon":!0,"pagination-icon--disabled":1===this._page})}
3719
+ title="First page"
3720
+ @click=${this.goToFirstPage}
3721
+ >
3722
+ <svg viewBox="0 0 24 24" fill="currentColor">
3723
+ <path d="M18.41 16.59L13.82 12l4.59-4.59L17 6l-6 6 6 6zM6 6h2v12H6z"/>
3724
+ </svg>
3725
+ </span>
3699
3726
  <span
3700
3727
  class=${ye({"pagination-icon":!0,"pagination-icon--disabled":1===this._page})}
3701
3728
  @click=${this.goToPrevPage}
@@ -3713,6 +3740,15 @@ class $e extends _e{constructor(e){if(super(e),this.it=U,e.type!==fe)throw Error
3713
3740
  <path d="M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"/>
3714
3741
  </svg>
3715
3742
  </span>
3743
+ <span
3744
+ class=${ye({"pagination-icon":!0,"pagination-icon--disabled":this._page===this._totalPages})}
3745
+ title="Last page"
3746
+ @click=${this.goToLastPage}
3747
+ >
3748
+ <svg viewBox="0 0 24 24" fill="currentColor">
3749
+ <path d="M5.59 7.41L10.18 12l-4.59 4.59L7 18l6-6-6-6zM16 6h2v12h-2z"/>
3750
+ </svg>
3751
+ </span>
3716
3752
  </div>
3717
3753
  `}_renderCardHeader(){return"card"!==this.variant?U:this._model.title||this._model.description?N`
3718
3754
  <div class="card-header">
@@ -5298,7 +5334,7 @@ class $e extends _e{constructor(e){if(super(e),this.it=U,e.type!==fe)throw Error
5298
5334
  flex-shrink: 0;
5299
5335
  border-top: 1px solid rgba(0, 0, 0, 0.1);
5300
5336
  }
5301
- `],Li([ce({type:Boolean,reflect:!0})],Vi.prototype,"opened",void 0),Li([ce({type:String})],Vi.prototype,"title",void 0),Li([ce({type:String})],Vi.prototype,"description",void 0),Li([ce({attribute:!1})],Vi.prototype,"def",void 0),Li([ce({attribute:!1})],Vi.prototype,"actions",void 0),customElements.get("krs-grid-dialog")||customElements.define("krs-grid-dialog",Vi);var Bi=function(e,t,i,s){var o,r=arguments.length,a=r<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,i,s);else for(var n=e.length-1;n>=0;n--)(o=e[n])&&(a=(r<3?o(a):r>3?o(t,i,a):o(t,i))||a);return r>3&&a&&Object.defineProperty(t,i,a),a};class Fi extends ne{constructor(){super(...arguments),this.size="md",this.color="dark"}render(){var e="",t="";return e="sm"==this.size?"16px":"md"==this.size?"24px":"lg"==this.size?"32px":"xl"==this.size?"48px":this.size,t="dark"==this.color?"#163052":"light"==this.color?"#ffffff":this.color,N`
5337
+ `],Li([ce({type:Boolean,reflect:!0})],Vi.prototype,"opened",void 0),Li([ce({type:String})],Vi.prototype,"title",void 0),Li([ce({type:String})],Vi.prototype,"description",void 0),Li([ce({attribute:!1})],Vi.prototype,"def",void 0),Li([ce({attribute:!1})],Vi.prototype,"actions",void 0),customElements.get("krs-grid-dialog")||customElements.define("krs-grid-dialog",Vi);var Fi=function(e,t,i,s){var o,r=arguments.length,a=r<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,i,s);else for(var n=e.length-1;n>=0;n--)(o=e[n])&&(a=(r<3?o(a):r>3?o(t,i,a):o(t,i))||a);return r>3&&a&&Object.defineProperty(t,i,a),a};class Bi extends ne{constructor(){super(...arguments),this.size="md",this.color="dark"}render(){var e="",t="";return e="sm"==this.size?"16px":"md"==this.size?"24px":"lg"==this.size?"32px":"xl"==this.size?"48px":this.size,t="dark"==this.color?"#163052":"light"==this.color?"#ffffff":this.color,N`
5302
5338
  <svg
5303
5339
  class="spinner"
5304
5340
  style=${we({width:e,height:e,color:t})}
@@ -5315,7 +5351,7 @@ class $e extends _e{constructor(e){if(super(e),this.it=U,e.type!==fe)throw Error
5315
5351
  stroke-width="4"
5316
5352
  />
5317
5353
  </svg>
5318
- `}}Fi.styles=a`
5354
+ `}}Bi.styles=a`
5319
5355
  :host {
5320
5356
  display: inline-flex;
5321
5357
  align-items: center;
@@ -5358,7 +5394,7 @@ class $e extends _e{constructor(e){if(super(e),this.it=U,e.type!==fe)throw Error
5358
5394
  stroke: currentColor;
5359
5395
  stroke-linecap: round;
5360
5396
  }
5361
- `,Bi([ce({type:String,reflect:!0})],Fi.prototype,"size",void 0),Bi([ce({type:String,reflect:!0})],Fi.prototype,"color",void 0),customElements.get("krs-spinner")||customElements.define("krs-spinner",Fi);var Ni=function(e,t,i,s){var o,r=arguments.length,a=r<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,i,s);else for(var n=e.length-1;n>=0;n--)(o=e[n])&&(a=(r<3?o(a):r>3?o(t,i,a):o(t,i))||a);return r>3&&a&&Object.defineProperty(t,i,a),a};class ji extends ne{constructor(){super(...arguments),this.color="dark"}render(){let e="",t="";return e="dark"===this.color?"#163052":"light"===this.color?"#ffffff":this.color,t=this.trackColor?this.trackColor:"light"===this.color?"#ffffff4d":"#0000001a",N`
5397
+ `,Fi([ce({type:String,reflect:!0})],Bi.prototype,"size",void 0),Fi([ce({type:String,reflect:!0})],Bi.prototype,"color",void 0),customElements.get("krs-spinner")||customElements.define("krs-spinner",Bi);var Ni=function(e,t,i,s){var o,r=arguments.length,a=r<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,i,s);else for(var n=e.length-1;n>=0;n--)(o=e[n])&&(a=(r<3?o(a):r>3?o(t,i,a):o(t,i))||a);return r>3&&a&&Object.defineProperty(t,i,a),a};class ji extends ne{constructor(){super(...arguments),this.color="dark"}render(){let e="",t="";return e="dark"===this.color?"#163052":"light"===this.color?"#ffffff":this.color,t=this.trackColor?this.trackColor:"light"===this.color?"#ffffff4d":"#0000001a",N`
5362
5398
  <div
5363
5399
  class="progress-bar"
5364
5400
  style=${we({background:t})}
@@ -5921,7 +5957,7 @@ class $e extends _e{constructor(e){if(super(e),this.it=U,e.type!==fe)throw Error
5921
5957
  * @license
5922
5958
  * Copyright 2020 Google LLC
5923
5959
  * SPDX-License-Identifier: BSD-3-Clause
5924
- */,Xi=be(class extends _e{constructor(e){if(super(e),e.type!==me&&e.type!==ge&&e.type!==ve)throw Error("The `live` directive is not allowed on child or event bindings");if(!(e=>void 0===e.strings)(e))throw Error("`live` bindings can only contain a single expression")}render(e){return e}update(e,[t]){if(t===j||t===U)return t;const i=e.element,s=e.name;if(e.type===me){if(t===i[s])return j}else if(e.type===ve){if(!!t===i.hasAttribute(s))return j}else if(e.type===ge&&i.getAttribute(s)===t+"")return j;return Oe(e),t}});var Zi=function(e,t,i,s){var o,r=arguments.length,a=r<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,i,s);else for(var n=e.length-1;n>=0;n--)(o=e[n])&&(a=(r<3?o(a):r>3?o(t,i,a):o(t,i))||a);return r>3&&a&&Object.defineProperty(t,i,a),a};class Ji extends ne{static fromJSON(e){const t=new Ji;return void 0!==e.label&&(t.label=e.label),void 0!==e.name&&(t.name=e.name),void 0!==e.value&&(t.value=e.value),void 0!==e.placeholder&&(t.placeholder=e.placeholder),void 0!==e.type&&(t.type=e.type),void 0!==e.required&&(t.required=e.required),void 0!==e.disabled&&(t.disabled=e.disabled),void 0!==e.readonly&&(t.readonly=e.readonly),void 0!==e.minlength&&(t.minlength=e.minlength),void 0!==e.maxlength&&(t.maxlength=e.maxlength),void 0!==e.pattern&&(t.pattern=e.pattern),void 0!==e.autocomplete&&(t.autocomplete=e.autocomplete),void 0!==e.hint&&(t.hint=e.hint),void 0!==e.saveMode&&(t.saveMode=e.saveMode),t}constructor(){super(),this._dirtyValue="",this.label="",this.name="",this.value="",this.valueAsNumber=null,this.placeholder="",this.type="text",this.required=!1,this.disabled=!1,this.readonly=!1,this.autocomplete="",this.hint="",this.dirty=!1,this.saving=!1,this._touched=!1,this._handleInvalid=e=>{e.preventDefault(),this._touched=!0},this._internals=this.attachInternals()}connectedCallback(){super.connectedCallback(),this.classList.add("kr-form-field"),this.addEventListener("invalid",this._handleInvalid)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("invalid",this._handleInvalid)}firstUpdated(){this._updateValidity()}willUpdate(e){let t=this.saveMode;t||(t=this.closest("krs-form")?.saveMode),e.has("value")&&this.dirty&&this.value!==this._dirtyValue&&"autosave"===t&&(this.value=this._dirtyValue)}updated(e){if((e.has("required")||e.has("value"))&&this._updateValidity(),e.has("value")){const e=Number(this.value);""===this.value||Number.isNaN(e)?this.valueAsNumber=null:this.valueAsNumber=e}}get form(){return this._internals.form}get validity(){return this._internals.validity}get validationMessage(){return this._internals.validationMessage}get willValidate(){return this._internals.willValidate}checkValidity(){return this._internals.checkValidity()}reportValidity(){return this._internals.reportValidity()}formResetCallback(){this.value="",this._touched=!1,this.dirty=!1,this.saving=!1,this._internals.setFormValue(""),this._internals.setValidity({})}markPristine(){this.dirty=!1}markSaving(){this.saving=!0,this.dirty=!1}markSaved(){this.saving=!1}markSaveFailed(){this.saving=!1,this.dirty=!0,this._dirtyValue=this.value}formStateRestoreCallback(e){this.value=e}focus(){this._input?.focus()}blur(){this._input?.blur()}select(){this._input?.select()}_updateValidity(){this._input&&this._internals.setValidity(this._input.validity,this._input.validationMessage)}_handleInput(e){this.value=e.target.value,this.dirty=!0,this._dirtyValue=this.value,this._internals.setFormValue(this.value),this._internals.setValidity(this._input.validity,this._input.validationMessage)}_handleChange(e){this.value=e.target.value,this._internals.setFormValue(this.value),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}_handleBlur(){this._touched=!0,this._internals.setValidity(this._input.validity,this._input.validationMessage)}render(){let e="";return this._touched&&this._input&&!this._input.validity.valid&&(e=this._input.validationMessage),N`
5960
+ */,Xi=be(class extends _e{constructor(e){if(super(e),e.type!==ve&&e.type!==ge&&e.type!==me)throw Error("The `live` directive is not allowed on child or event bindings");if(!(e=>void 0===e.strings)(e))throw Error("`live` bindings can only contain a single expression")}render(e){return e}update(e,[t]){if(t===j||t===U)return t;const i=e.element,s=e.name;if(e.type===ve){if(t===i[s])return j}else if(e.type===me){if(!!t===i.hasAttribute(s))return j}else if(e.type===ge&&i.getAttribute(s)===t+"")return j;return Oe(e),t}});var Zi=function(e,t,i,s){var o,r=arguments.length,a=r<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,i,s);else for(var n=e.length-1;n>=0;n--)(o=e[n])&&(a=(r<3?o(a):r>3?o(t,i,a):o(t,i))||a);return r>3&&a&&Object.defineProperty(t,i,a),a};class Ji extends ne{static fromJSON(e){const t=new Ji;return void 0!==e.label&&(t.label=e.label),void 0!==e.name&&(t.name=e.name),void 0!==e.value&&(t.value=e.value),void 0!==e.placeholder&&(t.placeholder=e.placeholder),void 0!==e.type&&(t.type=e.type),void 0!==e.required&&(t.required=e.required),void 0!==e.disabled&&(t.disabled=e.disabled),void 0!==e.readonly&&(t.readonly=e.readonly),void 0!==e.minlength&&(t.minlength=e.minlength),void 0!==e.maxlength&&(t.maxlength=e.maxlength),void 0!==e.pattern&&(t.pattern=e.pattern),void 0!==e.autocomplete&&(t.autocomplete=e.autocomplete),void 0!==e.hint&&(t.hint=e.hint),void 0!==e.saveMode&&(t.saveMode=e.saveMode),t}constructor(){super(),this._dirtyValue="",this.label="",this.name="",this.value="",this.valueAsNumber=null,this.placeholder="",this.type="text",this.required=!1,this.disabled=!1,this.readonly=!1,this.autocomplete="",this.hint="",this.dirty=!1,this.saving=!1,this._touched=!1,this._handleInvalid=e=>{e.preventDefault(),this._touched=!0},this._internals=this.attachInternals()}connectedCallback(){super.connectedCallback(),this.classList.add("kr-form-field"),this.addEventListener("invalid",this._handleInvalid)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("invalid",this._handleInvalid)}firstUpdated(){this._updateValidity()}willUpdate(e){let t=this.saveMode;t||(t=this.closest("krs-form")?.saveMode),e.has("value")&&this.dirty&&this.value!==this._dirtyValue&&"autosave"===t&&(this.value=this._dirtyValue)}updated(e){if((e.has("required")||e.has("value"))&&this._updateValidity(),e.has("value")){const e=Number(this.value);""===this.value||Number.isNaN(e)?this.valueAsNumber=null:this.valueAsNumber=e}}get form(){return this._internals.form}get validity(){return this._internals.validity}get validationMessage(){return this._internals.validationMessage}get willValidate(){return this._internals.willValidate}checkValidity(){return this._internals.checkValidity()}reportValidity(){return this._internals.reportValidity()}formResetCallback(){this.value="",this._touched=!1,this.dirty=!1,this.saving=!1,this._internals.setFormValue(""),this._internals.setValidity({})}markPristine(){this.dirty=!1}markSaving(){this.saving=!0,this.dirty=!1}markSaved(){this.saving=!1}markSaveFailed(){this.saving=!1,this.dirty=!0,this._dirtyValue=this.value}formStateRestoreCallback(e){this.value=e}focus(){this._input?.focus()}blur(){this._input?.blur()}select(){this._input?.select()}_updateValidity(){this._input&&this._internals.setValidity(this._input.validity,this._input.validationMessage)}_handleInput(e){this.value=e.target.value,this.dirty=!0,this._dirtyValue=this.value,this._internals.setFormValue(this.value),this._internals.setValidity(this._input.validity,this._input.validationMessage)}_handleChange(e){this.value=e.target.value,this._internals.setFormValue(this.value),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}_handleBlur(){this._touched=!0,this._internals.setValidity(this._input.validity,this._input.validationMessage)}render(){let e="";return this._touched&&this._input&&!this._input.validity.valid&&(e=this._input.validationMessage),N`
5925
5961
  <div class="wrapper">
5926
5962
  ${this.label?N`
5927
5963
  <label for="input">
@@ -7464,11 +7500,11 @@ class $e extends _e{constructor(e){if(super(e),this.it=U,e.type!==fe)throw Error
7464
7500
  font-size: 0.75rem;
7465
7501
  color: var(--kr-text-field-helper-color, #6b7280);
7466
7502
  }
7467
- `,us.formAssociated=!0,ps([ce({type:String})],us.prototype,"label",void 0),ps([ce({type:String})],us.prototype,"name",void 0),ps([ce({type:String})],us.prototype,"accept",void 0),ps([ce({type:Boolean})],us.prototype,"multiple",void 0),ps([ce({type:String})],us.prototype,"placeholder",void 0),ps([ce({type:String})],us.prototype,"value",void 0),ps([ce({type:String})],us.prototype,"buttonLabel",void 0),ps([ce({type:Boolean})],us.prototype,"required",void 0),ps([ce({type:Boolean})],us.prototype,"disabled",void 0),ps([ce({type:String})],us.prototype,"hint",void 0),ps([ce({attribute:!1})],us.prototype,"files",void 0),ps([ce({type:Boolean,reflect:!0})],us.prototype,"dirty",void 0),ps([ce({type:Boolean,reflect:!0})],us.prototype,"saving",void 0),ps([pe()],us.prototype,"_touched",void 0),ps([pe()],us.prototype,"_focused",void 0),ps([ue("input")],us.prototype,"_input",void 0),customElements.get("krs-file-field")||customElements.define("krs-file-field",us);var gs=function(e,t,i,s){var o,r=arguments.length,a=r<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,i,s);else for(var n=e.length-1;n>=0;n--)(o=e[n])&&(a=(r<3?o(a):r>3?o(t,i,a):o(t,i))||a);return r>3&&a&&Object.defineProperty(t,i,a),a};class fs extends ne{constructor(){super(...arguments),this._saveQueue=Promise.resolve(),this.save=null,this.saveMode="autosave",this._handleChange=()=>{this.save&&(this._saveQueue=this._saveQueue.then((()=>{const e=Array.from(this.querySelectorAll(".kr-form-field")).filter((e=>e.dirty&&e.name));if(!e.length)return;const t=this.getChanges();for(const t of e)t.markSaving?.();return Promise.resolve().then((()=>this.save(t))).then((()=>{for(const t of e)t.markSaved?.()}),(t=>{for(const t of e)t.markSaveFailed?.();return t instanceof Response?(console.error("krs-form save failed",t.status,t.url),t.json()):(console.error("krs-form save failed",t),{errors:[]})})).then((e=>{e&&hi.show({message:e.errors?.[0]||"Save failed.",type:"error"})}),(e=>{console.error("krs-form save failed with an unreadable response body",e),hi.show({message:"Save failed.",type:"error"})}))})))}}static fromJSON(e){if("text-field"===e.type)return Ji.fromJSON(e);if("textarea-field"===e.type)return ts.fromJSON(e);if("number-field"===e.type)return Gi.fromJSON(e);if("checkbox"===e.type)return Mi.fromJSON(e);if("select-field"===e.type)return bi.fromJSON(e);if("combo-box"===e.type)return ns.fromJSON(e);if("date-picker"===e.type)return cs.fromJSON(e);if("date-range-picker"===e.type)return li.fromJSON(e);if("auto-suggest"===e.type)return rs.fromJSON(e);if("radio-cards"===e.type)return ds.fromJSON(e);if("file-field"===e.type)return us.fromJSON(e);if("detail-field"===e.type)return ss.fromJSON(e);if("monaco"===e.type){const t=customElements.get("kr-monaco");if(!t)return;return t.fromJSON(e)}}connectedCallback(){super.connectedCallback(),this.addEventListener("change",this._handleChange)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("change",this._handleChange)}getChanges(){const e={};for(const t of Array.from(this.querySelectorAll(".kr-form-field")))t.dirty&&t.name&&("checked"in t&&"boolean"==typeof t.checked?e[t.name]=t.checked:"KR-DATE-PICKER"===t.tagName?e[t.name]=t.valueAsDate:"KR-NUMBER-FIELD"===t.tagName?e[t.name]=t.valueAsNumber:e[t.name]=t.value);return e}hasChanges(){for(const e of Array.from(this.querySelectorAll(".kr-form-field")))if(e.dirty&&e.name)return!0;return!1}markPristine(){for(const e of Array.from(this.querySelectorAll(".kr-form-field")))e.markPristine?.()}render(){return N`<slot></slot>`}}fs.styles=a`
7503
+ `,us.formAssociated=!0,ps([ce({type:String})],us.prototype,"label",void 0),ps([ce({type:String})],us.prototype,"name",void 0),ps([ce({type:String})],us.prototype,"accept",void 0),ps([ce({type:Boolean})],us.prototype,"multiple",void 0),ps([ce({type:String})],us.prototype,"placeholder",void 0),ps([ce({type:String})],us.prototype,"value",void 0),ps([ce({type:String})],us.prototype,"buttonLabel",void 0),ps([ce({type:Boolean})],us.prototype,"required",void 0),ps([ce({type:Boolean})],us.prototype,"disabled",void 0),ps([ce({type:String})],us.prototype,"hint",void 0),ps([ce({attribute:!1})],us.prototype,"files",void 0),ps([ce({type:Boolean,reflect:!0})],us.prototype,"dirty",void 0),ps([ce({type:Boolean,reflect:!0})],us.prototype,"saving",void 0),ps([pe()],us.prototype,"_touched",void 0),ps([pe()],us.prototype,"_focused",void 0),ps([ue("input")],us.prototype,"_input",void 0),customElements.get("krs-file-field")||customElements.define("krs-file-field",us);var gs=function(e,t,i,s){var o,r=arguments.length,a=r<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,i,s);else for(var n=e.length-1;n>=0;n--)(o=e[n])&&(a=(r<3?o(a):r>3?o(t,i,a):o(t,i))||a);return r>3&&a&&Object.defineProperty(t,i,a),a};class fs extends ne{constructor(){super(...arguments),this._saveQueue=Promise.resolve(),this.save=null,this.saveMode="autosave",this._handleChange=()=>{this.save&&(this._saveQueue=this._saveQueue.then((()=>{const e=Array.from(this.querySelectorAll(".kr-form-field")).filter((e=>e.dirty&&e.name));if(!e.length)return;const t=this.getChanges();for(const t of e)t.markSaving?.();return Promise.resolve().then((()=>this.save(t))).then((()=>{for(const t of e)t.markSaved?.()}),(t=>{for(const t of e)t.markSaveFailed?.();return t instanceof Response?(console.error("krs-form save failed",t.status,t.url),t.json()):(console.error("krs-form save failed",t),{errors:[]})})).then((e=>{e&&hi.show({message:e.errors?.[0]||"Save failed.",type:"error"})}),(e=>{console.error("krs-form save failed with an unreadable response body",e),hi.show({message:"Save failed.",type:"error"})}))})))}}static fromJSON(e){if("text-field"===e.type)return Ji.fromJSON(e);if("textarea-field"===e.type)return ts.fromJSON(e);if("number-field"===e.type)return Gi.fromJSON(e);if("checkbox"===e.type)return Ai.fromJSON(e);if("select-field"===e.type)return bi.fromJSON(e);if("combo-box"===e.type)return ns.fromJSON(e);if("date-picker"===e.type)return cs.fromJSON(e);if("date-range-picker"===e.type)return li.fromJSON(e);if("auto-suggest"===e.type)return rs.fromJSON(e);if("radio-cards"===e.type)return ds.fromJSON(e);if("file-field"===e.type)return us.fromJSON(e);if("detail-field"===e.type)return ss.fromJSON(e);if("monaco"===e.type){const t=customElements.get("kr-monaco");if(!t)return;return t.fromJSON(e)}}connectedCallback(){super.connectedCallback(),this.addEventListener("change",this._handleChange)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("change",this._handleChange)}getChanges(){const e={};for(const t of Array.from(this.querySelectorAll(".kr-form-field")))t.dirty&&t.name&&("checked"in t&&"boolean"==typeof t.checked?e[t.name]=t.checked:"KR-DATE-PICKER"===t.tagName?e[t.name]=t.valueAsDate:"KR-NUMBER-FIELD"===t.tagName?e[t.name]=t.valueAsNumber:e[t.name]=t.value);return e}hasChanges(){for(const e of Array.from(this.querySelectorAll(".kr-form-field")))if(e.dirty&&e.name)return!0;return!1}markPristine(){for(const e of Array.from(this.querySelectorAll(".kr-form-field")))e.markPristine?.()}render(){return N`<slot></slot>`}}fs.styles=a`
7468
7504
  :host {
7469
7505
  display: block;
7470
7506
  }
7471
- `,gs([ce({attribute:!1})],fs.prototype,"save",void 0),gs([ce({attribute:"save-mode"})],fs.prototype,"saveMode",void 0),customElements.get("krs-form")||customElements.define("krs-form",fs);class ms{static configure(e){void 0!==e.baseUrl&&(ms._baseUrl=e.baseUrl),void 0!==e.devUrl&&(ms._devUrl=e.devUrl)}static getBaseUrl(){return"localhost"===window.location.hostname&&window.location.port.startsWith("4")&&ms._devUrl?ms._devUrl:ms._baseUrl}static fetch(e){let t=e.url;var i="localhost"===window.location.hostname&&window.location.port.startsWith("4");let s=ms.getBaseUrl();0!==t.indexOf("http")&&(t=s+t),e.params&&(t+="?",Object.keys(e.params).forEach(((i,s)=>{s>0&&(t+="&"),t+=`${i}=${e.params[i]}`})));var o={};let r;return e.headers&&(e.headers instanceof Headers?e.headers.forEach(((e,t)=>{o[t]=e})):Array.isArray(e.headers)?e.headers.forEach((([e,t])=>{o[e]=t})):Object.assign(o,e.headers)),!e.body||"object"!=typeof e.body||e.body instanceof ReadableStream||e.body instanceof Blob||e.body instanceof ArrayBuffer||e.body instanceof FormData||e.body instanceof URLSearchParams||(e.body=JSON.stringify(e.body),o["Content-Type"]||(o["Content-Type"]="application/json")),e.headers=o,i&&!e.credentials&&(e.credentials="include"),r=t.indexOf("/api/user/")>-1||t.indexOf("/api/account/")>-1?fetch(`${s}/api/user/customer/authToken`,{credentials:"include"}):Promise.resolve(null),r.then((e=>e?.json())).then((i=>(i?.data&&(o["X-CSRF-TOKEN"]=i.data),fetch(t,e)))).then((e=>e.ok?e:Promise.reject(e)))}}ms._baseUrl="",ms._devUrl="";var vs=function(e,t,i,s){var o,r=arguments.length,a=r<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,i,s);else for(var n=e.length-1;n>=0;n--)(o=e[n])&&(a=(r<3?o(a):r>3?o(t,i,a):o(t,i))||a);return r>3&&a&&Object.defineProperty(t,i,a),a};const bs=[{decision:"approve",label:"Yes"},{decision:"approveAlways",label:"Always allow"},{decision:"reject",label:"No"}],_s=[{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"}],ys=["jpg","jpeg","png","gif","webp"],ks=["pdf","doc","docx","xls","xlsx","csv","html","md","txt","json","xml","vtt","srt",...ys,"mp4","webm","ogg","mov"];class xs extends ne{constructor(){super(...arguments),this._inlineConfirm=!0,this._reasoningAsMessage=!0,this._reader=null,this._decoder=new TextDecoder,this._buffer="",this._turnFinishedCleanly=!1,this._reconnectAttempts=0,this._userHasScrolledUp=!1,this._followStream=!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._drawerResizeStartX=0,this._drawerResizeStartW=0,this._dragDepth=0,this._pendingSeq=0,this._pendingAttachAnalyze=!0,this._orgSkillRequestId=0,this._globalSkillRequestId=0,this._invocableSkillRequestId=0,this._suggestedActionRequestId=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._conversationTitle="",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._conversations=[],this._conversationsLoading=!1,this._toolDetail=null,this._toolDetailCopied=null,this._toolDetailInputOpen=!0,this._toolDetailOutputOpen=!0,this._drawerWidth=430,this._isDrawerResizing=!1,this._pendingConversationFiles=[],this._isDraggingFile=!1,this._skillMenuOpened=!1,this._skillQuery="",this._orgSkills=[],this._globalSkills=[],this._invocableSkills=[],this._suggestedActions=[],this._aiFrameworkConfig={},this._skillHighlighted=0,this._copiedIndex=-1,this._skillBrowseOpened=!1,this._skillBrowseDetail=null,this._skillInstallConfirm=null,this._skillOfferConfirm=null,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,o=380,r=.9*window.innerWidth,a=window.innerHeight-72;let n=this._resizeStartW,l=this._resizeStartH,d=this._dragStartLeft,h=this._dragStartTop;this._resizeDir.includes("e")&&(n=Math.max(s,Math.min(this._resizeStartW+t,r))),this._resizeDir.includes("w")&&(n=Math.max(s,Math.min(this._resizeStartW-t,r)),d=this._dragStartLeft+(this._resizeStartW-n)),this._resizeDir.includes("s")&&(l=Math.max(o,Math.min(this._resizeStartH+i,a))),this._resizeDir.includes("n")&&(l=Math.max(o,Math.min(this._resizeStartH-i,a)),h=this._dragStartTop+(this._resizeStartH-l)),d=Math.max(0,d),h=Math.max(0,h),this._panelEl.style.width=n+"px",this._panelEl.style.height=l+"px",this._panelEl.style.left=d+"px",this._panelEl.style.top=h+"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)%bs.length);if("ArrowLeft"===e.key)return e.preventDefault(),void(this._confirmationHighlighted=(this._confirmationHighlighted-1+bs.length)%bs.length);if("Enter"===e.key){e.preventDefault();const t=bs[this._confirmationHighlighted];t&&this._handleConfirmationDecision(t.decision)}}},this._handleDrawerResizeMouseMove=e=>{if(!this._isDrawerResizing)return;const t=e.clientX-this._drawerResizeStartX,i=Math.max(300,this.offsetWidth-300);this._drawerWidth=Math.max(300,Math.min(this._drawerResizeStartW-t,i))},this._handleDrawerResizeMouseUp=()=>{this._isDrawerResizing=!1,document.removeEventListener("mousemove",this._handleDrawerResizeMouseMove),document.removeEventListener("mouseup",this._handleDrawerResizeMouseUp),this._saveState()}}connectedCallback(){super.connectedCallback(),this.load||(this.load=()=>null==this.conversationId?Promise.resolve([]):ms.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("reasoning"===e.type)return Promise.resolve({type:"assistant",content:"",reasoning:e.content||""});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=>ms.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)}))))));let e=Promise.resolve();if("floating"===this.variant&&null==this.conversationId){const t=Number(sessionStorage.getItem("kr-chatbot-conversation-id"));t>0&&(this.conversationId=t,e=ms.fetch({url:`/api/system/conversation/${t}`}).then((e=>e.json())).then((e=>{this._conversationTitle=e?.data?.title||""})).catch((()=>{})))}e.then((()=>this.load())).then((e=>{e&&e.length&&(this.messages=e),this.conversationId&&!this._isStreaming&&this._reconnectStream()})).catch((()=>{})),ms.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)}))),this._isStreaming&&this._followStream&&this._messagesEl&&requestAnimationFrame((()=>{const e=this._messagesEl;if(!e||!this._isStreaming||!this._followStream)return;const t=e.querySelectorAll(".agent-turn"),i=t[t.length-1],s=i?.lastElementChild;if(!s)return;const o=s.getBoundingClientRect().bottom-e.getBoundingClientRect().top+e.scrollTop+24;o>e.scrollTop+e.clientHeight&&(e.scrollTop=Math.min(o-e.clientHeight,e.scrollHeight-e.clientHeight))})),e.has("opened")&&this.opened&&this._inputEl&&setTimeout((()=>{this._inputEl&&this._inputEl.focus()}),200),e.has("opened")&&this.opened&&0===this.messages.length&&this._loadSuggestedActions(),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(),o=Math.max(t,e.top-s.height-8);this._skillMenuEl.style.top=o+"px"}))}stop(){this._handleStop()}isStreaming(){return this._isStreaming}open(){this.opened||this._handleToggle()}close(){this.opened&&this._handleToggle()}toggle(){this._handleToggle()}prompt(e){this.open(),this._inputValue=e.message,this._handleSubmit()}draft(e){this.open(),this._inputValue=e.message,this._saveState(),this.updateComplete.then((()=>{setTimeout((()=>{this._inputEl&&(this._inputEl.focus(),this._inputEl.select())}),200)}))}_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()}_persistConversationId(){if("floating"===this.variant)try{null!=this.conversationId?sessionStorage.setItem("kr-chatbot-conversation-id",String(this.conversationId)):sessionStorage.removeItem("kr-chatbot-conversation-id")}catch{}}_saveState(){let e="kr-chatbot-state",t="kr-chatbot-tab";"inline"===this.variant&&(e="kr-chatbot-state-inline",t="kr-chatbot-tab-inline");try{const t={message:this._inputValue,mode:this._mode,showTools:String(this._showTools),showToolInputs:String(this._showToolInputs),showConfirmationInput:String(this._showConfirmationInput)};localStorage.setItem(e,JSON.stringify(t))}catch{}try{let e=this._drawerView;"toolDetail"===e&&(e="settings");const i={drawerOpen:String(this._drawerOpen),drawerView:e,drawerWidth:String(this._drawerWidth)};if("floating"===this.variant&&(i.opened=String(this.opened),this._panelEl)){const e=this._panelEl.style;e.left&&(i.left=e.left),e.top&&(i.top=e.top),e.width&&(i.width=e.width),e.height&&(i.height=e.height),e.position&&(i.position=e.position)}sessionStorage.setItem(t,JSON.stringify(i))}catch{}}_restoreState(){let e="kr-chatbot-state",t="kr-chatbot-tab";"inline"===this.variant&&(e="kr-chatbot-state-inline",t="kr-chatbot-tab-inline");try{const t=localStorage.getItem(e);if(t){const e=JSON.parse(t);"string"==typeof e.message&&"/"!==e.message.trim()&&(this._inputValue=e.message),"NORMAL"!==e.mode&&"EDIT"!==e.mode&&"PLAN"!==e.mode||(this._mode=e.mode),this._showTools="true"===e.showTools,this._showToolInputs="true"===e.showToolInputs,this._showConfirmationInput="true"===e.showConfirmationInput}}catch{}try{const e=sessionStorage.getItem(t);if(!e)return;const i=JSON.parse(e);this._drawerOpen="true"===i.drawerOpen,"settings"!==i.drawerView&&"debug"!==i.drawerView&&"history"!==i.drawerView||(this._drawerView=i.drawerView,"history"===i.drawerView&&this._loadConversations());const s=Number(i.drawerWidth);s>=300&&(this._drawerWidth=s),"floating"===this.variant&&"true"===i.opened&&(this.opened=!0,this.updateComplete.then((()=>this._applyStoredLayout())))}catch{}}_applyStoredLayout(){try{const e=sessionStorage.getItem("kr-chatbot-tab");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;ms.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("krs-chatbot: skill search failed",e)}))}_searchInvocableSkills(e){this._invocableSkillRequestId++;const t=this._invocableSkillRequestId;ms.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("krs-chatbot: invocable skill search failed",e)}))}_loadSuggestedActions(){this._suggestedActionRequestId++;const e=this._suggestedActionRequestId,t=this._captureContext();ms.fetch({url:"/api/system/conversation/suggestedActions",method:"POST",body:{pageContext:t.pageContext,selectionContext:t.selectionContext}}).then((e=>e.json())).then((t=>{e!==this._suggestedActionRequestId||this.messages.length>0||(this._suggestedActions=t?.data||[])})).catch((e=>{console.error("krs-chatbot: suggested actions load failed",e)}))}_searchGlobalSkills(e){this._globalSkillRequestId++;const t=this._globalSkillRequestId;ms.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("krs-chatbot: global skill search failed",e)}))}_handleGlobalSkillEnable(e,t){if(t.stopPropagation(),!e.canEnable)return void hi.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;if(!e.enabled&&e.billable)return void(this._skillInstallConfirm=e);const i=t.currentTarget;this._globalSkillPending.add(e.code),i?.showLoading(),ms.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,i?.reset(),this.requestUpdate(),e.enabled?hi.show({title:"Skill Installed",message:`${e.name} is now available to use.`,type:"success"}):hi.show({title:"Skill Uninstalled",message:`${e.name} is no longer available to use.`,type:"success"})})).catch((e=>{console.error("krs-chatbot: global skill enable failed",e),i?.showError("Error")})).finally((()=>{this._globalSkillPending.delete(e.code)}))}_handleSkillInstallCancel(){this._skillInstallConfirm=null}_handleSkillInstallConfirm(e){if(!this._skillInstallConfirm)return;if(this._globalSkillPending.has(this._skillInstallConfirm.code))return;const t=this._skillInstallConfirm,i=e.currentTarget;this._globalSkillPending.add(t.code),i?.showLoading(),ms.fetch({url:`/api/system/opensearch/aiskills/global/${encodeURIComponent(t.code)}/enabled`,method:"POST",body:{enabled:!0}}).then((e=>e.json())).then((e=>{t.enabled=e?.data?.enabled,i?.reset(),this._skillInstallConfirm=null,this.requestUpdate(),hi.show({title:"Skill Installed",message:`${t.name} is now available to use.`,type:"success"})})).catch((e=>{console.error("krs-chatbot: global skill install failed",e),i?.showError("Error")})).finally((()=>{this._globalSkillPending.delete(t.code)}))}_handleOfferedSkillsInstall(e,t){const i=JSON.parse(e.data.toolResultString);i.canInstall?i.skills.some((e=>this._globalSkillPending.has(e.code)))||(i.skills.some((e=>e.billable))?this._skillOfferConfirm=e:this._installOfferedSkills(e,t.currentTarget)):hi.show({title:"Permission Required",message:"You do not have permission to install skills. Please contact your site administrator.",type:"error"})}_handleSkillOfferCancel(){this._skillOfferConfirm=null}_handleSkillOfferConfirm(e){this._skillOfferConfirm&&this._installOfferedSkills(this._skillOfferConfirm,e.currentTarget)}_installOfferedSkills(e,t){const i=JSON.parse(e.data.toolResultString).skills;for(const e of i)this._globalSkillPending.add(e.code);t?.showLoading();let s=Promise.resolve();for(const e of i)s=s.then((()=>ms.fetch({url:`/api/system/opensearch/aiskills/global/${encodeURIComponent(e.code)}/enabled`,method:"POST",body:{enabled:!0}})));s.then((()=>{t?.reset(),this._skillOfferConfirm=null,e.data.skillOfferOutcome="installed",this.requestUpdate(),null!=this.conversationId&&ms.fetch({url:`/api/system/conversation/${this.conversationId}/skillOffer/${encodeURIComponent(e.data.toolUseId)}`,method:"POST",body:{outcome:"installed"}}).catch((e=>{console.error("krs-chatbot: failed to record skill offer outcome",e)})),this._inputValue=`I installed ${i.map((e=>e.name)).join(" and ")}. Please continue.`,this._handleSubmit()})).catch((e=>{console.error("krs-chatbot: skill offer install failed",e),t?.showError("Error")})).finally((()=>{for(const e of i)this._globalSkillPending.delete(e.code)}))}_handleOfferedSkillsDecline(e){e.data.skillOfferOutcome="declined",this.requestUpdate(),null!=this.conversationId&&ms.fetch({url:`/api/system/conversation/${this.conversationId}/skillOffer/${encodeURIComponent(e.data.toolUseId)}`,method:"POST",body:{outcome:"declined"}}).catch((e=>{console.error("krs-chatbot: failed to record skill offer outcome",e)})),this._inputValue=`I don't want to install ${JSON.parse(e.data.toolResultString).skills.map((e=>e.name)).join(" and ")} right now.`,this._handleSubmit()}_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 hi.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()):hi.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._handleSkillCardOpen(t))}_handleSuggestedActionClick(e){this._inputValue=`/${e.code} `,this._saveState(),this._inputEl?.focus()}_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||ms.getBaseUrl().includes("localhost"))&&this._searchGlobalSkills("")}_handleSkillBrowseClose(){this._skillBrowseOpened=!1,this._skillBrowseDetail=null}_handleSkillCardOpen(e){this._skillBrowseDetail=e}_handleSkillDetailBack(){this._skillBrowseDetail=null}_handleSkillDetailTry(){this._skillBrowseDetail&&this._handleSkillSelect(this._skillBrowseDetail)}_handleSkillDetailEnable(e){this._skillBrowseDetail&&this._handleGlobalSkillEnable(this._skillBrowseDetail,e)}_handleSkillBrowseSearch(e){this._skillBrowseQuery=e.target.value,this._searchOrgSkills(this._skillBrowseQuery),(!0!==this._aiFrameworkConfig.registryServer||ms.getBaseUrl().includes("localhost"))&&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=>ks.includes(this._getFileExtension(e.name))));i.length&&i.forEach((e=>{let i;(e.type.startsWith("image/")||ys.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||`${ms.getBaseUrl()}/api/system/conversationFile/${e.conversationFileID}/view`;Hi.open({src:t,name:e.niceName||"file"}).addEventListener("download",(()=>{window.open(`${ms.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._suggestedActions=[],this._saveState(),this._error="",this._userHasScrolledUp=!1,this._followStream=!0,this._pendingConversationFiles=[],this._inputEl&&(this._inputEl.style.height="auto"),this.messages=[...this.messages,{type:"assistant",content:""}],this._isStreaming=!0,this._turnFinishedCleanly=!1,this._reconnectAttempts=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 ms.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"),ms.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,ms.fetch({url:"/api/system/integration/aws/bedrock/stream/invokeModelForConversationWithState",method:"POST",headers:{Accept:"text/event-stream"},body:i}).then((e=>(null==this.conversationId&&ms.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._persistConversationId(),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._turnFinishedCleanly=!1,this._reconnectAttempts=0,this._userHasScrolledUp=!1,this._followStream=!0,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;t.scrollHeight-t.scrollTop-t.clientHeight>50?this._userHasScrolledUp=!0:(this._userHasScrolledUp=!1,this._isStreaming&&(this._followStream=!0))}_handleMessagesWheel(e){this._isStreaming&&e.deltaY<0&&(this._followStream=!1)}_handleMessagesTouchMove(){this._isStreaming&&(this._followStream=!1)}_handleMessagesPointerDown(e){const t=e.currentTarget;this._isStreaming&&e.offsetX>=t.clientWidth&&(this._followStream=!1)}_handleErrorDismiss(){this._error=""}_handleContextWarningDismiss(){this._contextWarning=""}_toggleDrawer(e){this._drawerOpen&&this._drawerView===e?this._drawerOpen=!1:(this._drawerOpen=!0,this._drawerView=e,"history"===e&&this._loadConversations()),this._saveState()}_loadConversations(){this._conversationsLoading=!0,ms.fetch({url:"/api/system/conversation/list",method:"POST",body:{page:0,size:50,sortBy:"lastModified",sortDirection:"desc",filterFields:[{name:"active",operation:"IS",value:"true"}]}}).then((e=>e.json())).then((e=>{this._conversations=e?.data?.content||[]})).catch((()=>{this._conversations=[]})).then((()=>{this._conversationsLoading=!1}))}_handleSwitchConversation(e){e!==this.conversationId?(this._handleStop(),this.conversationId=e,this._conversationTitle=this._conversations.find((t=>t.conversationID===e))?.title||"",this._persistConversationId(),this._pendingActions=[],this._inlineConfirm=!0,this._contextWarning="",this._contextLimitReached=!1,this._contextLimitMessage="",this._error="",this._reconnectAttempts=0,this._pendingConversationFiles.forEach((e=>{e.previewUrl&&URL.revokeObjectURL(e.previewUrl)})),this._pendingConversationFiles=[],this._drawerOpen=!1,this._saveState(),this.load&&this.load().then((e=>{this.messages=e||[],this.conversationId&&!this._isStreaming&&this._reconnectStream()})).catch((()=>{}))):this._handleCloseDrawer()}_handleNewConversation(){this._handleStop(),this.conversationId=null,this._conversationTitle="",this._persistConversationId(),this.messages=[],this._pendingActions=[],this._inlineConfirm=!0,this._contextWarning="",this._contextLimitReached=!1,this._contextLimitMessage="",this._error="",this._reconnectAttempts=0,this._pendingConversationFiles.forEach((e=>{e.previewUrl&&URL.revokeObjectURL(e.previewUrl)})),this._pendingConversationFiles=[],this._drawerOpen=!1,this._saveState()}_handleCloseDrawer(){this._drawerOpen=!1,this._saveState()}_openToolDetail(e){const t=this.messages[this.messages.indexOf(e)+1];this._toolDetail={use:e,result:null},"tool_result"===t?.type&&t.data?.toolUseId===e.data?.toolUseId&&(this._toolDetail.result=t),this._toolDetailCopied=null,this._toolDetailInputOpen=!0,this._toolDetailOutputOpen=!0,this._drawerView="toolDetail",this._drawerOpen=!0,this._saveState(),this.updateComplete.then((()=>{this._drawerBodyEl&&(this._drawerBodyEl.scrollTop=0)}))}_handleToggleToolDetailInput(){this._toolDetailInputOpen=!this._toolDetailInputOpen}_handleToggleToolDetailOutput(){this._toolDetailOutputOpen=!this._toolDetailOutputOpen}_formatToolJson(e){if(null==e)return"";const t=String(e),i=t.match(/(<<<[0-9a-f-]+_BEGIN>>>\n?)([\s\S]*?)(\n?<<<[0-9a-f-]+_END>>>)/);if(i&&null!=i.index){const e=i.index+i[1].length,s=e+i[2].length;return t.slice(0,e)+this._reindentJson(i[2])+t.slice(s)}return this._reindentJson(t)}_reindentJson(e){const t=e.trim();if(!t.startsWith("{")&&!t.startsWith("["))return e;try{return JSON.stringify(JSON.parse(t),null,2)}catch{}let i="",s=0,o=!1,r=!1;const a=e=>"\n"+" ".repeat(Math.max(0,e));for(let e=0;e<t.length;e++){const n=t[e];o?(i+=n,r?r=!1:"\\"===n?r=!0:'"'===n&&(o=!1)):'"'===n?(o=!0,i+=n):"{"===n||"["===n?(s++,i+=n+a(s)):"}"===n||"]"===n?(s--,i+=a(s)+n):","===n?i+=n+a(s):":"===n?i+=": ":" "===n||"\n"===n||"\t"===n||"\r"===n||(i+=n)}return i}_handleCopyToolDetailInput(e){e.stopPropagation(),this._copyToolDetail("input",this._formatToolJson(this._toolDetail?.use.data?.toolInput))}_handleCopyToolDetailOutput(e){e.stopPropagation(),this._copyToolDetail("output",this._formatToolJson(this._toolDetail?.result?.data?.toolResultString))}_copyToolDetail(e,t){navigator.clipboard.writeText(t).then((()=>{this._toolDetailCopied=e,setTimeout((()=>{this._toolDetailCopied===e&&(this._toolDetailCopied=null)}),2e3)})).catch((()=>{}))}_handleDrawerResizeMouseDown(e){this._isDrawerResizing=!0,this._drawerResizeStartX=e.clientX,this._drawerResizeStartW=this._drawerWidth,e.preventDefault(),e.stopPropagation(),document.addEventListener("mousemove",this._handleDrawerResizeMouseMove),document.addEventListener("mouseup",this._handleDrawerResizeMouseUp)}_readStreamChunk(){this._reader&&this._reader.read().then((e=>{if(e.done){if(this._turnFinishedCleanly)return;return void this._reconnectStream()}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)s.data?.title&&(this._conversationTitle=s.data.title,this.dispatchEvent(new CustomEvent("conversation-title",{detail:{title:s.data.title},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._turnFinishedCleanly=!0,this._finishStream())}}this._reader&&this._readStreamChunk()})).catch((e=>{"AbortError"!==e.name&&(this._turnFinishedCleanly?this._handleStreamError(e.message):this._reconnectStream())}))}_reconnectStream(){this.conversationId?this._reconnectAttempts>=5?this._handleStreamError("Lost connection to the assistant. Please reload the conversation."):(this._reconnectAttempts=this._reconnectAttempts+1,ms.fetch({url:`/api/system/integration/aws/bedrock/stream/attach/${this.conversationId}`,method:"GET",headers:{Accept:"text/event-stream"}}).then((e=>{if(204===e.status)return this._reconnectAttempts=0,this.load&&this.load().then((e=>{this.messages=e,this.requestUpdate()})).catch((()=>{})),void this._finishStream();e.ok&&e.body?(this._reconnectAttempts=0,this._isStreaming=!0,this._followStream=!0,this._reader=e.body.getReader(),this._decoder=new TextDecoder,this._buffer="",this.load?this.load().then((e=>{this.messages=e,this.requestUpdate(),this._readStreamChunk()})).catch((()=>{this._readStreamChunk()})):this._readStreamChunk()):setTimeout((()=>this._reconnectStream()),1e3)})).catch((()=>{setTimeout((()=>this._reconnectStream()),1e3)}))):this._finishStream()}_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[role="alertdialog"]')?.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=_s.find((e=>e.mode===this._mode))||_s[0];return N`
7507
+ `,gs([ce({attribute:!1})],fs.prototype,"save",void 0),gs([ce({attribute:"save-mode"})],fs.prototype,"saveMode",void 0),customElements.get("krs-form")||customElements.define("krs-form",fs);class vs{static configure(e){void 0!==e.baseUrl&&(vs._baseUrl=e.baseUrl),void 0!==e.devUrl&&(vs._devUrl=e.devUrl)}static getBaseUrl(){return"localhost"===window.location.hostname&&window.location.port.startsWith("4")&&vs._devUrl?vs._devUrl:vs._baseUrl}static fetch(e){let t=e.url;var i="localhost"===window.location.hostname&&window.location.port.startsWith("4");let s=vs.getBaseUrl();0!==t.indexOf("http")&&(t=s+t),e.params&&(t+="?",Object.keys(e.params).forEach(((i,s)=>{s>0&&(t+="&"),t+=`${i}=${e.params[i]}`})));var o={};let r;return e.headers&&(e.headers instanceof Headers?e.headers.forEach(((e,t)=>{o[t]=e})):Array.isArray(e.headers)?e.headers.forEach((([e,t])=>{o[e]=t})):Object.assign(o,e.headers)),!e.body||"object"!=typeof e.body||e.body instanceof ReadableStream||e.body instanceof Blob||e.body instanceof ArrayBuffer||e.body instanceof FormData||e.body instanceof URLSearchParams||(e.body=JSON.stringify(e.body),o["Content-Type"]||(o["Content-Type"]="application/json")),e.headers=o,i&&!e.credentials&&(e.credentials="include"),r=t.indexOf("/api/user/")>-1||t.indexOf("/api/account/")>-1?fetch(`${s}/api/user/customer/authToken`,{credentials:"include"}):Promise.resolve(null),r.then((e=>e?.json())).then((i=>(i?.data&&(o["X-CSRF-TOKEN"]=i.data),fetch(t,e)))).then((e=>e.ok?e:Promise.reject(e)))}}vs._baseUrl="",vs._devUrl="";var ms=function(e,t,i,s){var o,r=arguments.length,a=r<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,i,s);else for(var n=e.length-1;n>=0;n--)(o=e[n])&&(a=(r<3?o(a):r>3?o(t,i,a):o(t,i))||a);return r>3&&a&&Object.defineProperty(t,i,a),a};const bs=[{decision:"approve",label:"Yes"},{decision:"approveAlways",label:"Always allow"},{decision:"reject",label:"No"}],_s=[{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"}],ys=["jpg","jpeg","png","gif","webp"],ks=["pdf","doc","docx","xls","xlsx","csv","html","md","txt","json","xml","vtt","srt",...ys,"mp4","webm","ogg","mov"];class xs extends ne{constructor(){super(...arguments),this._inlineConfirm=!0,this._reasoningAsMessage=!0,this._reader=null,this._decoder=new TextDecoder,this._buffer="",this._turnFinishedCleanly=!1,this._reconnectAttempts=0,this._userHasScrolledUp=!1,this._followStream=!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._drawerResizeStartX=0,this._drawerResizeStartW=0,this._dragDepth=0,this._pendingSeq=0,this._pendingAttachAnalyze=!0,this._orgSkillRequestId=0,this._globalSkillRequestId=0,this._invocableSkillRequestId=0,this._suggestedActionRequestId=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._conversationTitle="",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._conversations=[],this._conversationsLoading=!1,this._toolDetail=null,this._toolDetailCopied=null,this._toolDetailInputOpen=!0,this._toolDetailOutputOpen=!0,this._drawerWidth=430,this._isDrawerResizing=!1,this._pendingConversationFiles=[],this._isDraggingFile=!1,this._skillMenuOpened=!1,this._skillQuery="",this._orgSkills=[],this._globalSkills=[],this._invocableSkills=[],this._suggestedActions=[],this._aiFrameworkConfig={},this._skillHighlighted=0,this._copiedIndex=-1,this._skillBrowseOpened=!1,this._skillBrowseDetail=null,this._skillInstallConfirm=null,this._skillOfferConfirm=null,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,o=380,r=.9*window.innerWidth,a=window.innerHeight-72;let n=this._resizeStartW,l=this._resizeStartH,d=this._dragStartLeft,h=this._dragStartTop;this._resizeDir.includes("e")&&(n=Math.max(s,Math.min(this._resizeStartW+t,r))),this._resizeDir.includes("w")&&(n=Math.max(s,Math.min(this._resizeStartW-t,r)),d=this._dragStartLeft+(this._resizeStartW-n)),this._resizeDir.includes("s")&&(l=Math.max(o,Math.min(this._resizeStartH+i,a))),this._resizeDir.includes("n")&&(l=Math.max(o,Math.min(this._resizeStartH-i,a)),h=this._dragStartTop+(this._resizeStartH-l)),d=Math.max(0,d),h=Math.max(0,h),this._panelEl.style.width=n+"px",this._panelEl.style.height=l+"px",this._panelEl.style.left=d+"px",this._panelEl.style.top=h+"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)%bs.length);if("ArrowLeft"===e.key)return e.preventDefault(),void(this._confirmationHighlighted=(this._confirmationHighlighted-1+bs.length)%bs.length);if("Enter"===e.key){e.preventDefault();const t=bs[this._confirmationHighlighted];t&&this._handleConfirmationDecision(t.decision)}}},this._handleDrawerResizeMouseMove=e=>{if(!this._isDrawerResizing)return;const t=e.clientX-this._drawerResizeStartX,i=Math.max(300,this.offsetWidth-300);this._drawerWidth=Math.max(300,Math.min(this._drawerResizeStartW-t,i))},this._handleDrawerResizeMouseUp=()=>{this._isDrawerResizing=!1,document.removeEventListener("mousemove",this._handleDrawerResizeMouseMove),document.removeEventListener("mouseup",this._handleDrawerResizeMouseUp),this._saveState()}}connectedCallback(){super.connectedCallback(),this.load||(this.load=()=>null==this.conversationId?Promise.resolve([]):vs.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("reasoning"===e.type)return Promise.resolve({type:"assistant",content:"",reasoning:e.content||""});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=>vs.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)}))))));let e=Promise.resolve();if("floating"===this.variant&&null==this.conversationId){const t=Number(sessionStorage.getItem("kr-chatbot-conversation-id"));t>0&&(this.conversationId=t,e=vs.fetch({url:`/api/system/conversation/${t}`}).then((e=>e.json())).then((e=>{this._conversationTitle=e?.data?.title||""})).catch((()=>{})))}e.then((()=>this.load())).then((e=>{e&&e.length&&(this.messages=e),this.conversationId&&!this._isStreaming&&this._reconnectStream()})).catch((()=>{})),vs.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)}))),this._isStreaming&&this._followStream&&this._messagesEl&&requestAnimationFrame((()=>{const e=this._messagesEl;if(!e||!this._isStreaming||!this._followStream)return;const t=e.querySelectorAll(".agent-turn"),i=t[t.length-1],s=i?.lastElementChild;if(!s)return;const o=s.getBoundingClientRect().bottom-e.getBoundingClientRect().top+e.scrollTop+24;o>e.scrollTop+e.clientHeight&&(e.scrollTop=Math.min(o-e.clientHeight,e.scrollHeight-e.clientHeight))})),e.has("opened")&&this.opened&&this._inputEl&&setTimeout((()=>{this._inputEl&&this._inputEl.focus()}),200),e.has("opened")&&this.opened&&0===this.messages.length&&this._loadSuggestedActions(),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(),o=Math.max(t,e.top-s.height-8);this._skillMenuEl.style.top=o+"px"}))}stop(){this._handleStop()}isStreaming(){return this._isStreaming}open(){this.opened||this._handleToggle()}close(){this.opened&&this._handleToggle()}toggle(){this._handleToggle()}prompt(e){this.open(),this._inputValue=e.message,this._handleSubmit()}draft(e){this.open(),this._inputValue=e.message,this._saveState(),this.updateComplete.then((()=>{setTimeout((()=>{this._inputEl&&(this._inputEl.focus(),this._inputEl.select())}),200)}))}_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()}_persistConversationId(){if("floating"===this.variant)try{null!=this.conversationId?sessionStorage.setItem("kr-chatbot-conversation-id",String(this.conversationId)):sessionStorage.removeItem("kr-chatbot-conversation-id")}catch{}}_saveState(){let e="kr-chatbot-state",t="kr-chatbot-tab";"inline"===this.variant&&(e="kr-chatbot-state-inline",t="kr-chatbot-tab-inline");try{const t={message:this._inputValue,mode:this._mode,showTools:String(this._showTools),showToolInputs:String(this._showToolInputs),showConfirmationInput:String(this._showConfirmationInput)};localStorage.setItem(e,JSON.stringify(t))}catch{}try{let e=this._drawerView;"toolDetail"===e&&(e="settings");const i={drawerOpen:String(this._drawerOpen),drawerView:e,drawerWidth:String(this._drawerWidth)};if("floating"===this.variant&&(i.opened=String(this.opened),this._panelEl)){const e=this._panelEl.style;e.left&&(i.left=e.left),e.top&&(i.top=e.top),e.width&&(i.width=e.width),e.height&&(i.height=e.height),e.position&&(i.position=e.position)}sessionStorage.setItem(t,JSON.stringify(i))}catch{}}_restoreState(){let e="kr-chatbot-state",t="kr-chatbot-tab";"inline"===this.variant&&(e="kr-chatbot-state-inline",t="kr-chatbot-tab-inline");try{const t=localStorage.getItem(e);if(t){const e=JSON.parse(t);"string"==typeof e.message&&"/"!==e.message.trim()&&(this._inputValue=e.message),"NORMAL"!==e.mode&&"EDIT"!==e.mode&&"PLAN"!==e.mode||(this._mode=e.mode),this._showTools="true"===e.showTools,this._showToolInputs="true"===e.showToolInputs,this._showConfirmationInput="true"===e.showConfirmationInput}}catch{}try{const e=sessionStorage.getItem(t);if(!e)return;const i=JSON.parse(e);this._drawerOpen="true"===i.drawerOpen,"settings"!==i.drawerView&&"debug"!==i.drawerView&&"history"!==i.drawerView||(this._drawerView=i.drawerView,"history"===i.drawerView&&this._loadConversations());const s=Number(i.drawerWidth);s>=300&&(this._drawerWidth=s),"floating"===this.variant&&"true"===i.opened&&(this.opened=!0,this.updateComplete.then((()=>this._applyStoredLayout())))}catch{}}_applyStoredLayout(){try{const e=sessionStorage.getItem("kr-chatbot-tab");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;vs.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("krs-chatbot: skill search failed",e)}))}_searchInvocableSkills(e){this._invocableSkillRequestId++;const t=this._invocableSkillRequestId;vs.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("krs-chatbot: invocable skill search failed",e)}))}_loadSuggestedActions(){this._suggestedActionRequestId++;const e=this._suggestedActionRequestId,t=this._captureContext();vs.fetch({url:"/api/system/conversation/suggestedActions",method:"POST",body:{pageContext:t.pageContext,selectionContext:t.selectionContext}}).then((e=>e.json())).then((t=>{e!==this._suggestedActionRequestId||this.messages.length>0||(this._suggestedActions=t?.data||[])})).catch((e=>{console.error("krs-chatbot: suggested actions load failed",e)}))}_searchGlobalSkills(e){this._globalSkillRequestId++;const t=this._globalSkillRequestId;vs.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("krs-chatbot: global skill search failed",e)}))}_handleGlobalSkillEnable(e,t){if(t.stopPropagation(),!e.canEnable)return void hi.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;if(!e.enabled&&e.billable)return void(this._skillInstallConfirm=e);const i=t.currentTarget;this._globalSkillPending.add(e.code),i?.showLoading(),vs.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,i?.reset(),this.requestUpdate(),e.enabled?hi.show({title:"Skill Installed",message:`${e.name} is now available to use.`,type:"success"}):hi.show({title:"Skill Uninstalled",message:`${e.name} is no longer available to use.`,type:"success"})})).catch((e=>{console.error("krs-chatbot: global skill enable failed",e),i?.showError("Error")})).finally((()=>{this._globalSkillPending.delete(e.code)}))}_handleSkillInstallCancel(){this._skillInstallConfirm=null}_handleSkillInstallConfirm(e){if(!this._skillInstallConfirm)return;if(this._globalSkillPending.has(this._skillInstallConfirm.code))return;const t=this._skillInstallConfirm,i=e.currentTarget;this._globalSkillPending.add(t.code),i?.showLoading(),vs.fetch({url:`/api/system/opensearch/aiskills/global/${encodeURIComponent(t.code)}/enabled`,method:"POST",body:{enabled:!0}}).then((e=>e.json())).then((e=>{t.enabled=e?.data?.enabled,i?.reset(),this._skillInstallConfirm=null,this.requestUpdate(),hi.show({title:"Skill Installed",message:`${t.name} is now available to use.`,type:"success"})})).catch((e=>{console.error("krs-chatbot: global skill install failed",e),i?.showError("Error")})).finally((()=>{this._globalSkillPending.delete(t.code)}))}_handleOfferedSkillsInstall(e,t){const i=JSON.parse(e.data.toolResultString);i.canInstall?i.skills.some((e=>this._globalSkillPending.has(e.code)))||(i.skills.some((e=>e.billable))?this._skillOfferConfirm=e:this._installOfferedSkills(e,t.currentTarget)):hi.show({title:"Permission Required",message:"You do not have permission to install skills. Please contact your site administrator.",type:"error"})}_handleSkillOfferCancel(){this._skillOfferConfirm=null}_handleSkillOfferConfirm(e){this._skillOfferConfirm&&this._installOfferedSkills(this._skillOfferConfirm,e.currentTarget)}_installOfferedSkills(e,t){const i=JSON.parse(e.data.toolResultString).skills;for(const e of i)this._globalSkillPending.add(e.code);t?.showLoading();let s=Promise.resolve();for(const e of i)s=s.then((()=>vs.fetch({url:`/api/system/opensearch/aiskills/global/${encodeURIComponent(e.code)}/enabled`,method:"POST",body:{enabled:!0}})));s.then((()=>{t?.reset(),this._skillOfferConfirm=null,e.data.skillOfferOutcome="installed",this.requestUpdate(),null!=this.conversationId&&vs.fetch({url:`/api/system/conversation/${this.conversationId}/skillOffer/${encodeURIComponent(e.data.toolUseId)}`,method:"POST",body:{outcome:"installed"}}).catch((e=>{console.error("krs-chatbot: failed to record skill offer outcome",e)})),this._inputValue=`I installed ${i.map((e=>e.name)).join(" and ")}. Please continue.`,this._handleSubmit()})).catch((e=>{console.error("krs-chatbot: skill offer install failed",e),t?.showError("Error")})).finally((()=>{for(const e of i)this._globalSkillPending.delete(e.code)}))}_handleOfferedSkillsDecline(e){e.data.skillOfferOutcome="declined",this.requestUpdate(),null!=this.conversationId&&vs.fetch({url:`/api/system/conversation/${this.conversationId}/skillOffer/${encodeURIComponent(e.data.toolUseId)}`,method:"POST",body:{outcome:"declined"}}).catch((e=>{console.error("krs-chatbot: failed to record skill offer outcome",e)})),this._inputValue=`I don't want to install ${JSON.parse(e.data.toolResultString).skills.map((e=>e.name)).join(" and ")} right now.`,this._handleSubmit()}_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 hi.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()):hi.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._handleSkillCardOpen(t))}_handleSuggestedActionClick(e){this._inputValue=`/${e.code} `,this._saveState(),this._inputEl?.focus()}_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||vs.getBaseUrl().includes("localhost"))&&this._searchGlobalSkills("")}_handleSkillBrowseClose(){this._skillBrowseOpened=!1,this._skillBrowseDetail=null}_handleSkillCardOpen(e){this._skillBrowseDetail=e}_handleSkillDetailBack(){this._skillBrowseDetail=null}_handleSkillDetailTry(){this._skillBrowseDetail&&this._handleSkillSelect(this._skillBrowseDetail)}_handleSkillDetailEnable(e){this._skillBrowseDetail&&this._handleGlobalSkillEnable(this._skillBrowseDetail,e)}_handleSkillBrowseSearch(e){this._skillBrowseQuery=e.target.value,this._searchOrgSkills(this._skillBrowseQuery),(!0!==this._aiFrameworkConfig.registryServer||vs.getBaseUrl().includes("localhost"))&&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=>ks.includes(this._getFileExtension(e.name))));i.length&&i.forEach((e=>{let i;(e.type.startsWith("image/")||ys.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||`${vs.getBaseUrl()}/api/system/conversationFile/${e.conversationFileID}/view`;Hi.open({src:t,name:e.niceName||"file"}).addEventListener("download",(()=>{window.open(`${vs.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._suggestedActions=[],this._saveState(),this._error="",this._userHasScrolledUp=!1,this._followStream=!0,this._pendingConversationFiles=[],this._inputEl&&(this._inputEl.style.height="auto"),this.messages=[...this.messages,{type:"assistant",content:""}],this._isStreaming=!0,this._turnFinishedCleanly=!1,this._reconnectAttempts=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 vs.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"),vs.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,vs.fetch({url:"/api/system/integration/aws/bedrock/stream/invokeModelForConversationWithState",method:"POST",headers:{Accept:"text/event-stream"},body:i}).then((e=>(null==this.conversationId&&vs.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._persistConversationId(),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._turnFinishedCleanly=!1,this._reconnectAttempts=0,this._userHasScrolledUp=!1,this._followStream=!0,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;t.scrollHeight-t.scrollTop-t.clientHeight>50?this._userHasScrolledUp=!0:(this._userHasScrolledUp=!1,this._isStreaming&&(this._followStream=!0))}_handleMessagesWheel(e){this._isStreaming&&e.deltaY<0&&(this._followStream=!1)}_handleMessagesTouchMove(){this._isStreaming&&(this._followStream=!1)}_handleMessagesPointerDown(e){const t=e.currentTarget;this._isStreaming&&e.offsetX>=t.clientWidth&&(this._followStream=!1)}_handleErrorDismiss(){this._error=""}_handleContextWarningDismiss(){this._contextWarning=""}_toggleDrawer(e){this._drawerOpen&&this._drawerView===e?this._drawerOpen=!1:(this._drawerOpen=!0,this._drawerView=e,"history"===e&&this._loadConversations()),this._saveState()}_loadConversations(){this._conversationsLoading=!0,vs.fetch({url:"/api/system/conversation/list",method:"POST",body:{page:0,size:50,sortBy:"lastModified",sortDirection:"desc",filterFields:[{name:"active",operation:"IS",value:"true"}]}}).then((e=>e.json())).then((e=>{this._conversations=e?.data?.content||[]})).catch((()=>{this._conversations=[]})).then((()=>{this._conversationsLoading=!1}))}_handleSwitchConversation(e){e!==this.conversationId?(this._handleStop(),this.conversationId=e,this._conversationTitle=this._conversations.find((t=>t.conversationID===e))?.title||"",this._persistConversationId(),this._pendingActions=[],this._inlineConfirm=!0,this._contextWarning="",this._contextLimitReached=!1,this._contextLimitMessage="",this._error="",this._reconnectAttempts=0,this._pendingConversationFiles.forEach((e=>{e.previewUrl&&URL.revokeObjectURL(e.previewUrl)})),this._pendingConversationFiles=[],this._drawerOpen=!1,this._saveState(),this.load&&this.load().then((e=>{this.messages=e||[],this.conversationId&&!this._isStreaming&&this._reconnectStream()})).catch((()=>{}))):this._handleCloseDrawer()}_handleNewConversation(){this._handleStop(),this.conversationId=null,this._conversationTitle="",this._persistConversationId(),this.messages=[],this._pendingActions=[],this._inlineConfirm=!0,this._contextWarning="",this._contextLimitReached=!1,this._contextLimitMessage="",this._error="",this._reconnectAttempts=0,this._pendingConversationFiles.forEach((e=>{e.previewUrl&&URL.revokeObjectURL(e.previewUrl)})),this._pendingConversationFiles=[],this._drawerOpen=!1,this._saveState()}_handleCloseDrawer(){this._drawerOpen=!1,this._saveState()}_openToolDetail(e){const t=this.messages[this.messages.indexOf(e)+1];this._toolDetail={use:e,result:null},"tool_result"===t?.type&&t.data?.toolUseId===e.data?.toolUseId&&(this._toolDetail.result=t),this._toolDetailCopied=null,this._toolDetailInputOpen=!0,this._toolDetailOutputOpen=!0,this._drawerView="toolDetail",this._drawerOpen=!0,this._saveState(),this.updateComplete.then((()=>{this._drawerBodyEl&&(this._drawerBodyEl.scrollTop=0)}))}_handleToggleToolDetailInput(){this._toolDetailInputOpen=!this._toolDetailInputOpen}_handleToggleToolDetailOutput(){this._toolDetailOutputOpen=!this._toolDetailOutputOpen}_formatToolJson(e){if(null==e)return"";const t=String(e),i=t.match(/(<<<[0-9a-f-]+_BEGIN>>>\n?)([\s\S]*?)(\n?<<<[0-9a-f-]+_END>>>)/);if(i&&null!=i.index){const e=i.index+i[1].length,s=e+i[2].length;return t.slice(0,e)+this._reindentJson(i[2])+t.slice(s)}return this._reindentJson(t)}_reindentJson(e){const t=e.trim();if(!t.startsWith("{")&&!t.startsWith("["))return e;try{return JSON.stringify(JSON.parse(t),null,2)}catch{}let i="",s=0,o=!1,r=!1;const a=e=>"\n"+" ".repeat(Math.max(0,e));for(let e=0;e<t.length;e++){const n=t[e];o?(i+=n,r?r=!1:"\\"===n?r=!0:'"'===n&&(o=!1)):'"'===n?(o=!0,i+=n):"{"===n||"["===n?(s++,i+=n+a(s)):"}"===n||"]"===n?(s--,i+=a(s)+n):","===n?i+=n+a(s):":"===n?i+=": ":" "===n||"\n"===n||"\t"===n||"\r"===n||(i+=n)}return i}_handleCopyToolDetailInput(e){e.stopPropagation(),this._copyToolDetail("input",this._formatToolJson(this._toolDetail?.use.data?.toolInput))}_handleCopyToolDetailOutput(e){e.stopPropagation(),this._copyToolDetail("output",this._formatToolJson(this._toolDetail?.result?.data?.toolResultString))}_copyToolDetail(e,t){navigator.clipboard.writeText(t).then((()=>{this._toolDetailCopied=e,setTimeout((()=>{this._toolDetailCopied===e&&(this._toolDetailCopied=null)}),2e3)})).catch((()=>{}))}_handleDrawerResizeMouseDown(e){this._isDrawerResizing=!0,this._drawerResizeStartX=e.clientX,this._drawerResizeStartW=this._drawerWidth,e.preventDefault(),e.stopPropagation(),document.addEventListener("mousemove",this._handleDrawerResizeMouseMove),document.addEventListener("mouseup",this._handleDrawerResizeMouseUp)}_readStreamChunk(){this._reader&&this._reader.read().then((e=>{if(e.done){if(this._turnFinishedCleanly)return;return void this._reconnectStream()}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)s.data?.title&&(this._conversationTitle=s.data.title,this.dispatchEvent(new CustomEvent("conversation-title",{detail:{title:s.data.title},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._turnFinishedCleanly=!0,this._finishStream())}}this._reader&&this._readStreamChunk()})).catch((e=>{"AbortError"!==e.name&&(this._turnFinishedCleanly?this._handleStreamError(e.message):this._reconnectStream())}))}_reconnectStream(){this.conversationId?this._reconnectAttempts>=5?this._handleStreamError("Lost connection to the assistant. Please reload the conversation."):(this._reconnectAttempts=this._reconnectAttempts+1,vs.fetch({url:`/api/system/integration/aws/bedrock/stream/attach/${this.conversationId}`,method:"GET",headers:{Accept:"text/event-stream"}}).then((e=>{if(204===e.status)return this._reconnectAttempts=0,this.load&&this.load().then((e=>{this.messages=e,this.requestUpdate()})).catch((()=>{})),void this._finishStream();e.ok&&e.body?(this._reconnectAttempts=0,this._isStreaming=!0,this._followStream=!0,this._reader=e.body.getReader(),this._decoder=new TextDecoder,this._buffer="",this.load?this.load().then((e=>{this.messages=e,this.requestUpdate(),this._readStreamChunk()})).catch((()=>{this._readStreamChunk()})):this._readStreamChunk()):setTimeout((()=>this._reconnectStream()),1e3)})).catch((()=>{setTimeout((()=>this._reconnectStream()),1e3)}))):this._finishStream()}_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[role="alertdialog"]')?.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=_s.find((e=>e.mode===this._mode))||_s[0];return N`
7472
7508
  <div class="mode">
7473
7509
  ${this._modeMenuOpened?N`
7474
7510
  <div class="mode-menu">
@@ -7705,7 +7741,7 @@ class $e extends _e{constructor(e){if(super(e),this.it=U,e.type!==fe)throw Error
7705
7741
  <krs-tab id="org" label="Your Org">
7706
7742
  ${this._renderSkillGrid()}
7707
7743
  </krs-tab>
7708
- ${!0!==this._aiFrameworkConfig.registryServer||ms.getBaseUrl().includes("localhost")?N`
7744
+ ${!0!==this._aiFrameworkConfig.registryServer||vs.getBaseUrl().includes("localhost")?N`
7709
7745
  <krs-tab id="kodaris" label="Kodaris">
7710
7746
  ${this._renderSkillGrid(!0)}
7711
7747
  </krs-tab>
@@ -8452,7 +8488,7 @@ class $e extends _e{constructor(e){if(super(e),this.it=U,e.type!==fe)throw Error
8452
8488
  @click=${()=>this._handleFileOpen(e)}
8453
8489
  >
8454
8490
  <img
8455
- src=${e.previewUrl||`${ms.getBaseUrl()}/api/system/conversationFile/${e.conversationFileID}/view`}
8491
+ src=${e.previewUrl||`${vs.getBaseUrl()}/api/system/conversationFile/${e.conversationFileID}/view`}
8456
8492
  alt=${e.niceName||""}
8457
8493
  />
8458
8494
  </button>
@@ -11023,5 +11059,5 @@ class $e extends _e{constructor(e){if(super(e),this.it=U,e.type!==fe)throw Error
11023
11059
  height: 32px;
11024
11060
  }
11025
11061
 
11026
- `,vs([ce({attribute:!1})],xs.prototype,"send",void 0),vs([ce({attribute:!1})],xs.prototype,"load",void 0),vs([ce({attribute:!1})],xs.prototype,"messages",void 0),vs([ce({type:String})],xs.prototype,"label",void 0),vs([ce({type:String})],xs.prototype,"placeholder",void 0),vs([ce({type:Boolean,reflect:!0})],xs.prototype,"opened",void 0),vs([ce({type:Boolean,attribute:"hide-toggle",reflect:!0})],xs.prototype,"hideToggle",void 0),vs([ce({type:String,reflect:!0})],xs.prototype,"variant",void 0),vs([ce({type:Number,attribute:"conversation-id",reflect:!0})],xs.prototype,"conversationId",void 0),vs([pe()],xs.prototype,"_inputValue",void 0),vs([pe()],xs.prototype,"_isStreaming",void 0),vs([pe()],xs.prototype,"_error",void 0),vs([pe()],xs.prototype,"_conversationTitle",void 0),vs([pe()],xs.prototype,"_contextWarning",void 0),vs([pe()],xs.prototype,"_contextLimitReached",void 0),vs([pe()],xs.prototype,"_contextLimitMessage",void 0),vs([pe()],xs.prototype,"_pendingActions",void 0),vs([pe()],xs.prototype,"_confirmationHighlighted",void 0),vs([pe()],xs.prototype,"_confirmationInFlight",void 0),vs([pe()],xs.prototype,"_telemetry",void 0),vs([pe()],xs.prototype,"_iterationLog",void 0),vs([pe()],xs.prototype,"_cacheCheckpoints",void 0),vs([pe()],xs.prototype,"_drawerOpen",void 0),vs([pe()],xs.prototype,"_drawerView",void 0),vs([pe()],xs.prototype,"_conversations",void 0),vs([pe()],xs.prototype,"_conversationsLoading",void 0),vs([pe()],xs.prototype,"_toolDetail",void 0),vs([pe()],xs.prototype,"_toolDetailCopied",void 0),vs([pe()],xs.prototype,"_toolDetailInputOpen",void 0),vs([pe()],xs.prototype,"_toolDetailOutputOpen",void 0),vs([pe()],xs.prototype,"_drawerWidth",void 0),vs([pe()],xs.prototype,"_isDrawerResizing",void 0),vs([pe()],xs.prototype,"_pendingConversationFiles",void 0),vs([pe()],xs.prototype,"_isDraggingFile",void 0),vs([pe()],xs.prototype,"_skillMenuOpened",void 0),vs([pe()],xs.prototype,"_skillQuery",void 0),vs([pe()],xs.prototype,"_orgSkills",void 0),vs([pe()],xs.prototype,"_globalSkills",void 0),vs([pe()],xs.prototype,"_invocableSkills",void 0),vs([pe()],xs.prototype,"_suggestedActions",void 0),vs([pe()],xs.prototype,"_aiFrameworkConfig",void 0),vs([pe()],xs.prototype,"_skillHighlighted",void 0),vs([pe()],xs.prototype,"_copiedIndex",void 0),vs([pe()],xs.prototype,"_skillBrowseOpened",void 0),vs([pe()],xs.prototype,"_skillBrowseDetail",void 0),vs([pe()],xs.prototype,"_skillInstallConfirm",void 0),vs([pe()],xs.prototype,"_skillOfferConfirm",void 0),vs([pe()],xs.prototype,"_skillBrowseSource",void 0),vs([pe()],xs.prototype,"_skillBrowseQuery",void 0),vs([pe()],xs.prototype,"_isDictating",void 0),vs([pe()],xs.prototype,"_mode",void 0),vs([pe()],xs.prototype,"_modeMenuOpened",void 0),vs([pe()],xs.prototype,"_showTools",void 0),vs([pe()],xs.prototype,"_showToolInputs",void 0),vs([pe()],xs.prototype,"_showConfirmationInput",void 0),vs([ue(".panel")],xs.prototype,"_panelEl",void 0),vs([ue(".messages")],xs.prototype,"_messagesEl",void 0),vs([ue(".input")],xs.prototype,"_inputEl",void 0),vs([ue(".file-input")],xs.prototype,"_fileInputEl",void 0),vs([ue(".input-wrapper")],xs.prototype,"_inputWrapperEl",void 0),vs([ue(".skill-menu")],xs.prototype,"_skillMenuEl",void 0),vs([ue(".drawer__body")],xs.prototype,"_drawerBodyEl",void 0),customElements.get("krs-chatbot")||customElements.define("krs-chatbot",xs),e.KRChatbot=xs}));
11062
+ `,ms([ce({attribute:!1})],xs.prototype,"send",void 0),ms([ce({attribute:!1})],xs.prototype,"load",void 0),ms([ce({attribute:!1})],xs.prototype,"messages",void 0),ms([ce({type:String})],xs.prototype,"label",void 0),ms([ce({type:String})],xs.prototype,"placeholder",void 0),ms([ce({type:Boolean,reflect:!0})],xs.prototype,"opened",void 0),ms([ce({type:Boolean,attribute:"hide-toggle",reflect:!0})],xs.prototype,"hideToggle",void 0),ms([ce({type:String,reflect:!0})],xs.prototype,"variant",void 0),ms([ce({type:Number,attribute:"conversation-id",reflect:!0})],xs.prototype,"conversationId",void 0),ms([pe()],xs.prototype,"_inputValue",void 0),ms([pe()],xs.prototype,"_isStreaming",void 0),ms([pe()],xs.prototype,"_error",void 0),ms([pe()],xs.prototype,"_conversationTitle",void 0),ms([pe()],xs.prototype,"_contextWarning",void 0),ms([pe()],xs.prototype,"_contextLimitReached",void 0),ms([pe()],xs.prototype,"_contextLimitMessage",void 0),ms([pe()],xs.prototype,"_pendingActions",void 0),ms([pe()],xs.prototype,"_confirmationHighlighted",void 0),ms([pe()],xs.prototype,"_confirmationInFlight",void 0),ms([pe()],xs.prototype,"_telemetry",void 0),ms([pe()],xs.prototype,"_iterationLog",void 0),ms([pe()],xs.prototype,"_cacheCheckpoints",void 0),ms([pe()],xs.prototype,"_drawerOpen",void 0),ms([pe()],xs.prototype,"_drawerView",void 0),ms([pe()],xs.prototype,"_conversations",void 0),ms([pe()],xs.prototype,"_conversationsLoading",void 0),ms([pe()],xs.prototype,"_toolDetail",void 0),ms([pe()],xs.prototype,"_toolDetailCopied",void 0),ms([pe()],xs.prototype,"_toolDetailInputOpen",void 0),ms([pe()],xs.prototype,"_toolDetailOutputOpen",void 0),ms([pe()],xs.prototype,"_drawerWidth",void 0),ms([pe()],xs.prototype,"_isDrawerResizing",void 0),ms([pe()],xs.prototype,"_pendingConversationFiles",void 0),ms([pe()],xs.prototype,"_isDraggingFile",void 0),ms([pe()],xs.prototype,"_skillMenuOpened",void 0),ms([pe()],xs.prototype,"_skillQuery",void 0),ms([pe()],xs.prototype,"_orgSkills",void 0),ms([pe()],xs.prototype,"_globalSkills",void 0),ms([pe()],xs.prototype,"_invocableSkills",void 0),ms([pe()],xs.prototype,"_suggestedActions",void 0),ms([pe()],xs.prototype,"_aiFrameworkConfig",void 0),ms([pe()],xs.prototype,"_skillHighlighted",void 0),ms([pe()],xs.prototype,"_copiedIndex",void 0),ms([pe()],xs.prototype,"_skillBrowseOpened",void 0),ms([pe()],xs.prototype,"_skillBrowseDetail",void 0),ms([pe()],xs.prototype,"_skillInstallConfirm",void 0),ms([pe()],xs.prototype,"_skillOfferConfirm",void 0),ms([pe()],xs.prototype,"_skillBrowseSource",void 0),ms([pe()],xs.prototype,"_skillBrowseQuery",void 0),ms([pe()],xs.prototype,"_isDictating",void 0),ms([pe()],xs.prototype,"_mode",void 0),ms([pe()],xs.prototype,"_modeMenuOpened",void 0),ms([pe()],xs.prototype,"_showTools",void 0),ms([pe()],xs.prototype,"_showToolInputs",void 0),ms([pe()],xs.prototype,"_showConfirmationInput",void 0),ms([ue(".panel")],xs.prototype,"_panelEl",void 0),ms([ue(".messages")],xs.prototype,"_messagesEl",void 0),ms([ue(".input")],xs.prototype,"_inputEl",void 0),ms([ue(".file-input")],xs.prototype,"_fileInputEl",void 0),ms([ue(".input-wrapper")],xs.prototype,"_inputWrapperEl",void 0),ms([ue(".skill-menu")],xs.prototype,"_skillMenuEl",void 0),ms([ue(".drawer__body")],xs.prototype,"_drawerBodyEl",void 0),customElements.get("krs-chatbot")||customElements.define("krs-chatbot",xs),e.KRChatbot=xs}));
11027
11063
  //# sourceMappingURL=krubble-shell-chatbot.umd.min.js.map