aptolix_chatbot 1.0.12 → 1.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/web.mjs CHANGED
@@ -1,2 +1,2 @@
1
- function e(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var t={async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null};function n(e){t=e}var i={exec:()=>null};function a(e,t=""){let n="string"==typeof e?e:e.source,i={replace:(e,t)=>{let a="string"==typeof t?t:t.source;return a=a.replace(s.caret,"$1"),n=n.replace(e,a),i},getRegex:()=>new RegExp(n,t)};return i}var s={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] /,listReplaceTask:/^\[[ xX]\] +/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/gi,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>new RegExp(`^( {0,3}${e})((?:[\t ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ \t][^\\n]*)?(?:\\n|$))`),hrRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}#`),htmlBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}<(?:[a-z].*>|!--)`,"i")},r=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,o=/(?:[*+-]|\d{1,9}[.)])/,l=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,c=a(l).replace(/bull/g,o).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),p=a(l).replace(/bull/g,o).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),h=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,d=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,u=a(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",d).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),g=a(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,o).getRegex(),m="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",x=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,f=a("^ {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[ \t]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$))","i").replace("comment",x).replace("tag",m).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),b=a(h).replace("hr",r).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",m).getRegex(),w={blockquote:a(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",b).getRegex(),code:/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,def:u,fences:/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,heading:/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,hr:r,html:f,lheading:c,list:g,newline:/^(?:[ \t]*(?:\n|$))+/,paragraph:b,table:i,text:/^[^\n]+/},k=a("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",r).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3}\t)[^\\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",m).getRegex(),y={...w,lheading:p,table:k,paragraph:a(h).replace("hr",r).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",k).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",m).getRegex()},v={...w,html:a("^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:\"[^\"]*\"|'[^']*'|\\s[^'\"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))").replace("comment",x).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:i,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:a(h).replace("hr",r).replace("heading"," *#{1,6} *[^\n]").replace("lheading",c).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},$=/^( {2,}|\\)\n(?!\s*$)/,S=/[\p{P}\p{S}]/u,T=/[\s\p{P}\p{S}]/u,C=/[^\s\p{P}\p{S}]/u,R=a(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,T).getRegex(),L=/(?!~)[\p{P}\p{S}]/u,A=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,_=a(A,"u").replace(/punct/g,S).getRegex(),I=a(A,"u").replace(/punct/g,L).getRegex(),z="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",E=a(z,"gu").replace(/notPunctSpace/g,C).replace(/punctSpace/g,T).replace(/punct/g,S).getRegex(),D=a(z,"gu").replace(/notPunctSpace/g,/(?:[^\s\p{P}\p{S}]|~)/u).replace(/punctSpace/g,/(?!~)[\s\p{P}\p{S}]/u).replace(/punct/g,L).getRegex(),M=a("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,C).replace(/punctSpace/g,T).replace(/punct/g,S).getRegex(),q=a(/\\(punct)/,"gu").replace(/punct/g,S).getRegex(),P=a(/^<(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(),B=a(x).replace("(?:--\x3e|$)","--\x3e").getRegex(),H=a("^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",B).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),U=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`[^`]*`|[^\[\]\\`])*?/,W=a(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",U).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),j=a(/^!?\[(label)\]\[(ref)\]/).replace("label",U).replace("ref",d).getRegex(),N=a(/^!?\[(ref)\](?:\[\])?/).replace("ref",d).getRegex(),Z={_backpedal:i,anyPunctuation:q,autolink:P,blockSkip:/\[[^\[\]]*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)|`[^`]*?`|<(?! )[^<>]*?>/g,br:$,code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,del:i,emStrongLDelim:_,emStrongRDelimAst:E,emStrongRDelimUnd:M,escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,link:W,nolink:N,punctuation:R,reflink:j,reflinkSearch:a("reflink|nolink(?!\\()","g").replace("reflink",j).replace("nolink",N).getRegex(),tag:H,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,url:i},O={...Z,link:a(/^!?\[(label)\]\((.*?)\)/).replace("label",U).getRegex(),reflink:a(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",U).getRegex()},F={...Z,emStrongRDelimAst:D,emStrongLDelim:I,url:a(/^((?: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\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.!#$%&'*+\/=?_`{\|}~-]+@)))/},Q={...F,br:a($).replace("{2,}","*").getRegex(),text:a(F.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},G={normal:w,gfm:y,pedantic:v},V={normal:Z,gfm:F,breaks:Q,pedantic:O},Y={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},J=e=>Y[e];function X(e,t){if(t){if(s.escapeTest.test(e))return e.replace(s.escapeReplace,J)}else if(s.escapeTestNoEncode.test(e))return e.replace(s.escapeReplaceNoEncode,J);return e}function K(e){try{e=encodeURI(e).replace(s.percentDecode,"%")}catch{return null}return e}function ee(e,t){let n=e.replace(s.findPipe,(e,t,n)=>{let i=!1,a=t;for(;--a>=0&&"\\"===n[a];)i=!i;return i?"|":" |"}).split(s.splitPipe),i=0;if(n[0].trim()||n.shift(),n.length>0&&!n.at(-1)?.trim()&&n.pop(),t)if(n.length>t)n.splice(t);else for(;n.length<t;)n.push("");for(;i<n.length;i++)n[i]=n[i].trim().replace(s.slashPipe,"|");return n}function te(e,t,n){let i=e.length;if(0===i)return"";let a=0;for(;a<i;){let s=e.charAt(i-a-1);if(s!==t||n){if(s===t||!n)break;a++}else a++}return e.slice(0,i-a)}function ne(e,t,n,i,a){let s=t.href,r=t.title||null,o=e[1].replace(a.other.outputLinkReplace,"$1");i.state.inLink=!0;let l={type:"!"===e[0].charAt(0)?"image":"link",raw:n,href:s,title:r,text:o,tokens:i.inlineTokens(o)};return i.state.inLink=!1,l}var ie=class{options;rules;lexer;constructor(e){this.options=e||t}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let e=t[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:t[0],codeBlockStyle:"indented",text:this.options.pedantic?e:te(e,"\n")}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let e=t[0],n=function(e,t,n){let i=e.match(n.other.indentCodeCompensation);if(null===i)return t;let a=i[1];return t.split("\n").map(e=>{let t=e.match(n.other.beginningSpace);if(null===t)return e;let[i]=t;return i.length>=a.length?e.slice(a.length):e}).join("\n")}(e,t[3]||"",this.rules);return{type:"code",raw:e,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:n}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let e=t[2].trim();if(this.rules.other.endingHash.test(e)){let t=te(e,"#");(this.options.pedantic||!t||this.rules.other.endingSpaceChar.test(t))&&(e=t.trim())}return{type:"heading",raw:t[0],depth:t[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:te(t[0],"\n")}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let e=te(t[0],"\n").split("\n"),n="",i="",a=[];for(;e.length>0;){let t,s=!1,r=[];for(t=0;t<e.length;t++)if(this.rules.other.blockquoteStart.test(e[t]))r.push(e[t]),s=!0;else{if(s)break;r.push(e[t])}e=e.slice(t);let o=r.join("\n"),l=o.replace(this.rules.other.blockquoteSetextReplace,"\n $1").replace(this.rules.other.blockquoteSetextReplace2,"");n=n?`${n}\n${o}`:o,i=i?`${i}\n${l}`:l;let c=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(l,a,!0),this.lexer.state.top=c,0===e.length)break;let p=a.at(-1);if("code"===p?.type)break;if("blockquote"===p?.type){let t=p,s=t.raw+"\n"+e.join("\n"),r=this.blockquote(s);a[a.length-1]=r,n=n.substring(0,n.length-t.raw.length)+r.raw,i=i.substring(0,i.length-t.text.length)+r.text;break}if("list"===p?.type){let t=p,s=t.raw+"\n"+e.join("\n"),r=this.list(s);a[a.length-1]=r,n=n.substring(0,n.length-p.raw.length)+r.raw,i=i.substring(0,i.length-t.raw.length)+r.raw,e=s.substring(a.at(-1).raw.length).split("\n");continue}}return{type:"blockquote",raw:n,tokens:a,text:i}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim(),i=n.length>1,a={type:"list",raw:"",ordered:i,start:i?+n.slice(0,-1):"",loose:!1,items:[]};n=i?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=i?n:"[*+-]");let s=this.rules.other.listItemRegex(n),r=!1;for(;e;){let n=!1,i="",o="";if(!(t=s.exec(e))||this.rules.block.hr.test(e))break;i=t[0],e=e.substring(i.length);let l=t[2].split("\n",1)[0].replace(this.rules.other.listReplaceTabs,e=>" ".repeat(3*e.length)),c=e.split("\n",1)[0],p=!l.trim(),h=0;if(this.options.pedantic?(h=2,o=l.trimStart()):p?h=t[1].length+1:(h=t[2].search(this.rules.other.nonSpaceChar),h=h>4?1:h,o=l.slice(h),h+=t[1].length),p&&this.rules.other.blankLine.test(c)&&(i+=c+"\n",e=e.substring(c.length+1),n=!0),!n){let t=this.rules.other.nextBulletRegex(h),n=this.rules.other.hrRegex(h),a=this.rules.other.fencesBeginRegex(h),s=this.rules.other.headingBeginRegex(h),r=this.rules.other.htmlBeginRegex(h);for(;e;){let d,u=e.split("\n",1)[0];if(c=u,this.options.pedantic?(c=c.replace(this.rules.other.listReplaceNesting," "),d=c):d=c.replace(this.rules.other.tabCharGlobal," "),a.test(c)||s.test(c)||r.test(c)||t.test(c)||n.test(c))break;if(d.search(this.rules.other.nonSpaceChar)>=h||!c.trim())o+="\n"+d.slice(h);else{if(p||l.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||a.test(l)||s.test(l)||n.test(l))break;o+="\n"+c}!p&&!c.trim()&&(p=!0),i+=u+"\n",e=e.substring(u.length+1),l=d.slice(h)}}a.loose||(r?a.loose=!0:this.rules.other.doubleBlankLine.test(i)&&(r=!0));let d,u=null;this.options.gfm&&(u=this.rules.other.listIsTask.exec(o),u&&(d="[ ] "!==u[0],o=o.replace(this.rules.other.listReplaceTask,""))),a.items.push({type:"list_item",raw:i,task:!!u,checked:d,loose:!1,text:o,tokens:[]}),a.raw+=i}let o=a.items.at(-1);if(!o)return;o.raw=o.raw.trimEnd(),o.text=o.text.trimEnd(),a.raw=a.raw.trimEnd();for(let e=0;e<a.items.length;e++)if(this.lexer.state.top=!1,a.items[e].tokens=this.lexer.blockTokens(a.items[e].text,[]),!a.loose){let t=a.items[e].tokens.filter(e=>"space"===e.type),n=t.length>0&&t.some(e=>this.rules.other.anyLine.test(e.raw));a.loose=n}if(a.loose)for(let e=0;e<a.items.length;e++)a.items[e].loose=!0;return a}}html(e){let 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){let t=this.rules.block.def.exec(e);if(t){let e=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),n=t[2]?t[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",i=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:i}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=ee(t[1]),i=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),a=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split("\n"):[],s={type:"table",raw:t[0],header:[],align:[],rows:[]};if(n.length===i.length){for(let e of i)this.rules.other.tableAlignRight.test(e)?s.align.push("right"):this.rules.other.tableAlignCenter.test(e)?s.align.push("center"):this.rules.other.tableAlignLeft.test(e)?s.align.push("left"):s.align.push(null);for(let e=0;e<n.length;e++)s.header.push({text:n[e],tokens:this.lexer.inline(n[e]),header:!0,align:s.align[e]});for(let e of a)s.rows.push(ee(e,s.header.length).map((e,t)=>({text:e,tokens:this.lexer.inline(e),header:!1,align:s.align[t]})));return s}}lheading(e){let 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){let t=this.rules.block.paragraph.exec(e);if(t){let 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){let 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){let t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.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){let t=this.rules.inline.link.exec(e);if(t){let e=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(e)){if(!this.rules.other.endAngleBracket.test(e))return;let t=te(e.slice(0,-1),"\\");if((e.length-t.length)%2==0)return}else{let e=function(e,t){if(-1===e.indexOf(t[1]))return-1;let n=0;for(let i=0;i<e.length;i++)if("\\"===e[i])i++;else if(e[i]===t[0])n++;else if(e[i]===t[1]&&(n--,n<0))return i;return n>0?-2:-1}(t[2],"()");if(-2===e)return;if(e>-1){let 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],i="";if(this.options.pedantic){let e=this.rules.other.pedanticHrefTitle.exec(n);e&&(n=e[1],i=e[3])}else i=t[3]?t[3].slice(1,-1):"";return n=n.trim(),this.rules.other.startAngleBracket.test(n)&&(n=this.options.pedantic&&!this.rules.other.endAngleBracket.test(e)?n.slice(1):n.slice(1,-1)),ne(t,{href:n&&n.replace(this.rules.inline.anyPunctuation,"$1"),title:i&&i.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let e=t[(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," ").toLowerCase()];if(!e){let e=n[0].charAt(0);return{type:"text",raw:e,text:e}}return ne(n,e,n[0],this.lexer,this.rules)}}emStrong(e,t,n=""){let i=this.rules.inline.emStrongLDelim.exec(e);if(!(!i||i[3]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!i[1]&&!i[2]||!n||this.rules.inline.punctuation.exec(n))){let n,a,s=[...i[0]].length-1,r=s,o=0,l="*"===i[0][0]?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(l.lastIndex=0,t=t.slice(-1*e.length+s);null!=(i=l.exec(t));){if(n=i[1]||i[2]||i[3]||i[4]||i[5]||i[6],!n)continue;if(a=[...n].length,i[3]||i[4]){r+=a;continue}if((i[5]||i[6])&&s%3&&!((s+a)%3)){o+=a;continue}if(r-=a,r>0)continue;a=Math.min(a,a+r+o);let t=[...i[0]][0].length,l=e.slice(0,s+i.index+t+a);if(Math.min(s,a)%2){let e=l.slice(1,-1);return{type:"em",raw:l,text:e,tokens:this.lexer.inlineTokens(e)}}let c=l.slice(2,-2);return{type:"strong",raw:l,text:c,tokens:this.lexer.inlineTokens(c)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let e=t[2].replace(this.rules.other.newLineCharGlobal," "),n=this.rules.other.nonSpaceChar.test(e),i=this.rules.other.startingSpaceChar.test(e)&&this.rules.other.endingSpaceChar.test(e);return n&&i&&(e=e.substring(1,e.length-1)),{type:"codespan",raw:t[0],text:e}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e){let 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){let t=this.rules.inline.autolink.exec(e);if(t){let e,n;return"@"===t[2]?(e=t[1],n="mailto:"+e):(e=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=t[0],n="mailto:"+e;else{let i;do{i=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??""}while(i!==t[0]);e=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){let t=this.rules.inline.text.exec(e);if(t){let e=this.lexer.state.inRawBlock;return{type:"text",raw:t[0],text:t[0],escaped:e}}}},ae=class e{tokens;options;state;tokenizer;inlineQueue;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||t,this.options.tokenizer=this.options.tokenizer||new ie,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let n={other:s,block:G.normal,inline:V.normal};this.options.pedantic?(n.block=G.pedantic,n.inline=V.pedantic):this.options.gfm&&(n.block=G.gfm,this.options.breaks?n.inline=V.breaks:n.inline=V.gfm),this.tokenizer.rules=n}static get rules(){return{block:G,inline:V}}static lex(t,n){return new e(n).lex(t)}static lexInline(t,n){return new e(n).inlineTokens(t)}lex(e){e=e.replace(s.carriageReturn,"\n"),this.blockTokens(e,this.tokens);for(let e=0;e<this.inlineQueue.length;e++){let t=this.inlineQueue[e];this.inlineTokens(t.src,t.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],n=!1){for(this.options.pedantic&&(e=e.replace(s.tabCharGlobal," ").replace(s.spaceLine,""));e;){let i;if(this.options.extensions?.block?.some(n=>!!(i=n.call({lexer:this},e,t))&&(e=e.substring(i.raw.length),t.push(i),!0)))continue;if(i=this.tokenizer.space(e)){e=e.substring(i.raw.length);let n=t.at(-1);1===i.raw.length&&void 0!==n?n.raw+="\n":t.push(i);continue}if(i=this.tokenizer.code(e)){e=e.substring(i.raw.length);let n=t.at(-1);"paragraph"===n?.type||"text"===n?.type?(n.raw+=(n.raw.endsWith("\n")?"":"\n")+i.raw,n.text+="\n"+i.text,this.inlineQueue.at(-1).src=n.text):t.push(i);continue}if(i=this.tokenizer.fences(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.heading(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.hr(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.blockquote(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.list(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.html(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.def(e)){e=e.substring(i.raw.length);let n=t.at(-1);"paragraph"===n?.type||"text"===n?.type?(n.raw+=(n.raw.endsWith("\n")?"":"\n")+i.raw,n.text+="\n"+i.raw,this.inlineQueue.at(-1).src=n.text):this.tokens.links[i.tag]||(this.tokens.links[i.tag]={href:i.href,title:i.title},t.push(i));continue}if(i=this.tokenizer.table(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.lheading(e)){e=e.substring(i.raw.length),t.push(i);continue}let a=e;if(this.options.extensions?.startBlock){let t,n=1/0,i=e.slice(1);this.options.extensions.startBlock.forEach(e=>{t=e.call({lexer:this},i),"number"==typeof t&&t>=0&&(n=Math.min(n,t))}),n<1/0&&n>=0&&(a=e.substring(0,n+1))}if(this.state.top&&(i=this.tokenizer.paragraph(a))){let s=t.at(-1);n&&"paragraph"===s?.type?(s.raw+=(s.raw.endsWith("\n")?"":"\n")+i.raw,s.text+="\n"+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=s.text):t.push(i),n=a.length!==e.length,e=e.substring(i.raw.length);continue}if(i=this.tokenizer.text(e)){e=e.substring(i.raw.length);let n=t.at(-1);"text"===n?.type?(n.raw+=(n.raw.endsWith("\n")?"":"\n")+i.raw,n.text+="\n"+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=n.text):t.push(i);continue}if(e){let 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=e,i=null;if(this.tokens.links){let e=Object.keys(this.tokens.links);if(e.length>0)for(;null!=(i=this.tokenizer.rules.inline.reflinkSearch.exec(n));)e.includes(i[0].slice(i[0].lastIndexOf("[")+1,-1))&&(n=n.slice(0,i.index)+"["+"a".repeat(i[0].length-2)+"]"+n.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;null!=(i=this.tokenizer.rules.inline.anyPunctuation.exec(n));)n=n.slice(0,i.index)+"++"+n.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;null!=(i=this.tokenizer.rules.inline.blockSkip.exec(n));)n=n.slice(0,i.index)+"["+"a".repeat(i[0].length-2)+"]"+n.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);let a=!1,s="";for(;e;){let i;if(a||(s=""),a=!1,this.options.extensions?.inline?.some(n=>!!(i=n.call({lexer:this},e,t))&&(e=e.substring(i.raw.length),t.push(i),!0)))continue;if(i=this.tokenizer.escape(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.tag(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.link(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(i.raw.length);let n=t.at(-1);"text"===i.type&&"text"===n?.type?(n.raw+=i.raw,n.text+=i.text):t.push(i);continue}if(i=this.tokenizer.emStrong(e,n,s)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.codespan(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.br(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.del(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.autolink(e)){e=e.substring(i.raw.length),t.push(i);continue}if(!this.state.inLink&&(i=this.tokenizer.url(e))){e=e.substring(i.raw.length),t.push(i);continue}let r=e;if(this.options.extensions?.startInline){let t,n=1/0,i=e.slice(1);this.options.extensions.startInline.forEach(e=>{t=e.call({lexer:this},i),"number"==typeof t&&t>=0&&(n=Math.min(n,t))}),n<1/0&&n>=0&&(r=e.substring(0,n+1))}if(i=this.tokenizer.inlineText(r)){e=e.substring(i.raw.length),"_"!==i.raw.slice(-1)&&(s=i.raw.slice(-1)),a=!0;let n=t.at(-1);"text"===n?.type?(n.raw+=i.raw,n.text+=i.text):t.push(i);continue}if(e){let t="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(t);break}throw new Error(t)}}return t}},se=class{options;parser;constructor(e){this.options=e||t}space(e){return""}code({text:e,lang:t,escaped:n}){let i=(t||"").match(s.notSpaceStart)?.[0],a=e.replace(s.endingNewline,"")+"\n";return i?'<pre><code class="language-'+X(i)+'">'+(n?a:X(a,!0))+"</code></pre>\n":"<pre><code>"+(n?a:X(a,!0))+"</code></pre>\n"}blockquote({tokens:e}){return`<blockquote>\n${this.parser.parse(e)}</blockquote>\n`}html({text:e}){return e}def(e){return""}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>\n`}hr(e){return"<hr>\n"}list(e){let t=e.ordered,n=e.start,i="";for(let t=0;t<e.items.length;t++){let n=e.items[t];i+=this.listitem(n)}let a=t?"ol":"ul";return"<"+a+(t&&1!==n?' start="'+n+'"':"")+">\n"+i+"</"+a+">\n"}listitem(e){let t="";if(e.task){let n=this.checkbox({checked:!!e.checked});e.loose?"paragraph"===e.tokens[0]?.type?(e.tokens[0].text=n+" "+e.tokens[0].text,e.tokens[0].tokens&&e.tokens[0].tokens.length>0&&"text"===e.tokens[0].tokens[0].type&&(e.tokens[0].tokens[0].text=n+" "+X(e.tokens[0].tokens[0].text),e.tokens[0].tokens[0].escaped=!0)):e.tokens.unshift({type:"text",raw:n+" ",text:n+" ",escaped:!0}):t+=n+" "}return t+=this.parser.parse(e.tokens,!!e.loose),`<li>${t}</li>\n`}checkbox({checked:e}){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox">'}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>\n`}table(e){let t="",n="";for(let t=0;t<e.header.length;t++)n+=this.tablecell(e.header[t]);t+=this.tablerow({text:n});let i="";for(let t=0;t<e.rows.length;t++){let a=e.rows[t];n="";for(let e=0;e<a.length;e++)n+=this.tablecell(a[e]);i+=this.tablerow({text:n})}return i&&(i=`<tbody>${i}</tbody>`),"<table>\n<thead>\n"+t+"</thead>\n"+i+"</table>\n"}tablerow({text:e}){return`<tr>\n${e}</tr>\n`}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?"th":"td";return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>\n`}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${X(e,!0)}</code>`}br(e){return"<br>"}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let i=this.parser.parseInline(n),a=K(e);if(null===a)return i;let s='<a href="'+(e=a)+'"';return t&&(s+=' title="'+X(t)+'"'),s+=">"+i+"</a>",s}image({href:e,title:t,text:n,tokens:i}){i&&(n=this.parser.parseInline(i,this.parser.textRenderer));let a=K(e);if(null===a)return X(n);let s=`<img src="${e=a}" alt="${n}"`;return t&&(s+=` title="${X(t)}"`),s+=">",s}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:X(e.text)}},re=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return""+e}image({text:e}){return""+e}br(){return""}},oe=class e{options;renderer;textRenderer;constructor(e){this.options=e||t,this.options.renderer=this.options.renderer||new se,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new re}static parse(t,n){return new e(n).parse(t)}static parseInline(t,n){return new e(n).parseInline(t)}parse(e,t=!0){let n="";for(let i=0;i<e.length;i++){let a=e[i];if(this.options.extensions?.renderers?.[a.type]){let e=a,t=this.options.extensions.renderers[e.type].call({parser:this},e);if(!1!==t||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(e.type)){n+=t||"";continue}}let s=a;switch(s.type){case"space":n+=this.renderer.space(s);continue;case"hr":n+=this.renderer.hr(s);continue;case"heading":n+=this.renderer.heading(s);continue;case"code":n+=this.renderer.code(s);continue;case"table":n+=this.renderer.table(s);continue;case"blockquote":n+=this.renderer.blockquote(s);continue;case"list":n+=this.renderer.list(s);continue;case"html":n+=this.renderer.html(s);continue;case"def":n+=this.renderer.def(s);continue;case"paragraph":n+=this.renderer.paragraph(s);continue;case"text":{let a=s,r=this.renderer.text(a);for(;i+1<e.length&&"text"===e[i+1].type;)a=e[++i],r+="\n"+this.renderer.text(a);n+=t?this.renderer.paragraph({type:"paragraph",raw:r,text:r,tokens:[{type:"text",raw:r,text:r,escaped:!0}]}):r;continue}default:{let e='Token with "'+s.type+'" type was not found.';if(this.options.silent)return console.error(e),"";throw new Error(e)}}}return n}parseInline(e,t=this.renderer){let n="";for(let i=0;i<e.length;i++){let a=e[i];if(this.options.extensions?.renderers?.[a.type]){let e=this.options.extensions.renderers[a.type].call({parser:this},a);if(!1!==e||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(a.type)){n+=e||"";continue}}let s=a;switch(s.type){case"escape":case"text":n+=t.text(s);break;case"html":n+=t.html(s);break;case"link":n+=t.link(s);break;case"image":n+=t.image(s);break;case"strong":n+=t.strong(s);break;case"em":n+=t.em(s);break;case"codespan":n+=t.codespan(s);break;case"br":n+=t.br(s);break;case"del":n+=t.del(s);break;default:{let e='Token with "'+s.type+'" type was not found.';if(this.options.silent)return console.error(e),"";throw new Error(e)}}}return n}},le=class{options;block;constructor(e){this.options=e||t}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}provideLexer(){return this.block?ae.lex:ae.lexInline}provideParser(){return this.block?oe.parse:oe.parseInline}},ce=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.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=oe;Renderer=se;TextRenderer=re;Lexer=ae;Tokenizer=ie;Hooks=le;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(let i of e)switch(n=n.concat(t.call(this,i)),i.type){case"table":{let e=i;for(let i of e.header)n=n.concat(this.walkTokens(i.tokens,t));for(let i of e.rows)for(let e of i)n=n.concat(this.walkTokens(e.tokens,t));break}case"list":{let e=i;n=n.concat(this.walkTokens(e.items,t));break}default:{let e=i;this.defaults.extensions?.childTokens?.[e.type]?this.defaults.extensions.childTokens[e.type].forEach(i=>{let a=e[i].flat(1/0);n=n.concat(this.walkTokens(a,t))}):e.tokens&&(n=n.concat(this.walkTokens(e.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(e=>{let 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){let n=t.renderers[e.name];t.renderers[e.name]=n?function(...t){let i=e.renderer.apply(this,t);return!1===i&&(i=n.apply(this,t)),i}: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'");let 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){let t=this.defaults.renderer||new se(this.defaults);for(let n in e.renderer){if(!(n in t))throw new Error(`renderer '${n}' does not exist`);if(["options","parser"].includes(n))continue;let i=n,a=e.renderer[i],s=t[i];t[i]=(...e)=>{let n=a.apply(t,e);return!1===n&&(n=s.apply(t,e)),n||""}}n.renderer=t}if(e.tokenizer){let t=this.defaults.tokenizer||new ie(this.defaults);for(let n in e.tokenizer){if(!(n in t))throw new Error(`tokenizer '${n}' does not exist`);if(["options","rules","lexer"].includes(n))continue;let i=n,a=e.tokenizer[i],s=t[i];t[i]=(...e)=>{let n=a.apply(t,e);return!1===n&&(n=s.apply(t,e)),n}}n.tokenizer=t}if(e.hooks){let t=this.defaults.hooks||new le;for(let n in e.hooks){if(!(n in t))throw new Error(`hook '${n}' does not exist`);if(["options","block"].includes(n))continue;let i=n,a=e.hooks[i],s=t[i];le.passThroughHooks.has(n)?t[i]=e=>{if(this.defaults.async)return Promise.resolve(a.call(t,e)).then(e=>s.call(t,e));let n=a.call(t,e);return s.call(t,n)}:t[i]=(...e)=>{let n=a.apply(t,e);return!1===n&&(n=s.apply(t,e)),n}}n.hooks=t}if(e.walkTokens){let t=this.defaults.walkTokens,i=e.walkTokens;n.walkTokens=function(e){let n=[];return n.push(i.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 ae.lex(e,t??this.defaults)}parser(e,t){return oe.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let i={...n},a={...this.defaults,...i},s=this.onError(!!a.silent,!!a.async);if(!0===this.defaults.async&&!1===i.async)return s(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof t>"u"||null===t)return s(new Error("marked(): input parameter is undefined or null"));if("string"!=typeof t)return s(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));a.hooks&&(a.hooks.options=a,a.hooks.block=e);let r=a.hooks?a.hooks.provideLexer():e?ae.lex:ae.lexInline,o=a.hooks?a.hooks.provideParser():e?oe.parse:oe.parseInline;if(a.async)return Promise.resolve(a.hooks?a.hooks.preprocess(t):t).then(e=>r(e,a)).then(e=>a.hooks?a.hooks.processAllTokens(e):e).then(e=>a.walkTokens?Promise.all(this.walkTokens(e,a.walkTokens)).then(()=>e):e).then(e=>o(e,a)).then(e=>a.hooks?a.hooks.postprocess(e):e).catch(s);try{a.hooks&&(t=a.hooks.preprocess(t));let e=r(t,a);a.hooks&&(e=a.hooks.processAllTokens(e)),a.walkTokens&&this.walkTokens(e,a.walkTokens);let n=o(e,a);return a.hooks&&(n=a.hooks.postprocess(n)),n}catch(e){return s(e)}}}onError(e,t){return n=>{if(n.message+="\nPlease report this to https://github.com/markedjs/marked.",e){let e="<p>An error occurred:</p><pre>"+X(n.message+"",!0)+"</pre>";return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}};function pe(e,t){return ce.parse(e,t)}pe.options=pe.setOptions=function(e){return ce.setOptions(e),pe.defaults=ce.defaults,n(pe.defaults),pe},pe.getDefaults=e,pe.defaults=t,pe.use=function(...e){return ce.use(...e),pe.defaults=ce.defaults,n(pe.defaults),pe},pe.walkTokens=function(e,t){return ce.walkTokens(e,t)},pe.parseInline=ce.parseInline,pe.Parser=oe,pe.parser=oe.parse,pe.Renderer=se,pe.TextRenderer=re,pe.Lexer=ae,pe.lexer=ae.lex,pe.Tokenizer=ie,pe.Hooks=le,pe.parse=pe,pe.options,pe.setOptions,pe.use,pe.walkTokens,pe.parseInline,oe.parse,ae.lex;!function(e,t){void 0===t&&(t={});var n=t.insertAt;if(e&&"undefined"!=typeof document){var i=document.head||document.getElementsByTagName("head")[0],a=document.createElement("style");a.type="text/css","top"===n&&i.firstChild?i.insertBefore(a,i.firstChild):i.appendChild(a),a.styleSheet?a.styleSheet.cssText=e:a.appendChild(document.createTextNode(e))}}('#aptolix-chat-window{border-radius:16px;border-style:solid;border-width:2.5px;box-sizing:border-box;display:flex;flex-direction:column;font-family:Inter,sans-serif;height:100%;margin:0;max-height:100%;max-width:100%;min-height:0;min-width:0;overflow:hidden;width:100%}#aptolix-chat-header{align-items:center;border-bottom-style:solid;border-bottom-width:2px;color:#fff;display:flex;font-size:1.15rem;font-weight:200;justify-content:space-between;padding:10px 13px}.aptolix-header-title{align-items:center;display:flex;flex:1;flex-direction:row;gap:12px;justify-content:flex-start;min-width:0}.aptolix-company-logo-wrapper{align-items:center;display:flex;flex-shrink:0}.aptolix-bot-name{align-items:center;display:flex;font-family:Inter,-apple-system,BlinkMacSystemFont,Segoe UI,sans-serif;font-size:1rem;font-weight:600;letter-spacing:.01em;line-height:1.2;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.aptolix-header-subtitle{color:#ede9fe;font-size:.95rem;font-weight:400;margin-top:2px}.aptolix-header-actions{align-items:center;display:flex;gap:6px;margin-top:0;position:relative}.aptolix-menu-dropdown{background:#fff;border:1px solid rgba(0,0,0,.08);border-radius:6px;box-shadow:0 2px 8px rgba(0,0,0,.15);display:none;flex-direction:column;gap:0;min-width:120px;overflow:hidden;padding:3px 0;position:absolute;right:0;top:calc(100% + 6px);z-index:1000}.aptolix-menu-dropdown.show{display:flex}.aptolix-menu-item{align-items:center;background:transparent;border:none;color:#4b5563;cursor:pointer;direction:ltr;display:flex;gap:7px;justify-content:flex-start!important;padding:6px 10px;text-align:left!important;transition:background-color .1s ease;white-space:nowrap;width:100%}.aptolix-menu-item:hover{background-color:#f9fafb;color:#1f2937}.aptolix-menu-icon{align-items:center;display:inline-flex;flex-shrink:0;font-size:14px!important;justify-content:flex-start!important;line-height:1;text-align:left!important;width:14px}.aptolix-menu-text{flex:1;font-size:12px!important;font-weight:400;line-height:1.3;text-align:left!important}#aptolix-chat-header button{align-items:center;background:transparent;border:none;border-radius:6px;color:#fff;cursor:pointer;display:flex;font-size:22px;justify-content:center;min-height:20px;min-width:20px;transition:all .2s}#aptolix-chat-header button:hover{background:hsla(0,0%,100%,.15);transform:scale(1.05)}#aptolix-chat-header button:active{background:hsla(0,0%,100%,.25);transform:scale(.95)}.aptolix-header-flex{align-items:center;display:flex;justify-content:space-between;width:100%}#aptolix-chat-messages{display:flex;flex:1 1 auto;flex-direction:column;gap:6px;min-height:120px;overflow-y:auto;padding:18px 16px 16px}.aptolix-footer{align-items:center;background:transparent;display:flex;gap:10px;justify-content:center;min-height:36px;padding:0 8px}.aptolix-footer-separator{color:#d1d5db;font-size:.75rem;opacity:0;transition:opacity .4s ease .1s;user-select:none}.aptolix-footer-separator.show{opacity:1}.aptolix-powered-by{background:transparent;flex:0 0 auto;font-size:.75rem;font-weight:500;letter-spacing:.01em;padding:8px 0;text-align:center;transition:all .3s ease;white-space:nowrap}.aptolix-powered-by .aptolix-link{font-family:inherit;font-weight:600;text-decoration:underline}.aptolix-rating{align-items:center;color:#6b7280;display:flex;flex:0 0 auto;font-size:.75rem;gap:6px;max-width:0;opacity:0;overflow:hidden;transition:max-width .4s ease,opacity .4s ease,visibility .4s ease;visibility:hidden}.aptolix-rating.show{max-width:200px;opacity:1;visibility:visible}.aptolix-rating-label{font-size:.75rem;font-weight:500;white-space:nowrap}.aptolix-stars{align-items:center;display:flex;gap:2px}.star{color:#fbbf24;cursor:pointer;font-size:1.1rem;line-height:1;transition:transform .1s ease;user-select:none}.star:hover{transform:scale(1.1)}#aptolix-chat-input{align-items:center;background:#fff;border-top-style:solid;border-top-width:2px;display:flex;gap:8px;min-height:56px;padding:5px 10px}#aptolix-chat-input input{border:1.5px solid;border-radius:10px;flex:1 1 auto;font-size:1rem;min-width:0;padding:10px 14px;transition:border .2s}#aptolix-chat-input input:focus{outline:none}#aptolix-chat-input button{border:none;border-radius:10px;box-shadow:0 2px 8px rgba(0,0,0,.1);cursor:pointer;flex-shrink:0;font-size:1rem;font-weight:600;padding:8px 18px;transition:background .2s,box-shadow .2s}#aptolix-chat-input button:hover{box-shadow:0 4px 16px rgba(0,0,0,.15)}#aptolix-chat-input button:not(:first-child){background:rgba(167,139,250,.12);border-radius:8px;box-shadow:none;color:#9333ea;font-size:1.1rem;font-weight:500;padding:8px 12px}#aptolix-chat-input button:not(:first-child):hover{background:rgba(167,139,250,.22);color:#4b5563}#aptolix-chat-inputbox{border:1px solid;border-radius:4px;box-sizing:border-box;font-family:inherit;font-size:1rem;max-height:130px;min-height:42px;outline:none;overflow-y:auto;padding:6px 12px;resize:none;transition:border-color .2s;width:100%}.message{align-items:flex-end;display:flex;font-family:Inter,sans-serif;gap:4px;margin-bottom:4px;max-width:88%}.message.user{align-self:flex-end;flex-direction:row-reverse}.message.bot{align-self:flex-start;flex-direction:row}.message-avatar{cursor:pointer;flex-shrink:0;height:16px;opacity:.7;position:relative;transition:opacity .2s;width:16px}.message-avatar:hover{opacity:1}.message-avatar img,.message-avatar svg{border-radius:50%;height:16px;width:16px}.message-sender{background:rgba(0,0,0,.8);border-radius:4px;bottom:100%;color:#fff;font-size:.75rem;font-weight:500;left:0;margin-bottom:4px;opacity:0;padding:4px 8px;pointer-events:none;position:absolute;transition:opacity .2s;white-space:nowrap;z-index:1000}.message-avatar:hover .message-sender{opacity:1}.message.user .message-sender{left:auto;right:0}.message-content{align-items:flex-start;display:flex;flex-direction:column;gap:0;justify-content:flex-start;max-width:100%;min-width:0}.message.user .message-content{align-items:flex-end}.message-text{border-radius:14px;font-weight:500;line-height:1.5;margin-bottom:0;padding:8px 14px;word-break:break-word}.message.user .message-text{border-radius:14px 14px 4px 14px;box-shadow:0 2px 8px rgba(167,139,250,.1)}.message.bot .message-text{border-radius:14px 14px 14px 4px;box-shadow:0 2px 8px rgba(167,139,250,.08);margin-bottom:0}.message-timestamp{align-self:flex-start;background:none;color:#9ca3af;font-size:.7rem;line-height:1.2;margin-top:2px;padding:0 8px;position:relative;z-index:1}.message.user .message-timestamp{align-self:flex-end}.message-text a{text-decoration:underline;word-break:break-all}.message-text b,.message-text strong{font-weight:700}.message-text h1,.message-text h2,.message-text h3{font-size:1.3rem;line-height:1.2;margin:10px 0 6px}.message-text h2{font-size:1.15rem}.message-text h3{font-size:1.05rem}.message-text p{margin:10px 0}.message-text ol,.message-text ul{margin:8px 0 8px 18px;padding-left:18px}.message-text ul{list-style:none;padding-left:0}.message-text ul li{margin-bottom:4px;padding-left:1.3em;position:relative}.message-text ul li:before{background:#9333ea;border-radius:50%;content:"";display:inline-block;height:.5em;left:.3em;position:absolute;top:.7em;width:.5em}.message-text li{margin-bottom:4px}.message-text code,.message-text pre{background:#f3f4f6;border-radius:6px;color:#7c3aed;font-family:Fira Mono,Consolas,Monaco,monospace;font-size:1em;margin:8px 0;padding:4px 10px}.message-text pre{overflow-x:auto;padding:12px 16px}.typing-dots span{animation:blink 1.2s infinite;font-size:1.5em;margin-right:2px;opacity:.5}.typing-dots span:nth-child(2){animation-delay:.2s}.typing-dots span:nth-child(3){animation-delay:.4s}@keyframes blink{0%,to{opacity:.2}50%{opacity:1}}#aptolix-chat-bubble{align-items:center;background:#9333ea;border-radius:50%;bottom:32px;box-shadow:0 6px 24px rgba(167,139,250,.18);color:#fff;cursor:pointer;display:flex;font-size:2rem;height:56px;justify-content:center;position:fixed;right:32px;transition:background .2s,box-shadow .2s;width:56px;z-index:9999}#aptolix-chat-bubble:hover{background:#7c3aed;box-shadow:0 8px 32px rgba(124,62,237,.28)}#aptolix-chat-window.bubble-mode{border-radius:16px;bottom:100px;height:595px;max-height:80vh;min-height:595px;position:fixed;right:32px;width:400px;z-index:9999}#aptolix-chat-window.section-mode{border:2px solid #a78bfa;border-radius:18px;box-shadow:0 4px 24px rgba(167,139,250,.1);height:100%;max-height:100%;max-width:100%;position:static!important;width:100%}#aptolix-chat-window.section-mode #aptolix-chat-header{background:#9333ea;color:#fff}#aptolix-chat-window.section-mode #aptolix-chat-close,#aptolix-chat-window.section-mode #aptolix-chat-expand,#aptolix-chat-window.section-mode~#aptolix-chat-bubble{display:none!important}#aptolix-chat-window.section-mode #aptolix-chat-messages{background:#f6f3ff;padding:20px 18px 18px}@media (max-width:600px){#aptolix-chat-window,#aptolix-chat-window.bubble-mode,#aptolix-chat-window.section-mode{border-radius:12px;left:0;margin:0;max-width:100vw;min-height:180px;padding:0;right:0;width:100vw}#aptolix-chat-header{font-size:1rem;padding:10px 6px 8px}#aptolix-chat-messages{padding:8px 4px 6px}#aptolix-chat-input{padding:6px 2px}#aptolix-chat-expand,#aptolix-chat-window.section-mode #aptolix-chat-close{display:none!important}}.aptolix-retry-btn{background:#ede9fe;border:none;border-radius:6px;color:#7c3aed;cursor:pointer;font-weight:600;margin-top:8px;padding:4px 12px}.aptolix-retry-btn:hover{background:#d8b4fe}.aptolix-hint-bubble{background:#fff;border-radius:8px;bottom:110px;box-shadow:0 2px 8px rgba(0,0,0,.15);color:#333;font-size:1em;max-width:320px;min-width:180px;padding:16px 40px 16px 16px;pointer-events:auto;position:fixed;right:40px;z-index:9999}.aptolix-hint-bubble:after{border-left:10px solid transparent;border-right:10px solid transparent;border-top:12px solid #fff;bottom:-12px;content:"";height:0;position:absolute;right:28px;width:0}');class he{constructor(){this.keys={config:"aptolix_chatbot_config",state:"aptolix_chatbot_state"}}_getState(e){try{const t=`${this.keys.state}_${e}`,n=localStorage.getItem(t);return n?JSON.parse(n):null}catch(e){return null}}_saveState(e,t){try{const n=`${this.keys.state}_${e}`;t.timestamp=Date.now(),localStorage.setItem(n,JSON.stringify(t))}catch(e){}}_isToday(e){const t=new Date,n=new Date(e);return t.getFullYear()===n.getFullYear()&&t.getMonth()===n.getMonth()&&t.getDate()===n.getDate()}_getTodayStart(){const e=new Date;return e.setHours(0,0,0,0),e.getTime()}saveConfig(e,t){try{const n=`${this.keys.config}_${e}`,i={config:t,timestamp:Date.now()};localStorage.setItem(n,JSON.stringify(i))}catch(e){}}getConfig(e){try{const t=`${this.keys.config}_${e}`,n=localStorage.getItem(t);if(!n)return null;return JSON.parse(n).config}catch(e){return null}}clearConfig(e){try{const t=`${this.keys.config}_${e}`;localStorage.removeItem(t)}catch(e){}}hasConfig(e){const t=`${this.keys.config}_${e}`;return null!==localStorage.getItem(t)}saveVisitorId(e,t){try{const n=this._getState(e)||{};n.visitorId=t,this._saveState(e,n)}catch(e){}}getVisitorId(e){try{const t=this._getState(e);return t?.visitorId||null}catch(e){return null}}clearVisitorId(e){try{const t=this._getState(e);t&&(delete t.visitorId,this._saveState(e,t))}catch(e){}}hasVisitorId(e){return null!==this.getVisitorId(e)}saveSessionId(e,t){try{const n=this._getState(e)||{};n.sessionId=t,this._saveState(e,n)}catch(e){}}getSessionId(e){try{const t=this._getState(e);return t?.sessionId||null}catch(e){return null}}clearSessionId(e){try{const t=this._getState(e);t&&(delete t.sessionId,this._saveState(e,t))}catch(e){}}hasSessionId(e){return null!==this.getSessionId(e)}saveChatHistory(e,t,n){try{const t=this._getState(e)||{};t.history={messages:n,timestamp:Date.now()},this._saveState(e,t)}catch(e){}}getChatHistory(e,t){try{const n=this._getState(e);if(!n?.history)return null;const{history:i}=n;return n.sessionId!==t?null:this._isToday(i.timestamp)?i.messages:(this.clearChatHistory(e,t),null)}catch(e){return null}}clearChatHistory(e,t){try{const n=this._getState(e);n?.history&&n.sessionId===t&&(delete n.history,this._saveState(e,n))}catch(e){}}hasChatHistory(e,t){return null!==this.getChatHistory(e,t)}setUsageLimitReached(e,t,n){try{const t=this._getState(e)||{};t.usageLimitReached={limitReachedDate:n,timestamp:Date.now()},this._saveState(e,t)}catch(e){}}getUsageLimitReached(e,t){try{const n=this._getState(e);if(!n?.usageLimitReached)return null;const{usageLimitReached:i}=n;let a;a=10!==i.limitReachedDate.length||i.limitReachedDate.includes("T")?new Date(i.limitReachedDate):new Date(i.limitReachedDate+"T23:59:59.999Z");return new Date>a?(this.clearUsageLimitReached(e,t),null):{limitReachedDate:i.limitReachedDate,timestamp:i.timestamp}}catch(e){return null}}clearUsageLimitReached(e,t){try{const t=this._getState(e);t&&(delete t.usageLimitReached,this._saveState(e,t))}catch(e){}}hasUsageLimitReached(e,t){return null!==this.getUsageLimitReached(e,t)}clearAll(e,t=null,n=null){this.clearConfig(e);try{const t=`${this.keys.state}_${e}`;localStorage.removeItem(t)}catch(e){}}}const de={mode:"bubble",botname:"AI Assistant",widgetIcon:"💬",companyLogoBlack:'\n <svg width="24" height="32" viewBox="0 0 81 52" fill="none" xmlns="http://www.w3.org/2000/svg">\n <rect x="34.8" y="0" width="46" height="11.7" rx="5.9" fill="#000"/>\n <rect x="0.2" y="19.7" width="80.6" height="12" rx="6" fill="#000"/>\n <rect x="61.7" y="39.4" width="19" height="11.7" rx="6" fill="#000"/>\n <rect x="7.7" y="39.5" width="49" height="11.7" rx="6" fill="#000"/>\n </svg>\n ',companyLogoWhite:'\n <svg width="24" height="32" viewBox="0 0 81 52" fill="none" xmlns="http://www.w3.org/2000/svg">\n <rect x="34.8" y="0" width="46" height="11.7" rx="5.9" fill="#fcfcfcff"/>\n <rect x="0.2" y="19.7" width="80.6" height="12" rx="6" fill="#fcfcfcff"/>\n <rect x="61.7" y="39.4" width="19" height="11.7" rx="6" fill="#fcfcfcff"/>\n <rect x="7.7" y="39.5" width="49" height="11.7" rx="6" fill="#fcfcfcff"/>\n </svg>\n ',botAvatar:'\n <svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">\n <circle cx="20" cy="20" r="18" fill="#9333ea"/>\n <rect x="12" y="14" width="6" height="6" rx="1" fill="#fff"/>\n <rect x="22" y="14" width="6" height="6" rx="1" fill="#fff"/>\n <rect x="13" y="26" width="14" height="4" rx="2" fill="#fff"/>\n </svg>\n ',userAvatar:'\n <svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">\n <circle cx="20" cy="20" r="20" fill="#64748b"/>\n <circle cx="20" cy="15" r="6" fill="#fff"/>\n <path d="M 8 35 Q 8 25 20 25 Q 32 25 32 35" fill="#fff"/>\n </svg>\n ',username:"You",botaccentColor:"#4a57e2ff",floatingWelcomeMessage:"Hello! Looking for something? I'm here to assist - just ask!",floatingWelcomeDelay:2,greetingMessage:"Welcome! Let me know if you have any questions.",allowDownloadTranscript:!0,allowExpandChatWindow:!0,allowFullPageChat:!1,inputCharLimit:350,allowRating:!0,ratingThreshold:3,ratingInterval:4};function ue(e){return!(!e||"string"!=typeof e)&&(!!(e.includes("<svg")||e.includes("<")&&e.includes(">"))||e.trim().length>0&&e.length<=100)}async function ge(e,t){const n=new he;if(e&&t){const i=await async function(e,t){try{const i=await fetch(`${e}/chatbot/${t}/appearance`,{method:"GET",headers:{"Content-Type":"application/json"}});if(!i.ok)return null;return(n=await i.json())?{botname:n.bot_name,widgetIcon:n.widget_icon,companyLogo:n.company_logo,botAvatar:n.bot_avatar,userAvatar:n.user_avatar,username:n.username,botaccentColor:n.accent_color,floatingWelcomeMessage:n.floating_welcome_message,floatingWelcomeDelay:n.floating_welcome_delay,greetingMessage:n.greeting_message,allowDownloadTranscript:n.download_transcript,allowExpandChatWindow:n.expand_chat_window,allowFullPageChat:n.full_page_chat,inputCharLimit:n.input_char_limit,allowRating:n.allow_rating,ratingThreshold:n.rating_threshold,ratingInterval:n.rating_interval}:null}catch(e){return null}var n}(e,t);if(i)return i.widgetIcon&&ue(i.widgetIcon)||(i.widgetIcon=de.widgetIcon),n.saveConfig(t,i),i;{const e=n.getConfig(t);return e?(e.widgetIcon&&ue(e.widgetIcon)||(e.widgetIcon=de.widgetIcon),e):null}}return null}const me={init:async({apiHost:e,chatbotId:t,botname:n,widgetIcon:i,companyLogo:a,companyLogoUrl:s,botAvatar:r,botavatarUrl:o,botaccentColor:l,floatingWelcomeMessage:c,floatingWelcomeDelay:p,greetingMessage:h,allowDownloadTranscript:d,allowExpandChatWindow:u,allowFullPageChat:g,inputCharLimit:m,allowRating:x,ratingThreshold:f,ratingInterval:b,mode:w="bubble",target:k})=>{if(!e||!t)return void console.error("apiHost and chatbotId are mandatory parameters");const y=await ge(e,t),v={botname:n||y?.botname||de.botname,widgetIcon:i||y?.widgetIcon||de.widgetIcon,companyLogo:a||y?.companyLogo||de.companyLogo,companyLogoUrl:s||y?.companyLogoUrl||"",botAvatar:r||y?.botAvatar||de.botAvatar,botavatarUrl:o||y?.botavatarUrl||"",userAvatar:y?.userAvatar||de.userAvatar,username:y?.username||de.username,botaccentColor:l||y?.botaccentColor||de.botaccentColor,floatingWelcomeMessage:c||y?.floatingWelcomeMessage||de.floatingWelcomeMessage,floatingWelcomeDelay:p||y?.floatingWelcomeDelay||de.floatingWelcomeDelay,greetingMessage:h||y?.greetingMessage||de.greetingMessage,allowDownloadTranscript:void 0!==d?d:void 0!==y?.allowDownloadTranscript?y.allowDownloadTranscript:de.allowDownloadTranscript,allowExpandChatWindow:void 0!==u?u:void 0!==y?.allowExpandChatWindow?y.allowExpandChatWindow:de.allowExpandChatWindow,allowFullPageChat:void 0!==g?g:void 0!==y?.allowFullPageChat?y.allowFullPageChat:de.allowFullPageChat,inputCharLimit:m||y?.inputCharLimit||de.inputCharLimit,allowRating:void 0!==x?x:void 0!==y?.allowRating?y.allowRating:de.allowRating,ratingThreshold:f||y?.ratingThreshold||de.ratingThreshold,ratingInterval:b||y?.ratingInterval||de.ratingInterval,mode:w||de.mode,target:k},$=e=>!(!e||"string"!=typeof e)&&/^https?:\/\/.+/.test(e.trim()),S=async e=>new Promise(t=>{const n=new Image,i=setTimeout(()=>{n.src="",t(!1)},3e3);n.onload=()=>{clearTimeout(i),t(!0)},n.onerror=()=>{clearTimeout(i),t(!1)},n.src=e}),T=e=>{if(!e||"string"!=typeof e)return!1;if(!/^\s*<svg[\s\S]*<\/svg>\s*$/i.test(e))return!1;try{const t=(new DOMParser).parseFromString(e,"image/svg+xml");return!t.querySelector("parsererror")}catch(e){return!1}},C=(e=>{const t=e=>{const t=e.replace("#","").substring(0,6),n=/^([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);return n?{r:parseInt(n[1],16),g:parseInt(n[2],16),b:parseInt(n[3],16)}:null},n=(e,n)=>{const i=t(e);if(!i)return e;const a=Math.min(255,Math.round(i.r+(255-i.r)*n)),s=Math.min(255,Math.round(i.g+(255-i.g)*n)),r=Math.min(255,Math.round(i.b+(255-i.b)*n));return`#${a.toString(16).padStart(2,"0")}${s.toString(16).padStart(2,"0")}${r.toString(16).padStart(2,"0")}`},i=(e,n)=>{const i=t(e);if(!i)return e;const a=Math.max(0,Math.round(i.r*(1-n))),s=Math.max(0,Math.round(i.g*(1-n))),r=Math.max(0,Math.round(i.b*(1-n)));return`#${a.toString(16).padStart(2,"0")}${s.toString(16).padStart(2,"0")}${r.toString(16).padStart(2,"0")}`},a=(e,n)=>{const i=t(e);return i?`rgba(${i.r}, ${i.g}, ${i.b}, ${n})`:e},s=(e=>{let n,i,a;if(e.startsWith("#")){const s=t(e);if(!s)return!1;n=s.r,i=s.g,a=s.b}else{if(!e.startsWith("rgb"))return!1;{const t=e.match(/\d+/g);[n,i,a]=t.map(Number)}}return(.299*n+.587*i+.114*a)/255>.5})(e);return{primary:e,isLight:s,header:{background:e,text:s?"#1f2937":"#ffffff",button:s?"#374151":"#ffffff",border:n(e,.85)},messages:{userBackground:e,userText:s?"#1f2937":"#ffffff",botBackground:n(e,.85),botText:"#4b5563",link:i(e,.1),timestamp:"#9ca3af"},window:{background:n(e,.95),border:s?i(e,.2):n(e,.3),shadow:a(e,.15)},input:{background:"#ffffff",border:n(e,.85),text:"#1f2937",placeholder:"#9ca3af",buttonBackground:e,buttonText:s?"#1f2937":"#ffffff"},footer:{text:s?i(e,.3):n(e,.2),link:i(e,.1)},bubble:{background:e,icon:s?"#1f2937":"#ffffff"},hint:{background:"#ffffff",text:"#1f2937",border:n(e,.85),closeButton:e},menu:{background:"#ffffff",text:"#1f2937",hover:n(e,.9),border:"#e5e7eb"},rating:{star:"#fbbf24",text:"#6b7280"},utils:{lighten:n,darken:i,addAlpha:a,hexToRgb:t}}})(v.botaccentColor),R=C.messages.userBackground,L=C.messages.userText,A=C.messages.botBackground,_=C.messages.botText,I=C.messages.link,z=C.header.text,E=C.header.button,D=C.input.buttonText,M=C.window.border,q=C.window.background,P=C.input.border,B=C.header.border,H=C.footer.text,U=C.window.shadow,W=a||y?.companyLogo;let j=W,N=!1;if(W&&$(W)){await S(W)||(N=!0)}else W&&!T(W)&&(N=!0);v.companyLogo=N?null:j;const Z=v.botAvatar;let O=Z,F=!1;if(Z&&$(Z)){await S(Z)||(F=!0)}else Z&&!T(Z)&&(F=!0);v.botAvatar=F?null:O;const Q="section"===v.mode?"section-mode":"bubble-mode",G=document.createElement("div");let V,Y,J;if("bubble"===v.mode){V=document.createElement("div"),V.id="aptolix-chat-bubble",V.style.backgroundColor=v.botaccentColor;const e=v.widgetIcon||de.widgetIcon;e.includes("<svg")||e.includes("<")&&e.includes(">")?V.innerHTML=e:V.innerText=e,document.body.appendChild(V);const t=document.getElementById("aptolix-chat-hint-bubble");t&&t.remove(),J=document.createElement("div"),J.id="aptolix-chat-hint-bubble",J.className="aptolix-hint-bubble",J.style.display="none",J.style.position="fixed",J.style.right="40px",J.style.bottom="110px",J.style.zIndex="9999";const n=document.createElement("span");n.textContent=v.floatingWelcomeMessage;const i=document.createElement("button");i.id="aptolix-hint-close",i.title="Close",i.setAttribute("aria-label","Close"),i.innerHTML="&#10005;",i.style.background="none",i.style.border="none",i.style.color=v.botaccentColor,i.style.fontSize="1.3em",i.style.position="absolute",i.style.top="8px",i.style.right="12px",i.style.cursor="pointer",i.style.padding="0",i.addEventListener("click",()=>{J.style.display="none",sessionStorage.setItem("aptolixHintClosed","true"),clearTimeout(Y)}),J.appendChild(n),J.appendChild(i),document.body.appendChild(J),Y=setTimeout(()=>{"none"!==G.style.display||sessionStorage.getItem("aptolixHintClosed")||(J.style.display="block")},1e3*v.floatingWelcomeDelay),V.addEventListener("click",()=>{J.style.display="none",clearTimeout(Y)}),G.addEventListener("transitionstart",()=>{J.style.display="none",clearTimeout(Y)})}if(G.id="aptolix-chat-window",G.classList.add(Q),G.style.display="section"===v.mode?"flex":"none",G.style.backgroundColor=q,G.style.borderColor=M,G.style.boxShadow=`0 4px 20px ${U}`,"section"===v.mode&&v.target){const e="string"==typeof v.target?document.querySelector(v.target):v.target;e?e.appendChild(G):document.body.appendChild(G)}else document.body.appendChild(G);let X="";if(v.companyLogo){X=/^https?:\/\//.test(v.companyLogo)?`<img src="${v.companyLogo}" alt="Company Logo" class="aptolix-company-logo" style="max-width:40px;max-height:40px;" />`:v.companyLogo}const K=v.botAvatar&&/^https?:\/\//.test(v.botAvatar)?`<img src="${v.botAvatar}" alt="Bot Avatar" style="width:40px;height:40px;border-radius:50%;" />`:v.botAvatar||de.botAvatar,ee=v.userAvatar&&/^https?:\/\//.test(v.userAvatar)?`<img src="${v.userAvatar}" alt="User Avatar" style="width:40px;height:40px;border-radius:50%;" />`:v.userAvatar||de.userAvatar,te=`https://aptolix.com?utm_source=${encodeURIComponent(window.location.hostname)}&utm_medium=${encodeURIComponent("widget")}&utm_campaign=${encodeURIComponent("refback")}`;G.innerHTML=`\n <div id="aptolix-chat-header" style="background-color: ${v.botaccentColor}; color: ${z}; border-bottom: 2px solid ${B};">\n <div class="aptolix-header-flex">\n <div class="aptolix-header-title">\n ${X?`<div class="aptolix-company-logo-wrapper">${X}</div>`:""}\n <strong class="aptolix-bot-name">${v.botname}</strong>\n </div>\n <div class="aptolix-header-actions">\n <button id="aptolix-chat-menu" title="More options" aria-label="More options" style="color: ${E};">⋮</button>\n ${v.allowExpandChatWindow?`<button id="aptolix-chat-expand" title="Expand/Collapse" aria-label="Expand/Collapse" style="color: ${E};">\n <span id="aptolix-chat-expand-icon">⤢</span>\n </button>`:""}\n <button id="aptolix-chat-close" title="Close chat" aria-label="Close chat" style="color: ${E};">×</button>\n <div id="aptolix-chat-menu-dropdown" class="aptolix-menu-dropdown">\n <button id="aptolix-chat-reset" class="aptolix-menu-item" title="Reset chat" aria-label="Reset chat">\n <span class="aptolix-menu-icon">⟲</span>\n <span class="aptolix-menu-text">Reset Chat</span>\n </button>\n ${v.allowDownloadTranscript?'<button id="aptolix-chat-download" class="aptolix-menu-item" title="Download chat" aria-label="Download chat">\n <span class="aptolix-menu-icon">⤓</span>\n <span class="aptolix-menu-text">Download Chat</span>\n </button>':""}\n </div>\n </div>\n </div>\n </div>\n <div id="aptolix-chat-messages"></div>\n <div id="aptolix-chat-input" style="border-top: 2px solid ${P};">\n <textarea id="aptolix-chat-inputbox" rows="1" placeholder="Type your message..." style="resize:none"></textarea>\n <button style="background-color: ${v.botaccentColor}; color: ${D};">Send</button>\n </div>\n <div class="aptolix-footer">\n <div class="aptolix-powered-by" id="aptolix-powered-by" style="color: ${H};">\n Powered by <a href="${te}" target="_blank" rel="noopener" class="aptolix-link" style="color: ${v.botaccentColor};">Aptolix</a>\n </div>\n <span class="aptolix-footer-separator" id="aptolix-footer-separator">|</span>\n <div class="aptolix-rating" id="aptolix-rating">\n <span class="aptolix-rating-label">Rate this chat:</span>\n <div class="aptolix-stars" id="aptolix-stars">\n <span class="star" data-rating="1">☆</span>\n <span class="star" data-rating="2">☆</span>\n <span class="star" data-rating="3">☆</span>\n <span class="star" data-rating="4">☆</span>\n <span class="star" data-rating="5">☆</span>\n </div>\n </div>\n </div>\n`;const ne=G.querySelector("#aptolix-chat-close"),ie=G.querySelector("#aptolix-chat-reset"),ae=v.allowExpandChatWindow?G.querySelector("#aptolix-chat-expand"):null,se=v.allowExpandChatWindow?G.querySelector("#aptolix-chat-expand-icon"):null,re=G.querySelector("#aptolix-chat-inputbox"),oe=G.querySelector("#aptolix-chat-input button"),le=G.querySelector("#aptolix-chat-messages"),ce=v.allowDownloadTranscript?G.querySelector("#aptolix-chat-download"):null,ue=G.querySelector("#aptolix-chat-menu"),me=G.querySelector("#aptolix-chat-menu-dropdown");le.style.backgroundColor=C.window.background,re.style.borderColor=C.input.border,re.style.backgroundColor=C.window.background,re.addEventListener("focus",()=>{re.style.borderColor=C.primary}),re.addEventListener("blur",()=>{re.style.borderColor=C.input.border}),me.style.backgroundColor=C.menu.background,me.style.borderColor=C.menu.border,me.style.border=`1px solid ${C.menu.border}`;me.querySelectorAll(".aptolix-menu-item").forEach(e=>{e.style.backgroundColor=C.menu.background,e.style.color=C.menu.text,e.addEventListener("mouseenter",()=>{e.style.backgroundColor=C.menu.hover}),e.addEventListener("mouseleave",()=>{e.style.backgroundColor=C.menu.background})}),ue.addEventListener("click",e=>{e.stopPropagation(),me.classList.toggle("show")}),document.addEventListener("click",e=>{ue.contains(e.target)||me.contains(e.target)||me.classList.remove("show")});const xe=G.querySelectorAll(".star");xe.forEach(e=>{e.addEventListener("mouseenter",e=>{const t=parseInt(e.target.getAttribute("data-rating"));xe.forEach((e,n)=>{e.textContent=n<t?"★":"☆"})}),e.addEventListener("click",e=>{const t=parseInt(e.target.getAttribute("data-rating"));_e(t)})});const fe=G.querySelector("#aptolix-stars");fe&&fe.addEventListener("mouseleave",()=>{xe.forEach(e=>e.textContent="☆")});const be=e=>{const t=Date.now(),n=Math.floor((t-e)/1e3);if(n<10)return"just now";if(n<60)return`${n} secs ago`;if(n<3600){const e=Math.floor(n/60);return 1===e?"1 min ago":`${e} mins ago`}if(n<86400){const e=Math.floor(n/3600);return 1===e?"1 hour ago":`${e} hours ago`}const i=Math.floor(n/86400);return 1===i?"1 day ago":`${i} days ago`};setInterval(()=>{le.querySelectorAll(".message-timestamp").forEach(e=>{const t=parseInt(e.getAttribute("data-timestamp"));e.textContent=be(t)})},6e4);const we=()=>{le.querySelectorAll(".message-text a").forEach(e=>{e.style.color=I});le.querySelectorAll(".message.user .message-text").forEach(e=>{e.style.backgroundColor=R,e.style.color=L});le.querySelectorAll(".message.bot .message-text").forEach(e=>{e.style.backgroundColor=A,e.style.color=_})},ke=new he;let ye=ke.getVisitorId(t),ve=ke.getSessionId(t),$e=0,Se=0,Te=!1;const Ce=()=>{if(!ve)return;const e=Array.from(le.querySelectorAll(".message:not(.typing):not(.error)")).map(e=>{const t=e.classList.contains("user"),n=e.classList.contains("greeting"),i=e.querySelector(".message-text"),a=e.querySelector(".message-timestamp");return{type:t?"user":"bot",text:i?i.innerHTML:"",timestamp:a?parseInt(a.getAttribute("data-timestamp")):Date.now(),isGreeting:n}});ke.saveChatHistory(t,ve,e)},Re=e=>{const t=(e=>{let t;t=10!==e.length||e.includes("T")?new Date(e):new Date(e+"T23:59:59.999Z");const n=t-new Date;if(n<=0)return"0 minutes";const i=Math.ceil(n/6e4),a=Math.floor(i/60),s=i%60;return a>0&&s>0?`${a} hour${1!==a?"s":""} and ${s} minute${1!==s?"s":""}`:a>0?`${a} hour${1!==a?"s":""}`:`${s} minute${1!==s?"s":""}`})(e),n=G.querySelector(".aptolix-limit-warning");n&&n.remove();const i=document.createElement("div");i.className="aptolix-limit-warning",i.style.cssText="\n background: linear-gradient(135deg, #fef3c7 0%, #fed7aa 100%);\n border-top: 2px solid #f59e0b;\n border-bottom: 2px solid #f59e0b;\n color: #92400e;\n padding: 6px 12px;\n font-size: 12px;\n line-height: 1.3;\n font-weight: 500;\n display: flex;\n align-items: center;\n gap: 6px;\n ",i.innerHTML=`\n <span style="font-size: 14px;">⚠️</span>\n <span>Usage limit reached. Try again in ${t}.</span>\n `;const a=G.querySelector("#aptolix-chat-input");a.parentNode.insertBefore(i,a),re.disabled=!0,re.placeholder="Chat unavailable",re.style.cursor="not-allowed",oe.disabled=!0,oe.style.opacity="0.5",oe.style.cursor="not-allowed"},Le=()=>{re.disabled=!1,re.placeholder="Type your message...",re.style.cursor="text",oe.disabled=!1,oe.style.opacity="1",oe.style.cursor="pointer";const e=G.querySelector(".aptolix-limit-warning");e&&e.remove()},Ae=(e=!1)=>{const t=G.querySelector("#aptolix-powered-by"),n=G.querySelector("#aptolix-rating"),i=G.querySelector("#aptolix-footer-separator");if(t&&n&&i)if(e){const e=t.innerHTML;t.innerHTML="✓ Thanks for your feedback!",i.classList.remove("show"),n.classList.remove("show"),setTimeout(()=>{t.innerHTML=e,Te=!1},2e3)}else i.classList.remove("show"),n.classList.remove("show"),setTimeout(()=>{Te=!1},400)},_e=async n=>{try{if(!ye||!ve)return void Ae(!0);const i={rating:n,visitor_id:ye,session_id:ve};await fetch(`${e}/chatbot/${t}/rating`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)}),Se=$e,Ae(!0)}catch(e){Ae(!0)}},Ie=()=>{if(!v.allowRating)return;$e>=v.ratingThreshold&&$e>=Se+v.ratingInterval&&(()=>{if(!v.allowRating||Te)return;const e=G.querySelector("#aptolix-rating"),t=G.querySelector("#aptolix-footer-separator");e&&t&&(Te=!0,setTimeout(()=>{t.classList.add("show"),e.classList.add("show")},10))})()};async function ze(n=!1,i=null){if(re.disabled&&!n)return;const a=i||re.value.trim();if(!a)return;if(n||(re.value="",re.rows=1,re.style.height="32px",re.style.overflowY="hidden"),!n){const e=document.createElement("div");e.className="message user";const t=Date.now();e.innerHTML=`\n <div class="message-avatar">\n ${ee}\n <div class="message-sender">${v.username}</div>\n </div>\n <div class="message-content">\n <div class="message-text" style="background-color: ${R}; color: ${L};">${a}</div>\n <span class="message-timestamp" data-timestamp="${t}">${be(t)}</span>\n </div>\n `,le.appendChild(e),le.scrollTop=le.scrollHeight,Ce()}const s=document.createElement("div");s.className="message bot typing",s.innerHTML='<span class="typing-dots"><span>.</span><span>.</span><span>.</span></span>',le.appendChild(s),le.scrollTop=le.scrollHeight;try{const n={message:a};ye&&(n.visitor_id=ye),ve&&(n.session_id=ve);const i=await fetch(`${e}/chatbot/${t}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)}),r=await i.json();if(r.visitor_id&&(ye=r.visitor_id,ke.saveVisitorId(t,ye)),r.session_id&&(ve=r.session_id,ke.saveSessionId(t,ve)),r.limitReachedDate)return ke.setUsageLimitReached(t,ye,r.limitReachedDate),s.remove(),void Re(r.limitReachedDate);s.remove();const o=document.createElement("div");o.className="message bot";const l=Date.now();o.innerHTML=`\n ${K?`<div class="message-avatar">${K}<div class="message-sender">${v.botname}</div></div>`:""}\n <div class="message-content">\n <div class="message-text" style="background-color: ${A}; color: ${_};">${pe.parse(r.response||r.text||"[No response]")}</div>\n <span class="message-timestamp" data-timestamp="${l}">${be(l)}</span>\n </div>\n `,le.appendChild(o),le.scrollTop=le.scrollHeight,we(),Ce(),$e++,Ie(),"bubble"===v.mode&&"none"===G.style.display&&V.setAttribute("data-unread","true")}catch(e){!function(){s.remove();const e=document.createElement("div");e.className="message bot error",e.innerHTML='\n <div>\n <strong>⚠️ Unable to connect to the assistant.</strong><br>\n Please check your internet connection or try again later.\n </div>\n <button class="aptolix-retry-btn">Retry</button>\n ',le.appendChild(e),le.scrollTop=le.scrollHeight;const t=e.querySelector(".aptolix-retry-btn");t&&t.addEventListener("click",()=>{e.remove(),ze(!0,a)})}(),"bubble"===v.mode&&"none"===G.style.display&&V.setAttribute("data-unread","true")}}"bubble"===v.mode&&ne.addEventListener("click",()=>{G.style.display="none"}),ie.addEventListener("click",()=>{le.innerHTML="",re.value="",ve&&(ke.clearChatHistory(t,ve),ke.clearSessionId(t),ve=null),$e=0,Se=0,Ae(!1),me.classList.remove("show");const e=ye?ke.getUsageLimitReached(t,ye):null;e&&e.limitReachedDate?(De(),Re(e.limitReachedDate)):(De(),Le()),Ce()}),"bubble"===v.mode&&V&&V.addEventListener("click",()=>{const e="none"===G.style.display;if(G.style.display=e?"flex":"none",V.removeAttribute("data-unread"),e){const e=ke.getUsageLimitReached(t,ye);e?Re(e.limitReachedDate):(Le(),De())}}),"bubble"===v.mode&&document.addEventListener("mousedown",function(e){"none"!==G.style.display&&(G.contains(e.target)||V.contains(e.target)||(G.style.display="none"))}),oe.addEventListener("click",()=>ze()),re.addEventListener("keydown",e=>{"Enter"===e.key&&(e.preventDefault(),ze())});let Ee=!1;function De(){const e=ke.getUsageLimitReached(t,ye);if(e)return void Re(e.limitReachedDate);Le(),le.querySelectorAll(".message.greeting").forEach(e=>e.remove());const n=v.greetingMessage,i=document.createElement("div");i.className="message bot greeting";const a=Date.now();i.innerHTML=`\n ${K?`<div class="message-avatar">${K}<div class="message-sender">${v.botname}</div></div>`:""}\n <div class="message-content">\n <div class="message-text" style="background-color: ${A}; color: ${_};">${n}</div>\n <span class="message-timestamp" data-timestamp="${a}">${be(a)}</span>\n </div>\n `,le.appendChild(i),le.scrollTop=le.scrollHeight,we()}"bubble"===v.mode&&ae&&ae.addEventListener("click",()=>{Ee=!Ee,Ee?(G.style.width="600px",G.style.height="80vh",se.textContent="⤡"):(G.style.width="400px",G.style.height="595px",se.textContent="⤢")}),setTimeout(function(){if(ye){const e=ke.getUsageLimitReached(t,ye);e&&e.limitReachedDate&&Re(e.limitReachedDate)}if(ve){return(ke.getChatHistory(t,ve)||[]).forEach(e=>{const t=document.createElement("div");t.className=`message ${e.type}${e.isGreeting?" greeting":""}`;const n="user"===e.type?ee:K,i="user"===e.type?v.username:v.botname,a="user"===e.type?R:A,s="user"===e.type?L:_;t.innerHTML="user"===e.type?`<div class="message-avatar">${n}<div class="message-sender">${i}</div></div><div class="message-content"><div class="message-text" style="background-color: ${a}; color: ${s};">${e.text}</div><span class="message-timestamp" data-timestamp="${e.timestamp}">${be(e.timestamp)}</span></div>`:`${n?`<div class="message-avatar">${n}<div class="message-sender">${i}</div></div>`:""}<div class="message-content"><div class="message-text" style="background-color: ${a}; color: ${s};">${e.text}</div><span class="message-timestamp" data-timestamp="${e.timestamp}">${be(e.timestamp)}</span></div>`,le.appendChild(t)}),le.scrollTop=le.scrollHeight,void we()}De()},100),re.addEventListener("input",function(){if(this.disabled)return void(this.value="");if(this.value.length>v.inputCharLimit)return void(this.value=this.value.slice(0,v.inputCharLimit));if(""===this.value)return this.rows=1,this.style.height="32px",void(this.style.overflowY="hidden");const e=this.value.split("\n");this.rows=Math.min(e.length,4);this.style.height="auto",this.style.height=Math.min(this.scrollHeight,108)+"px",this.scrollHeight>108?this.style.overflowY="auto":this.style.overflowY="hidden"}),ce&&ce.addEventListener("click",()=>{me.classList.remove("show");const e=new Date,t=e.toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"}),n=e.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit"}),i=`Chat Transcript - ${v.botname}\nWebsite: ${window.location.href}\nDownloaded on: ${t} at ${n}\n${"=".repeat(60)}\n\n`,a=Array.from(le.querySelectorAll(".message")).map(e=>{const t=e.classList.contains("user")?v.username:v.botname,n=e.querySelector(".message-text"),i=n?n.innerText||n.textContent:"",a=e.querySelector(".message-timestamp");let s="";if(a){const e=parseInt(a.getAttribute("data-timestamp"));s=new Date(e).toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",second:"2-digit"})}return`[${s}] ${t}:\n${i}`}).join("\n\n"),s=new Blob([i+a],{type:"text/plain"}),r=URL.createObjectURL(s),o=document.createElement("a");o.href=r,o.download=`${v.botname}_chat_${e.getTime()}.txt`,document.body.appendChild(o),o.click(),setTimeout(()=>{document.body.removeChild(o),URL.revokeObjectURL(r)},100)})},initFull:function(e){let t=document.querySelector("aptolix-chatbot");t&&Object.entries(e).forEach(([e,n])=>{t.setAttribute(e,n)})}};class xe extends HTMLElement{static get observedAttributes(){return["apihost","chatbotid","botname","widgeticon","companylogo","companylogourl","botavatar","botavatarurl","botaccentcolor","floatingwelcomemessage","floatingwelcomedelay","greetingmessage","allowdownloadtranscript","allowexpandchatwindow","allowfullpagechat","inputcharlimit","target"]}connectedCallback(){this.tryInit()}attributeChangedCallback(){const e=this.querySelector("#aptolix-chat-window");e&&e.remove(),this._initialized=!1,this.tryInit()}tryInit(){const e=this.getAttribute("apihost"),t=this.getAttribute("chatbotid");if(!e||!t)return;const n=this.getAttribute("botname"),i=this.getAttribute("widgeticon"),a=this.getAttribute("companylogo"),s=this.getAttribute("companylogourl"),r=this.getAttribute("botavatar"),o=this.getAttribute("botavatarurl"),l=this.getAttribute("botaccentcolor"),c=this.getAttribute("floatingwelcomemessage"),p=this.getAttribute("floatingwelcomedelay"),h=this.getAttribute("greetingmessage"),d="true"===this.getAttribute("allowdownloadtranscript"),u="true"===this.getAttribute("allowexpandchatwindow"),g="true"===this.getAttribute("allowfullpagechat"),m=parseInt(this.getAttribute("inputcharlimit"))||void 0,x=this.getAttribute("target");let f=this;if(x){const e=document.querySelector(x);e&&(f=e)}this._initialized||(this._initialized=!0,me.init({apiHost:e,chatbotId:t,botname:n,widgetIcon:i,companyLogo:a,companyLogoUrl:s,botAvatar:r,botavatarUrl:o,botaccentColor:l,floatingWelcomeMessage:c,floatingWelcomeDelay:p,greetingMessage:h,allowDownloadTranscript:d,allowExpandChatWindow:u,allowFullPageChat:g,inputCharLimit:m,mode:"section",target:f}))}}customElements.define("aptolix-chatbot",xe);export{me as default};
1
+ function e(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var t={async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null};function n(e){t=e}var i={exec:()=>null};function a(e,t=""){let n="string"==typeof e?e:e.source,i={replace:(e,t)=>{let a="string"==typeof t?t:t.source;return a=a.replace(s.caret,"$1"),n=n.replace(e,a),i},getRegex:()=>new RegExp(n,t)};return i}var s={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] /,listReplaceTask:/^\[[ xX]\] +/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/gi,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>new RegExp(`^( {0,3}${e})((?:[\t ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ \t][^\\n]*)?(?:\\n|$))`),hrRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}#`),htmlBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}<(?:[a-z].*>|!--)`,"i")},r=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,o=/(?:[*+-]|\d{1,9}[.)])/,l=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,c=a(l).replace(/bull/g,o).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),p=a(l).replace(/bull/g,o).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),h=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,d=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,u=a(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",d).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),g=a(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,o).getRegex(),m="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",x=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,f=a("^ {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[ \t]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$))","i").replace("comment",x).replace("tag",m).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),b=a(h).replace("hr",r).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",m).getRegex(),w={blockquote:a(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",b).getRegex(),code:/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,def:u,fences:/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,heading:/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,hr:r,html:f,lheading:c,list:g,newline:/^(?:[ \t]*(?:\n|$))+/,paragraph:b,table:i,text:/^[^\n]+/},k=a("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",r).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3}\t)[^\\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",m).getRegex(),y={...w,lheading:p,table:k,paragraph:a(h).replace("hr",r).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",k).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",m).getRegex()},v={...w,html:a("^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:\"[^\"]*\"|'[^']*'|\\s[^'\"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))").replace("comment",x).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:i,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:a(h).replace("hr",r).replace("heading"," *#{1,6} *[^\n]").replace("lheading",c).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},$=/^( {2,}|\\)\n(?!\s*$)/,S=/[\p{P}\p{S}]/u,T=/[\s\p{P}\p{S}]/u,C=/[^\s\p{P}\p{S}]/u,R=a(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,T).getRegex(),L=/(?!~)[\p{P}\p{S}]/u,A=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,_=a(A,"u").replace(/punct/g,S).getRegex(),I=a(A,"u").replace(/punct/g,L).getRegex(),z="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",E=a(z,"gu").replace(/notPunctSpace/g,C).replace(/punctSpace/g,T).replace(/punct/g,S).getRegex(),D=a(z,"gu").replace(/notPunctSpace/g,/(?:[^\s\p{P}\p{S}]|~)/u).replace(/punctSpace/g,/(?!~)[\s\p{P}\p{S}]/u).replace(/punct/g,L).getRegex(),M=a("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,C).replace(/punctSpace/g,T).replace(/punct/g,S).getRegex(),q=a(/\\(punct)/,"gu").replace(/punct/g,S).getRegex(),P=a(/^<(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(),B=a(x).replace("(?:--\x3e|$)","--\x3e").getRegex(),H=a("^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",B).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),U=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`[^`]*`|[^\[\]\\`])*?/,W=a(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",U).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),j=a(/^!?\[(label)\]\[(ref)\]/).replace("label",U).replace("ref",d).getRegex(),N=a(/^!?\[(ref)\](?:\[\])?/).replace("ref",d).getRegex(),Z={_backpedal:i,anyPunctuation:q,autolink:P,blockSkip:/\[[^\[\]]*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)|`[^`]*?`|<(?! )[^<>]*?>/g,br:$,code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,del:i,emStrongLDelim:_,emStrongRDelimAst:E,emStrongRDelimUnd:M,escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,link:W,nolink:N,punctuation:R,reflink:j,reflinkSearch:a("reflink|nolink(?!\\()","g").replace("reflink",j).replace("nolink",N).getRegex(),tag:H,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,url:i},O={...Z,link:a(/^!?\[(label)\]\((.*?)\)/).replace("label",U).getRegex(),reflink:a(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",U).getRegex()},F={...Z,emStrongRDelimAst:D,emStrongLDelim:I,url:a(/^((?: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\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.!#$%&'*+\/=?_`{\|}~-]+@)))/},Q={...F,br:a($).replace("{2,}","*").getRegex(),text:a(F.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},G={normal:w,gfm:y,pedantic:v},V={normal:Z,gfm:F,breaks:Q,pedantic:O},Y={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},J=e=>Y[e];function X(e,t){if(t){if(s.escapeTest.test(e))return e.replace(s.escapeReplace,J)}else if(s.escapeTestNoEncode.test(e))return e.replace(s.escapeReplaceNoEncode,J);return e}function K(e){try{e=encodeURI(e).replace(s.percentDecode,"%")}catch{return null}return e}function ee(e,t){let n=e.replace(s.findPipe,(e,t,n)=>{let i=!1,a=t;for(;--a>=0&&"\\"===n[a];)i=!i;return i?"|":" |"}).split(s.splitPipe),i=0;if(n[0].trim()||n.shift(),n.length>0&&!n.at(-1)?.trim()&&n.pop(),t)if(n.length>t)n.splice(t);else for(;n.length<t;)n.push("");for(;i<n.length;i++)n[i]=n[i].trim().replace(s.slashPipe,"|");return n}function te(e,t,n){let i=e.length;if(0===i)return"";let a=0;for(;a<i;){let s=e.charAt(i-a-1);if(s!==t||n){if(s===t||!n)break;a++}else a++}return e.slice(0,i-a)}function ne(e,t,n,i,a){let s=t.href,r=t.title||null,o=e[1].replace(a.other.outputLinkReplace,"$1");i.state.inLink=!0;let l={type:"!"===e[0].charAt(0)?"image":"link",raw:n,href:s,title:r,text:o,tokens:i.inlineTokens(o)};return i.state.inLink=!1,l}var ie=class{options;rules;lexer;constructor(e){this.options=e||t}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let e=t[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:t[0],codeBlockStyle:"indented",text:this.options.pedantic?e:te(e,"\n")}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let e=t[0],n=function(e,t,n){let i=e.match(n.other.indentCodeCompensation);if(null===i)return t;let a=i[1];return t.split("\n").map(e=>{let t=e.match(n.other.beginningSpace);if(null===t)return e;let[i]=t;return i.length>=a.length?e.slice(a.length):e}).join("\n")}(e,t[3]||"",this.rules);return{type:"code",raw:e,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:n}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let e=t[2].trim();if(this.rules.other.endingHash.test(e)){let t=te(e,"#");(this.options.pedantic||!t||this.rules.other.endingSpaceChar.test(t))&&(e=t.trim())}return{type:"heading",raw:t[0],depth:t[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:te(t[0],"\n")}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let e=te(t[0],"\n").split("\n"),n="",i="",a=[];for(;e.length>0;){let t,s=!1,r=[];for(t=0;t<e.length;t++)if(this.rules.other.blockquoteStart.test(e[t]))r.push(e[t]),s=!0;else{if(s)break;r.push(e[t])}e=e.slice(t);let o=r.join("\n"),l=o.replace(this.rules.other.blockquoteSetextReplace,"\n $1").replace(this.rules.other.blockquoteSetextReplace2,"");n=n?`${n}\n${o}`:o,i=i?`${i}\n${l}`:l;let c=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(l,a,!0),this.lexer.state.top=c,0===e.length)break;let p=a.at(-1);if("code"===p?.type)break;if("blockquote"===p?.type){let t=p,s=t.raw+"\n"+e.join("\n"),r=this.blockquote(s);a[a.length-1]=r,n=n.substring(0,n.length-t.raw.length)+r.raw,i=i.substring(0,i.length-t.text.length)+r.text;break}if("list"===p?.type){let t=p,s=t.raw+"\n"+e.join("\n"),r=this.list(s);a[a.length-1]=r,n=n.substring(0,n.length-p.raw.length)+r.raw,i=i.substring(0,i.length-t.raw.length)+r.raw,e=s.substring(a.at(-1).raw.length).split("\n");continue}}return{type:"blockquote",raw:n,tokens:a,text:i}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim(),i=n.length>1,a={type:"list",raw:"",ordered:i,start:i?+n.slice(0,-1):"",loose:!1,items:[]};n=i?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=i?n:"[*+-]");let s=this.rules.other.listItemRegex(n),r=!1;for(;e;){let n=!1,i="",o="";if(!(t=s.exec(e))||this.rules.block.hr.test(e))break;i=t[0],e=e.substring(i.length);let l=t[2].split("\n",1)[0].replace(this.rules.other.listReplaceTabs,e=>" ".repeat(3*e.length)),c=e.split("\n",1)[0],p=!l.trim(),h=0;if(this.options.pedantic?(h=2,o=l.trimStart()):p?h=t[1].length+1:(h=t[2].search(this.rules.other.nonSpaceChar),h=h>4?1:h,o=l.slice(h),h+=t[1].length),p&&this.rules.other.blankLine.test(c)&&(i+=c+"\n",e=e.substring(c.length+1),n=!0),!n){let t=this.rules.other.nextBulletRegex(h),n=this.rules.other.hrRegex(h),a=this.rules.other.fencesBeginRegex(h),s=this.rules.other.headingBeginRegex(h),r=this.rules.other.htmlBeginRegex(h);for(;e;){let d,u=e.split("\n",1)[0];if(c=u,this.options.pedantic?(c=c.replace(this.rules.other.listReplaceNesting," "),d=c):d=c.replace(this.rules.other.tabCharGlobal," "),a.test(c)||s.test(c)||r.test(c)||t.test(c)||n.test(c))break;if(d.search(this.rules.other.nonSpaceChar)>=h||!c.trim())o+="\n"+d.slice(h);else{if(p||l.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||a.test(l)||s.test(l)||n.test(l))break;o+="\n"+c}!p&&!c.trim()&&(p=!0),i+=u+"\n",e=e.substring(u.length+1),l=d.slice(h)}}a.loose||(r?a.loose=!0:this.rules.other.doubleBlankLine.test(i)&&(r=!0));let d,u=null;this.options.gfm&&(u=this.rules.other.listIsTask.exec(o),u&&(d="[ ] "!==u[0],o=o.replace(this.rules.other.listReplaceTask,""))),a.items.push({type:"list_item",raw:i,task:!!u,checked:d,loose:!1,text:o,tokens:[]}),a.raw+=i}let o=a.items.at(-1);if(!o)return;o.raw=o.raw.trimEnd(),o.text=o.text.trimEnd(),a.raw=a.raw.trimEnd();for(let e=0;e<a.items.length;e++)if(this.lexer.state.top=!1,a.items[e].tokens=this.lexer.blockTokens(a.items[e].text,[]),!a.loose){let t=a.items[e].tokens.filter(e=>"space"===e.type),n=t.length>0&&t.some(e=>this.rules.other.anyLine.test(e.raw));a.loose=n}if(a.loose)for(let e=0;e<a.items.length;e++)a.items[e].loose=!0;return a}}html(e){let 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){let t=this.rules.block.def.exec(e);if(t){let e=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),n=t[2]?t[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",i=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:i}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=ee(t[1]),i=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),a=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split("\n"):[],s={type:"table",raw:t[0],header:[],align:[],rows:[]};if(n.length===i.length){for(let e of i)this.rules.other.tableAlignRight.test(e)?s.align.push("right"):this.rules.other.tableAlignCenter.test(e)?s.align.push("center"):this.rules.other.tableAlignLeft.test(e)?s.align.push("left"):s.align.push(null);for(let e=0;e<n.length;e++)s.header.push({text:n[e],tokens:this.lexer.inline(n[e]),header:!0,align:s.align[e]});for(let e of a)s.rows.push(ee(e,s.header.length).map((e,t)=>({text:e,tokens:this.lexer.inline(e),header:!1,align:s.align[t]})));return s}}lheading(e){let 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){let t=this.rules.block.paragraph.exec(e);if(t){let 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){let 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){let t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.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){let t=this.rules.inline.link.exec(e);if(t){let e=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(e)){if(!this.rules.other.endAngleBracket.test(e))return;let t=te(e.slice(0,-1),"\\");if((e.length-t.length)%2==0)return}else{let e=function(e,t){if(-1===e.indexOf(t[1]))return-1;let n=0;for(let i=0;i<e.length;i++)if("\\"===e[i])i++;else if(e[i]===t[0])n++;else if(e[i]===t[1]&&(n--,n<0))return i;return n>0?-2:-1}(t[2],"()");if(-2===e)return;if(e>-1){let 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],i="";if(this.options.pedantic){let e=this.rules.other.pedanticHrefTitle.exec(n);e&&(n=e[1],i=e[3])}else i=t[3]?t[3].slice(1,-1):"";return n=n.trim(),this.rules.other.startAngleBracket.test(n)&&(n=this.options.pedantic&&!this.rules.other.endAngleBracket.test(e)?n.slice(1):n.slice(1,-1)),ne(t,{href:n&&n.replace(this.rules.inline.anyPunctuation,"$1"),title:i&&i.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let e=t[(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," ").toLowerCase()];if(!e){let e=n[0].charAt(0);return{type:"text",raw:e,text:e}}return ne(n,e,n[0],this.lexer,this.rules)}}emStrong(e,t,n=""){let i=this.rules.inline.emStrongLDelim.exec(e);if(!(!i||i[3]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!i[1]&&!i[2]||!n||this.rules.inline.punctuation.exec(n))){let n,a,s=[...i[0]].length-1,r=s,o=0,l="*"===i[0][0]?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(l.lastIndex=0,t=t.slice(-1*e.length+s);null!=(i=l.exec(t));){if(n=i[1]||i[2]||i[3]||i[4]||i[5]||i[6],!n)continue;if(a=[...n].length,i[3]||i[4]){r+=a;continue}if((i[5]||i[6])&&s%3&&!((s+a)%3)){o+=a;continue}if(r-=a,r>0)continue;a=Math.min(a,a+r+o);let t=[...i[0]][0].length,l=e.slice(0,s+i.index+t+a);if(Math.min(s,a)%2){let e=l.slice(1,-1);return{type:"em",raw:l,text:e,tokens:this.lexer.inlineTokens(e)}}let c=l.slice(2,-2);return{type:"strong",raw:l,text:c,tokens:this.lexer.inlineTokens(c)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let e=t[2].replace(this.rules.other.newLineCharGlobal," "),n=this.rules.other.nonSpaceChar.test(e),i=this.rules.other.startingSpaceChar.test(e)&&this.rules.other.endingSpaceChar.test(e);return n&&i&&(e=e.substring(1,e.length-1)),{type:"codespan",raw:t[0],text:e}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e){let 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){let t=this.rules.inline.autolink.exec(e);if(t){let e,n;return"@"===t[2]?(e=t[1],n="mailto:"+e):(e=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=t[0],n="mailto:"+e;else{let i;do{i=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??""}while(i!==t[0]);e=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){let t=this.rules.inline.text.exec(e);if(t){let e=this.lexer.state.inRawBlock;return{type:"text",raw:t[0],text:t[0],escaped:e}}}},ae=class e{tokens;options;state;tokenizer;inlineQueue;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||t,this.options.tokenizer=this.options.tokenizer||new ie,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let n={other:s,block:G.normal,inline:V.normal};this.options.pedantic?(n.block=G.pedantic,n.inline=V.pedantic):this.options.gfm&&(n.block=G.gfm,this.options.breaks?n.inline=V.breaks:n.inline=V.gfm),this.tokenizer.rules=n}static get rules(){return{block:G,inline:V}}static lex(t,n){return new e(n).lex(t)}static lexInline(t,n){return new e(n).inlineTokens(t)}lex(e){e=e.replace(s.carriageReturn,"\n"),this.blockTokens(e,this.tokens);for(let e=0;e<this.inlineQueue.length;e++){let t=this.inlineQueue[e];this.inlineTokens(t.src,t.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],n=!1){for(this.options.pedantic&&(e=e.replace(s.tabCharGlobal," ").replace(s.spaceLine,""));e;){let i;if(this.options.extensions?.block?.some(n=>!!(i=n.call({lexer:this},e,t))&&(e=e.substring(i.raw.length),t.push(i),!0)))continue;if(i=this.tokenizer.space(e)){e=e.substring(i.raw.length);let n=t.at(-1);1===i.raw.length&&void 0!==n?n.raw+="\n":t.push(i);continue}if(i=this.tokenizer.code(e)){e=e.substring(i.raw.length);let n=t.at(-1);"paragraph"===n?.type||"text"===n?.type?(n.raw+=(n.raw.endsWith("\n")?"":"\n")+i.raw,n.text+="\n"+i.text,this.inlineQueue.at(-1).src=n.text):t.push(i);continue}if(i=this.tokenizer.fences(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.heading(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.hr(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.blockquote(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.list(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.html(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.def(e)){e=e.substring(i.raw.length);let n=t.at(-1);"paragraph"===n?.type||"text"===n?.type?(n.raw+=(n.raw.endsWith("\n")?"":"\n")+i.raw,n.text+="\n"+i.raw,this.inlineQueue.at(-1).src=n.text):this.tokens.links[i.tag]||(this.tokens.links[i.tag]={href:i.href,title:i.title},t.push(i));continue}if(i=this.tokenizer.table(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.lheading(e)){e=e.substring(i.raw.length),t.push(i);continue}let a=e;if(this.options.extensions?.startBlock){let t,n=1/0,i=e.slice(1);this.options.extensions.startBlock.forEach(e=>{t=e.call({lexer:this},i),"number"==typeof t&&t>=0&&(n=Math.min(n,t))}),n<1/0&&n>=0&&(a=e.substring(0,n+1))}if(this.state.top&&(i=this.tokenizer.paragraph(a))){let s=t.at(-1);n&&"paragraph"===s?.type?(s.raw+=(s.raw.endsWith("\n")?"":"\n")+i.raw,s.text+="\n"+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=s.text):t.push(i),n=a.length!==e.length,e=e.substring(i.raw.length);continue}if(i=this.tokenizer.text(e)){e=e.substring(i.raw.length);let n=t.at(-1);"text"===n?.type?(n.raw+=(n.raw.endsWith("\n")?"":"\n")+i.raw,n.text+="\n"+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=n.text):t.push(i);continue}if(e){let 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=e,i=null;if(this.tokens.links){let e=Object.keys(this.tokens.links);if(e.length>0)for(;null!=(i=this.tokenizer.rules.inline.reflinkSearch.exec(n));)e.includes(i[0].slice(i[0].lastIndexOf("[")+1,-1))&&(n=n.slice(0,i.index)+"["+"a".repeat(i[0].length-2)+"]"+n.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;null!=(i=this.tokenizer.rules.inline.anyPunctuation.exec(n));)n=n.slice(0,i.index)+"++"+n.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;null!=(i=this.tokenizer.rules.inline.blockSkip.exec(n));)n=n.slice(0,i.index)+"["+"a".repeat(i[0].length-2)+"]"+n.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);let a=!1,s="";for(;e;){let i;if(a||(s=""),a=!1,this.options.extensions?.inline?.some(n=>!!(i=n.call({lexer:this},e,t))&&(e=e.substring(i.raw.length),t.push(i),!0)))continue;if(i=this.tokenizer.escape(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.tag(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.link(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(i.raw.length);let n=t.at(-1);"text"===i.type&&"text"===n?.type?(n.raw+=i.raw,n.text+=i.text):t.push(i);continue}if(i=this.tokenizer.emStrong(e,n,s)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.codespan(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.br(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.del(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.autolink(e)){e=e.substring(i.raw.length),t.push(i);continue}if(!this.state.inLink&&(i=this.tokenizer.url(e))){e=e.substring(i.raw.length),t.push(i);continue}let r=e;if(this.options.extensions?.startInline){let t,n=1/0,i=e.slice(1);this.options.extensions.startInline.forEach(e=>{t=e.call({lexer:this},i),"number"==typeof t&&t>=0&&(n=Math.min(n,t))}),n<1/0&&n>=0&&(r=e.substring(0,n+1))}if(i=this.tokenizer.inlineText(r)){e=e.substring(i.raw.length),"_"!==i.raw.slice(-1)&&(s=i.raw.slice(-1)),a=!0;let n=t.at(-1);"text"===n?.type?(n.raw+=i.raw,n.text+=i.text):t.push(i);continue}if(e){let t="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(t);break}throw new Error(t)}}return t}},se=class{options;parser;constructor(e){this.options=e||t}space(e){return""}code({text:e,lang:t,escaped:n}){let i=(t||"").match(s.notSpaceStart)?.[0],a=e.replace(s.endingNewline,"")+"\n";return i?'<pre><code class="language-'+X(i)+'">'+(n?a:X(a,!0))+"</code></pre>\n":"<pre><code>"+(n?a:X(a,!0))+"</code></pre>\n"}blockquote({tokens:e}){return`<blockquote>\n${this.parser.parse(e)}</blockquote>\n`}html({text:e}){return e}def(e){return""}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>\n`}hr(e){return"<hr>\n"}list(e){let t=e.ordered,n=e.start,i="";for(let t=0;t<e.items.length;t++){let n=e.items[t];i+=this.listitem(n)}let a=t?"ol":"ul";return"<"+a+(t&&1!==n?' start="'+n+'"':"")+">\n"+i+"</"+a+">\n"}listitem(e){let t="";if(e.task){let n=this.checkbox({checked:!!e.checked});e.loose?"paragraph"===e.tokens[0]?.type?(e.tokens[0].text=n+" "+e.tokens[0].text,e.tokens[0].tokens&&e.tokens[0].tokens.length>0&&"text"===e.tokens[0].tokens[0].type&&(e.tokens[0].tokens[0].text=n+" "+X(e.tokens[0].tokens[0].text),e.tokens[0].tokens[0].escaped=!0)):e.tokens.unshift({type:"text",raw:n+" ",text:n+" ",escaped:!0}):t+=n+" "}return t+=this.parser.parse(e.tokens,!!e.loose),`<li>${t}</li>\n`}checkbox({checked:e}){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox">'}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>\n`}table(e){let t="",n="";for(let t=0;t<e.header.length;t++)n+=this.tablecell(e.header[t]);t+=this.tablerow({text:n});let i="";for(let t=0;t<e.rows.length;t++){let a=e.rows[t];n="";for(let e=0;e<a.length;e++)n+=this.tablecell(a[e]);i+=this.tablerow({text:n})}return i&&(i=`<tbody>${i}</tbody>`),"<table>\n<thead>\n"+t+"</thead>\n"+i+"</table>\n"}tablerow({text:e}){return`<tr>\n${e}</tr>\n`}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?"th":"td";return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>\n`}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${X(e,!0)}</code>`}br(e){return"<br>"}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let i=this.parser.parseInline(n),a=K(e);if(null===a)return i;let s='<a href="'+(e=a)+'"';return t&&(s+=' title="'+X(t)+'"'),s+=">"+i+"</a>",s}image({href:e,title:t,text:n,tokens:i}){i&&(n=this.parser.parseInline(i,this.parser.textRenderer));let a=K(e);if(null===a)return X(n);let s=`<img src="${e=a}" alt="${n}"`;return t&&(s+=` title="${X(t)}"`),s+=">",s}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:X(e.text)}},re=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return""+e}image({text:e}){return""+e}br(){return""}},oe=class e{options;renderer;textRenderer;constructor(e){this.options=e||t,this.options.renderer=this.options.renderer||new se,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new re}static parse(t,n){return new e(n).parse(t)}static parseInline(t,n){return new e(n).parseInline(t)}parse(e,t=!0){let n="";for(let i=0;i<e.length;i++){let a=e[i];if(this.options.extensions?.renderers?.[a.type]){let e=a,t=this.options.extensions.renderers[e.type].call({parser:this},e);if(!1!==t||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(e.type)){n+=t||"";continue}}let s=a;switch(s.type){case"space":n+=this.renderer.space(s);continue;case"hr":n+=this.renderer.hr(s);continue;case"heading":n+=this.renderer.heading(s);continue;case"code":n+=this.renderer.code(s);continue;case"table":n+=this.renderer.table(s);continue;case"blockquote":n+=this.renderer.blockquote(s);continue;case"list":n+=this.renderer.list(s);continue;case"html":n+=this.renderer.html(s);continue;case"def":n+=this.renderer.def(s);continue;case"paragraph":n+=this.renderer.paragraph(s);continue;case"text":{let a=s,r=this.renderer.text(a);for(;i+1<e.length&&"text"===e[i+1].type;)a=e[++i],r+="\n"+this.renderer.text(a);n+=t?this.renderer.paragraph({type:"paragraph",raw:r,text:r,tokens:[{type:"text",raw:r,text:r,escaped:!0}]}):r;continue}default:{let e='Token with "'+s.type+'" type was not found.';if(this.options.silent)return console.error(e),"";throw new Error(e)}}}return n}parseInline(e,t=this.renderer){let n="";for(let i=0;i<e.length;i++){let a=e[i];if(this.options.extensions?.renderers?.[a.type]){let e=this.options.extensions.renderers[a.type].call({parser:this},a);if(!1!==e||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(a.type)){n+=e||"";continue}}let s=a;switch(s.type){case"escape":case"text":n+=t.text(s);break;case"html":n+=t.html(s);break;case"link":n+=t.link(s);break;case"image":n+=t.image(s);break;case"strong":n+=t.strong(s);break;case"em":n+=t.em(s);break;case"codespan":n+=t.codespan(s);break;case"br":n+=t.br(s);break;case"del":n+=t.del(s);break;default:{let e='Token with "'+s.type+'" type was not found.';if(this.options.silent)return console.error(e),"";throw new Error(e)}}}return n}},le=class{options;block;constructor(e){this.options=e||t}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}provideLexer(){return this.block?ae.lex:ae.lexInline}provideParser(){return this.block?oe.parse:oe.parseInline}},ce=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.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=oe;Renderer=se;TextRenderer=re;Lexer=ae;Tokenizer=ie;Hooks=le;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(let i of e)switch(n=n.concat(t.call(this,i)),i.type){case"table":{let e=i;for(let i of e.header)n=n.concat(this.walkTokens(i.tokens,t));for(let i of e.rows)for(let e of i)n=n.concat(this.walkTokens(e.tokens,t));break}case"list":{let e=i;n=n.concat(this.walkTokens(e.items,t));break}default:{let e=i;this.defaults.extensions?.childTokens?.[e.type]?this.defaults.extensions.childTokens[e.type].forEach(i=>{let a=e[i].flat(1/0);n=n.concat(this.walkTokens(a,t))}):e.tokens&&(n=n.concat(this.walkTokens(e.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(e=>{let 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){let n=t.renderers[e.name];t.renderers[e.name]=n?function(...t){let i=e.renderer.apply(this,t);return!1===i&&(i=n.apply(this,t)),i}: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'");let 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){let t=this.defaults.renderer||new se(this.defaults);for(let n in e.renderer){if(!(n in t))throw new Error(`renderer '${n}' does not exist`);if(["options","parser"].includes(n))continue;let i=n,a=e.renderer[i],s=t[i];t[i]=(...e)=>{let n=a.apply(t,e);return!1===n&&(n=s.apply(t,e)),n||""}}n.renderer=t}if(e.tokenizer){let t=this.defaults.tokenizer||new ie(this.defaults);for(let n in e.tokenizer){if(!(n in t))throw new Error(`tokenizer '${n}' does not exist`);if(["options","rules","lexer"].includes(n))continue;let i=n,a=e.tokenizer[i],s=t[i];t[i]=(...e)=>{let n=a.apply(t,e);return!1===n&&(n=s.apply(t,e)),n}}n.tokenizer=t}if(e.hooks){let t=this.defaults.hooks||new le;for(let n in e.hooks){if(!(n in t))throw new Error(`hook '${n}' does not exist`);if(["options","block"].includes(n))continue;let i=n,a=e.hooks[i],s=t[i];le.passThroughHooks.has(n)?t[i]=e=>{if(this.defaults.async)return Promise.resolve(a.call(t,e)).then(e=>s.call(t,e));let n=a.call(t,e);return s.call(t,n)}:t[i]=(...e)=>{let n=a.apply(t,e);return!1===n&&(n=s.apply(t,e)),n}}n.hooks=t}if(e.walkTokens){let t=this.defaults.walkTokens,i=e.walkTokens;n.walkTokens=function(e){let n=[];return n.push(i.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 ae.lex(e,t??this.defaults)}parser(e,t){return oe.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let i={...n},a={...this.defaults,...i},s=this.onError(!!a.silent,!!a.async);if(!0===this.defaults.async&&!1===i.async)return s(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof t>"u"||null===t)return s(new Error("marked(): input parameter is undefined or null"));if("string"!=typeof t)return s(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));a.hooks&&(a.hooks.options=a,a.hooks.block=e);let r=a.hooks?a.hooks.provideLexer():e?ae.lex:ae.lexInline,o=a.hooks?a.hooks.provideParser():e?oe.parse:oe.parseInline;if(a.async)return Promise.resolve(a.hooks?a.hooks.preprocess(t):t).then(e=>r(e,a)).then(e=>a.hooks?a.hooks.processAllTokens(e):e).then(e=>a.walkTokens?Promise.all(this.walkTokens(e,a.walkTokens)).then(()=>e):e).then(e=>o(e,a)).then(e=>a.hooks?a.hooks.postprocess(e):e).catch(s);try{a.hooks&&(t=a.hooks.preprocess(t));let e=r(t,a);a.hooks&&(e=a.hooks.processAllTokens(e)),a.walkTokens&&this.walkTokens(e,a.walkTokens);let n=o(e,a);return a.hooks&&(n=a.hooks.postprocess(n)),n}catch(e){return s(e)}}}onError(e,t){return n=>{if(n.message+="\nPlease report this to https://github.com/markedjs/marked.",e){let e="<p>An error occurred:</p><pre>"+X(n.message+"",!0)+"</pre>";return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}};function pe(e,t){return ce.parse(e,t)}pe.options=pe.setOptions=function(e){return ce.setOptions(e),pe.defaults=ce.defaults,n(pe.defaults),pe},pe.getDefaults=e,pe.defaults=t,pe.use=function(...e){return ce.use(...e),pe.defaults=ce.defaults,n(pe.defaults),pe},pe.walkTokens=function(e,t){return ce.walkTokens(e,t)},pe.parseInline=ce.parseInline,pe.Parser=oe,pe.parser=oe.parse,pe.Renderer=se,pe.TextRenderer=re,pe.Lexer=ae,pe.lexer=ae.lex,pe.Tokenizer=ie,pe.Hooks=le,pe.parse=pe,pe.options,pe.setOptions,pe.use,pe.walkTokens,pe.parseInline,oe.parse,ae.lex;!function(e,t){void 0===t&&(t={});var n=t.insertAt;if(e&&"undefined"!=typeof document){var i=document.head||document.getElementsByTagName("head")[0],a=document.createElement("style");a.type="text/css","top"===n&&i.firstChild?i.insertBefore(a,i.firstChild):i.appendChild(a),a.styleSheet?a.styleSheet.cssText=e:a.appendChild(document.createTextNode(e))}}('#aptolix-chat-window{border-radius:16px;border-style:solid;border-width:2.5px;box-sizing:border-box;display:flex;flex-direction:column;font-family:Inter,sans-serif;height:100%;margin:0;max-height:100%;max-width:100%;min-height:0;min-width:0;overflow:hidden;width:100%}#aptolix-chat-header{align-items:center;border-bottom-style:solid;border-bottom-width:2px;color:#fff;display:flex;font-size:1.15rem;font-weight:200;justify-content:space-between;padding:10px 13px}.aptolix-header-title{align-items:center;display:flex;flex:1;flex-direction:row;gap:12px;justify-content:flex-start;min-width:0}.aptolix-company-logo-wrapper{align-items:center;display:flex;flex-shrink:0}.aptolix-bot-name{align-items:center;display:flex;font-family:Inter,-apple-system,BlinkMacSystemFont,Segoe UI,sans-serif;font-size:1rem;font-weight:600;letter-spacing:.01em;line-height:1.2;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.aptolix-header-subtitle{color:#ede9fe;font-size:.95rem;font-weight:400;margin-top:2px}.aptolix-header-actions{align-items:center;display:flex;gap:6px;margin-top:0;position:relative}.aptolix-menu-dropdown{background:#fff;border:1px solid rgba(0,0,0,.08);border-radius:6px;box-shadow:0 2px 8px rgba(0,0,0,.15);display:none;flex-direction:column;gap:0;min-width:120px;overflow:hidden;padding:3px 0;position:absolute;right:0;top:calc(100% + 6px);z-index:1000}.aptolix-menu-dropdown.show{display:flex}.aptolix-menu-item{align-items:center;background:transparent;border:none;color:#4b5563;cursor:pointer;direction:ltr;display:flex;gap:7px;justify-content:flex-start!important;padding:6px 10px;text-align:left!important;transition:background-color .1s ease;white-space:nowrap;width:100%}.aptolix-menu-item:hover{background-color:#f9fafb;color:#1f2937}.aptolix-menu-icon{align-items:center;display:inline-flex;flex-shrink:0;font-size:14px!important;justify-content:flex-start!important;line-height:1;text-align:left!important;width:14px}.aptolix-menu-text{flex:1;font-size:12px!important;font-weight:400;line-height:1.3;text-align:left!important}#aptolix-chat-header button{align-items:center;background:transparent;border:none;border-radius:6px;color:#fff;cursor:pointer;display:flex;font-size:22px;justify-content:center;min-height:20px;min-width:20px;transition:all .2s}#aptolix-chat-header button:hover{background:hsla(0,0%,100%,.15);transform:scale(1.05)}#aptolix-chat-header button:active{background:hsla(0,0%,100%,.25);transform:scale(.95)}.aptolix-header-flex{align-items:center;display:flex;justify-content:space-between;width:100%}#aptolix-chat-messages{display:flex;flex:1 1 auto;flex-direction:column;gap:6px;min-height:120px;overflow-y:auto;padding:18px 16px 16px}.aptolix-footer{align-items:center;background:transparent;display:flex;gap:10px;justify-content:center;min-height:36px;padding:0 8px}.aptolix-footer-separator{color:#d1d5db;font-size:.75rem;opacity:0;transition:opacity .4s ease .1s;user-select:none}.aptolix-footer-separator.show{opacity:1}.aptolix-powered-by{background:transparent;flex:0 0 auto;font-size:.75rem;font-weight:500;letter-spacing:.01em;padding:8px 0;text-align:center;transition:all .3s ease;white-space:nowrap}.aptolix-powered-by .aptolix-link{font-family:inherit;font-weight:600;text-decoration:underline}.aptolix-rating{align-items:center;color:#6b7280;display:flex;flex:0 0 auto;font-size:.75rem;gap:6px;max-width:0;opacity:0;overflow:hidden;transition:max-width .4s ease,opacity .4s ease,visibility .4s ease;visibility:hidden}.aptolix-rating.show{max-width:200px;opacity:1;visibility:visible}.aptolix-rating-label{font-size:.75rem;font-weight:500;white-space:nowrap}.aptolix-stars{align-items:center;display:flex;gap:2px}.star{color:#fbbf24;cursor:pointer;font-size:1.1rem;line-height:1;transition:transform .1s ease;user-select:none}.star:hover{transform:scale(1.1)}#aptolix-chat-input{align-items:center;background:#fff;border-top-style:solid;border-top-width:2px;display:flex;gap:8px;min-height:56px;padding:5px 10px}#aptolix-chat-input input{border:1.5px solid;border-radius:10px;flex:1 1 auto;font-size:1rem;min-width:0;padding:10px 14px;transition:border .2s}#aptolix-chat-input input:focus{outline:none}#aptolix-chat-input button{border:none;border-radius:10px;box-shadow:0 2px 8px rgba(0,0,0,.1);cursor:pointer;flex-shrink:0;font-size:1rem;font-weight:600;padding:8px 18px;transition:background .2s,box-shadow .2s}#aptolix-chat-input button:hover{box-shadow:0 4px 16px rgba(0,0,0,.15)}#aptolix-chat-input button:not(:first-child){background:rgba(167,139,250,.12);border-radius:8px;box-shadow:none;color:#9333ea;font-size:1.1rem;font-weight:500;padding:8px 12px}#aptolix-chat-input button:not(:first-child):hover{background:rgba(167,139,250,.22);color:#4b5563}#aptolix-chat-inputbox{border:1px solid;border-radius:4px;box-sizing:border-box;font-family:inherit;font-size:1rem;max-height:130px;min-height:42px;outline:none;overflow-y:auto;padding:6px 12px;resize:none;transition:border-color .2s;width:100%}.message{align-items:flex-end;display:flex;font-family:Inter,sans-serif;gap:4px;margin-bottom:4px;max-width:88%}.message.user{align-self:flex-end;flex-direction:row-reverse}.message.bot{align-self:flex-start;flex-direction:row}.message-avatar{cursor:pointer;flex-shrink:0;height:16px;opacity:.7;position:relative;transition:opacity .2s;width:16px}.message-avatar:hover{opacity:1}.message-avatar img,.message-avatar svg{border-radius:50%;height:16px;width:16px}.message-sender{background:rgba(0,0,0,.8);border-radius:4px;bottom:100%;color:#fff;font-size:.75rem;font-weight:500;left:0;margin-bottom:4px;opacity:0;padding:4px 8px;pointer-events:none;position:absolute;transition:opacity .2s;white-space:nowrap;z-index:1000}.message-avatar:hover .message-sender{opacity:1}.message.user .message-sender{left:auto;right:0}.message-content{align-items:flex-start;display:flex;flex-direction:column;gap:0;justify-content:flex-start;max-width:100%;min-width:0}.message.user .message-content{align-items:flex-end}.message-text{border-radius:14px;font-weight:500;line-height:1.5;margin-bottom:0;padding:8px 14px;word-break:break-word}.message.user .message-text{border-radius:14px 14px 4px 14px;box-shadow:0 2px 8px rgba(167,139,250,.1)}.message.bot .message-text{border-radius:14px 14px 14px 4px;box-shadow:0 2px 8px rgba(167,139,250,.08);margin-bottom:0}.message-timestamp{align-self:flex-start;background:none;color:#9ca3af;font-size:.7rem;line-height:1.2;margin-top:2px;padding:0 8px;position:relative;z-index:1}.message.user .message-timestamp{align-self:flex-end}.message-text a{text-decoration:underline;word-break:break-all}.message-text b,.message-text strong{font-weight:700}.message-text h1,.message-text h2,.message-text h3{font-size:1.3rem;line-height:1.2;margin:10px 0 6px}.message-text h2{font-size:1.15rem}.message-text h3{font-size:1.05rem}.message-text p{margin:10px 0}.message-text ol,.message-text ul{margin:8px 0 8px 18px;padding-left:18px}.message-text ul{list-style:none;padding-left:0}.message-text ul li{margin-bottom:4px;padding-left:1.3em;position:relative}.message-text ul li:before{background:#9333ea;border-radius:50%;content:"";display:inline-block;height:.5em;left:.3em;position:absolute;top:.7em;width:.5em}.message-text li{margin-bottom:4px}.message-text code,.message-text pre{background:#f3f4f6;border-radius:6px;color:#7c3aed;font-family:Fira Mono,Consolas,Monaco,monospace;font-size:1em;margin:8px 0;padding:4px 10px}.message-text pre{overflow-x:auto;padding:12px 16px}.typing-dots span{animation:blink 1.2s infinite;font-size:1.5em;margin-right:2px;opacity:.5}.typing-dots span:nth-child(2){animation-delay:.2s}.typing-dots span:nth-child(3){animation-delay:.4s}@keyframes blink{0%,to{opacity:.2}50%{opacity:1}}#aptolix-chat-bubble{align-items:center;background:#9333ea;border-radius:50%;bottom:32px;box-shadow:0 6px 24px rgba(167,139,250,.18);color:#fff;cursor:pointer;display:flex;font-size:2rem;height:56px;justify-content:center;position:fixed;right:32px;transition:background .2s,box-shadow .2s;width:56px;z-index:9999}#aptolix-chat-bubble:hover{background:#7c3aed;box-shadow:0 8px 32px rgba(124,62,237,.28)}#aptolix-chat-window.bubble-mode{border-radius:16px;bottom:100px;height:595px;max-height:80vh;min-height:595px;position:fixed;right:32px;width:400px;z-index:9999}#aptolix-chat-window.section-mode{border:2px solid #a78bfa;border-radius:18px;box-shadow:0 4px 24px rgba(167,139,250,.1);height:100%;max-height:100%;max-width:100%;position:static!important;width:100%}#aptolix-chat-window.section-mode #aptolix-chat-header{background:#9333ea;color:#fff}#aptolix-chat-window.section-mode #aptolix-chat-close,#aptolix-chat-window.section-mode #aptolix-chat-expand,#aptolix-chat-window.section-mode~#aptolix-chat-bubble{display:none!important}#aptolix-chat-window.section-mode #aptolix-chat-messages{background:#f6f3ff;padding:20px 18px 18px}@media (max-width:600px){#aptolix-chat-window,#aptolix-chat-window.bubble-mode,#aptolix-chat-window.section-mode{border-radius:12px;left:0;margin:0;max-width:100vw;min-height:180px;padding:0;right:0;width:100vw}#aptolix-chat-header{font-size:1rem;padding:10px 6px 8px}#aptolix-chat-messages{padding:8px 4px 6px}#aptolix-chat-input{padding:6px 2px}#aptolix-chat-expand,#aptolix-chat-window.section-mode #aptolix-chat-close{display:none!important}}.aptolix-retry-btn{background:#ede9fe;border:none;border-radius:6px;color:#7c3aed;cursor:pointer;font-weight:600;margin-top:8px;padding:4px 12px}.aptolix-retry-btn:hover{background:#d8b4fe}.aptolix-hint-bubble{background:#fff;border-radius:8px;bottom:110px;box-shadow:0 2px 8px rgba(0,0,0,.15);color:#333;font-size:1em;max-width:320px;min-width:180px;padding:16px 40px 16px 16px;pointer-events:auto;position:fixed;right:40px;z-index:9999}.aptolix-hint-bubble:after{border-left:10px solid transparent;border-right:10px solid transparent;border-top:12px solid #fff;bottom:-12px;content:"";height:0;position:absolute;right:28px;width:0}');class he{constructor(){this.keys={config:"aptolix_chatbot_config",state:"aptolix_chatbot_state"}}_getState(e){try{const t=`${this.keys.state}_${e}`,n=localStorage.getItem(t);return n?JSON.parse(n):null}catch(e){return null}}_saveState(e,t){try{const n=`${this.keys.state}_${e}`;t.timestamp=Date.now(),t.version="1.0.12",localStorage.setItem(n,JSON.stringify(t))}catch(e){}}_isToday(e){const t=new Date,n=new Date(e);return t.getFullYear()===n.getFullYear()&&t.getMonth()===n.getMonth()&&t.getDate()===n.getDate()}_getTodayStart(){const e=new Date;return e.setHours(0,0,0,0),e.getTime()}saveConfig(e,t){try{const n=`${this.keys.config}_${e}`,i={config:t,timestamp:Date.now()};localStorage.setItem(n,JSON.stringify(i))}catch(e){}}getConfig(e){try{const t=`${this.keys.config}_${e}`,n=localStorage.getItem(t);if(!n)return null;return JSON.parse(n).config}catch(e){return null}}clearConfig(e){try{const t=`${this.keys.config}_${e}`;localStorage.removeItem(t)}catch(e){}}hasConfig(e){const t=`${this.keys.config}_${e}`;return null!==localStorage.getItem(t)}saveVisitorId(e,t){try{const n=this._getState(e)||{};n.visitorId=t,this._saveState(e,n)}catch(e){}}getVisitorId(e){try{const t=this._getState(e);return t?.visitorId||null}catch(e){return null}}clearVisitorId(e){try{const t=this._getState(e);t&&(delete t.visitorId,this._saveState(e,t))}catch(e){}}hasVisitorId(e){return null!==this.getVisitorId(e)}saveSessionId(e,t){try{const n=this._getState(e)||{};n.sessionId=t,this._saveState(e,n)}catch(e){}}getSessionId(e){try{const t=this._getState(e);return t?.sessionId||null}catch(e){return null}}clearSessionId(e){try{const t=this._getState(e);t&&(delete t.sessionId,this._saveState(e,t))}catch(e){}}hasSessionId(e){return null!==this.getSessionId(e)}saveChatHistory(e,t,n){try{const t=this._getState(e)||{};t.history={messages:n,timestamp:Date.now()},this._saveState(e,t)}catch(e){}}getChatHistory(e,t){try{const n=this._getState(e);if(!n?.history)return null;const{history:i}=n;return n.sessionId!==t?null:this._isToday(i.timestamp)?i.messages:(this.clearChatHistory(e,t),null)}catch(e){return null}}clearChatHistory(e,t){try{const n=this._getState(e);n?.history&&n.sessionId===t&&(delete n.history,this._saveState(e,n))}catch(e){}}hasChatHistory(e,t){return null!==this.getChatHistory(e,t)}setUsageLimitReached(e,t,n){try{const t=this._getState(e)||{};t.usageLimitReached={limitReachedDate:n,timestamp:Date.now()},this._saveState(e,t)}catch(e){}}getUsageLimitReached(e,t){try{const n=this._getState(e);if(!n?.usageLimitReached)return null;const{usageLimitReached:i}=n;let a;a=10!==i.limitReachedDate.length||i.limitReachedDate.includes("T")?new Date(i.limitReachedDate):new Date(i.limitReachedDate+"T23:59:59.999Z");return new Date>a?(this.clearUsageLimitReached(e,t),null):{limitReachedDate:i.limitReachedDate,timestamp:i.timestamp}}catch(e){return null}}clearUsageLimitReached(e,t){try{const t=this._getState(e);t&&(delete t.usageLimitReached,this._saveState(e,t))}catch(e){}}hasUsageLimitReached(e,t){return null!==this.getUsageLimitReached(e,t)}clearAll(e,t=null,n=null){this.clearConfig(e);try{const t=`${this.keys.state}_${e}`;localStorage.removeItem(t)}catch(e){}}}const de={mode:"bubble",botname:"AI Assistant",widgetIcon:"💬",companyLogoBlack:'\n <svg width="24" height="32" viewBox="0 0 81 52" fill="none" xmlns="http://www.w3.org/2000/svg">\n <rect x="34.8" y="0" width="46" height="11.7" rx="5.9" fill="#000"/>\n <rect x="0.2" y="19.7" width="80.6" height="12" rx="6" fill="#000"/>\n <rect x="61.7" y="39.4" width="19" height="11.7" rx="6" fill="#000"/>\n <rect x="7.7" y="39.5" width="49" height="11.7" rx="6" fill="#000"/>\n </svg>\n ',companyLogoWhite:'\n <svg width="24" height="32" viewBox="0 0 81 52" fill="none" xmlns="http://www.w3.org/2000/svg">\n <rect x="34.8" y="0" width="46" height="11.7" rx="5.9" fill="#fcfcfcff"/>\n <rect x="0.2" y="19.7" width="80.6" height="12" rx="6" fill="#fcfcfcff"/>\n <rect x="61.7" y="39.4" width="19" height="11.7" rx="6" fill="#fcfcfcff"/>\n <rect x="7.7" y="39.5" width="49" height="11.7" rx="6" fill="#fcfcfcff"/>\n </svg>\n ',botAvatar:'\n <svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">\n <circle cx="20" cy="20" r="18" fill="#9333ea"/>\n <rect x="12" y="14" width="6" height="6" rx="1" fill="#fff"/>\n <rect x="22" y="14" width="6" height="6" rx="1" fill="#fff"/>\n <rect x="13" y="26" width="14" height="4" rx="2" fill="#fff"/>\n </svg>\n ',userAvatar:'\n <svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">\n <circle cx="20" cy="20" r="20" fill="#64748b"/>\n <circle cx="20" cy="15" r="6" fill="#fff"/>\n <path d="M 8 35 Q 8 25 20 25 Q 32 25 32 35" fill="#fff"/>\n </svg>\n ',username:"You",botaccentColor:"#4a57e2ff",floatingWelcomeMessage:"Hello! Looking for something? I'm here to assist - just ask!",floatingWelcomeDelay:2,greetingMessage:"Welcome! Let me know if you have any questions.",allowDownloadTranscript:!0,allowExpandChatWindow:!0,allowFullPageChat:!1,inputCharLimit:350,allowRating:!0,ratingThreshold:3,ratingInterval:4};function ue(e){return!(!e||"string"!=typeof e)&&(!!(e.includes("<svg")||e.includes("<")&&e.includes(">"))||e.trim().length>0&&e.length<=100)}async function ge(e,t){const n=new he;if(e&&t){const i=await async function(e,t){try{const i=await fetch(`${e}/chatbot/${t}/appearance`,{method:"GET",headers:{"Content-Type":"application/json"}});if(!i.ok)return null;return(n=await i.json())?{botname:n.bot_name,widgetIcon:n.widget_icon,companyLogo:n.company_logo,botAvatar:n.bot_avatar,userAvatar:n.user_avatar,username:n.username,botaccentColor:n.accent_color,floatingWelcomeMessage:n.floating_welcome_message,floatingWelcomeDelay:n.floating_welcome_delay,greetingMessage:n.greeting_message,allowDownloadTranscript:n.download_transcript,allowExpandChatWindow:n.expand_chat_window,allowFullPageChat:n.full_page_chat,inputCharLimit:n.input_char_limit,allowRating:n.allow_rating,ratingThreshold:n.rating_threshold,ratingInterval:n.rating_interval}:null}catch(e){return null}var n}(e,t);if(i)return i.widgetIcon&&ue(i.widgetIcon)||(i.widgetIcon=de.widgetIcon),n.saveConfig(t,i),i;{const e=n.getConfig(t);return e?(e.widgetIcon&&ue(e.widgetIcon)||(e.widgetIcon=de.widgetIcon),e):null}}return null}const me={init:async({apiHost:e,chatbotId:t,botname:n,widgetIcon:i,companyLogo:a,companyLogoUrl:s,botAvatar:r,botavatarUrl:o,botaccentColor:l,floatingWelcomeMessage:c,floatingWelcomeDelay:p,greetingMessage:h,allowDownloadTranscript:d,allowExpandChatWindow:u,allowFullPageChat:g,inputCharLimit:m,allowRating:x,ratingThreshold:f,ratingInterval:b,mode:w="bubble",target:k})=>{if(!e||!t)return void console.error("apiHost and chatbotId are mandatory parameters");const y=await ge(e,t),v={botname:n||y?.botname||de.botname,widgetIcon:i||y?.widgetIcon||de.widgetIcon,companyLogo:a||y?.companyLogo||de.companyLogo,companyLogoUrl:s||y?.companyLogoUrl||"",botAvatar:r||y?.botAvatar||de.botAvatar,botavatarUrl:o||y?.botavatarUrl||"",userAvatar:y?.userAvatar||de.userAvatar,username:y?.username||de.username,botaccentColor:l||y?.botaccentColor||de.botaccentColor,floatingWelcomeMessage:c||y?.floatingWelcomeMessage||de.floatingWelcomeMessage,floatingWelcomeDelay:p||y?.floatingWelcomeDelay||de.floatingWelcomeDelay,greetingMessage:h||y?.greetingMessage||de.greetingMessage,allowDownloadTranscript:void 0!==d?d:void 0!==y?.allowDownloadTranscript?y.allowDownloadTranscript:de.allowDownloadTranscript,allowExpandChatWindow:void 0!==u?u:void 0!==y?.allowExpandChatWindow?y.allowExpandChatWindow:de.allowExpandChatWindow,allowFullPageChat:void 0!==g?g:void 0!==y?.allowFullPageChat?y.allowFullPageChat:de.allowFullPageChat,inputCharLimit:m||y?.inputCharLimit||de.inputCharLimit,allowRating:void 0!==x?x:void 0!==y?.allowRating?y.allowRating:de.allowRating,ratingThreshold:f||y?.ratingThreshold||de.ratingThreshold,ratingInterval:b||y?.ratingInterval||de.ratingInterval,mode:w||de.mode,target:k},$=e=>!(!e||"string"!=typeof e)&&/^https?:\/\/.+/.test(e.trim()),S=async e=>new Promise(t=>{const n=new Image,i=setTimeout(()=>{n.src="",t(!1)},3e3);n.onload=()=>{clearTimeout(i),t(!0)},n.onerror=()=>{clearTimeout(i),t(!1)},n.src=e}),T=e=>{if(!e||"string"!=typeof e)return!1;if(!/^\s*<svg[\s\S]*<\/svg>\s*$/i.test(e))return!1;try{const t=(new DOMParser).parseFromString(e,"image/svg+xml");return!t.querySelector("parsererror")}catch(e){return!1}},C=(e=>{const t=e=>{const t=e.replace("#","").substring(0,6),n=/^([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);return n?{r:parseInt(n[1],16),g:parseInt(n[2],16),b:parseInt(n[3],16)}:null},n=(e,n)=>{const i=t(e);if(!i)return e;const a=Math.min(255,Math.round(i.r+(255-i.r)*n)),s=Math.min(255,Math.round(i.g+(255-i.g)*n)),r=Math.min(255,Math.round(i.b+(255-i.b)*n));return`#${a.toString(16).padStart(2,"0")}${s.toString(16).padStart(2,"0")}${r.toString(16).padStart(2,"0")}`},i=(e,n)=>{const i=t(e);if(!i)return e;const a=Math.max(0,Math.round(i.r*(1-n))),s=Math.max(0,Math.round(i.g*(1-n))),r=Math.max(0,Math.round(i.b*(1-n)));return`#${a.toString(16).padStart(2,"0")}${s.toString(16).padStart(2,"0")}${r.toString(16).padStart(2,"0")}`},a=(e,n)=>{const i=t(e);return i?`rgba(${i.r}, ${i.g}, ${i.b}, ${n})`:e},s=(e=>{let n,i,a;if(e.startsWith("#")){const s=t(e);if(!s)return!1;n=s.r,i=s.g,a=s.b}else{if(!e.startsWith("rgb"))return!1;{const t=e.match(/\d+/g);[n,i,a]=t.map(Number)}}return(.299*n+.587*i+.114*a)/255>.5})(e);return{primary:e,isLight:s,header:{background:e,text:s?"#1f2937":"#ffffff",button:s?"#374151":"#ffffff",border:n(e,.85)},messages:{userBackground:e,userText:s?"#1f2937":"#ffffff",botBackground:n(e,.85),botText:"#4b5563",link:i(e,.1),timestamp:"#9ca3af"},window:{background:n(e,.95),border:s?i(e,.2):n(e,.3),shadow:a(e,.15)},input:{background:"#ffffff",border:n(e,.85),text:"#1f2937",placeholder:"#9ca3af",buttonBackground:e,buttonText:s?"#1f2937":"#ffffff"},footer:{text:s?i(e,.3):n(e,.2),link:i(e,.1)},bubble:{background:e,icon:s?"#1f2937":"#ffffff"},hint:{background:"#ffffff",text:"#1f2937",border:n(e,.85),closeButton:e},menu:{background:"#ffffff",text:"#1f2937",hover:n(e,.9),border:"#e5e7eb"},rating:{star:"#fbbf24",text:"#6b7280"},utils:{lighten:n,darken:i,addAlpha:a,hexToRgb:t}}})(v.botaccentColor),R=C.messages.userBackground,L=C.messages.userText,A=C.messages.botBackground,_=C.messages.botText,I=C.messages.link,z=C.header.text,E=C.header.button,D=C.input.buttonText,M=C.window.border,q=C.window.background,P=C.input.border,B=C.header.border,H=C.footer.text,U=C.window.shadow,W=a||y?.companyLogo;let j=W,N=!1;if(W&&$(W)){await S(W)||(N=!0)}else W&&!T(W)&&(N=!0);v.companyLogo=N?null:j;const Z=v.botAvatar;let O=Z,F=!1;if(Z&&$(Z)){await S(Z)||(F=!0)}else Z&&!T(Z)&&(F=!0);v.botAvatar=F?null:O;const Q="section"===v.mode?"section-mode":"bubble-mode",G=document.createElement("div");let V,Y,J;if("bubble"===v.mode){V=document.createElement("div"),V.id="aptolix-chat-bubble",V.style.backgroundColor=v.botaccentColor;const e=v.widgetIcon||de.widgetIcon;e.includes("<svg")||e.includes("<")&&e.includes(">")?V.innerHTML=e:V.innerText=e,document.body.appendChild(V);const t=document.getElementById("aptolix-chat-hint-bubble");t&&t.remove(),J=document.createElement("div"),J.id="aptolix-chat-hint-bubble",J.className="aptolix-hint-bubble",J.style.display="none",J.style.position="fixed",J.style.right="40px",J.style.bottom="110px",J.style.zIndex="9999";const n=document.createElement("span");n.textContent=v.floatingWelcomeMessage;const i=document.createElement("button");i.id="aptolix-hint-close",i.title="Close",i.setAttribute("aria-label","Close"),i.innerHTML="&#10005;",i.style.background="none",i.style.border="none",i.style.color=v.botaccentColor,i.style.fontSize="1.3em",i.style.position="absolute",i.style.top="8px",i.style.right="12px",i.style.cursor="pointer",i.style.padding="0",i.addEventListener("click",()=>{J.style.display="none",sessionStorage.setItem("aptolixHintClosed","true"),clearTimeout(Y)}),J.appendChild(n),J.appendChild(i),document.body.appendChild(J),Y=setTimeout(()=>{"none"!==G.style.display||sessionStorage.getItem("aptolixHintClosed")||(J.style.display="block")},1e3*v.floatingWelcomeDelay),V.addEventListener("click",()=>{J.style.display="none",clearTimeout(Y)}),G.addEventListener("transitionstart",()=>{J.style.display="none",clearTimeout(Y)})}if(G.id="aptolix-chat-window",G.classList.add(Q),G.style.display="section"===v.mode?"flex":"none",G.style.backgroundColor=q,G.style.borderColor=M,G.style.boxShadow=`0 4px 20px ${U}`,"section"===v.mode&&v.target){const e="string"==typeof v.target?document.querySelector(v.target):v.target;e?e.appendChild(G):document.body.appendChild(G)}else document.body.appendChild(G);let X="";if(v.companyLogo){X=/^https?:\/\//.test(v.companyLogo)?`<img src="${v.companyLogo}" alt="Company Logo" class="aptolix-company-logo" style="max-width:40px;max-height:40px;" />`:v.companyLogo}const K=v.botAvatar&&/^https?:\/\//.test(v.botAvatar)?`<img src="${v.botAvatar}" alt="Bot Avatar" style="width:40px;height:40px;border-radius:50%;" />`:v.botAvatar||de.botAvatar,ee=v.userAvatar&&/^https?:\/\//.test(v.userAvatar)?`<img src="${v.userAvatar}" alt="User Avatar" style="width:40px;height:40px;border-radius:50%;" />`:v.userAvatar||de.userAvatar,te=`https://aptolix.com?utm_source=${encodeURIComponent(window.location.hostname)}&utm_medium=${encodeURIComponent("widget")}&utm_campaign=${encodeURIComponent("refback")}`;G.innerHTML=`\n <div id="aptolix-chat-header" style="background-color: ${v.botaccentColor}; color: ${z}; border-bottom: 2px solid ${B};">\n <div class="aptolix-header-flex">\n <div class="aptolix-header-title">\n ${X?`<div class="aptolix-company-logo-wrapper">${X}</div>`:""}\n <strong class="aptolix-bot-name">${v.botname}</strong>\n </div>\n <div class="aptolix-header-actions">\n <button id="aptolix-chat-menu" title="More options" aria-label="More options" style="color: ${E};">⋮</button>\n ${v.allowExpandChatWindow?`<button id="aptolix-chat-expand" title="Expand/Collapse" aria-label="Expand/Collapse" style="color: ${E};">\n <span id="aptolix-chat-expand-icon">⤢</span>\n </button>`:""}\n <button id="aptolix-chat-close" title="Close chat" aria-label="Close chat" style="color: ${E};">×</button>\n <div id="aptolix-chat-menu-dropdown" class="aptolix-menu-dropdown">\n <button id="aptolix-chat-reset" class="aptolix-menu-item" title="Reset chat" aria-label="Reset chat">\n <span class="aptolix-menu-icon">⟲</span>\n <span class="aptolix-menu-text">Reset Chat</span>\n </button>\n ${v.allowDownloadTranscript?'<button id="aptolix-chat-download" class="aptolix-menu-item" title="Download chat" aria-label="Download chat">\n <span class="aptolix-menu-icon">⤓</span>\n <span class="aptolix-menu-text">Download Chat</span>\n </button>':""}\n </div>\n </div>\n </div>\n </div>\n <div id="aptolix-chat-messages"></div>\n <div id="aptolix-chat-input" style="border-top: 2px solid ${P};">\n <textarea id="aptolix-chat-inputbox" rows="1" placeholder="Type your message..." style="resize:none"></textarea>\n <button style="background-color: ${v.botaccentColor}; color: ${D};">Send</button>\n </div>\n <div class="aptolix-footer">\n <div class="aptolix-powered-by" id="aptolix-powered-by" style="color: ${H};">\n Powered by <a href="${te}" target="_blank" rel="noopener" class="aptolix-link" style="color: ${v.botaccentColor};">Aptolix</a>\n </div>\n <span class="aptolix-footer-separator" id="aptolix-footer-separator">|</span>\n <div class="aptolix-rating" id="aptolix-rating">\n <span class="aptolix-rating-label">Rate this chat:</span>\n <div class="aptolix-stars" id="aptolix-stars">\n <span class="star" data-rating="1">☆</span>\n <span class="star" data-rating="2">☆</span>\n <span class="star" data-rating="3">☆</span>\n <span class="star" data-rating="4">☆</span>\n <span class="star" data-rating="5">☆</span>\n </div>\n </div>\n </div>\n`;const ne=G.querySelector("#aptolix-chat-close"),ie=G.querySelector("#aptolix-chat-reset"),ae=v.allowExpandChatWindow?G.querySelector("#aptolix-chat-expand"):null,se=v.allowExpandChatWindow?G.querySelector("#aptolix-chat-expand-icon"):null,re=G.querySelector("#aptolix-chat-inputbox"),oe=G.querySelector("#aptolix-chat-input button"),le=G.querySelector("#aptolix-chat-messages"),ce=v.allowDownloadTranscript?G.querySelector("#aptolix-chat-download"):null,ue=G.querySelector("#aptolix-chat-menu"),me=G.querySelector("#aptolix-chat-menu-dropdown");le.style.backgroundColor=C.window.background,re.style.borderColor=C.input.border,re.style.backgroundColor=C.window.background,re.addEventListener("focus",()=>{re.style.borderColor=C.primary}),re.addEventListener("blur",()=>{re.style.borderColor=C.input.border}),me.style.backgroundColor=C.menu.background,me.style.borderColor=C.menu.border,me.style.border=`1px solid ${C.menu.border}`;me.querySelectorAll(".aptolix-menu-item").forEach(e=>{e.style.backgroundColor=C.menu.background,e.style.color=C.menu.text,e.addEventListener("mouseenter",()=>{e.style.backgroundColor=C.menu.hover}),e.addEventListener("mouseleave",()=>{e.style.backgroundColor=C.menu.background})}),ue.addEventListener("click",e=>{e.stopPropagation(),me.classList.toggle("show")}),document.addEventListener("click",e=>{ue.contains(e.target)||me.contains(e.target)||me.classList.remove("show")});const xe=G.querySelectorAll(".star");xe.forEach(e=>{e.addEventListener("mouseenter",e=>{const t=parseInt(e.target.getAttribute("data-rating"));xe.forEach((e,n)=>{e.textContent=n<t?"★":"☆"})}),e.addEventListener("click",e=>{const t=parseInt(e.target.getAttribute("data-rating"));_e(t)})});const fe=G.querySelector("#aptolix-stars");fe&&fe.addEventListener("mouseleave",()=>{xe.forEach(e=>e.textContent="☆")});const be=e=>{const t=Date.now(),n=Math.floor((t-e)/1e3);if(n<10)return"just now";if(n<60)return`${n} secs ago`;if(n<3600){const e=Math.floor(n/60);return 1===e?"1 min ago":`${e} mins ago`}if(n<86400){const e=Math.floor(n/3600);return 1===e?"1 hour ago":`${e} hours ago`}const i=Math.floor(n/86400);return 1===i?"1 day ago":`${i} days ago`};setInterval(()=>{le.querySelectorAll(".message-timestamp").forEach(e=>{const t=parseInt(e.getAttribute("data-timestamp"));e.textContent=be(t)})},6e4);const we=()=>{le.querySelectorAll(".message-text a").forEach(e=>{e.style.color=I});le.querySelectorAll(".message.user .message-text").forEach(e=>{e.style.backgroundColor=R,e.style.color=L});le.querySelectorAll(".message.bot .message-text").forEach(e=>{e.style.backgroundColor=A,e.style.color=_})},ke=new he;let ye=ke.getVisitorId(t),ve=ke.getSessionId(t),$e=0,Se=0,Te=!1;const Ce=()=>{if(!ve)return;const e=Array.from(le.querySelectorAll(".message:not(.typing):not(.error)")).map(e=>{const t=e.classList.contains("user"),n=e.classList.contains("greeting"),i=e.querySelector(".message-text"),a=e.querySelector(".message-timestamp");return{type:t?"user":"bot",text:i?i.innerHTML:"",timestamp:a?parseInt(a.getAttribute("data-timestamp")):Date.now(),isGreeting:n}});ke.saveChatHistory(t,ve,e)},Re=e=>{const t=(e=>{let t;t=10!==e.length||e.includes("T")?new Date(e):new Date(e+"T23:59:59.999Z");const n=t-new Date;if(n<=0)return"0 minutes";const i=Math.ceil(n/6e4),a=Math.floor(i/60),s=i%60;return a>0&&s>0?`${a} hour${1!==a?"s":""} and ${s} minute${1!==s?"s":""}`:a>0?`${a} hour${1!==a?"s":""}`:`${s} minute${1!==s?"s":""}`})(e),n=G.querySelector(".aptolix-limit-warning");n&&n.remove();const i=document.createElement("div");i.className="aptolix-limit-warning",i.style.cssText="\n background: linear-gradient(135deg, #fef3c7 0%, #fed7aa 100%);\n border-top: 2px solid #f59e0b;\n border-bottom: 2px solid #f59e0b;\n color: #92400e;\n padding: 6px 12px;\n font-size: 12px;\n line-height: 1.3;\n font-weight: 500;\n display: flex;\n align-items: center;\n gap: 6px;\n ",i.innerHTML=`\n <span style="font-size: 14px;">⚠️</span>\n <span>Usage limit reached. Try again in ${t}.</span>\n `;const a=G.querySelector("#aptolix-chat-input");a.parentNode.insertBefore(i,a),re.disabled=!0,re.placeholder="Chat unavailable",re.style.cursor="not-allowed",oe.disabled=!0,oe.style.opacity="0.5",oe.style.cursor="not-allowed"},Le=()=>{re.disabled=!1,re.placeholder="Type your message...",re.style.cursor="text",oe.disabled=!1,oe.style.opacity="1",oe.style.cursor="pointer";const e=G.querySelector(".aptolix-limit-warning");e&&e.remove()},Ae=(e=!1)=>{const t=G.querySelector("#aptolix-powered-by"),n=G.querySelector("#aptolix-rating"),i=G.querySelector("#aptolix-footer-separator");if(t&&n&&i)if(e){const e=t.innerHTML;t.innerHTML="✓ Thanks for your feedback!",i.classList.remove("show"),n.classList.remove("show"),setTimeout(()=>{t.innerHTML=e,Te=!1},2e3)}else i.classList.remove("show"),n.classList.remove("show"),setTimeout(()=>{Te=!1},400)},_e=async n=>{try{if(!ye||!ve)return void Ae(!0);const i={rating:n,visitor_id:ye,session_id:ve};await fetch(`${e}/chatbot/${t}/rating`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)}),Se=$e,Ae(!0)}catch(e){Ae(!0)}},Ie=()=>{if(!v.allowRating)return;$e>=v.ratingThreshold&&$e>=Se+v.ratingInterval&&(()=>{if(!v.allowRating||Te)return;const e=G.querySelector("#aptolix-rating"),t=G.querySelector("#aptolix-footer-separator");e&&t&&(Te=!0,setTimeout(()=>{t.classList.add("show"),e.classList.add("show")},10))})()};async function ze(n=!1,i=null){if(re.disabled&&!n)return;const a=i||re.value.trim();if(!a)return;if(n||(re.value="",re.rows=1,re.style.height="32px",re.style.overflowY="hidden"),!n){const e=document.createElement("div");e.className="message user";const t=Date.now();e.innerHTML=`\n <div class="message-avatar">\n ${ee}\n <div class="message-sender">${v.username}</div>\n </div>\n <div class="message-content">\n <div class="message-text" style="background-color: ${R}; color: ${L};">${a}</div>\n <span class="message-timestamp" data-timestamp="${t}">${be(t)}</span>\n </div>\n `,le.appendChild(e),le.scrollTop=le.scrollHeight,Ce()}const s=document.createElement("div");s.className="message bot typing",s.innerHTML='<span class="typing-dots"><span>.</span><span>.</span><span>.</span></span>',le.appendChild(s),le.scrollTop=le.scrollHeight;try{const n={message:a};ye&&(n.visitor_id=ye),ve&&(n.session_id=ve);const i=await fetch(`${e}/chatbot/${t}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)}),r=await i.json();if(r.visitor_id&&(ye=r.visitor_id,ke.saveVisitorId(t,ye)),r.session_id&&(ve=r.session_id,ke.saveSessionId(t,ve)),r.limitReachedDate)return ke.setUsageLimitReached(t,ye,r.limitReachedDate),s.remove(),void Re(r.limitReachedDate);s.remove();const o=document.createElement("div");o.className="message bot";const l=Date.now();o.innerHTML=`\n ${K?`<div class="message-avatar">${K}<div class="message-sender">${v.botname}</div></div>`:""}\n <div class="message-content">\n <div class="message-text" style="background-color: ${A}; color: ${_};">${pe.parse(r.response||r.text||"[No response]")}</div>\n <span class="message-timestamp" data-timestamp="${l}">${be(l)}</span>\n </div>\n `,le.appendChild(o),le.scrollTop=le.scrollHeight,we(),Ce(),$e++,Ie(),"bubble"===v.mode&&"none"===G.style.display&&V.setAttribute("data-unread","true")}catch(e){!function(){s.remove();const e=document.createElement("div");e.className="message bot error",e.innerHTML='\n <div>\n <strong>⚠️ Unable to connect to the assistant.</strong><br>\n Please check your internet connection or try again later.\n </div>\n <button class="aptolix-retry-btn">Retry</button>\n ',le.appendChild(e),le.scrollTop=le.scrollHeight;const t=e.querySelector(".aptolix-retry-btn");t&&t.addEventListener("click",()=>{e.remove(),ze(!0,a)})}(),"bubble"===v.mode&&"none"===G.style.display&&V.setAttribute("data-unread","true")}}"bubble"===v.mode&&ne.addEventListener("click",()=>{G.style.display="none"}),ie.addEventListener("click",()=>{le.innerHTML="",re.value="",ve&&(ke.clearChatHistory(t,ve),ke.clearSessionId(t),ve=null),$e=0,Se=0,Ae(!1),me.classList.remove("show");const e=ye?ke.getUsageLimitReached(t,ye):null;e&&e.limitReachedDate?(De(),Re(e.limitReachedDate)):(De(),Le()),Ce()}),"bubble"===v.mode&&V&&V.addEventListener("click",()=>{const e="none"===G.style.display;if(G.style.display=e?"flex":"none",V.removeAttribute("data-unread"),e){const e=ke.getUsageLimitReached(t,ye);e?Re(e.limitReachedDate):(Le(),De())}}),"bubble"===v.mode&&document.addEventListener("mousedown",function(e){"none"!==G.style.display&&(G.contains(e.target)||V.contains(e.target)||(G.style.display="none"))}),oe.addEventListener("click",()=>ze()),re.addEventListener("keydown",e=>{"Enter"===e.key&&(e.preventDefault(),ze())});let Ee=!1;function De(){const e=ke.getUsageLimitReached(t,ye);if(e)return void Re(e.limitReachedDate);Le(),le.querySelectorAll(".message.greeting").forEach(e=>e.remove());const n=v.greetingMessage,i=document.createElement("div");i.className="message bot greeting";const a=Date.now();i.innerHTML=`\n ${K?`<div class="message-avatar">${K}<div class="message-sender">${v.botname}</div></div>`:""}\n <div class="message-content">\n <div class="message-text" style="background-color: ${A}; color: ${_};">${n}</div>\n <span class="message-timestamp" data-timestamp="${a}">${be(a)}</span>\n </div>\n `,le.appendChild(i),le.scrollTop=le.scrollHeight,we()}"bubble"===v.mode&&ae&&ae.addEventListener("click",()=>{Ee=!Ee,Ee?(G.style.width="600px",G.style.height="80vh",se.textContent="⤡"):(G.style.width="400px",G.style.height="595px",se.textContent="⤢")}),setTimeout(function(){if(ye){const e=ke.getUsageLimitReached(t,ye);e&&e.limitReachedDate&&Re(e.limitReachedDate)}if(ve){return(ke.getChatHistory(t,ve)||[]).forEach(e=>{const t=document.createElement("div");t.className=`message ${e.type}${e.isGreeting?" greeting":""}`;const n="user"===e.type?ee:K,i="user"===e.type?v.username:v.botname,a="user"===e.type?R:A,s="user"===e.type?L:_;t.innerHTML="user"===e.type?`<div class="message-avatar">${n}<div class="message-sender">${i}</div></div><div class="message-content"><div class="message-text" style="background-color: ${a}; color: ${s};">${e.text}</div><span class="message-timestamp" data-timestamp="${e.timestamp}">${be(e.timestamp)}</span></div>`:`${n?`<div class="message-avatar">${n}<div class="message-sender">${i}</div></div>`:""}<div class="message-content"><div class="message-text" style="background-color: ${a}; color: ${s};">${e.text}</div><span class="message-timestamp" data-timestamp="${e.timestamp}">${be(e.timestamp)}</span></div>`,le.appendChild(t)}),le.scrollTop=le.scrollHeight,void we()}De()},100),re.addEventListener("input",function(){if(this.disabled)return void(this.value="");if(this.value.length>v.inputCharLimit)return void(this.value=this.value.slice(0,v.inputCharLimit));if(""===this.value)return this.rows=1,this.style.height="32px",void(this.style.overflowY="hidden");const e=this.value.split("\n");this.rows=Math.min(e.length,4);this.style.height="auto",this.style.height=Math.min(this.scrollHeight,108)+"px",this.scrollHeight>108?this.style.overflowY="auto":this.style.overflowY="hidden"}),ce&&ce.addEventListener("click",()=>{me.classList.remove("show");const e=new Date,t=e.toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"}),n=e.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit"}),i=`Chat Transcript - ${v.botname}\nWebsite: ${window.location.href}\nDownloaded on: ${t} at ${n}\n${"=".repeat(60)}\n\n`,a=Array.from(le.querySelectorAll(".message")).map(e=>{const t=e.classList.contains("user")?v.username:v.botname,n=e.querySelector(".message-text"),i=n?n.innerText||n.textContent:"",a=e.querySelector(".message-timestamp");let s="";if(a){const e=parseInt(a.getAttribute("data-timestamp"));s=new Date(e).toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",second:"2-digit"})}return`[${s}] ${t}:\n${i}`}).join("\n\n"),s=new Blob([i+a],{type:"text/plain"}),r=URL.createObjectURL(s),o=document.createElement("a");o.href=r,o.download=`${v.botname}_chat_${e.getTime()}.txt`,document.body.appendChild(o),o.click(),setTimeout(()=>{document.body.removeChild(o),URL.revokeObjectURL(r)},100)})},initFull:function(e){let t=document.querySelector("aptolix-chatbot");t&&Object.entries(e).forEach(([e,n])=>{t.setAttribute(e,n)})}};class xe extends HTMLElement{static get observedAttributes(){return["apihost","chatbotid","botname","widgeticon","companylogo","companylogourl","botavatar","botavatarurl","botaccentcolor","floatingwelcomemessage","floatingwelcomedelay","greetingmessage","allowdownloadtranscript","allowexpandchatwindow","allowfullpagechat","inputcharlimit","target"]}connectedCallback(){this.tryInit()}attributeChangedCallback(){const e=this.querySelector("#aptolix-chat-window");e&&e.remove(),this._initialized=!1,this.tryInit()}tryInit(){const e=this.getAttribute("apihost"),t=this.getAttribute("chatbotid");if(!e||!t)return;const n=this.getAttribute("botname"),i=this.getAttribute("widgeticon"),a=this.getAttribute("companylogo"),s=this.getAttribute("companylogourl"),r=this.getAttribute("botavatar"),o=this.getAttribute("botavatarurl"),l=this.getAttribute("botaccentcolor"),c=this.getAttribute("floatingwelcomemessage"),p=this.getAttribute("floatingwelcomedelay"),h=this.getAttribute("greetingmessage"),d="true"===this.getAttribute("allowdownloadtranscript"),u="true"===this.getAttribute("allowexpandchatwindow"),g="true"===this.getAttribute("allowfullpagechat"),m=parseInt(this.getAttribute("inputcharlimit"))||void 0,x=this.getAttribute("target");let f=this;if(x){const e=document.querySelector(x);e&&(f=e)}this._initialized||(this._initialized=!0,me.init({apiHost:e,chatbotId:t,botname:n,widgetIcon:i,companyLogo:a,companyLogoUrl:s,botAvatar:r,botavatarUrl:o,botaccentColor:l,floatingWelcomeMessage:c,floatingWelcomeDelay:p,greetingMessage:h,allowDownloadTranscript:d,allowExpandChatWindow:u,allowFullPageChat:g,inputCharLimit:m,mode:"section",target:f}))}}customElements.define("aptolix-chatbot",xe);export{me as default};
2
2
  //# sourceMappingURL=web.mjs.map