| 12 |
- function e(){return e=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},e.apply(this,arguments)}function t(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var n=["input:not([inert])","select:not([inert])","textarea:not([inert])","a[href]:not([inert])","button:not([inert])","[tabindex]:not(slot):not([inert])","audio[controls]:not([inert])","video[controls]:not([inert])",'[contenteditable]:not([contenteditable="false"]):not([inert])',"details>summary:first-of-type:not([inert])","details:not([inert])"],r=/* #__PURE__ */n.join(","),i="undefined"==typeof Element,o=i?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,a=!i&&Element.prototype.getRootNode?function(e){var t;return null==e||null===(t=e.getRootNode)||void 0===t?void 0:t.call(e)}:function(e){return null==e?void 0:e.ownerDocument},s=function e(t,n){var r;void 0===n&&(n=!0);var i=null==t||null===(r=t.getAttribute)||void 0===r?void 0:r.call(t,"inert");return""===i||"true"===i||n&&t&&e(t.parentNode)},l=function(e,t,n){if(s(e))return[];var i=Array.prototype.slice.apply(e.querySelectorAll(r));return t&&o.call(e,r)&&i.unshift(e),i.filter(n)},c=function e(t,n,i){for(var a=[],l=Array.from(t);l.length;){var c=l.shift();if(!s(c,!1))if("SLOT"===c.tagName){var u=c.assignedElements(),h=e(u.length?u:c.children,!0,i);i.flatten?a.push.apply(a,h):a.push({scopeParent:c,candidates:h})}else{o.call(c,r)&&i.filter(c)&&(n||!t.includes(c))&&a.push(c);var d=c.shadowRoot||"function"==typeof i.getShadowRoot&&i.getShadowRoot(c),g=!s(d,!1)&&(!i.shadowRootFilter||i.shadowRootFilter(c));if(d&&g){var f=e(!0===d?c.children:d.children,!0,i);i.flatten?a.push.apply(a,f):a.push({scopeParent:c,candidates:f})}else l.unshift.apply(l,c.children)}}return a},u=function(e){return!isNaN(parseInt(e.getAttribute("tabindex"),10))},h=function(e){if(!e)throw new Error("No node provided");return e.tabIndex<0&&(/^(AUDIO|VIDEO|DETAILS)$/.test(e.tagName)||function(e){var t,n=null==e||null===(t=e.getAttribute)||void 0===t?void 0:t.call(e,"contenteditable");return""===n||"true"===n}(e))&&!u(e)?0:e.tabIndex},d=function(e,t){return e.tabIndex===t.tabIndex?e.documentOrder-t.documentOrder:e.tabIndex-t.tabIndex},g=function(e){return"INPUT"===e.tagName},f=function(e){var t=e.getBoundingClientRect();return 0===t.width&&0===t.height},p=function(e,t){return!(t.disabled||s(t)||function(e){return g(e)&&"hidden"===e.type}(t)||function(e,t){var n=t.displayCheck,r=t.getShadowRoot;if("hidden"===getComputedStyle(e).visibility)return!0;var i=o.call(e,"details>summary:first-of-type");if(o.call(i?e.parentElement:e,"details:not([open]) *"))return!0;if(n&&"full"!==n&&"legacy-full"!==n){if("non-zero-area"===n)return f(e)}else{if("function"==typeof r){for(var s=e;e;){var l=e.parentElement,c=a(e);if(l&&!l.shadowRoot&&!0===r(l))return f(e);e=e.assignedSlot?e.assignedSlot:l||c===e.ownerDocument?l:c.host}e=s}if(function(e){var t,n,r,i,o=e&&a(e),s=null===(t=o)||void 0===t?void 0:t.host,l=!1;if(o&&o!==e)for(l=!!(null!==(n=s)&&void 0!==n&&null!==(r=n.ownerDocument)&&void 0!==r&&r.contains(s)||null!=e&&null!==(i=e.ownerDocument)&&void 0!==i&&i.contains(e));!l&&s;){var c,u,h;l=!(null===(u=s=null===(c=o=a(s))||void 0===c?void 0:c.host)||void 0===u||null===(h=u.ownerDocument)||void 0===h||!h.contains(s))}return l}(e))return!e.getClientRects().length;if("legacy-full"!==n)return!0}return!1}(t,e)||function(e){return"DETAILS"===e.tagName&&Array.prototype.slice.apply(e.children).some(function(e){return"SUMMARY"===e.tagName})}(t)||function(e){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(e.tagName))for(var t=e.parentElement;t;){if("FIELDSET"===t.tagName&&t.disabled){for(var n=0;n<t.children.length;n++){var r=t.children.item(n);if("LEGEND"===r.tagName)return!!o.call(t,"fieldset[disabled] *")||!r.contains(e)}return!0}t=t.parentElement}return!1}(t))},m=function(e,t){return!(function(e){return function(e){return g(e)&&"radio"===e.type}(e)&&!function(e){if(!e.name)return!0;var t,n=e.form||a(e),r=function(e){return n.querySelectorAll('input[type="radio"][name="'+e+'"]')};if("undefined"!=typeof window&&void 0!==window.CSS&&"function"==typeof window.CSS.escape)t=r(window.CSS.escape(e.name));else try{t=r(e.name)}catch(e){return console.error("Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s",e.message),!1}var i=function(e,t){for(var n=0;n<e.length;n++)if(e[n].checked&&e[n].form===t)return e[n]}(t,e.form);return!i||i===e}(e)}(t)||h(t)<0||!p(e,t))},b=function(e){var t=parseInt(e.getAttribute("tabindex"),10);return!!(isNaN(t)||t>=0)},w=function e(t){var n=[],r=[];return t.forEach(function(t,i){var o=!!t.scopeParent,a=o?t.scopeParent:t,s=function(e,t){var n=h(e);return n<0&&t&&!u(e)?0:n}(a,o),l=o?e(t.candidates):a;0===s?o?n.push.apply(n,l):n.push(a):r.push({documentOrder:i,tabIndex:s,item:t,isScope:o,content:l})}),r.sort(d).reduce(function(e,t){return t.isScope?e.push.apply(e,t.content):e.push(t.content),e},[]).concat(n)},v=function(e,t){if(t=t||{},!e)throw new Error("No node provided");return!1!==o.call(e,r)&&m(t,e)},y=/* #__PURE__ */n.concat("iframe").join(","),x=function(e,t){if(t=t||{},!e)throw new Error("No node provided");return!1!==o.call(e,y)&&p(t,e)};function k(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function _(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?k(Object(n),!0).forEach(function(t){var r,i,o;r=e,o=n[t],(i=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:String(t)}(i=t))in r?Object.defineProperty(r,i,{value:o,enumerable:!0,configurable:!0,writable:!0}):r[i]=o}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):k(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var E=function(e){return"Tab"===(null==e?void 0:e.key)||9===(null==e?void 0:e.keyCode)},T=function(e){return E(e)&&!e.shiftKey},R=function(e){return E(e)&&e.shiftKey},S=function(e){return setTimeout(e,0)},C=function(e,t){var n=-1;return e.every(function(e,r){return!t(e)||(n=r,!1)}),n},$=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return"function"==typeof e?e.apply(void 0,n):e},A=function(e){return e.target.shadowRoot&&"function"==typeof e.composedPath?e.composedPath()[0]:e.target},P=[];let z={async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null};function L(e){z=e}const O=/[&<>"']/,I=new RegExp(O.source,"g"),N=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,D=new RegExp(N.source,"g"),F={"&":"&","<":"<",">":">",'"':""","'":"'"},B=e=>F[e];function M(e,t){if(t){if(O.test(e))return e.replace(I,B)}else if(N.test(e))return e.replace(D,B);return e}const j=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/gi;function q(e){return e.replace(j,(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 Z=/(^|[^\[])\^/g;function H(e,t){let n="string"==typeof e?e:e.source;t=t||"";const r={replace:(e,t)=>{let i="string"==typeof t?t:t.source;return i=i.replace(Z,"$1"),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}function G(e){try{e=encodeURI(e).replace(/%25/g,"%")}catch(e){return null}return e}const V={exec:()=>null};function W(e,t){const n=e.replace(/\|/g,(e,t,n)=>{let r=!1,i=t;for(;--i>=0&&"\\"===n[i];)r=!r;return r?"|":" |"}).split(/ \|/);let r=0;if(n[0].trim()||n.shift(),n.length>0&&!n[n.length-1].trim()&&n.pop(),t)if(n.length>t)n.splice(t);else for(;n.length<t;)n.push("");for(;r<n.length;r++)n[r]=n[r].trim().replace(/\\\|/g,"|");return n}function Q(e,t,n){const r=e.length;if(0===r)return"";let i=0;for(;i<r;){const o=e.charAt(r-i-1);if(o!==t||n){if(o===t||!n)break;i++}else i++}return e.slice(0,r-i)}function K(e,t,n,r){const i=t.href,o=t.title?M(t.title):null,a=e[1].replace(/\\([\[\]])/g,"$1");if("!"!==e[0].charAt(0)){r.state.inLink=!0;const e={type:"link",raw:n,href:i,title:o,text:a,tokens:r.inlineTokens(a)};return r.state.inLink=!1,e}return{type:"image",raw:n,href:i,title:o,text:M(a)}}class U{options;rules;lexer;constructor(e){this.options=e||z}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:Q(e,"\n")}}}fences(e){const t=this.rules.block.fences.exec(e);if(t){const e=t[0],n=function(e,t){const n=e.match(/^(\s+)(?:```)/);if(null===n)return t;const r=n[1];return t.split("\n").map(e=>{const t=e.match(/^\s+/);if(null===t)return e;const[n]=t;return n.length>=r.length?e.slice(r.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:n}}}heading(e){const t=this.rules.block.heading.exec(e);if(t){let e=t[2].trim();if(/#$/.test(e)){const t=Q(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){const e=Q(t[0].replace(/^ *>[ \t]?/gm,""),"\n"),n=this.lexer.state.top;this.lexer.state.top=!0;const r=this.lexer.blockTokens(e);return this.lexer.state.top=n,{type:"blockquote",raw:t[0],tokens:r,text:e}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim();const r=n.length>1,i={type:"list",raw:"",ordered:r,start:r?+n.slice(0,-1):"",loose:!1,items:[]};n=r?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=r?n:"[*+-]");const o=new RegExp(`^( {0,3}${n})((?:[\t ][^\\n]*)?(?:\\n|$))`);let a="",s="",l=!1;for(;e;){let n=!1;if(!(t=o.exec(e)))break;if(this.rules.block.hr.test(e))break;a=t[0],e=e.substring(a.length);let r=t[2].split("\n",1)[0].replace(/^\t+/,e=>" ".repeat(3*e.length)),c=e.split("\n",1)[0],u=0;this.options.pedantic?(u=2,s=r.trimStart()):(u=t[2].search(/[^ ]/),u=u>4?1:u,s=r.slice(u),u+=t[1].length);let h=!1;if(!r&&/^ *$/.test(c)&&(a+=c+"\n",e=e.substring(c.length+1),n=!0),!n){const t=new RegExp(`^ {0,${Math.min(3,u-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ \t][^\\n]*)?(?:\\n|$))`),n=new RegExp(`^ {0,${Math.min(3,u-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),i=new RegExp(`^ {0,${Math.min(3,u-1)}}(?:\`\`\`|~~~)`),o=new RegExp(`^ {0,${Math.min(3,u-1)}}#`);for(;e;){const l=e.split("\n",1)[0];if(c=l,this.options.pedantic&&(c=c.replace(/^ {1,4}(?=( {4})*[^ ])/g," ")),i.test(c))break;if(o.test(c))break;if(t.test(c))break;if(n.test(e))break;if(c.search(/[^ ]/)>=u||!c.trim())s+="\n"+c.slice(u);else{if(h)break;if(r.search(/[^ ]/)>=4)break;if(i.test(r))break;if(o.test(r))break;if(n.test(r))break;s+="\n"+c}h||c.trim()||(h=!0),a+=l+"\n",e=e.substring(l.length+1),r=c.slice(u)}}i.loose||(l?i.loose=!0:/\n *\n *$/.test(a)&&(l=!0));let d,g=null;this.options.gfm&&(g=/^\[[ xX]\] /.exec(s),g&&(d="[ ] "!==g[0],s=s.replace(/^\[[ xX]\] +/,""))),i.items.push({type:"list_item",raw:a,task:!!g,checked:d,loose:!1,text:s,tokens:[]}),i.raw+=a}i.items[i.items.length-1].raw=a.trimEnd(),i.items[i.items.length-1].text=s.trimEnd(),i.raw=i.raw.trimEnd();for(let e=0;e<i.items.length;e++)if(this.lexer.state.top=!1,i.items[e].tokens=this.lexer.blockTokens(i.items[e].text,[]),!i.loose){const t=i.items[e].tokens.filter(e=>"space"===e.type),n=t.length>0&&t.some(e=>/\n.*\n/.test(e.raw));i.loose=n}if(i.loose)for(let e=0;e<i.items.length;e++)i.items[e].loose=!0;return i}}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," "),n=t[2]?t[2].replace(/^<(.*)>$/,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",r=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:n,title:r}}}table(e){const t=this.rules.block.table.exec(e);if(!t)return;if(!/[:|]/.test(t[2]))return;const n=W(t[1]),r=t[2].replace(/^\||\| *$/g,"").split("|"),i=t[3]&&t[3].trim()?t[3].replace(/\n[ \t]*$/,"").split("\n"):[],o={type:"table",raw:t[0],header:[],align:[],rows:[]};if(n.length===r.length){for(const e of r)/^ *-+: *$/.test(e)?o.align.push("right"):/^ *:-+: *$/.test(e)?o.align.push("center"):/^ *:-+ *$/.test(e)?o.align.push("left"):o.align.push(null);for(const e of n)o.header.push({text:e,tokens:this.lexer.inline(e)});for(const e of i)o.rows.push(W(e,o.header.length).map(e=>({text:e,tokens:this.lexer.inline(e)})));return o}}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:M(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=Q(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 n=0;for(let r=0;r<e.length;r++)if("\\"===e[r])r++;else if(e[r]===t[0])n++;else if(e[r]===t[1]&&(n--,n<0))return r;return-1}(t[2],"()");if(e>-1){const n=(0===t[0].indexOf("!")?5:4)+t[1].length+e;t[2]=t[2].substring(0,e),t[0]=t[0].substring(0,n).trim(),t[3]=""}}let n=t[2],r="";if(this.options.pedantic){const e=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(n);e&&(n=e[1],r=e[3])}else r=t[3]?t[3].slice(1,-1):"";return n=n.trim(),/^</.test(n)&&(n=this.options.pedantic&&!/>$/.test(e)?n.slice(1):n.slice(1,-1)),K(t,{href:n?n.replace(this.rules.inline.anyPunctuation,"$1"):n,title:r?r.replace(this.rules.inline.anyPunctuation,"$1"):r},t[0],this.lexer)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){const e=t[(n[2]||n[1]).replace(/\s+/g," ").toLowerCase()];if(!e){const e=n[0].charAt(0);return{type:"text",raw:e,text:e}}return K(n,e,n[0],this.lexer)}}emStrong(e,t,n=""){let r=this.rules.inline.emStrongLDelim.exec(e);if(r&&(!r[3]||!n.match(/[\p{L}\p{N}]/u))&&(!r[1]&&!r[2]||!n||this.rules.inline.punctuation.exec(n))){const n=[...r[0]].length-1;let i,o,a=n,s=0;const l="*"===r[0][0]?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(l.lastIndex=0,t=t.slice(-1*e.length+n);null!=(r=l.exec(t));){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i)continue;if(o=[...i].length,r[3]||r[4]){a+=o;continue}if((r[5]||r[6])&&n%3&&!((n+o)%3)){s+=o;continue}if(a-=o,a>0)continue;o=Math.min(o,o+a+s);const t=[...r[0]][0].length,l=e.slice(0,n+r.index+t+o);if(Math.min(n,o)%2){const e=l.slice(1,-1);return{type:"em",raw:l,text:e,tokens:this.lexer.inlineTokens(e)}}const c=l.slice(2,-2);return{type:"strong",raw:l,text:c,tokens:this.lexer.inlineTokens(c)}}}}codespan(e){const t=this.rules.inline.code.exec(e);if(t){let e=t[2].replace(/\n/g," ");const n=/[^ ]/.test(e),r=/^ /.test(e)&&/ $/.test(e);return n&&r&&(e=e.substring(1,e.length-1)),e=M(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,n;return"@"===t[2]?(e=M(t[1]),n="mailto:"+e):(e=M(t[1]),n=e),{type:"link",raw:t[0],text:e,href:n,tokens:[{type:"text",raw:e,text:e}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let e,n;if("@"===t[2])e=M(t[0]),n="mailto:"+e;else{let r;do{r=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??""}while(r!==t[0]);e=M(t[0]),n="www."===t[1]?"http://"+t[0]:t[0]}return{type:"link",raw:t[0],text:e,href:n,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]:M(t[0]),{type:"text",raw:t[0],text:e}}}}const Y=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,X=/(?:[*+-]|\d{1,9}[.)])/,J=H(/^(?!bull )((?:.|\n(?!\s*?\n|bull ))+?)\n {0,3}(=+|-+) *(?:\n+|$)/).replace(/bull/g,X).getRegex(),ee=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,te=/(?!\s*\])(?:\\.|[^\[\]\\])+/,ne=H(/^ {0,3}\[(label)\]: *(?:\n *)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/).replace("label",te).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),re=H(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,X).getRegex(),ie="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",oe=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,ae=H("^ {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",oe).replace("tag",ie).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),se=H(ee).replace("hr",Y).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",ie).getRegex(),le={blockquote:H(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",se).getRegex(),code:/^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/,def:ne,fences:/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,heading:/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,hr:Y,html:ae,lheading:J,list:re,newline:/^(?: *(?:\n|$))+/,paragraph:se,table:V,text:/^[^\n]+/},ce=H("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Y).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",ie).getRegex(),ue={...le,table:ce,paragraph:H(ee).replace("hr",Y).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",ce).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",ie).getRegex()},he={...le,html:H("^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:\"[^\"]*\"|'[^']*'|\\s[^'\"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))").replace("comment",oe).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:V,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:H(ee).replace("hr",Y).replace("heading"," *#{1,6} *[^\n]").replace("lheading",J).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},de=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,ge=/^( {2,}|\\)\n(?!\s*$)/,fe="\\p{P}\\p{S}",pe=H(/^((?![*_])[\spunctuation])/,"u").replace(/punctuation/g,fe).getRegex(),me=H(/^(?:\*+(?:((?!\*)[punct])|[^\s*]))|^_+(?:((?!_)[punct])|([^\s_]))/,"u").replace(/punct/g,fe).getRegex(),be=H("^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)[punct](\\*+)(?=[\\s]|$)|[^punct\\s](\\*+)(?!\\*)(?=[punct\\s]|$)|(?!\\*)[punct\\s](\\*+)(?=[^punct\\s])|[\\s](\\*+)(?!\\*)(?=[punct])|(?!\\*)[punct](\\*+)(?!\\*)(?=[punct])|[^punct\\s](\\*+)(?=[^punct\\s])","gu").replace(/punct/g,fe).getRegex(),we=H("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)[punct](_+)(?=[\\s]|$)|[^punct\\s](_+)(?!_)(?=[punct\\s]|$)|(?!_)[punct\\s](_+)(?=[^punct\\s])|[\\s](_+)(?!_)(?=[punct])|(?!_)[punct](_+)(?!_)(?=[punct])","gu").replace(/punct/g,fe).getRegex(),ve=H(/\\([punct])/,"gu").replace(/punct/g,fe).getRegex(),ye=H(/^<(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(),xe=H(oe).replace("(?:--\x3e|$)","--\x3e").getRegex(),ke=H("^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",xe).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),_e=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,Ee=H(/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/).replace("label",_e).replace("href",/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Te=H(/^!?\[(label)\]\[(ref)\]/).replace("label",_e).replace("ref",te).getRegex(),Re=H(/^!?\[(ref)\](?:\[\])?/).replace("ref",te).getRegex(),Se={_backpedal:V,anyPunctuation:ve,autolink:ye,blockSkip:/\[[^[\]]*?\]\([^\(\)]*?\)|`[^`]*?`|<[^<>]*?>/g,br:ge,code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,del:V,emStrongLDelim:me,emStrongRDelimAst:be,emStrongRDelimUnd:we,escape:de,link:Ee,nolink:Re,punctuation:pe,reflink:Te,reflinkSearch:H("reflink|nolink(?!\\()","g").replace("reflink",Te).replace("nolink",Re).getRegex(),tag:ke,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,url:V},Ce={...Se,link:H(/^!?\[(label)\]\((.*?)\)/).replace("label",_e).getRegex(),reflink:H(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",_e).getRegex()},$e={...Se,escape:H(de).replace("])","~|])").getRegex(),url:H(/^((?: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.!#$%&'*+\/=?_`{\|}~-]+@)))/},Ae={...$e,br:H(ge).replace("{2,}","*").getRegex(),text:H($e.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Pe={normal:le,gfm:ue,pedantic:he},ze={normal:Se,gfm:$e,breaks:Ae,pedantic:Ce};class Le{tokens;options;state;tokenizer;inlineQueue;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||z,this.options.tokenizer=this.options.tokenizer||new U,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:Pe.normal,inline:ze.normal};this.options.pedantic?(t.block=Pe.pedantic,t.inline=ze.pedantic):this.options.gfm&&(t.block=Pe.gfm,t.inline=this.options.breaks?ze.breaks:ze.gfm),this.tokenizer.rules=t}static get rules(){return{block:Pe,inline:ze}}static lex(e,t){return new Le(t).lex(e)}static lexInline(e,t){return new Le(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 n,r,i,o;for(e=this.options.pedantic?e.replace(/\t/g," ").replace(/^ +$/gm,""):e.replace(/^( *)(\t+)/gm,(e,t,n)=>t+" ".repeat(n.length));e;)if(!(this.options.extensions&&this.options.extensions.block&&this.options.extensions.block.some(r=>!!(n=r.call({lexer:this},e,t))&&(e=e.substring(n.raw.length),t.push(n),!0))))if(n=this.tokenizer.space(e))e=e.substring(n.raw.length),1===n.raw.length&&t.length>0?t[t.length-1].raw+="\n":t.push(n);else if(n=this.tokenizer.code(e))e=e.substring(n.raw.length),r=t[t.length-1],!r||"paragraph"!==r.type&&"text"!==r.type?t.push(n):(r.raw+="\n"+n.raw,r.text+="\n"+n.text,this.inlineQueue[this.inlineQueue.length-1].src=r.text);else if(n=this.tokenizer.fences(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.heading(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.hr(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.blockquote(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.list(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.html(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.def(e))e=e.substring(n.raw.length),r=t[t.length-1],!r||"paragraph"!==r.type&&"text"!==r.type?this.tokens.links[n.tag]||(this.tokens.links[n.tag]={href:n.href,title:n.title}):(r.raw+="\n"+n.raw,r.text+="\n"+n.raw,this.inlineQueue[this.inlineQueue.length-1].src=r.text);else if(n=this.tokenizer.table(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.lheading(e))e=e.substring(n.raw.length),t.push(n);else{if(i=e,this.options.extensions&&this.options.extensions.startBlock){let t=Infinity;const n=e.slice(1);let r;this.options.extensions.startBlock.forEach(e=>{r=e.call({lexer:this},n),"number"==typeof r&&r>=0&&(t=Math.min(t,r))}),t<Infinity&&t>=0&&(i=e.substring(0,t+1))}if(this.state.top&&(n=this.tokenizer.paragraph(i)))r=t[t.length-1],o&&"paragraph"===r.type?(r.raw+="\n"+n.raw,r.text+="\n"+n.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=r.text):t.push(n),o=i.length!==e.length,e=e.substring(n.raw.length);else if(n=this.tokenizer.text(e))e=e.substring(n.raw.length),r=t[t.length-1],r&&"text"===r.type?(r.raw+="\n"+n.raw,r.text+="\n"+n.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=r.text):t.push(n);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 n,r,i,o,a,s,l=e;if(this.tokens.links){const e=Object.keys(this.tokens.links);if(e.length>0)for(;null!=(o=this.tokenizer.rules.inline.reflinkSearch.exec(l));)e.includes(o[0].slice(o[0].lastIndexOf("[")+1,-1))&&(l=l.slice(0,o.index)+"["+"a".repeat(o[0].length-2)+"]"+l.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;null!=(o=this.tokenizer.rules.inline.blockSkip.exec(l));)l=l.slice(0,o.index)+"["+"a".repeat(o[0].length-2)+"]"+l.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;null!=(o=this.tokenizer.rules.inline.anyPunctuation.exec(l));)l=l.slice(0,o.index)+"++"+l.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;e;)if(a||(s=""),a=!1,!(this.options.extensions&&this.options.extensions.inline&&this.options.extensions.inline.some(r=>!!(n=r.call({lexer:this},e,t))&&(e=e.substring(n.raw.length),t.push(n),!0))))if(n=this.tokenizer.escape(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.tag(e))e=e.substring(n.raw.length),r=t[t.length-1],r&&"text"===n.type&&"text"===r.type?(r.raw+=n.raw,r.text+=n.text):t.push(n);else if(n=this.tokenizer.link(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.reflink(e,this.tokens.links))e=e.substring(n.raw.length),r=t[t.length-1],r&&"text"===n.type&&"text"===r.type?(r.raw+=n.raw,r.text+=n.text):t.push(n);else if(n=this.tokenizer.emStrong(e,l,s))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.codespan(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.br(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.del(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.autolink(e))e=e.substring(n.raw.length),t.push(n);else if(this.state.inLink||!(n=this.tokenizer.url(e))){if(i=e,this.options.extensions&&this.options.extensions.startInline){let t=Infinity;const n=e.slice(1);let r;this.options.extensions.startInline.forEach(e=>{r=e.call({lexer:this},n),"number"==typeof r&&r>=0&&(t=Math.min(t,r))}),t<Infinity&&t>=0&&(i=e.substring(0,t+1))}if(n=this.tokenizer.inlineText(i))e=e.substring(n.raw.length),"_"!==n.raw.slice(-1)&&(s=n.raw.slice(-1)),a=!0,r=t[t.length-1],r&&"text"===r.type?(r.raw+=n.raw,r.text+=n.text):t.push(n);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(n.raw.length),t.push(n);return t}}class Oe{options;constructor(e){this.options=e||z}code(e,t,n){const r=(t||"").match(/^\S*/)?.[0];return e=e.replace(/\n$/,"")+"\n",r?'<pre><code class="language-'+M(r)+'">'+(n?e:M(e,!0))+"</code></pre>\n":"<pre><code>"+(n?e:M(e,!0))+"</code></pre>\n"}blockquote(e){return`<blockquote>\n${e}</blockquote>\n`}html(e,t){return e}heading(e,t,n){return`<h${t}>${e}</h${t}>\n`}hr(){return"<hr>\n"}list(e,t,n){const r=t?"ol":"ul";return"<"+r+(t&&1!==n?' start="'+n+'"':"")+">\n"+e+"</"+r+">\n"}listitem(e,t,n){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 n=t.header?"th":"td";return(t.align?`<${n} align="${t.align}">`:`<${n}>`)+e+`</${n}>\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,n){const r=G(e);if(null===r)return n;let i='<a href="'+(e=r)+'"';return t&&(i+=' title="'+t+'"'),i+=">"+n+"</a>",i}image(e,t,n){const r=G(e);if(null===r)return n;let i=`<img src="${e=r}" alt="${n}"`;return t&&(i+=` title="${t}"`),i+=">",i}text(e){return e}}class Ie{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,n){return""+n}image(e,t,n){return""+n}br(){return""}}class Ne{options;renderer;textRenderer;constructor(e){this.options=e||z,this.options.renderer=this.options.renderer||new Oe,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new Ie}static parse(e,t){return new Ne(t).parse(e)}static parseInline(e,t){return new Ne(t).parseInline(e)}parse(e,t=!0){let n="";for(let r=0;r<e.length;r++){const i=e[r];if(this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[i.type]){const e=i,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)){n+=t||"";continue}}switch(i.type){case"space":continue;case"hr":n+=this.renderer.hr();continue;case"heading":{const e=i;n+=this.renderer.heading(this.parseInline(e.tokens),e.depth,q(this.parseInline(e.tokens,this.textRenderer)));continue}case"code":n+=this.renderer.code(i.text,i.lang,!!i.escaped);continue;case"table":{const e=i;let t="",r="";for(let t=0;t<e.header.length;t++)r+=this.renderer.tablecell(this.parseInline(e.header[t].tokens),{header:!0,align:e.align[t]});t+=this.renderer.tablerow(r);let o="";for(let t=0;t<e.rows.length;t++){const n=e.rows[t];r="";for(let t=0;t<n.length;t++)r+=this.renderer.tablecell(this.parseInline(n[t].tokens),{header:!1,align:e.align[t]});o+=this.renderer.tablerow(r)}n+=this.renderer.table(t,o);continue}case"blockquote":{const e=this.parse(i.tokens);n+=this.renderer.blockquote(e);continue}case"list":{const e=i,t=e.ordered,r=e.start,o=e.loose;let a="";for(let t=0;t<e.items.length;t++){const n=e.items[t],r=n.checked,i=n.task;let s="";if(n.task){const e=this.renderer.checkbox(!!r);o?n.tokens.length>0&&"paragraph"===n.tokens[0].type?(n.tokens[0].text=e+" "+n.tokens[0].text,n.tokens[0].tokens&&n.tokens[0].tokens.length>0&&"text"===n.tokens[0].tokens[0].type&&(n.tokens[0].tokens[0].text=e+" "+n.tokens[0].tokens[0].text)):n.tokens.unshift({type:"text",text:e+" "}):s+=e+" "}s+=this.parse(n.tokens,o),a+=this.renderer.listitem(s,i,!!r)}n+=this.renderer.list(a,t,r);continue}case"html":n+=this.renderer.html(i.text,i.block);continue;case"paragraph":n+=this.renderer.paragraph(this.parseInline(i.tokens));continue;case"text":{let o=i,a=o.tokens?this.parseInline(o.tokens):o.text;for(;r+1<e.length&&"text"===e[r+1].type;)o=e[++r],a+="\n"+(o.tokens?this.parseInline(o.tokens):o.text);n+=t?this.renderer.paragraph(a):a;continue}default:{const e='Token with "'+i.type+'" type was not found.';if(this.options.silent)return console.error(e),"";throw new Error(e)}}}return n}parseInline(e,t){t=t||this.renderer;let n="";for(let r=0;r<e.length;r++){const i=e[r];if(this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[i.type]){const e=this.options.extensions.renderers[i.type].call({parser:this},i);if(!1!==e||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(i.type)){n+=e||"";continue}}switch(i.type){case"escape":case"text":n+=t.text(i.text);break;case"html":n+=t.html(i.text);break;case"link":n+=t.link(i.href,i.title,this.parseInline(i.tokens,t));break;case"image":n+=t.image(i.href,i.title,i.text);break;case"strong":n+=t.strong(this.parseInline(i.tokens,t));break;case"em":n+=t.em(this.parseInline(i.tokens,t));break;case"codespan":n+=t.codespan(i.text);break;case"br":n+=t.br();break;case"del":n+=t.del(this.parseInline(i.tokens,t));break;default:{const e='Token with "'+i.type+'" type was not found.';if(this.options.silent)return console.error(e),"";throw new Error(e)}}}return n}}class De{options;constructor(e){this.options=e||z}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}}const Fe=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(Le.lex,Ne.parse);parseInline=this.#e(Le.lexInline,Ne.parseInline);Parser=Ne;Renderer=Oe;TextRenderer=Ie;Lexer=Le;Tokenizer=U;Hooks=De;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(const r of e)switch(n=n.concat(t.call(this,r)),r.type){case"table":{const e=r;for(const r of e.header)n=n.concat(this.walkTokens(r.tokens,t));for(const r of e.rows)for(const e of r)n=n.concat(this.walkTokens(e.tokens,t));break}case"list":n=n.concat(this.walkTokens(r.items,t));break;default:{const e=r;this.defaults.extensions?.childTokens?.[e.type]?this.defaults.extensions.childTokens[e.type].forEach(r=>{const i=e[r].flat(Infinity);n=n.concat(this.walkTokens(i,t))}):e.tokens&&(n=n.concat(this.walkTokens(e.tokens,t)))}}return n}use(...e){const t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(e=>{const n={...e};if(n.async=this.defaults.async||n.async||!1,e.extensions&&(e.extensions.forEach(e=>{if(!e.name)throw new Error("extension name required");if("renderer"in e){const n=t.renderers[e.name];t.renderers[e.name]=n?function(...t){let r=e.renderer.apply(this,t);return!1===r&&(r=n.apply(this,t)),r}: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 n=t[e.level];n?n.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)}),n.extensions=t),e.renderer){const t=this.defaults.renderer||new Oe(this.defaults);for(const n in e.renderer){if(!(n in t))throw new Error(`renderer '${n}' does not exist`);if("options"===n)continue;const r=e.renderer[n],i=t[n];t[n]=(...e)=>{let n=r.apply(t,e);return!1===n&&(n=i.apply(t,e)),n||""}}n.renderer=t}if(e.tokenizer){const t=this.defaults.tokenizer||new U(this.defaults);for(const n in e.tokenizer){if(!(n in t))throw new Error(`tokenizer '${n}' does not exist`);if(["options","rules","lexer"].includes(n))continue;const r=e.tokenizer[n],i=t[n];t[n]=(...e)=>{let n=r.apply(t,e);return!1===n&&(n=i.apply(t,e)),n}}n.tokenizer=t}if(e.hooks){const t=this.defaults.hooks||new De;for(const n in e.hooks){if(!(n in t))throw new Error(`hook '${n}' does not exist`);if("options"===n)continue;const r=e.hooks[n],i=t[n];t[n]=De.passThroughHooks.has(n)?e=>{if(this.defaults.async)return Promise.resolve(r.call(t,e)).then(e=>i.call(t,e));const n=r.call(t,e);return i.call(t,n)}:(...e)=>{let n=r.apply(t,e);return!1===n&&(n=i.apply(t,e)),n}}n.hooks=t}if(e.walkTokens){const t=this.defaults.walkTokens,r=e.walkTokens;n.walkTokens=function(e){let n=[];return n.push(r.call(this,e)),t&&(n=n.concat(t.call(this,e))),n}}this.defaults={...this.defaults,...n}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return Le.lex(e,t??this.defaults)}parser(e,t){return Ne.parse(e,t??this.defaults)}#e(e,t){return(n,r)=>{const i={...r},o={...this.defaults,...i};!0===this.defaults.async&&!1===i.async&&(o.silent||console.warn("marked(): The async option was set to true by an extension. The async: false option sent to parse will be ignored."),o.async=!0);const a=this.#t(!!o.silent,!!o.async);if(null==n)return a(new Error("marked(): input parameter is undefined or null"));if("string"!=typeof n)return a(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(n)+", string expected"));if(o.hooks&&(o.hooks.options=o),o.async)return Promise.resolve(o.hooks?o.hooks.preprocess(n):n).then(t=>e(t,o)).then(e=>o.hooks?o.hooks.processAllTokens(e):e).then(e=>o.walkTokens?Promise.all(this.walkTokens(e,o.walkTokens)).then(()=>e):e).then(e=>t(e,o)).then(e=>o.hooks?o.hooks.postprocess(e):e).catch(a);try{o.hooks&&(n=o.hooks.preprocess(n));let r=e(n,o);o.hooks&&(r=o.hooks.processAllTokens(r)),o.walkTokens&&this.walkTokens(r,o.walkTokens);let i=t(r,o);return o.hooks&&(i=o.hooks.postprocess(i)),i}catch(e){return a(e)}}}#t(e,t){return n=>{if(n.message+="\nPlease report this to https://github.com/markedjs/marked.",e){const e="<p>An error occurred:</p><pre>"+M(n.message+"",!0)+"</pre>";return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}};function Be(e,t){return Fe.parse(e,t)}Be.options=Be.setOptions=function(e){return Fe.setOptions(e),L(Be.defaults=Fe.defaults),Be},Be.getDefaults=function(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}},Be.defaults=z,Be.use=function(...e){return Fe.use(...e),L(Be.defaults=Fe.defaults),Be},Be.walkTokens=function(e,t){return Fe.walkTokens(e,t)},Be.parseInline=Fe.parseInline,Be.Parser=Ne,Be.parser=Ne.parse,Be.Renderer=Oe,Be.TextRenderer=Ie,Be.Lexer=Le,Be.lexer=Le.lex,Be.Tokenizer=U,Be.Hooks=De,Be.parse=Be;const Me=Math.min,je=Math.max,qe=Math.round,Ze=Math.floor,He=e=>({x:e,y:e}),Ge={left:"right",right:"left",bottom:"top",top:"bottom"},Ve={start:"end",end:"start"};function We(e,t,n){return je(e,Me(t,n))}function Qe(e,t){return"function"==typeof e?e(t):e}function Ke(e){return e.split("-")[0]}function Ue(e){return e.split("-")[1]}function Ye(e){return"x"===e?"y":"x"}function Xe(e){return"y"===e?"height":"width"}function Je(e){return["top","bottom"].includes(Ke(e))?"y":"x"}function et(e){return Ye(Je(e))}function tt(e){return e.replace(/start|end/g,e=>Ve[e])}function nt(e){return e.replace(/left|right|bottom|top/g,e=>Ge[e])}function rt(e){return{...e,top:e.y,left:e.x,right:e.x+e.width,bottom:e.y+e.height}}function it(e,t,n){let{reference:r,floating:i}=e;const o=Je(t),a=et(t),s=Xe(a),l=Ke(t),c="y"===o,u=r.x+r.width/2-i.width/2,h=r.y+r.height/2-i.height/2,d=r[s]/2-i[s]/2;let g;switch(l){case"top":g={x:u,y:r.y-i.height};break;case"bottom":g={x:u,y:r.y+r.height};break;case"right":g={x:r.x+r.width,y:h};break;case"left":g={x:r.x-i.width,y:h};break;default:g={x:r.x,y:r.y}}switch(Ue(t)){case"start":g[a]-=d*(n&&c?-1:1);break;case"end":g[a]+=d*(n&&c?-1:1)}return g}async function ot(e,t){var n;void 0===t&&(t={});const{x:r,y:i,platform:o,rects:a,elements:s,strategy:l}=e,{boundary:c="clippingAncestors",rootBoundary:u="viewport",elementContext:h="floating",altBoundary:d=!1,padding:g=0}=Qe(t,e),f=function(e){return"number"!=typeof e?function(e){return{top:0,right:0,bottom:0,left:0,...e}}(e):{top:e,right:e,bottom:e,left:e}}(g),p=s[d?"floating"===h?"reference":"floating":h],m=rt(await o.getClippingRect({element:null==(n=await(null==o.isElement?void 0:o.isElement(p)))||n?p:p.contextElement||await(null==o.getDocumentElement?void 0:o.getDocumentElement(s.floating)),boundary:c,rootBoundary:u,strategy:l})),b="floating"===h?{...a.floating,x:r,y:i}:a.reference,w=await(null==o.getOffsetParent?void 0:o.getOffsetParent(s.floating)),v=await(null==o.isElement?void 0:o.isElement(w))&&await(null==o.getScale?void 0:o.getScale(w))||{x:1,y:1},y=rt(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:s,rect:b,offsetParent:w,strategy:l}):b);return{top:(m.top-y.top+f.top)/v.y,bottom:(y.bottom-m.bottom+f.bottom)/v.y,left:(m.left-y.left+f.left)/v.x,right:(y.right-m.right+f.right)/v.x}}function at(e){return ct(e)?(e.nodeName||"").toLowerCase():"#document"}function st(e){var t;return(null==e||null==(t=e.ownerDocument)?void 0:t.defaultView)||window}function lt(e){var t;return null==(t=(ct(e)?e.ownerDocument:e.document)||window.document)?void 0:t.documentElement}function ct(e){return e instanceof Node||e instanceof st(e).Node}function ut(e){return e instanceof Element||e instanceof st(e).Element}function ht(e){return e instanceof HTMLElement||e instanceof st(e).HTMLElement}function dt(e){return"undefined"!=typeof ShadowRoot&&(e instanceof ShadowRoot||e instanceof st(e).ShadowRoot)}function gt(e){const{overflow:t,overflowX:n,overflowY:r,display:i}=wt(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!["inline","contents"].includes(i)}function ft(e){return["table","td","th"].includes(at(e))}function pt(e){const t=mt(),n=wt(e);return"none"!==n.transform||"none"!==n.perspective||!!n.containerType&&"normal"!==n.containerType||!t&&!!n.backdropFilter&&"none"!==n.backdropFilter||!t&&!!n.filter&&"none"!==n.filter||["transform","perspective","filter"].some(e=>(n.willChange||"").includes(e))||["paint","layout","strict","content"].some(e=>(n.contain||"").includes(e))}function mt(){return!("undefined"==typeof CSS||!CSS.supports)&&CSS.supports("-webkit-backdrop-filter","none")}function bt(e){return["html","body","#document"].includes(at(e))}function wt(e){return st(e).getComputedStyle(e)}function vt(e){return ut(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.pageXOffset,scrollTop:e.pageYOffset}}function yt(e){if("html"===at(e))return e;const t=e.assignedSlot||e.parentNode||dt(e)&&e.host||lt(e);return dt(t)?t.host:t}function xt(e){const t=yt(e);return bt(t)?e.ownerDocument?e.ownerDocument.body:e.body:ht(t)&>(t)?t:xt(t)}function kt(e,t,n){var r;void 0===t&&(t=[]),void 0===n&&(n=!0);const i=xt(e),o=i===(null==(r=e.ownerDocument)?void 0:r.body),a=st(i);return o?t.concat(a,a.visualViewport||[],gt(i)?i:[],a.frameElement&&n?kt(a.frameElement):[]):t.concat(i,kt(i,[],n))}function _t(e){const t=wt(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const i=ht(e),o=i?e.offsetWidth:n,a=i?e.offsetHeight:r,s=qe(n)!==o||qe(r)!==a;return s&&(n=o,r=a),{width:n,height:r,$:s}}function Et(e){return ut(e)?e:e.contextElement}function Tt(e){const t=Et(e);if(!ht(t))return He(1);const n=t.getBoundingClientRect(),{width:r,height:i,$:o}=_t(t);let a=(o?qe(n.width):n.width)/r,s=(o?qe(n.height):n.height)/i;return a&&Number.isFinite(a)||(a=1),s&&Number.isFinite(s)||(s=1),{x:a,y:s}}const Rt=/*#__PURE__*/He(0);function St(e){const t=st(e);return mt()&&t.visualViewport?{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}:Rt}function Ct(e,t,n,r){void 0===t&&(t=!1),void 0===n&&(n=!1);const i=e.getBoundingClientRect(),o=Et(e);let a=He(1);t&&(r?ut(r)&&(a=Tt(r)):a=Tt(e));const s=function(e,t,n){return void 0===t&&(t=!1),!(!n||t&&n!==st(e))&&t}(o,n,r)?St(o):He(0);let l=(i.left+s.x)/a.x,c=(i.top+s.y)/a.y,u=i.width/a.x,h=i.height/a.y;if(o){const e=st(o),t=r&&ut(r)?st(r):r;let n=e,i=n.frameElement;for(;i&&r&&t!==n;){const e=Tt(i),t=i.getBoundingClientRect(),r=wt(i),o=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,a=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;l*=e.x,c*=e.y,u*=e.x,h*=e.y,l+=o,c+=a,n=st(i),i=n.frameElement}}return rt({width:u,height:h,x:l,y:c})}const $t=[":popover-open",":modal"];function At(e){return $t.some(t=>{try{return e.matches(t)}catch(e){return!1}})}function Pt(e){return Ct(lt(e)).left+vt(e).scrollLeft}function zt(e,t,n){let r;if("viewport"===t)r=function(e,t){const n=st(e),r=lt(e),i=n.visualViewport;let o=r.clientWidth,a=r.clientHeight,s=0,l=0;if(i){o=i.width,a=i.height;const e=mt();(!e||e&&"fixed"===t)&&(s=i.offsetLeft,l=i.offsetTop)}return{width:o,height:a,x:s,y:l}}(e,n);else if("document"===t)r=function(e){const t=lt(e),n=vt(e),r=e.ownerDocument.body,i=je(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),o=je(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let a=-n.scrollLeft+Pt(e);const s=-n.scrollTop;return"rtl"===wt(r).direction&&(a+=je(t.clientWidth,r.clientWidth)-i),{width:i,height:o,x:a,y:s}}(lt(e));else if(ut(t))r=function(e,t){const n=Ct(e,!0,"fixed"===t),r=n.top+e.clientTop,i=n.left+e.clientLeft,o=ht(e)?Tt(e):He(1);return{width:e.clientWidth*o.x,height:e.clientHeight*o.y,x:i*o.x,y:r*o.y}}(t,n);else{const n=St(e);r={...t,x:t.x-n.x,y:t.y-n.y}}return rt(r)}function Lt(e,t){const n=yt(e);return!(n===t||!ut(n)||bt(n))&&("fixed"===wt(n).position||Lt(n,t))}function Ot(e,t,n){const r=ht(t),i=lt(t),o="fixed"===n,a=Ct(e,!0,o,t);let s={scrollLeft:0,scrollTop:0};const l=He(0);if(r||!r&&!o)if(("body"!==at(t)||gt(i))&&(s=vt(t)),r){const e=Ct(t,!0,o,t);l.x=e.x+t.clientLeft,l.y=e.y+t.clientTop}else i&&(l.x=Pt(i));return{x:a.left+s.scrollLeft-l.x,y:a.top+s.scrollTop-l.y,width:a.width,height:a.height}}function It(e,t){return ht(e)&&"fixed"!==wt(e).position?t?t(e):e.offsetParent:null}function Nt(e,t){const n=st(e);if(!ht(e)||At(e))return n;let r=It(e,t);for(;r&&ft(r)&&"static"===wt(r).position;)r=It(r,t);return r&&("html"===at(r)||"body"===at(r)&&"static"===wt(r).position&&!pt(r))?n:r||function(e){let t=yt(e);for(;ht(t)&&!bt(t);){if(pt(t))return t;t=yt(t)}return null}(e)||n}const Dt={convertOffsetParentRelativeRectToViewportRelativeRect:function(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e;const o="fixed"===i,a=lt(r),s=!!t&&At(t.floating);if(r===a||s&&o)return n;let l={scrollLeft:0,scrollTop:0},c=He(1);const u=He(0),h=ht(r);if((h||!h&&!o)&&(("body"!==at(r)||gt(a))&&(l=vt(r)),ht(r))){const e=Ct(r);c=Tt(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-l.scrollLeft*c.x+u.x,y:n.y*c.y-l.scrollTop*c.y+u.y}},getDocumentElement:lt,getClippingRect:function(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e;const o=[..."clippingAncestors"===n?function(e,t){const n=t.get(e);if(n)return n;let r=kt(e,[],!1).filter(e=>ut(e)&&"body"!==at(e)),i=null;const o="fixed"===wt(e).position;let a=o?yt(e):e;for(;ut(a)&&!bt(a);){const t=wt(a),n=pt(a);n||"fixed"!==t.position||(i=null),(o?!n&&!i:!n&&"static"===t.position&&i&&["absolute","fixed"].includes(i.position)||gt(a)&&!n&&Lt(e,a))?r=r.filter(e=>e!==a):i=t,a=yt(a)}return t.set(e,r),r}(t,this._c):[].concat(n),r],a=o.reduce((e,n)=>{const r=zt(t,n,i);return e.top=je(r.top,e.top),e.right=Me(r.right,e.right),e.bottom=Me(r.bottom,e.bottom),e.left=je(r.left,e.left),e},zt(t,o[0],i));return{width:a.right-a.left,height:a.bottom-a.top,x:a.left,y:a.top}},getOffsetParent:Nt,getElementRects:async function(e){const t=this.getOffsetParent||Nt,n=this.getDimensions;return{reference:Ot(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,...await n(e.floating)}}},getClientRects:function(e){return Array.from(e.getClientRects())},getDimensions:function(e){const{width:t,height:n}=_t(e);return{width:t,height:n}},getScale:Tt,isElement:ut,isRTL:function(e){return"rtl"===wt(e).direction}},Ft=function(e){return void 0===e&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:i,middlewareData:o,rects:a,initialPlacement:s,platform:l,elements:c}=t,{mainAxis:u=!0,crossAxis:h=!0,fallbackPlacements:d,fallbackStrategy:g="bestFit",fallbackAxisSideDirection:f="none",flipAlignment:p=!0,...m}=Qe(e,t);if(null!=(n=o.arrow)&&n.alignmentOffset)return{};const b=Ke(i),w=Ke(s)===s,v=await(null==l.isRTL?void 0:l.isRTL(c.floating)),y=d||(w||!p?[nt(s)]:function(e){const t=nt(e);return[tt(e),t,tt(t)]}(s));d||"none"===f||y.push(...function(e,t,n,r){const i=Ue(e);let o=function(e,t,n){const r=["left","right"],i=["right","left"],o=["top","bottom"],a=["bottom","top"];switch(e){case"top":case"bottom":return n?t?i:r:t?r:i;case"left":case"right":return t?o:a;default:return[]}}(Ke(e),"start"===n,r);return i&&(o=o.map(e=>e+"-"+i),t&&(o=o.concat(o.map(tt)))),o}(s,p,f,v));const x=[s,...y],k=await ot(t,m),_=[];let E=(null==(r=o.flip)?void 0:r.overflows)||[];if(u&&_.push(k[b]),h){const e=function(e,t,n){void 0===n&&(n=!1);const r=Ue(e),i=et(e),o=Xe(i);let a="x"===i?r===(n?"end":"start")?"right":"left":"start"===r?"bottom":"top";return t.reference[o]>t.floating[o]&&(a=nt(a)),[a,nt(a)]}(i,a,v);_.push(k[e[0]],k[e[1]])}if(E=[...E,{placement:i,overflows:_}],!_.every(e=>e<=0)){var T,R;const e=((null==(T=o.flip)?void 0:T.index)||0)+1,t=x[e];if(t)return{data:{index:e,overflows:E},reset:{placement:t}};let n=null==(R=E.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0])?void 0:R.placement;if(!n)switch(g){case"bestFit":{var S;const e=null==(S=E.map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0])?void 0:S[0];e&&(n=e);break}case"initialPlacement":n=s}if(i!==n)return{reset:{placement:n}}}return{}}}};var Bt;function Mt(e,t,n){if(!e.s){if(n instanceof qt){if(!n.s)return void(n.o=Mt.bind(null,e,t));1&t&&(t=n.s),n=n.v}if(n&&n.then)return void n.then(Mt.bind(null,e,t),Mt.bind(null,e,2));e.s=t,e.v=n;var r=e.o;r&&r(e)}}var jt=function(t){try{t.preventDefault();var n=t.target;if(!Kt.url)return console.error("LangChat Chat Widget: No URL provided"),Kt.disableErrorAlert||alert("Could not send chat message: No URL provided"),Promise.resolve();var r=document.getElementById("langchat-chat-widget__submit");r.setAttribute("disabled","");var i=new Headers;i.append("Content-Type","application/json"),i.append("Accept","text/event-stream"),i.append("Authorization","Bearer "+Kt.apiKey);var o=n.elements.message.value,a=e({},Kt.user,{messages:[{role:"user",content:o}],threadId:Kt.threadId,timestamp:Date.now()});return Promise.resolve(Ht(o,a.timestamp,"user")).then(function(){function e(){return r.removeAttribute("disabled"),!1}n.reset(),Xt.prepend(en);var t=function(e,t){try{var n=Promise.resolve(fetch(Kt.url,{method:"POST",headers:i,body:JSON.stringify(a)})).then(function(e){en.remove();var t=Kt.responseIsAStream?Promise.resolve(an(e)).then(function(){}):Promise.resolve(on(e)).then(function(){});if(t&&t.then)return t.then(function(){})})}catch(e){return t(e)}return n&&n.then?n.then(void 0,t):n}(0,function(e){en.remove(),console.error("LangChat Chat Widget:",e),Kt.disableErrorAlert||alert("Could not send message: "+e.message)});return t&&t.then?t.then(e):e()})}catch(t){return Promise.reject(t)}},qt=/*#__PURE__*/function(){function e(){}return e.prototype.then=function(t,n){var r=new e,i=this.s;if(i){var o=1&i?t:n;if(o){try{Mt(r,1,o(this.v))}catch(e){Mt(r,2,e)}return r}return this}return this.o=function(e){try{var i=e.v;1&e.s?Mt(r,1,t?t(i):i):n?Mt(r,1,n(i)):Mt(r,2,i)}catch(e){Mt(r,2,e)}},r},e}();function Zt(e){return e instanceof qt&&1&e.s}var Ht=function(e,t,n){try{var r=document.createElement("div");r.classList.add("langchat-chat-widget__message"),r.classList.add("langchat-chat-widget__message--"+n),r.id="langchat-chat-widget__message--"+n+"--"+t;var i=document.createElement("p");return Promise.resolve(Be(e,{renderer:Wt})).then(function(e){i.innerHTML=e,r.appendChild(i);var n=document.createElement("p");n.classList.add("langchat-chat-widget__message-timestamp"),n.textContent=("0"+new Date(t).getHours()).slice(-2)+":"+("0"+new Date(t).getMinutes()).slice(-2),r.appendChild(n),Xt.prepend(r)})}catch(e){return Promise.reject(e)}},Gt=function(){try{var e=document.createElement("style");return e.innerHTML=":root{--langchat-chat-widget-bg-color:#fff;--langchat-chat-widget-border-color:#e2e2e2;--langchat-chat-widget-shadow:0 0 8rem 0 rgba(0,0,0,.1),0rem 2rem 4rem -3rem rgba(0,0,0,.5);--langchat-chat-widget-primary-color-text:#000;--langchat-chat-widget-secondary-color-text:#979797;--langchat-chat-widget-user-message-text-color:#fff;--langchat-chat-widget-user-message-bg-color:#2c91ed;--langchat-chat-widget-system-message-text-color:#000;--langchat-chat-widget-system-message-bg-color:#e4e4e4;--langchat-chat-widget-primary-color:#2c91ed;--langchat-chat-widget-header-height:4rem;--langchat-chat-widget-button-transition:background-color 0.2s ease-in-out,opacity 0.2s ease-in-out,transform 0.2s ease-in-out;--langchat-chat-widget-title-weight:600;--langchat-chat-widget-button-weight:500;--langchat-chat-widget-border-radius:1rem}@media (prefers-color-scheme:dark){:root{--langchat-chat-widget-bg-color:#2d2d30;--langchat-chat-widget-border-color:#424244;--langchat-chat-widget-shadow:0 0 8rem 0 rgba(0,0,0,.1),0rem 2rem 4rem -3rem rgba(0,0,0,.5);--langchat-chat-widget-primary-color-text:#fff;--langchat-chat-widget-secondary-color-text:#818183;--langchat-chat-widget-user-message-text-color:#fff;--langchat-chat-widget-user-message-bg-color:#2c91ed;--langchat-chat-widget-system-message-text-color:#fff;--langchat-chat-widget-system-message-bg-color:#424244}}[data-theme=light]{--langchat-chat-widget-bg-color:#fff;--langchat-chat-widget-border-color:#e2e2e2;--langchat-chat-widget-shadow:0 0 8rem 0 rgba(0,0,0,.1),0rem 2rem 4rem -3rem rgba(0,0,0,.5);--langchat-chat-widget-primary-color-text:#000;--langchat-chat-widget-secondary-color-text:#979797;--langchat-chat-widget-user-message-text-color:#fff;--langchat-chat-widget-user-message-bg-color:#2c91ed;--langchat-chat-widget-system-message-text-color:#000;--langchat-chat-widget-system-message-bg-color:#e4e4e4}[data-theme=dark]{--langchat-chat-widget-bg-color:#2d2d30;--langchat-chat-widget-border-color:#424244;--langchat-chat-widget-shadow:0 0 8rem 0 rgba(0,0,0,.1),0rem 2rem 4rem -3rem rgba(0,0,0,.5);--langchat-chat-widget-primary-color-text:#fff;--langchat-chat-widget-secondary-color-text:#818183;--langchat-chat-widget-user-message-text-color:#fff;--langchat-chat-widget-user-message-bg-color:#2c91ed;--langchat-chat-widget-system-message-text-color:#fff;--langchat-chat-widget-system-message-bg-color:#424244}#langchat-chat-widget__container{background-color:var(--langchat-chat-widget-bg-color);border-radius:var(--langchat-chat-widget-border-radius);box-shadow:var(--langchat-chat-widget-shadow);box-sizing:border-box;color:var(--langchat-chat-widget-primary-color-text);font-family:inherit;font-size:1rem;height:40rem;opacity:1;overflow:hidden;position:fixed;transform:scale(1);transform-origin:bottom right;transition:transform .3s ease-out,opacity .3s ease-out;width:25rem;z-index:9999}#langchat-chat-widget__container *{box-sizing:border-box}#langchat-chat-widget__container :focus{outline:none}#langchat-chat-widget__backdrop{background-color:transparent;box-sizing:border-box;height:100vh;left:0;position:fixed;top:0;width:100vw;z-index:9998}#langchat-chat-widget__header{align-items:center;display:flex;height:var(--langchat-chat-widget-header-height);justify-content:space-between;padding:1rem}#langchat-chat-widget__title{align-items:center;display:flex;font-weight:var(--langchat-chat-widget-title-weight);width:60%}#langchat-chat-widget__title_icon{margin-right:.5rem}#langchat-chat-widget__title_icon path{fill:var(--langchat-chat-widget-primary-color-text)}#langchat-chat-widget__title_text{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;width:100%}#langchat-chat-widget__branding{color:var(--langchat-chat-widget-secondary-color-text);font-size:.75rem;text-decoration:none}#langchat-chat-widget__branding>span{color:var(--langchat-chat-widget-primary-color-text)}#langchat-chat-widget__body{box-shadow:inset 0 2rem 2rem -2rem rgba(0,0,0,.05),inset 0 -2rem 2rem -2rem rgba(0,0,0,.05);display:flex;flex-direction:column;height:calc(100% - var(--langchat-chat-widget-header-height));padding:.6rem 1rem 1rem;position:relative;width:100%}#langchat-chat-widget__messages_history{-ms-overflow-style:none;display:flex;flex-direction:column-reverse;flex-grow:1;overflow-y:auto;scrollbar-width:none}#langchat-chat-widget__messages_history::-webkit-scrollbar{display:none}#langchat-chat-widget__messages_history .langchat-chat-widget__message{animation:fade-in .75s;border-radius:var(--langchat-chat-widget-border-radius);margin-bottom:.5rem;max-width:85%;padding:.5rem 1rem}#langchat-chat-widget__messages_history p{word-wrap:break-word;margin:0}#langchat-chat-widget__messages_history img{max-width:100%;-o-object-fit:cover;object-fit:cover}#langchat-chat-widget__messages_history code{display:inline-block;max-width:100%;overflow-x:auto;vertical-align:bottom}#langchat-chat-widget__messages_history .langchat-chat-widget__message .langchat-chat-widget__message-timestamp{font-size:.8rem;margin-top:.3rem;opacity:.5}#langchat-chat-widget__messages_history .langchat-chat-widget__message.langchat-chat-widget__message--system{align-self:flex-start;background-color:var(--langchat-chat-widget-system-message-bg-color);border-radius:1.125rem 1.125rem 1.125rem 0}#langchat-chat-widget__messages_history .langchat-chat-widget__message.langchat-chat-widget__message--system p{color:var(--langchat-chat-widget-system-message-text-color)}#langchat-chat-widget__messages_history .langchat-chat-widget__message.langchat-chat-widget__message--user{align-self:flex-end;background-color:var(--langchat-chat-widget-user-message-bg-color);border-radius:1.125rem 1.125rem 0 1.125rem}#langchat-chat-widget__messages_history .langchat-chat-widget__message.langchat-chat-widget__message--user p{color:var(--langchat-chat-widget-user-message-text-color)}#langchat-chat-widget__messages_history .langchat-chat-widget__message.langchat-chat-widget__message--user .langchat-chat-widget__message-timestamp{text-align:right}@keyframes fade-in{0%{opacity:0}to{opacity:1}}#langchat-chat-widget__thinking_bubble{align-items:center;animation:fade-in .75s;background-color:var(--langchat-chat-widget-system-message-bg-color);border-radius:var(--langchat-chat-widget-border-radius);display:flex;justify-content:space-between;margin-bottom:.5rem;padding:1rem;width:80px}#langchat-chat-widget__thinking_bubble .circle{animation:bounce 1.5s infinite;background-color:var(--langchat-chat-widget-system-message-text-color);border-radius:50%;height:12px;opacity:.5;width:12px}#langchat-chat-widget__thinking_bubble .circle:first-child{animation-delay:1s}#langchat-chat-widget__thinking_bubble .circle:nth-child(2){animation-delay:1.1s}#langchat-chat-widget__thinking_bubble .circle:nth-child(3){animation-delay:1.2s}@keyframes bounce{0%{transform:translateY(0)}20%{transform:translateY(-.5rem)}40%{transform:translateY(0)}to{transform:translateY(0)}}#langchat-chat-widget__form{display:flex;gap:.5rem;margin-bottom:0;margin-top:1rem;position:relative;width:100%}#langchat-chat-widget__input{background:none;border:1px solid var(--langchat-chat-widget-border-color);border-radius:23px;color:inherit;flex-grow:1;font:inherit;padding:.5rem 1rem;resize:none}#langchat-chat-widget__input:focus{box-shadow:none;outline:none}#langchat-chat-widget__submit{align-items:center;background-color:transparent;border:none;border-radius:50%;color:inherit;color:var(--langchat-chat-widget-primary-color);cursor:pointer;display:flex;justify-content:center;line-height:2rem;min-height:2rem;position:relative;transition:var(--langchat-chat-widget-button-transition)}#langchat-chat-widget__submit:hover{transform:scale(1.05);transition-duration:0s}#langchat-chat-widget__submit:active{transform:scale(.95);transition-duration:0s}#langchat-chat-widget__submit[disabled]{background-color:var(--langchat-chat-widget-border-color);cursor:default;opacity:.5}",document.head.insertBefore(e,document.head.firstChild),Promise.resolve(new Promise(function(e){return setTimeout(e,500)})).then(function(){var e;null==(e=document.querySelector("[data-langchat-chat-widget-button]"))||e.addEventListener("click",nn),Kt.openOnLoad&&nn({target:document.querySelector("[data-langchat-chat-widget-button]")})})}catch(e){return Promise.reject(e)}},Vt="langchat-chat-widget__backdrop",Wt=new Be.Renderer,Qt=Wt.link;Wt.link=function(e,t,n){return Qt.call(Wt,e,t,n).replace(/^<a /,'<a target="_blank" rel="nofollow" ')};var Kt=e({url:"",apiKey:"",threadId:null,responseIsAStream:!1,user:{},widgetTitle:"LangChat",greetingMessage:null,disableErrorAlert:!1,closeOnOutsideClick:!0,openOnLoad:!1},null==(Bt=window.langchatChatWidget)?void 0:Bt.config),Ut=function(){};window.addEventListener("load",Gt);var Yt=document.createElement("div");Yt.id="langchat-chat-widget__container";var Xt=document.createElement("div");Xt.id="langchat-chat-widget__messages_history";var Jt=document.createElement("div");Jt.id=Vt;var en=document.createElement("div");en.id="langchat-chat-widget__thinking_bubble",en.innerHTML='\n <span class="circle"></span>\n <span class="circle"></span>\n <span class="circle"></span>\n ';var tn=function(e,t){var n,r=(null==t?void 0:t.document)||document,i=(null==t?void 0:t.trapStack)||P,o=_({returnFocusOnDeactivate:!0,escapeDeactivates:!0,delayInitialFocus:!0,isKeyForward:T,isKeyBackward:R},t),a={containers:[],containerGroups:[],tabbableGroups:[],nodeFocusedBeforeActivation:null,mostRecentlyFocusedNode:null,active:!1,paused:!1,delayInitialFocusTimer:void 0,recentNavEvent:void 0},s=function(e,t,n){return e&&void 0!==e[t]?e[t]:o[n||t]},u=function(e,t){var n="function"==typeof(null==t?void 0:t.composedPath)?t.composedPath():void 0;return a.containerGroups.findIndex(function(t){var r=t.container,i=t.tabbableNodes;return r.contains(e)||(null==n?void 0:n.includes(r))||i.find(function(t){return t===e})})},d=function(e){var t=o[e];if("function"==typeof t){for(var n=arguments.length,i=new Array(n>1?n-1:0),a=1;a<n;a++)i[a-1]=arguments[a];t=t.apply(void 0,i)}if(!0===t&&(t=void 0),!t){if(void 0===t||!1===t)return t;throw new Error("`".concat(e,"` was specified but was not a node, or did not return a node"))}var s=t;if("string"==typeof t&&!(s=r.querySelector(t)))throw new Error("`".concat(e,"` as selector refers to no known node"));return s},g=function(){var e=d("initialFocus");if(!1===e)return!1;if(void 0===e||!x(e,o.tabbableOptions))if(u(r.activeElement)>=0)e=r.activeElement;else{var t=a.tabbableGroups[0];e=t&&t.firstTabbableNode||d("fallbackFocus")}if(!e)throw new Error("Your focus-trap needs to have at least one focusable element");return e},f=function(){if(a.containerGroups=a.containers.map(function(e){var t=function(e,t){var n;return n=(t=t||{}).getShadowRoot?c([e],t.includeContainer,{filter:m.bind(null,t),flatten:!1,getShadowRoot:t.getShadowRoot,shadowRootFilter:b}):l(e,t.includeContainer,m.bind(null,t)),w(n)}(e,o.tabbableOptions),n=function(e,t){return(t=t||{}).getShadowRoot?c([e],t.includeContainer,{filter:p.bind(null,t),flatten:!0,getShadowRoot:t.getShadowRoot}):l(e,t.includeContainer,p.bind(null,t))}(e,o.tabbableOptions),r=t.length>0?t[0]:void 0,i=t.length>0?t[t.length-1]:void 0,a=n.find(function(e){return v(e)}),s=n.slice().reverse().find(function(e){return v(e)}),u=!!t.find(function(e){return h(e)>0});return{container:e,tabbableNodes:t,focusableNodes:n,posTabIndexesFound:u,firstTabbableNode:r,lastTabbableNode:i,firstDomTabbableNode:a,lastDomTabbableNode:s,nextTabbableNode:function(e){var r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],i=t.indexOf(e);return i<0?r?n.slice(n.indexOf(e)+1).find(function(e){return v(e)}):n.slice(0,n.indexOf(e)).reverse().find(function(e){return v(e)}):t[i+(r?1:-1)]}}}),a.tabbableGroups=a.containerGroups.filter(function(e){return e.tabbableNodes.length>0}),a.tabbableGroups.length<=0&&!d("fallbackFocus"))throw new Error("Your focus-trap must have at least one container with at least one tabbable node in it at all times");if(a.containerGroups.find(function(e){return e.posTabIndexesFound})&&a.containerGroups.length>1)throw new Error("At least one node with a positive tabindex was found in one of your focus-trap's multiple containers. Positive tabindexes are only supported in single-container focus-traps.")},y=function e(t){var n=t.activeElement;if(n)return n.shadowRoot&&null!==n.shadowRoot.activeElement?e(n.shadowRoot):n},k=function e(t){!1!==t&&t!==y(document)&&(t&&t.focus?(t.focus({preventScroll:!!o.preventScroll}),a.mostRecentlyFocusedNode=t,function(e){return e.tagName&&"input"===e.tagName.toLowerCase()&&"function"==typeof e.select}(t)&&t.select()):e(g()))},z=function(e){var t=d("setReturnFocus",e);return t||!1!==t&&e},L=function(e){var t=e.target,n=e.event,r=e.isBackward,i=void 0!==r&&r;t=t||A(n),f();var s=null;if(a.tabbableGroups.length>0){var l=u(t,n),c=l>=0?a.containerGroups[l]:void 0;if(l<0)s=i?a.tabbableGroups[a.tabbableGroups.length-1].lastTabbableNode:a.tabbableGroups[0].firstTabbableNode;else if(i){var g=C(a.tabbableGroups,function(e){return t===e.firstTabbableNode});if(g<0&&(c.container===t||x(t,o.tabbableOptions)&&!v(t,o.tabbableOptions)&&!c.nextTabbableNode(t,!1))&&(g=l),g>=0){var p=a.tabbableGroups[0===g?a.tabbableGroups.length-1:g-1];s=h(t)>=0?p.lastTabbableNode:p.lastDomTabbableNode}else E(n)||(s=c.nextTabbableNode(t,!1))}else{var m=C(a.tabbableGroups,function(e){return t===e.lastTabbableNode});if(m<0&&(c.container===t||x(t,o.tabbableOptions)&&!v(t,o.tabbableOptions)&&!c.nextTabbableNode(t))&&(m=l),m>=0){var b=a.tabbableGroups[m===a.tabbableGroups.length-1?0:m+1];s=h(t)>=0?b.firstTabbableNode:b.firstDomTabbableNode}else E(n)||(s=c.nextTabbableNode(t))}}else s=d("fallbackFocus");return s},O=function(e){var t=A(e);u(t,e)>=0||($(o.clickOutsideDeactivates,e)?n.deactivate({returnFocus:o.returnFocusOnDeactivate}):$(o.allowOutsideClick,e)||e.preventDefault())},I=function(e){var t=A(e),n=u(t,e)>=0;if(n||t instanceof Document)n&&(a.mostRecentlyFocusedNode=t);else{var r;e.stopImmediatePropagation();var i=!0;if(a.mostRecentlyFocusedNode)if(h(a.mostRecentlyFocusedNode)>0){var s=u(a.mostRecentlyFocusedNode),l=a.containerGroups[s].tabbableNodes;if(l.length>0){var c=l.findIndex(function(e){return e===a.mostRecentlyFocusedNode});c>=0&&(o.isKeyForward(a.recentNavEvent)?c+1<l.length&&(r=l[c+1],i=!1):c-1>=0&&(r=l[c-1],i=!1))}}else a.containerGroups.some(function(e){return e.tabbableNodes.some(function(e){return h(e)>0})})||(i=!1);else i=!1;i&&(r=L({target:a.mostRecentlyFocusedNode,isBackward:o.isKeyBackward(a.recentNavEvent)})),k(r||a.mostRecentlyFocusedNode||g())}a.recentNavEvent=void 0},N=function(e){if(("Escape"===(null==(t=e)?void 0:t.key)||"Esc"===(null==t?void 0:t.key)||27===(null==t?void 0:t.keyCode))&&!1!==$(o.escapeDeactivates,e))return e.preventDefault(),void n.deactivate();var t;(o.isKeyForward(e)||o.isKeyBackward(e))&&function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];a.recentNavEvent=e;var n=L({event:e,isBackward:t});n&&(E(e)&&e.preventDefault(),k(n))}(e,o.isKeyBackward(e))},D=function(e){var t=A(e);u(t,e)>=0||$(o.clickOutsideDeactivates,e)||$(o.allowOutsideClick,e)||(e.preventDefault(),e.stopImmediatePropagation())},F=function(){if(a.active)return function(e,t){if(e.length>0){var n=e[e.length-1];n!==t&&n.pause()}var r=e.indexOf(t);-1===r||e.splice(r,1),e.push(t)}(i,n),a.delayInitialFocusTimer=o.delayInitialFocus?S(function(){k(g())}):k(g()),r.addEventListener("focusin",I,!0),r.addEventListener("mousedown",O,{capture:!0,passive:!1}),r.addEventListener("touchstart",O,{capture:!0,passive:!1}),r.addEventListener("click",D,{capture:!0,passive:!1}),r.addEventListener("keydown",N,{capture:!0,passive:!1}),n},B=function(){if(a.active)return r.removeEventListener("focusin",I,!0),r.removeEventListener("mousedown",O,!0),r.removeEventListener("touchstart",O,!0),r.removeEventListener("click",D,!0),r.removeEventListener("keydown",N,!0),n},M="undefined"!=typeof window&&"MutationObserver"in window?new MutationObserver(function(e){e.some(function(e){return Array.from(e.removedNodes).some(function(e){return e===a.mostRecentlyFocusedNode})})&&k(g())}):void 0,j=function(){M&&(M.disconnect(),a.active&&!a.paused&&a.containers.map(function(e){M.observe(e,{subtree:!0,childList:!0})}))};return(n={get active(){return a.active},get paused(){return a.paused},activate:function(e){if(a.active)return this;var t=s(e,"onActivate"),n=s(e,"onPostActivate"),i=s(e,"checkCanFocusTrap");i||f(),a.active=!0,a.paused=!1,a.nodeFocusedBeforeActivation=r.activeElement,null==t||t();var o=function(){i&&f(),F(),j(),null==n||n()};return i?(i(a.containers.concat()).then(o,o),this):(o(),this)},deactivate:function(e){if(!a.active)return this;var t=_({onDeactivate:o.onDeactivate,onPostDeactivate:o.onPostDeactivate,checkCanReturnFocus:o.checkCanReturnFocus},e);clearTimeout(a.delayInitialFocusTimer),a.delayInitialFocusTimer=void 0,B(),a.active=!1,a.paused=!1,j(),function(e,t){var n=e.indexOf(t);-1!==n&&e.splice(n,1),e.length>0&&e[e.length-1].unpause()}(i,n);var r=s(t,"onDeactivate"),l=s(t,"onPostDeactivate"),c=s(t,"checkCanReturnFocus"),u=s(t,"returnFocus","returnFocusOnDeactivate");null==r||r();var h=function(){S(function(){u&&k(z(a.nodeFocusedBeforeActivation)),null==l||l()})};return u&&c?(c(z(a.nodeFocusedBeforeActivation)).then(h,h),this):(h(),this)},pause:function(e){if(a.paused||!a.active)return this;var t=s(e,"onPause"),n=s(e,"onPostPause");return a.paused=!0,null==t||t(),B(),j(),null==n||n(),this},unpause:function(e){if(!a.paused||!a.active)return this;var t=s(e,"onUnpause"),n=s(e,"onPostUnpause");return a.paused=!1,null==t||t(),f(),F(),j(),null==n||n(),this},updateContainerElements:function(e){var t=[].concat(e).filter(Boolean);return a.containers=t.map(function(e){return"string"==typeof e?r.querySelector(e):e}),a.active&&f(),j(),this}}).updateContainerElements(e),n}(Yt,{initialFocus:"#langchat-chat-widget__input",allowOutsideClick:!0});function nn(e){if(Kt.closeOnOutsideClick&&document.body.appendChild(Jt),Yt.hasChildNodes())rn();else{document.body.appendChild(Yt),Yt.innerHTML='<div id="langchat-chat-widget__header"><div id="langchat-chat-widget__title"><svg height="19" id="langchat-chat-widget__title_icon" viewBox="0 0 24 19" width="24"><path d="M9 6C9.55229 6 10 6.44772 10 7V9C10 9.55228 9.55229 10 9 10C8.44771 10 8 9.55228 8 9V7C8 6.44772 8.44771 6 9 6Z"/><path d="M16 7C16 6.44772 15.5523 6 15 6C14.4477 6 14 6.44772 14 7V9C14 9.55228 14.4477 10 15 10C15.5523 10 16 9.55228 16 9V7Z"/><path d="M19.2099 16C19.0086 16 18.815 16.0768 18.6684 16.2147L16.4858 18.269C15.2525 19.4298 13.2248 18.6278 13.1191 16.9374C13.0862 16.4105 12.6493 16 12.1213 16H5C3.34315 16 2 14.6569 2 13V9C2 9.55228 1.55228 10 1 10C0.447715 10 0 9.55228 0 9V6C0 5.44772 0.447715 5 1 5C1.55228 5 2 5.44772 2 6V3C2 1.34315 3.34315 0 5 0H19C20.6569 0 22 1.34315 22 3V6C22 5.44772 22.4477 5 23 5C23.5523 5 24 5.44772 24 6V9C24 9.55228 23.5523 10 23 10C22.4477 10 22 9.55228 22 9V13.2099C22 14.7508 20.7508 16 19.2099 16ZM5 2C4.44772 2 4 2.44772 4 3V13C4 13.5523 4.44772 14 5 14H12.1213C13.7053 14 15.0163 15.2315 15.1152 16.8124L17.2977 14.7583C17.8152 14.2712 18.4992 14 19.2099 14C19.6463 14 20 13.6463 20 13.2099V3C20 2.44772 19.5523 2 19 2H5Z"/></svg></div><div><a href="https://github.com/tycoding/langchat" id="langchat-chat-widget__branding" target="_blank">Powered by <span>LangChat</span></a></div></div><div id="langchat-chat-widget__body"><form id="langchat-chat-widget__form"><input aria-label="Message" autocomplete="off" id="langchat-chat-widget__input" name="message" placeholder="Ask me a question…" required type="text"><button id="langchat-chat-widget__submit" type="submit"><svg height="26" viewBox="0 0 26 26" width="26" xmlns="http://www.w3.org/2000/svg"><g fill="none"><path d="M24 0v24H0V0zM12.593 23.258l-.011.002l-.071.035l-.02.004l-.014-.004l-.071-.035q-.016-.005-.024.005l-.004.01l-.017.428l.005.02l.01.013l.104.074l.015.004l.012-.004l.104-.074l.012-.016l.004-.017l-.017-.427q-.004-.016-.017-.018m.265-.113l-.013.002l-.185.093l-.01.01l-.003.011l.018.43l.005.012l.008.007l.201.093q.019.005.029-.008l.004-.014l-.034-.614q-.005-.019-.02-.022m-.715.002a.02.02 0 0 0-.027.006l-.006.014l-.034.614q.001.018.017.024l.015-.002l.201-.093l.01-.008l.004-.011l.017-.43l-.003-.012l-.01-.01z"></path><path d="m21.433 4.861l-6 15.5a1 1 0 0 1-1.624.362l-3.382-3.235l-2.074 2.073a.5.5 0 0 1-.853-.354v-4.519L2.309 9.723a1 1 0 0 1 .442-1.691l17.5-4.5a1 1 0 0 1 1.181 1.329ZM19 6.001L8.032 13.152l1.735 1.66L19 6Z" fill="currentColor"></path></g></svg></button></form></div>',Yt.style.display="block";var t=document.createElement("span");t.id="langchat-chat-widget__title_text",t.textContent=Kt.widgetTitle,document.getElementById("langchat-chat-widget__title").appendChild(t),document.getElementById("langchat-chat-widget__body").prepend(Xt),Kt.greetingMessage&&0===Xt.children.length&&Ht(Kt.greetingMessage,Date.now(),"system");var n=(null==e?void 0:e.target)||document.body;Ut=function(e,t,n,r){void 0===r&&(r={});const{ancestorScroll:i=!0,ancestorResize:o=!0,elementResize:a="function"==typeof ResizeObserver,layoutShift:s="function"==typeof IntersectionObserver,animationFrame:l=!1}=r,c=Et(e),u=i||o?[...c?kt(c):[],...kt(t)]:[];u.forEach(e=>{i&&e.addEventListener("scroll",n,{passive:!0}),o&&e.addEventListener("resize",n)});const h=c&&s?function(e,t){let n,r=null;const i=lt(e);function o(){var e;clearTimeout(n),null==(e=r)||e.disconnect(),r=null}return function a(s,l){void 0===s&&(s=!1),void 0===l&&(l=1),o();const{left:c,top:u,width:h,height:d}=e.getBoundingClientRect();if(s||t(),!h||!d)return;const g={rootMargin:-Ze(u)+"px "+-Ze(i.clientWidth-(c+h))+"px "+-Ze(i.clientHeight-(u+d))+"px "+-Ze(c)+"px",threshold:je(0,Me(1,l))||1};let f=!0;function p(e){const t=e[0].intersectionRatio;if(t!==l){if(!f)return a();t?a(!1,t):n=setTimeout(()=>{a(!1,1e-7)},100)}f=!1}try{r=new IntersectionObserver(p,{...g,root:i.ownerDocument})}catch(e){r=new IntersectionObserver(p,g)}r.observe(e)}(!0),o}(c,n):null;let d,g=-1,f=null;a&&(f=new ResizeObserver(e=>{let[r]=e;r&&r.target===c&&f&&(f.unobserve(t),cancelAnimationFrame(g),g=requestAnimationFrame(()=>{var e;null==(e=f)||e.observe(t)})),n()}),c&&!l&&f.observe(c),f.observe(t));let p=l?Ct(e):null;return l&&function t(){const r=Ct(e);!p||r.x===p.x&&r.y===p.y&&r.width===p.width&&r.height===p.height||n(),p=r,d=requestAnimationFrame(t)}(),n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener("scroll",n),o&&e.removeEventListener("resize",n)}),null==h||h(),null==(e=f)||e.disconnect(),f=null,l&&cancelAnimationFrame(d)}}(n,Yt,function(){var e;((e,t,n)=>{const r=new Map,i={platform:Dt,...n},o={...i.platform,_c:r};return(async(e,t,n)=>{const{placement:r="bottom",strategy:i="absolute",middleware:o=[],platform:a}=n,s=o.filter(Boolean),l=await(null==a.isRTL?void 0:a.isRTL(t));let c=await a.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:h}=it(c,r,l),d=r,g={},f=0;for(let n=0;n<s.length;n++){const{name:o,fn:p}=s[n],{x:m,y:b,data:w,reset:v}=await p({x:u,y:h,initialPlacement:r,placement:d,strategy:i,middlewareData:g,rects:c,platform:a,elements:{reference:e,floating:t}});u=null!=m?m:u,h=null!=b?b:h,g={...g,[o]:{...g[o],...w}},v&&f<=50&&(f++,"object"==typeof v&&(v.placement&&(d=v.placement),v.rects&&(c=!0===v.rects?await a.getElementRects({reference:e,floating:t,strategy:i}):v.rects),({x:u,y:h}=it(c,d,l))),n=-1)}return{x:u,y:h,placement:d,strategy:i,middlewareData:g}})(e,t,{...i,platform:o})})(n,Yt,{placement:"top-start",middleware:[Ft(),(e={crossAxis:!0,padding:8},void 0===e&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:i}=t,{mainAxis:o=!0,crossAxis:a=!1,limiter:s={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=Qe(e,t),c={x:n,y:r},u=await ot(t,l),h=Je(Ke(i)),d=Ye(h);let g=c[d],f=c[h];o&&(g=We(g+u["y"===d?"top":"left"],g,g-u["y"===d?"bottom":"right"])),a&&(f=We(f+u["y"===h?"top":"left"],f,f-u["y"===h?"bottom":"right"]));const p=s.fn({...t,[d]:g,[h]:f});return{...p,data:{x:p.x-n,y:p.y-r}}}})],strategy:"fixed"}).then(function(e){Object.assign(Yt.style,{left:e.x+"px",top:e.y-10+"px"})})}),tn.activate(),Kt.closeOnOutsideClick&&document.getElementById(Vt).addEventListener("click",rn),document.getElementById("langchat-chat-widget__form").addEventListener("submit",jt)}}function rn(){tn.deactivate(),Yt.innerHTML="",Yt.remove(),Jt.remove(),Ut(),Ut=function(){}}var on=function(e){try{return Promise.resolve(function(){if(e.ok)return Promise.resolve(e.json()).then(function(t){var n=t.message,r=t.threadId;return"string"!=typeof r?(console.error("LangChat Chat Widget: Server error",e),void(Kt.disableErrorAlert||alert("Received an OK response but \"threadId\" was of incompatible type (expected 'string', received '"+typeof r+"'). Please make sure the API response is configured correctly.\n\nYou can learn more here: https://github.com/rowyio/langchat-chat-widget?tab=readme-ov-file#connecting-the-widget-to-your-langchat-workflow"))):"string"!=typeof n?(console.error("LangChat Chat Widget: Server error",e),void(Kt.disableErrorAlert||alert("Received an OK response but \"message\" was of incompatible type (expected 'string', received '"+typeof n+"'). Please make sure the API response is configured correctly.\n\nYou can learn more here: https://github.com/rowyio/langchat-chat-widget?tab=readme-ov-file#connecting-the-widget-to-your-langchat-workflow"))):n||""===n?Promise.resolve(Ht(n,Date.now(),"system")).then(function(){var e,t;Kt.threadId=null!=(e=null!=(t=Kt.threadId)?t:r)?e:null}):(console.error("LangChat Chat Widget: Server error",e),void(Kt.disableErrorAlert||alert("Received an OK response but no message was found. Please make sure the API response is configured correctly. You can learn more here:\n\nhttps://github.com/rowyio/langchat-chat-widget?tab=readme-ov-file#connecting-the-widget-to-your-langchat-workflow")))});console.error("LangChat Chat Widget: Server error",e),Kt.disableErrorAlert||alert("Could not send message: "+e.statusText)}())}catch(e){return Promise.reject(e)}},an=function(e){try{var n,r,i=function(e){var t,r;if(n)return e;Kt.threadId=null!=(t=null!=(r=Kt.threadId)?r:o)?t:""!==s?s:null};if(!e.body)return console.error("LangChat Chat Widget: Streamed response has no body",e),Kt.disableErrorAlert||alert("Received a streamed response but no body was found. Please make sure the API response is configured correctly."),Promise.resolve();var o=e.headers.get("x-thread-id"),a="",s="",l=Date.now(),c=e.body.getReader(),u=function(e,t,n){for(var r;;){var i=e();if(Zt(i)&&(i=i.v),!i)return o;if(i.then){r=0;break}var o=n();if(o&&o.then){if(!Zt(o)){r=1;break}o=o.s}if(t){var a=t();if(a&&a.then&&!Zt(a)){r=2;break}}}var s=new qt,l=Mt.bind(null,s,2);return(0===r?i.then(u):1===r?o.then(c):a.then(h)).then(void 0,l),s;function c(r){o=r;do{if(t&&(a=t())&&a.then&&!Zt(a))return void a.then(h).then(void 0,l);if(!(i=e())||Zt(i)&&!i.v)return void Mt(s,1,o);if(i.then)return void i.then(u).then(void 0,l);Zt(o=n())&&(o=o.v)}while(!o||!o.then);o.then(c).then(void 0,l)}function u(e){e?(o=n())&&o.then?o.then(c).then(void 0,l):c(o):Mt(s,1,o)}function h(){(i=e())?i.then?i.then(u).then(void 0,l):u(i):Mt(s,1,o)}}(function(){return!(r||n)},void 0,function(){return Promise.resolve(c.read()).then(function(e){var i=e.value;if(!e.done&&void 0!==i){for(var o,s=function(e,n){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,n){if(e){if("string"==typeof e)return t(e,n);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?t(e,n):void 0}}(e))){r&&(e=r);var i=0;return function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}((new TextDecoder).decode(i,{stream:!0}).split("\n"));!(o=s()).done;){var c=o.value;if(c.startsWith("data:{")||c.startsWith("{")){var u="";c.startsWith("data:{")&&(u=c.slice(5).trim()),c.startsWith("{")&&(u=c.trim());try{var h=JSON.parse(u).choices[0];if("STOP"===h.finishReason)return void(n=1);a+=h.delta.content}catch(e){console.error("Failed to parse JSON:",e)}}}return Promise.resolve(function(e,t,n){try{var r=Xt.querySelector("#langchat-chat-widget__message--"+n+"--"+t);return Promise.resolve(function(){if(r){var i=r.querySelector("p");return Promise.resolve(Be(e,{renderer:Wt})).then(function(e){i.innerHTML=e})}return Promise.resolve(Ht(e,t,n)).then(function(){})}())}catch(e){return Promise.reject(e)}}(a,l,"system")).then(function(){})}r=1})});return Promise.resolve(u&&u.then?u.then(i):i(u))}catch(e){return Promise.reject(e)}},sn={open:nn,close:rn,config:Kt,init:Gt};window.langchatChatWidget=sn;export{sn as default};
- //# sourceMappingURL=index.module.js.map
|