@kodaris/krubble-app-components 1.0.73 → 1.0.74

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.
@@ -14,12 +14,12 @@ import{KRContextMenu as e,KRDialog as t,KRFilePreview as i}from"@kodaris/krubble
14
14
  * Copyright 2017 Google LLC
15
15
  * SPDX-License-Identifier: BSD-3-Clause
16
16
  */
17
- const S=globalThis,E=S.trustedTypes,A=E?E.createPolicy("lit-html",{createHTML:e=>e}):void 0,z="$lit$",C=`lit$${Math.random().toFixed(9).slice(2)}$`,M="?"+C,D=`<${M}>`,T=document,R=()=>T.createComment(""),N=e=>null===e||"object"!=typeof e&&"function"!=typeof e,P=Array.isArray,O="[ \t\n\f\r]",U=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,L=/-->/g,H=/>/g,j=RegExp(`>|${O}(?:([^\\s"'>=/]+)(${O}*=${O}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),B=/'/g,F=/"/g,q=/^(?:script|style|textarea|title)$/i,X=(e=>(t,...i)=>({_$litType$:e,strings:t,values:i}))(1),Q=Symbol.for("lit-noChange"),W=Symbol.for("lit-nothing"),Y=new WeakMap,Z=T.createTreeWalker(T,129);function V(e,t){if(!P(e)||!e.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==A?A.createHTML(t):t}class K{constructor({strings:e,_$litType$:t},i){let s;this.parts=[];let n=0,r=0;const a=e.length-1,o=this.parts,[l,h]=((e,t)=>{const i=e.length-1,s=[];let n,r=2===t?"<svg>":3===t?"<math>":"",a=U;for(let t=0;t<i;t++){const i=e[t];let o,l,h=-1,c=0;for(;c<i.length&&(a.lastIndex=c,l=a.exec(i),null!==l);)c=a.lastIndex,a===U?"!--"===l[1]?a=L:void 0!==l[1]?a=H:void 0!==l[2]?(q.test(l[2])&&(n=RegExp("</"+l[2],"g")),a=j):void 0!==l[3]&&(a=j):a===j?">"===l[0]?(a=n??U,h=-1):void 0===l[1]?h=-2:(h=a.lastIndex-l[2].length,o=l[1],a=void 0===l[3]?j:'"'===l[3]?F:B):a===F||a===B?a=j:a===L||a===H?a=U:(a=j,n=void 0);const d=a===j&&e[t+1].startsWith("/>")?" ":"";r+=a===U?i+D:h>=0?(s.push(o),i.slice(0,h)+z+i.slice(h)+C+d):i+C+(-2===h?t:d)}return[V(e,r+(e[i]||"<?>")+(2===t?"</svg>":3===t?"</math>":"")),s]})(e,t);if(this.el=K.createElement(l,i),Z.currentNode=this.el.content,2===t||3===t){const e=this.el.content.firstChild;e.replaceWith(...e.childNodes)}for(;null!==(s=Z.nextNode())&&o.length<a;){if(1===s.nodeType){if(s.hasAttributes())for(const e of s.getAttributeNames())if(e.endsWith(z)){const t=h[r++],i=s.getAttribute(e).split(C),a=/([.?@])?(.*)/.exec(t);o.push({type:1,index:n,name:a[2],strings:i,ctor:"."===a[1]?ie:"?"===a[1]?se:"@"===a[1]?ne:te}),s.removeAttribute(e)}else e.startsWith(C)&&(o.push({type:6,index:n}),s.removeAttribute(e));if(q.test(s.tagName)){const e=s.textContent.split(C),t=e.length-1;if(t>0){s.textContent=E?E.emptyScript:"";for(let i=0;i<t;i++)s.append(e[i],R()),Z.nextNode(),o.push({type:2,index:++n});s.append(e[t],R())}}}else if(8===s.nodeType)if(s.data===M)o.push({type:2,index:n});else{let e=-1;for(;-1!==(e=s.data.indexOf(C,e+1));)o.push({type:7,index:n}),e+=C.length-1}n++}}static createElement(e,t){const i=T.createElement("template");return i.innerHTML=e,i}}function G(e,t,i=e,s){if(t===Q)return t;let n=void 0!==s?i._$Co?.[s]:i._$Cl;const r=N(t)?void 0:t._$litDirective$;return n?.constructor!==r&&(n?._$AO?.(!1),void 0===r?n=void 0:(n=new r(e),n._$AT(e,i,s)),void 0!==s?(i._$Co??=[])[s]=n:i._$Cl=n),void 0!==n&&(t=G(e,n._$AS(e,t.values),n,s)),t}class J{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);Z.currentNode=s;let n=Z.nextNode(),r=0,a=0,o=i[0];for(;void 0!==o;){if(r===o.index){let t;2===o.type?t=new ee(n,n.nextSibling,this,e):1===o.type?t=new o.ctor(n,o.name,o.strings,this,e):6===o.type&&(t=new re(n,this,e)),this._$AV.push(t),o=i[++a]}r!==o?.index&&(n=Z.nextNode(),r++)}return Z.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 ee{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(e,t,i,s){this.type=2,this._$AH=W,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=G(this,e,t),N(e)?e===W||null==e||""===e?(this._$AH!==W&&this._$AR(),this._$AH=W):e!==this._$AH&&e!==Q&&this._(e):void 0!==e._$litType$?this.$(e):void 0!==e.nodeType?this.T(e):(e=>P(e)||"function"==typeof e?.[Symbol.iterator])(e)?this.k(e):this._(e)}O(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}T(e){this._$AH!==e&&(this._$AR(),this._$AH=this.O(e))}_(e){this._$AH!==W&&N(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(V(i.h,i.h[0]),this.options)),i);if(this._$AH?._$AD===s)this._$AH.p(t);else{const e=new J(s,this),i=e.u(this.options);e.p(t),this.T(i),this._$AH=e}}_$AC(e){let t=Y.get(e.strings);return void 0===t&&Y.set(e.strings,t=new K(e)),t}k(e){P(this._$AH)||(this._$AH=[],this._$AR());const t=this._$AH;let i,s=0;for(const n of e)s===t.length?t.push(i=new ee(this.O(R()),this.O(R()),this,this.options)):i=t[s],i._$AI(n),s++;s<t.length&&(this._$AR(i&&i._$AB.nextSibling,s),t.length=s)}_$AR(e=this._$AA.nextSibling,t){for(this._$AP?.(!1,!0,t);e!==this._$AB;){const t=e.nextSibling;e.remove(),e=t}}setConnected(e){void 0===this._$AM&&(this._$Cv=e,this._$AP?.(e))}}class te{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,t,i,s,n){this.type=1,this._$AH=W,this._$AN=void 0,this.element=e,this.name=t,this._$AM=s,this.options=n,i.length>2||""!==i[0]||""!==i[1]?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=W}_$AI(e,t=this,i,s){const n=this.strings;let r=!1;if(void 0===n)e=G(this,e,t,0),r=!N(e)||e!==this._$AH&&e!==Q,r&&(this._$AH=e);else{const s=e;let a,o;for(e=n[0],a=0;a<n.length-1;a++)o=G(this,s[i+a],t,a),o===Q&&(o=this._$AH[a]),r||=!N(o)||o!==this._$AH[a],o===W?e=W:e!==W&&(e+=(o??"")+n[a+1]),this._$AH[a]=o}r&&!s&&this.j(e)}j(e){e===W?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??"")}}class ie extends te{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===W?void 0:e}}class se extends te{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==W)}}class ne extends te{constructor(e,t,i,s,n){super(e,t,i,s,n),this.type=5}_$AI(e,t=this){if((e=G(this,e,t,0)??W)===Q)return;const i=this._$AH,s=e===W&&i!==W||e.capture!==i.capture||e.once!==i.once||e.passive!==i.passive,n=e!==W&&(i===W||s);s&&this.element.removeEventListener(this.name,this,i),n&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){"function"==typeof this._$AH?this._$AH.call(this.options?.host??this.element,e):this._$AH.handleEvent(e)}}class re{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){G(this,e)}}const ae={I:ee},oe=S.litHtmlPolyfillSupport;oe?.(K,ee),(S.litHtmlVersions??=[]).push("3.3.2");const le=globalThis;
17
+ const S=globalThis,E=S.trustedTypes,A=E?E.createPolicy("lit-html",{createHTML:e=>e}):void 0,z="$lit$",C=`lit$${Math.random().toFixed(9).slice(2)}$`,M="?"+C,D=`<${M}>`,R=document,T=()=>R.createComment(""),N=e=>null===e||"object"!=typeof e&&"function"!=typeof e,P=Array.isArray,O="[ \t\n\f\r]",U=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,L=/-->/g,H=/>/g,j=RegExp(`>|${O}(?:([^\\s"'>=/]+)(${O}*=${O}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),F=/'/g,B=/"/g,q=/^(?:script|style|textarea|title)$/i,X=(e=>(t,...i)=>({_$litType$:e,strings:t,values:i}))(1),Q=Symbol.for("lit-noChange"),W=Symbol.for("lit-nothing"),Y=new WeakMap,Z=R.createTreeWalker(R,129);function V(e,t){if(!P(e)||!e.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==A?A.createHTML(t):t}class K{constructor({strings:e,_$litType$:t},i){let s;this.parts=[];let n=0,r=0;const a=e.length-1,o=this.parts,[l,h]=((e,t)=>{const i=e.length-1,s=[];let n,r=2===t?"<svg>":3===t?"<math>":"",a=U;for(let t=0;t<i;t++){const i=e[t];let o,l,h=-1,c=0;for(;c<i.length&&(a.lastIndex=c,l=a.exec(i),null!==l);)c=a.lastIndex,a===U?"!--"===l[1]?a=L:void 0!==l[1]?a=H:void 0!==l[2]?(q.test(l[2])&&(n=RegExp("</"+l[2],"g")),a=j):void 0!==l[3]&&(a=j):a===j?">"===l[0]?(a=n??U,h=-1):void 0===l[1]?h=-2:(h=a.lastIndex-l[2].length,o=l[1],a=void 0===l[3]?j:'"'===l[3]?B:F):a===B||a===F?a=j:a===L||a===H?a=U:(a=j,n=void 0);const d=a===j&&e[t+1].startsWith("/>")?" ":"";r+=a===U?i+D:h>=0?(s.push(o),i.slice(0,h)+z+i.slice(h)+C+d):i+C+(-2===h?t:d)}return[V(e,r+(e[i]||"<?>")+(2===t?"</svg>":3===t?"</math>":"")),s]})(e,t);if(this.el=K.createElement(l,i),Z.currentNode=this.el.content,2===t||3===t){const e=this.el.content.firstChild;e.replaceWith(...e.childNodes)}for(;null!==(s=Z.nextNode())&&o.length<a;){if(1===s.nodeType){if(s.hasAttributes())for(const e of s.getAttributeNames())if(e.endsWith(z)){const t=h[r++],i=s.getAttribute(e).split(C),a=/([.?@])?(.*)/.exec(t);o.push({type:1,index:n,name:a[2],strings:i,ctor:"."===a[1]?ie:"?"===a[1]?se:"@"===a[1]?ne:te}),s.removeAttribute(e)}else e.startsWith(C)&&(o.push({type:6,index:n}),s.removeAttribute(e));if(q.test(s.tagName)){const e=s.textContent.split(C),t=e.length-1;if(t>0){s.textContent=E?E.emptyScript:"";for(let i=0;i<t;i++)s.append(e[i],T()),Z.nextNode(),o.push({type:2,index:++n});s.append(e[t],T())}}}else if(8===s.nodeType)if(s.data===M)o.push({type:2,index:n});else{let e=-1;for(;-1!==(e=s.data.indexOf(C,e+1));)o.push({type:7,index:n}),e+=C.length-1}n++}}static createElement(e,t){const i=R.createElement("template");return i.innerHTML=e,i}}function G(e,t,i=e,s){if(t===Q)return t;let n=void 0!==s?i._$Co?.[s]:i._$Cl;const r=N(t)?void 0:t._$litDirective$;return n?.constructor!==r&&(n?._$AO?.(!1),void 0===r?n=void 0:(n=new r(e),n._$AT(e,i,s)),void 0!==s?(i._$Co??=[])[s]=n:i._$Cl=n),void 0!==n&&(t=G(e,n._$AS(e,t.values),n,s)),t}class J{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??R).importNode(t,!0);Z.currentNode=s;let n=Z.nextNode(),r=0,a=0,o=i[0];for(;void 0!==o;){if(r===o.index){let t;2===o.type?t=new ee(n,n.nextSibling,this,e):1===o.type?t=new o.ctor(n,o.name,o.strings,this,e):6===o.type&&(t=new re(n,this,e)),this._$AV.push(t),o=i[++a]}r!==o?.index&&(n=Z.nextNode(),r++)}return Z.currentNode=R,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 ee{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(e,t,i,s){this.type=2,this._$AH=W,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=G(this,e,t),N(e)?e===W||null==e||""===e?(this._$AH!==W&&this._$AR(),this._$AH=W):e!==this._$AH&&e!==Q&&this._(e):void 0!==e._$litType$?this.$(e):void 0!==e.nodeType?this.T(e):(e=>P(e)||"function"==typeof e?.[Symbol.iterator])(e)?this.k(e):this._(e)}O(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}T(e){this._$AH!==e&&(this._$AR(),this._$AH=this.O(e))}_(e){this._$AH!==W&&N(this._$AH)?this._$AA.nextSibling.data=e:this.T(R.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(V(i.h,i.h[0]),this.options)),i);if(this._$AH?._$AD===s)this._$AH.p(t);else{const e=new J(s,this),i=e.u(this.options);e.p(t),this.T(i),this._$AH=e}}_$AC(e){let t=Y.get(e.strings);return void 0===t&&Y.set(e.strings,t=new K(e)),t}k(e){P(this._$AH)||(this._$AH=[],this._$AR());const t=this._$AH;let i,s=0;for(const n of e)s===t.length?t.push(i=new ee(this.O(T()),this.O(T()),this,this.options)):i=t[s],i._$AI(n),s++;s<t.length&&(this._$AR(i&&i._$AB.nextSibling,s),t.length=s)}_$AR(e=this._$AA.nextSibling,t){for(this._$AP?.(!1,!0,t);e!==this._$AB;){const t=e.nextSibling;e.remove(),e=t}}setConnected(e){void 0===this._$AM&&(this._$Cv=e,this._$AP?.(e))}}class te{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,t,i,s,n){this.type=1,this._$AH=W,this._$AN=void 0,this.element=e,this.name=t,this._$AM=s,this.options=n,i.length>2||""!==i[0]||""!==i[1]?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=W}_$AI(e,t=this,i,s){const n=this.strings;let r=!1;if(void 0===n)e=G(this,e,t,0),r=!N(e)||e!==this._$AH&&e!==Q,r&&(this._$AH=e);else{const s=e;let a,o;for(e=n[0],a=0;a<n.length-1;a++)o=G(this,s[i+a],t,a),o===Q&&(o=this._$AH[a]),r||=!N(o)||o!==this._$AH[a],o===W?e=W:e!==W&&(e+=(o??"")+n[a+1]),this._$AH[a]=o}r&&!s&&this.j(e)}j(e){e===W?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??"")}}class ie extends te{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===W?void 0:e}}class se extends te{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==W)}}class ne extends te{constructor(e,t,i,s,n){super(e,t,i,s,n),this.type=5}_$AI(e,t=this){if((e=G(this,e,t,0)??W)===Q)return;const i=this._$AH,s=e===W&&i!==W||e.capture!==i.capture||e.once!==i.once||e.passive!==i.passive,n=e!==W&&(i===W||s);s&&this.element.removeEventListener(this.name,this,i),n&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){"function"==typeof this._$AH?this._$AH.call(this.options?.host??this.element,e):this._$AH.handleEvent(e)}}class re{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){G(this,e)}}const ae={I:ee},oe=S.litHtmlPolyfillSupport;oe?.(K,ee),(S.litHtmlVersions??=[]).push("3.3.2");const le=globalThis;
18
18
  /**
19
19
  * @license
20
20
  * Copyright 2017 Google LLC
21
21
  * SPDX-License-Identifier: BSD-3-Clause
22
- */let he=class extends I{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){const e=super.createRenderRoot();return this.renderOptions.renderBefore??=e.firstChild,e}update(e){const t=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=((e,t,i)=>{const s=i?.renderBefore??t;let n=s._$litPart$;if(void 0===n){const e=i?.renderBefore??null;s._$litPart$=n=new ee(t.insertBefore(R(),e),e,void 0,i??{})}return n._$AI(e),n})(t,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return Q}};he._$litElement$=!0,he.finalized=!0,le.litElementHydrateSupport?.({LitElement:he});const ce=le.litElementPolyfillSupport;ce?.({LitElement:he}),(le.litElementVersions??=[]).push("4.2.2");
22
+ */let he=class extends I{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){const e=super.createRenderRoot();return this.renderOptions.renderBefore??=e.firstChild,e}update(e){const t=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=((e,t,i)=>{const s=i?.renderBefore??t;let n=s._$litPart$;if(void 0===n){const e=i?.renderBefore??null;s._$litPart$=n=new ee(t.insertBefore(T(),e),e,void 0,i??{})}return n._$AI(e),n})(t,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return Q}};he._$litElement$=!0,he.finalized=!0,le.litElementHydrateSupport?.({LitElement:he});const ce=le.litElementPolyfillSupport;ce?.({LitElement:he}),(le.litElementVersions??=[]).push("4.2.2");
23
23
  /**
24
24
  * @license
25
25
  * Copyright 2017 Google LLC
@@ -1254,7 +1254,7 @@ function me(e,t){return(t,i,s)=>((e,t,i)=>(i.configurable=!0,i.enumerable=!0,Ref
1254
1254
  width: 100%;
1255
1255
  max-width: 700px;
1256
1256
  }
1257
- `,Ce([ge({type:String})],Me.prototype,"title",void 0),Me=Ce([de("kr-screen-detail")],Me);var De=function(e,t,i,s){var n,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 o=e.length-1;o>=0;o--)(n=e[o])&&(a=(r<3?n(a):r>3?n(t,i,a):n(t,i))||a);return r>3&&a&&Object.defineProperty(t,i,a),a};let Te=class extends he{constructor(){super(...arguments),this.breadcrumbs=[],this.menu=!1}_handleMenuClick(){this.dispatchEvent(new CustomEvent("menu-click",{bubbles:!0,composed:!0}))}resolveUrl(e){if(!e.url)return"#";let t=e.url;e.url.startsWith("/")&&(t=e.url.slice(1));const i=document.querySelector("base")?.getAttribute("href")||"/";return i.endsWith("/")?i+t:i+"/"+t}_handleBreadcrumbClick(e,t,i){if(i||!t.url)return void e.preventDefault();if(e.ctrlKey||e.metaKey||1===e.button)return;const s=new CustomEvent("breadcrumb-click",{detail:{breadcrumb:t},bubbles:!0,composed:!0,cancelable:!0});this.dispatchEvent(s),s.defaultPrevented&&e.preventDefault()}render(){return X`
1257
+ `,Ce([ge({type:String})],Me.prototype,"title",void 0),Me=Ce([de("kr-screen-detail")],Me);var De=function(e,t,i,s){var n,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 o=e.length-1;o>=0;o--)(n=e[o])&&(a=(r<3?n(a):r>3?n(t,i,a):n(t,i))||a);return r>3&&a&&Object.defineProperty(t,i,a),a};let Re=class extends he{constructor(){super(...arguments),this.breadcrumbs=[],this.menu=!1}_handleMenuClick(){this.dispatchEvent(new CustomEvent("menu-click",{bubbles:!0,composed:!0}))}resolveUrl(e){if(!e.url)return"#";let t=e.url;e.url.startsWith("/")&&(t=e.url.slice(1));const i=document.querySelector("base")?.getAttribute("href")||"/";return i.endsWith("/")?i+t:i+"/"+t}_handleBreadcrumbClick(e,t,i){if(i||!t.url)return void e.preventDefault();if(e.ctrlKey||e.metaKey||1===e.button)return;const s=new CustomEvent("breadcrumb-click",{detail:{breadcrumb:t},bubbles:!0,composed:!0,cancelable:!0});this.dispatchEvent(s),s.defaultPrevented&&e.preventDefault()}render(){return X`
1258
1258
  ${this.menu?X`
1259
1259
  <div class="menu" @click=${this._handleMenuClick}>
1260
1260
  <svg
@@ -1299,7 +1299,7 @@ function me(e,t){return(t,i,s)=>((e,t,i)=>(i.configurable=!0,i.enumerable=!0,Ref
1299
1299
  <slot></slot>
1300
1300
  </div>
1301
1301
 
1302
- `}};Te.styles=h`
1302
+ `}};Re.styles=h`
1303
1303
  :host {
1304
1304
  display: flex;
1305
1305
  flex-direction: row;
@@ -1365,23 +1365,23 @@ function me(e,t){return(t,i,s)=>((e,t,i)=>(i.configurable=!0,i.enumerable=!0,Ref
1365
1365
  width: 18px;
1366
1366
  height: 18px;
1367
1367
  }
1368
- `,De([ge({type:Array})],Te.prototype,"breadcrumbs",void 0),De([ge({type:Boolean})],Te.prototype,"menu",void 0),Te=De([de("kr-subbar")],Te);var Re=function(e,t,i,s){var n,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 o=e.length-1;o>=0;o--)(n=e[o])&&(a=(r<3?n(a):r>3?n(t,i,a):n(t,i))||a);return r>3&&a&&Object.defineProperty(t,i,a),a};class Ne{static configure(e){Ne.base=e.base,Ne.routes=e.routes,window.addEventListener("click",(e=>{const t=e.composedPath().find((e=>e instanceof HTMLAnchorElement));t&&t.origin===window.location.origin&&t.pathname.startsWith(Ne.base)&&(e.preventDefault(),Ne.navigate(t.pathname))}))}static navigate(e){let t=e;e.startsWith("/")||(t=Ne.base+"/"+e),window.history.pushState({},"",t),window.dispatchEvent(new PopStateEvent("popstate"))}static getParams(){const e=Ne.matchAll(),t={};for(const i of e)for(const e in i.params)t[e]=decodeURIComponent(i.params[e]);return t}static outlet(e){const t=Ne.matchAll();if(e>=t.length)return null;const i=t[e].route.component,s=Ne.elementCache.get(e+":"+i);if(s)return s;for(const t of Ne.elementCache.keys())t.startsWith(e+":")&&Ne.elementCache.delete(t);const n=document.createElement(i);return Ne.elementCache.set(e+":"+i,n),n}static matchAll(){const e=window.location.pathname;let t=e;e.startsWith(Ne.base)&&(t=e.slice(Ne.base.length));const i=t.split("/").filter((e=>e));return Ne.matchRoutes(Ne.routes,i)}static matchRoutes(e,t){for(const i of e){const e=i.path.split("/").filter((e=>e));if(0===e.length&&0===t.length)return[{route:i,params:{}}];if(0===e.length)continue;if(t.length<e.length)continue;const s={};let n=!0;for(let i=0;i<e.length;i++)if(e[i].startsWith(":"))s[e[i].slice(1)]=t[i];else if(e[i]!==t[i]){n=!1;break}if(!n)continue;const r=t.slice(e.length);if(r.length>0&&!i.children)continue;const a=[{route:i,params:s}];if(i.children&&r.length>0){const e=Ne.matchRoutes(i.children,r);if(e.length>0)return a.push(...e),a}if(i.children&&0===r.length&&i.default){window.history.replaceState({},"",window.location.pathname+"/"+i.default);const e=Ne.matchRoutes(i.children,[i.default]);if(e.length>0)return a.push(...e),a}return a}return[]}}Ne.base="",Ne.routes=[],Ne.elementCache=new Map;let Pe=class extends he{constructor(){super(...arguments),this.level=-1,this.handlePopState=()=>{this.requestUpdate()}}connectedCallback(){super.connectedCallback(),this.level=this.detectLevel(),window.addEventListener("popstate",this.handlePopState)}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("popstate",this.handlePopState)}detectLevel(){let e=0,t=this;for(;t;)t instanceof ShadowRoot?t=t.host:(t instanceof HTMLElement&&"KR-ROUTER-OUTLET"===t.tagName&&t!==this&&e++,t=t instanceof HTMLElement?t.parentNode:null);return e}render(){const e=Ne.outlet(this.level);return e?X`${e}`:X``}};Pe.styles=h`
1368
+ `,De([ge({type:Array})],Re.prototype,"breadcrumbs",void 0),De([ge({type:Boolean})],Re.prototype,"menu",void 0),Re=De([de("kr-subbar")],Re);var Te=function(e,t,i,s){var n,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 o=e.length-1;o>=0;o--)(n=e[o])&&(a=(r<3?n(a):r>3?n(t,i,a):n(t,i))||a);return r>3&&a&&Object.defineProperty(t,i,a),a};class Ne{static configure(e){Ne.base=e.base,Ne.routes=e.routes,window.addEventListener("click",(e=>{const t=e.composedPath().find((e=>e instanceof HTMLAnchorElement));t&&t.origin===window.location.origin&&t.pathname.startsWith(Ne.base)&&(e.preventDefault(),Ne.navigate(t.pathname))}))}static navigate(e){let t=e;e.startsWith("/")||(t=Ne.base+"/"+e),window.history.pushState({},"",t),window.dispatchEvent(new PopStateEvent("popstate"))}static getParams(){const e=Ne.matchAll(),t={};for(const i of e)for(const e in i.params)t[e]=decodeURIComponent(i.params[e]);return t}static outlet(e){const t=Ne.matchAll();if(e>=t.length)return null;const i=t[e].route.component,s=Ne.elementCache.get(e+":"+i);if(s)return s;for(const t of Ne.elementCache.keys())t.startsWith(e+":")&&Ne.elementCache.delete(t);const n=document.createElement(i);return Ne.elementCache.set(e+":"+i,n),n}static matchAll(){const e=window.location.pathname;let t=e;e.startsWith(Ne.base)&&(t=e.slice(Ne.base.length));const i=t.split("/").filter((e=>e));return Ne.matchRoutes(Ne.routes,i)}static matchRoutes(e,t){for(const i of e){const e=i.path.split("/").filter((e=>e));if(0===e.length&&0===t.length)return[{route:i,params:{}}];if(0===e.length)continue;if(t.length<e.length)continue;const s={};let n=!0;for(let i=0;i<e.length;i++)if(e[i].startsWith(":"))s[e[i].slice(1)]=t[i];else if(e[i]!==t[i]){n=!1;break}if(!n)continue;const r=t.slice(e.length);if(r.length>0&&!i.children)continue;const a=[{route:i,params:s}];if(i.children&&r.length>0){const e=Ne.matchRoutes(i.children,r);if(e.length>0)return a.push(...e),a}if(i.children&&0===r.length&&i.default){window.history.replaceState({},"",window.location.pathname+"/"+i.default);const e=Ne.matchRoutes(i.children,[i.default]);if(e.length>0)return a.push(...e),a}return a}return[]}}Ne.base="",Ne.routes=[],Ne.elementCache=new Map;let Pe=class extends he{constructor(){super(...arguments),this.level=-1,this.handlePopState=()=>{this.requestUpdate()}}connectedCallback(){super.connectedCallback(),this.level=this.detectLevel(),window.addEventListener("popstate",this.handlePopState)}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("popstate",this.handlePopState)}detectLevel(){let e=0,t=this;for(;t;)t instanceof ShadowRoot?t=t.host:(t instanceof HTMLElement&&"KR-ROUTER-OUTLET"===t.tagName&&t!==this&&e++,t=t instanceof HTMLElement?t.parentNode:null);return e}render(){const e=Ne.outlet(this.level);return e?X`${e}`:X``}};Pe.styles=h`
1369
1369
  :host {
1370
1370
  display: block;
1371
1371
  height: 100%;
1372
1372
  }
1373
- `,Pe=Re([de("kr-router-outlet")],Pe);
1373
+ `,Pe=Te([de("kr-router-outlet")],Pe);
1374
1374
  /**
1375
1375
  * @license
1376
1376
  * Copyright 2020 Google LLC
1377
1377
  * SPDX-License-Identifier: BSD-3-Clause
1378
1378
  */
