| 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)}var t=["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])"],n=/* #__PURE__ */t.join(","),r="undefined"==typeof Element,i=r?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,o=!r&&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},a=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)},s=function(e,t,r){if(a(e))return[];var o=Array.prototype.slice.apply(e.querySelectorAll(n));return t&&i.call(e,n)&&o.unshift(e),o.filter(r)},l=function e(t,r,o){for(var s=[],l=Array.from(t);l.length;){var c=l.shift();if(!a(c,!1))if("SLOT"===c.tagName){var u=c.assignedElements(),h=e(u.length?u:c.children,!0,o);o.flatten?s.push.apply(s,h):s.push({scopeParent:c,candidates:h})}else{i.call(c,n)&&o.filter(c)&&(r||!t.includes(c))&&s.push(c);var d=c.shadowRoot||"function"==typeof o.getShadowRoot&&o.getShadowRoot(c),g=!a(d,!1)&&(!o.shadowRootFilter||o.shadowRootFilter(c));if(d&&g){var p=e(!0===d?c.children:d.children,!0,o);o.flatten?s.push.apply(s,p):s.push({scopeParent:c,candidates:p})}else l.unshift.apply(l,c.children)}}return s},c=function(e){return!isNaN(parseInt(e.getAttribute("tabindex"),10))},u=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))&&!c(e)?0:e.tabIndex},h=function(e,t){return e.tabIndex===t.tabIndex?e.documentOrder-t.documentOrder:e.tabIndex-t.tabIndex},d=function(e){return"INPUT"===e.tagName},g=function(e){var t=e.getBoundingClientRect();return 0===t.width&&0===t.height},p=function(e,t){return!(t.disabled||a(t)||function(e){return d(e)&&"hidden"===e.type}(t)||function(e,t){var n=t.displayCheck,r=t.getShadowRoot;if("hidden"===getComputedStyle(e).visibility)return!0;var a=i.call(e,"details>summary:first-of-type");if(i.call(a?e.parentElement:e,"details:not([open]) *"))return!0;if(n&&"full"!==n&&"legacy-full"!==n){if("non-zero-area"===n)return g(e)}else{if("function"==typeof r){for(var s=e;e;){var l=e.parentElement,c=o(e);if(l&&!l.shadowRoot&&!0===r(l))return g(e);e=e.assignedSlot?e.assignedSlot:l||c===e.ownerDocument?l:c.host}e=s}if(function(e){var t,n,r,i,a=e&&o(e),s=null===(t=a)||void 0===t?void 0:t.host,l=!1;if(a&&a!==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=a=o(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!!i.call(t,"fieldset[disabled] *")||!r.contains(e)}return!0}t=t.parentElement}return!1}(t))},f=function(e,t){return!(function(e){return function(e){return d(e)&&"radio"===e.type}(e)&&!function(e){if(!e.name)return!0;var t,n=e.form||o(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)||u(t)<0||!p(e,t))},m=function(e){var t=parseInt(e.getAttribute("tabindex"),10);return!!(isNaN(t)||t>=0)},b=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=u(e);return n<0&&t&&!c(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(h).reduce(function(e,t){return t.isScope?e.push.apply(e,t.content):e.push(t.content),e},[]).concat(n)},w=function(e,t){if(t=t||{},!e)throw new Error("No node provided");return!1!==i.call(e,n)&&f(t,e)},y=/* #__PURE__ */t.concat("iframe").join(","),x=function(e,t){if(t=t||{},!e)throw new Error("No node provided");return!1!==i.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 v(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 _=function(e){return"Tab"===(null==e?void 0:e.key)||9===(null==e?void 0:e.keyCode)},E=function(e){return _(e)&&!e.shiftKey},R=function(e){return _(e)&&e.shiftKey},T=function(e){return setTimeout(e,0)},$=function(e,t){var n=-1;return e.every(function(e,r){return!t(e)||(n=r,!1)}),n},S=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},C=function(e){return e.target.shadowRoot&&"function"==typeof e.composedPath?e.composedPath()[0]:e.target},A=[];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+);)/,P=new RegExp(N.source,"g"),D={"&":"&","<":"<",">":">",'"':""","'":"'"},F=e=>D[e];function B(e,t){if(t){if(O.test(e))return e.replace(I,F)}else if(N.test(e))return e.replace(P,F);return e}const M=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/gi;function q(e){return e.replace(M,(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 j=/(^|[^\[])\^/g;function Z(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(j,"$1"),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}function H(e){try{e=encodeURI(e).replace(/%25/g,"%")}catch(e){return null}return e}const G={exec:()=>null};function V(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 W(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 Q(e,t,n,r){const i=t.href,o=t.title?B(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:B(a)}}class K{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:W(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=W(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=W(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=V(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(V(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:B(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=W(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)),Q(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 Q(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=B(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=B(t[1]),n="mailto:"+e):(e=B(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=B(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=B(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]:B(t[0]),{type:"text",raw:t[0],text:e}}}}const U=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Y=/(?:[*+-]|\d{1,9}[.)])/,X=Z(/^(?!bull )((?:.|\n(?!\s*?\n|bull ))+?)\n {0,3}(=+|-+) *(?:\n+|$)/).replace(/bull/g,Y).getRegex(),J=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,ee=/(?!\s*\])(?:\\.|[^\[\]\\])+/,te=Z(/^ {0,3}\[(label)\]: *(?:\n *)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/).replace("label",ee).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),ne=Z(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Y).getRegex(),re="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",ie=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,oe=Z("^ {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",ie).replace("tag",re).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),ae=Z(J).replace("hr",U).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",re).getRegex(),se={blockquote:Z(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",ae).getRegex(),code:/^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/,def:te,fences:/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,heading:/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,hr:U,html:oe,lheading:X,list:ne,newline:/^(?: *(?:\n|$))+/,paragraph:ae,table:G,text:/^[^\n]+/},le=Z("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",U).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",re).getRegex(),ce={...se,table:le,paragraph:Z(J).replace("hr",U).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",le).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",re).getRegex()},ue={...se,html:Z("^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:\"[^\"]*\"|'[^']*'|\\s[^'\"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))").replace("comment",ie).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:G,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:Z(J).replace("hr",U).replace("heading"," *#{1,6} *[^\n]").replace("lheading",X).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},he=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,de=/^( {2,}|\\)\n(?!\s*$)/,ge="\\p{P}\\p{S}",pe=Z(/^((?![*_])[\spunctuation])/,"u").replace(/punctuation/g,ge).getRegex(),fe=Z(/^(?:\*+(?:((?!\*)[punct])|[^\s*]))|^_+(?:((?!_)[punct])|([^\s_]))/,"u").replace(/punct/g,ge).getRegex(),me=Z("^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)[punct](\\*+)(?=[\\s]|$)|[^punct\\s](\\*+)(?!\\*)(?=[punct\\s]|$)|(?!\\*)[punct\\s](\\*+)(?=[^punct\\s])|[\\s](\\*+)(?!\\*)(?=[punct])|(?!\\*)[punct](\\*+)(?!\\*)(?=[punct])|[^punct\\s](\\*+)(?=[^punct\\s])","gu").replace(/punct/g,ge).getRegex(),be=Z("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)[punct](_+)(?=[\\s]|$)|[^punct\\s](_+)(?!_)(?=[punct\\s]|$)|(?!_)[punct\\s](_+)(?=[^punct\\s])|[\\s](_+)(?!_)(?=[punct])|(?!_)[punct](_+)(?!_)(?=[punct])","gu").replace(/punct/g,ge).getRegex(),we=Z(/\\([punct])/,"gu").replace(/punct/g,ge).getRegex(),ye=Z(/^<(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=Z(ie).replace("(?:--\x3e|$)","--\x3e").getRegex(),ke=Z("^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(),ve=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,_e=Z(/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/).replace("label",ve).replace("href",/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Ee=Z(/^!?\[(label)\]\[(ref)\]/).replace("label",ve).replace("ref",ee).getRegex(),Re=Z(/^!?\[(ref)\](?:\[\])?/).replace("ref",ee).getRegex(),Te={_backpedal:G,anyPunctuation:we,autolink:ye,blockSkip:/\[[^[\]]*?\]\([^\(\)]*?\)|`[^`]*?`|<[^<>]*?>/g,br:de,code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,del:G,emStrongLDelim:fe,emStrongRDelimAst:me,emStrongRDelimUnd:be,escape:he,link:_e,nolink:Re,punctuation:pe,reflink:Ee,reflinkSearch:Z("reflink|nolink(?!\\()","g").replace("reflink",Ee).replace("nolink",Re).getRegex(),tag:ke,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,url:G},$e={...Te,link:Z(/^!?\[(label)\]\((.*?)\)/).replace("label",ve).getRegex(),reflink:Z(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",ve).getRegex()},Se={...Te,escape:Z(he).replace("])","~|])").getRegex(),url:Z(/^((?: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.!#$%&'*+\/=?_`{\|}~-]+@)))/},Ce={...Se,br:Z(de).replace("{2,}","*").getRegex(),text:Z(Se.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Ae={normal:se,gfm:ce,pedantic:ue},ze={normal:Te,gfm:Se,breaks:Ce,pedantic:$e};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 K,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:Ae.normal,inline:ze.normal};this.options.pedantic?(t.block=Ae.pedantic,t.inline=ze.pedantic):this.options.gfm&&(t.block=Ae.gfm,t.inline=this.options.breaks?ze.breaks:ze.gfm),this.tokenizer.rules=t}static get rules(){return{block:Ae,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-'+B(r)+'">'+(n?e:B(e,!0))+"</code></pre>\n":"<pre><code>"+(n?e:B(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=H(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=H(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 Pe{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 De=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=K;Hooks=Pe;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 K(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 Pe;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]=Pe.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>"+B(n.message+"",!0)+"</pre>";return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}};function Fe(e,t){return De.parse(e,t)}Fe.options=Fe.setOptions=function(e){return De.setOptions(e),L(Fe.defaults=De.defaults),Fe},Fe.getDefaults=function(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}},Fe.defaults=z,Fe.use=function(...e){return De.use(...e),L(Fe.defaults=De.defaults),Fe},Fe.walkTokens=function(e,t){return De.walkTokens(e,t)},Fe.parseInline=De.parseInline,Fe.Parser=Ne,Fe.parser=Ne.parse,Fe.Renderer=Oe,Fe.TextRenderer=Ie,Fe.Lexer=Le,Fe.lexer=Le.lex,Fe.Tokenizer=K,Fe.Hooks=Pe,Fe.parse=Fe;const Be=Math.min,Me=Math.max,qe=Math.round,je=Math.floor,Ze=e=>({x:e,y:e}),He={left:"right",right:"left",bottom:"top",top:"bottom"},Ge={start:"end",end:"start"};function Ve(e,t,n){return Me(e,Be(t,n))}function We(e,t){return"function"==typeof e?e(t):e}function Qe(e){return e.split("-")[0]}function Ke(e){return e.split("-")[1]}function Ue(e){return"x"===e?"y":"x"}function Ye(e){return"y"===e?"height":"width"}function Xe(e){return["top","bottom"].includes(Qe(e))?"y":"x"}function Je(e){return Ue(Xe(e))}function et(e){return e.replace(/start|end/g,e=>Ge[e])}function tt(e){return e.replace(/left|right|bottom|top/g,e=>He[e])}function nt(e){return{...e,top:e.y,left:e.x,right:e.x+e.width,bottom:e.y+e.height}}function rt(e,t,n){let{reference:r,floating:i}=e;const o=Xe(t),a=Je(t),s=Ye(a),l=Qe(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(Ke(t)){case"start":g[a]-=d*(n&&c?-1:1);break;case"end":g[a]+=d*(n&&c?-1:1)}return g}async function it(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}=We(t,e),p=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),f=s[d?"floating"===h?"reference":"floating":h],m=nt(await o.getClippingRect({element:null==(n=await(null==o.isElement?void 0:o.isElement(f)))||n?f:f.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)),y=await(null==o.isElement?void 0:o.isElement(w))&&await(null==o.getScale?void 0:o.getScale(w))||{x:1,y:1},x=nt(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:s,rect:b,offsetParent:w,strategy:l}):b);return{top:(m.top-x.top+p.top)/y.y,bottom:(x.bottom-m.bottom+p.bottom)/y.y,left:(m.left-x.left+p.left)/y.x,right:(x.right-m.right+p.right)/y.x}}function ot(e){return lt(e)?(e.nodeName||"").toLowerCase():"#document"}function at(e){var t;return(null==e||null==(t=e.ownerDocument)?void 0:t.defaultView)||window}function st(e){var t;return null==(t=(lt(e)?e.ownerDocument:e.document)||window.document)?void 0:t.documentElement}function lt(e){return e instanceof Node||e instanceof at(e).Node}function ct(e){return e instanceof Element||e instanceof at(e).Element}function ut(e){return e instanceof HTMLElement||e instanceof at(e).HTMLElement}function ht(e){return"undefined"!=typeof ShadowRoot&&(e instanceof ShadowRoot||e instanceof at(e).ShadowRoot)}function dt(e){const{overflow:t,overflowX:n,overflowY:r,display:i}=bt(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!["inline","contents"].includes(i)}function gt(e){return["table","td","th"].includes(ot(e))}function pt(e){const t=ft(),n=bt(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 ft(){return!("undefined"==typeof CSS||!CSS.supports)&&CSS.supports("-webkit-backdrop-filter","none")}function mt(e){return["html","body","#document"].includes(ot(e))}function bt(e){return at(e).getComputedStyle(e)}function wt(e){return ct(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.pageXOffset,scrollTop:e.pageYOffset}}function yt(e){if("html"===ot(e))return e;const t=e.assignedSlot||e.parentNode||ht(e)&&e.host||st(e);return ht(t)?t.host:t}function xt(e){const t=yt(e);return mt(t)?e.ownerDocument?e.ownerDocument.body:e.body:ut(t)&&dt(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=at(i);return o?t.concat(a,a.visualViewport||[],dt(i)?i:[],a.frameElement&&n?kt(a.frameElement):[]):t.concat(i,kt(i,[],n))}function vt(e){const t=bt(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const i=ut(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 _t(e){return ct(e)?e:e.contextElement}function Et(e){const t=_t(e);if(!ut(t))return Ze(1);const n=t.getBoundingClientRect(),{width:r,height:i,$:o}=vt(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__*/Ze(0);function Tt(e){const t=at(e);return ft()&&t.visualViewport?{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}:Rt}function $t(e,t,n,r){void 0===t&&(t=!1),void 0===n&&(n=!1);const i=e.getBoundingClientRect(),o=_t(e);let a=Ze(1);t&&(r?ct(r)&&(a=Et(r)):a=Et(e));const s=function(e,t,n){return void 0===t&&(t=!1),!(!n||t&&n!==at(e))&&t}(o,n,r)?Tt(o):Ze(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=at(o),t=r&&ct(r)?at(r):r;let n=e,i=n.frameElement;for(;i&&r&&t!==n;){const e=Et(i),t=i.getBoundingClientRect(),r=bt(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=at(i),i=n.frameElement}}return nt({width:u,height:h,x:l,y:c})}const St=[":popover-open",":modal"];function Ct(e){return St.some(t=>{try{return e.matches(t)}catch(e){return!1}})}function At(e){return $t(st(e)).left+wt(e).scrollLeft}function zt(e,t,n){let r;if("viewport"===t)r=function(e,t){const n=at(e),r=st(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=ft();(!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=st(e),n=wt(e),r=e.ownerDocument.body,i=Me(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),o=Me(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let a=-n.scrollLeft+At(e);const s=-n.scrollTop;return"rtl"===bt(r).direction&&(a+=Me(t.clientWidth,r.clientWidth)-i),{width:i,height:o,x:a,y:s}}(st(e));else if(ct(t))r=function(e,t){const n=$t(e,!0,"fixed"===t),r=n.top+e.clientTop,i=n.left+e.clientLeft,o=ut(e)?Et(e):Ze(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=Tt(e);r={...t,x:t.x-n.x,y:t.y-n.y}}return nt(r)}function Lt(e,t){const n=yt(e);return!(n===t||!ct(n)||mt(n))&&("fixed"===bt(n).position||Lt(n,t))}function Ot(e,t,n){const r=ut(t),i=st(t),o="fixed"===n,a=$t(e,!0,o,t);let s={scrollLeft:0,scrollTop:0};const l=Ze(0);if(r||!r&&!o)if(("body"!==ot(t)||dt(i))&&(s=wt(t)),r){const e=$t(t,!0,o,t);l.x=e.x+t.clientLeft,l.y=e.y+t.clientTop}else i&&(l.x=At(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 ut(e)&&"fixed"!==bt(e).position?t?t(e):e.offsetParent:null}function Nt(e,t){const n=at(e);if(!ut(e)||Ct(e))return n;let r=It(e,t);for(;r&>(r)&&"static"===bt(r).position;)r=It(r,t);return r&&("html"===ot(r)||"body"===ot(r)&&"static"===bt(r).position&&!pt(r))?n:r||function(e){let t=yt(e);for(;ut(t)&&!mt(t);){if(pt(t))return t;t=yt(t)}return null}(e)||n}const Pt={convertOffsetParentRelativeRectToViewportRelativeRect:function(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e;const o="fixed"===i,a=st(r),s=!!t&&Ct(t.floating);if(r===a||s&&o)return n;let l={scrollLeft:0,scrollTop:0},c=Ze(1);const u=Ze(0),h=ut(r);if((h||!h&&!o)&&(("body"!==ot(r)||dt(a))&&(l=wt(r)),ut(r))){const e=$t(r);c=Et(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:st,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=>ct(e)&&"body"!==ot(e)),i=null;const o="fixed"===bt(e).position;let a=o?yt(e):e;for(;ct(a)&&!mt(a);){const t=bt(a),n=pt(a);n||"fixed"!==t.position||(i=null),(o?!n&&!i:!n&&"static"===t.position&&i&&["absolute","fixed"].includes(i.position)||dt(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=Me(r.top,e.top),e.right=Be(r.right,e.right),e.bottom=Be(r.bottom,e.bottom),e.left=Me(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}=vt(e);return{width:t,height:n}},getScale:Et,isElement:ct,isRTL:function(e){return"rtl"===bt(e).direction}},Dt=function(e){return 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}=We(e,t),c={x:n,y:r},u=await it(t,l),h=Xe(Qe(i)),d=Ue(h);let g=c[d],p=c[h];o&&(g=Ve(g+u["y"===d?"top":"left"],g,g-u["y"===d?"bottom":"right"])),a&&(p=Ve(p+u["y"===h?"top":"left"],p,p-u["y"===h?"bottom":"right"]));const f=s.fn({...t,[d]:g,[h]:p});return{...f,data:{x:f.x-n,y:f.y-r}}}}},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:p="none",flipAlignment:f=!0,...m}=We(e,t);if(null!=(n=o.arrow)&&n.alignmentOffset)return{};const b=Qe(i),w=Qe(s)===s,y=await(null==l.isRTL?void 0:l.isRTL(c.floating)),x=d||(w||!f?[tt(s)]:function(e){const t=tt(e);return[et(e),t,et(t)]}(s));d||"none"===p||x.push(...function(e,t,n,r){const i=Ke(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[]}}(Qe(e),"start"===n,r);return i&&(o=o.map(e=>e+"-"+i),t&&(o=o.concat(o.map(et)))),o}(s,f,p,y));const k=[s,...x],v=await it(t,m),_=[];let E=(null==(r=o.flip)?void 0:r.overflows)||[];if(u&&_.push(v[b]),h){const e=function(e,t,n){void 0===n&&(n=!1);const r=Ke(e),i=Je(e),o=Ye(i);let a="x"===i?r===(n?"end":"start")?"right":"left":"start"===r?"bottom":"top";return t.reference[o]>t.floating[o]&&(a=tt(a)),[a,tt(a)]}(i,a,y);_.push(v[e[0]],v[e[1]])}if(E=[...E,{placement:i,overflows:_}],!_.every(e=>e<=0)){var R,T;const e=((null==(R=o.flip)?void 0:R.index)||0)+1,t=k[e];if(t)return{data:{index:e,overflows:E},reset:{placement:t}};let n=null==(T=E.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0])?void 0:T.placement;if(!n)switch(g){case"bestFit":{var $;const e=null==($=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:$[0];e&&(n=e);break}case"initialPlacement":n=s}if(i!==n)return{reset:{placement:n}}}return{}}}},Bt=(e,t,n)=>{const r=new Map,i={platform:Pt,...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}=rt(c,r,l),d=r,g={},p=0;for(let n=0;n<s.length;n++){const{name:o,fn:f}=s[n],{x:m,y:b,data:w,reset:y}=await f({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}},y&&p<=50&&(p++,"object"==typeof y&&(y.placement&&(d=y.placement),y.rects&&(c=!0===y.rects?await a.getElementRects({reference:e,floating:t,strategy:i}):y.rects),({x:u,y:h}=rt(c,d,l))),n=-1)}return{x:u,y:h,placement:d,strategy:i,middlewareData:g}})(e,t,{...i,platform:o})},Mt='<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>';var qt;const jt="langchat-chat-widget__backdrop",Zt=new Fe.Renderer,Ht=Zt.link;Zt.link=(e,t,n)=>Ht.call(Zt,e,t,n).replace(/^<a /,'<a target="_blank" rel="nofollow" ');const Gt=e({url:"",apiKey:"",threadId:null,responseIsAStream:!1,user:{},widgetTitle:"LangChat",greetingMessage:null,disableErrorAlert:!1,closeOnOutsideClick:!0,openOnLoad:!1},null==(qt=window.langchatChatWidget)?void 0:qt.config);let Vt=()=>{};async function Wt(){var e;const t=document.createElement("style");t.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(t,document.head.firstChild),await new Promise(e=>setTimeout(e,500)),null==(e=document.querySelector("[data-langchat-chat-widget-button]"))||e.addEventListener("click",Jt),Gt.openOnLoad&&Jt({target:document.querySelector("[data-langchat-chat-widget-button]")})}window.addEventListener("load",Wt);const Qt=document.createElement("div");Qt.id="langchat-chat-widget__container";const Kt=document.createElement("div");Kt.id="langchat-chat-widget__messages_history";const Ut=document.createElement("div");Ut.id=jt;const Yt=document.createElement("div");Yt.id="langchat-chat-widget__thinking_bubble",Yt.innerHTML='\n <span class="circle"></span>\n <span class="circle"></span>\n <span class="circle"></span>\n ';const Xt=function(e,t){var n,r=(null==t?void 0:t.document)||document,i=(null==t?void 0:t.trapStack)||A,o=v({returnFocusOnDeactivate:!0,escapeDeactivates:!0,delayInitialFocus:!0,isKeyForward:E,isKeyBackward:R},t),a={containers:[],containerGroups:[],tabbableGroups:[],nodeFocusedBeforeActivation:null,mostRecentlyFocusedNode:null,active:!1,paused:!1,delayInitialFocusTimer:void 0,recentNavEvent:void 0},c=function(e,t,n){return e&&void 0!==e[t]?e[t]:o[n||t]},h=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(h(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},y=function(){if(a.containerGroups=a.containers.map(function(e){var t=function(e,t){var n;return n=(t=t||{}).getShadowRoot?l([e],t.includeContainer,{filter:f.bind(null,t),flatten:!1,getShadowRoot:t.getShadowRoot,shadowRootFilter:m}):s(e,t.includeContainer,f.bind(null,t)),b(n)}(e,o.tabbableOptions),n=function(e,t){return(t=t||{}).getShadowRoot?l([e],t.includeContainer,{filter:p.bind(null,t),flatten:!0,getShadowRoot:t.getShadowRoot}):s(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 w(e)}),c=n.slice().reverse().find(function(e){return w(e)}),h=!!t.find(function(e){return u(e)>0});return{container:e,tabbableNodes:t,focusableNodes:n,posTabIndexesFound:h,firstTabbableNode:r,lastTabbableNode:i,firstDomTabbableNode:a,lastDomTabbableNode:c,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 w(e)}):n.slice(0,n.indexOf(e)).reverse().find(function(e){return w(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.")},k=function e(t){var n=t.activeElement;if(n)return n.shadowRoot&&null!==n.shadowRoot.activeElement?e(n.shadowRoot):n},z=function e(t){!1!==t&&t!==k(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()))},L=function(e){var t=d("setReturnFocus",e);return t||!1!==t&&e},O=function(e){var t=e.target,n=e.event,r=e.isBackward,i=void 0!==r&&r;t=t||C(n),y();var s=null;if(a.tabbableGroups.length>0){var l=h(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=$(a.tabbableGroups,function(e){return t===e.firstTabbableNode});if(g<0&&(c.container===t||x(t,o.tabbableOptions)&&!w(t,o.tabbableOptions)&&!c.nextTabbableNode(t,!1))&&(g=l),g>=0){var p=a.tabbableGroups[0===g?a.tabbableGroups.length-1:g-1];s=u(t)>=0?p.lastTabbableNode:p.lastDomTabbableNode}else _(n)||(s=c.nextTabbableNode(t,!1))}else{var f=$(a.tabbableGroups,function(e){return t===e.lastTabbableNode});if(f<0&&(c.container===t||x(t,o.tabbableOptions)&&!w(t,o.tabbableOptions)&&!c.nextTabbableNode(t))&&(f=l),f>=0){var m=a.tabbableGroups[f===a.tabbableGroups.length-1?0:f+1];s=u(t)>=0?m.firstTabbableNode:m.firstDomTabbableNode}else _(n)||(s=c.nextTabbableNode(t))}}else s=d("fallbackFocus");return s},I=function(e){var t=C(e);h(t,e)>=0||(S(o.clickOutsideDeactivates,e)?n.deactivate({returnFocus:o.returnFocusOnDeactivate}):S(o.allowOutsideClick,e)||e.preventDefault())},N=function(e){var t=C(e),n=h(t,e)>=0;if(n||t instanceof Document)n&&(a.mostRecentlyFocusedNode=t);else{var r;e.stopImmediatePropagation();var i=!0;if(a.mostRecentlyFocusedNode)if(u(a.mostRecentlyFocusedNode)>0){var s=h(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 u(e)>0})})||(i=!1);else i=!1;i&&(r=O({target:a.mostRecentlyFocusedNode,isBackward:o.isKeyBackward(a.recentNavEvent)})),z(r||a.mostRecentlyFocusedNode||g())}a.recentNavEvent=void 0},P=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!==S(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=O({event:e,isBackward:t});n&&(_(e)&&e.preventDefault(),z(n))}(e,o.isKeyBackward(e))},D=function(e){var t=C(e);h(t,e)>=0||S(o.clickOutsideDeactivates,e)||S(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?T(function(){z(g())}):z(g()),r.addEventListener("focusin",N,!0),r.addEventListener("mousedown",I,{capture:!0,passive:!1}),r.addEventListener("touchstart",I,{capture:!0,passive:!1}),r.addEventListener("click",D,{capture:!0,passive:!1}),r.addEventListener("keydown",P,{capture:!0,passive:!1}),n},B=function(){if(a.active)return r.removeEventListener("focusin",N,!0),r.removeEventListener("mousedown",I,!0),r.removeEventListener("touchstart",I,!0),r.removeEventListener("click",D,!0),r.removeEventListener("keydown",P,!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})})&&z(g())}):void 0,q=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=c(e,"onActivate"),n=c(e,"onPostActivate"),i=c(e,"checkCanFocusTrap");i||y(),a.active=!0,a.paused=!1,a.nodeFocusedBeforeActivation=r.activeElement,null==t||t();var o=function(){i&&y(),F(),q(),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=v({onDeactivate:o.onDeactivate,onPostDeactivate:o.onPostDeactivate,checkCanReturnFocus:o.checkCanReturnFocus},e);clearTimeout(a.delayInitialFocusTimer),a.delayInitialFocusTimer=void 0,B(),a.active=!1,a.paused=!1,q(),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=c(t,"onDeactivate"),s=c(t,"onPostDeactivate"),l=c(t,"checkCanReturnFocus"),u=c(t,"returnFocus","returnFocusOnDeactivate");null==r||r();var h=function(){T(function(){u&&z(L(a.nodeFocusedBeforeActivation)),null==s||s()})};return u&&l?(l(L(a.nodeFocusedBeforeActivation)).then(h,h),this):(h(),this)},pause:function(e){if(a.paused||!a.active)return this;var t=c(e,"onPause"),n=c(e,"onPostPause");return a.paused=!0,null==t||t(),B(),q(),null==n||n(),this},unpause:function(e){if(!a.paused||!a.active)return this;var t=c(e,"onUnpause"),n=c(e,"onPostUnpause");return a.paused=!1,null==t||t(),y(),F(),q(),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&&y(),q(),this}}).updateContainerElements(e),n}(Qt,{initialFocus:"#langchat-chat-widget__input",allowOutsideClick:!0});function Jt(e){if(Gt.closeOnOutsideClick&&document.body.appendChild(Ut),Qt.hasChildNodes())return void en();document.body.appendChild(Qt),Qt.innerHTML=Mt,Qt.style.display="block";const t=document.createElement("span");t.id="langchat-chat-widget__title_text",t.textContent=Gt.widgetTitle,document.getElementById("langchat-chat-widget__title").appendChild(t),document.getElementById("langchat-chat-widget__body").prepend(Kt),Gt.greetingMessage&&0===Kt.children.length&&tn(Gt.greetingMessage,Date.now(),"system");const n=(null==e?void 0:e.target)||document.body;Vt=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=_t(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=st(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:-je(u)+"px "+-je(i.clientWidth-(c+h))+"px "+-je(i.clientHeight-(u+d))+"px "+-je(c)+"px",threshold:Me(0,Be(1,l))||1};let p=!0;function f(e){const t=e[0].intersectionRatio;if(t!==l){if(!p)return a();t?a(!1,t):n=setTimeout(()=>{a(!1,1e-7)},100)}p=!1}try{r=new IntersectionObserver(f,{...g,root:i.ownerDocument})}catch(e){r=new IntersectionObserver(f,g)}r.observe(e)}(!0),o}(c,n):null;let d,g=-1,p=null;a&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===c&&p&&(p.unobserve(t),cancelAnimationFrame(g),g=requestAnimationFrame(()=>{var e;null==(e=p)||e.observe(t)})),n()}),c&&!l&&p.observe(c),p.observe(t));let f=l?$t(e):null;return l&&function t(){const r=$t(e);!f||r.x===f.x&&r.y===f.y&&r.width===f.width&&r.height===f.height||n(),f=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=p)||e.disconnect(),p=null,l&&cancelAnimationFrame(d)}}(n,Qt,()=>{Bt(n,Qt,{placement:"top-start",middleware:[Ft(),Dt({crossAxis:!0,padding:8})],strategy:"fixed"}).then(({x:e,y:t})=>{Object.assign(Qt.style,{left:`${e}px`,top:t-10+"px"})})}),Xt.activate(),Gt.closeOnOutsideClick&&document.getElementById(jt).addEventListener("click",en),document.getElementById("langchat-chat-widget__form").addEventListener("submit",an)}function en(){Xt.deactivate(),Qt.innerHTML="",Qt.remove(),Ut.remove(),Vt(),Vt=()=>{}}async function tn(e,t,n){const 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}`;const i=document.createElement("p");i.innerHTML=await Fe(e,{renderer:Zt}),r.appendChild(i);const o=document.createElement("p");o.classList.add("langchat-chat-widget__message-timestamp"),o.textContent=("0"+new Date(t).getHours()).slice(-2)+":"+("0"+new Date(t).getMinutes()).slice(-2),r.appendChild(o),Kt.prepend(r)}const nn=async e=>{if(e.ok){var t,n;const{message:r,threadId:i}=await e.json();if("string"!=typeof i)return console.error("LangChat Chat Widget: Server error",e),void(Gt.disableErrorAlert||alert(`Received an OK response but "threadId" was of incompatible type (expected 'string', received '${typeof i}'). 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`));if("string"!=typeof r)return console.error("LangChat Chat Widget: Server error",e),void(Gt.disableErrorAlert||alert(`Received an OK response but "message" 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`));if(!r&&""!==r)return console.error("LangChat Chat Widget: Server error",e),void(Gt.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"));await tn(r,Date.now(),"system"),Gt.threadId=null!=(t=null!=(n=Gt.threadId)?n:i)?t:null}else console.error("LangChat Chat Widget: Server error",e),Gt.disableErrorAlert||alert(`Could not send message: ${e.statusText}`)};async function rn(e,t,n){const r=Kt.querySelector(`#langchat-chat-widget__message--${n}--${t}`);r?r.querySelector("p").innerHTML=await Fe(e,{renderer:Zt}):await tn(e,t,n)}const on=async e=>{var t,n;if(!e.body)return console.error("LangChat Chat Widget: Streamed response has no body",e),void(Gt.disableErrorAlert||alert("Received a streamed response but no body was found. Please make sure the API response is configured correctly."));const r=e.headers.get("x-thread-id");let i="",o=!1,a=Date.now();const s=e.body.getReader();for(;;){const{value:e,done:t}=await s.read();if(t||void 0===e)break;const n=(new TextDecoder).decode(e,{stream:!0}).split("\n");for(const e of n){const t=e;if(t.startsWith("data:{")||t.startsWith("{")){let e="";t.startsWith("data:{")&&(e=t.slice(5).trim()),t.startsWith("{")&&(e=t.trim());try{const t=JSON.parse(e).choices[0];if("STOP"===t.finishReason)return void(o=!0);i+=t.delta.content}catch(e){o=!0,console.error("Failed to parse JSON:",e)}}}await rn(i,a,"system")}Gt.threadId=null!=(t=null!=(n=Gt.threadId)?n:r)?t:null};async function an(t){t.preventDefault();const n=t.target;if(!Gt.url)return console.error("LangChat Chat Widget: No URL provided"),void(Gt.disableErrorAlert||alert("Could not send chat message: No URL provided"));const r=document.getElementById("langchat-chat-widget__submit");r.setAttribute("disabled","");const i=new Headers;i.append("Content-Type","application/json"),i.append("Accept","text/event-stream"),i.append("Authorization",`Bearer ${Gt.apiKey}`);const o=n.elements.message.value,a=e({},Gt.user,{messages:[{role:"user",content:o}],threadId:Gt.threadId,timestamp:Date.now()});await tn(o,a.timestamp,"user"),n.reset(),Kt.prepend(Yt);try{let e=await fetch(Gt.url,{method:"POST",headers:i,body:JSON.stringify(a)});Yt.remove(),Gt.responseIsAStream?await on(e):await nn(e)}catch(t){Yt.remove(),console.error("LangChat Chat Widget:",t),Gt.disableErrorAlert||alert(`Could not send message: ${t.message}`)}return r.removeAttribute("disabled"),!1}const sn={open:Jt,close:en,config:Gt,init:Wt};window.langchatChatWidget=sn;export{sn as default};
- //# sourceMappingURL=index.modern.js.map
|