1379
- const{I:Oe}=ae,Ue=()=>document.createComment(""),Le=(e,t,i)=>{const s=e._$AA.parentNode,n=void 0===t?e._$AB:t._$AA;if(void 0===i){const t=s.insertBefore(Ue(),n),r=s.insertBefore(Ue(),n);i=new Oe(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!==n||a){let e=i._$AA;for(;e!==t;){const t=e.nextSibling;s.insertBefore(e,n),e=t}}}return i},He=(e,t,i=e)=>(e._$AI(t,i),e),je={},Be=(e,t=je)=>e._$AH=t,Fe=e=>{e._$AR(),e._$AA.remove()},qe=(e,t,i)=>{const s=new Map;for(let n=t;n<=i;n++)s.set(e[n],n);return s},Xe=xe(class extends ke{constructor(e){if(super(e),e.type!==be)throw Error("repeat() can only be used in text expressions")}dt(e,t,i){let s;void 0===i?i=t:void 0!==t&&(s=t);const n=[],r=[];let a=0;for(const t of e)n[a]=s?s(t,a):a,r[a]=i(t,a),a++;return{values:r,keys:n}}render(e,t,i){return this.dt(e,t,i).values}update(e,[t,i,s]){const n=(e=>e._$AH)(e),{values:r,keys:a}=this.dt(t,i,s);if(!Array.isArray(n))return this.ut=a,r;const o=this.ut??=[],l=[];let h,c,d=0,p=n.length-1,u=0,g=r.length-1;for(;d<=p&&u<=g;)if(null===n[d])d++;else if(null===n[p])p--;else if(o[d]===a[u])l[u]=He(n[d],r[u]),d++,u++;else if(o[p]===a[g])l[g]=He(n[p],r[g]),p--,g--;else if(o[d]===a[g])l[g]=He(n[d],r[g]),Le(e,l[g+1],n[d]),d++,g--;else if(o[p]===a[u])l[u]=He(n[p],r[u]),Le(e,n[d],n[p]),p--,u++;else if(void 0===h&&(h=qe(a,u,g),c=qe(o,d,p)),h.has(o[d]))if(h.has(o[p])){const t=c.get(a[u]),i=void 0!==t?n[t]:null;if(null===i){const t=Le(e,n[d]);He(t,r[u]),l[u]=t}else l[u]=He(i,r[u]),Le(e,n[d],i),n[t]=null;u++}else Fe(n[p]),p--;else Fe(n[d]),d++;for(;u<=g;){const t=Le(e,l[g+1]);He(t,r[u]),l[u++]=t}for(;d<=p;){const e=n[d++];null!==e&&Fe(e)}return this.ut=a,Be(e,l),Q}});
1379
+ const{I:Oe}=ae,Ue=()=>document.createComment(""),Le=(e,t,i)=>{const s=e._$AA.parentNode,n=void 0===t?e._$AB:t._$AA;if(void 0===i){const t=s.insertBefore(Ue(),n),r=s.insertBefore(Ue(),n);i=new Oe(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!==n||a){let e=i._$AA;for(;e!==t;){const t=e.nextSibling;s.insertBefore(e,n),e=t}}}return i},He=(e,t,i=e)=>(e._$AI(t,i),e),je={},Fe=(e,t=je)=>e._$AH=t,Be=e=>{e._$AR(),e._$AA.remove()},qe=(e,t,i)=>{const s=new Map;for(let n=t;n<=i;n++)s.set(e[n],n);return s},Xe=xe(class extends ke{constructor(e){if(super(e),e.type!==be)throw Error("repeat() can only be used in text expressions")}dt(e,t,i){let s;void 0===i?i=t:void 0!==t&&(s=t);const n=[],r=[];let a=0;for(const t of e)n[a]=s?s(t,a):a,r[a]=i(t,a),a++;return{values:r,keys:n}}render(e,t,i){return this.dt(e,t,i).values}update(e,[t,i,s]){const n=(e=>e._$AH)(e),{values:r,keys:a}=this.dt(t,i,s);if(!Array.isArray(n))return this.ut=a,r;const o=this.ut??=[],l=[];let h,c,d=0,p=n.length-1,u=0,g=r.length-1;for(;d<=p&&u<=g;)if(null===n[d])d++;else if(null===n[p])p--;else if(o[d]===a[u])l[u]=He(n[d],r[u]),d++,u++;else if(o[p]===a[g])l[g]=He(n[p],r[g]),p--,g--;else if(o[d]===a[g])l[g]=He(n[d],r[g]),Le(e,l[g+1],n[d]),d++,g--;else if(o[p]===a[u])l[u]=He(n[p],r[u]),Le(e,n[d],n[p]),p--,u++;else if(void 0===h&&(h=qe(a,u,g),c=qe(o,d,p)),h.has(o[d]))if(h.has(o[p])){const t=c.get(a[u]),i=void 0!==t?n[t]:null;if(null===i){const t=Le(e,n[d]);He(t,r[u]),l[u]=t}else l[u]=He(i,r[u]),Le(e,n[d],i),n[t]=null;u++}else Be(n[p]),p--;else Be(n[d]),d++;for(;u<=g;){const t=Le(e,l[g+1]);He(t,r[u]),l[u++]=t}for(;d<=p;){const e=n[d++];null!==e&&Be(e)}return this.ut=a,Fe(e,l),Q}});
1380
1380
  /**
1381
1381
  * @license
1382
1382
  * Copyright 2017 Google LLC
1383
1383
  * SPDX-License-Identifier: BSD-3-Clause
1384
- */function Qe(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}let We={async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null};function Ye(e){We=e}const Ze=/[&<>"']/,Ve=new RegExp(Ze.source,"g"),Ke=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,Ge=new RegExp(Ke.source,"g"),Je={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},et=e=>Je[e];function tt(e,t){if(t){if(Ze.test(e))return e.replace(Ve,et)}else if(Ke.test(e))return e.replace(Ge,et);return e}const it=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/gi;function st(e){return e.replace(it,((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 nt=/(^|[^\[])\^/g;function rt(e,t){let i="string"==typeof e?e:e.source;t=t||"";const s={replace:(e,t)=>{let n="string"==typeof t?t:t.source;return n=n.replace(nt,"$1"),i=i.replace(e,n),s},getRegex:()=>new RegExp(i,t)};return s}function at(e){try{e=encodeURI(e).replace(/%25/g,"%")}catch(e){return null}return e}const ot={exec:()=>null};function lt(e,t){const i=e.replace(/\|/g,((e,t,i)=>{let s=!1,n=t;for(;--n>=0&&"\\"===i[n];)s=!s;return s?"|":" |"})).split(/ \|/);let s=0;if(i[0].trim()||i.shift(),i.length>0&&!i[i.length-1].trim()&&i.pop(),t)if(i.length>t)i.splice(t);else for(;i.length<t;)i.push("");for(;s<i.length;s++)i[s]=i[s].trim().replace(/\\\|/g,"|");return i}function ht(e,t,i){const s=e.length;if(0===s)return"";let n=0;for(;n<s;){if(e.charAt(s-n-1)!==t)break;n++}return e.slice(0,s-n)}function ct(e,t,i,s){const n=t.href,r=t.title?tt(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:n,title:r,text:a,tokens:s.inlineTokens(a)};return s.state.inLink=!1,e}return{type:"image",raw:i,href:n,title:r,text:tt(a)}}class dt{options;rules;lexer;constructor(e){this.options=e||We}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:ht(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=ht(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=ht(e.replace(/^ *>[ \t]?/gm,""),"\n");const i=this.lexer.state.top;this.lexer.state.top=!0;const s=this.lexer.blockTokens(e);return this.lexer.state.top=i,{type:"blockquote",raw:t[0],tokens:s,text:e}}}list(e){let t=this.rules.block.list.exec(e);if(t){let i=t[1].trim();const s=i.length>1,n={type:"list",raw:"",ordered:s,start:s?+i.slice(0,-1):"",loose:!1,items:[]};i=s?`\\d{1,9}\\${i.slice(-1)}`:`\\${i}`,this.options.pedantic&&(i=s?i:"[*+-]");const r=new RegExp(`^( {0,3}${i})((?:[\t ][^\\n]*)?(?:\\n|$))`);let a="",o="",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))),h=e.split("\n",1)[0],c=0;this.options.pedantic?(c=2,o=s.trimStart()):(c=t[2].search(/[^ ]/),c=c>4?1:c,o=s.slice(c),c+=t[1].length);let d=!1;if(!s&&/^ *$/.test(h)&&(a+=h+"\n",e=e.substring(h.length+1),i=!0),!i){const t=new RegExp(`^ {0,${Math.min(3,c-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ \t][^\\n]*)?(?:\\n|$))`),i=new RegExp(`^ {0,${Math.min(3,c-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),n=new RegExp(`^ {0,${Math.min(3,c-1)}}(?:\`\`\`|~~~)`),r=new RegExp(`^ {0,${Math.min(3,c-1)}}#`);for(;e;){const l=e.split("\n",1)[0];if(h=l,this.options.pedantic&&(h=h.replace(/^ {1,4}(?=( {4})*[^ ])/g," ")),n.test(h))break;if(r.test(h))break;if(t.test(h))break;if(i.test(e))break;if(h.search(/[^ ]/)>=c||!h.trim())o+="\n"+h.slice(c);else{if(d)break;if(s.search(/[^ ]/)>=4)break;if(n.test(s))break;if(r.test(s))break;if(i.test(s))break;o+="\n"+h}d||h.trim()||(d=!0),a+=l+"\n",e=e.substring(l.length+1),s=h.slice(c)}}n.loose||(l?n.loose=!0:/\n *\n *$/.test(a)&&(l=!0));let p,u=null;this.options.gfm&&(u=/^\[[ xX]\] /.exec(o),u&&(p="[ ] "!==u[0],o=o.replace(/^\[[ xX]\] +/,""))),n.items.push({type:"list_item",raw:a,task:!!u,checked:p,loose:!1,text:o,tokens:[]}),n.raw+=a}n.items[n.items.length-1].raw=a.trimEnd(),n.items[n.items.length-1].text=o.trimEnd(),n.raw=n.raw.trimEnd();for(let e=0;e<n.items.length;e++)if(this.lexer.state.top=!1,n.items[e].tokens=this.lexer.blockTokens(n.items[e].text,[]),!n.loose){const t=n.items[e].tokens.filter((e=>"space"===e.type)),i=t.length>0&&t.some((e=>/\n.*\n/.test(e.raw)));n.loose=i}if(n.loose)for(let e=0;e<n.items.length;e++)n.items[e].loose=!0;return n}}html(e){const t=this.rules.block.html.exec(e);if(t){return{type:"html",block:!0,raw:t[0],pre:"pre"===t[1]||"script"===t[1]||"style"===t[1],text:t[0]}}}def(e){const t=this.rules.block.def.exec(e);if(t){const e=t[1].toLowerCase().replace(/\s+/g," "),i=t[2]?t[2].replace(/^<(.*)>$/,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",s=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:e,raw:t[0],href:i,title:s}}}table(e){const t=this.rules.block.table.exec(e);if(!t)return;if(!/[:|]/.test(t[2]))return;const i=lt(t[1]),s=t[2].replace(/^\||\| *$/g,"").split("|"),n=t[3]&&t[3].trim()?t[3].replace(/\n[ \t]*$/,"").split("\n"):[],r={type:"table",raw:t[0],header:[],align:[],rows:[]};if(i.length===s.length){for(const e of s)/^ *-+: *$/.test(e)?r.align.push("right"):/^ *:-+: *$/.test(e)?r.align.push("center"):/^ *:-+ *$/.test(e)?r.align.push("left"):r.align.push(null);for(const e of i)r.header.push({text:e,tokens:this.lexer.inline(e)});for(const e of n)r.rows.push(lt(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:tt(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=ht(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)),ct(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 ct(i,e,i[0],this.lexer)}}emStrong(e,t,i=""){let s=this.rules.inline.emStrongLDelim.exec(e);if(!s)return;if(s[3]&&i.match(/[\p{L}\p{N}]/u))return;if(!(s[1]||s[2]||"")||!i||this.rules.inline.punctuation.exec(i)){const i=[...s[0]].length-1;let n,r,a=i,o=0;const l="*"===s[0][0]?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(l.lastIndex=0,t=t.slice(-1*e.length+i);null!=(s=l.exec(t));){if(n=s[1]||s[2]||s[3]||s[4]||s[5]||s[6],!n)continue;if(r=[...n].length,s[3]||s[4]){a+=r;continue}if((s[5]||s[6])&&i%3&&!((i+r)%3)){o+=r;continue}if(a-=r,a>0)continue;r=Math.min(r,r+a+o);const t=[...s[0]][0].length,l=e.slice(0,i+s.index+t+r);if(Math.min(i,r)%2){const e=l.slice(1,-1);return{type:"em",raw:l,text:e,tokens:this.lexer.inlineTokens(e)}}const h=l.slice(2,-2);return{type:"strong",raw:l,text:h,tokens:this.lexer.inlineTokens(h)}}}}codespan(e){const t=this.rules.inline.code.exec(e);if(t){let e=t[2].replace(/\n/g," ");const i=/[^ ]/.test(e),s=/^ /.test(e)&&/ $/.test(e);return i&&s&&(e=e.substring(1,e.length-1)),e=tt(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=tt(t[1]),i="mailto:"+e):(e=tt(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=tt(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=tt(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]:tt(t[0]),{type:"text",raw:t[0],text:e}}}}const pt=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,ut=/(?:[*+-]|\d{1,9}[.)])/,gt=rt(/^(?!bull |blockCode|fences|blockquote|heading|html)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html))+?)\n {0,3}(=+|-+) *(?:\n+|$)/).replace(/bull/g,ut).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(),ft=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,mt=/(?!\s*\])(?:\\.|[^\[\]\\])+/,vt=rt(/^ {0,3}\[(label)\]: *(?:\n *)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/).replace("label",mt).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),bt=rt(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,ut).getRegex(),xt="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",kt=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,_t=rt("^ {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",kt).replace("tag",xt).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),yt=rt(ft).replace("hr",pt).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",xt).getRegex(),wt={blockquote:rt(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",yt).getRegex(),code:/^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/,def:vt,fences:/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,heading:/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,hr:pt,html:_t,lheading:gt,list:bt,newline:/^(?: *(?:\n|$))+/,paragraph:yt,table:ot,text:/^[^\n]+/},$t=rt("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",pt).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",xt).getRegex(),It={...wt,table:$t,paragraph:rt(ft).replace("hr",pt).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",$t).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",xt).getRegex()},St={...wt,html:rt("^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:\"[^\"]*\"|'[^']*'|\\s[^'\"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))").replace("comment",kt).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:ot,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:rt(ft).replace("hr",pt).replace("heading"," *#{1,6} *[^\n]").replace("lheading",gt).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},Et=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,At=/^( {2,}|\\)\n(?!\s*$)/,zt="\\p{P}\\p{S}",Ct=rt(/^((?![*_])[\spunctuation])/,"u").replace(/punctuation/g,zt).getRegex(),Mt=rt(/^(?:\*+(?:((?!\*)[punct])|[^\s*]))|^_+(?:((?!_)[punct])|([^\s_]))/,"u").replace(/punct/g,zt).getRegex(),Dt=rt("^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)[punct](\\*+)(?=[\\s]|$)|[^punct\\s](\\*+)(?!\\*)(?=[punct\\s]|$)|(?!\\*)[punct\\s](\\*+)(?=[^punct\\s])|[\\s](\\*+)(?!\\*)(?=[punct])|(?!\\*)[punct](\\*+)(?!\\*)(?=[punct])|[^punct\\s](\\*+)(?=[^punct\\s])","gu").replace(/punct/g,zt).getRegex(),Tt=rt("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)[punct](_+)(?=[\\s]|$)|[^punct\\s](_+)(?!_)(?=[punct\\s]|$)|(?!_)[punct\\s](_+)(?=[^punct\\s])|[\\s](_+)(?!_)(?=[punct])|(?!_)[punct](_+)(?!_)(?=[punct])","gu").replace(/punct/g,zt).getRegex(),Rt=rt(/\\([punct])/,"gu").replace(/punct/g,zt).getRegex(),Nt=rt(/^<(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(),Pt=rt(kt).replace("(?:--\x3e|$)","--\x3e").getRegex(),Ot=rt("^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",Pt).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Ut=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,Lt=rt(/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/).replace("label",Ut).replace("href",/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Ht=rt(/^!?\[(label)\]\[(ref)\]/).replace("label",Ut).replace("ref",mt).getRegex(),jt=rt(/^!?\[(ref)\](?:\[\])?/).replace("ref",mt).getRegex(),Bt={_backpedal:ot,anyPunctuation:Rt,autolink:Nt,blockSkip:/\[[^[\]]*?\]\([^\(\)]*?\)|`[^`]*?`|<[^<>]*?>/g,br:At,code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,del:ot,emStrongLDelim:Mt,emStrongRDelimAst:Dt,emStrongRDelimUnd:Tt,escape:Et,link:Lt,nolink:jt,punctuation:Ct,reflink:Ht,reflinkSearch:rt("reflink|nolink(?!\\()","g").replace("reflink",Ht).replace("nolink",jt).getRegex(),tag:Ot,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,url:ot},Ft={...Bt,link:rt(/^!?\[(label)\]\((.*?)\)/).replace("label",Ut).getRegex(),reflink:rt(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Ut).getRegex()},qt={...Bt,escape:rt(Et).replace("])","~|])").getRegex(),url:rt(/^((?: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.!#$%&'*+\/=?_`{\|}~-]+@)))/},Xt={...qt,br:rt(At).replace("{2,}","*").getRegex(),text:rt(qt.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Qt={normal:wt,gfm:It,pedantic:St},Wt={normal:Bt,gfm:qt,breaks:Xt,pedantic:Ft};class Yt{tokens;options;state;tokenizer;inlineQueue;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||We,this.options.tokenizer=this.options.tokenizer||new dt,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:Qt.normal,inline:Wt.normal};this.options.pedantic?(t.block=Qt.pedantic,t.inline=Wt.pedantic):this.options.gfm&&(t.block=Qt.gfm,this.options.breaks?t.inline=Wt.breaks:t.inline=Wt.gfm),this.tokenizer.rules=t}static get rules(){return{block:Qt,inline:Wt}}static lex(e,t){return new Yt(t).lex(e)}static lexInline(e,t){return new Yt(t).inlineTokens(e)}lex(e){e=e.replace(/\r\n|\r/g,"\n"),this.blockTokens(e,this.tokens);for(let e=0;e<this.inlineQueue.length;e++){const t=this.inlineQueue[e];this.inlineTokens(t.src,t.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[]){let i,s,n,r;for(e=this.options.pedantic?e.replace(/\t/g," ").replace(/^ +$/gm,""):e.replace(/^( *)(\t+)/gm,((e,t,i)=>t+" ".repeat(i.length)));e;)if(!(this.options.extensions&&this.options.extensions.block&&this.options.extensions.block.some((s=>!!(i=s.call({lexer:this},e,t))&&(e=e.substring(i.raw.length),t.push(i),!0)))))if(i=this.tokenizer.space(e))e=e.substring(i.raw.length),1===i.raw.length&&t.length>0?t[t.length-1].raw+="\n":t.push(i);else if(i=this.tokenizer.code(e))e=e.substring(i.raw.length),s=t[t.length-1],!s||"paragraph"!==s.type&&"text"!==s.type?t.push(i):(s.raw+="\n"+i.raw,s.text+="\n"+i.text,this.inlineQueue[this.inlineQueue.length-1].src=s.text);else if(i=this.tokenizer.fences(e))e=e.substring(i.raw.length),t.push(i);else if(i=this.tokenizer.heading(e))e=e.substring(i.raw.length),t.push(i);else if(i=this.tokenizer.hr(e))e=e.substring(i.raw.length),t.push(i);else if(i=this.tokenizer.blockquote(e))e=e.substring(i.raw.length),t.push(i);else if(i=this.tokenizer.list(e))e=e.substring(i.raw.length),t.push(i);else if(i=this.tokenizer.html(e))e=e.substring(i.raw.length),t.push(i);else if(i=this.tokenizer.def(e))e=e.substring(i.raw.length),s=t[t.length-1],!s||"paragraph"!==s.type&&"text"!==s.type?this.tokens.links[i.tag]||(this.tokens.links[i.tag]={href:i.href,title:i.title}):(s.raw+="\n"+i.raw,s.text+="\n"+i.raw,this.inlineQueue[this.inlineQueue.length-1].src=s.text);else if(i=this.tokenizer.table(e))e=e.substring(i.raw.length),t.push(i);else if(i=this.tokenizer.lheading(e))e=e.substring(i.raw.length),t.push(i);else{if(n=e,this.options.extensions&&this.options.extensions.startBlock){let t=1/0;const i=e.slice(1);let s;this.options.extensions.startBlock.forEach((e=>{s=e.call({lexer:this},i),"number"==typeof s&&s>=0&&(t=Math.min(t,s))})),t<1/0&&t>=0&&(n=e.substring(0,t+1))}if(this.state.top&&(i=this.tokenizer.paragraph(n)))s=t[t.length-1],r&&"paragraph"===s.type?(s.raw+="\n"+i.raw,s.text+="\n"+i.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=s.text):t.push(i),r=n.length!==e.length,e=e.substring(i.raw.length);else if(i=this.tokenizer.text(e))e=e.substring(i.raw.length),s=t[t.length-1],s&&"text"===s.type?(s.raw+="\n"+i.raw,s.text+="\n"+i.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=s.text):t.push(i);else if(e){const t="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(t);break}throw new Error(t)}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){let i,s,n,r,a,o,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||(o=""),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,o))e=e.substring(i.raw.length),t.push(i);else if(i=this.tokenizer.codespan(e))e=e.substring(i.raw.length),t.push(i);else if(i=this.tokenizer.br(e))e=e.substring(i.raw.length),t.push(i);else if(i=this.tokenizer.del(e))e=e.substring(i.raw.length),t.push(i);else if(i=this.tokenizer.autolink(e))e=e.substring(i.raw.length),t.push(i);else if(this.state.inLink||!(i=this.tokenizer.url(e))){if(n=e,this.options.extensions&&this.options.extensions.startInline){let t=1/0;const i=e.slice(1);let s;this.options.extensions.startInline.forEach((e=>{s=e.call({lexer:this},i),"number"==typeof s&&s>=0&&(t=Math.min(t,s))})),t<1/0&&t>=0&&(n=e.substring(0,t+1))}if(i=this.tokenizer.inlineText(n))e=e.substring(i.raw.length),"_"!==i.raw.slice(-1)&&(o=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 Zt{options;constructor(e){this.options=e||We}code(e,t,i){const s=(t||"").match(/^\S*/)?.[0];return e=e.replace(/\n$/,"")+"\n",s?'<pre><code class="language-'+tt(s)+'">'+(i?e:tt(e,!0))+"</code></pre>\n":"<pre><code>"+(i?e:tt(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=at(e);if(null===s)return i;let n='<a href="'+(e=s)+'"';return t&&(n+=' title="'+t+'"'),n+=">"+i+"</a>",n}image(e,t,i){const s=at(e);if(null===s)return i;let n=`<img src="${e=s}" alt="${i}"`;return t&&(n+=` title="${t}"`),n+=">",n}text(e){return e}}class 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 Kt{options;renderer;textRenderer;constructor(e){this.options=e||We,this.options.renderer=this.options.renderer||new Zt,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new Vt}static parse(e,t){return new Kt(t).parse(e)}static parseInline(e,t){return new Kt(t).parseInline(e)}parse(e,t=!0){let i="";for(let s=0;s<e.length;s++){const n=e[s];if(this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[n.type]){const e=n,t=this.options.extensions.renderers[e.type].call({parser:this},e);if(!1!==t||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(e.type)){i+=t||"";continue}}switch(n.type){case"space":continue;case"hr":i+=this.renderer.hr();continue;case"heading":{const e=n;i+=this.renderer.heading(this.parseInline(e.tokens),e.depth,st(this.parseInline(e.tokens,this.textRenderer)));continue}case"code":{const e=n;i+=this.renderer.code(e.text,e.lang,!!e.escaped);continue}case"table":{const e=n;let t="",s="";for(let t=0;t<e.header.length;t++)s+=this.renderer.tablecell(this.parseInline(e.header[t].tokens),{header:!0,align:e.align[t]});t+=this.renderer.tablerow(s);let r="";for(let t=0;t<e.rows.length;t++){const i=e.rows[t];s="";for(let t=0;t<i.length;t++)s+=this.renderer.tablecell(this.parseInline(i[t].tokens),{header:!1,align:e.align[t]});r+=this.renderer.tablerow(s)}i+=this.renderer.table(t,r);continue}case"blockquote":{const e=n,t=this.parse(e.tokens);i+=this.renderer.blockquote(t);continue}case"list":{const e=n,t=e.ordered,s=e.start,r=e.loose;let a="";for(let t=0;t<e.items.length;t++){const i=e.items[t],s=i.checked,n=i.task;let o="";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+" "}):o+=e+" "}o+=this.parse(i.tokens,r),a+=this.renderer.listitem(o,n,!!s)}i+=this.renderer.list(a,t,s);continue}case"html":{const e=n;i+=this.renderer.html(e.text,e.block);continue}case"paragraph":{const e=n;i+=this.renderer.paragraph(this.parseInline(e.tokens));continue}case"text":{let r=n,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 "'+n.type+'" type was not found.';if(this.options.silent)return console.error(e),"";throw new Error(e)}}}return i}parseInline(e,t){t=t||this.renderer;let i="";for(let s=0;s<e.length;s++){const n=e[s];if(this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[n.type]){const e=this.options.extensions.renderers[n.type].call({parser:this},n);if(!1!==e||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(n.type)){i+=e||"";continue}}switch(n.type){case"escape":{const e=n;i+=t.text(e.text);break}case"html":{const e=n;i+=t.html(e.text);break}case"link":{const e=n;i+=t.link(e.href,e.title,this.parseInline(e.tokens,t));break}case"image":{const e=n;i+=t.image(e.href,e.title,e.text);break}case"strong":{const e=n;i+=t.strong(this.parseInline(e.tokens,t));break}case"em":{const e=n;i+=t.em(this.parseInline(e.tokens,t));break}case"codespan":{const e=n;i+=t.codespan(e.text);break}case"br":i+=t.br();break;case"del":{const e=n;i+=t.del(this.parseInline(e.tokens,t));break}case"text":{const e=n;i+=t.text(e.text);break}default:{const e='Token with "'+n.type+'" type was not found.';if(this.options.silent)return console.error(e),"";throw new Error(e)}}}return i}}class Gt{options;constructor(e){this.options=e||We}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}}const Jt=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(Yt.lex,Kt.parse);parseInline=this.#e(Yt.lexInline,Kt.parseInline);Parser=Kt;Renderer=Zt;TextRenderer=Vt;Lexer=Yt;Tokenizer=dt;Hooks=Gt;constructor(...e){this.use(...e)}walkTokens(e,t){let i=[];for(const s of e)switch(i=i.concat(t.call(this,s)),s.type){case"table":{const e=s;for(const s of e.header)i=i.concat(this.walkTokens(s.tokens,t));for(const s of e.rows)for(const e of s)i=i.concat(this.walkTokens(e.tokens,t));break}case"list":{const e=s;i=i.concat(this.walkTokens(e.items,t));break}default:{const e=s;this.defaults.extensions?.childTokens?.[e.type]?this.defaults.extensions.childTokens[e.type].forEach((s=>{const n=e[s].flat(1/0);i=i.concat(this.walkTokens(n,t))})):e.tokens&&(i=i.concat(this.walkTokens(e.tokens,t)))}}return i}use(...e){const t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach((e=>{const i={...e};if(i.async=this.defaults.async||i.async||!1,e.extensions&&(e.extensions.forEach((e=>{if(!e.name)throw new Error("extension name required");if("renderer"in e){const i=t.renderers[e.name];t.renderers[e.name]=i?function(...t){let s=e.renderer.apply(this,t);return!1===s&&(s=i.apply(this,t)),s}:e.renderer}if("tokenizer"in e){if(!e.level||"block"!==e.level&&"inline"!==e.level)throw new Error("extension level must be 'block' or 'inline'");const i=t[e.level];i?i.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&("block"===e.level?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:"inline"===e.level&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}"childTokens"in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)})),i.extensions=t),e.renderer){const t=this.defaults.renderer||new Zt(this.defaults);for(const i in e.renderer){if(!(i in t))throw new Error(`renderer '${i}' does not exist`);if("options"===i)continue;const s=i,n=e.renderer[s],r=t[s];t[s]=(...e)=>{let i=n.apply(t,e);return!1===i&&(i=r.apply(t,e)),i||""}}i.renderer=t}if(e.tokenizer){const t=this.defaults.tokenizer||new dt(this.defaults);for(const i in e.tokenizer){if(!(i in t))throw new Error(`tokenizer '${i}' does not exist`);if(["options","rules","lexer"].includes(i))continue;const s=i,n=e.tokenizer[s],r=t[s];t[s]=(...e)=>{let i=n.apply(t,e);return!1===i&&(i=r.apply(t,e)),i}}i.tokenizer=t}if(e.hooks){const t=this.defaults.hooks||new Gt;for(const i in e.hooks){if(!(i in t))throw new Error(`hook '${i}' does not exist`);if("options"===i)continue;const s=i,n=e.hooks[s],r=t[s];Gt.passThroughHooks.has(i)?t[s]=e=>{if(this.defaults.async)return Promise.resolve(n.call(t,e)).then((e=>r.call(t,e)));const i=n.call(t,e);return r.call(t,i)}:t[s]=(...e)=>{let i=n.apply(t,e);return!1===i&&(i=r.apply(t,e)),i}}i.hooks=t}if(e.walkTokens){const t=this.defaults.walkTokens,s=e.walkTokens;i.walkTokens=function(e){let i=[];return i.push(s.call(this,e)),t&&(i=i.concat(t.call(this,e))),i}}this.defaults={...this.defaults,...i}})),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return Yt.lex(e,t??this.defaults)}parser(e,t){return Kt.parse(e,t??this.defaults)}#e(e,t){return(i,s)=>{const n={...s},r={...this.defaults,...n};!0===this.defaults.async&&!1===n.async&&(r.silent||console.warn("marked(): The async option was set to true by an extension. The async: false option sent to parse will be ignored."),r.async=!0);const 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 n=t(s,r);return r.hooks&&(n=r.hooks.postprocess(n)),n}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>"+tt(i.message+"",!0)+"</pre>";return t?Promise.resolve(e):e}if(t)return Promise.reject(i);throw i}}};function ei(e,t){return Jt.parse(e,t)}ei.options=ei.setOptions=function(e){return Jt.setOptions(e),ei.defaults=Jt.defaults,Ye(ei.defaults),ei},ei.getDefaults=Qe,ei.defaults=We,ei.use=function(...e){return Jt.use(...e),ei.defaults=Jt.defaults,Ye(ei.defaults),ei},ei.walkTokens=function(e,t){return Jt.walkTokens(e,t)},ei.parseInline=Jt.parseInline,ei.Parser=Kt,ei.parser=Kt.parse,ei.Renderer=Zt,ei.TextRenderer=Vt,ei.Lexer=Yt,ei.lexer=Yt.lex,ei.Tokenizer=dt,ei.Hooks=Gt,ei.parse=ei,ei.options,ei.setOptions,ei.use,ei.walkTokens,ei.parseInline,Kt.parse,Yt.lex;var ti=function(e,t,i,s){var n,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 o=e.length-1;o>=0;o--)(n=e[o])&&(a=(r<3?n(a):r>3?n(t,i,a):n(t,i))||a);return r>3&&a&&Object.defineProperty(t,i,a),a};const ii=["image/jpeg","image/png","image/gif","image/webp"];let si=class extends he{constructor(){super(...arguments),this._reader=null,this._decoder=new TextDecoder,this._buffer="",this._userHasScrolledUp=!1,this._isDragging=!1,this._isResizing=!1,this._overlay=null,this._resizeDir="",this._dragStartX=0,this._dragStartY=0,this._dragStartLeft=0,this._dragStartTop=0,this._resizeStartW=0,this._resizeStartH=0,this._dragDepth=0,this._pendingSeq=0,this.send=null,this.clear=null,this.load=null,this.messages=[],this.label="Kat",this.placeholder="Type a message...",this.skills=[],this.opened=!1,this.hideToggle=!1,this.variant="floating",this._inputValue="",this._isStreaming=!1,this._error="",this._pendingInternalFiles=[],this._isDraggingFile=!1,this._skillMenuOpened=!1,this._skillQuery="",this._skillHighlighted=0,this._copiedIndex=-1,this._skillBrowseOpened=!1,this._skillBrowseSource="org",this._skillBrowseQuery="",this._handleMouseMove=e=>{if(this._isDragging){let t=this._dragStartLeft+(e.clientX-this._dragStartX),i=this._dragStartTop+(e.clientY-this._dragStartY);const s=this._panelEl.offsetWidth;t=Math.max(48-s,Math.min(t,window.innerWidth-48)),i=Math.max(0,Math.min(i,window.innerHeight-48)),this._panelEl.style.left=t+"px",this._panelEl.style.top=i+"px"}else if(this._isResizing){const t=e.clientX-this._dragStartX,i=e.clientY-this._dragStartY,s=340,n=380,r=.9*window.innerWidth,a=window.innerHeight-72;let o=this._resizeStartW,l=this._resizeStartH,h=this._dragStartLeft,c=this._dragStartTop;this._resizeDir.includes("e")&&(o=Math.max(s,Math.min(this._resizeStartW+t,r))),this._resizeDir.includes("w")&&(o=Math.max(s,Math.min(this._resizeStartW-t,r)),h=this._dragStartLeft+(this._resizeStartW-o)),this._resizeDir.includes("s")&&(l=Math.max(n,Math.min(this._resizeStartH+i,a))),this._resizeDir.includes("n")&&(l=Math.max(n,Math.min(this._resizeStartH-i,a)),c=this._dragStartTop+(this._resizeStartH-l)),h=Math.max(0,h),c=Math.max(0,c),this._panelEl.style.width=o+"px",this._panelEl.style.height=l+"px",this._panelEl.style.left=h+"px",this._panelEl.style.top=c+"px"}},this._handleMouseUp=()=>{this._isDragging&&(this._isDragging=!1,this._panelEl.classList.remove("panel--dragging")),this._isResizing&&(this._isResizing=!1,this._panelEl.classList.remove("panel--resizing")),this._hideOverlay(),document.removeEventListener("mousemove",this._handleMouseMove),document.removeEventListener("mouseup",this._handleMouseUp),this._saveState()}}connectedCallback(){super.connectedCallback(),this.load||(this.load=()=>s.fetch({url:"/api/system/integration/aws/bedrock/getConversationMessages"}).then((e=>e.json())).then((e=>e.data||[]))),this.load().then((e=>{e&&e.length&&(this.messages=e)})).catch((()=>{})),"inline"!==this.variant?this._restoreState():this.opened=!0}disconnectedCallback(){super.disconnectedCallback(),this._reader&&(this._reader.cancel(),this._reader=null),document.removeEventListener("mousemove",this._handleMouseMove),document.removeEventListener("mouseup",this._handleMouseUp),this._pendingInternalFiles.forEach((e=>URL.revokeObjectURL(e.previewUrl)))}updated(e){e.has("messages")&&(this._userHasScrolledUp||this._isStreaming||!this._messagesEl||requestAnimationFrame((()=>{this._messagesEl&&(this._messagesEl.scrollTop=this._messagesEl.scrollHeight)}))),e.has("opened")&&this.opened&&this._inputEl&&setTimeout((()=>{this._inputEl&&this._inputEl.focus()}),200),this._skillMenuOpened&&this._positionSkillMenu(),e.has("_skillHighlighted")&&this._skillMenuOpened&&this._skillMenuEl?.querySelector(".skill-menu__item--highlighted")?.scrollIntoView({block:"nearest"})}_positionSkillMenu(){requestAnimationFrame((()=>{if(!this._skillMenuEl||!this._inputWrapperEl)return;const e=this._inputWrapperEl.getBoundingClientRect();this._skillMenuEl.style.left=e.left+"px",this._skillMenuEl.style.width=e.width+"px";const t=this._panelEl.getBoundingClientRect().top+8,i=e.top-8-t;this._skillMenuEl.style.maxHeight=i+"px";const s=this._skillMenuEl.getBoundingClientRect(),n=Math.max(t,e.top-s.height-8);this._skillMenuEl.style.top=n+"px"}))}stop(){this._handleStop()}open(){this.opened||this._handleToggle()}close(){this.opened&&this._handleToggle()}toggle(){this._handleToggle()}_showOverlay(){this._overlay||(this._overlay=document.createElement("div"),this._overlay.style.cssText="position:fixed; inset:0; z-index:9999; display:none;",document.body.appendChild(this._overlay)),this._overlay.style.display="block"}_hideOverlay(){this._overlay&&(this._overlay.style.display="none")}_handleHeaderMouseDown(e){if("inline"===this.variant)return;if(e.target.closest("button"))return;if(!this._panelEl)return;this._isDragging=!0,this._panelEl.classList.add("panel--dragging"),this._showOverlay();const t=this._panelEl.getBoundingClientRect();this._panelEl.style.left=t.left+"px",this._panelEl.style.top=t.top+"px",this._panelEl.style.right="auto",this._panelEl.style.bottom="auto",this._panelEl.style.position="fixed",this._dragStartX=e.clientX,this._dragStartY=e.clientY,this._dragStartLeft=t.left,this._dragStartTop=t.top,e.preventDefault(),document.addEventListener("mousemove",this._handleMouseMove),document.addEventListener("mouseup",this._handleMouseUp)}_handleResizeMouseDown(e){if("inline"===this.variant)return;if(!this._panelEl)return;this._isResizing=!0,this._resizeDir=e.currentTarget.dataset.dir||"",this._panelEl.classList.add("panel--resizing"),this._showOverlay();const t=this._panelEl.getBoundingClientRect();this._panelEl.style.left=t.left+"px",this._panelEl.style.top=t.top+"px",this._panelEl.style.right="auto",this._panelEl.style.bottom="auto",this._panelEl.style.position="fixed",this._dragStartX=e.clientX,this._dragStartY=e.clientY,this._dragStartLeft=t.left,this._dragStartTop=t.top,this._resizeStartW=t.width,this._resizeStartH=t.height,e.preventDefault(),e.stopPropagation(),document.addEventListener("mousemove",this._handleMouseMove),document.addEventListener("mouseup",this._handleMouseUp)}_handleToggle(){this.opened=!this.opened,this.opened&&this._panelEl&&this._applyStoredLayout(),this._saveState()}_saveState(){try{const e={opened:String(this.opened)};if(this._panelEl){const t=this._panelEl.style;t.left&&(e.left=t.left),t.top&&(e.top=t.top),t.width&&(e.width=t.width),t.height&&(e.height=t.height),t.position&&(e.position=t.position)}localStorage.setItem("kr-chatbot-state",JSON.stringify(e))}catch{}}_restoreState(){try{const e=localStorage.getItem("kr-chatbot-state");if(!e)return;"true"===JSON.parse(e).opened&&(this.opened=!0,this.updateComplete.then((()=>this._applyStoredLayout())))}catch{}}_applyStoredLayout(){try{const e=localStorage.getItem("kr-chatbot-state");if(!e||!this._panelEl)return;const t=JSON.parse(e);t.position&&(this._panelEl.style.position=t.position),t.left&&(this._panelEl.style.left=t.left),t.top&&(this._panelEl.style.top=t.top),t.width&&(this._panelEl.style.width=t.width),t.height&&(this._panelEl.style.height=t.height)}catch{}}_handleInputChange(e){this._inputValue=e.target.value;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.skills.length?(this._skillMenuOpened=!0,this._skillQuery=i[1],this._skillHighlighted=0):this._skillMenuOpened=!1}_handleKeyDown(e){if(this._skillMenuOpened){const t=2+this._filteredSkills().length;if("ArrowDown"===e.key)return e.preventDefault(),void(this._skillHighlighted=(this._skillHighlighted+1)%t);if("ArrowUp"===e.key)return e.preventDefault(),void(this._skillHighlighted=(this._skillHighlighted-1+t)%t);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){if(0===e)return void this._openFilePicker();if(1===e)return void this._handleSkillBrowseOpen();const t=this._filteredSkills()[e-2];t&&this._handleSkillSelect(t)}_filteredSkills(){const e=this._skillQuery.toLowerCase();return this.skills.filter((t=>t.name.toLowerCase().includes(e)||t.label.toLowerCase().includes(e))).slice(0,15)}_handlePlusClick(){this._skillMenuOpened?this._skillMenuOpened=!1:(this._skillQuery="",this._skillHighlighted=0,this._skillMenuOpened=!0)}_handleSkillSelect(e){this._inputValue=`/${e.name} `,this._skillMenuOpened=!1,this._skillBrowseOpened=!1,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}_handleSkillBrowseClose(){this._skillBrowseOpened=!1}_handleSkillBrowseSearch(e){this._skillBrowseQuery=e.target.value}_handleSkillBrowseTabChange(e){this._skillBrowseSource=e.detail.activeTabId}_browseSkills(){const e=this._skillBrowseQuery.toLowerCase();return this.skills.filter((t=>(t.source||"org")===this._skillBrowseSource&&(t.name.toLowerCase().includes(e)||t.label.toLowerCase().includes(e)||(t.description||"").toLowerCase().includes(e))))}_openFilePicker(){this._fileInputEl?.click()}_handleFileInputChange(e){const t=e.target;t.files&&this._addFiles(t.files),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")}_addFiles(e){const t=Array.from(e).filter((e=>ii.includes(e.type)));t.length&&t.forEach((e=>{const t={localId:"att-"+this._pendingSeq++,file:e,name:e.name,previewUrl:URL.createObjectURL(e)};this._pendingInternalFiles=[...this._pendingInternalFiles,t]}))}_removePending(e){const t=this._pendingInternalFiles.find((t=>t.localId===e));t&&URL.revokeObjectURL(t.previewUrl),this._pendingInternalFiles=this._pendingInternalFiles.filter((t=>t.localId!==e))}_clearPending(){this._pendingInternalFiles.forEach((e=>URL.revokeObjectURL(e.previewUrl))),this._pendingInternalFiles=[]}_openImage(e){i.open({src:`/api/system/integration/aws/bedrock/conversationImage/${e.internalFileID}/view`,name:e.niceName||"image"})}_canSend(){return Boolean(this._inputValue.trim())||this._pendingInternalFiles.length>0}_handleSubmit(){if(this._isStreaming)return;const e=this._inputValue.trim(),t=this._pendingInternalFiles;if(!e&&!t.length)return;const i=t.map((e=>e.file)),n=new CustomEvent("message-submit",{detail:{message:e,internalFiles:i},bubbles:!0,composed:!0,cancelable:!0});if(this.dispatchEvent(n),n.defaultPrevented)return;const r={type:"user",content:e};this.messages=[...this.messages,r],this._inputValue="",this._error="",this._userHasScrolledUp=!1,this._pendingInternalFiles.forEach((e=>URL.revokeObjectURL(e.previewUrl))),this._pendingInternalFiles=[],this._inputEl&&(this._inputEl.style.height="auto"),this.messages=[...this.messages,{type:"assistant",content:""}],this._isStreaming=!0,this.updateComplete.then((()=>{if(!this._messagesEl)return;this._messagesEl.querySelectorAll(".message--assistant").forEach((e=>{e.style.minHeight=""}));const e=this._messagesEl.querySelectorAll(".message"),t=e[this.messages.length-2],i=e[this.messages.length-1];i&&(i.style.minHeight=this._messagesEl.clientHeight+"px"),t&&(this._messagesEl.scrollTop=t.offsetTop-this._messagesEl.offsetTop-24)})),this.send||(this.send=e=>{if(e.internalFiles.length){const t=new FormData;return t.append("userText",e.message),e.internalFiles.forEach((e=>t.append("images",e))),s.fetch({url:"/api/system/integration/aws/bedrock/stream/invokeModelForConversationWithImages",method:"POST",headers:{Accept:"text/event-stream"},body:t})}return s.fetch({url:"/api/system/integration/aws/bedrock/stream/invokeModelForConversationWithState",method:"POST",headers:{Accept:"text/event-stream"},body:{userText:e.message}})}),this.send({message:e,messages:this.messages.slice(0,-1),internalFiles:i}).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)}))}_handleStop(){this._reader&&(this._reader.cancel(),this._reader=null),this._isStreaming=!1}_handleClear(){this.clear||(this.clear=()=>s.fetch({url:"/api/system/integration/aws/bedrock/clearConversationWithState",method:"POST"})),this.clear().then((()=>{this._reader&&(this._reader.cancel(),this._reader=null),this.messages=[],this._isStreaming=!1,this._error="",this._inputValue="",this._userHasScrolledUp=!1}))}_handleMessagesScroll(e){const t=e.target,i=t.scrollHeight-t.scrollTop-t.clientHeight;this._userHasScrolledUp=i>50}_handleErrorDismiss(){this._error=""}_readStreamChunk(){this._reader&&this._reader.read().then((e=>{if(e.done)return this._isStreaming=!1,void(this._reader=null);this._buffer=this._buffer+this._decoder.decode(e.value,{stream:!0});const t=this._buffer.split("\n\n");this._buffer=t.pop()||"";for(let e=0;e<t.length;e++){if(!t[e].trim())continue;const i=t[e].split("\n");for(let e=0;e<i.length;e++){if(!i[e].startsWith("data:"))continue;const t=i[e].slice(5).trim();if(!t)continue;let s;try{s=JSON.parse(t)}catch{continue}if(this.dispatchEvent(new CustomEvent("stream-event",{detail:s,bubbles:!0,composed:!0})),"REASONING_PART"===s.type){if(s.message){const e=this.messages.length-1;e>=0&&"assistant"===this.messages[e].type&&(this.messages[e].reasoning||(this.messages[e].reasoning=""),this.messages[e].reasoning+=String(s.message),this.requestUpdate())}}else if("RESPONSE_PART"===s.type){if(s.message){const e=this.messages.length-1;e>=0&&"assistant"===this.messages[e].type&&(this.messages[e].content+=String(s.message),this.requestUpdate())}}else"ERROR"===s.type&&this._handleStreamError(String(s.message||"Unknown error"));s.finished&&(this._isStreaming=!1,this._reader=null)}}this._readStreamChunk()})).catch((e=>{"AbortError"!==e.name&&this._handleStreamError(e.message)}))}_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))}}_renderSkillMenu(){const e=this._filteredSkills();return X`
1384
+ */function Qe(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}let We={async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null};function Ye(e){We=e}const Ze=/[&<>"']/,Ve=new RegExp(Ze.source,"g"),Ke=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,Ge=new RegExp(Ke.source,"g"),Je={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},et=e=>Je[e];function tt(e,t){if(t){if(Ze.test(e))return e.replace(Ve,et)}else if(Ke.test(e))return e.replace(Ge,et);return e}const it=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/gi;function st(e){return e.replace(it,((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 nt=/(^|[^\[])\^/g;function rt(e,t){let i="string"==typeof e?e:e.source;t=t||"";const s={replace:(e,t)=>{let n="string"==typeof t?t:t.source;return n=n.replace(nt,"$1"),i=i.replace(e,n),s},getRegex:()=>new RegExp(i,t)};return s}function at(e){try{e=encodeURI(e).replace(/%25/g,"%")}catch(e){return null}return e}const ot={exec:()=>null};function lt(e,t){const i=e.replace(/\|/g,((e,t,i)=>{let s=!1,n=t;for(;--n>=0&&"\\"===i[n];)s=!s;return s?"|":" |"})).split(/ \|/);let s=0;if(i[0].trim()||i.shift(),i.length>0&&!i[i.length-1].trim()&&i.pop(),t)if(i.length>t)i.splice(t);else for(;i.length<t;)i.push("");for(;s<i.length;s++)i[s]=i[s].trim().replace(/\\\|/g,"|");return i}function ht(e,t,i){const s=e.length;if(0===s)return"";let n=0;for(;n<s;){if(e.charAt(s-n-1)!==t)break;n++}return e.slice(0,s-n)}function ct(e,t,i,s){const n=t.href,r=t.title?tt(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:n,title:r,text:a,tokens:s.inlineTokens(a)};return s.state.inLink=!1,e}return{type:"image",raw:i,href:n,title:r,text:tt(a)}}class dt{options;rules;lexer;constructor(e){this.options=e||We}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:ht(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=ht(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=ht(e.replace(/^ *>[ \t]?/gm,""),"\n");const i=this.lexer.state.top;this.lexer.state.top=!0;const s=this.lexer.blockTokens(e);return this.lexer.state.top=i,{type:"blockquote",raw:t[0],tokens:s,text:e}}}list(e){let t=this.rules.block.list.exec(e);if(t){let i=t[1].trim();const s=i.length>1,n={type:"list",raw:"",ordered:s,start:s?+i.slice(0,-1):"",loose:!1,items:[]};i=s?`\\d{1,9}\\${i.slice(-1)}`:`\\${i}`,this.options.pedantic&&(i=s?i:"[*+-]");const r=new RegExp(`^( {0,3}${i})((?:[\t ][^\\n]*)?(?:\\n|$))`);let a="",o="",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))),h=e.split("\n",1)[0],c=0;this.options.pedantic?(c=2,o=s.trimStart()):(c=t[2].search(/[^ ]/),c=c>4?1:c,o=s.slice(c),c+=t[1].length);let d=!1;if(!s&&/^ *$/.test(h)&&(a+=h+"\n",e=e.substring(h.length+1),i=!0),!i){const t=new RegExp(`^ {0,${Math.min(3,c-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ \t][^\\n]*)?(?:\\n|$))`),i=new RegExp(`^ {0,${Math.min(3,c-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),n=new RegExp(`^ {0,${Math.min(3,c-1)}}(?:\`\`\`|~~~)`),r=new RegExp(`^ {0,${Math.min(3,c-1)}}#`);for(;e;){const l=e.split("\n",1)[0];if(h=l,this.options.pedantic&&(h=h.replace(/^ {1,4}(?=( {4})*[^ ])/g," ")),n.test(h))break;if(r.test(h))break;if(t.test(h))break;if(i.test(e))break;if(h.search(/[^ ]/)>=c||!h.trim())o+="\n"+h.slice(c);else{if(d)break;if(s.search(/[^ ]/)>=4)break;if(n.test(s))break;if(r.test(s))break;if(i.test(s))break;o+="\n"+h}d||h.trim()||(d=!0),a+=l+"\n",e=e.substring(l.length+1),s=h.slice(c)}}n.loose||(l?n.loose=!0:/\n *\n *$/.test(a)&&(l=!0));let p,u=null;this.options.gfm&&(u=/^\[[ xX]\] /.exec(o),u&&(p="[ ] "!==u[0],o=o.replace(/^\[[ xX]\] +/,""))),n.items.push({type:"list_item",raw:a,task:!!u,checked:p,loose:!1,text:o,tokens:[]}),n.raw+=a}n.items[n.items.length-1].raw=a.trimEnd(),n.items[n.items.length-1].text=o.trimEnd(),n.raw=n.raw.trimEnd();for(let e=0;e<n.items.length;e++)if(this.lexer.state.top=!1,n.items[e].tokens=this.lexer.blockTokens(n.items[e].text,[]),!n.loose){const t=n.items[e].tokens.filter((e=>"space"===e.type)),i=t.length>0&&t.some((e=>/\n.*\n/.test(e.raw)));n.loose=i}if(n.loose)for(let e=0;e<n.items.length;e++)n.items[e].loose=!0;return n}}html(e){const t=this.rules.block.html.exec(e);if(t){return{type:"html",block:!0,raw:t[0],pre:"pre"===t[1]||"script"===t[1]||"style"===t[1],text:t[0]}}}def(e){const t=this.rules.block.def.exec(e);if(t){const e=t[1].toLowerCase().replace(/\s+/g," "),i=t[2]?t[2].replace(/^<(.*)>$/,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",s=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:e,raw:t[0],href:i,title:s}}}table(e){const t=this.rules.block.table.exec(e);if(!t)return;if(!/[:|]/.test(t[2]))return;const i=lt(t[1]),s=t[2].replace(/^\||\| *$/g,"").split("|"),n=t[3]&&t[3].trim()?t[3].replace(/\n[ \t]*$/,"").split("\n"):[],r={type:"table",raw:t[0],header:[],align:[],rows:[]};if(i.length===s.length){for(const e of s)/^ *-+: *$/.test(e)?r.align.push("right"):/^ *:-+: *$/.test(e)?r.align.push("center"):/^ *:-+ *$/.test(e)?r.align.push("left"):r.align.push(null);for(const e of i)r.header.push({text:e,tokens:this.lexer.inline(e)});for(const e of n)r.rows.push(lt(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:tt(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=ht(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)),ct(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 ct(i,e,i[0],this.lexer)}}emStrong(e,t,i=""){let s=this.rules.inline.emStrongLDelim.exec(e);if(!s)return;if(s[3]&&i.match(/[\p{L}\p{N}]/u))return;if(!(s[1]||s[2]||"")||!i||this.rules.inline.punctuation.exec(i)){const i=[...s[0]].length-1;let n,r,a=i,o=0;const l="*"===s[0][0]?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(l.lastIndex=0,t=t.slice(-1*e.length+i);null!=(s=l.exec(t));){if(n=s[1]||s[2]||s[3]||s[4]||s[5]||s[6],!n)continue;if(r=[...n].length,s[3]||s[4]){a+=r;continue}if((s[5]||s[6])&&i%3&&!((i+r)%3)){o+=r;continue}if(a-=r,a>0)continue;r=Math.min(r,r+a+o);const t=[...s[0]][0].length,l=e.slice(0,i+s.index+t+r);if(Math.min(i,r)%2){const e=l.slice(1,-1);return{type:"em",raw:l,text:e,tokens:this.lexer.inlineTokens(e)}}const h=l.slice(2,-2);return{type:"strong",raw:l,text:h,tokens:this.lexer.inlineTokens(h)}}}}codespan(e){const t=this.rules.inline.code.exec(e);if(t){let e=t[2].replace(/\n/g," ");const i=/[^ ]/.test(e),s=/^ /.test(e)&&/ $/.test(e);return i&&s&&(e=e.substring(1,e.length-1)),e=tt(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=tt(t[1]),i="mailto:"+e):(e=tt(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=tt(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=tt(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]:tt(t[0]),{type:"text",raw:t[0],text:e}}}}const pt=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,ut=/(?:[*+-]|\d{1,9}[.)])/,gt=rt(/^(?!bull |blockCode|fences|blockquote|heading|html)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html))+?)\n {0,3}(=+|-+) *(?:\n+|$)/).replace(/bull/g,ut).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(),ft=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,mt=/(?!\s*\])(?:\\.|[^\[\]\\])+/,vt=rt(/^ {0,3}\[(label)\]: *(?:\n *)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/).replace("label",mt).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),bt=rt(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,ut).getRegex(),xt="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",kt=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,_t=rt("^ {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",kt).replace("tag",xt).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),yt=rt(ft).replace("hr",pt).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",xt).getRegex(),wt={blockquote:rt(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",yt).getRegex(),code:/^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/,def:vt,fences:/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,heading:/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,hr:pt,html:_t,lheading:gt,list:bt,newline:/^(?: *(?:\n|$))+/,paragraph:yt,table:ot,text:/^[^\n]+/},$t=rt("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",pt).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",xt).getRegex(),It={...wt,table:$t,paragraph:rt(ft).replace("hr",pt).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",$t).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",xt).getRegex()},St={...wt,html:rt("^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:\"[^\"]*\"|'[^']*'|\\s[^'\"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))").replace("comment",kt).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:ot,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:rt(ft).replace("hr",pt).replace("heading"," *#{1,6} *[^\n]").replace("lheading",gt).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},Et=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,At=/^( {2,}|\\)\n(?!\s*$)/,zt="\\p{P}\\p{S}",Ct=rt(/^((?![*_])[\spunctuation])/,"u").replace(/punctuation/g,zt).getRegex(),Mt=rt(/^(?:\*+(?:((?!\*)[punct])|[^\s*]))|^_+(?:((?!_)[punct])|([^\s_]))/,"u").replace(/punct/g,zt).getRegex(),Dt=rt("^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)[punct](\\*+)(?=[\\s]|$)|[^punct\\s](\\*+)(?!\\*)(?=[punct\\s]|$)|(?!\\*)[punct\\s](\\*+)(?=[^punct\\s])|[\\s](\\*+)(?!\\*)(?=[punct])|(?!\\*)[punct](\\*+)(?!\\*)(?=[punct])|[^punct\\s](\\*+)(?=[^punct\\s])","gu").replace(/punct/g,zt).getRegex(),Rt=rt("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)[punct](_+)(?=[\\s]|$)|[^punct\\s](_+)(?!_)(?=[punct\\s]|$)|(?!_)[punct\\s](_+)(?=[^punct\\s])|[\\s](_+)(?!_)(?=[punct])|(?!_)[punct](_+)(?!_)(?=[punct])","gu").replace(/punct/g,zt).getRegex(),Tt=rt(/\\([punct])/,"gu").replace(/punct/g,zt).getRegex(),Nt=rt(/^<(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(),Pt=rt(kt).replace("(?:--\x3e|$)","--\x3e").getRegex(),Ot=rt("^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",Pt).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Ut=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,Lt=rt(/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/).replace("label",Ut).replace("href",/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Ht=rt(/^!?\[(label)\]\[(ref)\]/).replace("label",Ut).replace("ref",mt).getRegex(),jt=rt(/^!?\[(ref)\](?:\[\])?/).replace("ref",mt).getRegex(),Ft={_backpedal:ot,anyPunctuation:Tt,autolink:Nt,blockSkip:/\[[^[\]]*?\]\([^\(\)]*?\)|`[^`]*?`|<[^<>]*?>/g,br:At,code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,del:ot,emStrongLDelim:Mt,emStrongRDelimAst:Dt,emStrongRDelimUnd:Rt,escape:Et,link:Lt,nolink:jt,punctuation:Ct,reflink:Ht,reflinkSearch:rt("reflink|nolink(?!\\()","g").replace("reflink",Ht).replace("nolink",jt).getRegex(),tag:Ot,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,url:ot},Bt={...Ft,link:rt(/^!?\[(label)\]\((.*?)\)/).replace("label",Ut).getRegex(),reflink:rt(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Ut).getRegex()},qt={...Ft,escape:rt(Et).replace("])","~|])").getRegex(),url:rt(/^((?: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.!#$%&'*+\/=?_`{\|}~-]+@)))/},Xt={...qt,br:rt(At).replace("{2,}","*").getRegex(),text:rt(qt.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Qt={normal:wt,gfm:It,pedantic:St},Wt={normal:Ft,gfm:qt,breaks:Xt,pedantic:Bt};class Yt{tokens;options;state;tokenizer;inlineQueue;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||We,this.options.tokenizer=this.options.tokenizer||new dt,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:Qt.normal,inline:Wt.normal};this.options.pedantic?(t.block=Qt.pedantic,t.inline=Wt.pedantic):this.options.gfm&&(t.block=Qt.gfm,this.options.breaks?t.inline=Wt.breaks:t.inline=Wt.gfm),this.tokenizer.rules=t}static get rules(){return{block:Qt,inline:Wt}}static lex(e,t){return new Yt(t).lex(e)}static lexInline(e,t){return new Yt(t).inlineTokens(e)}lex(e){e=e.replace(/\r\n|\r/g,"\n"),this.blockTokens(e,this.tokens);for(let e=0;e<this.inlineQueue.length;e++){const t=this.inlineQueue[e];this.inlineTokens(t.src,t.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[]){let i,s,n,r;for(e=this.options.pedantic?e.replace(/\t/g," ").replace(/^ +$/gm,""):e.replace(/^( *)(\t+)/gm,((e,t,i)=>t+" ".repeat(i.length)));e;)if(!(this.options.extensions&&this.options.extensions.block&&this.options.extensions.block.some((s=>!!(i=s.call({lexer:this},e,t))&&(e=e.substring(i.raw.length),t.push(i),!0)))))if(i=this.tokenizer.space(e))e=e.substring(i.raw.length),1===i.raw.length&&t.length>0?t[t.length-1].raw+="\n":t.push(i);else if(i=this.tokenizer.code(e))e=e.substring(i.raw.length),s=t[t.length-1],!s||"paragraph"!==s.type&&"text"!==s.type?t.push(i):(s.raw+="\n"+i.raw,s.text+="\n"+i.text,this.inlineQueue[this.inlineQueue.length-1].src=s.text);else if(i=this.tokenizer.fences(e))e=e.substring(i.raw.length),t.push(i);else if(i=this.tokenizer.heading(e))e=e.substring(i.raw.length),t.push(i);else if(i=this.tokenizer.hr(e))e=e.substring(i.raw.length),t.push(i);else if(i=this.tokenizer.blockquote(e))e=e.substring(i.raw.length),t.push(i);else if(i=this.tokenizer.list(e))e=e.substring(i.raw.length),t.push(i);else if(i=this.tokenizer.html(e))e=e.substring(i.raw.length),t.push(i);else if(i=this.tokenizer.def(e))e=e.substring(i.raw.length),s=t[t.length-1],!s||"paragraph"!==s.type&&"text"!==s.type?this.tokens.links[i.tag]||(this.tokens.links[i.tag]={href:i.href,title:i.title}):(s.raw+="\n"+i.raw,s.text+="\n"+i.raw,this.inlineQueue[this.inlineQueue.length-1].src=s.text);else if(i=this.tokenizer.table(e))e=e.substring(i.raw.length),t.push(i);else if(i=this.tokenizer.lheading(e))e=e.substring(i.raw.length),t.push(i);else{if(n=e,this.options.extensions&&this.options.extensions.startBlock){let t=1/0;const i=e.slice(1);let s;this.options.extensions.startBlock.forEach((e=>{s=e.call({lexer:this},i),"number"==typeof s&&s>=0&&(t=Math.min(t,s))})),t<1/0&&t>=0&&(n=e.substring(0,t+1))}if(this.state.top&&(i=this.tokenizer.paragraph(n)))s=t[t.length-1],r&&"paragraph"===s.type?(s.raw+="\n"+i.raw,s.text+="\n"+i.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=s.text):t.push(i),r=n.length!==e.length,e=e.substring(i.raw.length);else if(i=this.tokenizer.text(e))e=e.substring(i.raw.length),s=t[t.length-1],s&&"text"===s.type?(s.raw+="\n"+i.raw,s.text+="\n"+i.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=s.text):t.push(i);else if(e){const t="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(t);break}throw new Error(t)}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){let i,s,n,r,a,o,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||(o=""),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,o))e=e.substring(i.raw.length),t.push(i);else if(i=this.tokenizer.codespan(e))e=e.substring(i.raw.length),t.push(i);else if(i=this.tokenizer.br(e))e=e.substring(i.raw.length),t.push(i);else if(i=this.tokenizer.del(e))e=e.substring(i.raw.length),t.push(i);else if(i=this.tokenizer.autolink(e))e=e.substring(i.raw.length),t.push(i);else if(this.state.inLink||!(i=this.tokenizer.url(e))){if(n=e,this.options.extensions&&this.options.extensions.startInline){let t=1/0;const i=e.slice(1);let s;this.options.extensions.startInline.forEach((e=>{s=e.call({lexer:this},i),"number"==typeof s&&s>=0&&(t=Math.min(t,s))})),t<1/0&&t>=0&&(n=e.substring(0,t+1))}if(i=this.tokenizer.inlineText(n))e=e.substring(i.raw.length),"_"!==i.raw.slice(-1)&&(o=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 Zt{options;constructor(e){this.options=e||We}code(e,t,i){const s=(t||"").match(/^\S*/)?.[0];return e=e.replace(/\n$/,"")+"\n",s?'<pre><code class="language-'+tt(s)+'">'+(i?e:tt(e,!0))+"</code></pre>\n":"<pre><code>"+(i?e:tt(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=at(e);if(null===s)return i;let n='<a href="'+(e=s)+'"';return t&&(n+=' title="'+t+'"'),n+=">"+i+"</a>",n}image(e,t,i){const s=at(e);if(null===s)return i;let n=`<img src="${e=s}" alt="${i}"`;return t&&(n+=` title="${t}"`),n+=">",n}text(e){return e}}class 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 Kt{options;renderer;textRenderer;constructor(e){this.options=e||We,this.options.renderer=this.options.renderer||new Zt,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new Vt}static parse(e,t){return new Kt(t).parse(e)}static parseInline(e,t){return new Kt(t).parseInline(e)}parse(e,t=!0){let i="";for(let s=0;s<e.length;s++){const n=e[s];if(this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[n.type]){const e=n,t=this.options.extensions.renderers[e.type].call({parser:this},e);if(!1!==t||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(e.type)){i+=t||"";continue}}switch(n.type){case"space":continue;case"hr":i+=this.renderer.hr();continue;case"heading":{const e=n;i+=this.renderer.heading(this.parseInline(e.tokens),e.depth,st(this.parseInline(e.tokens,this.textRenderer)));continue}case"code":{const e=n;i+=this.renderer.code(e.text,e.lang,!!e.escaped);continue}case"table":{const e=n;let t="",s="";for(let t=0;t<e.header.length;t++)s+=this.renderer.tablecell(this.parseInline(e.header[t].tokens),{header:!0,align:e.align[t]});t+=this.renderer.tablerow(s);let r="";for(let t=0;t<e.rows.length;t++){const i=e.rows[t];s="";for(let t=0;t<i.length;t++)s+=this.renderer.tablecell(this.parseInline(i[t].tokens),{header:!1,align:e.align[t]});r+=this.renderer.tablerow(s)}i+=this.renderer.table(t,r);continue}case"blockquote":{const e=n,t=this.parse(e.tokens);i+=this.renderer.blockquote(t);continue}case"list":{const e=n,t=e.ordered,s=e.start,r=e.loose;let a="";for(let t=0;t<e.items.length;t++){const i=e.items[t],s=i.checked,n=i.task;let o="";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+" "}):o+=e+" "}o+=this.parse(i.tokens,r),a+=this.renderer.listitem(o,n,!!s)}i+=this.renderer.list(a,t,s);continue}case"html":{const e=n;i+=this.renderer.html(e.text,e.block);continue}case"paragraph":{const e=n;i+=this.renderer.paragraph(this.parseInline(e.tokens));continue}case"text":{let r=n,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 "'+n.type+'" type was not found.';if(this.options.silent)return console.error(e),"";throw new Error(e)}}}return i}parseInline(e,t){t=t||this.renderer;let i="";for(let s=0;s<e.length;s++){const n=e[s];if(this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[n.type]){const e=this.options.extensions.renderers[n.type].call({parser:this},n);if(!1!==e||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(n.type)){i+=e||"";continue}}switch(n.type){case"escape":{const e=n;i+=t.text(e.text);break}case"html":{const e=n;i+=t.html(e.text);break}case"link":{const e=n;i+=t.link(e.href,e.title,this.parseInline(e.tokens,t));break}case"image":{const e=n;i+=t.image(e.href,e.title,e.text);break}case"strong":{const e=n;i+=t.strong(this.parseInline(e.tokens,t));break}case"em":{const e=n;i+=t.em(this.parseInline(e.tokens,t));break}case"codespan":{const e=n;i+=t.codespan(e.text);break}case"br":i+=t.br();break;case"del":{const e=n;i+=t.del(this.parseInline(e.tokens,t));break}case"text":{const e=n;i+=t.text(e.text);break}default:{const e='Token with "'+n.type+'" type was not found.';if(this.options.silent)return console.error(e),"";throw new Error(e)}}}return i}}class Gt{options;constructor(e){this.options=e||We}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}}const Jt=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(Yt.lex,Kt.parse);parseInline=this.#e(Yt.lexInline,Kt.parseInline);Parser=Kt;Renderer=Zt;TextRenderer=Vt;Lexer=Yt;Tokenizer=dt;Hooks=Gt;constructor(...e){this.use(...e)}walkTokens(e,t){let i=[];for(const s of e)switch(i=i.concat(t.call(this,s)),s.type){case"table":{const e=s;for(const s of e.header)i=i.concat(this.walkTokens(s.tokens,t));for(const s of e.rows)for(const e of s)i=i.concat(this.walkTokens(e.tokens,t));break}case"list":{const e=s;i=i.concat(this.walkTokens(e.items,t));break}default:{const e=s;this.defaults.extensions?.childTokens?.[e.type]?this.defaults.extensions.childTokens[e.type].forEach((s=>{const n=e[s].flat(1/0);i=i.concat(this.walkTokens(n,t))})):e.tokens&&(i=i.concat(this.walkTokens(e.tokens,t)))}}return i}use(...e){const t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach((e=>{const i={...e};if(i.async=this.defaults.async||i.async||!1,e.extensions&&(e.extensions.forEach((e=>{if(!e.name)throw new Error("extension name required");if("renderer"in e){const i=t.renderers[e.name];t.renderers[e.name]=i?function(...t){let s=e.renderer.apply(this,t);return!1===s&&(s=i.apply(this,t)),s}:e.renderer}if("tokenizer"in e){if(!e.level||"block"!==e.level&&"inline"!==e.level)throw new Error("extension level must be 'block' or 'inline'");const i=t[e.level];i?i.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&("block"===e.level?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:"inline"===e.level&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}"childTokens"in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)})),i.extensions=t),e.renderer){const t=this.defaults.renderer||new Zt(this.defaults);for(const i in e.renderer){if(!(i in t))throw new Error(`renderer '${i}' does not exist`);if("options"===i)continue;const s=i,n=e.renderer[s],r=t[s];t[s]=(...e)=>{let i=n.apply(t,e);return!1===i&&(i=r.apply(t,e)),i||""}}i.renderer=t}if(e.tokenizer){const t=this.defaults.tokenizer||new dt(this.defaults);for(const i in e.tokenizer){if(!(i in t))throw new Error(`tokenizer '${i}' does not exist`);if(["options","rules","lexer"].includes(i))continue;const s=i,n=e.tokenizer[s],r=t[s];t[s]=(...e)=>{let i=n.apply(t,e);return!1===i&&(i=r.apply(t,e)),i}}i.tokenizer=t}if(e.hooks){const t=this.defaults.hooks||new Gt;for(const i in e.hooks){if(!(i in t))throw new Error(`hook '${i}' does not exist`);if("options"===i)continue;const s=i,n=e.hooks[s],r=t[s];Gt.passThroughHooks.has(i)?t[s]=e=>{if(this.defaults.async)return Promise.resolve(n.call(t,e)).then((e=>r.call(t,e)));const i=n.call(t,e);return r.call(t,i)}:t[s]=(...e)=>{let i=n.apply(t,e);return!1===i&&(i=r.apply(t,e)),i}}i.hooks=t}if(e.walkTokens){const t=this.defaults.walkTokens,s=e.walkTokens;i.walkTokens=function(e){let i=[];return i.push(s.call(this,e)),t&&(i=i.concat(t.call(this,e))),i}}this.defaults={...this.defaults,...i}})),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return Yt.lex(e,t??this.defaults)}parser(e,t){return Kt.parse(e,t??this.defaults)}#e(e,t){return(i,s)=>{const n={...s},r={...this.defaults,...n};!0===this.defaults.async&&!1===n.async&&(r.silent||console.warn("marked(): The async option was set to true by an extension. The async: false option sent to parse will be ignored."),r.async=!0);const 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 n=t(s,r);return r.hooks&&(n=r.hooks.postprocess(n)),n}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>"+tt(i.message+"",!0)+"</pre>";return t?Promise.resolve(e):e}if(t)return Promise.reject(i);throw i}}};function ei(e,t){return Jt.parse(e,t)}ei.options=ei.setOptions=function(e){return Jt.setOptions(e),ei.defaults=Jt.defaults,Ye(ei.defaults),ei},ei.getDefaults=Qe,ei.defaults=We,ei.use=function(...e){return Jt.use(...e),ei.defaults=Jt.defaults,Ye(ei.defaults),ei},ei.walkTokens=function(e,t){return Jt.walkTokens(e,t)},ei.parseInline=Jt.parseInline,ei.Parser=Kt,ei.parser=Kt.parse,ei.Renderer=Zt,ei.TextRenderer=Vt,ei.Lexer=Yt,ei.lexer=Yt.lex,ei.Tokenizer=dt,ei.Hooks=Gt,ei.parse=ei,ei.options,ei.setOptions,ei.use,ei.walkTokens,ei.parseInline,Kt.parse,Yt.lex;var ti=function(e,t,i,s){var n,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 o=e.length-1;o>=0;o--)(n=e[o])&&(a=(r<3?n(a):r>3?n(t,i,a):n(t,i))||a);return r>3&&a&&Object.defineProperty(t,i,a),a};const ii=["image/jpeg","image/png","image/gif","image/webp"];let si=class extends he{constructor(){super(...arguments),this._reader=null,this._decoder=new TextDecoder,this._buffer="",this._userHasScrolledUp=!1,this._isDragging=!1,this._isResizing=!1,this._overlay=null,this._resizeDir="",this._dragStartX=0,this._dragStartY=0,this._dragStartLeft=0,this._dragStartTop=0,this._resizeStartW=0,this._resizeStartH=0,this._dragDepth=0,this._pendingSeq=0,this._skillRequestId=0,this.send=null,this.clear=null,this.load=null,this.messages=[],this.label="Kat",this.placeholder="Type a message...",this.opened=!1,this.hideToggle=!1,this.variant="floating",this._inputValue="",this._isStreaming=!1,this._error="",this._pendingInternalFiles=[],this._isDraggingFile=!1,this._skillMenuOpened=!1,this._skillQuery="",this._skillResults=[],this._skillHighlighted=0,this._copiedIndex=-1,this._skillBrowseOpened=!1,this._skillBrowseSource="org",this._skillBrowseQuery="",this._handleMouseMove=e=>{if(this._isDragging){let t=this._dragStartLeft+(e.clientX-this._dragStartX),i=this._dragStartTop+(e.clientY-this._dragStartY);const s=this._panelEl.offsetWidth;t=Math.max(48-s,Math.min(t,window.innerWidth-48)),i=Math.max(0,Math.min(i,window.innerHeight-48)),this._panelEl.style.left=t+"px",this._panelEl.style.top=i+"px"}else if(this._isResizing){const t=e.clientX-this._dragStartX,i=e.clientY-this._dragStartY,s=340,n=380,r=.9*window.innerWidth,a=window.innerHeight-72;let o=this._resizeStartW,l=this._resizeStartH,h=this._dragStartLeft,c=this._dragStartTop;this._resizeDir.includes("e")&&(o=Math.max(s,Math.min(this._resizeStartW+t,r))),this._resizeDir.includes("w")&&(o=Math.max(s,Math.min(this._resizeStartW-t,r)),h=this._dragStartLeft+(this._resizeStartW-o)),this._resizeDir.includes("s")&&(l=Math.max(n,Math.min(this._resizeStartH+i,a))),this._resizeDir.includes("n")&&(l=Math.max(n,Math.min(this._resizeStartH-i,a)),c=this._dragStartTop+(this._resizeStartH-l)),h=Math.max(0,h),c=Math.max(0,c),this._panelEl.style.width=o+"px",this._panelEl.style.height=l+"px",this._panelEl.style.left=h+"px",this._panelEl.style.top=c+"px"}},this._handleMouseUp=()=>{this._isDragging&&(this._isDragging=!1,this._panelEl.classList.remove("panel--dragging")),this._isResizing&&(this._isResizing=!1,this._panelEl.classList.remove("panel--resizing")),this._hideOverlay(),document.removeEventListener("mousemove",this._handleMouseMove),document.removeEventListener("mouseup",this._handleMouseUp),this._saveState()}}connectedCallback(){super.connectedCallback(),this.load||(this.load=()=>s.fetch({url:"/api/system/integration/aws/bedrock/getConversationMessages"}).then((e=>e.json())).then((e=>e.data||[]))),this.load().then((e=>{e&&e.length&&(this.messages=e)})).catch((()=>{})),"inline"!==this.variant?this._restoreState():this.opened=!0}disconnectedCallback(){super.disconnectedCallback(),this._reader&&(this._reader.cancel(),this._reader=null),document.removeEventListener("mousemove",this._handleMouseMove),document.removeEventListener("mouseup",this._handleMouseUp),this._pendingInternalFiles.forEach((e=>URL.revokeObjectURL(e.previewUrl)))}updated(e){e.has("messages")&&(this._userHasScrolledUp||this._isStreaming||!this._messagesEl||requestAnimationFrame((()=>{this._messagesEl&&(this._messagesEl.scrollTop=this._messagesEl.scrollHeight)}))),e.has("opened")&&this.opened&&this._inputEl&&setTimeout((()=>{this._inputEl&&this._inputEl.focus()}),200),this._skillMenuOpened&&this._positionSkillMenu(),e.has("_skillHighlighted")&&this._skillMenuOpened&&this._skillMenuEl?.querySelector(".skill-menu__item--highlighted")?.scrollIntoView({block:"nearest"})}_positionSkillMenu(){requestAnimationFrame((()=>{if(!this._skillMenuEl||!this._inputWrapperEl)return;const e=this._inputWrapperEl.getBoundingClientRect();this._skillMenuEl.style.left=e.left+"px",this._skillMenuEl.style.width=e.width+"px";const t=this._panelEl.getBoundingClientRect().top+8,i=e.top-8-t;this._skillMenuEl.style.maxHeight=i+"px";const s=this._skillMenuEl.getBoundingClientRect(),n=Math.max(t,e.top-s.height-8);this._skillMenuEl.style.top=n+"px"}))}stop(){this._handleStop()}open(){this.opened||this._handleToggle()}close(){this.opened&&this._handleToggle()}toggle(){this._handleToggle()}_showOverlay(){this._overlay||(this._overlay=document.createElement("div"),this._overlay.style.cssText="position:fixed; inset:0; z-index:9999; display:none;",document.body.appendChild(this._overlay)),this._overlay.style.display="block"}_hideOverlay(){this._overlay&&(this._overlay.style.display="none")}_handleHeaderMouseDown(e){if("inline"===this.variant)return;if(e.target.closest("button"))return;if(!this._panelEl)return;this._isDragging=!0,this._panelEl.classList.add("panel--dragging"),this._showOverlay();const t=this._panelEl.getBoundingClientRect();this._panelEl.style.left=t.left+"px",this._panelEl.style.top=t.top+"px",this._panelEl.style.right="auto",this._panelEl.style.bottom="auto",this._panelEl.style.position="fixed",this._dragStartX=e.clientX,this._dragStartY=e.clientY,this._dragStartLeft=t.left,this._dragStartTop=t.top,e.preventDefault(),document.addEventListener("mousemove",this._handleMouseMove),document.addEventListener("mouseup",this._handleMouseUp)}_handleResizeMouseDown(e){if("inline"===this.variant)return;if(!this._panelEl)return;this._isResizing=!0,this._resizeDir=e.currentTarget.dataset.dir||"",this._panelEl.classList.add("panel--resizing"),this._showOverlay();const t=this._panelEl.getBoundingClientRect();this._panelEl.style.left=t.left+"px",this._panelEl.style.top=t.top+"px",this._panelEl.style.right="auto",this._panelEl.style.bottom="auto",this._panelEl.style.position="fixed",this._dragStartX=e.clientX,this._dragStartY=e.clientY,this._dragStartLeft=t.left,this._dragStartTop=t.top,this._resizeStartW=t.width,this._resizeStartH=t.height,e.preventDefault(),e.stopPropagation(),document.addEventListener("mousemove",this._handleMouseMove),document.addEventListener("mouseup",this._handleMouseUp)}_handleToggle(){this.opened=!this.opened,this.opened&&this._panelEl&&this._applyStoredLayout(),this._saveState()}_saveState(){try{const e={opened:String(this.opened)};if(this._panelEl){const t=this._panelEl.style;t.left&&(e.left=t.left),t.top&&(e.top=t.top),t.width&&(e.width=t.width),t.height&&(e.height=t.height),t.position&&(e.position=t.position)}localStorage.setItem("kr-chatbot-state",JSON.stringify(e))}catch{}}_restoreState(){try{const e=localStorage.getItem("kr-chatbot-state");if(!e)return;"true"===JSON.parse(e).opened&&(this.opened=!0,this.updateComplete.then((()=>this._applyStoredLayout())))}catch{}}_applyStoredLayout(){try{const e=localStorage.getItem("kr-chatbot-state");if(!e||!this._panelEl)return;const t=JSON.parse(e);t.position&&(this._panelEl.style.position=t.position),t.left&&(this._panelEl.style.left=t.left),t.top&&(this._panelEl.style.top=t.top),t.width&&(this._panelEl.style.width=t.width),t.height&&(this._panelEl.style.height=t.height)}catch{}}_handleInputChange(e){this._inputValue=e.target.value;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._searchSkills(this._skillQuery)):this._skillMenuOpened=!1}_handleKeyDown(e){if(this._skillMenuOpened){const t=2+this._filteredSkills().length;if("ArrowDown"===e.key)return e.preventDefault(),void(this._skillHighlighted=(this._skillHighlighted+1)%t);if("ArrowUp"===e.key)return e.preventDefault(),void(this._skillHighlighted=(this._skillHighlighted-1+t)%t);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){if(0===e)return void this._openFilePicker();if(1===e)return void this._handleSkillBrowseOpen();const t=this._filteredSkills()[e-2];t&&this._handleSkillSelect(t)}_searchSkills(e){this._skillRequestId++;const t=this._skillRequestId,i=e.trim();let n={match_all:{}};i&&(n={multi_match:{query:i,fields:["name^3","description^2","instructions"],type:"best_fields"}}),s.fetch({url:"/api/system/opensearch/aiskills/search",method:"POST",body:{size:100,query:{bool:{must:[n],filter:[{term:{active:!0}}]}}}}).then((e=>e.json())).then((e=>{t===this._skillRequestId&&(this._skillResults=(e?.data?.hits?.hits||[]).map((e=>e._source)))})).catch((e=>{console.error("kr-chatbot: skill search failed",e)}))}_filteredSkills(){return this._skillResults.slice(0,15)}_handlePlusClick(){this._skillMenuOpened?this._skillMenuOpened=!1:(this._skillQuery="",this._skillHighlighted=0,this._skillMenuOpened=!0,this._searchSkills(""))}_handleSkillSelect(e){this._inputValue=`/${e.code} `,this._skillMenuOpened=!1,this._skillBrowseOpened=!1,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._searchSkills("")}_handleSkillBrowseClose(){this._skillBrowseOpened=!1}_handleSkillBrowseSearch(e){this._skillBrowseQuery=e.target.value,this._searchSkills(this._skillBrowseQuery)}_handleSkillBrowseTabChange(e){this._skillBrowseSource=e.detail.activeTabId}_openFilePicker(){this._fileInputEl?.click()}_handleFileInputChange(e){const t=e.target;t.files&&this._addFiles(t.files),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")}_addFiles(e){const t=Array.from(e).filter((e=>ii.includes(e.type)));t.length&&t.forEach((e=>{const t={localId:"att-"+this._pendingSeq++,file:e,name:e.name,previewUrl:URL.createObjectURL(e)};this._pendingInternalFiles=[...this._pendingInternalFiles,t]}))}_removePending(e){const t=this._pendingInternalFiles.find((t=>t.localId===e));t&&URL.revokeObjectURL(t.previewUrl),this._pendingInternalFiles=this._pendingInternalFiles.filter((t=>t.localId!==e))}_clearPending(){this._pendingInternalFiles.forEach((e=>URL.revokeObjectURL(e.previewUrl))),this._pendingInternalFiles=[]}_openImage(e){i.open({src:`/api/system/integration/aws/bedrock/conversationImage/${e.internalFileID}/view`,name:e.niceName||"image"})}_canSend(){return Boolean(this._inputValue.trim())||this._pendingInternalFiles.length>0}_handleSubmit(){if(this._isStreaming)return;const e=this._inputValue.trim(),t=this._pendingInternalFiles;if(!e&&!t.length)return;const i=t.map((e=>e.file)),n=new CustomEvent("message-submit",{detail:{message:e,internalFiles:i},bubbles:!0,composed:!0,cancelable:!0});if(this.dispatchEvent(n),n.defaultPrevented)return;const r={type:"user",content:e};this.messages=[...this.messages,r],this._inputValue="",this._error="",this._userHasScrolledUp=!1,this._pendingInternalFiles.forEach((e=>URL.revokeObjectURL(e.previewUrl))),this._pendingInternalFiles=[],this._inputEl&&(this._inputEl.style.height="auto"),this.messages=[...this.messages,{type:"assistant",content:""}],this._isStreaming=!0,this.updateComplete.then((()=>{if(!this._messagesEl)return;this._messagesEl.querySelectorAll(".message--assistant").forEach((e=>{e.style.minHeight=""}));const e=this._messagesEl.querySelectorAll(".message"),t=e[this.messages.length-2],i=e[this.messages.length-1];i&&(i.style.minHeight=this._messagesEl.clientHeight+"px"),t&&(this._messagesEl.scrollTop=t.offsetTop-this._messagesEl.offsetTop-24)})),this.send||(this.send=e=>{if(e.internalFiles.length){const t=new FormData;return t.append("userText",e.message),e.internalFiles.forEach((e=>t.append("images",e))),s.fetch({url:"/api/system/integration/aws/bedrock/stream/invokeModelForConversationWithImages",method:"POST",headers:{Accept:"text/event-stream"},body:t})}return s.fetch({url:"/api/system/integration/aws/bedrock/stream/invokeModelForConversationWithState",method:"POST",headers:{Accept:"text/event-stream"},body:{userText:e.message}})}),this.send({message:e,messages:this.messages.slice(0,-1),internalFiles:i}).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)}))}_handleStop(){this._reader&&(this._reader.cancel(),this._reader=null),this._isStreaming=!1}_handleClear(){this.clear||(this.clear=()=>s.fetch({url:"/api/system/integration/aws/bedrock/clearConversationWithState",method:"POST"})),this.clear().then((()=>{this._reader&&(this._reader.cancel(),this._reader=null),this.messages=[],this._isStreaming=!1,this._error="",this._inputValue="",this._userHasScrolledUp=!1}))}_handleMessagesScroll(e){const t=e.target,i=t.scrollHeight-t.scrollTop-t.clientHeight;this._userHasScrolledUp=i>50}_handleErrorDismiss(){this._error=""}_readStreamChunk(){this._reader&&this._reader.read().then((e=>{if(e.done)return this._isStreaming=!1,void(this._reader=null);this._buffer=this._buffer+this._decoder.decode(e.value,{stream:!0});const t=this._buffer.split("\n\n");this._buffer=t.pop()||"";for(let e=0;e<t.length;e++){if(!t[e].trim())continue;const i=t[e].split("\n");for(let e=0;e<i.length;e++){if(!i[e].startsWith("data:"))continue;const t=i[e].slice(5).trim();if(!t)continue;let s;try{s=JSON.parse(t)}catch{continue}if(this.dispatchEvent(new CustomEvent("stream-event",{detail:s,bubbles:!0,composed:!0})),"REASONING_PART"===s.type){if(s.message){const e=this.messages.length-1;e>=0&&"assistant"===this.messages[e].type&&(this.messages[e].reasoning||(this.messages[e].reasoning=""),this.messages[e].reasoning+=String(s.message),this.requestUpdate())}}else if("RESPONSE_PART"===s.type){if(s.message){const e=this.messages.length-1;e>=0&&"assistant"===this.messages[e].type&&(this.messages[e].content+=String(s.message),this.requestUpdate())}}else"ERROR"===s.type&&this._handleStreamError(String(s.message||"Unknown error"));s.finished&&(this._isStreaming=!1,this._reader=null)}}this._readStreamChunk()})).catch((e=>{"AbortError"!==e.name&&this._handleStreamError(e.message)}))}_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))}}_renderSkillMenu(){const e=this._filteredSkills();return X`
1385
1385
  <div class="skill-menu">
1386
1386
  <div class="skill-menu__actions">
1387
1387
  <button
@@ -1405,7 +1405,7 @@ const{I:Oe}=ae,Ue=()=>document.createComment(""),Le=(e,t,i)=>{const s=e._$AA.par
1405
1405
  class=${we({"skill-menu__item":!0,"skill-menu__item--highlighted":t+2===this._skillHighlighted})}
1406
1406
  @click=${()=>this._handleSkillSelect(e)}
1407
1407
  >
1408
- <span class="skill-menu__name">${e.label}</span>
1408
+ <span class="skill-menu__name">${e.name}</span>
1409
1409
  ${e.description?X`
1410
1410
  <span class="skill-menu__desc">${e.description}</span>
1411
1411
  `:W}
@@ -1413,9 +1413,7 @@ const{I:Oe}=ae,Ue=()=>document.createComment(""),Le=(e,t,i)=>{const s=e._$AA.par
1413
1413
  </li>
1414
1414
  `))}
1415
1415
  </ul>
1416
- `:X`
1417
- <div class="skill-menu__empty">No matching skills</div>
1418
- `}
1416
+ `:W}
1419
1417
  </div>
1420
1418
  `}_renderSkillBrowse(){return X`
1421
1419
  <kr-dialog
@@ -1438,26 +1436,28 @@ const{I:Oe}=ae,Ue=()=>document.createComment(""),Le=(e,t,i)=>{const s=e._$AA.par
1438
1436
  ${this._renderSkillGrid()}
1439
1437
  </kr-tab>
1440
1438
  <kr-tab id="kodaris" label="Kodaris">
1441
- ${this._renderSkillGrid()}
1439
+ <div class="skill-browse__empty">
1440
+ Shared Kodaris skills are coming soon.
1441
+ </div>
1442
1442
  </kr-tab>
1443
1443
  </kr-tab-group>
1444
1444
  </div>
1445
1445
  </kr-dialog>
1446
- `}_renderSkillGrid(){const e=this._browseSkills();return e.length?X`
1446
+ `}_renderSkillGrid(){const e=this._skillResults;return e.length?X`
1447
1447
  <div class="skill-browse__grid">
1448
1448
  ${e.map((e=>X`
1449
1449
  <button
1450
1450
  class="skill-card"
1451
1451
  @click=${()=>this._handleSkillSelect(e)}
1452
1452
  >
1453
- <span class="skill-card__name">${e.label}</span>
1453
+ <span class="skill-card__name">${e.name}</span>
1454
1454
  ${e.description?X`
1455
1455
  <span class="skill-card__desc">${e.description}</span>
1456
1456
  `:W}
1457
1457
  </button>
1458
1458
  `))}
1459
1459
  </div>
1460
- `:X`<div class="skill-browse__empty">No matching skills</div>`}_renderUserContent(e){const t=e.match(/^\/(\S+)(\s[\s\S]*)?$/);return t&&this.skills.some((e=>e.name===t[1]))?X`<span class="message-skill">/${t[1]}</span>${t[2]||""}`:e}render(){return X`
1460
+ `:W}_renderUserContent(e){const t=e.match(/^\/(\S+)(\s[\s\S]*)?$/);return t?X`<span class="message-skill">/${t[1]}</span>${t[2]||""}`:e}render(){return X`
1461
1461
  ${this.hideToggle||"inline"===this.variant?W:X`
1462
1462
  <button
1463
1463
  class=${we({toggle:!0,"toggle--hidden":this.opened})}
@@ -2539,12 +2539,6 @@ const{I:Oe}=ae,Ue=()=>document.createComment(""),Le=(e,t,i)=>{const s=e._$AA.par
2539
2539
  white-space: nowrap;
2540
2540
  }
2541
2541
 
2542
- .skill-menu__empty {
2543
- padding: 16px;
2544
- text-align: center;
2545
- color: #000000;
2546
- }
2547
-
2548
2542
  .skill-menu__actions {
2549
2543
  display: flex;
2550
2544
  flex-direction: column;
@@ -2635,6 +2629,12 @@ const{I:Oe}=ae,Ue=()=>document.createComment(""),Le=(e,t,i)=>{const s=e._$AA.par
2635
2629
  .skill-card__desc {
2636
2630
  font-size: 12px;
2637
2631
  color: #000000;
2632
+ /* Clamp to 3 lines so a long description doesn't make one card tower over
2633
+ its row-mates in the grid. */
2634
+ display: -webkit-box;
2635
+ -webkit-line-clamp: 3;
2636
+ -webkit-box-orient: vertical;
2637
+ overflow: hidden;
2638
2638
  }
2639
2639
 
2640
2640
  .skill-browse__empty {
@@ -2724,5 +2724,5 @@ const{I:Oe}=ae,Ue=()=>document.createComment(""),Le=(e,t,i)=>{const s=e._$AA.par
2724
2724
  height: 32px;
2725
2725
  }
2726
2726
 
2727
- `,ti([ge({attribute:!1})],si.prototype,"send",void 0),ti([ge({attribute:!1})],si.prototype,"clear",void 0),ti([ge({attribute:!1})],si.prototype,"load",void 0),ti([ge({attribute:!1})],si.prototype,"messages",void 0),ti([ge({type:String})],si.prototype,"label",void 0),ti([ge({type:String})],si.prototype,"placeholder",void 0),ti([ge({attribute:!1})],si.prototype,"skills",void 0),ti([ge({type:Boolean,reflect:!0})],si.prototype,"opened",void 0),ti([ge({type:Boolean,attribute:"hide-toggle",reflect:!0})],si.prototype,"hideToggle",void 0),ti([ge({type:String,reflect:!0})],si.prototype,"variant",void 0),ti([fe()],si.prototype,"_inputValue",void 0),ti([fe()],si.prototype,"_isStreaming",void 0),ti([fe()],si.prototype,"_error",void 0),ti([fe()],si.prototype,"_pendingInternalFiles",void 0),ti([fe()],si.prototype,"_isDraggingFile",void 0),ti([fe()],si.prototype,"_skillMenuOpened",void 0),ti([fe()],si.prototype,"_skillQuery",void 0),ti([fe()],si.prototype,"_skillHighlighted",void 0),ti([fe()],si.prototype,"_copiedIndex",void 0),ti([fe()],si.prototype,"_skillBrowseOpened",void 0),ti([fe()],si.prototype,"_skillBrowseSource",void 0),ti([fe()],si.prototype,"_skillBrowseQuery",void 0),ti([me(".panel")],si.prototype,"_panelEl",void 0),ti([me(".messages")],si.prototype,"_messagesEl",void 0),ti([me(".input")],si.prototype,"_inputEl",void 0),ti([me(".file-input")],si.prototype,"_fileInputEl",void 0),ti([me(".input-wrapper")],si.prototype,"_inputWrapperEl",void 0),ti([me(".skill-menu")],si.prototype,"_skillMenuEl",void 0),si=ti([de("kr-chatbot")],si);export{si as KRChatbot,Ne as KRRouter,Pe as KRRouterOutlet,Ee as KRScaffold,Me as KRScreenDetail,ze as KRScreenNav,Te as KRSubbar};
2727
+ `,ti([ge({attribute:!1})],si.prototype,"send",void 0),ti([ge({attribute:!1})],si.prototype,"clear",void 0),ti([ge({attribute:!1})],si.prototype,"load",void 0),ti([ge({attribute:!1})],si.prototype,"messages",void 0),ti([ge({type:String})],si.prototype,"label",void 0),ti([ge({type:String})],si.prototype,"placeholder",void 0),ti([ge({type:Boolean,reflect:!0})],si.prototype,"opened",void 0),ti([ge({type:Boolean,attribute:"hide-toggle",reflect:!0})],si.prototype,"hideToggle",void 0),ti([ge({type:String,reflect:!0})],si.prototype,"variant",void 0),ti([fe()],si.prototype,"_inputValue",void 0),ti([fe()],si.prototype,"_isStreaming",void 0),ti([fe()],si.prototype,"_error",void 0),ti([fe()],si.prototype,"_pendingInternalFiles",void 0),ti([fe()],si.prototype,"_isDraggingFile",void 0),ti([fe()],si.prototype,"_skillMenuOpened",void 0),ti([fe()],si.prototype,"_skillQuery",void 0),ti([fe()],si.prototype,"_skillResults",void 0),ti([fe()],si.prototype,"_skillHighlighted",void 0),ti([fe()],si.prototype,"_copiedIndex",void 0),ti([fe()],si.prototype,"_skillBrowseOpened",void 0),ti([fe()],si.prototype,"_skillBrowseSource",void 0),ti([fe()],si.prototype,"_skillBrowseQuery",void 0),ti([me(".panel")],si.prototype,"_panelEl",void 0),ti([me(".messages")],si.prototype,"_messagesEl",void 0),ti([me(".input")],si.prototype,"_inputEl",void 0),ti([me(".file-input")],si.prototype,"_fileInputEl",void 0),ti([me(".input-wrapper")],si.prototype,"_inputWrapperEl",void 0),ti([me(".skill-menu")],si.prototype,"_skillMenuEl",void 0),si=ti([de("kr-chatbot")],si);export{si as KRChatbot,Ne as KRRouter,Pe as KRRouterOutlet,Ee as KRScaffold,Me as KRScreenDetail,ze as KRScreenNav,Re as KRSubbar};
2728
2728
  //# sourceMappingURL=krubble-app.bundled.min.js.map